Skip to content

Commit 1178678

Browse files
committed
chore: cleanup
1 parent f886658 commit 1178678

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

NativeScript/runtime/ArgConverter.mm

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "Interop.h"
88
#include "Helpers.h"
99
#include "Runtime.h"
10+
#include "RuntimeConfig.h"
1011

1112
using namespace v8;
1213
using namespace std;
@@ -32,16 +33,16 @@
3233
// During fast view churn like HMR in development, JS objects can outlive their
3334
// native wrappers briefly. In Debug, avoid a crash and just skip the native call.
3435
// In Release, assert so crash reporting can capture unexpected cases.
35-
#ifdef DEBUG
36+
if (RuntimeConfig.IsDebug) {
3637
const char* selectorStr = meta ? meta->selectorAsString() : "<unknown>";
3738
const char* jsNameStr = meta ? meta->jsName() : "<unknown>";
3839
const char* classNameStr = klass ? class_getName(klass) : "<unknown>";
39-
Log(@"ArgConverter::Invoke: skipping instance method on non-native receiver (class: %s, selector: %s, jsName: %s, args: %d). Normal during HMR.",
40+
Log(@"ArgConverter::Invoke: ignore method on non-native receiver (class: %s, selector: %s, jsName: %s, args: %d). Common during HMR.",
4041
classNameStr, selectorStr, jsNameStr, (int)args.Length());
4142
return v8::Undefined(isolate);
42-
#else
43+
} else {
4344
tns::Assert(false, isolate);
44-
#endif
45+
}
4546
}
4647

4748
if (wrapper->Type() == WrapperType::ObjCAllocObject) {
@@ -58,7 +59,16 @@
5859
// For extended classes we will call the base method
5960
callSuper = isMethodCallback && it != cache->ClassPrototypes.end();
6061
} else {
61-
tns::Assert(false, isolate);
62+
if (RuntimeConfig.IsDebug) {
63+
const char* selectorStr = meta ? meta->selectorAsString() : "<unknown>";
64+
const char* jsNameStr = meta ? meta->jsName() : "<unknown>";
65+
const char* classNameStr = klass ? class_getName(klass) : "<unknown>";
66+
Log(@"ArgConverter::Invoke: unexpected receiver wrapper type %d (class: %s, selector: %s, jsName: %s). Skipping in DEBUG.",
67+
(int)wrapper->Type(), classNameStr, selectorStr, jsNameStr);
68+
return v8::Undefined(isolate);
69+
} else {
70+
tns::Assert(false, isolate);
71+
}
6272
}
6373
}
6474

0 commit comments

Comments
 (0)