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

Side by Side Diff: src/api.cc

Issue 1847823004: Expose JSON stringifier through V8 API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 | « include/v8.h ('k') | no next file » | 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 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 22 matching lines...) Expand all
33 #include "src/conversions-inl.h" 33 #include "src/conversions-inl.h"
34 #include "src/counters.h" 34 #include "src/counters.h"
35 #include "src/debug/debug.h" 35 #include "src/debug/debug.h"
36 #include "src/deoptimizer.h" 36 #include "src/deoptimizer.h"
37 #include "src/execution.h" 37 #include "src/execution.h"
38 #include "src/gdb-jit.h" 38 #include "src/gdb-jit.h"
39 #include "src/global-handles.h" 39 #include "src/global-handles.h"
40 #include "src/icu_util.h" 40 #include "src/icu_util.h"
41 #include "src/isolate-inl.h" 41 #include "src/isolate-inl.h"
42 #include "src/json-parser.h" 42 #include "src/json-parser.h"
43 #include "src/json-stringifier.h"
43 #include "src/messages.h" 44 #include "src/messages.h"
44 #include "src/parsing/parser.h" 45 #include "src/parsing/parser.h"
45 #include "src/parsing/scanner-character-streams.h" 46 #include "src/parsing/scanner-character-streams.h"
46 #include "src/pending-compilation-error-handler.h" 47 #include "src/pending-compilation-error-handler.h"
47 #include "src/profiler/cpu-profiler.h" 48 #include "src/profiler/cpu-profiler.h"
48 #include "src/profiler/heap-profiler.h" 49 #include "src/profiler/heap-profiler.h"
49 #include "src/profiler/heap-snapshot-generator-inl.h" 50 #include "src/profiler/heap-snapshot-generator-inl.h"
50 #include "src/profiler/profile-generator-inl.h" 51 #include "src/profiler/profile-generator-inl.h"
51 #include "src/profiler/sampler.h" 52 #include "src/profiler/sampler.h"
52 #include "src/property.h"
53 #include "src/property-descriptor.h" 53 #include "src/property-descriptor.h"
54 #include "src/property-details.h" 54 #include "src/property-details.h"
55 #include "src/property.h"
please use gerrit instead 2016/03/31 23:17:12 Result of `git cl format`.
55 #include "src/prototype.h" 56 #include "src/prototype.h"
57 #include "src/runtime-profiler.h"
please use gerrit instead 2016/03/31 23:17:12 Result of `git cl format`.
56 #include "src/runtime/runtime.h" 58 #include "src/runtime/runtime.h"
57 #include "src/runtime-profiler.h"
58 #include "src/simulator.h" 59 #include "src/simulator.h"
59 #include "src/snapshot/natives.h" 60 #include "src/snapshot/natives.h"
60 #include "src/snapshot/snapshot.h" 61 #include "src/snapshot/snapshot.h"
61 #include "src/startup-data-util.h" 62 #include "src/startup-data-util.h"
62 #include "src/tracing/trace-event.h" 63 #include "src/tracing/trace-event.h"
63 #include "src/unicode-inl.h" 64 #include "src/unicode-inl.h"
64 #include "src/v8.h" 65 #include "src/v8.h"
65 #include "src/v8threads.h" 66 #include "src/v8threads.h"
66 #include "src/version.h" 67 #include "src/version.h"
67 #include "src/vm-state-inl.h" 68 #include "src/vm-state-inl.h"
68 69
69
please use gerrit instead 2016/03/31 23:17:12 Result of `git cl format`.
70 namespace v8 { 70 namespace v8 {
71 71
72 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) 72 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
73 73
74 74
75 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate)) 75 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate))
76 76
77 77
78 #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \ 78 #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \
79 bailout_value, HandleScopeClass, \ 79 bailout_value, HandleScopeClass, \
(...skipping 2665 matching lines...) Expand 10 before | Expand all | Expand 10 after
2745 RETURN_ESCAPED(result); 2745 RETURN_ESCAPED(result);
2746 } 2746 }
2747 2747
2748 2748
2749 Local<Value> JSON::Parse(Local<String> json_string) { 2749 Local<Value> JSON::Parse(Local<String> json_string) {
2750 auto isolate = reinterpret_cast<v8::Isolate*>( 2750 auto isolate = reinterpret_cast<v8::Isolate*>(
2751 Utils::OpenHandle(*json_string)->GetIsolate()); 2751 Utils::OpenHandle(*json_string)->GetIsolate());
2752 RETURN_TO_LOCAL_UNCHECKED(Parse(isolate, json_string), Value); 2752 RETURN_TO_LOCAL_UNCHECKED(Parse(isolate, json_string), Value);
2753 } 2753 }
2754 2754
2755 MaybeLocal<String> JSON::Stringify(Isolate* v8_isolate,
2756 Local<Object> json_object) {
2757 auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
2758 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, "JSON::Stringify", String);
2759 i::Handle<i::Object> object = Utils::OpenHandle(*json_object);
2760 i::BasicJsonStringifier stringifier(isolate);
2761 auto maybe = stringifier.Stringify(object);
2762 Local<String> result;
2763 has_pending_exception = !ToLocal<String>(maybe, &result);
2764 RETURN_ON_FAILED_EXECUTION(String);
2765 RETURN_ESCAPED(result);
2766 }
2755 2767
2756 // --- D a t a --- 2768 // --- D a t a ---
2757 2769
2758 bool Value::FullIsUndefined() const { 2770 bool Value::FullIsUndefined() const {
2759 bool result = Utils::OpenHandle(this)->IsUndefined(); 2771 bool result = Utils::OpenHandle(this)->IsUndefined();
2760 DCHECK_EQ(result, QuickIsUndefined()); 2772 DCHECK_EQ(result, QuickIsUndefined());
2761 return result; 2773 return result;
2762 } 2774 }
2763 2775
2764 2776
(...skipping 6013 matching lines...) Expand 10 before | Expand all | Expand 10 after
8778 Address callback_address = 8790 Address callback_address =
8779 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8791 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8780 VMState<EXTERNAL> state(isolate); 8792 VMState<EXTERNAL> state(isolate);
8781 ExternalCallbackScope call_scope(isolate, callback_address); 8793 ExternalCallbackScope call_scope(isolate, callback_address);
8782 callback(info); 8794 callback(info);
8783 } 8795 }
8784 8796
8785 8797
8786 } // namespace internal 8798 } // namespace internal
8787 } // namespace v8 8799 } // namespace v8
OLDNEW
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698