Index: include/v8.h |
diff --git a/include/v8.h b/include/v8.h |
index d31ef5405cfaf5c0fb7bbd419b73c50b715ca3a9..77ffb385ab97f34381177e4a39e2f01aec62fa94 100644 |
--- a/include/v8.h |
+++ b/include/v8.h |
@@ -100,6 +100,7 @@ class Function; |
class Date; |
class ImplementationUtilities; |
class Signature; |
+class AccessorSignature; |
template <class T> class Handle; |
template <class T> class Local; |
template <class T> class Persistent; |
@@ -2289,7 +2290,8 @@ class V8EXPORT FunctionTemplate : public Template { |
AccessorSetter setter, |
Handle<Value> data, |
AccessControl settings, |
- PropertyAttribute attributes); |
+ PropertyAttribute attributes, |
+ Handle<AccessorSignature> signature); |
void SetNamedInstancePropertyHandler(NamedPropertyGetter getter, |
NamedPropertySetter setter, |
NamedPropertyQuery query, |
@@ -2347,13 +2349,20 @@ class V8EXPORT ObjectTemplate : public Template { |
* cross-context access. |
* \param attribute The attributes of the property for which an accessor |
* is added. |
+ * \param signature The signature describes valid receivers for the accessor |
+ * and is used to perform implicit instance checks against them. If the |
+ * receiver is incompatible (i.e. is not an instance of the constructor as |
+ * defined by FunctionTemplate::HasInstance()), an implicit TypeError is |
+ * thrown and no callback is invoked. |
*/ |
void SetAccessor(Handle<String> name, |
AccessorGetter getter, |
AccessorSetter setter = 0, |
Handle<Value> data = Handle<Value>(), |
AccessControl settings = DEFAULT, |
- PropertyAttribute attribute = None); |
+ PropertyAttribute attribute = None, |
+ Handle<AccessorSignature> signature = |
+ Handle<AccessorSignature>()); |
/** |
* Sets a named property handler on the object template. |
@@ -2457,8 +2466,8 @@ class V8EXPORT ObjectTemplate : public Template { |
/** |
- * A Signature specifies which receivers and arguments a function can |
- * legally be called with. |
+ * A Signature specifies which receivers and arguments are valid |
+ * parameters to a function. |
*/ |
class V8EXPORT Signature : public Data { |
public: |
@@ -2472,6 +2481,19 @@ class V8EXPORT Signature : public Data { |
/** |
+ * An AccessorSignature specifies which receivers are valid parameters |
+ * to an accessor callback. |
+ */ |
+class V8EXPORT AccessorSignature : public Data { |
+ public: |
+ static Local<AccessorSignature> New(Handle<FunctionTemplate> receiver = |
+ Handle<FunctionTemplate>()); |
+ private: |
+ AccessorSignature(); |
+}; |
+ |
+ |
+/** |
* A utility for determining the type of objects based on the template |
* they were constructed from. |
*/ |