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

Commit76170f5

Browse files
authored
gh-104469: Convert _testcapi/long to use AC (gh-104720)
1 parentabdda5b commit76170f5

File tree

2 files changed

+250
-35
lines changed

2 files changed

+250
-35
lines changed

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

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

‎Modules/_testcapi/long.c‎

Lines changed: 84 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#include"parts.h"
2+
#include"clinic/long.c.h"
3+
4+
/*[clinic input]
5+
module _testcapi
6+
[clinic start generated code]*/
7+
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=6361033e795369fc]*/
28

39

410
staticPyObject*
@@ -40,8 +46,13 @@ raise_test_long_error(const char* msg)
4046

4147
#include"testcapi_long.h"
4248

49+
/*[clinic input]
50+
_testcapi.test_long_api
51+
[clinic start generated code]*/
52+
4353
staticPyObject*
44-
test_long_api(PyObject*self,PyObject*Py_UNUSED(ignored))
54+
_testcapi_test_long_api_impl(PyObject*module)
55+
/*[clinic end generated code: output=4405798ca1e9f444 input=e9b8880d7331c688]*/
4556
{
4657
returnTESTNAME(raise_test_long_error);
4758
}
@@ -68,8 +79,13 @@ raise_test_longlong_error(const char* msg)
6879

6980
#include"testcapi_long.h"
7081

82+
/*[clinic input]
83+
_testcapi.test_longlong_api
84+
[clinic start generated code]*/
85+
7186
staticPyObject*
72-
test_longlong_api(PyObject*self,PyObject*args)
87+
_testcapi_test_longlong_api_impl(PyObject*module)
88+
/*[clinic end generated code: output=2b3414ba8c31dfe6 input=ccbb2a48c2b3c4a5]*/
7389
{
7490
returnTESTNAME(raise_test_longlong_error);
7591
}
@@ -81,13 +97,19 @@ test_longlong_api(PyObject* self, PyObject *args)
8197
#undef F_U_TO_PY
8298
#undef F_PY_TO_U
8399

84-
/* Test the PyLong_AsLongAndOverflow API. General conversion to PY_LONG
85-
is tested by test_long_api_inner. This test will concentrate on proper
86-
handling of overflow.
87-
*/
100+
101+
/*[clinic input]
102+
_testcapi.test_long_and_overflow
103+
104+
Test the PyLong_AsLongAndOverflow API.
105+
106+
General conversion to PY_LONG is tested by test_long_api_inner.
107+
This test will concentrate on proper handling of overflow.
108+
[clinic start generated code]*/
88109

89110
staticPyObject*
90-
test_long_and_overflow(PyObject*self,PyObject*Py_UNUSED(ignored))
111+
_testcapi_test_long_and_overflow_impl(PyObject*module)
112+
/*[clinic end generated code: output=f8460ca115e31d8e input=762f6b62da0a3cdc]*/
91113
{
92114
PyObject*num,*one,*temp;
93115
longvalue;
@@ -243,13 +265,18 @@ test_long_and_overflow(PyObject *self, PyObject *Py_UNUSED(ignored))
243265
Py_RETURN_NONE;
244266
}
245267

246-
/* Test the PyLong_AsLongLongAndOverflow API. General conversion to
247-
long long is tested by test_long_api_inner. This test will
248-
concentrate on proper handling of overflow.
249-
*/
268+
/*[clinic input]
269+
_testcapi.test_long_long_and_overflow
270+
271+
Test the PyLong_AsLongLongAndOverflow API.
272+
273+
General conversion to long long is tested by test_long_api_inner.
274+
This test will concentrate on proper handling of overflow.
275+
[clinic start generated code]*/
250276

251277
staticPyObject*
252-
test_long_long_and_overflow(PyObject*self,PyObject*Py_UNUSED(ignored))
278+
_testcapi_test_long_long_and_overflow_impl(PyObject*module)
279+
/*[clinic end generated code: output=0b92330786f45483 input=544bb0aefe5e8a9e]*/
253280
{
254281
PyObject*num,*one,*temp;
255282
long longvalue;
@@ -405,13 +432,18 @@ test_long_long_and_overflow(PyObject *self, PyObject *Py_UNUSED(ignored))
405432
Py_RETURN_NONE;
406433
}
407434

408-
/* Test the PyLong_As{Size,Ssize}_t API. At present this just tests that
409-
non-integer arguments are handled correctly. It should be extended to
410-
test overflow handling.
411-
*/
435+
/*[clinic input]
436+
_testcapi.test_long_as_size_t
437+
438+
Test the PyLong_As{Size,Ssize}_t API.
439+
440+
At present this just tests that non-integer arguments are handled correctly.
441+
It should be extended to test overflow handling.
442+
[clinic start generated code]*/
412443

