Skip to content

Commit

Permalink
Merge pull request #3578 from rism-digital/develop-c20
Browse files Browse the repository at this point in the history
Upgrading to C++20
  • Loading branch information
lpugin authored Jan 31, 2024
2 parents 681e543 + 98e5533 commit 6de14da
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 72 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
# but only for the branches specified
branches:
# Push events on develop branch
- develop
- 'develop'
# Push events on ci-test branch (uncomment if needed for testing purposes)
# - ci-test
paths-ignore:
Expand Down Expand Up @@ -44,7 +44,7 @@ env:
# emscripten
EM_VERSION: latest
EM_CACHE_FOLDER: "emsdk-cache"
EM_CACHE_ID: 2
EM_CACHE_ID: 3

# gh-pages
GH_PAGES_REPO: ${{ github.repository_owner }}/verovio.org # works from rism-digital and from forks
Expand Down Expand Up @@ -74,10 +74,6 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
compiler: g++
version: "9"

- os: ubuntu-20.04
compiler: g++
version: "10"
Expand All @@ -86,13 +82,17 @@ jobs:
compiler: g++
version: "11"

- os: ubuntu-22.04
compiler: g++
version: "12"

- os: ubuntu-20.04
compiler: clang
version: "6.0"
version: "10"

- os: ubuntu-20.04
compiler: clang
version: "9"
version: "11"

- os: ubuntu-20.04
compiler: clang
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [unreleased]
* Support for `fTrem@unitdur` (@eNote-GmbH)
* Upgrade to C++20

## [4.1.0] - 2023-12-15
* Support for staves ordered by `scoreDef`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

Verovio is a fast, portable and lightweight library for engraving [Music Encoding Initiative (MEI)](http://www.music-encoding.org) digital scores into SVG images. Verovio also contains on-the-fly converters to render [Plaine & Easie Code](https://www.iaml.info/plaine-easie-code), [Humdrum](https://www.humdrum.org), [Musedata](https://musedata.org), [MusicXML](https://www.musicxml.com), [EsAC](http://esac-data.org), and [ABC](https://en.wikipedia.org/wiki/ABC_notation) digital scores.

Verovio is written in standard 2017 C++ and can be compiled as a standalone command-line tool, used as a compiled music-rendering library for applications (Qt, python), or compiled into Javascript using the Emscripten LLVM-to-JavaScript compiler. Check out the JavaScript toolkit version of verovio running in the [MEI Viewer](http://www.verovio.org/mei-viewer.xhtml) as well as the [app](http://www.verovio.org/app.html) or [tutorials](https://book.verovio.org/first-steps/) for web integration and user interaction.
Verovio is written in standard 2020 C++ and can be compiled as a standalone command-line tool, used as a compiled music-rendering library for applications (Qt, python), or compiled into Javascript using the Emscripten LLVM-to-JavaScript compiler. Check out the JavaScript toolkit version of verovio running in the [MEI Viewer](http://www.verovio.org/mei-viewer.xhtml) as well as the [app](http://www.verovio.org/app.html) or [tutorials](https://book.verovio.org/first-steps/) for web integration and user interaction.

![Choice interaction](https://raw.githubusercontent.com/rism-digital/verovio.org/gh-pages/movies/reflow.gif)

Expand Down
4 changes: 2 additions & 2 deletions Verovio.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5024,7 +5024,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LANGUAGE_STANDARD = "c++20";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
Expand Down Expand Up @@ -5083,7 +5083,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LANGUAGE_STANDARD = "c++20";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
Expand Down
4 changes: 2 additions & 2 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if(MSVC)
add_definitions(/wd4244) # suppress warning of possible loss of precision
add_definitions(-DNO_PAE_SUPPORT) # regex is working differently under Windows so PAE is not supported (yet)
add_definitions(-DUSE_PAE_OLD_PARSER)
add_definitions(/std:c++17)
add_definitions(/std:c++20)
include_directories(../include/win32)
else()
if(CMAKE_BUILD_TYPE MATCHES Debug)
Expand All @@ -60,7 +60,7 @@ else()
# jsonxx raises -Wdollar-in-identifier-extension
# gcc 8.3.1 does not like -Wdollar-in-identifier-extension option.
add_definitions(-Wall -W -pedantic -Wno-unused-parameter -Wno-dollar-in-identifier-extension)
add_definitions(-std=c++17)
add_definitions(-std=c++20)

# extra warnings similar to Xcode compiling settings (most probably covered by -Wall):
# https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/DiagnosticGroups.td
Expand Down
2 changes: 1 addition & 1 deletion emscripten/buildToolkit
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ my ($lightQ, $version, $chattyQ, $helpQ, $exclusion, $wasmQ, $makeQ, $modularize
my ($nopae, $nohumdrum, $nomusicxml, $nodarms);
my ($FLAGS_NAME, $VERSION, $CHATTY);

my $cpp = 17; # c++ version to compile (11, 14, 17)
my $cpp = 20; # c++ version to compile (11, 14, 17)
my $VEROVIO_ROOT = "..";

Getopt::Long::Configure("bundling");
Expand Down
86 changes: 43 additions & 43 deletions include/vrv/staff.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,49 @@ class Syl;
class TimeSpanningInterface;
class Tuning;

//----------------------------------------------------------------------------
// LedgerLine
//----------------------------------------------------------------------------

/**
* This is a class with no MEI equivalent for representing legder lines.
* A ledger line is represented by a list of dashes.
* Each dash is represented by a pair of points (left - right).
*/
class LedgerLine {
public:
/**
* @name Constructors, destructors, reset methods
* Reset method reset all attribute classes
*/
///@{
LedgerLine();
virtual ~LedgerLine();
virtual void Reset();
///@}

/**
* Add a dash to the ledger line object.
* If necessary merges overlapping dashes.
*/
void AddDash(int left, int right, int extension);

protected:
//
private:
//
public:
/**
* A list of dashes relative to the staff position.
*/
std::list<std::pair<int, int>> m_dashes;

protected:
//
private:
//
};

//----------------------------------------------------------------------------
// Staff
//----------------------------------------------------------------------------
Expand Down Expand Up @@ -249,49 +292,6 @@ class Staff : public Object,
///@}
};

//----------------------------------------------------------------------------
// LedgerLine
//----------------------------------------------------------------------------

/**
* This is a class with no MEI equivalent for representing legder lines.
* A ledger line is represented by a list of dashes.
* Each dash is represented by a pair of points (left - right).
*/
class LedgerLine {
public:
/**
* @name Constructors, destructors, reset methods
* Reset method reset all attribute classes
*/
///@{
LedgerLine();
virtual ~LedgerLine();
virtual void Reset();
///@}

/**
* Add a dash to the ledger line object.
* If necessary merges overlapping dashes.
*/
void AddDash(int left, int right, int extension);

protected:
//
private:
//
public:
/**
* A list of dashes relative to the staff position.
*/
std::list<std::pair<int, int>> m_dashes;

protected:
//
private:
//
};

} // namespace vrv

#endif
6 changes: 3 additions & 3 deletions include/win32/win_getopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int optopt = '?'; /* character checked for validity */
#undef optreset /* see getopt.h */
#define optreset __mingw_optreset
int optreset; /* reset getopt */
char *optarg; /* argument associated with option */
const char *optarg; /* argument associated with option */
#endif

//extern int optind; /* index of first non-option in argv */
Expand Down Expand Up @@ -76,7 +76,7 @@ static int parse_long_options(char * const *, const char *,
static int gcd(int, int);
static void permute_args(int, int, int, char * const *);

static char *place = EMSG; /* option letter processing */
static const char *place = EMSG; /* option letter processing */

/* XXX: set optreset to 1 rather than these two */
static int nonopt_start = -1; /* first non option argument (for permute) */
Expand Down Expand Up @@ -243,7 +243,7 @@ static int
parse_long_options(char * const *nargv, const char *options,
const struct option *long_options, int *idx, int short_too)
{
char *current_argv, *has_equal;
const char *current_argv, *has_equal;
size_t current_argv_len;
int i, ambiguous, match;

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ def get_version() -> str:
# extra compile arguments
EXTRA_COMPILE_ARGS = ['-DPYTHON_BINDING']
if platform.system() != 'Windows':
EXTRA_COMPILE_ARGS += ['-std=c++17',
EXTRA_COMPILE_ARGS += ['-std=c++20',
'-Wno-write-strings', '-Wno-overloaded-virtual', '-g0']
else:
EXTRA_COMPILE_ARGS += ['/std:c++17',
EXTRA_COMPILE_ARGS += ['/std:c++20',
'-DNO_PAE_SUPPORT']

verovio_module = Extension('verovio._verovio',
Expand Down
2 changes: 1 addition & 1 deletion src/accid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void Accid::AdjustX(LayerElement *element, const Doc *doc, int staffSize, std::v
leftAccids.push_back(accid);
return;
}
if (adjustedAccids.count(accid) == 0) return;
if (!adjustedAccids.contains(accid)) return;
}

int xRelShift = 0;
Expand Down
5 changes: 3 additions & 2 deletions src/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,9 @@ const Staff *Measure::GetBottomVisibleStaff() const
int Measure::EnclosesTime(int time) const
{
int repeat = 1;
double timeDuration
= m_measureAligner.GetRightAlignment()->GetTime() * DURATION_4 / DUR_MAX * 60.0 / m_currentTempo * 1000.0 + 0.5;
double timeDuration = m_measureAligner.GetRightAlignment()->GetTime() * static_cast<int>(DURATION_4) / DUR_MAX
* 60.0 / m_currentTempo * 1000.0
+ 0.5;
std::vector<double>::const_iterator iter;
for (iter = m_realTimeOffsetMilliseconds.begin(); iter != m_realTimeOffsetMilliseconds.end(); ++iter) {
if ((time >= *iter) && (time <= *iter + timeDuration)) return repeat;
Expand Down
6 changes: 3 additions & 3 deletions src/midifunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ FunctorCode InitMaxMeasureDurationFunctor::VisitMeasureEnd(Measure *measure)
const double tempo = this->GetAdjustedTempo();
measure->SetCurrentTempo(tempo);

const double scoreTimeIncrement
= measure->m_measureAligner.GetRightAlignment()->GetTime() * m_multiRestFactor * DURATION_4 / DUR_MAX;
const double scoreTimeIncrement = measure->m_measureAligner.GetRightAlignment()->GetTime() * m_multiRestFactor
* static_cast<int>(DURATION_4) / DUR_MAX;
m_currentScoreTime += scoreTimeIncrement;
m_currentRealTimeSeconds += scoreTimeIncrement * 60.0 / tempo;
m_multiRestFactor = 1;
Expand Down Expand Up @@ -698,7 +698,7 @@ FunctorCode GenerateMIDIFunctor::VisitPedal(const Pedal *pedal)
{
if (!pedal->HasDir()) return FUNCTOR_CONTINUE;

double pedalTime = pedal->GetStart()->GetAlignment()->GetTime() * DURATION_4 / DUR_MAX;
double pedalTime = pedal->GetStart()->GetAlignment()->GetTime() * static_cast<int>(DURATION_4) / DUR_MAX;
double startTime = m_totalTime + pedalTime;
int tpq = m_midiFile->getTPQ();

Expand Down
8 changes: 4 additions & 4 deletions src/view_neume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ void View::DrawNc(DeviceContext *dc, LayerElement *element, Layer *layer, Staff
struct drawingParams {
wchar_t fontNo = SMUFL_E990_chantPunctum;
wchar_t fontNoLiq[5] = {};
float xOffset = 0;
float yOffset = 0;
float xOffsetLiq[5] = { 0, 0, 0, 0, 0 };
float yOffsetLiq[5] = { 0, 0, 0, 0, 0 };
double xOffset = 0;
double yOffset = 0;
double xOffsetLiq[5] = { 0, 0, 0, 0, 0 };
double yOffsetLiq[5] = { 0, 0, 0, 0, 0 };
};
std::vector<drawingParams> params;
params.push_back(drawingParams());
Expand Down

0 comments on commit 6de14da

Please sign in to comment.