void TAO_StructDef_i::members_i (const CORBA::StructMemberSeq &members) { // Destroy our old refs. TAO_Container_i::destroy_references_i (); CORBA::ULong count = members.length (); ACE_TString section_name; ACE_Configuration_Section_Key refs_key; this->repo_->config ()->open_section (this->section_key_, "refs", 1, refs_key); char *path = 0; // Create a section for each new member. We just store the // member name and the path to its database entry. for (CORBA::ULong i = 0; i < count; ++i) { ACE_Configuration_Section_Key member_key; char *stringified = TAO_IFR_Service_Utils::int_to_string (i); this->repo_->config ()->open_section (refs_key, stringified, 1, member_key); this->repo_->config ()->set_string_value (member_key, "name", members[i].name.in ()); path = TAO_IFR_Service_Utils::reference_to_path (members[i].type_def.in ()); this->repo_->config ()->set_string_value (member_key, "path", path); } this->repo_->config ()->set_integer_value (refs_key, "count", count); }
int ifr_adding_visitor_structure::visit_structure (AST_Structure *node) { try { CORBA::StructDef_var struct_def; CORBA::Contained_var prev_def = be_global->repository ()->lookup_id (node->repoID ()); if (CORBA::is_nil (prev_def.in ())) { CORBA::StructDef_var struct_def; CORBA::StructMemberSeq dummyMembers; dummyMembers.length (0); CORBA::Container_ptr current_scope = CORBA::Container::_nil (); if (be_global->ifr_scopes ().top (current_scope) != 0) { ORBSVCS_ERROR_RETURN (( LM_ERROR, ACE_TEXT ("(%N:%l) ifr_adding_visitor_structure::") ACE_TEXT ("visit_structure -") ACE_TEXT (" scope stack is empty\n")), -1); } // First create the named structure without any members. struct_def = current_scope->create_struct ( node->repoID (), node->local_name ()->get_string (), node->version (), dummyMembers ); if (be_global->ifr_scopes ().push (struct_def.in ()) != 0) { ORBSVCS_ERROR_RETURN (( LM_ERROR, ACE_TEXT ("(%N:%l) ifr_adding_visitor_structure::") ACE_TEXT ("visit_structure -") ACE_TEXT (" scope push failed\n") ), -1 ); } // Then add the real structure members (which corrupts ir_current_). if (this->add_members (node, struct_def.in ()) == -1) { ORBSVCS_ERROR_RETURN (( LM_ERROR, ACE_TEXT ("(%N:%l) ifr_adding_visitor_structure::") ACE_TEXT ("visit_structure -") ACE_TEXT (" visit_scope failed\n")), -1); } this->ir_current_ = CORBA::IDLType::_narrow (struct_def.in ()); CORBA::Container_ptr used_scope = CORBA::Container::_nil (); // Pop the new IR object back off the scope stack. if (be_global->ifr_scopes ().pop (used_scope) != 0) { ORBSVCS_ERROR_RETURN (( LM_ERROR, ACE_TEXT ("(%N:%l) ifr_adding_visitor_structure::") ACE_TEXT ("visit_structure -") ACE_TEXT (" scope pop failed\n") ), -1 ); } } // if (CORBA::is_nil (...)) else { // We are seeing the full definition of a forward // declaration - just add the members so repo // entries referencing the UnionDef will stay valid. // Also we know node->ifr_fwd_added_ is true. struct_def = CORBA::StructDef::_narrow (prev_def.in ()); if (be_global->ifr_scopes ().push (struct_def.in ()) != 0) { ORBSVCS_ERROR_RETURN (( LM_ERROR, ACE_TEXT ("(%N:%l) ifr_adding_visitor_structure::") ACE_TEXT ("visit_structure -") ACE_TEXT (" scope push failed\n") ), -1 ); } if (this->add_members (node, struct_def.in ()) == -1) { ORBSVCS_ERROR_RETURN (( LM_ERROR, ACE_TEXT ("(%N:%l) ifr_adding_visitor_structure::") ACE_TEXT ("visit_structure -") ACE_TEXT (" visit_scope failed\n")), -1); } this->ir_current_ = CORBA::IDLType::_narrow (prev_def.in ()); CORBA::Container_ptr used_scope = CORBA::Container::_nil (); // Pop the new IR object back off the scope stack. if (be_global->ifr_scopes ().pop (used_scope) != 0) { ORBSVCS_ERROR_RETURN (( LM_ERROR, ACE_TEXT ("(%N:%l) ifr_adding_visitor_structure::") ACE_TEXT ("visit_structure -") ACE_TEXT (" scope pop failed\n") ), -1 ); } } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( ACE_TEXT ( "ifr_adding_visitor_structure::visit_structure")); return -1; } return 0; }
CORBA::StructMemberSeq * TAO_StructDef_i::members_i (void) { ACE_Unbounded_Queue<CORBA::DefinitionKind> kind_queue; ACE_Unbounded_Queue<ACE_TString> path_queue; ACE_Unbounded_Queue<ACE_TString> name_queue; ACE_Configuration_Section_Key refs_key; this->repo_->config ()->open_section (this->section_key_, "refs", 0, refs_key); u_int count = 0; this->repo_->config ()->get_integer_value (refs_key, "count", count); for (u_int i = 0; i < count; ++i) { ACE_Configuration_Section_Key member_key; char *stringified = TAO_IFR_Service_Utils::int_to_string (i); this->repo_->config ()->open_section (refs_key, stringified, 0, member_key); ACE_TString path; this->repo_->config ()->get_string_value (member_key, "path", path); ACE_Configuration_Section_Key entry_key; int status = this->repo_->config ()->expand_path (this->repo_->root_key (), path, entry_key, 0); // This entry may have been removed. if (status == 0) { path_queue.enqueue_tail (path); ACE_TString name; this->repo_->config ()->get_string_value (member_key, "name", name); name_queue.enqueue_tail (name); u_int kind = 0; this->repo_->config ()->get_integer_value (entry_key, "def_kind", kind); CORBA::DefinitionKind def_kind = static_cast<CORBA::DefinitionKind> (kind); kind_queue.enqueue_tail (def_kind); } } CORBA::ULong size = static_cast<CORBA::ULong> (kind_queue.size ()); CORBA::StructMemberSeq *members = 0; ACE_NEW_THROW_EX (members, CORBA::StructMemberSeq (size), CORBA::NO_MEMORY ()); members->length (size); CORBA::StructMemberSeq_var retval = members; ACE_TString name, path; CORBA::DefinitionKind kind = CORBA::dk_none; CORBA::Object_var obj; ACE_Configuration_Section_Key member_key; TAO_IDLType_i *impl = 0; // Store to replace below. ACE_Configuration_Section_Key key_holder = this->section_key_; for (CORBA::ULong k = 0; k < size; ++k) { name_queue.dequeue_head (name); retval[k].name = name.c_str (); kind_queue.dequeue_head (kind); path_queue.dequeue_head (path); obj = TAO_IFR_Service_Utils::create_objref (kind, path.c_str (), this->repo_); retval[k].type_def = CORBA::IDLType::_narrow (obj.in ()); this->repo_->config ()->expand_path (this->repo_->root_key (), path, member_key, 0); impl = TAO_IFR_Service_Utils::path_to_idltype (path, this->repo_); if (0 == impl) { throw CORBA::OBJECT_NOT_EXIST(); } retval[k].type = impl->type_i (); // If this struct contains a nested struct (of another type) at // some level, the above code will have changed the section key // so we have to replace it with the value we stored above. this->section_key (key_holder); } return retval._retn (); }
int ifr_adding_visitor_exception::visit_exception (AST_Exception *node) { try { CORBA::ExceptionDef_var new_def; CORBA::Contained_var prev_def = be_global->repository ()->lookup_id (node->repoID ()); if (CORBA::is_nil (prev_def.in ())) { CORBA::StructMemberSeq dummyMembers; dummyMembers.length (0); CORBA::Container_ptr current_scope = CORBA::Container::_nil (); if (be_global->ifr_scopes ().top (current_scope) != 0) { ORBSVCS_ERROR_RETURN (( LM_ERROR, ACE_TEXT ("(%N:%l) ifr_adding_visitor_exception::") ACE_TEXT ("visit_exception -") ACE_TEXT (" scope stack is empty\n") ), -1 ); } new_def = current_scope->create_exception (node->repoID (), node->local_name ()->get_string (), node->version (), dummyMembers); if (be_global->ifr_scopes ().push (new_def.in ()) != 0) { ORBSVCS_ERROR_RETURN (( LM_ERROR, ACE_TEXT ("(%N:%l) ifr_adding_visitor_exception::") ACE_TEXT ("visit_exception -") ACE_TEXT (" scope push failed\n") ), -1 ); } // Then add the real exception members. if (this->add_members (node, new_def.in ()) == -1) { ORBSVCS_ERROR_RETURN (( LM_ERROR, ACE_TEXT ("(%N:%l) ifr_adding_visitor_exception::") ACE_TEXT ("visit_exception -") ACE_TEXT (" visit_scope failed\n")), -1); } CORBA::Container_ptr used_scope = CORBA::Container::_nil (); // Pop the new IR object back off the scope stack. if (be_global->ifr_scopes ().pop (used_scope) != 0) { ORBSVCS_ERROR_RETURN (( LM_ERROR, ACE_TEXT ("(%N:%l) ifr_adding_visitor_exception::") ACE_TEXT ("visit_exception -") ACE_TEXT (" scope pop failed\n") ), -1 ); } } else { new_def = CORBA::ExceptionDef::_narrow (prev_def.in ()); if (be_global->ifr_scopes ().push (new_def.in ()) != 0) { ORBSVCS_ERROR_RETURN (( LM_ERROR, ACE_TEXT ("(%N:%l) ifr_adding_visitor_exception::") ACE_TEXT ("visit_exception -") ACE_TEXT (" scope push failed\n") ), -1 ); } // Then add the real exception members. if (this->add_members (node, new_def.in ()) == -1) { ORBSVCS_ERROR_RETURN (( LM_ERROR, ACE_TEXT ("(%N:%l) ifr_adding_visitor_exception::") ACE_TEXT ("visit_exception -") ACE_TEXT (" visit_scope failed\n")), -1); } CORBA::Container_ptr used_scope = CORBA::Container::_nil (); // Pop the new IR object back off the scope stack. if (be_global->ifr_scopes ().pop (used_scope) != 0) { ORBSVCS_ERROR_RETURN (( LM_ERROR, ACE_TEXT ("(%N:%l) ifr_adding_visitor_exception::") ACE_TEXT ("visit_exception -") ACE_TEXT (" scope pop failed\n") ), -1 ); } } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( ACE_TEXT ( "ifr_adding_visitor_exception::visit_exception")); return -1; } return 0; }