summaryrefslogtreecommitdiff
path: root/TAO/tao/operation_details.cpp
blob: d8d2e27a3e3df3d061f5e164ecb7b3d87107aa93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//$Id$
#include "operation_details.h"
#include "Stub.h"
#include "Typecode.h"
#include "ORB_Constants.h"
#include "DynamicC.h"
#include "Exception_Data.h"
#include "SystemException.h"

#include "ace/OS_NS_string.h"


#if !defined (__ACE_INLINE__)
# include "tao/operation_details.i"
#endif /* ! __ACE_INLINE__ */


ACE_RCSID (tao,
           operation_details,
           "$Id$")


CORBA::Exception *
TAO_Operation_Details::corba_exception (const char *id
                                        ACE_ENV_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  for (CORBA::ULong i = 0; i != this->ex_count_; ++i)
    {
      if (ACE_OS::strcmp (id,
                          this->ex_data_[i].id) != 0)
        {
          continue;
        }

      // Create an exception object
      CORBA::Exception *exception =
        this->ex_data_[i].alloc ();

      if (exception == 0)
        {
          ACE_THROW_RETURN (CORBA::NO_MEMORY (0,
                                              CORBA::COMPLETED_YES),
                            0);
        }

      // Return the exception object that we just created.
      return exception;
    }

  // If there are no matches return an unknown exception.
  ACE_THROW_RETURN (CORBA::UNKNOWN (0,
                                    CORBA::COMPLETED_YES),
                    0);
}

bool
TAO_Operation_Details::marshal_args (TAO_OutputCDR &cdr)
{
  for (CORBA::ULong i = 0; i != this->num_args_; ++i)
    {
      if (!((*this->args_[i]).marshal (cdr)))
        return false;
    }

  return true;
}

bool
TAO_Operation_Details::demarshal_args (TAO_InputCDR &cdr)
{
  for (CORBA::ULong i = 0; i != this->num_args_; ++i)
    {
      if (!((*this->args_[i]).demarshal (cdr)))
        return false;
    }

  return true;
}

#if TAO_HAS_INTERCEPTORS == 1

bool
TAO_Operation_Details::parameter_list (Dynamic::ParameterList &param_list)
{
  // Account for the return type that could be in the argument list.
  param_list.length (this->num_args_ - 1);

   for (CORBA::ULong i = 1; i != this->num_args_; ++i)
     this->args_[i]->interceptor_param (param_list[i - 1]);

   return true;
}

#endif /* TAO_HAS_INTERCEPTORS == 1 */

bool
TAO_Operation_Details::exception_list (Dynamic::ExceptionList &exception_list)
{
  if (this->ex_count_)
    {
      exception_list.length (this->ex_count_);

      for (CORBA::ULong i = 0;
           i != this->ex_count_;
           ++i)
        {
          CORBA::TypeCode_ptr tcp = this->ex_data_[i].tc_ptr;
          TAO_Pseudo_Object_Manager<CORBA::TypeCode> tcp_object (&tcp, 1);
          exception_list[i] = tcp_object;
        }
    }
  return true;
}


#if TAO_HAS_INTERCEPTORS == 1

bool
TAO_Operation_Details::result (CORBA::Any *any)
{
  for (CORBA::ULong i = 0; i != this->num_args_; ++i)
    (*this->args_[i]).interceptor_result (any);

  return true;
}

#endif /* TAO_HAS_INTERCEPTORS == 1 */