lua-users home
lua-l archive

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

Hi Lua list,
  I'm a bit of a lua newbie and I'm trying to go from an existing c++ perl binding to c++ lua binding. I'm currently using swig to do the binding, which I'm hoping to stay with. I'm not quite sure if these are more of a swig question or a lua questions, but any input would be appreciated.

Question 1: I have a class Apple and member function Apple:get_position(float *x,float *y,float *z);
is there a easy way to do this?
 Swig spits out a bunch of:
     if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("get_position",4,"float *");
which go off when I can't provide it a float *. I noticed a couple of posts about luatypemaps.swg but I can't tell if it handles float *'s. Swig also declares SWIGTYPE_p_float but it doesn't seem to be an instatiatable object.

Question 2. I have an AppleManager class, which can look up an apple. When getting the apple, Swig will create a apple userdata and assocate the member functions of the apple into apple's metatable (I think in the ".fn" field via the registery).
   I'm wondering if there is anyway to cleanly add some lua functions to the apple's table so that every time the registry looks it up, I can get both the c++ member functions and the new lua functions. Swig seems to support this only at compile time. but I'm intrested being able to add new functions at run time. I guess the best c++ way I could describe it is that I'd like to cast the Apple * into an AppleLua * where AppleLua inherits from Apple and has a bunch of Lua code.

No fruit came to any harm in writing this email

Thank you for any help or suggestions.
-Gedalia Pasternak
Fight Entropy!!! Fight Entropy!!! Figth Etnropy! !
iFgth Etnrop!y ! giFth tErno!py ! giFt htrEno!p y! --- Well maybe