[pypy-commit] pypy default: Forgot to import the app-level parts of cffi/1d4ca4f4914a
arigo
noreply at buildbot.pypy.org
Thu Jun 20 08:36:32 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r64946:ce2b1ea66d55
Date: 2013-06-20 08:35 +0200
http://bitbucket.org/pypy/pypy/changeset/ce2b1ea66d55/
Log: Forgot to import the app-level parts of cffi/1d4ca4f4914a
diff --git a/lib_pypy/cffi/backend_ctypes.py b/lib_pypy/cffi/backend_ctypes.py
--- a/lib_pypy/cffi/backend_ctypes.py
+++ b/lib_pypy/cffi/backend_ctypes.py
@@ -707,7 +707,7 @@
class CTypesStructOrUnion(CTypesBaseStructOrUnion):
__slots__ = ['_blob']
_ctype = struct_or_union
- _reftypename = '%s %s &' % (kind, name)
+ _reftypename = '%s &' % (name,)
_kind = kind
#
CTypesStructOrUnion._fix_class()
@@ -934,7 +934,7 @@
#
class CTypesEnum(CTypesInt):
__slots__ = []
- _reftypename = 'enum %s &' % name
+ _reftypename = '%s &' % name
def _get_own_repr(self):
value = self._value
diff --git a/lib_pypy/cffi/model.py b/lib_pypy/cffi/model.py
--- a/lib_pypy/cffi/model.py
+++ b/lib_pypy/cffi/model.py
@@ -244,6 +244,10 @@
self.forcename = forcename
self.build_c_name_with_marker()
+ def get_official_name(self):
+ assert self.c_name_with_marker.endswith('&')
+ return self.c_name_with_marker[:-1]
+
class StructOrUnion(StructOrUnionOrEnum):
fixedlayout = None
@@ -357,7 +361,9 @@
def build_backend_type(self, ffi, finishlist):
self.check_not_partial()
finishlist.append(self)
- return global_cache(self, ffi, 'new_struct_type', self.name, key=self)
+
+ return global_cache(self, ffi, 'new_struct_type',
+ self.get_official_name(), key=self)
class UnionType(StructOrUnion):
@@ -365,7 +371,8 @@
def build_backend_type(self, ffi, finishlist):
finishlist.append(self)
- return global_cache(self, ffi, 'new_union_type', self.name, key=self)
+ return global_cache(self, ffi, 'new_union_type',
+ self.get_official_name(), key=self)
class EnumType(StructOrUnionOrEnum):
@@ -388,7 +395,8 @@
def build_backend_type(self, ffi, finishlist):
self.check_not_partial()
base_btype = self.build_baseinttype(ffi, finishlist)
- return global_cache(self, ffi, 'new_enum_type', self.name,
+ return global_cache(self, ffi, 'new_enum_type',
+ self.get_official_name(),
self.enumerators, self.enumvalues,
base_btype, key=self)
diff --git a/pypy/module/test_lib_pypy/cffi_tests/backend_tests.py b/pypy/module/test_lib_pypy/cffi_tests/backend_tests.py
--- a/pypy/module/test_lib_pypy/cffi_tests/backend_tests.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/backend_tests.py
@@ -990,7 +990,7 @@
assert f.a == 12345
assert b.b == b"B"
assert b.c == b"C"
- assert repr(b).startswith("<cdata 'struct $bar_t *'")
+ assert repr(b).startswith("<cdata 'bar_t *'")
def test_struct_with_two_usages(self):
for name in ['foo_s', '']: # anonymous or not
@@ -1300,9 +1300,9 @@
ffi = FFI(backend=self.Backend())
ffi.cdef("typedef enum { Value0 = 0 } e, *pe;\n"
"typedef enum { Value1 = 1 } e1;")
- assert ffi.getctype("e*") == 'enum $e *'
- assert ffi.getctype("pe") == 'enum $e *'
- assert ffi.getctype("e1*") == 'enum $e1 *'
+ assert ffi.getctype("e*") == 'e *'
+ assert ffi.getctype("pe") == 'e *'
+ assert ffi.getctype("e1*") == 'e1 *'
def test_new_ctype(self):
ffi = FFI(backend=self.Backend())
diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_ffi_backend.py b/pypy/module/test_lib_pypy/cffi_tests/test_ffi_backend.py
--- a/pypy/module/test_lib_pypy/cffi_tests/test_ffi_backend.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/test_ffi_backend.py
@@ -179,3 +179,9 @@
'ffi.cdef("struct s2 { char x:0; };"); ffi.new("struct s2 *")')
py.test.raises(TypeError,
'ffi.cdef("struct s3 { char x:9; };"); ffi.new("struct s3 *")')
+
+ def test_struct_with_typedef(self):
+ ffi = FFI()
+ ffi.cdef("typedef struct { float x; } foo_t;")
+ p = ffi.new("foo_t *", [5.2])
+ assert repr(p).startswith("<cdata 'foo_t *' ")
diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_verify.py b/pypy/module/test_lib_pypy/cffi_tests/test_verify.py
--- a/pypy/module/test_lib_pypy/cffi_tests/test_verify.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/test_verify.py
@@ -1442,7 +1442,7 @@
"foo_t myfunc(void) { foo_t x = { 42 }; return x; }")
assert str(e.value) in [
"function myfunc: 'foo_t' is used as result type, but is opaque",
- "function myfunc: result type 'struct $foo_t' is opaque"]
+ "function myfunc: result type 'foo_t' is opaque"]
def test_include():
ffi1 = FFI()
More information about the pypy-commit
mailing list