mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
Completed initial conversion
This commit is contained in:
parent
ba1dd1894a
commit
d686831a7c
@ -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.Ptr );
|
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.ptr );
|
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.Ptr );
|
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");
|
||||||
}
|
}
|
||||||
@ -423,19 +423,19 @@ String to_string(CodeExec exec)
|
|||||||
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,7 +447,7 @@ 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 && (* result)[ length(* result) - 1 ] != ';' )
|
||||||
{
|
{
|
||||||
@ -455,7 +455,7 @@ void to_string(CodeFriend 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");
|
||||||
}
|
}
|
||||||
@ -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" );
|
||||||
}
|
}
|
||||||
@ -775,7 +775,7 @@ void to_string_def(CodeOpCast self, String* result )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( self->Name && self->Name.Len )
|
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 && self->Name.Len )
|
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");
|
||||||
}
|
}
|
||||||
|
@ -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); }
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user