summaryrefslogtreecommitdiff
path: root/modules/tools/c_gen_iface.hpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2024-01-16 12:59:10 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2024-01-16 12:59:22 +0100
commite4ea59e05e6ca870a05f731d42efdcdc3f595055 (patch)
tree78c4fe090c29fa164bb58d85ad3656439f163acc /modules/tools/c_gen_iface.hpp
parentd94c31fee53c3c7df981cf44a54dd722d7fc122c (diff)
tools: Dangling changes
Diffstat (limited to 'modules/tools/c_gen_iface.hpp')
-rw-r--r--modules/tools/c_gen_iface.hpp61
1 files changed, 11 insertions, 50 deletions
diff --git a/modules/tools/c_gen_iface.hpp b/modules/tools/c_gen_iface.hpp
index 4fa6ca7..1416062 100644
--- a/modules/tools/c_gen_iface.hpp
+++ b/modules/tools/c_gen_iface.hpp
@@ -250,22 +250,21 @@ struct c_data_translater<schema::Array<T,Dim>> {
}
{
c_types::c_member memb;
- memb.key
}
- str.def = "struct ";
- str.def += type_str;
+ str.type = "struct ";
+ str.type += type_str;
- str.def += " {\n";
+ str.type += " {\n";
- str.def += "\t" + inner_type_str + "* data;\n";
- str.def += "\tsize_t size;\n";
+ str.type += "\t" + inner_type_str + "* data;\n";
+ str.type += "\tsize_t size;\n";
if( Dim > 1 ){
- str.def += "\tsize_t dims["+std::to_string(Dim)+"];\n";
+ str.type += "\tsize_t dims["+std::to_string(Dim)+"];\n";
}
- str.def += "};\n";
+ str.type += "};\n";
c_state.struct_map.emplace(std::make_pair(type_str, std::move(str)));
return void_t{};
@@ -337,48 +336,12 @@ struct c_iface_translater<schema::Function<schema::Struct<schema::Member<Request
return eov;
}
}
- std::string c_func_name = c_state.prefix + "_" + func_name;
c_types::c_func fn;
fn.cpp_name = func_name;
- fn.def = "int";
- std::string iface_ctx = c_state.prefix + "_iface_context* ctx";
- fn.def += " " + c_func_name + "(" + iface_ctx;
- fn.def += ", " + response_type_str + "* out";
- if constexpr ( sizeof...(Request) > 0 ){
- fn.def += ", ";
- auto eov = generate_parameter<0>(fn.def, request_type_arr);
- if(eov.is_error()){
- return eov;
- }
- }
- fn.def += ")";
-
- fn.source = "{\n";
- // Check necessary pointers
- fn.source += "\tassert(ctx);\n";
- fn.source += "\tif(!ctx){return -1;}\n\n";
- fn.source += "\tauto rmt = reinterpret_cast<interface<IfaceSchema, ";
- fn.source += c_state.encoding;
- fn.source += ">*>(ctx);\n";
-
- // translate the input data
- if constexpr (sizeof...(Request) > 0){
- // I need a recursive search for the types
- }
-
- // Call the remote interface
- fn.source += "\tauto eov = rmt->template call<\"" + fn.cpp_name + "\">(std::move(input));";
- fn.source += ");\n";
- // translate the output data
- fn.source += "";
-
- // Close the brace
-
- fn.source += "}\n";
- c_state.func_map.emplace(std::make_pair(c_func_name, std::move(fn)));
+ c_state.func_map.emplace(std::make_pair(fn.cpp_name, std::move(fn)));
return void_t{};
}
@@ -469,7 +432,7 @@ error_or<void> generate_iface_example(){
for(auto& iter : type_map){
std::cout<<"\nType: \""<<iter.first<<"\""<<std::endl;
std::cout<<"Definition:\n\"\"\"\n";
- std::cout<<iter.second.def;
+ std::cout<<iter.second.type;
std::cout<<"\"\"\""<<std::endl;
std::cout<<"Schema: "<<iter.second.cpp_schema<<std::endl;
}
@@ -478,9 +441,7 @@ error_or<void> generate_iface_example(){
for(auto& iter : func_map){
std::cout<<"\nSymbol: \""<<iter.first<<"\""<<std::endl;
std::cout<<"Definition:\n\"\"\"\n";
- std::cout<<iter.second.def<<";\n";
- std::cout<<"\"\"\""<<std::endl;
- std::cout<<"\nSource:\n"<<iter.second.source<<std::endl;
+ std::cout<<iter.second.cpp_name<<";\n";
}
return eov;
@@ -523,7 +484,7 @@ error_or<void> generate_array_example(){
for(auto& iter : c_state.struct_map){
std::cout<<"\nType: \""<<iter.first<<"\""<<std::endl;
std::cout<<"Definition:\n\"\"\"\n";
- std::cout<<iter.second.def;
+ std::cout<<iter.second.type;
std::cout<<"\"\"\""<<std::endl;
}