Jump to content
  • Advertisement
Sign in to follow this  
McFury

Luabind exposing derived class problem

This topic is 3716 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi :) I have a problem trying to expose a class to luabind. When i expose a class normally it compiles and works fine, but when i try to expose a class that has inherited a base class (using the "bases<>" call) it brings up errors that i cant seem to figure out. I have made a scaled down test version of the problem which is pasted below.
#include "Dog.h"   //Animal and Dog are both declared in here

extern "C"
{
  #include <lua/lua.h>
  #include <lua/lualib.h>
  #include <lua/lauxlib.h>
}

#pragma comment (lib, "lua-d.lib")
#pragma comment (lib, "lauxlib-d.lib")
#pragma comment (lib, "luabind-d.lib")

#include <luabind/luabind.hpp>

using namespace luabind;

int main()
{
	lua_State *state;

	state = lua_open();

	luaopen_base(state);
	luaopen_string(state);
	luaopen_table(state);
	luaopen_math(state);
	luaopen_io(state);
	luabind::open(state);

	Dog puppy(0);

	luabind::module(state)
	[
		luabind::class_<Animal>("Animal")
		
		.def(luabind::constructor<int>())
		.def("SetAge", &Animal::SetAge)
		.def("GetAge", &Animal::GetAge)
	];

	luabind::module(state)
	[
		luabind::class_<Dog, bases<Animal> >("Dog")
		
		.def(luabind::constructor<int>())
		.def("SetType", &Dog::SetType)
		.def("GetType", &Dog::GetType)
	];

	return 0;
}
Without the "bases<Animal>" part it compiles fine, but with it i get the following errors.
ERRORS:

error C3203: 'type' : class template invalid as template argument for template parameter 'T2', expected a real type
error C3203: 'type' : class template invalid as template argument for template parameter 'T', expected a real type
error C3203: 'type' : class template invalid as template argument for template parameter 'A0', expected a real type
error C2955: 'luabind::detail::type' : use of class template requires template argument list
see declaration of 'luabind::detail::type'
error C2955: 'luabind::detail::type' : use of class template requires template argument list
see declaration of 'luabind::detail::type'
error C2039: 'type' : is not a member of 'boost::mpl::eval_if<C,F1,F2>'
        with
        [
            C=boost::is_same<boost::mpl::aux::iter_fold_if_null_step<boost::mpl::iter_fold_if<boost::mpl::list3<luabind::bases<Animal>,
luabind::detail::unspecified,luabind::detail::unspecified>,void,boost::mpl::arg<1>,boost::mpl::protect<boost::mpl::aux::find_if_pred<
luabind::detail::extract_parameter<boost::mpl::list3<luabind::bases<Animal>,luabind::detail::unspecified,luabind::detail::unspecified>,
boost::mpl::not_<boost::mpl::or_<boost::mpl::or_<luabind::detail::is_bases<boost::mpl::_>,boost::is_base_and_derived<boost::mpl::_,
Dog>>,boost::is_base_and_derived<Dog,boost::mpl::_>>>,luabind::detail::null_type>::pred>>>::first_,void>::iterator,
boost::mpl::iter_fold_if<boost::mpl::list3<luabind::bases<Animal>,luabind::detail::unspecified,luabind::detail::unspecified>,void,
boost::mpl::arg<1>,boost::mpl::protect<boost::mpl::aux::find_if_pred<luabind::detail::extract_parameter<boost::mpl::list3<
luabind::bases<Animal>,luabind::detail::unspecified,luabind::detail::unspecified>,boost::mpl::not_<boost::mpl::or_<boost::mpl::or_<
luabind::detail::is_bases<boost::mpl::_>,boost::is_base_and_derived<boost::mpl::_,Dog>>,boost::is_base_and_derived<Dog,boost::mpl::_>
>>,luabind::detail::null_type>::pred>>>::last_>,
            F1=boost::mpl::identity<luabind::no_bases>,
            F2=luabind::detail::extract_parameter<boost::mpl::list3<luabind::bases<Animal>,luabind::detail::unspecified,luabind::detail::unspecified>,
boost::mpl::or_<luabind::detail::is_bases<boost::mpl::_>,boost::is_base_and_derived<boost::mpl::_,Dog>>,luabind::no_bases>::iterator
        ]

If anyone could help i would be very thankful.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!