void be_home::scan (UTL_Scope *s) { if (s == 0) { return; } for (UTL_ScopeActiveIterator i (s, UTL_Scope::IK_both); !i.is_done (); i.next ()) { AST_Decl *d = i.item (); AST_Attribute *attr = AST_Attribute::narrow_from_decl (d); if (attr != 0 && ! attr->readonly ()) { this->has_rw_attributes_ = true; return; } } AST_Home *h = AST_Home::narrow_from_scope (s); if (h != 0) { this->scan (h->base_home ()); } }
void be_component::mirror_scan (AST_PortType *pt) { AST_Uses *u = 0; AST_Provides *p = 0; AST_Attribute *a = 0; for (UTL_ScopeActiveIterator i (pt, UTL_Scope::IK_decls); !i.is_done (); i.next ()) { AST_Decl *d = i.item (); switch (d->node_type ()) { case AST_Decl::NT_provides: ++this->n_uses_; p = AST_Provides::narrow_from_decl (d); if (!p->provides_type ()->is_local ()) { ++this->n_remote_uses_; } continue; case AST_Decl::NT_uses: ++this->n_provides_; u = AST_Uses::narrow_from_decl (d); if (!u->uses_type ()->is_local ()) { ++this->n_remote_provides_; } continue; case AST_Decl::NT_attr: a = AST_Attribute::narrow_from_decl (d);; if (!a->readonly ()) { this->has_rw_attributes_ = true; } continue; default: continue; } } }
int be_visitor_interface_ss::gen_abstract_ops_helper ( be_interface *node, be_interface *base, TAO_OutStream *os) { if (!base->is_abstract ()) { return 0; } AST_Decl *d = 0; be_visitor_context ctx; ctx.stream (os); ctx.state (TAO_CodeGen::TAO_ROOT_SS); for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); !si.is_done (); si.next ()) { d = si.item (); if (d == 0) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("be_visitor_interface_ss::") ACE_TEXT ("gen_abstract_ops_helper - ") ACE_TEXT ("bad node in this scope\n")), -1); } AST_Decl::NodeType nt = d->node_type (); UTL_ScopedName *item_new_name = 0; UTL_ScopedName *new_name = 0; if (AST_Decl::NT_op == nt || AST_Decl::NT_attr == nt) { ACE_NEW_RETURN (item_new_name, UTL_ScopedName (d->local_name ()->copy (), 0), -1); new_name = (UTL_ScopedName *) node->name ()->copy (); new_name->nconc (item_new_name); } else { continue; } // We pass the node's is_abstract flag to the operation // constructor so we will get the right generated operation // body if we are regenerating an operation from an // abstract interface in a concrete interface or component. if (AST_Decl::NT_op == nt) { be_operation *op = be_operation::narrow_from_decl (d); UTL_ScopedName *old_name = (UTL_ScopedName *) op->name ()->copy (); op->set_name (new_name); op->set_defined_in (node); op->is_abstract (node->is_abstract ()); be_visitor_operation_ss op_visitor (&ctx); op_visitor.visit_operation (op); op->set_name (old_name); op->set_defined_in (base); op->is_abstract (base->is_abstract ()); } else if (AST_Decl::NT_attr == nt) { AST_Attribute *attr = AST_Attribute::narrow_from_decl (d); be_attribute new_attr (attr->readonly (), attr->field_type (), 0, attr->is_local (), attr->is_abstract ()); new_attr.set_defined_in (node); new_attr.set_name (new_name); UTL_ExceptList *get_exceptions = attr->get_get_exceptions (); if (0 != get_exceptions) { new_attr.be_add_get_exceptions (get_exceptions->copy ()); } UTL_ExceptList *set_exceptions = attr->get_set_exceptions (); if (0 != set_exceptions) { new_attr.be_add_set_exceptions (set_exceptions->copy ()); } be_visitor_attribute attr_visitor (&ctx); attr_visitor.visit_attribute (&new_attr); ctx.attribute (0); new_attr.destroy (); } } return 0; }
be_valuetype * be_visitor_amh_pre_proc::create_exception_holder (be_interface *node) { // AMH exception holders require both of these. idl_global->valuetype_seen_ = true; idl_global->valuefactory_seen_ = true; const int inherit_count = 0; AST_Type **p_intf = 0; UTL_ScopedName *excep_holder_name = node->compute_name ("AMH_", "ExceptionHolder"); UTL_Scope *s = node->defined_in (); idl_global->scopes ().push (s); be_valuetype *excep_holder = 0; ACE_NEW_RETURN (excep_holder, be_valuetype (excep_holder_name, p_intf, inherit_count, 0, 0, 0, 0, 0, 0, 0, 0, 0), 0); idl_global->scopes ().pop (); excep_holder->set_name (excep_holder_name); excep_holder->set_defined_in (node->defined_in ()); // Set repo id to 0, so it will be recomputed on the next access, // and set the prefix to the node's prefix. All this is // necessary in case the node's prefix was modified after // its declaration. excep_holder->AST_Decl::repoID (0); excep_holder->prefix (const_cast<char*> (node->prefix ())); excep_holder->gen_fwd_helper_name (); // Now our customized valuetype is created, we have to // add now the operations and attributes to the scope. // initialize an iterator to iterate thru our scope for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); !si.is_done (); si.next ()) { AST_Decl *d = si.item (); if (d == 0) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_amh_pre_proc::" "visit_interface - " "bad node in this scope\n"), 0); } be_decl *op = be_decl::narrow_from_decl (d); AST_Decl::NodeType nt = d->node_type (); if (nt == AST_Decl::NT_attr) { AST_Attribute *attribute = AST_Attribute::narrow_from_decl (d); if (attribute == 0) { return 0; } this->create_raise_operation (op, excep_holder, GET_OPERATION); if (!attribute->readonly ()) { this->create_raise_operation (op, excep_holder, SET_OPERATION); } } else if (nt == AST_Decl::NT_op) { this->create_raise_operation (op, excep_holder, NORMAL); } else { continue; } } return excep_holder; }
int be_visitor_interface_sh::gen_abstract_ops_helper ( be_interface *node, be_interface *base, TAO_OutStream *os) { if (!base->is_abstract ()) { return 0; } AST_Decl *d = 0; be_visitor_context ctx; ctx.stream (os); ctx.state (TAO_CodeGen::TAO_ROOT_SH); for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); !si.is_done (); si.next ()) { d = si.item (); if (d == 0) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("be_visitor_interface_sh::") ACE_TEXT ("gen_abstract_ops_helper - ") ACE_TEXT ("bad node in this scope\n")), -1); } UTL_ScopedName item_new_name (d->local_name (), 0); if (d->node_type () == AST_Decl::NT_op) { be_operation *op = be_operation::narrow_from_decl (d); be_visitor_operation_sh op_visitor (&ctx); op_visitor.visit_operation (op); } else if (d->node_type () == AST_Decl::NT_attr) { AST_Attribute *attr = AST_Attribute::narrow_from_decl (d); be_attribute new_attr (attr->readonly (), attr->field_type (), &item_new_name, attr->is_local (), attr->is_abstract ()); new_attr.set_defined_in (node); UTL_ExceptList *get_exceptions = attr->get_get_exceptions (); if (0 != get_exceptions) { new_attr.be_add_get_exceptions (get_exceptions->copy ()); } UTL_ExceptList *set_exceptions = attr->get_set_exceptions (); if (0 != set_exceptions) { new_attr.be_add_set_exceptions (set_exceptions->copy ()); } be_visitor_attribute attr_visitor (&ctx); attr_visitor.visit_attribute (&new_attr); ctx.attribute (0); new_attr.destroy (); } } return 0; }
bool idl_mapping_java::gen_interf(UTL_ScopedName *name, bool local, const std::vector<AST_Interface *> &inherits, const std::vector<AST_Interface *> &inherits_flat, const std::vector<AST_Attribute *> &attrs, const std::vector<AST_Operation *> &ops, const char *repoid) { JavaName jn(name); JavaName jn_ops(jn, "Operations"); JavaName jn_stub(jn, local ? "TAOPeer" : "Stub", true); string extends = jn.clazz_ + "Operations, " + (inherits.size() ? "" : "org.omg.CORBA.Object"); string extends_ops; for (size_t i = 0; i < inherits.size(); ++i) { extends += type(inherits[i]); extends_ops += type(inherits[i]) + "Operations"; if (i != inherits.size() - 1) { extends += ", "; extends_ops += ", "; } } string extends_stub = string("i2jrt.TAO") + (local ? "Local" : "") + "Object"; string allRepoIds = '"' + string(repoid) + '"', body_ops, body_stub = " protected " + jn_stub.clazz_ + "(long ptr) {\n" " super(ptr);\n" " }\n\n"; for (size_t i = 0; i < attrs.size(); ++i) { AST_Attribute *attr = attrs[i]; string signature = attr_signature_r(attr); body_ops += " " + signature + ";\n"; body_stub += " public native " + signature + ";\n\n"; if (!attr->readonly()) { string signature = attr_signature_w(attr); body_ops += " " + signature + ";\n"; body_stub += " public native " + signature + ";\n\n"; } } for (size_t i = 0; i < ops.size(); ++i) { string signature = op_signature(ops[i]); body_ops += " " + signature + ";\n"; body_stub += " public native " + signature + ";\n\n"; } for (size_t i = 0; i < inherits_flat.size(); ++i) { AST_Interface *base = inherits_flat[i]; allRepoIds += ", \"" + string(base->repoID()) + '"'; UTL_ScopeActiveIterator it(base, UTL_Scope::IK_decls); for (; !it.is_done(); it.next()) { AST_Decl *item = it.item(); if (item->node_type() == AST_Decl::NT_attr) { AST_Attribute *attr = AST_Attribute::narrow_from_decl(item); string signature = attr_signature_r(attr); body_stub += " public native " + signature + ";\n\n"; if (!attr->readonly()) { string signature = attr_signature_w(attr); body_stub += " public native " + signature + ";\n\n"; } } else if (item->node_type() == AST_Decl::NT_op) { AST_Operation *op = AST_Operation::narrow_from_decl(item); body_stub += " public native " + op_signature(op) + ";\n\n"; } } } bool ok(true); if (local) { JavaName jn_lb(jn, "LocalBase", true); string lb = " private String[] _type_ids = {" + allRepoIds + "};\n\n" " public String[] _ids() { return (String[])_type_ids.clone(); }\n"; ok = java_class_gen(jn_lb, JABSTRACT_CLASS, lb.c_str(), "org.omg.CORBA.LocalObject", jn.clazz_.c_str()); } return ok && java_class_gen(jn, JINTERFACE, "", extends.c_str()) && java_class_gen(jn_ops, JINTERFACE, body_ops.c_str(), extends_ops.c_str()) && java_class_gen(jn_stub, JCLASS, body_stub.c_str(), extends_stub.c_str(), jn.clazz_.c_str()) && gen_helper(jn, repoid, true) && gen_holder(jn); //FUTURE: server side }
void be_component::scan (UTL_Scope *s) { if (s == 0) { return; } AST_Extended_Port *ep = 0; AST_Mirror_Port *mp = 0; AST_Uses *u = 0; AST_Provides *p = 0; AST_Attribute *a = 0; AST_Decl::NodeType my_nt; AST_Decl::NodeType scope_nt; for (UTL_ScopeActiveIterator i (s, UTL_Scope::IK_both); !i.is_done (); i.next ()) { AST_Decl *d = i.item (); switch (d->node_type ()) { case AST_Decl::NT_provides: ++this->n_provides_; p = AST_Provides::narrow_from_decl (d); if (!p->provides_type ()->is_local ()) { ++this->n_remote_provides_; } continue; case AST_Decl::NT_uses: ++this->n_uses_; u = AST_Uses::narrow_from_decl (d); if (u->is_multiple ()) { this->has_uses_multiple_ = true; } if (!u->uses_type ()->is_local ()) { ++this->n_remote_uses_; } continue; case AST_Decl::NT_publishes: ++this->n_publishes_; continue; case AST_Decl::NT_consumes: ++this->n_consumes_; continue; case AST_Decl::NT_emits: ++this->n_emits_; continue; case AST_Decl::NT_ext_port: ep = AST_Extended_Port::narrow_from_decl (d); this->scan (ep->port_type ()); continue; case AST_Decl::NT_mirror_port: mp = AST_Mirror_Port::narrow_from_decl (d); this->mirror_scan (mp->port_type ()); continue; case AST_Decl::NT_attr: a = AST_Attribute::narrow_from_decl (d);; if (!a->readonly ()) { my_nt = this->node_type (); scope_nt = ScopeAsDecl (a->defined_in ())->node_type (); /// Attributes coming from a porttype appear /// only on connectors. if (my_nt == AST_Decl::NT_component && scope_nt == AST_Decl::NT_porttype) { continue; } this->has_rw_attributes_ = true; } continue; default: continue; } } AST_Component *c = AST_Component::narrow_from_scope (s); AST_Interface *iface = 0; if (c != 0) { for (long i = 0; i < c->n_supports (); ++i) { // See if the supported interfaces (if any) have attributes. // If CORBA::Object is supported, DeclAsScope will evaluate // to 0 and the call to scan() will return immediately. this->scan (DeclAsScope (c->supports ()[i])); } // Check the base component. If there is none, the arg to scan() // will be 0 and the call will return immediately. this->scan (c->base_component ()); } else if ((iface = AST_Interface::narrow_from_scope (s)) != 0) { for (long i = 0; i < iface->n_inherits (); ++i) { // Will pick up a chain of inheritance, // no need to use inherits_flat(). this->scan (DeclAsScope (iface->inherits ()[i])); } } }