Automatic lint fixes

Summary:
@public
A round of automatic lint fixes.

Reviewed By: SidharthGuglani

Differential Revision: D14590396

fbshipit-source-id: f0b4a0ce503a1d9d46ea7ae788f9f2eac09c2ac7
This commit is contained in:
David Aurelio
2019-03-25 05:37:36 -07:00
committed by Facebook Github Bot
parent 7d7b7b9e18
commit 85352c4e45
66 changed files with 833 additions and 917 deletions

View File

@@ -1,5 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved. /**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* 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.samples.yoga; package com.facebook.samples.yoga;
import android.content.Intent; import android.content.Intent;

View File

@@ -1,5 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved. /**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* 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.samples.yoga; package com.facebook.samples.yoga;
import java.io.File; import java.io.File;

View File

@@ -1,5 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved. /**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* 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.samples.yoga; package com.facebook.samples.yoga;

View File

@@ -1,5 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved. /**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* 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.samples.yoga; package com.facebook.samples.yoga;
import android.os.Bundle; import android.os.Bundle;

View File

@@ -1,5 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved. /**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* 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.samples.yoga; package com.facebook.samples.yoga;
import android.os.Bundle; import android.os.Bundle;

View File

@@ -1,5 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved. /**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* 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.samples.yoga; package com.facebook.samples.yoga;
import android.os.Bundle; import android.os.Bundle;

View File

@@ -1,11 +1,9 @@
/** /**
* Copyright 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the license found in the * This source code is licensed under the MIT license found in the LICENSE
* LICENSE-examples file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
package com.facebook.samples.yoga; package com.facebook.samples.yoga;
import android.content.Intent; import android.content.Intent;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
package com.facebook.yoga.android; package com.facebook.yoga.android;
import java.util.HashMap; import java.util.HashMap;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
package com.facebook.yoga.android; package com.facebook.yoga.android;
import android.content.Context; import android.content.Context;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
package com.facebook.yoga.android; package com.facebook.yoga.android;
import android.content.Context; import android.content.Context;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
package com.facebook.proguard.annotations; package com.facebook.proguard.annotations;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,8 +1,8 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignItemsTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignItemsTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAndroidNewsFeed.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAndroidNewsFeed.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGDimensionTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGDimensionTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,8 +1,8 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * 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

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexWrapTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexWrapTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,8 +1,8 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGMarginTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGMarginTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGMinMaxDimensionTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGMinMaxDimensionTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGRoundingTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGRoundingTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
package com.facebook.yoga; package com.facebook.yoga;
import org.junit.Test; import org.junit.Test;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
package com.facebook.yoga; package com.facebook.yoga;
import org.junit.Test; import org.junit.Test;

View File

@@ -8,37 +8,30 @@
#include "./Config.hh" #include "./Config.hh"
/* static */ Config * Config::create(void) /* static */ Config* Config::create(void) {
{
return new Config(); return new Config();
} }
/* static */ void Config::destroy(Config * node) /* static */ void Config::destroy(Config* node) {
{
delete node; delete node;
} }
Config::Config(void) Config::Config(void) : m_config(YGConfigNew()) {}
: m_config(YGConfigNew())
{
}
Config::~Config(void) Config::~Config(void) {
{
YGConfigFree(m_config); YGConfigFree(m_config);
} }
void Config::setExperimentalFeatureEnabled(int feature, bool enabled) void Config::setExperimentalFeatureEnabled(int feature, bool enabled) {
{ YGConfigSetExperimentalFeatureEnabled(
YGConfigSetExperimentalFeatureEnabled(m_config, static_cast<YGExperimentalFeature>(feature), enabled); m_config, static_cast<YGExperimentalFeature>(feature), enabled);
} }
void Config::setPointScaleFactor(float pixelsInPoint) void Config::setPointScaleFactor(float pixelsInPoint) {
{
YGConfigSetPointScaleFactor(m_config, pixelsInPoint); YGConfigSetPointScaleFactor(m_config, pixelsInPoint);
} }
bool Config::isExperimentalFeatureEnabled(int feature) const bool Config::isExperimentalFeatureEnabled(int feature) const {
{ return YGConfigIsExperimentalFeatureEnabled(
return YGConfigIsExperimentalFeatureEnabled(m_config, static_cast<YGExperimentalFeature>(feature)); m_config, static_cast<YGExperimentalFeature>(feature));
} }

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
#pragma once #pragma once
#include <nbind/api.h> #include <nbind/api.h>
@@ -16,36 +15,28 @@ class Config {
friend class Node; friend class Node;
public: public:
static Config* create(void); static Config* create(void);
static void destroy(Config* config); static void destroy(Config* config);
private: private:
Config(void); Config(void);
public: public:
~Config(void); ~Config(void);
public: // Prevent accidental copy public: // Prevent accidental copy
Config(Config const&) = delete; Config(Config const&) = delete;
Config const& operator=(Config const&) = delete; Config const& operator=(Config const&) = delete;
public: // Setters public: // Setters
void setExperimentalFeatureEnabled(int feature, bool enabled); void setExperimentalFeatureEnabled(int feature, bool enabled);
void setPointScaleFactor(float pixelsInPoint); void setPointScaleFactor(float pixelsInPoint);
public: // Getters public: // Getters
bool isExperimentalFeatureEnabled(int feature) const; bool isExperimentalFeatureEnabled(int feature) const;
private: private:
YGConfigRef m_config; YGConfigRef m_config;
}; };

View File

@@ -1,17 +1,15 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
#pragma once #pragma once
#include <nbind/api.h> #include <nbind/api.h>
#include <nbind/BindDefiner.h> #include <nbind/BindDefiner.h>
struct Layout struct Layout {
{
double left; double left;
double right; double right;
@@ -21,8 +19,7 @@ struct Layout
double width; double width;
double height; double height;
void toJS(nbind::cbOutput expose) const void toJS(nbind::cbOutput expose) const {
{
expose(left, right, top, bottom, width, height); expose(left, right, top, bottom, width, height);
} }
}; };

View File

@@ -13,251 +13,213 @@
#include "./Size.hh" #include "./Size.hh"
#include "./Config.hh" #include "./Config.hh"
static YGSize globalMeasureFunc(YGNodeRef nodeRef, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode) static YGSize globalMeasureFunc(
{ YGNodeRef nodeRef,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
Node const& node = *reinterpret_cast<Node const*>(YGNodeGetContext(nodeRef)); Node const& node = *reinterpret_cast<Node const*>(YGNodeGetContext(nodeRef));
Size size = node.callMeasureFunc(width, widthMode, height, heightMode); Size size = node.callMeasureFunc(width, widthMode, height, heightMode);
YGSize ygSize = { static_cast<float>(size.width), static_cast<float>(size.height) }; YGSize ygSize = {static_cast<float>(size.width),
static_cast<float>(size.height)};
return ygSize; return ygSize;
} }
static void globalDirtiedFunc(YGNodeRef nodeRef) static void globalDirtiedFunc(YGNodeRef nodeRef) {
{
Node const& node = *reinterpret_cast<Node const*>(YGNodeGetContext(nodeRef)); Node const& node = *reinterpret_cast<Node const*>(YGNodeGetContext(nodeRef));
node.callDirtiedFunc(); node.callDirtiedFunc();
} }
/* static */ Node * Node::createDefault(void) /* static */ Node* Node::createDefault(void) {
{
return new Node(nullptr); return new Node(nullptr);
} }
/* static */ Node * Node::createWithConfig(Config * config) /* static */ Node* Node::createWithConfig(Config* config) {
{
return new Node(config); return new Node(config);
} }
/* static */ void Node::destroy(Node * node) /* static */ void Node::destroy(Node* node) {
{
delete node; delete node;
} }
/* static */ Node * Node::fromYGNode(YGNodeRef nodeRef) /* static */ Node* Node::fromYGNode(YGNodeRef nodeRef) {
{
return reinterpret_cast<Node*>(YGNodeGetContext(nodeRef)); return reinterpret_cast<Node*>(YGNodeGetContext(nodeRef));
} }
Node::Node(Config* config) Node::Node(Config* config)
: m_node(config != nullptr ? YGNodeNewWithConfig(config->m_config) : YGNodeNew()) : m_node(
, m_measureFunc(nullptr) config != nullptr ? YGNodeNewWithConfig(config->m_config)
, m_dirtiedFunc(nullptr) : YGNodeNew()),
{ m_measureFunc(nullptr),
m_dirtiedFunc(nullptr) {
YGNodeSetContext(m_node, reinterpret_cast<void*>(this)); YGNodeSetContext(m_node, reinterpret_cast<void*>(this));
} }
Node::~Node(void) Node::~Node(void) {
{
YGNodeFree(m_node); YGNodeFree(m_node);
} }
void Node::reset(void) void Node::reset(void) {
{
m_measureFunc.reset(nullptr); m_measureFunc.reset(nullptr);
m_dirtiedFunc.reset(nullptr); m_dirtiedFunc.reset(nullptr);
YGNodeReset(m_node); YGNodeReset(m_node);
} }
void Node::copyStyle(Node const & other) void Node::copyStyle(Node const& other) {
{
YGNodeCopyStyle(m_node, other.m_node); YGNodeCopyStyle(m_node, other.m_node);
} }
void Node::setPositionType(int positionType) void Node::setPositionType(int positionType) {
{
YGNodeStyleSetPositionType(m_node, static_cast<YGPositionType>(positionType)); YGNodeStyleSetPositionType(m_node, static_cast<YGPositionType>(positionType));
} }
void Node::setPosition(int edge, double position) void Node::setPosition(int edge, double position) {
{
YGNodeStyleSetPosition(m_node, static_cast<YGEdge>(edge), position); YGNodeStyleSetPosition(m_node, static_cast<YGEdge>(edge), position);
} }
void Node::setPositionPercent(int edge, double position) void Node::setPositionPercent(int edge, double position) {
{
YGNodeStyleSetPositionPercent(m_node, static_cast<YGEdge>(edge), position); YGNodeStyleSetPositionPercent(m_node, static_cast<YGEdge>(edge), position);
} }
void Node::setAlignContent(int alignContent) void Node::setAlignContent(int alignContent) {
{
YGNodeStyleSetAlignContent(m_node, static_cast<YGAlign>(alignContent)); YGNodeStyleSetAlignContent(m_node, static_cast<YGAlign>(alignContent));
} }
void Node::setAlignItems(int alignItems) void Node::setAlignItems(int alignItems) {
{
YGNodeStyleSetAlignItems(m_node, static_cast<YGAlign>(alignItems)); YGNodeStyleSetAlignItems(m_node, static_cast<YGAlign>(alignItems));
} }
void Node::setAlignSelf(int alignSelf) void Node::setAlignSelf(int alignSelf) {
{
YGNodeStyleSetAlignSelf(m_node, static_cast<YGAlign>(alignSelf)); YGNodeStyleSetAlignSelf(m_node, static_cast<YGAlign>(alignSelf));
} }
void Node::setFlexDirection(int flexDirection) void Node::setFlexDirection(int flexDirection) {
{ YGNodeStyleSetFlexDirection(
YGNodeStyleSetFlexDirection(m_node, static_cast<YGFlexDirection>(flexDirection)); m_node, static_cast<YGFlexDirection>(flexDirection));
} }
void Node::setFlexWrap(int flexWrap) void Node::setFlexWrap(int flexWrap) {
{
YGNodeStyleSetFlexWrap(m_node, static_cast<YGWrap>(flexWrap)); YGNodeStyleSetFlexWrap(m_node, static_cast<YGWrap>(flexWrap));
} }
void Node::setJustifyContent(int justifyContent) void Node::setJustifyContent(int justifyContent) {
{
YGNodeStyleSetJustifyContent(m_node, static_cast<YGJustify>(justifyContent)); YGNodeStyleSetJustifyContent(m_node, static_cast<YGJustify>(justifyContent));
} }
void Node::setMargin(int edge, double margin) void Node::setMargin(int edge, double margin) {
{
YGNodeStyleSetMargin(m_node, static_cast<YGEdge>(edge), margin); YGNodeStyleSetMargin(m_node, static_cast<YGEdge>(edge), margin);
} }
void Node::setMarginPercent(int edge, double margin) void Node::setMarginPercent(int edge, double margin) {
{
YGNodeStyleSetMarginPercent(m_node, static_cast<YGEdge>(edge), margin); YGNodeStyleSetMarginPercent(m_node, static_cast<YGEdge>(edge), margin);
} }
void Node::setMarginAuto(int edge) void Node::setMarginAuto(int edge) {
{
YGNodeStyleSetMarginAuto(m_node, static_cast<YGEdge>(edge)); YGNodeStyleSetMarginAuto(m_node, static_cast<YGEdge>(edge));
} }
void Node::setOverflow(int overflow) void Node::setOverflow(int overflow) {
{
YGNodeStyleSetOverflow(m_node, static_cast<YGOverflow>(overflow)); YGNodeStyleSetOverflow(m_node, static_cast<YGOverflow>(overflow));
} }
void Node::setDisplay(int display) void Node::setDisplay(int display) {
{
YGNodeStyleSetDisplay(m_node, static_cast<YGDisplay>(display)); YGNodeStyleSetDisplay(m_node, static_cast<YGDisplay>(display));
} }
void Node::setFlex(double flex) void Node::setFlex(double flex) {
{
YGNodeStyleSetFlex(m_node, flex); YGNodeStyleSetFlex(m_node, flex);
} }
void Node::setFlexBasis(double flexBasis) void Node::setFlexBasis(double flexBasis) {
{
YGNodeStyleSetFlexBasis(m_node, flexBasis); YGNodeStyleSetFlexBasis(m_node, flexBasis);
} }
void Node::setFlexBasisPercent(double flexBasis) void Node::setFlexBasisPercent(double flexBasis) {
{
YGNodeStyleSetFlexBasisPercent(m_node, flexBasis); YGNodeStyleSetFlexBasisPercent(m_node, flexBasis);
} }
void Node::setFlexGrow(double flexGrow) void Node::setFlexGrow(double flexGrow) {
{
YGNodeStyleSetFlexGrow(m_node, flexGrow); YGNodeStyleSetFlexGrow(m_node, flexGrow);
} }
void Node::setFlexShrink(double flexShrink) void Node::setFlexShrink(double flexShrink) {
{
YGNodeStyleSetFlexShrink(m_node, flexShrink); YGNodeStyleSetFlexShrink(m_node, flexShrink);
} }
void Node::setWidth(double width) void Node::setWidth(double width) {
{
YGNodeStyleSetWidth(m_node, width); YGNodeStyleSetWidth(m_node, width);
} }
void Node::setWidthPercent(double width) void Node::setWidthPercent(double width) {
{
YGNodeStyleSetWidthPercent(m_node, width); YGNodeStyleSetWidthPercent(m_node, width);
} }
void Node::setWidthAuto() void Node::setWidthAuto() {
{
YGNodeStyleSetWidthAuto(m_node); YGNodeStyleSetWidthAuto(m_node);
} }
void Node::setHeight(double height) void Node::setHeight(double height) {
{
YGNodeStyleSetHeight(m_node, height); YGNodeStyleSetHeight(m_node, height);
} }
void Node::setHeightPercent(double height) void Node::setHeightPercent(double height) {
{
YGNodeStyleSetHeightPercent(m_node, height); YGNodeStyleSetHeightPercent(m_node, height);
} }
void Node::setHeightAuto() void Node::setHeightAuto() {
{
YGNodeStyleSetHeightAuto(m_node); YGNodeStyleSetHeightAuto(m_node);
} }
void Node::setMinWidth(double minWidth) void Node::setMinWidth(double minWidth) {
{
YGNodeStyleSetMinWidth(m_node, minWidth); YGNodeStyleSetMinWidth(m_node, minWidth);
} }
void Node::setMinWidthPercent(double minWidth) void Node::setMinWidthPercent(double minWidth) {
{
YGNodeStyleSetMinWidthPercent(m_node, minWidth); YGNodeStyleSetMinWidthPercent(m_node, minWidth);
} }
void Node::setMinHeight(double minHeight) void Node::setMinHeight(double minHeight) {
{
YGNodeStyleSetMinHeight(m_node, minHeight); YGNodeStyleSetMinHeight(m_node, minHeight);
} }
void Node::setMinHeightPercent(double minHeight) void Node::setMinHeightPercent(double minHeight) {
{
YGNodeStyleSetMinHeightPercent(m_node, minHeight); YGNodeStyleSetMinHeightPercent(m_node, minHeight);
} }
void Node::setMaxWidth(double maxWidth) void Node::setMaxWidth(double maxWidth) {
{
YGNodeStyleSetMaxWidth(m_node, maxWidth); YGNodeStyleSetMaxWidth(m_node, maxWidth);
} }
void Node::setMaxWidthPercent(double maxWidth) void Node::setMaxWidthPercent(double maxWidth) {
{
YGNodeStyleSetMaxWidthPercent(m_node, maxWidth); YGNodeStyleSetMaxWidthPercent(m_node, maxWidth);
} }
void Node::setMaxHeight(double maxHeight) void Node::setMaxHeight(double maxHeight) {
{
YGNodeStyleSetMaxHeight(m_node, maxHeight); YGNodeStyleSetMaxHeight(m_node, maxHeight);
} }
void Node::setMaxHeightPercent(double maxHeight) void Node::setMaxHeightPercent(double maxHeight) {
{
YGNodeStyleSetMaxHeightPercent(m_node, maxHeight); YGNodeStyleSetMaxHeightPercent(m_node, maxHeight);
} }
void Node::setAspectRatio(double aspectRatio) void Node::setAspectRatio(double aspectRatio) {
{
YGNodeStyleSetAspectRatio(m_node, aspectRatio); YGNodeStyleSetAspectRatio(m_node, aspectRatio);
} }
void Node::setBorder(int edge, double border) void Node::setBorder(int edge, double border) {
{
YGNodeStyleSetBorder(m_node, static_cast<YGEdge>(edge), border); YGNodeStyleSetBorder(m_node, static_cast<YGEdge>(edge), border);
} }
void Node::setPadding(int edge, double padding) void Node::setPadding(int edge, double padding) {
{
YGNodeStyleSetPadding(m_node, static_cast<YGEdge>(edge), padding); YGNodeStyleSetPadding(m_node, static_cast<YGEdge>(edge), padding);
} }
void Node::setPaddingPercent(int edge, double padding) void Node::setPaddingPercent(int edge, double padding) {
{
YGNodeStyleSetPaddingPercent(m_node, static_cast<YGEdge>(edge), padding); YGNodeStyleSetPaddingPercent(m_node, static_cast<YGEdge>(edge), padding);
} }
@@ -265,142 +227,118 @@ void Node::setIsReferenceBaseline(bool isReferenceBaseline) {
YGNodeSetIsReferenceBaseline(m_node, isReferenceBaseline); YGNodeSetIsReferenceBaseline(m_node, isReferenceBaseline);
} }
int Node::getPositionType(void) const int Node::getPositionType(void) const {
{
return YGNodeStyleGetPositionType(m_node); return YGNodeStyleGetPositionType(m_node);
} }
Value Node::getPosition(int edge) const Value Node::getPosition(int edge) const {
{ return Value::fromYGValue(
return Value::fromYGValue(YGNodeStyleGetPosition(m_node, static_cast<YGEdge>(edge))); YGNodeStyleGetPosition(m_node, static_cast<YGEdge>(edge)));
} }
int Node::getAlignContent(void) const int Node::getAlignContent(void) const {
{
return YGNodeStyleGetAlignContent(m_node); return YGNodeStyleGetAlignContent(m_node);
} }
int Node::getAlignItems(void) const int Node::getAlignItems(void) const {
{
return YGNodeStyleGetAlignItems(m_node); return YGNodeStyleGetAlignItems(m_node);
} }
int Node::getAlignSelf(void) const int Node::getAlignSelf(void) const {
{
return YGNodeStyleGetAlignSelf(m_node); return YGNodeStyleGetAlignSelf(m_node);
} }
int Node::getFlexDirection(void) const int Node::getFlexDirection(void) const {
{
return YGNodeStyleGetFlexDirection(m_node); return YGNodeStyleGetFlexDirection(m_node);
} }
int Node::getFlexWrap(void) const int Node::getFlexWrap(void) const {
{
return YGNodeStyleGetFlexWrap(m_node); return YGNodeStyleGetFlexWrap(m_node);
} }
int Node::getJustifyContent(void) const int Node::getJustifyContent(void) const {
{
return YGNodeStyleGetJustifyContent(m_node); return YGNodeStyleGetJustifyContent(m_node);
} }
Value Node::getMargin(int edge) const Value Node::getMargin(int edge) const {
{ return Value::fromYGValue(
return Value::fromYGValue(YGNodeStyleGetMargin(m_node, static_cast<YGEdge>(edge))); YGNodeStyleGetMargin(m_node, static_cast<YGEdge>(edge)));
} }
int Node::getOverflow(void) const int Node::getOverflow(void) const {
{
return YGNodeStyleGetOverflow(m_node); return YGNodeStyleGetOverflow(m_node);
} }
int Node::getDisplay(void) const int Node::getDisplay(void) const {
{
return YGNodeStyleGetDisplay(m_node); return YGNodeStyleGetDisplay(m_node);
} }
Value Node::getFlexBasis(void) const Value Node::getFlexBasis(void) const {
{
return Value::fromYGValue(YGNodeStyleGetFlexBasis(m_node)); return Value::fromYGValue(YGNodeStyleGetFlexBasis(m_node));
} }
double Node::getFlexGrow(void) const double Node::getFlexGrow(void) const {
{
return YGNodeStyleGetFlexGrow(m_node); return YGNodeStyleGetFlexGrow(m_node);
} }
double Node::getFlexShrink(void) const double Node::getFlexShrink(void) const {
{
return YGNodeStyleGetFlexShrink(m_node); return YGNodeStyleGetFlexShrink(m_node);
} }
Value Node::getWidth(void) const Value Node::getWidth(void) const {
{
return Value::fromYGValue(YGNodeStyleGetWidth(m_node)); return Value::fromYGValue(YGNodeStyleGetWidth(m_node));
} }
Value Node::getHeight(void) const Value Node::getHeight(void) const {
{
return Value::fromYGValue(YGNodeStyleGetHeight(m_node)); return Value::fromYGValue(YGNodeStyleGetHeight(m_node));
} }
Value Node::getMinWidth(void) const Value Node::getMinWidth(void) const {
{
return Value::fromYGValue(YGNodeStyleGetMinWidth(m_node)); return Value::fromYGValue(YGNodeStyleGetMinWidth(m_node));
} }
Value Node::getMinHeight(void) const Value Node::getMinHeight(void) const {
{
return Value::fromYGValue(YGNodeStyleGetMinHeight(m_node)); return Value::fromYGValue(YGNodeStyleGetMinHeight(m_node));
} }
Value Node::getMaxWidth(void) const Value Node::getMaxWidth(void) const {
{
return Value::fromYGValue(YGNodeStyleGetMaxWidth(m_node)); return Value::fromYGValue(YGNodeStyleGetMaxWidth(m_node));
} }
Value Node::getMaxHeight(void) const Value Node::getMaxHeight(void) const {
{
return Value::fromYGValue(YGNodeStyleGetMaxHeight(m_node)); return Value::fromYGValue(YGNodeStyleGetMaxHeight(m_node));
} }
double Node::getAspectRatio(void) const double Node::getAspectRatio(void) const {
{
return YGNodeStyleGetAspectRatio(m_node); return YGNodeStyleGetAspectRatio(m_node);
} }
double Node::getBorder(int edge) const double Node::getBorder(int edge) const {
{
return YGNodeStyleGetBorder(m_node, static_cast<YGEdge>(edge)); return YGNodeStyleGetBorder(m_node, static_cast<YGEdge>(edge));
} }
Value Node::getPadding(int edge) const Value Node::getPadding(int edge) const {
{ return Value::fromYGValue(
return Value::fromYGValue(YGNodeStyleGetPadding(m_node, static_cast<YGEdge>(edge))); YGNodeStyleGetPadding(m_node, static_cast<YGEdge>(edge)));
} }
bool Node::isReferenceBaseline() { bool Node::isReferenceBaseline() {
return YGNodeIsReferenceBaseline(m_node); return YGNodeIsReferenceBaseline(m_node);
} }
void Node::insertChild(Node * child, unsigned index) void Node::insertChild(Node* child, unsigned index) {
{
YGNodeInsertChild(m_node, child->m_node, index); YGNodeInsertChild(m_node, child->m_node, index);
} }
void Node::removeChild(Node * child) void Node::removeChild(Node* child) {
{
YGNodeRemoveChild(m_node, child->m_node); YGNodeRemoveChild(m_node, child->m_node);
} }
unsigned Node::getChildCount(void) const unsigned Node::getChildCount(void) const {
{
return YGNodeGetChildCount(m_node); return YGNodeGetChildCount(m_node);
} }
Node * Node::getParent(void) Node* Node::getParent(void) {
{
auto nodePtr = YGNodeGetParent(m_node); auto nodePtr = YGNodeGetParent(m_node);
if (nodePtr == nullptr) if (nodePtr == nullptr)
@@ -409,8 +347,7 @@ Node * Node::getParent(void)
return Node::fromYGNode(nodePtr); return Node::fromYGNode(nodePtr);
} }
Node * Node::getChild(unsigned index) Node* Node::getChild(unsigned index) {
{
auto nodePtr = YGNodeGetChild(m_node, index); auto nodePtr = YGNodeGetChild(m_node, index);
if (nodePtr == nullptr) if (nodePtr == nullptr)
@@ -419,27 +356,27 @@ Node * Node::getChild(unsigned index)
return Node::fromYGNode(nodePtr); return Node::fromYGNode(nodePtr);
} }
void Node::setMeasureFunc(nbind::cbFunction & measureFunc) void Node::setMeasureFunc(nbind::cbFunction& measureFunc) {
{
m_measureFunc.reset(new nbind::cbFunction(measureFunc)); m_measureFunc.reset(new nbind::cbFunction(measureFunc));
YGNodeSetMeasureFunc(m_node, &globalMeasureFunc); YGNodeSetMeasureFunc(m_node, &globalMeasureFunc);
} }
void Node::unsetMeasureFunc(void) void Node::unsetMeasureFunc(void) {
{
m_measureFunc.reset(nullptr); m_measureFunc.reset(nullptr);
YGNodeSetMeasureFunc(m_node, nullptr); YGNodeSetMeasureFunc(m_node, nullptr);
} }
Size Node::callMeasureFunc(double width, int widthMode, double height, int heightMode) const Size Node::callMeasureFunc(
{ double width,
int widthMode,
double height,
int heightMode) const {
return m_measureFunc->call<Size>(width, widthMode, height, heightMode); return m_measureFunc->call<Size>(width, widthMode, height, heightMode);
} }
void Node::setDirtiedFunc(nbind::cbFunction & dirtiedFunc) void Node::setDirtiedFunc(nbind::cbFunction& dirtiedFunc) {
{
m_dirtiedFunc.reset(new nbind::cbFunction(dirtiedFunc)); m_dirtiedFunc.reset(new nbind::cbFunction(dirtiedFunc));
YGNodeSetDirtiedFunc(m_node, &globalDirtiedFunc); YGNodeSetDirtiedFunc(m_node, &globalDirtiedFunc);
@@ -451,58 +388,48 @@ void Node::unsetDirtiedFunc(void) {
YGNodeSetDirtiedFunc(m_node, nullptr); YGNodeSetDirtiedFunc(m_node, nullptr);
} }
void Node::callDirtiedFunc(void) const void Node::callDirtiedFunc(void) const {
{
m_dirtiedFunc->call<void>(); m_dirtiedFunc->call<void>();
} }
void Node::markDirty(void) void Node::markDirty(void) {
{
YGNodeMarkDirty(m_node); YGNodeMarkDirty(m_node);
} }
bool Node::isDirty(void) const bool Node::isDirty(void) const {
{
return YGNodeIsDirty(m_node); return YGNodeIsDirty(m_node);
} }
void Node::calculateLayout(double width, double height, int direction) void Node::calculateLayout(double width, double height, int direction) {
{ YGNodeCalculateLayout(
YGNodeCalculateLayout(m_node, width, height, static_cast<YGDirection>(direction)); m_node, width, height, static_cast<YGDirection>(direction));
} }
double Node::getComputedLeft(void) const double Node::getComputedLeft(void) const {
{
return YGNodeLayoutGetLeft(m_node); return YGNodeLayoutGetLeft(m_node);
} }
double Node::getComputedRight(void) const double Node::getComputedRight(void) const {
{
return YGNodeLayoutGetRight(m_node); return YGNodeLayoutGetRight(m_node);
} }
double Node::getComputedTop(void) const double Node::getComputedTop(void) const {
{
return YGNodeLayoutGetTop(m_node); return YGNodeLayoutGetTop(m_node);
} }
double Node::getComputedBottom(void) const double Node::getComputedBottom(void) const {
{
return YGNodeLayoutGetBottom(m_node); return YGNodeLayoutGetBottom(m_node);
} }
double Node::getComputedWidth(void) const double Node::getComputedWidth(void) const {
{
return YGNodeLayoutGetWidth(m_node); return YGNodeLayoutGetWidth(m_node);
} }
double Node::getComputedHeight(void) const double Node::getComputedHeight(void) const {
{
return YGNodeLayoutGetHeight(m_node); return YGNodeLayoutGetHeight(m_node);
} }
Layout Node::getComputedLayout(void) const Layout Node::getComputedLayout(void) const {
{
Layout layout; Layout layout;
layout.left = YGNodeLayoutGetLeft(m_node); layout.left = YGNodeLayoutGetLeft(m_node);
@@ -517,17 +444,14 @@ Layout Node::getComputedLayout(void) const
return layout; return layout;
} }
double Node::getComputedMargin(int edge) const double Node::getComputedMargin(int edge) const {
{
return YGNodeLayoutGetMargin(m_node, static_cast<YGEdge>(edge)); return YGNodeLayoutGetMargin(m_node, static_cast<YGEdge>(edge));
} }
double Node::getComputedBorder(int edge) const double Node::getComputedBorder(int edge) const {
{
return YGNodeLayoutGetBorder(m_node, static_cast<YGEdge>(edge)); return YGNodeLayoutGetBorder(m_node, static_cast<YGEdge>(edge));
} }
double Node::getComputedPadding(int edge) const double Node::getComputedPadding(int edge) const {
{
return YGNodeLayoutGetPadding(m_node, static_cast<YGEdge>(edge)); return YGNodeLayoutGetPadding(m_node, static_cast<YGEdge>(edge));
} }

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
#pragma once #pragma once
#include <memory> #include <memory>
@@ -21,36 +20,29 @@
class Node { class Node {
public: public:
static Node* createDefault(void); static Node* createDefault(void);
static Node* createWithConfig(Config* config); static Node* createWithConfig(Config* config);
static void destroy(Node* node); static void destroy(Node* node);
public: public:
static Node* fromYGNode(YGNodeRef nodeRef); static Node* fromYGNode(YGNodeRef nodeRef);
private: private:
Node(Config* config); Node(Config* config);
public: public:
~Node(void); ~Node(void);
public: // Prevent accidental copy public: // Prevent accidental copy
Node(Node const&) = delete; Node(Node const&) = delete;
Node const& operator=(Node const&) = delete; Node const& operator=(Node const&) = delete;
public: public:
void reset(void); void reset(void);
public: // Style setters public: // Style setters
void copyStyle(Node const& other); void copyStyle(Node const& other);
void setPositionType(int positionType); void setPositionType(int positionType);
@@ -103,7 +95,6 @@ class Node {
void setPaddingPercent(int edge, double padding); void setPaddingPercent(int edge, double padding);
public: // Style getters public: // Style getters
int getPositionType(void) const; int getPositionType(void) const;
Value getPosition(int edge) const; Value getPosition(int edge) const;
@@ -139,48 +130,44 @@ class Node {
Value getPadding(int edge) const; Value getPadding(int edge) const;
public: // Tree hierarchy mutators public: // Tree hierarchy mutators
void insertChild(Node* child, unsigned index); void insertChild(Node* child, unsigned index);
void removeChild(Node* child); void removeChild(Node* child);
public: // Tree hierarchy inspectors public: // Tree hierarchy inspectors
unsigned getChildCount(void) const; unsigned getChildCount(void) const;
// The following functions cannot be const because they could discard const qualifiers (ex: constNode->getChild(0)->getParent() wouldn't be const) // The following functions cannot be const because they could discard const
// qualifiers (ex: constNode->getChild(0)->getParent() wouldn't be const)
Node* getParent(void); Node* getParent(void);
Node* getChild(unsigned index); Node* getChild(unsigned index);
public: // Measure func mutators public: // Measure func mutators
void setMeasureFunc(nbind::cbFunction& measureFunc); void setMeasureFunc(nbind::cbFunction& measureFunc);
void unsetMeasureFunc(void); void unsetMeasureFunc(void);
public: // Measure func inspectors public: // Measure func inspectors
Size callMeasureFunc(
Size callMeasureFunc(double width, int widthMode, double height, int heightMode) const; double width,
int widthMode,
double height,
int heightMode) const;
public: // Dirtied func mutators public: // Dirtied func mutators
void setDirtiedFunc(nbind::cbFunction& dirtiedFunc); void setDirtiedFunc(nbind::cbFunction& dirtiedFunc);
void unsetDirtiedFunc(void); void unsetDirtiedFunc(void);
public: // Dirtied func inspectors public: // Dirtied func inspectors
void callDirtiedFunc(void) const; void callDirtiedFunc(void) const;
public: // Dirtiness accessors public: // Dirtiness accessors
void markDirty(void); void markDirty(void);
bool isDirty(void) const; bool isDirty(void) const;
public: // Layout mutators public: // Layout mutators
void calculateLayout(double width, double height, int direction); void calculateLayout(double width, double height, int direction);
public: // Layout inspectors public: // Layout inspectors
double getComputedLeft(void) const; double getComputedLeft(void) const;
double getComputedRight(void) const; double getComputedRight(void) const;

View File

@@ -1,34 +1,23 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
#pragma once #pragma once
#include <nbind/api.h> #include <nbind/api.h>
#include <nbind/BindDefiner.h> #include <nbind/BindDefiner.h>
struct Size struct Size {
{
double width; double width;
double height; double height;
Size(void) Size(void) : width(0.0), height(0.0) {}
: width(0.0)
, height(0.0)
{
}
Size(double width, double height) Size(double width, double height) : width(width), height(height) {}
: width(width)
, height(height)
{
}
void toJS(nbind::cbOutput expose) const void toJS(nbind::cbOutput expose) const {
{
expose(width, height); expose(width, height);
} }
}; };

View File

@@ -1,38 +1,26 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
#pragma once #pragma once
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
struct Value struct Value {
{ static Value fromYGValue(YGValue const& ygValue) {
static Value fromYGValue(YGValue const & ygValue)
{
return Value(static_cast<int>(ygValue.unit), ygValue.value); return Value(static_cast<int>(ygValue.unit), ygValue.value);
} }
int unit; int unit;
double value; double value;
Value(void) Value(void) : unit(YGUnitUndefined), value(0.0) {}
: unit(YGUnitUndefined)
, value(0.0)
{
}
Value(int unit, double value) Value(int unit, double value) : unit(unit), value(value) {}
: unit(unit)
, value(value)
{
}
void toJS(nbind::cbOutput expose) const void toJS(nbind::cbOutput expose) const {
{
expose(unit, value); expose(unit, value);
} }
}; };

View File

@@ -8,7 +8,6 @@
#include "./global.hh" #include "./global.hh"
unsigned getInstanceCount(void) unsigned getInstanceCount(void) {
{
return YGNodeGetInstanceCount(); return YGNodeGetInstanceCount();
} }

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* 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
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
#pragma once #pragma once
unsigned getInstanceCount(void); unsigned getInstanceCount(void);

View File

@@ -15,30 +15,25 @@
#include <nbind/nbind.h> #include <nbind/nbind.h>
NBIND_GLOBAL() NBIND_GLOBAL() {
{
function(getInstanceCount); function(getInstanceCount);
} }
NBIND_CLASS(Size) NBIND_CLASS(Size) {
{
construct<>(); construct<>();
construct<double, double>(); construct<double, double>();
} }
NBIND_CLASS(Layout) NBIND_CLASS(Layout) {
{
construct<>(); construct<>();
} }
NBIND_CLASS(Value) NBIND_CLASS(Value) {
{
construct<>(); construct<>();
construct<int, double>(); construct<int, double>();
} }
NBIND_CLASS(Config) NBIND_CLASS(Config) {
{
method(create); method(create);
method(destroy); method(destroy);
@@ -49,8 +44,7 @@ NBIND_CLASS(Config)
method(isExperimentalFeatureEnabled); method(isExperimentalFeatureEnabled);
} }
NBIND_CLASS(Node) NBIND_CLASS(Node) {
{
method(createDefault); method(createDefault);
method(createWithConfig); method(createWithConfig);
method(destroy); method(destroy);

View File

@@ -4,7 +4,8 @@
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html // @Generated by gentest/gentest.rb from
// gentest/fixtures/YGAbsolutePositionTest.html
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
@@ -183,7 +184,9 @@ TEST(YogaTest, absolute_layout_width_height_start_top_end_bottom) {
YGConfigFree(config); YGConfigFree(config);
} }
TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent) { TEST(
YogaTest,
do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent) {
const YGConfigRef config = YGConfigNew(); const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);
@@ -575,7 +578,9 @@ TEST(YogaTest, absolute_layout_align_items_center_on_child_only) {
YGConfigFree(config); YGConfigFree(config);
} }
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_top_position) { TEST(
YogaTest,
absolute_layout_align_items_and_justify_content_center_and_top_position) {
const YGConfigRef config = YGConfigNew(); const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);
@@ -620,7 +625,9 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_top_po
YGConfigFree(config); YGConfigFree(config);
} }
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_bottom_position) { TEST(
YogaTest,
absolute_layout_align_items_and_justify_content_center_and_bottom_position) {
const YGConfigRef config = YGConfigNew(); const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);
@@ -665,7 +672,9 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_bottom
YGConfigFree(config); YGConfigFree(config);
} }
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_left_position) { TEST(
YogaTest,
absolute_layout_align_items_and_justify_content_center_and_left_position) {
const YGConfigRef config = YGConfigNew(); const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);
@@ -710,7 +719,9 @@ TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_left_p
YGConfigFree(config); YGConfigFree(config);
} }
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_right_position) { TEST(
YogaTest,
absolute_layout_align_items_and_justify_content_center_and_right_position) {
const YGConfigRef config = YGConfigNew(); const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);

View File

@@ -8,8 +8,10 @@
#include <yoga/YGNode.h> #include <yoga/YGNode.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
static float static float _baselineFunc(
_baselineFunc(YGNodeRef node, const float width, const float height) { YGNodeRef node,
const float width,
const float height) {
return height / 2; return height / 2;
} }

View File

@@ -4,7 +4,8 @@
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html // @Generated by gentest/gentest.rb from
// gentest/fixtures/YGAlignContentTest.html
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>

View File

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

View File

@@ -4,7 +4,8 @@
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html // @Generated by gentest/gentest.rb from
// gentest/fixtures/YGFlexDirectionTest.html
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>

View File

@@ -29,7 +29,9 @@ protected:
YGConfigRef config; YGConfigRef config;
}; };
TEST_F(YogaTest_HadOverflowTests, children_overflow_no_wrap_and_no_flex_children) { TEST_F(
YogaTest_HadOverflowTests,
children_overflow_no_wrap_and_no_flex_children) {
const YGNodeRef child0 = YGNodeNewWithConfig(config); const YGNodeRef child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(child0, 80); YGNodeStyleSetWidth(child0, 80);
YGNodeStyleSetHeight(child0, 40); YGNodeStyleSetHeight(child0, 40);
@@ -47,7 +49,9 @@ TEST_F(YogaTest_HadOverflowTests, children_overflow_no_wrap_and_no_flex_children
ASSERT_TRUE(YGNodeLayoutGetHadOverflow(root)); ASSERT_TRUE(YGNodeLayoutGetHadOverflow(root));
} }
TEST_F(YogaTest_HadOverflowTests, spacing_overflow_no_wrap_and_no_flex_children) { TEST_F(
YogaTest_HadOverflowTests,
spacing_overflow_no_wrap_and_no_flex_children) {
const YGNodeRef child0 = YGNodeNewWithConfig(config); const YGNodeRef child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(child0, 80); YGNodeStyleSetWidth(child0, 80);
YGNodeStyleSetHeight(child0, 40); YGNodeStyleSetHeight(child0, 40);

View File

@@ -9,7 +9,8 @@
// This test isn't correct from the Flexbox standard standpoint, // This test isn't correct from the Flexbox standard standpoint,
// because percentages are calculated with parent constraints. // because percentages are calculated with parent constraints.
// However, we need to make sure we fail gracefully in this case, not returning NaN // However, we need to make sure we fail gracefully in this case, not returning
// NaN
TEST(YogaTest, percent_absolute_position_infinite_height) { TEST(YogaTest, percent_absolute_position_infinite_height) {
const YGConfigRef config = YGConfigNew(); const YGConfigRef config = YGConfigNew();

View File

@@ -10,17 +10,19 @@
namespace { namespace {
char writeBuffer[4096]; char writeBuffer[4096];
int _unmanagedLogger(const YGConfigRef config, int _unmanagedLogger(
const YGConfigRef config,
const YGNodeRef node, const YGNodeRef node,
YGLogLevel level, YGLogLevel level,
const char* format, const char* format,
va_list args) { va_list args) {
return vsnprintf(writeBuffer + strlen(writeBuffer), return vsnprintf(
writeBuffer + strlen(writeBuffer),
sizeof(writeBuffer) - strlen(writeBuffer), sizeof(writeBuffer) - strlen(writeBuffer),
format, format,
args); args);
} }
} } // namespace
TEST(YogaTest, config_print_tree_enabled) { TEST(YogaTest, config_print_tree_enabled) {
writeBuffer[0] = '\0'; writeBuffer[0] = '\0';
@@ -68,13 +70,16 @@ TEST(YogaTest, logger_default_node_should_print_no_style_info) {
YGConfigSetLogger(config, _unmanagedLogger); YGConfigSetLogger(config, _unmanagedLogger);
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR);
YGNodePrint(root, YGNodePrint(
(YGPrintOptions)(YGPrintOptionsLayout | YGPrintOptionsChildren | root,
YGPrintOptionsStyle)); (YGPrintOptions)(
YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGConfigSetLogger(config, NULL); YGConfigSetLogger(config, NULL);
YGNodeFree(root); YGNodeFree(root);
const char *expected = "<div layout=\"width: 0; height: 0; top: 0; left: 0;\" style=\"\" ></div>"; const char* expected =
"<div layout=\"width: 0; height: 0; top: 0; left: 0;\" style=\"\" "
"></div>";
ASSERT_STREQ(expected, writeBuffer); ASSERT_STREQ(expected, writeBuffer);
} }
@@ -90,13 +95,15 @@ TEST(YogaTest, logger_node_with_percentage_absolute_position_and_margin) {
YGNodeStyleSetMargin(root, YGEdgeRight, 10); YGNodeStyleSetMargin(root, YGEdgeRight, 10);
YGNodeStyleSetMarginAuto(root, YGEdgeLeft); YGNodeStyleSetMarginAuto(root, YGEdgeLeft);
YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR);
YGNodePrint(root, YGNodePrint(
(YGPrintOptions)(YGPrintOptionsLayout | YGPrintOptionsChildren | root,
YGPrintOptionsStyle)); (YGPrintOptions)(
YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGConfigSetLogger(config, NULL); YGConfigSetLogger(config, NULL);
YGNodeFree(root); YGNodeFree(root);
const char *expected = "<div layout=\"width: 0; height: 0; top: 0; left: 0;\" style=\"flex: 1; " const char* expected =
"<div layout=\"width: 0; height: 0; top: 0; left: 0;\" style=\"flex: 1; "
"margin-left: auto; margin-right: 10px; width: 50%; height: 75%; " "margin-left: auto; margin-right: 10px; width: 50%; height: 75%; "
"position: absolute; \" ></div>"; "position: absolute; \" ></div>";
ASSERT_STREQ(expected, writeBuffer); ASSERT_STREQ(expected, writeBuffer);
@@ -112,13 +119,15 @@ TEST(YogaTest, logger_node_with_children_should_print_indented) {
YGNodeInsertChild(root, child0, 0); YGNodeInsertChild(root, child0, 0);
YGNodeInsertChild(root, child1, 1); YGNodeInsertChild(root, child1, 1);
YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR);
YGNodePrint(root, YGNodePrint(
(YGPrintOptions)(YGPrintOptionsLayout | YGPrintOptionsChildren | root,
YGPrintOptionsStyle)); (YGPrintOptions)(
YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGConfigSetLogger(config, NULL); YGConfigSetLogger(config, NULL);
YGNodeFreeRecursive(root); YGNodeFreeRecursive(root);
const char *expected = "<div layout=\"width: 0; height: 0; top: 0; left: 0;\" style=\"\" >\n " const char* expected =
"<div layout=\"width: 0; height: 0; top: 0; left: 0;\" style=\"\" >\n "
"<div layout=\"width: 0; height: 0; top: 0; left: 0;\" style=\"\" " "<div layout=\"width: 0; height: 0; top: 0; left: 0;\" style=\"\" "
"></div>\n <div layout=\"width: 0; height: 0; top: 0; left: 0;\" " "></div>\n <div layout=\"width: 0; height: 0; top: 0; left: 0;\" "
"style=\"\" ></div>\n</div>"; "style=\"\" ></div>\n</div>";

View File

@@ -8,7 +8,8 @@
#include <yoga/YGNode.h> #include <yoga/YGNode.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
static YGSize _measureMax(YGNodeRef node, static YGSize _measureMax(
YGNodeRef node,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, float height,
@@ -22,7 +23,8 @@ static YGSize _measureMax(YGNodeRef node,
}; };
} }
static YGSize _measureMin(YGNodeRef node, static YGSize _measureMin(
YGNodeRef node,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, float height,
@@ -30,18 +32,19 @@ static YGSize _measureMin(YGNodeRef node,
int* measureCount = (int*) node->getContext(); int* measureCount = (int*) node->getContext();
*measureCount = *measureCount + 1; *measureCount = *measureCount + 1;
return YGSize{ return YGSize{
.width = .width = widthMode == YGMeasureModeUndefined ||
widthMode == YGMeasureModeUndefined || (widthMode == YGMeasureModeAtMost && width > 10) (widthMode == YGMeasureModeAtMost && width > 10)
? 10 ? 10
: width, : width,
.height = .height = heightMode == YGMeasureModeUndefined ||
heightMode == YGMeasureModeUndefined || (heightMode == YGMeasureModeAtMost && height > 10) (heightMode == YGMeasureModeAtMost && height > 10)
? 10 ? 10
: height, : height,
}; };
} }
static YGSize _measure_84_49(YGNodeRef node, static YGSize _measure_84_49(
YGNodeRef node,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, float height,
@@ -52,7 +55,8 @@ static YGSize _measure_84_49(YGNodeRef node,
} }
return YGSize{ return YGSize{
.width = 84.f, .height = 49.f, .width = 84.f,
.height = 49.f,
}; };
} }
@@ -149,7 +153,9 @@ TEST(YogaTest, remeasure_with_atmost_computed_width_undefined_height) {
YGNodeFreeRecursive(root); YGNodeFreeRecursive(root);
} }
TEST(YogaTest, remeasure_with_already_measured_value_smaller_but_still_float_equal) { TEST(
YogaTest,
remeasure_with_already_measured_value_smaller_but_still_float_equal) {
int measureCount = 0; int measureCount = 0;
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();

View File

@@ -20,7 +20,8 @@ struct _MeasureConstraintList {
struct _MeasureConstraint* constraints; struct _MeasureConstraint* constraints;
}; };
static YGSize _measure(YGNodeRef node, static YGSize _measure(
YGNodeRef node,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, float height,
@@ -44,7 +45,8 @@ static YGSize _measure(YGNodeRef node,
TEST(YogaTest, exactly_measure_stretched_child_column) { TEST(YogaTest, exactly_measure_stretched_child_column) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList{ struct _MeasureConstraintList constraintList = _MeasureConstraintList{
.length = 0, .length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), .constraints = (struct _MeasureConstraint*) malloc(
10 * sizeof(struct _MeasureConstraint)),
}; };
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
@@ -72,7 +74,8 @@ TEST(YogaTest, exactly_measure_stretched_child_column) {
TEST(YogaTest, exactly_measure_stretched_child_row) { TEST(YogaTest, exactly_measure_stretched_child_row) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList{ struct _MeasureConstraintList constraintList = _MeasureConstraintList{
.length = 0, .length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), .constraints = (struct _MeasureConstraint*) malloc(
10 * sizeof(struct _MeasureConstraint)),
}; };
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
@@ -100,7 +103,8 @@ TEST(YogaTest, exactly_measure_stretched_child_row) {
TEST(YogaTest, at_most_main_axis_column) { TEST(YogaTest, at_most_main_axis_column) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList{ struct _MeasureConstraintList constraintList = _MeasureConstraintList{
.length = 0, .length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), .constraints = (struct _MeasureConstraint*) malloc(
10 * sizeof(struct _MeasureConstraint)),
}; };
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
@@ -126,7 +130,8 @@ TEST(YogaTest, at_most_main_axis_column) {
TEST(YogaTest, at_most_cross_axis_column) { TEST(YogaTest, at_most_cross_axis_column) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList{ struct _MeasureConstraintList constraintList = _MeasureConstraintList{
.length = 0, .length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), .constraints = (struct _MeasureConstraint*) malloc(
10 * sizeof(struct _MeasureConstraint)),
}; };
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
@@ -153,7 +158,8 @@ TEST(YogaTest, at_most_cross_axis_column) {
TEST(YogaTest, at_most_main_axis_row) { TEST(YogaTest, at_most_main_axis_row) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList{ struct _MeasureConstraintList constraintList = _MeasureConstraintList{
.length = 0, .length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), .constraints = (struct _MeasureConstraint*) malloc(
10 * sizeof(struct _MeasureConstraint)),
}; };
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
@@ -180,7 +186,8 @@ TEST(YogaTest, at_most_main_axis_row) {
TEST(YogaTest, at_most_cross_axis_row) { TEST(YogaTest, at_most_cross_axis_row) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList{ struct _MeasureConstraintList constraintList = _MeasureConstraintList{
.length = 0, .length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), .constraints = (struct _MeasureConstraint*) malloc(
10 * sizeof(struct _MeasureConstraint)),
}; };
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
@@ -208,7 +215,8 @@ TEST(YogaTest, at_most_cross_axis_row) {
TEST(YogaTest, flex_child) { TEST(YogaTest, flex_child) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList{ struct _MeasureConstraintList constraintList = _MeasureConstraintList{
.length = 0, .length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), .constraints = (struct _MeasureConstraint*) malloc(
10 * sizeof(struct _MeasureConstraint)),
}; };
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
@@ -237,7 +245,8 @@ TEST(YogaTest, flex_child) {
TEST(YogaTest, flex_child_with_flex_basis) { TEST(YogaTest, flex_child_with_flex_basis) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList{ struct _MeasureConstraintList constraintList = _MeasureConstraintList{
.length = 0, .length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), .constraints = (struct _MeasureConstraint*) malloc(
10 * sizeof(struct _MeasureConstraint)),
}; };
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
@@ -264,7 +273,8 @@ TEST(YogaTest, flex_child_with_flex_basis) {
TEST(YogaTest, overflow_scroll_column) { TEST(YogaTest, overflow_scroll_column) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList{ struct _MeasureConstraintList constraintList = _MeasureConstraintList{
.length = 0, .length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), .constraints = (struct _MeasureConstraint*) malloc(
10 * sizeof(struct _MeasureConstraint)),
}; };
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
@@ -295,7 +305,8 @@ TEST(YogaTest, overflow_scroll_column) {
TEST(YogaTest, overflow_scroll_row) { TEST(YogaTest, overflow_scroll_row) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList{ struct _MeasureConstraintList constraintList = _MeasureConstraintList{
.length = 0, .length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), .constraints = (struct _MeasureConstraint*) malloc(
10 * sizeof(struct _MeasureConstraint)),
}; };
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();

View File

@@ -4,7 +4,8 @@
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGMinMaxDimensionTest.html // @Generated by gentest/gentest.rb from
// gentest/fixtures/YGMinMaxDimensionTest.html
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>

View File

@@ -647,7 +647,9 @@ TEST(YogaTest, percentage_flex_basis_cross_min_width) {
YGConfigFree(config); YGConfigFree(config);
} }
TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_values) { TEST(
YogaTest,
percentage_multiple_nested_with_padding_margin_and_percentage_values) {
const YGConfigRef config = YGConfigNew(); const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);

View File

@@ -9,7 +9,8 @@
TEST(YogaTest, dont_cache_computed_flex_basis_between_layouts) { TEST(YogaTest, dont_cache_computed_flex_basis_between_layouts) {
const YGConfigRef config = YGConfigNew(); const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureWebFlexBasis, true); YGConfigSetExperimentalFeatureEnabled(
config, YGExperimentalFeatureWebFlexBasis, true);
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetHeightPercent(root, 100); YGNodeStyleSetHeightPercent(root, 100);

View File

@@ -24,7 +24,8 @@ TEST(YogaTest, rounding_value) {
ASSERT_FLOAT_EQ(-6.0, YGRoundValueToPixelGrid(-5.999999, 2.0, true, false)); ASSERT_FLOAT_EQ(-6.0, YGRoundValueToPixelGrid(-5.999999, 2.0, true, false));
ASSERT_FLOAT_EQ(-6.0, YGRoundValueToPixelGrid(-5.999999, 2.0, false, true)); ASSERT_FLOAT_EQ(-6.0, YGRoundValueToPixelGrid(-5.999999, 2.0, false, true));
// Test that numbers with fraction are rounded correctly accounting for ceil/floor flags // Test that numbers with fraction are rounded correctly accounting for
// ceil/floor flags
ASSERT_FLOAT_EQ(6.0, YGRoundValueToPixelGrid(6.01, 2.0, false, false)); ASSERT_FLOAT_EQ(6.0, YGRoundValueToPixelGrid(6.01, 2.0, false, false));
ASSERT_FLOAT_EQ(6.5, YGRoundValueToPixelGrid(6.01, 2.0, true, false)); ASSERT_FLOAT_EQ(6.5, YGRoundValueToPixelGrid(6.01, 2.0, true, false));
ASSERT_FLOAT_EQ(6.0, YGRoundValueToPixelGrid(6.01, 2.0, false, true)); ASSERT_FLOAT_EQ(6.0, YGRoundValueToPixelGrid(6.01, 2.0, false, true));

View File

@@ -8,33 +8,39 @@
#include <yoga/YGNode.h> #include <yoga/YGNode.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
static YGSize _measureFloor(YGNodeRef node, static YGSize _measureFloor(
YGNodeRef node,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, float height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
return YGSize{ return YGSize{
width = 10.2f, height = 10.2f, width = 10.2f,
height = 10.2f,
}; };
} }
static YGSize _measureCeil(YGNodeRef node, static YGSize _measureCeil(
YGNodeRef node,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, float height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
return YGSize{ return YGSize{
width = 10.5f, height = 10.5f, width = 10.5f,
height = 10.5f,
}; };
} }
static YGSize _measureFractial(YGNodeRef node, static YGSize _measureFractial(
YGNodeRef node,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, float height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
return YGSize{ return YGSize{
width = 0.5f, height = 0.5f, width = 0.5f,
height = 0.5f,
}; };
} }
@@ -106,7 +112,9 @@ TEST(YogaTest, rounding_feature_with_custom_measure_func_ceil) {
YGConfigFree(config); YGConfigFree(config);
} }
TEST(YogaTest, rounding_feature_with_custom_measure_and_fractial_matching_scale) { TEST(
YogaTest,
rounding_feature_with_custom_measure_and_fractial_matching_scale) {
const YGConfigRef config = YGConfigNew(); const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);

View File

@@ -4,7 +4,8 @@
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html // @Generated by gentest/gentest.rb from
// gentest/fixtures/YGSizeOverflowTest.html
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>

View File

@@ -17,16 +17,11 @@ TEST(YogaTest, pre_order_traversal) {
YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeInsertChild(root_child0, root_child0_child0, 0);
std::vector<YGNodeRef> visited; std::vector<YGNodeRef> visited;
YGTraversePreOrder(root, [&visited](YGNodeRef node) { YGTraversePreOrder(
visited.push_back(node); root, [&visited](YGNodeRef node) { visited.push_back(node); });
});
const std::vector<YGNodeRef> expected = { const std::vector<YGNodeRef> expected = {
root, root, root_child0, root_child0_child0, root_child1};
root_child0,
root_child0_child0,
root_child1
};
ASSERT_EQ(visited, expected); ASSERT_EQ(visited, expected);
YGNodeFreeRecursive(root); YGNodeFreeRecursive(root);

View File

@@ -7,8 +7,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
static std::vector<YGNodeRef> getChildren(YGNodeRef const node) static std::vector<YGNodeRef> getChildren(YGNodeRef const node) {
{
const uint32_t count = YGNodeGetChildCount(node); const uint32_t count = YGNodeGetChildCount(node);
std::vector<YGNodeRef> children; std::vector<YGNodeRef> children;
children.reserve(count); children.reserve(count);
@@ -29,7 +28,8 @@ TEST(YogaTest, set_children_adds_children_to_parent) {
const std::vector<YGNodeRef> expectedChildren = {root_child0, root_child1}; const std::vector<YGNodeRef> expectedChildren = {root_child0, root_child1};
ASSERT_EQ(children, expectedChildren); ASSERT_EQ(children, expectedChildren);
const std::vector<YGNodeRef> owners = {YGNodeGetOwner(root_child0), YGNodeGetOwner(root_child1)}; const std::vector<YGNodeRef> owners = {YGNodeGetOwner(root_child0),
YGNodeGetOwner(root_child1)};
const std::vector<YGNodeRef> expectedOwners = {root, root}; const std::vector<YGNodeRef> expectedOwners = {root, root};
ASSERT_EQ(owners, expectedOwners); ASSERT_EQ(owners, expectedOwners);
@@ -48,7 +48,8 @@ TEST(YogaTest, set_children_to_empty_removes_old_children) {
const std::vector<YGNodeRef> expectedChildren = {}; const std::vector<YGNodeRef> expectedChildren = {};
ASSERT_EQ(children, expectedChildren); ASSERT_EQ(children, expectedChildren);
const std::vector<YGNodeRef> owners = {YGNodeGetOwner(root_child0), YGNodeGetOwner(root_child1)}; const std::vector<YGNodeRef> owners = {YGNodeGetOwner(root_child0),
YGNodeGetOwner(root_child1)};
const std::vector<YGNodeRef> expectedOwners = {nullptr, nullptr}; const std::vector<YGNodeRef> expectedOwners = {nullptr, nullptr};
ASSERT_EQ(owners, expectedOwners); ASSERT_EQ(owners, expectedOwners);
@@ -71,7 +72,8 @@ TEST(YogaTest, set_children_replaces_non_common_children) {
const std::vector<YGNodeRef> expectedChildren = {root_child2, root_child3}; const std::vector<YGNodeRef> expectedChildren = {root_child2, root_child3};
ASSERT_EQ(children, expectedChildren); ASSERT_EQ(children, expectedChildren);
const std::vector<YGNodeRef> owners = {YGNodeGetOwner(root_child0), YGNodeGetOwner(root_child1)}; const std::vector<YGNodeRef> owners = {YGNodeGetOwner(root_child0),
YGNodeGetOwner(root_child1)};
const std::vector<YGNodeRef> expectedOwners = {nullptr, nullptr}; const std::vector<YGNodeRef> expectedOwners = {nullptr, nullptr};
ASSERT_EQ(owners, expectedOwners); ASSERT_EQ(owners, expectedOwners);
@@ -93,15 +95,14 @@ TEST(YogaTest, set_children_keeps_and_reorders_common_children) {
YGNodeSetChildren(root, {root_child2, root_child1, root_child3}); YGNodeSetChildren(root, {root_child2, root_child1, root_child3});
const std::vector<YGNodeRef> children = getChildren(root); const std::vector<YGNodeRef> children = getChildren(root);
const std::vector<YGNodeRef> expectedChildren = {root_child2, root_child1, root_child3}; const std::vector<YGNodeRef> expectedChildren = {
root_child2, root_child1, root_child3};
ASSERT_EQ(children, expectedChildren); ASSERT_EQ(children, expectedChildren);
const std::vector<YGNodeRef> owners = { const std::vector<YGNodeRef> owners = {YGNodeGetOwner(root_child0),
YGNodeGetOwner(root_child0),
YGNodeGetOwner(root_child1), YGNodeGetOwner(root_child1),
YGNodeGetOwner(root_child2), YGNodeGetOwner(root_child2),
YGNodeGetOwner(root_child3) YGNodeGetOwner(root_child3)};
};
const std::vector<YGNodeRef> expectedOwners = {nullptr, root, root, root}; const std::vector<YGNodeRef> expectedOwners = {nullptr, root, root, root};
ASSERT_EQ(owners, expectedOwners); ASSERT_EQ(owners, expectedOwners);

View File

@@ -4,7 +4,6 @@
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
#include "log.h" #include "log.h"
#include "Yoga.h" #include "Yoga.h"