From: <pj...@us...> - 2008-07-23 20:55:05
|
Revision: 4992 http://jython.svn.sourceforge.net/jython/?rev=4992&view=rev Author: pjenvey Date: 2008-07-23 20:55:03 +0000 (Wed, 23 Jul 2008) Log Message: ----------- support the new float.__get/setformat__ classmethods -- they just claim our formats are 'unknown' Modified Paths: -------------- branches/asm/src/org/python/core/PyFloat.java Modified: branches/asm/src/org/python/core/PyFloat.java =================================================================== --- branches/asm/src/org/python/core/PyFloat.java 2008-07-23 20:36:42 UTC (rev 4991) +++ branches/asm/src/org/python/core/PyFloat.java 2008-07-23 20:55:03 UTC (rev 4992) @@ -4,6 +4,7 @@ import java.io.Serializable; import java.math.BigDecimal; +import org.python.expose.ExposedClassMethod; import org.python.expose.ExposedMethod; import org.python.expose.ExposedNew; import org.python.expose.ExposedType; @@ -579,6 +580,28 @@ return float___getnewargs__(); } + @ExposedClassMethod + public static String float___getformat__(PyType type, String typestr) { + if (!"double".equals(typestr) && !"float".equals(typestr)) { + throw Py.ValueError("__getformat__() argument 1 must be 'double' or 'float'"); + } + return "unknown"; + } + + @ExposedClassMethod + public static void float___setformat__(PyType type, String typestr, String format) { + if (!"double".equals(typestr) && !"float".equals(typestr)) { + throw Py.ValueError("__setformat__() argument 1 must be 'double' or 'float'"); + } + if ("IEEE, little-endian".equals(format) || "IEEE, big-endian".equals(format)) { + throw Py.ValueError(String.format("can only set %s format to 'unknown' or the " + + "detected platform value", typestr)); + } else if (!"unknown".equals(format)) { + throw Py.ValueError("__setformat__() argument 2 must be 'unknown', " + + "'IEEE, little-endian' or 'IEEE, big-endian'"); + } + } + public boolean isMappingType() { return false; } public boolean isSequenceType() { return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |