fixes for array when not using member features.

This commit is contained in:
Edward R. Gonzalez 2024-12-02 02:11:49 -05:00
parent 2dcc968c39
commit 9b68791e38
4 changed files with 9 additions and 5 deletions

View File

@ -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"

View File

@ -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"

View File

@ -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); }

View File

@ -201,7 +201,7 @@ bool append_at(Array<Type>* 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<Type>* 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<class Type> forceinline
@ -374,7 +375,8 @@ bool set_capacity(Array<Type>* 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;
}