Commit a012b541 authored by Stefan Behnel's avatar Stefan Behnel

reverted rev 921 (still breaks code)

parent 9518368e
...@@ -362,12 +362,8 @@ class CNameDeclaratorNode(CDeclaratorNode): ...@@ -362,12 +362,8 @@ class CNameDeclaratorNode(CDeclaratorNode):
def analyse(self, base_type, env, nonempty = 0): def analyse(self, base_type, env, nonempty = 0):
if nonempty and self.name == '': if nonempty and self.name == '':
# May have mistaken the name for the type. # Must have mistaken the name for the type.
if base_type.is_ptr or base_type.is_array or base_type.is_buffer: self.name = base_type.name
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 base_type = py_object_type
self.type = base_type self.type = base_type
return self, base_type return self, base_type
...@@ -426,8 +422,6 @@ class CFuncDeclaratorNode(CDeclaratorNode): ...@@ -426,8 +422,6 @@ class CFuncDeclaratorNode(CDeclaratorNode):
optional_arg_count = 0 optional_arg_count = 0
def analyse(self, return_type, env, nonempty = 0): def analyse(self, return_type, env, nonempty = 0):
if nonempty:
nonempty -= 1
func_type_args = [] func_type_args = []
for arg_node in self.args: for arg_node in self.args:
name_declarator, type = arg_node.analyse(env, nonempty = nonempty) name_declarator, type = arg_node.analyse(env, nonempty = nonempty)
...@@ -1056,8 +1050,7 @@ class CFuncDefNode(FuncDefNode): ...@@ -1056,8 +1050,7 @@ class CFuncDefNode(FuncDefNode):
def analyse_declarations(self, env): def analyse_declarations(self, env):
base_type = self.base_type.analyse(env) base_type = self.base_type.analyse(env)
# The 2 here is because we need both function and argument names. name_declarator, type = self.declarator.analyse(base_type, env, self.body is not None)
name_declarator, type = self.declarator.analyse(base_type, env, nonempty = 2 * (self.body is not None))
if not type.is_cfunction: if not type.is_cfunction:
error(self.pos, error(self.pos,
"Suite attached to non-function declaration") "Suite attached to non-function declaration")
......
def f(obj, int i, float f, char *s1, char s2[]): def f(obj, int i, float f, char *s1, char s2[]):
pass pass
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