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

Unified Diff: include/v8.h

Issue 2311873002: [api] Add interceptor for getOwnPropertyDescriptor(). (Closed)
Patch Set: Rename and comments. Created 4 years, 3 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 | « no previous file | src/api.cc » ('j') | src/objects.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 9c45c1099185f8952851bd2031a2a9da076670ca..c93249c801dc39d333ffb5efa09a10b88315c860 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -4712,6 +4712,28 @@ typedef void (*GenericNamedPropertyDefinerCallback)(
const PropertyCallbackInfo<Value>& info);
/**
+ * Interceptor for getOwnPropertyDescriptor requests on an object.
+ *
+ * Use `info.GetReturnValue().Set()` to set the return value of the
+ * intercepted request. The return value must be an object that
+ * can be converted to a PropertyDescriptor, e.g., a `v8::value` returned from
+ * `v8::Object::getOwnPropertyDescriptor`.
+ *
+ * \param property The name of the property for which the request was
+ * intercepted.
+ * \info Information about the intercepted request, such as
+ * isolate, receiver, return value, or whether running in `'use strict'` mode.
+ * See `PropertyCallbackInfo`.
+ *
+ * \note If GetOwnPropertyDescriptor is intercepted, it will
+ * always return true, i.e., indicate that the property was found.
+ *
+ * See also `ObjectTemplate::SetNamedPropertyHandler`.
+ */
+typedef void (*GenericNamedPropertyDescriptorCallback)(
+ Local<Name> property, const PropertyCallbackInfo<Value>& info);
+
+/**
* Returns the value of the property if the getter intercepts the
* request. Otherwise, returns an empty handle.
*/
@@ -4760,6 +4782,9 @@ typedef void (*IndexedPropertyDefinerCallback)(
uint32_t index, const PropertyDescriptor& desc,
const PropertyCallbackInfo<Value>& info);
+typedef void (*IndexedPropertyDescriptorCallback)(
+ uint32_t index, const PropertyCallbackInfo<Value>& info);
+
/**
* Access type specification.
*/
@@ -5022,13 +5047,14 @@ struct NamedPropertyHandlerConfiguration {
deleter(deleter),
enumerator(enumerator),
definer(0),
+ descriptor(0),
data(data),
flags(flags) {}
NamedPropertyHandlerConfiguration(
GenericNamedPropertyGetterCallback getter,
GenericNamedPropertySetterCallback setter,
- GenericNamedPropertyQueryCallback query,
+ GenericNamedPropertyDescriptorCallback descriptor,
GenericNamedPropertyDeleterCallback deleter,
GenericNamedPropertyEnumeratorCallback enumerator,
GenericNamedPropertyDefinerCallback definer,
@@ -5036,10 +5062,11 @@ struct NamedPropertyHandlerConfiguration {
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
: getter(getter),
setter(setter),
- query(query),
+ query(0),
deleter(deleter),
enumerator(enumerator),
definer(definer),
+ descriptor(descriptor),
data(data),
flags(flags) {}
@@ -5049,6 +5076,7 @@ struct NamedPropertyHandlerConfiguration {
GenericNamedPropertyDeleterCallback deleter;
GenericNamedPropertyEnumeratorCallback enumerator;
GenericNamedPropertyDefinerCallback definer;
+ GenericNamedPropertyDescriptorCallback descriptor;
Local<Value> data;
PropertyHandlerFlags flags;
};
@@ -5070,12 +5098,14 @@ struct IndexedPropertyHandlerConfiguration {
deleter(deleter),
enumerator(enumerator),
definer(0),
+ descriptor(0),
data(data),
flags(flags) {}
IndexedPropertyHandlerConfiguration(
IndexedPropertyGetterCallback getter,
- IndexedPropertySetterCallback setter, IndexedPropertyQueryCallback query,
+ IndexedPropertySetterCallback setter,
+ IndexedPropertyDescriptorCallback descriptor,
IndexedPropertyDeleterCallback deleter,
IndexedPropertyEnumeratorCallback enumerator,
IndexedPropertyDefinerCallback definer,
@@ -5083,10 +5113,11 @@ struct IndexedPropertyHandlerConfiguration {
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
: getter(getter),
setter(setter),
- query(query),
+ query(0),
deleter(deleter),
enumerator(enumerator),
definer(definer),
+ descriptor(descriptor),
data(data),
flags(flags) {}
@@ -5096,6 +5127,7 @@ struct IndexedPropertyHandlerConfiguration {
IndexedPropertyDeleterCallback deleter;
IndexedPropertyEnumeratorCallback enumerator;
IndexedPropertyDefinerCallback definer;
+ IndexedPropertyDescriptorCallback descriptor;
Local<Value> data;
PropertyHandlerFlags flags;
};
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698