diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 15:25:44 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 15:25:44 +0200 |
commit | 8286ac511144e4f17d34eac9affb97e50646344a (patch) | |
tree | f1af7320d7b6be6be059216d0ad08ac7b4f73fd0 /libxsd-frontend/xsd-frontend/traversal/elements.hxx | |
parent | a15cf65c44d5c224169c32ef5495b68c758134b7 (diff) |
Imported Upstream version 4.0.0upstream/4.0.0
Diffstat (limited to 'libxsd-frontend/xsd-frontend/traversal/elements.hxx')
-rw-r--r-- | libxsd-frontend/xsd-frontend/traversal/elements.hxx | 221 |
1 files changed, 76 insertions, 145 deletions
diff --git a/libxsd-frontend/xsd-frontend/traversal/elements.hxx b/libxsd-frontend/xsd-frontend/traversal/elements.hxx index c405a1b..bd1dd70 100644 --- a/libxsd-frontend/xsd-frontend/traversal/elements.hxx +++ b/libxsd-frontend/xsd-frontend/traversal/elements.hxx @@ -1,165 +1,97 @@ // file : xsd-frontend/traversal/elements.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_FRONTEND_TRAVERSAL_ELEMENTS_HXX #define XSD_FRONTEND_TRAVERSAL_ELEMENTS_HXX -#include <cult/types.hxx> - -#include <frontend-elements/traversal.hxx> +#include <cutl/compiler/traversal.hxx> +#include <xsd-frontend/types.hxx> #include <xsd-frontend/semantic-graph/elements.hxx> namespace XSDFrontend { namespace Traversal { - using namespace Cult::Types; - - namespace Bits - { - using FrontendElements::Traversal::TraverserBase; - using FrontendElements::Traversal::Traverser; - - using FrontendElements::Traversal::DispatcherBase; - using FrontendElements::Traversal::Dispatcher; - - } - - typedef Bits::DispatcherBase<SemanticGraph::Node> NodeDispatcherBase; - typedef Bits::DispatcherBase<SemanticGraph::Edge> EdgeDispatcherBase; + using namespace cutl; + typedef compiler::dispatcher<SemanticGraph::Node> NodeDispatcher; + typedef compiler::dispatcher<SemanticGraph::Edge> EdgeDispatcher; // // - struct NodeBase : virtual Bits::Dispatcher<SemanticGraph::Node>, - virtual Bits::Dispatcher<SemanticGraph::Edge> + struct NodeBase: NodeDispatcher, EdgeDispatcher { - Void - edge_traverser (EdgeDispatcherBase& d) + void + edge_traverser (EdgeDispatcher& d) { - Bits::Dispatcher<SemanticGraph::Edge>::traverser (d); + EdgeDispatcher::traverser (d); } - EdgeDispatcherBase& + EdgeDispatcher& edge_traverser () { return *this; } - public: - using Bits::Dispatcher<SemanticGraph::Node>::dispatch; - using Bits::Dispatcher<SemanticGraph::Edge>::dispatch; - - using Bits::Dispatcher<SemanticGraph::Node>::map; - - using Bits::Dispatcher<SemanticGraph::Edge>::iterate_and_dispatch; - }; - - - // - // - template <typename T> - struct Node : Bits::TraverserBase<SemanticGraph::Node>, virtual NodeBase - { - typedef - T - Type; - - Node () - { - map (typeid (Type), *this); - } - - virtual Void - traverse (Type&) = 0; + using NodeDispatcher::dispatch; + using EdgeDispatcher::dispatch; - virtual Void - trampoline (SemanticGraph::Node& i) - { - traverse (dynamic_cast<Type&> (i)); - } - - virtual Void - trampoline (SemanticGraph::Node const&) - { - abort (); - } + using EdgeDispatcher::iterate_and_dispatch; }; - - // - // - struct EdgeBase : virtual Bits::Dispatcher<SemanticGraph::Edge>, - virtual Bits::Dispatcher<SemanticGraph::Node> + struct EdgeBase: EdgeDispatcher, NodeDispatcher { - Void - node_traverser (NodeDispatcherBase& d) + void + node_traverser (NodeDispatcher& d) { - Bits::Dispatcher<SemanticGraph::Node>::traverser (d); + NodeDispatcher::traverser (d); } - NodeDispatcherBase& + NodeDispatcher& node_traverser () { return *this; } - public: - using Bits::Dispatcher<SemanticGraph::Edge>::dispatch; - using Bits::Dispatcher<SemanticGraph::Node>::dispatch; + using EdgeDispatcher::dispatch; + using NodeDispatcher::dispatch; - using Bits::Dispatcher<SemanticGraph::Edge>::map; - - using Bits::Dispatcher<SemanticGraph::Node>::iterate_and_dispatch; - }; - - template <typename T> - struct Edge : Bits::TraverserBase<SemanticGraph::Edge>, virtual EdgeBase - { - typedef - T - Type; - - Edge () - { - map (typeid (Type), *this); - } - - virtual Void - traverse (Type&) = 0; - - virtual Void - trampoline (SemanticGraph::Edge& i) - { - traverse (dynamic_cast<Type&> (i)); - } - - virtual Void - trampoline (SemanticGraph::Edge const&) - { - abort (); - } + using NodeDispatcher::iterate_and_dispatch; }; - inline - EdgeBase& + inline EdgeBase& operator>> (NodeBase& n, EdgeBase& e) { n.edge_traverser (e); return e; } - inline - NodeBase& + inline NodeBase& operator>> (EdgeBase& e, NodeBase& n) { e.node_traverser (n); return n; } + // + // + template <typename T> + struct Node: compiler::traverser_impl<T, SemanticGraph::Node>, + virtual NodeBase + { + typedef T Type; + }; + + template <typename T> + struct Edge: compiler::traverser_impl<T, SemanticGraph::Edge>, + virtual EdgeBase + { + typedef T Type; + }; + + // // Edges // @@ -176,7 +108,7 @@ namespace XSDFrontend node_traverser (n); } - virtual Void + virtual void traverse (Type& e) { dispatch (e.named ()); @@ -197,18 +129,17 @@ namespace XSDFrontend node_traverser (n); } - virtual Void + virtual void traverse (Type& e) { dispatch (e.type ()); } }; - + // // Nodes // - // // struct Nameable : Node<SemanticGraph::Nameable> @@ -222,20 +153,20 @@ namespace XSDFrontend struct ScopeTemplate : Node<T> { public: - virtual Void + virtual void traverse (T& s) { names (s); } template<typename X> - Void + void names (T& s, - EdgeDispatcherBase& d, - Void (X::*pre_) (T&) = (Void (ScopeTemplate<T>::*)(T&)) (0), - Void (X::*post_) (T&) = (Void (ScopeTemplate<T>::*)(T&)) (0), - Void (X::*none_) (T&) = (Void (ScopeTemplate<T>::*)(T&)) (0), - Void (X::*next_) (T&) = (Void (ScopeTemplate<T>::*)(T&)) (0)) + EdgeDispatcher& d, + void (X::*pre_) (T&) = (void (ScopeTemplate<T>::*)(T&)) (0), + void (X::*post_) (T&) = (void (ScopeTemplate<T>::*)(T&)) (0), + void (X::*none_) (T&) = (void (ScopeTemplate<T>::*)(T&)) (0), + void (X::*next_) (T&) = (void (ScopeTemplate<T>::*)(T&)) (0)) { X* this_ (dynamic_cast<X*> (this)); @@ -266,13 +197,13 @@ namespace XSDFrontend } } - virtual Void - names (T& s, EdgeDispatcherBase& d) + virtual void + names (T& s, EdgeDispatcher& d) { names<ScopeTemplate<T> > (s, d); } - virtual Void + virtual void names (T& s) { names (s, @@ -283,22 +214,22 @@ namespace XSDFrontend &ScopeTemplate<T>::names_next); } - virtual Void + virtual void names_pre (T&) { } - virtual Void + virtual void names_next (T&) { } - virtual Void + virtual void names_post (T&) { } - virtual Void + virtual void names_none (T&) { } @@ -316,7 +247,7 @@ namespace XSDFrontend // struct Type : Node<SemanticGraph::Type> { - virtual Void + virtual void traverse (SemanticGraph::Type&) = 0; }; @@ -325,19 +256,19 @@ namespace XSDFrontend // struct Instance : Node<SemanticGraph::Instance> { - virtual Void + virtual void traverse (Type&); - virtual Void + virtual void pre (Type&); - virtual Void - belongs (Type&, EdgeDispatcherBase&); + virtual void + belongs (Type&, EdgeDispatcher&); - virtual Void + virtual void belongs (Type&); - virtual Void + virtual void post (Type&); }; @@ -346,19 +277,19 @@ namespace XSDFrontend // struct Member : Node<SemanticGraph::Member> { - virtual Void + virtual void traverse (Type&); - virtual Void + virtual void pre (Type&); - virtual Void - belongs (Type&, EdgeDispatcherBase&); + virtual void + belongs (Type&, EdgeDispatcher&); - virtual Void + virtual void belongs (Type&); - virtual Void + virtual void post (Type&); }; @@ -376,7 +307,7 @@ namespace XSDFrontend node_traverser (n); } - virtual Void + virtual void traverse (Type& e) { dispatch (e.base ()); @@ -397,7 +328,7 @@ namespace XSDFrontend node_traverser (n); } - virtual Void + virtual void traverse (Type& e) { dispatch (e.base ()); @@ -418,7 +349,7 @@ namespace XSDFrontend node_traverser (n); } - virtual Void + virtual void traverse (Type& e) { dispatch (e.base ()); @@ -439,7 +370,7 @@ namespace XSDFrontend node_traverser (n); } - virtual Void + virtual void traverse (Type& a) { dispatch (a.type ()); @@ -452,7 +383,7 @@ namespace XSDFrontend // struct Contains : Edge<SemanticGraph::Contains> { - virtual Void + virtual void traverse (Type& e) { dispatch (e.element ()); |