Author: Armin Rigo <[email protected]>
Branch: cffi-1.0
Changeset: r2002:31abe6c1eee0
Date: 2015-05-16 09:06 +0200
http://bitbucket.org/cffi/cffi/changeset/31abe6c1eee0/
Log: fixes
diff --git a/cffi/recompiler.py b/cffi/recompiler.py
--- a/cffi/recompiler.py
+++ b/cffi/recompiler.py
@@ -38,10 +38,10 @@
self.field_type_op = field_type_op
def as_c_expr(self):
- return (' { "%s", %s,\n' % (fldname, offset) +
- ' %s %s,\n' % (spaces, size) +
- ' %s _CFFI_OP(%s, %s) },' % (
- spaces, op, self._typesdict[fldtype]))
+ spaces = " " * len(self.name)
+ return (' { "%s", %s,\n' % (self.name, self.field_offset) +
+ ' %s %s,\n' % (spaces, self.field_size) +
+ ' %s %s },' % (spaces, self.field_type_op.as_c_expr()))
def as_python_expr(self):
raise NotImplementedError
@@ -74,7 +74,7 @@
+ '\n %s, %s, ' % (self.size, self.alignment)
+ '%d, %d ' % (self.first_field_index, len(self.c_fields))
+ ('/* %s */ ' % self.comment if self.comment else '')
- + '}')
+ + '},')
def as_python_expr(self):
flags = eval(self.flags, G_FLAGS)
@@ -271,7 +271,7 @@
self.write_py_source_to_f(f)
else:
assert preamble is not None
- self.write_c_source_to_f(f)
+ self.write_c_source_to_f(f, preamble)
def _rel_readlines(self, filename):
g = open(os.path.join(os.path.dirname(__file__), filename), 'r')
@@ -755,7 +755,6 @@
enumfields = list(tp.enumfields())
for fldname, fldtype, fbitsize in enumfields:
fldtype = self._field_type(tp, fldname, fldtype)
- spaces = " " * len(fldname)
# cname is None for _add_missing_struct_unions() only
op = OP_NOOP
if fbitsize >= 0:
@@ -804,7 +803,7 @@
# len(enumfields),))
comment = None
else:
- size = -1
+ size = '(size_t)-1'
align = -1
first_field_index = -1
comment = reason_for_not_expanding
diff --git a/testing/cffi1/test_recompiler.py b/testing/cffi1/test_recompiler.py
--- a/testing/cffi1/test_recompiler.py
+++ b/testing/cffi1/test_recompiler.py
@@ -230,7 +230,8 @@
def test_check_value_of_static_const():
ffi = FFI()
ffi.cdef("static const int FOOBAR = 042;")
- lib = verify(ffi, 'test_constant', "#define FOOBAR (-6912)")
+ lib = verify(ffi, 'test_check_value_of_static_const',
+ "#define FOOBAR (-6912)")
e = py.test.raises(ffi.error, getattr, lib, 'FOOBAR')
assert str(e.value) == (
"the C compiler says 'FOOBAR' is equal to -6912, but the cdef
disagrees")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit