summaryrefslogtreecommitdiff
path: root/CIAO/CCF/CCF/IDL2/SemanticGraph/Union.cpp
blob: 4fccb9a0ebcb13a8acac695f19a5709fd7efd793 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// file      : CCF/IDL2/SemanticGraph/Union.cpp
// author    : Boris Kolpackov <boris@dre.vanderbilt.edu>
// cvs-id    : $Id$

#include "CCF/IDL2/SemanticGraph/Union.hpp"

namespace CCF
{
  namespace IDL2
  {
    namespace SemanticGraph
    {
      using Introspection::TypeInfo;
      using Introspection::Access;


      // Selects
      //
      //
      namespace
      {
        TypeInfo
        selects_init_ ()
        {
          TypeInfo ti (typeid (Selects));
          ti.add_base (Access::PUBLIC, true, Edge::static_type_info ());
          return ti;
        }

        TypeInfo selects_ (selects_init_ ());
      }

      TypeInfo const& Selects::
      static_type_info () { return selects_; }


      // UnionMember
      //
      //
      namespace
      {
        TypeInfo
        union_member_init_ ()
        {
          TypeInfo ti (typeid (UnionMember));
          ti.add_base (Access::PUBLIC, true, Member::static_type_info ());
          return ti;
        }

        TypeInfo union_member_ (union_member_init_ ());
      }

      TypeInfo const& UnionMember::
      static_type_info () { return union_member_; }


      // Selector
      //
      //
      namespace
      {
        TypeInfo
        selector_init_ ()
        {
          TypeInfo ti (typeid (Selector));
          ti.add_base (Access::PUBLIC, true, Node::static_type_info ());
          return ti;
        }

        TypeInfo selector_ (selector_init_ ());
      }

      TypeInfo const& Selector::
      static_type_info () { return selector_; }

      Selector::
      ~Selector ()
      {
      }

      // DefaultSelector
      //
      //
      namespace
      {
        TypeInfo
        default_selector_init_ ()
        {
          TypeInfo ti (typeid (DefaultSelector));
          ti.add_base (Access::PUBLIC, true, Selector::static_type_info ());
          return ti;
        }

        TypeInfo default_selector_ (default_selector_init_ ());
      }

      TypeInfo const& DefaultSelector::
      static_type_info () { return default_selector_; }


      // ValueSelector
      //
      //
      namespace
      {
        TypeInfo
        value_selector_init_ ()
        {
          TypeInfo ti (typeid (ValueSelector));
          ti.add_base (Access::PUBLIC, true, Selector::static_type_info ());
          ti.add_base (Access::PUBLIC, true, Instance::static_type_info ());
          return ti;
        }

        TypeInfo value_selector_ (value_selector_init_ ());
      }

      TypeInfo const& ValueSelector::
      static_type_info () { return value_selector_; }

      // Union
      //
      //
      namespace
      {
        TypeInfo
        union_init_ ()
        {
          TypeInfo ti (typeid (Union));

          ti.add_base (
            Access::PUBLIC, true, Specialization::static_type_info ());

          ti.add_base (Access::PUBLIC, true, Scope::static_type_info ());
          return ti;
        }

        TypeInfo union_ (union_init_ ());
      }

      TypeInfo const& Union::
      static_type_info () { return union_; }

      bool Union::
      complete () const
      {
        if (defined ())
        {
          CompilerElements::Context& ctx (
            const_cast<CompilerElements::Context&> (context ()));

          if (ctx.count ("union-complete-test"))
            return true;

          ctx.set ("union-complete-test", true);
          bool c (true);

          for (Scope::NamesIterator i (names_begin ());
               c && i != names_end ();
               ++i)
          {
            Member const& m (dynamic_cast<Member&> ((*i)->named ()));
            Type const& t (m.belongs ().type ());

            if (!t.complete ())
              c = false;
          }

          ctx.remove ("union-complete-test");
          return c;
        }

        return false;
      }
    }
  }
}