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

Side by Side Diff: src/json-stringifier.h

Issue 2008293002: Revert of [json] support replacer function in BasicJsonStringifier. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@jsonproplist
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/js/json.js ('k') | src/json-stringifier.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_JSON_STRINGIFIER_H_ 5 #ifndef V8_JSON_STRINGIFIER_H_
6 #define V8_JSON_STRINGIFIER_H_ 6 #define V8_JSON_STRINGIFIER_H_
7 7
8 #include "src/objects.h" 8 #include "src/objects.h"
9 #include "src/string-builder.h" 9 #include "src/string-builder.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 class JsonStringifier BASE_EMBEDDED { 14 class BasicJsonStringifier BASE_EMBEDDED {
15 public: 15 public:
16 explicit JsonStringifier(Isolate* isolate); 16 explicit BasicJsonStringifier(Isolate* isolate);
17 17
18 ~JsonStringifier() { DeleteArray(gap_); } 18 ~BasicJsonStringifier() { DeleteArray(gap_); }
19 19
20 MUST_USE_RESULT MaybeHandle<Object> Stringify(Handle<Object> object, 20 MUST_USE_RESULT MaybeHandle<Object> Stringify(Handle<Object> object,
21 Handle<Object> replacer, 21 Handle<Object> replacer,
22 Handle<Object> gap); 22 Handle<Object> gap);
23 23
24 MUST_USE_RESULT static MaybeHandle<Object> StringifyString(
25 Isolate* isolate, Handle<String> object);
26
24 private: 27 private:
25 enum Result { UNCHANGED, SUCCESS, EXCEPTION }; 28 enum Result { UNCHANGED, SUCCESS, EXCEPTION };
26 29
27 bool InitializeReplacer(Handle<Object> replacer); 30 bool InitializeReplacer(Handle<Object> replacer);
28 bool InitializeGap(Handle<Object> gap); 31 bool InitializeGap(Handle<Object> gap);
29 32
30 MUST_USE_RESULT MaybeHandle<Object> ApplyToJsonFunction( 33 MUST_USE_RESULT MaybeHandle<Object> ApplyToJsonFunction(
31 Handle<Object> object, 34 Handle<Object> object,
32 Handle<Object> key); 35 Handle<Object> key);
33 MUST_USE_RESULT MaybeHandle<Object> ApplyReplacerFunction(
34 Handle<Object> object, Handle<Object> key);
35 36
36 // Entry point to serialize the object. 37 // Entry point to serialize the object.
37 INLINE(Result SerializeObject(Handle<Object> obj)) { 38 INLINE(Result SerializeObject(Handle<Object> obj)) {
38 return Serialize_<false>(obj, false, factory()->empty_string()); 39 return Serialize_<false>(obj, false, factory()->empty_string());
39 } 40 }
40 41
41 // Serialize an array element. 42 // Serialize an array element.
42 // The index may serve as argument for the toJSON function. 43 // The index may serve as argument for the toJSON function.
43 INLINE(Result SerializeElement(Isolate* isolate, 44 INLINE(Result SerializeElement(Isolate* isolate,
44 Handle<Object> object, 45 Handle<Object> object,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 INLINE(void SerializeString_(Handle<String> string)); 93 INLINE(void SerializeString_(Handle<String> string));
93 94
94 template <typename Char> 95 template <typename Char>
95 INLINE(static bool DoNotEscape(Char c)); 96 INLINE(static bool DoNotEscape(Char c));
96 97
97 INLINE(void NewLine()); 98 INLINE(void NewLine());
98 INLINE(void Indent() { indent_++; }); 99 INLINE(void Indent() { indent_++; });
99 INLINE(void Unindent() { indent_--; }); 100 INLINE(void Unindent() { indent_--; });
100 INLINE(void Separator(bool first)); 101 INLINE(void Separator(bool first));
101 102
102 Handle<JSReceiver> CurrentHolder(Handle<Object> value);
103
104 Result StackPush(Handle<Object> object); 103 Result StackPush(Handle<Object> object);
105 void StackPop(); 104 void StackPop();
106 105
107 Factory* factory() { return isolate_->factory(); } 106 Factory* factory() { return isolate_->factory(); }
108 107
109 Isolate* isolate_; 108 Isolate* isolate_;
110 IncrementalStringBuilder builder_; 109 IncrementalStringBuilder builder_;
111 Handle<String> tojson_string_; 110 Handle<String> tojson_string_;
112 Handle<JSArray> stack_; 111 Handle<JSArray> stack_;
113 Handle<FixedArray> property_list_; 112 Handle<FixedArray> property_list_;
114 Handle<JSReceiver> replacer_function_;
115 uc16* gap_; 113 uc16* gap_;
116 int indent_; 114 int indent_;
117 115
118 static const int kJsonEscapeTableEntrySize = 8; 116 static const int kJsonEscapeTableEntrySize = 8;
119 static const char* const JsonEscapeTable; 117 static const char* const JsonEscapeTable;
120 }; 118 };
121 119
122 } // namespace internal 120 } // namespace internal
123 } // namespace v8 121 } // namespace v8
124 122
125 #endif // V8_JSON_STRINGIFIER_H_ 123 #endif // V8_JSON_STRINGIFIER_H_
OLDNEW
« no previous file with comments | « src/js/json.js ('k') | src/json-stringifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698