gh-61103: Support double complex (_Complex) type in ctypes (#120894)

Example:

```pycon
>>> import ctypes
>>> ctypes.__STDC_IEC_559_COMPLEX__
1
>>> libm = ctypes.CDLL('libm.so.6')
>>> libm.clog.argtypes = [ctypes.c_double_complex]
>>> libm.clog.restype = ctypes.c_double_complex
>>> libm.clog(1+1j)
(0.34657359027997264+0.7853981633974483j)
```

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Sergey B Kirpichev 2024-07-01 11:54:33 +03:00 committed by GitHub
parent a0b8b342c5
commit 6988ff02a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 316 additions and 17 deletions

View file

@ -72,6 +72,7 @@ _KEYWORD = textwrap.dedent(r'''
long |
float |
double |
_Complex |
void |
struct |
@ -121,6 +122,16 @@ SIMPLE_TYPE = textwrap.dedent(rf'''
|
(?: signed | unsigned ) # implies int
|
(?:
(?: (?: float | double | long\s+double ) \s+ )?
_Complex
)
|
(?:
_Complex
(?: \s+ (?: float | double | long\s+double ) )?
)
|
(?:
(?: (?: signed | unsigned ) \s+ )?
(?: (?: long | short ) \s+ )?