From 018e1ba581ec6f01f069a45ec4cf89f152b44d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 19 Mar 2025 15:41:36 +0100 Subject: remerge --- .../xsd-frontend/semantic-graph/any-attribute.cxx | 111 +++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/any-attribute.cxx (limited to 'libxsd-frontend/xsd-frontend/semantic-graph/any-attribute.cxx') diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/any-attribute.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/any-attribute.cxx new file mode 100644 index 0000000..19b9df2 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/any-attribute.cxx @@ -0,0 +1,111 @@ +// file : xsd-frontend/semantic-graph/any-attribute.cxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + AnyAttribute:: + AnyAttribute (Path const& file, + unsigned long line, + unsigned long column, + String const& namespaces) + : Node (file, line, column), + prototype_ (0) + { + // Not sure if the separator is just space or any white-space + // chararcter. + // + + for (size_t i (0), j (namespaces.find (L' '));;) + { + if (j != String::npos) + { + namespaces_.push_back (String (namespaces, i, j - i)); + + i = j + 1; + j = namespaces.find (L' ', i); + } + else + { + // Last element. + // + namespaces_.push_back (String (namespaces, i)); + break; + } + } + } + + AnyAttribute:: + AnyAttribute (Path const& file, + unsigned long line, + unsigned long column, + NamespaceIterator begin, + NamespaceIterator end) + : Node (file, line, column), + prototype_ (0) + { + for (; begin != end; ++begin) + namespaces_.push_back (*begin); + } + + namespace + { + Namespace& + namespace_ (Nameable& n) + { + // The basic idea goes like this: go up Names edges until you + // reach Namespace. There are, however, anonymous types which + // need special handling. In the case of an anonymous type we + // will go up the first Belongs edge (because the first edge + // is where the type was defined. + // + + if (n.named_p ()) + { + Scope& s (n.scope ()); + Namespace* ns (dynamic_cast (&n)); + + return ns ? *ns : namespace_ (s); + } + else + { + Type& t (dynamic_cast (n)); + Belongs& b (*t.classifies_begin ()); + + return namespace_ (b.instance ()); + } + } + } + + Namespace& AnyAttribute:: + definition_namespace () + { + if (prototype_p ()) + return prototype ().definition_namespace (); + + return namespace_ (scope ()); + } + + namespace + { + using compiler::type_info; + + struct AnyAttributeInit + { + AnyAttributeInit () + { + type_info ti (typeid (AnyAttribute)); + ti.add_base (typeid (Nameable)); + insert (ti); + } + } any_attribute_init_; + } + } +} -- cgit v1.2.3