Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf0ce379

Browse files
committed
gh-104469 Convert _testcapi/flaot.c to use AC
1 parent7d2deaf commitf0ce379

File tree

2 files changed

+123
-19
lines changed

2 files changed

+123
-19
lines changed

‎Modules/_testcapi/clinic/float.c.h‎

Lines changed: 88 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Modules/_testcapi/float.c‎

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
#definePY_SSIZE_T_CLEAN
22

33
#include"parts.h"
4+
#include"clinic/float.c.h"
45

56

6-
// Test PyFloat_Pack2(), PyFloat_Pack4() and PyFloat_Pack8()
7+
/*[clinic input]
8+
module _testcapi
9+
[clinic start generated code]*/
10+
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=6361033e795369fc]*/
11+
12+
/*[clinic input]
13+
_testcapi.float_pack
14+
15+
size: int
16+
d: double
17+
le: int
18+
/
19+
20+
Test PyFloat_Pack2(), PyFloat_Pack4() and PyFloat_Pack8()
21+
[clinic start generated code]*/
22+
723
staticPyObject*
8-
test_float_pack(PyObject*self,PyObject*args)
24+
_testcapi_float_pack_impl(PyObject*module,intsize,doubled,intle)
25+
/*[clinic end generated code: output=7899bd98f8b6cb04 input=52c9115121999c98]*/
926
{
10-
intsize;
11-
doubled;
12-
intle;
13-
if (!PyArg_ParseTuple(args,"idi",&size,&d,&le)) {
14-
returnNULL;
15-
}
1627
switch (size)
1728
{
1829
case2:
@@ -47,19 +58,24 @@ test_float_pack(PyObject *self, PyObject *args)
4758
}
4859

4960

50-
// Test PyFloat_Unpack2(), PyFloat_Unpack4() and PyFloat_Unpack8()
61+
/*[clinic input]
62+
_testcapi.float_unpack
63+
64+
data: str(accept={robuffer}, zeroes=True)
65+
le: int
66+
/
67+
68+
Test PyFloat_Unpack2(), PyFloat_Unpack4() and PyFloat_Unpack8()
69+
[clinic start generated code]*/
70+
5171
staticPyObject*
52-
test_float_unpack(PyObject*self,PyObject*args)
72+
_testcapi_float_unpack_impl(PyObject*module,constchar*data,
73+
Py_ssize_tdata_length,intle)
74+
/*[clinic end generated code: output=617059f889ddbfe4 input=c095e4bb75a696cd]*/
5375
{
5476
assert(!PyErr_Occurred());
55-
constchar*data;
56-
Py_ssize_tsize;
57-
intle;
58-
if (!PyArg_ParseTuple(args,"y#i",&data,&size,&le)) {
59-
returnNULL;
60-
}
6177
doubled;
62-
switch (size)
78+
switch (data_length)
6379
{
6480
case2:
6581
d=PyFloat_Unpack2(data,le);
@@ -82,8 +98,8 @@ test_float_unpack(PyObject *self, PyObject *args)
8298
}
8399

84100
staticPyMethodDeftest_methods[]= {
85-
{"float_pack",test_float_pack,METH_VARARGS,NULL},
86-
{"float_unpack",test_float_unpack,METH_VARARGS,NULL},
101+
_TESTCAPI_FLOAT_PACK_METHODDEF
102+
_TESTCAPI_FLOAT_UNPACK_METHODDEF
87103
{NULL},
88104
};
89105

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp