visual studio project
This commit is contained in:
parent
5bc866cf3e
commit
c1d004f411
15
.gitignore
vendored
15
.gitignore
vendored
@ -1,13 +1,12 @@
|
|||||||
# Build results
|
# Build results
|
||||||
[Bb]in/
|
bin/
|
||||||
|
bin-*/
|
||||||
.bin/
|
.bin/
|
||||||
[Dd]ebug/
|
obj/
|
||||||
[Rr]elease/
|
obj-*/
|
||||||
[Rr]eleases/
|
log/
|
||||||
[Oo]bj/
|
logs/
|
||||||
[Oo]ut/
|
logs-*/
|
||||||
[Ll]og/
|
|
||||||
[Ll]ogs/
|
|
||||||
|
|
||||||
# IDE files
|
# IDE files
|
||||||
.vs/
|
.vs/
|
||||||
|
|||||||
@ -1,22 +1,26 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Autoarr_declare.h"
|
#include "Autoarr_declare.h"
|
||||||
#include "Autoarr_define.h"
|
#include "Autoarr_define.h"
|
||||||
|
|
||||||
declare_Autoarr(uint8)
|
declare_Autoarr(uint8)
|
||||||
declare_Autoarr(int8)
|
declare_Autoarr(int8)
|
||||||
declare_Autoarr(uint16)
|
declare_Autoarr(uint16)
|
||||||
declare_Autoarr(int16)
|
declare_Autoarr(int16)
|
||||||
declare_Autoarr(uint32)
|
declare_Autoarr(uint32)
|
||||||
declare_Autoarr(int32)
|
declare_Autoarr(int32)
|
||||||
declare_Autoarr(uint64)
|
declare_Autoarr(uint64)
|
||||||
declare_Autoarr(int64)
|
declare_Autoarr(int64)
|
||||||
declare_Autoarr(float)
|
declare_Autoarr(float)
|
||||||
declare_Autoarr(double)
|
declare_Autoarr(double)
|
||||||
declare_Autoarr(Unitype)
|
declare_Autoarr(Unitype)
|
||||||
|
|
||||||
//right func to clear array of unitype values
|
//right func to clear array of unitype values
|
||||||
void Autoarr_Unitype_clear(Autoarr(Unitype)* ar);
|
void Autoarr_Unitype_clear(Autoarr(Unitype)* ar);
|
||||||
|
|
||||||
#define Autoarr_foreach(ar,elem,codeblock)({\
|
#define Autoarr_foreach(ar,elem,codeblock)({\
|
||||||
if(ar->blocks_count>0) {\
|
if(ar->blocks_count>0) {\
|
||||||
@ -32,3 +36,7 @@ void Autoarr_Unitype_clear(Autoarr(Unitype)* ar);
|
|||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
})
|
})
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -1,5 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../base/base.h"
|
#include "../base/base.h"
|
||||||
|
|
||||||
#define declare_Autoarr(type)\
|
#define declare_Autoarr(type)\
|
||||||
@ -59,3 +63,7 @@ Autoarr_##type __Autoarr_create_##type(uint16 max_blocks_count, uint16 max_block
|
|||||||
}\
|
}\
|
||||||
else AR->block_length--;\
|
else AR->block_length--;\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -1,5 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../base/base.h"
|
#include "../base/base.h"
|
||||||
|
|
||||||
#define define_Autoarr(type)\
|
#define define_Autoarr(type)\
|
||||||
@ -62,3 +66,7 @@ Autoarr_##type __Autoarr_create_##type(uint16 max_blocks_count, uint16 max_block
|
|||||||
.functions=&__functions_list_##type\
|
.functions=&__functions_list_##type\
|
||||||
};\
|
};\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -1,14 +1,22 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Autoarr.h"
|
#include "Autoarr.h"
|
||||||
|
|
||||||
typedef Autoarr(int8) StringBuilder;
|
typedef Autoarr(int8) StringBuilder;
|
||||||
|
|
||||||
StringBuilder StringBuilder_create(uint16 max_blocks_count, uint16 max_block_length);
|
StringBuilder StringBuilder_create(uint16 max_blocks_count, uint16 max_block_length);
|
||||||
void StringBuilder_append_char(StringBuilder* b, char c);
|
void StringBuilder_append_char(StringBuilder* b, char c);
|
||||||
void StringBuilder_append_cptr(StringBuilder* b, char* s);
|
void StringBuilder_append_cptr(StringBuilder* b, char* s);
|
||||||
void StringBuilder_append_string(StringBuilder* b, string s);
|
void StringBuilder_append_string(StringBuilder* b, string s);
|
||||||
void StringBuilder_append_int64(StringBuilder* b, int64 a);
|
void StringBuilder_append_int64(StringBuilder* b, int64 a);
|
||||||
void StringBuilder_append_uint64(StringBuilder* b, uint64 a);
|
void StringBuilder_append_uint64(StringBuilder* b, uint64 a);
|
||||||
void StringBuilder_append_double(StringBuilder* b, double a);
|
void StringBuilder_append_double(StringBuilder* b, double a);
|
||||||
char* StringBuilder_build(StringBuilder* b);
|
char* StringBuilder_build(StringBuilder* b);
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -1,9 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "../base/base.h"
|
|
||||||
#include "../Hashtable/Hashtable.h"
|
#include "../Hashtable/Hashtable.h"
|
||||||
|
|
||||||
//parses text to binary values
|
//parses text to binary values
|
||||||
|
|||||||
@ -6,234 +6,259 @@
|
|||||||
#define STRB_BC 64
|
#define STRB_BC 64
|
||||||
#define STRB_BL 1024
|
#define STRB_BL 1024
|
||||||
|
|
||||||
Hashtable* __deserialize(char** _text, bool calledRecursively){
|
void __throw_wrongchar(char* file, int line, char* fname, char _c, char* _text) {
|
||||||
Hashtable* dict=Hashtable_create();
|
char errBuf[]="unexpected <c> at:\n \""
|
||||||
char* text=*_text;
|
"00000000000000000000000000000000\"";
|
||||||
|
errBuf[12]=_c;
|
||||||
|
for (uint8 i=0; i < 32; i++)
|
||||||
|
errBuf[i + 22]=*(_text - 16 + i);
|
||||||
|
printf("\n\e[91m[%s:%d %s] throwed error: %s\n", file, line, fname, errBuf);
|
||||||
|
exit(128);
|
||||||
|
};
|
||||||
|
#define throw_wrongchar(C) __throw_wrongchar(__FILE__,__LINE__,__func__,C, text)
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct DeserializeSharedData{
|
||||||
|
char* sh_text;
|
||||||
|
bool sh_partOfDollarList;
|
||||||
|
bool sh_readingList;
|
||||||
|
bool sh_calledRecursively;
|
||||||
|
} DeserializeSharedData;
|
||||||
|
#define text shared->sh_text
|
||||||
|
#define partOfDollarList shared->sh_partOfDollarList
|
||||||
|
#define readingList shared->sh_readingList
|
||||||
|
#define calledRecursively shared->sh_calledRecursively
|
||||||
|
|
||||||
|
void __SkipComment(DeserializeSharedData* shared) {
|
||||||
char c;
|
char c;
|
||||||
bool partOfDollarList=false;
|
while ((c=*++text) != '\n')
|
||||||
bool readingList=false;
|
if (!c) throw(ERR_ENDOFSTR);
|
||||||
|
};
|
||||||
|
#define SkipComment() __SkipComment(shared)
|
||||||
|
|
||||||
void __throw_wrongchar(char* file, int line, char* fname,char _c){
|
string __ReadName(DeserializeSharedData* shared){
|
||||||
char errBuf[]="unexpected <c> at:\n \""
|
char c;
|
||||||
"00000000000000000000000000000000\"";
|
string nameStr={text,0};
|
||||||
errBuf[12]=_c;
|
text--;
|
||||||
for(uint8 i=0;i<32;i++)
|
while ((c=*++text)) switch (c){
|
||||||
errBuf[i+22]=*(text-16+i);
|
case ' ': case '\t':
|
||||||
printf("\n\e[91m[%s:%d %s] throwed error: %s\n",file,line,fname,errBuf);
|
case '\r': case '\n':
|
||||||
exit(128);
|
if(nameStr.length!=0)
|
||||||
};
|
|
||||||
#define throw_wrongchar(C) __throw_wrongchar(__FILE__,__LINE__,__func__,C)
|
|
||||||
|
|
||||||
|
|
||||||
void SkipComment(){
|
|
||||||
while((c=*++text)!='\n')
|
|
||||||
if(!c) throw(ERR_ENDOFSTR);
|
|
||||||
};
|
|
||||||
|
|
||||||
string ReadName(){
|
|
||||||
string nameStr={text,0};
|
|
||||||
text--;
|
|
||||||
while ((c=*++text)) switch (c){
|
|
||||||
case ' ': case '\t':
|
|
||||||
case '\r': case '\n':
|
|
||||||
if(nameStr.length!=0)
|
|
||||||
throw_wrongchar(c);
|
|
||||||
nameStr.ptr++;
|
|
||||||
break;
|
|
||||||
case '=': case ';':
|
|
||||||
case '\'': case '"':
|
|
||||||
case '[': case ']':
|
|
||||||
case '{':
|
|
||||||
throw_wrongchar(c);
|
throw_wrongchar(c);
|
||||||
break;
|
nameStr.ptr++;
|
||||||
case '#':
|
break;
|
||||||
SkipComment();
|
case '=': case ';':
|
||||||
if(nameStr.length!=0)
|
case '\'': case '"':
|
||||||
throw_wrongchar(c);
|
case '[': case ']':
|
||||||
nameStr.ptr=text+1; //skips '\n'
|
case '{':
|
||||||
break;
|
throw_wrongchar(c);
|
||||||
case '}':
|
break;
|
||||||
if(!calledRecursively) throw_wrongchar(c);
|
case '#':
|
||||||
if((*++text)!=';')
|
SkipComment();
|
||||||
throw_wrongchar(c);
|
if(nameStr.length!=0)
|
||||||
case ':':
|
throw_wrongchar(c);
|
||||||
return nameStr;
|
nameStr.ptr=text+1; //skips '\n'
|
||||||
case '$':
|
break;
|
||||||
if(nameStr.length!=0)
|
case '}':
|
||||||
throw_wrongchar(c);
|
if(!calledRecursively) throw_wrongchar(c);
|
||||||
nameStr.ptr++;
|
if((*++text)!=';')
|
||||||
partOfDollarList=true;
|
throw_wrongchar(c);
|
||||||
break;
|
case ':':
|
||||||
default:
|
return nameStr;
|
||||||
nameStr.length++;
|
case '$':
|
||||||
break;
|
if(nameStr.length!=0)
|
||||||
}
|
throw_wrongchar(c);
|
||||||
|
nameStr.ptr++;
|
||||||
|
partOfDollarList=true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
nameStr.length++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(nameStr.length>0) throw(ERR_ENDOFSTR);
|
if(nameStr.length>0) throw(ERR_ENDOFSTR);
|
||||||
return nameStr;
|
return nameStr;
|
||||||
};
|
};
|
||||||
|
#define ReadName() __ReadName(shared)
|
||||||
|
|
||||||
Unitype ReadValue(){
|
Hashtable* __deserialize(char** _text, bool _calledRecursively);
|
||||||
//returns part of <text> without quotes
|
Unitype __ReadValue(DeserializeSharedData* shared);
|
||||||
char* ReadString(){
|
#define ReadValue() __ReadValue(shared)
|
||||||
bool prevIsBackslash=false;
|
|
||||||
StringBuilder _b=StringBuilder_create(STRB_BC,STRB_BL);
|
//returns part of <text> without quotes
|
||||||
StringBuilder* b=&_b;
|
char* __ReadString(DeserializeSharedData* shared){
|
||||||
while ((c=*++text)){
|
char c;
|
||||||
if(c=='"') {
|
bool prevIsBackslash=false;
|
||||||
if(prevIsBackslash) {
|
StringBuilder _b=StringBuilder_create(STRB_BC,STRB_BL);
|
||||||
//replacing <\"> with <">
|
StringBuilder* b=&_b;
|
||||||
Autoarr_remove(b);
|
while ((c=*++text)){
|
||||||
StringBuilder_append_char(b,c);
|
if(c=='"') {
|
||||||
}
|
if(prevIsBackslash) {
|
||||||
else {
|
//replacing <\"> with <">
|
||||||
char* str=StringBuilder_build(b);
|
Autoarr_remove(b);
|
||||||
Autoarr_clear(b);
|
StringBuilder_append_char(b,c);
|
||||||
return str;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
prevIsBackslash= c=='\\' && !prevIsBackslash;
|
|
||||||
StringBuilder_append_char(b,c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
throw(ERR_ENDOFSTR);
|
else {
|
||||||
return NULL;
|
char* str=StringBuilder_build(b);
|
||||||
};
|
Autoarr_clear(b);
|
||||||
|
return str;
|
||||||
Autoarr(Unitype)* ReadList(){
|
|
||||||
Autoarr(Unitype)* list=malloc(sizeof(Autoarr(Unitype)));
|
|
||||||
*list=Autoarr_create(Unitype,ARR_BC,ARR_BL);
|
|
||||||
readingList=true;
|
|
||||||
while (true){
|
|
||||||
Autoarr_add(list,ReadValue());
|
|
||||||
if (!readingList) break;
|
|
||||||
}
|
}
|
||||||
return list;
|
|
||||||
};
|
|
||||||
|
|
||||||
Hashtable* ReadDtsod(){
|
|
||||||
++text; //skips '{'
|
|
||||||
return __deserialize(&text,true);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
prevIsBackslash= c=='\\' && !prevIsBackslash;
|
||||||
|
StringBuilder_append_char(b,c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw(ERR_ENDOFSTR);
|
||||||
|
return NULL;
|
||||||
|
};
|
||||||
|
#define ReadString() __ReadString(shared)
|
||||||
|
|
||||||
Unitype ParseValue(string str){
|
Autoarr(Unitype)* __ReadList(DeserializeSharedData* shared){
|
||||||
//printf("\e[94m<\e[96m%s\e[94m>\n",string_cpToCharPtr(str));
|
Autoarr(Unitype)* list=malloc(sizeof(Autoarr(Unitype)));
|
||||||
const string nullStr={"null",4};
|
*list=Autoarr_create(Unitype,ARR_BC,ARR_BL);
|
||||||
const string trueStr={"true",4};
|
readingList=true;
|
||||||
const string falseStr={"false",5};
|
while (true){
|
||||||
switch(*str.ptr){
|
Autoarr_add(list,ReadValue());
|
||||||
case 'n':
|
if (!readingList) break;
|
||||||
if(string_compare(str,nullStr))
|
}
|
||||||
return UniNull;
|
return list;
|
||||||
else throw_wrongchar(*str.ptr);
|
};
|
||||||
break;
|
#define ReadList() __ReadList(shared)
|
||||||
case 't':
|
|
||||||
if(string_compare(str,trueStr))
|
Unitype __ParseValue(DeserializeSharedData* shared, string str){
|
||||||
return UniTrue;
|
//printf("\e[94m<\e[96m%s\e[94m>\n",string_cpToCptr(str));
|
||||||
else throw_wrongchar(*str.ptr);
|
const string nullStr={"null",4};
|
||||||
break;
|
const string trueStr={"true",4};
|
||||||
case 'f':
|
const string falseStr={"false",5};
|
||||||
if(string_compare(str,falseStr))
|
switch(*str.ptr){
|
||||||
return UniFalse;
|
case 'n':
|
||||||
else throw_wrongchar(*str.ptr);
|
if(string_compare(str,nullStr))
|
||||||
break;
|
return UniNull;
|
||||||
|
else throw_wrongchar(*str.ptr);
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
if(string_compare(str,trueStr))
|
||||||
|
return UniTrue;
|
||||||
|
else throw_wrongchar(*str.ptr);
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
if(string_compare(str,falseStr))
|
||||||
|
return UniFalse;
|
||||||
|
else throw_wrongchar(*str.ptr);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
switch(str.ptr[str.length-1]){
|
||||||
|
case 'f': {
|
||||||
|
char* _c=string_cpToCptr(str);
|
||||||
|
Unitype rez=Uni(Double,strtod(_c,NULL));
|
||||||
|
free(_c);
|
||||||
|
return rez;
|
||||||
|
}
|
||||||
|
case 'u': {
|
||||||
|
uint64 lu=0;
|
||||||
|
char* _c=string_cpToCptr(str);
|
||||||
|
sscanf(_c,"%lu",&lu);
|
||||||
|
free(_c);
|
||||||
|
return Uni(UInt64,lu);
|
||||||
|
}
|
||||||
|
case '0': case '1': case '2': case '3': case '4':
|
||||||
|
case '5': case '6': case '7': case '8': case '9': {
|
||||||
|
int64 li=0;
|
||||||
|
char* _c=string_cpToCptr(str);
|
||||||
|
if(sscanf(_c,"%li",&li)!=1){
|
||||||
|
char err[64];
|
||||||
|
sprintf(err,"can't parse to int: <%s>",_c);
|
||||||
|
throw(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(_c);
|
||||||
|
return Uni(Int64,li);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
switch(str.ptr[str.length-1]){
|
throw_wrongchar(str.ptr[str.length-1]);
|
||||||
case 'f': {
|
|
||||||
char* _c=string_cpToCharPtr(str);
|
|
||||||
Unitype rez=Uni(Double,strtod(_c,NULL));
|
|
||||||
free(_c);
|
|
||||||
return rez;
|
|
||||||
}
|
|
||||||
case 'u': {
|
|
||||||
uint64 lu=0;
|
|
||||||
char* _c=string_cpToCharPtr(str);
|
|
||||||
sscanf(_c,"%lu",&lu);
|
|
||||||
free(_c);
|
|
||||||
return Uni(UInt64,lu);
|
|
||||||
}
|
|
||||||
case '0': case '1': case '2': case '3': case '4':
|
|
||||||
case '5': case '6': case '7': case '8': case '9': {
|
|
||||||
int64 li=0;
|
|
||||||
char* _c=string_cpToCharPtr(str);
|
|
||||||
if(sscanf(_c,"%li",&li)!=1){
|
|
||||||
char err[64];
|
|
||||||
sprintf(err,"can't parse to int: <%s>",_c);
|
|
||||||
throw(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(_c);
|
|
||||||
return Uni(Int64,li);
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
throw_wrongchar(str.ptr[str.length-1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
throw(ERR_ENDOFSTR);
|
}
|
||||||
return UniNull;
|
throw(ERR_ENDOFSTR);
|
||||||
};
|
return UniNull;
|
||||||
|
};
|
||||||
|
#define ParseValue(str) __ParseValue(shared, str)
|
||||||
|
|
||||||
string valueStr={text+1,0};
|
Unitype __ReadValue(DeserializeSharedData* shared){
|
||||||
Unitype value;
|
char c;
|
||||||
while ((c=*++text)) switch (c){
|
string valueStr={text+1,0};
|
||||||
case ' ': case '\t':
|
Unitype value;
|
||||||
case '\r': case '\n':
|
while ((c=*++text)) switch (c){
|
||||||
if(valueStr.length!=0)
|
case ' ': case '\t':
|
||||||
throw_wrongchar(c);
|
case '\r': case '\n':
|
||||||
valueStr.ptr++;
|
if(valueStr.length!=0)
|
||||||
break;
|
|
||||||
case '=': case ':':
|
|
||||||
case '}': case '$':
|
|
||||||
throw_wrongchar(c);
|
throw_wrongchar(c);
|
||||||
break;
|
valueStr.ptr++;
|
||||||
case '#':;
|
break;
|
||||||
char _c=c;
|
case '=': case ':':
|
||||||
SkipComment();
|
case '}': case '$':
|
||||||
if(valueStr.length!=0)
|
throw_wrongchar(c);
|
||||||
throw_wrongchar(_c);
|
break;
|
||||||
valueStr.ptr=text+1; //skips '\n'
|
case '#':;
|
||||||
break;
|
char _c=c;
|
||||||
case '"':
|
SkipComment();
|
||||||
if(valueStr.length!=0) throw_wrongchar(c);
|
if(valueStr.length!=0)
|
||||||
value=UniPtr(CharPtr,ReadString());
|
throw_wrongchar(_c);
|
||||||
break;
|
valueStr.ptr=text+1; //skips '\n'
|
||||||
case '\'':
|
break;
|
||||||
if(valueStr.length!=0) throw_wrongchar(c);
|
case '"':
|
||||||
char valueChar=*++text;
|
if(valueStr.length!=0) throw_wrongchar(c);
|
||||||
if (*++text != '\'') throw("after <'> should be char");
|
value=UniPtr(CharPtr,ReadString());
|
||||||
value=Uni(Char,valueChar);
|
break;
|
||||||
break;
|
case '\'':
|
||||||
case '[':
|
if(valueStr.length!=0) throw_wrongchar(c);
|
||||||
if(valueStr.length!=0) throw_wrongchar(c);
|
char valueChar=*++text;
|
||||||
value=UniPtr(AutoarrUnitypePtr,ReadList());
|
if (*++text != '\'') throw("after <'> should be char");
|
||||||
case ']':
|
value=Uni(Char,valueChar);
|
||||||
readingList=false;
|
break;
|
||||||
break;
|
case '[':
|
||||||
case '{':
|
if(valueStr.length!=0) throw_wrongchar(c);
|
||||||
if(valueStr.length!=0) throw_wrongchar(c);
|
value=UniPtr(AutoarrUnitypePtr,ReadList());
|
||||||
value=UniPtr(HashtablePtr,ReadDtsod());
|
case ']':
|
||||||
return value;
|
readingList=false;
|
||||||
case ';':
|
break;
|
||||||
case ',':
|
case '{':
|
||||||
if(valueStr.length!=0)
|
if(valueStr.length!=0) throw_wrongchar(c);
|
||||||
value=ParseValue(valueStr);
|
++text; //skips '{'
|
||||||
return value;
|
value=UniPtr(HashtablePtr, __deserialize(&text,true));
|
||||||
default:
|
return value;
|
||||||
valueStr.length++;
|
case ';':
|
||||||
break;
|
case ',':
|
||||||
}
|
if(valueStr.length!=0)
|
||||||
|
value=ParseValue(valueStr);
|
||||||
|
return value;
|
||||||
|
default:
|
||||||
|
valueStr.length++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
throw(ERR_ENDOFSTR);
|
throw(ERR_ENDOFSTR);
|
||||||
return UniNull;
|
return UniNull;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Hashtable* __deserialize(char** _text, bool _calledRecursively) {
|
||||||
|
DeserializeSharedData _shared={
|
||||||
|
.sh_text=*_text,
|
||||||
|
.sh_partOfDollarList=false,
|
||||||
|
.sh_readingList=false,
|
||||||
|
.sh_calledRecursively=_calledRecursively
|
||||||
};
|
};
|
||||||
|
DeserializeSharedData* shared=&_shared;
|
||||||
|
Hashtable* dict=Hashtable_create();
|
||||||
|
char c;
|
||||||
|
|
||||||
text--;
|
text--;
|
||||||
while((c=*++text)){
|
while((c=*++text)){
|
||||||
string name=ReadName();
|
string name=ReadName();
|
||||||
if(name.length==0) //end of file or '}' in recursive call
|
if(name.length==0) //end of file or '}' in recursive call
|
||||||
goto END;
|
goto END;
|
||||||
char* nameCPtr=string_cpToCharPtr(name);
|
char* nameCPtr=string_cpToCptr(name);
|
||||||
Unitype value=ReadValue();
|
Unitype value=ReadValue();
|
||||||
if(partOfDollarList){
|
if(partOfDollarList){
|
||||||
Autoarr(Unitype)* list;
|
Autoarr(Unitype)* list;
|
||||||
@ -255,7 +280,6 @@ Hashtable* __deserialize(char** _text, bool calledRecursively){
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hashtable* DtsodV24_deserialize(char* text) {
|
Hashtable* DtsodV24_deserialize(char* _text) {
|
||||||
Hashtable* r=__deserialize(&text,false);
|
return __deserialize(&_text, false);
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|||||||
45
DtsodParser/DtsodV24_exported.c
Normal file
45
DtsodParser/DtsodV24_exported.c
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
//
|
||||||
|
// I planned to export functions from DtsodV24.h,
|
||||||
|
// but C# P/Invoke can't get returned values for some reason.
|
||||||
|
// Following functions return values by pointer, which looks in C# like out parameter
|
||||||
|
//
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "DtsodV24.h"
|
||||||
|
|
||||||
|
//parses text to binary values
|
||||||
|
EXPORT void CALL kerep_DtsodV24_deserialize(char* text, Hashtable** output){
|
||||||
|
*output=DtsodV24_deserialize(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
//creates text representation of dtsod
|
||||||
|
EXPORT void CALL kerep_DtsodV24_serialize(Hashtable* dtsod, char** output){
|
||||||
|
*output=DtsodV24_serialize(dtsod);
|
||||||
|
}
|
||||||
|
|
||||||
|
//returns value or UniNull if key not found
|
||||||
|
EXPORT void CALL kerep_DtsodV24_get(Hashtable* dtsod, char* key, Unitype* output){
|
||||||
|
*output=DtsodV24_get(dtsod, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
//adds or sets value
|
||||||
|
EXPORT void CALL kerep_DtsodV24_addOrSet(Hashtable* dtsod, char* key, Unitype value){
|
||||||
|
DtsodV24_addOrSet(dtsod, key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//checks for dtsod contains value or dont
|
||||||
|
EXPORT void CALL kerep_DtsodV24_contains(Hashtable* dtsod, char* key, bool* output){
|
||||||
|
*output=DtsodV24_contains(dtsod, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
//replaces value with UniNull if key exists in dtsod
|
||||||
|
EXPORT void CALL kerep_DtsodV24_remove(Hashtable* dtsod, char* key, bool* output){
|
||||||
|
*output=DtsodV24_remove(dtsod, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -5,86 +5,104 @@
|
|||||||
#define STRB_BC 64
|
#define STRB_BC 64
|
||||||
#define STRB_BL 1024
|
#define STRB_BL 1024
|
||||||
|
|
||||||
#define addc(B,C) StringBuilder_append_char(B,C)
|
typedef struct SerializeSharedData{
|
||||||
|
StringBuilder* sh_builder;
|
||||||
|
uint8 sh_tabs;
|
||||||
|
} SerializeSharedData;
|
||||||
|
#define b shared->sh_builder
|
||||||
|
#define tabs shared->sh_tabs
|
||||||
|
|
||||||
void __serialize(StringBuilder* b, uint8 tabs, Hashtable* dtsod){
|
void __serialize(StringBuilder* _b, uint8 _tabs, Hashtable* dtsod);
|
||||||
|
|
||||||
void AppendTabs(){
|
#define addc(C) StringBuilder_append_char(b,C)
|
||||||
for(uint8 t=0; t<tabs; t++)
|
|
||||||
addc(b,'\t');
|
|
||||||
};
|
void __AppendTabs(SerializeSharedData* shared) {
|
||||||
|
for (uint8 t = 0; t < tabs; t++)
|
||||||
void AppendValue(Unitype u){
|
addc( '\t');
|
||||||
switch(u.type){
|
};
|
||||||
case Int64:
|
#define AppendTabs() __AppendTabs(shared)
|
||||||
StringBuilder_append_int64(b,u.Int64);
|
|
||||||
break;
|
void __AppendValue(SerializeSharedData* shared, Unitype u);
|
||||||
case UInt64:
|
#define AppendValue(UNI) __AppendValue(shared, UNI)
|
||||||
StringBuilder_append_uint64(b,u.UInt64);
|
void __AppendValue(SerializeSharedData* shared, Unitype u){
|
||||||
addc(b,'u');
|
switch(u.type){
|
||||||
break;
|
case Int64:
|
||||||
case Double:
|
StringBuilder_append_int64(b,u.Int64);
|
||||||
StringBuilder_append_double(b,u.Double);
|
break;
|
||||||
addc(b,'f');
|
case UInt64:
|
||||||
break;
|
StringBuilder_append_uint64(b,u.UInt64);
|
||||||
case CharPtr:
|
addc('u');
|
||||||
addc(b,'"');
|
break;
|
||||||
char c;
|
case Double:
|
||||||
while((c=*(char*)(u.VoidPtr++))){
|
StringBuilder_append_double(b,u.Double);
|
||||||
if(c=='\"') addc(b,'\\');
|
addc('f');
|
||||||
addc(b,c);
|
break;
|
||||||
}
|
case CharPtr:
|
||||||
addc(b,'"');
|
addc('"');
|
||||||
break;
|
char c;
|
||||||
case Char:
|
while((c=*(char*)(u.VoidPtr++))){
|
||||||
addc(b,'\'');
|
if(c=='\"') addc('\\');
|
||||||
addc(b,u.Char);
|
addc(c);
|
||||||
addc(b,'\'');
|
}
|
||||||
break;
|
addc('"');
|
||||||
case Bool:
|
break;
|
||||||
StringBuilder_append_cptr(b, u.Bool ? "true" : "false");
|
case Char:
|
||||||
break;
|
addc('\'');
|
||||||
case Null:
|
addc(u.Char);
|
||||||
if(!u.VoidPtr) StringBuilder_append_cptr(b, "null");
|
addc('\'');
|
||||||
else throw("Null-type pointer is not 0");
|
break;
|
||||||
break;
|
case Bool:
|
||||||
case AutoarrUnitypePtr:
|
StringBuilder_append_cptr(b, u.Bool ? "true" : "false");
|
||||||
addc(b,'[');
|
break;
|
||||||
Autoarr_foreach(((Autoarr_Unitype*)(u.VoidPtr)), e, ({
|
case Null:
|
||||||
addc(b,' ');
|
if(!u.VoidPtr) StringBuilder_append_cptr(b, "null");
|
||||||
AppendValue(e);
|
else throw("Null-type pointer is not 0");
|
||||||
addc(b,',');
|
break;
|
||||||
}));
|
case AutoarrUnitypePtr:
|
||||||
Autoarr_remove(b);
|
addc('[');
|
||||||
addc(b,' ');
|
Autoarr_foreach(((Autoarr_Unitype*)(u.VoidPtr)), e, ({
|
||||||
addc(b,']');
|
addc(' ');
|
||||||
break;
|
AppendValue(e);
|
||||||
case HashtablePtr:
|
addc(',');
|
||||||
addc(b,'{');
|
}));
|
||||||
addc(b,'\n');
|
Autoarr_remove(b);
|
||||||
__serialize(b,tabs+1,u.VoidPtr);
|
addc(' ');
|
||||||
AppendTabs();
|
addc(']');
|
||||||
addc(b,'}');
|
break;
|
||||||
break;
|
case HashtablePtr:
|
||||||
default: dbg((u.type)); throw(ERR_WRONGTYPE);
|
addc('{');
|
||||||
}
|
addc('\n');
|
||||||
|
__serialize(b,tabs+1,u.VoidPtr);
|
||||||
|
AppendTabs();
|
||||||
|
addc('}');
|
||||||
|
break;
|
||||||
|
default: dbg((u.type)); throw(ERR_WRONGTYPE);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void __serialize(StringBuilder* _b, uint8 _tabs, Hashtable* dtsod){
|
||||||
|
SerializeSharedData _shared={
|
||||||
|
.sh_builder=_b,
|
||||||
|
.sh_tabs=_tabs
|
||||||
};
|
};
|
||||||
|
SerializeSharedData* shared=&_shared;
|
||||||
|
|
||||||
Hashtable_foreach(dtsod, p, ({
|
Hashtable_foreach(dtsod, p, ({
|
||||||
AppendTabs();
|
AppendTabs();
|
||||||
StringBuilder_append_cptr(b,p.key);
|
StringBuilder_append_cptr(b,p.key);
|
||||||
addc(b,':');
|
addc(':');
|
||||||
addc(b,' ');
|
addc(' ');
|
||||||
AppendValue(p.value);
|
AppendValue(p.value);
|
||||||
addc(b,';');
|
addc(';');
|
||||||
addc(b,'\n');
|
addc('\n');
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
char* DtsodV24_serialize(Hashtable* dtsod){
|
char* DtsodV24_serialize(Hashtable* dtsod){
|
||||||
StringBuilder b=StringBuilder_create(STRB_BC,STRB_BL);
|
StringBuilder sb=StringBuilder_create(STRB_BC,STRB_BL);
|
||||||
__serialize(&b,0,dtsod);
|
__serialize(&sb,0,dtsod);
|
||||||
char* str=StringBuilder_build(&b);
|
char* str=StringBuilder_build(&sb);
|
||||||
Autoarr_clear((&b));
|
Autoarr_clear((&sb));
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../base/base.h"
|
#include "../base/base.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "KeyValuePair.h"
|
#include "KeyValuePair.h"
|
||||||
@ -41,3 +45,7 @@ void Hashtable_set(Hashtable* ht, char* key, Unitype u);
|
|||||||
Autoarr_foreach(AR, EL, codeblock);\
|
Autoarr_foreach(AR, EL, codeblock);\
|
||||||
}\
|
}\
|
||||||
})
|
})
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -1,3 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../base/base.h"
|
#include "../base/base.h"
|
||||||
#include "../Autoarr/Autoarr.h"
|
#include "../Autoarr/Autoarr.h"
|
||||||
|
|
||||||
@ -15,3 +21,7 @@ void KeyValuePair_free(KeyValuePair p);
|
|||||||
void Autoarr_KeyValuePair_clear(Autoarr_KeyValuePair* ar);
|
void Autoarr_KeyValuePair_clear(Autoarr_KeyValuePair* ar);
|
||||||
|
|
||||||
void printkvp(KeyValuePair p);
|
void printkvp(KeyValuePair p);
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -1,8 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../base/base.h"
|
#include "../base/base.h"
|
||||||
|
|
||||||
//djb2 hash function from http://www.cse.yorku.ca/~oz/hash.html
|
//djb2 hash function from http://www.cse.yorku.ca/~oz/hash.html
|
||||||
uint32 ihash(char *str);
|
uint32 ihash(char *str);
|
||||||
//sdbm hash function
|
//sdbm hash function
|
||||||
uint64 lhash(char* str);
|
uint64 lhash(char* str);
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
20
Makefile
20
Makefile
@ -1,9 +1,9 @@
|
|||||||
SRC=$(wildcard [^tests]**/*.c)
|
SRC=$(wildcard [^tests]**/*.c)
|
||||||
TESTS=$(wildcard tests/*c) $(wildcard tests/**/*.c)
|
TESTS=$(wildcard tests/*c) $(wildcard tests/**/*.c)
|
||||||
OUTDIR=.bin
|
OUTDIR=bin
|
||||||
CMP=gcc
|
CMP=gcc
|
||||||
|
|
||||||
all: clear_c clear_bin build_test build_dll
|
all: clear_c clear_bin build_test build_lib
|
||||||
|
|
||||||
clear_c:
|
clear_c:
|
||||||
clear
|
clear
|
||||||
@ -27,7 +27,7 @@ build_test_dbg:
|
|||||||
@echo -e '\n\e[96m--------------[build_test_dbg]--------------\e[0m'
|
@echo -e '\n\e[96m--------------[build_test_dbg]--------------\e[0m'
|
||||||
$(CMP) -O0 -g $(TEST_ARGS).dbg
|
$(CMP) -O0 -g $(TEST_ARGS).dbg
|
||||||
|
|
||||||
test:
|
test: clear_c build_test
|
||||||
@echo -e '\n\e[96m----------------[test]-----------------\e[0m'
|
@echo -e '\n\e[96m----------------[test]-----------------\e[0m'
|
||||||
$(TEST_FILE)
|
$(TEST_FILE)
|
||||||
|
|
||||||
@ -36,10 +36,10 @@ valgrind: clear_c build_test_dbg
|
|||||||
valgrind -s --read-var-info=yes --track-origins=yes --fullpath-after=kerep/ \
|
valgrind -s --read-var-info=yes --track-origins=yes --fullpath-after=kerep/ \
|
||||||
--leak-check=full --show-leak-kinds=all $(TEST_FILE).dbg
|
--leak-check=full --show-leak-kinds=all $(TEST_FILE).dbg
|
||||||
|
|
||||||
DLL_FILE=$(OUTDIR)/kerep.dll
|
LIB_FILE=kerep.so
|
||||||
DLL_ARGS= -Wall -Wno-discarded-qualifiers \
|
LIB_ARGS= -Wall -Wno-discarded-qualifiers \
|
||||||
-fPIC -shared -Wl,-soname,kerep.dll \
|
-O1 -fPIC -shared -Wl,-soname,$(LIB_FILE) \
|
||||||
$(SRC) $(TESTS) -o $(DLL_FILE)
|
$(SRC) $(TESTS) -o $(OUTDIR)/$(LIB_FILE)
|
||||||
build_dll:
|
build_lib:
|
||||||
@echo -e '\n\e[96m-------------[build_dll]---------------\e[0m'
|
@echo -e '\n\e[96m-------------[build_lib]---------------\e[0m'
|
||||||
$(CMP) $(OPT_ARGS) $(DLL_ARGS)
|
$(CMP) $(OPT_ARGS) $(LIB_ARGS)
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
# kerep
|
# kerep
|
||||||
|
|
||||||
My static library written in C
|
My library written in C
|
||||||
@ -1,5 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../base/base.h"
|
#include "../base/base.h"
|
||||||
|
|
||||||
typedef struct SearchTreeNode{
|
typedef struct SearchTreeNode{
|
||||||
@ -12,3 +16,7 @@ void STNode_free(STNode* node);
|
|||||||
|
|
||||||
void ST_push(STNode* node, const char* key, Unitype value);
|
void ST_push(STNode* node, const char* key, Unitype value);
|
||||||
Unitype ST_pull(STNode* node, const char* key);
|
Unitype ST_pull(STNode* node, const char* key);
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
18
base/base.h
18
base/base.h
@ -1,12 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "std.h"
|
#include "std.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
#include "mystr.h"
|
#include "mystr.h"
|
||||||
|
|
||||||
// executes codeblock and prints execution time
|
// executes codeblock and prints execution time
|
||||||
#define optime(opname,repeats,codeblock) ({\
|
/*#define optime(opname,repeats,codeblock) ({\
|
||||||
struct timespec start, stop;\
|
struct timespec start, stop;\
|
||||||
clock_gettime(CLOCK_REALTIME, &start);\
|
clock_gettime(CLOCK_REALTIME, &start);\
|
||||||
for(uint64 ___OPREP=0;___OPREP<repeats;___OPREP++)\
|
for(uint64 ___OPREP=0;___OPREP<repeats;___OPREP++)\
|
||||||
@ -14,4 +18,16 @@
|
|||||||
clock_gettime(CLOCK_REALTIME, &stop);\
|
clock_gettime(CLOCK_REALTIME, &stop);\
|
||||||
double t=(double)(stop.tv_sec-start.tv_sec+(double)(stop.tv_nsec-start.tv_nsec)/1000000000)/repeats;\
|
double t=(double)(stop.tv_sec-start.tv_sec+(double)(stop.tv_nsec-start.tv_nsec)/1000000000)/repeats;\
|
||||||
printf("\e[93moperation \e[94m%s\e[93m lasted \e[94m%lf \e[93mseconds\n",opname,t);\
|
printf("\e[93moperation \e[94m%s\e[93m lasted \e[94m%lf \e[93mseconds\n",opname,t);\
|
||||||
|
})*/
|
||||||
|
#define optime(opname,repeats,codeblock) ({\
|
||||||
|
clock_t start=clock();\
|
||||||
|
for(uint64 ___OPREP=0;___OPREP<repeats;___OPREP++)\
|
||||||
|
(codeblock);\
|
||||||
|
clock_t stop=clock();\
|
||||||
|
double t=(double)(stop-start)/CLOCKS_PER_SEC/repeats;\
|
||||||
|
printf("\e[93moperation \e[94m%s\e[93m lasted \e[94m%lf \e[93mseconds\n",opname,t);\
|
||||||
})
|
})
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -1,5 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef enum err_t {
|
typedef enum err_t {
|
||||||
SUCCESS, //not an error
|
SUCCESS, //not an error
|
||||||
ERR_MAXLENGTH, ERR_WRONGTYPE, ERR_WRONGINDEX, ERR_NOTIMPLEMENTED, ERR_NULLPTR, ERR_ENDOFSTR
|
ERR_MAXLENGTH, ERR_WRONGTYPE, ERR_WRONGINDEX, ERR_NOTIMPLEMENTED, ERR_NULLPTR, ERR_ENDOFSTR
|
||||||
@ -14,3 +18,7 @@ void _throwstr(const char* errmesg, const char* srcfile, int line, const char* f
|
|||||||
CHOOSE(IFTYPE(E,int), _throwint(E,__FILE__,__LINE__,__func__), \
|
CHOOSE(IFTYPE(E,int), _throwint(E,__FILE__,__LINE__,__func__), \
|
||||||
CHOOSE(IFTYPE(E,char[]), _throwstr(E,__FILE__,__LINE__,__func__), \
|
CHOOSE(IFTYPE(E,char[]), _throwstr(E,__FILE__,__LINE__,__func__), \
|
||||||
printf("\e[31m[%s:%d/%s] UNKNOWN ERROR\n",__FILE__,__LINE__,__func__)))
|
printf("\e[31m[%s:%d/%s] UNKNOWN ERROR\n",__FILE__,__LINE__,__func__)))
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -36,7 +36,7 @@ char* char_multiply(char c, uint32 n){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//copies str content to new char pointer value (adding '\0' at the end)
|
//copies str content to new char pointer value (adding '\0' at the end)
|
||||||
char* string_cpToCharPtr(string str){
|
char* string_cpToCptr(string str){
|
||||||
char* cptr=malloc(str.length*sizeof(char)+1);
|
char* cptr=malloc(str.length*sizeof(char)+1);
|
||||||
if(str.length==0) return NULL;
|
if(str.length==0) return NULL;
|
||||||
cptr[str.length]=0;
|
cptr[str.length]=0;
|
||||||
|
|||||||
10
base/mystr.h
10
base/mystr.h
@ -1,5 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
//returns length of string (including \0)
|
//returns length of string (including \0)
|
||||||
@ -24,7 +28,7 @@ typedef struct string{
|
|||||||
static const string stringNull={NULL,0};
|
static const string stringNull={NULL,0};
|
||||||
|
|
||||||
//copies str content to new char pointer value (adding '\0' at the end)
|
//copies str content to new char pointer value (adding '\0' at the end)
|
||||||
char* string_cpToCharPtr(string str);
|
char* string_cpToCptr(string str);
|
||||||
|
|
||||||
//copies cptr content (excluding '\0' at the end) to new string
|
//copies cptr content (excluding '\0' at the end) to new string
|
||||||
string string_cpFromCharPtr(char* cptr);
|
string string_cpFromCharPtr(char* cptr);
|
||||||
@ -34,3 +38,7 @@ bool string_compare(string str0, string str1);
|
|||||||
|
|
||||||
//creates new string which is reversed variant of <s>
|
//creates new string which is reversed variant of <s>
|
||||||
string string_reverse(string s);
|
string string_reverse(string s);
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
36
base/std.h
36
base/std.h
@ -1,4 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -11,3 +16,34 @@
|
|||||||
#define IFTYPE(X, T) __builtin_types_compatible_p(typeof(X), T)
|
#define IFTYPE(X, T) __builtin_types_compatible_p(typeof(X), T)
|
||||||
|
|
||||||
#define dbg(N) printf("\e[95m%d\n",N)
|
#define dbg(N) printf("\e[95m%d\n",N)
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma comment(lib, "mincore_downlevel.lib") // Support OS older than SDK
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS 1
|
||||||
|
#define EXPORT __declspec(dllexport)
|
||||||
|
#define CALL __cdecl
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
#define EXPORT __attribute__((visibility("default")))
|
||||||
|
#if __SIZEOF_POINTER__ == 4
|
||||||
|
#define CALL __attribute__((__cdecl__))
|
||||||
|
#else
|
||||||
|
#define CALL
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#pragma GCC error "unknown compiler"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define IFWIN(YES, NO) YES
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
#define IFWIN(YES, NO) NO
|
||||||
|
#else
|
||||||
|
#pragma GCC error "unknown compiler"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
14
base/types.c
14
base/types.c
@ -4,7 +4,7 @@
|
|||||||
#include "../Hashtable/Hashtable.h"
|
#include "../Hashtable/Hashtable.h"
|
||||||
#include "../SearchTree/SearchTree.h"
|
#include "../SearchTree/SearchTree.h"
|
||||||
|
|
||||||
const char* typename(my_type t){
|
const char* my_type_name(my_type t){
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case Null: return "Null";
|
case Null: return "Null";
|
||||||
case Double: return "Double";
|
case Double: return "Double";
|
||||||
@ -119,12 +119,12 @@ void Unitype_free(Unitype u){
|
|||||||
void printuni(Unitype v){
|
void printuni(Unitype v){
|
||||||
switch (v.type) {
|
switch (v.type) {
|
||||||
case Null: printf("{Null}");break;
|
case Null: printf("{Null}");break;
|
||||||
case Double: printf("{%s : %lf}",typename(v.type),v.Double);break;
|
case Double: printf("{%s : %lf}",my_type_name(v.type),v.Double);break;
|
||||||
case Char: printf("{%s : '%c'}",typename(v.type),v.Char);break;
|
case Char: printf("{%s : '%c'}",my_type_name(v.type),v.Char);break;
|
||||||
case Bool:
|
case Bool:
|
||||||
case UInt64: printf("{%s : %lu}",typename(v.type),v.UInt64);break;
|
case UInt64: printf("{%s : %lu}",my_type_name(v.type),v.UInt64);break;
|
||||||
case Int64: printf("{%s : %ld}",typename(v.type),v.Int64);break;
|
case Int64: printf("{%s : %ld}",my_type_name(v.type),v.Int64);break;
|
||||||
case CharPtr: printf("{%s : \"%s\"}",typename(v.type),(char*)v.VoidPtr);break;
|
case CharPtr: printf("{%s : \"%s\"}",my_type_name(v.type),(char*)v.VoidPtr);break;
|
||||||
default: printf("{%s : %p}",typename(v.type),v.VoidPtr);break;
|
default: printf("{%s : %p}",my_type_name(v.type),v.VoidPtr);break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
base/types.h
19
base/types.h
@ -1,5 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "std.h"
|
#include "std.h"
|
||||||
|
|
||||||
typedef int8_t int8;
|
typedef int8_t int8;
|
||||||
@ -10,7 +14,7 @@ typedef int32_t int32;
|
|||||||
typedef uint32_t uint32;
|
typedef uint32_t uint32;
|
||||||
typedef int64_t int64;
|
typedef int64_t int64;
|
||||||
typedef uint64_t uint64;
|
typedef uint64_t uint64;
|
||||||
typedef enum my_type{
|
typedef enum __attribute__((__packed__)) my_type {
|
||||||
Null, Float, Double, Char, Bool,
|
Null, Float, Double, Char, Bool,
|
||||||
UInt8, Int8, UInt16, Int16, UInt32, Int32, UInt64, Int64,
|
UInt8, Int8, UInt16, Int16, UInt32, Int32, UInt64, Int64,
|
||||||
UInt8Ptr, Int8Ptr, UInt16Ptr, Int16Ptr, UInt32Ptr, Int32Ptr, UInt64Ptr, Int64Ptr,
|
UInt8Ptr, Int8Ptr, UInt16Ptr, Int16Ptr, UInt32Ptr, Int32Ptr, UInt64Ptr, Int64Ptr,
|
||||||
@ -19,15 +23,10 @@ typedef enum my_type{
|
|||||||
AutoarrInt8Ptr, AutoarrUInt8Ptr, AutoarrInt16Ptr, AutoarrUInt16Ptr,
|
AutoarrInt8Ptr, AutoarrUInt8Ptr, AutoarrInt16Ptr, AutoarrUInt16Ptr,
|
||||||
AutoarrInt32Ptr, AutoarrUInt32Ptr, AutoarrInt64Ptr, AutoarrUInt64Ptr,
|
AutoarrInt32Ptr, AutoarrUInt32Ptr, AutoarrInt64Ptr, AutoarrUInt64Ptr,
|
||||||
AutoarrUnitypePtr, AutoarrKVPairPtr
|
AutoarrUnitypePtr, AutoarrKVPairPtr
|
||||||
} __attribute__ ((__packed__)) my_type;
|
} my_type;
|
||||||
|
|
||||||
//returns type name
|
const char* my_type_name(my_type t);
|
||||||
const char* typename(my_type t);
|
|
||||||
|
|
||||||
// returns size of type in bytes
|
|
||||||
int8 typesize(my_type type);
|
|
||||||
|
|
||||||
// can store any base type
|
|
||||||
typedef struct Unitype{
|
typedef struct Unitype{
|
||||||
union {
|
union {
|
||||||
int64 Int64;
|
int64 Int64;
|
||||||
@ -50,3 +49,7 @@ static const Unitype UniFalse={.Bool=false,.type=Bool};
|
|||||||
//frees VoidPtr value or does nothing if type isn't pointer
|
//frees VoidPtr value or does nothing if type isn't pointer
|
||||||
void Unitype_free(Unitype u);
|
void Unitype_free(Unitype u);
|
||||||
void printuni(Unitype v);
|
void printuni(Unitype v);
|
||||||
|
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
31
kerep.sln
Normal file
31
kerep.sln
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.2.32317.152
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kerep", "kerep.vcxproj", "{52F0BD29-A3CB-47CE-B25D-CEAF5DFB2D73}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{52F0BD29-A3CB-47CE-B25D-CEAF5DFB2D73}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{52F0BD29-A3CB-47CE-B25D-CEAF5DFB2D73}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{52F0BD29-A3CB-47CE-B25D-CEAF5DFB2D73}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{52F0BD29-A3CB-47CE-B25D-CEAF5DFB2D73}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{52F0BD29-A3CB-47CE-B25D-CEAF5DFB2D73}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{52F0BD29-A3CB-47CE-B25D-CEAF5DFB2D73}.Release|x64.Build.0 = Release|x64
|
||||||
|
{52F0BD29-A3CB-47CE-B25D-CEAF5DFB2D73}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{52F0BD29-A3CB-47CE-B25D-CEAF5DFB2D73}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {22F8C351-9A96-4F37-94E6-37E6AB5BA058}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
246
kerep.vcxproj
Normal file
246
kerep.vcxproj
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{52f0bd29-a3cb-47ce-b25d-ceaf5dfb2d73}</ProjectGuid>
|
||||||
|
<RootNamespace>kerep</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>ClangCL</PlatformToolset>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<CLRSupport>false</CLRSupport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>ClangCL</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<CLRSupport>false</CLRSupport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>ClangCL</PlatformToolset>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<CLRSupport>false</CLRSupport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>ClangCL</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<CLRSupport>false</CLRSupport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OutDir>bin-$(Platform)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>obj-$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||||
|
<ManagedAssembly>false</ManagedAssembly>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>bin-$(Platform)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>obj-$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||||
|
<ManagedAssembly>false</ManagedAssembly>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||||
|
<OutDir>bin-$(Platform)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>obj-$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
<ManagedAssembly>false</ManagedAssembly>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||||
|
<OutDir>bin-$(Platform)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>obj-$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
<ManagedAssembly>false</ManagedAssembly>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;KEREP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>
|
||||||
|
</PrecompiledHeaderFile>
|
||||||
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
|
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||||
|
<PrecompiledHeaderOutputFile />
|
||||||
|
<AdditionalOptions>/Zc:twoPhase- /MP %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<CompileAs>Default</CompileAs>
|
||||||
|
<LanguageStandard>Default</LanguageStandard>
|
||||||
|
<DebugInformationFormat>None</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableUAC>false</EnableUAC>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;KEREP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>
|
||||||
|
</PrecompiledHeaderFile>
|
||||||
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
|
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||||
|
<PrecompiledHeaderOutputFile />
|
||||||
|
<AdditionalOptions>/Zc:twoPhase- /MP %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
|
<CompileAs>Default</CompileAs>
|
||||||
|
<LanguageStandard>Default</LanguageStandard>
|
||||||
|
<DebugInformationFormat>None</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableUAC>false</EnableUAC>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;KEREP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>
|
||||||
|
</PrecompiledHeaderFile>
|
||||||
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
|
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||||
|
<PrecompiledHeaderOutputFile />
|
||||||
|
<AdditionalOptions>/Zc:twoPhase- /MP %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<CompileAs>Default</CompileAs>
|
||||||
|
<LanguageStandard>Default</LanguageStandard>
|
||||||
|
<DebugInformationFormat>None</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableUAC>false</EnableUAC>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;KEREP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>
|
||||||
|
</PrecompiledHeaderFile>
|
||||||
|
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
||||||
|
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||||
|
<PrecompiledHeaderOutputFile />
|
||||||
|
<AdditionalOptions>/Zc:twoPhase- /MP %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
|
<CompileAs>Default</CompileAs>
|
||||||
|
<LanguageStandard>Default</LanguageStandard>
|
||||||
|
<DebugInformationFormat>None</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableUAC>false</EnableUAC>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Autoarr\Autoarr.h" />
|
||||||
|
<ClInclude Include="Autoarr\Autoarr_declare.h" />
|
||||||
|
<ClInclude Include="Autoarr\Autoarr_define.h" />
|
||||||
|
<ClInclude Include="Autoarr\StringBuilder.h" />
|
||||||
|
<ClInclude Include="base\base.h" />
|
||||||
|
<ClInclude Include="base\errors.h" />
|
||||||
|
<ClInclude Include="base\mystr.h" />
|
||||||
|
<ClInclude Include="base\std.h" />
|
||||||
|
<ClInclude Include="base\types.h" />
|
||||||
|
<ClInclude Include="DtsodParser\DtsodV24.h" />
|
||||||
|
<ClInclude Include="Hashtable\hash.h" />
|
||||||
|
<ClInclude Include="Hashtable\Hashtable.h" />
|
||||||
|
<ClInclude Include="Hashtable\KeyValuePair.h" />
|
||||||
|
<ClInclude Include="SearchTree\SearchTree.h" />
|
||||||
|
<ClInclude Include="tests\tests.h" />
|
||||||
|
<ClInclude Include="tests\test_marshalling.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Autoarr\Autoarr.c" />
|
||||||
|
<ClCompile Include="Autoarr\StringBuilder.c" />
|
||||||
|
<ClCompile Include="base\errors.c" />
|
||||||
|
<ClCompile Include="base\mystr.c" />
|
||||||
|
<ClCompile Include="base\types.c" />
|
||||||
|
<ClCompile Include="DtsodParser\DtsodV24.c" />
|
||||||
|
<ClCompile Include="DtsodParser\DtsodV24_deserialize.c" />
|
||||||
|
<ClCompile Include="DtsodParser\DtsodV24_exported.c" />
|
||||||
|
<ClCompile Include="DtsodParser\DtsodV24_serialize.c" />
|
||||||
|
<ClCompile Include="Hashtable\hash.c" />
|
||||||
|
<ClCompile Include="Hashtable\Hashtable.c" />
|
||||||
|
<ClCompile Include="Hashtable\KeyValuePair.c" />
|
||||||
|
<ClCompile Include="SearchTree\SearchTree.c" />
|
||||||
|
<ClCompile Include="tests\main.c" />
|
||||||
|
<ClCompile Include="tests\test_autoarr.c" />
|
||||||
|
<ClCompile Include="tests\test_dtsod.c" />
|
||||||
|
<ClCompile Include="tests\test_hashtable.c" />
|
||||||
|
<ClCompile Include="tests\test_marshalling.c" />
|
||||||
|
<ClCompile Include="tests\test_searchtree.c" />
|
||||||
|
<ClCompile Include="tests\test_string.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
129
kerep.vcxproj.filters
Normal file
129
kerep.vcxproj.filters
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Исходные файлы">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Файлы заголовков">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Файлы ресурсов">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Autoarr\Autoarr.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Autoarr\Autoarr_declare.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Autoarr\Autoarr_define.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Autoarr\StringBuilder.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="base\base.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="base\errors.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="base\mystr.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="base\std.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="base\types.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DtsodParser\DtsodV24.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Hashtable\hash.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Hashtable\Hashtable.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Hashtable\KeyValuePair.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="SearchTree\SearchTree.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="tests\test_marshalling.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="tests\tests.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Autoarr\Autoarr.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Autoarr\StringBuilder.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="base\errors.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="base\mystr.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="base\types.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DtsodParser\DtsodV24.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DtsodParser\DtsodV24_deserialize.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DtsodParser\DtsodV24_serialize.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Hashtable\hash.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Hashtable\Hashtable.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Hashtable\KeyValuePair.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="SearchTree\SearchTree.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\main.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\test_autoarr.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\test_dtsod.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\test_hashtable.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\test_searchtree.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\test_string.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\test_marshalling.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DtsodParser\DtsodV24_exported.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
10
tests/main.c
10
tests/main.c
@ -1,15 +1,5 @@
|
|||||||
#include "../base/base.h"
|
|
||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
|
|
||||||
#include "../Hashtable/KeyValuePair.h"
|
|
||||||
|
|
||||||
KeyValuePair test_marshalling(char* text){
|
|
||||||
//printf("<%s>\n", text);
|
|
||||||
Unitype u={.VoidPtr=text,.type=CharPtr};
|
|
||||||
KeyValuePair msg={"message",u};
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_all(){
|
void test_all(){
|
||||||
test_searchtree();
|
test_searchtree();
|
||||||
test_autoarr();
|
test_autoarr();
|
||||||
|
|||||||
@ -2,8 +2,9 @@
|
|||||||
#include "../Autoarr/Autoarr.h"
|
#include "../Autoarr/Autoarr.h"
|
||||||
|
|
||||||
static void printautoarr(Autoarr(uint16)* ar){
|
static void printautoarr(Autoarr(uint16)* ar){
|
||||||
printf("\e[94mAutoarr(uint16): %lu\n"
|
printf("\e[94mAutoarr(uint16): "
|
||||||
" max_blocks_count: %u\n"
|
IFWIN("%llu", "%lu")
|
||||||
|
"\n max_blocks_count: %u\n"
|
||||||
" blocks_count: %u\n"
|
" blocks_count: %u\n"
|
||||||
" max_block_length: %u\n"
|
" max_block_length: %u\n"
|
||||||
" block_length: %u\n"
|
" block_length: %u\n"
|
||||||
|
|||||||
@ -2,8 +2,9 @@
|
|||||||
#include "../Hashtable/Hashtable.h"
|
#include "../Hashtable/Hashtable.h"
|
||||||
|
|
||||||
void print_hashtable(Hashtable* ht){
|
void print_hashtable(Hashtable* ht){
|
||||||
printf("\e[94mHashtable:%lu\n"
|
printf("\e[94mHashtable: "
|
||||||
" hein: %u\n"
|
IFWIN("%llu", "%lu")
|
||||||
|
"\n hein: %u\n"
|
||||||
" height: %u\n"
|
" height: %u\n"
|
||||||
" rows: %p\n",
|
" rows: %p\n",
|
||||||
sizeof(Hashtable),
|
sizeof(Hashtable),
|
||||||
|
|||||||
14
tests/test_marshalling.c
Normal file
14
tests/test_marshalling.c
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include "../Hashtable/KeyValuePair.h"
|
||||||
|
|
||||||
|
EXPORT void CALL test_marshalling(char* text, KeyValuePair** kptr){
|
||||||
|
KeyValuePair* k=malloc(sizeof(KeyValuePair));
|
||||||
|
k->key="message";
|
||||||
|
char* tc=cptr_copy(text);
|
||||||
|
Unitype u={.VoidPtr=tc, .type=CharPtr};
|
||||||
|
k->value=u;
|
||||||
|
*kptr=k;
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPORT void CALL pinvoke_print(char* msg) {
|
||||||
|
printf("printed from unmanaged code: %s\n", msg);
|
||||||
|
}
|
||||||
@ -1,13 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#if __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../Hashtable/KeyValuePair.h"
|
|
||||||
|
|
||||||
KeyValuePair test_marshalling(char* text);
|
|
||||||
|
|
||||||
#if __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@ -2,7 +2,9 @@
|
|||||||
#include "../SearchTree/SearchTree.h"
|
#include "../SearchTree/SearchTree.h"
|
||||||
|
|
||||||
void printstnode(STNode* node){
|
void printstnode(STNode* node){
|
||||||
printf("\e[94mSTNode: %lu\n address: %p\n value: ",sizeof(STNode),node);
|
printf("\e[94mSTNode: "
|
||||||
|
IFWIN("%llu", "%lu")
|
||||||
|
"\n address: %p\n value: ",sizeof(STNode),node);
|
||||||
printuni(node->value);
|
printuni(node->value);
|
||||||
// prints pointers to all existing branches
|
// prints pointers to all existing branches
|
||||||
printf("\n branches: %p\n", node->branches);
|
printf("\n branches: %p\n", node->branches);
|
||||||
|
|||||||
@ -8,8 +8,8 @@ void test_string(){
|
|||||||
string s=string_cpFromCharPtr(c);
|
string s=string_cpFromCharPtr(c);
|
||||||
printf("\e[92m\"%s\" -> string_cpFromCharPtr()\n",c);
|
printf("\e[92m\"%s\" -> string_cpFromCharPtr()\n",c);
|
||||||
if(s.length!=16) throw("string created with incorrect length");
|
if(s.length!=16) throw("string created with incorrect length");
|
||||||
char* p=string_cpToCharPtr(s);
|
char* p=string_cpToCptr(s);
|
||||||
printf("\e[92mstring_cpToCharPtr() -> \"%s\"\n",p);
|
printf("\e[92mstring_cpToCptr() -> \"%s\"\n",p);
|
||||||
free(p);
|
free(p);
|
||||||
free(s.ptr);
|
free(s.ptr);
|
||||||
}));
|
}));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user