Specify format folders more granularly
Summary: We don't want to format files in lib/ for example. For some reason java/jni and tests/CSSLayoutTestUtils folders were previously ignored. This change formats those folders as well. Reviewed By: lucasr Differential Revision: D3715203 fbshipit-source-id: 37bcbd36bcf8535cfca73d6a806ab0f1d097dde7
This commit is contained in:
committed by
Facebook Github Bot 6
parent
53ff4f59ca
commit
48e5304276
@@ -27,4 +27,8 @@ clang-format \
|
||||
SpaceAfterCStyleCast: true, \
|
||||
UseTab: Never, \
|
||||
}" "$@" \
|
||||
-i $(dirname $0)/**/*.{h,c,cpp}
|
||||
-i $(dirname $0)/CSSLayout/*.{h,c,cpp} \
|
||||
$(dirname $0)/tests/*.{h,c,cpp} \
|
||||
$(dirname $0)/tests/CSSLayoutTestUtils/*.{h,c,cpp} \
|
||||
$(dirname $0)/benchmarks/*.{h,c,cpp} \
|
||||
$(dirname $0)/java/jni/*.{h,c,cpp}
|
||||
|
@@ -12,32 +12,37 @@
|
||||
|
||||
#define JNI_VERSION JNI_VERSION_1_6
|
||||
|
||||
#define CSS_NODE_JNI(type, func) JNIEXPORT type JNICALL Java_com_facebook_csslayout_CSSNodeJNI_jni_1##func
|
||||
#define CSS_NODE_JNI(type, func) \
|
||||
JNIEXPORT type JNICALL Java_com_facebook_csslayout_CSSNodeJNI_jni_1##func
|
||||
|
||||
#define CSS_NODE_JNI_STYLE_PROP(javatype, type, name) \
|
||||
CSS_NODE_JNI(javatype, CSSNodeStyleGet##name(JNIEnv *env, jobject instance, jint nativePointer) { \
|
||||
return (javatype) CSSNodeStyleGet##name((CSSNodeRef) nativePointer); \
|
||||
}) \
|
||||
\
|
||||
CSS_NODE_JNI(void, CSSNodeStyleSet##name(JNIEnv *env, jobject instance, jint nativePointer, javatype value) { \
|
||||
CSSNodeStyleSet##name((CSSNodeRef) nativePointer, (type) value); \
|
||||
})
|
||||
#define CSS_NODE_JNI_STYLE_PROP(javatype, type, name) \
|
||||
CSS_NODE_JNI(javatype, \
|
||||
CSSNodeStyleGet##name(JNIEnv *env, jobject instance, jint nativePointer) { \
|
||||
return (javatype) CSSNodeStyleGet##name((CSSNodeRef) nativePointer); \
|
||||
}) \
|
||||
\
|
||||
CSS_NODE_JNI( \
|
||||
void, \
|
||||
CSSNodeStyleSet##name(JNIEnv *env, jobject instance, jint nativePointer, javatype value) { \
|
||||
CSSNodeStyleSet##name((CSSNodeRef) nativePointer, (type) value); \
|
||||
})
|
||||
|
||||
#define CSS_NODE_JNI_LAYOUT_PROP(javatype, type, name) \
|
||||
CSS_NODE_JNI(javatype, CSSNodeLayoutGet##name(JNIEnv *env, jobject instance, jint nativePointer) { \
|
||||
return (javatype) CSSNodeLayoutGet##name((CSSNodeRef) nativePointer); \
|
||||
})
|
||||
#define CSS_NODE_JNI_LAYOUT_PROP(javatype, type, name) \
|
||||
CSS_NODE_JNI(javatype, \
|
||||
CSSNodeLayoutGet##name(JNIEnv *env, jobject instance, jint nativePointer) { \
|
||||
return (javatype) CSSNodeLayoutGet##name((CSSNodeRef) nativePointer); \
|
||||
})
|
||||
|
||||
static JavaVM* jvm = NULL;
|
||||
static JavaVM *jvm = NULL;
|
||||
|
||||
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
jvm = vm;
|
||||
return JNI_VERSION;
|
||||
}
|
||||
|
||||
static void _jniPrint(void *context) {
|
||||
JNIEnv *env = NULL;
|
||||
CSS_ASSERT((*jvm)->GetEnv(jvm, (void**) &env, JNI_VERSION) == JNI_OK, "Must have valid jni env");
|
||||
CSS_ASSERT((*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION) == JNI_OK, "Must have valid jni env");
|
||||
|
||||
static jclass cssNodeClass = NULL;
|
||||
if (!cssNodeClass) {
|
||||
@@ -51,16 +56,20 @@ static void _jniPrint(void *context) {
|
||||
CSS_ASSERT(toStringID, "Could not find toString method");
|
||||
}
|
||||
|
||||
jstring javaString = (jstring) (*env)->CallObjectMethod(env, context, toStringID);
|
||||
jstring javaString = (jstring)(*env)->CallObjectMethod(env, context, toStringID);
|
||||
const char *nativeString = (*env)->GetStringUTFChars(env, javaString, 0);
|
||||
printf("%s\n", nativeString);
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, javaString, nativeString);
|
||||
}
|
||||
|
||||
static CSSSize _jniMeasureFunc(void *context, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) {
|
||||
static CSSSize _jniMeasureFunc(void *context,
|
||||
float width,
|
||||
CSSMeasureMode widthMode,
|
||||
float height,
|
||||
CSSMeasureMode heightMode) {
|
||||
JNIEnv *env = NULL;
|
||||
CSS_ASSERT((*jvm)->GetEnv(jvm, (void**) &env, JNI_VERSION) == JNI_OK, "Must have valid jni env");
|
||||
CSS_ASSERT((*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION) == JNI_OK, "Must have valid jni env");
|
||||
|
||||
static jclass cssNodeClass = NULL;
|
||||
if (!cssNodeClass) {
|
||||
@@ -74,10 +83,10 @@ static CSSSize _jniMeasureFunc(void *context, float width, CSSMeasureMode widthM
|
||||
CSS_ASSERT(measureID, "Could not find measure method");
|
||||
}
|
||||
|
||||
jlong measureResult = (*env)->CallLongMethod(env, context, measureID, width, widthMode, height, heightMode);
|
||||
jlong measureResult =
|
||||
(*env)->CallLongMethod(env, context, measureID, width, widthMode, height, heightMode);
|
||||
CSSSize size = {
|
||||
.width = (int32_t) (measureResult >> 32),
|
||||
.height = (int32_t) measureResult,
|
||||
.width = (int32_t)(measureResult >> 32), .height = (int32_t) measureResult,
|
||||
};
|
||||
|
||||
return size;
|
||||
@@ -95,16 +104,25 @@ CSS_NODE_JNI(void, CSSNodeFree(JNIEnv *env, jobject thiz, jint nativePointer) {
|
||||
CSSNodeFree((CSSNodeRef) nativePointer);
|
||||
})
|
||||
|
||||
CSS_NODE_JNI(void, CSSNodeInsertChild(JNIEnv *env, jobject thiz, jint nativePointer, jint childPointer, jint index) {
|
||||
CSSNodeInsertChild((CSSNodeRef) nativePointer, (CSSNodeRef) childPointer, index);
|
||||
})
|
||||
CSS_NODE_JNI(void,
|
||||
CSSNodeInsertChild(JNIEnv *env,
|
||||
jobject thiz,
|
||||
jint nativePointer,
|
||||
jint childPointer,
|
||||
jint index) {
|
||||
CSSNodeInsertChild((CSSNodeRef) nativePointer, (CSSNodeRef) childPointer, index);
|
||||
})
|
||||
|
||||
CSS_NODE_JNI(void, CSSNodeRemoveChild(JNIEnv *env, jobject thiz, jint nativePointer, jint childPointer) {
|
||||
CSSNodeRemoveChild((CSSNodeRef) nativePointer, (CSSNodeRef) childPointer);
|
||||
})
|
||||
CSS_NODE_JNI(void,
|
||||
CSSNodeRemoveChild(JNIEnv *env, jobject thiz, jint nativePointer, jint childPointer) {
|
||||
CSSNodeRemoveChild((CSSNodeRef) nativePointer, (CSSNodeRef) childPointer);
|
||||
})
|
||||
|
||||
CSS_NODE_JNI(void, CSSNodeCalculateLayout(JNIEnv *env, jobject thiz, jint nativePointer) {
|
||||
CSSNodeCalculateLayout((CSSNodeRef) nativePointer, NAN, NAN, CSSNodeStyleGetDirection(((CSSNodeRef) nativePointer)));
|
||||
CSSNodeCalculateLayout((CSSNodeRef) nativePointer,
|
||||
NAN,
|
||||
NAN,
|
||||
CSSNodeStyleGetDirection(((CSSNodeRef) nativePointer)));
|
||||
})
|
||||
|
||||
CSS_NODE_JNI(void, CSSNodeMarkDirty(JNIEnv *env, jobject thiz, jint nativePointer) {
|
||||
@@ -115,13 +133,20 @@ CSS_NODE_JNI(jboolean, CSSNodeIsDirty(JNIEnv *env, jobject instance, jint native
|
||||
return (jboolean) CSSNodeIsDirty((CSSNodeRef) nativePointer);
|
||||
})
|
||||
|
||||
CSS_NODE_JNI(void, CSSNodeSetHasMeasureFunc(JNIEnv *env, jobject thiz, jint nativePointer, jboolean hasMeasureFunc) {
|
||||
CSSNodeSetMeasureFunc((CSSNodeRef) nativePointer, hasMeasureFunc ? _jniMeasureFunc : NULL);
|
||||
})
|
||||
CSS_NODE_JNI(void,
|
||||
CSSNodeSetHasMeasureFunc(JNIEnv *env,
|
||||
jobject thiz,
|
||||
jint nativePointer,
|
||||
jboolean hasMeasureFunc) {
|
||||
CSSNodeSetMeasureFunc((CSSNodeRef) nativePointer,
|
||||
hasMeasureFunc ? _jniMeasureFunc : NULL);
|
||||
})
|
||||
|
||||
CSS_NODE_JNI(void, CSSNodeSetIsTextNode(JNIEnv *env, jobject instance, jint nativePointer, jboolean isTextNode) {
|
||||
CSSNodeSetIsTextnode((CSSNodeRef) nativePointer, isTextNode);
|
||||
})
|
||||
CSS_NODE_JNI(
|
||||
void,
|
||||
CSSNodeSetIsTextNode(JNIEnv *env, jobject instance, jint nativePointer, jboolean isTextNode) {
|
||||
CSSNodeSetIsTextnode((CSSNodeRef) nativePointer, isTextNode);
|
||||
})
|
||||
|
||||
CSS_NODE_JNI(jboolean, CSSNodeGetIsTextNode(JNIEnv *env, jobject instance, jint nativePointer) {
|
||||
return (jboolean) CSSNodeGetIsTextnode((CSSNodeRef) nativePointer);
|
||||
|
@@ -46,8 +46,12 @@ static bool are_layout_equal(CSSNode *a, CSSNode *b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CSSSize measure(void *context, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) {
|
||||
const char *text = (const char *)context;
|
||||
CSSSize measure(void *context,
|
||||
float width,
|
||||
CSSMeasureMode widthMode,
|
||||
float height,
|
||||
CSSMeasureMode heightMode) {
|
||||
const char *text = (const char *) context;
|
||||
CSSSize result;
|
||||
if (strcmp(text, SMALL_TEXT) == 0) {
|
||||
if (widthMode == CSSMeasureModeUndefined) {
|
||||
@@ -105,7 +109,7 @@ CSSSize measure(void *context, float width, CSSMeasureMode widthMode, float heig
|
||||
}
|
||||
|
||||
bool test(CSSNode *style, CSSNode *expected_layout) {
|
||||
CSSNodeCalculateLayout(style, CSSUndefined, CSSUndefined, (CSSDirection)-1);
|
||||
CSSNodeCalculateLayout(style, CSSUndefined, CSSUndefined, (CSSDirection) -1);
|
||||
return are_layout_equal(style, expected_layout);
|
||||
}
|
||||
|
||||
|
@@ -10,16 +10,16 @@
|
||||
#ifndef __CSS_LAYOUT_TEST_UTILS_H
|
||||
#define __CSS_LAYOUT_TEST_UTILS_H
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#include <CSSLayout/CSSMacros.h>
|
||||
#include <CSSLayout/CSSLayout-internal.h>
|
||||
#include <CSSLayout/CSSMacros.h>
|
||||
#include <CSSLayout/CSSNodeList.h>
|
||||
|
||||
#define SMALL_WIDTH 35
|
||||
@@ -34,7 +34,11 @@
|
||||
CSS_EXTERN_C_BEGIN
|
||||
|
||||
bool test(CSSNode *style, CSSNode *expected_layout);
|
||||
CSSSize measure(void *context, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode);
|
||||
CSSSize measure(void *context,
|
||||
float width,
|
||||
CSSMeasureMode widthMode,
|
||||
float height,
|
||||
CSSMeasureMode heightMode);
|
||||
void init_css_node_children(CSSNode *node, int childCount);
|
||||
CSSNode *new_test_css_node(void);
|
||||
|
||||
|
Reference in New Issue
Block a user