X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=codegen%2Fmain.cpp;h=2e377ec52ad4f12aebc0a5d5dd1923dfafa0fa9a;hp=ca912219cb6b2c9d88c882798e378d9b4d176fde;hb=d55e0d0f9f17e1706e9751b7e920479f31370f51;hpb=73eb04f2271acbd992d395dd821aeadcb73896d8 diff --git a/codegen/main.cpp b/codegen/main.cpp index ca91221..2e377ec 100644 --- a/codegen/main.cpp +++ b/codegen/main.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #ifdef HAVE_CONFIG_H #include "config.h" @@ -323,8 +324,22 @@ protected: assert(arg->get_attribute("type")); a.type=get_type(root, arg->get_attribute("type")->get_value()); - if(arg->get_attribute("default")) - a.defaultArg=arg->get_attribute("default")->get_value(); + // this would be the nice way of solving the problem of default arguments + // but currently the output of gccxml is unreliable (e.g. namespace only + // sometimes available) + // if(arg->get_attribute("default")) + // a.defaultArg=arg->get_attribute("default")->get_value(); + + // so we need to get the def. arg. via attribute + // which is previously set by the macro LIBT2N_DEFAULT_ARG(type,value) + if(arg->get_attribute("attributes")) + { + std::string attr=arg->get_attribute("attributes")->get_value(); + const std::string look_for = "gccxml(libt2n-default-arg,"; + + if (attr.compare(0,look_for.size(),look_for) == 0) + a.defaultArg=attr.substr(look_for.size(),attr.size()-look_for.size()-1); + } // todo: ugly - could be any other error if (a.type.name.empty()) @@ -477,7 +492,7 @@ void output_client_hpp(std::ostream &o, const std::string &group, const std::lis o << "class " << groupClass(group) << "_client : public libt2n::command_client\n" << "{\n" << "public:\n" - << groupClass(group) << "_client(libt2n::client_connection &_c,\n" + << groupClass(group) << "_client(libt2n::client_connection *_c,\n" << " long long _command_timeout_usec=command_timeout_usec_default,\n" << " long long _hello_timeout_usec=hello_timeout_usec_default)\n" << " : libt2n::command_client(_c,_command_timeout_usec,_hello_timeout_usec)\n"