413444
staticPyObject*
414-
test_long_as_size_t(PyObject*self,PyObject*Py_UNUSED(ignored))
445+
_testcapi_test_long_as_size_t_impl(PyObject*module)
446+
/*[clinic end generated code: output=f6490ea2b41e6173 input=922990c4a3edfb0d]*/
415447
{
416448
size_tout_u;
417449
Py_ssize_tout_s;
@@ -442,9 +474,13 @@ test_long_as_size_t(PyObject *self, PyObject *Py_UNUSED(ignored))
442474
returnPy_None;
443475
}
444476

477+
/*[clinic input]
478+
_testcapi.test_long_as_unsigned_long_long_mask
479+
[clinic start generated code]*/
480+
445481
staticPyObject*
446-
test_long_as_unsigned_long_long_mask(PyObject*self,
447-
PyObject*Py_UNUSED(ignored))
482+
_testcapi_test_long_as_unsigned_long_long_mask_impl(PyObject*module)
483+
/*[clinic end generated code: output=e3e16cd0189440cc input=eb2438493ae7b9af]*/
448484
{
449485
unsigned long longres=PyLong_AsUnsignedLongLongMask(NULL);
450486

@@ -462,12 +498,13 @@ test_long_as_unsigned_long_long_mask(PyObject *self,
462498
Py_RETURN_NONE;
463499
}
464500

465-
/* Test the PyLong_AsDouble API. At present this just tests that
466-
non-integer arguments are handled correctly.
467-
*/
501+
/*[clinic input]
502+
_testcapi.test_long_as_double
503+
[clinic start generated code]*/
468504

469505
staticPyObject*
470-
test_long_as_double(PyObject*self,PyObject*Py_UNUSED(ignored))
506+
_testcapi_test_long_as_double_impl(PyObject*module)
507+
/*[clinic end generated code: output=deca0898e15adde5 input=c77bc88ef5a1de76]*/
471508
{
472509
doubleout;
473510

@@ -487,9 +524,13 @@ test_long_as_double(PyObject *self, PyObject *Py_UNUSED(ignored))
487524
returnPy_None;
488525
}
489526

490-
/* Simple test of _PyLong_NumBits and _PyLong_Sign. */
527+
/*[clinic input]
528+
_testcapi.test_long_numbits
529+
[clinic start generated code]*/
530+
491531
staticPyObject*
492-
test_long_numbits(PyObject*self,PyObject*Py_UNUSED(ignored))
532+
_testcapi_test_long_numbits_impl(PyObject*module)
533+
/*[clinic end generated code: output=9eaf8458cb15d7f7 input=265c02d48a13059e]*/
493534
{
494535
structtriple {
495536
longinput;
@@ -534,8 +575,16 @@ test_long_numbits(PyObject *self, PyObject *Py_UNUSED(ignored))
534575
Py_RETURN_NONE;
535576
}
536577

578+
/*[clinic input]
579+
_testcapi.call_long_compact_api
580+
arg: object
581+
/
582+
[clinic start generated code]*/
583+
537584
staticPyObject*
538-
check_long_compact_api(PyObject*self,PyObject*arg)
585+
_testcapi_call_long_compact_api(PyObject*module,PyObject*arg)
586+
/*[clinic end generated code: output=7e3894f611b1b2b7 input=87b87396967af14c]*/
587+
539588
{
540589
assert(PyLong_Check(arg));
541590
intis_compact=PyUnstable_Long_IsCompact((PyLongObject*)arg);
@@ -547,15 +596,15 @@ check_long_compact_api(PyObject *self, PyObject *arg)
547596
}
548597

549598
staticPyMethodDeftest_methods[]= {
550-
{"test_long_and_overflow",test_long_and_overflow,METH_NOARGS},
551-
{"test_long_api",test_long_api,METH_NOARGS},
552-
{"test_long_as_double",test_long_as_double,METH_NOARGS},
553-
{"test_long_as_size_t",test_long_as_size_t,METH_NOARGS},
554-
{"test_long_as_unsigned_long_long_mask",test_long_as_unsigned_long_long_mask,METH_NOARGS},
555-
{"test_long_long_and_overflow",test_long_long_and_overflow,METH_NOARGS},
556-
{"test_long_numbits",test_long_numbits,METH_NOARGS},
557-
{"test_longlong_api",test_longlong_api,METH_NOARGS},
558-
{"call_long_compact_api",check_long_compact_api,METH_O},
599+
_TESTCAPI_TEST_LONG_AND_OVERFLOW_METHODDEF
600+
_TESTCAPI_TEST_LONG_API_METHODDEF
601+
_TESTCAPI_TEST_LONG_AS_DOUBLE_METHODDEF
602+
_TESTCAPI_TEST_LONG_AS_SIZE_T_METHODDEF
603+
_TESTCAPI_TEST_LONG_AS_UNSIGNED_LONG_LONG_MASK_METHODDEF
604+
_TESTCAPI_TEST_LONG_LONG_AND_OVERFLOW_METHODDEF
605+
_TESTCAPI_TEST_LONG_NUMBITS_METHODDEF
606+
_TESTCAPI_TEST_LONGLONG_API_METHODDEF
607+
_TESTCAPI_CALL_LONG_COMPACT_API_METHODDEF
559608
{NULL},
560609
};
561610

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp