[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cinvoke-dev] Lua / VC++ 2005 / passing struct to callback
From: |
Dean C. Davis |
Subject: |
[cinvoke-dev] Lua / VC++ 2005 / passing struct to callback |
Date: |
Sat, 29 Jul 2006 10:33:59 -0400 |
User-agent: |
Thunderbird 1.5.0.5 (Windows/20060719) |
First time user here. I built cinvoke (0.9) and the Lua (5.1.1) binding
on a Windows XP system with MS VC++ 2005 Express. I had to make four
changes to cinvoke_lua.c to get this to work (well, the change to
luaopen_ is a matter of taste).
To learn about the binding, I am attempting to invoke functions from
Simple HTTPD (http://shttpd.sourceforce.net) built "EMBEDDED" into a
DLL. However, I'm stumped by the callback functions because they expect
to be passed a struct (specifically, "struct shttpd_arg *"). Passing a
plain Cptr is a partial solution, but to actually be useful it is
necessary to manipulate some of the shttpd_arg struct members.
I'm a bit naive on the implementation details, so I'm wondering, is the
restriction on passing a struct to a callback function a limitation of
the Lua binding or of C/Invoke in general? Is there an alternate
approach that I'm overlooking? I'm willing to post my
shttpd.[lua|h|dll] if anyone is willing to take a look.
Thanks,
Dean.
34a35,38
> #ifdef _MSC_VER
> #define snprintf _snprintf
> #endif
>
384,386c388,392
< lua_Integer charid = tointeger(l, -1);
< lua_pop(l, 1);
< return (char)charid;
---
> {
> lua_Integer charid = tointeger(l, -1);
> lua_pop(l, 1);
> return (char)charid;
> }
506c512
< ret = (void *)strtol(pstr, &endptr, 10);
---
> ret = (void *)strtol(pstr, &endptr, 16);
1484c1490
< int luaopen_cinvoke_lua(lua_State *l) {
---
> LUALIB_API int luaopen_cinvoke(lua_State *l) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cinvoke-dev] Lua / VC++ 2005 / passing struct to callback,
Dean C. Davis <=