Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: facebook/yoga
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4ba768ed8e653b2df0783128d89c56a63660d3d9
Choose a base ref
..
head repository: facebook/yoga
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 06e47b201a7832ac0b9ba7bf656823a6a295c19e
Choose a head ref
4 changes: 2 additions & 2 deletions .github/workflows/publish-website.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Website
name: Publish Website

on:
push:
@@ -26,7 +26,7 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: website/public
cname: yogalayout.com
cname: yogalayout.dev
keep_files: true
user_name: 'Yoga-bot'
user_email: 'yogabot@fb.com'
3 changes: 2 additions & 1 deletion .github/workflows/validate-android.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Android
name: Validate Android

on:
pull_request:
push:
branches:
- main
- 'release-*'
workflow_dispatch:

jobs:
18 changes: 16 additions & 2 deletions .github/workflows/validate-apple.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name: Apple
name: Validate Apple

on:
pull_request:
push:
branches:
- main
- 'release-*'
workflow_dispatch:

jobs:
lint-pods:
name: Lint pod
name: Build [CocoaPods]
runs-on: macos-latest

steps:
@@ -20,3 +21,16 @@ jobs:

- name: pod lib lint
run: pod lib lint --verbose --include-podspecs=**/*.podspec

test:
name: Build [SwiftPM]
runs-on: macos-latest

steps:
- uses: actions/checkout@v3

- name: Build Debug
run: swift build -c debug

- name: Build Release
run: swift build -c release
3 changes: 2 additions & 1 deletion .github/workflows/validate-cpp.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: C++
name: Validate C++

on:
pull_request:
push:
branches:
- main
- 'release-*'
workflow_dispatch:

env:
3 changes: 2 additions & 1 deletion .github/workflows/validate-js.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: JavaScript
name: Validate JavaScript

on:
pull_request:
push:
branches:
- main
- 'release-*'
workflow_dispatch:

env:
21 changes: 0 additions & 21 deletions .github/workflows/validate-python.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/validate-swiftpm.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/validate-website-next.yml

This file was deleted.

22 changes: 17 additions & 5 deletions .github/workflows/validate-website.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Website
name: Validate Website

on:
pull_request:
branches:
- main
push:
branches:
- main
@@ -32,10 +34,20 @@ jobs:
- name: Setup
uses: ./.github/actions/setup-js

- name: Build Yoga
run: yarn build
working-directory: javascript

- name: Build Website
run: yarn build
working-directory: website-next

typecheck:
name: Typecheck [Docusaurus]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup-js

- name: yarn tsc
run: yarn tsc
working-directory: website-next
6 changes: 3 additions & 3 deletions Yoga.podspec
Original file line number Diff line number Diff line change
@@ -6,10 +6,10 @@

Pod::Spec.new do |spec|
spec.name = 'Yoga'
spec.version = '2.0.0'
spec.version = '0.0.0'
spec.license = { :type => 'MIT', :file => "LICENSE" }
spec.homepage = 'https://yogalayout.com/'
spec.documentation_url = 'https://yogalayout.com/docs'
spec.homepage = 'https://yogalayout.dev/'
spec.documentation_url = 'https://yogalayout.dev/docs'

spec.summary = 'An embeddable and performant flexbox layout engine with bindings for multiple languages'

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -11,4 +11,4 @@ android.useAndroidX=true

org.gradle.jvmargs=-Xmx1536M

VERSION_NAME=2.0.0
VERSION_NAME=0.0.0
4 changes: 2 additions & 2 deletions javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "yoga-layout",
"version": "2.0.0",
"version": "0.0.0",
"description": "An embeddable and performant flexbox layout engine with bindings for multiple languages",
"license": "MIT",
"author": "Meta Open Source",
"homepage": "https://yogalayout.com/",
"homepage": "https://yogalayout.dev/",
"repository": {
"type": "git",
"url": "git@github.com:facebook/yoga.git"
8 changes: 8 additions & 0 deletions set-version.py
Original file line number Diff line number Diff line change
@@ -28,6 +28,14 @@
f.truncate()
f.write(new_contents)

with open("website-next/package.json", "r+") as f:
new_contents = re.sub(
r'"yoga-layout": ".*"', f'"yoga-layout": "{version}"', f.read()
)
f.seek(0)
f.truncate()
f.write(new_contents)

with open("Yoga.podspec", "r+") as f:
new_contents = re.sub(
r"spec\.version = '.*'", f"spec.version = '{version}'", f.read()
35 changes: 35 additions & 0 deletions tests/OrdinalsTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#include <deque>

#include <gtest/gtest.h>
#include <yoga/enums/Edge.h>

namespace facebook::yoga {

TEST(Ordinals, iteration) {
std::deque expectedEdges{
Edge::Left,
Edge::Top,
Edge::Right,
Edge::Bottom,
Edge::Start,
Edge::End,
Edge::Horizontal,
Edge::Vertical,
Edge::All};

for (auto edge : yoga::ordinals<Edge>()) {
ASSERT_EQ(edge, expectedEdges.front());
expectedEdges.pop_front();
}

ASSERT_TRUE(expectedEdges.empty());
}

} // namespace facebook::yoga
2 changes: 1 addition & 1 deletion website-next/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ export default {
'Build flexible layouts on any platform with a highly optimized open source layout engine designed with speed, size, and ease of use in mind.',
favicon: 'img/favicon.png',

url: 'https:/yogalayout.com',
url: 'https:/yogalayout.dev',
baseUrl: '/',

organizationName: 'facebook',
2 changes: 1 addition & 1 deletion website-next/package.json
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
"prism-react-renderer": "^2.1.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"yoga-layout": "^2.0.0"
"yoga-layout": "0.0.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.0.0",
44 changes: 42 additions & 2 deletions yoga/enums/YogaEnums.h
Original file line number Diff line number Diff line change
@@ -7,20 +7,60 @@

#pragma once

#include <iterator>
#include <type_traits>

namespace facebook::yoga {

template <typename EnumT>
constexpr inline int32_t ordinalCount();

/**
* Count of bits needed to represent every ordinal
*/
template <typename EnumT>
constexpr inline int32_t bitCount();

// Polyfill of C++ 23 to_underlying()
// https://en.cppreference.com/w/cpp/utility/to_underlying
/**
* Polyfill of C++ 23 to_underlying()
* https://en.cppreference.com/w/cpp/utility/to_underlying
*/
constexpr auto to_underlying(auto e) noexcept {
return static_cast<std::underlying_type_t<decltype(e)>>(e);
}

/**
* Convenience function to iterate through every value in a Yoga enum as part of
* a range-based for loop.
*/
template <typename EnumT>
auto ordinals() {
struct Iterator {
EnumT e{};

EnumT operator*() const {
return e;
}

Iterator& operator++() {
e = static_cast<EnumT>(to_underlying(e) + 1);
return *this;
}

bool operator==(const Iterator& other) const = default;
bool operator!=(const Iterator& other) const = default;
};

struct Range {
Iterator begin() const {
return Iterator{};
}
Iterator end() const {
return Iterator{static_cast<EnumT>(ordinalCount<EnumT>())};
}
};

return Range{};
}

} // namespace facebook::yoga
2 changes: 1 addition & 1 deletion yoga/module.modulemap
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ module yoga [system] {
header "YGMacros.h"
header "YGNode.h"
header "YGNodeLayout.h"
header "YGNodeStye.h"
header "YGNodeStyle.h"
header "YGPixelGrid.h"
header "YGValue.h"
header "Yoga.h"
2 changes: 1 addition & 1 deletion yoga/style/ValueFactories.h
Original file line number Diff line number Diff line change
@@ -39,4 +39,4 @@ inline CompactValue undefined() {
return CompactValue::ofUndefined();
}

} // namespace facebook::yoga
} // namespace facebook::yoga::value