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 (); } } } }
VALUE rCORBA_Request_arguments(VALUE self) { CORBA::Request_ptr _req = r2tao_Request_r2t(self); R2TAO_TRY { CORBA::ULong arg_len = _req->arguments ()->count (); VALUE rargs = rb_ary_new (); for (CORBA::ULong a=0; a<arg_len ;++a) { VALUE rarg = rb_ary_new (); CORBA::NamedValue_ptr arg = _req->arguments ()->item (a); rb_ary_push (rarg, rb_str_new2 (arg->name ())); if (ACE_BIT_ENABLED (arg->flags (), CORBA::ARG_IN)) rb_ary_push (rarg, ULONG2NUM (r2tao_IN_ARG)); else if (ACE_BIT_ENABLED (arg->flags (), CORBA::ARG_OUT)) rb_ary_push (rarg, ULONG2NUM (r2tao_OUT_ARG)); else if (ACE_BIT_ENABLED (arg->flags (), CORBA::ARG_INOUT)) rb_ary_push (rarg, ULONG2NUM (r2tao_INOUT_ARG)); CORBA::TypeCode_var atc = arg->value ()->type (); VALUE arg_rtc = r2tao_Typecode_t2r(atc.in (), _req->target ()->_get_orb ()); rb_ary_push (rarg, arg_rtc); VALUE arg_val = r2tao_Typecode_Any2Ruby (*arg->value (), atc.in (), arg_rtc, arg_rtc, _req->target ()->_get_orb ()); rb_ary_push (rarg, arg_val); rb_ary_push (rargs, rarg); } return rargs; } R2TAO_CATCH; return Qnil; }
void TAO_DynEnum_i::set_as_string (const char *value_as_string) { CORBA::TypeCode_var ct = TAO_DynAnyFactory::strip_alias (this->type_.in ()); CORBA::ULong count = ct.in ()->member_count (); CORBA::ULong i; const char *temp = 0; for (i = 0; i < count; ++i) { temp = ct.in ()->member_name (i); if (!ACE_OS::strcmp (value_as_string, temp)) { break; } } if (i < count) { this->value_ = i; } else { throw DynamicAny::DynAny::InvalidValue (); } }
CORBA::TypeCode_ptr TAO_ValueBoxDef_i::type_i (void) { ACE_TString id; this->repo_->config ()->get_string_value (this->section_key_, "id", id); ACE_TString name; this->repo_->config ()->get_string_value (this->section_key_, "name", name); ACE_TString boxed_type_path; this->repo_->config ()->get_string_value (this->section_key_, "boxed_type", boxed_type_path); TAO_IDLType_i *impl = TAO_IFR_Service_Utils::path_to_idltype (boxed_type_path, this->repo_); CORBA::TypeCode_var tc = impl->type_i (); return this->repo_->tc_factory ()->create_value_box_tc (id.c_str (), name.c_str (), tc.in ()); }
TAO_Literal_Constraint:: TAO_Literal_Constraint (CORBA::Any* any) { CORBA::Any& any_ref = *any; CORBA::TypeCode_var type = any_ref.type (); // @@ No where to throw exception back. CORBA::TCKind corba_type = CORBA::tk_null; try { corba_type = type->kind (); } catch (const CORBA::Exception&) { // @@ Seth: Don't know what else to do. Make sure we can tell // when this constructor fails. return; } this->type_ = TAO_Literal_Constraint::comparable_type (type.in ()); switch (this->type_) { case TAO_SIGNED: this->op_.integer_ = 0; if (corba_type == CORBA::tk_short) { CORBA::Short sh; any_ref >>= sh; this->op_.integer_ = static_cast<CORBA::LongLong> (sh); } else if (corba_type == CORBA::tk_long)
CORBA::TypeCode_ptr DynAlias_Handler::create_typecode (const DataType &type) { DANCE_TRACE("DynAlias_Handler::create_typecode"); if (!type.alias_p ()) { DANCE_DEBUG (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, ACE_TEXT ("ERROR: Alias type description required"))); throw Config_Error (ACE_TEXT (""), ACE_TEXT ("Did not find expected alias type description, tk_kind"\ "may be wrong.")); } CORBA::TypeCode_var tc = DYNANY_HANDLER->orb ()->create_alias_tc (ACE_TEXT_ALWAYS_CHAR (type.alias ().typeId ().c_str ()), ACE_TEXT_ALWAYS_CHAR (type.alias ().name ().c_str ()), DYNANY_HANDLER->create_typecode (type.alias ().elementType ())); DYNANY_HANDLER->register_typecode (type.alias ().typeId (), tc.in ()); return tc._retn (); }
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 ); }
void TAO_DynArray_i::init (CORBA::TypeCode_ptr tc) { CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc); if (kind != CORBA::tk_array) { throw DynamicAny::DynAnyFactory::InconsistentTypeCode (); } this->type_ = CORBA::TypeCode::_duplicate (tc); CORBA::ULong numfields = this->get_tc_length (tc); // Resize the array. this->da_members_.size (numfields); this->init_common (); CORBA::TypeCode_var elemtype = this->get_element_type (); for (CORBA::ULong i = 0; i < numfields; ++i) { // Recursively initialize each element. this->da_members_[i] = TAO::MakeDynAnyUtils::make_dyn_any_t<CORBA::TypeCode_ptr> ( elemtype.in (), elemtype.in (), this->allow_truncation_ ); } }
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; }
CORBA::TypeCode_ptr TAO_AliasDef_i::type_i (void) { ACE_TString id; this->repo_->config ()->get_string_value (this->section_key_, ACE_TEXT("id"), id); ACE_TString name; this->repo_->config ()->get_string_value (this->section_key_, ACE_TEXT("name"), name); ACE_TString original_type; this->repo_->config ()->get_string_value (this->section_key_, ACE_TEXT("original_type"), original_type); TAO_IDLType_i *impl = TAO_IFR_Service_Utils::path_to_idltype (original_type, this->repo_); if (0 == impl) { throw CORBA::OBJECT_NOT_EXIST(); } CORBA::TypeCode_var tc = impl->type_i (); return this->repo_->tc_factory ()->create_alias_tc (id.c_str (), name.c_str (), tc.in ()); }
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 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; }
char * TAO_DynEnum_i::get_as_string (void) { CORBA::TypeCode_var ct = TAO_DynAnyFactory::strip_alias (this->type_.in ()); const char *retval = ct.in ()->member_name (this->value_); return CORBA::string_dup (retval); }
void TAO_DynEnum_i::set_as_ulong (CORBA::ULong value_as_ulong) { CORBA::TypeCode_var ct = TAO_DynAnyFactory::strip_alias (this->type_.in ()); CORBA::ULong const max = ct.in ()->member_count (); if (value_as_ulong < max) { this->value_ = value_as_ulong; } else { throw DynamicAny::DynAny::InvalidValue (); } }
CORBA::Boolean TAO_Log_Constraint_Visitor::struct_does_contain ( const CORBA::Any *any, TAO_ETCL_Literal_Constraint &item ) { try { TAO_DynStruct_i dyn_struct; dyn_struct.init (*any); DynamicAny::NameValuePairSeq_var members = dyn_struct.get_members (); CORBA::ULong length = members->length (); CORBA::TypeCode_var tc; CORBA::TCKind kind; for (CORBA::ULong i = 0; i < length; ++i) { tc = members[i].value.type (); kind = TAO_DynAnyFactory::unalias (tc.in ()); // The literal and the struct member must be // of the same simple type. CORBA::Boolean match = this->simple_type_match (item.expr_type (), kind); if (!match) { return false; } TAO_ETCL_Literal_Constraint element (&members[i].value); if (item == element) { return true; } } } catch (const CORBA::Exception&) { return false; } return false; }
CORBA::Boolean TAO_Log_Constraint_Visitor::array_does_contain ( const CORBA::Any *any, TAO_ETCL_Literal_Constraint &item ) { try { CORBA::TypeCode_var type = any->type (); CORBA::TCKind kind = TAO_DynAnyFactory::unalias (type.in ()); // The literal and the array elements must be // of the same simple type. CORBA::Boolean match = this->simple_type_match (item.expr_type (), kind); if (!match) { return false; } TAO_DynArray_i dyn_array; dyn_array.init (*any); DynamicAny::AnySeq_var any_seq = dyn_array.get_elements (); CORBA::ULong length = any_seq->length (); for (CORBA::ULong i = 0; i < length; ++i) { TAO_ETCL_Literal_Constraint element (&any_seq[i]); if (item == element) { return true; } } } catch (const CORBA::Exception&) { return false; } return false; }
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; }
VALUE rCORBA_Request_exceptions(VALUE self) { CORBA::Request_ptr _req = r2tao_Request_r2t(self); R2TAO_TRY { CORBA::ORB_var _orb = _req->target ()->_get_orb (); CORBA::ULong exc_len = _req->exceptions ()->count (); VALUE rexc = rb_ary_new (); for (CORBA::ULong x=0; x<exc_len ;++x) { CORBA::TypeCode_var xtc = _req->exceptions ()->item (x); VALUE x_rtc = r2tao_Typecode_t2r(xtc.in (), _orb.in ()); rb_ary_push (rexc, x_rtc); } return rexc; } R2TAO_CATCH; return Qnil; }
CORBA::TypeCode_ptr TAO_UnionDef_i::type_i (void) { ACE_TString id; this->repo_->config ()->get_string_value (this->section_key_, "id", id); //--------------------------------------------------------------------------- // Have we already seen this union definition at an outer scope? // If yes, return a recursive type code to signal the nesting. // If not, record this new union id in our stack (it will automatically be // removed when NowSeenThis goes out of scope). //--------------------------------------------------------------------------- if (TAO_RecursiveDef_OuterScopes::SeenBefore( id )) return this->repo_->tc_factory ()-> create_recursive_tc ( id.c_str ()); TAO_RecursiveDef_OuterScopes NowSeenThis( id ); //--------------------------------------------------------------------------- // Create a new type code for this structure; the create_union_tc() call // that follows may recursivly call this method again if one of its children // refers to a union (which is the point of the above NowSeenThis stack). //--------------------------------------------------------------------------- ACE_TString name; this->repo_->config ()->get_string_value (this->section_key_, "name", name); CORBA::TypeCode_var tc = this->discriminator_type_i (); CORBA::UnionMemberSeq_var members = this->members_i (); return this->repo_->tc_factory ()->create_union_tc (id.c_str (), name.c_str (), tc.in (), members.in ()); }
void TAO_DynUnion_i::init (const CORBA::Any& any) { CORBA::TypeCode_var tc = any.type (); CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ()); if (kind != CORBA::tk_union) { throw DynamicAny::DynAnyFactory::InconsistentTypeCode (); } // Initialize the typecode holder. this->type_ = tc; this->init_common (); // Set the from_factory arg to TRUE, so any problems will throw // InconsistentTypeCode. this->set_from_any (any); }
void DII_Invocation_Adapter::invoke (TAO::Exception_Data * /*ex_data*/, unsigned long ex_count) { // Convert DII exception list to a form the invocation can use // to filter raised user exceptions. ex_count = this->exception_list_->count (); ACE_NEW_THROW_EX (this->ex_data_, TAO::Exception_Data[ex_count], CORBA::NO_MEMORY ()); for (unsigned long l=0; l<ex_count ;++l) { CORBA::TypeCode_var xtc = this->exception_list_->item (l); this->ex_data_[l].id = xtc->id (); this->ex_data_[l].alloc = 0; #if TAO_HAS_INTERCEPTORS == 1 this->ex_data_[l].tc_ptr = xtc.in (); #endif } Invocation_Adapter::invoke (this->ex_data_, ex_count); }
void TAO_DynEnum_i::init (const CORBA::Any &any) { CORBA::TypeCode_var tc = any.type (); CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ()); if (kind != CORBA::tk_enum) { throw DynamicAny::DynAnyFactory::InconsistentTypeCode (); } this->type_ = tc; TAO::Any_Impl *impl = any.impl (); if (impl->encoded ()) { TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); if (!unk) throw CORBA::INTERNAL (); // We don't want unk's rd_ptr to move, in case we are shared by // another Any, so we use this to copy the state, not the buffer. TAO_InputCDR for_reading (unk->_tao_get_cdr ()); for_reading.read_ulong (this->value_); } else { TAO_OutputCDR out; impl->marshal_value (out); TAO_InputCDR in (out); in.read_ulong (this->value_); } this->init_common (); }
CORBA::Boolean TAO_Log_Constraint_Visitor::union_does_contain ( const CORBA::Any *any, TAO_ETCL_Literal_Constraint &item ) { try { TAO_DynUnion_i dyn_union; dyn_union.init (*any); DynamicAny::DynAny_var cc = dyn_union.current_component (); CORBA::Any_var member = cc->to_any (); CORBA::TypeCode_var tc = member->type (); CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ()); // The literal and the union member must be // of the same simple type. CORBA::Boolean match = this->simple_type_match (item.expr_type (), kind); if (!match) { return false; } TAO_ETCL_Literal_Constraint element (&member.inout ()); return (item == element); } catch (const CORBA::Exception&) { return false; } }
CORBA::Any * TAO_ConstantDef_i::value_i (void) { CORBA::TypeCode_var tc = this->type_i (); void *ref = 0; size_t length = 0; this->repo_->config ()->get_binary_value ( this->section_key_, "value", ref, length ); char *data = static_cast<char *> (ref); ACE_Auto_Basic_Array_Ptr<char> safety (data); ACE_Message_Block mb (data, length); mb.length (length); TAO_InputCDR in_cdr (&mb); CORBA::Any *retval = 0; ACE_NEW_THROW_EX (retval, CORBA::Any, CORBA::NO_MEMORY ()); TAO::Unknown_IDL_Type *impl = 0; ACE_NEW_THROW_EX (impl, TAO::Unknown_IDL_Type (tc.in (), in_cdr), CORBA::NO_MEMORY ()); retval->replace (impl); return retval; }
int TAO_Log_Constraint_Visitor::visit_in ( ETCL_Binary_Expr *binary) { int return_value = -1; ETCL_Constraint *lhs = binary->lhs (); // Determine if the left operand is contained in the right. if (lhs->accept (this) == 0) { TAO_ETCL_Literal_Constraint left; this->queue_.dequeue_head (left); ETCL_Constraint *rhs = binary->rhs (); if (rhs->accept (this) == 0) { TAO_ETCL_Literal_Constraint bag; this->queue_.dequeue_head (bag); if (bag.expr_type () == ETCL_COMPONENT) { CORBA::Any_ptr any_ptr = 0; ACE_NEW_RETURN (any_ptr, CORBA::Any, -1); CORBA::Any_var component = any_ptr; component->replace (bag); component->impl ()->_add_ref (); CORBA::TCKind kind = CORBA::tk_null; try { CORBA::TypeCode_var tc = component->type (); kind = TAO_DynAnyFactory::unalias (tc.in ()); } catch (const CORBA::Exception&) { return return_value; } CORBA::Boolean result = 0; switch (kind) { case CORBA::tk_sequence: result = this->sequence_does_contain (&component.in (), left); break; case CORBA::tk_array: result = this->array_does_contain (&component.in (), left); break; case CORBA::tk_struct: result = this->struct_does_contain (&component.in (), left); break; case CORBA::tk_union: result = this->union_does_contain (&component.in (), left); break; case CORBA::tk_any: result = this->any_does_contain (&component.in (), left); break; default: return return_value; } this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); return_value = 0; } } } return return_value; }
int TAO_Log_Constraint_Visitor::visit_component_array ( ETCL_Component_Array *array) { try { // If we are here (from visit_component) the Any containing the // component as found in property_lookup_ will be in current_member_. CORBA::TypeCode_var tc = this->current_member_->type (); CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ()); DynamicAny::DynAny_var member; CORBA::Boolean success = 0; CORBA::ULong slot = (CORBA::ULong) *array->integer (); switch (kind) { case CORBA::tk_array: { TAO_DynEnum_i dyn_array; dyn_array.init (this->current_member_.in ()); success = dyn_array.seek (slot); if (success == 0) { return -1; } member = dyn_array.current_component (); break; } case CORBA::tk_sequence: { TAO_DynStruct_i dyn_sequence; dyn_sequence.init (this->current_member_.in ()); success = dyn_sequence.seek (slot); if (success == 0) { return -1; } member = dyn_sequence.current_component (); break; } // Enums and sequences are the only two cases handled // by Component_Array. default: return -1; } CORBA::Any_var value = member->to_any (); ETCL_Constraint *comp = array->component (); if (comp == 0) { TAO_ETCL_Literal_Constraint result (value.ptr ()); this->queue_.enqueue_head (result); return 0; } else { this->current_member_ = value._retn (); return comp->accept (this); } } catch (const CORBA::Exception&) { return -1; } }
void TAO_UnionDef_i::fetch_label (const ACE_Configuration_Section_Key member_key, CORBA::UnionMember &member) { ACE_Configuration::VALUETYPE vt; this->repo_->config ()->find_value (member_key, "label", vt); if (vt == ACE_Configuration::STRING) { member.label <<= CORBA::Any::from_octet (0); return; } u_int value = 0; this->repo_->config ()->get_integer_value (member_key, "label", value); CORBA::TypeCode_var tc = this->discriminator_type_i (); CORBA::TCKind kind = tc->kind (); switch (kind) { case CORBA::tk_char: member.label <<= CORBA::Any::from_char (static_cast<CORBA::Char> (value)); break; case CORBA::tk_wchar: member.label <<= CORBA::Any::from_wchar (static_cast<CORBA::WChar> (value)); break; case CORBA::tk_boolean: member.label <<= CORBA::Any::from_boolean (static_cast<CORBA::Boolean> (value)); break; case CORBA::tk_short: member.label <<= static_cast<CORBA::Short> (value); break; case CORBA::tk_ushort: member.label <<= static_cast<CORBA::UShort> (value); break; case CORBA::tk_long: member.label <<= static_cast<CORBA::Long> (value); break; case CORBA::tk_ulong: member.label <<= static_cast<CORBA::ULong> (value); break; case CORBA::tk_longlong: member.label <<= static_cast<CORBA::LongLong> (value); break; case CORBA::tk_ulonglong: member.label <<= static_cast<CORBA::ULongLong> (value); break; case CORBA::tk_enum: { TAO_OutputCDR cdr; cdr.write_ulong (static_cast<CORBA::ULong> (value)); TAO_InputCDR in_cdr (cdr); TAO::Unknown_IDL_Type *impl = 0; ACE_NEW (impl, TAO::Unknown_IDL_Type (tc.in (), in_cdr)); member.label.replace (impl); break; } default: break; } }
void TAO_DynSequence_i::from_any (const CORBA::Any & any) { if (this->destroyed_) { throw ::CORBA::OBJECT_NOT_EXIST (); } CORBA::TypeCode_var tc = any.type (); CORBA::Boolean equivalent = this->type_.in ()->equivalent (tc.in ()); if (equivalent) { // Get the CDR stream of the Any, if there isn't one, make one. TAO::Any_Impl *impl = any.impl (); TAO_OutputCDR out; TAO_InputCDR cdr (static_cast<ACE_Message_Block *> (0)); if (impl->encoded ()) { TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); if (!unk) throw CORBA::INTERNAL (); cdr = unk->_tao_get_cdr (); } else { impl->marshal_value (out); TAO_InputCDR tmp_in (out); cdr = tmp_in; } CORBA::ULong arg_length; // If the any is a sequence, first 4 bytes of cdr hold the // length. cdr.read_ulong (arg_length); // If the array grows, we must do it now. if (arg_length > this->component_count_) { this->da_members_.size (arg_length); } CORBA::TypeCode_var field_tc = this->get_element_type (); for (CORBA::ULong i = 0; i < arg_length; ++i) { CORBA::Any field_any; TAO_InputCDR unk_in (cdr); TAO::Unknown_IDL_Type *field_unk = 0; ACE_NEW (field_unk, TAO::Unknown_IDL_Type (field_tc.in (), unk_in)); field_any.replace (field_unk); if (i < this->component_count_) { this->da_members_[i]->destroy (); } this->da_members_[i] = TAO::MakeDynAnyUtils::make_dyn_any_t<const CORBA::Any&> ( field_any._tao_get_typecode (), field_any, this->allow_truncation_ ); // Move to the next field in the CDR stream. (void) TAO_Marshal_Object::perform_skip (field_tc.in (), &cdr); } // Destroy any dangling members. for (CORBA::ULong j = arg_length; j < this->component_count_; ++j) { this->da_members_[j]->destroy (); } // If the array shrinks, we must wait until now to do it. if (arg_length < this->component_count_) { this->da_members_.size (arg_length); } // Now we can update component_count_. this->component_count_ = arg_length; this->current_position_ = arg_length ? 0 : -1; } else { throw DynamicAny::DynAny::TypeMismatch (); } }
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; }
OCI_APT::ArgList * OCI_APT::OperationTable::add_interface (CORBA::InterfaceDef_ptr intDef, const char * desired_op) { bool want_attribute = false; if (desired_op && desired_op[0] == '_') want_attribute = ACE_OS::strncmp(desired_op+2,"et_",3) == 0; ACE_Write_Guard<ACE_RW_Thread_Mutex>(this->lock_); OCI_APT::ArgList *result = 0; CORBA::InterfaceDefSeq_var bases = intDef->base_interfaces (); CORBA::String_var *derived = new CORBA::String_var[bases->length()]; CORBA::ULong n_bases = bases->length(); CORBA::ULong i = 0; for (; i <= n_bases; i++) { CORBA::String_var rep_id = intDef->id(); if (i == 0) { OCI_APT::ArgList *al = this->add_is_a (rep_id.in()); if (!want_attribute && desired_op && ACE_OS::strcmp("_is_a",desired_op) == 0) result = al; else al->remove_ref(); al = this->add_non_existent (rep_id.in()); if (!want_attribute && desired_op && ACE_OS::strcmp("_non_existent",desired_op) == 0) result = al; else al->remove_ref(); } CORBA::ContainedSeq_var attributes = intDef->contents (CORBA::dk_Attribute,1); CORBA::ULong n_ats = attributes->length(); for (CORBA::ULong at = 0; at < n_ats; ++at) { CORBA::String_var attr_name = attributes[at]->name(); CORBA::AttributeDef_var attr = CORBA::AttributeDef::_narrow (attributes[at]); CORBA::String_var attr_op = CORBA::string_alloc(ACE_OS::strlen(attr_name.in()) + 5); ACE_OS::strcpy(attr_op.inout(),"_get_"); ACE_OS::strcat(attr_op.inout(),attr_name.in()); OCI_APT::Operation *op_ptr = this->find_or_add(attr_op.in()); OCI_APT::ArgList *arg_list = new OCI_APT::ArgList (0, 0, false); arg_list->result (attr->type()); if (want_attribute && ACE_OS::strcmp (attr_op.in(),desired_op) == 0) { arg_list->add_ref(); result = arg_list; } op_ptr->add_set (new OpArgs(rep_id.in(),arg_list)); for (CORBA::ULong d = 0; d < i; d++) op_ptr->add_set (new OpArgs(derived[d],arg_list)); arg_list->remove_ref(); if (attr->mode() == CORBA::ATTR_READONLY) continue; attr_op.inout()[1] = 's'; // from _get_ to _set_ op_ptr = this->find_or_add(attr_op.in()); arg_list = new OCI_APT::ArgList (1, 0, false); arg_list->set_arg(0, attr->type(),CORBA::ARG_IN); arg_list->result (CORBA::_tc_void); if (want_attribute && ACE_OS::strcmp (attr_op.in(),desired_op) == 0) { arg_list->add_ref(); result = arg_list; } op_ptr->add_set (new OpArgs(rep_id.in(),arg_list)); for (CORBA::ULong d = 0; d < i; d++) op_ptr->add_set (new OpArgs(derived[d],arg_list)); arg_list->remove_ref(); } CORBA::ContainedSeq_var operations = intDef->contents (CORBA::dk_Operation,1); CORBA::ULong n_ops = operations->length (); for (CORBA::ULong op = 0; op < n_ops; ++op) { CORBA::String_var op_name = operations[op]->name(); OCI_APT::Operation *op_ptr = this->find_or_add(op_name.in()); CORBA::OperationDef_var opDef = CORBA::OperationDef::_narrow (operations[op]); CORBA::ParDescriptionSeq_var params = opDef->params (); CORBA::ExceptionDefSeq_var excepts = opDef->exceptions(); int is_oneway = opDef->mode() == CORBA::OP_ONEWAY; OCI_APT::ArgList *arg_list = new OCI_APT::ArgList (params->length(), excepts->length(), is_oneway); if (!is_oneway) arg_list->result (opDef->result()); for (CORBA::ULong p = 0; p < params->length (); ++p) { CORBA::Flags mode = CORBA::ARG_IN; if (params[p].mode == CORBA::PARAM_OUT) mode = CORBA::ARG_OUT; else if (params[p].mode == CORBA::PARAM_INOUT) mode = CORBA::ARG_INOUT; arg_list->set_arg(p, params[p].type.in(),mode); } for (CORBA::ULong e = 0; e < excepts->length (); ++e) { CORBA::TypeCode_var tc = excepts[e]->type(); arg_list->set_excep(e, tc.in()); } if (!want_attribute && desired_op && ACE_OS::strcmp(op_name,desired_op) == 0) { arg_list->add_ref(); result = arg_list; } op_ptr->add_set (new OpArgs(rep_id.in(),arg_list)); for (CORBA::ULong d = 0; d < i; d++) op_ptr->add_set (new OpArgs(derived[d],arg_list)); arg_list->remove_ref(); } if (i < bases->length()) { derived[i] = rep_id; intDef = bases[i]; } } delete [] derived; return result; }