mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-10-30 22:40:54 -07:00 
			
		
		
		
	Last fixes before handmade hero hiatus
This commit is contained in:
		| @@ -696,7 +696,19 @@ String AST::to_string() | |||||||
| 				result.append_fmt( " %S ", Attributes->to_string() ); | 				result.append_fmt( " %S ", Attributes->to_string() ); | ||||||
|  |  | ||||||
| 			if ( Specs ) | 			if ( Specs ) | ||||||
| 				result.append_fmt( "%S", Specs->to_string() ); | 			{ | ||||||
|  | 				for ( SpecifierT spec : Specs->cast<CodeSpecifiers>() ) | ||||||
|  | 				{ | ||||||
|  | 					if ( ! ESpecifier::is_trailing( spec ) ) | ||||||
|  | 					{ | ||||||
|  | 						StrC spec_str = ESpecifier::to_str( spec ); | ||||||
|  | 						result.append_fmt( " %.*s", spec_str.Len, spec_str.Ptr ); | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			if ( Attributes || Specs ) | ||||||
|  | 				result.append( "\n" ); | ||||||
|  |  | ||||||
| 			if ( ReturnType ) | 			if ( ReturnType ) | ||||||
| 				result.append_fmt( "%S %S(", ReturnType->to_string(), Name ); | 				result.append_fmt( "%S %S(", ReturnType->to_string(), Name ); | ||||||
| @@ -735,7 +747,21 @@ String AST::to_string() | |||||||
| 				result.append_fmt( "%S ", Attributes->to_string() ); | 				result.append_fmt( "%S ", Attributes->to_string() ); | ||||||
|  |  | ||||||
| 			if ( Specs ) | 			if ( Specs ) | ||||||
| 				result.append_fmt( "%S", Specs->to_string() ); | 			{ | ||||||
|  | 				for ( SpecifierT spec : Specs->cast<CodeSpecifiers>() ) | ||||||
|  | 				{ | ||||||
|  | 					if ( ! ESpecifier::is_trailing( spec ) ) | ||||||
|  | 					{ | ||||||
|  | 						StrC spec_str = ESpecifier::to_str( spec ); | ||||||
|  | 						result.append_fmt( " %.*s", spec_str.Len, spec_str.Ptr ); | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			if ( Attributes || Specs ) | ||||||
|  | 			{ | ||||||
|  | 				result.append("\n" ); | ||||||
|  | 			} | ||||||
|  |  | ||||||
| 			if ( ReturnType ) | 			if ( ReturnType ) | ||||||
| 				result.append_fmt( "%S %S(", ReturnType->to_string(), Name ); | 				result.append_fmt( "%S %S(", ReturnType->to_string(), Name ); | ||||||
| @@ -795,7 +821,24 @@ String AST::to_string() | |||||||
| 				result.append_fmt( "%S ", Attributes->to_string() ); | 				result.append_fmt( "%S ", Attributes->to_string() ); | ||||||
|  |  | ||||||
| 			if ( Attributes ) | 			if ( Attributes ) | ||||||
| 				result.append_fmt( "%S\n", Attributes->to_string() ); | 				result.append_fmt( "%S ", Attributes->to_string() ); | ||||||
|  |  | ||||||
|  | 			if ( Specs ) | ||||||
|  | 			{ | ||||||
|  | 				for ( SpecifierT spec : Specs->cast<CodeSpecifiers>() ) | ||||||
|  | 				{ | ||||||
|  | 					if ( ! ESpecifier::is_trailing( spec ) ) | ||||||
|  | 					{ | ||||||
|  | 						StrC spec_str = ESpecifier::to_str( spec ); | ||||||
|  | 						result.append_fmt( " %.*s", spec_str.Len, spec_str.Ptr ); | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			if ( Attributes || Specs ) | ||||||
|  | 			{ | ||||||
|  | 				result.append("\n" ); | ||||||
|  | 			} | ||||||
|  |  | ||||||
| 			if ( ReturnType ) | 			if ( ReturnType ) | ||||||
| 				result.append_fmt( "%S %S (", ReturnType->to_string(), Name ); | 				result.append_fmt( "%S %S (", ReturnType->to_string(), Name ); | ||||||
| @@ -834,7 +877,21 @@ String AST::to_string() | |||||||
| 				result.append_fmt( "%S\n", Attributes->to_string() ); | 				result.append_fmt( "%S\n", Attributes->to_string() ); | ||||||
|  |  | ||||||
| 			if ( Specs ) | 			if ( Specs ) | ||||||
| 				result.append_fmt( "%S\n", Specs->to_string() ); | 			{ | ||||||
|  | 				for ( SpecifierT spec : Specs->cast<CodeSpecifiers>() ) | ||||||
|  | 				{ | ||||||
|  | 					if ( ! ESpecifier::is_trailing( spec ) ) | ||||||
|  | 					{ | ||||||
|  | 						StrC spec_str = ESpecifier::to_str( spec ); | ||||||
|  | 						result.append_fmt( " %.*s", spec_str.Len, spec_str.Ptr ); | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			if ( Attributes || Specs ) | ||||||
|  | 			{ | ||||||
|  | 				result.append("\n" ); | ||||||
|  | 			} | ||||||
|  |  | ||||||
| 			result.append_fmt( "%S %S (", ReturnType->to_string(), Name ); | 			result.append_fmt( "%S %S (", ReturnType->to_string(), Name ); | ||||||
|  |  | ||||||
| @@ -991,12 +1048,6 @@ String AST::to_string() | |||||||
| 			s32 left = NumEntries; | 			s32 left = NumEntries; | ||||||
| 			while ( left-- ) | 			while ( left-- ) | ||||||
| 			{ | 			{ | ||||||
| 				if ( ESpecifier::is_trailing( ArrSpecs[idx]) && ArrSpecs[idx] != ESpecifier::Const ) |  | ||||||
| 				{ |  | ||||||
| 					idx++; |  | ||||||
| 					continue; |  | ||||||
| 				} |  | ||||||
|  |  | ||||||
| 				StrC spec = ESpecifier::to_str( ArrSpecs[idx] ); | 				StrC spec = ESpecifier::to_str( ArrSpecs[idx] ); | ||||||
| 				result.append_fmt( "%.*s ", spec.Len, spec.Ptr ); | 				result.append_fmt( "%.*s ", spec.Len, spec.Ptr ); | ||||||
| 				idx++; | 				idx++; | ||||||
|   | |||||||
| @@ -257,7 +257,7 @@ struct AST | |||||||
| 			}; | 			}; | ||||||
| 			union { | 			union { | ||||||
| 				AST*  NextVar;          // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value ) | 				AST*  NextVar;          // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value ) | ||||||
| 				AST*  SpecsFuncSuffix;  // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed ) | 				AST*  SuffixSpecs;      // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed ) | ||||||
| 			}; | 			}; | ||||||
| 		}; | 		}; | ||||||
| 		StringCached  Content;          // Attributes, Comment, Execution, Include | 		StringCached  Content;          // Attributes, Comment, Execution, Include | ||||||
| @@ -316,7 +316,7 @@ struct AST_POD | |||||||
| 			}; | 			}; | ||||||
| 			union { | 			union { | ||||||
| 				AST*  NextVar;          // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value ) | 				AST*  NextVar;          // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value ) | ||||||
| 				AST*  SpecsFuncSuffix;  // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed ) | 				AST*  SuffixSpecs;      // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed ) | ||||||
| 			}; | 			}; | ||||||
| 		}; | 		}; | ||||||
| 		StringCached  Content;          // Attributes, Comment, Execution, Include | 		StringCached  Content;          // Attributes, Comment, Execution, Include | ||||||
|   | |||||||
| @@ -2296,6 +2296,7 @@ CodeFn parse_function_after_name( | |||||||
|  |  | ||||||
| 	CodeParam params = parse_params(); | 	CodeParam params = parse_params(); | ||||||
|  |  | ||||||
|  | 	// These have to be kept separate from the return type's specifiers. | ||||||
| 	while ( left && currtok.is_specifier() ) | 	while ( left && currtok.is_specifier() ) | ||||||
| 	{ | 	{ | ||||||
| 		if ( specifiers.ast == nullptr ) | 		if ( specifiers.ast == nullptr ) | ||||||
| @@ -4784,7 +4785,7 @@ CodeType parse_type( bool* typedef_is_function ) | |||||||
| #if 0 | #if 0 | ||||||
| 	else if ( currtok.Type == TokType::DeclType ) | 	else if ( currtok.Type == TokType::DeclType ) | ||||||
| 	{ | 	{ | ||||||
| 		// Will have a capture and its own parsing rules, were going to just shove everything in a string. | 		// Will have a capture and its own parsing rules, were going to just shove everything in a string (for now). | ||||||
| 		name = currtok; | 		name = currtok; | ||||||
| 		eat( TokType::DeclType ); | 		eat( TokType::DeclType ); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user