diff --git a/BUCK b/BUCK index 6073721a..cddedfce 100644 --- a/BUCK +++ b/BUCK @@ -21,6 +21,7 @@ GMOCK_OVERRIDE_FLAGS = [ ] COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c11'] +JNI_COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c++11'] TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ['-std=c++11'] cxx_library( @@ -38,12 +39,12 @@ cxx_library( cxx_library( name = 'CSSLayout_jni', soname = 'libcsslayout.$(ext)', - srcs = glob(['java/jni/*.c']), - exported_headers = subdir_glob([('', 'java/jni/*.h')]), + srcs = glob(['java/jni/*.cpp']), header_namespace = '', - compiler_flags = COMPILER_FLAGS, + compiler_flags = JNI_COMPILER_FLAGS, deps = [ - ':CSSLayout' + ':CSSLayout', + css_layout_dep('lib/fb:fbjni'), ], visibility = ['PUBLIC'], ) diff --git a/CSSLAYOUT_DEFS b/CSSLAYOUT_DEFS index fa2919b9..94904b5f 100644 --- a/CSSLAYOUT_DEFS +++ b/CSSLAYOUT_DEFS @@ -13,3 +13,6 @@ class allow_unsafe_import: pass def __exit__(self, type, value, traceback): pass + +def css_layout_dep(name): + return '//' + name diff --git a/java/jni/CSSJNI.c b/java/jni/CSSJNI.c deleted file mode 100644 index ecf28a89..00000000 --- a/java/jni/CSSJNI.c +++ /dev/null @@ -1,210 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#include -#include - -#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_STYLE_PROP(javatype, type, name) \ - CSS_NODE_JNI(javatype, \ - CSSNodeStyleGet##name(JNIEnv *env, jobject instance, jlong nativePointer) { \ - return (javatype) CSSNodeStyleGet##name((CSSNodeRef)(intptr_t) nativePointer); \ - }) \ - \ - CSS_NODE_JNI( \ - void, \ - CSSNodeStyleSet##name(JNIEnv *env, jobject instance, jlong nativePointer, javatype value) { \ - CSSNodeStyleSet##name((CSSNodeRef)(intptr_t) nativePointer, (type) value); \ - }) - -#define CSS_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \ - CSS_NODE_JNI( \ - javatype, \ - CSSNodeStyleGet##name(JNIEnv *env, jobject instance, jlong nativePointer, jint edge) { \ - return (javatype) CSSNodeStyleGet##name((CSSNodeRef)(intptr_t) nativePointer, \ - (CSSEdge) edge); \ - }) \ - \ - CSS_NODE_JNI( \ - void, \ - CSSNodeStyleSet##name( \ - JNIEnv *env, jobject instance, jlong nativePointer, jint edge, javatype value) { \ - CSSNodeStyleSet##name((CSSNodeRef)(intptr_t) nativePointer, (CSSEdge) edge, (type) value); \ - }) - -#define CSS_NODE_JNI_LAYOUT_PROP(javatype, type, name) \ - CSS_NODE_JNI(javatype, \ - CSSNodeLayoutGet##name(JNIEnv *env, jobject instance, jlong nativePointer) { \ - return (javatype) CSSNodeLayoutGet##name((CSSNodeRef)(intptr_t) nativePointer); \ - }) - -static JavaVM *jvm = NULL; - -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"); - - static jclass cssNodeClass = NULL; - if (!cssNodeClass) { - cssNodeClass = (*env)->FindClass(env, "com/facebook/csslayout/CSSNodeJNI"); - CSS_ASSERT(cssNodeClass, "Could not find CSSNode class"); - } - - static jmethodID toStringID = NULL; - if (!toStringID) { - toStringID = (*env)->GetMethodID(env, cssNodeClass, "toString", "()Ljava/lang/String"); - CSS_ASSERT(toStringID, "Could not find toString method"); - } - - 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) { - JNIEnv *env = NULL; - CSS_ASSERT((*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION) == JNI_OK, "Must have valid jni env"); - - static jclass cssNodeClass = NULL; - if (!cssNodeClass) { - cssNodeClass = (*env)->FindClass(env, "com/facebook/csslayout/CSSNodeJNI"); - CSS_ASSERT(cssNodeClass, "Could not find CSSNode class"); - } - - static jmethodID measureID = NULL; - if (!measureID) { - measureID = (*env)->GetMethodID(env, cssNodeClass, "measure", "(FIFI)J"); - CSS_ASSERT(measureID, "Could not find measure method"); - } - - jlong measureResult = - (*env)->CallLongMethod(env, context, measureID, width, widthMode, height, heightMode); - - return (CSSSize){ - .width = (int32_t)(measureResult >> 32), .height = (int32_t) measureResult, - }; -} - -CSS_NODE_JNI(jlong, CSSNodeNew(JNIEnv *env, jobject thiz) { - const CSSNodeRef node = CSSNodeNew(); - CSSNodeSetContext(node, (*env)->NewGlobalRef(env, thiz)); - CSSNodeSetPrintFunc(node, _jniPrint); - return (jlong)(intptr_t) node; -}) - -CSS_NODE_JNI(void, CSSNodeFree(JNIEnv *env, jobject thiz, jlong nativePointer) { - (*env)->DeleteGlobalRef(env, (jobject) CSSNodeGetContext((CSSNodeRef)(intptr_t) nativePointer)); - CSSNodeFree((CSSNodeRef)(intptr_t) nativePointer); -}) - -CSS_NODE_JNI(void, - CSSNodeInsertChild(JNIEnv *env, - jobject thiz, - jlong nativePointer, - jlong childPointer, - jint index) { - CSSNodeInsertChild((CSSNodeRef)(intptr_t) nativePointer, - (CSSNodeRef)(intptr_t) childPointer, - index); - }) - -CSS_NODE_JNI( - void, - CSSNodeRemoveChild(JNIEnv *env, jobject thiz, jlong nativePointer, jlong childPointer) { - CSSNodeRemoveChild((CSSNodeRef)(intptr_t) nativePointer, (CSSNodeRef)(intptr_t) childPointer); - }) - -CSS_NODE_JNI(void, CSSNodeCalculateLayout(JNIEnv *env, jobject thiz, jlong nativePointer) { - CSSNodeCalculateLayout((CSSNodeRef)(intptr_t) nativePointer, - NAN, - NAN, - CSSNodeStyleGetDirection(((CSSNodeRef)(intptr_t) nativePointer))); -}) - -CSS_NODE_JNI(void, CSSNodeMarkDirty(JNIEnv *env, jobject thiz, jlong nativePointer) { - CSSNodeMarkDirty((CSSNodeRef)(intptr_t) nativePointer); -}) - -CSS_NODE_JNI(jboolean, CSSNodeIsDirty(JNIEnv *env, jobject instance, jlong nativePointer) { - return (jboolean) CSSNodeIsDirty((CSSNodeRef)(intptr_t) nativePointer); -}) - -CSS_NODE_JNI(void, - CSSNodeSetHasMeasureFunc(JNIEnv *env, - jobject thiz, - jlong nativePointer, - jboolean hasMeasureFunc) { - CSSNodeSetMeasureFunc((CSSNodeRef)(intptr_t) nativePointer, - hasMeasureFunc ? _jniMeasureFunc : NULL); - }) - -CSS_NODE_JNI( - void, - CSSNodeSetIsTextNode(JNIEnv *env, jobject instance, jlong nativePointer, jboolean isTextNode) { - CSSNodeSetIsTextnode((CSSNodeRef)(intptr_t) nativePointer, isTextNode); - }) - -CSS_NODE_JNI(jboolean, CSSNodeGetIsTextNode(JNIEnv *env, jobject instance, jlong nativePointer) { - return (jboolean) CSSNodeGetIsTextnode((CSSNodeRef)(intptr_t) nativePointer); -}) - -CSS_NODE_JNI(jboolean, CSSNodeHasNewLayout(JNIEnv *env, jobject instance, jlong nativePointer) { - return (jboolean) CSSNodeGetHasNewLayout((CSSNodeRef)(intptr_t) nativePointer); -}) - -CSS_NODE_JNI(void, CSSNodeMarkLayoutSeen(JNIEnv *env, jobject instance, jlong nativePointer) { - CSSNodeSetHasNewLayout((CSSNodeRef)(intptr_t) nativePointer, false); -}) - -CSS_NODE_JNI_STYLE_PROP(jint, CSSDirection, Direction); -CSS_NODE_JNI_STYLE_PROP(jint, CSSFlexDirection, FlexDirection); -CSS_NODE_JNI_STYLE_PROP(jint, CSSJustify, JustifyContent); -CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignItems); -CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignSelf); -CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignContent); -CSS_NODE_JNI_STYLE_PROP(jint, CSSPositionType, PositionType); -CSS_NODE_JNI_STYLE_PROP(jint, CSSWrapType, FlexWrap); -CSS_NODE_JNI_STYLE_PROP(jint, CSSOverflow, Overflow); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, Flex); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexBasis); - -CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Position); -CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Margin); -CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Padding); -CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Border); - -CSS_NODE_JNI_STYLE_PROP(jfloat, float, Width); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinWidth); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, MaxWidth); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, Height); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinHeight); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, MaxHeight); - -CSS_NODE_JNI_LAYOUT_PROP(jfloat, float, Width); -CSS_NODE_JNI_LAYOUT_PROP(jfloat, float, Height); -CSS_NODE_JNI_LAYOUT_PROP(jfloat, float, Left); -CSS_NODE_JNI_LAYOUT_PROP(jfloat, float, Top); -CSS_NODE_JNI_LAYOUT_PROP(jint, CSSDirection, Direction); diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp new file mode 100644 index 00000000..297c3328 --- /dev/null +++ b/java/jni/CSSJNI.cpp @@ -0,0 +1,239 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#include +#include +#include + +using namespace facebook::jni; +using namespace std; + +static void _jniPrint(void *context) { + const auto obj = wrap_alias(reinterpret_cast(context)); + cout << obj->toString() << endl; +} + +static CSSSize _jniMeasureFunc(void *context, + float width, + CSSMeasureMode widthMode, + float height, + CSSMeasureMode heightMode) { + const auto obj = wrap_alias(reinterpret_cast(context)); + static auto measureFunc = + obj->getClass()->getMethod("measure"); + const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode); + + static_assert(sizeof(measureResult) == 8, + "Expected measureResult to be 8 bytes, or two 32 bit ints"); + + const float measuredWidth = static_cast(0xFFFFFFFF & (measureResult >> 32)); + const float measuredHeight = static_cast(0xFFFFFFFF & measureResult); + return CSSSize{measuredWidth, measuredHeight}; +} + +static inline CSSNodeRef _jlong2CSSNodeRef(jlong addr) { + return reinterpret_cast(static_cast(addr)); +} + +jlong jni_CSSNodeNew(alias_ref thiz) { + const CSSNodeRef node = CSSNodeNew(); + auto globalThiz = make_global(thiz); + CSSNodeSetContext(node, globalThiz.release()); + CSSNodeSetPrintFunc(node, _jniPrint); + return reinterpret_cast(node); +} + +void jni_CSSNodeFree(alias_ref thiz, jlong nativePointer) { + const auto globalContext = + adopt_global(reinterpret_cast(CSSNodeGetContext(_jlong2CSSNodeRef(nativePointer)))); + CSSNodeFree(_jlong2CSSNodeRef(nativePointer)); +} + +void jni_CSSNodeInsertChild(alias_ref, + jlong nativePointer, + jlong childPointer, + jint index) { + CSSNodeInsertChild(_jlong2CSSNodeRef(nativePointer), _jlong2CSSNodeRef(childPointer), index); +} + +void jni_CSSNodeRemoveChild(alias_ref, jlong nativePointer, jlong childPointer) { + CSSNodeRemoveChild(_jlong2CSSNodeRef(nativePointer), _jlong2CSSNodeRef(childPointer)); +} + +void jni_CSSNodeCalculateLayout(alias_ref, jlong nativePointer) { + CSSNodeCalculateLayout(_jlong2CSSNodeRef(nativePointer), + CSSUndefined, + CSSUndefined, + CSSNodeStyleGetDirection(_jlong2CSSNodeRef(nativePointer))); +} + +void jni_CSSNodeMarkDirty(alias_ref, jlong nativePointer) { + CSSNodeMarkDirty(_jlong2CSSNodeRef(nativePointer)); +} + +jboolean jni_CSSNodeIsDirty(alias_ref, jlong nativePointer) { + return (jboolean) CSSNodeIsDirty(_jlong2CSSNodeRef(nativePointer)); +} + +void jni_CSSNodeSetHasMeasureFunc(alias_ref, + jlong nativePointer, + jboolean hasMeasureFunc) { + CSSNodeSetMeasureFunc(_jlong2CSSNodeRef(nativePointer), hasMeasureFunc ? _jniMeasureFunc : NULL); +} + +void jni_CSSNodeSetIsTextNode(alias_ref, jlong nativePointer, jboolean isTextNode) { + CSSNodeSetIsTextnode(_jlong2CSSNodeRef(nativePointer), isTextNode); +} + +jboolean jni_CSSNodeGetIsTextNode(alias_ref, jlong nativePointer) { + return (jboolean) CSSNodeGetIsTextnode(_jlong2CSSNodeRef(nativePointer)); +} + +jboolean jni_CSSNodeHasNewLayout(alias_ref, jlong nativePointer) { + return (jboolean) CSSNodeGetHasNewLayout(_jlong2CSSNodeRef(nativePointer)); +} + +void jni_CSSNodeMarkLayoutSeen(alias_ref, jlong nativePointer) { + CSSNodeSetHasNewLayout(_jlong2CSSNodeRef(nativePointer), false); +} + +#define CSS_NODE_JNI_STYLE_PROP(javatype, type, name) \ + javatype jni_CSSNodeStyleGet##name(alias_ref, jlong nativePointer) { \ + return (javatype) CSSNodeStyleGet##name(_jlong2CSSNodeRef(nativePointer)); \ + } \ + \ + void jni_CSSNodeStyleSet##name(alias_ref, jlong nativePointer, javatype value) { \ + CSSNodeStyleSet##name(_jlong2CSSNodeRef(nativePointer), static_cast(value)); \ + } + +#define CSS_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \ + javatype jni_CSSNodeStyleGet##name(alias_ref, jlong nativePointer, jint edge) { \ + return (javatype) CSSNodeStyleGet##name(_jlong2CSSNodeRef(nativePointer), \ + static_cast(edge)); \ + } \ + \ + void jni_CSSNodeStyleSet##name(alias_ref, \ + jlong nativePointer, \ + jint edge, \ + javatype value) { \ + CSSNodeStyleSet##name(_jlong2CSSNodeRef(nativePointer), \ + static_cast(edge), \ + static_cast(value)); \ + } + +#define CSS_NODE_JNI_LAYOUT_PROP(javatype, type, name) \ + javatype jni_CSSNodeLayoutGet##name(alias_ref, jlong nativePointer) { \ + return (javatype) CSSNodeLayoutGet##name(_jlong2CSSNodeRef(nativePointer)); \ + } + +CSS_NODE_JNI_STYLE_PROP(jint, CSSDirection, Direction); +CSS_NODE_JNI_STYLE_PROP(jint, CSSFlexDirection, FlexDirection); +CSS_NODE_JNI_STYLE_PROP(jint, CSSJustify, JustifyContent); +CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignItems); +CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignSelf); +CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignContent); +CSS_NODE_JNI_STYLE_PROP(jint, CSSPositionType, PositionType); +CSS_NODE_JNI_STYLE_PROP(jint, CSSWrapType, FlexWrap); +CSS_NODE_JNI_STYLE_PROP(jint, CSSOverflow, Overflow); +CSS_NODE_JNI_STYLE_PROP(jfloat, float, Flex); +CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow); +CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink); +CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexBasis); + +CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Position); +CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Margin); +CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Padding); +CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Border); + +CSS_NODE_JNI_STYLE_PROP(jfloat, float, Width); +CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinWidth); +CSS_NODE_JNI_STYLE_PROP(jfloat, float, MaxWidth); +CSS_NODE_JNI_STYLE_PROP(jfloat, float, Height); +CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinHeight); +CSS_NODE_JNI_STYLE_PROP(jfloat, float, MaxHeight); + +CSS_NODE_JNI_LAYOUT_PROP(jfloat, float, Width); +CSS_NODE_JNI_LAYOUT_PROP(jfloat, float, Height); +CSS_NODE_JNI_LAYOUT_PROP(jfloat, float, Left); +CSS_NODE_JNI_LAYOUT_PROP(jfloat, float, Top); +CSS_NODE_JNI_LAYOUT_PROP(jint, CSSDirection, Direction); + +#define CSSMakeNativeMethod(name) makeNativeMethod(#name, name) + +jint JNI_OnLoad(JavaVM *vm, void *) { + return initialize(vm, [] { + registerNatives("com/facebook/csslayout/CSSNodeJNI", + { + CSSMakeNativeMethod(jni_CSSNodeNew), + CSSMakeNativeMethod(jni_CSSNodeFree), + CSSMakeNativeMethod(jni_CSSNodeInsertChild), + CSSMakeNativeMethod(jni_CSSNodeRemoveChild), + CSSMakeNativeMethod(jni_CSSNodeSetIsTextNode), + CSSMakeNativeMethod(jni_CSSNodeGetIsTextNode), + CSSMakeNativeMethod(jni_CSSNodeCalculateLayout), + CSSMakeNativeMethod(jni_CSSNodeHasNewLayout), + CSSMakeNativeMethod(jni_CSSNodeMarkDirty), + CSSMakeNativeMethod(jni_CSSNodeIsDirty), + CSSMakeNativeMethod(jni_CSSNodeMarkLayoutSeen), + CSSMakeNativeMethod(jni_CSSNodeSetHasMeasureFunc), + + CSSMakeNativeMethod(jni_CSSNodeStyleGetDirection), + CSSMakeNativeMethod(jni_CSSNodeStyleSetDirection), + CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexDirection), + CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexDirection), + CSSMakeNativeMethod(jni_CSSNodeStyleGetJustifyContent), + CSSMakeNativeMethod(jni_CSSNodeStyleSetJustifyContent), + CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignItems), + CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignItems), + CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignSelf), + CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignSelf), + CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignContent), + CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignContent), + CSSMakeNativeMethod(jni_CSSNodeStyleGetPositionType), + CSSMakeNativeMethod(jni_CSSNodeStyleSetPositionType), + CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexWrap), + CSSMakeNativeMethod(jni_CSSNodeStyleGetOverflow), + CSSMakeNativeMethod(jni_CSSNodeStyleSetOverflow), + CSSMakeNativeMethod(jni_CSSNodeStyleGetFlex), + CSSMakeNativeMethod(jni_CSSNodeStyleSetFlex), + CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexGrow), + CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexGrow), + CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexShrink), + CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexShrink), + CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexBasis), + CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexBasis), + CSSMakeNativeMethod(jni_CSSNodeStyleGetMargin), + CSSMakeNativeMethod(jni_CSSNodeStyleSetMargin), + CSSMakeNativeMethod(jni_CSSNodeStyleGetPadding), + CSSMakeNativeMethod(jni_CSSNodeStyleSetPadding), + CSSMakeNativeMethod(jni_CSSNodeStyleGetBorder), + CSSMakeNativeMethod(jni_CSSNodeStyleSetBorder), + CSSMakeNativeMethod(jni_CSSNodeStyleGetPosition), + CSSMakeNativeMethod(jni_CSSNodeStyleSetPosition), + CSSMakeNativeMethod(jni_CSSNodeStyleGetWidth), + CSSMakeNativeMethod(jni_CSSNodeStyleSetWidth), + CSSMakeNativeMethod(jni_CSSNodeStyleGetHeight), + CSSMakeNativeMethod(jni_CSSNodeStyleSetHeight), + CSSMakeNativeMethod(jni_CSSNodeStyleGetMinWidth), + CSSMakeNativeMethod(jni_CSSNodeStyleSetMinWidth), + CSSMakeNativeMethod(jni_CSSNodeStyleGetMinHeight), + CSSMakeNativeMethod(jni_CSSNodeStyleSetMinHeight), + CSSMakeNativeMethod(jni_CSSNodeStyleGetMaxWidth), + CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxWidth), + CSSMakeNativeMethod(jni_CSSNodeStyleGetMaxHeight), + CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxHeight), + + CSSMakeNativeMethod(jni_CSSNodeLayoutGetLeft), + CSSMakeNativeMethod(jni_CSSNodeLayoutGetTop), + CSSMakeNativeMethod(jni_CSSNodeLayoutGetWidth), + CSSMakeNativeMethod(jni_CSSNodeLayoutGetHeight), + CSSMakeNativeMethod(jni_CSSNodeLayoutGetDirection), + }); + }); +} diff --git a/lib/fb/BUCK b/lib/fb/BUCK new file mode 100644 index 00000000..1ca6070d --- /dev/null +++ b/lib/fb/BUCK @@ -0,0 +1,41 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +include_defs('//CSSLAYOUT_DEFS') + +prebuilt_cxx_library( + name = 'ndklog', + header_only = True, + exported_platform_linker_flags = [ + ('android.*', ['-llog']), + ], + visibility = [CSSLAYOUT_ROOT], +) + +cxx_library( + name = 'fbjni', + srcs = glob(['**/*.cpp']), + exported_headers = subdir_glob([('include', '**/*.h')]), + header_namespace = '', + compiler_flags = [ + '-DLOG_TAG=\"libfb\"', + '-DDISABLE_CPUCAP', + '-DDISABLE_XPLAT', + '-DHAVE_POSIX_CLOCKS', + '-fno-omit-frame-pointer', + '-fexceptions', + '-frtti', + '-Wall', + '-Werror', + '-Wno-unused-parameter', + '-std=c++11', + ], + deps = [ + ':ndklog', + ], + visibility = [CSSLAYOUT_ROOT], +)