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,
@@ -124,8 +113,7 @@ static jint jni_YGConfigGetErrataJNI(
124
113
125
114
static jlong jni_YGNodeNewJNI (JNIEnv* env, jobject obj) {
126
115
const YGNodeRef node = YGNodeNew ();
127
- node->setContext (YGNodeContext{}.asVoidPtr );
128
- node->setPrintFunc (YGPrint);
116
+ YGNodeSetContext (node, YGNodeContext{}.asVoidPtr );
129
117
return reinterpret_cast <jlong>(node);
130
118
}
131
119
@@ -134,7 +122,7 @@ static jlong jni_YGNodeNewWithConfigJNI(
134
122
jobject obj,
135
123
jlong configPointer) {
136
124
const YGNodeRef node = YGNodeNewWithConfig (_jlong2YGConfigRef (configPointer));
137
- node-> setContext ( YGNodeContext{}.asVoidPtr );
125
+ YGNodeSetContext (node, YGNodeContext{}.asVoidPtr );
138
126
return reinterpret_cast <jlong>(node);
139
127
}
140
128
@@ -218,9 +206,9 @@ static void jni_YGNodeFreeJNI(JNIEnv* env, jobject obj, jlong nativePointer) {
218
206
219
207
static void jni_YGNodeResetJNI (JNIEnv* env, jobject obj, jlong nativePointer) {
220
208
const YGNodeRef node = _jlong2YGNodeRef (nativePointer);
221
- void * context = node-> getContext ( );
209
+ void * context = YGNodeGetContext (node );
222
210
YGNodeReset (node);
223
- node-> setContext ( context);
211
+ YGNodeSetContext (node, context);
224
212
}
225
213
226
214
static void jni_YGNodeInsertChildJNI (
@@ -259,12 +247,12 @@ static jboolean jni_YGNodeIsReferenceBaselineJNI(
259
247
return YGNodeIsReferenceBaseline (_jlong2YGNodeRef (nativePointer));
260
248
}
261
249
262
- static void jni_YGNodeClearChildrenJNI (
250
+ static void jni_YGNodeRemoveAllChildrenJNI (
263
251
JNIEnv* env,
264
252
jobject obj,
265
253
jlong nativePointer) {
266
254
const YGNodeRef node = _jlong2YGNodeRef (nativePointer);
267
- node-> clearChildren ( );
255
+ YGNodeRemoveAllChildren (node );
268
256
}
269
257
270
258
static void jni_YGNodeRemoveChildJNI (
@@ -281,16 +269,11 @@ static void YGTransferLayoutOutputsRecursive(
281
269
jobject thiz,
282
270
YGNodeRef root,
283
271
void * layoutContext) {
284
- if (!root-> getHasNewLayout ( )) {
272
+ if (!YGNodeGetHasNewLayout (root )) {
285
273
return ;
286
274
}
287
275
auto obj = YGNodeJobject (root, layoutContext);
288
276
if (!obj) {
289
- Log::log (
290
- root,
291
- YGLogLevelError,
292
- nullptr ,
293
- " Java YGNode was GCed during layout calculation\n " );
294
277
return ;
295
278
}
296
279
@@ -351,7 +334,7 @@ static void YGTransferLayoutOutputsRecursive(
351
334
env->SetFloatArrayRegion (arrFinal.get (), 0 , arrSize, arr);
352
335
env->SetObjectField (obj.get (), arrField, arrFinal.get ());
353
336
354
- root-> setHasNewLayout ( false );
337
+ YGNodeSetHasNewLayout (root, false );
355
338
356
339
for (uint32_t i = 0 ; i < YGNodeGetChildCount (root); i++) {
357
340
YGTransferLayoutOutputsRecursive (
@@ -417,7 +400,7 @@ static jboolean jni_YGNodeIsDirtyJNI(
417
400
JNIEnv* env,
418
401
jobject obj,
419
402
jlong nativePointer) {
420
- return (jboolean) _jlong2YGNodeRef (nativePointer)-> isDirty ( );
403
+ return (jboolean) YGNodeIsDirty ( _jlong2YGNodeRef (nativePointer));
421
404
}
422
405
423
406
static void jni_YGNodeCopyStyleJNI (
@@ -674,11 +657,6 @@ static YGSize YGJNIMeasureFunc(
674
657
675
658
return YGSize{*measuredWidth, *measuredHeight};
676
659
} else {
677
- Log::log (
678
- node,
679
- YGLogLevelError,
680
- nullptr ,
681
- " Java YGNode was GCed during layout calculation\n " );
682
660
return YGSize{
683
661
widthMode == YGMeasureModeUndefined ? 0 : width,
684
662
heightMode == YGMeasureModeUndefined ? 0 : height,
@@ -734,7 +712,7 @@ static void jni_YGNodePrintJNI(JNIEnv* env, jobject obj, jlong nativePointer) {
734
712
static jlong jni_YGNodeCloneJNI (JNIEnv* env, jobject obj, jlong nativePointer) {
735
713
auto node = _jlong2YGNodeRef (nativePointer);
736
714
const YGNodeRef clonedYogaNode = YGNodeClone (node);
737
- clonedYogaNode-> setContext (node-> getContext ( ));
715
+ YGNodeSetContext ( clonedYogaNode, YGNodeGetContext (node));
738
716
739
717
return reinterpret_cast <jlong>(clonedYogaNode);
740
718
}
@@ -798,7 +776,9 @@ static JNINativeMethod methods[] = {
798
776
{" jni_YGNodeIsReferenceBaselineJNI" ,
799
777
" (J)Z" ,
800
778
(void *) jni_YGNodeIsReferenceBaselineJNI},
801
- {" jni_YGNodeClearChildrenJNI" , " (J)V" , (void *) jni_YGNodeClearChildrenJNI},
779
+ {" jni_YGNodeRemoveAllChildrenJNI" ,
780
+ " (J)V" ,
781
+ (void *) jni_YGNodeRemoveAllChildrenJNI},
802
782
{" jni_YGNodeRemoveChildJNI" , " (JJ)V" , (void *) jni_YGNodeRemoveChildJNI},
803
783
{" jni_YGNodeCalculateLayoutJNI" ,
804
784
" (JFF[J[Lcom/facebook/yoga/YogaNodeJNIBase;)V" ,
0 commit comments