Inline YGFloatOptional completely

Summary:
@public
`YGFLoatOptional` only contains trivial functionality. Make it header-only.

Reviewed By: SidharthGuglani

Differential Revision: D13209151

fbshipit-source-id: 3ecca015fa0ac6644ae694b44bc53d840fbc5635
This commit is contained in:
David Aurelio
2018-12-06 07:35:10 -08:00
committed by Facebook Github Bot
parent a7757f6e5d
commit ceb6602422
3 changed files with 35 additions and 73 deletions

View File

@@ -846,8 +846,6 @@
53D1239F1FBF1EFB001B8A10 /* Yoga-internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 53CBF1851FB4FE80002CBB31 /* Yoga-internal.h */; };
53D123A01FBF1EFF001B8A10 /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1871FB4FE80002CBB31 /* Yoga.cpp */; };
53D123A11FBF1EFF001B8A10 /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1871FB4FE80002CBB31 /* Yoga.cpp */; };
53DEF6EA205AE5A0006A3890 /* YGFloatOptional.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53DEF6E6205AE59B006A3890 /* YGFloatOptional.cpp */; };
53DEF6EB205AE5A1006A3890 /* YGFloatOptional.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53DEF6E6205AE59B006A3890 /* YGFloatOptional.cpp */; };
53DEF6EC205AE5A6006A3890 /* YGFloatOptional.h in Headers */ = {isa = PBXBuildFile; fileRef = 53DEF6E7205AE59C006A3890 /* YGFloatOptional.h */; };
53DEF6ED205AE5A7006A3890 /* YGFloatOptional.h in Headers */ = {isa = PBXBuildFile; fileRef = 53DEF6E7205AE59C006A3890 /* YGFloatOptional.h */; };
53EC85E21FDEC75F0051B2B5 /* YGNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53EC85DF1FDEC75A0051B2B5 /* YGNode.cpp */; };
@@ -4376,7 +4374,6 @@
files = (
AC6B69E721B146B400B2B68A /* YGValue.cpp in Sources */,
AC8360D121B025BC00FC46B9 /* YGConfig.cpp in Sources */,
53DEF6EA205AE5A0006A3890 /* YGFloatOptional.cpp in Sources */,
53D123A01FBF1EFF001B8A10 /* Yoga.cpp in Sources */,
5352C5752038FF9500A3B97E /* YGStyle.cpp in Sources */,
53EC85E21FDEC75F0051B2B5 /* YGNode.cpp in Sources */,
@@ -4393,7 +4390,6 @@
files = (
AC6B69EA21B146E700B2B68A /* YGValue.cpp in Sources */,
BA0501B02109DD1800A6BBC4 /* YGConfig.cpp in Sources */,
53DEF6EB205AE5A1006A3890 /* YGFloatOptional.cpp in Sources */,
53D123A11FBF1EFF001B8A10 /* Yoga.cpp in Sources */,
5352C5762038FF9700A3B97E /* YGStyle.cpp in Sources */,
53EC85E31FDEC75F0051B2B5 /* YGNode.cpp in Sources */,

View File

@@ -1,57 +0,0 @@
/**
* 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.
*/
#include "YGFloatOptional.h"
#include <cstdlib>
#include <iostream>
#include "Yoga-internal.h"
#include "Yoga.h"
using namespace facebook;
bool YGFloatOptional::operator==(YGFloatOptional op) const {
return value_ == op.value_ || (isUndefined() && op.isUndefined());
}
bool YGFloatOptional::operator!=(YGFloatOptional op) const {
return !(*this == op);
}
bool YGFloatOptional::operator==(float val) const {
return value_ == val || (isUndefined() && yoga::isUndefined(val));
}
bool YGFloatOptional::operator!=(float val) const {
return !(*this == val);
}
YGFloatOptional YGFloatOptional::operator-() const {
return YGFloatOptional{-value_};
}
YGFloatOptional YGFloatOptional::operator+(YGFloatOptional op) const {
return YGFloatOptional{value_ + op.value_};
}
YGFloatOptional YGFloatOptional::operator-(YGFloatOptional op) const {
return YGFloatOptional{value_ - op.value_};
}
bool YGFloatOptional::operator>(YGFloatOptional op) const {
return value_ > op.value_;
}
bool YGFloatOptional::operator<(YGFloatOptional op) const {
return value_ < op.value_;
}
bool YGFloatOptional::operator>=(YGFloatOptional op) const {
return *this > op || *this == op;
}
bool YGFloatOptional::operator<=(YGFloatOptional op) const {
return *this < op || *this == op;
}

View File

@@ -7,6 +7,7 @@
#pragma once
#include <limits>
#include "Yoga-internal.h"
struct YGFloatOptional {
private:
@@ -17,7 +18,7 @@ struct YGFloatOptional {
constexpr YGFloatOptional() = default;
// returns the wrapped value, or a value x with YGIsUndefined(x) == true
float unwrap() const {
constexpr float unwrap() const {
return value_;
}
@@ -35,16 +36,38 @@ struct YGFloatOptional {
return isUndefined() ? f() : value_;
}
YGFloatOptional operator-() const;
YGFloatOptional operator+(YGFloatOptional op) const;
YGFloatOptional operator-(YGFloatOptional op) const;
bool operator>(YGFloatOptional op) const;
bool operator<(YGFloatOptional op) const;
bool operator>=(YGFloatOptional op) const;
bool operator<=(YGFloatOptional op) const;
bool operator==(YGFloatOptional op) const;
bool operator!=(YGFloatOptional op) const;
YGFloatOptional operator-() const {
return YGFloatOptional{-value_};
}
YGFloatOptional operator+(YGFloatOptional op) const {
return YGFloatOptional{value_ + op.value_};
}
YGFloatOptional operator-(YGFloatOptional op) const {
return YGFloatOptional{value_ - op.value_};
}
bool operator>(YGFloatOptional op) const {
return value_ > op.value_;
}
bool operator<(YGFloatOptional op) const {
return value_ < op.value_;
}
bool operator>=(YGFloatOptional op) const {
return *this > op || *this == op;
}
bool operator<=(YGFloatOptional op) const {
return *this < op || *this == op;
}
bool operator==(YGFloatOptional op) const {
return value_ == op.value_ || (isUndefined() && op.isUndefined());
}
bool operator!=(YGFloatOptional op) const {
return !(*this == op);
}
bool operator==(float val) const;
bool operator!=(float val) const;
bool operator==(float val) const {
return value_ == val || (isUndefined() && yoga::isUndefined(val));
}
bool operator!=(float val) const {
return !(*this == val);
}
};