2 //=============================================================================
6 * Static helper methods used by multiple visitors.
11 //=============================================================================
14 #include "be_helper.h"
15 #include "be_module.h"
17 #include "be_identifier_helper.h"
18 #include "be_extern.h"
19 #include "be_generator.h"
20 #include "be_codegen.h"
22 #include "utl_identifier.h"
23 #include "utl_string.h"
25 #include "ast_typedef.h"
26 #include "ast_structure.h"
27 #include "ast_structure_fwd.h"
28 #include "ast_string.h"
30 #include "ace/OS_NS_string.h"
33 be_util::gen_nested_namespace_begin (TAO_OutStream
*os
,
37 char *item_name
= nullptr;
38 bool first_level
= true;
40 for (UTL_IdListActiveIterator
i (node
->name ());
44 item_name
= i
.item ()->get_string ();
46 if (ACE_OS::strcmp (item_name
, "") != 0)
48 // Leave the outermost root scope.
49 *os
<< be_nl
<< "namespace ";
51 if (first_level
&& skel
)
53 // We are outermost module.
58 *os
<< item_name
<< be_nl
65 be_util::gen_nested_namespace_end (TAO_OutStream
*os
,
68 for (UTL_IdListActiveIterator
i (node
->name ());
72 if (ACE_OS::strcmp (i
.item ()->get_string (), "") != 0)
74 // Leave the outermost root scope.
75 *os
<< be_uidt_nl
<< "}";
81 be_util::gen_nesting_open (TAO_OutStream
&os
, AST_Decl
*node
)
83 AST_Decl::NodeType nt
= node
->node_type ();
85 if (nt
== AST_Decl::NT_root
)
91 be_util::gen_nesting_open (
93 ScopeAsDecl (node
->defined_in ()));
95 if (nt
== AST_Decl::NT_module
)
97 ACE_CString
module_name (
98 IdentifierHelper::try_escape (node
->original_local_name ()));
101 << "module " << module_name
.c_str () << be_nl
107 be_util::gen_nesting_close (TAO_OutStream
&os
, AST_Decl
*node
)
109 AST_Decl
*d
= ScopeAsDecl (node
->defined_in ());
110 AST_Decl::NodeType nt
= d
->node_type ();
112 while (nt
!= AST_Decl::NT_root
)
117 d
= ScopeAsDecl (d
->defined_in ());
118 nt
= d
->node_type ();
122 // Prepare an argument for a BE
124 be_util::prep_be_arg (char *s
)
126 static const char arg_macro
[] = "export_macro=";
127 static const char arg_include
[] = "export_include=";
128 static const char skel_arg_macro
[] = "skel_export_macro=";
129 static const char skel_arg_include
[] = "skel_export_include=";
130 static const char skel_arg_file
[] = "skel_export_file=";
131 static const char stub_arg_macro
[] = "stub_export_macro=";
132 static const char stub_arg_include
[] = "stub_export_include=";
133 static const char stub_arg_file
[] = "stub_export_file=";
134 static const char anyop_arg_macro
[] = "anyop_export_macro=";
135 static const char anyop_arg_include
[] = "anyop_export_include=";
136 static const char exec_arg_macro
[] = "exec_export_macro=";
137 static const char exec_arg_include
[] = "exec_export_include=";
138 static const char svnt_arg_macro
[] = "svnt_export_macro=";
139 static const char svnt_arg_include
[] = "svnt_export_include=";
140 static const char conn_arg_macro
[] = "conn_export_macro=";
141 static const char conn_arg_include
[] = "conn_export_include=";
142 static const char arg_pch_include
[] = "pch_include=";
143 static const char arg_pre_include
[] = "pre_include=";
144 static const char arg_post_include
[] = "post_include=";
145 static const char arg_versioning_begin
[] = "versioning_begin=";
146 static const char arg_versioning_end
[] = "versioning_end=";
147 static const char arg_versioning_include
[] = "versioning_include=";
148 static const char obv_opt_accessor
[] = "obv_opt_accessor";
149 static const char ciao_container_type
[] = "ciao_container_type=";
150 static const char include_guard
[] = "include_guard=";
151 static const char safe_include
[] = "safe_include=";
152 static const char unique_include
[] = "unique_include=";
153 static const char dds_impl
[] = "dds_impl=";
154 static const char stripped_filename
[] = "stripped_filename=";
155 static const char no_fixed_err
[] = "no_fixed_err";
157 char* last
= nullptr;
159 for (char* arg
= ACE_OS::strtok_r (s
, ",", &last
);
161 arg
= ACE_OS::strtok_r (nullptr, ",", &last
))
163 if (ACE_OS::strstr (arg
, arg_macro
) == arg
)
165 char* val
= arg
+ sizeof (arg_macro
) - 1;
166 be_global
->skel_export_macro (val
);
167 be_global
->stub_export_macro (val
);
168 be_global
->anyop_export_macro (val
);
170 else if (ACE_OS::strstr (arg
, arg_include
) == arg
)
172 char* val
= arg
+ sizeof (arg_include
) - 1;
173 be_global
->stub_export_include (val
);
175 else if (ACE_OS::strstr (arg
, skel_arg_macro
) == arg
)
177 char* val
= arg
+ sizeof (skel_arg_macro
) - 1;
178 be_global
->skel_export_macro (val
);
180 else if (ACE_OS::strstr (arg
, skel_arg_include
) == arg
)
182 char* val
= arg
+ sizeof (skel_arg_include
) - 1;
183 be_global
->skel_export_include (val
);
185 else if (ACE_OS::strstr (arg
, skel_arg_file
) == arg
)
187 char* val
= arg
+ sizeof (skel_arg_file
) - 1;
188 be_global
->skel_export_file (val
);
190 else if (ACE_OS::strstr (arg
, stub_arg_macro
) == arg
)
192 char* val
= arg
+ sizeof (stub_arg_macro
) - 1;
193 be_global
->stub_export_macro (val
);
195 else if (ACE_OS::strstr (arg
, stub_arg_include
) == arg
)
197 char* val
= arg
+ sizeof (stub_arg_include
) - 1;
198 be_global
->stub_export_include (val
);
200 else if (ACE_OS::strstr (arg
, stub_arg_file
) == arg
)
202 char* val
= arg
+ sizeof (stub_arg_file
) - 1;
203 be_global
->stub_export_file (val
);
205 else if (ACE_OS::strstr (arg
, anyop_arg_macro
) == arg
)
207 char* val
= arg
+ sizeof (anyop_arg_macro
) - 1;
208 be_global
->anyop_export_macro (val
);
210 else if (ACE_OS::strstr (arg
, anyop_arg_include
) == arg
)
212 char* val
= arg
+ sizeof (anyop_arg_include
) - 1;
213 be_global
->anyop_export_include (val
);
215 else if (ACE_OS::strstr (arg
, exec_arg_macro
) == arg
)
217 char* val
= arg
+ sizeof (exec_arg_macro
) - 1;
218 be_global
->exec_export_macro (val
);
220 else if (ACE_OS::strstr (arg
, exec_arg_include
) == arg
)
222 char* val
= arg
+ sizeof (exec_arg_include
) - 1;
223 be_global
->exec_export_include (val
);
225 else if (ACE_OS::strstr (arg
, svnt_arg_macro
) == arg
)
227 char* val
= arg
+ sizeof (svnt_arg_macro
) - 1;
228 be_global
->svnt_export_macro (val
);
230 else if (ACE_OS::strstr (arg
, svnt_arg_include
) == arg
)
232 char* val
= arg
+ sizeof (svnt_arg_include
) - 1;
233 be_global
->svnt_export_include (val
);
235 else if (ACE_OS::strstr (arg
, conn_arg_macro
) == arg
)
237 char* val
= arg
+ sizeof (conn_arg_macro
) - 1;
238 be_global
->conn_export_macro (val
);
240 else if (ACE_OS::strstr (arg
, conn_arg_include
) == arg
)
242 char* val
= arg
+ sizeof (conn_arg_include
) - 1;
243 be_global
->conn_export_include (val
);
245 else if (ACE_OS::strstr (arg
, arg_pch_include
) == arg
)
247 char* val
= arg
+ sizeof (arg_pch_include
) - 1;
248 be_global
->pch_include (val
);
250 else if (ACE_OS::strstr (arg
, arg_pre_include
) == arg
)
252 char* val
= arg
+ sizeof (arg_pre_include
) - 1;
253 be_global
->pre_include (val
);
255 else if (ACE_OS::strstr (arg
, arg_post_include
) == arg
)
257 char* val
= arg
+ sizeof (arg_post_include
) - 1;
258 be_global
->post_include (val
);
260 else if (ACE_OS::strstr (arg
, include_guard
) == arg
)
262 char* val
= arg
+ sizeof (include_guard
) - 1;
263 be_global
->include_guard (val
);
265 else if (ACE_OS::strstr (arg
, safe_include
) == arg
)
267 char* val
= arg
+ sizeof (safe_include
) - 1;
268 be_global
->safe_include (val
);
270 else if (ACE_OS::strstr (arg
, unique_include
) == arg
)
272 char* val
= arg
+ sizeof (unique_include
) - 1;
273 be_global
->unique_include (val
);
275 else if (ACE_OS::strstr (arg
, stripped_filename
) == arg
)
277 char* val
= arg
+ sizeof (stripped_filename
) - 1;
278 be_global
->stripped_filename (val
);
280 else if (ACE_OS::strstr (arg
, obv_opt_accessor
) == arg
)
282 be_global
->obv_opt_accessor (true);
284 else if (ACE_OS::strstr (arg
, ciao_container_type
) == arg
)
286 char* val
= arg
+ sizeof (ciao_container_type
) - 1;
287 be_global
->ciao_container_type (val
);
289 else if (ACE_OS::strstr (arg
, arg_versioning_begin
) == arg
)
291 char const * const val
=
292 arg
+ sizeof (arg_versioning_begin
) - 1;
293 be_global
->versioning_begin (val
);
295 else if (ACE_OS::strstr (arg
, arg_versioning_end
) == arg
)
297 char const * const val
=
298 arg
+ sizeof (arg_versioning_end
) - 1;
299 be_global
->versioning_end (val
);
301 else if (ACE_OS::strstr (arg
, arg_versioning_include
) == arg
)
303 char const * const val
=
304 arg
+ sizeof (arg_versioning_include
) - 1;
305 be_global
->versioning_include (val
);
307 else if (ACE_OS::strstr (arg
, dds_impl
) == arg
)
309 char const * const val
=
310 arg
+ sizeof (dds_impl
) - 1;
311 be_global
->dds_impl (val
);
313 else if (ACE_OS::strstr (arg
, no_fixed_err
) == arg
)
315 be_global
->no_fixed_err (true);
319 ACE_ERROR ((LM_ERROR
,
320 ACE_TEXT ("%C: invalid or unknown ")
321 ACE_TEXT ("argument <%C> to back end\n"),
322 idl_global
->prog_name (),
329 be_util::arg_post_proc ()
331 // Let us try to use Perfect Hashing Operation Lookup Strategy. Let
332 // us check whether things are fine with GPERF.
333 #if defined (ACE_HAS_GPERF) && !defined (ACE_USES_WCHAR)
334 // If Perfect Hashing or Binary Search or Linear Search strategies
335 // have been selected, let us make sure that it exists and will
337 if ((be_global
->lookup_strategy () == BE_GlobalData::TAO_PERFECT_HASH
) ||
338 (be_global
->lookup_strategy () == BE_GlobalData::TAO_BINARY_SEARCH
) ||
339 (be_global
->lookup_strategy () == BE_GlobalData::TAO_LINEAR_SEARCH
))
341 // Testing whether GPERF works or no.
342 if (idl_global
->check_gperf () == -1)
344 // If gperf_path is an absolute path, try to call this
348 ACE_TEXT ("TAO_IDL: warning, GPERF could not be executed\n")
349 ACE_TEXT ("Perfect Hashing or Binary/Linear Search cannot be")
350 ACE_TEXT (" done without GPERF\n")
351 ACE_TEXT ("Now, using Dynamic Hashing..\n")
352 ACE_TEXT ("To use Perfect Hashing or Binary/Linear")
353 ACE_TEXT (" Search strategy\n")
354 ACE_TEXT ("\t-Build gperf at $ACE_ROOT/apps/gperf/src\n")
355 ACE_TEXT ("\t-Set the environment variable $ACE_ROOT")
356 ACE_TEXT (" appropriately or add $ACE_ROOT/bin to the PATH\n")
357 ACE_TEXT ("\t-Refer to Operation Lookup section in the TAO IDL")
358 ACE_TEXT (" User Guide ($TAO_ROOT/docs/compiler.html)")
359 ACE_TEXT (" for more details\n")
362 // Switching over to Dynamic Hashing.
363 be_global
->lookup_strategy (BE_GlobalData::TAO_DYNAMIC_HASH
);
366 #else /* Not ACE_HAS_GPERF */
367 // If GPERF is not there, we cannot use PERFECT_HASH strategy. Let
368 // us go for DYNAMIC_HASH.
369 if ((be_global
->lookup_strategy () == BE_GlobalData::TAO_PERFECT_HASH
) ||
370 (be_global
->lookup_strategy () == BE_GlobalData::TAO_BINARY_SEARCH
) ||
371 (be_global
->lookup_strategy () == BE_GlobalData::TAO_LINEAR_SEARCH
))
373 be_global
->lookup_strategy (BE_GlobalData::TAO_DYNAMIC_HASH
);
375 #endif /* ACE_HAS_GPERF */
377 // Make sure that we are not suppressing TypeCode generation and asking for
378 // optimized typecode support at the same time.
379 if (!be_global
->tc_support () && be_global
->opt_tc ())
381 ACE_ERROR ((LM_ERROR
,
382 ACE_TEXT ("Bad Combination -St and -Gt\n")));
391 ACE_TEXT (" -Wb,export_macro=<macro name>\t\t\tsets export macro ")
392 ACE_TEXT ("for all files\n")
396 ACE_TEXT (" -Wb,export_include=<include path>\t\tsets export include ")
397 ACE_TEXT ("file for all files\n")
401 ACE_TEXT (" -Wb,stub_export_macro=<macro name>\t\tsets export ")
402 ACE_TEXT ("macro for client files only\n")
406 ACE_TEXT (" -Wb,stub_export_include=<include path>\t\tsets export ")
407 ACE_TEXT ("include file for client only\n")
411 ACE_TEXT (" -Wb,stub_export_file=<filename>\t\tsets export ")
412 ACE_TEXT ("file for client only\n")
416 ACE_TEXT (" -Wb,skel_export_macro=<macro name>\t\tsets export ")
417 ACE_TEXT ("macro for server files only\n")
421 ACE_TEXT (" -Wb,skel_export_include=<include path>\t\tsets export ")
422 ACE_TEXT ("include file for server only\n")
426 ACE_TEXT (" -Wb,skel_export_file=<include path>\t\tsets export ")
427 ACE_TEXT ("file for server only\n")
431 ACE_TEXT (" -Wb,anyop_export_macro=<macro name>\t\tsets export macro ")
432 ACE_TEXT ("for typecode/Any operator files only, when -GA option ")
433 ACE_TEXT ("is used\n")
437 ACE_TEXT (" -Wb,anyop_export_include=<include path>\tsets export ")
438 ACE_TEXT ("include file for typecode/Any operator files only, when -GA ")
439 ACE_TEXT ("option is used\n")
443 ACE_TEXT (" -Wb,svnt_export_macro=<macro name>\t\tsets export macro ")
444 ACE_TEXT ("for CIAO servant files only, when -Gsv option ")
445 ACE_TEXT ("is used\n")
449 ACE_TEXT (" -Wb,svnt_export_include=<include path>\t\tsets export ")
450 ACE_TEXT ("include file for CIAO servant files only, when -Gsv ")
451 ACE_TEXT ("option is used\n")
455 ACE_TEXT (" -Wb,exec_export_macro=<macro name>\t\tsets export macro ")
456 ACE_TEXT ("for CIAO executor impl files only, when -Gex option ")
457 ACE_TEXT ("is used\n")
461 ACE_TEXT (" -Wb,exec_export_include=<include path>\t\tsets export ")
462 ACE_TEXT ("include file for CIAO executor impl files only, when -Gex ")
463 ACE_TEXT ("option is used\n")
467 ACE_TEXT (" -Wb,conn_export_macro=<macro name>\t\tsets export macro ")
468 ACE_TEXT ("for CIAO connector impl files only, when -Gcn option ")
469 ACE_TEXT ("is used\n")
473 ACE_TEXT (" -Wb,conn_export_include=<include path>\t\tsets export ")
474 ACE_TEXT ("include file for CIAO connector impl files only, when -Gcn ")
475 ACE_TEXT ("option is used\n")
479 ACE_TEXT (" -Wb,pch_include=<include path>\t\t\tsets include ")
480 ACE_TEXT ("file for precompiled header mechanism\n")
484 ACE_TEXT (" -Wb,pre_include=<include path>\t\t\tsets include ")
485 ACE_TEXT ("file generate before any other includes\n")
489 ACE_TEXT (" -Wb,post_include=<include path>\t\tsets include ")
490 ACE_TEXT ("file generated at the end of the file\n")
494 ACE_TEXT (" -Wb,include_guard=<include path>\t\tguard to prevent ")
495 ACE_TEXT ("the generated client header file\n")
499 ACE_TEXT (" -Wb,safe_include=<include path>\t\tinclude that should ")
500 ACE_TEXT ("be used instead of the own generated client header file\n")
504 ACE_TEXT (" -Wb,unique_include=<include path>\t\tinclude that should ")
505 ACE_TEXT ("be generated as only contents of the generated client ")
506 ACE_TEXT ("header file.\n")
510 ACE_TEXT (" -Wb,stripped_filename=<filename>\t\tfilename that should ")
511 ACE_TEXT ("be used as stripped_filename instead of input filename.\n")
515 ACE_TEXT (" -Wb,container_type=<type>\t\t\ttype of container we generated\n")
519 ACE_TEXT (" -Wb,obv_opt_accessor\t\t\t\toptimizes access to base class ")
520 ACE_TEXT ("data in valuetypes\n")
524 ACE_TEXT (" -Wb,versioning_begin\t\t\tSet text that opens a ")
525 ACE_TEXT ("a \"versioned\" namespace\n")
529 ACE_TEXT (" -Wb,versioning_end\t\t\tSet text that closes a ")
530 ACE_TEXT ("a \"versioned\" namespace\n")
534 ACE_TEXT (" -Wb,versioning_include\t\t\tSet text that will be used as include for ")
535 ACE_TEXT ("a \"versioned\" namespace\n")
539 ACE_TEXT (" -Wb,no_fixed_err\t\t\tDon't generate an error when the fixed")
540 ACE_TEXT (" type is used\n")
544 ACE_TEXT (" -b\t\t\tUse a clonable argument type for oneway methods.\n")
548 ACE_TEXT (" -ci\t\t\tClient inline file name ending. Default is C.inl\n")
552 ACE_TEXT (" -cs\t\t\tClient stub's file name ending.")
553 ACE_TEXT (" Default is C.cpp\n")
557 ACE_TEXT (" -g <gperf_path>\tPath for the GPERF program.")
558 ACE_TEXT (" Default is $ACE_ROOT/bin/ace_gperf\n")));
561 ACE_TEXT (" -GC \t\t\tGenerate the AMI classes\n")
565 ACE_TEXT (" -GH \t\t\tGenerate the AMH classes\n")
569 ACE_TEXT (" -GM \t\t\tGenerate the AMI4CCM classes\n")
573 ACE_TEXT (" -Gce \t\t\tGenerate code optimized for CORBA/e\n")
577 ACE_TEXT (" -Gmc \t\t\tGenerate code optimized for Minimum CORBA\n")
581 ACE_TEXT (" -Gcl \t\t\tGenerate code optimized for LwCCM\n")
585 ACE_TEXT (" -Gcm \t\t\tGenerate code optimized for noevent CCM\n")
589 ACE_TEXT (" -Gd \t\t\tGenerate the code for direct collocation. Default ")
590 ACE_TEXT ("is thru-POA collocation\n")
594 ACE_TEXT (" -Gos \t\t\tGenerate std::ostream insertion operators.\n")
598 ACE_TEXT (" -GI[h|s|b|e|c|a|d]\tGenerate Implementation Files\n")
602 ACE_TEXT (" \t\t\th - Implementation header file name ending.")
603 ACE_TEXT (" Default is I.h\n")
607 ACE_TEXT (" \t\t\ts - Implementation skeleton file name ending.")
608 ACE_TEXT (" Default is I.cpp\n")
612 ACE_TEXT (" \t\t\tb - Prefix to the implementation class names.")
613 ACE_TEXT (" Default is 'no prefix'\n")
617 ACE_TEXT (" \t\t\te - Suffix to the implementation class names.")
618 ACE_TEXT (" Default is _i\n")
622 ACE_TEXT (" \t\t\tc - Generate copy constructors in the servant")
623 ACE_TEXT (" implementation template files (off by default)\n")
627 ACE_TEXT (" \t\t\ta - Generate assignment operators in the servant")
628 ACE_TEXT (" implementation template files (off by default)\n")
632 ACE_TEXT (" \t\t\td - Generate debug (source file/line#) information.")
633 ACE_TEXT (" (off by default)\n")
637 ACE_TEXT (" -Gp \t\t\tGenerate the code for thru-POA collocation")
638 ACE_TEXT (" (default)\n")
642 ACE_TEXT (" -Gsp\t\t\tGenerate the code for Smart Proxies\n")
646 ACE_TEXT (" -Gstl\t\t\tGenerate the alternate C++ mapping for")
647 ACE_TEXT (" IDL strings and sequences\n")
651 ACE_TEXT (" -Gt\t\t\tenable optimized TypeCode support")
652 ACE_TEXT (" (unopt by default)\n")
656 ACE_TEXT (" -GT\t\t\tgenerate tie class (and file)")
657 ACE_TEXT (" generation (disabled by default)\n")
661 ACE_TEXT (" \t\t\tNo effect if TypeCode generation is suppressed\n")
665 ACE_TEXT (" -GA\t\t\tgenerate Any operator and type codes in *A.{h,cpp}")
666 ACE_TEXT (" (generated in *C.{h,cpp} by default)\n")
670 ACE_TEXT (" -Guc\t\t\tgenerate uninlined constant if declared ")
671 ACE_TEXT ("in a module (inlined by default)\n")
675 ACE_TEXT (" -Gsd\t\t\tgenerate static description operations which can ")
676 ACE_TEXT ("be useful for template programming (not generated by default)\n")
680 ACE_TEXT (" -Gse\t\t\tgenerate explicit export of sequence's ")
681 ACE_TEXT ("template base class (not generated by default)\n")
685 ACE_TEXT (" -Gsv\t\t\tgenerate CIAO servant code ")
686 ACE_TEXT ("(not generated by default)\n")
690 ACE_TEXT (" -Glem\t\t\tgenerate CIAO executor IDL ")
691 ACE_TEXT ("(not generated by default)\n")
695 ACE_TEXT (" -Gex\t\t\tgenerate CIAO executor implementation ")
696 ACE_TEXT ("code (not generated by default)\n")
700 ACE_TEXT (" -Gexr\t\t\tgenerate CIAO executor implementation ")
701 ACE_TEXT ("code with an ACE_Reactor implementation (not generated by default)\n")
705 ACE_TEXT (" -Gcn\t\t\tgenerate CIAO connector implementation ")
706 ACE_TEXT ("code (not generated by default)\n")
710 ACE_TEXT (" -Gts\t\t\tgenerate DDS type support IDL ")
711 ACE_TEXT ("(not generated by default)\n")
715 ACE_TEXT (" -Gxhst\t\t\tgenerate export header file ")
716 ACE_TEXT ("for stub (not generated by default)\n")
720 ACE_TEXT (" -Gxhsk\t\t\tgenerate export header file ")
721 ACE_TEXT ("for skeleton (not generated by default)\n")
725 ACE_TEXT (" -Gxhsv\t\t\tgenerate export header file ")
726 ACE_TEXT ("for CIAO servant (not generated by default)\n")
730 ACE_TEXT (" -Gxhex\t\t\tgenerate export header file ")
731 ACE_TEXT ("for CIAO executor (not generated by default)\n")
735 ACE_TEXT (" -Gxhcn\t\t\tgenerate export header file ")
736 ACE_TEXT ("for CIAO connector (not generated by default)\n")
740 ACE_TEXT (" -GX\t\t\tgenerate empty A.h file\n")
744 ACE_TEXT (" -hc\t\t\tClient's header file name ending.")
745 ACE_TEXT (" Default is C.h\n")
749 ACE_TEXT (" -hs\t\t\tServer's header file name ending.")
750 ACE_TEXT (" Default is S.h\n")
754 ACE_TEXT (" -hT\t\t\tServer's template hdr file name ending.")
755 ACE_TEXT (" Default is S_T.h\n")
759 ACE_TEXT (" -H perfect_hash\tTo force perfect hashed operation")
760 ACE_TEXT (" lookup strategy (default)\n")
764 ACE_TEXT (" -H dynamic_hash\tTo force dynamic hashed operation")
765 ACE_TEXT (" lookup strategy. Default is perfect hashing\n")
769 ACE_TEXT (" -H linear_search\tTo force linear search operation")
770 ACE_TEXT (" lookup strategy\n")
774 ACE_TEXT (" -H binary_search\tTo force binary search operation")
775 ACE_TEXT (" lookup strategy\n")
779 ACE_TEXT (" -in \t\t\tTo generate <>s for standard #include'd")
780 ACE_TEXT (" files (non-changing files)\n")
784 ACE_TEXT (" -ic \t\t\tTo generate \"\"s for standard #include'd")
785 ACE_TEXT (" files (changing files)\n")
789 ACE_TEXT (" -iC <path>\t\tInclude path for the generated stub files ")
790 ACE_TEXT ("in *A.h. Can be relative to $TAO_ROOT or $CIAO_ROOT. ")
791 ACE_TEXT ("Default is $TAO_ROOT/tao or current directory\n")
795 ACE_TEXT (" -o <output_dir>\tOutput directory for the generated files.")
796 ACE_TEXT (" Default is current directory\n")
800 ACE_TEXT (" -oS <output_dir>\tOutput directory for the generated ")
801 ACE_TEXT ("skeleton files. Default is -o value or current directory\n")
805 ACE_TEXT (" -oA <output_dir>\tOutput directory for the generated anyop")
806 ACE_TEXT ("files. Default is -o value or current directory\n")
810 ACE_TEXT (" -oE <output_dir>\tOutput directory for the generated ")
811 ACE_TEXT ("executor files, only when -Gex option is used.")
812 ACE_TEXT (" Default is current directory\n")
816 ACE_TEXT (" -oN\tWhen -Gex option is used, executor files shouldn't be overwritten ")
817 ACE_TEXT ("if they are already in the output directory.\n")
821 ACE_TEXT (" -ss\t\t\tServer's skeleton file name ending.")
822 ACE_TEXT (" Default is S.cpp\n")
826 ACE_TEXT (" -sT\t\t\tServer's template skeleton file name ending.")
827 ACE_TEXT (" Default is S_T.cpp\n")
831 ACE_TEXT (" -Sa\t\t\tsuppress Any support")
832 ACE_TEXT (" (support enabled by default)\n")
836 ACE_TEXT (" -Sal\t\t\tsuppress Any support")
837 ACE_TEXT (" for local interfaces")
838 ACE_TEXT (" (support enabled by default)\n")
842 ACE_TEXT (" -Scdr\t\t\tsuppress CDR support")
843 ACE_TEXT (" (support enabled by default)\n")
847 ACE_TEXT (" -Sat\t\t\tsuppress arg traits")
848 ACE_TEXT (" generation")
849 ACE_TEXT (" (arg traits generated by default)\n")
853 ACE_TEXT (" -St\t\t\tsuppress TypeCode support")
854 ACE_TEXT (" (support enabled by default)\n")
858 ACE_TEXT (" -Sp\t\t\tsuppress generating Thru POA collocated")
859 ACE_TEXT (" stubs (enabled by default)\n")
863 ACE_TEXT (" -Sd\t\t\tsuppress generating Direct collocated")
864 ACE_TEXT (" stubs (disable by default)\n")
868 ACE_TEXT (" -Sm\t\t\tdisable IDL3 equivalent IDL preprocessing")
869 ACE_TEXT (" (enabled by default)\n")
873 ACE_TEXT (" -SS\t\t\tsuppress generating skeleton implementation")
874 ACE_TEXT (" (disabled by default)\n")
878 ACE_TEXT (" -Ssvntc\t\tsuppress generating servant implementation")
879 ACE_TEXT (" (disabled by default)\n")
883 ACE_TEXT (" -Ssvntt\t\tsuppress generating servant template files")
884 ACE_TEXT (" (disabled by default)\n")
888 ACE_TEXT (" -Sci\t\t\tsuppress generating client inline file")
889 ACE_TEXT (" (disabled by default)\n")
893 ACE_TEXT (" -Sch\t\t\tsuppress generating client header file")
894 ACE_TEXT (" (disabled by default)\n")
898 ACE_TEXT (" -Scc\t\t\tsuppress generating client source file")
899 ACE_TEXT (" (disabled by default)\n")
903 ACE_TEXT (" -Ssh\t\t\tsuppress generating skeleton header")
904 ACE_TEXT (" (disabled by default)\n")
908 ACE_TEXT (" -Sorb\t\t\tsuppress generating include of ORB.h")
909 ACE_TEXT (" (disabled by default)\n")
913 ACE_TEXT (" -Sfr\t\t\tsuppress generating valuetype factory")
914 ACE_TEXT (" registration in CIAO (generated by default)\n")
918 ACE_TEXT (" -Se\t\t\tdisable custom header file name endings")
919 ACE_TEXT (" for files\n\t\t\t")
920 ACE_TEXT ("that are found in TAO specific include directories,\n\t\t\t")
921 ACE_TEXT ("(i.e. $TAO_ROOT, $TAO_ROOT/tao, $TAO_ROOT/orbsvcs,\n\t\t\t")
922 ACE_TEXT ("$TAO_ROOT/CIAO, $TAO_ROOT/CIAO/ciao, $TAO_ROOT/CIAO/ccm)\n\t\t\t")
923 ACE_TEXT (" (enabled by default)\n")
927 ACE_TEXT (" -Sg\t\t\tsuppress generating of unique header guards")
928 ACE_TEXT (" (unique guards are generated by default)\n")
932 ACE_TEXT (" -TS <value>\t\tset tab size for generated files")
933 ACE_TEXT (" (default is 2 spaces)\n")
938 be_util::generator_init ()
940 tao_cg
= TAO_CODEGEN::instance ();
942 AST_Generator
*gen
= nullptr;
951 be_util::get_output_path (bool for_anyop
,
955 if (for_anyop
&& nullptr != be_global
->anyop_output_dir ())
957 return be_global
->anyop_output_dir ();
959 else if (for_skel
&& nullptr != be_global
->skel_output_dir ())
961 return be_global
->skel_output_dir ();
963 else if (for_exec
&& nullptr != be_global
->exec_output_dir ())
965 return be_global
->exec_output_dir ();
969 return be_global
->output_dir ();
974 be_util::overwrite_ciao_exec_files ()
976 bool overwrite
= true;
977 if (be_global
->overwrite_not_exec())
979 bool src_exist
= false;
980 bool hdr_exist
= false;
981 const char *fname_hdr
= be_global
->be_get_ciao_exec_hdr_fname (false);
982 FILE* fp_hdr
= ACE_OS::fopen(fname_hdr
, "r");
985 // file exists, don't generate new exec files.
986 ACE_OS::fclose(fp_hdr
);
989 const char *fname_src
= be_global
->be_get_ciao_exec_src_fname (false);
990 FILE* fp_src
= ACE_OS::fopen(fname_src
, "r");
993 // file exists, don't generate new exec files.
994 ACE_OS::fclose(fp_src
);
997 if (hdr_exist
&& src_exist
)
1004 be_util::set_arg_seen_bit (be_type
*bt
)
1011 switch (bt
->node_type ())
1013 case AST_Decl::NT_typedef
:
1015 AST_Typedef
*td
= dynamic_cast<AST_Typedef
*> (bt
);
1016 be_util::set_arg_seen_bit (
1017 dynamic_cast<be_type
*> (td
->primitive_base_type ())
1021 case AST_Decl::NT_interface
:
1022 case AST_Decl::NT_interface_fwd
:
1023 case AST_Decl::NT_valuetype
:
1024 case AST_Decl::NT_valuetype_fwd
:
1025 case AST_Decl::NT_component
:
1026 case AST_Decl::NT_component_fwd
:
1027 case AST_Decl::NT_home
:
1028 case AST_Decl::NT_eventtype
:
1029 case AST_Decl::NT_eventtype_fwd
:
1030 idl_global
->object_arg_seen_
= true;
1032 case AST_Decl::NT_union
:
1033 case AST_Decl::NT_struct
:
1034 if (bt
->size_type () == AST_Type::FIXED
)
1036 idl_global
->fixed_size_decl_seen_
= true;
1040 idl_global
->var_size_decl_seen_
= true;
1044 case AST_Decl::NT_struct_fwd
:
1045 case AST_Decl::NT_union_fwd
:
1047 AST_StructureFwd
*fwd
= dynamic_cast<AST_StructureFwd
*> (bt
);
1048 be_type
*fd
= dynamic_cast<be_type
*> (fwd
->full_definition ());
1049 be_util::set_arg_seen_bit (fd
);
1052 case AST_Decl::NT_enum
:
1053 case AST_Decl::NT_enum_val
:
1054 // idl_global->basic_arg_seen_ = true;
1056 case AST_Decl::NT_string
:
1057 case AST_Decl::NT_wstring
:
1059 AST_String
*str
= dynamic_cast<AST_String
*> (bt
);
1061 if (str
->max_size ()->ev ()->u
.ulval
== 0)
1063 idl_global
->ub_string_seen_
= true;
1067 idl_global
->bd_string_seen_
= true;
1072 case AST_Decl::NT_array
:
1073 if (bt
->size_type () == AST_Type::FIXED
)
1075 idl_global
->fixed_array_decl_seen_
= true;
1079 idl_global
->var_array_decl_seen_
= true;
1083 case AST_Decl::NT_sequence
:
1084 idl_global
->var_size_decl_seen_
= true;
1086 case AST_Decl::NT_pre_defined
:
1088 AST_PredefinedType
*pdt
= dynamic_cast<AST_PredefinedType
*> (bt
);
1092 case AST_PredefinedType::PT_object
:
1093 case AST_PredefinedType::PT_pseudo
:
1094 case AST_PredefinedType::PT_value
:
1095 case AST_PredefinedType::PT_abstract
:
1096 idl_global
->object_arg_seen_
= true;
1098 case AST_PredefinedType::PT_any
:
1099 idl_global
->var_size_decl_seen_
= true;
1100 idl_global
->any_arg_seen_
= true;
1102 case AST_PredefinedType::PT_char
:
1103 case AST_PredefinedType::PT_wchar
:
1104 case AST_PredefinedType::PT_octet
:
1105 case AST_PredefinedType::PT_boolean
:
1106 idl_global
->special_basic_decl_seen_
= true;