[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Design mistakes in mixed C/C++ and Lua projects (was: How can I be sure LuaJIT is working?)
- From: Michael Gogins <michael.gogins@...>
- Date: Fri, 21 Oct 2011 08:31:20 -0400
I would advise:
Either refactor your C/C++ libraries for more efficient calls, and
then use a wrapper generator such as SWIG, or hand-coded LUA C API
Or use LuaJIT/FFI and do your work in Lua, but using C structures and
arrays that you declare and allocate from Lua and access from local
I think with the right design either of these approaches would work.
Of course the two approaches can be combined.
If you declare C++ classes as "plain old data" structures, then you
can alias them with C struct declarations in LuaJIT/FFI. Then you can
pass pointers back and forth as lightuserdata and type cast them in
LuaJIT/FFI. In this way, with care, you can use either C++ or Lua to
work on the same data in a very efficient way.
On Thu, Oct 20, 2011 at 9:52 PM, Xavier Wang <email@example.com> wrote:
> 2011/10/21 Patrick Donnelly <firstname.lastname@example.org>:
>> On Thu, Oct 20, 2011 at 9:37 PM, Xavier Wang <email@example.com> wrote:
>>> - write it in pure Lua? first is the speed, maybe LuaJIT may fast,
>>> then, using Lua to do actually render?
>> Yes! Use LuaJIT 2.x with FFI. I believe plenty of people have already
>> have opengl FFI bindings written. Just google around. With the FFI, it
>> should be lightning fast...
>> - Patrick Donnelly
> This is a good idea, thank you :-)
> May be I should learn to wrtie C wrappers for C++ class, and try to
> write FFI interface (may be meta-method is supported) for my C++
> Thank you.
Michael dot Gogins at gmail dot com