// file : Test/IDL2/SemanticGraph/HandBuilt/Builder.cpp // author : Boris Kolpackov // cvs-id : $Id$ #include #include "Builder.hpp" using namespace CCF::IDL2::SemanticGraph; //@@ tmp using std::cerr; using std::endl; TranslationUnit* Builder:: build () { /* 0 1 #include "../foo/quote.idl" 2 #include 3 4 module M 5 { 6 7 interface I; 8 9 typedef I J; 10 11 interface I 12 { 13 void f (in long id, out string name); 14 15 attribute long a; 16 }; 17 18 interface Q : J {}; 19 20 typeid I "Foo"; 21 typeprefix M "Bar"; 22 23 struct S 24 { 25 long member; 26 }; 27 28 typedef sequence LongSeq; 29 30 }; 31 32 */ //@@ names can be spcified without explicit construction. // TranslationUnit& tu (*(new TranslationUnit)); // 0: Implied translation region with fundamental types. // // TranslationRegion& fundamental (tu.new_node ()); tu.new_edge (tu, fundamental, ".fundamental"); Root& fundamental_root (tu.new_node ()); tu.new_edge (fundamental, fundamental_root); Void& void_ (tu.new_node ()); tu.new_edge (fundamental_root, void_, SimpleName ("void")); Long& long_ (tu.new_node ()); tu.new_edge (fundamental_root, long_, SimpleName ("long")); String& string_ (tu.new_node ()); tu.new_edge (fundamental_root, string_, SimpleName ("string")); // Principal translation region. // TranslationRegion& principal (tu.new_node ()); tu.new_edge (tu, principal); // 1: Quote included translation region. // TranslationRegion& quote_included (tu.new_node ()); tu.new_edge (principal, quote_included, "../foo/quote.idl"); // 2: Bracket included translation region. // TranslationRegion& braket_included (tu.new_node ()); tu.new_edge (principal, braket_included, "ui/bracket.idl"); Root& root (tu.new_node ()); tu.new_edge (principal, root); // 4-5: // Module& m (tu.new_node ()); tu.new_edge (root, m, SimpleName ("M")); // 7-11: // UnconstrainedInterface& i (tu.new_node ()); tu.new_edge (m, i, SimpleName ("I")); tu.new_edge (m, i, SimpleName ("J")); tu.new_edge (m, i, SimpleName ("I")); // 13: // TwoWayOperation& f (tu.new_node ()); tu.new_edge (f, void_); Parameter& id (tu.new_node ("id")); tu.new_edge (id, long_); tu.new_edge (f, id); Parameter& name (tu.new_node ("name")); tu.new_edge (name, string_); tu.new_edge (f, name); tu.new_edge (i, f, SimpleName ("f")); // 15: // Attribute& a (tu.new_node ()); tu.new_edge (a, long_); tu.new_edge (i, a, SimpleName ("a")); // 18: // UnconstrainedInterface& q (tu.new_node ()); tu.new_edge (q, i); tu.new_edge (m, q, SimpleName ("Q")); // 20: // TypeId& ti (tu.new_node ( ScopedName ("::M::I"), StringLiteral ("Foo"))); tu.new_edge (m, ti, SimpleName ("typeid")); // 21: // TypePrefix& tp (tu.new_node ( ScopedName ("::M"), StringLiteral ("Bar"))); tu.new_edge (m, tp, SimpleName ("typeprefix")); // 23-24: // Struct& s (tu.new_node ()); tu.new_edge (m, s, SimpleName ("S")); // 25: // Member& member (tu.new_node ()); tu.new_edge (member, long_); tu.new_edge (s, member, SimpleName ("member")); // 28: // UnboundedSequence& long_seq (tu.new_node ()); tu.new_edge (long_seq, long_); tu.new_edge (m, long_seq, SimpleName ("LongSeq")); return &tu; }