[omniORB] problem differentiating between Arrays and Sequences

Tim Black timblack0 at gmail.com
Thu Jul 30 14:46:25 BST 2009


OK, thanks. I see that array-ness is specified in Declarator.sizes().
Is this the only place array-ness is specified? Is idltype.tk_array
never used? I tend to use type.kind() to determine what kind of
declaration I'm dealing with, so for example, I can treat an int
struct member differently than an array struct member when I generate
code.

It seems like I could just modify visitDeclarator() to set my
visitor's self.__result_typekind = idltype.tk_array when it sees a
declarator with len(sizes) > 0. I need to do something different to
detect array-ness, because just visiting the type is not enough.
Visiting the type just tells me what it is an array of. (Bc it seems
the type objects know nothing about sizes.)

I apologize - I misinterpreted some of my back-end observations. My
visitor is not seeing a sequence type corresponding to an array
declaration in IDL. (I actually had a valid bounded sequence in my IDL
that I was visiting) When you visit an array in the AST, its type
corresponds to what the array elements are. So, as stated above, to
determine array-ness you have to look at decl.sizes().

Please let me know if you see any holes in my reasoning.

Thanks,
Tim

On Thu, Jul 30, 2009 at 8:19 AM, Duncan Grisby<duncan at grisby.org> wrote:
> On Wednesday 29 July, Tim Black wrote:
>
>> sequence<long> UnboundLongs;
>> sequence<long, 10> BoundLongs;
>>
>> Arrays are fixed-length sequences, defined thusly:
>>
>> long ExactlyTenLongs[10];
>>
>> In omniIDL documentation, I can see that there is no mention of this
>> fixed-length Array type. However, I can see that there is a type kind for
>> arrays: idltype.tk_array. But when I visit an IDL array (e.g. ExactlyTenLongs
>> above) in my back end, the type comes out looking like a bounded sequence,
>> i.e. the type of the corresponding AST node is an instance of class Sequence,
>> it's self.__kind is tk_sequence, not tk_array, and bound = 10. What gives?
>> Does omniIDL not support the CORBA array construct?
>
> What exactly does your IDL look like?  I don't know why you're meeting a
> sequence unless you have an array of a sequence type.
>
> Arrays are handled differently from sequences, because the semantics of
> declaring them in IDL are different. Places you can use an array are a
> Declarator, and the Declarator class has a sizes() method that returns a
> list of array sizes. It's done that way to support nasty but valid IDL
> like this:
>
>  typedef long one, two[10], three[20][30];
>
> It's documented (briefly) in the section about omniidl.idlast.Declarator.
>
> Cheers,
>
> Duncan.
>
> --
>  -- Duncan Grisby         --
>  -- duncan at grisby.org     --
>   -- http://www.grisby.org --
>



More information about the omniORB-list mailing list