Commits

Armin Rigo committed ce2b1ea

Forgot to import the app-level parts of cffi/1d4ca4f4914a

Comments (0)

Files changed (5)

lib_pypy/cffi/backend_ctypes.py

         class CTypesStructOrUnion(CTypesBaseStructOrUnion):
             __slots__ = ['_blob']
             _ctype = struct_or_union
-            _reftypename = '%s %s &' % (kind, name)
+            _reftypename = '%s &' % (name,)
             _kind = kind
         #
         CTypesStructOrUnion._fix_class()
         #
         class CTypesEnum(CTypesInt):
             __slots__ = []
-            _reftypename = 'enum %s &' % name
+            _reftypename = '%s &' % name
 
             def _get_own_repr(self):
                 value = self._value

lib_pypy/cffi/model.py

         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
     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):
 
     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):
     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)
 

pypy/module/test_lib_pypy/cffi_tests/backend_tests.py

         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
         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())

pypy/module/test_lib_pypy/cffi_tests/test_ffi_backend.py

             '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 *' ")

pypy/module/test_lib_pypy/cffi_tests/test_verify.py

                        "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()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.