*
* @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;
void setX(int x) { _x = x; }
};
+naRef member(Derived&, naContext, int, naRef*) { return naNil(); }
+
int main(int argc, char* argv[])
{
naContext c = naNewContext();
.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) );