Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,24 @@ jobs:

- name: Build and run examples
run: make examples-run

swift-local:
name: macOS (Swift package, local checkout)
runs-on: macos-latest

# The local-checkout consumption mode (MX_LOCAL_CHECKOUT) builds `Mx` as a
# source library straight from this checkout -- the path komp takes when it
# depends on a sibling mx via `.package(path:)`. Building it here proves mx
# compiles as a Swift package under AppleClang/SPM on every PR. The binary
# xcframework release arm is follow-up work.
env:
MX_LOCAL_CHECKOUT: "1"

steps:
- uses: actions/checkout@v4

- name: Swift toolchain
run: swift --version

- name: Build the Mx Swift package (local-checkout source mode)
run: swift build --product Mx
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ __pycache__/
# Gen test build artifacts
gen/test/c/build/
gen/test/go/build/

# Swift package build artifacts
.build/
Package.resolved
52 changes: 52 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// swift-tools-version: 5.9
import PackageDescription

// mx is consumed as a Swift package in one of two modes, selected by the
// MX_LOCAL_CHECKOUT environment variable. The name mirrors the repo's existing
// local-vs-Docker build switch (MX_RUNNING_IN_DOCKER) and reads as "consume mx
// from a local checkout":
//
// set -> `Mx` is a source library compiled from this checkout, for
// sibling-checkout development (a consumer using `.package(path:)`).
// unset -> `Mx` is the published xcframework binary release. That pipeline is
// follow-up work and is not wired up yet, so this arm fails loudly
// rather than silently resolving to a nonexistent artifact.
let useLocalCheckout = Context.environment["MX_LOCAL_CHECKOUT"] != nil

let mxTarget: Target
if useLocalCheckout {
// SPM globs every C++ translation unit under `src` (all of which live in
// `src/private`), minus the Catch2 runner, the test suites, and the example
// programs -- the only files carrying their own main(). The public surface
// is the mx::api headers under `src/include`; `src/private` is added to the
// internal header search path so the model can include `mx/core/...` and
// `pugixml/...`.
mxTarget = .target(
name: "Mx",
path: "src",
exclude: [
"private/cpul",
"private/mxtest",
"private/mx/examples",
],
publicHeadersPath: "include",
cxxSettings: [
.headerSearchPath("private"),
]
)
} else {
fatalError(
"The Mx binary release is not published yet. Build with "
+ "MX_LOCAL_CHECKOUT=1 against a sibling mx checkout; the "
+ "binary-release arm is follow-up work."
)
}

let package = Package(
name: "mx",
products: [
.library(name: "Mx", targets: ["Mx"]),
],
targets: [mxTarget],
cxxLanguageStandard: .cxx20
)
2 changes: 1 addition & 1 deletion src/include/mx/api/ApiCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace mx
{
namespace api
{
using Double = long double;
using Double = double;
using OptionalDouble = std::optional<Double>;
constexpr const Double MX_API_EQUALITY_EPSILON = 0.00000001;

Expand Down
2 changes: 1 addition & 1 deletion src/include/mx/api/ApiEquality.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ template <typename T> inline bool areEqual(const T &lhs, const T &rhs)
return lhs == rhs;
}

template <> inline bool areEqual<long double>(const long double &lhs, const long double &rhs)
template <> inline bool areEqual<double>(const double &lhs, const double &rhs)
{
return areSame(lhs, rhs);
}
Expand Down
2 changes: 1 addition & 1 deletion src/include/mx/api/AppearanceData.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AppearanceData
public:
AppearanceType appearanceType;
std::string appearanceSubType;
long double value;
double value;
};

MXAPI_EQUALS_BEGIN(AppearanceData)
Expand Down
10 changes: 5 additions & 5 deletions src/include/mx/api/CurveData.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ struct CurvePoints
PositionData positionData;

bool isBezierXSpecified;
long double bezierX;
double bezierX;

bool isBezierYSpecified;
long double bezierY;
double bezierY;

bool isBezierOffsetSpecified;
int bezierOffset;
Expand Down Expand Up @@ -112,11 +112,11 @@ struct CurveContinue
int numberLevel;
CurvePoints curvePoints;
bool isBezierX2Specified;
long double bezierX2;
double bezierX2;
bool isBezierY2Specified;
long double bezierY2;
double bezierY2;
bool isBezierOffset2Specified;
long double bezierOffset2;
double bezierOffset2;

