1 // This may look like C, but it's really -*- C++ -*-
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
52 Sun, Sun Microsystems and the Sun logo are trademarks or registered
53 trademarks of Sun Microsystems, Inc.
57 Mountain View, California 94043
61 SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
62 trademarks or registered trademarks of Sun Microsystems, Inc.
66 #ifndef _AST_STRUCTURE_AST_STRUCTURE_HH
67 #define _AST_STRUCTURE_AST_STRUCTURE_HH
69 // Representation of structure:
71 // NOTE: add (AST_ConcreteType *) is defined here because a structure
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_Structure.
79 #include "ast_concrete_type.h"
80 #include "utl_scope.h"
81 #include "ace/Unbounded_Queue.h"
83 class TAO_IDL_FE_Export AST_Structure
84 : public virtual AST_ConcreteType
,
85 public virtual UTL_Scope
88 AST_Structure (UTL_ScopedName
*n
,
92 AST_Structure (AST_Decl::NodeType nt
,
97 virtual ~AST_Structure (void);
99 // This serves for both structs and unions.
100 static void fwd_redefinition_helper (AST_Structure
*&i
,
103 // Overridden for unions.
104 virtual void redefine (AST_Structure
*from
);
108 DEF_NARROW_FROM_DECL(AST_Structure
);
109 DEF_NARROW_FROM_SCOPE(AST_Structure
);
111 virtual int member_count (void);
112 // Return the count of members.
114 virtual ACE_CDR::ULong
nfields (void) const;
115 // Return the count of actual fields.
117 virtual int field (AST_Field
**&result
,
118 ACE_CDR::ULong slot
) const;
119 // Get an individual field node.
121 virtual bool is_local (void);
122 // Overwrite the is_local method.
124 virtual bool in_recursion (ACE_Unbounded_Queue
<AST_Type
*> &list
);
125 // Are we or the node represented by node involved in recursion.
127 virtual int contains_wstring (void);
128 // Do we contain a wstring at some nesting level?
130 // Is this struct or union defined? This predicate returns FALSE when a
131 // forward declaration is not defined yet, and TRUE in
133 virtual bool is_defined (void);
135 // Recursively called on valuetype to check for legal use as
136 // a primary key. Overridden for valuetype, struct, sequence,
137 // union, array, typedef, and interface.
138 virtual bool legal_for_primary_key (void) const;
140 // Accessors for the member.
141 AST_StructureFwd
*fwd_decl (void) const;
142 void fwd_decl (AST_StructureFwd
*node
);
145 virtual void dump (ACE_OSTREAM_TYPE
&o
);
148 virtual void destroy (void);
151 virtual int ast_accept (ast_visitor
*visitor
);
153 // Accessor for the member.
154 ACE_Unbounded_Queue
<AST_Field
*> &fields (void);
156 static AST_Decl::NodeType
const NT
;
158 virtual bool annotatable () const;
160 virtual AST_Field
*fe_add_field (AST_Field
*f
);
162 /// Easy Member Access
164 virtual AST_Decl
*operator[] (const size_t index
);
165 virtual AST_Decl
*operator[] (const char* name
);
169 friend int tao_yyparse (void);
170 // Scope Management Protocol.
172 virtual AST_Union
*fe_add_union (AST_Union
*u
);
174 virtual AST_Structure
*fe_add_structure (AST_Structure
*s
);
176 virtual AST_Enum
*fe_add_enum (AST_Enum
*e
);
178 virtual AST_EnumVal
*fe_add_enum_val (AST_EnumVal
*v
);
180 virtual int compute_size_type (void);
181 // Compute the size type if it is unknown.
183 ACE_Unbounded_Queue
<AST_Field
*> fields_
;
184 // Container for this struct's field nodes. Excludes nodes included
185 // in member_count, i.e., enum values of an enum declared inside
189 int compute_member_count (void);
190 // Count the number of members.
193 // Number of members.
196 // We also need to determine whether we contain any local type.
198 AST_StructureFwd
*fwd_decl_
;
199 // The forward declaration we may have been created from.
202 #endif // _AST_STRUCTURE_AST_STRUCTURE_HH