Work around Visual Studio bug
This commit is contained in:
@@ -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<MyClass>::init("Test")
|
||||
* .method<&myMethod>("myMethod");
|
||||
* .method_func<&myMethod>("myMethod");
|
||||
* @endcode
|
||||
*/
|
||||
template<free_func_t func>
|
||||
Ghost& method(const std::string& name)
|
||||
Ghost& method_func(const std::string& name)
|
||||
{
|
||||
_members[name].func = &FreeFunctionWrapper<func>::call;
|
||||
return *this;
|
||||
|
||||
@@ -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<Derived>::init("Derived")
|
||||
.bases<Base>()
|
||||
.member("x", &Derived::getX, &Derived::setX);
|
||||
.member("x", &Derived::getX, &Derived::setX)
|
||||
.method_func<&member>("free_member");
|
||||
|
||||
naRef derived = Ghost<Derived>::create(c);
|
||||
VERIFY( naIsGhost(derived) );
|
||||
|
||||
Reference in New Issue
Block a user