CurveContinue(CurveType inCurveType)
: curveType{inCurveType}, numberLevel{-1}, curvePoints{}, isBezierX2Specified{false}, bezierX2{0.0},
Expand Down
34 changes: 17 additions & 17 deletions src/include/mx/api/DurationData.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ enum class DurationName
dur1024th
};

constexpr long double DUR_QUARTERS_VALUE_MAXIMA = 32.0L;
constexpr long double DUR_QUARTERS_VALUE_LONGA = 16.0L;
constexpr long double DUR_QUARTERS_VALUE_BREVE = 8.0L;
constexpr long double DUR_QUARTERS_VALUE_WHOLE = 4.0L;
constexpr long double DUR_QUARTERS_VALUE_HALF = 2.0L;
constexpr long double DUR_QUARTERS_VALUE_QUARTER = 1.0L;
constexpr long double DUR_QUARTERS_VALUE_EIGHTH = 1.0L / 2.0L;
constexpr long double DUR_QUARTERS_VALUE_16TH = 1.0L / 4.0L;
constexpr long double DUR_QUARTERS_VALUE_32ND = 1.0L / 8.0L;
constexpr long double DUR_QUARTERS_VALUE_64TH = 1.0L / 16.0L;
constexpr long double DUR_QUARTERS_VALUE_128TH = 1.0L / 32.0L;
constexpr long double DUR_QUARTERS_VALUE_256TH = 1.0L / 64.0L;
constexpr long double DUR_QUARTERS_VALUE_512TH = 1.0L / 128.0L;
constexpr long double DUR_QUARTERS_VALUE_1024TH = 1.0L / 256.0L;
constexpr double DUR_QUARTERS_VALUE_MAXIMA = 32.0;
constexpr double DUR_QUARTERS_VALUE_LONGA = 16.0;
constexpr double DUR_QUARTERS_VALUE_BREVE = 8.0;
constexpr double DUR_QUARTERS_VALUE_WHOLE = 4.0;
constexpr double DUR_QUARTERS_VALUE_HALF = 2.0;
constexpr double DUR_QUARTERS_VALUE_QUARTER = 1.0;
constexpr double DUR_QUARTERS_VALUE_EIGHTH = 1.0 / 2.0;
constexpr double DUR_QUARTERS_VALUE_16TH = 1.0 / 4.0;
constexpr double DUR_QUARTERS_VALUE_32ND = 1.0 / 8.0;
constexpr double DUR_QUARTERS_VALUE_64TH = 1.0 / 16.0;
constexpr double DUR_QUARTERS_VALUE_128TH = 1.0 / 32.0;
constexpr double DUR_QUARTERS_VALUE_256TH = 1.0 / 64.0;
constexpr double DUR_QUARTERS_VALUE_512TH = 1.0 / 128.0;
constexpr double DUR_QUARTERS_VALUE_1024TH = 1.0 / 256.0;

