[pypy-commit] pypy struct-double: use the new append_float, and fix translation error

alex_gaynor noreply at buildbot.pypy.org
Sun Mar 4 22:59:36 CET 2012


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: struct-double
Changeset: r53218:0065938b29be
Date: 2012-03-04 16:59 -0500
http://bitbucket.org/pypy/pypy/changeset/0065938b29be/

Log:	use the new append_float, and fix translation error

diff --git a/pypy/rlib/rstruct/ieee.py b/pypy/rlib/rstruct/ieee.py
--- a/pypy/rlib/rstruct/ieee.py
+++ b/pypy/rlib/rstruct/ieee.py
@@ -136,13 +136,13 @@
 
 
 def pack_float(result, x, size, be):
-    l = [] if be else result
+    l = []
     unsigned = float_pack(x, size)
     for i in range(size):
         l.append(chr((unsigned >> (i * 8)) & 0xFF))
     if be:
         l.reverse()
-        result.append("".join(l))
+    result.append("".join(l))
 
 
 def unpack_float(s, be):
diff --git a/pypy/rlib/rstruct/nativefmttable.py b/pypy/rlib/rstruct/nativefmttable.py
--- a/pypy/rlib/rstruct/nativefmttable.py
+++ b/pypy/rlib/rstruct/nativefmttable.py
@@ -27,10 +27,7 @@
 
 def pack_double(fmtiter):
     doubleval = fmtiter.accept_float_arg()
-    double_buf[0] = doubleval
-    p = rffi.cast(rffi.CCHARP, double_buf)
-    for i in range(sizeof_double):
-        fmtiter.result.append(p[i])
+    fmtiter.result.append_float(doubleval)
 
 @specialize.argtype(0)
 def unpack_double(fmtiter):
@@ -44,10 +41,7 @@
 def pack_float(fmtiter):
     doubleval = fmtiter.accept_float_arg()
     floatval = r_singlefloat(doubleval)
-    float_buf[0] = floatval
-    p = rffi.cast(rffi.CCHARP, float_buf)
-    for i in range(sizeof_float):
-        fmtiter.result.append(p[i])
+    fmtiter.result.append_float(floatval)
 
 @specialize.argtype(0)
 def unpack_float(fmtiter):


More information about the pypy-commit mailing list