Skip to content

Commit

Permalink
Update schema generation to output schema for all levels, and for make
Browse files Browse the repository at this point in the history
minsky.xsd to output level 2 schema.
  • Loading branch information
highperformancecoder committed Nov 2, 2017
1 parent 7252621 commit fc37466
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -206,7 +206,7 @@ mac-dist: gui-tk/minsky
sh -v mkMacDist.sh

minsky.xsd: gui-tk/minsky
gui-tk/minsky exportSchema.tcl
gui-tk/minsky exportSchema.tcl 2

upload-schema: minsky.xsd
scp minsky.xsd $(SF_WEB)
Expand Down
2 changes: 1 addition & 1 deletion exportSchema.tcl
@@ -1,3 +1,3 @@
#!minsky
minsky.exportSchema minsky.xsd
minsky.exportSchema minsky.xsd $argv(2)
tcl_exit
6 changes: 0 additions & 6 deletions gui-tk/minskyTCL.h
Expand Up @@ -246,12 +246,6 @@ namespace minsky
rebuildTCLcommands=true;
}

void exportSchema(TCL_args args) {
const char* filename=args;
int schemaLevel=1;
if (args.count) schemaLevel=args;
Minsky::exportSchema(filename, schemaLevel);
}
void latex(const char* filename, bool wrapLaTeXLines);

void matlab(const char* filename) {
Expand Down
13 changes: 12 additions & 1 deletion model/minsky.cc
Expand Up @@ -807,7 +807,18 @@ namespace minsky
{
xsd_generate_t x;
// currently, there is only 1 schema level, so ignore second arg
xsd_generate(x,"Minsky",schema1::Minsky());
switch (schemaLevel)
{
case 0:
xsd_generate(x,"Minsky",schema0::Minsky());
break;
case 1:
xsd_generate(x,"Minsky",schema1::Minsky());
break;
case 2:
xsd_generate(x,"Minsky",schema2::Minsky());
break;
}
ofstream f(filename);
x.output(f,schemaURL);
}
Expand Down
18 changes: 18 additions & 0 deletions schema/schema2.h
Expand Up @@ -275,6 +275,19 @@ namespace schema2

namespace classdesc
{

#ifdef _CLASSDESC
#pragma omit xsd_generate schema2::Optional
#pragma omit xml_pack schema2::Optional
#endif

template <class T>
void xsd_generate(xsd_generate_t& g, const string& d, const schema2::Optional<T>& a)
{
xsd_generate_t::Optional o(g,true);
xsd_generate(g,d,*a);
}

template <class T> void xpack(xml_pack_t& t,const string& d,T& a)
{if (a) ::xml_pack(t,d,*a);}

Expand All @@ -297,6 +310,11 @@ namespace classdesc
std::shared_ptr<ecolab::Plot::Side>& a) {xpack(t,d,a);}
}

//template <class T>
//void xml_pack(classdesc::xml_pack_t& t, const classdesc::string& d, const schema2::Optional<T>& a)
//{if (a) ::xml_pack(t,d,*a);}

using classdesc::xsd_generate;
using classdesc::xml_pack;

#include "schema2.cd"
Expand Down

0 comments on commit fc37466

Please sign in to comment.