diff options
author | Mark Spruiell <mes@zeroc.com> | 2012-10-17 12:38:03 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2012-10-17 12:38:03 -0700 |
commit | f087326373250c76fa3b7b8e68cede0cb9af01ff (patch) | |
tree | e801ec18aba93a74b373388fc947617643da0008 /py/python/Ice.py | |
parent | Fix related to ICE-4847 (diff) | |
download | ice-f087326373250c76fa3b7b8e68cede0cb9af01ff.tar.bz2 ice-f087326373250c76fa3b7b8e68cede0cb9af01ff.tar.xz ice-f087326373250c76fa3b7b8e68cede0cb9af01ff.zip |
ICE-4619 - custom enumerator values
Diffstat (limited to 'py/python/Ice.py')
-rw-r--r-- | py/python/Ice.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/py/python/Ice.py b/py/python/Ice.py index 5790c64cd8a..e371ffe15fa 100644 --- a/py/python/Ice.py +++ b/py/python/Ice.py @@ -189,6 +189,70 @@ class UserException(Exception): '''The base class for all user-defined exceptions.''' pass +class EnumBase(object): + def __init__(self, _n, _v): + self._name = _n + self._value = _v + + def __str__(self): + return self._name + + __repr__ = __str__ + + def __hash__(self): + return self._value + + def __lt__(self, other): + if isinstance(other, self.__class__): + return self._value < other._value; + elif other == None: + return False + return NotImplemented + + def __le__(self, other): + if isinstance(other, self.__class__): + return self._value <= other._value; + elif other == None: + return False + return NotImplemented + + def __eq__(self, other): + if isinstance(other, self.__class__): + return self._value == other._value; + elif other == None: + return False + return NotImplemented + + def __ne__(self, other): + if isinstance(other, self.__class__): + return self._value != other._value; + elif other == None: + return False + return NotImplemented + + def __gt__(self, other): + if isinstance(other, self.__class__): + return self._value > other._value; + elif other == None: + return False + return NotImplemented + + def __ge__(self, other): + if isinstance(other, self.__class__): + return self._value >= other._value; + elif other == None: + return False + return NotImplemented + + def _getName(self): + return self._name + + def _getValue(self): + return self._value + + name = property(_getName) + value = property(_getValue) + class SlicedData(object): # # Members: |