[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: how to store a ref to a table without registry?
- From: "Chris Swetenham" <cswetenham@...>
- Date: Thu, 20 Mar 2008 11:27:26 -0000
If I understand correctly, you want to be able to store a reference to the
object from the C++ side without preventing it from being garbage collected?
If this is the case, then you can create a table in the registry that has
weak values, and store a reference in that table. See section 2.10.2 of the
reference manual: http://www.lua.org/manual/5.1/manual.html#2.10.2
Hope that helps!
----- Original Message -----
From: "joerg piringer" <email@example.com>
To: "Lua list" <firstname.lastname@example.org>
Sent: Thursday, March 20, 2008 11:17 AM
Subject: how to store a ref to a table without registry?
i am pretty new to lua so please forgive me if this question has been
i'd like to access a function (or rather a method) inside a specific table
from c++. how can i do that without storing the reference to the table in
the problem is when i store the reference in the registry it won't get
garbage collected, right?
i have the following code:
o = TestObject()
o.testFunc = function() print "test" end
TestObject() is a c++ function that returns a table with a userdata inside
(the actual c++ object).
now i'd like to call my testFunc from the c++ object that's inside the
i did it with a reference (in the registry) to self (the table) until i
tried to garbage collect the objects...