[PolyORB-users] Additional pragmas facilitating migration of legacy Ada to CORBA

oliver.kellogg at t-online.de oliver.kellogg at t-online.de
Wed Sep 14 08:56:11 CEST 2011


Here is a patch that adds support for #pragma array_index, tested with
the mo.idl file sent in my previous mail.

The syntax is:

   #pragma array_index  <array_typedef>  <index_type>

The pragma should be given after the declaration of the <index_type>
but before the declaration of the <array_typedef>.

Using this pragma, we can control the type used in the dimension
of the Ada array type generated for an IDL array-typedef.

Example:

// IDL
module m {
   enum colors { red, green, blue };

   #pragma array_index rgb_array_t colors;
   typedef octet rgb_array_t[3];
};

This generates the Ada array type:

   type rgb_array_t is array (colors) of CORBA.Octet;

so that in an application we can write e.g.

declare
   RGB_Array : m.rgb_array_t;
begin
   for I in m.colors loop
      RGB_Array (I) := 127;
   end loop;
end;

There are some restrictions:

1) This pragma only works for one dimensional arrays.
Multi dimensional arrays would require splitting into several
IDL typedefs where each typedef only adds one dimension.

2) The number given as the dimension in the IDL typedef needs
to match the range of the type given as the index type in the pragma.
In the above example, type colors has 3 values: Thus the dimension
number given in the IDL typedef must be 3.

Next, I will send a unit test case.

Hope this helps,

Oliver


On 2011-09-13 08:32:45 +0200, oliver.kellogg at t-online.de wrote:
> 
> Compiling the code generated for the attached IDL file showed a problem
> in the Helper package code generation for #pragma switchname.
> The attached patch for compilers/iac fixes that problem.
> 
> In the course of work on the forthcoming #pragma array_index, I will make
> a proper unit test for the new pragmas.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pragma_array_index.diff
Type: text/x-patch
Size: 18601 bytes
Desc: 
Url : /pipermail/polyorb-users/attachments/20110914/0639c577/attachment.bin 


More information about the PolyORB-users mailing list