move yg node new and ygnode new with config

Summary: YGNode creation methods to vanilla JNI

Reviewed By: amir-shalem

Differential Revision: D17714230

fbshipit-source-id: 74e14e876ab7efc67771d92091c2a78f09072b83
This commit is contained in:
Sidharth Guglani
2019-10-08 17:48:32 -07:00
committed by Facebook Github Bot
parent 34739ec652
commit 22a60e82b0
5 changed files with 47 additions and 1 deletions

View File

@@ -125,6 +125,9 @@ public class YogaNative {
static native void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI(long nativePointer, boolean shouldDiffLayoutWithoutLegacyStretchBehaviour);
// static native void jni_YGConfigSetLoggerJNI(long nativePointer, Object logger);
// YGNode related
static native long jni_YGNodeNewJNI();
static native long jni_YGNodeNewWithConfigJNI(long configPointer);
static native void jni_YGNodeFreeJNI(long nativePointer);
static native void jni_YGNodeResetJNI(long nativePointer);
static native void jni_YGNodeInsertChildJNI(long nativePointer, long childPointer, int index);

View File

@@ -5,6 +5,10 @@ public abstract class YogaNodeFactory {
return new YogaNodeJNIFinalizer();
}
public static YogaNode create(boolean useVanillaJNI) {
return new YogaNodeJNIFinalizer(useVanillaJNI);
}
public static YogaNode create(YogaConfig config) {
return new YogaNodeJNIFinalizer(config);
}

View File

@@ -59,8 +59,12 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
this(YogaNative.jni_YGNodeNew());
}
YogaNodeJNIBase(boolean useVanillaJNI) {
this(useVanillaJNI ? YogaNative.jni_YGNodeNewJNI() : YogaNative.jni_YGNodeNew());
}
YogaNodeJNIBase(YogaConfig config) {
this(YogaNative.jni_YGNodeNewWithConfig(((YogaConfigJNIBase)config).mNativePointer));
this(config.useVanillaJNI() ? YogaNative.jni_YGNodeNewWithConfigJNI(((YogaConfigJNIBase)config).mNativePointer) : YogaNative.jni_YGNodeNewWithConfig(((YogaConfigJNIBase)config).mNativePointer));
this.useVanillaJNI = config.useVanillaJNI();
}

View File

@@ -11,6 +11,10 @@ public class YogaNodeJNIFinalizer extends YogaNodeJNIBase {
super();
}
public YogaNodeJNIFinalizer(boolean useVanillaJNI) {
super(useVanillaJNI);
}
public YogaNodeJNIFinalizer(YogaConfig config) {
super(config);
}