1. Python CFFI
  2. Untitled project
  3. cffi

Commits

Armin Rigo  committed 3bb5d49

Allow '[...]' when declaring a global array, and interpret it like '[]'.

  • Participants
  • Parent commits efa2822
  • Branches default

Comments (0)

Files changed (2)

File cffi/cparser.py

View file
  • Ignore whitespace
                                     decl)
             #
             if decl.name:
-                tp = self._get_type(node)
+                tp = self._get_type(node, partial_length_ok=True)
                 if self._is_constant_declaration(node):
                     self._declare('constant ' + decl.name, tp)
                 else:

File testing/test_verify.py

View file
  • Ignore whitespace
     result = posix.read(fdr, 256)
     posix.close(fdr)
     assert result == b"Xhello, 42!\n"
+
+def test_global_array_with_missing_length():
+    ffi = FFI()
+    ffi.cdef("int fooarray[];")
+    lib = ffi.verify("int fooarray[50];")
+    assert repr(lib.fooarray).startswith("<cdata 'int *'")
+
+def test_global_array_with_dotdotdot_length():
+    ffi = FFI()
+    ffi.cdef("int fooarray[...];")
+    lib = ffi.verify("int fooarray[50];")
+    assert repr(lib.fooarray).startswith("<cdata 'int *'")