Commit 7e3e990f authored by Robert Bradshaw's avatar Robert Bradshaw

Function pointers as arguments, better errors for unnamed arguments.

parent d5a8f001
......@@ -362,8 +362,13 @@ class CNameDeclaratorNode(CDeclaratorNode):
def analyse(self, base_type, env, nonempty = 0):
if nonempty and self.name == '':
# Must have mistaken the name for the type.
self.name = base_type.name
raise RuntimeError
# May have mistaken the name for the type.
if base_type.is_ptr or base_type.is_array or base_type.is_buffer:
error(self.pos, "Missing argument name.")
elif base_type.is_void:
error(self.pos, "Use spam() rather than spam(void) to declare a function with no arguments.")
self.name = base_type.declaration_code("", for_display=1, pyrex=1)
base_type = py_object_type
self.type = base_type
return self, base_type
......@@ -424,7 +429,7 @@ class CFuncDeclaratorNode(CDeclaratorNode):
def analyse(self, return_type, env, nonempty = 0):
func_type_args = []
for arg_node in self.args:
name_declarator, type = arg_node.analyse(env, nonempty = nonempty)
name_declarator, type = arg_node.analyse(env)
name = name_declarator.name
if name_declarator.cname:
error(self.pos,
......
def f(obj, int i, float f, char *s1, char s2[]):
pass
\ No newline at end of file
cdef g(obj, int i, float f, char *s1, char s2[]):
pass
cdef do_g(object (*func)(object, int, float, char*, char*)):
return func(1, 2, 3.14159, "a", "b")
do_g(&g)
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