Skip to content

Commit

Permalink
fix another pass by reference
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Nov 22, 2020
1 parent f020cd7 commit fe9e02b
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/controllers/controllerpreset.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ControllerPreset {
}

void setModuleFileInfo(QFileInfo fileInfo) {
m_moduleFileInfo = fileInfo;
m_moduleFileInfo = std::move(fileInfo);
}

QFileInfo moduleFileInfo() const {
Expand Down
13 changes: 7 additions & 6 deletions src/controllers/engine/controllerengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void ControllerEngine::loadModule(QFileInfo moduleFileInfo) {
return;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
m_moduleFileInfo = moduleFileInfo;
m_moduleFileInfo = std::move(moduleFileInfo);

QJSValue mod = m_pScriptEngine->importModule(moduleFileInfo.absoluteFilePath());
if (mod.isError()) {
Expand Down Expand Up @@ -291,7 +291,7 @@ void ControllerEngine::loadModule(QFileInfo moduleFileInfo) {
#endif
}

void ControllerEngine::handleInput(QByteArray data, mixxx::Duration timestamp) {
void ControllerEngine::handleInput(const QByteArray& data, mixxx::Duration timestamp) {
if (m_handleInputFunction.isCallable()) {
QJSValueList args;
args << byteArrayToScriptValue(data);
Expand Down Expand Up @@ -438,7 +438,8 @@ void ControllerEngine::throwJSError(const QString& message) {
#endif
}

void ControllerEngine::showScriptExceptionDialog(QJSValue evaluationResult, bool bFatalError) {
void ControllerEngine::showScriptExceptionDialog(
const QJSValue& evaluationResult, bool bFatalError) {
VERIFY_OR_DEBUG_ASSERT(evaluationResult.isError()) {
return;
}
Expand Down Expand Up @@ -679,7 +680,7 @@ void ControllerEngine::log(const QString& message) {
}

QJSValue ControllerEngine::makeConnection(
const QString& group, const QString& name, const QJSValue callback) {
const QString& group, const QString& name, const QJSValue& callback) {
VERIFY_OR_DEBUG_ASSERT(m_pScriptEngine != nullptr) {
return QJSValue();
}
Expand Down Expand Up @@ -714,7 +715,7 @@ QJSValue ControllerEngine::makeConnection(
return QJSValue();
}

bool ControllerEngine::removeScriptConnection(const ScriptConnection connection) {
bool ControllerEngine::removeScriptConnection(const ScriptConnection& connection) {
ControlObjectScript* coScript = getControlObjectScript(connection.key.group,
connection.key.item);

Expand All @@ -725,7 +726,7 @@ bool ControllerEngine::removeScriptConnection(const ScriptConnection connection)
return coScript->removeScriptConnection(connection);
}

void ControllerEngine::triggerScriptConnection(const ScriptConnection connection) {
void ControllerEngine::triggerScriptConnection(const ScriptConnection& connection) {
VERIFY_OR_DEBUG_ASSERT(m_pScriptEngine) {
return;
}
Expand Down
10 changes: 5 additions & 5 deletions src/controllers/engine/controllerengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ControllerEngine : public QObject {
ControllerEngine(Controller* controller);
virtual ~ControllerEngine();

void handleInput(QByteArray data, mixxx::Duration timestamp);
void handleInput(const QByteArray& data, mixxx::Duration timestamp);

bool executeFunction(QJSValue functionObject, const QJSValueList& arguments);
bool executeFunction(const QJSValue& functionObject, const QByteArray& data);
Expand All @@ -43,11 +43,11 @@ class ControllerEngine : public QObject {

/// Shows a UI dialog notifying of a script evaluation error.
/// Precondition: QJSValue.isError() == true
void showScriptExceptionDialog(QJSValue evaluationResult, bool bFatal = false);
void showScriptExceptionDialog(const QJSValue& evaluationResult, bool bFatal = false);

bool removeScriptConnection(const ScriptConnection conn);
bool removeScriptConnection(const ScriptConnection& conn);
/// Execute a ScriptConnection's JS callback
void triggerScriptConnection(const ScriptConnection conn);
void triggerScriptConnection(const ScriptConnection& conn);

inline void setTesting(bool testing) {
m_bTesting = testing;
Expand All @@ -64,7 +64,7 @@ class ControllerEngine : public QObject {
double getDefaultParameter(const QString& group, const QString& name);
/// Connect a ControlObject's valueChanged() signal to a script callback function
/// Returns to the script a ScriptConnectionJSProxy
QJSValue makeConnection(const QString& group, const QString& name, const QJSValue callback);
QJSValue makeConnection(const QString& group, const QString& name, const QJSValue& callback);
/// DEPRECATED: Use makeConnection instead.
QJSValue connectControl(const QString& group,
const QString& name,
Expand Down
88 changes: 67 additions & 21 deletions src/controllers/engine/controllerenginejsproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,100 @@ ControllerEngineJSProxy::ControllerEngineJSProxy(ControllerEngine* m_pEngine)
ControllerEngineJSProxy::~ControllerEngineJSProxy() {
}

double ControllerEngineJSProxy::getValue(QString group, QString name) {
double ControllerEngineJSProxy::getValue(
const QString& group,
const QString& name) {
return m_pEngine->getValue(group, name);
}

void ControllerEngineJSProxy::setValue(QString group, QString name, double newValue) {
void ControllerEngineJSProxy::setValue(
const QString& group,
const QString& name,
double newValue) {
m_pEngine->setValue(group, name, newValue);
}

double ControllerEngineJSProxy::getParameter(QString group, QString name) {
double ControllerEngineJSProxy::getParameter(
const QString& group,
const QString& name) {
return m_pEngine->getParameter(group, name);
}

void ControllerEngineJSProxy::setParameter(QString group, QString name, double newValue) {
void ControllerEngineJSProxy::setParameter(
const QString& group,
const QString& name,
double newValue) {
m_pEngine->setParameter(group, name, newValue);
}

double ControllerEngineJSProxy::getParameterForValue(QString group,
QString name,
double ControllerEngineJSProxy::getParameterForValue(
const QString& group,
const QString& name,
double value) {
return m_pEngine->getParameterForValue(group, name, value);
}

void ControllerEngineJSProxy::reset(QString group, QString name) {
void ControllerEngineJSProxy::reset(
const QString& group,
const QString& name) {
m_pEngine->reset(group, name);
}

double ControllerEngineJSProxy::getDefaultValue(QString group, QString name) {
double ControllerEngineJSProxy::getDefaultValue(
const QString& group,
const QString& name) {
return m_pEngine->getDefaultValue(group, name);
}

double ControllerEngineJSProxy::getDefaultParameter(QString group,
QString name) {
double ControllerEngineJSProxy::getDefaultParameter(
const QString& group,
const QString& name) {
return m_pEngine->getDefaultParameter(group, name);
}

QJSValue ControllerEngineJSProxy::makeConnection(QString group, QString name, const QJSValue callback) {
QJSValue ControllerEngineJSProxy::makeConnection(
const QString& group,
const QString& name,
const QJSValue& callback) {
return m_pEngine->makeConnection(group, name, callback);
}

QJSValue ControllerEngineJSProxy::connectControl(QString group, QString name, const QJSValue passedCallback, bool disconnect) {
QJSValue ControllerEngineJSProxy::connectControl(
const QString& group,
const QString& name,
const QJSValue& passedCallback,
bool disconnect) {
return m_pEngine->connectControl(group, name, passedCallback, disconnect);
}

void ControllerEngineJSProxy::trigger(QString group, QString name) {
void ControllerEngineJSProxy::trigger(
const QString& group,
const QString& name) {
m_pEngine->trigger(group, name);
}

void ControllerEngineJSProxy::log(QString message) {
void ControllerEngineJSProxy::log(const QString& message) {
m_pEngine->log(message);
}

int ControllerEngineJSProxy::beginTimer(int interval, QJSValue scriptCode, bool oneShot) {
int ControllerEngineJSProxy::beginTimer(
int interval,
const QJSValue& scriptCode,
bool oneShot) {
return m_pEngine->beginTimer(interval, scriptCode, oneShot);
}

void ControllerEngineJSProxy::stopTimer(int timerId) {
m_pEngine->stopTimer(timerId);
}

void ControllerEngineJSProxy::scratchEnable(int deck, int intervalsPerRev, double rpm, double alpha, double beta, bool ramp) {
void ControllerEngineJSProxy::scratchEnable(
int deck,
int intervalsPerRev,
double rpm,
double alpha,
double beta,
bool ramp) {
m_pEngine->scratchEnable(deck, intervalsPerRev, rpm, alpha, beta, ramp);
}

Expand All @@ -83,20 +117,32 @@ bool ControllerEngineJSProxy::isScratching(int deck) {
return m_pEngine->isScratching(deck);
}

void ControllerEngineJSProxy::softTakeover(QString group, QString name, bool set) {
void ControllerEngineJSProxy::softTakeover(
const QString& group,
const QString& name,
bool set) {
m_pEngine->softTakeover(group, name, set);
}

void ControllerEngineJSProxy::softTakeoverIgnoreNextValue(QString group,
QString name) {
void ControllerEngineJSProxy::softTakeoverIgnoreNextValue(
const QString& group,
const QString& name) {
m_pEngine->softTakeoverIgnoreNextValue(group, name);
}

void ControllerEngineJSProxy::brake(int deck, bool activate, double factor, double rate) {
void ControllerEngineJSProxy::brake(
int deck,
bool activate,
double factor,
double rate) {
m_pEngine->brake(deck, activate, factor, rate);
}

void ControllerEngineJSProxy::spinback(int deck, bool activate, double factor, double rate) {
void ControllerEngineJSProxy::spinback(
int deck,
bool activate,
double factor,
double rate) {
m_pEngine->spinback(deck, activate, factor, rate);
}

Expand Down
36 changes: 21 additions & 15 deletions src/controllers/engine/controllerenginejsproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,34 @@ class ControllerEngineJSProxy : public QObject {

virtual ~ControllerEngineJSProxy();

Q_INVOKABLE double getValue(QString group, QString name);
Q_INVOKABLE void setValue(QString group, QString name, double newValue);
Q_INVOKABLE double getParameter(QString group, QString name);
Q_INVOKABLE void setParameter(QString group, QString name, double newValue);
Q_INVOKABLE double getParameterForValue(QString group, QString name, double value);
Q_INVOKABLE void reset(QString group, QString name);
Q_INVOKABLE double getDefaultValue(QString group, QString name);
Q_INVOKABLE double getDefaultParameter(QString group, QString name);
Q_INVOKABLE QJSValue makeConnection(QString group, QString name, const QJSValue callback);
Q_INVOKABLE double getValue(const QString& group, const QString& name);
Q_INVOKABLE void setValue(const QString& group, const QString& name, double newValue);
Q_INVOKABLE double getParameter(const QString& group, const QString& name);
Q_INVOKABLE void setParameter(const QString& group, const QString& name, double newValue);
Q_INVOKABLE double getParameterForValue(
const QString& group, const QString& name, double value);
Q_INVOKABLE void reset(const QString& group, const QString& name);
Q_INVOKABLE double getDefaultValue(const QString& group, const QString& name);
Q_INVOKABLE double getDefaultParameter(const QString& group, const QString& name);
Q_INVOKABLE QJSValue makeConnection(const QString& group,
const QString& name,
const QJSValue& callback);
// DEPRECATED: Use makeConnection instead.
Q_INVOKABLE QJSValue connectControl(QString group, QString name, const QJSValue passedCallback, bool disconnect = false);
Q_INVOKABLE QJSValue connectControl(const QString& group,
const QString& name,
const QJSValue& passedCallback,
bool disconnect = false);
// Called indirectly by the objects returned by connectControl
Q_INVOKABLE void trigger(QString group, QString name);
Q_INVOKABLE void log(QString message);
Q_INVOKABLE int beginTimer(int interval, QJSValue scriptCode, bool oneShot = false);
Q_INVOKABLE void trigger(const QString& group, const QString& name);
Q_INVOKABLE void log(const QString& message);
Q_INVOKABLE int beginTimer(int interval, const QJSValue& scriptCode, bool oneShot = false);
Q_INVOKABLE void stopTimer(int timerId);
Q_INVOKABLE void scratchEnable(int deck, int intervalsPerRev, double rpm, double alpha, double beta, bool ramp = true);
Q_INVOKABLE void scratchTick(int deck, int interval);
Q_INVOKABLE void scratchDisable(int deck, bool ramp = true);
Q_INVOKABLE bool isScratching(int deck);
Q_INVOKABLE void softTakeover(QString group, QString name, bool set);
Q_INVOKABLE void softTakeoverIgnoreNextValue(QString group, QString name);
Q_INVOKABLE void softTakeover(const QString& group, const QString& name, bool set);
Q_INVOKABLE void softTakeoverIgnoreNextValue(const QString& group, const QString& name);
Q_INVOKABLE void brake(int deck, bool activate, double factor = 1.0, double rate = 1.0);
Q_INVOKABLE void spinback(int deck, bool activate, double factor = 1.8, double rate = -10.0);
Q_INVOKABLE void softStart(int deck, bool activate, double factor = 1.0);
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/midi/midicontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class MidiControllerJSProxy : public ControllerJSProxy {
m_pMidiController->sendShortMsg(status, byte1, byte2);
}

Q_INVOKABLE void sendSysexMsg(QList<int> data, unsigned int length = 0) {
Q_INVOKABLE void sendSysexMsg(const QList<int>& data, unsigned int length = 0) {
m_pMidiController->sendSysexMsg(data, length);
}

Expand Down

0 comments on commit fe9e02b

Please sign in to comment.