Ejemplo n.º 1
0
void
TAO::Unknown_IDL_Type::_tao_decode (TAO_InputCDR & cdr)
{
  // @@ (JP) The following code depends on the fact that
  //         TAO_InputCDR does not contain chained message blocks,
  //         otherwise <begin> and <end> could be part of
  //         different buffers!

  // This will be the start of a new message block.
  char const * const begin = cdr.rd_ptr ();

  // Skip over the next argument.
  TAO::traverse_status const status =
    TAO_Marshal_Object::perform_skip (this->type_, &cdr);

  if (status != TAO::TRAVERSE_CONTINUE)
    {
      throw ::CORBA::MARSHAL ();
    }

  // This will be the end of the new message block.
  char const * const end = cdr.rd_ptr ();

  // The ACE_CDR::mb_align() call can shift the rd_ptr by up to
  // ACE_CDR::MAX_ALIGNMENT - 1 bytes. Similarly, the offset adjustment
  // can move the rd_ptr by up to the same amount. We accommodate
  // this by including 2 * ACE_CDR::MAX_ALIGNMENT bytes of additional
  // space in the message block.
  size_t const size = end - begin;

  ACE_Message_Block new_mb (size + 2 * ACE_CDR::MAX_ALIGNMENT);

  ACE_CDR::mb_align (&new_mb);
  ptrdiff_t offset = ptrdiff_t (begin) % ACE_CDR::MAX_ALIGNMENT;

  if (offset < 0)
    {
      offset += ACE_CDR::MAX_ALIGNMENT;
    }

  new_mb.rd_ptr (offset);
  new_mb.wr_ptr (offset + size);

  ACE_OS::memcpy (new_mb.rd_ptr (), begin, size);

  this->cdr_.reset (&new_mb, cdr.byte_order ());
  this->cdr_.char_translator (cdr.char_translator ());
  this->cdr_.wchar_translator (cdr.wchar_translator ());

  this->cdr_.set_repo_id_map (cdr.get_repo_id_map ());
  this->cdr_.set_codebase_url_map (cdr.get_codebase_url_map ());
  this->cdr_.set_value_map (cdr.get_value_map ());

  // Take over the GIOP version, the input cdr can have a different
  // version then our current GIOP version.
  ACE_CDR::Octet major_version;
  ACE_CDR::Octet minor_version;
  cdr.get_version (major_version, minor_version);
  this->cdr_.set_version (major_version, minor_version);
}
Ejemplo n.º 2
0
CORBA::Boolean
CORBA::ValueBase::_tao_unmarshal_value_indirection (TAO_InputCDR &strm,
                                                    CORBA::ValueBase *&value)
{
  if (strm.get_value_map().is_nil ())
    throw CORBA::INTERNAL ();

  CORBA::Long offset = 0;
  if (!strm.read_long (offset) ||  offset >= 0)
  {
    return 0;
  }

  void* pos = strm.rd_ptr () + offset - sizeof (CORBA::Long);

  if (9 < TAO_debug_level)
    {
      TAOLIB_DEBUG ((LM_DEBUG,
        ACE_TEXT ("TAO (%P|%t) ValueBase::_tao_unmarshal_value_indirection, pos %x\n"), pos));
      TAO_InputCDR::Value_Map* map = strm.get_value_map()->get ();
      for (TAO_InputCDR::Value_Map::ITERATOR it = map->begin (); it != map->end (); ++ it)
        {
          TAOLIB_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) ValueBase::_tao_unmarshal_value_indirection, %x=%x\n"), it->ext_id_, it->int_id_));
        }
    }
  void * v = 0;
  if (strm.get_value_map()->get()->find (pos, v) != 0)
    {
      TAOLIB_DEBUG ((LM_DEBUG,
        ACE_TEXT ("TAO (%P|%t) - %N:%l ")
        ACE_TEXT ("ValueBase::_tao_unmarshal_value_indirection, ")
        ACE_TEXT ("did not find %x in map %x\n"),
        pos, (void *) strm.get_value_map()->get()));
      throw CORBA::INTERNAL ();
    }
  else if (TAO_debug_level)
    {
      TAOLIB_DEBUG ((LM_DEBUG,
        ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_unmarshal_value_indirection, found %x=%x\n"),
        pos,v));
    }

  value = reinterpret_cast<CORBA::ValueBase *>(v);
  return true;
}
Ejemplo n.º 3
0
CORBA::Boolean
CORBA::ValueBase::_tao_unmarshal_value_indirection_pre (TAO_InputCDR &strm,
                                                        TAO_InputCDR &indirected_strm)
{
  CORBA::Long offset = 0;
  if (!strm.read_long (offset) ||  offset >= 0)
    {
      return false;
    }

  size_t const buffer_size = -(offset) + sizeof (CORBA::Long);
  // Cribbed from tc_demarshal_indirection in Typecode_CDR_Extraction.cpp
  indirected_strm = TAO_InputCDR (strm.rd_ptr () + offset - sizeof (CORBA::Long),
    buffer_size,
    strm.byte_order ());

  indirected_strm.set_repo_id_map (strm.get_repo_id_map ());
  indirected_strm.set_codebase_url_map (strm.get_codebase_url_map ());
  indirected_strm.set_value_map (strm.get_value_map ());
  return indirected_strm.good_bit ();
}
Ejemplo n.º 4
0
void
CORBA::ValueBase::_tao_unmarshal_find_factory (
  TAO_InputCDR &strm,
  void *const start_of_valuetype,
  CORBA::ValueBase *&valuetype,
  Repository_Id_List &ids,
  CORBA::Boolean &is_chunked)
{
  valuetype = 0;

  TAO_ORB_Core *orb_core = strm.orb_core ();
  if (!orb_core)
    {
      orb_core = TAO_ORB_Core_instance ();
      if (TAO_debug_level)
        {
          TAOLIB_DEBUG ((
            LM_WARNING,
            ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_unmarshal_find_factory, ")
            ACE_TEXT ("WARNING: extracting valuetype using default ORB_Core\n") ));
        }
    }

  // Find the registered factory for this unmarshalling valuetype. If any
  // factory for the valuetype in its truncatable derivation hierarchy
  // is registered, the factory is used to create value for unmarshalling.
  // Value factories are reference counted. When we get a new value factory
  // from the ORB, its reference count is increased.

  CORBA::ValueFactory_var factory;
  CORBA::Boolean requires_truncation = false;
  const size_t num_ids = ids.size ();
  const char *id = (num_ids) ? ids[0].c_str () : "{Null}";
  for (size_t i = 0u; i < num_ids; ++i)
    {
      factory = orb_core->orb ()->lookup_value_factory (ids[i].c_str ());
      if (factory.in() != 0)
        {
          id = ids[i].c_str ();
          requires_truncation = (i != 0u);
          break;
        }
    }

  // Obtain the actual ValueType from the factory
  if (factory.in() == 0 || !(valuetype = factory->create_for_unmarshal ()))
    {
      if (TAO_debug_level)
        {
          TAOLIB_ERROR ((LM_ERROR,
            ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_unmarshal_find_factory, ")
            ACE_TEXT ("OBV factory is null, id=%C\n"),
            id));
        }

      throw ::CORBA::MARSHAL (CORBA::OMGVMCID | 1, CORBA::COMPLETED_MAYBE);
    }

  if (requires_truncation)
    {
      valuetype->truncation_hook ();
    }
  valuetype->chunking_ = is_chunked;

  // Cache the start of this ValueType for later possiable indirection
  VERIFY_MAP (TAO_InputCDR, value_map, Value_Map);
  if (strm.get_value_map ()->get()->bind (start_of_valuetype, valuetype) != 0)
    {
      TAOLIB_DEBUG ((LM_DEBUG,
        ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_unmarshal_find_factory, ")
        ACE_TEXT ("Failed to bound value %x=%x, id=%C\n"),
        start_of_valuetype, valuetype, id ));
    }
  else if (TAO_debug_level)
    {
      TAOLIB_DEBUG ((LM_DEBUG,
        ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_unmarshal_find_factory, ")
        ACE_TEXT ("bound value %x=%x, id=%C\n"),
        start_of_valuetype, valuetype, id ));
    }
}