diff --git a/java/com/facebook/yoga/YogaNode.java b/java/com/facebook/yoga/YogaNode.java index f995d786..3af33cdf 100644 --- a/java/com/facebook/yoga/YogaNode.java +++ b/java/com/facebook/yoga/YogaNode.java @@ -667,4 +667,14 @@ public class YogaNode { public Object getData() { return mData; } + + private native void jni_YGNodePrint(long nativePointer); + + /** + * Use the set logger (defaults to adb log) to print out the styles, children, and computed + * layout of the tree rooted at this node. + */ + public void print() { + jni_YGNodePrint(mNativePointer); + } } diff --git a/java/jni/YGJNI.cpp b/java/jni/YGJNI.cpp index c9366593..fd9e6081 100644 --- a/java/jni/YGJNI.cpp +++ b/java/jni/YGJNI.cpp @@ -223,6 +223,11 @@ void jni_YGNodeReset(alias_ref thiz, jlong nativePointer) { YGNodeSetPrintFunc(node, YGPrint); } +void jni_YGNodePrint(alias_ref thiz, jlong nativePointer) { + const YGNodeRef node = _jlong2YGNodeRef(nativePointer); + YGNodePrint(node, (YGPrintOptions) (YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren)); +} + void jni_YGNodeInsertChild(alias_ref, jlong nativePointer, jlong childPointer, jint index) { YGNodeInsertChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index); } @@ -490,6 +495,7 @@ jint JNI_OnLoad(JavaVM *vm, void *) { YGMakeNativeMethod(jni_YGNodeGetInstanceCount), YGMakeNativeMethod(jni_YGSetLogger), YGMakeNativeMethod(jni_YGLog), + YGMakeNativeMethod(jni_YGNodePrint), }); registerNatives("com/facebook/yoga/YogaConfig", {