| OLD | NEW |
| 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 BasicJsonStringifier BASE_EMBEDDED { | 14 class BasicJsonStringifier BASE_EMBEDDED { |
| 15 public: | 15 public: |
| 16 explicit BasicJsonStringifier(Isolate* isolate); | 16 explicit BasicJsonStringifier(Isolate* isolate); |
| 17 | 17 |
| 18 ~BasicJsonStringifier() { 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> gap); | 22 Handle<Object> gap); |
| 22 | 23 |
| 23 MUST_USE_RESULT static MaybeHandle<Object> StringifyString( | 24 MUST_USE_RESULT static MaybeHandle<Object> StringifyString( |
| 24 Isolate* isolate, Handle<String> object); | 25 Isolate* isolate, Handle<String> object); |
| 25 | 26 |
| 26 private: | 27 private: |
| 27 enum Result { UNCHANGED, SUCCESS, EXCEPTION }; | 28 enum Result { UNCHANGED, SUCCESS, EXCEPTION }; |
| 28 | 29 |
| 30 bool InitializeReplacer(Handle<Object> replacer); |
| 29 bool InitializeGap(Handle<Object> gap); | 31 bool InitializeGap(Handle<Object> gap); |
| 30 | 32 |
| 31 MUST_USE_RESULT MaybeHandle<Object> ApplyToJsonFunction( | 33 MUST_USE_RESULT MaybeHandle<Object> ApplyToJsonFunction( |
| 32 Handle<Object> object, | 34 Handle<Object> object, |
| 33 Handle<Object> key); | 35 Handle<Object> key); |
| 34 | 36 |
| 35 // Entry point to serialize the object. | 37 // Entry point to serialize the object. |
| 36 INLINE(Result SerializeObject(Handle<Object> obj)) { | 38 INLINE(Result SerializeObject(Handle<Object> obj)) { |
| 37 return Serialize_<false>(obj, false, factory()->empty_string()); | 39 return Serialize_<false>(obj, false, factory()->empty_string()); |
| 38 } | 40 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 102 |
| 101 Result StackPush(Handle<Object> object); | 103 Result StackPush(Handle<Object> object); |
| 102 void StackPop(); | 104 void StackPop(); |
| 103 | 105 |
| 104 Factory* factory() { return isolate_->factory(); } | 106 Factory* factory() { return isolate_->factory(); } |
| 105 | 107 |
| 106 Isolate* isolate_; | 108 Isolate* isolate_; |
| 107 IncrementalStringBuilder builder_; | 109 IncrementalStringBuilder builder_; |
| 108 Handle<String> tojson_string_; | 110 Handle<String> tojson_string_; |
| 109 Handle<JSArray> stack_; | 111 Handle<JSArray> stack_; |
| 112 Handle<FixedArray> property_list_; |
| 110 uc16* gap_; | 113 uc16* gap_; |
| 111 int indent_; | 114 int indent_; |
| 112 | 115 |
| 113 static const int kJsonEscapeTableEntrySize = 8; | 116 static const int kJsonEscapeTableEntrySize = 8; |
| 114 static const char* const JsonEscapeTable; | 117 static const char* const JsonEscapeTable; |
| 115 }; | 118 }; |
| 116 | 119 |
| 117 } // namespace internal | 120 } // namespace internal |
| 118 } // namespace v8 | 121 } // namespace v8 |
| 119 | 122 |
| 120 #endif // V8_JSON_STRINGIFIER_H_ | 123 #endif // V8_JSON_STRINGIFIER_H_ |
| OLD | NEW |