Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_ccm_pre_proc.cpp
blob014fd2f28ce09bc8305758c3b1cef583b1876e9a
1 /**
2 * @file be_visitor_ccm_pre_proc.cpp
4 * @author Jeff Parsons
5 */
6 //=============================================================================
8 #include "be_visitor_ccm_pre_proc.h"
9 #include "be_visitor_context.h"
10 #include "be_visitor_xplicit_pre_proc.h"
11 #include "be_root.h"
12 #include "be_operation.h"
13 #include "be_argument.h"
14 #include "be_exception.h"
15 #include "be_structure.h"
16 #include "be_sequence.h"
17 #include "be_valuetype.h"
18 #include "be_module.h"
19 #include "be_template_module.h"
20 #include "be_template_module_inst.h"
21 #include "be_field.h"
22 #include "be_typedef.h"
23 #include "be_connector.h"
24 #include "be_provides.h"
25 #include "be_uses.h"
26 #include "be_publishes.h"
27 #include "be_emits.h"
28 #include "be_consumes.h"
29 #include "be_extended_port.h"
30 #include "be_porttype.h"
31 #include "be_eventtype.h"
32 #include "be_eventtype_fwd.h"
33 #include "be_home.h"
34 #include "be_finder.h"
35 #include "be_extern.h"
37 #include "ast_generator.h"
39 #include "utl_exceptlist.h"
40 #include "utl_namelist.h"
41 #include "utl_err.h"
43 #include "fe_interface_header.h"
44 #include "global_extern.h"
45 #include "nr_extern.h"
47 const char *LW_EXCEP_NAMES[] =
49 "AlreadyConnected",
50 "InvalidConnection",
51 "NoConnection",
52 "ExceededConnectionLimit",
53 "CreateFailure",
54 "RemoveFailure",
55 "FinderFailure"
58 const char *ADDL_EXCEP_NAMES[] =
60 "InvalidKey",
61 "UnknownKeyValue",
62 "DuplicateKeyValue"
65 const int N_LW_EXCEPS =
66 sizeof (LW_EXCEP_NAMES) / sizeof (char *);
67 const int N_ADDL_EXCEPS =
68 sizeof (ADDL_EXCEP_NAMES) / sizeof (char *);
70 be_exception *LW_EXCEPS[N_LW_EXCEPS];
71 be_exception *ADDL_EXCEPS[N_ADDL_EXCEPS];
73 be_visitor_ccm_pre_proc::be_visitor_ccm_pre_proc (
74 be_visitor_context *ctx)
75 : be_visitor_component_scope (ctx),
76 module_id_ ("Components"),
77 cookie_ (nullptr),
78 already_connected_ (nullptr),
79 invalid_connection_ (nullptr),
80 no_connection_ (nullptr),
81 exceeded_connection_limit_ (nullptr),
82 create_failure_ (nullptr),
83 remove_failure_ (nullptr),
84 finder_failure_ (nullptr),
85 invalid_key_ (nullptr),
86 unknown_key_value_ (nullptr),
87 duplicate_key_value_ (nullptr),
88 comp_ (nullptr),
89 home_ (nullptr),
90 ccm_lookups_done_ (false)
94 be_visitor_ccm_pre_proc::~be_visitor_ccm_pre_proc ()
96 this->module_id_.destroy ();
99 int
100 be_visitor_ccm_pre_proc::visit_root (be_root *node)
102 /// Do this before traversing the tree so the traversal
103 /// will pick up the implied uses nodes we add, if any.
104 /// No need to check for the -GM option here - what's
105 /// generated by this call depends only on the contents
106 /// of the ciao_ami_recep_names_ queue.
107 int const status = this->generate_ami4ccm_uses ();
109 if (status == -1)
111 ACE_ERROR_RETURN ((LM_ERROR,
112 ACE_TEXT ("be_visitor_ccm_pre_proc::")
113 ACE_TEXT ("visit_root - ")
114 ACE_TEXT ("generate_ami4ccm_uses() ")
115 ACE_TEXT ("failed\n")),
116 -1);
119 if (this->visit_scope (node) == -1)
121 ACE_ERROR_RETURN ((LM_ERROR,
122 ACE_TEXT ("be_visitor_ccm_pre_proc::")
123 ACE_TEXT ("visit_root - ")
124 ACE_TEXT ("visit scope failed\n")),
125 -1);
128 return 0;
132 be_visitor_ccm_pre_proc::visit_module (be_module *node)
134 if (this->visit_scope (node) == -1)
136 ACE_ERROR_RETURN ((LM_ERROR,
137 ACE_TEXT ("be_visitor_ccm_pre_proc::")
138 ACE_TEXT ("visit_module - ")
139 ACE_TEXT ("visit scope failed\n")),
140 -1);
143 return 0;
147 be_visitor_ccm_pre_proc::visit_component (be_component *node)
149 /// Waiting to do this until a component is seen will ensure
150 /// that Components.idl is present and the lookups will
151 /// succeed. The flag ensures that the lookup is done only
152 /// once.
153 if (!this->ccm_lookups_done_)
155 if (this->lookup_cookie () == -1)
157 ACE_ERROR_RETURN ((LM_ERROR,
158 ACE_TEXT ("be_visitor_ccm_pre_proc::")
159 ACE_TEXT ("visit_root - ")
160 ACE_TEXT ("Components::Cookie ")
161 ACE_TEXT ("lookup failed\n")),
162 -1);
165 if (this->lookup_exceptions () == -1)
167 ACE_ERROR_RETURN ((LM_ERROR,
168 ACE_TEXT ("be_visitor_ccm_pre_proc::")
169 ACE_TEXT ("visit_root - ")
170 ACE_TEXT ("component exception ")
171 ACE_TEXT ("lookups failed\n")),
172 -1);
175 this->ccm_lookups_done_ = true;
178 // Set working node for all port code generation.
179 this->comp_ = node;
181 if (this->visit_scope (node) == -1)
183 ACE_ERROR_RETURN ((LM_ERROR,
184 ACE_TEXT ("be_visitor_ccm_pre_proc::")
185 ACE_TEXT ("visit_component - ")
186 ACE_TEXT ("code generation for ")
187 ACE_TEXT ("scope3 failed\n")),
188 -1);
191 return 0;
195 be_visitor_ccm_pre_proc::visit_connector (be_connector *node)
197 return this->visit_component (node);
201 be_visitor_ccm_pre_proc::visit_provides (be_provides *node)
203 if (node->provides_type ()->is_local ())
205 return 0;
208 if (!be_global->gen_lwccm ())
210 // If this facet comes from a porttype, the instantiated
211 // port/mirrorport name is prefixed to the facet name.
212 ACE_CString prefix ("provide_");
213 prefix += this->ctx_->port_prefix ();
215 AST_Operation *provides_op = nullptr;
216 UTL_ScopedName *op_name =
217 this->create_scoped_name (prefix.c_str (),
218 node->local_name ()->get_string (),
219 nullptr,
220 comp_);
221 ACE_NEW_RETURN (provides_op,
222 be_operation (node->provides_type (),
223 AST_Operation::OP_noflags,
224 nullptr,
227 -1);
229 provides_op->set_defined_in (comp_);
230 provides_op->set_imported (comp_->imported ());
231 provides_op->set_name (op_name);
233 if (nullptr == comp_->be_add_operation (provides_op))
235 ACE_ERROR_RETURN ((LM_ERROR,
236 ACE_TEXT ("be_visitor_ccm_pre_proc::")
237 ACE_TEXT ("visit_provides - ")
238 ACE_TEXT ("be_add_operation() failed\n")),
239 -1);
243 return 0;
247 be_visitor_ccm_pre_proc::visit_uses (be_uses *node)
249 if (node->uses_type ()->is_local ())
251 return 0;
254 if (!be_global->gen_lwccm ())
256 if (node->is_multiple ())
258 if (this->gen_connect_multiple (node) == -1)
260 ACE_ERROR_RETURN ((LM_ERROR,
261 ACE_TEXT ("be_visitor_ccm_pre_proc::")
262 ACE_TEXT ("visit_uses - ")
263 ACE_TEXT ("gen_connect_multiple failed\n")),
264 -1);
267 if (this->gen_disconnect_multiple (node) == -1)
269 ACE_ERROR_RETURN ((LM_ERROR,
270 ACE_TEXT ("be_visitor_ccm_pre_proc::")
271 ACE_TEXT ("visit_uses - ")
272 ACE_TEXT ("gen_disconnect_multiple failed\n")),
273 -1);
276 if (this->gen_get_connection_multiple (node) == -1)
278 ACE_ERROR_RETURN ((LM_ERROR,
279 ACE_TEXT ("be_visitor_ccm_pre_proc::")
280 ACE_TEXT ("visit_uses - ")
281 ACE_TEXT ("gen_get_connection_single failed\n")),
282 -1);
285 else
287 if (this->gen_connect_single (node) == -1)
289 ACE_ERROR_RETURN ((LM_ERROR,
290 ACE_TEXT ("be_visitor_ccm_pre_proc::")
291 ACE_TEXT ("visit_uses - ")
292 ACE_TEXT ("gen_connect_single failed\n")),
293 -1);
296 if (this->gen_disconnect_single (node) == -1)
298 ACE_ERROR_RETURN ((LM_ERROR,
299 ACE_TEXT ("be_visitor_ccm_pre_proc::")
300 ACE_TEXT ("visit_uses - ")
301 ACE_TEXT ("gen_disconnect_single failed\n")),
302 -1);
305 if (this->gen_get_connection_single (node) == -1)
307 ACE_ERROR_RETURN ((LM_ERROR,
308 ACE_TEXT ("be_visitor_ccm_pre_proc::")
309 ACE_TEXT ("visit_uses - ")
310 ACE_TEXT ("gen_get_connection_single failed\n")),
311 -1);
316 return 0;
320 be_visitor_ccm_pre_proc::visit_publishes (be_publishes *node)
322 if (!be_global->gen_noeventccm ())
324 if (this->gen_subscribe (node) == -1)
326 ACE_ERROR_RETURN ((LM_ERROR,
327 ACE_TEXT ("be_visitor_ccm_pre_proc::")
328 ACE_TEXT ("visit_publishes - ")
329 ACE_TEXT ("gen_subscribe failed\n")),
330 -1);
333 if (this->gen_unsubscribe (node) == -1)
335 ACE_ERROR_RETURN ((LM_ERROR,
336 ACE_TEXT ("be_visitor_ccm_pre_proc::")
337 ACE_TEXT ("visit_publishes - ")
338 ACE_TEXT ("gen_unsubscribe failed\n")),
339 -1);
342 return 0;
346 be_visitor_ccm_pre_proc::visit_emits (be_emits *node)
348 if (!be_global->gen_noeventccm ())
350 if (this->gen_emits_connect (node) == -1)
352 ACE_ERROR_RETURN ((LM_ERROR,
353 ACE_TEXT ("be_visitor_ccm_pre_proc::")
354 ACE_TEXT ("visit_emits - ")
355 ACE_TEXT ("gen_emits_connect failed\n")),
356 -1);
359 if (this->gen_emits_disconnect (node) == -1)
361 ACE_ERROR_RETURN ((LM_ERROR,
362 ACE_TEXT ("be_visitor_ccm_pre_proc::")
363 ACE_TEXT ("visit_emits - ")
364 ACE_TEXT ("gen_emits_disconnect failed\n")),
365 -1);
368 return 0;
372 be_visitor_ccm_pre_proc::visit_consumes (be_consumes *node)
374 if (!be_global->gen_noeventccm ())
376 if (this->gen_get_consumer (node) == -1)
378 ACE_ERROR_RETURN ((LM_ERROR,
379 ACE_TEXT ("be_visitor_ccm_pre_proc::")
380 ACE_TEXT ("visit_comsumes - ")
381 ACE_TEXT ("gen_get_consumer failed\n")),
382 -1);
385 return 0;
389 be_visitor_ccm_pre_proc::visit_home (be_home *node)
391 AST_Interface *xplicit = this->create_explicit (node);
393 if (xplicit == nullptr)
395 ACE_ERROR_RETURN ((LM_ERROR,
396 ACE_TEXT ("be_visitor_ccm_pre_proc::")
397 ACE_TEXT ("visit_home - code generation ")
398 ACE_TEXT ("for explicit interface failed\n")),
399 -1);
402 AST_Interface *implicit = this->create_implicit (node);
404 if (implicit == nullptr)
406 ACE_ERROR_RETURN ((LM_ERROR,
407 ACE_TEXT ("be_visitor_ccm_pre_proc::")
408 ACE_TEXT ("visit_home - code generation ")
409 ACE_TEXT ("for implicit interface failed\n")),
410 -1);
413 if (this->gen_implicit_ops (node, implicit) == -1)
415 ACE_ERROR_RETURN ((LM_ERROR,
416 ACE_TEXT ("be_visitor_ccm_pre_proc::")
417 ACE_TEXT ("visit_home - ")
418 ACE_TEXT ("code generation for primary key ")
419 ACE_TEXT ("operations failed\n")),
420 -1);
423 if (this->create_equivalent (node, xplicit, implicit) == nullptr)
425 ACE_ERROR_RETURN ((LM_ERROR,
426 ACE_TEXT ("be_visitor_ccm_pre_proc::")
427 ACE_TEXT ("visit_home - code generation ")
428 ACE_TEXT ("for equivalent interface failed\n")),
429 -1);
432 return 0;
436 be_visitor_ccm_pre_proc::visit_eventtype (be_eventtype *node)
438 if (!be_global->gen_noeventccm ())
440 if (node->ccm_pre_proc_gen ())
442 return 0;
445 if (this->create_event_consumer (node) == -1)
447 ACE_ERROR_RETURN ((LM_ERROR,
448 ACE_TEXT ("be_visitor_ccm_pre_proc::")
449 ACE_TEXT ("visit_eventtype - code generation ")
450 ACE_TEXT ("for consumer failed\n")),
451 -1);
454 node->ccm_pre_proc_gen (true);
456 return 0;
460 be_visitor_ccm_pre_proc::visit_eventtype_fwd (be_eventtype_fwd *node)
462 be_eventtype *fd =
463 dynamic_cast<be_eventtype*> (node->full_definition ());
465 return this->visit_eventtype (fd);
469 be_visitor_ccm_pre_proc::gen_implicit_ops (be_home *node,
470 AST_Interface *implicit)
472 if (this->gen_create (node, implicit) == -1)
474 ACE_ERROR_RETURN ((LM_ERROR,
475 ACE_TEXT ("be_visitor_ccm_pre_proc::")
476 ACE_TEXT ("gen_implicit_ops - ")
477 ACE_TEXT ("gen_create failed\n")),
478 -1);
481 AST_Type *pk = node->primary_key ();
483 if (pk == nullptr)
485 return 0;
488 if (!be_global->gen_lwccm ())
490 if (this->gen_find_by_primary_key (node, implicit) == -1)
492 ACE_ERROR_RETURN ((LM_ERROR,
493 ACE_TEXT ("be_visitor_ccm_pre_proc::")
494 ACE_TEXT ("gen_implicit_ops - ")
495 ACE_TEXT ("gen_find_by_primary_key failed\n")),
496 -1);
500 if (this->gen_remove (node, implicit) == -1)
502 ACE_ERROR_RETURN ((LM_ERROR,
503 ACE_TEXT ("be_visitor_ccm_pre_proc::")
504 ACE_TEXT ("gen_implicit_ops - ")
505 ACE_TEXT ("gen_remove failed\n")),
506 -1);
509 if (!be_global->gen_lwccm ())
511 if (this->gen_get_primary_key (node, implicit) == -1)
513 ACE_ERROR_RETURN ((LM_ERROR,
514 ACE_TEXT ("be_visitor_ccm_pre_proc::")
515 ACE_TEXT ("gen_implicit_ops - ")
516 ACE_TEXT ("gen_get_primary_key failed\n")),
517 -1);
521 return 0;
524 // **************************************************************
527 be_visitor_ccm_pre_proc::gen_connect_single (be_uses *node)
529 // If this facet comes from a porttype, the instantiated
530 // port/mirrorport name is prefixed to the receptacle name.
531 ACE_CString prefix ("connect_");
532 prefix += this->ctx_->port_prefix ();
534 UTL_ScopedName *op_full_name =
535 this->create_scoped_name (prefix.c_str (),
536 node->local_name ()->get_string (),
537 nullptr,
538 comp_);
539 be_operation *op = nullptr;
540 ACE_NEW_RETURN (op,
541 be_operation (be_global->void_type (),
542 AST_Operation::OP_noflags,
543 nullptr,
546 -1);
547 op->set_defined_in (comp_);
548 op->set_imported (comp_->imported ());
549 op->set_name (op_full_name);
550 Identifier arg_id ("conxn");
551 UTL_ScopedName arg_name (&arg_id,
552 nullptr);
553 be_argument *arg = nullptr;
554 ACE_NEW_RETURN (arg,
555 be_argument (AST_Argument::dir_IN,
556 node->uses_type (),
557 &arg_name),
558 -1);
559 arg_id.destroy ();
560 op->be_add_argument (arg);
562 UTL_ExceptList *tail = nullptr;
563 ACE_NEW_RETURN (tail,
564 UTL_ExceptList (this->invalid_connection_,
565 nullptr),
566 -1);
567 UTL_ExceptList *connect_single = nullptr;
568 ACE_NEW_RETURN (connect_single,
569 UTL_ExceptList (this->already_connected_,
570 tail),
571 -1);
572 op->be_add_exceptions (connect_single);
574 if (nullptr == comp_->be_add_operation (op))
576 return -1;
579 return 0;
583 be_visitor_ccm_pre_proc::gen_disconnect_single (be_uses *node)
585 // If this facet comes from a porttype, the instantiated
586 // port/mirrorport name is prefixed to the receptacle name.
587 ACE_CString prefix ("disconnect_");
588 prefix += this->ctx_->port_prefix ();
590 UTL_ScopedName *op_full_name =
591 this->create_scoped_name (prefix.c_str (),
592 node->local_name ()->get_string (),
593 nullptr,
594 comp_);
595 be_operation *op = nullptr;
596 ACE_NEW_RETURN (op,
597 be_operation (node->uses_type (),
598 AST_Operation::OP_noflags,
599 nullptr,
602 -1);
603 op->set_name (op_full_name);
604 op->set_defined_in (comp_);
605 op->set_imported (comp_->imported ());
606 UTL_ExceptList *disconnect_single = nullptr;
607 ACE_NEW_RETURN (disconnect_single,
608 UTL_ExceptList (this->no_connection_,
609 nullptr),
610 -1);
611 op->be_add_exceptions (disconnect_single);
613 if (nullptr == comp_->be_add_operation (op))
615 return -1;
618 return 0;
622 be_visitor_ccm_pre_proc::gen_get_connection_single (be_uses *node)
624 // If this facet comes from a porttype, the instantiated
625 // port/mirrorport name is prefixed to the receptacle name.
626 ACE_CString prefix ("get_connection_");
627 prefix += this->ctx_->port_prefix ();
629 UTL_ScopedName *op_full_name =
630 this->create_scoped_name (prefix.c_str (),
631 node->local_name ()->get_string (),
632 nullptr,
633 comp_);
634 be_operation *op = nullptr;
635 ACE_NEW_RETURN (op,
636 be_operation (node->uses_type (),
637 AST_Operation::OP_noflags,
638 nullptr,
641 -1);
642 op->set_name (op_full_name);
643 op->set_defined_in (comp_);
644 op->set_imported (comp_->imported ());
646 if (nullptr == comp_->be_add_operation (op))
648 return -1;
651 return 0;
655 be_visitor_ccm_pre_proc::gen_connect_multiple (be_uses *node)
657 // If this facet comes from a porttype, the instantiated
658 // port/mirrorport name is prefixed to the receptacle name.
659 ACE_CString prefix ("connect_");
660 prefix += this->ctx_->port_prefix ();
662 UTL_ScopedName *op_full_name =
663 this->create_scoped_name (prefix.c_str (),
664 node->local_name ()->get_string (),
665 nullptr,
666 comp_);
668 be_operation *op = nullptr;
669 ACE_NEW_RETURN (op,
670 be_operation (this->cookie_,
671 AST_Operation::OP_noflags,
672 nullptr,
675 -1);
676 op->set_name (op_full_name);
677 op->set_defined_in (comp_);
678 op->set_imported (comp_->imported ());
679 Identifier arg_id ("connection");
680 UTL_ScopedName arg_name (&arg_id,
681 nullptr);
682 be_argument *arg = nullptr;
683 ACE_NEW_RETURN (arg,
684 be_argument (AST_Argument::dir_IN,
685 node->uses_type (),
686 &arg_name),
687 -1);
688 arg_id.destroy ();
689 op->be_add_argument (arg);
690 UTL_ExceptList *tail = nullptr;
691 ACE_NEW_RETURN (tail,
692 UTL_ExceptList (this->invalid_connection_,
693 nullptr),
694 -1);
695 UTL_ExceptList *connect_multiple = nullptr;
696 ACE_NEW_RETURN (connect_multiple,
697 UTL_ExceptList (this->exceeded_connection_limit_,
698 tail),
699 -1);
700 op->be_add_exceptions (connect_multiple);
702 if (nullptr == comp_->be_add_operation (op))
704 return -1;
707 return 0;
711 be_visitor_ccm_pre_proc::gen_disconnect_multiple (be_uses *node)
713 // If this facet comes from a porttype, the instantiated
714 // port/mirrorport name is prefixed to the receptacle name.
715 ACE_CString prefix ("disconnect_");
716 prefix += this->ctx_->port_prefix ();
718 UTL_ScopedName *op_full_name =
719 this->create_scoped_name (prefix.c_str (),
720 node->local_name ()->get_string (),
721 nullptr,
722 comp_);
723 be_operation *op = nullptr;
724 ACE_NEW_RETURN (op,
725 be_operation (node->uses_type (),
726 AST_Operation::OP_noflags,
727 nullptr,
730 -1);
731 op->set_name (op_full_name);
732 op->set_defined_in (comp_);
733 op->set_imported (comp_->imported ());
734 Identifier arg_id ("ck");
735 UTL_ScopedName arg_name (&arg_id,
736 nullptr);
737 be_argument *arg = nullptr;
738 ACE_NEW_RETURN (arg,
739 be_argument (AST_Argument::dir_IN,
740 this->cookie_,
741 &arg_name),
742 -1);
743 arg_id.destroy ();
744 op->be_add_argument (arg);
745 UTL_ExceptList *disconnect_multiple = nullptr;
746 ACE_NEW_RETURN (disconnect_multiple,
747 UTL_ExceptList (this->invalid_connection_,
748 nullptr),
749 -1);
750 op->be_add_exceptions (disconnect_multiple);
752 if (nullptr == comp_->be_add_operation (op))
754 return -1;
757 return 0;
761 be_visitor_ccm_pre_proc::gen_get_connection_multiple (be_uses *node)
763 // If this facet comes from a porttype, the instantiated
764 // port/mirrorport name is prefixed to the receptacle name.
765 ACE_CString prefix ("get_connections_");
766 prefix += this->ctx_->port_prefix ();
768 UTL_ScopedName *op_full_name =
769 this->create_scoped_name (prefix.c_str (),
770 node->local_name ()->get_string (),
771 nullptr,
772 comp_);
774 // Look up the implied IDL typedef created in the front end.
775 // It will be the return type of the created operation. The
776 // sequence was originally created with the port prefix (if
777 // any) in its name, so we must use it here.
778 ACE_CString connections_string (this->ctx_->port_prefix ());
779 connections_string += node->local_name ()->get_string ();
780 connections_string += "Connections";
781 Identifier connections_id (connections_string.c_str ());
782 UTL_ScopedName connections_name (&connections_id,
783 nullptr);
784 AST_Decl *d = comp_->lookup_by_name (&connections_name,
785 true);
786 be_typedef *td = dynamic_cast<be_typedef*> (d);
787 connections_id.destroy ();
789 be_operation *op = nullptr;
790 ACE_NEW_RETURN (op,
791 be_operation (td,
792 AST_Operation::OP_noflags,
793 nullptr,
796 -1);
797 op->set_name (op_full_name);
798 op->set_defined_in (comp_);
799 op->set_imported (comp_->imported ());
801 if (nullptr == comp_->be_add_operation (op))
803 return -1;
806 return 0;
810 be_visitor_ccm_pre_proc::gen_push_op (be_eventtype *node,
811 AST_Interface *consumer)
813 if (!be_global->gen_noeventccm ())
815 UTL_ScopedName *op_full_name =
816 this->create_scoped_name ("push_",
817 node->local_name (),
818 nullptr,
819 consumer);
820 be_operation *push_op = nullptr;
821 ACE_NEW_RETURN (push_op,
822 be_operation (be_global->void_type (),
823 AST_Operation::OP_noflags,
824 nullptr,
825 false,
826 false),
827 -1);
828 push_op->set_defined_in (consumer);
829 push_op->set_imported (node->imported ());
830 push_op->set_name (op_full_name);
831 ACE_CString arg_string ("the_",
832 nullptr,
833 false);
834 arg_string += node->local_name ();
835 Identifier arg_id (arg_string.fast_rep ());
836 UTL_ScopedName arg_name (&arg_id,
837 nullptr);
838 be_argument *arg = nullptr;
839 ACE_NEW_RETURN (arg,
840 be_argument (AST_Argument::dir_IN,
841 node,
842 &arg_name),
843 -1);
844 arg_id.destroy ();
845 push_op->be_add_argument (arg);
847 if (nullptr == consumer->be_add_operation (push_op))
849 return -1;
852 return 0;
856 be_visitor_ccm_pre_proc::gen_subscribe (be_publishes *node)
858 if ((be_global->gen_lwccm ()) ||(be_global->gen_noeventccm ()))
860 return 0;
863 UTL_ScopedName *op_name =
864 this->create_scoped_name ("subscribe_",
865 node->local_name ()->get_string (),
866 nullptr,
867 comp_);
868 be_operation *op = nullptr;
869 ACE_NEW_RETURN (op,
870 be_operation (this->cookie_,
871 AST_Operation::OP_noflags,
872 nullptr,
875 -1);
876 op->set_defined_in (comp_);
877 op->set_imported (comp_->imported ());
878 op->set_name (op_name);
880 AST_Interface *i = this->lookup_consumer (node);
882 if (i == nullptr)
884 op->destroy ();
885 delete op;
886 op = nullptr;
888 ACE_ERROR_RETURN ((LM_ERROR,
889 ACE_TEXT ("be_visitor_ccm_pre_proc::")
890 ACE_TEXT ("gen_subscribe - ")
891 ACE_TEXT ("consumer lookup failed\n")),
892 -1);
895 Identifier arg_id ("consumer");
896 UTL_ScopedName arg_name (&arg_id,
897 nullptr);
898 be_argument *arg = nullptr;
899 ACE_NEW_RETURN (arg,
900 be_argument (AST_Argument::dir_IN,
902 &arg_name),
903 -1);
904 op->be_add_argument (arg);
905 UTL_ExceptList *subscribe = nullptr;
906 ACE_NEW_RETURN (subscribe,
907 UTL_ExceptList (this->exceeded_connection_limit_,
908 nullptr),
909 -1);
910 op->be_add_exceptions (subscribe);
912 if (nullptr == comp_->be_add_operation (op))
914 return -1;
917 return 0;
921 be_visitor_ccm_pre_proc::gen_unsubscribe (be_publishes *node)
923 if (be_global->gen_lwccm () ||be_global->gen_noeventccm ())
925 return 0;
928 AST_Interface *i = this->lookup_consumer (node);
930 if (i == nullptr)
932 ACE_ERROR_RETURN ((LM_ERROR,
933 ACE_TEXT ("be_visitor_ccm_pre_proc::")
934 ACE_TEXT ("gen_unsubscribe - ")
935 ACE_TEXT ("consumer lookup failed\n")),
936 -1);
939 UTL_ScopedName *op_name =
940 this->create_scoped_name ("unsubscribe_",
941 node->local_name ()->get_string (),
942 nullptr,
943 comp_);
944 be_operation *op = nullptr;
945 ACE_NEW_RETURN (op,
946 be_operation (i,
947 AST_Operation::OP_noflags,
948 nullptr,
951 -1);
952 op->set_defined_in (comp_);
953 op->set_imported (comp_->imported ());
954 op->set_name (op_name);
955 Identifier arg_id ("ck");
956 UTL_ScopedName arg_name (&arg_id,
957 nullptr);
958 be_argument *arg = nullptr;
959 ACE_NEW_RETURN (arg,
960 be_argument (AST_Argument::dir_IN,
961 this->cookie_,
962 &arg_name),
963 -1);
964 op->be_add_argument (arg);
965 UTL_ExceptList *unsubscribe = nullptr;
966 ACE_NEW_RETURN (unsubscribe,
967 UTL_ExceptList (this->invalid_connection_,
968 nullptr),
969 -1);
970 op->be_add_exceptions (unsubscribe);
972 if (nullptr == comp_->be_add_operation (op))
974 return -1;
977 return 0;
981 be_visitor_ccm_pre_proc::gen_emits_connect (be_emits *node)
983 if ((be_global->gen_lwccm ()) ||(be_global->gen_noeventccm ()))
985 return 0;
988 UTL_ScopedName *op_name =
989 this->create_scoped_name ("connect_",
990 node->local_name ()->get_string (),
991 nullptr,
992 comp_);
993 be_operation *op = nullptr;
994 ACE_NEW_RETURN (op,
995 be_operation (be_global->void_type (),
996 AST_Operation::OP_noflags,
997 nullptr,
1000 -1);
1001 op->set_name (op_name);
1002 op->set_defined_in (comp_);
1003 op->set_imported (comp_->imported ());
1004 AST_Interface *i = this->lookup_consumer (node);
1006 if (i == nullptr)
1008 op->destroy ();
1009 delete op;
1010 op = nullptr;
1012 ACE_ERROR_RETURN ((LM_ERROR,
1013 ACE_TEXT ("be_visitor_ccm_pre_proc::")
1014 ACE_TEXT ("gen_emits_connect - ")
1015 ACE_TEXT ("consumer lookup failed\n")),
1016 -1);
1019 Identifier arg_id ("consumer");
1020 UTL_ScopedName arg_name (&arg_id,
1021 nullptr);
1022 be_argument *arg = nullptr;
1023 ACE_NEW_RETURN (arg,
1024 be_argument (AST_Argument::dir_IN,
1026 &arg_name),
1027 -1);
1028 op->be_add_argument (arg);
1029 UTL_ExceptList *emits_connect = nullptr;
1030 ACE_NEW_RETURN (emits_connect,
1031 UTL_ExceptList (this->already_connected_,
1032 nullptr),
1033 -1);
1034 op->be_add_exceptions (emits_connect);
1036 if (nullptr == comp_->be_add_operation (op))
1038 return -1;
1041 return 0;
1045 be_visitor_ccm_pre_proc::gen_emits_disconnect (be_emits *node)
1047 if ((be_global->gen_lwccm ()) ||(be_global->gen_noeventccm ()))
1049 return 0;
1052 AST_Interface *i = this->lookup_consumer (node);
1054 if (i == nullptr)
1056 ACE_ERROR_RETURN ((LM_ERROR,
1057 ACE_TEXT ("be_visitor_ccm_pre_proc::")
1058 ACE_TEXT ("gen_emits_disconnect - ")
1059 ACE_TEXT ("consumer lookup failed\n")),
1060 -1);
1063 UTL_ScopedName *op_name =
1064 this->create_scoped_name ("disconnect_",
1065 node->local_name ()->get_string (),
1066 nullptr,
1067 comp_);
1068 be_operation *op = nullptr;
1069 ACE_NEW_RETURN (op,
1070 be_operation (i,
1071 AST_Operation::OP_noflags,
1072 nullptr,
1075 -1);
1076 op->set_name (op_name);
1077 op->set_defined_in (comp_);
1078 op->set_imported (comp_->imported ());
1079 UTL_ExceptList *emits_disconnect = nullptr;
1080 ACE_NEW_RETURN (emits_disconnect,
1081 UTL_ExceptList (this->no_connection_,
1082 nullptr),
1083 -1);
1084 op->be_add_exceptions (emits_disconnect);
1086 if (nullptr == comp_->be_add_operation (op))
1088 return -1;
1091 return 0;
1095 be_visitor_ccm_pre_proc::gen_get_consumer (be_consumes *node)
1097 if (be_global->gen_lwccm () || be_global->gen_noeventccm ())
1099 return 0;
1102 AST_Interface *i = this->lookup_consumer (node);
1104 if (i == nullptr)
1106 ACE_ERROR_RETURN ((LM_ERROR,
1107 ACE_TEXT ("be_visitor_ccm_pre_proc::")
1108 ACE_TEXT ("gen_get_consumer - ")
1109 ACE_TEXT ("consumer lookup failed\n")),
1110 -1);
1113 UTL_ScopedName *op_name =
1114 this->create_scoped_name ("get_consumer_",
1115 node->local_name ()->get_string (),
1116 nullptr,
1117 comp_);
1118 be_operation *op = nullptr;
1119 ACE_NEW_RETURN (op,
1120 be_operation (i,
1121 AST_Operation::OP_noflags,
1122 nullptr,
1125 -1);
1126 op->set_name (op_name);
1127 op->set_defined_in (comp_);
1128 op->set_imported (comp_->imported ());
1130 if (nullptr == comp_->be_add_operation (op))
1132 return -1;
1135 return 0;
1139 be_visitor_ccm_pre_proc::gen_create (be_home *node,
1140 AST_Interface *implicit)
1142 UTL_ScopedName *op_name = this->create_scoped_name (nullptr,
1143 "create",
1144 nullptr,
1145 implicit);
1146 be_operation *op = nullptr;
1147 ACE_NEW_RETURN (op,
1148 be_operation (node->managed_component (),
1149 AST_Operation::OP_noflags,
1150 nullptr,
1153 -1);
1154 op->set_name (op_name);
1155 AST_Type *pk = node->primary_key ();
1156 UTL_ExceptList *exceps = nullptr;
1157 ACE_NEW_RETURN (exceps,
1158 UTL_ExceptList (this->create_failure_,
1159 nullptr),
1160 -1);
1162 if (pk != nullptr && !be_global->gen_lwccm ())
1164 Identifier arg_id ("key");
1165 UTL_ScopedName arg_name (&arg_id,
1166 nullptr);
1167 AST_Argument *arg = nullptr;
1168 ACE_NEW_RETURN (arg,
1169 be_argument (AST_Argument::dir_IN,
1171 &arg_name),
1172 -1);
1173 arg_id.destroy ();
1174 op->be_add_argument (arg);
1176 UTL_ExceptList *tail = nullptr;
1177 ACE_NEW_RETURN (tail,
1178 UTL_ExceptList (this->invalid_key_,
1179 nullptr),
1180 -1);
1181 UTL_ExceptList *middle = nullptr;
1182 ACE_NEW_RETURN (middle,
1183 UTL_ExceptList (this->duplicate_key_value_,
1184 tail),
1185 -1);
1186 exceps->nconc (middle);
1189 op->be_add_exceptions (exceps);
1190 op->set_defined_in (implicit);
1191 op->set_imported (node->imported ());
1193 if (nullptr == implicit->be_add_operation (op))
1195 return -1;
1198 return 0;
1202 be_visitor_ccm_pre_proc::gen_find_by_primary_key (be_home *node,
1203 AST_Interface *implicit)
1205 UTL_ScopedName *op_name = this->create_scoped_name (nullptr,
1206 "find_by_primary_key",
1207 nullptr,
1208 implicit);
1209 be_operation *op = nullptr;
1210 ACE_NEW_RETURN (op,
1211 be_operation (node->managed_component (),
1212 AST_Operation::OP_noflags,
1213 nullptr,
1216 -1);
1217 op->set_name (op_name);
1218 AST_Type *pk = node->primary_key ();
1219 Identifier arg_id ("key");
1220 UTL_ScopedName arg_name (&arg_id,
1221 nullptr);
1222 AST_Argument *arg = nullptr;
1223 ACE_NEW_RETURN (arg,
1224 be_argument (AST_Argument::dir_IN,
1226 &arg_name),
1227 -1);
1228 arg_id.destroy ();
1229 op->be_add_argument (arg);
1231 UTL_ExceptList *tail = nullptr;
1232 UTL_ExceptList *middle = nullptr;
1234 if (!be_global->gen_lwccm ())
1236 ACE_NEW_RETURN (tail,
1237 UTL_ExceptList (this->invalid_key_,
1238 nullptr),
1239 -1);
1240 ACE_NEW_RETURN (middle,
1241 UTL_ExceptList (this->unknown_key_value_,
1242 tail),
1243 -1);
1246 UTL_ExceptList *exceps = nullptr;
1247 ACE_NEW_RETURN (exceps,
1248 UTL_ExceptList (this->finder_failure_,
1249 middle),
1250 -1);
1251 op->be_add_exceptions (exceps);
1252 op->set_defined_in (implicit);
1253 op->set_imported (node->imported ());
1255 if (nullptr == implicit->be_add_operation (op))
1257 return -1;
1260 return 0;
1264 be_visitor_ccm_pre_proc::gen_remove (be_home *node,
1265 AST_Interface *implicit)
1267 UTL_ScopedName *op_name = this->create_scoped_name (nullptr,
1268 "remove",
1269 nullptr,
1270 implicit);
1271 be_operation *op = nullptr;
1272 ACE_NEW_RETURN (op,
1273 be_operation (be_global->void_type (),
1274 AST_Operation::OP_noflags,
1275 nullptr,
1278 -1);
1279 op->set_name (op_name);
1280 AST_Type *pk = node->primary_key ();
1281 Identifier arg_id ("key");
1282 UTL_ScopedName arg_name (&arg_id,
1283 nullptr);
1284 AST_Argument *arg = nullptr;
1285 ACE_NEW_RETURN (arg,
1286 be_argument (AST_Argument::dir_IN,
1288 &arg_name),
1289 -1);
1290 arg_id.destroy ();
1291 op->be_add_argument (arg);
1293 UTL_ExceptList *tail = nullptr;
1294 UTL_ExceptList *middle = nullptr;
1296 if (!be_global->gen_lwccm ())
1298 ACE_NEW_RETURN (tail,
1299 UTL_ExceptList (this->invalid_key_,
1300 nullptr),
1301 -1);
1302 ACE_NEW_RETURN (middle,
1303 UTL_ExceptList (this->unknown_key_value_,
1304 tail),
1305 -1);
1308 UTL_ExceptList *exceps = nullptr;
1309 ACE_NEW_RETURN (exceps,
1310 UTL_ExceptList (this->remove_failure_,
1311 middle),
1312 -1);
1313 op->be_add_exceptions (exceps);
1314 op->set_defined_in (implicit);
1315 op->set_imported (node->imported ());
1317 if (nullptr == implicit->be_add_operation (op))
1319 return -1;
1322 return 0;
1326 be_visitor_ccm_pre_proc::gen_get_primary_key (be_home *node,
1327 AST_Interface *implicit)
1329 UTL_ScopedName *op_name = this->create_scoped_name (nullptr,
1330 "get_primary_key",
1331 nullptr,
1332 implicit);
1333 be_operation *op = nullptr;
1334 ACE_NEW_RETURN (op,
1335 be_operation (node->primary_key (),
1336 AST_Operation::OP_noflags,
1337 nullptr,
1340 -1);
1341 op->set_name (op_name);
1342 Identifier arg_id ("comp");
1343 UTL_ScopedName arg_name (&arg_id,
1344 nullptr);
1345 AST_Argument *arg = nullptr;
1346 ACE_NEW_RETURN (arg,
1347 be_argument (AST_Argument::dir_IN,
1348 node->managed_component (),
1349 &arg_name),
1350 -1);
1351 arg_id.destroy ();
1352 op->be_add_argument (arg);
1353 op->set_defined_in (implicit);
1354 op->set_imported (node->imported ());
1356 if (nullptr == implicit->be_add_operation (op))
1358 return -1;
1361 return 0;
1365 be_visitor_ccm_pre_proc::gen_extended_port (be_porttype *pt)
1367 if (this->visit_scope (pt) == -1)
1369 ACE_ERROR_RETURN ((LM_ERROR,
1370 ACE_TEXT ("be_visitor_ccm_pre_proc::")
1371 ACE_TEXT ("gen_extended_port - ")
1372 ACE_TEXT ("visit_scope for porttype failed\n")),
1373 -1);
1376 return 0;
1380 be_visitor_ccm_pre_proc::lookup_cookie ()
1382 if (this->cookie_ == nullptr)
1384 Identifier local_id ("Cookie");
1385 UTL_ScopedName local_name (&local_id,
1386 nullptr);
1387 UTL_ScopedName cookie_name (&this->module_id_,
1388 &local_name);
1389 AST_Decl *d =
1390 idl_global->root ()->lookup_by_name (&cookie_name,
1391 true);
1392 local_id.destroy ();
1394 if (d == nullptr)
1396 idl_global->err ()->lookup_error (&cookie_name);
1397 return -1;
1400 this->cookie_ = dynamic_cast<be_valuetype*> (d);
1402 if (this->cookie_ == nullptr)
1404 idl_global->err ()->valuetype_expected (d);
1405 return -1;
1409 return 0;
1413 be_visitor_ccm_pre_proc::lookup_exceptions ()
1415 int status = 0;
1417 for (int i = 0; i < N_LW_EXCEPS; ++i)
1419 status = this->lookup_one_exception (LW_EXCEP_NAMES[i],
1420 LW_EXCEPS[i]);
1422 if (status == -1)
1424 return -1;
1428 this->already_connected_ = LW_EXCEPS[0];
1429 this->invalid_connection_ = LW_EXCEPS[1];
1430 this->no_connection_ = LW_EXCEPS[2];
1431 this->exceeded_connection_limit_ = LW_EXCEPS[3];
1432 this->create_failure_ = LW_EXCEPS[4];
1433 this->remove_failure_ = LW_EXCEPS[5];
1434 this->finder_failure_ = LW_EXCEPS[6];
1436 if (!be_global->gen_lwccm ())
1438 for (int j = 0; j < N_ADDL_EXCEPS; ++j)
1440 status = this->lookup_one_exception (ADDL_EXCEP_NAMES[j],
1441 ADDL_EXCEPS[j]);
1443 if (status == -1)
1445 return -1;
1449 this->invalid_key_ = ADDL_EXCEPS[0];
1450 this->unknown_key_value_ = ADDL_EXCEPS[1];
1451 this->duplicate_key_value_ = ADDL_EXCEPS[2];
1454 return 0;
1458 be_visitor_ccm_pre_proc::lookup_one_exception (const char *name,
1459 be_exception *&result)
1461 Identifier id (name);
1462 UTL_ScopedName local_name (&id,
1463 nullptr);
1464 UTL_ScopedName scoped_name (&this->module_id_,
1465 &local_name);
1466 AST_Decl *d =
1467 idl_global->root ()->lookup_by_name (&scoped_name,
1468 true);
1469 id.destroy ();
1471 if (d == nullptr)
1473 idl_global->err ()->lookup_error (&scoped_name);
1474 return -1;
1477 result = dynamic_cast<be_exception*> (d);
1479 if (result == nullptr)
1481 return -1;
1484 return 0;
1488 be_visitor_ccm_pre_proc::create_event_consumer (be_eventtype *node)
1490 UTL_Scope *s = node->defined_in ();
1492 UTL_ScopedName *consumer_name =
1493 this->create_scoped_name (nullptr,
1494 node->local_name (),
1495 "Consumer",
1496 ScopeAsDecl (node->defined_in ()));
1498 /// We need to create event consumers even for forward
1499 /// declared eventtypes. Since forward declarations can
1500 /// appear any number of times, we need to check that this
1501 /// event consumer hasn't already been created.
1502 if (s->lookup_by_name (consumer_name, true) != nullptr)
1504 return 0;
1507 AST_Interface *event_consumer = nullptr;
1508 AST_Module *m = dynamic_cast<AST_Module*> (s);
1510 // We're at global scope here so we need to fool the scope stack
1511 // for a minute so the correct repo id can be calculated at
1512 // interface construction time.
1513 idl_global->scopes ().push (s);
1515 Identifier parent_id ("EventConsumerBase");
1516 UTL_ScopedName parent_local_name (&parent_id,
1517 nullptr);
1518 UTL_ScopedName parent_full_name (&this->module_id_,
1519 &parent_local_name);
1520 UTL_NameList parent_list (&parent_full_name,
1521 nullptr);
1522 FE_InterfaceHeader header (consumer_name,
1523 &parent_list,
1524 false,
1525 false,
1526 true);
1527 ACE_NEW_RETURN (event_consumer,
1528 be_interface (header.name (),
1529 header.inherits (),
1530 header.n_inherits (),
1531 header.inherits_flat (),
1532 header.n_inherits_flat (),
1533 false,
1534 false),
1535 -1);
1536 parent_id.destroy ();
1538 // Back to reality.
1539 idl_global->scopes ().pop ();
1541 event_consumer->set_defined_in (s);
1542 event_consumer->set_imported (node->imported ());
1543 event_consumer->set_name (consumer_name);
1544 be_interface *bec =
1545 dynamic_cast<be_interface*> (event_consumer);
1546 bec->original_interface (node);
1548 // Set repo id to 0, so it will be recomputed on the next access,
1549 // and set the prefix to the eventtype's prefix. All this is
1550 // necessary in case the eventtype's prefix was modified after
1551 // its declaration. We assume 'implied IDL' means that the
1552 // derived event consumer interface should have the same prefix.
1553 event_consumer->repoID (nullptr);
1554 event_consumer->prefix (const_cast<char*> (node->prefix ()));
1556 dynamic_cast<be_type*> (event_consumer)->gen_fwd_helper_name ();
1557 m->be_add_interface (event_consumer);
1558 return this->gen_push_op (node,
1559 event_consumer);
1562 AST_Interface *
1563 be_visitor_ccm_pre_proc::lookup_consumer (be_field *node)
1565 AST_Type *impl = node->field_type ();
1566 ACE_CString rettype_string (impl->local_name ()->get_string ());
1567 rettype_string += "Consumer";
1568 Identifier rettype_id (rettype_string.fast_rep ());
1569 AST_Decl *d =
1570 impl->defined_in ()->lookup_by_name_local (&rettype_id, false);
1571 rettype_id.destroy ();
1573 if (d == nullptr)
1575 return nullptr;
1578 AST_Interface *i = dynamic_cast<AST_Interface*> (d);
1580 if (i == nullptr)
1582 idl_global->err ()->interface_expected (d);
1583 return nullptr;
1586 return i;
1589 AST_Interface *
1590 be_visitor_ccm_pre_proc::create_explicit (be_home *node)
1592 be_visitor_xplicit_pre_proc v (this->ctx_);
1594 if (v.visit_home (node) != 0)
1596 ACE_ERROR_RETURN ((LM_ERROR,
1597 ACE_TEXT ("be_visitor_ccm_pre_proc::")
1598 ACE_TEXT ("create_explicit - ")
1599 ACE_TEXT ("home xplicit visitor failed\n")),
1603 return v.xplicit ();
1606 AST_Interface *
1607 be_visitor_ccm_pre_proc::create_implicit (be_home *node)
1609 Identifier *parent_id = nullptr;
1610 ACE_NEW_RETURN (parent_id,
1611 Identifier ("KeylessCCMHome"),
1612 nullptr);
1614 UTL_ScopedName *parent_local_name = nullptr;
1615 ACE_NEW_RETURN (parent_local_name,
1616 UTL_ScopedName (parent_id, nullptr),
1617 nullptr);
1619 UTL_ScopedName *parent_full_name = nullptr;
1620 ACE_NEW_RETURN (parent_full_name,
1621 UTL_ScopedName (this->module_id_.copy (),
1622 parent_local_name),
1623 nullptr);
1625 UTL_NameList parent_list (parent_full_name, nullptr);
1627 UTL_NameList *parent_list_ptr = nullptr;
1629 if (node->primary_key () == nullptr)
1631 parent_list_ptr = &parent_list;
1634 FE_InterfaceHeader header (nullptr,
1635 parent_list_ptr,
1636 false,
1637 false,
1638 true);
1640 // We're at global scope here so we need to fool the scope stack
1641 // for a minute so the correct repo id can be calculated at
1642 // interface construction time.
1643 idl_global->scopes ().push (node->defined_in ());
1645 UTL_ScopedName *implicit_name =
1646 this->create_scoped_name (nullptr,
1647 node->local_name (),
1648 "Implicit",
1649 ScopeAsDecl (node->defined_in ()));
1651 be_interface *i = nullptr;
1652 ACE_NEW_RETURN (i,
1653 be_interface (implicit_name,
1654 header.inherits (),
1655 header.n_inherits (),
1656 header.inherits_flat (),
1657 header.n_inherits_flat (),
1658 false,
1659 false),
1660 nullptr);
1662 // Back to reality.
1663 idl_global->scopes ().pop ();
1665 header.destroy ();
1666 parent_list.destroy ();
1668 // So we can generate the proper typecode.
1669 i->home_equiv (true);
1671 i->set_name (implicit_name);
1672 i->set_defined_in (node->defined_in ());
1673 i->set_imported (node->imported ());
1675 i->gen_fwd_helper_name ();
1676 i->original_interface (node);
1677 AST_Module *m = dynamic_cast<AST_Module*> (node->defined_in ());
1678 m->be_add_interface (i);
1680 return i;
1683 AST_Interface *
1684 be_visitor_ccm_pre_proc::create_equivalent (be_home *node,
1685 AST_Interface *xplicit,
1686 AST_Interface *implicit)
1688 UTL_Scope *s = node->defined_in ();
1689 UTL_ScopedName *equiv_name =
1690 this->create_scoped_name (nullptr,
1691 node->local_name (),
1692 nullptr,
1693 ScopeAsDecl (s));
1694 UTL_NameList tail (implicit->name (),
1695 nullptr);
1696 UTL_NameList parent_list (xplicit->name (),
1697 &tail);
1698 FE_InterfaceHeader header (nullptr,
1699 &parent_list,
1700 false,
1701 false,
1702 true);
1704 // We're at global scope here so we need to fool the scope stack
1705 // for a minute so the correct repo id can be calculated at
1706 // interface construction time.
1707 idl_global->scopes ().push (node->defined_in ());
1709 be_interface *retval = nullptr;
1710 ACE_NEW_RETURN (retval,
1711 be_interface (equiv_name,
1712 header.inherits (),
1713 header.n_inherits (),
1714 header.inherits_flat (),
1715 header.n_inherits_flat (),
1716 false,
1717 false),
1718 nullptr);
1720 // Back to reality.
1721 idl_global->scopes ().pop ();
1723 // So we can generate the proper typecode.
1724 retval->home_equiv (true);
1726 retval->set_name (equiv_name);
1727 retval->set_defined_in (s);
1728 retval->set_imported (node->imported ());
1729 retval->gen_fwd_helper_name ();
1730 retval->original_interface (node);
1732 UTL_ScopedName *unmangled_name =
1733 static_cast<UTL_ScopedName *> (node->name ()->copy ());
1734 UTL_ScopedName *mangled_name =
1735 this->create_scoped_name (nullptr,
1736 node->local_name (),
1737 "_tao_home_name_extension",
1738 ScopeAsDecl (s));
1739 node->set_name (mangled_name);
1740 AST_Module *m = dynamic_cast<AST_Module*> (s);
1742 /// Calling be_add_interface() here calls add_to_referenced(),
1743 /// which will give a redef error.
1744 m->add_to_scope (retval);
1746 node->set_name (unmangled_name);
1747 return retval;
1750 UTL_ScopedName *
1751 be_visitor_ccm_pre_proc::create_scoped_name (const char *prefix,
1752 const char *local_name,
1753 const char *suffix,
1754 AST_Decl *parent)
1756 ACE_CString local_string (prefix,
1757 nullptr,
1758 false);
1759 local_string += local_name;
1760 local_string += suffix;
1761 Identifier *local_id = nullptr;
1762 ACE_NEW_RETURN (local_id,
1763 Identifier (local_string.fast_rep ()),
1764 nullptr);
1765 UTL_ScopedName *last_segment = nullptr;
1766 ACE_NEW_RETURN (last_segment,
1767 UTL_ScopedName (local_id,
1768 nullptr),
1769 nullptr);
1770 UTL_ScopedName *full_name =
1771 static_cast<UTL_ScopedName *> (parent->name ()->copy ());
1772 full_name->nconc (last_segment);
1773 return full_name;
1776 UTL_NameList *
1777 be_visitor_ccm_pre_proc::compute_inheritance (be_home *node)
1779 UTL_NameList *retval = nullptr;
1781 if (node->base_home () == nullptr)
1783 Identifier *local_id = nullptr;
1784 ACE_NEW_RETURN (local_id,
1785 Identifier ("CCMHome"),
1786 nullptr);
1787 UTL_ScopedName *local_name = nullptr;
1788 ACE_NEW_RETURN (local_name,
1789 UTL_ScopedName (local_id,
1790 nullptr),
1791 nullptr);
1792 UTL_ScopedName *full_name = nullptr;
1793 ACE_NEW_RETURN (full_name,
1794 UTL_ScopedName (this->module_id_.copy (),
1795 local_name),
1796 nullptr);
1797 ACE_NEW_RETURN (retval,
1798 UTL_NameList (full_name,
1799 nullptr),
1800 nullptr);
1802 else
1804 ACE_CString new_local (
1805 node->base_home ()->local_name ()->get_string ()
1807 new_local += "Explicit";
1808 UTL_ScopedName *parent_name =
1809 static_cast<UTL_ScopedName *> (node->base_home ()->name ()->copy ());
1810 parent_name->last_component ()->replace_string (new_local.c_str ());
1811 ACE_NEW_RETURN (retval,
1812 UTL_NameList (parent_name,
1813 nullptr),
1814 nullptr);
1817 long n_supports = node->n_inherits ();
1818 UTL_ScopedName *supported_name = nullptr;
1819 UTL_NameList *conc_value = nullptr;
1821 for (long i = 0; i < n_supports; ++i)
1823 supported_name =
1824 static_cast<UTL_ScopedName *> (node->inherits ()[i]->name ()->copy ());
1825 ACE_NEW_RETURN (conc_value,
1826 UTL_NameList (supported_name,
1827 nullptr),
1828 nullptr);
1829 retval->nconc (conc_value);
1832 return retval;
1836 be_visitor_ccm_pre_proc::generate_ami4ccm_uses ()
1838 /// The interfaces in the list below are from this IDL file,
1839 /// which then must be processed with the -GC option, so we
1840 /// know we'll get here - a good place to generate the *A.idl
1841 /// file containing the local interfaces and connector
1842 /// associated with each interface in the list.
1844 ACE_Unbounded_Queue<char *> &ccm_ami_receps =
1845 idl_global->ciao_ami_recep_names ();
1847 /// If the queue is empty, we're done.
1848 if (ccm_ami_receps.size () == 0)
1850 return 0;
1853 for (ACE_Unbounded_Queue<char *>::CONST_ITERATOR i (
1854 ccm_ami_receps);
1855 ! i.done ();
1856 i.advance ())
1858 char **item = nullptr;
1859 i.next (item);
1861 UTL_ScopedName *sn =
1862 FE_Utils::string_to_scoped_name (*item);
1864 UTL_Scope *s =
1865 idl_global->scopes ().top_non_null ();
1867 AST_Decl *d = s->lookup_by_name (sn, true);
1869 if (d == nullptr)
1871 idl_global->err ()->lookup_error (sn);
1873 sn->destroy ();
1874 delete sn;
1875 sn = nullptr;
1877 continue;
1880 sn->destroy ();
1881 delete sn;
1882 sn = nullptr;
1884 be_uses *u = dynamic_cast<be_uses*> (d);
1886 if (u == nullptr)
1888 ACE_ERROR_RETURN ((LM_ERROR,
1889 ACE_TEXT ("be_visitor_ccm_pre_proc")
1890 ACE_TEXT ("::generate_ami4ccm_uses - ")
1891 ACE_TEXT ("narrow to receptacle ")
1892 ACE_TEXT ("failed\n")),
1893 -1);
1896 be_interface *iface =
1897 dynamic_cast<be_interface*> (u->uses_type ());
1899 /// The real AMI_xxx exists only in the *A.idl file, so
1900 /// we create a dummy as the uses type for the implied
1901 /// receptacle created below, but only if it hasn't
1902 /// already been created for this uses type.
1904 be_interface *ami_iface =
1905 dynamic_cast<be_interface*> (iface->ami4ccm_uses ());
1907 if (ami_iface == nullptr)
1909 ACE_CString iname ("AMI4CCM_");
1911 iname += iface->local_name ();
1912 Identifier itmp_id (iname.c_str ());
1913 UTL_ScopedName itmp_sn (&itmp_id, nullptr);
1915 s = iface->defined_in ();
1916 idl_global->scopes ().push (s);
1917 ACE_NEW_RETURN (ami_iface,
1918 be_interface (&itmp_sn,
1919 nullptr,
1921 nullptr,
1923 true,
1924 false),
1925 -1);
1927 idl_global->scopes ().pop ();
1929 /// Make it imported so it doesn't trigger
1930 /// any unwanted code generation.
1931 ami_iface->set_imported (true);
1933 s->add_to_scope (ami_iface);
1934 iface->ami4ccm_uses (ami_iface);
1937 /// Now create the receptacle, passing in
1938 /// the local interface created above as the
1939 /// uses type. We don't generate anything
1940 /// in the main IDL file from the interface's
1941 /// contents, so it's ok that it's empty.
1943 ACE_CString uname ("sendc_");
1944 uname += u->local_name ()->get_string ();
1945 Identifier utmp_id (uname.c_str ());
1946 UTL_ScopedName utmp_sn (&utmp_id, nullptr);
1948 s = u->defined_in ();
1949 idl_global->scopes ().push (s);
1950 be_uses *ami_uses = nullptr;
1951 ACE_NEW_RETURN (ami_uses,
1952 be_uses (&utmp_sn,
1953 ami_iface,
1954 u->is_multiple ()),
1955 -1);
1957 s->add_to_scope (ami_uses);
1958 idl_global->scopes ().pop ();
1960 if (u->is_multiple ())
1963 AST_Type *t = u->uses_type ();
1964 ACE_CString fname (t->file_name ());
1965 char *dummy = 0;
1966 char *path = ACE_OS::realpath (fname.c_str (), dummy);
1967 ACE_DEBUG ((LM_DEBUG, "utype file: %s\n", path));
1969 // Grammar ensures this narrowing will never be 0.
1970 AST_Component *c =
1971 dynamic_cast<AST_Component*> (s);
1972 FE_Utils::create_uses_multiple_stuff (c, ami_uses);
1976 return 0;