Skip to content

Commit

Permalink
Merge branch 'master' into bugfix-1661-recent-files-namager
Browse files Browse the repository at this point in the history
  • Loading branch information
highperformancecoder committed Jan 8, 2024
2 parents 5275438 + 438c5c9 commit e7aca9a
Show file tree
Hide file tree
Showing 48 changed files with 245 additions and 862 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
sudo add-apt-repository -y \
'deb http://download.opensuse.org/repositories/home:/hpcoder1/xUbuntu_${{ matrix.ubuntu_ver }}/ /'
sudo apt install -y --no-install-recommends \
g++ tcl-dev tk-dev libcairo2-dev zlib1g-dev libreadline-dev libgsl0-dev libblas-dev libpango1.0-dev exuberant-ctags libdb-dev libncurses5-dev librsvg2-dev json-spirit boost-python3-dev libssl-dev libclipboard
g++ tcl-dev tk-dev libcairo2-dev zlib1g-dev libreadline-dev libgsl0-dev libblas-dev libpango1.0-dev exuberant-ctags libdb-dev libncurses5-dev librsvg2-dev boost-python3-dev libssl-dev libclipboard
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ PREFIX=/usr/local
# custom one that picks up its scripts from a relative library
# directory
MODLINK=$(LIBMODS:%=$(ECOLAB_HOME)/lib/%)
MODEL_OBJS=autoLayout.o cairoItems.o canvas.o CSVDialog.o dataOp.o equationDisplay.o godleyIcon.o godleyTable.o godleyTableWindow.o grid.o group.o item.o itemTab.o intOp.o lasso.o lock.o minsky.o operation.o operationRS.o operationRS1.o operationRS2.o phillipsDiagram.o plotWidget.o port.o pubTab.o ravelWrap.o renderNativeWindow.o selection.o sheet.o SVGItem.o switchIcon.o userFunction.o userFunction_units.o variableInstanceList.o variable.o variablePane.o windowInformation.o wire.o
MODEL_OBJS=autoLayout.o cairoItems.o canvas.o CSVDialog.o dataOp.o equationDisplay.o godleyIcon.o godleyTable.o godleyTableWindow.o grid.o group.o item.o intOp.o lasso.o lock.o minsky.o operation.o operationRS.o operationRS1.o operationRS2.o phillipsDiagram.o plotWidget.o port.o pubTab.o ravelWrap.o renderNativeWindow.o selection.o sheet.o SVGItem.o switchIcon.o userFunction.o userFunction_units.o variableInstanceList.o variable.o variablePane.o windowInformation.o wire.o
ENGINE_OBJS=coverage.o clipboard.o derivative.o equationDisplayRender.o equations.o evalGodley.o evalOp.o flowCoef.o \
godleyExport.o latexMarkup.o valueId.o variableValue.o node_latex.o node_matlab.o CSVParser.o \
minskyTensorOps.o mdlReader.o saver.o rungeKutta.o
Expand Down
15 changes: 15 additions & 0 deletions RESTService/addon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ namespace minsky
mutex cmdMutex;
atomic<bool> running{true};
std::thread thread;
bool inputBufferExceeded=false;

AddOnMinsky(): thread([this](){run();}) {
flags=0;
Expand Down Expand Up @@ -135,6 +136,14 @@ namespace minsky
if (syncPos!=string::npos && syncPos==command.size()-12)
return String::New(env, utf_to_utf<char16_t>(doCommand(command, arguments)));
#endif
if (minskyCommands.size()>10)
{
if (!inputBufferExceeded) setBusyCursor();
inputBufferExceeded=true;
return env.Null();
}
if (inputBufferExceeded) clearBusyCursor(); // single shot clear of busy curser
inputBufferExceeded=false;
lock_guard<mutex> lock(cmdMutex);
minskyCommands.emplace_back(new Command{env,command,arguments});
return minskyCommands.back()->promiseResolver->promise.Promise();
Expand Down Expand Up @@ -237,6 +246,12 @@ namespace minsky
LocalMinsky lm(*this); // sets this to be the global minsky object
reset();
}
if (inputBufferExceeded && minskyCommands.empty())
{
// clears busy cursor when no commands are being received or processed
clearBusyCursor();
inputBufferExceeded=false;
}
}
catch (...)
{flags&=~reset_needed;}
Expand Down
3 changes: 0 additions & 3 deletions RESTService/typescriptAPI.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
#include "intOp.tcd"
#include "item.tcd"
#include "itemT.tcd"
#include "itemTab.h"
#include "itemTab.tcd"
#include "lasso.tcd"
#include "lock.tcd"
#include "noteBase.tcd"
Expand Down Expand Up @@ -309,7 +307,6 @@ int main()
cout << "class classdesc__RESTProcess_t {}\n";
cout << "class classdesc__TCL_obj_t {}\n";
cout << "class ecolab__cairo__Surface {}\n";
cout << "class ecolab__Pango {}\n";
cout<<endl;

// these need to be declared in a specific order
Expand Down
2 changes: 1 addition & 1 deletion ecolab
Submodule ecolab updated 1 files
+1 −1 classdesc
9 changes: 7 additions & 2 deletions engine/CSVParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -809,13 +809,15 @@ namespace minsky
size_t idx=0;
assert (hc.rank()<=i.first.size());
assert(dimLabels.size()==hc.rank());
for (int j=hc.rank()-1, k=i.first.size()-1; j>=0 && k>=0; --j, --k)
int j=hc.rank()-1, k=i.first.size()-1;
while (j>=0 && k>=0)
{
auto dimLabel=dimLabels[j].find(i.first[k]);
while (dimLabel==dimLabels[j].end() && k>0) // skip over elided dimension
dimLabel=dimLabels[j].find(i.first[--k]);
assert(dimLabel!=dimLabels[j].end());
idx = (idx*dims[j]) + dimLabel->second;
--j; --k;
}
vv.tensorInit[idx]=i.second;
++minsky().progressState;
Expand All @@ -836,13 +838,16 @@ namespace minsky
size_t idx=0;
assert (dims.size()<=i.first.size());
assert(dimLabels.size()==dims.size());
for (int j=dims.size()-1, k=i.first.size()-1; j>=0 && k>=0; --j, --k)
int j=dims.size()-1, k=i.first.size()-1;
while (j>=0 && k>=0) // changed from for loop to while loop at CodeQL's insistence
{
auto dimLabel=dimLabels[j].find(i.first[k]);
while (dimLabel==dimLabels[j].end() && k>0) // skip over elided dimension
dimLabel=dimLabels[j].find(i.first[--k]);
assert(dimLabel!=dimLabels[j].end());
idx = (idx*dims[j]) + dimLabel->second;
--j;
--k;
}
if (!isnan(i.second))
indexValue.emplace(idx, i.second);
Expand Down
28 changes: 14 additions & 14 deletions engine/equations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,15 @@ namespace MathDAG
i++;
if (!argIdx.empty() && i<argIdx[0].size())
{
ev.push_back(EvalOpPtr(OperationType::copy, state, *r, *argIdx[0][i]));
ev.push_back(EvalOpPtr(OperationType::copy, state, r, *argIdx[0][i]));
for (++i; i<argIdx[0].size(); ++i)
if (accum!=OperationType::add || !argIdx[0][i]->isZero())
ev.push_back(EvalOpPtr(accum, state, *r, *r, *argIdx[0][i]));
ev.push_back(EvalOpPtr(accum, state, r, *r, *argIdx[0][i]));
}
else
{
//TODO: could be cleaned up if we don't need to support constant operators
ev.push_back(EvalOpPtr(OperationType::constant, state, *r));
ev.push_back(EvalOpPtr(OperationType::constant, state, r));
dynamic_cast<ConstantEvalOp&>(*ev.back()).value=groupIdentity;
}
}
Expand All @@ -291,12 +291,12 @@ namespace MathDAG
{
if (argIdx[1].size()==1)
// eliminate redundant copy operation when only one wire
ev.push_back(EvalOpPtr(op, state, *r, *r, *argIdx[1][0]));
ev.push_back(EvalOpPtr(op, state, r, *r, *argIdx[1][0]));
else if (argIdx[1].size()>1)
{
// multiple wires to second input port
VariableValue tmp(VariableType::tempFlow);
tmp.hypercube(r->hypercube());
VariableValuePtr tmp(VariableType::tempFlow);
tmp->hypercube(r->hypercube());
size_t i=0;
if (accum==OperationType::add)
while (i<argIdx[1].size() && argIdx[1][i]->isZero()) i++;
Expand All @@ -305,8 +305,8 @@ namespace MathDAG
ev.push_back(EvalOpPtr(OperationType::copy, state, tmp, *argIdx[1][i]));
for (++i; i<argIdx[1].size(); ++i)
if (accum!=OperationType::add || !argIdx[1][i]->isZero())
ev.push_back(EvalOpPtr(accum, state, tmp, tmp, *argIdx[1][i]));
ev.push_back(EvalOpPtr(op, state, *r, *r, tmp));
ev.push_back(EvalOpPtr(accum, state, tmp, *tmp, *argIdx[1][i]));
ev.push_back(EvalOpPtr(op, state, r, *r, *tmp));
}
}
}
Expand Down Expand Up @@ -388,7 +388,7 @@ namespace MathDAG
else if (arguments.size()>1 && !argIdx[1].empty())
argIdx[0][0]->units=argIdx[1][0]->units;
}
ev.push_back(EvalOpPtr(type(), state, *result, *argIdx[0][0], *argIdx[1][0]));
ev.push_back(EvalOpPtr(type(), state, result, *argIdx[0][0], *argIdx[1][0]));
break;
case userFunction:
for (size_t i=0; i<arguments.size(); ++i)
Expand All @@ -397,11 +397,11 @@ namespace MathDAG
argIdx[i].push_back(VariableValuePtr(VariableValue::tempFlow));
argIdx[i].back()->allocValue();
}
ev.push_back(EvalOpPtr(type(), state, *result, *argIdx[0][0], *argIdx[1][0]));
ev.push_back(EvalOpPtr(type(), state, result, *argIdx[0][0], *argIdx[1][0]));
break;
case data:
if (!argIdx.empty() && argIdx[0].size()==1)
ev.push_back(EvalOpPtr(type(), state, *result, *argIdx[0][0]));
ev.push_back(EvalOpPtr(type(), state, result, *argIdx[0][0]));
else
throw error("inputs for highlighted operations incorrectly wired");
break;
Expand All @@ -423,13 +423,13 @@ namespace MathDAG
switch (arguments.size())
{
case 0:
ev.push_back(EvalOpPtr(type(), state, *result));
ev.push_back(EvalOpPtr(type(), state, result));
break;
case 1:
ev.push_back(EvalOpPtr(type(), state, *result, *argIdx[0][0]));
ev.push_back(EvalOpPtr(type(), state, result, *argIdx[0][0]));
break;
case 2:
ev.push_back(EvalOpPtr(type(), state, *result, *argIdx[0][0], *argIdx[1][0]));
ev.push_back(EvalOpPtr(type(), state, result, *argIdx[0][0], *argIdx[1][0]));
break;
default:
throw error("Too many arguments");
Expand Down
9 changes: 6 additions & 3 deletions engine/evalOp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -641,9 +641,12 @@ namespace minsky
}

