Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / TAO_IDL / be / be_util.cpp
blobe735a1916cc1d00648ea0bf1e3a394b4a8c9e9ad
2 //=============================================================================
3 /**
4 * @file be_util.cpp
6 * Static helper methods used by multiple visitors.
8 * @author Gary Maxey
9 * @author Jeff Parsons
11 //=============================================================================
13 #include "be_util.h"
14 #include "be_helper.h"
15 #include "be_module.h"
16 #include "be_type.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"
32 void
33 be_util::gen_nested_namespace_begin (TAO_OutStream *os,
34 be_module *node,
35 bool skel)
37 char *item_name = nullptr;
38 bool first_level = true;
40 for (UTL_IdListActiveIterator i (node->name ());
41 !i.is_done ();
42 i.next ())
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.
54 *os << "POA_";
55 first_level = false;
58 *os << item_name << be_nl
59 << "{" << be_idt_nl;
64 void
65 be_util::gen_nested_namespace_end (TAO_OutStream *os,
66 be_module *node)
68 for (UTL_IdListActiveIterator i (node->name ());
69 !i.is_done ();
70 i.next ())
72 if (ACE_OS::strcmp (i.item ()->get_string (), "") != 0)
74 // Leave the outermost root scope.
75 *os << be_uidt_nl << "}";
80 void
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)
87 os << be_nl;
88 return;
91 be_util::gen_nesting_open (
92 os,
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 ()));
100 os << be_nl
101 << "module " << module_name.c_str () << be_nl
102 << "{" << be_idt;
106 void
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)
114 os << be_uidt_nl
115 << "};";
117 d = ScopeAsDecl (d->defined_in ());
118 nt = d->node_type ();
122 // Prepare an argument for a BE
123 void
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);
160 arg != nullptr;
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);
317 else
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 (),
323 arg));
328 void
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
336 // work.
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
345 // again with
346 ACE_DEBUG ((
347 LM_DEBUG,
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")));
386 void
387 be_util::usage ()
389 ACE_DEBUG ((
390 LM_DEBUG,
391 ACE_TEXT (" -Wb,export_macro=<macro name>\t\t\tsets export macro ")
392 ACE_TEXT ("for all files\n")
394 ACE_DEBUG ((
395 LM_DEBUG,
396 ACE_TEXT (" -Wb,export_include=<include path>\t\tsets export include ")
397 ACE_TEXT ("file for all files\n")
399 ACE_DEBUG ((
400 LM_DEBUG,
401 ACE_TEXT (" -Wb,stub_export_macro=<macro name>\t\tsets export ")
402 ACE_TEXT ("macro for client files only\n")
404 ACE_DEBUG ((
405 LM_DEBUG,
406 ACE_TEXT (" -Wb,stub_export_include=<include path>\t\tsets export ")
407 ACE_TEXT ("include file for client only\n")
409 ACE_DEBUG ((
410 LM_DEBUG,
411 ACE_TEXT (" -Wb,stub_export_file=<filename>\t\tsets export ")
412 ACE_TEXT ("file for client only\n")
414 ACE_DEBUG ((
415 LM_DEBUG,
416 ACE_TEXT (" -Wb,skel_export_macro=<macro name>\t\tsets export ")
417 ACE_TEXT ("macro for server files only\n")
419 ACE_DEBUG ((
420 LM_DEBUG,
421 ACE_TEXT (" -Wb,skel_export_include=<include path>\t\tsets export ")
422 ACE_TEXT ("include file for server only\n")
424 ACE_DEBUG ((
425 LM_DEBUG,
426 ACE_TEXT (" -Wb,skel_export_file=<include path>\t\tsets export ")
427 ACE_TEXT ("file for server only\n")
429 ACE_DEBUG ((
430 LM_DEBUG,
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")
435 ACE_DEBUG ((
436 LM_DEBUG,
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")
441 ACE_DEBUG ((
442 LM_DEBUG,
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")
447 ACE_DEBUG ((
448 LM_DEBUG,
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")
453 ACE_DEBUG ((
454 LM_DEBUG,
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")
459 ACE_DEBUG ((
460 LM_DEBUG,
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")
465 ACE_DEBUG ((
466 LM_DEBUG,
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")
471 ACE_DEBUG ((
472 LM_DEBUG,
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")
477 ACE_DEBUG ((
478 LM_DEBUG,
479 ACE_TEXT (" -Wb,pch_include=<include path>\t\t\tsets include ")
480 ACE_TEXT ("file for precompiled header mechanism\n")
482 ACE_DEBUG ((
483 LM_DEBUG,
484 ACE_TEXT (" -Wb,pre_include=<include path>\t\t\tsets include ")
485 ACE_TEXT ("file generate before any other includes\n")
487 ACE_DEBUG ((
488 LM_DEBUG,
489 ACE_TEXT (" -Wb,post_include=<include path>\t\tsets include ")
490 ACE_TEXT ("file generated at the end of the file\n")
492 ACE_DEBUG ((
493 LM_DEBUG,
494 ACE_TEXT (" -Wb,include_guard=<include path>\t\tguard to prevent ")
495 ACE_TEXT ("the generated client header file\n")
497 ACE_DEBUG ((
498 LM_DEBUG,
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")
502 ACE_DEBUG ((
503 LM_DEBUG,
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")
508 ACE_DEBUG ((
509 LM_DEBUG,
510 ACE_TEXT (" -Wb,stripped_filename=<filename>\t\tfilename that should ")
511 ACE_TEXT ("be used as stripped_filename instead of input filename.\n")
513 ACE_DEBUG ((
514 LM_DEBUG,
515 ACE_TEXT (" -Wb,container_type=<type>\t\t\ttype of container we generated\n")
517 ACE_DEBUG ((
518 LM_DEBUG,
519 ACE_TEXT (" -Wb,obv_opt_accessor\t\t\t\toptimizes access to base class ")
520 ACE_TEXT ("data in valuetypes\n")
522 ACE_DEBUG ((
523 LM_DEBUG,
524 ACE_TEXT (" -Wb,versioning_begin\t\t\tSet text that opens a ")
525 ACE_TEXT ("a \"versioned\" namespace\n")
527 ACE_DEBUG ((
528 LM_DEBUG,
529 ACE_TEXT (" -Wb,versioning_end\t\t\tSet text that closes a ")
530 ACE_TEXT ("a \"versioned\" namespace\n")
532 ACE_DEBUG ((
533 LM_DEBUG,
534 ACE_TEXT (" -Wb,versioning_include\t\t\tSet text that will be used as include for ")
535 ACE_TEXT ("a \"versioned\" namespace\n")
537 ACE_DEBUG ((
538 LM_DEBUG,
539 ACE_TEXT (" -Wb,no_fixed_err\t\t\tDon't generate an error when the fixed")
540 ACE_TEXT (" type is used\n")
542 ACE_DEBUG ((
543 LM_DEBUG,
544 ACE_TEXT (" -b\t\t\tUse a clonable argument type for oneway methods.\n")
546 ACE_DEBUG ((
547 LM_DEBUG,
548 ACE_TEXT (" -ci\t\t\tClient inline file name ending. Default is C.inl\n")
550 ACE_DEBUG ((
551 LM_DEBUG,
552 ACE_TEXT (" -cs\t\t\tClient stub's file name ending.")
553 ACE_TEXT (" Default is C.cpp\n")
555 ACE_DEBUG ((
556 LM_DEBUG,
557 ACE_TEXT (" -g <gperf_path>\tPath for the GPERF program.")
558 ACE_TEXT (" Default is $ACE_ROOT/bin/ace_gperf\n")));
559 ACE_DEBUG ((
560 LM_DEBUG,
561 ACE_TEXT (" -GC \t\t\tGenerate the AMI classes\n")
563 ACE_DEBUG ((
564 LM_DEBUG,
565 ACE_TEXT (" -GH \t\t\tGenerate the AMH classes\n")
567 ACE_DEBUG ((
568 LM_DEBUG,
569 ACE_TEXT (" -GM \t\t\tGenerate the AMI4CCM classes\n")
571 ACE_DEBUG ((
572 LM_DEBUG,
573 ACE_TEXT (" -Gce \t\t\tGenerate code optimized for CORBA/e\n")
575 ACE_DEBUG ((
576 LM_DEBUG,
577 ACE_TEXT (" -Gmc \t\t\tGenerate code optimized for Minimum CORBA\n")
579 ACE_DEBUG ((
580 LM_DEBUG,
581 ACE_TEXT (" -Gcl \t\t\tGenerate code optimized for LwCCM\n")
583 ACE_DEBUG ((
584 LM_DEBUG,
585 ACE_TEXT (" -Gcm \t\t\tGenerate code optimized for noevent CCM\n")
587 ACE_DEBUG ((
588 LM_DEBUG,
589 ACE_TEXT (" -Gd \t\t\tGenerate the code for direct collocation. Default ")
590 ACE_TEXT ("is thru-POA collocation\n")
592 ACE_DEBUG ((
593 LM_DEBUG,
594 ACE_TEXT (" -Gos \t\t\tGenerate std::ostream insertion operators.\n")
596 ACE_DEBUG ((
597 LM_DEBUG,
598 ACE_TEXT (" -GI[h|s|b|e|c|a|d]\tGenerate Implementation Files\n")
600 ACE_DEBUG ((
601 LM_DEBUG,
602 ACE_TEXT (" \t\t\th - Implementation header file name ending.")
603 ACE_TEXT (" Default is I.h\n")
605 ACE_DEBUG ((
606 LM_DEBUG,
607 ACE_TEXT (" \t\t\ts - Implementation skeleton file name ending.")
608 ACE_TEXT (" Default is I.cpp\n")
610 ACE_DEBUG ((
611 LM_DEBUG,
612 ACE_TEXT (" \t\t\tb - Prefix to the implementation class names.")
613 ACE_TEXT (" Default is 'no prefix'\n")
615 ACE_DEBUG ((
616 LM_DEBUG,
617 ACE_TEXT (" \t\t\te - Suffix to the implementation class names.")
618 ACE_TEXT (" Default is _i\n")
620 ACE_DEBUG ((
621 LM_DEBUG,
622 ACE_TEXT (" \t\t\tc - Generate copy constructors in the servant")
623 ACE_TEXT (" implementation template files (off by default)\n")
625 ACE_DEBUG ((
626 LM_DEBUG,
627 ACE_TEXT (" \t\t\ta - Generate assignment operators in the servant")
628 ACE_TEXT (" implementation template files (off by default)\n")
630 ACE_DEBUG ((
631 LM_DEBUG,
632 ACE_TEXT (" \t\t\td - Generate debug (source file/line#) information.")
633 ACE_TEXT (" (off by default)\n")
635 ACE_DEBUG ((
636 LM_DEBUG,
637 ACE_TEXT (" -Gp \t\t\tGenerate the code for thru-POA collocation")
638 ACE_TEXT (" (default)\n")
640 ACE_DEBUG ((
641 LM_DEBUG,
642 ACE_TEXT (" -Gsp\t\t\tGenerate the code for Smart Proxies\n")
644 ACE_DEBUG ((
645 LM_DEBUG,
646 ACE_TEXT (" -Gstl\t\t\tGenerate the alternate C++ mapping for")
647 ACE_TEXT (" IDL strings and sequences\n")
649 ACE_DEBUG ((
650 LM_DEBUG,
651 ACE_TEXT (" -Gt\t\t\tenable optimized TypeCode support")
652 ACE_TEXT (" (unopt by default)\n")
654 ACE_DEBUG ((
655 LM_DEBUG,
656 ACE_TEXT (" -GT\t\t\tgenerate tie class (and file)")
657 ACE_TEXT (" generation (disabled by default)\n")
659 ACE_DEBUG ((
660 LM_DEBUG,
661 ACE_TEXT (" \t\t\tNo effect if TypeCode generation is suppressed\n")
663 ACE_DEBUG ((
664 LM_DEBUG,
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")
668 ACE_DEBUG ((
669 LM_DEBUG,
670 ACE_TEXT (" -Guc\t\t\tgenerate uninlined constant if declared ")
671 ACE_TEXT ("in a module (inlined by default)\n")
673 ACE_DEBUG ((
674 LM_DEBUG,
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")
678 ACE_DEBUG ((
679 LM_DEBUG,
680 ACE_TEXT (" -Gse\t\t\tgenerate explicit export of sequence's ")
681 ACE_TEXT ("template base class (not generated by default)\n")
683 ACE_DEBUG ((
684 LM_DEBUG,
685 ACE_TEXT (" -Gsv\t\t\tgenerate CIAO servant code ")
686 ACE_TEXT ("(not generated by default)\n")
688 ACE_DEBUG ((
689 LM_DEBUG,
690 ACE_TEXT (" -Glem\t\t\tgenerate CIAO executor IDL ")
691 ACE_TEXT ("(not generated by default)\n")
693 ACE_DEBUG ((
694 LM_DEBUG,
695 ACE_TEXT (" -Gex\t\t\tgenerate CIAO executor implementation ")
696 ACE_TEXT ("code (not generated by default)\n")
698 ACE_DEBUG ((
699 LM_DEBUG,
700 ACE_TEXT (" -Gexr\t\t\tgenerate CIAO executor implementation ")
701 ACE_TEXT ("code with an ACE_Reactor implementation (not generated by default)\n")
703 ACE_DEBUG ((
704 LM_DEBUG,
705 ACE_TEXT (" -Gcn\t\t\tgenerate CIAO connector implementation ")
706 ACE_TEXT ("code (not generated by default)\n")
708 ACE_DEBUG ((
709 LM_DEBUG,
710 ACE_TEXT (" -Gts\t\t\tgenerate DDS type support IDL ")
711 ACE_TEXT ("(not generated by default)\n")
713 ACE_DEBUG ((
714 LM_DEBUG,
715 ACE_TEXT (" -Gxhst\t\t\tgenerate export header file ")
716 ACE_TEXT ("for stub (not generated by default)\n")
718 ACE_DEBUG ((
719 LM_DEBUG,
720 ACE_TEXT (" -Gxhsk\t\t\tgenerate export header file ")
721 ACE_TEXT ("for skeleton (not generated by default)\n")
723 ACE_DEBUG ((
724 LM_DEBUG,
725 ACE_TEXT (" -Gxhsv\t\t\tgenerate export header file ")
726 ACE_TEXT ("for CIAO servant (not generated by default)\n")
728 ACE_DEBUG ((
729 LM_DEBUG,
730 ACE_TEXT (" -Gxhex\t\t\tgenerate export header file ")
731 ACE_TEXT ("for CIAO executor (not generated by default)\n")
733 ACE_DEBUG ((
734 LM_DEBUG,
735 ACE_TEXT (" -Gxhcn\t\t\tgenerate export header file ")
736 ACE_TEXT ("for CIAO connector (not generated by default)\n")
738 ACE_DEBUG ((
739 LM_DEBUG,
740 ACE_TEXT (" -GX\t\t\tgenerate empty A.h file\n")
742 ACE_DEBUG ((
743 LM_DEBUG,
744 ACE_TEXT (" -hc\t\t\tClient's header file name ending.")
745 ACE_TEXT (" Default is C.h\n")
747 ACE_DEBUG ((
748 LM_DEBUG,
749 ACE_TEXT (" -hs\t\t\tServer's header file name ending.")
750 ACE_TEXT (" Default is S.h\n")
752 ACE_DEBUG ((
753 LM_DEBUG,
754 ACE_TEXT (" -hT\t\t\tServer's template hdr file name ending.")
755 ACE_TEXT (" Default is S_T.h\n")
757 ACE_DEBUG ((
758 LM_DEBUG,
759 ACE_TEXT (" -H perfect_hash\tTo force perfect hashed operation")
760 ACE_TEXT (" lookup strategy (default)\n")
762 ACE_DEBUG ((
763 LM_DEBUG,
764 ACE_TEXT (" -H dynamic_hash\tTo force dynamic hashed operation")
765 ACE_TEXT (" lookup strategy. Default is perfect hashing\n")
767 ACE_DEBUG ((
768 LM_DEBUG,
769 ACE_TEXT (" -H linear_search\tTo force linear search operation")
770 ACE_TEXT (" lookup strategy\n")
772 ACE_DEBUG ((
773 LM_DEBUG,
774 ACE_TEXT (" -H binary_search\tTo force binary search operation")
775 ACE_TEXT (" lookup strategy\n")
777 ACE_DEBUG ((
778 LM_DEBUG,
779 ACE_TEXT (" -in \t\t\tTo generate <>s for standard #include'd")
780 ACE_TEXT (" files (non-changing files)\n")
782 ACE_DEBUG ((
783 LM_DEBUG,
784 ACE_TEXT (" -ic \t\t\tTo generate \"\"s for standard #include'd")
785 ACE_TEXT (" files (changing files)\n")
787 ACE_DEBUG ((
788 LM_DEBUG,
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")
793 ACE_DEBUG ((
794 LM_DEBUG,
795 ACE_TEXT (" -o <output_dir>\tOutput directory for the generated files.")
796 ACE_TEXT (" Default is current directory\n")
798 ACE_DEBUG ((
799 LM_DEBUG,
800 ACE_TEXT (" -oS <output_dir>\tOutput directory for the generated ")
801 ACE_TEXT ("skeleton files. Default is -o value or current directory\n")
803 ACE_DEBUG ((
804 LM_DEBUG,
805 ACE_TEXT (" -oA <output_dir>\tOutput directory for the generated anyop")
806 ACE_TEXT ("files. Default is -o value or current directory\n")
808 ACE_DEBUG ((
809 LM_DEBUG,
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")
814 ACE_DEBUG ((
815 LM_DEBUG,
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")
819 ACE_DEBUG ((
820 LM_DEBUG,
821 ACE_TEXT (" -ss\t\t\tServer's skeleton file name ending.")
822 ACE_TEXT (" Default is S.cpp\n")
824 ACE_DEBUG ((
825 LM_DEBUG,
826 ACE_TEXT (" -sT\t\t\tServer's template skeleton file name ending.")
827 ACE_TEXT (" Default is S_T.cpp\n")
829 ACE_DEBUG ((
830 LM_DEBUG,
831 ACE_TEXT (" -Sa\t\t\tsuppress Any support")
832 ACE_TEXT (" (support enabled by default)\n")
834 ACE_DEBUG ((
835 LM_DEBUG,
836 ACE_TEXT (" -Sal\t\t\tsuppress Any support")
837 ACE_TEXT (" for local interfaces")
838 ACE_TEXT (" (support enabled by default)\n")
840 ACE_DEBUG ((
841 LM_DEBUG,
842 ACE_TEXT (" -Scdr\t\t\tsuppress CDR support")
843 ACE_TEXT (" (support enabled by default)\n")
845 ACE_DEBUG ((
846 LM_DEBUG,
847 ACE_TEXT (" -Sat\t\t\tsuppress arg traits")
848 ACE_TEXT (" generation")
849 ACE_TEXT (" (arg traits generated by default)\n")
851 ACE_DEBUG ((
852 LM_DEBUG,
853 ACE_TEXT (" -St\t\t\tsuppress TypeCode support")
854 ACE_TEXT (" (support enabled by default)\n")
856 ACE_DEBUG ((
857 LM_DEBUG,
858 ACE_TEXT (" -Sp\t\t\tsuppress generating Thru POA collocated")
859 ACE_TEXT (" stubs (enabled by default)\n")
861 ACE_DEBUG ((
862 LM_DEBUG,
863 ACE_TEXT (" -Sd\t\t\tsuppress generating Direct collocated")
864 ACE_TEXT (" stubs (disable by default)\n")
866 ACE_DEBUG ((
867 LM_DEBUG,
868 ACE_TEXT (" -Sm\t\t\tdisable IDL3 equivalent IDL preprocessing")
869 ACE_TEXT (" (enabled by default)\n")
871 ACE_DEBUG ((
872 LM_DEBUG,
873 ACE_TEXT (" -SS\t\t\tsuppress generating skeleton implementation")
874 ACE_TEXT (" (disabled by default)\n")
876 ACE_DEBUG ((
877 LM_DEBUG,
878 ACE_TEXT (" -Ssvntc\t\tsuppress generating servant implementation")
879 ACE_TEXT (" (disabled by default)\n")
881 ACE_DEBUG ((
882 LM_DEBUG,
883 ACE_TEXT (" -Ssvntt\t\tsuppress generating servant template files")
884 ACE_TEXT (" (disabled by default)\n")
886 ACE_DEBUG ((
887 LM_DEBUG,
888 ACE_TEXT (" -Sci\t\t\tsuppress generating client inline file")
889 ACE_TEXT (" (disabled by default)\n")
891 ACE_DEBUG ((
892 LM_DEBUG,
893 ACE_TEXT (" -Sch\t\t\tsuppress generating client header file")
894 ACE_TEXT (" (disabled by default)\n")
896 ACE_DEBUG ((
897 LM_DEBUG,
898 ACE_TEXT (" -Scc\t\t\tsuppress generating client source file")
899 ACE_TEXT (" (disabled by default)\n")
901 ACE_DEBUG ((
902 LM_DEBUG,
903 ACE_TEXT (" -Ssh\t\t\tsuppress generating skeleton header")
904 ACE_TEXT (" (disabled by default)\n")
906 ACE_DEBUG ((
907 LM_DEBUG,
908 ACE_TEXT (" -Sorb\t\t\tsuppress generating include of ORB.h")
909 ACE_TEXT (" (disabled by default)\n")
911 ACE_DEBUG ((
912 LM_DEBUG,
913 ACE_TEXT (" -Sfr\t\t\tsuppress generating valuetype factory")
914 ACE_TEXT (" registration in CIAO (generated by default)\n")
916 ACE_DEBUG ((
917 LM_DEBUG,
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")
925 ACE_DEBUG ((
926 LM_DEBUG,
927 ACE_TEXT (" -Sg\t\t\tsuppress generating of unique header guards")
928 ACE_TEXT (" (unique guards are generated by default)\n")
930 ACE_DEBUG ((
931 LM_DEBUG,
932 ACE_TEXT (" -TS <value>\t\tset tab size for generated files")
933 ACE_TEXT (" (default is 2 spaces)\n")
937 AST_Generator *
938 be_util::generator_init ()
940 tao_cg = TAO_CODEGEN::instance ();
942 AST_Generator *gen = nullptr;
943 ACE_NEW_RETURN (gen,
944 be_generator,
945 nullptr);
947 return gen;
950 const char *
951 be_util::get_output_path (bool for_anyop,
952 bool for_skel,
953 bool for_exec)
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 ();
967 else
969 return be_global->output_dir ();
973 bool
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");
983 if (fp_hdr)
985 // file exists, don't generate new exec files.
986 ACE_OS::fclose(fp_hdr);
987 hdr_exist = true;
989 const char *fname_src = be_global->be_get_ciao_exec_src_fname (false);
990 FILE* fp_src = ACE_OS::fopen(fname_src, "r");
991 if (fp_src)
993 // file exists, don't generate new exec files.
994 ACE_OS::fclose(fp_src);
995 src_exist = true;
997 if (hdr_exist && src_exist)
998 overwrite = false;
1000 return overwrite;
1003 void
1004 be_util::set_arg_seen_bit (be_type *bt)
1006 if (bt == nullptr)
1008 return;
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 ())
1019 break;
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;
1031 break;
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;
1038 else
1040 idl_global->var_size_decl_seen_ = true;
1043 break;
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);
1050 break;
1052 case AST_Decl::NT_enum:
1053 case AST_Decl::NT_enum_val:
1054 // idl_global->basic_arg_seen_ = true;
1055 break;
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;
1065 else
1067 idl_global->bd_string_seen_ = true;
1070 break;
1072 case AST_Decl::NT_array:
1073 if (bt->size_type () == AST_Type::FIXED)
1075 idl_global->fixed_array_decl_seen_ = true;
1077 else
1079 idl_global->var_array_decl_seen_ = true;
1082 break;
1083 case AST_Decl::NT_sequence:
1084 idl_global->var_size_decl_seen_ = true;
1085 break;
1086 case AST_Decl::NT_pre_defined:
1088 AST_PredefinedType *pdt = dynamic_cast<AST_PredefinedType*> (bt);
1090 switch (pdt->pt ())
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;
1097 break;
1098 case AST_PredefinedType::PT_any:
1099 idl_global->var_size_decl_seen_ = true;
1100 idl_global->any_arg_seen_ = true;
1101 break;
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;
1107 break;
1108 default:
1109 break;
1112 default:
1113 break;