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/annotation.cxx | 45 + .../xsd-frontend/semantic-graph/annotation.hxx | 75 ++ .../xsd-frontend/semantic-graph/any-attribute.cxx | 111 ++ .../xsd-frontend/semantic-graph/any-attribute.hxx | 80 ++ .../xsd-frontend/semantic-graph/any.cxx | 122 +++ .../xsd-frontend/semantic-graph/any.hxx | 85 ++ .../semantic-graph/attribute-group.cxx | 34 + .../semantic-graph/attribute-group.hxx | 24 + .../xsd-frontend/semantic-graph/attribute.cxx | 41 + .../xsd-frontend/semantic-graph/attribute.hxx | 36 + .../xsd-frontend/semantic-graph/complex.cxx | 42 + .../xsd-frontend/semantic-graph/complex.hxx | 87 ++ .../xsd-frontend/semantic-graph/compositors.cxx | 100 ++ .../xsd-frontend/semantic-graph/compositors.hxx | 234 ++++ .../xsd-frontend/semantic-graph/element-group.cxx | 34 + .../xsd-frontend/semantic-graph/element-group.hxx | 42 + .../xsd-frontend/semantic-graph/element.cxx | 53 + .../xsd-frontend/semantic-graph/element.hxx | 94 ++ .../xsd-frontend/semantic-graph/elements.cxx | 299 +++++ .../xsd-frontend/semantic-graph/elements.hxx | 997 +++++++++++++++++ .../xsd-frontend/semantic-graph/enumeration.cxx | 59 + .../xsd-frontend/semantic-graph/enumeration.hxx | 30 + .../xsd-frontend/semantic-graph/fundamental.cxx | 1143 ++++++++++++++++++++ .../xsd-frontend/semantic-graph/fundamental.cxx.m4 | 211 ++++ .../xsd-frontend/semantic-graph/fundamental.hxx | 516 +++++++++ .../xsd-frontend/semantic-graph/fundamental.hxx.m4 | 155 +++ .../xsd-frontend/semantic-graph/fundamental.m4 | 17 + .../xsd-frontend/semantic-graph/list.cxx | 34 + .../xsd-frontend/semantic-graph/list.hxx | 22 + .../xsd-frontend/semantic-graph/namespace.cxx | 34 + .../xsd-frontend/semantic-graph/namespace.hxx | 27 + .../xsd-frontend/semantic-graph/particle.cxx | 54 + .../xsd-frontend/semantic-graph/particle.hxx | 140 +++ .../xsd-frontend/semantic-graph/schema.cxx | 130 +++ .../xsd-frontend/semantic-graph/schema.hxx | 237 ++++ .../xsd-frontend/semantic-graph/union.cxx | 34 + .../xsd-frontend/semantic-graph/union.hxx | 22 + 37 files changed, 5500 insertions(+) create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/annotation.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/annotation.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/any-attribute.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/any-attribute.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/any.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/any.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/attribute-group.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/attribute-group.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/attribute.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/attribute.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/complex.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/complex.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/compositors.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/compositors.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/element-group.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/element-group.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/element.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/element.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/elements.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/elements.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/enumeration.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/enumeration.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/fundamental.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/fundamental.cxx.m4 create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/fundamental.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/fundamental.hxx.m4 create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/fundamental.m4 create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/list.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/list.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/namespace.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/namespace.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/particle.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/particle.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/schema.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/schema.hxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/union.cxx create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/union.hxx (limited to 'libxsd-frontend/xsd-frontend/semantic-graph') diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/annotation.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/annotation.cxx new file mode 100644 index 0000000..17a0f03 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/annotation.cxx @@ -0,0 +1,45 @@ +// file : xsd-frontend/semantic-graph/annotation.cxx +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + using compiler::type_info; + + // Annotates + // + namespace + { + struct AnnotatesInit + { + AnnotatesInit () + { + type_info ti (typeid (Annotates)); + ti.add_base (typeid (Edge)); + insert (ti); + } + } annotates_init_; + } + + // Annotation + // + namespace + { + struct AnnotationInit + { + AnnotationInit () + { + type_info ti (typeid (Annotation)); + ti.add_base (typeid (Node)); + insert (ti); + } + } annotation_init_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/annotation.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/annotation.hxx new file mode 100644 index 0000000..0464f4f --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/annotation.hxx @@ -0,0 +1,75 @@ +// file : xsd-frontend/semantic-graph/annotation.hxx +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_ANNOTATION_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_ANNOTATION_HXX + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + // + // + class Annotation; + + class Annotates: public virtual Edge + { + public: + Annotation& + annotation () + { + return *annotation_; + } + + public: + Annotates (): annotation_ (0) {} + + void + set_left_node (Annotation& a) + { + annotation_ = &a; + } + + void + set_right_node (Node&) {} + + void + set_right_node (Edge&) {} + + private: + Annotation* annotation_; + }; + + // + // + class Annotation: public virtual Node + { + public: + String const& + documentation () const + { + return documentation_; + } + + public: + Annotation (Path const& file, + unsigned long line, + unsigned long column, + String const& documentation) + : Node (file, line, column), documentation_ (documentation) + { + } + + void + add_edge_left (Annotates&) {} + + private: + String documentation_; + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_ANNOTATION_HXX 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_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/any-attribute.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/any-attribute.hxx new file mode 100644 index 0000000..bb3d761 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/any-attribute.hxx @@ -0,0 +1,80 @@ +// file : xsd-frontend/semantic-graph/any-attribute.hxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_ANY_ATTRIBUTE_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_ANY_ATTRIBUTE_HXX + +#include + +#include +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + class AnyAttribute: public virtual Nameable + { + typedef std::vector Namespaces; + + public: + typedef Namespaces::const_iterator NamespaceIterator; + + NamespaceIterator + namespace_begin () const + { + return namespaces_.begin (); + } + + NamespaceIterator + namespace_end () const + { + return namespaces_.end (); + } + + public: + bool + prototype_p () + { + return prototype_ != 0; + } + + AnyAttribute& + prototype () + { + assert (prototype_ != 0); + return *prototype_; + } + + void + prototype (AnyAttribute& a) + { + assert (prototype_ == 0); + prototype_ = &a; + } + + public: + Namespace& + definition_namespace (); + + public: + AnyAttribute (Path const& file, + unsigned long line, + unsigned long column, + String const& namespaces); + + AnyAttribute (Path const& file, + unsigned long line, + unsigned long column, + NamespaceIterator begin, + NamespaceIterator end); + + private: + AnyAttribute* prototype_; + Namespaces namespaces_; + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_ANY_ATTRIBUTE_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/any.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/any.cxx new file mode 100644 index 0000000..c8ebc93 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/any.cxx @@ -0,0 +1,122 @@ +// file : xsd-frontend/semantic-graph/any.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 + { + Any:: + Any (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; + } + } + } + + Any:: + Any (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& Any:: + definition_namespace () + { + if (prototype_p ()) + return prototype ().definition_namespace (); + + // Get to our scope. + // + Compositor* c (&contained_particle ().compositor ()); + + while(!c->contained_compositor_p ()) + c = &c->contained_particle ().compositor (); + + Scope& scope ( + dynamic_cast (c->contained_compositor ().container ())); + + return namespace_ (scope); + } + + namespace + { + using compiler::type_info; + + struct AnyInit + { + AnyInit () + { + type_info ti (typeid (Any)); + ti.add_base (typeid (Nameable)); + ti.add_base (typeid (Particle)); + insert (ti); + } + } any_init_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/any.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/any.hxx new file mode 100644 index 0000000..8e42762 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/any.hxx @@ -0,0 +1,85 @@ +// file : xsd-frontend/semantic-graph/any.hxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_ANY_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_ANY_HXX + +#include + +#include +#include +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + class Any: public virtual Nameable, + public virtual Particle + { + typedef std::vector Namespaces; + + public: + typedef Namespaces::const_iterator NamespaceIterator; + + NamespaceIterator + namespace_begin () const + { + return namespaces_.begin (); + } + + NamespaceIterator + namespace_end () const + { + return namespaces_.end (); + } + + public: + bool + prototype_p () + { + return prototype_ != 0; + } + + Any& + prototype () + { + assert (prototype_ != 0); + return *prototype_; + } + + void + prototype (Any& a) + { + assert (prototype_ == 0); + prototype_ = &a; + } + + public: + Namespace& + definition_namespace (); + + public: + Any (Path const& file, + unsigned long line, + unsigned long column, + String const& namespaces); + + Any (Path const& file, + unsigned long line, + unsigned long column, + NamespaceIterator begin, + NamespaceIterator end); + + using Nameable::add_edge_right; + using Particle::add_edge_right; + + private: + Any* prototype_; + Namespaces namespaces_; + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_ANY_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/attribute-group.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/attribute-group.cxx new file mode 100644 index 0000000..f61fa39 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/attribute-group.cxx @@ -0,0 +1,34 @@ +// file : xsd-frontend/semantic-graph/attribute-group.cxx +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + AttributeGroup:: + AttributeGroup (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column) + { + } + + namespace + { + using compiler::type_info; + + struct AttributeGroupInit + { + AttributeGroupInit () + { + type_info ti (typeid (AttributeGroup)); + ti.add_base (typeid (Scope)); + insert (ti); + } + } attribute_group_init_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/attribute-group.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/attribute-group.hxx new file mode 100644 index 0000000..62a1f81 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/attribute-group.hxx @@ -0,0 +1,24 @@ +// file : xsd-frontend/semantic-graph/attribute-group.hxx +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_ATTRIBUTE_GROUP_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_ATTRIBUTE_GROUP_HXX + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + class AttributeGroup: public virtual Scope + { + public: + AttributeGroup (Path const& file, + unsigned long line, + unsigned long column); + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_ATTRIBUTE_GROUP_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/attribute.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/attribute.cxx new file mode 100644 index 0000000..624b16a --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/attribute.cxx @@ -0,0 +1,41 @@ +// file : xsd-frontend/semantic-graph/attribute.cxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + Attribute:: + Attribute (Path const& file, + unsigned long line, + unsigned long column, + bool optional, + bool global, + bool qualified) + : Node (file, line, column), + Member (global, qualified), + optional_ (optional) + { + } + + namespace + { + using compiler::type_info; + + struct AttributeInit + { + AttributeInit () + { + type_info ti (typeid (Attribute)); + ti.add_base (typeid (Member)); + insert (ti); + } + } attribute_init_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/attribute.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/attribute.hxx new file mode 100644 index 0000000..9d9b0fb --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/attribute.hxx @@ -0,0 +1,36 @@ +// file : xsd-frontend/semantic-graph/attribute.hxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_ATTRIBUTE_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_ATTRIBUTE_HXX + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + class Attribute: public virtual Member + { + public: + bool + optional_p () const + { + return optional_; + } + + public: + Attribute (Path const& file, + unsigned long line, + unsigned long column, + bool optional, + bool global, + bool qualified); + private: + bool optional_; + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_ATTRIBUTE_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/complex.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/complex.cxx new file mode 100644 index 0000000..8433a0e --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/complex.cxx @@ -0,0 +1,42 @@ +// file : xsd-frontend/semantic-graph/complex.cxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + Complex:: + Complex () + : mixed_ (false), contains_compositor_ (0) + { + } + + Complex:: + Complex (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column), + mixed_ (false), contains_compositor_ (0) + { + } + + namespace + { + using compiler::type_info; + + struct ComplexInit + { + ComplexInit () + { + type_info ti (typeid (Complex)); + ti.add_base (typeid (Type)); + ti.add_base (typeid (Scope)); + insert (ti); + } + } complex_init_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/complex.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/complex.hxx new file mode 100644 index 0000000..ac47810 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/complex.hxx @@ -0,0 +1,87 @@ +// file : xsd-frontend/semantic-graph/complex.hxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_COMPLEX_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_COMPLEX_HXX + +#include +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + class Complex: public virtual Type, public virtual Scope + { + public: + bool + mixed_p () const + { + if (mixed_) + return true; + + // If we have empty content, then we have the same content + // type as our base. + // + if (!contains_compositor_p () && inherits_p ()) + { + if (Complex* b = dynamic_cast (&inherits ().base ())) + return b->mixed_p (); + } + + return false; + } + + public: + bool + contains_compositor_p () const + { + return contains_compositor_ != 0; + } + + ContainsCompositor& + contains_compositor () + { + assert (contains_compositor_ != 0); + return *contains_compositor_; + } + + public: + void + mixed_p (bool m) + { + mixed_ = m; + } + + public: + Complex (Path const& file, unsigned long line, unsigned long column); + + void + add_edge_left (ContainsCompositor& e) + { + contains_compositor_ = &e; + } + + void + remove_edge_left (ContainsCompositor& e) + { + assert (contains_compositor_ == &e); + contains_compositor_ = 0; + } + + using Type::add_edge_right; + using Type::add_edge_left; + using Scope::add_edge_left; + + protected: + Complex (); // For virtual inheritance (Enumeration). + + private: + bool mixed_; + ContainsCompositor* contains_compositor_; + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_COMPLEX_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/compositors.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/compositors.cxx new file mode 100644 index 0000000..dd65e56 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/compositors.cxx @@ -0,0 +1,100 @@ +// file : xsd-frontend/semantic-graph/compositor.cxx +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + // ContainsCompositor + // + ContainsCompositor:: + ContainsCompositor (unsigned long min, unsigned long max) + : compositor_ (0), container_ (0), min_ (min), max_ (max) + { + } + + // All + // + All:: + All (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column) + { + } + + // Choice + // + Choice:: + Choice (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column) + { + } + + // Sequence + // + Sequence:: + Sequence (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column) + { + } + + namespace + { + using compiler::type_info; + + struct ContainsCompositorInit + { + ContainsCompositorInit () + { + type_info ti (typeid (ContainsCompositor)); + ti.add_base (typeid (Edge)); + insert (ti); + } + } contains_compositor_init_; + + struct CompositorInit + { + CompositorInit () + { + type_info ti (typeid (Compositor)); + ti.add_base (typeid (Particle)); + insert (ti); + } + } compositor_init_; + + struct AllInit + { + AllInit () + { + type_info ti (typeid (All)); + ti.add_base (typeid (Compositor)); + insert (ti); + } + } all_init_; + + struct ChoiceInit + { + ChoiceInit () + { + type_info ti (typeid (Choice)); + ti.add_base (typeid (Compositor)); + insert (ti); + } + } choice_init_; + + struct SequenceInit + { + SequenceInit () + { + type_info ti (typeid (Sequence)); + ti.add_base (typeid (Compositor)); + insert (ti); + } + } sequence_init_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/compositors.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/compositors.hxx new file mode 100644 index 0000000..3573c24 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/compositors.hxx @@ -0,0 +1,234 @@ +// file : xsd-frontend/semantic-graph/compositors.hxx +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_COMPOSITORS_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_COMPOSITORS_HXX + +#include + +#include +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + // + // + class ContainsCompositor: public virtual Edge + { + public: + Compositor& + compositor () const + { + return *compositor_; + } + + Node& + container () const + { + return *container_; + } + + public: + unsigned long + min () const + { + return min_; + } + + unsigned long + max () const + { + return max_; + } + + public: + ContainsCompositor (unsigned long min, unsigned long max); + + void + set_left_node (Node& n) + { + container_ = &n; + } + + void + set_right_node (Compositor& n) + { + compositor_ = &n; + } + + void + clear_left_node (Node& n) + { + assert (container_ == &n); + container_ = 0; + } + + void + clear_right_node (Compositor& n) + { + assert (compositor_ == &n); + compositor_ = 0; + } + + private: + Compositor* compositor_; + Node* container_; + unsigned long min_, max_; + }; + + // + // + class Compositor: public virtual Particle + { + typedef std::list ContainsList; + + public: + typedef pointer_iterator ContainsIterator; + typedef + pointer_iterator + ContainsConstIterator; + + ContainsIterator + contains_begin () + { + return contains_.begin (); + } + + ContainsIterator + contains_end () + { + return contains_.end (); + } + + ContainsConstIterator + contains_begin () const + { + return contains_.begin (); + } + + ContainsConstIterator + contains_end () const + { + return contains_.end (); + } + + public: + bool + contained_compositor_p () + { + return contained_compositor_ != 0; + } + + ContainsCompositor& + contained_compositor () + { + assert (contained_compositor_ != 0); + return *contained_compositor_; + } + + public: + unsigned long + min () const + { + if (contained_compositor_ != 0) + return contained_compositor_->min (); + else + return Particle::min (); + } + + unsigned long + max () const + { + if (contained_compositor_ != 0) + return contained_compositor_->max (); + else + return Particle::max (); + } + + public: + Compositor (): contained_compositor_ (0) {} + + void + add_edge_left (ContainsParticle& e) + { + contains_.push_back (&e); + } + + void + add_edge_left (ContainsParticle& e, ContainsIterator const& after) + { + if (after.base () == contains_.end ()) + contains_.push_front (&e); + else + { + ContainsList::iterator i (after.base ()); + contains_.insert (++i, &e); + } + } + + void + remove_edge_left (ContainsParticle& e) + { + for (ContainsList::iterator i (contains_.begin ()); + i != contains_.end (); ++i) + { + if (*i == &e) + { + contains_.erase (i); + break; + } + } + } + + void + add_edge_right (ContainsCompositor& e) + { + contained_compositor_ = &e; + } + + void + remove_edge_right (ContainsCompositor& e) + { + assert (contained_compositor_ == &e); + contained_compositor_ = 0; + } + + using Node::add_edge_right; + using Particle::add_edge_right; + using Particle::remove_edge_right; + + private: + ContainsList contains_; + ContainsCompositor* contained_compositor_; + }; + + // + // + class All: public virtual Compositor + { + public: + All (Path const& file, unsigned long line, unsigned long column); + }; + + // + // + class Choice: public virtual Compositor + { + public: + Choice (Path const& file, unsigned long line, unsigned long column); + }; + + // + // + class Sequence: public virtual Compositor + { + public: + Sequence (Path const& file, unsigned long line, unsigned long column); + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_COMPOSITORS_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/element-group.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/element-group.cxx new file mode 100644 index 0000000..a02d751 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/element-group.cxx @@ -0,0 +1,34 @@ +// file : xsd-frontend/semantic-graph/element-group.cxx +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + ElementGroup:: + ElementGroup (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column), contains_compositor_ (0) + { + } + + namespace + { + using compiler::type_info; + + struct ElementGroupInit + { + ElementGroupInit () + { + type_info ti (typeid (ElementGroup)); + ti.add_base (typeid (Scope)); + insert (ti); + } + } element_group_init_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/element-group.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/element-group.hxx new file mode 100644 index 0000000..ee7772c --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/element-group.hxx @@ -0,0 +1,42 @@ +// file : xsd-frontend/semantic-graph/element-group.hxx +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_ELEMENT_GROUP_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_ELEMENT_GROUP_HXX + +#include +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + class ElementGroup: public virtual Scope + { + public: + ContainsCompositor& + contains_compositor () + { + assert (contains_compositor_ != 0); + return *contains_compositor_; + } + + public: + ElementGroup (Path const& file, unsigned long line, unsigned long column); + + void + add_edge_left (ContainsCompositor& e) + { + contains_compositor_ = &e; + } + + using Scope::add_edge_left; + + private: + ContainsCompositor* contains_compositor_; + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_ELEMENT_GROUP_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/element.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/element.cxx new file mode 100644 index 0000000..fb7d3a7 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/element.cxx @@ -0,0 +1,53 @@ +// file : xsd-frontend/semantic-graph/element.cxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + // Element + // + Element:: + Element (Path const& file, + unsigned long line, + unsigned long column, + bool global, + bool qualified) + : Node (file, line, column), + Member (global, qualified), + substitutes_ (0) + { + } + + namespace + { + using compiler::type_info; + + struct SubstitutesInit + { + SubstitutesInit () + { + type_info ti (typeid (Substitutes)); + ti.add_base (typeid (Edge)); + insert (ti); + } + } substitutes_init_; + + struct ElementInit + { + ElementInit () + { + type_info ti (typeid (Element)); + ti.add_base (typeid (Member)); + ti.add_base (typeid (Particle)); + insert (ti); + } + } element_init_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/element.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/element.hxx new file mode 100644 index 0000000..0af164e --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/element.hxx @@ -0,0 +1,94 @@ +// file : xsd-frontend/semantic-graph/element.hxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_ELEMENT_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_ELEMENT_HXX + +#include +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + class Element; + + class Substitutes: public virtual Edge + { + public: + Element& + substitution () const + { + return *substitution_; + } + + Element& + root () const + { + return *root_; + } + + public: + void + set_left_node (Element& n) + { + substitution_ = &n; + } + + void + set_right_node (Element& n) + { + root_ = &n; + } + + private: + Element* root_; + Element* substitution_; + }; + + + class Element: public virtual Member, + public virtual Particle + { + public: + bool + substitutes_p () const + { + return substitutes_ != 0; + } + + Substitutes& + substitutes () const + { + assert (substitutes_ != 0); + return *substitutes_; + } + + public: + Element (Path const& file, + unsigned long line, + unsigned long column, + bool global, + bool qualified); + + void + add_edge_left (Substitutes& e) + { + substitutes_ = &e; + } + + void + add_edge_right (Substitutes&) {} + + using Member::add_edge_left; + using Member::add_edge_right; + using Particle::add_edge_right; + + private: + Substitutes* substitutes_; + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_ELEMENT_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/elements.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/elements.cxx new file mode 100644 index 0000000..fa48a9a --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/elements.cxx @@ -0,0 +1,299 @@ +// file : xsd-frontend/semantic-graph/elements.cxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +#include +#include + +using namespace std; + +namespace XSDFrontend +{ + namespace SemanticGraph + { + // Node + // + Annotation& Node:: + annotation () + { + return annotates_->annotation (); + } + + // Type + // + void Type:: + remove_edge_left (Arguments& a) + { + ArgumentsSet::iterator i (arguments_.find (&a)); + assert (i != arguments_.end ()); + arguments_.erase (i); + } + + // Specialization + // + void Specialization:: + remove_edge_right (Arguments& a) + { + // The number of entries should be small so linear search will do. + // + Argumented::iterator i ( + std::find (argumented_.begin (), argumented_.end (), &a)); + + assert (i != argumented_.end ()); + argumented_.erase (i); + } + + using compiler::type_info; + + namespace + { + // Edge + // + struct EdgeInit + { + EdgeInit () + { + type_info ti (typeid (Edge)); + insert (ti); + } + } edge_init_; + + // Node + // + struct NodeInit + { + NodeInit () + { + type_info ti (typeid (Node)); + insert (ti); + } + } node_init_; + + // Names + // + struct NamesInit + { + NamesInit () + { + type_info ti (typeid (Names)); + ti.add_base (typeid (Edge)); + insert (ti); + } + } names_init_; + + // Nameable + // + struct NameableInit + { + NameableInit () + { + type_info ti (typeid (Nameable)); + ti.add_base (typeid (Node)); + insert (ti); + } + } nameable_init_; + + // Scope + // + struct ScopeInit + { + ScopeInit () + { + type_info ti (typeid (Scope)); + ti.add_base (typeid (Nameable)); + insert (ti); + } + } scope_init_; + + // Type + // + struct TypeInit + { + TypeInit () + { + type_info ti (typeid (Type)); + ti.add_base (typeid (Nameable)); + insert (ti); + } + } type_init_; + + // Instance + // + struct InstanceInit + { + InstanceInit () + { + type_info ti (typeid (Instance)); + ti.add_base (typeid (Nameable)); + insert (ti); + } + } instance_init_; + + // Belongs + // + struct BelongsInit + { + BelongsInit () + { + type_info ti (typeid (Belongs)); + ti.add_base (typeid (Edge)); + insert (ti); + } + } belongs_init_; + + // Inherits + // + struct InheritsInit + { + InheritsInit () + { + type_info ti (typeid (Inherits)); + ti.add_base (typeid (Edge)); + insert (ti); + } + } inherits_init_; + + // Extends + // + struct ExtendsInit + { + ExtendsInit () + { + type_info ti (typeid (Extends)); + ti.add_base (typeid (Inherits)); + insert (ti); + } + } extends_init_; + + // Restricts + // + struct RestrictsInit + { + RestrictsInit () + { + type_info ti (typeid (Restricts)); + ti.add_base (typeid (Inherits)); + insert (ti); + } + } restricts_init_; + + // BelongsToNamespace + // + struct BelongsToNamespaceInit + { + BelongsToNamespaceInit () + { + type_info ti (typeid (BelongsToNamespace)); + ti.add_base (typeid (Edge)); + insert (ti); + } + } belongs_to_namespace_init_; + + // Member + // + struct MemberInit + { + MemberInit () + { + type_info ti (typeid (Member)); + ti.add_base (typeid (Instance)); + insert (ti); + } + } member_init_; + + // Specialization + // + struct SpecializationInit + { + SpecializationInit () + { + type_info ti (typeid (Specialization)); + ti.add_base (typeid (Type)); + insert (ti); + } + } specialization_init_; + + // Arguments + // + struct ArgumentsInit + { + ArgumentsInit () + { + type_info ti (typeid (Arguments)); + ti.add_base (typeid (Edge)); + insert (ti); + } + } arguments_init_; + + /* + // Contains + // + struct ContainsInit + { + ContainsInit () + { + type_info ti (typeid (Contains)); + ti.add_base (typeid (Edge)); + insert (ti); + } + } contains_init_; + + // Container + // + struct ContainerInit + { + ContainerInit () + { + type_info ti (typeid (Container)); + ti.add_base (typeid (Node)); + insert (ti); + } + } container_init_; + */ + + // AnyType + // + struct AnyTypeInit + { + AnyTypeInit () + { + type_info ti (typeid (AnyType)); + ti.add_base (typeid (SemanticGraph::Type)); + insert (ti); + } + } any_type_init_; + + // AnySimpleType + // + struct AnySimpleTypeInit + { + AnySimpleTypeInit () + { + type_info ti (typeid (AnySimpleType)); + ti.add_base (typeid (Type)); + insert (ti); + } + } any_simple_type_init_; + } + + // Instance + // + Type& Instance:: + type () const + { + return belongs ().type (); + } + } +} + +// Path +// +std::wostream& +operator<< (std::wostream& os, XSDFrontend::SemanticGraph::Path const& path) +{ + return os << path.string ().c_str (); +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/elements.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/elements.hxx new file mode 100644 index 0000000..98fb180 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/elements.hxx @@ -0,0 +1,997 @@ +// file : xsd-frontend/semantic-graph/elements.hxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_ELEMENTS_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_ELEMENTS_HXX + +#include +#include +#include +#include +#include +#include // std::pair +#include // abort +#include + +#include +#include +#include +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + using namespace cutl; + + using container::pointer_iterator; + + // + // + typedef fs::path Path; + typedef fs::invalid_path InvalidPath; + typedef std::vector Paths; + + typedef compiler::context Context; + + // + // + class Node; + class Edge; + + // + // + class Annotates; + class Annotation; + + // + // + class Edge + { + public: + Context& + context () const + { + return context_; + } + + virtual + ~Edge () + { + } + + public: + template + bool + is_a () const + { + return dynamic_cast (this) != 0; + } + + private: + mutable Context context_; + }; + + inline bool + operator== (Edge const& x, Edge const& y) + { + return &x == &y; + } + + + // + // + class Node + { + public: + Context& + context () const + { + return context_; + } + + public: + Path const& + file () const + { + return file_; + } + + unsigned long + line () const + { + return line_; + } + + unsigned long + column () const + { + return column_; + } + + public: + bool + annotated_p () const + { + return annotates_ != 0; + } + + Annotates& + annotated () const + { + return *annotates_; + } + + Annotation& + annotation (); + + public: + template + bool + is_a () const + { + return dynamic_cast (this) != 0; + } + + public: + virtual + ~Node () {} + + Node (Path const& file, unsigned long line, unsigned long column) + : annotates_ (0), file_ (file), line_ (line), column_ (column) + { + } + + void + add_edge_right (Annotates& a) + { + annotates_ = &a; + } + + protected: + Node () // For virtual inheritance. + { + abort (); // Told you so! + } + + private: + mutable Context context_; + Annotates* annotates_; + Path file_; + unsigned long line_; + unsigned long column_; + }; + + inline bool + operator== (Node const& x, Node const& y) + { + return &x == &y; + } + + // + // + typedef container::graph graph; + + // + // + typedef String Name; + + + // + // + class Scope; + class Nameable; + + + // + // + class Names: public virtual Edge + { + public: + Name + name () const + { + return name_; + } + + Scope& + scope () const + { + return *scope_; + } + + Nameable& + named () const + { + return *named_; + } + + public: + Names (Name const& name): name_ (name) {} + + void + set_left_node (Scope& n) + { + scope_ = &n; + } + + void + set_right_node (Nameable& n) + { + named_ = &n; + } + + void + clear_left_node (Scope& n) + { + assert (scope_ == &n); + scope_ = 0; + } + + void + clear_right_node (Nameable& n) + { + assert (named_ == &n); + named_ = 0; + } + + private: + Scope* scope_; + Nameable* named_; + Name name_; + }; + + + class Nameable: public virtual Node + { + public: + bool + named_p () const + { + return named_ != 0; + } + + Name + name () const + { + assert (named_p ()); + return named_->name (); + } + + Scope& + scope () + { + assert (named_p ()); + return named_->scope (); + } + + Names& + named () + { + assert (named_p ()); + return *named_; + } + + public: + Nameable (): named_ (0) {} + + void + add_edge_right (Names& e) + { + named_ = &e; + } + + void + remove_edge_right (Names& e) + { + assert (named_ == &e); + named_ = 0; + } + + using Node::add_edge_right; + + private: + Names* named_; + }; + + // + // + typedef std::set Nameables; + + // + // + class Scope: public virtual Nameable + { + protected: + typedef std::list NamesList; + typedef std::map ListIteratorMap; + typedef std::map NamesMap; + + public: + typedef pointer_iterator NamesIterator; + typedef pointer_iterator NamesConstIterator; + + typedef + std::pair + NamesIteratorPair; + + NamesIterator + names_begin () + { + return names_.begin (); + } + + NamesIterator + names_end () + { + return names_.end (); + } + + NamesConstIterator + names_begin () const + { + return names_.begin (); + } + + NamesConstIterator + names_end () const + { + return names_.end (); + } + + virtual NamesIteratorPair + find (Name const& name) const + { + NamesMap::const_iterator i (names_map_.find (name)); + + if (i == names_map_.end ()) + return NamesIteratorPair (names_.end (), names_.end ()); + else + return NamesIteratorPair (i->second.begin (), i->second.end ()); + } + + NamesIterator + find (Names& e) + { + ListIteratorMap::iterator i (iterator_map_.find (&e)); + return i != iterator_map_.end () ? i->second : names_.end (); + } + + public: + Scope (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column) + { + } + + void + add_edge_left (Names& e) + { + NamesList::iterator i (names_.insert (names_.end (), &e)); + iterator_map_[&e] = i; + names_map_[e.name ()].push_back (&e); + } + + void + remove_edge_left (Names& e) + { + ListIteratorMap::iterator i (iterator_map_.find (&e)); + assert (i != iterator_map_.end ()); + + names_.erase (i->second); + iterator_map_.erase (i); + + NamesMap::iterator j (names_map_.find (e.name ())); + + for (NamesList::iterator i (j->second.begin ()); + i != j->second.end (); ++i) + { + if (*i == &e) + i = j->second.erase (i); + } + } + + void + add_edge_left (Names& e, NamesIterator const& after) + { + NamesList::iterator i; + + if (after.base () == names_.end ()) + i = names_.insert (names_.begin (), &e); + else + { + NamesList::iterator j (after.base ()); + i = names_.insert (++j, &e); + } + + iterator_map_[&e] = i; + names_map_[e.name ()].push_back (&e); + } + + using Nameable::add_edge_right; + + protected: + Scope () {} + + private: + NamesList names_; + ListIteratorMap iterator_map_; + NamesMap names_map_; + }; + + + // + // + class Belongs; + class Inherits; + class Arguments; + + class Type: public virtual Nameable + { + protected: + typedef std::vector Classifies; + typedef std::vector Begets; + typedef std::set ArgumentsSet; + + public: + typedef pointer_iterator ClassifiesIterator; + + ClassifiesIterator + classifies_begin () const + { + return classifies_.begin (); + } + + ClassifiesIterator + classifies_end () const + { + return classifies_.end (); + } + + // + // + bool + inherits_p () const + { + return inherits_ != 0; + } + + Inherits& + inherits () const + { + assert (inherits_ != 0); + return *inherits_; + } + + // + // + typedef pointer_iterator BegetsIterator; + + BegetsIterator + begets_begin () const + { + return begets_.begin (); + } + + BegetsIterator + begets_end () const + { + return begets_.end (); + } + + // + // + typedef pointer_iterator ArgumentsIterator; + + ArgumentsIterator + arguments_begin () const + { + return arguments_.begin (); + } + + ArgumentsIterator + arguments_end () const + { + return arguments_.end (); + } + + public: + Type (): inherits_ (0) {} + + void + add_edge_right (Belongs& e) + { + classifies_.push_back (&e); + } + + void + add_edge_right (Inherits& e) + { + begets_.push_back (&e); + } + + using Nameable::add_edge_right; + + void + add_edge_left (Arguments& a) + { + arguments_.insert (&a); + } + + void + remove_edge_left (Arguments&); + + void + add_edge_left (Inherits& e) + { + inherits_ = &e; + } + + private: + Inherits* inherits_; + Begets begets_; + Classifies classifies_; + ArgumentsSet arguments_; + }; + + class Instance: public virtual Nameable + { + public: + Belongs& + belongs () const + { + return *belongs_; + } + + Type& + type () const; + + bool + typed_p () const + { + return belongs_ != 0; + } + + public: + Instance (): belongs_ (0) {} + + void + add_edge_left (Belongs& e) + { + belongs_ = &e; + } + + private: + Belongs* belongs_; + }; + + + class Belongs: public virtual Edge + { + public: + Instance& + instance () const + { + return *instance_; + } + + Type& + type () const + { + return *type_; + } + + public: + void + set_left_node (Instance& n) + { + instance_ = &n; + } + + void + set_right_node (Type& n) + { + type_ = &n; + } + + private: + Instance* instance_; + Type* type_; + }; + + + // + // + class Inherits: public virtual Edge + { + public: + Type& + base () const + { + return *base_; + } + + Type& + derived () const + { + return *derived_; + } + + public: + void + set_left_node (Type& n) + { + derived_ = &n; + } + + void + set_right_node (Type& n) + { + base_ = &n; + } + + private: + Type* base_; + Type* derived_; + }; + + class Extends: public virtual Inherits + { + }; + + class Restricts: public virtual Inherits + { + public: + typedef std::map Facets; + typedef Facets::iterator FacetIterator; + + bool + facet_empty () + { + return facets_.empty (); + } + + FacetIterator + facet_begin () + { + return facets_.begin (); + } + + FacetIterator + facet_end () + { + return facets_.end (); + } + + FacetIterator + facet_find (String const& name) + { + return facets_.find (name); + } + + void + facet_insert (String const& name, String const& value) + { + facets_[name] = value; + } + + Facets const& + facets () const + { + return facets_; + } + + protected: + Facets facets_; + }; + + + // + // + class Member; + class Namespace; + + class BelongsToNamespace: public virtual Edge + { + public: + Member& + member () const + { + assert (member_ != 0); + return *member_; + } + + Namespace& + namespace_ () const + { + assert (namespace__ != 0); + return *namespace__; + } + + public: + BelongsToNamespace (): member_ (0), namespace__ (0) {} + + void + set_left_node (Member& n) + { + member_ = &n; + } + + void + set_right_node (Namespace& n) + { + namespace__ = &n; + } + + private: + Member* member_; + Namespace* namespace__; + }; + + // + // + class Member: public virtual Instance + { + public: + // Member is global either if it is defined outside any type + // or it is a ref="" of a global member. + // + bool + global_p () const + { + return global_; + } + + bool + qualified_p () const + { + return qualified_; + } + + // Note that only qualified members belong to a namespace. + // + Namespace& + namespace_ () const + { + assert (belongs_to_namespace_ != 0); + return belongs_to_namespace_->namespace_ (); + } + + + // Default and fixed value API. Note that the fixed value semantics + // is a superset of the default value semantics. As such setting the + // fixed value appears as if the default value was also set. + // + bool + default_p () const + { + return value_type_ != ValueType::none; + } + + bool + fixed_p () const + { + return value_type_ == ValueType::fixed; + } + + struct NoValue {}; + + String + value () const + { + if (value_type_ != ValueType::none) + return value_; + else + throw NoValue (); + } + + // + // + void + default_ (String const& v) + { + value_ = v; + value_type_ = ValueType::default_; + } + + void + fixed (String const& v) + { + value_ = v; + value_type_ = ValueType::fixed; + } + + public: + Member (bool global, bool qualified) + : global_ (global), + qualified_ (qualified), + belongs_to_namespace_ (0), + value_type_ (ValueType::none) + { + } + + void + add_edge_left (BelongsToNamespace& e) + { + // In the parser we sometimes re-add the same adge. + // + belongs_to_namespace_ = &e; + } + + using Instance::add_edge_left; + + private: + bool global_; + bool qualified_; + BelongsToNamespace* belongs_to_namespace_; + + struct ValueType + { + enum Value + { + none, + default_, + fixed + }; + }; + + String value_; + ValueType::Value value_type_; + }; + + + // Parametric types. + // + + class Specialization: public virtual Type + { + typedef std::vector Argumented; + + public: + typedef pointer_iterator ArgumentedIterator; + typedef + pointer_iterator + ArgumentedConstIterator; + + ArgumentedIterator + argumented_begin () + { + return argumented_.begin (); + } + + ArgumentedConstIterator + argumented_begin () const + { + return argumented_.begin (); + } + + ArgumentedIterator + argumented_end () + { + return argumented_.end (); + } + + ArgumentedConstIterator + argumented_end () const + { + return argumented_.end (); + } + + // Shortcut for one-argument specializations. + // + Arguments& + argumented () const + { + return *argumented_[0]; + } + + public: + using Type::add_edge_right; + + void + add_edge_right (Arguments& a) + { + argumented_.push_back (&a); + } + + void + add_edge_right (Arguments& a, ArgumentedIterator const& pos) + { + argumented_.insert (pos.base (), &a); + } + + void + remove_edge_right (Arguments&); + + private: + Argumented argumented_; + }; + + class Arguments: public virtual Edge + { + public: + Type& + type () const + { + return *type_; + } + + Specialization& + specialization () const + { + return *specialization_; + } + + public: + void + set_left_node (Type& n) + { + type_ = &n; + } + + void + clear_left_node (Type& n) + { + assert (type_ == &n); + type_ = 0; + } + + void + set_right_node (Specialization& s) + { + specialization_ = &s; + } + + void + clear_right_node (Specialization& s) + { + assert (specialization_ == &s); + specialization_ = 0; + } + + private: + Type* type_; + Specialization* specialization_; + }; + + + // + // + class AnyType: public virtual Type + { + public: + AnyType (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column) + { + } + + protected: + AnyType () {} // For virtual inheritance. + }; + + + // + // + class AnySimpleType: public virtual Type + { + public: + AnySimpleType (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column) + { + } + + protected: + AnySimpleType () {} // For virtual inheritance. + }; + } +} + +// ADL won't find it because Path is a typedef. Note that this +// function prints in native format. +// +std::wostream& +operator<< (std::wostream& os, XSDFrontend::SemanticGraph::Path const& path); + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_ELEMENTS_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/enumeration.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/enumeration.cxx new file mode 100644 index 0000000..93bcf79 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/enumeration.cxx @@ -0,0 +1,59 @@ +// file : xsd-frontend/semantic-graph/enumeration.cxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + // Enumeration + // + Enumeration:: + Enumeration (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column) + { + } + + // Enumerator + // + Enumerator:: + Enumerator (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column) + { + } + + namespace + { + using compiler::type_info; + + // Enumeration + // + struct EnumerationInit + { + EnumerationInit () + { + type_info ti (typeid (Enumeration)); + ti.add_base (typeid (Complex)); + insert (ti); + } + } enumeration_init_; + + + // Enumerator + // + struct EnumeratorInit + { + EnumeratorInit () + { + type_info ti (typeid (Enumerator)); + ti.add_base (typeid (Instance)); + insert (ti); + } + } enumerator_init_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/enumeration.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/enumeration.hxx new file mode 100644 index 0000000..90a33d1 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/enumeration.hxx @@ -0,0 +1,30 @@ +// file : xsd-frontend/semantic-graph/enumeration.hxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_ENUMERATION_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_ENUMERATION_HXX + +#include +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + class Enumeration: public virtual Complex + { + public: + Enumeration (Path const& file, unsigned long line, unsigned long column); + }; + + + class Enumerator: public virtual Instance + { + public: + Enumerator (Path const& file, unsigned long line, unsigned long column); + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_ENUMERATION_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.cxx new file mode 100644 index 0000000..cc98449 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.cxx @@ -0,0 +1,1143 @@ +// file : xsd-frontend/semantic-graph/fundamental.cxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Note, that this file is automatically generated! +// + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace Fundamental + { + using compiler::type_info; + + // Type + // + namespace + { + struct TypeInit + { + TypeInit () + { + type_info ti (typeid (Type)); + ti.add_base (typeid (SemanticGraph::Type)); + insert (ti); + } + } any_type_init_; + } + + Type:: + Type () + { + } + + + // Byte + // + namespace + { + struct ByteInit + { + ByteInit () + { + type_info ti (typeid (Byte)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } byte_init_; + } + + Byte:: + Byte (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // UnsignedByte + // + namespace + { + struct UnsignedByteInit + { + UnsignedByteInit () + { + type_info ti (typeid (UnsignedByte)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } unsigned_byte_init_; + } + + UnsignedByte:: + UnsignedByte (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Short + // + namespace + { + struct ShortInit + { + ShortInit () + { + type_info ti (typeid (Short)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } short_init_; + } + + Short:: + Short (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // UnsignedShort + // + namespace + { + struct UnsignedShortInit + { + UnsignedShortInit () + { + type_info ti (typeid (UnsignedShort)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } unsigned_short_init_; + } + + UnsignedShort:: + UnsignedShort (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Int + // + namespace + { + struct IntInit + { + IntInit () + { + type_info ti (typeid (Int)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } int_init_; + } + + Int:: + Int (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // UnsignedInt + // + namespace + { + struct UnsignedIntInit + { + UnsignedIntInit () + { + type_info ti (typeid (UnsignedInt)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } unsigned_int_init_; + } + + UnsignedInt:: + UnsignedInt (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Long + // + namespace + { + struct LongInit + { + LongInit () + { + type_info ti (typeid (Long)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } long_init_; + } + + Long:: + Long (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // UnsignedLong + // + namespace + { + struct UnsignedLongInit + { + UnsignedLongInit () + { + type_info ti (typeid (UnsignedLong)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } unsigned_long_init_; + } + + UnsignedLong:: + UnsignedLong (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Integer + // + namespace + { + struct IntegerInit + { + IntegerInit () + { + type_info ti (typeid (Integer)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } integer_init_; + } + + Integer:: + Integer (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // NonPositiveInteger + // + namespace + { + struct NonPositiveIntegerInit + { + NonPositiveIntegerInit () + { + type_info ti (typeid (NonPositiveInteger)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } non_positive_integer_init_; + } + + NonPositiveInteger:: + NonPositiveInteger (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // NonNegativeInteger + // + namespace + { + struct NonNegativeIntegerInit + { + NonNegativeIntegerInit () + { + type_info ti (typeid (NonNegativeInteger)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } non_negative_integer_init_; + } + + NonNegativeInteger:: + NonNegativeInteger (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // PositiveInteger + // + namespace + { + struct PositiveIntegerInit + { + PositiveIntegerInit () + { + type_info ti (typeid (PositiveInteger)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } positive_integer_init_; + } + + PositiveInteger:: + PositiveInteger (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // NegativeInteger + // + namespace + { + struct NegativeIntegerInit + { + NegativeIntegerInit () + { + type_info ti (typeid (NegativeInteger)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } negative_integer_init_; + } + + NegativeInteger:: + NegativeInteger (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Boolean + // + namespace + { + struct BooleanInit + { + BooleanInit () + { + type_info ti (typeid (Boolean)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } boolean_init_; + } + + Boolean:: + Boolean (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Float + // + namespace + { + struct FloatInit + { + FloatInit () + { + type_info ti (typeid (Float)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } float_init_; + } + + Float:: + Float (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Double + // + namespace + { + struct DoubleInit + { + DoubleInit () + { + type_info ti (typeid (Double)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } double_init_; + } + + Double:: + Double (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Decimal + // + namespace + { + struct DecimalInit + { + DecimalInit () + { + type_info ti (typeid (Decimal)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } decimal_init_; + } + + Decimal:: + Decimal (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // String + // + namespace + { + struct StringInit + { + StringInit () + { + type_info ti (typeid (String)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } string_init_; + } + + String:: + String (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // NormalizedString + // + namespace + { + struct NormalizedStringInit + { + NormalizedStringInit () + { + type_info ti (typeid (NormalizedString)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } normalized_string_init_; + } + + NormalizedString:: + NormalizedString (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Token + // + namespace + { + struct TokenInit + { + TokenInit () + { + type_info ti (typeid (Token)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } token_init_; + } + + Token:: + Token (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Name + // + namespace + { + struct NameInit + { + NameInit () + { + type_info ti (typeid (Name)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } name_init_; + } + + Name:: + Name (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // NameToken + // + namespace + { + struct NameTokenInit + { + NameTokenInit () + { + type_info ti (typeid (NameToken)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } name_token_init_; + } + + NameToken:: + NameToken (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // NameTokens + // + namespace + { + struct NameTokensInit + { + NameTokensInit () + { + type_info ti (typeid (NameTokens)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } name_tokens_init_; + } + + NameTokens:: + NameTokens (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // NCName + // + namespace + { + struct NCNameInit + { + NCNameInit () + { + type_info ti (typeid (NCName)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } NC_name_init_; + } + + NCName:: + NCName (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Language + // + namespace + { + struct LanguageInit + { + LanguageInit () + { + type_info ti (typeid (Language)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } language_init_; + } + + Language:: + Language (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // QName + // + namespace + { + struct QNameInit + { + QNameInit () + { + type_info ti (typeid (QName)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } q_name_init_; + } + + QName:: + QName (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Id + // + namespace + { + struct IdInit + { + IdInit () + { + type_info ti (typeid (Id)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } id_init_; + } + + Id:: + Id (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // IdRef + // + namespace + { + struct IdRefInit + { + IdRefInit () + { + type_info ti (typeid (IdRef)); + ti.add_base (typeid (Type)); + ti.add_base (typeid (Specialization)); + insert (ti); + } + + } id_ref_init_; + } + + IdRef:: + IdRef (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // IdRefs + // + namespace + { + struct IdRefsInit + { + IdRefsInit () + { + type_info ti (typeid (IdRefs)); + ti.add_base (typeid (Type)); + ti.add_base (typeid (Specialization)); + insert (ti); + } + + } id_refs_init_; + } + + IdRefs:: + IdRefs (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // AnyURI + // + namespace + { + struct AnyURIInit + { + AnyURIInit () + { + type_info ti (typeid (AnyURI)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } any_URI_init_; + } + + AnyURI:: + AnyURI (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Base64Binary + // + namespace + { + struct Base64BinaryInit + { + Base64BinaryInit () + { + type_info ti (typeid (Base64Binary)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } base_64_binary_init_; + } + + Base64Binary:: + Base64Binary (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // HexBinary + // + namespace + { + struct HexBinaryInit + { + HexBinaryInit () + { + type_info ti (typeid (HexBinary)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } hex_binary_init_; + } + + HexBinary:: + HexBinary (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Date + // + namespace + { + struct DateInit + { + DateInit () + { + type_info ti (typeid (Date)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } date_init_; + } + + Date:: + Date (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // DateTime + // + namespace + { + struct DateTimeInit + { + DateTimeInit () + { + type_info ti (typeid (DateTime)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } date_time_init_; + } + + DateTime:: + DateTime (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Duration + // + namespace + { + struct DurationInit + { + DurationInit () + { + type_info ti (typeid (Duration)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } duration_init_; + } + + Duration:: + Duration (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Day + // + namespace + { + struct DayInit + { + DayInit () + { + type_info ti (typeid (Day)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } day_init_; + } + + Day:: + Day (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Month + // + namespace + { + struct MonthInit + { + MonthInit () + { + type_info ti (typeid (Month)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } month_init_; + } + + Month:: + Month (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // MonthDay + // + namespace + { + struct MonthDayInit + { + MonthDayInit () + { + type_info ti (typeid (MonthDay)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } month_day_init_; + } + + MonthDay:: + MonthDay (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Year + // + namespace + { + struct YearInit + { + YearInit () + { + type_info ti (typeid (Year)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } year_init_; + } + + Year:: + Year (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // YearMonth + // + namespace + { + struct YearMonthInit + { + YearMonthInit () + { + type_info ti (typeid (YearMonth)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } year_month_init_; + } + + YearMonth:: + YearMonth (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Time + // + namespace + { + struct TimeInit + { + TimeInit () + { + type_info ti (typeid (Time)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } time_init_; + } + + Time:: + Time (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Entity + // + namespace + { + struct EntityInit + { + EntityInit () + { + type_info ti (typeid (Entity)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } entity_init_; + } + + Entity:: + Entity (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Entities + // + namespace + { + struct EntitiesInit + { + EntitiesInit () + { + type_info ti (typeid (Entities)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } entities_init_; + } + + Entities:: + Entities (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // Notation + // + namespace + { + struct NotationInit + { + NotationInit () + { + type_info ti (typeid (Notation)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } notation_init_; + } + + Notation:: + Notation (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.cxx.m4 b/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.cxx.m4 new file mode 100644 index 0000000..c336ab8 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.cxx.m4 @@ -0,0 +1,211 @@ +divert(-1) + +# file : xsd-frontend/semantic-graph/fundamental.cxx.m4 +# copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include(`fundamental.m4') + +define(`fundamental_type', + `fundamental_type_impl(`make_class_name(`$1')', `make_var_name(`$1')')') + + +define(`fundamental_type_impl', ` + + // $1 + // + namespace + { + struct $1Init + { + $1Init () + { + type_info ti (typeid ($1)); + ti.add_base (typeid (Type)); + insert (ti); + } + + } $2_init_; + } + + $1:: + $1 (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + }') + +divert(0)dnl +dnl +dnl +dnl +// file : xsd-frontend/semantic-graph/fundamental.cxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Note, that this file is automatically generated! +// + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace Fundamental + { + using compiler::type_info; + + // Type + // + namespace + { + struct TypeInit + { + TypeInit () + { + type_info ti (typeid (Type)); + ti.add_base (typeid (SemanticGraph::Type)); + insert (ti); + } + } any_type_init_; + } + + Type:: + Type () + { + } +dnl +dnl Integers. +dnl +fundamental_type(`byte') +fundamental_type(`unsigned byte') +fundamental_type(`short') +fundamental_type(`unsigned short') +fundamental_type(`int') +fundamental_type(`unsigned int') +fundamental_type(`long') +fundamental_type(`unsigned long') +fundamental_type(`integer') +fundamental_type(`non positive integer') +fundamental_type(`non negative integer') +fundamental_type(`positive integer') +fundamental_type(`negative integer') +dnl +dnl Boolean. +dnl +fundamental_type(`boolean') +dnl +dnl Floats. +dnl +fundamental_type(`float') +fundamental_type(`double') +fundamental_type(`decimal') +dnl +dnl Strings. +dnl +fundamental_type(`string') +fundamental_type(`normalized string') +fundamental_type(`token') +fundamental_type(`name') +fundamental_type(`name token') +fundamental_type(`name tokens') +fundamental_type(`NC name') +fundamental_type(`language') +dnl +dnl Qualified name. +dnl +fundamental_type(`q name') +dnl +dnl ID/IDREF. +dnl +fundamental_type(`id') + + + // IdRef + // + namespace + { + struct IdRefInit + { + IdRefInit () + { + type_info ti (typeid (IdRef)); + ti.add_base (typeid (Type)); + ti.add_base (typeid (Specialization)); + insert (ti); + } + + } id_ref_init_; + } + + IdRef:: + IdRef (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } + + + // IdRefs + // + namespace + { + struct IdRefsInit + { + IdRefsInit () + { + type_info ti (typeid (IdRefs)); + ti.add_base (typeid (Type)); + ti.add_base (typeid (Specialization)); + insert (ti); + } + + } id_refs_init_; + } + + IdRefs:: + IdRefs (Path const& file, + unsigned long line, + unsigned long column) + : Node (file, line, column) + { + } +dnl +dnl URI. +dnl +fundamental_type(`any URI') +dnl +dnl Binary. +dnl +fundamental_type(`base 64 binary') +fundamental_type(`hex binary') +dnl +dnl Date/time. +dnl +fundamental_type(`date') +fundamental_type(`date time') +fundamental_type(`duration') +fundamental_type(`day') +fundamental_type(`month') +fundamental_type(`month day') +fundamental_type(`year') +fundamental_type(`year month') +fundamental_type(`time') +dnl +dnl Entity. +dnl +fundamental_type(`entity') +fundamental_type(`entities') +dnl +dnl Notation. +dnl +fundamental_type(`notation') +dnl + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.hxx new file mode 100644 index 0000000..d810824 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.hxx @@ -0,0 +1,516 @@ +// file : xsd-frontend/semantic-graph/fundamental.hxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Note, that this file is automatically generated! +// + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_FUNDAMENTAL_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_FUNDAMENTAL_HXX + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace Fundamental + { + // + // + class Type: public virtual SemanticGraph::Type + { + protected: + Type (); + }; + + + // + // + class Byte: public virtual Type + { + public: + Byte (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class UnsignedByte: public virtual Type + { + public: + UnsignedByte (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Short: public virtual Type + { + public: + Short (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class UnsignedShort: public virtual Type + { + public: + UnsignedShort (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Int: public virtual Type + { + public: + Int (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class UnsignedInt: public virtual Type + { + public: + UnsignedInt (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Long: public virtual Type + { + public: + Long (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class UnsignedLong: public virtual Type + { + public: + UnsignedLong (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Integer: public virtual Type + { + public: + Integer (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class NonPositiveInteger: public virtual Type + { + public: + NonPositiveInteger (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class NonNegativeInteger: public virtual Type + { + public: + NonNegativeInteger (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class PositiveInteger: public virtual Type + { + public: + PositiveInteger (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class NegativeInteger: public virtual Type + { + public: + NegativeInteger (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Boolean: public virtual Type + { + public: + Boolean (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Float: public virtual Type + { + public: + Float (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Double: public virtual Type + { + public: + Double (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Decimal: public virtual Type + { + public: + Decimal (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class String: public virtual Type + { + public: + String (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class NormalizedString: public virtual Type + { + public: + NormalizedString (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Token: public virtual Type + { + public: + Token (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Name: public virtual Type + { + public: + Name (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class NameToken: public virtual Type + { + public: + NameToken (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class NameTokens: public virtual Type + { + public: + NameTokens (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class NCName: public virtual Type + { + public: + NCName (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Language: public virtual Type + { + public: + Language (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class QName: public virtual Type + { + public: + QName (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Id: public virtual Type + { + public: + Id (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class IdRef: public virtual Type, + public virtual Specialization + { + public: + IdRef (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class IdRefs: public virtual Type, + public virtual Specialization + { + public: + IdRefs (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class AnyURI: public virtual Type + { + public: + AnyURI (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Base64Binary: public virtual Type + { + public: + Base64Binary (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class HexBinary: public virtual Type + { + public: + HexBinary (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Date: public virtual Type + { + public: + Date (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class DateTime: public virtual Type + { + public: + DateTime (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Duration: public virtual Type + { + public: + Duration (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Day: public virtual Type + { + public: + Day (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Month: public virtual Type + { + public: + Month (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class MonthDay: public virtual Type + { + public: + MonthDay (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Year: public virtual Type + { + public: + Year (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class YearMonth: public virtual Type + { + public: + YearMonth (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Time: public virtual Type + { + public: + Time (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Entity: public virtual Type + { + public: + Entity (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Entities: public virtual Type + { + public: + Entities (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class Notation: public virtual Type + { + public: + Notation (Path const& file, + unsigned long line, + unsigned long column); + }; + } + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_FUNDAMENTAL_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.hxx.m4 b/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.hxx.m4 new file mode 100644 index 0000000..52c9c89 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.hxx.m4 @@ -0,0 +1,155 @@ +divert(-1) + +# file : xsd-frontend/semantic-graph/fundamental.hxx.m4 +# copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include(`fundamental.m4') + +define(`fundamental_type', `fundamental_type_impl(`make_class_name(`$1')', `$1')') + +define(`fundamental_type_impl', ` + + // + // + class $1: public virtual Type + { + public: + $1 (Path const& file, + unsigned long line, + unsigned long column); + };') +divert(0)dnl +dnl +dnl +dnl +// file : xsd-frontend/semantic-graph/fundamental.hxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Note, that this file is automatically generated! +// + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_FUNDAMENTAL_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_FUNDAMENTAL_HXX + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace Fundamental + { + // + // + class Type: public virtual SemanticGraph::Type + { + protected: + Type (); + }; +dnl +dnl Integers. +dnl +fundamental_type(`byte') +fundamental_type(`unsigned byte') +fundamental_type(`short') +fundamental_type(`unsigned short') +fundamental_type(`int') +fundamental_type(`unsigned int') +fundamental_type(`long') +fundamental_type(`unsigned long') +fundamental_type(`integer') +fundamental_type(`non positive integer') +fundamental_type(`non negative integer') +fundamental_type(`positive integer') +fundamental_type(`negative integer') +dnl +dnl Boolean. +dnl +fundamental_type(`boolean') +dnl +dnl Floats. +dnl +fundamental_type(`float') +fundamental_type(`double') +fundamental_type(`decimal') +dnl +dnl Strings. +dnl +fundamental_type(`string') +fundamental_type(`normalized string') +fundamental_type(`token') +fundamental_type(`name') +fundamental_type(`name token') +fundamental_type(`name tokens') +fundamental_type(`NC name') +fundamental_type(`language') +dnl +dnl Qualified name. +dnl +fundamental_type(`q name') +dnl +dnl ID/IDREF. +dnl +fundamental_type(`id') + + + // + // + class IdRef: public virtual Type, + public virtual Specialization + { + public: + IdRef (Path const& file, + unsigned long line, + unsigned long column); + }; + + + // + // + class IdRefs: public virtual Type, + public virtual Specialization + { + public: + IdRefs (Path const& file, + unsigned long line, + unsigned long column); + }; +dnl +dnl URI. +dnl +fundamental_type(`any URI') +dnl +dnl Binary. +dnl +fundamental_type(`base 64 binary') +fundamental_type(`hex binary') +dnl +dnl Date/time. +dnl +fundamental_type(`date') +fundamental_type(`date time') +fundamental_type(`duration') +fundamental_type(`day') +fundamental_type(`month') +fundamental_type(`month day') +fundamental_type(`year') +fundamental_type(`year month') +fundamental_type(`time') +dnl +dnl Entity. +dnl +fundamental_type(`entity') +fundamental_type(`entities') +dnl +dnl Notation. +dnl +fundamental_type(`notation') +dnl + } + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_FUNDAMENTAL_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.m4 b/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.m4 new file mode 100644 index 0000000..b9243f7 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.m4 @@ -0,0 +1,17 @@ +# file : xsd-frontend/semantic-graph/fundamental.m4 +# copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +define(`upcase', `translit(`$*', `a-z', `A-Z')') + + +define(`capitalize_word', + `regexp(`$1', `^\(.\)\(.*\)', `upcase(`\1')`\2'')') + + +define(`capitalize', + `patsubst(`$1', `\w+', `capitalize_word(`\&')')') + +define(`make_class_name', `patsubst(capitalize(`$1'), ` ')') + +define(`make_var_name', `patsubst(`$1', ` ', `_')') diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/list.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/list.cxx new file mode 100644 index 0000000..f62f617 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/list.cxx @@ -0,0 +1,34 @@ +// file : xsd-frontend/semantic-graph/list.cxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + List:: + List (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column) + { + } + + namespace + { + using compiler::type_info; + + struct ListInit + { + ListInit () + { + type_info ti (typeid (List)); + ti.add_base (typeid (Specialization)); + insert (ti); + } + } list_init_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/list.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/list.hxx new file mode 100644 index 0000000..d7f370f --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/list.hxx @@ -0,0 +1,22 @@ +// file : xsd-frontend/semantic-graph/list.hxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_LIST_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_LIST_HXX + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + class List: public virtual Specialization + { + public: + List (Path const& file, unsigned long line, unsigned long column); + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_LIST_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/namespace.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/namespace.cxx new file mode 100644 index 0000000..e33a892 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/namespace.cxx @@ -0,0 +1,34 @@ +// file : xsd-frontend/semantic-graph/namespace.cxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + Namespace:: + Namespace (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column) + { + } + + namespace + { + using compiler::type_info; + + struct NamespaceInit + { + NamespaceInit () + { + type_info ti (typeid (Namespace)); + ti.add_base (typeid (Scope)); + insert (ti); + } + } namespace_init_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/namespace.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/namespace.hxx new file mode 100644 index 0000000..ccc9d61 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/namespace.hxx @@ -0,0 +1,27 @@ +// file : xsd-frontend/semantic-graph/namespace.hxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_NAMESPACE_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_NAMESPACE_HXX + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + class Namespace : public virtual Scope + { + public: + Namespace (Path const& file, unsigned long line, unsigned long column); + + void + add_edge_right (BelongsToNamespace&) {} + + using Scope::add_edge_right; + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_NAMESPACE_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/particle.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/particle.cxx new file mode 100644 index 0000000..c3269e6 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/particle.cxx @@ -0,0 +1,54 @@ +// file : xsd-frontend/semantic-graph/particle.cxx +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + // ContainsParticle + // + ContainsParticle:: + ContainsParticle (unsigned long min, unsigned long max) + : particle_ (0), compositor_ (0), min_ (min), max_ (max) + { + } + + // Particle + // + Particle:: + Particle () + : contained_particle_ (0) + { + } + + namespace + { + using compiler::type_info; + + struct ContainsParticleInit + { + ContainsParticleInit () + { + type_info ti (typeid (ContainsParticle)); + ti.add_base (typeid (Edge)); + insert (ti); + } + } contains_particle_init_; + + struct ParticleInit + { + ParticleInit () + { + type_info ti (typeid (Particle)); + ti.add_base (typeid (Node)); + insert (ti); + } + } particle_init_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/particle.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/particle.hxx new file mode 100644 index 0000000..a7f0755 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/particle.hxx @@ -0,0 +1,140 @@ +// file : xsd-frontend/semantic-graph/particle.hxx +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_PARTICLE_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_PARTICLE_HXX + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + // + // + class Particle; + class Compositor; + + + // + // + class ContainsParticle: public virtual Edge + { + public: + Particle& + particle () const + { + return *particle_; + } + + Compositor& + compositor () const + { + return *compositor_; + } + + public: + unsigned long + min () const + { + return min_; + } + + unsigned long + max () const + { + return max_; + } + + public: + ContainsParticle (unsigned long min, unsigned long max); + + void + set_left_node (Compositor& n) + { + compositor_ = &n; + } + + void + set_right_node (Particle& n) + { + particle_ = &n; + } + + void + clear_left_node (Compositor& n) + { + assert (compositor_ == &n); + compositor_ = 0; + } + + void + clear_right_node (Particle& n) + { + assert (particle_ == &n); + particle_ = 0; + } + + private: + Particle* particle_; + Compositor* compositor_; + unsigned long min_, max_; + }; + + // + // + class Particle: public virtual Node + { + public: + bool + contained_particle_p () + { + return contained_particle_ != 0; + } + + ContainsParticle& + contained_particle () + { + assert (contained_particle_ != 0); + return *contained_particle_; + } + + public: + unsigned long + min () const + { + assert (contained_particle_ != 0); + return contained_particle_->min (); + } + + unsigned long + max () const + { + assert (contained_particle_ != 0); + return contained_particle_->max (); + } + + public: + Particle (); + + void + add_edge_right (ContainsParticle& e) + { + contained_particle_ = &e; + } + + void + remove_edge_right (ContainsParticle& e) + { + assert (contained_particle_ == &e); + contained_particle_ = 0; + } + + private: + ContainsParticle* contained_particle_; + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_PARTICLE_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/schema.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/schema.cxx new file mode 100644 index 0000000..d1cbf25 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/schema.cxx @@ -0,0 +1,130 @@ +// file : xsd-frontend/semantic-graph/schema.cxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + // Schema + // + Schema::NamesIteratorPair Schema:: + find (Name const& name) const + { + // Here we are going to create an illusion that the namespace + // hierarchy is flat. + names_.clear (); + schemas_.clear (); + + find_ (name, names_, schemas_); + + return NamesIteratorPair (NamesConstIterator (names_.begin ()), + NamesConstIterator (names_.end ())); + } + + void Schema:: + find_ (Name const& name, NamesList& names, SchemaSet& set) const + { + set.insert (this); + + // Check our own namespace first so it will end up first in the list. + // + NamesIteratorPair pair (Scope::find (name)); + names.insert (names.end (), pair.first.base (), pair.second.base ()); + + for (UsesIterator i (uses_begin ()), end (uses_end ()); i != end; ++i) + { + Schema& s (i->schema ()); + + if (set.find (&s) == set.end ()) + s.find_ (name, names, set); + } + } + + namespace + { + using compiler::type_info; + + // Uses + // + struct UsesInit + { + UsesInit () + { + type_info ti (typeid (Uses)); + ti.add_base (typeid (Edge)); + insert (ti); + } + } uses_init_; + + + // Implies + // + struct ImpliesInit + { + ImpliesInit () + { + type_info ti (typeid (Implies)); + ti.add_base (typeid (Uses)); + insert (ti); + } + } implies_init_; + + + // Sources + // + struct SourcesInit + { + SourcesInit () + { + type_info ti (typeid (Sources)); + ti.add_base (typeid (Uses)); + insert (ti); + } + } sources_init_; + + + // Includes + // + struct IncludesInit + { + IncludesInit () + { + type_info ti (typeid (Includes)); + ti.add_base (typeid (Uses)); + insert (ti); + } + } includes_init_; + + + // Imports + // + struct ImportsInit + { + ImportsInit () + { + type_info ti (typeid (Imports)); + ti.add_base (typeid (Uses)); + insert (ti); + } + } imports_init_; + + + // Schema + // + struct SchemaInit + { + SchemaInit () + { + type_info ti (typeid (Schema)); + ti.add_base (typeid (Scope)); + insert (ti); + } + } schema_init_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/schema.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/schema.hxx new file mode 100644 index 0000000..803c870 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/schema.hxx @@ -0,0 +1,237 @@ +// file : xsd-frontend/semantic-graph/schema.hxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_SCHEMA_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_SCHEMA_HXX + +#include +#include + +#include +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + class Schema; + + class Uses: public virtual Edge + { + public: + Schema& + user () const + { + return *user_; + } + + Schema& + schema () const + { + return *schema_; + } + + Path + path () const + { + return path_; + } + + public: + Uses (Path const& path): path_ (path) {} + + void + set_left_node (Schema& s) + { + user_ = &s; + } + + void + set_right_node (Schema& s) + { + schema_ = &s; + } + + private: + Path path_; + Schema* user_; + Schema* schema_; + }; + + + // + // + class Implies: public virtual Uses + { + public: + Implies (Path const& path): Uses (path) {} + }; + + + // + // + class Sources: public virtual Uses + { + public: + Sources (Path const& path): Uses (path) {} + }; + + + // + // + class Includes: public virtual Uses + { + public: + Includes (Path const& path): Uses (path) {} + }; + + + // + // + class Imports: public virtual Uses + { + public: + Imports (Path const& path): Uses (path) {} + }; + + // + // + class Schema: public graph, public virtual Scope + { + typedef std::vector UsesList; + typedef std::vector UsedList; + + public: + Schema (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column), graph_ (*this) + { + } + + private: + Schema (Schema const&); + Schema& operator= (Schema const&); + + public: + typedef pointer_iterator UsesIterator; + + UsesIterator + uses_begin () const + { + return uses_.begin (); + } + + UsesIterator + uses_end () const + { + return uses_.end (); + } + + public: + typedef pointer_iterator UsedIterator; + + UsedIterator + used_begin () const + { + return used_.begin (); + } + + UsedIterator + used_end () const + { + return used_.end (); + } + + bool + used_p () const + { + return used_begin () != used_end (); + } + + virtual NamesIteratorPair + find (Name const& name) const; + + public: + using graph::new_edge; + using graph::reset_left_node; + using graph::reset_right_node; + using graph::add_edge_left; + using graph::add_edge_right; + using graph::delete_node; + using graph::delete_edge; + + template + T& + new_node (Path const& file, unsigned long line, unsigned long column) + { + return graph_.new_node (file, line, column); + } + + template + T& + new_node (Path const& file, unsigned long line, unsigned long column, + A0 const& a0) + { + return graph_.new_node (file, line, column, a0); + } + + template + T& + new_node (Path const& file, unsigned long line, unsigned long column, + A0 const& a0, A1 const& a1) + { + return graph_.new_node (file, line, column, a0, a1); + } + + template + T& + new_node (Path const& file, unsigned long line, unsigned long column, + A0 const& a0, A1 const& a1, A2 const& a2) + { + return graph_.new_node (file, line, column, a0, a1, a2); + } + + template + T& + new_node (Path const& file, unsigned long line, unsigned long column, + A0 const& a0, A1 const& a1, A2 const& a2, A3 const& a3) + { + return graph_.new_node (file, line, column, a0, a1, a2, a3); + } + + public: + using Scope::add_edge_left; + using Node::add_edge_right; + + void + add_edge_left (Uses& e) + { + uses_.push_back (&e); + } + + void + add_edge_right (Uses& e) + { + used_.push_back (&e); + } + + private: + typedef std::set SchemaSet; + + void + find_ (Name const& name, NamesList&, SchemaSet&) const; + + private: + graph& graph_; + + UsesList uses_; + UsedList used_; + + mutable NamesList names_; + mutable SchemaSet schemas_; + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_SCHEMA_HXX diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/union.cxx b/libxsd-frontend/xsd-frontend/semantic-graph/union.cxx new file mode 100644 index 0000000..4e7436d --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/union.cxx @@ -0,0 +1,34 @@ +// file : xsd-frontend/semantic-graph/union.cxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + Union:: + Union (Path const& file, unsigned long line, unsigned long column) + : Node (file, line, column) + { + } + + namespace + { + using compiler::type_info; + + struct UnionInit + { + UnionInit () + { + type_info ti (typeid (Union)); + ti.add_base (typeid (Specialization)); + insert (ti); + } + } union_init_; + } + } +} diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/union.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/union.hxx new file mode 100644 index 0000000..d7ba385 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/union.hxx @@ -0,0 +1,22 @@ +// file : xsd-frontend/semantic-graph/union.hxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_UNION_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_UNION_HXX + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + class Union: public virtual Specialization + { + public: + Union (Path const& file, unsigned long line, unsigned long column); + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_UNION_HXX -- cgit v1.2.3