diff --git a/BUCK b/BUCK index b9d6c907..aa7ec37e 100644 --- a/BUCK +++ b/BUCK @@ -7,14 +7,6 @@ include_defs('//YOGA_DEFS') -BASE_COMPILER_FLAGS = [ - '-fno-omit-frame-pointer', - '-fexceptions', - '-Wall', - '-Werror', - '-O3', -] - GMOCK_OVERRIDE_FLAGS = [ # gmock does not mark mocked methods as override, ignore the warnings in tests '-Wno-inconsistent-missing-override', diff --git a/YOGA_DEFS b/YOGA_DEFS index 137b96fd..288b13be 100644 --- a/YOGA_DEFS +++ b/YOGA_DEFS @@ -17,6 +17,14 @@ CXX_LIBRARY_WHITELIST = [ '//java:jni', ] +BASE_COMPILER_FLAGS = [ + '-fno-omit-frame-pointer', + '-fexceptions', + '-Wall', + '-Werror', + '-O3', +] + def yoga_dep(dep): return '//' + dep diff --git a/YogaKit/Tests/YogaKitTests.m b/YogaKit/Tests/YogaKitTests.m index 21b7f4ba..99927ade 100644 --- a/YogaKit/Tests/YogaKitTests.m +++ b/YogaKit/Tests/YogaKitTests.m @@ -9,7 +9,7 @@ #import -#import "UIView+Yoga.h" +#import @interface YogaKitTests : XCTestCase @end diff --git a/YogaKit/UIView+Yoga.h b/YogaKit/UIView+Yoga.h index 97bb2532..386416b2 100644 --- a/YogaKit/UIView+Yoga.h +++ b/YogaKit/UIView+Yoga.h @@ -55,7 +55,7 @@ - (YGDirection)yg_resolvedDirection; /** - Perform a layout calculation and update the frames of the views in the hierarchy with th results + Perform a layout calculation and update the frames of the views in the hierarchy with the results */ - (void)yg_applyLayout; diff --git a/YogaKit/UIView+Yoga.m b/YogaKit/UIView+Yoga.m index 0ad7bddc..241ad33e 100644 --- a/YogaKit/UIView+Yoga.m +++ b/YogaKit/UIView+Yoga.m @@ -53,7 +53,7 @@ - (NSUInteger)yg_numberOfChildren { - return YGNodeChildCount([self ygNode]); + return YGNodeGetChildCount([self ygNode]); } #pragma mark - Setters @@ -295,7 +295,7 @@ static void YGAttachNodesFromViewHierachy(UIView *view) { } BOOL shouldReconstructChildList = NO; - if (YGNodeChildCount(node) != subviewsToInclude.count) { + if (YGNodeGetChildCount(node) != subviewsToInclude.count) { shouldReconstructChildList = YES; } else { for (int i = 0; i < subviewsToInclude.count; i++) { @@ -324,8 +324,8 @@ static void YGRemoveAllChildren(const YGNodeRef node) return; } - while (YGNodeChildCount(node) > 0) { - YGNodeRemoveChild(node, YGNodeGetChild(node, YGNodeChildCount(node) - 1)); + while (YGNodeGetChildCount(node) > 0) { + YGNodeRemoveChild(node, YGNodeGetChild(node, YGNodeGetChildCount(node) - 1)); } } diff --git a/csharp/BUCK b/csharp/BUCK index 8223450a..8fc408eb 100644 --- a/csharp/BUCK +++ b/csharp/BUCK @@ -5,6 +5,10 @@ # 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_defs('//YOGA_DEFS') + +COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c++11'] + csharp_library( name = 'yogalibnet46', dll_name = 'Facebook.Yoga.dll', @@ -18,3 +22,42 @@ csharp_library( framework_ver = 'net45', srcs = glob(['**/*.cs']), ) + +cxx_library( + name = 'yoganet', + soname = 'libyoga.$(ext)', + srcs = glob(['Yoga/YGInterop.cpp']), + compiler_flags = COMPILER_FLAGS, + link_style = 'static', + link_whole = True, + deps = [yoga_dep(':yoga')], + visibility = ['PUBLIC'], +) + +with allow_unsafe_import(): + import os + +if os.path.isdir('/Applications/Xcode.app'): + yoganet_ios_srcs = [] + for arch in ['iphonesimulator-x86_64', 'iphoneos-arm64', 'iphoneos-armv7']: + name = 'yoganet-' + arch + yoganet_ios_srcs.append(':' + name) + genrule( + name = name, + srcs = [ + yoga_dep(':yoga#%s,static' % arch), + yoga_dep('YogaKit:YogaKit#%s,static' % arch), + yoga_dep('csharp:yoganet#%s,static' % arch), + ], + out = 'libyoga-%s.a' % arch, + cmd = 'libtool -static -o $OUT $SRCS', + visibility = [yoga_dep('csharp:yoganet-ios')], + ) + + genrule( + name = 'yoganet-ios', + srcs = yoganet_ios_srcs, + out = 'libyoga.a', + cmd = 'lipo $SRCS -create -output $OUT', + visibility = ['PUBLIC'], + ) diff --git a/csharp/Facebook.Yoga.Desktop.sln b/csharp/Facebook.Yoga.Desktop.sln index 8058b4ea..0c1fb81c 100644 --- a/csharp/Facebook.Yoga.Desktop.sln +++ b/csharp/Facebook.Yoga.Desktop.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Yoga", "Yoga\Yoga.vcxproj", "{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yoga", "Yoga\Yoga.vcxproj", "{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga", "Facebook.Yoga\Facebook.Yoga.csproj", "{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}" ProjectSection(ProjectDependencies) = postProject @@ -27,7 +27,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Build\Facebook.Yoga.NativeInterop.targets = Build\Facebook.Yoga.NativeInterop.targets NuGet\Facebook.Yoga.nuspec = NuGet\Facebook.Yoga.nuspec NuGet\Facebook.Yoga.targets = NuGet\Facebook.Yoga.targets - nuget\NuGetPackageBuilder.ps1 = nuget\NuGetPackageBuilder.ps1 EndProjectSection EndProject Global diff --git a/csharp/Facebook.Yoga.Universal.sln b/csharp/Facebook.Yoga.Universal.sln index c69bf78a..a55c0466 100644 --- a/csharp/Facebook.Yoga.Universal.sln +++ b/csharp/Facebook.Yoga.Universal.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Yoga", "Yoga\Yoga.vcxproj", "{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yoga", "Yoga\Yoga.vcxproj", "{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga", "Facebook.Yoga\Facebook.Yoga.csproj", "{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}" ProjectSection(ProjectDependencies) = postProject @@ -25,7 +25,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Build\Facebook.Yoga.NativeInterop.targets = Build\Facebook.Yoga.NativeInterop.targets NuGet\Facebook.Yoga.nuspec = NuGet\Facebook.Yoga.nuspec NuGet\Facebook.Yoga.targets = NuGet\Facebook.Yoga.targets - nuget\NuGetPackageBuilder.ps1 = nuget\NuGetPackageBuilder.ps1 EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Universal.Tests", "tests\Facebook.Yoga.Universal.Tests\Facebook.Yoga.Universal.Tests.csproj", "{0856757B-1671-4E43-AF41-4AEA53988796}" diff --git a/csharp/Facebook.Yoga.sln b/csharp/Facebook.Yoga.sln index b9553ebc..a9ae1dc7 100644 --- a/csharp/Facebook.Yoga.sln +++ b/csharp/Facebook.Yoga.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Yoga", "Yoga\Yoga.vcxproj", "{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yoga", "Yoga\Yoga.vcxproj", "{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga", "Facebook.Yoga\Facebook.Yoga.csproj", "{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}" ProjectSection(ProjectDependencies) = postProject @@ -27,7 +27,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Build\Facebook.Yoga.NativeInterop.targets = Build\Facebook.Yoga.NativeInterop.targets NuGet\Facebook.Yoga.nuspec = NuGet\Facebook.Yoga.nuspec NuGet\Facebook.Yoga.targets = NuGet\Facebook.Yoga.targets - nuget\NuGetPackageBuilder.ps1 = nuget\NuGetPackageBuilder.ps1 EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Universal.Tests", "tests\Facebook.Yoga.Universal.Tests\Facebook.Yoga.Universal.Tests.csproj", "{0856757B-1671-4E43-AF41-4AEA53988796}" diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs index 5e825de2..5f1702fa 100644 --- a/csharp/Facebook.Yoga/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -14,7 +14,7 @@ namespace Facebook.Yoga { internal static class Native { -#if UNITY_IOS && !UNITY_EDITOR +#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__ private const string DllName = "__Internal"; #else private const string DllName = "yoga"; @@ -58,7 +58,7 @@ namespace Facebook.Yoga public static extern IntPtr YGNodeGetChild(IntPtr node, uint index); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - public static extern uint YGNodeChildCount(IntPtr node); + public static extern uint YGNodeGetChildCount(IntPtr node); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeCalculateLayout(IntPtr node, diff --git a/csharp/Facebook.Yoga/Properties/AssemblyInfo.cs b/csharp/Facebook.Yoga/Properties/AssemblyInfo.cs index 089c3a6c..c6fc18bb 100644 --- a/csharp/Facebook.Yoga/Properties/AssemblyInfo.cs +++ b/csharp/Facebook.Yoga/Properties/AssemblyInfo.cs @@ -24,6 +24,6 @@ using System.Runtime.InteropServices; [assembly: NeutralResourcesLanguage("en")] -[assembly: AssemblyVersion("3.0.0.0")] -[assembly: AssemblyFileVersion("3.0.0.0")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/csharp/Facebook.Yoga/YogaNode.Create.cs b/csharp/Facebook.Yoga/YogaNode.Create.cs index a7df02d0..d04d0ffa 100644 --- a/csharp/Facebook.Yoga/YogaNode.Create.cs +++ b/csharp/Facebook.Yoga/YogaNode.Create.cs @@ -31,12 +31,12 @@ namespace Facebook.Yoga Spacing margin = null, Spacing padding = null, Spacing border = null, - float? Width = null, - float? Height = null, - float? MaxWidth = null, - float? MaxHeight = null, - float? MinWidth = null, - float? MinHeight = null) + float? width = null, + float? height = null, + float? maxWidth = null, + float? maxHeight = null, + float? minWidth = null, + float? minHeight = null) { YogaNode node = new YogaNode(); @@ -197,34 +197,34 @@ namespace Facebook.Yoga } } - if (Width.HasValue) + if (width.HasValue) { - node.Width = Width.Value; + node.Width = width.Value; } - if (Height.HasValue) + if (height.HasValue) { - node.Height = Height.Value; + node.Height = height.Value; } - if (MinWidth.HasValue) + if (minWidth.HasValue) { - node.MinWidth = MinWidth.Value; + node.MinWidth = minWidth.Value; } - if (MinHeight.HasValue) + if (minHeight.HasValue) { - node.MinHeight = MinHeight.Value; + node.MinHeight = minHeight.Value; } - if (MaxWidth.HasValue) + if (maxWidth.HasValue) { - node.MaxWidth = MaxWidth.Value; + node.MaxWidth = maxWidth.Value; } - if (MaxHeight.HasValue) + if (maxHeight.HasValue) { - node.MaxHeight = MaxHeight.Value; + node.MaxHeight = maxHeight.Value; } return node; diff --git a/csharp/Yoga/Yoga.rc b/csharp/Yoga/Yoga.rc index 2ca29747..e684194e 100644 Binary files a/csharp/Yoga/Yoga.rc and b/csharp/Yoga/Yoga.rc differ diff --git a/csharp/Yoga/Yoga.vcxproj b/csharp/Yoga/Yoga.vcxproj index 6a0622e9..789cf9ba 100755 --- a/csharp/Yoga/Yoga.vcxproj +++ b/csharp/Yoga/Yoga.vcxproj @@ -29,6 +29,7 @@ {0446C86B-F47B-4C46-B673-C7AE0CFF35D5} Win32Proj + yoga Yoga 8.1 true diff --git a/csharp/nuget/Facebook.Yoga.Native.nuspec b/csharp/nuget/Facebook.Yoga.Native.nuspec index 76955e35..659cdd12 100644 --- a/csharp/nuget/Facebook.Yoga.Native.nuspec +++ b/csharp/nuget/Facebook.Yoga.Native.nuspec @@ -2,7 +2,7 @@ Facebook.Yoga.Native - 3.0.0-pre + 1.0.0-pre Facebook.Yoga.Native Facebook Facebook @@ -31,8 +31,8 @@ - - + + \ No newline at end of file diff --git a/csharp/nuget/Facebook.Yoga.Native.targets b/csharp/nuget/Facebook.Yoga.Native.targets index 2a2705f0..3a2c7680 100644 --- a/csharp/nuget/Facebook.Yoga.Native.targets +++ b/csharp/nuget/Facebook.Yoga.Native.targets @@ -27,7 +27,7 @@ - + %(Filename)%(Extension) PreserveNewest False diff --git a/csharp/nuget/Facebook.Yoga.nuspec b/csharp/nuget/Facebook.Yoga.nuspec index 3cbbc6d8..42b1f6fa 100644 --- a/csharp/nuget/Facebook.Yoga.nuspec +++ b/csharp/nuget/Facebook.Yoga.nuspec @@ -2,7 +2,7 @@ Facebook.Yoga - 3.0.0-pre + 1.0.0-pre Facebook.Yoga Facebook Facebook @@ -30,8 +30,8 @@ - - + + @@ -40,7 +40,7 @@ - - + + \ No newline at end of file diff --git a/csharp/nuget/Facebook.Yoga.targets b/csharp/nuget/Facebook.Yoga.targets index b10fb47c..799fdb78 100644 --- a/csharp/nuget/Facebook.Yoga.targets +++ b/csharp/nuget/Facebook.Yoga.targets @@ -37,12 +37,12 @@ - + %(Filename)%(Extension) PreserveNewest False - + %(Filename)%(Extension) PreserveNewest False diff --git a/csharp/nuget/NuGetPackageBuilder.ps1 b/csharp/nuget/NuGetPackageBuilder.ps1 deleted file mode 100644 index 5285d11d..00000000 --- a/csharp/nuget/NuGetPackageBuilder.ps1 +++ /dev/null @@ -1,10 +0,0 @@ -$solutionRoot = Resolve-Path ..\ - -# Delete any existing output. -Remove-Item *.nupkg - -# Create new packages for any nuspec files that exist in this directory. -Foreach ($nuspec in $(Get-Item *.nuspec)) -{ - .\Tools\NuGet.exe pack "$nuspec" -} \ No newline at end of file diff --git a/csharp/nuget/Tools/nuget.exe b/csharp/nuget/Tools/nuget.exe deleted file mode 100644 index 6bb79fe5..00000000 Binary files a/csharp/nuget/Tools/nuget.exe and /dev/null differ diff --git a/csharp/tests/Facebook.Yoga.Desktop.Tests/Properties/AssemblyInfo.cs b/csharp/tests/Facebook.Yoga.Desktop.Tests/Properties/AssemblyInfo.cs index 1f0b4b85..3947118c 100644 --- a/csharp/tests/Facebook.Yoga.Desktop.Tests/Properties/AssemblyInfo.cs +++ b/csharp/tests/Facebook.Yoga.Desktop.Tests/Properties/AssemblyInfo.cs @@ -23,6 +23,6 @@ using System.Runtime.InteropServices; [assembly: NeutralResourcesLanguage("en")] -[assembly: AssemblyVersion("3.0.0.0")] -[assembly: AssemblyFileVersion("3.0.0.0")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs b/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs index d7cd8d8e..0d43cdbc 100644 --- a/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs +++ b/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs @@ -87,12 +87,12 @@ namespace Facebook.Yoga padding: new Spacing(top: 13, bottom: 14, left: 15, right: 16), border: new Spacing(top: 17, bottom: 18, left: 19, right: 20), - Width: 21, - Height: 22, - MinWidth: 23, - MinHeight: 24, - MaxWidth: 25, - MaxHeight: 26); + width: 21, + height: 22, + minWidth: 23, + minHeight: 24, + maxWidth: 25, + maxHeight: 26); Assert.AreEqual(YogaDirection.RTL, node.StyleDirection); Assert.AreEqual(YogaFlexDirection.RowReverse, node.FlexDirection); diff --git a/csharp/tests/Facebook.Yoga/test_macos.sh b/csharp/tests/Facebook.Yoga/test_macos.sh index 7df36893..1d04177d 100755 --- a/csharp/tests/Facebook.Yoga/test_macos.sh +++ b/csharp/tests/Facebook.Yoga/test_macos.sh @@ -1,16 +1,6 @@ #!/bin/sh -if clang --version >/dev/null 2>&1; then true; else - echo "ERROR: Can't execute clang. You need to install Xcode and command line tools." - exit 1 -fi - -if mcs --version >/dev/null 2>&1; then true; else - echo "ERROR: Can't execute mcs. You need to install Mono from http://www.mono-project.com/download/ and re-login to apply PATH environment." - exit 1 -fi - -if mono --version >/dev/null 2>&1; then true; else - echo "ERROR: Can't execute mono64. You need to install Mono from http://www.mono-project.com/download/ and re-login to apply PATH environment." +if mcs --version >/dev/null 2>&1 && mono --version >/dev/null 2>&1; then true; else + echo "ERROR: Need to install Mono (brew install mono, or http://www.mono-project.com/download/)" exit 1 fi @@ -28,6 +18,11 @@ if [ -d $NUNIT \ rm NUnit-2.6.4.zip fi -clang -g -Wall -Wextra -dynamiclib -o libyoga.dylib -I../../.. ../../../yoga/*.c ../../Yoga/YGInterop.cpp +TARGET=//csharp:yoganet#default,shared +buck build $TARGET +ROOT=`buck root|tail -1` +DYLIB=`buck targets --show-output $TARGET|tail -1|awk '{print $2}'` +cp $ROOT/$DYLIB . + mcs -debug -t:library -r:$NUNIT/nunit.framework.dll -out:YogaTest.dll *.cs ../../../csharp/Facebook.Yoga/*cs MONO_PATH=$NUNIT mono --arch=64 --debug $NUNIT/nunit-console.exe YogaTest.dll diff --git a/java/jni/YGJNI.cpp b/java/jni/YGJNI.cpp index bf17f087..09236b88 100644 --- a/java/jni/YGJNI.cpp +++ b/java/jni/YGJNI.cpp @@ -36,7 +36,7 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) { obj->setFieldValue(topField, YGNodeLayoutGetTop(root)); YGTransferLayoutDirection(root, obj); - for (uint32_t i = 0; i < YGNodeChildCount(root); i++) { + for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) { YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i)); } } else { diff --git a/tests/YGLayoutAspectRatioTest.cpp b/tests/YGAspectRatioTest.cpp similarity index 100% rename from tests/YGLayoutAspectRatioTest.cpp rename to tests/YGAspectRatioTest.cpp diff --git a/tests/YGLayoutDefaultValuesTest.cpp b/tests/YGDefaultValuesTest.cpp similarity index 98% rename from tests/YGLayoutDefaultValuesTest.cpp rename to tests/YGDefaultValuesTest.cpp index fbc1e1b9..044059b5 100644 --- a/tests/YGLayoutDefaultValuesTest.cpp +++ b/tests/YGDefaultValuesTest.cpp @@ -13,7 +13,7 @@ TEST(YogaTest, assert_default_values) { const YGNodeRef root = YGNodeNew(); - ASSERT_EQ(0, YGNodeChildCount(root)); + ASSERT_EQ(0, YGNodeGetChildCount(root)); ASSERT_EQ(NULL, YGNodeGetChild(root, 1)); ASSERT_EQ(YGDirectionInherit, YGNodeStyleGetDirection(root)); diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 29acb459..dad81116 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -256,7 +256,7 @@ void YGNodeFree(const YGNodeRef node) { node->parent = NULL; } - const uint32_t childCount = YGNodeChildCount(node); + const uint32_t childCount = YGNodeGetChildCount(node); for (uint32_t i = 0; i < childCount; i++) { const YGNodeRef child = YGNodeGetChild(node, i); child->parent = NULL; @@ -268,7 +268,7 @@ void YGNodeFree(const YGNodeRef node) { } void YGNodeFreeRecursive(const YGNodeRef root) { - while (YGNodeChildCount(root) > 0) { + while (YGNodeGetChildCount(root) > 0) { const YGNodeRef child = YGNodeGetChild(root, 0); YGNodeRemoveChild(root, child); YGNodeFreeRecursive(child); @@ -277,7 +277,7 @@ void YGNodeFreeRecursive(const YGNodeRef root) { } void YGNodeReset(const YGNodeRef node) { - YG_ASSERT(YGNodeChildCount(node) == 0, "Cannot reset a node which still has children attached"); + YG_ASSERT(YGNodeGetChildCount(node) == 0, "Cannot reset a node which still has children attached"); YG_ASSERT(node->parent == NULL, "Cannot reset a node still attached to a parent"); YGNodeListFree(node->children); @@ -303,7 +303,7 @@ void YGNodeSetMeasureFunc(const YGNodeRef node, YGMeasureFunc measureFunc) { if (measureFunc == NULL) { node->measure = NULL; } else { - YG_ASSERT(YGNodeChildCount(node) == 0, + YG_ASSERT(YGNodeGetChildCount(node) == 0, "Cannot set measure function: Nodes with measure functions cannot have children."); node->measure = measureFunc; } @@ -333,7 +333,11 @@ YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index) { return YGNodeListGet(node->children, index); } -inline uint32_t YGNodeChildCount(const YGNodeRef node) { +YGNodeRef YGNodeGetParent(const YGNodeRef node) { + return node->parent; +} + +inline uint32_t YGNodeGetChildCount(const YGNodeRef node) { return YGNodeListCount(node->children); } diff --git a/yoga/Yoga.h b/yoga/Yoga.h index c7bc600d..3bb96727 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -64,7 +64,8 @@ WIN_EXPORT void YGNodeInsertChild(const YGNodeRef node, const uint32_t index); WIN_EXPORT void YGNodeRemoveChild(const YGNodeRef node, const YGNodeRef child); WIN_EXPORT YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index); -WIN_EXPORT uint32_t YGNodeChildCount(const YGNodeRef node); +WIN_EXPORT YGNodeRef YGNodeGetParent(const YGNodeRef node); +WIN_EXPORT uint32_t YGNodeGetChildCount(const YGNodeRef node); WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node, const float availableWidth,