Namespace lmms (#6174)
This PR places all LMMS symbols into namespaces to eliminate any potential future name collisions between LMMS and third-party modules.
Also, this PR changes back `LmmsCore` to `Engine`, reverting c519921306 .
Co-authored-by: allejok96 <allejok96@gmail.com>
This commit is contained in:
@@ -91,6 +91,21 @@ for c in sorted(classes_found):
|
||||
|
||||
caption('themes')
|
||||
|
||||
|
||||
GUI_NAMESPACE_PREFIX = "lmms--gui"
|
||||
|
||||
|
||||
def unscope_classname(stylesheet, cname):
|
||||
# Strip the namespace part from the given class name,
|
||||
# while expecting it to have one in the first place.
|
||||
SCOPE_TOKEN = "--"
|
||||
i = cname.rfind(SCOPE_TOKEN) + len(SCOPE_TOKEN)
|
||||
|
||||
assert i>=0
|
||||
|
||||
return cname[i:]
|
||||
|
||||
|
||||
for theme in sorted([d for d in Path('data/themes').iterdir() if d.is_dir()]):
|
||||
classes_in_sheet = set()
|
||||
stylesheet = theme / 'style.css'
|
||||
@@ -101,7 +116,10 @@ for theme in sorted([d for d in Path('data/themes').iterdir() if d.is_dir()]):
|
||||
for c in rule.prelude:
|
||||
if c.type == 'ident' and not class_found:
|
||||
if is_our_class(c.value):
|
||||
classes_in_sheet.add(c.value)
|
||||
if str(c.value).startswith(GUI_NAMESPACE_PREFIX):
|
||||
classes_in_sheet.add(unscope_classname(stylesheet, c.value))
|
||||
else:
|
||||
error(str(stylesheet), f"Namespace prefix missing from class {c.value}")
|
||||
class_found = True
|
||||
# After whitespace or comma comes a new class
|
||||
elif c.type == 'whitespace' or (c.type == 'literal' and c.value == ','):
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
new QCoreApplication(argc, argv);
|
||||
Engine::init(true);
|
||||
lmms::Engine::init(true);
|
||||
|
||||
int numsuites = QTestSuite::suites().size();
|
||||
qDebug() << ">> Will run" << numsuites << "test suites";
|
||||
|
||||
@@ -43,6 +43,8 @@ private slots: // tests
|
||||
//! but no downcast or any other casts
|
||||
void CastTests()
|
||||
{
|
||||
using namespace lmms;
|
||||
|
||||
ComboBoxModel comboModel;
|
||||
AutomatableModel* amPtr = &comboModel;
|
||||
QVERIFY(nullptr == amPtr->dynamicCast<FloatModel>()); // not a parent class
|
||||
@@ -60,6 +62,8 @@ private slots: // tests
|
||||
|
||||
void LinkTests()
|
||||
{
|
||||
using namespace lmms;
|
||||
|
||||
BoolModel m1(false), m2(false);
|
||||
|
||||
QObject::connect(&m1, SIGNAL(dataChanged()),
|
||||
|
||||
@@ -32,6 +32,8 @@ class ProjectVersionTest : QTestSuite
|
||||
private slots:
|
||||
void ProjectVersionComparisonTests()
|
||||
{
|
||||
using namespace lmms;
|
||||
|
||||
QVERIFY(ProjectVersion("1.1.0", ProjectVersion::Minor) > "1.0.3");
|
||||
QVERIFY(ProjectVersion("1.1.0", ProjectVersion::Major) < "2.1.0");
|
||||
QVERIFY(ProjectVersion("1.1.0", ProjectVersion::Release) > "0.2.1");
|
||||
|
||||
@@ -36,6 +36,8 @@ class RelativePathsTest : QTestSuite
|
||||
private slots:
|
||||
void PathUtilComparisonTests()
|
||||
{
|
||||
using namespace lmms;
|
||||
|
||||
QFileInfo fi(ConfigManager::inst()->factorySamplesDir() + "/drums/kick01.ogg");
|
||||
QVERIFY(fi.exists());
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ private slots:
|
||||
|
||||
void testClipLinear()
|
||||
{
|
||||
using namespace lmms;
|
||||
|
||||
AutomationClip c(nullptr);
|
||||
c.setProgressionType(AutomationClip::LinearProgression);
|
||||
c.putValue(0, 0.0, false);
|
||||
@@ -64,6 +66,8 @@ private slots:
|
||||
|
||||
void testClipDiscrete()
|
||||
{
|
||||
using namespace lmms;
|
||||
|
||||
AutomationClip c(nullptr);
|
||||
c.setProgressionType(AutomationClip::DiscreteProgression);
|
||||
c.putValue(0, 0.0, false);
|
||||
@@ -77,6 +81,8 @@ private slots:
|
||||
|
||||
void testClips()
|
||||
{
|
||||
using namespace lmms;
|
||||
|
||||
FloatModel model;
|
||||
|
||||
auto song = Engine::getSong();
|
||||
@@ -111,6 +117,8 @@ private slots:
|
||||
|
||||
void testLengthRespected()
|
||||
{
|
||||
using namespace lmms;
|
||||
|
||||
FloatModel model;
|
||||
|
||||
auto song = Engine::getSong();
|
||||
@@ -136,6 +144,8 @@ private slots:
|
||||
|
||||
void testInlineAutomation()
|
||||
{
|
||||
using namespace lmms;
|
||||
|
||||
auto song = Engine::getSong();
|
||||
|
||||
InstrumentTrack* instrumentTrack =
|
||||
@@ -160,6 +170,8 @@ private slots:
|
||||
|
||||
void testPatternTrack()
|
||||
{
|
||||
using namespace lmms;
|
||||
|
||||
auto song = Engine::getSong();
|
||||
auto patternStore = Engine::patternStore();
|
||||
PatternTrack patternTrack(song);
|
||||
@@ -197,6 +209,8 @@ private slots:
|
||||
|
||||
void testGlobalAutomation()
|
||||
{
|
||||
using namespace lmms;
|
||||
|
||||
// Global automation should not have priority, see https://github.com/LMMS/lmms/issues/4268
|
||||
// Tests regression caused by 75077f6200a5aee3a5821aae48a3b8466ed8714a
|
||||
auto song = Engine::getSong();
|
||||
|
||||
Reference in New Issue
Block a user