Support 64 bit platforms

Summary: Pointers are 64 bit on 64 bit platforms so using an int might truncate the pointer. Using longs supports 32 bit platforms as well.

Reviewed By: davidaurelio

Differential Revision: D3722479

fbshipit-source-id: c132f24c92c8476b328713861ad30670a43040c4
This commit is contained in:
Emil Sjolander
2016-08-16 08:49:54 -07:00
committed by Facebook Github Bot 7
parent 7cd6305371
commit dde2b349f2
2 changed files with 112 additions and 107 deletions

View File

@@ -32,7 +32,7 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
private CSSNodeJNI mParent; private CSSNodeJNI mParent;
private List<CSSNodeJNI> mChildren; private List<CSSNodeJNI> mChildren;
private MeasureFunction mMeasureFunction; private MeasureFunction mMeasureFunction;
private int mNativePointer; private long mNativePointer;
private Object mData; private Object mData;
private void assertNativeInstance() { private void assertNativeInstance() {
@@ -41,7 +41,7 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
} }
} }
private native int jni_CSSNodeNew(); private native long jni_CSSNodeNew();
@Override @Override
public void init() { public void init() {
if (mNativePointer != 0) { if (mNativePointer != 0) {
@@ -52,7 +52,7 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
mChildren = new ArrayList<>(4); mChildren = new ArrayList<>(4);
} }
private native void jni_CSSNodeFree(int nativePointer); private native void jni_CSSNodeFree(long nativePointer);
@Override @Override
public void reset() { public void reset() {
assertNativeInstance(); assertNativeInstance();
@@ -74,7 +74,7 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
return mChildren.get(i); return mChildren.get(i);
} }
private native void jni_CSSNodeInsertChild(int nativePointer, int childPointer, int index); private native void jni_CSSNodeInsertChild(long nativePointer, long childPointer, int index);
@Override @Override
public void addChildAt(CSSNodeJNI child, int i) { public void addChildAt(CSSNodeJNI child, int i) {
assertNativeInstance(); assertNativeInstance();
@@ -84,7 +84,7 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
jni_CSSNodeInsertChild(mNativePointer, child.mNativePointer, i); jni_CSSNodeInsertChild(mNativePointer, child.mNativePointer, i);
} }
private native void jni_CSSNodeRemoveChild(int nativePointer, int childPointer); private native void jni_CSSNodeRemoveChild(long nativePointer, long childPointer);
@Override @Override
public CSSNodeJNI removeChildAt(int i) { public CSSNodeJNI removeChildAt(int i) {
assertNativeInstance(); assertNativeInstance();
@@ -105,195 +105,195 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
return mChildren.indexOf(child); return mChildren.indexOf(child);
} }
private native void jni_CSSNodeSetIsTextNode(int nativePointer, boolean isTextNode); private native void jni_CSSNodeSetIsTextNode(long nativePointer, boolean isTextNode);
@Override @Override
public void setIsTextNode(boolean isTextNode) { public void setIsTextNode(boolean isTextNode) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeSetIsTextNode(mNativePointer, isTextNode); jni_CSSNodeSetIsTextNode(mNativePointer, isTextNode);
} }
private native boolean jni_CSSNodeGetIsTextNode(int nativePointer); private native boolean jni_CSSNodeGetIsTextNode(long nativePointer);
@Override @Override
public boolean isTextNode() { public boolean isTextNode() {
assertNativeInstance(); assertNativeInstance();
return jni_CSSNodeGetIsTextNode(mNativePointer); return jni_CSSNodeGetIsTextNode(mNativePointer);
} }
private native void jni_CSSNodeCalculateLayout(int nativePointer); private native void jni_CSSNodeCalculateLayout(long nativePointer);
@Override @Override
public void calculateLayout(CSSLayoutContext layoutContext) { public void calculateLayout(CSSLayoutContext layoutContext) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeCalculateLayout(mNativePointer); jni_CSSNodeCalculateLayout(mNativePointer);
} }
private native boolean jni_CSSNodeHasNewLayout(int nativePointer); private native boolean jni_CSSNodeHasNewLayout(long nativePointer);
@Override @Override
public boolean hasNewLayout() { public boolean hasNewLayout() {
assertNativeInstance(); assertNativeInstance();
return jni_CSSNodeHasNewLayout(mNativePointer); return jni_CSSNodeHasNewLayout(mNativePointer);
} }
private native void jni_CSSNodeMarkDirty(int nativePointer); private native void jni_CSSNodeMarkDirty(long nativePointer);
@Override @Override
public void dirty() { public void dirty() {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeMarkDirty(mNativePointer); jni_CSSNodeMarkDirty(mNativePointer);
} }
private native boolean jni_CSSNodeIsDirty(int nativePointer); private native boolean jni_CSSNodeIsDirty(long nativePointer);
@Override @Override
public boolean isDirty() { public boolean isDirty() {
return jni_CSSNodeIsDirty(mNativePointer); return jni_CSSNodeIsDirty(mNativePointer);
} }
private native void jni_CSSNodeMarkLayoutSeen(int nativePointer); private native void jni_CSSNodeMarkLayoutSeen(long nativePointer);
@Override @Override
public void markLayoutSeen() { public void markLayoutSeen() {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeMarkLayoutSeen(mNativePointer); jni_CSSNodeMarkLayoutSeen(mNativePointer);
} }
private native int jni_CSSNodeStyleGetDirection(int nativePointer); private native int jni_CSSNodeStyleGetDirection(long nativePointer);
@Override @Override
public CSSDirection getStyleDirection() { public CSSDirection getStyleDirection() {
assertNativeInstance(); assertNativeInstance();
return CSSDirection.values()[jni_CSSNodeStyleGetDirection(mNativePointer)]; return CSSDirection.values()[jni_CSSNodeStyleGetDirection(mNativePointer)];
} }
private native void jni_CSSNodeStyleSetDirection(int nativePointer, int direction); private native void jni_CSSNodeStyleSetDirection(long nativePointer, int direction);
@Override @Override
public void setDirection(CSSDirection direction) { public void setDirection(CSSDirection direction) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetDirection(mNativePointer, direction.ordinal()); jni_CSSNodeStyleSetDirection(mNativePointer, direction.ordinal());
} }
private native int jni_CSSNodeLayoutGetDirection(int nativePointer); private native int jni_CSSNodeLayoutGetDirection(long nativePointer);
@Override @Override
public CSSDirection getLayoutDirection() { public CSSDirection getLayoutDirection() {
assertNativeInstance(); assertNativeInstance();
return CSSDirection.values()[jni_CSSNodeLayoutGetDirection(mNativePointer)]; return CSSDirection.values()[jni_CSSNodeLayoutGetDirection(mNativePointer)];
} }
private native int jni_CSSNodeStyleGetFlexDirection(int nativePointer); private native int jni_CSSNodeStyleGetFlexDirection(long nativePointer);
@Override @Override
public CSSFlexDirection getFlexDirection() { public CSSFlexDirection getFlexDirection() {
assertNativeInstance(); assertNativeInstance();
return CSSFlexDirection.values()[jni_CSSNodeStyleGetFlexDirection(mNativePointer)]; return CSSFlexDirection.values()[jni_CSSNodeStyleGetFlexDirection(mNativePointer)];
} }
private native void jni_CSSNodeStyleSetFlexDirection(int nativePointer, int flexDirection); private native void jni_CSSNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
@Override @Override
public void setFlexDirection(CSSFlexDirection flexDirection) { public void setFlexDirection(CSSFlexDirection flexDirection) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetFlexDirection(mNativePointer, flexDirection.ordinal()); jni_CSSNodeStyleSetFlexDirection(mNativePointer, flexDirection.ordinal());
} }
private native int jni_CSSNodeStyleGetJustifyContent(int nativePointer); private native int jni_CSSNodeStyleGetJustifyContent(long nativePointer);
@Override @Override
public CSSJustify getJustifyContent() { public CSSJustify getJustifyContent() {
assertNativeInstance(); assertNativeInstance();
return CSSJustify.values()[jni_CSSNodeStyleGetJustifyContent(mNativePointer)]; return CSSJustify.values()[jni_CSSNodeStyleGetJustifyContent(mNativePointer)];
} }
private native void jni_CSSNodeStyleSetJustifyContent(int nativePointer, int justifyContent); private native void jni_CSSNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
@Override @Override
public void setJustifyContent(CSSJustify justifyContent) { public void setJustifyContent(CSSJustify justifyContent) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetJustifyContent(mNativePointer, justifyContent.ordinal()); jni_CSSNodeStyleSetJustifyContent(mNativePointer, justifyContent.ordinal());
} }
private native int jni_CSSNodeStyleGetAlignItems(int nativePointer); private native int jni_CSSNodeStyleGetAlignItems(long nativePointer);
@Override @Override
public CSSAlign getAlignItems() { public CSSAlign getAlignItems() {
assertNativeInstance(); assertNativeInstance();
return CSSAlign.values()[jni_CSSNodeStyleGetAlignItems(mNativePointer)]; return CSSAlign.values()[jni_CSSNodeStyleGetAlignItems(mNativePointer)];
} }
private native void jni_CSSNodeStyleSetAlignItems(int nativePointer, int alignItems); private native void jni_CSSNodeStyleSetAlignItems(long nativePointer, int alignItems);
@Override @Override
public void setAlignItems(CSSAlign alignItems) { public void setAlignItems(CSSAlign alignItems) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetAlignItems(mNativePointer, alignItems.ordinal()); jni_CSSNodeStyleSetAlignItems(mNativePointer, alignItems.ordinal());
} }
private native int jni_CSSNodeStyleGetAlignSelf(int nativePointer); private native int jni_CSSNodeStyleGetAlignSelf(long nativePointer);
@Override @Override
public CSSAlign getAlignSelf() { public CSSAlign getAlignSelf() {
assertNativeInstance(); assertNativeInstance();
return CSSAlign.values()[jni_CSSNodeStyleGetAlignSelf(mNativePointer)]; return CSSAlign.values()[jni_CSSNodeStyleGetAlignSelf(mNativePointer)];
} }
private native void jni_CSSNodeStyleSetAlignSelf(int nativePointer, int alignSelf); private native void jni_CSSNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
@Override @Override
public void setAlignSelf(CSSAlign alignSelf) { public void setAlignSelf(CSSAlign alignSelf) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetAlignSelf(mNativePointer, alignSelf.ordinal()); jni_CSSNodeStyleSetAlignSelf(mNativePointer, alignSelf.ordinal());
} }
private native int jni_CSSNodeStyleGetAlignContent(int nativePointer); private native int jni_CSSNodeStyleGetAlignContent(long nativePointer);
@Override @Override
public CSSAlign getAlignContent() { public CSSAlign getAlignContent() {
assertNativeInstance(); assertNativeInstance();
return CSSAlign.values()[jni_CSSNodeStyleGetAlignContent(mNativePointer)]; return CSSAlign.values()[jni_CSSNodeStyleGetAlignContent(mNativePointer)];
} }
private native void jni_CSSNodeStyleSetAlignContent(int nativePointer, int alignContent); private native void jni_CSSNodeStyleSetAlignContent(long nativePointer, int alignContent);
@Override @Override
public void setAlignContent(CSSAlign alignContent) { public void setAlignContent(CSSAlign alignContent) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetAlignContent(mNativePointer, alignContent.ordinal()); jni_CSSNodeStyleSetAlignContent(mNativePointer, alignContent.ordinal());
} }
private native int jni_CSSNodeStyleGetPositionType(int nativePointer); private native int jni_CSSNodeStyleGetPositionType(long nativePointer);
@Override @Override
public CSSPositionType getPositionType() { public CSSPositionType getPositionType() {
assertNativeInstance(); assertNativeInstance();
return CSSPositionType.values()[jni_CSSNodeStyleGetPositionType(mNativePointer)]; return CSSPositionType.values()[jni_CSSNodeStyleGetPositionType(mNativePointer)];
} }
private native void jni_CSSNodeStyleSetPositionType(int nativePointer, int positionType); private native void jni_CSSNodeStyleSetPositionType(long nativePointer, int positionType);
@Override @Override
public void setPositionType(CSSPositionType positionType) { public void setPositionType(CSSPositionType positionType) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetPositionType(mNativePointer, positionType.ordinal()); jni_CSSNodeStyleSetPositionType(mNativePointer, positionType.ordinal());
} }
private native void jni_CSSNodeStyleSetFlexWrap(int nativePointer, int wrapType); private native void jni_CSSNodeStyleSetFlexWrap(long nativePointer, int wrapType);
@Override @Override
public void setWrap(CSSWrap flexWrap) { public void setWrap(CSSWrap flexWrap) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetFlexWrap(mNativePointer, flexWrap.ordinal()); jni_CSSNodeStyleSetFlexWrap(mNativePointer, flexWrap.ordinal());
} }
private native int jni_CSSNodeStyleGetOverflow(int nativePointer); private native int jni_CSSNodeStyleGetOverflow(long nativePointer);
@Override @Override
public CSSOverflow getOverflow() { public CSSOverflow getOverflow() {
assertNativeInstance(); assertNativeInstance();
return CSSOverflow.values()[jni_CSSNodeStyleGetOverflow(mNativePointer)]; return CSSOverflow.values()[jni_CSSNodeStyleGetOverflow(mNativePointer)];
} }
private native void jni_CSSNodeStyleSetOverflow(int nativePointer, int overflow); private native void jni_CSSNodeStyleSetOverflow(long nativePointer, int overflow);
@Override @Override
public void setOverflow(CSSOverflow overflow) { public void setOverflow(CSSOverflow overflow) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetOverflow(mNativePointer, overflow.ordinal()); jni_CSSNodeStyleSetOverflow(mNativePointer, overflow.ordinal());
} }
private native float jni_CSSNodeStyleGetFlex(int nativePointer); private native float jni_CSSNodeStyleGetFlex(long nativePointer);
@Override @Override
public float getFlex() { public float getFlex() {
assertNativeInstance(); assertNativeInstance();
return jni_CSSNodeStyleGetFlex(mNativePointer); return jni_CSSNodeStyleGetFlex(mNativePointer);
} }
private native void jni_CSSNodeStyleSetFlex(int nativePointer, float flex); private native void jni_CSSNodeStyleSetFlex(long nativePointer, float flex);
@Override @Override
public void setFlex(float flex) { public void setFlex(float flex) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetFlex(mNativePointer, flex); jni_CSSNodeStyleSetFlex(mNativePointer, flex);
} }
private native float jni_CSSNodeStyleGetMargin(int nativePointer, int edge); private native float jni_CSSNodeStyleGetMargin(long nativePointer, int edge);
@Override @Override
public Spacing getMargin() { public Spacing getMargin() {
assertNativeInstance(); assertNativeInstance();
@@ -307,14 +307,14 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
return margin; return margin;
} }
private native void jni_CSSNodeStyleSetMargin(int nativePointer, int edge, float margin); private native void jni_CSSNodeStyleSetMargin(long nativePointer, int edge, float margin);
@Override @Override
public void setMargin(int spacingType, float margin) { public void setMargin(int spacingType, float margin) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetMargin(mNativePointer, spacingType, margin); jni_CSSNodeStyleSetMargin(mNativePointer, spacingType, margin);
} }
private native float jni_CSSNodeStyleGetPadding(int nativePointer, int edge); private native float jni_CSSNodeStyleGetPadding(long nativePointer, int edge);
@Override @Override
public Spacing getPadding() { public Spacing getPadding() {
assertNativeInstance(); assertNativeInstance();
@@ -328,7 +328,7 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
return padding; return padding;
} }
private native void jni_CSSNodeStyleSetPadding(int nativePointer, int edge, float padding); private native void jni_CSSNodeStyleSetPadding(long nativePointer, int edge, float padding);
@Override @Override
public void setPadding(int spacingType, float padding) { public void setPadding(int spacingType, float padding) {
assertNativeInstance(); assertNativeInstance();
@@ -340,7 +340,7 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
// TODO // TODO
} }
private native float jni_CSSNodeStyleGetBorder(int nativePointer, int edge); private native float jni_CSSNodeStyleGetBorder(long nativePointer, int edge);
@Override @Override
public Spacing getBorder() { public Spacing getBorder() {
assertNativeInstance(); assertNativeInstance();
@@ -354,14 +354,14 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
return border; return border;
} }
private native void jni_CSSNodeStyleSetBorder(int nativePointer, int edge, float border); private native void jni_CSSNodeStyleSetBorder(long nativePointer, int edge, float border);
@Override @Override
public void setBorder(int spacingType, float border) { public void setBorder(int spacingType, float border) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetBorder(mNativePointer, spacingType, border); jni_CSSNodeStyleSetBorder(mNativePointer, spacingType, border);
} }
private native float jni_CSSNodeStyleGetPosition(int nativePointer, int edge); private native float jni_CSSNodeStyleGetPosition(long nativePointer, int edge);
@Override @Override
public Spacing getPosition() { public Spacing getPosition() {
assertNativeInstance(); assertNativeInstance();
@@ -375,126 +375,126 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
return position; return position;
} }
private native void jni_CSSNodeStyleSetPosition(int nativePointer, int edge, float position); private native void jni_CSSNodeStyleSetPosition(long nativePointer, int edge, float position);
@Override @Override
public void setPosition(int spacingType, float position) { public void setPosition(int spacingType, float position) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetPosition(mNativePointer, spacingType, position); jni_CSSNodeStyleSetPosition(mNativePointer, spacingType, position);
} }
private native float jni_CSSNodeStyleGetWidth(int nativePointer); private native float jni_CSSNodeStyleGetWidth(long nativePointer);
@Override @Override
public float getStyleWidth() { public float getStyleWidth() {
assertNativeInstance(); assertNativeInstance();
return jni_CSSNodeStyleGetWidth(mNativePointer); return jni_CSSNodeStyleGetWidth(mNativePointer);
} }
private native void jni_CSSNodeStyleSetWidth(int nativePointer, float width); private native void jni_CSSNodeStyleSetWidth(long nativePointer, float width);
@Override @Override
public void setStyleWidth(float width) { public void setStyleWidth(float width) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetWidth(mNativePointer, width); jni_CSSNodeStyleSetWidth(mNativePointer, width);
} }
private native float jni_CSSNodeStyleGetHeight(int nativePointer); private native float jni_CSSNodeStyleGetHeight(long nativePointer);
@Override @Override
public float getStyleHeight() { public float getStyleHeight() {
assertNativeInstance(); assertNativeInstance();
return jni_CSSNodeStyleGetHeight(mNativePointer); return jni_CSSNodeStyleGetHeight(mNativePointer);
} }
private native void jni_CSSNodeStyleSetHeight(int nativePointer, float height); private native void jni_CSSNodeStyleSetHeight(long nativePointer, float height);
@Override @Override
public void setStyleHeight(float height) { public void setStyleHeight(float height) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetHeight(mNativePointer, height); jni_CSSNodeStyleSetHeight(mNativePointer, height);
} }
private native float jni_CSSNodeStyleGetMinWidth(int nativePointer); private native float jni_CSSNodeStyleGetMinWidth(long nativePointer);
@Override @Override
public float getStyleMinWidth() { public float getStyleMinWidth() {
assertNativeInstance(); assertNativeInstance();
return jni_CSSNodeStyleGetMinWidth(mNativePointer); return jni_CSSNodeStyleGetMinWidth(mNativePointer);
} }
private native void jni_CSSNodeStyleSetMinWidth(int nativePointer, float minWidth); private native void jni_CSSNodeStyleSetMinWidth(long nativePointer, float minWidth);
@Override @Override
public void setStyleMinWidth(float minWidth) { public void setStyleMinWidth(float minWidth) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetMinWidth(mNativePointer, minWidth); jni_CSSNodeStyleSetMinWidth(mNativePointer, minWidth);
} }
private native float jni_CSSNodeStyleGetMinHeight(int nativePointer); private native float jni_CSSNodeStyleGetMinHeight(long nativePointer);
@Override @Override
public float getStyleMinHeight() { public float getStyleMinHeight() {
assertNativeInstance(); assertNativeInstance();
return jni_CSSNodeStyleGetMinHeight(mNativePointer); return jni_CSSNodeStyleGetMinHeight(mNativePointer);
} }
private native void jni_CSSNodeStyleSetMinHeight(int nativePointer, float minHeight); private native void jni_CSSNodeStyleSetMinHeight(long nativePointer, float minHeight);
@Override @Override
public void setStyleMinHeight(float minHeight) { public void setStyleMinHeight(float minHeight) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetMinHeight(mNativePointer, minHeight); jni_CSSNodeStyleSetMinHeight(mNativePointer, minHeight);
} }
private native float jni_CSSNodeStyleGetMaxWidth(int nativePointer); private native float jni_CSSNodeStyleGetMaxWidth(long nativePointer);
@Override @Override
public float getStyleMaxWidth() { public float getStyleMaxWidth() {
assertNativeInstance(); assertNativeInstance();
return jni_CSSNodeStyleGetMaxWidth(mNativePointer); return jni_CSSNodeStyleGetMaxWidth(mNativePointer);
} }
private native void jni_CSSNodeStyleSetMaxWidth(int nativePointer, float maxWidth); private native void jni_CSSNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
@Override @Override
public void setStyleMaxWidth(float maxWidth) { public void setStyleMaxWidth(float maxWidth) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetMaxWidth(mNativePointer, maxWidth); jni_CSSNodeStyleSetMaxWidth(mNativePointer, maxWidth);
} }
private native float jni_CSSNodeStyleGetMaxHeight(int nativePointer); private native float jni_CSSNodeStyleGetMaxHeight(long nativePointer);
@Override @Override
public float getStyleMaxHeight() { public float getStyleMaxHeight() {
assertNativeInstance(); assertNativeInstance();
return jni_CSSNodeStyleGetMaxHeight(mNativePointer); return jni_CSSNodeStyleGetMaxHeight(mNativePointer);
} }
private native void jni_CSSNodeStyleSetMaxHeight(int nativePointer, float maxheight); private native void jni_CSSNodeStyleSetMaxHeight(long nativePointer, float maxheight);
@Override @Override
public void setStyleMaxHeight(float maxheight) { public void setStyleMaxHeight(float maxheight) {
assertNativeInstance(); assertNativeInstance();
jni_CSSNodeStyleSetMaxHeight(mNativePointer, maxheight); jni_CSSNodeStyleSetMaxHeight(mNativePointer, maxheight);
} }
private native float jni_CSSNodeLayoutGetLeft(int nativePointer); private native float jni_CSSNodeLayoutGetLeft(long nativePointer);
@Override @Override
public float getLayoutX() { public float getLayoutX() {
assertNativeInstance(); assertNativeInstance();
return jni_CSSNodeLayoutGetLeft(mNativePointer); return jni_CSSNodeLayoutGetLeft(mNativePointer);
} }
private native float jni_CSSNodeLayoutGetTop(int nativePointer); private native float jni_CSSNodeLayoutGetTop(long nativePointer);
@Override @Override
public float getLayoutY() { public float getLayoutY() {
assertNativeInstance(); assertNativeInstance();
return jni_CSSNodeLayoutGetTop(mNativePointer); return jni_CSSNodeLayoutGetTop(mNativePointer);
} }
private native float jni_CSSNodeLayoutGetWidth(int nativePointer); private native float jni_CSSNodeLayoutGetWidth(long nativePointer);
@Override @Override
public float getLayoutWidth() { public float getLayoutWidth() {
assertNativeInstance(); assertNativeInstance();
return jni_CSSNodeLayoutGetWidth(mNativePointer); return jni_CSSNodeLayoutGetWidth(mNativePointer);
} }
private native float jni_CSSNodeLayoutGetHeight(int nativePointer); private native float jni_CSSNodeLayoutGetHeight(long nativePointer);
@Override @Override
public float getLayoutHeight() { public float getLayoutHeight() {
assertNativeInstance(); assertNativeInstance();
return jni_CSSNodeLayoutGetHeight(mNativePointer); return jni_CSSNodeLayoutGetHeight(mNativePointer);
} }
private native void jni_CSSNodeSetHasMeasureFunc(int nativePointer, boolean hasMeasureFunc); private native void jni_CSSNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
@Override @Override
public void setMeasureFunction(MeasureFunction measureFunction) { public void setMeasureFunction(MeasureFunction measureFunction) {
assertNativeInstance(); assertNativeInstance();

View File

@@ -15,35 +15,37 @@
#define CSS_NODE_JNI(type, func) \ #define CSS_NODE_JNI(type, func) \
JNIEXPORT type JNICALL Java_com_facebook_csslayout_CSSNodeJNI_jni_1##func JNIEXPORT type JNICALL Java_com_facebook_csslayout_CSSNodeJNI_jni_1##func
#define CSS_NODE_JNI_STYLE_PROP(javatype, type, name) \ #define CSS_NODE_JNI_STYLE_PROP(javatype, type, name) \
CSS_NODE_JNI(javatype, \ CSS_NODE_JNI(javatype, \
CSSNodeStyleGet##name(JNIEnv *env, jobject instance, jint nativePointer) { \ CSSNodeStyleGet##name(JNIEnv *env, jobject instance, jlong nativePointer) { \
return (javatype) CSSNodeStyleGet##name((CSSNodeRef) nativePointer); \ return (javatype) CSSNodeStyleGet##name((CSSNodeRef)(intptr_t) nativePointer); \
}) \ }) \
\ \
CSS_NODE_JNI( \ CSS_NODE_JNI( \
void, \ void, \
CSSNodeStyleSet##name(JNIEnv *env, jobject instance, jint nativePointer, javatype value) { \ CSSNodeStyleSet##name(JNIEnv *env, jobject instance, jlong nativePointer, javatype value) { \
CSSNodeStyleSet##name((CSSNodeRef) nativePointer, (type) value); \ CSSNodeStyleSet##name((CSSNodeRef)(intptr_t) nativePointer, (type) value); \
}) })
#define CSS_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \ #define CSS_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
CSS_NODE_JNI( \ CSS_NODE_JNI( \
javatype, \ javatype, \
CSSNodeStyleGet##name(JNIEnv *env, jobject instance, jint nativePointer, jint edge) { \ CSSNodeStyleGet##name(JNIEnv *env, jobject instance, jlong nativePointer, jint edge) { \
return (javatype) CSSNodeStyleGet##name((CSSNodeRef) nativePointer, (CSSEdge) edge); \ return (javatype) CSSNodeStyleGet##name((CSSNodeRef)(intptr_t) nativePointer, \
(CSSEdge) edge); \
}) \ }) \
\ \
CSS_NODE_JNI(void, \ CSS_NODE_JNI( \
CSSNodeStyleSet##name( \ void, \
JNIEnv *env, jobject instance, jint nativePointer, jint edge, javatype value) { \ CSSNodeStyleSet##name( \
CSSNodeStyleSet##name((CSSNodeRef) nativePointer, (CSSEdge) edge, (type) value); \ JNIEnv *env, jobject instance, jlong nativePointer, jint edge, javatype value) { \
}) CSSNodeStyleSet##name((CSSNodeRef)(intptr_t) nativePointer, (CSSEdge) edge, (type) value); \
})
#define CSS_NODE_JNI_LAYOUT_PROP(javatype, type, name) \ #define CSS_NODE_JNI_LAYOUT_PROP(javatype, type, name) \
CSS_NODE_JNI(javatype, \ CSS_NODE_JNI(javatype, \
CSSNodeLayoutGet##name(JNIEnv *env, jobject instance, jint nativePointer) { \ CSSNodeLayoutGet##name(JNIEnv *env, jobject instance, jlong nativePointer) { \
return (javatype) CSSNodeLayoutGet##name((CSSNodeRef) nativePointer); \ return (javatype) CSSNodeLayoutGet##name((CSSNodeRef)(intptr_t) nativePointer); \
}) })
static JavaVM *jvm = NULL; static JavaVM *jvm = NULL;
@@ -105,72 +107,75 @@ static CSSSize _jniMeasureFunc(void *context,
return size; return size;
} }
CSS_NODE_JNI(jint, CSSNodeNew(JNIEnv *env, jobject thiz) { CSS_NODE_JNI(jlong, CSSNodeNew(JNIEnv *env, jobject thiz) {
CSSNodeRef node = CSSNodeNew(); CSSNodeRef node = CSSNodeNew();
CSSNodeSetContext(node, (*env)->NewGlobalRef(env, thiz)); CSSNodeSetContext(node, (*env)->NewGlobalRef(env, thiz));
CSSNodeSetPrintFunc(node, _jniPrint); CSSNodeSetPrintFunc(node, _jniPrint);
return (jint) node; return (jlong)(intptr_t) node;
}) })
CSS_NODE_JNI(void, CSSNodeFree(JNIEnv *env, jobject thiz, jint nativePointer) { CSS_NODE_JNI(void, CSSNodeFree(JNIEnv *env, jobject thiz, jlong nativePointer) {
(*env)->DeleteGlobalRef(env, (jobject) CSSNodeGetContext((CSSNodeRef) nativePointer)); (*env)->DeleteGlobalRef(env, (jobject) CSSNodeGetContext((CSSNodeRef)(intptr_t) nativePointer));
CSSNodeFree((CSSNodeRef) nativePointer); CSSNodeFree((CSSNodeRef)(intptr_t) nativePointer);
}) })
CSS_NODE_JNI(void, CSS_NODE_JNI(void,
CSSNodeInsertChild(JNIEnv *env, CSSNodeInsertChild(JNIEnv *env,
jobject thiz, jobject thiz,
jint nativePointer, jlong nativePointer,
jint childPointer, jlong childPointer,
jint index) { jint index) {
CSSNodeInsertChild((CSSNodeRef) nativePointer, (CSSNodeRef) childPointer, index); CSSNodeInsertChild((CSSNodeRef)(intptr_t) nativePointer,
(CSSNodeRef)(intptr_t) childPointer,
index);
}) })
CSS_NODE_JNI(void, CSS_NODE_JNI(
CSSNodeRemoveChild(JNIEnv *env, jobject thiz, jint nativePointer, jint childPointer) { void,
CSSNodeRemoveChild((CSSNodeRef) nativePointer, (CSSNodeRef) childPointer); CSSNodeRemoveChild(JNIEnv *env, jobject thiz, jlong nativePointer, jlong childPointer) {
}) CSSNodeRemoveChild((CSSNodeRef)(intptr_t) nativePointer, (CSSNodeRef)(intptr_t) childPointer);
})
CSS_NODE_JNI(void, CSSNodeCalculateLayout(JNIEnv *env, jobject thiz, jint nativePointer) { CSS_NODE_JNI(void, CSSNodeCalculateLayout(JNIEnv *env, jobject thiz, jlong nativePointer) {
CSSNodeCalculateLayout((CSSNodeRef) nativePointer, CSSNodeCalculateLayout((CSSNodeRef)(intptr_t) nativePointer,
NAN, NAN,
NAN, NAN,
CSSNodeStyleGetDirection(((CSSNodeRef) nativePointer))); CSSNodeStyleGetDirection(((CSSNodeRef)(intptr_t) nativePointer)));
}) })
CSS_NODE_JNI(void, CSSNodeMarkDirty(JNIEnv *env, jobject thiz, jint nativePointer) { CSS_NODE_JNI(void, CSSNodeMarkDirty(JNIEnv *env, jobject thiz, jlong nativePointer) {
CSSNodeMarkDirty((CSSNodeRef) nativePointer); CSSNodeMarkDirty((CSSNodeRef)(intptr_t) nativePointer);
}) })
CSS_NODE_JNI(jboolean, CSSNodeIsDirty(JNIEnv *env, jobject instance, jint nativePointer) { CSS_NODE_JNI(jboolean, CSSNodeIsDirty(JNIEnv *env, jobject instance, jlong nativePointer) {
return (jboolean) CSSNodeIsDirty((CSSNodeRef) nativePointer); return (jboolean) CSSNodeIsDirty((CSSNodeRef)(intptr_t) nativePointer);
}) })
CSS_NODE_JNI(void, CSS_NODE_JNI(void,
CSSNodeSetHasMeasureFunc(JNIEnv *env, CSSNodeSetHasMeasureFunc(JNIEnv *env,
jobject thiz, jobject thiz,
jint nativePointer, jlong nativePointer,
jboolean hasMeasureFunc) { jboolean hasMeasureFunc) {
CSSNodeSetMeasureFunc((CSSNodeRef) nativePointer, CSSNodeSetMeasureFunc((CSSNodeRef)(intptr_t) nativePointer,
hasMeasureFunc ? _jniMeasureFunc : NULL); hasMeasureFunc ? _jniMeasureFunc : NULL);
}) })
CSS_NODE_JNI( CSS_NODE_JNI(
void, void,
CSSNodeSetIsTextNode(JNIEnv *env, jobject instance, jint nativePointer, jboolean isTextNode) { CSSNodeSetIsTextNode(JNIEnv *env, jobject instance, jlong nativePointer, jboolean isTextNode) {
CSSNodeSetIsTextnode((CSSNodeRef) nativePointer, isTextNode); CSSNodeSetIsTextnode((CSSNodeRef)(intptr_t) nativePointer, isTextNode);
}) })
CSS_NODE_JNI(jboolean, CSSNodeGetIsTextNode(JNIEnv *env, jobject instance, jint nativePointer) { CSS_NODE_JNI(jboolean, CSSNodeGetIsTextNode(JNIEnv *env, jobject instance, jlong nativePointer) {
return (jboolean) CSSNodeGetIsTextnode((CSSNodeRef) nativePointer); return (jboolean) CSSNodeGetIsTextnode((CSSNodeRef)(intptr_t) nativePointer);
}) })
CSS_NODE_JNI(jboolean, CSSNodeHasNewLayout(JNIEnv *env, jobject instance, jint nativePointer) { CSS_NODE_JNI(jboolean, CSSNodeHasNewLayout(JNIEnv *env, jobject instance, jlong nativePointer) {
return (jboolean) CSSNodeGetHasNewLayout((CSSNodeRef) nativePointer); return (jboolean) CSSNodeGetHasNewLayout((CSSNodeRef)(intptr_t) nativePointer);
}) })
CSS_NODE_JNI(void, CSSNodeMarkLayoutSeen(JNIEnv *env, jobject instance, jint nativePointer) { CSS_NODE_JNI(void, CSSNodeMarkLayoutSeen(JNIEnv *env, jobject instance, jlong nativePointer) {
CSSNodeSetHasNewLayout((CSSNodeRef) nativePointer, false); CSSNodeSetHasNewLayout((CSSNodeRef)(intptr_t) nativePointer, false);
}) })
CSS_NODE_JNI_STYLE_PROP(jint, CSSDirection, Direction); CSS_NODE_JNI_STYLE_PROP(jint, CSSDirection, Direction);