luabind - c++ member functions as lua non-member functions

Started by
1 comment, last by sprite_hound 15 years, 5 months ago
I may have just got this the wrong way round in my head, but is it possible to have something like this:

-- lua code:

texture_handle = resources.add_texture("t_id", "t_file")
sound_handle = resources.add_sound("s_id", "s_file")



template<class T>
class ResourceManager {
public:
	unsigned int add(const std::string& type, const std::string& file);
	//...
};

class TextureManager : public ResourceManager<Texture> {
	//...
} textureManager;

class SoundManager : public ResourceManager<Sound> {
	//...
} soundManager;



luabind::module(state) [
	// How to register textureManager.add as resources.add_texture
	// and soundManager.add as resources.add_sound?
];


?
Advertisement
int add_texture(std::string id, std::string file){    textureManager.add(id, file);}int add_sound(std::string id, std::string file){    soundManager.add(id, file);}...luabind::module(state,"resources") [    def("add_texture", &add_texture),    def("add_sound", &add_sound)];
Ah, of course. Thanks.

This topic is closed to new replies.

Advertisement