Skip to content

Commit

Permalink
Inline YGFloatOptional completely
Browse files Browse the repository at this point in the history
Summary:
@public
`YGFLoatOptional` only contains trivial functionality. Make it header-only.

Reviewed By: SidharthGuglani

Differential Revision: D13209151

fbshipit-source-id: 3ecca015fa0ac6644ae694b44bc53d840fbc5635
  • Loading branch information
davidaurelio authored and facebook-github-bot committed Dec 6, 2018
1 parent a7757f6 commit ceb6602
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 73 deletions.
4 changes: 0 additions & 4 deletions React/React.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 */,
Expand All @@ -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 */,
Expand Down
57 changes: 0 additions & 57 deletions ReactCommon/yoga/yoga/YGFloatOptional.cpp

This file was deleted.

47 changes: 35 additions & 12 deletions ReactCommon/yoga/yoga/YGFloatOptional.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#pragma once

#include <limits>
#include "Yoga-internal.h"

struct YGFloatOptional {
private:
Expand All @@ -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_;
}

Expand All @@ -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);
}
};

0 comments on commit ceb6602

Please sign in to comment.