diff --git a/.gitignore b/.gitignore index 488a468..424302c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ a.out generated_header.h +generated_source.cpp diff --git a/generator/src/generator.c b/generator/src/generator.c index 57e4d2e..05fe213 100644 --- a/generator/src/generator.c +++ b/generator/src/generator.c @@ -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,