fix: Fix namespace
This commit is contained in:
parent
78a64abb8c
commit
deeb8db59f
@ -27,6 +27,8 @@
|
|||||||
using namespace facebook;
|
using namespace facebook;
|
||||||
using namespace facebook::react;
|
using namespace facebook::react;
|
||||||
|
|
||||||
|
namespace JSINSObjectConversion {
|
||||||
|
|
||||||
jsi::Value convertNSNumberToJSIBoolean(jsi::Runtime &runtime, NSNumber *value)
|
jsi::Value convertNSNumberToJSIBoolean(jsi::Runtime &runtime, NSNumber *value)
|
||||||
{
|
{
|
||||||
return jsi::Value((bool)[value boolValue]);
|
return jsi::Value((bool)[value boolValue]);
|
||||||
@ -167,7 +169,7 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, s
|
|||||||
}
|
}
|
||||||
return convertJSIObjectToNSDictionary(runtime, o, jsInvoker);
|
return convertJSIObjectToNSDictionary(runtime, o, jsInvoker);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw std::runtime_error("Unsupported jsi::jsi::Value kind");
|
throw std::runtime_error("Unsupported jsi::jsi::Value kind");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,35 +182,37 @@ RCTResponseSenderBlock convertJSIFunctionToCallback(jsi::Runtime &runtime, const
|
|||||||
strongWrapper->destroy();
|
strongWrapper->destroy();
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
BOOL __block wrapperWasCalled = NO;
|
BOOL __block wrapperWasCalled = NO;
|
||||||
RCTResponseSenderBlock callback = ^(NSArray *responses) {
|
RCTResponseSenderBlock callback = ^(NSArray *responses) {
|
||||||
if (wrapperWasCalled) {
|
if (wrapperWasCalled) {
|
||||||
throw std::runtime_error("callback arg cannot be called more than once");
|
throw std::runtime_error("callback arg cannot be called more than once");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto strongWrapper = weakWrapper.lock();
|
auto strongWrapper = weakWrapper.lock();
|
||||||
if (!strongWrapper) {
|
if (!strongWrapper) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
strongWrapper->jsInvoker().invokeAsync([weakWrapper, responses, blockGuard]() {
|
strongWrapper->jsInvoker().invokeAsync([weakWrapper, responses, blockGuard]() {
|
||||||
auto strongWrapper2 = weakWrapper.lock();
|
auto strongWrapper2 = weakWrapper.lock();
|
||||||
if (!strongWrapper2) {
|
if (!strongWrapper2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const jsi::Value* args = convertNSArrayToJSICStyleArray(strongWrapper2->runtime(), responses);
|
const jsi::Value* args = convertNSArrayToJSICStyleArray(strongWrapper2->runtime(), responses);
|
||||||
strongWrapper2->callback().call(strongWrapper2->runtime(), args, static_cast<size_t>(responses.count));
|
strongWrapper2->callback().call(strongWrapper2->runtime(), args, static_cast<size_t>(responses.count));
|
||||||
strongWrapper2->destroy();
|
strongWrapper2->destroy();
|
||||||
delete[] args;
|
delete[] args;
|
||||||
|
|
||||||
// Delete the CallbackWrapper when the block gets dealloced without being invoked.
|
// Delete the CallbackWrapper when the block gets dealloced without being invoked.
|
||||||
(void)blockGuard;
|
(void)blockGuard;
|
||||||
});
|
});
|
||||||
|
|
||||||
wrapperWasCalled = YES;
|
wrapperWasCalled = YES;
|
||||||
};
|
};
|
||||||
|
|
||||||
return [callback copy];
|
return [callback copy];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace JSIJNIObjectConversion
|
||||||
|
Loading…
Reference in New Issue
Block a user