Skip to content

Commit a532829

Browse files
rozeleopenvela-robot
authored andcommitted
Adds fixes for react-native-windows UWP (#848)
Summary: Specifically, updates the UWP .vcxproj for MSBuild and also exposes the UseLegacyStretchBehaviour API for use with react-native-windows. Pull Request resolved: facebook/yoga#848 Reviewed By: SidharthGuglani Differential Revision: D13848609 Pulled By: davidaurelio fbshipit-source-id: eab046ff3c47e49706f515e209d8aaf750c2198f
1 parent 90071b5 commit a532829

11 files changed

Lines changed: 155 additions & 113 deletions

File tree

csharp/Facebook.Yoga/Native.cs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010

1111
namespace Facebook.Yoga
1212
{
13-
#if WINDOWS_UWP_ARM
14-
using YogaValueType = IntPtr;
15-
#else
16-
using YogaValueType = YogaValue;
17-
#endif
18-
1913
internal static class Native
2014
{
2115
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
@@ -74,6 +68,14 @@ public static extern void YGConfigSetUseWebDefaults(
7468
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
7569
public static extern bool YGConfigGetUseWebDefaults(YGConfigHandle config);
7670

71+
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
72+
public static extern void YGConfigSetUseLegacyStretchBehaviour(
73+
YGConfigHandle config,
74+
bool useLegacyStretchBehavior);
75+
76+
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
77+
public static extern bool YGConfigGetUseLegacyStretchBehaviour(YGConfigHandle config);
78+
7779
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
7880
public static extern void YGConfigSetPointScaleFactor(
7981
YGConfigHandle config,
@@ -226,7 +228,7 @@ public static extern void YGNodeSetHasNewLayout(
226228
public static extern void YGNodeStyleSetFlexBasisAuto(YGNodeHandle node);
227229

228230
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
229-
public static extern YogaValueType YGNodeStyleGetFlexBasis(YGNodeHandle node);
231+
public static extern YogaValue YGNodeStyleGetFlexBasis(YGNodeHandle node);
230232

231233
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
232234
public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width);
@@ -238,7 +240,7 @@ public static extern void YGNodeSetHasNewLayout(
238240
public static extern void YGNodeStyleSetWidthAuto(YGNodeHandle node);
239241

240242
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
241-
public static extern YogaValueType YGNodeStyleGetWidth(YGNodeHandle node);
243+
public static extern YogaValue YGNodeStyleGetWidth(YGNodeHandle node);
242244

243245
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
244246
public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height);
@@ -250,7 +252,7 @@ public static extern void YGNodeSetHasNewLayout(
250252
public static extern void YGNodeStyleSetHeightAuto(YGNodeHandle node);
251253

252254
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
253-
public static extern YogaValueType YGNodeStyleGetHeight(YGNodeHandle node);
255+
public static extern YogaValue YGNodeStyleGetHeight(YGNodeHandle node);
254256

255257
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
256258
public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth);
@@ -259,7 +261,7 @@ public static extern void YGNodeSetHasNewLayout(
259261
public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth);
260262

261263
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
262-
public static extern YogaValueType YGNodeStyleGetMinWidth(YGNodeHandle node);
264+
public static extern YogaValue YGNodeStyleGetMinWidth(YGNodeHandle node);
263265

264266
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
265267
public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight);
@@ -268,7 +270,7 @@ public static extern void YGNodeSetHasNewLayout(
268270
public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight);
269271

270272
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
271-
public static extern YogaValueType YGNodeStyleGetMinHeight(YGNodeHandle node);
273+
public static extern YogaValue YGNodeStyleGetMinHeight(YGNodeHandle node);
272274

273275
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
274276
public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth);
@@ -277,7 +279,7 @@ public static extern void YGNodeSetHasNewLayout(
277279
public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth);
278280

279281
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
280-
public static extern YogaValueType YGNodeStyleGetMaxWidth(YGNodeHandle node);
282+
public static extern YogaValue YGNodeStyleGetMaxWidth(YGNodeHandle node);
281283

282284
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
283285
public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight);
@@ -286,7 +288,7 @@ public static extern void YGNodeSetHasNewLayout(
286288
public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight);
287289

288290
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
289-
public static extern YogaValueType YGNodeStyleGetMaxHeight(YGNodeHandle node);
291+
public static extern YogaValue YGNodeStyleGetMaxHeight(YGNodeHandle node);
290292

291293
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
292294
public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio);
@@ -305,7 +307,7 @@ public static extern void YGNodeSetHasNewLayout(
305307
public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position);
306308

307309
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
308-
public static extern YogaValueType YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
310+
public static extern YogaValue YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
309311

310312
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
311313
public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin);
@@ -317,7 +319,7 @@ public static extern void YGNodeSetHasNewLayout(
317319
public static extern void YGNodeStyleSetMarginAuto(YGNodeHandle node, YogaEdge edge);
318320

319321
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
320-
public static extern YogaValueType YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
322+
public static extern YogaValue YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
321323

322324
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
323325
public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding);
@@ -326,7 +328,7 @@ public static extern void YGNodeSetHasNewLayout(
326328
public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding);
327329

