From 3201e24780e5a758589c383113ae54f9e6348705 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Thu, 27 Oct 2016 11:38:32 -0700 Subject: [PATCH] Fix build and clean up Summary: - bit operation with long - Clean up _measureOutput which is no longer needed - Fix unittests (SetMeasureFunction, unused error) Reviewed By: emilsjolander Differential Revision: D4082401 fbshipit-source-id: b3b2dd002d108c5b43f36a4a73ce8e5233281b45 --- csharp/CSSLayout/CSSInterop.h | 0 csharp/Facebook.CSSLayout/CSSNode.cs | 12 +----------- csharp/Facebook.CSSLayout/MeasureOutput.cs | 2 +- csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs | 6 +++--- 4 files changed, 5 insertions(+), 15 deletions(-) mode change 100755 => 100644 csharp/CSSLayout/CSSInterop.h diff --git a/csharp/CSSLayout/CSSInterop.h b/csharp/CSSLayout/CSSInterop.h old mode 100755 new mode 100644 diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.CSSLayout/CSSNode.cs index dff4e5fb..1648617f 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.cs @@ -22,7 +22,6 @@ namespace Facebook.CSSLayout private List _children; private MeasureFunction _measureFunction; private CSSMeasureFunc _cssMeasureFunc; - private MeasureOutput _measureOutput; private object _data; public CSSNode() @@ -509,16 +508,7 @@ namespace Facebook.CSSLayout public void SetMeasureFunction(MeasureFunction measureFunction) { _measureFunction = measureFunction; - if (measureFunction != null) - { - _cssMeasureFunc = MeasureInternal; - _measureOutput = new MeasureOutput(); - } - else - { - _cssMeasureFunc = null; - _measureOutput = null; - } + _cssMeasureFunc = measureFunction != null ? MeasureInternal : (CSSMeasureFunc)null; Native.CSSNodeSetMeasureFunc(_cssNode, _cssMeasureFunc); } diff --git a/csharp/Facebook.CSSLayout/MeasureOutput.cs b/csharp/Facebook.CSSLayout/MeasureOutput.cs index ef3ce1d7..5fabf348 100644 --- a/csharp/Facebook.CSSLayout/MeasureOutput.cs +++ b/csharp/Facebook.CSSLayout/MeasureOutput.cs @@ -13,7 +13,7 @@ namespace Facebook.CSSLayout { public static long Make(int width, int height) { - return ((long) width) << 32 | ((long) height); + return (long)(((ulong) width) << 32 | ((ulong) height)); } public static int GetWidth(long measureOutput) diff --git a/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs b/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs index 7ebd3f96..f46ef24d 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs @@ -44,6 +44,7 @@ namespace Facebook.CSSLayout { CSSNode parent = new CSSNode(); foreach (CSSNode node in parent) { + Assert.Fail(node.ToString()); } CSSNode child0 = new CSSNode(); @@ -302,9 +303,8 @@ namespace Facebook.CSSLayout { CSSNode child = new CSSNode(); parent.Insert(0, child); - child.SetMeasureFunction((_, width, widthMode, height, heightMode, measureResult) => { - measureResult.Width = 120; - measureResult.Height = 130; + child.SetMeasureFunction((_, width, widthMode, height, heightMode) => { + return MeasureOutput.Make(120, 130); }); } #endif