Skip to content

Commit

Permalink
Add C# bindings for Errata API
Browse files Browse the repository at this point in the history
Summary: Wires C ABI to C# bindings using `System.Runtime.InteropServices`. Note that we don't have a working C# build right now, but there is [effort to address that](facebook#1207) which may get some more effort before the Yoga release, so this keeps the bindings up to date.

Differential Revision: https://internalfb.com/D45297676

fbshipit-source-id: 4a308833fc86b0fac8e2d8a04ca9fd08df4e35cd
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Apr 27, 2023
1 parent 6c40b61 commit ca43337
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
6 changes: 6 additions & 0 deletions csharp/Facebook.Yoga/Native.cs
Expand Up @@ -73,6 +73,12 @@ internal static class Native
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGConfigGetUseLegacyStretchBehaviour(YGConfigHandle config);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetErrata(YGConfigHandle config, YogaErrata errata);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaErrata YGConfigGetErrata(YGConfigHandle config);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetPointScaleFactor(
YGConfigHandle config,
Expand Down
21 changes: 19 additions & 2 deletions csharp/Facebook.Yoga/YogaConfig.cs
Expand Up @@ -117,8 +117,12 @@ public bool UseWebDefaults
}
}

public bool UseLegacyStretchBehaviour
{
[ObsoleteAttribute("\"UseLegacyStretchBehaviour\" will be removed in the next release. " +
"Usage should be replaced with \"Errata\" set to \"YogaErrata.All\" to opt out of all " +
"future breaking conformance fixes, or \"YogaErrata.StretchFlexBasis\" toopt out of " +
"the specific conformance fix previously disabled by \"UseLegacyStretchBehaviour\".",
true /*error*/)]
public bool UseLegacyStretchBehaviour {
get
{
return Native.YGConfigGetUseLegacyStretchBehaviour(_ygConfig);
Expand All @@ -130,6 +134,19 @@ public bool UseLegacyStretchBehaviour
}
}

public YogaErrata Errata
{
get
{
return Native.YGConfigGetErrata(_ygConfig);
}

set
{
Native.YGConfigSetErrata(_ygConfig, value);
}
}

public float PointScaleFactor
{
set
Expand Down

0 comments on commit ca43337

Please sign in to comment.