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

Unified Diff: include/v8.h

Issue 2756523004: WIP: Create a public v8::DictionarySchema API for bulk reads from dict objects.
Patch Set: Created 3 years, 9 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.h » ('j') | no next file with comments »
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 d7b7205ef0a0b18e341343875f614ca18fed6610..5f0d367e6b6aaab723fef16197e13ba6875e1970 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -302,6 +302,7 @@ class Local {
template<class F1, class F2> friend class PersistentValueVector;
template <class F>
friend class ReturnValue;
+ friend class DictionarySchema;
explicit V8_INLINE Local(T* that) : val_(that) {}
V8_INLINE static Local<T> New(Isolate* isolate, T* that);
@@ -5581,6 +5582,38 @@ class V8_EXPORT AccessorSignature : public Data {
AccessorSignature();
};
+// --- Dictionary schema ---
+
+/*
+ * A DictionarySchema defines the keys expected to be present on a dictionary
+ * object and provides an efficient way of reading them.
+ */
+class V8_EXPORT DictionarySchema : public Data {
+ public:
+ static Local<DictionarySchema> New(Isolate* isolate, Local<Value> keys[],
+ int keyCount);
+
+ enum ValueFilter {
+ kValueFilterNone = 0,
+ kValueFilterPrimitives = 1 << 0,
+ kValueFilterObjects = 1 << 1,
+ };
+
+ /*
+ * Reads keys from the object according to the schema, in order.
+ * Reading will abort if:
+ * - an exception is thrown (Nothing<bool>() is returned)
+ * - an object that doesn't match |continue_filter| is reached
+ * (Just(false) is returned)
+ * - all properties are read (Just(true) is returned)
+ *
+ * |index| will be updated to point to the next index left to be read;
+ * this makes repeated invocations convenient.
+ */
+ Maybe<bool> Get(Local<Context> context, Local<Object> object,
+ ValueFilter continue_filter, Local<Value>* out_values,
+ int out_length, int* index);
+};
// --- Extensions ---
« no previous file with comments | « no previous file | src/api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698