mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-10-31 06:50:53 -07:00 
			
		
		
		
	Compare commits
	
		
			4 Commits
		
	
	
		
			e00b2f8afb
			...
			6081834687
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 6081834687 | |||
| a3548a5bd3 | |||
| d686831a7c | |||
| ba1dd1894a | 
| @@ -128,12 +128,12 @@ int gen_main() | |||||||
| 		header.print( debug ); | 		header.print( debug ); | ||||||
|  |  | ||||||
| 		CodeBody parsed_memory = parse_file( project_dir "dependencies/memory.hpp" ); | 		CodeBody parsed_memory = parse_file( project_dir "dependencies/memory.hpp" ); | ||||||
| 		CodeBody memory        = def_body(ECode::Global_Body); | 		CodeBody memory        = def_body(CT_Global_Body); | ||||||
| 		for ( Code entry = parsed_memory.begin(); entry != parsed_memory.end(); ++ entry ) | 		for ( Code entry = parsed_memory.begin(); entry != parsed_memory.end(); ++ entry ) | ||||||
| 		{ | 		{ | ||||||
| 			switch (entry->Type) | 			switch (entry->Type) | ||||||
| 			{ | 			{ | ||||||
| 				case ECode::Using: | 				case CT_Using: | ||||||
| 				{ | 				{ | ||||||
| 					log_fmt("REPLACE THIS MANUALLY: %S\n", entry->Name); | 					log_fmt("REPLACE THIS MANUALLY: %S\n", entry->Name); | ||||||
| 					CodeUsing   using_ver   = cast(CodeUsing, entry); | 					CodeUsing   using_ver   = cast(CodeUsing, entry); | ||||||
| @@ -142,7 +142,7 @@ int gen_main() | |||||||
| 					memory.append(typedef_ver); | 					memory.append(typedef_ver); | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
| 				case ECode::Function_Fwd: | 				case CT_Function_Fwd: | ||||||
| 				{ | 				{ | ||||||
| 					CodeFn fn = cast(CodeFn, entry); | 					CodeFn fn = cast(CodeFn, entry); | ||||||
| 					if ( fn->Name.is_equal(txt("free")) ) | 					if ( fn->Name.is_equal(txt("free")) ) | ||||||
| @@ -152,13 +152,13 @@ int gen_main() | |||||||
| 					memory.append(entry); | 					memory.append(entry); | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
| 				case ECode::Function: | 				case CT_Function: | ||||||
| 				{ | 				{ | ||||||
| 					CodeFn fn = cast(CodeFn, entry); | 					CodeFn fn = cast(CodeFn, entry); | ||||||
| 					s32 constexpr_found = fn->Specs.remove( ESpecifier::Constexpr ); | 					s32 constexpr_found = fn->Specs.remove( Spec_Constexpr ); | ||||||
| 					if (constexpr_found > -1) { | 					if (constexpr_found > -1) { | ||||||
| 						log_fmt("Found constexpr: %S\n", entry.to_string()); | 						log_fmt("Found constexpr: %S\n", entry.to_string()); | ||||||
| 						fn->Specs.append(ESpecifier::Inline); | 						fn->Specs.append(Spec_Inline); | ||||||
| 					} | 					} | ||||||
| 					if ( fn->Name.is_equal(txt("free")) ) | 					if ( fn->Name.is_equal(txt("free")) ) | ||||||
| 					{ | 					{ | ||||||
| @@ -167,7 +167,7 @@ int gen_main() | |||||||
| 					memory.append(entry); | 					memory.append(entry); | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
| 				case ECode::Template: | 				case CT_Template: | ||||||
| 				{ | 				{ | ||||||
| 					CodeTemplate tmpl = cast(CodeTemplate, entry); | 					CodeTemplate tmpl = cast(CodeTemplate, entry); | ||||||
| 					if ( tmpl->Declaration->Name.contains(txt("swap"))) | 					if ( tmpl->Declaration->Name.contains(txt("swap"))) | ||||||
| @@ -186,14 +186,14 @@ int gen_main() | |||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
| 				case ECode::Class: | 				case CT_Class: | ||||||
| 				case ECode::Struct: | 				case CT_Struct: | ||||||
| 				{ | 				{ | ||||||
| 					CodeBody body     = cast(CodeBody, entry->Body); | 					CodeBody body     = cast(CodeBody, entry->Body); | ||||||
| 					CodeBody new_body = def_body( entry->Body->Type ); | 					CodeBody new_body = def_body( entry->Body->Type ); | ||||||
| 					for ( Code body_entry = body.begin(); body_entry != body.end(); ++ body_entry ) switch | 					for ( Code body_entry = body.begin(); body_entry != body.end(); ++ body_entry ) switch | ||||||
| 					(body_entry->Type) { | 					(body_entry->Type) { | ||||||
| 						case ECode::Preprocess_If: | 						case CT_Preprocess_If: | ||||||
| 						{ | 						{ | ||||||
| 							ignore_preprocess_cond_block(txt("GEN_SUPPORT_CPP_MEMBER_FEATURES"), body_entry, body ); | 							ignore_preprocess_cond_block(txt("GEN_SUPPORT_CPP_MEMBER_FEATURES"), body_entry, body ); | ||||||
| 						} | 						} | ||||||
| @@ -208,7 +208,7 @@ int gen_main() | |||||||
| 					memory.append(entry); | 					memory.append(entry); | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
| 				case ECode::Preprocess_If: | 				case CT_Preprocess_If: | ||||||
| 				{ | 				{ | ||||||
| 					b32 found = ignore_preprocess_cond_block(txt("GEN_SUPPORT_CPP_MEMBER_FEATURES"), entry, parsed_memory ); | 					b32 found = ignore_preprocess_cond_block(txt("GEN_SUPPORT_CPP_MEMBER_FEATURES"), entry, parsed_memory ); | ||||||
| 					if (found) break; | 					if (found) break; | ||||||
| @@ -216,7 +216,7 @@ int gen_main() | |||||||
| 					memory.append(entry); | 					memory.append(entry); | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
| 				case ECode::Preprocess_IfDef: | 				case CT_Preprocess_IfDef: | ||||||
| 				{ | 				{ | ||||||
| 					b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_memory ); | 					b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_memory ); | ||||||
| 					if (found) break; | 					if (found) break; | ||||||
| @@ -224,7 +224,7 @@ int gen_main() | |||||||
| 					memory.append(entry); | 					memory.append(entry); | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
| 				case ECode::Preprocess_Pragma: | 				case CT_Preprocess_Pragma: | ||||||
| 				{ | 				{ | ||||||
| 					b32 found = swap_pragma_region_implementation( txt("FixedArena"), gen_fixed_arenas, entry, memory); | 					b32 found = swap_pragma_region_implementation( txt("FixedArena"), gen_fixed_arenas, entry, memory); | ||||||
| 					if (found) break; | 					if (found) break; | ||||||
| @@ -244,12 +244,12 @@ int gen_main() | |||||||
| 		header.print( string_ops ); | 		header.print( string_ops ); | ||||||
|  |  | ||||||
| 		CodeBody printing_parsed = parse_file( project_dir "dependencies/printing.hpp" ); | 		CodeBody printing_parsed = parse_file( project_dir "dependencies/printing.hpp" ); | ||||||
| 		CodeBody printing        = def_body(ECode::Global_Body); | 		CodeBody printing        = def_body(CT_Global_Body); | ||||||
| 		for ( Code entry = printing_parsed.begin(); entry != printing_parsed.end(); ++ entry ) | 		for ( Code entry = printing_parsed.begin(); entry != printing_parsed.end(); ++ entry ) | ||||||
| 		{ | 		{ | ||||||
| 			switch (entry->Type) | 			switch (entry->Type) | ||||||
| 			{ | 			{ | ||||||
| 				case ECode::Preprocess_IfDef: | 				case CT_Preprocess_IfDef: | ||||||
| 				{ | 				{ | ||||||
| 					b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, printing_parsed ); | 					b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, printing_parsed ); | ||||||
| 					if (found) break; | 					if (found) break; | ||||||
| @@ -257,7 +257,7 @@ int gen_main() | |||||||
| 					printing.append(entry); | 					printing.append(entry); | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
| 				case ECode::Variable: | 				case CT_Variable: | ||||||
| 				{ | 				{ | ||||||
| 					if (contains(entry->Name, txt("Msg_Invalid_Value"))) | 					if (contains(entry->Name, txt("Msg_Invalid_Value"))) | ||||||
| 					{ | 					{ | ||||||
| @@ -275,7 +275,7 @@ int gen_main() | |||||||
| 		} | 		} | ||||||
| 		header.print(dump_to_scratch_and_retireve(printing)); | 		header.print(dump_to_scratch_and_retireve(printing)); | ||||||
|  |  | ||||||
| 		CodeBody containers = def_body(ECode::Global_Body); | 		CodeBody containers = def_body(CT_Global_Body); | ||||||
| 		{ | 		{ | ||||||
| 			containers.append( def_pragma(code(region Containers))); | 			containers.append( def_pragma(code(region Containers))); | ||||||
|  |  | ||||||
| @@ -291,24 +291,24 @@ int gen_main() | |||||||
| 		header.print( hashing ); | 		header.print( hashing ); | ||||||
|  |  | ||||||
| 		CodeBody parsed_strings = parse_file( project_dir "dependencies/strings.hpp" ); | 		CodeBody parsed_strings = parse_file( project_dir "dependencies/strings.hpp" ); | ||||||
| 		CodeBody strings        = def_body(ECode::Global_Body); | 		CodeBody strings        = def_body(CT_Global_Body); | ||||||
| 		for ( Code entry = parsed_strings.begin(); entry != parsed_strings.end(); ++ entry ) | 		for ( Code entry = parsed_strings.begin(); entry != parsed_strings.end(); ++ entry ) | ||||||
| 		{ | 		{ | ||||||
| 			switch (entry->Type) | 			switch (entry->Type) | ||||||
| 			{ | 			{ | ||||||
| 				case ECode::Preprocess_If: | 				case CT_Preprocess_If: | ||||||
| 				{ | 				{ | ||||||
| 					ignore_preprocess_cond_block(txt("! GEN_COMPILER_C"), entry, parsed_strings); | 					ignore_preprocess_cond_block(txt("! GEN_COMPILER_C"), entry, parsed_strings); | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
|  |  | ||||||
| 				case ECode::Preprocess_IfDef: | 				case CT_Preprocess_IfDef: | ||||||
| 				{ | 				{ | ||||||
| 					ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_strings ); | 					ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_strings ); | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
|  |  | ||||||
| 				case ECode::Struct_Fwd: | 				case CT_Struct_Fwd: | ||||||
| 				{ | 				{ | ||||||
| 					if ( entry->Name.is_equal(txt("String")) ) | 					if ( entry->Name.is_equal(txt("String")) ) | ||||||
| 					{ | 					{ | ||||||
| @@ -322,13 +322,13 @@ int gen_main() | |||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
|  |  | ||||||
| 				case ECode::Struct: | 				case CT_Struct: | ||||||
| 				{ | 				{ | ||||||
| 					CodeBody body     = cast(CodeBody, entry->Body); | 					CodeBody body     = cast(CodeBody, entry->Body); | ||||||
| 					CodeBody new_body = def_body( entry->Body->Type ); | 					CodeBody new_body = def_body( entry->Body->Type ); | ||||||
| 					for ( Code body_entry = body.begin(); body_entry != body.end(); ++ body_entry ) switch | 					for ( Code body_entry = body.begin(); body_entry != body.end(); ++ body_entry ) switch | ||||||
| 					(body_entry->Type) { | 					(body_entry->Type) { | ||||||
| 						case ECode::Preprocess_If: | 						case CT_Preprocess_If: | ||||||
| 						{ | 						{ | ||||||
| 							b32 found = ignore_preprocess_cond_block(txt("! GEN_COMPILER_C"), body_entry, body ); | 							b32 found = ignore_preprocess_cond_block(txt("! GEN_COMPILER_C"), body_entry, body ); | ||||||
| 							if (found) break; | 							if (found) break; | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ using namespace gen; | |||||||
|  |  | ||||||
| CodeBody gen_fixed_arenas() | CodeBody gen_fixed_arenas() | ||||||
| { | { | ||||||
| 	CodeBody result = def_body(ECode::Global_Body); | 	CodeBody result = def_body(CT_Global_Body); | ||||||
| 	result.append(def_pragma(txt("region FixedArena"))); | 	result.append(def_pragma(txt("region FixedArena"))); | ||||||
|  |  | ||||||
| 	char const* template_struct = stringize( | 	char const* template_struct = stringize( | ||||||
|   | |||||||
| @@ -17,13 +17,13 @@ b32 ignore_preprocess_cond_block( StrC cond_sig, Code& entry_iter, CodeBody& bod | |||||||
| 		s32 depth = 1; | 		s32 depth = 1; | ||||||
| 		++ entry_iter; for(b32 continue_for = true; continue_for && entry_iter != body.end(); ) switch | 		++ entry_iter; for(b32 continue_for = true; continue_for && entry_iter != body.end(); ) switch | ||||||
| 		(entry_iter->Type) { | 		(entry_iter->Type) { | ||||||
| 			case ECode::Preprocess_If: | 			case CT_Preprocess_If: | ||||||
| 			case ECode::Preprocess_IfDef: | 			case CT_Preprocess_IfDef: | ||||||
| 			case ECode::Preprocess_IfNotDef: | 			case CT_Preprocess_IfNotDef: | ||||||
| 				depth ++; | 				depth ++; | ||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| 			case ECode::Preprocess_EndIf: | 			case CT_Preprocess_EndIf: | ||||||
| 			{ | 			{ | ||||||
| 				depth --; | 				depth --; | ||||||
| 				if (depth == 0) { | 				if (depth == 0) { | ||||||
| @@ -56,7 +56,7 @@ bool swap_pragma_region_implementation( StrC region_name, SwapContentProc* swap_ | |||||||
|  |  | ||||||
| 		++ entry_iter; for(b32 continue_for = true; continue_for; ++entry_iter) switch | 		++ entry_iter; for(b32 continue_for = true; continue_for; ++entry_iter) switch | ||||||
| 		(entry_iter->Type) { | 		(entry_iter->Type) { | ||||||
| 			case ECode::Preprocess_Pragma: | 			case CT_Preprocess_Pragma: | ||||||
| 			{ | 			{ | ||||||
| 				CodePragma possible_end_region = cast(CodePragma, entry_iter); | 				CodePragma possible_end_region = cast(CodePragma, entry_iter); | ||||||
| 				if ( possible_end_region->Content.contains(endregion_sig) ) { | 				if ( possible_end_region->Content.contains(endregion_sig) ) { | ||||||
|   | |||||||
| @@ -43,7 +43,7 @@ void Builder::print_fmt( char const* fmt, ... ) | |||||||
| 	va_end( va ); | 	va_end( va ); | ||||||
|  |  | ||||||
| 	// log_fmt( "$%s - print_fmt: %.*s\n", File.filename, res > 80 ? 80 : res, buf ); | 	// log_fmt( "$%s - print_fmt: %.*s\n", File.filename, res > 80 ? 80 : res, buf ); | ||||||
| 	append( & Buffer, buf, res ); | 	append( (String*) & Buffer, (char const*)buf, res ); | ||||||
| } | } | ||||||
|  |  | ||||||
| void Builder::write() | void Builder::write() | ||||||
|   | |||||||
| @@ -39,7 +39,7 @@ Code scan_file( char const* path ) | |||||||
| 		const StrC def_intellisense = txt("GEN_INTELLISENSE_DIRECTIVES" ); | 		const StrC def_intellisense = txt("GEN_INTELLISENSE_DIRECTIVES" ); | ||||||
|  |  | ||||||
| 		bool        found_directive = false; | 		bool        found_directive = false; | ||||||
| 		char const* scanner         = str.Data; | 		char const* scanner         = (char const*)str; | ||||||
| 		s32         left            = fsize; | 		s32         left            = fsize; | ||||||
| 		while ( left ) | 		while ( left ) | ||||||
| 		{ | 		{ | ||||||
| @@ -94,7 +94,7 @@ Code scan_file( char const* path ) | |||||||
| 						move_fwd(); | 						move_fwd(); | ||||||
|  |  | ||||||
| 					// sptr skip_size = fsize - left; | 					// sptr skip_size = fsize - left; | ||||||
| 					if ( (scanner + 2) >= ( str.Data + fsize ) ) | 					if ( (scanner + 2) >= ( (char const*) str + fsize ) ) | ||||||
| 					{ | 					{ | ||||||
| 						mem_move( str, scanner, left ); | 						mem_move( str, scanner, left ); | ||||||
| 						get_header(str)->Length = left; | 						get_header(str)->Length = left; | ||||||
| @@ -106,7 +106,6 @@ Code scan_file( char const* path ) | |||||||
|  |  | ||||||
| 					break; | 					break; | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			move_fwd(); | 			move_fwd(); | ||||||
| @@ -117,7 +116,7 @@ Code scan_file( char const* path ) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	file_close( & file ); | 	file_close( & file ); | ||||||
| 	return untyped_str( str ); | 	return untyped_str( to_strc(str) ); | ||||||
| } | } | ||||||
|  |  | ||||||
| #if 0 | #if 0 | ||||||
|   | |||||||
| @@ -621,9 +621,9 @@ bool is_equal( Code self, Code other ) | |||||||
| 		        "AST  : %S\n"                                 \ | 		        "AST  : %S\n"                                 \ | ||||||
| 		        "Other: %S\n"                                 \ | 		        "Other: %S\n"                                 \ | ||||||
| 		    , debug_str(self)                                 \ | 		    , debug_str(self)                                 \ | ||||||
| 		    ,debug_str(other)                              \ | 		    ,debug_str(other)                                 \ | ||||||
| 		);                                                    \ | 		);                                                    \ | ||||||
| 	                                                          \ |                                                               \ | ||||||
| 		return false;                                         \ | 		return false;                                         \ | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -634,7 +634,7 @@ bool is_equal( Code self, Code other ) | |||||||
| 				"AST  : %S\n"                                       \ | 				"AST  : %S\n"                                       \ | ||||||
| 				"Other: %S\n"                                       \ | 				"Other: %S\n"                                       \ | ||||||
| 			, debug_str(self)                                       \ | 			, debug_str(self)                                       \ | ||||||
| 			,debug_str(other)                                    \ | 			,debug_str(other)                                       \ | ||||||
| 		);                                                          \ | 		);                                                          \ | ||||||
| 	                                                                \ | 	                                                                \ | ||||||
| 		return false;                                               \ | 		return false;                                               \ | ||||||
| @@ -647,15 +647,15 @@ bool is_equal( Code self, Code other ) | |||||||
| 				"AST  : %S\n"                                             \ | 				"AST  : %S\n"                                             \ | ||||||
| 				"Other: %S\n"                                             \ | 				"Other: %S\n"                                             \ | ||||||
| 			, debug_str(self)                                             \ | 			, debug_str(self)                                             \ | ||||||
| 			,debug_str(other)                                          \ | 			,debug_str(other)                                             \ | ||||||
| 		);                                                                \ | 		);                                                                \ | ||||||
|                                                                           \ |                                                                           \ | ||||||
| 		log_fmt("Content cannot be trusted to be unique with this check " \ | 		log_fmt("Content cannot be trusted to be unique with this check " \ | ||||||
| 			"so it must be verified by eye for now\n"                     \ | 			"so it must be verified by eye for now\n"                     \ | ||||||
| 			"AST   Content:\n%S\n"                                        \ | 			"AST   Content:\n%S\n"                                        \ | ||||||
| 			"Other Content:\n%S\n"                                        \ | 			"Other Content:\n%S\n"                                        \ | ||||||
| 			, visualize_whitespace(self->content)                         \ | 			, visualize_whitespace(self->content, GlobalAllocator)        \ | ||||||
| 			, visualize_whitespace(other->content)                        \ | 			, visualize_whitespace(other->content, GlobalAllocator)       \ | ||||||
| 		);                                                                \ | 		);                                                                \ | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -669,14 +669,14 @@ bool is_equal( Code self, Code other ) | |||||||
| 					"Other: %s\n"                                                                  \ | 					"Other: %s\n"                                                                  \ | ||||||
| 					"For ast member: %s\n"                                                         \ | 					"For ast member: %s\n"                                                         \ | ||||||
| 				, debug_str(self)                                                                  \ | 				, debug_str(self)                                                                  \ | ||||||
| 				, debug_str(other)                                                               \ | 				, debug_str(other)                                                                 \ | ||||||
| 				, debug_str(self->ast)                                                           \ | 				, debug_str(self->ast)                                                             \ | ||||||
| 			);                                                                                     \ | 			);                                                                                     \ | ||||||
|                                                                                                    \ |                                                                                                    \ | ||||||
| 			return false;                                                                          \ | 			return false;                                                                          \ | ||||||
| 		}                                                                                          \ | 		}                                                                                          \ | ||||||
|                                                                                                    \ |                                                                                                    \ | ||||||
| 		if ( ! is_equal(self->ast, other->ast ) )                                                 \ | 		if ( ! is_equal(self->ast, other->ast ) )                                                  \ | ||||||
| 		{                                                                                          \ | 		{                                                                                          \ | ||||||
| 			log_fmt( "\nAST::is_equal: Failed for " #ast"\n"                                       \ | 			log_fmt( "\nAST::is_equal: Failed for " #ast"\n"                                       \ | ||||||
| 			         "AST  : %S\n"                                                                 \ | 			         "AST  : %S\n"                                                                 \ | ||||||
| @@ -684,9 +684,9 @@ bool is_equal( Code self, Code other ) | |||||||
| 			         "For     ast member: %S\n"                                                    \ | 			         "For     ast member: %S\n"                                                    \ | ||||||
| 			         "other's ast member: %S\n"                                                    \ | 			         "other's ast member: %S\n"                                                    \ | ||||||
| 				, debug_str(self)                                                                  \ | 				, debug_str(self)                                                                  \ | ||||||
| 				, debug_str(other)                                                               \ | 				, debug_str(other)                                                                 \ | ||||||
| 				, debug_str(self->ast)                                                           \ | 				, debug_str(self->ast)                                                             \ | ||||||
| 				, debug_str(other->ast)                                                          \ | 				, debug_str(other->ast)                                                            \ | ||||||
| 			);                                                                                     \ | 			);                                                                                     \ | ||||||
| 		                                                                                           \ | 		                                                                                           \ | ||||||
| 			return false;                                                                          \ | 			return false;                                                                          \ | ||||||
| @@ -711,7 +711,6 @@ bool is_equal( Code self, Code other ) | |||||||
| 		case CT_Untyped: | 		case CT_Untyped: | ||||||
| 		{ | 		{ | ||||||
| 			check_member_content( Content ); | 			check_member_content( Content ); | ||||||
|  |  | ||||||
| 			return true; | 			return true; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -1147,19 +1146,19 @@ bool is_equal( Code self, Code other ) | |||||||
|  |  | ||||||
| bool validate_body(Code self) | bool validate_body(Code self) | ||||||
| { | { | ||||||
| #define CheckEntries( Unallowed_Types )                                                               \ | #define CheckEntries( Unallowed_Types )                                                                     \ | ||||||
| 	do                                                                                                \ | 	do                                                                                                      \ | ||||||
| 	{                                                                                                 \ | 	{                                                                                                       \ | ||||||
| 		for ( Code entry : cast(CodeBody, self) )                                                    \ | 		for ( Code entry : cast(CodeBody, self) )                                                           \ | ||||||
| 		{                                                                                             \ | 		{                                                                                                   \ | ||||||
| 			switch ( entry->Type )                                                                    \ | 			switch ( entry->Type )                                                                          \ | ||||||
| 			{                                                                                         \ | 			{                                                                                               \ | ||||||
| 				Unallowed_Types                                                                       \ | 				Unallowed_Types                                                                             \ | ||||||
| 					log_failure( "AST::validate_body: Invalid entry in body %s", GEN_NS debug_str(entry) );  \ | 					log_failure( "AST::validate_body: Invalid entry in body %s", GEN_NS debug_str(entry) ); \ | ||||||
| 					return false;                                                                     \ | 					return false;                                                                           \ | ||||||
| 			}                                                                                         \ | 			}                                                                                               \ | ||||||
| 		}                                                                                             \ | 		}                                                                                                   \ | ||||||
| 	}                                                                                                 \ | 	}                                                                                                       \ | ||||||
| 	while (0); | 	while (0); | ||||||
|  |  | ||||||
| 	switch ( self->Type ) | 	switch ( self->Type ) | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| String to_string(CodeAttributes attributes) { | String to_string(CodeAttributes attributes) { | ||||||
| 	return GEN_NS duplicate( attributes->Content, GlobalAllocator ); | 	return {(char*) duplicate( attributes->Content, GlobalAllocator ).Ptr}; | ||||||
| } | } | ||||||
|  |  | ||||||
| String to_string(CodeBody body) | String to_string(CodeBody body) | ||||||
| @@ -68,7 +68,7 @@ void to_string_export( CodeBody body, String* result ) | |||||||
|  |  | ||||||
| String to_string(CodeComment comment) | String to_string(CodeComment comment) | ||||||
| { | { | ||||||
| 	return GEN_NS duplicate( comment->Content, GlobalAllocator ); | 	return {(char*) duplicate( comment->Content, GlobalAllocator ).Ptr}; | ||||||
| } | } | ||||||
|  |  | ||||||
| String to_string(CodeConstructor self) | String to_string(CodeConstructor self) | ||||||
| @@ -97,17 +97,17 @@ void to_string_def(CodeConstructor self, String* result ) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( self->Params ) | 	if ( self->Params ) | ||||||
| 		append_fmt( result, "( %S )", GEN_NS to_string(self->Params) ); | 		append_fmt( result, "( %S )", to_string(self->Params) ); | ||||||
| 	else | 	else | ||||||
| 		append( result, "()" ); | 		append( result, "()" ); | ||||||
|  |  | ||||||
| 	if ( self->InitializerList ) | 	if ( self->InitializerList ) | ||||||
| 		append_fmt( result, " : %S", GEN_NS to_string(self->InitializerList) ); | 		append_fmt( result, " : %S", to_string(self->InitializerList) ); | ||||||
|  |  | ||||||
| 	if ( self->InlineCmt ) | 	if ( self->InlineCmt ) | ||||||
| 		append_fmt( result, " // %S", self->InlineCmt->Content ); | 		append_fmt( result, " // %SC", self->InlineCmt->Content ); | ||||||
|  |  | ||||||
| 	append_fmt( result, "\n{\n%S\n}\n", GEN_NS to_string(self->Body) ); | 	append_fmt( result, "\n{\n%S\n}\n", to_string(self->Body) ); | ||||||
| } | } | ||||||
|  |  | ||||||
| void to_string_fwd(CodeConstructor self, String* result ) | void to_string_fwd(CodeConstructor self, String* result ) | ||||||
| @@ -121,15 +121,15 @@ void to_string_fwd(CodeConstructor self, String* result ) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( self->Params ) | 	if ( self->Params ) | ||||||
| 		append_fmt( result, "( %S )", GEN_NS to_string(self->Params) ); | 		append_fmt( result, "( %S )", to_string(self->Params) ); | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, "()"); | 		append_fmt( result, "()"); | ||||||
|  |  | ||||||
| 	if (self->Body) | 	if (self->Body) | ||||||
| 		append_fmt( result, " = %S", GEN_NS to_string(self->Body) ); | 		append_fmt( result, " = %S", to_string(self->Body) ); | ||||||
|  |  | ||||||
| 	if ( self->InlineCmt ) | 	if ( self->InlineCmt ) | ||||||
| 		append_fmt( result, "; // %S\n", self->InlineCmt->Content ); | 		append_fmt( result, "; // %SC\n", self->InlineCmt->Content ); | ||||||
| 	else | 	else | ||||||
| 		append( result, ";\n" ); | 		append( result, ";\n" ); | ||||||
| } | } | ||||||
| @@ -168,7 +168,7 @@ void to_string_def( CodeClass self, String* result ) | |||||||
| 	{ | 	{ | ||||||
| 		char const* access_level = to_str( ast->ParentAccess ); | 		char const* access_level = to_str( ast->ParentAccess ); | ||||||
|  |  | ||||||
| 		append_fmt( result, "%S : %s %S", ast->Name, access_level, to_string(ast->ParentType) ); | 		append_fmt( result, "%SC : %s %S", ast->Name, access_level, to_string(ast->ParentType) ); | ||||||
|  |  | ||||||
| 		CodeTypename interface = cast(CodeTypename, ast->ParentType->Next); | 		CodeTypename interface = cast(CodeTypename, ast->ParentType->Next); | ||||||
| 		if ( interface ) | 		if ( interface ) | ||||||
| @@ -187,10 +187,10 @@ void to_string_def( CodeClass self, String* result ) | |||||||
|  |  | ||||||
| 	if ( ast->InlineCmt ) | 	if ( ast->InlineCmt ) | ||||||
| 	{ | 	{ | ||||||
| 		append_fmt( result, " // %S", ast->InlineCmt->Content ); | 		append_fmt( result, " // %SC", ast->InlineCmt->Content ); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	append_fmt( result, "\n{\n%S\n}", GEN_NS to_string(ast->Body) ); | 	append_fmt( result, "\n{\n%S\n}", to_string(ast->Body) ); | ||||||
|  |  | ||||||
| 	if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) | 	if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) | ||||||
| 		append( result, ";\n"); | 		append( result, ";\n"); | ||||||
| @@ -205,15 +205,15 @@ void to_string_fwd( CodeClass self, String* result ) | |||||||
| 		append( result, "export " ); | 		append( result, "export " ); | ||||||
|  |  | ||||||
| 	if ( ast->Attributes ) | 	if ( ast->Attributes ) | ||||||
| 		append_fmt( result, "class %S %S", to_string(ast->Attributes), ast->Name ); | 		append_fmt( result, "class %S %SC", to_string(ast->Attributes), ast->Name ); | ||||||
|  |  | ||||||
| 	else append_fmt( result, "class %S", ast->Name ); | 	else append_fmt( result, "class %SC", ast->Name ); | ||||||
|  |  | ||||||
| 	// Check if it can have an end-statement | 	// Check if it can have an end-statement | ||||||
| 	if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) | 	if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) | ||||||
| 	{ | 	{ | ||||||
| 		if ( ast->InlineCmt ) | 		if ( ast->InlineCmt ) | ||||||
| 			append_fmt( result, "; // %S\n", ast->InlineCmt->Content ); | 			append_fmt( result, "; // %SC\n", ast->InlineCmt->Content ); | ||||||
| 		else | 		else | ||||||
| 			append( result,";\n"); | 			append( result,";\n"); | ||||||
| 	} | 	} | ||||||
| @@ -221,12 +221,12 @@ void to_string_fwd( CodeClass self, String* result ) | |||||||
|  |  | ||||||
| String to_string(CodeDefine define) | String to_string(CodeDefine define) | ||||||
| { | { | ||||||
| 	return string_fmt_buf( GlobalAllocator, "#define %S %S\n", define->Name, define->Content ); | 	return string_fmt_buf( GlobalAllocator, "#define %SC %SC\n", define->Name, define->Content ); | ||||||
| } | } | ||||||
|  |  | ||||||
| void to_string(CodeDefine define, String* result ) | void to_string(CodeDefine define, String* result ) | ||||||
| { | { | ||||||
| 	append_fmt( result, "#define %S %S\n", define->Name, define->Content ); | 	append_fmt( result, "#define %SC %SC\n", define->Name, define->Content ); | ||||||
| } | } | ||||||
|  |  | ||||||
| String to_string(CodeDestructor self) | String to_string(CodeDestructor self) | ||||||
| @@ -248,19 +248,19 @@ void to_string_def(CodeDestructor self, String* result ) | |||||||
| { | { | ||||||
| 	if ( self->Name ) | 	if ( self->Name ) | ||||||
| 	{ | 	{ | ||||||
| 		append_fmt( result, "%S()", self->Name ); | 		append_fmt( result, "%SC()", self->Name ); | ||||||
| 	} | 	} | ||||||
| 	else if ( self->Specs ) | 	else if ( self->Specs ) | ||||||
| 	{ | 	{ | ||||||
| 		if ( has(self->Specs, Spec_Virtual ) ) | 		if ( has(self->Specs, Spec_Virtual ) ) | ||||||
| 			append_fmt( result, "virtual ~%S()", self->Parent->Name ); | 			append_fmt( result, "virtual ~%SC()", self->Parent->Name ); | ||||||
| 		else | 		else | ||||||
| 			append_fmt( result, "~%S()", self->Parent->Name ); | 			append_fmt( result, "~%SC()", self->Parent->Name ); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, "~%S()", self->Parent->Name ); | 		append_fmt( result, "~%SC()", self->Parent->Name ); | ||||||
|  |  | ||||||
| 	append_fmt( result, "\n{\n%S\n}\n", GEN_NS to_string(self->Body) ); | 	append_fmt( result, "\n{\n%S\n}\n", to_string(self->Body) ); | ||||||
| } | } | ||||||
|  |  | ||||||
| void to_string_fwd(CodeDestructor self, String* result ) | void to_string_fwd(CodeDestructor self, String* result ) | ||||||
| @@ -268,20 +268,20 @@ void to_string_fwd(CodeDestructor self, String* result ) | |||||||
| 	if ( self->Specs ) | 	if ( self->Specs ) | ||||||
| 	{ | 	{ | ||||||
| 		if ( has(self->Specs, Spec_Virtual ) ) | 		if ( has(self->Specs, Spec_Virtual ) ) | ||||||
| 			append_fmt( result, "virtual ~%S();\n", self->Parent->Name ); | 			append_fmt( result, "virtual ~%SC();\n", self->Parent->Name ); | ||||||
| 		else | 		else | ||||||
| 			append_fmt( result, "~%S()", self->Parent->Name ); | 			append_fmt( result, "~%SC()", self->Parent->Name ); | ||||||
|  |  | ||||||
| 		if ( has(self->Specs, Spec_Pure ) ) | 		if ( has(self->Specs, Spec_Pure ) ) | ||||||
| 			append( result, " = 0;" ); | 			append( result, " = 0;" ); | ||||||
| 		else if (self->Body) | 		else if (self->Body) | ||||||
| 			append_fmt( result, " = %S;", GEN_NS to_string(self->Body) ); | 			append_fmt( result, " = %S;", to_string(self->Body) ); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, "~%S();", self->Parent->Name ); | 		append_fmt( result, "~%SC();", self->Parent->Name ); | ||||||
|  |  | ||||||
| 	if ( self->InlineCmt ) | 	if ( self->InlineCmt ) | ||||||
| 		append_fmt( result, "  %S", self->InlineCmt->Content ); | 		append_fmt( result, "  %SC", self->InlineCmt->Content ); | ||||||
| 	else | 	else | ||||||
| 		append( result, "\n"); | 		append( result, "\n"); | ||||||
| } | } | ||||||
| @@ -317,24 +317,24 @@ void to_string_def(CodeEnum self, String* result ) | |||||||
| 		append( result, "enum " ); | 		append( result, "enum " ); | ||||||
|  |  | ||||||
| 		if ( self->Attributes ) | 		if ( self->Attributes ) | ||||||
| 			append_fmt( result, "%S ", GEN_NS to_string(self->Attributes) ); | 			append_fmt( result, "%S ", to_string(self->Attributes) ); | ||||||
|  |  | ||||||
| 		if ( self->UnderlyingType ) | 		if ( self->UnderlyingType ) | ||||||
| 			append_fmt( result, "%S : %S\n{\n%S\n}" | 			append_fmt( result, "%SC : %S\n{\n%S\n}" | ||||||
| 				, self->Name | 				, self->Name | ||||||
| 				, to_string(self->UnderlyingType) | 				, to_string(self->UnderlyingType) | ||||||
| 				, GEN_NS to_string(self->Body) | 				, to_string(self->Body) | ||||||
| 			); | 			); | ||||||
| 		else if ( self->UnderlyingTypeMacro ) | 		else if ( self->UnderlyingTypeMacro ) | ||||||
| 			append_fmt( result, "%S : %S\n{\n%S\n}" | 			append_fmt( result, "%SC : %S\n{\n%S\n}" | ||||||
| 				, self->Name | 				, self->Name | ||||||
| 				, GEN_NS to_string(self->UnderlyingTypeMacro) | 				, to_string(self->UnderlyingTypeMacro) | ||||||
| 				, GEN_NS to_string(self->Body) | 				, to_string(self->Body) | ||||||
| 			); | 			); | ||||||
|  |  | ||||||
| 		else append_fmt( result, "%S\n{\n%S\n}", self->Name, GEN_NS to_string(self->Body) ); | 		else append_fmt( result, "%SC\n{\n%S\n}", self->Name, to_string(self->Body) ); | ||||||
| 	} | 	} | ||||||
| 	else append_fmt( result, "enum %S\n{\n%S\n}", self->Name, GEN_NS to_string(self->Body) ); | 	else append_fmt( result, "enum %SC\n{\n%S\n}", self->Name, to_string(self->Body) ); | ||||||
|  |  | ||||||
| 	if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) | 	if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) | ||||||
| 		append( result, ";\n"); | 		append( result, ";\n"); | ||||||
| @@ -346,17 +346,17 @@ void to_string_fwd(CodeEnum self, String* result ) | |||||||
| 		append( result, "export " ); | 		append( result, "export " ); | ||||||
|  |  | ||||||
| 	if ( self->Attributes ) | 	if ( self->Attributes ) | ||||||
| 		append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) ); | 		append_fmt( result, "%S ", to_string(self->Attributes) ); | ||||||
|  |  | ||||||
| 	if ( self->UnderlyingType ) | 	if ( self->UnderlyingType ) | ||||||
| 		append_fmt( result, "enum %S : %S", self->Name, to_string(self->UnderlyingType) ); | 		append_fmt( result, "enum %SC : %S", self->Name, to_string(self->UnderlyingType) ); | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, "enum %S", self->Name ); | 		append_fmt( result, "enum %SC", self->Name ); | ||||||
|  |  | ||||||
| 	if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) | 	if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) | ||||||
| 	{ | 	{ | ||||||
| 		if ( self->InlineCmt ) | 		if ( self->InlineCmt ) | ||||||
| 			append_fmt( result, ";  %S", self->InlineCmt->Content ); | 			append_fmt( result, ";  %SC", self->InlineCmt->Content ); | ||||||
| 		else | 		else | ||||||
| 			append( result, ";\n"); | 			append( result, ";\n"); | ||||||
| 	} | 	} | ||||||
| @@ -373,21 +373,21 @@ void to_string_class_def(CodeEnum self, String* result ) | |||||||
|  |  | ||||||
| 		if ( self->Attributes ) | 		if ( self->Attributes ) | ||||||
| 		{ | 		{ | ||||||
| 			append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) ); | 			append_fmt( result, "%S ", to_string(self->Attributes) ); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if ( self->UnderlyingType ) | 		if ( self->UnderlyingType ) | ||||||
| 		{ | 		{ | ||||||
| 			append_fmt( result, "%S : %S\n{\n%S\n}", self->Name, to_string(self->UnderlyingType), GEN_NS to_string(self->Body) ); | 			append_fmt( result, "%SC : %S\n{\n%S\n}", self->Name, to_string(self->UnderlyingType), to_string(self->Body) ); | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| 		{ | 		{ | ||||||
| 			append_fmt( result, "%S\n{\n%S\n}", self->Name, GEN_NS to_string(self->Body) ); | 			append_fmt( result, "%SC\n{\n%S\n}", self->Name, to_string(self->Body) ); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		append_fmt( result, "enum class %S\n{\n%S\n}", GEN_NS to_string(self->Body) ); | 		append_fmt( result, "enum %SC\n{\n%S\n}", self->Name, to_string(self->Body) ); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) | 	if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) | ||||||
| @@ -402,14 +402,14 @@ void to_string_class_fwd(CodeEnum self, String* result ) | |||||||
| 	append( result, "enum class " ); | 	append( result, "enum class " ); | ||||||
|  |  | ||||||
| 	if ( self->Attributes ) | 	if ( self->Attributes ) | ||||||
| 		append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) ); | 		append_fmt( result, "%S ", to_string(self->Attributes) ); | ||||||
|  |  | ||||||
| 	append_fmt( result, "%S : %S", self->Name, to_string(self->UnderlyingType) ); | 	append_fmt( result, "%SC : %S", self->Name, to_string(self->UnderlyingType) ); | ||||||
|  |  | ||||||
| 	if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) | 	if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) | ||||||
| 	{ | 	{ | ||||||
| 		if ( self->InlineCmt ) | 		if ( self->InlineCmt ) | ||||||
| 			append_fmt( result, ";  %S", self->InlineCmt->Content ); | 			append_fmt( result, ";  %SC", self->InlineCmt->Content ); | ||||||
| 		else | 		else | ||||||
| 			append( result, ";\n"); | 			append( result, ";\n"); | ||||||
| 	} | 	} | ||||||
| @@ -417,25 +417,25 @@ void to_string_class_fwd(CodeEnum self, String* result ) | |||||||
|  |  | ||||||
| String to_string(CodeExec exec) | String to_string(CodeExec exec) | ||||||
| { | { | ||||||
| 	return GEN_NS duplicate( exec->Content, GlobalAllocator ); | 	return {(char*) duplicate( exec->Content, GlobalAllocator ).Ptr}; | ||||||
| } | } | ||||||
|  |  | ||||||
| void to_string(CodeExtern self, String* result ) | void to_string(CodeExtern self, String* result ) | ||||||
| { | { | ||||||
| 	if ( self->Body ) | 	if ( self->Body ) | ||||||
| 		append_fmt( result, "extern \"%S\"\n{\n%S\n}\n", self->Name, GEN_NS to_string(self->Body) ); | 		append_fmt( result, "extern \"%SC\"\n{\n%S\n}\n", self->Name, to_string(self->Body) ); | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, "extern \"%S\"\n{}\n", self->Name ); | 		append_fmt( result, "extern \"%SC\"\n{}\n", self->Name ); | ||||||
| } | } | ||||||
|  |  | ||||||
| String to_string(CodeInclude include) | String to_string(CodeInclude include) | ||||||
| { | { | ||||||
| 	return string_fmt_buf( GlobalAllocator, "#include %S\n", include->Content ); | 	return string_fmt_buf( GlobalAllocator, "#include %SC\n", include->Content ); | ||||||
| } | } | ||||||
|  |  | ||||||
| void to_string( CodeInclude include, String* result ) | void to_string( CodeInclude include, String* result ) | ||||||
| { | { | ||||||
| 	append_fmt( result, "#include %S\n", include->Content ); | 	append_fmt( result, "#include %SC\n", include->Content ); | ||||||
| } | } | ||||||
|  |  | ||||||
| String to_string(CodeFriend self) | String to_string(CodeFriend self) | ||||||
| @@ -447,15 +447,15 @@ String to_string(CodeFriend self) | |||||||
|  |  | ||||||
| void to_string(CodeFriend self, String* result ) | void to_string(CodeFriend self, String* result ) | ||||||
| { | { | ||||||
| 	append_fmt( result, "friend %S", GEN_NS to_string(self->Declaration) ); | 	append_fmt( result, "friend %S", to_string(self->Declaration) ); | ||||||
|  |  | ||||||
| 	if ( self->Declaration->Type != CT_Function && (* result)[ length(* result) - 1 ] != ';' ) | 	if ( self->Declaration->Type != CT_Function && self->Declaration->Type != CT_Operator && (* result)[ length(* result) - 1 ] != ';' ) | ||||||
| 	{ | 	{ | ||||||
| 		append( result, ";" ); | 		append( result, ";" ); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( self->InlineCmt ) | 	if ( self->InlineCmt ) | ||||||
| 		append_fmt( result, "  %S", self->InlineCmt->Content ); | 		append_fmt( result, "  %SC", self->InlineCmt->Content ); | ||||||
| 	else | 	else | ||||||
| 		append( result, "\n"); | 		append( result, "\n"); | ||||||
| } | } | ||||||
| @@ -481,7 +481,7 @@ void to_string_def(CodeFn self, String* result ) | |||||||
| 		append( result, "export" ); | 		append( result, "export" ); | ||||||
|  |  | ||||||
| 	if ( self->Attributes ) | 	if ( self->Attributes ) | ||||||
| 		append_fmt( result, " %S ",GEN_NS to_string(self->Attributes) ); | 		append_fmt( result, " %S ", to_string(self->Attributes) ); | ||||||
|  |  | ||||||
| 	bool prefix_specs = false; | 	bool prefix_specs = false; | ||||||
| 	if ( self->Specs ) | 	if ( self->Specs ) | ||||||
| @@ -502,13 +502,13 @@ void to_string_def(CodeFn self, String* result ) | |||||||
| 		append( result, "\n" ); | 		append( result, "\n" ); | ||||||
|  |  | ||||||
| 	if ( self->ReturnType ) | 	if ( self->ReturnType ) | ||||||
| 		append_fmt( result, "%S %S(", to_string(self->ReturnType), self->Name ); | 		append_fmt( result, "%S %SC(", to_string(self->ReturnType), self->Name ); | ||||||
|  |  | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, "%S(", self->Name ); | 		append_fmt( result, "%SC(", self->Name ); | ||||||
|  |  | ||||||
| 	if ( self->Params ) | 	if ( self->Params ) | ||||||
| 		append_fmt( result, "%S)", GEN_NS to_string(self->Params) ); | 		append_fmt( result, "%S)", to_string(self->Params) ); | ||||||
|  |  | ||||||
| 	else | 	else | ||||||
| 		append( result, ")" ); | 		append( result, ")" ); | ||||||
| @@ -525,7 +525,7 @@ void to_string_def(CodeFn self, String* result ) | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	append_fmt( result, "\n{\n%S\n}\n", GEN_NS to_string(self->Body) ); | 	append_fmt( result, "\n{\n%S\n}\n", to_string(self->Body) ); | ||||||
| } | } | ||||||
|  |  | ||||||
| void to_string_fwd(CodeFn self, String* result ) | void to_string_fwd(CodeFn self, String* result ) | ||||||
| @@ -534,7 +534,7 @@ void to_string_fwd(CodeFn self, String* result ) | |||||||
| 		append( result, "export " ); | 		append( result, "export " ); | ||||||
|  |  | ||||||
| 	if ( self->Attributes ) | 	if ( self->Attributes ) | ||||||
| 		append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) ); | 		append_fmt( result, "%S ", to_string(self->Attributes) ); | ||||||
|  |  | ||||||
| 	b32 prefix_specs = false; | 	b32 prefix_specs = false; | ||||||
| 	if ( self->Specs ) | 	if ( self->Specs ) | ||||||
| @@ -557,13 +557,13 @@ void to_string_fwd(CodeFn self, String* result ) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( self->ReturnType ) | 	if ( self->ReturnType ) | ||||||
| 		append_fmt( result, "%S %S(", to_string(self->ReturnType), self->Name ); | 		append_fmt( result, "%S %SC(", to_string(self->ReturnType), self->Name ); | ||||||
|  |  | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, "%S(", self->Name ); | 		append_fmt( result, "%SC(", self->Name ); | ||||||
|  |  | ||||||
| 	if ( self->Params ) | 	if ( self->Params ) | ||||||
| 		append_fmt( result, "%S)", GEN_NS to_string(self->Params) ); | 		append_fmt( result, "%S)", to_string(self->Params) ); | ||||||
|  |  | ||||||
| 	else | 	else | ||||||
| 		append( result, ")" ); | 		append( result, ")" ); | ||||||
| @@ -583,10 +583,10 @@ void to_string_fwd(CodeFn self, String* result ) | |||||||
| 	if ( self->Specs && has(self->Specs, Spec_Pure ) >= 0 ) | 	if ( self->Specs && has(self->Specs, Spec_Pure ) >= 0 ) | ||||||
| 		append( result, " = 0;" ); | 		append( result, " = 0;" ); | ||||||
| 	else if (self->Body) | 	else if (self->Body) | ||||||
| 		append_fmt( result, " = %S;", GEN_NS to_string(self->Body) ); | 		append_fmt( result, " = %S;", to_string(self->Body) ); | ||||||
|  |  | ||||||
| 	if ( self->InlineCmt ) | 	if ( self->InlineCmt ) | ||||||
| 		append_fmt( result, ";  %S", self->InlineCmt->Content ); | 		append_fmt( result, ";  %SC", self->InlineCmt->Content ); | ||||||
| 	else | 	else | ||||||
| 		append( result, ";\n" ); | 		append( result, ";\n" ); | ||||||
| } | } | ||||||
| @@ -606,7 +606,7 @@ void to_string(CodeModule self, String* result ) | |||||||
| 	if (((u32(ModuleFlag_Import) & u32(self->ModuleFlags)) == u32(ModuleFlag_Import))) | 	if (((u32(ModuleFlag_Import) & u32(self->ModuleFlags)) == u32(ModuleFlag_Import))) | ||||||
| 		append( result, "import "); | 		append( result, "import "); | ||||||
|  |  | ||||||
| 	append_fmt( result, "%S;\n", self->Name ); | 	append_fmt( result, "%SC;\n", self->Name ); | ||||||
| } | } | ||||||
|  |  | ||||||
| String to_string(CodeNS self) | String to_string(CodeNS self) | ||||||
| @@ -621,7 +621,7 @@ void to_string(CodeNS self, String* result ) | |||||||
| 	if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) | 	if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) | ||||||
| 		append( result, "export " ); | 		append( result, "export " ); | ||||||
|  |  | ||||||
| 	append_fmt( result, "namespace %S\n{\n%S\n}\n", self->Name, to_string(self->Body) ); | 	append_fmt( result, "namespace %SC\n{\n%S\n}\n", self->Name, to_string(self->Body) ); | ||||||
| } | } | ||||||
|  |  | ||||||
| String to_string(CodeOperator self) | String to_string(CodeOperator self) | ||||||
| @@ -647,10 +647,10 @@ void to_string_def(CodeOperator self, String* result ) | |||||||
| 		append( result, "export " ); | 		append( result, "export " ); | ||||||
|  |  | ||||||
| 	if ( self->Attributes ) | 	if ( self->Attributes ) | ||||||
| 		append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) ); | 		append_fmt( result, "%S ", to_string(self->Attributes) ); | ||||||
|  |  | ||||||
| 	if ( self->Attributes ) | 	if ( self->Attributes ) | ||||||
| 		append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) ); | 		append_fmt( result, "%S ", to_string(self->Attributes) ); | ||||||
|  |  | ||||||
| 	if ( self->Specs ) | 	if ( self->Specs ) | ||||||
| 	{ | 	{ | ||||||
| @@ -670,10 +670,10 @@ void to_string_def(CodeOperator self, String* result ) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( self->ReturnType ) | 	if ( self->ReturnType ) | ||||||
| 		append_fmt( result, "%S %S (", GEN_NS to_string(self->ReturnType), self->Name ); | 		append_fmt( result, "%S %SC (", to_string(self->ReturnType), self->Name ); | ||||||
|  |  | ||||||
| 	if ( self->Params ) | 	if ( self->Params ) | ||||||
| 		append_fmt( result, "%S)", GEN_NS to_string(self->Params) ); | 		append_fmt( result, "%S)", to_string(self->Params) ); | ||||||
|  |  | ||||||
| 	else | 	else | ||||||
| 		append( result, ")" ); | 		append( result, ")" ); | ||||||
| @@ -691,7 +691,7 @@ void to_string_def(CodeOperator self, String* result ) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	append_fmt( result, "\n{\n%S\n}\n" | 	append_fmt( result, "\n{\n%S\n}\n" | ||||||
| 		, GEN_NS to_string(self->Body) | 		, to_string(self->Body) | ||||||
| 	); | 	); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -701,7 +701,7 @@ void to_string_fwd(CodeOperator self, String* result ) | |||||||
| 		append( result, "export " ); | 		append( result, "export " ); | ||||||
|  |  | ||||||
| 	if ( self->Attributes ) | 	if ( self->Attributes ) | ||||||
| 		append_fmt( result, "%S\n",GEN_NS to_string(self->Attributes) ); | 		append_fmt( result, "%S\n", to_string(self->Attributes) ); | ||||||
|  |  | ||||||
| 	if ( self->Specs ) | 	if ( self->Specs ) | ||||||
| 	{ | 	{ | ||||||
| @@ -720,10 +720,10 @@ void to_string_fwd(CodeOperator self, String* result ) | |||||||
| 		append( result, "\n" ); | 		append( result, "\n" ); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	append_fmt( result, "%S %S (", to_string(self->ReturnType), self->Name ); | 	append_fmt( result, "%S %SC (", to_string(self->ReturnType), self->Name ); | ||||||
|  |  | ||||||
| 	if ( self->Params ) | 	if ( self->Params ) | ||||||
| 		append_fmt( result, "%S)", GEN_NS to_string(self->Params) ); | 		append_fmt( result, "%S)", to_string(self->Params) ); | ||||||
|  |  | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, ")" ); | 		append_fmt( result, ")" ); | ||||||
| @@ -741,7 +741,7 @@ void to_string_fwd(CodeOperator self, String* result ) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( self->InlineCmt ) | 	if ( self->InlineCmt ) | ||||||
| 		append_fmt( result, ";  %S", self->InlineCmt->Content ); | 		append_fmt( result, ";  %SC", self->InlineCmt->Content ); | ||||||
| 	else | 	else | ||||||
| 		append( result, ";\n" ); | 		append( result, ";\n" ); | ||||||
| } | } | ||||||
| @@ -774,8 +774,8 @@ void to_string_def(CodeOpCast self, String* result ) | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if ( self->Name && length(self->Name) ) | 		if ( self->Name && self->Name.Len ) | ||||||
| 			append_fmt( result, "%Soperator %S()", self->Name, to_string(self->ValueType) ); | 			append_fmt( result, "%SC operator %S()", self->Name, to_string(self->ValueType) ); | ||||||
| 		else | 		else | ||||||
| 			append_fmt( result, "operator %S()", to_string(self->ValueType) ); | 			append_fmt( result, "operator %S()", to_string(self->ValueType) ); | ||||||
|  |  | ||||||
| @@ -788,14 +788,14 @@ void to_string_def(CodeOpCast self, String* result ) | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		append_fmt( result, "\n{\n%S\n}\n", GEN_NS to_string(self->Body) ); | 		append_fmt( result, "\n{\n%S\n}\n", to_string(self->Body) ); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( self->Name && length(self->Name) ) | 	if ( self->Name && self->Name.Len ) | ||||||
| 		append_fmt( result, "%Soperator %S()\n{\n%S\n}\n", self->Name, to_string(self->ValueType), GEN_NS to_string(self->Body) ); | 		append_fmt( result, "%SC operator %S()\n{\n%S\n}\n", self->Name, to_string(self->ValueType), to_string(self->Body) ); | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, "operator %S()\n{\n%S\n}\n", to_string(self->ValueType), GEN_NS to_string(self->Body) ); | 		append_fmt( result, "operator %S()\n{\n%S\n}\n", to_string(self->ValueType), to_string(self->Body) ); | ||||||
| } | } | ||||||
|  |  | ||||||
| void to_string_fwd(CodeOpCast self, String* result ) | void to_string_fwd(CodeOpCast self, String* result ) | ||||||
| @@ -823,7 +823,7 @@ void to_string_fwd(CodeOpCast self, String* result ) | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if ( self->InlineCmt ) | 		if ( self->InlineCmt ) | ||||||
| 			append_fmt( result, ";  %S", self->InlineCmt->Content ); | 			append_fmt( result, ";  %SC", self->InlineCmt->Content ); | ||||||
| 		else | 		else | ||||||
| 			append( result, ";\n" ); | 			append( result, ";\n" ); | ||||||
| 		return; | 		return; | ||||||
| @@ -848,16 +848,16 @@ void to_string( CodeParam self, String* result ) | |||||||
| 	if ( ast->Macro ) | 	if ( ast->Macro ) | ||||||
| 	{ | 	{ | ||||||
| 		// Related to parsing: ( <macro>, ... ) | 		// Related to parsing: ( <macro>, ... ) | ||||||
| 		GEN_NS append( result, ast->Macro.ast->Content ); | 		append( result, ast->Macro.ast->Content ); | ||||||
| 		// Could also be: ( <macro> <type <name>, ... ) | 		// Could also be: ( <macro> <type <name>, ... ) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( ast->Name ) | 	if ( ast->Name ) | ||||||
| 	{ | 	{ | ||||||
| 		if ( ast->ValueType.ast == nullptr ) | 		if ( ast->ValueType.ast == nullptr ) | ||||||
| 			append_fmt( result, " %S", ast->Name ); | 			append_fmt( result, " %SC", ast->Name ); | ||||||
| 		else | 		else | ||||||
| 			append_fmt( result, " %S %S", to_string(ast->ValueType), ast->Name ); | 			append_fmt( result, " %S %SC", to_string(ast->ValueType), ast->Name ); | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
| 	else if ( ast->ValueType ) | 	else if ( ast->ValueType ) | ||||||
| @@ -865,11 +865,11 @@ void to_string( CodeParam self, String* result ) | |||||||
|  |  | ||||||
| 	if ( ast->PostNameMacro ) | 	if ( ast->PostNameMacro ) | ||||||
| 	{ | 	{ | ||||||
| 		append_fmt( result, " %S", GEN_NS to_string(ast->PostNameMacro) ); | 		append_fmt( result, " %S", to_string(ast->PostNameMacro) ); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( ast->Value ) | 	if ( ast->Value ) | ||||||
| 		append_fmt( result, " = %S", GEN_NS to_string(ast->Value) ); | 		append_fmt( result, " = %S", to_string(ast->Value) ); | ||||||
|  |  | ||||||
| 	if ( ast->NumEntries - 1 > 0 ) | 	if ( ast->NumEntries - 1 > 0 ) | ||||||
| 	{ | 	{ | ||||||
| @@ -909,22 +909,22 @@ String to_string(CodePreprocessCond self) | |||||||
|  |  | ||||||
| void to_string_if(CodePreprocessCond cond, String* result ) | void to_string_if(CodePreprocessCond cond, String* result ) | ||||||
| { | { | ||||||
| 	append_fmt( result, "#if %S\n", cond->Content ); | 	append_fmt( result, "#if %SC\n", cond->Content ); | ||||||
| } | } | ||||||
|  |  | ||||||
| void to_string_ifdef(CodePreprocessCond cond, String* result ) | void to_string_ifdef(CodePreprocessCond cond, String* result ) | ||||||
| { | { | ||||||
| 	append_fmt( result, "#ifdef %S\n", cond->Content ); | 	append_fmt( result, "#ifdef %SC\n", cond->Content ); | ||||||
| } | } | ||||||
|  |  | ||||||
| void to_string_ifndef(CodePreprocessCond cond, String* result ) | void to_string_ifndef(CodePreprocessCond cond, String* result ) | ||||||
| { | { | ||||||
| 	append_fmt( result, "#ifndef %S\n", cond->Content ); | 	append_fmt( result, "#ifndef %SC\n", cond->Content ); | ||||||
| } | } | ||||||
|  |  | ||||||
| void to_string_elif(CodePreprocessCond cond, String* result ) | void to_string_elif(CodePreprocessCond cond, String* result ) | ||||||
| { | { | ||||||
| 	append_fmt( result, "#elif %S\n", cond->Content ); | 	append_fmt( result, "#elif %SC\n", cond->Content ); | ||||||
| } | } | ||||||
|  |  | ||||||
| void to_string_else(CodePreprocessCond cond, String* result ) | void to_string_else(CodePreprocessCond cond, String* result ) | ||||||
| @@ -946,7 +946,7 @@ String to_string(CodePragma self) | |||||||
|  |  | ||||||
| void to_string(CodePragma self, String* result ) | void to_string(CodePragma self, String* result ) | ||||||
| { | { | ||||||
| 	append_fmt( result, "#pragma %S\n", self->Content ); | 	append_fmt( result, "#pragma %SC\n", self->Content ); | ||||||
| } | } | ||||||
|  |  | ||||||
| String to_string(CodeSpecifiers self) | String to_string(CodeSpecifiers self) | ||||||
| @@ -998,14 +998,14 @@ void to_string_def( CodeStruct self, String* result ) | |||||||
|  |  | ||||||
| 	if ( ast->Attributes ) | 	if ( ast->Attributes ) | ||||||
| 	{ | 	{ | ||||||
| 		append_fmt( result, "%S ",GEN_NS to_string(ast->Attributes) ); | 		append_fmt( result, "%S ", to_string(ast->Attributes) ); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( ast->ParentType ) | 	if ( ast->ParentType ) | ||||||
| 	{ | 	{ | ||||||
| 		char const* access_level = to_str( ast->ParentAccess ); | 		char const* access_level = to_str( ast->ParentAccess ); | ||||||
|  |  | ||||||
| 		append_fmt( result, "%S : %s %S", ast->Name, access_level, GEN_NS to_string(ast->ParentType) ); | 		append_fmt( result, "%SC : %s %S", ast->Name, access_level, to_string(ast->ParentType) ); | ||||||
|  |  | ||||||
| 		CodeTypename interface = cast(CodeTypename, ast->ParentType->Next); | 		CodeTypename interface = cast(CodeTypename, ast->ParentType->Next); | ||||||
| 		if ( interface ) | 		if ( interface ) | ||||||
| @@ -1013,7 +1013,7 @@ void to_string_def( CodeStruct self, String* result ) | |||||||
|  |  | ||||||
| 		while ( interface ) | 		while ( interface ) | ||||||
| 		{ | 		{ | ||||||
| 			append_fmt( result, ", %S", GEN_NS to_string(interface) ); | 			append_fmt( result, ", %S", to_string(interface) ); | ||||||
| 			interface = interface->Next ? cast( CodeTypename, interface->Next) : CodeTypename { nullptr }; | 			interface = interface->Next ? cast( CodeTypename, interface->Next) : CodeTypename { nullptr }; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -1024,10 +1024,10 @@ void to_string_def( CodeStruct self, String* result ) | |||||||
|  |  | ||||||
| 	if ( ast->InlineCmt ) | 	if ( ast->InlineCmt ) | ||||||
| 	{ | 	{ | ||||||
| 		append_fmt( result, " // %S", ast->InlineCmt->Content ); | 		append_fmt( result, " // %SC", ast->InlineCmt->Content ); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	append_fmt( result, "\n{\n%S\n}", GEN_NS to_string(ast->Body) ); | 	append_fmt( result, "\n{\n%S\n}", to_string(ast->Body) ); | ||||||
|  |  | ||||||
| 	if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) | 	if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) | ||||||
| 		append( result, ";\n"); | 		append( result, ";\n"); | ||||||
| @@ -1042,14 +1042,14 @@ void to_string_fwd( CodeStruct self, String* result ) | |||||||
| 		append( result, "export " ); | 		append( result, "export " ); | ||||||
|  |  | ||||||
| 	if ( ast->Attributes ) | 	if ( ast->Attributes ) | ||||||
| 		append_fmt( result, "struct %S %S", GEN_NS to_string(ast->Attributes), ast->Name ); | 		append_fmt( result, "struct %S %SC", to_string(ast->Attributes), ast->Name ); | ||||||
|  |  | ||||||
| 	else append_fmt( result, "struct %S", ast->Name ); | 	else append_fmt( result, "struct %SC", ast->Name ); | ||||||
|  |  | ||||||
| 	if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) | 	if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) | ||||||
| 	{ | 	{ | ||||||
| 		if ( ast->InlineCmt ) | 		if ( ast->InlineCmt ) | ||||||
| 			append_fmt( result, ";  %S", ast->InlineCmt->Content ); | 			append_fmt( result, ";  %SC", ast->InlineCmt->Content ); | ||||||
| 		else | 		else | ||||||
| 			append( result, ";\n"); | 			append( result, ";\n"); | ||||||
| 	} | 	} | ||||||
| @@ -1068,9 +1068,9 @@ void to_string(CodeTemplate self, String* result ) | |||||||
| 		append( result, "export " ); | 		append( result, "export " ); | ||||||
|  |  | ||||||
| 	if ( self->Params ) | 	if ( self->Params ) | ||||||
| 		append_fmt( result, "template< %S >\n%S", GEN_NS to_string(self->Params), GEN_NS to_string(self->Declaration) ); | 		append_fmt( result, "template< %S >\n%S", to_string(self->Params), to_string(self->Declaration) ); | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, "template<>\n%S", GEN_NS to_string(self->Declaration) ); | 		append_fmt( result, "template<>\n%S", to_string(self->Declaration) ); | ||||||
| } | } | ||||||
|  |  | ||||||
| String to_string(CodeTypedef self) | String to_string(CodeTypedef self) | ||||||
| @@ -1089,18 +1089,18 @@ void to_string(CodeTypedef self, String* result ) | |||||||
|  |  | ||||||
| 	// Determines if the typedef is a function typename | 	// Determines if the typedef is a function typename | ||||||
| 	if ( self->UnderlyingType->ReturnType ) | 	if ( self->UnderlyingType->ReturnType ) | ||||||
| 		append( result, GEN_NS to_string(self->UnderlyingType) ); | 		append( result, to_string(self->UnderlyingType) ); | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, "%S %S", GEN_NS to_string(self->UnderlyingType), self->Name ); | 		append_fmt( result, "%S %SC", to_string(self->UnderlyingType), self->Name ); | ||||||
|  |  | ||||||
| 	if ( self->UnderlyingType->Type == CT_Typename && self->UnderlyingType->ArrExpr ) | 	if ( self->UnderlyingType->Type == CT_Typename && self->UnderlyingType->ArrExpr ) | ||||||
| 	{ | 	{ | ||||||
| 		append_fmt( result, "[ %S ];", GEN_NS to_string(self->UnderlyingType->ArrExpr) ); | 		append_fmt( result, "[ %S ];", to_string(self->UnderlyingType->ArrExpr) ); | ||||||
|  |  | ||||||
| 		Code next_arr_expr = self->UnderlyingType->ArrExpr->Next; | 		Code next_arr_expr = self->UnderlyingType->ArrExpr->Next; | ||||||
| 		while ( next_arr_expr ) | 		while ( next_arr_expr ) | ||||||
| 		{ | 		{ | ||||||
| 			append_fmt( result, "[ %S ];", GEN_NS to_string(next_arr_expr) ); | 			append_fmt( result, "[ %S ];", to_string(next_arr_expr) ); | ||||||
| 			next_arr_expr = next_arr_expr->Next; | 			next_arr_expr = next_arr_expr->Next; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -1110,7 +1110,7 @@ void to_string(CodeTypedef self, String* result ) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( self->InlineCmt ) | 	if ( self->InlineCmt ) | ||||||
| 		append_fmt( result, "  %S", self->InlineCmt->Content); | 		append_fmt( result, "  %SC", self->InlineCmt->Content); | ||||||
| 	else | 	else | ||||||
| 		append( result, "\n"); | 		append( result, "\n"); | ||||||
| } | } | ||||||
| @@ -1128,13 +1128,13 @@ void to_string(CodeTypename self, String* result ) | |||||||
| 		if ( self->ReturnType && self->Params ) | 		if ( self->ReturnType && self->Params ) | ||||||
| 		{ | 		{ | ||||||
| 			if ( self->Attributes ) | 			if ( self->Attributes ) | ||||||
| 				append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) ); | 				append_fmt( result, "%S ", to_string(self->Attributes) ); | ||||||
| 			else | 			else | ||||||
| 			{ | 			{ | ||||||
| 				if ( self->Specs ) | 				if ( self->Specs ) | ||||||
| 					append_fmt( result, "%S ( %S ) ( %S ) %S", self->ReturnType.to_string(), self->Name, self->Params.to_string(), self->Specs.to_string() ); | 					append_fmt( result, "%S ( %SC ) ( %S ) %S", to_string(self->ReturnType), self->Name, to_string(self->Params), to_string(self->Specs) ); | ||||||
| 				else | 				else | ||||||
| 					append_fmt( result, "%S ( %S ) ( %S )", self->ReturnType.to_string(), self->Name, self->Params.to_string() ); | 					append_fmt( result, "%S ( %SC ) ( %S )", to_string(self->ReturnType), self->Name, to_string(self->Params) ); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			break; | 			break; | ||||||
| @@ -1143,13 +1143,13 @@ void to_string(CodeTypename self, String* result ) | |||||||
| 		if ( self->ReturnType && self->Params ) | 		if ( self->ReturnType && self->Params ) | ||||||
| 		{ | 		{ | ||||||
| 			if ( self->Attributes ) | 			if ( self->Attributes ) | ||||||
| 				append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) ); | 				append_fmt( result, "%S ", to_string(self->Attributes) ); | ||||||
| 			else | 			else | ||||||
| 			{ | 			{ | ||||||
| 				if ( self->Specs ) | 				if ( self->Specs ) | ||||||
| 					append_fmt( result, "%S %S ( %S ) %S", GEN_NS to_string(self->ReturnType), self->Name, GEN_NS to_string(self->Params), GEN_NS to_string(self->Specs) ); | 					append_fmt( result, "%S %SC ( %S ) %S", to_string(self->ReturnType), self->Name, to_string(self->Params), to_string(self->Specs) ); | ||||||
| 				else | 				else | ||||||
| 					append_fmt( result, "%S %S ( %S )", GEN_NS to_string(self->ReturnType), self->Name, GEN_NS to_string(self->Params) ); | 					append_fmt( result, "%S %SC ( %S )", to_string(self->ReturnType), self->Name, to_string(self->Params) ); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			return; | 			return; | ||||||
| @@ -1157,12 +1157,12 @@ void to_string(CodeTypename self, String* result ) | |||||||
| 	#endif | 	#endif | ||||||
|  |  | ||||||
| 	if ( self->Attributes ) | 	if ( self->Attributes ) | ||||||
| 		append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) ); | 		append_fmt( result, "%S ", to_string(self->Attributes) ); | ||||||
|  |  | ||||||
| 	if ( self->Specs ) | 	if ( self->Specs ) | ||||||
| 		append_fmt( result, "%S %S", self->Name, GEN_NS to_string(self->Specs) ); | 		append_fmt( result, "%SC %S", self->Name, to_string(self->Specs) ); | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, "%S", self->Name ); | 		append_fmt( result, "%SC", self->Name ); | ||||||
|  |  | ||||||
| 	if ( self->IsParamPack ) | 	if ( self->IsParamPack ) | ||||||
| 		append( result, "..."); | 		append( result, "..."); | ||||||
| @@ -1183,11 +1183,11 @@ void to_string(CodeUnion self, String* result ) | |||||||
| 	append( result, "union " ); | 	append( result, "union " ); | ||||||
|  |  | ||||||
| 	if ( self->Attributes ) | 	if ( self->Attributes ) | ||||||
| 		append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) ); | 		append_fmt( result, "%S ", to_string(self->Attributes) ); | ||||||
|  |  | ||||||
| 	if ( self->Name ) | 	if ( self->Name ) | ||||||
| 	{ | 	{ | ||||||
| 		append_fmt( result, "%S\n{\n%S\n}" | 		append_fmt( result, "%SC\n{\n%S\n}" | ||||||
| 			, self->Name | 			, self->Name | ||||||
| 			, GEN_NS to_string(self->Body) | 			, GEN_NS to_string(self->Body) | ||||||
| 		); | 		); | ||||||
| @@ -1225,20 +1225,20 @@ void to_string(CodeUsing self, String* result ) | |||||||
| 		append( result, "export " ); | 		append( result, "export " ); | ||||||
|  |  | ||||||
| 	if ( self->Attributes ) | 	if ( self->Attributes ) | ||||||
| 		append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) ); | 		append_fmt( result, "%S ", to_string(self->Attributes) ); | ||||||
|  |  | ||||||
| 	if ( self->UnderlyingType ) | 	if ( self->UnderlyingType ) | ||||||
| 	{ | 	{ | ||||||
| 		append_fmt( result, "using %S = %S", self->Name, GEN_NS to_string(self->UnderlyingType) ); | 		append_fmt( result, "using %SC = %S", self->Name, to_string(self->UnderlyingType) ); | ||||||
|  |  | ||||||
| 		if ( self->UnderlyingType->ArrExpr ) | 		if ( self->UnderlyingType->ArrExpr ) | ||||||
| 		{ | 		{ | ||||||
| 			append_fmt( result, "[ %S ]", GEN_NS to_string(self->UnderlyingType->ArrExpr) ); | 			append_fmt( result, "[ %S ]", to_string(self->UnderlyingType->ArrExpr) ); | ||||||
|  |  | ||||||
| 			Code next_arr_expr = self->UnderlyingType->ArrExpr->Next; | 			Code next_arr_expr = self->UnderlyingType->ArrExpr->Next; | ||||||
| 			while ( next_arr_expr ) | 			while ( next_arr_expr ) | ||||||
| 			{ | 			{ | ||||||
| 				append_fmt( result, "[ %S ]", GEN_NS to_string(next_arr_expr) ); | 				append_fmt( result, "[ %S ]", to_string(next_arr_expr) ); | ||||||
| 				next_arr_expr = next_arr_expr->Next; | 				next_arr_expr = next_arr_expr->Next; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| @@ -1246,10 +1246,10 @@ void to_string(CodeUsing self, String* result ) | |||||||
| 		append( result, ";" ); | 		append( result, ";" ); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, "using %S;", self->Name ); | 		append_fmt( result, "using %SC;", self->Name ); | ||||||
|  |  | ||||||
| 	if ( self->InlineCmt ) | 	if ( self->InlineCmt ) | ||||||
| 		append_fmt( result, "  %S\n", self->InlineCmt->Content ); | 		append_fmt( result, "  %SC\n", self->InlineCmt->Content ); | ||||||
| 	else | 	else | ||||||
| 		append( result, "\n"); | 		append( result, "\n"); | ||||||
| } | } | ||||||
| @@ -1257,9 +1257,9 @@ void to_string(CodeUsing self, String* result ) | |||||||
| void to_string_ns(CodeUsing self, String* result ) | void to_string_ns(CodeUsing self, String* result ) | ||||||
| { | { | ||||||
| 	if ( self->InlineCmt ) | 	if ( self->InlineCmt ) | ||||||
| 		append_fmt( result, "using namespace $S;  %S", self->Name, self->InlineCmt->Content ); | 		append_fmt( result, "using namespace $SC;  %SC", self->Name, self->InlineCmt->Content ); | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, "using namespace %s;\n", self->Name ); | 		append_fmt( result, "using namespace %SC;\n", self->Name ); | ||||||
| } | } | ||||||
|  |  | ||||||
| String to_string(CodeVar self) | String to_string(CodeVar self) | ||||||
| @@ -1276,18 +1276,18 @@ void to_string(CodeVar self, String* result ) | |||||||
| 		// Its a comma-separated variable ( a NextVar ) | 		// Its a comma-separated variable ( a NextVar ) | ||||||
|  |  | ||||||
| 		if ( self->Specs ) | 		if ( self->Specs ) | ||||||
| 			append_fmt( result, "%S ", GEN_NS to_string(self->Specs) ); | 			append_fmt( result, "%S ", to_string(self->Specs) ); | ||||||
|  |  | ||||||
| 		append( result, self->Name ); | 		append( result, self->Name ); | ||||||
|  |  | ||||||
| 		if ( self->ValueType->ArrExpr ) | 		if ( self->ValueType->ArrExpr ) | ||||||
| 		{ | 		{ | ||||||
| 			append_fmt( result, "[ %S ]", GEN_NS to_string(self->ValueType->ArrExpr) ); | 			append_fmt( result, "[ %S ]", to_string(self->ValueType->ArrExpr) ); | ||||||
|  |  | ||||||
| 			Code next_arr_expr = self->ValueType->ArrExpr->Next; | 			Code next_arr_expr = self->ValueType->ArrExpr->Next; | ||||||
| 			while ( next_arr_expr ) | 			while ( next_arr_expr ) | ||||||
| 			{ | 			{ | ||||||
| 				append_fmt( result, "[ %S ]", GEN_NS to_string(next_arr_expr) ); | 				append_fmt( result, "[ %S ]", to_string(next_arr_expr) ); | ||||||
| 				next_arr_expr = next_arr_expr->Next; | 				next_arr_expr = next_arr_expr->Next; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| @@ -1295,14 +1295,14 @@ void to_string(CodeVar self, String* result ) | |||||||
| 		if ( self->Value ) | 		if ( self->Value ) | ||||||
| 		{ | 		{ | ||||||
| 			if ( self->VarConstructorInit ) | 			if ( self->VarConstructorInit ) | ||||||
| 				append_fmt( result, "( %S ", GEN_NS to_string(self->Value) ); | 				append_fmt( result, "( %S ", to_string(self->Value) ); | ||||||
| 			else | 			else | ||||||
| 				append_fmt( result, " = %S", GEN_NS to_string(self->Value) ); | 				append_fmt( result, " = %S", to_string(self->Value) ); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Keep the chain going... | 		// Keep the chain going... | ||||||
| 		if ( self->NextVar ) | 		if ( self->NextVar ) | ||||||
| 			append_fmt( result, ", %S", self->NextVar.to_string() ); | 			append_fmt( result, ", %S", to_string(self->NextVar) ); | ||||||
|  |  | ||||||
| 		if ( self->VarConstructorInit ) | 		if ( self->VarConstructorInit ) | ||||||
| 			append( result, " )"); | 			append( result, " )"); | ||||||
| @@ -1316,44 +1316,44 @@ void to_string(CodeVar self, String* result ) | |||||||
| 	if ( self->Attributes || self->Specs ) | 	if ( self->Attributes || self->Specs ) | ||||||
| 	{ | 	{ | ||||||
| 		if ( self->Attributes ) | 		if ( self->Attributes ) | ||||||
| 			append_fmt( result, "%S ", GEN_NS to_string(self->Specs) ); | 			append_fmt( result, "%S ", to_string(self->Specs) ); | ||||||
|  |  | ||||||
| 		if ( self->Specs ) | 		if ( self->Specs ) | ||||||
| 			append_fmt( result, "%S\n", GEN_NS to_string(self->Specs) ); | 			append_fmt( result, "%S\n", to_string(self->Specs) ); | ||||||
|  |  | ||||||
| 		append_fmt( result, "%S %S", GEN_NS to_string(self->ValueType), self->Name ); | 		append_fmt( result, "%S %SC", to_string(self->ValueType), self->Name ); | ||||||
|  |  | ||||||
| 		if ( self->ValueType->ArrExpr ) | 		if ( self->ValueType->ArrExpr ) | ||||||
| 		{ | 		{ | ||||||
| 			append_fmt( result, "[ %S ]", GEN_NS to_string(self->ValueType->ArrExpr) ); | 			append_fmt( result, "[ %S ]", to_string(self->ValueType->ArrExpr) ); | ||||||
|  |  | ||||||
| 			Code next_arr_expr = self->ValueType->ArrExpr->Next; | 			Code next_arr_expr = self->ValueType->ArrExpr->Next; | ||||||
| 			while ( next_arr_expr ) | 			while ( next_arr_expr ) | ||||||
| 			{ | 			{ | ||||||
| 				append_fmt( result, "[ %S ]", GEN_NS to_string(next_arr_expr) ); | 				append_fmt( result, "[ %S ]", to_string(next_arr_expr) ); | ||||||
| 				next_arr_expr = next_arr_expr->Next; | 				next_arr_expr = next_arr_expr->Next; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if ( self->BitfieldSize ) | 		if ( self->BitfieldSize ) | ||||||
| 			append_fmt( result, " : %S", GEN_NS to_string(self->BitfieldSize) ); | 			append_fmt( result, " : %S", to_string(self->BitfieldSize) ); | ||||||
|  |  | ||||||
| 		if ( self->Value ) | 		if ( self->Value ) | ||||||
| 		{ | 		{ | ||||||
| 			if ( self->VarConstructorInit ) | 			if ( self->VarConstructorInit ) | ||||||
| 				append_fmt( result, "( %S ", GEN_NS to_string(self->Value) ); | 				append_fmt( result, "( %S ", to_string(self->Value) ); | ||||||
| 			else | 			else | ||||||
| 				append_fmt( result, " = %S", GEN_NS to_string(self->Value) ); | 				append_fmt( result, " = %S", to_string(self->Value) ); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if ( self->NextVar ) | 		if ( self->NextVar ) | ||||||
| 			append_fmt( result, ", %S", self->NextVar.to_string() ); | 			append_fmt( result, ", %S", to_string(self->NextVar) ); | ||||||
|  |  | ||||||
| 		if ( self->VarConstructorInit ) | 		if ( self->VarConstructorInit ) | ||||||
| 			append( result, " )"); | 			append( result, " )"); | ||||||
|  |  | ||||||
| 		if ( self->InlineCmt ) | 		if ( self->InlineCmt ) | ||||||
| 			append_fmt( result, ";  %S", self->InlineCmt->Content); | 			append_fmt( result, ";  %SC", self->InlineCmt->Content); | ||||||
| 		else | 		else | ||||||
| 			append( result, ";\n" ); | 			append( result, ";\n" ); | ||||||
|  |  | ||||||
| @@ -1361,33 +1361,33 @@ void to_string(CodeVar self, String* result ) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( self->BitfieldSize ) | 	if ( self->BitfieldSize ) | ||||||
| 		append_fmt( result, "%S %S : %S", GEN_NS to_string(self->ValueType), self->Name, GEN_NS to_string(self->BitfieldSize) ); | 		append_fmt( result, "%S %SC : %S", to_string(self->ValueType), self->Name, to_string(self->BitfieldSize) ); | ||||||
|  |  | ||||||
| 	else if ( self->ValueType->ArrExpr ) | 	else if ( self->ValueType->ArrExpr ) | ||||||
| 	{ | 	{ | ||||||
| 		append_fmt( result, "%S %S[ %S ]", GEN_NS to_string(self->ValueType), self->Name, GEN_NS to_string(self->ValueType->ArrExpr) ); | 		append_fmt( result, "%S %SC[ %S ]", to_string(self->ValueType), self->Name, to_string(self->ValueType->ArrExpr) ); | ||||||
|  |  | ||||||
| 		Code next_arr_expr = self->ValueType->ArrExpr->Next; | 		Code next_arr_expr = self->ValueType->ArrExpr->Next; | ||||||
| 		while ( next_arr_expr ) | 		while ( next_arr_expr ) | ||||||
| 		{ | 		{ | ||||||
| 			append_fmt( result, "[ %S ]", GEN_NS to_string(next_arr_expr) ); | 			append_fmt( result, "[ %S ]", to_string(next_arr_expr) ); | ||||||
| 			next_arr_expr = next_arr_expr->Next; | 			next_arr_expr = next_arr_expr->Next; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	else | 	else | ||||||
| 		append_fmt( result, "%S %S", GEN_NS to_string(self->ValueType), self->Name ); | 		append_fmt( result, "%S %SC", to_string(self->ValueType), self->Name ); | ||||||
|  |  | ||||||
| 	if ( self->Value ) | 	if ( self->Value ) | ||||||
| 	{ | 	{ | ||||||
| 		if ( self->VarConstructorInit ) | 		if ( self->VarConstructorInit ) | ||||||
| 			append_fmt( result, "( %S ", GEN_NS to_string(self->Value) ); | 			append_fmt( result, "( %S ", to_string(self->Value) ); | ||||||
| 		else | 		else | ||||||
| 			append_fmt( result, " = %S", GEN_NS to_string(self->Value) ); | 			append_fmt( result, " = %S", to_string(self->Value) ); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( self->NextVar ) | 	if ( self->NextVar ) | ||||||
| 		append_fmt( result, ", %S", self->NextVar.to_string() ); | 		append_fmt( result, ", %S", to_string( self->NextVar) ); | ||||||
|  |  | ||||||
| 	if ( self->VarConstructorInit ) | 	if ( self->VarConstructorInit ) | ||||||
| 		append( result, " )"); | 		append( result, " )"); | ||||||
| @@ -1395,7 +1395,7 @@ void to_string(CodeVar self, String* result ) | |||||||
| 	append( result, ";" ); | 	append( result, ";" ); | ||||||
|  |  | ||||||
| 	if ( self->InlineCmt ) | 	if ( self->InlineCmt ) | ||||||
| 		append_fmt( result, "  %S", self->InlineCmt->Content); | 		append_fmt( result, "  %SC", self->InlineCmt->Content); | ||||||
| 	else | 	else | ||||||
| 		append( result, "\n"); | 		append( result, "\n"); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -211,9 +211,9 @@ struct CodeSpecifiers | |||||||
| #if GEN_SUPPORT_CPP_MEMBER_FEATURES | #if GEN_SUPPORT_CPP_MEMBER_FEATURES | ||||||
| 	Using_Code( CodeSpecifiers ); | 	Using_Code( CodeSpecifiers ); | ||||||
|  |  | ||||||
| 	bool   append( SpecifierT spec )      { return GEN_NS append(* this, spec); } | 	bool   append( Specifier spec )       { return GEN_NS append(* this, spec); } | ||||||
| 	s32    has( SpecifierT spec )         { return GEN_NS has(* this, spec); } | 	s32    has( Specifier spec )          { return GEN_NS has(* this, spec); } | ||||||
| 	s32    remove( SpecifierT to_remove ) { return GEN_NS remove(* this, to_remove); } | 	s32    remove( Specifier to_remove )  { return GEN_NS remove(* this, to_remove); } | ||||||
| 	String to_string()                    { return GEN_NS to_string(* this ); } | 	String to_string()                    { return GEN_NS to_string(* this ); } | ||||||
| 	void   to_string( String& result )    { return GEN_NS to_string(* this, & result); } | 	void   to_string( String& result )    { return GEN_NS to_string(* this, & result); } | ||||||
| #endif | #endif | ||||||
| @@ -959,7 +959,7 @@ struct CodeTypedef | |||||||
|  |  | ||||||
| struct CodeUnion | struct CodeUnion | ||||||
| { | { | ||||||
| #if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1 | #if GEN_SUPPORT_CPP_MEMBER_FEATURES | ||||||
| 	Using_Code( CodeUnion ); | 	Using_Code( CodeUnion ); | ||||||
|  |  | ||||||
| 	String to_string()                 { return GEN_NS to_string(* this); } | 	String to_string()                 { return GEN_NS to_string(* this); } | ||||||
| @@ -974,7 +974,7 @@ struct CodeUnion | |||||||
|  |  | ||||||
| struct CodeUsing | struct CodeUsing | ||||||
| { | { | ||||||
| #if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1 | #if GEN_SUPPORT_CPP_MEMBER_FEATURES | ||||||
| 	Using_Code( CodeUsing ); | 	Using_Code( CodeUsing ); | ||||||
|  |  | ||||||
| 	String to_string()                    { return GEN_NS to_string(* this); } | 	String to_string()                    { return GEN_NS to_string(* this); } | ||||||
| @@ -990,7 +990,7 @@ struct CodeUsing | |||||||
|  |  | ||||||
| struct CodeVar | struct CodeVar | ||||||
| { | { | ||||||
| #if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1 | #if GEN_SUPPORT_CPP_MEMBER_FEATURES | ||||||
| 	Using_Code( CodeVar ); | 	Using_Code( CodeVar ); | ||||||
|  |  | ||||||
| 	String to_string()                 { return GEN_NS to_string(* this); } | 	String to_string()                 { return GEN_NS to_string(* this); } | ||||||
|   | |||||||
| @@ -5,8 +5,6 @@ | |||||||
|  |  | ||||||
| // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) | // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) | ||||||
|  |  | ||||||
| typedef enum CodeType_Def CodeType; |  | ||||||
|  |  | ||||||
| enum CodeType_Def : u32 | enum CodeType_Def : u32 | ||||||
| { | { | ||||||
| 	CT_Invalid, | 	CT_Invalid, | ||||||
| @@ -71,6 +69,7 @@ enum CodeType_Def : u32 | |||||||
| 	CT_Variable, | 	CT_Variable, | ||||||
| 	CT_NumTypes | 	CT_NumTypes | ||||||
| }; | }; | ||||||
|  | typedef enum CodeType_Def CodeType; | ||||||
|  |  | ||||||
| inline StrC to_str( CodeType type ) | inline StrC to_str( CodeType type ) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -5,8 +5,6 @@ | |||||||
|  |  | ||||||
| // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) | // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) | ||||||
|  |  | ||||||
| typedef enum Operator_Def Operator; |  | ||||||
|  |  | ||||||
| enum Operator_Def : u32 | enum Operator_Def : u32 | ||||||
| { | { | ||||||
| 	Op_Invalid, | 	Op_Invalid, | ||||||
| @@ -58,6 +56,7 @@ enum Operator_Def : u32 | |||||||
| 	Op_DeleteArray, | 	Op_DeleteArray, | ||||||
| 	NumOps | 	NumOps | ||||||
| }; | }; | ||||||
|  | typedef enum Operator_Def Operator; | ||||||
|  |  | ||||||
| inline StrC to_str( Operator op ) | inline StrC to_str( Operator op ) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -5,8 +5,6 @@ | |||||||
|  |  | ||||||
| // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) | // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) | ||||||
|  |  | ||||||
| typedef enum Specifier_Def Specifier; |  | ||||||
|  |  | ||||||
| enum Specifier_Def : u32 | enum Specifier_Def : u32 | ||||||
| { | { | ||||||
| 	Spec_Invalid, | 	Spec_Invalid, | ||||||
| @@ -37,6 +35,7 @@ enum Specifier_Def : u32 | |||||||
| 	Spec_Volatile, | 	Spec_Volatile, | ||||||
| 	Spec_NumSpecifiers | 	Spec_NumSpecifiers | ||||||
| }; | }; | ||||||
|  | typedef enum Specifier_Def Specifier; | ||||||
|  |  | ||||||
| inline bool is_trailing( Specifier specifier ) | inline bool is_trailing( Specifier specifier ) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -8,8 +8,6 @@ | |||||||
| GEN_NS_PARSER_BEGIN | GEN_NS_PARSER_BEGIN | ||||||
| #define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" ) | #define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" ) | ||||||
|  |  | ||||||
| typedef enum TokType_Def TokType; |  | ||||||
|  |  | ||||||
| enum TokType_Def : u32 | enum TokType_Def : u32 | ||||||
| { | { | ||||||
| 	Tok_Invalid, | 	Tok_Invalid, | ||||||
| @@ -111,6 +109,7 @@ enum TokType_Def : u32 | |||||||
| 	Tok_Attribute_API_Import, | 	Tok_Attribute_API_Import, | ||||||
| 	Tok_NumTokens | 	Tok_NumTokens | ||||||
| }; | }; | ||||||
|  | typedef enum TokType_Def TokType; | ||||||
|  |  | ||||||
| inline StrC to_str( TokType type ) | inline StrC to_str( TokType type ) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -134,7 +134,7 @@ Code begin( CodeBody body) { | |||||||
| } | } | ||||||
| inline | inline | ||||||
| Code end(CodeBody body ){ | Code end(CodeBody body ){ | ||||||
| 	return { rcast(AST*, body.ast)->Back->Next }; | 	return { nullptr }; | ||||||
| } | } | ||||||
| #pragma endregion CodeBody | #pragma endregion CodeBody | ||||||
|  |  | ||||||
|   | |||||||
| @@ -74,9 +74,9 @@ void* Global_Allocator_Proc( void* allocator_data, AllocType type, ssize size, s | |||||||
| internal | internal | ||||||
| void define_constants() | void define_constants() | ||||||
| { | { | ||||||
| 	Code_Global                         = make_code(); | 	Code_Global          = make_code(); | ||||||
| 	scast(String, Code_Global->Name)    = get_cached_string( txt("Global Code") ); | 	Code_Global->Name    = get_cached_string( txt("Global Code") ); | ||||||
| 	scast(String, Code_Global->Content) = Code_Global->Name; | 	Code_Global->Content = Code_Global->Name; | ||||||
|  |  | ||||||
| 	Code_Invalid = make_code(); | 	Code_Invalid = make_code(); | ||||||
| 	set_global(Code_Invalid); | 	set_global(Code_Invalid); | ||||||
| @@ -403,9 +403,9 @@ StringCached get_cached_string( StrC str ) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	String result = string_make( get_string_allocator( str.Len ), str ); | 	String result = string_make( get_string_allocator( str.Len ), str ); | ||||||
| 	set<StringCached>(& StringCache, key, result ); | 	set(& StringCache, key, { length(result), result } ); | ||||||
|  |  | ||||||
| 	return result; | 	return { length(result), result }; | ||||||
| } | } | ||||||
|  |  | ||||||
| // Used internally to retireve a Code object form the CodePool. | // Used internally to retireve a Code object form the CodePool. | ||||||
|   | |||||||
| @@ -11,13 +11,13 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va ) | |||||||
| 	local_persist | 	local_persist | ||||||
| 	Arena tok_map_arena; | 	Arena tok_map_arena; | ||||||
|  |  | ||||||
| 	HashTable<StrC> tok_map; | 	HashTable(StrC) tok_map; | ||||||
| 	{ | 	{ | ||||||
| 		local_persist | 		local_persist | ||||||
| 		char tok_map_mem[ TokenFmt_TokenMap_MemSize ]; | 		char tok_map_mem[ TokenFmt_TokenMap_MemSize ]; | ||||||
|  |  | ||||||
| 		tok_map_arena = arena_init_from_memory( tok_map_mem, sizeof(tok_map_mem) ); | 		tok_map_arena = arena_init_from_memory( tok_map_mem, sizeof(tok_map_mem) ); | ||||||
| 		tok_map       = hashtable_init<StrC>( allocator_info(& tok_map_arena) ); | 		tok_map       = hashtable_init(StrC, allocator_info(& tok_map_arena) ); | ||||||
|  |  | ||||||
| 		s32 left = num_tokens - 1; | 		s32 left = num_tokens - 1; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -485,7 +485,7 @@ CodeComment def_comment( StrC content ) | |||||||
| 	Code | 	Code | ||||||
| 	result          = make_code(); | 	result          = make_code(); | ||||||
| 	result->Type    = CT_Comment; | 	result->Type    = CT_Comment; | ||||||
| 	result->Name    = get_cached_string( cmt_formatted ); | 	result->Name    = get_cached_string( { length(cmt_formatted), cmt_formatted } ); | ||||||
| 	result->Content = result->Name; | 	result->Content = result->Name; | ||||||
|  |  | ||||||
| 	free(& cmt_formatted); | 	free(& cmt_formatted); | ||||||
|   | |||||||
| @@ -357,7 +357,7 @@ s32 lex_preprocessor_directive( LexContext* ctx ) | |||||||
| 				, current | 				, current | ||||||
| 				, preprocess_content.Line | 				, preprocess_content.Line | ||||||
| 				, preprocess_content.Column | 				, preprocess_content.Column | ||||||
| 				, directive_str.Data | 				, (char*) directive_str | ||||||
| 			); | 			); | ||||||
| 			return Lex_ReturnNull; | 			return Lex_ReturnNull; | ||||||
| 		} | 		} | ||||||
| @@ -578,11 +578,11 @@ TokArray lex( StrC content ) | |||||||
| 		return { {}, 0 }; | 		return { {}, 0 }; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	foreach( StringCached, entry, PreprocessorDefines ) | 	foreach( StringCached*, entry, PreprocessorDefines ) | ||||||
| 	{ | 	{ | ||||||
| 		s32         length  = 0; | 		s32         length  = 0; | ||||||
| 		char const* scanner = entry.Data; | 		char const* scanner = * entry; | ||||||
| 		while ( GEN_NS length(entry) > length && (char_is_alphanumeric( *scanner ) || *scanner == '_') ) | 		while ( entry->Len > length && (char_is_alphanumeric( *scanner ) || *scanner == '_') ) | ||||||
| 		{ | 		{ | ||||||
| 			c.scanner++; | 			c.scanner++; | ||||||
| 			length ++; | 			length ++; | ||||||
| @@ -592,8 +592,8 @@ TokArray lex( StrC content ) | |||||||
| 			length++; | 			length++; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		u64 key = crc32( entry.Data, length ); | 		u64 key = crc32( * entry, length ); | ||||||
| 		set(& c.defines, key, (StrC)entry ); | 		set(& c.defines, key, (StrC) * entry ); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	clear(Tokens); | 	clear(Tokens); | ||||||
|   | |||||||
| @@ -669,7 +669,7 @@ CodeAttributes parse_attributes() | |||||||
|  |  | ||||||
| 		Code result     = make_code(); | 		Code result     = make_code(); | ||||||
| 		result->Type    = CT_PlatformAttributes; | 		result->Type    = CT_PlatformAttributes; | ||||||
| 		result->Name    = get_cached_string( name_stripped ); | 		result->Name    = get_cached_string( { length(name_stripped), name_stripped } ); | ||||||
| 		result->Content = result->Name; | 		result->Content = result->Name; | ||||||
| 		// result->Token   = | 		// result->Token   = | ||||||
|  |  | ||||||
| @@ -905,11 +905,11 @@ CodeBody parse_class_struct_body( TokType which, Token name ) | |||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| 			case Tok_Operator: | 			case Tok_Operator: | ||||||
| 				if ( currtok.Text[0] != '~' ) | 				//if ( currtok.Text[0] != '~' ) | ||||||
| 				{ | 				//{ | ||||||
| 					log_failure( "Operator token found in global body but not destructor unary negation\n%s", to_string(Context) ); | 				//	log_failure( "Operator token found in global body but not destructor unary negation\n%s", to_string(Context) ); | ||||||
| 					return InvalidCode; | 				//	return InvalidCode; | ||||||
| 				} | 				//} | ||||||
|  |  | ||||||
| 				member = parse_destructor(); | 				member = parse_destructor(); | ||||||
| 				// ~<Name>() | 				// ~<Name>() | ||||||
| @@ -1047,10 +1047,10 @@ CodeBody parse_class_struct_body( TokType which, Token name ) | |||||||
|  |  | ||||||
| 					if ( attributes ) | 					if ( attributes ) | ||||||
| 					{ | 					{ | ||||||
| 						String fused = string_make_reserve( GlobalAllocator, length(attributes->Content) + length(more_attributes->Content) ); | 						String fused = string_make_reserve( GlobalAllocator, attributes->Content.Len + more_attributes->Content.Len ); | ||||||
| 						append_fmt( & fused, "%S %S", attributes->Content, more_attributes->Content ); | 						append_fmt( & fused, "%S %S", attributes->Content, more_attributes->Content ); | ||||||
|  |  | ||||||
| 						attributes->Name    = get_cached_string(fused); | 						attributes->Name    = get_cached_string({ length(fused), fused }); | ||||||
| 						attributes->Content = attributes->Name; | 						attributes->Content = attributes->Name; | ||||||
| 						// <Attributes> <Specifiers> <Attributes> | 						// <Attributes> <Specifiers> <Attributes> | ||||||
| 					} | 					} | ||||||
| @@ -1344,7 +1344,7 @@ CodeDefine parse_define() | |||||||
| 		return define; | 		return define; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	define->Content = get_cached_string( strip_formatting( to_str(currtok), strip_formatting_dont_preserve_newlines ) ); | 	define->Content = get_cached_string( to_strc( strip_formatting( to_str(currtok), strip_formatting_dont_preserve_newlines )) ); | ||||||
| 	eat( Tok_Preprocess_Content ); | 	eat( Tok_Preprocess_Content ); | ||||||
| 	// #define <Name> <Content> | 	// #define <Name> <Content> | ||||||
|  |  | ||||||
| @@ -1494,7 +1494,7 @@ CodeFn parse_function_after_name( | |||||||
|  |  | ||||||
| 	CodeFn | 	CodeFn | ||||||
| 	result              = (CodeFn) make_code(); | 	result              = (CodeFn) make_code(); | ||||||
| 	result->Name        = get_cached_string( name_stripped ); | 	result->Name        = get_cached_string( to_strc(name_stripped) ); | ||||||
| 	result->ModuleFlags = mflags; | 	result->ModuleFlags = mflags; | ||||||
|  |  | ||||||
| 	if ( body ) | 	if ( body ) | ||||||
| @@ -2730,7 +2730,7 @@ CodeParam parse_params( bool use_template_capture ) | |||||||
| 				eat( currtok.Type ); | 				eat( currtok.Type ); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			value = untyped_str( strip_formatting( to_str(value_tok), strip_formatting_dont_preserve_newlines ) ); | 			value = untyped_str( to_strc(strip_formatting( to_str(value_tok), strip_formatting_dont_preserve_newlines )) ); | ||||||
| 			// ( <Macro> <ValueType> <Name> = <Expression> | 			// ( <Macro> <ValueType> <Name> = <Expression> | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -2845,7 +2845,7 @@ CodeParam parse_params( bool use_template_capture ) | |||||||
| 					eat( currtok.Type ); | 					eat( currtok.Type ); | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				value = untyped_str( strip_formatting( to_str(value_tok), strip_formatting_dont_preserve_newlines ) ); | 				value = untyped_str( to_strc(strip_formatting( to_str(value_tok), strip_formatting_dont_preserve_newlines )) ); | ||||||
| 				// ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <Name> = <Expression> | 				// ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <Name> = <Expression> | ||||||
| 			} | 			} | ||||||
| 			// ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <Name> = <Expression>, .. | 			// ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <Name> = <Expression>, .. | ||||||
| @@ -3859,7 +3859,8 @@ CodeFriend parse_friend() | |||||||
| 	eat( Tok_Decl_Friend ); | 	eat( Tok_Decl_Friend ); | ||||||
| 	// friend | 	// friend | ||||||
|  |  | ||||||
| 	CodeFn function = { nullptr }; | 	CodeFn       function = { nullptr }; | ||||||
|  | 	CodeOperator op       = { nullptr }; | ||||||
|  |  | ||||||
| 	// Type declaration or return type | 	// Type declaration or return type | ||||||
| 	CodeTypename type = parse_type(); | 	CodeTypename type = parse_type(); | ||||||
| @@ -3893,6 +3894,12 @@ CodeFriend parse_friend() | |||||||
| 			// function->Params = params; | 			// function->Params = params; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	// Operator declaration or definition | ||||||
|  | 	if ( currtok.Type == Tok_Decl_Operator ) | ||||||
|  | 	{ | ||||||
|  | 		op = parse_operator_after_ret_type( ModuleFlag_None, NullCode, NullCode, type ); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	CodeComment inline_cmt = NullCode; | 	CodeComment inline_cmt = NullCode; | ||||||
| 	if ( function && function->Type == CT_Function_Fwd ) | 	if ( function && function->Type == CT_Function_Fwd ) | ||||||
| 	{ | 	{ | ||||||
| @@ -3912,6 +3919,8 @@ CodeFriend parse_friend() | |||||||
|  |  | ||||||
| 	if ( function ) | 	if ( function ) | ||||||
| 		result->Declaration = function; | 		result->Declaration = function; | ||||||
|  | 	else if ( op ) | ||||||
|  | 		result->Declaration = op; | ||||||
| 	else | 	else | ||||||
| 		result->Declaration = type; | 		result->Declaration = type; | ||||||
|  |  | ||||||
| @@ -4132,7 +4141,7 @@ CodeOpCast parse_operator_cast( CodeSpecifiers specifiers ) | |||||||
| 	Code type = parse_type(); | 	Code type = parse_type(); | ||||||
| 	// <Specifiers> <Qualifier> :: ... operator <UnderlyingType> | 	// <Specifiers> <Qualifier> :: ... operator <UnderlyingType> | ||||||
|  |  | ||||||
| 	Context.Scope->Name = { type->Name.Data, length(type->Name) }; | 	Context.Scope->Name = { type->Name.Ptr, type->Name.Len }; | ||||||
|  |  | ||||||
| 	eat( Tok_Capture_Start ); | 	eat( Tok_Capture_Start ); | ||||||
| 	eat( Tok_Capture_End ); | 	eat( Tok_Capture_End ); | ||||||
| @@ -4820,7 +4829,7 @@ else if ( currtok.Type == Tok_DeclType ) | |||||||
| 	} | 	} | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| 	result->Name = get_cached_string( name_stripped ); | 	result->Name = get_cached_string( to_strc(name_stripped) ); | ||||||
|  |  | ||||||
| 	if ( attributes ) | 	if ( attributes ) | ||||||
| 		result->Attributes = attributes; | 		result->Attributes = attributes; | ||||||
|   | |||||||
| @@ -152,7 +152,7 @@ bool append(Array<Type>* array, Type value) | |||||||
|  |  | ||||||
| 	if (header->Num == header->Capacity) | 	if (header->Num == header->Capacity) | ||||||
| 	{ | 	{ | ||||||
| 		if (!grow(array, header->Capacity)) | 		if ( ! grow(array, header->Capacity)) | ||||||
| 			return false; | 			return false; | ||||||
| 		header = get_header(* array); | 		header = get_header(* array); | ||||||
| 	} | 	} | ||||||
| @@ -170,12 +170,12 @@ bool append(Array<Type>* array, Type* items, usize item_num) | |||||||
|  |  | ||||||
| 	if (header->Num + item_num > header->Capacity) | 	if (header->Num + item_num > header->Capacity) | ||||||
| 	{ | 	{ | ||||||
| 		if (!grow(array, header->Capacity + item_num)) | 		if ( ! grow(array, header->Capacity + item_num)) | ||||||
| 			return false; | 			return false; | ||||||
| 		header = get_header(array); | 		header = get_header(array); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	mem_copy(array.Data + header->Num, items, item_num * sizeof(Type)); | 	mem_copy((Type*)array + header->Num, items, item_num * sizeof(Type)); | ||||||
| 	header->Num += item_num; | 	header->Num += item_num; | ||||||
|  |  | ||||||
| 	return true; | 	return true; | ||||||
| @@ -296,7 +296,7 @@ bool grow(Array<Type>* array, usize min_capacity) | |||||||
| 	usize        new_capacity = array_grow_formula(header->Capacity); | 	usize        new_capacity = array_grow_formula(header->Capacity); | ||||||
|  |  | ||||||
| 	if (new_capacity < min_capacity) | 	if (new_capacity < min_capacity) | ||||||
| 	new_capacity = min_capacity; | 		new_capacity = min_capacity; | ||||||
|  |  | ||||||
| 	return set_capacity(array, new_capacity); | 	return set_capacity(array, new_capacity); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -212,11 +212,7 @@ | |||||||
|  |  | ||||||
| // This is intended to only really be used internally or with the C-library variant | // This is intended to only really be used internally or with the C-library variant | ||||||
| // C++ users can just use the for-range directly. | // C++ users can just use the for-range directly. | ||||||
| #if GEN_COMPILER_C | #define foreach(Type, entry_id, iterable) for ( Type entry_id = begin(iterable); entry_id != end(iterable); entry_id = next(iterable, entry_id) ) | ||||||
| #	define foreach(Type, entry_id, iterable) for ( Type entry_id = begin(iterable); entry_id != end(iterable); entry_id = next(iterable, entry_id) ) |  | ||||||
| #else |  | ||||||
| #	define foreach(Type, entry_id, iterable) for ( Type entry_id : iterable ) |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #if GEN_COMPILER_C | #if GEN_COMPILER_C | ||||||
| #	if __STDC_VERSION__ >= 202311L | #	if __STDC_VERSION__ >= 202311L | ||||||
|   | |||||||
| @@ -43,8 +43,8 @@ struct _format_info | |||||||
|  |  | ||||||
| internal ssize _print_string( char* text, ssize max_len, _format_info* info, char const* str ) | internal ssize _print_string( char* text, ssize max_len, _format_info* info, char const* str ) | ||||||
| { | { | ||||||
| 	ssize    res = 0, len = 0; | 	ssize res = 0, len = 0; | ||||||
| 	ssize    remaining = max_len; | 	ssize remaining = max_len; | ||||||
| 	char* begin     = text; | 	char* begin     = text; | ||||||
|  |  | ||||||
| 	if ( str == NULL && max_len >= 6 ) | 	if ( str == NULL && max_len >= 6 ) | ||||||
| @@ -247,7 +247,7 @@ neverinline ssize str_fmt_va( char* text, ssize max_len, char const* fmt, va_lis | |||||||
| 	while ( *fmt ) | 	while ( *fmt ) | ||||||
| 	{ | 	{ | ||||||
| 		_format_info info = { 0 }; | 		_format_info info = { 0 }; | ||||||
| 		ssize           len  = 0; | 		ssize        len  = 0; | ||||||
| 		info.precision    = -1; | 		info.precision    = -1; | ||||||
|  |  | ||||||
| 		while ( *fmt && *fmt != '%' && remaining ) | 		while ( *fmt && *fmt != '%' && remaining ) | ||||||
| @@ -420,6 +420,15 @@ neverinline ssize str_fmt_va( char* text, ssize max_len, char const* fmt, va_lis | |||||||
|  |  | ||||||
| 			case 'S': | 			case 'S': | ||||||
| 			{ | 			{ | ||||||
|  | 				if ( *(fmt + 1) == 'C' ) | ||||||
|  | 				{ | ||||||
|  | 					++ fmt; | ||||||
|  | 					StrC gen_str   = va_arg( va, StrC); | ||||||
|  | 					info.precision = gen_str.Len; | ||||||
|  | 					len            = _print_string( text, remaining, &info, gen_str.Ptr ); | ||||||
|  | 					break; | ||||||
|  | 				} | ||||||
|  |  | ||||||
| 				String gen_str = String { va_arg( va, char*) }; | 				String gen_str = String { va_arg( va, char*) }; | ||||||
|  |  | ||||||
| 				info.precision = length(gen_str); | 				info.precision = length(gen_str); | ||||||
|   | |||||||
| @@ -5,6 +5,16 @@ | |||||||
|  |  | ||||||
| #pragma region Strings | #pragma region Strings | ||||||
|  |  | ||||||
|  | struct StrC; | ||||||
|  |  | ||||||
|  | bool        are_equal           (StrC lhs, StrC rhs); | ||||||
|  | char const* back                (StrC str); | ||||||
|  | bool        contains            (StrC str, StrC substring); | ||||||
|  | StrC        duplicate           (StrC str, AllocatorInfo allocator); | ||||||
|  | b32         starts_with         (StrC str, StrC substring); | ||||||
|  | StrC        to_str              (char const* bad_string); | ||||||
|  | StrC        visualize_whitespace(StrC str, AllocatorInfo allocator); | ||||||
|  |  | ||||||
| // Constant string with length. | // Constant string with length. | ||||||
| struct StrC | struct StrC | ||||||
| { | { | ||||||
| @@ -14,15 +24,71 @@ struct StrC | |||||||
| #if ! GEN_COMPILER_C | #if ! GEN_COMPILER_C | ||||||
| 	operator char const* ()               const { return Ptr; } | 	operator char const* ()               const { return Ptr; } | ||||||
| 	char const& operator[]( ssize index ) const { return Ptr[index]; } | 	char const& operator[]( ssize index ) const { return Ptr[index]; } | ||||||
|  |  | ||||||
|  | #if GEN_SUPPORT_CPP_MEMBER_FEATURES | ||||||
|  | 	bool        is_equal            (StrC rhs)                const { return GEN_NS are_equal(* this, rhs); } | ||||||
|  | 	char const* back                ()                        const { return GEN_NS back(* this); } | ||||||
|  | 	bool        contains            (StrC substring)          const { return GEN_NS contains(* this, substring); } | ||||||
|  | 	StrC        duplicate           (AllocatorInfo allocator) const { return GEN_NS duplicate(* this, allocator); } | ||||||
|  | 	b32         starts_with         (StrC substring)          const { return GEN_NS starts_with(* this, substring); } | ||||||
|  | 	StrC        visualize_whitespace(AllocatorInfo allocator) const { return GEN_NS visualize_whitespace(* this, allocator); } | ||||||
|  | #endif | ||||||
| #endif | #endif | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #define cast_to_strc( str ) * rcast( StrC*, (str) - sizeof(ssize) ) | #define cast_to_strc( str ) * rcast( StrC*, (str) - sizeof(ssize) ) | ||||||
| #define txt( text )         StrC { sizeof( text ) - 1, ( text ) } | #define txt( text )         StrC { sizeof( text ) - 1, ( text ) } | ||||||
|  |  | ||||||
|  | inline char const* begin(StrC str)                   { return str.Ptr; } | ||||||
|  | inline char const* end  (StrC str)                   { return str.Ptr + str.Len; } | ||||||
|  | inline char const* next (StrC str, char const* iter) { return iter + 1; } | ||||||
|  |  | ||||||
| inline | inline | ||||||
| StrC to_str( char const* str ) { | bool are_equal(StrC lhs, StrC rhs) | ||||||
| 	return { str_len( str ), str }; | { | ||||||
|  | 	if (lhs.Len != rhs.Len) | ||||||
|  | 		return false; | ||||||
|  |  | ||||||
|  | 	for (ssize idx = 0; idx < lhs.Len; ++idx) | ||||||
|  | 		if (lhs[idx] != rhs[idx]) | ||||||
|  | 			return false; | ||||||
|  |  | ||||||
|  | 	return true; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | inline | ||||||
|  | char const* back(StrC str) { | ||||||
|  | 	return & str.Ptr[str.Len - 1]; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | inline | ||||||
|  | bool contains(StrC str, StrC substring) | ||||||
|  | { | ||||||
|  | 	if (substring.Len > str.Len) | ||||||
|  | 		return false; | ||||||
|  |  | ||||||
|  | 	ssize main_len = str.Len; | ||||||
|  | 	ssize sub_len  = substring.Len; | ||||||
|  | 	for (ssize idx = 0; idx <= main_len - sub_len; ++idx) | ||||||
|  | 	{ | ||||||
|  | 		if (str_compare(str.Ptr + idx, substring.Ptr, sub_len) == 0) | ||||||
|  | 			return true; | ||||||
|  | 	} | ||||||
|  | 	return false; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | inline | ||||||
|  | b32 starts_with(StrC str, StrC substring) { | ||||||
|  | 	if (substring.Len > str.Len) | ||||||
|  | 		return false; | ||||||
|  |  | ||||||
|  | 	b32 result = str_compare(str.Ptr, substring.Ptr, substring.Len) == 0; | ||||||
|  | 		return result; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | inline | ||||||
|  | StrC to_str( char const* bad_str ) { | ||||||
|  | 	return { str_len( bad_str ), bad_str }; | ||||||
| } | } | ||||||
|  |  | ||||||
| // Dynamic String | // Dynamic String | ||||||
| @@ -31,7 +97,12 @@ StrC to_str( char const* str ) { | |||||||
| // I kept it for simplicty of porting but its not necessary to keep it that way. | // I kept it for simplicty of porting but its not necessary to keep it that way. | ||||||
| #pragma region String | #pragma region String | ||||||
| struct StringHeader; | struct StringHeader; | ||||||
|  |  | ||||||
|  | #if GEN_COMPILER_C || ! GEN_SUPPORT_CPP_MEMBER_FEATURES | ||||||
|  | typedef char* String; | ||||||
|  | #else | ||||||
| struct String; | struct String; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| usize string_grow_formula(usize value); | usize string_grow_formula(usize value); | ||||||
|  |  | ||||||
| @@ -65,6 +136,7 @@ b32           starts_with         (String const str, StrC   substring); | |||||||
| b32           starts_with         (String const str, String substring); | b32           starts_with         (String const str, String substring); | ||||||
| void          skip_line           (String       str); | void          skip_line           (String       str); | ||||||
| void          strip_space         (String       str); | void          strip_space         (String       str); | ||||||
|  | StrC          to_strc             (String       str); | ||||||
| void          trim                (String       str, char const* cut_set); | void          trim                (String       str, char const* cut_set); | ||||||
| void          trim_space          (String       str); | void          trim_space          (String       str); | ||||||
| String        visualize_whitespace(String const str); | String        visualize_whitespace(String const str); | ||||||
| @@ -75,15 +147,14 @@ struct StringHeader { | |||||||
| 	ssize         Length; | 	ssize         Length; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #if ! GEN_COMPILER_C | #if ! GEN_COMPILER_C && GEN_SUPPORT_CPP_MEMBER_FEATURES | ||||||
| struct String | struct String | ||||||
| { | { | ||||||
| 	char* Data; | 	char* Data; | ||||||
|  |  | ||||||
| 	forceinline operator bool()              { return Data != nullptr; } |  | ||||||
| 	forceinline operator char*()             { return Data; } | 	forceinline operator char*()             { return Data; } | ||||||
| 	forceinline operator char const*() const { return Data; } | 	forceinline operator char const*() const { return Data; } | ||||||
| 	forceinline operator StrC() const        { return { GEN_NS length(* this), Data }; } | 	forceinline operator StrC()        const { return { GEN_NS length(* this), Data }; } | ||||||
|  |  | ||||||
| 	String const& operator=(String const& other) const { | 	String const& operator=(String const& other) const { | ||||||
| 		if (this == &other) | 		if (this == &other) | ||||||
| @@ -95,13 +166,17 @@ struct String | |||||||
| 		return *this; | 		return *this; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	forceinline char& operator[](ssize index)             { return Data[index]; } | 	forceinline char&       operator[](ssize index)       { return Data[index]; } | ||||||
| 	forceinline char const& operator[](ssize index) const { return Data[index]; } | 	forceinline char const& operator[](ssize index) const { return Data[index]; } | ||||||
|  |  | ||||||
| 	forceinline char* begin() const { return Data; } | 	       bool operator==(std::nullptr_t) const             { return     Data == nullptr; } | ||||||
| 	forceinline char* end() const   { return Data + GEN_NS length(* this); } | 	       bool operator!=(std::nullptr_t) const             { return     Data != nullptr; } | ||||||
|  | 	friend bool operator==(std::nullptr_t, const String str) { return str.Data == nullptr; } | ||||||
|  | 	friend bool operator!=(std::nullptr_t, const String str) { return str.Data != nullptr; } | ||||||
|  |  | ||||||
|  | 	forceinline char* begin() const { return Data; } | ||||||
|  | 	forceinline char* end()   const { return Data + GEN_NS length(* this); } | ||||||
|  |  | ||||||
| #if GEN_SUPPORT_CPP_MEMBER_FEATURES |  | ||||||
| #pragma region Member Mapping | #pragma region Member Mapping | ||||||
| 	forceinline static String make(AllocatorInfo allocator, char const* str)                { return GEN_NS string_make(allocator, str); } | 	forceinline static String make(AllocatorInfo allocator, char const* str)                { return GEN_NS string_make(allocator, str); } | ||||||
| 	forceinline static String make(AllocatorInfo allocator, StrC str)                       { return GEN_NS string_make(allocator, str); } | 	forceinline static String make(AllocatorInfo allocator, StrC str)                       { return GEN_NS string_make(allocator, str); } | ||||||
| @@ -151,6 +226,7 @@ struct String | |||||||
| 	forceinline b32           starts_with(String substring) const            { return GEN_NS starts_with(* this, substring); } | 	forceinline b32           starts_with(String substring) const            { return GEN_NS starts_with(* this, substring); } | ||||||
| 	forceinline void          skip_line()                                    { GEN_NS skip_line(* this); } | 	forceinline void          skip_line()                                    { GEN_NS skip_line(* this); } | ||||||
| 	forceinline void          strip_space()                                  { GEN_NS strip_space(* this); } | 	forceinline void          strip_space()                                  { GEN_NS strip_space(* this); } | ||||||
|  | 	forceinline StrC          to_strc()                                      { return { length(), Data}; } | ||||||
| 	forceinline void          trim(char const* cut_set)                      { GEN_NS trim(* this, cut_set); } | 	forceinline void          trim(char const* cut_set)                      { GEN_NS trim(* this, cut_set); } | ||||||
| 	forceinline void          trim_space()                                   { GEN_NS trim_space(* this); } | 	forceinline void          trim_space()                                   { GEN_NS trim_space(* this); } | ||||||
| 	forceinline String        visualize_whitespace() const                   { return GEN_NS visualize_whitespace(* this); } | 	forceinline String        visualize_whitespace() const                   { return GEN_NS visualize_whitespace(* this); } | ||||||
| @@ -168,26 +244,25 @@ struct String | |||||||
| 		return GEN_NS append(this, buf, res); | 		return GEN_NS append(this, buf, res); | ||||||
| 	} | 	} | ||||||
| #pragma endregion Member Mapping | #pragma endregion Member Mapping | ||||||
| #endif |  | ||||||
| }; | }; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if GEN_SUPPORT_CPP_REFERENCES | inline char* begin(String str)             { return ((char*) str); } | ||||||
| bool          make_space_for(String& str, char const* to_append, ssize add_len); | inline char* end  (String str)             { return ((char*) str + length(str)); } | ||||||
| bool          append(String& str, char c); | inline char* next (String str, char* iter) { return ((char*) iter + 1); } | ||||||
| bool          append(String& str, char const* str_to_append); |  | ||||||
| bool          append(String& str, char const* str_to_append, ssize length); |  | ||||||
| bool          append(String& str, StrC str_to_append); |  | ||||||
| bool          append(String& str, const String other); |  | ||||||
| bool          append_fmt(String& str, char const* fmt, ...); |  | ||||||
| char&         back(String& str); |  | ||||||
| void          clear(String& str); |  | ||||||
| void          free(String& str); |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| inline char* begin(String str) { return str; } | #if GEN_SUPPORT_CPP_REFERENCES | ||||||
| inline char* end(String str)   { return scast(char*, str) + length(str); } | inline bool          make_space_for(String& str, char const* to_append, ssize add_len); | ||||||
| inline char* next(String str)  { return scast(char*, str) + 1; } | inline bool          append(String& str, char c); | ||||||
|  | inline bool          append(String& str, char const* str_to_append); | ||||||
|  | inline bool          append(String& str, char const* str_to_append, ssize length); | ||||||
|  | inline bool          append(String& str, StrC str_to_append); | ||||||
|  | inline bool          append(String& str, const String other); | ||||||
|  | inline bool          append_fmt(String& str, char const* fmt, ...); | ||||||
|  | inline char&         back(String& str); | ||||||
|  | inline void          clear(String& str); | ||||||
|  | inline void          free(String& str); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| inline | inline | ||||||
| usize string_grow_formula(usize value) { | usize string_grow_formula(usize value) { | ||||||
| @@ -249,7 +324,7 @@ String string_join(AllocatorInfo allocator, char const** parts, ssize num_parts, | |||||||
| inline | inline | ||||||
| bool append(String* str, char c) { | bool append(String* str, char c) { | ||||||
| 	GEN_ASSERT(str != nullptr); | 	GEN_ASSERT(str != nullptr); | ||||||
| 	return append(str, &c, 1); | 	return append( str, (char const*)& c, (ssize)1); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline | inline | ||||||
| @@ -288,9 +363,9 @@ bool append(String* str, StrC str_to_append) { | |||||||
| } | } | ||||||
|  |  | ||||||
| inline | inline | ||||||
| bool append(String* str, const String other) { | bool append(String* str, String const other) { | ||||||
| 	GEN_ASSERT(str != nullptr); | 	GEN_ASSERT(str != nullptr); | ||||||
| 	return append(str, other, length(other)); | 	return append(str, (char const*)other, length(other)); | ||||||
| } | } | ||||||
|  |  | ||||||
| bool append_fmt(String* str, char const* fmt, ...) { | bool append_fmt(String* str, char const* fmt, ...) { | ||||||
| @@ -303,7 +378,7 @@ bool append_fmt(String* str, char const* fmt, ...) { | |||||||
| 	res = str_fmt_va(buf, count_of(buf) - 1, fmt, va) - 1; | 	res = str_fmt_va(buf, count_of(buf) - 1, fmt, va) - 1; | ||||||
| 	va_end(va); | 	va_end(va); | ||||||
|  |  | ||||||
| 	return append(str, buf, res); | 	return append(str, (char const*)buf, res); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline | inline | ||||||
| @@ -464,7 +539,7 @@ b32 starts_with(String const str, StrC substring) { | |||||||
| 	if (substring.Len > length(str)) | 	if (substring.Len > length(str)) | ||||||
| 	return false; | 	return false; | ||||||
|  |  | ||||||
| 	b32 result = str_compare(str.Data, substring.Ptr, substring.Len) == 0; | 	b32 result = str_compare(str, substring.Ptr, substring.Len) == 0; | ||||||
| 	return result; | 	return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -473,7 +548,7 @@ b32 starts_with(String const str, String substring) { | |||||||
| 	if (length(substring) > length(str)) | 	if (length(substring) > length(str)) | ||||||
| 		return false; | 		return false; | ||||||
|  |  | ||||||
| 	b32 result = str_compare(str.Data, substring.Data, length(substring) - 1) == 0; | 	b32 result = str_compare(str, substring, length(substring) - 1) == 0; | ||||||
| 	return result; | 	return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -481,18 +556,18 @@ inline | |||||||
| void skip_line(String str) | void skip_line(String str) | ||||||
| { | { | ||||||
| #define current (*scanner) | #define current (*scanner) | ||||||
| 	char* scanner = str.Data; | 	char* scanner = str; | ||||||
| 	while (current != '\r' && current != '\n') { | 	while (current != '\r' && current != '\n') { | ||||||
|  		++scanner; |  		++scanner; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	s32 new_length = scanner - str.Data; | 	s32 new_length = scanner - str; | ||||||
|  |  | ||||||
| 	if (current == '\r') { | 	if (current == '\r') { | ||||||
| 		new_length += 1; | 		new_length += 1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	mem_move(str.Data, scanner, new_length); | 	mem_move((char*)str, scanner, new_length); | ||||||
|  |  | ||||||
| 	StringHeader* header = get_header(str); | 	StringHeader* header = get_header(str); | ||||||
| 	header->Length = new_length; | 	header->Length = new_length; | ||||||
| @@ -518,29 +593,34 @@ void strip_space(String str) | |||||||
|    write_pos[0] = '\0';  // Null-terminate the modified string |    write_pos[0] = '\0';  // Null-terminate the modified string | ||||||
|  |  | ||||||
|    // Update the length if needed |    // Update the length if needed | ||||||
|    get_header(str)->Length = write_pos - str.Data; |    get_header(str)->Length = write_pos - str; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | inline | ||||||
|  | StrC to_strc(String str) { | ||||||
|  | 	return { length(str), (char const*)str }; | ||||||
| } | } | ||||||
|  |  | ||||||
| inline | inline | ||||||
| void trim(String str, char const* cut_set) | void trim(String str, char const* cut_set) | ||||||
| { | { | ||||||
|    ssize len = 0; | 	ssize len = 0; | ||||||
|  |  | ||||||
|    char* start_pos = str.Data; | 	char* start_pos = str; | ||||||
|    char* end_pos = str.Data + length(str) - 1; | 	char* end_pos   = scast(char*, str) + length(str) - 1; | ||||||
|  |  | ||||||
|    while (start_pos <= end_pos && char_first_occurence(cut_set, *start_pos)) | 	while (start_pos <= end_pos && char_first_occurence(cut_set, *start_pos)) | ||||||
|    	start_pos++; | 	start_pos++; | ||||||
|  |  | ||||||
|    while (end_pos > start_pos && char_first_occurence(cut_set, *end_pos)) | 	while (end_pos > start_pos && char_first_occurence(cut_set, *end_pos)) | ||||||
|    	end_pos--; | 	end_pos--; | ||||||
|  |  | ||||||
|    len = scast(ssize, (start_pos > end_pos) ? 0 : ((end_pos - start_pos) + 1)); | 	len = scast(ssize, (start_pos > end_pos) ? 0 : ((end_pos - start_pos) + 1)); | ||||||
|  |  | ||||||
|    if (str.Data != start_pos) | 	if (str != start_pos) | ||||||
|    	mem_move(str.Data, start_pos, len); | 		mem_move(str, start_pos, len); | ||||||
|  |  | ||||||
|    str.Data[len] = '\0'; | 	str[len] = '\0'; | ||||||
|  |  | ||||||
|    get_header(str)->Length = len; |    get_header(str)->Length = len; | ||||||
| } | } | ||||||
| @@ -556,7 +636,7 @@ String visualize_whitespace(String const str) | |||||||
| 	StringHeader* header = (StringHeader*)(scast(char const*, str) - sizeof(StringHeader)); | 	StringHeader* header = (StringHeader*)(scast(char const*, str) - sizeof(StringHeader)); | ||||||
| 	String        result = string_make_reserve(header->Allocator, length(str) * 2); // Assume worst case for space requirements. | 	String        result = string_make_reserve(header->Allocator, length(str) * 2); // Assume worst case for space requirements. | ||||||
|  |  | ||||||
| 	for (auto c : str) switch (c) | 	foreach (char*, c, str) switch ( * c ) | ||||||
| 	{ | 	{ | ||||||
| 		case ' ': | 		case ' ': | ||||||
| 			append(& result, txt("·")); | 			append(& result, txt("·")); | ||||||
| @@ -590,11 +670,47 @@ struct String_POD { | |||||||
| }; | }; | ||||||
| static_assert( sizeof( String_POD ) == sizeof( String ), "String is not a POD" ); | static_assert( sizeof( String_POD ) == sizeof( String ), "String is not a POD" ); | ||||||
|  |  | ||||||
| // Implements basic string interning. Data structure is based off the ZPL Hashtable. | inline | ||||||
| typedef HashTable<String const>   StringTable; | StrC duplicate(StrC str, AllocatorInfo allocator) { | ||||||
|  | 	String result = string_make_length(allocator, str.Ptr, str.Len); | ||||||
|  | 	return {  get_header(result)->Length, result }; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | inline | ||||||
|  | StrC visualize_whitespace(StrC str, AllocatorInfo allocator) | ||||||
|  | { | ||||||
|  | 	String result = string_make_reserve(allocator, str.Len * 2); // Assume worst case for space requirements. | ||||||
|  | 	foreach (char const*, c, str) switch ( * c ) | ||||||
|  | 	{ | ||||||
|  | 		case ' ': | ||||||
|  | 			append(& result, txt("·")); | ||||||
|  | 		break; | ||||||
|  | 		case '\t': | ||||||
|  | 			append(& result, txt("→")); | ||||||
|  | 		break; | ||||||
|  | 		case '\n': | ||||||
|  | 			append(& result, txt("↵")); | ||||||
|  | 		break; | ||||||
|  | 		case '\r': | ||||||
|  | 			append(& result, txt("⏎")); | ||||||
|  | 		break; | ||||||
|  | 		case '\v': | ||||||
|  | 			append(& result, txt("⇕")); | ||||||
|  | 		break; | ||||||
|  | 		case '\f': | ||||||
|  | 			append(& result, txt("⌂")); | ||||||
|  | 		break; | ||||||
|  | 		default: | ||||||
|  | 			append(& result, c); | ||||||
|  | 		break; | ||||||
|  | 	} | ||||||
|  | 	return to_strc(result); | ||||||
|  | } | ||||||
|  |  | ||||||
| // Represents strings cached with the string table. | // Represents strings cached with the string table. | ||||||
| // Should never be modified, if changed string is desired, cache_string( str ) another. | // Should never be modified, if changed string is desired, cache_string( str ) another. | ||||||
| typedef String const   StringCached; | typedef StrC StringCached; | ||||||
|  |  | ||||||
|  | // Implements basic string interning. Data structure is based off the ZPL Hashtable. | ||||||
|  | typedef HashTable<StringCached> StringTable; | ||||||
| #pragma endregion Strings | #pragma endregion Strings | ||||||
|   | |||||||
| @@ -31,11 +31,11 @@ CodeBody gen_ecode( char const* path ) | |||||||
| 		append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", code, code ); | 		append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", code, code ); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	CodeEnum enum_code = parse_enum(gen::token_fmt_impl((3 + 1) / 2, "entries", (StrC)enum_entries, "enum CodeType_Def : u32 { <entries> CT_NumTypes };")); | 	CodeEnum enum_code = parse_enum(gen::token_fmt_impl((3 + 1) / 2, "entries", to_strc(enum_entries), "enum CodeType_Def : u32 { <entries> CT_NumTypes };")); | ||||||
|  |  | ||||||
| #pragma push_macro("local_persist") | #pragma push_macro("local_persist") | ||||||
| #undef local_persist | #undef local_persist | ||||||
| 	CodeFn to_str = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize( | 	CodeFn to_str = parse_function( token_fmt( "entries", to_strc(to_str_entries), stringize( | ||||||
| 		inline | 		inline | ||||||
| 		StrC to_str( CodeType type ) | 		StrC to_str( CodeType type ) | ||||||
| 		{ | 		{ | ||||||
| @@ -53,7 +53,7 @@ CodeBody gen_ecode( char const* path ) | |||||||
| 	//CodeUsing code_t = def_using( name(CodeT), def_type( name(ECode::Type) ) ); | 	//CodeUsing code_t = def_using( name(CodeT), def_type( name(ECode::Type) ) ); | ||||||
| 	CodeTypedef code_t = parse_typedef(code(typedef enum CodeType_Def CodeType; )); | 	CodeTypedef code_t = parse_typedef(code(typedef enum CodeType_Def CodeType; )); | ||||||
|  |  | ||||||
| 	return def_global_body( args( code_t, enum_code, to_str, fmt_newline ) ); | 	return def_global_body( args( enum_code, code_t, to_str, fmt_newline ) ); | ||||||
| } | } | ||||||
|  |  | ||||||
| CodeBody gen_eoperator( char const* path ) | CodeBody gen_eoperator( char const* path ) | ||||||
| @@ -81,7 +81,7 @@ CodeBody gen_eoperator( char const* path ) | |||||||
| 		append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str); | 		append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	CodeEnum  enum_code = parse_enum(token_fmt("entries", (StrC)enum_entries, stringize( | 	CodeEnum  enum_code = parse_enum(token_fmt("entries", to_strc(enum_entries), stringize( | ||||||
| 		enum Operator_Def : u32 | 		enum Operator_Def : u32 | ||||||
| 		{ | 		{ | ||||||
| 			<entries> | 			<entries> | ||||||
| @@ -91,7 +91,7 @@ CodeBody gen_eoperator( char const* path ) | |||||||
|  |  | ||||||
| #pragma push_macro("local_persist") | #pragma push_macro("local_persist") | ||||||
| #undef local_persist | #undef local_persist | ||||||
| 	CodeFn to_str = parse_function(token_fmt("entries", (StrC)to_str_entries, stringize( | 	CodeFn to_str = parse_function(token_fmt("entries", to_strc(to_str_entries), stringize( | ||||||
| 		inline | 		inline | ||||||
| 		StrC to_str( Operator op ) | 		StrC to_str( Operator op ) | ||||||
| 		{ | 		{ | ||||||
| @@ -109,7 +109,7 @@ CodeBody gen_eoperator( char const* path ) | |||||||
| 	//CodeUsing operator_t = def_using( name(OperatorT), def_type( name(EOperator::Type) ) ); | 	//CodeUsing operator_t = def_using( name(OperatorT), def_type( name(EOperator::Type) ) ); | ||||||
| 	CodeTypedef operator_t = parse_typedef(code( typedef enum Operator_Def Operator; )); | 	CodeTypedef operator_t = parse_typedef(code( typedef enum Operator_Def Operator; )); | ||||||
|  |  | ||||||
| 	return def_global_body( args( operator_t, enum_code, to_str, fmt_newline ) ); | 	return def_global_body( args( enum_code, operator_t, to_str, fmt_newline ) ); | ||||||
| } | } | ||||||
|  |  | ||||||
| CodeBody gen_especifier( char const* path ) | CodeBody gen_especifier( char const* path ) | ||||||
| @@ -137,7 +137,7 @@ CodeBody gen_especifier( char const* path ) | |||||||
| 		append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str); | 		append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	CodeEnum  enum_code = parse_enum(token_fmt("entries", (StrC)enum_entries, stringize( | 	CodeEnum  enum_code = parse_enum(token_fmt("entries", to_strc(enum_entries), stringize( | ||||||
| 		enum Specifier_Def : u32 | 		enum Specifier_Def : u32 | ||||||
| 		{ | 		{ | ||||||
| 			<entries> | 			<entries> | ||||||
| @@ -145,7 +145,7 @@ CodeBody gen_especifier( char const* path ) | |||||||
| 		}; | 		}; | ||||||
| 	))); | 	))); | ||||||
|  |  | ||||||
| 	CodeFn is_trailing = parse_function(token_fmt("specifier", (StrC)to_str_entries, stringize( | 	CodeFn is_trailing = parse_function(token_fmt("specifier", to_strc(to_str_entries), stringize( | ||||||
| 		inline | 		inline | ||||||
| 		bool is_trailing( Specifier specifier ) | 		bool is_trailing( Specifier specifier ) | ||||||
| 		{ | 		{ | ||||||
| @@ -163,7 +163,7 @@ CodeBody gen_especifier( char const* path ) | |||||||
| #undef do_once_end | #undef do_once_end | ||||||
| #undef forceinline | #undef forceinline | ||||||
| #undef neverinline | #undef neverinline | ||||||
| 	CodeFn to_str = parse_function(token_fmt("entries", (StrC)to_str_entries, stringize( | 	CodeFn to_str = parse_function(token_fmt("entries", to_strc(to_str_entries), stringize( | ||||||
| 		inline | 		inline | ||||||
| 		StrC to_str( Specifier type ) | 		StrC to_str( Specifier type ) | ||||||
| 		{ | 		{ | ||||||
| @@ -176,7 +176,7 @@ CodeBody gen_especifier( char const* path ) | |||||||
| 		} | 		} | ||||||
| 	))); | 	))); | ||||||
|  |  | ||||||
| 	CodeFn to_type = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize( | 	CodeFn to_type = parse_function( token_fmt( "entries", to_strc(to_str_entries), stringize( | ||||||
| 		inline | 		inline | ||||||
| 		Specifier to_specifier( StrC str ) | 		Specifier to_specifier( StrC str ) | ||||||
| 		{ | 		{ | ||||||
| @@ -214,7 +214,7 @@ CodeBody gen_especifier( char const* path ) | |||||||
| 	//CodeUsing specifier_t = def_using( name(SpecifierT), def_type( name(ESpecifier::Type) ) ); | 	//CodeUsing specifier_t = def_using( name(SpecifierT), def_type( name(ESpecifier::Type) ) ); | ||||||
| 	CodeTypedef specifier_t = parse_typedef( code(typedef enum Specifier_Def Specifier; )); | 	CodeTypedef specifier_t = parse_typedef( code(typedef enum Specifier_Def Specifier; )); | ||||||
|  |  | ||||||
| 	return def_global_body( args( specifier_t, enum_code, is_trailing, to_str, to_type, fmt_newline ) ); | 	return def_global_body( args( enum_code, specifier_t, is_trailing, to_str, to_type, fmt_newline ) ); | ||||||
| } | } | ||||||
|  |  | ||||||
| CodeBody gen_etoktype( char const* etok_path, char const* attr_path ) | CodeBody gen_etoktype( char const* etok_path, char const* attr_path ) | ||||||
| @@ -271,11 +271,11 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path ) | |||||||
|  |  | ||||||
| #pragma push_macro("GEN_DEFINE_ATTRIBUTE_TOKENS") | #pragma push_macro("GEN_DEFINE_ATTRIBUTE_TOKENS") | ||||||
| #undef GEN_DEFINE_ATTRIBUTE_TOKENS | #undef GEN_DEFINE_ATTRIBUTE_TOKENS | ||||||
| 	CodeDefine attribute_entires_def = def_define( name(GEN_DEFINE_ATTRIBUTE_TOKENS), attribute_define_entries  ); | 	CodeDefine attribute_entires_def = def_define( name(GEN_DEFINE_ATTRIBUTE_TOKENS), to_strc(attribute_define_entries)  ); | ||||||
| #pragma pop_macro("GEN_DEFINE_ATTRIBUTE_TOKENS") | #pragma pop_macro("GEN_DEFINE_ATTRIBUTE_TOKENS") | ||||||
|  |  | ||||||
| 	// We cannot parse this enum, it has Attribute names as enums | 	// We cannot parse this enum, it has Attribute names as enums | ||||||
| 	CodeEnum enum_code = parse_enum(token_fmt("entries", (StrC)enum_entries, "attribute_toks", (StrC)attribute_entries, stringize( | 	CodeEnum enum_code = parse_enum(token_fmt("entries", to_str(enum_entries), "attribute_toks", to_str(attribute_entries), stringize( | ||||||
| 		enum TokType_Def : u32 | 		enum TokType_Def : u32 | ||||||
| 		{ | 		{ | ||||||
| 			<entries> | 			<entries> | ||||||
| @@ -290,7 +290,7 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path ) | |||||||
| #undef local_persist | #undef local_persist | ||||||
| #undef do_once_start | #undef do_once_start | ||||||
| #undef do_once_end | #undef do_once_end | ||||||
| 	CodeFn to_str = parse_function(token_fmt("entries", (StrC)to_str_entries, "attribute_toks", (StrC)to_str_attributes, stringize( | 	CodeFn to_str = parse_function(token_fmt("entries", to_strc(to_str_entries), "attribute_toks", to_strc(to_str_attributes), stringize( | ||||||
| 		inline | 		inline | ||||||
| 		StrC to_str( TokType type ) | 		StrC to_str( TokType type ) | ||||||
| 		{ | 		{ | ||||||
| @@ -304,7 +304,7 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path ) | |||||||
| 		} | 		} | ||||||
| 	))); | 	))); | ||||||
|  |  | ||||||
| 	CodeFn to_type = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize( | 	CodeFn to_type = parse_function( token_fmt( "entries", to_strc(to_str_entries), stringize( | ||||||
| 		inline | 		inline | ||||||
| 		TokType to_toktype( StrC str ) | 		TokType to_toktype( StrC str ) | ||||||
| 		{ | 		{ | ||||||
| @@ -341,8 +341,8 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path ) | |||||||
|  |  | ||||||
| 	return def_global_body( args( | 	return def_global_body( args( | ||||||
| 		attribute_entires_def, | 		attribute_entires_def, | ||||||
| 		td_toktype, |  | ||||||
| 		enum_code, | 		enum_code, | ||||||
|  | 		td_toktype, | ||||||
| 		to_str, | 		to_str, | ||||||
| 		to_type | 		to_type | ||||||
| 	)); | 	)); | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ | |||||||
| #   pragma clang diagnostic ignored "-Wunknown-pragmas" | #   pragma clang diagnostic ignored "-Wunknown-pragmas" | ||||||
| #	pragma clang diagnostic ignored "-Wvarargs" | #	pragma clang diagnostic ignored "-Wvarargs" | ||||||
| #	pragma clang diagnostic ignored "-Wunused-function" | #	pragma clang diagnostic ignored "-Wunused-function" | ||||||
|  | #	pragma clang diagnostic ignored "-Wbraced-scalar-init" | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef __GNUC__ | #ifdef __GNUC__ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user