int be_visitor_ami_pre_proc::visit_interface (be_interface *node) { // We check for an imported node after generating the reply handler. if (node->is_local () || node->is_abstract ()) { return 0; } // The following 3 IF blocks are checks for CCM-related nodes, which // we want to skip until we get AMI integrated with CIAO. // Skip the *EventConsumer added for each eventtype. if (node->is_event_consumer ()) { return 0; } // Check for home equivalent interface. The lookup will find the // home itself, which was declared first. Identifier *node_lname = node->AST_Decl::local_name (); AST_Decl *first_stored = node->defined_in ()->lookup_by_name_local (node_lname, false); if (0 != first_stored && first_stored->node_type () == AST_Decl::NT_home) { return 0; } ACE_CString lname (node_lname->get_string ()); // Skip the *Explict and *Implicit interfaces added for a home. if (lname.substr (lname.length () - 6) == "plicit") { UTL_Scope *s = node->defined_in (); Identifier local_id (lname.substr (0, lname.length () - 8).c_str ()); AST_Decl *d = s->lookup_by_name_local (&local_id, false); local_id.destroy (); if (0 != d) { return 0; } } AST_Module *module = AST_Module::narrow_from_scope (node->defined_in ()); if (!module) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_ami_pre_proc::" "visit_interface - " "module is null\n"), -1); } be_interface *reply_handler = this->create_reply_handler (node); if (reply_handler) { reply_handler->set_defined_in (node->defined_in ()); // Insert the ami handler after the node, the // exception holder will be placed between these two later. module->be_add_interface (reply_handler, node); // Remember from whom we were cloned reply_handler->original_interface (node); // If this was created for an imported node, it will be wrong // unless we set it. reply_handler->set_imported (node->imported ()); } else { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_ami_pre_proc::" "visit_interface - " "creating the reply handler failed\n"), -1); } if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_ami_pre_proc::" "visit_interface - " "visit scope failed\n"), -1); } return 0; }
/* * Helper function for lookup_by_name. Iterates doing local lookups of * subsequent components of a scoped name */ static AST_Decl * iter_lookup_by_name_local(AST_Decl *d, UTL_ScopedName *e, idl_bool treat_as_ref) { Identifier *s; AST_Typedef *td; UTL_IdListActiveIterator *i; UTL_Scope *sc; i = new UTL_IdListActiveIterator(e); for (i->next(); !(i->is_done()); ) { s = i->item(); /* * Update iterator before loop. This is needed for the check for * typedef, since we only want to look at the base type if there * actually are more components of the name to resolve. */ i->next(); /* * Next component in name was not found */ if (d == NULL) { return NULL; } /* * If this is a typedef and we're not done, we should get the * base type to get the scope it defines (if any) */ if (!(i->is_done())) { while (d != NULL && d->node_type() == AST_Decl::NT_typedef) { td = AST_Typedef::narrow_from_decl(d); if (td == NULL) return NULL; d = td->base_type(); } if (d == NULL) return NULL; } /* * Try to convert the AST_Decl to a UTL_Scope */ sc = DeclAsScope(d); if (sc == NULL) return NULL; /* * Look up the next element */ d = sc->lookup_by_name_local (s); } /* * OK, done with the loop */ return d; }