From 0d8f30b25c018b2052518f1ff186d2cbc737856f Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 3 Feb 2025 11:26:03 -0500 Subject: [PATCH] adjustments based on odin bindings drafting --- base/components/code_types.hpp | 5 ++++- base/components/inlines.hpp | 12 +++++++++++- base/components/interface.hpp | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/base/components/code_types.hpp b/base/components/code_types.hpp index 65c7254..10f3662 100644 --- a/base/components/code_types.hpp +++ b/base/components/code_types.hpp @@ -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 diff --git a/base/components/inlines.hpp b/base/components/inlines.hpp index f432f12..9014011 100644 --- a/base/components/inlines.hpp +++ b/base/components/inlines.hpp @@ -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++ ) { diff --git a/base/components/interface.hpp b/base/components/interface.hpp index bd5fbba..0fcfa8d 100644 --- a/base/components/interface.hpp +++ b/base/components/interface.hpp @@ -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, ... );