Remove C++ form of YGNodeSetChildren (#37013)

Summary:
X-link: https://github.com/facebook/react-native/pull/37013

Pull Request resolved: https://github.com/facebook/yoga/pull/1254

Brings Yoga public interface back to a nice pure C ABI.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D45138827

fbshipit-source-id: 8df7e4fd03afcda9a714d193b0430c122a7a7574
This commit is contained in:
Nick Gerleman
2023-04-21 15:36:17 -07:00
committed by Facebook GitHub Bot
parent 7afddfd204
commit 85ff2f06c2
3 changed files with 29 additions and 46 deletions

View File

@@ -379,13 +379,16 @@ YOGA_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef owner) {
owner->markDirtyAndPropagate();
}
static void YGNodeSetChildrenInternal(
YGNodeRef const owner,
const std::vector<YGNodeRef>& children) {
YOGA_EXPORT void YGNodeSetChildren(
const YGNodeRef owner,
const YGNodeRef* children,
const uint32_t count) {
if (!owner) {
return;
}
if (children.size() == 0) {
const YGVector childrenVector = {children, children + count};
if (childrenVector.size() == 0) {
if (YGNodeGetChildCount(owner) > 0) {
for (YGNodeRef const child : owner->getChildren()) {
child->setLayout(YGLayout());
@@ -399,35 +402,21 @@ static void YGNodeSetChildrenInternal(
for (YGNodeRef const oldChild : owner->getChildren()) {
// Our new children may have nodes in common with the old children. We
// don't reset these common nodes.
if (std::find(children.begin(), children.end(), oldChild) ==
children.end()) {
if (std::find(childrenVector.begin(), childrenVector.end(), oldChild) ==
childrenVector.end()) {
oldChild->setLayout(YGLayout());
oldChild->setOwner(nullptr);
}
}
}
owner->setChildren(children);
for (YGNodeRef child : children) {
owner->setChildren(childrenVector);
for (YGNodeRef child : childrenVector) {
child->setOwner(owner);
}
owner->markDirtyAndPropagate();
}
}
YOGA_EXPORT void YGNodeSetChildren(
const YGNodeRef owner,
const YGNodeRef c[],
const uint32_t count) {
const YGVector children = {c, c + count};
YGNodeSetChildrenInternal(owner, children);
}
YOGA_EXPORT void YGNodeSetChildren(
YGNodeRef const owner,
const std::vector<YGNodeRef>& children) {
YGNodeSetChildrenInternal(owner, children);
}
YOGA_EXPORT YGNodeRef
YGNodeGetChild(const YGNodeRef node, const uint32_t index) {
if (index < node->getChildren().size()) {