Remove redundant void from tao_idl
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_ccm_pre_proc.cpp
blobb2ce62ec6a3a6da56b66e344aa15f08f79d2f550
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_ (0),
78 already_connected_ (0),
79 invalid_connection_ (0),
80 no_connection_ (0),
81 exceeded_connection_limit_ (0),
82 create_failure_ (0),
83 remove_failure_ (0),
84 finder_failure_ (0),
85 invalid_key_ (0),
86 unknown_key_value_ (0),
87 duplicate_key_value_ (0),
88 comp_ (0),
89 home_ (0),
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 = 0;
216 UTL_ScopedName *op_name =
217 this->create_scoped_name (prefix.c_str (),
218 node->local_name ()->get_string (),
220 comp_);
221 ACE_NEW_RETURN (provides_op,
222 be_operation (node->provides_type (),
223 AST_Operation::OP_noflags,
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 (0 == 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 == 0)
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 == 0)
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) == 0)
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 == 0)
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 (),
538 comp_);
539 be_operation *op = 0;
540 ACE_NEW_RETURN (op,
541 be_operation (be_global->void_type (),
542 AST_Operation::OP_noflags,
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,
553 be_argument *arg = 0;
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 = 0;
563 ACE_NEW_RETURN (tail,
564 UTL_ExceptList (this->invalid_connection_,
566 -1);
567 UTL_ExceptList *connect_single = 0;
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 (0 == 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 (),
594 comp_);
595 be_operation *op = 0;
596 ACE_NEW_RETURN (op,
597 be_operation (node->uses_type (),
598 AST_Operation::OP_noflags,
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 = 0;
607 ACE_NEW_RETURN (disconnect_single,
608 UTL_ExceptList (this->no_connection_,
610 -1);
611 op->be_add_exceptions (disconnect_single);
613 if (0 == 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 (),
633 comp_);
634 be_operation *op = 0;
635 ACE_NEW_RETURN (op,
636 be_operation (node->uses_type (),
637 AST_Operation::OP_noflags,
641 -1);
642 op->set_name (op_full_name);
643 op->set_defined_in (comp_);
644 op->set_imported (comp_->imported ());
646 if (0 == 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 (),
666 comp_);
668 be_operation *op = 0;
669 ACE_NEW_RETURN (op,
670 be_operation (this->cookie_,
671 AST_Operation::OP_noflags,
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,
682 be_argument *arg = 0;
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 = 0;
691 ACE_NEW_RETURN (tail,
692 UTL_ExceptList (this->invalid_connection_,
694 -1);
695 UTL_ExceptList *connect_multiple = 0;
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 (0 == 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 (),
722 comp_);
723 be_operation *op = 0;
724 ACE_NEW_RETURN (op,
725 be_operation (node->uses_type (),
726 AST_Operation::OP_noflags,
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,
737 be_argument *arg = 0;
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 = 0;
746 ACE_NEW_RETURN (disconnect_multiple,
747 UTL_ExceptList (this->invalid_connection_,
749 -1);
750 op->be_add_exceptions (disconnect_multiple);
752 if (0 == 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 (),
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,
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 = 0;
790 ACE_NEW_RETURN (op,
791 be_operation (td,
792 AST_Operation::OP_noflags,
796 -1);
797 op->set_name (op_full_name);
798 op->set_defined_in (comp_);
799 op->set_imported (comp_->imported ());
801 if (0 == 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 (),
819 consumer);
820 be_operation *push_op = 0;
821 ACE_NEW_RETURN (push_op,
822 be_operation (be_global->void_type (),
823 AST_Operation::OP_noflags,
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_",
833 false);
834 arg_string += node->local_name ();
835 Identifier arg_id (arg_string.fast_rep ());
836 UTL_ScopedName arg_name (&arg_id,
838 be_argument *arg = 0;
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 (0 == 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 (),
867 comp_);
868 be_operation *op = 0;
869 ACE_NEW_RETURN (op,
870 be_operation (this->cookie_,
871 AST_Operation::OP_noflags,
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 == 0)
884 op->destroy ();
885 delete op;
886 op = 0;
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,
898 be_argument *arg = 0;
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 = 0;
906 ACE_NEW_RETURN (subscribe,
907 UTL_ExceptList (this->exceeded_connection_limit_,
909 -1);
910 op->be_add_exceptions (subscribe);
912 if (0 == 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 == 0)
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 (),
943 comp_);
944 be_operation *op = 0;
945 ACE_NEW_RETURN (op,
946 be_operation (i,
947 AST_Operation::OP_noflags,
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,
958 be_argument *arg = 0;
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 = 0;
966 ACE_NEW_RETURN (unsubscribe,
967 UTL_ExceptList (this->invalid_connection_,
969 -1);
970 op->be_add_exceptions (unsubscribe);
972 if (0 == 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 (),
992 comp_);
993 be_operation *op = 0;
994 ACE_NEW_RETURN (op,
995 be_operation (be_global->void_type (),
996 AST_Operation::OP_noflags,
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 == 0)
1008 op->destroy ();
1009 delete op;
1010 op = 0;
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,
1022 be_argument *arg = 0;
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 = 0;
1030 ACE_NEW_RETURN (emits_connect,
1031 UTL_ExceptList (this->already_connected_,
1033 -1);
1034 op->be_add_exceptions (emits_connect);
1036 if (0 == 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 == 0)
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 (),
1067 comp_);
1068 be_operation *op = 0;
1069 ACE_NEW_RETURN (op,
1070 be_operation (i,
1071 AST_Operation::OP_noflags,
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 = 0;
1080 ACE_NEW_RETURN (emits_disconnect,
1081 UTL_ExceptList (this->no_connection_,
1083 -1);
1084 op->be_add_exceptions (emits_disconnect);
1086 if (0 == 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 == 0)
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 (),
1117 comp_);
1118 be_operation *op = 0;
1119 ACE_NEW_RETURN (op,
1120 be_operation (i,
1121 AST_Operation::OP_noflags,
1125 -1);
1126 op->set_name (op_name);
1127 op->set_defined_in (comp_);
1128 op->set_imported (comp_->imported ());
1130 if (0 == 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 (0,
1143 "create",
1145 implicit);
1146 be_operation *op = 0;
1147 ACE_NEW_RETURN (op,
1148 be_operation (node->managed_component (),
1149 AST_Operation::OP_noflags,
1153 -1);
1154 op->set_name (op_name);
1155 AST_Type *pk = node->primary_key ();
1156 UTL_ExceptList *exceps = 0;
1157 ACE_NEW_RETURN (exceps,
1158 UTL_ExceptList (this->create_failure_,
1160 -1);
1162 if (pk != 0 && !be_global->gen_lwccm ())
1164 Identifier arg_id ("key");
1165 UTL_ScopedName arg_name (&arg_id,
1167 AST_Argument *arg = 0;
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 = 0;
1177 ACE_NEW_RETURN (tail,
1178 UTL_ExceptList (this->invalid_key_,
1180 -1);
1181 UTL_ExceptList *middle = 0;
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 (0 == 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 (0,
1206 "find_by_primary_key",
1208 implicit);
1209 be_operation *op = 0;
1210 ACE_NEW_RETURN (op,
1211 be_operation (node->managed_component (),
1212 AST_Operation::OP_noflags,
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,
1222 AST_Argument *arg = 0;
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 = 0;
1232 UTL_ExceptList *middle = 0;
1234 if (!be_global->gen_lwccm ())
1236 ACE_NEW_RETURN (tail,
1237 UTL_ExceptList (this->invalid_key_,
1239 -1);
1240 ACE_NEW_RETURN (middle,
1241 UTL_ExceptList (this->unknown_key_value_,
1242 tail),
1243 -1);
1246 UTL_ExceptList *exceps = 0;
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 (0 == 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 (0,
1268 "remove",
1270 implicit);
1271 be_operation *op = 0;
1272 ACE_NEW_RETURN (op,
1273 be_operation (be_global->void_type (),
1274 AST_Operation::OP_noflags,
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,
1284 AST_Argument *arg = 0;
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 = 0;
1294 UTL_ExceptList *middle = 0;
1296 if (!be_global->gen_lwccm ())
1298 ACE_NEW_RETURN (tail,
1299 UTL_ExceptList (this->invalid_key_,
1301 -1);
1302 ACE_NEW_RETURN (middle,
1303 UTL_ExceptList (this->unknown_key_value_,
1304 tail),
1305 -1);
1308 UTL_ExceptList *exceps = 0;
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 (0 == 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 (0,
1330 "get_primary_key",
1332 implicit);
1333 be_operation *op = 0;
1334 ACE_NEW_RETURN (op,
1335 be_operation (node->primary_key (),
1336 AST_Operation::OP_noflags,
1340 -1);
1341 op->set_name (op_name);
1342 Identifier arg_id ("comp");
1343 UTL_ScopedName arg_name (&arg_id,
1345 AST_Argument *arg = 0;
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 (0 == 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_ == 0)
1384 Identifier local_id ("Cookie");
1385 UTL_ScopedName local_name (&local_id,
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 == 0)
1396 idl_global->err ()->lookup_error (&cookie_name);
1397 return -1;
1400 this->cookie_ = dynamic_cast<be_valuetype*> (d);
1402 if (this->cookie_ == 0)
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,
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 == 0)
1473 idl_global->err ()->lookup_error (&scoped_name);
1474 return -1;
1477 result = dynamic_cast<be_exception*> (d);
1479 if (result == 0)
1481 return -1;
1484 return 0;
1488 be_visitor_ccm_pre_proc::create_event_consumer (be_eventtype *node)
1491 UTL_Scope *s = node->defined_in ();
1493 UTL_ScopedName *consumer_name =
1494 this->create_scoped_name (0,
1495 node->local_name (),
1496 "Consumer",
1497 ScopeAsDecl (node->defined_in ()));
1499 /// We need to create event consumers even for forward
1500 /// declared eventtypes. Since forward declarations can
1501 /// appear any number of times, we need to check that this
1502 /// event consumer hasn't already been created.
1503 if (s->lookup_by_name (consumer_name, true) != 0)
1505 return 0;
1508 AST_Interface *event_consumer = 0;
1509 AST_Module *m = dynamic_cast<AST_Module*> (s);
1511 // We're at global scope here so we need to fool the scope stack
1512 // for a minute so the correct repo id can be calculated at
1513 // interface construction time.
1514 idl_global->scopes ().push (s);
1516 Identifier parent_id ("EventConsumerBase");
1517 UTL_ScopedName parent_local_name (&parent_id,
1519 UTL_ScopedName parent_full_name (&this->module_id_,
1520 &parent_local_name);
1521 UTL_NameList parent_list (&parent_full_name,
1523 FE_InterfaceHeader header (consumer_name,
1524 &parent_list,
1525 false,
1526 false,
1527 true);
1528 ACE_NEW_RETURN (event_consumer,
1529 be_interface (header.name (),
1530 header.inherits (),
1531 header.n_inherits (),
1532 header.inherits_flat (),
1533 header.n_inherits_flat (),
1534 false,
1535 false),
1536 -1);
1537 parent_id.destroy ();
1539 // Back to reality.
1540 idl_global->scopes ().pop ();
1542 event_consumer->set_defined_in (s);
1543 event_consumer->set_imported (node->imported ());
1544 event_consumer->set_name (consumer_name);
1545 be_interface *bec =
1546 dynamic_cast<be_interface*> (event_consumer);
1547 bec->original_interface (node);
1549 // Set repo id to 0, so it will be recomputed on the next access,
1550 // and set the prefix to the eventtype's prefix. All this is
1551 // necessary in case the eventtype's prefix was modified after
1552 // its declaration. We assume 'implied IDL' means that the
1553 // derived event consumer interface should have the same prefix.
1554 event_consumer->repoID (0);
1555 event_consumer->prefix (const_cast<char*> (node->prefix ()));
1557 dynamic_cast<be_type*> (event_consumer)->gen_fwd_helper_name ();
1558 m->be_add_interface (event_consumer);
1559 return this->gen_push_op (node,
1560 event_consumer);
1563 AST_Interface *
1564 be_visitor_ccm_pre_proc::lookup_consumer (be_field *node)
1566 AST_Type *impl = node->field_type ();
1567 ACE_CString rettype_string (impl->local_name ()->get_string ());
1568 rettype_string += "Consumer";
1569 Identifier rettype_id (rettype_string.fast_rep ());
1570 AST_Decl *d =
1571 impl->defined_in ()->lookup_by_name_local (&rettype_id, false);
1572 rettype_id.destroy ();
1574 if (d == 0)
1576 return 0;
1579 AST_Interface *i = dynamic_cast<AST_Interface*> (d);
1581 if (i == 0)
1583 idl_global->err ()->interface_expected (d);
1584 return 0;
1587 return i;
1590 AST_Interface *
1591 be_visitor_ccm_pre_proc::create_explicit (be_home *node)
1593 be_visitor_xplicit_pre_proc v (this->ctx_);
1595 if (v.visit_home (node) != 0)
1597 ACE_ERROR_RETURN ((LM_ERROR,
1598 ACE_TEXT ("be_visitor_ccm_pre_proc::")
1599 ACE_TEXT ("create_explicit - ")
1600 ACE_TEXT ("home xplicit visitor failed\n")),
1604 return v.xplicit ();
1607 AST_Interface *
1608 be_visitor_ccm_pre_proc::create_implicit (be_home *node)
1610 Identifier *parent_id = 0;
1611 ACE_NEW_RETURN (parent_id,
1612 Identifier ("KeylessCCMHome"),
1615 UTL_ScopedName *parent_local_name = 0;
1616 ACE_NEW_RETURN (parent_local_name,
1617 UTL_ScopedName (parent_id, 0),
1620 UTL_ScopedName *parent_full_name = 0;
1621 ACE_NEW_RETURN (parent_full_name,
1622 UTL_ScopedName (this->module_id_.copy (),
1623 parent_local_name),
1626 UTL_NameList parent_list (parent_full_name, 0);
1628 UTL_NameList *parent_list_ptr = 0;
1630 if (node->primary_key () == 0)
1632 parent_list_ptr = &parent_list;
1635 FE_InterfaceHeader header (0,
1636 parent_list_ptr,
1637 false,
1638 false,
1639 true);
1641 // We're at global scope here so we need to fool the scope stack
1642 // for a minute so the correct repo id can be calculated at
1643 // interface construction time.
1644 idl_global->scopes ().push (node->defined_in ());
1646 UTL_ScopedName *implicit_name =
1647 this->create_scoped_name (0,
1648 node->local_name (),
1649 "Implicit",
1650 ScopeAsDecl (node->defined_in ()));
1652 be_interface *i = 0;
1653 ACE_NEW_RETURN (i,
1654 be_interface (implicit_name,
1655 header.inherits (),
1656 header.n_inherits (),
1657 header.inherits_flat (),
1658 header.n_inherits_flat (),
1659 false,
1660 false),
1663 // Back to reality.
1664 idl_global->scopes ().pop ();
1666 header.destroy ();
1667 parent_list.destroy ();
1669 // So we can generate the proper typecode.
1670 i->home_equiv (true);
1672 i->set_name (implicit_name);
1673 i->set_defined_in (node->defined_in ());
1674 i->set_imported (node->imported ());
1676 i->gen_fwd_helper_name ();
1677 i->original_interface (node);
1678 AST_Module *m = dynamic_cast<AST_Module*> (node->defined_in ());
1679 m->be_add_interface (i);
1681 return i;
1684 AST_Interface *
1685 be_visitor_ccm_pre_proc::create_equivalent (be_home *node,
1686 AST_Interface *xplicit,
1687 AST_Interface *implicit)
1689 UTL_Scope *s = node->defined_in ();
1690 UTL_ScopedName *equiv_name =
1691 this->create_scoped_name (0,
1692 node->local_name (),
1694 ScopeAsDecl (s));
1695 UTL_NameList tail (implicit->name (),
1697 UTL_NameList parent_list (xplicit->name (),
1698 &tail);
1699 FE_InterfaceHeader header (0,
1700 &parent_list,
1701 false,
1702 false,
1703 true);
1705 // We're at global scope here so we need to fool the scope stack
1706 // for a minute so the correct repo id can be calculated at
1707 // interface construction time.
1708 idl_global->scopes ().push (node->defined_in ());
1710 be_interface *retval = 0;
1711 ACE_NEW_RETURN (retval,
1712 be_interface (equiv_name,
1713 header.inherits (),
1714 header.n_inherits (),
1715 header.inherits_flat (),
1716 header.n_inherits_flat (),
1717 false,
1718 false),
1721 // Back to reality.
1722 idl_global->scopes ().pop ();
1724 // So we can generate the proper typecode.
1725 retval->home_equiv (true);
1727 retval->set_name (equiv_name);
1728 retval->set_defined_in (s);
1729 retval->set_imported (node->imported ());
1730 retval->gen_fwd_helper_name ();
1731 retval->original_interface (node);
1733 UTL_ScopedName *unmangled_name =
1734 static_cast<UTL_ScopedName *> (node->name ()->copy ());
1735 UTL_ScopedName *mangled_name =
1736 this->create_scoped_name (0,
1737 node->local_name (),
1738 "_tao_home_name_extension",
1739 ScopeAsDecl (s));
1740 node->set_name (mangled_name);
1741 AST_Module *m = dynamic_cast<AST_Module*> (s);
1743 /// Calling be_add_interface() here calls add_to_referenced(),
1744 /// which will give a redef error.
1745 m->add_to_scope (retval);
1747 node->set_name (unmangled_name);
1748 return retval;
1751 UTL_ScopedName *
1752 be_visitor_ccm_pre_proc::create_scoped_name (const char *prefix,
1753 const char *local_name,
1754 const char *suffix,
1755 AST_Decl *parent)
1757 ACE_CString local_string (prefix,
1759 false);
1760 local_string += local_name;
1761 local_string += suffix;
1762 Identifier *local_id = 0;
1763 ACE_NEW_RETURN (local_id,
1764 Identifier (local_string.fast_rep ()),
1766 UTL_ScopedName *last_segment = 0;
1767 ACE_NEW_RETURN (last_segment,
1768 UTL_ScopedName (local_id,
1771 UTL_ScopedName *full_name =
1772 static_cast<UTL_ScopedName *> (parent->name ()->copy ());
1773 full_name->nconc (last_segment);
1774 return full_name;
1777 UTL_NameList *
1778 be_visitor_ccm_pre_proc::compute_inheritance (be_home *node)
1780 UTL_NameList *retval = 0;
1782 if (node->base_home () == 0)
1784 Identifier *local_id = 0;
1785 ACE_NEW_RETURN (local_id,
1786 Identifier ("CCMHome"),
1788 UTL_ScopedName *local_name = 0;
1789 ACE_NEW_RETURN (local_name,
1790 UTL_ScopedName (local_id,
1793 UTL_ScopedName *full_name = 0;
1794 ACE_NEW_RETURN (full_name,
1795 UTL_ScopedName (this->module_id_.copy (),
1796 local_name),
1798 ACE_NEW_RETURN (retval,
1799 UTL_NameList (full_name,
1804 else
1806 ACE_CString new_local (
1807 node->base_home ()->local_name ()->get_string ()
1809 new_local += "Explicit";
1810 UTL_ScopedName *parent_name =
1811 static_cast<UTL_ScopedName *> (node->base_home ()->name ()->copy ());
1812 parent_name->last_component ()->replace_string (new_local.c_str ());
1813 ACE_NEW_RETURN (retval,
1814 UTL_NameList (parent_name,
1819 long n_supports = node->n_inherits ();
1820 UTL_ScopedName *supported_name = 0;
1821 UTL_NameList *conc_value = 0;
1823 for (long i = 0; i < n_supports; ++i)
1825 supported_name =
1826 static_cast<UTL_ScopedName *> (node->inherits ()[i]->name ()->copy ());
1827 ACE_NEW_RETURN (conc_value,
1828 UTL_NameList (supported_name,
1831 retval->nconc (conc_value);
1834 return retval;
1838 be_visitor_ccm_pre_proc::generate_ami4ccm_uses ()
1840 /// The interfaces in the list below are from this IDL file,
1841 /// which then must be processed with the -GC option, so we
1842 /// know we'll get here - a good place to generate the *A.idl
1843 /// file containing the local interfaces and connector
1844 /// associated with each interface in the list.
1846 ACE_Unbounded_Queue<char *> &ccm_ami_receps =
1847 idl_global->ciao_ami_recep_names ();
1849 /// If the queue is empty, we're done.
1850 if (ccm_ami_receps.size () == 0)
1852 return 0;
1855 for (ACE_Unbounded_Queue<char *>::CONST_ITERATOR i (
1856 ccm_ami_receps);
1857 ! i.done ();
1858 i.advance ())
1860 char **item = 0;
1861 i.next (item);
1863 UTL_ScopedName *sn =
1864 FE_Utils::string_to_scoped_name (*item);
1866 UTL_Scope *s =
1867 idl_global->scopes ().top_non_null ();
1869 AST_Decl *d = s->lookup_by_name (sn, true);
1871 if (d == 0)
1873 idl_global->err ()->lookup_error (sn);
1875 sn->destroy ();
1876 delete sn;
1877 sn = 0;
1879 continue;
1882 sn->destroy ();
1883 delete sn;
1884 sn = 0;
1886 be_uses *u = dynamic_cast<be_uses*> (d);
1888 if (u == 0)
1890 ACE_ERROR_RETURN ((LM_ERROR,
1891 ACE_TEXT ("be_visitor_ccm_pre_proc")
1892 ACE_TEXT ("::generate_ami4ccm_uses - ")
1893 ACE_TEXT ("narrow to receptacle ")
1894 ACE_TEXT ("failed\n")),
1895 -1);
1898 be_interface *iface =
1899 dynamic_cast<be_interface*> (u->uses_type ());
1901 /// The real AMI_xxx exists only in the *A.idl file, so
1902 /// we create a dummy as the uses type for the implied
1903 /// receptacle created below, but only if it hasn't
1904 /// already been created for this uses type.
1906 be_interface *ami_iface =
1907 dynamic_cast<be_interface*> (iface->ami4ccm_uses ());
1909 if (ami_iface == 0)
1911 ACE_CString iname ("AMI4CCM_");
1913 iname += iface->local_name ();
1914 Identifier itmp_id (iname.c_str ());
1915 UTL_ScopedName itmp_sn (&itmp_id, 0);
1917 s = iface->defined_in ();
1918 idl_global->scopes ().push (s);
1919 ACE_NEW_RETURN (ami_iface,
1920 be_interface (&itmp_sn,
1925 true,
1926 false),
1927 -1);
1929 idl_global->scopes ().pop ();
1931 /// Make it imported so it doesn't trigger
1932 /// any unwanted code generation.
1933 ami_iface->set_imported (true);
1935 s->add_to_scope (ami_iface);
1936 iface->ami4ccm_uses (ami_iface);
1939 /// Now create the receptacle, passing in
1940 /// the local interface created above as the
1941 /// uses type. We don't generate anything
1942 /// in the main IDL file from the interface's
1943 /// contents, so it's ok that it's empty.
1945 ACE_CString uname ("sendc_");
1946 uname += u->local_name ()->get_string ();
1947 Identifier utmp_id (uname.c_str ());
1948 UTL_ScopedName utmp_sn (&utmp_id, 0);
1950 s = u->defined_in ();
1951 idl_global->scopes ().push (s);
1952 be_uses *ami_uses = 0;
1953 ACE_NEW_RETURN (ami_uses,
1954 be_uses (&utmp_sn,
1955 ami_iface,
1956 u->is_multiple ()),
1957 -1);
1959 s->add_to_scope (ami_uses);
1960 idl_global->scopes ().pop ();
1962 if (u->is_multiple ())
1965 AST_Type *t = u->uses_type ();
1966 ACE_CString fname (t->file_name ());
1967 char *dummy = 0;
1968 char *path = ACE_OS::realpath (fname.c_str (), dummy);
1969 ACE_DEBUG ((LM_DEBUG, "utype file: %s\n", path));
1971 // Grammar ensures this narrowing will never be 0.
1972 AST_Component *c =
1973 dynamic_cast<AST_Component*> (s);
1974 FE_Utils::create_uses_multiple_stuff (c, ami_uses);
1978 return 0;