Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: src/api.cc

Issue 17069003: deprecate old style callbacks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 9b1d01cd8f4ead1bab6e46f03c3ed362157f8c13..579af7aebd442e4c346d1bc65dcc56d75b1b8073 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -961,6 +961,22 @@ void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) {
}
+// TODO(dcarney): Remove this abstraction when old callbacks are removed.
+class CallHandlerHelper {
+ public:
+ static inline void Set(Local<FunctionTemplate> function_template,
+ InvocationCallback callback,
+ v8::Handle<Value> data) {
+ function_template->SetCallHandlerInternal(callback, data);
+ }
+ static inline void Set(Local<FunctionTemplate> function_template,
+ FunctionCallback callback,
+ v8::Handle<Value> data) {
+ function_template->SetCallHandler(callback, data);
+ }
+};
+
+
template<typename Callback>
static Local<FunctionTemplate> FunctionTemplateNew(
Callback callback,
@@ -981,7 +997,7 @@ static Local<FunctionTemplate> FunctionTemplateNew(
obj->set_serial_number(i::Smi::FromInt(next_serial_number));
if (callback != 0) {
if (data.IsEmpty()) data = v8::Undefined();
- Utils::ToLocal(obj)->SetCallHandler(callback, data);
+ CallHandlerHelper::Set(Utils::ToLocal(obj), callback, data);
}
obj->set_length(length);
obj->set_undetectable(false);
@@ -1225,6 +1241,11 @@ void FunctionTemplate::SetCallHandler(InvocationCallback callback,
FunctionTemplateSetCallHandler(this, callback, data);
}
+void FunctionTemplate::SetCallHandlerInternal(InvocationCallback callback,
+ v8::Handle<Value> data) {
+ FunctionTemplateSetCallHandler(this, callback, data);
+}
+
void FunctionTemplate::SetCallHandler(FunctionCallback callback,
v8::Handle<Value> data) {
FunctionTemplateSetCallHandler(this, callback, data);
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698