Make native method binding configurable
Summary: Moves binding of native methods into a separate native method that can be parameterized. This will be used to experiment with JNI-related technology. Reviewed By: priteshrnandgaonkar Differential Revision: D9943870 fbshipit-source-id: 661f15537d5bbf7a3eef7717e3d99fed2de23904
This commit is contained in:
committed by
Facebook Github Bot
parent
328ec7dc4d
commit
554d8cdf76
@@ -16,7 +16,7 @@ public class YogaConfig {
|
|||||||
public static int SPACING_TYPE = 1;
|
public static int SPACING_TYPE = 1;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SoLoader.loadLibrary("yoga");
|
YogaJNI.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
long mNativePointer;
|
long mNativePointer;
|
||||||
|
26
java/com/facebook/yoga/YogaJNI.java
Normal file
26
java/com/facebook/yoga/YogaJNI.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.facebook.yoga;
|
||||||
|
|
||||||
|
import com.facebook.soloader.SoLoader;
|
||||||
|
|
||||||
|
public class YogaJNI {
|
||||||
|
// set before loading any other Yoga code
|
||||||
|
public static boolean useFastCall = false;
|
||||||
|
|
||||||
|
private static native void jni_bindNativeMethods(boolean useFastCall);
|
||||||
|
|
||||||
|
static boolean init() {
|
||||||
|
if (SoLoader.loadLibrary("yoga")) {
|
||||||
|
jni_bindNativeMethods(useFastCall);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@@ -18,7 +18,7 @@ import javax.annotation.Nullable;
|
|||||||
public class YogaNode implements Cloneable {
|
public class YogaNode implements Cloneable {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SoLoader.loadLibrary("yoga");
|
YogaJNI.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
* file in the root directory of this source tree.
|
* file in the root directory of this source tree.
|
||||||
@@ -674,8 +674,7 @@ jint jni_YGNodeGetInstanceCount(alias_ref<jclass> clazz) {
|
|||||||
|
|
||||||
#define YGMakeNativeMethod(name) makeNativeMethod(#name, name)
|
#define YGMakeNativeMethod(name) makeNativeMethod(#name, name)
|
||||||
|
|
||||||
jint JNI_OnLoad(JavaVM* vm, void*) {
|
void jni_bindNativeMethods(alias_ref<jclass>, jboolean) {
|
||||||
return initialize(vm, [] {
|
|
||||||
registerNatives(
|
registerNatives(
|
||||||
"com/facebook/yoga/YogaNode",
|
"com/facebook/yoga/YogaNode",
|
||||||
{
|
{
|
||||||
@@ -776,5 +775,14 @@ jint JNI_OnLoad(JavaVM* vm, void*) {
|
|||||||
YGMakeNativeMethod(
|
YGMakeNativeMethod(
|
||||||
jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour),
|
jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
jint JNI_OnLoad(JavaVM* vm, void*) {
|
||||||
|
return initialize(vm, [] {
|
||||||
|
registerNatives(
|
||||||
|
"com/facebook/yoga/YogaJNI",
|
||||||
|
{
|
||||||
|
YGMakeNativeMethod(jni_bindNativeMethods),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user