summaryrefslogtreecommitdiffstats
path: root/gin/object_template_builder.h
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-10 12:55:19 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-10 12:55:19 +0000
commit777183d073f20b851391345e6a5d8ca9ad7a45ac (patch)
tree7f2d29aa6bf991f79da63139d399bb5bac2cc622 /gin/object_template_builder.h
parent05a526aa340676d4df945b3c772cb17bc200dbe1 (diff)
downloadchromium_src-777183d073f20b851391345e6a5d8ca9ad7a45ac.zip
chromium_src-777183d073f20b851391345e6a5d8ca9ad7a45ac.tar.gz
chromium_src-777183d073f20b851391345e6a5d8ca9ad7a45ac.tar.bz2
gin: Add ability to install call-as-function handlers on gin::Wrappable
BUG=347565 R=dcarney@chromium.org Review URL: https://codereview.chromium.org/192693002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255927 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gin/object_template_builder.h')
-rw-r--r--gin/object_template_builder.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/gin/object_template_builder.h b/gin/object_template_builder.h
index 6367b71..768f4c8 100644
--- a/gin/object_template_builder.h
+++ b/gin/object_template_builder.h
@@ -27,6 +27,11 @@ struct CallbackTraits {
T callback) {
return CreateFunctionTemplate(isolate, base::Bind(callback));
}
+ static void SetAsFunctionHandler(v8::Isolate* isolate,
+ v8::Local<v8::ObjectTemplate> tmpl,
+ T callback) {
+ CreateFunctionHandler(isolate, tmpl, base::Bind(callback));
+ }
};
// Specialization for base::Callback.
@@ -36,6 +41,11 @@ struct CallbackTraits<base::Callback<T> > {
v8::Isolate* isolate, const base::Callback<T>& callback) {
return CreateFunctionTemplate(isolate, callback);
}
+ static void SetAsFunctionHandler(v8::Isolate* isolate,
+ v8::Local<v8::ObjectTemplate> tmpl,
+ const base::Callback<T>& callback) {
+ CreateFunctionHandler(isolate, tmpl, callback);
+ }
};
// Specialization for member function pointers. We need to handle this case
@@ -50,6 +60,12 @@ struct CallbackTraits<T, typename base::enable_if<
return CreateFunctionTemplate(isolate, base::Bind(callback),
HolderIsFirstArgument);
}
+ static void SetAsFunctionHandler(v8::Isolate* isolate,
+ v8::Local<v8::ObjectTemplate> tmpl,
+ T callback) {
+ CreateFunctionHandler(
+ isolate, tmpl, base::Bind(callback), HolderIsFirstArgument);
+ }
};
// This specialization allows people to construct function templates directly if
@@ -103,6 +119,11 @@ class GIN_EXPORT ObjectTemplateBuilder {
CallbackTraits<T>::CreateTemplate(isolate_, getter),
CallbackTraits<U>::CreateTemplate(isolate_, setter));
}
+ template<typename T>
+ ObjectTemplateBuilder& SetCallAsFunctionHandler(const T& callback) {
+ CallbackTraits<T>::SetAsFunctionHandler(isolate_, template_, callback);
+ return *this;
+ }
v8::Local<v8::ObjectTemplate> Build();