Remove useVanillaJNI flag and usage of fbjni in yoga build

Summary:
## Changelog:

[General] [Yoga] - Use vanilla jni instead of fbjni for all the jni communication

Reviewed By: astreet

Differential Revision: D17808005

fbshipit-source-id: 5e9a1ed73978f519c71c248774a28e5a294e7c7f
This commit is contained in:
Sidharth Guglani
2019-11-13 15:13:02 -08:00
committed by Facebook Github Bot
parent 5960dd888d
commit f99da09716
18 changed files with 125 additions and 1278 deletions

View File

@@ -3,7 +3,7 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID", "CXX_LIBRARY_WHITELIST", "FBJNI_JAVA_TARGET", "FBJNI_TARGET", "JNI_TARGET", "JSR_305_TARGET", "JUNIT_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "yoga_cxx_lib", "yoga_cxx_library", "yoga_dep", "yoga_java_binary", "yoga_java_library", "yoga_java_test")
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID", "CXX_LIBRARY_WHITELIST", "JNI_TARGET", "JSR_305_TARGET", "JUNIT_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "YOGA_ROOTS", "yoga_cxx_lib", "yoga_cxx_library", "yoga_dep", "yoga_java_binary", "yoga_java_library", "yoga_java_test", "yoga_prebuilt_cxx_library")
CXX_LIBRARY_WHITELIST_FOR_TESTS = CXX_LIBRARY_WHITELIST + [
yoga_cxx_lib("testutil:jni"),
@@ -16,6 +16,18 @@ YOGA_JAVA_IMPLEMENTATION_FILES = [
"com/facebook/yoga/YogaNative.java",
]
yoga_prebuilt_cxx_library(
name = "ndklog",
exported_platform_linker_flags = [
(
"^android.*",
["-llog"],
),
],
header_only = True,
visibility = YOGA_ROOTS,
)
yoga_cxx_library(
name = "jni",
srcs = glob(["jni/*.cpp"]),
@@ -41,9 +53,9 @@ yoga_cxx_library(
soname = "libyoga.$(ext)",
visibility = ["PUBLIC"],
deps = [
FBJNI_TARGET,
JNI_TARGET,
yoga_dep(":yoga"),
":ndklog",
],
)
@@ -72,7 +84,6 @@ yoga_java_library(
deps = [
":java-interface",
":jni",
FBJNI_JAVA_TARGET,
JSR_305_TARGET,
PROGRUARD_ANNOTATIONS_TARGET,
SOLOADER_TARGET,
@@ -111,6 +122,5 @@ yoga_java_binary(
name = "yoga",
deps = [
":java",
FBJNI_JAVA_TARGET,
],
)

View File

@@ -8,17 +8,14 @@ cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_VERBOSE_MAKEFILE on)
# configure import libs
set(libfb_DIR ${CMAKE_SOURCE_DIR}/../lib/fb/src/main/cpp)
set(yogacore_DIR ${CMAKE_SOURCE_DIR}/..)
set(build_DIR ${CMAKE_SOURCE_DIR}/build)
set(libfb_build_DIR ${build_DIR}/libfb/${ANDROID_ABI})
set(yogacore_build_DIR ${build_DIR}/yogacore/${ANDROID_ABI})
file(MAKE_DIRECTORY ${build_DIR})
add_subdirectory(${libfb_DIR} ${libfb_build_DIR})
add_subdirectory(${yogacore_DIR} ${yogacore_build_DIR})
add_compile_options(
@@ -36,7 +33,6 @@ file(GLOB jni_SRC
add_library(yoga SHARED ${jni_SRC})
target_include_directories(yoga PRIVATE
${libfb_DIR}/include
${yogacore_DIR})
target_link_libraries(yoga -Wl,--gc-sections yogacore fb)
target_link_libraries(yoga -Wl,--gc-sections yogacore)

View File

@@ -38,8 +38,4 @@ public abstract class YogaConfig {
public abstract YogaLogger getLogger();
abstract long getNativePointer();
public abstract void setUseVanillaJNI(boolean useVanillaJNI);
public abstract boolean useVanillaJNI();
}

View File

@@ -11,8 +11,4 @@ public abstract class YogaConfigFactory {
public static YogaConfig create() {
return new YogaConfigJNIFinalizer();
}
public static YogaConfig create(boolean useVanillaJNI) {
return new YogaConfigJNIFinalizer(useVanillaJNI);
}
}

View File

@@ -11,7 +11,6 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
long mNativePointer;
private YogaLogger mLogger;
protected boolean useVanillaJNI = false;
private YogaConfigJNIBase(long nativePointer) {
if (nativePointer == 0) {
@@ -21,40 +20,27 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
}
YogaConfigJNIBase() {
this(YogaNative.jni_YGConfigNew());
this(YogaNative.jni_YGConfigNewJNI());
}
YogaConfigJNIBase(boolean useVanillaJNI) {
this(useVanillaJNI ? YogaNative.jni_YGConfigNewJNI() : YogaNative.jni_YGConfigNew());
this.useVanillaJNI = useVanillaJNI;
this(YogaNative.jni_YGConfigNewJNI());
}
public void setExperimentalFeatureEnabled(YogaExperimentalFeature feature, boolean enabled) {
if (useVanillaJNI)
YogaNative.jni_YGConfigSetExperimentalFeatureEnabledJNI(mNativePointer, feature.intValue(), enabled);
else
YogaNative.jni_YGConfigSetExperimentalFeatureEnabled(mNativePointer, feature.intValue(), enabled);
YogaNative.jni_YGConfigSetExperimentalFeatureEnabledJNI(mNativePointer, feature.intValue(), enabled);
}
public void setUseWebDefaults(boolean useWebDefaults) {
if (useVanillaJNI)
YogaNative.jni_YGConfigSetUseWebDefaultsJNI(mNativePointer, useWebDefaults);
else
YogaNative.jni_YGConfigSetUseWebDefaults(mNativePointer, useWebDefaults);
YogaNative.jni_YGConfigSetUseWebDefaultsJNI(mNativePointer, useWebDefaults);
}
public void setPrintTreeFlag(boolean enable) {
if (useVanillaJNI)
YogaNative.jni_YGConfigSetPrintTreeFlagJNI(mNativePointer, enable);
else
YogaNative.jni_YGConfigSetPrintTreeFlag(mNativePointer, enable);
YogaNative.jni_YGConfigSetPrintTreeFlagJNI(mNativePointer, enable);
}
public void setPointScaleFactor(float pixelsInPoint) {
if (useVanillaJNI)
YogaNative.jni_YGConfigSetPointScaleFactorJNI(mNativePointer, pixelsInPoint);
else
YogaNative.jni_YGConfigSetPointScaleFactor(mNativePointer, pixelsInPoint);
YogaNative.jni_YGConfigSetPointScaleFactorJNI(mNativePointer, pixelsInPoint);
}
/**
@@ -63,10 +49,7 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
* Because this was such a long-standing bug we must allow legacy users to switch back to this behaviour.
*/
public void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour) {
if (useVanillaJNI)
YogaNative.jni_YGConfigSetUseLegacyStretchBehaviourJNI(mNativePointer, useLegacyStretchBehaviour);
else
YogaNative.jni_YGConfigSetUseLegacyStretchBehaviour(mNativePointer, useLegacyStretchBehaviour);
YogaNative.jni_YGConfigSetUseLegacyStretchBehaviourJNI(mNativePointer, useLegacyStretchBehaviour);
}
/**
@@ -76,20 +59,13 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
*/
public void setShouldDiffLayoutWithoutLegacyStretchBehaviour(
boolean shouldDiffLayoutWithoutLegacyStretchBehaviour) {
if (useVanillaJNI)
YogaNative.jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI(
mNativePointer, shouldDiffLayoutWithoutLegacyStretchBehaviour);
else
YogaNative.jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
mNativePointer, shouldDiffLayoutWithoutLegacyStretchBehaviour);
}
public void setLogger(YogaLogger logger) {
mLogger = logger;
if (useVanillaJNI)
YogaNative.jni_YGConfigSetLoggerJNI(mNativePointer, logger);
else
YogaNative.jni_YGConfigSetLogger(mNativePointer, logger);
YogaNative.jni_YGConfigSetLoggerJNI(mNativePointer, logger);
}
public YogaLogger getLogger() {
@@ -99,14 +75,4 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
long getNativePointer() {
return mNativePointer;
}
@Override
public void setUseVanillaJNI(boolean useVanillaJNI) {
this.useVanillaJNI = useVanillaJNI;
}
@Override
public boolean useVanillaJNI() {
return this.useVanillaJNI;
}
}

View File

@@ -12,10 +12,6 @@ public class YogaConfigJNIFinalizer extends YogaConfigJNIBase {
super();
}
public YogaConfigJNIFinalizer(boolean useVanillaJNI) {
super(useVanillaJNI);
}
@Override
protected void finalize() throws Throwable {
try {
@@ -29,10 +25,7 @@ public class YogaConfigJNIFinalizer extends YogaConfigJNIBase {
if (mNativePointer != 0) {
long nativePointer = mNativePointer;
mNativePointer = 0;
if (useVanillaJNI)
YogaNative.jni_YGConfigFreeJNI(nativePointer);
else
YogaNative.jni_YGConfigFree(nativePointer);
YogaNative.jni_YGConfigFreeJNI(nativePointer);
}
}
}

View File

@@ -15,105 +15,7 @@ public class YogaNative {
static {
SoLoader.loadLibrary("yoga");
}
// YGConfig related
static native long jni_YGConfigNew();
static native void jni_YGConfigFree(long nativePointer);
static native void jni_YGConfigSetExperimentalFeatureEnabled(long nativePointer, int feature, boolean enabled);
static native void jni_YGConfigSetUseWebDefaults(long nativePointer, boolean useWebDefaults);
static native void jni_YGConfigSetPrintTreeFlag(long nativePointer, boolean enable);
static native void jni_YGConfigSetPointScaleFactor(long nativePointer, float pixelsInPoint);
static native void jni_YGConfigSetUseLegacyStretchBehaviour(long nativePointer, boolean useLegacyStretchBehaviour);
static native void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(long nativePointer, boolean shouldDiffLayoutWithoutLegacyStretchBehaviour);
static native void jni_YGConfigSetLogger(long nativePointer, Object logger);
// YGNode related
static native long jni_YGNodeNew();
static native long jni_YGNodeNewWithConfig(long configPointer);
static native void jni_YGNodeFree(long nativePointer);
static native void jni_YGNodeReset(long nativePointer);
static native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
static native void jni_YGNodeSetIsReferenceBaseline(long nativePointer, boolean isReferenceBaseline);
static native boolean jni_YGNodeIsReferenceBaseline(long nativePointer);
static native void jni_YGNodeClearChildren(long nativePointer);
static native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
static native void jni_YGNodeCalculateLayout(long nativePointer, float width, float height, long[] nativePointers, YogaNodeJNIBase[] nodes);
static native void jni_YGNodeMarkDirty(long nativePointer);
static native void jni_YGNodeMarkDirtyAndPropogateToDescendants(long nativePointer);
static native boolean jni_YGNodeIsDirty(long nativePointer);
static native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
static native int jni_YGNodeStyleGetDirection(long nativePointer);
static native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
static native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
static native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
static native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
static native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
static native int jni_YGNodeStyleGetAlignItems(long nativePointer);
static native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
static native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
static native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
static native int jni_YGNodeStyleGetAlignContent(long nativePointer);
static native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
static native int jni_YGNodeStyleGetPositionType(long nativePointer);
static native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
static native int jni_YGNodeStyleGetFlexWrap(long nativePointer);
static native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType);
static native int jni_YGNodeStyleGetOverflow(long nativePointer);
static native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
static native int jni_YGNodeStyleGetDisplay(long nativePointer);
static native void jni_YGNodeStyleSetDisplay(long nativePointer, int display);
static native float jni_YGNodeStyleGetFlex(long nativePointer);
static native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
static native float jni_YGNodeStyleGetFlexGrow(long nativePointer);
static native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
static native float jni_YGNodeStyleGetFlexShrink(long nativePointer);
static native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
static native long jni_YGNodeStyleGetFlexBasis(long nativePointer);
static native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
static native void jni_YGNodeStyleSetFlexBasisPercent(long nativePointer, float percent);
static native void jni_YGNodeStyleSetFlexBasisAuto(long nativePointer);
static native long jni_YGNodeStyleGetMargin(long nativePointer, int edge);
static native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
static native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent);
static native void jni_YGNodeStyleSetMarginAuto(long nativePointer, int edge);
static native long jni_YGNodeStyleGetPadding(long nativePointer, int edge);
static native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
static native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent);
static native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
static native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
static native long jni_YGNodeStyleGetPosition(long nativePointer, int edge);
static native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
static native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent);
static native long jni_YGNodeStyleGetWidth(long nativePointer);
static native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
static native void jni_YGNodeStyleSetWidthPercent(long nativePointer, float percent);
static native void jni_YGNodeStyleSetWidthAuto(long nativePointer);
static native long jni_YGNodeStyleGetHeight(long nativePointer);
static native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
static native void jni_YGNodeStyleSetHeightPercent(long nativePointer, float percent);
static native void jni_YGNodeStyleSetHeightAuto(long nativePointer);
static native long jni_YGNodeStyleGetMinWidth(long nativePointer);
static native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
static native void jni_YGNodeStyleSetMinWidthPercent(long nativePointer, float percent);
static native long jni_YGNodeStyleGetMinHeight(long nativePointer);
static native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
static native void jni_YGNodeStyleSetMinHeightPercent(long nativePointer, float percent);
static native long jni_YGNodeStyleGetMaxWidth(long nativePointer);
static native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
static native void jni_YGNodeStyleSetMaxWidthPercent(long nativePointer, float percent);
static native long jni_YGNodeStyleGetMaxHeight(long nativePointer);
static native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
static native void jni_YGNodeStyleSetMaxHeightPercent(long nativePointer, float percent);
static native float jni_YGNodeStyleGetAspectRatio(long nativePointer);
static native void jni_YGNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
static native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
static native void jni_YGNodeSetHasBaselineFunc(long nativePointer, boolean hasMeasureFunc);
static native void jni_YGNodePrint(long nativePointer);
static native void jni_YGNodeSetStyleInputs(long nativePointer, float[] styleInputsArray, int size);
static native long jni_YGNodeClone(long nativePointer);
// JNI methods that use Vanilla JNI
// YGConfig related
static native long jni_YGConfigNewJNI();

View File

@@ -12,10 +12,6 @@ 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

@@ -47,8 +47,6 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
private boolean mHasNewLayout = true;
protected boolean useVanillaJNI = false;
private YogaNodeJNIBase(long nativePointer) {
if (nativePointer == 0) {
throw new IllegalStateException("Failed to allocate native memory");
@@ -57,17 +55,11 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
}
YogaNodeJNIBase() {
this(YogaNative.jni_YGNodeNew());
}
YogaNodeJNIBase(boolean useVanillaJNI) {
this(useVanillaJNI ? YogaNative.jni_YGNodeNewJNI() : YogaNative.jni_YGNodeNew());
this.useVanillaJNI = useVanillaJNI;
this(YogaNative.jni_YGNodeNewJNI());
}
YogaNodeJNIBase(YogaConfig config) {
this(config.useVanillaJNI() ? YogaNative.jni_YGNodeNewWithConfigJNI(((YogaConfigJNIBase)config).mNativePointer) : YogaNative.jni_YGNodeNewWithConfig(((YogaConfigJNIBase)config).mNativePointer));
this.useVanillaJNI = config.useVanillaJNI();
this(YogaNative.jni_YGNodeNewWithConfigJNI(((YogaConfigJNIBase)config).mNativePointer));
}
public void reset() {
@@ -78,10 +70,7 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
mHasNewLayout = true;
mLayoutDirection = 0;
if (useVanillaJNI)
YogaNative.jni_YGNodeResetJNI(mNativePointer);
else
YogaNative.jni_YGNodeReset(mNativePointer);
YogaNative.jni_YGNodeResetJNI(mNativePointer);
}
public int getChildCount() {
@@ -106,28 +95,22 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
}
mChildren.add(i, child);
child.mOwner = this;
if (useVanillaJNI)
YogaNative.jni_YGNodeInsertChildJNI(mNativePointer, child.mNativePointer, i);
else
YogaNative.jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
YogaNative.jni_YGNodeInsertChildJNI(mNativePointer, child.mNativePointer, i);
}
public void setIsReferenceBaseline(boolean isReferenceBaseline) {
if (useVanillaJNI)
YogaNative.jni_YGNodeSetIsReferenceBaselineJNI(mNativePointer, isReferenceBaseline);
else
YogaNative.jni_YGNodeSetIsReferenceBaseline(mNativePointer, isReferenceBaseline);
YogaNative.jni_YGNodeSetIsReferenceBaselineJNI(mNativePointer, isReferenceBaseline);
}
public boolean isReferenceBaseline() {
return useVanillaJNI ? YogaNative.jni_YGNodeIsReferenceBaselineJNI(mNativePointer) : YogaNative.jni_YGNodeIsReferenceBaseline(mNativePointer);
return YogaNative.jni_YGNodeIsReferenceBaselineJNI(mNativePointer);
}
@Override
public YogaNodeJNIBase cloneWithoutChildren() {
try {
YogaNodeJNIBase clonedYogaNode = (YogaNodeJNIBase) super.clone();
long clonedNativePointer = useVanillaJNI ? YogaNative.jni_YGNodeCloneJNI(mNativePointer) : YogaNative.jni_YGNodeClone(mNativePointer);;
long clonedNativePointer = YogaNative.jni_YGNodeCloneJNI(mNativePointer);
clonedYogaNode.mOwner = null;
clonedYogaNode.mNativePointer = clonedNativePointer;
clonedYogaNode.clearChildren();
@@ -140,10 +123,7 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
private void clearChildren() {
mChildren = null;
if (useVanillaJNI)
YogaNative.jni_YGNodeClearChildrenJNI(mNativePointer);
else
YogaNative.jni_YGNodeClearChildren(mNativePointer);
YogaNative.jni_YGNodeClearChildrenJNI(mNativePointer);
}
public YogaNodeJNIBase removeChildAt(int i) {
@@ -153,10 +133,7 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
}
final YogaNodeJNIBase child = mChildren.remove(i);
child.mOwner = null;
if (useVanillaJNI)
YogaNative.jni_YGNodeRemoveChildJNI(mNativePointer, child.mNativePointer);
else
YogaNative.jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
YogaNative.jni_YGNodeRemoveChildJNI(mNativePointer, child.mNativePointer);
return child;
}
@@ -203,418 +180,285 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
nativePointers[i] = nodes[i].mNativePointer;
}
if (useVanillaJNI)
YogaNative.jni_YGNodeCalculateLayoutJNI(mNativePointer, width, height, nativePointers, nodes);
else
YogaNative.jni_YGNodeCalculateLayout(mNativePointer, width, height, nativePointers, nodes);
YogaNative.jni_YGNodeCalculateLayoutJNI(mNativePointer, width, height, nativePointers, nodes);
}
public void dirty() {
if (useVanillaJNI)
YogaNative.jni_YGNodeMarkDirtyJNI(mNativePointer);
else
YogaNative.jni_YGNodeMarkDirty(mNativePointer);
YogaNative.jni_YGNodeMarkDirtyJNI(mNativePointer);
}
public void dirtyAllDescendants() {
if (useVanillaJNI)
YogaNative.jni_YGNodeMarkDirtyAndPropogateToDescendantsJNI(mNativePointer);
else
YogaNative.jni_YGNodeMarkDirtyAndPropogateToDescendants(mNativePointer);
YogaNative.jni_YGNodeMarkDirtyAndPropogateToDescendantsJNI(mNativePointer);
}
public boolean isDirty() {
return useVanillaJNI ? YogaNative.jni_YGNodeIsDirtyJNI(mNativePointer) : YogaNative.jni_YGNodeIsDirty(mNativePointer);
return YogaNative.jni_YGNodeIsDirtyJNI(mNativePointer);
}
@Override
public void copyStyle(YogaNode srcNode) {
if (useVanillaJNI)
YogaNative.jni_YGNodeCopyStyleJNI(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer);
else
YogaNative.jni_YGNodeCopyStyle(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer);
YogaNative.jni_YGNodeCopyStyleJNI(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer);
}
public YogaDirection getStyleDirection() {
return YogaDirection.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetDirectionJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetDirection(mNativePointer));
return YogaDirection.fromInt(YogaNative.jni_YGNodeStyleGetDirectionJNI(mNativePointer));
}
public void setDirection(YogaDirection direction) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetDirectionJNI(mNativePointer, direction.intValue());
else
YogaNative.jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue());
YogaNative.jni_YGNodeStyleSetDirectionJNI(mNativePointer, direction.intValue());
}
public YogaFlexDirection getFlexDirection() {
return YogaFlexDirection.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetFlexDirectionJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetFlexDirection(mNativePointer));
return YogaFlexDirection.fromInt(YogaNative.jni_YGNodeStyleGetFlexDirectionJNI(mNativePointer));
}
public void setFlexDirection(YogaFlexDirection flexDirection) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetFlexDirectionJNI(mNativePointer, flexDirection.intValue());
else
YogaNative.jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
YogaNative.jni_YGNodeStyleSetFlexDirectionJNI(mNativePointer, flexDirection.intValue());
}
public YogaJustify getJustifyContent() {
return YogaJustify.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetJustifyContentJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetJustifyContent(mNativePointer));
return YogaJustify.fromInt(YogaNative.jni_YGNodeStyleGetJustifyContentJNI(mNativePointer));
}
public void setJustifyContent(YogaJustify justifyContent) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetJustifyContentJNI(mNativePointer, justifyContent.intValue());
else
YogaNative.jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
YogaNative.jni_YGNodeStyleSetJustifyContentJNI(mNativePointer, justifyContent.intValue());
}
public YogaAlign getAlignItems() {
return YogaAlign.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetAlignItemsJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetAlignItems(mNativePointer));
return YogaAlign.fromInt(YogaNative.jni_YGNodeStyleGetAlignItemsJNI(mNativePointer));
}
public void setAlignItems(YogaAlign alignItems) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetAlignItemsJNI(mNativePointer, alignItems.intValue());
else
YogaNative.jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
YogaNative.jni_YGNodeStyleSetAlignItemsJNI(mNativePointer, alignItems.intValue());
}
public YogaAlign getAlignSelf() {
return YogaAlign.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetAlignSelfJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetAlignSelf(mNativePointer));
return YogaAlign.fromInt(YogaNative.jni_YGNodeStyleGetAlignSelfJNI(mNativePointer));
}
public void setAlignSelf(YogaAlign alignSelf) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetAlignSelfJNI(mNativePointer, alignSelf.intValue());
else
YogaNative.jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
YogaNative.jni_YGNodeStyleSetAlignSelfJNI(mNativePointer, alignSelf.intValue());
}
public YogaAlign getAlignContent() {
return YogaAlign.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetAlignContentJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetAlignContent(mNativePointer));
return YogaAlign.fromInt(YogaNative.jni_YGNodeStyleGetAlignContentJNI(mNativePointer));
}
public void setAlignContent(YogaAlign alignContent) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetAlignContentJNI(mNativePointer, alignContent.intValue());
else
YogaNative.jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
YogaNative.jni_YGNodeStyleSetAlignContentJNI(mNativePointer, alignContent.intValue());
}
public YogaPositionType getPositionType() {
return YogaPositionType.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetPositionTypeJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetPositionType(mNativePointer));
return YogaPositionType.fromInt(YogaNative.jni_YGNodeStyleGetPositionTypeJNI(mNativePointer));
}
public void setPositionType(YogaPositionType positionType) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetPositionTypeJNI(mNativePointer, positionType.intValue());
else
YogaNative.jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue());
YogaNative.jni_YGNodeStyleSetPositionTypeJNI(mNativePointer, positionType.intValue());
}
public YogaWrap getWrap() {
return YogaWrap.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetFlexWrapJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetFlexWrap(mNativePointer));
return YogaWrap.fromInt(YogaNative.jni_YGNodeStyleGetFlexWrapJNI(mNativePointer));
}
public void setWrap(YogaWrap flexWrap) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetFlexWrapJNI(mNativePointer, flexWrap.intValue());
else
YogaNative.jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
YogaNative.jni_YGNodeStyleSetFlexWrapJNI(mNativePointer, flexWrap.intValue());
}
public YogaOverflow getOverflow() {
return YogaOverflow.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetOverflowJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetOverflow(mNativePointer));
return YogaOverflow.fromInt(YogaNative.jni_YGNodeStyleGetOverflowJNI(mNativePointer));
}
public void setOverflow(YogaOverflow overflow) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetOverflowJNI(mNativePointer, overflow.intValue());
else
YogaNative.jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
YogaNative.jni_YGNodeStyleSetOverflowJNI(mNativePointer, overflow.intValue());
}
public YogaDisplay getDisplay() {
return YogaDisplay.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetDisplayJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetDisplay(mNativePointer));
return YogaDisplay.fromInt(YogaNative.jni_YGNodeStyleGetDisplayJNI(mNativePointer));
}
public void setDisplay(YogaDisplay display) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetDisplayJNI(mNativePointer, display.intValue());
else
YogaNative.jni_YGNodeStyleSetDisplay(mNativePointer, display.intValue());
YogaNative.jni_YGNodeStyleSetDisplayJNI(mNativePointer, display.intValue());
}
public float getFlex() {
return useVanillaJNI ? YogaNative.jni_YGNodeStyleGetFlexJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetFlex(mNativePointer);
return YogaNative.jni_YGNodeStyleGetFlexJNI(mNativePointer);
}
public void setFlex(float flex) {
if (useVanillaJNI) {
YogaNative.jni_YGNodeStyleSetFlexJNI(mNativePointer, flex);
} else {
YogaNative.jni_YGNodeStyleSetFlex(mNativePointer, flex);
}
YogaNative.jni_YGNodeStyleSetFlexJNI(mNativePointer, flex);
}
public float getFlexGrow() {
return useVanillaJNI ? YogaNative.jni_YGNodeStyleGetFlexGrowJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetFlexGrow(mNativePointer);
return YogaNative.jni_YGNodeStyleGetFlexGrowJNI(mNativePointer);
}
public void setFlexGrow(float flexGrow) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetFlexGrowJNI(mNativePointer, flexGrow);
else
YogaNative.jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow);
YogaNative.jni_YGNodeStyleSetFlexGrowJNI(mNativePointer, flexGrow);
}
public float getFlexShrink() {
return useVanillaJNI ? YogaNative.jni_YGNodeStyleGetFlexShrinkJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetFlexShrink(mNativePointer);
return YogaNative.jni_YGNodeStyleGetFlexShrinkJNI(mNativePointer);
}
public void setFlexShrink(float flexShrink) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetFlexShrinkJNI(mNativePointer, flexShrink);
else
YogaNative.jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
YogaNative.jni_YGNodeStyleSetFlexShrinkJNI(mNativePointer, flexShrink);
}
public YogaValue getFlexBasis() {
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetFlexBasisJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetFlexBasis(mNativePointer));
return valueFromLong(YogaNative.jni_YGNodeStyleGetFlexBasisJNI(mNativePointer));
}
public void setFlexBasis(float flexBasis) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetFlexBasisJNI(mNativePointer, flexBasis);
else
YogaNative.jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
YogaNative.jni_YGNodeStyleSetFlexBasisJNI(mNativePointer, flexBasis);
}
public void setFlexBasisPercent(float percent) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetFlexBasisPercentJNI(mNativePointer, percent);
else
YogaNative.jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent);
YogaNative.jni_YGNodeStyleSetFlexBasisPercentJNI(mNativePointer, percent);
}
public void setFlexBasisAuto() {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetFlexBasisAutoJNI(mNativePointer);
else
YogaNative.jni_YGNodeStyleSetFlexBasisAuto(mNativePointer);
YogaNative.jni_YGNodeStyleSetFlexBasisAutoJNI(mNativePointer);
}
public YogaValue getMargin(YogaEdge edge) {
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetMarginJNI(mNativePointer, edge.intValue()) : YogaNative.jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue()));
return valueFromLong(YogaNative.jni_YGNodeStyleGetMarginJNI(mNativePointer, edge.intValue()));
}
public void setMargin(YogaEdge edge, float margin) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetMarginJNI(mNativePointer, edge.intValue(), margin);
else
YogaNative.jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
YogaNative.jni_YGNodeStyleSetMarginJNI(mNativePointer, edge.intValue(), margin);
}
public void setMarginPercent(YogaEdge edge, float percent) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetMarginPercentJNI(mNativePointer, edge.intValue(), percent);
else
YogaNative.jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent);
YogaNative.jni_YGNodeStyleSetMarginPercentJNI(mNativePointer, edge.intValue(), percent);
}
public void setMarginAuto(YogaEdge edge) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetMarginAutoJNI(mNativePointer, edge.intValue());
else
YogaNative.jni_YGNodeStyleSetMarginAuto(mNativePointer, edge.intValue());
YogaNative.jni_YGNodeStyleSetMarginAutoJNI(mNativePointer, edge.intValue());
}
public YogaValue getPadding(YogaEdge edge) {
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetPaddingJNI(mNativePointer, edge.intValue()) : YogaNative.jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue()));
return valueFromLong(YogaNative.jni_YGNodeStyleGetPaddingJNI(mNativePointer, edge.intValue()));
}
public void setPadding(YogaEdge edge, float padding) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetPaddingJNI(mNativePointer, edge.intValue(), padding);
else
YogaNative.jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
YogaNative.jni_YGNodeStyleSetPaddingJNI(mNativePointer, edge.intValue(), padding);
}
public void setPaddingPercent(YogaEdge edge, float percent) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetPaddingPercentJNI(mNativePointer, edge.intValue(), percent);
else
YogaNative.jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent);
YogaNative.jni_YGNodeStyleSetPaddingPercentJNI(mNativePointer, edge.intValue(), percent);
}
public float getBorder(YogaEdge edge) {
return useVanillaJNI ? YogaNative.jni_YGNodeStyleGetBorderJNI(mNativePointer, edge.intValue()) : YogaNative.jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
return YogaNative.jni_YGNodeStyleGetBorderJNI(mNativePointer, edge.intValue());
}
public void setBorder(YogaEdge edge, float border) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetBorderJNI(mNativePointer, edge.intValue(), border);
else
YogaNative.jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
YogaNative.jni_YGNodeStyleSetBorderJNI(mNativePointer, edge.intValue(), border);
}
public YogaValue getPosition(YogaEdge edge) {
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetPositionJNI(mNativePointer, edge.intValue()) : YogaNative.jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue()));
return valueFromLong(YogaNative.jni_YGNodeStyleGetPositionJNI(mNativePointer, edge.intValue()));
}
public void setPosition(YogaEdge edge, float position) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetPositionJNI(mNativePointer, edge.intValue(), position);
else
YogaNative.jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
YogaNative.jni_YGNodeStyleSetPositionJNI(mNativePointer, edge.intValue(), position);
}
public void setPositionPercent(YogaEdge edge, float percent) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetPositionPercentJNI(mNativePointer, edge.intValue(), percent);
else
YogaNative.jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent);
YogaNative.jni_YGNodeStyleSetPositionPercentJNI(mNativePointer, edge.intValue(), percent);
}
public YogaValue getWidth() {
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetWidthJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetWidth(mNativePointer));
return valueFromLong(YogaNative.jni_YGNodeStyleGetWidthJNI(mNativePointer));
}
public void setWidth(float width) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetWidthJNI(mNativePointer, width);
else
YogaNative.jni_YGNodeStyleSetWidth(mNativePointer, width);
YogaNative.jni_YGNodeStyleSetWidthJNI(mNativePointer, width);
}
public void setWidthPercent(float percent) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetWidthPercentJNI(mNativePointer, percent);
else
YogaNative.jni_YGNodeStyleSetWidthPercent(mNativePointer, percent);
YogaNative.jni_YGNodeStyleSetWidthPercentJNI(mNativePointer, percent);
}
public void setWidthAuto() {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetWidthAutoJNI(mNativePointer);
else
YogaNative.jni_YGNodeStyleSetWidthAuto(mNativePointer);
YogaNative.jni_YGNodeStyleSetWidthAutoJNI(mNativePointer);
}
public YogaValue getHeight() {
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetHeightJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetHeight(mNativePointer));
return valueFromLong(YogaNative.jni_YGNodeStyleGetHeightJNI(mNativePointer));
}
public void setHeight(float height) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetHeightJNI(mNativePointer, height);
else
YogaNative.jni_YGNodeStyleSetHeight(mNativePointer, height);
YogaNative.jni_YGNodeStyleSetHeightJNI(mNativePointer, height);
}
public void setHeightPercent(float percent) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetHeightPercentJNI(mNativePointer, percent);
else
YogaNative.jni_YGNodeStyleSetHeightPercent(mNativePointer, percent);
YogaNative.jni_YGNodeStyleSetHeightPercentJNI(mNativePointer, percent);
}
public void setHeightAuto() {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetHeightAutoJNI(mNativePointer);
else
YogaNative.jni_YGNodeStyleSetHeightAuto(mNativePointer);
YogaNative.jni_YGNodeStyleSetHeightAutoJNI(mNativePointer);
}
public YogaValue getMinWidth() {
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetMinWidthJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetMinWidth(mNativePointer));
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinWidthJNI(mNativePointer));
}
public void setMinWidth(float minWidth) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetMinWidthJNI(mNativePointer, minWidth);
else
YogaNative.jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
YogaNative.jni_YGNodeStyleSetMinWidthJNI(mNativePointer, minWidth);
}
public void setMinWidthPercent(float percent) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetMinWidthPercentJNI(mNativePointer, percent);
else
YogaNative.jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent);
YogaNative.jni_YGNodeStyleSetMinWidthPercentJNI(mNativePointer, percent);
}
public YogaValue getMinHeight() {
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetMinHeightJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetMinHeight(mNativePointer));
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinHeightJNI(mNativePointer));
}
public void setMinHeight(float minHeight) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetMinHeightJNI(mNativePointer, minHeight);
else
YogaNative.jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
YogaNative.jni_YGNodeStyleSetMinHeightJNI(mNativePointer, minHeight);
}
public void setMinHeightPercent(float percent) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetMinHeightPercentJNI(mNativePointer, percent);
else
YogaNative.jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent);
YogaNative.jni_YGNodeStyleSetMinHeightPercentJNI(mNativePointer, percent);
}
public YogaValue getMaxWidth() {
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetMaxWidthJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetMaxWidth(mNativePointer));
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxWidthJNI(mNativePointer));
}
public void setMaxWidth(float maxWidth) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetMaxWidthJNI(mNativePointer, maxWidth);
else
YogaNative.jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
YogaNative.jni_YGNodeStyleSetMaxWidthJNI(mNativePointer, maxWidth);
}
public void setMaxWidthPercent(float percent) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetMaxWidthPercentJNI(mNativePointer, percent);
else
YogaNative.jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent);
YogaNative.jni_YGNodeStyleSetMaxWidthPercentJNI(mNativePointer, percent);
}
public YogaValue getMaxHeight() {
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetMaxHeightJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetMaxHeight(mNativePointer));
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxHeightJNI(mNativePointer));
}
public void setMaxHeight(float maxheight) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetMaxHeightJNI(mNativePointer, maxheight);
else
YogaNative.jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
YogaNative.jni_YGNodeStyleSetMaxHeightJNI(mNativePointer, maxheight);
}
public void setMaxHeightPercent(float percent) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetMaxHeightPercentJNI(mNativePointer, percent);
else
YogaNative.jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent);
YogaNative.jni_YGNodeStyleSetMaxHeightPercentJNI(mNativePointer, percent);
}
public float getAspectRatio() {
return useVanillaJNI ? YogaNative.jni_YGNodeStyleGetAspectRatioJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetAspectRatio(mNativePointer);
return YogaNative.jni_YGNodeStyleGetAspectRatioJNI(mNativePointer);
}
public void setAspectRatio(float aspectRatio) {
if (useVanillaJNI)
YogaNative.jni_YGNodeStyleSetAspectRatioJNI(mNativePointer, aspectRatio);
else
YogaNative.jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
YogaNative.jni_YGNodeStyleSetAspectRatioJNI(mNativePointer, aspectRatio);
}
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
mMeasureFunction = measureFunction;
if (useVanillaJNI)
YogaNative.jni_YGNodeSetHasMeasureFuncJNI(mNativePointer, measureFunction != null);
else
YogaNative.jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
YogaNative.jni_YGNodeSetHasMeasureFuncJNI(mNativePointer, measureFunction != null);
}
// Implementation Note: Why this method needs to stay final
@@ -638,10 +482,7 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
public void setBaselineFunction(YogaBaselineFunction baselineFunction) {
mBaselineFunction = baselineFunction;
if (useVanillaJNI)
YogaNative.jni_YGNodeSetHasBaselineFuncJNI(mNativePointer, baselineFunction != null);
else
YogaNative.jni_YGNodeSetHasBaselineFunc(mNativePointer, baselineFunction != null);
YogaNative.jni_YGNodeSetHasBaselineFuncJNI(mNativePointer, baselineFunction != null);
}
@DoNotStrip
@@ -672,10 +513,7 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
* layout of the tree rooted at this node.
*/
public void print() {
if (useVanillaJNI)
YogaNative.jni_YGNodePrintJNI(mNativePointer);
else
YogaNative.jni_YGNodePrint(mNativePointer);
YogaNative.jni_YGNodePrintJNI(mNativePointer);
}
/**

View File

@@ -12,10 +12,6 @@ public class YogaNodeJNIFinalizer extends YogaNodeJNIBase {
super();
}
public YogaNodeJNIFinalizer(boolean useVanillaJNI) {
super(useVanillaJNI);
}
public YogaNodeJNIFinalizer(YogaConfig config) {
super(config);
}
@@ -33,10 +29,7 @@ public class YogaNodeJNIFinalizer extends YogaNodeJNIBase {
if (mNativePointer != 0) {
long nativePointer = mNativePointer;
mNativePointer = 0;
if (useVanillaJNI)
YogaNative.jni_YGNodeFreeJNI(nativePointer);
else
YogaNative.jni_YGNodeFree(nativePointer);
YogaNative.jni_YGNodeFreeJNI(nativePointer);
}
}
}

View File

@@ -1,712 +0,0 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <fbjni/fbjni.h>
#include <yoga/YGNode.h>
#include <yoga/Yoga.h>
#include <yoga/Yoga-internal.h>
#include <yoga/log.h>
#include <cstdint>
#include <cstring>
#include <iostream>
#include <map>
#include "YGJTypes.h"
#include "YGJNIVanilla.h"
#include "YGJNI.h"
#include "yogajni.h"
using namespace facebook::jni;
using namespace std;
using facebook::yoga::detail::Log;
static inline local_ref<JYogaNode> YGNodeJobject(
YGNodeRef node,
void* layoutContext) {
return reinterpret_cast<PtrJNodeMap*>(layoutContext)->ref(node);
}
static void YGTransferLayoutDirection(
YGNodeRef node,
alias_ref<jobject> javaNode) {
static auto layoutDirectionField =
javaNode->getClass()->getField<jint>("mLayoutDirection");
javaNode->setFieldValue(
layoutDirectionField, static_cast<jint>(YGNodeLayoutGetDirection(node)));
}
static void YGTransferLayoutOutputsRecursive(
YGNodeRef root,
void* layoutContext) {
if (!root->getHasNewLayout()) {
return;
}
auto obj = YGNodeJobject(root, layoutContext);
if (!obj) {
Log::log(
root,
YGLogLevelError,
nullptr,
"Java YGNode was GCed during layout calculation\n");
return;
}
auto edgesSet = YGNodeEdges{root};
bool marginFieldSet = edgesSet.has(YGNodeEdges::MARGIN);
bool paddingFieldSet = edgesSet.has(YGNodeEdges::PADDING);
bool borderFieldSet = edgesSet.has(YGNodeEdges::BORDER);
int fieldFlags = edgesSet.get();
fieldFlags |= HAS_NEW_LAYOUT;
if (YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(root)) {
fieldFlags |= DOES_LEGACY_STRETCH_BEHAVIOUR;
}
const int arrSize = 6 + (marginFieldSet ? 4 : 0) + (paddingFieldSet ? 4 : 0) +
(borderFieldSet ? 4 : 0);
float arr[18];
arr[LAYOUT_EDGE_SET_FLAG_INDEX] = fieldFlags;
arr[LAYOUT_WIDTH_INDEX] = YGNodeLayoutGetWidth(root);
arr[LAYOUT_HEIGHT_INDEX] = YGNodeLayoutGetHeight(root);
arr[LAYOUT_LEFT_INDEX] = YGNodeLayoutGetLeft(root);
arr[LAYOUT_TOP_INDEX] = YGNodeLayoutGetTop(root);
arr[LAYOUT_DIRECTION_INDEX] =
static_cast<jint>(YGNodeLayoutGetDirection(root));
if (marginFieldSet) {
arr[LAYOUT_MARGIN_START_INDEX] = YGNodeLayoutGetMargin(root, YGEdgeLeft);
arr[LAYOUT_MARGIN_START_INDEX + 1] = YGNodeLayoutGetMargin(root, YGEdgeTop);
arr[LAYOUT_MARGIN_START_INDEX + 2] =
YGNodeLayoutGetMargin(root, YGEdgeRight);
arr[LAYOUT_MARGIN_START_INDEX + 3] =
YGNodeLayoutGetMargin(root, YGEdgeBottom);
}
if (paddingFieldSet) {
int paddingStartIndex =
LAYOUT_PADDING_START_INDEX - (marginFieldSet ? 0 : 4);
arr[paddingStartIndex] = YGNodeLayoutGetPadding(root, YGEdgeLeft);
arr[paddingStartIndex + 1] = YGNodeLayoutGetPadding(root, YGEdgeTop);
arr[paddingStartIndex + 2] = YGNodeLayoutGetPadding(root, YGEdgeRight);
arr[paddingStartIndex + 3] = YGNodeLayoutGetPadding(root, YGEdgeBottom);
}
if (borderFieldSet) {
int borderStartIndex = LAYOUT_BORDER_START_INDEX -
(marginFieldSet ? 0 : 4) - (paddingFieldSet ? 0 : 4);
arr[borderStartIndex] = YGNodeLayoutGetBorder(root, YGEdgeLeft);
arr[borderStartIndex + 1] = YGNodeLayoutGetBorder(root, YGEdgeTop);
arr[borderStartIndex + 2] = YGNodeLayoutGetBorder(root, YGEdgeRight);
arr[borderStartIndex + 3] = YGNodeLayoutGetBorder(root, YGEdgeBottom);
}
static auto arrField = obj->getClass()->getField<jfloatArray>("arr");
local_ref<jfloatArray> arrFinal = make_float_array(arrSize);
arrFinal->setRegion(0, arrSize, arr);
obj->setFieldValue<jfloatArray>(arrField, arrFinal.get());
root->setHasNewLayout(false);
for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) {
YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i), layoutContext);
}
}
static void YGPrint(YGNodeRef node, void* layoutContext) {
if (auto obj = YGNodeJobject(node, layoutContext)) {
cout << obj->toString() << endl;
} else {
Log::log(
node,
YGLogLevelError,
nullptr,
"Java YGNode was GCed during layout calculation\n");
}
}
static float YGJNIBaselineFunc(
YGNodeRef node,
float width,
float height,
void* layoutContext) {
if (auto obj = YGNodeJobject(node, layoutContext)) {
return obj->baseline(width, height);
} else {
return height;
}
}
static inline YGNodeRef _jlong2YGNodeRef(jlong addr) {
return reinterpret_cast<YGNodeRef>(static_cast<intptr_t>(addr));
}
static inline YGConfigRef _jlong2YGConfigRef(jlong addr) {
return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr));
}
jlong jni_YGNodeClone(alias_ref<jobject> thiz, jlong nativePointer) {
auto node = _jlong2YGNodeRef(nativePointer);
const YGNodeRef clonedYogaNode = YGNodeClone(node);
clonedYogaNode->setContext(node->getContext());
return reinterpret_cast<jlong>(clonedYogaNode);
}
static YGSize YGJNIMeasureFunc(
YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode,
void* layoutContext) {
if (auto obj = YGNodeJobject(node, layoutContext)) {
YGTransferLayoutDirection(node, obj);
const auto measureResult =
obj->measure(width, widthMode, height, heightMode);
static_assert(
sizeof(measureResult) == 8,
"Expected measureResult to be 8 bytes, or two 32 bit ints");
int32_t wBits = 0xFFFFFFFF & (measureResult >> 32);
int32_t hBits = 0xFFFFFFFF & measureResult;
const float* measuredWidth = reinterpret_cast<float*>(&wBits);
const float* measuredHeight = reinterpret_cast<float*>(&hBits);
return YGSize{*measuredWidth, *measuredHeight};
} else {
Log::log(
node,
YGLogLevelError,
nullptr,
"Java YGNode was GCed during layout calculation\n");
return YGSize{
widthMode == YGMeasureModeUndefined ? 0 : width,
heightMode == YGMeasureModeUndefined ? 0 : height,
};
}
}
static int YGJNILogFunc(
const YGConfigRef config,
const YGNodeRef node,
YGLogLevel level,
void* layoutContext,
const char* format,
va_list args) {
int result = vsnprintf(NULL, 0, format, args);
std::vector<char> buffer(1 + result);
vsnprintf(buffer.data(), buffer.size(), format, args);
auto jloggerPtr =
static_cast<global_ref<JYogaLogger>*>(YGConfigGetContext(config));
if (jloggerPtr != nullptr) {
(*jloggerPtr)
->log(
JYogaLogLevel::fromInt(level),
Environment::current()->NewStringUTF(buffer.data()));
}
return result;
}
jlong jni_YGNodeNew(alias_ref<jobject> thiz) {
const YGNodeRef node = YGNodeNew();
node->setContext(YGNodeContext{}.asVoidPtr);
node->setPrintFunc(YGPrint);
return reinterpret_cast<jlong>(node);
}
jlong jni_YGNodeNewWithConfig(alias_ref<jclass>, jlong configPointer) {
const YGNodeRef node = YGNodeNewWithConfig(_jlong2YGConfigRef(configPointer));
node->setContext(YGNodeContext{}.asVoidPtr);
return reinterpret_cast<jlong>(node);
}
void jni_YGNodeFree(alias_ref<jclass>, jlong nativePointer) {
if (nativePointer == 0) {
return;
}
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
YGNodeFree(node);
}
void jni_YGNodeClearChildren(jlong nativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
node->clearChildren();
}
void jni_YGNodeReset(jlong nativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
void* context = node->getContext();
YGNodeReset(node);
node->setContext(context);
}
void jni_YGNodePrint(jlong nativePointer) {
#ifdef DEBUG
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
YGNodePrint(
node,
(YGPrintOptions)(
YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
#endif
}
void jni_YGNodeInsertChild(
jlong nativePointer,
jlong childPointer,
jint index) {
YGNodeInsertChild(
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
}
void jni_YGNodeRemoveChild(jlong nativePointer, jlong childPointer) {
YGNodeRemoveChild(
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer));
}
void jni_YGNodeSetIsReferenceBaseline(
jlong nativePointer,
jboolean isReferenceBaseline) {
YGNodeSetIsReferenceBaseline(
_jlong2YGNodeRef(nativePointer), isReferenceBaseline);
}
jboolean jni_YGNodeIsReferenceBaseline(jlong nativePointer) {
return YGNodeIsReferenceBaseline(_jlong2YGNodeRef(nativePointer));
}
void jni_YGNodeCalculateLayout(
alias_ref<jclass>,
jlong nativePointer,
jfloat width,
jfloat height,
alias_ref<JArrayLong> nativePointers,
alias_ref<JArrayClass<JYogaNode::javaobject>> javaNodes) {
void* layoutContext = nullptr;
auto map = PtrJNodeMap{};
if (nativePointers) {
map = PtrJNodeMap{nativePointers, javaNodes};
layoutContext = &map;
}
const YGNodeRef root = _jlong2YGNodeRef(nativePointer);
YGNodeCalculateLayoutWithContext(
root,
static_cast<float>(width),
static_cast<float>(height),
YGNodeStyleGetDirection(_jlong2YGNodeRef(nativePointer)),
layoutContext);
YGTransferLayoutOutputsRecursive(root, layoutContext);
}
void jni_YGNodeMarkDirty(jlong nativePointer) {
YGNodeMarkDirty(_jlong2YGNodeRef(nativePointer));
}
void jni_YGNodeMarkDirtyAndPropogateToDescendants(jlong nativePointer) {
YGNodeMarkDirtyAndPropogateToDescendants(_jlong2YGNodeRef(nativePointer));
}
jboolean jni_YGNodeIsDirty(jlong nativePointer) {
return (jboolean) _jlong2YGNodeRef(nativePointer)->isDirty();
}
void jni_YGNodeSetHasMeasureFunc(jlong nativePointer, jboolean hasMeasureFunc) {
_jlong2YGNodeRef(nativePointer)
->setMeasureFunc(hasMeasureFunc ? YGJNIMeasureFunc : nullptr);
}
void jni_YGNodeSetHasBaselineFunc(
jlong nativePointer,
jboolean hasBaselineFunc) {
_jlong2YGNodeRef(nativePointer)
->setBaselineFunc(hasBaselineFunc ? YGJNIBaselineFunc : nullptr);
}
void jni_YGNodeCopyStyle(jlong dstNativePointer, jlong srcNativePointer) {
YGNodeCopyStyle(
_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer));
}
#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name(jlong nativePointer) { \
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
} \
\
void jni_YGNodeStyleSet##name(jlong nativePointer, javatype value) { \
YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
}
#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
jlong jni_YGNodeStyleGet##name(jlong nativePointer) { \
return YogaValue::asJavaLong( \
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
} \
\
void jni_YGNodeStyleSet##name(jlong nativePointer, jfloat value) { \
YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
} \
\
void jni_YGNodeStyleSet##name##Percent(jlong nativePointer, jfloat value) { \
YGNodeStyleSet##name##Percent( \
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
}
#define YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(name) \
YG_NODE_JNI_STYLE_UNIT_PROP(name) \
void jni_YGNodeStyleSet##name##Auto(jlong nativePointer) { \
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
}
#define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name(jlong nativePointer, jint edge) { \
return (javatype) YGNodeStyleGet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \
} \
\
void jni_YGNodeStyleSet##name( \
jlong nativePointer, jint edge, javatype value) { \
YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \
static_cast<type>(value)); \
}
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
jlong jni_YGNodeStyleGet##name(jlong nativePointer, jint edge) { \
return YogaValue::asJavaLong(YGNodeStyleGet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge))); \
} \
\
void jni_YGNodeStyleSet##name( \
jlong nativePointer, jint edge, jfloat value) { \
YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \
static_cast<float>(value)); \
} \
\
void jni_YGNodeStyleSet##name##Percent( \
jlong nativePointer, jint edge, jfloat value) { \
YGNodeStyleSet##name##Percent( \
_jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \
static_cast<float>(value)); \
}
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(name) \
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
void jni_YGNodeStyleSet##name##Auto(jlong nativePointer, jint edge) { \
YGNodeStyleSet##name##Auto( \
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \
}
YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
YG_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection);
YG_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignItems);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignSelf);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignContent);
YG_NODE_JNI_STYLE_PROP(jint, YGPositionType, PositionType);
YG_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap);
YG_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow);
YG_NODE_JNI_STYLE_PROP(jint, YGDisplay, Display);
jfloat jni_YGNodeStyleGetFlex(jlong nativePointer) {
return YGNodeStyleGetFlex(_jlong2YGNodeRef(nativePointer));
}
void jni_YGNodeStyleSetFlex(jlong nativePointer, jfloat value) {
YGNodeStyleSetFlex(
_jlong2YGNodeRef(nativePointer), static_cast<float>(value));
}
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(FlexBasis);
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(Position);
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(Width);
YG_NODE_JNI_STYLE_UNIT_PROP(MinWidth);
YG_NODE_JNI_STYLE_UNIT_PROP(MaxWidth);
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(Height);
YG_NODE_JNI_STYLE_UNIT_PROP(MinHeight);
YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight);
// Yoga specific properties, not compatible with flexbox specification
YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
jlong jni_YGConfigNew(alias_ref<jclass>) {
return reinterpret_cast<jlong>(YGConfigNew());
}
void jni_YGConfigFree(alias_ref<jclass>, jlong nativePointer) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
// unique_ptr will destruct the underlying global_ref, if present.
auto context = std::unique_ptr<global_ref<JYogaLogger>>{
static_cast<global_ref<JYogaLogger>*>(YGConfigGetContext(config))};
YGConfigFree(config);
}
void jni_YGConfigSetExperimentalFeatureEnabled(
alias_ref<jclass>,
jlong nativePointer,
jint feature,
jboolean enabled) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
YGConfigSetExperimentalFeatureEnabled(
config, static_cast<YGExperimentalFeature>(feature), enabled);
}
void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
alias_ref<jclass>,
jlong nativePointer,
jboolean enabled) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(config, enabled);
}
void jni_YGConfigSetUseWebDefaults(
alias_ref<jclass>,
jlong nativePointer,
jboolean useWebDefaults) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
YGConfigSetUseWebDefaults(config, useWebDefaults);
}
void jni_YGConfigSetPrintTreeFlag(
alias_ref<jclass>,
jlong nativePointer,
jboolean enable) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
YGConfigSetPrintTreeFlag(config, enable);
}
void jni_YGConfigSetPointScaleFactor(
alias_ref<jclass>,
jlong nativePointer,
jfloat pixelsInPoint) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
YGConfigSetPointScaleFactor(config, pixelsInPoint);
}
void jni_YGConfigSetUseLegacyStretchBehaviour(
alias_ref<jclass>,
jlong nativePointer,
jboolean useLegacyStretchBehaviour) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
YGConfigSetUseLegacyStretchBehaviour(config, useLegacyStretchBehaviour);
}
void jni_YGConfigSetLogger(
alias_ref<jclass>,
jlong nativePointer,
alias_ref<jobject> logger) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
auto context =
reinterpret_cast<global_ref<JYogaLogger>*>(YGConfigGetContext(config));
if (logger) {
if (context == nullptr) {
context = new global_ref<JYogaLogger>{};
YGConfigSetContext(config, context);
}
*context = make_global(static_ref_cast<JYogaLogger::javaobject>(logger));
config->setLogger(YGJNILogFunc);
} else {
if (context != nullptr) {
delete context;
YGConfigSetContext(config, nullptr);
}
config->setLogger(nullptr);
}
}
jlong jni_YGNodeStyleGetMargin(jlong nativePointer, jint edge) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::MARGIN)) {
return YogaValue::undefinedAsJavaLong();
}
return YogaValue::asJavaLong(
YGNodeStyleGetMargin(yogaNodeRef, static_cast<YGEdge>(edge)));
}
void jni_YGNodeStyleSetMargin(jlong nativePointer, jint edge, jfloat margin) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
YGNodeStyleSetMargin(
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(margin));
}
void jni_YGNodeStyleSetMarginPercent(
jlong nativePointer,
jint edge,
jfloat percent) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
YGNodeStyleSetMarginPercent(
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(percent));
}
void jni_YGNodeStyleSetMarginAuto(jlong nativePointer, jint edge) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
YGNodeStyleSetMarginAuto(yogaNodeRef, static_cast<YGEdge>(edge));
}
jlong jni_YGNodeStyleGetPadding(jlong nativePointer, jint edge) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::PADDING)) {
return YogaValue::undefinedAsJavaLong();
}
return YogaValue::asJavaLong(
YGNodeStyleGetPadding(yogaNodeRef, static_cast<YGEdge>(edge)));
}
void jni_YGNodeStyleSetPadding(jlong nativePointer, jint edge, jfloat padding) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::PADDING).setOn(yogaNodeRef);
YGNodeStyleSetPadding(
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(padding));
}
void jni_YGNodeStyleSetPaddingPercent(
jlong nativePointer,
jint edge,
jfloat percent) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::PADDING).setOn(yogaNodeRef);
YGNodeStyleSetPaddingPercent(
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(percent));
}
jfloat jni_YGNodeStyleGetBorder(jlong nativePointer, jint edge) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::BORDER)) {
return (jfloat) YGUndefined;
}
return (jfloat) YGNodeStyleGetBorder(yogaNodeRef, static_cast<YGEdge>(edge));
}
void jni_YGNodeStyleSetBorder(jlong nativePointer, jint edge, jfloat border) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::BORDER).setOn(yogaNodeRef);
YGNodeStyleSetBorder(
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(border));
}
#define YGMakeNativeMethod(name) makeNativeMethod(#name, name)
#define YGMakeCriticalNativeMethod(name) \
makeCriticalNativeMethod_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(#name, name)
jint YGJNI::registerNativeMethods(JavaVM* vm) {
jint ret = initialize(vm, [] {
registerNatives(
"com/facebook/yoga/YogaNative",
{
YGMakeNativeMethod(jni_YGNodeNew),
YGMakeNativeMethod(jni_YGNodeNewWithConfig),
YGMakeNativeMethod(jni_YGNodeFree),
YGMakeCriticalNativeMethod(jni_YGNodeReset),
YGMakeCriticalNativeMethod(jni_YGNodeClearChildren),
YGMakeCriticalNativeMethod(jni_YGNodeInsertChild),
YGMakeCriticalNativeMethod(jni_YGNodeRemoveChild),
YGMakeCriticalNativeMethod(jni_YGNodeSetIsReferenceBaseline),
YGMakeCriticalNativeMethod(jni_YGNodeIsReferenceBaseline),
YGMakeNativeMethod(jni_YGNodeCalculateLayout),
YGMakeCriticalNativeMethod(jni_YGNodeMarkDirty),
YGMakeCriticalNativeMethod(
jni_YGNodeMarkDirtyAndPropogateToDescendants),
YGMakeCriticalNativeMethod(jni_YGNodeIsDirty),
YGMakeCriticalNativeMethod(jni_YGNodeSetHasMeasureFunc),
YGMakeCriticalNativeMethod(jni_YGNodeSetHasBaselineFunc),
YGMakeCriticalNativeMethod(jni_YGNodeCopyStyle),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetDirection),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetDirection),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexDirection),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexDirection),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetJustifyContent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetJustifyContent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignItems),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignItems),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignSelf),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignSelf),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignContent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignContent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPositionType),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionType),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexWrap),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexWrap),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetOverflow),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetOverflow),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetDisplay),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetDisplay),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlex),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlex),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexGrow),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexGrow),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexShrink),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexShrink),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexBasis),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasis),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisAuto),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMargin),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMargin),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginAuto),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPadding),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPadding),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPaddingPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetBorder),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetBorder),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPosition),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPosition),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthAuto),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightAuto),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMinWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidthPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMinHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeightPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMaxWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidthPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMaxHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeightPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAspectRatio),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAspectRatio),
YGMakeCriticalNativeMethod(jni_YGNodePrint),
YGMakeNativeMethod(jni_YGNodeClone),
YGMakeNativeMethod(jni_YGConfigNew),
YGMakeNativeMethod(jni_YGConfigFree),
YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled),
YGMakeNativeMethod(jni_YGConfigSetUseWebDefaults),
YGMakeNativeMethod(jni_YGConfigSetPrintTreeFlag),
YGMakeNativeMethod(jni_YGConfigSetPointScaleFactor),
YGMakeNativeMethod(jni_YGConfigSetUseLegacyStretchBehaviour),
YGMakeNativeMethod(jni_YGConfigSetLogger),
YGMakeNativeMethod(
jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour),
});
});
return ret;
}

View File

@@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
#include "jni.h"
namespace YGJNIVanilla {
void registerNatives(JNIEnv* env);
};

View File

@@ -1,43 +0,0 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "YGJTypes.h"
using facebook::jni::alias_ref;
using facebook::jni::local_ref;
jfloat JYogaNode::baseline(jfloat width, jfloat height) {
static auto javaMethod =
javaClassLocal()->getMethod<jfloat(jfloat, jfloat)>("baseline");
return javaMethod(self(), width, height);
}
jlong JYogaNode::measure(
jfloat width,
jint widthMode,
jfloat height,
jint heightMode) {
static auto javaMethod =
javaClassLocal()->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
return javaMethod(self(), width, widthMode, height, heightMode);
}
facebook::jni::local_ref<JYogaLogLevel> JYogaLogLevel::fromInt(jint logLevel) {
static auto javaMethod =
javaClassStatic()->getStaticMethod<alias_ref<JYogaLogLevel>(jint)>(
"fromInt");
return javaMethod(javaClassStatic(), logLevel);
}
void JYogaLogger::log(
facebook::jni::alias_ref<JYogaLogLevel> logLevel,
jstring message) {
static auto javaMethod =
javaClassLocal()->getMethod<void(alias_ref<JYogaLogLevel>, jstring)>(
"log");
javaMethod(self(), logLevel, message);
}

View File

@@ -1,61 +0,0 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <fbjni/fbjni.h>
#include <yoga/YGValue.h>
#include <yoga/Yoga.h>
#include <map>
using namespace facebook::jni;
using namespace std;
struct JYogaNode : public facebook::jni::JavaClass<JYogaNode> {
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaNodeJNIBase;";
jfloat baseline(jfloat width, jfloat height);
jlong measure(jfloat width, jint widthMode, jfloat height, jint heightMode);
};
struct JYogaLogLevel : public facebook::jni::JavaClass<JYogaLogLevel> {
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaLogLevel;";
static facebook::jni::local_ref<JYogaLogLevel> fromInt(jint);
};
struct JYogaLogger : public facebook::jni::JavaClass<JYogaLogger> {
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaLogger;";
void log(facebook::jni::alias_ref<JYogaLogLevel>, jstring);
};
class PtrJNodeMap {
using JNodeArray = JArrayClass<JYogaNode::javaobject>;
std::map<YGNodeRef, size_t> ptrsToIdxs_;
alias_ref<JNodeArray> javaNodes_;
public:
PtrJNodeMap() : ptrsToIdxs_{}, javaNodes_{} {}
PtrJNodeMap(
alias_ref<JArrayLong> nativePointers,
alias_ref<JNodeArray> javaNodes)
: javaNodes_{javaNodes} {
auto pin = nativePointers->pinCritical();
auto ptrs = pin.get();
for (size_t i = 0, n = pin.size(); i < n; ++i) {
ptrsToIdxs_[(YGNodeRef) ptrs[i]] = i;
}
}
local_ref<JYogaNode> ref(YGNodeRef node) {
auto idx = ptrsToIdxs_.find(node);
if (idx == ptrsToIdxs_.end()) {
return local_ref<JYogaNode>{};
} else {
return javaNodes_->getElement(idx->second);
}
}
};

View File

@@ -4,20 +4,14 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "yogajni.h"
#include "YGJNIVanilla.h"
#include <fbjni/fbjni.h>
#include "common.h"
using namespace facebook::jni;
using namespace facebook::yoga;
jint JNI_OnLoad(JavaVM* vm, void*) {
jint ret = YGJNI::registerNativeMethods(vm);
JNIEnv* env;
vanillajni::ensureInitialized(&env, vm);
jint ret = vanillajni::ensureInitialized(&env, vm);
YGJNIVanilla::registerNatives(env);
return ret;
}

View File

@@ -1,12 +0,0 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <fbjni/fbjni.h>
namespace YGJNI {
jint registerNativeMethods(JavaVM* vm);
};

View File

@@ -28,25 +28,7 @@ public class TestParametrization {
return "JNI";
}
};
NodeFactory nodeFactoryUsingVanillaJNI = new NodeFactory() {
@Override
public YogaNode create() {
return YogaNodeFactory.create(true);
}
@Override
public YogaNode create(YogaConfig config) {
config.setUseVanillaJNI(true);
return YogaNodeFactory.create(config);
}
@Override
public String toString() {
return "VanillaJNI";
}
};
return Arrays.asList(nodeFactory, nodeFactoryUsingVanillaJNI);
return Arrays.asList(nodeFactory);
}