Browse Source

Merge branch 'master' of https://github.com/VCVRack/VCV-Prototype

tags/v1.3.0
max 4 years ago
parent
commit
75f1c5f0e1
5 changed files with 67 additions and 24 deletions
  1. +1
    -1
      CHANGELOG.md
  2. +1
    -1
      README.md
  3. +1
    -1
      plugin.json
  4. +4
    -1
      src/LuaJITEngine.cpp
  5. +60
    -20
      src/Prototype.cpp

+ 1
- 1
CHANGELOG.md View File

@@ -28,4 +28,4 @@
- Use ArrayBuffers instead of arrays, improving performance \~5x. - Use ArrayBuffers instead of arrays, improving performance \~5x.


### 1.0.0 (2019-09-15) ### 1.0.0 (2019-09-15)
- Initial release.
- Initial release.

+ 1
- 1
README.md View File

@@ -149,5 +149,5 @@ make
- [Andrew Belt](https://github.com/AndrewBelt): host code, Duktape (JavaScript, not used), LuaJIT (Lua), Python (in development) - [Andrew Belt](https://github.com/AndrewBelt): host code, Duktape (JavaScript, not used), LuaJIT (Lua), Python (in development)
- [Jerry Sievert](https://github.com/JerrySievert): QuickJS (JavaScript) - [Jerry Sievert](https://github.com/JerrySievert): QuickJS (JavaScript)
- [Leonardo Laguna Ruiz](https://github.com/modlfo): Vult - [Leonardo Laguna Ruiz](https://github.com/modlfo): Vult
- [CHAIR](https://chair.audio) [Clemens Wegener (libpd), Max Neupert (patches)] : libpd
- [CHAIR](https://chair.audio) (Clemens Wegener, Max Neupert): libpd
- add your name here - add your name here

+ 1
- 1
plugin.json View File

@@ -1,7 +1,7 @@
{ {
"slug": "VCV-Prototype", "slug": "VCV-Prototype",
"name": "Prototype", "name": "Prototype",
"version": "1.2.0",
"version": "1.3.0",
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"brand": "VCV", "brand": "VCV",
"author": "VCV", "author": "VCV",


+ 4
- 1
src/LuaJITEngine.cpp View File

@@ -112,7 +112,10 @@ struct LuaJITEngine : ScriptEngine {
<< "float *switchLights[" << NUM_ROWS + 1 << "];" << std::endl << "float *switchLights[" << NUM_ROWS + 1 << "];" << std::endl
<< "};]]" << std::endl << "};]]" << std::endl
// Declare the function `_castBlock` used to transform `luaBlock` pointer into a LuaJIT cdata // Declare the function `_castBlock` used to transform `luaBlock` pointer into a LuaJIT cdata
<< "function _castBlock(b) return ffi.cast('struct LuaProcessBlock*', b) end";
<< "_ffi_cast = ffi.cast" << std::endl
<< "function _castBlock(b) return _ffi_cast('struct LuaProcessBlock*', b) end" << std::endl
// Remove global functions that could be abused
<< "jit = nil; require = nil; ffi = nil; load = nil; loadfile = nil; loadstring = nil; dofile = nil;" << std::endl;
std::string ffi_script = ffi_stream.str(); std::string ffi_script = ffi_stream.str();


// Compile the ffi script // Compile the ffi script


+ 60
- 20
src/Prototype.cpp View File

@@ -28,19 +28,30 @@ ScriptEngine* createScriptEngine(std::string extension) {
} }




static std::string editorPath;
static std::string settingsEditorPath;
static std::string settingsPdEditorPath =
#if defined ARCH_LIN
"\"/usr/bin/pd\"";
#else
"";
#endif




json_t* settingsToJson() { json_t* settingsToJson() {
json_t* rootJ = json_object(); json_t* rootJ = json_object();
json_object_set_new(rootJ, "editorPath", json_string(editorPath.c_str()));
json_object_set_new(rootJ, "editorPath", json_string(settingsEditorPath.c_str()));
json_object_set_new(rootJ, "pdEditorPath", json_string(settingsPdEditorPath.c_str()));
return rootJ; return rootJ;
} }


void settingsFromJson(json_t* rootJ) { void settingsFromJson(json_t* rootJ) {
json_t* editorPathJ = json_object_get(rootJ, "editorPath"); json_t* editorPathJ = json_object_get(rootJ, "editorPath");
if (editorPathJ) if (editorPathJ)
editorPath = json_string_value(editorPathJ);
settingsEditorPath = json_string_value(editorPathJ);

json_t* pdEditorPathJ = json_object_get(rootJ, "pdEditorPath");
if (pdEditorPathJ)
settingsPdEditorPath = json_string_value(pdEditorPathJ);
} }


void settingsLoad() { void settingsLoad() {
@@ -75,27 +86,43 @@ void settingsSave() {
json_decref(rootJ); json_decref(rootJ);
} }


void setEditorDialog() {
char* editorPathC = NULL;
std::string getApplicationPathDialog() {
char* pathC = NULL;
#if defined ARCH_LIN #if defined ARCH_LIN
editorPathC = osdialog_file(OSDIALOG_OPEN, "/usr/bin/", NULL, NULL);
pathC = osdialog_file(OSDIALOG_OPEN, "/usr/bin/", NULL, NULL);
#elif defined ARCH_WIN #elif defined ARCH_WIN
osdialog_filters* filters = osdialog_filters_parse("Executable:exe"); osdialog_filters* filters = osdialog_filters_parse("Executable:exe");
editorPathC = osdialog_file(OSDIALOG_OPEN, "C:/", NULL, filters);
pathC = osdialog_file(OSDIALOG_OPEN, "C:/", NULL, filters);
osdialog_filters_free(filters); osdialog_filters_free(filters);
#elif defined ARCH_MAC #elif defined ARCH_MAC
osdialog_filters* filters = osdialog_filters_parse("Application:app"); osdialog_filters* filters = osdialog_filters_parse("Application:app");
editorPathC = osdialog_file(OSDIALOG_OPEN, "/Applications/", NULL, filters);
pathC = osdialog_file(OSDIALOG_OPEN, "/Applications/", NULL, filters);
osdialog_filters_free(filters); osdialog_filters_free(filters);
#endif #endif
if (!editorPathC)
if (!pathC)
return "";

std::string path = "\"";
path += pathC;
path += "\"";
std::free(pathC);
return path;
}

void setEditorDialog() {
std::string path = getApplicationPathDialog();
if (path == "")
return; return;
settingsEditorPath = path;
settingsSave();
}


editorPath = "\"";
editorPath += editorPathC;
editorPath += "\"";
void setPdEditorDialog() {
std::string path = getApplicationPathDialog();
if (path == "")
return;
settingsPdEditorPath = path;
settingsSave(); settingsSave();
std::free(editorPathC);
} }




@@ -463,6 +490,13 @@ struct Prototype : Module {
} }


void editScript() { void editScript() {
std::string editorPath;
// HACK check if extension is .pd
if (string::filenameExtension(string::filename(path)) == "pd")
editorPath = settingsPdEditorPath;
else
editorPath = settingsEditorPath;

if (editorPath.empty()) if (editorPath.empty())
return; return;
if (path.empty()) if (path.empty())
@@ -539,22 +573,28 @@ struct Prototype : Module {
}; };
EditScriptItem* editScriptItem = createMenuItem<EditScriptItem>("Edit script"); EditScriptItem* editScriptItem = createMenuItem<EditScriptItem>("Edit script");
editScriptItem->module = this; editScriptItem->module = this;
editScriptItem->disabled = !doesPathExist() || editorPath == "";

// TODO fix for pdEditorPath
editScriptItem->disabled = !doesPathExist() || settingsEditorPath == "" && false;
menu->addChild(editScriptItem); menu->addChild(editScriptItem);


menu->addChild(new MenuSeparator);

struct SetEditorItem : MenuItem { struct SetEditorItem : MenuItem {
void onAction(const event::Action& e) override { void onAction(const event::Action& e) override {
setEditorDialog(); setEditorDialog();
} }
}; };
SetEditorItem* setEditorItem = createMenuItem<SetEditorItem>("Set editor application");
SetEditorItem* setEditorItem = createMenuItem<SetEditorItem>("Set text editor application");
menu->addChild(setEditorItem); menu->addChild(setEditorItem);


// if (!editorPath.empty()) {
// std::string editorBase = string::filenameBase(string::filename(editorPath));
// MenuLabel* editorBaseLabel = createMenuLabel(editorBase);
// menu->addChild(editorBaseLabel);
// }
struct SetPdEditorItem : MenuItem {
void onAction(const event::Action& e) override {
setPdEditorDialog();
}
};
SetPdEditorItem* setPdEditorItem = createMenuItem<SetPdEditorItem>("Set Pure Data application");
menu->addChild(setPdEditorItem);
} }
}; };




Loading…
Cancel
Save