breaking changes in type system

This commit is contained in:
2023-02-13 00:34:32 +06:00
parent 305854e721
commit 95fec8d166
48 changed files with 704 additions and 608 deletions

View File

@@ -6,34 +6,32 @@ extern "C" {
#include "../base/base.h"
#define Array_declare(type)\
typedef struct Array_##type{\
type* values;\
u32 length;\
bool allocatedOnHeap;\
} Array_##type;\
#define Array_declare(type) \
STRUCT(Array_##type, \
type* values; \
u32 length; \
bool allocatedOnHeap; \
) \
\
ktid_declare(Array_##type);\
static inline Array_##type Array_##type##_allocValues(u32 length){ \
return (Array_##type) { \
.values=(type*)malloc(sizeof(type)*length), \
.length=length, \
.allocatedOnHeap=true \
}; \
} \
\
static inline Array_##type Array_##type##_allocValues(u32 length){\
return (Array_##type) {\
.values=(type*)malloc(sizeof(type)*length),\
.length=length,\
.allocatedOnHeap=true\
};\
}\
static inline Array_##type Array_##type##_fromBuffer(type* buffer, u32 bufferLength, bool allocatedOnHeap){ \
return (Array_##type) { \
.values=buffer, \
.length=bufferLength, \
.allocatedOnHeap=allocatedOnHeap \
}; \
} \
\
static inline Array_##type Array_##type##_fromBuffer(type* buffer, u32 bufferLength, bool allocatedOnHeap){\
return (Array_##type) {\
.values=buffer,\
.length=bufferLength,\
.allocatedOnHeap=allocatedOnHeap\
};\
}\
\
static inline void Array_##type##_free(Array_##type* array){\
if(array->allocatedOnHeap)\
free(array->values);\
static inline void Array_##type##_free(Array_##type* array){ \
if(array->allocatedOnHeap) \
free(array->values); \
}
#if __cplusplus