fixed a lot of broken stuff
This commit is contained in:
126
src/base/init.c
126
src/base/init.c
@@ -6,90 +6,90 @@
|
||||
|
||||
void kerepTypeDescriptors_initKerepTypes(){
|
||||
// null
|
||||
kerepType_register(NULL, Null, NULL);
|
||||
kerepType_register(NULL, kerepTypeId_Null, NULL);
|
||||
// base types
|
||||
kerepType_register(char, Char, NULL);
|
||||
kerepType_register(bool, Bool, NULL);
|
||||
kerepType_register(float32, Float32, NULL);
|
||||
kerepType_register(float64, Float64, NULL);
|
||||
kerepType_register(int8, Int8, NULL);
|
||||
kerepType_register(uint8, UInt8, NULL);
|
||||
kerepType_register(int16, Int16, NULL);
|
||||
kerepType_register(uint16, UInt16, NULL);
|
||||
kerepType_register(int32, Int32, NULL);
|
||||
kerepType_register(uint32, UInt32, NULL);
|
||||
kerepType_register(int64, Int64, NULL);
|
||||
kerepType_register(uint64, UInt64, NULL);
|
||||
kerepType_register(char, kerepTypeId_Char, NULL);
|
||||
kerepType_register(bool, kerepTypeId_Bool, NULL);
|
||||
kerepType_register(float32, kerepTypeId_Float32, NULL);
|
||||
kerepType_register(float64, kerepTypeId_Float64, NULL);
|
||||
kerepType_register(int8, kerepTypeId_Int8, NULL);
|
||||
kerepType_register(uint8, kerepTypeId_UInt8, NULL);
|
||||
kerepType_register(int16, kerepTypeId_Int16, NULL);
|
||||
kerepType_register(uint16, kerepTypeId_UInt16, NULL);
|
||||
kerepType_register(int32, kerepTypeId_Int32, NULL);
|
||||
kerepType_register(uint32, kerepTypeId_UInt32, NULL);
|
||||
kerepType_register(int64, kerepTypeId_Int64, NULL);
|
||||
kerepType_register(uint64, kerepTypeId_UInt64, NULL);
|
||||
// base type pointers
|
||||
kerepType_register(char*, CharPtr, NULL);
|
||||
kerepType_register(bool*, BoolPtr, NULL);
|
||||
kerepType_register(float32*, Float32Ptr, NULL);
|
||||
kerepType_register(float64*, Float64Ptr, NULL);
|
||||
kerepType_register(int8*, Int8Ptr, NULL);
|
||||
kerepType_register(uint8*, UInt8Ptr, NULL);
|
||||
kerepType_register(int16*, Int16Ptr, NULL);
|
||||
kerepType_register(uint16*, UInt16Ptr, NULL);
|
||||
kerepType_register(int32*, Int32Ptr, NULL);
|
||||
kerepType_register(uint32*, UInt32Ptr, NULL);
|
||||
kerepType_register(int64*, Int64Ptr, NULL);
|
||||
kerepType_register(uint64*, UInt64Ptr, NULL);
|
||||
kerepType_register(char*, kerepTypeId_CharPtr, NULL);
|
||||
kerepType_register(bool*, kerepTypeId_BoolPtr, NULL);
|
||||
kerepType_register(float32*, kerepTypeId_Float32Ptr, NULL);
|
||||
kerepType_register(float64*, kerepTypeId_Float64Ptr, NULL);
|
||||
kerepType_register(int8*, kerepTypeId_Int8Ptr, NULL);
|
||||
kerepType_register(uint8*, kerepTypeId_UInt8Ptr, NULL);
|
||||
kerepType_register(int16*, kerepTypeId_Int16Ptr, NULL);
|
||||
kerepType_register(uint16*, kerepTypeId_UInt16Ptr, NULL);
|
||||
kerepType_register(int32*, kerepTypeId_Int32Ptr, NULL);
|
||||
kerepType_register(uint32*, kerepTypeId_UInt32Ptr, NULL);
|
||||
kerepType_register(int64*, kerepTypeId_Int64Ptr, NULL);
|
||||
kerepType_register(uint64*, kerepTypeId_UInt64Ptr, NULL);
|
||||
|
||||
// base type autoarrs
|
||||
kerepType_register(Autoarr_char, AutoarrChar, ____Autoarr_free_char);
|
||||
kerepType_register(Autoarr_bool, AutoarrBool, ____Autoarr_free_bool);
|
||||
kerepType_register(Autoarr_float32, AutoarrFloat32, ____Autoarr_free_float32);
|
||||
kerepType_register(Autoarr_float64, AutoarrFloat64, ____Autoarr_free_float64);
|
||||
kerepType_register(Autoarr_int8, AutoarrInt8, ____Autoarr_free_int8);
|
||||
kerepType_register(Autoarr_uint8, AutoarrUInt8, ____Autoarr_free_uint8);
|
||||
kerepType_register(Autoarr_int16, AutoarrInt16, ____Autoarr_free_int16);
|
||||
kerepType_register(Autoarr_uint16, AutoarrUInt16, ____Autoarr_free_uint16);
|
||||
kerepType_register(Autoarr_int32, AutoarrInt32, ____Autoarr_free_int32);
|
||||
kerepType_register(Autoarr_uint32, AutoarrUInt32, ____Autoarr_free_uint32);
|
||||
kerepType_register(Autoarr_int64, AutoarrInt64, ____Autoarr_free_int64);
|
||||
kerepType_register(Autoarr_uint64, AutoarrUInt64, ____Autoarr_free_uint64);
|
||||
kerepType_register(Autoarr_char, kerepTypeId_AutoarrChar, ____Autoarr_free_char);
|
||||
kerepType_register(Autoarr_bool, kerepTypeId_AutoarrBool, ____Autoarr_free_bool);
|
||||
kerepType_register(Autoarr_float32, kerepTypeId_AutoarrFloat32, ____Autoarr_free_float32);
|
||||
kerepType_register(Autoarr_float64, kerepTypeId_AutoarrFloat64, ____Autoarr_free_float64);
|
||||
kerepType_register(Autoarr_int8, kerepTypeId_AutoarrInt8, ____Autoarr_free_int8);
|
||||
kerepType_register(Autoarr_uint8, kerepTypeId_AutoarrUInt8, ____Autoarr_free_uint8);
|
||||
kerepType_register(Autoarr_int16, kerepTypeId_AutoarrInt16, ____Autoarr_free_int16);
|
||||
kerepType_register(Autoarr_uint16, kerepTypeId_AutoarrUInt16, ____Autoarr_free_uint16);
|
||||
kerepType_register(Autoarr_int32, kerepTypeId_AutoarrInt32, ____Autoarr_free_int32);
|
||||
kerepType_register(Autoarr_uint32, kerepTypeId_AutoarrUInt32, ____Autoarr_free_uint32);
|
||||
kerepType_register(Autoarr_int64, kerepTypeId_AutoarrInt64, ____Autoarr_free_int64);
|
||||
kerepType_register(Autoarr_uint64, kerepTypeId_AutoarrUInt64, ____Autoarr_free_uint64);
|
||||
// base type autoarr pointers
|
||||
kerepType_register(Autoarr_char*, AutoarrCharPtr, ____Autoarr_free_char);
|
||||
kerepType_register(Autoarr_bool*, AutoarrBoolPtr, ____Autoarr_free_bool);
|
||||
kerepType_register(Autoarr_float32*, AutoarrFloat32Ptr, ____Autoarr_free_float32);
|
||||
kerepType_register(Autoarr_float64*, AutoarrFloat64Ptr, ____Autoarr_free_float64);
|
||||
kerepType_register(Autoarr_int8*, AutoarrInt8Ptr, ____Autoarr_free_int8);
|
||||
kerepType_register(Autoarr_uint8*, AutoarrUInt8Ptr, ____Autoarr_free_uint8);
|
||||
kerepType_register(Autoarr_int16*, AutoarrInt16Ptr, ____Autoarr_free_int16);
|
||||
kerepType_register(Autoarr_uint16*, AutoarrUInt16Ptr, ____Autoarr_free_uint16);
|
||||
kerepType_register(Autoarr_int32*, AutoarrInt32Ptr, ____Autoarr_free_int32);
|
||||
kerepType_register(Autoarr_uint32*, AutoarrUInt32Ptr, ____Autoarr_free_uint32);
|
||||
kerepType_register(Autoarr_int64*, AutoarrInt64Ptr, ____Autoarr_free_int64);
|
||||
kerepType_register(Autoarr_uint64*, AutoarrUInt64Ptr, ____Autoarr_free_uint64);
|
||||
kerepType_register(Autoarr_char*, kerepTypeId_AutoarrCharPtr, ____Autoarr_free_char);
|
||||
kerepType_register(Autoarr_bool*, kerepTypeId_AutoarrBoolPtr, ____Autoarr_free_bool);
|
||||
kerepType_register(Autoarr_float32*, kerepTypeId_AutoarrFloat32Ptr, ____Autoarr_free_float32);
|
||||
kerepType_register(Autoarr_float64*, kerepTypeId_AutoarrFloat64Ptr, ____Autoarr_free_float64);
|
||||
kerepType_register(Autoarr_int8*, kerepTypeId_AutoarrInt8Ptr, ____Autoarr_free_int8);
|
||||
kerepType_register(Autoarr_uint8*, kerepTypeId_AutoarrUInt8Ptr, ____Autoarr_free_uint8);
|
||||
kerepType_register(Autoarr_int16*, kerepTypeId_AutoarrInt16Ptr, ____Autoarr_free_int16);
|
||||
kerepType_register(Autoarr_uint16*, kerepTypeId_AutoarrUInt16Ptr, ____Autoarr_free_uint16);
|
||||
kerepType_register(Autoarr_int32*, kerepTypeId_AutoarrInt32Ptr, ____Autoarr_free_int32);
|
||||
kerepType_register(Autoarr_uint32*, kerepTypeId_AutoarrUInt32Ptr, ____Autoarr_free_uint32);
|
||||
kerepType_register(Autoarr_int64*, kerepTypeId_AutoarrInt64Ptr, ____Autoarr_free_int64);
|
||||
kerepType_register(Autoarr_uint64*, kerepTypeId_AutoarrUInt64Ptr, ____Autoarr_free_uint64);
|
||||
|
||||
// Unitype
|
||||
kerepType_register(Unitype, Unitype, __UnitypePtr_free);
|
||||
kerepType_register(Unitype*, UnitypePtr, __UnitypePtr_free);
|
||||
kerepType_register(Autoarr_Unitype, AutoarrUnitype, ____Autoarr_free_Unitype_);
|
||||
kerepType_register(Autoarr_Unitype*, AutoarrUnitypePtr, ____Autoarr_free_Unitype_);
|
||||
kerepType_register(Unitype, kerepTypeId_Unitype, __UnitypePtr_free);
|
||||
kerepType_register(Unitype*, kerepTypeId_UnitypePtr, __UnitypePtr_free);
|
||||
kerepType_register(Autoarr_Unitype, kerepTypeId_AutoarrUnitype, ____Autoarr_free_Unitype_);
|
||||
kerepType_register(Autoarr_Unitype*, kerepTypeId_AutoarrUnitypePtr, ____Autoarr_free_Unitype_);
|
||||
// replacing autogenerated freear() function to custom
|
||||
Autoarr_Unitype* _uar=Autoarr_create(Unitype, 1, 1);
|
||||
_uar->functions->freear=__Autoarr_free_Unitype_;
|
||||
Autoarr_free(_uar, true);
|
||||
|
||||
// SearchTreeNode
|
||||
kerepType_register(STNode, STNode, __STNode_free);
|
||||
kerepType_register(STNode*, STNodePtr, __STNode_free);
|
||||
kerepType_register(STNode, kerepTypeId_STNode, __STNode_free);
|
||||
kerepType_register(STNode*, kerepTypeId_STNodePtr, __STNode_free);
|
||||
|
||||
// KeyValuePair
|
||||
kerepType_register(KVPair, KVPair, __KVPair_free);
|
||||
kerepType_register(KVPair*, KVPairPtr, __KVPair_free);
|
||||
kerepType_register(Autoarr_KVPair, AutoarrKVPair, ____Autoarr_free_KVPair_);
|
||||
kerepType_register(Autoarr_KVPair*, AutoarrKVPairPtr, ____Autoarr_free_KVPair_);
|
||||
kerepType_register(KVPair, kerepTypeId_KVPair, __KVPair_free);
|
||||
kerepType_register(KVPair*, kerepTypeId_KVPairPtr, __KVPair_free);
|
||||
kerepType_register(Autoarr_KVPair, kerepTypeId_AutoarrKVPair, ____Autoarr_free_KVPair_);
|
||||
kerepType_register(Autoarr_KVPair*, kerepTypeId_AutoarrKVPairPtr, ____Autoarr_free_KVPair_);
|
||||
// replacing autogenerated freear() function to custom
|
||||
Autoarr_KVPair* _kvpar=Autoarr_create(KVPair, 1, 1);
|
||||
_kvpar->functions->freear=__Autoarr_free_KVPair_;
|
||||
Autoarr_free(_kvpar, true);
|
||||
|
||||
// Hashtable
|
||||
kerepType_register(Hashtable, Hashtable, __Hashtable_free);
|
||||
kerepType_register(Hashtable*, HashtablePtr, __Hashtable_free);
|
||||
kerepType_register(Hashtable, kerepTypeId_Hashtable, __Hashtable_free);
|
||||
kerepType_register(Hashtable*, kerepTypeId_HashtablePtr, __Hashtable_free);
|
||||
|
||||
// StringBuilder
|
||||
kerepType_register(StringBuilder, StringBuilder, __StringBuilder_free);
|
||||
kerepType_register(StringBuilder*, StringBuilderPtr, __StringBuilder_free);
|
||||
kerepType_register(StringBuilder, kerepTypeId_StringBuilder, __StringBuilder_free);
|
||||
kerepType_register(StringBuilder*, kerepTypeId_StringBuilderPtr, __StringBuilder_free);
|
||||
}
|
||||
|
||||
@@ -15,47 +15,49 @@ typedef struct kerepTypeDescriptor{
|
||||
uint16 size;
|
||||
} kerepTypeDescriptor;
|
||||
|
||||
#define kerepType_declare(NAME)\
|
||||
extern kerepTypeId kerepTypeId_##NAME
|
||||
#define kerepTypeId_declare(ID_VAR_NAME)\
|
||||
extern kerepTypeId ID_VAR_NAME
|
||||
#define kerepTypeId_define(ID_VAR_NAME)\
|
||||
kerepTypeId ID_VAR_NAME=-1
|
||||
|
||||
extern kerepTypeId kerepTypeId_last;
|
||||
void __kerepType_register(char* name, int16 size, void (*free_members)(void*));
|
||||
|
||||
#define kerepType_register(TYPE, NAME, FREE_MEMBERS_FUNC)\
|
||||
__kerepType_register(#NAME, sizeof(TYPE), FREE_MEMBERS_FUNC);\
|
||||
kerepTypeId_##NAME=kerepTypeId_last;
|
||||
#define kerepType_register(TYPE, ID_VAR_NAME, FREE_MEMBERS_FUNC)\
|
||||
__kerepType_register(#ID_VAR_NAME, sizeof(TYPE), FREE_MEMBERS_FUNC);\
|
||||
ID_VAR_NAME=kerepTypeId_last;
|
||||
|
||||
void kerepTypeDescriptors_beginInit();
|
||||
void kerepTypeDescriptors_endInit();
|
||||
kerepTypeDescriptor kerepTypeDescriptor_get(kerepTypeId id);
|
||||
|
||||
kerepType_declare(Null);
|
||||
kerepTypeId_declare(kerepTypeId_Null);
|
||||
|
||||
kerepType_declare(Char);
|
||||
kerepType_declare(Bool);
|
||||
kerepType_declare(Float32);
|
||||
kerepType_declare(Float64);
|
||||
kerepType_declare(Int8);
|
||||
kerepType_declare(UInt8);
|
||||
kerepType_declare(Int16);
|
||||
kerepType_declare(UInt16);
|
||||
kerepType_declare(Int32);
|
||||
kerepType_declare(UInt32);
|
||||
kerepType_declare(Int64);
|
||||
kerepType_declare(UInt64);
|
||||
kerepTypeId_declare(kerepTypeId_Char);
|
||||
kerepTypeId_declare(kerepTypeId_Bool);
|
||||
kerepTypeId_declare(kerepTypeId_Float32);
|
||||
kerepTypeId_declare(kerepTypeId_Float64);
|
||||
kerepTypeId_declare(kerepTypeId_Int8);
|
||||
kerepTypeId_declare(kerepTypeId_UInt8);
|
||||
kerepTypeId_declare(kerepTypeId_Int16);
|
||||
kerepTypeId_declare(kerepTypeId_UInt16);
|
||||
kerepTypeId_declare(kerepTypeId_Int32);
|
||||
kerepTypeId_declare(kerepTypeId_UInt32);
|
||||
kerepTypeId_declare(kerepTypeId_Int64);
|
||||
kerepTypeId_declare(kerepTypeId_UInt64);
|
||||
|
||||
kerepType_declare(CharPtr);
|
||||
kerepType_declare(BoolPtr);
|
||||
kerepType_declare(Float32Ptr);
|
||||
kerepType_declare(Float64Ptr);
|
||||
kerepType_declare(Int8Ptr);
|
||||
kerepType_declare(UInt8Ptr);
|
||||
kerepType_declare(Int16Ptr);
|
||||
kerepType_declare(UInt16Ptr);
|
||||
kerepType_declare(Int32Ptr);
|
||||
kerepType_declare(UInt32Ptr);
|
||||
kerepType_declare(Int64Ptr);
|
||||
kerepType_declare(UInt64Ptr);
|
||||
kerepTypeId_declare(kerepTypeId_CharPtr);
|
||||
kerepTypeId_declare(kerepTypeId_BoolPtr);
|
||||
kerepTypeId_declare(kerepTypeId_Float32Ptr);
|
||||
kerepTypeId_declare(kerepTypeId_Float64Ptr);
|
||||
kerepTypeId_declare(kerepTypeId_Int8Ptr);
|
||||
kerepTypeId_declare(kerepTypeId_UInt8Ptr);
|
||||
kerepTypeId_declare(kerepTypeId_Int16Ptr);
|
||||
kerepTypeId_declare(kerepTypeId_UInt16Ptr);
|
||||
kerepTypeId_declare(kerepTypeId_Int32Ptr);
|
||||
kerepTypeId_declare(kerepTypeId_UInt32Ptr);
|
||||
kerepTypeId_declare(kerepTypeId_Int64Ptr);
|
||||
kerepTypeId_declare(kerepTypeId_UInt64Ptr);
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -18,24 +18,24 @@ typedef struct Unitype{
|
||||
kerepTypeId typeId;
|
||||
bool allocatedInHeap; // should Unitype_free call free() to VoidPtr*
|
||||
} Unitype;
|
||||
kerepType_declare(Unitype);
|
||||
kerepType_declare(UnitypePtr);
|
||||
kerepTypeId_declare(kerepTypeId_Unitype);
|
||||
kerepTypeId_declare(kerepTypeId_UnitypePtr);
|
||||
|
||||
|
||||
#define __Uni(TYPE,VAL) (Unitype){\
|
||||
.TYPE_NAME=VAL, .typeId=kerepTypeId_##TYPE, .allocatedInHeap=false}
|
||||
#define Uni(TYPE, VAL) (Unitype){\
|
||||
.TYPE=VAL, .typeId=kerepTypeId_##TYPE, .allocatedInHeap=false}
|
||||
|
||||
#define UniInt64(VAL) __Uni(Int64, VAL)
|
||||
#define UniUInt64(VAL) __Uni(UInt64, VAL)
|
||||
#define UniFloat64(VAL) __Uni(Float64, VAL)
|
||||
#define UniBool(VAL) __Uni(Bool, VAL)
|
||||
#define UniInt64(VAL) Uni(Int64, VAL)
|
||||
#define UniUInt64(VAL) Uni(UInt64, VAL)
|
||||
#define UniFloat64(VAL) Uni(Float64, VAL)
|
||||
#define UniBool(VAL) Uni(Bool, VAL)
|
||||
|
||||
#define UniPtrStack(TYPE_NAME,VAL) (Unitype){\
|
||||
.VoidPtr=VAL, .typeId=kerepTypeId_##TYPE_NAME, .allocatedInHeap=false}
|
||||
#define UniPtrHeap (TYPE_NAME,VAL) (Unitype){\
|
||||
.VoidPtr=VAL, .typeId=kerepTypeId_##TYPE_NAME, .allocatedInHeap=true}
|
||||
#define UniPtrStack(ID_VAR_NAME, VAL) (Unitype){\
|
||||
.VoidPtr=VAL, .typeId=ID_VAR_NAME, .allocatedInHeap=false}
|
||||
#define UniPtrHeap(ID_VAR_NAME, VAL) (Unitype){\
|
||||
.VoidPtr=VAL, .typeId=ID_VAR_NAME, .allocatedInHeap=true}
|
||||
|
||||
#define UniNull UniPtrStack(Null, NULL)
|
||||
#define UniNull UniPtrStack(kerepTypeId_Null, NULL)
|
||||
#define UniTrue UniBool(true)
|
||||
#define UniFalse UniBool(false)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user