summaryrefslogtreecommitdiff
path: root/cffi/cparser.py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2015-01-11 15:04:41 +0100
committerArmin Rigo <arigo@tunes.org>2015-01-11 15:04:41 +0100
commit9215b25edf36171343d4acac02f2237e38e188ed (patch)
treed5dbbd4096f845530b344bdc5fe13d5234f5ec96 /cffi/cparser.py
parent5328afc70e4e27f10865d4e596aca6d875284d90 (diff)
downloadcffi-9215b25edf36171343d4acac02f2237e38e188ed.tar.gz
Fix (thanks gkcn on irc): in cdef() we can say "#define FOO 42", but
this declaration is completely ignored in verify(). Instead, we need to check that the real value is 42, and store the name FOO on the returned library object.
Diffstat (limited to 'cffi/cparser.py')
-rw-r--r--cffi/cparser.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/cffi/cparser.py b/cffi/cparser.py
index 5375242..49ca9b9 100644
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -229,12 +229,18 @@ class Parser(object):
pyvalue = int(int_str, 0)
self._add_constants(key, pyvalue)
+ self._declare('macro ' + key, pyvalue)
elif value == '...':
self._declare('macro ' + key, value)
else:
- raise api.CDefError('only supports the syntax "#define '
- '%s ..." (literally) or "#define '
- '%s 0x1FF" for now' % (key, key))
+ raise api.CDefError(
+ 'only supports one of the following syntax:\n'
+ ' #define %s ... (literally dot-dot-dot)\n'
+ ' #define %s NUMBER (with NUMBER an integer'
+ ' constant, decimal/hex/octal)\n'
+ 'got:\n'
+ ' #define %s %s'
+ % (key, key, key, value))
def _parse_decl(self, decl):
node = decl.type