Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index 17502bce90e8a7c512affbf8318bcb19f1e11136..b78325c317b285ace5f1b7164f2deedc63c1bc85 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -49,12 +49,12 @@ |
| #include "src/profiler/heap-snapshot-generator-inl.h" |
| #include "src/profiler/profile-generator-inl.h" |
| #include "src/profiler/sampler.h" |
| -#include "src/property.h" |
| #include "src/property-descriptor.h" |
| #include "src/property-details.h" |
| +#include "src/property.h" |
| #include "src/prototype.h" |
| -#include "src/runtime/runtime.h" |
| #include "src/runtime-profiler.h" |
| +#include "src/runtime/runtime.h" |
| #include "src/simulator.h" |
| #include "src/snapshot/natives.h" |
| #include "src/snapshot/snapshot.h" |
| @@ -66,7 +66,6 @@ |
| #include "src/version.h" |
| #include "src/vm-state-inl.h" |
| - |
| namespace v8 { |
| #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) |
| @@ -2749,6 +2748,19 @@ MaybeLocal<Value> JSON::Parse(Isolate* v8_isolate, Local<String> json_string) { |
| RETURN_ESCAPED(result); |
| } |
| +MaybeLocal<Value> JSON::Parse(Local<Context> context, |
| + Local<String> json_string) { |
| + PREPARE_FOR_EXECUTION(context, "JSON::Parse", Value); |
| + i::Handle<i::String> string = Utils::OpenHandle(*json_string); |
| + i::Handle<i::String> source = i::String::Flatten(string); |
| + auto maybe = source->IsSeqOneByteString() |
| + ? i::JsonParser<true>::Parse(source) |
|
haavardm
2016/04/15 10:44:49
Does |context| end up in source? or is a new empty
jochen (gone - plz use gerrit)
2016/04/15 10:50:11
the PREPARE_FOR_EXECUTION macro will create a pote
|
| + : i::JsonParser<false>::Parse(source); |
| + Local<Value> result; |
| + has_pending_exception = !ToLocal<Value>(maybe, &result); |
| + RETURN_ON_FAILED_EXECUTION(Value); |
| + RETURN_ESCAPED(result); |
| +} |
| Local<Value> JSON::Parse(Local<String> json_string) { |
| auto isolate = reinterpret_cast<v8::Isolate*>( |
| @@ -2756,6 +2768,21 @@ Local<Value> JSON::Parse(Local<String> json_string) { |
| RETURN_TO_LOCAL_UNCHECKED(Parse(isolate, json_string), Value); |
| } |
| +MaybeLocal<String> JSON::Stringify(Isolate* v8_isolate, |
| + Local<Object> json_object) { |
| + auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| + PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, "JSON::Stringify", String); |
| + i::Handle<i::Object> object = Utils::OpenHandle(*json_object); |
| + i::Handle<i::Object> maybe; |
| + has_pending_exception = |
| + !i::Runtime::BasicJsonStringify(isolate, object).ToHandle(&maybe); |
| + RETURN_ON_FAILED_EXECUTION(String); |
| + Local<String> result; |
| + has_pending_exception = |
| + !ToLocal<String>(i::Object::ToString(isolate, maybe), &result); |
| + RETURN_ON_FAILED_EXECUTION(String); |
| + RETURN_ESCAPED(result); |
| +} |
| // --- D a t a --- |