From: Thomas Geymayer Date: Tue, 13 Nov 2012 11:35:12 +0000 (+0100) Subject: Work around Visual Studio bug X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e872f9e92815d1d311b2ee268562adeb1e4fbc56;p=simgear.git Work around Visual Studio bug --- diff --git a/simgear/nasal/cppbind/Ghost.hxx b/simgear/nasal/cppbind/Ghost.hxx index b86367ce..2b037496 100644 --- a/simgear/nasal/cppbind/Ghost.hxx +++ b/simgear/nasal/cppbind/Ghost.hxx @@ -434,16 +434,21 @@ namespace nasal * * @tparam func Pointer to free function being registered. * + * @note Due to a severe bug in Visual Studio it is not possible to create + * a specialization of #method for free function pointers and + * member function pointers at the same time. Do overcome this + * limitation we had to use a different name for this function. + * * @code{cpp} * class MyClass; * naRef myMethod(MyClass& obj, naContext c, int argc, naRef* args); * * Ghost::init("Test") - * .method<&myMethod>("myMethod"); + * .method_func<&myMethod>("myMethod"); * @endcode */ template - Ghost& method(const std::string& name) + Ghost& method_func(const std::string& name) { _members[name].func = &FreeFunctionWrapper::call; return *this; diff --git a/simgear/nasal/cppbind/cppbind_test.cxx b/simgear/nasal/cppbind/cppbind_test.cxx index a6024858..1a68f1b5 100644 --- a/simgear/nasal/cppbind/cppbind_test.cxx +++ b/simgear/nasal/cppbind/cppbind_test.cxx @@ -23,6 +23,8 @@ struct Derived: void setX(int x) { _x = x; } }; +naRef member(Derived&, naContext, int, naRef*) { return naNil(); } + int main(int argc, char* argv[]) { naContext c = naNewContext(); @@ -76,7 +78,8 @@ int main(int argc, char* argv[]) .method<&Base::member>("member"); Ghost::init("Derived") .bases() - .member("x", &Derived::getX, &Derived::setX); + .member("x", &Derived::getX, &Derived::setX) + .method_func<&member>("free_member"); naRef derived = Ghost::create(c); VERIFY( naIsGhost(derived) );