From a15cf65c44d5c224169c32ef5495b68c758134b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 18 May 2014 16:08:14 +0200 Subject: Imported Upstream version 3.3.0.2 --- .../xsd-frontend/semantic-graph/annotation.cxx | 50 + .../xsd-frontend/semantic-graph/annotation.hxx | 89 ++ .../xsd-frontend/semantic-graph/any-attribute.cxx | 114 ++ .../xsd-frontend/semantic-graph/any-attribute.hxx | 85 ++ .../xsd-frontend/semantic-graph/any.cxx | 125 ++ .../xsd-frontend/semantic-graph/any.hxx | 90 ++ .../semantic-graph/attribute-group.cxx | 39 + .../semantic-graph/attribute-group.hxx | 27 + .../xsd-frontend/semantic-graph/attribute.cxx | 44 + .../xsd-frontend/semantic-graph/attribute.hxx | 39 + .../xsd-frontend/semantic-graph/complex.cxx | 45 + .../xsd-frontend/semantic-graph/complex.hxx | 78 ++ .../xsd-frontend/semantic-graph/compositors.cxx | 124 ++ .../xsd-frontend/semantic-graph/compositors.hxx | 263 +++++ .../xsd-frontend/semantic-graph/element-group.cxx | 38 + .../xsd-frontend/semantic-graph/element-group.hxx | 45 + .../xsd-frontend/semantic-graph/element.cxx | 63 + .../xsd-frontend/semantic-graph/element.hxx | 105 ++ .../xsd-frontend/semantic-graph/elements.cxx | 350 ++++++ .../xsd-frontend/semantic-graph/elements.hxx | 1247 ++++++++++++++++++++ .../xsd-frontend/semantic-graph/enumeration.cxx | 67 ++ .../xsd-frontend/semantic-graph/enumeration.hxx | 35 + .../xsd-frontend/semantic-graph/fundamental.cxx.m4 | 216 ++++ .../xsd-frontend/semantic-graph/fundamental.hxx.m4 | 165 +++ .../xsd-frontend/semantic-graph/fundamental.m4 | 18 + .../xsd-frontend/semantic-graph/list.cxx | 37 + .../xsd-frontend/semantic-graph/list.hxx | 25 + .../xsd-frontend/semantic-graph/namespace.cxx | 37 + .../xsd-frontend/semantic-graph/namespace.hxx | 32 + .../xsd-frontend/semantic-graph/particle.cxx | 61 + .../xsd-frontend/semantic-graph/particle.hxx | 145 +++ .../xsd-frontend/semantic-graph/schema.cxx | 139 +++ .../xsd-frontend/semantic-graph/schema.hxx | 281 +++++ .../xsd-frontend/semantic-graph/union.cxx | 37 + .../xsd-frontend/semantic-graph/union.hxx | 25 + 35 files changed, 4380 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.m4 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..22793f7 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/annotation.cxx @@ -0,0 +1,50 @@ +// file : xsd-frontend/semantic-graph/annotation.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + + // Annotates + // + namespace + { + struct AnnotatesInit + { + AnnotatesInit () + { + TypeInfo ti (typeid (Annotates)); + ti.add_base (Access::public_, true, typeid (Edge)); + RTTI::insert (ti); + } + + } annotates_init_; + } + + // Annotation + // + namespace + { + struct AnnotationInit + { + AnnotationInit () + { + TypeInfo ti (typeid (Annotation)); + ti.add_base (Access::public_, true, typeid (Node)); + RTTI::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..661ac72 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/annotation.hxx @@ -0,0 +1,89 @@ +// file : xsd-frontend/semantic-graph/annotation.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2010 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_; + } + + protected: + friend class Bits::Graph; + + 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: + WideString const& + documentation () const + { + return documentation_; + } + + protected: + friend class Bits::Graph; + + Annotation (Path const& file, + UnsignedLong line, + UnsignedLong column, + WideString const& documentation) + : Node (file, line, column), documentation_ (documentation) + { + } + + Void + add_edge_left (Annotates&) + { + } + + private: + WideString 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..e25e742 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/any-attribute.cxx @@ -0,0 +1,114 @@ +// file : xsd-frontend/semantic-graph/any-attribute.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + namespace + { + struct AnyAttributeInit + { + AnyAttributeInit () + { + TypeInfo ti (typeid (AnyAttribute)); + ti.add_base (Access::public_, true, typeid (Nameable)); + RTTI::insert (ti); + } + + } any_attribute_init_; + } + + AnyAttribute:: + AnyAttribute (Path const& file, + UnsignedLong line, + UnsignedLong column, + WideString const& namespaces) + : Node (file, line, column), + prototype_ (0) + { + // Not sure if the separator is just space or any white-space + // chararcter. + // + + for (Size i (0), j (namespaces.find (L' '));;) + { + if (j != WideString::npos) + { + namespaces_.push_back (WideString (namespaces, i, j - i)); + + i = j + 1; + j = namespaces.find (L' ', i); + } + else + { + // Last element. + // + namespaces_.push_back (WideString (namespaces, i)); + break; + } + } + } + + AnyAttribute:: + AnyAttribute (Path const& file, + UnsignedLong line, + UnsignedLong 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 ()); + } + } +} 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..bc8c512 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/any-attribute.hxx @@ -0,0 +1,85 @@ +// file : xsd-frontend/semantic-graph/any-attribute.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 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 + Cult::Containers::Vector + Namespaces; + + public: + typedef Namespaces::ConstIterator NamespaceIterator; + + NamespaceIterator + namespace_begin () const + { + return namespaces_.begin (); + } + + NamespaceIterator + namespace_end () const + { + return namespaces_.end (); + } + + public: + Boolean + 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 (); + + protected: + friend class Bits::Graph; + + AnyAttribute (Path const& file, + UnsignedLong line, + UnsignedLong column, + WideString const& namespaces); + + AnyAttribute (Path const& file, + UnsignedLong line, + UnsignedLong 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..a6c9e72 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/any.cxx @@ -0,0 +1,125 @@ +// file : xsd-frontend/semantic-graph/any.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + namespace + { + struct AnyInit + { + AnyInit () + { + TypeInfo ti (typeid (Any)); + ti.add_base (Access::public_, true, typeid (Nameable)); + ti.add_base (Access::public_, true, typeid (Particle)); + RTTI::insert (ti); + } + + } any_init_; + } + + Any:: + Any (Path const& file, + UnsignedLong line, + UnsignedLong column, + WideString const& namespaces) + : Node (file, line, column), + prototype_ (0) + { + // Not sure if the separator is just space or any white-space + // chararcter. + // + + for (Size i (0), j (namespaces.find (L' '));;) + { + if (j != WideString::npos) + { + namespaces_.push_back (WideString (namespaces, i, j - i)); + + i = j + 1; + j = namespaces.find (L' ', i); + } + else + { + // Last element. + // + namespaces_.push_back (WideString (namespaces, i)); + break; + } + } + } + + Any:: + Any (Path const& file, + UnsignedLong line, + UnsignedLong 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); + } + } +} 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..ded9bd8 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/any.hxx @@ -0,0 +1,90 @@ +// file : xsd-frontend/semantic-graph/any.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 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 + Cult::Containers::Vector + Namespaces; + + public: + typedef Namespaces::ConstIterator NamespaceIterator; + + NamespaceIterator + namespace_begin () const + { + return namespaces_.begin (); + } + + NamespaceIterator + namespace_end () const + { + return namespaces_.end (); + } + + public: + Boolean + 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 (); + + protected: + friend class Bits::Graph; + + Any (Path const& file, + UnsignedLong line, + UnsignedLong column, + WideString const& namespaces); + + Any (Path const& file, + UnsignedLong line, + UnsignedLong 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..54bb5df --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/attribute-group.cxx @@ -0,0 +1,39 @@ +// file : xsd-frontend/semantic-graph/attribute-group.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + + namespace + { + struct AttributeGroupInit + { + AttributeGroupInit () + { + TypeInfo ti (typeid (AttributeGroup)); + ti.add_base (Access::public_, true, typeid (Scope)); + RTTI::insert (ti); + } + + } attribute_group_init_; + } + + AttributeGroup:: + AttributeGroup (Path const& file, UnsignedLong line, UnsignedLong column) + : Node (file, line, column) + { + } + + } +} 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..44739f2 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/attribute-group.hxx @@ -0,0 +1,27 @@ +// file : xsd-frontend/semantic-graph/attribute-group.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2010 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 + { + protected: + friend class Bits::Graph; + + AttributeGroup (Path const& file, + UnsignedLong line, + UnsignedLong 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..2e30d4e --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/attribute.cxx @@ -0,0 +1,44 @@ +// file : xsd-frontend/semantic-graph/attribute.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + namespace + { + struct AttributeInit + { + AttributeInit () + { + TypeInfo ti (typeid (Attribute)); + ti.add_base (Access::public_, true, typeid (Member)); + RTTI::insert (ti); + } + + } attribute_init_; + } + + Attribute:: + Attribute (Path const& file, + UnsignedLong line, + UnsignedLong column, + Boolean optional, + Boolean global, + Boolean qualified) + : Node (file, line, column), + Member (global, qualified), + optional_ (optional) + { + } + } +} 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..f7a516d --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/attribute.hxx @@ -0,0 +1,39 @@ +// file : xsd-frontend/semantic-graph/attribute.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 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: + Boolean + optional_p () const + { + return optional_; + } + + protected: + friend class Bits::Graph; + + Attribute (Path const& file, + UnsignedLong line, + UnsignedLong column, + Boolean optional, + Boolean global, + Boolean qualified); + private: + Boolean 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..0cc265f --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/complex.cxx @@ -0,0 +1,45 @@ +// file : xsd-frontend/semantic-graph/complex.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + namespace + { + struct ComplexInit + { + ComplexInit () + { + TypeInfo ti (typeid (Complex)); + ti.add_base (Access::public_, true, typeid (Type)); + ti.add_base (Access::public_, true, typeid (Scope)); + RTTI::insert (ti); + } + + } complex_init_; + } + + Complex:: + Complex () + : mixed_ (false), contains_compositor_ (0) + { + } + + Complex:: + Complex (Path const& file, UnsignedLong line, UnsignedLong column) + : Node (file, line, column), + mixed_ (false), contains_compositor_ (0) + { + } + } +} 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..40327bc --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/complex.hxx @@ -0,0 +1,78 @@ +// file : xsd-frontend/semantic-graph/complex.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 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 + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + class Complex: public virtual Type, public virtual Scope + { + public: + Boolean + mixed_p () const + { + return mixed_; + } + + public: + Boolean + contains_compositor_p () + { + return contains_compositor_ != 0; + } + + ContainsCompositor& + contains_compositor () + { + assert (contains_compositor_ != 0); + return *contains_compositor_; + } + + public: + Void + mixed_p (Boolean m) + { + mixed_ = m; + } + + protected: + friend class Bits::Graph; + + Complex (); // Virtual inheritance (Enumeration). + Complex (Path const& file, UnsignedLong line, UnsignedLong column); + + using Type::add_edge_right; + using Type::add_edge_left; + using Scope::add_edge_left; + + Void + add_edge_left (ContainsCompositor& e) + { + contains_compositor_ = &e; + } + + Void + remove_edge_left (ContainsCompositor& e) + { + assert (contains_compositor_ == &e); + contains_compositor_ = 0; + } + + private: + Boolean 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..08953bc --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/compositors.cxx @@ -0,0 +1,124 @@ +// file : xsd-frontend/semantic-graph/compositor.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + + // ContainsCompositor + // + namespace + { + struct ContainsCompositorInit + { + ContainsCompositorInit () + { + TypeInfo ti (typeid (ContainsCompositor)); + ti.add_base (Access::public_, true, typeid (Edge)); + RTTI::insert (ti); + } + + } contains_compositor_init_; + } + + ContainsCompositor:: + ContainsCompositor (UnsignedLong min, UnsignedLong max) + : compositor_ (0), container_ (0), min_ (min), max_ (max) + { + } + + // Compositor + // + namespace + { + struct CompositorInit + { + CompositorInit () + { + TypeInfo ti (typeid (Compositor)); + ti.add_base (Access::public_, true, typeid (Particle)); + RTTI::insert (ti); + } + + } compositor_init_; + } + + + // All + // + namespace + { + struct AllInit + { + AllInit () + { + TypeInfo ti (typeid (All)); + ti.add_base (Access::public_, true, typeid (Compositor)); + RTTI::insert (ti); + } + + } all_init_; + } + + All:: + All (Path const& file, UnsignedLong line, UnsignedLong column) + : Node (file, line, column) + { + } + + + // Choice + // + namespace + { + struct ChoiceInit + { + ChoiceInit () + { + TypeInfo ti (typeid (Choice)); + ti.add_base (Access::public_, true, typeid (Compositor)); + RTTI::insert (ti); + } + + } choice_init_; + } + + Choice:: + Choice (Path const& file, UnsignedLong line, UnsignedLong column) + : Node (file, line, column) + { + } + + // Sequence + // + namespace + { + struct SequenceInit + { + SequenceInit () + { + TypeInfo ti (typeid (Sequence)); + ti.add_base (Access::public_, true, typeid (Compositor)); + RTTI::insert (ti); + } + + } sequence_init_; + } + + Sequence:: + Sequence (Path const& file, UnsignedLong line, UnsignedLong column) + : Node (file, line, column) + { + } + } +} 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..c82d8a4 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/compositors.hxx @@ -0,0 +1,263 @@ +// file : xsd-frontend/semantic-graph/compositors.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2010 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: + UnsignedLong + min () const + { + return min_; + } + + UnsignedLong + max () const + { + return max_; + } + + protected: + friend class Bits::Graph; + + ContainsCompositor (UnsignedLong min, UnsignedLong 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_; + UnsignedLong min_, max_; + }; + + + // + // + class Compositor: public virtual Particle + { + typedef + Cult::Containers::List + ContainsList; + + public: + typedef + Bits::PointerIterator + ContainsIterator; + + typedef + Bits::PointerIterator + 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: + Boolean + contained_compositor_p () + { + return contained_compositor_ != 0; + } + + ContainsCompositor& + contained_compositor () + { + assert (contained_compositor_ != 0); + return *contained_compositor_; + } + + public: + UnsignedLong + min () const + { + if (contained_compositor_ != 0) + return contained_compositor_->min (); + else + return Particle::min (); + } + + UnsignedLong + max () const + { + if (contained_compositor_ != 0) + return contained_compositor_->max (); + else + return Particle::max (); + } + + protected: + friend class Bits::Graph; + + Compositor () + : contained_compositor_ (0) + { + } + + Void + add_edge_left (ContainsParticle& e) + { + contains_.push_back (&e); + } + + Void + remove_edge_left (ContainsParticle& e) + { + for (ContainsList::Iterator i (contains_.begin ()); + i != contains_.end (); ++i) + { + if (*i == &e) + { + contains_.erase (i); + break; + } + } + } + + //@@ Ideally should be protected but then NodeArg has no way to + // access it. Maybe when (if) I move NodeArg into Grpah I can + // resolve this. + // + public: + 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); + } + } + + protected: + using Node::add_edge_right; + using Particle::add_edge_right; + using Particle::remove_edge_right; + + Void + add_edge_right (ContainsCompositor& e) + { + contained_compositor_ = &e; + } + + Void + remove_edge_right (ContainsCompositor& e) + { + assert (contained_compositor_ == &e); + contained_compositor_ = 0; + } + + private: + ContainsList contains_; + ContainsCompositor* contained_compositor_; + }; + + + // + // + class All: public virtual Compositor + { + protected: + friend class Bits::Graph; + + All (Path const& file, UnsignedLong line, UnsignedLong column); + }; + + + // + // + class Choice: public virtual Compositor + { + protected: + friend class Bits::Graph; + + Choice (Path const& file, UnsignedLong line, UnsignedLong column); + }; + + + // + // + class Sequence: public virtual Compositor + { + protected: + friend class Bits::Graph; + + Sequence (Path const& file, UnsignedLong line, UnsignedLong 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..0e71aa6 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/element-group.cxx @@ -0,0 +1,38 @@ +// file : xsd-frontend/semantic-graph/element-group.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + + namespace + { + struct ElementGroupInit + { + ElementGroupInit () + { + TypeInfo ti (typeid (ElementGroup)); + ti.add_base (Access::public_, true, typeid (Scope)); + RTTI::insert (ti); + } + + } element_group_init_; + } + + ElementGroup:: + ElementGroup (Path const& file, UnsignedLong line, UnsignedLong column) + : Node (file, line, column), contains_compositor_ (0) + { + } + } +} 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..23514b5 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/element-group.hxx @@ -0,0 +1,45 @@ +// file : xsd-frontend/semantic-graph/element-group.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2010 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_; + } + + protected: + friend class Bits::Graph; + + ElementGroup (Path const& file, UnsignedLong line, UnsignedLong column); + + using Scope::add_edge_left; + + Void + add_edge_left (ContainsCompositor& e) + { + contains_compositor_ = &e; + } + + 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..1d8cda5 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/element.cxx @@ -0,0 +1,63 @@ +// file : xsd-frontend/semantic-graph/element.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + + // Substitutes + // + namespace + { + struct SubstitutesInit + { + SubstitutesInit () + { + TypeInfo ti (typeid (Substitutes)); + ti.add_base (Access::public_, true, typeid (Edge)); + RTTI::insert (ti); + } + + } substitutes_init_; + } + + // Element + // + namespace + { + struct ElementInit + { + ElementInit () + { + TypeInfo ti (typeid (Element)); + ti.add_base (Access::public_, true, typeid (Member)); + ti.add_base (Access::public_, true, typeid (Particle)); + RTTI::insert (ti); + } + + } element_init_; + } + + Element:: + Element (Path const& file, + UnsignedLong line, + UnsignedLong column, + Boolean global, + Boolean qualified) + : Node (file, line, column), + Member (global, qualified), + substitutes_ (0) + { + } + } +} 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..e7046e4 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/element.hxx @@ -0,0 +1,105 @@ +// file : xsd-frontend/semantic-graph/element.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 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_; + } + + protected: + friend class Bits::Graph; + + Substitutes () + { + } + + 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: + Boolean + substitutes_p () const + { + return substitutes_ != 0; + } + + Substitutes& + substitutes () const + { + assert (substitutes_ != 0); + return *substitutes_; + } + + protected: + friend class Bits::Graph; + + Element (Path const& file, + UnsignedLong line, + UnsignedLong column, + Boolean global, + Boolean 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..6a2addf --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/elements.cxx @@ -0,0 +1,350 @@ +// file : xsd-frontend/semantic-graph/elements.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#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); + } + + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + namespace + { + // Edge + // + struct EdgeInit + { + EdgeInit () + { + TypeInfo ti (typeid (Edge)); + RTTI::insert (ti); + } + + } edge_init_; + + + // Node + // + struct NodeInit + { + NodeInit () + { + TypeInfo ti (typeid (Node)); + RTTI::insert (ti); + } + + } node_init_; + + + // Names + // + struct NamesInit + { + NamesInit () + { + TypeInfo ti (typeid (Names)); + ti.add_base (Access::public_, true, typeid (Edge)); + RTTI::insert (ti); + } + + } names_init_; + + + // Nameable + // + struct NameableInit + { + NameableInit () + { + TypeInfo ti (typeid (Nameable)); + ti.add_base (Access::public_, true, typeid (Node)); + RTTI::insert (ti); + } + + } nameable_init_; + + + // Scope + // + struct ScopeInit + { + ScopeInit () + { + TypeInfo ti (typeid (Scope)); + ti.add_base (Access::public_, true, typeid (Nameable)); + RTTI::insert (ti); + } + + } scope_init_; + + + // Type + // + struct TypeInit + { + TypeInit () + { + TypeInfo ti (typeid (Type)); + ti.add_base (Access::public_, true, typeid (Nameable)); + RTTI::insert (ti); + } + + } type_init_; + + + // Instance + // + struct InstanceInit + { + InstanceInit () + { + TypeInfo ti (typeid (Instance)); + ti.add_base (Access::public_, true, typeid (Nameable)); + RTTI::insert (ti); + } + + } instance_init_; + + + // Belongs + // + struct BelongsInit + { + BelongsInit () + { + TypeInfo ti (typeid (Belongs)); + ti.add_base (Access::public_, true, typeid (Edge)); + RTTI::insert (ti); + } + + } belongs_init_; + + + + // Inherits + // + struct InheritsInit + { + InheritsInit () + { + TypeInfo ti (typeid (Inherits)); + ti.add_base (Access::public_, true, typeid (Edge)); + RTTI::insert (ti); + } + + } inherits_init_; + + + // Extends + // + struct ExtendsInit + { + ExtendsInit () + { + TypeInfo ti (typeid (Extends)); + ti.add_base (Access::public_, true, typeid (Inherits)); + RTTI::insert (ti); + } + + } extends_init_; + + + // Restricts + // + struct RestrictsInit + { + RestrictsInit () + { + TypeInfo ti (typeid (Restricts)); + ti.add_base (Access::public_, true, typeid (Inherits)); + RTTI::insert (ti); + } + + } restricts_init_; + + + // BelongsToNamespace + // + struct BelongsToNamespaceInit + { + BelongsToNamespaceInit () + { + TypeInfo ti (typeid (BelongsToNamespace)); + ti.add_base (Access::public_, true, typeid (Edge)); + RTTI::insert (ti); + } + + } belongs_to_namespace_init_; + + + // Member + // + struct MemberInit + { + MemberInit () + { + TypeInfo ti (typeid (Member)); + ti.add_base (Access::public_, true, typeid (Instance)); + RTTI::insert (ti); + } + + } member_init_; + + + // Specialization + // + struct SpecializationInit + { + SpecializationInit () + { + TypeInfo ti (typeid (Specialization)); + ti.add_base (Access::public_, true, typeid (Type)); + RTTI::insert (ti); + } + + } specialization_init_; + + + // Arguments + // + struct ArgumentsInit + { + ArgumentsInit () + { + TypeInfo ti (typeid (Arguments)); + ti.add_base (Access::public_, true, typeid (Edge)); + RTTI::insert (ti); + } + + } arguments_init_; + + + /* + // Contains + // + struct ContainsInit + { + ContainsInit () + { + TypeInfo ti (typeid (Contains)); + ti.add_base (Access::public_, true, typeid (Edge)); + RTTI::insert (ti); + } + + } contains_init_; + + + // Container + // + struct ContainerInit + { + ContainerInit () + { + TypeInfo ti (typeid (Container)); + ti.add_base (Access::public_, true, typeid (Node)); + RTTI::insert (ti); + } + + } container_init_; + */ + + + // AnyType + // + namespace + { + struct AnyTypeInit + { + AnyTypeInit () + { + TypeInfo ti (typeid (AnyType)); + ti.add_base (Access::public_, true, typeid (SemanticGraph::Type)); + RTTI::insert (ti); + } + + } any_type_init_; + } + + + // AnySimpleType + // + namespace + { + struct AnySimpleTypeInit + { + AnySimpleTypeInit () + { + TypeInfo ti (typeid (AnySimpleType)); + ti.add_base (Access::public_, true, typeid (Type)); + RTTI::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) +{ +#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 + return os << path.native_file_string ().c_str (); +#else + return os << path.string ().c_str (); +#endif +} 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..78b6615 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/elements.hxx @@ -0,0 +1,1247 @@ +// file : xsd-frontend/semantic-graph/elements.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 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 + +#include +#include +#include +#include +#include +#include + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + using namespace Cult::Types; + + namespace Bits + { + using Cult::Containers::Graph; + + //@@ Should end up in Cult::Meta + // + template + struct strip_pointer + { + typedef X Type; + }; + + template + struct strip_pointer + { + typedef X Type; + }; + + template + struct PointerIterator + { + typedef + typename strip_pointer::Type + Value; + + typedef I BaseIterator; + typedef Value& Reference; + typedef Value* Pointer; + + PointerIterator () + : i_ () // i_ can be of a pointer type. + { + } + + PointerIterator (I const& i) + : i_ (i) + { + } + + public: + Reference + operator* () const + { + return **i_; + } + + Pointer + operator-> () const + { + return *i_; + } + + I const& + base () const + { + return i_; + } + + public: + PointerIterator& + operator++ () + { + ++i_; + return *this; + } + + PointerIterator + operator++ (Int) + { + PointerIterator r (*this); + ++i_; + return r; + } + + PointerIterator& + operator-- () + { + --i_; + return *this; + } + + PointerIterator + operator-- (Int) + { + PointerIterator r (*this); + --i_; + return r; + } + + private: + I i_; + }; + + template + inline + Boolean + operator== (PointerIterator const& a, PointerIterator const& b) + { + return a.base () == b.base (); + } + + template + inline + Boolean + operator!= (PointerIterator const& a, PointerIterator const& b) + { + return a.base () != b.base (); + } + + template + inline + typename PointerIterator::BaseIterator::difference_type + operator- (PointerIterator const& a, PointerIterator const& b) + { + return a.base () - b.base (); + } + } + + // + // + typedef + boost::filesystem::filesystem_error + InvalidPath; + + typedef + boost::filesystem::path + Path; + + typedef + Cult::Containers::Vector + Paths; + + typedef + FrontendElements::Context + Context; + + // + // + class Node; + class Edge; + + // + // + class Annotates; + class Annotation; + + // + // + class Edge + { + public: + Context& + context () const + { + return context_; + } + + virtual + ~Edge () + { + } + + public: + template + Boolean + is_a () const + { + return dynamic_cast (this) != 0; + } + + protected: + friend class Bits::Graph; + + Edge () + { + } + + private: + mutable Context context_; + }; + + inline Boolean + 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_; + } + + UnsignedLong + line () const + { + return line_; + } + + UnsignedLong + column () const + { + return column_; + } + + public: + Boolean + annotated_p () const + { + return annotates_ != 0; + } + + Annotates& + annotated () const + { + return *annotates_; + } + + Annotation& + annotation (); + + public: + template + Boolean + is_a () const + { + return dynamic_cast (this) != 0; + } + + public: + + virtual + ~Node () + { + } + + protected: + friend class Bits::Graph; + + Node (Path const& file, UnsignedLong line, UnsignedLong column) + : annotates_ (0), file_ (file), line_ (line), column_ (column) + { + } + + Node () // For virtual inheritance. + { + abort (); // Told you so! + } + + Void + add_edge_right (Annotates& a) + { + annotates_ = &a; + } + + private: + mutable Context context_; + Annotates* annotates_; + Path file_; + UnsignedLong line_; + UnsignedLong column_; + }; + + inline Boolean + operator== (Node const& x, Node const& y) + { + return &x == &y; + } + + + // + // + typedef WideString 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_; + } + + protected: + friend class Bits::Graph; + + 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: + Boolean + 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_; + } + + protected: + friend class Bits::Graph; + + 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 + Cult::Containers::Set + Nameables; + + + // + // + class Scope: public virtual Nameable + { + protected: + typedef + Cult::Containers::List + NamesList; + + typedef + Cult::Containers::Map + ListIteratorMap; + + typedef + Cult::Containers::Map + NamesMap; + + public: + typedef + Bits::PointerIterator + NamesIterator; + + typedef + Bits::PointerIterator + NamesConstIterator; + + typedef + Cult::Containers::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::ConstIterator 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 (); + } + + protected: + friend class Bits::Graph; + + Scope (Path const& file, UnsignedLong line, UnsignedLong column) + : Node (file, line, column) + { + } + + Scope () + { + } + + 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); + } + } + + //@@ Ideally should be protected but then NodeArg has no way to + // access it. Maybe when (if) I move NodeArg into Grpah I can + // resolve this. + // + public: + 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); + } + + protected: + using Nameable::add_edge_right; + + private: + NamesList names_; + ListIteratorMap iterator_map_; + NamesMap names_map_; + }; + + + // + // + class Belongs; + class Inherits; + class Arguments; + + class Type: public virtual Nameable + { + protected: + typedef + Cult::Containers::Vector + Classifies; + + typedef + Cult::Containers::Vector + Begets; + + typedef + Cult::Containers::Set + ArgumentsSet; + + public: + typedef + Bits::PointerIterator + ClassifiesIterator; + + ClassifiesIterator + classifies_begin () const + { + return classifies_.begin (); + } + + ClassifiesIterator + classifies_end () const + { + return classifies_.end (); + } + + // + // + Boolean + inherits_p () const + { + return inherits_ != 0; + } + + Inherits& + inherits () const + { + assert (inherits_ != 0); + return *inherits_; + } + + // + // + typedef + Bits::PointerIterator + BegetsIterator; + + BegetsIterator + begets_begin () const + { + return begets_.begin (); + } + + BegetsIterator + begets_end () const + { + return begets_.end (); + } + + // + // + typedef + Bits::PointerIterator + ArgumentsIterator; + + ArgumentsIterator + arguments_begin () const + { + return arguments_.begin (); + } + + ArgumentsIterator + arguments_end () const + { + return arguments_.end (); + } + + protected: + friend class Bits::Graph; + + 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; + + Boolean + typed_p () const + { + return belongs_ != 0; + } + + protected: + friend class Bits::Graph; + + 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_; + } + + protected: + friend class Bits::Graph; + + Belongs () + { + } + + 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_; + } + + protected: + friend class Bits::Graph; + + Inherits () + { + } + + 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 + { + protected: + friend class Bits::Graph; + + Extends () + { + } + }; + + class Restricts: public virtual Inherits + { + protected: + typedef + Cult::Containers::Map + Facets; + + public: + typedef + Facets::Iterator + FacetIterator; + + Boolean + facet_empty () + { + return facets_.empty (); + } + + FacetIterator + facet_begin () + { + return facets_.begin (); + } + + FacetIterator + facet_end () + { + return facets_.end (); + } + + FacetIterator + facet_find (WideString const& name) + { + return facets_.find (name); + } + + Void + facet_insert (String const& name, String const& value) + { + facets_[name] = value; + } + + protected: + friend class Bits::Graph; + + Restricts () + { + } + + 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__; + } + + protected: + friend class Bits::Graph; + + 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. + // + Boolean + global_p () const + { + return global_; + } + + Boolean + 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. + // + Boolean + default_p () const + { + return value_type_ != ValueType::none; + } + + Boolean + fixed_p () const + { + return value_type_ == ValueType::fixed; + } + + struct NoValue {}; + + WideString + value () const + { + if (value_type_ != ValueType::none) + return value_; + else + throw NoValue (); + } + + // + // + Void + default_ (WideString const& v) + { + value_ = v; + value_type_ = ValueType::default_; + } + + Void + fixed (WideString const& v) + { + value_ = v; + value_type_ = ValueType::fixed; + } + + protected: + friend class Bits::Graph; + + Member (Boolean global, Boolean 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: + Boolean global_; + Boolean qualified_; + BelongsToNamespace* belongs_to_namespace_; + + struct ValueType + { + enum Value + { + none, + default_, + fixed + }; + }; + + WideString value_; + ValueType::Value value_type_; + }; + + + // Parametric types. + // + + class Specialization: public virtual Type + { + typedef + Cult::Containers::Vector + Argumented; + + public: + typedef + Bits::PointerIterator + ArgumentedIterator; + + typedef + Bits::PointerIterator + 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]; + } + + protected: + friend class Bits::Graph; + + using Type::add_edge_right; + + Void + add_edge_right (Arguments& a) + { + argumented_.push_back (&a); + } + + Void + remove_edge_right (Arguments&); + + public: + Void + add_edge_right (Arguments& a, ArgumentedIterator const& pos) + { + argumented_.insert (pos.base (), &a); + } + + private: + Argumented argumented_; + }; + + + class Arguments: public virtual Edge + { + public: + Type& + type () const + { + return *type_; + } + + Specialization& + specialization () const + { + return *specialization_; + } + + protected: + friend class Bits::Graph; + + 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 + { + protected: + friend class Bits::Graph; + + AnyType (Path const& file, UnsignedLong line, UnsignedLong column) + : Node (file, line, column) + { + } + + AnyType () // For virtual inheritance. + { + } + }; + + + // + // + class AnySimpleType: public virtual Type + { + protected: + friend class Bits::Graph; + + AnySimpleType (Path const& file, UnsignedLong line, UnsignedLong column) + : Node (file, line, column) + { + } + + 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..adcf71e --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/enumeration.cxx @@ -0,0 +1,67 @@ +// file : xsd-frontend/semantic-graph/enumeration.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + namespace + { + // Enumeration + // + struct EnumerationInit + { + EnumerationInit () + { + TypeInfo ti (typeid (Enumeration)); + ti.add_base (Access::public_, true, typeid (Complex)); + RTTI::insert (ti); + } + + } enumeration_init_; + + + // Enumerator + // + struct EnumeratorInit + { + EnumeratorInit () + { + TypeInfo ti (typeid (Enumerator)); + ti.add_base (Access::public_, true, typeid (Instance)); + RTTI::insert (ti); + } + + } enumerator_init_; + } + + + // Enumeration + // + + Enumeration:: + Enumeration (Path const& file, UnsignedLong line, UnsignedLong column) + : Node (file, line, column) + { + } + + + // Enumerator + // + + Enumerator:: + Enumerator (Path const& file, UnsignedLong line, UnsignedLong column) + : Node (file, line, column) + { + } + } +} 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..a21e8f3 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/enumeration.hxx @@ -0,0 +1,35 @@ +// file : xsd-frontend/semantic-graph/enumeration.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 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 + { + protected: + friend class Bits::Graph; + + Enumeration (Path const& file, UnsignedLong line, UnsignedLong column); + }; + + + class Enumerator: public virtual Instance + { + protected: + friend class Bits::Graph; + + Enumerator (Path const& file, UnsignedLong line, UnsignedLong column); + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_ENUMERATION_HXX 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..cc1316c --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.cxx.m4 @@ -0,0 +1,216 @@ +divert(-1) + +# file : xsd-frontend/semantic-graph/fundamental.cxx.m4 +# author : Boris Kolpackov +# copyright : Copyright (c) 2005-2010 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 () + { + TypeInfo ti (typeid ($1)); + ti.add_base (Access::public_, true, typeid (Type)); + RTTI::insert (ti); + } + + } $2_init_; + } + + $1:: + $1 (Path const& file, + SemanticGraph::UnsignedLong line, + SemanticGraph::UnsignedLong column) + : Node (file, line, column) + { + }') + +divert(0)dnl +dnl +dnl +dnl +// file : xsd-frontend/semantic-graph/fundamental.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Note, that this file is automatically generated! +// + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace Fundamental + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + + // Type + // + namespace + { + struct TypeInit + { + TypeInit () + { + TypeInfo ti (typeid (Type)); + ti.add_base (Access::public_, true, typeid (SemanticGraph::Type)); + RTTI::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 () + { + TypeInfo ti (typeid (IdRef)); + ti.add_base (Access::public_, true, typeid (Type)); + ti.add_base (Access::public_, true, typeid (Specialization)); + RTTI::insert (ti); + } + + } id_ref_init_; + } + + IdRef:: + IdRef (Path const& file, + SemanticGraph::UnsignedLong line, + SemanticGraph::UnsignedLong column) + : Node (file, line, column) + { + } + + + // IdRefs + // + namespace + { + struct IdRefsInit + { + IdRefsInit () + { + TypeInfo ti (typeid (IdRefs)); + ti.add_base (Access::public_, true, typeid (Type)); + ti.add_base (Access::public_, true, typeid (Specialization)); + RTTI::insert (ti); + } + + } id_refs_init_; + } + + IdRefs:: + IdRefs (Path const& file, + SemanticGraph::UnsignedLong line, + SemanticGraph::UnsignedLong 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.m4 b/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.hxx.m4 new file mode 100644 index 0000000..f5a88a9 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.hxx.m4 @@ -0,0 +1,165 @@ +divert(-1) + +# file : xsd-frontend/semantic-graph/fundamental.hxx.m4 +# author : Boris Kolpackov +# copyright : Copyright (c) 2005-2010 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 + { + protected: + friend class Bits::Graph; + + $1 (Path const& file, + SemanticGraph::UnsignedLong line, + SemanticGraph::UnsignedLong column); + };') +divert(0)dnl +dnl +dnl +dnl +// file : xsd-frontend/semantic-graph/fundamental.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 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: + friend class Bits::Graph; + + 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 + { + protected: + friend class Bits::Graph; + + IdRef (Path const& file, + SemanticGraph::UnsignedLong line, + SemanticGraph::UnsignedLong column); + }; + + + // + // + class IdRefs: public virtual Type, + public virtual Specialization + { + protected: + friend class Bits::Graph; + + IdRefs (Path const& file, + SemanticGraph::UnsignedLong line, + SemanticGraph::UnsignedLong 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..735b35d --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/fundamental.m4 @@ -0,0 +1,18 @@ +# file : xsd-frontend/semantic-graph/fundamental.m4 +# author : Boris Kolpackov +# copyright : Copyright (c) 2005-2010 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..3184041 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/list.cxx @@ -0,0 +1,37 @@ +// file : xsd-frontend/semantic-graph/list.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + namespace + { + struct ListInit + { + ListInit () + { + TypeInfo ti (typeid (List)); + ti.add_base (Access::public_, true, typeid (Specialization)); + RTTI::insert (ti); + } + + } list_init_; + } + + List:: + List (Path const& file, UnsignedLong line, UnsignedLong column) + : Node (file, line, column) + { + } + } +} 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..3ba0c02 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/list.hxx @@ -0,0 +1,25 @@ +// file : xsd-frontend/semantic-graph/list.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 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 + { + protected: + friend class Bits::Graph; + + List (Path const& file, UnsignedLong line, UnsignedLong 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..789b5d8 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/namespace.cxx @@ -0,0 +1,37 @@ +// file : xsd-frontend/semantic-graph/namespace.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + namespace + { + struct NamespaceInit + { + NamespaceInit () + { + TypeInfo ti (typeid (Namespace)); + ti.add_base (Access::public_, true, typeid (Scope)); + RTTI::insert (ti); + } + + } namespace_init_; + } + + Namespace:: + Namespace (Path const& file, UnsignedLong line, UnsignedLong column) + : Node (file, line, column) + { + } + } +} 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..25bd1c0 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/namespace.hxx @@ -0,0 +1,32 @@ +// file : xsd-frontend/semantic-graph/namespace.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 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 + { + protected: + friend class Bits::Graph; + + Namespace (Path const& file, UnsignedLong line, UnsignedLong 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..f8c93de --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/particle.cxx @@ -0,0 +1,61 @@ +// file : xsd-frontend/semantic-graph/particle.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + // ContainsParticle + // + namespace + { + struct ContainsParticleInit + { + ContainsParticleInit () + { + TypeInfo ti (typeid (ContainsParticle)); + ti.add_base (Access::public_, true, typeid (Edge)); + RTTI::insert (ti); + } + + } contains_particle_init_; + } + + ContainsParticle:: + ContainsParticle (UnsignedLong min, UnsignedLong max) + : particle_ (0), compositor_ (0), min_ (min), max_ (max) + { + } + + // Particle + // + namespace + { + struct ParticleInit + { + ParticleInit () + { + TypeInfo ti (typeid (Particle)); + ti.add_base (Access::public_, true, typeid (Node)); + RTTI::insert (ti); + } + + } particle_init_; + } + + Particle:: + Particle () + : contained_particle_ (0) + { + } + } +} 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..df48de4 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/particle.hxx @@ -0,0 +1,145 @@ +// file : xsd-frontend/semantic-graph/particle.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2010 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: + UnsignedLong + min () const + { + return min_; + } + + UnsignedLong + max () const + { + return max_; + } + + protected: + friend class Bits::Graph; + + ContainsParticle (UnsignedLong min, UnsignedLong 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_; + UnsignedLong min_, max_; + }; + + // + // + class Particle: public virtual Node + { + public: + Boolean + contained_particle_p () + { + return contained_particle_ != 0; + } + + ContainsParticle& + contained_particle () + { + assert (contained_particle_ != 0); + return *contained_particle_; + } + + public: + UnsignedLong + min () const + { + assert (contained_particle_ != 0); + return contained_particle_->min (); + } + + UnsignedLong + max () const + { + assert (contained_particle_ != 0); + return contained_particle_->max (); + } + + protected: + friend class Bits::Graph; + + 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..f812797 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/schema.cxx @@ -0,0 +1,139 @@ +// file : xsd-frontend/semantic-graph/schema.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + namespace + { + // Uses + // + struct UsesInit + { + UsesInit () + { + TypeInfo ti (typeid (Uses)); + ti.add_base (Access::public_, true, typeid (Edge)); + RTTI::insert (ti); + } + + } uses_init_; + + + // Implies + // + struct ImpliesInit + { + ImpliesInit () + { + TypeInfo ti (typeid (Implies)); + ti.add_base (Access::public_, true, typeid (Uses)); + RTTI::insert (ti); + } + + } implies_init_; + + + // Sources + // + struct SourcesInit + { + SourcesInit () + { + TypeInfo ti (typeid (Sources)); + ti.add_base (Access::public_, true, typeid (Uses)); + RTTI::insert (ti); + } + + } sources_init_; + + + // Includes + // + struct IncludesInit + { + IncludesInit () + { + TypeInfo ti (typeid (Includes)); + ti.add_base (Access::public_, true, typeid (Uses)); + RTTI::insert (ti); + } + + } includes_init_; + + + // Imports + // + struct ImportsInit + { + ImportsInit () + { + TypeInfo ti (typeid (Imports)); + ti.add_base (Access::public_, true, typeid (Uses)); + RTTI::insert (ti); + } + + } imports_init_; + + + // Schema + // + struct SchemaInit + { + SchemaInit () + { + TypeInfo ti (typeid (Schema)); + ti.add_base (Access::public_, true, typeid (Scope)); + RTTI::insert (ti); + } + + } schema_init_; + } + + + // 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); + } + } + } +} 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..10d2f75 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/schema.hxx @@ -0,0 +1,281 @@ +// file : xsd-frontend/semantic-graph/schema.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 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 + +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_; + } + + protected: + friend class Bits::Graph; + + 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 + { + protected: + friend class Bits::Graph; + + Implies (Path const& path) + : Uses (path) + { + } + }; + + + // + // + class Sources: public virtual Uses + { + protected: + friend class Bits::Graph; + + Sources (Path const& path) + : Uses (path) + { + } + }; + + + // + // + class Includes: public virtual Uses + { + protected: + friend class Bits::Graph; + + Includes (Path const& path) + : Uses (path) + { + } + }; + + + // + // + class Imports: public virtual Uses + { + protected: + friend class Bits::Graph; + + Imports (Path const& path) + : Uses (path) + { + } + }; + + + // + // + class Schema: public virtual Scope, + private Bits::Graph, + public NonCopyable + { + typedef + Cult::Containers::Vector + UsesList; + + typedef + Cult::Containers::Vector + UsedList; + + public: + Schema (Path const& file, UnsignedLong line, UnsignedLong column) + : SemanticGraph::Node (file, line, column) + { + } + + public: + typedef + Bits::PointerIterator + UsesIterator; + + UsesIterator + uses_begin () const + { + return uses_.begin (); + } + + UsesIterator + uses_end () const + { + return uses_.end (); + } + + typedef + Bits::PointerIterator + UsedIterator; + + UsedIterator + used_begin () const + { + return used_.begin (); + } + + UsedIterator + used_end () const + { + return used_.end (); + } + + Boolean + used_p () const + { + return used_begin () != used_end (); + } + + virtual NamesIteratorPair + find (Name const& name) const; + + public: + using Bits::Graph::new_edge; + using Bits::Graph::reset_left_node; + using Bits::Graph::reset_right_node; + using Bits::Graph::add_edge_left; + using Bits::Graph::add_edge_right; + using Bits::Graph::delete_node; + using Bits::Graph::delete_edge; + + template + T& + new_node (Path const& file, UnsignedLong line, UnsignedLong column) + { + return graph ().new_node (file, line, column); + } + + template + T& + new_node (Path const& file, UnsignedLong line, UnsignedLong column, + A0 const& a0) + { + return graph ().new_node (file, line, column, a0); + } + + template + T& + new_node (Path const& file, UnsignedLong line, UnsignedLong column, + A0 const& a0, A1 const& a1) + { + return graph ().new_node (file, line, column, a0, a1); + } + + template + T& + new_node (Path const& file, UnsignedLong line, UnsignedLong 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, UnsignedLong line, UnsignedLong column, + A0 const& a0, A1 const& a1, A2 const& a2, A3 const& a3) + { + return graph ().new_node (file, line, column, a0, a1, a2, a3); + } + + protected: + //@@ gcc bug #21146 + // + friend class Bits::Graph; + + 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: + Bits::Graph& + graph () + { + return *this; + } + + private: + UsesList uses_; + UsedList used_; + + private: + typedef Cult::Containers::Set SchemaSet; + + Void + find_ (Name const& name, NamesList&, SchemaSet&) const; + + 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..b4b4cf0 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/union.cxx @@ -0,0 +1,37 @@ +// file : xsd-frontend/semantic-graph/union.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + namespace RTTI = Cult::RTTI; + + using RTTI::Access; + using RTTI::TypeInfo; + + namespace + { + struct UnionInit + { + UnionInit () + { + TypeInfo ti (typeid (Union)); + ti.add_base (Access::public_, true, typeid (Specialization)); + RTTI::insert (ti); + } + + } union_init_; + } + + Union:: + Union (Path const& file, UnsignedLong line, UnsignedLong column) + : Node (file, line, column) + { + } + } +} 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..62df730 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/union.hxx @@ -0,0 +1,25 @@ +// file : xsd-frontend/semantic-graph/union.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 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 + { + protected: + friend class Bits::Graph; + + Union (Path const& file, UnsignedLong line, UnsignedLong column); + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_UNION_HXX -- cgit v1.2.3