diff options
author | Matthew Newhook <matthew@zeroc.com> | 2002-01-25 16:56:52 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2002-01-25 16:56:52 +0000 |
commit | ccb36bbe1463c2b4760f793ec5611b24caa6c09f (patch) | |
tree | 0fb6ecc7d0ba90c6b82606b46b3621f5fbcd238a /cpp/src/slice2wsdl/Main.cpp | |
parent | Changed Gen.cpp to fix a minor bug that prevented compiling in VC++. Added (diff) | |
download | ice-ccb36bbe1463c2b4760f793ec5611b24caa6c09f.tar.bz2 ice-ccb36bbe1463c2b4760f793ec5611b24caa6c09f.tar.xz ice-ccb36bbe1463c2b4760f793ec5611b24caa6c09f.zip |
Use visitor pattern. Add ability to generate WSDL definitions for all types
in a file.
Diffstat (limited to 'cpp/src/slice2wsdl/Main.cpp')
-rw-r--r-- | cpp/src/slice2wsdl/Main.cpp | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/cpp/src/slice2wsdl/Main.cpp b/cpp/src/slice2wsdl/Main.cpp index 2efe434b590..e1d77cb24f6 100644 --- a/cpp/src/slice2wsdl/Main.cpp +++ b/cpp/src/slice2wsdl/Main.cpp @@ -17,7 +17,7 @@ using namespace Slice; void usage(const char* n) { - cerr << "Usage: " << n << " [options] slice-file type-id\n"; + cerr << "Usage: " << n << " [options] slice-file [type-id ...]\n"; cerr << "Options:\n" "-h, --help Show this message.\n" @@ -133,14 +133,13 @@ main(int argc, char* argv[]) } } - if (argc != 3) + if (argc < 2) { usage(argv[0]); return EXIT_FAILURE; } string sourceFile = argv[1]; - string typeId = argv[2]; int status = EXIT_SUCCESS; @@ -196,23 +195,30 @@ main(int argc, char* argv[]) } else { - ContainedList contained = unit->findContents(typeId); - if (contained.empty() || contained.front()->containedType() != Contained::ContainedTypeClass) + Gen gen(argv[0], base, include, includePaths, output); + + if (argc > 2) { - cerr << argv[0] << ": invalid type: " << typeId << endl; - status = EXIT_FAILURE; + for (idx = 2 ; idx < argc; ++idx) + { + ClassDeclPtr classDecl; + TypeList classTypes = unit->lookupType(argv[idx], false); + if (!classTypes.empty()) + { + classDecl = ClassDeclPtr::dynamicCast(classTypes.front()); + } + if (!classDecl) + { + cerr << argv[0] << ": invalid type: " << argv[idx] << endl; + status = EXIT_FAILURE; + break; + } + gen.visitClassDefStart(classDecl->definition()); + } } else { - ClassDefPtr p = ClassDefPtr::dynamicCast(contained.front()); - assert(p); - Gen gen(argv[0], base, include, includePaths, output, p); - if (!gen) - { - unit->destroy(); - return EXIT_FAILURE; - } - gen.generate(unit); + unit->visit(&gen); } } |