//-----------------------------------------------------------------------------// std::string CCorbaErrorHelper::ToString(const CORBA::Exception& err) { CORBA::Any tmp; tmp <<= err; CORBA::TypeCode_var tc = tmp.type(); return std::string(tc->name()); }
CORBA::Any * TAO::TypeCode::Case_Enum_T<StringType, TypeCodeType>::label (void) const { TAO_OutputCDR out_cdr; out_cdr.write_ulong (this->label_); CORBA::Any *retval = 0; ACE_NEW_THROW_EX (retval, CORBA::Any, CORBA::NO_MEMORY ()); TAO_InputCDR in_cdr (out_cdr); TAO::Unknown_IDL_Type *unk = 0; ACE_NEW_THROW_EX (unk, TAO::Unknown_IDL_Type (this->discriminator_tc_.in (), in_cdr), CORBA::NO_MEMORY ()); CORBA::Any_var safe_value (retval); retval->replace (unk); return safe_value._retn (); }
bool UnionTypeCode::dump_value (TIDorb::core::cdr::CDRInputStream& input, ostream& output) const { CORBA::Any discriminator; discriminator.delegate().read_value(input, m_discriminator_type, true); output << "[VALUE]{union " << m_name << " discriminator: "; discriminator.delegate().dump(output); CORBA::Long index = search_member_index(discriminator); if (index == -1) { return true; // default constructed union } if ((index < 0) || (index >= m_members->length())) { throw CORBA::MARSHAL(); } TypeCodeImpl* tc = (TypeCodeImpl*)((CORBA::TypeCode_ptr)(*m_members)[index].type); if(index == m_default_used) output << " /default/ "; output << ((*m_members)[index]).name << " -> " ; if (!tc->dump_value(input, output)) return false; output << '}'; return true; }
void TAO_ConstantDef_i::value_i (const CORBA::Any &value) { CORBA::TypeCode_var my_tc = this->type_i (); CORBA::TypeCode_var val_tc = value.type (); CORBA::Boolean const equal_tc = my_tc.in ()->equal (val_tc.in ()); if (!equal_tc) { return; } ACE_Message_Block *mb = 0; TAO::Any_Impl *impl = value.impl (); if (impl->encoded ()) { TAO::Unknown_IDL_Type *unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); mb = unk->_tao_get_cdr ().steal_contents (); } else { TAO_OutputCDR out; impl->marshal_value (out); TAO_InputCDR in (out); mb = in.steal_contents (); } ACE_Auto_Ptr<ACE_Message_Block> safe (mb); CORBA::TCKind kind = val_tc->kind (); switch (kind) { // The data for these types will be aligned to an 8-byte // boundary, while the rd_ptr may not. case CORBA::tk_double: case CORBA::tk_ulonglong: case CORBA::tk_longlong: case CORBA::tk_longdouble: mb->rd_ptr (ACE_ptr_align_binary (mb->rd_ptr (), ACE_CDR::MAX_ALIGNMENT)); break; default: break; } mb->crunch (); this->repo_->config ()->set_binary_value (this->section_key_, "value", mb->base (), mb->length ()); }
// compareAnys function compares both Any type inputs // returns FIRST_BIGGER if the first argument is bigger // returns SECOND_BIGGER is the second argument is bigger // and BOTH_EQUAL if they are equal Service_impl::AnyComparisonType Service_impl::compareAnys (CORBA::Any& first, CORBA::Any& second) { CORBA::TypeCode_var tc1 = first.type (); CORBA::TypeCode_var tc2 = second.type (); switch (tc1->kind ()) { case CORBA::tk_ulong: { CORBA::ULong frst, scnd; first >>= frst; second >>= scnd; if (frst > scnd) { return FIRST_BIGGER; } else if (frst == scnd) { return BOTH_EQUAL; } else { return SECOND_BIGGER; } } case CORBA::tk_long: { CORBA::Long frst, scnd; first >>= frst; second >>= scnd; if (frst > scnd) { return FIRST_BIGGER; } else if (frst == scnd) { return BOTH_EQUAL; } else { return SECOND_BIGGER; } } case CORBA::tk_short: { CORBA::Short frst, scnd; first >>= frst; second >>= scnd; if (frst > scnd) { return FIRST_BIGGER; } else if (frst == scnd) { return BOTH_EQUAL; } else { return SECOND_BIGGER; } } default: return UNKNOWN; } return UNKNOWN; }
CORBA::Boolean CDBPropertySet::get_properties (const CosPropertyService::PropertyNames & property_names, CosPropertyService::Properties_out nproperties) { ACS_TRACE("baci::CDBPropertySet::get_properties"); // Allocate memory for the out parameter. ACE_NEW_RETURN (nproperties, CosPropertyService::Properties, 0); // Validate the length. CORBA::ULong n = property_names.length (); if (n == 0) { return 0; } // Set the length for the out parameter. nproperties->length (n); // Get values for all the names. CORBA::Any_ptr any_p = 0; CORBA::Boolean retVal = true; for (CORBA::ULong i = 0UL; i < n; i++) { any_p = get_property_value(property_names[i]); ACE_CHECK_RETURN (0); if (any_p != 0) { // Property is found. nproperties [i].property_name = property_names [i]; nproperties [i].property_value = *any_p; } else { // Invalid name. Ret value is False. retVal = false; // Assign void type to this name in the out parameter. nproperties [i].property_name = property_names [i]; // Make an any value with tk_void type. CORBA::Any voidany; voidany.type(CORBA::_tc_void); nproperties [i].property_value = voidany; // CORBA::Any(CORBA::_tc_void); } } return retVal; }
static ostream & operator<< (ostream & os, const CORBA::Exception & e) { CORBA::Any tmp; tmp <<= e; CORBA::TypeCode_var tc = tmp.type (); const char * p = tc->name (); if (*p != '\0') os << p; else os << tc->id (); return os; }
CORBA::Long UnionTypeCode::search_member_index (const CORBA::Any& discriminator) const { CORBA::ULong length = m_members->length(); CORBA::Any* disc; for (CORBA::ULong i = 0; i < length; i++) { disc = &(((*m_members)[i]).label); if( discriminator.delegate() == disc->delegate()) return i; } return m_default_used; }
//-----------------------------------------------------------------------------// std::string CCorbaErrorHelper::ToString(const CORBA::SystemException& err) { std::string errDescription; TCHAR buf[50]; memset(buf, 0, sizeof(TCHAR) * 50); CORBA::Any tmp; tmp <<= err; CORBA::TypeCode_var tc = tmp.type(); errDescription = std::string(tc->name()) + _T(" Description: ") + err.NP_minorString(); errDescription += _T(" Minor code: "); errDescription += _ltoa_s(err.minor(), buf, 50, 10); return errDescription; }
void operator<<=(::CORBA::Any& _a, standardInterfaces::complexFloat_ptr* _op) { _a.PR_insert(standardInterfaces::_tc_complexFloat, _0RL_standardInterfaces_mcomplexFloat_marshal_fn, _0RL_standardInterfaces_mcomplexFloat_destructor_fn, (*_op)->_PR_getobj()); *_op = standardInterfaces::complexFloat::_nil(); }
void operator<<=(::CORBA::Any& _a, standardInterfaces::complexFloat_ptr _o) { standardInterfaces::complexFloat_ptr _no = standardInterfaces::complexFloat::_duplicate(_o); _a.PR_insert(standardInterfaces::_tc_complexFloat, _0RL_standardInterfaces_mcomplexFloat_marshal_fn, _0RL_standardInterfaces_mcomplexFloat_destructor_fn, _no->_PR_getobj()); }
void TAO_IFR_Client_Adapter_Impl::create_operation_list ( CORBA::ORB_ptr orb, CORBA::OperationDef_ptr opDef, CORBA::NVList_ptr &result) { // Create an empty NVList. orb->create_list (0, result); // Get the parameters (if any) from the OperationDef, and for each // parameter add a corresponding entry to the result. CORBA::ParDescriptionSeq_var params = opDef->params (); CORBA::ULong paramCount = params->length (); for (CORBA::ULong i = 0; i < paramCount; ++i) { CORBA::Any value; TAO::Unknown_IDL_Type *unk = 0; ACE_NEW (unk, TAO::Unknown_IDL_Type (params[i].type.in ())); value.replace (unk); // Convert the parameter mode to an arg mode CORBA::Flags flags = 0; switch(params[i].mode) { case CORBA::PARAM_IN: flags = CORBA::ARG_IN; break; case CORBA::PARAM_OUT: flags = CORBA::ARG_OUT; break; case CORBA::PARAM_INOUT: flags = CORBA::ARG_INOUT; break; default: // Shouldn't happen throw ::CORBA::INTERNAL(); } // Add an argument to the NVList. result->add_value (params[i].name.in (), value, flags); } }
void TAO_DynAny_i::init (const CORBA::Any& any) { this->type_ = any.type (); this->check_typecode (this->type_.in ()); this->init_common (); this->any_ = any; }
CORBA::Any * TAO_RequestInfo_Util::make_any (CORBA::Boolean tk_void_any) { CORBA::Any *any = 0; ACE_NEW_THROW_EX (any, CORBA::Any, CORBA::NO_MEMORY ( CORBA::SystemException::_tao_minor_code ( 0, ENOMEM), CORBA::COMPLETED_NO)); if (tk_void_any) { any->_tao_set_typecode (CORBA::_tc_void); } return any; }
int TAO_Log_Constraint_Visitor::visit_identifier (ETCL_Identifier *ident) { int return_value = -1; const char *name = ident->value (); ACE_CString key (name, 0, false); CORBA::Any any; if (this->property_lookup_.find (key, any) == 0) { if (any.impl() != 0) { this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (&any)); return_value = 0; } } return return_value; }
//---------------------------------------------------------------------- CORBA::TCKind AnyAide::getRealType(const CORBA::Any& any) { //have to create an _var type because this is actually a CORBA object CORBA::TypeCode_var tc; //get the type from the any tc = any.type(); //return the kind...simple enough. return tc->kind(); }
int TAO_Log_Constraint_Visitor::visit_component_assoc ( ETCL_Component_Assoc *assoc) { // @@@ (JP) The spec reserves this type of constraint for NVLists. // Since NVLists don't have type codes or Any operators, there's // no way that TAO can put one into the event's filterable data. // However, from the looks of the ETCL grammar, I believe that a // contruct like 'exist $(foo)' is legal, and is in effect using // the event's filterable data as one big NVList. It is // equivalent to '$.foo'. I've implemented this method on that // basis, while keeping in mind that a clearer interpretation of // the spec may come along someday. CORBA::Any any; ACE_CString key (assoc->identifier ()->value (), 0, false); if (this->property_lookup_.find (key, any) != 0 || any.impl () == 0) { return -1; } ETCL_Constraint *comp = assoc->component (); if (comp == 0) { TAO_ETCL_Literal_Constraint result (&any); this->queue_.enqueue_head (result); return 0; } CORBA::Any *any_ptr = 0; ACE_NEW_RETURN (any_ptr, CORBA::Any (any), -1); this->current_member_ = any_ptr; return comp->accept (this); }
CORBA::Boolean operator<< (TAO_OutputCDR &cdr, const CORBA::Any &any) { TAO::Any_Impl *impl = any.impl (); if (impl != 0) { return impl->marshal (cdr); } return (cdr << CORBA::_tc_null); }
bool UnionTypeCode::skip_value (TIDorb::core::cdr::CDRInputStream& input) const { CORBA::Any discriminator; discriminator.delegate().read_value(input, m_discriminator_type, true); CORBA::Long index = search_member_index(discriminator); if (index == -1) { return true; // default constructed union } if ((index < 0) || (index >= m_members->length())) { throw CORBA::MARSHAL(); } TypeCodeImpl* tc = (TypeCodeImpl*)((CORBA::TypeCode_ptr)(*m_members)[index].type); tc->skip_value(input); return true; }
void TAO::Any_Impl_T<T>::insert (CORBA::Any & any, _tao_destructor destructor, CORBA::TypeCode_ptr tc, T * const value) { TAO::Any_Impl_T<T> *new_impl = 0; ACE_NEW (new_impl, TAO::Any_Impl_T<T> (destructor, tc, value)); any.replace (new_impl); }
void Best_Effort::post_passivate (const Deployment::DeploymentPlan & plan, uint32_t index, const CORBA::Any & exception) { if (exception.type()->kind () != CORBA::TCKind::tk_null) { DANCEX11_LOG_ERROR ("Best_Effort::post_passivate - " << "Received exception while passivating instance " << "<" << plan.instance ()[index].name () << ">:<" << DAnCE::Utility::stringify_exception_from_any (exception) << ">"); } }
void Best_Effort::post_connect (const Deployment::DeploymentPlan &plan, uint32_t connection, const CORBA::Any &exception) { if (exception.type()->kind () != CORBA::TCKind::tk_null) { DANCEX11_LOG_ERROR ("Best_Effort::post_connect - " << "Received exception while establishing connection " << "<" << plan.connection ()[connection].name () << ">:<" << DAnCE::Utility::stringify_exception_from_any (exception) << ">"); } }
CORBA::Any_ptr TAO_DynEnum_i::to_any (void) { TAO_OutputCDR out_cdr; out_cdr.write_ulong (this->value_); CORBA::Any *retval; ACE_NEW_THROW_EX (retval, CORBA::Any, CORBA::NO_MEMORY ()); TAO_InputCDR in_cdr (out_cdr); TAO::Unknown_IDL_Type *unk = 0; ACE_NEW_THROW_EX (unk, TAO::Unknown_IDL_Type (this->type_.in (), in_cdr), CORBA::NO_MEMORY ()); retval->replace (unk); return retval; }
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 (); }
void TAO::Any_Array_Impl_T<T_slice, T_forany>::insert (CORBA::Any & any, _tao_destructor destructor, CORBA::TypeCode_ptr tc, T_slice * const value) { TAO::Any_Array_Impl_T<T_slice, T_forany> *new_impl = 0; typedef TAO::Any_Array_Impl_T<T_slice, T_forany> ARRAY_ANY_IMPL; ACE_NEW (new_impl, ARRAY_ANY_IMPL (destructor, tc, value)); any.replace (new_impl); }
// compareAnyToZero function compares the any type input to zero // returns POSITIVE if the first argument is bigger // returns NEGATIVE is the second argument is bigger // and ZERO if they are equal Service_impl::AnyComparisonType Service_impl::compareAnyToZero (CORBA::Any& first) { CORBA::TypeCode_var tc1 = first.type (); switch (tc1->kind ()) { case CORBA::tk_ulong: { CORBA::ULong frst; first >>= frst; if (frst > 0) { return POSITIVE; } else if (frst == 0) { return ZERO; } else { return NEGATIVE; } } case CORBA::tk_long: { CORBA::Long frst; first >>= frst; if (frst > 0) { return POSITIVE; } else if (frst == 0) { return ZERO; } else { return NEGATIVE; } } case CORBA::tk_short: { CORBA::Short frst; first >>= frst; if (frst > 0) { return POSITIVE; } else if (frst == 0) { return ZERO; } else { return NEGATIVE; } } default: return UNKNOWN; } return UNKNOWN; }
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; }
void Standard_Error::post_connect (const ::Deployment::DeploymentPlan &plan, ::CORBA::ULong connection, const ::CORBA::Any &exception) { if (exception.type() != ::CORBA::_tc_null) { DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("Standard_Error::post_connect - ") ACE_TEXT ("Propagating exception from connection <%C>\n"), plan.connection[connection].name.in ())); DAnCE::Utility::throw_exception_from_any (exception); } }
void Standard_Error::post_passivate (const ::Deployment::DeploymentPlan & plan, ::CORBA::ULong index, const ::CORBA::Any & exception) { if (exception.type() != ::CORBA::_tc_null) { DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("Standard_Error::post_passivate - ") ACE_TEXT ("Propagating exception from passivation of instance <%C>\n"), plan.instance[index].name.in ())); DAnCE::Utility::throw_exception_from_any (exception); } }
// Store the exception value. void CORBA::ServerRequest::set_exception (const CORBA::Any &value) { CORBA::TypeCode_var tc = value.type (); CORBA::TCKind const kind = tc->kind (); // set_exception() can be called at any time, but the Any arg MUST // contain an exception. if (kind != CORBA::tk_except) { throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 21, CORBA::COMPLETED_MAYBE); } ACE_NEW_THROW_EX (this->exception_, CORBA::Any (value), CORBA::NO_MEMORY ()); this->orb_server_request_.reply_status (GIOP::USER_EXCEPTION); }