[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: memoryblock Lua object
- From: Justin Cormack <justin@...>
- Date: Tue, 9 Jul 2013 10:44:07 +0100
On Tue, Jul 9, 2013 at 7:47 AM, Philipp Kraus
> Am 08.07.2013 um 22:17 schrieb Justin Cormack:
> On Mon, Jul 8, 2013 at 8:23 PM, Philipp Kraus
> <firstname.lastname@example.org> wrote:
> I use Boost.MPI for communication only, no network socket.
> Am 08.07.2013 um 20:22 schrieb Gabriel Duarte:
> You can't use network sockets to do this instead?
> It sounds to me like your best solution is to use an ffi type
> solution, either the LuaJIT ffi, or luaffi or a libffi binding, as
> these will let you do this (for structures with no pointers,
> obviously). You could do the same with userdata but its less
> That's a nice idea, but at the moment I'm in the planning phase, so
> I plan to create a mapping between my C++ and LUA class, each LUA
> class is point to a C++ class and all datatypes in the LUA object are
> user defined pointers. I don't want to create a copy-by-value structure
> LUA and C++.
> I haven't written a concept idea in LUA, so in the user-defined-pointer
> solution exists
> the problem, if the user create in the LUA script class proberties, because
> my C++ don't see
> these proberties and my data will be lost.
The ffi interfaces do not copy the data between C++ and Lua, they
share the same classes via pointers. I only said copy-by-value as you
need that if you want to copy to another memory address (ideally; you
are serializing and deserializing which is a similar version of the
same thing, ie reconstructing a new set of valid pointers).
> I my design the C++ class has got a serializable interface for Boost.MPI and
> I would like to store large
> dataset in the class, so these datasets are pushed to LUA with a pointer
> (and functions). In the documentation
> I have found this description:
> Account = class(function(acc,balance)
> acc.balance = balance
> But my C++ class does not know anything about balance. So can I grep / catch
> this proberty on C side?
> I must read only the memory data of balance. So I would like to get access
> from C side to the LUA object
Yes, the Lua/C interface can do this. It sounds to me like you need to
create a prototype to understand better how the bondings work. It is
easiest if you try it out directly, but C++ is a bit more painful than
C so it is a bit more work to understand, and many people generate the