#include <ifr_adding_visitor_operation.h>
Inheritance diagram for ifr_adding_visitor_operation:
Public Member Functions | |
ifr_adding_visitor_operation (AST_Decl *scope) | |
virtual | ~ifr_adding_visitor_operation (void) |
virtual int | visit_operation (AST_Operation *node) |
virtual int | visit_argument (AST_Argument *node) |
Private Attributes | |
CORBA::ParDescriptionSeq | params_ |
CORBA::ULong | index_ |
Definition at line 29 of file ifr_adding_visitor_operation.h.
ifr_adding_visitor_operation::ifr_adding_visitor_operation | ( | AST_Decl * | scope | ) |
Definition at line 20 of file ifr_adding_visitor_operation.cpp.
00021 : ifr_adding_visitor (scope), 00022 index_ (0) 00023 { 00024 }
ifr_adding_visitor_operation::~ifr_adding_visitor_operation | ( | void | ) | [virtual] |
int ifr_adding_visitor_operation::visit_argument | ( | AST_Argument * | node | ) | [virtual] |
Reimplemented from ifr_visitor.
Definition at line 209 of file ifr_adding_visitor_operation.cpp.
References CORBA::Exception::_tao_print_exception(), ACE_TEXT(), ifr_adding_visitor::get_referenced_type(), index_, params_, and CORBA::string_dup().
00210 { 00211 // Get the parameter's name. 00212 this->params_[this->index_].name = 00213 CORBA::string_dup (node->local_name ()->get_string ()); 00214 00215 AST_Type *arg_type = node->field_type (); 00216 00217 try 00218 { 00219 // Updates ir_current_. 00220 this->get_referenced_type (arg_type); 00221 00222 this->params_[this->index_].type_def = 00223 CORBA::IDLType::_duplicate (this->ir_current_.in ()); 00224 00225 00226 switch (node->direction ()) 00227 { 00228 case AST_Argument::dir_IN: 00229 this->params_[this->index_].mode = CORBA::PARAM_IN; 00230 break; 00231 case AST_Argument::dir_OUT: 00232 this->params_[this->index_].mode = CORBA::PARAM_OUT; 00233 break; 00234 case AST_Argument::dir_INOUT: 00235 this->params_[this->index_].mode = CORBA::PARAM_INOUT; 00236 break; 00237 } 00238 00239 // IfR method create_operation does not use this - it just needs 00240 // to be non-zero for marshaling. 00241 this->params_[this->index_].type = 00242 CORBA::TypeCode::_duplicate (CORBA::_tc_void); 00243 00244 ++this->index_; 00245 } 00246 catch (const CORBA::Exception& ex) 00247 { 00248 ex._tao_print_exception ( 00249 ACE_TEXT ( 00250 "ifr_adding_visitor_operation::visit_argument")); 00251 00252 return -1; 00253 } 00254 00255 return 0; 00256 }
int ifr_adding_visitor_operation::visit_operation | ( | AST_Operation * | node | ) | [virtual] |
Reimplemented from ifr_adding_visitor.
Definition at line 31 of file ifr_adding_visitor_operation.cpp.
References CORBA::Exception::_tao_print_exception(), ACE_ERROR_RETURN, ACE_TEXT(), be_global, ifr_adding_visitor::get_referenced_type(), BE_GlobalData::ifr_scopes(), index_, ifr_adding_visitor::ir_current_, CORBA::is_nil(), LM_ERROR, params_, BE_GlobalData::repository(), and ACE_Unbounded_Stack< T >::top().
Referenced by ifr_adding_visitor::visit_operation().
00032 { 00033 try 00034 { 00035 // If this operation is already in the repository (for example, if 00036 // we are processing the IDL file a second time inadvertently), we 00037 // just return 0. The IDL file must be legal, otherwise the IDL 00038 // compiler front end would have told us. 00039 00040 CORBA::Contained_var prev_def = 00041 be_global->repository ()->lookup_id (node->repoID ()); 00042 00043 if (!CORBA::is_nil (prev_def.in ())) 00044 { 00045 return 0; 00046 } 00047 00048 // Build the parameter list. Our overridden version of visit_argument 00049 // will look up each parameter and add its repository entry to 00050 // our params_ member. 00051 00052 CORBA::ULong length = static_cast<CORBA::ULong> (node->argument_count ()); 00053 00054 this->params_.length (length); 00055 00056 if (this->visit_scope (node) == -1) 00057 { 00058 ACE_ERROR_RETURN (( 00059 LM_ERROR, 00060 ACE_TEXT ("(%N:%l) ifr_adding_visitor_operation::") 00061 ACE_TEXT ("visit_operation -") 00062 ACE_TEXT (" visit_scope failed\n") 00063 ), 00064 -1 00065 ); 00066 } 00067 00068 this->index_ = 0; 00069 00070 // Build the exception list. 00071 00072 UTL_ExceptList *excepts = node->exceptions (); 00073 00074 if (excepts != 0) 00075 { 00076 length = static_cast<CORBA::ULong> (excepts->length ()); 00077 } 00078 else 00079 { 00080 length = 0; 00081 } 00082 00083 CORBA::ExceptionDefSeq exceptions (length); 00084 exceptions.length (length); 00085 00086 AST_Exception *ex = 0; 00087 CORBA::ULong i = 0; 00088 00089 for (UTL_ExceptlistActiveIterator ex_iter (excepts); 00090 !ex_iter.is_done (); 00091 ex_iter.next (), ++i) 00092 { 00093 ex = ex_iter.item (); 00094 00095 prev_def = 00096 be_global->repository ()->lookup_id (ex->repoID ()); 00097 00098 exceptions[i] = 00099 CORBA::ExceptionDef::_narrow (prev_def.in ()); 00100 } 00101 00102 // Build the context list. 00103 00104 UTL_StrList *ctx_list = node->context (); 00105 00106 if (ctx_list != 0) 00107 { 00108 length = static_cast<CORBA::ULong> (ctx_list->length ()); 00109 } 00110 else 00111 { 00112 length = 0; 00113 } 00114 00115 CORBA::ContextIdSeq contexts (length); 00116 contexts.length (length); 00117 00118 UTL_StrlistActiveIterator ctx_iter (ctx_list); 00119 UTL_String *str = 0; 00120 i = 0; 00121 00122 while (!ctx_iter.is_done ()) 00123 { 00124 str = ctx_iter.item (); 00125 00126 contexts[i++] = str->get_string (); 00127 00128 ctx_iter.next (); 00129 } 00130 00131 // Get the return type. 00132 00133 AST_Type *return_type = node->return_type (); 00134 00135 // Updates ir_current_. 00136 this->get_referenced_type (return_type); 00137 00138 // Is the operation oneway? 00139 CORBA::OperationMode mode = node->flags () == AST_Operation::OP_oneway 00140 ? CORBA::OP_ONEWAY 00141 : CORBA::OP_NORMAL; 00142 00143 // Create the repository entry. 00144 00145 CORBA::Container_ptr current_scope = 00146 CORBA::Container::_nil (); 00147 00148 if (be_global->ifr_scopes ().top (current_scope) == 0) 00149 { 00150 AST_Decl *op_scope = ScopeAsDecl (node->defined_in ()); 00151 AST_Decl::NodeType nt = op_scope->node_type (); 00152 00153 if (nt == AST_Decl::NT_interface) 00154 { 00155 CORBA::InterfaceDef_var iface = 00156 CORBA::InterfaceDef::_narrow (current_scope); 00157 00158 CORBA::OperationDef_var new_def = 00159 iface->create_operation (node->repoID (), 00160 node->local_name ()->get_string (), 00161 node->version (), 00162 this->ir_current_.in (), 00163 mode, 00164 this->params_, 00165 exceptions, 00166 contexts); 00167 } 00168 else 00169 { 00170 CORBA::ValueDef_var vtype = 00171 CORBA::ValueDef::_narrow (current_scope); 00172 00173 CORBA::OperationDef_var new_def = 00174 vtype->create_operation (node->repoID (), 00175 node->local_name ()->get_string (), 00176 node->version (), 00177 this->ir_current_.in (), 00178 mode, 00179 this->params_, 00180 exceptions, 00181 contexts); 00182 } 00183 } 00184 else 00185 { 00186 ACE_ERROR_RETURN (( 00187 LM_ERROR, 00188 ACE_TEXT ("(%N:%l) ifr_adding_visitor_operation::") 00189 ACE_TEXT ("visit_operation -") 00190 ACE_TEXT (" scope stack is empty\n") 00191 ), 00192 -1 00193 ); 00194 } 00195 } 00196 catch (const CORBA::Exception& ex) 00197 { 00198 ex._tao_print_exception ( 00199 ACE_TEXT ( 00200 "ifr_adding_visitor_operation::visit_operation")); 00201 00202 return -1; 00203 } 00204 00205 return 0; 00206 }
Definition at line 57 of file ifr_adding_visitor_operation.h.
Referenced by visit_argument(), and visit_operation().
CORBA::ParDescriptionSeq ifr_adding_visitor_operation::params_ [private] |
Definition at line 53 of file ifr_adding_visitor_operation.h.
Referenced by visit_argument(), and visit_operation().