- Subject: Re: [slang-users] Creating nested structures
- From: "John E. Davis" <davis@xxxxxxxxxxxxx>
- Date: Fri, 5 Sep 2008 12:42:42 -0400
Laurent Perez <laurent.perez@xxxxxxxxxx> wrote:
> Is there a way to create an interpreter structure from a nested C
> structure ?
>
> struct first {
> int a;
> int b;
>}
>
> struct second {
> int c;
> struct first d;
>}
>
> How do I create an interpreter structure corresponding to the second C
> defined structure ?
I can tell you the easiest way to answer this precise question, but a
more general answer would involve asking more about what you want to
do within the interpeter. The easiest way to create a structure that
looks like the above is to use:
char buf[256];
sprintf (buf, "struct{c=%d, d=struct{a=%d, b=%d}};",
second.c, first.a, first.b);
(void) SLang_load_string (buf);
The use of SLang_load_string has the effect of pushing the structure
onto the slang stack. While this will accomplish the stated goal, I
am not sure if this is really what you want.
Thanks,
--John
[2008 date index]
[2008 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]