Support IL2CPP and fix stale handle

Summary:
- Unity IL2CPP (ENABLE_IL2CPP) requires the same code path with AOT compile.
- Clean up unneeded code in YGConfigHandle.
- YogaNode.Reset makes YGNodeHandle stale. Unmanaged side was reset by YGNodeReset, but YGNodeHandle keeps to retain the old managed handle. Release it.
Closes https://github.com/facebook/yoga/pull/491

Reviewed By: astreet

Differential Revision: D4765683

Pulled By: splhack

fbshipit-source-id: 83bfe19feb0e6ec45dc504e42b0c6c34e10af8e2
This commit is contained in:
Kazuki Sakamoto
2017-03-27 07:57:54 -07:00
committed by Facebook Github Bot
parent d342fb1879
commit 91a34bb875
3 changed files with 39 additions and 30 deletions

View File

@@ -12,12 +12,15 @@ using System.Collections;
using System.Collections.Generic;
using System.Text;
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
using System.Runtime.InteropServices;
#endif
#if __IOS__
using ObjCRuntime;
#endif
#if ENABLE_IL2CPP
using AOT;
#endif
namespace Facebook.Yoga
{
@@ -63,7 +66,7 @@ namespace Facebook.Yoga
private MeasureFunction _measureFunction;
private BaselineFunction _baselineFunction;
private object _data;
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
private static YogaMeasureFunc _managedMeasure;
private static YogaBaselineFunc _managedBaseline;
#else
@@ -106,6 +109,9 @@ namespace Facebook.Yoga
_data = null;
Native.YGNodeReset(_ygNode);
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
_ygNode.ReleaseManaged();
#endif
}
public bool IsDirty
@@ -616,8 +622,8 @@ namespace Facebook.Yoga
_measureFunction = measureFunction;
if (measureFunction != null)
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
_managedMeasure = MeasureInternalIOS;
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
_managedMeasure = MeasureInternalAOT;
_ygNode.SetContext(this);
#else
_managedMeasure = MeasureInternal;
@@ -635,8 +641,8 @@ namespace Facebook.Yoga
_baselineFunction = baselineFunction;
if (baselineFunction != null)
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
_managedBaseline = BaselineInternalIOS;
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
_managedBaseline = BaselineInternalAOT;
_ygNode.SetContext(this);
#else
_managedBaseline = BaselineInternal;
@@ -658,9 +664,9 @@ namespace Facebook.Yoga
Native.YGNodeStyleGetDirection(_ygNode));
}
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
[MonoPInvokeCallback(typeof(YogaMeasureFunc))]
private static YogaSize MeasureInternalIOS(
private static YogaSize MeasureInternalAOT(
IntPtr ygNodePtr,
float width,
YogaMeasureMode widthMode,
@@ -687,9 +693,9 @@ namespace Facebook.Yoga
return _measureFunction(this, width, widthMode, height, heightMode);
}
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
[MonoPInvokeCallback(typeof(YogaBaselineFunc))]
private static float BaselineInternalIOS(
private static float BaselineInternalAOT(
IntPtr ygNodePtr,
float width,
float height)