Please report new issues athttps://github.com/DOCGroup
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); } };
Created attachment 414 [details] some code parts
accept
will be handled by Remedy
updated version
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;
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;
with the new last proposal the trick is how to support multi dimensional arrays without any problems.
first iteration of refactoring is ready on taoarray branch, when x.5.2 is out this goes in the repo
to pool
enhancement