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

Unified Diff: src/json-parser.h

Issue 2026563002: [json] implement InternalizeJSONProperty in C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase and address comments Created 4 years, 7 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 | « src/js/json.js ('k') | src/json-parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/json-parser.h
diff --git a/src/json-parser.h b/src/json-parser.h
index abbb99c93a236c2e08fdd86bd3b17846fd4f8fe8..2d08fefda98cc3db00e5e04f24cd89b53b743681 100644
--- a/src/json-parser.h
+++ b/src/json-parser.h
@@ -13,19 +13,45 @@ namespace internal {
enum ParseElementResult { kElementFound, kElementNotFound, kNullHandle };
+class JsonParseInternalizer BASE_EMBEDDED {
+ public:
+ static MaybeHandle<Object> Internalize(Isolate* isolate,
+ Handle<Object> object,
+ Handle<Object> reviver);
+
+ private:
+ JsonParseInternalizer(Isolate* isolate, Handle<JSReceiver> reviver)
+ : isolate_(isolate), reviver_(reviver) {}
+
+ MaybeHandle<Object> InternalizeJsonProperty(Handle<JSReceiver> holder,
+ Handle<String> key);
+
+ bool RecurseAndApply(Handle<JSReceiver> holder, Handle<String> name);
+
+ Isolate* isolate_;
+ Handle<JSReceiver> reviver_;
+};
// A simple json parser.
template <bool seq_one_byte>
class JsonParser BASE_EMBEDDED {
public:
- MUST_USE_RESULT static MaybeHandle<Object> Parse(Handle<String> source) {
- return JsonParser(source).ParseJson();
+ MUST_USE_RESULT static MaybeHandle<Object> Parse(Isolate* isolate,
+ Handle<String> source,
+ Handle<Object> reviver) {
+ Handle<Object> result;
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, result,
+ JsonParser(isolate, source).ParseJson(), Object);
+ if (reviver->IsCallable()) {
+ return JsonParseInternalizer::Internalize(isolate, result, reviver);
+ }
+ return result;
}
static const int kEndOfString = -1;
private:
- explicit JsonParser(Handle<String> source);
+ JsonParser(Isolate* isolate, Handle<String> source);
// Parse a string containing a single JSON value.
MaybeHandle<Object> ParseJson();
« no previous file with comments | « src/js/json.js ('k') | src/json-parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698