27 Commits

Author SHA1 Message Date
Ed_
2ad164dc39 CodeSpecifiers fixes 2025-04-02 21:19:15 -04:00
Ed_
878bc4c8ae Merge pull request #72 from Ed94/dev
Changes involved with getting gencpp-odin setup
2025-02-04 22:43:18 -05:00
Ed_
ec8dd1e9cd missing delete specifier (gen_unreal_engine) 2025-02-04 22:37:28 -05:00
Ed_
c0ea2ce3ff fix for edge case (running out of tokens while parsing assignment expression 2025-02-04 22:05:24 -05:00
Ed_
b5652a4dad if on c11 segmented (parsing spec defines were mising!) 2025-02-04 21:42:01 -05:00
Ed_
dda70fce36 can't use static globals on static libs 2025-02-04 21:23:51 -05:00
Ed_
3bce2e9b8a rename GEN_INTELLISENSE_DIRECTIVES -> INTELLISENSE_DIRECTIVES 2025-02-04 18:33:07 -05:00
Ed_
f3f8f2fff2 update readme with related repos 2025-02-04 17:24:03 -05:00
Ed_
c600a3e0dc add missing defines 2025-02-04 17:04:33 -05:00
Ed_
372cda734e fixes for generated c11 segemented 2025-02-04 16:17:29 -05:00
Ed_
6481313969 Various fixes and adjustments
* moved constants to components/constants.hpp (adjsuted generators accordingly)
* parser accepts include & defineas parameter identifiers (will add more flags for keywords when necessary
2025-02-04 15:35:28 -05:00
Ed_
5c17983a73 move more strbuilder functions to cpp 2025-02-04 14:53:26 -05:00
Ed_
b6d95e8d70 move strbuilder_make_space_for to strings.cpp (not inlined) 2025-02-04 14:17:15 -05:00
Ed_
6f2d81434e fixes 2025-02-04 12:57:42 -05:00
Ed_
b8695a33db added missing asserts to serialization functions 2025-02-04 11:50:15 -05:00
Ed_
1f958e121c more adjustments based on odin binding drafting 2025-02-04 01:57:23 -05:00
Ed_
e457191f5d moved seiralization inlines to inlines.hpp, more adjustments 2025-02-03 18:53:35 -05:00
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
Ed_
13ebd105c4 Fix for convert_cpp_enum_to_c for gen_c_library
It wasn't generating correct typedefs for when underlying type was used over the enum name.
2025-01-30 14:14:53 -05:00
Ed_
bdd9c9bcdf Fixes for building all library types 2025-01-30 13:57:42 -05:00
Ed_
16bc66c80e Backporting changes done on UnrealGencpp repo
Commits:
ec77e8b - Fixes while parsing EditorEngine.h
5017429 - parse_complicated_definition fix when parsing Controller.h
aac0dd5 - Add  IRISCORE_API
049b59c - Support for attributes retated to an operator or function between the return type and the identifier/op (Thanks World.h...)
97d7e6d - Fix for attributes after name in using statements
9f204e7 - Support for final specifier on class & struct definitions
f0698cc - Added support for Spec_Delete (= delete on functions and operators) [Part 3]
1f6650a - Added support for Spec_Delete (= delete on functions and operators) [Part 2]
06ac8da - Added support for Spec_Delete (= delete on functions and operators)
2025-01-30 13:25:56 -05:00
Ed_
f8c42a53c6 Fix for parse_function_after_name suffix specifier macro 2025-01-29 02:35:55 -05:00
Ed_
eca538c6af Fixes for GEN_API symbol exports necessary for dynamic linking 2025-01-29 02:04:50 -05:00
Ed_
ce2be411d7 Add support for non Specifier enum SuffixSpecs in AST_Fn and parsing (Thanks Unreal) 2025-01-29 01:29:55 -05:00
Ed_
16fc3fa379 Separate ifndef for bitfield_is_set 2025-01-28 21:09:35 -05:00
Ed_
62b36ec8bb misc changes to clang format spacing 2025-01-28 14:49:19 -05:00
74 changed files with 1748 additions and 1443 deletions

View File

@ -11,6 +11,14 @@ These build up a code AST to then serialize with a file builder, or can be trave
This code base attempts follow the [handmade philosophy](https://handmade.network/manifesto). This code base attempts follow the [handmade philosophy](https://handmade.network/manifesto).
Its not meant to be a black box metaprogramming utility, it should be easy to integrate into a user's project domain. Its not meant to be a black box metaprogramming utility, it should be easy to integrate into a user's project domain.
## Langauge Bindings
* [gencpp-odin](https://github.com/Ed94/gencpp-odin): Bindings for the odin programming language.
## Utility Libraries
* [UnrealGencpp](https://github.com/Ed94/UnrealGencpp): Setup as a plugin to integrate into Unreal Engine or Unreal Projects.
## Documentation ## Documentation
* [docs - General](./docs/Readme.md): Overview and additional docs * [docs - General](./docs/Readme.md): Overview and additional docs

View File

@ -191,7 +191,7 @@ These require the following to be handled to the equivalent extent as the other
4. [ast.cpp](./components/ast.cpp): Need to review 4. [ast.cpp](./components/ast.cpp): Need to review
* `code_debug_str` * `code_debug_str`
* `code_is_equal` * `code_is_equal`
* `code_to_strbuilder_ptr` * `code_to_strbuilder_ref`
* `code_validate_body` * `code_validate_body`
5. [code_serialization.cpp](./components/code_serialization.cpp): Define serialization here. 5. [code_serialization.cpp](./components/code_serialization.cpp): Define serialization here.
6. [inlines.hpp](./components/inlines.hpp): Any inline definitions for the `struct Code<Name>` are defined here. 6. [inlines.hpp](./components/inlines.hpp): Any inline definitions for the `struct Code<Name>` are defined here.

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# include "builder.hpp" # include "builder.hpp"
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "helpers/push_ignores.inline.hpp" # include "helpers/push_ignores.inline.hpp"
# include "components/header_start.hpp" # include "components/header_start.hpp"
@ -21,11 +21,11 @@ using namespace gen;
struct Builder; struct Builder;
typedef struct Builder Builder; typedef struct Builder Builder;
Builder builder_open ( char const* path ); GEN_API Builder builder_open ( char const* path );
void builder_pad_lines ( Builder* builder, s32 num ); GEN_API void builder_pad_lines ( Builder* builder, s32 num );
void builder_print ( Builder* builder, Code code ); GEN_API void builder_print ( Builder* builder, Code code );
void builder_print_fmt_va( Builder* builder, char const* fmt, va_list va ); GEN_API void builder_print_fmt_va( Builder* builder, char const* fmt, va_list va );
void builder_write ( Builder* builder ); GEN_API void builder_write ( Builder* builder );
forceinline void builder_print_fmt ( Builder* builder, char const* fmt, ... ) { forceinline void builder_print_fmt ( Builder* builder, char const* fmt, ... ) {
va_list va; va_list va;

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "helpers/push_ignores.inline.hpp" # include "helpers/push_ignores.inline.hpp"
# include "components/header_start.hpp" # include "components/header_start.hpp"

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# include "scanner.hpp" # include "scanner.hpp"
#endif #endif
@ -24,7 +24,7 @@ Code scan_file( char const* path )
file_read( & file, str, fsize ); file_read( & file, str, fsize );
strbuilder_get_header(str)->Length = fsize; strbuilder_get_header(str)->Length = fsize;
// Skip GEN_INTELLISENSE_DIRECTIVES preprocessor blocks // Skip INTELLISENSE_DIRECTIVES preprocessor blocks
// Its designed so that the directive should be the first thing in the file. // Its designed so that the directive should be the first thing in the file.
// Anything that comes before it will also be omitted. // Anything that comes before it will also be omitted.
{ {
@ -33,7 +33,7 @@ Code scan_file( char const* path )
#define move_fwd() do { ++ scanner; -- left; } while (0) #define move_fwd() do { ++ scanner; -- left; } while (0)
const Str directive_start = txt( "ifdef" ); const Str directive_start = txt( "ifdef" );
const Str directive_end = txt( "endif" ); const Str directive_end = txt( "endif" );
const Str def_intellisense = txt("GEN_INTELLISENSE_DIRECTIVES" ); const Str def_intellisense = txt("INTELLISENSE_DIRECTIVES" );
bool found_directive = false; bool found_directive = false;
char const* scanner = (char const*)str; char const* scanner = (char const*)str;

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "helpers/push_ignores.inline.hpp" # include "helpers/push_ignores.inline.hpp"
# include "components/header_start.hpp" # include "components/header_start.hpp"
@ -20,9 +20,9 @@
// This is a simple file reader that reads the entire file into memory. // This is a simple file reader that reads the entire file into memory.
// It has an extra option to skip the first few lines for undesired includes. // It has an extra option to skip the first few lines for undesired includes.
// This is done so that includes can be kept in dependency and component files so that intellisense works. // This is done so that includes can be kept in dependency and component files so that intellisense works.
Code scan_file( char const* path ); GEN_API Code scan_file( char const* path );
CodeBody parse_file( const char* path ); GEN_API CodeBody parse_file( const char* path );
// The follow is basic support for light csv parsing (use it as an example) // The follow is basic support for light csv parsing (use it as an example)
// Make something robust if its more serious. // Make something robust if its more serious.
@ -40,7 +40,7 @@ struct CSV_Columns2 {
Array(ADT_Node) Col_2; Array(ADT_Node) Col_2;
}; };
CSV_Column parse_csv_one_column(AllocatorInfo allocator, char const* path); GEN_API CSV_Column parse_csv_one_column (AllocatorInfo allocator, char const* path);
CSV_Columns2 parse_csv_two_columns(AllocatorInfo allocator, char const* path); GEN_API CSV_Columns2 parse_csv_two_columns(AllocatorInfo allocator, char const* path);
#pragma endregion Scanner #pragma endregion Scanner

View File

@ -30,7 +30,7 @@ int gen_main()
gen::init( & ctx); gen::init( & ctx);
CodeBody gen_component_header = def_global_body( args( CodeBody gen_component_header = def_global_body( args(
def_preprocess_cond( PreprocessCond_IfDef, txt("GEN_INTELLISENSE_DIRECTIVES") ), def_preprocess_cond( PreprocessCond_IfDef, txt("INTELLISENSE_DIRECTIVES") ),
pragma_once, pragma_once,
def_include(txt("components/types.hpp")), def_include(txt("components/types.hpp")),
preprocess_endif, preprocess_endif,

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "static_data.cpp" #include "static_data.cpp"
#endif #endif
@ -379,11 +379,11 @@ Code code_duplicate(Code self)
StrBuilder code_to_strbuilder(Code self) StrBuilder code_to_strbuilder(Code self)
{ {
StrBuilder result = strbuilder_make_str( _ctx->Allocator_Temp, txt("") ); StrBuilder result = strbuilder_make_str( _ctx->Allocator_Temp, txt("") );
code_to_strbuilder_ptr( self, & result ); code_to_strbuilder_ref( self, & result );
return result; return result;
} }
void code_to_strbuilder_ptr( Code self, StrBuilder* result ) void code_to_strbuilder_ref( Code self, StrBuilder* result )
{ {
GEN_ASSERT(self != nullptr); GEN_ASSERT(self != nullptr);
local_persist thread_local local_persist thread_local

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "types.hpp" #include "types.hpp"
#include "gen/ecode.hpp" #include "gen/ecode.hpp"
@ -193,6 +193,7 @@ typedef AST_Stmt_If* CodeStmt_If;
typedef AST_Stmt_For* CodeStmt_For; typedef AST_Stmt_For* CodeStmt_For;
typedef AST_Stmt_Goto* CodeStmt_Goto; typedef AST_Stmt_Goto* CodeStmt_Goto;
typedef AST_Stmt_Label* CodeStmt_Label; typedef AST_Stmt_Label* CodeStmt_Label;
typedef AST_Stmt_Lambda* CodeStmt_Lambda;
typedef AST_Stmt_Switch* CodeStmt_Switch; typedef AST_Stmt_Switch* CodeStmt_Switch;
typedef AST_Stmt_While* CodeStmt_While; typedef AST_Stmt_While* CodeStmt_While;
#else #else
@ -208,6 +209,7 @@ struct CodeStmt_If;
struct CodeStmt_For; struct CodeStmt_For;
struct CodeStmt_Goto; struct CodeStmt_Goto;
struct CodeStmt_Label; struct CodeStmt_Label;
struct CodeStmt_Lambda;
struct CodeStmt_Switch; struct CodeStmt_Switch;
struct CodeStmt_While; struct CodeStmt_While;
#endif #endif
@ -239,18 +241,18 @@ template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast(
#pragma region Code C-Interface #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 Str code_debug_str (Code code);
GEN_API Code code_duplicate (Code code); GEN_API Code code_duplicate (Code code);
GEN_API Code* code_entry (Code code, u32 idx ); Code* code_entry (Code code, u32 idx );
GEN_API bool code_has_entries (Code code); bool code_has_entries (Code code);
GEN_API bool code_is_body (Code code); bool code_is_body (Code code);
GEN_API bool code_is_equal (Code code, Code other); GEN_API bool code_is_equal (Code code, Code other);
GEN_API bool code_is_valid (Code code); bool code_is_valid (Code code);
GEN_API void code_set_global (Code code); void code_set_global (Code code);
GEN_API StrBuilder code_to_strbuilder (Code self ); GEN_API StrBuilder code_to_strbuilder (Code self );
GEN_API void code_to_strbuilder_ptr(Code self, StrBuilder* result ); GEN_API void code_to_strbuilder_ref(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 ); GEN_API bool code_validate_body (Code self );
#pragma endregion Code C-Interface #pragma endregion Code C-Interface
@ -287,7 +289,7 @@ struct Code
forceinline Code* entry(u32 idx) { return code_entry(* this, idx); } forceinline Code* entry(u32 idx) { return code_entry(* this, idx); }
forceinline bool has_entries() { return code_has_entries(* this); } forceinline bool has_entries() { return code_has_entries(* this); }
forceinline StrBuilder to_strbuilder() { return code_to_strbuilder(* this); } forceinline StrBuilder to_strbuilder() { return code_to_strbuilder(* this); }
forceinline void to_strbuilder(StrBuilder& result) { return code_to_strbuilder_ptr(* this, & result); } forceinline void to_strbuilder(StrBuilder& result) { return code_to_strbuilder_ref(* this, & result); }
forceinline Str type_str() { return code_type_str(* this); } forceinline Str type_str() { return code_type_str(* this); }
forceinline bool validate_body() { return code_validate_body(*this); } forceinline bool validate_body() { return code_validate_body(*this); }
#endif #endif
@ -337,10 +339,10 @@ struct Code
#pragma region Statics #pragma region Statics
// Used to identify ASTs that should always be duplicated. (Global constant ASTs) // Used to identify ASTs that should always be duplicated. (Global constant ASTs)
extern Code Code_Global; GEN_API extern Code Code_Global;
// Used to identify invalid generated code. // Used to identify invalid generated code.
extern Code Code_Invalid; GEN_API extern Code Code_Invalid;
#pragma endregion Statics #pragma endregion Statics
struct Code_POD struct Code_POD
@ -378,7 +380,7 @@ struct AST
{ {
Code InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable Code InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
Code Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable // TODO(Ed): Parameters can have attributes Code Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable // TODO(Ed): Parameters can have attributes
Code Specs; // Destructor, Function, Operator, Typename, Variable Code Specs; // Class, Destructor, Function, Operator, Struct, Typename, Variable
union { union {
Code InitializerList; // Constructor Code InitializerList; // Constructor
Code ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces. Code ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces.
@ -399,8 +401,8 @@ struct AST
Code Value; // Parameter, Variable Code Value; // Parameter, Variable
}; };
union { 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; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed ) Code SuffixSpecs; // Typename, Function (Thanks Unreal)
Code PostNameMacro; // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal) Code PostNameMacro; // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal)
}; };
}; };

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "code_types.hpp" # include "code_types.hpp"
#endif #endif
@ -100,7 +100,7 @@ struct AST_Class
{ {
CodeComment InlineCmt; // Only supported by forward declarations CodeComment InlineCmt; // Only supported by forward declarations
CodeAttributes Attributes; CodeAttributes Attributes;
char _PAD_SPECS_ [ sizeof(AST*) ]; CodeSpecifiers Specs; // Support for final
CodeTypename ParentType; CodeTypename ParentType;
char _PAD_PARAMS_[ sizeof(AST*) ]; char _PAD_PARAMS_[ sizeof(AST*) ];
CodeBody Body; CodeBody Body;
@ -227,7 +227,7 @@ struct AST_Enum
Code Parent; Code Parent;
CodeType Type; CodeType Type;
ModuleFlag ModuleFlags; 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"); static_assert( sizeof(AST_Enum) == sizeof(AST), "ERROR: AST_Enum is not the same size as AST");
@ -575,7 +575,7 @@ struct AST_Fn
CodeTypename ReturnType; CodeTypename ReturnType;
CodeParams Params; CodeParams Params;
CodeBody Body; CodeBody Body;
char _PAD_PROPERTIES_ [ sizeof(AST*) ]; Code SuffixSpecs; // Thanks Unreal
}; };
}; };
StrCached Name; StrCached Name;
@ -738,8 +738,8 @@ static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_Preprocess
struct AST_Specifiers struct AST_Specifiers
{ {
Specifier ArrSpecs[ AST_ArrSpecs_Cap ]; Specifier ArrSpecs[ AST_ArrSpecs_Cap ];
StrCached Name;
CodeSpecifiers NextSpecs; CodeSpecifiers NextSpecs;
StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
@ -970,7 +970,7 @@ struct AST_Struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
CodeAttributes Attributes; CodeAttributes Attributes;
char _PAD_SPECS_ [ sizeof(AST*) ]; CodeSpecifiers Specs; // Support for final
CodeTypename ParentType; CodeTypename ParentType;
char _PAD_PARAMS_[ sizeof(AST*) ]; char _PAD_PARAMS_[ sizeof(AST*) ];
CodeBody Body; CodeBody Body;
@ -1056,7 +1056,7 @@ struct AST_Typename
CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
@ -1082,7 +1082,7 @@ struct AST_Typedef
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
}; };
}; };
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;

View File

@ -1,23 +1,8 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "ast.cpp" #include "ast.cpp"
#endif #endif
inline
StrBuilder attributes_to_strbuilder(CodeAttributes attributes) {
GEN_ASSERT(attributes);
char* raw = ccast(char*, str_duplicate( attributes->Content, _ctx->Allocator_Temp ).Ptr);
StrBuilder result = { raw };
return result;
}
inline
void attributes_to_strbuilder_ref(CodeAttributes attributes, StrBuilder* result) {
GEN_ASSERT(attributes);
GEN_ASSERT(result);
strbuilder_append_str(result, attributes->Content);
}
StrBuilder body_to_strbuilder(CodeBody body) StrBuilder body_to_strbuilder(CodeBody body)
{ {
GEN_ASSERT(body); GEN_ASSERT(body);
@ -47,20 +32,6 @@ StrBuilder body_to_strbuilder(CodeBody body)
return result; return result;
} }
void body_to_strbuilder_ref( CodeBody body, StrBuilder* result )
{
GEN_ASSERT(body != nullptr);
GEN_ASSERT(result != nullptr);
Code curr = body->Front;
s32 left = body->NumEntries;
while ( left -- )
{
code_to_strbuilder_ptr(curr, result);
// strbuilder_append_fmt( result, "%SB", code_to_strbuilder(curr) );
++curr;
}
}
void body_to_strbuilder_export( CodeBody body, StrBuilder* result ) void body_to_strbuilder_export( CodeBody body, StrBuilder* result )
{ {
GEN_ASSERT(body != nullptr); GEN_ASSERT(body != nullptr);
@ -71,7 +42,7 @@ void body_to_strbuilder_export( CodeBody body, StrBuilder* result )
s32 left = body->NumEntries; s32 left = body->NumEntries;
while ( left-- ) while ( left-- )
{ {
code_to_strbuilder_ptr(curr, result); code_to_strbuilder_ref(curr, result);
// strbuilder_append_fmt( result, "%SB", code_to_strbuilder(curr) ); // strbuilder_append_fmt( result, "%SB", code_to_strbuilder(curr) );
++curr; ++curr;
} }
@ -79,23 +50,9 @@ void body_to_strbuilder_export( CodeBody body, StrBuilder* result )
strbuilder_append_fmt( result, "};\n" ); strbuilder_append_fmt( result, "};\n" );
} }
inline
StrBuilder comment_to_strbuilder(CodeComment comment) {
GEN_ASSERT(comment);
char* raw = ccast(char*, str_duplicate( comment->Content, _ctx->Allocator_Temp ).Ptr);
StrBuilder result = { raw };
return result;
}
inline
void comment_to_strbuilder_ref(CodeComment comment, StrBuilder* result) {
GEN_ASSERT(comment);
GEN_ASSERT(result);
strbuilder_append_str(result, comment->Content);
}
StrBuilder constructor_to_strbuilder(CodeConstructor self) StrBuilder constructor_to_strbuilder(CodeConstructor self)
{ {
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 );
switch (self->Type) switch (self->Type)
{ {
@ -111,6 +68,8 @@ StrBuilder constructor_to_strbuilder(CodeConstructor self)
void constructor_to_strbuilder_def(CodeConstructor self, StrBuilder* result ) void constructor_to_strbuilder_def(CodeConstructor self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
Code ClassStructParent = self->Parent->Parent; Code ClassStructParent = self->Parent->Parent;
if (ClassStructParent) { if (ClassStructParent) {
strbuilder_append_str( result, ClassStructParent->Name ); strbuilder_append_str( result, ClassStructParent->Name );
@ -135,6 +94,8 @@ void constructor_to_strbuilder_def(CodeConstructor self, StrBuilder* result )
void constructor_to_strbuilder_fwd(CodeConstructor self, StrBuilder* result ) void constructor_to_strbuilder_fwd(CodeConstructor self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
Code ClassStructParent = self->Parent->Parent; Code ClassStructParent = self->Parent->Parent;
if (ClassStructParent) { if (ClassStructParent) {
strbuilder_append_str( result, ClassStructParent->Name ); strbuilder_append_str( result, ClassStructParent->Name );
@ -159,6 +120,7 @@ void constructor_to_strbuilder_fwd(CodeConstructor self, StrBuilder* result )
StrBuilder class_to_strbuilder( CodeClass self ) StrBuilder class_to_strbuilder( CodeClass self )
{ {
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 );
switch ( self->Type ) switch ( self->Type )
{ {
@ -175,6 +137,7 @@ StrBuilder class_to_strbuilder( CodeClass self )
void class_to_strbuilder_def( CodeClass self, StrBuilder* result ) void class_to_strbuilder_def( CodeClass self, StrBuilder* result )
{ {
GEN_ASSERT(self); GEN_ASSERT(self);
GEN_ASSERT(result);
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
strbuilder_append_str( result, txt("export ") ); strbuilder_append_str( result, txt("export ") );
@ -186,10 +149,16 @@ void class_to_strbuilder_def( CodeClass self, StrBuilder* result )
strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) );
} }
if ( self->Name.Len )
strbuilder_append_str( result, self->Name );
if (self->Specs && specifiers_has(self->Specs, Spec_Final))
strbuilder_append_str(result, txt(" final"));
if ( self->ParentType ) if ( self->ParentType )
{ {
Str access_level = access_spec_to_str( self->ParentAccess ); Str access_level = access_spec_to_str( self->ParentAccess );
strbuilder_append_fmt( result, "%S : %S %SB", self->Name, access_level, typename_to_strbuilder(self->ParentType) ); strbuilder_append_fmt( result, " : %S %SB", self->Name, access_level, typename_to_strbuilder(self->ParentType) );
CodeTypename interface = cast(CodeTypename, self->ParentType->Next); CodeTypename interface = cast(CodeTypename, self->ParentType->Next);
if ( interface ) if ( interface )
@ -201,10 +170,6 @@ void class_to_strbuilder_def( CodeClass self, StrBuilder* result )
interface = interface->Next ? cast(CodeTypename, interface->Next) : NullCode; interface = interface->Next ? cast(CodeTypename, interface->Next) : NullCode;
} }
} }
else if ( self->Name.Len )
{
strbuilder_append_str( result, self->Name );
}
if ( self->InlineCmt ) if ( self->InlineCmt )
{ {
@ -220,6 +185,7 @@ void class_to_strbuilder_def( CodeClass self, StrBuilder* result )
void class_to_strbuilder_fwd( CodeClass self, StrBuilder* result ) void class_to_strbuilder_fwd( CodeClass self, StrBuilder* result )
{ {
GEN_ASSERT(self); GEN_ASSERT(self);
GEN_ASSERT(result);
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
strbuilder_append_str( result, txt("export ") ); strbuilder_append_str( result, txt("export ") );
@ -239,13 +205,6 @@ void class_to_strbuilder_fwd( CodeClass self, StrBuilder* result )
} }
} }
StrBuilder define_to_strbuilder(CodeDefine define)
{
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 );
define_to_strbuilder_ref(define, & result);
return result;
}
void define_to_strbuilder_ref(CodeDefine define, StrBuilder* result ) void define_to_strbuilder_ref(CodeDefine define, StrBuilder* result )
{ {
GEN_ASSERT(define); GEN_ASSERT(define);
@ -260,14 +219,6 @@ void define_to_strbuilder_ref(CodeDefine define, StrBuilder* result )
} }
} }
StrBuilder define_params_to_strbuilder(CodeDefineParams params)
{
GEN_ASSERT(params);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 );
define_params_to_strbuilder_ref( params, & result );
return result;
}
void define_params_to_strbuilder_ref(CodeDefineParams self, StrBuilder* result) void define_params_to_strbuilder_ref(CodeDefineParams self, StrBuilder* result)
{ {
GEN_ASSERT(self); GEN_ASSERT(self);
@ -287,6 +238,7 @@ void define_params_to_strbuilder_ref(CodeDefineParams self, StrBuilder* result)
StrBuilder destructor_to_strbuilder(CodeDestructor self) StrBuilder destructor_to_strbuilder(CodeDestructor self)
{ {
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 );
switch ( self->Type ) switch ( self->Type )
{ {
@ -302,6 +254,8 @@ StrBuilder destructor_to_strbuilder(CodeDestructor self)
void destructor_to_strbuilder_def(CodeDestructor self, StrBuilder* result ) void destructor_to_strbuilder_def(CodeDestructor self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( self->Name.Len ) if ( self->Name.Len )
{ {
strbuilder_append_fmt( result, "%S()", self->Name ); strbuilder_append_fmt( result, "%S()", self->Name );
@ -321,6 +275,8 @@ void destructor_to_strbuilder_def(CodeDestructor self, StrBuilder* result )
void destructor_to_strbuilder_fwd(CodeDestructor self, StrBuilder* result ) void destructor_to_strbuilder_fwd(CodeDestructor self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( self->Specs ) if ( self->Specs )
{ {
if ( specifiers_has(self->Specs, Spec_Virtual ) ) if ( specifiers_has(self->Specs, Spec_Virtual ) )
@ -344,6 +300,7 @@ void destructor_to_strbuilder_fwd(CodeDestructor self, StrBuilder* result )
StrBuilder enum_to_strbuilder(CodeEnum self) StrBuilder enum_to_strbuilder(CodeEnum self)
{ {
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 );
switch ( self->Type ) switch ( self->Type )
{ {
@ -365,6 +322,8 @@ StrBuilder enum_to_strbuilder(CodeEnum self)
void enum_to_strbuilder_def(CodeEnum self, StrBuilder* result ) void enum_to_strbuilder_def(CodeEnum self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
strbuilder_append_str( result, txt("export ") ); strbuilder_append_str( result, txt("export ") );
@ -398,6 +357,8 @@ void enum_to_strbuilder_def(CodeEnum self, StrBuilder* result )
void enum_to_strbuilder_fwd(CodeEnum self, StrBuilder* result ) void enum_to_strbuilder_fwd(CodeEnum self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
strbuilder_append_str( result, txt("export ") ); strbuilder_append_str( result, txt("export ") );
@ -425,6 +386,8 @@ void enum_to_strbuilder_fwd(CodeEnum self, StrBuilder* result )
void enum_to_strbuilder_class_def(CodeEnum self, StrBuilder* result ) void enum_to_strbuilder_class_def(CodeEnum self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
strbuilder_append_str( result, txt("export ") ); strbuilder_append_str( result, txt("export ") );
@ -457,6 +420,8 @@ void enum_to_strbuilder_class_def(CodeEnum self, StrBuilder* result )
void enum_to_strbuilder_class_fwd(CodeEnum self, StrBuilder* result ) void enum_to_strbuilder_class_fwd(CodeEnum self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
strbuilder_append_str( result, txt("export ") ); strbuilder_append_str( result, txt("export ") );
@ -476,56 +441,9 @@ void enum_to_strbuilder_class_fwd(CodeEnum self, StrBuilder* result )
} }
} }
StrBuilder exec_to_strbuilder(CodeExec exec)
{
GEN_ASSERT(exec);
char* raw = ccast(char*, str_duplicate( exec->Content, _ctx->Allocator_Temp ).Ptr);
StrBuilder result = { raw };
return result;
}
void extern_to_strbuilder(CodeExtern self, StrBuilder* result )
{
if ( self->Body )
strbuilder_append_fmt( result, "extern \"%S\"\n{\n%SB\n}\n", self->Name, body_to_strbuilder(self->Body) );
else
strbuilder_append_fmt( result, "extern \"%S\"\n{}\n", self->Name );
}
StrBuilder include_to_strbuilder(CodeInclude include)
{
return strbuilder_fmt_buf( _ctx->Allocator_Temp, "#include %S\n", include->Content );
}
void include_to_strbuilder_ref( CodeInclude include, StrBuilder* result )
{
strbuilder_append_fmt( result, "#include %S\n", include->Content );
}
StrBuilder friend_to_strbuilder(CodeFriend self)
{
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 256 );
friend_to_strbuilder_ref( self, & result );
return result;
}
void friend_to_strbuilder_ref(CodeFriend self, StrBuilder* result )
{
strbuilder_append_fmt( result, "friend %SB", code_to_strbuilder(self->Declaration) );
if ( self->Declaration->Type != CT_Function && self->Declaration->Type != CT_Operator && (* result)[ strbuilder_length(* result) - 1 ] != ';' )
{
strbuilder_append_str( result, txt(";") );
}
if ( self->InlineCmt )
strbuilder_append_fmt( result, " %S", self->InlineCmt->Content );
else
strbuilder_append_str( result, txt("\n"));
}
StrBuilder fn_to_strbuilder(CodeFn self) StrBuilder fn_to_strbuilder(CodeFn self)
{ {
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 );
switch ( self->Type ) switch ( self->Type )
{ {
@ -541,6 +459,8 @@ StrBuilder fn_to_strbuilder(CodeFn self)
void fn_to_strbuilder_def(CodeFn self, StrBuilder* result ) void fn_to_strbuilder_def(CodeFn self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
strbuilder_append_str( result, txt("export") ); strbuilder_append_str( result, txt("export") );
@ -589,11 +509,17 @@ void fn_to_strbuilder_def(CodeFn self, StrBuilder* result )
} }
} }
// This is bodged in for now SOLEY for Unreal's PURE_VIRTUAL functional macro
if ( self->SuffixSpecs )
strbuilder_append_fmt( result, " %SB", code_to_strbuilder(self->SuffixSpecs) );
strbuilder_append_fmt( result, "\n{\n%SB\n}\n", body_to_strbuilder(self->Body) ); strbuilder_append_fmt( result, "\n{\n%SB\n}\n", body_to_strbuilder(self->Body) );
} }
void fn_to_strbuilder_fwd(CodeFn self, StrBuilder* result ) void fn_to_strbuilder_fwd(CodeFn self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
strbuilder_append_str( result, txt("export ") ); strbuilder_append_str( result, txt("export ") );
@ -642,11 +568,18 @@ void fn_to_strbuilder_fwd(CodeFn self, StrBuilder* result )
strbuilder_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); strbuilder_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
} }
} }
if ( specifiers_has(self->Specs, Spec_Pure ) )
strbuilder_append_str( result, txt(" = 0") );
else if ( specifiers_has(self->Specs, Spec_Delete ) )
strbuilder_append_str( result, txt(" = delete") );
} }
if ( self->Specs && specifiers_has(self->Specs, Spec_Pure ) >= 0 ) // This is bodged in for now SOLEY for Unreal's PURE_VIRTUAL functional macro (I kept it open ended for other jank)
strbuilder_append_str( result, txt(" = 0;") ); if ( self->SuffixSpecs )
else if (self->Body) strbuilder_append_fmt( result, " %SB", code_to_strbuilder(self->SuffixSpecs) );
if (self->Body)
strbuilder_append_fmt( result, " = %SB;", body_to_strbuilder(self->Body) ); strbuilder_append_fmt( result, " = %SB;", body_to_strbuilder(self->Body) );
if ( self->InlineCmt ) if ( self->InlineCmt )
@ -655,15 +588,10 @@ void fn_to_strbuilder_fwd(CodeFn self, StrBuilder* result )
strbuilder_append_str( result, txt(";\n") ); strbuilder_append_str( result, txt(";\n") );
} }
StrBuilder module_to_strbuilder(CodeModule self)
{
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 64 );
module_to_strbuilder_ref( self, & result );
return result;
}
void module_to_strbuilder_ref(CodeModule self, StrBuilder* result ) void module_to_strbuilder_ref(CodeModule self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if (((scast(u32, ModuleFlag_Export) & scast(u32, self->ModuleFlags)) == scast(u32, ModuleFlag_Export))) if (((scast(u32, ModuleFlag_Export) & scast(u32, self->ModuleFlags)) == scast(u32, ModuleFlag_Export)))
strbuilder_append_str( result, txt("export ")); strbuilder_append_str( result, txt("export "));
@ -673,23 +601,9 @@ void module_to_strbuilder_ref(CodeModule self, StrBuilder* result )
strbuilder_append_fmt( result, "%S;\n", self->Name ); strbuilder_append_fmt( result, "%S;\n", self->Name );
} }
StrBuilder namespace_to_strbuilder(CodeNS self)
{
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 );
namespace_to_strbuilder_ref( self, & result );
return result;
}
void namespace_to_strbuilder_ref(CodeNS self, StrBuilder* result )
{
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
strbuilder_append_str( result, txt("export ") );
strbuilder_append_fmt( result, "namespace %S\n{\n%SB\n}\n", self->Name, body_to_strbuilder(self->Body) );
}
StrBuilder code_op_to_strbuilder(CodeOperator self) StrBuilder code_op_to_strbuilder(CodeOperator self)
{ {
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 );
switch ( self->Type ) switch ( self->Type )
{ {
@ -707,6 +621,8 @@ StrBuilder code_op_to_strbuilder(CodeOperator self)
void code_op_to_strbuilder_def(CodeOperator self, StrBuilder* result ) void code_op_to_strbuilder_def(CodeOperator self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
strbuilder_append_str( result, txt("export ") ); strbuilder_append_str( result, txt("export ") );
@ -761,6 +677,8 @@ void code_op_to_strbuilder_def(CodeOperator self, StrBuilder* result )
void code_op_to_strbuilder_fwd(CodeOperator self, StrBuilder* result ) void code_op_to_strbuilder_fwd(CodeOperator self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
strbuilder_append_str( result, txt("export ") ); strbuilder_append_str( result, txt("export ") );
@ -812,6 +730,7 @@ void code_op_to_strbuilder_fwd(CodeOperator self, StrBuilder* result )
StrBuilder opcast_to_strbuilder(CodeOpCast self) StrBuilder opcast_to_strbuilder(CodeOpCast self)
{ {
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 ); StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 );
switch ( self->Type ) switch ( self->Type )
{ {
@ -827,6 +746,8 @@ StrBuilder opcast_to_strbuilder(CodeOpCast self)
void opcast_to_strbuilder_def(CodeOpCast self, StrBuilder* result ) void opcast_to_strbuilder_def(CodeOpCast self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( self->Specs ) if ( self->Specs )
{ {
for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) )
@ -864,6 +785,8 @@ void opcast_to_strbuilder_def(CodeOpCast self, StrBuilder* result )
void opcast_to_strbuilder_fwd(CodeOpCast self, StrBuilder* result ) void opcast_to_strbuilder_fwd(CodeOpCast self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( self->Specs ) if ( self->Specs )
{ {
for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) )
@ -899,14 +822,6 @@ void opcast_to_strbuilder_fwd(CodeOpCast self, StrBuilder* result )
strbuilder_append_fmt( result, "operator %SB();\n", typename_to_strbuilder(self->ValueType) ); strbuilder_append_fmt( result, "operator %SB();\n", typename_to_strbuilder(self->ValueType) );
} }
StrBuilder params_to_strbuilder(CodeParams self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 );
params_to_strbuilder_ref( self, & result );
return result;
}
void params_to_strbuilder_ref( CodeParams self, StrBuilder* result ) void params_to_strbuilder_ref( CodeParams self, StrBuilder* result )
{ {
GEN_ASSERT(self); GEN_ASSERT(self);
@ -974,62 +889,6 @@ StrBuilder preprocess_to_strbuilder(CodePreprocessCond self)
return result; return result;
} }
void preprocess_to_strbuilder_if(CodePreprocessCond cond, StrBuilder* result )
{
GEN_ASSERT(cond);
strbuilder_append_fmt( result, "#if %S", cond->Content );
}
void preprocess_to_strbuilder_ifdef(CodePreprocessCond cond, StrBuilder* result )
{
GEN_ASSERT(cond);
strbuilder_append_fmt( result, "#ifdef %S\n", cond->Content );
}
void preprocess_to_strbuilder_ifndef(CodePreprocessCond cond, StrBuilder* result )
{
GEN_ASSERT(cond);
strbuilder_append_fmt( result, "#ifndef %S", cond->Content );
}
void preprocess_to_strbuilder_elif(CodePreprocessCond cond, StrBuilder* result )
{
GEN_ASSERT(cond);
strbuilder_append_fmt( result, "#elif %S\n", cond->Content );
}
void preprocess_to_strbuilder_else(CodePreprocessCond cond, StrBuilder* result )
{
GEN_ASSERT(cond);
strbuilder_append_str( result, txt("#else\n") );
}
void preprocess_to_strbuilder_endif(CodePreprocessCond cond, StrBuilder* result )
{
GEN_ASSERT(cond);
strbuilder_append_str( result, txt("#endif\n") );
}
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;
}
void pragma_to_strbuilder_ref(CodePragma self, StrBuilder* result )
{
strbuilder_append_fmt( result, "#pragma %S\n", self->Content );
}
StrBuilder specifiers_to_strbuilder(CodeSpecifiers self)
{
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 64 );
specifiers_to_strbuilder_ref( self, & result );
return result;
}
void specifiers_to_strbuilder_ref( CodeSpecifiers self, StrBuilder* result ) void specifiers_to_strbuilder_ref( CodeSpecifiers self, StrBuilder* result )
{ {
GEN_ASSERT(self); GEN_ASSERT(self);
@ -1087,11 +946,17 @@ void struct_to_strbuilder_def( CodeStruct self, StrBuilder* result )
strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) ); strbuilder_append_fmt( result, "%SB ", attributes_to_strbuilder(self->Attributes) );
} }
if ( self->Name.Len )
strbuilder_append_str( result, self->Name );
if (self->Specs && specifiers_has(self->Specs, Spec_Final))
strbuilder_append_str( result, txt(" final"));
if ( self->ParentType ) if ( self->ParentType )
{ {
Str access_level = access_spec_to_str( self->ParentAccess ); Str access_level = access_spec_to_str( self->ParentAccess );
strbuilder_append_fmt( result, "%S : %S %SB", self->Name, access_level, typename_to_strbuilder(self->ParentType) ); strbuilder_append_fmt( result, " : %S %SB", access_level, typename_to_strbuilder(self->ParentType) );
CodeTypename interface = cast(CodeTypename, self->ParentType->Next); CodeTypename interface = cast(CodeTypename, self->ParentType->Next);
if ( interface ) if ( interface )
@ -1103,10 +968,6 @@ void struct_to_strbuilder_def( CodeStruct self, StrBuilder* result )
interface = interface->Next ? cast( CodeTypename, interface->Next) : NullCode; interface = interface->Next ? cast( CodeTypename, interface->Next) : NullCode;
} }
} }
else if ( self->Name.Len )
{
strbuilder_append_str( result, self->Name );
}
if ( self->InlineCmt ) if ( self->InlineCmt )
{ {
@ -1140,14 +1001,6 @@ void struct_to_strbuilder_fwd( CodeStruct self, StrBuilder* result )
} }
} }
StrBuilder template_to_strbuilder(CodeTemplate self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 1024 );
template_to_strbuilder_ref( self, & result );
return result;
}
void template_to_strbuilder_ref(CodeTemplate self, StrBuilder* result ) void template_to_strbuilder_ref(CodeTemplate self, StrBuilder* result )
{ {
GEN_ASSERT(self); GEN_ASSERT(self);
@ -1161,15 +1014,10 @@ void template_to_strbuilder_ref(CodeTemplate self, StrBuilder* result )
strbuilder_append_fmt( result, "template<>\n%SB", code_to_strbuilder(self->Declaration) ); strbuilder_append_fmt( result, "template<>\n%SB", code_to_strbuilder(self->Declaration) );
} }
StrBuilder typedef_to_strbuilder(CodeTypedef self)
{
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 );
typedef_to_strbuilder_ref( self, & result );
return result;
}
void typedef_to_strbuilder_ref(CodeTypedef self, StrBuilder* result ) void typedef_to_strbuilder_ref(CodeTypedef self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
strbuilder_append_str( result, txt("export ") ); strbuilder_append_str( result, txt("export ") );
@ -1203,15 +1051,10 @@ void typedef_to_strbuilder_ref(CodeTypedef self, StrBuilder* result )
strbuilder_append_str( result, txt("\n")); strbuilder_append_str( result, txt("\n"));
} }
StrBuilder typename_to_strbuilder(CodeTypename self)
{
StrBuilder result = strbuilder_make_str( _ctx->Allocator_Temp, txt("") );
typename_to_strbuilder_ref( self, & result );
return result;
}
void typename_to_strbuilder_ref(CodeTypename self, StrBuilder* result ) void typename_to_strbuilder_ref(CodeTypename self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
#if defined(GEN_USE_NEW_TYPENAME_PARSING) #if defined(GEN_USE_NEW_TYPENAME_PARSING)
if ( self->ReturnType && self->Params ) if ( self->ReturnType && self->Params )
{ {
@ -1268,6 +1111,7 @@ void typename_to_strbuilder_ref(CodeTypename self, StrBuilder* result )
StrBuilder union_to_strbuilder(CodeUnion self) StrBuilder union_to_strbuilder(CodeUnion self)
{ {
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 ); StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 );
switch ( self->Type ) switch ( self->Type )
{ {
@ -1283,6 +1127,8 @@ StrBuilder union_to_strbuilder(CodeUnion self)
void union_to_strbuilder_def(CodeUnion self, StrBuilder* result ) void union_to_strbuilder_def(CodeUnion self, StrBuilder* result )
{ {
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export )) if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
strbuilder_append_str( result, txt("export ") ); strbuilder_append_str( result, txt("export ") );
@ -1331,22 +1177,6 @@ void union_to_strbuilder_fwd(CodeUnion self, StrBuilder* result )
strbuilder_append_str( result, txt(";\n")); strbuilder_append_str( result, txt(";\n"));
} }
StrBuilder using_to_strbuilder(CodeUsing self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 );
switch ( self->Type )
{
case CT_Using:
using_to_strbuilder_ref( self, & result );
break;
case CT_Using_Namespace:
using_to_strbuilder_ns( self, & result );
break;
}
return result;
}
void using_to_strbuilder_ref(CodeUsing self, StrBuilder* result ) void using_to_strbuilder_ref(CodeUsing self, StrBuilder* result )
{ {
GEN_ASSERT(self); GEN_ASSERT(self);
@ -1384,26 +1214,6 @@ void using_to_strbuilder_ref(CodeUsing self, StrBuilder* result )
strbuilder_append_str( result, txt("\n")); strbuilder_append_str( result, txt("\n"));
} }
inline
void using_to_strbuilder_ns(CodeUsing self, StrBuilder* result )
{
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( self->InlineCmt )
strbuilder_append_fmt( result, "using namespace $SC; %S", self->Name, self->InlineCmt->Content );
else
strbuilder_append_fmt( result, "using namespace %S;\n", self->Name );
}
inline
StrBuilder var_to_strbuilder(CodeVar self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 256 );
var_to_strbuilder_ref( self, & result );
return result;
}
neverinline neverinline
void var_to_strbuilder_ref(CodeVar self, StrBuilder* result ) void var_to_strbuilder_ref(CodeVar self, StrBuilder* result )
{ {

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "ast.hpp" #include "ast.hpp"
#endif #endif
@ -20,58 +20,59 @@
GEN_API void body_append ( CodeBody body, Code other ); GEN_API void body_append ( CodeBody body, Code other );
GEN_API void body_append_body ( CodeBody body, CodeBody other ); GEN_API void body_append_body ( CodeBody body, CodeBody other );
GEN_API StrBuilder body_to_strbuilder ( CodeBody body ); GEN_API StrBuilder body_to_strbuilder ( CodeBody body );
GEN_API void body_to_strbuilder_ref ( CodeBody body, StrBuilder* result ); void body_to_strbuilder_ref ( CodeBody body, StrBuilder* result );
GEN_API void body_to_strbuilder_export( CodeBody body, StrBuilder* result ); GEN_API void body_to_strbuilder_export( CodeBody body, StrBuilder* result );
GEN_API Code begin_CodeBody( CodeBody body); Code begin_CodeBody( CodeBody body);
GEN_API Code end_CodeBody ( CodeBody body ); Code end_CodeBody ( CodeBody body );
GEN_API Code next_CodeBody ( CodeBody body, Code entry_iter ); Code next_CodeBody ( CodeBody body, Code entry_iter );
GEN_API void class_add_interface ( CodeClass self, CodeTypename interface ); void class_add_interface ( CodeClass self, CodeTypename interface );
GEN_API StrBuilder class_to_strbuilder ( CodeClass self ); GEN_API StrBuilder class_to_strbuilder ( CodeClass self );
GEN_API void class_to_strbuilder_def( CodeClass self, StrBuilder* result ); GEN_API void class_to_strbuilder_def( CodeClass self, StrBuilder* result );
GEN_API void class_to_strbuilder_fwd( CodeClass self, StrBuilder* result ); GEN_API void class_to_strbuilder_fwd( CodeClass self, StrBuilder* result );
GEN_API void define_params_append (CodeDefineParams appendee, CodeDefineParams other ); void define_params_append (CodeDefineParams appendee, CodeDefineParams other );
GEN_API CodeDefineParams define_params_get (CodeDefineParams params, s32 idx); CodeDefineParams define_params_get (CodeDefineParams params, s32 idx);
GEN_API bool define_params_has_entries (CodeDefineParams params ); bool define_params_has_entries (CodeDefineParams params );
GEN_API StrBuilder define_params_to_strbuilder (CodeDefineParams params ); StrBuilder define_params_to_strbuilder (CodeDefineParams params );
GEN_API void define_params_to_strbuilder_ref(CodeDefineParams params, StrBuilder* result ); GEN_API void define_params_to_strbuilder_ref(CodeDefineParams params, StrBuilder* result );
GEN_API CodeDefineParams begin_CodeDefineParams(CodeDefineParams params); CodeDefineParams begin_CodeDefineParams(CodeDefineParams params);
GEN_API CodeDefineParams end_CodeDefineParams (CodeDefineParams params); CodeDefineParams end_CodeDefineParams (CodeDefineParams params);
GEN_API CodeDefineParams next_CodeDefineParams (CodeDefineParams params, CodeDefineParams entry_iter); CodeDefineParams next_CodeDefineParams (CodeDefineParams params, CodeDefineParams entry_iter);
GEN_API void params_append (CodeParams appendee, CodeParams other ); void params_append (CodeParams appendee, CodeParams other );
GEN_API CodeParams params_get (CodeParams params, s32 idx); CodeParams params_get (CodeParams params, s32 idx);
GEN_API bool params_has_entries (CodeParams params ); bool params_has_entries (CodeParams params );
GEN_API StrBuilder params_to_strbuilder (CodeParams params ); StrBuilder params_to_strbuilder (CodeParams params );
GEN_API void params_to_strbuilder_ref(CodeParams params, StrBuilder* result ); GEN_API void params_to_strbuilder_ref(CodeParams params, StrBuilder* result );
GEN_API CodeParams begin_CodeParams(CodeParams params); CodeParams begin_CodeParams(CodeParams params);
GEN_API CodeParams end_CodeParams (CodeParams params); CodeParams end_CodeParams (CodeParams params);
GEN_API CodeParams next_CodeParams (CodeParams params, CodeParams entry_iter); CodeParams next_CodeParams (CodeParams params, CodeParams entry_iter);
GEN_API bool specifiers_append (CodeSpecifiers specifiers, Specifier spec); bool specifiers_append (CodeSpecifiers specifiers, Specifier spec);
GEN_API s32 specifiers_has (CodeSpecifiers specifiers, Specifier spec); bool specifiers_has (CodeSpecifiers specifiers, Specifier spec);
GEN_API s32 specifiers_remove (CodeSpecifiers specifiers, Specifier to_remove ); s32 specifiers_index_of (CodeSpecifiers specifiers, Specifier spec);
GEN_API StrBuilder specifiers_to_strbuilder (CodeSpecifiers specifiers); s32 specifiers_remove (CodeSpecifiers specifiers, Specifier to_remove );
StrBuilder specifiers_to_strbuilder (CodeSpecifiers specifiers);
GEN_API void specifiers_to_strbuilder_ref(CodeSpecifiers specifiers, StrBuilder* result); GEN_API void specifiers_to_strbuilder_ref(CodeSpecifiers specifiers, StrBuilder* result);
GEN_API Specifier* begin_CodeSpecifiers(CodeSpecifiers specifiers); Specifier* begin_CodeSpecifiers(CodeSpecifiers specifiers);
GEN_API Specifier* end_CodeSpecifiers (CodeSpecifiers specifiers); Specifier* end_CodeSpecifiers (CodeSpecifiers specifiers);
GEN_API Specifier* next_CodeSpecifiers (CodeSpecifiers specifiers, Specifier* spec_iter); Specifier* next_CodeSpecifiers (CodeSpecifiers specifiers, Specifier* spec_iter);
GEN_API void struct_add_interface (CodeStruct self, CodeTypename interface); void struct_add_interface (CodeStruct self, CodeTypename interface);
GEN_API StrBuilder struct_to_strbuilder (CodeStruct self); GEN_API StrBuilder struct_to_strbuilder (CodeStruct self);
GEN_API void struct_to_strbuilder_fwd(CodeStruct self, StrBuilder* result); GEN_API void struct_to_strbuilder_fwd(CodeStruct self, StrBuilder* result);
GEN_API void struct_to_strbuilder_def(CodeStruct self, StrBuilder* result); GEN_API void struct_to_strbuilder_def(CodeStruct self, StrBuilder* result);
GEN_API StrBuilder attributes_to_strbuilder (CodeAttributes attributes); StrBuilder attributes_to_strbuilder (CodeAttributes attributes);
GEN_API void attributes_to_strbuilder_ref(CodeAttributes attributes, StrBuilder* result); void attributes_to_strbuilder_ref(CodeAttributes attributes, StrBuilder* result);
GEN_API StrBuilder comment_to_strbuilder (CodeComment comment ); StrBuilder comment_to_strbuilder (CodeComment comment );
GEN_API void comment_to_strbuilder_ref(CodeComment comment, StrBuilder* result ); void comment_to_strbuilder_ref(CodeComment comment, StrBuilder* result );
GEN_API StrBuilder constructor_to_strbuilder (CodeConstructor constructor); GEN_API StrBuilder constructor_to_strbuilder (CodeConstructor constructor);
GEN_API void constructor_to_strbuilder_def(CodeConstructor constructor, StrBuilder* result ); GEN_API void constructor_to_strbuilder_def(CodeConstructor constructor, StrBuilder* result );
@ -90,66 +91,68 @@ GEN_API void enum_to_strbuilder_fwd (CodeEnum self, StrBuilder* resul
GEN_API void enum_to_strbuilder_class_def(CodeEnum self, StrBuilder* result ); GEN_API void enum_to_strbuilder_class_def(CodeEnum self, StrBuilder* result );
GEN_API void enum_to_strbuilder_class_fwd(CodeEnum self, StrBuilder* result ); GEN_API void enum_to_strbuilder_class_fwd(CodeEnum self, StrBuilder* result );
GEN_API StrBuilder exec_to_strbuilder (CodeExec exec); StrBuilder exec_to_strbuilder (CodeExec exec);
GEN_API void exec_to_strbuilder_ref(CodeExec exec, StrBuilder* result); void exec_to_strbuilder_ref(CodeExec exec, StrBuilder* result);
GEN_API void extern_to_strbuilder(CodeExtern self, StrBuilder* result); void extern_to_strbuilder(CodeExtern self, StrBuilder* result);
GEN_API StrBuilder include_to_strbuilder (CodeInclude self); StrBuilder include_to_strbuilder (CodeInclude self);
GEN_API void include_to_strbuilder_ref(CodeInclude self, StrBuilder* result); void include_to_strbuilder_ref(CodeInclude self, StrBuilder* result);
GEN_API StrBuilder friend_to_strbuilder (CodeFriend self); StrBuilder friend_to_strbuilder (CodeFriend self);
GEN_API void friend_to_strbuilder_ref(CodeFriend self, StrBuilder* result); void friend_to_strbuilder_ref(CodeFriend self, StrBuilder* result);
GEN_API StrBuilder fn_to_strbuilder (CodeFn self); GEN_API StrBuilder fn_to_strbuilder (CodeFn self);
GEN_API void fn_to_strbuilder_def(CodeFn self, StrBuilder* result); GEN_API void fn_to_strbuilder_def(CodeFn self, StrBuilder* result);
GEN_API void fn_to_strbuilder_fwd(CodeFn self, StrBuilder* result); GEN_API void fn_to_strbuilder_fwd(CodeFn self, StrBuilder* result);
GEN_API StrBuilder module_to_strbuilder (CodeModule self); StrBuilder module_to_strbuilder (CodeModule self);
GEN_API void module_to_strbuilder_ref(CodeModule self, StrBuilder* result); GEN_API void module_to_strbuilder_ref(CodeModule self, StrBuilder* result);
GEN_API StrBuilder namespace_to_strbuilder (CodeNS self); StrBuilder namespace_to_strbuilder (CodeNS self);
GEN_API void namespace_to_strbuilder_ref(CodeNS self, StrBuilder* result); void namespace_to_strbuilder_ref(CodeNS self, StrBuilder* result);
GEN_API StrBuilder code_op_to_strbuilder (CodeOperator self); GEN_API StrBuilder code_op_to_strbuilder (CodeOperator self);
GEN_API void code_op_to_strbuilder_fwd(CodeOperator self, StrBuilder* result ); GEN_API void code_op_to_strbuilder_fwd(CodeOperator self, StrBuilder* result );
GEN_API void code_op_to_strbuilder_def(CodeOperator self, StrBuilder* result ); GEN_API void code_op_to_strbuilder_def(CodeOperator self, StrBuilder* result );
GEN_API StrBuilder opcast_to_strbuilder (CodeOpCast op_cast ); GEN_API StrBuilder opcast_to_strbuilder (CodeOpCast op_cast );
GEN_API void opcast_to_strbuilder_def(CodeOpCast op_cast, StrBuilder* result ); GEN_API void opcast_to_strbuilder_def(CodeOpCast op_cast, StrBuilder* result );
GEN_API void opcast_to_strbuilder_fwd(CodeOpCast op_cast, StrBuilder* result ); GEN_API void opcast_to_strbuilder_fwd(CodeOpCast op_cast, StrBuilder* result );
GEN_API StrBuilder pragma_to_strbuilder (CodePragma self); StrBuilder pragma_to_strbuilder (CodePragma self);
GEN_API void pragma_to_strbuilder_ref(CodePragma self, StrBuilder* result); void pragma_to_strbuilder_ref(CodePragma self, StrBuilder* result);
GEN_API StrBuilder preprocess_to_strbuilder (CodePreprocessCond cond); GEN_API StrBuilder preprocess_to_strbuilder (CodePreprocessCond cond);
GEN_API void preprocess_to_strbuilder_if (CodePreprocessCond cond, StrBuilder* result ); void preprocess_to_strbuilder_if (CodePreprocessCond cond, StrBuilder* result );
GEN_API void preprocess_to_strbuilder_ifdef (CodePreprocessCond cond, StrBuilder* result ); void preprocess_to_strbuilder_ifdef (CodePreprocessCond cond, StrBuilder* result );
GEN_API void preprocess_to_strbuilder_ifndef(CodePreprocessCond cond, StrBuilder* result ); void preprocess_to_strbuilder_ifndef(CodePreprocessCond cond, StrBuilder* result );
GEN_API void preprocess_to_strbuilder_elif (CodePreprocessCond cond, StrBuilder* result ); void preprocess_to_strbuilder_elif (CodePreprocessCond cond, StrBuilder* result );
GEN_API void preprocess_to_strbuilder_else (CodePreprocessCond cond, StrBuilder* result ); void preprocess_to_strbuilder_else (CodePreprocessCond cond, StrBuilder* result );
GEN_API void preprocess_to_strbuilder_endif (CodePreprocessCond cond, StrBuilder* result ); void preprocess_to_strbuilder_endif (CodePreprocessCond cond, StrBuilder* result );
GEN_API 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);
GEN_API StrBuilder typename_to_strbuilder (CodeTypename self); StrBuilder typedef_to_strbuilder (CodeTypedef self);
GEN_API void typename_to_strbuilder_ref(CodeTypename self, StrBuilder* result);
GEN_API 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);
GEN_API StrBuilder using_to_strbuilder (CodeUsing op_cast ); StrBuilder using_to_strbuilder (CodeUsing op_cast );
GEN_API void using_to_strbuilder_ref(CodeUsing op_cast, StrBuilder* result ); GEN_API void using_to_strbuilder_ref(CodeUsing op_cast, StrBuilder* result );
GEN_API void using_to_strbuilder_ns (CodeUsing op_cast, StrBuilder* result ); void using_to_strbuilder_ns (CodeUsing op_cast, StrBuilder* result );
GEN_API StrBuilder var_to_strbuilder (CodeVar self); StrBuilder var_to_strbuilder (CodeVar self);
GEN_API void var_to_strbuilder_ref(CodeVar self, StrBuilder* result); GEN_API void var_to_strbuilder_ref(CodeVar self, StrBuilder* result);
// TODO(Ed): Move C-Interface inlines here...
#pragma endregion Code Type C-Interface #pragma endregion Code Type C-Interface
#if GEN_COMPILER_CPP #if GEN_COMPILER_CPP
@ -249,7 +252,8 @@ struct CodeSpecifiers
#if ! GEN_C_LIKE_CPP #if ! GEN_C_LIKE_CPP
Using_Code( CodeSpecifiers ); Using_Code( CodeSpecifiers );
bool append( Specifier spec ) { return specifiers_append(* this, spec); } bool append( Specifier spec ) { return specifiers_append(* this, spec); }
s32 has( Specifier spec ) { return specifiers_has(* this, spec); } bool has( Specifier spec ) { return specifiers_has(* this, spec); }
s32 index_of(Specifier spec) { return specifiers_index_of(* this, spec); }
s32 remove( Specifier to_remove ) { return specifiers_remove(* this, to_remove); } s32 remove( Specifier to_remove ) { return specifiers_remove(* this, to_remove); }
StrBuilder to_strbuilder() { return specifiers_to_strbuilder(* this ); } StrBuilder to_strbuilder() { return specifiers_to_strbuilder(* this ); }
void to_strbuilder( StrBuilder& result ) { return specifiers_to_strbuilder_ref(* this, & result); } void to_strbuilder( StrBuilder& result ) { return specifiers_to_strbuilder_ref(* this, & result); }
@ -1071,7 +1075,8 @@ forceinline StrBuilder to_strbuilder(CodeParams params ) {
forceinline void to_strbuilder(CodeParams params, StrBuilder& result ) { return params_to_strbuilder_ref(params, & result); } forceinline void to_strbuilder(CodeParams params, StrBuilder& result ) { return params_to_strbuilder_ref(params, & result); }
forceinline bool append (CodeSpecifiers specifiers, Specifier spec) { return specifiers_append(specifiers, spec); } forceinline bool append (CodeSpecifiers specifiers, Specifier spec) { return specifiers_append(specifiers, spec); }
forceinline s32 has (CodeSpecifiers specifiers, Specifier spec) { return specifiers_has(specifiers, spec); } forceinline bool has (CodeSpecifiers specifiers, Specifier spec) { return specifiers_has(specifiers, spec); }
forceinline s32 index_of (CodeSpecifiers specifiers, Specifier spec) { return specifiers_index_of(specifiers, spec); }
forceinline s32 remove (CodeSpecifiers specifiers, Specifier to_remove ) { return specifiers_remove(specifiers, to_remove); } forceinline s32 remove (CodeSpecifiers specifiers, Specifier to_remove ) { return specifiers_remove(specifiers, to_remove); }
forceinline StrBuilder to_strbuilder(CodeSpecifiers specifiers) { return specifiers_to_strbuilder(specifiers); } forceinline StrBuilder to_strbuilder(CodeSpecifiers specifiers) { return specifiers_to_strbuilder(specifiers); }
forceinline void to_strbuilder(CodeSpecifiers specifiers, StrBuilder& result) { return specifiers_to_strbuilder_ref(specifiers, & result); } forceinline void to_strbuilder(CodeSpecifiers specifiers, StrBuilder& result) { return specifiers_to_strbuilder_ref(specifiers, & result); }

View File

@ -0,0 +1,85 @@
#ifdef INTELLISENSE_DIRECTIVES
# pragma once
# include "interface.hpp"
#endif
#pragma region Constants
// Predefined typename codes. Are set to readonly and are setup during gen::init()
GEN_API extern Macro enum_underlying_macro;
GEN_API extern Code access_public;
GEN_API extern Code access_protected;
GEN_API extern Code access_private;
GEN_API extern CodeAttributes attrib_api_export;
GEN_API extern CodeAttributes attrib_api_import;
GEN_API extern Code module_global_fragment;
GEN_API extern Code module_private_fragment;
GEN_API extern Code fmt_newline;
GEN_API extern CodePragma pragma_once;
GEN_API extern CodeParams param_varadic;
GEN_API extern CodePreprocessCond preprocess_else;
GEN_API extern CodePreprocessCond preprocess_endif;
GEN_API extern CodeSpecifiers spec_const;
GEN_API extern CodeSpecifiers spec_consteval;
GEN_API extern CodeSpecifiers spec_constexpr;
GEN_API extern CodeSpecifiers spec_constinit;
GEN_API extern CodeSpecifiers spec_extern_linkage;
GEN_API extern CodeSpecifiers spec_final;
GEN_API extern CodeSpecifiers spec_forceinline;
GEN_API extern CodeSpecifiers spec_global;
GEN_API extern CodeSpecifiers spec_inline;
GEN_API extern CodeSpecifiers spec_internal_linkage;
GEN_API extern CodeSpecifiers spec_local_persist;
GEN_API extern CodeSpecifiers spec_mutable;
GEN_API extern CodeSpecifiers spec_neverinline;
GEN_API extern CodeSpecifiers spec_noexcept;
GEN_API extern CodeSpecifiers spec_override;
GEN_API extern CodeSpecifiers spec_ptr;
GEN_API extern CodeSpecifiers spec_pure;
GEN_API extern CodeSpecifiers spec_ref;
GEN_API extern CodeSpecifiers spec_register;
GEN_API extern CodeSpecifiers spec_rvalue;
GEN_API extern CodeSpecifiers spec_static_member;
GEN_API extern CodeSpecifiers spec_thread_local;
GEN_API extern CodeSpecifiers spec_virtual;
GEN_API extern CodeSpecifiers spec_volatile;
GEN_API extern CodeTypename t_empty; // Used with varaidc parameters. (Exposing just in case its useful for another circumstance)
GEN_API extern CodeTypename t_auto;
GEN_API extern CodeTypename t_void;
GEN_API extern CodeTypename t_int;
GEN_API extern CodeTypename t_bool;
GEN_API extern CodeTypename t_char;
GEN_API extern CodeTypename t_wchar_t;
GEN_API extern CodeTypename t_class;
GEN_API extern CodeTypename t_typename;
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
GEN_API extern CodeTypename t_b32;
GEN_API extern CodeTypename t_s8;
GEN_API extern CodeTypename t_s16;
GEN_API extern CodeTypename t_s32;
GEN_API extern CodeTypename t_s64;
GEN_API extern CodeTypename t_u8;
GEN_API extern CodeTypename t_u16;
GEN_API extern CodeTypename t_u32;
GEN_API extern CodeTypename t_u64;
GEN_API extern CodeTypename t_ssize;
GEN_API extern CodeTypename t_usize;
GEN_API extern CodeTypename t_f32;
GEN_API extern CodeTypename t_f64;
#endif
#pragma endregion Constants

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "components/types.hpp" #include "components/types.hpp"
#endif #endif
@ -7,14 +7,14 @@
#pragma region generated code inline implementation #pragma region generated code inline implementation
inline Code& Code::operator=( Code other ) inline Code& Code::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -23,14 +23,14 @@ inline Code::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline CodeBody& CodeBody::operator=( Code other ) inline CodeBody& CodeBody::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -39,14 +39,14 @@ inline CodeBody::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline CodeAttributes& CodeAttributes::operator=( Code other ) inline CodeAttributes& CodeAttributes::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -57,27 +57,27 @@ inline CodeAttributes::operator bool()
inline CodeAttributes::operator Code() inline CodeAttributes::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Attributes* CodeAttributes::operator->() inline AST_Attributes* CodeAttributes::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeComment& CodeComment::operator=( Code other ) inline CodeComment& CodeComment::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -88,27 +88,27 @@ inline CodeComment::operator bool()
inline CodeComment::operator Code() inline CodeComment::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Comment* CodeComment::operator->() inline AST_Comment* CodeComment::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeConstructor& CodeConstructor::operator=( Code other ) inline CodeConstructor& CodeConstructor::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -119,27 +119,27 @@ inline CodeConstructor::operator bool()
inline CodeConstructor::operator Code() inline CodeConstructor::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Constructor* CodeConstructor::operator->() inline AST_Constructor* CodeConstructor::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeClass& CodeClass::operator=( Code other ) inline CodeClass& CodeClass::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -148,14 +148,14 @@ inline CodeClass::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline CodeDefine& CodeDefine::operator=( Code other ) inline CodeDefine& CodeDefine::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -166,27 +166,27 @@ inline CodeDefine::operator bool()
inline CodeDefine::operator Code() inline CodeDefine::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Define* CodeDefine::operator->() inline AST_Define* CodeDefine::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeDefineParams& CodeDefineParams::operator=( Code other ) inline CodeDefineParams& CodeDefineParams::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -195,14 +195,14 @@ inline CodeDefineParams::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline CodeDestructor& CodeDestructor::operator=( Code other ) inline CodeDestructor& CodeDestructor::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -213,27 +213,27 @@ inline CodeDestructor::operator bool()
inline CodeDestructor::operator Code() inline CodeDestructor::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Destructor* CodeDestructor::operator->() inline AST_Destructor* CodeDestructor::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeEnum& CodeEnum::operator=( Code other ) inline CodeEnum& CodeEnum::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -244,27 +244,27 @@ inline CodeEnum::operator bool()
inline CodeEnum::operator Code() inline CodeEnum::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Enum* CodeEnum::operator->() inline AST_Enum* CodeEnum::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeExec& CodeExec::operator=( Code other ) inline CodeExec& CodeExec::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -275,27 +275,27 @@ inline CodeExec::operator bool()
inline CodeExec::operator Code() inline CodeExec::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Exec* CodeExec::operator->() inline AST_Exec* CodeExec::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeExtern& CodeExtern::operator=( Code other ) inline CodeExtern& CodeExtern::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -306,27 +306,27 @@ inline CodeExtern::operator bool()
inline CodeExtern::operator Code() inline CodeExtern::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Extern* CodeExtern::operator->() inline AST_Extern* CodeExtern::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeFriend& CodeFriend::operator=( Code other ) inline CodeFriend& CodeFriend::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -337,27 +337,27 @@ inline CodeFriend::operator bool()
inline CodeFriend::operator Code() inline CodeFriend::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Friend* CodeFriend::operator->() inline AST_Friend* CodeFriend::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeFn& CodeFn::operator=( Code other ) inline CodeFn& CodeFn::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -368,27 +368,27 @@ inline CodeFn::operator bool()
inline CodeFn::operator Code() inline CodeFn::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Fn* CodeFn::operator->() inline AST_Fn* CodeFn::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeInclude& CodeInclude::operator=( Code other ) inline CodeInclude& CodeInclude::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -399,27 +399,27 @@ inline CodeInclude::operator bool()
inline CodeInclude::operator Code() inline CodeInclude::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Include* CodeInclude::operator->() inline AST_Include* CodeInclude::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeModule& CodeModule::operator=( Code other ) inline CodeModule& CodeModule::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -430,27 +430,27 @@ inline CodeModule::operator bool()
inline CodeModule::operator Code() inline CodeModule::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Module* CodeModule::operator->() inline AST_Module* CodeModule::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeNS& CodeNS::operator=( Code other ) inline CodeNS& CodeNS::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -461,27 +461,27 @@ inline CodeNS::operator bool()
inline CodeNS::operator Code() inline CodeNS::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_NS* CodeNS::operator->() inline AST_NS* CodeNS::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeOperator& CodeOperator::operator=( Code other ) inline CodeOperator& CodeOperator::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -492,27 +492,27 @@ inline CodeOperator::operator bool()
inline CodeOperator::operator Code() inline CodeOperator::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Operator* CodeOperator::operator->() inline AST_Operator* CodeOperator::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeOpCast& CodeOpCast::operator=( Code other ) inline CodeOpCast& CodeOpCast::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -523,27 +523,27 @@ inline CodeOpCast::operator bool()
inline CodeOpCast::operator Code() inline CodeOpCast::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_OpCast* CodeOpCast::operator->() inline AST_OpCast* CodeOpCast::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeParams& CodeParams::operator=( Code other ) inline CodeParams& CodeParams::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -552,14 +552,14 @@ inline CodeParams::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline CodePragma& CodePragma::operator=( Code other ) inline CodePragma& CodePragma::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -570,27 +570,27 @@ inline CodePragma::operator bool()
inline CodePragma::operator Code() inline CodePragma::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Pragma* CodePragma::operator->() inline AST_Pragma* CodePragma::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodePreprocessCond& CodePreprocessCond::operator=( Code other ) inline CodePreprocessCond& CodePreprocessCond::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -601,27 +601,27 @@ inline CodePreprocessCond::operator bool()
inline CodePreprocessCond::operator Code() inline CodePreprocessCond::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_PreprocessCond* CodePreprocessCond::operator->() inline AST_PreprocessCond* CodePreprocessCond::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeSpecifiers& CodeSpecifiers::operator=( Code other ) inline CodeSpecifiers& CodeSpecifiers::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -630,14 +630,14 @@ inline CodeSpecifiers::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline CodeStruct& CodeStruct::operator=( Code other ) inline CodeStruct& CodeStruct::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -646,14 +646,14 @@ inline CodeStruct::operator bool()
return ast != nullptr; return ast != nullptr;
} }
inline CodeTemplate& CodeTemplate::operator=( Code other ) inline CodeTemplate& CodeTemplate::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -664,27 +664,27 @@ inline CodeTemplate::operator bool()
inline CodeTemplate::operator Code() inline CodeTemplate::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Template* CodeTemplate::operator->() inline AST_Template* CodeTemplate::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeTypename& CodeTypename::operator=( Code other ) inline CodeTypename& CodeTypename::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -695,27 +695,27 @@ inline CodeTypename::operator bool()
inline CodeTypename::operator Code() inline CodeTypename::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Typename* CodeTypename::operator->() inline AST_Typename* CodeTypename::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeTypedef& CodeTypedef::operator=( Code other ) inline CodeTypedef& CodeTypedef::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -726,27 +726,27 @@ inline CodeTypedef::operator bool()
inline CodeTypedef::operator Code() inline CodeTypedef::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Typedef* CodeTypedef::operator->() inline AST_Typedef* CodeTypedef::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeUnion& CodeUnion::operator=( Code other ) inline CodeUnion& CodeUnion::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -757,27 +757,27 @@ inline CodeUnion::operator bool()
inline CodeUnion::operator Code() inline CodeUnion::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Union* CodeUnion::operator->() inline AST_Union* CodeUnion::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeUsing& CodeUsing::operator=( Code other ) inline CodeUsing& CodeUsing::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -788,27 +788,27 @@ inline CodeUsing::operator bool()
inline CodeUsing::operator Code() inline CodeUsing::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Using* CodeUsing::operator->() inline AST_Using* CodeUsing::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;
} }
inline CodeVar& CodeVar::operator=( Code other ) inline CodeVar& CodeVar::operator=(Code other)
{ {
if ( other.ast != nullptr && other->Parent != nullptr ) if (other.ast != nullptr && other->Parent != nullptr)
{ {
ast = rcast( decltype( ast ), code_duplicate( other ).ast ); ast = rcast(decltype(ast), code_duplicate(other).ast);
ast->Parent = { nullptr }; ast->Parent = { nullptr };
} }
ast = rcast( decltype( ast ), other.ast ); ast = rcast(decltype(ast), other.ast);
return *this; return *this;
} }
@ -819,14 +819,14 @@ inline CodeVar::operator bool()
inline CodeVar::operator Code() inline CodeVar::operator Code()
{ {
return *rcast( Code*, this ); return *rcast(Code*, this);
} }
inline AST_Var* CodeVar::operator->() inline AST_Var* CodeVar::operator->()
{ {
if ( ast == nullptr ) if (ast == nullptr)
{ {
log_failure( "Attempt to dereference a nullptr!\n" ); log_failure("Attempt to dereference a nullptr!\n");
return nullptr; return nullptr;
} }
return ast; return ast;

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "components/types.hpp" #include "components/types.hpp"
#endif #endif
@ -73,150 +73,150 @@ enum CodeType : u32
CT_UnderlyingType = GEN_U32_MAX CT_UnderlyingType = GEN_U32_MAX
}; };
inline Str codetype_to_str( CodeType type ) inline Str codetype_to_str(CodeType type)
{ {
local_persist Str lookup[] = { local_persist Str lookup[] = {
{ "Invalid", sizeof( "Invalid" ) - 1 }, { "Invalid", sizeof("Invalid") - 1 },
{ "Untyped", sizeof( "Untyped" ) - 1 }, { "Untyped", sizeof("Untyped") - 1 },
{ "NewLine", sizeof( "NewLine" ) - 1 }, { "NewLine", sizeof("NewLine") - 1 },
{ "Comment", sizeof( "Comment" ) - 1 }, { "Comment", sizeof("Comment") - 1 },
{ "Access_Private", sizeof( "Access_Private" ) - 1 }, { "Access_Private", sizeof("Access_Private") - 1 },
{ "Access_Protected", sizeof( "Access_Protected" ) - 1 }, { "Access_Protected", sizeof("Access_Protected") - 1 },
{ "Access_Public", sizeof( "Access_Public" ) - 1 }, { "Access_Public", sizeof("Access_Public") - 1 },
{ "PlatformAttributes", sizeof( "PlatformAttributes" ) - 1 }, { "PlatformAttributes", sizeof("PlatformAttributes") - 1 },
{ "Class", sizeof( "Class" ) - 1 }, { "Class", sizeof("Class") - 1 },
{ "Class_Fwd", sizeof( "Class_Fwd" ) - 1 }, { "Class_Fwd", sizeof("Class_Fwd") - 1 },
{ "Class_Body", sizeof( "Class_Body" ) - 1 }, { "Class_Body", sizeof("Class_Body") - 1 },
{ "Constructor", sizeof( "Constructor" ) - 1 }, { "Constructor", sizeof("Constructor") - 1 },
{ "Constructor_Fwd", sizeof( "Constructor_Fwd" ) - 1 }, { "Constructor_Fwd", sizeof("Constructor_Fwd") - 1 },
{ "Destructor", sizeof( "Destructor" ) - 1 }, { "Destructor", sizeof("Destructor") - 1 },
{ "Destructor_Fwd", sizeof( "Destructor_Fwd" ) - 1 }, { "Destructor_Fwd", sizeof("Destructor_Fwd") - 1 },
{ "Enum", sizeof( "Enum" ) - 1 }, { "Enum", sizeof("Enum") - 1 },
{ "Enum_Fwd", sizeof( "Enum_Fwd" ) - 1 }, { "Enum_Fwd", sizeof("Enum_Fwd") - 1 },
{ "Enum_Body", sizeof( "Enum_Body" ) - 1 }, { "Enum_Body", sizeof("Enum_Body") - 1 },
{ "Enum_Class", sizeof( "Enum_Class" ) - 1 }, { "Enum_Class", sizeof("Enum_Class") - 1 },
{ "Enum_Class_Fwd", sizeof( "Enum_Class_Fwd" ) - 1 }, { "Enum_Class_Fwd", sizeof("Enum_Class_Fwd") - 1 },
{ "Execution", sizeof( "Execution" ) - 1 }, { "Execution", sizeof("Execution") - 1 },
{ "Export_Body", sizeof( "Export_Body" ) - 1 }, { "Export_Body", sizeof("Export_Body") - 1 },
{ "Extern_Linkage", sizeof( "Extern_Linkage" ) - 1 }, { "Extern_Linkage", sizeof("Extern_Linkage") - 1 },
{ "Extern_Linkage_Body", sizeof( "Extern_Linkage_Body" ) - 1 }, { "Extern_Linkage_Body", sizeof("Extern_Linkage_Body") - 1 },
{ "Friend", sizeof( "Friend" ) - 1 }, { "Friend", sizeof("Friend") - 1 },
{ "Function", sizeof( "Function" ) - 1 }, { "Function", sizeof("Function") - 1 },
{ "Function_Fwd", sizeof( "Function_Fwd" ) - 1 }, { "Function_Fwd", sizeof("Function_Fwd") - 1 },
{ "Function_Body", sizeof( "Function_Body" ) - 1 }, { "Function_Body", sizeof("Function_Body") - 1 },
{ "Global_Body", sizeof( "Global_Body" ) - 1 }, { "Global_Body", sizeof("Global_Body") - 1 },
{ "Module", sizeof( "Module" ) - 1 }, { "Module", sizeof("Module") - 1 },
{ "Namespace", sizeof( "Namespace" ) - 1 }, { "Namespace", sizeof("Namespace") - 1 },
{ "Namespace_Body", sizeof( "Namespace_Body" ) - 1 }, { "Namespace_Body", sizeof("Namespace_Body") - 1 },
{ "Operator", sizeof( "Operator" ) - 1 }, { "Operator", sizeof("Operator") - 1 },
{ "Operator_Fwd", sizeof( "Operator_Fwd" ) - 1 }, { "Operator_Fwd", sizeof("Operator_Fwd") - 1 },
{ "Operator_Member", sizeof( "Operator_Member" ) - 1 }, { "Operator_Member", sizeof("Operator_Member") - 1 },
{ "Operator_Member_Fwd", sizeof( "Operator_Member_Fwd" ) - 1 }, { "Operator_Member_Fwd", sizeof("Operator_Member_Fwd") - 1 },
{ "Operator_Cast", sizeof( "Operator_Cast" ) - 1 }, { "Operator_Cast", sizeof("Operator_Cast") - 1 },
{ "Operator_Cast_Fwd", sizeof( "Operator_Cast_Fwd" ) - 1 }, { "Operator_Cast_Fwd", sizeof("Operator_Cast_Fwd") - 1 },
{ "Parameters", sizeof( "Parameters" ) - 1 }, { "Parameters", sizeof("Parameters") - 1 },
{ "Parameters_Define", sizeof( "Parameters_Define" ) - 1 }, { "Parameters_Define", sizeof("Parameters_Define") - 1 },
{ "Preprocess_Define", sizeof( "Preprocess_Define" ) - 1 }, { "Preprocess_Define", sizeof("Preprocess_Define") - 1 },
{ "Preprocess_Include", sizeof( "Preprocess_Include" ) - 1 }, { "Preprocess_Include", sizeof("Preprocess_Include") - 1 },
{ "Preprocess_If", sizeof( "Preprocess_If" ) - 1 }, { "Preprocess_If", sizeof("Preprocess_If") - 1 },
{ "Preprocess_IfDef", sizeof( "Preprocess_IfDef" ) - 1 }, { "Preprocess_IfDef", sizeof("Preprocess_IfDef") - 1 },
{ "Preprocess_IfNotDef", sizeof( "Preprocess_IfNotDef" ) - 1 }, { "Preprocess_IfNotDef", sizeof("Preprocess_IfNotDef") - 1 },
{ "Preprocess_ElIf", sizeof( "Preprocess_ElIf" ) - 1 }, { "Preprocess_ElIf", sizeof("Preprocess_ElIf") - 1 },
{ "Preprocess_Else", sizeof( "Preprocess_Else" ) - 1 }, { "Preprocess_Else", sizeof("Preprocess_Else") - 1 },
{ "Preprocess_EndIf", sizeof( "Preprocess_EndIf" ) - 1 }, { "Preprocess_EndIf", sizeof("Preprocess_EndIf") - 1 },
{ "Preprocess_Pragma", sizeof( "Preprocess_Pragma" ) - 1 }, { "Preprocess_Pragma", sizeof("Preprocess_Pragma") - 1 },
{ "Specifiers", sizeof( "Specifiers" ) - 1 }, { "Specifiers", sizeof("Specifiers") - 1 },
{ "Struct", sizeof( "Struct" ) - 1 }, { "Struct", sizeof("Struct") - 1 },
{ "Struct_Fwd", sizeof( "Struct_Fwd" ) - 1 }, { "Struct_Fwd", sizeof("Struct_Fwd") - 1 },
{ "Struct_Body", sizeof( "Struct_Body" ) - 1 }, { "Struct_Body", sizeof("Struct_Body") - 1 },
{ "Template", sizeof( "Template" ) - 1 }, { "Template", sizeof("Template") - 1 },
{ "Typedef", sizeof( "Typedef" ) - 1 }, { "Typedef", sizeof("Typedef") - 1 },
{ "Typename", sizeof( "Typename" ) - 1 }, { "Typename", sizeof("Typename") - 1 },
{ "Union", sizeof( "Union" ) - 1 }, { "Union", sizeof("Union") - 1 },
{ "Union_Fwd", sizeof( "Union_Fwd" ) - 1 }, { "Union_Fwd", sizeof("Union_Fwd") - 1 },
{ "Union_Body", sizeof( "Union_Body" ) - 1 }, { "Union_Body", sizeof("Union_Body") - 1 },
{ "Using", sizeof( "Using" ) - 1 }, { "Using", sizeof("Using") - 1 },
{ "Using_Namespace", sizeof( "Using_Namespace" ) - 1 }, { "Using_Namespace", sizeof("Using_Namespace") - 1 },
{ "Variable", sizeof( "Variable" ) - 1 }, { "Variable", sizeof("Variable") - 1 },
}; };
return lookup[type]; return lookup[type];
} }
inline Str codetype_to_keyword_str( CodeType type ) inline Str codetype_to_keyword_str(CodeType type)
{ {
local_persist Str lookup[] = { local_persist Str lookup[] = {
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "//", sizeof( "//" ) - 1 }, { "//", sizeof("//") - 1 },
{ "private", sizeof( "private" ) - 1 }, { "private", sizeof("private") - 1 },
{ "protected", sizeof( "protected" ) - 1 }, { "protected", sizeof("protected") - 1 },
{ "public", sizeof( "public" ) - 1 }, { "public", sizeof("public") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "class", sizeof( "class" ) - 1 }, { "class", sizeof("class") - 1 },
{ "clsss", sizeof( "clsss" ) - 1 }, { "clsss", sizeof("clsss") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "enum", sizeof( "enum" ) - 1 }, { "enum", sizeof("enum") - 1 },
{ "enum", sizeof( "enum" ) - 1 }, { "enum", sizeof("enum") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "enum class", sizeof( "enum class" ) - 1 }, { "enum class", sizeof("enum class") - 1 },
{ "enum class", sizeof( "enum class" ) - 1 }, { "enum class", sizeof("enum class") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "extern", sizeof( "extern" ) - 1 }, { "extern", sizeof("extern") - 1 },
{ "extern", sizeof( "extern" ) - 1 }, { "extern", sizeof("extern") - 1 },
{ "friend", sizeof( "friend" ) - 1 }, { "friend", sizeof("friend") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "module", sizeof( "module" ) - 1 }, { "module", sizeof("module") - 1 },
{ "namespace", sizeof( "namespace" ) - 1 }, { "namespace", sizeof("namespace") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "operator", sizeof( "operator" ) - 1 }, { "operator", sizeof("operator") - 1 },
{ "operator", sizeof( "operator" ) - 1 }, { "operator", sizeof("operator") - 1 },
{ "operator", sizeof( "operator" ) - 1 }, { "operator", sizeof("operator") - 1 },
{ "operator", sizeof( "operator" ) - 1 }, { "operator", sizeof("operator") - 1 },
{ "operator", sizeof( "operator" ) - 1 }, { "operator", sizeof("operator") - 1 },
{ "operator", sizeof( "operator" ) - 1 }, { "operator", sizeof("operator") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "define", sizeof( "define" ) - 1 }, { "define", sizeof("define") - 1 },
{ "include", sizeof( "include" ) - 1 }, { "include", sizeof("include") - 1 },
{ "if", sizeof( "if" ) - 1 }, { "if", sizeof("if") - 1 },
{ "ifdef", sizeof( "ifdef" ) - 1 }, { "ifdef", sizeof("ifdef") - 1 },
{ "ifndef", sizeof( "ifndef" ) - 1 }, { "ifndef", sizeof("ifndef") - 1 },
{ "elif", sizeof( "elif" ) - 1 }, { "elif", sizeof("elif") - 1 },
{ "else", sizeof( "else" ) - 1 }, { "else", sizeof("else") - 1 },
{ "endif", sizeof( "endif" ) - 1 }, { "endif", sizeof("endif") - 1 },
{ "pragma", sizeof( "pragma" ) - 1 }, { "pragma", sizeof("pragma") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "struct", sizeof( "struct" ) - 1 }, { "struct", sizeof("struct") - 1 },
{ "struct", sizeof( "struct" ) - 1 }, { "struct", sizeof("struct") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "template", sizeof( "template" ) - 1 }, { "template", sizeof("template") - 1 },
{ "typedef", sizeof( "typedef" ) - 1 }, { "typedef", sizeof("typedef") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "union", sizeof( "union" ) - 1 }, { "union", sizeof("union") - 1 },
{ "union", sizeof( "union" ) - 1 }, { "union", sizeof("union") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
{ "using", sizeof( "using" ) - 1 }, { "using", sizeof("using") - 1 },
{ "using namespace", sizeof( "using namespace" ) - 1 }, { "using namespace", sizeof("using namespace") - 1 },
{ "__NA__", sizeof( "__NA__" ) - 1 }, { "__NA__", sizeof("__NA__") - 1 },
}; };
return lookup[type]; return lookup[type];
} }
forceinline Str to_str( CodeType type ) forceinline Str to_str(CodeType type)
{ {
return codetype_to_str( type ); return codetype_to_str(type);
} }
forceinline Str to_keyword_str( CodeType type ) forceinline Str to_keyword_str(CodeType type)
{ {
return codetype_to_keyword_str( type ); return codetype_to_keyword_str(type);
} }

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "components/types.hpp" #include "components/types.hpp"
#endif #endif
@ -58,61 +58,61 @@ enum Operator : u32
Op_UnderlyingType = 0xffffffffu Op_UnderlyingType = 0xffffffffu
}; };
inline Str operator_to_str( Operator op ) inline Str operator_to_str(Operator op)
{ {
local_persist Str lookup[] = { local_persist Str lookup[] = {
{ "INVALID", sizeof( "INVALID" ) - 1 }, { "INVALID", sizeof("INVALID") - 1 },
{ "=", sizeof( "=" ) - 1 }, { "=", sizeof("=") - 1 },
{ "+=", sizeof( "+=" ) - 1 }, { "+=", sizeof("+=") - 1 },
{ "-=", sizeof( "-=" ) - 1 }, { "-=", sizeof("-=") - 1 },
{ "*=", sizeof( "*=" ) - 1 }, { "*=", sizeof("*=") - 1 },
{ "/=", sizeof( "/=" ) - 1 }, { "/=", sizeof("/=") - 1 },
{ "%=", sizeof( "%=" ) - 1 }, { "%=", sizeof("%=") - 1 },
{ "&=", sizeof( "&=" ) - 1 }, { "&=", sizeof("&=") - 1 },
{ "|=", sizeof( "|=" ) - 1 }, { "|=", sizeof("|=") - 1 },
{ "^=", sizeof( "^=" ) - 1 }, { "^=", sizeof("^=") - 1 },
{ "<<=", sizeof( "<<=" ) - 1 }, { "<<=", sizeof("<<=") - 1 },
{ ">>=", sizeof( ">>=" ) - 1 }, { ">>=", sizeof(">>=") - 1 },
{ "++", sizeof( "++" ) - 1 }, { "++", sizeof("++") - 1 },
{ "--", sizeof( "--" ) - 1 }, { "--", sizeof("--") - 1 },
{ "+", sizeof( "+" ) - 1 }, { "+", sizeof("+") - 1 },
{ "-", sizeof( "-" ) - 1 }, { "-", sizeof("-") - 1 },
{ "!", sizeof( "!" ) - 1 }, { "!", sizeof("!") - 1 },
{ "+", sizeof( "+" ) - 1 }, { "+", sizeof("+") - 1 },
{ "-", sizeof( "-" ) - 1 }, { "-", sizeof("-") - 1 },
{ "*", sizeof( "*" ) - 1 }, { "*", sizeof("*") - 1 },
{ "/", sizeof( "/" ) - 1 }, { "/", sizeof("/") - 1 },
{ "%", sizeof( "%" ) - 1 }, { "%", sizeof("%") - 1 },
{ "~", sizeof( "~" ) - 1 }, { "~", sizeof("~") - 1 },
{ "&", sizeof( "&" ) - 1 }, { "&", sizeof("&") - 1 },
{ "|", sizeof( "|" ) - 1 }, { "|", sizeof("|") - 1 },
{ "^", sizeof( "^" ) - 1 }, { "^", sizeof("^") - 1 },
{ "<<", sizeof( "<<" ) - 1 }, { "<<", sizeof("<<") - 1 },
{ ">>", sizeof( ">>" ) - 1 }, { ">>", sizeof(">>") - 1 },
{ "&&", sizeof( "&&" ) - 1 }, { "&&", sizeof("&&") - 1 },
{ "||", sizeof( "||" ) - 1 }, { "||", sizeof("||") - 1 },
{ "==", sizeof( "==" ) - 1 }, { "==", sizeof("==") - 1 },
{ "!=", sizeof( "!=" ) - 1 }, { "!=", sizeof("!=") - 1 },
{ "<", sizeof( "<" ) - 1 }, { "<", sizeof("<") - 1 },
{ ">", sizeof( ">" ) - 1 }, { ">", sizeof(">") - 1 },
{ "<=", sizeof( "<=" ) - 1 }, { "<=", sizeof("<=") - 1 },
{ ">=", sizeof( ">=" ) - 1 }, { ">=", sizeof(">=") - 1 },
{ "[]", sizeof( "[]" ) - 1 }, { "[]", sizeof("[]") - 1 },
{ "*", sizeof( "*" ) - 1 }, { "*", sizeof("*") - 1 },
{ "&", sizeof( "&" ) - 1 }, { "&", sizeof("&") - 1 },
{ "->", sizeof( "->" ) - 1 }, { "->", sizeof("->") - 1 },
{ "->*", sizeof( "->*" ) - 1 }, { "->*", sizeof("->*") - 1 },
{ "()", sizeof( "()" ) - 1 }, { "()", sizeof("()") - 1 },
{ ",", sizeof( "," ) - 1 }, { ",", sizeof(",") - 1 },
{ "new", sizeof( "new" ) - 1 }, { "new", sizeof("new") - 1 },
{ "new[]", sizeof( "new[]" ) - 1 }, { "new[]", sizeof("new[]") - 1 },
{ "delete", sizeof( "delete" ) - 1 }, { "delete", sizeof("delete") - 1 },
{ "delete[]", sizeof( "delete[]" ) - 1 }, { "delete[]", sizeof("delete[]") - 1 },
}; };
return lookup[op]; return lookup[op];
} }
forceinline Str to_str( Operator op ) forceinline Str to_str(Operator op)
{ {
return operator_to_str( op ); return operator_to_str(op);
} }

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "components/types.hpp" #include "components/types.hpp"
#endif #endif
@ -33,89 +33,92 @@ enum Specifier : u32
Spec_NoExceptions, Spec_NoExceptions,
Spec_Override, Spec_Override,
Spec_Pure, Spec_Pure,
Spec_Delete,
Spec_Volatile, Spec_Volatile,
Spec_NumSpecifiers, Spec_NumSpecifiers,
Spec_UnderlyingType = 0xffffffffu Spec_UnderlyingType = 0xffffffffu
}; };
inline Str spec_to_str( Specifier type ) inline Str spec_to_str(Specifier type)
{ {
local_persist Str lookup[] = { local_persist Str lookup[] = {
{ "INVALID", sizeof( "INVALID" ) - 1 }, { "INVALID", sizeof("INVALID") - 1 },
{ "consteval", sizeof( "consteval" ) - 1 }, { "consteval", sizeof("consteval") - 1 },
{ "constexpr", sizeof( "constexpr" ) - 1 }, { "constexpr", sizeof("constexpr") - 1 },
{ "constinit", sizeof( "constinit" ) - 1 }, { "constinit", sizeof("constinit") - 1 },
{ "explicit", sizeof( "explicit" ) - 1 }, { "explicit", sizeof("explicit") - 1 },
{ "extern", sizeof( "extern" ) - 1 }, { "extern", sizeof("extern") - 1 },
{ "forceinline", sizeof( "forceinline" ) - 1 }, { "forceinline", sizeof("forceinline") - 1 },
{ "global", sizeof( "global" ) - 1 }, { "global", sizeof("global") - 1 },
{ "inline", sizeof( "inline" ) - 1 }, { "inline", sizeof("inline") - 1 },
{ "internal", sizeof( "internal" ) - 1 }, { "internal", sizeof("internal") - 1 },
{ "local_persist", sizeof( "local_persist" ) - 1 }, { "local_persist", sizeof("local_persist") - 1 },
{ "mutable", sizeof( "mutable" ) - 1 }, { "mutable", sizeof("mutable") - 1 },
{ "neverinline", sizeof( "neverinline" ) - 1 }, { "neverinline", sizeof("neverinline") - 1 },
{ "*", sizeof( "*" ) - 1 }, { "*", sizeof("*") - 1 },
{ "&", sizeof( "&" ) - 1 }, { "&", sizeof("&") - 1 },
{ "register", sizeof( "register" ) - 1 }, { "register", sizeof("register") - 1 },
{ "restrict", sizeof( "restrict" ) - 1 }, { "restrict", sizeof("restrict") - 1 },
{ "&&", sizeof( "&&" ) - 1 }, { "&&", sizeof("&&") - 1 },
{ "static", sizeof( "static" ) - 1 }, { "static", sizeof("static") - 1 },
{ "thread_local", sizeof( "thread_local" ) - 1 }, { "thread_local", sizeof("thread_local") - 1 },
{ "virtual", sizeof( "virtual" ) - 1 }, { "virtual", sizeof("virtual") - 1 },
{ "const", sizeof( "const" ) - 1 }, { "const", sizeof("const") - 1 },
{ "final", sizeof( "final" ) - 1 }, { "final", sizeof("final") - 1 },
{ "noexcept", sizeof( "noexcept" ) - 1 }, { "noexcept", sizeof("noexcept") - 1 },
{ "override", sizeof( "override" ) - 1 }, { "override", sizeof("override") - 1 },
{ "= 0", sizeof( "= 0" ) - 1 }, { "= 0", sizeof("= 0") - 1 },
{ "volatile", sizeof( "volatile" ) - 1 }, { "= delete", sizeof("= delete") - 1 },
{ "volatile", sizeof("volatile") - 1 },
}; };
return lookup[type]; return lookup[type];
} }
inline bool spec_is_trailing( Specifier specifier ) inline bool spec_is_trailing(Specifier specifier)
{ {
switch ( specifier ) switch (specifier)
{ {
case Spec_Const : case Spec_Const:
case Spec_Final : case Spec_Final:
case Spec_NoExceptions : case Spec_NoExceptions:
case Spec_Override : case Spec_Override:
case Spec_Pure : case Spec_Pure:
case Spec_Volatile : case Spec_Delete:
case Spec_Volatile:
return true; return true;
default : default:
return false; return false;
} }
} }
inline Specifier str_to_specifier( Str str ) inline Specifier str_to_specifier(Str str)
{ {
local_persist u32 keymap[Spec_NumSpecifiers]; local_persist u32 keymap[Spec_NumSpecifiers];
do_once_start for ( u32 index = 0; index < Spec_NumSpecifiers; index++ ) do_once_start for (u32 index = 0; index < Spec_NumSpecifiers; index++)
{ {
Str enum_str = spec_to_str( (Specifier)index ); Str enum_str = spec_to_str((Specifier)index);
keymap[index] = crc32( enum_str.Ptr, enum_str.Len ); keymap[index] = crc32(enum_str.Ptr, enum_str.Len);
} }
do_once_end u32 hash = crc32( str.Ptr, str.Len ); do_once_end u32 hash = crc32(str.Ptr, str.Len);
for ( u32 index = 0; index < Spec_NumSpecifiers; index++ ) for (u32 index = 0; index < Spec_NumSpecifiers; index++)
{ {
if ( keymap[index] == hash ) if (keymap[index] == hash)
return (Specifier)index; return (Specifier)index;
} }
return Spec_Invalid; return Spec_Invalid;
} }
forceinline Str to_str( Specifier spec ) forceinline Str to_str(Specifier spec)
{ {
return spec_to_str( spec ); return spec_to_str(spec);
} }
forceinline Specifier to_type( Str str ) forceinline Specifier to_type(Str str)
{ {
return str_to_specifier( str ); return str_to_specifier(str);
} }
forceinline bool is_trailing( Specifier specifier ) forceinline bool is_trailing(Specifier specifier)
{ {
return spec_is_trailing( specifier ); return spec_is_trailing(specifier);
} }

View File

@ -1,11 +1,11 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "components/types.hpp" #include "components/types.hpp"
#endif #endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Tok_Attribute_GEN_API, "GEN_API" ) #define GEN_DEFINE_ATTRIBUTE_TOKENS Entry(Tok_Attribute_GEN_API, "GEN_API")
enum TokType : u32 enum TokType : u32
{ {
@ -112,125 +112,125 @@ enum TokType : u32
Tok_NumTokens Tok_NumTokens
}; };
inline Str toktype_to_str( TokType type ) inline Str toktype_to_str(TokType type)
{ {
local_persist Str lookup[] = { local_persist Str lookup[] = {
{ "__invalid__", sizeof( "__invalid__" ) - 1 }, { "__invalid__", sizeof("__invalid__") - 1 },
{ "private", sizeof( "private" ) - 1 }, { "private", sizeof("private") - 1 },
{ "protected", sizeof( "protected" ) - 1 }, { "protected", sizeof("protected") - 1 },
{ "public", sizeof( "public" ) - 1 }, { "public", sizeof("public") - 1 },
{ ".", sizeof( "." ) - 1 }, { ".", sizeof(".") - 1 },
{ "::", sizeof( "::" ) - 1 }, { "::", sizeof("::") - 1 },
{ "&", sizeof( "&" ) - 1 }, { "&", sizeof("&") - 1 },
{ "&&", sizeof( "&&" ) - 1 }, { "&&", sizeof("&&") - 1 },
{ ":", sizeof( ":" ) - 1 }, { ":", sizeof(":") - 1 },
{ "[[", sizeof( "[[" ) - 1 }, { "[[", sizeof("[[") - 1 },
{ "]]", sizeof( "]]" ) - 1 }, { "]]", sizeof("]]") - 1 },
{ "{", sizeof( "{" ) - 1 }, { "{", sizeof("{") - 1 },
{ "}", sizeof( "}" ) - 1 }, { "}", sizeof("}") - 1 },
{ "[", sizeof( "[" ) - 1 }, { "[", sizeof("[") - 1 },
{ "]", sizeof( "]" ) - 1 }, { "]", sizeof("]") - 1 },
{ "(", sizeof( "(" ) - 1 }, { "(", sizeof("(") - 1 },
{ ")", sizeof( ")" ) - 1 }, { ")", sizeof(")") - 1 },
{ "__comment__", sizeof( "__comment__" ) - 1 }, { "__comment__", sizeof("__comment__") - 1 },
{ "__comment_end__", sizeof( "__comment_end__" ) - 1 }, { "__comment_end__", sizeof("__comment_end__") - 1 },
{ "__comment_start__", sizeof( "__comment_start__" ) - 1 }, { "__comment_start__", sizeof("__comment_start__") - 1 },
{ "__character__", sizeof( "__character__" ) - 1 }, { "__character__", sizeof("__character__") - 1 },
{ ",", sizeof( "," ) - 1 }, { ",", sizeof(",") - 1 },
{ "class", sizeof( "class" ) - 1 }, { "class", sizeof("class") - 1 },
{ "__attribute__", sizeof( "__attribute__" ) - 1 }, { "__attribute__", sizeof("__attribute__") - 1 },
{ "__declspec", sizeof( "__declspec" ) - 1 }, { "__declspec", sizeof("__declspec") - 1 },
{ "enum", sizeof( "enum" ) - 1 }, { "enum", sizeof("enum") - 1 },
{ "extern", sizeof( "extern" ) - 1 }, { "extern", sizeof("extern") - 1 },
{ "friend", sizeof( "friend" ) - 1 }, { "friend", sizeof("friend") - 1 },
{ "module", sizeof( "module" ) - 1 }, { "module", sizeof("module") - 1 },
{ "namespace", sizeof( "namespace" ) - 1 }, { "namespace", sizeof("namespace") - 1 },
{ "operator", sizeof( "operator" ) - 1 }, { "operator", sizeof("operator") - 1 },
{ "struct", sizeof( "struct" ) - 1 }, { "struct", sizeof("struct") - 1 },
{ "template", sizeof( "template" ) - 1 }, { "template", sizeof("template") - 1 },
{ "typedef", sizeof( "typedef" ) - 1 }, { "typedef", sizeof("typedef") - 1 },
{ "using", sizeof( "using" ) - 1 }, { "using", sizeof("using") - 1 },
{ "union", sizeof( "union" ) - 1 }, { "union", sizeof("union") - 1 },
{ "__identifier__", sizeof( "__identifier__" ) - 1 }, { "__identifier__", sizeof("__identifier__") - 1 },
{ "import", sizeof( "import" ) - 1 }, { "import", sizeof("import") - 1 },
{ "export", sizeof( "export" ) - 1 }, { "export", sizeof("export") - 1 },
{ "__new_line__", sizeof( "__new_line__" ) - 1 }, { "__new_line__", sizeof("__new_line__") - 1 },
{ "__number__", sizeof( "__number__" ) - 1 }, { "__number__", sizeof("__number__") - 1 },
{ "__operator__", sizeof( "__operator__" ) - 1 }, { "__operator__", sizeof("__operator__") - 1 },
{ "#", sizeof( "#" ) - 1 }, { "#", sizeof("#") - 1 },
{ "define", sizeof( "define" ) - 1 }, { "define", sizeof("define") - 1 },
{ "__define_param__", sizeof( "__define_param__" ) - 1 }, { "__define_param__", sizeof("__define_param__") - 1 },
{ "if", sizeof( "if" ) - 1 }, { "if", sizeof("if") - 1 },
{ "ifdef", sizeof( "ifdef" ) - 1 }, { "ifdef", sizeof("ifdef") - 1 },
{ "ifndef", sizeof( "ifndef" ) - 1 }, { "ifndef", sizeof("ifndef") - 1 },
{ "elif", sizeof( "elif" ) - 1 }, { "elif", sizeof("elif") - 1 },
{ "else", sizeof( "else" ) - 1 }, { "else", sizeof("else") - 1 },
{ "endif", sizeof( "endif" ) - 1 }, { "endif", sizeof("endif") - 1 },
{ "include", sizeof( "include" ) - 1 }, { "include", sizeof("include") - 1 },
{ "pragma", sizeof( "pragma" ) - 1 }, { "pragma", sizeof("pragma") - 1 },
{ "__macro_content__", sizeof( "__macro_content__" ) - 1 }, { "__macro_content__", sizeof("__macro_content__") - 1 },
{ "__macro_expression__", sizeof( "__macro_expression__" ) - 1 }, { "__macro_expression__", sizeof("__macro_expression__") - 1 },
{ "__macro_statment__", sizeof( "__macro_statment__" ) - 1 }, { "__macro_statment__", sizeof("__macro_statment__") - 1 },
{ "__macro_typename__", sizeof( "__macro_typename__" ) - 1 }, { "__macro_typename__", sizeof("__macro_typename__") - 1 },
{ "__unsupported__", sizeof( "__unsupported__" ) - 1 }, { "__unsupported__", sizeof("__unsupported__") - 1 },
{ "alignas", sizeof( "alignas" ) - 1 }, { "alignas", sizeof("alignas") - 1 },
{ "const", sizeof( "const" ) - 1 }, { "const", sizeof("const") - 1 },
{ "consteval", sizeof( "consteval" ) - 1 }, { "consteval", sizeof("consteval") - 1 },
{ "constexpr", sizeof( "constexpr" ) - 1 }, { "constexpr", sizeof("constexpr") - 1 },
{ "constinit", sizeof( "constinit" ) - 1 }, { "constinit", sizeof("constinit") - 1 },
{ "explicit", sizeof( "explicit" ) - 1 }, { "explicit", sizeof("explicit") - 1 },
{ "extern", sizeof( "extern" ) - 1 }, { "extern", sizeof("extern") - 1 },
{ "final", sizeof( "final" ) - 1 }, { "final", sizeof("final") - 1 },
{ "forceinline", sizeof( "forceinline" ) - 1 }, { "forceinline", sizeof("forceinline") - 1 },
{ "global", sizeof( "global" ) - 1 }, { "global", sizeof("global") - 1 },
{ "inline", sizeof( "inline" ) - 1 }, { "inline", sizeof("inline") - 1 },
{ "internal", sizeof( "internal" ) - 1 }, { "internal", sizeof("internal") - 1 },
{ "local_persist", sizeof( "local_persist" ) - 1 }, { "local_persist", sizeof("local_persist") - 1 },
{ "mutable", sizeof( "mutable" ) - 1 }, { "mutable", sizeof("mutable") - 1 },
{ "neverinline", sizeof( "neverinline" ) - 1 }, { "neverinline", sizeof("neverinline") - 1 },
{ "override", sizeof( "override" ) - 1 }, { "override", sizeof("override") - 1 },
{ "restrict", sizeof( "restrict" ) - 1 }, { "restrict", sizeof("restrict") - 1 },
{ "static", sizeof( "static" ) - 1 }, { "static", sizeof("static") - 1 },
{ "thread_local", sizeof( "thread_local" ) - 1 }, { "thread_local", sizeof("thread_local") - 1 },
{ "volatile", sizeof( "volatile" ) - 1 }, { "volatile", sizeof("volatile") - 1 },
{ "virtual", sizeof( "virtual" ) - 1 }, { "virtual", sizeof("virtual") - 1 },
{ "*", sizeof( "*" ) - 1 }, { "*", sizeof("*") - 1 },
{ ";", sizeof( ";" ) - 1 }, { ";", sizeof(";") - 1 },
{ "static_assert", sizeof( "static_assert" ) - 1 }, { "static_assert", sizeof("static_assert") - 1 },
{ "__string__", sizeof( "__string__" ) - 1 }, { "__string__", sizeof("__string__") - 1 },
{ "typename", sizeof( "typename" ) - 1 }, { "typename", sizeof("typename") - 1 },
{ "unsigned", sizeof( "unsigned" ) - 1 }, { "unsigned", sizeof("unsigned") - 1 },
{ "signed", sizeof( "signed" ) - 1 }, { "signed", sizeof("signed") - 1 },
{ "short", sizeof( "short" ) - 1 }, { "short", sizeof("short") - 1 },
{ "long", sizeof( "long" ) - 1 }, { "long", sizeof("long") - 1 },
{ "bool", sizeof( "bool" ) - 1 }, { "bool", sizeof("bool") - 1 },
{ "char", sizeof( "char" ) - 1 }, { "char", sizeof("char") - 1 },
{ "int", sizeof( "int" ) - 1 }, { "int", sizeof("int") - 1 },
{ "double", sizeof( "double" ) - 1 }, { "double", sizeof("double") - 1 },
{ "__int8", sizeof( "__int8" ) - 1 }, { "__int8", sizeof("__int8") - 1 },
{ "__int16", sizeof( "__int16" ) - 1 }, { "__int16", sizeof("__int16") - 1 },
{ "__int32", sizeof( "__int32" ) - 1 }, { "__int32", sizeof("__int32") - 1 },
{ "__int64", sizeof( "__int64" ) - 1 }, { "__int64", sizeof("__int64") - 1 },
{ "_W64", sizeof( "_W64" ) - 1 }, { "_W64", sizeof("_W64") - 1 },
{ "...", sizeof( "..." ) - 1 }, { "...", sizeof("...") - 1 },
{ "__attrib_start__", sizeof( "__attrib_start__" ) - 1 }, { "__attrib_start__", sizeof("__attrib_start__") - 1 },
{ "GEN_API", sizeof( "GEN_API" ) - 1 }, { "GEN_API", sizeof("GEN_API") - 1 },
}; };
return lookup[type]; return lookup[type];
} }
inline TokType str_to_toktype( Str str ) inline TokType str_to_toktype(Str str)
{ {
local_persist u32 keymap[Tok_NumTokens]; local_persist u32 keymap[Tok_NumTokens];
do_once_start for ( u32 index = 0; index < Tok_NumTokens; index++ ) do_once_start for (u32 index = 0; index < Tok_NumTokens; index++)
{ {
Str enum_str = toktype_to_str( (TokType)index ); Str enum_str = toktype_to_str((TokType)index);
keymap[index] = crc32( enum_str.Ptr, enum_str.Len ); keymap[index] = crc32(enum_str.Ptr, enum_str.Len);
} }
do_once_end u32 hash = crc32( str.Ptr, str.Len ); do_once_end u32 hash = crc32(str.Ptr, str.Len);
for ( u32 index = 0; index < Tok_NumTokens; index++ ) for (u32 index = 0; index < Tok_NumTokens; index++)
{ {
if ( keymap[index] == hash ) if (keymap[index] == hash)
return (TokType)index; return (TokType)index;
} }
return Tok_Invalid; return Tok_Invalid;

View File

@ -1,88 +0,0 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "inlines.hpp"
#include "gen/ast_inlines.hpp"
#endif
#pragma region Constants
extern Macro enum_underlying_macro;
extern Code access_public;
extern Code access_protected;
extern Code access_private;
extern CodeAttributes attrib_api_export;
extern CodeAttributes attrib_api_import;
extern Code module_global_fragment;
extern Code module_private_fragment;
extern Code fmt_newline;
extern CodePragma pragma_once;
extern CodeParams param_varadic;
extern CodePreprocessCond preprocess_else;
extern CodePreprocessCond preprocess_endif;
extern CodeSpecifiers spec_const;
extern CodeSpecifiers spec_consteval;
extern CodeSpecifiers spec_constexpr;
extern CodeSpecifiers spec_constinit;
extern CodeSpecifiers spec_extern_linkage;
extern CodeSpecifiers spec_final;
extern CodeSpecifiers spec_forceinline;
extern CodeSpecifiers spec_global;
extern CodeSpecifiers spec_inline;
extern CodeSpecifiers spec_internal_linkage;
extern CodeSpecifiers spec_local_persist;
extern CodeSpecifiers spec_mutable;
extern CodeSpecifiers spec_neverinline;
extern CodeSpecifiers spec_noexcept;
extern CodeSpecifiers spec_override;
extern CodeSpecifiers spec_ptr;
extern CodeSpecifiers spec_pure;
extern CodeSpecifiers spec_ref;
extern CodeSpecifiers spec_register;
extern CodeSpecifiers spec_rvalue;
extern CodeSpecifiers spec_static_member;
extern CodeSpecifiers spec_thread_local;
extern CodeSpecifiers spec_virtual;
extern CodeSpecifiers spec_volatile;
extern CodeTypename t_empty; // Used with varaidc parameters. (Exposing just in case its useful for another circumstance)
extern CodeTypename t_auto;
extern CodeTypename t_void;
extern CodeTypename t_int;
extern CodeTypename t_bool;
extern CodeTypename t_char;
extern CodeTypename t_wchar_t;
extern CodeTypename t_class;
extern CodeTypename t_typename;
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
// Predefined typename codes. Are set to readonly and are setup during gen::init()
extern Context* _ctx;
extern CodeTypename t_b32;
extern CodeTypename t_s8;
extern CodeTypename t_s16;
extern CodeTypename t_s32;
extern CodeTypename t_s64;
extern CodeTypename t_u8;
extern CodeTypename t_u16;
extern CodeTypename t_u32;
extern CodeTypename t_u64;
extern CodeTypename t_ssize;
extern CodeTypename t_usize;
extern CodeTypename t_f32;
extern CodeTypename t_f64;
#endif
#pragma endregion Constants

View File

@ -15,7 +15,7 @@
| \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l | | \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l |
| | | | | __} | | | | | | | __} | |
| l_l l_l {___/ | | l_l l_l {___/ |
! ----------------------------------------------------------------------- VERSION: v0.23-Alpha | ! ----------------------------------------------------------------------- VERSION: v0.25-Alpha |
! ============================================================================================ | ! ============================================================================================ |
! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION | ! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION |
! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL | ! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL |

View File

@ -1,8 +1,318 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "interface.hpp" #include "interface.hpp"
#endif #endif
#pragma region Serialization
inline
StrBuilder attributes_to_strbuilder(CodeAttributes attributes) {
GEN_ASSERT(attributes);
char* raw = ccast(char*, str_duplicate( attributes->Content, get_context()->Allocator_Temp ).Ptr);
StrBuilder result = { raw };
return result;
}
inline
void attributes_to_strbuilder_ref(CodeAttributes attributes, StrBuilder* result) {
GEN_ASSERT(attributes);
GEN_ASSERT(result);
strbuilder_append_str(result, attributes->Content);
}
inline
StrBuilder comment_to_strbuilder(CodeComment comment) {
GEN_ASSERT(comment);
char* raw = ccast(char*, str_duplicate( comment->Content, get_context()->Allocator_Temp ).Ptr);
StrBuilder result = { raw };
return result;
}
inline
void body_to_strbuilder_ref( CodeBody body, StrBuilder* result )
{
GEN_ASSERT(body != nullptr);
GEN_ASSERT(result != nullptr);
Code curr = body->Front;
s32 left = body->NumEntries;
while ( left -- )
{
code_to_strbuilder_ref(curr, result);
// strbuilder_append_fmt( result, "%SB", code_to_strbuilder(curr) );
++curr;
}
}
inline
void comment_to_strbuilder_ref(CodeComment comment, StrBuilder* result) {
GEN_ASSERT(comment);
GEN_ASSERT(result);
strbuilder_append_str(result, comment->Content);
}
inline
StrBuilder define_to_strbuilder(CodeDefine define)
{
GEN_ASSERT(define);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 );
define_to_strbuilder_ref(define, & result);
return result;
}
inline
StrBuilder define_params_to_strbuilder(CodeDefineParams params)
{
GEN_ASSERT(params);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 );
define_params_to_strbuilder_ref( params, & result );
return result;
}
inline
StrBuilder exec_to_strbuilder(CodeExec exec)
{
GEN_ASSERT(exec);
char* raw = ccast(char*, str_duplicate( exec->Content, _ctx->Allocator_Temp ).Ptr);
StrBuilder result = { raw };
return result;
}
inline
void exec_to_strbuilder_ref(CodeExec exec, StrBuilder* result) {
GEN_ASSERT(exec);
GEN_ASSERT(result);
strbuilder_append_str(result, exec->Content);
}
inline
void extern_to_strbuilder(CodeExtern self, StrBuilder* result )
{
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( self->Body )
strbuilder_append_fmt( result, "extern \"%S\"\n{\n%SB\n}\n", self->Name, body_to_strbuilder(self->Body) );
else
strbuilder_append_fmt( result, "extern \"%S\"\n{}\n", self->Name );
}
inline
StrBuilder friend_to_strbuilder(CodeFriend self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 256 );
friend_to_strbuilder_ref( self, & result );
return result;
}
inline
void friend_to_strbuilder_ref(CodeFriend self, StrBuilder* result )
{
GEN_ASSERT(self);
GEN_ASSERT(result);
strbuilder_append_fmt( result, "friend %SB", code_to_strbuilder(self->Declaration) );
if ( self->Declaration->Type != CT_Function && self->Declaration->Type != CT_Operator && (* result)[ strbuilder_length(* result) - 1 ] != ';' )
{
strbuilder_append_str( result, txt(";") );
}
if ( self->InlineCmt )
strbuilder_append_fmt( result, " %S", self->InlineCmt->Content );
else
strbuilder_append_str( result, txt("\n"));
}
inline
StrBuilder include_to_strbuilder(CodeInclude include)
{
GEN_ASSERT(include);
return strbuilder_fmt_buf( _ctx->Allocator_Temp, "#include %S\n", include->Content );
}
inline
void include_to_strbuilder_ref( CodeInclude include, StrBuilder* result )
{
GEN_ASSERT(include);
GEN_ASSERT(result);
strbuilder_append_fmt( result, "#include %S\n", include->Content );
}
inline
StrBuilder module_to_strbuilder(CodeModule self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 64 );
module_to_strbuilder_ref( self, & result );
return result;
}
inline
StrBuilder namespace_to_strbuilder(CodeNS self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 512 );
namespace_to_strbuilder_ref( self, & result );
return result;
}
inline
void namespace_to_strbuilder_ref(CodeNS self, StrBuilder* result )
{
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( bitfield_is_set( u32, self->ModuleFlags, ModuleFlag_Export ))
strbuilder_append_str( result, txt("export ") );
strbuilder_append_fmt( result, "namespace %S\n{\n%SB\n}\n", self->Name, body_to_strbuilder(self->Body) );
}
inline
StrBuilder params_to_strbuilder(CodeParams self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 );
params_to_strbuilder_ref( self, & 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
void preprocess_to_strbuilder_if(CodePreprocessCond cond, StrBuilder* result )
{
GEN_ASSERT(cond);
GEN_ASSERT(result);
strbuilder_append_fmt( result, "#if %S", cond->Content );
}
inline
void preprocess_to_strbuilder_ifdef(CodePreprocessCond cond, StrBuilder* result )
{
GEN_ASSERT(cond);
GEN_ASSERT(result);
strbuilder_append_fmt( result, "#ifdef %S\n", cond->Content );
}
inline
void preprocess_to_strbuilder_ifndef(CodePreprocessCond cond, StrBuilder* result )
{
GEN_ASSERT(cond);
GEN_ASSERT(result);
strbuilder_append_fmt( result, "#ifndef %S", cond->Content );
}
inline
void preprocess_to_strbuilder_elif(CodePreprocessCond cond, StrBuilder* result )
{
GEN_ASSERT(cond);
GEN_ASSERT(result);
strbuilder_append_fmt( result, "#elif %S\n", cond->Content );
}
inline
void preprocess_to_strbuilder_else(CodePreprocessCond cond, StrBuilder* result )
{
GEN_ASSERT(cond);
GEN_ASSERT(result);
strbuilder_append_str( result, txt("#else\n") );
}
inline
void preprocess_to_strbuilder_endif(CodePreprocessCond cond, StrBuilder* result )
{
GEN_ASSERT(cond);
GEN_ASSERT(result);
strbuilder_append_str( result, txt("#endif\n") );
}
inline
StrBuilder specifiers_to_strbuilder(CodeSpecifiers self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 64 );
specifiers_to_strbuilder_ref( self, & result );
return result;
}
inline
StrBuilder template_to_strbuilder(CodeTemplate self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 1024 );
template_to_strbuilder_ref( self, & result );
return result;
}
inline
StrBuilder typedef_to_strbuilder(CodeTypedef self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 );
typedef_to_strbuilder_ref( self, & result );
return result;
}
inline
StrBuilder typename_to_strbuilder(CodeTypename self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_str( _ctx->Allocator_Temp, txt("") );
typename_to_strbuilder_ref( self, & result );
return result;
}
inline
StrBuilder using_to_strbuilder(CodeUsing self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( _ctx->Allocator_Temp, 128 );
switch ( self->Type )
{
case CT_Using:
using_to_strbuilder_ref( self, & result );
break;
case CT_Using_Namespace:
using_to_strbuilder_ns( self, & result );
break;
}
return result;
}
inline
void using_to_strbuilder_ns(CodeUsing self, StrBuilder* result )
{
GEN_ASSERT(self);
GEN_ASSERT(result);
if ( self->InlineCmt )
strbuilder_append_fmt( result, "using namespace $S; %S", self->Name, self->InlineCmt->Content );
else
strbuilder_append_fmt( result, "using namespace %S;\n", self->Name );
}
inline
StrBuilder var_to_strbuilder(CodeVar self)
{
GEN_ASSERT(self);
StrBuilder result = strbuilder_make_reserve( get_context()->Allocator_Temp, 256 );
var_to_strbuilder_ref( self, & result );
return result;
}
#pragma endregion Serialization
#pragma region Code #pragma region Code
inline inline
void code_append( Code self, Code other ) void code_append( Code self, Code other )
@ -74,7 +384,7 @@ bool code_is_valid(Code self)
return self != nullptr && self->Type != CT_Invalid; return self != nullptr && self->Type != CT_Invalid;
} }
forceinline forceinline
bool code_has_entries(AST* self) bool code_has_entries(Code self)
{ {
GEN_ASSERT(self); GEN_ASSERT(self);
return self->NumEntries > 0; return self->NumEntries > 0;
@ -169,12 +479,12 @@ void class_add_interface( CodeClass self, CodeTypename type )
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly. // 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 = cast(CodeTypename, possible_slot->Next);
} }
possible_slot = type; possible_slot->Next = cast(Code, type);
} }
#pragma endregion CodeClass #pragma endregion CodeClass
@ -296,7 +606,17 @@ bool specifiers_append(CodeSpecifiers self, Specifier spec )
return true; return true;
} }
inline 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); GEN_ASSERT(self != nullptr);
for ( s32 idx = 0; idx < self->NumEntries; idx++ ) { for ( s32 idx = 0; idx < self->NumEntries; idx++ ) {
@ -378,12 +698,12 @@ void struct_add_interface(CodeStruct self, CodeTypename type )
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly. // 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 = cast(CodeTypename, possible_slot->Next);
} }
possible_slot = type; possible_slot->Next = cast(Code, type);
} }
#pragma endregion Code #pragma endregion Code

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "code_serialization.cpp" #include "code_serialization.cpp"
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "ast_types.hpp" #include "ast_types.hpp"
#endif #endif
@ -99,6 +99,11 @@ struct Context
s32 temp_serialize_indent; s32 temp_serialize_indent;
}; };
// TODO(Ed): Eventually this library should opt out of an implicit context for baseline implementation
// This would automatically make it viable for multi-threaded purposes among other things
// An implicit context interface will be provided instead as wrapper procedures as convience.
GEN_API extern Context* _ctx;
// Initialize the library. There first ctx initialized must exist for lifetime of other contextes that come after as its the one that // Initialize the library. There first ctx initialized must exist for lifetime of other contextes that come after as its the one that
GEN_API void init(Context* ctx); GEN_API void init(Context* ctx);
@ -156,6 +161,7 @@ struct Opts_def_struct {
CodeAttributes attributes; CodeAttributes attributes;
CodeTypename* interfaces; CodeTypename* interfaces;
s32 num_interfaces; s32 num_interfaces;
CodeSpecifiers specifiers; // Only used for final specifier for now.
ModuleFlag mflags; ModuleFlag mflags;
}; };
GEN_API CodeClass def_class( Str name, Opts_def_struct opts GEN_PARAM_DEFAULT ); GEN_API CodeClass def_class( Str name, Opts_def_struct opts GEN_PARAM_DEFAULT );
@ -193,7 +199,7 @@ GEN_API CodeEnum def_enum( Str name, Opts_def_enum opts GEN_PARAM_DEFAULT );
GEN_API CodeExec def_execution ( Str content ); GEN_API CodeExec def_execution ( Str content );
GEN_API CodeExtern def_extern_link( Str name, CodeBody body ); GEN_API CodeExtern def_extern_link( Str name, CodeBody body );
GEN_API CodeFriend def_friend ( Code symbol ); GEN_API CodeFriend def_friend ( Code code );
struct Opts_def_function { struct Opts_def_function {
CodeParams params; CodeParams params;
@ -229,7 +235,7 @@ struct Opts_def_operator_cast {
GEN_API CodeOpCast def_operator_cast( CodeTypename type, Opts_def_operator_cast opts GEN_PARAM_DEFAULT ); GEN_API CodeOpCast def_operator_cast( CodeTypename type, Opts_def_operator_cast opts GEN_PARAM_DEFAULT );
struct Opts_def_param { Code value; }; struct Opts_def_param { Code value; };
GEN_API CodeParams def_param ( CodeTypename type, Str name, Opts_def_param opts GEN_PARAM_DEFAULT ); GEN_API CodeParams def_param ( CodeTypename type, Str name, Opts_def_param opts GEN_PARAM_DEFAULT );
GEN_API CodePragma def_pragma( Str directive ); GEN_API CodePragma def_pragma( Str directive );
GEN_API CodePreprocessCond def_preprocess_cond( EPreprocessCond type, Str content ); GEN_API CodePreprocessCond def_preprocess_cond( EPreprocessCond type, Str content );
@ -243,7 +249,7 @@ GEN_API CodeTemplate def_template( CodeParams params, Code definition, Opts_def_
struct Opts_def_type { struct Opts_def_type {
ETypenameTag type_tag; ETypenameTag type_tag;
Code arrayexpr; Code array_expr;
CodeSpecifiers specifiers; CodeSpecifiers specifiers;
CodeAttributes attributes; CodeAttributes attributes;
}; };
@ -279,7 +285,7 @@ struct Opts_def_variable
GEN_API CodeVar def_variable( CodeTypename type, Str name, Opts_def_variable opts GEN_PARAM_DEFAULT ); 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. // 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, // 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. /// or provide as an array of Code objects.
@ -387,7 +393,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 ); 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. //! 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_str( Str content);
GEN_API Code untyped_fmt ( char const* fmt, ... ); GEN_API Code untyped_fmt ( char const* fmt, ... );

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "gen/etoktype.cpp" #include "gen/etoktype.cpp"
#include "interface.upfront.cpp" #include "interface.upfront.cpp"

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "interface.parsing.cpp" #include "interface.parsing.cpp"
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "interface.cpp" #include "interface.cpp"
#endif #endif
@ -532,6 +532,7 @@ CodeClass def_class( Str name, Opts_def_struct p )
result->Name = cache_str( name ); result->Name = cache_str( name );
result->ModuleFlags = p.mflags; result->ModuleFlags = p.mflags;
result->Attributes = p.attributes; result->Attributes = p.attributes;
result->Specs = p.specifiers;
result->ParentAccess = p.parent_access; result->ParentAccess = p.parent_access;
result->ParentType = p.parent; result->ParentType = p.parent;
if ( p.body ) if ( p.body )
@ -1065,6 +1066,7 @@ CodeStruct def_struct( Str name, Opts_def_struct p )
result->Type = CT_Struct_Fwd; result->Type = CT_Struct_Fwd;
} }
result->Attributes = p.attributes; result->Attributes = p.attributes;
result->Specs = p.specifiers;
result->ParentAccess = p.parent_access; result->ParentAccess = p.parent_access;
result->ParentType = p.parent; result->ParentType = p.parent;
@ -1112,7 +1114,7 @@ CodeTypename def_type( Str name, Opts_def_type p )
GEN_DEBUG_TRAP(); GEN_DEBUG_TRAP();
return InvalidCode; return InvalidCode;
} }
Code arrayexpr = p.arrayexpr; Code array_expr = p.array_expr;
CodeSpecifiers specifiers = p.specifiers; CodeSpecifiers specifiers = p.specifiers;
CodeAttributes attributes = p.attributes; CodeAttributes attributes = p.attributes;
if ( p.attributes && p.attributes->Type != CT_PlatformAttributes ) { if ( p.attributes && p.attributes->Type != CT_PlatformAttributes ) {
@ -1125,8 +1127,8 @@ CodeTypename def_type( Str name, Opts_def_type p )
GEN_DEBUG_TRAP(); GEN_DEBUG_TRAP();
return InvalidCode; return InvalidCode;
} }
if ( p.arrayexpr && p.arrayexpr->Type != CT_Untyped ) { if ( p.array_expr && p.array_expr->Type != CT_Untyped ) {
log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", code_debug_str((Code)p.arrayexpr) ); log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", code_debug_str((Code)p.array_expr) );
GEN_DEBUG_TRAP(); GEN_DEBUG_TRAP();
return InvalidCode; return InvalidCode;
} }
@ -1136,7 +1138,7 @@ CodeTypename def_type( Str name, Opts_def_type p )
result->Type = CT_Typename; result->Type = CT_Typename;
result->Attributes = p.attributes; result->Attributes = p.attributes;
result->Specs = p.specifiers; result->Specs = p.specifiers;
result->ArrExpr = p.arrayexpr; result->ArrExpr = p.array_expr;
result->TypeTag = p.type_tag; result->TypeTag = p.type_tag;
return result; return result;
} }

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "interface.upfront.cpp" #include "interface.upfront.cpp"
#include "gen/etoktype.cpp" #include "gen/etoktype.cpp"
@ -264,7 +264,6 @@ s32 lex_preprocessor_define( LexContext* ctx )
} }
// TODO(Ed): We need to to attempt to recover from a lex failure? // TODO(Ed): We need to to attempt to recover from a lex failure?
forceinline
s32 lex_preprocessor_directive( LexContext* ctx ) s32 lex_preprocessor_directive( LexContext* ctx )
{ {
char const* hash = ctx->scanner; char const* hash = ctx->scanner;
@ -480,7 +479,6 @@ s32 lex_preprocessor_directive( LexContext* ctx )
return Lex_Continue; // Skip found token, its all handled here. return Lex_Continue; // Skip found token, its all handled here.
} }
forceinline
void lex_found_token( LexContext* ctx ) void lex_found_token( LexContext* ctx )
{ {
if ( ctx->token.Type != Tok_Invalid ) { if ( ctx->token.Type != Tok_Invalid ) {
@ -490,6 +488,10 @@ void lex_found_token( LexContext* ctx )
TokType type = str_to_toktype( ctx->token.Text ); TokType type = str_to_toktype( ctx->token.Text );
if (type == Tok_Preprocess_Define || type == Tok_Preprocess_Include) {
ctx->token.Flags |= TF_Identifier;
}
if (type <= Tok_Access_Public && type >= Tok_Access_Private ) { if (type <= Tok_Access_Public && type >= Tok_Access_Private ) {
ctx->token.Flags |= TF_AccessSpecifier; ctx->token.Flags |= TF_AccessSpecifier;
} }
@ -550,6 +552,9 @@ void lex_found_token( LexContext* ctx )
if ( bitfield_is_set(MacroFlags, macro->Flags, MF_Allow_As_Attribute) ) { if ( bitfield_is_set(MacroFlags, macro->Flags, MF_Allow_As_Attribute) ) {
ctx->token.Flags |= TF_Attribute; ctx->token.Flags |= TF_Attribute;
} }
if ( bitfield_is_set(MacroFlags, macro->Flags, MF_Allow_As_Specifier ) ) {
ctx->token.Flags |= TF_Specifier;
}
} }
else else
{ {

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "gen/etoktype.cpp" #include "gen/etoktype.cpp"
#include "parser_case_macros.cpp" #include "parser_case_macros.cpp"
@ -717,6 +717,13 @@ Code parse_class_struct( TokType which, bool inplace_def )
} }
// <ModuleFlags> <class/struct> <Attributes> <Name> // <ModuleFlags> <class/struct> <Attributes> <Name>
CodeSpecifiers specifiers = NullCode;
if ( check(Tok_Spec_Final)) {
specifiers = def_specifier(Spec_Final);
eat(Tok_Spec_Final);
}
// <ModuleFlags> <class/struct> <Attributes> <Name> <final>
local_persist local_persist
char interface_arr_mem[ kilobytes(4) ] = {0}; char interface_arr_mem[ kilobytes(4) ] = {0};
Array(CodeTypename) interfaces; { Array(CodeTypename) interfaces; {
@ -728,22 +735,22 @@ Code parse_class_struct( TokType which, bool inplace_def )
if ( check( Tok_Assign_Classifer ) ) if ( check( Tok_Assign_Classifer ) )
{ {
eat( Tok_Assign_Classifer ); eat( Tok_Assign_Classifer );
// <ModuleFlags> <class/struct> <Attributes> <Name> : // <ModuleFlags> <class/struct> <Attributes> <Name> <final> :
if ( tok_is_access_specifier(currtok) ) { if ( tok_is_access_specifier(currtok) ) {
access = tok_to_access_specifier(currtok); access = tok_to_access_specifier(currtok);
// <ModuleFlags> <class/struct> <Attributes> <Name> : <Access Specifier> // <ModuleFlags> <class/struct> <Attributes> <Name> <final> : <Access Specifier>
eat( currtok.Type ); eat( currtok.Type );
} }
Token parent_tok = parse_identifier(nullptr); Token parent_tok = parse_identifier(nullptr);
parent = def_type( parent_tok.Text ); parent = def_type( parent_tok.Text );
// <ModuleFlags> <class/struct> <Attributes> <Name> : <Access Specifier> <Parent/Interface Name> // <ModuleFlags> <class/struct> <Attributes> <Name> <final> : <Access Specifier> <Parent/Interface Name>
while ( check(Tok_Comma) ) while ( check(Tok_Comma) )
{ {
eat( Tok_Comma ); eat( Tok_Comma );
// <ModuleFlags> <class/struct> <Attributes> <Name> : <Access Specifier> <Name>, // <ModuleFlags> <class/struct> <Attributes> <Name> <final> : <Access Specifier> <Name>,
if ( tok_is_access_specifier(currtok) ) { if ( tok_is_access_specifier(currtok) ) {
eat(currtok.Type); eat(currtok.Type);
@ -751,32 +758,32 @@ Code parse_class_struct( TokType which, bool inplace_def )
Token interface_tok = parse_identifier(nullptr); Token interface_tok = parse_identifier(nullptr);
array_append( interfaces, def_type( interface_tok.Text ) ); array_append( interfaces, def_type( interface_tok.Text ) );
// <ModuleFlags> <class/struct> <Attributes> <Name> : <Access Specifier> <Name>, ... // <ModuleFlags> <class/struct> <Attributes> <Name> <final> : <Access Specifier> <Name>, ...
} }
} }
if ( check( Tok_BraceCurly_Open ) ) { if ( check( Tok_BraceCurly_Open ) ) {
body = parse_class_struct_body( which, name ); body = parse_class_struct_body( which, name );
} }
// <ModuleFlags> <class/struct> <Attributes> <Name> : <Access Specifier> <Name>, ... { <Body> } // <ModuleFlags> <class/struct> <Attributes> <Name> <final> : <Access Specifier> <Name>, ... { <Body> }
CodeComment inline_cmt = NullCode; CodeComment inline_cmt = NullCode;
if ( ! inplace_def ) if ( ! inplace_def )
{ {
Token stmt_end = currtok; Token stmt_end = currtok;
eat( Tok_Statement_End ); eat( Tok_Statement_End );
// <ModuleFlags> <class/struct> <Attributes> <Name> : <Access Specifier> <Name>, ... { <Body> }; // <ModuleFlags> <class/struct> <Attributes> <Name> <final> : <Access Specifier> <Name>, ... { <Body> };
if ( currtok_noskip.Type == Tok_Comment && currtok_noskip.Line == stmt_end.Line ) if ( currtok_noskip.Type == Tok_Comment && currtok_noskip.Line == stmt_end.Line )
inline_cmt = parse_comment(); inline_cmt = parse_comment();
// <ModuleFlags> <class/struct> <Attributes> <Name> : <Access Specifier> <Name>, ... { <Body> }; <InlineCmt> // <ModuleFlags> <class/struct> <Attributes> <Name> <final> : <Access Specifier> <Name>, ... { <Body> }; <InlineCmt>
} }
if ( which == Tok_Decl_Class ) if ( which == Tok_Decl_Class )
result = cast(Code, def_class( name.Text, def_assign( body, parent, access, attributes, interfaces, scast(s32, array_num(interfaces)), mflags ) )); result = cast(Code, def_class( name.Text, def_assign( body, parent, access, attributes, interfaces, scast(s32, array_num(interfaces)), specifiers, mflags ) ));
else else
result = cast(Code, def_struct( name.Text, def_assign( body, (CodeTypename)parent, access, attributes, interfaces, scast(s32, array_num(interfaces)), mflags ) )); result = cast(Code, def_struct( name.Text, def_assign( body, (CodeTypename)parent, access, attributes, interfaces, scast(s32, array_num(interfaces)), specifiers, mflags ) ));
if ( inline_cmt ) if ( inline_cmt )
result->InlineCmt = cast(Code, inline_cmt); result->InlineCmt = cast(Code, inline_cmt);
@ -947,10 +954,6 @@ CodeBody parse_class_struct_body( TokType which, Token name )
member = cast(Code, parse_simple_preprocess( Tok_Preprocess_Macro_Stmt )); member = cast(Code, parse_simple_preprocess( Tok_Preprocess_Macro_Stmt ));
break; break;
} }
case Tok_Preprocess_Macro_Expr: {
log_failure("Unbounded macro expression residing in class/struct body\n%S", parser_to_strbuilder(_ctx->parser));
return InvalidCode;
}
// case Tok_Preprocess_Macro: // case Tok_Preprocess_Macro:
// // <Macro> // // <Macro>
@ -976,6 +979,15 @@ CodeBody parse_class_struct_body( TokType which, Token name )
break; break;
} }
case Tok_Preprocess_Macro_Expr:
{
if ( ! tok_is_attribute(currtok))
{
log_failure("Unbounded macro expression residing in class/struct body\n%S", parser_to_strbuilder(_ctx->parser));
return InvalidCode;
}
}
//! Fallthrough intended
case Tok_Attribute_Open: case Tok_Attribute_Open:
case Tok_Decl_GNU_Attribute: case Tok_Decl_GNU_Attribute:
case Tok_Decl_MSVC_Attribute: case Tok_Decl_MSVC_Attribute:
@ -1143,27 +1155,44 @@ Code parse_complicated_definition( TokType which )
{ {
push_scope(); push_scope();
bool is_inplace = false; b32 is_inplace = false;
b32 is_fn_def = false;
TokArray tokens = _ctx->parser.Tokens; TokArray tokens = _ctx->parser.Tokens;
s32 idx = tokens.Idx; s32 idx = tokens.Idx;
s32 level = 0; s32 level = 0;
b32 had_def = false;
b32 had_paren = false;
for ( ; idx < array_num(tokens.Arr); idx++ ) for ( ; idx < array_num(tokens.Arr); idx++ )
{ {
if ( tokens.Arr[ idx ].Type == Tok_BraceCurly_Open ) if ( tokens.Arr[ idx ].Type == Tok_BraceCurly_Open )
level++; level++;
if ( tokens.Arr[ idx ].Type == Tok_BraceCurly_Close ) if ( tokens.Arr[ idx ].Type == Tok_BraceCurly_Close ) {
level--; level--;
had_def = level == 0;
}
if ( level == 0 && tokens.Arr[ idx ].Type == Tok_Statement_End ) b32 found_fn_def = had_def && had_paren;
if ( level == 0 && (tokens.Arr[ idx ].Type == Tok_Statement_End || found_fn_def) )
break; break;
} }
is_fn_def = had_def && had_paren;
if (is_fn_def)
{
// Function definition with <which> on return type
Code result = parse_operator_function_or_variable(false, NullCode, NullCode);
// <which> <typename>(...) ... { ... }
parser_pop(& _ctx->parser);
return result;
}
if ( ( idx - 2 ) == tokens.Idx ) if ( ( idx - 2 ) == tokens.Idx )
{ {
// Its a forward declaration only // It's a forward declaration only
Code result = parse_forward_or_definition( which, is_inplace ); Code result = parse_forward_or_definition( which, is_inplace );
// <class, enum, struct, or union> <Name>; // <class, enum, struct, or union> <Name>;
parser_pop(& _ctx->parser); parser_pop(& _ctx->parser);
@ -1336,8 +1365,10 @@ Code parse_assignment_expression()
eat( currtok.Type ); eat( currtok.Type );
} }
expr_tok.Text.Len = ( ( sptr )currtok.Text.Ptr + currtok.Text.Len ) - ( sptr )expr_tok.Text.Ptr - 1; if (left) {
expr = untyped_str( expr_tok.Text ); expr_tok.Text.Len = ( ( sptr )currtok.Text.Ptr + currtok.Text.Len ) - ( sptr )expr_tok.Text.Ptr - 1;
}
expr = untyped_str( expr_tok.Text );
// = <Expression> // = <Expression>
return expr; return expr;
} }
@ -1388,9 +1419,18 @@ CodeFn parse_function_after_name(
CodeParams params = parse_params(parser_use_parenthesis); CodeParams params = parse_params(parser_use_parenthesis);
// <Attributes> <Specifiers> <ReturnType> <Name> ( <Parameters> ) // <Attributes> <Specifiers> <ReturnType> <Name> ( <Parameters> )
Code suffix_specs = NullCode;
// TODO(Ed), Review old comment : These have to be kept separate from the return type's specifiers. // TODO(Ed), Review old comment : These have to be kept separate from the return type's specifiers.
while ( left && tok_is_specifier(currtok) ) while ( left && tok_is_specifier(currtok) )
{ {
// For Unreal's PURE_VIRTUAL Support
Macro* macro = lookup_macro( currtok.Text );
if (macro && tok_is_specifier(currtok))
{
suffix_specs = parse_simple_preprocess(Tok_Preprocess_Macro_Expr);
continue;
}
if ( specifiers == nullptr ) if ( specifiers == nullptr )
{ {
specifiers = def_specifier( str_to_specifier( currtok.Text) ); specifiers = def_specifier( str_to_specifier( currtok.Text) );
@ -1418,13 +1458,27 @@ CodeFn parse_function_after_name(
else if ( check(Tok_Operator) && currtok.Text.Ptr[0] == '=' ) else if ( check(Tok_Operator) && currtok.Text.Ptr[0] == '=' )
{ {
eat(Tok_Operator); eat(Tok_Operator);
specifiers_append(specifiers, Spec_Pure ); if ( specifiers == nullptr )
{
specifiers = (CodeSpecifiers) make_code();
specifiers->Type = CT_Specifiers;
}
if ( str_are_equal(nexttok.Text, txt("delete")))
{
specifiers_append(specifiers, Spec_Delete);
eat(currtok.Type);
// <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers> = delete
}
else
{
specifiers_append(specifiers, Spec_Pure );
eat( Tok_Number); eat( Tok_Number);
// <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers> = 0
}
Token stmt_end = currtok; Token stmt_end = currtok;
eat( Tok_Statement_End ); eat( Tok_Statement_End );
// <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers> = 0;
if ( currtok_noskip.Type == Tok_Comment && currtok_noskip.Line == stmt_end.Line ) if ( currtok_noskip.Type == Tok_Comment && currtok_noskip.Line == stmt_end.Line )
inline_cmt = parse_comment(); inline_cmt = parse_comment();
// <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers>; <InlineCmt> // <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers>; <InlineCmt>
@ -1479,6 +1533,9 @@ CodeFn parse_function_after_name(
if ( specifiers ) if ( specifiers )
result->Specs = specifiers; result->Specs = specifiers;
if ( suffix_specs )
result->SuffixSpecs = suffix_specs;
result->ReturnType = ret_type; result->ReturnType = ret_type;
if ( params ) if ( params )
@ -1672,10 +1729,6 @@ CodeBody parse_global_nspace( CodeType which )
member = cast(Code, parse_simple_preprocess( Tok_Preprocess_Macro_Stmt )); member = cast(Code, parse_simple_preprocess( Tok_Preprocess_Macro_Stmt ));
break; break;
} }
case Tok_Preprocess_Macro_Expr: {
log_failure("Unbounded macro expression residing in class/struct body\n%S", parser_to_strbuilder(_ctx->parser));
return InvalidCode;
}
case Tok_Preprocess_Pragma: { case Tok_Preprocess_Pragma: {
member = cast(Code, parse_pragma()); member = cast(Code, parse_pragma());
@ -1709,6 +1762,16 @@ CodeBody parse_global_nspace( CodeType which )
log_failure( "gen::%s: This function is not implemented" ); log_failure( "gen::%s: This function is not implemented" );
return InvalidCode; return InvalidCode;
} }
break;
case Tok_Preprocess_Macro_Expr:
{
if (tok_is_attribute(currtok))
{
log_failure("Unbounded macro expression residing in class/struct body\n%S", parser_to_strbuilder(_ctx->parser));
return InvalidCode;
}
}
//! Fallthrough intentional //! Fallthrough intentional
case Tok_Attribute_Open: case Tok_Attribute_Open:
case Tok_Decl_GNU_Attribute: case Tok_Decl_GNU_Attribute:
@ -1983,7 +2046,14 @@ Token parse_identifier( bool* possible_member_function )
Token name = currtok; Token name = currtok;
_ctx->parser.Scope->Name = name.Text; _ctx->parser.Scope->Name = name.Text;
eat( Tok_Identifier );
Macro* macro = lookup_macro(currtok.Text);
b32 accept_as_identifier = macro && bitfield_is_set(MacroFlags, macro->Flags, MF_Allow_As_Identifier );
// Typename can be: '::' <name>
// If that is the case first option will be Tok_Access_StaticSymbol below
if (check(Tok_Identifier) || accept_as_identifier)
eat( Tok_Identifier );
// <Name> // <Name>
parse_template_args( & name ); parse_template_args( & name );
@ -2403,6 +2473,25 @@ CodeOperator parse_operator_after_ret_type(
eat( currtok.Type ); eat( currtok.Type );
} }
// <ExportFlag> <Attributes> <Specifiers> <ReturnType> <Qualifier::...> operator <Op> ( <Parameters> ) <Specifiers> // <ExportFlag> <Attributes> <Specifiers> <ReturnType> <Qualifier::...> operator <Op> ( <Parameters> ) <Specifiers>
// TODO(Ed): Add proper "delete" and "new" awareness
// We're dealing with either a "= delete" or operator deletion
if (check(Tok_Operator) && currtok.Text.Ptr[0] == '=')
{
eat(currtok.Type);
if ( ! str_are_equal(currtok.Text, txt("delete")))
{
log_failure("Expected delete after = in operator forward instead found \"%S\"\n%SB", currtok.Text, parser_to_strbuilder(_ctx->parser));
parser_pop(& _ctx->parser);
return InvalidCode;
}
if (specifiers == nullptr)
specifiers = def_specifier( Spec_Delete );
else
specifiers_append(specifiers, Spec_Delete);
eat(currtok.Type);
// <ExportFlag> <Attributes> <Specifiers> <ReturnType> <Qualifier::...> operator <Op> ( <Parameters> ) <Specifiers> = delete
}
// Parse Body // Parse Body
CodeBody body = { nullptr }; CodeBody body = { nullptr };
@ -2454,6 +2543,24 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes
CodeTypename type = parser_parse_type( parser_not_from_template, nullptr ); CodeTypename type = parser_parse_type( parser_not_from_template, nullptr );
// <Attributes> <Specifiers> <ReturnType/ValueType> // <Attributes> <Specifiers> <ReturnType/ValueType>
// Thanks Unreal
CodeAttributes post_rt_attributes = parse_attributes();
if (post_rt_attributes)
{
if (attributes)
{
StrBuilder merged = strbuilder_fmt_buf(_ctx->Allocator_Temp, "%S %S", attributes->Content, post_rt_attributes->Content);
attributes->Content = cache_str(strbuilder_to_str(merged));
}
else
{
attributes = post_rt_attributes;
}
// <Attributes> <Specifiers> <ReturnType/ValueType> <Attributes>
// CONVERTED TO:
// <Attributes> <Specifiers> <ReturnType/ValueType>
}
if ( type == InvalidCode ) { if ( type == InvalidCode ) {
parser_pop(& _ctx->parser); parser_pop(& _ctx->parser);
return InvalidCode; return InvalidCode;
@ -2683,10 +2790,10 @@ CodeParams parse_params( bool use_template_capture )
} }
// ( <Macro> <ValueType> // ( <Macro> <ValueType>
if ( check( Tok_Identifier ) ) if ( check( Tok_Identifier ) || bitfield_is_set(u32, currtok.Flags, TF_Identifier) )
{ {
name = currtok; name = currtok;
eat( Tok_Identifier ); eat( currtok.Type );
// ( <Macro> <ValueType> <Name> // ( <Macro> <ValueType> <Name>
} }
@ -2701,10 +2808,8 @@ CodeParams parse_params( bool use_template_capture )
// ( <Macro> <ValueType> <Name> <PostNameMacro> // ( <Macro> <ValueType> <Name> <PostNameMacro>
} }
// In template captures you can have a typename have direct assignment without a name // C++ allows typename = expression... so anything goes....
// typename = typename ... if ( bitfield_is_set( u32, currtok.Flags, TF_Assign ) )
// Which would result in a static value type from a struct expansion (traditionally)
if ( ( name.Text.Ptr || use_template_capture ) && bitfield_is_set( u32, currtok.Flags, TF_Assign ) )
{ {
eat( Tok_Operator ); eat( Tok_Operator );
// ( <Macro> <ValueType> <Name> = // ( <Macro> <ValueType> <Name> =
@ -2796,10 +2901,10 @@ CodeParams parse_params( bool use_template_capture )
name = NullToken; name = NullToken;
if ( check( Tok_Identifier ) ) if ( check( Tok_Identifier ) || bitfield_is_set(u32, currtok.Flags, TF_Identifier) )
{ {
name = currtok; name = currtok;
eat( Tok_Identifier ); eat( currtok.Type );
// ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <Name> // ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <Name>
} }
@ -2812,10 +2917,8 @@ CodeParams parse_params( bool use_template_capture )
// ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <PostNameMacro> // ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <PostNameMacro>
} }
// In template captures you can have a typename have direct assignment without a name /// C++ allows typename = expression... so anything goes....
// typename = typename ... if ( bitfield_is_set( u32, currtok.Flags, TF_Assign ) )
// Which would result in a static value type from a struct expansion (traditionally)
if ( ( name.Text.Ptr || use_template_capture ) && bitfield_is_set( u32, currtok.Flags, TF_Assign ) )
{ {
eat( Tok_Operator ); eat( Tok_Operator );
// ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <Name> <PostNameMacro> = // ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <Name> <PostNameMacro> =
@ -3439,6 +3542,7 @@ CodeConstructor parser_parse_constructor( CodeSpecifiers specifiers )
body = cast(CodeBody, parse_function_body()); body = cast(CodeBody, parse_function_body());
// <Name> ( <Parameters> ) { <Body> } // <Name> ( <Parameters> ) { <Body> }
} }
// TODO(Ed): Add support for detecting constructor deletion
else if ( check( Tok_Operator) && currtok.Text.Ptr[ 0 ] == '=' ) else if ( check( Tok_Operator) && currtok.Text.Ptr[ 0 ] == '=' )
{ {
body = cast(CodeBody, parse_assignment_expression()); body = cast(CodeBody, parse_assignment_expression());
@ -5426,7 +5530,10 @@ CodeUsing parser_parse_using()
if ( ! is_namespace ) if ( ! is_namespace )
{ {
if ( bitfield_is_set( u32, currtok.Flags, TF_Assign ) ) attributes = parse_attributes();
// <ModuleFlags> using <Name> <Attributes>
if ( bitfield_is_set( u32, currtok.Flags, TF_Assign ))
{ {
attributes = parse_attributes(); attributes = parse_attributes();
// <ModuleFlags> using <Name> <Attributes> // <ModuleFlags> using <Name> <Attributes>

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "types.hpp" #include "types.hpp"
#include "gen/ecode.hpp" #include "gen/ecode.hpp"
@ -11,17 +11,18 @@ enum TokFlags : u32
{ {
TF_Operator = bit(0), TF_Operator = bit(0),
TF_Assign = bit(1), TF_Assign = bit(1),
TF_Preprocess = bit(2), TF_Identifier = bit(2),
TF_Preprocess_Cond = bit(3), TF_Preprocess = bit(3),
TF_Attribute = bit(6), TF_Preprocess_Cond = bit(4),
TF_AccessOperator = bit(7), TF_Attribute = bit(5),
TF_AccessSpecifier = bit(8), TF_AccessOperator = bit(6),
TF_Specifier = bit(9), TF_AccessSpecifier = bit(7),
TF_EndDefinition = bit(10), // Either ; or } TF_Specifier = bit(8),
TF_Formatting = bit(11), TF_EndDefinition = bit(9), // Either ; or }
TF_Literal = bit(12), TF_Formatting = bit(10),
TF_Macro_Functional = bit(13), TF_Literal = bit(11),
TF_Macro_Expects_Body = bit(14), TF_Macro_Functional = bit(12),
TF_Macro_Expects_Body = bit(13),
TF_Null = 0, TF_Null = 0,
TF_UnderlyingType = GEN_U32_MAX, TF_UnderlyingType = GEN_U32_MAX,
@ -181,11 +182,13 @@ enum EMacroFlags : u16
// & it would allow UE_DEPRECATED, (UE_PROPERTY / UE_FUNCTION) to chain themselves as attributes of a resolved member function/variable definition // & it would allow UE_DEPRECATED, (UE_PROPERTY / UE_FUNCTION) to chain themselves as attributes of a resolved member function/variable definition
MF_Allow_As_Attribute = bit(3), MF_Allow_As_Attribute = bit(3),
// When a macro is encountered after attributs and specifiers while parsing a function, or variable: // When a macro is encountered after attributes and specifiers while parsing a function, or variable:
// It will consume the macro and treat it as resolving the definition. (Yes this is for Unreal Engine) // It will consume the macro and treat it as resolving the definition. (Yes this is for Unreal Engine)
// (MUST BE OF MT_Statement TYPE) // (MUST BE OF MT_Statement TYPE)
MF_Allow_As_Definition = bit(4), MF_Allow_As_Definition = bit(4),
MF_Allow_As_Specifier = bit(5), // Created for Unreal's PURE_VIRTUAL
MF_Null = 0, MF_Null = 0,
MF_UnderlyingType = GEN_U16_MAX, MF_UnderlyingType = GEN_U16_MAX,
}; };

View File

@ -1,90 +1,90 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "../gen.hpp" #include "../gen.hpp"
#endif #endif
#pragma region StaticData #pragma region StaticData
global Context* _ctx; GEN_API global Context* _ctx;
global u32 context_counter; GEN_API global u32 context_counter;
#pragma region Constants #pragma region Constants
global Macro enum_underlying_macro; GEN_API global Macro enum_underlying_macro;
global Code Code_Global; GEN_API global Code Code_Global;
global Code Code_Invalid; GEN_API global Code Code_Invalid;
global Code access_public; GEN_API global Code access_public;
global Code access_protected; GEN_API global Code access_protected;
global Code access_private; GEN_API global Code access_private;
global CodeAttributes attrib_api_export; GEN_API global CodeAttributes attrib_api_export;
global CodeAttributes attrib_api_import; GEN_API global CodeAttributes attrib_api_import;
global Code module_global_fragment; GEN_API global Code module_global_fragment;
global Code module_private_fragment; GEN_API global Code module_private_fragment;
global Code fmt_newline; GEN_API global Code fmt_newline;
global CodeParams param_varadic; GEN_API global CodeParams param_varadic;
global CodePragma pragma_once; GEN_API global CodePragma pragma_once;
global CodePreprocessCond preprocess_else; GEN_API global CodePreprocessCond preprocess_else;
global CodePreprocessCond preprocess_endif; GEN_API global CodePreprocessCond preprocess_endif;
global CodeSpecifiers spec_const; GEN_API global CodeSpecifiers spec_const;
global CodeSpecifiers spec_consteval; GEN_API global CodeSpecifiers spec_consteval;
global CodeSpecifiers spec_constexpr; GEN_API global CodeSpecifiers spec_constexpr;
global CodeSpecifiers spec_constinit; GEN_API global CodeSpecifiers spec_constinit;
global CodeSpecifiers spec_extern_linkage; GEN_API global CodeSpecifiers spec_extern_linkage;
global CodeSpecifiers spec_final; GEN_API global CodeSpecifiers spec_final;
global CodeSpecifiers spec_forceinline; GEN_API global CodeSpecifiers spec_forceinline;
global CodeSpecifiers spec_global; GEN_API global CodeSpecifiers spec_global;
global CodeSpecifiers spec_inline; GEN_API global CodeSpecifiers spec_inline;
global CodeSpecifiers spec_internal_linkage; GEN_API global CodeSpecifiers spec_internal_linkage;
global CodeSpecifiers spec_local_persist; GEN_API global CodeSpecifiers spec_local_persist;
global CodeSpecifiers spec_mutable; GEN_API global CodeSpecifiers spec_mutable;
global CodeSpecifiers spec_noexcept; GEN_API global CodeSpecifiers spec_noexcept;
global CodeSpecifiers spec_neverinline; GEN_API global CodeSpecifiers spec_neverinline;
global CodeSpecifiers spec_override; GEN_API global CodeSpecifiers spec_override;
global CodeSpecifiers spec_ptr; GEN_API global CodeSpecifiers spec_ptr;
global CodeSpecifiers spec_pure; GEN_API global CodeSpecifiers spec_pure;
global CodeSpecifiers spec_ref; GEN_API global CodeSpecifiers spec_ref;
global CodeSpecifiers spec_register; GEN_API global CodeSpecifiers spec_register;
global CodeSpecifiers spec_rvalue; GEN_API global CodeSpecifiers spec_rvalue;
global CodeSpecifiers spec_static_member; GEN_API global CodeSpecifiers spec_static_member;
global CodeSpecifiers spec_thread_local; GEN_API global CodeSpecifiers spec_thread_local;
global CodeSpecifiers spec_virtual; GEN_API global CodeSpecifiers spec_virtual;
global CodeSpecifiers spec_volatile; GEN_API global CodeSpecifiers spec_volatile;
global CodeTypename t_empty; GEN_API global CodeTypename t_empty;
global CodeTypename t_auto; GEN_API global CodeTypename t_auto;
global CodeTypename t_void; GEN_API global CodeTypename t_void;
global CodeTypename t_int; GEN_API global CodeTypename t_int;
global CodeTypename t_bool; GEN_API global CodeTypename t_bool;
global CodeTypename t_char; GEN_API global CodeTypename t_char;
global CodeTypename t_wchar_t; GEN_API global CodeTypename t_wchar_t;
global CodeTypename t_class; GEN_API global CodeTypename t_class;
global CodeTypename t_typename; GEN_API global CodeTypename t_typename;
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS #ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
global CodeTypename t_b32; GEN_API global CodeTypename t_b32;
global CodeTypename t_s8; GEN_API global CodeTypename t_s8;
global CodeTypename t_s16; GEN_API global CodeTypename t_s16;
global CodeTypename t_s32; GEN_API global CodeTypename t_s32;
global CodeTypename t_s64; GEN_API global CodeTypename t_s64;
global CodeTypename t_u8; GEN_API global CodeTypename t_u8;
global CodeTypename t_u16; GEN_API global CodeTypename t_u16;
global CodeTypename t_u32; GEN_API global CodeTypename t_u32;
global CodeTypename t_u64; GEN_API global CodeTypename t_u64;
global CodeTypename t_ssize; GEN_API global CodeTypename t_ssize;
global CodeTypename t_usize; GEN_API global CodeTypename t_usize;
global CodeTypename t_f32; GEN_API global CodeTypename t_f32;
global CodeTypename t_f64; GEN_API global CodeTypename t_f64;
#endif #endif
#pragma endregion Constants #pragma endregion Constants

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "header_start.hpp" #include "header_start.hpp"
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "macros.hpp" # include "macros.hpp"
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "printing.hpp" # include "printing.hpp"
#endif #endif
@ -309,6 +309,7 @@ ArrayHeader* array_get_header(Array<Type> array) {
using NonConstType = TRemoveConst<Type>; using NonConstType = TRemoveConst<Type>;
return rcast(ArrayHeader*, const_cast<NonConstType*>(Data)) - 1; return rcast(ArrayHeader*, const_cast<NonConstType*>(Data)) - 1;
} }
template<class Type> forceinline template<class Type> forceinline
bool array_grow(Array<Type>* array, usize min_capacity) bool array_grow(Array<Type>* array, usize min_capacity)
{ {
@ -415,7 +416,7 @@ bool array_set_capacity(Array<Type>* array, usize new_capacity)
// These are intended for use in the base library of gencpp and the C-variant of the library // These are intended for use in the base library of gencpp and the C-variant of the library
// It provides a interoperability between the C++ and C implementation of arrays. (not letting these do any crazy substiution though) // It provides a interoperability between the C++ and C implementation of arrays. (not letting these do any crazy substiution though)
// They are undefined in gen.hpp and gen.cpp at the end of the files. // They are undefined in gen.hpp and gen.cpp at the end of the files.
// We cpp library expects the user to use the regular calls as they can resolve the type fine. // The cpp library expects the user to use the regular calls as they can resolve the type fine.
#define array_init(type, allocator) array_init <type> (allocator ) #define array_init(type, allocator) array_init <type> (allocator )
#define array_init_reserve(type, allocator, cap) array_init_reserve <type> (allocator, cap) #define array_init_reserve(type, allocator, cap) array_init_reserve <type> (allocator, cap)

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "src_start.cpp" # include "src_start.cpp"
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "dependencies/platform.hpp" # include "dependencies/platform.hpp"
# include "dependencies/macros.hpp" # include "dependencies/macros.hpp"
@ -67,8 +67,8 @@
while (0) while (0)
#endif #endif
void assert_handler( char const* condition, char const* file, char const* function, s32 line, char const* msg, ... ); GEN_API void assert_handler( char const* condition, char const* file, char const* function, s32 line, char const* msg, ... );
s32 assert_crash( char const* condition ); GEN_API s32 assert_crash( char const* condition );
void process_exit( u32 code ); GEN_API void process_exit( u32 code );
#pragma endregion Debug #pragma endregion Debug

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "strings.cpp" # include "strings.cpp"
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "strings.hpp" # include "strings.hpp"
#endif #endif
@ -121,20 +121,20 @@ enum FileStandardType
* @param std Check zpl_file_standard_type * @param std Check zpl_file_standard_type
* @return File handle to standard I/O * @return File handle to standard I/O
*/ */
FileInfo* file_get_standard( FileStandardType std ); GEN_API FileInfo* file_get_standard( FileStandardType std );
/** /**
* Closes the file * Closes the file
* @param file * @param file
*/ */
FileError file_close( FileInfo* file ); GEN_API FileError file_close( FileInfo* file );
/** /**
* Returns the currently opened file's name * Returns the currently opened file's name
* @param file * @param file
*/ */
inline inline
char const* file_name( FileInfo* file ) char const* file_name( FileInfo* file )
{ {
return file->filename ? file->filename : ""; return file->filename ? file->filename : "";
} }
@ -144,7 +144,7 @@ inline
* @param file * @param file
* @param filename * @param filename
*/ */
FileError file_open( FileInfo* file, char const* filename ); GEN_API FileError file_open( FileInfo* file, char const* filename );
/** /**
* Opens a file using a specified mode * Opens a file using a specified mode
@ -152,7 +152,7 @@ FileError file_open( FileInfo* file, char const* filename );
* @param mode Access mode to use * @param mode Access mode to use
* @param filename * @param filename
*/ */
FileError file_open_mode( FileInfo* file, FileMode mode, char const* filename ); GEN_API FileError file_open_mode( FileInfo* file, FileMode mode, char const* filename );
/** /**
* Reads from a file * Reads from a file
@ -200,14 +200,14 @@ constexpr b32 file_no_zero_terminate = false;
* @param filepath Path to the file * @param filepath Path to the file
* @return File contents data * @return File contents data
*/ */
FileContents file_read_contents( AllocatorInfo a, b32 zero_terminate, char const* filepath ); GEN_API FileContents file_read_contents( AllocatorInfo a, b32 zero_terminate, char const* filepath );
/** /**
* Returns a size of the file * Returns a size of the file
* @param file * @param file
* @return File size * @return File size
*/ */
s64 file_size( FileInfo* file ); GEN_API s64 file_size( FileInfo* file );
/** /**
* Seeks the file cursor from the beginning of file to a specific position * Seeks the file cursor from the beginning of file to a specific position
@ -274,7 +274,7 @@ enum FileStreamFlags : u32
* @param file * @param file
* @param allocator * @param allocator
*/ */
b8 file_stream_new( FileInfo* file, AllocatorInfo allocator ); GEN_API b8 file_stream_new( FileInfo* file, AllocatorInfo allocator );
/** /**
* Opens a memory stream over an existing buffer * Opens a memory stream over an existing buffer
@ -284,14 +284,14 @@ b8 file_stream_new( FileInfo* file, AllocatorInfo allocator );
* @param size Buffer's size * @param size Buffer's size
* @param flags * @param flags
*/ */
b8 file_stream_open( FileInfo* file, AllocatorInfo allocator, u8* buffer, ssize size, FileStreamFlags flags ); GEN_API b8 file_stream_open( FileInfo* file, AllocatorInfo allocator, u8* buffer, ssize size, FileStreamFlags flags );
/** /**
* Retrieves the stream's underlying buffer and buffer size. * Retrieves the stream's underlying buffer and buffer size.
* @param file memory stream * @param file memory stream
* @param size (Optional) buffer size * @param size (Optional) buffer size
*/ */
u8* file_stream_buf( FileInfo* file, ssize* size ); GEN_API u8* file_stream_buf( FileInfo* file, ssize* size );
extern FileOperations const memory_file_operations; extern FileOperations const memory_file_operations;

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "memory.cpp" # include "memory.cpp"
#endif #endif

View File

@ -1,11 +1,11 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "containers.hpp" #include "containers.hpp"
#endif #endif
#pragma region Hashing #pragma region Hashing
u32 crc32( void const* data, ssize len ); GEN_API u32 crc32( void const* data, ssize len );
u64 crc64( void const* data, ssize len ); GEN_API u64 crc64( void const* data, ssize len );
#pragma endregion Hashing #pragma endregion Hashing

View File

@ -1,10 +1,11 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "platform.hpp" # include "platform.hpp"
#endif #endif
#pragma region Macros #pragma region Macros
#ifndef GEN_API
#if GEN_COMPILER_MSVC #if GEN_COMPILER_MSVC
#ifdef GEN_DYN_LINK #ifdef GEN_DYN_LINK
#ifdef GEN_DYN_EXPORT #ifdef GEN_DYN_EXPORT
@ -22,9 +23,14 @@
#define GEN_API // Empty for static builds #define GEN_API // Empty for static builds
#endif #endif
#endif #endif
#endif // GEN_API
#ifndef global #ifndef global // Global variables
#define global static // Global variables # if defined(GEN_STATIC_LINK) || defined(GEN_DYN_LINK)
# define global
# else
# define global static
# endif
#endif #endif
#ifndef internal #ifndef internal
#define internal static // Internal linkage #define internal static // Internal linkage
@ -35,6 +41,9 @@
#ifndef bit #ifndef bit
#define bit( Value ) ( 1 << Value ) #define bit( Value ) ( 1 << Value )
#endif
#ifndef bitfield_is_set
#define bitfield_is_set( Type, Field, Mask ) ( (scast(Type, Mask) & scast(Type, Field)) == scast(Type, Mask) ) #define bitfield_is_set( Type, Field, Mask ) ( (scast(Type, Mask) & scast(Type, Field)) == scast(Type, Mask) )
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "printing.cpp" # include "printing.cpp"
#endif #endif
@ -84,13 +84,13 @@ void heap_stats_check( void )
typedef struct _heap_alloc_info _heap_alloc_info; typedef struct _heap_alloc_info _heap_alloc_info;
struct _heap_alloc_info struct _heap_alloc_info
{ {
ssize size; ssize size;
void* physical_start; void* physical_start;
}; };
void* heap_allocator_proc( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags ) void* heap_allocator_proc( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags )
{ {
void* ptr = NULL; void* ptr = nullptr;
// unused( allocator_data ); // unused( allocator_data );
// unused( old_size ); // unused( old_size );
if ( ! alignment ) if ( ! alignment )

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "debug.hpp" # include "debug.hpp"
#endif #endif
@ -41,10 +41,10 @@ void const* pointer_add_const( void const* ptr, ssize bytes );
ssize pointer_diff( void const* begin, void const* end ); ssize pointer_diff( void const* begin, void const* end );
//! Copy non-overlapping memory from source to destination. //! Copy non-overlapping memory from source to destination.
void* mem_copy( void* dest, void const* source, ssize size ); GEN_API void* mem_copy( void* dest, void const* source, ssize size );
//! Search for a constant value within the size limit at memory location. //! Search for a constant value within the size limit at memory location.
void const* mem_find( void const* data, u8 byte_value, ssize size ); GEN_API void const* mem_find( void const* data, u8 byte_value, ssize size );
//! Copy memory from source to destination. //! Copy memory from source to destination.
void* mem_move( void* dest, void const* source, ssize size ); void* mem_move( void* dest, void const* source, ssize size );
@ -119,17 +119,17 @@ void* resize_align( AllocatorInfo a, void* ptr, ssize old_size, ssize new_size,
/* define GEN_HEAP_ANALYSIS to enable this feature */ /* define GEN_HEAP_ANALYSIS to enable this feature */
/* call zpl_heap_stats_init at the beginning of the entry point */ /* call zpl_heap_stats_init at the beginning of the entry point */
/* you can call zpl_heap_stats_check near the end of the execution to validate any possible leaks */ /* you can call zpl_heap_stats_check near the end of the execution to validate any possible leaks */
void heap_stats_init( void ); GEN_API void heap_stats_init( void );
ssize heap_stats_used_memory( void ); GEN_API ssize heap_stats_used_memory( void );
ssize heap_stats_alloc_count( void ); GEN_API ssize heap_stats_alloc_count( void );
void heap_stats_check( void ); GEN_API void heap_stats_check( void );
//! Allocate/Resize memory using default options. //! Allocate/Resize memory using default options.
//! Use this if you don't need a "fancy" resize allocation //! Use this if you don't need a "fancy" resize allocation
void* default_resize_align( AllocatorInfo a, void* ptr, ssize old_size, ssize new_size, ssize alignment ); void* default_resize_align( AllocatorInfo a, void* ptr, ssize old_size, ssize new_size, ssize alignment );
void* heap_allocator_proc( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags ); GEN_API void* heap_allocator_proc( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags );
//! The heap allocator backed by operating system's memory manager. //! The heap allocator backed by operating system's memory manager.
constexpr AllocatorInfo heap( void ) { AllocatorInfo allocator = { heap_allocator_proc, nullptr }; return allocator; } constexpr AllocatorInfo heap( void ) { AllocatorInfo allocator = { heap_allocator_proc, nullptr }; return allocator; }
@ -147,25 +147,25 @@ struct VirtualMemory
}; };
//! Initialize virtual memory from existing data. //! Initialize virtual memory from existing data.
VirtualMemory vm_from_memory( void* data, ssize size ); GEN_API VirtualMemory vm_from_memory( void* data, ssize size );
//! Allocate virtual memory at address with size. //! Allocate virtual memory at address with size.
//! @param addr The starting address of the region to reserve. If NULL, it lets operating system to decide where to allocate it. //! @param addr The starting address of the region to reserve. If NULL, it lets operating system to decide where to allocate it.
//! @param size The size to serve. //! @param size The size to serve.
VirtualMemory vm_alloc( void* addr, ssize size ); GEN_API VirtualMemory vm_alloc( void* addr, ssize size );
//! Release the virtual memory. //! Release the virtual memory.
b32 vm_free( VirtualMemory vm ); GEN_API b32 vm_free( VirtualMemory vm );
//! Trim virtual memory. //! Trim virtual memory.
VirtualMemory vm_trim( VirtualMemory vm, ssize lead_size, ssize size ); GEN_API VirtualMemory vm_trim( VirtualMemory vm, ssize lead_size, ssize size );
//! Purge virtual memory. //! Purge virtual memory.
b32 vm_purge( VirtualMemory vm ); GEN_API b32 vm_purge( VirtualMemory vm );
//! Retrieve VM's page size and alignment. //! Retrieve VM's page size and alignment.
ssize virtual_memory_page_size( ssize* alignment_out ); GEN_API ssize virtual_memory_page_size( ssize* alignment_out );
#pragma region Arena #pragma region Arena
struct Arena; struct Arena;
@ -173,7 +173,7 @@ struct Arena;
AllocatorInfo arena_allocator_info( Arena* arena ); AllocatorInfo arena_allocator_info( Arena* arena );
// Remove static keyword and rename allocator_proc // Remove static keyword and rename allocator_proc
void* arena_allocator_proc(void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags); GEN_API void* arena_allocator_proc(void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags);
// Add these declarations after the Arena struct // Add these declarations after the Arena struct
Arena arena_init_from_allocator(AllocatorInfo backing, ssize size); Arena arena_init_from_allocator(AllocatorInfo backing, ssize size);
@ -382,13 +382,13 @@ using FixedArena_4MB = FixedArena< megabytes( 4 ) >;
#pragma region Pool #pragma region Pool
struct Pool; struct Pool;
void* pool_allocator_proc(void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags); GEN_API void* pool_allocator_proc(void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags);
Pool pool_init(AllocatorInfo backing, ssize num_blocks, ssize block_size); Pool pool_init(AllocatorInfo backing, ssize num_blocks, ssize block_size);
Pool pool_init_align(AllocatorInfo backing, ssize num_blocks, ssize block_size, ssize block_align); Pool pool_init_align(AllocatorInfo backing, ssize num_blocks, ssize block_size, ssize block_align);
AllocatorInfo pool_allocator_info(Pool* pool); AllocatorInfo pool_allocator_info(Pool* pool);
void pool_clear(Pool* pool); GEN_API void pool_clear(Pool* pool);
void pool_free(Pool* pool); void pool_free(Pool* pool);
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP #if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
forceinline AllocatorInfo allocator_info(Pool& pool) { return pool_allocator_info(& pool); } forceinline AllocatorInfo allocator_info(Pool& pool) { return pool_allocator_info(& pool); }

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "parsing.hpp" # include "parsing.hpp"
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "timing.hpp" # include "timing.hpp"
#endif #endif
@ -122,7 +122,7 @@ struct ADT_Node
* @param is_array * @param is_array
* @return error code * @return error code
*/ */
u8 adt_make_branch( ADT_Node* node, AllocatorInfo backing, char const* name, b32 is_array ); GEN_API u8 adt_make_branch( ADT_Node* node, AllocatorInfo backing, char const* name, b32 is_array );
/** /**
* @brief Destroy an ADT branch and its descendants * @brief Destroy an ADT branch and its descendants
@ -130,7 +130,7 @@ u8 adt_make_branch( ADT_Node* node, AllocatorInfo backing, char const* name, b32
* @param node * @param node
* @return error code * @return error code
*/ */
u8 adt_destroy_branch( ADT_Node* node ); GEN_API u8 adt_destroy_branch( ADT_Node* node );
/** /**
* @brief Initialise an ADT leaf * @brief Initialise an ADT leaf
@ -140,7 +140,7 @@ u8 adt_destroy_branch( ADT_Node* node );
* @param type Node's type (use zpl_adt_make_branch for container nodes) * @param type Node's type (use zpl_adt_make_branch for container nodes)
* @return error code * @return error code
*/ */
u8 adt_make_leaf( ADT_Node* node, char const* name, ADT_Type type ); GEN_API u8 adt_make_leaf( ADT_Node* node, char const* name, ADT_Type type );
/** /**
@ -160,7 +160,7 @@ u8 adt_make_leaf( ADT_Node* node, char const* name, ADT_Type type );
* *
* @see code/apps/examples/json_get.c * @see code/apps/examples/json_get.c
*/ */
ADT_Node* adt_query( ADT_Node* node, char const* uri ); GEN_API ADT_Node* adt_query( ADT_Node* node, char const* uri );
/** /**
* @brief Find a field node within an object by the given name. * @brief Find a field node within an object by the given name.
@ -170,7 +170,7 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri );
* @param deep_search Perform search recursively * @param deep_search Perform search recursively
* @return zpl_adt_node * node * @return zpl_adt_node * node
*/ */
ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search ); GEN_API ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search );
/** /**
* @brief Allocate an unitialised node within a container at a specified index. * @brief Allocate an unitialised node within a container at a specified index.
@ -179,7 +179,7 @@ ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search );
* @param index * @param index
* @return zpl_adt_node * node * @return zpl_adt_node * node
*/ */
ADT_Node* adt_alloc_at( ADT_Node* parent, ssize index ); GEN_API ADT_Node* adt_alloc_at( ADT_Node* parent, ssize index );
/** /**
* @brief Allocate an unitialised node within a container. * @brief Allocate an unitialised node within a container.
@ -187,7 +187,7 @@ ADT_Node* adt_alloc_at( ADT_Node* parent, ssize index );
* @param parent * @param parent
* @return zpl_adt_node * node * @return zpl_adt_node * node
*/ */
ADT_Node* adt_alloc( ADT_Node* parent ); GEN_API ADT_Node* adt_alloc( ADT_Node* parent );
/** /**
* @brief Move an existing node to a new container at a specified index. * @brief Move an existing node to a new container at a specified index.
@ -197,7 +197,7 @@ ADT_Node* adt_alloc( ADT_Node* parent );
* @param index * @param index
* @return zpl_adt_node * node * @return zpl_adt_node * node
*/ */
ADT_Node* adt_move_node_at( ADT_Node* node, ADT_Node* new_parent, ssize index ); GEN_API ADT_Node* adt_move_node_at( ADT_Node* node, ADT_Node* new_parent, ssize index );
/** /**
* @brief Move an existing node to a new container. * @brief Move an existing node to a new container.
@ -206,7 +206,7 @@ ADT_Node* adt_move_node_at( ADT_Node* node, ADT_Node* new_parent, ssize index );
* @param new_parent * @param new_parent
* @return zpl_adt_node * node * @return zpl_adt_node * node
*/ */
ADT_Node* adt_move_node( ADT_Node* node, ADT_Node* new_parent ); GEN_API ADT_Node* adt_move_node( ADT_Node* node, ADT_Node* new_parent );
/** /**
* @brief Swap two nodes. * @brief Swap two nodes.
@ -215,7 +215,7 @@ ADT_Node* adt_move_node( ADT_Node* node, ADT_Node* new_parent );
* @param other_node * @param other_node
* @return * @return
*/ */
void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node ); GEN_API void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node );
/** /**
* @brief Remove node from container. * @brief Remove node from container.
@ -223,7 +223,7 @@ void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node );
* @param node * @param node
* @return * @return
*/ */
void adt_remove_node( ADT_Node* node ); GEN_API void adt_remove_node( ADT_Node* node );
/** /**
* @brief Initialise a node as an object * @brief Initialise a node as an object
@ -233,7 +233,7 @@ void adt_remove_node( ADT_Node* node );
* @param backing * @param backing
* @return * @return
*/ */
b8 adt_set_obj( ADT_Node* obj, char const* name, AllocatorInfo backing ); GEN_API b8 adt_set_obj( ADT_Node* obj, char const* name, AllocatorInfo backing );
/** /**
* @brief Initialise a node as an array * @brief Initialise a node as an array
@ -243,7 +243,7 @@ b8 adt_set_obj( ADT_Node* obj, char const* name, AllocatorInfo backing );
* @param backing * @param backing
* @return * @return
*/ */
b8 adt_set_arr( ADT_Node* obj, char const* name, AllocatorInfo backing ); GEN_API b8 adt_set_arr( ADT_Node* obj, char const* name, AllocatorInfo backing );
/** /**
* @brief Initialise a node as a string * @brief Initialise a node as a string
@ -253,7 +253,7 @@ b8 adt_set_arr( ADT_Node* obj, char const* name, AllocatorInfo backing );
* @param value * @param value
* @return * @return
*/ */
b8 adt_set_str( ADT_Node* obj, char const* name, char const* value ); GEN_API b8 adt_set_str( ADT_Node* obj, char const* name, char const* value );
/** /**
* @brief Initialise a node as a float * @brief Initialise a node as a float
@ -263,7 +263,7 @@ b8 adt_set_str( ADT_Node* obj, char const* name, char const* value );
* @param value * @param value
* @return * @return
*/ */
b8 adt_set_flt( ADT_Node* obj, char const* name, f64 value ); GEN_API b8 adt_set_flt( ADT_Node* obj, char const* name, f64 value );
/** /**
* @brief Initialise a node as a signed integer * @brief Initialise a node as a signed integer
@ -273,7 +273,7 @@ b8 adt_set_flt( ADT_Node* obj, char const* name, f64 value );
* @param value * @param value
* @return * @return
*/ */
b8 adt_set_int( ADT_Node* obj, char const* name, s64 value ); GEN_API b8 adt_set_int( ADT_Node* obj, char const* name, s64 value );
/** /**
* @brief Append a new node to a container as an object * @brief Append a new node to a container as an object
@ -282,7 +282,7 @@ b8 adt_set_int( ADT_Node* obj, char const* name, s64 value );
* @param name * @param name
* @return* * @return*
*/ */
ADT_Node* adt_append_obj( ADT_Node* parent, char const* name ); GEN_API ADT_Node* adt_append_obj( ADT_Node* parent, char const* name );
/** /**
* @brief Append a new node to a container as an array * @brief Append a new node to a container as an array
@ -291,7 +291,7 @@ ADT_Node* adt_append_obj( ADT_Node* parent, char const* name );
* @param name * @param name
* @return* * @return*
*/ */
ADT_Node* adt_append_arr( ADT_Node* parent, char const* name ); GEN_API ADT_Node* adt_append_arr( ADT_Node* parent, char const* name );
/** /**
* @brief Append a new node to a container as a string * @brief Append a new node to a container as a string
@ -301,7 +301,7 @@ ADT_Node* adt_append_arr( ADT_Node* parent, char const* name );
* @param value * @param value
* @return* * @return*
*/ */
ADT_Node* adt_append_str( ADT_Node* parent, char const* name, char const* value ); GEN_API ADT_Node* adt_append_str( ADT_Node* parent, char const* name, char const* value );
/** /**
* @brief Append a new node to a container as a float * @brief Append a new node to a container as a float
@ -311,7 +311,7 @@ ADT_Node* adt_append_str( ADT_Node* parent, char const* name, char const* value
* @param value * @param value
* @return* * @return*
*/ */
ADT_Node* adt_append_flt( ADT_Node* parent, char const* name, f64 value ); GEN_API ADT_Node* adt_append_flt( ADT_Node* parent, char const* name, f64 value );
/** /**
* @brief Append a new node to a container as a signed integer * @brief Append a new node to a container as a signed integer
@ -321,7 +321,7 @@ ADT_Node* adt_append_flt( ADT_Node* parent, char const* name, f64 value );
* @param value * @param value
* @return* * @return*
*/ */
ADT_Node* adt_append_int( ADT_Node* parent, char const* name, s64 value ); GEN_API ADT_Node* adt_append_int( ADT_Node* parent, char const* name, s64 value );
/* parser helpers */ /* parser helpers */
@ -332,7 +332,7 @@ ADT_Node* adt_append_int( ADT_Node* parent, char const* name, s64 value );
* @param base * @param base
* @return* * @return*
*/ */
char* adt_parse_number( ADT_Node* node, char* base ); GEN_API char* adt_parse_number( ADT_Node* node, char* base );
/** /**
* @brief Parses a text and stores the result into an unitialised node. * @brief Parses a text and stores the result into an unitialised node.
@ -342,7 +342,7 @@ char* adt_parse_number( ADT_Node* node, char* base );
* @param base * @param base
* @return* * @return*
*/ */
char* adt_parse_number_strict( ADT_Node* node, char* base_str ); GEN_API char* adt_parse_number_strict( ADT_Node* node, char* base_str );
/** /**
* @brief Parses and converts an existing string node into a number. * @brief Parses and converts an existing string node into a number.
@ -350,7 +350,7 @@ char* adt_parse_number_strict( ADT_Node* node, char* base_str );
* @param node * @param node
* @return * @return
*/ */
ADT_Error adt_c_str_to_number( ADT_Node* node ); GEN_API ADT_Error adt_c_str_to_number( ADT_Node* node );
/** /**
* @brief Parses and converts an existing string node into a number. * @brief Parses and converts an existing string node into a number.
@ -359,7 +359,7 @@ ADT_Error adt_c_str_to_number( ADT_Node* node );
* @param node * @param node
* @return * @return
*/ */
ADT_Error adt_c_str_to_number_strict( ADT_Node* node ); GEN_API ADT_Error adt_c_str_to_number_strict( ADT_Node* node );
/** /**
* @brief Prints a number into a file stream. * @brief Prints a number into a file stream.
@ -371,7 +371,7 @@ ADT_Error adt_c_str_to_number_strict( ADT_Node* node );
* @param node * @param node
* @return * @return
*/ */
ADT_Error adt_print_number( FileInfo* file, ADT_Node* node ); GEN_API ADT_Error adt_print_number( FileInfo* file, ADT_Node* node );
/** /**
* @brief Prints a string into a file stream. * @brief Prints a string into a file stream.
@ -385,7 +385,7 @@ ADT_Error adt_print_number( FileInfo* file, ADT_Node* node );
* @param escape_symbol * @param escape_symbol
* @return * @return
*/ */
ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_chars, char const* escape_symbol ); GEN_API ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_chars, char const* escape_symbol );
#pragma endregion ADT #pragma endregion ADT
@ -401,14 +401,14 @@ enum CSV_Error : u32
typedef ADT_Node CSV_Object; typedef ADT_Node CSV_Object;
u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header ); u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header );
u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header, char delim ); GEN_API u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header, char delim );
void csv_free( CSV_Object* obj ); void csv_free( CSV_Object* obj );
void csv_write( FileInfo* file, CSV_Object* obj ); void csv_write( FileInfo* file, CSV_Object* obj );
StrBuilder csv_write_string( AllocatorInfo a, CSV_Object* obj ); StrBuilder csv_write_string( AllocatorInfo a, CSV_Object* obj );
void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delim ); GEN_API void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delim );
StrBuilder csv_write_strbuilder_delimiter( AllocatorInfo a, CSV_Object* obj, char delim ); GEN_API StrBuilder csv_write_strbuilder_delimiter( AllocatorInfo a, CSV_Object* obj, char delim );
/* inline */ /* inline */

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "strbuilder_ops.cpp" # include "strbuilder_ops.cpp"
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "strbuilder_ops.hpp" # include "strbuilder_ops.hpp"
#endif #endif
@ -13,15 +13,15 @@ typedef struct FileInfo FileInfo;
typedef char PrintF_Buffer[GEN_PRINTF_MAXLEN]; typedef char PrintF_Buffer[GEN_PRINTF_MAXLEN];
// NOTE: A locally persisting buffer is used internally // NOTE: A locally persisting buffer is used internally
char* c_str_fmt_buf ( char const* fmt, ... ); GEN_API char* c_str_fmt_buf ( char const* fmt, ... );
char* c_str_fmt_buf_va ( char const* fmt, va_list va ); GEN_API char* c_str_fmt_buf_va ( char const* fmt, va_list va );
ssize c_str_fmt ( char* str, ssize n, char const* fmt, ... ); GEN_API ssize c_str_fmt ( char* str, ssize n, char const* fmt, ... );
ssize c_str_fmt_va ( char* str, ssize n, char const* fmt, va_list va ); GEN_API ssize c_str_fmt_va ( char* str, ssize n, char const* fmt, va_list va );
ssize c_str_fmt_out_va ( char const* fmt, va_list va ); GEN_API ssize c_str_fmt_out_va ( char const* fmt, va_list va );
ssize c_str_fmt_out_err ( char const* fmt, ... ); GEN_API ssize c_str_fmt_out_err ( char const* fmt, ... );
ssize c_str_fmt_out_err_va( char const* fmt, va_list va ); GEN_API ssize c_str_fmt_out_err_va( char const* fmt, va_list va );
ssize c_str_fmt_file ( FileInfo* f, char const* fmt, ... ); GEN_API ssize c_str_fmt_file ( FileInfo* f, char const* fmt, ... );
ssize c_str_fmt_file_va ( FileInfo* f, char const* fmt, va_list va ); GEN_API ssize c_str_fmt_file_va ( FileInfo* f, char const* fmt, va_list va );
constexpr constexpr
char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED"; char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "header_start.hpp" # include "header_start.hpp"
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "debug.cpp" # include "debug.cpp"
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "memory.hpp" # include "memory.hpp"
#endif #endif
@ -33,10 +33,10 @@ char const* c_str_trim( char const* str, b32 catch_newline );
void c_str_to_lower( char* str ); void c_str_to_lower( char* str );
void c_str_to_upper( char* str ); void c_str_to_upper( char* str );
s64 c_str_to_i64( const char* str, char** end_ptr, s32 base ); GEN_API s64 c_str_to_i64( const char* str, char** end_ptr, s32 base );
void i64_to_str( s64 value, char* string, s32 base ); GEN_API void i64_to_str( s64 value, char* string, s32 base );
void u64_to_str( u64 value, char* string, s32 base ); GEN_API void u64_to_str( u64 value, char* string, s32 base );
f64 c_str_to_f64( const char* str, char** end_ptr ); GEN_API f64 c_str_to_f64( const char* str, char** end_ptr );
inline inline
const char* char_first_occurence( const char* s, char c ) const char* char_first_occurence( const char* s, char c )

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "hashing.cpp" # include "hashing.cpp"
#endif #endif
@ -58,4 +58,120 @@ StrBuilder strbuilder_make_reserve( AllocatorInfo allocator, ssize capacity )
return result; return result;
} }
bool strbuilder_make_space_for(StrBuilder* str, char const* to_append, ssize add_len)
{
ssize available = strbuilder_avail_space(* str);
if (available >= add_len) {
return true;
}
else
{
ssize new_len, old_size, new_size;
void* ptr;
void* new_ptr;
AllocatorInfo allocator = strbuilder_get_header(* str)->Allocator;
StrBuilderHeader* header = nullptr;
new_len = strbuilder_grow_formula(strbuilder_length(* str) + add_len);
ptr = strbuilder_get_header(* str);
old_size = size_of(StrBuilderHeader) + strbuilder_length(* str) + 1;
new_size = size_of(StrBuilderHeader) + new_len + 1;
new_ptr = resize(allocator, ptr, old_size, new_size);
if (new_ptr == nullptr)
return false;
header = rcast(StrBuilderHeader*, new_ptr);
header->Allocator = allocator;
header->Capacity = new_len;
char** Data = rcast(char**, str);
* Data = rcast(char*, header + 1);
return true;
}
}
bool strbuilder_append_c_str_len(StrBuilder* str, char const* c_str_to_append, ssize append_length)
{
GEN_ASSERT(str != nullptr);
if ( rcast(sptr, c_str_to_append) > 0)
{
ssize curr_len = strbuilder_length(* str);
if ( ! strbuilder_make_space_for(str, c_str_to_append, append_length))
return false;
StrBuilderHeader* header = strbuilder_get_header(* str);
char* Data = * str;
mem_copy( Data + curr_len, c_str_to_append, append_length);
Data[curr_len + append_length] = '\0';
header->Length = curr_len + append_length;
}
return c_str_to_append != nullptr;
}
void strbuilder_trim(StrBuilder str, char const* cut_set)
{
ssize len = 0;
char* start_pos = str;
char* end_pos = scast(char*, str) + strbuilder_length(str) - 1;
while (start_pos <= end_pos && char_first_occurence(cut_set, *start_pos))
start_pos++;
while (end_pos > start_pos && char_first_occurence(cut_set, *end_pos))
end_pos--;
len = scast(ssize, (start_pos > end_pos) ? 0 : ((end_pos - start_pos) + 1));
if (str != start_pos)
mem_move(str, start_pos, len);
str[len] = '\0';
strbuilder_get_header(str)->Length = len;
}
StrBuilder strbuilder_visualize_whitespace(StrBuilder const str)
{
StrBuilderHeader* header = (StrBuilderHeader*)(scast(char const*, str) - sizeof(StrBuilderHeader));
StrBuilder result = strbuilder_make_reserve(header->Allocator, strbuilder_length(str) * 2); // Assume worst case for space requirements.
for (char const* c = strbuilder_begin(str); c != strbuilder_end(str); c = strbuilder_next(str, c))
switch ( * c )
{
case ' ':
strbuilder_append_str(& result, txt("·"));
break;
case '\t':
strbuilder_append_str(& result, txt(""));
break;
case '\n':
strbuilder_append_str(& result, txt(""));
break;
case '\r':
strbuilder_append_str(& result, txt(""));
break;
case '\v':
strbuilder_append_str(& result, txt(""));
break;
case '\f':
strbuilder_append_str(& result, txt(""));
break;
default:
strbuilder_append_char(& result, * c);
break;
}
return result;
}
#pragma endregion StrBuilder #pragma endregion StrBuilder

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "hashing.hpp" # include "hashing.hpp"
#endif #endif
@ -122,19 +122,22 @@ struct StrBuilder;
forceinline usize strbuilder_grow_formula(usize value); forceinline usize strbuilder_grow_formula(usize value);
GEN_API StrBuilder strbuilder_make_reserve (AllocatorInfo allocator, ssize capacity);
GEN_API StrBuilder strbuilder_make_length (AllocatorInfo allocator, char const* str, ssize length);
GEN_API bool strbuilder_make_space_for (StrBuilder* str, char const* to_append, ssize add_len);
GEN_API bool strbuilder_append_c_str_len (StrBuilder* str, char const* c_str_to_append, ssize length);
GEN_API void strbuilder_trim (StrBuilder str, char const* cut_set);
GEN_API StrBuilder strbuilder_visualize_whitespace(StrBuilder const str);
StrBuilder strbuilder_make_c_str (AllocatorInfo allocator, char const* str); StrBuilder strbuilder_make_c_str (AllocatorInfo allocator, char const* str);
StrBuilder strbuilder_make_str (AllocatorInfo allocator, Str str); StrBuilder strbuilder_make_str (AllocatorInfo allocator, Str str);
StrBuilder strbuilder_make_reserve (AllocatorInfo allocator, ssize capacity);
StrBuilder strbuilder_make_length (AllocatorInfo allocator, char const* str, ssize length);
StrBuilder strbuilder_fmt (AllocatorInfo allocator, char* buf, ssize buf_size, char const* fmt, ...); StrBuilder strbuilder_fmt (AllocatorInfo allocator, char* buf, ssize buf_size, char const* fmt, ...);
StrBuilder strbuilder_fmt_buf (AllocatorInfo allocator, char const* fmt, ...); StrBuilder strbuilder_fmt_buf (AllocatorInfo allocator, char const* fmt, ...);
StrBuilder strbuilder_join (AllocatorInfo allocator, char const** parts, ssize num_parts, char const* glue); StrBuilder strbuilder_join (AllocatorInfo allocator, char const** parts, ssize num_parts, char const* glue);
bool strbuilder_are_equal (StrBuilder const lhs, StrBuilder const rhs); bool strbuilder_are_equal (StrBuilder const lhs, StrBuilder const rhs);
bool strbuilder_are_equal_str (StrBuilder const lhs, Str rhs); bool strbuilder_are_equal_str (StrBuilder const lhs, Str rhs);
bool strbuilder_make_space_for (StrBuilder* str, char const* to_append, ssize add_len);
bool strbuilder_append_char (StrBuilder* str, char c); bool strbuilder_append_char (StrBuilder* str, char c);
bool strbuilder_append_c_str (StrBuilder* str, char const* c_str_to_append); bool strbuilder_append_c_str (StrBuilder* str, char const* c_str_to_append);
bool strbuilder_append_c_str_len (StrBuilder* str, char const* c_str_to_append, ssize length);
bool strbuilder_append_str (StrBuilder* str, Str c_str_to_append); bool strbuilder_append_str (StrBuilder* str, Str c_str_to_append);
bool strbuilder_append_string (StrBuilder* str, StrBuilder const other); bool strbuilder_append_string (StrBuilder* str, StrBuilder const other);
bool strbuilder_append_fmt (StrBuilder* str, char const* fmt, ...); bool strbuilder_append_fmt (StrBuilder* str, char const* fmt, ...);
@ -153,9 +156,7 @@ b32 strbuilder_starts_with_string (StrBuilder const str, StrBuild
void strbuilder_skip_line (StrBuilder str); void strbuilder_skip_line (StrBuilder str);
void strbuilder_strip_space (StrBuilder str); void strbuilder_strip_space (StrBuilder str);
Str strbuilder_to_str (StrBuilder str); Str strbuilder_to_str (StrBuilder str);
void strbuilder_trim (StrBuilder str, char const* cut_set);
void strbuilder_trim_space (StrBuilder str); void strbuilder_trim_space (StrBuilder str);
StrBuilder strbuilder_visualize_whitespace(StrBuilder const str);
struct StrBuilderHeader { struct StrBuilderHeader {
AllocatorInfo Allocator; AllocatorInfo Allocator;
@ -357,29 +358,6 @@ bool strbuilder_append_c_str(StrBuilder* str, char const* c_str_to_append) {
return strbuilder_append_c_str_len(str, c_str_to_append, c_str_len(c_str_to_append)); return strbuilder_append_c_str_len(str, c_str_to_append, c_str_len(c_str_to_append));
} }
inline
bool strbuilder_append_c_str_len(StrBuilder* str, char const* c_str_to_append, ssize append_length)
{
GEN_ASSERT(str != nullptr);
if ( rcast(sptr, c_str_to_append) > 0)
{
ssize curr_len = strbuilder_length(* str);
if ( ! strbuilder_make_space_for(str, c_str_to_append, append_length))
return false;
StrBuilderHeader* header = strbuilder_get_header(* str);
char* Data = * str;
mem_copy( Data + curr_len, c_str_to_append, append_length);
Data[curr_len + append_length] = '\0';
header->Length = curr_len + append_length;
}
return c_str_to_append != nullptr;
}
forceinline forceinline
bool strbuilder_append_str(StrBuilder* str, Str c_str_to_append) { bool strbuilder_append_str(StrBuilder* str, Str c_str_to_append) {
GEN_ASSERT(str != nullptr); GEN_ASSERT(str != nullptr);
@ -521,44 +499,6 @@ ssize strbuilder_length(StrBuilder const str)
return header->Length; return header->Length;
} }
inline
bool strbuilder_make_space_for(StrBuilder* str, char const* to_append, ssize add_len)
{
ssize available = strbuilder_avail_space(* str);
if (available >= add_len) {
return true;
}
else
{
ssize new_len, old_size, new_size;
void* ptr;
void* new_ptr;
AllocatorInfo allocator = strbuilder_get_header(* str)->Allocator;
StrBuilderHeader* header = nullptr;
new_len = strbuilder_grow_formula(strbuilder_length(* str) + add_len);
ptr = strbuilder_get_header(* str);
old_size = size_of(StrBuilderHeader) + strbuilder_length(* str) + 1;
new_size = size_of(StrBuilderHeader) + new_len + 1;
new_ptr = resize(allocator, ptr, old_size, new_size);
if (new_ptr == nullptr)
return false;
header = rcast(StrBuilderHeader*, new_ptr);
header->Allocator = allocator;
header->Capacity = new_len;
char** Data = rcast(char**, str);
* Data = rcast(char*, header + 1);
return true;
}
}
forceinline forceinline
b32 strbuilder_starts_with_str(StrBuilder const str, Str substring) { b32 strbuilder_starts_with_str(StrBuilder const str, Str substring) {
if (substring.Len > strbuilder_length(str)) if (substring.Len > strbuilder_length(str))
@ -626,69 +566,11 @@ Str strbuilder_to_str(StrBuilder str) {
return result; return result;
} }
inline
void strbuilder_trim(StrBuilder str, char const* cut_set)
{
ssize len = 0;
char* start_pos = str;
char* end_pos = scast(char*, str) + strbuilder_length(str) - 1;
while (start_pos <= end_pos && char_first_occurence(cut_set, *start_pos))
start_pos++;
while (end_pos > start_pos && char_first_occurence(cut_set, *end_pos))
end_pos--;
len = scast(ssize, (start_pos > end_pos) ? 0 : ((end_pos - start_pos) + 1));
if (str != start_pos)
mem_move(str, start_pos, len);
str[len] = '\0';
strbuilder_get_header(str)->Length = len;
}
forceinline forceinline
void strbuilder_trim_space(StrBuilder str) { void strbuilder_trim_space(StrBuilder str) {
strbuilder_trim(str, " \t\r\n\v\f"); strbuilder_trim(str, " \t\r\n\v\f");
} }
inline
StrBuilder strbuilder_visualize_whitespace(StrBuilder const str)
{
StrBuilderHeader* header = (StrBuilderHeader*)(scast(char const*, str) - sizeof(StrBuilderHeader));
StrBuilder result = strbuilder_make_reserve(header->Allocator, strbuilder_length(str) * 2); // Assume worst case for space requirements.
for (char const* c = strbuilder_begin(str); c != strbuilder_end(str); c = strbuilder_next(str, c))
switch ( * c )
{
case ' ':
strbuilder_append_str(& result, txt("·"));
break;
case '\t':
strbuilder_append_str(& result, txt(""));
break;
case '\n':
strbuilder_append_str(& result, txt(""));
break;
case '\r':
strbuilder_append_str(& result, txt(""));
break;
case '\v':
strbuilder_append_str(& result, txt(""));
break;
case '\f':
strbuilder_append_str(& result, txt(""));
break;
default:
strbuilder_append_char(& result, * c);
break;
}
return result;
}
#pragma endregion StrBuilder #pragma endregion StrBuilder
#if GEN_COMPILER_CPP #if GEN_COMPILER_CPP

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "filesystem.cpp" # include "filesystem.cpp"
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# pragma once # pragma once
# include "filesystem.hpp" # include "filesystem.hpp"
#endif #endif
@ -7,13 +7,13 @@
#ifdef GEN_BENCHMARK #ifdef GEN_BENCHMARK
//! Return CPU timestamp. //! Return CPU timestamp.
u64 read_cpu_time_stamp_counter( void ); GEN_API u64 read_cpu_time_stamp_counter( void );
//! Return relative time (in seconds) since the application start. //! Return relative time (in seconds) since the application start.
f64 time_rel( void ); GEN_API f64 time_rel( void );
//! Return relative time since the application start. //! Return relative time since the application start.
u64 time_rel_ms( void ); GEN_API u64 time_rel_ms( void );
#endif #endif
#pragma endregion Timing #pragma endregion Timing

View File

@ -24,4 +24,5 @@ Final, final
NoExceptions, noexcept NoExceptions, noexcept
Override, override Override, override
Pure, = 0 Pure, = 0
Delete, = delete
Volatile, volatile Volatile, volatile

1 Invalid INVALID
24 NoExceptions noexcept
25 Override override
26 Pure = 0
27 Delete = delete
28 Volatile volatile

View File

@ -29,9 +29,9 @@ GEN_NS_BEGIN
#include "components/interface.hpp" #include "components/interface.hpp"
#include "components/constants.hpp"
#include "components/inlines.hpp" #include "components/inlines.hpp"
#include "components/gen/ast_inlines.hpp" #include "components/gen/ast_inlines.hpp"
#include "components/header_end.hpp"
#include "auxiliary/builder.hpp" #include "auxiliary/builder.hpp"
#include "auxiliary/scanner.hpp" #include "auxiliary/scanner.hpp"

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#if GEN_INTELLISENSE_DIRECTIVES #if INTELLISENSE_DIRECTIVES
# include "../gen.hpp" # include "../gen.hpp"
# include "misc.hpp" # include "misc.hpp"
@ -220,6 +220,7 @@ CodeBody gen_especifier( char const* path, bool use_c_definition = false )
case Spec_NoExceptions: case Spec_NoExceptions:
case Spec_Override: case Spec_Override:
case Spec_Pure: case Spec_Pure:
case Spec_Delete:
case Spec_Volatile: case Spec_Volatile:
return true; return true;

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef INTELLISENSE_DIRECTIVES
# define GEN_DEFINE_LIBRARY_CODE_CONSTANTS # define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
# define GEN_ENFORCE_STRONG_CODE_TYPES # define GEN_ENFORCE_STRONG_CODE_TYPES
# define GEN_EXPOSE_BACKEND # define GEN_EXPOSE_BACKEND

View File

@ -53,7 +53,7 @@ StrBuilder <prefix>_to_strbuilder(Code code);
Where the first generates strings allocated using Allocator_StringArena and the other appends an existing strings with their backed allocator. Where the first generates strings allocated using Allocator_StringArena and the other appends an existing strings with their backed allocator.
Serialization of for the AST is defined for `Code` in [`ast.cpp`](../base/components/ast.cpp) with `code_to_strbuilder_ptr` & `code_to_strbuilder`. Serialization of for the AST is defined for `Code` in [`ast.cpp`](../base/components/ast.cpp) with `code_to_strbuilder_ref` & `code_to_strbuilder`.
Serializtion for the rest of the code types is within [`code_serialization.cpp`](../base/components/code_serialization.cpp). Serializtion for the rest of the code types is within [`code_serialization.cpp`](../base/components/code_serialization.cpp).
Gencpp's serialization does not provide coherent formatting of the code. The user should use a formatter after serializing. Gencpp's serialization does not provide coherent formatting of the code. The user should use a formatter after serializing.

View File

@ -306,7 +306,7 @@ do \
break; break;
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_memory, header_memory ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_header_memory, header_memory );
if (found) break; if (found) break;
header_memory.append(entry); header_memory.append(entry);
@ -334,7 +334,7 @@ do \
{ {
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_printing, header_printing ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_header_printing, header_printing );
if (found) break; if (found) break;
header_printing.append(entry); header_printing.append(entry);
@ -391,7 +391,7 @@ do \
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_strings, header_strings ); ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_header_strings, header_strings );
} }
break; break;
@ -472,7 +472,7 @@ do \
{ {
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_filesystem, header_filesystem ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_header_filesystem, header_filesystem );
if (found) break; if (found) break;
header_filesystem.append(entry); header_filesystem.append(entry);
@ -509,7 +509,7 @@ do \
case CT_Variable: case CT_Variable:
{ {
CodeVar var = cast(CodeVar, entry); CodeVar var = cast(CodeVar, entry);
if (var->Specs.has(Spec_Constexpr) > -1) if (var->Specs.has(Spec_Constexpr))
{ {
Opts_def_define opts = { {}, entry->Value->Content }; Opts_def_define opts = { {}, entry->Value->Content };
CodeDefine define = def_define(entry->Name, MT_Expression, opts); CodeDefine define = def_define(entry->Name, MT_Expression, opts);
@ -532,7 +532,7 @@ do \
{ {
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_parsing, header_parsing ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_header_parsing, header_parsing );
if (found) break; if (found) break;
header_parsing.append(entry); header_parsing.append(entry);
@ -640,7 +640,7 @@ do \
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_types, types ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_types, types );
if (found) break; if (found) break;
types.append(entry); types.append(entry);
@ -702,7 +702,7 @@ do \
{ {
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_parser_types, parser_types ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_parser_types, parser_types );
if (found) break; if (found) break;
parser_types.append(entry); parser_types.append(entry);
@ -769,7 +769,7 @@ do \
case CT_Variable: case CT_Variable:
{ {
CodeVar var = cast(CodeVar, entry); CodeVar var = cast(CodeVar, entry);
if (var->Specs && var->Specs.has(Spec_Constexpr) > -1) { if (var->Specs && var->Specs.has(Spec_Constexpr)) {
Code define_ver = untyped_str(token_fmt( Code define_ver = untyped_str(token_fmt(
"name", var->Name "name", var->Name
, "value", var->Value->Content , "value", var->Value->Content
@ -797,7 +797,7 @@ do \
{ {
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_ast, ast ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_ast, ast );
if (found) break; if (found) break;
found = ignore_preprocess_cond_block(txt("GEN_EXECUTION_EXPRESSION_SUPPORT"), entry, parsed_ast, ast ); found = ignore_preprocess_cond_block(txt("GEN_EXECUTION_EXPRESSION_SUPPORT"), entry, parsed_ast, ast );
@ -978,7 +978,7 @@ R"(#define AST_ArrSpecs_Cap \
++ entry; // Skip a newline... ++ entry; // Skip a newline...
break; break;
} }
found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_code_types, code_types ); found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_code_types, code_types );
if (found) break; if (found) break;
found = ignore_preprocess_cond_block(txt("GEN_EXECUTION_EXPRESSION_SUPPORT"), entry, parsed_code_types, code_types); found = ignore_preprocess_cond_block(txt("GEN_EXECUTION_EXPRESSION_SUPPORT"), entry, parsed_code_types, code_types);
@ -1078,7 +1078,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
case CT_Preprocess_If: case CT_Preprocess_If:
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_ast_types, ast_types ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_ast_types, ast_types );
if (found) break; if (found) break;
found = ignore_preprocess_cond_block(txt("GEN_EXECUTION_EXPRESSION_SUPPORT"), entry, parsed_ast_types, ast_types); found = ignore_preprocess_cond_block(txt("GEN_EXECUTION_EXPRESSION_SUPPORT"), entry, parsed_ast_types, ast_types);
@ -1132,7 +1132,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
case CT_Preprocess_If: case CT_Preprocess_If:
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_interface, interface ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_interface, interface );
if (found) break; if (found) break;
found = ignore_preprocess_cond_block(txt("GEN_COMPILER_CPP"), entry, parsed_interface, interface); found = ignore_preprocess_cond_block(txt("GEN_COMPILER_CPP"), entry, parsed_interface, interface);
@ -1221,7 +1221,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
case CT_Preprocess_If: case CT_Preprocess_If:
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_inlines, inlines ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_inlines, inlines );
if (found) break; if (found) break;
found = ignore_preprocess_cond_block(txt("GEN_COMPILER_CPP"), entry, parsed_interface, interface); found = ignore_preprocess_cond_block(txt("GEN_COMPILER_CPP"), entry, parsed_interface, interface);
@ -1257,16 +1257,16 @@ R"(#define <interface_name>( code ) _Generic( (code), \
} }
s32 idx = 0; s32 idx = 0;
CodeBody parsed_header_end = parse_file( path_base "components/header_end.hpp" ); CodeBody parsed_constants = parse_file( path_base "components/constants.hpp" );
CodeBody header_end = def_body(CT_Global_Body); CodeBody constants = def_body(CT_Global_Body);
for ( Code entry = parsed_header_end.begin(); entry != parsed_header_end.end(); ++ entry, ++ idx ) switch( entry->Type ) for ( Code entry = parsed_constants.begin(); entry != parsed_constants.end(); ++ entry, ++ idx ) switch( entry->Type )
{ {
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_end, header_end ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_constants, constants );
if (found) break; if (found) break;
header_end.append(entry); constants.append(entry);
} }
break; break;
@ -1278,18 +1278,18 @@ R"(#define <interface_name>( code ) _Generic( (code), \
s32 constexpr_found = var->Specs.remove( Spec_Constexpr ); s32 constexpr_found = var->Specs.remove( Spec_Constexpr );
if (constexpr_found > -1) if (constexpr_found > -1)
{ {
Opts_def_define opts = { {}, entry->Value->Content }; Opts_def_define opts = { {}, entry->Value->Content };
CodeDefine define = def_define(entry->Name, MT_Expression, opts ); CodeDefine define = def_define(entry->Name, MT_Expression, opts );
header_end.append(define); constants.append(define);
continue; continue;
} }
} }
header_end.append(entry); constants.append(entry);
} }
break; break;
default: default:
header_end.append(entry); constants.append(entry);
break; break;
} }
#pragma endregion Resolve Components #pragma endregion Resolve Components
@ -1302,7 +1302,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
{ {
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_builder, header_builder ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_header_builder, header_builder );
if (found) break; if (found) break;
header_builder.append(entry); header_builder.append(entry);
@ -1446,7 +1446,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
{ {
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_src_ast, src_ast ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_src_ast, src_ast );
if (found) break; if (found) break;
src_ast.append(entry); src_ast.append(entry);
@ -1481,7 +1481,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
{ {
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_src_upfront, src_upfront ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_src_upfront, src_upfront );
if (found) break; if (found) break;
src_upfront.append(entry); src_upfront.append(entry);
@ -1520,7 +1520,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
{ {
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_src_lexer, src_lexer ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_src_lexer, src_lexer );
if (found) break; if (found) break;
src_lexer.append(entry); src_lexer.append(entry);
@ -1542,7 +1542,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
case CT_Variable: case CT_Variable:
{ {
CodeVar var = cast(CodeVar, entry); CodeVar var = cast(CodeVar, entry);
if (var->Specs && var->Specs.has(Spec_Constexpr) > -1) { if (var->Specs && var->Specs.has(Spec_Constexpr)) {
Code define_ver = untyped_str(token_fmt( Code define_ver = untyped_str(token_fmt(
"name", var->Name "name", var->Name
, "value", var->Value->Content , "value", var->Value->Content
@ -1569,7 +1569,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
{ {
case CT_Preprocess_IfDef: case CT_Preprocess_IfDef:
{ {
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_src_parser, src_parser ); b32 found = ignore_preprocess_cond_block(txt("INTELLISENSE_DIRECTIVES"), entry, parsed_src_parser, src_parser );
if (found) break; if (found) break;
src_parser.append(entry); src_parser.append(entry);
@ -1587,7 +1587,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
case CT_Variable: case CT_Variable:
{ {
CodeVar var = cast(CodeVar, entry); CodeVar var = cast(CodeVar, entry);
if (var->Specs && var->Specs.has(Spec_Constexpr) > -1) { if (var->Specs && var->Specs.has(Spec_Constexpr)) {
Code define_ver = untyped_str(token_fmt( Code define_ver = untyped_str(token_fmt(
"name", var->Name "name", var->Name
, "value", var->Value->Content , "value", var->Value->Content
@ -1673,11 +1673,11 @@ R"(#define <interface_name>( code ) _Generic( (code), \
Code rf_ast_types = refactor_and_format(ast_types); Code rf_ast_types = refactor_and_format(ast_types);
Code rf_interface = refactor_and_format(interface); Code rf_interface = refactor_and_format(interface);
Code rf_constants = refactor_and_format(constants);
Code rf_inlines = refactor_and_format(inlines); Code rf_inlines = refactor_and_format(inlines);
Code rf_ht_preprocessor_macro = refactor_and_format(ht_preprocessor_macro); Code rf_ht_preprocessor_macro = refactor_and_format(ht_preprocessor_macro);
Code rf_array_string_cached = refactor_and_format(array_string_cached); Code rf_array_string_cached = refactor_and_format(array_string_cached);
Code rf_header_end = refactor_and_format(header_end);
Code rf_header_builder = refactor_and_format(header_builder); Code rf_header_builder = refactor_and_format(header_builder);
Code rf_header_scanner = refactor_and_format( scan_file( path_base "auxiliary/scanner.hpp" )); Code rf_header_scanner = refactor_and_format( scan_file( path_base "auxiliary/scanner.hpp" ));
@ -1788,6 +1788,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
header.print( rf_ht_preprocessor_macro ); header.print( rf_ht_preprocessor_macro );
header.print( rf_interface ); header.print( rf_interface );
header.print( rf_constants );
header.print(fmt_newline); header.print(fmt_newline);
header.print_fmt("#pragma region Inlines\n"); header.print_fmt("#pragma region Inlines\n");
@ -1796,7 +1797,6 @@ R"(#define <interface_name>( code ) _Generic( (code), \
header.print(fmt_newline); header.print(fmt_newline);
header.print( rf_header_end );
header.print( rf_header_builder ); header.print( rf_header_builder );
header.print( rf_header_scanner ); header.print( rf_header_scanner );
@ -1882,6 +1882,9 @@ R"(#define <interface_name>( code ) _Generic( (code), \
header.print( r_header_macros ); header.print( r_header_macros );
header.print( header_generic_macros ); header.print( header_generic_macros );
header.print_fmt( "\nGEN_API_C_BEGIN\n" );
header.print( r_header_basic_types ); header.print( r_header_basic_types );
header.print( r_header_debug ); header.print( r_header_debug );
header.print( rf_header_memory ); header.print( rf_header_memory );
@ -1895,6 +1898,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
header.print( r_header_timing ); header.print( r_header_timing );
header.print(rf_header_parsing ); header.print(rf_header_parsing );
header.print_fmt( "\nGEN_API_C_END\n" );
header.print_fmt( "\nGEN_NS_END\n" ); header.print_fmt( "\nGEN_NS_END\n" );
header.write(); header.write();
} }
@ -1949,7 +1953,17 @@ R"(#define <interface_name>( code ) _Generic( (code), \
header.print( rf_ast_types ); header.print( rf_ast_types );
header.print_fmt("\n#pragma endregion AST\n"); header.print_fmt("\n#pragma endregion AST\n");
header.print( fmt_newline);
header.print( rf_array_arena );
header.print( fmt_newline);
header.print( rf_array_pool);
header.print( fmt_newline);
header.print( rf_array_string_cached );
header.print( fmt_newline);
header.print( rf_ht_preprocessor_macro );
header.print( rf_interface ); header.print( rf_interface );
header.print( rf_constants );
header.print(fmt_newline); header.print(fmt_newline);
header.print_fmt("#pragma region Inlines\n"); header.print_fmt("#pragma region Inlines\n");
@ -1957,9 +1971,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
header.print_fmt("#pragma endregion Inlines\n"); header.print_fmt("#pragma endregion Inlines\n");
header.print(fmt_newline); header.print(fmt_newline);
header.print( rf_array_string_cached );
header.print( rf_header_end );
header.print( rf_header_builder ); header.print( rf_header_builder );
header.print( rf_header_scanner ); header.print( rf_header_scanner );
@ -1976,11 +1988,6 @@ R"(#define <interface_name>( code ) _Generic( (code), \
builder_print( src, src_start ); builder_print( src, src_start );
src.print_fmt( "\nGEN_NS_BEGIN\n"); src.print_fmt( "\nGEN_NS_BEGIN\n");
src.print( fmt_newline);
src.print( rf_array_arena );
src.print( fmt_newline);
src.print( rf_array_pool);
src.print( r_src_static_data ); src.print( r_src_static_data );
src.print( fmt_newline); src.print( fmt_newline);
@ -1998,6 +2005,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
src.print( fmt_newline); src.print( fmt_newline);
src.print( rf_array_code_typename ); src.print( rf_array_code_typename );
src.print( fmt_newline); src.print( fmt_newline);
src.print( r_src_parser_case_macros );
src.print( rf_src_parser ); src.print( rf_src_parser );
src.print( r_src_parsing ); src.print( r_src_parsing );
src.print_fmt( "\n#pragma endregion Parsing\n" ); src.print_fmt( "\n#pragma endregion Parsing\n" );

View File

@ -13,7 +13,7 @@
| \_____|\___}_l |_|\___} .__/| .__/ {_____/ \__\__/_l\__. |\___/\__,_l \____}{_____}{_____} | | \_____|\___}_l |_|\___} .__/| .__/ {_____/ \__\__/_l\__. |\___/\__,_l \____}{_____}{_____} |
| | | | | __} | | | | | | | __} | |
| l_l l_l {___/ | | l_l l_l {___/ |
! ----------------------------------------------------------------------- VERSION: v0.23-Alpha | ! ----------------------------------------------------------------------- VERSION: v0.25-Alpha |
! ============================================================================================= | ! ============================================================================================= |
! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION | ! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION |
! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL | ! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL |

View File

@ -7,8 +7,19 @@ void convert_cpp_enum_to_c( CodeEnum to_convert, CodeBody to_append )
{ {
#pragma push_macro("enum_underlying") #pragma push_macro("enum_underlying")
#undef enum_underlying #undef enum_underlying
StrCached type = to_convert->UnderlyingType ? to_convert->UnderlyingType.to_strbuilder().to_str() : to_convert->Name; StrCached type;
CodeTypedef tdef = parse_typedef(token_fmt("type", type, "name", to_convert->Name, stringize( typedef enum <type> <name>; ))); CodeTypedef tdef;
if (to_convert->UnderlyingType)
{
type = to_convert->UnderlyingType.to_strbuilder().to_str();
tdef = parse_typedef(token_fmt("type", type, "name", to_convert->Name, stringize( typedef <type> <name>; )));
}
else
{
type = to_convert->Name;
tdef = parse_typedef(token_fmt("type", type, "name", to_convert->Name, stringize( typedef enum <type> <name>; )));
}
if (to_convert->UnderlyingType) if (to_convert->UnderlyingType)
{ {
to_convert->UnderlyingTypeMacro = untyped_str(token_fmt("type", to_convert->UnderlyingType->Name, stringize(enum_underlying(<type>)))); to_convert->UnderlyingTypeMacro = untyped_str(token_fmt("type", to_convert->UnderlyingType->Name, stringize(enum_underlying(<type>))));

View File

@ -1,3 +1,6 @@
#define GEN_IMPLEMENTATION #define GEN_IMPLEMENTATION
#define GEN_DONT_ENFORCE_GEN_TIME_GUARD #define GEN_DONT_ENFORCE_GEN_TIME_GUARD
#define GEN_DEFINE_LIBRARY_CORE_CONSTANTS
#define GEN_ENFORCE_STRONG_CODE_TYPES
#define GEN_EXPOSE_BACKEND
#include "gen/gen_singleheader.h" #include "gen/gen_singleheader.h"

View File

@ -114,7 +114,7 @@ int gen_main()
} }
CodeBody gen_component_header = def_global_body( args( CodeBody gen_component_header = def_global_body( args(
def_preprocess_cond( PreprocessCond_IfDef, txt("GEN_INTELLISENSE_DIRECTIVES") ), def_preprocess_cond( PreprocessCond_IfDef, txt("INTELLISENSE_DIRECTIVES") ),
pragma_once, pragma_once,
def_include(txt("components/types.hpp")), def_include(txt("components/types.hpp")),
preprocess_endif, preprocess_endif,
@ -131,8 +131,8 @@ int gen_main()
Code ast_types = scan_file( path_base "components/ast_types.hpp" ); Code ast_types = scan_file( path_base "components/ast_types.hpp" );
Code code_types = scan_file( path_base "components/code_types.hpp" ); Code code_types = scan_file( path_base "components/code_types.hpp" );
Code interface = scan_file( path_base "components/interface.hpp" ); Code interface = scan_file( path_base "components/interface.hpp" );
Code constants = scan_file( path_base "components/constants.hpp");
Code inlines = scan_file( path_base "components/inlines.hpp" ); Code inlines = scan_file( path_base "components/inlines.hpp" );
Code header_end = scan_file( path_base "components/header_end.hpp" );
CodeBody ecode = gen_ecode ( path_base "enums/ECodeTypes.csv" ); CodeBody ecode = gen_ecode ( path_base "enums/ECodeTypes.csv" );
CodeBody eoperator = gen_eoperator ( path_base "enums/EOperator.csv" ); CodeBody eoperator = gen_eoperator ( path_base "enums/EOperator.csv" );
@ -168,6 +168,7 @@ int gen_main()
builder_print_fmt( header, "\n#pragma endregion AST\n" ); builder_print_fmt( header, "\n#pragma endregion AST\n" );
builder_print( header, interface ); builder_print( header, interface );
builder_print( header, constants );
builder_print_fmt( header, "\n#pragma region Inlines\n" ); builder_print_fmt( header, "\n#pragma region Inlines\n" );
builder_print( header, inlines ); builder_print( header, inlines );
@ -176,7 +177,6 @@ int gen_main()
builder_print( header, fmt_newline ); builder_print( header, fmt_newline );
builder_print_fmt( header, "#pragma endregion Inlines\n" ); builder_print_fmt( header, "#pragma endregion Inlines\n" );
builder_print( header, header_end );
builder_print_fmt( header, "\nGEN_NS_END\n\n" ); builder_print_fmt( header, "\nGEN_NS_END\n\n" );
builder_print( header, pop_ignores ); builder_print( header, pop_ignores );
builder_write(header); builder_write(header);

View File

@ -15,7 +15,7 @@
| \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l | | \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l |
| Singleheader | | | | __} | | | Singleheader | | | | __} | |
| l_l l_l {___/ | | l_l l_l {___/ |
! ----------------------------------------------------------------------- VERSION: v0.23-Alpha | ! ----------------------------------------------------------------------- VERSION: v0.25-Alpha |
! ============================================================================================ | ! ============================================================================================ |
! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION | ! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION |
! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL | ! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL |

View File

@ -117,8 +117,8 @@ int gen_main()
Code ast_types = scan_file( path_base "components/ast_types.hpp" ); Code ast_types = scan_file( path_base "components/ast_types.hpp" );
Code code_types = scan_file( path_base "components/code_types.hpp" ); Code code_types = scan_file( path_base "components/code_types.hpp" );
Code interface = scan_file( path_base "components/interface.hpp" ); Code interface = scan_file( path_base "components/interface.hpp" );
Code constants = scan_file( path_base "components/constants.hpp" );
Code inlines = scan_file( path_base "components/inlines.hpp" ); Code inlines = scan_file( path_base "components/inlines.hpp" );
Code header_end = scan_file( path_base "components/header_end.hpp" );
CodeBody ecode = gen_ecode ( path_base "enums/ECodeTypes.csv" ); CodeBody ecode = gen_ecode ( path_base "enums/ECodeTypes.csv" );
CodeBody eoperator = gen_eoperator ( path_base "enums/EOperator.csv" ); CodeBody eoperator = gen_eoperator ( path_base "enums/EOperator.csv" );
@ -149,6 +149,7 @@ int gen_main()
header.print_fmt("\n#pragma endregion AST\n"); header.print_fmt("\n#pragma endregion AST\n");
header.print( interface ); header.print( interface );
header.print( constants );
header.print_fmt( "\n#pragma region Inlines\n" ); header.print_fmt( "\n#pragma region Inlines\n" );
header.print( inlines ); header.print( inlines );
@ -156,8 +157,6 @@ int gen_main()
header.print( fmt_newline ); header.print( fmt_newline );
header.print_fmt( "#pragma endregion Inlines\n" ); header.print_fmt( "#pragma endregion Inlines\n" );
header.print( header_end );
if ( generate_builder ) { if ( generate_builder ) {
header.print( scan_file( path_base "auxiliary/builder.hpp" ) ); header.print( scan_file( path_base "auxiliary/builder.hpp" ) );
} }

View File

@ -16,7 +16,7 @@
| \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l | | \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l |
| Unreal Engine | | | | __} | | | Unreal Engine | | | | __} | |
| l_l l_l {___/ | | l_l l_l {___/ |
! ----------------------------------------------------------------------- VERSION: v0.23-Alpha | ! ----------------------------------------------------------------------- VERSION: v0.25-Alpha |
! ============================================================================================ | ! ============================================================================================ |
! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION | ! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION |
! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL | ! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL |

View File

@ -24,4 +24,5 @@ Final, final
NoExceptions, noexcept NoExceptions, noexcept
Override, override Override, override
Pure, = 0 Pure, = 0
Delete, = delete
Volatile, volatile Volatile, volatile

1 Invalid INVALID
24 NoExceptions noexcept
25 Override override
26 Pure = 0
27 Delete = delete
28 Volatile volatile

View File

@ -224,8 +224,8 @@ int gen_main()
Code ast_types = scan_file( path_base "components/ast_types.hpp" ); Code ast_types = scan_file( path_base "components/ast_types.hpp" );
Code code_types = scan_file( path_base "components/code_types.hpp" ); Code code_types = scan_file( path_base "components/code_types.hpp" );
Code interface = scan_file( path_base "components/interface.hpp" ); Code interface = scan_file( path_base "components/interface.hpp" );
Code constants = scan_file( path_base "components/constants.hpp" );
Code inlines = scan_file( path_base "components/inlines.hpp" ); Code inlines = scan_file( path_base "components/inlines.hpp" );
Code header_end = scan_file( path_base "components/header_end.hpp" );
CodeBody ecode = gen_ecode ( path_base "enums/ECodeTypes.csv" ); CodeBody ecode = gen_ecode ( path_base "enums/ECodeTypes.csv" );
CodeBody eoperator = gen_eoperator ( path_base "enums/EOperator.csv" ); CodeBody eoperator = gen_eoperator ( path_base "enums/EOperator.csv" );
@ -266,6 +266,7 @@ int gen_main()
header.print_fmt( "\n#pragma endregion AST\n" ); header.print_fmt( "\n#pragma endregion AST\n" );
header.print( interface ); header.print( interface );
header.print( constants );
header.print_fmt( "\n#pragma region Inlines\n" ); header.print_fmt( "\n#pragma region Inlines\n" );
header.print( inlines ); header.print( inlines );
@ -274,7 +275,6 @@ int gen_main()
header.print( fmt_newline ); header.print( fmt_newline );
header.print_fmt( "#pragma endregion Inlines\n" ); header.print_fmt( "#pragma endregion Inlines\n" );
header.print( header_end );
header.print_fmt( "\nGEN_NS_END\n\n" ); header.print_fmt( "\nGEN_NS_END\n\n" );
header.print( pop_ignores ); header.print( pop_ignores );
header.write(); header.write();

View File

@ -146,7 +146,7 @@ QualifierAlignment: Leave
ReferenceAlignment: Left ReferenceAlignment: Left
ReflowComments: true ReflowComments: false
# RequiresExpressionIndentation: OuterScope # RequiresExpressionIndentation: OuterScope
@ -164,7 +164,7 @@ SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: Default SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: true SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: true SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true SpaceBeforeInheritanceColon: true
@ -182,7 +182,7 @@ SpacesInContainerLiterals: false
SpacesInLineCommentPrefix: SpacesInLineCommentPrefix:
Minimum: 1 Minimum: 1
Maximum: 20 Maximum: 20
SpacesInParentheses: true SpacesInParentheses: false
SpacesInSquareBrackets: false SpacesInSquareBrackets: false
Standard: c++17 Standard: c++17

View File

@ -172,7 +172,7 @@ if ( $segmented )
write-host `t $_ -ForegroundColor Green write-host `t $_ -ForegroundColor Green
} }
} }
write-host "`nBootstrap completed in $($time_taken.TotalMilliseconds) ms" write-host "`nSegmented completed in $($time_taken.TotalMilliseconds) ms"
} }
Pop-Location Pop-Location
} }
@ -263,6 +263,7 @@ if ( $c_lib_static )
$compiler_args += $flag_all_c $compiler_args += $flag_all_c
$compiler_args += $flag_updated_cpp_macro $compiler_args += $flag_updated_cpp_macro
$compiler_args += $flag_c11 $compiler_args += $flag_c11
$compiler_args += ($flag_define + 'GEN_STATIC_LINK')
$linker_args = @() $linker_args = @()
$result = build-simple $path_build $includes $compiler_args $linker_args $unit $path_lib $result = build-simple $path_build $includes $compiler_args $linker_args $unit $path_lib
@ -280,6 +281,7 @@ if ( $c_lib_dyn )
$compiler_args += $flag_c11 $compiler_args += $flag_c11
$compiler_args += ( $flag_define + 'GEN_DYN_LINK' ) $compiler_args += ( $flag_define + 'GEN_DYN_LINK' )
$compiler_args += ( $flag_define + 'GEN_DYN_EXPORT' ) $compiler_args += ( $flag_define + 'GEN_DYN_EXPORT' )
$compiler_args += ( $flag_define + 'GEN_DEFINE_LIBRARY_CODE_CONSTANTS' )
$linker_args = @() $linker_args = @()
$result = build-simple $path_build $includes $compiler_args $linker_args $unit $path_dll $result = build-simple $path_build $includes $compiler_args $linker_args $unit $path_dll

View File

@ -344,15 +344,17 @@ if ( $vendor -match "clang" )
} }
# Check if output is a static library # Check if output is a static library
# if ( $binary -match '\.lib$' ) if ( $binary -match '\.lib$' )
# { {
# $lib_args = @() $lib_args = @()
# $lib_args += $flag_nologo # $lib_args += $flag_nologo
# $lib_args += $flag_link_win_machine_64 # $lib_args += $flag_link_win_machine_64
# $lib_args += ( $flag_link_win_path_output + $binary ) # $lib_args += ( $flag_link_win_path_output + $binary )
# $lib_args += $object # $lib_args += '--format=windows'
# return run-archiver $archiver $binary $lib_args # $lib_args += '-X64'
# } $lib_args += $object
return run-archiver $archiver $binary $lib_args
}
$linker_args += $object $linker_args += $object
return run-linker $linker $binary $linker_args return run-linker $linker $binary $linker_args
@ -562,6 +564,7 @@ if ( $vendor -match "msvc" )
# Check if output is a static library # Check if output is a static library
if ( $binary -match '\.lib$' ) if ( $binary -match '\.lib$' )
{ {
write-host "Running archiver for $binary"
$lib_args = @() $lib_args = @()
$lib_args += $flag_nologo $lib_args += $flag_nologo
$lib_args += $flag_link_win_machine_64 $lib_args += $flag_link_win_machine_64

View File

@ -1,4 +1,4 @@
#if GEN_INTELLISENSE_DIRECTIVES #if INTELLISENSE_DIRECTIVES
#include "../../gen_c_library/gen/gen_singleheader.h" #include "../../gen_c_library/gen/gen_singleheader.h"
#endif #endif