2 #include "orbsvcs/Log_Macros.h"
3 #include "ast_argument.h"
4 #include "ast_exception.h"
5 #include "ast_expression.h"
6 #include "ast_operation.h"
7 #include "utl_identifier.h"
8 #include "utl_string.h"
10 #include "ifr_adding_visitor_operation.h"
11 #include "utl_exceptlist.h"
12 #include "utl_strlist.h"
13 #include "nr_extern.h"
15 ifr_adding_visitor_operation::ifr_adding_visitor_operation (AST_Decl
*scope
)
16 : ifr_adding_visitor (scope
),
21 ifr_adding_visitor_operation::~ifr_adding_visitor_operation (void)
26 ifr_adding_visitor_operation::visit_operation (AST_Operation
*node
)
30 // If this operation is already in the repository (for example, if
31 // we are processing the IDL file a second time inadvertently), we
32 // just return 0. The IDL file must be legal, otherwise the IDL
33 // compiler front end would have told us.
35 CORBA::Contained_var prev_def
=
36 be_global
->repository ()->lookup_id (node
->repoID ());
38 if (!CORBA::is_nil (prev_def
.in ()))
43 // Build the parameter list. Our overridden version of visit_argument
44 // will look up each parameter and add its repository entry to
45 // our params_ member.
47 CORBA::ULong length
= static_cast<CORBA::ULong
> (node
->argument_count ());
49 this->params_
.length (length
);
51 if (this->visit_scope (node
) == -1)
53 ORBSVCS_ERROR_RETURN ((
55 ACE_TEXT ("(%N:%l) ifr_adding_visitor_operation::")
56 ACE_TEXT ("visit_operation -")
57 ACE_TEXT (" visit_scope failed\n")
65 // Build the exception list.
67 UTL_ExceptList
*excepts
= node
->exceptions ();
71 length
= static_cast<CORBA::ULong
> (excepts
->length ());
78 CORBA::ExceptionDefSeq
exceptions (length
);
79 exceptions
.length (length
);
84 for (UTL_ExceptlistActiveIterator
ex_iter (excepts
);
91 be_global
->repository ()->lookup_id (ex
->repoID ());
94 CORBA::ExceptionDef::_narrow (prev_def
.in ());
97 // Build the context list.
99 UTL_StrList
*ctx_list
= node
->context ();
103 length
= static_cast<CORBA::ULong
> (ctx_list
->length ());
110 CORBA::ContextIdSeq
contexts (length
);
111 contexts
.length (length
);
113 UTL_StrlistActiveIterator
ctx_iter (ctx_list
);
117 while (!ctx_iter
.is_done ())
119 str
= ctx_iter
.item ();
121 contexts
[i
++] = str
->get_string ();
126 // Get the return type.
128 AST_Type
*return_type
= node
->return_type ();
130 // Updates ir_current_.
131 this->get_referenced_type (return_type
);
133 // Is the operation oneway?
134 CORBA::OperationMode mode
= node
->flags () == AST_Operation::OP_oneway
138 // Create the repository entry.
140 CORBA::Container_ptr current_scope
=
141 CORBA::Container::_nil ();
143 if (be_global
->ifr_scopes ().top (current_scope
) == 0)
145 AST_Decl
*op_scope
= ScopeAsDecl (node
->defined_in ());
146 AST_Decl::NodeType nt
= op_scope
->node_type ();
148 if (nt
== AST_Decl::NT_interface
)
150 CORBA::InterfaceDef_var iface
=
151 CORBA::InterfaceDef::_narrow (current_scope
);
153 CORBA::OperationDef_var new_def
=
154 iface
->create_operation (node
->repoID (),
155 node
->local_name ()->get_string (),
157 this->ir_current_
.in (),
165 CORBA::ValueDef_var vtype
=
166 CORBA::ValueDef::_narrow (current_scope
);
168 CORBA::OperationDef_var new_def
=
169 vtype
->create_operation (node
->repoID (),
170 node
->local_name ()->get_string (),
172 this->ir_current_
.in (),
181 ORBSVCS_ERROR_RETURN ((
183 ACE_TEXT ("(%N:%l) ifr_adding_visitor_operation::")
184 ACE_TEXT ("visit_operation -")
185 ACE_TEXT (" scope stack is empty\n")
191 catch (const CORBA::Exception
& ex
)
193 ex
._tao_print_exception (
195 "ifr_adding_visitor_operation::visit_operation"));
204 ifr_adding_visitor_operation::visit_argument (AST_Argument
*node
)
206 // Get the parameter's name.
207 this->params_
[this->index_
].name
=
208 CORBA::string_dup (node
->local_name ()->get_string ());
210 AST_Type
*arg_type
= node
->field_type ();
214 // Updates ir_current_.
215 this->get_referenced_type (arg_type
);
217 this->params_
[this->index_
].type_def
=
218 CORBA::IDLType::_duplicate (this->ir_current_
.in ());
221 switch (node
->direction ())
223 case AST_Argument::dir_IN
:
224 this->params_
[this->index_
].mode
= CORBA::PARAM_IN
;
226 case AST_Argument::dir_OUT
:
227 this->params_
[this->index_
].mode
= CORBA::PARAM_OUT
;
229 case AST_Argument::dir_INOUT
:
230 this->params_
[this->index_
].mode
= CORBA::PARAM_INOUT
;
234 // IfR method create_operation does not use this - it just needs
235 // to be non-zero for marshaling.
236 this->params_
[this->index_
].type
=
237 CORBA::TypeCode::_duplicate (CORBA::_tc_void
);
241 catch (const CORBA::Exception
& ex
)
243 ex
._tao_print_exception (
245 "ifr_adding_visitor_operation::visit_argument"));