From 7799fec761f19ead0aeea59e7db3f4a07eb96627 Mon Sep 17 00:00:00 2001 From: Gerd v. Egidy Date: Mon, 21 Jul 2008 10:12:46 +0000 Subject: [PATCH] libt2n: (gerd) really fix default arguments (#1427) --- codegen/codegen-stubhead.hxx | 2 ++ codegen/main.cpp | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/codegen/codegen-stubhead.hxx b/codegen/codegen-stubhead.hxx index 64d3d5b..9ab41c0 100644 --- a/codegen/codegen-stubhead.hxx +++ b/codegen/codegen-stubhead.hxx @@ -13,8 +13,10 @@ #ifdef __GCCXML__ #define LIBT2N_EXPORT __attribute((gccxml("libt2n-default"))) +#define LIBT2N_DEFAULT_ARG(_type,_value) __attribute((gccxml("libt2n-default-arg",#_value))) _type = _value #else #define LIBT2N_EXPORT +#define LIBT2N_DEFAULT_ARG(_type,_value) _type = _value #endif #endif diff --git a/codegen/main.cpp b/codegen/main.cpp index ca91221..7df215a 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()) -- 1.7.1