Minsky
typescriptAPI.cc File Reference
#include "function.h"
#include "typescriptAPI_base.h"
#include "minsky.h"
#include "minsky.tcd"
#include "assetClass.tcd"
#include "bookmark.h"
#include "bookmark.tcd"
#include "cairoSurfaceImage.tcd"
#include "callableFunction.tcd"
#include "canvas.tcd"
#include "CSVDialog.tcd"
#include "CSVParser.tcd"
#include "constMap.tcd"
#include "dataSpecSchema.tcd"
#include "dataOp.h"
#include "dataOp.tcd"
#include "dimension.tcd"
#include "engNotation.tcd"
#include "equationDisplay.tcd"
#include "evalGodley.tcd"
#include "eventInterface.tcd"
#include "fontDisplay.tcd"
#include "godleyIcon.tcd"
#include "godleyTable.tcd"
#include "godleyTableWindow.tcd"
#include "grid.tcd"
#include "group.tcd"
#include "handleLockInfo.tcd"
#include "hypercube.tcd"
#include "index.tcd"
#include "intOp.tcd"
#include "item.tcd"
#include "itemT.tcd"
#include "lasso.tcd"
#include "lock.tcd"
#include "noteBase.tcd"
#include "operation.tcd"
#include "operationBase.tcd"
#include "operationType.tcd"
#include "pango.tcd"
#include "pannableTab.tcd"
#include "phillipsDiagram.tcd"
#include "plot.tcd"
#include "plotOptions.tcd"
#include "plotWidget.tcd"
#include "polyRESTProcessBase.tcd"
#include "port.h"
#include "port.tcd"
#include "publication.tcd"
#include "pubTab.tcd"
#include "ravelState.tcd"
#include "renderNativeWindow.tcd"
#include "ravelWrap.tcd"
#include "rungeKutta.tcd"
#include "selection.tcd"
#include "sheet.tcd"
#include "simulation.tcd"
#include "slider.tcd"
#include "SVGItem.tcd"
#include "switchIcon.tcd"
#include "tensorInterface.tcd"
#include "tensorVal.tcd"
#include "units.tcd"
#include "userFunction.h"
#include "userFunction.tcd"
#include "variableInstanceList.h"
#include "variableInstanceList.tcd"
#include "variable.tcd"
#include "variablePane.tcd"
#include "variableType.tcd"
#include "variableValue.tcd"
#include "variableValues.tcd"
#include "wire.tcd"
#include "xvector.tcd"
#include "minsky_epilogue.h"

Go to the source code of this file.

Classes

struct  classdesc_access::access_typescriptAPI< classdesc::Exclude< T > >
 
struct  classdesc_access::access_typescriptAPI< ecolab::TCLAccessor< T, V, N > >
 
struct  classdesc_access::access_typescriptAPI< classdesc::PolyPackBase >
 
struct  classdesc_access::access_typescriptAPI< classdesc::PolyPack< T > >
 
struct  classdesc_access::access_typescriptAPI< std::vector< civita::any > >
 
struct  classdesc_access::access_typescriptAPI< minsky::Optional< T > >
 
struct  classdesc::tn< civita::any >
 
struct  classdesc::tn< boost::geometry::model::d2::point_xy< T > >
 
struct  classdesc::tn< RESTProcess_t >
 
struct  classdesc::tn< std::chrono::time_point< C, D > >
 
struct  classdesc::tn< std::istream >
 
struct  classdesc::tn< minsky::PannableTab< minsky::EquationDisplay > >
 

Namespaces

 classdesc_access
 
 classdesc
 
 minsky
 Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky's state changes.
 

Functions

template<>
string classdesc::typeName< cairo_t > ()
 
template<>
string classdesc::typeName< cairo_surface_t > ()
 
template<class T , class Base >
enable_if< Not< is_map< Base > >, void >::T classdesc::typescriptAPI (typescriptAPI_t &t, const string &d)
 
Minsky & minsky::minsky ()
 global minsky object More...
 
void minsky::doOneEvent (bool idleTasksOnly)
 checks if any GUI events are waiting, and proces an event if so More...
 
void exportClass (const std::string &name, const minsky::typescriptAPI_ns::ClassType &klass)
 
int main ()
 

Function Documentation

◆ exportClass()

void exportClass ( const std::string &  name,
const minsky::typescriptAPI_ns::ClassType &  klass 
)

Definition at line 186 of file typescriptAPI.cc.

Referenced by main().

187 {
188  cout << "export class "+name+" extends "+(klass.super.empty()? "CppClass": klass.super)+" {\n";
189 
190  // properties
191  for (auto& prop: klass.properties)
192  cout << " "<<prop.first <<": "<<prop.second.type<<";\n";
193 
194  // constructor
195  if (!klass.super.empty())
196  {
197  cout << " constructor(prefix: string|"<<klass.super<<"){\n";
198  cout << " if (typeof prefix==='string')\n";
199  cout << " super(prefix";
200  if (!klass.valueType.empty())
201  cout <<","<<klass.valueType;
202  cout << ")\n";
203  cout << " else\n";
204  cout << " super(prefix.$prefix()";
205  if (!klass.valueType.empty())
206  cout <<","<<klass.valueType;
207  cout <<")\n";
208  }
209  else
210  {
211  cout << " constructor(prefix: string){\n";
212  cout << " super(prefix);\n";
213  }
214  for (auto& prop: klass.properties)
215  {
216  if (!prop.second.construction.empty())
217  cout << " this."<<prop.first<<"="<<prop.second.construction<<"\n";
218  else
219  cout << " this."<<prop.first<<"=new "<<prop.second.type<<"(this.$prefix()+'."<<prop.first<<"');\n";
220  }
221  cout << " }\n";
222 
223  // methods
224  for (auto& method: klass.methods)
225  {
226  cout << " async "<<method.first<<"(";
227  for (size_t i=0; i<method.second.args.size(); ++i)
228  {
229  if (i>0) cout<<",";
230  cout<<method.second.args[i].name<<": "<<method.second.args[i].type;
231  }
232  cout << "): Promise<"<<method.second.returnType<<"> {return this.$callMethod('"<<method.first<<"'";
233  for (auto& arg: method.second.args)
234  cout<<","<<arg.name;
235  cout<<");}\n";
236  }
237  cout << "}\n\n";
238 }
Here is the caller graph for this function:

◆ main()

int main ( )

Definition at line 240 of file typescriptAPI.cc.

References classdesc::typescriptAPI_t::addClass(), classdesc::typescriptAPI_t::addSubclass(), and exportClass().

241 {
242  typescriptAPI_t api;
243  api.addClass<Minsky>();
244 
245  // supporting types
246  api.addClass<Bookmark>();
247  api.addClass<Canvas::ZoomCrop>();
248  api.addClass<civita::Dimension>();
249  api.addClass<civita::Hypercube>();
250  api.addClass<civita::Index>();
251  api.addClass<civita::ITensor>();
252  api.addClass<civita::XVector>();
253  api.addClass<DataSpecSchema>();
254  api.addClass<ecolab::Plot::LineStyle>();
255  api.addClass<EngNotation>();
256  api.addClass<EventInterface>();
257  api.addClass<GroupItems>();
258  api.addClass<HandleLockInfo>();
259  api.addClass<Port>();
260  api.addClass<PubItem>();
261  api.addClass<ravel::HandleState>();
262  api.addClass<ravel::RavelState>();
263  api.addClass<Units>();
264  api.addClass<VariablePaneCell>();
265  api.addClass<VariableValue>();
266  api.addClass<VariableValues>();
267  api["VariableValues"].valueType="VariableValue";
268 
269  // Item subclasses
270  api.addSubclass<DataOp,Item>();
271  api.addSubclass<Group,Item>();
272  api.addSubclass<GodleyIcon,Item>();
273  api.addSubclass<IntOp,Item>();
274  api.addSubclass<Lock,Item>();
278  api.addSubclass<PlotWidget,Item>();
279  api.addSubclass<Ravel,Item>();
280  api.addSubclass<Sheet,Item>();
281  api.addSubclass<SwitchIcon,Item>();
284 
285  // RenderNativeWindow subclasses
291 
292 
293  // to prevent Group recursively calling itself on construction
294  api["Group"].properties.erase("parent");
295 
296  cout << "/*\nThis is a built file, please do not edit.\n";
297  cout << "See RESTService/typescriptAPI for more information.\n*/\n\n";
298  cout << "import {CppClass, Sequence, Container, Map, Pair} from './backend';\n\n";
299 
300  // dummy types
301  cout << "class minsky__dummy {}\n";
302  cout << "class minsky__EventInterface__KeyPressArgs {}\n";
303  cout << "class minsky__GodleyIcon__MoveCellArgs {}\n";
304  cout << "class minsky__RenderNativeWindow__RenderFrameArgs {}\n";
305  cout << "class minsky__VariableType__TypeT {}\n";
306  cout << "class civita__ITensor__Args {}\n";
307  cout << "class classdesc__json_pack_t {}\n";
308  cout << "class classdesc__pack_t {}\n";
309  cout << "class classdesc__RESTProcess_t {}\n";
310  cout << "class classdesc__TCL_obj_t {}\n";
311  cout << "class ecolab__cairo__Surface {}\n";
312  cout<<endl;
313 
314  // these need to be declared in a specific order
315  vector<string> exportFirst{"EventInterface","Item","OperationBase","RenderNativeWindow","VariableBase"};
316  for (auto& i: exportFirst) exportClass(i,api[i]);
317 
318  cout << "class minsky__Variable<T> extends VariableBase {}\n";
319 
320  // then export the rest
321  for (auto& i: api)
322  if (find(exportFirst.begin(), exportFirst.end(), i.first)==exportFirst.end())
323  exportClass(i.first, i.second);
324 
325  cout << "export var minsky=new Minsky('minsky');\n";
326 }
Mixin implementing common panning functionality in tabs.
Definition: pannableTab.h:36
represents the units (in sense of dimensional analysis) of a variable.
Definition: units.h:34
void exportClass(const std::string &name, const minsky::typescriptAPI_ns::ClassType &klass)
legacy data importer object
Definition: dataOp.h:28
a container item for a plot widget
Definition: plotWidget.h:46
Here is the call graph for this function: