Commit 85bb6796 authored by Robert Bradshaw's avatar Robert Bradshaw

More complete array type parsing.

Also fixed passing templates through complex types.
parent 9b24fd97
...@@ -2009,7 +2009,7 @@ def p_c_base_type(s, self_flag = 0, nonempty = 0, templates = None): ...@@ -2009,7 +2009,7 @@ def p_c_base_type(s, self_flag = 0, nonempty = 0, templates = None):
# If self_flag is true, this is the base type for the # If self_flag is true, this is the base type for the
# self argument of a C method of an extension type. # self argument of a C method of an extension type.
if s.sy == '(': if s.sy == '(':
return p_c_complex_base_type(s) return p_c_complex_base_type(s, templates = templates)
else: else:
return p_c_simple_base_type(s, self_flag, nonempty = nonempty, templates = templates) return p_c_simple_base_type(s, self_flag, nonempty = nonempty, templates = templates)
...@@ -2024,20 +2024,21 @@ def p_calling_convention(s): ...@@ -2024,20 +2024,21 @@ def p_calling_convention(s):
calling_convention_words = cython.declare( calling_convention_words = cython.declare(
set, set(["__stdcall", "__cdecl", "__fastcall"])) set, set(["__stdcall", "__cdecl", "__fastcall"]))
def p_c_complex_base_type(s): def p_c_complex_base_type(s, templates = None):
# s.sy == '(' # s.sy == '('
pos = s.position() pos = s.position()
s.next() s.next()
base_type = p_c_base_type(s) base_type = p_c_base_type(s, templates = templates)
declarator = p_c_declarator(s, empty = 1) declarator = p_c_declarator(s, empty = 1)
s.expect(')') s.expect(')')
complex_type = Nodes.CComplexBaseTypeNode(pos, type_node = Nodes.CComplexBaseTypeNode(pos,
base_type = base_type, declarator = declarator) base_type = base_type, declarator = declarator)
while s.sy == '[': if s.sy == '[':
declarator = p_c_declarator(s, empty = 1) if is_memoryviewslice_access(s):
complex_type = Nodes.CComplexBaseTypeNode(pos, type_node = p_memoryviewslice_access(s, type_node)
base_type = complex_type, declarator = declarator) else:
return complex_type type_node = p_buffer_or_template(s, type_node, templates)
return type_node
def p_c_simple_base_type(s, self_flag, nonempty, templates = None): def p_c_simple_base_type(s, self_flag, nonempty, templates = None):
...@@ -2110,10 +2111,6 @@ def p_c_simple_base_type(s, self_flag, nonempty, templates = None): ...@@ -2110,10 +2111,6 @@ def p_c_simple_base_type(s, self_flag, nonempty, templates = None):
type_node = p_memoryviewslice_access(s, type_node) type_node = p_memoryviewslice_access(s, type_node)
else: else:
type_node = p_buffer_or_template(s, type_node, templates) type_node = p_buffer_or_template(s, type_node, templates)
while s.sy == '[':
declarator = p_c_declarator(s, empty = 1)
type_node = Nodes.CComplexBaseTypeNode(pos,
base_type = type_node, declarator = declarator)
if s.sy == '.': if s.sy == '.':
s.next() s.next()
...@@ -2132,6 +2129,9 @@ def p_buffer_or_template(s, base_type_node, templates): ...@@ -2132,6 +2129,9 @@ def p_buffer_or_template(s, base_type_node, templates):
p_positional_and_keyword_args(s, (']',), templates) p_positional_and_keyword_args(s, (']',), templates)
) )
s.expect(']') s.expect(']')
if s.sy == '[':
base_type_node = p_buffer_or_template(s, base_type_node, templates)
keyword_dict = ExprNodes.DictNode(pos, keyword_dict = ExprNodes.DictNode(pos,
key_value_pairs = [ key_value_pairs = [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment