#include "tao/AnyTypeCode/TypeCode_CDR_Extraction.h"
#include "tao/AnyTypeCode/TypeCode_Constants.h"
#include "tao/AnyTypeCode/True_RefCount_Policy.h"
#include "tao/AnyTypeCode/Alias_TypeCode.h"
#include "tao/AnyTypeCode/Enum_TypeCode.h"
#include "tao/AnyTypeCode/TypeCode_Case_Enum_T.h"
#include "tao/AnyTypeCode/Fixed_TypeCode.h"
#include "tao/AnyTypeCode/Objref_TypeCode.h"
#include "tao/AnyTypeCode/Sequence_TypeCode.h"
#include "tao/AnyTypeCode/String_TypeCode.h"
#include "tao/AnyTypeCode/Struct_TypeCode.h"
#include "tao/AnyTypeCode/Union_TypeCode.h"
#include "tao/AnyTypeCode/Value_TypeCode.h"
#include "tao/AnyTypeCode/Any.h"
#include "tao/AnyTypeCode/Recursive_Type_TypeCode.h"
#include "tao/AnyTypeCode/TypeCode_Case_T.h"
#include "tao/AnyTypeCode/TypeCode_Struct_Field.h"
#include "tao/AnyTypeCode/TypeCode_Value_Field.h"
#include "tao/CDR.h"
#include "ace/Array_Base.h"
#include "ace/Value_Ptr.h"
Include dependency graph for TypeCode_CDR_Extraction.cpp:
Go to the source code of this file.
|
Definition at line 121 of file TypeCode_CDR_Extraction.cpp. Referenced by tc_demarshal_indirection(), and TAO::TypeCodeFactory::tc_union_factory(). |
|
Definition at line 120 of file TypeCode_CDR_Extraction.cpp. Referenced by TAO::TypeCodeFactory::tc_union_factory(). |
|
Definition at line 67 of file TypeCode_CDR_Extraction.cpp. References TAO::TypeCodeFactory::TC_Info::id, ACE_Array_Base< T >::size(), TAO::TypeCodeFactory::TC_Info_List, and TAO::TypeCodeFactory::TC_Info::type. Referenced by tc_demarshal_indirection().
00069 { 00070 // Since we created a new tc, add it to the list. 00071 size_t const old_size = infos.size (); 00072 if (infos.size (old_size + 1) == -1) // Incremental growth -- *sigh* 00073 { 00074 // Can't increase the list size. 00075 return false; 00076 } 00077 00078 TAO::TypeCodeFactory::TC_Info & info = infos [old_size]; 00079 00080 try 00081 { 00082 // Append the new TC to the list. 00083 info.id = tc->id (); // Should never throw, but just incase! 00084 info.type = tc; 00085 } 00086 catch (...) 00087 { 00088 infos.size (old_size); // Remove the partially added new TC from the list. 00089 return false; 00090 } 00091 return true; 00092 } |
|
Definition at line 135 of file TypeCode_CDR_Extraction.cpp. References TAO::TypeCodeFactory::TC_Info::id, ACE_Array_Base< T >::size(), ACE_OS::strcmp(), TAO::TypeCodeFactory::TC_Info_List, and TAO::TypeCodeFactory::TC_Info::type. Referenced by tc_demarshal_indirection(), TAO::TypeCodeFactory::tc_struct_factory(), TAO::TypeCodeFactory::tc_union_factory(), and TAO::TypeCodeFactory::tc_value_factory().
00138 { 00139 // See comments above for rationale behind using an array instead 00140 // of a map. 00141 00142 size_t const len = infos.size (); 00143 00144 for (size_t i = 0; i < len; ++i) 00145 { 00146 TAO::TypeCodeFactory::TC_Info & info = infos[i]; 00147 00148 if (ACE_OS::strcmp (info.id, id) == 0) 00149 { 00150 // We have a matching id, so store the TypeCode in the out 00151 // array and then compare the others. 00152 size_t const old_size = tcs.size (); 00153 if (tcs.size (old_size + 1) == -1) // Incremental growth -- *sigh* 00154 return false; 00155 00156 TAO::TypeCodeFactory::TC_Info & new_info = tcs[old_size]; 00157 new_info.type = info.type; 00158 } 00159 } 00160 00161 return (tcs.size () > 0) ; 00162 } |
|
Definition at line 1407 of file TypeCode_CDR_Extraction.cpp. References tc_demarshal(), and TAO::TypeCodeFactory::TC_Info_List.
01408 { 01409 TAO::TypeCodeFactory::TC_Info_List infos; 01410 01411 return tc_demarshal (cdr, tc, infos); 01412 } |
|
Definition at line 94 of file TypeCode_CDR_Extraction.cpp. References ACE_InputCDR::reset_byte_order(), and ACE_InputCDR::skip_ulong(). Referenced by TAO::TypeCodeFactory::tc_alias_factory(), tc_demarshal_indirection(), TAO::TypeCodeFactory::tc_enum_factory(), TAO::TypeCodeFactory::tc_objref_factory(), TAO::TypeCodeFactory::tc_sequence_factory(), TAO::TypeCodeFactory::tc_struct_factory(), TAO::TypeCodeFactory::tc_union_factory(), and TAO::TypeCodeFactory::tc_value_factory().
00095 { 00096 CORBA::Boolean byte_order; 00097 00098 // Don't bother demarshaling the encapsulation length. Prefer 00099 // speed over early error checking. Any CDR length related 00100 // failures will be detected when demarshaling the remainder of 00101 // the complex parameter list TypeCode. 00102 00103 if (!(cdr.skip_ulong () // Skip encapsulation length. 00104 && cdr >> TAO_InputCDR::to_boolean (byte_order))) 00105 return false; 00106 00107 cdr.reset_byte_order (byte_order); 00108 00109 return true; 00110 } |
|
|
Demarshal a TypeCode.
|
|
Definition at line 1221 of file TypeCode_CDR_Extraction.cpp. References ACE_NEW_RETURN, add_to_recursion_list(), ACE_InputCDR::byte_order(), find_recursive_tc(), ACE_InputCDR::good_bit(), ACE_InputCDR::rd_ptr(), start_cdr_encap_extraction(), tc_demarshal(), TAO::TypeCodeFactory::TC_Info_List, TYPECODE_INDIRECTION, and union_case_array_type. Referenced by tc_demarshal().
01224 { 01225 CORBA::Long offset; 01226 01227 if (!(cdr >> offset) || offset >= -4) 01228 { 01229 // Offsets must be negative since they point back to a 01230 // TypeCode found earlier in the CDR stream. They must be 01231 // less than -4 since an offset of -4 points back to the 01232 // indirection TypeCode itself, meaning that it would be 01233 // self-indirecting. 01234 return false; 01235 } 01236 01237 TAO_InputCDR indir_stream (cdr.rd_ptr () + offset - sizeof (CORBA::Long), 01238 (-offset) + sizeof (CORBA::Long), 01239 cdr.byte_order ()); 01240 01241 if (!indir_stream.good_bit ()) 01242 { 01243 return false; 01244 } 01245 01246 CORBA::TCKind kind; 01247 if (!(indir_stream >> kind) 01248 01249 // Indirected TypeCode must point to top-level TypeCode. 01250 || static_cast<CORBA::ULong> (kind) == TYPECODE_INDIRECTION 01251 01252 // Only struct, union, event and valuetype TypeCodes may be 01253 // recursive. However non-recursive ALIAS may be indirected. 01254 || !(kind == CORBA::tk_struct 01255 || kind == CORBA::tk_union 01256 || kind == CORBA::tk_value 01257 || kind == CORBA::tk_event 01258 || kind == CORBA::tk_alias) 01259 01260 // Currently all recursive TypeCodes have complex parameter 01261 // lists, meaning they are encoded as CDR encapsulations. 01262 || !start_cdr_encap_extraction (indir_stream)) 01263 { 01264 return false; 01265 } 01266 01267 /** 01268 * @todo Recursive TypeCode demarshaling is currently suboptimal 01269 * due to redundant demarshaling of TypeCode parameters, 01270 * such as repository ID, and excessive 01271 * allocations/copying. 01272 */ 01273 01274 CORBA::String_var id; 01275 if (!(indir_stream >> TAO_InputCDR::to_string (id.out (), 0))) 01276 return false; 01277 01278 if (CORBA::tk_alias == kind) 01279 { 01280 // NOTE: Although Alias may be indirect, they are NOT recursive! 01281 // Just create another type code for this alias. 01282 01283 CORBA::String_var name; 01284 CORBA::TypeCode_var content_type; 01285 if (!(indir_stream >> TAO_InputCDR::to_string (name.out (), 0) 01286 && tc_demarshal (indir_stream, content_type.out (), infos))) 01287 { 01288 return false; 01289 } 01290 01291 typedef TAO::TypeCode::Alias< 01292 CORBA::String_var, 01293 CORBA::TypeCode_var, 01294 TAO::True_RefCount_Policy> typecode_type; 01295 01296 // NOTE: Although Alias may be indirect, they are NOT recursive! 01297 ACE_NEW_RETURN (tc, 01298 typecode_type (kind, 01299 id.in (), 01300 name.in (), 01301 content_type), 01302 false); 01303 return true; 01304 } 01305 01306 // Don't bother demarshaling the rest of the parameters. They will 01307 // be handled by the top-level TypeCode demarshaling call. 01308 01309 // Check if we already have a tc for this RECURSIVE type, if yes, use that 01310 TAO::TypeCodeFactory::TC_Info_List recursive_tc; 01311 if (find_recursive_tc (id.in (), recursive_tc, infos)) 01312 { 01313 tc = recursive_tc[0].type; 01314 } 01315 else switch (kind) 01316 { 01317 case CORBA::tk_struct: 01318 { 01319 typedef ACE_Array_Base< 01320 TAO::TypeCode::Struct_Field< 01321 CORBA::String_var, 01322 CORBA::TypeCode_var> > member_array_type; 01323 01324 typedef TAO::TypeCode::Struct< 01325 CORBA::String_var, 01326 CORBA::TypeCode_var, 01327 member_array_type, 01328 TAO::True_RefCount_Policy> typecode_type; 01329 01330 typedef TAO::TypeCode::Recursive_Type<typecode_type, 01331 CORBA::TypeCode_var, 01332 member_array_type> 01333 recursive_typecode_type; 01334 01335 ACE_NEW_RETURN (tc, 01336 recursive_typecode_type (kind, 01337 id.in ()), 01338 false); 01339 01340 // Since we created a new recursive tc, add it to the "Recursive" list. 01341 return add_to_recursion_list (tc, infos); 01342 } 01343 break; 01344 case CORBA::tk_union: 01345 { 01346 typedef union_case_array_type member_array_type; 01347 01348 typedef TAO::TypeCode::Union< 01349 CORBA::String_var, 01350 CORBA::TypeCode_var, 01351 member_array_type, 01352 TAO::True_RefCount_Policy> typecode_type; 01353 01354 typedef TAO::TypeCode::Recursive_Type<typecode_type, 01355 CORBA::TypeCode_var, 01356 member_array_type> 01357 recursive_typecode_type; 01358 01359 ACE_NEW_RETURN (tc, 01360 recursive_typecode_type (kind, 01361 id.in ()), 01362 false); 01363 01364 // Since we created a new recursive tc, add it to the "Recursive" list. 01365 return add_to_recursion_list (tc, infos); 01366 } 01367 break; 01368 case CORBA::tk_value: 01369 case CORBA::tk_event: 01370 { 01371 typedef ACE_Array_Base< 01372 TAO::TypeCode::Value_Field< 01373 CORBA::String_var, 01374 CORBA::TypeCode_var> > member_array_type; 01375 01376 typedef TAO::TypeCode::Value< 01377 CORBA::String_var, 01378 CORBA::TypeCode_var, 01379 member_array_type, 01380 TAO::True_RefCount_Policy> typecode_type; 01381 01382 typedef TAO::TypeCode::Recursive_Type<typecode_type, 01383 CORBA::TypeCode_var, 01384 member_array_type> 01385 recursive_typecode_type; 01386 01387 ACE_NEW_RETURN (tc, 01388 recursive_typecode_type (kind, 01389 id.in ()), 01390 false); 01391 01392 // Since we created a new recursive tc, add it to the "Recursive" list. 01393 return add_to_recursion_list (tc, infos); 01394 } 01395 break; 01396 default: 01397 return false; // We should never get here. 01398 } 01399 01400 return true; 01401 } |
|
Demarshal an indirected TypeCode.
|
|
Definition at line 114 of file TypeCode_CDR_Extraction.cpp. Referenced by tc_demarshal(), and tc_demarshal_indirection(). |