Update YGNodeStyleGetGap to return YGValue #1753

Closed
heoblitz wants to merge 2 commits from feature/gap-ygvalue into main
9 changed files with 18 additions and 22 deletions

View File

@@ -225,17 +225,17 @@ static void serializeTreeImpl(
appendEdges<&YGNodeStyleGetPosition>( appendEdges<&YGNodeStyleGetPosition>(
j, "position", node, defaultNode.get()); j, "position", node, defaultNode.get());
appendFloatIfNotDefault( appendYGValueIfNotDefault(
j["style"], j["style"],
"gap", "gap",
YGNodeStyleGetGap(node, YGGutterAll), YGNodeStyleGetGap(node, YGGutterAll),
YGNodeStyleGetGap(defaultNode.get(), YGGutterAll)); YGNodeStyleGetGap(defaultNode.get(), YGGutterAll));
appendFloatIfNotDefault( appendYGValueIfNotDefault(
j["style"], j["style"],
"column-gap", "column-gap",
YGNodeStyleGetGap(node, YGGutterColumn), YGNodeStyleGetGap(node, YGGutterColumn),
YGNodeStyleGetGap(defaultNode.get(), YGGutterColumn)); YGNodeStyleGetGap(defaultNode.get(), YGGutterColumn));
appendFloatIfNotDefault( appendYGValueIfNotDefault(
j["style"], j["style"],
"row-gap", "row-gap",
YGNodeStyleGetGap(node, YGGutterRow), YGNodeStyleGetGap(node, YGGutterRow),

View File

@@ -130,7 +130,7 @@ public class YogaNative {
static native void jni_YGNodeStyleSetMaxHeightStretchJNI(long nativePointer); static native void jni_YGNodeStyleSetMaxHeightStretchJNI(long nativePointer);
static native float jni_YGNodeStyleGetAspectRatioJNI(long nativePointer); static native float jni_YGNodeStyleGetAspectRatioJNI(long nativePointer);
static native void jni_YGNodeStyleSetAspectRatioJNI(long nativePointer, float aspectRatio); static native void jni_YGNodeStyleSetAspectRatioJNI(long nativePointer, float aspectRatio);
static native float jni_YGNodeStyleGetGapJNI(long nativePointer, int gutter); static native long jni_YGNodeStyleGetGapJNI(long nativePointer, int gutter);
static native void jni_YGNodeStyleSetGapJNI(long nativePointer, int gutter, float gapLength); static native void jni_YGNodeStyleSetGapJNI(long nativePointer, int gutter, float gapLength);
static native void jni_YGNodeStyleSetGapPercentJNI(long nativePointer, int gutter, float gapLength); static native void jni_YGNodeStyleSetGapPercentJNI(long nativePointer, int gutter, float gapLength);
static native void jni_YGNodeSetHasMeasureFuncJNI(long nativePointer, boolean hasMeasureFunc); static native void jni_YGNodeSetHasMeasureFuncJNI(long nativePointer, boolean hasMeasureFunc);

View File

@@ -236,7 +236,7 @@ public abstract class YogaNode implements YogaProps {
public abstract void setAspectRatio(float aspectRatio); public abstract void setAspectRatio(float aspectRatio);
public abstract float getGap(YogaGutter gutter); public abstract YogaValue getGap(YogaGutter gutter);
public abstract void setGap(YogaGutter gutter, float gapLength); public abstract void setGap(YogaGutter gutter, float gapLength);

View File

@@ -811,8 +811,8 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
} }
@Override @Override
public float getGap(YogaGutter gutter) { public YogaValue getGap(YogaGutter gutter) {
return YogaNative.jni_YGNodeStyleGetGapJNI(mNativePointer, gutter.intValue()); return valueFromLong(YogaNative.jni_YGNodeStyleGetGapJNI(mNativePointer, gutter.intValue()));
} }
@Override @Override

View File

@@ -725,13 +725,13 @@ jni_YGNodeCloneJNI(JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) {
return reinterpret_cast<jlong>(clonedYogaNode); return reinterpret_cast<jlong>(clonedYogaNode);
} }
static jfloat jni_YGNodeStyleGetGapJNI( static jlong jni_YGNodeStyleGetGapJNI(
JNIEnv* /*env*/, JNIEnv* /*env*/,
jobject /*obj*/, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jint gutter) { jint gutter) {
return (jfloat)YGNodeStyleGetGap( return YogaValue::asJavaLong(YGNodeStyleGetGap(
_jlong2YGNodeRef(nativePointer), static_cast<YGGutter>(gutter)); _jlong2YGNodeRef(nativePointer), static_cast<YGGutter>(gutter)));
} }
static void jni_YGNodeStyleSetGapJNI( static void jni_YGNodeStyleSetGapJNI(
@@ -1057,7 +1057,7 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeSetHasMeasureFuncJNI", {"jni_YGNodeSetHasMeasureFuncJNI",
"(JZ)V", "(JZ)V",
(void*)jni_YGNodeSetHasMeasureFuncJNI}, (void*)jni_YGNodeSetHasMeasureFuncJNI},
{"jni_YGNodeStyleGetGapJNI", "(JI)F", (void*)jni_YGNodeStyleGetGapJNI}, {"jni_YGNodeStyleGetGapJNI", "(JI)J", (void*)jni_YGNodeStyleGetGapJNI},
{"jni_YGNodeStyleSetGapJNI", "(JIF)V", (void*)jni_YGNodeStyleSetGapJNI}, {"jni_YGNodeStyleSetGapJNI", "(JIF)V", (void*)jni_YGNodeStyleSetGapJNI},
{"jni_YGNodeStyleSetGapPercentJNI", {"jni_YGNodeStyleSetGapPercentJNI",
"(JIF)V", "(JIF)V",

View File

@@ -439,8 +439,9 @@ Value Node::getPadding(int edge) const {
YGNodeStyleGetPadding(m_node, static_cast<YGEdge>(edge))); YGNodeStyleGetPadding(m_node, static_cast<YGEdge>(edge)));
} }
float Node::getGap(int gutter) { Value Node::getGap(int gutter) const {
return YGNodeStyleGetGap(m_node, static_cast<YGGutter>(gutter)); return Value::fromYGValue(
YGNodeStyleGetGap(m_node, static_cast<YGGutter>(gutter)));
} }
bool Node::isReferenceBaseline() { bool Node::isReferenceBaseline() {

View File

@@ -186,7 +186,7 @@ class Node {
Value getPadding(int edge) const; Value getPadding(int edge) const;
float getGap(int gutter); Value getGap(int gutter) const;
int getBoxSizing(void) const; int getBoxSizing(void) const;

View File

@@ -293,13 +293,8 @@ void YGNodeStyleSetGapPercent(YGNodeRef node, YGGutter gutter, float percent) {
node, scopedEnum(gutter), StyleLength::percent(percent)); node, scopedEnum(gutter), StyleLength::percent(percent));
} }
float YGNodeStyleGetGap(const YGNodeConstRef node, const YGGutter gutter) { YGValue YGNodeStyleGetGap(const YGNodeConstRef node, const YGGutter gutter) {
auto gapLength = resolveRef(node)->style().gap(scopedEnum(gutter)); return (YGValue)resolveRef(node)->style().gap(scopedEnum(gutter));
if (gapLength.isUndefined() || gapLength.isAuto()) {
return YGUndefined;
}
return static_cast<YGValue>(gapLength).value;
} }
void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) { void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) {

View File

@@ -96,7 +96,7 @@ YG_EXPORT void
YGNodeStyleSetGap(YGNodeRef node, YGGutter gutter, float gapLength); YGNodeStyleSetGap(YGNodeRef node, YGGutter gutter, float gapLength);
YG_EXPORT void YG_EXPORT void
YGNodeStyleSetGapPercent(YGNodeRef node, YGGutter gutter, float gapLength); YGNodeStyleSetGapPercent(YGNodeRef node, YGGutter gutter, float gapLength);
YG_EXPORT float YGNodeStyleGetGap(YGNodeConstRef node, YGGutter gutter); YG_EXPORT YGValue YGNodeStyleGetGap(YGNodeConstRef node, YGGutter gutter);
YG_EXPORT void YGNodeStyleSetBoxSizing(YGNodeRef node, YGBoxSizing boxSizing); YG_EXPORT void YGNodeStyleSetBoxSizing(YGNodeRef node, YGBoxSizing boxSizing);
YG_EXPORT YGBoxSizing YGNodeStyleGetBoxSizing(YGNodeConstRef node); YG_EXPORT YGBoxSizing YGNodeStyleGetBoxSizing(YGNodeConstRef node);