Bug 2310 - Update array implementation
Summary: Update array implementation
Status: NEW
Alias: None
Product: TAO
Classification: Unclassified
Component: ORB (show other bugs)
Version: 1.5.1
Hardware: All All
: P3 enhancement
Assignee: DOC Center Support List (internal)
URL:
Depends on:
Blocks: 2454
  Show dependency tree
 
Reported: 2005-11-21 06:27 CST by Johnny Willemsen
Modified: 2008-03-31 04:47 CDT (History)
0 users

See Also:


Attachments
some code parts (88.80 KB, application/octet-stream)
2005-11-21 06:28 CST, Johnny Willemsen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Johnny Willemsen 2005-11-21 06:27:47 CST
During sequence changes discussed Array issues with Carlos. Proposal is to
change the way arrays are handled in the IDL compiler/TAO so that we just have
one traits class generated that we can use everywhere. Just some code parts
added as zip archive also

template<typename T, typename T_slice, typename TAG>
struct Array_Traits;

template<>
struct Array_Traits<my_array,my_array_slice,my_array_tag>
{
  static my_array_slice * alloc();
  static void free(my_array_slice * _tao_slice);
  static my_array_slice * dup(my_array_slice const * _tao_source);
  static void copy(
      my_array_slice * _tao_destination,
      my_array_slice const * _tao_source);

  // TODO This is a new function
  static void zero(
      my_array_slice * _tao_slice);

};

}

struct mock_array_traits
{
  typedef unsigned long underlying_type;
  typedef my_array value_type;
  typedef my_array const const_value_type;

  typedef my_array_slice slice_type;
  typedef my_array_tag TAG;

  inline static void zero_range(
      value_type * begin, value_type * end)
  {
    std::for_each(
        begin, end, &TAO::Array_Traits<value_type,slice_type,TAG>::zero);
  }

  inline static void initialize_range(
      value_type * begin, value_type * end)
  {
    std::for_each(
        begin, end, &TAO::Array_Traits<value_type,slice_type,TAG>::zero);
  }

  inline static void copy_range(
      value_type * begin, value_type * end, value_type *dst)
  {
    for(value_type * i = begin; i != end; ++i, ++dst)
    {
      TAO::Array_Traits<value_type,slice_type,TAG>::copy(*dst, *i);
    }
  }

  inline static void release_range(
      value_type * begin, value_type * end, value_type *dst)
  {
    std::for_each(
        begin, end, &TAO::Array_Traits<value_type,slice_type,TAG>::zero);
  }
};
Comment 1 Johnny Willemsen 2005-11-21 06:28:46 CST
Created attachment 414 [details]
some code parts
Comment 2 Johnny Willemsen 2005-11-24 05:44:55 CST
accept
Comment 3 Johnny Willemsen 2006-03-21 05:08:31 CST
will be handled by Remedy
Comment 4 Johnny Willemsen 2006-03-21 05:08:39 CST
accept
Comment 5 Johnny Willemsen 2006-05-09 04:50:03 CDT
updated version
Comment 6 Johnny Willemsen 2006-05-17 07:56:30 CDT
the _alloc, _dup, etc methods could then also call the methods on the trait

in the generated code we then get something like this, will be added more

  struct char_seq_array_traits
  {
    typedef char_seq_array value_type;
    typedef char_seq_array_slice slice_type;
  };

  typedef
    TAO_VarArray_Var_T<
        char_seq_array_traits
      >
    char_seq_array_var;

  typedef
    TAO_Array_Out_T<
        char_seq_array_traits
      >
    char_seq_array_out;

  typedef
    TAO_Array_Forany_T<
        char_seq_array_traits
      >
    char_seq_array_forany;
Comment 7 Johnny Willemsen 2006-05-22 06:54:04 CDT
namespace TAO { namespace details {
  template<class BASE_TYPE, size N>
  class primitive_type_array_traits {
    typedef BASE_TYPE array_type[N];
    typedef BASE_TYPE * array_slice;

    // add functions here, such as copy, duplicate, etc.
  };
}}

    Now the generated code would look like this:

// IDL
typedef char Arraychar[2];

// C++
typedef TAO::details::primitive_array_traits<CORBA::Char,2> Arraychar;

Comment 8 Johnny Willemsen 2006-05-22 08:42:19 CDT
with the new last proposal the trick is how to support multi dimensional arrays
without any problems.
Comment 9 Johnny Willemsen 2006-05-26 04:35:52 CDT
first iteration of refactoring is ready on taoarray branch, when x.5.2 is out
this goes in the repo
Comment 10 Johnny Willemsen 2007-04-11 06:03:37 CDT
to pool
Comment 11 Johnny Willemsen 2008-03-31 04:47:59 CDT
enhancement