| 12 | } |
| 13 | |
| 14 | void ArrayHelper::Init(const Local<Context>& context) { |
| 15 | JEnv env; |
| 16 | |
| 17 | RUNTIME_CLASS = env.FindClass("com/tns/Runtime"); |
| 18 | assert(RUNTIME_CLASS != nullptr); |
| 19 | |
| 20 | CREATE_ARRAY_HELPER = env.GetStaticMethodID(RUNTIME_CLASS, "createArrayHelper", "(Ljava/lang/String;I)Ljava/lang/Object;"); |
| 21 | assert(CREATE_ARRAY_HELPER != nullptr); |
| 22 | |
| 23 | auto isolate = context->GetIsolate(); |
| 24 | auto global = context->Global(); |
| 25 | auto arr = global->Get(context, ArgConverter::ConvertToV8String(isolate, "Array")); |
| 26 | |
| 27 | if (!arr.IsEmpty()) { |
| 28 | Local<Value> arrVal; |
| 29 | auto success = arr.ToLocal(&arrVal); |
| 30 | if (success) { |
| 31 | auto arrayObj = arrVal.As<Object>(); |
| 32 | arrayObj->Set(context, ArgConverter::ConvertToV8String(isolate, "create"), FunctionTemplate::New(isolate, CreateJavaArrayCallback)->GetFunction(context).ToLocalChecked()); |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | void ArrayHelper::CreateJavaArrayCallback(const FunctionCallbackInfo<Value>& info) { |
| 38 | try { |
nothing calls this directly
no test coverage detected