mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 07:44:45 -08:00
fixes for array when not using member features.
This commit is contained in:
parent
2dcc968c39
commit
9b68791e38
@ -1,6 +1,8 @@
|
|||||||
#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
|
||||||
|
#define GEN_SUPPORT_CPP_MEMBER_FEATURES 1
|
||||||
|
#define GEN_SUPPORT_CPP_REFERENCES 0
|
||||||
#include "gen.cpp"
|
#include "gen.cpp"
|
||||||
|
|
||||||
#include "helpers/push_ignores.inline.hpp"
|
#include "helpers/push_ignores.inline.hpp"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#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
|
||||||
#define GEN_SUPPORT_CPP_MEMBER_FEATURES 1
|
#define GEN_SUPPORT_CPP_MEMBER_FEATURES 0
|
||||||
#define GEN_SUPPORT_CPP_REFERENCES 0
|
#define GEN_SUPPORT_CPP_REFERENCES 0
|
||||||
#include "gen.cpp"
|
#include "gen.cpp"
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ char const* type_str ( AST& self ) { return type_str( & self ); }
|
|||||||
*/
|
*/
|
||||||
struct AST
|
struct AST
|
||||||
{
|
{
|
||||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||||
# pragma region Member Functions
|
# pragma region Member Functions
|
||||||
void append ( AST* other ) { GEN_NS append(this, other); }
|
void append ( AST* other ) { GEN_NS append(this, other); }
|
||||||
char const* debug_str () { return GEN_NS debug_str(this); }
|
char const* debug_str () { return GEN_NS debug_str(this); }
|
||||||
|
@ -201,7 +201,7 @@ bool append_at(Array<Type>* array, Type item, usize idx)
|
|||||||
header = get_header(* array);
|
header = get_header(* array);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type* target = array->Data + slot;
|
Type* target = &(*array)[slot];
|
||||||
|
|
||||||
mem_move(target + 1, target, (header->Num - slot) * sizeof(Type));
|
mem_move(target + 1, target, (header->Num - slot) * sizeof(Type));
|
||||||
header->Num++;
|
header->Num++;
|
||||||
@ -278,7 +278,8 @@ void free(Array<Type>* array) {
|
|||||||
GEN_ASSERT(array != nullptr);
|
GEN_ASSERT(array != nullptr);
|
||||||
ArrayHeader* header = get_header(* array);
|
ArrayHeader* header = get_header(* array);
|
||||||
GEN_NS free(header->Allocator, header);
|
GEN_NS free(header->Allocator, header);
|
||||||
array->Data = nullptr;
|
Type** Data = (Type**)array;
|
||||||
|
*Data = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Type> forceinline
|
template<class Type> forceinline
|
||||||
@ -374,7 +375,8 @@ bool set_capacity(Array<Type>* array, usize new_capacity)
|
|||||||
|
|
||||||
GEN_NS free(header->Allocator, header);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user