diff options
| author | mozbugbox <mozbugbox@yahoo.com.au> | 2014-04-02 11:45:29 +0800 |
|---|---|---|
| committer | mozbugbox <mozbugbox@yahoo.com.au> | 2014-04-02 11:45:29 +0800 |
| commit | 58f87aa85b0381e91c6b1d8b194b3a71f1f0a14a (patch) | |
| tree | ec0ad40f33de4d19aa91722766331e6a5da2f4ae /cffi | |
| parent | c8f68e82fd06d667e36389ee1c8e9b3fdfbe49d2 (diff) | |
| download | cffi-reusable-enum-values.tar.gz | |
ffi.include update _int_constant and prevent duplicated const declreusable-enum-values
Duplicated declaration of constants even in enum name is not
valid.
Diffstat (limited to 'cffi')
| -rw-r--r-- | cffi/cparser.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cffi/cparser.py b/cffi/cparser.py index 8ad87db..0456b05 100644 --- a/cffi/cparser.py +++ b/cffi/cparser.py @@ -542,6 +542,10 @@ class Parser(object): if enum.value is not None: nextenumvalue = self._parse_constant(enum.value) enumvalues.append(nextenumvalue) + if enum.name in self._int_constants: + raise api.FFIError( + "multiple declarations of constant %s" % (enum.name,)) + self._int_constants[enum.name] = nextenumvalue nextenumvalue += 1 enumvalues = tuple(enumvalues) @@ -556,3 +560,9 @@ class Parser(object): kind = name.split(' ', 1)[0] if kind in ('typedef', 'struct', 'union', 'enum'): self._declare(name, tp) + for k, v in other._int_constants.items(): + if k not in self._int_constants: + self._int_constants[k] = v + else: + raise api.FFIError( + "multiple declarations of constant %s" % (k,)) |
