Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
PyPy
cffi
Commits
17be464b073d
Commit
18e78e6f
authored
Jun 15, 2015
by
Armin Rigo
Browse files
Explicitly complain if we find 'typedef int... t;' in a call to verify()
parent
78ba2e4ab0ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
cffi/cparser.py
View file @
17be464b
...
...
@@ -102,6 +102,7 @@ class Parser(object):
self
.
_packed
=
False
self
.
_int_constants
=
{}
self
.
_recomplete
=
[]
self
.
_uses_new_feature
=
None
def
_parse
(
self
,
csource
):
csource
,
macros
=
_preprocess
(
csource
)
...
...
@@ -648,4 +649,7 @@ class Parser(object):
for
t
in
typenames
[:
-
1
]:
if
t
not
in
[
'int'
,
'short'
,
'long'
,
'signed'
,
'unsigned'
,
'char'
]:
raise
api
.
FFIError
(
':%d: bad usage of "..."'
%
decl
.
coord
.
line
)
if
self
.
_uses_new_feature
is
None
:
self
.
_uses_new_feature
=
"'typedef %s... %s'"
%
(
' '
.
join
(
typenames
[:
-
1
]),
decl
.
name
)
return
model
.
UnknownIntegerType
(
decl
.
name
)
cffi/verifier.py
View file @
17be464b
...
...
@@ -28,6 +28,10 @@ class Verifier(object):
def
__init__
(
self
,
ffi
,
preamble
,
tmpdir
=
None
,
modulename
=
None
,
ext_package
=
None
,
tag
=
''
,
force_generic_engine
=
False
,
source_extension
=
'.c'
,
flags
=
None
,
relative_to
=
None
,
**
kwds
):
if
ffi
.
_parser
.
_uses_new_feature
:
raise
ffiplatform
.
VerificationError
(
"feature not supported with ffi.verify(), but only "
"with ffi.set_source(): %s"
%
(
ffi
.
_parser
.
_uses_new_feature
,))
self
.
ffi
=
ffi
self
.
preamble
=
preamble
if
not
modulename
:
...
...
testing/cffi0/test_verify.py
View file @
17be464b
...
...
@@ -2235,3 +2235,15 @@ def test_const_struct_global():
"const T myglob = { 0.1, 42 };"
)
assert
ffi
.
typeof
(
lib
.
myglob
)
==
ffi
.
typeof
(
"T"
)
assert
lib
.
myglob
.
x
==
42
def
test_dont_support_int_dotdotdot
():
ffi
=
FFI
()
ffi
.
cdef
(
"typedef int... t1;"
)
e
=
py
.
test
.
raises
(
VerificationError
,
ffi
.
verify
,
""
)
assert
str
(
e
.
value
)
==
(
"feature not supported with ffi.verify(), but only "
"with ffi.set_source(): 'typedef int... t1'"
)
ffi
=
FFI
()
ffi
.
cdef
(
"typedef unsigned long... t1;"
)
e
=
py
.
test
.
raises
(
VerificationError
,
ffi
.
verify
,
""
)
assert
str
(
e
.
value
)
==
(
"feature not supported with ffi.verify(), but only "
"with ffi.set_source(): 'typedef unsigned long... t1'"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment