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

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

View File

@@ -1,10 +1,9 @@
/**
* 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.
* 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 <nbind/api.h>
@@ -13,39 +12,31 @@
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:
Config(void);
private:
public:
~Config(void);
Config(void);
public: // Prevent accidental copy
Config(Config const&) = delete;
public:
Config const& operator=(Config const&) = delete;
~Config(void);
public: // Setters
void setExperimentalFeatureEnabled(int feature, bool enabled);
void setPointScaleFactor(float pixelsInPoint);
public: // Prevent accidental copy
Config(Config const &) = delete;
Config const & operator=(Config const &) = delete;
public: // Setters
void setExperimentalFeatureEnabled(int feature, bool enabled);
void setPointScaleFactor(float pixelsInPoint);
public: // Getters
bool isExperimentalFeatureEnabled(int feature) const;
private:
YGConfigRef m_config;
public: // Getters
bool isExperimentalFeatureEnabled(int feature) const;
private:
YGConfigRef m_config;
};

View File

@@ -1,28 +1,25 @@
/**
* 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.
* 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 <nbind/api.h>
#include <nbind/BindDefiner.h>
struct Layout
{
double left;
double right;
struct Layout {
double left;
double right;
double top;
double bottom;
double top;
double bottom;
double width;
double height;
double width;
double height;
void toJS(nbind::cbOutput expose) const
{
expose(left, right, top, bottom, width, height);
}
void toJS(nbind::cbOutput expose) const {
expose(left, right, top, bottom, width, height);
}
};

View File

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

View File

@@ -1,10 +1,9 @@
/**
* 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.
* 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 <memory>
@@ -20,188 +19,176 @@
class Node {
public:
public:
static Node* createDefault(void);
static Node* createWithConfig(Config* config);
static Node * createDefault(void);
static Node * createWithConfig(Config * config);
static void destroy(Node* node);
static void destroy(Node * node);
public:
static Node* fromYGNode(YGNodeRef nodeRef);
public:
private:
Node(Config* config);
static Node * fromYGNode(YGNodeRef nodeRef);
public:
~Node(void);
private:
public: // Prevent accidental copy
Node(Node const&) = delete;
Node(Config * config);
Node const& operator=(Node const&) = delete;
public:
public:
void reset(void);
~Node(void);
public: // Style setters
void copyStyle(Node const& other);
public: // Prevent accidental copy
void setPositionType(int positionType);
void setPosition(int edge, double position);
void setPositionPercent(int edge, double position);
Node(Node const &) = delete;
void setAlignContent(int alignContent);
void setAlignItems(int alignItems);
void setAlignSelf(int alignSelf);
void setFlexDirection(int flexDirection);
void setFlexWrap(int flexWrap);
void setJustifyContent(int justifyContent);
Node const & operator=(Node const &) = delete;
void setMargin(int edge, double margin);
void setMarginPercent(int edge, double margin);
void setMarginAuto(int edge);
public:
void setOverflow(int overflow);
void setDisplay(int display);
void reset(void);
void setFlex(double flex);
void setFlexBasis(double flexBasis);
void setFlexBasisPercent(double flexBasis);
void setFlexBasisAuto();
void setFlexGrow(double flexGrow);
void setFlexShrink(double flexShrink);
public: // Style setters
void setWidth(double width);
void setWidthPercent(double width);
void setWidthAuto();
void setHeight(double height);
void setHeightPercent(double height);
void setHeightAuto();
void copyStyle(Node const & other);
void setMinWidth(double minWidth);
void setMinWidthPercent(double minWidth);
void setMinHeight(double minHeight);
void setMinHeightPercent(double minHeight);
void setPositionType(int positionType);
void setPosition(int edge, double position);
void setPositionPercent(int edge, double position);
void setMaxWidth(double maxWidth);
void setMaxWidthPercent(double maxWidth);
void setMaxHeight(double maxHeight);
void setMaxHeightPercent(double maxHeight);
void setAlignContent(int alignContent);
void setAlignItems(int alignItems);
void setAlignSelf(int alignSelf);
void setFlexDirection(int flexDirection);
void setFlexWrap(int flexWrap);
void setJustifyContent(int justifyContent);
void setAspectRatio(double aspectRatio);
void setMargin(int edge, double margin);
void setMarginPercent(int edge, double margin);
void setMarginAuto(int edge);
void setBorder(int edge, double border);
void setOverflow(int overflow);
void setDisplay(int display);
void setPadding(int edge, double padding);
void setPaddingPercent(int edge, double padding);
void setFlex(double flex);
void setFlexBasis(double flexBasis);
void setFlexBasisPercent(double flexBasis);
void setFlexBasisAuto();
void setFlexGrow(double flexGrow);
void setFlexShrink(double flexShrink);
public: // Style getters
int getPositionType(void) const;
Value getPosition(int edge) const;
void setWidth(double width);
void setWidthPercent(double width);
void setWidthAuto();
void setHeight(double height);
void setHeightPercent(double height);
void setHeightAuto();
int getAlignContent(void) const;
int getAlignItems(void) const;
int getAlignSelf(void) const;
int getFlexDirection(void) const;
int getFlexWrap(void) const;
int getJustifyContent(void) const;
void setMinWidth(double minWidth);
void setMinWidthPercent(double minWidth);
void setMinHeight(double minHeight);
void setMinHeightPercent(double minHeight);
Value getMargin(int edge) const;
void setMaxWidth(double maxWidth);
void setMaxWidthPercent(double maxWidth);
void setMaxHeight(double maxHeight);
void setMaxHeightPercent(double maxHeight);
int getOverflow(void) const;
int getDisplay(void) const;
void setAspectRatio(double aspectRatio);
Value getFlexBasis(void) const;
double getFlexGrow(void) const;
double getFlexShrink(void) const;
void setBorder(int edge, double border);
Value getWidth(void) const;
Value getHeight(void) const;
void setPadding(int edge, double padding);
void setPaddingPercent(int edge, double padding);
Value getMinWidth(void) const;
Value getMinHeight(void) const;
public: // Style getters
Value getMaxWidth(void) const;
Value getMaxHeight(void) const;
int getPositionType(void) const;
Value getPosition(int edge) const;
double getAspectRatio(void) const;
int getAlignContent(void) const;
int getAlignItems(void) const;
int getAlignSelf(void) const;
int getFlexDirection(void) const;
int getFlexWrap(void) const;
int getJustifyContent(void) const;
double getBorder(int edge) const;
Value getMargin(int edge) const;
Value getPadding(int edge) const;
int getOverflow(void) const;
int getDisplay(void) const;
public: // Tree hierarchy mutators
void insertChild(Node* child, unsigned index);
void removeChild(Node* child);
Value getFlexBasis(void) const;
double getFlexGrow(void) const;
double getFlexShrink(void) const;
public: // Tree hierarchy inspectors
unsigned getChildCount(void) const;
Value getWidth(void) const;
Value getHeight(void) const;
// The following functions cannot be const because they could discard const
// qualifiers (ex: constNode->getChild(0)->getParent() wouldn't be const)
Value getMinWidth(void) const;
Value getMinHeight(void) const;
Node* getParent(void);
Node* getChild(unsigned index);
Value getMaxWidth(void) const;
Value getMaxHeight(void) const;
public: // Measure func mutators
void setMeasureFunc(nbind::cbFunction& measureFunc);
void unsetMeasureFunc(void);
double getAspectRatio(void) const;
public: // Measure func inspectors
Size callMeasureFunc(
double width,
int widthMode,
double height,
int heightMode) const;
double getBorder(int edge) const;
public: // Dirtied func mutators
void setDirtiedFunc(nbind::cbFunction& dirtiedFunc);
void unsetDirtiedFunc(void);
Value getPadding(int edge) const;
public: // Dirtied func inspectors
void callDirtiedFunc(void) const;
public: // Tree hierarchy mutators
public: // Dirtiness accessors
void markDirty(void);
bool isDirty(void) const;
void insertChild(Node * child, unsigned index);
void removeChild(Node * child);
public: // Layout mutators
void calculateLayout(double width, double height, int direction);
public: // Tree hierarchy inspectors
public: // Layout inspectors
double getComputedLeft(void) const;
double getComputedRight(void) const;
unsigned getChildCount(void) const;
double getComputedTop(void) const;
double getComputedBottom(void) const;
// The following functions cannot be const because they could discard const qualifiers (ex: constNode->getChild(0)->getParent() wouldn't be const)
double getComputedWidth(void) const;
double getComputedHeight(void) const;
Node * getParent(void);
Node * getChild(unsigned index);
Layout getComputedLayout(void) const;
public: // Measure func mutators
double getComputedMargin(int edge) const;
double getComputedBorder(int edge) const;
double getComputedPadding(int edge) const;
void setMeasureFunc(nbind::cbFunction & measureFunc);
void unsetMeasureFunc(void);
public:
void setIsReferenceBaseline(bool isReferenceBaseline);
bool isReferenceBaseline();
public: // Measure func inspectors
YGNodeRef m_node;
Size callMeasureFunc(double width, int widthMode, double height, int heightMode) const;
public: // Dirtied func mutators
void setDirtiedFunc(nbind::cbFunction & dirtiedFunc);
void unsetDirtiedFunc(void);
public: // Dirtied func inspectors
void callDirtiedFunc(void) const;
public: // Dirtiness accessors
void markDirty(void);
bool isDirty(void) const;
public: // Layout mutators
void calculateLayout(double width, double height, int direction);
public: // Layout inspectors
double getComputedLeft(void) const;
double getComputedRight(void) const;
double getComputedTop(void) const;
double getComputedBottom(void) const;
double getComputedWidth(void) const;
double getComputedHeight(void) const;
Layout getComputedLayout(void) const;
double getComputedMargin(int edge) const;
double getComputedBorder(int edge) const;
double getComputedPadding(int edge) const;
public:
void setIsReferenceBaseline(bool isReferenceBaseline);
bool isReferenceBaseline();
YGNodeRef m_node;
std::unique_ptr<nbind::cbFunction> m_measureFunc;
std::unique_ptr<nbind::cbFunction> m_dirtiedFunc;
std::unique_ptr<nbind::cbFunction> m_measureFunc;
std::unique_ptr<nbind::cbFunction> m_dirtiedFunc;
};

View File

@@ -1,34 +1,23 @@
/**
* 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.
* 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 <nbind/api.h>
#include <nbind/BindDefiner.h>
struct Size
{
double width;
double height;
struct Size {
double width;
double height;
Size(void)
: width(0.0)
, height(0.0)
{
}
Size(void) : width(0.0), height(0.0) {}
Size(double width, double height)
: width(width)
, height(height)
{
}
Size(double width, double height) : width(width), height(height) {}
void toJS(nbind::cbOutput expose) const
{
expose(width, height);
}
void toJS(nbind::cbOutput expose) const {
expose(width, height);
}
};

View File

@@ -1,38 +1,26 @@
/**
* 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.
* 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 <yoga/Yoga.h>
struct Value
{
static Value fromYGValue(YGValue const & ygValue)
{
return Value(static_cast<int>(ygValue.unit), ygValue.value);
}
struct Value {
static Value fromYGValue(YGValue const& ygValue) {
return Value(static_cast<int>(ygValue.unit), ygValue.value);
}
int unit;
double value;
int unit;
double value;
Value(void)
: unit(YGUnitUndefined)
, value(0.0)
{
}
Value(void) : unit(YGUnitUndefined), value(0.0) {}
Value(int unit, double value)
: unit(unit)
, value(value)
{
}
Value(int unit, double value) : unit(unit), value(value) {}
void toJS(nbind::cbOutput expose) const
{
expose(unit, value);
}
void toJS(nbind::cbOutput expose) const {
expose(unit, value);
}
};

View File

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

View File

@@ -1,10 +1,9 @@
/**
* 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.
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*/
#pragma once
unsigned getInstanceCount(void);

View File

@@ -15,166 +15,160 @@
#include <nbind/nbind.h>
NBIND_GLOBAL()
{
function(getInstanceCount);
NBIND_GLOBAL() {
function(getInstanceCount);
}
NBIND_CLASS(Size)
{
construct<>();
construct<double, double>();
NBIND_CLASS(Size) {
construct<>();
construct<double, double>();
}
NBIND_CLASS(Layout)
{
construct<>();
NBIND_CLASS(Layout) {
construct<>();
}
NBIND_CLASS(Value)
{
construct<>();
construct<int, double>();
NBIND_CLASS(Value) {
construct<>();
construct<int, double>();
}
NBIND_CLASS(Config)
{
method(create);
NBIND_CLASS(Config) {
method(create);
method(destroy);
method(destroy);
method(setExperimentalFeatureEnabled);
method(setPointScaleFactor);
method(setExperimentalFeatureEnabled);
method(setPointScaleFactor);
method(isExperimentalFeatureEnabled);
method(isExperimentalFeatureEnabled);
}
NBIND_CLASS(Node)
{
method(createDefault);
method(createWithConfig);
method(destroy);
NBIND_CLASS(Node) {
method(createDefault);
method(createWithConfig);
method(destroy);
method(reset);
method(reset);
method(copyStyle);
method(copyStyle);
method(setPositionType);
method(setPosition);
method(setPositionPercent);
method(setPositionType);
method(setPosition);
method(setPositionPercent);
method(setAlignContent);
method(setAlignItems);
method(setAlignSelf);
method(setFlexDirection);
method(setFlexWrap);
method(setJustifyContent);
method(setAlignContent);
method(setAlignItems);
method(setAlignSelf);
method(setFlexDirection);
method(setFlexWrap);
method(setJustifyContent);
method(setMargin);
method(setMarginPercent);
method(setMarginAuto);
method(setMargin);
method(setMarginPercent);
method(setMarginAuto);
method(setOverflow);
method(setDisplay);
method(setOverflow);
method(setDisplay);
method(setFlex);
method(setFlexBasis);
method(setFlexBasisPercent);
method(setFlexGrow);
method(setFlexShrink);
method(setFlex);
method(setFlexBasis);
method(setFlexBasisPercent);
method(setFlexGrow);
method(setFlexShrink);
method(setWidth);
method(setWidthPercent);
method(setWidthAuto);
method(setHeight);
method(setHeightPercent);
method(setHeightAuto);
method(setWidth);
method(setWidthPercent);
method(setWidthAuto);
method(setHeight);
method(setHeightPercent);
method(setHeightAuto);
method(setMinWidth);
method(setMinWidthPercent);
method(setMinHeight);
method(setMinHeightPercent);
method(setMinWidth);
method(setMinWidthPercent);
method(setMinHeight);
method(setMinHeightPercent);
method(setMaxWidth);
method(setMaxWidthPercent);
method(setMaxHeight);
method(setMaxHeightPercent);
method(setMaxWidth);
method(setMaxWidthPercent);
method(setMaxHeight);
method(setMaxHeightPercent);
method(setAspectRatio);
method(setAspectRatio);
method(setBorder);
method(setBorder);
method(setPadding);
method(setPaddingPercent);
method(setPadding);
method(setPaddingPercent);
method(getPositionType);
method(getPosition);
method(getPositionType);
method(getPosition);
method(getAlignContent);
method(getAlignItems);
method(getAlignSelf);
method(getFlexDirection);
method(getFlexWrap);
method(getJustifyContent);
method(getAlignContent);
method(getAlignItems);
method(getAlignSelf);
method(getFlexDirection);
method(getFlexWrap);
method(getJustifyContent);
method(getMargin);
method(getMargin);
method(getFlexBasis);
method(getFlexGrow);
method(getFlexShrink);
method(getFlexBasis);
method(getFlexGrow);
method(getFlexShrink);
method(getWidth);
method(getHeight);
method(getWidth);
method(getHeight);
method(getMinWidth);
method(getMinHeight);
method(getMinWidth);
method(getMinHeight);
method(getMaxWidth);
method(getMaxHeight);
method(getMaxWidth);
method(getMaxHeight);
method(getAspectRatio);
method(getAspectRatio);
method(getBorder);
method(getBorder);
method(getOverflow);
method(getDisplay);
method(getOverflow);
method(getDisplay);
method(getPadding);
method(getPadding);
method(insertChild);
method(removeChild);
method(insertChild);
method(removeChild);
method(getChildCount);
method(getChildCount);
method(getParent);
method(getChild);
method(getParent);
method(getChild);
method(isReferenceBaseline);
method(setIsReferenceBaseline);
method(isReferenceBaseline);
method(setIsReferenceBaseline);
method(setMeasureFunc);
method(unsetMeasureFunc);
method(setMeasureFunc);
method(unsetMeasureFunc);
method(setDirtiedFunc);
method(unsetDirtiedFunc);
method(setDirtiedFunc);
method(unsetDirtiedFunc);
method(markDirty);
method(isDirty);
method(markDirty);
method(isDirty);
method(calculateLayout);
method(calculateLayout);
method(getComputedLeft);
method(getComputedRight);
method(getComputedLeft);
method(getComputedRight);
method(getComputedTop);
method(getComputedBottom);
method(getComputedTop);
method(getComputedBottom);
method(getComputedWidth);
method(getComputedHeight);
method(getComputedWidth);
method(getComputedHeight);
method(getComputedLayout);
method(getComputedLayout);
method(getComputedMargin);
method(getComputedBorder);
method(getComputedPadding);
method(getComputedMargin);
method(getComputedBorder);
method(getComputedPadding);
}