(type: any, func: any, prop: any, value: any = null)
| 302 | } |
| 303 | |
| 304 | marshall(type: any, func: any, prop: any, value: any = null) { |
| 305 | if (DEBUGGING) { |
| 306 | nativeLog('MARSHALL:', type, prop ? prop : '', value ? value : ''); |
| 307 | } |
| 308 | |
| 309 | // eslint-disable-next-line no-async-promise-executor |
| 310 | return new Promise(async (resolve, reject) => { |
| 311 | const TID = 'R' + ++this._trackingId; |
| 312 | this._tracking[TID] = { resolve, reject, func }; |
| 313 | let newFunc = func; |
| 314 | let results = prop; |
| 315 | //nativeLog(newFunc[NS_PROXY_PARENT] != null ? "Good" : "Null", newFunc[NS_PROXY_PARENT][NS_PROXY_IS_FUNCTION] ? "Function" : "Good") |
| 316 | while ( |
| 317 | newFunc[NS_PROXY_PARENT] != null && |
| 318 | !newFunc[NS_PROXY_PARENT][NS_PROXY_IS_FUNCTION] |
| 319 | ) { |
| 320 | newFunc = newFunc[NS_PROXY_PARENT]; |
| 321 | results = newFunc[NS_PROXY_PROP] + '.' + results; |
| 322 | } |
| 323 | newFunc = newFunc[NS_PROXY_PARENT]; |
| 324 | const parent = newFunc[NS_PROXY_ID]; |
| 325 | const idx = results.lastIndexOf('.'); |
| 326 | let thisArg; |
| 327 | if (idx) { |
| 328 | thisArg = results.substr(0, idx); |
| 329 | } else { |
| 330 | thisArg = 'global'; |
| 331 | } |
| 332 | |
| 333 | if (DEBUGGING) { |
| 334 | nativeLog('R:', results, parent, thisArg); |
| 335 | } |
| 336 | |
| 337 | /* |
| 338 | const NS_MARSHALL_FUNCTION = 2; |
| 339 | const NS_MARSHALL_CONSTRUCTOR = 3; |
| 340 | const NS_MARSHALL_GET = 4; |
| 341 | const NS_MARSHALL_SET = 5; |
| 342 | */ |
| 343 | |
| 344 | if (value != null) { |
| 345 | value = await this.fixArgs(value); |
| 346 | } |
| 347 | |
| 348 | this.sendMessage({ |
| 349 | cmd: type, |
| 350 | tracking: TID, |
| 351 | value: results, |
| 352 | thisArg: thisArg, |
| 353 | parentObject: parent, |
| 354 | nextObjID: func[NS_PROXY_ID], |
| 355 | extra: value, |
| 356 | }); |
| 357 | }); |
| 358 | } |
| 359 | |
| 360 | getNextId() { |
| 361 | return this._id++; |
no test coverage detected