vector instead of YGNodeList

Reviewed By: jonathandann, emilsjolander

Differential Revision: D6442379

fbshipit-source-id: d2d48ef0676351d2eeaa2d427dcd72e082cd15a1
This commit is contained in:
Pritesh Nandgaonkar 2017-12-05 08:16:49 -08:00 committed by Facebook Github Bot
parent 7c7108a1e8
commit b08a912f11
8 changed files with 54 additions and 231 deletions

View File

@ -50,7 +50,6 @@
131B6AF51AF1093D00FFC3E0 /* RCTSegmentedControlManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 131B6AF31AF1093D00FFC3E0 /* RCTSegmentedControlManager.m */; };
133957881DF76D3500EC27BE /* YGEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77031DF767AF001F9587 /* YGEnums.h */; };
133957891DF76D3500EC27BE /* YGMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77041DF767AF001F9587 /* YGMacros.h */; };
1339578A1DF76D3500EC27BE /* YGNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77061DF767AF001F9587 /* YGNodeList.h */; };
1339578B1DF76D3500EC27BE /* Yoga.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77081DF767AF001F9587 /* Yoga.h */; };
133CAE8E1B8E5CFD00F6AD92 /* RCTDatePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 133CAE8D1B8E5CFD00F6AD92 /* RCTDatePicker.m */; };
13456E931ADAD2DE009F94A7 /* RCTConvert+CoreLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = 13456E921ADAD2DE009F94A7 /* RCTConvert+CoreLocation.m */; };
@ -962,8 +961,6 @@
3DC159E41E83E1AE007B1282 /* RCTRootContentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 59A7B9FC1E577DBF0068EDBF /* RCTRootContentView.m */; };
3DC159E51E83E1E9007B1282 /* JSBigString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27B958731E57587D0096647A /* JSBigString.cpp */; };
3DC159E61E83E1FA007B1282 /* JSBigString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27B958731E57587D0096647A /* JSBigString.cpp */; };
3DCC92B91E94456500EF89A8 /* YGNodeList.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77061DF767AF001F9587 /* YGNodeList.h */; };
3DCC92BE1E9445B100EF89A8 /* YGNodeList.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77061DF767AF001F9587 /* YGNodeList.h */; };
3DCD185D1DF978E7007FE5A1 /* RCTReloadCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = A2440AA11DF8D854006E7BFC /* RCTReloadCommand.m */; };
3DDEC1521DDCE0CA0020BBDF /* RCTJSCSamplingProfiler.m in Sources */ = {isa = PBXBuildFile; fileRef = 369123E01DDC75850095B341 /* RCTJSCSamplingProfiler.m */; };
3DE4F8681DF85D8E00B9E5A0 /* YGEnums.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77031DF767AF001F9587 /* YGEnums.h */; };
@ -975,7 +972,6 @@
3DF1BE851F26577300068F1A /* JSCTracing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3DF1BE801F26576400068F1A /* JSCTracing.cpp */; };
3DFE0D161DF8574D00459392 /* YGEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77031DF767AF001F9587 /* YGEnums.h */; };
3DFE0D171DF8574D00459392 /* YGMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77041DF767AF001F9587 /* YGMacros.h */; };
3DFE0D181DF8574D00459392 /* YGNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77061DF767AF001F9587 /* YGNodeList.h */; };
3DFE0D191DF8574D00459392 /* Yoga.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77081DF767AF001F9587 /* Yoga.h */; };
3DFE0D1A1DF8575800459392 /* YGEnums.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77031DF767AF001F9587 /* YGEnums.h */; };
3DFE0D1B1DF8575800459392 /* YGMacros.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77041DF767AF001F9587 /* YGMacros.h */; };
@ -988,8 +984,6 @@
53D123971FBF1DF5001B8A10 /* libyoga.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D3C059A1DE3340900C268FA /* libyoga.a */; };
53D1239A1FBF1EF2001B8A10 /* YGEnums.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1861FB4FE80002CBB31 /* YGEnums.cpp */; };
53D1239B1FBF1EF4001B8A10 /* YGEnums.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1861FB4FE80002CBB31 /* YGEnums.cpp */; };
53D1239C1FBF1EF7001B8A10 /* YGNodeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1881FB4FE80002CBB31 /* YGNodeList.cpp */; };
53D1239D1FBF1EF7001B8A10 /* YGNodeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1881FB4FE80002CBB31 /* YGNodeList.cpp */; };
53D1239E1FBF1EFB001B8A10 /* Yoga-internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 53CBF1851FB4FE80002CBB31 /* Yoga-internal.h */; };
53D1239F1FBF1EFB001B8A10 /* Yoga-internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 53CBF1851FB4FE80002CBB31 /* Yoga-internal.h */; };
53D123A01FBF1EFF001B8A10 /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1871FB4FE80002CBB31 /* Yoga.cpp */; };
@ -1477,7 +1471,6 @@
dstPath = include/yoga;
dstSubfolderSpec = 16;
files = (
3DCC92BE1E9445B100EF89A8 /* YGNodeList.h in Copy Headers */,
3DFE0D1A1DF8575800459392 /* YGEnums.h in Copy Headers */,
3DFE0D1B1DF8575800459392 /* YGMacros.h in Copy Headers */,
3DFE0D1C1DF8575800459392 /* Yoga.h in Copy Headers */,
@ -1703,7 +1696,6 @@
dstPath = include/yoga;
dstSubfolderSpec = 16;
files = (
3DCC92B91E94456500EF89A8 /* YGNodeList.h in Copy Headers */,
3DE4F8681DF85D8E00B9E5A0 /* YGEnums.h in Copy Headers */,
3DE4F8691DF85D8E00B9E5A0 /* YGMacros.h in Copy Headers */,
3DE4F86A1DF85D8E00B9E5A0 /* Yoga.h in Copy Headers */,
@ -1828,7 +1820,6 @@
130443D71E401AD800D93A67 /* RCTTVView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTVView.m; sourceTree = "<group>"; };
130A77031DF767AF001F9587 /* YGEnums.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGEnums.h; sourceTree = "<group>"; };
130A77041DF767AF001F9587 /* YGMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGMacros.h; sourceTree = "<group>"; };
130A77061DF767AF001F9587 /* YGNodeList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGNodeList.h; sourceTree = "<group>"; };
130A77081DF767AF001F9587 /* Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Yoga.h; sourceTree = "<group>"; };
130E3D861E6A082100ACE484 /* RCTDevSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDevSettings.h; sourceTree = "<group>"; };
130E3D871E6A082100ACE484 /* RCTDevSettings.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RCTDevSettings.mm; sourceTree = "<group>"; };
@ -2140,7 +2131,6 @@
53CBF1851FB4FE80002CBB31 /* Yoga-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Yoga-internal.h"; sourceTree = "<group>"; };
53CBF1861FB4FE80002CBB31 /* YGEnums.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGEnums.cpp; sourceTree = "<group>"; };
53CBF1871FB4FE80002CBB31 /* Yoga.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Yoga.cpp; sourceTree = "<group>"; };
53CBF1881FB4FE80002CBB31 /* YGNodeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGNodeList.cpp; sourceTree = "<group>"; };
53D123831FBF1D49001B8A10 /* libyoga.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libyoga.a; path = "../../../../../../../../../Library/Developer/Xcode/DerivedData/yoga-hdfifpwsinitsibujacpiefkjfdy/Build/Products/Debug/libyoga.a"; sourceTree = "<group>"; };
58114A121AAE854800E7D092 /* RCTPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPicker.h; sourceTree = "<group>"; };
58114A131AAE854800E7D092 /* RCTPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTPicker.m; sourceTree = "<group>"; };
@ -2310,12 +2300,10 @@
5376C5E11FC6DDB20083513D /* YGNodePrint.cpp */,
5376C5E01FC6DDB20083513D /* YGNodePrint.h */,
53CBF1861FB4FE80002CBB31 /* YGEnums.cpp */,
53CBF1881FB4FE80002CBB31 /* YGNodeList.cpp */,
53CBF1851FB4FE80002CBB31 /* Yoga-internal.h */,
53CBF1871FB4FE80002CBB31 /* Yoga.cpp */,
130A77031DF767AF001F9587 /* YGEnums.h */,
130A77041DF767AF001F9587 /* YGMacros.h */,
130A77061DF767AF001F9587 /* YGNodeList.h */,
130A77081DF767AF001F9587 /* Yoga.h */,
);
name = yoga;
@ -3217,7 +3205,6 @@
53D1239F1FBF1EFB001B8A10 /* Yoga-internal.h in Headers */,
3DFE0D161DF8574D00459392 /* YGEnums.h in Headers */,
3DFE0D171DF8574D00459392 /* YGMacros.h in Headers */,
3DFE0D181DF8574D00459392 /* YGNodeList.h in Headers */,
5376C5E71FC6DDC20083513D /* YGNodePrint.h in Headers */,
3DFE0D191DF8574D00459392 /* Yoga.h in Headers */,
);
@ -3295,7 +3282,6 @@
53D1239E1FBF1EFB001B8A10 /* Yoga-internal.h in Headers */,
133957881DF76D3500EC27BE /* YGEnums.h in Headers */,
1339578B1DF76D3500EC27BE /* Yoga.h in Headers */,
1339578A1DF76D3500EC27BE /* YGNodeList.h in Headers */,
5376C5E61FC6DDC10083513D /* YGNodePrint.h in Headers */,
133957891DF76D3500EC27BE /* YGMacros.h in Headers */,
);
@ -4228,7 +4214,6 @@
files = (
53D123A01FBF1EFF001B8A10 /* Yoga.cpp in Sources */,
53D1239A1FBF1EF2001B8A10 /* YGEnums.cpp in Sources */,
53D1239C1FBF1EF7001B8A10 /* YGNodeList.cpp in Sources */,
5376C5E41FC6DDBC0083513D /* YGNodePrint.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -4239,7 +4224,6 @@
files = (
53D123A11FBF1EFF001B8A10 /* Yoga.cpp in Sources */,
53D1239B1FBF1EF4001B8A10 /* YGEnums.cpp in Sources */,
53D1239D1FBF1EF7001B8A10 /* YGNodeList.cpp in Sources */,
5376C5E51FC6DDBD0083513D /* YGNodePrint.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;

View File

@ -15,7 +15,6 @@
131B6AF51AF1093D00FFC3E0 /* RCTSegmentedControlManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 131B6AF31AF1093D00FFC3E0 /* RCTSegmentedControlManager.m */; };
133957881DF76D3500EC27BE /* YGEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77031DF767AF001F9587 /* YGEnums.h */; };
133957891DF76D3500EC27BE /* YGMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77041DF767AF001F9587 /* YGMacros.h */; };
1339578A1DF76D3500EC27BE /* YGNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77061DF767AF001F9587 /* YGNodeList.h */; };
1339578B1DF76D3500EC27BE /* Yoga.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77081DF767AF001F9587 /* Yoga.h */; };
133CAE8E1B8E5CFD00F6AD92 /* RCTDatePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 133CAE8D1B8E5CFD00F6AD92 /* RCTDatePicker.m */; };
13456E931ADAD2DE009F94A7 /* RCTConvert+CoreLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = 13456E921ADAD2DE009F94A7 /* RCTConvert+CoreLocation.m */; };
@ -673,7 +672,6 @@
3DE4F86A1DF85D8E00B9E5A0 /* Yoga.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77081DF767AF001F9587 /* Yoga.h */; };
3DFE0D161DF8574D00459392 /* YGEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77031DF767AF001F9587 /* YGEnums.h */; };
3DFE0D171DF8574D00459392 /* YGMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77041DF767AF001F9587 /* YGMacros.h */; };
3DFE0D181DF8574D00459392 /* YGNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77061DF767AF001F9587 /* YGNodeList.h */; };
3DFE0D191DF8574D00459392 /* Yoga.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77081DF767AF001F9587 /* Yoga.h */; };
3DFE0D1A1DF8575800459392 /* YGEnums.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77031DF767AF001F9587 /* YGEnums.h */; };
3DFE0D1B1DF8575800459392 /* YGMacros.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77041DF767AF001F9587 /* YGMacros.h */; };
@ -686,7 +684,6 @@
53CBF1BF1FB50263002CBB31 /* Yoga-internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 53CBF1BB1FB50262002CBB31 /* Yoga-internal.h */; };
53CBF1C01FB50263002CBB31 /* YGEnums.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1BC1FB50263002CBB31 /* YGEnums.cpp */; };
53CBF1C11FB50263002CBB31 /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1BD1FB50263002CBB31 /* Yoga.cpp */; };
53CBF1C21FB50263002CBB31 /* YGNodeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1BE1FB50263002CBB31 /* YGNodeList.cpp */; };
58114A161AAE854800E7D092 /* RCTPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 58114A131AAE854800E7D092 /* RCTPicker.m */; };
58114A171AAE854800E7D092 /* RCTPickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 58114A151AAE854800E7D092 /* RCTPickerManager.m */; };
58114A501AAE93D500E7D092 /* RCTAsyncLocalStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 58114A4E1AAE93D500E7D092 /* RCTAsyncLocalStorage.m */; };
@ -1170,7 +1167,6 @@
008341F51D1DB34400876D9A /* RCTJSStackFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTJSStackFrame.h; sourceTree = "<group>"; };
130A77031DF767AF001F9587 /* YGEnums.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGEnums.h; sourceTree = "<group>"; };
130A77041DF767AF001F9587 /* YGMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGMacros.h; sourceTree = "<group>"; };
130A77061DF767AF001F9587 /* YGNodeList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGNodeList.h; sourceTree = "<group>"; };
130A77081DF767AF001F9587 /* Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Yoga.h; sourceTree = "<group>"; };
131B6AF01AF1093D00FFC3E0 /* RCTSegmentedControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTSegmentedControl.h; sourceTree = "<group>"; };
131B6AF11AF1093D00FFC3E0 /* RCTSegmentedControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSegmentedControl.m; sourceTree = "<group>"; };
@ -1356,7 +1352,6 @@
53CBF1BB1FB50262002CBB31 /* Yoga-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Yoga-internal.h"; sourceTree = "<group>"; };
53CBF1BC1FB50263002CBB31 /* YGEnums.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGEnums.cpp; sourceTree = "<group>"; };
53CBF1BD1FB50263002CBB31 /* Yoga.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Yoga.cpp; sourceTree = "<group>"; };
53CBF1BE1FB50263002CBB31 /* YGNodeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGNodeList.cpp; sourceTree = "<group>"; };
58114A121AAE854800E7D092 /* RCTPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPicker.h; sourceTree = "<group>"; };
58114A131AAE854800E7D092 /* RCTPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTPicker.m; sourceTree = "<group>"; };
58114A141AAE854800E7D092 /* RCTPickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPickerManager.h; sourceTree = "<group>"; };
@ -1473,12 +1468,10 @@
53330EE41FC6EE70008D7FA9 /* YGNodePrint.cpp */,
53330EE31FC6EE70008D7FA9 /* YGNodePrint.h */,
53CBF1BC1FB50263002CBB31 /* YGEnums.cpp */,
53CBF1BE1FB50263002CBB31 /* YGNodeList.cpp */,
53CBF1BB1FB50262002CBB31 /* Yoga-internal.h */,
53CBF1BD1FB50263002CBB31 /* Yoga.cpp */,
130A77031DF767AF001F9587 /* YGEnums.h */,
130A77041DF767AF001F9587 /* YGMacros.h */,
130A77061DF767AF001F9587 /* YGNodeList.h */,
130A77081DF767AF001F9587 /* Yoga.h */,
);
name = yoga;
@ -2054,7 +2047,6 @@
files = (
3DFE0D161DF8574D00459392 /* YGEnums.h in Headers */,
3DFE0D171DF8574D00459392 /* YGMacros.h in Headers */,
3DFE0D181DF8574D00459392 /* YGNodeList.h in Headers */,
3DFE0D191DF8574D00459392 /* Yoga.h in Headers */,
53330EEB1FC6EE7F008D7FA9 /* YGNodePrint.h in Headers */,
);
@ -2084,7 +2076,6 @@
files = (
133957881DF76D3500EC27BE /* YGEnums.h in Headers */,
1339578B1DF76D3500EC27BE /* Yoga.h in Headers */,
1339578A1DF76D3500EC27BE /* YGNodeList.h in Headers */,
133957891DF76D3500EC27BE /* YGMacros.h in Headers */,
53330EEA1FC6EE7F008D7FA9 /* YGNodePrint.h in Headers */,
);
@ -2760,7 +2751,6 @@
191E3EC11C29DC3800C180A6 /* RCTRefreshControl.m in Sources */,
13C156051AB1A2840079392D /* RCTWebView.m in Sources */,
83CBBA601A601EAA00E9B192 /* RCTBridge.m in Sources */,
53CBF1C21FB50263002CBB31 /* YGNodeList.cpp in Sources */,
13C156061AB1A2840079392D /* RCTWebViewManager.m in Sources */,
58114A161AAE854800E7D092 /* RCTPicker.m in Sources */,
137327E81AA5CF210034F82E /* RCTTabBarItem.m in Sources */,

View File

@ -7,7 +7,6 @@ LOCAL_MODULE := yogacore
LOCAL_SRC_FILES := \
yoga/Yoga.cpp \
yoga/YGEnums.cpp \
yoga/YGNodeList.cpp \
yoga/YGNodePrint.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)

View File

@ -1,129 +0,0 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <string.h>
#include "YGNodeList.h"
struct YGNodeList {
uint32_t capacity;
uint32_t count;
YGNodeRef *items;
};
YGNodeListRef YGNodeListNew(const uint32_t initialCapacity) {
const YGNodeListRef list =
(const YGNodeListRef)malloc(sizeof(struct YGNodeList));
YGAssert(list != nullptr, "Could not allocate memory for list");
list->capacity = initialCapacity;
list->count = 0;
list->items = (YGNodeRef*)malloc(sizeof(YGNodeRef) * list->capacity);
YGAssert(list->items != nullptr, "Could not allocate memory for items");
return list;
}
void YGNodeListFree(const YGNodeListRef list) {
if (list) {
free(list->items);
free(list);
}
}
uint32_t YGNodeListCount(const YGNodeListRef list) {
if (list) {
return list->count;
}
return 0;
}
void YGNodeListAdd(YGNodeListRef *listp, const YGNodeRef node) {
if (!*listp) {
*listp = YGNodeListNew(4);
}
YGNodeListInsert(listp, node, (*listp)->count);
}
void YGNodeListInsert(YGNodeListRef *listp, const YGNodeRef node, const uint32_t index) {
if (!*listp) {
*listp = YGNodeListNew(4);
}
YGNodeListRef list = *listp;
if (list->count == list->capacity) {
list->capacity *= 2;
list->items =
(YGNodeRef*)realloc(list->items, sizeof(YGNodeRef) * list->capacity);
YGAssert(list->items != nullptr, "Could not extend allocation for items");
}
for (uint32_t i = list->count; i > index; i--) {
list->items[i] = list->items[i - 1];
}
list->count++;
list->items[index] = node;
}
void YGNodeListReplace(YGNodeListRef list, const uint32_t index, const YGNodeRef newNode) {
list->items[index] = newNode;
}
void YGNodeListRemoveAll(const YGNodeListRef list) {
for (uint32_t i = 0; i < list->count; i++) {
list->items[i] = nullptr;
}
list->count = 0;
}
YGNodeRef YGNodeListRemove(const YGNodeListRef list, const uint32_t index) {
const YGNodeRef removed = list->items[index];
list->items[index] = nullptr;
for (uint32_t i = index; i < list->count - 1; i++) {
list->items[i] = list->items[i + 1];
list->items[i + 1] = nullptr;
}
list->count--;
return removed;
}
YGNodeRef YGNodeListDelete(const YGNodeListRef list, const YGNodeRef node) {
for (uint32_t i = 0; i < list->count; i++) {
if (list->items[i] == node) {
return YGNodeListRemove(list, i);
}
}
return nullptr;
}
YGNodeRef YGNodeListGet(const YGNodeListRef list, const uint32_t index) {
if (YGNodeListCount(list) > 0) {
return list->items[index];
}
return nullptr;
}
YGNodeListRef YGNodeListClone(const YGNodeListRef oldList) {
if (!oldList) {
return nullptr;
}
const uint32_t count = oldList->count;
if (count == 0) {
return nullptr;
}
const YGNodeListRef newList = YGNodeListNew(count);
memcpy(newList->items, oldList->items, sizeof(YGNodeRef) * count);
newList->count = count;
return newList;
}

