Hey guys,
I have a class for managing images and allocating memory for them.
I already know how to export this class to lua with luabind, so I can create one in a lua script, but I don't really know how to pass an existing instance of this class to lua.
I read the documentation two times but I didn't really see a solution to this. Maybe I'm just blind or I misunderstood something.
Cheers,
Marius
Passing objects with Luabind
Moderator: Coders of Rage
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: Passing objects with Luabind
One solution, if there's only one instance of the class, use M_D_K's "Singleton" method (which doesn't follor singleton theory, but works anyway ). I'd send you the code, but it's on another computer, so ask him for it.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Re: Passing objects with Luabind
You mean you provide a GetInstance function that can be called in C++ and in Lua?
If it's really that simple I guess I could code it myself.
If it's really that simple I guess I could code it myself.
- M_D_K
- Chaos Rift Demigod
- Posts: 1087
- Joined: Tue Oct 28, 2008 10:33 am
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C/++
- Location: UK
Re: Passing objects with Luabind
WTF Ginto!
The idea behind a Singleton is there is only one, just cause I wasn't stupid enough to initiate a singleton based class more than once doesn't mean that its not a singleton. BTW the singleton class I gave you allows for easy creation of singletons, its the programmer that has to follow the theory(which you didn't :See last sentence).
The idea behind a Singleton is there is only one, just cause I wasn't stupid enough to initiate a singleton based class more than once doesn't mean that its not a singleton. BTW the singleton class I gave you allows for easy creation of singletons, its the programmer that has to follow the theory(which you didn't :See last sentence).
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: Passing objects with Luabind
Ok, sorry. I guess I was saying it the wrong way. What I meant is that it does not fit the most common implementation of a singleton. And I DO follow the theory! When did I ever try to initiate a singleton more than once???? when I first mentioned its non-conventionality, I was basing what I said on its design. Most programmers don't seem to trust themselves enough to use your type of singleton I guess.M_D_K wrote:WTF Ginto!
The idea behind a Singleton is there is only one, just cause I wasn't stupid enough to initiate a singleton based class more than once doesn't mean that its not a singleton. BTW the singleton class I gave you allows for easy creation of singletons, its the programmer that has to follow the theory(which you didn't :See last sentence).
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Passing objects with Luabind
Yeah, all that you want to do is return a reference with a getInstance. The fact that its a singleton really doesn't have anything to do with the implementation. XD
Re: Passing objects with Luabind
Okay, thank you guys, sounds easy.
I can't believe that they don't say a word in the documentation about such a basic thing.
I can't believe that they don't say a word in the documentation about such a basic thing.
Re: Passing objects with Luabind
Do you mean a C++ reference or a boost.reference?GyroVorbis wrote:Yeah, all that you want to do is return a reference with a getInstance. The fact that its a singleton really doesn't have anything to do with the implementation. XD
OT: Since I've registered on the board I'm asking myself what you want to imply with your avatar