Rename C api
Summary: This renames the core C api to use the new Yoga branding. Differential Revision: D4259190 fbshipit-source-id: 26c8b356ca464d4304f5f9dc4192bff10cea2dc9
This commit is contained in:
committed by
Facebook Github Bot
parent
f7cc614d67
commit
dda24b1e23
@@ -27,26 +27,26 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
/**
|
||||
* Get native instance count. Useful for testing only.
|
||||
*/
|
||||
static native int jni_CSSNodeGetInstanceCount();
|
||||
static native void jni_CSSLog(int level, String message);
|
||||
static native int jni_YGNodeGetInstanceCount();
|
||||
static native void jni_YGLog(int level, String message);
|
||||
|
||||
private static native void jni_CSSLayoutSetLogger(Object logger);
|
||||
private static native void jni_YGSetLogger(Object logger);
|
||||
public static void setLogger(CSSLogger logger) {
|
||||
jni_CSSLayoutSetLogger(logger);
|
||||
jni_YGSetLogger(logger);
|
||||
}
|
||||
|
||||
private static native void jni_CSSLayoutSetExperimentalFeatureEnabled(
|
||||
private static native void jni_YGSetExperimentalFeatureEnabled(
|
||||
int feature,
|
||||
boolean enabled);
|
||||
public static void setExperimentalFeatureEnabled(
|
||||
YogaExperimentalFeature feature,
|
||||
boolean enabled) {
|
||||
jni_CSSLayoutSetExperimentalFeatureEnabled(feature.intValue(), enabled);
|
||||
jni_YGSetExperimentalFeatureEnabled(feature.intValue(), enabled);
|
||||
}
|
||||
|
||||
private static native boolean jni_CSSLayoutIsExperimentalFeatureEnabled(int feature);
|
||||
private static native boolean jni_YGIsExperimentalFeatureEnabled(int feature);
|
||||
public static boolean isExperimentalFeatureEnabled(YogaExperimentalFeature feature) {
|
||||
return jni_CSSLayoutIsExperimentalFeatureEnabled(feature.intValue());
|
||||
return jni_YGIsExperimentalFeatureEnabled(feature.intValue());
|
||||
}
|
||||
|
||||
private CSSNode mParent;
|
||||
@@ -71,25 +71,25 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
@DoNotStrip
|
||||
private int mLayoutDirection = 0;
|
||||
|
||||
private native long jni_CSSNodeNew();
|
||||
private native long jni_YGNodeNew();
|
||||
public CSSNode() {
|
||||
mNativePointer = jni_CSSNodeNew();
|
||||
mNativePointer = jni_YGNodeNew();
|
||||
if (mNativePointer == 0) {
|
||||
throw new IllegalStateException("Failed to allocate native memory");
|
||||
}
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeFree(long nativePointer);
|
||||
private native void jni_YGNodeFree(long nativePointer);
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
jni_CSSNodeFree(mNativePointer);
|
||||
jni_YGNodeFree(mNativePointer);
|
||||
} finally {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeReset(long nativePointer);
|
||||
private native void jni_YGNodeReset(long nativePointer);
|
||||
@Override
|
||||
public void reset() {
|
||||
mHasSetPadding = false;
|
||||
@@ -106,7 +106,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
mMeasureFunction = null;
|
||||
mData = null;
|
||||
|
||||
jni_CSSNodeReset(mNativePointer);
|
||||
jni_YGNodeReset(mNativePointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,7 +119,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
return mChildren.get(i);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeInsertChild(long nativePointer, long childPointer, int index);
|
||||
private native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
|
||||
@Override
|
||||
public void addChildAt(CSSNode child, int i) {
|
||||
if (child.mParent != null) {
|
||||
@@ -131,16 +131,16 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
}
|
||||
mChildren.add(i, child);
|
||||
child.mParent = this;
|
||||
jni_CSSNodeInsertChild(mNativePointer, child.mNativePointer, i);
|
||||
jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeRemoveChild(long nativePointer, long childPointer);
|
||||
private native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
|
||||
@Override
|
||||
public CSSNode removeChildAt(int i) {
|
||||
|
||||
final CSSNode child = mChildren.remove(i);
|
||||
child.mParent = null;
|
||||
jni_CSSNodeRemoveChild(mNativePointer, child.mNativePointer);
|
||||
jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
|
||||
return child;
|
||||
}
|
||||
|
||||
@@ -155,330 +155,330 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
return mChildren == null ? -1 : mChildren.indexOf(child);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeCalculateLayout(long nativePointer);
|
||||
private native void jni_YGNodeCalculateLayout(long nativePointer);
|
||||
@Override
|
||||
public void calculateLayout() {
|
||||
jni_CSSNodeCalculateLayout(mNativePointer);
|
||||
jni_YGNodeCalculateLayout(mNativePointer);
|
||||
}
|
||||
|
||||
private native boolean jni_CSSNodeHasNewLayout(long nativePointer);
|
||||
private native boolean jni_YGNodeHasNewLayout(long nativePointer);
|
||||
@Override
|
||||
public boolean hasNewLayout() {
|
||||
return jni_CSSNodeHasNewLayout(mNativePointer);
|
||||
return jni_YGNodeHasNewLayout(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeMarkDirty(long nativePointer);
|
||||
private native void jni_YGNodeMarkDirty(long nativePointer);
|
||||
@Override
|
||||
public void dirty() {
|
||||
jni_CSSNodeMarkDirty(mNativePointer);
|
||||
jni_YGNodeMarkDirty(mNativePointer);
|
||||
}
|
||||
|
||||
private native boolean jni_CSSNodeIsDirty(long nativePointer);
|
||||
private native boolean jni_YGNodeIsDirty(long nativePointer);
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
return jni_CSSNodeIsDirty(mNativePointer);
|
||||
return jni_YGNodeIsDirty(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeMarkLayoutSeen(long nativePointer);
|
||||
private native void jni_YGNodeMarkLayoutSeen(long nativePointer);
|
||||
@Override
|
||||
public void markLayoutSeen() {
|
||||
jni_CSSNodeMarkLayoutSeen(mNativePointer);
|
||||
jni_YGNodeMarkLayoutSeen(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeCopyStyle(long dstNativePointer, long srcNativePointer);
|
||||
private native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
|
||||
@Override
|
||||
public void copyStyle(CSSNode srcNode) {
|
||||
jni_CSSNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
|
||||
jni_YGNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetDirection(long nativePointer);
|
||||
private native int jni_YGNodeStyleGetDirection(long nativePointer);
|
||||
@Override
|
||||
public YogaDirection getStyleDirection() {
|
||||
return YogaDirection.values()[jni_CSSNodeStyleGetDirection(mNativePointer)];
|
||||
return YogaDirection.values()[jni_YGNodeStyleGetDirection(mNativePointer)];
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetDirection(long nativePointer, int direction);
|
||||
private native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
|
||||
@Override
|
||||
public void setDirection(YogaDirection direction) {
|
||||
jni_CSSNodeStyleSetDirection(mNativePointer, direction.intValue());
|
||||
jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue());
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetFlexDirection(long nativePointer);
|
||||
private native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
|
||||
@Override
|
||||
public YogaFlexDirection getFlexDirection() {
|
||||
return YogaFlexDirection.values()[jni_CSSNodeStyleGetFlexDirection(mNativePointer)];
|
||||
return YogaFlexDirection.values()[jni_YGNodeStyleGetFlexDirection(mNativePointer)];
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
|
||||
private native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
|
||||
@Override
|
||||
public void setFlexDirection(YogaFlexDirection flexDirection) {
|
||||
jni_CSSNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
|
||||
jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetJustifyContent(long nativePointer);
|
||||
private native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
|
||||
@Override
|
||||
public YogaJustify getJustifyContent() {
|
||||
return YogaJustify.values()[jni_CSSNodeStyleGetJustifyContent(mNativePointer)];
|
||||
return YogaJustify.values()[jni_YGNodeStyleGetJustifyContent(mNativePointer)];
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
|
||||
private native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
|
||||
@Override
|
||||
public void setJustifyContent(YogaJustify justifyContent) {
|
||||
jni_CSSNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
|
||||
jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetAlignItems(long nativePointer);
|
||||
private native int jni_YGNodeStyleGetAlignItems(long nativePointer);
|
||||
@Override
|
||||
public YogaAlign getAlignItems() {
|
||||
return YogaAlign.values()[jni_CSSNodeStyleGetAlignItems(mNativePointer)];
|
||||
return YogaAlign.values()[jni_YGNodeStyleGetAlignItems(mNativePointer)];
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetAlignItems(long nativePointer, int alignItems);
|
||||
private native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
|
||||
@Override
|
||||
public void setAlignItems(YogaAlign alignItems) {
|
||||
jni_CSSNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
|
||||
jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetAlignSelf(long nativePointer);
|
||||
private native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
|
||||
@Override
|
||||
public YogaAlign getAlignSelf() {
|
||||
return YogaAlign.values()[jni_CSSNodeStyleGetAlignSelf(mNativePointer)];
|
||||
return YogaAlign.values()[jni_YGNodeStyleGetAlignSelf(mNativePointer)];
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
|
||||
private native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
|
||||
@Override
|
||||
public void setAlignSelf(YogaAlign alignSelf) {
|
||||
jni_CSSNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
|
||||
jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetAlignContent(long nativePointer);
|
||||
private native int jni_YGNodeStyleGetAlignContent(long nativePointer);
|
||||
@Override
|
||||
public YogaAlign getAlignContent() {
|
||||
return YogaAlign.values()[jni_CSSNodeStyleGetAlignContent(mNativePointer)];
|
||||
return YogaAlign.values()[jni_YGNodeStyleGetAlignContent(mNativePointer)];
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetAlignContent(long nativePointer, int alignContent);
|
||||
private native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
|
||||
@Override
|
||||
public void setAlignContent(YogaAlign alignContent) {
|
||||
jni_CSSNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
|
||||
jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetPositionType(long nativePointer);
|
||||
private native int jni_YGNodeStyleGetPositionType(long nativePointer);
|
||||
@Override
|
||||
public YogaPositionType getPositionType() {
|
||||
return YogaPositionType.values()[jni_CSSNodeStyleGetPositionType(mNativePointer)];
|
||||
return YogaPositionType.values()[jni_YGNodeStyleGetPositionType(mNativePointer)];
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetPositionType(long nativePointer, int positionType);
|
||||
private native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
|
||||
@Override
|
||||
public void setPositionType(YogaPositionType positionType) {
|
||||
jni_CSSNodeStyleSetPositionType(mNativePointer, positionType.intValue());
|
||||
jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue());
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetFlexWrap(long nativePointer, int wrapType);
|
||||
private native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType);
|
||||
@Override
|
||||
public void setWrap(YogaWrap flexWrap) {
|
||||
jni_CSSNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
|
||||
jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetOverflow(long nativePointer);
|
||||
private native int jni_YGNodeStyleGetOverflow(long nativePointer);
|
||||
@Override
|
||||
public YogaOverflow getOverflow() {
|
||||
return YogaOverflow.values()[jni_CSSNodeStyleGetOverflow(mNativePointer)];
|
||||
return YogaOverflow.values()[jni_YGNodeStyleGetOverflow(mNativePointer)];
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetOverflow(long nativePointer, int overflow);
|
||||
private native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
|
||||
@Override
|
||||
public void setOverflow(YogaOverflow overflow) {
|
||||
jni_CSSNodeStyleSetOverflow(mNativePointer, overflow.intValue());
|
||||
jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetFlex(long nativePointer, float flex);
|
||||
private native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
|
||||
@Override
|
||||
public void setFlex(float flex) {
|
||||
jni_CSSNodeStyleSetFlex(mNativePointer, flex);
|
||||
jni_YGNodeStyleSetFlex(mNativePointer, flex);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetFlexGrow(long nativePointer);
|
||||
private native float jni_YGNodeStyleGetFlexGrow(long nativePointer);
|
||||
@Override
|
||||
public float getFlexGrow() {
|
||||
return jni_CSSNodeStyleGetFlexGrow(mNativePointer);
|
||||
return jni_YGNodeStyleGetFlexGrow(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
|
||||
private native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
|
||||
@Override
|
||||
public void setFlexGrow(float flexGrow) {
|
||||
jni_CSSNodeStyleSetFlexGrow(mNativePointer, flexGrow);
|
||||
jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetFlexShrink(long nativePointer);
|
||||
private native float jni_YGNodeStyleGetFlexShrink(long nativePointer);
|
||||
@Override
|
||||
public float getFlexShrink() {
|
||||
return jni_CSSNodeStyleGetFlexShrink(mNativePointer);
|
||||
return jni_YGNodeStyleGetFlexShrink(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
|
||||
private native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
|
||||
@Override
|
||||
public void setFlexShrink(float flexShrink) {
|
||||
jni_CSSNodeStyleSetFlexShrink(mNativePointer, flexShrink);
|
||||
jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetFlexBasis(long nativePointer);
|
||||
private native float jni_YGNodeStyleGetFlexBasis(long nativePointer);
|
||||
@Override
|
||||
public float getFlexBasis() {
|
||||
return jni_CSSNodeStyleGetFlexBasis(mNativePointer);
|
||||
return jni_YGNodeStyleGetFlexBasis(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
|
||||
private native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
|
||||
@Override
|
||||
public void setFlexBasis(float flexBasis) {
|
||||
jni_CSSNodeStyleSetFlexBasis(mNativePointer, flexBasis);
|
||||
jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetMargin(long nativePointer, int edge);
|
||||
private native float jni_YGNodeStyleGetMargin(long nativePointer, int edge);
|
||||
@Override
|
||||
public float getMargin(YogaEdge edge) {
|
||||
if (!mHasSetMargin) {
|
||||
return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED;
|
||||
}
|
||||
return jni_CSSNodeStyleGetMargin(mNativePointer, edge.intValue());
|
||||
return jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetMargin(long nativePointer, int edge, float margin);
|
||||
private native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
|
||||
@Override
|
||||
public void setMargin(YogaEdge edge, float margin) {
|
||||
mHasSetMargin = true;
|
||||
jni_CSSNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
|
||||
jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetPadding(long nativePointer, int edge);
|
||||
private native float jni_YGNodeStyleGetPadding(long nativePointer, int edge);
|
||||
@Override
|
||||
public float getPadding(YogaEdge edge) {
|
||||
if (!mHasSetPadding) {
|
||||
return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED;
|
||||
}
|
||||
return jni_CSSNodeStyleGetPadding(mNativePointer, edge.intValue());
|
||||
return jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetPadding(long nativePointer, int edge, float padding);
|
||||
private native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
|
||||
@Override
|
||||
public void setPadding(YogaEdge edge, float padding) {
|
||||
mHasSetPadding = true;
|
||||
jni_CSSNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
|
||||
jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetBorder(long nativePointer, int edge);
|
||||
private native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
|
||||
@Override
|
||||
public float getBorder(YogaEdge edge) {
|
||||
if (!mHasSetBorder) {
|
||||
return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED;
|
||||
}
|
||||
return jni_CSSNodeStyleGetBorder(mNativePointer, edge.intValue());
|
||||
return jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetBorder(long nativePointer, int edge, float border);
|
||||
private native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
|
||||
@Override
|
||||
public void setBorder(YogaEdge edge, float border) {
|
||||
mHasSetBorder = true;
|
||||
jni_CSSNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
|
||||
jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetPosition(long nativePointer, int edge);
|
||||
private native float jni_YGNodeStyleGetPosition(long nativePointer, int edge);
|
||||
@Override
|
||||
public float getPosition(YogaEdge edge) {
|
||||
if (!mHasSetPosition) {
|
||||
return YogaConstants.UNDEFINED;
|
||||
}
|
||||
return jni_CSSNodeStyleGetPosition(mNativePointer, edge.intValue());
|
||||
return jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetPosition(long nativePointer, int edge, float position);
|
||||
private native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
|
||||
@Override
|
||||
public void setPosition(YogaEdge edge, float position) {
|
||||
mHasSetPosition = true;
|
||||
jni_CSSNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
|
||||
jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetWidth(long nativePointer);
|
||||
private native float jni_YGNodeStyleGetWidth(long nativePointer);
|
||||
@Override
|
||||
public float getWidth() {
|
||||
return jni_CSSNodeStyleGetWidth(mNativePointer);
|
||||
return jni_YGNodeStyleGetWidth(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetWidth(long nativePointer, float width);
|
||||
private native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
|
||||
@Override
|
||||
public void setWidth(float width) {
|
||||
jni_CSSNodeStyleSetWidth(mNativePointer, width);
|
||||
jni_YGNodeStyleSetWidth(mNativePointer, width);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetHeight(long nativePointer);
|
||||
private native float jni_YGNodeStyleGetHeight(long nativePointer);
|
||||
@Override
|
||||
public float getHeight() {
|
||||
return jni_CSSNodeStyleGetHeight(mNativePointer);
|
||||
return jni_YGNodeStyleGetHeight(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetHeight(long nativePointer, float height);
|
||||
private native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
|
||||
@Override
|
||||
public void setHeight(float height) {
|
||||
jni_CSSNodeStyleSetHeight(mNativePointer, height);
|
||||
jni_YGNodeStyleSetHeight(mNativePointer, height);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetMinWidth(long nativePointer);
|
||||
private native float jni_YGNodeStyleGetMinWidth(long nativePointer);
|
||||
@Override
|
||||
public float getMinWidth() {
|
||||
return jni_CSSNodeStyleGetMinWidth(mNativePointer);
|
||||
return jni_YGNodeStyleGetMinWidth(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetMinWidth(long nativePointer, float minWidth);
|
||||
private native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
|
||||
@Override
|
||||
public void setMinWidth(float minWidth) {
|
||||
jni_CSSNodeStyleSetMinWidth(mNativePointer, minWidth);
|
||||
jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetMinHeight(long nativePointer);
|
||||
private native float jni_YGNodeStyleGetMinHeight(long nativePointer);
|
||||
@Override
|
||||
public float getMinHeight() {
|
||||
return jni_CSSNodeStyleGetMinHeight(mNativePointer);
|
||||
return jni_YGNodeStyleGetMinHeight(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetMinHeight(long nativePointer, float minHeight);
|
||||
private native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
|
||||
@Override
|
||||
public void setMinHeight(float minHeight) {
|
||||
jni_CSSNodeStyleSetMinHeight(mNativePointer, minHeight);
|
||||
jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetMaxWidth(long nativePointer);
|
||||
private native float jni_YGNodeStyleGetMaxWidth(long nativePointer);
|
||||
@Override
|
||||
public float getMaxWidth() {
|
||||
return jni_CSSNodeStyleGetMaxWidth(mNativePointer);
|
||||
return jni_YGNodeStyleGetMaxWidth(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
|
||||
private native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
|
||||
@Override
|
||||
public void setMaxWidth(float maxWidth) {
|
||||
jni_CSSNodeStyleSetMaxWidth(mNativePointer, maxWidth);
|
||||
jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetMaxHeight(long nativePointer);
|
||||
private native float jni_YGNodeStyleGetMaxHeight(long nativePointer);
|
||||
@Override
|
||||
public float getMaxHeight() {
|
||||
return jni_CSSNodeStyleGetMaxHeight(mNativePointer);
|
||||
return jni_YGNodeStyleGetMaxHeight(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetMaxHeight(long nativePointer, float maxheight);
|
||||
private native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
|
||||
@Override
|
||||
public void setMaxHeight(float maxheight) {
|
||||
jni_CSSNodeStyleSetMaxHeight(mNativePointer, maxheight);
|
||||
jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetAspectRatio(long nativePointer);
|
||||
private native float jni_YGNodeStyleGetAspectRatio(long nativePointer);
|
||||
public float getAspectRatio() {
|
||||
return jni_CSSNodeStyleGetAspectRatio(mNativePointer);
|
||||
return jni_YGNodeStyleGetAspectRatio(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
|
||||
private native void jni_YGNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
|
||||
public void setAspectRatio(float aspectRatio) {
|
||||
jni_CSSNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
|
||||
jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -506,11 +506,11 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
return YogaDirection.values()[mLayoutDirection];
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
|
||||
private native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
|
||||
@Override
|
||||
public void setMeasureFunction(MeasureFunction measureFunction) {
|
||||
mMeasureFunction = measureFunction;
|
||||
jni_CSSNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
|
||||
jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
|
||||
}
|
||||
|
||||
// Implementation Note: Why this method needs to stay final
|
||||
|
@@ -1,340 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#include <CSSLayout/CSSLayout.h>
|
||||
#include <fb/fbjni.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace facebook::jni;
|
||||
using namespace std;
|
||||
|
||||
static inline weak_ref<jobject> *jobjectContext(CSSNodeRef node) {
|
||||
return reinterpret_cast<weak_ref<jobject> *>(CSSNodeGetContext(node));
|
||||
}
|
||||
|
||||
static void _jniTransferLayoutDirection(CSSNodeRef node, alias_ref<jobject> javaNode) {
|
||||
static auto layoutDirectionField = javaNode->getClass()->getField<jint>("mLayoutDirection");
|
||||
javaNode->setFieldValue(layoutDirectionField, static_cast<jint>(CSSNodeLayoutGetDirection(node)));
|
||||
}
|
||||
|
||||
static void _jniTransferLayoutOutputsRecursive(CSSNodeRef root) {
|
||||
if (auto obj = jobjectContext(root)->lockLocal()) {
|
||||
static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
|
||||
static auto heightField = obj->getClass()->getField<jfloat>("mHeight");
|
||||
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
|
||||
static auto topField = obj->getClass()->getField<jfloat>("mTop");
|
||||
|
||||
obj->setFieldValue(widthField, CSSNodeLayoutGetWidth(root));
|
||||
obj->setFieldValue(heightField, CSSNodeLayoutGetHeight(root));
|
||||
obj->setFieldValue(leftField, CSSNodeLayoutGetLeft(root));
|
||||
obj->setFieldValue(topField, CSSNodeLayoutGetTop(root));
|
||||
_jniTransferLayoutDirection(root, obj);
|
||||
|
||||
for (uint32_t i = 0; i < CSSNodeChildCount(root); i++) {
|
||||
_jniTransferLayoutOutputsRecursive(CSSNodeGetChild(root, i));
|
||||
}
|
||||
} else {
|
||||
CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void _jniPrint(CSSNodeRef node) {
|
||||
if (auto obj = jobjectContext(node)->lockLocal()) {
|
||||
cout << obj->toString() << endl;
|
||||
} else {
|
||||
CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n");
|
||||
}
|
||||
}
|
||||
|
||||
static CSSSize _jniMeasureFunc(CSSNodeRef node,
|
||||
float width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGMeasureMode heightMode) {
|
||||
if (auto obj = jobjectContext(node)->lockLocal()) {
|
||||
static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode")
|
||||
->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
|
||||
|
||||
_jniTransferLayoutDirection(node, obj);
|
||||
const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode);
|
||||
|
||||
static_assert(sizeof(measureResult) == 8,
|
||||
"Expected measureResult to be 8 bytes, or two 32 bit ints");
|
||||
|
||||
const float measuredWidth = static_cast<float>(0xFFFFFFFF & (measureResult >> 32));
|
||||
const float measuredHeight = static_cast<float>(0xFFFFFFFF & measureResult);
|
||||
|
||||
return CSSSize{measuredWidth, measuredHeight};
|
||||
} else {
|
||||
CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n");
|
||||
return CSSSize{
|
||||
widthMode == YGMeasureModeUndefined ? 0 : width,
|
||||
heightMode == YGMeasureModeUndefined ? 0 : height,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
struct JYogaLogLevel : public JavaClass<JYogaLogLevel> {
|
||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/YogaLogLevel;";
|
||||
};
|
||||
|
||||
static global_ref<jobject> *jLogger;
|
||||
static int _jniLog(YGLogLevel level, const char *format, va_list args) {
|
||||
char buffer[256];
|
||||
int result = vsnprintf(buffer, sizeof(buffer), format, args);
|
||||
|
||||
static auto logFunc = findClassLocal("com/facebook/csslayout/CSSLogger")
|
||||
->getMethod<void(local_ref<JYogaLogLevel>, jstring)>("log");
|
||||
|
||||
static auto logLevelFromInt =
|
||||
JYogaLogLevel::javaClassStatic()->getStaticMethod<JYogaLogLevel::javaobject(jint)>("fromInt");
|
||||
|
||||
logFunc(jLogger->get(),
|
||||
logLevelFromInt(JYogaLogLevel::javaClassStatic(), static_cast<jint>(level)),
|
||||
Environment::current()->NewStringUTF(buffer));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline CSSNodeRef _jlong2CSSNodeRef(jlong addr) {
|
||||
return reinterpret_cast<CSSNodeRef>(static_cast<intptr_t>(addr));
|
||||
}
|
||||
|
||||
void jni_CSSLayoutSetLogger(alias_ref<jclass> clazz, alias_ref<jobject> logger) {
|
||||
if (jLogger) {
|
||||
jLogger->releaseAlias();
|
||||
delete jLogger;
|
||||
}
|
||||
|
||||
if (logger) {
|
||||
jLogger = new global_ref<jobject>(make_global(logger));
|
||||
CSSLayoutSetLogger(_jniLog);
|
||||
} else {
|
||||
jLogger = NULL;
|
||||
CSSLayoutSetLogger(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void jni_CSSLog(alias_ref<jclass> clazz, jint level, jstring message) {
|
||||
const char *nMessage = Environment::current()->GetStringUTFChars(message, 0);
|
||||
CSSLog(static_cast<YGLogLevel>(level), "%s", nMessage);
|
||||
Environment::current()->ReleaseStringUTFChars(message, nMessage);
|
||||
}
|
||||
|
||||
void jni_CSSLayoutSetExperimentalFeatureEnabled(alias_ref<jclass> clazz,
|
||||
jint feature,
|
||||
jboolean enabled) {
|
||||
CSSLayoutSetExperimentalFeatureEnabled(static_cast<YGExperimentalFeature>(feature), enabled);
|
||||
}
|
||||
|
||||
jboolean jni_CSSLayoutIsExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature) {
|
||||
return CSSLayoutIsExperimentalFeatureEnabled(static_cast<YGExperimentalFeature>(feature));
|
||||
}
|
||||
|
||||
jint jni_CSSNodeGetInstanceCount(alias_ref<jclass> clazz) {
|
||||
return CSSNodeGetInstanceCount();
|
||||
}
|
||||
|
||||
jlong jni_CSSNodeNew(alias_ref<jobject> thiz) {
|
||||
const CSSNodeRef node = CSSNodeNew();
|
||||
CSSNodeSetContext(node, new weak_ref<jobject>(make_weak(thiz)));
|
||||
CSSNodeSetPrintFunc(node, _jniPrint);
|
||||
return reinterpret_cast<jlong>(node);
|
||||
}
|
||||
|
||||
void jni_CSSNodeFree(alias_ref<jobject> thiz, jlong nativePointer) {
|
||||
const CSSNodeRef node = _jlong2CSSNodeRef(nativePointer);
|
||||
delete jobjectContext(node);
|
||||
CSSNodeFree(node);
|
||||
}
|
||||
|
||||
void jni_CSSNodeReset(alias_ref<jobject> thiz, jlong nativePointer) {
|
||||
const CSSNodeRef node = _jlong2CSSNodeRef(nativePointer);
|
||||
void *context = CSSNodeGetContext(node);
|
||||
CSSNodeReset(node);
|
||||
CSSNodeSetContext(node, context);
|
||||
CSSNodeSetPrintFunc(node, _jniPrint);
|
||||
}
|
||||
|
||||
void jni_CSSNodeInsertChild(alias_ref<jobject>,
|
||||
jlong nativePointer,
|
||||
jlong childPointer,
|
||||
jint index) {
|
||||
CSSNodeInsertChild(_jlong2CSSNodeRef(nativePointer), _jlong2CSSNodeRef(childPointer), index);
|
||||
}
|
||||
|
||||
void jni_CSSNodeRemoveChild(alias_ref<jobject>, jlong nativePointer, jlong childPointer) {
|
||||
CSSNodeRemoveChild(_jlong2CSSNodeRef(nativePointer), _jlong2CSSNodeRef(childPointer));
|
||||
}
|
||||
|
||||
void jni_CSSNodeCalculateLayout(alias_ref<jobject>, jlong nativePointer) {
|
||||
const CSSNodeRef root = _jlong2CSSNodeRef(nativePointer);
|
||||
CSSNodeCalculateLayout(root,
|
||||
YGUndefined,
|
||||
YGUndefined,
|
||||
CSSNodeStyleGetDirection(_jlong2CSSNodeRef(nativePointer)));
|
||||
_jniTransferLayoutOutputsRecursive(root);
|
||||
}
|
||||
|
||||
void jni_CSSNodeMarkDirty(alias_ref<jobject>, jlong nativePointer) {
|
||||
CSSNodeMarkDirty(_jlong2CSSNodeRef(nativePointer));
|
||||
}
|
||||
|
||||
jboolean jni_CSSNodeIsDirty(alias_ref<jobject>, jlong nativePointer) {
|
||||
return (jboolean) CSSNodeIsDirty(_jlong2CSSNodeRef(nativePointer));
|
||||
}
|
||||
|
||||
void jni_CSSNodeSetHasMeasureFunc(alias_ref<jobject>,
|
||||
jlong nativePointer,
|
||||
jboolean hasMeasureFunc) {
|
||||
CSSNodeSetMeasureFunc(_jlong2CSSNodeRef(nativePointer), hasMeasureFunc ? _jniMeasureFunc : NULL);
|
||||
}
|
||||
|
||||
jboolean jni_CSSNodeHasNewLayout(alias_ref<jobject>, jlong nativePointer) {
|
||||
return (jboolean) CSSNodeGetHasNewLayout(_jlong2CSSNodeRef(nativePointer));
|
||||
}
|
||||
|
||||
void jni_CSSNodeMarkLayoutSeen(alias_ref<jobject>, jlong nativePointer) {
|
||||
CSSNodeSetHasNewLayout(_jlong2CSSNodeRef(nativePointer), false);
|
||||
}
|
||||
|
||||
void jni_CSSNodeCopyStyle(alias_ref<jobject>, jlong dstNativePointer, jlong srcNativePointer) {
|
||||
CSSNodeCopyStyle(_jlong2CSSNodeRef(dstNativePointer), _jlong2CSSNodeRef(srcNativePointer));
|
||||
}
|
||||
|
||||
#define CSS_NODE_JNI_STYLE_PROP(javatype, type, name) \
|
||||
javatype jni_CSSNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer) { \
|
||||
return (javatype) CSSNodeStyleGet##name(_jlong2CSSNodeRef(nativePointer)); \
|
||||
} \
|
||||
\
|
||||
void jni_CSSNodeStyleSet##name(alias_ref<jobject>, jlong nativePointer, javatype value) { \
|
||||
CSSNodeStyleSet##name(_jlong2CSSNodeRef(nativePointer), static_cast<type>(value)); \
|
||||
}
|
||||
|
||||
#define CSS_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
|
||||
javatype jni_CSSNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer, jint edge) { \
|
||||
return (javatype) CSSNodeStyleGet##name(_jlong2CSSNodeRef(nativePointer), \
|
||||
static_cast<YGEdge>(edge)); \
|
||||
} \
|
||||
\
|
||||
void jni_CSSNodeStyleSet##name(alias_ref<jobject>, \
|
||||
jlong nativePointer, \
|
||||
jint edge, \
|
||||
javatype value) { \
|
||||
CSSNodeStyleSet##name(_jlong2CSSNodeRef(nativePointer), \
|
||||
static_cast<YGEdge>(edge), \
|
||||
static_cast<type>(value)); \
|
||||
}
|
||||
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection);
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent);
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignItems);
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignSelf);
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignContent);
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, YGPositionType, PositionType);
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap);
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow);
|
||||
|
||||
void jni_CSSNodeStyleSetFlex(alias_ref<jobject>, jlong nativePointer, jfloat value) {
|
||||
CSSNodeStyleSetFlex(_jlong2CSSNodeRef(nativePointer), static_cast<float>(value));
|
||||
}
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexBasis);
|
||||
|
||||
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Position);
|
||||
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Margin);
|
||||
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Padding);
|
||||
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Border);
|
||||
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, Width);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinWidth);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MaxWidth);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, Height);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinHeight);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MaxHeight);
|
||||
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
|
||||
|
||||
#define CSSMakeNativeMethod(name) makeNativeMethod(#name, name)
|
||||
|
||||
jint JNI_OnLoad(JavaVM *vm, void *) {
|
||||
return initialize(vm, [] {
|
||||
registerNatives("com/facebook/csslayout/CSSNode",
|
||||
{
|
||||
CSSMakeNativeMethod(jni_CSSNodeNew),
|
||||
CSSMakeNativeMethod(jni_CSSNodeFree),
|
||||
CSSMakeNativeMethod(jni_CSSNodeReset),
|
||||
CSSMakeNativeMethod(jni_CSSNodeInsertChild),
|
||||
CSSMakeNativeMethod(jni_CSSNodeRemoveChild),
|
||||
CSSMakeNativeMethod(jni_CSSNodeCalculateLayout),
|
||||
CSSMakeNativeMethod(jni_CSSNodeHasNewLayout),
|
||||
CSSMakeNativeMethod(jni_CSSNodeMarkDirty),
|
||||
CSSMakeNativeMethod(jni_CSSNodeIsDirty),
|
||||
CSSMakeNativeMethod(jni_CSSNodeMarkLayoutSeen),
|
||||
CSSMakeNativeMethod(jni_CSSNodeSetHasMeasureFunc),
|
||||
CSSMakeNativeMethod(jni_CSSNodeCopyStyle),
|
||||
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetDirection),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetDirection),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexDirection),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexDirection),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetJustifyContent),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetJustifyContent),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignItems),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignItems),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignSelf),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignSelf),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignContent),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignContent),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetPositionType),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetPositionType),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexWrap),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetOverflow),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetOverflow),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlex),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexGrow),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexGrow),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexShrink),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexShrink),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexBasis),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexBasis),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetMargin),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetMargin),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetPadding),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetPadding),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetBorder),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetBorder),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetPosition),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetPosition),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetWidth),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetWidth),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetHeight),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetHeight),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetMinWidth),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetMinWidth),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetMinHeight),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetMinHeight),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetMaxWidth),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxWidth),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetMaxHeight),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxHeight),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetAspectRatio),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetAspectRatio),
|
||||
|
||||
CSSMakeNativeMethod(jni_CSSNodeGetInstanceCount),
|
||||
CSSMakeNativeMethod(jni_CSSLayoutSetLogger),
|
||||
CSSMakeNativeMethod(jni_CSSLog),
|
||||
CSSMakeNativeMethod(jni_CSSLayoutSetExperimentalFeatureEnabled),
|
||||
CSSMakeNativeMethod(jni_CSSLayoutIsExperimentalFeatureEnabled),
|
||||
});
|
||||
});
|
||||
}
|
333
java/jni/YGJNI.cpp
Normal file
333
java/jni/YGJNI.cpp
Normal file
@@ -0,0 +1,333 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#include <CSSLayout/Yoga.h>
|
||||
#include <fb/fbjni.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace facebook::jni;
|
||||
using namespace std;
|
||||
|
||||
static inline weak_ref<jobject> *YGNodeJobject(YGNodeRef node) {
|
||||
return reinterpret_cast<weak_ref<jobject> *>(YGNodeGetContext(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) {
|
||||
if (auto obj = YGNodeJobject(root)->lockLocal()) {
|
||||
static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
|
||||
static auto heightField = obj->getClass()->getField<jfloat>("mHeight");
|
||||
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
|
||||
static auto topField = obj->getClass()->getField<jfloat>("mTop");
|
||||
|
||||
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
|
||||
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
|
||||
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
|
||||
obj->setFieldValue(topField, YGNodeLayoutGetTop(root));
|
||||
YGTransferLayoutDirection(root, obj);
|
||||
|
||||
for (uint32_t i = 0; i < YGNodeChildCount(root); i++) {
|
||||
YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i));
|
||||
}
|
||||
} else {
|
||||
YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void YGPrint(YGNodeRef node) {
|
||||
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
||||
cout << obj->toString() << endl;
|
||||
} else {
|
||||
YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
||||
}
|
||||
}
|
||||
|
||||
static YGSize YGJNIMeasureFunc(YGNodeRef node,
|
||||
float width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGMeasureMode heightMode) {
|
||||
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
||||
static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode")
|
||||
->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
|
||||
|
||||
YGTransferLayoutDirection(node, obj);
|
||||
const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode);
|
||||
|
||||
static_assert(sizeof(measureResult) == 8,
|
||||
"Expected measureResult to be 8 bytes, or two 32 bit ints");
|
||||
|
||||
const float measuredWidth = static_cast<float>(0xFFFFFFFF & (measureResult >> 32));
|
||||
const float measuredHeight = static_cast<float>(0xFFFFFFFF & measureResult);
|
||||
|
||||
return YGSize{measuredWidth, measuredHeight};
|
||||
} else {
|
||||
YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
||||
return YGSize{
|
||||
widthMode == YGMeasureModeUndefined ? 0 : width,
|
||||
heightMode == YGMeasureModeUndefined ? 0 : height,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
struct JYogaLogLevel : public JavaClass<JYogaLogLevel> {
|
||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/YogaLogLevel;";
|
||||
};
|
||||
|
||||
static global_ref<jobject> *jLogger;
|
||||
static int YGLog(YGLogLevel level, const char *format, va_list args) {
|
||||
char buffer[256];
|
||||
int result = vsnprintf(buffer, sizeof(buffer), format, args);
|
||||
|
||||
static auto logFunc = findClassLocal("com/facebook/csslayout/CSSLogger")
|
||||
->getMethod<void(local_ref<JYogaLogLevel>, jstring)>("log");
|
||||
|
||||
static auto logLevelFromInt =
|
||||
JYogaLogLevel::javaClassStatic()->getStaticMethod<JYogaLogLevel::javaobject(jint)>("fromInt");
|
||||
|
||||
logFunc(jLogger->get(),
|
||||
logLevelFromInt(JYogaLogLevel::javaClassStatic(), static_cast<jint>(level)),
|
||||
Environment::current()->NewStringUTF(buffer));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline YGNodeRef _jlong2YGNodeRef(jlong addr) {
|
||||
return reinterpret_cast<YGNodeRef>(static_cast<intptr_t>(addr));
|
||||
}
|
||||
|
||||
void jni_YGSetLogger(alias_ref<jclass> clazz, alias_ref<jobject> logger) {
|
||||
if (jLogger) {
|
||||
jLogger->releaseAlias();
|
||||
delete jLogger;
|
||||
}
|
||||
|
||||
if (logger) {
|
||||
jLogger = new global_ref<jobject>(make_global(logger));
|
||||
YGSetLogger(YGLog);
|
||||
} else {
|
||||
jLogger = NULL;
|
||||
YGSetLogger(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void jni_YGLog(alias_ref<jclass> clazz, jint level, jstring message) {
|
||||
const char *nMessage = Environment::current()->GetStringUTFChars(message, 0);
|
||||
YGLog(static_cast<YGLogLevel>(level), "%s", nMessage);
|
||||
Environment::current()->ReleaseStringUTFChars(message, nMessage);
|
||||
}
|
||||
|
||||
void jni_YGSetExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature, jboolean enabled) {
|
||||
YGSetExperimentalFeatureEnabled(static_cast<YGExperimentalFeature>(feature), enabled);
|
||||
}
|
||||
|
||||
jboolean jni_YGIsExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature) {
|
||||
return YGIsExperimentalFeatureEnabled(static_cast<YGExperimentalFeature>(feature));
|
||||
}
|
||||
|
||||
jint jni_YGNodeGetInstanceCount(alias_ref<jclass> clazz) {
|
||||
return YGNodeGetInstanceCount();
|
||||
}
|
||||
|
||||
jlong jni_YGNodeNew(alias_ref<jobject> thiz) {
|
||||
const YGNodeRef node = YGNodeNew();
|
||||
YGNodeSetContext(node, new weak_ref<jobject>(make_weak(thiz)));
|
||||
YGNodeSetPrintFunc(node, YGPrint);
|
||||
return reinterpret_cast<jlong>(node);
|
||||
}
|
||||
|
||||
void jni_YGNodeFree(alias_ref<jobject> thiz, jlong nativePointer) {
|
||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
||||
delete YGNodeJobject(node);
|
||||
YGNodeFree(node);
|
||||
}
|
||||
|
||||
void jni_YGNodeReset(alias_ref<jobject> thiz, jlong nativePointer) {
|
||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
||||
void *context = YGNodeGetContext(node);
|
||||
YGNodeReset(node);
|
||||
YGNodeSetContext(node, context);
|
||||
YGNodeSetPrintFunc(node, YGPrint);
|
||||
}
|
||||
|
||||
void jni_YGNodeInsertChild(alias_ref<jobject>, jlong nativePointer, jlong childPointer, jint index) {
|
||||
YGNodeInsertChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
|
||||
}
|
||||
|
||||
void jni_YGNodeRemoveChild(alias_ref<jobject>, jlong nativePointer, jlong childPointer) {
|
||||
YGNodeRemoveChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer));
|
||||
}
|
||||
|
||||
void jni_YGNodeCalculateLayout(alias_ref<jobject>, jlong nativePointer) {
|
||||
const YGNodeRef root = _jlong2YGNodeRef(nativePointer);
|
||||
YGNodeCalculateLayout(root,
|
||||
YGUndefined,
|
||||
YGUndefined,
|
||||
YGNodeStyleGetDirection(_jlong2YGNodeRef(nativePointer)));
|
||||
YGTransferLayoutOutputsRecursive(root);
|
||||
}
|
||||
|
||||
void jni_YGNodeMarkDirty(alias_ref<jobject>, jlong nativePointer) {
|
||||
YGNodeMarkDirty(_jlong2YGNodeRef(nativePointer));
|
||||
}
|
||||
|
||||
jboolean jni_YGNodeIsDirty(alias_ref<jobject>, jlong nativePointer) {
|
||||
return (jboolean) YGNodeIsDirty(_jlong2YGNodeRef(nativePointer));
|
||||
}
|
||||
|
||||
void jni_YGNodeSetHasMeasureFunc(alias_ref<jobject>, jlong nativePointer, jboolean hasMeasureFunc) {
|
||||
YGNodeSetMeasureFunc(_jlong2YGNodeRef(nativePointer), hasMeasureFunc ? YGJNIMeasureFunc : NULL);
|
||||
}
|
||||
|
||||
jboolean jni_YGNodeHasNewLayout(alias_ref<jobject>, jlong nativePointer) {
|
||||
return (jboolean) YGNodeGetHasNewLayout(_jlong2YGNodeRef(nativePointer));
|
||||
}
|
||||
|
||||
void jni_YGNodeMarkLayoutSeen(alias_ref<jobject>, jlong nativePointer) {
|
||||
YGNodeSetHasNewLayout(_jlong2YGNodeRef(nativePointer), false);
|
||||
}
|
||||
|
||||
void jni_YGNodeCopyStyle(alias_ref<jobject>, jlong dstNativePointer, jlong srcNativePointer) {
|
||||
YGNodeCopyStyle(_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer));
|
||||
}
|
||||
|
||||
#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
|
||||
javatype jni_YGNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer) { \
|
||||
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
|
||||
} \
|
||||
\
|
||||
void jni_YGNodeStyleSet##name(alias_ref<jobject>, jlong nativePointer, javatype value) { \
|
||||
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
|
||||
}
|
||||
|
||||
#define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
|
||||
javatype jni_YGNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer, jint edge) { \
|
||||
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer), \
|
||||
static_cast<YGEdge>(edge)); \
|
||||
} \
|
||||
\
|
||||
void jni_YGNodeStyleSet##name(alias_ref<jobject>, \
|
||||
jlong nativePointer, \
|
||||
jint edge, \
|
||||
javatype value) { \
|
||||
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), \
|
||||
static_cast<YGEdge>(edge), \
|
||||
static_cast<type>(value)); \
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
void jni_YGNodeStyleSetFlex(alias_ref<jobject>, 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_PROP(jfloat, float, FlexBasis);
|
||||
|
||||
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Position);
|
||||
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Margin);
|
||||
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Padding);
|
||||
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Border);
|
||||
|
||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, Width);
|
||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, MinWidth);
|
||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, MaxWidth);
|
||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, Height);
|
||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, MinHeight);
|
||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, MaxHeight);
|
||||
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
|
||||
|
||||
#define YGMakeNativeMethod(name) makeNativeMethod(#name, name)
|
||||
|
||||
jint JNI_OnLoad(JavaVM *vm, void *) {
|
||||
return initialize(vm, [] {
|
||||
registerNatives("com/facebook/csslayout/CSSNode",
|
||||
{
|
||||
YGMakeNativeMethod(jni_YGNodeNew),
|
||||
YGMakeNativeMethod(jni_YGNodeFree),
|
||||
YGMakeNativeMethod(jni_YGNodeReset),
|
||||
YGMakeNativeMethod(jni_YGNodeInsertChild),
|
||||
YGMakeNativeMethod(jni_YGNodeRemoveChild),
|
||||
YGMakeNativeMethod(jni_YGNodeCalculateLayout),
|
||||
YGMakeNativeMethod(jni_YGNodeHasNewLayout),
|
||||
YGMakeNativeMethod(jni_YGNodeMarkDirty),
|
||||
YGMakeNativeMethod(jni_YGNodeIsDirty),
|
||||
YGMakeNativeMethod(jni_YGNodeMarkLayoutSeen),
|
||||
YGMakeNativeMethod(jni_YGNodeSetHasMeasureFunc),
|
||||
YGMakeNativeMethod(jni_YGNodeCopyStyle),
|
||||
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetDirection),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetDirection),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetFlexDirection),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetFlexDirection),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetJustifyContent),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetJustifyContent),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetAlignItems),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetAlignItems),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetAlignSelf),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetAlignSelf),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetAlignContent),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetAlignContent),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetPositionType),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetPositionType),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetFlexWrap),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetOverflow),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetOverflow),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetFlex),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetFlexGrow),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetFlexGrow),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetFlexShrink),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetFlexShrink),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetFlexBasis),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetFlexBasis),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetMargin),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetMargin),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetPadding),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetPadding),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetBorder),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetBorder),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetPosition),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetPosition),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetWidth),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetWidth),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetHeight),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetHeight),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetMinWidth),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetMinWidth),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetMinHeight),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetMinHeight),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetMaxWidth),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetMaxWidth),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetMaxHeight),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetMaxHeight),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetAspectRatio),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetAspectRatio),
|
||||
|
||||
YGMakeNativeMethod(jni_YGNodeGetInstanceCount),
|
||||
YGMakeNativeMethod(jni_YGSetLogger),
|
||||
YGMakeNativeMethod(jni_YGLog),
|
||||
YGMakeNativeMethod(jni_YGSetExperimentalFeatureEnabled),
|
||||
YGMakeNativeMethod(jni_YGIsExperimentalFeatureEnabled),
|
||||
});
|
||||
});
|
||||
}
|
@@ -18,9 +18,9 @@ public class CSSNodeTest {
|
||||
|
||||
@Test
|
||||
public void testInit() {
|
||||
final int refCount = CSSNode.jni_CSSNodeGetInstanceCount();
|
||||
final int refCount = CSSNode.jni_YGNodeGetInstanceCount();
|
||||
final CSSNode node = new CSSNode();
|
||||
assertEquals(refCount + 1, CSSNode.jni_CSSNodeGetInstanceCount());
|
||||
assertEquals(refCount + 1, CSSNode.jni_YGNodeGetInstanceCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -52,7 +52,7 @@ public class CSSNodeTest {
|
||||
mLogMessage = message;
|
||||
}
|
||||
});
|
||||
CSSNode.jni_CSSLog(YogaLogLevel.DEBUG.intValue(), "Hello");
|
||||
CSSNode.jni_YGLog(YogaLogLevel.DEBUG.intValue(), "Hello");
|
||||
assertEquals(YogaLogLevel.DEBUG, mLogLevel);
|
||||
assertEquals("Hello", mLogMessage);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class CSSNodeTest {
|
||||
mLogMessage = message;
|
||||
}
|
||||
});
|
||||
CSSNode.jni_CSSLog(YogaLogLevel.VERBOSE.intValue(), "Flexbox");
|
||||
CSSNode.jni_YGLog(YogaLogLevel.VERBOSE.intValue(), "Flexbox");
|
||||
assertEquals(YogaLogLevel.VERBOSE, mLogLevel);
|
||||
assertEquals("Flexbox", mLogMessage);
|
||||
}
|
||||
|
Reference in New Issue
Block a user