View File

@ -1,36 +0,0 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#pragma once
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "YGMacros.h"
#include "Yoga.h"
YG_EXTERN_C_BEGIN
typedef struct YGNodeList *YGNodeListRef;
YGNodeListRef YGNodeListNew(const uint32_t initialCapacity);
void YGNodeListFree(const YGNodeListRef list);
uint32_t YGNodeListCount(const YGNodeListRef list);
void YGNodeListAdd(YGNodeListRef *listp, const YGNodeRef node);
void YGNodeListInsert(YGNodeListRef *listp, const YGNodeRef node, const uint32_t index);
void YGNodeListReplace(const YGNodeListRef list, const uint32_t index, const YGNodeRef newNode);
void YGNodeListRemoveAll(const YGNodeListRef list);
YGNodeRef YGNodeListRemove(const YGNodeListRef list, const uint32_t index);
YGNodeRef YGNodeListDelete(const YGNodeListRef list, const YGNodeRef node);
YGNodeRef YGNodeListGet(const YGNodeListRef list, const uint32_t index);
YGNodeListRef YGNodeListClone(YGNodeListRef list);
YG_EXTERN_C_END

View File

@ -205,7 +205,7 @@ void YGNodeToString(
}
appendFormatedString(str, ">");
const uint32_t childCount = YGNodeListCount(node->children);
const uint32_t childCount = node->children.size();
if (options & YGPrintOptionsChildren && childCount > 0) {
for (uint32_t i = 0; i < childCount; i++) {
appendFormatedString(str, "\n");

View File

@ -8,9 +8,12 @@
*/
#pragma once
#include "YGNodeList.h"
#include <vector>
#include "Yoga.h"
using YGVector = std::vector<YGNodeRef>;
YG_EXTERN_C_BEGIN
WIN_EXPORT float YGRoundValueToPixelGrid(const float value,
@ -101,7 +104,7 @@ typedef struct YGNode {
uint32_t lineIndex;
YGNodeRef parent;
YGNodeListRef children;
YGVector children;
struct YGNode* nextChild;
@ -205,7 +208,7 @@ static const YGNode gYGNodeDefaults = {
.layout = gYGNodeLayoutDefaults,
.lineIndex = 0,
.parent = nullptr,
.children = nullptr,
.children = YGVector(),
.nextChild = nullptr,
.measure = nullptr,
.baseline = nullptr,

View File

@ -7,12 +7,11 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include "Yoga.h"
#include <string.h>
#include "YGNodeList.h"
#include <algorithm>
#include "YGNodePrint.h"
#include "Yoga-internal.h"
#include "Yoga.h"
#ifdef _MSC_VER
#include <float.h>
@ -66,6 +65,16 @@ static void YGNodeMarkDirtyInternal(const YGNodeRef node);
static YGValue YGValueZero = {.value = 0, .unit = YGUnitPoint};
static bool YGNodeListDelete(YGVector& list, const YGNodeRef node) {
std::vector<YGNodeRef>::iterator p =
std::find(list.begin(), list.end(), node);
if (p != list.end()) {
list.erase(p);
return true;
}
return false;
}
#ifdef ANDROID
#include <android/log.h>
static int YGAndroidLog(const YGConfigRef config,
@ -195,14 +204,11 @@ YGNodeRef YGNodeNew(void) {
return YGNodeNewWithConfig(&gYGConfigDefaults);
}
YGNodeRef YGNodeClone(const YGNodeRef oldNode) {
const YGNodeRef node = (const YGNodeRef)malloc(sizeof(YGNode));
YGNodeRef YGNodeClone(YGNodeRef oldNode) {
YGNodeRef node = new YGNode(*oldNode);
YGAssertWithConfig(
oldNode->config, node != nullptr, "Could not allocate memory for node");
gNodeInstanceCount++;
memcpy(node, oldNode, sizeof(YGNode));
node->children = YGNodeListClone(oldNode->children);
node->parent = nullptr;
return node;
}
@ -219,7 +225,8 @@ void YGNodeFree(const YGNodeRef node) {
child->parent = nullptr;
}
YGNodeListFree(node->children);
node->children.clear();
node->children.shrink_to_fit();
free(node);
gNodeInstanceCount--;
}
@ -246,7 +253,8 @@ void YGNodeReset(const YGNodeRef node) {
node->parent == nullptr,
"Cannot reset a node still attached to a parent");
YGNodeListFree(node->children);
node->children.clear();
node->children.shrink_to_fit();
const YGConfigRef config = node->config;
memcpy(node, &gYGNodeDefaults, sizeof(YGNode));
@ -333,6 +341,7 @@ static void YGCloneChildrenIfNeeded(const YGNodeRef parent) {
// This is an empty set. Nothing to clone.
return;
}
const YGNodeRef firstChild = YGNodeGetChild(parent, 0);
if (firstChild->parent == parent) {
// If the first child has this node as its parent, we assume that it is already unique.
@ -341,12 +350,12 @@ static void YGCloneChildrenIfNeeded(const YGNodeRef parent) {
// We also assume that all its sibling are cloned as well.
return;
}
const YGNodeClonedFunc cloneNodeCallback = parent->config->cloneNodeCallback;
const YGNodeListRef children = parent->children;
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef oldChild = YGNodeListGet(children, i);
const YGNodeRef oldChild = parent->children[i];
const YGNodeRef newChild = YGNodeClone(oldChild);
YGNodeListReplace(children, i, newChild);
parent->children[i] = newChild;
newChild->parent = parent;
if (cloneNodeCallback) {
cloneNodeCallback(oldChild, newChild, parent, i);
@ -365,8 +374,7 @@ void YGNodeInsertChild(const YGNodeRef node, const YGNodeRef child, const uint32
"Cannot add child: Nodes with measure functions cannot have children.");
YGCloneChildrenIfNeeded(node);
YGNodeListInsert(&node->children, child, index);
node->children.insert(node->children.begin() + index, child);
child->parent = node;
YGNodeMarkDirtyInternal(node);
}
@ -374,6 +382,7 @@ void YGNodeInsertChild(const YGNodeRef node, const YGNodeRef child, const uint32
void YGNodeRemoveChild(const YGNodeRef parent, const YGNodeRef excludedChild) {
// This algorithm is a forked variant from YGCloneChildrenIfNeeded that excludes a child.
const uint32_t childCount = YGNodeGetChildCount(parent);
if (childCount == 0) {
// This is an empty set. Nothing to remove.
return;
@ -382,7 +391,7 @@ void YGNodeRemoveChild(const YGNodeRef parent, const YGNodeRef excludedChild) {
if (firstChild->parent == parent) {
// If the first child has this node as its parent, we assume that it is already unique.
// We can now try to delete a child in this list.
if (YGNodeListDelete(parent->children, excludedChild) != nullptr) {
if (YGNodeListDelete(parent->children, excludedChild)) {
excludedChild->layout = gYGNodeDefaults.layout; // layout is no longer valid
excludedChild->parent = nullptr;
YGNodeMarkDirtyInternal(parent);
@ -393,10 +402,9 @@ void YGNodeRemoveChild(const YGNodeRef parent, const YGNodeRef excludedChild) {
// We don't want to simply clone all children, because then the host will need to free
// the clone of the child that was just deleted.
const YGNodeClonedFunc cloneNodeCallback = parent->config->cloneNodeCallback;
const YGNodeListRef children = parent->children;
uint32_t nextInsertIndex = 0;
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef oldChild = YGNodeListGet(children, i);
const YGNodeRef oldChild = parent->children[i];
if (excludedChild == oldChild) {
// Ignore the deleted child. Don't reset its layout or parent since it is still valid
// in the other parent. However, since this parent has now changed, we need to mark it
@ -405,7 +413,7 @@ void YGNodeRemoveChild(const YGNodeRef parent, const YGNodeRef excludedChild) {
continue;
}
const YGNodeRef newChild = YGNodeClone(oldChild);
YGNodeListReplace(children, nextInsertIndex, newChild);
parent->children[nextInsertIndex] = newChild;
newChild->parent = parent;
if (cloneNodeCallback) {
cloneNodeCallback(oldChild, newChild, parent, nextInsertIndex);
@ -413,7 +421,7 @@ void YGNodeRemoveChild(const YGNodeRef parent, const YGNodeRef excludedChild) {
nextInsertIndex++;
}
while (nextInsertIndex < childCount) {
YGNodeListRemove(children, nextInsertIndex);
parent->children.erase(parent->children.begin() + nextInsertIndex);
nextInsertIndex++;
}
}
@ -432,17 +440,21 @@ void YGNodeRemoveAllChildren(const YGNodeRef parent) {
oldChild->layout = gYGNodeDefaults.layout; // layout is no longer valid
oldChild->parent = nullptr;
}
YGNodeListRemoveAll(parent->children);
parent->children.clear();
parent->children.shrink_to_fit();
YGNodeMarkDirtyInternal(parent);
return;
}
// Otherwise, we are not the owner of the child set. We don't have to do anything to clear it.
parent->children = nullptr;
parent->children = YGVector();
YGNodeMarkDirtyInternal(parent);
}
YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index) {
return YGNodeListGet(node->children, index);
if (index < node->children.size()) {
return node->children[index];
}
return nullptr;
}
YGNodeRef YGNodeGetParent(const YGNodeRef node) {
@ -450,7 +462,7 @@ YGNodeRef YGNodeGetParent(const YGNodeRef node) {
}
uint32_t YGNodeGetChildCount(const YGNodeRef node) {
return YGNodeListCount(node->children);
return node->children.size();
}
void YGNodeMarkDirty(const YGNodeRef node) {
@ -1687,7 +1699,7 @@ static void YGZeroOutLayoutRecursivly(const YGNodeRef node) {
YGCloneChildrenIfNeeded(node);
const uint32_t childCount = YGNodeGetChildCount(node);
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = YGNodeListGet(node->children, i);
const YGNodeRef child = node->children[i];
YGZeroOutLayoutRecursivly(child);
}
}
@ -1834,7 +1846,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
return;
}
const uint32_t childCount = YGNodeListCount(node->children);
const uint32_t childCount = node->children.size();
if (childCount == 0) {
YGNodeEmptyContainerSetMeasuredDimensions(node,
availableWidth,
@ -1954,7 +1966,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
// STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = YGNodeListGet(node->children, i);
const YGNodeRef child = node->children[i];
if (child->style.display == YGDisplayNone) {
YGZeroOutLayoutRecursivly(child);
child->hasNewLayout = true;
@ -2053,7 +2065,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
// Add items to the current line until it's full or we run out of items.
for (uint32_t i = startOfLineIndex; i < childCount; i++, endOfLineIndex++) {
const YGNodeRef child = YGNodeListGet(node->children, i);
const YGNodeRef child = node->children[i];
if (child->style.display == YGDisplayNone) {
continue;
}
@ -2431,7 +2443,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
int numberOfAutoMarginsOnCurrentLine = 0;
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) {
const YGNodeRef child = YGNodeListGet(node->children, i);
const YGNodeRef child = node->children[i];
if (child->style.positionType == YGPositionTypeRelative) {
if (YGMarginLeadingValue(child, mainAxis)->unit == YGUnitAuto) {
numberOfAutoMarginsOnCurrentLine++;
@ -2476,7 +2488,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
float crossDim = 0;
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) {
const YGNodeRef child = YGNodeListGet(node->children, i);
const YGNodeRef child = node->children[i];
if (child->style.display == YGDisplayNone) {
continue;
}
@ -2561,7 +2573,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
// We can skip child alignment if we're just measuring the container.
if (performLayout) {
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) {
const YGNodeRef child = YGNodeListGet(node->children, i);
const YGNodeRef child = node->children[i];
if (child->style.display == YGDisplayNone) {
continue;
}
@ -2726,7 +2738,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
float maxAscentForCurrentLine = 0;
float maxDescentForCurrentLine = 0;
for (ii = startIndex; ii < childCount; ii++) {
const YGNodeRef child = YGNodeListGet(node->children, ii);
const YGNodeRef child = node->children[ii];
if (child->style.display == YGDisplayNone) {
continue;
}
@ -2757,7 +2769,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
if (performLayout) {
for (ii = startIndex; ii < endIndex; ii++) {
const YGNodeRef child = YGNodeListGet(node->children, ii);
const YGNodeRef child = node->children[ii];
if (child->style.display == YGDisplayNone) {
continue;
}
@ -2914,7 +2926,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
// Set trailing position if necessary.
if (needsMainTrailingPos || needsCrossTrailingPos) {
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = YGNodeListGet(node->children, i);
const YGNodeRef child = node->children[i];
if (child->style.display == YGDisplayNone) {
continue;
}
@ -3359,7 +3371,7 @@ static void YGRoundToPixelGrid(const YGNodeRef node,
(textRounding && !hasFractionalHeight)) -
YGRoundValueToPixelGrid(absoluteNodeTop, pointScaleFactor, false, textRounding);
const uint32_t childCount = YGNodeListCount(node->children);
const uint32_t childCount = node->children.size();
for (uint32_t i = 0; i < childCount; i++) {
YGRoundToPixelGrid(YGNodeGetChild(node, i), pointScaleFactor, absoluteNodeLeft, absoluteNodeTop);
}