From 9b68791e387837af7c147b468c214516f9f25885 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 2 Dec 2024 02:11:49 -0500 Subject: [PATCH] fixes for array when not using member features. --- gen_singleheader/singleheader.cpp | 2 ++ project/bootstrap.cpp | 2 +- project/components/ast.hpp | 2 +- project/dependencies/containers.hpp | 8 +++++--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/gen_singleheader/singleheader.cpp b/gen_singleheader/singleheader.cpp index 5226d62..0e12511 100644 --- a/gen_singleheader/singleheader.cpp +++ b/gen_singleheader/singleheader.cpp @@ -1,6 +1,8 @@ #define GEN_DEFINE_LIBRARY_CODE_CONSTANTS #define GEN_ENFORCE_STRONG_CODE_TYPES #define GEN_EXPOSE_BACKEND +#define GEN_SUPPORT_CPP_MEMBER_FEATURES 1 +#define GEN_SUPPORT_CPP_REFERENCES 0 #include "gen.cpp" #include "helpers/push_ignores.inline.hpp" diff --git a/project/bootstrap.cpp b/project/bootstrap.cpp index 2a7332c..4d9b86d 100644 --- a/project/bootstrap.cpp +++ b/project/bootstrap.cpp @@ -1,7 +1,7 @@ #define GEN_DEFINE_LIBRARY_CODE_CONSTANTS #define GEN_ENFORCE_STRONG_CODE_TYPES #define GEN_EXPOSE_BACKEND -#define GEN_SUPPORT_CPP_MEMBER_FEATURES 1 +#define GEN_SUPPORT_CPP_MEMBER_FEATURES 0 #define GEN_SUPPORT_CPP_REFERENCES 0 #include "gen.cpp" diff --git a/project/components/ast.hpp b/project/components/ast.hpp index 51bef49..2d1fe0a 100644 --- a/project/components/ast.hpp +++ b/project/components/ast.hpp @@ -298,7 +298,7 @@ char const* type_str ( AST& self ) { return type_str( & self ); } */ struct AST { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1 # pragma region Member Functions void append ( AST* other ) { GEN_NS append(this, other); } char const* debug_str () { return GEN_NS debug_str(this); } diff --git a/project/dependencies/containers.hpp b/project/dependencies/containers.hpp index a6d6248..9205b95 100644 --- a/project/dependencies/containers.hpp +++ b/project/dependencies/containers.hpp @@ -201,7 +201,7 @@ bool append_at(Array* array, Type item, usize idx) header = get_header(* array); } - Type* target = array->Data + slot; + Type* target = &(*array)[slot]; mem_move(target + 1, target, (header->Num - slot) * sizeof(Type)); header->Num++; @@ -278,7 +278,8 @@ void free(Array* array) { GEN_ASSERT(array != nullptr); ArrayHeader* header = get_header(* array); GEN_NS free(header->Allocator, header); - array->Data = nullptr; + Type** Data = (Type**)array; + *Data = nullptr; } template forceinline @@ -374,7 +375,8 @@ bool set_capacity(Array* array, usize new_capacity) GEN_NS free(header->Allocator, header); - array->Data = rcast(Type*, new_header + 1); + Type** Data = (Type**)array; + * Data = rcast(Type*, new_header + 1); return true; }