This commit is contained in:
Edward R. Gonzalez 2025-02-04 12:57:42 -05:00
parent b8695a33db
commit 6f2d81434e
2 changed files with 26 additions and 28 deletions

View File

@ -134,12 +134,12 @@ GEN_API StrBuilder preprocess_to_strbuilder (CodePreprocessCond cond);
StrBuilder template_to_strbuilder (CodeTemplate self); StrBuilder template_to_strbuilder (CodeTemplate self);
GEN_API void template_to_strbuilder_ref(CodeTemplate self, StrBuilder* result); GEN_API 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); StrBuilder typedef_to_strbuilder (CodeTypedef self);
GEN_API void typedef_to_strbuilder_ref(CodeTypedef self, StrBuilder* result ); 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 StrBuilder union_to_strbuilder (CodeUnion self);
GEN_API void union_to_strbuilder_def(CodeUnion self, StrBuilder* result); GEN_API void union_to_strbuilder_def(CodeUnion self, StrBuilder* result);
GEN_API void union_to_strbuilder_fwd(CodeUnion self, StrBuilder* result); GEN_API void union_to_strbuilder_fwd(CodeUnion self, StrBuilder* result);

View File

@ -52,7 +52,7 @@ void comment_to_strbuilder_ref(CodeComment comment, StrBuilder* result) {
inline inline
StrBuilder define_to_strbuilder(CodeDefine define) StrBuilder define_to_strbuilder(CodeDefine define)
{ {
GEN_ASSERT(define) GEN_ASSERT(define);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 );
define_to_strbuilder_ref(define, & result); define_to_strbuilder_ref(define, & result);
return result; return result;
@ -77,12 +77,10 @@ StrBuilder exec_to_strbuilder(CodeExec exec)
} }
inline inline
StrBuilder exec_to_strbuilder_ref(CodeExec exec, StrBuilder* result) { void exec_to_strbuilder_ref(CodeExec exec, StrBuilder* result) {
GEN_ASSERT(exec); GEN_ASSERT(exec);
GEN_ASSERT(result); GEN_ASSERT(result);
char* raw = ccast(char*, str_duplicate( exec->Content, get_context()->Allocator_Temp ).Ptr); strbuilder_append_str(result, exec->Content);
StrBuilder result = { raw };
return result;
} }
inline inline
@ -176,6 +174,23 @@ StrBuilder params_to_strbuilder(CodeParams self)
return result; return result;
} }
inline
StrBuilder pragma_to_strbuilder(CodePragma self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 256 );
pragma_to_strbuilder_ref( self, & result );
return result;
}
inline
void pragma_to_strbuilder_ref(CodePragma self, StrBuilder* result )
{
GEN_ASSERT(self);
GEN_ASSERT(result);
strbuilder_append_fmt( result, "#pragma %S\n", self->Content );
}
inline inline
void preprocess_to_strbuilder_if(CodePreprocessCond cond, StrBuilder* result ) 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") ); 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 inline
StrBuilder specifiers_to_strbuilder(CodeSpecifiers self) StrBuilder specifiers_to_strbuilder(CodeSpecifiers self)
{ {
GEN_ASSERT(self) GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 64 ); StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 64 );
specifiers_to_strbuilder_ref( self, & result ); specifiers_to_strbuilder_ref( self, & result );
return result; return result;
@ -262,7 +260,7 @@ StrBuilder template_to_strbuilder(CodeTemplate self)
inline inline
StrBuilder typedef_to_strbuilder(CodeTypedef self) StrBuilder typedef_to_strbuilder(CodeTypedef self)
{ {
GEN_ASSERT(self) GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 );
typedef_to_strbuilder_ref( self, & result ); typedef_to_strbuilder_ref( self, & result );
return result; return result;
@ -271,7 +269,7 @@ StrBuilder typedef_to_strbuilder(CodeTypedef self)
inline inline
StrBuilder typename_to_strbuilder(CodeTypename self) StrBuilder typename_to_strbuilder(CodeTypename self)
{ {
GEN_ASSERT(self) GEN_ASSERT(self);
StrBuilder result = strbuilder_make_str( _ctx->Allocator_Temp, txt("") ); StrBuilder result = strbuilder_make_str( _ctx->Allocator_Temp, txt("") );
typename_to_strbuilder_ref( self, & result ); typename_to_strbuilder_ref( self, & result );
return result; return result;