Hi Garrett,
The problem is that nested _pointers_ to structs are supported -- not structs
themselves. IIRC, it's a grammar problem that should be easily fixable. Feel
free to send me patches, otherwise I'll fix it myself in an upcoming release.
Thanks,
Neil
Garrett Goebel [01/08/01 11:23 -0500]:
> Neil,
>
> I was playing with Inline::Struct today and noticed that it doesn't support
> nested structs. Here's a script to illustrate the point:
>
> use Inline C => <<'END' => STRUCTS => 1;
> struct POINT {int x; int y;};
> struct RECT {POINT a; POINT b;};
> END
>
> my $a = Inline::Struct::POINT(1,2);
> my $b = Inline::Struct::POINT(3,4);
> printf("a: [%d, %d]\n", $a->x, $a->y);
> printf("b: [%d, %d]\n", $b->x, $b->y);
>
> my $r = Inline::Struct::RECT($a,$b);
> printf("a: [%d, %d], b: [%d, %d]\n",
> $r->a->x, $r->a->y,
> $r->b->x, $r->b->y);
> __END__
>
> results in:
> >struct.pl
> a: [1, 2]
> b: [3, 4]
> Can't locate object method "new" via package
> "Inline::Struct::RECT" at C:\TEMP\struct.pl line 11.
>
> I'm guessing, but it appears that a typemap entry for POINT doesn't exist
> when it is time to parse RECT, and so RECT's struct definition isn't
> recognized. Do you think this is what is happening?
>
> I think I remember you originally intended to support nested structs. So I'm
> hoping this will make it into a future release. Let me know if there is
> anything I can do to help.
>
> Garrett
>
>