Duncan Grisby
2009-08-11 19:27:13 UTC
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.
idltype.tk_array is never used. It's there for consistency with TypeCodethe 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.
kinds and in case a back-end wants to use it.
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.)
You can do that, but beware of IDL like this: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.)
struct S {
long a, b[10], c[5][6];
};
There, you have a single type with three declarators, one of which is a
scalar, one a single-dimensional array, and the other a two-dimensional
array.
That kind of IDL is the reason array-ness is part of the declarator and
not the type.
Cheers,
Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --