DeepSpeech/native_client/swig_node_v12_0003-Move-to-new-MaybeLocal-based-GetFunction.patch
Alexandre Lissy f7f6a1480f Add NodeJS v12 support
Fixes #2070
2019-04-25 15:43:16 +02:00

46 lines
1.8 KiB
Diff

From 4e6df9ce197f2bb9ff34a6b584038a7dc7241126 Mon Sep 17 00:00:00 2001
From: Alexandre Lissy <lissyx@lissyx.dyndns.org>
Date: Thu, 25 Apr 2019 12:47:46 +0200
Subject: [PATCH 3/3] Move to new MaybeLocal based GetFunction()
---
Lib/javascript/v8/javascriptcode.swg | 4 ++++
Lib/javascript/v8/javascripthelpers.swg | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg
index 86963c1ed..a707750b1 100644
--- a/Lib/javascript/v8/javascriptcode.swg
+++ b/Lib/javascript/v8/javascriptcode.swg
@@ -424,7 +424,11 @@ fail:
$jsmangledname_class_0->SetCallHandler($jsctor);
$jsmangledname_class_0->Inherit($jsmangledname_class);
$jsmangledname_class_0->SetHiddenPrototype(true);
+#if (NODE_MODULE_VERSION < 72)
v8::Local<v8::Object> $jsmangledname_obj = $jsmangledname_class_0->GetFunction();
+#else
+ v8::Local<v8::Object> $jsmangledname_obj = $jsmangledname_class_0->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked();
+#endif
%}
/* -----------------------------------------------------------------------------
diff --git a/Lib/javascript/v8/javascripthelpers.swg b/Lib/javascript/v8/javascripthelpers.swg
index c610f5196..b0ecfafff 100644
--- a/Lib/javascript/v8/javascripthelpers.swg
+++ b/Lib/javascript/v8/javascripthelpers.swg
@@ -62,7 +62,11 @@ SWIGRUNTIME void SWIGV8_AddMemberVariable(v8::Local<v8::FunctionTemplate> class_
*/
SWIGRUNTIME void SWIGV8_AddStaticFunction(v8::Local<v8::Object> obj, const char* symbol,
const SwigV8FunctionCallback& _func) {
+#if (NODE_MODULE_VERSION < 72)
obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction());
+#else
+ obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked());
+#endif
}
/**
--
2.20.1