[xsde-users] using same TypeNames in different NameSpaces in inheritance chain

Песоцкий Максим aazmp at yandex.ru
Mon Dec 24 06:47:05 EST 2018


this is what seems to work for me 
cxx/serializer/serializer-source.cxx

to acquire c++ namespace of element 

+static SemanticGraph::Namespace* getNameSpace(SemanticGraph::Nameable& n)
+{
+  SemanticGraph::Namespace* ns = 0;
+  SemanticGraph::Nameable* n_ = &n.scope();
+  while (!ns)
+  {
+    if (!n_->named_p())
+      break;
+    ns = dynamic_cast<SemanticGraph::Namespace*>(n_);
+    if (ns)
+      break;
+    n_ = &n_->scope();
+  }
+  return ns;
+}
+

using e.namespace_() didn't work (do not know if it should), sometimes it returned namespace of base type instead of actual

then two parts of complete scope <scopeNamespace>::<scopeTypeSskelName> for each element/attribute/choice etc like this

+              String scopeTypeSskelName;
+              String scopeNamespace;
+              {
+                SemanticGraph::Scope& sc = scope (c);
+                const SemanticGraph::Type* scopeType = dynamic_cast<const SemanticGraph::Type*>(&sc);
+                scopeTypeSskelName = scopeType ? this->ename(*scopeType) + L"::" : L"E_R_R_O_R  ";
+                SemanticGraph::Namespace* ns = getNameSpace(sc); // this is call to function above
+                if (ns)
+                  scopeNamespace = this->ns_name(*ns) + L"::";
+              }
+

and instead of construction like this
-                   << "assert (this->" << impl << ");"
-                   << "return this->" << impl << "->" << next << " ();"
using 
+                   << "assert (" << scopeNamespace << scopeTypeSskelName << impl << ");"
+                   << "return " << scopeNamespace << scopeTypeSskelName << impl << "->" << next << " ();"

tried for 
SemanticGraph::Element SemanticGraph::Choice SemanticGraph::Attribute
seems to be working










More information about the xsde-users mailing list