7
7
8
8
#include " jni.h"
9
9
#include " YGJNIVanilla.h"
10
- #include < yoga/YGNode.h>
11
10
#include < cstring>
12
11
#include " YGJNI.h"
13
12
#include " common.h"
14
13
#include " YGJTypesVanilla.h"
15
- #include < yoga/log.h>
16
14
#include < iostream>
17
15
#include < memory>
18
16
#include " YogaJniException.h"
19
17
18
+ // TODO: Reconcile missing layoutContext functionality from callbacks in the C
19
+ // API and use that
20
+ #include < yoga/YGNode.h>
21
+
20
22
using namespace facebook ::yoga::vanillajni;
21
- using facebook::yoga::detail::Log;
22
23
23
24
static inline ScopedLocalRef<jobject> YGNodeJobject (
24
25
YGNodeRef node,
@@ -84,18 +85,6 @@ static void jni_YGConfigSetPointScaleFactorJNI(
84
85
YGConfigSetPointScaleFactor (config, pixelsInPoint);
85
86
}
86
87
87
- static void YGPrint (YGNodeRef node, void * layoutContext) {
88
- if (auto obj = YGNodeJobject (node, layoutContext)) {
89
- // TODO cout << obj.get()->toString() << endl;
90
- } else {
91
- Log::log (
92
- node,
93
- YGLogLevelError,
94
- nullptr ,
95
- " Java YGNode was GCed during layout calculation\n " );
96
- }
97
- }
98
-
99
88
static void jni_YGConfigSetUseLegacyStretchBehaviourJNI (
100
89
JNIEnv* env,
101
90
jobject obj,
@@ -127,8 +116,7 @@ static jint jni_YGConfigGetErrataJNI(
127
116
128
117
static jlong jni_YGNodeNewJNI (JNIEnv* env, jobject obj) {
129
118
const YGNodeRef node = YGNodeNew ();
130
- node->setContext (YGNodeContext{}.asVoidPtr );
131
- node->setPrintFunc (YGPrint);
119
+ YGNodeSetContext (node, YGNodeContext{}.asVoidPtr );
132
120
return reinterpret_cast <jlong>(node);
133
121
}
134
122
@@ -137,7 +125,7 @@ static jlong jni_YGNodeNewWithConfigJNI(
137
125
jobject obj,
138
126
jlong configPointer) {
139
127
const YGNodeRef node = YGNodeNewWithConfig (_jlong2YGConfigRef (configPointer));
140
- node-> setContext ( YGNodeContext{}.asVoidPtr );
128
+ YGNodeSetContext (node, YGNodeContext{}.asVoidPtr );
141
129
return reinterpret_cast <jlong>(node);
142
130
}
143
131
@@ -221,9 +209,9 @@ static void jni_YGNodeFreeJNI(JNIEnv* env, jobject obj, jlong nativePointer) {
221
209
222
210
static void jni_YGNodeResetJNI (JNIEnv* env, jobject obj, jlong nativePointer) {
223
211
const YGNodeRef node = _jlong2YGNodeRef (nativePointer);
224
- void * context = node-> getContext ( );
212
+ void * context = YGNodeGetContext (node );
225
213
YGNodeReset (node);
226
- node-> setContext ( context);
214
+ YGNodeSetContext (node, context);
227
215
}
228
216
229
217
static void jni_YGNodeInsertChildJNI (
@@ -262,12 +250,12 @@ static jboolean jni_YGNodeIsReferenceBaselineJNI(
262
250
return YGNodeIsReferenceBaseline (_jlong2YGNodeRef (nativePointer));
263
251
}
264
252
265
- static void jni_YGNodeClearChildrenJNI (
253
+ static void jni_YGNodeRemoveAllChildrenJNI (
266
254
JNIEnv* env,
267
255
jobject obj,
268
256
jlong nativePointer) {
269
257
const YGNodeRef node = _jlong2YGNodeRef (nativePointer);
270
- node-> clearChildren ( );
258
+ YGNodeRemoveAllChildren (node );
271
259
}
272
260
273
261
static void jni_YGNodeRemoveChildJNI (
@@ -284,16 +272,11 @@ static void YGTransferLayoutOutputsRecursive(
284
272
jobject thiz,
285
273
YGNodeRef root,
286
274
void * layoutContext) {
287
- if (!root-> getHasNewLayout ( )) {
275
+ if (!YGNodeGetHasNewLayout (root )) {
288
276
return ;
289
277
}
290
278
auto obj = YGNodeJobject (root, layoutContext);
291
279
if (!obj) {
292
- Log::log (
293
- root,
294
- YGLogLevelError,
295
- nullptr ,
296
- " Java YGNode was GCed during layout calculation\n " );
297
280
return ;
298
281
}
299
282
@@ -354,7 +337,7 @@ static void YGTransferLayoutOutputsRecursive(
354
337
env->SetFloatArrayRegion (arrFinal.get (), 0 , arrSize, arr);
355
338
env->SetObjectField (obj.get (), arrField, arrFinal.get ());
356
339
357
- root-> setHasNewLayout ( false );
340
+ YGNodeSetHasNewLayout (root, false );
358
341
359
342
for (uint32_t i = 0 ; i < YGNodeGetChildCount (root); i++) {
360
343
YGTransferLayoutOutputsRecursive (
@@ -420,7 +403,7 @@ static jboolean jni_YGNodeIsDirtyJNI(
420
403
JNIEnv* env,
421
404
jobject obj,
422
405
jlong nativePointer) {
423
- return (jboolean) _jlong2YGNodeRef (nativePointer)-> isDirty ( );
406
+ return (jboolean) YGNodeIsDirty ( _jlong2YGNodeRef (nativePointer));
424
407
}
425
408
426
409
static void jni_YGNodeCopyStyleJNI (
@@ -677,11 +660,6 @@ static YGSize YGJNIMeasureFunc(
677
660
678
661
return YGSize{*measuredWidth, *measuredHeight};
679
662
} else {
680
- Log::log (
681
- node,
682
- YGLogLevelError,
683
- nullptr ,
684
- " Java YGNode was GCed during layout calculation\n " );
685
663
return YGSize{
686
664
widthMode == YGMeasureModeUndefined ? 0 : width,
687
665
heightMode == YGMeasureModeUndefined ? 0 : height,
@@ -737,7 +715,7 @@ static void jni_YGNodePrintJNI(JNIEnv* env, jobject obj, jlong nativePointer) {
737
715
static jlong jni_YGNodeCloneJNI (JNIEnv* env, jobject obj, jlong nativePointer) {
738
716
auto node = _jlong2YGNodeRef (nativePointer);
739
717
const YGNodeRef clonedYogaNode = YGNodeClone (node);
740
- clonedYogaNode-> setContext (node-> getContext ( ));
718
+ YGNodeSetContext ( clonedYogaNode, YGNodeGetContext (node));
741
719
742
720
return reinterpret_cast <jlong>(clonedYogaNode);
743
721
}
@@ -801,7 +779,9 @@ static JNINativeMethod methods[] = {
801
779
{" jni_YGNodeIsReferenceBaselineJNI" ,
802
780
" (J)Z" ,
803
781
(void *) jni_YGNodeIsReferenceBaselineJNI},
804
- {" jni_YGNodeClearChildrenJNI" , " (J)V" , (void *) jni_YGNodeClearChildrenJNI},
782
+ {" jni_YGNodeRemoveAllChildrenJNI" ,
783
+ " (J)V" ,
784
+ (void *) jni_YGNodeRemoveAllChildrenJNI},
805
785
{" jni_YGNodeRemoveChildJNI" , " (JJ)V" , (void *) jni_YGNodeRemoveChildJNI},
806
786
{" jni_YGNodeCalculateLayoutJNI" ,
807
787
" (JFF[J[Lcom/facebook/yoga/YogaNodeJNIBase;)V" ,
0 commit comments