Revision: 15239
Author:   [email protected]
Date:     Thu Jun 20 05:53:19 2013
Log:      deprecate old style callbacks

[email protected]
BUG=

Review URL: https://codereview.chromium.org/17069003
http://code.google.com/p/v8/source/detail?r=15239

Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/src/api.cc

=======================================
--- /branches/bleeding_edge/include/v8.h        Tue Jun 18 00:39:15 2013
+++ /branches/bleeding_edge/include/v8.h        Thu Jun 20 05:53:19 2013
@@ -154,6 +154,7 @@
 class DeclaredAccessorDescriptor;
 class ObjectOperationDescriptor;
 class RawOperationDescriptor;
+class CallHandlerHelper;

 namespace internal {
 class Arguments;
@@ -2053,14 +2054,13 @@

   bool Delete(uint32_t index);

-  // TODO(dcarney): deprecate
+  V8_DEPRECATED(bool SetAccessor(Handle<String> name,
+                                 AccessorGetter getter,
+                                 AccessorSetter setter = 0,
+                                 Handle<Value> data = Handle<Value>(),
+                                 AccessControl settings = DEFAULT,
+                                 PropertyAttribute attribute = None));
   bool SetAccessor(Handle<String> name,
-                   AccessorGetter getter,
-                   AccessorSetter setter = 0,
-                   Handle<Value> data = Handle<Value>(),
-                   AccessControl settings = DEFAULT,
-                   PropertyAttribute attribute = None);
-  bool SetAccessor(Handle<String> name,
                    AccessorGetterCallback getter,
                    AccessorSetterCallback setter = 0,
                    Handle<Value> data = Handle<Value>(),
@@ -3195,14 +3195,13 @@
 class V8EXPORT FunctionTemplate : public Template {
  public:
   /** Creates a function template.*/
-  // TODO(dcarney): deprecate
-  static Local<FunctionTemplate> New(
-      InvocationCallback callback = 0,
+  V8_DEPRECATED(static Local<FunctionTemplate> New(
+      InvocationCallback callback,
       Handle<Value> data = Handle<Value>(),
       Handle<Signature> signature = Handle<Signature>(),
-      int length = 0);
+      int length = 0));
   static Local<FunctionTemplate> New(
-      FunctionCallback callback,  // TODO(dcarney): add back default param.
+      FunctionCallback callback = 0,
       Handle<Value> data = Handle<Value>(),
       Handle<Signature> signature = Handle<Signature>(),
       int length = 0);
@@ -3215,9 +3214,8 @@
    * callback is called whenever the function created from this
    * FunctionTemplate is called.
    */
-  // TODO(dcarney): deprecate
-  void SetCallHandler(InvocationCallback callback,
-                      Handle<Value> data = Handle<Value>());
+  V8_DEPRECATED(void SetCallHandler(InvocationCallback callback,
+                                    Handle<Value> data = Handle<Value>()));
   void SetCallHandler(FunctionCallback callback,
                       Handle<Value> data = Handle<Value>());

@@ -3271,6 +3269,9 @@

  private:
   FunctionTemplate();
+  // TODO(dcarney): Remove with SetCallHandler.
+  friend class v8::CallHandlerHelper;
+ void SetCallHandlerInternal(InvocationCallback callback, Handle<Value> data);
   friend class Context;
   friend class ObjectTemplate;
 };
@@ -3319,15 +3320,14 @@
* defined by FunctionTemplate::HasInstance()), an implicit TypeError is
    *   thrown and no callback is invoked.
    */
-  // TODO(dcarney): deprecate
-  void SetAccessor(Handle<String> name,
-                   AccessorGetter getter,
-                   AccessorSetter setter = 0,
-                   Handle<Value> data = Handle<Value>(),
-                   AccessControl settings = DEFAULT,
-                   PropertyAttribute attribute = None,
-                   Handle<AccessorSignature> signature =
-                       Handle<AccessorSignature>());
+  V8_DEPRECATED(void SetAccessor(Handle<String> name,
+                                 AccessorGetter getter,
+                                 AccessorSetter setter = 0,
+                                 Handle<Value> data = Handle<Value>(),
+                                 AccessControl settings = DEFAULT,
+                                 PropertyAttribute attribute = None,
+                                 Handle<AccessorSignature> signature =
+                                     Handle<AccessorSignature>()));
   void SetAccessor(Handle<String> name,
                    AccessorGetterCallback getter,
                    AccessorSetterCallback setter = 0,
@@ -3362,13 +3362,13 @@
    * \param data A piece of data that will be passed to the callbacks
    *   whenever they are invoked.
    */
-  // TODO(dcarney): deprecate
-  void SetNamedPropertyHandler(NamedPropertyGetter getter,
-                               NamedPropertySetter setter = 0,
-                               NamedPropertyQuery query = 0,
-                               NamedPropertyDeleter deleter = 0,
-                               NamedPropertyEnumerator enumerator = 0,
-                               Handle<Value> data = Handle<Value>());
+  V8_DEPRECATED(void SetNamedPropertyHandler(
+      NamedPropertyGetter getter,
+      NamedPropertySetter setter = 0,
+      NamedPropertyQuery query = 0,
+      NamedPropertyDeleter deleter = 0,
+      NamedPropertyEnumerator enumerator = 0,
+      Handle<Value> data = Handle<Value>()));
   void SetNamedPropertyHandler(
       NamedPropertyGetterCallback getter,
       NamedPropertySetterCallback setter = 0,
@@ -3393,13 +3393,13 @@
    * \param data A piece of data that will be passed to the callbacks
    *   whenever they are invoked.
    */
-  // TODO(dcarney): deprecate
-  void SetIndexedPropertyHandler(IndexedPropertyGetter getter,
-                                 IndexedPropertySetter setter = 0,
-                                 IndexedPropertyQuery query = 0,
-                                 IndexedPropertyDeleter deleter = 0,
-                                 IndexedPropertyEnumerator enumerator = 0,
-                                 Handle<Value> data = Handle<Value>());
+  V8_DEPRECATED(void SetIndexedPropertyHandler(
+      IndexedPropertyGetter getter,
+      IndexedPropertySetter setter = 0,
+      IndexedPropertyQuery query = 0,
+      IndexedPropertyDeleter deleter = 0,
+      IndexedPropertyEnumerator enumerator = 0,
+      Handle<Value> data = Handle<Value>()));
   void SetIndexedPropertyHandler(
       IndexedPropertyGetterCallback getter,
       IndexedPropertySetterCallback setter = 0,
@@ -3414,9 +3414,9 @@
    * behave like normal JavaScript objects that cannot be called as a
    * function.
    */
-  // TODO(dcarney): deprecate
-  void SetCallAsFunctionHandler(InvocationCallback callback,
-                                Handle<Value> data = Handle<Value>());
+  V8_DEPRECATED(void SetCallAsFunctionHandler(
+      InvocationCallback callback,
+      Handle<Value> data = Handle<Value>()));
   void SetCallAsFunctionHandler(FunctionCallback callback,
                                 Handle<Value> data = Handle<Value>());

=======================================
--- /branches/bleeding_edge/src/api.cc  Thu Jun 13 12:16:35 2013
+++ /branches/bleeding_edge/src/api.cc  Thu Jun 20 05:53:19 2013
@@ -959,6 +959,22 @@
   ENTER_V8(isolate);
   Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*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>
@@ -981,7 +997,7 @@
   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);
@@ -1224,6 +1240,11 @@
                                       v8::Handle<Value> data) {
   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) {

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to