Compare commits

...

2 Commits

Author SHA1 Message Date
Ed_
0d8f30b25c adjustments based on odin bindings drafting 2025-02-03 11:26:03 -05:00
Ed_
d08efcb5ef Corrections while implementing odin bindings 2025-02-03 09:42:31 -05:00
5 changed files with 35 additions and 22 deletions

View File

@ -239,18 +239,18 @@ template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast(
#pragma region Code C-Interface
GEN_API void code_append (Code code, Code other );
void code_append (Code code, Code other );
GEN_API Str code_debug_str (Code code);
GEN_API Code code_duplicate (Code code);
GEN_API Code* code_entry (Code code, u32 idx );
GEN_API bool code_has_entries (Code code);
GEN_API bool code_is_body (Code code);
Code* code_entry (Code code, u32 idx );
bool code_has_entries (Code code);
bool code_is_body (Code code);
GEN_API bool code_is_equal (Code code, Code other);
GEN_API bool code_is_valid (Code code);
GEN_API void code_set_global (Code code);
bool code_is_valid (Code code);
void code_set_global (Code code);
GEN_API StrBuilder code_to_strbuilder (Code self );
GEN_API void code_to_strbuilder_ptr(Code self, StrBuilder* result );
GEN_API Str code_type_str (Code self );
Str code_type_str (Code self );
GEN_API bool code_validate_body (Code self );
#pragma endregion Code C-Interface
@ -399,7 +399,7 @@ struct AST
Code Value; // Parameter, Variable
};
union {
Code NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
Code NextVar; // Variable
Code SuffixSpecs; // Typename, Function (Thanks Unreal)
Code PostNameMacro; // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal)
};

View File

@ -227,7 +227,7 @@ struct AST_Enum
Code Parent;
CodeType Type;
ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
char _PAD_UNUSED_[ sizeof(u32) ];
};
static_assert( sizeof(AST_Enum) == sizeof(AST), "ERROR: AST_Enum is not the same size as AST");
@ -738,8 +738,8 @@ static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_Preprocess
struct AST_Specifiers
{
Specifier ArrSpecs[ AST_ArrSpecs_Cap ];
StrCached Name;
CodeSpecifiers NextSpecs;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
@ -1056,7 +1056,7 @@ struct AST_Typename
CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures
};
};
StrCached Name;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
@ -1082,7 +1082,7 @@ struct AST_Typedef
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
};
};
StrCached Name;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;

View File

@ -53,7 +53,8 @@ GEN_API CodeParams end_CodeParams (CodeParams params);
GEN_API CodeParams next_CodeParams (CodeParams params, CodeParams entry_iter);
GEN_API bool specifiers_append (CodeSpecifiers specifiers, Specifier spec);
GEN_API s32 specifiers_has (CodeSpecifiers specifiers, Specifier spec);
GEN_API bool specifiers_has (CodeSpecifiers specifiers, Specifier spec);
GEN_API s32 specifiers_index_of (CodeSpecifiers specifiers, Specifier spec);
GEN_API s32 specifiers_remove (CodeSpecifiers specifiers, Specifier to_remove );
GEN_API StrBuilder specifiers_to_strbuilder (CodeSpecifiers specifiers);
GEN_API void specifiers_to_strbuilder_ref(CodeSpecifiers specifiers, StrBuilder* result);
@ -150,6 +151,8 @@ GEN_API void using_to_strbuilder_ns (CodeUsing op_cast, StrBuilder* result
GEN_API StrBuilder var_to_strbuilder (CodeVar self);
GEN_API void var_to_strbuilder_ref(CodeVar self, StrBuilder* result);
// TODO(Ed): Move C-Interface inlines here...
#pragma endregion Code Type C-Interface
#if GEN_COMPILER_CPP

View File

@ -74,7 +74,7 @@ bool code_is_valid(Code self)
return self != nullptr && self->Type != CT_Invalid;
}
forceinline
bool code_has_entries(AST* self)
bool code_has_entries(Code self)
{
GEN_ASSERT(self);
return self->NumEntries > 0;
@ -169,12 +169,12 @@ void class_add_interface( CodeClass self, CodeTypename type )
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
}
while ( possible_slot != nullptr )
while ( possible_slot->Next != nullptr )
{
possible_slot = cast(CodeTypename, possible_slot->Next);
}
possible_slot = type;
possible_slot->Next = type;
}
#pragma endregion CodeClass
@ -296,7 +296,17 @@ bool specifiers_append(CodeSpecifiers self, Specifier spec )
return true;
}
inline
s32 specifiers_has(CodeSpecifiers self, Specifier spec)
bool specifiers_has(CodeSpecifiers self, Specifier spec)
{
GEN_ASSERT(self != nullptr);
for ( s32 idx = 0; idx < self->NumEntries; idx++ ) {
if ( self->ArrSpecs[ idx ] == spec )
return true;
}
return false;
}
inline
s32 specifiers_index_of(CodeSpecifiers self, Specifier spec)
{
GEN_ASSERT(self != nullptr);
for ( s32 idx = 0; idx < self->NumEntries; idx++ ) {
@ -378,12 +388,12 @@ void struct_add_interface(CodeStruct self, CodeTypename type )
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
}
while ( possible_slot != nullptr )
while ( possible_slot->Next != nullptr )
{
possible_slot = cast(CodeTypename, possible_slot->Next);
possible_slot->Next = cast(CodeTypename, possible_slot->Next);
}
possible_slot = type;
possible_slot->Next = type;
}
#pragma endregion Code

View File

@ -280,7 +280,7 @@ struct Opts_def_variable
GEN_API CodeVar def_variable( CodeTypename type, Str name, Opts_def_variable opts GEN_PARAM_DEFAULT );
// Constructs an empty body. Use AST::validate_body() to check if the body is was has valid entries.
GEN_API CodeBody def_body( CodeType type );
CodeBody def_body( CodeType type );
// There are two options for defining a struct body, either varadically provided with the args macro to auto-deduce the arg num,
/// or provide as an array of Code objects.
@ -388,7 +388,7 @@ GEN_API CodeVar parse_variable ( Str var_def );
GEN_API ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va );
//! Do not use directly. Use the token_fmt macro instead.
GEN_API Str token_fmt_impl( ssize, ... );
Str token_fmt_impl( ssize, ... );
GEN_API Code untyped_str( Str content);
GEN_API Code untyped_fmt ( char const* fmt, ... );