# Treat trailing [] on type as buffer access
- if not is_basic and s.sy == '[':
+ if s.sy == '[':
return p_buffer_access(s, type_node)
else:
return type_node
-def p_buffer_access(s, type_node):
+def p_buffer_access(s, base_type_node):
# s.sy == '['
pos = s.position()
s.next()
+ if s.sy == ']':
+ # not buffer, could be [] on C type nameless array arguments
+ s.put_back('[', '[')
+ return base_type_node
positional_args, keyword_args = (
p_positional_and_keyword_args(s, (']',), (0,), ('dtype',))
)
result = Nodes.CBufferAccessTypeNode(pos,
positional_args = positional_args,
keyword_args = keyword_dict,
- base_type_node = type_node)
+ base_type_node = base_type_node)
return result
self.assert_(self.expect_error)
def parse_opts(self, opts, expect_error=False):
+ assert opts != ""
s = u"def f():\n cdef object[%s] x" % opts
self.expect_error = expect_error
root = self.fragment(s, pipeline=[NormalizeTree(self), PostParse(self)]).root
self.assert_(buf.dtype_node.signed == 0 and buf.dtype_node.longness == -1)
self.assertEqual(3, buf.ndim)
- def test_dtype(self):
- self.non_parse(ERR_BUF_MISSING % 'dtype', u"")
-
def test_ndim(self):
self.parse_opts(u"int, 2")
self.non_parse(ERR_BUF_INT % 'ndim', u"int, 'a'")
--- /dev/null
+cdef extern from *:
+
+ cdef void foo(int[])
+
+ ctypedef int MyInt
+ cdef void foo(MyInt[])
+
+ struct MyStruct:
+ pass
+ cdef void bar(MyStruct[])
+
+ ctypedef MyStruct* MyStructP
+ cdef void baz(MyStructP[])