diff options
Diffstat (limited to 'TAO/orbsvcs/IFR_Service/ifr_adding_visitor.cpp')
-rw-r--r-- | TAO/orbsvcs/IFR_Service/ifr_adding_visitor.cpp | 195 |
1 files changed, 84 insertions, 111 deletions
diff --git a/TAO/orbsvcs/IFR_Service/ifr_adding_visitor.cpp b/TAO/orbsvcs/IFR_Service/ifr_adding_visitor.cpp index 7e004427229..c418fe74a16 100644 --- a/TAO/orbsvcs/IFR_Service/ifr_adding_visitor.cpp +++ b/TAO/orbsvcs/IFR_Service/ifr_adding_visitor.cpp @@ -190,14 +190,25 @@ ifr_adding_visitor::visit_module (AST_Module *node) prev_def->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; - if (kind == CORBA::dk_Module) + // If the line below is true, we are clobbering a previous + // entry from another IDL file. In that + // case we do what other ORB vendors do, and destroy the + // original entry, create the new one, and let the user beware. + if (kind != CORBA::dk_Module) + { + prev_def->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + // This call will take the brach where prev_def.in() is 0. + return this->visit_module (node); + } + else { // We are either in a reopened module, are processing an IDL // IDL file for the second time, or are in a module whose // name already exists by coincidence - there is no way to // tell the difference. So any members whose repository ID - // already exists in this case will throw BAD_PARAM - // when we attempt to add them to the repository. + // already exists in this case will be skipped. this->in_reopened_ = 1; new_def = @@ -577,60 +588,12 @@ ifr_adding_visitor::visit_interface_fwd (AST_InterfaceFwd *node) } int -ifr_adding_visitor::visit_valuebox (AST_ValueBox *node) +ifr_adding_visitor::visit_valuebox (AST_ValueBox *) { - if (node->imported () && !be_global->do_included_files ()) - { - return 0; - } - - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - this->element_type (node->boxed_type () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - CORBA::Container_ptr current_scope = - CORBA::Container::_nil (); - - if (be_global->ifr_scopes ().top (current_scope) == 0) - { - this->ir_current_ = - current_scope->create_value_box ( - node->repoID (), - node->local_name ()->get_string (), - node->version (), - this->ir_current_.in () - ACE_ENV_ARG_PARAMETER - ); - ACE_TRY_CHECK; - } - else - { - ACE_ERROR_RETURN (( - LM_ERROR, - ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_valuebox -") - ACE_TEXT (" scope stack is empty\n") - ), - -1 - ); - } - - node->ifr_added (1); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT ("visit_valuebox")); - - return -1; - } - ACE_ENDTRY; - return 0; } + int ifr_adding_visitor::visit_valuetype (AST_ValueType *node) { @@ -2429,37 +2392,70 @@ ifr_adding_visitor::visit_typedef (AST_Typedef *node) ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { - this->element_type (node->base_type () - ACE_ENV_ARG_PARAMETER); + // Is this typedef already in the respository? + CORBA::Contained_var prev_def = + be_global->repository ()->lookup_id (node->repoID () + ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - CORBA::Container_ptr current_scope = - CORBA::Container::_nil (); - - if (be_global->ifr_scopes ().top (current_scope) == 0) + // If not, create a new entry. + if (CORBA::is_nil (prev_def.in ())) { - this->ir_current_ = - current_scope->create_alias ( - node->repoID (), - node->local_name ()->get_string (), - node->version (), - this->ir_current_.in () - ACE_ENV_ARG_PARAMETER - ); + this->element_type (node->base_type () + ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; + + CORBA::Container_ptr current_scope = + CORBA::Container::_nil (); + + if (be_global->ifr_scopes ().top (current_scope) == 0) + { + this->ir_current_ = + current_scope->create_alias ( + node->repoID (), + node->local_name ()->get_string (), + node->version (), + this->ir_current_.in () + ACE_ENV_ARG_PARAMETER + ); + ACE_TRY_CHECK; + } + else + { + ACE_ERROR_RETURN (( + LM_ERROR, + ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_typedef -") + ACE_TEXT (" scope stack is empty\n") + ), + -1 + ); + } + + node->ifr_added (1); } else { - ACE_ERROR_RETURN (( - LM_ERROR, - ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_typedef -") - ACE_TEXT (" scope stack is empty\n") - ), - -1 - ); - } + // If the line below is true, we are clobbering a previous + // entry (from another IDL file) of another type. In that + // case we do what other ORB vendors do, and destroy the + // original entry, create the new one, and let the user beware. + // Unless we are in a module that has been seen before, in + // which case we might be just processing and IDL file a + // second time and we want to just update ir_current_. + if (node->ifr_added () == 0 && this->in_reopened_ == 0) + { + prev_def->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; - node->ifr_added (1); + // This call will take the other branch. + return this->visit_typedef (node); + } + + this->ir_current_ = + CORBA::TypedefDef::_narrow (prev_def.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } } ACE_CATCHANY { @@ -3558,41 +3554,18 @@ ifr_adding_visitor::create_value_member (AST_Field *node) ACE_TRY_NEW_ENV { AST_Type *bt = node->field_type (); - AST_Decl::NodeType nt = bt->node_type (); - - // We can't use lookup_id() on these, because - // they don't inherit from Contained. - if (nt == AST_Decl::NT_pre_defined - || nt == AST_Decl::NT_string - || nt == AST_Decl::NT_wstring - || nt == AST_Decl::NT_array - || nt == AST_Decl::NT_sequence) - { - /// This will put the repo entry into ir_current_. - if (bt->ast_accept (this) != 0) - { - ACE_ERROR_RETURN (( - LM_ERROR, - ACE_TEXT ("(%N:%l) ifr_adding_visitor::") - ACE_TEXT ("create_value_member -") - ACE_TEXT (" visit base type failed\n") - ), - -1 - ); - } - } - else - { - // If the IDL is legal, this will succeed. - CORBA::Contained_var holder = - be_global->repository ()->lookup_id (bt->repoID () - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - this->ir_current_ = - CORBA::IDLType::_narrow (holder.in () - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + /// This will put the repo entry into ir_current_ whether it exists + /// already or not. + if (bt->ast_accept (this) != 0) + { + ACE_ERROR_RETURN (( + LM_ERROR, + ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_value_member -") + ACE_TEXT (" visit base type failed\n") + ), + -1 + ); } CORBA::Visibility vis = CORBA::PUBLIC_MEMBER; @@ -3880,7 +3853,7 @@ ifr_adding_visitor::fill_abstract_base_values (CORBA::ValueDefSeq &result, { AST_Interface **list = node->inherits (); CORBA::ULong u_length = static_cast<CORBA::ULong> (s_length); - bool first_abs = list[0]->is_abstract (); + idl_bool first_abs = list[0]->is_abstract (); result.length (first_abs ? u_length : u_length - 1); for (CORBA::ULong i = 0; i < u_length; ++i) |