Skip to content

Commit 2c683c5

Browse files
Apply clang-tidy setting; RN Android (facebook#52774)
Summary: Pull Request resolved: facebook#52774 Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D78634966 fbshipit-source-id: daee3ed21b6f2229049e6a09e2b9c48dfb7e0264
1 parent 8ed2cee commit 2c683c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+193
-121
lines changed

packages/react-native/ReactAndroid/src/main/jni/react/devsupport/JCxxInspectorPackagerConnection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ JCxxInspectorPackagerConnection::JCxxInspectorPackagerConnection(
2222

2323
local_ref<JCxxInspectorPackagerConnection::jhybriddata>
2424
JCxxInspectorPackagerConnection::initHybrid(
25-
alias_ref<jclass>,
25+
alias_ref<jclass> /*unused*/,
2626
const std::string& url,
2727
const std::string& deviceName,
2828
const std::string& packageName,

packages/react-native/ReactAndroid/src/main/jni/react/devsupport/JCxxInspectorPackagerConnectionWebSocketDelegate.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "JCxxInspectorPackagerConnectionWebSocketDelegate.h"
99

1010
#include <optional>
11+
#include <utility>
1112

1213
using namespace facebook::jni;
1314

@@ -16,7 +17,7 @@ namespace facebook::react::jsinspector_modern {
1617
JCxxInspectorPackagerConnectionWebSocketDelegate::
1718
JCxxInspectorPackagerConnectionWebSocketDelegate(
1819
std::weak_ptr<IWebSocketDelegate> cxxDelegate)
19-
: cxxDelegate_(cxxDelegate) {}
20+
: cxxDelegate_(std::move(cxxDelegate)) {}
2021

2122
void JCxxInspectorPackagerConnectionWebSocketDelegate::didFailWithError(
2223
alias_ref<jni::JInteger> posixCode,

packages/react-native/ReactAndroid/src/main/jni/react/devsupport/OnLoad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include <fbjni/fbjni.h>
1313

14-
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
14+
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* /*unused*/) {
1515
return facebook::jni::initialize(vm, [] {
1616
facebook::react::jsinspector_modern::JCxxInspectorPackagerConnection::
1717
registerNatives();

packages/react-native/ReactAndroid/src/main/jni/react/fabric/ComponentFactory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ using namespace facebook::jsi;
1616
namespace facebook::react {
1717

1818
jni::local_ref<ComponentFactory::jhybriddata> ComponentFactory::initHybrid(
19-
jni::alias_ref<jclass>) {
19+
jni::alias_ref<jclass> /*unused*/) {
2020
return makeCxxInstance();
2121
}
2222

packages/react-native/ReactAndroid/src/main/jni/react/fabric/EventEmitterWrapper.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "EventEmitterWrapper.h"
99
#include <fbjni/fbjni.h>
1010

11+
#include <utility>
12+
1113
using namespace facebook::jni;
1214

1315
namespace facebook::react {
@@ -21,8 +23,8 @@ void EventEmitterWrapper::dispatchEvent(
2123
// crashing.
2224
if (eventEmitter != nullptr) {
2325
eventEmitter->dispatchEvent(
24-
eventName,
25-
payload ? payload->consume() : folly::dynamic::object(),
26+
std::move(eventName),
27+
(payload != nullptr) ? payload->consume() : folly::dynamic::object(),
2628
static_cast<RawEvent::Category>(category));
2729
}
2830
}
@@ -51,7 +53,8 @@ void EventEmitterWrapper::dispatchUniqueEvent(
5153
// crashing.
5254
if (eventEmitter != nullptr) {
5355
eventEmitter->dispatchUniqueEvent(
54-
eventName, payload ? payload->consume() : folly::dynamic::object());
56+
std::move(eventName),
57+
(payload != nullptr) ? payload->consume() : folly::dynamic::object());
5558
}
5659
}
5760

packages/react-native/ReactAndroid/src/main/jni/react/fabric/EventEmitterWrapper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class EventEmitterWrapper : public jni::HybridClass<EventEmitterWrapper> {
2727

2828
SharedEventEmitter eventEmitter;
2929

30-
void dispatchEvent(std::string eventName, NativeMap* params, int category);
30+
void dispatchEvent(std::string eventName, NativeMap* payload, int category);
3131
void dispatchEventSynchronously(std::string eventName, NativeMap* params);
32-
void dispatchUniqueEvent(std::string eventName, NativeMap* params);
32+
void dispatchUniqueEvent(std::string eventName, NativeMap* payload);
3333
};
3434

3535
} // namespace facebook::react

packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ jni::local_ref<jstring> getPlatformComponentName(const ShadowView& shadowView) {
200200
inline float scale(Float value, Float pointScaleFactor) {
201201
std::feclearexcept(FE_ALL_EXCEPT);
202202
float result = value * pointScaleFactor;
203-
if (std::fetestexcept(FE_OVERFLOW)) {
203+
if (std::fetestexcept(FE_OVERFLOW) != 0) {
204204
LOG(ERROR) << "Binding::scale - FE_OVERFLOW - value: " << value
205205
<< " pointScaleFactor: " << pointScaleFactor
206206
<< " result: " << result;
207207
}
208-
if (std::fetestexcept(FE_UNDERFLOW)) {
208+
if (std::fetestexcept(FE_UNDERFLOW) != 0) {
209209
LOG(ERROR) << "Binding::scale - FE_UNDERFLOW - value: " << value
210210
<< " pointScaleFactor: " << pointScaleFactor
211211
<< " result: " << result;
@@ -455,7 +455,7 @@ void FabricMountingManager::executeMount(
455455

456456
auto env = jni::Environment::current();
457457

458-
auto telemetry = transaction.getTelemetry();
458+
const auto& telemetry = transaction.getTelemetry();
459459
auto surfaceId = transaction.getSurfaceId();
460460
auto& mutations = transaction.getMutations();
461461

@@ -720,9 +720,9 @@ void FabricMountingManager::executeMount(
720720
// Allocate the intBuffer and object array, now that we know exact sizes
721721
// necessary
722722
InstructionBuffer buffer = {
723-
env,
724-
env->NewIntArray(batchMountItemIntsSize),
725-
jni::JArrayClass<jobject>::newArray(batchMountItemObjectsSize),
723+
.env = env,
724+
.ints = env->NewIntArray(batchMountItemIntsSize),
725+
.objects = jni::JArrayClass<jobject>::newArray(batchMountItemObjectsSize),
726726
};
727727

728728
// Fill in arrays
@@ -985,14 +985,14 @@ void FabricMountingManager::preallocateShadowView(
985985
component.get(),
986986
props.get(),
987987
(javaStateWrapper != nullptr ? javaStateWrapper.get() : nullptr),
988-
isLayoutableShadowNode);
988+
static_cast<unsigned char>(isLayoutableShadowNode));
989989
}
990990

991991
bool FabricMountingManager::isOnMainThread() {
992992
static auto isOnMainThread =
993993
JFabricUIManager::javaClassStatic()->getMethod<jboolean()>(
994994
"isOnMainThread");
995-
return isOnMainThread(javaUIManager_);
995+
return isOnMainThread(javaUIManager_) != 0u;
996996
}
997997

998998
void FabricMountingManager::dispatchCommand(

packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,16 @@ void FabricUIManagerBinding::startSurfaceWithConstraints(
320320
return;
321321
}
322322

323-
auto minimumSize =
324-
Size{minWidth / pointScaleFactor_, minHeight / pointScaleFactor_};
325-
auto maximumSize =
326-
Size{maxWidth / pointScaleFactor_, maxHeight / pointScaleFactor_};
323+
auto minimumSize = Size{
324+
.width = minWidth / pointScaleFactor_,
325+
.height = minHeight / pointScaleFactor_};
326+
auto maximumSize = Size{
327+
.width = maxWidth / pointScaleFactor_,
328+
.height = maxHeight / pointScaleFactor_};
327329

328330
LayoutContext context;
329331
context.viewportOffset =
330-
Point{offsetX / pointScaleFactor_, offsetY / pointScaleFactor_};
332+
Point{.x = offsetX / pointScaleFactor_, .y = offsetY / pointScaleFactor_};
331333
context.pointScaleFactor = {pointScaleFactor_};
332334
context.swapLeftAndRightInRTL = doLeftAndRightSwapInRTL != 0;
333335
LayoutConstraints constraints = {};
@@ -461,21 +463,23 @@ void FabricUIManagerBinding::setConstraints(
461463
return;
462464
}
463465

464-
auto minimumSize =
465-
Size{minWidth / pointScaleFactor_, minHeight / pointScaleFactor_};
466-
auto maximumSize =
467-
Size{maxWidth / pointScaleFactor_, maxHeight / pointScaleFactor_};
466+
auto minimumSize = Size{
467+
.width = minWidth / pointScaleFactor_,
468+
.height = minHeight / pointScaleFactor_};
469+
auto maximumSize = Size{
470+
.width = maxWidth / pointScaleFactor_,
471+
.height = maxHeight / pointScaleFactor_};
468472

469473
LayoutContext context;
470474
context.viewportOffset =
471-
Point{offsetX / pointScaleFactor_, offsetY / pointScaleFactor_};
475+
Point{.x = offsetX / pointScaleFactor_, .y = offsetY / pointScaleFactor_};
472476
context.pointScaleFactor = {pointScaleFactor_};
473477
context.swapLeftAndRightInRTL = doLeftAndRightSwapInRTL != 0;
474478
LayoutConstraints constraints = {};
475479
constraints.minimumSize = minimumSize;
476480
constraints.maximumSize = maximumSize;
477-
constraints.layoutDirection =
478-
isRTL ? LayoutDirection::RightToLeft : LayoutDirection::LeftToRight;
481+
constraints.layoutDirection = (isRTL != 0u) ? LayoutDirection::RightToLeft
482+
: LayoutDirection::LeftToRight;
479483

480484
{
481485
std::shared_lock lock(surfaceHandlerRegistryMutex_);

packages/react-native/ReactAndroid/src/main/jni/react/fabric/MountItem.cpp

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,97 @@
1010
namespace facebook::react {
1111

1212
CppMountItem CppMountItem::CreateMountItem(const ShadowView& shadowView) {
13-
return {CppMountItem::Type::Create, {}, {}, shadowView, -1};
13+
return {
14+
.type = CppMountItem::Type::Create,
15+
.parentTag = {},
16+
.oldChildShadowView = {},
17+
.newChildShadowView = shadowView,
18+
.index = -1};
1419
}
1520
CppMountItem CppMountItem::DeleteMountItem(const ShadowView& shadowView) {
16-
return {CppMountItem::Type::Delete, {}, shadowView, {}, -1};
21+
return {
22+
.type = CppMountItem::Type::Delete,
23+
.parentTag = {},
24+
.oldChildShadowView = shadowView,
25+
.newChildShadowView = {},
26+
.index = -1};
1727
}
1828
CppMountItem CppMountItem::InsertMountItem(
1929
Tag parentTag,
2030
const ShadowView& shadowView,
2131
int index) {
22-
return {CppMountItem::Type::Insert, parentTag, {}, shadowView, index};
32+
return {
33+
.type = CppMountItem::Type::Insert,
34+
.parentTag = parentTag,
35+
.oldChildShadowView = {},
36+
.newChildShadowView = shadowView,
37+
.index = index};
2338
}
2439
CppMountItem CppMountItem::RemoveMountItem(
2540
Tag parentTag,
2641
const ShadowView& shadowView,
2742
int index) {
28-
return {CppMountItem::Type::Remove, parentTag, shadowView, {}, index};
43+
return {
44+
.type = CppMountItem::Type::Remove,
45+
.parentTag = parentTag,
46+
.oldChildShadowView = shadowView,
47+
.newChildShadowView = {},
48+
.index = index};
2949
}
3050
CppMountItem CppMountItem::UpdatePropsMountItem(
3151
const ShadowView& oldShadowView,
3252
const ShadowView& newShadowView) {
3353
return {
34-
CppMountItem::Type::UpdateProps, {}, oldShadowView, newShadowView, -1};
54+
.type = CppMountItem::Type::UpdateProps,
55+
.parentTag = {},
56+
.oldChildShadowView = oldShadowView,
57+
.newChildShadowView = newShadowView,
58+
.index = -1};
3559
}
3660
CppMountItem CppMountItem::UpdateStateMountItem(const ShadowView& shadowView) {
37-
return {CppMountItem::Type::UpdateState, {}, {}, shadowView, -1};
61+
return {
62+
.type = CppMountItem::Type::UpdateState,
63+
.parentTag = {},
64+
.oldChildShadowView = {},
65+
.newChildShadowView = shadowView,
66+
.index = -1};
3867
}
3968
CppMountItem CppMountItem::UpdateLayoutMountItem(
4069
const ShadowView& shadowView,
4170
Tag parentTag) {
42-
return {CppMountItem::Type::UpdateLayout, parentTag, {}, shadowView, -1};
71+
return {
72+
.type = CppMountItem::Type::UpdateLayout,
73+
.parentTag = parentTag,
74+
.oldChildShadowView = {},
75+
.newChildShadowView = shadowView,
76+
.index = -1};
4377
}
4478
CppMountItem CppMountItem::UpdateEventEmitterMountItem(
4579
const ShadowView& shadowView) {
46-
return {CppMountItem::Type::UpdateEventEmitter, -1, {}, shadowView, -1};
80+
return {
81+
.type = CppMountItem::Type::UpdateEventEmitter,
82+
.parentTag = -1,
83+
.oldChildShadowView = {},
84+
.newChildShadowView = shadowView,
85+
.index = -1};
4786
}
4887
CppMountItem CppMountItem::UpdatePaddingMountItem(
4988
const ShadowView& shadowView) {
50-
return {CppMountItem::Type::UpdatePadding, -1, {}, shadowView, -1};
89+
return {
90+
.type = CppMountItem::Type::UpdatePadding,
91+
.parentTag = -1,
92+
.oldChildShadowView = {},
93+
.newChildShadowView = shadowView,
94+
.index = -1};
5195
}
5296
CppMountItem CppMountItem::UpdateOverflowInsetMountItem(
5397
const ShadowView& shadowView) {
54-
return {CppMountItem::Type::UpdateOverflowInset, -1, {}, shadowView, -1};
98+
return {
99+
.type = CppMountItem::Type::UpdateOverflowInset,
100+
.parentTag = -1,
101+
.oldChildShadowView = {},
102+
.newChildShadowView = shadowView,
103+
.index = -1};
55104
}
56105

57106
} // namespace facebook::react

packages/react-native/ReactAndroid/src/main/jni/react/fabric/OnLoad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "StateWrapperImpl.h"
1515
#include "SurfaceHandlerBinding.h"
1616

17-
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
17+
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* /*unused*/) {
1818
return facebook::jni::initialize(vm, [] {
1919
facebook::react::EventBeatManager::registerNatives();
2020
facebook::react::EventEmitterWrapper::registerNatives();

0 commit comments

Comments
 (0)