1 Mar 2007 03:13
Re: SWIG question
Rici Lake <lua <at> ricilake.net>
2007-03-01 02:13:51 GMT
2007-03-01 02:13:51 GMT
On 28-Feb-07, at 1:50 PM, Brian Hassink wrote: > Actually, in looking at this some more it appears as though it's not > possible to put a lua_yield() call within a SWIG wrapped function. The > semantics of a SWIG wrapped function are different from that of a > lua_CFunction. > > So, how would one do something like... > > result = block(self, event) > > ...where block() is a SWIG wrapped function that takes the script > context (i.e. state) and an event as arguments, and blocks (yields) the > script until the event occurs, after which the details are copied into > a > result structure (resumes)? > I don't know a lot about SWIG (and it may not be the optimal binding system for you, in fact, but that's another issue). However, it seems like the easiest solution is to write block() in Lua. There's no shame in that :) function block(event) return coroutine.yield(event) end That assumes that you have a supervisor (event loop, I guess) which handles the coroutines. You could write this in Lua, as well; I've put an example on the wiki at(Continue reading)
RSS Feed