Add Java bindings for Errata API (#37096)
Summary: X-link: https://github.com/facebook/react-native/pull/37096 Pull Request resolved: https://github.com/facebook/yoga/pull/1263 JNI glue to expose `YogaConfig.setErrata()` and `YogaConfig.getErrata()`. Reviewed By: yungsters Differential Revision: D45296538 fbshipit-source-id: 8d743d278b7df43f7843a79d8f4542bfb03fc08d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fc6485b8cd
commit
4692e97ba0
@@ -25,6 +25,10 @@ public abstract class YogaConfig {
|
|||||||
*/
|
*/
|
||||||
public abstract void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour);
|
public abstract void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour);
|
||||||
|
|
||||||
|
public abstract void setErrata(YogaErrata errata);
|
||||||
|
|
||||||
|
public abstract YogaErrata getErrata();
|
||||||
|
|
||||||
public abstract void setLogger(YogaLogger logger);
|
public abstract void setLogger(YogaLogger logger);
|
||||||
|
|
||||||
public abstract YogaLogger getLogger();
|
public abstract YogaLogger getLogger();
|
||||||
|
@@ -52,6 +52,14 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
|
|||||||
YogaNative.jni_YGConfigSetUseLegacyStretchBehaviourJNI(mNativePointer, useLegacyStretchBehaviour);
|
YogaNative.jni_YGConfigSetUseLegacyStretchBehaviourJNI(mNativePointer, useLegacyStretchBehaviour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setErrata(YogaErrata errata) {
|
||||||
|
YogaNative.jni_YGConfigSetErrataJNI(mNativePointer, errata.intValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
public YogaErrata getErrata() {
|
||||||
|
return YogaErrata.fromInt(YogaNative.jni_YGConfigGetErrataJNI(mNativePointer));
|
||||||
|
}
|
||||||
|
|
||||||
public void setLogger(YogaLogger logger) {
|
public void setLogger(YogaLogger logger) {
|
||||||
mLogger = logger;
|
mLogger = logger;
|
||||||
YogaNative.jni_YGConfigSetLoggerJNI(mNativePointer, logger);
|
YogaNative.jni_YGConfigSetLoggerJNI(mNativePointer, logger);
|
||||||
|
@@ -25,6 +25,8 @@ public class YogaNative {
|
|||||||
static native void jni_YGConfigSetPrintTreeFlagJNI(long nativePointer, boolean enable);
|
static native void jni_YGConfigSetPrintTreeFlagJNI(long nativePointer, boolean enable);
|
||||||
static native void jni_YGConfigSetPointScaleFactorJNI(long nativePointer, float pixelsInPoint);
|
static native void jni_YGConfigSetPointScaleFactorJNI(long nativePointer, float pixelsInPoint);
|
||||||
static native void jni_YGConfigSetUseLegacyStretchBehaviourJNI(long nativePointer, boolean useLegacyStretchBehaviour);
|
static native void jni_YGConfigSetUseLegacyStretchBehaviourJNI(long nativePointer, boolean useLegacyStretchBehaviour);
|
||||||
|
static native void jni_YGConfigSetErrataJNI(long nativePointer, int errata);
|
||||||
|
static native int jni_YGConfigGetErrataJNI(long nativePointer);
|
||||||
static native void jni_YGConfigSetLoggerJNI(long nativePointer, YogaLogger logger);
|
static native void jni_YGConfigSetLoggerJNI(long nativePointer, YogaLogger logger);
|
||||||
|
|
||||||
// YGNode related
|
// YGNode related
|
||||||
|
@@ -105,6 +105,23 @@ static void jni_YGConfigSetUseLegacyStretchBehaviourJNI(
|
|||||||
YGConfigSetUseLegacyStretchBehaviour(config, useLegacyStretchBehaviour);
|
YGConfigSetUseLegacyStretchBehaviour(config, useLegacyStretchBehaviour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void jni_YGConfigSetErrataJNI(
|
||||||
|
JNIEnv* env,
|
||||||
|
jobject obj,
|
||||||
|
jlong nativePointer,
|
||||||
|
jint errata) {
|
||||||
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||||
|
YGConfigSetErrata(config, static_cast<YGErrata>(errata));
|
||||||
|
}
|
||||||
|
|
||||||
|
static jint jni_YGConfigGetErrataJNI(
|
||||||
|
JNIEnv* env,
|
||||||
|
jobject obj,
|
||||||
|
jlong nativePointer) {
|
||||||
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||||
|
return static_cast<jint>(YGConfigGetErrata(config));
|
||||||
|
}
|
||||||
|
|
||||||
static jlong jni_YGNodeNewJNI(JNIEnv* env, jobject obj) {
|
static jlong jni_YGNodeNewJNI(JNIEnv* env, jobject obj) {
|
||||||
const YGNodeRef node = YGNodeNew();
|
const YGNodeRef node = YGNodeNew();
|
||||||
node->setContext(YGNodeContext{}.asVoidPtr);
|
node->setContext(YGNodeContext{}.asVoidPtr);
|
||||||
@@ -764,6 +781,8 @@ static JNINativeMethod methods[] = {
|
|||||||
{"jni_YGConfigSetUseLegacyStretchBehaviourJNI",
|
{"jni_YGConfigSetUseLegacyStretchBehaviourJNI",
|
||||||
"(JZ)V",
|
"(JZ)V",
|
||||||
(void*) jni_YGConfigSetUseLegacyStretchBehaviourJNI},
|
(void*) jni_YGConfigSetUseLegacyStretchBehaviourJNI},
|
||||||
|
{"jni_YGConfigSetErrataJNI", "(JI)V", (void*) jni_YGConfigSetErrataJNI},
|
||||||
|
{"jni_YGConfigGetErrataJNI", "(J)I", (void*) jni_YGConfigGetErrataJNI},
|
||||||
{"jni_YGConfigSetLoggerJNI",
|
{"jni_YGConfigSetLoggerJNI",
|
||||||
"(JLcom/facebook/yoga/YogaLogger;)V",
|
"(JLcom/facebook/yoga/YogaLogger;)V",
|
||||||
(void*) jni_YGConfigSetLoggerJNI},
|
(void*) jni_YGConfigSetLoggerJNI},
|
||||||
|
Reference in New Issue
Block a user