CORBA::TypeCode_ptr TAO_Repository_i::get_canonical_typecode_i (CORBA::TypeCode_ptr tc) { CORBA::TCKind kind = tc->kind (); switch (kind) { // For all the TCKinds not covered below, no change is needed. default: return CORBA::TypeCode::_duplicate (tc); case CORBA::tk_fixed: throw CORBA::NO_IMPLEMENT (); case CORBA::tk_array: { CORBA::ULong length = tc->length (); CORBA::TypeCode_var ctype = tc->content_type (); CORBA::TypeCode_var canon_ctype = this->get_canonical_typecode_i (ctype.in ()); return this->tc_factory ()->create_array_tc (length, canon_ctype.in ()); } case CORBA::tk_sequence: { CORBA::ULong length = tc->length (); CORBA::TypeCode_var ctype = tc->content_type (); CORBA::TypeCode_var canon_ctype = this->get_canonical_typecode_i (ctype.in ()); return this->tc_factory ()->create_sequence_tc (length, canon_ctype.in ()); } case CORBA::tk_alias: case CORBA::tk_objref: case CORBA::tk_struct: case CORBA::tk_union: case CORBA::tk_enum: case CORBA::tk_except: case CORBA::tk_value: case CORBA::tk_value_box: case CORBA::tk_native: case CORBA::tk_abstract_interface: case CORBA::tk_component: case CORBA::tk_home: { CORBA::String_var id = tc->id (); ACE_TString path; int status = this->config ()->get_string_value (this->repo_ids_key (), id.in (), path); // TODO - something in case the repo id is an empty string, // or if it is not found in this repository if (status != 0) { return CORBA::TypeCode::_nil (); } ACE_Configuration_Section_Key key; this->config ()->expand_path (this->root_key (), path, key, 0); // An ExceptionDef is not an IDLType. if (kind == CORBA::tk_except) { TAO_ExceptionDef_i impl (this->repo_); impl.section_key (key); return impl.type_i (); } else { TAO_IDLType_i *impl = TAO_IFR_Service_Utils::path_to_idltype (path, this); impl->section_key (key); return impl->type_i (); } } } }
bool TAO::TypeCode::Case<StringType, TypeCodeType>::equivalent ( CORBA::ULong index, CORBA::TypeCode_ptr tc ) const { // Member names are ignore when determining equivalence. // Check case TypeCodes. CORBA::TypeCode_ptr const lhs_tc = this->type (); CORBA::TypeCode_var const rhs_tc = tc->member_type (index ); CORBA::Boolean const equivalent_members = lhs_tc->equivalent (rhs_tc.in () ); if (!equivalent_members) return 0; // Check case label. // The label must be equal when determining equivalence, too. return this->equal_label (index, tc ); }
CORBA::Boolean TIDorb::core::typecode::StructTypeCode::equal(CORBA::TypeCode_ptr tc) const { if (!ComplexTypeCode::equal(tc)) return false; if (!m_exhaustive_equal) return true; try { CORBA::ULong length = m_members->length(); if (length != tc->member_count()) return false; for (CORBA::ULong i = 0; i < length; i++) { if (strcmp(member_name(i), tc->member_name(i))) return false; if (! member_type(i)->equal(tc->member_type(i))) return false; } // allright return true; } catch (const CORBA::TypeCode::BadKind& bk) { return false; } catch (const CORBA::TypeCode::Bounds& bn) { return false; } }
CORBA::Boolean TAO::TypeCode::Enum<char const *, char const * const *, TAO::Null_RefCount_Policy>::equal_i ( CORBA::TypeCode_ptr tc ) const { // This call shouldn't throw since CORBA::TypeCode::equal() verified // that the TCKind is the same as our's prior to invoking this // method, meaning that member_count() is supported. CORBA::ULong const tc_nenumerators = tc->member_count (); if (tc_nenumerators != this->nenumerators_) return false; for (CORBA::ULong i = 0; i < this->nenumerators_; ++i) { char const * const & lhs_enumerator = this->enumerators_[i]; char const * const lhs_name = Traits<char const *>::get_string (lhs_enumerator); char const * const rhs_name = tc->member_name (i); if (ACE_OS::strcmp (lhs_name, rhs_name) != 0) return false; } return true; }
void TAO::TypeCode::Indirected_Type::set_recursive_tc (CORBA::TypeCode_ptr tc) { // link only once (should never happen that this is called twice but test anyway) if (this->recursive_tc_ == 0) { ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); if (tc == 0) // should never happen return; // make sure we are the right kind CORBA::TCKind & mutable_kind = const_cast<CORBA::TCKind &> (this->kind_); mutable_kind = tc->kind (); // for every reference beside the master reference (1) // increase the master tc's reference count to keep it // safe while we're referenced outside the master's context for (unsigned long cnt = this->refcount_; cnt > 1 ;--cnt) { tc->tao_duplicate (); } this->recursive_tc_ = tc; } }
CORBA::Boolean TAO::TypeCode::Struct<char const *, CORBA::TypeCode_ptr const *, TAO::TypeCode::Struct_Field<char const *, CORBA::TypeCode_ptr const *> const *, TAO::Null_RefCount_Policy>::equivalent_i ( CORBA::TypeCode_ptr tc) const { // Perform a structural comparison, excluding the name() and // member_name() operations. CORBA::ULong const tc_nfields = tc->member_count (); if (tc_nfields != this->nfields_) return false; for (CORBA::ULong i = 0; i < this->nfields_; ++i) { CORBA::TypeCode_ptr const lhs = Traits<char const *>::get_typecode (this->fields_[i].type); CORBA::TypeCode_var const rhs = tc->member_type (i); CORBA::Boolean const equiv_members = lhs->equivalent (rhs.in ()); if (!equiv_members) return false; } return true; }
bool TAO::TypeCode::Case<StringType, TypeCodeType>::equal (CORBA::ULong index, CORBA::TypeCode_ptr tc ) const { // Check case names. char const * const lhs_name = this->name (); char const * const rhs_name = tc->member_name (index ); if (ACE_OS::strcmp (lhs_name, rhs_name) != 0) return false; // Check case TypeCodes. CORBA::TypeCode_ptr const lhs_tc = this->type (); CORBA::TypeCode_var const rhs_tc = tc->member_type (index ); CORBA::Boolean const equal_members = lhs_tc->equal (rhs_tc.in () ); if (!equal_members) return false; // Check case label. return this->equal_label (index, tc ); }
CORBA::Boolean TAO::TypeCode::Fixed<RefCountPolicy>::equal_i (CORBA::TypeCode_ptr tc) const { // The following call won't throw since CORBA::TypeCode::equal() has // already established the kind of tc is the same as our kind. CORBA::UShort const tc_digits = tc->fixed_digits (); CORBA::UShort const tc_scale = tc->fixed_scale (); return (this->digits_ == tc_digits && this->scale_ == tc_scale); }
CORBA::Boolean TAO::TypeCode::Union<char const *, CORBA::TypeCode_ptr const *, TAO::TypeCode::Case<char const *, CORBA::TypeCode_ptr const *> const * const *, TAO::Null_RefCount_Policy>::equal_i ( CORBA::TypeCode_ptr tc ) const { // These calls shouldn't throw since CORBA::TypeCode::equal() // verified that the TCKind is the same as our's prior to invoking // this method, meaning that the CORBA::tk_union TypeCode methods // are supported. CORBA::ULong const tc_count = tc->member_count (); CORBA::Long tc_def = tc->default_index (); if (tc_count != this->ncases_ || tc_def != this->default_index_) return false; // Check the discriminator type. CORBA::TypeCode_var tc_discriminator = tc->discriminator_type (); CORBA::Boolean const equal_discriminators = Traits<char const *>::get_typecode (this->discriminant_type_)->equal ( tc_discriminator.in ()); if (!equal_discriminators) return false; for (CORBA::ULong i = 0; i < this->ncases_; ++i) { if (this->default_index_ > -1 && static_cast<CORBA::ULong> (this->default_index_) == i) { // Don't bother checking equality of default case label. It // will always be the zero octet (the CDR encoded value is // ignored). continue; } case_type const & lhs_case = *this->cases_[i]; bool const equal_case = lhs_case.equal (i, tc); if (!equal_case) return false; } return true; }
bool TAO::TypeCode::marshal (TAO_OutputCDR & cdr, CORBA::TypeCode_ptr tc, CORBA::ULong offset) { // Marshal the TypeCode TCKind and TypeCode body. // // Update the offset value in case a recursive TypeCode is being // marshaled. return tc != 0 && tc->tao_marshal_kind (cdr) && tc->tao_marshal (cdr, aligned_offset (offset) + sizeof (CORBA::ULong)); }
CORBA::TypeCode_ptr TAO::unaliased_typecode (CORBA::TypeCode_ptr tc) { if (CORBA::is_nil (tc)) { throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 13, CORBA::COMPLETED_NO); } CORBA::TCKind tc_kind = tc->kind (); if (tc_kind == CORBA::tk_alias) { CORBA::TypeCode_var tc_content = CORBA::TypeCode::_duplicate (tc); // Iterate until we get to the actual unaliased type. do { tc_content = tc_content->content_type (); tc_kind = tc_content->kind (); } while (tc_kind == CORBA::tk_alias); return tc_content._retn (); } return CORBA::TypeCode::_duplicate (tc); }
CORBA::Boolean TAO::TypeCode::Union<char const *, CORBA::TypeCode_ptr const *, TAO::TypeCode::Case<char const *, CORBA::TypeCode_ptr const *> const * const *, TAO::Null_RefCount_Policy>::equivalent_i ( CORBA::TypeCode_ptr tc) const { // Perform a structural comparison, excluding the name() and // member_name() operations. CORBA::ULong const tc_count = tc->member_count (); CORBA::Long tc_def = tc->default_index (); if (tc_count != this->ncases_ || tc_def != this->default_index_) return false; CORBA::TypeCode_var tc_discriminator = tc->discriminator_type (); CORBA::Boolean const equiv_discriminators = Traits<char const *>::get_typecode (this->discriminant_type_)->equivalent ( tc_discriminator.in ()); if (!equiv_discriminators) return false; for (CORBA::ULong i = 0; i < this->ncases_; ++i) { if (this->default_index_ > -1 && static_cast<CORBA::ULong> (this->default_index_) == i) { // Don't bother checking equality/equivalence of default // case label. It will always be the zero octet (the CDR // encoded value is ignored). continue; } case_type const & lhs_case = *this->cases_[i]; bool const equivalent_case = lhs_case.equivalent (i, tc); if (!equivalent_case) return false; } return true; }
CORBA::TypeCode_ptr TIDorb::core::typecode::TypeCodeCache::put(CORBA::TypeCode_ptr type) throw (CORBA::INTERNAL) { TIDThr::Synchronized synchro(recursive_mutex); CORBA::RepositoryId rep_id = NULL; try{ rep_id = (char*) type->id(); } catch (const CORBA::TypeCode::BadKind& badKind) { throw CORBA::INTERNAL("Only Complex Typecodes can be put in the cache"); } if (rep_id == NULL) throw CORBA::INTERNAL("Cannot get RepositoryId"); char *pointer = NULL; int i = 0; for (i = 0; i < m_index; i++) { pointer = m_table[i]->m_repid; if (strcmp(pointer,rep_id) == 0) break; pointer = NULL; } if (pointer) { // Anybody use return pointer (duplicate generates mem leak) // return CORBA::TypeCode::_duplicate(m_table[i]->m_typecode); return m_table[i]->m_typecode; } else { if (m_index == m_max) { m_cache** mtable = NULL; m_max *= 2; #if !defined(__linux__) && !defined(__sun) mtable = (m_cache**) new m_cache*[m_max]; #else mtable = new m_cache*[m_max]; #endif memcpy(mtable, m_table, m_max/2*sizeof(m_cache*)); delete[] m_table; m_table = mtable; } m_table[m_index] = new m_cache; m_table[m_index]->m_repid = CORBA::string_dup(rep_id); m_table[m_index++]->m_typecode = type; // Yet duplicate by caller // m_table[m_index++]->m_typecode = CORBA::TypeCode::_duplicate(type); // Anybody use return pointer (duplicate generates mem leak) //return CORBA::TypeCode::_duplicate(type); // is leak if no catch ?? return type; } return NULL; }
CORBA::Boolean TAO::TypeCode::Struct<char const *, CORBA::TypeCode_ptr const *, TAO::TypeCode::Struct_Field<char const *, CORBA::TypeCode_ptr const *> const *, TAO::Null_RefCount_Policy>::equal_i ( CORBA::TypeCode_ptr tc) const { // This call shouldn't throw since CORBA::TypeCode::equal() verified // that the TCKind is the same as our's prior to invoking this // method, meaning that member_count() is supported. CORBA::ULong const tc_nfields = tc->member_count (); if (tc_nfields != this->nfields_) return false; for (CORBA::ULong i = 0; i < this->nfields_; ++i) { Struct_Field<char const *, CORBA::TypeCode_ptr const *> const & lhs_field = this->fields_[i]; char const * const lhs_name = Traits<char const *>::get_string (lhs_field.name); char const * const rhs_name = tc->member_name (i ); if (ACE_OS::strcmp (lhs_name, rhs_name) != 0) return false; CORBA::TypeCode_ptr const lhs_tc = Traits<char const *>::get_typecode (lhs_field.type); CORBA::TypeCode_var const rhs_tc = tc->member_type (i); CORBA::Boolean const equal_members = lhs_tc->equal (rhs_tc.in ()); if (!equal_members) return false; } return true; }
CORBA::Boolean TAO::TypeCode::String<RefCountPolicy>::equal_i (CORBA::TypeCode_ptr tc) const { // The following call won't throw since CORBA::TypeCode::equal() has // already established the kind of tc is the same as our kind. CORBA::ULong const tc_length = tc->length (); return (this->length_ == tc_length); }
CORBA::Boolean TAO::TypeCode::Value<StringType, TypeCodeType, FieldArrayType, RefCountPolicy>::equivalent_i (CORBA::TypeCode_ptr tc) const { CORBA::ValueModifier const tc_type_modifier = tc->type_modifier (); if (tc_type_modifier != this->type_modifier_) return false; CORBA::TypeCode_var rhs_concrete_base_type = tc->concrete_base_type (); CORBA::Boolean const equivalent_concrete_base_types = this->equivalent (rhs_concrete_base_type.in ()); if (!equivalent_concrete_base_types) return false; // Perform a structural comparison, excluding the name() and // member_name() operations. CORBA::ULong const tc_nfields = tc->member_count (); if (tc_nfields != this->nfields_) return false; for (CORBA::ULong i = 0; i < this->nfields_; ++i) { Value_Field<StringType, TypeCodeType> const & lhs_field = this->fields_[i]; CORBA::Visibility const lhs_visibility = lhs_field.visibility; CORBA::Visibility const rhs_visibility = tc->member_visibility (i); if (lhs_visibility != rhs_visibility) return false; CORBA::TypeCode_ptr const lhs_tc = Traits<StringType>::get_typecode (lhs_field.type); CORBA::TypeCode_var const rhs_tc = tc->member_type (i); CORBA::Boolean const equiv_types = lhs_tc->equivalent (rhs_tc.in () ); if (!equiv_types) return false; } return true; }
void TAO::TypeCode::Indirected_Type::tao_release (void) { unsigned long newcount; CORBA::TypeCode_ptr curmaster; { ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); newcount = --this->refcount_; curmaster = this->recursive_tc_; } if (newcount >= 1 && curmaster) { curmaster->tao_release (); } else if (newcount == 0) { delete this; } }
DynArrayImpl::DynArrayImpl(DynamicAny::DynAnyFactory_ptr factory, TIDorb::core::TIDORB* orb, CORBA::TypeCode_ptr type, CORBA::TypeCode_ptr real_type) throw(CORBA::SystemException) : DynComposite(factory, orb, type, real_type) { try { _component_count = real_type->length(); } catch (const CORBA::TypeCode::BadKind& bk) { throw CORBA::BAD_TYPECODE(); } this->TIDThr::RefCounter::_add_ref(); }
CORBA::Boolean TAO::TypeCode::Alias<StringType, TypeCodeType, RefCountPolicy>::equal_i (CORBA::TypeCode_ptr tc) const { // The CORBA::TypeCode base class already verified equality of the // base attributes (id and name). Perform an equality comparison of // the content. CORBA::TypeCode_var rhs_content_type = tc->content_type (); return Traits<StringType>::get_typecode (this->content_type_)->equal ( rhs_content_type.in ()); }
CORBA::Boolean TAO::TypeCode::Enum<char const *, char const * const *, TAO::Null_RefCount_Policy>::equivalent_i ( CORBA::TypeCode_ptr tc ) const { // Perform a structural comparison, excluding the name() and // member_name() operations. CORBA::ULong const tc_nenumerators = tc->member_count (); if (tc_nenumerators != this->nenumerators_) return false; return true; }
void DynAnyAnalyzer::analyze_basic_seq (CORBA::TypeCode_ptr tc, DynamicAny::DynAny_ptr da) { CORBA::TypeCode_var ct = tc->content_type (); CORBA::TCKind tk = ct->kind (); tab (level_); if (debug_) { ACE_DEBUG ((LM_DEBUG, "BASIC TYPE SEQUENCE\n")); } switch (tk) { CASEBS (boolean, Boolean, " Value (bool) = %d\n"); CASEBS (octet, Octet, " Value (octet) = %c\n"); CASEBS (char, Char, " Value (char) = %c\n"); CASEBS (wchar, WChar, " Value (wchar) = %u\n"); CASEBS (short, Short, " Value (short) = %d\n"); CASEBS (ushort, UShort, " Value (ushort) = %u\n"); CASEBS (long, Long, " Value (long) = %d\n"); CASEBS (ulong, ULong, " Value (ulong) = %u\n"); CASEBS (longlong, LongLong, " Value (longlong) = %Ld\n"); CASEBS (ulonglong, ULongLong, " Value (ulonglong) = %Lu\n"); CASEBS (float, Float, " Value (float) = %f\n"); CASEBS (double, Double, " Value (double) = %f\n"); case CORBA::tk_longdouble: default: tab (level_); if (debug_) { ACE_DEBUG ((LM_DEBUG, " unhandled typecode = %d\n", static_cast<int> (tk))); } break; } }
DynStructImpl::DynStructImpl(DynamicAny::DynAnyFactory_ptr factory, TIDorb::core::TIDORB* orb, CORBA::TypeCode_ptr type, CORBA::TypeCode_ptr real_type) throw(CORBA::SystemException) : DynComposite(factory, orb, type, real_type) { try { _component_count = real_type->member_count(); } catch(CORBA::TypeCode::BadKind) { throw CORBA::BAD_TYPECODE(); } _current = (_component_count == 0) ? -1 : 0; this->TIDThr::RefCounter::_add_ref(); }
bool TAO::TypeCode::Case_Enum_T<StringType, TypeCodeType>::equal_label (::CORBA::ULong index, ::CORBA::TypeCode_ptr tc) const { CORBA::Any_var any = tc->member_label (index); TAO_OutputCDR out_cdr; if (! any->impl ()->marshal_value (out_cdr)) { return false; } TAO_InputCDR in_cdr (out_cdr); CORBA::ULong tc_label = ACE_UINT32_MAX; if (! in_cdr.read_ulong (tc_label)) { return false; } return (this->label_ == tc_label); }
CORBA::Boolean TAO::TypeCode::Value<char const *, CORBA::TypeCode_ptr const *, TAO::TypeCode::Value_Field<char const *, CORBA::TypeCode_ptr const *> const *, TAO::Null_RefCount_Policy>::equal_i ( CORBA::TypeCode_ptr tc) const { // None of these calls should throw since CORBA::TypeCode::equal() // verified that the TCKind is the same as our's prior to invoking // this method. CORBA::ValueModifier const tc_type_modifier = tc->type_modifier (); if (tc_type_modifier != this->type_modifier_) return false; CORBA::TypeCode_var rhs_concrete_base_type = tc->concrete_base_type (); CORBA::Boolean const equal_concrete_base_types = this->equal (rhs_concrete_base_type.in ()); if (!equal_concrete_base_types) return false; CORBA::ULong const tc_nfields = tc->member_count (); if (tc_nfields != this->nfields_) return false; for (CORBA::ULong i = 0; i < this->nfields_; ++i) { Value_Field<char const *, CORBA::TypeCode_ptr const *> const & lhs_field = this->fields_[i]; CORBA::Visibility const lhs_visibility = lhs_field.visibility; CORBA::Visibility const rhs_visibility = tc->member_visibility (i); if (lhs_visibility != rhs_visibility) return false; char const * const lhs_name = Traits<char const *>::get_string (lhs_field.name);; char const * const rhs_name = tc->member_name (i); if (ACE_OS::strcmp (lhs_name, rhs_name) != 0) return false; CORBA::TypeCode_ptr const lhs_tc = Traits<char const *>::get_typecode (lhs_field.type); CORBA::TypeCode_var const rhs_tc = tc->member_type (i); CORBA::Boolean const equal_members = lhs_tc->equal (rhs_tc.in ()); if (!equal_members) return false; } return true; }
DataType DataType_Handler::data_type ( const CORBA::TypeCode_ptr& src) { DANCE_TRACE("DataType_Handler::data_type"); DataType type; switch (src->kind ()) { case ::CORBA::tk_null: type.kind (TCKind::tk_null); break; case CORBA::tk_short: type.kind (TCKind::tk_short); break; case CORBA::tk_long: type.kind (TCKind::tk_long); break; case CORBA::tk_ushort: type.kind (TCKind::tk_ushort); break; case CORBA::tk_ulong: type.kind (TCKind::tk_ulong); break; case CORBA::tk_float: type.kind (TCKind::tk_float); break; case CORBA::tk_double: type.kind (TCKind::tk_double); break; case CORBA::tk_boolean: type.kind (TCKind::tk_boolean); break; case CORBA::tk_char: type.kind (TCKind::tk_char); break; case CORBA::tk_octet: type.kind (TCKind::tk_octet); break; case CORBA::tk_string: type.kind (TCKind::tk_string); break; case CORBA::tk_longlong: type.kind (TCKind::tk_longlong); break; case CORBA::tk_ulonglong: type.kind (TCKind::tk_ulonglong); break; case CORBA::tk_longdouble: type.kind (TCKind::tk_longdouble); break; case CORBA::tk_wchar: type.kind (TCKind::tk_wchar); break; case CORBA::tk_wstring: type.kind (TCKind::tk_wstring); break; case CORBA::tk_any: type.kind (TCKind::tk_any); break; case CORBA::tk_TypeCode: type.kind (TCKind::tk_TypeCode); default: DANCE_DEBUG (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, "DataType_Handler::data_type - Invalid typecode\n")); throw Config_Error ("", "Invalid typecode"); } return type; }
void TAO_DynAny_i::check_typecode (CORBA::TypeCode_ptr tc) { // Check to see if it's a simple type. CORBA::TCKind tk = TAO_DynAnyFactory::unalias (tc); switch (tk) { case CORBA::tk_null: case CORBA::tk_void: case CORBA::tk_short: case CORBA::tk_long: case CORBA::tk_ushort: case CORBA::tk_ulong: case CORBA::tk_float: case CORBA::tk_double: case CORBA::tk_longlong: case CORBA::tk_ulonglong: case CORBA::tk_boolean: case CORBA::tk_char: case CORBA::tk_wchar: case CORBA::tk_octet: case CORBA::tk_any: case CORBA::tk_TypeCode: case CORBA::tk_objref: case CORBA::tk_string: case CORBA::tk_wstring: case CORBA::tk_longdouble: break; case CORBA::tk_sequence: if (tc->equivalent (CORBA::_tc_BooleanSeq) || tc->equivalent (CORBA::_tc_OctetSeq) || tc->equivalent (CORBA::_tc_CharSeq) || tc->equivalent (CORBA::_tc_WCharSeq) || tc->equivalent (CORBA::_tc_ShortSeq) || tc->equivalent (CORBA::_tc_UShortSeq) || tc->equivalent (CORBA::_tc_LongSeq) || tc->equivalent (CORBA::_tc_ULongSeq) || tc->equivalent (CORBA::_tc_LongLongSeq) || tc->equivalent (CORBA::_tc_ULongLongSeq) || tc->equivalent (CORBA::_tc_FloatSeq) || tc->equivalent (CORBA::_tc_DoubleSeq) || tc->equivalent (CORBA::_tc_LongDoubleSeq)) { // Otherwise fall through. break; } // fallthrough default: throw DynamicAny::DynAnyFactory::InconsistentTypeCode (); } }
// In this version of TAO typecodes are based on CDR, we have to // verify that CDR offers the services needed for Typecode... int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); static const CORBA::TypeCode_ptr tcs[]= { CORBA::_tc_null, CORBA::_tc_void, CORBA::_tc_short, CORBA::_tc_long, CORBA::_tc_ushort, CORBA::_tc_ulong, CORBA::_tc_float, CORBA::_tc_double, CORBA::_tc_boolean, CORBA::_tc_char, CORBA::_tc_octet, CORBA::_tc_any, CORBA::_tc_TypeCode, CORBA::_tc_Principal, CORBA::_tc_Object, // CORBA::_tc_struct, // CORBA::_tc_union, // CORBA::_tc_enum, CORBA::_tc_string, // CORBA::_tc_sequence, // CORBA::_tc_array, // CORBA::_tc_alias, // CORBA::_tc_except, CORBA::_tc_longlong, CORBA::_tc_ulonglong, CORBA::_tc_longdouble, CORBA::_tc_wchar, CORBA::_tc_wstring, CORBA::_tc_UNKNOWN, CORBA::_tc_BAD_PARAM, CORBA::_tc_NO_MEMORY, CORBA::_tc_IMP_LIMIT, CORBA::_tc_COMM_FAILURE, CORBA::_tc_INV_OBJREF, CORBA::_tc_OBJECT_NOT_EXIST, CORBA::_tc_NO_PERMISSION, CORBA::_tc_INTERNAL, CORBA::_tc_MARSHAL, CORBA::_tc_INITIALIZE, CORBA::_tc_NO_IMPLEMENT, CORBA::_tc_BAD_TYPECODE, CORBA::_tc_BAD_OPERATION, CORBA::_tc_NO_RESOURCES, CORBA::_tc_NO_RESPONSE, CORBA::_tc_PERSIST_STORE, CORBA::_tc_BAD_INV_ORDER, CORBA::_tc_TRANSIENT, CORBA::_tc_FREE_MEM, CORBA::_tc_INV_IDENT, CORBA::_tc_INV_FLAG, CORBA::_tc_INTF_REPOS, CORBA::_tc_BAD_CONTEXT, CORBA::_tc_OBJ_ADAPTER, CORBA::_tc_DATA_CONVERSION, CORBA::TypeCode::_tc_Bounds, CORBA::TypeCode::_tc_BadKind }; static int n = sizeof (tcs) / sizeof (tcs[0]); for (const CORBA::TypeCode_ptr *i = tcs; i != tcs + n; ++i) { CORBA::TypeCode_ptr tc = *i; CORBA::TCKind k = tc->kind (); switch (k) { case CORBA::tk_objref: case CORBA::tk_struct: case CORBA::tk_union: case CORBA::tk_enum: case CORBA::tk_alias: case CORBA::tk_except: { const char *id = tc->id (); const char *name = tc->name (); CORBA::ULong length = 0; // tc->length (TAO_TRY_ENV); if (TAO_debug_level > 0) { ACE_DEBUG ((LM_DEBUG, "ID = '%C'\n" "%{%{ NAME = %C%$" " KIND = %d%$" " LENGTH = %d" "%}%}\n", (id?id:"empty ID"), (name?name:"empty name"), k, length)); } break; } default: if (TAO_debug_level > 0) { ACE_DEBUG ((LM_DEBUG, "basic type: %d\n", k)); } break; } } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("TC"); return 1; } return 0; }
string IDLBase::tcToName(CORBA::TypeCode_ptr type) { switch(type->kind()) { case CORBA::tk_null: return ""; break; case CORBA::tk_void: return "void"; break; case CORBA::tk_short: return "short"; break; case CORBA::tk_long: return "long"; break; case CORBA::tk_longlong: return "long long"; break; case CORBA::tk_ushort: return "unsigned short"; break; case CORBA::tk_ulong: return "unsigned long"; break; case CORBA::tk_ulonglong: return "unsigned long long"; break; case CORBA::tk_float: return "float"; break; case CORBA::tk_double: return "double"; break; case CORBA::tk_longdouble: return "long double"; break; case CORBA::tk_boolean: return "boolean"; break; case CORBA::tk_char: return "char"; break; case CORBA::tk_wchar: return "wchar"; break; case CORBA::tk_octet: return "octet"; break; case CORBA::tk_any: return "any"; break; case CORBA::tk_TypeCode: return "CORBA::TypeCode"; break; case CORBA::tk_Principal: return "CORBA::Principal"; break; case CORBA::tk_fixed: break; case CORBA::tk_objref: try { return map_absolute_name(repository_->lookup_id(type->id())); } catch (...) { // CORBA::Object is not in the repository // but it can be used as parameter return "Object"; } break; case CORBA::tk_abstract_interface: case CORBA::tk_local_interface: case CORBA::tk_native: case CORBA::tk_struct: case CORBA::tk_except: case CORBA::tk_union: case CORBA::tk_enum: case CORBA::tk_sequence: case CORBA::tk_array: case CORBA::tk_alias: case CORBA::tk_value_box: case CORBA::tk_value: return map_absolute_name(repository_->lookup_id(type->id())); break; case CORBA::tk_string: return "string"; break; case CORBA::tk_wstring: return "wstring"; break; default: std::cerr << "Unknown type code (" << (int)type->kind() << ")" << std::endl; assert(false); } return ""; }
CORBA::Boolean Any_Basic_Impl::extract (const CORBA::Any &any, CORBA::TypeCode_ptr tc, void *_tao_elem) { try { CORBA::TypeCode_ptr any_tc = any._tao_get_typecode (); CORBA::Boolean const _tao_equiv = any_tc->equivalent (tc); if (!_tao_equiv) { return false; } TAO::Any_Impl * const impl = any.impl (); if (impl && !impl->encoded ()) { TAO::Any_Basic_Impl * const narrow_impl = dynamic_cast<TAO::Any_Basic_Impl *> (impl); if (narrow_impl == 0) { return false; } Any_Basic_Impl::assign_value (_tao_elem, narrow_impl); return true; } TAO::Any_Basic_Impl *replacement = TAO::Any_Basic_Impl::create_empty (any_tc); auto_ptr<TAO::Any_Basic_Impl> replacement_safety (replacement); // We know this will work since the unencoded case is covered above. TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); if (!unk) return false; // Get the kind of the type where we are extracting in ie. the // aliased type if there are any. Passing the aliased kind // will not help. CORBA::TCKind const tck = tc->kind (); // We don't want the rd_ptr of unk to move, in case it is // shared by another Any. This copies the state, not the buffer. TAO_InputCDR for_reading (unk->_tao_get_cdr ()); CORBA::Boolean const good_decode = replacement->demarshal_value (for_reading, static_cast<CORBA::Long> (tck)); if (good_decode) { Any_Basic_Impl::assign_value (_tao_elem, replacement, tck); const_cast<CORBA::Any &> (any).replace (replacement); replacement_safety.release (); return true; } // Duplicated by Any_Impl base class constructor. ::CORBA::release (any_tc); } catch (const ::CORBA::Exception&) { } return false; }