Skip to content

Commit

Permalink
Fix extension handling to work with the V2 SDK.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleexyz committed Jan 12, 2022
1 parent f693e76 commit 7a3d948
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/DuktapeEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,5 @@ struct DuktapeEngine : ScriptEngine {

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<DuktapeEngine>("js");
addScriptEngine<DuktapeEngine>(".js");
}
2 changes: 1 addition & 1 deletion src/FaustEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,5 +369,5 @@ class FaustEngine : public ScriptEngine {

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<FaustEngine>("dsp");
addScriptEngine<FaustEngine>(".dsp");
}
2 changes: 1 addition & 1 deletion src/LibPDEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,5 +331,5 @@ void LibPDEngine::sendInitialStates(const ProcessBlock* block) {

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<LibPDEngine>("pd");
addScriptEngine<LibPDEngine>(".pd");
}
2 changes: 1 addition & 1 deletion src/LuaJITEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,5 @@ struct LuaJITEngine : ScriptEngine {

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<LuaJITEngine>("lua");
addScriptEngine<LuaJITEngine>(".lua");
}
14 changes: 7 additions & 7 deletions src/Prototype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ struct Prototype : Module {
std::string extension = system::getExtension(path);
scriptEngine = createScriptEngine(extension);
if (!scriptEngine) {
message = string::f("No engine for .%s extension", extension.c_str());
message = string::f("No engine for %s extension", extension.c_str());
return;
}
scriptEngine->module = this;
Expand Down Expand Up @@ -406,13 +406,13 @@ struct Prototype : Module {
}

void newScriptDialog() {
std::string ext = "js";
std::string ext = ".js";
// Get current extension if a script is currently loaded
if (!path.empty()) {
ext = system::getExtension(path);
}
std::string dir = asset::plugin(pluginInstance, "examples");
std::string filename = "Untitled." + ext;
std::string filename = "Untitled" + ext;
char* newPathC = osdialog_file(OSDIALOG_SAVE, dir.c_str(), filename.c_str(), NULL);
if (!newPathC) {
return;
Expand All @@ -436,7 +436,7 @@ struct Prototype : Module {
}

// Copy template to new script
std::string templatePath = asset::plugin(pluginInstance, "examples/template." + ext);
std::string templatePath = asset::plugin(pluginInstance, "examples/template" + ext);
{
std::ifstream templateFile(templatePath, std::ios::binary);
std::ofstream newFile(newPath, std::ios::binary);
Expand Down Expand Up @@ -468,7 +468,7 @@ struct Prototype : Module {

std::string ext = system::getExtension(path);
std::string dir = asset::plugin(pluginInstance, "examples");
std::string filename = "Untitled." + ext;
std::string filename = "Untitled" + ext;
char* newPathC = osdialog_file(OSDIALOG_SAVE, dir.c_str(), filename.c_str(), NULL);
if (!newPathC) {
return;
Expand All @@ -478,7 +478,7 @@ struct Prototype : Module {
// Add extension if user didn't specify one
std::string newExt = system::getExtension(newPath);
if (newExt == "")
newPath += "." + ext;
newPath += ext;

// Write and close file
{
Expand Down Expand Up @@ -594,7 +594,7 @@ struct Prototype : Module {
if (path == "")
return "";
// HACK check if extension is .pd
if (system::getExtension(path) == "pd")
if (system::getExtension(path) == ".pd")
return settingsPdEditorPath;
return settingsEditorPath;
}
Expand Down
2 changes: 1 addition & 1 deletion src/PythonEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,5 @@ struct PythonEngine : ScriptEngine {

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<PythonEngine>("py");
addScriptEngine<PythonEngine>(".py");
}
2 changes: 1 addition & 1 deletion src/QuickJSEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,5 +329,5 @@ struct QuickJSEngine : ScriptEngine {

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<QuickJSEngine>("js");
addScriptEngine<QuickJSEngine>(".js");
}
4 changes: 2 additions & 2 deletions src/SuperColliderEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,6 @@ bool SC_VcvPrototypeClient::copyArrayOfFloatArrays(const PyrSlot& inSlot, const

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<SuperColliderEngine>("sc");
addScriptEngine<SuperColliderEngine>("scd");
addScriptEngine<SuperColliderEngine>(".sc");
addScriptEngine<SuperColliderEngine>(".scd");
}
2 changes: 1 addition & 1 deletion src/VultEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,5 @@ struct VultEngine : ScriptEngine {

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<VultEngine>("vult");
addScriptEngine<VultEngine>(".vult");
}

0 comments on commit 7a3d948

Please sign in to comment.