00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef TAO_PSDL_SCOPE_H
00024 #define TAO_PSDL_SCOPE_H
00025
00026 #include "ace/pre.h"
00027
00028 #include "tao/corbafwd.h"
00029
00030 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00031 # pragma once
00032 #endif
00033
00034 #include "psdl_export.h"
00035
00036 #include "tao/TAO_Singleton.h"
00037
00038 #include "ace/Hash_Map_Manager_T.h"
00039 #include "ace/Array_Base.h"
00040 #include "ace/SString.h"
00041
00042
00043
00044 class TAO_PSDL_Node;
00045 class TAO_PSDL_Scope;
00046 class TAO_PSDL_Root_Scope;
00047 class TAO_PSDL_Stream;
00048
00049 typedef ACE_Hash_Map_Manager_Ex<ACE_CString, TAO_PSDL_Scope *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> Scope_Map;
00050
00051 typedef Scope_Map::iterator Scope_Map_Iterator;
00052
00053 class TAO_PSDL_Export TAO_PSDL_Scope
00054 {
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 friend class TAO_Singleton<TAO_PSDL_Scope, TAO_SYNCH_MUTEX>;
00065
00066 public:
00067
00068 TAO_PSDL_Scope (void);
00069
00070 virtual ~TAO_PSDL_Scope (void);
00071
00072
00073
00074
00075 virtual int add_module (ACE_CString identifier);
00076
00077 virtual int add_interface (ACE_CString identifier);
00078
00079 virtual int add_struct (ACE_CString identifier);
00080
00081 virtual int add_typedef (ACE_CString identifier,
00082 ACE_CString identifier_type);
00083
00084 virtual int add_const_decl (ACE_CString identifier,
00085 ACE_CString identifier_type);
00086
00087 virtual int add_except_decl (ACE_CString identifier,
00088 ACE_CString identifier_type);
00089
00090 virtual int add_exception (ACE_CString identifier);
00091
00092 virtual int add_op_dcl (ACE_CString identifier);
00093
00094 virtual int add_member_decl (ACE_CString identifier,
00095 ACE_CString identifier_type);
00096
00097
00098 virtual TAO_PSDL_Scope *pop_top_scope (void);
00099
00100
00101 virtual void push_scope (TAO_PSDL_Scope *scope);
00102
00103
00104 virtual TAO_PSDL_Scope *parent_scope (void);
00105
00106
00107 virtual Scope_Map *scope_map (void);
00108
00109
00110 virtual void dump (CORBA::ULong depth);
00111
00112
00113 virtual int find (const ACE_CString &identifier_name,
00114 ACE_CString &identifier_type);
00115
00116
00117
00118 virtual int find (const ACE_CString &identifier_name);
00119
00120
00121
00122 virtual int get_module_name (const ACE_CString &identifier_name,
00123 ACE_CString &module_name);
00124
00125
00126
00127 virtual int get_interface_name (const ACE_CString &identifier_name,
00128 ACE_CString &interface_name);
00129
00130
00131
00132
00133 virtual ACE_CString identifier_type (void);
00134 virtual ACE_CString module_name (void);
00135 virtual ACE_CString interface_name (void);
00136
00137
00138
00139
00140 int add_module_to_scope (ACE_CString identifier,
00141 TAO_PSDL_Scope *scope);
00142
00143 int add_interface_to_scope (ACE_CString identifier,
00144 TAO_PSDL_Scope *scope);
00145
00146 int add_interface_dcl_to_scope (ACE_CString identifier,
00147 TAO_PSDL_Scope *scope);
00148
00149 int add_struct_to_scope (ACE_CString identifier,
00150 TAO_PSDL_Scope *scope);
00151
00152 int add_typedef_to_scope (ACE_CString identifier,
00153 ACE_CString identifier_type,
00154 TAO_PSDL_Scope *scope);
00155
00156 int add_const_decl_to_scope (ACE_CString identifier,
00157 ACE_CString identifier_type,
00158 TAO_PSDL_Scope *scope);
00159
00160 int add_except_decl_to_scope (ACE_CString identifier,
00161 ACE_CString identifier_type,
00162 TAO_PSDL_Scope *scope);
00163
00164 int add_exception_to_scope (ACE_CString identifier,
00165 TAO_PSDL_Scope *scope);
00166
00167 int add_scoped_decl_to_scope (ACE_CString identifier,
00168 ACE_CString identifier_type,
00169 TAO_PSDL_Scope *scope);
00170
00171 int add_enum_decl_to_scope (ACE_CString identifier,
00172 ACE_CString identifier_type,
00173 TAO_PSDL_Scope *scope);
00174
00175 int add_op_dcl_to_scope (ACE_CString identifier,
00176 TAO_PSDL_Scope *scope);
00177
00178 int add_member_decl_to_scope (ACE_CString identifier,
00179 ACE_CString identifier_type,
00180 TAO_PSDL_Scope *scope);
00181
00182
00183 void set_root_scope (void);
00184
00185
00186
00187 void set_stub_prefix (const char *filename);
00188 const ACE_CString &get_stub_prefix (void);
00189
00190
00191
00192 void header_initialization (TAO_PSDL_Stream *ps_sh);
00193 void stub_initialization (TAO_PSDL_Stream *ps_si);
00194
00195
00196 TAO_PSDL_Stream *get_sh (void);
00197
00198
00199
00200 TAO_PSDL_Stream *get_si (void);
00201
00202
00203
00204 TAO_PSDL_Stream *get_sinline (void);
00205
00206
00207
00208 int check_identifier (ACE_CString identifier,
00209 TAO_PSDL_Scope *scope);
00210
00211
00212
00213 void check_name_in_scope (ACE_CString identifier,
00214 TAO_PSDL_Scope *scope);
00215
00216
00217 static TAO_PSDL_Scope *instance (void);
00218
00219
00220
00221 void print_depth (CORBA::ULong depth);
00222
00223
00224 void set_scope (void);
00225
00226
00227 void set_interface_scope (void);
00228
00229
00230 void set_module_scope (void);
00231
00232
00233 void save_identifier (ACE_CString identifier);
00234 ACE_CString get_identifier (void);
00235
00236
00237 void set_name_space (ACE_CString name_space);
00238 ACE_CString get_name_space (void);
00239
00240
00241 void set_interface_name (ACE_CString interface_name);
00242 ACE_CString get_interface_name (void);
00243
00244
00245
00246 void to_lower_case (ACE_CString &identifier);
00247
00248
00249
00250
00251 ACE_CString convert_str (int identifier_type);
00252
00253 private:
00254
00255
00256
00257 TAO_PSDL_Scope **psdl_scope_;
00258
00259
00260
00261 ACE_Array_Base <TAO_PSDL_Scope *> ast_scope_;
00262
00263
00264 ACE_Array_Base <ACE_CString> module_names_;
00265 ACE_Array_Base <ACE_CString> interface_names_;
00266
00267
00268 unsigned long psdl_scope_top_;
00269
00270
00271 TAO_PSDL_Root_Scope *root_scope_;
00272
00273
00274
00275 ACE_CString identifier_;
00276
00277
00278 ACE_CString name_space_;
00279 ACE_CString interface_name_;
00280
00281
00282 ACE_CString stub_prefix_;
00283
00284
00285
00286 TAO_PSDL_Stream *ps_sh_;
00287 TAO_PSDL_Stream *ps_si_;
00288 TAO_PSDL_Stream *ps_sin_;
00289
00290 };
00291
00292 #include "ace/post.h"
00293
00294 #endif