decimad / luabind-deboostified

Create Lua bindings for your C++ code easily - my improvements
http://www.vrac.iastate.edu/vancegroup/docs/luabind/
Other
70 stars 27 forks source link

Compile error VC12 (VS2013 RTM) #4

Closed tripleslash closed 10 years ago

tripleslash commented 11 years ago
    luabind::module(L) [
    luabind::class_<ID3DInterface,
        std::shared_ptr<ID3DInterface>>("ID3DInterface")
];

2>libs\luabind/detail/inheritance.hpp(133): error C2440: 'static_cast': 'ID3DInterface *' cannot be converted to 'std::shared_ptr<ID3DInterface> *'.

Works in Oberon00's version.

Full error in german:

2>E:\crap\dev\prometheus\trunk\libs\luabind/detail/inheritance.hpp(133): error C2440: 'static_cast': 'ID3DInterface *' kann nicht in 'std::shared_ptr<ID3DInterface> *' konvertiert werden
2>          Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat.
2>          E:\crap\dev\prometheus\trunk\libs\luabind/detail/inheritance.hpp(132): Bei der Kompilierung der  Klassen-template der void *luabind::detail::static_cast_<T,Class0>::execute(void *)-Memberfunktion
2>          with
2>          [
2>              T=ID3DInterface
2>  ,            Class0=std::shared_ptr<ID3DInterface>
2>          ]
2>          E:\crap\dev\prometheus\trunk\libs\luabind/class.hpp(531): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template "void *luabind::detail::static_cast_<T,Class0>::execute(void *)".
2>          with
2>          [
2>              T=ID3DInterface
2>  ,            Class0=std::shared_ptr<ID3DInterface>
2>          ]
2>          E:\crap\dev\prometheus\trunk\libs\luabind/class.hpp(531): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "luabind::detail::static_cast_<T,Class0>".
2>          with
2>          [
2>              T=ID3DInterface
2>  ,            Class0=std::shared_ptr<ID3DInterface>
2>          ]
2>          E:\crap\dev\prometheus\trunk\libs\luabind/class.hpp(543): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template "void luabind::class_<ID3DInterface,std::shared_ptr<ID3DInterface>,luabind::detail::null_type,luabind::detail::null_type>::gen_base_info<T,>(luabind::bases<T>)".
2>          with
2>          [
2>              T=std::shared_ptr<ID3DInterface>
2>          ]
2>          E:\crap\dev\prometheus\trunk\libs\luabind/class.hpp(543): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template "void luabind::class_<ID3DInterface,std::shared_ptr<ID3DInterface>,luabind::detail::null_type,luabind::detail::null_type>::gen_base_info<T,>(luabind::bases<T>)".
2>          with
2>          [
2>              T=std::shared_ptr<ID3DInterface>
2>          ]
2>          E:\crap\dev\prometheus\trunk\libs\luabind/class.hpp(542): Bei der Kompilierung der  Klassen-template der void luabind::class_<ID3DInterface,std::shared_ptr<ID3DInterface>,luabind::detail::null_type,luabind::detail::null_type>::generate_baseclass_list(void)-Memberfunktion
2>          E:\crap\dev\prometheus\trunk\libs\luabind/class.hpp(508): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template "void luabind::class_<ID3DInterface,std::shared_ptr<ID3DInterface>,luabind::detail::null_type,luabind::detail::null_type>::generate_baseclass_list(void)".
2>          src\Base\ID3DInterface.cpp(14): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "luabind::class_<ID3DInterface,std::shared_ptr<ID3DInterface>,luabind::detail::null_type,luabind::detail::null_type>".
tripleslash commented 11 years ago

Has to be some bug with the shared_ptr recognition. Doesn't recognize it as holder type somehow.

decimad commented 11 years ago

Hello, this is an incompatibility I intridocuded when taking the whole thing apart. The original luabind did all kinds of conversion trickery stuff so you could give any parameter at any of the 4 template argument indices. I switched to <class, base or base list, holder type, wrapper type>. The holder type is what you're trying to achieve there. The fix for your case would be to introduce a "luabind::no_bases" inbetween the parameters. That being said - the luabind I forked from was incredibly buggy with regards to shared pointers, which leads to the point where shared counts get fragmented, which again leads literally to death. As I noted in your first post, I have a version in personal use that preserves smart pointer integrity without resorting to custom deleter tricks that don't work anyways (if interested also have a look at the corresponding bug report in oberon's repo). However I made that change while also allocating user data memory from within the generated constructors (to store any size of object per value in one place), which basically breaks the luabind class machinery on the lua side (Ie. defining classes or deriving from wrap_base classes), because they relied on the constructor to in-place-construct into prescribed memory boundaries (which means that the prepared memory only really holds a pointer to the real object in the end if it was larger than 16 bytes or something). So it's currently a technical problem to somehow make that work again. I consider backporting the smart-pointer stuff so not too much time passes by until I fixed the classes. I also need to work out the implicit casting of smart pointers (which "worked" in the original source because the smart pointers were just stripped away, introducing the said problems).

To the initial problem: Is the "any parameter at any parameter index"-thingy that luabind had wanted? If so, I will reintroduce it and see if I can document it better so that anybody knows what's going on. I found it to be unintuitive when working on that part.

Thank you for your feedback, this really helps me a lot!

tripleslash commented 11 years ago

Hey, huge thanks for that! I should have seen the bases template parameter. Anything new regarding smart_ptr support?