Created
April 5, 2012 17:01
-
-
Save rectalogic/2312526 to your computer and use it in GitHub Desktop.
template dispatching to pointer to member function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class T, int Arity, v8::Handle<v8::Value> (T::*InvocationCallbackMember)(v8::Arguments const&)> | |
static v8::Handle<v8::Value> InvocationCallbackDispatcher(v8::Arguments const& args) { | |
if (args.Length() < Arity) | |
return ThrowArgCount(); | |
T* object = T::FromV8Object(args.Holder()); | |
if (!object) | |
return ThrowObjectDisposed(); | |
try { | |
return ((*object).*(InvocationCallbackMember))(args); | |
} catch (...) { | |
return v8::ThrowException(v8::String::New("Caught unknown native exception.")); | |
} | |
} | |
//// | |
InvocationCallbackDispatcher<Canvas, 2, &Canvas::Callback_getContext>(args); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment