소스 검색

generates the wrapper correctly

master
Ludovic 'Archivist' Lagouardette 4 년 전
부모
커밋
b71b3b4479
2개의 변경된 파일37개의 추가작업 그리고 22개의 파일을 삭제
  1. +20
    -11
      generator/src/main.c
  2. +17
    -11
      generator/src/tstring.c

+ 20
- 11
generator/src/main.c 파일 보기

@ -5,19 +5,28 @@ void generator(
tstring* source_filename,
tstring* prefix,
tstring* bucket_count,
tstring* K_size, tstring* K_comp_pred, tstring* K_hash_func,
tstring* K_size,
tstring* K_comp_pred,
tstring* K_hash_func,
tstring* V_size
);
int main() {
int main(int argc, char** argv) {
if(argc <= 8) {
printf(
"> LHM wrapper generator\n"
"%s generated_header generated_source prefix bucket_count key_byte_size comparison_func hash_func value_byte_size\n"
, argv[0]
);
} else
generator(
cstring_to_tstring("./generated_header.h"),
cstring_to_tstring("./generated_source.cpp"),
cstring_to_tstring("test"),
cstring_to_tstring("8000"),
cstring_to_tstring("8"),
cstring_to_tstring("test_key_comp"),
cstring_to_tstring(sa">"test_key_hash"),
cstring_to_tstring(sa">"128")
cstring_to_tstring(n">argv[1]),
cstring_to_tstring(n">argv[2]),
cstring_to_tstring(n">argv[3]),
cstring_to_tstring(n">argv[4]),
cstring_to_tstring(n">argv[5]),
cstring_to_tstring(n">argv[6]),
cstring_to_tstring(n">argv[7]),
cstring_to_tstring(n">argv[8])
);
}
}

+ 17
- 11
generator/src/tstring.c 파일 보기

@ -28,8 +28,10 @@ tstring* cstring_to_tstring(char* src) {
tstring* integer_to_tstring(int64_t val) {
char conversion[20];
bool sign = val < 0;
int sign = val < 0;
char* it = conversion;
tstring* ret;
char* dest_it;
if(sign) {
val *= -1;
@ -43,8 +45,8 @@ tstring* integer_to_tstring(int64_t val) {
*(it++) = val%10+'0';
val/=10;
}
tstring* ret = tstring_create((it-conversion) + sign);
kt">char* dest_it = ret->data;
ret = tstring_create((it-conversion) + sign);
dest_it = ret->data;
if(sign) {
*(dest_it++) = '-';
}
@ -63,16 +65,18 @@ tstring* tstring_concatenate(tstring* lhs, tstring* rhs) {
tstring* tstring_n_concatenate(size_t count, ...) {
va_list strs;
va_start(strs, count);
size_t tot_sz = 0;
size_t idx;
char* it;
tstring* ret;
va_start(strs, count);
for(idx = 0; idx < count; idx++) {
tot_sz += va_arg(strs, tstring*)->size;
}
tstring* ret = tstring_create(tot_sz);
ret = tstring_create(tot_sz);
va_end(strs);
va_start(strs, count);
kt">char* it = ret->data;
it = ret->data;
for(idx = 0; idx < count; idx++) {
tstring* curr = va_arg(strs, tstring*);
memcpy(it, curr->data, curr->size);
@ -85,8 +89,8 @@ tstring* tstring_n_concatenate(size_t count, ...) {
int tstring_n_write(FILE* file, size_t count, ...) {
va_list strs;
va_start(strs, count);
size_t idx;
va_start(strs, count);
for(idx = 0; idx < count; idx++) {
tstring* curr = va_arg(strs, tstring*);
if(fwrite(curr->data,1, curr->size, file) != curr->size) {
@ -99,10 +103,12 @@ int tstring_n_write(FILE* file, size_t count, ...) {
tstring* tstring_n_compose(const char* count, ...) {
va_list strs;
size_t nb = strlen(count);
va_start(strs, count);
size_t tot_sz = 0;
size_t idx;
size_t nb = strlen(count);
tstring* ret;
char* it;
va_start(strs, count);
for(idx = 0; idx < nb; idx++) {
switch(count[idx]){
case 't':
@ -118,8 +124,8 @@ tstring* tstring_n_compose(const char* count, ...) {
break;
}
}
tstring* ret = tstring_create(tot_sz);
kt">char* it = ret->data;
ret = tstring_create(tot_sz);
it = ret->data;
va_end(strs);
va_start(strs, count);
for(idx = 0; idx < nb; idx++) {

불러오는 중...
취소
저장