inline long double applyDots(long double inUnDottedValue, int inNumDots)
inline double applyDots(double inUnDottedValue, int inNumDots)
{
long double outValue = inUnDottedValue;
long double valueToAdd = inUnDottedValue / 0.5;
double outValue = inUnDottedValue;
double valueToAdd = inUnDottedValue / 0.5;

for (int i = 0; i < inNumDots; ++i)
{
Expand Down
4 changes: 2 additions & 2 deletions src/include/mx/api/FontData.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct FontData
// is in use. if css, then use the fontSizeCss
// field, if point then use fontSizePoint
FontSizeType sizeType;
long double sizePoint;
double sizePoint;
CssSize sizeCss;

FontStyle style;
Expand All @@ -69,7 +69,7 @@ struct FontData
int lineThrough;

FontData()
: sizeType{FontSizeType::unspecified}, sizePoint{-1.0L}, sizeCss{CssSize::unspecified},
: sizeType{FontSizeType::unspecified}, sizePoint{-1.0}, sizeCss{CssSize::unspecified},
style{FontStyle::unspecified}, weight{FontWeight::unspecified}, fontFamily{}, underline{0}, overline{0},
lineThrough{0}
{
Expand Down
6 changes: 3 additions & 3 deletions src/include/mx/api/LineData.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ struct LineData
LineType lineType;
LineHook lineHook;
bool isStopLengthSpecified;
long double endLength;
double endLength;
bool isDashLengthSpecified;
long double dashLength;
double dashLength;
bool isSpaceLengthSpecified;
long double spaceLength;
double spaceLength;

inline bool isSpecified() const
{
Expand Down
2 changes: 1 addition & 1 deletion src/include/mx/api/MeasureData.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class MeasureData
Bool nonControlling;

// a width value less than 0 means 'unspecified'
long double width;
double width;
std::vector<KeyData> keys;
std::vector<BarlineData> barlines;

Expand Down
6 changes: 3 additions & 3 deletions src/include/mx/api/PartData.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ struct MidiData
int unpitched;

// percent, valid range 0.0 to 100.0
long double volume;
double volume;
bool isVolumeSpecified;

// rotation degrees, valid range -180.0 to +180.0
long double pan;
double pan;
bool isPanSpecified;

// rotation degrees, valid range -180.0 to +180.0
long double elevation;
double elevation;
bool isElevationSpecified;

MidiData()
Expand Down
8 changes: 4 additions & 4 deletions src/include/mx/api/PositionData.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ class PositionData
public:
// decimal values are in 'tenths'

long double defaultX;
double defaultX;
bool isDefaultXSpecified;
long double defaultY;
double defaultY;
bool isDefaultYSpecified;
long double relativeX;
double relativeX;
bool isRelativeXSpecified;
long double relativeY;
double relativeY;
bool isRelativeYSpecified;
Placement placement;
VerticalAlignment verticalAlignment;
Expand Down
4 changes: 2 additions & 2 deletions src/include/mx/api/WedgeData.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct WedgeStart
int numberLevel;
WedgeType wedgeType;
bool isSpreadSpecified;
long double spread;
double spread;
LineData lineData;
PositionData positionData;
ColorData colorData;
Expand All @@ -42,7 +42,7 @@ struct WedgeStop
int numberLevel;
PositionData positionData;
bool isSpreadSpecified;
long double spread;
double spread;

WedgeStop() : numberLevel{-1}, positionData{}, isSpreadSpecified{false}, spread{0.0}
{
Expand Down
16 changes: 8 additions & 8 deletions src/private/mx/impl/Cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ void Cursor::reset()

int Cursor::convertDurationToGlobalTickScale(const core::PositiveDivisions &duration) const
{
return convertDurationToGlobalTickScale(static_cast<long double>(duration.value().value()));
return convertDurationToGlobalTickScale(static_cast<double>(duration.value().value()));
}

int Cursor::convertDurationToGlobalTickScale(long double durationValue) const
int Cursor::convertDurationToGlobalTickScale(double durationValue) const
{
if (this->ticksPerQuarter == this->getGlobalTicksPerQuarter())
{
return static_cast<int>(std::ceil(durationValue - 0.5L));
return static_cast<int>(std::ceil(durationValue - 0.5));
}

const long double currentTicksPerQuarter = static_cast<long double>(this->ticksPerQuarter);
const long double globalTicksPerQuarter = static_cast<long double>(this->getGlobalTicksPerQuarter());
const long double convertedVal = durationValue * (globalTicksPerQuarter / currentTicksPerQuarter);
return static_cast<int>(std::ceil(convertedVal - 0.5L));
const double currentTicksPerQuarter = static_cast<double>(this->ticksPerQuarter);
const double globalTicksPerQuarter = static_cast<double>(this->getGlobalTicksPerQuarter());
const double convertedVal = durationValue * (globalTicksPerQuarter / currentTicksPerQuarter);
return static_cast<int>(std::ceil(convertedVal - 0.5));
}

int Cursor::convertDurationToGlobalTickScale(int durationValue) const
{
return convertDurationToGlobalTickScale(static_cast<long double>(durationValue));
return convertDurationToGlobalTickScale(static_cast<double>(durationValue));
}
} // namespace impl
} // namespace mx
2 changes: 1 addition & 1 deletion src/private/mx/impl/Cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Cursor
void reset();

int convertDurationToGlobalTickScale(const core::PositiveDivisions &duration) const;
int convertDurationToGlobalTickScale(long double durationValue) const;
int convertDurationToGlobalTickScale(double durationValue) const;
int convertDurationToGlobalTickScale(int duration) const;

private:
Expand Down
8 changes: 4 additions & 4 deletions src/private/mx/impl/DirectionReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ void DirectionReader::parseWedge(const core::DirectionType &directionType)
const auto &wedge = directionType.choice().asWedge();
const auto wedgeType = myConverter.convert(wedge.type());
const bool isSpreadSpecified = wedge.spread().has_value();
const long double spread = isSpreadSpecified ? static_cast<long double>(wedge.spread()->value().value()) : 0.0L;
const double spread = isSpreadSpecified ? static_cast<double>(wedge.spread()->value().value()) : 0.0;
auto positionData = getPositionData(wedge);
auto lineData = getLineData(wedge);
auto colorData = getColor(wedge);
Expand Down Expand Up @@ -569,17 +569,17 @@ void DirectionReader::parseBracket(const core::DirectionType &directionType)
if (bracket.endLength().has_value())
{
lineData.isStopLengthSpecified = true;
lineData.endLength = static_cast<long double>(bracket.endLength()->value().value());
lineData.endLength = static_cast<double>(bracket.endLength()->value().value());
}
if (bracket.dashLength().has_value())
{
lineData.isDashLengthSpecified = true;
lineData.dashLength = static_cast<long double>(bracket.dashLength()->value().value());
lineData.dashLength = static_cast<double>(bracket.dashLength()->value().value());
}
if (bracket.spaceLength().has_value())
{
lineData.isSpaceLengthSpecified = true;
lineData.spaceLength = static_cast<long double>(bracket.spaceLength()->value().value());
lineData.spaceLength = static_cast<double>(bracket.spaceLength()->value().value());
}
return lineData;
};
Expand Down
6 changes: 3 additions & 3 deletions src/private/mx/impl/FontFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ template <typename ATTRIBUTES_TYPE> api::FontWeight getFontWeight(const ATTRIBUT
}

template <typename ATTRIBUTES_TYPE>
api::FontSizeType getFontSize(const ATTRIBUTES_TYPE &inAttributes, long double &outPointSize, api::CssSize &outCssSize)
api::FontSizeType getFontSize(const ATTRIBUTES_TYPE &inAttributes, double &outPointSize, api::CssSize &outCssSize)
{
if (!checkHasFontSize<ATTRIBUTES_TYPE>(&inAttributes))
{
outPointSize = -1.0L;
outPointSize = -1.0;
outCssSize = api::CssSize::unspecified;
return api::FontSizeType::unspecified;
}
Expand All @@ -93,7 +93,7 @@ api::FontSizeType getFontSize(const ATTRIBUTES_TYPE &inAttributes, long double &

if (coreFontSize.isCSSFontSize())
{
outPointSize = -1.0L;
outPointSize = -1.0;
outCssSize = converter.convert(coreFontSize.asCSSFontSize());
return api::FontSizeType::css;
}
Expand Down
6 changes: 3 additions & 3 deletions src/private/mx/impl/LineFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ MX_OPTIONAL_HAS_FUNC(lineStop, LineStop);
MX_OPTIONAL_GET_VALUE_FUNC(lineStop, LineStop, core::LineEnd, core::LineEnd::none());

MX_OPTIONAL_HAS_FUNC(dashLength, DashLength);
MX_OPTIONAL_GET_DECIMAL_FUNC(dashLength, DashLength, 0.0L);
MX_OPTIONAL_GET_DECIMAL_FUNC(dashLength, DashLength, 0.0);

MX_OPTIONAL_HAS_FUNC(spaceLength, SpaceLength);
MX_OPTIONAL_GET_DECIMAL_FUNC(spaceLength, SpaceLength, 0.0L);
MX_OPTIONAL_GET_DECIMAL_FUNC(spaceLength, SpaceLength, 0.0);

MX_OPTIONAL_HAS_FUNC(endLength, StopLength);
MX_OPTIONAL_GET_DECIMAL_FUNC(endLength, StopLength, 0.0L);
MX_OPTIONAL_GET_DECIMAL_FUNC(endLength, StopLength, 0.0);

template <typename ATTRIBUTES_TYPE> api::LineData getLineData(const ATTRIBUTES_TYPE &inAttributes)
{
Expand Down
Loading
Loading