[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Calling from C through lua to another C function
- From: Steve Heller <steve@...>
- Date: Sun, 30 Apr 2006 10:57:12 -0700 (PDT)
I'm a total newbie to lua, although I have a lot of
experience in other languages, notably C++.
I'm sure what I'm trying to do is simple if you know
how to do it, but I don't, so I've been floundering
around for several days with it.
Here's the problem. I have a number of C++ objects
that have member functions that I need to be able to
access from lua. To make this possible, I need to pass
a pointer to one of the objects from the calling C++
program through lua into C++ again. My plan was to
pass the pointer via light userdata through the lua
program out to a lower level C++ static member
function which will then cast it back to the right
type (which I will always know) and call the
I know this is possible, but I've been unable to
figure out exactly how to do it. Does anyone have a
complete example that actually compiles and runs? It
doesn't have to be anything fancy; just passing a
light user data value from C through lua back to C
will do the job.