7 #include "create_wrapper.h"
12 CompilationUnit* unit = 0;
13 std::istream* input = 0;
14 std::string inputfile;
15 std::string modulename = "wrapper";
19 std::cout << "Usage: miniswig --input FILE --output-cpp FILE --output-hpp FILE [--module NAME]\n";
23 int main(int argc, char** argv)
25 std::string outputcpp;
26 std::string outputhpp;
27 for(int i = 0; i < argc; ++i) {
28 if(strcmp(argv[i], "--module") == 0) {
30 std::cerr << "Need to specify a module name.\n";
34 modulename = argv[++i];
35 } else if(strcmp(argv[i], "--input") == 0) {
37 std::cerr << "Need to specify input file name.\n";
41 inputfile = argv[++i];
42 } else if(strcmp(argv[i], "--output-cpp") == 0) {
44 std::cerr << "Need to specifiy output cpp name.\n";
48 outputcpp = argv[++i];
49 } else if(strcmp(argv[i], "--output-hpp") == 0) {
51 std::cerr << "Need to specify output hpp name.\n";
55 outputhpp = argv[++i];
56 } else if(argv[i][0] == '-') {
57 std::cerr << "Unknown option '" << argv[i] << "'.\n";
63 if(inputfile == "" || outputcpp == "" || outputhpp == "") {
64 std::cerr << "Not all options specified.\n";
70 input = new std::ifstream(inputfile.c_str());
72 std::cerr << "Couldn't open file '" << input << "' for reading.\n";
75 unit = new CompilationUnit();
76 unit->types.push_back(new StringType());
77 Namespace* std_namespace = new Namespace();
78 std_namespace->name = "std";
79 unit->namespaces.push_back(std_namespace);
81 std::ofstream cppout(outputcpp.c_str());
83 std::cerr << "Couldn't open file '" << outputcpp << "' for writing.\n";
86 std::ofstream hppout(outputhpp.c_str());
88 std::cerr << "Couldn't open file '" << outputhpp << "' for writing.\n";
91 WrapperCreator creator(cppout, hppout);
92 creator.create_wrapper(unit);
93 } catch(std::exception& e) {
94 std::cerr << e.what() << "\n";