[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Object oriented access of c++ objects in lua
- From: "Rob Sadedin" <serenity@...>
- Date: Tue, 10 Aug 2004 13:55:17 +1000
Hey all, some advice, if you don't mind:
I'm accessing a number of c++ objects by create a lua user data that
contains a pointer to the object, and sets a meta table that fires on
indexing that points to functions that link to the appropriate c++ methods
for the given object.
lobj = create_my_cpp_obj_and_return_lua_data()
lobj::callsomecppmethod()
Is this a sensible method, and if not, what would be better?
Secondly, I'd like the users to be able to add lua data to the c++ objects.
That is, say something like:
-- Set a variable
lobj.x = 6
waaaaay later in the code:
lobj = get_that_object_I_created_before_and_stored_in_a_cpp_list_somewhere()
print(lobj.x)
* this should output 6 ... well, I'd like it to :)
I hope this makes sense, thanks guys,
Rob