mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5a6db38fc |
@@ -32,7 +32,7 @@ std::unique_ptr<IWebSocket> RCTCxxInspectorPackagerConnectionDelegate::connectWe
|
||||
std::weak_ptr<IWebSocketDelegate> delegate)
|
||||
{
|
||||
auto *adapter = [[RCTCxxInspectorWebSocketAdapter alloc] initWithURL:url delegate:delegate];
|
||||
if (!adapter) {
|
||||
if (adapter == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_unique<WebSocket>(adapter);
|
||||
|
||||
@@ -34,7 +34,7 @@ NSString *NSStringFromUTF8StringView(std::string_view view)
|
||||
@implementation RCTCxxInspectorWebSocketAdapter
|
||||
- (instancetype)initWithURL:(const std::string &)url delegate:(std::weak_ptr<IWebSocketDelegate>)delegate
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
if ((self = [super init]) != nullptr) {
|
||||
_delegate = delegate;
|
||||
_webSocket = [[SRWebSocket alloc] initWithURL:[NSURL URLWithString:NSStringFromUTF8StringView(url)]];
|
||||
_webSocket.delegate = self;
|
||||
@@ -49,7 +49,7 @@ NSString *NSStringFromUTF8StringView(std::string_view view)
|
||||
NSString *messageStr = NSStringFromUTF8StringView(message);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
RCTCxxInspectorWebSocketAdapter *strongSelf = weakSelf;
|
||||
if (strongSelf) {
|
||||
if (strongSelf != nullptr) {
|
||||
[strongSelf->_webSocket sendString:messageStr error:NULL];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -50,7 +50,7 @@ static SEL selectorForType(NSString *type)
|
||||
bridge:(RCTBridge *)bridge
|
||||
eventDispatcher:(id<RCTEventDispatcherProtocol>)eventDispatcher
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
if ((self = [super init]) != nullptr) {
|
||||
_bridge = bridge;
|
||||
_eventDispatcher = eventDispatcher;
|
||||
_managerClass = managerClass;
|
||||
@@ -71,12 +71,12 @@ static SEL selectorForType(NSString *type)
|
||||
|
||||
- (RCTViewManager *)manager
|
||||
{
|
||||
if (!_manager && [self isBridgeMode]) {
|
||||
if ((_manager == nullptr) && [self isBridgeMode]) {
|
||||
_manager = [_bridge moduleForClass:_managerClass];
|
||||
} else if (!_manager && !_bridgelessViewManager) {
|
||||
} else if ((_manager == nullptr) && (_bridgelessViewManager == nullptr)) {
|
||||
_bridgelessViewManager = [_bridge moduleForClass:_managerClass];
|
||||
}
|
||||
return _manager ? _manager : _bridgelessViewManager;
|
||||
return (_manager != nullptr) ? _manager : _bridgelessViewManager;
|
||||
}
|
||||
|
||||
RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
@@ -106,7 +106,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
{
|
||||
json = RCTNilIfNull(json);
|
||||
if (!isShadowView) {
|
||||
if (!json && !_defaultView) {
|
||||
if ((json == nullptr) && (_defaultView == nullptr)) {
|
||||
// Only create default view if json is null
|
||||
_defaultView = [self createViewWithTag:nil rootTag:nil];
|
||||
}
|
||||
@@ -130,11 +130,11 @@ static RCTPropBlock createEventSetter(
|
||||
eventHandler = ^(NSDictionary *event) {
|
||||
// The component no longer exists, we shouldn't send the event
|
||||
id<RCTComponent> strongTarget = weakTarget;
|
||||
if (!strongTarget) {
|
||||
if (strongTarget == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventInterceptor) {
|
||||
if (eventInterceptor != nullptr) {
|
||||
eventInterceptor(propName, event, strongTarget.reactTag);
|
||||
} else {
|
||||
RCTComponentEvent *componentEvent = [[RCTComponentEvent alloc] initWithName:propName
|
||||
@@ -158,13 +158,13 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
__block NSMutableData *defaultValue = nil;
|
||||
|
||||
return ^(id target, id json) {
|
||||
if (!target) {
|
||||
if (target == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get default value
|
||||
if (!defaultValue) {
|
||||
if (!json) {
|
||||
if (defaultValue == nullptr) {
|
||||
if (json == nullptr) {
|
||||
// We only set the defaultValue when we first pass a non-null
|
||||
// value, so if the first value sent for a prop is null, it's
|
||||
// a no-op (we'd be resetting it to its default when its
|
||||
@@ -186,10 +186,10 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
// Get value
|
||||
BOOL freeValueOnCompletion = NO;
|
||||
void *value = defaultValue.mutableBytes;
|
||||
if (json) {
|
||||
if (json != nullptr) {
|
||||
freeValueOnCompletion = YES;
|
||||
value = malloc(typeSignature.methodReturnLength);
|
||||
if (!value) {
|
||||
if (value == nullptr) {
|
||||
// CWE - 391 : Unchecked error condition
|
||||
// https://www.cvedetails.com/cwe-details/391/Unchecked-Error-Condition.html
|
||||
// https://eli.thegreenplace.net/2009/10/30/handling-out-of-memory-conditions-in-c
|
||||
@@ -201,7 +201,7 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
}
|
||||
|
||||
// Set value
|
||||
if (!targetInvocation) {
|
||||
if (targetInvocation == nullptr) {
|
||||
NSMethodSignature *signature = [target methodSignatureForSelector:setter];
|
||||
targetInvocation = [NSInvocation invocationWithMethodSignature:signature];
|
||||
targetInvocation.selector = setter;
|
||||
@@ -252,7 +252,7 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
// Disect keypath
|
||||
NSString *key = name;
|
||||
NSArray<NSString *> *parts = [keyPath componentsSeparatedByString:@"."];
|
||||
if (parts) {
|
||||
if (parts != nullptr) {
|
||||
key = parts.lastObject;
|
||||
parts = [parts subarrayWithRange:(NSRange){0, parts.count - 1}];
|
||||
}
|
||||
@@ -275,7 +275,7 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
} else {
|
||||
// Ordinary property handlers
|
||||
NSMethodSignature *typeSignature = [[RCTConvert class] methodSignatureForSelector:type];
|
||||
if (!typeSignature) {
|
||||
if (typeSignature == nullptr) {
|
||||
RCTLogError(@"No +[RCTConvert %@] function found.", NSStringFromSelector(type));
|
||||
return ^(__unused id<RCTComponent> view, __unused id json) {
|
||||
};
|
||||
@@ -347,7 +347,7 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
{
|
||||
RCTPropBlockDictionary *propBlocks = isShadowView ? _shadowPropBlocks : _viewPropBlocks;
|
||||
RCTPropBlock propBlock = propBlocks[name];
|
||||
if (!propBlock) {
|
||||
if (propBlock == nullptr) {
|
||||
propBlock = [self createPropBlock:name isShadowView:isShadowView];
|
||||
|
||||
#if RCT_DEBUG
|
||||
@@ -381,7 +381,7 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
|
||||
- (void)setProps:(NSDictionary<NSString *, id> *)props forView:(id<RCTComponent>)view isShadowView:(BOOL)isShadowView
|
||||
{
|
||||
if (!view) {
|
||||
if (view == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -467,13 +467,13 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S
|
||||
|
||||
// We need to handle both propConfig_* and propConfigShadow_* methods
|
||||
const char *underscorePos = strchr(selectorName + strlen("propConfig"), '_');
|
||||
if (!underscorePos) {
|
||||
if (underscorePos == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *name = @(underscorePos + 1);
|
||||
NSString *type = ((NSArray<NSString *> * (*)(id, SEL)) objc_msgSend)(managerClass, selector)[0];
|
||||
if (RCT_DEBUG && propTypes[name] && ![propTypes[name] isEqualToString:type]) {
|
||||
if (RCT_DEBUG && (propTypes[name] != nullptr) && ![propTypes[name] isEqualToString:type]) {
|
||||
RCTLogError(
|
||||
@"Property '%@' of component '%@' redefined from '%@' "
|
||||
"to '%@'",
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ lastResort(const char* tag, const char* msg, const char* arg = nullptr) {
|
||||
}
|
||||
#else
|
||||
std::cerr << msg;
|
||||
if (arg) {
|
||||
if (arg != nullptr) {
|
||||
std::cerr << ": " << arg;
|
||||
}
|
||||
std::cerr << std::endl;
|
||||
|
||||
+3
-2
@@ -60,7 +60,8 @@ static std::unordered_map<int, std::string> responseBuffers;
|
||||
|
||||
/* static */ jboolean JInspectorNetworkReporter::isDebuggingEnabled(
|
||||
jni::alias_ref<jclass> /*unused*/) {
|
||||
return NetworkReporter::getInstance().isDebuggingEnabled();
|
||||
return static_cast<jboolean>(
|
||||
NetworkReporter::getInstance().isDebuggingEnabled());
|
||||
}
|
||||
|
||||
/* static */ void JInspectorNetworkReporter::reportRequestStart(
|
||||
@@ -138,7 +139,7 @@ static std::unordered_map<int, std::string> responseBuffers;
|
||||
jint requestId,
|
||||
jboolean cancelled) {
|
||||
NetworkReporter::getInstance().reportRequestFailed(
|
||||
std::to_string(requestId), cancelled);
|
||||
std::to_string(requestId), cancelled != 0u);
|
||||
}
|
||||
|
||||
/* static */ void JInspectorNetworkReporter::maybeStoreResponseBodyImpl(
|
||||
|
||||
@@ -320,7 +320,7 @@ std::string JSStringToSTLString(JSStringRef str) {
|
||||
buffer = heapBuffer.get();
|
||||
}
|
||||
size_t actualBytes = JSStringGetUTF8CString(str, buffer, maxBytes);
|
||||
if (!actualBytes) {
|
||||
if (actualBytes == 0u) {
|
||||
// Happens if maxBytes == 0 (never the case here) or if str contains
|
||||
// invalid UTF-16 data, since JSStringGetUTF8CString attempts a strict
|
||||
// conversion.
|
||||
@@ -437,7 +437,7 @@ jsi::Value JSCRuntime::evaluateJavaScript(
|
||||
JSValueRef res =
|
||||
JSEvaluateScript(ctx_, sourceRef, nullptr, sourceURLRef, 0, &exc);
|
||||
JSStringRelease(sourceRef);
|
||||
if (sourceURLRef) {
|
||||
if (sourceURLRef != nullptr) {
|
||||
JSStringRelease(sourceURLRef);
|
||||
}
|
||||
checkException(res, exc);
|
||||
@@ -597,7 +597,7 @@ void JSCRuntime::JSCObjectValue::invalidate() noexcept {
|
||||
|
||||
jsi::Runtime::PointerValue* JSCRuntime::cloneSymbol(
|
||||
const jsi::Runtime::PointerValue* pv) {
|
||||
if (!pv) {
|
||||
if (pv == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
const JSCSymbolValue* symbol = static_cast<const JSCSymbolValue*>(pv);
|
||||
@@ -611,7 +611,7 @@ jsi::Runtime::PointerValue* JSCRuntime::cloneBigInt(
|
||||
|
||||
jsi::Runtime::PointerValue* JSCRuntime::cloneString(
|
||||
const jsi::Runtime::PointerValue* pv) {
|
||||
if (!pv) {
|
||||
if (pv == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
const JSCStringValue* string = static_cast<const JSCStringValue*>(pv);
|
||||
@@ -620,7 +620,7 @@ jsi::Runtime::PointerValue* JSCRuntime::cloneString(
|
||||
|
||||
jsi::Runtime::PointerValue* JSCRuntime::cloneObject(
|
||||
const jsi::Runtime::PointerValue* pv) {
|
||||
if (!pv) {
|
||||
if (pv == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
const JSCObjectValue* object = static_cast<const JSCObjectValue*>(pv);
|
||||
@@ -632,7 +632,7 @@ jsi::Runtime::PointerValue* JSCRuntime::cloneObject(
|
||||
|
||||
jsi::Runtime::PointerValue* JSCRuntime::clonePropNameID(
|
||||
const jsi::Runtime::PointerValue* pv) {
|
||||
if (!pv) {
|
||||
if (pv == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
const JSCStringValue* string = static_cast<const JSCStringValue*>(pv);
|
||||
@@ -914,7 +914,7 @@ JSClassRef getNativeStateClass() {
|
||||
} // namespace
|
||||
|
||||
JSValueRef JSCRuntime::getNativeStateSymbol() {
|
||||
if (!nativeStateSymbol_) {
|
||||
if (nativeStateSymbol_ == nullptr) {
|
||||
JSStringRef symbolName =
|
||||
JSStringCreateWithUTF8CString("__internal_nativeState");
|
||||
JSValueRef symbol = JSValueMakeSymbol(ctx_, symbolName);
|
||||
@@ -1182,7 +1182,7 @@ jsi::Function JSCRuntime::createFunctionFromHostFunction(
|
||||
kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum |
|
||||
kJSPropertyAttributeDontDelete,
|
||||
&exc);
|
||||
if (exc) {
|
||||
if (exc != nullptr) {
|
||||
// Silently fail to set length
|
||||
exc = nullptr;
|
||||
}
|
||||
@@ -1198,7 +1198,7 @@ jsi::Function JSCRuntime::createFunctionFromHostFunction(
|
||||
kJSPropertyAttributeDontDelete,
|
||||
&exc);
|
||||
JSStringRelease(name);
|
||||
if (exc) {
|
||||
if (exc != nullptr) {
|
||||
// Silently fail to set name
|
||||
exc = nullptr;
|
||||
}
|
||||
@@ -1211,7 +1211,7 @@ jsi::Function JSCRuntime::createFunctionFromHostFunction(
|
||||
abort();
|
||||
}
|
||||
JSObjectRef funcCtor = JSValueToObject(ctx, value, &exc);
|
||||
if (!funcCtor) {
|
||||
if (funcCtor == nullptr) {
|
||||
// We can't do anything if Function is not an object
|
||||
return;
|
||||
}
|
||||
@@ -1439,7 +1439,7 @@ JSStringRef getEmptyString() {
|
||||
|
||||
jsi::Runtime::PointerValue* JSCRuntime::makeStringValue(
|
||||
JSStringRef stringRef) const {
|
||||
if (!stringRef) {
|
||||
if (stringRef == nullptr) {
|
||||
stringRef = getEmptyString();
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
@@ -1463,7 +1463,7 @@ jsi::PropNameID JSCRuntime::createPropNameID(JSStringRef str) {
|
||||
|
||||
jsi::Runtime::PointerValue* JSCRuntime::makeObjectValue(
|
||||
JSObjectRef objectRef) const {
|
||||
if (!objectRef) {
|
||||
if (objectRef == nullptr) {
|
||||
objectRef = JSObjectMake(ctx_, nullptr, nullptr);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ class InspectorPackagerConnectionTestBase : public testing::Test {
|
||||
auto pages = getInspectorInstance().getPages();
|
||||
int liveConnectionCount = 0;
|
||||
for (size_t i = 0; i != localConnections_.objectsVended(); ++i) {
|
||||
if (localConnections_[i]) {
|
||||
if (localConnections_[i] != nullptr) {
|
||||
liveConnectionCount++;
|
||||
// localConnections_[i] is a strict mock and will complain when we
|
||||
// removePage if the call is unexpected.
|
||||
@@ -69,7 +69,7 @@ class InspectorPackagerConnectionTestBase : public testing::Test {
|
||||
for (auto& page : pages) {
|
||||
getInspectorInstance().removePage(page.id);
|
||||
}
|
||||
if (!pages.empty() && liveConnectionCount) {
|
||||
if (!pages.empty() && (liveConnectionCount != 0)) {
|
||||
if (!::testing::Test::HasFailure()) {
|
||||
FAIL()
|
||||
<< "Test case ended with " << liveConnectionCount
|
||||
|
||||
@@ -65,12 +65,12 @@ class JsiIntegrationPortableTestBase : public ::testing::Test,
|
||||
|
||||
~JsiIntegrationPortableTestBase() override {
|
||||
toPage_.reset();
|
||||
if (runtimeTarget_) {
|
||||
if (runtimeTarget_ != nullptr) {
|
||||
EXPECT_TRUE(instance_);
|
||||
instance_->unregisterRuntime(*runtimeTarget_);
|
||||
runtimeTarget_ = nullptr;
|
||||
}
|
||||
if (instance_) {
|
||||
if (instance_ != nullptr) {
|
||||
page_->unregisterInstance(*instance_);
|
||||
instance_ = nullptr;
|
||||
}
|
||||
@@ -108,12 +108,12 @@ class JsiIntegrationPortableTestBase : public ::testing::Test,
|
||||
}
|
||||
|
||||
void reload() {
|
||||
if (runtimeTarget_) {
|
||||
if (runtimeTarget_ != nullptr) {
|
||||
ASSERT_TRUE(instance_);
|
||||
instance_->unregisterRuntime(*runtimeTarget_);
|
||||
runtimeTarget_ = nullptr;
|
||||
}
|
||||
if (instance_) {
|
||||
if (instance_ != nullptr) {
|
||||
page_->unregisterInstance(*instance_);
|
||||
instance_ = nullptr;
|
||||
}
|
||||
|
||||
+2
-1
@@ -395,7 +395,8 @@ JNIArgs convertJSIArgsToJNIArgs(
|
||||
"boolean", argIndex, methodName, arg, &rt);
|
||||
}
|
||||
jarg->l = makeGlobalIfNecessary(
|
||||
jni::JBoolean::valueOf(arg->getBool()).release());
|
||||
jni::JBoolean::valueOf(static_cast<unsigned char>(arg->getBool()))
|
||||
.release());
|
||||
} else if (type == "Ljava/lang/String;") {
|
||||
if (!arg->isString()) {
|
||||
throw JavaTurboModuleArgumentConversionException(
|
||||
|
||||
+5
-5
@@ -51,7 +51,7 @@ std::vector<const RCTMethodInfo *> getMethodInfos(Class moduleClass)
|
||||
std::vector<const RCTMethodInfo *> methodInfos;
|
||||
|
||||
Class cls = moduleClass;
|
||||
while (cls && cls != [NSObject class] && cls != [NSProxy class]) {
|
||||
while ((cls != nullptr) && cls != [NSObject class] && cls != [NSProxy class]) {
|
||||
unsigned int methodCount;
|
||||
Method *methods = class_copyMethodList(object_getClass(cls), &methodCount);
|
||||
|
||||
@@ -482,7 +482,7 @@ void ObjCInteropTurboModule::setInvocationArg(
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg) {
|
||||
if (arg != nullptr) {
|
||||
[retainedObjectsForInvocation addObject:arg];
|
||||
}
|
||||
[inv setArgument:&arg atIndex:(index) + 2];
|
||||
@@ -496,7 +496,7 @@ void ObjCInteropTurboModule::setInvocationArg(
|
||||
typeInvocation.target = [RCTConvert class];
|
||||
|
||||
void *returnValue = malloc(typeSignature.methodReturnLength);
|
||||
if (!returnValue) {
|
||||
if (returnValue == nullptr) {
|
||||
// CWE - 391 : Unchecked error condition
|
||||
// https://www.cvedetails.com/cwe-details/391/Unchecked-Error-Condition.html
|
||||
// https://eli.thegreenplace.net/2009/10/30/handling-out-of-memory-conditions-in-c
|
||||
@@ -519,7 +519,7 @@ void ObjCInteropTurboModule::setInvocationArg(
|
||||
* RCTModuleMethod doesn't actually call into RCTConvert in this case.
|
||||
*/
|
||||
id arg = [objCArg copy];
|
||||
if (arg) {
|
||||
if (arg != nullptr) {
|
||||
[retainedObjectsForInvocation addObject:arg];
|
||||
}
|
||||
[inv setArgument:&arg atIndex:(index) + 2];
|
||||
@@ -537,7 +537,7 @@ void ObjCInteropTurboModule::setInvocationArg(
|
||||
|
||||
RCTResponseSenderBlock arg =
|
||||
(RCTResponseSenderBlock)TurboModuleConvertUtils::convertJSIValueToObjCObject(runtime, jsiArg, jsInvoker_, YES);
|
||||
if (arg) {
|
||||
if (arg != nullptr) {
|
||||
[retainedObjectsForInvocation addObject:arg];
|
||||
}
|
||||
[inv setArgument:&arg atIndex:(index) + 2];
|
||||
|
||||
+15
-15
@@ -59,7 +59,7 @@ static jsi::Value convertNSNumberToJSINumber(jsi::Runtime &runtime, NSNumber *va
|
||||
|
||||
static jsi::String convertNSStringToJSIString(jsi::Runtime &runtime, NSString *value)
|
||||
{
|
||||
return jsi::String::createFromUtf8(runtime, [value UTF8String] ? [value UTF8String] : "");
|
||||
return jsi::String::createFromUtf8(runtime, ([value UTF8String] != nullptr) ? [value UTF8String] : "");
|
||||
}
|
||||
|
||||
static jsi::Object convertNSDictionaryToJSIObject(jsi::Runtime &runtime, NSDictionary *value)
|
||||
@@ -124,7 +124,7 @@ static NSArray *convertJSIArrayToNSArray(
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
// Insert kCFNull when it's `undefined` value to preserve the indices.
|
||||
id convertedObject = convertJSIValueToObjCObject(runtime, value.getValueAtIndex(runtime, i), jsInvoker, useNSNull);
|
||||
[result addObject:convertedObject ? convertedObject : (id)kCFNull];
|
||||
[result addObject:(convertedObject != nullptr) ? convertedObject : (id)kCFNull];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -142,7 +142,7 @@ static NSDictionary *convertJSIObjectToNSDictionary(
|
||||
jsi::String name = propertyNames.getValueAtIndex(runtime, i).getString(runtime);
|
||||
NSString *k = convertJSIStringToNSString(runtime, name);
|
||||
id v = convertJSIValueToObjCObject(runtime, value.getProperty(runtime, name), jsInvoker, useNSNull);
|
||||
if (v) {
|
||||
if (v != nullptr) {
|
||||
result[k] = v;
|
||||
}
|
||||
}
|
||||
@@ -252,7 +252,7 @@ static jsi::Value convertJSErrorDetailsToJSRuntimeError(jsi::Runtime &runtime, N
|
||||
jsi::Value
|
||||
ObjCTurboModule::createPromise(jsi::Runtime &runtime, const std::string &methodName, PromiseInvocationBlock invoke)
|
||||
{
|
||||
if (!invoke) {
|
||||
if (invoke == nullptr) {
|
||||
return jsi::Value::undefined();
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ id ObjCTurboModule::performMethodInvocation(
|
||||
|
||||
void (^block)() = ^{
|
||||
id<RCTBridgeModule> strongModule = weakModule;
|
||||
if (!strongModule) {
|
||||
if (strongModule == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ void ObjCTurboModule::performVoidMethodInvocation(
|
||||
|
||||
void (^block)() = ^{
|
||||
id<RCTBridgeModule> strongModule = weakModule;
|
||||
if (!strongModule) {
|
||||
if (strongModule == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -560,14 +560,14 @@ jsi::Value ObjCTurboModule::convertReturnIdToJSIValue(
|
||||
*/
|
||||
NSString *ObjCTurboModule::getArgumentTypeName(jsi::Runtime &runtime, NSString *methodName, int argIndex)
|
||||
{
|
||||
if (!methodArgumentTypeNames_) {
|
||||
if (methodArgumentTypeNames_ == nullptr) {
|
||||
NSMutableDictionary<NSString *, NSArray<NSString *> *> *methodArgumentTypeNames = [NSMutableDictionary new];
|
||||
|
||||
unsigned int numberOfMethods;
|
||||
Class cls = [instance_ class];
|
||||
Method *methods = class_copyMethodList(object_getClass(cls), &numberOfMethods);
|
||||
|
||||
if (methods) {
|
||||
if (methods != nullptr) {
|
||||
for (unsigned int i = 0; i < numberOfMethods; i++) {
|
||||
SEL s = method_getName(methods[i]);
|
||||
NSString *mName = NSStringFromSelector(s);
|
||||
@@ -597,7 +597,7 @@ NSString *ObjCTurboModule::getArgumentTypeName(jsi::Runtime &runtime, NSString *
|
||||
methodArgumentTypeNames_ = methodArgumentTypeNames;
|
||||
}
|
||||
|
||||
if (methodArgumentTypeNames_[methodName]) {
|
||||
if (methodArgumentTypeNames_[methodName] != nullptr) {
|
||||
assert([methodArgumentTypeNames_[methodName] count] > argIndex);
|
||||
return methodArgumentTypeNames_[methodName][argIndex];
|
||||
}
|
||||
@@ -656,7 +656,7 @@ void ObjCTurboModule::setInvocationArg(
|
||||
*/
|
||||
BOOL enableModuleArgumentNSNullConversionIOS = ReactNativeFeatureFlags::enableModuleArgumentNSNullConversionIOS();
|
||||
id objCArg = convertJSIValueToObjCObject(runtime, arg, jsInvoker_, enableModuleArgumentNSNullConversionIOS);
|
||||
if (objCArg) {
|
||||
if (objCArg != nullptr) {
|
||||
NSString *methodNameNSString = @(methodName);
|
||||
|
||||
/**
|
||||
@@ -678,7 +678,7 @@ void ObjCTurboModule::setInvocationArg(
|
||||
}
|
||||
|
||||
[inv setArgument:(void *)&convertedObjCArg atIndex:i + 2];
|
||||
if (convertedObjCArg) {
|
||||
if (convertedObjCArg != nullptr) {
|
||||
[retainedObjectsForInvocation addObject:convertedObjCArg];
|
||||
}
|
||||
return;
|
||||
@@ -708,7 +708,7 @@ void ObjCTurboModule::setInvocationArg(
|
||||
* Insert converted args unmodified.
|
||||
*/
|
||||
[inv setArgument:(void *)&objCArg atIndex:i + 2];
|
||||
if (objCArg) {
|
||||
if (objCArg != nullptr) {
|
||||
[retainedObjectsForInvocation addObject:objCArg];
|
||||
}
|
||||
}
|
||||
@@ -848,7 +848,7 @@ jsi::Value ObjCTurboModule::invokeObjCMethod(
|
||||
|
||||
BOOL ObjCTurboModule::hasMethodArgConversionSelector(NSString *methodName, size_t argIndex)
|
||||
{
|
||||
return methodArgConversionSelectors_ && methodArgConversionSelectors_[methodName] &&
|
||||
return (methodArgConversionSelectors_ != nullptr) && (methodArgConversionSelectors_[methodName] != nullptr) &&
|
||||
![methodArgConversionSelectors_[methodName][argIndex] isEqual:(id)kCFNull];
|
||||
}
|
||||
|
||||
@@ -860,11 +860,11 @@ SEL ObjCTurboModule::getMethodArgConversionSelector(NSString *methodName, size_t
|
||||
|
||||
void ObjCTurboModule::setMethodArgConversionSelector(NSString *methodName, size_t argIndex, NSString *fnName)
|
||||
{
|
||||
if (!methodArgConversionSelectors_) {
|
||||
if (methodArgConversionSelectors_ == nullptr) {
|
||||
methodArgConversionSelectors_ = [NSMutableDictionary new];
|
||||
}
|
||||
|
||||
if (!methodArgConversionSelectors_[methodName]) {
|
||||
if (methodArgConversionSelectors_[methodName] == nullptr) {
|
||||
auto metaData = methodMap_.at([methodName UTF8String]);
|
||||
auto argCount = metaData.argCount;
|
||||
|
||||
|
||||
+4
-4
@@ -136,14 +136,14 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSDictionary *, getValue : (double)x y : (NS
|
||||
{
|
||||
return @{
|
||||
@"x" : @(x),
|
||||
@"y" : y ? y : [NSNull null],
|
||||
@"z" : z ? z : [NSNull null],
|
||||
@"y" : (y != nullptr) ? y : [NSNull null],
|
||||
@"z" : (z != nullptr) ? z : [NSNull null],
|
||||
};
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(getValueWithCallback : (RCTResponseSenderBlock)callback)
|
||||
{
|
||||
if (!callback) {
|
||||
if (callback == nullptr) {
|
||||
return;
|
||||
}
|
||||
callback(@[ @"value from callback!" ]);
|
||||
@@ -154,7 +154,7 @@ RCT_EXPORT_METHOD(getValueWithPromise
|
||||
: (RCTPromiseResolveBlock)resolve reject
|
||||
: (RCTPromiseRejectBlock)reject)
|
||||
{
|
||||
if (!resolve || !reject) {
|
||||
if ((resolve == nullptr) || (reject == nullptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -136,14 +136,14 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSDictionary *, getValue : (double)x y : (NS
|
||||
{
|
||||
return @{
|
||||
@"x" : @(x),
|
||||
@"y" : y ? y : [NSNull null],
|
||||
@"z" : z ? z : [NSNull null],
|
||||
@"y" : (y != nullptr) ? y : [NSNull null],
|
||||
@"z" : (z != nullptr) ? z : [NSNull null],
|
||||
};
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(getValueWithCallback : (RCTResponseSenderBlock)callback)
|
||||
{
|
||||
if (!callback) {
|
||||
if (callback == nullptr) {
|
||||
return;
|
||||
}
|
||||
callback(@[ @"value from callback!" ]);
|
||||
@@ -154,7 +154,7 @@ RCT_EXPORT_METHOD(getValueWithPromise
|
||||
: (RCTPromiseResolveBlock)resolve reject
|
||||
: (RCTPromiseRejectBlock)reject)
|
||||
{
|
||||
if (!resolve || !reject) {
|
||||
if ((resolve == nullptr) || (reject == nullptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -402,79 +402,79 @@ inline void fromRawValue(
|
||||
inline std::string toString(const FontVariant& fontVariant) {
|
||||
auto result = std::string{};
|
||||
auto separator = std::string{", "};
|
||||
if ((int)fontVariant & (int)FontVariant::SmallCaps) {
|
||||
if (((int)fontVariant & (int)FontVariant::SmallCaps) != 0) {
|
||||
result += "small-caps" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::OldstyleNums) {
|
||||
if (((int)fontVariant & (int)FontVariant::OldstyleNums) != 0) {
|
||||
result += "oldstyle-nums" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::LiningNums) {
|
||||
if (((int)fontVariant & (int)FontVariant::LiningNums) != 0) {
|
||||
result += "lining-nums" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::TabularNums) {
|
||||
if (((int)fontVariant & (int)FontVariant::TabularNums) != 0) {
|
||||
result += "tabular-nums" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::ProportionalNums) {
|
||||
if (((int)fontVariant & (int)FontVariant::ProportionalNums) != 0) {
|
||||
result += "proportional-nums" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticOne) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticOne) != 0) {
|
||||
result += "stylistic-one" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticTwo) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticTwo) != 0) {
|
||||
result += "stylistic-two" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticThree) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticThree) != 0) {
|
||||
result += "stylistic-three" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticFour) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticFour) != 0) {
|
||||
result += "stylistic-four" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticFive) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticFive) != 0) {
|
||||
result += "stylistic-five" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticSix) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticSix) != 0) {
|
||||
result += "stylistic-six" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticSeven) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticSeven) != 0) {
|
||||
result += "stylistic-seven" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticEight) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticEight) != 0) {
|
||||
result += "stylistic-eight" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticNine) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticNine) != 0) {
|
||||
result += "stylistic-nine" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticTen) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticTen) != 0) {
|
||||
result += "stylistic-ten" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticEleven) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticEleven) != 0) {
|
||||
result += "stylistic-eleven" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticTwelve) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticTwelve) != 0) {
|
||||
result += "stylistic-twelve" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticThirteen) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticThirteen) != 0) {
|
||||
result += "stylistic-thirteen" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticFourteen) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticFourteen) != 0) {
|
||||
result += "stylistic-fourteen" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticFifteen) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticFifteen) != 0) {
|
||||
result += "stylistic-fifteen" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticSixteen) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticSixteen) != 0) {
|
||||
result += "stylistic-sixteen" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticSeventeen) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticSeventeen) != 0) {
|
||||
result += "stylistic-seventeen" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticEighteen) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticEighteen) != 0) {
|
||||
result += "stylistic-eighteen" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticNineteen) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticNineteen) != 0) {
|
||||
result += "stylistic-nineteen" + separator;
|
||||
}
|
||||
if ((int)fontVariant & (int)FontVariant::StylisticTwenty) {
|
||||
if (((int)fontVariant & (int)FontVariant::StylisticTwenty) != 0) {
|
||||
result += "stylistic-twenty" + separator;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -63,13 +63,13 @@ static Class getViewManagerFromComponentName(const std::string &componentName)
|
||||
// 1. Try to get the manager with the RCT prefix.
|
||||
auto rctViewManagerName = "RCT" + viewManagerName;
|
||||
Class viewManagerClass = NSClassFromString(RCTNSStringFromString(rctViewManagerName));
|
||||
if (viewManagerClass) {
|
||||
if (viewManagerClass != nullptr) {
|
||||
return viewManagerClass;
|
||||
}
|
||||
|
||||
// 2. Try to get the manager without the prefix.
|
||||
viewManagerClass = NSClassFromString(RCTNSStringFromString(viewManagerName));
|
||||
if (viewManagerClass) {
|
||||
if (viewManagerClass != nullptr) {
|
||||
return viewManagerClass;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ class AndroidTextInputComponentDescriptor final
|
||||
->getMethod<jboolean(jint, jfloatArray)>("getThemeData");
|
||||
|
||||
if (getThemeData(
|
||||
fabricUIManager, surfaceId, defaultTextInputPaddingArray)) {
|
||||
fabricUIManager, surfaceId, defaultTextInputPaddingArray) != 0u) {
|
||||
jfloat* defaultTextInputPadding =
|
||||
env->GetFloatArrayElements(defaultTextInputPaddingArray, nullptr);
|
||||
theme.start = defaultTextInputPadding[0];
|
||||
|
||||
+3
-3
@@ -29,7 +29,7 @@ bool UIColorIsP3ColorSpace(const std::shared_ptr<void> &uiColor)
|
||||
|
||||
if (CGColorSpaceGetModel(colorSpace) == kCGColorSpaceModelRGB) {
|
||||
CFStringRef name = CGColorSpaceGetName(colorSpace);
|
||||
if (name != NULL && CFEqual(name, kCGColorSpaceDisplayP3)) {
|
||||
if (name != NULL && (CFEqual(name, kCGColorSpaceDisplayP3) != 0u)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ uint32_t ColorFromUIColorForSpecificTraitCollection(
|
||||
UITraitCollection *traitCollection)
|
||||
{
|
||||
UIColor *color = (UIColor *)unwrapManagedObject(uiColor);
|
||||
if (color) {
|
||||
if (color != nullptr) {
|
||||
color = [color resolvedColorWithTraitCollection:traitCollection];
|
||||
return ColorFromUIColor(color);
|
||||
}
|
||||
@@ -199,7 +199,7 @@ Color::Color(const ColorComponents &components)
|
||||
Color::Color(std::shared_ptr<void> uiColor)
|
||||
{
|
||||
UIColor *color = ((UIColor *)unwrapManagedObject(uiColor));
|
||||
if (color) {
|
||||
if (color != nullptr) {
|
||||
auto colorHash = hashFromUIColor(uiColor);
|
||||
uiColorHashValue_ = colorHash;
|
||||
}
|
||||
|
||||
+4
-4
@@ -29,16 +29,16 @@ inline facebook::react::SharedColor RCTPlatformColorComponentsFromDynamicItems(
|
||||
SharedColor darkSharedColor{};
|
||||
SharedColor highContrastLightSharedColor{};
|
||||
SharedColor highContrastDarkSharedColor{};
|
||||
if (dynamicItems.count("light")) {
|
||||
if (dynamicItems.count("light") != 0u) {
|
||||
fromRawValue(contextContainer, surfaceId, dynamicItems.at("light"), lightSharedColor);
|
||||
}
|
||||
if (dynamicItems.count("dark")) {
|
||||
if (dynamicItems.count("dark") != 0u) {
|
||||
fromRawValue(contextContainer, surfaceId, dynamicItems.at("dark"), darkSharedColor);
|
||||
}
|
||||
if (dynamicItems.count("highContrastLight")) {
|
||||
if (dynamicItems.count("highContrastLight") != 0u) {
|
||||
fromRawValue(contextContainer, surfaceId, dynamicItems.at("highContrastLight"), highContrastLightSharedColor);
|
||||
}
|
||||
if (dynamicItems.count("highContrastDark")) {
|
||||
if (dynamicItems.count("highContrastDark") != 0u) {
|
||||
fromRawValue(contextContainer, surfaceId, dynamicItems.at("highContrastDark"), highContrastDarkSharedColor);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user