diff --git a/benchmark/YGBenchmark.c b/benchmark/YGBenchmark.c index 443ed7e438..78aa2d2d6d 100644 --- a/benchmark/YGBenchmark.c +++ b/benchmark/YGBenchmark.c @@ -76,7 +76,7 @@ static void __printBenchmarkResult( } static YGSize _measure( - YGNodeRef node, + YGNodeConstRef node, float width, YGMeasureMode widthMode, float height, diff --git a/java/jni/YGJNIVanilla.cpp b/java/jni/YGJNIVanilla.cpp index 6a1406c170..af06c4a396 100644 --- a/java/jni/YGJNIVanilla.cpp +++ b/java/jni/YGJNIVanilla.cpp @@ -27,7 +27,7 @@ using namespace facebook::yoga; using namespace facebook::yoga::vanillajni; static inline ScopedLocalRef YGNodeJobject( - YGNodeRef node, + YGNodeConstRef node, void* layoutContext) { return reinterpret_cast(layoutContext)->ref(node); } @@ -138,8 +138,8 @@ static jlong jni_YGNodeNewWithConfigJNI( } static int YGJNILogFunc( - const YGConfigRef config, - const YGNodeRef /*node*/, + const YGConfigConstRef config, + const YGNodeConstRef /*node*/, YGLogLevel level, void* /*layoutContext*/, const char* format, @@ -639,7 +639,7 @@ static void jni_YGNodeStyleSetBorderJNI( yogaNodeRef, static_cast(edge), static_cast(border)); } -static void YGTransferLayoutDirection(YGNodeRef node, jobject javaNode) { +static void YGTransferLayoutDirection(YGNodeConstRef node, jobject javaNode) { // Don't change this field name without changing the name of the field in // Database.java JNIEnv* env = getCurrentEnv(); @@ -655,7 +655,7 @@ static void YGTransferLayoutDirection(YGNodeRef node, jobject javaNode) { } static YGSize YGJNIMeasureFunc( - YGNodeRef node, + YGNodeConstRef node, float width, YGMeasureMode widthMode, float height, @@ -700,7 +700,7 @@ static void jni_YGNodeSetHasMeasureFuncJNI( } static float YGJNIBaselineFunc( - YGNodeRef node, + YGNodeConstRef node, float width, float height, void* layoutContext) { diff --git a/javascript/src/Node.cpp b/javascript/src/Node.cpp index 2a1afa985c..7f4d674511 100644 --- a/javascript/src/Node.cpp +++ b/javascript/src/Node.cpp @@ -15,7 +15,7 @@ #include "./Config.h" static YGSize globalMeasureFunc( - YGNodeRef nodeRef, + YGNodeConstRef nodeRef, float width, YGMeasureMode widthMode, float height, @@ -29,7 +29,7 @@ static YGSize globalMeasureFunc( return ygSize; } -static void globalDirtiedFunc(YGNodeRef nodeRef) { +static void globalDirtiedFunc(YGNodeConstRef nodeRef) { Node const& node = *reinterpret_cast(YGNodeGetContext(nodeRef)); node.callDirtiedFunc(); diff --git a/tests/EventsTest.cpp b/tests/EventsTest.cpp index 11131d4333..7dcee28918 100644 --- a/tests/EventsTest.cpp +++ b/tests/EventsTest.cpp @@ -249,7 +249,7 @@ TEST_F(EventTest, layout_events_has_max_measure_cache) { TEST_F(EventTest, measure_functions_get_wrapped) { auto root = YGNodeNew(); YGNodeSetMeasureFunc( - root, [](YGNodeRef, float, YGMeasureMode, float, YGMeasureMode) { + root, [](YGNodeConstRef, float, YGMeasureMode, float, YGMeasureMode) { return YGSize{}; }); @@ -267,7 +267,8 @@ TEST_F(EventTest, baseline_functions_get_wrapped) { auto child = YGNodeNew(); YGNodeInsertChild(root, child, 0); - YGNodeSetBaselineFunc(child, [](YGNodeRef, float, float) { return 0.0f; }); + YGNodeSetBaselineFunc( + child, [](YGNodeConstRef, float, float) { return 0.0f; }); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignBaseline); diff --git a/tests/YGAlignBaselineTest.cpp b/tests/YGAlignBaselineTest.cpp index df64a1517a..2750a474b6 100644 --- a/tests/YGAlignBaselineTest.cpp +++ b/tests/YGAlignBaselineTest.cpp @@ -9,14 +9,14 @@ #include static float _baselineFunc( - YGNodeRef /*node*/, + YGNodeConstRef /*node*/, const float /*width*/, const float height) { return height / 2; } static YGSize _measure1( - YGNodeRef /*node*/, + YGNodeConstRef /*node*/, float /*width*/, YGMeasureMode /*widthMode*/, float /*height*/, @@ -25,7 +25,7 @@ static YGSize _measure1( } static YGSize _measure2( - YGNodeRef /*node*/, + YGNodeConstRef /*node*/, float /*width*/, YGMeasureMode /*widthMode*/, float /*height*/, diff --git a/tests/YGAspectRatioTest.cpp b/tests/YGAspectRatioTest.cpp index 4a5fe60003..378f407165 100644 --- a/tests/YGAspectRatioTest.cpp +++ b/tests/YGAspectRatioTest.cpp @@ -9,7 +9,7 @@ #include static YGSize _measure( - YGNodeRef /*node*/, + YGNodeConstRef /*node*/, float width, YGMeasureMode widthMode, float height, diff --git a/tests/YGBaselineFuncTest.cpp b/tests/YGBaselineFuncTest.cpp index 5888dcae88..d93910d489 100644 --- a/tests/YGBaselineFuncTest.cpp +++ b/tests/YGBaselineFuncTest.cpp @@ -9,7 +9,7 @@ #include static float _baseline( - YGNodeRef node, + YGNodeConstRef node, const float /*width*/, const float /*height*/) { float* baseline = (float*) YGNodeGetContext(node); diff --git a/tests/YGDirtiedTest.cpp b/tests/YGDirtiedTest.cpp index f996ac5f1b..6b9b38f685 100644 --- a/tests/YGDirtiedTest.cpp +++ b/tests/YGDirtiedTest.cpp @@ -11,7 +11,7 @@ using namespace facebook; -static void _dirtied(YGNodeRef node) { +static void _dirtied(YGNodeConstRef node) { int* dirtiedCount = (int*) YGNodeGetContext(node); (*dirtiedCount)++; } diff --git a/tests/YGDirtyMarkingTest.cpp b/tests/YGDirtyMarkingTest.cpp index b548a921e9..a032b27801 100644 --- a/tests/YGDirtyMarkingTest.cpp +++ b/tests/YGDirtyMarkingTest.cpp @@ -147,7 +147,7 @@ TEST(YogaTest, dirty_propagation_changing_benign_config) { YGConfigRef newConfig = YGConfigNew(); YGConfigSetLogger( newConfig, - [](const YGConfigRef, const YGNodeRef, YGLogLevel, const char*, va_list) { + [](YGConfigConstRef, YGNodeConstRef, YGLogLevel, const char*, va_list) { return 0; }); YGNodeSetConfig(root_child0, newConfig); diff --git a/tests/YGLoggerTest.cpp b/tests/YGLoggerTest.cpp index d1aa972741..276d3fe0ca 100644 --- a/tests/YGLoggerTest.cpp +++ b/tests/YGLoggerTest.cpp @@ -14,8 +14,8 @@ namespace { char writeBuffer[4096]; int _unmanagedLogger( - const YGConfigRef /*config*/, - const YGNodeRef /*node*/, + const YGConfigConstRef /*config*/, + const YGNodeConstRef /*node*/, YGLogLevel /*level*/, const char* format, va_list args) { diff --git a/tests/YGMeasureCacheTest.cpp b/tests/YGMeasureCacheTest.cpp index a973837413..f5d73520eb 100644 --- a/tests/YGMeasureCacheTest.cpp +++ b/tests/YGMeasureCacheTest.cpp @@ -9,7 +9,7 @@ #include static YGSize _measureMax( - YGNodeRef node, + YGNodeConstRef node, float width, YGMeasureMode widthMode, float height, @@ -24,7 +24,7 @@ static YGSize _measureMax( } static YGSize _measureMin( - YGNodeRef node, + YGNodeConstRef node, float width, YGMeasureMode widthMode, float height, @@ -44,7 +44,7 @@ static YGSize _measureMin( } static YGSize _measure_84_49( - YGNodeRef node, + YGNodeConstRef node, float /*width*/, YGMeasureMode /*widthMode*/, float /*height*/, diff --git a/tests/YGMeasureModeTest.cpp b/tests/YGMeasureModeTest.cpp index e9f977aa4e..8825a02374 100644 --- a/tests/YGMeasureModeTest.cpp +++ b/tests/YGMeasureModeTest.cpp @@ -21,7 +21,7 @@ struct _MeasureConstraintList { }; static YGSize _measure( - YGNodeRef node, + YGNodeConstRef node, float width, YGMeasureMode widthMode, float height, diff --git a/tests/YGMeasureTest.cpp b/tests/YGMeasureTest.cpp index e6d851cdc2..cce30f8d2a 100644 --- a/tests/YGMeasureTest.cpp +++ b/tests/YGMeasureTest.cpp @@ -9,7 +9,7 @@ #include static YGSize _measure( - YGNodeRef node, + YGNodeConstRef node, float /*width*/, YGMeasureMode /*widthMode*/, float /*height*/, @@ -23,7 +23,7 @@ static YGSize _measure( } static YGSize _simulate_wrapping_text( - YGNodeRef /*node*/, + YGNodeConstRef /*node*/, float width, YGMeasureMode widthMode, float /*height*/, @@ -36,7 +36,7 @@ static YGSize _simulate_wrapping_text( } static YGSize _measure_assert_negative( - YGNodeRef /*node*/, + YGNodeConstRef /*node*/, float width, YGMeasureMode /*widthMode*/, float height, @@ -640,7 +640,7 @@ TEST(YogaTest, cant_call_negative_measure_horizontal) { } static YGSize _measure_90_10( - YGNodeRef /*node*/, + YGNodeConstRef /*node*/, float /*width*/, YGMeasureMode /*widthMode*/, float /*height*/, @@ -650,7 +650,7 @@ static YGSize _measure_90_10( } static YGSize _measure_100_100( - YGNodeRef /*node*/, + YGNodeConstRef /*node*/, float /*width*/, YGMeasureMode /*widthMode*/, float /*height*/, diff --git a/tests/YGNodeCallbackTest.cpp b/tests/YGNodeCallbackTest.cpp index ec41bb43ba..e599af501b 100644 --- a/tests/YGNodeCallbackTest.cpp +++ b/tests/YGNodeCallbackTest.cpp @@ -22,9 +22,10 @@ TEST(Node, hasMeasureFunc_initial) { TEST(Node, hasMeasureFunc_with_measure_fn) { auto n = Node{}; - n.setMeasureFunc([](YGNodeRef, float, YGMeasureMode, float, YGMeasureMode) { - return YGSize{}; - }); + n.setMeasureFunc( + [](YGNodeConstRef, float, YGMeasureMode, float, YGMeasureMode) { + return YGSize{}; + }); ASSERT_TRUE(n.hasMeasureFunc()); } @@ -32,7 +33,7 @@ TEST(Node, measure_with_measure_fn) { auto n = Node{}; n.setMeasureFunc( - [](YGNodeRef, float w, YGMeasureMode wm, float h, YGMeasureMode hm) { + [](YGNodeConstRef, float w, YGMeasureMode wm, float h, YGMeasureMode hm) { return YGSize{w * static_cast(wm), h / static_cast(hm)}; }); @@ -43,10 +44,12 @@ TEST(Node, measure_with_measure_fn) { TEST(Node, measure_with_context_measure_fn) { auto n = Node{}; - n.setMeasureFunc( - [](YGNodeRef, float, YGMeasureMode, float, YGMeasureMode, void* ctx) { - return *(YGSize*) ctx; - }); + n.setMeasureFunc([](YGNodeConstRef, + float, + YGMeasureMode, + float, + YGMeasureMode, + void* ctx) { return *(YGSize*) ctx; }); auto result = YGSize{123.4f, -56.7f}; ASSERT_EQ( @@ -57,11 +60,11 @@ TEST(Node, measure_with_context_measure_fn) { TEST(Node, switching_measure_fn_types) { auto n = Node{}; n.setMeasureFunc( - [](YGNodeRef, float, YGMeasureMode, float, YGMeasureMode, void*) { + [](YGNodeConstRef, float, YGMeasureMode, float, YGMeasureMode, void*) { return YGSize{}; }); n.setMeasureFunc( - [](YGNodeRef, float w, YGMeasureMode wm, float h, YGMeasureMode hm) { + [](YGNodeConstRef, float w, YGMeasureMode wm, float h, YGMeasureMode hm) { return YGSize{w * static_cast(wm), h / static_cast(hm)}; }); @@ -72,9 +75,10 @@ TEST(Node, switching_measure_fn_types) { TEST(Node, hasMeasureFunc_after_unset) { auto n = Node{}; - n.setMeasureFunc([](YGNodeRef, float, YGMeasureMode, float, YGMeasureMode) { - return YGSize{}; - }); + n.setMeasureFunc( + [](YGNodeConstRef, float, YGMeasureMode, float, YGMeasureMode) { + return YGSize{}; + }); n.setMeasureFunc(nullptr); ASSERT_FALSE(n.hasMeasureFunc()); @@ -83,7 +87,7 @@ TEST(Node, hasMeasureFunc_after_unset) { TEST(Node, hasMeasureFunc_after_unset_context) { auto n = Node{}; n.setMeasureFunc( - [](YGNodeRef, float, YGMeasureMode, float, YGMeasureMode, void*) { + [](YGNodeConstRef, float, YGMeasureMode, float, YGMeasureMode, void*) { return YGSize{}; }); @@ -98,20 +102,20 @@ TEST(Node, hasBaselineFunc_initial) { TEST(Node, hasBaselineFunc_with_baseline_fn) { auto n = Node{}; - n.setBaselineFunc([](YGNodeRef, float, float) { return 0.0f; }); + n.setBaselineFunc([](YGNodeConstRef, float, float) { return 0.0f; }); ASSERT_TRUE(n.hasBaselineFunc()); } TEST(Node, baseline_with_baseline_fn) { auto n = Node{}; - n.setBaselineFunc([](YGNodeRef, float w, float h) { return w + h; }); + n.setBaselineFunc([](YGNodeConstRef, float w, float h) { return w + h; }); ASSERT_EQ(n.baseline(1.25f, 2.5f, nullptr), 3.75f); } TEST(Node, baseline_with_context_baseline_fn) { auto n = Node{}; - n.setBaselineFunc([](YGNodeRef, float w, float h, void* ctx) { + n.setBaselineFunc([](YGNodeConstRef, float w, float h, void* ctx) { return w + h + *(float*) ctx; }); @@ -121,7 +125,7 @@ TEST(Node, baseline_with_context_baseline_fn) { TEST(Node, hasBaselineFunc_after_unset) { auto n = Node{}; - n.setBaselineFunc([](YGNodeRef, float, float) { return 0.0f; }); + n.setBaselineFunc([](YGNodeConstRef, float, float) { return 0.0f; }); n.setBaselineFunc(nullptr); ASSERT_FALSE(n.hasBaselineFunc()); @@ -129,7 +133,7 @@ TEST(Node, hasBaselineFunc_after_unset) { TEST(Node, hasBaselineFunc_after_unset_context) { auto n = Node{}; - n.setBaselineFunc([](YGNodeRef, float, float, void*) { return 0.0f; }); + n.setBaselineFunc([](YGNodeConstRef, float, float, void*) { return 0.0f; }); n.setMeasureFunc(nullptr); ASSERT_FALSE(n.hasMeasureFunc()); @@ -137,7 +141,7 @@ TEST(Node, hasBaselineFunc_after_unset_context) { TEST(Node, switching_baseline_fn_types) { auto n = Node{}; - n.setBaselineFunc([](YGNodeRef, float, float, void*) { return 0.0f; }); - n.setBaselineFunc([](YGNodeRef, float, float) { return 1.0f; }); + n.setBaselineFunc([](YGNodeConstRef, float, float, void*) { return 0.0f; }); + n.setBaselineFunc([](YGNodeConstRef, float, float) { return 1.0f; }); ASSERT_EQ(n.baseline(1, 2, nullptr), 1.0f); } diff --git a/tests/YGRoundingFunctionTest.cpp b/tests/YGRoundingFunctionTest.cpp index 4405b855d0..90b15f7e43 100644 --- a/tests/YGRoundingFunctionTest.cpp +++ b/tests/YGRoundingFunctionTest.cpp @@ -43,7 +43,7 @@ TEST(YogaTest, rounding_value) { } static YGSize measureText( - YGNodeRef /*node*/, + YGNodeConstRef /*node*/, float /*width*/, YGMeasureMode /*widthMode*/, float /*height*/, diff --git a/tests/YGRoundingMeasureFuncTest.cpp b/tests/YGRoundingMeasureFuncTest.cpp index c5c3a3ab6b..045089d797 100644 --- a/tests/YGRoundingMeasureFuncTest.cpp +++ b/tests/YGRoundingMeasureFuncTest.cpp @@ -9,7 +9,7 @@ #include static YGSize _measureFloor( - YGNodeRef /*node*/, + YGNodeConstRef /*node*/, float width, YGMeasureMode /*widthMode*/, float height, @@ -21,7 +21,7 @@ static YGSize _measureFloor( } static YGSize _measureCeil( - YGNodeRef /*node*/, + YGNodeConstRef /*node*/, float width, YGMeasureMode /*widthMode*/, float height, @@ -33,7 +33,7 @@ static YGSize _measureCeil( } static YGSize _measureFractial( - YGNodeRef /*node*/, + YGNodeConstRef /*node*/, float width, YGMeasureMode /*widthMode*/, float height, diff --git a/tests/generated/YGConfigTest.cpp b/tests/generated/YGConfigTest.cpp index 8665d50023..4cfd90eff2 100644 --- a/tests/generated/YGConfigTest.cpp +++ b/tests/generated/YGConfigTest.cpp @@ -23,8 +23,12 @@ struct ConfigCloningTest : public ::testing::Test { void TearDown() override; static yoga::Node clonedNode; - static YGNodeRef cloneNode(YGNodeRef, YGNodeRef, int) { return &clonedNode; } - static YGNodeRef doNotClone(YGNodeRef, YGNodeRef, int) { return nullptr; } + static YGNodeRef cloneNode(YGNodeConstRef, YGNodeConstRef, int) { + return &clonedNode; + } + static YGNodeRef doNotClone(YGNodeConstRef, YGNodeConstRef, int) { + return nullptr; + } }; TEST_F(ConfigCloningTest, uses_values_provided_by_cloning_callback) { @@ -49,9 +53,10 @@ TEST_F( } TEST_F(ConfigCloningTest, can_clone_with_context) { - config->setCloneNodeCallback([](YGNodeRef, YGNodeRef, int, void* context) { - return (YGNodeRef) context; - }); + config->setCloneNodeCallback( + [](YGNodeConstRef, YGNodeConstRef, int, void* context) { + return (YGNodeRef) context; + }); yoga::Node node{}, owner{}, clone{}; ASSERT_EQ(config->cloneNode(&node, &owner, 0, &clone), &clone); diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index 1b81de2be5..0e89c06d8a 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -22,15 +22,15 @@ using namespace facebook::yoga; #ifdef ANDROID static int YGAndroidLog( - const YGConfigRef config, - const YGNodeRef node, + const YGConfigConstRef config, + const YGNodeConstRef node, YGLogLevel level, const char* format, va_list args); #else static int YGDefaultLog( - const YGConfigRef config, - const YGNodeRef node, + const YGConfigConstRef config, + const YGNodeConstRef node, YGLogLevel level, const char* format, va_list args); @@ -39,8 +39,8 @@ static int YGDefaultLog( #ifdef ANDROID #include static int YGAndroidLog( - const YGConfigRef /*config*/, - const YGNodeRef /*node*/, + const YGConfigConstRef /*config*/, + const YGNodeConstRef /*node*/, YGLogLevel level, const char* format, va_list args) { @@ -69,16 +69,12 @@ static int YGAndroidLog( return result; } #else -#define YG_UNUSED(x) (void) (x); - static int YGDefaultLog( - const YGConfigRef config, - const YGNodeRef node, + const YGConfigConstRef /*config*/, + const YGNodeConstRef /*node*/, YGLogLevel level, const char* format, va_list args) { - YG_UNUSED(config); - YG_UNUSED(node); switch (level) { case YGLogLevelError: case YGLogLevelFatal: @@ -91,8 +87,6 @@ static int YGDefaultLog( return vprintf(format, args); } } - -#undef YG_UNUSED #endif YOGA_EXPORT bool YGFloatIsUndefined(const float value) { @@ -202,7 +196,7 @@ YOGA_EXPORT YGNodeRef YGNodeNew(void) { return YGNodeNewWithConfig(YGConfigGetDefault()); } -YOGA_EXPORT YGNodeRef YGNodeClone(YGNodeRef oldNodeRef) { +YOGA_EXPORT YGNodeRef YGNodeClone(YGNodeConstRef oldNodeRef) { auto oldNode = resolveRef(oldNodeRef); const auto node = new yoga::Node(*oldNode); yoga::assertFatalWithConfig( diff --git a/yoga/Yoga.h b/yoga/Yoga.h index 54569adc5d..fa5b9834ec 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -29,28 +29,30 @@ typedef struct YGNode* YGNodeRef; typedef const struct YGNode* YGNodeConstRef; typedef YGSize (*YGMeasureFunc)( - YGNodeRef node, + YGNodeConstRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode); -typedef float (*YGBaselineFunc)(YGNodeRef node, float width, float height); -typedef void (*YGDirtiedFunc)(YGNodeRef node); -typedef void (*YGPrintFunc)(YGNodeRef node); -typedef void (*YGNodeCleanupFunc)(YGNodeRef node); +typedef float (*YGBaselineFunc)(YGNodeConstRef node, float width, float height); +typedef void (*YGDirtiedFunc)(YGNodeConstRef node); +typedef void (*YGPrintFunc)(YGNodeConstRef node); +typedef void (*YGNodeCleanupFunc)(YGNodeConstRef node); typedef int (*YGLogger)( - YGConfigRef config, - YGNodeRef node, + YGConfigConstRef config, + YGNodeConstRef node, YGLogLevel level, const char* format, va_list args); -typedef YGNodeRef ( - *YGCloneNodeFunc)(YGNodeRef oldNode, YGNodeRef owner, int childIndex); +typedef YGNodeRef (*YGCloneNodeFunc)( + YGNodeConstRef oldNode, + YGNodeConstRef owner, + int childIndex); // YGNode WIN_EXPORT YGNodeRef YGNodeNew(void); WIN_EXPORT YGNodeRef YGNodeNewWithConfig(YGConfigRef config); -WIN_EXPORT YGNodeRef YGNodeClone(YGNodeRef node); +WIN_EXPORT YGNodeRef YGNodeClone(YGNodeConstRef node); WIN_EXPORT void YGNodeFree(YGNodeRef node); WIN_EXPORT void YGNodeFreeRecursiveWithCleanupFunc( YGNodeRef node, diff --git a/yoga/config/Config.cpp b/yoga/config/Config.cpp index 3032a5b7d1..deb7b5fe4d 100644 --- a/yoga/config/Config.cpp +++ b/yoga/config/Config.cpp @@ -107,23 +107,10 @@ void Config::log( void* logContext, const char* format, va_list args) const { - // TODO: Break log callback signatures to make them const correct - if (flags_.loggerUsesContext) { - logger_.withContext( - const_cast(this), - const_cast(node), - logLevel, - logContext, - format, - args); + logger_.withContext(this, node, logLevel, logContext, format, args); } else { - logger_.noContext( - const_cast(this), - const_cast(node), - logLevel, - format, - args); + logger_.noContext(this, node, logLevel, format, args); } } @@ -142,8 +129,8 @@ void Config::setCloneNodeCallback(std::nullptr_t) { } YGNodeRef Config::cloneNode( - YGNodeRef node, - YGNodeRef owner, + YGNodeConstRef node, + YGNodeConstRef owner, int childIndex, void* cloneContext) const { YGNodeRef clone = nullptr; diff --git a/yoga/config/Config.h b/yoga/config/Config.h index 0a422c9c29..75bde993b6 100644 --- a/yoga/config/Config.h +++ b/yoga/config/Config.h @@ -25,15 +25,15 @@ bool configUpdateInvalidatesLayout(Config* a, Config* b); // Internal variants of log functions, currently used only by JNI bindings. // TODO: Reconcile this with the public API using LogWithContextFn = int (*)( - YGConfigRef config, - YGNodeRef node, + YGConfigConstRef config, + YGNodeConstRef node, YGLogLevel level, void* context, const char* format, va_list args); using CloneWithContextFn = YGNodeRef (*)( - YGNodeRef node, - YGNodeRef owner, + YGNodeConstRef node, + YGNodeConstRef owner, int childIndex, void* cloneContext); @@ -90,8 +90,8 @@ class YOGA_EXPORT Config : public ::YGConfig { void setCloneNodeCallback(CloneWithContextFn cloneNode); void setCloneNodeCallback(std::nullptr_t); YGNodeRef cloneNode( - YGNodeRef node, - YGNodeRef owner, + YGNodeConstRef node, + YGNodeConstRef owner, int childIndex, void* cloneContext) const; diff --git a/yoga/node/Node.h b/yoga/node/Node.h index 8a21d43060..4e8ef24ede 100644 --- a/yoga/node/Node.h +++ b/yoga/node/Node.h @@ -38,10 +38,17 @@ struct NodeFlags { class YOGA_EXPORT Node : public ::YGNode { public: - using MeasureWithContextFn = - YGSize (*)(YGNode*, float, YGMeasureMode, float, YGMeasureMode, void*); - using BaselineWithContextFn = float (*)(YGNode*, float, float, void*); - using PrintWithContextFn = void (*)(YGNode*, void*); + // Internal variants of callbacks, currently used only by JNI bindings. + // TODO: Reconcile this with the public API + using MeasureWithContextFn = YGSize (*)( + YGNodeConstRef, + float, + YGMeasureMode, + float, + YGMeasureMode, + void*); + using BaselineWithContextFn = float (*)(YGNodeConstRef, float, float, void*); + using PrintWithContextFn = void (*)(YGNodeConstRef, void*); private: void* context_ = nullptr;