[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: cpp to lua binding question
- From: Moritz Mühlenthaler <haz_ard@...>
- Date: Thu, 22 May 2003 17:19:54 +0200 (MEST)
Hi everyone,
im rather new to lua and i have some problems binding it to my cpp code. The
main problem is that all my classes are loaded dynamically, so i cant
hardcode the binding to a lua table. I could register each class' methods as soon
as it's loaded, but i'd prefer to set some kind of hook in the metatable,
which takes care of calling the right functions; I hope i can make it a little
clearer by getting more specific.
Lets say i have a "content server" which holds a hirarchy of classes
representing the content of a little game (texture classes, mesh classes, sounds,
ect). This "content server" has something like a "current content" to save some
typing (i.e. cs.meshes.player01.load("mymesh.xyz") = cs.load("mymesh.xyz")
if cs.meshes.player01 is the "current content"). So the problem is that i cant
hardcode the functions in the "cs" table, because the current content can be
a mesh, a texture, a camera or whatever... I've read about the metatables,
and the "__call" hook, but i somehow cant override it properly. I'd be glad if
someone could give me a hint how to set a cfunction as a "__call" hook from
c in the metatable. Perhaps you even have a completely different idea..
Thx for your time.
JiM.
--
-= HazarD =-
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!