[pypy-commit] pypy default: Refactor typedef'd identifier handling in _get_type_and_quals(): move it together with the other identifiers
rlamy
pypy.commits at gmail.com
Fri Jan 20 12:03:16 EST 2017
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch:
Changeset: r89679:5444bd569e8a
Date: 2017-01-20 17:02 +0000
http://bitbucket.org/pypy/pypy/changeset/5444bd569e8a/
Log: Refactor typedef'd identifier handling in _get_type_and_quals():
move it together with the other identifiers
diff --git a/pypy/module/cpyext/cparser.py b/pypy/module/cpyext/cparser.py
--- a/pypy/module/cpyext/cparser.py
+++ b/pypy/module/cpyext/cparser.py
@@ -326,15 +326,6 @@
return model.PointerType(type, quals)
def _get_type_and_quals(self, typenode, name=None, partial_length_ok=False):
- # first, dereference typedefs, if we have it already parsed, we're good
- if (isinstance(typenode, pycparser.c_ast.TypeDecl) and
- isinstance(typenode.type, pycparser.c_ast.IdentifierType) and
- len(typenode.type.names) == 1 and
- ('typedef ' + typenode.type.names[0]) in self._declarations):
- tp, quals = self._declarations['typedef ' + typenode.type.names[0]]
- quals |= self._extract_quals(typenode)
- return tp, quals
- #
if isinstance(typenode, pycparser.c_ast.ArrayDecl):
# array type
if typenode.dim is None:
@@ -356,6 +347,13 @@
if isinstance(typenode, pycparser.c_ast.TypeDecl):
quals = self._extract_quals(typenode)
type = typenode.type
+ # first, dereference typedefs, if we have it already parsed, we're good
+ if (isinstance(type, pycparser.c_ast.IdentifierType) and
+ len(type.names) == 1 and
+ ('typedef ' + type.names[0]) in self._declarations):
+ tp, base_quals = self._declarations['typedef ' + type.names[0]]
+ quals |= base_quals
+ return tp, quals
if isinstance(type, pycparser.c_ast.IdentifierType):
# assume a primitive type. get it from .names, but reduce
# synonyms to a single chosen combination
More information about the pypy-commit
mailing list