lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I'm using Lua 4 and ToLua to embed Lua in my C++ application.

I'm a little confused about something relating to objects and instances of objects. I'd appreciate it if you could just point out whether my assumptions are correct.

1)
I use ToLua to create the bindings for my C++ class A.
I create an instance of this class in my C++ code.
That instance is now visible to C++ but not to Lua.
I then expose the instance to Lua; the instance is visible to both C++ and Lua. Is the variable in Lua a reference to the C++ instance, or is it a completely separate entity (instance)? I delete the instance in C++. The variable still exists in Lua, but what value does it have? I presume that the deletion doesn't automatically get filtered to Lua. How would I deal with this?

2)
I create an instance of an object in Lua. The instance is only visible to Lua and not C++. I delete the instance in Lua, and the C++ code is none the wiser that a new instance ever existed.

Thanks, appreciate it.