mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-10-31 06:50:53 -07:00 
			
		
		
		
	Compare commits
	
		
			18 Commits
		
	
	
		
			13ebd105c4
			...
			v0.25-Alph
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 878bc4c8ae | |||
| ec8dd1e9cd | |||
| c0ea2ce3ff | |||
| b5652a4dad | |||
| dda70fce36 | |||
| 3bce2e9b8a | |||
| f3f8f2fff2 | |||
| c600a3e0dc | |||
| 372cda734e | |||
| 6481313969 | |||
| 5c17983a73 | |||
| b6d95e8d70 | |||
| 6f2d81434e | |||
| b8695a33db | |||
| 1f958e121c | |||
| e457191f5d | |||
| 0d8f30b25c | |||
| d08efcb5ef | 
| @@ -11,6 +11,14 @@ These build up a code AST to then serialize with a file builder, or can be trave | ||||
| This code base attempts follow the [handmade philosophy](https://handmade.network/manifesto).   | ||||
| Its not meant to be a black box metaprogramming utility, it should be easy to integrate into a user's project domain. | ||||
|  | ||||
| ## Langauge Bindings | ||||
|  | ||||
| * [gencpp-odin](https://github.com/Ed94/gencpp-odin): Bindings for the odin programming language. | ||||
|  | ||||
| ## Utility Libraries | ||||
|  | ||||
| * [UnrealGencpp](https://github.com/Ed94/UnrealGencpp): Setup as a plugin to integrate into Unreal Engine or Unreal Projects. | ||||
|  | ||||
| ## Documentation | ||||
|  | ||||
| * [docs - General](./docs/Readme.md): Overview and additional docs | ||||
|   | ||||
| @@ -191,7 +191,7 @@ These require the following to be handled to the equivalent extent as the other | ||||
| 4. [ast.cpp](./components/ast.cpp): Need to review | ||||
|     * `code_debug_str` | ||||
|     * `code_is_equal` | ||||
|     * `code_to_strbuilder_ptr` | ||||
|     * `code_to_strbuilder_ref` | ||||
|     * `code_validate_body` | ||||
| 5. [code_serialization.cpp](./components/code_serialization.cpp): Define serialization here. | ||||
| 6. [inlines.hpp](./components/inlines.hpp): Any inline definitions for the `struct Code<Name>` are defined here. | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	include "builder.hpp" | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "helpers/push_ignores.inline.hpp" | ||||
| #	include "components/header_start.hpp" | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "helpers/push_ignores.inline.hpp" | ||||
| #	include "components/header_start.hpp" | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	include "scanner.hpp" | ||||
| #endif | ||||
|  | ||||
| @@ -24,7 +24,7 @@ Code scan_file( char const* path ) | ||||
| 		file_read( & file, str, fsize ); | ||||
| 		strbuilder_get_header(str)->Length = fsize; | ||||
|  | ||||
| 	// Skip GEN_INTELLISENSE_DIRECTIVES preprocessor blocks | ||||
| 	// Skip INTELLISENSE_DIRECTIVES preprocessor blocks | ||||
| 	// Its designed so that the directive should be the first thing in the file. | ||||
| 	// Anything that comes before it will also be omitted. | ||||
| 	{ | ||||
| @@ -33,7 +33,7 @@ Code scan_file( char const* path ) | ||||
| 	#define move_fwd() do { ++ scanner; -- left; } while (0) | ||||
| 		const Str directive_start = txt( "ifdef" ); | ||||
| 		const Str directive_end   = txt( "endif" ); | ||||
| 		const Str def_intellisense = txt("GEN_INTELLISENSE_DIRECTIVES" ); | ||||
| 		const Str def_intellisense = txt("INTELLISENSE_DIRECTIVES" ); | ||||
|  | ||||
| 		bool        found_directive = false; | ||||
| 		char const* scanner         = (char const*)str; | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "helpers/push_ignores.inline.hpp" | ||||
| #	include "components/header_start.hpp" | ||||
|   | ||||
| @@ -30,7 +30,7 @@ int gen_main() | ||||
| 	gen::init( & ctx); | ||||
|  | ||||
| 	CodeBody gen_component_header = def_global_body( args( | ||||
| 		def_preprocess_cond( PreprocessCond_IfDef, txt("GEN_INTELLISENSE_DIRECTIVES") ), | ||||
| 		def_preprocess_cond( PreprocessCond_IfDef, txt("INTELLISENSE_DIRECTIVES") ), | ||||
| 		pragma_once, | ||||
| 		def_include(txt("components/types.hpp")), | ||||
| 		preprocess_endif, | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "static_data.cpp" | ||||
| #endif | ||||
| @@ -379,11 +379,11 @@ Code code_duplicate(Code self) | ||||
| StrBuilder code_to_strbuilder(Code self) | ||||
| { | ||||
| 	StrBuilder result = strbuilder_make_str( _ctx->Allocator_Temp, txt("") ); | ||||
| 	code_to_strbuilder_ptr( self, & result ); | ||||
| 	code_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void code_to_strbuilder_ptr( Code self, StrBuilder* result ) | ||||
| void code_to_strbuilder_ref( Code self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self != nullptr); | ||||
| 	local_persist thread_local | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "types.hpp" | ||||
| #include "gen/ecode.hpp" | ||||
| @@ -193,6 +193,7 @@ typedef AST_Stmt_If*       CodeStmt_If; | ||||
| typedef AST_Stmt_For*      CodeStmt_For; | ||||
| typedef AST_Stmt_Goto*     CodeStmt_Goto; | ||||
| typedef AST_Stmt_Label*    CodeStmt_Label; | ||||
| typedef AST_Stmt_Lambda*   CodeStmt_Lambda; | ||||
| typedef AST_Stmt_Switch*   CodeStmt_Switch; | ||||
| typedef AST_Stmt_While*    CodeStmt_While; | ||||
| #else | ||||
| @@ -208,6 +209,7 @@ struct CodeStmt_If; | ||||
| struct CodeStmt_For; | ||||
| struct CodeStmt_Goto; | ||||
| struct CodeStmt_Label; | ||||
| struct CodeStmt_Lambda; | ||||
| struct CodeStmt_Switch; | ||||
| struct CodeStmt_While; | ||||
| #endif | ||||
| @@ -239,18 +241,18 @@ template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast( | ||||
|  | ||||
| #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 Code       code_duplicate        (Code code); | ||||
| GEN_API Code*      code_entry            (Code code, u32 idx ); | ||||
| GEN_API bool       code_has_entries      (Code code); | ||||
| GEN_API bool       code_is_body          (Code code); | ||||
|         Code*      code_entry            (Code code, u32 idx ); | ||||
|         bool       code_has_entries      (Code code); | ||||
|         bool       code_is_body          (Code code); | ||||
| GEN_API bool       code_is_equal         (Code code, Code other); | ||||
| GEN_API bool       code_is_valid         (Code code); | ||||
| GEN_API void       code_set_global       (Code code); | ||||
|         bool       code_is_valid         (Code code); | ||||
|         void       code_set_global       (Code code); | ||||
| GEN_API StrBuilder code_to_strbuilder    (Code self ); | ||||
| GEN_API void       code_to_strbuilder_ptr(Code self, StrBuilder* result ); | ||||
| GEN_API Str        code_type_str         (Code self ); | ||||
| GEN_API void       code_to_strbuilder_ref(Code self, StrBuilder* result ); | ||||
|         Str        code_type_str         (Code self ); | ||||
| GEN_API bool       code_validate_body    (Code self ); | ||||
|  | ||||
| #pragma endregion Code C-Interface | ||||
| @@ -287,7 +289,7 @@ struct Code | ||||
| 	forceinline Code*      entry(u32 idx)                    { return code_entry(* this, idx); } | ||||
| 	forceinline bool       has_entries()                     { return code_has_entries(* this); } | ||||
| 	forceinline StrBuilder to_strbuilder()                   { return code_to_strbuilder(* this); } | ||||
| 	forceinline void       to_strbuilder(StrBuilder& result) { return code_to_strbuilder_ptr(* this, & result); } | ||||
| 	forceinline void       to_strbuilder(StrBuilder& result) { return code_to_strbuilder_ref(* this, & result); } | ||||
| 	forceinline Str        type_str()                        { return code_type_str(* this); } | ||||
| 	forceinline bool       validate_body()                   { return code_validate_body(*this); } | ||||
| #endif | ||||
| @@ -399,7 +401,7 @@ struct AST | ||||
| 				Code  Value;            // Parameter, Variable | ||||
| 			}; | ||||
| 			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  PostNameMacro;    // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal) | ||||
| 			}; | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "code_types.hpp" | ||||
| #endif | ||||
| @@ -227,7 +227,7 @@ struct AST_Enum | ||||
| 	Code                   Parent; | ||||
| 	CodeType               Type; | ||||
| 	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"); | ||||
|  | ||||
| @@ -738,8 +738,8 @@ static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_Preprocess | ||||
| struct AST_Specifiers | ||||
| { | ||||
| 	Specifier      ArrSpecs[ AST_ArrSpecs_Cap ]; | ||||
| 	StrCached      Name; | ||||
| 	CodeSpecifiers NextSpecs; | ||||
| 	StrCached      Name; | ||||
| 	Code           Prev; | ||||
| 	Code           Next; | ||||
| 	Token*         Tok; | ||||
|   | ||||
| @@ -1,23 +1,8 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "ast.cpp" | ||||
| #endif | ||||
|  | ||||
| inline | ||||
| StrBuilder attributes_to_strbuilder(CodeAttributes attributes) { | ||||
| 	GEN_ASSERT(attributes); | ||||
| 	char* raw = ccast(char*, str_duplicate( attributes->Content, _ctx->Allocator_Temp ).Ptr); | ||||
| 	StrBuilder result = { raw }; | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| void attributes_to_strbuilder_ref(CodeAttributes attributes, StrBuilder* result) { | ||||
| 	GEN_ASSERT(attributes); | ||||
| 	GEN_ASSERT(result); | ||||
| 	strbuilder_append_str(result, attributes->Content); | ||||
| } | ||||
|  | ||||
| StrBuilder body_to_strbuilder(CodeBody body) | ||||
| { | ||||
| 	GEN_ASSERT(body); | ||||
| @@ -47,20 +32,6 @@ StrBuilder body_to_strbuilder(CodeBody body) | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void body_to_strbuilder_ref( CodeBody body, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(body   != nullptr); | ||||
| 	GEN_ASSERT(result != nullptr); | ||||
| 	Code curr = body->Front; | ||||
| 	s32  left = body->NumEntries; | ||||
| 	while ( left -- ) | ||||
| 	{ | ||||
| 		code_to_strbuilder_ptr(curr, result); | ||||
| 		// strbuilder_append_fmt( result, "%SB", code_to_strbuilder(curr) ); | ||||
| 		++curr; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void body_to_strbuilder_export( CodeBody body, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(body   != nullptr); | ||||
| @@ -71,7 +42,7 @@ void body_to_strbuilder_export( CodeBody body, StrBuilder* result ) | ||||
| 	s32  left = body->NumEntries; | ||||
| 	while ( left-- ) | ||||
| 	{ | ||||
| 		code_to_strbuilder_ptr(curr, result); | ||||
| 		code_to_strbuilder_ref(curr, result); | ||||
| 		// strbuilder_append_fmt( result, "%SB", code_to_strbuilder(curr) ); | ||||
| 		++curr; | ||||
| 	} | ||||
| @@ -79,23 +50,9 @@ void body_to_strbuilder_export( CodeBody body, StrBuilder* result ) | ||||
| 	strbuilder_append_fmt( result, "};\n" ); | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder comment_to_strbuilder(CodeComment comment) { | ||||
| 	GEN_ASSERT(comment); | ||||
| 	char* raw = ccast(char*, str_duplicate( comment->Content, _ctx->Allocator_Temp ).Ptr); | ||||
| 	StrBuilder result = { raw }; | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| void comment_to_strbuilder_ref(CodeComment comment, StrBuilder* result) { | ||||
| 	GEN_ASSERT(comment); | ||||
| 	GEN_ASSERT(result); | ||||
| 	strbuilder_append_str(result, comment->Content); | ||||
| } | ||||
|  | ||||
| StrBuilder constructor_to_strbuilder(CodeConstructor self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); | ||||
| 	switch (self->Type) | ||||
| 	{ | ||||
| @@ -111,6 +68,8 @@ StrBuilder constructor_to_strbuilder(CodeConstructor self) | ||||
|  | ||||
| void constructor_to_strbuilder_def(CodeConstructor self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	Code ClassStructParent = self->Parent->Parent; | ||||
| 	if (ClassStructParent) { | ||||
| 		strbuilder_append_str( result, ClassStructParent->Name ); | ||||
| @@ -135,6 +94,8 @@ void constructor_to_strbuilder_def(CodeConstructor self, StrBuilder* result ) | ||||
|  | ||||
| void constructor_to_strbuilder_fwd(CodeConstructor self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	Code ClassStructParent = self->Parent->Parent; | ||||
| 	if (ClassStructParent) { | ||||
| 		strbuilder_append_str( result, ClassStructParent->Name ); | ||||
| @@ -159,6 +120,7 @@ void constructor_to_strbuilder_fwd(CodeConstructor self, StrBuilder* result ) | ||||
|  | ||||
| StrBuilder class_to_strbuilder( CodeClass self ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); | ||||
| 	switch ( self->Type ) | ||||
| 	{ | ||||
| @@ -175,6 +137,7 @@ StrBuilder class_to_strbuilder( CodeClass self ) | ||||
| void class_to_strbuilder_def( CodeClass self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
|  | ||||
| 	if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||
| 		strbuilder_append_str( result, txt("export ") ); | ||||
| @@ -189,7 +152,7 @@ void class_to_strbuilder_def( CodeClass self, StrBuilder* result ) | ||||
| 	if ( self->Name.Len ) | ||||
| 		strbuilder_append_str( result, self->Name ); | ||||
|  | ||||
| 	if (self->Specs && specifiers_has(self->Specs, Spec_Final) > -1) | ||||
| 	if (self->Specs && specifiers_has(self->Specs, Spec_Final)) | ||||
| 		strbuilder_append_str(result, txt(" final")); | ||||
|  | ||||
| 	if ( self->ParentType ) | ||||
| @@ -222,6 +185,7 @@ void class_to_strbuilder_def( CodeClass self, StrBuilder* result ) | ||||
| void class_to_strbuilder_fwd( CodeClass self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
|  | ||||
| 	if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||
| 		strbuilder_append_str( result, txt("export ") ); | ||||
| @@ -241,13 +205,6 @@ void class_to_strbuilder_fwd( CodeClass self, StrBuilder* result ) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| StrBuilder define_to_strbuilder(CodeDefine define) | ||||
| { | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); | ||||
| 	define_to_strbuilder_ref(define, & result); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void define_to_strbuilder_ref(CodeDefine define, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(define); | ||||
| @@ -262,14 +219,6 @@ void define_to_strbuilder_ref(CodeDefine define, StrBuilder* result ) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| StrBuilder define_params_to_strbuilder(CodeDefineParams params) | ||||
| { | ||||
| 	GEN_ASSERT(params); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); | ||||
| 	define_params_to_strbuilder_ref( params, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void define_params_to_strbuilder_ref(CodeDefineParams self, StrBuilder* result) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| @@ -289,6 +238,7 @@ void define_params_to_strbuilder_ref(CodeDefineParams self, StrBuilder* result) | ||||
|  | ||||
| StrBuilder destructor_to_strbuilder(CodeDestructor self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); | ||||
| 	switch ( self->Type ) | ||||
| 	{ | ||||
| @@ -304,6 +254,8 @@ StrBuilder destructor_to_strbuilder(CodeDestructor self) | ||||
|  | ||||
| void destructor_to_strbuilder_def(CodeDestructor self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( self->Name.Len ) | ||||
| 	{ | ||||
| 		strbuilder_append_fmt( result, "%S()", self->Name ); | ||||
| @@ -323,6 +275,8 @@ void destructor_to_strbuilder_def(CodeDestructor self, StrBuilder* result ) | ||||
|  | ||||
| void destructor_to_strbuilder_fwd(CodeDestructor self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( self->Specs ) | ||||
| 	{ | ||||
| 		if ( specifiers_has(self->Specs, Spec_Virtual ) ) | ||||
| @@ -346,6 +300,7 @@ void destructor_to_strbuilder_fwd(CodeDestructor self, StrBuilder* result ) | ||||
|  | ||||
| StrBuilder enum_to_strbuilder(CodeEnum self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); | ||||
| 	switch ( self->Type ) | ||||
| 	{ | ||||
| @@ -367,6 +322,8 @@ StrBuilder enum_to_strbuilder(CodeEnum self) | ||||
|  | ||||
| void enum_to_strbuilder_def(CodeEnum self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||
| 		strbuilder_append_str( result, txt("export ") ); | ||||
|  | ||||
| @@ -400,6 +357,8 @@ void enum_to_strbuilder_def(CodeEnum self, StrBuilder* result ) | ||||
|  | ||||
| void enum_to_strbuilder_fwd(CodeEnum self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||
| 		strbuilder_append_str( result, txt("export ") ); | ||||
|  | ||||
| @@ -427,6 +386,8 @@ void enum_to_strbuilder_fwd(CodeEnum self, StrBuilder* result ) | ||||
|  | ||||
| void enum_to_strbuilder_class_def(CodeEnum self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||
| 		strbuilder_append_str( result, txt("export ") ); | ||||
|  | ||||
| @@ -459,6 +420,8 @@ void enum_to_strbuilder_class_def(CodeEnum self, StrBuilder* result ) | ||||
|  | ||||
| void enum_to_strbuilder_class_fwd(CodeEnum self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||
| 		strbuilder_append_str( result, txt("export ") ); | ||||
|  | ||||
| @@ -478,56 +441,9 @@ void enum_to_strbuilder_class_fwd(CodeEnum self, StrBuilder* result ) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| StrBuilder exec_to_strbuilder(CodeExec exec) | ||||
| { | ||||
| 	GEN_ASSERT(exec); | ||||
| 	char* raw = ccast(char*, str_duplicate( exec->Content, _ctx->Allocator_Temp ).Ptr); | ||||
| 	StrBuilder result = { raw }; | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void extern_to_strbuilder(CodeExtern self, StrBuilder* result ) | ||||
| { | ||||
| 	if ( self->Body ) | ||||
| 		strbuilder_append_fmt( result, "extern \"%S\"\n{\n%SB\n}\n", self->Name, body_to_strbuilder(self->Body) ); | ||||
| 	else | ||||
| 		strbuilder_append_fmt( result, "extern \"%S\"\n{}\n", self->Name ); | ||||
| } | ||||
|  | ||||
| StrBuilder include_to_strbuilder(CodeInclude include) | ||||
| { | ||||
| 	return strbuilder_fmt_buf( _ctx->Allocator_Temp, "#include %S\n", include->Content ); | ||||
| } | ||||
|  | ||||
| void include_to_strbuilder_ref( CodeInclude include, StrBuilder* result ) | ||||
| { | ||||
| 	strbuilder_append_fmt( result, "#include %S\n", include->Content ); | ||||
| } | ||||
|  | ||||
| StrBuilder friend_to_strbuilder(CodeFriend self) | ||||
| { | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 256 ); | ||||
| 	friend_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void friend_to_strbuilder_ref(CodeFriend self, StrBuilder* result ) | ||||
| { | ||||
| 	strbuilder_append_fmt( result, "friend %SB", code_to_strbuilder(self->Declaration) ); | ||||
|  | ||||
| 	if ( self->Declaration->Type != CT_Function && self->Declaration->Type != CT_Operator && (* result)[ strbuilder_length(* result) - 1 ] != ';' ) | ||||
| 	{ | ||||
| 		strbuilder_append_str( result, txt(";") ); | ||||
| 	} | ||||
|  | ||||
| 	if ( self->InlineCmt ) | ||||
| 		strbuilder_append_fmt( result, "  %S", self->InlineCmt->Content ); | ||||
| 	else | ||||
| 		strbuilder_append_str( result, txt("\n")); | ||||
| } | ||||
|  | ||||
| StrBuilder fn_to_strbuilder(CodeFn self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); | ||||
| 	switch ( self->Type ) | ||||
| 	{ | ||||
| @@ -543,6 +459,8 @@ StrBuilder fn_to_strbuilder(CodeFn self) | ||||
|  | ||||
| void fn_to_strbuilder_def(CodeFn self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||
| 		strbuilder_append_str( result, txt("export") ); | ||||
|  | ||||
| @@ -600,6 +518,8 @@ void fn_to_strbuilder_def(CodeFn self, StrBuilder* result ) | ||||
|  | ||||
| void fn_to_strbuilder_fwd(CodeFn self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||
| 		strbuilder_append_str( result, txt("export ") ); | ||||
|  | ||||
| @@ -649,9 +569,9 @@ void fn_to_strbuilder_fwd(CodeFn self, StrBuilder* result ) | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if ( specifiers_has(self->Specs, Spec_Pure ) >= 0 ) | ||||
| 		if ( specifiers_has(self->Specs, Spec_Pure ) ) | ||||
| 			strbuilder_append_str( result, txt(" = 0") ); | ||||
| 		else if ( specifiers_has(self->Specs, Spec_Delete ) >= 0 ) | ||||
| 		else if ( specifiers_has(self->Specs, Spec_Delete ) ) | ||||
| 			strbuilder_append_str( result, txt(" = delete") ); | ||||
| 	} | ||||
|  | ||||
| @@ -668,15 +588,10 @@ void fn_to_strbuilder_fwd(CodeFn self, StrBuilder* result ) | ||||
| 		strbuilder_append_str( result, txt(";\n") ); | ||||
| } | ||||
|  | ||||
| StrBuilder module_to_strbuilder(CodeModule self) | ||||
| { | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 64 ); | ||||
| 	module_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void module_to_strbuilder_ref(CodeModule self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if (((scast(u32, ModuleFlag_Export) & scast(u32, self->ModuleFlags)) == scast(u32, ModuleFlag_Export))) | ||||
| 		strbuilder_append_str( result, txt("export ")); | ||||
|  | ||||
| @@ -686,23 +601,9 @@ void module_to_strbuilder_ref(CodeModule self, StrBuilder* result ) | ||||
| 	strbuilder_append_fmt( result, "%S;\n", self->Name ); | ||||
| } | ||||
|  | ||||
| StrBuilder namespace_to_strbuilder(CodeNS self) | ||||
| { | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); | ||||
| 	namespace_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void namespace_to_strbuilder_ref(CodeNS self, StrBuilder* result ) | ||||
| { | ||||
| 	if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||
| 		strbuilder_append_str( result, txt("export ") ); | ||||
|  | ||||
| 	strbuilder_append_fmt( result, "namespace %S\n{\n%SB\n}\n", self->Name, body_to_strbuilder(self->Body) ); | ||||
| } | ||||
|  | ||||
| StrBuilder code_op_to_strbuilder(CodeOperator self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); | ||||
| 	switch ( self->Type ) | ||||
| 	{ | ||||
| @@ -720,6 +621,8 @@ StrBuilder code_op_to_strbuilder(CodeOperator self) | ||||
|  | ||||
| void code_op_to_strbuilder_def(CodeOperator self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||
| 		strbuilder_append_str( result, txt("export ") ); | ||||
|  | ||||
| @@ -774,6 +677,8 @@ void code_op_to_strbuilder_def(CodeOperator self, StrBuilder* result ) | ||||
|  | ||||
| void code_op_to_strbuilder_fwd(CodeOperator self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||
| 		strbuilder_append_str( result, txt("export ") ); | ||||
|  | ||||
| @@ -825,6 +730,7 @@ void code_op_to_strbuilder_fwd(CodeOperator self, StrBuilder* result ) | ||||
|  | ||||
| StrBuilder opcast_to_strbuilder(CodeOpCast self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); | ||||
| 	switch ( self->Type ) | ||||
| 	{ | ||||
| @@ -840,6 +746,8 @@ StrBuilder opcast_to_strbuilder(CodeOpCast self) | ||||
|  | ||||
| void opcast_to_strbuilder_def(CodeOpCast self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( self->Specs ) | ||||
| 	{ | ||||
| 		for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) | ||||
| @@ -877,6 +785,8 @@ void opcast_to_strbuilder_def(CodeOpCast self, StrBuilder* result ) | ||||
|  | ||||
| void opcast_to_strbuilder_fwd(CodeOpCast self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( self->Specs ) | ||||
| 	{ | ||||
| 		for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) | ||||
| @@ -912,14 +822,6 @@ void opcast_to_strbuilder_fwd(CodeOpCast self, StrBuilder* result ) | ||||
| 		strbuilder_append_fmt( result, "operator %SB();\n", typename_to_strbuilder(self->ValueType) ); | ||||
| } | ||||
|  | ||||
| StrBuilder params_to_strbuilder(CodeParams self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); | ||||
| 	params_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void params_to_strbuilder_ref( CodeParams self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| @@ -987,62 +889,6 @@ StrBuilder preprocess_to_strbuilder(CodePreprocessCond self) | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void preprocess_to_strbuilder_if(CodePreprocessCond cond, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(cond); | ||||
| 	strbuilder_append_fmt( result, "#if %S", cond->Content ); | ||||
| } | ||||
|  | ||||
| void preprocess_to_strbuilder_ifdef(CodePreprocessCond cond, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(cond); | ||||
| 	strbuilder_append_fmt( result, "#ifdef %S\n", cond->Content ); | ||||
| } | ||||
|  | ||||
| void preprocess_to_strbuilder_ifndef(CodePreprocessCond cond, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(cond); | ||||
| 	strbuilder_append_fmt( result, "#ifndef %S", cond->Content ); | ||||
| } | ||||
|  | ||||
| void preprocess_to_strbuilder_elif(CodePreprocessCond cond, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(cond); | ||||
| 	strbuilder_append_fmt( result, "#elif %S\n", cond->Content ); | ||||
| } | ||||
|  | ||||
| void preprocess_to_strbuilder_else(CodePreprocessCond cond, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(cond); | ||||
| 	strbuilder_append_str( result, txt("#else\n") ); | ||||
| } | ||||
|  | ||||
| void preprocess_to_strbuilder_endif(CodePreprocessCond cond, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(cond); | ||||
| 	strbuilder_append_str( result, txt("#endif\n") ); | ||||
| } | ||||
|  | ||||
| StrBuilder pragma_to_strbuilder(CodePragma self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 256 ); | ||||
| 	pragma_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void pragma_to_strbuilder_ref(CodePragma self, StrBuilder* result ) | ||||
| { | ||||
| 	strbuilder_append_fmt( result, "#pragma %S\n", self->Content ); | ||||
| } | ||||
|  | ||||
| StrBuilder specifiers_to_strbuilder(CodeSpecifiers self) | ||||
| { | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 64 ); | ||||
| 	specifiers_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void specifiers_to_strbuilder_ref( CodeSpecifiers self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| @@ -1155,14 +1001,6 @@ void struct_to_strbuilder_fwd( CodeStruct self, StrBuilder* result ) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| StrBuilder template_to_strbuilder(CodeTemplate self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 1024 ); | ||||
| 	template_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void template_to_strbuilder_ref(CodeTemplate self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| @@ -1176,15 +1014,10 @@ void template_to_strbuilder_ref(CodeTemplate self, StrBuilder* result ) | ||||
| 		strbuilder_append_fmt( result, "template<>\n%SB", code_to_strbuilder(self->Declaration) ); | ||||
| } | ||||
|  | ||||
| StrBuilder typedef_to_strbuilder(CodeTypedef self) | ||||
| { | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); | ||||
| 	typedef_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void typedef_to_strbuilder_ref(CodeTypedef self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||
| 		strbuilder_append_str( result, txt("export ") ); | ||||
|  | ||||
| @@ -1218,15 +1051,10 @@ void typedef_to_strbuilder_ref(CodeTypedef self, StrBuilder* result ) | ||||
| 		strbuilder_append_str( result, txt("\n")); | ||||
| } | ||||
|  | ||||
| StrBuilder typename_to_strbuilder(CodeTypename self) | ||||
| { | ||||
| 	StrBuilder result = strbuilder_make_str( _ctx->Allocator_Temp, txt("") ); | ||||
| 	typename_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void typename_to_strbuilder_ref(CodeTypename self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	#if defined(GEN_USE_NEW_TYPENAME_PARSING) | ||||
| 		if ( self->ReturnType && self->Params ) | ||||
| 		{ | ||||
| @@ -1283,6 +1111,7 @@ void typename_to_strbuilder_ref(CodeTypename self, StrBuilder* result ) | ||||
|  | ||||
| StrBuilder union_to_strbuilder(CodeUnion self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); | ||||
| 	switch ( self->Type ) | ||||
| 	{ | ||||
| @@ -1298,6 +1127,8 @@ StrBuilder union_to_strbuilder(CodeUnion self) | ||||
|  | ||||
| void union_to_strbuilder_def(CodeUnion self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||
| 		strbuilder_append_str( result, txt("export ") ); | ||||
|  | ||||
| @@ -1346,22 +1177,6 @@ void union_to_strbuilder_fwd(CodeUnion self, StrBuilder* result ) | ||||
| 		strbuilder_append_str( result, txt(";\n")); | ||||
| } | ||||
|  | ||||
| StrBuilder using_to_strbuilder(CodeUsing self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); | ||||
| 	switch ( self->Type ) | ||||
| 	{ | ||||
| 		case CT_Using: | ||||
| 			using_to_strbuilder_ref( self, & result ); | ||||
| 		break; | ||||
| 		case CT_Using_Namespace: | ||||
| 			using_to_strbuilder_ns( self, & result ); | ||||
| 		break; | ||||
| 	} | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| void using_to_strbuilder_ref(CodeUsing self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| @@ -1399,26 +1214,6 @@ void using_to_strbuilder_ref(CodeUsing self, StrBuilder* result ) | ||||
| 		strbuilder_append_str( result, txt("\n")); | ||||
| } | ||||
|  | ||||
| inline | ||||
| void using_to_strbuilder_ns(CodeUsing self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( self->InlineCmt ) | ||||
| 		strbuilder_append_fmt( result, "using namespace $SC;  %S", self->Name, self->InlineCmt->Content ); | ||||
| 	else | ||||
| 		strbuilder_append_fmt( result, "using namespace %S;\n", self->Name ); | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder var_to_strbuilder(CodeVar self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 256 ); | ||||
| 	var_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| neverinline | ||||
| void var_to_strbuilder_ref(CodeVar self, StrBuilder* result ) | ||||
| { | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "ast.hpp" | ||||
| #endif | ||||
| @@ -20,58 +20,59 @@ | ||||
| GEN_API void       body_append              ( CodeBody body, Code     other ); | ||||
| GEN_API void       body_append_body         ( CodeBody body, CodeBody other ); | ||||
| GEN_API StrBuilder body_to_strbuilder       ( CodeBody body ); | ||||
| GEN_API void       body_to_strbuilder_ref   ( CodeBody body, StrBuilder* result ); | ||||
|         void       body_to_strbuilder_ref   ( CodeBody body, StrBuilder* result ); | ||||
| GEN_API void       body_to_strbuilder_export( CodeBody body, StrBuilder* result ); | ||||
|  | ||||
| GEN_API Code begin_CodeBody( CodeBody body); | ||||
| GEN_API Code end_CodeBody  ( CodeBody body ); | ||||
| GEN_API Code next_CodeBody ( CodeBody body, Code entry_iter ); | ||||
| Code begin_CodeBody( CodeBody body); | ||||
| Code end_CodeBody  ( CodeBody body ); | ||||
| Code next_CodeBody ( CodeBody body, Code entry_iter ); | ||||
|  | ||||
| GEN_API void       class_add_interface    ( CodeClass self, CodeTypename interface ); | ||||
|         void       class_add_interface    ( CodeClass self, CodeTypename interface ); | ||||
| GEN_API StrBuilder class_to_strbuilder    ( CodeClass self ); | ||||
| GEN_API void       class_to_strbuilder_def( CodeClass self, StrBuilder* result ); | ||||
| GEN_API void       class_to_strbuilder_fwd( CodeClass self, StrBuilder* result ); | ||||
|  | ||||
| GEN_API void             define_params_append           (CodeDefineParams appendee, CodeDefineParams other ); | ||||
| GEN_API CodeDefineParams define_params_get              (CodeDefineParams params, s32 idx); | ||||
| GEN_API bool             define_params_has_entries      (CodeDefineParams params ); | ||||
| GEN_API StrBuilder       define_params_to_strbuilder    (CodeDefineParams params ); | ||||
|         void             define_params_append           (CodeDefineParams appendee, CodeDefineParams other ); | ||||
|         CodeDefineParams define_params_get              (CodeDefineParams params, s32 idx); | ||||
|         bool             define_params_has_entries      (CodeDefineParams params ); | ||||
|         StrBuilder       define_params_to_strbuilder    (CodeDefineParams params ); | ||||
| GEN_API void             define_params_to_strbuilder_ref(CodeDefineParams params, StrBuilder* result ); | ||||
|  | ||||
| GEN_API CodeDefineParams begin_CodeDefineParams(CodeDefineParams params); | ||||
| GEN_API CodeDefineParams end_CodeDefineParams  (CodeDefineParams params); | ||||
| GEN_API CodeDefineParams next_CodeDefineParams (CodeDefineParams params, CodeDefineParams entry_iter); | ||||
| CodeDefineParams begin_CodeDefineParams(CodeDefineParams params); | ||||
| CodeDefineParams end_CodeDefineParams  (CodeDefineParams params); | ||||
| CodeDefineParams next_CodeDefineParams (CodeDefineParams params, CodeDefineParams entry_iter); | ||||
|  | ||||
| GEN_API void       params_append           (CodeParams appendee, CodeParams other ); | ||||
| GEN_API CodeParams params_get              (CodeParams params, s32 idx); | ||||
| GEN_API bool       params_has_entries      (CodeParams params ); | ||||
| GEN_API StrBuilder params_to_strbuilder    (CodeParams params ); | ||||
|         void       params_append           (CodeParams appendee, CodeParams other ); | ||||
|         CodeParams params_get              (CodeParams params, s32 idx); | ||||
|         bool       params_has_entries      (CodeParams params ); | ||||
|         StrBuilder params_to_strbuilder    (CodeParams params ); | ||||
| GEN_API void       params_to_strbuilder_ref(CodeParams params, StrBuilder* result ); | ||||
|  | ||||
| GEN_API CodeParams begin_CodeParams(CodeParams params); | ||||
| GEN_API CodeParams end_CodeParams  (CodeParams params); | ||||
| GEN_API CodeParams next_CodeParams (CodeParams params, CodeParams entry_iter); | ||||
| CodeParams begin_CodeParams(CodeParams params); | ||||
| CodeParams end_CodeParams  (CodeParams params); | ||||
| CodeParams next_CodeParams (CodeParams params, CodeParams entry_iter); | ||||
|  | ||||
| GEN_API bool       specifiers_append           (CodeSpecifiers specifiers, Specifier spec); | ||||
| GEN_API s32        specifiers_has              (CodeSpecifiers specifiers, Specifier spec); | ||||
| GEN_API s32        specifiers_remove           (CodeSpecifiers specifiers, Specifier to_remove ); | ||||
| GEN_API StrBuilder specifiers_to_strbuilder    (CodeSpecifiers specifiers); | ||||
|         bool       specifiers_append           (CodeSpecifiers specifiers, Specifier spec); | ||||
|         bool       specifiers_has              (CodeSpecifiers specifiers, Specifier spec); | ||||
|         s32        specifiers_index_of         (CodeSpecifiers specifiers, Specifier spec); | ||||
|         s32        specifiers_remove           (CodeSpecifiers specifiers, Specifier to_remove ); | ||||
|         StrBuilder specifiers_to_strbuilder    (CodeSpecifiers specifiers); | ||||
| GEN_API void       specifiers_to_strbuilder_ref(CodeSpecifiers specifiers, StrBuilder* result); | ||||
|  | ||||
| GEN_API Specifier* begin_CodeSpecifiers(CodeSpecifiers specifiers); | ||||
| GEN_API Specifier* end_CodeSpecifiers  (CodeSpecifiers specifiers); | ||||
| GEN_API Specifier* next_CodeSpecifiers (CodeSpecifiers specifiers, Specifier* spec_iter); | ||||
| Specifier* begin_CodeSpecifiers(CodeSpecifiers specifiers); | ||||
| Specifier* end_CodeSpecifiers  (CodeSpecifiers specifiers); | ||||
| Specifier* next_CodeSpecifiers (CodeSpecifiers specifiers, Specifier* spec_iter); | ||||
|  | ||||
| GEN_API void       struct_add_interface    (CodeStruct self, CodeTypename interface); | ||||
|         void       struct_add_interface    (CodeStruct self, CodeTypename interface); | ||||
| GEN_API StrBuilder struct_to_strbuilder    (CodeStruct self); | ||||
| GEN_API void       struct_to_strbuilder_fwd(CodeStruct self, StrBuilder* result); | ||||
| GEN_API void       struct_to_strbuilder_def(CodeStruct self, StrBuilder* result); | ||||
|  | ||||
| GEN_API StrBuilder attributes_to_strbuilder    (CodeAttributes attributes); | ||||
| GEN_API void       attributes_to_strbuilder_ref(CodeAttributes attributes, StrBuilder* result); | ||||
|         StrBuilder attributes_to_strbuilder    (CodeAttributes attributes); | ||||
|         void       attributes_to_strbuilder_ref(CodeAttributes attributes, StrBuilder* result); | ||||
|  | ||||
| GEN_API StrBuilder comment_to_strbuilder    (CodeComment comment ); | ||||
| GEN_API void       comment_to_strbuilder_ref(CodeComment comment, StrBuilder* result ); | ||||
|         StrBuilder comment_to_strbuilder    (CodeComment comment ); | ||||
|         void       comment_to_strbuilder_ref(CodeComment comment, StrBuilder* result ); | ||||
|  | ||||
| GEN_API StrBuilder constructor_to_strbuilder    (CodeConstructor constructor); | ||||
| GEN_API void       constructor_to_strbuilder_def(CodeConstructor constructor, StrBuilder* result ); | ||||
| @@ -90,26 +91,26 @@ GEN_API void       enum_to_strbuilder_fwd      (CodeEnum self, StrBuilder* resul | ||||
| GEN_API void       enum_to_strbuilder_class_def(CodeEnum self, StrBuilder* result ); | ||||
| GEN_API void       enum_to_strbuilder_class_fwd(CodeEnum self, StrBuilder* result ); | ||||
|  | ||||
| GEN_API StrBuilder exec_to_strbuilder    (CodeExec exec); | ||||
| GEN_API void       exec_to_strbuilder_ref(CodeExec exec, StrBuilder* result); | ||||
|         StrBuilder exec_to_strbuilder    (CodeExec exec); | ||||
|         void       exec_to_strbuilder_ref(CodeExec exec, StrBuilder* result); | ||||
|  | ||||
| GEN_API void extern_to_strbuilder(CodeExtern self, StrBuilder* result); | ||||
|         void extern_to_strbuilder(CodeExtern self, StrBuilder* result); | ||||
|  | ||||
| GEN_API StrBuilder include_to_strbuilder    (CodeInclude self); | ||||
| GEN_API void       include_to_strbuilder_ref(CodeInclude self, StrBuilder* result); | ||||
|         StrBuilder include_to_strbuilder    (CodeInclude self); | ||||
|         void       include_to_strbuilder_ref(CodeInclude self, StrBuilder* result); | ||||
|  | ||||
| GEN_API StrBuilder friend_to_strbuilder     (CodeFriend self); | ||||
| GEN_API void       friend_to_strbuilder_ref(CodeFriend self, StrBuilder* result); | ||||
|         StrBuilder friend_to_strbuilder     (CodeFriend self); | ||||
|         void       friend_to_strbuilder_ref(CodeFriend self, StrBuilder* result); | ||||
|  | ||||
| GEN_API StrBuilder fn_to_strbuilder    (CodeFn self); | ||||
| GEN_API void       fn_to_strbuilder_def(CodeFn self, StrBuilder* result); | ||||
| GEN_API void       fn_to_strbuilder_fwd(CodeFn self, StrBuilder* result); | ||||
|  | ||||
| GEN_API StrBuilder module_to_strbuilder    (CodeModule self); | ||||
|         StrBuilder module_to_strbuilder    (CodeModule self); | ||||
| GEN_API void       module_to_strbuilder_ref(CodeModule self, StrBuilder* result); | ||||
|  | ||||
| GEN_API StrBuilder namespace_to_strbuilder    (CodeNS self); | ||||
| GEN_API void       namespace_to_strbuilder_ref(CodeNS self, StrBuilder* result); | ||||
|         StrBuilder namespace_to_strbuilder    (CodeNS self); | ||||
|         void       namespace_to_strbuilder_ref(CodeNS self, StrBuilder* result); | ||||
|  | ||||
| GEN_API StrBuilder code_op_to_strbuilder    (CodeOperator self); | ||||
| GEN_API void       code_op_to_strbuilder_fwd(CodeOperator self, StrBuilder* result ); | ||||
| @@ -119,37 +120,39 @@ GEN_API StrBuilder opcast_to_strbuilder     (CodeOpCast op_cast ); | ||||
| GEN_API void       opcast_to_strbuilder_def(CodeOpCast op_cast, StrBuilder* result ); | ||||
| GEN_API void       opcast_to_strbuilder_fwd(CodeOpCast op_cast, StrBuilder* result ); | ||||
|  | ||||
| GEN_API StrBuilder pragma_to_strbuilder    (CodePragma self); | ||||
| GEN_API void       pragma_to_strbuilder_ref(CodePragma self, StrBuilder* result); | ||||
|         StrBuilder pragma_to_strbuilder    (CodePragma self); | ||||
|         void       pragma_to_strbuilder_ref(CodePragma self, StrBuilder* result); | ||||
|  | ||||
| GEN_API StrBuilder preprocess_to_strbuilder       (CodePreprocessCond cond); | ||||
| GEN_API void       preprocess_to_strbuilder_if    (CodePreprocessCond cond, StrBuilder* result ); | ||||
| GEN_API void       preprocess_to_strbuilder_ifdef (CodePreprocessCond cond, StrBuilder* result ); | ||||
| GEN_API void       preprocess_to_strbuilder_ifndef(CodePreprocessCond cond, StrBuilder* result ); | ||||
| GEN_API void       preprocess_to_strbuilder_elif  (CodePreprocessCond cond, StrBuilder* result ); | ||||
| GEN_API void       preprocess_to_strbuilder_else  (CodePreprocessCond cond, StrBuilder* result ); | ||||
| GEN_API void       preprocess_to_strbuilder_endif (CodePreprocessCond cond, StrBuilder* result ); | ||||
|         void       preprocess_to_strbuilder_if    (CodePreprocessCond cond, StrBuilder* result ); | ||||
|         void       preprocess_to_strbuilder_ifdef (CodePreprocessCond cond, StrBuilder* result ); | ||||
|         void       preprocess_to_strbuilder_ifndef(CodePreprocessCond cond, StrBuilder* result ); | ||||
|         void       preprocess_to_strbuilder_elif  (CodePreprocessCond cond, StrBuilder* result ); | ||||
|         void       preprocess_to_strbuilder_else  (CodePreprocessCond cond, StrBuilder* result ); | ||||
|         void       preprocess_to_strbuilder_endif (CodePreprocessCond cond, StrBuilder* result ); | ||||
|  | ||||
| GEN_API StrBuilder template_to_strbuilder    (CodeTemplate self); | ||||
|         StrBuilder template_to_strbuilder    (CodeTemplate self); | ||||
| GEN_API void       template_to_strbuilder_ref(CodeTemplate self, StrBuilder* result); | ||||
|  | ||||
| GEN_API StrBuilder typename_to_strbuilder    (CodeTypename self); | ||||
| GEN_API void       typename_to_strbuilder_ref(CodeTypename self, StrBuilder* result); | ||||
|  | ||||
| GEN_API StrBuilder typedef_to_strbuilder    (CodeTypedef self); | ||||
|         StrBuilder typedef_to_strbuilder    (CodeTypedef self); | ||||
| GEN_API void       typedef_to_strbuilder_ref(CodeTypedef self, StrBuilder* result ); | ||||
|  | ||||
|         StrBuilder typename_to_strbuilder    (CodeTypename self); | ||||
| GEN_API void       typename_to_strbuilder_ref(CodeTypename self, StrBuilder* result); | ||||
|  | ||||
| GEN_API StrBuilder union_to_strbuilder    (CodeUnion self); | ||||
| GEN_API void       union_to_strbuilder_def(CodeUnion self, StrBuilder* result); | ||||
| GEN_API void       union_to_strbuilder_fwd(CodeUnion self, StrBuilder* result); | ||||
|  | ||||
| GEN_API StrBuilder using_to_strbuilder    (CodeUsing op_cast ); | ||||
|         StrBuilder using_to_strbuilder    (CodeUsing op_cast ); | ||||
| GEN_API void       using_to_strbuilder_ref(CodeUsing op_cast, StrBuilder* result ); | ||||
| GEN_API void       using_to_strbuilder_ns (CodeUsing op_cast, StrBuilder* result ); | ||||
|         void       using_to_strbuilder_ns (CodeUsing op_cast, StrBuilder* result ); | ||||
|  | ||||
| GEN_API StrBuilder var_to_strbuilder    (CodeVar self); | ||||
|         StrBuilder var_to_strbuilder    (CodeVar self); | ||||
| GEN_API void       var_to_strbuilder_ref(CodeVar self, StrBuilder* result); | ||||
|  | ||||
| // TODO(Ed): Move C-Interface inlines here... | ||||
|  | ||||
| #pragma endregion Code Type C-Interface | ||||
|  | ||||
| #if GEN_COMPILER_CPP | ||||
|   | ||||
							
								
								
									
										85
									
								
								base/components/constants.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								base/components/constants.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,85 @@ | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "interface.hpp" | ||||
| #endif | ||||
|  | ||||
| #pragma region Constants | ||||
| // Predefined typename codes. Are set to readonly and are setup during gen::init() | ||||
|  | ||||
| GEN_API extern Macro enum_underlying_macro; | ||||
|  | ||||
| GEN_API extern Code access_public; | ||||
| GEN_API extern Code access_protected; | ||||
| GEN_API extern Code access_private; | ||||
|  | ||||
| GEN_API extern CodeAttributes attrib_api_export; | ||||
| GEN_API extern CodeAttributes attrib_api_import; | ||||
|  | ||||
| GEN_API extern Code module_global_fragment; | ||||
| GEN_API extern Code module_private_fragment; | ||||
|  | ||||
| GEN_API extern Code fmt_newline; | ||||
|  | ||||
| GEN_API extern CodePragma pragma_once; | ||||
|  | ||||
| GEN_API extern CodeParams param_varadic; | ||||
|  | ||||
| GEN_API extern CodePreprocessCond preprocess_else; | ||||
| GEN_API extern CodePreprocessCond preprocess_endif; | ||||
|  | ||||
| GEN_API extern CodeSpecifiers spec_const; | ||||
| GEN_API extern CodeSpecifiers spec_consteval; | ||||
| GEN_API extern CodeSpecifiers spec_constexpr; | ||||
| GEN_API extern CodeSpecifiers spec_constinit; | ||||
| GEN_API extern CodeSpecifiers spec_extern_linkage; | ||||
| GEN_API extern CodeSpecifiers spec_final; | ||||
| GEN_API extern CodeSpecifiers spec_forceinline; | ||||
| GEN_API extern CodeSpecifiers spec_global; | ||||
| GEN_API extern CodeSpecifiers spec_inline; | ||||
| GEN_API extern CodeSpecifiers spec_internal_linkage; | ||||
| GEN_API extern CodeSpecifiers spec_local_persist; | ||||
| GEN_API extern CodeSpecifiers spec_mutable; | ||||
| GEN_API extern CodeSpecifiers spec_neverinline; | ||||
| GEN_API extern CodeSpecifiers spec_noexcept; | ||||
| GEN_API extern CodeSpecifiers spec_override; | ||||
| GEN_API extern CodeSpecifiers spec_ptr; | ||||
| GEN_API extern CodeSpecifiers spec_pure; | ||||
| GEN_API extern CodeSpecifiers spec_ref; | ||||
| GEN_API extern CodeSpecifiers spec_register; | ||||
| GEN_API extern CodeSpecifiers spec_rvalue; | ||||
| GEN_API extern CodeSpecifiers spec_static_member; | ||||
| GEN_API extern CodeSpecifiers spec_thread_local; | ||||
| GEN_API extern CodeSpecifiers spec_virtual; | ||||
| GEN_API extern CodeSpecifiers spec_volatile; | ||||
|  | ||||
| GEN_API extern CodeTypename t_empty; // Used with varaidc parameters. (Exposing just in case its useful for another circumstance) | ||||
| GEN_API extern CodeTypename t_auto; | ||||
| GEN_API extern CodeTypename t_void; | ||||
| GEN_API extern CodeTypename t_int; | ||||
| GEN_API extern CodeTypename t_bool; | ||||
| GEN_API extern CodeTypename t_char; | ||||
| GEN_API extern CodeTypename t_wchar_t; | ||||
| GEN_API extern CodeTypename t_class; | ||||
| GEN_API extern CodeTypename t_typename; | ||||
|  | ||||
| #ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS | ||||
| 	GEN_API extern CodeTypename t_b32; | ||||
|  | ||||
| 	GEN_API extern CodeTypename t_s8; | ||||
| 	GEN_API extern CodeTypename t_s16; | ||||
| 	GEN_API extern CodeTypename t_s32; | ||||
| 	GEN_API extern CodeTypename t_s64; | ||||
|  | ||||
| 	GEN_API extern CodeTypename t_u8; | ||||
| 	GEN_API extern CodeTypename t_u16; | ||||
| 	GEN_API extern CodeTypename t_u32; | ||||
| 	GEN_API extern CodeTypename t_u64; | ||||
|  | ||||
| 	GEN_API extern CodeTypename t_ssize; | ||||
| 	GEN_API extern CodeTypename t_usize; | ||||
|  | ||||
| 	GEN_API extern CodeTypename t_f32; | ||||
| 	GEN_API extern CodeTypename t_f64; | ||||
| #endif | ||||
|  | ||||
| #pragma endregion Constants | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "components/types.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "components/types.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "components/types.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "components/types.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "components/types.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,88 +0,0 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "inlines.hpp" | ||||
| #include "gen/ast_inlines.hpp" | ||||
| #endif | ||||
|  | ||||
| #pragma region Constants | ||||
|  | ||||
| GEN_API extern Macro enum_underlying_macro; | ||||
|  | ||||
| GEN_API extern Code access_public; | ||||
| GEN_API extern Code access_protected; | ||||
| GEN_API extern Code access_private; | ||||
|  | ||||
| GEN_API extern CodeAttributes attrib_api_export; | ||||
| GEN_API extern CodeAttributes attrib_api_import; | ||||
|  | ||||
| GEN_API extern Code module_global_fragment; | ||||
| GEN_API extern Code module_private_fragment; | ||||
|  | ||||
| GEN_API extern Code fmt_newline; | ||||
|  | ||||
| GEN_API extern CodePragma pragma_once; | ||||
|  | ||||
| GEN_API extern CodeParams param_varadic; | ||||
|  | ||||
| GEN_API extern CodePreprocessCond preprocess_else; | ||||
| GEN_API extern CodePreprocessCond preprocess_endif; | ||||
|  | ||||
| GEN_API extern CodeSpecifiers spec_const; | ||||
| GEN_API extern CodeSpecifiers spec_consteval; | ||||
| GEN_API extern CodeSpecifiers spec_constexpr; | ||||
| GEN_API extern CodeSpecifiers spec_constinit; | ||||
| GEN_API extern CodeSpecifiers spec_extern_linkage; | ||||
| GEN_API extern CodeSpecifiers spec_final; | ||||
| GEN_API extern CodeSpecifiers spec_forceinline; | ||||
| GEN_API extern CodeSpecifiers spec_global; | ||||
| GEN_API extern CodeSpecifiers spec_inline; | ||||
| GEN_API extern CodeSpecifiers spec_internal_linkage; | ||||
| GEN_API extern CodeSpecifiers spec_local_persist; | ||||
| GEN_API extern CodeSpecifiers spec_mutable; | ||||
| GEN_API extern CodeSpecifiers spec_neverinline; | ||||
| GEN_API extern CodeSpecifiers spec_noexcept; | ||||
| GEN_API extern CodeSpecifiers spec_override; | ||||
| GEN_API extern CodeSpecifiers spec_ptr; | ||||
| GEN_API extern CodeSpecifiers spec_pure; | ||||
| GEN_API extern CodeSpecifiers spec_ref; | ||||
| GEN_API extern CodeSpecifiers spec_register; | ||||
| GEN_API extern CodeSpecifiers spec_rvalue; | ||||
| GEN_API extern CodeSpecifiers spec_static_member; | ||||
| GEN_API extern CodeSpecifiers spec_thread_local; | ||||
| GEN_API extern CodeSpecifiers spec_virtual; | ||||
| GEN_API extern CodeSpecifiers spec_volatile; | ||||
|  | ||||
| GEN_API extern CodeTypename t_empty; // Used with varaidc parameters. (Exposing just in case its useful for another circumstance) | ||||
| GEN_API extern CodeTypename t_auto; | ||||
| GEN_API extern CodeTypename t_void; | ||||
| GEN_API extern CodeTypename t_int; | ||||
| GEN_API extern CodeTypename t_bool; | ||||
| GEN_API extern CodeTypename t_char; | ||||
| GEN_API extern CodeTypename t_wchar_t; | ||||
| GEN_API extern CodeTypename t_class; | ||||
| GEN_API extern CodeTypename t_typename; | ||||
|  | ||||
| #ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS | ||||
| 	// Predefined typename codes. Are set to readonly and are setup during gen::init() | ||||
| 	GEN_API extern Context* _ctx; | ||||
|  | ||||
| 	GEN_API extern CodeTypename t_b32; | ||||
|  | ||||
| 	GEN_API extern CodeTypename t_s8; | ||||
| 	GEN_API extern CodeTypename t_s16; | ||||
| 	GEN_API extern CodeTypename t_s32; | ||||
| 	GEN_API extern CodeTypename t_s64; | ||||
|  | ||||
| 	GEN_API extern CodeTypename t_u8; | ||||
| 	GEN_API extern CodeTypename t_u16; | ||||
| 	GEN_API extern CodeTypename t_u32; | ||||
| 	GEN_API extern CodeTypename t_u64; | ||||
|  | ||||
| 	GEN_API extern CodeTypename t_ssize; | ||||
| 	GEN_API extern CodeTypename t_usize; | ||||
|  | ||||
| 	GEN_API extern CodeTypename t_f32; | ||||
| 	GEN_API extern CodeTypename t_f64; | ||||
| #endif | ||||
|  | ||||
| #pragma endregion Constants | ||||
|   | ||||
| @@ -15,7 +15,7 @@ | ||||
| 	|  \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l                       | | ||||
| 	|                        | |   | |                      __} |                                  | | ||||
| 	|                        l_l   l_l                     {___/                                   | | ||||
| 	! ----------------------------------------------------------------------- VERSION: v0.23-Alpha | | ||||
| 	! ----------------------------------------------------------------------- VERSION: v0.25-Alpha | | ||||
| 	! ============================================================================================ | | ||||
| 	! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION                 | | ||||
| 	! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL | | ||||
|   | ||||
| @@ -1,8 +1,318 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "interface.hpp" | ||||
| #endif | ||||
|  | ||||
| #pragma region Serialization | ||||
| inline | ||||
| StrBuilder attributes_to_strbuilder(CodeAttributes attributes) { | ||||
| 	GEN_ASSERT(attributes); | ||||
| 	char* raw = ccast(char*, str_duplicate( attributes->Content, get_context()->Allocator_Temp ).Ptr); | ||||
| 	StrBuilder result = { raw }; | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| void attributes_to_strbuilder_ref(CodeAttributes attributes, StrBuilder* result) { | ||||
| 	GEN_ASSERT(attributes); | ||||
| 	GEN_ASSERT(result); | ||||
| 	strbuilder_append_str(result, attributes->Content); | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder comment_to_strbuilder(CodeComment comment) { | ||||
| 	GEN_ASSERT(comment); | ||||
| 	char* raw = ccast(char*, str_duplicate( comment->Content, get_context()->Allocator_Temp ).Ptr); | ||||
| 	StrBuilder result = { raw }; | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| void body_to_strbuilder_ref( CodeBody body, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(body   != nullptr); | ||||
| 	GEN_ASSERT(result != nullptr); | ||||
| 	Code curr = body->Front; | ||||
| 	s32  left = body->NumEntries; | ||||
| 	while ( left -- ) | ||||
| 	{ | ||||
| 		code_to_strbuilder_ref(curr, result); | ||||
| 		// strbuilder_append_fmt( result, "%SB", code_to_strbuilder(curr) ); | ||||
| 		++curr; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| inline | ||||
| void comment_to_strbuilder_ref(CodeComment comment, StrBuilder* result) { | ||||
| 	GEN_ASSERT(comment); | ||||
| 	GEN_ASSERT(result); | ||||
| 	strbuilder_append_str(result, comment->Content); | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder define_to_strbuilder(CodeDefine define) | ||||
| { | ||||
| 	GEN_ASSERT(define); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); | ||||
| 	define_to_strbuilder_ref(define, & result); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder define_params_to_strbuilder(CodeDefineParams params) | ||||
| { | ||||
| 	GEN_ASSERT(params); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); | ||||
| 	define_params_to_strbuilder_ref( params, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder exec_to_strbuilder(CodeExec exec) | ||||
| { | ||||
| 	GEN_ASSERT(exec); | ||||
| 	char* raw = ccast(char*, str_duplicate( exec->Content, _ctx->Allocator_Temp ).Ptr); | ||||
| 	StrBuilder result = { raw }; | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| void exec_to_strbuilder_ref(CodeExec exec, StrBuilder* result) { | ||||
| 	GEN_ASSERT(exec); | ||||
| 	GEN_ASSERT(result); | ||||
| 	strbuilder_append_str(result, exec->Content); | ||||
| } | ||||
|  | ||||
| inline | ||||
| void extern_to_strbuilder(CodeExtern self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( self->Body ) | ||||
| 		strbuilder_append_fmt( result, "extern \"%S\"\n{\n%SB\n}\n", self->Name, body_to_strbuilder(self->Body) ); | ||||
| 	else | ||||
| 		strbuilder_append_fmt( result, "extern \"%S\"\n{}\n", self->Name ); | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder friend_to_strbuilder(CodeFriend self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 256 ); | ||||
| 	friend_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| void friend_to_strbuilder_ref(CodeFriend self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	strbuilder_append_fmt( result, "friend %SB", code_to_strbuilder(self->Declaration) ); | ||||
|  | ||||
| 	if ( self->Declaration->Type != CT_Function && self->Declaration->Type != CT_Operator && (* result)[ strbuilder_length(* result) - 1 ] != ';' ) | ||||
| 	{ | ||||
| 		strbuilder_append_str( result, txt(";") ); | ||||
| 	} | ||||
|  | ||||
| 	if ( self->InlineCmt ) | ||||
| 		strbuilder_append_fmt( result, "  %S", self->InlineCmt->Content ); | ||||
| 	else | ||||
| 		strbuilder_append_str( result, txt("\n")); | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder include_to_strbuilder(CodeInclude include) | ||||
| { | ||||
| 	GEN_ASSERT(include); | ||||
| 	return strbuilder_fmt_buf( _ctx->Allocator_Temp, "#include %S\n", include->Content ); | ||||
| } | ||||
|  | ||||
| inline | ||||
| void include_to_strbuilder_ref( CodeInclude include, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(include); | ||||
| 	GEN_ASSERT(result); | ||||
| 	strbuilder_append_fmt( result, "#include %S\n", include->Content ); | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder module_to_strbuilder(CodeModule self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 64 ); | ||||
| 	module_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder namespace_to_strbuilder(CodeNS self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); | ||||
| 	namespace_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| void namespace_to_strbuilder_ref(CodeNS self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||
| 		strbuilder_append_str( result, txt("export ") ); | ||||
|  | ||||
| 	strbuilder_append_fmt( result, "namespace %S\n{\n%SB\n}\n", self->Name, body_to_strbuilder(self->Body) ); | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder params_to_strbuilder(CodeParams self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); | ||||
| 	params_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder pragma_to_strbuilder(CodePragma self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 256 ); | ||||
| 	pragma_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| void pragma_to_strbuilder_ref(CodePragma self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	strbuilder_append_fmt( result, "#pragma %S\n", self->Content ); | ||||
| } | ||||
|  | ||||
| inline | ||||
| void preprocess_to_strbuilder_if(CodePreprocessCond cond, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(cond); | ||||
| 	GEN_ASSERT(result); | ||||
| 	strbuilder_append_fmt( result, "#if %S", cond->Content ); | ||||
| } | ||||
|  | ||||
| inline | ||||
| void preprocess_to_strbuilder_ifdef(CodePreprocessCond cond, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(cond); | ||||
| 	GEN_ASSERT(result); | ||||
| 	strbuilder_append_fmt( result, "#ifdef %S\n", cond->Content ); | ||||
| } | ||||
|  | ||||
| inline | ||||
| void preprocess_to_strbuilder_ifndef(CodePreprocessCond cond, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(cond); | ||||
| 	GEN_ASSERT(result); | ||||
| 	strbuilder_append_fmt( result, "#ifndef %S", cond->Content ); | ||||
| } | ||||
|  | ||||
| inline | ||||
| void preprocess_to_strbuilder_elif(CodePreprocessCond cond, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(cond); | ||||
| 	GEN_ASSERT(result); | ||||
| 	strbuilder_append_fmt( result, "#elif %S\n", cond->Content ); | ||||
| } | ||||
|  | ||||
| inline | ||||
| void preprocess_to_strbuilder_else(CodePreprocessCond cond, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(cond); | ||||
| 	GEN_ASSERT(result); | ||||
| 	strbuilder_append_str( result, txt("#else\n") ); | ||||
| } | ||||
|  | ||||
| inline | ||||
| void preprocess_to_strbuilder_endif(CodePreprocessCond cond, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(cond); | ||||
| 	GEN_ASSERT(result); | ||||
| 	strbuilder_append_str( result, txt("#endif\n") ); | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder specifiers_to_strbuilder(CodeSpecifiers self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 64 ); | ||||
| 	specifiers_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder template_to_strbuilder(CodeTemplate self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 1024 ); | ||||
| 	template_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder typedef_to_strbuilder(CodeTypedef self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); | ||||
| 	typedef_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder typename_to_strbuilder(CodeTypename self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_str( _ctx->Allocator_Temp, txt("") ); | ||||
| 	typename_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder using_to_strbuilder(CodeUsing self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); | ||||
| 	switch ( self->Type ) | ||||
| 	{ | ||||
| 		case CT_Using: | ||||
| 			using_to_strbuilder_ref( self, & result ); | ||||
| 		break; | ||||
| 		case CT_Using_Namespace: | ||||
| 			using_to_strbuilder_ns( self, & result ); | ||||
| 		break; | ||||
| 	} | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| void using_to_strbuilder_ns(CodeUsing self, StrBuilder* result ) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	GEN_ASSERT(result); | ||||
| 	if ( self->InlineCmt ) | ||||
| 		strbuilder_append_fmt( result, "using namespace $S;  %S", self->Name, self->InlineCmt->Content ); | ||||
| 	else | ||||
| 		strbuilder_append_fmt( result, "using namespace %S;\n", self->Name ); | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder var_to_strbuilder(CodeVar self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	StrBuilder result = strbuilder_make_reserve( get_context()->Allocator_Temp, 256 ); | ||||
| 	var_to_strbuilder_ref( self, & result ); | ||||
| 	return result; | ||||
| } | ||||
| #pragma endregion Serialization | ||||
|  | ||||
| #pragma region Code | ||||
| inline | ||||
| void code_append( Code self, Code other ) | ||||
| @@ -74,7 +384,7 @@ bool code_is_valid(Code self) | ||||
| 	return self != nullptr && self->Type != CT_Invalid; | ||||
| } | ||||
| forceinline | ||||
| bool code_has_entries(AST* self) | ||||
| bool code_has_entries(Code self) | ||||
| { | ||||
| 	GEN_ASSERT(self); | ||||
| 	return self->NumEntries > 0; | ||||
| @@ -169,12 +479,12 @@ void class_add_interface( CodeClass self, CodeTypename type ) | ||||
| 		// 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 = type; | ||||
| 	possible_slot->Next = cast(Code, type); | ||||
| } | ||||
| #pragma endregion CodeClass | ||||
|  | ||||
| @@ -296,7 +606,17 @@ bool specifiers_append(CodeSpecifiers self, Specifier spec ) | ||||
| 	return true; | ||||
| } | ||||
| 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); | ||||
| 	for ( s32 idx = 0; idx < self->NumEntries; idx++ ) { | ||||
| @@ -378,12 +698,12 @@ void struct_add_interface(CodeStruct self, CodeTypename type ) | ||||
| 		// 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 = type; | ||||
| 	possible_slot->Next = cast(Code, type); | ||||
| } | ||||
| #pragma endregion Code | ||||
|  | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "code_serialization.cpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "ast_types.hpp" | ||||
| #endif | ||||
| @@ -99,6 +99,11 @@ struct Context | ||||
| 	s32 temp_serialize_indent; | ||||
| }; | ||||
|  | ||||
| // TODO(Ed): Eventually this library should opt out of an implicit context for baseline implementation | ||||
| // This would automatically make it viable for multi-threaded purposes among other things | ||||
| // An implicit context interface will be provided instead as wrapper procedures as convience. | ||||
| GEN_API extern Context* _ctx; | ||||
|  | ||||
| // Initialize the library. There first ctx initialized must exist for lifetime of other contextes that come after as its the one that | ||||
| GEN_API void init(Context* ctx); | ||||
|  | ||||
| @@ -194,7 +199,7 @@ GEN_API CodeEnum def_enum( Str name, Opts_def_enum opts GEN_PARAM_DEFAULT ); | ||||
|  | ||||
| GEN_API CodeExec   def_execution  ( Str content ); | ||||
| GEN_API CodeExtern def_extern_link( Str name, CodeBody body ); | ||||
| GEN_API CodeFriend def_friend     ( Code symbol ); | ||||
| GEN_API CodeFriend def_friend     ( Code code ); | ||||
|  | ||||
| struct Opts_def_function { | ||||
| 	CodeParams      params; | ||||
| @@ -244,7 +249,7 @@ GEN_API CodeTemplate def_template( CodeParams params, Code definition, Opts_def_ | ||||
|  | ||||
| struct Opts_def_type { | ||||
| 	ETypenameTag   type_tag; | ||||
| 	Code           arrayexpr; | ||||
| 	Code           array_expr; | ||||
| 	CodeSpecifiers specifiers; | ||||
| 	CodeAttributes attributes; | ||||
| }; | ||||
| @@ -280,7 +285,7 @@ struct Opts_def_variable | ||||
| 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. | ||||
| 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, | ||||
| /// or provide as an array of Code objects. | ||||
| @@ -388,7 +393,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 ); | ||||
| //! 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_fmt      ( char const* fmt, ... ); | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "gen/etoktype.cpp" | ||||
| #include "interface.upfront.cpp" | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "interface.parsing.cpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "interface.cpp" | ||||
| #endif | ||||
| @@ -1114,7 +1114,7 @@ CodeTypename def_type( Str name, Opts_def_type p ) | ||||
| 		GEN_DEBUG_TRAP(); | ||||
| 		return InvalidCode; | ||||
| 	} | ||||
| 	Code           arrayexpr  = p.arrayexpr; | ||||
| 	Code           array_expr = p.array_expr; | ||||
| 	CodeSpecifiers specifiers = p.specifiers; | ||||
| 	CodeAttributes attributes = p.attributes; | ||||
| 	if ( p.attributes && p.attributes->Type != CT_PlatformAttributes ) { | ||||
| @@ -1127,8 +1127,8 @@ CodeTypename def_type( Str name, Opts_def_type p ) | ||||
| 		GEN_DEBUG_TRAP(); | ||||
| 		return InvalidCode; | ||||
| 	} | ||||
| 	if ( p.arrayexpr && p.arrayexpr->Type != CT_Untyped ) { | ||||
| 		log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", code_debug_str((Code)p.arrayexpr) ); | ||||
| 	if ( p.array_expr && p.array_expr->Type != CT_Untyped ) { | ||||
| 		log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", code_debug_str((Code)p.array_expr) ); | ||||
| 		GEN_DEBUG_TRAP(); | ||||
| 		return InvalidCode; | ||||
| 	} | ||||
| @@ -1138,7 +1138,7 @@ CodeTypename def_type( Str name, Opts_def_type p ) | ||||
| 	result->Type       = CT_Typename; | ||||
| 	result->Attributes = p.attributes; | ||||
| 	result->Specs      = p.specifiers; | ||||
| 	result->ArrExpr    = p.arrayexpr; | ||||
| 	result->ArrExpr    = p.array_expr; | ||||
| 	result->TypeTag    = p.type_tag; | ||||
| 	return result; | ||||
| } | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "interface.upfront.cpp" | ||||
| #include "gen/etoktype.cpp" | ||||
| @@ -488,6 +488,10 @@ void lex_found_token( LexContext* ctx ) | ||||
|  | ||||
| 	TokType type = str_to_toktype( ctx->token.Text ); | ||||
|  | ||||
| 	if (type == Tok_Preprocess_Define || type == Tok_Preprocess_Include) { | ||||
| 		ctx->token.Flags |= TF_Identifier; | ||||
| 	} | ||||
|  | ||||
| 	if (type <= Tok_Access_Public && type >= Tok_Access_Private ) { | ||||
| 		ctx->token.Flags |= TF_AccessSpecifier; | ||||
| 	} | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "gen/etoktype.cpp" | ||||
| #include "parser_case_macros.cpp" | ||||
| @@ -1365,7 +1365,9 @@ Code parse_assignment_expression() | ||||
| 		eat( currtok.Type ); | ||||
| 	} | ||||
|  | ||||
| 	if (left) { | ||||
| 		expr_tok.Text.Len = ( ( sptr )currtok.Text.Ptr + currtok.Text.Len ) - ( sptr )expr_tok.Text.Ptr - 1; | ||||
| 	} | ||||
| 	expr = untyped_str( expr_tok.Text ); | ||||
| 	// = <Expression> | ||||
| 	return expr; | ||||
| @@ -2788,10 +2790,10 @@ CodeParams parse_params( bool use_template_capture ) | ||||
| 		} | ||||
| 		// ( <Macro> <ValueType> | ||||
|  | ||||
| 		if ( check( Tok_Identifier ) ) | ||||
| 		if ( check( Tok_Identifier ) || bitfield_is_set(u32, currtok.Flags, TF_Identifier) ) | ||||
| 		{ | ||||
| 			name = currtok; | ||||
| 			eat( Tok_Identifier ); | ||||
| 			eat( currtok.Type ); | ||||
| 			// ( <Macro> <ValueType> <Name> | ||||
| 		} | ||||
|  | ||||
| @@ -2899,10 +2901,10 @@ CodeParams parse_params( bool use_template_capture ) | ||||
|  | ||||
| 			name = NullToken; | ||||
|  | ||||
| 			if ( check( Tok_Identifier ) ) | ||||
| 			if ( check( Tok_Identifier ) || bitfield_is_set(u32, currtok.Flags, TF_Identifier) ) | ||||
| 			{ | ||||
| 				name = currtok; | ||||
| 				eat( Tok_Identifier ); | ||||
| 				eat( currtok.Type ); | ||||
| 				// ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <Name> | ||||
| 			} | ||||
|  | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "types.hpp" | ||||
| #include "gen/ecode.hpp" | ||||
| @@ -11,17 +11,18 @@ enum TokFlags : u32 | ||||
| { | ||||
| 	TF_Operator              = bit(0), | ||||
| 	TF_Assign                = bit(1), | ||||
| 	TF_Preprocess            = bit(2), | ||||
| 	TF_Preprocess_Cond       = bit(3), | ||||
| 	TF_Attribute             = bit(6), | ||||
| 	TF_AccessOperator        = bit(7), | ||||
| 	TF_AccessSpecifier       = bit(8), | ||||
| 	TF_Specifier             = bit(9), | ||||
| 	TF_EndDefinition         = bit(10),    // Either ; or } | ||||
| 	TF_Formatting            = bit(11), | ||||
| 	TF_Literal               = bit(12), | ||||
| 	TF_Macro_Functional      = bit(13), | ||||
| 	TF_Macro_Expects_Body    = bit(14), | ||||
| 	TF_Identifier            = bit(2), | ||||
| 	TF_Preprocess            = bit(3), | ||||
| 	TF_Preprocess_Cond       = bit(4), | ||||
| 	TF_Attribute             = bit(5), | ||||
| 	TF_AccessOperator        = bit(6), | ||||
| 	TF_AccessSpecifier       = bit(7), | ||||
| 	TF_Specifier             = bit(8), | ||||
| 	TF_EndDefinition         = bit(9),    // Either ; or } | ||||
| 	TF_Formatting            = bit(10), | ||||
| 	TF_Literal               = bit(11), | ||||
| 	TF_Macro_Functional      = bit(12), | ||||
| 	TF_Macro_Expects_Body    = bit(13), | ||||
|  | ||||
| 	TF_Null = 0, | ||||
| 	TF_UnderlyingType = GEN_U32_MAX, | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "../gen.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "header_start.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "macros.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "printing.hpp" | ||||
| #endif | ||||
| @@ -416,7 +416,7 @@ bool array_set_capacity(Array<Type>* array, usize new_capacity) | ||||
| // These are intended for use in the base library of gencpp and the C-variant of the library | ||||
| // It provides a interoperability between the C++ and C implementation of arrays. (not letting these do any crazy substiution though) | ||||
| // They are undefined in gen.hpp and gen.cpp at the end of the files. | ||||
| // We cpp library expects the user to use the regular calls as they can resolve the type fine. | ||||
| // The cpp library expects the user to use the regular calls as they can resolve the type fine. | ||||
|  | ||||
| #define array_init(type, allocator)                        array_init           <type>                               (allocator ) | ||||
| #define array_init_reserve(type, allocator, cap)           array_init_reserve   <type>                               (allocator, cap) | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #   include "src_start.cpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "dependencies/platform.hpp" | ||||
| #	include "dependencies/macros.hpp" | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "strings.cpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "strings.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "memory.cpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "containers.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #   pragma once | ||||
| #	include "platform.hpp" | ||||
| #endif | ||||
| @@ -26,7 +26,7 @@ | ||||
| #endif // GEN_API | ||||
|  | ||||
| #ifndef global // Global variables | ||||
| #	ifdef GEN_DYN_EXPORT | ||||
| #	if defined(GEN_STATIC_LINK) || defined(GEN_DYN_LINK) | ||||
| #		define global          | ||||
| #	else | ||||
| #		define global static | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "printing.cpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "debug.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "parsing.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "timing.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "strbuilder_ops.cpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "strbuilder_ops.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "header_start.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "debug.cpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "memory.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "hashing.cpp" | ||||
| #endif | ||||
| @@ -58,4 +58,120 @@ StrBuilder strbuilder_make_reserve( AllocatorInfo allocator, ssize capacity ) | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| bool strbuilder_make_space_for(StrBuilder* str, char const* to_append, ssize add_len) | ||||
| { | ||||
| 	ssize available = strbuilder_avail_space(* str); | ||||
|  | ||||
| 	if (available >= add_len) { | ||||
| 		return true; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		ssize new_len, old_size, new_size; | ||||
| 		void* ptr; | ||||
| 		void* new_ptr; | ||||
|  | ||||
| 		AllocatorInfo allocator = strbuilder_get_header(* str)->Allocator; | ||||
| 		StrBuilderHeader* header    = nullptr; | ||||
|  | ||||
| 		new_len  = strbuilder_grow_formula(strbuilder_length(* str) + add_len); | ||||
| 		ptr      = strbuilder_get_header(* str); | ||||
| 		old_size = size_of(StrBuilderHeader) + strbuilder_length(* str) + 1; | ||||
| 		new_size = size_of(StrBuilderHeader) + new_len + 1; | ||||
|  | ||||
| 		new_ptr = resize(allocator, ptr, old_size, new_size); | ||||
|  | ||||
| 		if (new_ptr == nullptr) | ||||
| 			return false; | ||||
|  | ||||
| 		header = rcast(StrBuilderHeader*, new_ptr); | ||||
| 		header->Allocator = allocator; | ||||
| 		header->Capacity  = new_len; | ||||
|  | ||||
| 		char** Data = rcast(char**, str); | ||||
| 		* Data = rcast(char*, header + 1); | ||||
|  | ||||
| 		return true; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| bool strbuilder_append_c_str_len(StrBuilder* str, char const* c_str_to_append, ssize append_length) | ||||
| { | ||||
| 	GEN_ASSERT(str != nullptr); | ||||
| 	if ( rcast(sptr, c_str_to_append) > 0) | ||||
| 	{ | ||||
| 		ssize curr_len = strbuilder_length(* str); | ||||
|  | ||||
| 		if ( ! strbuilder_make_space_for(str, c_str_to_append, append_length)) | ||||
| 			return false; | ||||
|  | ||||
| 		StrBuilderHeader* header = strbuilder_get_header(* str); | ||||
|  | ||||
| 		char* Data = * str; | ||||
| 		mem_copy( Data + curr_len, c_str_to_append, append_length); | ||||
|  | ||||
| 		Data[curr_len + append_length] = '\0'; | ||||
|  | ||||
| 		header->Length = curr_len + append_length; | ||||
| 	} | ||||
| 	return c_str_to_append != nullptr; | ||||
| } | ||||
|  | ||||
| void strbuilder_trim(StrBuilder str, char const* cut_set) | ||||
| { | ||||
| 	ssize len = 0; | ||||
|  | ||||
| 	char* start_pos = str; | ||||
| 	char* end_pos   = scast(char*, str) + strbuilder_length(str) - 1; | ||||
|  | ||||
| 	while (start_pos <= end_pos && char_first_occurence(cut_set, *start_pos)) | ||||
| 	start_pos++; | ||||
|  | ||||
| 	while (end_pos > start_pos && char_first_occurence(cut_set, *end_pos)) | ||||
| 	end_pos--; | ||||
|  | ||||
| 	len = scast(ssize, (start_pos > end_pos) ? 0 : ((end_pos - start_pos) + 1)); | ||||
|  | ||||
| 	if (str != start_pos) | ||||
| 		mem_move(str, start_pos, len); | ||||
|  | ||||
| 	str[len] = '\0'; | ||||
|  | ||||
| 	strbuilder_get_header(str)->Length = len; | ||||
| } | ||||
|  | ||||
| StrBuilder strbuilder_visualize_whitespace(StrBuilder const str) | ||||
| { | ||||
| 	StrBuilderHeader* header = (StrBuilderHeader*)(scast(char const*, str) - sizeof(StrBuilderHeader)); | ||||
| 	StrBuilder        result = strbuilder_make_reserve(header->Allocator, strbuilder_length(str) * 2); // Assume worst case for space requirements. | ||||
|  | ||||
| 	for (char const* c = strbuilder_begin(str); c != strbuilder_end(str); c = strbuilder_next(str, c)) | ||||
| 	switch ( * c ) | ||||
| 	{ | ||||
| 		case ' ': | ||||
| 			strbuilder_append_str(& result, txt("·")); | ||||
| 		break; | ||||
| 		case '\t': | ||||
| 			strbuilder_append_str(& result, txt("→")); | ||||
| 		break; | ||||
| 		case '\n': | ||||
| 			strbuilder_append_str(& result, txt("↵")); | ||||
| 		break; | ||||
| 		case '\r': | ||||
| 			strbuilder_append_str(& result, txt("⏎")); | ||||
| 		break; | ||||
| 		case '\v': | ||||
| 			strbuilder_append_str(& result, txt("⇕")); | ||||
| 		break; | ||||
| 		case '\f': | ||||
| 			strbuilder_append_str(& result, txt("⌂")); | ||||
| 		break; | ||||
| 		default: | ||||
| 			strbuilder_append_char(& result, * c); | ||||
| 		break; | ||||
| 	} | ||||
|  | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| #pragma endregion StrBuilder | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "hashing.hpp" | ||||
| #endif | ||||
| @@ -124,6 +124,10 @@ forceinline usize strbuilder_grow_formula(usize value); | ||||
|  | ||||
| GEN_API StrBuilder        strbuilder_make_reserve        (AllocatorInfo allocator, ssize        capacity); | ||||
| GEN_API StrBuilder        strbuilder_make_length         (AllocatorInfo allocator, char const*  str,   ssize length); | ||||
| GEN_API bool              strbuilder_make_space_for      (StrBuilder* str, char const* to_append,       ssize add_len); | ||||
| GEN_API bool              strbuilder_append_c_str_len    (StrBuilder* str, char const* c_str_to_append, ssize length); | ||||
| GEN_API void              strbuilder_trim                (StrBuilder  str, char const* cut_set); | ||||
| GEN_API StrBuilder        strbuilder_visualize_whitespace(StrBuilder const str); | ||||
|  | ||||
| StrBuilder        strbuilder_make_c_str          (AllocatorInfo allocator, char const*  str); | ||||
| StrBuilder        strbuilder_make_str            (AllocatorInfo allocator, Str         str); | ||||
| @@ -132,10 +136,8 @@ StrBuilder        strbuilder_fmt_buf             (AllocatorInfo allocator, char | ||||
| StrBuilder        strbuilder_join                (AllocatorInfo allocator, char const** parts, ssize num_parts, char const* glue); | ||||
| bool              strbuilder_are_equal           (StrBuilder const lhs, StrBuilder const rhs); | ||||
| bool              strbuilder_are_equal_str       (StrBuilder const lhs, Str rhs); | ||||
| bool              strbuilder_make_space_for      (StrBuilder*      str, char const*  to_append, ssize add_len); | ||||
| bool              strbuilder_append_char         (StrBuilder*      str, char         c); | ||||
| bool              strbuilder_append_c_str        (StrBuilder*      str, char const*  c_str_to_append); | ||||
| bool              strbuilder_append_c_str_len    (StrBuilder*      str, char const*  c_str_to_append, ssize length); | ||||
| bool              strbuilder_append_str          (StrBuilder*      str, Str         c_str_to_append); | ||||
| bool              strbuilder_append_string       (StrBuilder*      str, StrBuilder const other); | ||||
| bool              strbuilder_append_fmt          (StrBuilder*      str, char const*  fmt, ...); | ||||
| @@ -154,9 +156,7 @@ b32               strbuilder_starts_with_string  (StrBuilder const str, StrBuild | ||||
| void              strbuilder_skip_line           (StrBuilder       str); | ||||
| void              strbuilder_strip_space         (StrBuilder       str); | ||||
| Str               strbuilder_to_str              (StrBuilder       str); | ||||
| void              strbuilder_trim                (StrBuilder       str, char const* cut_set); | ||||
| void              strbuilder_trim_space          (StrBuilder       str); | ||||
| StrBuilder        strbuilder_visualize_whitespace(StrBuilder const str); | ||||
|  | ||||
| struct StrBuilderHeader { | ||||
| 	AllocatorInfo Allocator; | ||||
| @@ -358,29 +358,6 @@ bool strbuilder_append_c_str(StrBuilder* str, char const* c_str_to_append) { | ||||
| 	return strbuilder_append_c_str_len(str, c_str_to_append, c_str_len(c_str_to_append)); | ||||
| } | ||||
|  | ||||
| inline | ||||
| bool strbuilder_append_c_str_len(StrBuilder* str, char const* c_str_to_append, ssize append_length) | ||||
| { | ||||
| 	GEN_ASSERT(str != nullptr); | ||||
| 	if ( rcast(sptr, c_str_to_append) > 0) | ||||
| 	{ | ||||
| 		ssize curr_len = strbuilder_length(* str); | ||||
|  | ||||
| 		if ( ! strbuilder_make_space_for(str, c_str_to_append, append_length)) | ||||
| 			return false; | ||||
|  | ||||
| 		StrBuilderHeader* header = strbuilder_get_header(* str); | ||||
|  | ||||
| 		char* Data = * str; | ||||
| 		mem_copy( Data + curr_len, c_str_to_append, append_length); | ||||
|  | ||||
| 		Data[curr_len + append_length] = '\0'; | ||||
|  | ||||
| 		header->Length = curr_len + append_length; | ||||
| 	} | ||||
| 	return c_str_to_append != nullptr; | ||||
| } | ||||
|  | ||||
| forceinline | ||||
| bool strbuilder_append_str(StrBuilder* str, Str c_str_to_append) { | ||||
| 	GEN_ASSERT(str != nullptr); | ||||
| @@ -522,44 +499,6 @@ ssize strbuilder_length(StrBuilder const str) | ||||
| 	return header->Length; | ||||
| } | ||||
|  | ||||
| inline | ||||
| bool strbuilder_make_space_for(StrBuilder* str, char const* to_append, ssize add_len) | ||||
| { | ||||
| 	ssize available = strbuilder_avail_space(* str); | ||||
|  | ||||
| 	if (available >= add_len) { | ||||
| 		return true; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		ssize new_len, old_size, new_size; | ||||
| 		void* ptr; | ||||
| 		void* new_ptr; | ||||
|  | ||||
| 		AllocatorInfo allocator = strbuilder_get_header(* str)->Allocator; | ||||
| 		StrBuilderHeader* header    = nullptr; | ||||
|  | ||||
| 		new_len  = strbuilder_grow_formula(strbuilder_length(* str) + add_len); | ||||
| 		ptr      = strbuilder_get_header(* str); | ||||
| 		old_size = size_of(StrBuilderHeader) + strbuilder_length(* str) + 1; | ||||
| 		new_size = size_of(StrBuilderHeader) + new_len + 1; | ||||
|  | ||||
| 		new_ptr = resize(allocator, ptr, old_size, new_size); | ||||
|  | ||||
| 		if (new_ptr == nullptr) | ||||
| 			return false; | ||||
|  | ||||
| 		header = rcast(StrBuilderHeader*, new_ptr); | ||||
| 		header->Allocator = allocator; | ||||
| 		header->Capacity  = new_len; | ||||
|  | ||||
| 		char** Data = rcast(char**, str); | ||||
| 		* Data = rcast(char*, header + 1); | ||||
|  | ||||
| 		return true; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| forceinline | ||||
| b32 strbuilder_starts_with_str(StrBuilder const str, Str substring) { | ||||
| 	if (substring.Len > strbuilder_length(str)) | ||||
| @@ -627,69 +566,11 @@ Str strbuilder_to_str(StrBuilder str) { | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| inline | ||||
| void strbuilder_trim(StrBuilder str, char const* cut_set) | ||||
| { | ||||
| 	ssize len = 0; | ||||
|  | ||||
| 	char* start_pos = str; | ||||
| 	char* end_pos   = scast(char*, str) + strbuilder_length(str) - 1; | ||||
|  | ||||
| 	while (start_pos <= end_pos && char_first_occurence(cut_set, *start_pos)) | ||||
| 	start_pos++; | ||||
|  | ||||
| 	while (end_pos > start_pos && char_first_occurence(cut_set, *end_pos)) | ||||
| 	end_pos--; | ||||
|  | ||||
| 	len = scast(ssize, (start_pos > end_pos) ? 0 : ((end_pos - start_pos) + 1)); | ||||
|  | ||||
| 	if (str != start_pos) | ||||
| 		mem_move(str, start_pos, len); | ||||
|  | ||||
| 	str[len] = '\0'; | ||||
|  | ||||
| 	strbuilder_get_header(str)->Length = len; | ||||
| } | ||||
|  | ||||
| forceinline | ||||
| void strbuilder_trim_space(StrBuilder str) { | ||||
| 	strbuilder_trim(str, " \t\r\n\v\f"); | ||||
| } | ||||
|  | ||||
| inline | ||||
| StrBuilder strbuilder_visualize_whitespace(StrBuilder const str) | ||||
| { | ||||
| 	StrBuilderHeader* header = (StrBuilderHeader*)(scast(char const*, str) - sizeof(StrBuilderHeader)); | ||||
| 	StrBuilder        result = strbuilder_make_reserve(header->Allocator, strbuilder_length(str) * 2); // Assume worst case for space requirements. | ||||
|  | ||||
| 	for (char const* c = strbuilder_begin(str); c != strbuilder_end(str); c = strbuilder_next(str, c)) | ||||
| 	switch ( * c ) | ||||
| 	{ | ||||
| 		case ' ': | ||||
| 			strbuilder_append_str(& result, txt("·")); | ||||
| 		break; | ||||
| 		case '\t': | ||||
| 			strbuilder_append_str(& result, txt("→")); | ||||
| 		break; | ||||
| 		case '\n': | ||||
| 			strbuilder_append_str(& result, txt("↵")); | ||||
| 		break; | ||||
| 		case '\r': | ||||
| 			strbuilder_append_str(& result, txt("⏎")); | ||||
| 		break; | ||||
| 		case '\v': | ||||
| 			strbuilder_append_str(& result, txt("⇕")); | ||||
| 		break; | ||||
| 		case '\f': | ||||
| 			strbuilder_append_str(& result, txt("⌂")); | ||||
| 		break; | ||||
| 		default: | ||||
| 			strbuilder_append_char(& result, * c); | ||||
| 		break; | ||||
| 	} | ||||
|  | ||||
| 	return result; | ||||
| } | ||||
| #pragma endregion StrBuilder | ||||
|  | ||||
| #if GEN_COMPILER_CPP | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "filesystem.cpp" | ||||
| #endif | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	pragma once | ||||
| #	include "filesystem.hpp" | ||||
| #endif | ||||
|   | ||||
| @@ -29,9 +29,9 @@ GEN_NS_BEGIN | ||||
|  | ||||
| #include "components/interface.hpp" | ||||
|  | ||||
| #include "components/constants.hpp" | ||||
| #include "components/inlines.hpp" | ||||
| #include "components/gen/ast_inlines.hpp" | ||||
| #include "components/header_end.hpp" | ||||
|  | ||||
| #include "auxiliary/builder.hpp" | ||||
| #include "auxiliary/scanner.hpp" | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| #pragma once | ||||
|  | ||||
| #if GEN_INTELLISENSE_DIRECTIVES | ||||
| #if INTELLISENSE_DIRECTIVES | ||||
| #	include "../gen.hpp" | ||||
| #	include "misc.hpp" | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| #pragma once | ||||
|  | ||||
| #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||
| #ifdef INTELLISENSE_DIRECTIVES | ||||
| #	define GEN_DEFINE_LIBRARY_CODE_CONSTANTS | ||||
| #	define GEN_ENFORCE_STRONG_CODE_TYPES | ||||
| #	define GEN_EXPOSE_BACKEND | ||||
|   | ||||
| @@ -53,7 +53,7 @@ StrBuilder <prefix>_to_strbuilder(Code code); | ||||
|  | ||||
| Where the first generates strings allocated using Allocator_StringArena and the other appends an existing strings with their backed allocator. | ||||
|  | ||||
| Serialization of for the AST is defined for `Code` in [`ast.cpp`](../base/components/ast.cpp) with `code_to_strbuilder_ptr` & `code_to_strbuilder`.   | ||||
| Serialization of for the AST is defined for `Code` in [`ast.cpp`](../base/components/ast.cpp) with `code_to_strbuilder_ref` & `code_to_strbuilder`.   | ||||
| Serializtion for the rest of the code types is within [`code_serialization.cpp`](../base/components/code_serialization.cpp).   | ||||
|  | ||||
| Gencpp's serialization does not provide coherent formatting of the code. The user should use a formatter after serializing. | ||||
|   | ||||
| @@ -306,7 +306,7 @@ do                          \ | ||||
| 		break; | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_memory, header_memory ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_header_memory, header_memory ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			header_memory.append(entry); | ||||
| @@ -334,7 +334,7 @@ do                          \ | ||||
| 	{ | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_printing, header_printing ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_header_printing, header_printing ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			header_printing.append(entry); | ||||
| @@ -391,7 +391,7 @@ do                          \ | ||||
|  | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_strings, header_strings ); | ||||
| 			ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_header_strings, header_strings ); | ||||
| 		} | ||||
| 		break; | ||||
|  | ||||
| @@ -472,7 +472,7 @@ do                          \ | ||||
| 	{ | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_filesystem, header_filesystem ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_header_filesystem, header_filesystem ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			header_filesystem.append(entry); | ||||
| @@ -509,7 +509,7 @@ do                          \ | ||||
| 		case CT_Variable: | ||||
| 		{ | ||||
| 			CodeVar var = cast(CodeVar, entry); | ||||
| 			if (var->Specs.has(Spec_Constexpr) > -1) | ||||
| 			if (var->Specs.has(Spec_Constexpr)) | ||||
| 			{ | ||||
| 				Opts_def_define opts = { {}, entry->Value->Content }; | ||||
| 				CodeDefine define = def_define(entry->Name, MT_Expression, opts); | ||||
| @@ -532,7 +532,7 @@ do                          \ | ||||
| 	{ | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_parsing, header_parsing ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_header_parsing, header_parsing ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			header_parsing.append(entry); | ||||
| @@ -640,7 +640,7 @@ do                          \ | ||||
|  | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_types, types ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_types, types ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			types.append(entry); | ||||
| @@ -702,7 +702,7 @@ do                          \ | ||||
| 	{ | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_parser_types, parser_types ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_parser_types, parser_types ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			parser_types.append(entry); | ||||
| @@ -769,7 +769,7 @@ do                          \ | ||||
| 		case CT_Variable: | ||||
| 		{ | ||||
| 			CodeVar var = cast(CodeVar, entry); | ||||
| 			if (var->Specs && var->Specs.has(Spec_Constexpr) > -1) { | ||||
| 			if (var->Specs && var->Specs.has(Spec_Constexpr)) { | ||||
| 				Code define_ver = untyped_str(token_fmt( | ||||
| 						"name",  var->Name | ||||
| 					,	"value", var->Value->Content | ||||
| @@ -797,7 +797,7 @@ do                          \ | ||||
| 	{ | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_ast, ast ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_ast, ast ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			found = ignore_preprocess_cond_block(txt("GEN_EXECUTION_EXPRESSION_SUPPORT"), entry, parsed_ast, ast ); | ||||
| @@ -978,7 +978,7 @@ R"(#define AST_ArrSpecs_Cap \ | ||||
| 				++ entry; // Skip a newline... | ||||
| 				break; | ||||
| 			} | ||||
| 			found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_code_types, code_types ); | ||||
| 			found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_code_types, code_types ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			found = ignore_preprocess_cond_block(txt("GEN_EXECUTION_EXPRESSION_SUPPORT"), entry, parsed_code_types, code_types); | ||||
| @@ -1078,7 +1078,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 		case CT_Preprocess_If: | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_ast_types, ast_types ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_ast_types, ast_types ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			found = ignore_preprocess_cond_block(txt("GEN_EXECUTION_EXPRESSION_SUPPORT"), entry, parsed_ast_types, ast_types); | ||||
| @@ -1132,7 +1132,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 		case CT_Preprocess_If: | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_interface, interface ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_interface, interface ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			found = ignore_preprocess_cond_block(txt("GEN_COMPILER_CPP"), entry, parsed_interface, interface); | ||||
| @@ -1221,7 +1221,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 		case CT_Preprocess_If: | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_inlines, inlines ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_inlines, inlines ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			found = ignore_preprocess_cond_block(txt("GEN_COMPILER_CPP"), entry, parsed_interface, interface); | ||||
| @@ -1257,16 +1257,16 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 	} | ||||
|  | ||||
| 	s32 idx = 0; | ||||
| 	CodeBody parsed_header_end = parse_file( path_base "components/header_end.hpp" ); | ||||
| 	CodeBody header_end        = def_body(CT_Global_Body); | ||||
| 	for ( Code entry = parsed_header_end.begin(); entry != parsed_header_end.end(); ++ entry, ++ idx ) switch( entry->Type ) | ||||
| 	CodeBody parsed_constants = parse_file( path_base "components/constants.hpp" ); | ||||
| 	CodeBody constants        = def_body(CT_Global_Body); | ||||
| 	for ( Code entry = parsed_constants.begin(); entry != parsed_constants.end(); ++ entry, ++ idx ) switch( entry->Type ) | ||||
| 	{ | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_end, header_end ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_constants, constants ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			header_end.append(entry); | ||||
| 			constants.append(entry); | ||||
| 		} | ||||
| 		break; | ||||
|  | ||||
| @@ -1280,16 +1280,16 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 				{ | ||||
| 					Opts_def_define opts = { {}, entry->Value->Content }; | ||||
| 					CodeDefine define = def_define(entry->Name, MT_Expression, opts ); | ||||
| 					header_end.append(define); | ||||
| 					constants.append(define); | ||||
| 					continue; | ||||
| 				} | ||||
| 			} | ||||
| 			header_end.append(entry); | ||||
| 			constants.append(entry); | ||||
| 		} | ||||
| 		break; | ||||
|  | ||||
| 		default: | ||||
| 			header_end.append(entry); | ||||
| 		constants.append(entry); | ||||
| 		break; | ||||
| 	} | ||||
| #pragma endregion Resolve Components | ||||
| @@ -1302,7 +1302,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 	{ | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_builder, header_builder ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_header_builder, header_builder ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			header_builder.append(entry); | ||||
| @@ -1446,7 +1446,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 	{ | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_src_ast, src_ast ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_src_ast, src_ast ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			src_ast.append(entry); | ||||
| @@ -1481,7 +1481,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 	{ | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_src_upfront, src_upfront ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_src_upfront, src_upfront ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			src_upfront.append(entry); | ||||
| @@ -1520,7 +1520,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 	{ | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_src_lexer, src_lexer ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_src_lexer, src_lexer ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			src_lexer.append(entry); | ||||
| @@ -1542,7 +1542,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 		case CT_Variable: | ||||
| 		{ | ||||
| 			CodeVar var = cast(CodeVar, entry); | ||||
| 			if (var->Specs && var->Specs.has(Spec_Constexpr) > -1) { | ||||
| 			if (var->Specs && var->Specs.has(Spec_Constexpr)) { | ||||
| 				Code define_ver = untyped_str(token_fmt( | ||||
| 						"name",  var->Name | ||||
| 					,	"value", var->Value->Content | ||||
| @@ -1569,7 +1569,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 	{ | ||||
| 		case CT_Preprocess_IfDef: | ||||
| 		{ | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_src_parser, src_parser ); | ||||
| 			b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_src_parser, src_parser ); | ||||
| 			if (found) break; | ||||
|  | ||||
| 			src_parser.append(entry); | ||||
| @@ -1587,7 +1587,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 		case CT_Variable: | ||||
| 		{ | ||||
| 			CodeVar var = cast(CodeVar, entry); | ||||
| 			if (var->Specs && var->Specs.has(Spec_Constexpr) > -1) { | ||||
| 			if (var->Specs && var->Specs.has(Spec_Constexpr)) { | ||||
| 				Code define_ver = untyped_str(token_fmt( | ||||
| 						"name",  var->Name | ||||
| 					,	"value", var->Value->Content | ||||
| @@ -1673,11 +1673,11 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 	Code rf_ast_types    = refactor_and_format(ast_types); | ||||
|  | ||||
| 	Code rf_interface = refactor_and_format(interface); | ||||
| 	Code rf_constants = refactor_and_format(constants); | ||||
| 	Code rf_inlines   = refactor_and_format(inlines); | ||||
|  | ||||
| 	Code rf_ht_preprocessor_macro = refactor_and_format(ht_preprocessor_macro); | ||||
| 	Code rf_array_string_cached   = refactor_and_format(array_string_cached); | ||||
| 	Code rf_header_end            = refactor_and_format(header_end); | ||||
| 	Code rf_header_builder        = refactor_and_format(header_builder); | ||||
| 	Code rf_header_scanner        = refactor_and_format( scan_file( path_base "auxiliary/scanner.hpp" )); | ||||
|  | ||||
| @@ -1788,6 +1788,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 		header.print( rf_ht_preprocessor_macro ); | ||||
|  | ||||
| 		header.print( rf_interface ); | ||||
| 		header.print( rf_constants ); | ||||
| 		header.print(fmt_newline); | ||||
|  | ||||
| 		header.print_fmt("#pragma region Inlines\n"); | ||||
| @@ -1796,7 +1797,6 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
|  | ||||
| 		header.print(fmt_newline); | ||||
|  | ||||
| 		header.print( rf_header_end ); | ||||
| 		header.print( rf_header_builder ); | ||||
| 		header.print( rf_header_scanner ); | ||||
|  | ||||
| @@ -1882,6 +1882,9 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
|  | ||||
| 		header.print( r_header_macros ); | ||||
| 		header.print( header_generic_macros ); | ||||
| 		 | ||||
| 		header.print_fmt( "\nGEN_API_C_BEGIN\n" ); | ||||
|  | ||||
| 		header.print( r_header_basic_types ); | ||||
| 		header.print( r_header_debug ); | ||||
| 		header.print( rf_header_memory ); | ||||
| @@ -1895,6 +1898,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 		header.print( r_header_timing ); | ||||
| 		header.print(rf_header_parsing ); | ||||
|  | ||||
| 		header.print_fmt( "\nGEN_API_C_END\n" ); | ||||
| 		header.print_fmt( "\nGEN_NS_END\n" ); | ||||
| 		header.write(); | ||||
| 	} | ||||
| @@ -1949,7 +1953,17 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 		header.print( rf_ast_types ); | ||||
| 		header.print_fmt("\n#pragma endregion AST\n"); | ||||
|  | ||||
| 		header.print( fmt_newline); | ||||
| 		header.print( rf_array_arena ); | ||||
| 		header.print( fmt_newline); | ||||
| 		header.print( rf_array_pool); | ||||
| 		header.print( fmt_newline); | ||||
| 		header.print( rf_array_string_cached ); | ||||
| 		header.print( fmt_newline); | ||||
| 		header.print( rf_ht_preprocessor_macro ); | ||||
|  | ||||
| 		header.print( rf_interface ); | ||||
| 		header.print( rf_constants ); | ||||
| 		header.print(fmt_newline); | ||||
|  | ||||
| 		header.print_fmt("#pragma region Inlines\n"); | ||||
| @@ -1957,9 +1971,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 		header.print_fmt("#pragma endregion Inlines\n"); | ||||
|  | ||||
| 		header.print(fmt_newline); | ||||
| 		header.print( rf_array_string_cached ); | ||||
|  | ||||
| 		header.print( rf_header_end ); | ||||
| 		header.print( rf_header_builder ); | ||||
| 		header.print( rf_header_scanner ); | ||||
|  | ||||
| @@ -1976,11 +1988,6 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 		builder_print( src, src_start ); | ||||
| 		src.print_fmt( "\nGEN_NS_BEGIN\n"); | ||||
|  | ||||
| 		src.print( fmt_newline); | ||||
| 		src.print( rf_array_arena ); | ||||
| 		src.print( fmt_newline); | ||||
| 		src.print( rf_array_pool); | ||||
|  | ||||
| 		src.print( r_src_static_data ); | ||||
| 		src.print( fmt_newline); | ||||
|  | ||||
| @@ -1998,6 +2005,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 		src.print( fmt_newline); | ||||
| 		src.print( rf_array_code_typename ); | ||||
| 		src.print( fmt_newline); | ||||
| 		src.print( r_src_parser_case_macros ); | ||||
| 		src.print( rf_src_parser ); | ||||
| 		src.print( r_src_parsing ); | ||||
| 		src.print_fmt( "\n#pragma endregion Parsing\n" ); | ||||
|   | ||||
| @@ -13,7 +13,7 @@ | ||||
| 	|  \_____|\___}_l |_|\___} .__/| .__/ {_____/ \__\__/_l\__. |\___/\__,_l   \____}{_____}{_____} | | ||||
| 	|                        | |   | |                      __} |                                   | | ||||
| 	|                        l_l   l_l                     {___/                                    | | ||||
| 	! ----------------------------------------------------------------------- VERSION: v0.23-Alpha  | | ||||
| 	! ----------------------------------------------------------------------- VERSION: v0.25-Alpha  | | ||||
| 	! ============================================================================================= | | ||||
| 	! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION                  | | ||||
| 	! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL  | | ||||
|   | ||||
| @@ -1,3 +1,6 @@ | ||||
| #define GEN_IMPLEMENTATION | ||||
| #define GEN_DONT_ENFORCE_GEN_TIME_GUARD | ||||
| #define GEN_DEFINE_LIBRARY_CORE_CONSTANTS | ||||
| #define GEN_ENFORCE_STRONG_CODE_TYPES | ||||
| #define GEN_EXPOSE_BACKEND | ||||
| #include "gen/gen_singleheader.h" | ||||
|   | ||||
| @@ -114,7 +114,7 @@ int gen_main() | ||||
| 	} | ||||
|  | ||||
| 	CodeBody gen_component_header = def_global_body( args( | ||||
| 		def_preprocess_cond( PreprocessCond_IfDef, txt("GEN_INTELLISENSE_DIRECTIVES") ), | ||||
| 		def_preprocess_cond( PreprocessCond_IfDef, txt("INTELLISENSE_DIRECTIVES") ), | ||||
| 		pragma_once, | ||||
| 		def_include(txt("components/types.hpp")), | ||||
| 		preprocess_endif, | ||||
| @@ -131,8 +131,8 @@ int gen_main() | ||||
| 		Code ast_types    = scan_file( path_base "components/ast_types.hpp" ); | ||||
| 		Code code_types   = scan_file( path_base "components/code_types.hpp" ); | ||||
| 		Code interface    = scan_file( path_base "components/interface.hpp" ); | ||||
| 		Code constants    = scan_file( path_base "components/constants.hpp"); | ||||
| 		Code inlines      = scan_file( path_base "components/inlines.hpp" ); | ||||
| 		Code header_end   = scan_file( path_base "components/header_end.hpp" ); | ||||
|  | ||||
| 		CodeBody ecode       = gen_ecode     ( path_base "enums/ECodeTypes.csv" ); | ||||
| 		CodeBody eoperator   = gen_eoperator ( path_base "enums/EOperator.csv" ); | ||||
| @@ -168,6 +168,7 @@ int gen_main() | ||||
| 		builder_print_fmt( header, "\n#pragma endregion AST\n" ); | ||||
|  | ||||
| 		builder_print( header, interface ); | ||||
| 		builder_print( header, constants ); | ||||
|  | ||||
| 		builder_print_fmt( header, "\n#pragma region Inlines\n" ); | ||||
| 		builder_print( header, inlines ); | ||||
| @@ -176,7 +177,6 @@ int gen_main() | ||||
| 		builder_print( header, fmt_newline ); | ||||
| 		builder_print_fmt( header, "#pragma endregion Inlines\n" ); | ||||
|  | ||||
| 		builder_print( header, header_end ); | ||||
| 		builder_print_fmt( header, "\nGEN_NS_END\n\n" ); | ||||
| 		builder_print( header, pop_ignores ); | ||||
| 		builder_write(header); | ||||
|   | ||||
| @@ -15,7 +15,7 @@ | ||||
| 	|  \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l                       | | ||||
| 	|     Singleheader       | |   | |                      __} |                                  | | ||||
| 	|                        l_l   l_l                     {___/                                   | | ||||
| 	! ----------------------------------------------------------------------- VERSION: v0.23-Alpha | | ||||
| 	! ----------------------------------------------------------------------- VERSION: v0.25-Alpha | | ||||
| 	! ============================================================================================ | | ||||
| 	! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION                 | | ||||
| 	! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL | | ||||
|   | ||||
| @@ -117,8 +117,8 @@ int gen_main() | ||||
| 		Code ast_types    = scan_file( path_base "components/ast_types.hpp" ); | ||||
| 		Code code_types   = scan_file( path_base "components/code_types.hpp" ); | ||||
| 		Code interface    = scan_file( path_base "components/interface.hpp" ); | ||||
| 		Code constants    = scan_file( path_base "components/constants.hpp" ); | ||||
| 		Code inlines 	  = scan_file( path_base "components/inlines.hpp" ); | ||||
| 		Code header_end   = scan_file( path_base "components/header_end.hpp" ); | ||||
|  | ||||
| 		CodeBody ecode       = gen_ecode     ( path_base "enums/ECodeTypes.csv" ); | ||||
| 		CodeBody eoperator   = gen_eoperator ( path_base "enums/EOperator.csv" ); | ||||
| @@ -149,6 +149,7 @@ int gen_main() | ||||
| 		header.print_fmt("\n#pragma endregion AST\n"); | ||||
|  | ||||
| 		header.print( interface ); | ||||
| 		header.print( constants ); | ||||
|  | ||||
| 		header.print_fmt( "\n#pragma region Inlines\n" ); | ||||
| 		header.print( inlines ); | ||||
| @@ -156,8 +157,6 @@ int gen_main() | ||||
| 		header.print( fmt_newline ); | ||||
| 		header.print_fmt( "#pragma endregion Inlines\n" ); | ||||
|  | ||||
| 		header.print( header_end ); | ||||
|  | ||||
| 		if ( generate_builder ) { | ||||
| 			header.print( scan_file( path_base "auxiliary/builder.hpp" ) ); | ||||
| 		} | ||||
|   | ||||
| @@ -16,7 +16,7 @@ | ||||
| 	|  \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l                       | | ||||
| 	|  Unreal Engine         | |   | |                      __} |                                  | | ||||
| 	|                        l_l   l_l                     {___/                                   | | ||||
| 	! ----------------------------------------------------------------------- VERSION: v0.23-Alpha | | ||||
| 	! ----------------------------------------------------------------------- VERSION: v0.25-Alpha | | ||||
| 	! ============================================================================================ | | ||||
| 	! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION                 | | ||||
| 	! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL | | ||||
|   | ||||
| @@ -24,4 +24,5 @@ Final,                  final | ||||
| NoExceptions,           noexcept | ||||
| Override,               override | ||||
| Pure,                   = 0 | ||||
| Delete,                 = delete | ||||
| Volatile,               volatile | ||||
|   | ||||
| 
 | 
| @@ -224,8 +224,8 @@ int gen_main() | ||||
| 		Code ast_types    = scan_file( path_base "components/ast_types.hpp" ); | ||||
| 		Code code_types   = scan_file( path_base "components/code_types.hpp" ); | ||||
| 		Code interface    = scan_file( path_base "components/interface.hpp" ); | ||||
| 		Code constants    = scan_file( path_base "components/constants.hpp" ); | ||||
| 		Code inlines      = scan_file( path_base "components/inlines.hpp" ); | ||||
| 		Code header_end   = scan_file( path_base "components/header_end.hpp" ); | ||||
|  | ||||
| 		CodeBody ecode       = gen_ecode     ( path_base "enums/ECodeTypes.csv" ); | ||||
| 		CodeBody eoperator   = gen_eoperator ( path_base "enums/EOperator.csv" ); | ||||
| @@ -266,6 +266,7 @@ int gen_main() | ||||
| 		header.print_fmt( "\n#pragma endregion AST\n" ); | ||||
|  | ||||
| 		header.print( interface ); | ||||
| 		header.print( constants ); | ||||
|  | ||||
| 		header.print_fmt( "\n#pragma region Inlines\n" ); | ||||
| 		header.print( inlines ); | ||||
| @@ -274,7 +275,6 @@ int gen_main() | ||||
| 		header.print( fmt_newline ); | ||||
| 		header.print_fmt( "#pragma endregion Inlines\n" ); | ||||
|  | ||||
| 		header.print( header_end ); | ||||
| 		header.print_fmt( "\nGEN_NS_END\n\n" ); | ||||
| 		header.print( pop_ignores ); | ||||
| 		header.write(); | ||||
|   | ||||
| @@ -172,7 +172,7 @@ if ( $segmented ) | ||||
| 						write-host `t $_ -ForegroundColor Green | ||||
| 					} | ||||
| 				} | ||||
| 			write-host "`nBootstrap completed in $($time_taken.TotalMilliseconds) ms" | ||||
| 			write-host "`nSegmented completed in $($time_taken.TotalMilliseconds) ms" | ||||
| 		} | ||||
| 	Pop-Location | ||||
| } | ||||
| @@ -263,6 +263,7 @@ if ( $c_lib_static ) | ||||
| 	$compiler_args += $flag_all_c | ||||
| 	$compiler_args += $flag_updated_cpp_macro | ||||
| 	$compiler_args += $flag_c11 | ||||
| 	$compiler_args += ($flag_define + 'GEN_STATIC_LINK') | ||||
|  | ||||
| 	$linker_args = @() | ||||
| 	$result = build-simple $path_build $includes $compiler_args $linker_args $unit $path_lib | ||||
|   | ||||
| @@ -564,6 +564,7 @@ if ( $vendor -match "msvc" ) | ||||
| 		# Check if output is a static library | ||||
| 		if ( $binary -match '\.lib$' ) | ||||
| 		{ | ||||
| 			write-host "Running archiver for $binary" | ||||
| 			$lib_args  = @() | ||||
| 			$lib_args += $flag_nologo | ||||
| 			$lib_args += $flag_link_win_machine_64 | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #if GEN_INTELLISENSE_DIRECTIVES | ||||
| #if INTELLISENSE_DIRECTIVES | ||||
| #include "../../gen_c_library/gen/gen_singleheader.h" | ||||
| #endif | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user