Skip to content

Commit ba16c3d

Browse files
Merge pull request #558 from highperformancecoder/feature-librarian
Feature librarian
2 parents a91c0c6 + 81c02d4 commit ba16c3d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1511
-824
lines changed

Doxyversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
PROJECT_NAME=Minsky: 3.19.0-beta.1
1+
PROJECT_NAME=Minsky: 3.19.0-beta.2

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ PREFIX=/usr/local
162162
# directory
163163
MODLINK=$(LIBMODS:%=$(ECOLAB_HOME)/lib/%)
164164
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
165-
ENGINE_OBJS=clipboard.o derivative.o equationDisplayRender.o equations.o evalGodley.o evalOp.o flowCoef.o \
165+
ENGINE_OBJS=clipboard.o databaseIngestor.o derivative.o equationDisplayRender.o equations.o evalGodley.o evalOp.o flowCoef.o \
166166
godleyExport.o latexMarkup.o valueId.o variableValue.o node_latex.o node_matlab.o CSVParser.o \
167167
minskyTensorOps.o mdlReader.o saver.o rungeKutta.o
168168
SCHEMA_OBJS=schema3.o schema2.o schema1.o schema0.o schemaHelper.o variableType.o \
@@ -305,7 +305,7 @@ endif
305305
LIBS+= -LRavelCAPI -lravelCAPI -LRavelCAPI/civita -lcivita \
306306
-lboost_system$(BOOST_EXT) -lboost_regex$(BOOST_EXT) \
307307
-lboost_date_time$(BOOST_EXT) -lboost_program_options$(BOOST_EXT) \
308-
-lboost_filesystem$(BOOST_EXT) -lboost_thread$(BOOST_EXT) -lgsl -lgslcblas -lssl -lcrypto
308+
-lboost_filesystem$(BOOST_EXT) -lboost_thread$(BOOST_EXT) -lsoci_core -lgsl -lgslcblas -lssl -lcrypto
309309

310310
ifdef MXE
311311
LIBS+=-lcrypt32 -lbcrypt -lshcore

RESTService/addon.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ namespace minsky
242242
if (reset_flag()) requestReset();
243243

244244
civita::ITensor::cancel(false);
245+
ravelCAPI::Ravel::cancel(false);
245246
// disable quoting wide characters in UTF-8 strings
246247
auto result=write(registry.process(command, arguments)->asBuffer(),json5_parser::raw_utf8);
247248
commandHook(command,arguments);
@@ -594,6 +595,7 @@ struct MinskyAddon: public Addon<MinskyAddon>
594595
Value cancelProgress(const Napi::CallbackInfo& info) {
595596
*addOnMinsky.progressState.cancel=true;
596597
civita::ITensor::cancel(true);
598+
ravelCAPI::Ravel::cancel(true);
597599
return info.Env().Null();
598600
}
599601

RESTService/pyminsky.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ namespace pyminsky
9797
}
9898
CLASSDESC_ADD_FUNCTION(findObject);
9999
CLASSDESC_ADD_FUNCTION(findVariable);
100+
using minsky::DataSpec;
101+
CLASSDESC_DECLARE_TYPE(DataSpec);
100102
}
101103

102104
CLASSDESC_PYTHON_MODULE(pyminsky);

