int be_visitor_ami_pre_proc::create_reply_handler_operation ( be_operation *node, be_interface *reply_handler) { if (!node) { return -1; } if (node->flags () == AST_Operation::OP_oneway) { // We do nothing for oneways! return 0; } Identifier *id = 0; UTL_ScopedName *sn = 0; ACE_CString original_op_name ( node->name ()->last_component ()->get_string () ); UTL_ScopedName *op_name = static_cast<UTL_ScopedName *> (reply_handler->name ()-> copy ()); ACE_NEW_RETURN (id, Identifier (original_op_name.c_str ()), -1); ACE_NEW_RETURN (sn, UTL_ScopedName (id, 0), -1); op_name->nconc (sn); // Create the operation. be_operation *operation = 0; ACE_NEW_RETURN (operation, be_operation (be_global->void_type (), AST_Operation::OP_noflags, op_name, 0, 0), -1); operation->set_name (op_name); // If return type is non-void add it as first argument. if (!node->void_return_type ()) { ACE_NEW_RETURN (id, Identifier ("ami_return_val"), -1); UTL_ScopedName *tmp = 0; ACE_NEW_RETURN (tmp, UTL_ScopedName (id, 0), -1); sn = (UTL_ScopedName *)operation->name ()->copy (); sn->nconc (tmp); // Create the argument. be_argument *arg = 0; ACE_NEW_RETURN (arg, be_argument (AST_Argument::dir_IN, node->return_type (), sn), -1); arg->set_defined_in (operation); arg->set_name (sn); // Add the reply handler to the argument list. operation->be_add_argument (arg); } // Iterate over the arguments and put all the in and inout // into the new method. if (node->nmembers () > 0) { // 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) { operation->destroy (); delete operation; operation = 0; ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("be_visitor_ami_pre_proc::") ACE_TEXT ("create_reply_handler_operation - ") ACE_TEXT ("bad node in this scope\n")), -1); } AST_Argument *original_arg = AST_Argument::narrow_from_decl (d); if (original_arg->direction () == AST_Argument::dir_INOUT || original_arg->direction () == AST_Argument::dir_OUT) { // Create the argument. be_argument *arg = 0; UTL_ScopedName *new_name = (UTL_ScopedName *)original_arg->name ()->copy (); ACE_NEW_RETURN (arg, be_argument (AST_Argument::dir_IN, original_arg->field_type (), new_name), -1); arg->set_defined_in (operation); arg->set_name (new_name); operation->be_add_argument (arg); } } // end of while loop } // end of if operation->set_defined_in (reply_handler); // Copy the exceptions. if (node->exceptions ()) { UTL_ExceptList *exceptions = node->exceptions (); if (0 != exceptions) { operation->be_add_exceptions (exceptions->copy ()); } } // After having generated the operation we insert it into the // reply handler interface. if (0 == reply_handler->be_add_operation (operation)) { return -1; } operation->is_attr_op (node->is_attr_op ()); return 0; }
int be_visitor_ami_pre_proc::create_excep_operation (be_operation *node, be_interface *reply_handler) { if (node->flags () == AST_Operation::OP_oneway) { // We do nothing for oneways! return 0; } // Create the return type, which is "void". Identifier *id = 0; UTL_ScopedName *sn = 0; // Create the argument. ACE_NEW_RETURN (id, Identifier ("excep_holder"), -1); ACE_NEW_RETURN (sn, UTL_ScopedName (id, 0), -1); be_valuetype *excep_holder = be_global->messaging_exceptionholder (); be_argument *arg = 0; ACE_NEW_RETURN (arg, be_argument (AST_Argument::dir_IN, excep_holder, // is also a valuetype sn), -1); arg->set_name (sn); UTL_ScopedName *tmp = (UTL_ScopedName *)sn->copy (); // Create the new name // Append _excep to the name of the operation ACE_CString original_op_name ( node->name ()->last_component ()->get_string () ); ACE_CString new_op_name = original_op_name + ACE_CString ("_excep"); UTL_ScopedName *op_name = static_cast<UTL_ScopedName *> (reply_handler->name ()->copy ()); ACE_NEW_RETURN (id, Identifier (new_op_name.c_str ()), -1); ACE_NEW_RETURN (sn, UTL_ScopedName (id, 0), -1); op_name->nconc (sn); AST_PredefinedType *rt = be_global->void_type (); // Create the operation. be_operation *operation = 0; ACE_NEW_RETURN (operation, be_operation (rt, AST_Operation::OP_noflags, op_name, false, false), -1); operation->set_name (op_name); operation->be_add_argument (arg); operation->set_defined_in (reply_handler); UTL_ScopedName *arg_name = dynamic_cast<UTL_ScopedName *> (op_name->copy ()); arg_name->nconc (tmp); arg->set_name (arg_name); arg->set_defined_in (operation); // Copy the exceptions since the user exception information may // be needed when collocation is disabled. UTL_ExceptList *exceptions = node->exceptions (); if (0 != exceptions) { operation->be_add_exceptions (exceptions->copy ()); } reply_handler->be_add_operation (operation); operation->is_excep_ami (true); return 0; }
int be_visitor_amh_pre_proc::create_raise_operation ( be_decl *node, be_valuetype *excep_holder, Operation_Kind operation_kind ) { Identifier *id = 0; UTL_ScopedName *sn = 0; be_operation *orig_op = 0; if (operation_kind == NORMAL) { orig_op = be_operation::narrow_from_decl (node); } // Name the operation properly UTL_ScopedName *op_name = static_cast<UTL_ScopedName *> (excep_holder->name ()->copy ()); ACE_CString new_local_name ("raise_"); if (operation_kind == SET_OPERATION) { new_local_name += "set_"; } else if (operation_kind == GET_OPERATION) { new_local_name += "get_"; } new_local_name += node->name ()->last_component ()->get_string (); ACE_NEW_RETURN (id, Identifier (new_local_name.c_str ()), -1); ACE_NEW_RETURN (sn, UTL_ScopedName (id, 0), -1); op_name->nconc (sn); be_operation *operation = 0; ACE_NEW_RETURN (operation, be_operation (be_global->void_type (), AST_Operation::OP_noflags, op_name, 0, 0), -1); operation->set_name (op_name); operation->set_defined_in (excep_holder); if (operation_kind == NORMAL) { if (orig_op) { // Copy the exceptions. UTL_ExceptList *exceptions = orig_op->exceptions (); if (0 != exceptions) { operation->be_add_exceptions (exceptions->copy ()); } } } // After having generated the operation we insert it into the // exceptionholder valuetype. if (0 == excep_holder->be_add_operation (operation)) { return -1; } return 0; }