From ed1a3c091b7f1e2d85a72fed5f1cca5deaf88cb8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ludwig=20J=C3=A4ck?= Date: Fri, 31 May 2024 11:57:46 +0200 Subject: [PATCH] Update xml parser to accept castxml output Update the function and argument annotations from gccxml to castxml style since castxml does not support 'gccxml' attributes and only supports user defined string attributes through using the 'annotation' attribute. Update nested namespace parsing since castxml does not provide the 'demangle' attribute which provides the entire expanded declaration of a type. The solution is concatenating the namespaces recursively. --- codegen/main.cpp | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-) diff --git a/codegen/main.cpp b/codegen/main.cpp index 7271b22..3060ee4 100644 --- a/codegen/main.cpp +++ b/codegen/main.cpp @@ -107,16 +107,16 @@ std::string get_namespace(const xmlpp::Element* root, const std::string &id) { std::string error; const xmlpp::Element* element(get_element_by_id(root, id)); - // [RP:20071024]: use "demangled" attribute instead of "name" to cover nested namespaces: - if ((!element)||(!element->get_attribute("demangled"))) return error; - return element->get_attribute("demangled")->get_value(); + // castxml does not support "demangled" attribute -> recursivly concat nested namespaces + if ((!element)||(element->get_attribute("name")->get_value() == "::")) return error; + else return get_namespace(root,element->get_attribute("context")->get_value() ) + element->get_attribute("name")->get_value() + "::"; } //! procedure marked for export? bool is_marked(const std::string &attrs) { // todo: improve this - std::string to_match("gccxml(libt2n-"); + std::string to_match("annotate(libt2n-"); std::string::size_type p(attrs.find(to_match)); return (p!=std::string::npos); } @@ -206,11 +206,6 @@ type_info get_type(const xmlpp::Element* root, const std::string &id) if (element->get_attribute("context")) { ret.name=get_namespace(root, element->get_attribute("context")->get_value()); - if (ret.name!="::") - ret.name+="::"; - else - // do not explicitely add :: - ret.name=""; } ret.name+=element->get_attribute("name")->get_value(); return ret; @@ -327,7 +322,6 @@ protected: f.ret_type=get_type(root, returns->get_value()); f.name=name->get_value(); f.mangled=mangled->get_value(); - xmlpp::Node::NodeList list = node->get_children("Argument"); for (xmlpp::Node::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter) { @@ -355,7 +349,7 @@ protected: if(arg->get_attribute("attributes")) { std::string attr=arg->get_attribute("attributes")->get_value(); - const std::string look_for = "gccxml(libt2n-default-arg,"; + const std::string look_for = "annotate(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); -- 1.7.1