Enable -Wextra in C++ builds #1294

Closed
NickGerleman wants to merge 2 commits from export-D45772846 into main
16 changed files with 212 additions and 189 deletions

View File

@@ -30,6 +30,7 @@ Pod::Spec.new do |spec|
'-fexceptions', '-fexceptions',
'-Wall', '-Wall',
'-Werror', '-Werror',
'-Wextra',
'-std=c++14', '-std=c++14',
'-fPIC' '-fPIC'
] ]

View File

@@ -17,6 +17,8 @@
#define YGBENCHMARKS(BLOCK) \ #define YGBENCHMARKS(BLOCK) \
int main(int argc, char const* argv[]) { \ int main(int argc, char const* argv[]) { \
(void) argc; \
(void) argv; \
clock_t __start; \ clock_t __start; \
clock_t __endTimes[NUM_REPETITIONS]; \ clock_t __endTimes[NUM_REPETITIONS]; \
{ BLOCK } \ { BLOCK } \
@@ -78,9 +80,10 @@ static YGSize _measure(
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, float height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
(void) node;
return (YGSize){ return (YGSize){
.width = widthMode == YGMeasureModeUndefined ? 10 : width, .width = widthMode == YGMeasureModeUndefined ? 10 : width,
.height = heightMode == YGMeasureModeUndefined ? 10 : width, .height = heightMode == YGMeasureModeUndefined ? 10 : height,
}; };
} }

View File

@@ -33,6 +33,7 @@ add_compile_options(
-fexceptions -fexceptions
# Enable warnings and warnings as errors # Enable warnings and warnings as errors
-Wall -Wall
-Wextra
-Werror -Werror
# Disable RTTI # Disable RTTI
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti> $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>

View File

@@ -35,11 +35,14 @@ 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 jlong jni_YGConfigNewJNI(JNIEnv* env, jobject obj) { static jlong jni_YGConfigNewJNI(JNIEnv* /*env*/, jobject /*obj*/) {
return reinterpret_cast<jlong>(YGConfigNew()); return reinterpret_cast<jlong>(YGConfigNew());
} }
static void jni_YGConfigFreeJNI(JNIEnv* env, jobject obj, jlong nativePointer) { static void jni_YGConfigFreeJNI(
JNIEnv* /*env*/,
jobject /*obj*/,
jlong nativePointer) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
// unique_ptr will destruct the underlying global_ref, if present. // unique_ptr will destruct the underlying global_ref, if present.
auto context = std::unique_ptr<ScopedGlobalRef<jobject>>{ auto context = std::unique_ptr<ScopedGlobalRef<jobject>>{
@@ -48,8 +51,8 @@ static void jni_YGConfigFreeJNI(JNIEnv* env, jobject obj, jlong nativePointer) {
} }
static void jni_YGConfigSetExperimentalFeatureEnabledJNI( static void jni_YGConfigSetExperimentalFeatureEnabledJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jint feature, jint feature,
jboolean enabled) { jboolean enabled) {
@@ -59,8 +62,8 @@ static void jni_YGConfigSetExperimentalFeatureEnabledJNI(
} }
static void jni_YGConfigSetUseWebDefaultsJNI( static void jni_YGConfigSetUseWebDefaultsJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jboolean useWebDefaults) { jboolean useWebDefaults) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
@@ -68,8 +71,8 @@ static void jni_YGConfigSetUseWebDefaultsJNI(
} }
static void jni_YGConfigSetPrintTreeFlagJNI( static void jni_YGConfigSetPrintTreeFlagJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jboolean enable) { jboolean enable) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
@@ -77,8 +80,8 @@ static void jni_YGConfigSetPrintTreeFlagJNI(
} }
static void jni_YGConfigSetPointScaleFactorJNI( static void jni_YGConfigSetPointScaleFactorJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jfloat pixelsInPoint) { jfloat pixelsInPoint) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
@@ -86,8 +89,8 @@ static void jni_YGConfigSetPointScaleFactorJNI(
} }
static void jni_YGConfigSetUseLegacyStretchBehaviourJNI( static void jni_YGConfigSetUseLegacyStretchBehaviourJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jboolean useLegacyStretchBehaviour) { jboolean useLegacyStretchBehaviour) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
@@ -98,8 +101,8 @@ static void jni_YGConfigSetUseLegacyStretchBehaviourJNI(
} }
static void jni_YGConfigSetErrataJNI( static void jni_YGConfigSetErrataJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jint errata) { jint errata) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
@@ -107,22 +110,22 @@ static void jni_YGConfigSetErrataJNI(
} }
static jint jni_YGConfigGetErrataJNI( static jint jni_YGConfigGetErrataJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer) { jlong nativePointer) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
return static_cast<jint>(YGConfigGetErrata(config)); return static_cast<jint>(YGConfigGetErrata(config));
} }
static jlong jni_YGNodeNewJNI(JNIEnv* env, jobject obj) { static jlong jni_YGNodeNewJNI(JNIEnv* /*env*/, jobject /*obj*/) {
const YGNodeRef node = YGNodeNew(); const YGNodeRef node = YGNodeNew();
YGNodeSetContext(node, YGNodeContext{}.asVoidPtr); YGNodeSetContext(node, YGNodeContext{}.asVoidPtr);
return reinterpret_cast<jlong>(node); return reinterpret_cast<jlong>(node);
} }
static jlong jni_YGNodeNewWithConfigJNI( static jlong jni_YGNodeNewWithConfigJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong configPointer) { jlong configPointer) {
const YGNodeRef node = YGNodeNewWithConfig(_jlong2YGConfigRef(configPointer)); const YGNodeRef node = YGNodeNewWithConfig(_jlong2YGConfigRef(configPointer));
YGNodeSetContext(node, YGNodeContext{}.asVoidPtr); YGNodeSetContext(node, YGNodeContext{}.asVoidPtr);
@@ -131,9 +134,9 @@ static jlong jni_YGNodeNewWithConfigJNI(
static int YGJNILogFunc( static int YGJNILogFunc(
const YGConfigRef config, const YGConfigRef config,
const YGNodeRef node, const YGNodeRef /*node*/,
YGLogLevel level, YGLogLevel level,
void* layoutContext, void* /*layoutContext*/,
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);
@@ -175,7 +178,7 @@ static int YGJNILogFunc(
static void jni_YGConfigSetLoggerJNI( static void jni_YGConfigSetLoggerJNI(
JNIEnv* env, JNIEnv* env,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jobject logger) { jobject logger) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
@@ -200,8 +203,8 @@ static void jni_YGConfigSetLoggerJNI(
} }
static void jni_YGNodeDeallocateJNI( static void jni_YGNodeDeallocateJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer) { jlong nativePointer) {
if (nativePointer == 0) { if (nativePointer == 0) {
return; return;
@@ -210,7 +213,10 @@ static void jni_YGNodeDeallocateJNI(
YGNodeFree(node); YGNodeFree(node);
} }
static void jni_YGNodeResetJNI(JNIEnv* env, jobject obj, jlong nativePointer) { static void jni_YGNodeResetJNI(
JNIEnv* /*env*/,
jobject /*obj*/,
jlong nativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer); const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
void* context = YGNodeGetContext(node); void* context = YGNodeGetContext(node);
YGNodeReset(node); YGNodeReset(node);
@@ -218,8 +224,8 @@ static void jni_YGNodeResetJNI(JNIEnv* env, jobject obj, jlong nativePointer) {
} }
static void jni_YGNodeInsertChildJNI( static void jni_YGNodeInsertChildJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jlong childPointer, jlong childPointer,
jint index) { jint index) {
@@ -228,8 +234,8 @@ static void jni_YGNodeInsertChildJNI(
} }
static void jni_YGNodeSwapChildJNI( static void jni_YGNodeSwapChildJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jlong childPointer, jlong childPointer,
jint index) { jint index) {
@@ -238,8 +244,8 @@ static void jni_YGNodeSwapChildJNI(
} }
static void jni_YGNodeSetIsReferenceBaselineJNI( static void jni_YGNodeSetIsReferenceBaselineJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jboolean isReferenceBaseline) { jboolean isReferenceBaseline) {
YGNodeSetIsReferenceBaseline( YGNodeSetIsReferenceBaseline(
@@ -247,23 +253,23 @@ static void jni_YGNodeSetIsReferenceBaselineJNI(
} }
static jboolean jni_YGNodeIsReferenceBaselineJNI( static jboolean jni_YGNodeIsReferenceBaselineJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer) { jlong nativePointer) {
return YGNodeIsReferenceBaseline(_jlong2YGNodeRef(nativePointer)); return YGNodeIsReferenceBaseline(_jlong2YGNodeRef(nativePointer));
} }
static void jni_YGNodeRemoveAllChildrenJNI( static void jni_YGNodeRemoveAllChildrenJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer) { jlong nativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer); const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
YGNodeRemoveAllChildren(node); YGNodeRemoveAllChildren(node);
} }
static void jni_YGNodeRemoveChildJNI( static void jni_YGNodeRemoveChildJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jlong childPointer) { jlong childPointer) {
YGNodeRemoveChild( YGNodeRemoveChild(
@@ -389,102 +395,102 @@ static void jni_YGNodeCalculateLayoutJNI(
} }
static void jni_YGNodeMarkDirtyJNI( static void jni_YGNodeMarkDirtyJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer) { jlong nativePointer) {
YGNodeMarkDirty(_jlong2YGNodeRef(nativePointer)); YGNodeMarkDirty(_jlong2YGNodeRef(nativePointer));
} }
static void jni_YGNodeMarkDirtyAndPropagateToDescendantsJNI( static void jni_YGNodeMarkDirtyAndPropagateToDescendantsJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer) { jlong nativePointer) {
YGNodeMarkDirtyAndPropagateToDescendants(_jlong2YGNodeRef(nativePointer)); YGNodeMarkDirtyAndPropagateToDescendants(_jlong2YGNodeRef(nativePointer));
} }
static jboolean jni_YGNodeIsDirtyJNI( static jboolean jni_YGNodeIsDirtyJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer) { jlong nativePointer) {
return (jboolean) YGNodeIsDirty(_jlong2YGNodeRef(nativePointer)); return (jboolean) YGNodeIsDirty(_jlong2YGNodeRef(nativePointer));
} }
static void jni_YGNodeCopyStyleJNI( static void jni_YGNodeCopyStyleJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong dstNativePointer, jlong dstNativePointer,
jlong srcNativePointer) { jlong srcNativePointer) {
YGNodeCopyStyle( YGNodeCopyStyle(
_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer)); _jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer));
} }
#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \ #define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
static javatype jni_YGNodeStyleGet##name##JNI( \ static javatype jni_YGNodeStyleGet##name##JNI( \
JNIEnv* env, jobject obj, jlong nativePointer) { \ JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \ return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
} \
\
static void jni_YGNodeStyleSet##name##JNI( \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, javatype value) { \
YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
}
#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
static jlong jni_YGNodeStyleGet##name##JNI( \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
return YogaValue::asJavaLong( \
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
} \ } \
\ \
static void jni_YGNodeStyleSet##name##JNI( \ static void jni_YGNodeStyleSet##name##JNI( \
JNIEnv* env, jobject obj, jlong nativePointer, javatype value) { \ JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jfloat value) { \
YGNodeStyleSet##name( \ YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \ _jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
} } \
\
#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \ static void jni_YGNodeStyleSet##name##PercentJNI( \
static jlong jni_YGNodeStyleGet##name##JNI( \ JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jfloat value) { \
JNIEnv* env, jobject obj, jlong nativePointer) { \ YGNodeStyleSet##name##Percent( \
return YogaValue::asJavaLong( \ _jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
} \
\
static void jni_YGNodeStyleSet##name##JNI( \
JNIEnv* env, jobject obj, jlong nativePointer, jfloat value) { \
YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
} \
\
static void jni_YGNodeStyleSet##name##PercentJNI( \
JNIEnv* env, jobject obj, 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) \
static void jni_YGNodeStyleSet##name##AutoJNI( \ static void jni_YGNodeStyleSet##name##AutoJNI( \
JNIEnv* env, jobject obj, jlong nativePointer) { \ JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \ YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
} }
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \ #define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
static jlong jni_YGNodeStyleGet##name##JNI( \ static jlong jni_YGNodeStyleGet##name##JNI( \
JNIEnv* env, jobject obj, jlong nativePointer, jint edge) { \ JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jint edge) { \
return YogaValue::asJavaLong(YGNodeStyleGet##name( \ return YogaValue::asJavaLong(YGNodeStyleGet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge))); \ _jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge))); \
} \ } \
\ \
static void jni_YGNodeStyleSet##name##JNI( \ static void jni_YGNodeStyleSet##name##JNI( \
JNIEnv* env, \ JNIEnv* /*env*/, \
jobject obj, \ jobject /*obj*/, \
jlong nativePointer, \ jlong nativePointer, \
jint edge, \ jint edge, \
jfloat value) { \ jfloat value) { \
YGNodeStyleSet##name( \ YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), \ _jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \ static_cast<YGEdge>(edge), \
static_cast<float>(value)); \ static_cast<float>(value)); \
} \ } \
\ \
static void jni_YGNodeStyleSet##name##PercentJNI( \ static void jni_YGNodeStyleSet##name##PercentJNI( \
JNIEnv* env, \ JNIEnv* /*env*/, \
jobject obj, \ jobject /*obj*/, \
jlong nativePointer, \ jlong nativePointer, \
jint edge, \ jint edge, \
jfloat value) { \ jfloat value) { \
YGNodeStyleSet##name##Percent( \ YGNodeStyleSet##name##Percent( \
_jlong2YGNodeRef(nativePointer), \ _jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \ static_cast<YGEdge>(edge), \
static_cast<float>(value)); \ static_cast<float>(value)); \
} }
YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction); YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
@@ -512,8 +518,8 @@ YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight);
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(Position); YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(Position);
static jlong jni_YGNodeStyleGetMarginJNI( static jlong jni_YGNodeStyleGetMarginJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jint edge) { jint edge) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
@@ -525,8 +531,8 @@ static jlong jni_YGNodeStyleGetMarginJNI(
} }
static void jni_YGNodeStyleSetMarginJNI( static void jni_YGNodeStyleSetMarginJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jint edge, jint edge,
jfloat margin) { jfloat margin) {
@@ -537,8 +543,8 @@ static void jni_YGNodeStyleSetMarginJNI(
} }
static void jni_YGNodeStyleSetMarginPercentJNI( static void jni_YGNodeStyleSetMarginPercentJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jint edge, jint edge,
jfloat percent) { jfloat percent) {
@@ -549,8 +555,8 @@ static void jni_YGNodeStyleSetMarginPercentJNI(
} }
static void jni_YGNodeStyleSetMarginAutoJNI( static void jni_YGNodeStyleSetMarginAutoJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jint edge) { jint edge) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
@@ -559,8 +565,8 @@ static void jni_YGNodeStyleSetMarginAutoJNI(
} }
static jlong jni_YGNodeStyleGetPaddingJNI( static jlong jni_YGNodeStyleGetPaddingJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jint edge) { jint edge) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
@@ -572,8 +578,8 @@ static jlong jni_YGNodeStyleGetPaddingJNI(
} }
static void jni_YGNodeStyleSetPaddingJNI( static void jni_YGNodeStyleSetPaddingJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jint edge, jint edge,
jfloat padding) { jfloat padding) {
@@ -584,8 +590,8 @@ static void jni_YGNodeStyleSetPaddingJNI(
} }
static void jni_YGNodeStyleSetPaddingPercentJNI( static void jni_YGNodeStyleSetPaddingPercentJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jint edge, jint edge,
jfloat percent) { jfloat percent) {
@@ -596,8 +602,8 @@ static void jni_YGNodeStyleSetPaddingPercentJNI(
} }
static jfloat jni_YGNodeStyleGetBorderJNI( static jfloat jni_YGNodeStyleGetBorderJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jint edge) { jint edge) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
@@ -608,8 +614,8 @@ static jfloat jni_YGNodeStyleGetBorderJNI(
} }
static void jni_YGNodeStyleSetBorderJNI( static void jni_YGNodeStyleSetBorderJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jint edge, jint edge,
jfloat border) { jfloat border) {
@@ -671,8 +677,8 @@ static YGSize YGJNIMeasureFunc(
} }
static void jni_YGNodeSetHasMeasureFuncJNI( static void jni_YGNodeSetHasMeasureFuncJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jboolean hasMeasureFunc) { jboolean hasMeasureFunc) {
_jlong2YGNodeRef(nativePointer) _jlong2YGNodeRef(nativePointer)
@@ -698,24 +704,32 @@ static float YGJNIBaselineFunc(
} }
static void jni_YGNodeSetHasBaselineFuncJNI( static void jni_YGNodeSetHasBaselineFuncJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jboolean hasBaselineFunc) { jboolean hasBaselineFunc) {
_jlong2YGNodeRef(nativePointer) _jlong2YGNodeRef(nativePointer)
->setBaselineFunc(hasBaselineFunc ? YGJNIBaselineFunc : nullptr); ->setBaselineFunc(hasBaselineFunc ? YGJNIBaselineFunc : nullptr);
} }
static void jni_YGNodePrintJNI(JNIEnv* env, jobject obj, jlong nativePointer) { static void jni_YGNodePrintJNI(
JNIEnv* /*env*/,
jobject /*obj*/,
jlong nativePointer) {
#ifdef DEBUG #ifdef DEBUG
const YGNodeRef node = _jlong2YGNodeRef(nativePointer); const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
YGNodePrint( YGNodePrint(
node, node,
(YGPrintOptions) (YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren)); (YGPrintOptions) (YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
#else
(void) nativePointer;
#endif #endif
} }
static jlong jni_YGNodeCloneJNI(JNIEnv* env, jobject obj, jlong nativePointer) { static jlong jni_YGNodeCloneJNI(
JNIEnv* /*env*/,
jobject /*obj*/,
jlong nativePointer) {
auto node = _jlong2YGNodeRef(nativePointer); auto node = _jlong2YGNodeRef(nativePointer);
const YGNodeRef clonedYogaNode = YGNodeClone(node); const YGNodeRef clonedYogaNode = YGNodeClone(node);
YGNodeSetContext(clonedYogaNode, YGNodeGetContext(node)); YGNodeSetContext(clonedYogaNode, YGNodeGetContext(node));
@@ -724,8 +738,8 @@ static jlong jni_YGNodeCloneJNI(JNIEnv* env, jobject obj, jlong nativePointer) {
} }
static jfloat jni_YGNodeStyleGetGapJNI( static jfloat jni_YGNodeStyleGetGapJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jint gutter) { jint gutter) {
return (jfloat) YGNodeStyleGetGap( return (jfloat) YGNodeStyleGetGap(
@@ -733,8 +747,8 @@ static jfloat jni_YGNodeStyleGetGapJNI(
} }
static void jni_YGNodeStyleSetGapJNI( static void jni_YGNodeStyleSetGapJNI(
JNIEnv* env, JNIEnv* /*env*/,
jobject obj, jobject /*obj*/,
jlong nativePointer, jlong nativePointer,
jint gutter, jint gutter,
jfloat gapLength) { jfloat gapLength) {

View File

@@ -56,6 +56,7 @@ JNIEXPORT JNIEnv* getCurrentEnv() {
} }
void logErrorMessageAndDie(const char* message) { void logErrorMessageAndDie(const char* message) {
(void) message;
VANILLAJNI_LOG_ERROR( VANILLAJNI_LOG_ERROR(
"VanillaJni", "VanillaJni",
"Aborting due to error detected in native code: %s", "Aborting due to error detected in native code: %s",

View File

@@ -290,7 +290,7 @@ EventArgs createArgs(const YGNode& node, const Event::Data data) {
using Data = Event::TypedData<E>; using Data = Event::TypedData<E>;
auto deleteData = [](void* x) { delete static_cast<Data*>(x); }; auto deleteData = [](void* x) { delete static_cast<Data*>(x); };
return {&node, E, {new Data{(data.get<E>())}, deleteData}}; return {&node, E, {new Data{(data.get<E>())}, deleteData}, nullptr};
} }
template <Event::Type E> template <Event::Type E>

View File

@@ -10,27 +10,27 @@
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
static float _baselineFunc( static float _baselineFunc(
YGNodeRef node, YGNodeRef /*node*/,
const float width, const float /*width*/,
const float height) { const float height) {
return height / 2; return height / 2;
} }
static YGSize _measure1( static YGSize _measure1(
YGNodeRef node, YGNodeRef /*node*/,
float width, float /*width*/,
YGMeasureMode widthMode, YGMeasureMode /*widthMode*/,
float height, float /*height*/,
YGMeasureMode heightMode) { YGMeasureMode /*heightMode*/) {
return YGSize{42, 50}; return YGSize{42, 50};
} }
static YGSize _measure2( static YGSize _measure2(
YGNodeRef node, YGNodeRef /*node*/,
float width, float /*width*/,
YGMeasureMode widthMode, YGMeasureMode /*widthMode*/,
float height, float /*height*/,
YGMeasureMode heightMode) { YGMeasureMode /*heightMode*/) {
return YGSize{279, 126}; return YGSize{279, 126};
} }

View File

@@ -10,7 +10,7 @@
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
static YGSize _measure( static YGSize _measure(
YGNodeRef node, YGNodeRef /*node*/,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, float height,

View File

@@ -9,7 +9,10 @@
#include <yoga/YGNode.h> #include <yoga/YGNode.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
static float _baseline(YGNodeRef node, const float width, const float height) { static float _baseline(
YGNodeRef node,
const float /*width*/,
const float /*height*/) {
float* baseline = (float*) node->getContext(); float* baseline = (float*) node->getContext();
return *baseline; return *baseline;
} }

View File

@@ -14,9 +14,9 @@
namespace { namespace {
char writeBuffer[4096]; char writeBuffer[4096];
int _unmanagedLogger( int _unmanagedLogger(
const YGConfigRef config, 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) {
return vsnprintf( return vsnprintf(

View File

@@ -46,10 +46,10 @@ static YGSize _measureMin(
static YGSize _measure_84_49( static YGSize _measure_84_49(
YGNodeRef node, YGNodeRef node,
float width, float /*width*/,
YGMeasureMode widthMode, YGMeasureMode /*widthMode*/,
float height, float /*height*/,
YGMeasureMode heightMode) { YGMeasureMode /*heightMode*/) {
int* measureCount = (int*) node->getContext(); int* measureCount = (int*) node->getContext();
if (measureCount) { if (measureCount) {
(*measureCount)++; (*measureCount)++;

View File

@@ -11,10 +11,10 @@
static YGSize _measure( static YGSize _measure(
YGNodeRef node, YGNodeRef node,
float width, float /*width*/,
YGMeasureMode widthMode, YGMeasureMode /*widthMode*/,
float height, float /*height*/,
YGMeasureMode heightMode) { YGMeasureMode /*heightMode*/) {
int* measureCount = (int*) node->getContext(); int* measureCount = (int*) node->getContext();
if (measureCount) { if (measureCount) {
(*measureCount)++; (*measureCount)++;
@@ -24,11 +24,11 @@ static YGSize _measure(
} }
static YGSize _simulate_wrapping_text( static YGSize _simulate_wrapping_text(
YGNodeRef node, YGNodeRef /*node*/,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, float /*height*/,
YGMeasureMode heightMode) { YGMeasureMode /*heightMode*/) {
if (widthMode == YGMeasureModeUndefined || width >= 68) { if (widthMode == YGMeasureModeUndefined || width >= 68) {
return YGSize{68, 16}; return YGSize{68, 16};
} }
@@ -37,11 +37,11 @@ static YGSize _simulate_wrapping_text(
} }
static YGSize _measure_assert_negative( static YGSize _measure_assert_negative(
YGNodeRef node, YGNodeRef /*node*/,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode /*widthMode*/,
float height, float height,
YGMeasureMode heightMode) { YGMeasureMode /*heightMode*/) {
EXPECT_GE(width, 0); EXPECT_GE(width, 0);
EXPECT_GE(height, 0); EXPECT_GE(height, 0);
@@ -641,21 +641,21 @@ TEST(YogaTest, cant_call_negative_measure_horizontal) {
} }
static YGSize _measure_90_10( static YGSize _measure_90_10(
YGNodeRef node, YGNodeRef /*node*/,
float width, float /*width*/,
YGMeasureMode widthMode, YGMeasureMode /*widthMode*/,
float height, float /*height*/,
YGMeasureMode heightMode) { YGMeasureMode /*heightMode*/) {
return YGSize{90, 10}; return YGSize{90, 10};
} }
static YGSize _measure_100_100( static YGSize _measure_100_100(
YGNodeRef node, YGNodeRef /*node*/,
float width, float /*width*/,
YGMeasureMode widthMode, YGMeasureMode /*widthMode*/,
float height, float /*height*/,
YGMeasureMode heightMode) { YGMeasureMode /*heightMode*/) {
return YGSize{100, 100}; return YGSize{100, 100};
} }

View File

@@ -43,11 +43,11 @@ TEST(YogaTest, rounding_value) {
} }
static YGSize measureText( static YGSize measureText(
YGNodeRef node, YGNodeRef /*node*/,
float width, float /*width*/,
YGMeasureMode widthMode, YGMeasureMode /*widthMode*/,
float height, float /*height*/,
YGMeasureMode heightMode) { YGMeasureMode /*heightMode*/) {
return YGSize{10, 10}; return YGSize{10, 10};
} }

View File

@@ -10,11 +10,11 @@
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
static YGSize _measureFloor( static YGSize _measureFloor(
YGNodeRef node, YGNodeRef /*node*/,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode /*widthMode*/,
float height, float height,
YGMeasureMode heightMode) { YGMeasureMode /*heightMode*/) {
return YGSize{ return YGSize{
width = 10.2f, width = 10.2f,
height = 10.2f, height = 10.2f,
@@ -22,11 +22,11 @@ static YGSize _measureFloor(
} }
static YGSize _measureCeil( static YGSize _measureCeil(
YGNodeRef node, YGNodeRef /*node*/,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode /*widthMode*/,
float height, float height,
YGMeasureMode heightMode) { YGMeasureMode /*heightMode*/) {
return YGSize{ return YGSize{
width = 10.5f, width = 10.5f,
height = 10.5f, height = 10.5f,
@@ -34,11 +34,11 @@ static YGSize _measureCeil(
} }
static YGSize _measureFractial( static YGSize _measureFractial(
YGNodeRef node, YGNodeRef /*node*/,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode /*widthMode*/,
float height, float height,
YGMeasureMode heightMode) { YGMeasureMode /*heightMode*/) {
return YGSize{ return YGSize{
width = 0.5f, width = 0.5f,
height = 0.5f, height = 0.5f,

View File

@@ -19,9 +19,9 @@ int nodeInstanceCount = 0;
namespace { namespace {
void yogaEventSubscriber( void yogaEventSubscriber(
const YGNode& node, const YGNode& /*node*/,
Event::Type eventType, Event::Type eventType,
const Event::Data& eventData) { const Event::Data& /*eventData*/) {
switch (eventType) { switch (eventType) {
case Event::NodeAllocation: case Event::NodeAllocation:

View File

@@ -42,8 +42,8 @@ static int YGDefaultLog(
#ifdef ANDROID #ifdef ANDROID
#include <android/log.h> #include <android/log.h>
static int YGAndroidLog( static int YGAndroidLog(
const YGConfigRef config, 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) {