lua-users home
lua-l archive

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


Nope, unfortunately not. Because my project is intended large scale (many Lua enabled classes), it seemed very complicated to use additional wrappers for each class and maintain normal class inheritance at the same time.

I know that Lunar is maybe not the best choice for larger projects, but I didn't find any Luabind port for Windows CE yet :(

Best Regards
Micha


Hakki Dogusan schrieb:
Hi,

Michael Bauroth wrote:
Hi,

thank you for your reply. I've implemented an explicit destructor method in my code and made a test. Unfortunately at the moment I get an exception later on in the __gc() method from Lua. This happens regardless I call only the C++ destructor of the object or set it afterwards in Lua to nil too. I will have to debug this behaviour a little bit more ...


You do have seperate classes for 'real C++ class' and 'Lunar binding to it C++ class', don't you? Otherwise it may be hard to control instance status..IMHO.


Best Regards
Micha

Hakki Dogusan schrieb:
Hi,

Michael Bauroth wrote:
Hi,

I've made a Lua based GUI application with Lunar binding to the C++ core. The GUI will be constructed in Lua, backed by related C++ classes. Sometimes I build temporary hierarchical structures (e.g. panel with 3 buttons), which I want to delete later on.

Now my question: Is it possible to simply call the explicit destructor of such a base node from Lua side (Lunar approach), so that the C++ core can remove the hierarchy or is the only way to set the Lua variable to nil, so that the garbage collection can make the rest?

Unfortunately haven't found something meaningful in the net until now.


General answer to similar questions (closing file, releasing resource, etc.) was/is:
- Supply a destroy/delete function to Lua side
- When called, delete C++ side objects, and record that situation (ie. ptr=0)
- Let garbage collector do its job whenever it like

For example:

class A {};

class LunarA {
  A* self_;
public:
  LunarA() { self_ = new A; }
  ~LunarA() { delete self_; }
  void destroy(lua_State* L) { delete self_; self_ = 0; }
};



Best Regards
Micha



--
Regards,
Hakki Dogusan




--
Regards,
Hakki Dogusan