Adapt methods for fast calls

Summary:
Changes all possible native JNI methods to critical methods.

For now, this only changes Android up and including v7. In order to be prepared for the `CriticalNative` annotation in Android v8, the following restrictions apply:

- Qualifying methods must be static (this is also enforced for Dalvik / Android v4)
- Method implementations can only consume primitive JNI types (`boolean`, jchar`, etc.)

Reviewed By: priteshrnandgaonkar

Differential Revision: D9943868

fbshipit-source-id: 728817eb37822b717fd3daf94cd9f02b42c17db6
This commit is contained in:
David Aurelio 2018-09-25 15:44:42 -07:00 committed by Facebook Github Bot
parent ee6c1ecef0
commit 27a3bdb886
3 changed files with 268 additions and 280 deletions

View File

@ -117,7 +117,7 @@ public class YogaNode implements Cloneable {
} }
} }
private native void jni_YGNodeReset(long nativePointer); private static native void jni_YGNodeReset(long nativePointer);
public void reset() { public void reset() {
mEdgeSetFlag = 0; mEdgeSetFlag = 0;
mHasSetPosition = false; mHasSetPosition = false;
@ -160,7 +160,7 @@ public class YogaNode implements Cloneable {
return mChildren.get(i); return mChildren.get(i);
} }
private native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index); private static native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
public void addChildAt(YogaNode child, int i) { public void addChildAt(YogaNode child, int i) {
if (child.mOwner != null) { if (child.mOwner != null) {
throw new IllegalStateException("Child already has a parent, it must be removed first."); throw new IllegalStateException("Child already has a parent, it must be removed first.");
@ -174,7 +174,7 @@ public class YogaNode implements Cloneable {
jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i); jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
} }
private native void jni_YGNodeInsertSharedChild(long nativePointer, long childPointer, int index); private static native void jni_YGNodeInsertSharedChild(long nativePointer, long childPointer, int index);
public void addSharedChildAt(YogaNode child, int i) { public void addSharedChildAt(YogaNode child, int i) {
if (mChildren == null) { if (mChildren == null) {
@ -185,7 +185,7 @@ public class YogaNode implements Cloneable {
jni_YGNodeInsertSharedChild(mNativePointer, child.mNativePointer, i); jni_YGNodeInsertSharedChild(mNativePointer, child.mNativePointer, i);
} }
private native void jni_YGNodeSetOwner(long nativePointer, long newOwnerNativePointer); private static native void jni_YGNodeSetOwner(long nativePointer, long newOwnerNativePointer);
private native long jni_YGNodeClone(long nativePointer, Object newNode); private native long jni_YGNodeClone(long nativePointer, Object newNode);
@ -197,7 +197,7 @@ public class YogaNode implements Cloneable {
if (mChildren != null) { if (mChildren != null) {
for (YogaNode child : mChildren) { for (YogaNode child : mChildren) {
child.jni_YGNodeSetOwner(child.mNativePointer, 0); YogaNode.jni_YGNodeSetOwner(child.mNativePointer, 0);
child.mOwner = null; child.mOwner = null;
} }
} }
@ -232,14 +232,14 @@ public class YogaNode implements Cloneable {
} }
} }
private native void jni_YGNodeClearChildren(long nativePointer); private static native void jni_YGNodeClearChildren(long nativePointer);
private void clearChildren() { private void clearChildren() {
mChildren = null; mChildren = null;
jni_YGNodeClearChildren(mNativePointer); jni_YGNodeClearChildren(mNativePointer);
} }
private native void jni_YGNodeRemoveChild(long nativePointer, long childPointer); private static native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
public YogaNode removeChildAt(int i) { public YogaNode removeChildAt(int i) {
if (mChildren == null) { if (mChildren == null) {
throw new IllegalStateException( throw new IllegalStateException(
@ -275,7 +275,7 @@ public class YogaNode implements Cloneable {
return mChildren == null ? -1 : mChildren.indexOf(child); return mChildren == null ? -1 : mChildren.indexOf(child);
} }
private native void jni_YGNodeCalculateLayout(long nativePointer, float width, float height); private static native void jni_YGNodeCalculateLayout(long nativePointer, float width, float height);
public void calculateLayout(float width, float height) { public void calculateLayout(float width, float height) {
jni_YGNodeCalculateLayout(mNativePointer, width, height); jni_YGNodeCalculateLayout(mNativePointer, width, height);
} }
@ -284,23 +284,23 @@ public class YogaNode implements Cloneable {
return mHasNewLayout; return mHasNewLayout;
} }
private native void jni_YGNodeMarkDirty(long nativePointer); private static native void jni_YGNodeMarkDirty(long nativePointer);
public void dirty() { public void dirty() {
jni_YGNodeMarkDirty(mNativePointer); jni_YGNodeMarkDirty(mNativePointer);
} }
private native void jni_YGNodeMarkDirtyAndPropogateToDescendants(long nativePointer); private static native void jni_YGNodeMarkDirtyAndPropogateToDescendants(long nativePointer);
public void dirtyAllDescendants() { public void dirtyAllDescendants() {
jni_YGNodeMarkDirtyAndPropogateToDescendants(mNativePointer); jni_YGNodeMarkDirtyAndPropogateToDescendants(mNativePointer);
} }
private native boolean jni_YGNodeIsDirty(long nativePointer); private static native boolean jni_YGNodeIsDirty(long nativePointer);
public boolean isDirty() { public boolean isDirty() {
return jni_YGNodeIsDirty(mNativePointer); return jni_YGNodeIsDirty(mNativePointer);
} }
private native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer); private static native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
public void copyStyle(YogaNode srcNode) { public void copyStyle(YogaNode srcNode) {
jni_YGNodeCopyStyle(mNativePointer, srcNode.mNativePointer); jni_YGNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
} }
@ -309,147 +309,147 @@ public class YogaNode implements Cloneable {
mHasNewLayout = false; mHasNewLayout = false;
} }
private native int jni_YGNodeStyleGetDirection(long nativePointer); private static native int jni_YGNodeStyleGetDirection(long nativePointer);
public YogaDirection getStyleDirection() { public YogaDirection getStyleDirection() {
return YogaDirection.fromInt(jni_YGNodeStyleGetDirection(mNativePointer)); return YogaDirection.fromInt(jni_YGNodeStyleGetDirection(mNativePointer));
} }
private native void jni_YGNodeStyleSetDirection(long nativePointer, int direction); private static native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
public void setDirection(YogaDirection direction) { public void setDirection(YogaDirection direction) {
jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue()); jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue());
} }
private native int jni_YGNodeStyleGetFlexDirection(long nativePointer); private static native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
public YogaFlexDirection getFlexDirection() { public YogaFlexDirection getFlexDirection() {
return YogaFlexDirection.fromInt(jni_YGNodeStyleGetFlexDirection(mNativePointer)); return YogaFlexDirection.fromInt(jni_YGNodeStyleGetFlexDirection(mNativePointer));
} }
private native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection); private static native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
public void setFlexDirection(YogaFlexDirection flexDirection) { public void setFlexDirection(YogaFlexDirection flexDirection) {
jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue()); jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
} }
private native int jni_YGNodeStyleGetJustifyContent(long nativePointer); private static native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
public YogaJustify getJustifyContent() { public YogaJustify getJustifyContent() {
return YogaJustify.fromInt(jni_YGNodeStyleGetJustifyContent(mNativePointer)); return YogaJustify.fromInt(jni_YGNodeStyleGetJustifyContent(mNativePointer));
} }
private native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent); private static native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
public void setJustifyContent(YogaJustify justifyContent) { public void setJustifyContent(YogaJustify justifyContent) {
jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue()); jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
} }
private native int jni_YGNodeStyleGetAlignItems(long nativePointer); private static native int jni_YGNodeStyleGetAlignItems(long nativePointer);
public YogaAlign getAlignItems() { public YogaAlign getAlignItems() {
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignItems(mNativePointer)); return YogaAlign.fromInt(jni_YGNodeStyleGetAlignItems(mNativePointer));
} }
private native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems); private static native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
public void setAlignItems(YogaAlign alignItems) { public void setAlignItems(YogaAlign alignItems) {
jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue()); jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
} }
private native int jni_YGNodeStyleGetAlignSelf(long nativePointer); private static native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
public YogaAlign getAlignSelf() { public YogaAlign getAlignSelf() {
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignSelf(mNativePointer)); return YogaAlign.fromInt(jni_YGNodeStyleGetAlignSelf(mNativePointer));
} }
private native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf); private static native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
public void setAlignSelf(YogaAlign alignSelf) { public void setAlignSelf(YogaAlign alignSelf) {
jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue()); jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
} }
private native int jni_YGNodeStyleGetAlignContent(long nativePointer); private static native int jni_YGNodeStyleGetAlignContent(long nativePointer);
public YogaAlign getAlignContent() { public YogaAlign getAlignContent() {
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignContent(mNativePointer)); return YogaAlign.fromInt(jni_YGNodeStyleGetAlignContent(mNativePointer));
} }
private native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent); private static native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
public void setAlignContent(YogaAlign alignContent) { public void setAlignContent(YogaAlign alignContent) {
jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue()); jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
} }
private native int jni_YGNodeStyleGetPositionType(long nativePointer); private static native int jni_YGNodeStyleGetPositionType(long nativePointer);
public YogaPositionType getPositionType() { public YogaPositionType getPositionType() {
return YogaPositionType.fromInt(jni_YGNodeStyleGetPositionType(mNativePointer)); return YogaPositionType.fromInt(jni_YGNodeStyleGetPositionType(mNativePointer));
} }
private native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType); private static native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
public void setPositionType(YogaPositionType positionType) { public void setPositionType(YogaPositionType positionType) {
jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue()); jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue());
} }
private native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType); private static native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType);
public void setWrap(YogaWrap flexWrap) { public void setWrap(YogaWrap flexWrap) {
jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue()); jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
} }
private native int jni_YGNodeStyleGetOverflow(long nativePointer); private static native int jni_YGNodeStyleGetOverflow(long nativePointer);
public YogaOverflow getOverflow() { public YogaOverflow getOverflow() {
return YogaOverflow.fromInt(jni_YGNodeStyleGetOverflow(mNativePointer)); return YogaOverflow.fromInt(jni_YGNodeStyleGetOverflow(mNativePointer));
} }
private native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow); private static native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
public void setOverflow(YogaOverflow overflow) { public void setOverflow(YogaOverflow overflow) {
jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue()); jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
} }
private native int jni_YGNodeStyleGetDisplay(long nativePointer); private static native int jni_YGNodeStyleGetDisplay(long nativePointer);
public YogaDisplay getDisplay() { public YogaDisplay getDisplay() {
return YogaDisplay.fromInt(jni_YGNodeStyleGetDisplay(mNativePointer)); return YogaDisplay.fromInt(jni_YGNodeStyleGetDisplay(mNativePointer));
} }
private native void jni_YGNodeStyleSetDisplay(long nativePointer, int display); private static native void jni_YGNodeStyleSetDisplay(long nativePointer, int display);
public void setDisplay(YogaDisplay display) { public void setDisplay(YogaDisplay display) {
jni_YGNodeStyleSetDisplay(mNativePointer, display.intValue()); jni_YGNodeStyleSetDisplay(mNativePointer, display.intValue());
} }
private native void jni_YGNodeStyleSetFlex(long nativePointer, float flex); private static native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
public void setFlex(float flex) { public void setFlex(float flex) {
jni_YGNodeStyleSetFlex(mNativePointer, flex); jni_YGNodeStyleSetFlex(mNativePointer, flex);
} }
private native float jni_YGNodeStyleGetFlexGrow(long nativePointer); private static native float jni_YGNodeStyleGetFlexGrow(long nativePointer);
public float getFlexGrow() { public float getFlexGrow() {
return jni_YGNodeStyleGetFlexGrow(mNativePointer); return jni_YGNodeStyleGetFlexGrow(mNativePointer);
} }
private native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow); private static native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
public void setFlexGrow(float flexGrow) { public void setFlexGrow(float flexGrow) {
jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow); jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow);
} }
private native float jni_YGNodeStyleGetFlexShrink(long nativePointer); private static native float jni_YGNodeStyleGetFlexShrink(long nativePointer);
public float getFlexShrink() { public float getFlexShrink() {
return jni_YGNodeStyleGetFlexShrink(mNativePointer); return jni_YGNodeStyleGetFlexShrink(mNativePointer);
} }
private native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink); private static native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
public void setFlexShrink(float flexShrink) { public void setFlexShrink(float flexShrink) {
jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink); jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
} }
private native Object jni_YGNodeStyleGetFlexBasis(long nativePointer); private static native Object jni_YGNodeStyleGetFlexBasis(long nativePointer);
public YogaValue getFlexBasis() { public YogaValue getFlexBasis() {
return (YogaValue) jni_YGNodeStyleGetFlexBasis(mNativePointer); return (YogaValue) jni_YGNodeStyleGetFlexBasis(mNativePointer);
} }
private native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis); private static native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
public void setFlexBasis(float flexBasis) { public void setFlexBasis(float flexBasis) {
jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis); jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
} }
private native void jni_YGNodeStyleSetFlexBasisPercent(long nativePointer, float percent); private static native void jni_YGNodeStyleSetFlexBasisPercent(long nativePointer, float percent);
public void setFlexBasisPercent(float percent) { public void setFlexBasisPercent(float percent) {
jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent); jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent);
} }
private native void jni_YGNodeStyleSetFlexBasisAuto(long nativePointer); private static native void jni_YGNodeStyleSetFlexBasisAuto(long nativePointer);
public void setFlexBasisAuto() { public void setFlexBasisAuto() {
jni_YGNodeStyleSetFlexBasisAuto(mNativePointer); jni_YGNodeStyleSetFlexBasisAuto(mNativePointer);
} }
private native Object jni_YGNodeStyleGetMargin(long nativePointer, int edge); private static native Object jni_YGNodeStyleGetMargin(long nativePointer, int edge);
public YogaValue getMargin(YogaEdge edge) { public YogaValue getMargin(YogaEdge edge) {
if (!((mEdgeSetFlag & MARGIN) == MARGIN)) { if (!((mEdgeSetFlag & MARGIN) == MARGIN)) {
return YogaValue.UNDEFINED; return YogaValue.UNDEFINED;
@ -457,25 +457,25 @@ public class YogaNode implements Cloneable {
return (YogaValue) jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue()); return (YogaValue) jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
} }
private native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin); private static native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
public void setMargin(YogaEdge edge, float margin) { public void setMargin(YogaEdge edge, float margin) {
mEdgeSetFlag |= MARGIN; mEdgeSetFlag |= MARGIN;
jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin); jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
} }
private native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent); private static native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent);
public void setMarginPercent(YogaEdge edge, float percent) { public void setMarginPercent(YogaEdge edge, float percent) {
mEdgeSetFlag |= MARGIN; mEdgeSetFlag |= MARGIN;
jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent); jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent);
} }
private native void jni_YGNodeStyleSetMarginAuto(long nativePointer, int edge); private static native void jni_YGNodeStyleSetMarginAuto(long nativePointer, int edge);
public void setMarginAuto(YogaEdge edge) { public void setMarginAuto(YogaEdge edge) {
mEdgeSetFlag |= MARGIN; mEdgeSetFlag |= MARGIN;
jni_YGNodeStyleSetMarginAuto(mNativePointer, edge.intValue()); jni_YGNodeStyleSetMarginAuto(mNativePointer, edge.intValue());
} }
private native Object jni_YGNodeStyleGetPadding(long nativePointer, int edge); private static native Object jni_YGNodeStyleGetPadding(long nativePointer, int edge);
public YogaValue getPadding(YogaEdge edge) { public YogaValue getPadding(YogaEdge edge) {
if (!((mEdgeSetFlag & PADDING) == PADDING)) { if (!((mEdgeSetFlag & PADDING) == PADDING)) {
return YogaValue.UNDEFINED; return YogaValue.UNDEFINED;
@ -483,19 +483,19 @@ public class YogaNode implements Cloneable {
return (YogaValue) jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue()); return (YogaValue) jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
} }
private native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding); private static native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
public void setPadding(YogaEdge edge, float padding) { public void setPadding(YogaEdge edge, float padding) {
mEdgeSetFlag |= PADDING; mEdgeSetFlag |= PADDING;
jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding); jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
} }
private native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent); private static native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent);
public void setPaddingPercent(YogaEdge edge, float percent) { public void setPaddingPercent(YogaEdge edge, float percent) {
mEdgeSetFlag |= PADDING; mEdgeSetFlag |= PADDING;
jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent); jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent);
} }
private native float jni_YGNodeStyleGetBorder(long nativePointer, int edge); private static native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
public float getBorder(YogaEdge edge) { public float getBorder(YogaEdge edge) {
if (!((mEdgeSetFlag & BORDER) == BORDER)) { if (!((mEdgeSetFlag & BORDER) == BORDER)) {
return YogaConstants.UNDEFINED; return YogaConstants.UNDEFINED;
@ -503,13 +503,13 @@ public class YogaNode implements Cloneable {
return jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue()); return jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
} }
private native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border); private static native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
public void setBorder(YogaEdge edge, float border) { public void setBorder(YogaEdge edge, float border) {
mEdgeSetFlag |= BORDER; mEdgeSetFlag |= BORDER;
jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border); jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
} }
private native Object jni_YGNodeStyleGetPosition(long nativePointer, int edge); private static native Object jni_YGNodeStyleGetPosition(long nativePointer, int edge);
public YogaValue getPosition(YogaEdge edge) { public YogaValue getPosition(YogaEdge edge) {
if (!mHasSetPosition) { if (!mHasSetPosition) {
return YogaValue.UNDEFINED; return YogaValue.UNDEFINED;
@ -517,124 +517,124 @@ public class YogaNode implements Cloneable {
return (YogaValue) jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue()); return (YogaValue) jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue());
} }
private native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position); private static native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
public void setPosition(YogaEdge edge, float position) { public void setPosition(YogaEdge edge, float position) {
mHasSetPosition = true; mHasSetPosition = true;
jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position); jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
} }
private native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent); private static native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent);
public void setPositionPercent(YogaEdge edge, float percent) { public void setPositionPercent(YogaEdge edge, float percent) {
mHasSetPosition = true; mHasSetPosition = true;
jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent); jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent);
} }
private native Object jni_YGNodeStyleGetWidth(long nativePointer); private static native Object jni_YGNodeStyleGetWidth(long nativePointer);
public YogaValue getWidth() { public YogaValue getWidth() {
return (YogaValue) jni_YGNodeStyleGetWidth(mNativePointer); return (YogaValue) jni_YGNodeStyleGetWidth(mNativePointer);
} }
private native void jni_YGNodeStyleSetWidth(long nativePointer, float width); private static native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
public void setWidth(float width) { public void setWidth(float width) {
jni_YGNodeStyleSetWidth(mNativePointer, width); jni_YGNodeStyleSetWidth(mNativePointer, width);
} }
private native void jni_YGNodeStyleSetWidthPercent(long nativePointer, float percent); private static native void jni_YGNodeStyleSetWidthPercent(long nativePointer, float percent);
public void setWidthPercent(float percent) { public void setWidthPercent(float percent) {
jni_YGNodeStyleSetWidthPercent(mNativePointer, percent); jni_YGNodeStyleSetWidthPercent(mNativePointer, percent);
} }
private native void jni_YGNodeStyleSetWidthAuto(long nativePointer); private static native void jni_YGNodeStyleSetWidthAuto(long nativePointer);
public void setWidthAuto() { public void setWidthAuto() {
jni_YGNodeStyleSetWidthAuto(mNativePointer); jni_YGNodeStyleSetWidthAuto(mNativePointer);
} }
private native Object jni_YGNodeStyleGetHeight(long nativePointer); private static native Object jni_YGNodeStyleGetHeight(long nativePointer);
public YogaValue getHeight() { public YogaValue getHeight() {
return (YogaValue) jni_YGNodeStyleGetHeight(mNativePointer); return (YogaValue) jni_YGNodeStyleGetHeight(mNativePointer);
} }
private native void jni_YGNodeStyleSetHeight(long nativePointer, float height); private static native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
public void setHeight(float height) { public void setHeight(float height) {
jni_YGNodeStyleSetHeight(mNativePointer, height); jni_YGNodeStyleSetHeight(mNativePointer, height);
} }
private native void jni_YGNodeStyleSetHeightPercent(long nativePointer, float percent); private static native void jni_YGNodeStyleSetHeightPercent(long nativePointer, float percent);
public void setHeightPercent(float percent) { public void setHeightPercent(float percent) {
jni_YGNodeStyleSetHeightPercent(mNativePointer, percent); jni_YGNodeStyleSetHeightPercent(mNativePointer, percent);
} }
private native void jni_YGNodeStyleSetHeightAuto(long nativePointer); private static native void jni_YGNodeStyleSetHeightAuto(long nativePointer);
public void setHeightAuto() { public void setHeightAuto() {
jni_YGNodeStyleSetHeightAuto(mNativePointer); jni_YGNodeStyleSetHeightAuto(mNativePointer);
} }
private native Object jni_YGNodeStyleGetMinWidth(long nativePointer); private static native Object jni_YGNodeStyleGetMinWidth(long nativePointer);
public YogaValue getMinWidth() { public YogaValue getMinWidth() {
return (YogaValue) jni_YGNodeStyleGetMinWidth(mNativePointer); return (YogaValue) jni_YGNodeStyleGetMinWidth(mNativePointer);
} }
private native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth); private static native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
public void setMinWidth(float minWidth) { public void setMinWidth(float minWidth) {
jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth); jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
} }
private native void jni_YGNodeStyleSetMinWidthPercent(long nativePointer, float percent); private static native void jni_YGNodeStyleSetMinWidthPercent(long nativePointer, float percent);
public void setMinWidthPercent(float percent) { public void setMinWidthPercent(float percent) {
jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent); jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent);
} }
private native Object jni_YGNodeStyleGetMinHeight(long nativePointer); private static native Object jni_YGNodeStyleGetMinHeight(long nativePointer);
public YogaValue getMinHeight() { public YogaValue getMinHeight() {
return (YogaValue) jni_YGNodeStyleGetMinHeight(mNativePointer); return (YogaValue) jni_YGNodeStyleGetMinHeight(mNativePointer);
} }
private native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight); private static native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
public void setMinHeight(float minHeight) { public void setMinHeight(float minHeight) {
jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight); jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
} }
private native void jni_YGNodeStyleSetMinHeightPercent(long nativePointer, float percent); private static native void jni_YGNodeStyleSetMinHeightPercent(long nativePointer, float percent);
public void setMinHeightPercent(float percent) { public void setMinHeightPercent(float percent) {
jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent); jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent);
} }
private native Object jni_YGNodeStyleGetMaxWidth(long nativePointer); private static native Object jni_YGNodeStyleGetMaxWidth(long nativePointer);
public YogaValue getMaxWidth() { public YogaValue getMaxWidth() {
return (YogaValue) jni_YGNodeStyleGetMaxWidth(mNativePointer); return (YogaValue) jni_YGNodeStyleGetMaxWidth(mNativePointer);
} }
private native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth); private static native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
public void setMaxWidth(float maxWidth) { public void setMaxWidth(float maxWidth) {
jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth); jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
} }
private native void jni_YGNodeStyleSetMaxWidthPercent(long nativePointer, float percent); private static native void jni_YGNodeStyleSetMaxWidthPercent(long nativePointer, float percent);
public void setMaxWidthPercent(float percent) { public void setMaxWidthPercent(float percent) {
jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent); jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent);
} }
private native Object jni_YGNodeStyleGetMaxHeight(long nativePointer); private static native Object jni_YGNodeStyleGetMaxHeight(long nativePointer);
public YogaValue getMaxHeight() { public YogaValue getMaxHeight() {
return (YogaValue) jni_YGNodeStyleGetMaxHeight(mNativePointer); return (YogaValue) jni_YGNodeStyleGetMaxHeight(mNativePointer);
} }
private native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight); private static native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
public void setMaxHeight(float maxheight) { public void setMaxHeight(float maxheight) {
jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight); jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
} }
private native void jni_YGNodeStyleSetMaxHeightPercent(long nativePointer, float percent); private static native void jni_YGNodeStyleSetMaxHeightPercent(long nativePointer, float percent);
public void setMaxHeightPercent(float percent) { public void setMaxHeightPercent(float percent) {
jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent); jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent);
} }
private native float jni_YGNodeStyleGetAspectRatio(long nativePointer); private static native float jni_YGNodeStyleGetAspectRatio(long nativePointer);
public float getAspectRatio() { public float getAspectRatio() {
return jni_YGNodeStyleGetAspectRatio(mNativePointer); return jni_YGNodeStyleGetAspectRatio(mNativePointer);
} }
private native void jni_YGNodeStyleSetAspectRatio(long nativePointer, float aspectRatio); private static native void jni_YGNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
public void setAspectRatio(float aspectRatio) { public void setAspectRatio(float aspectRatio) {
jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio); jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
} }
@ -720,7 +720,7 @@ public class YogaNode implements Cloneable {
return YogaDirection.fromInt(mLayoutDirection); return YogaDirection.fromInt(mLayoutDirection);
} }
private native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc); private static native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
public void setMeasureFunction(YogaMeasureFunction measureFunction) { public void setMeasureFunction(YogaMeasureFunction measureFunction) {
mMeasureFunction = measureFunction; mMeasureFunction = measureFunction;
jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null); jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
@ -745,7 +745,7 @@ public class YogaNode implements Cloneable {
YogaMeasureMode.fromInt(heightMode)); YogaMeasureMode.fromInt(heightMode));
} }
private native void jni_YGNodeSetHasBaselineFunc(long nativePointer, boolean hasMeasureFunc); private static native void jni_YGNodeSetHasBaselineFunc(long nativePointer, boolean hasMeasureFunc);
public void setBaselineFunction(YogaBaselineFunction baselineFunction) { public void setBaselineFunction(YogaBaselineFunction baselineFunction) {
mBaselineFunction = baselineFunction; mBaselineFunction = baselineFunction;
jni_YGNodeSetHasBaselineFunc(mNativePointer, baselineFunction != null); jni_YGNodeSetHasBaselineFunc(mNativePointer, baselineFunction != null);
@ -768,7 +768,7 @@ public class YogaNode implements Cloneable {
return mData; return mData;
} }
private native void jni_YGNodePrint(long nativePointer); private static native void jni_YGNodePrint(long nativePointer);
/** /**
* Use the set logger (defaults to adb log) to print out the styles, children, and computed * Use the set logger (defaults to adb log) to print out the styles, children, and computed

View File

@ -144,7 +144,7 @@ inline std::string makeDescriptor(R (C::*)(Args... args)) {
template<typename R, typename ...Args> template<typename R, typename ...Args>
template<R(*func)(Args...)> template<R(*func)(Args...)>
R CriticalMethod<R(*)(Args...)>::call(alias_ref<jclass>, Args... args) { JNI_ENTRY_POINT R CriticalMethod<R(*)(Args...)>::call(alias_ref<jclass>, Args... args) {
static_assert( static_assert(
IsJniPrimitive<R>() || std::is_void<R>(), IsJniPrimitive<R>() || std::is_void<R>(),
"Critical Native Methods may only return primitive JNI types, or void."); "Critical Native Methods may only return primitive JNI types, or void.");

View File

@ -303,10 +303,7 @@ jlong jni_YGNodeNewWithConfig(alias_ref<jobject> thiz, jlong configPointer) {
return reinterpret_cast<jlong>(node); return reinterpret_cast<jlong>(node);
} }
void jni_YGNodeSetOwner( void jni_YGNodeSetOwner(jlong nativePointer, jlong newOwnerNativePointer) {
alias_ref<jobject> thiz,
jlong nativePointer,
jlong newOwnerNativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer); const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
const YGNodeRef newOwnerNode = _jlong2YGNodeRef(newOwnerNativePointer); const YGNodeRef newOwnerNode = _jlong2YGNodeRef(newOwnerNativePointer);
@ -323,7 +320,7 @@ jlong jni_YGNodeClone(
return reinterpret_cast<jlong>(clonedYogaNode); return reinterpret_cast<jlong>(clonedYogaNode);
} }
void jni_YGNodeFree(alias_ref<jclass>, jlong nativePointer) { void jni_YGNodeFree(jlong nativePointer) {
if (nativePointer == 0) { if (nativePointer == 0) {
return; return;
} }
@ -332,12 +329,12 @@ void jni_YGNodeFree(alias_ref<jclass>, jlong nativePointer) {
YGNodeFree(node); YGNodeFree(node);
} }
void jni_YGNodeClearChildren(alias_ref<jobject> thiz, jlong nativePointer) { void jni_YGNodeClearChildren(jlong nativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer); const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
node->clearChildren(); node->clearChildren();
} }
void jni_YGNodeReset(alias_ref<jobject> thiz, jlong nativePointer) { void jni_YGNodeReset(jlong nativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer); const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
void* context = node->getContext(); void* context = node->getContext();
YGNodeReset(node); YGNodeReset(node);
@ -345,7 +342,7 @@ void jni_YGNodeReset(alias_ref<jobject> thiz, jlong nativePointer) {
node->setPrintFunc(YGPrint); node->setPrintFunc(YGPrint);
} }
void jni_YGNodePrint(alias_ref<jobject> thiz, jlong nativePointer) { void jni_YGNodePrint(jlong nativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer); const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
YGNodePrint( YGNodePrint(
node, node,
@ -354,7 +351,6 @@ void jni_YGNodePrint(alias_ref<jobject> thiz, jlong nativePointer) {
} }
void jni_YGNodeInsertChild( void jni_YGNodeInsertChild(
alias_ref<jobject>,
jlong nativePointer, jlong nativePointer,
jlong childPointer, jlong childPointer,
jint index) { jint index) {
@ -363,7 +359,6 @@ void jni_YGNodeInsertChild(
} }
void jni_YGNodeInsertSharedChild( void jni_YGNodeInsertSharedChild(
alias_ref<jobject>,
jlong nativePointer, jlong nativePointer,
jlong childPointer, jlong childPointer,
jint index) { jint index) {
@ -371,16 +366,13 @@ void jni_YGNodeInsertSharedChild(
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index); _jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
} }
void jni_YGNodeRemoveChild( void jni_YGNodeRemoveChild(jlong nativePointer, jlong childPointer) {
alias_ref<jobject>,
jlong nativePointer,
jlong childPointer) {
YGNodeRemoveChild( YGNodeRemoveChild(
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer)); _jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer));
} }
void jni_YGNodeCalculateLayout( void jni_YGNodeCalculateLayout(
alias_ref<jobject>, alias_ref<jclass>,
jlong nativePointer, jlong nativePointer,
jfloat width, jfloat width,
jfloat height) { jfloat height) {
@ -393,40 +385,31 @@ void jni_YGNodeCalculateLayout(
YGTransferLayoutOutputsRecursive(root); YGTransferLayoutOutputsRecursive(root);
} }
void jni_YGNodeMarkDirty(alias_ref<jobject>, jlong nativePointer) { void jni_YGNodeMarkDirty(jlong nativePointer) {
YGNodeMarkDirty(_jlong2YGNodeRef(nativePointer)); YGNodeMarkDirty(_jlong2YGNodeRef(nativePointer));
} }
void jni_YGNodeMarkDirtyAndPropogateToDescendants( void jni_YGNodeMarkDirtyAndPropogateToDescendants(jlong nativePointer) {
alias_ref<jobject>,
jlong nativePointer) {
YGNodeMarkDirtyAndPropogateToDescendants(_jlong2YGNodeRef(nativePointer)); YGNodeMarkDirtyAndPropogateToDescendants(_jlong2YGNodeRef(nativePointer));
} }
jboolean jni_YGNodeIsDirty(alias_ref<jobject>, jlong nativePointer) { jboolean jni_YGNodeIsDirty(jlong nativePointer) {
return (jboolean)_jlong2YGNodeRef(nativePointer)->isDirty(); return (jboolean)_jlong2YGNodeRef(nativePointer)->isDirty();
} }
void jni_YGNodeSetHasMeasureFunc( void jni_YGNodeSetHasMeasureFunc(jlong nativePointer, jboolean hasMeasureFunc) {
alias_ref<jobject>,
jlong nativePointer,
jboolean hasMeasureFunc) {
_jlong2YGNodeRef(nativePointer) _jlong2YGNodeRef(nativePointer)
->setMeasureFunc(hasMeasureFunc ? YGJNIMeasureFunc : nullptr); ->setMeasureFunc(hasMeasureFunc ? YGJNIMeasureFunc : nullptr);
} }
void jni_YGNodeSetHasBaselineFunc( void jni_YGNodeSetHasBaselineFunc(
alias_ref<jobject>,
jlong nativePointer, jlong nativePointer,
jboolean hasBaselineFunc) { jboolean hasBaselineFunc) {
_jlong2YGNodeRef(nativePointer) _jlong2YGNodeRef(nativePointer)
->setBaseLineFunc(hasBaselineFunc ? YGJNIBaselineFunc : nullptr); ->setBaseLineFunc(hasBaselineFunc ? YGJNIBaselineFunc : nullptr);
} }
void jni_YGNodeCopyStyle( void jni_YGNodeCopyStyle(jlong dstNativePointer, jlong srcNativePointer) {
alias_ref<jobject>,
jlong dstNativePointer,
jlong srcNativePointer) {
YGNodeCopyStyle( YGNodeCopyStyle(
_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer)); _jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer));
} }
@ -440,12 +423,11 @@ struct JYogaValue : public JavaClass<JYogaValue> {
}; };
#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \ #define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer) { \ javatype jni_YGNodeStyleGet##name(jlong nativePointer) { \
return (javatype)YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \ return (javatype)YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
} \ } \
\ \
void jni_YGNodeStyleSet##name( \ void jni_YGNodeStyleSet##name(jlong nativePointer, javatype value) { \
alias_ref<jobject>, jlong nativePointer, javatype value) { \
YGNodeStyleSet##name( \ YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \ _jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
} }
@ -457,34 +439,30 @@ struct JYogaValue : public JavaClass<JYogaValue> {
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \ YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
} \ } \
\ \
void jni_YGNodeStyleSet##name( \ void jni_YGNodeStyleSet##name(jlong nativePointer, jfloat value) { \
alias_ref<jobject>, jlong nativePointer, jfloat value) { \
YGNodeStyleSet##name( \ YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \ _jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
} \ } \
\ \
void jni_YGNodeStyleSet##name##Percent( \ void jni_YGNodeStyleSet##name##Percent(jlong nativePointer, jfloat value) { \
alias_ref<jobject>, jlong nativePointer, jfloat value) { \
YGNodeStyleSet##name##Percent( \ YGNodeStyleSet##name##Percent( \
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \ _jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
} }
#define YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(name) \ #define YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(name) \
YG_NODE_JNI_STYLE_UNIT_PROP(name) \ YG_NODE_JNI_STYLE_UNIT_PROP(name) \
void jni_YGNodeStyleSet##name##Auto( \ void jni_YGNodeStyleSet##name##Auto(jlong nativePointer) { \
alias_ref<jobject>, jlong nativePointer) { \
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \ YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
} }
#define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \ #define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name( \ javatype jni_YGNodeStyleGet##name(jlong nativePointer, jint edge) { \
alias_ref<jobject>, jlong nativePointer, jint edge) { \
return (javatype)YGNodeStyleGet##name( \ return (javatype)YGNodeStyleGet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \ _jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \
} \ } \
\ \
void jni_YGNodeStyleSet##name( \ void jni_YGNodeStyleSet##name( \
alias_ref<jobject>, jlong nativePointer, jint edge, javatype value) { \ jlong nativePointer, jint edge, javatype value) { \
YGNodeStyleSet##name( \ YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), \ _jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \ static_cast<YGEdge>(edge), \
@ -499,7 +477,7 @@ struct JYogaValue : public JavaClass<JYogaValue> {
} \ } \
\ \
void jni_YGNodeStyleSet##name( \ void jni_YGNodeStyleSet##name( \
alias_ref<jobject>, jlong nativePointer, jint edge, jfloat value) { \ jlong nativePointer, jint edge, jfloat value) { \
YGNodeStyleSet##name( \ YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), \ _jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \ static_cast<YGEdge>(edge), \
@ -507,7 +485,7 @@ struct JYogaValue : public JavaClass<JYogaValue> {
} \ } \
\ \
void jni_YGNodeStyleSet##name##Percent( \ void jni_YGNodeStyleSet##name##Percent( \
alias_ref<jobject>, jlong nativePointer, jint edge, jfloat value) { \ jlong nativePointer, jint edge, jfloat value) { \
YGNodeStyleSet##name##Percent( \ YGNodeStyleSet##name##Percent( \
_jlong2YGNodeRef(nativePointer), \ _jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \ static_cast<YGEdge>(edge), \
@ -516,8 +494,7 @@ struct JYogaValue : public JavaClass<JYogaValue> {
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(name) \ #define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(name) \
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \ YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
void jni_YGNodeStyleSet##name##Auto( \ void jni_YGNodeStyleSet##name##Auto(jlong nativePointer, jint edge) { \
alias_ref<jobject>, jlong nativePointer, jint edge) { \
YGNodeStyleSet##name##Auto( \ YGNodeStyleSet##name##Auto( \
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \ _jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \
} }
@ -533,10 +510,7 @@ YG_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap);
YG_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow); YG_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow);
YG_NODE_JNI_STYLE_PROP(jint, YGDisplay, Display); YG_NODE_JNI_STYLE_PROP(jint, YGDisplay, Display);
void jni_YGNodeStyleSetFlex( void jni_YGNodeStyleSetFlex(jlong nativePointer, jfloat value) {
alias_ref<jobject>,
jlong nativePointer,
jfloat value) {
YGNodeStyleSetFlex( YGNodeStyleSetFlex(
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); _jlong2YGNodeRef(nativePointer), static_cast<float>(value));
} }
@ -668,113 +642,127 @@ void jni_YGConfigSetLogger(
} }
} }
jint jni_YGNodeGetInstanceCount(alias_ref<jclass> clazz) { jint jni_YGNodeGetInstanceCount() {
return YGNodeGetInstanceCount(); return YGNodeGetInstanceCount();
} }
#define YGMakeNativeMethod(name) makeNativeMethod(#name, name) #define YGMakeNativeMethod(name) makeNativeMethod(#name, name)
#define YGRealMakeCriticalNativeMethod(name) \
makeCriticalNativeMethod(#name, name)
#define YGWrapCriticalNativeMethodForRegularCall(name) \
makeNativeMethod( \
#name, \
::facebook::jni::detail::CriticalMethod<decltype(&name)>::call<&name>)
void jni_bindNativeMethods(alias_ref<jclass>, jboolean) { #define YGRegisterNatives(YGMakeCriticalNativeMethod) \
registerNatives( registerNatives( \
"com/facebook/yoga/YogaNode", "com/facebook/yoga/YogaNode", \
{ { \
YGMakeNativeMethod(jni_YGNodeNew), YGMakeNativeMethod(jni_YGNodeNew), \
YGMakeNativeMethod(jni_YGNodeNewWithConfig), YGMakeNativeMethod(jni_YGNodeNewWithConfig), \
YGMakeNativeMethod(jni_YGNodeFree), YGMakeCriticalNativeMethod(jni_YGNodeFree), \
YGMakeNativeMethod(jni_YGNodeReset), YGMakeCriticalNativeMethod(jni_YGNodeReset), \
YGMakeNativeMethod(jni_YGNodeClearChildren), YGMakeCriticalNativeMethod(jni_YGNodeClearChildren), \
YGMakeNativeMethod(jni_YGNodeInsertChild), YGMakeCriticalNativeMethod(jni_YGNodeInsertChild), \
YGMakeNativeMethod(jni_YGNodeInsertSharedChild), YGMakeCriticalNativeMethod(jni_YGNodeInsertSharedChild), \
YGMakeNativeMethod(jni_YGNodeRemoveChild), YGMakeCriticalNativeMethod(jni_YGNodeRemoveChild), \
YGMakeNativeMethod(jni_YGNodeCalculateLayout), YGMakeNativeMethod(jni_YGNodeCalculateLayout), \
YGMakeNativeMethod(jni_YGNodeMarkDirty), YGMakeCriticalNativeMethod(jni_YGNodeMarkDirty), \
YGMakeNativeMethod(jni_YGNodeMarkDirtyAndPropogateToDescendants), YGMakeCriticalNativeMethod( \
YGMakeNativeMethod(jni_YGNodeIsDirty), jni_YGNodeMarkDirtyAndPropogateToDescendants), \
YGMakeNativeMethod(jni_YGNodeSetHasMeasureFunc), YGMakeCriticalNativeMethod(jni_YGNodeIsDirty), \
YGMakeNativeMethod(jni_YGNodeSetHasBaselineFunc), YGMakeCriticalNativeMethod(jni_YGNodeSetHasMeasureFunc), \
YGMakeNativeMethod(jni_YGNodeCopyStyle), YGMakeCriticalNativeMethod(jni_YGNodeSetHasBaselineFunc), \
YGMakeNativeMethod(jni_YGNodeStyleGetDirection), YGMakeCriticalNativeMethod(jni_YGNodeCopyStyle), \
YGMakeNativeMethod(jni_YGNodeStyleSetDirection), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetDirection), \
YGMakeNativeMethod(jni_YGNodeStyleGetFlexDirection), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetDirection), \
YGMakeNativeMethod(jni_YGNodeStyleSetFlexDirection), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexDirection), \
YGMakeNativeMethod(jni_YGNodeStyleGetJustifyContent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexDirection), \
YGMakeNativeMethod(jni_YGNodeStyleSetJustifyContent), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetJustifyContent), \
YGMakeNativeMethod(jni_YGNodeStyleGetAlignItems), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetJustifyContent), \
YGMakeNativeMethod(jni_YGNodeStyleSetAlignItems), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignItems), \
YGMakeNativeMethod(jni_YGNodeStyleGetAlignSelf), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignItems), \
YGMakeNativeMethod(jni_YGNodeStyleSetAlignSelf), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignSelf), \
YGMakeNativeMethod(jni_YGNodeStyleGetAlignContent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignSelf), \
YGMakeNativeMethod(jni_YGNodeStyleSetAlignContent), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignContent), \
YGMakeNativeMethod(jni_YGNodeStyleGetPositionType), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignContent), \
YGMakeNativeMethod(jni_YGNodeStyleSetPositionType), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPositionType), \
YGMakeNativeMethod(jni_YGNodeStyleSetFlexWrap), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionType), \
YGMakeNativeMethod(jni_YGNodeStyleGetOverflow), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexWrap), \
YGMakeNativeMethod(jni_YGNodeStyleSetOverflow), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetOverflow), \
YGMakeNativeMethod(jni_YGNodeStyleGetDisplay), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetOverflow), \
YGMakeNativeMethod(jni_YGNodeStyleSetDisplay), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetDisplay), \
YGMakeNativeMethod(jni_YGNodeStyleSetFlex), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetDisplay), \
YGMakeNativeMethod(jni_YGNodeStyleGetFlexGrow), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlex), \
YGMakeNativeMethod(jni_YGNodeStyleSetFlexGrow), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexGrow), \
YGMakeNativeMethod(jni_YGNodeStyleGetFlexShrink), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexGrow), \
YGMakeNativeMethod(jni_YGNodeStyleSetFlexShrink), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexShrink), \
YGMakeNativeMethod(jni_YGNodeStyleGetFlexBasis), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexShrink), \
YGMakeNativeMethod(jni_YGNodeStyleSetFlexBasis), YGMakeNativeMethod(jni_YGNodeStyleGetFlexBasis), \
YGMakeNativeMethod(jni_YGNodeStyleSetFlexBasisPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasis), \
YGMakeNativeMethod(jni_YGNodeStyleSetFlexBasisAuto), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisPercent), \
YGMakeNativeMethod(jni_YGNodeStyleGetMargin), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisAuto), \
YGMakeNativeMethod(jni_YGNodeStyleSetMargin), YGMakeNativeMethod(jni_YGNodeStyleGetMargin), \
YGMakeNativeMethod(jni_YGNodeStyleSetMarginPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMargin), \
YGMakeNativeMethod(jni_YGNodeStyleSetMarginAuto), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginPercent), \
YGMakeNativeMethod(jni_YGNodeStyleGetPadding), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginAuto), \
YGMakeNativeMethod(jni_YGNodeStyleSetPadding), YGMakeNativeMethod(jni_YGNodeStyleGetPadding), \
YGMakeNativeMethod(jni_YGNodeStyleSetPaddingPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPadding), \
YGMakeNativeMethod(jni_YGNodeStyleGetBorder), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPaddingPercent), \
YGMakeNativeMethod(jni_YGNodeStyleSetBorder), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetBorder), \
YGMakeNativeMethod(jni_YGNodeStyleGetPosition), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetBorder), \
YGMakeNativeMethod(jni_YGNodeStyleSetPosition), YGMakeNativeMethod(jni_YGNodeStyleGetPosition), \
YGMakeNativeMethod(jni_YGNodeStyleSetPositionPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPosition), \
YGMakeNativeMethod(jni_YGNodeStyleGetWidth), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionPercent), \
YGMakeNativeMethod(jni_YGNodeStyleSetWidth), YGMakeNativeMethod(jni_YGNodeStyleGetWidth), \
YGMakeNativeMethod(jni_YGNodeStyleSetWidthPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidth), \
YGMakeNativeMethod(jni_YGNodeStyleSetWidthAuto), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthPercent), \
YGMakeNativeMethod(jni_YGNodeStyleGetHeight), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthAuto), \
YGMakeNativeMethod(jni_YGNodeStyleSetHeight), YGMakeNativeMethod(jni_YGNodeStyleGetHeight), \
YGMakeNativeMethod(jni_YGNodeStyleSetHeightPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeight), \
YGMakeNativeMethod(jni_YGNodeStyleSetHeightAuto), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightPercent), \
YGMakeNativeMethod(jni_YGNodeStyleGetMinWidth), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightAuto), \
YGMakeNativeMethod(jni_YGNodeStyleSetMinWidth), YGMakeNativeMethod(jni_YGNodeStyleGetMinWidth), \
YGMakeNativeMethod(jni_YGNodeStyleSetMinWidthPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidth), \
YGMakeNativeMethod(jni_YGNodeStyleGetMinHeight), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidthPercent), \
YGMakeNativeMethod(jni_YGNodeStyleSetMinHeight), YGMakeNativeMethod(jni_YGNodeStyleGetMinHeight), \
YGMakeNativeMethod(jni_YGNodeStyleSetMinHeightPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeight), \
YGMakeNativeMethod(jni_YGNodeStyleGetMaxWidth), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeightPercent), \
YGMakeNativeMethod(jni_YGNodeStyleSetMaxWidth), YGMakeNativeMethod(jni_YGNodeStyleGetMaxWidth), \
YGMakeNativeMethod(jni_YGNodeStyleSetMaxWidthPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidth), \
YGMakeNativeMethod(jni_YGNodeStyleGetMaxHeight), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidthPercent), \
YGMakeNativeMethod(jni_YGNodeStyleSetMaxHeight), YGMakeNativeMethod(jni_YGNodeStyleGetMaxHeight), \
YGMakeNativeMethod(jni_YGNodeStyleSetMaxHeightPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeight), \
YGMakeNativeMethod(jni_YGNodeStyleGetAspectRatio), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeightPercent), \
YGMakeNativeMethod(jni_YGNodeStyleSetAspectRatio), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAspectRatio), \
YGMakeNativeMethod(jni_YGNodeGetInstanceCount), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAspectRatio), \
YGMakeNativeMethod(jni_YGNodePrint), YGMakeCriticalNativeMethod(jni_YGNodeGetInstanceCount), \
YGMakeNativeMethod(jni_YGNodeClone), YGMakeCriticalNativeMethod(jni_YGNodePrint), \
YGMakeNativeMethod(jni_YGNodeSetOwner), YGMakeNativeMethod(jni_YGNodeClone), \
}); YGMakeCriticalNativeMethod(jni_YGNodeSetOwner), \
registerNatives( }); \
"com/facebook/yoga/YogaConfig", registerNatives( \
{ "com/facebook/yoga/YogaConfig", \
YGMakeNativeMethod(jni_YGConfigNew), { \
YGMakeNativeMethod(jni_YGConfigFree), YGMakeNativeMethod(jni_YGConfigNew), \
YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled), YGMakeNativeMethod(jni_YGConfigFree), \
YGMakeNativeMethod(jni_YGConfigSetUseWebDefaults), YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled), \
YGMakeNativeMethod(jni_YGConfigSetPrintTreeFlag), YGMakeNativeMethod(jni_YGConfigSetUseWebDefaults), \
YGMakeNativeMethod(jni_YGConfigSetPointScaleFactor), YGMakeNativeMethod(jni_YGConfigSetPrintTreeFlag), \
YGMakeNativeMethod(jni_YGConfigSetUseLegacyStretchBehaviour), YGMakeNativeMethod(jni_YGConfigSetPointScaleFactor), \
YGMakeNativeMethod(jni_YGConfigSetLogger), YGMakeNativeMethod(jni_YGConfigSetUseLegacyStretchBehaviour), \
YGMakeNativeMethod(jni_YGConfigSetHasCloneNodeFunc), YGMakeNativeMethod(jni_YGConfigSetLogger), \
YGMakeNativeMethod( YGMakeNativeMethod(jni_YGConfigSetHasCloneNodeFunc), \
jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour), YGMakeNativeMethod( \
jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour), \
}); });
void jni_bindNativeMethods(alias_ref<jclass>, jboolean useFastCall) {
if (useFastCall) {
YGRegisterNatives(YGRealMakeCriticalNativeMethod);
} else {
YGRegisterNatives(YGWrapCriticalNativeMethodForRegularCall);
}
} }
jint JNI_OnLoad(JavaVM* vm, void*) { jint JNI_OnLoad(JavaVM* vm, void*) {