Browse Source

properly generates

master
Ludovic 'Archivist' Lagouardette 3 years ago
parent
commit
75bea52694
2 changed files with 7 additions and 6 deletions
  1. +1
    -0
      .gitignore
  2. +6
    -6
      generator/src/generator.c

+ 1
- 0
.gitignore View File

@ -1,2 +1,3 @@
a.out
generated_header.h
generated_source.cpp

+ 6
- 6
generator/src/generator.c View File

@ -38,8 +38,8 @@ void generator(
tstring* hash_decl = tstring_n_compose("ctctctctc",
"size_t ",K_hash_func,"(void*);\n"
"struct ",prefix,"_hashtype{\n"
"size_t operator()(",key_type," key) {\n"
"return ", K_hash_func, "(key);\n"
"size_t operator()(const ",key_type,"& key) {\n"
"return ", K_hash_func, "((void*)&key);\n"
"}\n"
"};\n"
);
@ -71,7 +71,7 @@ void generator(
tstring* hashmap_get_decl = tstring_n_compose("tctctctc",
accessor_type, " ", prefix, "_hm_get(",hashmap_ptr_type," ptr, ",key_type,"* k);\n"
);
tstring* hashmap_endget_decl = tstring_n_compose("ctctctc",
tstring* hashmap_endget_decl = tstring_n_compose("ctctc",
"void ", prefix, "_hm_endget(",accessor_type," acc);\n"
);
tstring* hashmap_remove_decl = tstring_n_compose("ctctctc",
@ -134,7 +134,7 @@ void generator(
accessor_type, " acc;\n"
" auto obtained = (",to_cpp_hashmap_cast,"ptr)->get(*k);\n"
" if(obtained) {\n"
" acc.value = (void*)new accessor<",value_type,">(obtained.value());\n"
" acc.value = (void*)new mct20::accessor<",value_type,">(obtained.value());\n"
" } else {\n"
" acc.value = nullptr;\n"
" }\n"
@ -142,7 +142,7 @@ void generator(
);
tstring* hashmap_endget_impl = tstring_n_compose("ctctctc",
"void ", prefix, "_hm_endget(",accessor_type," acc) {\n"
" delete (accessor<",value_type,">*)acc.value;\n"
" delete (mct20::accessor<",value_type,">*)acc.value;\n"
"}\n"
);
tstring* hashmap_remove_impl = tstring_n_compose("ctctctctc",
@ -195,7 +195,7 @@ void generator(
}
if(
tstring_n_write(
source,21,
source,22,
top_guard,
cpp_header_include,
extc_top_guard,

Loading…
Cancel
Save