Commit d57a91df authored by Stefan Behnel's avatar Stefan Behnel

work around bug in fused types code that prevents typing the signature of the...

work around bug in fused types code that prevents typing the signature of the runtime dispatch function
parent 36361c20
...@@ -519,15 +519,15 @@ class FusedCFuncDefNode(StatListNode): ...@@ -519,15 +519,15 @@ class FusedCFuncDefNode(StatListNode):
pyx_code.put_chunk( pyx_code.put_chunk(
u""" u"""
# PROCESSING ARGUMENT {{arg_tuple_idx}} # PROCESSING ARGUMENT {{arg_tuple_idx}}
if {{arg_tuple_idx}} < len(args): if {{arg_tuple_idx}} < len(<tuple>args):
arg = args[{{arg_tuple_idx}}] arg = (<tuple>args)[{{arg_tuple_idx}}]
elif '{{arg.name}}' in kwargs: elif '{{arg.name}}' in <dict>kwargs:
arg = kwargs['{{arg.name}}'] arg = (<dict>kwargs)['{{arg.name}}']
else: else:
{{if arg.default}} {{if arg.default}}
arg = defaults[{{default_idx}}] arg = (<tuple>defaults)[{{default_idx}}]
{{else}} {{else}}
raise TypeError("Expected at least %d arguments" % len(args)) raise TypeError("Expected at least %d arguments" % len(<tuple>args))
{{endif}} {{endif}}
""") """)
...@@ -561,8 +561,9 @@ class FusedCFuncDefNode(StatListNode): ...@@ -561,8 +561,9 @@ class FusedCFuncDefNode(StatListNode):
pyx_code.put_chunk( pyx_code.put_chunk(
u""" u"""
def __pyx_fused_cpdef(dict signatures not None, def __pyx_fused_cpdef(signatures, args, kwargs, defaults):
tuple args not None, dict kwargs, tuple defaults not None): # FIXME: use a typed signature - currently fails badly because
# default arguments inherit the types we specify here!
dest_sig = [{{for _ in range(n_fused)}}None,{{endfor}}] dest_sig = [{{for _ in range(n_fused)}}None,{{endfor}}]
...@@ -617,7 +618,7 @@ class FusedCFuncDefNode(StatListNode): ...@@ -617,7 +618,7 @@ class FusedCFuncDefNode(StatListNode):
pyx_code.put_chunk( pyx_code.put_chunk(
u""" u"""
candidates = [] candidates = []
for sig in signatures: for sig in <dict>signatures:
match_found = False match_found = False
for src_type, dst_type in zip(sig.strip('()').split('|'), dest_sig): for src_type, dst_type in zip(sig.strip('()').split('|'), dest_sig):
if dst_type is not None: if dst_type is not None:
...@@ -635,7 +636,7 @@ class FusedCFuncDefNode(StatListNode): ...@@ -635,7 +636,7 @@ class FusedCFuncDefNode(StatListNode):
elif len(candidates) > 1: elif len(candidates) > 1:
raise TypeError("Function call with ambiguous argument types") raise TypeError("Function call with ambiguous argument types")
else: else:
return signatures[candidates[0]] return (<dict>signatures)[candidates[0]]
""") """)
fragment_code = pyx_code.getvalue() fragment_code = pyx_code.getvalue()
......
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