summaryrefslogtreecommitdiff
path: root/cffi/cparser.py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2014-10-10 20:56:41 +0200
committerArmin Rigo <arigo@tunes.org>2014-10-10 20:56:41 +0200
commitfc53b53095d61a1ec5814c09c3bf2c7e18627fb5 (patch)
tree5c824926e1165a9ceee4156018b186216b7faee4 /cffi/cparser.py
parent4d0b57bd13b6e0f6a7eaa1e434313c6dc4cec3a8 (diff)
parent591081e92434f35f1c7bbe5e7bf854ded61ddc18 (diff)
downloadcffi-fc53b53095d61a1ec5814c09c3bf2c7e18627fb5.tar.gz
Merge this to default too
Diffstat (limited to 'cffi/cparser.py')
-rw-r--r--cffi/cparser.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/cffi/cparser.py b/cffi/cparser.py
index a53d4c3..e7a164e 100644
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -1,4 +1,3 @@
-
from . import api, model
from .commontypes import COMMON_TYPES, resolve_common_type
try:
@@ -460,6 +459,8 @@ class Parser(object):
elif kind == 'union':
tp = model.UnionType(explicit_name, None, None, None)
elif kind == 'enum':
+ if explicit_name == '__dotdotdot__':
+ raise CDefError("Enums cannot be declared with ...")
tp = self._build_enum_type(explicit_name, type.values)
else:
raise AssertionError("kind = %r" % (kind,))
@@ -532,11 +533,15 @@ class Parser(object):
def _parse_constant(self, exprnode, partial_length_ok=False):
# for now, limited to expressions that are an immediate number
- # or negative number
+ # or positive/negative number
if isinstance(exprnode, pycparser.c_ast.Constant):
return int(exprnode.value, 0)
#
if (isinstance(exprnode, pycparser.c_ast.UnaryOp) and
+ exprnode.op == '+'):
+ return self._parse_constant(exprnode.expr)
+ #
+ if (isinstance(exprnode, pycparser.c_ast.UnaryOp) and
exprnode.op == '-'):
return -self._parse_constant(exprnode.expr)
# load previously defined int constant