328330
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
329-
public static extern YogaValueType YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
331+
public static extern YogaValue YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
330332

331333
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
332334
public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border);

csharp/Facebook.Yoga/YogaConfig.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* Copyright (c) Facebook, Inc. and its affiliates.
33
*
44
* This source code is licensed under the MIT license found in the
@@ -117,6 +117,19 @@ public bool UseWebDefaults
117117
}
118118
}
119119

120+
public bool UseLegacyStretchBehaviour
121+
{
122+
get
123+
{
124+
return Native.YGConfigGetUseLegacyStretchBehaviour(_ygConfig);
125+
}
126+
127+
set
128+
{
129+
Native.YGConfigSetUseLegacyStretchBehaviour(_ygConfig, value);
130+
}
131+
}
132+
120133
public float PointScaleFactor
121134
{
122135
set

csharp/Facebook.Yoga/YogaNode.Spacing.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* Copyright (c) Facebook, Inc. and its affiliates.
33
*
44
* This source code is licensed under the MIT license found in the
@@ -13,7 +13,7 @@ public YogaValue Left
1313
{
1414
get
1515
{
16-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left));
16+
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left);
1717
}
1818

1919
set
@@ -26,7 +26,7 @@ public YogaValue Top
2626
{
2727
get
2828
{
29-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top));
29+
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top);
3030
}
3131

3232
set
@@ -39,7 +39,7 @@ public YogaValue Right
3939
{
4040
get
4141
{
42-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right));
42+
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right);
4343
}
4444

4545
set
@@ -52,7 +52,7 @@ public YogaValue Bottom
5252
{
5353
get
5454
{
55-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom));
55+
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom);
5656
}
5757

5858
set
@@ -65,7 +65,7 @@ public YogaValue Start
6565
{
6666
get
6767
{
68-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start));
68+
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start);
6969
}
7070

7171
set
@@ -78,7 +78,7 @@ public YogaValue End
7878
{
7979
get
8080
{
81-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End));
81+
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End);
8282
}
8383

8484
set
@@ -103,7 +103,7 @@ public YogaValue MarginLeft
103103
{
104104
get
105105
{
106-
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left));
106+
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left);
107107
}
108108

109109
set
@@ -116,7 +116,7 @@ public YogaValue MarginTop
116116
{
117117
get
118118
{
119-
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top));
119+
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top);
120120
}
121121

122122
set
@@ -129,7 +129,7 @@ public YogaValue MarginRight
129129
{
130130
get
131131
{
132-
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right));
132+
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right);
133133
}
134134

135135
set
@@ -142,7 +142,7 @@ public YogaValue MarginBottom
142142
{
143143
get
144144
{
145-
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom));
145+
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom);
146146
}
147147

148148
set
@@ -155,7 +155,7 @@ public YogaValue MarginStart
155155
{
156156
get
157157
{
158-
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start));
158+
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start);
159159
}
160160

161161
set
@@ -168,7 +168,7 @@ public YogaValue MarginEnd
168168
{
169169
get
170170
{
171-
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End));
171+
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End);
172172
}
173173

174174
set
@@ -181,7 +181,7 @@ public YogaValue MarginHorizontal
181181
{
182182
get
183183
{
184-
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal));
184+
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal);
185185
}
186186

187187
set
@@ -194,7 +194,7 @@ public YogaValue MarginVertical
194194
{
195195
get
196196
{
197-
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical));
197+
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical);
198198
}
199199

200200
set
@@ -207,7 +207,7 @@ public YogaValue Margin
207207
{
208208
get
209209
{
210-
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All));
210+
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All);
211211
}
212212

213213
set
@@ -236,7 +236,7 @@ public YogaValue PaddingLeft
236236
{
237237
get
238238
{
239-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left));
239+
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left);
240240
}
241241

242242
set
@@ -249,7 +249,7 @@ public YogaValue PaddingTop
249249
{
250250
get
251251
{
252-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top));
252+
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top);
253253
}
254254

255255
set
@@ -262,7 +262,7 @@ public YogaValue PaddingRight
262262
{
263263
get
264264
{
265-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right));
265+
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right);
266266
}
267267

268268
set
@@ -275,7 +275,7 @@ public YogaValue PaddingBottom
275275
{
276276
get
277277
{
278-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom));
278+
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom);
279279
}
280280

281281
set
@@ -288,7 +288,7 @@ public YogaValue PaddingStart
288288
{
289289
get
290290
{
291-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start));
291+
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start);
292292
}
293293

294294
set
@@ -301,7 +301,7 @@ public YogaValue PaddingEnd
301301
{
302302
get
303303
{
304-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End));
304+
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End);
305305
}
306306

307307
set
@@ -314,7 +314,7 @@ public YogaValue PaddingHorizontal
314314
{
315315
get
316316
{
317-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal));
317+
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal);
318318
}
319319

320320
set
@@ -327,7 +327,7 @@ public YogaValue PaddingVertical
327327
{
328328
get
329329
{
330-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical));
330+
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical);
331331
}
332332

333333
set
@@ -340,7 +340,7 @@ public YogaValue Padding
340340
{
341341
get
342342
{
343-
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All));
343+
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All);
344344
}
345345

346346
set

0 commit comments

Comments
 (0)