EvalOpPtr::EvalOpPtr(OperationType::Type op, const ItemPtr& state,
VariableValue& to, const VariableValue& from1, const VariableValue& from2)
const std::shared_ptr<VariableValue>& to,
const VariableValue& from1, const VariableValue& from2)
{
assert(to);
auto t=ScalarEvalOp::create(op,state);
t->result=to;
reset(t);
assert(t->numArgs()==0 || (from1.idx()>=0 && (t->numArgs()==1 || from2.idx()>=0)));

Expand All @@ -655,8 +658,8 @@ namespace minsky
if (t->numArgs()>1)
t->in2.emplace_back(1,EvalOpBase::Support{1,unsigned(from2.idx())});

if (to.idx()==-1) to.allocValue();
t->out=to.idx();
if (to->idx()==-1) to->allocValue();
t->out=to->idx();
t->flow1=from1.isFlowVar();
t->flow2=from2.isFlowVar();

Expand Down
4 changes: 3 additions & 1 deletion engine/evalOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ namespace minsky
/// Legacy EvalOp base interface
struct ScalarEvalOp: public EvalOpBase
{
std::shared_ptr<VariableValue> result; ///< lifetime management of the resultant variableValue
/// number of arguments to this operation
virtual int numArgs() const =0;

Expand Down Expand Up @@ -154,9 +155,10 @@ namespace minsky
EvalOpPtr(EvalOpBase* e): classdesc::shared_ptr<EvalOpBase>(e) {}
EvalOpPtr(OperationType::Type op):
classdesc::shared_ptr<EvalOpBase>(ScalarEvalOp::create(op,nullptr)) {}
/// \a to cannot be null
EvalOpPtr(OperationType::Type op,
const ItemPtr& state,
VariableValue& to,
const std::shared_ptr<VariableValue>& to,
const VariableValue& from1={},
const VariableValue& from2={});
};
Expand Down
8 changes: 4 additions & 4 deletions engine/valueId.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace minsky
return utf_to_utf<char>(stripActive(trimWS(latexToPangoNonItalicised(uqName(name)))));
}

string valueId(size_t scope, const string& name)
string valueIdCanonical(size_t scope, const string& name)
{
auto tmp=":"+name;
if (scope==0) return tmp;
Expand All @@ -68,7 +68,7 @@ namespace minsky

string valueId(const string& name)
{
return valueId(scope(name), canonicalName(name));
return valueIdCanonical(scope(name), canonicalName(name));
}

string valueId(const GroupPtr& ref, const string& name)
Expand Down Expand Up @@ -121,8 +121,8 @@ namespace minsky
string valueIdFromScope(const GroupPtr& scope, const std::string& name)
{
if (name.empty() || !scope || !scope->group.lock())
return valueId(0,utf_to_utf<char>(name)); // retain previous global var id
return valueId(size_t(scope.get()), utf_to_utf<char>(name));
return valueIdCanonical(0,name); // retain previous global var id
return valueIdCanonical(size_t(scope.get()), name);
}

std::string uqName(const std::string& name)
Expand Down
2 changes: 1 addition & 1 deletion engine/valueId.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace minsky
bool isValueId(const std::string& name);

/// construct a valueId \@ name should be canonicalised
std::string valueId(size_t scope, const std::string& name);
std::string valueIdCanonical(size_t scope, const std::string& name);
/// construct a valueId from fully qualified name \@ name should not be canonicalised
std::string valueId(const std::string& name);

Expand Down
4 changes: 2 additions & 2 deletions engine/variableValue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ namespace minsky
case tempFlow:
case constant:
case parameter:
// assert(idxInRange());
assert(idxInRange());
if (size_t(m_idx)<ValueVector::flowVars.size())
return ValueVector::flowVars[m_idx];
break;
case stock:
case integral:
// assert(idxInRange());
assert(idxInRange());
if (size_t(m_idx)<ValueVector::stockVars.size())
return ValueVector::stockVars[m_idx];
break;
Expand Down
2 changes: 1 addition & 1 deletion engine/variableValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ namespace minsky
/// allocate space in the variable vector. @returns reference to this
VariableValue& allocValue();

std::string valueId() const {return valueIdFromScope(m_scope.lock(),name);}
std::string valueId() const {return valueIdFromScope(m_scope.lock(),canonicalName(name));}

void exportAsCSV(const std::string& filename, const std::string& comment="") const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class ApplicationMenuManager {
{
label: 'Dimensional Analysis',
click: async () => {
const res = minsky.dimensionalAnalysis();
const res = await minsky.dimensionalAnalysis();

// empty object is returned if no error
if (typeof res=="object") {
Expand Down Expand Up @@ -605,7 +605,7 @@ export class ApplicationMenuManager {
};
}
static async buildMenuForInsertOperations() {
const availableOperationsMapping = minsky.availableOperationsMapping();
const availableOperationsMapping = await minsky.availableOperationsMapping();
let insertOperationsMenu: MenuItem[] = [];
let menuNames={
"constop": "Fundamental Constants",
Expand Down
11 changes: 3 additions & 8 deletions gui-js/apps/minsky-electron/src/app/managers/BookmarkManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class BookmarkManager {
.getMenuItemById('main-bookmark')
.submenu.getMenuItemById('delete-bookmark').submenu;

const disableAllBookmarksInListAndDelete = () => {
mainSubmenu.items.forEach((bookmark) => {
if (bookmark.id === 'minsky-bookmark') {
bookmark.visible = false;
Expand All @@ -25,9 +24,7 @@ export class BookmarkManager {
bookmark.visible = false;
}
});
};

const addNewBookmarks = () => {
if (bookmarks.length) {
bookmarks.forEach((bookmark, index) => {
mainSubmenu.append(
Expand Down Expand Up @@ -58,13 +55,11 @@ export class BookmarkManager {
);
});
}
};

disableAllBookmarksInListAndDelete();
addNewBookmarks();
}

static async updateBookmarkList() {
this.populateBookmarks(await minsky.canvas.model.bookmarkList());
let bookmarks=await minsky.canvas.model.bookmarkList();
if (bookmarks!==null) // TODO why is this sometime null?
this.populateBookmarks(bookmarks);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class CommandsManager {

static async getItemInfo(x: number, y: number): Promise<CanvasItem> {

if (!minsky.canvas.getItemAt(x, y)) {
if (!await minsky.canvas.getItemAt(x, y)) {
return null;
}

Expand Down Expand Up @@ -304,7 +304,7 @@ export class CommandsManager {

static async findDefinition(): Promise<void> {

const findVariableDefinition = minsky.canvas.findVariableDefinition();
const findVariableDefinition = await minsky.canvas.findVariableDefinition();

if (findVariableDefinition) {
const itemX = await minsky.model.x();
Expand Down Expand Up @@ -439,6 +439,7 @@ export class CommandsManager {
minsky.canvas.recentre();
minsky.popFlags();
await minsky.doPushHistory(true);
WindowManager.getMainWindow()?.webContents?.send(events.CHANGE_MAIN_TAB); // not necesarily removed, maybe added
WindowManager.getMainWindow()?.webContents?.send(events.PUB_TAB_REMOVED); // not necesarily removed, maybe added
}

Expand Down Expand Up @@ -553,7 +554,7 @@ export class CommandsManager {
let classType = (await this.getItemClassType(x, y, true)) as string;

if (Functions.isEmptyObject(classType)) {
classType = minsky.canvas.getWireAt(x,y) ? 'Wires' : 'DesignCanvas';
classType = (await minsky.canvas.getWireAt(x,y)) ? 'Wires' : 'DesignCanvas';
}

if (!classType) {
Expand Down
Loading

0 comments on commit e7aca9a

Please sign in to comment.