void
TAO_IFR_Client_Adapter_Impl::create_operation_list (
    CORBA::ORB_ptr orb,
    CORBA::OperationDef_ptr opDef,
    CORBA::NVList_ptr &result)
{
    // Create an empty NVList.
    orb->create_list (0, result);

    // Get the parameters (if any) from the OperationDef, and for each
    // parameter add a corresponding entry to the result.
    CORBA::ParDescriptionSeq_var params = opDef->params ();

    CORBA::ULong paramCount = params->length ();

    for (CORBA::ULong i = 0; i < paramCount; ++i)
    {
        CORBA::Any value;
        TAO::Unknown_IDL_Type *unk = 0;
        ACE_NEW (unk,
                 TAO::Unknown_IDL_Type (params[i].type.in ()));
        value.replace (unk);

        // Convert the parameter mode to an arg mode
        CORBA::Flags flags = 0;
        switch(params[i].mode)
        {
        case CORBA::PARAM_IN:
            flags = CORBA::ARG_IN;
            break;
        case CORBA::PARAM_OUT:
            flags = CORBA::ARG_OUT;
            break;
        case CORBA::PARAM_INOUT:
            flags = CORBA::ARG_INOUT;
            break;
        default:
            // Shouldn't happen
            throw ::CORBA::INTERNAL();
        }

        // Add an argument to the NVList.
        result->add_value (params[i].name.in (), value, flags);
    }
}
Example #2
0
OCI_APT::ArgList *
OCI_APT::OperationTable::add_interface (CORBA::InterfaceDef_ptr intDef,
					const char * desired_op)
{
	bool want_attribute = false;
	if (desired_op && desired_op[0] == '_')
		want_attribute = ACE_OS::strncmp(desired_op+2,"et_",3) == 0;

	ACE_Write_Guard<ACE_RW_Thread_Mutex>(this->lock_);
	OCI_APT::ArgList *result = 0;
	CORBA::InterfaceDefSeq_var bases = intDef->base_interfaces ();
	CORBA::String_var *derived = new CORBA::String_var[bases->length()];
	CORBA::ULong n_bases = bases->length();
	CORBA::ULong i = 0;
	for (; i <= n_bases; i++)
	{
		CORBA::String_var rep_id = intDef->id();
		if (i == 0)
		{
			OCI_APT::ArgList *al = this->add_is_a (rep_id.in());
			if (!want_attribute && desired_op && ACE_OS::strcmp("_is_a",desired_op) == 0)
				result = al;
			else
				al->remove_ref();

			al = this->add_non_existent (rep_id.in());
			if (!want_attribute && desired_op && ACE_OS::strcmp("_non_existent",desired_op) == 0)
				result = al;
			else
				al->remove_ref();
		}

		CORBA::ContainedSeq_var attributes =
			intDef->contents (CORBA::dk_Attribute,1);
		CORBA::ULong n_ats = attributes->length();
		for (CORBA::ULong at = 0; at < n_ats; ++at)
		{
			CORBA::String_var attr_name = attributes[at]->name();
			CORBA::AttributeDef_var attr =
				CORBA::AttributeDef::_narrow (attributes[at]);
			CORBA::String_var attr_op =
				CORBA::string_alloc(ACE_OS::strlen(attr_name.in()) + 5);
			ACE_OS::strcpy(attr_op.inout(),"_get_");
			ACE_OS::strcat(attr_op.inout(),attr_name.in());
			OCI_APT::Operation *op_ptr = this->find_or_add(attr_op.in());
			OCI_APT::ArgList *arg_list =
				new OCI_APT::ArgList (0, 0, false);
			arg_list->result (attr->type());
			if (want_attribute && ACE_OS::strcmp (attr_op.in(),desired_op) == 0)
			{
				arg_list->add_ref();
				result = arg_list;
			}

			op_ptr->add_set (new OpArgs(rep_id.in(),arg_list));
			for (CORBA::ULong d = 0; d < i; d++)
				op_ptr->add_set (new OpArgs(derived[d],arg_list));
			arg_list->remove_ref();

			if (attr->mode() == CORBA::ATTR_READONLY)
				continue;

			attr_op.inout()[1] = 's'; // from _get_ to _set_
			op_ptr = this->find_or_add(attr_op.in());
			arg_list =
				new OCI_APT::ArgList (1, 0, false);
			arg_list->set_arg(0, attr->type(),CORBA::ARG_IN);
			arg_list->result (CORBA::_tc_void);
			if (want_attribute && ACE_OS::strcmp (attr_op.in(),desired_op) == 0)
			{
				arg_list->add_ref();
				result = arg_list;
			}

			op_ptr->add_set (new OpArgs(rep_id.in(),arg_list));
			for (CORBA::ULong d = 0; d < i; d++)
				op_ptr->add_set (new OpArgs(derived[d],arg_list));
			arg_list->remove_ref();

		}

		CORBA::ContainedSeq_var operations =
			intDef->contents (CORBA::dk_Operation,1);

		CORBA::ULong n_ops = operations->length ();
		for (CORBA::ULong op = 0; op < n_ops; ++op)
		{
			CORBA::String_var op_name = operations[op]->name();
			OCI_APT::Operation *op_ptr = this->find_or_add(op_name.in());

			CORBA::OperationDef_var opDef =
				CORBA::OperationDef::_narrow (operations[op]);
			CORBA::ParDescriptionSeq_var params = opDef->params ();
			CORBA::ExceptionDefSeq_var excepts = opDef->exceptions();

			int is_oneway = opDef->mode() == CORBA::OP_ONEWAY;
			OCI_APT::ArgList *arg_list =
				new OCI_APT::ArgList (params->length(),
						      excepts->length(),
						      is_oneway);
			if (!is_oneway)
				arg_list->result (opDef->result());

			for (CORBA::ULong p = 0; p < params->length (); ++p)
			{
				CORBA::Flags mode = CORBA::ARG_IN;
				if (params[p].mode == CORBA::PARAM_OUT)
					mode = CORBA::ARG_OUT;
				else if (params[p].mode == CORBA::PARAM_INOUT)
					mode = CORBA::ARG_INOUT;

				arg_list->set_arg(p, params[p].type.in(),mode);
			}

			for (CORBA::ULong e = 0; e < excepts->length (); ++e)
			{
				CORBA::TypeCode_var tc = excepts[e]->type();
				arg_list->set_excep(e, tc.in());
			}

			if (!want_attribute && desired_op && ACE_OS::strcmp(op_name,desired_op) == 0)
			{
				arg_list->add_ref();
				result = arg_list;
			}

			op_ptr->add_set (new OpArgs(rep_id.in(),arg_list));
			for (CORBA::ULong d = 0; d < i; d++)
				op_ptr->add_set (new OpArgs(derived[d],arg_list));
			arg_list->remove_ref();
		}

		if (i < bases->length())
		{
			derived[i] = rep_id;
			intDef = bases[i];
		}
	}
	delete [] derived;
	return result;
}