mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-10-30 14:30:53 -07:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			13ebd105c4
			...
			0d8f30b25c
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 0d8f30b25c | |||
| d08efcb5ef | 
| @@ -239,18 +239,18 @@ template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast( | |||||||
|  |  | ||||||
| #pragma region Code C-Interface | #pragma region Code C-Interface | ||||||
|  |  | ||||||
| GEN_API void       code_append           (Code code, Code other ); |         void       code_append           (Code code, Code other ); | ||||||
| GEN_API Str        code_debug_str        (Code code); | GEN_API Str        code_debug_str        (Code code); | ||||||
| GEN_API Code       code_duplicate        (Code code); | GEN_API Code       code_duplicate        (Code code); | ||||||
| GEN_API Code*      code_entry            (Code code, u32 idx ); |         Code*      code_entry            (Code code, u32 idx ); | ||||||
| GEN_API bool       code_has_entries      (Code code); |         bool       code_has_entries      (Code code); | ||||||
| GEN_API bool       code_is_body          (Code code); |         bool       code_is_body          (Code code); | ||||||
| GEN_API bool       code_is_equal         (Code code, Code other); | GEN_API bool       code_is_equal         (Code code, Code other); | ||||||
| GEN_API bool       code_is_valid         (Code code); |         bool       code_is_valid         (Code code); | ||||||
| GEN_API void       code_set_global       (Code code); |         void       code_set_global       (Code code); | ||||||
| GEN_API StrBuilder code_to_strbuilder    (Code self ); | GEN_API StrBuilder code_to_strbuilder    (Code self ); | ||||||
| GEN_API void       code_to_strbuilder_ptr(Code self, StrBuilder* result ); | GEN_API void       code_to_strbuilder_ptr(Code self, StrBuilder* result ); | ||||||
| GEN_API Str        code_type_str         (Code self ); |         Str        code_type_str         (Code self ); | ||||||
| GEN_API bool       code_validate_body    (Code self ); | GEN_API bool       code_validate_body    (Code self ); | ||||||
|  |  | ||||||
| #pragma endregion Code C-Interface | #pragma endregion Code C-Interface | ||||||
| @@ -399,7 +399,7 @@ struct AST | |||||||
| 				Code  Value;            // Parameter, Variable | 				Code  Value;            // Parameter, Variable | ||||||
| 			}; | 			}; | ||||||
| 			union { | 			union { | ||||||
| 				Code  NextVar;          // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value ) | 				Code  NextVar;          // Variable | ||||||
| 				Code  SuffixSpecs;      // Typename, Function (Thanks Unreal) | 				Code  SuffixSpecs;      // Typename, Function (Thanks Unreal) | ||||||
| 				Code  PostNameMacro;    // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal) | 				Code  PostNameMacro;    // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal) | ||||||
| 			}; | 			}; | ||||||
|   | |||||||
| @@ -227,7 +227,7 @@ struct AST_Enum | |||||||
| 	Code                   Parent; | 	Code                   Parent; | ||||||
| 	CodeType               Type; | 	CodeType               Type; | ||||||
| 	ModuleFlag             ModuleFlags; | 	ModuleFlag             ModuleFlags; | ||||||
| 	char                   _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; | 	char                   _PAD_UNUSED_[ sizeof(u32) ]; | ||||||
| }; | }; | ||||||
| static_assert( sizeof(AST_Enum) == sizeof(AST), "ERROR: AST_Enum is not the same size as AST"); | static_assert( sizeof(AST_Enum) == sizeof(AST), "ERROR: AST_Enum is not the same size as AST"); | ||||||
|  |  | ||||||
| @@ -738,8 +738,8 @@ static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_Preprocess | |||||||
| struct AST_Specifiers | struct AST_Specifiers | ||||||
| { | { | ||||||
| 	Specifier      ArrSpecs[ AST_ArrSpecs_Cap ]; | 	Specifier      ArrSpecs[ AST_ArrSpecs_Cap ]; | ||||||
| 	StrCached      Name; |  | ||||||
| 	CodeSpecifiers NextSpecs; | 	CodeSpecifiers NextSpecs; | ||||||
|  | 	StrCached      Name; | ||||||
| 	Code           Prev; | 	Code           Prev; | ||||||
| 	Code           Next; | 	Code           Next; | ||||||
| 	Token*         Tok; | 	Token*         Tok; | ||||||
| @@ -1056,7 +1056,7 @@ struct AST_Typename | |||||||
| 			CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures | 			CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	StrCached           Name; | 	StrCached              Name; | ||||||
| 	Code                   Prev; | 	Code                   Prev; | ||||||
| 	Code                   Next; | 	Code                   Next; | ||||||
| 	Token*                 Tok; | 	Token*                 Tok; | ||||||
| @@ -1082,7 +1082,7 @@ struct AST_Typedef | |||||||
| 			char           _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ]; | 			char           _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	StrCached           Name; | 	StrCached              Name; | ||||||
| 	Code                   Prev; | 	Code                   Prev; | ||||||
| 	Code                   Next; | 	Code                   Next; | ||||||
| 	Token*                 Tok; | 	Token*                 Tok; | ||||||
|   | |||||||
| @@ -53,7 +53,8 @@ GEN_API CodeParams end_CodeParams  (CodeParams params); | |||||||
| GEN_API CodeParams next_CodeParams (CodeParams params, CodeParams entry_iter); | GEN_API CodeParams next_CodeParams (CodeParams params, CodeParams entry_iter); | ||||||
|  |  | ||||||
| GEN_API bool       specifiers_append           (CodeSpecifiers specifiers, Specifier spec); | GEN_API bool       specifiers_append           (CodeSpecifiers specifiers, Specifier spec); | ||||||
| GEN_API s32        specifiers_has              (CodeSpecifiers specifiers, Specifier spec); | GEN_API bool       specifiers_has              (CodeSpecifiers specifiers, Specifier spec); | ||||||
|  | GEN_API s32        specifiers_index_of         (CodeSpecifiers specifiers, Specifier spec); | ||||||
| GEN_API s32        specifiers_remove           (CodeSpecifiers specifiers, Specifier to_remove ); | GEN_API s32        specifiers_remove           (CodeSpecifiers specifiers, Specifier to_remove ); | ||||||
| GEN_API StrBuilder specifiers_to_strbuilder    (CodeSpecifiers specifiers); | GEN_API StrBuilder specifiers_to_strbuilder    (CodeSpecifiers specifiers); | ||||||
| GEN_API void       specifiers_to_strbuilder_ref(CodeSpecifiers specifiers, StrBuilder* result); | GEN_API void       specifiers_to_strbuilder_ref(CodeSpecifiers specifiers, StrBuilder* result); | ||||||
| @@ -150,6 +151,8 @@ GEN_API void       using_to_strbuilder_ns (CodeUsing op_cast, StrBuilder* result | |||||||
| GEN_API StrBuilder var_to_strbuilder    (CodeVar self); | GEN_API StrBuilder var_to_strbuilder    (CodeVar self); | ||||||
| GEN_API void       var_to_strbuilder_ref(CodeVar self, StrBuilder* result); | GEN_API void       var_to_strbuilder_ref(CodeVar self, StrBuilder* result); | ||||||
|  |  | ||||||
|  | // TODO(Ed): Move C-Interface inlines here... | ||||||
|  |  | ||||||
| #pragma endregion Code Type C-Interface | #pragma endregion Code Type C-Interface | ||||||
|  |  | ||||||
| #if GEN_COMPILER_CPP | #if GEN_COMPILER_CPP | ||||||
|   | |||||||
| @@ -74,7 +74,7 @@ bool code_is_valid(Code self) | |||||||
| 	return self != nullptr && self->Type != CT_Invalid; | 	return self != nullptr && self->Type != CT_Invalid; | ||||||
| } | } | ||||||
| forceinline | forceinline | ||||||
| bool code_has_entries(AST* self) | bool code_has_entries(Code self) | ||||||
| { | { | ||||||
| 	GEN_ASSERT(self); | 	GEN_ASSERT(self); | ||||||
| 	return self->NumEntries > 0; | 	return self->NumEntries > 0; | ||||||
| @@ -169,12 +169,12 @@ void class_add_interface( CodeClass self, CodeTypename type ) | |||||||
| 		// then you'll need to move this over to ParentType->next and update ParentAccess accordingly. | 		// then you'll need to move this over to ParentType->next and update ParentAccess accordingly. | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	while ( possible_slot != nullptr ) | 	while ( possible_slot->Next != nullptr ) | ||||||
| 	{ | 	{ | ||||||
| 		possible_slot = cast(CodeTypename, possible_slot->Next); | 		possible_slot = cast(CodeTypename, possible_slot->Next); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	possible_slot = type; | 	possible_slot->Next = type; | ||||||
| } | } | ||||||
| #pragma endregion CodeClass | #pragma endregion CodeClass | ||||||
|  |  | ||||||
| @@ -296,7 +296,17 @@ bool specifiers_append(CodeSpecifiers self, Specifier spec ) | |||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
| inline | inline | ||||||
| s32 specifiers_has(CodeSpecifiers self, Specifier spec) | bool specifiers_has(CodeSpecifiers self, Specifier spec) | ||||||
|  | { | ||||||
|  | 	GEN_ASSERT(self != nullptr); | ||||||
|  | 	for ( s32 idx = 0; idx < self->NumEntries; idx++ ) { | ||||||
|  | 		if ( self->ArrSpecs[ idx ] == spec ) | ||||||
|  | 			return true; | ||||||
|  | 	} | ||||||
|  | 	return false; | ||||||
|  | } | ||||||
|  | inline | ||||||
|  | s32 specifiers_index_of(CodeSpecifiers self, Specifier spec) | ||||||
| { | { | ||||||
| 	GEN_ASSERT(self != nullptr); | 	GEN_ASSERT(self != nullptr); | ||||||
| 	for ( s32 idx = 0; idx < self->NumEntries; idx++ ) { | 	for ( s32 idx = 0; idx < self->NumEntries; idx++ ) { | ||||||
| @@ -378,12 +388,12 @@ void struct_add_interface(CodeStruct self, CodeTypename type ) | |||||||
| 		// then you'll need to move this over to ParentType->next and update ParentAccess accordingly. | 		// then you'll need to move this over to ParentType->next and update ParentAccess accordingly. | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	while ( possible_slot != nullptr ) | 	while ( possible_slot->Next != nullptr ) | ||||||
| 	{ | 	{ | ||||||
| 		possible_slot = cast(CodeTypename, possible_slot->Next); | 		possible_slot->Next = cast(CodeTypename, possible_slot->Next); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	possible_slot = type; | 	possible_slot->Next = type; | ||||||
| } | } | ||||||
| #pragma endregion Code | #pragma endregion Code | ||||||
|  |  | ||||||
|   | |||||||
| @@ -280,7 +280,7 @@ struct Opts_def_variable | |||||||
| GEN_API CodeVar def_variable( CodeTypename type, Str name, Opts_def_variable opts GEN_PARAM_DEFAULT ); | GEN_API CodeVar def_variable( CodeTypename type, Str name, Opts_def_variable opts GEN_PARAM_DEFAULT ); | ||||||
|  |  | ||||||
| // Constructs an empty body. Use AST::validate_body() to check if the body is was has valid entries. | // Constructs an empty body. Use AST::validate_body() to check if the body is was has valid entries. | ||||||
| GEN_API CodeBody def_body( CodeType type ); | CodeBody def_body( CodeType type ); | ||||||
|  |  | ||||||
| // There are two options for defining a struct body, either varadically provided with the args macro to auto-deduce the arg num, | // There are two options for defining a struct body, either varadically provided with the args macro to auto-deduce the arg num, | ||||||
| /// or provide as an array of Code objects. | /// or provide as an array of Code objects. | ||||||
| @@ -388,7 +388,7 @@ GEN_API CodeVar         parse_variable     ( Str var_def         ); | |||||||
|  |  | ||||||
| GEN_API ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va ); | GEN_API ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va ); | ||||||
| //! Do not use directly. Use the token_fmt macro instead. | //! Do not use directly. Use the token_fmt macro instead. | ||||||
| GEN_API Str token_fmt_impl( ssize, ... ); | Str   token_fmt_impl( ssize, ... ); | ||||||
|  |  | ||||||
| GEN_API Code untyped_str( Str content); | GEN_API Code untyped_str( Str content); | ||||||
| GEN_API Code untyped_fmt      ( char const* fmt, ... ); | GEN_API Code untyped_fmt      ( char const* fmt, ... ); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user