mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Compare commits
1
Commits
main
...
export-D81699709
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
873c65d871 |
+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