diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/include/Slice/Parser.h | 2 | ||||
-rw-r--r-- | cpp/src/Slice/Parser.cpp | 13 | ||||
-rw-r--r-- | cpp/src/slice2docbook/Gen.cpp | 8 | ||||
-rw-r--r-- | cpp/src/slice2docbook/Gen.h | 3 | ||||
-rw-r--r-- | cpp/src/slice2docbook/Main.cpp | 6 |
5 files changed, 24 insertions, 8 deletions
diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h index fa7ca402ea9..c80b67892a2 100644 --- a/cpp/include/Slice/Parser.h +++ b/cpp/include/Slice/Parser.h @@ -423,7 +423,7 @@ public: std::string thisScope() const; void mergeModules(); void sort(); - void sortContents(); + void sortContents(bool); virtual void visit(ParserVisitor*, bool); void containerRecDependencies(std::set<ConstructedPtr>&); // Internal operation, don't use directly. diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 3f49a5d84a3..c36bbd38cee 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -1756,13 +1756,22 @@ Slice::Container::sort() } void -Slice::Container::sortContents() +Slice::Container::sortContents(bool sortFields) { for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { ContainerPtr container = ContainerPtr::dynamicCast(*p); if(container) { + if(!sortFields) + { + if(StructPtr::dynamicCast(container) || + ClassDefPtr::dynamicCast(container) || + ExceptionPtr::dynamicCast(container)) + { + continue; + } + } // // Don't sort operation definitions, otherwise parameters are shown in the // wrong order in the synopsis. @@ -1771,7 +1780,7 @@ Slice::Container::sortContents() { container->sort(); } - container->sortContents(); + container->sortContents(sortFields); } } } diff --git a/cpp/src/slice2docbook/Gen.cpp b/cpp/src/slice2docbook/Gen.cpp index b0719df9abc..66c3c9c6a40 100644 --- a/cpp/src/slice2docbook/Gen.cpp +++ b/cpp/src/slice2docbook/Gen.cpp @@ -15,10 +15,12 @@ using namespace std; using namespace Slice; using namespace IceUtil; -Slice::Gen::Gen(const string& name, const string& file, bool standAlone, bool noGlobals, bool chapter, bool noIndex) : +Slice::Gen::Gen(const string& name, const string& file, bool standAlone, bool noGlobals, bool chapter, + bool noIndex, bool sortFields) : _standAlone(standAlone), _noGlobals(noGlobals), - _noIndex(noIndex) + _noIndex(noIndex), + _sortFields(sortFields) { if(chapter) { @@ -57,7 +59,7 @@ Slice::Gen::generate(const UnitPtr& p) // I don't want the top-level module to be sorted, therefore no // p->sort() before or after the p->sortContents(). // - p->sortContents(); + p->sortContents(_sortFields); p->visit(this, false); } diff --git a/cpp/src/slice2docbook/Gen.h b/cpp/src/slice2docbook/Gen.h index 10ddf105deb..26718c07cc8 100644 --- a/cpp/src/slice2docbook/Gen.h +++ b/cpp/src/slice2docbook/Gen.h @@ -21,7 +21,7 @@ class Gen : private ::IceUtil::noncopyable, public ParserVisitor { public: - Gen(const std::string&, const std::string&, bool, bool, bool, bool); + Gen(const std::string&, const std::string&, bool, bool, bool, bool, bool); virtual ~Gen(); bool operator!() const; // Returns true if there was a constructor error @@ -61,6 +61,7 @@ private: bool _noGlobals; std::string _chapter; bool _noIndex; + bool _sortFields; }; } diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp index e34aaa956b3..898812f0379 100644 --- a/cpp/src/slice2docbook/Main.cpp +++ b/cpp/src/slice2docbook/Main.cpp @@ -33,6 +33,7 @@ usage(const char* n) "--chapter Use \"chapter\" instead of \"section\" as\n" " top-level element.\n" "--noindex Suppress generation of index pages.\n" + "--sort-fields Sort fields of structures, classes, and exceptions.\n" "-d, --debug Print debug messages.\n" "--ice Permit `Ice' prefix (for building Ice source code only)\n" ; @@ -51,6 +52,7 @@ main(int argc, char* argv[]) bool debug; bool ice; bool caseSensitive; + bool sortFields; IceUtil::Options opts; opts.addOpt("h", "help"); @@ -63,6 +65,7 @@ main(int argc, char* argv[]) opts.addOpt("", "no-globals"); opts.addOpt("", "chapter"); opts.addOpt("", "noindex"); + opts.addOpt("", "sort-fields"); opts.addOpt("d", "debug"); opts.addOpt("", "ice"); opts.addOpt("", "case-sensitive"); @@ -118,6 +121,7 @@ main(int argc, char* argv[]) noGlobals = opts.isSet("no-globals"); chapter = opts.isSet("chapter"); noIndex = opts.isSet("noindex"); + sortFields = opts.isSet("sort-fields"); debug = opts.isSet("d") || opts.isSet("debug"); ice = opts.isSet("ice"); caseSensitive = opts.isSet("case-sensitive"); @@ -190,7 +194,7 @@ main(int argc, char* argv[]) if(status == EXIT_SUCCESS && !preprocess) { - Gen gen(argv[0], docbook, standAlone, noGlobals, chapter, noIndex); + Gen gen(argv[0], docbook, standAlone, noGlobals, chapter, noIndex, sortFields); if(!gen) { p->destroy(); |