Compare commits
40 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e9e2ae28e0 | ||
|
4ed3dd4b82 | ||
|
a7f430a5ef | ||
|
89ba4f282d | ||
|
b6231ee0ed | ||
|
e384002878 | ||
|
9ceed4b601 | ||
|
765bb85d1e | ||
|
6548dddec3 | ||
|
966f5ece4a | ||
|
ede2888326 | ||
|
2eda444bbf | ||
|
7c4319181b | ||
|
f4d29e6f11 | ||
|
77ea79490f | ||
|
46c96ee2cb | ||
|
a67c555320 | ||
|
cdb1ee21a0 | ||
|
2ce219ef42 | ||
|
c5f826de83 | ||
|
526ca42d04 | ||
|
b47f0ce41a | ||
|
eb7cb11ffd | ||
|
f9df990177 | ||
|
684dccb7b9 | ||
|
6c51eb4f72 | ||
|
ca485dfb50 | ||
|
50e3714b21 | ||
|
c52c7cdd1e | ||
|
11200f3d75 | ||
|
5dbe3c128b | ||
|
3564ccf6e4 | ||
|
e1c19cecad | ||
|
8e4f3a3084 | ||
|
9b8323ff38 | ||
|
5b7adda620 | ||
|
ba2a3b8c91 | ||
|
eb15939c23 | ||
|
b9fa60fd74 | ||
|
d397aa04d7 |
55
.travis.yml
55
.travis.yml
@@ -1,16 +1,58 @@
|
|||||||
language: node_js
|
language: java
|
||||||
node_js:
|
|
||||||
- "8"
|
env:
|
||||||
|
- TARGET: website
|
||||||
|
- TARGET: android
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- cd website
|
- cd website
|
||||||
- yarn --ignore-scripts
|
- yarn --ignore-scripts
|
||||||
- cd ..
|
- cd ..
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/buck
|
||||||
|
- $HOME/.gradle
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- |
|
||||||
|
if [[ -n "$encrypted_d27e803291ff_iv" ]]; then
|
||||||
|
openssl aes-256-cbc -K $encrypted_d27e803291ff_key -iv $encrypted_d27e803291ff_iv -in scripts/setup-keys.enc -d >> gradle.properties;
|
||||||
|
fi
|
||||||
|
# Android
|
||||||
|
- |
|
||||||
|
if [[ $TARGET = "android" ]]; then
|
||||||
|
pushd $HOME
|
||||||
|
git clone --depth 1 https://github.com/facebook/buck.git
|
||||||
|
cd buck
|
||||||
|
ant
|
||||||
|
popd
|
||||||
|
export PATH=$PATH:$HOME/buck/bin/
|
||||||
|
buck --version
|
||||||
|
export TERMINAL=dumb
|
||||||
|
source scripts/android-setup.sh && installAndroidSDK
|
||||||
|
export ANDROID_SDK=$ANDROID_HOME
|
||||||
|
export ANDROID_NDK_REPOSITORY=$HOME/android-ndk
|
||||||
|
export ANDROID_NDK_HOME=$ANDROID_NDK_REPOSITORY/android-ndk-r15c
|
||||||
|
fi
|
||||||
|
# Website
|
||||||
|
- |
|
||||||
|
if [[ $TARGET = "website" ]]; then
|
||||||
|
nvm install 8
|
||||||
|
nvm use 8
|
||||||
|
fi
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cd website
|
- |
|
||||||
- yarn build
|
if [[ $TARGET = "android" ]]; then
|
||||||
- cd ..
|
./gradlew testDebugUnit && scripts/publish-snapshot.sh
|
||||||
|
fi
|
||||||
|
- |
|
||||||
|
if [[ $TARGET = "website" ]]; then
|
||||||
|
pushd website
|
||||||
|
yarn build
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
provider: pages
|
provider: pages
|
||||||
@@ -23,3 +65,4 @@ deploy:
|
|||||||
keep-history: true
|
keep-history: true
|
||||||
on:
|
on:
|
||||||
branch: master
|
branch: master
|
||||||
|
condition: $TARGET = website
|
||||||
|
7
BUCK
7
BUCK
@@ -2,8 +2,7 @@
|
|||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
load("//:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "GTEST_TARGET", "LIBRARY_COMPILER_FLAGS", "subdir_glob", "yoga_cxx_library", "yoga_cxx_test", "yoga_dep")
|
||||||
load("//:yoga_defs.bzl", "LIBRARY_COMPILER_FLAGS", "BASE_COMPILER_FLAGS", "GTEST_TARGET", "yoga_dep", "cxx_library", "cxx_test")
|
|
||||||
|
|
||||||
GMOCK_OVERRIDE_FLAGS = [
|
GMOCK_OVERRIDE_FLAGS = [
|
||||||
# gmock does not mark mocked methods as override, ignore the warnings in tests
|
# gmock does not mark mocked methods as override, ignore the warnings in tests
|
||||||
@@ -18,7 +17,7 @@ TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
|
|||||||
"-std=c++1y",
|
"-std=c++1y",
|
||||||
]
|
]
|
||||||
|
|
||||||
cxx_library(
|
yoga_cxx_library(
|
||||||
name = "yoga",
|
name = "yoga",
|
||||||
srcs = glob(["yoga/*.cpp"]),
|
srcs = glob(["yoga/*.cpp"]),
|
||||||
header_namespace = "",
|
header_namespace = "",
|
||||||
@@ -32,7 +31,7 @@ cxx_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
cxx_test(
|
yoga_cxx_test(
|
||||||
name = "YogaTests",
|
name = "YogaTests",
|
||||||
srcs = glob(["tests/*.cpp"]),
|
srcs = glob(["tests/*.cpp"]),
|
||||||
compiler_flags = TEST_COMPILER_FLAGS,
|
compiler_flags = TEST_COMPILER_FLAGS,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
Pod::Spec.new do |spec|
|
Pod::Spec.new do |spec|
|
||||||
spec.name = 'Yoga'
|
spec.name = 'Yoga'
|
||||||
spec.version = '1.8.0'
|
spec.version = '1.9.0'
|
||||||
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
||||||
spec.homepage = 'https://yogalayout.com/'
|
spec.homepage = 'https://yogalayout.com/'
|
||||||
spec.documentation_url = 'https://yogalayout.com/docs'
|
spec.documentation_url = 'https://yogalayout.com/docs'
|
||||||
@@ -11,11 +11,14 @@ Pod::Spec.new do |spec|
|
|||||||
spec.authors = 'Facebook'
|
spec.authors = 'Facebook'
|
||||||
spec.source = {
|
spec.source = {
|
||||||
:git => 'https://github.com/facebook/yoga.git',
|
:git => 'https://github.com/facebook/yoga.git',
|
||||||
:tag => '1.8.0',
|
:tag => spec.version.to_s,
|
||||||
}
|
}
|
||||||
spec.osx.deployment_target = '10.13'
|
spec.platforms = { :ios => "8.0", :tvos => "10.0" }
|
||||||
spec.module_name = 'yoga'
|
spec.module_name = 'yoga'
|
||||||
spec.requires_arc = false
|
spec.requires_arc = false
|
||||||
|
spec.pod_target_xcconfig = {
|
||||||
|
'DEFINES_MODULE' => 'YES'
|
||||||
|
}
|
||||||
spec.compiler_flags = [
|
spec.compiler_flags = [
|
||||||
'-fno-omit-frame-pointer',
|
'-fno-omit-frame-pointer',
|
||||||
'-fexceptions',
|
'-fexceptions',
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
podspec = Pod::Spec.new do |spec|
|
podspec = Pod::Spec.new do |spec|
|
||||||
spec.name = 'YogaKit'
|
spec.name = 'YogaKit'
|
||||||
spec.version = '1.7.0'
|
spec.version = '1.9.0'
|
||||||
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
||||||
spec.homepage = 'https://facebook.github.io/yoga/'
|
spec.homepage = 'https://facebook.github.io/yoga/'
|
||||||
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/'
|
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/'
|
||||||
@@ -11,14 +11,14 @@ podspec = Pod::Spec.new do |spec|
|
|||||||
spec.authors = 'Facebook'
|
spec.authors = 'Facebook'
|
||||||
spec.source = {
|
spec.source = {
|
||||||
:git => 'https://github.com/facebook/yoga.git',
|
:git => 'https://github.com/facebook/yoga.git',
|
||||||
:tag => '1.7.0',
|
:tag => spec.version.to_s,
|
||||||
}
|
}
|
||||||
|
|
||||||
spec.platform = :ios
|
spec.platform = :ios
|
||||||
spec.ios.deployment_target = '8.0'
|
spec.ios.deployment_target = '8.0'
|
||||||
spec.ios.frameworks = 'UIKit'
|
spec.ios.frameworks = 'UIKit'
|
||||||
|
|
||||||
spec.dependency 'Yoga', '~> 1.7'
|
spec.dependency 'Yoga', '~> 1.9'
|
||||||
spec.source_files = 'YogaKit/Source/*.{h,m,swift}'
|
spec.source_files = 'YogaKit/Source/*.{h,m,swift}'
|
||||||
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
|
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
|
||||||
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
|
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
|
||||||
|
@@ -2,8 +2,7 @@
|
|||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
load("//:yoga_defs.bzl", "subdir_glob", "yoga_apple_library", "yoga_apple_test", "yoga_dep")
|
||||||
load("//:yoga_defs.bzl", "yoga_dep", "apple_library", "apple_test")
|
|
||||||
|
|
||||||
COMPILER_FLAGS = [
|
COMPILER_FLAGS = [
|
||||||
"-fobjc-arc",
|
"-fobjc-arc",
|
||||||
@@ -25,7 +24,7 @@ COMPILER_FLAGS = [
|
|||||||
"-Wunused-value",
|
"-Wunused-value",
|
||||||
]
|
]
|
||||||
|
|
||||||
apple_library(
|
yoga_apple_library(
|
||||||
name = "YogaKit",
|
name = "YogaKit",
|
||||||
srcs = glob(["Source/**/*.m"]),
|
srcs = glob(["Source/**/*.m"]),
|
||||||
header_namespace = "",
|
header_namespace = "",
|
||||||
@@ -49,7 +48,7 @@ apple_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
apple_test(
|
yoga_apple_test(
|
||||||
name = "YogaKitTests",
|
name = "YogaKitTests",
|
||||||
srcs = glob(["Tests/**/*.m"]),
|
srcs = glob(["Tests/**/*.m"]),
|
||||||
compiler_flags = COMPILER_FLAGS,
|
compiler_flags = COMPILER_FLAGS,
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "android_aar", "android_resource")
|
load("//:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "yoga_android_aar", "yoga_android_resource")
|
||||||
|
|
||||||
android_aar(
|
yoga_android_aar(
|
||||||
name = "android",
|
name = "android",
|
||||||
manifest_skeleton = "src/main/AndroidManifest.xml",
|
manifest_skeleton = "src/main/AndroidManifest.xml",
|
||||||
visibility = [
|
visibility = [
|
||||||
@@ -20,7 +20,7 @@ android_aar(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
android_resource(
|
yoga_android_resource(
|
||||||
name = "res",
|
name = "res",
|
||||||
package = "com.facebook.yoga.android",
|
package = "com.facebook.yoga.android",
|
||||||
res = "src/main/res",
|
res = "src/main/res",
|
||||||
|
@@ -4,9 +4,9 @@
|
|||||||
# This source code is licensed under the license found in the
|
# This source code is licensed under the license found in the
|
||||||
# LICENSE-examples file in the root directory of this source tree.
|
# LICENSE-examples file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "ANDROID_SAMPLE_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_RES_TARGET", "android_binary", "android_resource")
|
load("//:yoga_defs.bzl", "ANDROID_RES_TARGET", "ANDROID_SAMPLE_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "yoga_android_binary", "yoga_android_resource")
|
||||||
|
|
||||||
android_binary(
|
yoga_android_binary(
|
||||||
name = "sample",
|
name = "sample",
|
||||||
keystore = ":debug_keystore",
|
keystore = ":debug_keystore",
|
||||||
manifest = "AndroidManifest.xml",
|
manifest = "AndroidManifest.xml",
|
||||||
@@ -16,7 +16,7 @@ android_binary(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
android_resource(
|
yoga_android_resource(
|
||||||
name = "res",
|
name = "res",
|
||||||
package = "com.facebook.samples.yoga",
|
package = "com.facebook.samples.yoga",
|
||||||
res = "res",
|
res = "res",
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the license found in the
|
# This source code is licensed under the license found in the
|
||||||
# LICENSE-examples file in the root directory of this source tree.
|
# LICENSE-examples file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_SUPPORT_TARGET", "APPCOMPAT_TARGET", "SOLOADER_TARGET", "android_library")
|
load("//:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_SUPPORT_TARGET", "APPCOMPAT_TARGET", "SOLOADER_TARGET", "yoga_android_library")
|
||||||
|
|
||||||
android_library(
|
yoga_android_library(
|
||||||
name = "yoga",
|
name = "yoga",
|
||||||
srcs = glob(["**/*.java"]),
|
srcs = glob(["**/*.java"]),
|
||||||
visibility = [
|
visibility = [
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "JSR_305_TARGET", "SOLOADER_TARGET", "android_library")
|
load("//:yoga_defs.bzl", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "JSR_305_TARGET", "SOLOADER_TARGET", "yoga_android_library")
|
||||||
|
|
||||||
android_library(
|
yoga_android_library(
|
||||||
name = "android",
|
name = "android",
|
||||||
srcs = glob(["**/*.java"]),
|
srcs = glob(["**/*.java"]),
|
||||||
visibility = [
|
visibility = [
|
||||||
|
@@ -2,10 +2,9 @@
|
|||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
load("//:yoga_defs.bzl", "subdir_glob", "yoga_cxx_binary", "yoga_dep")
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "yoga_dep")
|
yoga_cxx_binary(
|
||||||
|
|
||||||
cxx_binary(
|
|
||||||
name = "benchmark",
|
name = "benchmark",
|
||||||
srcs = glob(["*.c"]),
|
srcs = glob(["*.c"]),
|
||||||
headers = subdir_glob([("", "*.h")]),
|
headers = subdir_glob([("", "*.h")]),
|
||||||
|
@@ -5,10 +5,72 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "YGBenchmark.h"
|
#include <math.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
|
#define NUM_REPETITIONS 1000
|
||||||
|
|
||||||
|
#define YGBENCHMARKS(BLOCK) \
|
||||||
|
int main(int argc, char const *argv[]) { \
|
||||||
|
clock_t __start; \
|
||||||
|
clock_t __endTimes[NUM_REPETITIONS]; \
|
||||||
|
{ BLOCK } \
|
||||||
|
return 0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define YGBENCHMARK(NAME, BLOCK) \
|
||||||
|
__start = clock(); \
|
||||||
|
for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \
|
||||||
|
{ BLOCK } \
|
||||||
|
__endTimes[__i] = clock(); \
|
||||||
|
} \
|
||||||
|
__printBenchmarkResult(NAME, __start, __endTimes);
|
||||||
|
|
||||||
|
static int __compareDoubles(const void *a, const void *b) {
|
||||||
|
double arg1 = *(const double *) a;
|
||||||
|
double arg2 = *(const double *) b;
|
||||||
|
|
||||||
|
if (arg1 < arg2) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg1 > arg2) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __printBenchmarkResult(char *name, clock_t start, clock_t *endTimes) {
|
||||||
|
double timesInMs[NUM_REPETITIONS];
|
||||||
|
double mean = 0;
|
||||||
|
clock_t lastEnd = start;
|
||||||
|
for (uint32_t i = 0; i < NUM_REPETITIONS; i++) {
|
||||||
|
timesInMs[i] = (endTimes[i] - lastEnd) / (double) CLOCKS_PER_SEC * 1000;
|
||||||
|
lastEnd = endTimes[i];
|
||||||
|
mean += timesInMs[i];
|
||||||
|
}
|
||||||
|
mean /= NUM_REPETITIONS;
|
||||||
|
|
||||||
|
qsort(timesInMs, NUM_REPETITIONS, sizeof(double), __compareDoubles);
|
||||||
|
double median = timesInMs[NUM_REPETITIONS / 2];
|
||||||
|
|
||||||
|
double variance = 0;
|
||||||
|
for (uint32_t i = 0; i < NUM_REPETITIONS; i++) {
|
||||||
|
variance += pow(timesInMs[i] - mean, 2);
|
||||||
|
}
|
||||||
|
variance /= NUM_REPETITIONS;
|
||||||
|
double stddev = sqrt(variance);
|
||||||
|
|
||||||
|
printf("%s: median: %lf ms, stddev: %lf ms\n", name, median, stddev);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static YGSize _measure(YGNodeRef node,
|
static YGSize _measure(YGNodeRef node,
|
||||||
float width,
|
float width,
|
||||||
YGMeasureMode widthMode,
|
YGMeasureMode widthMode,
|
||||||
@@ -97,7 +159,7 @@ YGBENCHMARKS({
|
|||||||
YGNodeStyleSetHeight(grandGrandChild, 10);
|
YGNodeStyleSetHeight(grandGrandChild, 10);
|
||||||
YGNodeInsertChild(grandChild, grandGrandChild, 0);
|
YGNodeInsertChild(grandChild, grandGrandChild, 0);
|
||||||
|
|
||||||
for (uint32_t iii = 0; iii < 10; iii++) {
|
for (uint32_t iiii = 0; iiii < 10; iiii++) {
|
||||||
const YGNodeRef grandGrandGrandChild = YGNodeNew();
|
const YGNodeRef grandGrandGrandChild = YGNodeNew();
|
||||||
YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow);
|
YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow);
|
||||||
YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1);
|
YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1);
|
||||||
|
@@ -1,71 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#define NUM_REPETITIONS 1000
|
|
||||||
|
|
||||||
#define YGBENCHMARKS(BLOCK) \
|
|
||||||
int main(int argc, char const *argv[]) { \
|
|
||||||
clock_t __start; \
|
|
||||||
clock_t __endTimes[NUM_REPETITIONS]; \
|
|
||||||
{ BLOCK } \
|
|
||||||
return 0; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YGBENCHMARK(NAME, BLOCK) \
|
|
||||||
__start = clock(); \
|
|
||||||
for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \
|
|
||||||
{ BLOCK } \
|
|
||||||
__endTimes[__i] = clock(); \
|
|
||||||
} \
|
|
||||||
__printBenchmarkResult(NAME, __start, __endTimes);
|
|
||||||
|
|
||||||
int __compareDoubles(const void *a, const void *b) {
|
|
||||||
double arg1 = *(const double *) a;
|
|
||||||
double arg2 = *(const double *) b;
|
|
||||||
|
|
||||||
if (arg1 < arg2) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arg1 > arg2) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void __printBenchmarkResult(char *name, clock_t start, clock_t *endTimes) {
|
|
||||||
double timesInMs[NUM_REPETITIONS];
|
|
||||||
double mean = 0;
|
|
||||||
clock_t lastEnd = start;
|
|
||||||
for (uint32_t i = 0; i < NUM_REPETITIONS; i++) {
|
|
||||||
timesInMs[i] = (endTimes[i] - lastEnd) / (double) CLOCKS_PER_SEC * 1000;
|
|
||||||
lastEnd = endTimes[i];
|
|
||||||
mean += timesInMs[i];
|
|
||||||
}
|
|
||||||
mean /= NUM_REPETITIONS;
|
|
||||||
|
|
||||||
qsort(timesInMs, NUM_REPETITIONS, sizeof(double), __compareDoubles);
|
|
||||||
double median = timesInMs[NUM_REPETITIONS / 2];
|
|
||||||
|
|
||||||
double variance = 0;
|
|
||||||
for (uint32_t i = 0; i < NUM_REPETITIONS; i++) {
|
|
||||||
variance += pow(timesInMs[i] - mean, 2);
|
|
||||||
}
|
|
||||||
variance /= NUM_REPETITIONS;
|
|
||||||
double stddev = sqrt(variance);
|
|
||||||
|
|
||||||
printf("%s: median: %lf ms, stddev: %lf ms\n", name, median, stddev);
|
|
||||||
}
|
|
71
csharp/BUCK
71
csharp/BUCK
@@ -3,7 +3,7 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "yoga_dep", "cxx_library", "is_apple_platform")
|
load("//:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "is_apple_platform", "yoga_cxx_library", "yoga_dep")
|
||||||
|
|
||||||
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++11"]
|
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++11"]
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ csharp_library(
|
|||||||
framework_ver = "net45",
|
framework_ver = "net45",
|
||||||
)
|
)
|
||||||
|
|
||||||
cxx_library(
|
yoga_cxx_library(
|
||||||
name = "yoganet",
|
name = "yoganet",
|
||||||
srcs = glob(["Yoga/YGInterop.cpp"]),
|
srcs = glob(["Yoga/YGInterop.cpp"]),
|
||||||
compiler_flags = COMPILER_FLAGS,
|
compiler_flags = COMPILER_FLAGS,
|
||||||
@@ -33,39 +33,40 @@ cxx_library(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if is_apple_platform():
|
if is_apple_platform():
|
||||||
yoganet_ios_srcs = []
|
yoganet_ios_srcs = []
|
||||||
for arch in [
|
for arch in [
|
||||||
'iphonesimulator-x86_64', 'iphoneos-arm64'
|
"iphonesimulator-x86_64",
|
||||||
]:
|
"iphoneos-arm64",
|
||||||
name = 'yoganet-' + arch
|
]:
|
||||||
yoganet_ios_srcs.append(':' + name)
|
name = "yoganet-" + arch
|
||||||
|
yoganet_ios_srcs.append(":" + name)
|
||||||
|
genrule(
|
||||||
|
name = name,
|
||||||
|
srcs = [
|
||||||
|
yoga_dep(":yogaApple#%s,static" % arch),
|
||||||
|
yoga_dep("YogaKit:YogaKitApple#%s,static" % arch),
|
||||||
|
yoga_dep("csharp:yoganetApple#%s,static" % arch),
|
||||||
|
],
|
||||||
|
out = "libyoga-%s.a" % arch,
|
||||||
|
cmd = "libtool -static -o $OUT $SRCS",
|
||||||
|
visibility = [yoga_dep("csharp:yoganet-ios")],
|
||||||
|
)
|
||||||
|
|
||||||
genrule(
|
genrule(
|
||||||
name = name,
|
name = "yoganet-ios",
|
||||||
srcs = [
|
srcs = yoganet_ios_srcs,
|
||||||
yoga_dep(':yoga#%s,static' % arch),
|
out = "libyoga.a",
|
||||||
yoga_dep('YogaKit:YogaKit#%s,static' % arch),
|
cmd = "lipo $SRCS -create -output $OUT",
|
||||||
yoga_dep('csharp:yoganet#%s,static' % arch),
|
visibility = ["PUBLIC"],
|
||||||
],
|
|
||||||
out = 'libyoga-%s.a' % arch,
|
|
||||||
cmd = 'libtool -static -o $OUT $SRCS',
|
|
||||||
visibility = [yoga_dep('csharp:yoganet-ios')],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
genrule(
|
yoganet_macosx_target = "csharp:yoganetAppleMac#macosx-%s,dynamic"
|
||||||
name = 'yoganet-ios',
|
genrule(
|
||||||
srcs = yoganet_ios_srcs,
|
name = "yoganet-macosx",
|
||||||
out = 'libyoga.a',
|
srcs = [
|
||||||
cmd = 'lipo $SRCS -create -output $OUT',
|
yoga_dep(yoganet_macosx_target % "x86_64"),
|
||||||
visibility = ['PUBLIC'],
|
],
|
||||||
)
|
out = "libyoga.dylib",
|
||||||
|
cmd = "lipo $SRCS -create -output $OUT",
|
||||||
yoganet_macosx_target = 'csharp:yoganet#macosx-%s,dynamic'
|
visibility = ["PUBLIC"],
|
||||||
genrule(
|
)
|
||||||
name = 'yoganet-macosx',
|
|
||||||
srcs = [
|
|
||||||
yoga_dep(yoganet_macosx_target % 'x86_64')
|
|
||||||
],
|
|
||||||
out = 'libyoga.dylib',
|
|
||||||
cmd = 'lipo $SRCS -create -output $OUT',
|
|
||||||
visibility = ['PUBLIC'],
|
|
||||||
)
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
org.gradle.jvmargs=-Xmx1536M
|
org.gradle.jvmargs=-Xmx1536M
|
||||||
|
|
||||||
VERSION_NAME=1.8.0
|
VERSION_NAME=1.8.1-SNAPSHOT
|
||||||
POM_URL=https://github.com/facebook/yoga
|
POM_URL=https://github.com/facebook/yoga
|
||||||
POM_SCM_URL=https://github.com/facebook/yoga.git
|
POM_SCM_URL=https://github.com/facebook/yoga.git
|
||||||
POM_SCM_CONNECTION=scm:git:https://github.com/facebook/yoga.git
|
POM_SCM_CONNECTION=scm:git:https://github.com/facebook/yoga.git
|
||||||
|
10
java/BUCK
10
java/BUCK
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "FBJNI_TARGET", "JNI_TARGET", "INFER_ANNOTATIONS_TARGET", "JSR_305_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "JUNIT_TARGET", "FBJNI_JAVA_TARGET", "CXX_LIBRARY_WHITELIST", "ANDROID", "yoga_dep", "cxx_library", "java_library", "java_test", "java_binary")
|
load("//:yoga_defs.bzl", "ANDROID", "CXX_LIBRARY_WHITELIST", "FBJNI_JAVA_TARGET", "FBJNI_TARGET", "INFER_ANNOTATIONS_TARGET", "JNI_TARGET", "JSR_305_TARGET", "JUNIT_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "yoga_cxx_library", "yoga_dep", "yoga_java_binary", "yoga_java_library", "yoga_java_test")
|
||||||
|
|
||||||
cxx_library(
|
yoga_cxx_library(
|
||||||
name = "jni",
|
name = "jni",
|
||||||
srcs = glob(["jni/*.cpp"]),
|
srcs = glob(["jni/*.cpp"]),
|
||||||
header_namespace = "",
|
header_namespace = "",
|
||||||
@@ -28,7 +28,7 @@ cxx_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
java_library(
|
yoga_java_library(
|
||||||
name = "java",
|
name = "java",
|
||||||
srcs = glob(["com/facebook/yoga/*.java"]),
|
srcs = glob(["com/facebook/yoga/*.java"]),
|
||||||
required_for_source_only_abi = True,
|
required_for_source_only_abi = True,
|
||||||
@@ -47,7 +47,7 @@ java_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
java_test(
|
yoga_java_test(
|
||||||
name = "tests",
|
name = "tests",
|
||||||
srcs = glob(["tests/**/*.java"]),
|
srcs = glob(["tests/**/*.java"]),
|
||||||
cxx_library_whitelist = CXX_LIBRARY_WHITELIST,
|
cxx_library_whitelist = CXX_LIBRARY_WHITELIST,
|
||||||
@@ -59,7 +59,7 @@ java_test(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
java_binary(
|
yoga_java_binary(
|
||||||
name = "yoga",
|
name = "yoga",
|
||||||
deps = [
|
deps = [
|
||||||
":java",
|
":java",
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
public class YogaConstants {
|
public class YogaConstants {
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
@@ -174,6 +175,8 @@ public class YogaNode implements Cloneable {
|
|||||||
jni_YGNodeInsertSharedChild(mNativePointer, child.mNativePointer, i);
|
jni_YGNodeInsertSharedChild(mNativePointer, child.mNativePointer, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private native void jni_YGNodeSetOwner(long nativePointer, long newOwnerNativePointer);
|
||||||
|
|
||||||
private native long jni_YGNodeClone(long nativePointer, Object newNode);
|
private native long jni_YGNodeClone(long nativePointer, Object newNode);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -181,10 +184,23 @@ public class YogaNode implements Cloneable {
|
|||||||
try {
|
try {
|
||||||
YogaNode clonedYogaNode = (YogaNode) super.clone();
|
YogaNode clonedYogaNode = (YogaNode) super.clone();
|
||||||
long clonedNativePointer = jni_YGNodeClone(mNativePointer, clonedYogaNode);
|
long clonedNativePointer = jni_YGNodeClone(mNativePointer, clonedYogaNode);
|
||||||
|
|
||||||
|
if (mChildren != null) {
|
||||||
|
for (YogaNode child : mChildren) {
|
||||||
|
child.jni_YGNodeSetOwner(child.mNativePointer, 0);
|
||||||
|
child.mOwner = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clonedYogaNode.mNativePointer = clonedNativePointer;
|
clonedYogaNode.mNativePointer = clonedNativePointer;
|
||||||
clonedYogaNode.mOwner = null;
|
clonedYogaNode.mOwner = null;
|
||||||
clonedYogaNode.mChildren =
|
clonedYogaNode.mChildren =
|
||||||
mChildren != null ? (List<YogaNode>) ((ArrayList) mChildren).clone() : null;
|
mChildren != null ? (List<YogaNode>) ((ArrayList) mChildren).clone() : null;
|
||||||
|
if (clonedYogaNode.mChildren != null) {
|
||||||
|
for (YogaNode child : clonedYogaNode.mChildren) {
|
||||||
|
child.mOwner = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
return clonedYogaNode;
|
return clonedYogaNode;
|
||||||
} catch (CloneNotSupportedException ex) {
|
} catch (CloneNotSupportedException ex) {
|
||||||
// This class implements Cloneable, this should not happen
|
// This class implements Cloneable, this should not happen
|
||||||
@@ -234,11 +250,17 @@ public class YogaNode implements Cloneable {
|
|||||||
* {@link YogaNode} is shared between two or more YogaTrees.
|
* {@link YogaNode} is shared between two or more YogaTrees.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public
|
public YogaNode getOwner() {
|
||||||
YogaNode getOwner() {
|
|
||||||
return mOwner;
|
return mOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated Use #getOwner() instead. This will be removed in the next version. */
|
||||||
|
@Deprecated
|
||||||
|
@Nullable
|
||||||
|
public YogaNode getParent() {
|
||||||
|
return getOwner();
|
||||||
|
}
|
||||||
|
|
||||||
public int indexOf(YogaNode child) {
|
public int indexOf(YogaNode child) {
|
||||||
return mChildren == null ? -1 : mChildren.indexOf(child);
|
return mChildren == null ? -1 : mChildren.indexOf(child);
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017-present, Facebook, Inc.
|
* Copyright (c) 2017-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
167
java/com/facebook/yoga/YogaNodeProperties.java
Normal file
167
java/com/facebook/yoga/YogaNodeProperties.java
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.facebook.yoga;
|
||||||
|
|
||||||
|
public interface YogaNodeProperties {
|
||||||
|
|
||||||
|
YogaNodeProperties clone(YogaNode node);
|
||||||
|
|
||||||
|
long getNativePointer();
|
||||||
|
|
||||||
|
void onAfterCalculateLayout();
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
boolean hasNewLayout();
|
||||||
|
|
||||||
|
boolean isDirty();
|
||||||
|
|
||||||
|
void markLayoutSeen();
|
||||||
|
|
||||||
|
YogaDirection getStyleDirection();
|
||||||
|
|
||||||
|
void setDirection(YogaDirection direction);
|
||||||
|
|
||||||
|
YogaFlexDirection getFlexDirection();
|
||||||
|
|
||||||
|
void setFlexDirection(YogaFlexDirection flexDirection);
|
||||||
|
|
||||||
|
YogaJustify getJustifyContent();
|
||||||
|
|
||||||
|
void setJustifyContent(YogaJustify justifyContent);
|
||||||
|
|
||||||
|
YogaAlign getAlignItems();
|
||||||
|
|
||||||
|
void setAlignItems(YogaAlign alignItems);
|
||||||
|
|
||||||
|
YogaAlign getAlignSelf();
|
||||||
|
|
||||||
|
void setAlignSelf(YogaAlign alignSelf);
|
||||||
|
|
||||||
|
YogaAlign getAlignContent();
|
||||||
|
|
||||||
|
void setAlignContent(YogaAlign alignContent);
|
||||||
|
|
||||||
|
YogaPositionType getPositionType();
|
||||||
|
|
||||||
|
void setPositionType(YogaPositionType positionType);
|
||||||
|
|
||||||
|
void setWrap(YogaWrap flexWrap);
|
||||||
|
|
||||||
|
YogaOverflow getOverflow();
|
||||||
|
|
||||||
|
void setOverflow(YogaOverflow overflow);
|
||||||
|
|
||||||
|
YogaDisplay getDisplay();
|
||||||
|
|
||||||
|
void setDisplay(YogaDisplay display);
|
||||||
|
|
||||||
|
void setFlex(float flex);
|
||||||
|
|
||||||
|
float getFlexGrow();
|
||||||
|
|
||||||
|
void setFlexGrow(float flexGrow);
|
||||||
|
|
||||||
|
float getFlexShrink();
|
||||||
|
|
||||||
|
void setFlexShrink(float flexShrink);
|
||||||
|
|
||||||
|
YogaValue getFlexBasis();
|
||||||
|
|
||||||
|
void setFlexBasis(float flexBasis);
|
||||||
|
|
||||||
|
void setFlexBasisPercent(float percent);
|
||||||
|
|
||||||
|
void setFlexBasisAuto();
|
||||||
|
|
||||||
|
YogaValue getMargin(YogaEdge edge);
|
||||||
|
|
||||||
|
void setMargin(YogaEdge edge, float margin);
|
||||||
|
|
||||||
|
void setMarginPercent(YogaEdge edge, float percent);
|
||||||
|
|
||||||
|
void setMarginAuto(YogaEdge edge);
|
||||||
|
|
||||||
|
YogaValue getPadding(YogaEdge edge);
|
||||||
|
|
||||||
|
void setPadding(YogaEdge edge, float padding);
|
||||||
|
|
||||||
|
void setPaddingPercent(YogaEdge edge, float percent);
|
||||||
|
|
||||||
|
float getBorder(YogaEdge edge);
|
||||||
|
|
||||||
|
void setBorder(YogaEdge edge, float border);
|
||||||
|
|
||||||
|
YogaValue getPosition(YogaEdge edge);
|
||||||
|
|
||||||
|
void setPosition(YogaEdge edge, float position);
|
||||||
|
|
||||||
|
void setPositionPercent(YogaEdge edge, float percent);
|
||||||
|
|
||||||
|
YogaValue getWidth();
|
||||||
|
|
||||||
|
void setWidth(float width);
|
||||||
|
|
||||||
|
void setWidthPercent(float percent);
|
||||||
|
|
||||||
|
void setWidthAuto();
|
||||||
|
|
||||||
|
YogaValue getHeight();
|
||||||
|
|
||||||
|
void setHeight(float height);
|
||||||
|
|
||||||
|
void setHeightPercent(float percent);
|
||||||
|
|
||||||
|
void setHeightAuto();
|
||||||
|
|
||||||
|
YogaValue getMinWidth();
|
||||||
|
|
||||||
|
void setMinWidth(float minWidth);
|
||||||
|
|
||||||
|
void setMinWidthPercent(float percent);
|
||||||
|
|
||||||
|
YogaValue getMinHeight();
|
||||||
|
|
||||||
|
void setMinHeight(float minHeight);
|
||||||
|
|
||||||
|
void setMinHeightPercent(float percent);
|
||||||
|
|
||||||
|
YogaValue getMaxWidth();
|
||||||
|
|
||||||
|
void setMaxWidth(float maxWidth);
|
||||||
|
|
||||||
|
void setMaxWidthPercent(float percent);
|
||||||
|
|
||||||
|
YogaValue getMaxHeight();
|
||||||
|
|
||||||
|
void setMaxHeight(float maxheight);
|
||||||
|
|
||||||
|
void setMaxHeightPercent(float percent);
|
||||||
|
|
||||||
|
float getAspectRatio();
|
||||||
|
|
||||||
|
void setAspectRatio(float aspectRatio);
|
||||||
|
|
||||||
|
float getLayoutX();
|
||||||
|
|
||||||
|
float getLayoutY();
|
||||||
|
|
||||||
|
float getLayoutWidth();
|
||||||
|
|
||||||
|
float getLayoutHeight();
|
||||||
|
|
||||||
|
boolean getDoesLegacyStretchFlagAffectsLayout();
|
||||||
|
|
||||||
|
float getLayoutMargin(YogaEdge edge);
|
||||||
|
|
||||||
|
float getLayoutPadding(YogaEdge edge);
|
||||||
|
|
||||||
|
float getLayoutBorder(YogaEdge edge);
|
||||||
|
|
||||||
|
YogaDirection getLayoutDirection();
|
||||||
|
}
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fb/fbjni.h>
|
#include <fb/fbjni.h>
|
||||||
#include <yoga/YGNode.h>
|
#include <yoga/YGNode.h>
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
@@ -33,94 +33,121 @@ 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) {
|
||||||
if (root->getHasNewLayout()) {
|
if (!root->getHasNewLayout()) {
|
||||||
if (auto obj = YGNodeJobject(root)->lockLocal()) {
|
return;
|
||||||
static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
|
}
|
||||||
static auto heightField = obj->getClass()->getField<jfloat>("mHeight");
|
auto obj = YGNodeJobject(root)->lockLocal();
|
||||||
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
|
if (!obj) {
|
||||||
static auto topField = obj->getClass()->getField<jfloat>("mTop");
|
YGLog(
|
||||||
|
root,
|
||||||
|
YGLogLevelError,
|
||||||
|
"Java YGNode was GCed during layout calculation\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static auto marginLeftField = obj->getClass()->getField<jfloat>("mMarginLeft");
|
static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
|
||||||
static auto marginTopField = obj->getClass()->getField<jfloat>("mMarginTop");
|
static auto heightField = obj->getClass()->getField<jfloat>("mHeight");
|
||||||
static auto marginRightField = obj->getClass()->getField<jfloat>("mMarginRight");
|
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
|
||||||
static auto marginBottomField = obj->getClass()->getField<jfloat>("mMarginBottom");
|
static auto topField = obj->getClass()->getField<jfloat>("mTop");
|
||||||
|
|
||||||
static auto paddingLeftField = obj->getClass()->getField<jfloat>("mPaddingLeft");
|
static auto marginLeftField =
|
||||||
static auto paddingTopField = obj->getClass()->getField<jfloat>("mPaddingTop");
|
obj->getClass()->getField<jfloat>("mMarginLeft");
|
||||||
static auto paddingRightField = obj->getClass()->getField<jfloat>("mPaddingRight");
|
static auto marginTopField = obj->getClass()->getField<jfloat>("mMarginTop");
|
||||||
static auto paddingBottomField = obj->getClass()->getField<jfloat>("mPaddingBottom");
|
static auto marginRightField =
|
||||||
|
obj->getClass()->getField<jfloat>("mMarginRight");
|
||||||
|
static auto marginBottomField =
|
||||||
|
obj->getClass()->getField<jfloat>("mMarginBottom");
|
||||||
|
|
||||||
static auto borderLeftField = obj->getClass()->getField<jfloat>("mBorderLeft");
|
static auto paddingLeftField =
|
||||||
static auto borderTopField = obj->getClass()->getField<jfloat>("mBorderTop");
|
obj->getClass()->getField<jfloat>("mPaddingLeft");
|
||||||
static auto borderRightField = obj->getClass()->getField<jfloat>("mBorderRight");
|
static auto paddingTopField =
|
||||||
static auto borderBottomField = obj->getClass()->getField<jfloat>("mBorderBottom");
|
obj->getClass()->getField<jfloat>("mPaddingTop");
|
||||||
|
static auto paddingRightField =
|
||||||
|
obj->getClass()->getField<jfloat>("mPaddingRight");
|
||||||
|
static auto paddingBottomField =
|
||||||
|
obj->getClass()->getField<jfloat>("mPaddingBottom");
|
||||||
|
|
||||||
static auto edgeSetFlagField = obj->getClass()->getField<jint>("mEdgeSetFlag");
|
static auto borderLeftField =
|
||||||
static auto hasNewLayoutField = obj->getClass()->getField<jboolean>("mHasNewLayout");
|
obj->getClass()->getField<jfloat>("mBorderLeft");
|
||||||
static auto doesLegacyStretchBehaviour =
|
static auto borderTopField = obj->getClass()->getField<jfloat>("mBorderTop");
|
||||||
obj->getClass()->getField<jboolean>(
|
static auto borderRightField =
|
||||||
"mDoesLegacyStretchFlagAffectsLayout");
|
obj->getClass()->getField<jfloat>("mBorderRight");
|
||||||
|
static auto borderBottomField =
|
||||||
|
obj->getClass()->getField<jfloat>("mBorderBottom");
|
||||||
|
|
||||||
/* Those flags needs be in sync with YogaNode.java */
|
static auto edgeSetFlagField =
|
||||||
const int MARGIN = 1;
|
obj->getClass()->getField<jint>("mEdgeSetFlag");
|
||||||
const int PADDING = 2;
|
static auto hasNewLayoutField =
|
||||||
const int BORDER = 4;
|
obj->getClass()->getField<jboolean>("mHasNewLayout");
|
||||||
|
static auto doesLegacyStretchBehaviour = obj->getClass()->getField<jboolean>(
|
||||||
|
"mDoesLegacyStretchFlagAffectsLayout");
|
||||||
|
|
||||||
int hasEdgeSetFlag = (int) obj->getFieldValue(edgeSetFlagField);
|
/* Those flags needs be in sync with YogaNode.java */
|
||||||
|
const int MARGIN = 1;
|
||||||
|
const int PADDING = 2;
|
||||||
|
const int BORDER = 4;
|
||||||
|
|
||||||
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
|
int hasEdgeSetFlag = (int)obj->getFieldValue(edgeSetFlagField);
|
||||||
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
|
|
||||||
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
|
|
||||||
obj->setFieldValue(topField, YGNodeLayoutGetTop(root));
|
|
||||||
obj->setFieldValue<jboolean>(
|
|
||||||
doesLegacyStretchBehaviour,
|
|
||||||
YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(root));
|
|
||||||
|
|
||||||
if ((hasEdgeSetFlag & MARGIN) == MARGIN) {
|
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
|
||||||
obj->setFieldValue(
|
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
|
||||||
marginLeftField, YGNodeLayoutGetMargin(root, YGEdgeLeft));
|
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
|
||||||
obj->setFieldValue(
|
obj->setFieldValue(topField, YGNodeLayoutGetTop(root));
|
||||||
marginTopField, YGNodeLayoutGetMargin(root, YGEdgeTop));
|
obj->setFieldValue<jboolean>(
|
||||||
obj->setFieldValue(
|
doesLegacyStretchBehaviour,
|
||||||
marginRightField, YGNodeLayoutGetMargin(root, YGEdgeRight));
|
YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(root));
|
||||||
obj->setFieldValue(
|
|
||||||
marginBottomField, YGNodeLayoutGetMargin(root, YGEdgeBottom));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((hasEdgeSetFlag & PADDING) == PADDING) {
|
if ((hasEdgeSetFlag & MARGIN) == MARGIN) {
|
||||||
obj->setFieldValue(paddingLeftField, YGNodeLayoutGetPadding(root, YGEdgeLeft));
|
obj->setFieldValue(
|
||||||
obj->setFieldValue(paddingTopField, YGNodeLayoutGetPadding(root, YGEdgeTop));
|
marginLeftField, YGNodeLayoutGetMargin(root, YGEdgeLeft));
|
||||||
obj->setFieldValue(paddingRightField, YGNodeLayoutGetPadding(root, YGEdgeRight));
|
obj->setFieldValue(marginTopField, YGNodeLayoutGetMargin(root, YGEdgeTop));
|
||||||
obj->setFieldValue(paddingBottomField, YGNodeLayoutGetPadding(root, YGEdgeBottom));
|
obj->setFieldValue(
|
||||||
}
|
marginRightField, YGNodeLayoutGetMargin(root, YGEdgeRight));
|
||||||
|
obj->setFieldValue(
|
||||||
|
marginBottomField, YGNodeLayoutGetMargin(root, YGEdgeBottom));
|
||||||
|
}
|
||||||
|
|
||||||
if ((hasEdgeSetFlag & BORDER) == BORDER) {
|
if ((hasEdgeSetFlag & PADDING) == PADDING) {
|
||||||
obj->setFieldValue(borderLeftField, YGNodeLayoutGetBorder(root, YGEdgeLeft));
|
obj->setFieldValue(
|
||||||
obj->setFieldValue(borderTopField, YGNodeLayoutGetBorder(root, YGEdgeTop));
|
paddingLeftField, YGNodeLayoutGetPadding(root, YGEdgeLeft));
|
||||||
obj->setFieldValue(borderRightField, YGNodeLayoutGetBorder(root, YGEdgeRight));
|
obj->setFieldValue(
|
||||||
obj->setFieldValue(borderBottomField, YGNodeLayoutGetBorder(root, YGEdgeBottom));
|
paddingTopField, YGNodeLayoutGetPadding(root, YGEdgeTop));
|
||||||
}
|
obj->setFieldValue(
|
||||||
|
paddingRightField, YGNodeLayoutGetPadding(root, YGEdgeRight));
|
||||||
|
obj->setFieldValue(
|
||||||
|
paddingBottomField, YGNodeLayoutGetPadding(root, YGEdgeBottom));
|
||||||
|
}
|
||||||
|
|
||||||
obj->setFieldValue<jboolean>(hasNewLayoutField, true);
|
if ((hasEdgeSetFlag & BORDER) == BORDER) {
|
||||||
YGTransferLayoutDirection(root, obj);
|
obj->setFieldValue(
|
||||||
root->setHasNewLayout(false);
|
borderLeftField, YGNodeLayoutGetBorder(root, YGEdgeLeft));
|
||||||
|
obj->setFieldValue(borderTopField, YGNodeLayoutGetBorder(root, YGEdgeTop));
|
||||||
|
obj->setFieldValue(
|
||||||
|
borderRightField, YGNodeLayoutGetBorder(root, YGEdgeRight));
|
||||||
|
obj->setFieldValue(
|
||||||
|
borderBottomField, YGNodeLayoutGetBorder(root, YGEdgeBottom));
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) {
|
obj->setFieldValue<jboolean>(hasNewLayoutField, true);
|
||||||
YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i));
|
YGTransferLayoutDirection(root, obj);
|
||||||
}
|
root->setHasNewLayout(false);
|
||||||
} else {
|
|
||||||
YGLog(root, YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) {
|
||||||
}
|
YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,14 +155,18 @@ 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 =
|
||||||
->getMethod<jfloat(jfloat, jfloat)>("baseline");
|
findClassStatic("com/facebook/yoga/YogaNode")
|
||||||
|
->getMethod<jfloat(jfloat, jfloat)>("baseline");
|
||||||
return baselineFunc(obj, width, height);
|
return baselineFunc(obj, width, height);
|
||||||
} else {
|
} else {
|
||||||
return height;
|
return height;
|
||||||
@@ -150,20 +181,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 =
|
||||||
->getMethod<alias_ref<JYogaNode>(
|
findClassStatic("com/facebook/yoga/YogaConfig")
|
||||||
local_ref<JYogaNode>,
|
->getMethod<alias_ref<JYogaNode>(
|
||||||
local_ref<JYogaNode>,
|
local_ref<JYogaNode>, local_ref<JYogaNode>, jint)>("cloneNode");
|
||||||
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 +202,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 +219,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 =
|
||||||
->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
|
findClassStatic("com/facebook/yoga/YogaNode")
|
||||||
|
->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(
|
||||||
"Expected measureResult to be 8 bytes, or two 32 bit ints");
|
sizeof(measureResult) == 8,
|
||||||
|
"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,24 +254,28 @@ 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 YGNodeRef node,
|
const YGConfigRef config,
|
||||||
YGLogLevel level,
|
const YGNodeRef node,
|
||||||
const char *format,
|
YGLogLevel level,
|
||||||
va_list args) {
|
const char* format,
|
||||||
|
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);
|
||||||
vsnprintf(buffer.data(), buffer.size(), format, args);
|
vsnprintf(buffer.data(), buffer.size(), format, args);
|
||||||
|
|
||||||
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,
|
||||||
@@ -268,6 +303,16 @@ jlong jni_YGNodeNewWithConfig(alias_ref<jobject> thiz, jlong configPointer) {
|
|||||||
return reinterpret_cast<jlong>(node);
|
return reinterpret_cast<jlong>(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void jni_YGNodeSetOwner(
|
||||||
|
alias_ref<jobject> thiz,
|
||||||
|
jlong nativePointer,
|
||||||
|
jlong newOwnerNativePointer) {
|
||||||
|
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
||||||
|
const YGNodeRef newOwnerNode = _jlong2YGNodeRef(newOwnerNativePointer);
|
||||||
|
|
||||||
|
node->setOwner(newOwnerNode);
|
||||||
|
}
|
||||||
|
|
||||||
jlong jni_YGNodeClone(
|
jlong jni_YGNodeClone(
|
||||||
alias_ref<jobject> thiz,
|
alias_ref<jobject> thiz,
|
||||||
jlong nativePointer,
|
jlong nativePointer,
|
||||||
@@ -299,13 +344,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(
|
||||||
@@ -317,19 +368,25 @@ 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(
|
||||||
jlong nativePointer,
|
alias_ref<jobject>,
|
||||||
jfloat width,
|
jlong nativePointer,
|
||||||
jfloat height) {
|
jfloat width,
|
||||||
|
jfloat height) {
|
||||||
const YGNodeRef root = _jlong2YGNodeRef(nativePointer);
|
const YGNodeRef root = _jlong2YGNodeRef(nativePointer);
|
||||||
YGNodeCalculateLayout(root,
|
YGNodeCalculateLayout(
|
||||||
static_cast<float>(width),
|
root,
|
||||||
static_cast<float>(height),
|
static_cast<float>(width),
|
||||||
YGNodeStyleGetDirection(_jlong2YGNodeRef(nativePointer)));
|
static_cast<float>(height),
|
||||||
|
YGNodeStyleGetDirection(_jlong2YGNodeRef(nativePointer)));
|
||||||
YGTransferLayoutOutputsRecursive(root);
|
YGTransferLayoutOutputsRecursive(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,20 +404,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(
|
||||||
jlong nativePointer,
|
alias_ref<jobject>,
|
||||||
jboolean hasBaselineFunc) {
|
jlong nativePointer,
|
||||||
|
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> {
|
||||||
@@ -382,67 +447,76 @@ struct JYogaValue : public JavaClass<JYogaValue> {
|
|||||||
_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
|
_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#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) { \
|
} \
|
||||||
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
|
\
|
||||||
} \
|
void jni_YGNodeStyleSet##name( \
|
||||||
\
|
alias_ref<jobject>, jlong nativePointer, jfloat value) { \
|
||||||
void jni_YGNodeStyleSet##name##Percent(alias_ref<jobject>, jlong nativePointer, jfloat value) { \
|
YGNodeStyleSet##name( \
|
||||||
YGNodeStyleSet##name##Percent(_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
|
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
void jni_YGNodeStyleSet##name##Percent( \
|
||||||
|
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( \
|
||||||
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
|
alias_ref<jobject>, jlong 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>, \
|
\
|
||||||
jlong nativePointer, \
|
void jni_YGNodeStyleSet##name( \
|
||||||
jint edge, \
|
alias_ref<jobject>, jlong nativePointer, jint edge, javatype value) { \
|
||||||
javatype value) { \
|
YGNodeStyleSet##name( \
|
||||||
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), \
|
_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( \
|
||||||
void jni_YGNodeStyleSet##name(alias_ref<jobject>, jlong nativePointer, jint edge, jfloat value) { \
|
alias_ref<jobject>, jlong nativePointer, jint edge, jfloat value) { \
|
||||||
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), \
|
YGNodeStyleSet##name( \
|
||||||
static_cast<YGEdge>(edge), \
|
_jlong2YGNodeRef(nativePointer), \
|
||||||
static_cast<float>(value)); \
|
static_cast<YGEdge>(edge), \
|
||||||
} \
|
static_cast<float>(value)); \
|
||||||
\
|
} \
|
||||||
void jni_YGNodeStyleSet##name##Percent(alias_ref<jobject>, \
|
\
|
||||||
jlong nativePointer, \
|
void jni_YGNodeStyleSet##name##Percent( \
|
||||||
jint edge, \
|
alias_ref<jobject>, jlong nativePointer, 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)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#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);
|
||||||
@@ -456,8 +530,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);
|
||||||
@@ -491,14 +569,14 @@ void jni_YGConfigFree(alias_ref<jobject>, jlong nativePointer) {
|
|||||||
YGConfigFree(config);
|
YGConfigFree(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGConfigSetExperimentalFeatureEnabled(alias_ref<jobject>,
|
void jni_YGConfigSetExperimentalFeatureEnabled(
|
||||||
jlong nativePointer,
|
alias_ref<jobject>,
|
||||||
jint feature,
|
jlong nativePointer,
|
||||||
jboolean enabled) {
|
jint feature,
|
||||||
|
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(
|
||||||
@@ -509,23 +587,26 @@ void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
|||||||
YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(config, enabled);
|
YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(config, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGConfigSetUseWebDefaults(alias_ref<jobject>,
|
void jni_YGConfigSetUseWebDefaults(
|
||||||
jlong nativePointer,
|
alias_ref<jobject>,
|
||||||
jboolean useWebDefaults) {
|
jlong nativePointer,
|
||||||
|
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(
|
||||||
jlong nativePointer,
|
alias_ref<jobject>,
|
||||||
jfloat pixelsInPoint) {
|
jlong nativePointer,
|
||||||
|
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(
|
||||||
jlong nativePointer,
|
alias_ref<jobject>,
|
||||||
jboolean useLegacyStretchBehaviour) {
|
jlong nativePointer,
|
||||||
|
jboolean useLegacyStretchBehaviour) {
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||||
YGConfigSetUseLegacyStretchBehaviour(config, useLegacyStretchBehaviour);
|
YGConfigSetUseLegacyStretchBehaviour(config, useLegacyStretchBehaviour);
|
||||||
}
|
}
|
||||||
@@ -582,7 +663,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",
|
||||||
@@ -667,6 +748,7 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
|
|||||||
YGMakeNativeMethod(jni_YGNodeGetInstanceCount),
|
YGMakeNativeMethod(jni_YGNodeGetInstanceCount),
|
||||||
YGMakeNativeMethod(jni_YGNodePrint),
|
YGMakeNativeMethod(jni_YGNodePrint),
|
||||||
YGMakeNativeMethod(jni_YGNodeClone),
|
YGMakeNativeMethod(jni_YGNodeClone),
|
||||||
|
YGMakeNativeMethod(jni_YGNodeSetOwner),
|
||||||
});
|
});
|
||||||
registerNatives(
|
registerNatives(
|
||||||
"com/facebook/yoga/YogaConfig",
|
"com/facebook/yoga/YogaConfig",
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "YOGA_ROOTS", "java_library")
|
load("//:yoga_defs.bzl", "YOGA_ROOTS", "yoga_java_library")
|
||||||
|
|
||||||
java_library(
|
yoga_java_library(
|
||||||
name = "annotations",
|
name = "annotations",
|
||||||
srcs = glob(["*.java"]),
|
srcs = glob(["*.java"]),
|
||||||
source = "1.7",
|
source = "1.7",
|
||||||
|
@@ -61,7 +61,7 @@ for (let [name, results] of testResults) {
|
|||||||
|
|
||||||
for (let [type, result] of results) {
|
for (let [type, result] of results) {
|
||||||
console.log(
|
console.log(
|
||||||
` - ${type}: ${result}ms (${Math.round(result / min * 10000) / 100}%)`,
|
` - ${type}: ${result}ms (${Math.round((result / min) * 10000) / 100}%)`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "YOGA_ROOTS", "prebuilt_jar")
|
load("//:yoga_defs.bzl", "YOGA_ROOTS", "yoga_prebuilt_jar")
|
||||||
|
|
||||||
prebuilt_jar(
|
yoga_prebuilt_jar(
|
||||||
name = "android-support",
|
name = "android-support",
|
||||||
binary_jar = "android-support-v4.jar",
|
binary_jar = "android-support-v4.jar",
|
||||||
visibility = YOGA_ROOTS,
|
visibility = YOGA_ROOTS,
|
||||||
|
@@ -2,10 +2,9 @@
|
|||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
load("//:yoga_defs.bzl", "ANDROID", "FBJNI_JAVA_TARGET", "JNI_TARGET", "YOGA_ROOTS", "subdir_glob", "yoga_cxx_library", "yoga_prebuilt_cxx_library")
|
||||||
|
|
||||||
include_defs("//yoga_defs.bzl")
|
yoga_prebuilt_cxx_library(
|
||||||
|
|
||||||
prebuilt_cxx_library(
|
|
||||||
name = "ndklog",
|
name = "ndklog",
|
||||||
exported_platform_linker_flags = [
|
exported_platform_linker_flags = [
|
||||||
(
|
(
|
||||||
@@ -17,7 +16,7 @@ prebuilt_cxx_library(
|
|||||||
visibility = YOGA_ROOTS,
|
visibility = YOGA_ROOTS,
|
||||||
)
|
)
|
||||||
|
|
||||||
cxx_library(
|
yoga_cxx_library(
|
||||||
name = "fbjni",
|
name = "fbjni",
|
||||||
srcs = glob(["src/main/cpp/**/*.cpp"]),
|
srcs = glob(["src/main/cpp/**/*.cpp"]),
|
||||||
header_namespace = "",
|
header_namespace = "",
|
||||||
@@ -35,6 +34,7 @@ cxx_library(
|
|||||||
"-Wno-unused-parameter",
|
"-Wno-unused-parameter",
|
||||||
"-std=c++11",
|
"-std=c++11",
|
||||||
],
|
],
|
||||||
|
platforms = (ANDROID,),
|
||||||
visibility = ["PUBLIC"],
|
visibility = ["PUBLIC"],
|
||||||
deps = [
|
deps = [
|
||||||
":ndklog",
|
":ndklog",
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "JSR_305_TARGET", "java_library")
|
load("//:yoga_defs.bzl", "JSR_305_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "yoga_java_library")
|
||||||
|
|
||||||
java_library(
|
yoga_java_library(
|
||||||
name = "jni",
|
name = "jni",
|
||||||
srcs = glob(["**/*.java"]),
|
srcs = glob(["**/*.java"]),
|
||||||
proguard_config = "fbjni.pro",
|
proguard_config = "fbjni.pro",
|
||||||
|
@@ -2,15 +2,14 @@
|
|||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
load("//:yoga_defs.bzl", "YOGA_ROOTS", "subdir_glob", "yoga_cxx_library")
|
||||||
load("//:yoga_defs.bzl", "cxx_library", "YOGA_ROOTS")
|
|
||||||
|
|
||||||
COMPILER_FLAGS = [
|
COMPILER_FLAGS = [
|
||||||
"-std=c++11",
|
"-std=c++11",
|
||||||
"-Wno-missing-prototypes",
|
"-Wno-missing-prototypes",
|
||||||
]
|
]
|
||||||
|
|
||||||
cxx_library(
|
yoga_cxx_library(
|
||||||
name = "gtest",
|
name = "gtest",
|
||||||
srcs = glob(["googletest/googletest/src/*.cc"]),
|
srcs = glob(["googletest/googletest/src/*.cc"]),
|
||||||
header_namespace = "",
|
header_namespace = "",
|
||||||
|
@@ -3,17 +3,17 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "YOGA_ROOTS", "prebuilt_jar", "java_library")
|
load("//:yoga_defs.bzl", "YOGA_ROOTS", "yoga_java_library", "yoga_prebuilt_jar")
|
||||||
|
|
||||||
prebuilt_jar(
|
yoga_prebuilt_jar(
|
||||||
name = "infer-annotations-jar",
|
name = "infer-annotations-jar",
|
||||||
binary_jar = "infer-annotations-1.4.jar",
|
binary_jar = "infer-annotations-1.4.jar",
|
||||||
)
|
)
|
||||||
|
|
||||||
java_library(
|
yoga_java_library(
|
||||||
name = "infer-annotations",
|
name = "infer-annotations",
|
||||||
|
visibility = YOGA_ROOTS,
|
||||||
exported_deps = [
|
exported_deps = [
|
||||||
":infer-annotations-jar",
|
":infer-annotations-jar",
|
||||||
],
|
],
|
||||||
visibility = YOGA_ROOTS,
|
|
||||||
)
|
)
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "cxx_library")
|
load("//:yoga_defs.bzl", "yoga_cxx_library")
|
||||||
|
|
||||||
cxx_library(
|
yoga_cxx_library(
|
||||||
name = "jni",
|
name = "jni",
|
||||||
header_namespace = "",
|
header_namespace = "",
|
||||||
exported_headers = [
|
exported_headers = [
|
||||||
|
@@ -3,17 +3,17 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "YOGA_ROOTS", "prebuilt_jar", "java_library")
|
load("//:yoga_defs.bzl", "YOGA_ROOTS", "yoga_java_library", "yoga_prebuilt_jar")
|
||||||
|
|
||||||
prebuilt_jar(
|
yoga_prebuilt_jar(
|
||||||
name = "jsr305-jar",
|
name = "jsr305-jar",
|
||||||
binary_jar = "jsr305.jar",
|
binary_jar = "jsr305.jar",
|
||||||
)
|
)
|
||||||
|
|
||||||
java_library(
|
yoga_java_library(
|
||||||
name = "jsr-305",
|
name = "jsr-305",
|
||||||
|
visibility = YOGA_ROOTS,
|
||||||
exported_deps = [
|
exported_deps = [
|
||||||
":jsr305-jar",
|
":jsr305-jar",
|
||||||
],
|
],
|
||||||
visibility = YOGA_ROOTS,
|
|
||||||
)
|
)
|
||||||
|
@@ -3,17 +3,17 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "YOGA_ROOTS", "prebuilt_jar", "java_library")
|
load("//:yoga_defs.bzl", "YOGA_ROOTS", "yoga_java_library", "yoga_prebuilt_jar")
|
||||||
|
|
||||||
prebuilt_jar(
|
yoga_prebuilt_jar(
|
||||||
name = "junit-jar",
|
name = "junit-jar",
|
||||||
binary_jar = "junit4.jar",
|
binary_jar = "junit4.jar",
|
||||||
)
|
)
|
||||||
|
|
||||||
java_library(
|
yoga_java_library(
|
||||||
name = "junit",
|
name = "junit",
|
||||||
|
visibility = YOGA_ROOTS,
|
||||||
exported_deps = [
|
exported_deps = [
|
||||||
":junit-jar",
|
":junit-jar",
|
||||||
],
|
],
|
||||||
visibility = YOGA_ROOTS,
|
|
||||||
)
|
)
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
|
set -e
|
||||||
|
|
||||||
function download() {
|
function download() {
|
||||||
echo "Downloading '$1' to '$2' ..."
|
|
||||||
if hash curl 2>/dev/null; then
|
if hash curl 2>/dev/null; then
|
||||||
curl --retry 10 -L -o "$2" "$1"
|
curl -s -L -o "$2" "$1"
|
||||||
elif hash wget 2>/dev/null; then
|
elif hash wget 2>/dev/null; then
|
||||||
wget -O "$2" "$1"
|
wget -O "$2" "$1"
|
||||||
else
|
else
|
||||||
@@ -12,38 +13,38 @@ function download() {
|
|||||||
|
|
||||||
function installsdk() {
|
function installsdk() {
|
||||||
PROXY_ARGS=""
|
PROXY_ARGS=""
|
||||||
if [[ ! -z "$https_proxy" ]]; then
|
if [[ ! -z "$HTTPS_PROXY" ]]; then
|
||||||
PROXY_HOST="$(cut -d : "$https_proxy" -f 1,1)"
|
PROXY_HOST="$(echo $HTTPS_PROXY | cut -d : -f 1,1)"
|
||||||
PROXY_PORT="$(cut -d : "$https_proxy" -f 2,2)"
|
PROXY_PORT="$(echo $HTTPS_PROXY | cut -d : -f 2,2)"
|
||||||
PROXY_ARGS="--proxy=http --proxy_host=$PROXY_HOST --proxy_port=$PROXY_PORT"
|
PROXY_ARGS="--proxy=http --proxy_host=$PROXY_HOST --proxy_port=$PROXY_PORT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
yes | "$ANDROID_HOME/tools/bin/sdkmanager" $PROXY_ARGS $@
|
echo y | "$ANDROID_HOME"/tools/bin/sdkmanager $PROXY_ARGS "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function installAndroidSDK {
|
function installAndroidSDK {
|
||||||
export ANDROID_HOME=$HOME/android-sdk
|
if [[ ! -d "$HOME/android-sdk" ]]; then
|
||||||
export ANDROID_NDK_REPOSITORY=$HOME/android-ndk
|
|
||||||
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$PATH"
|
|
||||||
|
|
||||||
if [[ ! -f "$ANDROID_HOME/tools/bin/sdkmanager" ]]; then
|
|
||||||
TMP=/tmp/sdk$$.zip
|
TMP=/tmp/sdk$$.zip
|
||||||
download 'https://dl.google.com/android/repository/sdk-tools-darwin-3859397.zip' $TMP
|
download 'https://dl.google.com/android/repository/tools_r25.2.3-linux.zip' $TMP
|
||||||
unzip -qod "$ANDROID_HOME" "$TMP"
|
unzip -qod "$HOME/android-sdk" $TMP
|
||||||
rm $TMP
|
rm $TMP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
export ANDROID_NDK_REPOSITORY=$HOME/android-ndk
|
||||||
if [[ ! -d "$ANDROID_NDK_REPOSITORY/android-ndk-r15c" ]]; then
|
if [[ ! -d "$ANDROID_NDK_REPOSITORY/android-ndk-r15c" ]]; then
|
||||||
TMP=/tmp/ndk$$.zip
|
TMP=/tmp/ndk$$.zip
|
||||||
mkdir -p "$ANDROID_NDK_REPOSITORY"
|
mkdir -p "$ANDROID_NDK_REPOSITORY"
|
||||||
download 'https://dl.google.com/android/repository/android-ndk-r15c-darwin-x86_64.zip' $TMP
|
download 'https://dl.google.com/android/repository/android-ndk-r15c-linux-x86_64.zip' $TMP
|
||||||
unzip -qod "$ANDROID_NDK_REPOSITORY" "$TMP"
|
unzip -qod "$ANDROID_NDK_REPOSITORY" "$TMP"
|
||||||
rm $TMP
|
rm $TMP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$ANDROID_HOME/licenses/"
|
export ANDROID_HOME=$HOME/android-sdk
|
||||||
echo > "$ANDROID_HOME/licenses/android-sdk-license"
|
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$PATH"
|
||||||
echo -n d56f5187479451eabf01fb78af6dfcb131a6481e >> "$ANDROID_HOME/licenses/android-sdk-license"
|
|
||||||
|
|
||||||
installsdk 'build-tools;26.0.2' 'platform-tools' 'platforms;android-23' 'platforms;android-25' 'extras;android;m2repository'
|
mkdir -p $ANDROID_HOME/licenses/
|
||||||
|
echo > $ANDROID_HOME/licenses/android-sdk-license
|
||||||
|
echo -n d56f5187479451eabf01fb78af6dfcb131a6481e > $ANDROID_HOME/licenses/android-sdk-license
|
||||||
|
|
||||||
|
installsdk 'build-tools;25.0.3' 'build-tools;26.0.2' 'platforms;android-25' 'platforms;android-26' 'ndk-bundle' 'extras;android;m2repository'
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html
|
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
@@ -64,6 +64,90 @@ TEST(YogaTest, flex_basis_flex_grow_column) {
|
|||||||
YGConfigFree(config);
|
YGConfigFree(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, flex_shrink_flex_grow_row) {
|
||||||
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||||
|
YGNodeStyleSetWidth(root, 500);
|
||||||
|
YGNodeStyleSetHeight(root, 500);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexGrow(root_child0, 0);
|
||||||
|
YGNodeStyleSetFlexShrink(root_child0, 1);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 500);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 100);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexGrow(root_child1, 0);
|
||||||
|
YGNodeStyleSetFlexShrink(root_child1, 1);
|
||||||
|
YGNodeStyleSetWidth(root_child1, 500);
|
||||||
|
YGNodeStyleSetHeight(root_child1, 100);
|
||||||
|
YGNodeInsertChild(root, root_child1, 1);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child1));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
||||||
|
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child1));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, flex_shrink_flex_grow_child_flex_shrink_other_child) {
|
||||||
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||||
|
YGNodeStyleSetWidth(root, 500);
|
||||||
|
YGNodeStyleSetHeight(root, 500);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexGrow(root_child0, 0);
|
||||||
|
YGNodeStyleSetFlexShrink(root_child0, 1);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 500);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 100);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexGrow(root_child1, 1);
|
||||||
|
YGNodeStyleSetFlexShrink(root_child1, 1);
|
||||||
|
YGNodeStyleSetWidth(root_child1, 500);
|
||||||
|
YGNodeStyleSetHeight(root_child1, 100);
|
||||||
|
YGNodeInsertChild(root, root_child1, 1);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child1));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
||||||
|
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child1));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(YogaTest, flex_basis_flex_grow_row) {
|
TEST(YogaTest, flex_basis_flex_grow_row) {
|
||||||
const YGConfigRef config = YGConfigNew();
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <yoga/YGNode.h>
|
#include <yoga/YGNode.h>
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
@@ -5,8 +5,6 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html
|
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
|
12381
website/package-lock.json
generated
12381
website/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -4,21 +4,22 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
|
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"antd": "^3.2.0",
|
"antd": "^3.6.5",
|
||||||
"atob": "^2.0.3",
|
"atob": "^2.1.1",
|
||||||
"gatsby": "^1.9.158",
|
"btoa": "^1.2.1",
|
||||||
"gatsby-link": "^1.6.34",
|
"gatsby": "^1.9.273",
|
||||||
"gatsby-plugin-antd": "^1.0.10",
|
"gatsby-link": "^1.6.45",
|
||||||
"gatsby-plugin-google-analytics": "^1.0.19",
|
"gatsby-plugin-antd": "^1.0.12",
|
||||||
"gatsby-plugin-less": "^1.1.4",
|
"gatsby-plugin-google-analytics": "^1.0.31",
|
||||||
"gatsby-plugin-react-helmet": "^2.0.3",
|
"gatsby-plugin-less": "^1.1.8",
|
||||||
"gatsby-plugin-react-next": "^1.0.8",
|
"gatsby-plugin-react-helmet": "^2.0.11",
|
||||||
"gatsby-remark-prismjs": "^1.2.14",
|
"gatsby-plugin-react-next": "^1.0.11",
|
||||||
"gatsby-source-filesystem": "^1.5.18",
|
"gatsby-remark-prismjs": "^2.0.4",
|
||||||
"gatsby-transformer-remark": "^1.7.31",
|
"gatsby-source-filesystem": "^1.5.39",
|
||||||
|
"gatsby-transformer-remark": "^1.7.44",
|
||||||
"immutable": "^4.0.0-rc.9",
|
"immutable": "^4.0.0-rc.9",
|
||||||
"react-helmet": "^5.2.0",
|
"react-helmet": "^5.2.0",
|
||||||
"react-syntax-highlighter": "^7.0.0",
|
"react-syntax-highlighter": "^8.0.0",
|
||||||
"yoga-layout": "^1.9.3"
|
"yoga-layout": "^1.9.3"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -31,6 +32,6 @@
|
|||||||
"develop": "gatsby develop"
|
"develop": "gatsby develop"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier": "^1.10.2"
|
"prettier": "1.13.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,10 +10,12 @@
|
|||||||
|
|
||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
|
|
||||||
export default () => <svg viewBox="0 0 1133.9 1133.9">
|
export default () => (
|
||||||
<g>
|
<svg viewBox="0 0 1133.9 1133.9">
|
||||||
<path d="M 498.3 3.7 c 153.6 88.9 307.3 177.7 461.1 266.2 c 7.6 4.4 10.3 9.1 10.3 17.8 c -0.3 179.1 -0.2 358.3 0 537.4 c 0 8.1 -2.4 12.8 -9.7 17.1 c -154.5 88.9 -308.8 178.1 -462.9 267.5 c -9 5.2 -15.5 5.3 -24.6 0.1 c -153.9 -89.2 -307.9 -178 -462.1 -266.8 C 3 838.8 0 833.9 0 825.1 c 0.3 -179.1 0.2 -358.3 0 -537.4 c 0 -8.6 2.6 -13.6 10.2 -18 C 164.4 180.9 318.4 92 472.4 3 C 477 -1.5 494.3 -0.7 498.3 3.7 Z M 48.8 555.3 c 0 79.9 0.2 159.9 -0.2 239.8 c -0.1 10 3 15.6 11.7 20.6 c 137.2 78.8 274.2 157.8 411 237.3 c 9.9 5.7 17 5.7 26.8 0.1 c 137.5 -79.8 275.2 -159.2 412.9 -238.5 c 7.4 -4.3 10.5 -8.9 10.5 -17.8 c -0.3 -160.2 -0.3 -320.5 0 -480.7 c 0 -8.8 -2.8 -13.6 -10.3 -18 C 772.1 218 633.1 137.8 494.2 57.4 c -6.5 -3.8 -11.5 -4.5 -18.5 -0.5 C 336.8 137.4 197.9 217.7 58.8 297.7 c -7.7 4.4 -10.2 9.2 -10.2 17.9 C 48.9 395.5 48.8 475.4 48.8 555.3 Z" />
|
<g>
|
||||||
<path d="M 184.4 555.9 c 0 -33.3 -1 -66.7 0.3 -100 c 1.9 -48 24.1 -86 64.7 -110.9 c 54.8 -33.6 110.7 -65.5 167 -96.6 c 45.7 -25.2 92.9 -24.7 138.6 1 c 54.4 30.6 108.7 61.5 162.2 93.7 c 44 26.5 67.3 66.8 68 118.4 c 0.9 63.2 0.9 126.5 0 189.7 c -0.7 50.6 -23.4 90.7 -66.6 116.9 c -55 33.4 -110.8 65.4 -167.1 96.5 c -43.4 24 -89 24.2 -132.3 0.5 c -57.5 -31.3 -114.2 -64 -170 -98.3 c -41 -25.1 -62.9 -63.7 -64.5 -112.2 C 183.5 621.9 184.3 588.9 184.4 555.9 Z M 232.9 556.3 c 0 29.5 0.5 59.1 -0.1 88.6 c -0.8 39.2 16.9 67.1 50.2 86.2 c 51.2 29.4 102.2 59.2 153.4 88.4 c 31.4 17.9 63.6 18.3 95 0.6 c 53.7 -30.3 107.1 -61.2 160.3 -92.5 c 29.7 -17.5 45 -44.5 45.3 -78.8 c 0.6 -61.7 0.5 -123.5 0 -185.2 c -0.3 -34.4 -15.3 -61.5 -44.9 -79 C 637.7 352.6 583 320.8 527.9 290 c -27.5 -15.4 -57.2 -16.1 -84.7 -0.7 c -56.9 31.6 -113.4 64 -169.1 97.6 c -26.4 15.9 -40.7 41.3 -41.1 72.9 C 232.6 491.9 232.9 524.1 232.9 556.3 Z" />
|
<path d="M 498.3 3.7 c 153.6 88.9 307.3 177.7 461.1 266.2 c 7.6 4.4 10.3 9.1 10.3 17.8 c -0.3 179.1 -0.2 358.3 0 537.4 c 0 8.1 -2.4 12.8 -9.7 17.1 c -154.5 88.9 -308.8 178.1 -462.9 267.5 c -9 5.2 -15.5 5.3 -24.6 0.1 c -153.9 -89.2 -307.9 -178 -462.1 -266.8 C 3 838.8 0 833.9 0 825.1 c 0.3 -179.1 0.2 -358.3 0 -537.4 c 0 -8.6 2.6 -13.6 10.2 -18 C 164.4 180.9 318.4 92 472.4 3 C 477 -1.5 494.3 -0.7 498.3 3.7 Z M 48.8 555.3 c 0 79.9 0.2 159.9 -0.2 239.8 c -0.1 10 3 15.6 11.7 20.6 c 137.2 78.8 274.2 157.8 411 237.3 c 9.9 5.7 17 5.7 26.8 0.1 c 137.5 -79.8 275.2 -159.2 412.9 -238.5 c 7.4 -4.3 10.5 -8.9 10.5 -17.8 c -0.3 -160.2 -0.3 -320.5 0 -480.7 c 0 -8.8 -2.8 -13.6 -10.3 -18 C 772.1 218 633.1 137.8 494.2 57.4 c -6.5 -3.8 -11.5 -4.5 -18.5 -0.5 C 336.8 137.4 197.9 217.7 58.8 297.7 c -7.7 4.4 -10.2 9.2 -10.2 17.9 C 48.9 395.5 48.8 475.4 48.8 555.3 Z" />
|
||||||
<path d="M 484.9 424.4 c 69.8 -2.8 133.2 57.8 132.6 132 C 617 630 558.5 688.7 484.9 689.1 c -75.1 0.4 -132.6 -63.6 -132.7 -132.7 C 352.1 485 413.4 421.5 484.9 424.4 Z M 401.3 556.7 c -3.4 37.2 30.5 83.6 83 84.1 c 46.6 0.4 84.8 -37.6 84.9 -84 c 0.1 -46.6 -37.2 -84.4 -84.2 -84.6 C 432.2 472.1 397.9 518.3 401.3 556.7 Z" />
|
<path d="M 184.4 555.9 c 0 -33.3 -1 -66.7 0.3 -100 c 1.9 -48 24.1 -86 64.7 -110.9 c 54.8 -33.6 110.7 -65.5 167 -96.6 c 45.7 -25.2 92.9 -24.7 138.6 1 c 54.4 30.6 108.7 61.5 162.2 93.7 c 44 26.5 67.3 66.8 68 118.4 c 0.9 63.2 0.9 126.5 0 189.7 c -0.7 50.6 -23.4 90.7 -66.6 116.9 c -55 33.4 -110.8 65.4 -167.1 96.5 c -43.4 24 -89 24.2 -132.3 0.5 c -57.5 -31.3 -114.2 -64 -170 -98.3 c -41 -25.1 -62.9 -63.7 -64.5 -112.2 C 183.5 621.9 184.3 588.9 184.4 555.9 Z M 232.9 556.3 c 0 29.5 0.5 59.1 -0.1 88.6 c -0.8 39.2 16.9 67.1 50.2 86.2 c 51.2 29.4 102.2 59.2 153.4 88.4 c 31.4 17.9 63.6 18.3 95 0.6 c 53.7 -30.3 107.1 -61.2 160.3 -92.5 c 29.7 -17.5 45 -44.5 45.3 -78.8 c 0.6 -61.7 0.5 -123.5 0 -185.2 c -0.3 -34.4 -15.3 -61.5 -44.9 -79 C 637.7 352.6 583 320.8 527.9 290 c -27.5 -15.4 -57.2 -16.1 -84.7 -0.7 c -56.9 31.6 -113.4 64 -169.1 97.6 c -26.4 15.9 -40.7 41.3 -41.1 72.9 C 232.6 491.9 232.9 524.1 232.9 556.3 Z" />
|
||||||
</g>
|
<path d="M 484.9 424.4 c 69.8 -2.8 133.2 57.8 132.6 132 C 617 630 558.5 688.7 484.9 689.1 c -75.1 0.4 -132.6 -63.6 -132.7 -132.7 C 352.1 485 413.4 421.5 484.9 424.4 Z M 401.3 556.7 c -3.4 37.2 30.5 83.6 83 84.1 c 46.6 0.4 84.8 -37.6 84.9 -84 c 0.1 -46.6 -37.2 -84.4 -84.2 -84.6 C 432.2 472.1 397.9 518.3 401.3 556.7 Z" />
|
||||||
</svg>
|
</g>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
@@ -137,9 +137,9 @@ function getLayoutCode(
|
|||||||
)}\n${indent}\t},`,
|
)}\n${indent}\t},`,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
lines.push(indent + `}]${isRoot ? ';' : ''}`);
|
lines.push(indent + `}]${isRoot ? ';' : ','}`);
|
||||||
} else {
|
} else {
|
||||||
lines[lines.length - 1] += ']';
|
lines[lines.length - 1] += '],';
|
||||||
CKFlexboxComponentChild.forEach(key => {
|
CKFlexboxComponentChild.forEach(key => {
|
||||||
let line = renderKey(node, key, indent);
|
let line = renderKey(node, key, indent);
|
||||||
if (line) {
|
if (line) {
|
||||||
@@ -165,7 +165,7 @@ function renderKey(node: Yoga$Node, key: string, indent: string): ?string {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
['top', 'left', 'right', 'bottom'].forEach(pKey => {
|
['top', 'start', 'end', 'bottom'].forEach(pKey => {
|
||||||
if (node[key][pKey]) {
|
if (node[key][pKey]) {
|
||||||
lines.push(indent + `\t.${pKey} = ${getValue(node[key][pKey])},`);
|
lines.push(indent + `\t.${pKey} = ${getValue(node[key][pKey])},`);
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,9 @@ function dipOrPercent(value) {
|
|||||||
console.log(value);
|
console.log(value);
|
||||||
return value === 'auto'
|
return value === 'auto'
|
||||||
? 'Auto'
|
? 'Auto'
|
||||||
: typeof value === 'string' && /%$/.test(value) ? 'Percent' : 'Dip';
|
: typeof value === 'string' && /%$/.test(value)
|
||||||
|
? 'Percent'
|
||||||
|
: 'Dip';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValue(value) {
|
function getValue(value) {
|
||||||
|
@@ -33,7 +33,7 @@ export default (props: Props<*>) => {
|
|||||||
type="text"
|
type="text"
|
||||||
{...props}
|
{...props}
|
||||||
onChange={e => props.onChange(props.property, e.target.value)}
|
onChange={e => props.onChange(props.property, e.target.value)}
|
||||||
placeholder="undefined"
|
placeholder={props.placeholder || 'undefined'}
|
||||||
onFocus={e => e.target.select()}
|
onFocus={e => e.target.select()}
|
||||||
value={Number.isNaN(props.value) ? '' : props.value}
|
value={Number.isNaN(props.value) ? '' : props.value}
|
||||||
/>
|
/>
|
||||||
|
@@ -89,6 +89,7 @@ export default class Editor extends Component<Props> {
|
|||||||
<EditValue
|
<EditValue
|
||||||
type="text"
|
type="text"
|
||||||
property="flexBasis"
|
property="flexBasis"
|
||||||
|
placeholder="auto"
|
||||||
disabled={disabled || selectedNodeIsRoot}
|
disabled={disabled || selectedNodeIsRoot}
|
||||||
value={node ? node.flexBasis : undefined}
|
value={node ? node.flexBasis : undefined}
|
||||||
onChange={this.props.onChangeLayout}
|
onChange={this.props.onChangeLayout}
|
||||||
@@ -104,6 +105,7 @@ export default class Editor extends Component<Props> {
|
|||||||
<EditValue
|
<EditValue
|
||||||
type="text"
|
type="text"
|
||||||
property="flexGrow"
|
property="flexGrow"
|
||||||
|
placeholder="0"
|
||||||
disabled={disabled || selectedNodeIsRoot}
|
disabled={disabled || selectedNodeIsRoot}
|
||||||
value={node ? node.flexGrow : undefined}
|
value={node ? node.flexGrow : undefined}
|
||||||
onChange={this.props.onChangeLayout}
|
onChange={this.props.onChangeLayout}
|
||||||
@@ -120,6 +122,7 @@ export default class Editor extends Component<Props> {
|
|||||||
<EditValue
|
<EditValue
|
||||||
type="text"
|
type="text"
|
||||||
property="flexShrink"
|
property="flexShrink"
|
||||||
|
placeholder="1"
|
||||||
disabled={disabled || selectedNodeIsRoot}
|
disabled={disabled || selectedNodeIsRoot}
|
||||||
value={node ? node.flexShrink : undefined}
|
value={node ? node.flexShrink : undefined}
|
||||||
onChange={this.props.onChangeLayout}
|
onChange={this.props.onChangeLayout}
|
||||||
@@ -222,6 +225,62 @@ export default class Editor extends Component<Props> {
|
|||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
<h2>
|
||||||
|
Max-Width × Max-Height
|
||||||
|
<InfoText doclink="/docs/min-max">
|
||||||
|
Maximum dimensions of the node
|
||||||
|
</InfoText>
|
||||||
|
</h2>
|
||||||
|
<Row gutter={15}>
|
||||||
|
<Col span={12}>
|
||||||
|
<EditValue
|
||||||
|
type="text"
|
||||||
|
placeholder="none"
|
||||||
|
property="maxWidth"
|
||||||
|
disabled={disabled}
|
||||||
|
value={node ? node.maxWidth : undefined}
|
||||||
|
onChange={this.props.onChangeLayout}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
<Col span={12}>
|
||||||
|
<EditValue
|
||||||
|
type="text"
|
||||||
|
placeholder="none"
|
||||||
|
property="maxHeight"
|
||||||
|
disabled={disabled}
|
||||||
|
value={node ? node.maxHeight : undefined}
|
||||||
|
onChange={this.props.onChangeLayout}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<h2>
|
||||||
|
Min-Width × Min-Height
|
||||||
|
<InfoText doclink="/docs/min-max">
|
||||||
|
Minimum dimensions of the node
|
||||||
|
</InfoText>
|
||||||
|
</h2>
|
||||||
|
<Row gutter={15}>
|
||||||
|
<Col span={12}>
|
||||||
|
<EditValue
|
||||||
|
type="text"
|
||||||
|
placeholder="0"
|
||||||
|
property="minWidth"
|
||||||
|
disabled={disabled}
|
||||||
|
value={node ? node.minWidth : undefined}
|
||||||
|
onChange={this.props.onChangeLayout}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
<Col span={12}>
|
||||||
|
<EditValue
|
||||||
|
type="text"
|
||||||
|
placeholder="0"
|
||||||
|
property="minHeight"
|
||||||
|
disabled={disabled}
|
||||||
|
value={node ? node.minHeight : undefined}
|
||||||
|
onChange={this.props.onChangeLayout}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
<h2>
|
<h2>
|
||||||
Aspect Ratio
|
Aspect Ratio
|
||||||
|
@@ -19,18 +19,22 @@ import type {
|
|||||||
Yoga$JustifyContent,
|
Yoga$JustifyContent,
|
||||||
Yoga$FlexDirection,
|
Yoga$FlexDirection,
|
||||||
Yoga$FlexWrap,
|
Yoga$FlexWrap,
|
||||||
Yoga$YogaPositionType,
|
Yoga$PositionType,
|
||||||
} from 'yoga-layout';
|
} from 'yoga-layout';
|
||||||
|
|
||||||
export type LayoutRecordT = RecordOf<{
|
export type LayoutRecordT = RecordOf<{
|
||||||
width?: ?number,
|
width?: ?number,
|
||||||
height?: ?number,
|
height?: ?number,
|
||||||
|
minWidth?: ?number,
|
||||||
|
minHeight?: ?number,
|
||||||
|
maxWidth?: ?number,
|
||||||
|
maxHeight?: ?number,
|
||||||
justifyContent?: Yoga$JustifyContent,
|
justifyContent?: Yoga$JustifyContent,
|
||||||
padding: PositionRecordT,
|
padding: PositionRecordT,
|
||||||
border: PositionRecordT,
|
border: PositionRecordT,
|
||||||
margin: PositionRecordT,
|
margin: PositionRecordT,
|
||||||
position: PositionRecordT,
|
position: PositionRecordT,
|
||||||
positionType: Yoga$YogaPositionType,
|
positionType: Yoga$PositionType,
|
||||||
alignItems?: Yoga$Align,
|
alignItems?: Yoga$Align,
|
||||||
alignSelf?: Yoga$Align,
|
alignSelf?: Yoga$Align,
|
||||||
alignContent?: Yoga$Align,
|
alignContent?: Yoga$Align,
|
||||||
@@ -51,6 +55,10 @@ export type LayoutRecordT = RecordOf<{
|
|||||||
const r: LayoutRecordT = Record({
|
const r: LayoutRecordT = Record({
|
||||||
width: 'auto',
|
width: 'auto',
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
|
minWidth: 0,
|
||||||
|
minHeight: 0,
|
||||||
|
maxWidth: 'none',
|
||||||
|
maxHeight: 'none',
|
||||||
justifyContent: yoga.JUSTIFY_FLEX_START,
|
justifyContent: yoga.JUSTIFY_FLEX_START,
|
||||||
alignItems: yoga.ALIGN_STRETCH,
|
alignItems: yoga.ALIGN_STRETCH,
|
||||||
alignSelf: yoga.ALIGN_AUTO,
|
alignSelf: yoga.ALIGN_AUTO,
|
||||||
|
@@ -49,7 +49,7 @@ export default class URLShortener extends Component<{}, State> {
|
|||||||
window.ga('send', {
|
window.ga('send', {
|
||||||
hitType: 'event',
|
hitType: 'event',
|
||||||
eventCategory: 'URLShortener',
|
eventCategory: 'URLShortener',
|
||||||
eventAction: 'created'
|
eventAction: 'created',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,7 +18,8 @@ import {List, setIn} from 'immutable';
|
|||||||
import PositionRecord from './PositionRecord';
|
import PositionRecord from './PositionRecord';
|
||||||
import LayoutRecord from './LayoutRecord';
|
import LayoutRecord from './LayoutRecord';
|
||||||
import Sidebar from './Sidebar';
|
import Sidebar from './Sidebar';
|
||||||
import {Row, Col} from 'antd';
|
import {Row, Col, Button} from 'antd';
|
||||||
|
import btoa from 'btoa';
|
||||||
import type {LayoutRecordT} from './LayoutRecord';
|
import type {LayoutRecordT} from './LayoutRecord';
|
||||||
import type {Yoga$Direction} from 'yoga-layout';
|
import type {Yoga$Direction} from 'yoga-layout';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
@@ -164,12 +165,15 @@ export default class Playground extends Component<Props, State> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (this.props.persist) {
|
if (this.props.persist) {
|
||||||
window.location.hash = btoa(
|
window.location.hash = this.getHash(layoutDefinition);
|
||||||
JSON.stringify(this.removeUnchangedProperties(layoutDefinition)),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHash = (
|
||||||
|
layoutDefinition: LayoutRecordT = this.state.layoutDefinition,
|
||||||
|
): string =>
|
||||||
|
btoa(JSON.stringify(this.removeUnchangedProperties(layoutDefinition)));
|
||||||
|
|
||||||
removeUnchangedProperties = (node: LayoutRecordT): Object => {
|
removeUnchangedProperties = (node: LayoutRecordT): Object => {
|
||||||
const untouchedLayout = LayoutRecord({});
|
const untouchedLayout = LayoutRecord({});
|
||||||
const untouchedPosition = PositionRecord({});
|
const untouchedPosition = PositionRecord({});
|
||||||
@@ -243,7 +247,15 @@ export default class Playground extends Component<Props, State> {
|
|||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<URLShortener />
|
{this.props.persist ? (
|
||||||
|
<URLShortener />
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
href={`/playground#${this.getHash()}`}
|
||||||
|
type="primary">
|
||||||
|
Open Playground
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -34,7 +34,7 @@ export default ({data}) => (
|
|||||||
comes with an interactive playground for you to explore that
|
comes with an interactive playground for you to explore that
|
||||||
feature. The examples section showcases some of the most common
|
feature. The examples section showcases some of the most common
|
||||||
layouts and how to build them. This is a community projects and
|
layouts and how to build them. This is a community projects and
|
||||||
contributions within documentation, code, and tests are more then
|
contributions within documentation, code, and tests are more than
|
||||||
welcome. The contributing section below covers how to get started.
|
welcome. The contributing section below covers how to get started.
|
||||||
</p>
|
</p>
|
||||||
</Col>
|
</Col>
|
||||||
|
@@ -183,12 +183,14 @@ const AboutSectionTwo = () => (
|
|||||||
);
|
);
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<Page className="landing-page" title="A cross-platform layout engine">
|
<div>
|
||||||
<HeroSection />
|
<Page className="landing-page" title="A cross-platform layout engine">
|
||||||
<PlaygroundSection />
|
<HeroSection />
|
||||||
<AboutSectionOne />
|
<PlaygroundSection />
|
||||||
<hr />
|
<AboutSectionOne />
|
||||||
<AboutSectionTwo />
|
<hr />
|
||||||
<Footer />
|
<AboutSectionTwo />
|
||||||
</Page>
|
<Footer />
|
||||||
|
</Page>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
|
@@ -3,11 +3,13 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.playground-page .error-container {
|
@media (max-width: 991px) {
|
||||||
display: flex;
|
.playground-page .error-container {
|
||||||
flex-direction: column;
|
display: flex;
|
||||||
align-items: center;
|
flex-direction: column;
|
||||||
justify-content: center;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.playground-page .error-text {
|
.playground-page .error-text {
|
||||||
|
2581
website/yarn.lock
2581
website/yarn.lock
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,16 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "YGFloatOptional.h"
|
#include "YGFloatOptional.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Yoga.h"
|
#include "Yoga.h"
|
||||||
|
|
||||||
YGFloatOptional::YGFloatOptional(const float& value) {
|
YGFloatOptional::YGFloatOptional(float value) {
|
||||||
if (YGFloatIsUndefined(value)) {
|
if (YGFloatIsUndefined(value)) {
|
||||||
isUndefined_ = true;
|
isUndefined_ = true;
|
||||||
value_ = 0;
|
value_ = 0;
|
||||||
@@ -31,18 +31,9 @@ const float& YGFloatOptional::getValue() const {
|
|||||||
return value_;
|
return value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGFloatOptional::setValue(const float& val) {
|
|
||||||
value_ = val;
|
|
||||||
isUndefined_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool& YGFloatOptional::isUndefined() const {
|
|
||||||
return isUndefined_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool YGFloatOptional::operator==(const YGFloatOptional& op) const {
|
bool YGFloatOptional::operator==(const YGFloatOptional& op) const {
|
||||||
if (isUndefined_ == op.isUndefined()) {
|
if (isUndefined_ == op.isUndefined()) {
|
||||||
return isUndefined_ ? true : value_ == op.getValue();
|
return isUndefined_ || value_ == op.getValue();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -51,14 +42,14 @@ bool YGFloatOptional::operator!=(const YGFloatOptional& op) const {
|
|||||||
return !(*this == op);
|
return !(*this == op);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YGFloatOptional::operator==(const float& val) const {
|
bool YGFloatOptional::operator==(float val) const {
|
||||||
if (YGFloatIsUndefined(val) == isUndefined_) {
|
if (YGFloatIsUndefined(val) == isUndefined_) {
|
||||||
return isUndefined_ ? true : val == value_;
|
return isUndefined_ || val == value_;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YGFloatOptional::operator!=(const float& val) const {
|
bool YGFloatOptional::operator!=(float val) const {
|
||||||
return !(*this == val);
|
return !(*this == val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,9 +75,9 @@ bool YGFloatOptional::operator<(const YGFloatOptional& op) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool YGFloatOptional::operator>=(const YGFloatOptional& op) const {
|
bool YGFloatOptional::operator>=(const YGFloatOptional& op) const {
|
||||||
return *this == op ? true : *this > op;
|
return *this == op || *this > op;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YGFloatOptional::operator<=(const YGFloatOptional& op) const {
|
bool YGFloatOptional::operator<=(const YGFloatOptional& op) const {
|
||||||
return *this == op ? true : *this < op;
|
return *this == op || *this < op;
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
struct YGFloatOptional {
|
struct YGFloatOptional {
|
||||||
@@ -13,7 +13,7 @@ struct YGFloatOptional {
|
|||||||
bool isUndefined_;
|
bool isUndefined_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit YGFloatOptional(const float& value);
|
explicit YGFloatOptional(float value);
|
||||||
explicit YGFloatOptional();
|
explicit YGFloatOptional();
|
||||||
|
|
||||||
// Program will terminate if the value of an undefined is accessed. Please
|
// Program will terminate if the value of an undefined is accessed. Please
|
||||||
@@ -22,9 +22,14 @@ struct YGFloatOptional {
|
|||||||
const float& getValue() const;
|
const float& getValue() const;
|
||||||
|
|
||||||
// Sets the value of float optional, and thus isUndefined is assigned false.
|
// Sets the value of float optional, and thus isUndefined is assigned false.
|
||||||
void setValue(const float& val);
|
void setValue(float val) {
|
||||||
|
value_ = val;
|
||||||
|
isUndefined_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
const bool& isUndefined() const;
|
bool isUndefined() const {
|
||||||
|
return isUndefined_;
|
||||||
|
}
|
||||||
|
|
||||||
YGFloatOptional operator+(const YGFloatOptional& op);
|
YGFloatOptional operator+(const YGFloatOptional& op);
|
||||||
bool operator>(const YGFloatOptional& op) const;
|
bool operator>(const YGFloatOptional& op) const;
|
||||||
@@ -34,6 +39,6 @@ struct YGFloatOptional {
|
|||||||
bool operator==(const YGFloatOptional& op) const;
|
bool operator==(const YGFloatOptional& op) const;
|
||||||
bool operator!=(const YGFloatOptional& op) const;
|
bool operator!=(const YGFloatOptional& op) const;
|
||||||
|
|
||||||
bool operator==(const float& val) const;
|
bool operator==(float val) const;
|
||||||
bool operator!=(const float& val) const;
|
bool operator!=(float val) const;
|
||||||
};
|
};
|
||||||
|
139
yoga/YGNode.cpp
139
yoga/YGNode.cpp
@@ -9,82 +9,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
void* YGNode::getContext() const {
|
|
||||||
return context_;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGPrintFunc YGNode::getPrintFunc() const {
|
|
||||||
return print_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool YGNode::getHasNewLayout() const {
|
|
||||||
return hasNewLayout_;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGNodeType YGNode::getNodeType() const {
|
|
||||||
return nodeType_;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGMeasureFunc YGNode::getMeasure() const {
|
|
||||||
return measure_;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGBaselineFunc YGNode::getBaseline() const {
|
|
||||||
return baseline_;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGDirtiedFunc YGNode::getDirtied() const {
|
|
||||||
return dirtied_;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGStyle& YGNode::getStyle() {
|
|
||||||
return style_;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGLayout& YGNode::getLayout() {
|
|
||||||
return layout_;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t YGNode::getLineIndex() const {
|
|
||||||
return lineIndex_;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGNodeRef YGNode::getOwner() const {
|
|
||||||
return owner_;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGVector YGNode::getChildren() const {
|
|
||||||
return children_;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t YGNode::getChildrenCount() const {
|
|
||||||
return static_cast<uint32_t>(children_.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
YGNodeRef YGNode::getChild(uint32_t index) const {
|
|
||||||
return children_.at(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
YGNodeRef YGNode::getNextChild() const {
|
|
||||||
return nextChild_;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGConfigRef YGNode::getConfig() const {
|
|
||||||
return config_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool YGNode::isDirty() const {
|
|
||||||
return isDirty_;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGValue YGNode::getResolvedDimension(int index) {
|
|
||||||
return resolvedDimensions_[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
std::array<YGValue, 2> YGNode::getResolvedDimensions() const {
|
|
||||||
return resolvedDimensions_;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGFloatOptional YGNode::getLeadingPosition(
|
YGFloatOptional YGNode::getLeadingPosition(
|
||||||
const YGFlexDirection& axis,
|
const YGFlexDirection& axis,
|
||||||
const float& axisSize) const {
|
const float& axisSize) const {
|
||||||
@@ -173,29 +97,7 @@ YGFloatOptional YGNode::getMarginForAxis(
|
|||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
|
|
||||||
void YGNode::setContext(void* context) {
|
|
||||||
context_ = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setPrintFunc(YGPrintFunc printFunc) {
|
|
||||||
print_ = printFunc;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setHasNewLayout(bool hasNewLayout) {
|
|
||||||
hasNewLayout_ = hasNewLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setNodeType(YGNodeType nodeType) {
|
|
||||||
nodeType_ = nodeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setStyleFlexDirection(YGFlexDirection direction) {
|
|
||||||
style_.flexDirection = direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setStyleAlignContent(YGAlign alignContent) {
|
|
||||||
style_.alignContent = alignContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setMeasureFunc(YGMeasureFunc measureFunc) {
|
void YGNode::setMeasureFunc(YGMeasureFunc measureFunc) {
|
||||||
if (measureFunc == nullptr) {
|
if (measureFunc == nullptr) {
|
||||||
@@ -217,38 +119,6 @@ void YGNode::setMeasureFunc(YGMeasureFunc measureFunc) {
|
|||||||
measure_ = measureFunc;
|
measure_ = measureFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNode::setBaseLineFunc(YGBaselineFunc baseLineFunc) {
|
|
||||||
baseline_ = baseLineFunc;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setDirtiedFunc(YGDirtiedFunc dirtiedFunc) {
|
|
||||||
dirtied_ = dirtiedFunc;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setStyle(const YGStyle& style) {
|
|
||||||
style_ = style;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setLayout(const YGLayout& layout) {
|
|
||||||
layout_ = layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setLineIndex(uint32_t lineIndex) {
|
|
||||||
lineIndex_ = lineIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setOwner(YGNodeRef owner) {
|
|
||||||
owner_ = owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setChildren(const YGVector& children) {
|
|
||||||
children_ = children;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setNextChild(YGNodeRef nextChild) {
|
|
||||||
nextChild_ = nextChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::replaceChild(YGNodeRef child, uint32_t index) {
|
void YGNode::replaceChild(YGNodeRef child, uint32_t index) {
|
||||||
children_[index] = child;
|
children_[index] = child;
|
||||||
}
|
}
|
||||||
@@ -261,10 +131,6 @@ void YGNode::insertChild(YGNodeRef child, uint32_t index) {
|
|||||||
children_.insert(children_.begin() + index, child);
|
children_.insert(children_.begin() + index, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNode::setConfig(YGConfigRef config) {
|
|
||||||
config_ = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setDirty(bool isDirty) {
|
void YGNode::setDirty(bool isDirty) {
|
||||||
if (isDirty == isDirty_) {
|
if (isDirty == isDirty_) {
|
||||||
return;
|
return;
|
||||||
@@ -401,7 +267,6 @@ YGNode::YGNode()
|
|||||||
lineIndex_(0),
|
lineIndex_(0),
|
||||||
owner_(nullptr),
|
owner_(nullptr),
|
||||||
children_(YGVector()),
|
children_(YGVector()),
|
||||||
nextChild_(nullptr),
|
|
||||||
config_(nullptr),
|
config_(nullptr),
|
||||||
isDirty_(false),
|
isDirty_(false),
|
||||||
resolvedDimensions_({{YGValueUndefined, YGValueUndefined}}) {}
|
resolvedDimensions_({{YGValueUndefined, YGValueUndefined}}) {}
|
||||||
@@ -419,7 +284,6 @@ YGNode::YGNode(const YGNode& node)
|
|||||||
lineIndex_(node.lineIndex_),
|
lineIndex_(node.lineIndex_),
|
||||||
owner_(node.owner_),
|
owner_(node.owner_),
|
||||||
children_(node.children_),
|
children_(node.children_),
|
||||||
nextChild_(node.nextChild_),
|
|
||||||
config_(node.config_),
|
config_(node.config_),
|
||||||
isDirty_(node.isDirty_),
|
isDirty_(node.isDirty_),
|
||||||
resolvedDimensions_(node.resolvedDimensions_) {}
|
resolvedDimensions_(node.resolvedDimensions_) {}
|
||||||
@@ -441,7 +305,6 @@ YGNode::YGNode(
|
|||||||
uint32_t lineIndex,
|
uint32_t lineIndex,
|
||||||
YGNodeRef owner,
|
YGNodeRef owner,
|
||||||
const YGVector& children,
|
const YGVector& children,
|
||||||
YGNodeRef nextChild,
|
|
||||||
YGConfigRef config,
|
YGConfigRef config,
|
||||||
bool isDirty,
|
bool isDirty,
|
||||||
std::array<YGValue, 2> resolvedDimensions)
|
std::array<YGValue, 2> resolvedDimensions)
|
||||||
@@ -457,7 +320,6 @@ YGNode::YGNode(
|
|||||||
lineIndex_(lineIndex),
|
lineIndex_(lineIndex),
|
||||||
owner_(owner),
|
owner_(owner),
|
||||||
children_(children),
|
children_(children),
|
||||||
nextChild_(nextChild),
|
|
||||||
config_(config),
|
config_(config),
|
||||||
isDirty_(isDirty),
|
isDirty_(isDirty),
|
||||||
resolvedDimensions_(resolvedDimensions) {}
|
resolvedDimensions_(resolvedDimensions) {}
|
||||||
@@ -483,7 +345,6 @@ YGNode& YGNode::operator=(const YGNode& node) {
|
|||||||
lineIndex_ = node.getLineIndex();
|
lineIndex_ = node.getLineIndex();
|
||||||
owner_ = node.getOwner();
|
owner_ = node.getOwner();
|
||||||
children_ = node.getChildren();
|
children_ = node.getChildren();
|
||||||
nextChild_ = node.getNextChild();
|
|
||||||
config_ = node.getConfig();
|
config_ = node.getConfig();
|
||||||
isDirty_ = node.isDirty();
|
isDirty_ = node.isDirty();
|
||||||
resolvedDimensions_ = node.getResolvedDimensions();
|
resolvedDimensions_ = node.getResolvedDimensions();
|
||||||
|
179
yoga/YGNode.h
179
yoga/YGNode.h
@@ -26,7 +26,6 @@ struct YGNode {
|
|||||||
uint32_t lineIndex_;
|
uint32_t lineIndex_;
|
||||||
YGNodeRef owner_;
|
YGNodeRef owner_;
|
||||||
YGVector children_;
|
YGVector children_;
|
||||||
YGNodeRef nextChild_;
|
|
||||||
YGConfigRef config_;
|
YGConfigRef config_;
|
||||||
bool isDirty_;
|
bool isDirty_;
|
||||||
std::array<YGValue, 2> resolvedDimensions_;
|
std::array<YGValue, 2> resolvedDimensions_;
|
||||||
@@ -54,38 +53,102 @@ struct YGNode {
|
|||||||
uint32_t lineIndex,
|
uint32_t lineIndex,
|
||||||
YGNodeRef owner,
|
YGNodeRef owner,
|
||||||
const YGVector& children,
|
const YGVector& children,
|
||||||
YGNodeRef nextChild,
|
|
||||||
YGConfigRef config,
|
YGConfigRef config,
|
||||||
bool isDirty,
|
bool isDirty,
|
||||||
std::array<YGValue, 2> resolvedDimensions);
|
std::array<YGValue, 2> resolvedDimensions);
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
void* getContext() const;
|
void* getContext() const {
|
||||||
YGPrintFunc getPrintFunc() const;
|
return context_;
|
||||||
bool getHasNewLayout() const;
|
}
|
||||||
YGNodeType getNodeType() const;
|
|
||||||
YGMeasureFunc getMeasure() const;
|
YGPrintFunc getPrintFunc() const {
|
||||||
YGBaselineFunc getBaseline() const;
|
return print_;
|
||||||
YGDirtiedFunc getDirtied() const;
|
}
|
||||||
|
|
||||||
|
bool getHasNewLayout() const {
|
||||||
|
return hasNewLayout_;
|
||||||
|
}
|
||||||
|
|
||||||
|
YGNodeType getNodeType() const {
|
||||||
|
return nodeType_;
|
||||||
|
}
|
||||||
|
|
||||||
|
YGMeasureFunc getMeasure() const {
|
||||||
|
return measure_;
|
||||||
|
}
|
||||||
|
|
||||||
|
YGBaselineFunc getBaseline() const {
|
||||||
|
return baseline_;
|
||||||
|
}
|
||||||
|
|
||||||
|
YGDirtiedFunc getDirtied() const {
|
||||||
|
return dirtied_;
|
||||||
|
}
|
||||||
|
|
||||||
// For Performance reasons passing as reference.
|
// For Performance reasons passing as reference.
|
||||||
YGStyle& getStyle();
|
YGStyle& getStyle() {
|
||||||
|
return style_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const YGStyle& getStyle() const {
|
||||||
|
return style_;
|
||||||
|
}
|
||||||
|
|
||||||
// For Performance reasons passing as reference.
|
// For Performance reasons passing as reference.
|
||||||
YGLayout& getLayout();
|
YGLayout& getLayout() {
|
||||||
uint32_t getLineIndex() const;
|
return layout_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const YGLayout& getLayout() const {
|
||||||
|
return layout_;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t getLineIndex() const {
|
||||||
|
return lineIndex_;
|
||||||
|
}
|
||||||
|
|
||||||
// returns the YGNodeRef that owns this YGNode. An owner is used to identify
|
// returns the YGNodeRef that owns this YGNode. An owner is used to identify
|
||||||
// the YogaTree that a YGNode belongs to.
|
// the YogaTree that a YGNode belongs to.
|
||||||
// This method will return the parent of the YGNode when a YGNode only belongs
|
// This method will return the parent of the YGNode when a YGNode only belongs
|
||||||
// to one YogaTree or nullptr when the YGNode is shared between two or more
|
// to one YogaTree or nullptr when the YGNode is shared between two or more
|
||||||
// YogaTrees.
|
// YogaTrees.
|
||||||
YGNodeRef getOwner() const;
|
YGNodeRef getOwner() const {
|
||||||
YGVector getChildren() const;
|
return owner_;
|
||||||
uint32_t getChildrenCount() const;
|
}
|
||||||
YGNodeRef getChild(uint32_t index) const;
|
|
||||||
YGNodeRef getNextChild() const;
|
// Deprecated, use getOwner() instead.
|
||||||
YGConfigRef getConfig() const;
|
YGNodeRef getParent() const {
|
||||||
bool isDirty() const;
|
return getOwner();
|
||||||
std::array<YGValue, 2> getResolvedDimensions() const;
|
}
|
||||||
YGValue getResolvedDimension(int index);
|
|
||||||
|
YGVector getChildren() const {
|
||||||
|
return children_;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t getChildrenCount() const {
|
||||||
|
return static_cast<uint32_t>(children_.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
YGNodeRef getChild(uint32_t index) const {
|
||||||
|
return children_.at(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
YGConfigRef getConfig() const {
|
||||||
|
return config_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isDirty() const {
|
||||||
|
return isDirty_;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::array<YGValue, 2> getResolvedDimensions() const {
|
||||||
|
return resolvedDimensions_;
|
||||||
|
}
|
||||||
|
|
||||||
|
YGValue getResolvedDimension(int index) const {
|
||||||
|
return resolvedDimensions_[index];
|
||||||
|
}
|
||||||
|
|
||||||
// Methods related to positions, margin, padding and border
|
// Methods related to positions, margin, padding and border
|
||||||
YGFloatOptional getLeadingPosition(const YGFlexDirection& axis,
|
YGFloatOptional getLeadingPosition(const YGFlexDirection& axis,
|
||||||
@@ -120,22 +183,66 @@ struct YGNode {
|
|||||||
const float& widthSize) const;
|
const float& widthSize) const;
|
||||||
// Setters
|
// Setters
|
||||||
|
|
||||||
void setContext(void* context);
|
void setContext(void* context) {
|
||||||
void setPrintFunc(YGPrintFunc printFunc);
|
context_ = context;
|
||||||
void setHasNewLayout(bool hasNewLayout);
|
}
|
||||||
void setNodeType(YGNodeType nodeTye);
|
|
||||||
|
void setPrintFunc(YGPrintFunc printFunc) {
|
||||||
|
print_ = printFunc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setHasNewLayout(bool hasNewLayout) {
|
||||||
|
hasNewLayout_ = hasNewLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setNodeType(YGNodeType nodeType) {
|
||||||
|
nodeType_ = nodeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setStyleFlexDirection(YGFlexDirection direction) {
|
||||||
|
style_.flexDirection = direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setStyleAlignContent(YGAlign alignContent) {
|
||||||
|
style_.alignContent = alignContent;
|
||||||
|
}
|
||||||
|
|
||||||
void setMeasureFunc(YGMeasureFunc measureFunc);
|
void setMeasureFunc(YGMeasureFunc measureFunc);
|
||||||
void setBaseLineFunc(YGBaselineFunc baseLineFunc);
|
|
||||||
void setDirtiedFunc(YGDirtiedFunc dirtiedFunc);
|
void setBaseLineFunc(YGBaselineFunc baseLineFunc) {
|
||||||
void setStyle(const YGStyle& style);
|
baseline_ = baseLineFunc;
|
||||||
void setStyleFlexDirection(YGFlexDirection direction);
|
}
|
||||||
void setStyleAlignContent(YGAlign alignContent);
|
|
||||||
void setLayout(const YGLayout& layout);
|
void setDirtiedFunc(YGDirtiedFunc dirtiedFunc) {
|
||||||
void setLineIndex(uint32_t lineIndex);
|
dirtied_ = dirtiedFunc;
|
||||||
void setOwner(YGNodeRef owner);
|
}
|
||||||
void setChildren(const YGVector& children);
|
|
||||||
void setNextChild(YGNodeRef nextChild);
|
void setStyle(const YGStyle& style) {
|
||||||
void setConfig(YGConfigRef config);
|
style_ = style;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLayout(const YGLayout& layout) {
|
||||||
|
layout_ = layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLineIndex(uint32_t lineIndex) {
|
||||||
|
lineIndex_ = lineIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setOwner(YGNodeRef owner) {
|
||||||
|
owner_ = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setChildren(const YGVector& children) {
|
||||||
|
children_ = children;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: rvalue override for setChildren
|
||||||
|
|
||||||
|
void setConfig(YGConfigRef config) {
|
||||||
|
config_ = config;
|
||||||
|
}
|
||||||
|
|
||||||
void setDirty(bool isDirty);
|
void setDirty(bool isDirty);
|
||||||
void setLayoutLastOwnerDirection(YGDirection direction);
|
void setLayoutLastOwnerDirection(YGDirection direction);
|
||||||
void setLayoutComputedFlexBasis(const YGFloatOptional& computedFlexBasis);
|
void setLayoutComputedFlexBasis(const YGFloatOptional& computedFlexBasis);
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Yoga.h"
|
#include "Yoga.h"
|
||||||
@@ -274,10 +275,6 @@ static YGNodeRef YGNodeDeepClone(YGNodeRef oldNode) {
|
|||||||
node->setConfig(YGConfigClone(*(oldNode->getConfig())));
|
node->setConfig(YGConfigClone(*(oldNode->getConfig())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldNode->getNextChild() != nullptr) {
|
|
||||||
node->setNextChild(YGNodeDeepClone(oldNode->getNextChild()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,6 +532,10 @@ YGNodeRef YGNodeGetOwner(const YGNodeRef node) {
|
|||||||
return node->getOwner();
|
return node->getOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
YGNodeRef YGNodeGetParent(const YGNodeRef node) {
|
||||||
|
return node->getOwner();
|
||||||
|
}
|
||||||
|
|
||||||
void YGNodeMarkDirty(const YGNodeRef node) {
|
void YGNodeMarkDirty(const YGNodeRef node) {
|
||||||
YGAssertWithNode(
|
YGAssertWithNode(
|
||||||
node,
|
node,
|
||||||
@@ -1783,16 +1784,17 @@ static void YGNodeComputeFlexBasisForChildren(
|
|||||||
// child to exactly match the remaining space
|
// child to exactly match the remaining space
|
||||||
if (measureModeMainDim == YGMeasureModeExactly) {
|
if (measureModeMainDim == YGMeasureModeExactly) {
|
||||||
for (auto child : children) {
|
for (auto child : children) {
|
||||||
if (singleFlexChild != nullptr) {
|
if (child->isNodeFlexible()) {
|
||||||
if (child->isNodeFlexible()) {
|
if (singleFlexChild != nullptr ||
|
||||||
// There is already a flexible child, abort
|
YGFloatsEqual(child->resolveFlexGrow(), 0.0f) ||
|
||||||
|
YGFloatsEqual(child->resolveFlexShrink(), 0.0f)) {
|
||||||
|
// There is already a flexible child, or this flexible child doesn't
|
||||||
|
// have flexGrow and flexShrink, abort
|
||||||
singleFlexChild = nullptr;
|
singleFlexChild = nullptr;
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
singleFlexChild = child;
|
||||||
}
|
}
|
||||||
} else if (
|
|
||||||
child->resolveFlexGrow() > 0.0f &&
|
|
||||||
child->resolveFlexShrink() > 0.0f) {
|
|
||||||
singleFlexChild = child;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -92,6 +92,7 @@ WIN_EXPORT void YGNodeRemoveChild(const YGNodeRef node, const YGNodeRef child);
|
|||||||
WIN_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef node);
|
WIN_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef node);
|
||||||
WIN_EXPORT YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index);
|
WIN_EXPORT YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index);
|
||||||
WIN_EXPORT YGNodeRef YGNodeGetOwner(const YGNodeRef node);
|
WIN_EXPORT YGNodeRef YGNodeGetOwner(const YGNodeRef node);
|
||||||
|
WIN_EXPORT YGNodeRef YGNodeGetParent(const YGNodeRef node);
|
||||||
WIN_EXPORT uint32_t YGNodeGetChildCount(const YGNodeRef node);
|
WIN_EXPORT uint32_t YGNodeGetChildCount(const YGNodeRef node);
|
||||||
WIN_EXPORT void YGNodeSetChildren(
|
WIN_EXPORT void YGNodeSetChildren(
|
||||||
YGNodeRef const owner,
|
YGNodeRef const owner,
|
||||||
|
247
yoga_defs.bzl
247
yoga_defs.bzl
@@ -1,115 +1,192 @@
|
|||||||
"""Provides macros for working with yoga library."""
|
"""Provides macros for working with yoga library."""
|
||||||
|
|
||||||
YOGA_ROOTS = ['//...']
|
YOGA_ROOTS = ["//..."]
|
||||||
JAVA_TARGET = '//java:java'
|
|
||||||
INFER_ANNOTATIONS_TARGET = '//lib/infer-annotations:infer-annotations'
|
JAVA_TARGET = "//java:java"
|
||||||
JSR_305_TARGET = '//lib/jsr-305:jsr-305'
|
|
||||||
JUNIT_TARGET = '//lib/junit:junit'
|
INFER_ANNOTATIONS_TARGET = "//lib/infer-annotations:infer-annotations"
|
||||||
PROGRUARD_ANNOTATIONS_TARGET = '//java/proguard-annotations/src/main/java/com/facebook/proguard/annotations:annotations'
|
|
||||||
SOLOADER_TARGET = '//lib/soloader:soloader'
|
JSR_305_TARGET = "//lib/jsr-305:jsr-305"
|
||||||
GTEST_TARGET = '//lib/gtest:gtest'
|
|
||||||
JNI_TARGET = '//lib/jni:jni'
|
JUNIT_TARGET = "//lib/junit:junit"
|
||||||
FBJNI_TARGET = '//lib/fb:fbjni'
|
|
||||||
FBJNI_JAVA_TARGET = '//lib/fb/src/main/java/com/facebook/jni:jni'
|
PROGRUARD_ANNOTATIONS_TARGET = "//java/proguard-annotations/src/main/java/com/facebook/proguard/annotations:annotations"
|
||||||
APPCOMPAT_TARGET = '//lib/appcompat:appcompat'
|
|
||||||
ANDROID = ''
|
SOLOADER_TARGET = "//lib/soloader:soloader"
|
||||||
ANDROID_SUPPORT_TARGET = '//lib/android-support:android-support'
|
|
||||||
ANDROID_TARGET = '//android:android'
|
GTEST_TARGET = "//lib/gtest:gtest"
|
||||||
ANDROID_JAVA_TARGET = '//android/src/main/java/com/facebook/yoga/android:android'
|
|
||||||
ANDROID_RES_TARGET = '//android:res'
|
JNI_TARGET = "//lib/jni:jni"
|
||||||
ANDROID_SAMPLE_JAVA_TARGET = '//android/sample/java/com/facebook/samples/yoga:yoga'
|
|
||||||
ANDROID_SAMPLE_RES_TARGET = '//android/sample:res'
|
FBJNI_TARGET = "//lib/fb:fbjni"
|
||||||
|
|
||||||
|
FBJNI_JAVA_TARGET = "//lib/fb/src/main/java/com/facebook/jni:jni"
|
||||||
|
|
||||||
|
APPCOMPAT_TARGET = "//lib/appcompat:appcompat"
|
||||||
|
|
||||||
|
APPLE = ""
|
||||||
|
|
||||||
|
ANDROID = ""
|
||||||
|
|
||||||
|
ANDROID_SUPPORT_TARGET = "//lib/android-support:android-support"
|
||||||
|
|
||||||
|
ANDROID_TARGET = "//android:android"
|
||||||
|
|
||||||
|
ANDROID_JAVA_TARGET = "//android/src/main/java/com/facebook/yoga/android:android"
|
||||||
|
|
||||||
|
ANDROID_RES_TARGET = "//android:res"
|
||||||
|
|
||||||
|
ANDROID_SAMPLE_JAVA_TARGET = "//android/sample/java/com/facebook/samples/yoga:yoga"
|
||||||
|
|
||||||
|
ANDROID_SAMPLE_RES_TARGET = "//android/sample:res"
|
||||||
|
|
||||||
CXX_LIBRARY_WHITELIST = [
|
CXX_LIBRARY_WHITELIST = [
|
||||||
'//:yoga',
|
"//:yoga",
|
||||||
'//lib/fb:fbjni',
|
"//lib/fb:fbjni",
|
||||||
'//java:jni',
|
"//java:jni",
|
||||||
]
|
]
|
||||||
|
|
||||||
BASE_COMPILER_FLAGS = [
|
BASE_COMPILER_FLAGS = [
|
||||||
'-fno-omit-frame-pointer',
|
"-fno-omit-frame-pointer",
|
||||||
'-fexceptions',
|
"-fexceptions",
|
||||||
'-Wall',
|
"-Wall",
|
||||||
'-Werror',
|
"-Werror",
|
||||||
'-O3',
|
"-O3",
|
||||||
'-ffast-math',
|
"-ffast-math",
|
||||||
]
|
]
|
||||||
|
|
||||||
LIBRARY_COMPILER_FLAGS = BASE_COMPILER_FLAGS + [
|
LIBRARY_COMPILER_FLAGS = BASE_COMPILER_FLAGS + [
|
||||||
'-fPIC',
|
"-fPIC",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def _paths_join(path, *others):
|
||||||
|
"""Joins one or more path components."""
|
||||||
|
result = path
|
||||||
|
|
||||||
|
for p in others:
|
||||||
|
if p.startswith("/"): # absolute
|
||||||
|
result = p
|
||||||
|
elif not result or result.endswith("/"):
|
||||||
|
result += p
|
||||||
|
else:
|
||||||
|
result += "/" + p
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
def subdir_glob(glob_specs, exclude = None, prefix = ""):
|
||||||
|
"""Returns a dict of sub-directory relative paths to full paths.
|
||||||
|
|
||||||
|
The subdir_glob() function is useful for defining header maps for C/C++
|
||||||
|
libraries which should be relative the given sub-directory.
|
||||||
|
Given a list of tuples, the form of (relative-sub-directory, glob-pattern),
|
||||||
|
it returns a dict of sub-directory relative paths to full paths.
|
||||||
|
|
||||||
|
Please refer to native.glob() for explanations and examples of the pattern.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
glob_specs: The array of tuples in form of
|
||||||
|
(relative-sub-directory, glob-pattern inside relative-sub-directory).
|
||||||
|
type: List[Tuple[str, str]]
|
||||||
|
exclude: A list of patterns to identify files that should be removed
|
||||||
|
from the set specified by the first argument. Defaults to [].
|
||||||
|
type: Optional[List[str]]
|
||||||
|
prefix: If is not None, prepends it to each key in the dictionary.
|
||||||
|
Defaults to None.
|
||||||
|
type: Optional[str]
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A dict of sub-directory relative paths to full paths.
|
||||||
|
"""
|
||||||
|
if exclude == None:
|
||||||
|
exclude = []
|
||||||
|
|
||||||
|
results = []
|
||||||
|
|
||||||
|
for dirpath, glob_pattern in glob_specs:
|
||||||
|
results.append(
|
||||||
|
_single_subdir_glob(dirpath, glob_pattern, exclude, prefix),
|
||||||
|
)
|
||||||
|
|
||||||
|
return _merge_maps(*results)
|
||||||
|
|
||||||
|
def _merge_maps(*file_maps):
|
||||||
|
result = {}
|
||||||
|
for file_map in file_maps:
|
||||||
|
for key in file_map:
|
||||||
|
if key in result and result[key] != file_map[key]:
|
||||||
|
fail(
|
||||||
|
"Conflicting files in file search paths. " +
|
||||||
|
"\"%s\" maps to both \"%s\" and \"%s\"." %
|
||||||
|
(key, result[key], file_map[key]),
|
||||||
|
)
|
||||||
|
|
||||||
|
result[key] = file_map[key]
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
def _single_subdir_glob(dirpath, glob_pattern, exclude = None, prefix = None):
|
||||||
|
if exclude == None:
|
||||||
|
exclude = []
|
||||||
|
results = {}
|
||||||
|
files = native.glob([_paths_join(dirpath, glob_pattern)], exclude = exclude)
|
||||||
|
for f in files:
|
||||||
|
if dirpath:
|
||||||
|
key = f[len(dirpath) + 1:]
|
||||||
|
else:
|
||||||
|
key = f
|
||||||
|
if prefix:
|
||||||
|
key = _paths_join(prefix, key)
|
||||||
|
results[key] = f
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
def yoga_dep(dep):
|
def yoga_dep(dep):
|
||||||
return '//' + dep
|
return "//" + dep
|
||||||
|
|
||||||
|
def yoga_android_aar(*args, **kwargs):
|
||||||
|
native.android_aar(*args, **kwargs)
|
||||||
|
|
||||||
_original_android_aar = android_aar
|
def yoga_android_binary(*args, **kwargs):
|
||||||
def android_aar(*args, **kwargs):
|
native.android_binary(*args, **kwargs)
|
||||||
_original_android_aar(*args, **kwargs)
|
|
||||||
|
|
||||||
|
def yoga_android_library(*args, **kwargs):
|
||||||
|
native.android_library(*args, **kwargs)
|
||||||
|
|
||||||
_original_android_binary = android_binary
|
def yoga_android_resource(*args, **kwargs):
|
||||||
def android_binary(*args, **kwargs):
|
native.android_resource(*args, **kwargs)
|
||||||
_original_android_binary(*args, **kwargs)
|
|
||||||
|
|
||||||
|
def yoga_apple_library(*args, **kwargs):
|
||||||
|
native.apple_library(*args, **kwargs)
|
||||||
|
|
||||||
_original_android_library = android_library
|
def yoga_apple_test(*args, **kwargs):
|
||||||
def android_library(*args, **kwargs):
|
native.apple_test(*args, **kwargs)
|
||||||
_original_android_library(*args, **kwargs)
|
|
||||||
|
|
||||||
|
def yoga_cxx_binary(*args, **kwargs):
|
||||||
|
kwargs.pop("platforms", None)
|
||||||
|
native.cxx_binary(*args, **kwargs)
|
||||||
|
|
||||||
_original_android_resource = android_resource
|
def yoga_cxx_library(*args, **kwargs):
|
||||||
def android_resource(*args, **kwargs):
|
# Currently unused
|
||||||
_original_android_resource(*args, **kwargs)
|
kwargs.pop("platforms", None)
|
||||||
|
native.cxx_library(*args, **kwargs)
|
||||||
|
|
||||||
|
def yoga_cxx_test(*args, **kwargs):
|
||||||
|
native.cxx_test(*args, **kwargs)
|
||||||
|
|
||||||
_original_apple_library = apple_library
|
def yoga_java_binary(*args, **kwargs):
|
||||||
def apple_library(*args, **kwargs):
|
native.java_binary(*args, **kwargs)
|
||||||
_original_apple_library(*args, **kwargs)
|
|
||||||
|
|
||||||
|
def yoga_java_library(*args, **kwargs):
|
||||||
|
native.java_library(*args, **kwargs)
|
||||||
|
|
||||||
_original_apple_test = apple_test
|
def yoga_java_test(*args, **kwargs):
|
||||||
def apple_test(*args, **kwargs):
|
native.java_test(*args, **kwargs)
|
||||||
_original_apple_test(*args, **kwargs)
|
|
||||||
|
|
||||||
|
def yoga_prebuilt_cxx_library(*args, **kwargs):
|
||||||
|
native.prebuilt_cxx_library(*args, **kwargs)
|
||||||
|
|
||||||
_original_cxx_library = cxx_library
|
def yoga_prebuilt_jar(*args, **kwargs):
|
||||||
def cxx_library(*args, **kwargs):
|
native.prebuilt_jar(*args, **kwargs)
|
||||||
# Currently unused
|
|
||||||
kwargs.pop("platforms", None)
|
|
||||||
_original_cxx_library(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_cxx_test = cxx_test
|
|
||||||
def cxx_test(*args, **kwargs):
|
|
||||||
_original_cxx_test(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_java_binary = java_binary
|
|
||||||
def java_binary(*args, **kwargs):
|
|
||||||
_original_java_binary(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_java_library = java_library
|
|
||||||
def java_library(*args, **kwargs):
|
|
||||||
_original_java_library(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_java_test = java_test
|
|
||||||
def java_test(*args, **kwargs):
|
|
||||||
_original_java_test(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_prebuilt_cxx_library = prebuilt_cxx_library
|
|
||||||
def prebuilt_cxx_library(*args, **kwargs):
|
|
||||||
_original_prebuilt_cxx_library(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_prebuilt_jar = prebuilt_jar
|
|
||||||
def prebuilt_jar(*args, **kwargs):
|
|
||||||
_original_prebuilt_jar(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
def is_apple_platform():
|
def is_apple_platform():
|
||||||
return True
|
return True
|
||||||
|
Reference in New Issue
Block a user