- Subject: Re: [slang-users] Slirp / slirp_map_struct() not working
- From: Laurent Perez <laurent.perez@xxxxxxxxxx>
- Date: Sun, 30 May 2021 23:40:25 +0200
* Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> [2021-05-29 14:54] :
[...]
> The docs say:
>
> "In the present implementation additional manual coding is required to
> define the structure layout used by the SLang_push_cstruct() and
> SLang_pop_cstruct() routines."
>
> Which manual code?
Hi Sebastian,
The interpreter needs to know about your C structure layout, which
can be done by filling a SLang_CStruct_Field_Type table (see [1]) :
SLang_CStruct_Field_Type WindowEntry_Layout [] =
{
MAKE_CSTRUCT_FIELD(WindowEntry, name, "name",SLANG_STRING_TYPE, 0),
MAKE_CSTRUCT_FIELD(WindowEntry, path, "path",SLANG_STRING_TYPE, 0),
MAKE_CSTRUCT_FIELD(WindowEntry, syntax, "syntax",SLANG_STRING_TYPE, 0),
SLANG_END_CSTRUCT_TABLE
};
This is the "additional manual coding" part that Slirp manual is
refering to.
Structures can then be passed from / to S-Lang this way :
WindowEntry en;
SLang_push_cstruct ((VOID_STAR)&en, WindowEntry_Layout);
SLang_pop_cstruct ((VOID_STAR)&en, WindowEntry_Layout);
For a working example, please look at slgtk code (GdkColor,
GdkRectangle...)
Regards ;
Laurent.
References :
------------
[1] https://www.jedsoft.org/slang/doc/html/cslang-5.html#ss5.5
_______________________________________________
For list information, visit <http://jedsoft.org/slang/mailinglists.html>.
[2021 date index]
[2021 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]