Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ class ScrollViewProps final : public ViewProps {
bool canCancelContentTouches{true};
bool centerContent{};
bool automaticallyAdjustContentInsets{};
Float decelerationRate{0.998};
Float decelerationRate{0.998f};
bool directionalLockEnabled{};
ScrollViewIndicatorStyle indicatorStyle{};
ScrollViewKeyboardDismissMode keyboardDismissMode{};
Float maximumZoomScale{1.0};
Float minimumZoomScale{1.0};
Float maximumZoomScale{1.0f};
Float minimumZoomScale{1.0f};
bool scrollEnabled{true};
bool pagingEnabled{};
bool pinchGestureEnabled{true};
bool scrollsToTop{true};
bool showsHorizontalScrollIndicator{true};
bool showsVerticalScrollIndicator{true};
Float scrollEventThrottle{};
Float zoomScale{1.0};
Float zoomScale{1.0f};
EdgeInsets contentInset{};
Point contentOffset{};
EdgeInsets scrollIndicatorInsets{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ Content ParagraphShadowNode::getContentWithMeasuredAttachments(
laytableShadowNode->measure(layoutContext, localLayoutConstraints);

// Rounding to *next* value on the pixel grid.
size.width += 0.01;
size.height += 0.01;
size.width += 0.01f;
size.height += 0.01f;
size = roundToPixel<&ceil>(size, layoutContext.pointScaleFactor);

auto fragmentLayoutMetrics = LayoutMetrics{};
Expand Down Expand Up @@ -186,7 +186,7 @@ void ParagraphShadowNode::layout(LayoutContext layoutContext) {
react_native_assert(
content.attachments.size() == measurement.attachments.size());

for (auto i = 0; i < content.attachments.size(); i++) {
for (size_t i = 0; i < content.attachments.size(); i++) {
auto &attachment = content.attachments.at(i);

if (!traitCast<LayoutableShadowNode const *>(attachment.shadowNode)) {
Expand Down
8 changes: 4 additions & 4 deletions ReactCommon/react/renderer/components/view/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ struct CascadedRectangleEdges {
OptionalT all{};

Counterpart resolve(bool isRTL, T defaults) const {
const auto leading = isRTL ? end : start;
const auto trailing = isRTL ? start : end;
const auto leadingEdge = isRTL ? end : start;
const auto trailingEdge = isRTL ? start : end;
const auto horizontalOrAllOrDefault =
horizontal.value_or(all.value_or(defaults));
const auto verticalOrAllOrDefault =
vertical.value_or(all.value_or(defaults));

return {
/* .left = */ left.value_or(leading.value_or(horizontalOrAllOrDefault)),
/* .left = */ left.value_or(leadingEdge.value_or(horizontalOrAllOrDefault)),
/* .top = */ top.value_or(verticalOrAllOrDefault),
/* .right = */
right.value_or(trailing.value_or(horizontalOrAllOrDefault)),
right.value_or(trailingEdge.value_or(horizontalOrAllOrDefault)),
/* .bottom = */ bottom.value_or(verticalOrAllOrDefault),
};
}
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/react/renderer/core/EventEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static std::string normalizeEventType(const std::string &type) {
auto prefixedType = type;
if (type.find("top", 0) != 0) {
prefixedType.insert(0, "top");
prefixedType[3] = toupper(prefixedType[3]);
prefixedType[3] = static_cast<char>(toupper(prefixedType[3]));
}
return prefixedType;
}
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/react/renderer/core/RawPropsKeyMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void RawPropsKeyMap::reindex() noexcept {
buckets_.resize(kPropNameLengthHardCap);

auto length = RawPropsPropNameLength{0};
for (auto i = 0; i < items_.size(); i++) {
for (size_t i = 0; i < items_.size(); i++) {
auto &item = items_[i];
if (item.length != length) {
for (auto j = length; j < item.length; j++) {
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/react/renderer/core/RawPropsParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void RawPropsParser::preparse(RawProps const &rawProps) const noexcept {
auto count = names.size(runtime);
auto valueIndex = RawPropsValueIndex{0};

for (auto i = 0; i < count; i++) {
for (size_t i = 0; i < count; i++) {
auto nameValue = names.getValueAtIndex(runtime, i).getString(runtime);
auto value = object.getProperty(runtime, nameValue);

Expand Down
4 changes: 2 additions & 2 deletions ReactCommon/react/renderer/core/ShadowNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void ShadowNode::replaceChild(
*std::const_pointer_cast<ShadowNode::ListOfShared>(children_);
auto size = children.size();

if (suggestedIndex != -1 && suggestedIndex < size) {
if (suggestedIndex != -1 && static_cast<size_t>(suggestedIndex) < size) {
Comment thread
acoates-ms marked this conversation as resolved.
// If provided `suggestedIndex` is accurate,
// replacing in place using the index.
if (children.at(suggestedIndex).get() == &oldChild) {
Expand All @@ -222,7 +222,7 @@ void ShadowNode::replaceChild(
}
}

for (auto index = 0; index < size; index++) {
for (size_t index = 0; index < size; index++) {
if (children.at(index).get() == &oldChild) {
children[index] = newChild;
return;
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/react/renderer/core/propsConversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void fromRawValue(RawValue const &rawValue, std::vector<T> &result) {
auto length = items.size();
result.clear();
result.reserve(length);
for (int i = 0; i < length; i++) {
for (size_t i = 0; i < length; i++) {
T itemResult;
fromRawValue(items.at(i), itemResult);
result.push_back(itemResult);
Expand Down
18 changes: 9 additions & 9 deletions ReactCommon/react/renderer/debug/DebugStringConvertible.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,16 @@ std::string getDebugChildrenDescription(
return "";
}

auto trailing = options.format ? std::string{"\n"} : std::string{""};
auto separator = options.format ? std::string{"\n"} : std::string{""};
auto childrenString = std::string{""};
options.depth++;

for (auto child : getDebugChildren(object, options)) {
childrenString += getDebugDescription(child, options) + trailing;
childrenString += getDebugDescription(child, options) + separator;
}

if (!childrenString.empty() && !trailing.empty()) {
// Removing trailing fragment.
if (!childrenString.empty() && !separator.empty()) {
// Removing separator fragment.
childrenString.erase(childrenString.end() - 1);
}

Expand Down Expand Up @@ -230,16 +230,16 @@ std::string getDebugDescription(
auto childrenString = getDebugChildrenDescription(object, options);
auto propsString = getDebugPropsDescription(object, options);

auto leading =
auto prefix =
options.format ? std::string(options.depth * 2, ' ') : std::string{""};
auto trailing = options.format ? std::string{"\n"} : std::string{""};
auto separator = options.format ? std::string{"\n"} : std::string{""};

return leading + "<" + nameString +
return prefix + "<" + nameString +
(valueString.empty() ? "" : "=" + valueString) +
(propsString.empty() ? "" : " " + propsString) +
(childrenString.empty() ? "/>"
: ">" + trailing + childrenString + trailing +
leading + "</" + nameString + ">");
: ">" + separator + childrenString + separator +
prefix + "</" + nameString + ">");
}

/*
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/react/renderer/graphics/Transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ Transform Transform::Interpolate(
// transform If at any point we hit an "Arbitrary" Transform, return at that
// point
Transform result = Transform::Identity();
for (int i = 0, j = 0;
for (size_t i = 0, j = 0;
i < lhs.operations.size() || j < rhs.operations.size();) {
bool haveLHS = i < lhs.operations.size();
bool haveRHS = j < rhs.operations.size();
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/react/renderer/leakchecker/LeakChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void LeakChecker::stopSurface(SurfaceId surfaceId) {

void LeakChecker::checkSurfaceForLeaks(SurfaceId surfaceId) const {
auto weakFamilies = registry_.weakFamiliesForSurfaceId(surfaceId);
uint numberOfLeaks = 0;
unsigned int numberOfLeaks = 0;
for (auto const &weakFamily : weakFamilies) {
auto strong = weakFamily.lock();
if (strong) {
Expand Down
4 changes: 2 additions & 2 deletions ReactCommon/react/renderer/mounting/Differentiator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ class TinyMap final {
}

better::small_vector<Pair, DefaultSize> vector_;
int numErased_{0};
int erasedAtFront_{0};
size_t numErased_{0};
size_t erasedAtFront_{0};
};

/*
Expand Down
4 changes: 2 additions & 2 deletions ReactCommon/react/renderer/mounting/ShadowTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static void updateMountedFlag(
return;
}

int index;
size_t index;

// Stage 1: Mount and unmount "updated" children.
for (index = 0; index < oldChildren.size() && index < newChildren.size();
Expand All @@ -202,7 +202,7 @@ static void updateMountedFlag(
updateMountedFlag(oldChild->getChildren(), newChild->getChildren());
}

int lastIndexAfterFirstStage = index;
size_t lastIndexAfterFirstStage = index;

// State 2: Mount new children.
for (index = lastIndexAfterFirstStage; index < newChildren.size(); index++) {
Expand Down
9 changes: 5 additions & 4 deletions ReactCommon/react/renderer/mounting/StubViewTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ void StubViewTree::mutate(ShadowViewMutationList const &mutations) {
<< parentStubView->children.size() << " children)";
});
react_native_assert(childStubView->parentTag == NO_VIEW_TAG);
react_native_assert(
parentStubView->children.size() >= mutation.index);
react_native_assert(mutation.index < 0 ||
parentStubView->children.size() >= static_cast<size_t>(mutation.index));
childStubView->parentTag = parentTag;
parentStubView->children.insert(
parentStubView->children.begin() + mutation.index, childStubView);
Expand Down Expand Up @@ -147,7 +147,7 @@ void StubViewTree::mutate(ShadowViewMutationList const &mutations) {
<< parentTag << "] @" << mutation.index << " with "
<< parentStubView->children.size() << " children";
});
react_native_assert(parentStubView->children.size() > mutation.index);
react_native_assert(mutation.index > 0 && parentStubView->children.size() > static_cast<size_t>(mutation.index));
react_native_assert(registry.find(childTag) != registry.end());
auto childStubView = registry[childTag];
if ((ShadowView)(*childStubView) != mutation.oldChildShadowView) {
Expand Down Expand Up @@ -183,7 +183,8 @@ void StubViewTree::mutate(ShadowViewMutationList const &mutations) {
<< ": " << strChildList;
});
react_native_assert(
parentStubView->children.size() > mutation.index &&
mutation.index >= 0 &&
parentStubView->children.size() > static_cast<size_t>(mutation.index) &&
parentStubView->children[mutation.index]->tag ==
childStubView->tag);
childStubView->parentTag = NO_VIEW_TAG;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bool TelemetryController::pullTransaction(
auto surfaceId = transaction.getSurfaceId();
auto number = transaction.getNumber();
auto telemetry = transaction.getTelemetry();
auto numberOfMutations = transaction.getMutations().size();
auto numberOfMutations = static_cast<int>(transaction.getMutations().size());

mutex_.lock();
auto compoundTelemetry = compoundTelemetry_;
Expand Down
4 changes: 2 additions & 2 deletions ReactCommon/react/renderer/mounting/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ static void calculateShadowViewMutationsForNewTree(
// Sorting pairs based on `orderIndex` if needed.
reorderInPlaceIfNeeded(newChildPairs);

for (auto index = 0; index < newChildPairs.size(); index++) {
for (size_t index = 0; index < newChildPairs.size(); index++) {
auto const &newChildPair = newChildPairs[index];

mutations.push_back(
ShadowViewMutation::CreateMutation(newChildPair.shadowView));
mutations.push_back(ShadowViewMutation::InsertMutation(
parentShadowView, newChildPair.shadowView, index));
parentShadowView, newChildPair.shadowView, static_cast<int>(index)));

auto newGrandChildPairs =
sliceChildShadowNodeViewPairsLegacy(*newChildPair.shadowNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ SharedShadowNode UITemplateProcessor::runCommand(
const int tagOffset = 420000;
// TODO: change to integer codes and a switch statement
if (opcode == "createNode") {
int tag = command[1].asInt();
Tag tag = static_cast<Tag>(command[1].asInt());
const auto &type = command[2].asString();
const auto parentTag = command[3].asInt();
const auto &props = command[4];
nodes[tag] = componentDescriptorRegistry.createNode(
tag + tagOffset, type, surfaceId, props, nullptr);
if (parentTag > -1) { // parentTag == -1 indicates root node
auto parentShadowNode = nodes[parentTag];
auto parentShadowNode = nodes[static_cast<size_t>(parentTag)];
auto const &componentDescriptor = componentDescriptorRegistry.at(
parentShadowNode->getComponentHandle());
componentDescriptor.appendChild(parentShadowNode, nodes[tag]);
Expand All @@ -61,13 +61,13 @@ SharedShadowNode UITemplateProcessor::runCommand(
LOG(INFO)
<< "(stop) UITemplateProcessor inject serialized 'server rendered' view tree";
}
return nodes[command[1].asInt()];
return nodes[static_cast<Tag>(command[1].asInt())];
} else if (opcode == "loadNativeBool") {
int registerNumber = command[1].asInt();
auto registerNumber = static_cast<size_t>(command[1].asInt());
std::string param = command[4][0].asString();
registers[registerNumber] = reactNativeConfig->getBool(param);
} else if (opcode == "conditional") {
int registerNumber = command[1].asInt();
auto registerNumber = static_cast<size_t>(command[1].asInt());
Comment thread
acoates-ms marked this conversation as resolved.
auto conditionDynamic = registers[registerNumber];
if (conditionDynamic.isNull()) {
// TODO: provide original command or command line?
Expand Down