Merge pull request #1815 from sonndinh/get_signal_info
[ACE_TAO.git] / TAO / TAO_IDL / include / ast_union.h
blob4aada429a1b6423a00b64abdf40c11d461e880f4
1 // This may look like C, but it's really -*- C++ -*-
2 /*
4 COPYRIGHT
6 Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United
7 States of America. All Rights Reserved.
9 This product is protected by copyright and distributed under the following
10 license restricting its use.
12 The Interface Definition Language Compiler Front End (CFE) is made
13 available for your use provided that you include this license and copyright
14 notice on all media and documentation and the software program in which
15 this product is incorporated in whole or part. You may copy and extend
16 functionality (but may not remove functionality) of the Interface
17 Definition Language CFE without charge, but you are not authorized to
18 license or distribute it to anyone else except as part of a product or
19 program developed by you or with the express written consent of Sun
20 Microsystems, Inc. ("Sun").
22 The names of Sun Microsystems, Inc. and any of its subsidiaries or
23 affiliates may not be used in advertising or publicity pertaining to
24 distribution of Interface Definition Language CFE as permitted herein.
26 This license is effective until terminated by Sun for failure to comply
27 with this license. Upon termination, you shall destroy or return all code
28 and documentation for the Interface Definition Language CFE.
30 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF
31 ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS
32 FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF
33 DEALING, USAGE OR TRADE PRACTICE.
35 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT
36 ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES
37 TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.
39 SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
40 RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
41 INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF.
43 IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR
44 ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
45 DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
47 Use, duplication, or disclosure by the government is subject to
48 restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
49 Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR
50 52.227-19.
52 Sun, Sun Microsystems and the Sun logo are trademarks or registered
53 trademarks of Sun Microsystems, Inc.
55 SunSoft, Inc.
56 2550 Garcia Avenue
57 Mountain View, California 94043
59 NOTE:
61 SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
62 trademarks or registered trademarks of Sun Microsystems, Inc.
66 #ifndef _AST_UNION_AST_UNION_HH
67 #define _AST_UNION_AST_UNION_HH
69 #include "ast_structure.h"
71 // NOTE: add (AST_ConcreteType *) is defined here because a union
72 // can contain locally defined types in addition to fields.
74 // NOTE: add (AST_EnumValue *) is defined here because enums can
75 // be defined manifest locally; the constants defined in these
76 // enums are inserted in the enclosing scope. It is unlikely that
77 // a BE writer will need to overload this function in AST_Union.
79 class TAO_IDL_FE_Export AST_Union : public virtual AST_Structure
81 public:
82 AST_Union (AST_ConcreteType *disc_type,
83 UTL_ScopedName *n,
84 bool local,
85 bool abstract);
87 virtual ~AST_Union (void);
89 // This also calls the base class version.
90 virtual void redefine (AST_Structure *from);
92 virtual bool in_recursion (ACE_Unbounded_Queue<AST_Type *> &list);
93 // Are we or the parameter node involved in some kind of recursion?
95 // Data Accessors.
97 AST_ConcreteType *disc_type (void);
99 AST_Expression::ExprType udisc_type (void);
101 // Narrowing.
102 DEF_NARROW_FROM_DECL(AST_Union);
103 DEF_NARROW_FROM_SCOPE(AST_Union);
105 struct DefaultValue
107 union PermittedTypes
109 ACE_CDR::Char char_val;
110 ACE_CDR::WChar wchar_val;
111 ACE_CDR::Boolean bool_val;
112 ACE_CDR::Short short_val;
113 ACE_CDR::UShort ushort_val;
114 ACE_CDR::Long long_val;
115 ACE_CDR::ULong ulong_val;
116 ACE_CDR::ULong enum_val;
117 ACE_CDR::LongLong longlong_val;
118 ACE_CDR::ULongLong ulonglong_val;
119 } u;
120 long computed_;
121 // computed == -1 => error condition
122 // == 0 => does not exist because all cases have been covered
123 // == 1 => already computed
124 // == -2 => initial value
127 int default_value (DefaultValue &);
128 // Get the default value.
130 virtual int default_index (void);
131 // Return the default index used.
133 // AST Dumping.
134 virtual void dump (ACE_OSTREAM_TYPE &);
136 // Visiting.
137 virtual int ast_accept (ast_visitor *visitor);
139 static AST_Decl::NodeType const NT;
142 * Get and Set Annotations on the discriminator
144 ///{
145 AST_Annotation_Appls &disc_annotations ();
146 void disc_annotations (const AST_Annotation_Appls &annotations);
147 ///}
149 protected:
150 virtual int compute_size_type (void);
151 // Compute the size type if it is unknown.
153 virtual AST_UnionBranch *fe_add_union_branch (AST_UnionBranch *b);
154 // Moved out of private section so it can be called from subclass.
156 private:
157 // Data.
159 AST_ConcreteType *pd_disc_type;
160 // Discriminator type.
162 AST_Expression::ExprType pd_udisc_type;
163 // Its expression type.
164 // Convention: udisc_type == EV_enum denotes an enum value.
166 // Operations.
168 // Look up a branch by node pointer.
169 AST_UnionBranch *lookup_branch (AST_UnionBranch *branch);
171 // Look up the branch with the "default" label.
172 AST_UnionBranch *lookup_default (void);
174 // Look up a branch given a branch with a label. This is used to
175 // check for duplicate labels.
176 AST_UnionBranch *lookup_label (AST_UnionBranch *b);
178 // Look up a union branch given an enumerator. This is used to
179 // check for duplicate enum labels.
180 AST_UnionBranch *lookup_enum (AST_UnionBranch *b);
182 friend int tao_yyparse (void);
183 friend class ast_visitor_tmpl_module_inst;
185 // Scope Management Protocol.
187 virtual AST_Union *fe_add_union (AST_Union *u);
189 virtual AST_Structure *fe_add_structure (AST_Structure *s);
191 virtual AST_Enum *fe_add_enum (AST_Enum *e);
193 virtual AST_EnumVal *fe_add_enum_val (AST_EnumVal *v);
195 virtual int compute_default_value (void);
196 // Compute the default value (if any).
198 int compute_default_index (void);
199 // Count the default index.
201 DefaultValue default_value_;
202 // Default value (if any).
204 int default_index_;
205 // Default label index (zero based indexing).
208 * Annotations on the discriminator
210 AST_Annotation_Appls disc_annotations_;
213 #endif // _AST_UNION_AST_UNION_HH