From d7ab9496bc95f7b720fd6db1ed503af1c461e84d Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Tue, 21 Nov 2017 10:10:30 -0800 Subject: [PATCH] Change c files to cpp Reviewed By: gkassabli Differential Revision: D6271299 fbshipit-source-id: 66c0e54ccf019d72d1fd0b4d117826e4e84fdc89 --- React.podspec | 2 +- React/React.xcodeproj/project.pbxproj | 82 ++-- React/ReactLegacy.xcodeproj/project.pbxproj | 34 +- ReactCommon/yoga/Android.mk | 8 +- ReactCommon/yoga/BUCK | 8 +- ReactCommon/yoga/yoga.podspec | 4 +- .../yoga/yoga/{YGEnums.c => YGEnums.cpp} | 1 - .../yoga/{YGNodeList.c => YGNodeList.cpp} | 36 +- ReactCommon/yoga/yoga/{Yoga.c => Yoga.cpp} | 351 ++++++++++-------- ReactCommon/yoga/yoga/Yoga.h | 5 - 10 files changed, 297 insertions(+), 234 deletions(-) rename ReactCommon/yoga/yoga/{YGEnums.c => YGEnums.cpp} (99%) rename ReactCommon/yoga/yoga/{YGNodeList.c => YGNodeList.cpp} (78%) rename ReactCommon/yoga/yoga/{Yoga.c => Yoga.cpp} (95%) diff --git a/React.podspec b/React.podspec index b4346aa9a403b4..1e790575d270ca 100644 --- a/React.podspec +++ b/React.podspec @@ -43,7 +43,7 @@ Pod::Spec.new do |s| s.subspec "Core" do |ss| ss.dependency "yoga", "#{package["version"]}.React" - ss.source_files = "React/**/*.{c,h,m,mm,S}" + ss.source_files = "React/**/*.{c,h,m,mm,S,cpp}" ss.exclude_files = "**/__tests__/*", "IntegrationTests/*", "React/DevSupport/*", diff --git a/React/React.xcodeproj/project.pbxproj b/React/React.xcodeproj/project.pbxproj index 9756d7fd4c0570..05b862ffe590e5 100644 --- a/React/React.xcodeproj/project.pbxproj +++ b/React/React.xcodeproj/project.pbxproj @@ -110,8 +110,6 @@ 13A0C28A1B74F71200B29F6F /* RCTDevMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 13A0C2881B74F71200B29F6F /* RCTDevMenu.m */; }; 13A1F71E1A75392D00D3D453 /* RCTKeyCommands.m in Sources */ = {isa = PBXBuildFile; fileRef = 13A1F71D1A75392D00D3D453 /* RCTKeyCommands.m */; }; 13A6E20E1C19AA0C00845B82 /* RCTParserUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 13A6E20D1C19AA0C00845B82 /* RCTParserUtils.m */; }; - 13AB5E011DF777F2001A8C30 /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 130A77051DF767AF001F9587 /* YGNodeList.c */; }; - 13AB5E021DF777F2001A8C30 /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 130A77071DF767AF001F9587 /* Yoga.c */; }; 13AB90C11B6FA36700713B4F /* RCTComponentData.m in Sources */ = {isa = PBXBuildFile; fileRef = 13AB90C01B6FA36700713B4F /* RCTComponentData.m */; }; 13AF20451AE707F9005F5298 /* RCTSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = 13AF20441AE707F9005F5298 /* RCTSlider.m */; }; 13B07FEF1A69327A00A75B9A /* RCTAlertManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FE81A69327A00A75B9A /* RCTAlertManager.m */; }; @@ -526,7 +524,6 @@ 3D383D6F1EBD2940005632C8 /* libthird-party.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139D7ECE1E25DB7D00323FB7 /* libthird-party.a */; }; 3D383D711EBD2949005632C8 /* libjschelpers.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D3CD9181DE5FBD800167DC4 /* libjschelpers.a */; }; 3D383D721EBD2949005632C8 /* libthird-party.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D383D3C1EBD27B6005632C8 /* libthird-party.a */; }; - 3D3C08891DE342FB00C268FA /* libyoga.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D3C059A1DE3340900C268FA /* libyoga.a */; }; 3D3CD93D1DE5FC1400167DC4 /* JavaScriptCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D7A27DC1DE32541002E3F95 /* JavaScriptCore.h */; }; 3D3CD93E1DE5FC1400167DC4 /* JSCWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D7A27DE1DE32541002E3F95 /* JSCWrapper.h */; }; 3D3CD9411DE5FC5300167DC4 /* libcxxreact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D3CD9251DE5FBEC00167DC4 /* libcxxreact.a */; }; @@ -966,8 +963,6 @@ 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 */; }; - 3DCC92BC1E94459100EF89A8 /* YGEnums.c in Sources */ = {isa = PBXBuildFile; fileRef = 3DCC92BA1E94458B00EF89A8 /* YGEnums.c */; }; - 3DCC92BD1E94459100EF89A8 /* YGEnums.c in Sources */ = {isa = PBXBuildFile; fileRef = 3DCC92BA1E94458B00EF89A8 /* YGEnums.c */; }; 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 */; }; @@ -985,9 +980,17 @@ 3DFE0D1A1DF8575800459392 /* YGEnums.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77031DF767AF001F9587 /* YGEnums.h */; }; 3DFE0D1B1DF8575800459392 /* YGMacros.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77041DF767AF001F9587 /* YGMacros.h */; }; 3DFE0D1C1DF8575800459392 /* Yoga.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77081DF767AF001F9587 /* Yoga.h */; }; - 3DFE0D1D1DF857FF00459392 /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 130A77051DF767AF001F9587 /* YGNodeList.c */; }; - 3DFE0D1E1DF857FF00459392 /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 130A77071DF767AF001F9587 /* Yoga.c */; }; 3EDCA8A51D3591E700450C31 /* RCTErrorInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EDCA8A41D3591E700450C31 /* RCTErrorInfo.m */; }; + 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 */; }; + 53D123A11FBF1EFF001B8A10 /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1871FB4FE80002CBB31 /* Yoga.cpp */; }; + 53D123B21FBF220F001B8A10 /* Yoga.h in Headers */ = {isa = PBXBuildFile; fileRef = 130A77081DF767AF001F9587 /* Yoga.h */; }; 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 */; }; @@ -1214,19 +1217,19 @@ remoteGlobalIDString = 3D3CD8FF1DE5FBD600167DC4; remoteInfo = jschelpers; }; - 3D8ED92A1E5B11EA00D83D20 /* PBXContainerItemProxy */ = { + 3DC159E71E83E2A0007B1282 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; proxyType = 1; - remoteGlobalIDString = 3D3C04B91DE3340900C268FA; - remoteInfo = yoga; + remoteGlobalIDString = 3D3CD90C1DE5FBD800167DC4; + remoteInfo = "jschelpers-tvOS"; }; - 3DC159E71E83E2A0007B1282 /* PBXContainerItemProxy */ = { + 53D123981FBF1E0C001B8A10 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; proxyType = 1; - remoteGlobalIDString = 3D3CD90C1DE5FBD800167DC4; - remoteInfo = "jschelpers-tvOS"; + remoteGlobalIDString = 3D3C04B91DE3340900C268FA; + remoteInfo = yoga; }; 9936F33F1F5F305D0010BF04 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; @@ -1741,9 +1744,7 @@ 130443D71E401AD800D93A67 /* RCTTVView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTVView.m; sourceTree = ""; }; 130A77031DF767AF001F9587 /* YGEnums.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGEnums.h; sourceTree = ""; }; 130A77041DF767AF001F9587 /* YGMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGMacros.h; sourceTree = ""; }; - 130A77051DF767AF001F9587 /* YGNodeList.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = YGNodeList.c; sourceTree = ""; }; 130A77061DF767AF001F9587 /* YGNodeList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGNodeList.h; sourceTree = ""; }; - 130A77071DF767AF001F9587 /* Yoga.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = Yoga.c; sourceTree = ""; }; 130A77081DF767AF001F9587 /* Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Yoga.h; sourceTree = ""; }; 130E3D861E6A082100ACE484 /* RCTDevSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDevSettings.h; sourceTree = ""; }; 130E3D871E6A082100ACE484 /* RCTDevSettings.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RCTDevSettings.mm; sourceTree = ""; }; @@ -2045,12 +2046,16 @@ 3D92B10B1E0369AD0018521A /* Unicode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Unicode.h; sourceTree = ""; }; 3D92B10C1E0369AD0018521A /* Value.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Value.cpp; sourceTree = ""; }; 3D92B10D1E0369AD0018521A /* Value.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Value.h; sourceTree = ""; }; - 3DCC92BA1E94458B00EF89A8 /* YGEnums.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = YGEnums.c; sourceTree = ""; }; 3DF1BE801F26576400068F1A /* JSCTracing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCTracing.cpp; sourceTree = ""; }; 3DF1BE811F26576400068F1A /* JSCTracing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCTracing.h; sourceTree = ""; }; 3EDCA8A21D3591E700450C31 /* RCTErrorCustomizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTErrorCustomizer.h; sourceTree = ""; }; 3EDCA8A31D3591E700450C31 /* RCTErrorInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTErrorInfo.h; sourceTree = ""; }; 3EDCA8A41D3591E700450C31 /* RCTErrorInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTErrorInfo.m; sourceTree = ""; }; + 53CBF1851FB4FE80002CBB31 /* Yoga-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Yoga-internal.h"; sourceTree = ""; }; + 53CBF1861FB4FE80002CBB31 /* YGEnums.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGEnums.cpp; sourceTree = ""; }; + 53CBF1871FB4FE80002CBB31 /* Yoga.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Yoga.cpp; sourceTree = ""; }; + 53CBF1881FB4FE80002CBB31 /* YGNodeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGNodeList.cpp; sourceTree = ""; }; + 53D123831FBF1D49001B8A10 /* libyoga.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libyoga.a; path = "../../../../../../../../../Library/Developer/Xcode/DerivedData/yoga-hdfifpwsinitsibujacpiefkjfdy/Build/Products/Debug/libyoga.a"; sourceTree = ""; }; 58114A121AAE854800E7D092 /* RCTPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPicker.h; sourceTree = ""; }; 58114A131AAE854800E7D092 /* RCTPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTPicker.m; sourceTree = ""; }; 58114A141AAE854800E7D092 /* RCTPickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPickerManager.h; sourceTree = ""; }; @@ -2174,11 +2179,11 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 53D123971FBF1DF5001B8A10 /* libyoga.a in Frameworks */, 3D383D6D1EBD2940005632C8 /* libdouble-conversion.a in Frameworks */, 3D383D6E1EBD2940005632C8 /* libjschelpers.a in Frameworks */, 3D383D6F1EBD2940005632C8 /* libthird-party.a in Frameworks */, 3D3CD9411DE5FC5300167DC4 /* libcxxreact.a in Frameworks */, - 3D3C08891DE342FB00C268FA /* libyoga.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2210,12 +2215,13 @@ 130A77021DF767AF001F9587 /* yoga */ = { isa = PBXGroup; children = ( - 3DCC92BA1E94458B00EF89A8 /* YGEnums.c */, + 53CBF1861FB4FE80002CBB31 /* YGEnums.cpp */, + 53CBF1881FB4FE80002CBB31 /* YGNodeList.cpp */, + 53CBF1851FB4FE80002CBB31 /* Yoga-internal.h */, + 53CBF1871FB4FE80002CBB31 /* Yoga.cpp */, 130A77031DF767AF001F9587 /* YGEnums.h */, 130A77041DF767AF001F9587 /* YGMacros.h */, - 130A77051DF767AF001F9587 /* YGNodeList.c */, 130A77061DF767AF001F9587 /* YGNodeList.h */, - 130A77071DF767AF001F9587 /* Yoga.c */, 130A77081DF767AF001F9587 /* Yoga.h */, ); name = yoga; @@ -2643,6 +2649,14 @@ path = "../third-party"; sourceTree = ""; }; + 53D123821FBF1D49001B8A10 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 53D123831FBF1D49001B8A10 /* libyoga.a */, + ); + name = Frameworks; + sourceTree = ""; + }; 599FAA291FB274970058CCF6 /* Surface */ = { isa = PBXGroup; children = ( @@ -2696,6 +2710,7 @@ 3D1FA0781DE4F2CD00E03CC6 /* Libraries */, 3D92B1151E036A690018521A /* ThirdParty */, 83CBBA001A601CBA00E9B192 /* Products */, + 53D123821FBF1D49001B8A10 /* Frameworks */, ); indentWidth = 2; sourceTree = ""; @@ -3081,6 +3096,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 53D1239F1FBF1EFB001B8A10 /* Yoga-internal.h in Headers */, 3DFE0D161DF8574D00459392 /* YGEnums.h in Headers */, 3DFE0D171DF8574D00459392 /* YGMacros.h in Headers */, 3DFE0D181DF8574D00459392 /* YGNodeList.h in Headers */, @@ -3157,6 +3173,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 53D1239E1FBF1EFB001B8A10 /* Yoga-internal.h in Headers */, 133957881DF76D3500EC27BE /* YGEnums.h in Headers */, 1339578B1DF76D3500EC27BE /* Yoga.h in Headers */, 1339578A1DF76D3500EC27BE /* YGNodeList.h in Headers */, @@ -3269,6 +3286,7 @@ 3D80DA361DF820620028D040 /* RCTModuleMethod.h in Headers */, 3D80DA371DF820620028D040 /* RCTMultipartDataTask.h in Headers */, 3D80DA381DF820620028D040 /* RCTMultipartStreamReader.h in Headers */, + 53D123B21FBF220F001B8A10 /* Yoga.h in Headers */, 3D80DA391DF820620028D040 /* RCTNullability.h in Headers */, 3D80DA3A1DF820620028D040 /* RCTParserUtils.h in Headers */, 599FAA421FB274980058CCF6 /* RCTSurfaceRootView.h in Headers */, @@ -3621,7 +3639,7 @@ buildRules = ( ); dependencies = ( - 3D8ED92B1E5B11EA00D83D20 /* PBXTargetDependency */, + 53D123991FBF1E0C001B8A10 /* PBXTargetDependency */, 3D3CD94C1DE5FCE700167DC4 /* PBXTargetDependency */, ); name = React; @@ -4032,9 +4050,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 13AB5E011DF777F2001A8C30 /* YGNodeList.c in Sources */, - 13AB5E021DF777F2001A8C30 /* Yoga.c in Sources */, - 3DCC92BC1E94459100EF89A8 /* YGEnums.c in Sources */, + 53D123A01FBF1EFF001B8A10 /* Yoga.cpp in Sources */, + 53D1239A1FBF1EF2001B8A10 /* YGEnums.cpp in Sources */, + 53D1239C1FBF1EF7001B8A10 /* YGNodeList.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4042,9 +4060,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 3DFE0D1D1DF857FF00459392 /* YGNodeList.c in Sources */, - 3DFE0D1E1DF857FF00459392 /* Yoga.c in Sources */, - 3DCC92BD1E94459100EF89A8 /* YGEnums.c in Sources */, + 53D123A11FBF1EFF001B8A10 /* Yoga.cpp in Sources */, + 53D1239B1FBF1EF4001B8A10 /* YGEnums.cpp in Sources */, + 53D1239D1FBF1EF7001B8A10 /* YGNodeList.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4322,16 +4340,16 @@ target = 3D3CD8FF1DE5FBD600167DC4 /* jschelpers */; targetProxy = 3D3CD94F1DE5FDB900167DC4 /* PBXContainerItemProxy */; }; - 3D8ED92B1E5B11EA00D83D20 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 3D3C04B91DE3340900C268FA /* yoga */; - targetProxy = 3D8ED92A1E5B11EA00D83D20 /* PBXContainerItemProxy */; - }; 3DC159E81E83E2A0007B1282 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 3D3CD90C1DE5FBD800167DC4 /* jschelpers-tvOS */; targetProxy = 3DC159E71E83E2A0007B1282 /* PBXContainerItemProxy */; }; + 53D123991FBF1E0C001B8A10 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 3D3C04B91DE3340900C268FA /* yoga */; + targetProxy = 53D123981FBF1E0C001B8A10 /* PBXContainerItemProxy */; + }; 9936F3401F5F305D0010BF04 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 9936F2F81F5F2E4B0010BF04 /* privatedata */; diff --git a/React/ReactLegacy.xcodeproj/project.pbxproj b/React/ReactLegacy.xcodeproj/project.pbxproj index 8f953a5ff3fc90..99f9374ca3624f 100644 --- a/React/ReactLegacy.xcodeproj/project.pbxproj +++ b/React/ReactLegacy.xcodeproj/project.pbxproj @@ -27,14 +27,11 @@ 137327E81AA5CF210034F82E /* RCTTabBarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 137327E21AA5CF210034F82E /* RCTTabBarItem.m */; }; 137327E91AA5CF210034F82E /* RCTTabBarItemManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 137327E41AA5CF210034F82E /* RCTTabBarItemManager.m */; }; 137327EA1AA5CF210034F82E /* RCTTabBarManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 137327E61AA5CF210034F82E /* RCTTabBarManager.m */; }; - 138FDE6B1E92EA4F005FEEDD /* YGEnums.c in Sources */ = {isa = PBXBuildFile; fileRef = 138FDE6A1E92EA4F005FEEDD /* YGEnums.c */; }; 139324FE1E70B069009FD7E0 /* RCTJSCErrorHandling.h in Headers */ = {isa = PBXBuildFile; fileRef = 139324FC1E70B069009FD7E0 /* RCTJSCErrorHandling.h */; }; 139324FF1E70B069009FD7E0 /* RCTJSCErrorHandling.mm in Sources */ = {isa = PBXBuildFile; fileRef = 139324FD1E70B069009FD7E0 /* RCTJSCErrorHandling.mm */; }; 13A0C2891B74F71200B29F6F /* RCTDevLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 13A0C2861B74F71200B29F6F /* RCTDevLoadingView.m */; }; 13A1F71E1A75392D00D3D453 /* RCTKeyCommands.m in Sources */ = {isa = PBXBuildFile; fileRef = 13A1F71D1A75392D00D3D453 /* RCTKeyCommands.m */; }; 13A6E20E1C19AA0C00845B82 /* RCTParserUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 13A6E20D1C19AA0C00845B82 /* RCTParserUtils.m */; }; - 13AB5E011DF777F2001A8C30 /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 130A77051DF767AF001F9587 /* YGNodeList.c */; }; - 13AB5E021DF777F2001A8C30 /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 130A77071DF767AF001F9587 /* Yoga.c */; }; 13AB90C11B6FA36700713B4F /* RCTComponentData.m in Sources */ = {isa = PBXBuildFile; fileRef = 13AB90C01B6FA36700713B4F /* RCTComponentData.m */; }; 13AF20451AE707F9005F5298 /* RCTSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = 13AF20441AE707F9005F5298 /* RCTSlider.m */; }; 13B07FEF1A69327A00A75B9A /* RCTAlertManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FE81A69327A00A75B9A /* RCTAlertManager.m */; }; @@ -157,7 +154,6 @@ 2D7FEB891E734B5700D3238C /* systemJSCWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65F3E41D1E73031C009375BD /* systemJSCWrapper.cpp */; }; 2D8C2E331DA40441000EE098 /* RCTMultipartStreamReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 001BFCCF1D8381DE008E587E /* RCTMultipartStreamReader.m */; }; 2DD0EFE11DA84F2800B0C975 /* RCTStatusBarManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13723B4F1A82FD3C00F88898 /* RCTStatusBarManager.m */; }; - 2DDD72161E931C25007C55D1 /* YGEnums.c in Sources */ = {isa = PBXBuildFile; fileRef = 138FDE6A1E92EA4F005FEEDD /* YGEnums.c */; }; 352DCFF01D19F4C20056D623 /* RCTI18nUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 352DCFEF1D19F4C20056D623 /* RCTI18nUtil.m */; }; 369123E11DDC75850095B341 /* RCTJSCSamplingProfiler.m in Sources */ = {isa = PBXBuildFile; fileRef = 369123E01DDC75850095B341 /* RCTJSCSamplingProfiler.m */; }; 391E86A41C623EC800009732 /* RCTTouchEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 391E86A21C623EC800009732 /* RCTTouchEvent.m */; }; @@ -682,9 +678,11 @@ 3DFE0D1A1DF8575800459392 /* YGEnums.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77031DF767AF001F9587 /* YGEnums.h */; }; 3DFE0D1B1DF8575800459392 /* YGMacros.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77041DF767AF001F9587 /* YGMacros.h */; }; 3DFE0D1C1DF8575800459392 /* Yoga.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77081DF767AF001F9587 /* Yoga.h */; }; - 3DFE0D1D1DF857FF00459392 /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 130A77051DF767AF001F9587 /* YGNodeList.c */; }; - 3DFE0D1E1DF857FF00459392 /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 130A77071DF767AF001F9587 /* Yoga.c */; }; 3EDCA8A51D3591E700450C31 /* RCTErrorInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EDCA8A41D3591E700450C31 /* RCTErrorInfo.m */; }; + 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 */; }; @@ -1168,9 +1166,7 @@ 008341F51D1DB34400876D9A /* RCTJSStackFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTJSStackFrame.h; sourceTree = ""; }; 130A77031DF767AF001F9587 /* YGEnums.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGEnums.h; sourceTree = ""; }; 130A77041DF767AF001F9587 /* YGMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGMacros.h; sourceTree = ""; }; - 130A77051DF767AF001F9587 /* YGNodeList.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = YGNodeList.c; sourceTree = ""; }; 130A77061DF767AF001F9587 /* YGNodeList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGNodeList.h; sourceTree = ""; }; - 130A77071DF767AF001F9587 /* Yoga.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = Yoga.c; sourceTree = ""; }; 130A77081DF767AF001F9587 /* Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Yoga.h; sourceTree = ""; }; 131B6AF01AF1093D00FFC3E0 /* RCTSegmentedControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTSegmentedControl.h; sourceTree = ""; }; 131B6AF11AF1093D00FFC3E0 /* RCTSegmentedControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSegmentedControl.m; sourceTree = ""; }; @@ -1201,7 +1197,6 @@ 137327E41AA5CF210034F82E /* RCTTabBarItemManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTabBarItemManager.m; sourceTree = ""; }; 137327E51AA5CF210034F82E /* RCTTabBarManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTabBarManager.h; sourceTree = ""; }; 137327E61AA5CF210034F82E /* RCTTabBarManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTabBarManager.m; sourceTree = ""; }; - 138FDE6A1E92EA4F005FEEDD /* YGEnums.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = YGEnums.c; sourceTree = ""; }; 139324FC1E70B069009FD7E0 /* RCTJSCErrorHandling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTJSCErrorHandling.h; sourceTree = ""; }; 139324FD1E70B069009FD7E0 /* RCTJSCErrorHandling.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RCTJSCErrorHandling.mm; sourceTree = ""; }; 13A0C2851B74F71200B29F6F /* RCTDevLoadingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = RCTDevLoadingView.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; @@ -1352,6 +1347,10 @@ 3EDCA8A21D3591E700450C31 /* RCTErrorCustomizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTErrorCustomizer.h; sourceTree = ""; }; 3EDCA8A31D3591E700450C31 /* RCTErrorInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTErrorInfo.h; sourceTree = ""; }; 3EDCA8A41D3591E700450C31 /* RCTErrorInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTErrorInfo.m; sourceTree = ""; }; + 53CBF1BB1FB50262002CBB31 /* Yoga-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Yoga-internal.h"; sourceTree = ""; }; + 53CBF1BC1FB50263002CBB31 /* YGEnums.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGEnums.cpp; sourceTree = ""; }; + 53CBF1BD1FB50263002CBB31 /* Yoga.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Yoga.cpp; sourceTree = ""; }; + 53CBF1BE1FB50263002CBB31 /* YGNodeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGNodeList.cpp; sourceTree = ""; }; 58114A121AAE854800E7D092 /* RCTPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPicker.h; sourceTree = ""; }; 58114A131AAE854800E7D092 /* RCTPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTPicker.m; sourceTree = ""; }; 58114A141AAE854800E7D092 /* RCTPickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPickerManager.h; sourceTree = ""; }; @@ -1465,12 +1464,13 @@ 130A77021DF767AF001F9587 /* yoga */ = { isa = PBXGroup; children = ( - 138FDE6A1E92EA4F005FEEDD /* YGEnums.c */, + 53CBF1BC1FB50263002CBB31 /* YGEnums.cpp */, + 53CBF1BE1FB50263002CBB31 /* YGNodeList.cpp */, + 53CBF1BB1FB50262002CBB31 /* Yoga-internal.h */, + 53CBF1BD1FB50263002CBB31 /* Yoga.cpp */, 130A77031DF767AF001F9587 /* YGEnums.h */, 130A77041DF767AF001F9587 /* YGMacros.h */, - 130A77051DF767AF001F9587 /* YGNodeList.c */, 130A77061DF767AF001F9587 /* YGNodeList.h */, - 130A77071DF767AF001F9587 /* Yoga.c */, 130A77081DF767AF001F9587 /* Yoga.h */, ); name = yoga; @@ -2185,6 +2185,7 @@ 3D80DA611DF820620028D040 /* RCTAnimationType.h in Headers */, 3D80DA621DF820620028D040 /* RCTAutoInsetsProtocol.h in Headers */, 3D4153711F277092005B8EFE /* RCTConvert+Transform.h in Headers */, + 53CBF1BF1FB50263002CBB31 /* Yoga-internal.h in Headers */, 3D80DA631DF820620028D040 /* RCTBorderDrawing.h in Headers */, 3D80DA641DF820620028D040 /* RCTBorderStyle.h in Headers */, 3D80DA651DF820620028D040 /* RCTComponent.h in Headers */, @@ -2614,9 +2615,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 13AB5E011DF777F2001A8C30 /* YGNodeList.c in Sources */, - 13AB5E021DF777F2001A8C30 /* Yoga.c in Sources */, - 138FDE6B1E92EA4F005FEEDD /* YGEnums.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2624,9 +2622,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 3DFE0D1D1DF857FF00459392 /* YGNodeList.c in Sources */, - 3DFE0D1E1DF857FF00459392 /* Yoga.c in Sources */, - 2DDD72161E931C25007C55D1 /* YGEnums.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2711,6 +2706,7 @@ AC70D2E91DE489E4002E6351 /* RCTJavaScriptLoader.mm in Sources */, 14F7A0EC1BDA3B3C003C6C10 /* RCTPerfMonitor.m in Sources */, 1450FF881BCFF28A00208362 /* RCTProfileTrampoline-arm64.S in Sources */, + 53CBF1C11FB50263002CBB31 /* Yoga.cpp in Sources */, 13E41EEB1C05CA0B00CD8DAC /* RCTProfileTrampoline-i386.S in Sources */, 3D37B5821D522B190042D5B5 /* RCTFont.mm in Sources */, 13B080061A6947C200A75B9A /* RCTScrollViewManager.m in Sources */, @@ -2752,12 +2748,14 @@ 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 */, 83A1FE8C1B62640A00BE0E65 /* RCTModalHostView.m in Sources */, C60669311F3CC7BD00E67165 /* RCTModuleMethod.mm in Sources */, 13E067551A70F44B002CDEE1 /* RCTShadowView.m in Sources */, + 53CBF1C01FB50263002CBB31 /* YGEnums.cpp in Sources */, 1450FF871BCFF28A00208362 /* RCTProfileTrampoline-arm.S in Sources */, 131B6AF51AF1093D00FFC3E0 /* RCTSegmentedControlManager.m in Sources */, 58114A171AAE854800E7D092 /* RCTPickerManager.m in Sources */, diff --git a/ReactCommon/yoga/Android.mk b/ReactCommon/yoga/Android.mk index e03438cb5970b9..b9a460e7ca7b99 100644 --- a/ReactCommon/yoga/Android.mk +++ b/ReactCommon/yoga/Android.mk @@ -5,13 +5,13 @@ include $(CLEAR_VARS) LOCAL_MODULE := yogacore LOCAL_SRC_FILES := \ - yoga/Yoga.c \ - yoga/YGEnums.c \ - yoga/YGNodeList.c + yoga/Yoga.cpp \ + yoga/YGEnums.cpp \ + yoga/YGNodeList.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) -LOCAL_CFLAGS := -Wall -Werror -fexceptions -frtti -std=c99 -O3 +LOCAL_CFLAGS := -Wall -Werror -fexceptions -frtti -std=c++1y -O3 include $(BUILD_STATIC_LIBRARY) diff --git a/ReactCommon/yoga/BUCK b/ReactCommon/yoga/BUCK index 20e4bdbd1fa509..6e6f1b2e998a9d 100644 --- a/ReactCommon/yoga/BUCK +++ b/ReactCommon/yoga/BUCK @@ -1,17 +1,17 @@ cxx_library( name = "yoga", - srcs = glob(["yoga/*.c"]), + srcs = glob(["yoga/*.cpp"]), + header_namespace = "", + exported_headers = glob(["yoga/*.h"]), compiler_flags = [ "-fno-omit-frame-pointer", "-fexceptions", "-Wall", "-Werror", - "-std=c99", + "-std=c++1y", "-O3", ], - exported_headers = glob(["yoga/*.h"]), force_static = True, - header_namespace = "", visibility = ["PUBLIC"], deps = [ ], diff --git a/ReactCommon/yoga/yoga.podspec b/ReactCommon/yoga/yoga.podspec index 29706c1fb75735..4d0577e80dbec5 100644 --- a/ReactCommon/yoga/yoga.podspec +++ b/ReactCommon/yoga/yoga.podspec @@ -29,7 +29,7 @@ Pod::Spec.new do |spec| '-fexceptions', '-Wall', '-Werror', - '-std=c11', + '-std=c++1y', '-fPIC' ] @@ -38,7 +38,7 @@ Pod::Spec.new do |spec| # Set this environment variable when not using the `:path` option to install the pod. # E.g. when publishing this spec to a spec repo. - source_files = 'yoga/**/*.{c,h}' + source_files = 'yoga/**/*.{cpp,h}' source_files = File.join('ReactCommon/yoga', source_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION'] spec.source_files = source_files end diff --git a/ReactCommon/yoga/yoga/YGEnums.c b/ReactCommon/yoga/yoga/YGEnums.cpp similarity index 99% rename from ReactCommon/yoga/yoga/YGEnums.c rename to ReactCommon/yoga/yoga/YGEnums.cpp index f554c367978c14..7baf5c26243020 100644 --- a/ReactCommon/yoga/yoga/YGEnums.c +++ b/ReactCommon/yoga/yoga/YGEnums.cpp @@ -224,4 +224,3 @@ const char *YGWrapToString(const YGWrap value){ } return "unknown"; } - diff --git a/ReactCommon/yoga/yoga/YGNodeList.c b/ReactCommon/yoga/yoga/YGNodeList.cpp similarity index 78% rename from ReactCommon/yoga/yoga/YGNodeList.c rename to ReactCommon/yoga/yoga/YGNodeList.cpp index 5bac4d85a58b1d..e05ffa290eeb1b 100644 --- a/ReactCommon/yoga/yoga/YGNodeList.c +++ b/ReactCommon/yoga/yoga/YGNodeList.cpp @@ -11,10 +11,6 @@ #include "YGNodeList.h" -extern YGMalloc gYGMalloc; -extern YGRealloc gYGRealloc; -extern YGFree gYGFree; - struct YGNodeList { uint32_t capacity; uint32_t count; @@ -22,21 +18,22 @@ struct YGNodeList { }; YGNodeListRef YGNodeListNew(const uint32_t initialCapacity) { - const YGNodeListRef list = gYGMalloc(sizeof(struct YGNodeList)); - YGAssert(list != NULL, "Could not allocate memory for list"); + 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 = gYGMalloc(sizeof(YGNodeRef) * list->capacity); - YGAssert(list->items != NULL, "Could not allocate memory for items"); + 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) { - gYGFree(list->items); - gYGFree(list); + free(list->items); + free(list); } } @@ -62,8 +59,9 @@ void YGNodeListInsert(YGNodeListRef *listp, const YGNodeRef node, const uint32_t if (list->count == list->capacity) { list->capacity *= 2; - list->items = gYGRealloc(list->items, sizeof(YGNodeRef) * list->capacity); - YGAssert(list->items != NULL, "Could not extend allocation for items"); + 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--) { @@ -80,18 +78,18 @@ void YGNodeListReplace(YGNodeListRef list, const uint32_t index, const YGNodeRef void YGNodeListRemoveAll(const YGNodeListRef list) { for (uint32_t i = 0; i < list->count; i++) { - list->items[i] = NULL; + 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] = NULL; + 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] = NULL; + list->items[i + 1] = nullptr; } list->count--; @@ -105,7 +103,7 @@ YGNodeRef YGNodeListDelete(const YGNodeListRef list, const YGNodeRef node) { } } - return NULL; + return nullptr; } YGNodeRef YGNodeListGet(const YGNodeListRef list, const uint32_t index) { @@ -113,16 +111,16 @@ YGNodeRef YGNodeListGet(const YGNodeListRef list, const uint32_t index) { return list->items[index]; } - return NULL; + return nullptr; } YGNodeListRef YGNodeListClone(const YGNodeListRef oldList) { if (!oldList) { - return NULL; + return nullptr; } const uint32_t count = oldList->count; if (count == 0) { - return NULL; + return nullptr; } const YGNodeListRef newList = YGNodeListNew(count); memcpy(newList->items, oldList->items, sizeof(YGNodeRef) * count); diff --git a/ReactCommon/yoga/yoga/Yoga.c b/ReactCommon/yoga/yoga/Yoga.cpp similarity index 95% rename from ReactCommon/yoga/yoga/Yoga.c rename to ReactCommon/yoga/yoga/Yoga.cpp index 252c7efe2caf5c..960a4f3bb3f582 100644 --- a/ReactCommon/yoga/yoga/Yoga.c +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -18,7 +18,6 @@ #ifndef isnan #define isnan _isnan #endif - #ifndef __cplusplus #define inline __inline #endif @@ -157,55 +156,74 @@ static const float kDefaultFlexGrow = 0.0f; static const float kDefaultFlexShrink = 0.0f; static const float kWebDefaultFlexShrink = 1.0f; +static const YGStyle gYGNodeStyleDefaults = { + .direction = YGDirectionInherit, + .flexDirection = YGFlexDirectionColumn, + .justifyContent = YGJustifyFlexStart, + .alignContent = YGAlignFlexStart, + .alignItems = YGAlignStretch, + .alignSelf = YGAlignAuto, + .positionType = YGPositionTypeRelative, + .flexWrap = YGWrapNoWrap, + .overflow = YGOverflowVisible, + .display = YGDisplayFlex, + .flex = YGUndefined, + .flexGrow = YGUndefined, + .flexShrink = YGUndefined, + .flexBasis = YG_AUTO_VALUES, + .margin = YG_DEFAULT_EDGE_VALUES_UNIT, + .position = YG_DEFAULT_EDGE_VALUES_UNIT, + .padding = YG_DEFAULT_EDGE_VALUES_UNIT, + .border = YG_DEFAULT_EDGE_VALUES_UNIT, + .dimensions = YG_DEFAULT_DIMENSION_VALUES_AUTO_UNIT, + .minDimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT, + .maxDimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT, + .aspectRatio = YGUndefined, +}; + +static const YGLayout gYGNodeLayoutDefaults = { + .position = {}, + .dimensions = YG_DEFAULT_DIMENSION_VALUES, + .margin = {}, + .border = {}, + .padding = {}, + .direction = YGDirectionInherit, + .computedFlexBasisGeneration = 0, + .computedFlexBasis = YGUndefined, + .hadOverflow = false, + .generationCount = 0, + .lastParentDirection = (YGDirection)-1, + .nextCachedMeasurementsIndex = 0, + .cachedMeasurements = {}, + .measuredDimensions = YG_DEFAULT_DIMENSION_VALUES, + .cachedLayout = + { + .availableWidth = 0, + .availableHeight = 0, + .widthMeasureMode = (YGMeasureMode)-1, + .heightMeasureMode = (YGMeasureMode)-1, + .computedWidth = -1, + .computedHeight = -1, + }, +}; + static const YGNode gYGNodeDefaults = { - .parent = NULL, - .children = NULL, - .hasNewLayout = true, + .style = gYGNodeStyleDefaults, + .layout = gYGNodeLayoutDefaults, + .lineIndex = 0, + .parent = nullptr, + .children = nullptr, + .nextChild = nullptr, + .measure = nullptr, + .baseline = nullptr, + .print = nullptr, + .config = nullptr, + .context = nullptr, .isDirty = false, + .hasNewLayout = true, .nodeType = YGNodeTypeDefault, .resolvedDimensions = {[YGDimensionWidth] = &YGValueUndefined, [YGDimensionHeight] = &YGValueUndefined}, - - .style = - { - .flex = YGUndefined, - .flexGrow = YGUndefined, - .flexShrink = YGUndefined, - .flexBasis = YG_AUTO_VALUES, - .justifyContent = YGJustifyFlexStart, - .alignItems = YGAlignStretch, - .alignContent = YGAlignFlexStart, - .direction = YGDirectionInherit, - .flexDirection = YGFlexDirectionColumn, - .overflow = YGOverflowVisible, - .display = YGDisplayFlex, - .dimensions = YG_DEFAULT_DIMENSION_VALUES_AUTO_UNIT, - .minDimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT, - .maxDimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT, - .position = YG_DEFAULT_EDGE_VALUES_UNIT, - .margin = YG_DEFAULT_EDGE_VALUES_UNIT, - .padding = YG_DEFAULT_EDGE_VALUES_UNIT, - .border = YG_DEFAULT_EDGE_VALUES_UNIT, - .aspectRatio = YGUndefined, - }, - - .layout = - { - .dimensions = YG_DEFAULT_DIMENSION_VALUES, - .lastParentDirection = (YGDirection) -1, - .nextCachedMeasurementsIndex = 0, - .computedFlexBasis = YGUndefined, - .hadOverflow = false, - .measuredDimensions = YG_DEFAULT_DIMENSION_VALUES, - - .cachedLayout = - { - .widthMeasureMode = (YGMeasureMode) -1, - .heightMeasureMode = (YGMeasureMode) -1, - .computedWidth = -1, - .computedHeight = -1, - }, - }, }; #ifdef ANDROID @@ -225,25 +243,22 @@ static int YGDefaultLog(const YGConfigRef config, static YGConfig gYGConfigDefaults = { .experimentalFeatures = { - [YGExperimentalFeatureWebFlexBasis] = false, + [YGExperimentalFeatureWebFlexBasis] = false, }, .useWebDefaults = false, + .useLegacyStretchBehaviour = false, .pointScaleFactor = 1.0f, #ifdef ANDROID .logger = &YGAndroidLog, #else .logger = &YGDefaultLog, #endif - .context = NULL, + .cloneNodeCallback = nullptr, + .context = nullptr, }; static void YGNodeMarkDirtyInternal(const YGNodeRef node); -YGMalloc gYGMalloc = &malloc; -YGCalloc gYGCalloc = &calloc; -YGRealloc gYGRealloc = &realloc; -YGFree gYGFree = &free; - static YGValue YGValueZero = {.value = 0, .unit = YGUnitPoint}; #ifdef ANDROID @@ -297,6 +312,10 @@ static int YGDefaultLog(const YGConfigRef config, } #endif +bool YGFloatIsUndefined(const float value) { + return isnan(value); +} + static inline const YGValue *YGComputedEdgeValue(const YGValue edges[YGEdgeCount], const YGEdge edge, const YGValue *const defaultValue) { @@ -346,8 +365,9 @@ int32_t gNodeInstanceCount = 0; int32_t gConfigInstanceCount = 0; WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) { - const YGNodeRef node = gYGMalloc(sizeof(YGNode)); - YGAssertWithConfig(config, node != NULL, "Could not allocate memory for node"); + const YGNodeRef node = (const YGNodeRef)malloc(sizeof(YGNode)); + YGAssertWithConfig( + config, node != nullptr, "Could not allocate memory for node"); gNodeInstanceCount++; memcpy(node, &gYGNodeDefaults, sizeof(YGNode)); @@ -364,30 +384,31 @@ YGNodeRef YGNodeNew(void) { } YGNodeRef YGNodeClone(const YGNodeRef oldNode) { - const YGNodeRef node = gYGMalloc(sizeof(YGNode)); - YGAssertWithConfig(oldNode->config, node != NULL, "Could not allocate memory for node"); + const YGNodeRef node = (const YGNodeRef)malloc(sizeof(YGNode)); + YGAssertWithConfig( + oldNode->config, node != nullptr, "Could not allocate memory for node"); gNodeInstanceCount++; memcpy(node, oldNode, sizeof(YGNode)); node->children = YGNodeListClone(oldNode->children); - node->parent = NULL; + node->parent = nullptr; return node; } void YGNodeFree(const YGNodeRef node) { if (node->parent) { YGNodeListDelete(node->parent->children, node); - node->parent = NULL; + node->parent = nullptr; } const uint32_t childCount = YGNodeGetChildCount(node); for (uint32_t i = 0; i < childCount; i++) { const YGNodeRef child = YGNodeGetChild(node, i); - child->parent = NULL; + child->parent = nullptr; } YGNodeListFree(node->children); - gYGFree(node); + free(node); gNodeInstanceCount--; } @@ -408,7 +429,10 @@ void YGNodeReset(const YGNodeRef node) { YGAssertWithNode(node, YGNodeGetChildCount(node) == 0, "Cannot reset a node which still has children attached"); - YGAssertWithNode(node, node->parent == NULL, "Cannot reset a node still attached to a parent"); + YGAssertWithNode( + node, + node->parent == nullptr, + "Cannot reset a node still attached to a parent"); YGNodeListFree(node->children); @@ -435,8 +459,8 @@ YGConfigRef YGConfigGetDefault() { } YGConfigRef YGConfigNew(void) { - const YGConfigRef config = gYGMalloc(sizeof(YGConfig)); - YGAssert(config != NULL, "Could not allocate memory for config"); + const YGConfigRef config = (const YGConfigRef)malloc(sizeof(YGConfig)); + YGAssert(config != nullptr, "Could not allocate memory for config"); gConfigInstanceCount++; memcpy(config, &gYGConfigDefaults, sizeof(YGConfig)); @@ -444,7 +468,7 @@ YGConfigRef YGConfigNew(void) { } void YGConfigFree(const YGConfigRef config) { - gYGFree(config); + free(config); gConfigInstanceCount--; } @@ -463,8 +487,8 @@ static void YGNodeMarkDirtyInternal(const YGNodeRef node) { } void YGNodeSetMeasureFunc(const YGNodeRef node, YGMeasureFunc measureFunc) { - if (measureFunc == NULL) { - node->measure = NULL; + if (measureFunc == nullptr) { + node->measure = nullptr; // TODO: t18095186 Move nodeType to opt-in function and mark appropriate places in Litho node->nodeType = YGNodeTypeDefault; } else { @@ -519,12 +543,14 @@ static void YGCloneChildrenIfNeeded(const YGNodeRef parent) { } void YGNodeInsertChild(const YGNodeRef node, const YGNodeRef child, const uint32_t index) { - YGAssertWithNode(node, - child->parent == NULL, - "Child already has a parent, it must be removed first."); - YGAssertWithNode(node, - node->measure == NULL, - "Cannot add child: Nodes with measure functions cannot have children."); + YGAssertWithNode( + node, + child->parent == nullptr, + "Child already has a parent, it must be removed first."); + YGAssertWithNode( + node, + node->measure == nullptr, + "Cannot add child: Nodes with measure functions cannot have children."); YGCloneChildrenIfNeeded(node); @@ -544,9 +570,9 @@ 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) != NULL) { + if (YGNodeListDelete(parent->children, excludedChild) != nullptr) { excludedChild->layout = gYGNodeDefaults.layout; // layout is no longer valid - excludedChild->parent = NULL; + excludedChild->parent = nullptr; YGNodeMarkDirtyInternal(parent); } return; @@ -592,14 +618,14 @@ void YGNodeRemoveAllChildren(const YGNodeRef parent) { for (uint32_t i = 0; i < childCount; i++) { const YGNodeRef oldChild = YGNodeGetChild(parent, i); oldChild->layout = gYGNodeDefaults.layout; // layout is no longer valid - oldChild->parent = NULL; + oldChild->parent = nullptr; } YGNodeListRemoveAll(parent->children); 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 = NULL; + parent->children = nullptr; YGNodeMarkDirtyInternal(parent); } @@ -616,10 +642,11 @@ uint32_t YGNodeGetChildCount(const YGNodeRef node) { } void YGNodeMarkDirty(const YGNodeRef node) { - YGAssertWithNode(node, - node->measure != NULL, - "Only leaf nodes with custom measure functions" - "should manually mark themselves as dirty"); + YGAssertWithNode( + node, + node->measure != nullptr, + "Only leaf nodes with custom measure functions" + "should manually mark themselves as dirty"); YGNodeMarkDirtyInternal(node); } @@ -637,7 +664,7 @@ void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode) { static inline float YGResolveFlexGrow(const YGNodeRef node) { // Root nodes flexGrow should always be 0 - if (node->parent == NULL) { + if (node->parent == nullptr) { return 0.0; } if (!YGFloatIsUndefined(node->style.flexGrow)) { @@ -661,7 +688,7 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) { static inline float YGNodeResolveFlexShrink(const YGNodeRef node) { // Root nodes flexShrink should always be 0 - if (node->parent == NULL) { + if (node->parent == nullptr) { return 0.0; } if (!YGFloatIsUndefined(node->style.flexShrink)) { @@ -913,10 +940,6 @@ bool YGLayoutNodeInternal(const YGNodeRef node, const char *reason, const YGConfigRef config); -inline bool YGFloatIsUndefined(const float value) { - return isnan(value); -} - static inline bool YGValueEqual(const YGValue a, const YGValue b) { if (a.unit != b.unit) { return false; @@ -930,7 +953,7 @@ static inline bool YGValueEqual(const YGValue a, const YGValue b) { } static inline void YGResolveDimensions(YGNodeRef node) { - for (YGDimension dim = YGDimensionWidth; dim <= YGDimensionHeight; dim++) { + for (uint32_t dim = YGDimensionWidth; dim < YGDimensionCount; dim++) { if (node->style.maxDimensions[dim].unit != YGUnitUndefined && YGValueEqual(node->style.maxDimensions[dim], node->style.minDimensions[dim])) { node->resolvedDimensions[dim] = &node->style.maxDimensions[dim]; @@ -959,11 +982,11 @@ static void YGWriteToStringStream(YGStringStream *stream, const char *format, .. va_list argsCopy; va_copy(argsCopy, args); int available = stream->capacity - stream->length; - int required = vsnprintf(NULL, 0, format, args); + int required = vsnprintf(nullptr, 0, format, args); va_end(args); if (required >= available) { char *newStr = (char *) realloc(stream->str, sizeof(char) * (stream->capacity) * 2); - if (newStr != NULL) { + if (newStr != nullptr) { stream->str = newStr; stream->capacity *= 2; available = stream->capacity - stream->length; @@ -1037,9 +1060,9 @@ static void YGPrintEdges(YGStringStream *stream, const char *str, const YGValue if (YGFourValuesEqual(edges)) { YGPrintNumberIfNotZero(stream, str, &edges[YGEdgeLeft]); } else { - for (YGEdge edge = YGEdgeLeft; edge < YGEdgeCount; edge++) { + for (uint32_t edge = 0; edge < YGEdgeCount; edge++) { char buf[30]; - snprintf(buf, sizeof(buf), "%s-%s", str, YGEdgeToString(edge)); + snprintf(buf, sizeof(buf), "%s-%s", str, YGEdgeToString((YGEdge)edge)); YGPrintNumberIfNotZero(stream, buf, &edges[edge]); } } @@ -1127,7 +1150,7 @@ static void YGNodeToString(YGStringStream *stream, YGPrintEdgeIfNotUndefined(stream, "bottom", node->style.position, YGEdgeBottom); YGWriteToStringStream(stream, "\" "); - if (node->measure != NULL) { + if (node->measure != nullptr) { YGWriteToStringStream(stream, "has-custom-measure=\"true\""); } } @@ -1151,7 +1174,7 @@ static void YGNodePrintInternal(const YGNodeRef node, stream.str = (char *) malloc(sizeof(char) * 1024); stream.length = 0; stream.capacity = 1024; - if (stream.str != NULL) { + if (stream.str != nullptr) { YGNodeToString(&stream, node, options, 0); YGLog(node, YGLogLevelDebug, stream.str); free(stream.str); @@ -1305,7 +1328,7 @@ static inline YGDirection YGNodeResolveDirection(const YGNodeRef node, } static float YGBaseline(const YGNodeRef node) { - if (node->baseline != NULL) { + if (node->baseline != nullptr) { const float baseline = node->baseline(node, node->layout.measuredDimensions[YGDimensionWidth], node->layout.measuredDimensions[YGDimensionHeight]); @@ -1315,7 +1338,7 @@ static float YGBaseline(const YGNodeRef node) { return baseline; } - YGNodeRef baselineChild = NULL; + YGNodeRef baselineChild = nullptr; const uint32_t childCount = YGNodeGetChildCount(node); for (uint32_t i = 0; i < childCount; i++) { const YGNodeRef child = YGNodeGetChild(node, i); @@ -1330,12 +1353,12 @@ static float YGBaseline(const YGNodeRef node) { break; } - if (baselineChild == NULL) { + if (baselineChild == nullptr) { baselineChild = child; } } - if (baselineChild == NULL) { + if (baselineChild == nullptr) { return node->layout.measuredDimensions[YGDimensionHeight]; } @@ -1563,7 +1586,8 @@ static void YGNodeSetPosition(const YGNodeRef node, const float crossSize, const float parentWidth) { /* Root nodes should be always layouted as LTR, so we don't return negative values. */ - const YGDirection directionRespectingRoot = node->parent != NULL ? direction : YGDirectionLTR; + const YGDirection directionRespectingRoot = + node->parent != nullptr ? direction : YGDirectionLTR; const YGFlexDirection mainAxis = YGResolveFlexDirection(node->style.flexDirection, directionRespectingRoot); const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, directionRespectingRoot); @@ -1889,7 +1913,10 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node, const YGMeasureMode heightMeasureMode, const float parentWidth, const float parentHeight) { - YGAssertWithNode(node, node->measure != NULL, "Expected node to have custom measure function"); + YGAssertWithNode( + node, + node->measure != nullptr, + "Expected node to have custom measure function"); const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, availableWidth); @@ -2207,8 +2234,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, const float mainAxisParentSize = isMainAxisRow ? parentWidth : parentHeight; const float crossAxisParentSize = isMainAxisRow ? parentHeight : parentWidth; - YGNodeRef firstAbsoluteChild = NULL; - YGNodeRef currentAbsoluteChild = NULL; + YGNodeRef firstAbsoluteChild = nullptr; + YGNodeRef currentAbsoluteChild = nullptr; const float leadingPaddingAndBorderMain = YGNodeLeadingPaddingAndBorder(node, mainAxis, parentWidth); @@ -2267,14 +2294,14 @@ static void YGNodelayoutImpl(const YGNodeRef node, // If there is only one child with flexGrow + flexShrink it means we can set the // computedFlexBasis to 0 instead of measuring and shrinking / flexing the child to exactly // match the remaining space - YGNodeRef singleFlexChild = NULL; + YGNodeRef singleFlexChild = nullptr; if (measureModeMainDim == YGMeasureModeExactly) { for (uint32_t i = 0; i < childCount; i++) { const YGNodeRef child = YGNodeGetChild(node, i); if (singleFlexChild) { if (YGNodeIsFlex(child)) { // There is already a flexible child, abort. - singleFlexChild = NULL; + singleFlexChild = nullptr; break; } } else if (YGResolveFlexGrow(child) > 0.0f && YGNodeResolveFlexShrink(child) > 0.0f) { @@ -2310,14 +2337,14 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (child->style.positionType == YGPositionTypeAbsolute) { // Store a private linked list of absolutely positioned children // so that we can efficiently traverse them later. - if (firstAbsoluteChild == NULL) { + if (firstAbsoluteChild == nullptr) { firstAbsoluteChild = child; } - if (currentAbsoluteChild != NULL) { + if (currentAbsoluteChild != nullptr) { currentAbsoluteChild->nextChild = child; } currentAbsoluteChild = child; - child->nextChild = NULL; + child->nextChild = nullptr; } else { if (child == singleFlexChild) { child->layout.computedFlexBasisGeneration = gCurrentGenerationCount; @@ -2381,8 +2408,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, float totalFlexShrinkScaledFactors = 0; // Maintain a linked list of the child nodes that can shrink and/or grow. - YGNodeRef firstRelativeChild = NULL; - YGNodeRef currentRelativeChild = NULL; + YGNodeRef firstRelativeChild = nullptr; + YGNodeRef currentRelativeChild = nullptr; // 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++) { @@ -2426,14 +2453,14 @@ static void YGNodelayoutImpl(const YGNodeRef node, } // Store a private linked list of children that need to be layed out. - if (firstRelativeChild == NULL) { + if (firstRelativeChild == nullptr) { firstRelativeChild = child; } - if (currentRelativeChild != NULL) { + if (currentRelativeChild != nullptr) { currentRelativeChild->nextChild = child; } currentRelativeChild = child; - child->nextChild = NULL; + child->nextChild = nullptr; } } @@ -2526,7 +2553,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, float deltaFlexShrinkScaledFactors = 0; float deltaFlexGrowFactors = 0; currentRelativeChild = firstRelativeChild; - while (currentRelativeChild != NULL) { + while (currentRelativeChild != nullptr) { childFlexBasis = fminf(YGResolveValue(¤tRelativeChild->style.maxDimensions[dim[mainAxis]], mainAxisParentSize), @@ -2594,7 +2621,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, // Second pass: resolve the sizes of the flexible items deltaFreeSpace = 0; currentRelativeChild = firstRelativeChild; - while (currentRelativeChild != NULL) { + while (currentRelativeChild != nullptr) { childFlexBasis = fminf(YGResolveValue(¤tRelativeChild->style.maxDimensions[dim[mainAxis]], mainAxisParentSize), @@ -3215,7 +3242,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (performLayout) { // STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN - for (currentAbsoluteChild = firstAbsoluteChild; currentAbsoluteChild != NULL; + for (currentAbsoluteChild = firstAbsoluteChild; + currentAbsoluteChild != nullptr; currentAbsoluteChild = currentAbsoluteChild->nextChild) { YGNodeAbsoluteLayoutChild(node, currentAbsoluteChild, @@ -3322,7 +3350,8 @@ float YGRoundValueToPixelGrid(const float value, scaledValue = scaledValue - fractial; } else { // Finally we just round the value - scaledValue = scaledValue - fractial + (fractial > 0.5f || YGFloatsEqual(fractial, 0.5f) ? 1.0f : 0.0f); + scaledValue = scaledValue - fractial + + (fractial > 0.5f || YGFloatsEqual(fractial, 0.5f) ? 1.0f : 0.0f); } return scaledValue / pointScaleFactor; } @@ -3343,7 +3372,8 @@ bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode, if (lastComputedHeight < 0 || lastComputedWidth < 0) { return false; } - bool useRoundedComparison = config != NULL && config->pointScaleFactor != 0; + bool useRoundedComparison = + config != nullptr && config->pointScaleFactor != 0; const float effectiveWidth = useRoundedComparison ? YGRoundValueToPixelGrid(width, config->pointScaleFactor, false, false) : width; @@ -3425,7 +3455,7 @@ bool YGLayoutNodeInternal(const YGNodeRef node, layout->cachedLayout.computedHeight = -1; } - YGCachedMeasurement *cachedResults = NULL; + YGCachedMeasurement* cachedResults = nullptr; // Determine whether the results are already cached. We maintain a separate // cache for layouts and measurements. A layout operation modifies the @@ -3498,7 +3528,7 @@ bool YGLayoutNodeInternal(const YGNodeRef node, } } - if (!needToVisitNode && cachedResults != NULL) { + if (!needToVisitNode && cachedResults != nullptr) { layout->measuredDimensions[YGDimensionWidth] = cachedResults->computedWidth; layout->measuredDimensions[YGDimensionHeight] = cachedResults->computedHeight; @@ -3507,27 +3537,39 @@ bool YGLayoutNodeInternal(const YGNodeRef node, if (node->print) { node->print(node); } - YGLog(node, YGLogLevelVerbose, "wm: %s, hm: %s, aw: %f ah: %f => d: (%f, %f) %s\n", - YGMeasureModeName(widthMeasureMode, performLayout), - YGMeasureModeName(heightMeasureMode, performLayout), - availableWidth, - availableHeight, - cachedResults->computedWidth, - cachedResults->computedHeight, - reason); + YGLog( + node, + YGLogLevelVerbose, + "wm: %s, hm: %s, aw: %f ah: %f => d: (%f, %f) %s\n", + YGMeasureModeName(widthMeasureMode, performLayout), + YGMeasureModeName(heightMeasureMode, performLayout), + availableWidth, + availableHeight, + cachedResults->computedWidth, + cachedResults->computedHeight, + reason); } } else { if (gPrintChanges) { - YGLog(node, YGLogLevelVerbose, "%s%d.{%s", YGSpacer(gDepth), gDepth, needToVisitNode ? "*" : ""); + YGLog( + node, + YGLogLevelVerbose, + "%s%d.{%s", + YGSpacer(gDepth), + gDepth, + needToVisitNode ? "*" : ""); if (node->print) { node->print(node); } - YGLog(node, YGLogLevelVerbose, "wm: %s, hm: %s, aw: %f ah: %f %s\n", - YGMeasureModeName(widthMeasureMode, performLayout), - YGMeasureModeName(heightMeasureMode, performLayout), - availableWidth, - availableHeight, - reason); + YGLog( + node, + YGLogLevelVerbose, + "wm: %s, hm: %s, aw: %f ah: %f %s\n", + YGMeasureModeName(widthMeasureMode, performLayout), + YGMeasureModeName(heightMeasureMode, performLayout), + availableWidth, + availableHeight, + reason); } YGNodelayoutImpl(node, @@ -3542,21 +3584,30 @@ bool YGLayoutNodeInternal(const YGNodeRef node, config); if (gPrintChanges) { - YGLog(node, YGLogLevelVerbose, "%s%d.}%s", YGSpacer(gDepth), gDepth, needToVisitNode ? "*" : ""); + YGLog( + node, + YGLogLevelVerbose, + "%s%d.}%s", + YGSpacer(gDepth), + gDepth, + needToVisitNode ? "*" : ""); if (node->print) { node->print(node); } - YGLog(node, YGLogLevelVerbose, "wm: %s, hm: %s, d: (%f, %f) %s\n", - YGMeasureModeName(widthMeasureMode, performLayout), - YGMeasureModeName(heightMeasureMode, performLayout), - layout->measuredDimensions[YGDimensionWidth], - layout->measuredDimensions[YGDimensionHeight], - reason); + YGLog( + node, + YGLogLevelVerbose, + "wm: %s, hm: %s, d: (%f, %f) %s\n", + YGMeasureModeName(widthMeasureMode, performLayout), + YGMeasureModeName(heightMeasureMode, performLayout), + layout->measuredDimensions[YGDimensionWidth], + layout->measuredDimensions[YGDimensionHeight], + reason); } layout->lastParentDirection = parentDirection; - if (cachedResults == NULL) { + if (cachedResults == nullptr) { if (layout->nextCachedMeasurementsIndex == YG_MAX_CACHED_RESULT_COUNT) { if (gPrintChanges) { YGLog(node, YGLogLevelVerbose, "Out of cache entries!\n"); @@ -3592,7 +3643,7 @@ bool YGLayoutNodeInternal(const YGNodeRef node, gDepth--; layout->generationCount = gCurrentGenerationCount; - return (needToVisitNode || cachedResults == NULL); + return (needToVisitNode || cachedResults == nullptr); } void YGConfigSetPointScaleFactor(const YGConfigRef config, const float pixelsInPoint) { @@ -3719,13 +3770,17 @@ void YGNodeCalculateLayout(const YGNodeRef node, YGRoundToPixelGrid(node, node->config->pointScaleFactor, 0.0f, 0.0f); if (gPrintTree) { - YGNodePrint(node, YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle); + YGNodePrint( + node, + (YGPrintOptions)( + YGPrintOptionsLayout | YGPrintOptionsChildren | + YGPrintOptionsStyle)); } } } void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) { - if (logger != NULL) { + if (logger != nullptr) { config->logger = logger; } else { #ifdef ANDROID @@ -3741,7 +3796,7 @@ static void YGVLog(const YGConfigRef config, YGLogLevel level, const char *format, va_list args) { - const YGConfigRef logConfig = config != NULL ? config : &gYGConfigDefaults; + const YGConfigRef logConfig = config != nullptr ? config : &gYGConfigDefaults; logConfig->logger(logConfig, node, level, format, args); if (level == YGLogLevelFatal) { @@ -3752,20 +3807,20 @@ static void YGVLog(const YGConfigRef config, void YGLogWithConfig(const YGConfigRef config, YGLogLevel level, const char *format, ...) { va_list args; va_start(args, format); - YGVLog(config, NULL, level, format, args); + YGVLog(config, nullptr, level, format, args); va_end(args); } void YGLog(const YGNodeRef node, YGLogLevel level, const char *format, ...) { va_list args; va_start(args, format); - YGVLog(node == NULL ? NULL : node->config, node, level, format, args); + YGVLog(node == nullptr ? nullptr : node->config, node, level, format, args); va_end(args); } void YGAssert(const bool condition, const char *message) { if (!condition) { - YGLog(NULL, YGLogLevelFatal, "%s\n", message); + YGLog(nullptr, YGLogLevelFatal, "%s\n", message); } } diff --git a/ReactCommon/yoga/yoga/Yoga.h b/ReactCommon/yoga/yoga/Yoga.h index b10b954b505f18..370b8f770fe19f 100644 --- a/ReactCommon/yoga/yoga/Yoga.h +++ b/ReactCommon/yoga/yoga/Yoga.h @@ -65,11 +65,6 @@ typedef void (*YGNodeClonedFunc)(YGNodeRef oldNode, YGNodeRef parent, int childIndex); -typedef void *(*YGMalloc)(size_t size); -typedef void *(*YGCalloc)(size_t count, size_t size); -typedef void *(*YGRealloc)(void *ptr, size_t size); -typedef void (*YGFree)(void *ptr); - // YGNode WIN_EXPORT YGNodeRef YGNodeNew(void); WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config);