diff --git a/base/components/code_types.hpp b/base/components/code_types.hpp index c67cd43..e160aa3 100644 --- a/base/components/code_types.hpp +++ b/base/components/code_types.hpp @@ -134,12 +134,12 @@ GEN_API StrBuilder preprocess_to_strbuilder (CodePreprocessCond cond); StrBuilder template_to_strbuilder (CodeTemplate self); GEN_API void template_to_strbuilder_ref(CodeTemplate self, StrBuilder* result); - StrBuilder typename_to_strbuilder (CodeTypename self); -GEN_API void typename_to_strbuilder_ref(CodeTypename self, StrBuilder* result); - StrBuilder typedef_to_strbuilder (CodeTypedef self); GEN_API void typedef_to_strbuilder_ref(CodeTypedef self, StrBuilder* result ); + StrBuilder typename_to_strbuilder (CodeTypename self); +GEN_API void typename_to_strbuilder_ref(CodeTypename self, StrBuilder* result); + GEN_API StrBuilder union_to_strbuilder (CodeUnion self); GEN_API void union_to_strbuilder_def(CodeUnion self, StrBuilder* result); GEN_API void union_to_strbuilder_fwd(CodeUnion self, StrBuilder* result); diff --git a/base/components/inlines.hpp b/base/components/inlines.hpp index cfd4fb1..ba4036a 100644 --- a/base/components/inlines.hpp +++ b/base/components/inlines.hpp @@ -52,7 +52,7 @@ void comment_to_strbuilder_ref(CodeComment comment, StrBuilder* result) { inline StrBuilder define_to_strbuilder(CodeDefine define) { - GEN_ASSERT(define) + GEN_ASSERT(define); StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); define_to_strbuilder_ref(define, & result); return result; @@ -77,12 +77,10 @@ StrBuilder exec_to_strbuilder(CodeExec exec) } inline -StrBuilder exec_to_strbuilder_ref(CodeExec exec, StrBuilder* result) { +void exec_to_strbuilder_ref(CodeExec exec, StrBuilder* result) { GEN_ASSERT(exec); GEN_ASSERT(result); - char* raw = ccast(char*, str_duplicate( exec->Content, get_context()->Allocator_Temp ).Ptr); - StrBuilder result = { raw }; - return result; + strbuilder_append_str(result, exec->Content); } inline @@ -176,6 +174,23 @@ StrBuilder params_to_strbuilder(CodeParams self) return result; } +inline +StrBuilder pragma_to_strbuilder(CodePragma self) +{ + GEN_ASSERT(self); + StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 256 ); + pragma_to_strbuilder_ref( self, & result ); + return result; +} + +inline +void pragma_to_strbuilder_ref(CodePragma self, StrBuilder* result ) +{ + GEN_ASSERT(self); + GEN_ASSERT(result); + strbuilder_append_fmt( result, "#pragma %S\n", self->Content ); +} + inline void preprocess_to_strbuilder_if(CodePreprocessCond cond, StrBuilder* result ) { @@ -224,27 +239,10 @@ void preprocess_to_strbuilder_endif(CodePreprocessCond cond, StrBuilder* result strbuilder_append_str( result, txt("#endif\n") ); } -inline -StrBuilder pragma_to_strbuilder(CodePragma self) -{ - GEN_ASSERT(self); - StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 256 ); - pragma_to_strbuilder_ref( self, & result ); - return result; -} - -inline -void pragma_to_strbuilder_ref(CodePragma self, StrBuilder* result ) -{ - GEN_ASSERT(self) - GEN_ASSERT(result) - strbuilder_append_fmt( result, "#pragma %S\n", self->Content ); -} - inline StrBuilder specifiers_to_strbuilder(CodeSpecifiers self) { - GEN_ASSERT(self) + GEN_ASSERT(self); StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 64 ); specifiers_to_strbuilder_ref( self, & result ); return result; @@ -262,7 +260,7 @@ StrBuilder template_to_strbuilder(CodeTemplate self) inline StrBuilder typedef_to_strbuilder(CodeTypedef self) { - GEN_ASSERT(self) + GEN_ASSERT(self); StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); typedef_to_strbuilder_ref( self, & result ); return result; @@ -271,7 +269,7 @@ StrBuilder typedef_to_strbuilder(CodeTypedef self) inline StrBuilder typename_to_strbuilder(CodeTypename self) { - GEN_ASSERT(self) + GEN_ASSERT(self); StrBuilder result = strbuilder_make_str( _ctx->Allocator_Temp, txt("") ); typename_to_strbuilder_ref( self, & result ); return result;