Index: gin/function_template.h.pump |
diff --git a/gin/function_template.h.pump b/gin/function_template.h.pump |
index 6f5badee9246866f166beff9e6926d7f32d55ed2..20b2821e0ef000c92c47b0269460bd1bc229ee5a 100644 |
--- a/gin/function_template.h.pump |
+++ b/gin/function_template.h.pump |
@@ -221,6 +221,20 @@ v8::Local<v8::FunctionTemplate> CreateFunctionTemplate( |
holder->GetHandle(isolate))); |
} |
+// CreateFunctionHandler installs a CallAsFunction handler on the given |
+// object template that forwards to a provided C++ function or base::Callback. |
+template<typename Sig> |
+void CreateFunctionHandler(v8::Isolate* isolate, |
+ v8::Local<v8::ObjectTemplate> tmpl, |
+ const base::Callback<Sig> callback, |
+ int callback_flags = 0) { |
+ typedef internal::CallbackHolder<Sig> HolderT; |
+ HolderT* holder = new HolderT(isolate, callback, callback_flags); |
+ tmpl->SetCallAsFunctionHandler(&internal::Dispatcher<Sig>::DispatchToCallback, |
+ ConvertToV8<v8::Handle<v8::External> >( |
+ isolate, holder->GetHandle(isolate))); |
+} |
+ |
} // namespace gin |
#endif // GIN_FUNCTION_TEMPLATE_H_ |