Skip to content

Commit

Permalink
Merge pull request #72 from Ed94/dev
Browse files Browse the repository at this point in the history
Changes involved with getting gencpp-odin setup
  • Loading branch information
Ed94 authored Feb 5, 2025
2 parents 13ebd10 + ec8dd1e commit 878bc4c
Show file tree
Hide file tree
Showing 71 changed files with 833 additions and 686 deletions.
8 changes: 8 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
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

* [docs - General](./docs/Readme.md): Overview and additional docs
Expand Down
2 changes: 1 addition & 1 deletion base/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
* `code_debug_str`
* `code_is_equal`
* `code_to_strbuilder_ptr`
* `code_to_strbuilder_ref`
* `code_validate_body`
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.
Expand Down
2 changes: 1 addition & 1 deletion base/auxiliary/builder.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#ifdef INTELLISENSE_DIRECTIVES
# include "builder.hpp"
#endif

Expand Down
2 changes: 1 addition & 1 deletion base/auxiliary/builder.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#ifdef INTELLISENSE_DIRECTIVES
# pragma once
# include "helpers/push_ignores.inline.hpp"
# include "components/header_start.hpp"
Expand Down
2 changes: 1 addition & 1 deletion base/auxiliary/gen_template.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#ifdef INTELLISENSE_DIRECTIVES
# pragma once
# include "helpers/push_ignores.inline.hpp"
# include "components/header_start.hpp"
Expand Down
6 changes: 3 additions & 3 deletions base/auxiliary/scanner.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#ifdef INTELLISENSE_DIRECTIVES
# include "scanner.hpp"
#endif

Expand All @@ -24,7 +24,7 @@ Code scan_file( char const* path )
file_read( & file, str, 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.
// Anything that comes before it will also be omitted.
{
Expand All @@ -33,7 +33,7 @@ Code scan_file( char const* path )
#define move_fwd() do { ++ scanner; -- left; } while (0)
const Str directive_start = txt( "ifdef" );
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;
char const* scanner = (char const*)str;
Expand Down
2 changes: 1 addition & 1 deletion base/auxiliary/scanner.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#ifdef INTELLISENSE_DIRECTIVES
# pragma once
# include "helpers/push_ignores.inline.hpp"
# include "components/header_start.hpp"
Expand Down
2 changes: 1 addition & 1 deletion base/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int gen_main()
gen::init( & ctx);

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,
def_include(txt("components/types.hpp")),
preprocess_endif,
Expand Down
6 changes: 3 additions & 3 deletions base/components/ast.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#ifdef INTELLISENSE_DIRECTIVES
#pragma once
#include "static_data.cpp"
#endif
Expand Down Expand Up @@ -379,11 +379,11 @@ Code code_duplicate(Code self)
StrBuilder code_to_strbuilder(Code self)
{
StrBuilder result = strbuilder_make_str( _ctx->Allocator_Temp, txt("") );
code_to_strbuilder_ptr( self, & result );
code_to_strbuilder_ref( self, & 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);
local_persist thread_local
Expand Down
24 changes: 13 additions & 11 deletions base/components/ast.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#ifdef INTELLISENSE_DIRECTIVES
#pragma once
#include "types.hpp"
#include "gen/ecode.hpp"
Expand Down Expand Up @@ -193,6 +193,7 @@ typedef AST_Stmt_If* CodeStmt_If;
typedef AST_Stmt_For* CodeStmt_For;
typedef AST_Stmt_Goto* CodeStmt_Goto;
typedef AST_Stmt_Label* CodeStmt_Label;
typedef AST_Stmt_Lambda* CodeStmt_Lambda;
typedef AST_Stmt_Switch* CodeStmt_Switch;
typedef AST_Stmt_While* CodeStmt_While;
#else
Expand All @@ -208,6 +209,7 @@ struct CodeStmt_If;
struct CodeStmt_For;
struct CodeStmt_Goto;
struct CodeStmt_Label;
struct CodeStmt_Lambda;
struct CodeStmt_Switch;
struct CodeStmt_While;
#endif
Expand Down Expand Up @@ -239,18 +241,18 @@ template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast(

#pragma region Code C-Interface

GEN_API void code_append (Code code, Code other );
void code_append (Code code, Code other );
GEN_API Str code_debug_str (Code code);
GEN_API Code code_duplicate (Code code);
GEN_API Code* code_entry (Code code, u32 idx );
GEN_API bool code_has_entries (Code code);
GEN_API bool code_is_body (Code code);
Code* code_entry (Code code, u32 idx );
bool code_has_entries (Code code);
bool code_is_body (Code code);
GEN_API bool code_is_equal (Code code, Code other);
GEN_API bool code_is_valid (Code code);
GEN_API void code_set_global (Code code);
bool code_is_valid (Code code);
void code_set_global (Code code);
GEN_API StrBuilder code_to_strbuilder (Code self );
GEN_API void code_to_strbuilder_ptr(Code self, StrBuilder* result );
GEN_API Str code_type_str (Code self );
GEN_API void code_to_strbuilder_ref(Code self, StrBuilder* result );
Str code_type_str (Code self );
GEN_API bool code_validate_body (Code self );

#pragma endregion Code C-Interface
Expand Down Expand Up @@ -287,7 +289,7 @@ struct Code
forceinline Code* entry(u32 idx) { return code_entry(* this, idx); }
forceinline bool has_entries() { return code_has_entries(* 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 bool validate_body() { return code_validate_body(*this); }
#endif
Expand Down Expand Up @@ -399,7 +401,7 @@ struct AST
Code Value; // Parameter, Variable
};
union {
Code NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
Code NextVar; // Variable
Code SuffixSpecs; // Typename, Function (Thanks Unreal)
Code PostNameMacro; // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal)
};
Expand Down
10 changes: 5 additions & 5 deletions base/components/ast_types.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#ifdef INTELLISENSE_DIRECTIVES
# pragma once
# include "code_types.hpp"
#endif
Expand Down Expand Up @@ -227,7 +227,7 @@ struct AST_Enum
Code Parent;
CodeType Type;
ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
char _PAD_UNUSED_[ sizeof(u32) ];
};
static_assert( sizeof(AST_Enum) == sizeof(AST), "ERROR: AST_Enum is not the same size as AST");

Expand Down Expand Up @@ -738,8 +738,8 @@ static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_Preprocess
struct AST_Specifiers
{
Specifier ArrSpecs[ AST_ArrSpecs_Cap ];
StrCached Name;
CodeSpecifiers NextSpecs;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Expand Down Expand Up @@ -1056,7 +1056,7 @@ struct AST_Typename
CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures
};
};
StrCached Name;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Expand All @@ -1082,7 +1082,7 @@ struct AST_Typedef
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
};
};
StrCached Name;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Expand Down
Loading

0 comments on commit 878bc4c

Please sign in to comment.