Skip to content

Commit 896aaea

Browse files
committed
feat: add clang-format
1 parent 684eeec commit 896aaea

Some content is hidden

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

60 files changed

+4156
-2786
lines changed

.github/workflows/lint-clang.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Lint Clang
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
merge_group:
11+
types:
12+
- checks_requested
13+
14+
jobs:
15+
lint:
16+
name: Run clang lint
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: '20'
28+
29+
- name: Install dependencies
30+
run: yarn install --frozen-lockfile
31+
32+
- name: Run clang lint
33+
run: yarn lint-clang

android/src/main/new_arch/RNEnrichedTextInputViewSpec.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11

22
/**
3-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3+
* This code was generated by
4+
* [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
45
*
5-
* Do not edit this file as changes may cause incorrect behavior and will be lost
6-
* once the code is regenerated.
6+
* Do not edit this file as changes may cause incorrect behavior and will be
7+
* lost once the code is regenerated.
78
*
89
* @generated by codegen project: GenerateModuleJniCpp.js
910
*/
@@ -12,9 +13,8 @@
1213

1314
namespace facebook::react {
1415

15-
16-
17-
std::shared_ptr<TurboModule> RNEnrichedTextInputViewSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
16+
std::shared_ptr<TurboModule> RNEnrichedTextInputViewSpec_ModuleProvider(
17+
const std::string &moduleName, const JavaTurboModule::InitParams &params) {
1818

1919
return nullptr;
2020
}

android/src/main/new_arch/RNEnrichedTextInputViewSpec.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11

22
/**
3-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3+
* This code was generated by
4+
* [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
45
*
5-
* Do not edit this file as changes may cause incorrect behavior and will be lost
6-
* once the code is regenerated.
6+
* Do not edit this file as changes may cause incorrect behavior and will be
7+
* lost once the code is regenerated.
78
*
89
* @generated by codegen project: GenerateModuleJniH.js
910
*/
@@ -18,9 +19,8 @@
1819

1920
namespace facebook::react {
2021

21-
22-
2322
JSI_EXPORT
24-
std::shared_ptr<TurboModule> RNEnrichedTextInputViewSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
23+
std::shared_ptr<TurboModule> RNEnrichedTextInputViewSpec_ModuleProvider(
24+
const std::string &moduleName, const JavaTurboModule::InitParams &params);
2525

2626
} // namespace facebook::react

android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputComponentDescriptor.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@
88
namespace facebook::react {
99

1010
class EnrichedTextInputComponentDescriptor final
11-
: public ConcreteComponentDescriptor<EnrichedTextInputShadowNode> {
11+
: public ConcreteComponentDescriptor<EnrichedTextInputShadowNode> {
1212
public:
13-
EnrichedTextInputComponentDescriptor(
14-
const ComponentDescriptorParameters& parameters)
15-
: ConcreteComponentDescriptor(parameters),
16-
measurementsManager_(
17-
std::make_shared<EnrichedTextInputMeasurementManager>(
18-
contextContainer_)) {}
19-
20-
void adopt(ShadowNode& shadowNode) const override {
21-
ConcreteComponentDescriptor::adopt(shadowNode);
22-
auto& editorShadowNode = static_cast<EnrichedTextInputShadowNode&>(shadowNode);
23-
24-
// `EnrichedTextInputShadowNode` uses
25-
// `EnrichedTextInputMeasurementManager` to provide measurements to Yoga.
26-
editorShadowNode.setMeasurementsManager(measurementsManager_);
27-
}
13+
EnrichedTextInputComponentDescriptor(
14+
const ComponentDescriptorParameters &parameters)
15+
: ConcreteComponentDescriptor(parameters),
16+
measurementsManager_(
17+
std::make_shared<EnrichedTextInputMeasurementManager>(
18+
contextContainer_)) {}
19+
20+
void adopt(ShadowNode &shadowNode) const override {
21+
ConcreteComponentDescriptor::adopt(shadowNode);
22+
auto &editorShadowNode =
23+
static_cast<EnrichedTextInputShadowNode &>(shadowNode);
24+
25+
// `EnrichedTextInputShadowNode` uses
26+
// `EnrichedTextInputMeasurementManager` to provide measurements to Yoga.
27+
editorShadowNode.setMeasurementsManager(measurementsManager_);
28+
}
2829

2930
private:
30-
const std::shared_ptr<EnrichedTextInputMeasurementManager>
31-
measurementsManager_;
31+
const std::shared_ptr<EnrichedTextInputMeasurementManager>
32+
measurementsManager_;
3233
};
3334

3435
} // namespace facebook::react
35-

android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.cpp

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,37 @@ using namespace facebook::jni;
88

99
namespace facebook::react {
1010

11-
Size EnrichedTextInputMeasurementManager::measure(
12-
SurfaceId surfaceId,
13-
int viewTag,
14-
LayoutConstraints layoutConstraints) const {
15-
const jni::global_ref<jobject>& fabricUIManager =
16-
contextContainer_->at<jni::global_ref<jobject>>("FabricUIManager");
17-
18-
static const auto measure = facebook::jni::findClassStatic(
19-
"com/facebook/react/fabric/FabricUIManager")
20-
->getMethod<jlong(
21-
jint,
22-
jstring,
23-
ReadableMap::javaobject,
24-
ReadableMap::javaobject,
25-
ReadableMap::javaobject,
26-
jfloat,
27-
jfloat,
28-
jfloat,
29-
jfloat)>("measure");
30-
31-
auto minimumSize = layoutConstraints.minimumSize;
32-
auto maximumSize = layoutConstraints.maximumSize;
33-
34-
local_ref<JString> componentName = make_jstring("EnrichedTextInputView");
35-
36-
folly::dynamic extra = folly::dynamic::object();
37-
extra["viewTag"] = viewTag;
38-
local_ref<ReadableNativeMap::javaobject> extraData = ReadableNativeMap::newObjectCxxArgs(extra);
39-
local_ref<ReadableMap::javaobject> extraDataRM = make_local(reinterpret_cast<ReadableMap::javaobject>(extraData.get()));
40-
41-
auto measurement = yogaMeassureToSize(measure(
42-
fabricUIManager,
43-
surfaceId,
44-
componentName.get(),
45-
extraDataRM.get(),
46-
nullptr,
47-
nullptr,
48-
minimumSize.width,
49-
maximumSize.width,
50-
minimumSize.height,
51-
maximumSize.height));
52-
53-
return measurement;
54-
}
11+
Size EnrichedTextInputMeasurementManager::measure(
12+
SurfaceId surfaceId, int viewTag,
13+
LayoutConstraints layoutConstraints) const {
14+
const jni::global_ref<jobject> &fabricUIManager =
15+
contextContainer_->at<jni::global_ref<jobject>>("FabricUIManager");
16+
17+
static const auto measure =
18+
facebook::jni::findClassStatic(
19+
"com/facebook/react/fabric/FabricUIManager")
20+
->getMethod<jlong(jint, jstring, ReadableMap::javaobject,
21+
ReadableMap::javaobject, ReadableMap::javaobject,
22+
jfloat, jfloat, jfloat, jfloat)>("measure");
23+
24+
auto minimumSize = layoutConstraints.minimumSize;
25+
auto maximumSize = layoutConstraints.maximumSize;
26+
27+
local_ref<JString> componentName = make_jstring("EnrichedTextInputView");
28+
29+
folly::dynamic extra = folly::dynamic::object();
30+
extra["viewTag"] = viewTag;
31+
local_ref<ReadableNativeMap::javaobject> extraData =
32+
ReadableNativeMap::newObjectCxxArgs(extra);
33+
local_ref<ReadableMap::javaobject> extraDataRM =
34+
make_local(reinterpret_cast<ReadableMap::javaobject>(extraData.get()));
35+
36+
auto measurement = yogaMeassureToSize(
37+
measure(fabricUIManager, surfaceId, componentName.get(),
38+
extraDataRM.get(), nullptr, nullptr, minimumSize.width,
39+
maximumSize.width, minimumSize.height, maximumSize.height));
40+
41+
return measurement;
42+
}
5543

5644
} // namespace facebook::react

android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.h

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,23 @@
22

33
#include "ComponentDescriptors.h"
44

5-
#include <react/utils/ContextContainer.h>
6-
#include <react/renderer/core/LayoutConstraints.h>
75
#include <react/renderer/components/RNEnrichedTextInputViewSpec/Props.h>
6+
#include <react/renderer/core/LayoutConstraints.h>
7+
#include <react/utils/ContextContainer.h>
88

99
namespace facebook::react {
1010

11-
class EnrichedTextInputMeasurementManager {
12-
public:
13-
EnrichedTextInputMeasurementManager(
14-
const std::shared_ptr<const ContextContainer>& contextContainer)
15-
: contextContainer_(contextContainer) {}
11+
class EnrichedTextInputMeasurementManager {
12+
public:
13+
EnrichedTextInputMeasurementManager(
14+
const std::shared_ptr<const ContextContainer> &contextContainer)
15+
: contextContainer_(contextContainer) {}
1616

17-
Size measure(
18-
SurfaceId surfaceId,
19-
int viewTag,
20-
LayoutConstraints layoutConstraints) const;
17+
Size measure(SurfaceId surfaceId, int viewTag,
18+
LayoutConstraints layoutConstraints) const;
2119

22-
private:
23-
const std::shared_ptr<const ContextContainer> contextContainer_;
24-
};
20+
private:
21+
const std::shared_ptr<const ContextContainer> contextContainer_;
22+
};
2523

2624
} // namespace facebook::react

android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.cpp

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,32 @@
44

55
namespace facebook::react {
66
extern const char EnrichedTextInputComponentName[] = "EnrichedTextInputView";
7-
void EnrichedTextInputShadowNode::setMeasurementsManager(
8-
const std::shared_ptr<EnrichedTextInputMeasurementManager>&
9-
measurementsManager) {
10-
ensureUnsealed();
11-
measurementsManager_ = measurementsManager;
12-
}
7+
void EnrichedTextInputShadowNode::setMeasurementsManager(
8+
const std::shared_ptr<EnrichedTextInputMeasurementManager>
9+
&measurementsManager) {
10+
ensureUnsealed();
11+
measurementsManager_ = measurementsManager;
12+
}
1313

14-
// Mark layout as dirty after state has been updated
15-
// Once layout is marked as dirty, `measureContent` will be called in order to recalculate layout
16-
void EnrichedTextInputShadowNode::dirtyLayoutIfNeeded() {
17-
const auto state = this->getStateData();
18-
const auto counter = state.getForceHeightRecalculationCounter();
14+
// Mark layout as dirty after state has been updated
15+
// Once layout is marked as dirty, `measureContent` will be called in order to
16+
// recalculate layout
17+
void EnrichedTextInputShadowNode::dirtyLayoutIfNeeded() {
18+
const auto state = this->getStateData();
19+
const auto counter = state.getForceHeightRecalculationCounter();
1920

20-
if (forceHeightRecalculationCounter_ != counter) {
21-
forceHeightRecalculationCounter_ = counter;
21+
if (forceHeightRecalculationCounter_ != counter) {
22+
forceHeightRecalculationCounter_ = counter;
2223

23-
dirtyLayout();
24-
}
25-
}
24+
dirtyLayout();
25+
}
26+
}
2627

27-
Size EnrichedTextInputShadowNode::measureContent(
28-
const LayoutContext &layoutContext,
29-
const LayoutConstraints &layoutConstraints) const {
30-
return measurementsManager_->measure(getSurfaceId(), getTag(), layoutConstraints);
31-
}
28+
Size EnrichedTextInputShadowNode::measureContent(
29+
const LayoutContext &layoutContext,
30+
const LayoutConstraints &layoutConstraints) const {
31+
return measurementsManager_->measure(getSurfaceId(), getTag(),
32+
layoutConstraints);
33+
}
3234

3335
} // namespace facebook::react

android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.h

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,51 @@
33
#include "EnrichedTextInputMeasurementManager.h"
44
#include "EnrichedTextInputState.h"
55

6-
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
7-
#include <react/renderer/components/RNEnrichedTextInputViewSpec/Props.h>
86
#include <react/renderer/components/RNEnrichedTextInputViewSpec/EventEmitters.h>
7+
#include <react/renderer/components/RNEnrichedTextInputViewSpec/Props.h>
8+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
99

1010
namespace facebook::react {
1111

1212
JSI_EXPORT extern const char EnrichedTextInputComponentName[];
1313
/*
1414
* `ShadowNode` for <EnrichedTextInputView> component.
1515
*/
16-
class EnrichedTextInputShadowNode final : public ConcreteViewShadowNode<
17-
EnrichedTextInputComponentName,
18-
EnrichedTextInputViewProps,
19-
EnrichedTextInputViewEventEmitter,
20-
EnrichedTextInputState> {
16+
class EnrichedTextInputShadowNode final
17+
: public ConcreteViewShadowNode<
18+
EnrichedTextInputComponentName, EnrichedTextInputViewProps,
19+
EnrichedTextInputViewEventEmitter, EnrichedTextInputState> {
2120
public:
22-
using ConcreteViewShadowNode::ConcreteViewShadowNode;
23-
24-
// This constructor is called when we "update" shadow node, e.g. after updating shadow node's state
25-
EnrichedTextInputShadowNode(
26-
ShadowNode const &sourceShadowNode,
27-
ShadowNodeFragment const &fragment)
28-
: ConcreteViewShadowNode(sourceShadowNode, fragment) {
29-
dirtyLayoutIfNeeded();
30-
}
31-
32-
static ShadowNodeTraits BaseTraits() {
33-
auto traits = ConcreteViewShadowNode::BaseTraits();
34-
traits.set(ShadowNodeTraits::Trait::LeafYogaNode);
35-
traits.set(ShadowNodeTraits::Trait::MeasurableYogaNode);
36-
return traits;
37-
}
38-
39-
// Associates a shared `EnrichedTextInputMeasurementManager` with the node.
40-
void setMeasurementsManager(
41-
const std::shared_ptr<EnrichedTextInputMeasurementManager>&
42-
measurementsManager);
43-
44-
void dirtyLayoutIfNeeded();
45-
46-
Size measureContent(
47-
const LayoutContext& layoutContext,
48-
const LayoutConstraints& layoutConstraints) const override;
21+
using ConcreteViewShadowNode::ConcreteViewShadowNode;
22+
23+
// This constructor is called when we "update" shadow node, e.g. after
24+
// updating shadow node's state
25+
EnrichedTextInputShadowNode(ShadowNode const &sourceShadowNode,
26+
ShadowNodeFragment const &fragment)
27+
: ConcreteViewShadowNode(sourceShadowNode, fragment) {
28+
dirtyLayoutIfNeeded();
29+
}
30+
31+
static ShadowNodeTraits BaseTraits() {
32+
auto traits = ConcreteViewShadowNode::BaseTraits();
33+
traits.set(ShadowNodeTraits::Trait::LeafYogaNode);
34+
traits.set(ShadowNodeTraits::Trait::MeasurableYogaNode);
35+
return traits;
36+
}
37+
38+
// Associates a shared `EnrichedTextInputMeasurementManager` with the node.
39+
void setMeasurementsManager(
40+
const std::shared_ptr<EnrichedTextInputMeasurementManager>
41+
&measurementsManager);
42+
43+
void dirtyLayoutIfNeeded();
44+
45+
Size
46+
measureContent(const LayoutContext &layoutContext,
47+
const LayoutConstraints &layoutConstraints) const override;
4948

5049
private:
51-
int forceHeightRecalculationCounter_;
52-
std::shared_ptr<EnrichedTextInputMeasurementManager> measurementsManager_;
50+
int forceHeightRecalculationCounter_;
51+
std::shared_ptr<EnrichedTextInputMeasurementManager> measurementsManager_;
5352
};
5453
} // namespace facebook::react

0 commit comments

Comments
 (0)