Skip to content

Instantly share code, notes, and snippets.

@GregoryHlavac
Created March 2, 2014 06:20
Show Gist options
  • Save GregoryHlavac/9302699 to your computer and use it in GitHub Desktop.
Save GregoryHlavac/9302699 to your computer and use it in GitHub Desktop.
template <typename ReturnType, typename... ArgumentTypes>
struct FunctionGear
{
typedef std::function<ReturnType(ArgumentTypes...)> NativeFunction;
FunctionGear(NativeFunction nf) : mNativeFunction(nf){}
void Invoke(const v8::FunctionCallbackInfo<v8::Value> args)
{
size_t currentArgumentIndex = args.Length() - 1;
mNativeFunction(ConvertTypeAtIndex<ArgumentTypes>(args.GetIsolate(), args, currentArgumentIndex)...);
}
private:
NativeFunction mNativeFunction;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment