From: <le...@us...> - 2008-07-15 16:24:46
|
Revision: 4940 http://jython.svn.sourceforge.net/jython/?rev=4940&view=rev Author: leosoto Date: 2008-07-15 09:24:18 -0700 (Tue, 15 Jul 2008) Log Message: ----------- Implemented decimal.Decimal.__tojava__ to convert decimal instances to java BigDecimal when python -> java conversion is requested Modified Paths: -------------- branches/asm/Lib/decimal.py Modified: branches/asm/Lib/decimal.py =================================================================== --- branches/asm/Lib/decimal.py 2008-07-15 16:13:50 UTC (rev 4939) +++ branches/asm/Lib/decimal.py 2008-07-15 16:24:18 UTC (rev 4940) @@ -3330,6 +3330,15 @@ return self # My components are also immutable return self.__class__(str(self)) + # support for Jython __tojava__: + def __tojava__(self, java_class): + from java.lang import Object + from java.math import BigDecimal + from org.python.core import Py + if java_class not in (BigDecimal, Object): + return Py.NoConversion + return BigDecimal(str(self)) + def _dec_from_triple(sign, coefficient, exponent, special=False): """Create a decimal instance directly, without any validation, normalization (e.g. removal of leading zeros) or argument This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |