diff options
author | Mark Spruiell <mes@zeroc.com> | 2007-09-20 07:00:46 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2007-09-20 07:00:46 -0700 |
commit | b62cc09379bfb11e95dbba1eace9b8afb0131396 (patch) | |
tree | 840510ebab966a2799d9340c174a258742e20c13 /cpp/src/Slice/PythonUtil.cpp | |
parent | Changed ok! to ok for some of the keyword tests. (diff) | |
download | ice-b62cc09379bfb11e95dbba1eace9b8afb0131396.tar.bz2 ice-b62cc09379bfb11e95dbba1eace9b8afb0131396.tar.xz ice-b62cc09379bfb11e95dbba1eace9b8afb0131396.zip |
changing struct __eq__ to __cmp___; check for None
Diffstat (limited to 'cpp/src/Slice/PythonUtil.cpp')
-rw-r--r-- | cpp/src/Slice/PythonUtil.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp index fdc6449285d..1e730598a94 100644 --- a/cpp/src/Slice/PythonUtil.cpp +++ b/cpp/src/Slice/PythonUtil.cpp @@ -1103,16 +1103,24 @@ Slice::Python::CodeVisitor::visitStructStart(const StructPtr& p) _out << nl << "return _h % 0x7fffffff"; _out.dec(); - _out << sp << nl << "def __eq__(self, other):"; + _out << sp << nl << "def __cmp__(self, other):"; + _out.inc(); + _out << nl << "if other == None:"; _out.inc(); + _out << nl << "return 1"; + _out.dec(); for(r = memberList.begin(); r != memberList.end(); ++r) { - _out << nl << "if not self." << r->fixedName << " == other." << r->fixedName << ':'; + _out << nl << "if self." << r->fixedName << " < other." << r->fixedName << ':'; + _out.inc(); + _out << nl << "return -1"; + _out.dec(); + _out << nl << "elif self." << r->fixedName << " > other." << r->fixedName << ':'; _out.inc(); - _out << nl << "return False"; + _out << nl << "return 1"; _out.dec(); } - _out << nl << "return True"; + _out << nl << "return 0"; _out.dec(); // |