Skip to content

Commit b7b0a76

Browse files
author
Anselm Kruis
committed
Issue python#113: update argument clinic to create Stackless aware parsers
Argument clinic now adds STACKLESS_GETARG(), STACKLESS_PROMOTE_ALL() and STACKLESS_ASSERT() to parsers for functions, which have the @stackless decoration. https://bitbucket.org/stackless-dev/stackless/issues/113
1 parent 6468d62 commit b7b0a76

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Tools/clinic/clinic.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,14 +650,17 @@ def parser_body(prototype, *fields):
650650
fields = list(fields)
651651
fields.insert(0, normalize_snippet("""
652652
{{
653+
{stackless_getarg}
653654
{return_value_declaration}
654655
{declarations}
655656
{initializers}
656657
""") + "\n")
657658
# just imagine--your code is here in the middle
658659
fields.append(normalize_snippet("""
659660
{modifications}
661+
{stackless_promote}
660662
{return_value} = {c_basename}_impl({impl_arguments});
663+
{stackless_assert}
661664
{return_conversion}
662665
663666
{exit_label}
@@ -1095,7 +1098,10 @@ def render_function(self, clinic, f):
10951098
# if we have any gotos
10961099
need_exit_label = "goto exit;" in template
10971100
template = linear_format(template,
1098-
exit_label="exit:" if need_exit_label else ''
1101+
exit_label="exit:" if need_exit_label else '',
1102+
stackless_getarg="STACKLESS_GETARG();" if need_exit_label and f.stackless else '',
1103+
stackless_promote="STACKLESS_PROMOTE_ALL();" if need_exit_label and f.stackless else '',
1104+
stackless_assert="STACKLESS_ASSERT();" if need_exit_label and f.stackless else ''
10991105
)
11001106

11011107
s = template.format_map(template_dict)

0 commit comments

Comments
 (0)