I am concreting a question I had earlier.
I have two classes in C++ and I use SWIG to wrap them. A method in one class can return a pointer to the other class. How can I get Lua to see it as more than just a userdata?
More concretely:
I have
class fruit
{
int numberofseeds;
//some other stuff about fruit constructors etc...
public:
getseedcount()
{
return numberofseeds;
}
}
class tree
{
fruit * apple;
public:
//constructors and whatnot
fruit * getfruit()
{
return apple;
}
}
I wrap these two class with SWIG so I can access them in Lua
So I can get in Lua the object x=pomona.tree(grannysmith).
My question now is: How can I arrange for things so that when I type y=x:getfruit() I will get a pomona:fruit type object? Where I can write something line y:getseedcount()? At the moment all I get is userdata which not edible.