- Subject: [slang-users] push array structure into slang
- From: Joe Miller <lpe540@xxxxxxxxx>
- Date: Thu, 25 Aug 2005 06:57:03 -0700 (PDT)
Hi,
I was wondering how to push an array of slang structs
into slang from c.
I have a c function that returns an array of C
structures and I'd like to push onto slang. I've tried
to do this a bunch of different ways and have to find
a way that works. I was wondering if anyone had any
suggestions.
Here's one approach I took. I think it describes at
least what I'm trying to do.
typedef struct cstruct
{
double x; // x position
double y; // y position
} CSTRUCT, *CSTRUCT_P;
SLang_CStruct_Field_Type SLANG_XY [] =
{
MAKE_CSTRUCT_FIELD(CSTRUCT, x, "x",
SLANG_DOUBLE_TYPE, 0),
MAKE_CSTRUCT_FIELD(CSTRUCT, y, "y",
SLANG_DOUBLE_TYPE, 0),
SLANG_END_CSTRUCT_TABLE
};
void sl_fucnc (void)
{
CSTRUCT_P cp;
int size = 4;
c_func (cp, size); //Where cfunc creates an array
of cp;
SLang_Array_Type *at =
SLang_create_array(SLANG_STRUCT_TYPE,0,NULL,&size,1);
SLang_Struct_Type *st;
SLang_Any_Type *any;
for (int ww = 0; ww < arg2; ww++){
SLang_push_cstruct((VOID_STAR)&cp[ww], SLANG_XY);
SLang_pop_anytype (&any);
*((SLang_Struct_Type**)st) =
(SLang_Struct_Type*)any;
SLang_set_array_element (at, &ww, st);
}
SLang_push_array(at,1);
}
Any thoughts or suggestion would be greatly
appreciated. I could be going about this all wrong so
let me know if you need more info.
Thanks.
-joe
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html
[2005 date index]
[2005 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]