Remove redundant void from tao_idl
[ACE_TAO.git] / TAO / TAO_IDL / util / utl_global.cpp
blobfe0e649d2713aeed7a5a8c98106a42e4e3a646a9
1 /*
3 COPYRIGHT
5 Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United
6 States of America. All Rights Reserved.
8 This product is protected by copyright and distributed under the following
9 license restricting its use.
11 The Interface Definition Language Compiler Front End (CFE) is made
12 available for your use provided that you include this license and copyright
13 notice on all media and documentation and the software program in which
14 this product is incorporated in whole or part. You may copy and extend
15 functionality (but may not remove functionality) of the Interface
16 Definition Language CFE without charge, but you are not authorized to
17 license or distribute it to anyone else except as part of a product or
18 program developed by you or with the express written consent of Sun
19 Microsystems, Inc. ("Sun").
21 The names of Sun Microsystems, Inc. and any of its subsidiaries or
22 affiliates may not be used in advertising or publicity pertaining to
23 distribution of Interface Definition Language CFE as permitted herein.
25 This license is effective until terminated by Sun for failure to comply
26 with this license. Upon termination, you shall destroy or return all code
27 and documentation for the Interface Definition Language CFE.
29 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF
30 ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS
31 FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF
32 DEALING, USAGE OR TRADE PRACTICE.
34 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT
35 ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES
36 TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.
38 SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
39 RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
40 INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF.
42 IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR
43 ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
44 DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
46 Use, duplication, or disclosure by the government is subject to
47 restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
48 Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR
49 52.227-19.
51 Sun, Sun Microsystems and the Sun logo are trademarks or registered
52 trademarks of Sun Microsystems, Inc.
54 SunSoft, Inc.
55 2550 Garcia Avenue
56 Mountain View, California 94043
58 NOTE:
60 SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
61 trademarks or registered trademarks of Sun Microsystems, Inc.
65 #include "idl_defines.h"
66 #include "idl_global.h"
67 #include "global_extern.h"
68 #include "utl_identifier.h"
69 #include "utl_indenter.h"
70 #include "utl_err.h"
71 #include "utl_string.h"
72 #include "fe_extern.h"
73 #include "fe_private.h"
74 #include "nr_extern.h"
75 #include "ast_extern.h"
77 #include "ast_root.h"
78 #include "ast_generator.h"
79 #include "ast_valuetype.h"
80 #include "ast_annotation_decl.h"
82 #include "ace/OS_NS_stdio.h"
83 #include "ace/OS_NS_unistd.h"
84 #include "ace/Process.h"
85 #include "ace/Env_Value_T.h"
86 // FUZZ: disable check_for_streams_include
87 #include "ace/streams.h"
89 // Define an increment for the size of the array used to store names of
90 // included files.
91 #undef INCREMENT
92 #define INCREMENT 64
94 static long *pSeenOnce = 0;
96 #if defined (ACE_OPENVMS)
97 #include <unixlib.h>
98 char* IDL_GlobalData::translateName(const char* name, char *name_buf)
100 char* transName = (ACE_OS::strpbrk (name, ":[") == 0
101 ? (char*)name
102 : ::decc$translate_vms (name));
103 if (transName)
105 ACE_OS::strcpy (name_buf, transName);
106 transName = name_buf;
109 return (transName == 0 || ((int)transName) == -1 ) ? 0 : transName;
111 #endif
113 IDL_GlobalData::IDL_GlobalData ()
114 : syntax_only_ (false),
115 parse_args_exit_ (false),
116 parse_args_exit_status_ (0),
117 print_help_ (false),
118 print_version_ (false),
119 in_eval_ (false),
120 dump_builtins_ (false),
121 just_dump_builtins_ (false),
122 ignore_files_ (false),
123 ignore_lookup_errors_ (false),
124 unknown_annotations_ (UNKNOWN_ANNOTATIONS_WARN_ONCE),
125 pd_root (0),
126 pd_gen (0),
127 pd_primary_key_base (0),
128 pd_err (0),
129 pd_err_count (0),
130 pd_lineno (0),
131 pd_filename (0),
132 pd_main_filename (0),
133 pd_real_filename (0),
134 pd_stripped_filename (0),
135 pd_import (false),
136 pd_in_main_file (false),
137 pd_prog_name (0),
138 pd_cpp_location (0),
139 pd_compile_flags (0),
140 pd_local_escapes (0),
141 pd_indent (0),
142 pd_include_file_names (0),
143 pd_n_include_file_names (0),
144 pd_n_alloced_file_names (0),
145 included_idl_files_ (0),
146 n_included_idl_files_ (0),
147 n_allocated_idl_files_ (0),
148 pd_parse_state (PS_NoState),
149 pd_idl_src_file (0),
150 tao_root_ (0),
151 gperf_path_ (0),
152 temp_dir_ (0),
153 ident_string_ (0),
154 case_diff_error_ (true),
155 nest_orb_ (false),
156 idl_flags_ (""),
157 preserve_cpp_keywords_ (true),
158 pass_orb_idl_ (false),
159 using_ifr_backend_ (false),
160 ignore_idl3_ (false),
161 dcps_support_zero_copy_read_ (false),
162 dcps_gen_zero_copy_read_ (false),
163 recursion_start_ (0),
164 multi_file_input_ (false),
165 big_file_name_ ("PICML_IDL_file_bag"),
166 current_params_ (0),
167 alias_params_ (0),
168 for_new_holder_ (0),
169 included_ami_receps_done_ (false),
170 corba_module_ (0),
171 anon_type_diagnostic_ (ANON_TYPE_ERROR),
172 explicit_anon_type_diagnostic_ (false),
173 in_typedef_ (false),
174 in_tmpl_mod_no_alias_ (false),
175 in_tmpl_mod_alias_ (false)
177 // Path for the perfect hash generator(gperf) program.
178 // Default is $ACE_ROOT/bin/gperf unless ACE_GPERF is defined.
179 // Use ACE_GPERF if $ACE_ROOT hasn't been set or won't be set
180 // in the environment.
181 // Form the absolute pathname.
182 char* ace_root = ACE_OS::getenv ("ACE_ROOT");
184 if (ace_root == 0)
185 // This may not cause any problem if -g option is used to specify
186 // the correct path for the gperf program. Let us ignore this
187 // error here. It will be caught when we check the existence of
188 // the perfect hasher and at that time, we can switch over to some
189 // other scheme.
191 #if defined (ACE_GPERF)
192 // The actual gperf program must be included in the definition of
193 // ACE_GPERF, not just the directory in which it is located.
194 const char ace_gperf[] = ACE_GPERF;
195 ACE_NEW (this->gperf_path_,
196 char [ACE_OS::strlen (ace_gperf) + 1]);
197 ACE_OS::sprintf (this->gperf_path_,
198 "%s",
199 ace_gperf);
200 #else
201 this->gperf_path_ = 0;
202 #endif
204 else
206 #if defined (ACE_GPERF)
207 const char ace_gperf[] = ACE_GPERF;
208 ACE_NEW (this->gperf_path_,
209 char [ACE_OS::strlen (ace_root)
210 + ACE_OS::strlen ("/bin/")
211 + ACE_OS::strlen (ace_gperf)
212 + 1]);
213 ACE_OS::sprintf (this->gperf_path_,
214 "%s" ACE_DIRECTORY_SEPARATOR_STR_A "bin" ACE_DIRECTORY_SEPARATOR_STR_A "%s",
215 ace_root,
216 ace_gperf);
217 #else /* Not ACE_GPERF */
218 // Set it to the default value.
219 ACE_NEW (this->gperf_path_,
220 char [ACE_OS::strlen (ace_root)
221 + ACE_OS::strlen ("/bin/ace_gperf")
222 + 1]);
223 ACE_OS::sprintf (this->gperf_path_,
224 "%s" ACE_DIRECTORY_SEPARATOR_STR_A "bin" ACE_DIRECTORY_SEPARATOR_STR_A "ace_gperf",
225 ace_root);
226 #endif /* ACE_GPERF */
229 #if defined (IDL_ANON_ERROR)
230 anon_type_diagnostic (ANON_TYPE_ERROR);
231 #elif defined (IDL_ANON_WARNING)
232 anon_type_diagnostic (ANON_TYPE_WARNING);
233 #elif defined (IDL_ANON_SILENT)
234 anon_type_diagnostic (ANON_TYPE_SILENT);
235 #endif
237 // ambiguous_type_seen_ and basic_type_seen_ are not reset between
238 // command line idl files, so do those here and then reset the rest.
239 this->ambiguous_type_seen_ = false;
240 this->basic_type_seen_ = false;
241 this->reset_flag_seen ();
244 IDL_GlobalData::~IDL_GlobalData ()
248 // When starting to process the next command line input idl file, reset.
249 void
250 IDL_GlobalData::reset_flag_seen ()
252 abstract_iface_seen_ = false;
253 abstractbase_seen_ = false;
254 aggregate_seen_ = false;
255 any_arg_seen_ = false;
256 any_seen_ = false;
257 any_seq_seen_ = false;
258 array_seen_ = false;
259 array_seq_seen_ = false;
260 base_object_seen_ = false;
261 //basic_type_seen_
262 bd_string_seen_ = false;
263 boolean_seq_seen_ = false;
264 char_seq_seen_ = false;
265 component_seen_ = false;
266 connector_seen_ = false;
267 double_seq_seen_ = false;
268 enum_seen_ = false;
269 exception_seen_ = false;
270 fixed_array_decl_seen_ = false;
271 fixed_size_decl_seen_ = false;
272 float_seq_seen_ = false;
273 fwd_iface_seen_ = false;
274 fwd_valuetype_seen_ = false;
275 iface_seq_seen_ = false;
276 interface_seen_ = false;
277 local_iface_seen_ = false;
278 long_seq_seen_ = false;
279 longdouble_seq_seen_ = false;
280 longlong_seq_seen_ = false;
281 non_local_fwd_iface_seen_ = false;
282 non_local_iface_seen_ = false;
283 non_local_op_seen_ = false;
284 object_arg_seen_ = false;
285 octet_seq_seen_ = false;
286 operation_seen_ = false;
287 pseudo_seq_seen_ = false;
288 recursive_type_seen_ = false;
289 seq_seen_ = false;
290 short_seq_seen_ = false;
291 special_basic_decl_seen_ = false;
292 string_seen_ = false;
293 string_member_seen_ = false;
294 string_seq_seen_ = false;
295 typecode_seen_ = false;
296 ub_string_seen_ = false;
297 ulong_seq_seen_ = false;
298 ulonglong_seq_seen_ = false;
299 union_seen_ = false;
300 ushort_seq_seen_ = false;
301 valuebase_seen_ = false;
302 valuefactory_seen_ = false;
303 valuetype_seen_ = false;
304 var_array_decl_seen_ = false;
305 var_size_decl_seen_ = false;
306 vt_seq_seen_ = false;
307 wchar_seq_seen_ = false;
308 wstring_seq_seen_ = false;
309 dds_connector_seen_ = false;
310 ami_connector_seen_ = false;
312 need_skeleton_includes_ = false;
315 // Get or set scopes stack
316 UTL_ScopeStack &
317 IDL_GlobalData::scopes ()
319 return this->pd_scopes;
322 // Get or set root of AST
323 AST_Root *
324 IDL_GlobalData::root ()
326 return this->pd_root;
329 void
330 IDL_GlobalData::set_root (AST_Root *r)
332 this->pd_root = r;
335 // Get or set generator object
336 AST_Generator *
337 IDL_GlobalData::gen ()
339 return this->pd_gen;
342 void
343 IDL_GlobalData::set_gen (AST_Generator *g)
345 this->pd_gen = g;
348 // Get or set PrimaryKeyBase object
349 AST_ValueType *
350 IDL_GlobalData::primary_key_base ()
352 return this->pd_primary_key_base;
355 void
356 IDL_GlobalData::primary_key_base (AST_ValueType *v)
358 this->pd_primary_key_base = v;
361 // Get or set error object
362 UTL_Error *
363 IDL_GlobalData::err ()
365 return this->pd_err;
368 void
369 IDL_GlobalData::set_err (UTL_Error *e)
371 this->pd_err = e;
374 // Get or set error count
376 IDL_GlobalData::err_count ()
378 return this->pd_err_count;
381 void
382 IDL_GlobalData::set_err_count (int c)
384 this->pd_err_count = c;
387 // Get or set line number
388 long
389 IDL_GlobalData::lineno ()
391 return this->pd_lineno;
394 void
395 IDL_GlobalData::set_lineno (long n)
397 this->pd_lineno = n;
400 // Get or set file name being read now
401 UTL_String *
402 IDL_GlobalData::filename ()
404 return this->pd_filename;
407 void
408 IDL_GlobalData::set_filename (UTL_String *s)
410 if (this->pd_filename != 0)
412 this->pd_filename->destroy ();
413 delete this->pd_filename;
414 this->pd_filename = 0;
417 this->pd_filename = s;
420 // Get or set main file name
421 UTL_String *
422 IDL_GlobalData::main_filename ()
424 return this->pd_main_filename;
427 void
428 IDL_GlobalData::set_main_filename (UTL_String *n)
430 if (this->pd_main_filename != 0)
432 this->pd_main_filename->destroy ();
433 delete this->pd_main_filename;
434 this->pd_main_filename = 0;
436 this->pd_main_filename = n;
439 // Get or set real file name
440 UTL_String *
441 IDL_GlobalData::real_filename ()
443 return this->pd_real_filename;
446 void
447 IDL_GlobalData::set_real_filename (UTL_String *n)
449 if (this->pd_real_filename != 0)
451 this->pd_real_filename->destroy ();
452 delete this->pd_real_filename;
453 this->pd_real_filename = 0;
456 this->pd_real_filename = n;
459 // Get or set indicator whether import is on
460 bool
461 IDL_GlobalData::imported ()
463 return this->pd_in_main_file ? false : pd_import;
466 bool
467 IDL_GlobalData::import ()
469 return this->pd_import;
472 void
473 IDL_GlobalData::set_import (bool is_in)
475 this->pd_import = is_in;
478 // Get or set indicator whether we're reading the main file now
479 bool
480 IDL_GlobalData::in_main_file ()
482 return this->pd_in_main_file;
485 void
486 IDL_GlobalData::set_in_main_file (bool is_in)
488 this->pd_in_main_file = is_in;
491 // Get or set stripped file name
492 UTL_String *
493 IDL_GlobalData::stripped_filename ()
495 return this->pd_stripped_filename;
498 void
499 IDL_GlobalData::set_stripped_filename (UTL_String *nm)
501 if (this->pd_stripped_filename != 0)
503 delete this->pd_stripped_filename;
506 this->pd_stripped_filename = nm;
509 // Get or set cache value for argv[0]
510 const char *
511 IDL_GlobalData::prog_name ()
513 return this->pd_prog_name;
516 void
517 IDL_GlobalData::set_prog_name (const char *pn)
519 this->pd_prog_name = pn;
522 // Get or set location to find C preprocessor
523 const char *
524 IDL_GlobalData::cpp_location ()
526 return this->pd_cpp_location;
529 void
530 IDL_GlobalData::set_cpp_location (const char *l)
532 this->pd_cpp_location = l;
535 // Get or set IDL compiler flags
536 long
537 IDL_GlobalData::compile_flags ()
539 return this->pd_compile_flags;
542 void
543 IDL_GlobalData::set_compile_flags (long cf)
545 if (cf & IDL_CF_ONLY_USAGE)
547 print_help ();
549 if (cf & IDL_CF_DUMP_AST)
551 syntax_only_ = true;
553 this->pd_compile_flags = cf;
556 // Get or set local escapes string. This provides an additional
557 // mechanism to pass information to a BE.
558 char *
559 IDL_GlobalData::local_escapes ()
561 return this->pd_local_escapes;
564 void
565 IDL_GlobalData::set_local_escapes (const char *e)
567 if (this->pd_local_escapes != 0)
569 delete [] this->pd_local_escapes;
572 this->pd_local_escapes = ACE::strnew (e);
575 // Get or set indent object
576 UTL_Indenter *
577 IDL_GlobalData::indent ()
579 return this->pd_indent;
582 void
583 IDL_GlobalData::set_indent (UTL_Indenter *i)
585 this->pd_indent = i;
588 // Have we seen this #include file name before?
589 long
590 IDL_GlobalData::seen_include_file_before (char *n)
592 unsigned long i;
593 char *incl = 0;
594 char *tmp = n;
596 for (i = 0; i < this->pd_n_include_file_names; ++i)
598 incl = this->pd_include_file_names[i]->get_string ();
600 if (ACE_OS::strcmp (tmp, incl) == 0)
602 return ++pSeenOnce[i];
606 return 0;
609 // Store the name of an #include file.
610 void
611 IDL_GlobalData::store_include_file_name (UTL_String *n)
613 // Check if we need to store it at all or whether we've seen it already.
614 if (this->seen_include_file_before (n->get_string ()))
616 n->destroy ();
617 delete n; // Don't keep filenames we don't store!
618 return;
621 // OK, need to store. Make sure there's space for one more string
622 if (this->pd_n_include_file_names == this->pd_n_alloced_file_names)
624 // Allocating more space.
625 if (this->pd_n_alloced_file_names == 0)
627 this->pd_n_alloced_file_names = INCREMENT;
628 ACE_NEW (this->pd_include_file_names,
629 UTL_String *[this->pd_n_alloced_file_names]);
630 ACE_NEW (pSeenOnce,
631 long [this->pd_n_alloced_file_names]);
633 else
635 UTL_String **o_include_file_names= this->pd_include_file_names;
636 unsigned long o_n_alloced_file_names= this->pd_n_alloced_file_names;
637 long *o_pSeenOnce= pSeenOnce;
639 this->pd_n_alloced_file_names += INCREMENT;
640 ACE_NEW (this->pd_include_file_names,
641 UTL_String *[this->pd_n_alloced_file_names]);
642 ACE_NEW (pSeenOnce,
643 long [this->pd_n_alloced_file_names]);
645 for (unsigned long i = 0; i < o_n_alloced_file_names; ++i)
647 this->pd_include_file_names[i] = o_include_file_names[i];
648 pSeenOnce[i]= o_pSeenOnce[i];
651 delete [] o_include_file_names;
652 delete [] o_pSeenOnce;
656 // Store it.
657 pSeenOnce[this->pd_n_include_file_names] = 1;
658 this->pd_include_file_names[this->pd_n_include_file_names++] = n;
661 void
662 IDL_GlobalData::set_include_file_names (UTL_String **ns)
664 this->pd_include_file_names = ns;
667 UTL_String **
668 IDL_GlobalData::include_file_names ()
670 return this->pd_include_file_names;
673 void
674 IDL_GlobalData::set_n_include_file_names (unsigned long n)
676 pd_n_include_file_names = n;
679 unsigned long
680 IDL_GlobalData::n_include_file_names ()
682 return pd_n_include_file_names;
685 // Access methods to deal with other IDL files included in the main
686 // IDL file.
688 void
689 IDL_GlobalData::add_to_included_idl_files (const char *file_name)
691 // Let's avoid duplicates.
692 for (size_t index = 0; index < this->n_included_idl_files_; ++index)
694 if (!ACE_OS::strcmp (file_name, this->included_idl_files_[index]))
696 return;
700 // Is there enough space there to store one more file.
701 if (this->n_included_idl_files_ == this->n_allocated_idl_files_)
703 // Allocating more space.
704 if (this->n_allocated_idl_files_ == 0)
706 // First time creation.
707 this->n_allocated_idl_files_ = INCREMENT;
708 ACE_NEW (this->included_idl_files_,
709 char *[this->n_allocated_idl_files_]);
711 else
713 // Adding more storage.
714 char** old_included_idl_files =
715 this->included_idl_files_;
716 size_t n_old_allocated_idl_files =
717 this->n_allocated_idl_files_;
718 this->n_allocated_idl_files_ += INCREMENT;
719 ACE_NEW (this->included_idl_files_,
720 char *[this->n_allocated_idl_files_]);
722 for (size_t i = 0; i < n_old_allocated_idl_files; ++i)
724 this->included_idl_files_ [i] =
725 old_included_idl_files [i];
728 delete [] old_included_idl_files;
732 // Store it.
733 this->included_idl_files_ [this->n_included_idl_files_++] =
734 ACE::strnew (file_name);
737 char**
738 IDL_GlobalData::included_idl_files ()
740 return this->included_idl_files_;
743 size_t
744 IDL_GlobalData::n_included_idl_files ()
746 return this->n_included_idl_files_;
749 // Set the number of included_idl_files. Use this carefully. This
750 // method is used when we validate all the #included idl files,
751 // against the ones that we get after preprocessing.
752 void
753 IDL_GlobalData::n_included_idl_files (size_t n)
755 this->n_included_idl_files_ = n;
758 void
759 IDL_GlobalData::set_parse_state(ParseState ps)
761 pd_parse_state = ps;
764 IDL_GlobalData::ParseState
765 IDL_GlobalData::parse_state ()
767 return pd_parse_state;
770 // returns the IDL source file being copiled
771 UTL_String* IDL_GlobalData::idl_src_file ()
773 return this->pd_idl_src_file;
776 // set the source IDL file that is being parsed
777 void IDL_GlobalData::idl_src_file (UTL_String *s)
779 this->pd_idl_src_file = s;
782 void
783 IDL_GlobalData::temp_dir (const char *s)
785 // Delete the old pointer.
786 delete [] this->temp_dir_;
787 this->temp_dir_ = 0; // In case the ACE_NEW fails below.
789 const size_t lengthSep = sizeof (ACE_DIRECTORY_SEPARATOR_STR_A) - 1u;
790 const size_t lengthPath = ACE_OS::strlen (s);
792 // Allocate memory, 1 for the end of string.
793 ACE_NEW (this->temp_dir_, char [lengthPath + lengthSep + 1u]);
795 // Copy the strings.
796 if (lengthSep < lengthPath &&
797 0 == ACE_OS::strcmp (s + lengthPath - lengthSep, ACE_DIRECTORY_SEPARATOR_STR_A))
799 // Already has a directory seporator on end of temp root, don't add another.
800 ACE_OS::strcpy (this->temp_dir_, s);
802 else
804 // Need to add a directory seporator to temp root.
805 ACE_OS::sprintf (this->temp_dir_,
806 "%s%s",
808 ACE_DIRECTORY_SEPARATOR_STR_A);
812 const char *
813 IDL_GlobalData::temp_dir () const
815 return this->temp_dir_;
818 void
819 IDL_GlobalData::tao_root (const char *s)
821 delete [] this->tao_root_;
822 this->tao_root_ = ACE::strnew (s);
825 const char *
826 IDL_GlobalData::tao_root () const
828 return this->tao_root_;
831 void
832 IDL_GlobalData::gperf_path (const char *s)
834 delete [] this->gperf_path_;
835 this->gperf_path_ = ACE::strnew (s);
838 const char *
839 IDL_GlobalData::gperf_path () const
841 return this->gperf_path_;
844 void
845 IDL_GlobalData::ident_string (const char *s)
847 delete [] this->ident_string_;
848 this->ident_string_ = ACE::strnew (s);
851 const char *
852 IDL_GlobalData::ident_string () const
854 return this->ident_string_;
857 void
858 IDL_GlobalData::case_diff_error (bool val)
860 this->case_diff_error_ = val;
863 bool
864 IDL_GlobalData::case_diff_error ()
866 return this->case_diff_error_;
869 void
870 IDL_GlobalData::nest_orb (bool val)
872 this->nest_orb_ = val;
875 bool
876 IDL_GlobalData::nest_orb ()
878 return this->nest_orb_;
881 void
882 IDL_GlobalData::destroy ()
884 if (this->pd_filename != 0)
886 this->pd_filename->destroy ();
887 delete this->pd_filename;
888 this->pd_filename = 0;
891 if (this->pd_main_filename != 0)
893 this->pd_main_filename->destroy ();
894 delete this->pd_main_filename;
895 this->pd_main_filename = 0;
898 if (this->pd_real_filename != 0)
900 this->pd_real_filename->destroy ();
901 delete this->pd_real_filename;
902 this->pd_real_filename = 0;
905 if (this->pd_stripped_filename != 0)
907 this->pd_stripped_filename->destroy ();
908 delete this->pd_stripped_filename;
909 this->pd_stripped_filename = 0;
912 if (this->pd_idl_src_file != 0)
914 this->pd_idl_src_file->destroy ();
915 delete this->pd_idl_src_file;
916 this->pd_idl_src_file = 0;
919 size_t size = this->pragma_prefixes ().size ();
920 char *trash = 0;
922 for (size_t i = 0; i < size; ++i)
924 this->pragma_prefixes ().pop (trash);
925 delete [] trash;
926 trash = 0;
929 // Clean up each included file name - the array allocation itself
930 // gets cleaned up in fini().
931 for (unsigned long j = 0; j < this->pd_n_include_file_names; ++j)
933 this->pd_include_file_names[j]->destroy ();
934 delete this->pd_include_file_names[j];
935 this->pd_include_file_names[j] = 0;
938 this->pd_n_include_file_names = 0;
940 for (size_t k = 0; k < n_included_idl_files_; ++k)
942 ACE::strdelete (this->included_idl_files_[k]);
943 this->included_idl_files_[k] = 0;
946 this->n_included_idl_files_ = 0;
947 this->n_allocated_idl_files_ = 0;
948 delete [] this->included_idl_files_;
949 this->included_idl_files_ = 0;
951 ACE::strdelete (this->recursion_start_);
952 this->recursion_start_ = 0;
954 // Reset the member of the CORBA module containing the basic types
955 // to point to itself, since all the other CORBA modules (if any)
956 // will be destroyed.
957 if (this->corba_module_ != 0)
959 this->corba_module_->reset_last_in_same_parent_scope ();
962 if (0 != this->pd_root)
964 this->pd_root->destroy ();
968 void
969 IDL_GlobalData::append_idl_flag (const char *s)
971 this->idl_flags_ += " " + ACE_CString (s);
974 const char *
975 IDL_GlobalData::idl_flags () const
977 return this->idl_flags_.c_str ();
980 ACE_Hash_Map_Manager<ACE_CString, int, ACE_Null_Mutex> &
981 IDL_GlobalData::idl_keywords ()
983 return this->idl_keywords_;
986 ACE_Unbounded_Stack<char *> &
987 IDL_GlobalData::pragma_prefixes ()
989 return this->pragma_prefixes_;
992 void
993 IDL_GlobalData::update_prefix (char *filename)
995 // If we are just starting up and processing the temporary filename,
996 // there are no prefix issues to deal with yet.
997 if (this->pd_main_filename == 0 || this->pd_filename == 0)
999 return;
1002 char *fstring = this->pd_filename->get_string ();
1003 char *tail = fstring + ACE_OS::strlen (fstring) - 3;
1005 // We have to do this check because some preprocessors (gcc 3.2
1006 // on RedHat Linux 7.1, for one) output the same filename
1007 // multiple times for no apparent reason, and we don't want it
1008 // to clear the prefix.
1009 if (ACE_OS::strcmp (fstring, filename) == 0
1010 || ACE_OS::strcmp (tail, ".cc") == 0)
1012 return;
1015 ACE_CString tmp ("", 0, false);
1016 char *main_filename = this->pd_main_filename->get_string ();
1018 char *prefix = 0;
1019 int status = this->file_prefixes_.find (filename, prefix);
1021 if (status == 0)
1023 this->pd_root->prefix (prefix);
1025 else
1027 prefix = ACE::strnew ("");
1028 (void) this->file_prefixes_.bind (ACE::strnew (filename), prefix);
1029 this->pd_root->prefix ("");
1032 // The first branch is executed if we are finishing an
1033 // included IDL file (but the current filename has not yet
1034 // been changed). So we check for (1) the current filename is
1035 // not the same as the main filename (2) the prefix stack size
1036 // is greater than 1 (to skip the case where we are passed the
1037 // temporary filename) and (3) we have either seen the filename
1038 // passed in before as an included file or we are passed the
1039 // main filename. Otherwise we know we are beginning an included
1040 // file, so we push a blank prefix on the stack, which may
1041 // possibly be changed later.
1042 if (this->seen_include_file_before (filename) != 0
1043 || ACE_OS::strcmp (filename, main_filename) == 0
1044 || ACE_OS::strcmp (filename, this->pd_filename->get_string ()) != 0)
1046 if (!this->pd_in_main_file)
1048 status =
1049 this->file_prefixes_.find (this->pd_filename->get_string (),
1050 prefix);
1052 // This function is called just before we transition to a
1053 // new file at global scope. If there is a non-null prefix
1054 // stored in the table under our not-yet-changed filename,
1055 // pop it.
1056 if (status == 0 && ACE_OS::strcmp (prefix, "") != 0)
1058 char *trash = 0;
1059 this->pragma_prefixes_.pop (trash);
1060 delete [] trash;
1064 else
1066 this->pragma_prefixes_.push (tmp.rep ());
1071 Whether we should not mung idl element names that are
1072 C++ keywords e.g. delete, operator etc. with _cxx_ prefix.
1073 Should be true when being used by the IFR Service
1075 bool
1076 IDL_GlobalData::preserve_cpp_keywords ()
1078 return preserve_cpp_keywords_;
1082 Set whether we should not mung idl element names that are C++
1083 keywords e.g. delete, operator etc. with _cxx_ prefix.
1084 Is unset by the tao_idl compiler.
1086 void
1087 IDL_GlobalData::preserve_cpp_keywords (bool val)
1089 preserve_cpp_keywords_ = val;
1092 void
1093 IDL_GlobalData::add_include_path (const char *s, bool is_system)
1095 Include_Path_Info info = { ACE::strnew (s), is_system };
1096 this->include_paths_.enqueue_tail (info);
1099 void
1100 IDL_GlobalData::add_rel_include_path (const char *s)
1102 this->rel_include_paths_.enqueue_tail (ACE::strnew (s));
1105 ACE_Unbounded_Queue<char *> const &
1106 IDL_GlobalData::rel_include_paths () const
1108 return this->rel_include_paths_;
1111 void
1112 IDL_GlobalData::add_ciao_lem_file_names (const char *s)
1114 this->ciao_lem_file_names_.enqueue_tail (ACE::strnew (s));
1117 ACE_Unbounded_Queue<char *> &
1118 IDL_GlobalData::ciao_lem_file_names ()
1120 return this->ciao_lem_file_names_;
1123 void
1124 IDL_GlobalData::add_ciao_rti_ts_file_names (const char *s)
1126 this->ciao_rti_ts_file_names_.enqueue_tail (ACE::strnew (s));
1129 ACE_Unbounded_Queue<char *> &
1130 IDL_GlobalData::ciao_rti_ts_file_names ()
1132 return this->ciao_rti_ts_file_names_;
1135 void
1136 IDL_GlobalData::add_ciao_spl_ts_file_names (const char *s)
1138 this->ciao_spl_ts_file_names_.enqueue_tail (ACE::strnew (s));
1141 ACE_Unbounded_Queue<char *> &
1142 IDL_GlobalData::ciao_spl_ts_file_names ()
1144 return this->ciao_spl_ts_file_names_;
1147 void
1148 IDL_GlobalData::add_ciao_oci_ts_file_names (const char *s)
1150 this->ciao_oci_ts_file_names_.enqueue_tail (ACE::strnew (s));
1153 ACE_Unbounded_Queue<char *> &
1154 IDL_GlobalData::ciao_oci_ts_file_names ()
1156 return this->ciao_oci_ts_file_names_;
1159 void
1160 IDL_GlobalData::add_ciao_coredx_ts_file_names (const char *s)
1162 this->ciao_coredx_ts_file_names_.enqueue_tail (ACE::strnew (s));
1165 ACE_Unbounded_Queue<char *> &
1166 IDL_GlobalData::ciao_coredx_ts_file_names ()
1168 return this->ciao_coredx_ts_file_names_;
1171 void
1172 IDL_GlobalData::add_ciao_ami_iface_names (const char *s)
1174 this->ciao_ami_iface_names_.enqueue_tail (ACE::strnew (s));
1177 ACE_Unbounded_Queue<char *> &
1178 IDL_GlobalData::ciao_ami_iface_names ()
1180 return this->ciao_ami_iface_names_;
1183 void
1184 IDL_GlobalData::add_ciao_ami_recep_names (const char *s)
1186 this->ciao_ami_recep_names_.enqueue_tail (ACE::strnew (s));
1189 ACE_Unbounded_Queue<char *> &
1190 IDL_GlobalData::ciao_ami_recep_names ()
1192 return this->ciao_ami_recep_names_;
1195 void
1196 IDL_GlobalData::add_included_ami_recep_names (const char *s)
1198 this->included_ami_recep_names_.enqueue_tail (ACE::strnew (s));
1201 ACE_Unbounded_Queue<char *> &
1202 IDL_GlobalData::included_ami_recep_names ()
1204 return this->included_ami_recep_names_;
1207 bool
1208 IDL_GlobalData::included_ami_receps_done () const
1210 return this->included_ami_receps_done_;
1213 void
1214 IDL_GlobalData::included_ami_receps_done (bool val)
1216 this->included_ami_receps_done_ = val;
1219 void
1220 IDL_GlobalData::add_ciao_ami_idl_fnames (const char *s)
1222 this->ciao_ami_idl_fnames_.enqueue_tail (ACE::strnew (s));
1225 ACE_Unbounded_Queue<char *> &
1226 IDL_GlobalData::ciao_ami_idl_fnames ()
1228 return this->ciao_ami_idl_fnames_;
1231 void
1232 IDL_GlobalData::add_dds4ccm_impl_fnames (const char *s)
1234 this->dds4ccm_impl_fnames_.enqueue_tail (ACE::strnew (s));
1237 ACE_Unbounded_Queue<char *> &
1238 IDL_GlobalData::dds4ccm_impl_fnames ()
1240 return this->dds4ccm_impl_fnames_;
1243 ACE_Unbounded_Queue<AST_Interface *> &
1244 IDL_GlobalData::mixed_parentage_interfaces ()
1246 return this->mixed_parentage_interfaces_;
1249 ACE_Hash_Map_Manager<char *, char *, ACE_Null_Mutex> &
1250 IDL_GlobalData::file_prefixes ()
1252 return this->file_prefixes_;
1255 bool
1256 IDL_GlobalData::pass_orb_idl () const
1258 return this->pass_orb_idl_;
1261 void
1262 IDL_GlobalData::pass_orb_idl (bool val)
1264 this->pass_orb_idl_ = val;
1267 bool
1268 IDL_GlobalData::using_ifr_backend () const
1270 return this->using_ifr_backend_;
1273 void
1274 IDL_GlobalData::using_ifr_backend (bool val)
1276 this->using_ifr_backend_ = val;
1279 bool
1280 IDL_GlobalData::ignore_idl3 () const
1282 return this->ignore_idl3_;
1285 void
1286 IDL_GlobalData::ignore_idl3 (bool val)
1288 this->ignore_idl3_ = val;
1291 bool
1292 IDL_GlobalData::dcps_support_zero_copy_read () const
1294 return this->dcps_support_zero_copy_read_;
1297 void
1298 IDL_GlobalData::dcps_support_zero_copy_read (bool val)
1300 this->dcps_support_zero_copy_read_ = val;
1303 bool
1304 IDL_GlobalData::dcps_gen_zero_copy_read () const
1306 return this->dcps_gen_zero_copy_read_;
1309 void
1310 IDL_GlobalData::dcps_gen_zero_copy_read (bool val)
1312 this->dcps_gen_zero_copy_read_ = val;
1315 // Return 0 on success, -1 failure. The <errno> corresponding to the
1316 // error that caused the GPERF execution is also set.
1318 IDL_GlobalData::check_gperf ()
1320 // If absolute path is not specified yet, let us call just
1321 // "gperf". Hopefully PATH is set up correctly to locate the gperf.
1322 if (this->gperf_path_ == 0)
1324 // If ACE_GPERF is defined then use that gperf program instead of "gperf."
1325 #if defined (ACE_GPERF)
1326 this->gperf_path (ACE_GPERF);
1327 #else
1328 this->gperf_path ("ace_gperf");
1329 #endif /* ACE_GPERF */
1332 // If we have absolute path for the <gperf> rather than just the
1333 // executable name <gperf>, make sure the file exists
1334 // firsts. Otherwise just call <gperf>. Probably PATH is set
1335 // correctly to take care of this.
1337 // If ACE_GPERF is defined then use that gperf program instead of "gperf."
1338 #if defined (ACE_GPERF)
1339 if (ACE_OS::strcmp (this->gperf_path_, ACE_GPERF) != 0)
1340 #else
1341 if (ACE_OS::strcmp (this->gperf_path_, "ace_gperf") != 0)
1342 #endif /* ACE_GPERF */
1344 // It is absolute path. Check the existence, permissions and
1345 // the modes.
1346 if (ACE_OS::access (this->gperf_path_,
1347 F_OK | X_OK) == -1)
1349 // Problem with the file. No point in having the absolute
1350 // path. Swith to "gperf".
1351 // If ACE_GPERF is defined then use that gperf program
1352 //instead of "gperf."
1353 #if defined (ACE_GPERF)
1354 this->gperf_path (ACE_GPERF);
1355 #else
1356 this->gperf_path ("ace_gperf");
1357 #endif /* ACE_GPERF */
1361 // Just call gperf in silent mode. It will come and immly exit.
1363 // Using ACE_Process.
1364 ACE_Process process;
1365 ACE_Process_Options process_options;
1367 // Set the command line for the gperf program.
1368 process_options.command_line (ACE_TEXT ("\"%s\" -V"),
1369 this->gperf_path_);
1371 // Spawn a process for gperf.
1372 if (process.spawn (process_options) == -1)
1374 return -1;
1377 #if defined (ACE_WIN32)
1378 // No wait or anything in Win32.
1379 return 0;
1380 #else
1381 // Wait for gperf to complete.
1382 ACE_exitcode wait_status = 0;
1383 if (process.wait (&wait_status) == -1)
1385 return -1;
1387 else
1389 // Wait is successful, we will check the exit code from the
1390 // spawned process.
1391 if (WIFEXITED (wait_status))
1393 // Normal exit.
1395 // Check the exit value of the spawned process. ACE_Process
1396 // exits with <errno> as exit code, if it is not able to
1397 // exec gperf program, so get the exit code now and set that
1398 // to <errno> again, so that it can be used to print error
1399 // messages.
1400 errno = WEXITSTATUS (wait_status);
1402 if (errno)
1404 // <exec> has failed.
1405 return -1;
1407 else
1409 // Everything was alright.
1410 return 0;
1413 else
1415 // Not a normal exit. No <errno> might be set.
1416 return -1;
1419 #endif /* ACE_WIN32 */
1422 void
1423 IDL_GlobalData::fini ()
1425 if (0 != this->pd_root)
1427 this->pd_root->fini ();
1428 delete this->pd_root;
1429 this->pd_root = 0;
1432 delete this->pd_err;
1433 this->pd_err = 0;
1434 delete this->pd_gen;
1435 this->pd_gen = 0;
1436 delete this->pd_indent;
1437 this->pd_indent = 0;
1438 delete [] this->pd_local_escapes;
1439 this->pd_local_escapes = 0;
1440 delete [] this->tao_root_;
1441 this->tao_root_ = 0;
1442 delete [] this->gperf_path_;
1443 this->gperf_path_ = 0;
1444 delete [] this->temp_dir_;
1445 this->temp_dir_ = 0;
1446 delete [] this->ident_string_;
1447 this->ident_string_ = 0;
1448 delete [] this->pd_include_file_names;
1449 this->pd_include_file_names = 0;
1451 Include_Path_Info *path_info = 0;
1453 for (Unbounded_Paths_Queue_Iterator qiter (this->include_paths_);
1454 qiter.done () == 0;
1455 qiter.advance ())
1457 qiter.next (path_info);
1458 ACE::strdelete (path_info->path_);
1461 char **path_tmp = 0;
1463 for (ACE_Unbounded_Queue_Iterator<char *>riter (
1464 this->rel_include_paths_
1466 riter.done () == 0;
1467 riter.advance ())
1469 riter.next (path_tmp);
1470 ACE::strdelete (*path_tmp);
1473 for (ACE_Unbounded_Queue_Iterator<char *>iter1 (
1474 this->ciao_lem_file_names_);
1475 iter1.done () == 0;
1476 iter1.advance ())
1478 iter1.next (path_tmp);
1479 ACE::strdelete (*path_tmp);
1482 for (ACE_Unbounded_Queue_Iterator<char *>iter2 (
1483 this->ciao_rti_ts_file_names_);
1484 iter2.done () == 0;
1485 iter2.advance ())
1487 iter2.next (path_tmp);
1488 ACE::strdelete (*path_tmp);
1491 for (ACE_Unbounded_Queue_Iterator<char *>iter3 (
1492 this->ciao_spl_ts_file_names_);
1493 iter3.done () == 0;
1494 iter3.advance ())
1496 iter3.next (path_tmp);
1497 ACE::strdelete (*path_tmp);
1500 for (ACE_Unbounded_Queue_Iterator<char *>iter4 (
1501 this->ciao_oci_ts_file_names_);
1502 iter4.done () == 0;
1503 iter4.advance ())
1505 iter4.next (path_tmp);
1506 ACE::strdelete (*path_tmp);
1509 for (ACE_Unbounded_Queue_Iterator<char *>iter5 (
1510 this->ciao_ami_iface_names_);
1511 iter5.done () == 0;
1512 iter5.advance ())
1514 iter5.next (path_tmp);
1515 ACE::strdelete (*path_tmp);
1518 for (ACE_Unbounded_Queue_Iterator<char *>iter6 (
1519 this->ciao_ami_recep_names_);
1520 iter6.done () == 0;
1521 iter6.advance ())
1523 iter6.next (path_tmp);
1524 ACE::strdelete (*path_tmp);
1527 for (ACE_Unbounded_Queue_Iterator<char *>iter7 (
1528 this->included_ami_recep_names_);
1529 iter7.done () == 0;
1530 iter7.advance ())
1532 iter7.next (path_tmp);
1533 ACE::strdelete (*path_tmp);
1536 for (ACE_Unbounded_Queue_Iterator<char *>iter8 (
1537 this->ciao_ami_idl_fnames_);
1538 iter8.done () == 0;
1539 iter8.advance ())
1541 iter8.next (path_tmp);
1542 ACE::strdelete (*path_tmp);
1545 for (ACE_Unbounded_Queue_Iterator<char *>iter9 (
1546 this->dds4ccm_impl_fnames_);
1547 iter9.done () == 0;
1548 iter9.advance ())
1550 iter9.next (path_tmp);
1551 ACE::strdelete (*path_tmp);
1554 for (ACE_Unbounded_Queue_Iterator<char *>iter10 (
1555 this->dcps_sequence_types_list_);
1556 iter10.done () == 0;
1557 iter10.advance ())
1559 iter10.next (path_tmp);
1560 ACE::strdelete (*path_tmp);
1564 ACE_Hash_Map_Entry<char *, char *> *entry = 0;
1566 for (ACE_Hash_Map_Iterator<char *, char *, ACE_Null_Mutex> hiter (
1567 this->file_prefixes_
1569 !hiter.done ();
1570 hiter.advance ())
1572 hiter.next (entry);
1573 ACE::strdelete (entry->ext_id_);
1574 ACE::strdelete (entry->int_id_);
1577 DCPS_Type_Info_Map::ENTRY *dcps_entry = 0;
1579 for (DCPS_Type_Info_Map::ITERATOR dcps_iter (
1580 this->dcps_type_info_map_);
1581 !dcps_iter.done ();
1582 dcps_iter.advance ())
1584 dcps_iter.next (dcps_entry);
1586 dcps_entry->int_id_->name_->destroy ();
1587 delete dcps_entry->int_id_->name_;
1588 dcps_entry->int_id_->name_ = 0;
1590 delete dcps_entry->int_id_;
1591 dcps_entry->int_id_ = 0;
1593 delete [] dcps_entry->ext_id_;
1594 dcps_entry->ext_id_ = 0;
1598 ACE_Unbounded_Queue<AST_ValueType *> &
1599 IDL_GlobalData::primary_keys ()
1601 return this->primary_keys_;
1604 void
1605 IDL_GlobalData::check_primary_keys ()
1607 AST_ValueType *holder = 0;
1609 while (!this->primary_keys_.is_empty ())
1611 // Dequeue the element at the head of the queue.
1612 if (this->primary_keys_.dequeue_head (holder) != 0)
1614 ACE_ERROR ((LM_ERROR,
1615 "(%N:%l) idl_global::check_primary_keys - "
1616 "dequeue_head failed\n"));
1617 throw Bailout ();
1620 if (!holder->legal_for_primary_key ())
1622 this->pd_err->illegal_primary_key (holder);
1627 const char *
1628 IDL_GlobalData::recursion_start () const
1630 return this->recursion_start_;
1633 void
1634 IDL_GlobalData::recursion_start (const char *val)
1636 ACE::strdelete (this->recursion_start_);
1638 /// Strip off any trailing slashes (not needed
1639 /// for further processing).
1640 ACE_CString tmp (val);
1641 ACE_CString::size_type len = tmp.length ();
1642 ACE_TCHAR c = tmp[len - 1];
1644 while (c == '\\' || c == '/')
1646 tmp = tmp.substr (0, --len);
1647 c = tmp[len - 1];
1650 this->recursion_start_ = ACE::strnew (tmp.c_str ());
1653 bool
1654 IDL_GlobalData::multi_file_input () const
1656 return this->multi_file_input_;
1659 void
1660 IDL_GlobalData::multi_file_input (bool val)
1662 this->multi_file_input_ = val;
1665 const char *
1666 IDL_GlobalData::big_file_name () const
1668 return this->big_file_name_;
1671 FE_Utils::T_PARAMLIST_INFO const *
1672 IDL_GlobalData::current_params () const
1674 return this->current_params_;
1677 void
1678 IDL_GlobalData::current_params (
1679 FE_Utils::T_PARAMLIST_INFO *params)
1681 this->current_params_ = params;
1684 UTL_StrList const *
1685 IDL_GlobalData::alias_params () const
1687 return this->alias_params_;
1690 void
1691 IDL_GlobalData::alias_params (
1692 UTL_StrList *params)
1694 this->alias_params_ = params;
1697 UTL_StrList const *
1698 IDL_GlobalData::for_new_holder () const
1700 return this->for_new_holder_;
1703 void
1704 IDL_GlobalData::for_new_holder (
1705 UTL_StrList *params)
1707 this->for_new_holder_ = params;
1710 void
1711 IDL_GlobalData::set_dcps_sequence_type (const char* seq_type)
1713 this->dcps_sequence_types_list_.enqueue_tail (ACE::strnew (seq_type));
1716 bool
1717 IDL_GlobalData::dcps_sequence_type_defined (const char* seq_type)
1719 char **tmp = 0;
1721 for (ACE_Unbounded_Queue_Iterator<char *>riter (
1722 this->dcps_sequence_types_list_);
1723 riter.done () == 0;
1724 riter.advance ())
1726 riter.next (tmp);
1727 if (ACE_OS::strcmp (*tmp, seq_type) == 0)
1728 return true;
1730 return false;
1733 void
1734 IDL_GlobalData::add_dcps_data_type (const char* id)
1736 // Check if the type already exists.
1737 DCPS_Data_Type_Info* newinfo ;
1739 if (this->dcps_type_info_map_.find (id, newinfo) != 0)
1741 // No existing entry, add one.
1743 char* foo_type;
1744 ACE_NEW (foo_type, char [ACE_OS::strlen (id) + 1]);
1745 ACE_OS::strcpy (foo_type, id);
1747 UTL_ScopedName* t1 =
1748 FE_Utils::string_to_scoped_name (foo_type);
1750 // Chained with null Identifier required!!
1751 UTL_ScopedName* target =
1752 new UTL_ScopedName (new Identifier (""), t1);
1754 newinfo = new DCPS_Data_Type_Info ();
1755 newinfo->name_ = target;
1757 // Add the newly formed entry to the map.
1758 if (this->dcps_type_info_map_.bind (foo_type, newinfo) != 0)
1760 ACE_ERROR ((LM_ERROR,
1761 ACE_TEXT ("Unable to insert type into ")
1762 ACE_TEXT ("DCPS type container: %s.\n"),
1763 id));
1764 return;
1767 else
1769 ACE_ERROR ((LM_WARNING,
1770 ACE_TEXT ("Duplicate DCPS type defined: %s.\n"),
1771 id));
1775 bool
1776 IDL_GlobalData::add_dcps_data_key (const char* id, const char* key)
1778 // Search the map for the type.
1779 DCPS_Data_Type_Info* newinfo = 0;
1781 if (this->dcps_type_info_map_.find (id, newinfo) == 0)
1783 // Add the new key field to the type.
1784 newinfo->key_list_.enqueue_tail (ACE_TEXT_CHAR_TO_TCHAR (key));
1785 return true;
1787 else
1789 ACE_ERROR ((LM_ERROR,
1790 ACE_TEXT ("missing previous #pragma ")
1791 ACE_TEXT ("DCPS_DATA_TYPE\n")));
1794 return false;
1797 IDL_GlobalData::DCPS_Data_Type_Info*
1798 IDL_GlobalData::is_dcps_type (UTL_ScopedName* target)
1800 // Traverse the entire map.
1801 DCPS_Type_Info_Map::ENTRY* entry ;
1803 for (DCPS_Type_Info_Map::ITERATOR current (
1804 this->dcps_type_info_map_);
1805 current.next (entry);
1806 current.advance ())
1808 // Look for our Identifier.
1809 if (0 == entry->int_id_->name_->compare (target))
1811 // Found it!
1812 return entry->int_id_;
1816 // No joy.
1817 return 0;
1820 AST_Module *
1821 IDL_GlobalData::corba_module () const
1823 return this->corba_module_;
1826 void
1827 IDL_GlobalData::corba_module (AST_Module *m)
1829 this->corba_module_ = m;
1832 IDL_GlobalData::Unbounded_Paths_Queue &
1833 IDL_GlobalData::include_paths ()
1835 return this->include_paths_;
1838 void
1839 IDL_GlobalData::anon_type_diagnostic (
1840 IDL_GlobalData::ANON_TYPE_DIAGNOSTIC val)
1842 anon_type_diagnostic_ = val;
1843 explicit_anon_type_diagnostic_ = true;
1846 bool
1847 IDL_GlobalData::explicit_anon_type_diagnostic () const
1849 return explicit_anon_type_diagnostic_;
1852 bool
1853 IDL_GlobalData::anon_error () const
1855 if (idl_version_ >= IDL_VERSION_4 && !explicit_anon_type_diagnostic_) {
1856 return false;
1858 return anon_type_diagnostic_ == ANON_TYPE_ERROR;
1861 bool
1862 IDL_GlobalData::anon_warning () const
1864 if (idl_version_ >= IDL_VERSION_4 && !explicit_anon_type_diagnostic_) {
1865 return false;
1867 return anon_type_diagnostic_ == ANON_TYPE_WARNING;
1870 bool
1871 IDL_GlobalData::anon_silent () const
1873 if (idl_version_ >= IDL_VERSION_4 && !explicit_anon_type_diagnostic_) {
1874 return true;
1876 return anon_type_diagnostic_ == ANON_TYPE_SILENT;
1879 bool
1880 IDL_GlobalData::in_typedef () const
1882 return this->in_typedef_;
1885 void
1886 IDL_GlobalData::in_typedef (bool val)
1888 this->in_typedef_ = val;
1891 bool
1892 IDL_GlobalData::in_tmpl_mod_no_alias () const
1894 return this->in_tmpl_mod_no_alias_;
1897 void
1898 IDL_GlobalData::in_tmpl_mod_no_alias (bool val)
1900 this->in_tmpl_mod_no_alias_ = val;
1903 bool
1904 IDL_GlobalData::in_tmpl_mod_alias () const
1906 return this->in_tmpl_mod_alias_;
1909 void
1910 IDL_GlobalData::in_tmpl_mod_alias (bool val)
1912 this->in_tmpl_mod_alias_ = val;
1915 void
1916 IDL_GlobalData::parse_args_exit (int status)
1918 parse_args_exit_ = true;
1919 parse_args_exit_status_ = status;
1922 void
1923 IDL_GlobalData::print_help ()
1925 print_help_ = true;
1926 parse_args_exit (0);
1929 void
1930 IDL_GlobalData::print_version ()
1932 print_version_ = true;
1933 parse_args_exit (0);
1936 bool
1937 IDL_GlobalData::print_warnings ()
1939 return ! (idl_global->compile_flags () & IDL_CF_NOWARNINGS);
1943 * These are generated in idl.yy.cpp but they are not put in the header file,
1944 * so to use them we must declare them here.
1946 struct yy_buffer_state;
1947 extern yy_buffer_state *tao_yy_scan_string (const char *);
1948 extern int tao_yylex_destroy ();
1950 namespace
1952 class OldState
1954 public:
1955 explicit OldState (bool disable_output = false)
1956 : old_filename_ (idl_global->filename () ? new UTL_String (idl_global->filename (), true) : 0),
1957 // need a copy because IDL_GlobalData::set_filename() destroys previous value
1958 old_lineno_ (idl_global->lineno ()),
1959 old_idl_src_file_ (idl_global->idl_src_file ()),
1960 disable_output_ (disable_output),
1961 default_streambuf_ (ACE_DEFAULT_LOG_STREAM->rdbuf ()),
1962 flags_ (ACE_LOG_MSG->flags ())
1964 idl_global->in_eval_ = true;
1966 idl_global->set_lineno (1);
1967 idl_global->set_filename (0);
1969 // Name this pseudo-file "builtin-N"
1970 static char buffer[64];
1971 static unsigned n = 1;
1972 ACE_OS::snprintf (&buffer[0], sizeof buffer, "builtin-%u", n++);
1973 UTL_String pseudo_filename (&buffer[0], true);
1975 idl_global->idl_src_file (new UTL_String (&pseudo_filename, true));
1976 idl_global->set_filename (new UTL_String (&pseudo_filename, true));
1978 if (disable_output_)
1980 ACE_DEFAULT_LOG_STREAM->rdbuf (0);
1981 ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR);
1982 ACE_LOG_MSG->clr_flags (ACE_LOG_MSG->flags ());
1986 ~OldState()
1988 idl_global->set_lineno (old_lineno_);
1990 idl_global->set_filename (old_filename_);
1991 idl_global->idl_src_file ()->destroy ();
1992 delete idl_global->idl_src_file ();
1993 idl_global->idl_src_file (old_idl_src_file_);
1994 idl_global->reset_flag_seen ();
1996 if (disable_output_)
1998 ACE_DEFAULT_LOG_STREAM->rdbuf (default_streambuf_);
1999 ACE_LOG_MSG->set_flags (flags_);
2002 tao_yylex_destroy ();
2003 idl_global->in_eval_ = false;
2006 private:
2007 UTL_String *const old_filename_;
2008 const long old_lineno_;
2009 UTL_String *const old_idl_src_file_;
2010 const bool disable_output_;
2011 std::streambuf *const default_streambuf_;
2012 const unsigned long flags_;
2016 void
2017 IDL_GlobalData::eval (const char *string, bool disable_output)
2019 OldState old (disable_output);
2021 // Set up Flex to read from string
2022 tao_yy_scan_string (string);
2024 // emulate DRV_drive()
2025 FE_yyparse ();
2026 idl_global->check_primary_keys ();
2027 AST_check_fwd_decls ();
2030 void
2031 IDL_GlobalData::dump_ast ()
2033 idl_global->set_compile_flags (idl_global->compile_flags ()
2034 | IDL_CF_DUMP_AST);