[pypy-commit] cffi cffi-1.0: in-progress

arigo noreply at buildbot.pypy.org
Tue May 12 11:18:23 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1983:456f626c06ea
Date: 2015-05-12 10:30 +0200
http://bitbucket.org/cffi/cffi/changeset/456f626c06ea/

Log:	in-progress

diff --git a/_cffi1/manual2.py b/_cffi1/manual2.py
--- a/_cffi1/manual2.py
+++ b/_cffi1/manual2.py
@@ -3,7 +3,7 @@
 ffi = _cffi_backend.FFI(b"manual2",
     _version = 0x2600,
     _types = b'\x00\x00\x01\x0D\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x00\x09\x00\x00\x00\x0B\x00\x00\x01\x03',
-    _globals = (b'\xff\xff\xff\x0bAA',0,b'\xff\xff\xff\x0bBB',1,b'\xff\xff\xff\x0bCC',2,b'\x00\x00\x00\x1fFOO',-42,b'\x00\x00\x00#close',0,b'\x00\x00\x05#stdout',0),
+    _globals = (b'\xff\xff\xff\x0bAA',0,b'\xff\xff\xff\x0bBB',-1,b'\xff\xff\xff\x0bCC',2,b'\xff\xff\xff\x1fFOO',0x9999999999999999,b'\x00\x00\x00#close',0,b'\x00\x00\x05#stdout',0),
     _struct_unions = ((b'\x00\x00\x00\x03\x00\x00\x00\x00point_s',b'\x00\x00\x01\x11\xff\xff\xff\xffx',b'\x00\x00\x01\x11\xff\xff\xff\xffy'),),
     _enums = (b'\x00\x00\x00\x04\x00\x00\x00\x07myenum_e\x00AA,BB,CC',),
     _typenames = (b'\x00\x00\x00\x01myint_t',),
@@ -13,8 +13,9 @@
 
 # trying it out
 lib = ffi.dlopen(None)
-assert lib.BB == 1
-assert lib.FOO == -42
+assert lib.AA == 0
+assert lib.BB == -1
+assert lib.FOO == 0x9999999999999999
 x = lib.close(-42)
 assert x == -1
 
@@ -23,8 +24,11 @@
 print ffi.new("struct point_s *")
 print ffi.offsetof("struct point_s", "x")
 print ffi.offsetof("struct point_s", "y")
+print ffi.new("struct point_s[CC]")
+assert ffi.sizeof("struct point_s[CC]") == 2 * ffi.sizeof("struct point_s")
 
 print ffi.cast("enum myenum_e", 2)
 print ffi.cast("myint_t", -2)
+assert ffi.typeof("myint_t") == ffi.typeof("int")
 
 del ffi, lib
diff --git a/_cffi1/recompiler.py b/_cffi1/recompiler.py
--- a/_cffi1/recompiler.py
+++ b/_cffi1/recompiler.py
@@ -747,7 +747,7 @@
 
     def _generate_cpy_constant_ctx(self, tp, name):
         if isinstance(tp, model.PrimitiveType) and tp.is_integer_type():
-            type_op = '_CFFI_OP(_CFFI_OP_CONSTANT_INT, 0)'
+            type_op = '_CFFI_OP(_CFFI_OP_CONSTANT_INT, -1)'
         else:
             type_index = self._typesdict[tp]
             type_op = '_CFFI_OP(_CFFI_OP_CONSTANT, %d)' % type_index
@@ -803,7 +803,7 @@
     def _generate_cpy_macro_ctx(self, tp, name):
         self._lsts["global"].append(
             '  { "%s", _cffi_const_%s,'
-            ' _CFFI_OP(_CFFI_OP_CONSTANT_INT, 0), 0 },' % (name, name))
+            ' _CFFI_OP(_CFFI_OP_CONSTANT_INT, -1), 0 },' % (name, name))
 
     # ----------
     # global variables


More information about the pypy-commit mailing list