| 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 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 private: | 24 private: |
| 25 enum Result { UNCHANGED, SUCCESS, EXCEPTION }; | 25 enum Result { UNCHANGED, SUCCESS, EXCEPTION }; |
| 26 | 26 |
| 27 bool InitializeReplacer(Handle<Object> replacer); | 27 bool InitializeReplacer(Handle<Object> replacer); |
| 28 bool InitializeGap(Handle<Object> gap); | 28 bool InitializeGap(Handle<Object> gap); |
| 29 | 29 |
| 30 MUST_USE_RESULT MaybeHandle<Object> ApplyToJsonFunction( | 30 MUST_USE_RESULT MaybeHandle<Object> ApplyToJsonFunction( |
| 31 Handle<Object> object, | 31 Handle<Object> object, |
| 32 Handle<Object> key); | 32 Handle<Object> key); |
| 33 MUST_USE_RESULT MaybeHandle<Object> ApplyReplacerFunction( | 33 MUST_USE_RESULT MaybeHandle<Object> ApplyReplacerFunction( |
| 34 Handle<Object> object, Handle<Object> key); | 34 Handle<Object> value, Handle<Object> key, Handle<Object> initial_holder); |
| 35 | 35 |
| 36 // Entry point to serialize the object. | 36 // Entry point to serialize the object. |
| 37 INLINE(Result SerializeObject(Handle<Object> obj)) { | 37 INLINE(Result SerializeObject(Handle<Object> obj)) { |
| 38 return Serialize_<false>(obj, false, factory()->empty_string()); | 38 return Serialize_<false>(obj, false, factory()->empty_string()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 // Serialize an array element. | 41 // Serialize an array element. |
| 42 // The index may serve as argument for the toJSON function. | 42 // The index may serve as argument for the toJSON function. |
| 43 INLINE(Result SerializeElement(Isolate* isolate, | 43 INLINE(Result SerializeElement(Isolate* isolate, |
| 44 Handle<Object> object, | 44 Handle<Object> object, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 INLINE(void SerializeString_(Handle<String> string)); | 92 INLINE(void SerializeString_(Handle<String> string)); |
| 93 | 93 |
| 94 template <typename Char> | 94 template <typename Char> |
| 95 INLINE(static bool DoNotEscape(Char c)); | 95 INLINE(static bool DoNotEscape(Char c)); |
| 96 | 96 |
| 97 INLINE(void NewLine()); | 97 INLINE(void NewLine()); |
| 98 INLINE(void Indent() { indent_++; }); | 98 INLINE(void Indent() { indent_++; }); |
| 99 INLINE(void Unindent() { indent_--; }); | 99 INLINE(void Unindent() { indent_--; }); |
| 100 INLINE(void Separator(bool first)); | 100 INLINE(void Separator(bool first)); |
| 101 | 101 |
| 102 Handle<JSReceiver> CurrentHolder(Handle<Object> value); | 102 Handle<JSReceiver> CurrentHolder(Handle<Object> value, |
| 103 Handle<Object> inital_holder); |
| 103 | 104 |
| 104 Result StackPush(Handle<Object> object); | 105 Result StackPush(Handle<Object> object); |
| 105 void StackPop(); | 106 void StackPop(); |
| 106 | 107 |
| 107 Factory* factory() { return isolate_->factory(); } | 108 Factory* factory() { return isolate_->factory(); } |
| 108 | 109 |
| 109 Isolate* isolate_; | 110 Isolate* isolate_; |
| 110 IncrementalStringBuilder builder_; | 111 IncrementalStringBuilder builder_; |
| 111 Handle<String> tojson_string_; | 112 Handle<String> tojson_string_; |
| 112 Handle<JSArray> stack_; | 113 Handle<JSArray> stack_; |
| 113 Handle<FixedArray> property_list_; | 114 Handle<FixedArray> property_list_; |
| 114 Handle<JSReceiver> replacer_function_; | 115 Handle<JSReceiver> replacer_function_; |
| 115 uc16* gap_; | 116 uc16* gap_; |
| 116 int indent_; | 117 int indent_; |
| 117 | 118 |
| 118 static const int kJsonEscapeTableEntrySize = 8; | 119 static const int kJsonEscapeTableEntrySize = 8; |
| 119 static const char* const JsonEscapeTable; | 120 static const char* const JsonEscapeTable; |
| 120 }; | 121 }; |
| 121 | 122 |
| 122 } // namespace internal | 123 } // namespace internal |
| 123 } // namespace v8 | 124 } // namespace v8 |
| 124 | 125 |
| 125 #endif // V8_JSON_STRINGIFIER_H_ | 126 #endif // V8_JSON_STRINGIFIER_H_ |
| OLD | NEW |