mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-108494: Argument Clinic: inline parsing code for positional-only parameters in the limited C API (GH-108622)
This commit is contained in:
parent
55846099b1
commit
1796c191b4
13 changed files with 555 additions and 307 deletions
|
|
@ -38,13 +38,14 @@ class HANDLE_converter(CConverter):
|
|||
type = 'void *'
|
||||
format_unit = '"_Py_PARSE_UINTPTR"'
|
||||
|
||||
def parse_arg(self, argname, displayname):
|
||||
return """
|
||||
def parse_arg(self, argname, displayname, *, limited_capi):
|
||||
return self.format_code("""
|
||||
{paramname} = PyLong_AsVoidPtr({argname});
|
||||
if (!{paramname} && PyErr_Occurred()) {{{{
|
||||
goto exit;
|
||||
}}}}
|
||||
""".format(argname=argname, paramname=self.parser_name)
|
||||
""",
|
||||
argname=argname)
|
||||
|
||||
class HANDLE_return_converter(CReturnConverter):
|
||||
type = 'void *'
|
||||
|
|
@ -74,7 +75,7 @@ class wchar_t_return_converter(CReturnConverter):
|
|||
data.return_conversion.append(
|
||||
'return_value = PyUnicode_FromOrdinal(_return_value);\n')
|
||||
[python start generated code]*/
|
||||
/*[python end generated code: output=da39a3ee5e6b4b0d input=1e8e9fa3538ec08f]*/
|
||||
/*[python end generated code: output=da39a3ee5e6b4b0d input=ff031be44ab3250d]*/
|
||||
|
||||
/*[clinic input]
|
||||
module msvcrt
|
||||
|
|
|
|||
18
PC/winreg.c
18
PC/winreg.c
|
|
@ -222,13 +222,15 @@ class HKEY_converter(CConverter):
|
|||
converter = 'clinic_HKEY_converter'
|
||||
broken_limited_capi = True
|
||||
|
||||
def parse_arg(self, argname, displayname):
|
||||
return """
|
||||
if (!{converter}(_PyModule_GetState(module), {argname}, &{paramname})) {{{{
|
||||
goto exit;
|
||||
}}}}
|
||||
""".format(argname=argname, paramname=self.parser_name,
|
||||
converter=self.converter)
|
||||
def parse_arg(self, argname, displayname, *, limited_capi):
|
||||
assert not limited_capi
|
||||
return self.format_code("""
|
||||
if (!{converter}(_PyModule_GetState(module), {argname}, &{paramname})) {{{{
|
||||
goto exit;
|
||||
}}}}
|
||||
""",
|
||||
argname=argname,
|
||||
converter=self.converter)
|
||||
|
||||
class HKEY_return_converter(CReturnConverter):
|
||||
type = 'HKEY'
|
||||
|
|
@ -250,7 +252,7 @@ class self_return_converter(CReturnConverter):
|
|||
data.return_conversion.append(
|
||||
'return_value = (PyObject *)_return_value;\n')
|
||||
[python start generated code]*/
|
||||
/*[python end generated code: output=da39a3ee5e6b4b0d input=f8cb7034338aeaba]*/
|
||||
/*[python end generated code: output=da39a3ee5e6b4b0d input=4979f33998ffb6f8]*/
|
||||
|
||||
#include "clinic/winreg.c.h"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue