[pypy-commit] pypy ffi-backend: Make the next test pass.
arigo
noreply at buildbot.pypy.org
Fri Jun 22 18:02:53 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: ffi-backend
Changeset: r55756:7bbdfe2ee83b
Date: 2012-06-21 20:22 +0200
http://bitbucket.org/pypy/pypy/changeset/7bbdfe2ee83b/
Log: Make the next test pass.
diff --git a/pypy/module/_ffi_backend/ctypeobj.py b/pypy/module/_ffi_backend/ctypeobj.py
--- a/pypy/module/_ffi_backend/ctypeobj.py
+++ b/pypy/module/_ffi_backend/ctypeobj.py
@@ -63,6 +63,9 @@
W_CType.__init__(self, space, size, name, name_position)
self.ctypeitem = ctypeitem
+ def cast(self, w_ob):
+ xxx
+
def newp(self, w_init):
space = self.space
citem = self.ctypeitem
@@ -76,17 +79,21 @@
class W_CTypePrimitive(W_CType):
+ def cast_single_char(self, w_ob):
+ space = self.space
+ s = space.str_w(w_ob)
+ if len(s) != 1:
+ raise operationerrfmt(space.w_TypeError,
+ "cannot cast string of length %d to ctype '%s'",
+ len(s), self.name)
+ return ord(s[0])
+
def cast(self, w_ob):
space = self.space
if cdataobj.check_cdata(space, w_ob):
xxx
elif space.isinstance_w(w_ob, space.w_str):
- s = space.str_w(w_ob)
- if len(s) != 1:
- raise operationerrfmt(space.w_TypeError,
- "cannot cast string of length %d to ctype '%s'",
- len(s), self.name)
- value = ord(s[0])
+ value = self.cast_single_char(w_ob)
elif space.is_w(w_ob, space.w_None):
value = 0
else:
@@ -153,7 +160,7 @@
if cdataobj.check_cdata(space, w_ob):
xxx
elif space.isinstance_w(w_ob, space.w_str):
- xxx
+ value = self.cast_single_char(w_ob)
elif space.is_w(w_ob, space.w_None):
value = 0.0
else:
More information about the pypy-commit
mailing list