@@ -17,9 +17,10 @@ using namespace tns;
1717/*
1818 * Converts a single JavaScript (V8) object to its respective Java representation
1919 */
20- JsArgToArrayConverter::JsArgToArrayConverter (Local<Context> context, const v8::Local<Value> &arg,
20+ JsArgToArrayConverter::JsArgToArrayConverter (Isolate *isolate, Local<Context> context,
21+ const v8::Local<Value> &arg,
2122 bool isImplementationObject, int classReturnType)
22- : m_arr(nullptr ), m_argsAsObject(nullptr ), m_argsLen(0 ), m_isValid(false ), m_error(Error()),
23+ : m_isolate(isolate), m_arr(nullptr ), m_argsAsObject(nullptr ), m_argsLen(0 ), m_isValid(false ), m_error(Error()),
2324 m_return_type(classReturnType) {
2425 if (!isImplementationObject) {
2526 m_argsLen = 1 ;
@@ -35,7 +36,7 @@ JsArgToArrayConverter::JsArgToArrayConverter(Local<Context> context, const v8::L
3536 */
3637JsArgToArrayConverter::JsArgToArrayConverter (const v8::FunctionCallbackInfo<Value> &args,
3738 bool hasImplementationObject)
38- : m_arr(nullptr ), m_argsAsObject(nullptr ), m_argsLen(0 ), m_isValid(false ), m_error(Error()),
39+ : m_isolate(args.GetIsolate()), m_arr(nullptr ), m_argsAsObject(nullptr ), m_argsLen(0 ), m_isValid(false ), m_error(Error()),
3940 m_return_type(static_cast <int >(Type::Null)) {
4041 m_argsLen = !hasImplementationObject ? args.Length () : args.Length () - 2 ;
4142
@@ -45,7 +46,7 @@ JsArgToArrayConverter::JsArgToArrayConverter(const v8::FunctionCallbackInfo<Valu
4546 m_argsAsObject = new jobject[m_argsLen];
4647 memset (m_argsAsObject, 0 , m_argsLen * sizeof (jobject));
4748
48- auto context = args. GetIsolate () ->GetCurrentContext ();
49+ auto context = m_isolate ->GetCurrentContext ();
4950 for (int i = 0 ; i < m_argsLen; i++) {
5051 success = ConvertArg (context, args[i], i);
5152
@@ -65,7 +66,7 @@ bool JsArgToArrayConverter::ConvertArg(Local<Context> context, const Local<Value
6566 JEnv env;
6667
6768 Type returnType = JType::getClassType (m_return_type);
68- auto isolate = v8::Isolate::GetCurrent () ;
69+ auto isolate = m_isolate ;
6970
7071 // A Proxy's target is what holds the Java link.
7172 auto arg = jsArg.IsEmpty () ? jsArg : ObjectManager::UnwrapProxy (jsArg);
@@ -136,7 +137,7 @@ bool JsArgToArrayConverter::ConvertArg(Local<Context> context, const Local<Value
136137
137138 success = true ;
138139 } else if (arg->IsString () || arg->IsStringObject ()) {
139- auto stringObject = ArgConverter::ConvertToJavaString (arg);
140+ auto stringObject = ArgConverter::ConvertToJavaString (isolate, arg);
140141 SetConvertedObject (env, index, stringObject);
141142
142143 success = true ;
@@ -160,7 +161,7 @@ bool JsArgToArrayConverter::ConvertArg(Local<Context> context, const Local<Value
160161
161162 switch (castType) {
162163 case CastType::Char:
163- castValue = NumericCasts::GetCastValue (jsObj);
164+ castValue = NumericCasts::GetCastValue (isolate, jsObj);
164165 charValue = ' \0 ' ;
165166 if (castValue->IsString ()) {
166167 charValue = ArgConverter::ToJavaChar (isolate, castValue.As <String>());
@@ -171,7 +172,7 @@ bool JsArgToArrayConverter::ConvertArg(Local<Context> context, const Local<Value
171172 break ;
172173
173174 case CastType::Byte:
174- castValue = NumericCasts::GetCastValue (jsObj);
175+ castValue = NumericCasts::GetCastValue (isolate, jsObj);
175176 byteValue = 0 ;
176177 if (castValue->IsString ()) {
177178 string value = ArgConverter::ConvertToString (
@@ -189,7 +190,7 @@ bool JsArgToArrayConverter::ConvertArg(Local<Context> context, const Local<Value
189190 break ;
190191
191192 case CastType::Short:
192- castValue = NumericCasts::GetCastValue (jsObj);
193+ castValue = NumericCasts::GetCastValue (isolate, jsObj);
193194 shortValue = 0 ;
194195 if (castValue->IsString ()) {
195196 string value = ArgConverter::ConvertToString (
@@ -207,7 +208,7 @@ bool JsArgToArrayConverter::ConvertArg(Local<Context> context, const Local<Value
207208 break ;
208209
209210 case CastType::Long:
210- castValue = NumericCasts::GetCastValue (jsObj);
211+ castValue = NumericCasts::GetCastValue (isolate, jsObj);
211212 longValue = 0 ;
212213 if (castValue->IsString ()) {
213214 auto strValue = ArgConverter::ConvertToString (
@@ -223,7 +224,7 @@ bool JsArgToArrayConverter::ConvertArg(Local<Context> context, const Local<Value
223224 break ;
224225
225226 case CastType::Float:
226- castValue = NumericCasts::GetCastValue (jsObj);
227+ castValue = NumericCasts::GetCastValue (isolate, jsObj);
227228 floatValue = 0 ;
228229 if (castValue->IsNumber ()) {
229230 double floatArg = castValue->ToNumber (context).ToLocalChecked ()->NumberValue (
@@ -236,7 +237,7 @@ bool JsArgToArrayConverter::ConvertArg(Local<Context> context, const Local<Value
236237 break ;
237238
238239 case CastType::Double:
239- castValue = NumericCasts::GetCastValue (jsObj);
240+ castValue = NumericCasts::GetCastValue (isolate, jsObj);
240241 doubleValue = 0 ;
241242 if (castValue->IsNumber ()) {
242243 double doubleArg = castValue->ToNumber (context).ToLocalChecked ()->NumberValue (
0 commit comments