c++: Turn (Logical|Physical)(Size|Position)` into structs

They used to declared by `using` before, so they were too easy to
convert into.
This commit is contained in:
Tobias Hunger 2022-09-13 11:24:42 +02:00 committed by Tobias Hunger
parent 0b29727aa5
commit e14fae45cd
3 changed files with 30 additions and 7 deletions

View file

@ -22,15 +22,27 @@ struct Point
};
namespace cbindgen_private {
// The Size types are expanded to the Point2D<...> type from the euclid crate which
// The Point types are expanded to the Point2D<...> type from the euclid crate which
// is binary compatible with Point<T>
template<typename T>
using Point2D = Point<T>;
}
/// A position in logical pixel coordinates
using LogicalPosition = Point<float>;
struct LogicalPosition : public Point<float>
{
/// Explicitly convert a Point<float> to a LogicalPosition
explicit LogicalPosition(const Point<float> p) : Point<float>(p) {};
/// Default construct a LogicalPosition in the origin
LogicalPosition() : Point<float> { 0., 0. } {};
};
/// A position in physical pixel coordinates
using PhysicalPosition = Point<int32_t>;
struct PhysicalPosition : public Point<int32_t>
{
/// Explicitly convert a Point<int32_t> to a LogicalPosition
explicit PhysicalPosition(const Point<int32_t> p) : Point<int32_t>(p) {};
/// Default construct a PhysicalPosition in the origin
PhysicalPosition() : Point<int32_t> { 0, 0 } {};
};
}