ifr_adding_visitor.cpp

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 // ifr_adding_visitor.cpp,v 1.57 2006/06/16 20:32:33 parsons Exp
00003 
00004 #include "ast_argument.h"
00005 #include "ast_array.h"
00006 #include "ast_attribute.h"
00007 #include "ast_component.h"
00008 #include "ast_component_fwd.h"
00009 #include "ast_constant.h"
00010 #include "ast_enum.h"
00011 #include "ast_eventtype.h"
00012 #include "ast_eventtype_fwd.h"
00013 #include "ast_exception.h"
00014 #include "ast_expression.h"
00015 #include "ast_factory.h"
00016 #include "ast_field.h"
00017 #include "ast_home.h"
00018 #include "ast_interface.h"
00019 #include "ast_interface_fwd.h"
00020 #include "ast_module.h"
00021 #include "ast_native.h"
00022 #include "ast_operation.h"
00023 #include "ast_predefined_type.h"
00024 #include "ast_root.h"
00025 #include "ast_sequence.h"
00026 #include "ast_string.h"
00027 #include "ast_structure.h"
00028 #include "ast_union.h"
00029 #include "ast_valuebox.h"
00030 #include "ast_valuetype.h"
00031 #include "ast_valuetype_fwd.h"
00032 #include "utl_identifier.h"
00033 #include "utl_string.h"
00034 #include "utl_exceptlist.h"
00035 #include "nr_extern.h"
00036 
00037 #include "ifr_adding_visitor.h"
00038 #include "ifr_adding_visitor_operation.h"
00039 #include "ifr_adding_visitor_structure.h"
00040 #include "ifr_adding_visitor_exception.h"
00041 #include "ifr_adding_visitor_union.h"
00042 
00043 #include "tao/IFR_Client/IFR_ComponentsC.h"
00044 
00045 #include "ace/Vector_T.h"
00046 
00047 ACE_RCSID (IFR_Service,
00048            ifr_adding_visitor,
00049            "ifr_adding_visitor.cpp,v 1.57 2006/06/16 20:32:33 parsons Exp")
00050 
00051 ifr_adding_visitor::ifr_adding_visitor (AST_Decl *scope,
00052                                         CORBA::Boolean in_reopened)
00053   : scope_ (scope),
00054     in_reopened_ (in_reopened)
00055 {
00056 }
00057 
00058 ifr_adding_visitor::~ifr_adding_visitor (void)
00059 {
00060 }
00061 
00062 int
00063 ifr_adding_visitor::visit_scope (UTL_Scope *node)
00064 {
00065   // Proceed if the number of members in our scope is greater than 0.
00066   if (node->nmembers () > 0)
00067     {
00068       // Initialize an iterator to iterate over our scope.
00069       UTL_ScopeActiveIterator si (node,
00070                                   UTL_Scope::IK_decls);
00071 
00072       AST_Decl *d = 0;
00073 
00074       // Continue until each element is visited.
00075       while (!si.is_done ())
00076         {
00077           d = si.item ();
00078 
00079           if (d == 0)
00080             {
00081               ACE_ERROR_RETURN ((
00082                   LM_ERROR,
00083                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_scope -")
00084                   ACE_TEXT (" bad node in this scope\n")
00085                 ),
00086                 -1
00087               );
00088             }
00089 
00090           // These are created at startup in the repository, and
00091           // need not be dealt with here.
00092           if (d->node_type () == AST_Decl::NT_pre_defined)
00093             {
00094               si.next ();
00095               continue;
00096             }
00097 
00098           if (d->ast_accept (this) == -1)
00099             {
00100               ACE_ERROR_RETURN ((
00101                   LM_ERROR,
00102                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_scope -")
00103                   ACE_TEXT (" failed to accept visitor\n")
00104                 ),
00105                 -1
00106               );
00107             }
00108 
00109           si.next ();
00110         }
00111     }
00112 
00113   return 0;
00114 }
00115 
00116 int
00117 ifr_adding_visitor::visit_predefined_type (AST_PredefinedType *node)
00118 {
00119   ACE_TRY_NEW_ENV
00120     {
00121       this->ir_current_ =
00122       be_global->repository ()->get_primitive (
00123                                     this->predefined_type_to_pkind (node)
00124                                     ACE_ENV_ARG_PARAMETER
00125                                   );
00126       ACE_TRY_CHECK;
00127     }
00128   ACE_CATCHANY
00129     {
00130       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00131                            ACE_TEXT ("visit_predefined_type"));
00132 
00133       return -1;
00134     }
00135   ACE_ENDTRY;
00136 
00137   return 0;
00138 }
00139 
00140 int
00141 ifr_adding_visitor::visit_module (AST_Module *node)
00142 {
00143   if (node->imported () && !be_global->do_included_files ())
00144     {
00145       return 0;
00146     }
00147 
00148   CORBA::Container_var new_def;
00149 
00150   ACE_DECLARE_NEW_CORBA_ENV;
00151   ACE_TRY
00152     {
00153       // If this module been opened before, it will already be in
00154       // the repository.
00155       CORBA::Contained_var prev_def =
00156         be_global->repository ()->lookup_id (node->repoID ()
00157                                              ACE_ENV_ARG_PARAMETER);
00158       ACE_TRY_CHECK;
00159 
00160       if (CORBA::is_nil (prev_def.in ()))
00161         {
00162           // New module.
00163           CORBA::Container_ptr container =
00164             CORBA::Container::_nil ();
00165 
00166           if (be_global->ifr_scopes ().top (container) == 0)
00167             {
00168               new_def = container->create_module (
00169                                        node->repoID (),
00170                                        node->local_name ()->get_string (),
00171                                        node->version ()
00172                                        ACE_ENV_ARG_PARAMETER
00173                                      );
00174               ACE_TRY_CHECK;
00175             }
00176           else
00177             {
00178               ACE_ERROR_RETURN ((
00179                   LM_ERROR,
00180                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_module -")
00181                   ACE_TEXT (" scope stack is empty\n")
00182                 ),
00183                 -1
00184               );
00185             }
00186         }
00187       else
00188         {
00189           CORBA::DefinitionKind kind =
00190             prev_def->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER);
00191           ACE_TRY_CHECK;
00192 
00193           if (kind == CORBA::dk_Module)
00194             {
00195               // We are either in a reopened module, are processing an IDL
00196               // IDL file for the second time, or are in a module whose
00197               // name already exists by coincidence - there is no way to
00198               // tell the difference. So any members whose repository ID
00199               // already exists in this case will throw BAD_PARAM
00200               // when we attempt to add them to the repository.
00201               this->in_reopened_ = 1;
00202 
00203               new_def =
00204                 CORBA::ComponentIR::Container::_narrow (prev_def.in ()
00205                                                         ACE_ENV_ARG_PARAMETER);
00206               ACE_TRY_CHECK;
00207             }
00208         }
00209 
00210       if (be_global->ifr_scopes ().push (new_def.in ()) != 0)
00211         {
00212           ACE_ERROR_RETURN ((
00213               LM_ERROR,
00214               ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_module -")
00215               ACE_TEXT (" scope push failed\n")
00216             ),
00217             -1
00218           );
00219         }
00220 
00221       if (this->visit_scope (node) == -1)
00222         {
00223           ACE_ERROR_RETURN ((
00224               LM_ERROR,
00225               ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_module -")
00226               ACE_TEXT (" visit_scope failed\n")
00227             ),
00228             -1
00229           );
00230         }
00231 
00232       this->in_reopened_ = 0;
00233       CORBA::Container_ptr tmp =
00234         CORBA::Container::_nil ();
00235 
00236       if (be_global->ifr_scopes ().pop (tmp) != 0)
00237         {
00238           ACE_ERROR_RETURN ((
00239               LM_ERROR,
00240               ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_module -")
00241               ACE_TEXT (" scope pop failed\n")
00242             ),
00243             -1
00244           );
00245         }
00246     }
00247   ACE_CATCHANY
00248     {
00249       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00250                            ACE_TEXT ("visit_module"));
00251 
00252       return -1;
00253     }
00254   ACE_ENDTRY;
00255 
00256   return 0;
00257 }
00258 
00259 int
00260 ifr_adding_visitor::visit_interface (AST_Interface *node)
00261 {
00262   if (node->imported () && !be_global->do_included_files ())
00263     {
00264       return 0;
00265     }
00266 
00267   ACE_DECLARE_NEW_CORBA_ENV;
00268   ACE_TRY
00269     {
00270       // Is this interface already in the respository?
00271       CORBA::Contained_var prev_def =
00272         be_global->repository ()->lookup_id (node->repoID ()
00273                                              ACE_ENV_ARG_PARAMETER);
00274       ACE_TRY_CHECK;
00275 
00276       // If not, create a new entry.
00277       if (CORBA::is_nil (prev_def.in ()))
00278         {
00279           int status = this->create_interface_def (node
00280                                                    ACE_ENV_ARG_PARAMETER);
00281           ACE_TRY_CHECK;
00282 
00283           return status;
00284         }
00285       else
00286         {
00287           // There is already an entry in the repository. If the interface is
00288           // defined and has not already been populated, we do so
00289           // now. If it is not yet defined or the full definition has already
00290           // been added to the repository, we just update the current IR object
00291           // holder.
00292           if (node->is_defined ()
00293               && node->ifr_added () == 0
00294               && this->in_reopened_ == 0)
00295             {
00296               // If we are here and the line below is true, then either
00297               // 1. We are defining an undefined forward declared interface
00298               //    from a previously processed IDL file, or
00299               // 2. We are clobbering a previous definition, either of an
00300               //    interface or of some other type.
00301               // 3. We are inside a module that has a previous entry.
00302               // If prev_def would narrow successfully to an InterfaceDef, we
00303               // have NO WAY of knowing if we are defining or clobbering. So
00304               // we destroy the contents of the previous entry (we don't want
00305               // to destroy the entry itself, since it may have already been
00306               // made a member of some other entry, and destroying it would
00307               // make the containing entry's section key invalid) and repopulate.
00308               // On the other hand, if prev_def is NOT an interface, we can
00309               // safely destroy it, since we know we are not redefining a
00310               // previous entry, forward declared or not.
00311               // If we are inside a module that was seen before, we could be
00312               // just processing an IDL file a second time, in which case we
00313               // again just update ir_current_.
00314               if (node->ifr_fwd_added () == 0)
00315                 {
00316                   CORBA::DefinitionKind kind =
00317                     prev_def->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER);
00318                   ACE_TRY_CHECK;
00319 
00320                   if (kind == CORBA::dk_Interface)
00321                     {
00322                       CORBA::InterfaceDef_var iface =
00323                         CORBA::InterfaceDef::_narrow (prev_def.in ()
00324                                                       ACE_ENV_ARG_PARAMETER);
00325                       ACE_TRY_CHECK;
00326 
00327                       CORBA::ContainedSeq_var contents =
00328                         iface->contents (CORBA::dk_all,
00329                                          1
00330                                          ACE_ENV_ARG_PARAMETER);
00331                       ACE_TRY_CHECK;
00332 
00333                       CORBA::ULong length = contents->length ();
00334 
00335                       for (CORBA::ULong i = 0; i < length; ++i)
00336                         {
00337                           contents[i]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
00338                           ACE_TRY_CHECK;
00339                         }
00340                     }
00341                   else
00342                     {
00343                       prev_def->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
00344                       ACE_TRY_CHECK;
00345 
00346                       int status = this->create_interface_def (node
00347                                                                ACE_ENV_ARG_PARAMETER);
00348                       ACE_TRY_CHECK;
00349 
00350                       return status;
00351                     }
00352                 }
00353 
00354               CORBA::ULong n_parents = static_cast<CORBA::ULong> (node->n_inherits ());
00355 
00356               CORBA::InterfaceDefSeq bases (n_parents);
00357               bases.length (n_parents);
00358               CORBA::Contained_var result;
00359 
00360               AST_Interface **parents = node->inherits ();
00361 
00362               // Construct a list of the parents.
00363               for (CORBA::ULong i = 0; i < n_parents; ++i)
00364                 {
00365                   result =
00366                     be_global->repository ()->lookup_id (parents[i]->repoID ()
00367                                                          ACE_ENV_ARG_PARAMETER);
00368                   ACE_TRY_CHECK;
00369 
00370                   // If one of our interface's parents is not in the repository,
00371                   // that means that it has not yet been seen (even as a
00372                   // forward declaration) in the IDL file, and we will have to
00373                   // postpone the populating of our interface until they are all
00374                   // added.
00375                   if (CORBA::is_nil (result.in ()))
00376                     {
00377                       this->ir_current_ =
00378                         CORBA::IDLType::_narrow (prev_def.in ()
00379                                                 ACE_ENV_ARG_PARAMETER);
00380                       ACE_TRY_CHECK
00381 
00382                       return 0;
00383                     }
00384 
00385                   bases[i] =
00386                     CORBA::InterfaceDef::_narrow (result.in ()
00387                                                   ACE_ENV_ARG_PARAMETER);
00388                   ACE_TRY_CHECK;
00389 
00390                   if (CORBA::is_nil (bases[i]))
00391                     {
00392                       ACE_ERROR_RETURN ((
00393                           LM_ERROR,
00394                           ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00395                           ACE_TEXT ("visit_interface -")
00396                           ACE_TEXT (" CORBA::InterfaceDef::_narrow failed\n")
00397                         ),
00398                         -1
00399                       );
00400                     }
00401                 }
00402 
00403               CORBA::InterfaceDef_var extant_def =
00404                 CORBA::InterfaceDef::_narrow (prev_def. in ()
00405                                               ACE_ENV_ARG_PARAMETER);
00406               ACE_TRY_CHECK;
00407 
00408               extant_def->base_interfaces (bases
00409                                            ACE_ENV_ARG_PARAMETER);
00410               ACE_TRY_CHECK
00411 
00412               node->ifr_added (1);
00413 
00414               // Push the new IR object onto the scope stack.
00415               if (be_global->ifr_scopes ().push (extant_def.in ()) != 0)
00416                 {
00417                   ACE_ERROR_RETURN ((
00418                       LM_ERROR,
00419                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00420                       ACE_TEXT ("visit_interface -")
00421                       ACE_TEXT (" scope push failed\n")
00422                     ),
00423                     -1
00424                   );
00425                 }
00426 
00427               // Visit the members, if any.
00428               if (this->visit_scope (node) == -1)
00429                 {
00430                   ACE_ERROR_RETURN ((
00431                       LM_ERROR,
00432                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00433                       ACE_TEXT ("visit_interface -")
00434                       ACE_TEXT (" visit_scope failed\n")
00435                     ),
00436                     -1
00437                   );
00438                 }
00439 
00440               // This spot in the AST doesn't necessarily have to be the
00441               // interface definition - it could be any reference to it.
00442               // The front end will already have fully defined it, so all
00443               // the info is available anywhere. So it's a good idea to
00444               // update the current IR object holder now.
00445               this->ir_current_ =
00446                 CORBA::IDLType::_duplicate (extant_def.in ());
00447 
00448               CORBA::Container_ptr used_scope =
00449                 CORBA::Container::_nil ();
00450 
00451               // Pop the new IR object back off the scope stack.
00452               if (be_global->ifr_scopes ().pop (used_scope) != 0)
00453                 {
00454                   ACE_ERROR_RETURN ((
00455                       LM_ERROR,
00456                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00457                       ACE_TEXT ("visit_interface -")
00458                       ACE_TEXT (" scope pop failed\n")
00459                     ),
00460                     -1
00461                   );
00462                 }
00463             }
00464           else
00465             {
00466               // @@ (JP) I think we're ok here without a check:
00467               // not defined/not added - visit_interface_fwd will have
00468               //                         detected a clobber.
00469               // not defined/added - not possible.
00470               // defined/not added - takes the other branch.
00471               // defined/added - we're ok.
00472               this->ir_current_ =
00473                 CORBA::IDLType::_narrow (prev_def.in ()
00474                                          ACE_ENV_ARG_PARAMETER);
00475               ACE_TRY_CHECK;
00476             }
00477         }
00478     }
00479   ACE_CATCHANY
00480     {
00481       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00482                            ACE_TEXT ("visit_interface"));
00483 
00484       return -1;
00485     }
00486   ACE_ENDTRY;
00487 
00488   return 0;
00489 }
00490 
00491 int
00492 ifr_adding_visitor::visit_interface_fwd (AST_InterfaceFwd *node)
00493 {
00494   if (node->imported () && !be_global->do_included_files ())
00495     {
00496       return 0;
00497     }
00498 
00499   AST_Interface *i = node->full_definition ();
00500 
00501   ACE_DECLARE_NEW_CORBA_ENV;
00502   ACE_TRY
00503     {
00504       // Is this interface already in the respository?
00505       CORBA::Contained_var prev_def =
00506         be_global->repository ()->lookup_id (i->repoID ()
00507                                              ACE_ENV_ARG_PARAMETER);
00508       ACE_TRY_CHECK;
00509 
00510       if (CORBA::is_nil (prev_def.in ()))
00511         {
00512           // If our full definition is found in this IDL file, we go
00513           // ahead and create the full entry now.
00514           // The forward declared interface is not defined anywhere
00515           // in this IDL file, so we just create an empty entry to
00516           // be replaced by a full definition in some other IDL file.
00517           CORBA::InterfaceDefSeq bases (0);
00518           bases.length (0);
00519 
00520           CORBA::Container_ptr current_scope =
00521             CORBA::Container::_nil ();
00522 
00523           if (be_global->ifr_scopes ().top (current_scope) == 0)
00524             {
00525               if (i->is_local ())
00526                 {
00527                   this->ir_current_ =
00528                     current_scope->create_local_interface (
00529                                        i->repoID (),
00530                                        i->local_name ()->get_string (),
00531                                        i->version (),
00532                                        bases
00533                                        ACE_ENV_ARG_PARAMETER
00534                                      );
00535                 }
00536               else
00537                 {
00538                   this->ir_current_ =
00539                     current_scope->create_interface (
00540                                        i->repoID (),
00541                                        i->local_name ()->get_string (),
00542                                        i->version (),
00543                                        bases
00544                                        ACE_ENV_ARG_PARAMETER
00545                                      );
00546                 }
00547 
00548               ACE_TRY_CHECK;
00549             }
00550           else
00551             {
00552               ACE_ERROR_RETURN ((
00553                   LM_ERROR,
00554                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00555                   ACE_TEXT ("visit_interface_fwd -")
00556                   ACE_TEXT (" scope stack is empty\n")
00557                 ),
00558                 -1
00559               );
00560             }
00561 
00562           node->ifr_added (1);
00563           i->ifr_fwd_added (1);
00564         }
00565 
00566    }
00567   ACE_CATCHANY
00568     {
00569       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00570                            ACE_TEXT ("visit_interface_fwd"));
00571 
00572       return -1;
00573     }
00574   ACE_ENDTRY;
00575 
00576   return 0;
00577 }
00578 
00579 int
00580 ifr_adding_visitor::visit_valuebox (AST_ValueBox *node)
00581 {
00582   if (node->imported () && !be_global->do_included_files ())
00583     {
00584       return 0;
00585     }
00586 
00587   ACE_DECLARE_NEW_CORBA_ENV;
00588   ACE_TRY
00589     {
00590       this->element_type (node->boxed_type ()
00591                           ACE_ENV_ARG_PARAMETER);
00592       ACE_TRY_CHECK;
00593 
00594       CORBA::Container_ptr current_scope =
00595         CORBA::Container::_nil ();
00596 
00597       if (be_global->ifr_scopes ().top (current_scope) == 0)
00598         {
00599           this->ir_current_ =
00600             current_scope->create_value_box (
00601                 node->repoID (),
00602                 node->local_name ()->get_string (),
00603                 node->version (),
00604                 this->ir_current_.in ()
00605                 ACE_ENV_ARG_PARAMETER
00606               );
00607           ACE_TRY_CHECK;
00608         }
00609       else
00610         {
00611           ACE_ERROR_RETURN ((
00612               LM_ERROR,
00613               ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_valuebox -")
00614               ACE_TEXT (" scope stack is empty\n")
00615             ),
00616             -1
00617           );
00618         }
00619 
00620       node->ifr_added (1);
00621     }
00622   ACE_CATCHANY
00623     {
00624       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00625                            ACE_TEXT ("visit_valuebox"));
00626 
00627       return -1;
00628     }
00629   ACE_ENDTRY;
00630 
00631   return 0;
00632 }
00633 
00634 int
00635 ifr_adding_visitor::visit_valuetype (AST_ValueType *node)
00636 {
00637   if (node->imported () && !be_global->do_included_files ())
00638     {
00639       return 0;
00640     }
00641 
00642   ACE_DECLARE_NEW_CORBA_ENV;
00643   ACE_TRY
00644     {
00645       // Is this interface already in the respository?
00646       CORBA::Contained_var prev_def =
00647         be_global->repository ()->lookup_id (node->repoID ()
00648                                              ACE_ENV_ARG_PARAMETER);
00649       ACE_TRY_CHECK;
00650 
00651       // If not, create a new entry.
00652       if (CORBA::is_nil (prev_def.in ()))
00653         {
00654           int status = this->create_value_def (node
00655                                                ACE_ENV_ARG_PARAMETER);
00656           ACE_TRY_CHECK;
00657 
00658           return status;
00659         }
00660       else
00661         {
00662           // There is already an entry in the repository. If the interface is
00663           // defined and has not already been populated, we do so
00664           // now. If it is not yet defined or the full definition has already
00665           // been added to the repository, we just update the current IR object
00666           // holder.
00667           if (node->is_defined ()
00668               && node->ifr_added () == 0
00669               && this->in_reopened_ == 0)
00670             {
00671               // If we are here and the line below is true, then either
00672               // 1. We are defining an undefined forward declared interface
00673               //    from a previously processed IDL file, or
00674               // 2. We are clobbering a previous definition, either of an
00675               //    interface or of some other type.
00676               // 3. We are inside a module that has a previous entry.
00677               // If prev_def would narrow successfully to an InterfaceDef, we
00678               // have NO WAY of knowing if we are defining or clobbering. So
00679               // we destroy the contents of the previous entry (we don't want
00680               // to destroy the entry itself, since it may have already been
00681               // made a member of some other entry, and destroying it would
00682               // make the containing entry's key invalid) and repopulate.
00683               // On the other hand, if prev_def is NOT an interface, we can
00684               // safely destroy it, since we know we are not redefining a
00685               // previous entry, forward declared or not.
00686               // If we are inside a module that was seen before, we could be
00687               // just processing an IDL file a second time, in which case we
00688               // again just update ir_current_.
00689               if (node->ifr_fwd_added () == 0)
00690                 {
00691                   CORBA::DefinitionKind kind =
00692                     prev_def->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER);
00693                   ACE_TRY_CHECK;
00694 
00695                   if (kind == CORBA::dk_Value)
00696                     {
00697                       CORBA::ValueDef_var value =
00698                         CORBA::ValueDef::_narrow (prev_def.in ()
00699                                                   ACE_ENV_ARG_PARAMETER);
00700                       ACE_TRY_CHECK;
00701 
00702                       CORBA::ContainedSeq_var contents =
00703                         value->contents (CORBA::dk_all,
00704                                          1
00705                                          ACE_ENV_ARG_PARAMETER);
00706                       ACE_TRY_CHECK;
00707 
00708                       CORBA::ULong length = contents->length ();
00709 
00710                       for (CORBA::ULong i = 0; i < length; ++i)
00711                         {
00712                           contents[i]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
00713                           ACE_TRY_CHECK;
00714                         }
00715                     }
00716                   else
00717                     {
00718                       prev_def->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
00719                       ACE_TRY_CHECK;
00720 
00721                       int status =
00722                         this->create_value_def (node
00723                                                 ACE_ENV_ARG_PARAMETER);
00724                       ACE_TRY_CHECK;
00725 
00726                       return status;
00727                     }
00728                 }
00729 
00730               // Our previous definition is a valuetype, so narrow it here,
00731               // then populate it.
00732               CORBA::ExtValueDef_var extant_def =
00733                 CORBA::ExtValueDef::_narrow (prev_def. in ()
00734                                              ACE_ENV_ARG_PARAMETER);
00735               ACE_TRY_CHECK;
00736 
00737               // Concrete base value.
00738 
00739               CORBA::ValueDef_var base_vt;
00740               this->fill_base_value (base_vt.out (),
00741                                      node
00742                                      ACE_ENV_ARG_PARAMETER);
00743               ACE_TRY_CHECK;
00744 
00745               extant_def->base_value (base_vt.in ()
00746                                       ACE_ENV_ARG_PARAMETER);
00747               ACE_TRY_CHECK;
00748 
00749               // Abstract base values.
00750 
00751               CORBA::ValueDefSeq abstract_base_values;
00752               this->fill_abstract_base_values (abstract_base_values,
00753                                                node
00754                                                ACE_ENV_ARG_PARAMETER);
00755               ACE_TRY_CHECK;
00756 
00757               extant_def->abstract_base_values (abstract_base_values
00758                                                 ACE_ENV_ARG_PARAMETER);
00759               ACE_TRY_CHECK;
00760 
00761               // Supported interfaces.
00762 
00763               CORBA::InterfaceDefSeq supported;
00764               this->fill_supported_interfaces (supported,
00765                                                node
00766                                                ACE_ENV_ARG_PARAMETER);
00767               ACE_TRY_CHECK;
00768 
00769               extant_def->supported_interfaces (supported
00770                                                 ACE_ENV_ARG_PARAMETER);
00771               ACE_TRY_CHECK;
00772 
00773               // Intializers.
00774 
00775               CORBA::ExtInitializerSeq initializers;
00776               this->fill_initializers (initializers,
00777                                        node
00778                                        ACE_ENV_ARG_PARAMETER);
00779               ACE_TRY_CHECK;
00780 
00781               extant_def->ext_initializers (initializers
00782                                             ACE_ENV_ARG_PARAMETER);
00783               ACE_TRY_CHECK;
00784 
00785               // Truncatable, abstract, custom.
00786 
00787               extant_def->is_abstract (static_cast<CORBA::Boolean> (node->is_abstract ())
00788                                        ACE_ENV_ARG_PARAMETER);
00789               ACE_TRY_CHECK;
00790 
00791               extant_def->is_truncatable (static_cast<CORBA::Boolean> (node->truncatable ())
00792                                           ACE_ENV_ARG_PARAMETER);
00793               ACE_TRY_CHECK;
00794 
00795               extant_def->is_custom (static_cast<CORBA::Boolean> (node->custom ())
00796                                      ACE_ENV_ARG_PARAMETER);
00797               ACE_TRY_CHECK;
00798 
00799               node->ifr_added (1);
00800 
00801               // Push the new IR object onto the scope stack before visiting
00802               // the new object's scope.
00803               if (be_global->ifr_scopes ().push (extant_def.in ()) != 0)
00804                 {
00805                   ACE_ERROR_RETURN ((
00806                       LM_ERROR,
00807                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00808                       ACE_TEXT ("visit_valuetype -")
00809                       ACE_TEXT (" scope push failed\n")
00810                     ),
00811                     -1
00812                   );
00813                 }
00814 
00815               // Visit the members, if any.
00816               if (this->visit_scope (node) == -1)
00817                 {
00818                   ACE_ERROR_RETURN ((
00819                       LM_ERROR,
00820                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00821                       ACE_TEXT ("visit_valuetype -")
00822                       ACE_TEXT (" visit_scope failed\n")
00823                     ),
00824                     -1
00825                   );
00826                 }
00827 
00828               // This spot in the AST doesn't necessarily have to be the
00829               // interface definition - it could be any reference to it.
00830               // The front end will already have fully defined it, so all
00831               // the info is available anywhere. So it's a good idea to
00832               // update the current IR object holder now.
00833               this->ir_current_ =
00834                 CORBA::IDLType::_duplicate (extant_def.in ());
00835 
00836               CORBA::Container_ptr used_scope =
00837                 CORBA::Container::_nil ();
00838 
00839               // Pop the new IR object back off the scope stack.
00840               if (be_global->ifr_scopes ().pop (used_scope) != 0)
00841                 {
00842                   ACE_ERROR_RETURN ((
00843                       LM_ERROR,
00844                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00845                       ACE_TEXT ("visit_valuetype -")
00846                       ACE_TEXT (" scope pop failed\n")
00847                     ),
00848                     -1
00849                   );
00850                 }
00851             }
00852           else
00853             {
00854               // @@ (JP) I think we're ok here without a check:
00855               // not defined/not added - visit_valuetype_fwd will have
00856               //                         detected a clobber.
00857               // not defined/added - not possible.
00858               // defined/not added - takes the other branch.
00859               // defined/added - we're ok.
00860               this->ir_current_ =
00861                 CORBA::IDLType::_narrow (prev_def.in ()
00862                                          ACE_ENV_ARG_PARAMETER);
00863               ACE_TRY_CHECK;
00864             }
00865         }
00866     }
00867   ACE_CATCHANY
00868     {
00869       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00870                            ACE_TEXT ("visit_valuetype"));
00871 
00872       return -1;
00873     }
00874   ACE_ENDTRY;
00875 
00876   return 0;
00877 }
00878 
00879 int
00880 ifr_adding_visitor::visit_valuetype_fwd (AST_ValueTypeFwd *node)
00881 {
00882   if (node->imported () && !be_global->do_included_files ())
00883     {
00884       return 0;
00885     }
00886 
00887   AST_Interface *v = node->full_definition ();
00888 
00889   ACE_DECLARE_NEW_CORBA_ENV;
00890   ACE_TRY
00891     {
00892       // Is this interface already in the respository?
00893       CORBA::Contained_var prev_def =
00894         be_global->repository ()->lookup_id (v->repoID ()
00895                                              ACE_ENV_ARG_PARAMETER);
00896       ACE_TRY_CHECK;
00897 
00898       if (CORBA::is_nil (prev_def.in ()))
00899         {
00900           // If our full definition is found in this IDL file, we go
00901           // ahead and create the full entry now.
00902           // The forward declared valuetype is not defined anywhere
00903           // in this IDL file, so we just create an empty entry to
00904           // be replaced by a full definition in some other IDL file.
00905           CORBA::ValueDefSeq abstract_bases (0);
00906           abstract_bases.length (0);
00907           CORBA::InterfaceDefSeq supported (0);
00908           supported.length (0);
00909           CORBA::InitializerSeq initializers (0);
00910           initializers.length (0);
00911 
00912           CORBA::Container_ptr current_scope =
00913             CORBA::Container::_nil ();
00914 
00915           CORBA::Boolean abstract =
00916             static_cast<CORBA::Boolean> (v->is_abstract ());
00917 
00918           if (be_global->ifr_scopes ().top (current_scope) == 0)
00919             {
00920               this->ir_current_ =
00921                 current_scope->create_value (
00922                                    v->repoID (),
00923                                    v->local_name ()->get_string (),
00924                                    v->version (),
00925                                    0, // 'custom' not handled yet
00926                                    abstract,
00927                                    CORBA::ValueDef::_nil (),
00928                                    0, // 'truncatable' not handled yet
00929                                    abstract_bases,
00930                                    supported,
00931                                    initializers
00932                                    ACE_ENV_ARG_PARAMETER
00933                                  );
00934               ACE_TRY_CHECK;
00935             }
00936           else
00937             {
00938               ACE_ERROR_RETURN ((
00939                   LM_ERROR,
00940                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00941                   ACE_TEXT ("visit_valuetype_fwd -")
00942                   ACE_TEXT (" scope stack is empty\n")
00943                 ),
00944                 -1
00945               );
00946             }
00947 
00948           node->ifr_added (1);
00949           v->ifr_fwd_added (1);
00950         }
00951    }
00952   ACE_CATCHANY
00953     {
00954       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00955                            ACE_TEXT ("visit_valuetype_fwd"));
00956 
00957       return -1;
00958     }
00959   ACE_ENDTRY;
00960 
00961   return 0;
00962 }
00963 
00964 int
00965 ifr_adding_visitor::visit_component (AST_Component *node)
00966 {
00967   if (node->imported () && !be_global->do_included_files ())
00968     {
00969       return 0;
00970     }
00971 
00972   ACE_DECLARE_NEW_CORBA_ENV;
00973   ACE_TRY
00974     {
00975       // Is this interface already in the respository?
00976       CORBA::Contained_var prev_def =
00977         be_global->repository ()->lookup_id (node->repoID ()
00978                                              ACE_ENV_ARG_PARAMETER);
00979       ACE_TRY_CHECK;
00980 
00981       // If not, create a new entry.
00982       if (CORBA::is_nil (prev_def.in ()))
00983         {
00984           int status = this->create_component_def (node
00985                                                    ACE_ENV_ARG_PARAMETER);
00986           ACE_TRY_CHECK;
00987 
00988           return status;
00989         }
00990       else
00991         {
00992           // There is already an entry in the repository. If the interface is
00993           // defined and has not already been populated, we do so
00994           // now. If it is not yet defined or the full definition has already
00995           // been added to the repository, we just update the current IR object
00996           // holder.
00997           if (node->is_defined ()
00998               && node->ifr_added () == 0
00999               && this->in_reopened_ == 0)
01000             {
01001               // If we are here and the line below is true, then either
01002               // 1. We are defining an undefined forward declared interface
01003               //    from a previously processed IDL file, or
01004               // 2. We are clobbering a previous definition, either of an
01005               //    interface or of some other type.
01006               // 3. We are inside a module that has a previous entry.
01007               // If prev_def would narrow successfully to an InterfaceDef, we
01008               // have NO WAY of knowing if we are defining or clobbering. So
01009               // we destroy the contents of the previous entry (we don't want
01010               // to destroy the entry itself, since it may have already been
01011               // made a member of some other entry, and destroying it would
01012               // make the containing entry's key invalid) and repopulate.
01013               // On the other hand, if prev_def is NOT an interface, we can
01014               // safely destroy it, since we know we are not redefining a
01015               // previous entry, forward declared or not.
01016               // If we are inside a module that was seen before, we could be
01017               // just processing an IDL file a second time, in which case we
01018               // again just update ir_current_.
01019               if (node->ifr_fwd_added () == 0)
01020                 {
01021                   CORBA::DefinitionKind kind =
01022                     prev_def->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER);
01023                   ACE_TRY_CHECK;
01024 
01025                   if (kind == CORBA::dk_Component)
01026                     {
01027                       CORBA::ComponentIR::ComponentDef_var value =
01028                         CORBA::ComponentIR::ComponentDef::_narrow (
01029                             prev_def.in ()
01030                             ACE_ENV_ARG_PARAMETER
01031                           );
01032                       ACE_TRY_CHECK;
01033 
01034                       CORBA::ContainedSeq_var contents =
01035                         value->contents (CORBA::dk_all,
01036                                          1
01037                                          ACE_ENV_ARG_PARAMETER);
01038                       ACE_TRY_CHECK;
01039 
01040                       CORBA::ULong length = contents->length ();
01041 
01042                       for (CORBA::ULong i = 0; i < length; ++i)
01043                         {
01044                           contents[i]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
01045                           ACE_TRY_CHECK;
01046                         }
01047                     }
01048                   else
01049                     {
01050                       prev_def->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
01051                       ACE_TRY_CHECK;
01052 
01053                       int status =
01054                         this->create_component_def (node
01055                                                     ACE_ENV_ARG_PARAMETER);
01056                       ACE_TRY_CHECK;
01057 
01058                       return status;
01059                     }
01060                 }
01061 
01062               // Re-populate the repository entry.
01063 
01064               CORBA::ComponentIR::ComponentDef_var extant_def =
01065                 CORBA::ComponentIR::ComponentDef::_narrow (
01066                                                       prev_def.in ()
01067                                                       ACE_ENV_ARG_PARAMETER
01068                                                     );
01069               ACE_TRY_CHECK;
01070 
01071               CORBA::InterfaceDefSeq supported_interfaces;
01072               this->fill_supported_interfaces (supported_interfaces,
01073                                                node
01074                                                ACE_ENV_ARG_PARAMETER);
01075               ACE_TRY_CHECK;
01076 
01077               extant_def->supported_interfaces (supported_interfaces
01078                                                 ACE_ENV_ARG_PARAMETER);
01079               ACE_TRY_CHECK;
01080 
01081               CORBA::ComponentIR::ComponentDef_var base_component;
01082               this->fill_base_component (base_component.out (),
01083                                          node
01084                                          ACE_ENV_ARG_PARAMETER);
01085               ACE_TRY_CHECK;
01086 
01087               extant_def->base_component (base_component.in ()
01088                                           ACE_ENV_ARG_PARAMETER);
01089               ACE_TRY_CHECK;
01090 
01091               this->visit_all_provides (node,
01092                                         extant_def.in ()
01093                                         ACE_ENV_ARG_PARAMETER);
01094               ACE_TRY_CHECK;
01095 
01096               this->visit_all_uses (node,
01097                                     extant_def.in ()
01098                                     ACE_ENV_ARG_PARAMETER);
01099               ACE_TRY_CHECK;
01100 
01101               this->visit_all_emits (node,
01102                                      extant_def.in ()
01103                                      ACE_ENV_ARG_PARAMETER);
01104               ACE_TRY_CHECK;
01105 
01106               this->visit_all_publishes (node,
01107                                          extant_def.in ()
01108                                          ACE_ENV_ARG_PARAMETER);
01109               ACE_TRY_CHECK;
01110 
01111               this->visit_all_consumes (node,
01112                                         extant_def.in ()
01113                                         ACE_ENV_ARG_PARAMETER);
01114               ACE_TRY_CHECK;
01115 
01116               node->ifr_added (1);
01117 
01118               // Push the new IR object onto the scope stack before visiting
01119               // the new object's scope.
01120               if (be_global->ifr_scopes ().push (extant_def.in ()) != 0)
01121                 {
01122                   ACE_ERROR_RETURN ((
01123                       LM_ERROR,
01124                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01125                       ACE_TEXT ("visit_component -")
01126                       ACE_TEXT (" scope push failed\n")
01127                     ),
01128                     -1
01129                   );
01130                 }
01131 
01132               // Visit the members, if any.
01133               if (this->visit_scope (node) == -1)
01134                 {
01135                   ACE_ERROR_RETURN ((
01136                       LM_ERROR,
01137                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01138                       ACE_TEXT ("visit_component -")
01139                       ACE_TEXT (" visit_scope failed\n")
01140                     ),
01141                     -1
01142                   );
01143                 }
01144 
01145               // This spot in the AST doesn't necessarily have to be the
01146               // interface definition - it could be any reference to it.
01147               // The front end will already have fully defined it, so all
01148               // the info is available anywhere. So it's a good idea to
01149               // update the current IR object holder now.
01150               this->ir_current_ =
01151                 CORBA::IDLType::_duplicate (extant_def.in ());
01152 
01153               CORBA::Container_ptr used_scope =
01154                 CORBA::Container::_nil ();
01155 
01156               // Pop the new IR object back off the scope stack.
01157               if (be_global->ifr_scopes ().pop (used_scope) != 0)
01158                 {
01159                   ACE_ERROR_RETURN ((
01160                       LM_ERROR,
01161                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01162                       ACE_TEXT ("visit_interface -")
01163                       ACE_TEXT (" scope pop failed\n")
01164                     ),
01165                     -1
01166                   );
01167                 }
01168              }
01169           else
01170             {
01171               // @@ (JP) I think we're ok here without a check:
01172               // not defined/not added - visit_interface_fwd will have
01173               //                         detected a clobber.
01174               // not defined/added - not possible.
01175               // defined/not added - takes the other branch.
01176               // defined/added - we're ok.
01177               this->ir_current_ =
01178                 CORBA::IDLType::_narrow (prev_def.in ()
01179                                          ACE_ENV_ARG_PARAMETER);
01180               ACE_TRY_CHECK;
01181             }
01182         }
01183    }
01184   ACE_CATCHANY
01185     {
01186       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
01187                            ACE_TEXT ("visit_component"));
01188 
01189       return -1;
01190     }
01191   ACE_ENDTRY;
01192 
01193   return 0;
01194 }
01195 
01196 int
01197 ifr_adding_visitor::visit_component_fwd (AST_ComponentFwd *node)
01198 {
01199   if (node->imported () && !be_global->do_included_files ())
01200     {
01201       return 0;
01202     }
01203 
01204   AST_Component *c =
01205     AST_Component::narrow_from_decl (node->full_definition ());
01206 
01207   ACE_DECLARE_NEW_CORBA_ENV;
01208   ACE_TRY
01209     {
01210       // Is this interface already in the respository?
01211       CORBA::Contained_var prev_def =
01212         be_global->repository ()->lookup_id (c->repoID ()
01213                                              ACE_ENV_ARG_PARAMETER);
01214       ACE_TRY_CHECK;
01215 
01216       if (CORBA::is_nil (prev_def.in ()))
01217         {
01218           CORBA::Container_ptr current_scope =
01219             CORBA::Container::_nil ();
01220 
01221           if (be_global->ifr_scopes ().top (current_scope) == 0)
01222             {
01223               CORBA::ComponentIR::Container_var ccm_scope =
01224                 CORBA::ComponentIR::Container::_narrow (
01225                                                    current_scope
01226                                                    ACE_ENV_ARG_PARAMETER
01227                                                  );
01228               ACE_TRY_CHECK;
01229 
01230               // If our full definition is found in this IDL file, we go
01231               // ahead and create the full entry now.
01232               // The forward declared component is not defined anywhere
01233               // in this IDL file, so we just create an empty entry to
01234               // be replaced by a full definition later.
01235               CORBA::InterfaceDefSeq supported_interfaces;
01236               supported_interfaces.length (0);
01237               CORBA::ComponentIR::ComponentDef_var base_component;
01238 
01239 
01240               if (node->is_defined ())
01241                 {
01242                   this->fill_supported_interfaces (supported_interfaces,
01243                                                    c
01244                                                    ACE_ENV_ARG_PARAMETER);
01245                   ACE_TRY_CHECK;
01246 
01247                   this->fill_base_component (base_component.out (),
01248                                              c
01249                                              ACE_ENV_ARG_PARAMETER);
01250                   ACE_TRY_CHECK;
01251                 }
01252 
01253               this->ir_current_ =
01254                 ccm_scope->create_component (
01255                                c->repoID (),
01256                                c->local_name ()->get_string (),
01257                                c->version (),
01258                                base_component.in (),
01259                                supported_interfaces
01260                                ACE_ENV_ARG_PARAMETER
01261                              );
01262               ACE_TRY_CHECK;
01263 
01264               // Might as well go ahead and complete the repository
01265               // entry now, if we can - we're halfway there already.
01266               if (node->is_defined ())
01267                 {
01268                   CORBA::ComponentIR::ComponentDef_var new_def =
01269                     CORBA::ComponentIR::ComponentDef::_narrow (
01270                         this->ir_current_.in ()
01271                         ACE_ENV_ARG_PARAMETER
01272                       );
01273                   ACE_TRY_CHECK;
01274 
01275                   this->visit_all_provides (c,
01276                                             new_def.in ()
01277                                             ACE_ENV_ARG_PARAMETER);
01278                   ACE_TRY_CHECK;
01279 
01280                   this->visit_all_uses (c,
01281                                         new_def.in ()
01282                                         ACE_ENV_ARG_PARAMETER);
01283                   ACE_TRY_CHECK;
01284 
01285                   this->visit_all_emits (c,
01286                                          new_def.in ()
01287                                          ACE_ENV_ARG_PARAMETER);
01288                   ACE_TRY_CHECK;
01289 
01290                   this->visit_all_publishes (c,
01291                                              new_def.in ()
01292                                              ACE_ENV_ARG_PARAMETER);
01293                   ACE_TRY_CHECK;
01294 
01295                   this->visit_all_consumes (c,
01296                                             new_def.in ()
01297                                             ACE_ENV_ARG_PARAMETER);
01298                   ACE_TRY_CHECK;
01299                 }
01300             }
01301           else
01302             {
01303               ACE_ERROR_RETURN ((
01304                   LM_ERROR,
01305                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01306                   ACE_TEXT ("visit_component_fwd -")
01307                   ACE_TEXT (" scope stack is empty\n")
01308                 ),
01309                 -1
01310               );
01311             }
01312 
01313           node->ifr_added (1);
01314           c->ifr_fwd_added (1);
01315         }
01316    }
01317   ACE_CATCHANY
01318     {
01319       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
01320                            ACE_TEXT ("visit_component_fwd"));
01321 
01322       return -1;
01323     }
01324   ACE_ENDTRY;
01325 
01326   return 0;
01327 }
01328 
01329 int
01330 ifr_adding_visitor::visit_eventtype (AST_EventType *node)
01331 {
01332   if (node->imported () && !be_global->do_included_files ())
01333     {
01334       return 0;
01335     }
01336 
01337   ACE_DECLARE_NEW_CORBA_ENV;
01338   ACE_TRY
01339     {
01340       // Is this interface already in the respository?
01341       CORBA::Contained_var prev_def =
01342         be_global->repository ()->lookup_id (node->repoID ()
01343                                              ACE_ENV_ARG_PARAMETER);
01344       ACE_TRY_CHECK;
01345 
01346       // If not, create a new entry.
01347       if (CORBA::is_nil (prev_def.in ()))
01348         {
01349           int status = this->create_event_def (node
01350                                                ACE_ENV_ARG_PARAMETER);
01351           ACE_TRY_CHECK;
01352 
01353           return status;
01354         }
01355       else
01356         {
01357           // There is already an entry in the repository. If the interface is
01358           // defined and has not already been populated, we do so
01359           // now. If it is not yet defined or the full definition has already
01360           // been added to the repository, we just update the current IR object
01361           // holder.
01362           if (node->is_defined ()
01363               && node->ifr_added () == 0
01364               && this->in_reopened_ == 0)
01365             {
01366               // If we are here and the line below is true, then either
01367               // 1. We are defining an undefined forward declared interface
01368               //    from a previously processed IDL file, or
01369               // 2. We are clobbering a previous definition, either of an
01370               //    interface or of some other type.
01371               // 3. We are inside a module that has a previous entry.
01372               // If prev_def would narrow successfully to an InterfaceDef, we
01373               // have NO WAY of knowing if we are defining or clobbering. So
01374               // we destroy the contents of the previous entry (we don't want
01375               // to destroy the entry itself, since it may have already been
01376               // made a member of some other entry, and destroying it would
01377               // make the containing entry's key invalid) and repopulate.
01378               // On the other hand, if prev_def is NOT an interface, we can
01379               // safely destroy it, since we know we are not redefining a
01380               // previous entry, forward declared or not.
01381               // If we are inside a module that was seen before, we could be
01382               // just processing an IDL file a second time, in which case we
01383               // again just update ir_current_.
01384               if (node->ifr_fwd_added () == 0)
01385                 {
01386                   CORBA::DefinitionKind kind =
01387                     prev_def->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER);
01388                   ACE_TRY_CHECK;
01389 
01390                   if (kind == CORBA::dk_Value)
01391                     {
01392                       CORBA::ComponentIR::EventDef_var event =
01393                         CORBA::ComponentIR::EventDef::_narrow (
01394                             prev_def.in ()
01395                             ACE_ENV_ARG_PARAMETER
01396                           );
01397                       ACE_TRY_CHECK;
01398 
01399                       CORBA::ContainedSeq_var contents =
01400                         event->contents (CORBA::dk_all,
01401                                          1
01402                                          ACE_ENV_ARG_PARAMETER);
01403                       ACE_TRY_CHECK;
01404 
01405                       CORBA::ULong length = contents->length ();
01406 
01407                       for (CORBA::ULong i = 0; i < length; ++i)
01408                         {
01409                           contents[i]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
01410                           ACE_TRY_CHECK;
01411                         }
01412                     }
01413                   else
01414                     {
01415                       prev_def->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
01416                       ACE_TRY_CHECK;
01417 
01418                       int status =
01419                         this->create_event_def (node
01420                                                 ACE_ENV_ARG_PARAMETER);
01421                       ACE_TRY_CHECK;
01422 
01423                       return status;
01424                     }
01425                 }
01426 
01427               // Our previous definition is a valuetype, so narrow it here,
01428               // then populate it.
01429               CORBA::ComponentIR::EventDef_var extant_def =
01430                 CORBA::ComponentIR::EventDef::_narrow (prev_def. in ()
01431                                                        ACE_ENV_ARG_PARAMETER);
01432               ACE_TRY_CHECK;
01433 
01434               // Concrete base value.
01435 
01436               CORBA::ValueDef_var base_vt;
01437               this->fill_base_value (base_vt.out (),
01438                                      node
01439                                      ACE_ENV_ARG_PARAMETER);
01440               ACE_TRY_CHECK;
01441 
01442               extant_def->base_value (base_vt.in ()
01443                                       ACE_ENV_ARG_PARAMETER);
01444               ACE_TRY_CHECK;
01445 
01446               // Abstract base values.
01447 
01448               CORBA::ValueDefSeq abstract_base_values;
01449               this->fill_abstract_base_values (abstract_base_values,
01450                                                node
01451                                                ACE_ENV_ARG_PARAMETER);
01452               ACE_TRY_CHECK;
01453 
01454               extant_def->abstract_base_values (abstract_base_values
01455                                                 ACE_ENV_ARG_PARAMETER);
01456               ACE_TRY_CHECK;
01457 
01458               // Supported interfaces.
01459 
01460               CORBA::InterfaceDefSeq supported;
01461               this->fill_supported_interfaces (supported,
01462                                                node
01463                                                ACE_ENV_ARG_PARAMETER);
01464               ACE_TRY_CHECK;
01465 
01466               extant_def->supported_interfaces (supported
01467                                                 ACE_ENV_ARG_PARAMETER);
01468               ACE_TRY_CHECK;
01469 
01470               // Intializers.
01471 
01472               CORBA::ExtInitializerSeq initializers;
01473               this->fill_initializers (initializers,
01474                                        node
01475                                        ACE_ENV_ARG_PARAMETER);
01476               ACE_TRY_CHECK;
01477 
01478               extant_def->ext_initializers (initializers
01479                                             ACE_ENV_ARG_PARAMETER);
01480               ACE_TRY_CHECK;
01481 
01482               // Truncatable, abstract, custom.
01483 
01484               extant_def->is_abstract (static_cast<CORBA::Boolean> (node->is_abstract ())
01485                                        ACE_ENV_ARG_PARAMETER);
01486               ACE_TRY_CHECK;
01487 
01488               extant_def->is_truncatable (static_cast<CORBA::Boolean> (node->truncatable ())
01489                                           ACE_ENV_ARG_PARAMETER);
01490               ACE_TRY_CHECK;
01491 
01492               extant_def->is_custom (static_cast<CORBA::Boolean> (node->custom ())
01493                                      ACE_ENV_ARG_PARAMETER);
01494               ACE_TRY_CHECK;
01495 
01496               node->ifr_added (1);
01497 
01498               // Push the new IR object onto the scope stack before visiting
01499               // the new object's scope.
01500               if (be_global->ifr_scopes ().push (extant_def.in ()) != 0)
01501                 {
01502                   ACE_ERROR_RETURN ((
01503                       LM_ERROR,
01504                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01505                       ACE_TEXT ("visit_eventtype -")
01506                       ACE_TEXT (" scope push failed\n")
01507                     ),
01508                     -1
01509                   );
01510                 }
01511 
01512               // Visit the members, if any.
01513               if (this->visit_scope (node) == -1)
01514                 {
01515                   ACE_ERROR_RETURN ((
01516                       LM_ERROR,
01517                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01518                       ACE_TEXT ("visit_eventtype -")
01519                       ACE_TEXT (" visit_scope failed\n")
01520                     ),
01521                     -1
01522                   );
01523                 }
01524 
01525               // This spot in the AST doesn't necessarily have to be the
01526               // interface definition - it could be any reference to it.
01527               // The front end will already have fully defined it, so all
01528               // the info is available anywhere. So it's a good idea to
01529               // update the current IR object holder now.
01530               this->ir_current_ =
01531                 CORBA::IDLType::_duplicate (extant_def.in ());
01532 
01533               CORBA::Container_ptr used_scope =
01534                 CORBA::Container::_nil ();
01535 
01536               // Pop the new IR object back off the scope stack.
01537               if (be_global->ifr_scopes ().pop (used_scope) != 0)
01538                 {
01539                   ACE_ERROR_RETURN ((
01540                       LM_ERROR,
01541                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01542                       ACE_TEXT ("visit_eventtype -")
01543                       ACE_TEXT (" scope pop failed\n")
01544                     ),
01545                     -1
01546                   );
01547                 }
01548             }
01549           else
01550             {
01551               // @@ (JP) I think we're ok here without a check:
01552               // not defined/not added - visit_valuetype_fwd will have
01553               //                         detected a clobber.
01554               // not defined/added - not possible.
01555               // defined/not added - takes the other branch.
01556               // defined/added - we're ok.
01557               this->ir_current_ =
01558                 CORBA::IDLType::_narrow (prev_def.in ()
01559                                          ACE_ENV_ARG_PARAMETER);
01560               ACE_TRY_CHECK;
01561             }
01562         }
01563     }
01564   ACE_CATCHANY
01565     {
01566       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
01567                            ACE_TEXT ("visit_eventtype"));
01568 
01569       return -1;
01570     }
01571   ACE_ENDTRY;
01572 
01573   return 0;
01574 }
01575 
01576 int
01577 ifr_adding_visitor::visit_eventtype_fwd (AST_EventTypeFwd *node)
01578 {
01579   if (node->imported () && !be_global->do_included_files ())
01580     {
01581       return 0;
01582     }
01583 
01584   AST_Interface *v = node->full_definition ();
01585 
01586   ACE_DECLARE_NEW_CORBA_ENV;
01587   ACE_TRY
01588     {
01589       // Is this interface already in the respository?
01590       CORBA::Contained_var prev_def =
01591         be_global->repository ()->lookup_id (v->repoID ()
01592                                              ACE_ENV_ARG_PARAMETER);
01593       ACE_TRY_CHECK;
01594 
01595       if (CORBA::is_nil (prev_def.in ()))
01596         {
01597           // If our full definition is found in this IDL file, we go
01598           // ahead and create the full entry now.
01599           // The forward declared valuetype is not defined anywhere
01600           // in this IDL file, so we just create an empty entry to
01601           // be replaced by a full definition in some other IDL file.
01602           CORBA::ValueDefSeq abstract_bases (0);
01603           abstract_bases.length (0);
01604           CORBA::InterfaceDefSeq supported (0);
01605           supported.length (0);
01606           CORBA::ExtInitializerSeq initializers (0);
01607           initializers.length (0);
01608 
01609           CORBA::Container_ptr current_scope =
01610             CORBA::Container::_nil ();
01611 
01612           if (be_global->ifr_scopes ().top (current_scope) == 0)
01613             {
01614               CORBA::ComponentIR::Container_var ccm_scope =
01615                 CORBA::ComponentIR::Container::_narrow (
01616                                                    current_scope
01617                                                    ACE_ENV_ARG_PARAMETER
01618                                                  );
01619               ACE_TRY_CHECK;
01620 
01621               CORBA::Boolean abstract =
01622                 static_cast<CORBA::Boolean> (v->is_abstract ());
01623 
01624               this->ir_current_ =
01625                 ccm_scope->create_event (
01626                                v->repoID (),
01627                                v->local_name ()->get_string (),
01628                                v->version (),
01629                                0, // 'custom' not handled yet
01630                                abstract,
01631                                CORBA::ValueDef::_nil (),
01632                                0, // 'truncatable' not handled yet
01633                                abstract_bases,
01634                                supported,
01635                                initializers
01636                                ACE_ENV_ARG_PARAMETER
01637                              );
01638               ACE_TRY_CHECK;
01639             }
01640           else
01641             {
01642               ACE_ERROR_RETURN ((
01643                   LM_ERROR,
01644                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01645                   ACE_TEXT ("visit_eventtype_fwd -")
01646                   ACE_TEXT (" scope stack is empty\n")
01647                 ),
01648                 -1
01649               );
01650             }
01651 
01652           node->ifr_added (1);
01653           v->ifr_fwd_added (1);
01654         }
01655    }
01656   ACE_CATCHANY
01657     {
01658       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
01659                            ACE_TEXT ("visit_eventtype_fwd"));
01660 
01661       return -1;
01662     }
01663   ACE_ENDTRY;
01664 
01665   return 0;
01666 }
01667 
01668 int
01669 ifr_adding_visitor::visit_home (AST_Home *node)
01670 {
01671   if (node->imported () && !be_global->do_included_files ())
01672     {
01673       return 0;
01674     }
01675 
01676   ACE_DECLARE_NEW_CORBA_ENV;
01677   ACE_TRY
01678     {
01679       // Is this interface already in the respository?
01680       CORBA::Contained_var prev_def =
01681         be_global->repository ()->lookup_id (node->repoID ()
01682                                              ACE_ENV_ARG_PARAMETER);
01683       ACE_TRY_CHECK;
01684 
01685       // If not, create a new entry.
01686       if (CORBA::is_nil (prev_def.in ()))
01687         {
01688           int status = this->create_home_def (node
01689                                               ACE_ENV_ARG_PARAMETER);
01690           ACE_TRY_CHECK;
01691 
01692           return status;
01693         }
01694       else
01695         {
01696           // There is already an entry in the repository. If the interface is
01697           // defined and has not already been populated, we do so
01698           // now. If it is not yet defined or the full definition has already
01699           // been added to the repository, we just update the current IR object
01700           // holder.
01701           if (node->is_defined ()
01702               && node->ifr_added () == 0
01703               && this->in_reopened_ == 0)
01704             {
01705               // If we are here and the line below is true, then either
01706               // 1. We are defining an undefined forward declared interface
01707               //    from a previously processed IDL file, or
01708               // 2. We are clobbering a previous definition, either of an
01709               //    interface or of some other type.
01710               // 3. We are inside a module that has a previous entry.
01711               // If prev_def would narrow successfully to an InterfaceDef, we
01712               // have NO WAY of knowing if we are defining or clobbering. So
01713               // we destroy the contents of the previous entry (we don't want
01714               // to destroy the entry itself, since it may have already been
01715               // made a member of some other entry, and destroying it would
01716               // make the containing entry's key invalid) and repopulate.
01717               // On the other hand, if prev_def is NOT an interface, we can
01718               // safely destroy it, since we know we are not redefining a
01719               // previous entry, forward declared or not.
01720               // If we are inside a module that was seen before, we could be
01721               // just processing an IDL file a second time, in which case we
01722               // again just update ir_current_.
01723               if (node->ifr_fwd_added () == 0)
01724                 {
01725                   CORBA::DefinitionKind kind =
01726                     prev_def->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER);
01727                   ACE_TRY_CHECK;
01728 
01729                   if (kind == CORBA::dk_Component)
01730                     {
01731                       CORBA::ComponentIR::HomeDef_var value =
01732                         CORBA::ComponentIR::HomeDef::_narrow (
01733                             prev_def.in ()
01734                             ACE_ENV_ARG_PARAMETER
01735                           );
01736                       ACE_TRY_CHECK;
01737 
01738                       CORBA::ContainedSeq_var contents =
01739                         value->contents (CORBA::dk_all,
01740                                          1
01741                                          ACE_ENV_ARG_PARAMETER);
01742                       ACE_TRY_CHECK;
01743 
01744                       CORBA::ULong length = contents->length ();
01745 
01746                       for (CORBA::ULong i = 0; i < length; ++i)
01747                         {
01748                           contents[i]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
01749                           ACE_TRY_CHECK;
01750                         }
01751                     }
01752                   else
01753                     {
01754                       prev_def->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
01755                       ACE_TRY_CHECK;
01756 
01757                       int status =
01758                         this->create_home_def (node
01759                                                ACE_ENV_ARG_PARAMETER);
01760                       ACE_TRY_CHECK;
01761 
01762                       return status;
01763                     }
01764                 }
01765 
01766               // Re-populate the repository entry.
01767 
01768             }
01769           else
01770             {
01771               // @@ (JP) I think we're ok here without a check:
01772               // not defined/not added - visit_interface_fwd will have
01773               //                         detected a clobber.
01774               // not defined/added - not possible.
01775               // defined/not added - takes the other branch.
01776               // defined/added - we're ok.
01777               this->ir_current_ =
01778                 CORBA::IDLType::_narrow (prev_def.in ()
01779                                          ACE_ENV_ARG_PARAMETER);
01780               ACE_TRY_CHECK;
01781             }
01782         }
01783    }
01784   ACE_CATCHANY
01785     {
01786       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
01787                            ACE_TEXT ("visit_home"));
01788 
01789       return -1;
01790     }
01791   ACE_ENDTRY;
01792 
01793   return 0;
01794 }
01795 
01796 int
01797 ifr_adding_visitor::visit_factory (AST_Factory *)
01798 {
01799   return 0;
01800 }
01801 
01802 int
01803 ifr_adding_visitor::visit_structure (AST_Structure *node)
01804 {
01805   if (node->imported () && !be_global->do_included_files ())
01806     {
01807       return 0;
01808     }
01809 
01810   ACE_DECLARE_NEW_CORBA_ENV;
01811   ACE_TRY
01812     {
01813       CORBA::Contained_var prev_def =
01814         be_global->repository ()->lookup_id (node->repoID ()
01815                                              ACE_ENV_ARG_PARAMETER);
01816       ACE_TRY_CHECK;
01817 
01818       if (CORBA::is_nil (prev_def.in ()))
01819         {
01820           ifr_adding_visitor_structure visitor (node, 0);
01821           int retval = visitor.visit_structure (node);
01822 
01823           if (retval == 0)
01824             {
01825               this->ir_current_ =
01826                 CORBA::IDLType::_duplicate (visitor.ir_current ());
01827             }
01828 
01829           return retval;
01830         }
01831       else
01832         {
01833           // If the line below is true, we are clobbering a previous
01834           // entry (from another IDL file) of another type. In that
01835           // case we do what other ORB vendors do, and destroy the
01836           // original entry, create the new one, and let the user beware.
01837           // Unless we are in a module that has been seen before, in
01838           // which case we might be just processing and IDL file a
01839           // second time and we want to just update ir_current_.
01840           if (node->ifr_added () == 0 && this->in_reopened_ == 0)
01841             {
01842               prev_def->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
01843               ACE_TRY_CHECK;
01844 
01845               return this->visit_structure (node);
01846             }
01847 
01848           this->ir_current_ =
01849             CORBA::IDLType::_narrow (prev_def.in ()
01850                                     ACE_ENV_ARG_PARAMETER);
01851           ACE_TRY_CHECK;
01852         }
01853     }
01854   ACE_CATCHANY
01855     {
01856       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
01857                            ACE_TEXT ("ifr_adding_visitor::visit_structure"));
01858 
01859       return -1;
01860     }
01861   ACE_ENDTRY;
01862 
01863   return 0;
01864 }
01865 
01866 int
01867 ifr_adding_visitor::visit_exception (AST_Exception *node)
01868 {
01869   if (node->imported () && !be_global->do_included_files ())
01870     {
01871       return 0;
01872     }
01873 
01874   ifr_adding_visitor_exception visitor (node,
01875                                         this->in_reopened_);
01876 
01877   // No point in updating ir_current_ here because
01878   // ExceptionDef is not an IDLType.
01879 
01880   return visitor.visit_exception (node);
01881 }
01882 
01883 int
01884 ifr_adding_visitor::visit_enum (AST_Enum *node)
01885 {
01886   if (node->imported () && !be_global->do_included_files ())
01887     {
01888       return 0;
01889     }
01890 
01891   ACE_DECLARE_NEW_CORBA_ENV;
01892   ACE_TRY
01893     {
01894       // Is this enum already in the respository?
01895       CORBA::Contained_var prev_def =
01896         be_global->repository ()->lookup_id (node->repoID ()
01897                                              ACE_ENV_ARG_PARAMETER);
01898       ACE_TRY_CHECK;
01899 
01900       // If not, create a new entry.
01901       if (CORBA::is_nil (prev_def.in ()))
01902         {
01903           CORBA::ULong member_count =
01904             static_cast<CORBA::ULong> (node->member_count ());
01905 
01906           CORBA::EnumMemberSeq members (member_count);
01907           members.length (member_count);
01908 
01909           UTL_ScopedName *member_name = 0;
01910 
01911           // Get a list of the member names.
01912           for (CORBA::ULong i = 0; i < member_count; ++i)
01913             {
01914               member_name = node->value_to_name (i);
01915 
01916               members[i] =
01917                 CORBA::string_dup (
01918                     member_name->last_component ()->get_string ()
01919                   );
01920             }
01921 
01922           CORBA::Container_ptr current_scope =
01923             CORBA::Container::_nil ();
01924 
01925           if (be_global->ifr_scopes ().top (current_scope) == 0)
01926             {
01927               this->ir_current_ =
01928                 current_scope->create_enum (
01929                     node->repoID (),
01930                     node->local_name ()->get_string (),
01931                     node->version (),
01932                     members
01933                     ACE_ENV_ARG_PARAMETER
01934                   );
01935               ACE_TRY_CHECK;
01936             }
01937           else
01938             {
01939               ACE_ERROR_RETURN ((
01940                   LM_ERROR,
01941                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_enum -")
01942                   ACE_TEXT (" scope stack is empty\n")
01943                 ),
01944                 -1
01945               );
01946             }
01947 
01948           node->ifr_added (1);
01949         }
01950       else
01951         {
01952           // If the line below is true, we are clobbering a previous
01953           // entry (from another IDL file) of another type. In that
01954           // case we do what other ORB vendors do, and destroy the
01955           // original entry, create the new one, and let the user beware.
01956           // Unless we are in a module that has been seen before, in
01957           // which case we might be just processing and IDL file a
01958           // second time and we want to just update ir_current_.
01959           if (node->ifr_added () == 0 && this->in_reopened_ == 0)
01960             {
01961               prev_def->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
01962               ACE_TRY_CHECK;
01963 
01964               return this->visit_enum (node);
01965             }
01966 
01967           // There is already an entry in the repository, so just update
01968           // the current IR object holder.
01969           this->ir_current_ =
01970             CORBA::EnumDef::_narrow (prev_def.in ()
01971                                     ACE_ENV_ARG_PARAMETER);
01972           ACE_TRY_CHECK;
01973         }
01974     }
01975   ACE_CATCHANY
01976     {
01977       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
01978                            ACE_TEXT ("ifr_adding_visitor::visit_enum"));
01979 
01980       return -1;
01981     }
01982   ACE_ENDTRY;
01983 
01984   return 0;
01985 }
01986 
01987 int
01988 ifr_adding_visitor::visit_operation (AST_Operation *node)
01989 {
01990   ifr_adding_visitor_operation visitor (node);
01991 
01992   return visitor.visit_operation (node);
01993 }
01994 
01995 int
01996 ifr_adding_visitor::visit_field (AST_Field *node)
01997 {
01998   AST_Decl *scope = ScopeAsDecl (node->defined_in ());
01999   AST_Decl::NodeType nt = scope->node_type ();
02000 
02001   if (nt == AST_Decl::NT_valuetype || nt == AST_Decl::NT_eventtype)
02002     {
02003       return this->create_value_member (node);
02004     }
02005 
02006   AST_Type *ft = AST_Type::narrow_from_decl (node->field_type ());
02007 
02008   if (ft == 0)
02009     {
02010       ACE_ERROR_RETURN ((
02011           LM_ERROR,
02012           ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02013           ACE_TEXT ("visit_field - ")
02014           ACE_TEXT ("Bad field type\n")
02015         ),
02016         -1
02017       );
02018     }
02019 
02020   if (ft->ast_accept (this) == -1)
02021     {
02022       ACE_ERROR_RETURN ((
02023           LM_ERROR,
02024           ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02025           ACE_TEXT ("visit_field - ")
02026           ACE_TEXT ("failed to accept visitor\n")
02027         ),
02028         -1
02029       );
02030     }
02031 
02032   return 0;
02033 }
02034 
02035 int
02036 ifr_adding_visitor::visit_attribute (AST_Attribute *node)
02037 {
02038   ACE_DECLARE_NEW_CORBA_ENV;
02039   ACE_TRY
02040     {
02041       AST_Type *type = node->field_type ();
02042 
02043       // Updates ir_current_.
02044       this->get_referenced_type (type
02045                                  ACE_ENV_ARG_PARAMETER);
02046       ACE_TRY_CHECK;
02047 
02048       CORBA::AttributeMode mode =
02049         node->readonly () ? CORBA::ATTR_READONLY : CORBA::ATTR_NORMAL;
02050 
02051       CORBA::ExceptionDefSeq get_exceptions;
02052       this->fill_get_exceptions (get_exceptions,
02053                                  node
02054                                  ACE_ENV_ARG_PARAMETER);
02055       ACE_TRY_CHECK;
02056 
02057       CORBA::ExceptionDefSeq set_exceptions;
02058       this->fill_set_exceptions (set_exceptions,
02059                                  node
02060                                  ACE_ENV_ARG_PARAMETER);
02061       ACE_TRY_CHECK;
02062 
02063       CORBA::Container_ptr current_scope =
02064         CORBA::Container::_nil ();
02065 
02066       if (be_global->ifr_scopes ().top (current_scope) == 0)
02067         {
02068           CORBA::DefinitionKind kind =
02069             current_scope->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER);
02070           ACE_TRY_CHECK;
02071 
02072           if (kind == CORBA::dk_Value || kind == CORBA::dk_Event)
02073             {
02074               CORBA::ExtValueDef_var value =
02075                 CORBA::ExtValueDef::_narrow (current_scope
02076                                              ACE_ENV_ARG_PARAMETER);
02077               ACE_TRY_CHECK;
02078 
02079               CORBA::ExtAttributeDef_var new_def =
02080                 value->create_ext_attribute (
02081                     node->repoID (),
02082                     node->local_name ()->get_string (),
02083                     node->version (),
02084                     this->ir_current_.in (),
02085                     mode,
02086                     get_exceptions,
02087                     set_exceptions
02088                     ACE_ENV_ARG_PARAMETER
02089                   );
02090               ACE_TRY_CHECK;
02091             }
02092           else
02093             {
02094               // We are an interface, a local interface, an abstract
02095               // interface or a component. This narrow covers them all.
02096               CORBA::InterfaceAttrExtension_var iface =
02097                 CORBA::InterfaceAttrExtension::_narrow (current_scope
02098                                                         ACE_ENV_ARG_PARAMETER);
02099               ACE_TRY_CHECK;
02100 
02101               CORBA::ExtAttributeDef_var new_def =
02102                 iface->create_ext_attribute (
02103                     node->repoID (),
02104                     node->local_name ()->get_string (),
02105                     node->version (),
02106                     this->ir_current_.in (),
02107                     mode,
02108                     get_exceptions,
02109                     set_exceptions
02110                     ACE_ENV_ARG_PARAMETER
02111                   );
02112               ACE_TRY_CHECK;
02113             }
02114         }
02115       else
02116         {
02117           ACE_ERROR_RETURN ((
02118               LM_ERROR,
02119               ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_attribute -")
02120               ACE_TEXT (" scope stack is empty\n")
02121             ),
02122             -1
02123           );
02124         }
02125     }
02126   ACE_CATCHANY
02127     {
02128       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
02129                            ACE_TEXT ("visit_attribute"));
02130 
02131       return -1;
02132     }
02133   ACE_ENDTRY;
02134 
02135   return 0;
02136 }
02137 
02138 int
02139 ifr_adding_visitor::visit_union (AST_Union *node)
02140 {
02141   if (node->imported () && !be_global->do_included_files ())
02142     {
02143       return 0;
02144     }
02145 
02146   ACE_DECLARE_NEW_CORBA_ENV;
02147   ACE_TRY
02148     {
02149       CORBA::Contained_var prev_def =
02150         be_global->repository ()->lookup_id (node->repoID ()
02151                                              ACE_ENV_ARG_PARAMETER);
02152       ACE_TRY_CHECK;
02153 
02154       if (CORBA::is_nil (prev_def.in ()))
02155         {
02156           ifr_adding_visitor_union visitor (node,
02157                                             0);
02158 
02159           int retval = visitor.visit_union (node);
02160 
02161           if (retval == 0)
02162             {
02163               this->ir_current_ =
02164                 CORBA::IDLType::_duplicate (visitor.ir_current ());
02165             }
02166 
02167           return retval;
02168         }
02169       else
02170         {
02171           // If the line below is true, we are clobbering a previous
02172           // entry (from another IDL file) of another type. In that
02173           // case we do what other ORB vendors do, and destroy the
02174           // original entry, create the new one, and let the user beware.
02175           // Unless we are in a module that has been seen before, in
02176           // which case we might be just processing and IDL file a
02177           // second time and we want to just update ir_current_.
02178           if (node->ifr_added () == 0 && this->in_reopened_ == 0)
02179             {
02180               prev_def->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
02181               ACE_TRY_CHECK;
02182 
02183               return this->visit_union (node);
02184             }
02185 
02186           this->ir_current_ =
02187             CORBA::UnionDef::_narrow (prev_def.in ()
02188                                      ACE_ENV_ARG_PARAMETER);
02189           ACE_TRY_CHECK;
02190         }
02191     }
02192   ACE_CATCHANY
02193     {
02194       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
02195                            ACE_TEXT ("ifr_adding_visitor::visit_union"));
02196 
02197       return -1;
02198     }
02199   ACE_ENDTRY;
02200 
02201   return 0;
02202 }
02203 
02204 int
02205 ifr_adding_visitor::visit_constant (AST_Constant *node)
02206 {
02207   if (node->imported () && !be_global->do_included_files ())
02208     {
02209       return 0;
02210     }
02211 
02212   const char *id = node->repoID ();
02213 
02214   ACE_DECLARE_NEW_CORBA_ENV;
02215   ACE_TRY
02216     {
02217       CORBA::Contained_var prev_def =
02218         be_global->repository ()->lookup_id (id
02219                                              ACE_ENV_ARG_PARAMETER);
02220       ACE_TRY_CHECK;
02221 
02222       // Nothing prevents this constant's repo id from already being
02223       // in the repository as another type, if it came from another
02224       // IDL file whose generated code is not linked to the generated
02225       // code from this IDL file. So we check here before we make a
02226       // call on ir_current_.
02227       if (!CORBA::is_nil (prev_def.in ()))
02228         {
02229           // If the line below is true, we are clobbering a previous
02230           // entry (from another IDL file) of another type. In that
02231           // case we do what other ORB vendors do, and destroy the
02232           // original entry, create the new one, and let the user beware.
02233           // Unless we are in a module that has been seen before, in
02234           // which case we might be just processing and IDL file a
02235           // second time and we want to just update ir_current_.
02236           if (node->ifr_added () == 0 && this->in_reopened_ == 0)
02237             {
02238               prev_def->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
02239               ACE_TRY_CHECK;
02240             }
02241           else
02242             {
02243               // The node is referenced in an array size, string bound
02244               // or sequence bound - no action needed in the IFR.
02245               return 0;
02246             }
02247         }
02248 
02249       AST_Expression::AST_ExprValue *ev = node->constant_value ()->ev ();
02250       AST_Decl *td = node->constant_value ()->get_tdef ();
02251 
02252       if (td != 0 && td->node_type () == AST_Decl::NT_typedef)
02253         {
02254           // This constant's type is a typedef - look up the typedef to
02255           // pass to create_constant().
02256           CORBA::Contained_var contained =
02257             be_global->repository ()->lookup_id (td->repoID ()
02258                                                  ACE_ENV_ARG_PARAMETER);
02259           ACE_TRY_CHECK;
02260 
02261           this->ir_current_ = CORBA::IDLType::_narrow (contained.in ()
02262                                                        ACE_ENV_ARG_PARAMETER);
02263           ACE_TRY_CHECK;
02264         }
02265       else
02266         {
02267           CORBA::PrimitiveKind pkind = this->expr_type_to_pkind (ev->et);
02268           this->ir_current_ =
02269             be_global->repository ()->get_primitive (pkind
02270                                                      ACE_ENV_ARG_PARAMETER);
02271           ACE_TRY_CHECK;
02272         }
02273 
02274       CORBA::Any any;
02275       this->load_any (ev,
02276                       any);
02277 
02278       CORBA::Container_ptr current_scope =
02279         CORBA::Container::_nil ();
02280 
02281       if (be_global->ifr_scopes ().top (current_scope) == 0)
02282         {
02283           CORBA::ConstantDef_var new_def =
02284             current_scope->create_constant (
02285                 id,
02286                 node->local_name ()->get_string (),
02287                 node->version (),
02288                 this->ir_current_.in (),
02289                 any
02290                 ACE_ENV_ARG_PARAMETER
02291               );
02292           ACE_TRY_CHECK;
02293         }
02294       else
02295         {
02296           ACE_ERROR_RETURN ((
02297               LM_ERROR,
02298               ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_constant -")
02299               ACE_TEXT (" scope stack is empty\n")
02300             ),
02301             -1
02302           );
02303         }
02304     }
02305   ACE_CATCHANY
02306     {
02307       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
02308                            ACE_TEXT ("visit_constant"));
02309 
02310       return -1;
02311     }
02312   ACE_ENDTRY;
02313 
02314   return 0;
02315 }
02316 
02317 int
02318 ifr_adding_visitor::visit_array (AST_Array *node)
02319 {
02320   ACE_DECLARE_NEW_CORBA_ENV;
02321   ACE_TRY
02322     {
02323       this->element_type (node->base_type ()
02324                           ACE_ENV_ARG_PARAMETER);
02325       ACE_TRY_CHECK;
02326 
02327       AST_Expression **dims = node->dims ();
02328 
02329       for (unsigned long i = node->n_dims (); i > 0; --i)
02330         {
02331           this->ir_current_ =
02332             be_global->repository ()->create_array (
02333                 dims[i - 1]->ev ()->u.ulval,
02334                 this->ir_current_.in ()
02335                 ACE_ENV_ARG_PARAMETER
02336               );
02337           ACE_TRY_CHECK;
02338         }
02339     }
02340   ACE_CATCHANY
02341     {
02342       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
02343                            ACE_TEXT ("visit_array"));
02344 
02345       return -1;
02346     }
02347   ACE_ENDTRY;
02348 
02349   return 0;
02350 }
02351 
02352 int
02353 ifr_adding_visitor::visit_sequence (AST_Sequence *node)
02354 {
02355   ACE_DECLARE_NEW_CORBA_ENV;
02356   ACE_TRY
02357     {
02358       this->element_type (node->base_type ()
02359                           ACE_ENV_ARG_PARAMETER);
02360       ACE_TRY_CHECK;
02361 
02362       this->ir_current_ =
02363         be_global->repository ()->create_sequence (
02364                                       node->max_size ()->ev ()->u.ulval,
02365                                       this->ir_current_.in ()
02366                                       ACE_ENV_ARG_PARAMETER
02367                                     );
02368       ACE_TRY_CHECK;
02369     }
02370   ACE_CATCHANY
02371     {
02372       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
02373                            ACE_TEXT ("visit_sequence"));
02374 
02375       return -1;
02376     }
02377   ACE_ENDTRY;
02378 
02379   return 0;
02380 }
02381 
02382 int
02383 ifr_adding_visitor::visit_string (AST_String *node)
02384 {
02385   AST_Expression *ex = node->max_size ();
02386 
02387   AST_Expression::AST_ExprValue *ev = ex->ev ();
02388 
02389   CORBA::ULong bound = static_cast<CORBA::ULong> (ev->u.ulval);
02390 
02391   ACE_DECLARE_NEW_CORBA_ENV;
02392   ACE_TRY
02393     {
02394       if (node->node_type () == AST_Decl::NT_string)
02395         {
02396           this->ir_current_ =
02397             be_global->repository ()->create_string (bound
02398                                                      ACE_ENV_ARG_PARAMETER);
02399         }
02400       else
02401         {
02402           this->ir_current_ =
02403             be_global->repository ()->create_wstring (bound
02404                                                       ACE_ENV_ARG_PARAMETER);
02405         }
02406 
02407       ACE_TRY_CHECK;
02408     }
02409   ACE_CATCHANY
02410     {
02411       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
02412                            ACE_TEXT ("visit_string"));
02413 
02414       return -1;
02415     }
02416   ACE_ENDTRY;
02417 
02418   return 0;
02419 }
02420 
02421 int
02422 ifr_adding_visitor::visit_typedef (AST_Typedef *node)
02423 {
02424   if (node->imported () && !be_global->do_included_files ())
02425     {
02426       return 0;
02427     }
02428 
02429   ACE_DECLARE_NEW_CORBA_ENV;
02430   ACE_TRY
02431     {
02432       this->element_type (node->base_type ()
02433                           ACE_ENV_ARG_PARAMETER);
02434       ACE_TRY_CHECK;
02435 
02436       CORBA::Container_ptr current_scope =
02437         CORBA::Container::_nil ();
02438 
02439       if (be_global->ifr_scopes ().top (current_scope) == 0)
02440         {
02441           this->ir_current_ =
02442             current_scope->create_alias (
02443                 node->repoID (),
02444                 node->local_name ()->get_string (),
02445                 node->version (),
02446                 this->ir_current_.in ()
02447                 ACE_ENV_ARG_PARAMETER
02448               );
02449           ACE_TRY_CHECK;
02450         }
02451       else
02452         {
02453           ACE_ERROR_RETURN ((
02454               LM_ERROR,
02455               ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_typedef -")
02456               ACE_TEXT (" scope stack is empty\n")
02457             ),
02458             -1
02459           );
02460         }
02461 
02462       node->ifr_added (1);
02463     }
02464   ACE_CATCHANY
02465     {
02466       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
02467                            ACE_TEXT ("visit_typedef"));
02468 
02469       return -1;
02470     }
02471   ACE_ENDTRY;
02472 
02473   return 0;
02474 }
02475 
02476 int
02477 ifr_adding_visitor::visit_root (AST_Root *node)
02478 {
02479   if (be_global->ifr_scopes ().push (be_global->repository ()) != 0)
02480     {
02481       ACE_ERROR_RETURN ((
02482           LM_ERROR,
02483           ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_root -")
02484           ACE_TEXT (" scope push failed\n")
02485         ),
02486         -1
02487       );
02488     }
02489 
02490   if (this->visit_scope (node) == -1)
02491     {
02492       ACE_ERROR_RETURN ((
02493           LM_ERROR,
02494           ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_root -")
02495           ACE_TEXT (" visit_scope failed\n")
02496         ),
02497         -1
02498       );
02499     }
02500 
02501   CORBA::Container_ptr tmp =
02502     CORBA::Container::_nil ();
02503 
02504   if (be_global->ifr_scopes ().pop (tmp) != 0)
02505     {
02506       ACE_ERROR_RETURN ((
02507           LM_ERROR,
02508           ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_root -")
02509           ACE_TEXT (" scope pop failed\n")
02510         ),
02511         -1
02512       );
02513     }
02514 
02515   return 0;
02516 }
02517 
02518 int
02519 ifr_adding_visitor::visit_native (AST_Native *node)
02520 {
02521   if (node->imported () && !be_global->do_included_files ())
02522     {
02523       return 0;
02524     }
02525 
02526   ACE_DECLARE_NEW_CORBA_ENV;
02527   ACE_TRY
02528     {
02529       CORBA::Contained_var prev_def =
02530         be_global->repository ()->lookup_id (node->repoID ()
02531                                              ACE_ENV_ARG_PARAMETER);
02532       ACE_TRY_CHECK;
02533 
02534       if (CORBA::is_nil (prev_def.in ()))
02535         {
02536           CORBA::Container_ptr current_scope =
02537             CORBA::Container::_nil ();
02538 
02539           if (be_global->ifr_scopes ().top (current_scope) == 0)
02540             {
02541               this->ir_current_ =
02542                 current_scope->create_native (
02543                     node->repoID (),
02544                     node->local_name ()->get_string (),
02545                     node->version ()
02546                     ACE_ENV_ARG_PARAMETER
02547                   );
02548               ACE_TRY_CHECK;
02549             }
02550           else
02551             {
02552               ACE_ERROR_RETURN ((
02553                   LM_ERROR,
02554                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_native -")
02555                   ACE_TEXT (" scope stack is empty\n")
02556                 ),
02557                 -1
02558               );
02559             }
02560 
02561           node->ifr_added (1);
02562         }
02563       else
02564         {
02565           // If the line below is true, we are clobbering a previous
02566           // entry (from another IDL file) of another type. In that
02567           // case we do what other ORB vendors do, and destroy the
02568           // original entry, create the new one, and let the user beware.
02569           // Unless we are in a module that has been seen before, in
02570           // which case we might be just processing and IDL file a
02571           // second time and we want to just update ir_current_.
02572           if (node->ifr_added () == 0 && this->in_reopened_ == 0)
02573             {
02574               prev_def->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
02575               ACE_TRY_CHECK;
02576 
02577               // This call will take the other branch.
02578               return this->visit_native (node);
02579             }
02580 
02581           this->ir_current_ =
02582             CORBA::NativeDef::_narrow (prev_def.in ()
02583                                       ACE_ENV_ARG_PARAMETER);
02584           ACE_TRY_CHECK;
02585         }
02586     }
02587   ACE_CATCHANY
02588     {
02589       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
02590                            ACE_TEXT ("visit_native"));
02591 
02592       return -1;
02593     }
02594   ACE_ENDTRY;
02595 
02596   return 0;
02597 }
02598 
02599 CORBA::PrimitiveKind
02600 ifr_adding_visitor::expr_type_to_pkind (AST_Expression::ExprType et)
02601 {
02602   switch (et)
02603     {
02604     case AST_Expression::EV_short:
02605       return CORBA::pk_short;
02606     case AST_Expression::EV_ushort:
02607       return CORBA::pk_ushort;
02608     case AST_Expression::EV_long:
02609       return CORBA::pk_long;
02610     case AST_Expression::EV_ulong:
02611       return CORBA::pk_ulong;
02612     case AST_Expression::EV_longlong:
02613       return CORBA::pk_longlong;
02614     case AST_Expression::EV_ulonglong:
02615       return CORBA::pk_ulonglong;
02616     case AST_Expression::EV_float:
02617       return CORBA::pk_float;
02618     case AST_Expression::EV_double:
02619       return CORBA::pk_double;
02620     case AST_Expression::EV_longdouble:
02621       return CORBA::pk_longdouble;
02622     case AST_Expression::EV_char:
02623       return CORBA::pk_char;
02624     case AST_Expression::EV_wchar:
02625       return CORBA::pk_wchar;
02626     case AST_Expression::EV_octet:
02627       return CORBA::pk_octet;
02628     case AST_Expression::EV_bool:
02629       return CORBA::pk_boolean;
02630     case AST_Expression::EV_string:
02631       return CORBA::pk_string;
02632     case AST_Expression::EV_wstring:
02633       return CORBA::pk_wstring;
02634     case AST_Expression::EV_any:
02635       return CORBA::pk_any;
02636     case AST_Expression::EV_void:
02637       return CORBA::pk_void;
02638     case AST_Expression::EV_none:
02639       return CORBA::pk_null;
02640     default:
02641       return CORBA::pk_null;
02642     }
02643 }
02644 
02645 CORBA::PrimitiveKind
02646 ifr_adding_visitor::predefined_type_to_pkind (AST_PredefinedType *node)
02647 {
02648   switch (node->pt ())
02649     {
02650     case AST_PredefinedType::PT_short:
02651       return CORBA::pk_short;
02652     case AST_PredefinedType::PT_ushort:
02653       return CORBA::pk_ushort;
02654     case AST_PredefinedType::PT_long:
02655       return CORBA::pk_long;
02656     case AST_PredefinedType::PT_ulong:
02657       return CORBA::pk_ulong;
02658     case AST_PredefinedType::PT_longlong:
02659       return CORBA::pk_longlong;
02660     case AST_PredefinedType::PT_ulonglong:
02661       return CORBA::pk_ulonglong;
02662     case AST_PredefinedType::PT_float:
02663       return CORBA::pk_float;
02664     case AST_PredefinedType::PT_double:
02665       return CORBA::pk_double;
02666     case AST_PredefinedType::PT_longdouble:
02667       return CORBA::pk_longdouble;
02668     case AST_PredefinedType::PT_char:
02669       return CORBA::pk_char;
02670     case AST_PredefinedType::PT_wchar:
02671       return CORBA::pk_wchar;
02672     case AST_PredefinedType::PT_octet:
02673       return CORBA::pk_octet;
02674     case AST_PredefinedType::PT_boolean:
02675       return CORBA::pk_boolean;
02676     case AST_PredefinedType::PT_any:
02677       return CORBA::pk_any;
02678     case AST_PredefinedType::PT_void:
02679       return CORBA::pk_void;
02680     case AST_PredefinedType::PT_object:
02681       return CORBA::pk_objref;
02682     case AST_PredefinedType::PT_pseudo:
02683       {
02684         const char *local_name = node->local_name ()->get_string ();
02685 
02686         if (!ACE_OS::strcmp (local_name, "Principal"))
02687           {
02688             return CORBA::pk_Principal;
02689           }
02690         else
02691           {
02692             return CORBA::pk_TypeCode;
02693           }
02694       }
02695     default:
02696       return CORBA::pk_null;
02697     }
02698 }
02699 
02700 void
02701 ifr_adding_visitor::load_any (AST_Expression::AST_ExprValue *ev,
02702                               CORBA::Any &any)
02703 {
02704   switch (ev->et)
02705     {
02706     case AST_Expression::EV_short:
02707       any <<= ev->u.sval;
02708       break;
02709     case AST_Expression::EV_ushort:
02710       any <<= ev->u.usval;
02711       break;
02712     case AST_Expression::EV_long:
02713       any <<= static_cast<CORBA::Long> (ev->u.lval);
02714       break;
02715     case AST_Expression::EV_ulong:
02716       any <<= static_cast<CORBA::ULong> (ev->u.ulval);
02717       break;
02718 #if !defined (ACE_LACKS_LONGLONG_T)
02719     case AST_Expression::EV_longlong:
02720       any <<= ev->u.llval;
02721       break;
02722     case AST_Expression::EV_ulonglong:
02723       any <<= ev->u.ullval;
02724       break;
02725 #endif /* !defined (ACE_LACKS_LONGLONG_T) */
02726     case AST_Expression::EV_float:
02727       any <<= ev->u.fval;
02728       break;
02729     case AST_Expression::EV_double:
02730       any <<= ev->u.dval;
02731       break;
02732 #if 0
02733     case AST_Expression::EV_longdouble:
02734     // Not implemented in IDL compiler.
02735 #endif
02736     case AST_Expression::EV_char:
02737       any <<= CORBA::Any::from_char (ev->u.cval);
02738       break;
02739     case AST_Expression::EV_wchar:
02740       any <<= CORBA::Any::from_wchar (ev->u.wcval);
02741       break;
02742     case AST_Expression::EV_octet:
02743       any <<= CORBA::Any::from_octet (ev->u.oval);
02744       break;
02745     case AST_Expression::EV_bool:
02746       any <<= CORBA::Any::from_boolean ((CORBA::Boolean) ev->u.bval);
02747       break;
02748     case AST_Expression::EV_string:
02749       any <<= ev->u.strval->get_string ();
02750       break;
02751     case AST_Expression::EV_wstring:
02752       {
02753         char *str = ev->u.wstrval;
02754         size_t len = ACE_OS::strlen (str);
02755         CORBA::WChar *wstr = 0;
02756         ACE_NEW (wstr,
02757                  CORBA::WChar[len + 1]);
02758 
02759         for (size_t i = 0; i < len; ++i)
02760           {
02761             wstr[i] = static_cast<CORBA::WChar> (str[i]);
02762           }
02763 
02764         wstr[len] = 0;
02765         any <<= wstr;
02766         delete wstr;
02767         break;
02768       }
02769     default:
02770       break;
02771     }
02772 }
02773 
02774 void
02775 ifr_adding_visitor::element_type (AST_Type *base_type
02776                                   ACE_ENV_ARG_DECL)
02777 {
02778   if (base_type->anonymous ())
02779     {
02780       if (base_type->ast_accept (this) == -1)
02781         {
02782           ACE_ERROR ((
02783               LM_ERROR,
02784               ACE_TEXT ("(%N:%l) ifr_adding_visitor::element_type -")
02785               ACE_TEXT (" failed to accept visitor\n")
02786             ));
02787         }
02788     }
02789   else
02790     {
02791       CORBA::Contained_var contained =
02792         be_global->repository ()->lookup_id (base_type->repoID ()
02793                                              ACE_ENV_ARG_PARAMETER);
02794       ACE_CHECK;
02795 
02796       if (CORBA::is_nil (contained.in ()))
02797         {
02798           ACE_ERROR ((
02799               LM_ERROR,
02800               ACE_TEXT ("(%N:%l) ifr_adding_visitor::element_type -")
02801               ACE_TEXT (" lookup_id failed\n")
02802             ));
02803         }
02804 
02805       this->ir_current_ = CORBA::IDLType::_narrow (contained.in ()
02806                                                   ACE_ENV_ARG_PARAMETER);
02807       ACE_CHECK;
02808     }
02809 }
02810 
02811 int
02812 ifr_adding_visitor::create_interface_def (AST_Interface *node
02813                                           ACE_ENV_ARG_DECL)
02814 {
02815   CORBA::ULong n_parents = static_cast<CORBA::ULong> (node->n_inherits ());
02816   AST_Interface **parents = node->inherits ();
02817   CORBA::Contained_var result;
02818   CORBA::AbstractInterfaceDefSeq abs_bases;
02819   CORBA::InterfaceDefSeq bases;
02820 
02821   if (node->is_abstract ())
02822     {
02823       abs_bases.length (n_parents);
02824 
02825       // Construct a list of the parents.
02826       for (CORBA::ULong i = 0; i < n_parents; ++i)
02827         {
02828           result =
02829             be_global->repository ()->lookup_id (parents[i]->repoID ()
02830                                                  ACE_ENV_ARG_PARAMETER);
02831           ACE_CHECK_RETURN (-1);
02832 
02833           // If we got to visit_interface() from a forward declared interface,
02834           // this node may not yet be in the repository.
02835           if (CORBA::is_nil (result.in ()))
02836             {
02837               int status = this->create_interface_def (parents[i]
02838                                                        ACE_ENV_ARG_PARAMETER);
02839 
02840               if (status != 0)
02841                 {
02842                   ACE_ERROR_RETURN ((
02843                       LM_ERROR,
02844                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02845                       ACE_TEXT ("create_interface_def -")
02846                       ACE_TEXT (" parent interfacedef creation failed\n")
02847                     ),
02848                     -1
02849                   );
02850                 }
02851 
02852               bases[i] =
02853                 CORBA::AbstractInterfaceDef::_narrow (this->ir_current_.in ()
02854                                                       ACE_ENV_ARG_PARAMETER);
02855               ACE_CHECK_RETURN (-1);
02856             }
02857           else
02858             {
02859               abs_bases[i] =
02860                 CORBA::AbstractInterfaceDef::_narrow (result.in ()
02861                                                       ACE_ENV_ARG_PARAMETER);
02862               ACE_CHECK_RETURN (-1);
02863             }
02864 
02865           if (CORBA::is_nil (abs_bases[i]))
02866             {
02867               ACE_ERROR_RETURN ((
02868                   LM_ERROR,
02869                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02870                   ACE_TEXT ("create_interface_def -")
02871                   ACE_TEXT (" CORBA::InterfaceDef::_narrow failed\n")
02872                 ),
02873                 -1
02874               );
02875             }
02876         }
02877     }
02878   else
02879     {
02880       bases.length (n_parents);
02881 
02882       // Construct a list of the parents.
02883       for (CORBA::ULong i = 0; i < n_parents; ++i)
02884         {
02885           result =
02886             be_global->repository ()->lookup_id (parents[i]->repoID ()
02887                                                  ACE_ENV_ARG_PARAMETER);
02888           ACE_CHECK_RETURN (-1);
02889 
02890           // If we got to visit_interface() from a forward declared interface,
02891           // this node may not yet be in the repository.
02892           if (CORBA::is_nil (result.in ()))
02893             {
02894               int status = this->create_interface_def (parents[i]
02895                                                        ACE_ENV_ARG_PARAMETER);
02896 
02897               if (status != 0)
02898                 {
02899                   ACE_ERROR_RETURN ((
02900                       LM_ERROR,
02901                       ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02902                       ACE_TEXT ("create_interface_def -")
02903                       ACE_TEXT (" parent interfacedef creation failed\n")
02904                     ),
02905                     -1
02906                   );
02907                 }
02908 
02909               bases[i] = CORBA::InterfaceDef::_narrow (this->ir_current_.in ()
02910                                                        ACE_ENV_ARG_PARAMETER);
02911               ACE_CHECK_RETURN (-1);
02912             }
02913           else
02914             {
02915               bases[i] = CORBA::InterfaceDef::_narrow (result.in ()
02916                                                        ACE_ENV_ARG_PARAMETER);
02917               ACE_CHECK_RETURN (-1);
02918             }
02919 
02920           if (CORBA::is_nil (bases[i]))
02921             {
02922               ACE_ERROR_RETURN ((
02923                   LM_ERROR,
02924                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02925                   ACE_TEXT ("create_interface_def -")
02926                   ACE_TEXT (" CORBA::InterfaceDef::_narrow failed\n")
02927                 ),
02928                 -1
02929               );
02930             }
02931         }
02932     }
02933 
02934   CORBA::Container_ptr current_scope =
02935     CORBA::Container::_nil ();
02936 
02937   if (be_global->ifr_scopes ().top (current_scope) == 0)
02938     {
02939       CORBA::InterfaceDef_var new_def;
02940 
02941       if (node->is_local ())
02942         {
02943           new_def =
02944             current_scope->create_local_interface (
02945                                node->repoID (),
02946                                node->local_name ()->get_string (),
02947                                node->version (),
02948                                bases
02949                                ACE_ENV_ARG_PARAMETER
02950                              );
02951         }
02952       else if (node->is_abstract ())
02953         {
02954           new_def =
02955             current_scope->create_abstract_interface (
02956                                node->repoID (),
02957                                node->local_name ()->get_string (),
02958                                node->version (),
02959                                abs_bases
02960                                ACE_ENV_ARG_PARAMETER
02961                              );
02962         }
02963       else
02964         {
02965           new_def =
02966             current_scope->create_interface (
02967                                node->repoID (),
02968                                node->local_name ()->get_string (),
02969                                node->version (),
02970                                bases
02971                                ACE_ENV_ARG_PARAMETER
02972                              );
02973         }
02974 
02975       ACE_CHECK_RETURN (-1);
02976 
02977       node->ifr_added (1);
02978 
02979       // Push the new IR object onto the scope stack.
02980       CORBA::Container_var new_scope =
02981         CORBA::Container::_narrow (new_def.in ()
02982                                   ACE_ENV_ARG_PARAMETER);
02983       ACE_CHECK_RETURN (-1);
02984 
02985       if (be_global->ifr_scopes ().push (new_scope.in ()) != 0)
02986         {
02987           ACE_ERROR_RETURN ((
02988               LM_ERROR,
02989               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02990               ACE_TEXT ("create_interface_def -")
02991               ACE_TEXT (" scope push failed\n")
02992             ),
02993             -1
02994           );
02995         }
02996 
02997       // Visit the members, if any.
02998       if (this->visit_scope (node) == -1)
02999         {
03000           ACE_ERROR_RETURN ((
03001               LM_ERROR,
03002               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03003               ACE_TEXT ("create_interface_def -")
03004               ACE_TEXT (" visit_scope failed\n")
03005             ),
03006             -1
03007           );
03008         }
03009 
03010       // This spot in the AST doesn't necessarily have to be the
03011       // interface definition - it could be any reference to it.
03012       // The front end will already have fully defined it, so all
03013       // the info is available anywhere. So it's a good idea to
03014       // update the current IR object holder now. This will
03015       // consume the objref pointer.
03016       this->ir_current_ =
03017         CORBA::IDLType::_duplicate (new_def.in ());
03018 
03019       CORBA::Container_ptr used_scope =
03020         CORBA::Container::_nil ();
03021 
03022       // Pop the new IR object back off the scope stack.
03023       if (be_global->ifr_scopes ().pop (used_scope) != 0)
03024         {
03025           ACE_ERROR_RETURN ((
03026               LM_ERROR,
03027               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03028               ACE_TEXT ("create_interface_def -")
03029               ACE_TEXT (" scope pop failed\n")
03030             ),
03031             -1
03032           );
03033         }
03034     }
03035   else
03036     {
03037       ACE_ERROR_RETURN ((
03038           LM_ERROR,
03039           ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_interface_def -")
03040           ACE_TEXT (" scope stack is empty\n")
03041         ),
03042         -1
03043       );
03044     }
03045 
03046   return 0;
03047 }
03048 
03049 int
03050 ifr_adding_visitor::create_value_def (AST_ValueType *node
03051                                       ACE_ENV_ARG_DECL)
03052 {
03053   CORBA::Container_ptr current_scope =
03054     CORBA::Container::_nil ();
03055 
03056   if (be_global->ifr_scopes ().top (current_scope) == 0)
03057     {
03058       CORBA::ValueDef_var base_value;
03059       this->fill_base_value (base_value.out (),
03060                              node
03061                              ACE_ENV_ARG_PARAMETER);
03062       ACE_CHECK_RETURN (-1);
03063 
03064       CORBA::ValueDefSeq abstract_base_values;
03065       this->fill_abstract_base_values (abstract_base_values,
03066                                        node
03067                                        ACE_ENV_ARG_PARAMETER);
03068       ACE_CHECK_RETURN (-1);
03069 
03070       CORBA::InterfaceDefSeq supported_interfaces;
03071       this->fill_supported_interfaces (supported_interfaces,
03072                                        node
03073                                        ACE_ENV_ARG_PARAMETER);
03074       ACE_CHECK_RETURN (-1);
03075 
03076       CORBA::ExtInitializerSeq initializers;
03077       this->fill_initializers (initializers,
03078                                node
03079                                ACE_ENV_ARG_PARAMETER);
03080       ACE_CHECK_RETURN (-1);
03081 
03082       CORBA::ExtValueDef_var new_def =
03083         current_scope->create_ext_value (
03084                            node->repoID (),
03085                            node->local_name ()->get_string (),
03086                            node->version (),
03087                            static_cast<CORBA::Boolean> (node->custom ()),
03088                            static_cast<CORBA::Boolean> (node->is_abstract ()),
03089                            base_value.in (),
03090                            static_cast<CORBA::Boolean> (node->truncatable ()),
03091                            abstract_base_values,
03092                            supported_interfaces,
03093                            initializers
03094                            ACE_ENV_ARG_PARAMETER
03095                          );
03096       ACE_CHECK_RETURN (-1);
03097 
03098       node->ifr_added (1);
03099 
03100       // Push the new IR object onto the scope stack.
03101       CORBA::Container_var new_scope =
03102         CORBA::Container::_narrow (new_def.in ()
03103                                    ACE_ENV_ARG_PARAMETER);
03104       ACE_CHECK_RETURN (-1);
03105 
03106       if (be_global->ifr_scopes ().push (new_scope.in ()) != 0)
03107         {
03108           ACE_ERROR_RETURN ((
03109               LM_ERROR,
03110               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03111               ACE_TEXT ("create_value_def -")
03112               ACE_TEXT (" scope push failed\n")
03113             ),
03114             -1
03115           );
03116         }
03117 
03118       // Visit the members, if any.
03119       if (this->visit_scope (node) == -1)
03120         {
03121           ACE_ERROR_RETURN ((
03122               LM_ERROR,
03123               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03124               ACE_TEXT ("create_value_def -")
03125               ACE_TEXT (" visit_scope failed\n")
03126             ),
03127             -1
03128           );
03129         }
03130 
03131       // This spot in the AST doesn't necessarily have to be the
03132       // interface definition - it could be any reference to it.
03133       // The front end will already have fully defined it, so all
03134       // the info is available anywhere. So it's a good idea to
03135       // update the current IR object holder now. This will
03136       // consume the objref pointer.
03137       this->ir_current_ =
03138         CORBA::IDLType::_duplicate (new_def.in ());
03139 
03140       CORBA::Container_ptr used_scope =
03141         CORBA::Container::_nil ();
03142 
03143       // Pop the new IR object back off the scope stack.
03144       if (be_global->ifr_scopes ().pop (used_scope) != 0)
03145         {
03146           ACE_ERROR_RETURN ((
03147               LM_ERROR,
03148               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03149               ACE_TEXT ("create_value_def -")
03150               ACE_TEXT (" scope pop failed\n")
03151             ),
03152             -1
03153           );
03154         }
03155     }
03156   else
03157     {
03158       ACE_ERROR_RETURN ((
03159           LM_ERROR,
03160           ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_value_def -")
03161           ACE_TEXT (" scope stack is empty\n")
03162         ),
03163         -1
03164       );
03165     }
03166 
03167   return 0;
03168 }
03169 
03170 int
03171 ifr_adding_visitor::create_component_def (AST_Component *node
03172                                           ACE_ENV_ARG_DECL)
03173 {
03174   CORBA::Container_ptr current_scope =
03175     CORBA::Container::_nil ();
03176 
03177   if (be_global->ifr_scopes ().top (current_scope) == 0)
03178     {
03179       CORBA::ComponentIR::ComponentDef_var base_component;
03180       this->fill_base_component (base_component.out (),
03181                                  node
03182                                  ACE_ENV_ARG_PARAMETER);
03183       ACE_CHECK_RETURN (-1);
03184 
03185       CORBA::InterfaceDefSeq supported_interfaces;
03186       this->fill_supported_interfaces (supported_interfaces,
03187                                        node
03188                                        ACE_ENV_ARG_PARAMETER);
03189       ACE_CHECK_RETURN (-1);
03190 
03191       CORBA::ComponentIR::Container_var ccm_scope =
03192         CORBA::ComponentIR::Container::_narrow (current_scope
03193                                                 ACE_ENV_ARG_PARAMETER);
03194       ACE_CHECK_RETURN (-1);
03195 
03196       CORBA::ComponentIR::ComponentDef_var new_def =
03197         ccm_scope->create_component (node->repoID (),
03198                                      node->local_name ()->get_string (),
03199                                      node->version (),
03200                                      base_component.in (),
03201                                      supported_interfaces
03202                                      ACE_ENV_ARG_PARAMETER);
03203       ACE_CHECK_RETURN (-1);
03204 
03205       node->ifr_added (1);
03206 
03207       if (be_global->ifr_scopes ().push (new_def.in ()) != 0)
03208         {
03209           ACE_ERROR_RETURN ((
03210               LM_ERROR,
03211               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03212               ACE_TEXT ("create_component_def -")
03213               ACE_TEXT (" scope push failed\n")
03214             ),
03215             -1
03216           );
03217         }
03218 
03219       // Visit the members, if any.
03220       if (this->visit_scope (node) == -1)
03221         {
03222           ACE_ERROR_RETURN ((
03223               LM_ERROR,
03224               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03225               ACE_TEXT ("create_component_def -")
03226               ACE_TEXT (" visit_scope failed\n")
03227             ),
03228             -1
03229           );
03230         }
03231 
03232       this->visit_all_provides (node,
03233                                 new_def.in ()
03234                                 ACE_ENV_ARG_PARAMETER);
03235       ACE_CHECK_RETURN (-1);
03236 
03237       this->visit_all_uses (node,
03238                             new_def.in ()
03239                             ACE_ENV_ARG_PARAMETER);
03240       ACE_CHECK_RETURN (-1);
03241 
03242       this->visit_all_emits (node,
03243                              new_def.in ()
03244                              ACE_ENV_ARG_PARAMETER);
03245       ACE_CHECK_RETURN (-1);
03246 
03247       this->visit_all_publishes (node,
03248                                  new_def.in ()
03249                                  ACE_ENV_ARG_PARAMETER);
03250       ACE_CHECK_RETURN (-1);
03251 
03252       this->visit_all_consumes (node,
03253                                 new_def.in ()
03254                                 ACE_ENV_ARG_PARAMETER);
03255       ACE_CHECK_RETURN (-1);
03256 
03257       // This spot in the AST doesn't necessarily have to be the
03258       // interface definition - it could be any reference to it.
03259       // The front end will already have fully defined it, so all
03260       // the info is available anywhere. So it's a good idea to
03261       // update the current IR object holder now. This will
03262       // consume the objref pointer.
03263       this->ir_current_ =
03264         CORBA::IDLType::_duplicate (new_def.in ());
03265 
03266       CORBA::Container_ptr used_scope =
03267         CORBA::Container::_nil ();
03268 
03269       // Pop the new IR object back off the scope stack.
03270       if (be_global->ifr_scopes ().pop (used_scope) != 0)
03271         {
03272           ACE_ERROR_RETURN ((
03273               LM_ERROR,
03274               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03275               ACE_TEXT ("create_component_def -")
03276               ACE_TEXT (" scope pop failed\n")
03277             ),
03278             -1
03279           );
03280         }
03281     }
03282   else
03283     {
03284       ACE_ERROR_RETURN ((
03285           LM_ERROR,
03286           ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_component_def -")
03287           ACE_TEXT (" scope stack is empty\n")
03288         ),
03289         -1
03290       );
03291     }
03292 
03293   return 0;
03294 }
03295 
03296 int
03297 ifr_adding_visitor::create_home_def (AST_Home *node
03298                                      ACE_ENV_ARG_DECL)
03299 {
03300   CORBA::Container_ptr current_scope =
03301     CORBA::Container::_nil ();
03302 
03303   if (be_global->ifr_scopes ().top (current_scope) == 0)
03304     {
03305       CORBA::ComponentIR::HomeDef_var base_home;
03306       this->fill_base_home (base_home.out (),
03307                             node
03308                             ACE_ENV_ARG_PARAMETER);
03309       ACE_CHECK_RETURN (-1);
03310 
03311       CORBA::ComponentIR::ComponentDef_var managed_component;
03312       this->fill_managed_component (managed_component.out (),
03313                                     node
03314                                     ACE_ENV_ARG_PARAMETER);
03315       ACE_CHECK_RETURN (-1);
03316 
03317       CORBA::InterfaceDefSeq supported_interfaces;
03318       this->fill_supported_interfaces (supported_interfaces,
03319                                        node
03320                                        ACE_ENV_ARG_PARAMETER);
03321       ACE_CHECK_RETURN (-1);
03322 
03323       CORBA::ValueDef_var primary_key;
03324       this->fill_primary_key (primary_key.out (),
03325                               node
03326                               ACE_ENV_ARG_PARAMETER);
03327       ACE_CHECK_RETURN (-1);
03328 
03329       CORBA::ComponentIR::Container_var ccm_scope =
03330         CORBA::ComponentIR::Container::_narrow (current_scope
03331                                                 ACE_ENV_ARG_PARAMETER);
03332       ACE_CHECK_RETURN (-1);
03333 
03334       CORBA::ComponentIR::HomeDef_var new_def =
03335         ccm_scope->create_home (node->repoID (),
03336                                 node->local_name ()->get_string (),
03337                                 node->version (),
03338                                 base_home.in (),
03339                                 managed_component.in (),
03340                                 supported_interfaces,
03341                                 primary_key.in ()
03342                                 ACE_ENV_ARG_PARAMETER);
03343       ACE_CHECK_RETURN (-1);
03344 
03345       node->ifr_added (1);
03346 
03347       // Push the new IR object onto the scope stack.
03348       CORBA::Container_var new_scope =
03349         CORBA::Container::_narrow (new_def.in ()
03350                                    ACE_ENV_ARG_PARAMETER);
03351       ACE_CHECK_RETURN (-1);
03352 
03353       if (be_global->ifr_scopes ().push (new_scope.in ()) != 0)
03354         {
03355           ACE_ERROR_RETURN ((
03356               LM_ERROR,
03357               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03358               ACE_TEXT ("create_home_def -")
03359               ACE_TEXT (" scope push failed\n")
03360             ),
03361             -1
03362           );
03363         }
03364 
03365       // Visit the members, if any.
03366       if (this->visit_scope (node) == -1)
03367         {
03368           ACE_ERROR_RETURN ((
03369               LM_ERROR,
03370               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03371               ACE_TEXT ("create_home_def -")
03372               ACE_TEXT (" visit_scope failed\n")
03373             ),
03374             -1
03375           );
03376         }
03377 
03378       // Get the contents of these lists into the repository.
03379 
03380       this->visit_all_factories (node,
03381                                  new_def.in ()
03382                                  ACE_ENV_ARG_PARAMETER);
03383       ACE_CHECK_RETURN (-1);
03384 
03385       this->visit_all_finders (node,
03386                                new_def.in ()
03387                                ACE_ENV_ARG_PARAMETER);
03388       ACE_CHECK_RETURN (-1);
03389 
03390       // This spot in the AST doesn't necessarily have to be the
03391       // interface definition - it could be any reference to it.
03392       // The front end will already have fully defined it, so all
03393       // the info is available anywhere. So it's a good idea to
03394       // update the current IR object holder now. This will
03395       // consume the objref pointer.
03396       this->ir_current_ =
03397         CORBA::IDLType::_duplicate (new_def.in ());
03398 
03399       CORBA::Container_ptr used_scope =
03400         CORBA::Container::_nil ();
03401 
03402       // Pop the new IR object back off the scope stack.
03403       if (be_global->ifr_scopes ().pop (used_scope) != 0)
03404         {
03405           ACE_ERROR_RETURN ((
03406               LM_ERROR,
03407               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03408               ACE_TEXT ("create_home_def -")
03409               ACE_TEXT (" scope pop failed\n")
03410             ),
03411             -1
03412           );
03413         }
03414     }
03415   else
03416     {
03417       ACE_ERROR_RETURN ((
03418           LM_ERROR,
03419           ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_home_def -")
03420           ACE_TEXT (" scope stack is empty\n")
03421         ),
03422         -1
03423       );
03424     }
03425 
03426   return 0;
03427 }
03428 
03429 int
03430 ifr_adding_visitor::create_event_def (AST_EventType *node
03431                                       ACE_ENV_ARG_DECL)
03432 {
03433   CORBA::Container_ptr current_scope =
03434     CORBA::Container::_nil ();
03435 
03436   if (be_global->ifr_scopes ().top (current_scope) == 0)
03437     {
03438       CORBA::ValueDef_var base_value;
03439       this->fill_base_value (base_value.out (),
03440                              node
03441                              ACE_ENV_ARG_PARAMETER);
03442       ACE_CHECK_RETURN (-1);
03443 
03444       CORBA::ValueDefSeq abstract_base_values;
03445       this->fill_abstract_base_values (abstract_base_values,
03446                                        node
03447                                        ACE_ENV_ARG_PARAMETER);
03448       ACE_CHECK_RETURN (-1);
03449 
03450       CORBA::InterfaceDefSeq supported_interfaces;
03451       this->fill_supported_interfaces (supported_interfaces,
03452                                        node
03453                                        ACE_ENV_ARG_PARAMETER);
03454       ACE_CHECK_RETURN (-1);
03455 
03456       CORBA::ExtInitializerSeq initializers;
03457       this->fill_initializers (initializers,
03458                                node
03459                                ACE_ENV_ARG_PARAMETER);
03460       ACE_CHECK_RETURN (-1);
03461 
03462       CORBA::ComponentIR::Container_var ccm_scope =
03463         CORBA::ComponentIR::Container::_narrow (current_scope
03464                                                 ACE_ENV_ARG_PARAMETER);
03465       ACE_CHECK_RETURN (-1);
03466 
03467       CORBA::ExtValueDef_var new_def =
03468         ccm_scope->create_event (
03469                        node->repoID (),
03470                        node->local_name ()->get_string (),
03471                        node->version (),
03472                        static_cast<CORBA::Boolean> (node->custom ()),
03473                        static_cast<CORBA::Boolean> (node->is_abstract ()),
03474                        base_value.in (),
03475                        static_cast<CORBA::Boolean> (node->truncatable ()),
03476                        abstract_base_values,
03477                        supported_interfaces,
03478                        initializers
03479                        ACE_ENV_ARG_PARAMETER
03480                      );
03481       ACE_CHECK_RETURN (-1);
03482 
03483       node->ifr_added (1);
03484 
03485       // Push the new IR object onto the scope stack.
03486       CORBA::Container_var new_scope =
03487         CORBA::Container::_narrow (new_def.in ()
03488                                    ACE_ENV_ARG_PARAMETER);
03489       ACE_CHECK_RETURN (-1);
03490 
03491       if (be_global->ifr_scopes ().push (new_scope.in ()) != 0)
03492         {
03493           ACE_ERROR_RETURN ((
03494               LM_ERROR,
03495               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03496               ACE_TEXT ("create_event_def -")
03497               ACE_TEXT (" scope push failed\n")
03498             ),
03499             -1
03500           );
03501         }
03502 
03503       // Visit the members, if any.
03504       if (this->visit_scope (node) == -1)
03505         {
03506           ACE_ERROR_RETURN ((
03507               LM_ERROR,
03508               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03509               ACE_TEXT ("create_event_def -")
03510               ACE_TEXT (" visit_scope failed\n")
03511             ),
03512             -1
03513           );
03514         }
03515 
03516       // This spot in the AST doesn't necessarily have to be the
03517       // interface definition - it could be any reference to it.
03518       // The front end will already have fully defined it, so all
03519       // the info is available anywhere. So it's a good idea to
03520       // update the current IR object holder now. This will
03521       // consume the objref pointer.
03522       this->ir_current_ =
03523         CORBA::IDLType::_duplicate (new_def.in ());
03524 
03525       CORBA::Container_ptr used_scope =
03526         CORBA::Container::_nil ();
03527 
03528       // Pop the new IR object back off the scope stack.
03529       if (be_global->ifr_scopes ().pop (used_scope) != 0)
03530         {
03531           ACE_ERROR_RETURN ((
03532               LM_ERROR,
03533               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03534               ACE_TEXT ("create_event_def -")
03535               ACE_TEXT (" scope pop failed\n")
03536             ),
03537             -1
03538           );
03539         }
03540     }
03541   else
03542     {
03543       ACE_ERROR_RETURN ((
03544           LM_ERROR,
03545           ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_event_def -")
03546           ACE_TEXT (" scope stack is empty\n")
03547         ),
03548         -1
03549       );
03550     }
03551 
03552   return 0;
03553 }
03554 
03555 int
03556 ifr_adding_visitor::create_value_member (AST_Field *node)
03557 {
03558   ACE_TRY_NEW_ENV
03559     {
03560       AST_Type *bt = node->field_type ();
03561       AST_Decl::NodeType nt = bt->node_type ();
03562 
03563       // We can't use lookup_id() on these, because
03564       // they don't inherit from Contained.
03565       if (nt == AST_Decl::NT_pre_defined
03566           || nt == AST_Decl::NT_string
03567           || nt == AST_Decl::NT_wstring
03568           || nt == AST_Decl::NT_array
03569           || nt == AST_Decl::NT_sequence)
03570         {
03571           /// This will put the repo entry into ir_current_.
03572           if (bt->ast_accept (this) != 0)
03573             {
03574               ACE_ERROR_RETURN ((
03575                   LM_ERROR,
03576                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03577                   ACE_TEXT ("create_value_member -")
03578                   ACE_TEXT (" visit base type failed\n")
03579                 ),
03580                 -1
03581               );
03582             }
03583         }
03584       else
03585         {
03586           // If the IDL is legal, this will succeed.
03587           CORBA::Contained_var holder =
03588                 be_global->repository ()->lookup_id (bt->repoID ()
03589                                                      ACE_ENV_ARG_PARAMETER);
03590           ACE_CHECK_RETURN (-1);
03591 
03592           this->ir_current_ =
03593             CORBA::IDLType::_narrow (holder.in ()
03594                                      ACE_ENV_ARG_PARAMETER);
03595           ACE_CHECK_RETURN (-1);
03596         }
03597 
03598       CORBA::Visibility vis = CORBA::PUBLIC_MEMBER;
03599 
03600       switch (node->visibility ())
03601         {
03602           case AST_Field::vis_PUBLIC:
03603             break;
03604           case AST_Field::vis_PRIVATE:
03605             vis = CORBA::PRIVATE_MEMBER;
03606             break;
03607           default:
03608             ACE_ERROR_RETURN ((
03609                 LM_ERROR,
03610                 ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_value_member -")
03611                 ACE_TEXT (" bad visibility value in node\n")
03612               ),
03613               -1
03614             );
03615         };
03616 
03617       CORBA::Container_ptr current_scope = CORBA::Container::_nil ();
03618 
03619       if (be_global->ifr_scopes ().top (current_scope) != 0)
03620         {
03621           ACE_ERROR_RETURN ((
03622               LM_ERROR,
03623               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03624               ACE_TEXT ("create_value_member -")
03625               ACE_TEXT (" scope stack empty\n")
03626             ),
03627             -1
03628           );
03629         }
03630       ACE_TRY_CHECK;
03631 
03632       CORBA::ValueDef_var vt =
03633         CORBA::ValueDef::_narrow (current_scope
03634                                   ACE_ENV_ARG_PARAMETER);
03635       ACE_TRY_CHECK;
03636 
03637       CORBA::ValueMemberDef_var vm =
03638         vt->create_value_member (node->repoID (),
03639                                  node->local_name ()->get_string (),
03640                                  node->version (),
03641                                  this->ir_current_.in (),
03642                                  vis
03643                                  ACE_ENV_ARG_PARAMETER);
03644       ACE_TRY_CHECK;
03645     }
03646   ACE_CATCHANY
03647     {
03648       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
03649                            ACE_TEXT ("create_value_member"));
03650 
03651       return -1;
03652     }
03653   ACE_ENDTRY;
03654 
03655   return 0;
03656 }
03657 
03658 void
03659 ifr_adding_visitor::get_referenced_type (AST_Type *node
03660                                          ACE_ENV_ARG_DECL)
03661 {
03662   switch (node->node_type ())
03663   {
03664     // For anonymous types, a new IR object is be created each
03665     // time, so we just visit the node, which get the object and
03666     // updates ir_current_.
03667     case AST_Decl::NT_pre_defined:
03668     case AST_Decl::NT_string:
03669     case AST_Decl::NT_wstring:
03670     case AST_Decl::NT_array:
03671     case AST_Decl::NT_sequence:
03672       if (node->ast_accept (this) == -1)
03673         {
03674           ACE_ERROR ((
03675               LM_ERROR,
03676               ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03677               ACE_TEXT ("get_scope_member -")
03678               ACE_TEXT (" failed to accept visitor\n")
03679             ));
03680         }
03681 
03682       break;
03683     // For names types, we can just look up the entry and update
03684     // ir_current_.
03685     default:
03686       {
03687         CORBA::Contained_var prev_def =
03688           be_global->repository ()->lookup_id (node->repoID ()
03689                                                ACE_ENV_ARG_PARAMETER);
03690         ACE_CHECK;
03691 
03692         this->ir_current_ =
03693           CORBA::IDLType::_narrow (prev_def.in ()
03694                                   ACE_ENV_ARG_PARAMETER);
03695         ACE_CHECK;
03696         break;
03697       }
03698   }
03699 }
03700 
03701 void
03702 ifr_adding_visitor::fill_base_value (CORBA::ValueDef_ptr &result,
03703                                      AST_ValueType *node
03704                                      ACE_ENV_ARG_DECL)
03705 {
03706   result = CORBA::ValueDef::_nil ();
03707   AST_ValueType *base_value = node->inherits_concrete ();
03708 
03709   if (base_value == 0)
03710     {
03711       return;
03712     }
03713 
03714   CORBA::Contained_var holder =
03715     be_global->repository ()->lookup_id (
03716                                   base_value->repoID ()
03717                                   ACE_ENV_ARG_PARAMETER
03718                                 );
03719   ACE_CHECK;
03720 
03721   if (!CORBA::is_nil (holder.in ()))
03722     {
03723       result =
03724         CORBA::ValueDef::_narrow (holder.in ()
03725                                   ACE_ENV_ARG_PARAMETER);
03726     }
03727 }
03728 
03729 void
03730 ifr_adding_visitor::fill_base_component (
03731     CORBA::ComponentIR::ComponentDef_ptr &result,
03732     AST_Component *node
03733     ACE_ENV_ARG_DECL
03734   )
03735 {
03736   result = CORBA::ComponentIR::ComponentDef::_nil ();
03737   AST_Component *base_component = node->base_component ();
03738 
03739   if (base_component == 0)
03740     {
03741       return;
03742     }
03743 
03744   CORBA::Contained_var holder =
03745     be_global->repository ()->lookup_id (
03746                                   base_component->repoID ()
03747                                   ACE_ENV_ARG_PARAMETER
03748                                 );
03749   ACE_CHECK;
03750 
03751   if (!CORBA::is_nil (holder.in ()))
03752     {
03753       result =
03754         CORBA::ComponentIR::ComponentDef::_narrow (holder.in ()
03755                                                    ACE_ENV_ARG_PARAMETER);
03756     }
03757 }
03758 
03759 void
03760 ifr_adding_visitor::fill_base_home (CORBA::ComponentIR::HomeDef_ptr &result,
03761                                     AST_Home *node
03762                                     ACE_ENV_ARG_DECL)
03763 {
03764   result = CORBA::ComponentIR::HomeDef::_nil ();
03765   AST_Home *base_home = node->base_home ();
03766 
03767   if (base_home == 0)
03768     {
03769       return;
03770     }
03771 
03772   CORBA::Contained_var holder =
03773     be_global->repository ()->lookup_id (
03774                                   base_home->repoID ()
03775                                   ACE_ENV_ARG_PARAMETER
03776                                 );
03777   ACE_CHECK;
03778 
03779   if (!CORBA::is_nil (holder.in ()))
03780     {
03781       result =
03782         CORBA::ComponentIR::HomeDef::_narrow (holder.in ()
03783                                               ACE_ENV_ARG_PARAMETER);
03784     }
03785   else
03786     {
03787       /// Maybe the base home is in an included IDL file - put it in
03788       /// the repository and go again.
03789       (void) base_home->ast_accept (this);
03790       this->fill_base_home (result,
03791                             node
03792                             ACE_ENV_ARG_PARAMETER);
03793     }
03794 }
03795 
03796 void
03797 ifr_adding_visitor::fill_managed_component (
03798     CORBA::ComponentIR::ComponentDef_ptr &result,
03799     AST_Home *node
03800     ACE_ENV_ARG_DECL
03801   )
03802 {
03803   result = CORBA::ComponentIR::ComponentDef::_nil ();
03804   AST_Component *managed_component = node->managed_component ();
03805 
03806   if (managed_component == 0)
03807     {
03808       return;
03809     }
03810 
03811   CORBA::Contained_var holder =
03812     be_global->repository ()->lookup_id (managed_component->repoID ()
03813                                          ACE_ENV_ARG_PARAMETER);
03814   ACE_CHECK;
03815 
03816   if (!CORBA::is_nil (holder.in ()))
03817     {
03818       result =
03819         CORBA::ComponentIR::ComponentDef::_narrow (holder.in ()
03820                                                    ACE_ENV_ARG_PARAMETER);
03821     }
03822   else
03823     {
03824       /// Maybe the managed component is in an included IDL file - put it in
03825       /// the repository and go again.
03826       (void) managed_component->ast_accept (this);
03827       this->fill_managed_component (result,
03828                                     node
03829                                     ACE_ENV_ARG_PARAMETER);
03830     }
03831 }
03832 
03833 void
03834 ifr_adding_visitor::fill_primary_key (CORBA::ValueDef_ptr &result,
03835                                       AST_Home *node
03836                                       ACE_ENV_ARG_DECL)
03837 {
03838   result = CORBA::ValueDef::_nil ();
03839   AST_ValueType *primary_key = node->primary_key ();
03840 
03841   if (primary_key == 0)
03842     {
03843       return;
03844     }
03845 
03846   CORBA::Contained_var holder =
03847     be_global->repository ()->lookup_id (primary_key->repoID ()
03848                                          ACE_ENV_ARG_PARAMETER);
03849   ACE_CHECK;
03850 
03851   if (!CORBA::is_nil (holder.in ()))
03852     {
03853       result =
03854         CORBA::ValueDef::_narrow (holder.in ()
03855                                   ACE_ENV_ARG_PARAMETER);
03856     }
03857   else
03858     {
03859       /// Maybe the primary key is in an included IDL file - put it in
03860       /// the repository and go again.
03861       (void) primary_key->ast_accept (this);
03862       this->fill_primary_key (result,
03863                               node
03864                               ACE_ENV_ARG_PARAMETER);
03865     }
03866 }
03867 
03868 void
03869 ifr_adding_visitor::fill_abstract_base_values (CORBA::ValueDefSeq &result,
03870                                                AST_ValueType *node
03871                                                ACE_ENV_ARG_DECL)
03872 {
03873   CORBA::Long s_length = node->n_inherits ();
03874   result.length (0);
03875 
03876   // Not sure if this could be negative in some default case or
03877   // not. If it's 0, we should make the call anyway to clear
03878   // existing entries, if any,  from the repository.
03879   if (s_length > 0)
03880     {
03881       AST_Interface **list = node->inherits ();
03882       CORBA::ULong u_length = static_cast<CORBA::ULong> (s_length);
03883       bool first_abs = list[0]->is_abstract ();
03884       result.length (first_abs ? u_length : u_length - 1);
03885 
03886       for (CORBA::ULong i = 0; i < u_length; ++i)
03887         {
03888           if (i == 0 && ! first_abs)
03889             {
03890               continue;
03891             }
03892 
03893           // Get list[i] into ir_current_.
03894           (void) list[i]->ast_accept (this);
03895 
03896           result[first_abs ? i : i - 1] =
03897             CORBA::ValueDef::_narrow (this->ir_current_.in ()
03898                                       ACE_ENV_ARG_PARAMETER);
03899           ACE_CHECK;
03900         }
03901     }
03902 }
03903 
03904 void
03905 ifr_adding_visitor::fill_inherited_interfaces (CORBA::InterfaceDefSeq &result,
03906                                                AST_Interface *node
03907                                                ACE_ENV_ARG_DECL)
03908 {
03909   result.length (0);
03910   this->fill_interfaces (result,
03911                          node->inherits (),
03912                          node->n_inherits ()
03913                          ACE_ENV_ARG_PARAMETER);
03914 }
03915 
03916 void
03917 ifr_adding_visitor::fill_supported_interfaces (CORBA::InterfaceDefSeq &result,
03918                                                AST_Interface *node
03919                                                ACE_ENV_ARG_DECL)
03920 {
03921   result.length (0);
03922   CORBA::Long s_length = 0;
03923   AST_Interface **list = 0;
03924 
03925   switch (node->node_type ())
03926     {
03927       case AST_Decl::NT_valuetype:
03928       case AST_Decl::NT_eventtype:
03929         {
03930           AST_ValueType *v = AST_ValueType::narrow_from_decl (node);
03931           s_length = v->n_supports ();
03932           list = v->supports ();
03933           break;
03934         }
03935       case AST_Decl::NT_component:
03936         {
03937           AST_Component *c = AST_Component::narrow_from_decl (node);
03938           s_length = c->n_supports ();
03939           list = c->supports ();
03940           break;
03941         }
03942       case AST_Decl::NT_home:
03943         {
03944           AST_Home *h = AST_Home::narrow_from_decl (node);
03945           s_length = h->n_supports ();
03946           list = h->supports ();
03947           break;
03948         }
03949       default:
03950         return;
03951     }
03952 
03953   this->fill_interfaces (result,
03954                          list,
03955                          s_length
03956                          ACE_ENV_ARG_PARAMETER);
03957 }
03958 
03959 void
03960 ifr_adding_visitor::fill_interfaces (CORBA::InterfaceDefSeq &result,
03961                                      AST_Interface **list,
03962                                      CORBA::Long length
03963                                      ACE_ENV_ARG_DECL)
03964 {
03965   // Not sure if this could be negative in some default case or
03966   // not. If it's 0, we should make the call anyway to clear
03967   // existing entries, if any,  from the repository.
03968   if (length > 0)
03969     {
03970       CORBA::ULong u_length = static_cast<CORBA::ULong> (length);
03971       result.length (u_length);
03972 
03973       for (CORBA::ULong i = 0; i < u_length; ++i)
03974         {
03975           // Get list[i] into ir_current_.
03976           (void) list[i]->ast_accept (this);
03977 
03978           result[i] =
03979             CORBA::InterfaceDef::_narrow (this->ir_current_.in ()
03980                                           ACE_ENV_ARG_PARAMETER);
03981           ACE_CHECK;
03982         }
03983     }
03984 }
03985 
03986 void
03987 ifr_adding_visitor::fill_initializers (CORBA::ExtInitializerSeq &result,
03988                                        AST_ValueType *node
03989                                        ACE_ENV_ARG_DECL_NOT_USED)
03990 {
03991   result.length (0);
03992   AST_Decl *item = 0;
03993   ACE_Vector<AST_Factory *> factories;
03994 
03995   for (UTL_ScopeActiveIterator v_iter (node,
03996                                        UTL_Scope::IK_decls);
03997        !v_iter.is_done ();
03998        v_iter.next ())
03999     {
04000       item = v_iter.item ();
04001 
04002       if (item->node_type () == AST_Decl::NT_factory)
04003         {
04004           factories.push_back (AST_Factory::narrow_from_decl (item));
04005         }
04006     }
04007 
04008   CORBA::ULong n_factories = factories.size ();
04009 
04010   if (n_factories == 0)
04011     {
04012       return;
04013     }
04014 
04015   result.length (n_factories);
04016   CORBA::ULong n_args = 0;
04017   AST_Argument *arg = 0;
04018   CORBA::ULong index = 0;
04019   AST_Exception *excp = 0;
04020   CORBA::Contained_var holder;
04021 
04022   for (CORBA::ULong i = 0; i < n_factories; ++i)
04023     {
04024       result[i].name =
04025         CORBA::string_dup (factories[i]->local_name ()->get_string ());
04026       n_args = static_cast<CORBA::ULong> (factories[i]->argument_count ());
04027       result[i].members.length (n_args);
04028 
04029       // The factory should have nothing in its scope but args.
04030       for (UTL_ScopeActiveIterator f_iter (factories[i],
04031                                            UTL_Scope::IK_decls);
04032            !f_iter.is_done ();
04033            f_iter.next (), ++index)
04034         {
04035           arg = AST_Argument::narrow_from_decl (f_iter.item ());
04036           result[i].members[index].name =
04037             CORBA::string_dup (arg->local_name ()->get_string ());
04038           result[i].members[index].type =
04039             CORBA::TypeCode::_duplicate (CORBA::_tc_void);
04040 
04041           /// This will put the field type in ir_current_, and also add it
04042           /// to the repository if it's not already there.
04043           if (arg->field_type ()->ast_accept (this) != 0)
04044             {
04045               ACE_ERROR ((
04046                   LM_ERROR,
04047                   ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
04048                   ACE_TEXT ("fill_initializers -")
04049                   ACE_TEXT (" failed to accept arg type visitor\n")
04050                 ));
04051             }
04052 
04053           result[i].members[index].type_def =
04054             CORBA::IDLType::_duplicate (this->ir_current_.in ());
04055         }
04056 
04057       CORBA::ULong n_exceptions =
04058         static_cast<CORBA::ULong> (factories[i]->n_exceptions ());
04059       result[i].exceptions.length (n_exceptions);
04060       index = 0;
04061 
04062       for (UTL_ExceptlistActiveIterator ei (factories[i]->exceptions ());
04063            !ei.is_done ();
04064            ei.next ())
04065         {
04066           excp = AST_Exception::narrow_from_decl (ei.item ());
04067           result[i].exceptions[index].name =
04068             CORBA::string_dup (excp->local_name ()->get_string ());
04069           result[i].exceptions[index].id = excp->repoID ();
04070           result[i].exceptions[index].defined_in =
04071             ScopeAsDecl (excp->defined_in ())->repoID ();
04072           result[i].exceptions[index].version = excp->version ();
04073           result[i].exceptions[index++].type =
04074             CORBA::TypeCode::_duplicate (CORBA::_tc_void);
04075         }
04076     }
04077 }
04078 
04079 void
04080 ifr_adding_visitor::fill_get_exceptions (CORBA::ExceptionDefSeq &result,
04081                                          AST_Attribute *node
04082                                          ACE_ENV_ARG_DECL)
04083 {
04084   this->fill_exceptions (result,
04085                          node->get_get_exceptions ()
04086                          ACE_ENV_ARG_PARAMETER);
04087 }
04088 
04089 void
04090 ifr_adding_visitor::fill_set_exceptions (CORBA::ExceptionDefSeq &result,
04091                                          AST_Attribute *node
04092                                          ACE_ENV_ARG_DECL)
04093 {
04094   this->fill_exceptions (result,
04095                          node->get_set_exceptions ()
04096                          ACE_ENV_ARG_PARAMETER);
04097 }
04098 
04099 void
04100 ifr_adding_visitor::fill_exceptions (CORBA::ExceptionDefSeq &result,
04101                                      AST_Decl *node
04102                                      ACE_ENV_ARG_DECL)
04103 {
04104   switch (node->node_type ())
04105     {
04106       case AST_Decl::NT_op:
04107         {
04108           AST_Operation *op = AST_Operation::narrow_from_decl (node);
04109           this->fill_exceptions (result,
04110                                  op->exceptions ()
04111                                  ACE_ENV_ARG_PARAMETER);
04112           return;
04113         }
04114       case AST_Decl::NT_factory:
04115         {
04116           AST_Factory *f = AST_Factory::narrow_from_decl (node);
04117           this->fill_exceptions (result,
04118                                  f->exceptions ()
04119                                  ACE_ENV_ARG_PARAMETER);
04120           return;
04121         }
04122       default:
04123         result.length (0);
04124         return;
04125     }
04126 }
04127 
04128 void
04129 ifr_adding_visitor::fill_exceptions (CORBA::ExceptionDefSeq &result,
04130                                      UTL_ExceptList *list
04131                                      ACE_ENV_ARG_DECL)
04132 {
04133   if (list == 0)
04134     {
04135       result.length (0);
04136       return;
04137     }
04138 
04139   result.length (static_cast<CORBA::ULong> (list->length ()));
04140   CORBA::ULong index = 0;
04141   AST_Decl *d = 0;
04142   CORBA::Contained_var holder;
04143 
04144   for (UTL_ExceptlistActiveIterator ei (list);
04145        !ei.is_done ();
04146        ei.next (), ++index)
04147     {
04148       d = ei.item ();
04149 
04150       // Just to make sure. The call will return quickly if d has already
04151       // been visited. Can't use ir_current_ because ExceptionDef doesn't
04152       // inherit from IDLType.
04153       (void) d->ast_accept (this);
04154 
04155       holder = be_global->repository ()->lookup_id (d->repoID ()
04156                                                     ACE_ENV_ARG_PARAMETER);
04157       ACE_CHECK;
04158 
04159       result[index] =
04160         CORBA::ExceptionDef::_narrow (holder.in ()
04161                                       ACE_ENV_ARG_PARAMETER);
04162       ACE_CHECK;
04163     }
04164 }
04165 
04166 void
04167 ifr_adding_visitor::fill_params (CORBA::ParDescriptionSeq &result,
04168                                  AST_Operation *node
04169                                  ACE_ENV_ARG_DECL)
04170 {
04171   AST_Argument *arg = 0;
04172   CORBA::ULong n_args = static_cast<CORBA::ULong> (node->argument_count ());
04173   result.length (n_args);
04174   CORBA::ULong index = 0;
04175   CORBA::Contained_var holder;
04176 
04177   for (UTL_ScopeActiveIterator iter (node,
04178                                      UTL_Scope::IK_decls);
04179        ! iter.is_done ();
04180        iter.next (), ++index)
04181     {
04182       arg = AST_Argument::narrow_from_decl (iter.item ());
04183       result[index].name =
04184         CORBA::string_dup (arg->local_name ()->get_string ());
04185       result[index].type = CORBA::TypeCode::_duplicate (CORBA::_tc_void);
04186 
04187       // Get the arg type into ir_current_.
04188       (void) arg->ast_accept (this);
04189 
04190       result[index].type_def =
04191         CORBA::IDLType::_duplicate (this->ir_current_.in ());
04192       ACE_CHECK;
04193 
04194       result[index].mode = CORBA::PARAM_IN;
04195     }
04196 }
04197 
04198 void
04199 ifr_adding_visitor::visit_all_provides (AST_Component *node,
04200                                         CORBA::ComponentIR::ComponentDef_ptr c
04201                                         ACE_ENV_ARG_DECL)
04202 {
04203   AST_Component::port_description *tmp = 0;
04204   CORBA::Contained_var contained;
04205   CORBA::InterfaceDef_var interface_type;
04206   CORBA::ComponentIR::ProvidesDef_var new_def;
04207   char *local_name = 0;
04208 
04209   for (ACE_Unbounded_Queue_Iterator<AST_Component::port_description> i (
04210            node->provides ()
04211          );
04212        ! i.done ();
04213        i.advance ())
04214     {
04215       i.next (tmp);
04216       contained = be_global->repository ()->lookup_id (tmp->impl->repoID ()
04217                                                        ACE_ENV_ARG_PARAMETER);
04218       ACE_CHECK;
04219 
04220       interface_type = CORBA::InterfaceDef::_narrow (contained.in ()
04221                                                      ACE_ENV_ARG_PARAMETER);
04222       ACE_CHECK;
04223 
04224       ACE_CString str (node->repoID ());
04225       local_name = tmp->id->get_string ();
04226       this->expand_id (str, local_name);
04227       new_def = c->create_provides (str.fast_rep (),
04228                                     local_name,
04229                                     tmp->impl->version (),
04230                                     interface_type.in ()
04231                                     ACE_ENV_ARG_PARAMETER);
04232       ACE_CHECK;
04233     }
04234 }
04235 
04236 void
04237 ifr_adding_visitor::visit_all_uses (AST_Component *node,
04238                                     CORBA::ComponentIR::ComponentDef_ptr c
04239                                     ACE_ENV_ARG_DECL)
04240 {
04241   AST_Component::port_description *tmp = 0;
04242   CORBA::Contained_var contained;
04243   CORBA::InterfaceDef_var interface_type;
04244   CORBA::ComponentIR::UsesDef_var new_def;
04245   char *local_name = 0;
04246 
04247   for (ACE_Unbounded_Queue_Iterator<AST_Component::port_description> i (
04248            node->uses ()
04249          );
04250        ! i.done ();
04251        i.advance ())
04252     {
04253       i.next (tmp);
04254       contained = be_global->repository ()->lookup_id (tmp->impl->repoID ()
04255                                                        ACE_ENV_ARG_PARAMETER);
04256       ACE_CHECK;
04257 
04258       interface_type = CORBA::InterfaceDef::_narrow (contained.in ()
04259                                                      ACE_ENV_ARG_PARAMETER);
04260       ACE_CHECK;
04261 
04262       ACE_CString str (node->repoID ());
04263       local_name = tmp->id->get_string ();
04264       this->expand_id (str, local_name);
04265       new_def = c->create_uses (str.fast_rep (),
04266                                 local_name,
04267                                 tmp->impl->version (),
04268                                 interface_type.in (),
04269                                 static_cast<CORBA::Boolean> (tmp->is_multiple)
04270                                 ACE_ENV_ARG_PARAMETER);
04271       ACE_CHECK;
04272     }
04273 }
04274 
04275 void
04276 ifr_adding_visitor::visit_all_emits (AST_Component *node,
04277                                      CORBA::ComponentIR::ComponentDef_ptr c
04278                                      ACE_ENV_ARG_DECL)
04279 {
04280   AST_Component::port_description *tmp = 0;
04281   CORBA::Contained_var contained;
04282   CORBA::ComponentIR::EventDef_var event_type;
04283   CORBA::ComponentIR::EmitsDef_var new_def;
04284   char *local_name = 0;
04285 
04286   for (ACE_Unbounded_Queue_Iterator<AST_Component::port_description> i (
04287            node->emits ()
04288          );
04289        ! i.done ();
04290        i.advance ())
04291     {
04292       i.next (tmp);
04293       contained = be_global->repository ()->lookup_id (tmp->impl->repoID ()
04294                                                        ACE_ENV_ARG_PARAMETER);
04295       ACE_CHECK;
04296 
04297       event_type =
04298         CORBA::ComponentIR::EventDef::_narrow (contained.in ()
04299                                                ACE_ENV_ARG_PARAMETER);
04300       ACE_CHECK;
04301 
04302       ACE_CString str (node->repoID ());
04303       local_name = tmp->id->get_string ();
04304       this->expand_id (str, local_name);
04305       new_def = c->create_emits (str.fast_rep (),
04306                                  local_name,
04307                                  tmp->impl->version (),
04308                                  event_type.in ()
04309                                  ACE_ENV_ARG_PARAMETER);
04310       ACE_CHECK;
04311     }
04312 }
04313 
04314 void
04315 ifr_adding_visitor::visit_all_publishes (AST_Component *node,
04316                                          CORBA::ComponentIR::ComponentDef_ptr c
04317                                          ACE_ENV_ARG_DECL)
04318 {
04319   AST_Component::port_description *tmp = 0;
04320   CORBA::Contained_var contained;
04321   CORBA::ComponentIR::EventDef_var event_type;
04322   CORBA::ComponentIR::PublishesDef_var new_def;
04323   char *local_name = 0;
04324 
04325   for (ACE_Unbounded_Queue_Iterator<AST_Component::port_description> i (
04326            node->publishes ()
04327          );
04328        ! i.done ();
04329        i.advance ())
04330     {
04331       i.next (tmp);
04332       contained = be_global->repository ()->lookup_id (tmp->impl->repoID ()
04333                                                        ACE_ENV_ARG_PARAMETER);
04334       ACE_CHECK;
04335 
04336       event_type =
04337         CORBA::ComponentIR::EventDef::_narrow (contained.in ()
04338                                                ACE_ENV_ARG_PARAMETER);
04339       ACE_CHECK;
04340 
04341       ACE_CString str (node->repoID ());
04342       local_name = tmp->id->get_string ();
04343       this->expand_id (str, local_name);
04344       new_def = c->create_publishes (str.fast_rep (),
04345                                      local_name,
04346                                      tmp->impl->version (),
04347                                      event_type.in ()
04348                                      ACE_ENV_ARG_PARAMETER);
04349       ACE_CHECK;
04350     }
04351 }
04352 
04353 void
04354 ifr_adding_visitor::visit_all_consumes (AST_Component *node,
04355                                         CORBA::ComponentIR::ComponentDef_ptr c
04356                                         ACE_ENV_ARG_DECL)
04357 {
04358   AST_Component::port_description *tmp = 0;
04359   CORBA::Contained_var contained;
04360   CORBA::ComponentIR::EventDef_var event_type;
04361   CORBA::ComponentIR::ConsumesDef_var new_def;
04362   char *local_name = 0;
04363 
04364   for (ACE_Unbounded_Queue_Iterator<AST_Component::port_description> i (
04365            node->consumes ()
04366          );
04367        ! i.done ();
04368        i.advance ())
04369     {
04370       i.next (tmp);
04371       contained = be_global->repository ()->lookup_id (tmp->impl->repoID ()
04372                                                        ACE_ENV_ARG_PARAMETER);
04373       ACE_CHECK;
04374 
04375       event_type =
04376         CORBA::ComponentIR::EventDef::_narrow (contained.in ()
04377                                                ACE_ENV_ARG_PARAMETER);
04378       ACE_CHECK;
04379 
04380       ACE_CString str (node->repoID ());
04381       local_name = tmp->id->get_string ();
04382       this->expand_id (str, local_name);
04383       new_def = c->create_consumes (str.fast_rep (),
04384                                     local_name,
04385                                     tmp->impl->version (),
04386                                     event_type.in ()
04387                                     ACE_ENV_ARG_PARAMETER);
04388       ACE_CHECK;
04389     }
04390 }
04391 
04392 void
04393 ifr_adding_visitor::visit_all_factories (AST_Home *node,
04394                                          CORBA::ComponentIR::HomeDef_ptr h
04395                                          ACE_ENV_ARG_DECL)
04396 {
04397   AST_Operation **tmp = 0;
04398   CORBA::Contained_var contained;
04399   CORBA::ComponentIR::FactoryDef_var new_def;
04400 
04401   for (ACE_Unbounded_Queue_Iterator<AST_Operation *> i (node->factories ());
04402        ! i.done ();
04403        i.advance ())
04404     {
04405       i.next (tmp);
04406       CORBA::ParDescriptionSeq params;
04407       this->fill_params (params,
04408                          *tmp
04409                          ACE_ENV_ARG_PARAMETER);
04410       ACE_CHECK;
04411 
04412       CORBA::ExceptionDefSeq exceptions;
04413       this->fill_exceptions (exceptions,
04414                              *tmp
04415                              ACE_ENV_ARG_PARAMETER);
04416       ACE_CHECK;
04417 
04418       new_def = h->create_factory ((*tmp)->repoID (),
04419                                    (*tmp)->local_name ()->get_string (),
04420                                    (*tmp)->version (),
04421                                    params,
04422                                    exceptions
04423                                    ACE_ENV_ARG_PARAMETER);
04424       ACE_CHECK;
04425     }
04426 }
04427 
04428 void
04429 ifr_adding_visitor::visit_all_finders (AST_Home *node,
04430                                        CORBA::ComponentIR::HomeDef_ptr h
04431                                        ACE_ENV_ARG_DECL)
04432 {
04433   AST_Operation **tmp = 0;
04434   CORBA::Contained_var contained;
04435   CORBA::ComponentIR::FinderDef_var new_def;
04436 
04437   for (ACE_Unbounded_Queue_Iterator<AST_Operation *> i (node->finders ());
04438        ! i.done ();
04439        i.advance ())
04440     {
04441       i.next (tmp);
04442       CORBA::ParDescriptionSeq params;
04443       this->fill_params (params,
04444                          *tmp
04445                          ACE_ENV_ARG_PARAMETER);
04446       ACE_CHECK;
04447 
04448       CORBA::ExceptionDefSeq exceptions;
04449       this->fill_exceptions (exceptions,
04450                              *tmp
04451                              ACE_ENV_ARG_PARAMETER);
04452       ACE_CHECK;
04453 
04454       new_def = h->create_finder ((*tmp)->repoID (),
04455                                   (*tmp)->local_name ()->get_string (),
04456                                   (*tmp)->version (),
04457                                   params,
04458                                   exceptions
04459                                   ACE_ENV_ARG_PARAMETER);
04460       ACE_CHECK;
04461     }
04462 }
04463 
04464 void
04465 ifr_adding_visitor::expand_id (ACE_CString &str,
04466                                const char *local_name)
04467 {
04468   ssize_t pos = str.rfind (':');
04469   str = str.substr (0, pos) + '/' + local_name + str.substr (pos);
04470 }

Generated on Thu Nov 9 14:11:50 2006 for TAO_IFR by doxygen 1.3.6