Index: include/v8.h |
diff --git a/include/v8.h b/include/v8.h |
index 36f3d4b47db8deacc573164762439bb3a4899235..3069c598f629bfbaf7930e22efdfdec29f9c2bcd 100644 |
--- a/include/v8.h |
+++ b/include/v8.h |
@@ -439,7 +439,7 @@ class MaybeLocal { |
template <class S> |
V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const { |
out->val_ = IsEmpty() ? nullptr : this->val_; |
- return IsEmpty(); |
+ return !IsEmpty(); |
} |
V8_INLINE Local<T> ToLocalChecked() { |
@@ -1066,10 +1066,14 @@ class V8_EXPORT Script { |
/** |
* A shorthand for ScriptCompiler::Compile(). |
*/ |
+ // TODO(dcarney): deprecate. |
static Local<Script> Compile(Handle<String> source, |
- ScriptOrigin* origin = NULL); |
+ ScriptOrigin* origin = nullptr); |
+ static MaybeLocal<Script> Compile(Local<Context> context, |
+ Handle<String> source, |
+ ScriptOrigin* origin = nullptr); |
- // To be decprecated, use the Compile above. |
+ // TODO(dcarney): deprecate. |
static Local<Script> Compile(Handle<String> source, |
Handle<String> file_name); |
@@ -1265,9 +1269,13 @@ class V8_EXPORT ScriptCompiler { |
* \return Compiled script object (context independent; for running it must be |
* bound to a context). |
*/ |
+ // TODO(dcarney): deprecate |
static Local<UnboundScript> CompileUnbound( |
Isolate* isolate, Source* source, |
CompileOptions options = kNoCompileOptions); |
+ static MaybeLocal<UnboundScript> CompileUnboundScript( |
+ Isolate* isolate, Source* source, |
+ CompileOptions options = kNoCompileOptions); |
/** |
* Compiles the specified script (bound to current context). |
@@ -1280,9 +1288,12 @@ class V8_EXPORT ScriptCompiler { |
* when this function was called. When run it will always use this |
* context. |
*/ |
+ // TODO(dcarney): deprecate |
static Local<Script> Compile( |
Isolate* isolate, Source* source, |
CompileOptions options = kNoCompileOptions); |
+ static MaybeLocal<Script> Compile(Local<Context> context, Source* source, |
+ CompileOptions options = kNoCompileOptions); |
/** |
* Returns a task which streams script data into V8, or NULL if the script |
@@ -1306,9 +1317,14 @@ class V8_EXPORT ScriptCompiler { |
* (ScriptStreamingTask has been run). V8 doesn't construct the source string |
* during streaming, so the embedder needs to pass the full source here. |
*/ |
+ // TODO(dcarney): deprecate |
static Local<Script> Compile(Isolate* isolate, StreamedSource* source, |
Handle<String> full_source_string, |
const ScriptOrigin& origin); |
+ static MaybeLocal<Script> Compile(Local<Context> context, |
+ StreamedSource* source, |
+ Handle<String> full_source_string, |
+ const ScriptOrigin& origin); |
/** |
* Return a version tag for CachedData for the current V8 version & flags. |
@@ -1338,9 +1354,13 @@ class V8_EXPORT ScriptCompiler { |
* TODO(adamk): Script is likely the wrong return value for this; |
* should return some new Module type. |
*/ |
+ // TODO(dcarney): deprecate. |
static Local<Script> CompileModule( |
Isolate* isolate, Source* source, |
CompileOptions options = kNoCompileOptions); |
+ static MaybeLocal<Script> CompileModule( |
+ Local<Context> context, Source* source, |
+ CompileOptions options = kNoCompileOptions); |
/** |
* Compile a function for a given context. This is equivalent to running |
@@ -1352,16 +1372,19 @@ class V8_EXPORT ScriptCompiler { |
* It is possible to specify multiple context extensions (obj in the above |
* example). |
*/ |
+ // TODO(dcarney): deprecate. |
static Local<Function> CompileFunctionInContext( |
Isolate* isolate, Source* source, Local<Context> context, |
size_t arguments_count, Local<String> arguments[], |
size_t context_extension_count, Local<Object> context_extensions[]); |
+ static MaybeLocal<Function> CompileFunctionInContext( |
+ Local<Context> context, Source* source, size_t arguments_count, |
+ Local<String> arguments[], size_t context_extension_count, |
+ Local<Object> context_extensions[]); |
private: |
- static Local<UnboundScript> CompileUnboundInternal(Isolate* isolate, |
- Source* source, |
- CompileOptions options, |
- bool is_module); |
+ static MaybeLocal<UnboundScript> CompileUnboundInternal( |
+ Isolate* isolate, Source* source, CompileOptions options, bool is_module); |
}; |