RESTService/typescriptAPI.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@
77
#include "bookmark.h"
88
#include "bookmark.tcd"
99
#include "cairoSurfaceImage.tcd"
10+
#include "cairoRenderer.tcd"
1011
#include "callableFunction.tcd"
1112
#include "canvas.tcd"
13+
#define CLASSDESC_typescriptAPI___CAPIRenderer
14+
#include "capiRenderer.tcd"
1215
#include "CSVDialog.tcd"
1316
#include "CSVParser.tcd"
17+
#include "CSVTools.tcd"
1418
#include "constMap.tcd"
1519
#include "dataSpecSchema.tcd"
1620
#include "dataOp.h"
1721
#include "dataOp.tcd"
22+
#include "databaseIngestor.tcd"
1823
#include "dimension.tcd"
24+
#include "dynamicRavelCAPI.tcd"
1925
#include "engNotation.tcd"
2026
#include "equationDisplay.tcd"
2127
#include "evalGodley.tcd"
@@ -242,10 +248,12 @@ int main()
242248
api.addClass<Bookmark>();
243249
api.addClass<Canvas::ZoomCrop>();
244250
api.addClass<civita::Dimension>();
251+
api.addClass<civita::NamedDimension>();
245252
api.addClass<civita::Hypercube>();
246253
api.addClass<civita::Index>();
247254
api.addClass<civita::ITensor>();
248255
api.addClass<civita::XVector>();
256+
api.addClass<CSVDialog>();
249257
api.addClass<DataSpecSchema>();
250258
api.addClass<ecolab::Plot::LineStyle>();
251259
api.addClass<EngNotation>();
@@ -254,8 +262,11 @@ int main()
254262
api.addClass<HandleLockInfo>();
255263
api.addClass<Port>();
256264
api.addClass<PubItem>();
265+
api.addClass<ravel::DataSpec>();
257266
api.addClass<ravel::HandleState>();
258267
api.addClass<ravel::RavelState>();
268+
api.addClass<ravelCAPI::Database>();
269+
api.addClass<ravelCAPI::Ravel>();
259270
api.addClass<Units>();
260271
api.addClass<VariablePaneCell>();
261272
api.addClass<VariableValue>();
@@ -299,6 +310,7 @@ int main()
299310
cout << "class minsky__GodleyIcon__MoveCellArgs {}\n";
300311
cout << "class minsky__RenderNativeWindow__RenderFrameArgs {}\n";
301312
cout << "class minsky__VariableType__TypeT {}\n";
313+
cout << "class CAPIRenderer {}\n";
302314
cout << "class civita__ITensor__Args {}\n";
303315
cout << "class classdesc__json_pack_t {}\n";
304316
cout << "class classdesc__pack_t {}\n";

doc/version.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
\author{Version 3.19.0-beta.1}
1+
\author{Version 3.19.0-beta.2}

engine/CSVParser.cc

Lines changed: 5 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "minsky.h"
2121
#include "CSVParser.h"
2222

23+
#include "CSVTools.rcd"
2324
#include "CSVParser.rcd"
2425
#include "dataSpecSchema.rcd"
2526
#include "dimension.rcd"
@@ -36,156 +37,15 @@
3637

3738
using namespace minsky;
3839
using namespace std;
40+
using ravel::Parser;
41+
using ravel::SpaceSeparatorParser;
42+
using ravel::getWholeLine;
3943

4044
#include <boost/type_traits.hpp>
4145
#include <boost/tokenizer.hpp>
4246
#include <boost/token_functions.hpp>
4347
#include <boost/pool/pool.hpp>
4448

45-
namespace escapedListSeparator
46-
{
47-
// pinched from boost::escape_list_separator, and modified to not throw
48-
template <class Char,
49-
class Traits = BOOST_DEDUCED_TYPENAME std::basic_string<Char>::traits_type >
50-
class EscapedListSeparator {
51-
52-
private:
53-
typedef std::basic_string<Char,Traits> string_type;
54-
struct char_eq {
55-
Char e_;
56-
char_eq(Char e):e_(e) { }
57-
bool operator()(Char c) {
58-
return Traits::eq(e_,c);
59-
}
60-
};
61-
string_type escape_;
62-
string_type c_;
63-
string_type quote_;
64-
bool last_;
65-
66-
bool is_escape(Char e) {
67-
const char_eq f(e);
68-
return std::find_if(escape_.begin(),escape_.end(),f)!=escape_.end();
69-
}
70-
bool is_c(Char e) {
71-
const char_eq f(e);
72-
return std::find_if(c_.begin(),c_.end(),f)!=c_.end();
73-
}
74-
bool is_quote(Char e) {
75-
const char_eq f(e);
76-
return std::find_if(quote_.begin(),quote_.end(),f)!=quote_.end();
77-
}
78-
template <typename iterator, typename Token>
79-
void do_escape(iterator& next,iterator end,Token& tok) {
80-
if (++next >= end)
81-
// don't throw, but pass on verbatim
82-
tok+=escape_.front();
83-
if (Traits::eq(*next,'n')) {
84-
tok+='\n';
85-
return;
86-
}
87-
if (is_quote(*next)) {
88-
tok+=*next;
89-
return;
90-
}
91-
if (is_c(*next)) {
92-
tok+=*next;
93-
return;
94-
}
95-
if (is_escape(*next)) {
96-
tok+=*next;
97-
return;
98-
}
99-
// don't throw, but pass on verbatim
100-
tok+=escape_.front()+*next;
101-
}
102-
103-
public:
104-
105-
explicit EscapedListSeparator(Char e = '\\',
106-
Char c = ',',Char q = '\"')
107-
: escape_(1,e), c_(1,c), quote_(1,q), last_(false) { }
108-
109-
EscapedListSeparator(string_type e, string_type c, string_type q)
110-
: escape_(e), c_(c), quote_(q), last_(false) { }
111-
112-
void reset() {last_=false;}
113-
114-
template <typename InputIterator, typename Token>
115-
bool operator()(InputIterator& next,InputIterator end,Token& tok) {
116-
bool bInQuote = false;
117-
tok = Token();
118-
119-
if (next >= end) {
120-
next=end; // reset next in case it has adavanced beyond
121-
if (last_) {
122-
last_ = false;
123-
return true;
124-
}
125-
return false;
126-
}
127-
last_ = false;
128-
while (next < end) {
129-
if (is_escape(*next)) {
130-
do_escape(next,end,tok);
131-
}
132-
else if (is_c(*next)) {
133-
if (!bInQuote) {
134-
// If we are not in quote, then we are done
135-
++next;
136-
// The last character was a c, that means there is
137-
// 1 more blank field
138-
last_ = true;
139-
return true;
140-
}
141-
tok+=*next;
142-
}
143-
else if (is_quote(*next)) {
144-
bInQuote=!bInQuote;
145-
}
146-
else {
147-
tok += *next;
148-
}
149-
++next;
150-
}
151-
return true;
152-
}
153-
};
154-
}
155-
using Parser=escapedListSeparator::EscapedListSeparator<char>;
156-
157-
typedef boost::tokenizer<Parser> Tokenizer;
158-
159-
struct SpaceSeparatorParser
160-
{
161-
char escape, quote;
162-
SpaceSeparatorParser(char escape='\\', char sep=' ', char quote='"'):
163-
escape(escape), quote(quote) {}
164-
template <class I>
165-
bool operator()(I& next, I end, std::string& tok)
166-
{
167-
tok.clear();
168-
bool quoted=false;
169-
while (next!=end)
170-
{
171-
if (*next==escape)
172-
tok+=*(++next);
173-
else if (*next==quote)
174-
quoted=!quoted;
175-
else if (!quoted && isspace(*next))
176-
{
177-
while (isspace(*next)) ++next;
178-
return true;
179-
}
180-
else
181-
tok+=*next;
182-
++next;
183-
}
184-
return !tok.empty();
185-
}
186-
void reset() {}
187-
};
188-
18949
namespace
19050
{
19151
/// An any with cached hash
@@ -383,6 +243,7 @@ void DataSpec::setDataArea(size_t row, size_t col)
383243
dataCols.erase(i);
384244
for (unsigned i=m_nColAxes; i<numCols && i<maxColumn; ++i)
385245
dataCols.insert(i);
246+
toSchema();
386247
}
387248

388249

@@ -573,49 +434,6 @@ void DataSpec::populateFromRavelMetadata(const std::string& metadata, const stri
573434

574435
namespace minsky
575436
{
576-
// handle DOS files with '\r' '\n' line terminators
577-
void chomp(string& buf)
578-
{
579-
if (!buf.empty() && buf.back()=='\r')
580-
buf.erase(buf.size()-1);
581-
}
582-
583-
// gets a line, accounting for quoted newlines
584-
bool getWholeLine(istream& input, string& line, const DataSpec& spec)
585-
{
586-
line.clear();
587-
bool r=getline(input,line).good();
588-
chomp(line);
589-
while (r)
590-
{
591-
int quoteCount=0;
592-
for (auto i: line)
593-
if (i==spec.quote)
594-
++quoteCount;
595-
if (quoteCount%2==0) break; // data line correctly terminated
596-
string buf;
597-
r=getline(input,buf).good(); // read next line and append
598-
chomp(buf);
599-
line+=buf;
600-
}
601-
escapeDoubledQuotes(line,spec);
602-
return r || !line.empty();
603-
}
604-
605-
void escapeDoubledQuotes(std::string& line,const DataSpec& spec)
606-
{
607-
// replace doubled quotes with escape quote
608-
for (size_t i=1; i<line.size(); ++i)
609-
if (line[i]==spec.quote && line[i-1]==spec.quote &&
610-
((i==1 && (i==line.size()-1|| line[i+1]!=spec.quote)) || // deal with leading ""
611-
(i>1 &&
612-
((line[i-2]!=spec.quote && line[i-2]!=spec.escape &&
613-
(line[i-2]!=spec.separator || i==line.size()-1|| line[i+1]!=spec.quote)) // deal with ,''
614-
|| // deal with "" middle or end
615-
(line[i-2]==spec.quote && (i==2 || line[i-3]==spec.separator || line[i-3]==spec.escape)))))) // deal with leading """
616-
line[i-1]=spec.escape;
617-
}
618-
619437
/// handle reporting errors in loadValueFromCSVFileT when loading files
620438
struct OnError
621439
{

engine/CSVParser.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@ namespace minsky
8383
guessFromStream(is, std::filesystem::file_size(fileName));
8484
}
8585

86+
// converts this to the ravel data spec. TODO - can we eliminate, or at least eviscerate this type?
87+
operator ravel::DataSpec() const {
88+
ravel::DataSpec r; static_cast<ravel::CSVSpec&>(r)=*this;
89+
r.dataRowOffset=dataRowOffset; // TODO: non-normalisation between dataRowOffset and m_nRowAxes causes problems...
90+
r.headerRow=headerRow;
91+
r.mergeDelimiters=mergeDelimiters;
92+
r.counter=counter;
93+
r.dontFail=dontFail;
94+
r.dimensionCols=dimensionCols;
95+
r.dataCols=dataCols;
96+
for (size_t i=0; i<std::min(dimensions.size(), dimensionNames.size()); ++i)
97+
r.dimensions.emplace_back(dimensionNames[i],dimensions[i]);
98+
return r;
99+
}
100+
86101
/// populates this spec from a "RavelHypercube" entry, \a row is the row being read, used to set the headerRow attribute
87102
/// \a If horizontalName is one of the dimensions, data is written in a tabular format
88103
void populateFromRavelMetadata(const std::string& metadata, const std::string& horizontalName, std::size_t row);
@@ -123,8 +138,6 @@ namespace minsky
123138
/// load a variableValue from a stream according to data spec
124139
void loadValueFromCSVFile(VariableValue&, std::istream& input, const DataSpec&);
125140

126-
/// replace doubled quotes with escaped quotes
127-
void escapeDoubledQuotes(std::string&,const DataSpec&);
128141
}
129142

130143
#include "CSVParser.cd"

0 commit comments

Comments
 (0)