diff options
author | Michi Henning <michi@zeroc.com> | 2005-03-24 04:30:34 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2005-03-24 04:30:34 +0000 |
commit | 00be99a369f583b1146e07c89425153cfa93a7ab (patch) | |
tree | 7aa4882d47e931a9e32e5614ccf5a61c78c4c5f1 /cpp/src/slice2cppe/Main.cpp | |
parent | Added slice2cppe and slice2javae to "all" target for VC++ and fixed (diff) | |
download | ice-00be99a369f583b1146e07c89425153cfa93a7ab.tar.bz2 ice-00be99a369f583b1146e07c89425153cfa93a7ab.tar.xz ice-00be99a369f583b1146e07c89425153cfa93a7ab.zip |
Added -E option to Slice compilers.
Diffstat (limited to 'cpp/src/slice2cppe/Main.cpp')
-rw-r--r-- | cpp/src/slice2cppe/Main.cpp | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/cpp/src/slice2cppe/Main.cpp b/cpp/src/slice2cppe/Main.cpp index 3dd9e7ec820..7bcebe1b172 100644 --- a/cpp/src/slice2cppe/Main.cpp +++ b/cpp/src/slice2cppe/Main.cpp @@ -28,6 +28,7 @@ usage(const char* n) "-DNAME=DEF Define NAME as DEF.\n" "-UNAME Remove any definition for NAME.\n" "-IDIR Put DIR in the include file search path.\n" + "-E Print preprocessor output on stdout.\n" "--include-dir DIR Use DIR as the header include directory in source files.\n" "--output-dir DIR Create files in the directory DIR.\n" "--dll-export SYMBOL Use SYMBOL for DLL exports.\n" @@ -46,6 +47,7 @@ main(int argc, char* argv[]) { string cppArgs; vector<string> includePaths; + bool preprocess; string include; string output; string dllExport; @@ -65,6 +67,7 @@ main(int argc, char* argv[]) opts.addOpt("D", "", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat); opts.addOpt("U", "", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat); opts.addOpt("I", "", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat); + opts.addOpt("E"); opts.addOpt("", "include-dir", IceUtil::Options::NeedArg); opts.addOpt("", "output-dir", IceUtil::Options::NeedArg); opts.addOpt("", "dll-export", IceUtil::Options::NeedArg); @@ -126,6 +129,7 @@ main(int argc, char* argv[]) cppArgs += " -I" + *i; } } + preprocess = opts.isSet("E"); if(opts.isSet("include-dir")) { include = opts.optArg("include-dir"); @@ -171,33 +175,50 @@ main(int argc, char* argv[]) { return EXIT_FAILURE; } - - UnitPtr u = Unit::createUnit(false, false, ice, caseSensitive); - int parseStatus = u->parse(cppHandle, debug); - - if(!icecpp.close()) + if(preprocess) { - u->destroy(); - return EXIT_FAILURE; - } - - if(parseStatus == EXIT_FAILURE) - { - status = EXIT_FAILURE; + char buf[4096]; + while(fgets(buf, sizeof(buf), cppHandle) != NULL) + { + if(fputs(buf, stdout) == EOF) + { + return EXIT_FAILURE; + } + } + if(!icecpp.close()) + { + return EXIT_FAILURE; + } } else { - Gen gen(argv[0], icecpp.getBaseName(), headerExtension, sourceExtension, include, - includePaths, dllExport, output, impl, checksum, stream); - if(!gen) + UnitPtr u = Unit::createUnit(false, false, ice, caseSensitive); + int parseStatus = u->parse(cppHandle, debug); + + if(!icecpp.close()) { u->destroy(); return EXIT_FAILURE; } - gen.generate(u); - } - u->destroy(); + if(parseStatus == EXIT_FAILURE) + { + status = EXIT_FAILURE; + } + else + { + Gen gen(argv[0], icecpp.getBaseName(), headerExtension, sourceExtension, include, + includePaths, dllExport, output, impl, checksum, stream); + if(!gen) + { + u->destroy(); + return EXIT_FAILURE; + } + gen.generate(u); + } + + u->destroy(); + } } } |