=========================================================================*/
+#include <stdio.h>
+
#include "bbtkInterpreter.h"
+#include "bbtkInterpreterPy.h"
#include "bbtkUtilities.h"
int main(int argc, char* argv[])
{
- if (argc<2) return 1;
-
- std::string file,path;
- file = bbtk::Utilities::ExtractScriptName(argv[1],path);
- file += ".h";
- bbtk::Interpreter::Pointer I = bbtk::Interpreter::New(file);
-
- I->SetThrow(true);
-
- try
+ if (argc<3)
{
- I->InterpretFile(argv[1]);
- }
- catch (bbtk::Exception e)
- {
- e.Print();
+ printf("bbs2 <filename.bbs> <cxx|py>\n");
+ return 1;
}
+ std::string file,path;
+ std::string extention( argv[2] );
+ file = bbtk::Utilities::ExtractScriptName(argv[1],path);
+ file += std::string(".")+extention;
+ if ( extention.compare("cxx")==0)
+ {
+ printf("bbs -> cxx\n");
+ bbtk::Interpreter::Pointer I = bbtk::Interpreter::New(file);
+ I->SetThrow(true);
+ try
+ {
+ I->InterpretFile(argv[1]);
+ } catch (bbtk::Exception e) {
+ e.Print();
+ } // try
+ } // if cxx
+
+ if ( extention.compare("py")==0)
+ {
+ printf("bbs -> py\n");
+ bbtk::InterpreterPy::Pointer I = bbtk::InterpreterPy::New();
+ I->SetThrow(true);
+ try
+ {
+ I->InterpretFile(argv[1]);
+ std::vector<std::string> pythonBBTK= ((bbtk::InterpreterPy*)(I.get()))->pythonBBTK ;
+ FILE *ff=fopen(file.c_str(),"w+");
+ fprintf(ff,"from bbtk.bbtkBlackBox import *\n" );
+ fprintf(ff,"class appliTest02:\n" );
+ fprintf(ff," def Run(self):\n" );
+ fprintf(ff," mCB = ComplexBlackBox('appliTest02')\n");
+ int i,size=pythonBBTK.size();
+ for (i=0; i<size;i++)
+ {
+ fprintf(ff," mCB.%s\n", pythonBBTK[i].c_str() );
+ }// for i
+ fprintf(ff," mCB.Execute()\n" );
+ fclose(ff);
+ } catch (bbtk::Exception e) {
+ e.Print();
+ } // try
+ } // py
+
return 0;
}