Lint / reformat YGJNI.cpp
Summary: Run clangformat on `YGJNI.cpp` @public Reviewed By: priteshrnandgaonkar Differential Revision: D8785660 fbshipit-source-id: 9748a5297e7b55e897de0280a79c2ea6ae1c1298
This commit is contained in:
committed by
Facebook Github Bot
parent
2eda444bbf
commit
ede2888326
@@ -33,13 +33,17 @@ struct YGConfigContext {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline weak_ref<JYogaNode> *YGNodeJobject(YGNodeRef node) {
|
static inline weak_ref<JYogaNode>* YGNodeJobject(YGNodeRef node) {
|
||||||
return reinterpret_cast<weak_ref<JYogaNode>*>(node->getContext());
|
return reinterpret_cast<weak_ref<JYogaNode>*>(node->getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGTransferLayoutDirection(YGNodeRef node, alias_ref<jobject> javaNode) {
|
static void YGTransferLayoutDirection(
|
||||||
static auto layoutDirectionField = javaNode->getClass()->getField<jint>("mLayoutDirection");
|
YGNodeRef node,
|
||||||
javaNode->setFieldValue(layoutDirectionField, static_cast<jint>(YGNodeLayoutGetDirection(node)));
|
alias_ref<jobject> javaNode) {
|
||||||
|
static auto layoutDirectionField =
|
||||||
|
javaNode->getClass()->getField<jint>("mLayoutDirection");
|
||||||
|
javaNode->setFieldValue(
|
||||||
|
layoutDirectionField, static_cast<jint>(YGNodeLayoutGetDirection(node)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||||
@@ -50,23 +54,37 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
|||||||
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
|
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
|
||||||
static auto topField = obj->getClass()->getField<jfloat>("mTop");
|
static auto topField = obj->getClass()->getField<jfloat>("mTop");
|
||||||
|
|
||||||
static auto marginLeftField = obj->getClass()->getField<jfloat>("mMarginLeft");
|
static auto marginLeftField =
|
||||||
static auto marginTopField = obj->getClass()->getField<jfloat>("mMarginTop");
|
obj->getClass()->getField<jfloat>("mMarginLeft");
|
||||||
static auto marginRightField = obj->getClass()->getField<jfloat>("mMarginRight");
|
static auto marginTopField =
|
||||||
static auto marginBottomField = obj->getClass()->getField<jfloat>("mMarginBottom");
|
obj->getClass()->getField<jfloat>("mMarginTop");
|
||||||
|
static auto marginRightField =
|
||||||
|
obj->getClass()->getField<jfloat>("mMarginRight");
|
||||||
|
static auto marginBottomField =
|
||||||
|
obj->getClass()->getField<jfloat>("mMarginBottom");
|
||||||
|
|
||||||
static auto paddingLeftField = obj->getClass()->getField<jfloat>("mPaddingLeft");
|
static auto paddingLeftField =
|
||||||
static auto paddingTopField = obj->getClass()->getField<jfloat>("mPaddingTop");
|
obj->getClass()->getField<jfloat>("mPaddingLeft");
|
||||||
static auto paddingRightField = obj->getClass()->getField<jfloat>("mPaddingRight");
|
static auto paddingTopField =
|
||||||
static auto paddingBottomField = obj->getClass()->getField<jfloat>("mPaddingBottom");
|
obj->getClass()->getField<jfloat>("mPaddingTop");
|
||||||
|
static auto paddingRightField =
|
||||||
|
obj->getClass()->getField<jfloat>("mPaddingRight");
|
||||||
|
static auto paddingBottomField =
|
||||||
|
obj->getClass()->getField<jfloat>("mPaddingBottom");
|
||||||
|
|
||||||
static auto borderLeftField = obj->getClass()->getField<jfloat>("mBorderLeft");
|
static auto borderLeftField =
|
||||||
static auto borderTopField = obj->getClass()->getField<jfloat>("mBorderTop");
|
obj->getClass()->getField<jfloat>("mBorderLeft");
|
||||||
static auto borderRightField = obj->getClass()->getField<jfloat>("mBorderRight");
|
static auto borderTopField =
|
||||||
static auto borderBottomField = obj->getClass()->getField<jfloat>("mBorderBottom");
|
obj->getClass()->getField<jfloat>("mBorderTop");
|
||||||
|
static auto borderRightField =
|
||||||
|
obj->getClass()->getField<jfloat>("mBorderRight");
|
||||||
|
static auto borderBottomField =
|
||||||
|
obj->getClass()->getField<jfloat>("mBorderBottom");
|
||||||
|
|
||||||
static auto edgeSetFlagField = obj->getClass()->getField<jint>("mEdgeSetFlag");
|
static auto edgeSetFlagField =
|
||||||
static auto hasNewLayoutField = obj->getClass()->getField<jboolean>("mHasNewLayout");
|
obj->getClass()->getField<jint>("mEdgeSetFlag");
|
||||||
|
static auto hasNewLayoutField =
|
||||||
|
obj->getClass()->getField<jboolean>("mHasNewLayout");
|
||||||
static auto doesLegacyStretchBehaviour =
|
static auto doesLegacyStretchBehaviour =
|
||||||
obj->getClass()->getField<jboolean>(
|
obj->getClass()->getField<jboolean>(
|
||||||
"mDoesLegacyStretchFlagAffectsLayout");
|
"mDoesLegacyStretchFlagAffectsLayout");
|
||||||
@@ -76,7 +94,7 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
|||||||
const int PADDING = 2;
|
const int PADDING = 2;
|
||||||
const int BORDER = 4;
|
const int BORDER = 4;
|
||||||
|
|
||||||
int hasEdgeSetFlag = (int) obj->getFieldValue(edgeSetFlagField);
|
int hasEdgeSetFlag = (int)obj->getFieldValue(edgeSetFlagField);
|
||||||
|
|
||||||
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
|
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
|
||||||
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
|
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
|
||||||
@@ -98,17 +116,25 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((hasEdgeSetFlag & PADDING) == PADDING) {
|
if ((hasEdgeSetFlag & PADDING) == PADDING) {
|
||||||
obj->setFieldValue(paddingLeftField, YGNodeLayoutGetPadding(root, YGEdgeLeft));
|
obj->setFieldValue(
|
||||||
obj->setFieldValue(paddingTopField, YGNodeLayoutGetPadding(root, YGEdgeTop));
|
paddingLeftField, YGNodeLayoutGetPadding(root, YGEdgeLeft));
|
||||||
obj->setFieldValue(paddingRightField, YGNodeLayoutGetPadding(root, YGEdgeRight));
|
obj->setFieldValue(
|
||||||
obj->setFieldValue(paddingBottomField, YGNodeLayoutGetPadding(root, YGEdgeBottom));
|
paddingTopField, YGNodeLayoutGetPadding(root, YGEdgeTop));
|
||||||
|
obj->setFieldValue(
|
||||||
|
paddingRightField, YGNodeLayoutGetPadding(root, YGEdgeRight));
|
||||||
|
obj->setFieldValue(
|
||||||
|
paddingBottomField, YGNodeLayoutGetPadding(root, YGEdgeBottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hasEdgeSetFlag & BORDER) == BORDER) {
|
if ((hasEdgeSetFlag & BORDER) == BORDER) {
|
||||||
obj->setFieldValue(borderLeftField, YGNodeLayoutGetBorder(root, YGEdgeLeft));
|
obj->setFieldValue(
|
||||||
obj->setFieldValue(borderTopField, YGNodeLayoutGetBorder(root, YGEdgeTop));
|
borderLeftField, YGNodeLayoutGetBorder(root, YGEdgeLeft));
|
||||||
obj->setFieldValue(borderRightField, YGNodeLayoutGetBorder(root, YGEdgeRight));
|
obj->setFieldValue(
|
||||||
obj->setFieldValue(borderBottomField, YGNodeLayoutGetBorder(root, YGEdgeBottom));
|
borderTopField, YGNodeLayoutGetBorder(root, YGEdgeTop));
|
||||||
|
obj->setFieldValue(
|
||||||
|
borderRightField, YGNodeLayoutGetBorder(root, YGEdgeRight));
|
||||||
|
obj->setFieldValue(
|
||||||
|
borderBottomField, YGNodeLayoutGetBorder(root, YGEdgeBottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
obj->setFieldValue<jboolean>(hasNewLayoutField, true);
|
obj->setFieldValue<jboolean>(hasNewLayoutField, true);
|
||||||
@@ -119,7 +145,10 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
|||||||
YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i));
|
YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
YGLog(root, YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
YGLog(
|
||||||
|
root,
|
||||||
|
YGLogLevelError,
|
||||||
|
"Java YGNode was GCed during layout calculation\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,13 +157,17 @@ static void YGPrint(YGNodeRef node) {
|
|||||||
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
||||||
cout << obj->toString() << endl;
|
cout << obj->toString() << endl;
|
||||||
} else {
|
} else {
|
||||||
YGLog(node, YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
YGLog(
|
||||||
|
node,
|
||||||
|
YGLogLevelError,
|
||||||
|
"Java YGNode was GCed during layout calculation\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static float YGJNIBaselineFunc(YGNodeRef node, float width, float height) {
|
static float YGJNIBaselineFunc(YGNodeRef node, float width, float height) {
|
||||||
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
||||||
static auto baselineFunc = findClassStatic("com/facebook/yoga/YogaNode")
|
static auto baselineFunc =
|
||||||
|
findClassStatic("com/facebook/yoga/YogaNode")
|
||||||
->getMethod<jfloat(jfloat, jfloat)>("baseline");
|
->getMethod<jfloat(jfloat, jfloat)>("baseline");
|
||||||
return baselineFunc(obj, width, height);
|
return baselineFunc(obj, width, height);
|
||||||
} else {
|
} else {
|
||||||
@@ -150,20 +183,17 @@ static inline YGConfigRef _jlong2YGConfigRef(jlong addr) {
|
|||||||
return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr));
|
return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
static YGNodeRef YGJNIOnNodeClonedFunc(
|
static YGNodeRef
|
||||||
YGNodeRef oldNode,
|
YGJNIOnNodeClonedFunc(YGNodeRef oldNode, YGNodeRef owner, int childIndex) {
|
||||||
YGNodeRef owner,
|
|
||||||
int childIndex) {
|
|
||||||
auto config = oldNode->getConfig();
|
auto config = oldNode->getConfig();
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto onNodeClonedFunc = findClassStatic("com/facebook/yoga/YogaConfig")
|
static auto onNodeClonedFunc =
|
||||||
|
findClassStatic("com/facebook/yoga/YogaConfig")
|
||||||
->getMethod<alias_ref<JYogaNode>(
|
->getMethod<alias_ref<JYogaNode>(
|
||||||
local_ref<JYogaNode>,
|
local_ref<JYogaNode>, local_ref<JYogaNode>, jint)>("cloneNode");
|
||||||
local_ref<JYogaNode>,
|
|
||||||
jint)>("cloneNode");
|
|
||||||
|
|
||||||
auto context = reinterpret_cast<YGConfigContext*>(YGConfigGetContext(config));
|
auto context = reinterpret_cast<YGConfigContext*>(YGConfigGetContext(config));
|
||||||
auto javaConfig = context->config;
|
auto javaConfig = context->config;
|
||||||
@@ -174,15 +204,12 @@ static YGNodeRef YGJNIOnNodeClonedFunc(
|
|||||||
YGNodeJobject(owner)->lockLocal(),
|
YGNodeJobject(owner)->lockLocal(),
|
||||||
childIndex);
|
childIndex);
|
||||||
|
|
||||||
static auto replaceChild = findClassStatic("com/facebook/yoga/YogaNode")
|
static auto replaceChild =
|
||||||
->getMethod<jlong(
|
findClassStatic("com/facebook/yoga/YogaNode")
|
||||||
local_ref<JYogaNode>,
|
->getMethod<jlong(local_ref<JYogaNode>, jint)>("replaceChild");
|
||||||
jint)>("replaceChild");
|
|
||||||
|
|
||||||
jlong newNodeNativePointer = replaceChild(
|
jlong newNodeNativePointer =
|
||||||
YGNodeJobject(owner)->lockLocal(),
|
replaceChild(YGNodeJobject(owner)->lockLocal(), newNode, childIndex);
|
||||||
newNode,
|
|
||||||
childIndex);
|
|
||||||
|
|
||||||
return _jlong2YGNodeRef(newNodeNativePointer);
|
return _jlong2YGNodeRef(newNodeNativePointer);
|
||||||
}
|
}
|
||||||
@@ -194,24 +221,30 @@ static YGSize YGJNIMeasureFunc(
|
|||||||
float height,
|
float height,
|
||||||
YGMeasureMode heightMode) {
|
YGMeasureMode heightMode) {
|
||||||
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
||||||
static auto measureFunc = findClassStatic("com/facebook/yoga/YogaNode")
|
static auto measureFunc =
|
||||||
|
findClassStatic("com/facebook/yoga/YogaNode")
|
||||||
->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
|
->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
|
||||||
|
|
||||||
YGTransferLayoutDirection(node, obj);
|
YGTransferLayoutDirection(node, obj);
|
||||||
const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode);
|
const auto measureResult =
|
||||||
|
measureFunc(obj, width, widthMode, height, heightMode);
|
||||||
|
|
||||||
static_assert(sizeof(measureResult) == 8,
|
static_assert(
|
||||||
|
sizeof(measureResult) == 8,
|
||||||
"Expected measureResult to be 8 bytes, or two 32 bit ints");
|
"Expected measureResult to be 8 bytes, or two 32 bit ints");
|
||||||
|
|
||||||
int32_t wBits = 0xFFFFFFFF & (measureResult >> 32);
|
int32_t wBits = 0xFFFFFFFF & (measureResult >> 32);
|
||||||
int32_t hBits = 0xFFFFFFFF & measureResult;
|
int32_t hBits = 0xFFFFFFFF & measureResult;
|
||||||
|
|
||||||
const float *measuredWidth = reinterpret_cast<float *>(&wBits);
|
const float* measuredWidth = reinterpret_cast<float*>(&wBits);
|
||||||
const float *measuredHeight = reinterpret_cast<float *>(&hBits);
|
const float* measuredHeight = reinterpret_cast<float*>(&hBits);
|
||||||
|
|
||||||
return YGSize{*measuredWidth, *measuredHeight};
|
return YGSize{*measuredWidth, *measuredHeight};
|
||||||
} else {
|
} else {
|
||||||
YGLog(node, YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
YGLog(
|
||||||
|
node,
|
||||||
|
YGLogLevelError,
|
||||||
|
"Java YGNode was GCed during layout calculation\n");
|
||||||
return YGSize{
|
return YGSize{
|
||||||
widthMode == YGMeasureModeUndefined ? 0 : width,
|
widthMode == YGMeasureModeUndefined ? 0 : width,
|
||||||
heightMode == YGMeasureModeUndefined ? 0 : height,
|
heightMode == YGMeasureModeUndefined ? 0 : height,
|
||||||
@@ -223,10 +256,11 @@ struct JYogaLogLevel : public JavaClass<JYogaLogLevel> {
|
|||||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaLogLevel;";
|
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaLogLevel;";
|
||||||
};
|
};
|
||||||
|
|
||||||
static int YGJNILogFunc(const YGConfigRef config,
|
static int YGJNILogFunc(
|
||||||
|
const YGConfigRef config,
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
YGLogLevel level,
|
YGLogLevel level,
|
||||||
const char *format,
|
const char* format,
|
||||||
va_list args) {
|
va_list args) {
|
||||||
int result = vsnprintf(NULL, 0, format, args);
|
int result = vsnprintf(NULL, 0, format, args);
|
||||||
std::vector<char> buffer(1 + result);
|
std::vector<char> buffer(1 + result);
|
||||||
@@ -234,13 +268,16 @@ static int YGJNILogFunc(const YGConfigRef config,
|
|||||||
|
|
||||||
static auto logFunc =
|
static auto logFunc =
|
||||||
findClassStatic("com/facebook/yoga/YogaLogger")
|
findClassStatic("com/facebook/yoga/YogaLogger")
|
||||||
->getMethod<void(local_ref<JYogaNode>, local_ref<JYogaLogLevel>, jstring)>("log");
|
->getMethod<void(
|
||||||
|
local_ref<JYogaNode>, local_ref<JYogaLogLevel>, jstring)>("log");
|
||||||
|
|
||||||
static auto logLevelFromInt =
|
static auto logLevelFromInt =
|
||||||
JYogaLogLevel::javaClassStatic()->getStaticMethod<JYogaLogLevel::javaobject(jint)>("fromInt");
|
JYogaLogLevel::javaClassStatic()
|
||||||
|
->getStaticMethod<JYogaLogLevel::javaobject(jint)>("fromInt");
|
||||||
|
|
||||||
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
||||||
auto jlogger = reinterpret_cast<global_ref<jobject> *>(YGConfigGetContext(config));
|
auto jlogger =
|
||||||
|
reinterpret_cast<global_ref<jobject>*>(YGConfigGetContext(config));
|
||||||
logFunc(
|
logFunc(
|
||||||
jlogger->get(),
|
jlogger->get(),
|
||||||
obj,
|
obj,
|
||||||
@@ -309,13 +346,19 @@ void jni_YGNodeReset(alias_ref<jobject> thiz, jlong nativePointer) {
|
|||||||
|
|
||||||
void jni_YGNodePrint(alias_ref<jobject> thiz, jlong nativePointer) {
|
void jni_YGNodePrint(alias_ref<jobject> thiz, jlong nativePointer) {
|
||||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
||||||
YGNodePrint(node,
|
YGNodePrint(
|
||||||
(YGPrintOptions)(YGPrintOptionsStyle | YGPrintOptionsLayout |
|
node,
|
||||||
YGPrintOptionsChildren));
|
(YGPrintOptions)(
|
||||||
|
YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGNodeInsertChild(alias_ref<jobject>, jlong nativePointer, jlong childPointer, jint index) {
|
void jni_YGNodeInsertChild(
|
||||||
YGNodeInsertChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
|
alias_ref<jobject>,
|
||||||
|
jlong nativePointer,
|
||||||
|
jlong childPointer,
|
||||||
|
jint index) {
|
||||||
|
YGNodeInsertChild(
|
||||||
|
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGNodeInsertSharedChild(
|
void jni_YGNodeInsertSharedChild(
|
||||||
@@ -327,16 +370,22 @@ void jni_YGNodeInsertSharedChild(
|
|||||||
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
|
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGNodeRemoveChild(alias_ref<jobject>, jlong nativePointer, jlong childPointer) {
|
void jni_YGNodeRemoveChild(
|
||||||
YGNodeRemoveChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer));
|
alias_ref<jobject>,
|
||||||
|
jlong nativePointer,
|
||||||
|
jlong childPointer) {
|
||||||
|
YGNodeRemoveChild(
|
||||||
|
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGNodeCalculateLayout(alias_ref<jobject>,
|
void jni_YGNodeCalculateLayout(
|
||||||
|
alias_ref<jobject>,
|
||||||
jlong nativePointer,
|
jlong nativePointer,
|
||||||
jfloat width,
|
jfloat width,
|
||||||
jfloat height) {
|
jfloat height) {
|
||||||
const YGNodeRef root = _jlong2YGNodeRef(nativePointer);
|
const YGNodeRef root = _jlong2YGNodeRef(nativePointer);
|
||||||
YGNodeCalculateLayout(root,
|
YGNodeCalculateLayout(
|
||||||
|
root,
|
||||||
static_cast<float>(width),
|
static_cast<float>(width),
|
||||||
static_cast<float>(height),
|
static_cast<float>(height),
|
||||||
YGNodeStyleGetDirection(_jlong2YGNodeRef(nativePointer)));
|
YGNodeStyleGetDirection(_jlong2YGNodeRef(nativePointer)));
|
||||||
@@ -357,20 +406,28 @@ jboolean jni_YGNodeIsDirty(alias_ref<jobject>, jlong nativePointer) {
|
|||||||
return (jboolean)_jlong2YGNodeRef(nativePointer)->isDirty();
|
return (jboolean)_jlong2YGNodeRef(nativePointer)->isDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGNodeSetHasMeasureFunc(alias_ref<jobject>, jlong nativePointer, jboolean hasMeasureFunc) {
|
void jni_YGNodeSetHasMeasureFunc(
|
||||||
|
alias_ref<jobject>,
|
||||||
|
jlong nativePointer,
|
||||||
|
jboolean hasMeasureFunc) {
|
||||||
_jlong2YGNodeRef(nativePointer)
|
_jlong2YGNodeRef(nativePointer)
|
||||||
->setMeasureFunc(hasMeasureFunc ? YGJNIMeasureFunc : nullptr);
|
->setMeasureFunc(hasMeasureFunc ? YGJNIMeasureFunc : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGNodeSetHasBaselineFunc(alias_ref<jobject>,
|
void jni_YGNodeSetHasBaselineFunc(
|
||||||
|
alias_ref<jobject>,
|
||||||
jlong nativePointer,
|
jlong nativePointer,
|
||||||
jboolean hasBaselineFunc) {
|
jboolean hasBaselineFunc) {
|
||||||
_jlong2YGNodeRef(nativePointer)
|
_jlong2YGNodeRef(nativePointer)
|
||||||
->setBaseLineFunc(hasBaselineFunc ? YGJNIBaselineFunc : nullptr);
|
->setBaseLineFunc(hasBaselineFunc ? YGJNIBaselineFunc : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGNodeCopyStyle(alias_ref<jobject>, jlong dstNativePointer, jlong srcNativePointer) {
|
void jni_YGNodeCopyStyle(
|
||||||
YGNodeCopyStyle(_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer));
|
alias_ref<jobject>,
|
||||||
|
jlong dstNativePointer,
|
||||||
|
jlong srcNativePointer) {
|
||||||
|
YGNodeCopyStyle(
|
||||||
|
_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct JYogaValue : public JavaClass<JYogaValue> {
|
struct JYogaValue : public JavaClass<JYogaValue> {
|
||||||
@@ -393,66 +450,75 @@ struct JYogaValue : public JavaClass<JYogaValue> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
||||||
local_ref<jobject> jni_YGNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer) { \
|
local_ref<jobject> jni_YGNodeStyleGet##name( \
|
||||||
return JYogaValue::create(YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
|
alias_ref<jobject>, jlong nativePointer) { \
|
||||||
|
return JYogaValue::create( \
|
||||||
|
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void jni_YGNodeStyleSet##name(alias_ref<jobject>, jlong nativePointer, jfloat value) { \
|
void jni_YGNodeStyleSet##name( \
|
||||||
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
|
alias_ref<jobject>, jlong nativePointer, jfloat value) { \
|
||||||
|
YGNodeStyleSet##name( \
|
||||||
|
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void jni_YGNodeStyleSet##name##Percent(alias_ref<jobject>, jlong nativePointer, jfloat value) { \
|
void jni_YGNodeStyleSet##name##Percent( \
|
||||||
YGNodeStyleSet##name##Percent(_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
|
alias_ref<jobject>, jlong nativePointer, jfloat value) { \
|
||||||
|
YGNodeStyleSet##name##Percent( \
|
||||||
|
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(name) \
|
#define YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(name) \
|
||||||
YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
||||||
void jni_YGNodeStyleSet##name##Auto(alias_ref<jobject>, jlong nativePointer) { \
|
void jni_YGNodeStyleSet##name##Auto( \
|
||||||
|
alias_ref<jobject>, jlong nativePointer) { \
|
||||||
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
|
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
|
#define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
|
||||||
javatype jni_YGNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer, jint edge) { \
|
javatype jni_YGNodeStyleGet##name( \
|
||||||
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer), \
|
alias_ref<jobject>, jlong nativePointer, jint edge) { \
|
||||||
static_cast<YGEdge>(edge)); \
|
return (javatype)YGNodeStyleGet##name( \
|
||||||
|
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void jni_YGNodeStyleSet##name(alias_ref<jobject>, \
|
void jni_YGNodeStyleSet##name( \
|
||||||
jlong nativePointer, \
|
alias_ref<jobject>, jlong nativePointer, jint edge, javatype value) { \
|
||||||
jint edge, \
|
YGNodeStyleSet##name( \
|
||||||
javatype value) { \
|
_jlong2YGNodeRef(nativePointer), \
|
||||||
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), \
|
|
||||||
static_cast<YGEdge>(edge), \
|
static_cast<YGEdge>(edge), \
|
||||||
static_cast<type>(value)); \
|
static_cast<type>(value)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
|
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
|
||||||
local_ref<jobject> jni_YGNodeStyleGet##name(alias_ref<jobject>, \
|
local_ref<jobject> jni_YGNodeStyleGet##name( \
|
||||||
jlong nativePointer, \
|
alias_ref<jobject>, jlong nativePointer, jint edge) { \
|
||||||
jint edge) { \
|
return JYogaValue::create(YGNodeStyleGet##name( \
|
||||||
return JYogaValue::create( \
|
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge))); \
|
||||||
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge))); \
|
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void jni_YGNodeStyleSet##name(alias_ref<jobject>, jlong nativePointer, jint edge, jfloat value) { \
|
void jni_YGNodeStyleSet##name( \
|
||||||
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), \
|
alias_ref<jobject>, jlong nativePointer, jint edge, jfloat value) { \
|
||||||
|
YGNodeStyleSet##name( \
|
||||||
|
_jlong2YGNodeRef(nativePointer), \
|
||||||
static_cast<YGEdge>(edge), \
|
static_cast<YGEdge>(edge), \
|
||||||
static_cast<float>(value)); \
|
static_cast<float>(value)); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void jni_YGNodeStyleSet##name##Percent(alias_ref<jobject>, \
|
void jni_YGNodeStyleSet##name##Percent( \
|
||||||
jlong nativePointer, \
|
alias_ref<jobject>, jlong nativePointer, jint edge, jfloat value) { \
|
||||||
jint edge, \
|
YGNodeStyleSet##name##Percent( \
|
||||||
jfloat value) { \
|
_jlong2YGNodeRef(nativePointer), \
|
||||||
YGNodeStyleSet##name##Percent(_jlong2YGNodeRef(nativePointer), \
|
|
||||||
static_cast<YGEdge>(edge), \
|
static_cast<YGEdge>(edge), \
|
||||||
static_cast<float>(value)); \
|
static_cast<float>(value)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(name) \
|
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(name) \
|
||||||
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
|
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
|
||||||
void jni_YGNodeStyleSet##name##Auto(alias_ref<jobject>, jlong nativePointer, jint edge) { \
|
void jni_YGNodeStyleSet##name##Auto( \
|
||||||
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \
|
alias_ref<jobject>, jlong nativePointer, jint edge) { \
|
||||||
|
YGNodeStyleSet##name##Auto( \
|
||||||
|
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
|
YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
|
||||||
@@ -466,8 +532,12 @@ YG_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap);
|
|||||||
YG_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow);
|
YG_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow);
|
||||||
YG_NODE_JNI_STYLE_PROP(jint, YGDisplay, Display);
|
YG_NODE_JNI_STYLE_PROP(jint, YGDisplay, Display);
|
||||||
|
|
||||||
void jni_YGNodeStyleSetFlex(alias_ref<jobject>, jlong nativePointer, jfloat value) {
|
void jni_YGNodeStyleSetFlex(
|
||||||
YGNodeStyleSetFlex(_jlong2YGNodeRef(nativePointer), static_cast<float>(value));
|
alias_ref<jobject>,
|
||||||
|
jlong nativePointer,
|
||||||
|
jfloat value) {
|
||||||
|
YGNodeStyleSetFlex(
|
||||||
|
_jlong2YGNodeRef(nativePointer), static_cast<float>(value));
|
||||||
}
|
}
|
||||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
|
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
|
||||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
|
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
|
||||||
@@ -501,14 +571,14 @@ void jni_YGConfigFree(alias_ref<jobject>, jlong nativePointer) {
|
|||||||
YGConfigFree(config);
|
YGConfigFree(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGConfigSetExperimentalFeatureEnabled(alias_ref<jobject>,
|
void jni_YGConfigSetExperimentalFeatureEnabled(
|
||||||
|
alias_ref<jobject>,
|
||||||
jlong nativePointer,
|
jlong nativePointer,
|
||||||
jint feature,
|
jint feature,
|
||||||
jboolean enabled) {
|
jboolean enabled) {
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||||
YGConfigSetExperimentalFeatureEnabled(config,
|
YGConfigSetExperimentalFeatureEnabled(
|
||||||
static_cast<YGExperimentalFeature>(feature),
|
config, static_cast<YGExperimentalFeature>(feature), enabled);
|
||||||
enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||||
@@ -519,21 +589,24 @@ void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
|||||||
YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(config, enabled);
|
YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(config, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGConfigSetUseWebDefaults(alias_ref<jobject>,
|
void jni_YGConfigSetUseWebDefaults(
|
||||||
|
alias_ref<jobject>,
|
||||||
jlong nativePointer,
|
jlong nativePointer,
|
||||||
jboolean useWebDefaults) {
|
jboolean useWebDefaults) {
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||||
YGConfigSetUseWebDefaults(config, useWebDefaults);
|
YGConfigSetUseWebDefaults(config, useWebDefaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGConfigSetPointScaleFactor(alias_ref<jobject>,
|
void jni_YGConfigSetPointScaleFactor(
|
||||||
|
alias_ref<jobject>,
|
||||||
jlong nativePointer,
|
jlong nativePointer,
|
||||||
jfloat pixelsInPoint) {
|
jfloat pixelsInPoint) {
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||||
YGConfigSetPointScaleFactor(config, pixelsInPoint);
|
YGConfigSetPointScaleFactor(config, pixelsInPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGConfigSetUseLegacyStretchBehaviour(alias_ref<jobject>,
|
void jni_YGConfigSetUseLegacyStretchBehaviour(
|
||||||
|
alias_ref<jobject>,
|
||||||
jlong nativePointer,
|
jlong nativePointer,
|
||||||
jboolean useLegacyStretchBehaviour) {
|
jboolean useLegacyStretchBehaviour) {
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||||
@@ -592,7 +665,7 @@ jint jni_YGNodeGetInstanceCount(alias_ref<jclass> clazz) {
|
|||||||
|
|
||||||
#define YGMakeNativeMethod(name) makeNativeMethod(#name, name)
|
#define YGMakeNativeMethod(name) makeNativeMethod(#name, name)
|
||||||
|
|
||||||
jint JNI_OnLoad(JavaVM *vm, void *) {
|
jint JNI_OnLoad(JavaVM* vm, void*) {
|
||||||
return initialize(vm, [] {
|
return initialize(vm, [] {
|
||||||
registerNatives(
|
registerNatives(
|
||||||
"com/facebook/yoga/YogaNode",
|
"com/facebook/yoga/YogaNode",
|
||||||
|
Reference in New Issue
Block a user