Commit 8202410c authored by dcarney@chromium.org's avatar dcarney@chromium.org

deprecate old style callbacks

R=svenpanne@chromium.org
BUG=

Review URL: https://codereview.chromium.org/17069003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15239 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 697bee61
...@@ -154,6 +154,7 @@ class Isolate; ...@@ -154,6 +154,7 @@ class Isolate;
class DeclaredAccessorDescriptor; class DeclaredAccessorDescriptor;
class ObjectOperationDescriptor; class ObjectOperationDescriptor;
class RawOperationDescriptor; class RawOperationDescriptor;
class CallHandlerHelper;
namespace internal { namespace internal {
class Arguments; class Arguments;
...@@ -2053,13 +2054,12 @@ class V8EXPORT Object : public Value { ...@@ -2053,13 +2054,12 @@ class V8EXPORT Object : public Value {
bool Delete(uint32_t index); bool Delete(uint32_t index);
// TODO(dcarney): deprecate V8_DEPRECATED(bool SetAccessor(Handle<String> name,
bool SetAccessor(Handle<String> name, AccessorGetter getter,
AccessorGetter getter, AccessorSetter setter = 0,
AccessorSetter setter = 0, Handle<Value> data = Handle<Value>(),
Handle<Value> data = Handle<Value>(), AccessControl settings = DEFAULT,
AccessControl settings = DEFAULT, PropertyAttribute attribute = None));
PropertyAttribute attribute = None);
bool SetAccessor(Handle<String> name, bool SetAccessor(Handle<String> name,
AccessorGetterCallback getter, AccessorGetterCallback getter,
AccessorSetterCallback setter = 0, AccessorSetterCallback setter = 0,
...@@ -3195,14 +3195,13 @@ typedef bool (*IndexedSecurityCallback)(Local<Object> host, ...@@ -3195,14 +3195,13 @@ typedef bool (*IndexedSecurityCallback)(Local<Object> host,
class V8EXPORT FunctionTemplate : public Template { class V8EXPORT FunctionTemplate : public Template {
public: public:
/** Creates a function template.*/ /** Creates a function template.*/
// TODO(dcarney): deprecate V8_DEPRECATED(static Local<FunctionTemplate> New(
static Local<FunctionTemplate> New( InvocationCallback callback,
InvocationCallback callback = 0,
Handle<Value> data = Handle<Value>(), Handle<Value> data = Handle<Value>(),
Handle<Signature> signature = Handle<Signature>(), Handle<Signature> signature = Handle<Signature>(),
int length = 0); int length = 0));
static Local<FunctionTemplate> New( static Local<FunctionTemplate> New(
FunctionCallback callback, // TODO(dcarney): add back default param. FunctionCallback callback = 0,
Handle<Value> data = Handle<Value>(), Handle<Value> data = Handle<Value>(),
Handle<Signature> signature = Handle<Signature>(), Handle<Signature> signature = Handle<Signature>(),
int length = 0); int length = 0);
...@@ -3215,9 +3214,8 @@ class V8EXPORT FunctionTemplate : public Template { ...@@ -3215,9 +3214,8 @@ class V8EXPORT FunctionTemplate : public Template {
* callback is called whenever the function created from this * callback is called whenever the function created from this
* FunctionTemplate is called. * FunctionTemplate is called.
*/ */
// TODO(dcarney): deprecate V8_DEPRECATED(void SetCallHandler(InvocationCallback callback,
void SetCallHandler(InvocationCallback callback, Handle<Value> data = Handle<Value>()));
Handle<Value> data = Handle<Value>());
void SetCallHandler(FunctionCallback callback, void SetCallHandler(FunctionCallback callback,
Handle<Value> data = Handle<Value>()); Handle<Value> data = Handle<Value>());
...@@ -3271,6 +3269,9 @@ class V8EXPORT FunctionTemplate : public Template { ...@@ -3271,6 +3269,9 @@ class V8EXPORT FunctionTemplate : public Template {
private: private:
FunctionTemplate(); FunctionTemplate();
// TODO(dcarney): Remove with SetCallHandler.
friend class v8::CallHandlerHelper;
void SetCallHandlerInternal(InvocationCallback callback, Handle<Value> data);
friend class Context; friend class Context;
friend class ObjectTemplate; friend class ObjectTemplate;
}; };
...@@ -3319,15 +3320,14 @@ class V8EXPORT ObjectTemplate : public Template { ...@@ -3319,15 +3320,14 @@ class V8EXPORT ObjectTemplate : public Template {
* defined by FunctionTemplate::HasInstance()), an implicit TypeError is * defined by FunctionTemplate::HasInstance()), an implicit TypeError is
* thrown and no callback is invoked. * thrown and no callback is invoked.
*/ */
// TODO(dcarney): deprecate V8_DEPRECATED(void SetAccessor(Handle<String> name,
void SetAccessor(Handle<String> name, AccessorGetter getter,
AccessorGetter getter, AccessorSetter setter = 0,
AccessorSetter setter = 0, Handle<Value> data = Handle<Value>(),
Handle<Value> data = Handle<Value>(), AccessControl settings = DEFAULT,
AccessControl settings = DEFAULT, PropertyAttribute attribute = None,
PropertyAttribute attribute = None, Handle<AccessorSignature> signature =
Handle<AccessorSignature> signature = Handle<AccessorSignature>()));
Handle<AccessorSignature>());
void SetAccessor(Handle<String> name, void SetAccessor(Handle<String> name,
AccessorGetterCallback getter, AccessorGetterCallback getter,
AccessorSetterCallback setter = 0, AccessorSetterCallback setter = 0,
...@@ -3362,13 +3362,13 @@ class V8EXPORT ObjectTemplate : public Template { ...@@ -3362,13 +3362,13 @@ class V8EXPORT ObjectTemplate : public Template {
* \param data A piece of data that will be passed to the callbacks * \param data A piece of data that will be passed to the callbacks
* whenever they are invoked. * whenever they are invoked.
*/ */
// TODO(dcarney): deprecate V8_DEPRECATED(void SetNamedPropertyHandler(
void SetNamedPropertyHandler(NamedPropertyGetter getter, NamedPropertyGetter getter,
NamedPropertySetter setter = 0, NamedPropertySetter setter = 0,
NamedPropertyQuery query = 0, NamedPropertyQuery query = 0,
NamedPropertyDeleter deleter = 0, NamedPropertyDeleter deleter = 0,
NamedPropertyEnumerator enumerator = 0, NamedPropertyEnumerator enumerator = 0,
Handle<Value> data = Handle<Value>()); Handle<Value> data = Handle<Value>()));
void SetNamedPropertyHandler( void SetNamedPropertyHandler(
NamedPropertyGetterCallback getter, NamedPropertyGetterCallback getter,
NamedPropertySetterCallback setter = 0, NamedPropertySetterCallback setter = 0,
...@@ -3393,13 +3393,13 @@ class V8EXPORT ObjectTemplate : public Template { ...@@ -3393,13 +3393,13 @@ class V8EXPORT ObjectTemplate : public Template {
* \param data A piece of data that will be passed to the callbacks * \param data A piece of data that will be passed to the callbacks
* whenever they are invoked. * whenever they are invoked.
*/ */
// TODO(dcarney): deprecate V8_DEPRECATED(void SetIndexedPropertyHandler(
void SetIndexedPropertyHandler(IndexedPropertyGetter getter, IndexedPropertyGetter getter,
IndexedPropertySetter setter = 0, IndexedPropertySetter setter = 0,
IndexedPropertyQuery query = 0, IndexedPropertyQuery query = 0,
IndexedPropertyDeleter deleter = 0, IndexedPropertyDeleter deleter = 0,
IndexedPropertyEnumerator enumerator = 0, IndexedPropertyEnumerator enumerator = 0,
Handle<Value> data = Handle<Value>()); Handle<Value> data = Handle<Value>()));
void SetIndexedPropertyHandler( void SetIndexedPropertyHandler(
IndexedPropertyGetterCallback getter, IndexedPropertyGetterCallback getter,
IndexedPropertySetterCallback setter = 0, IndexedPropertySetterCallback setter = 0,
...@@ -3414,9 +3414,9 @@ class V8EXPORT ObjectTemplate : public Template { ...@@ -3414,9 +3414,9 @@ class V8EXPORT ObjectTemplate : public Template {
* behave like normal JavaScript objects that cannot be called as a * behave like normal JavaScript objects that cannot be called as a
* function. * function.
*/ */
// TODO(dcarney): deprecate V8_DEPRECATED(void SetCallAsFunctionHandler(
void SetCallAsFunctionHandler(InvocationCallback callback, InvocationCallback callback,
Handle<Value> data = Handle<Value>()); Handle<Value> data = Handle<Value>()));
void SetCallAsFunctionHandler(FunctionCallback callback, void SetCallAsFunctionHandler(FunctionCallback callback,
Handle<Value> data = Handle<Value>()); Handle<Value> data = Handle<Value>());
......
...@@ -961,6 +961,22 @@ void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { ...@@ -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> template<typename Callback>
static Local<FunctionTemplate> FunctionTemplateNew( static Local<FunctionTemplate> FunctionTemplateNew(
Callback callback, Callback callback,
...@@ -981,7 +997,7 @@ static Local<FunctionTemplate> FunctionTemplateNew( ...@@ -981,7 +997,7 @@ static Local<FunctionTemplate> FunctionTemplateNew(
obj->set_serial_number(i::Smi::FromInt(next_serial_number)); obj->set_serial_number(i::Smi::FromInt(next_serial_number));
if (callback != 0) { if (callback != 0) {
if (data.IsEmpty()) data = v8::Undefined(); 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_length(length);
obj->set_undetectable(false); obj->set_undetectable(false);
...@@ -1225,6 +1241,11 @@ void FunctionTemplate::SetCallHandler(InvocationCallback callback, ...@@ -1225,6 +1241,11 @@ void FunctionTemplate::SetCallHandler(InvocationCallback callback,
FunctionTemplateSetCallHandler(this, callback, data); FunctionTemplateSetCallHandler(this, callback, data);
} }
void FunctionTemplate::SetCallHandlerInternal(InvocationCallback callback,
v8::Handle<Value> data) {
FunctionTemplateSetCallHandler(this, callback, data);
}
void FunctionTemplate::SetCallHandler(FunctionCallback callback, void FunctionTemplate::SetCallHandler(FunctionCallback callback,
v8::Handle<Value> data) { v8::Handle<Value> data) {
FunctionTemplateSetCallHandler(this, callback, data); FunctionTemplateSetCallHandler(this, callback, data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment