Luabind exposing derived class problem

Started by
0 comments, last by MurphyIdiot 15 years, 11 months ago
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.
Advertisement
You shouldn't need to use bases if you have only one base.

luabind::class_<Dog, Animal >("Dog")

This topic is closed to new replies.

Advertisement