Skip to content

Commit 5fc52c8

Browse files
committed
Revert "Use '_cffi_float_complex_t' or '_cffi_double_complex_t' more systematically."
This reverts commit 7ecdc9d.
1 parent 7ecdc9d commit 5fc52c8

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

src/c/_cffi_backend.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
#define CT_UNION 0x080 /* union */
218218
#define CT_FUNCTIONPTR 0x100 /* pointer to function */
219219
#define CT_VOID 0x200 /* void */
220-
#define CT_PRIMITIVE_COMPLEX 0x400 /* _cffi_float/double_complex_t */
220+
#define CT_PRIMITIVE_COMPLEX 0x400 /* float _Complex, double _Complex */
221221

222222
/* other flags that may also be set in addition to the base flag: */
223223
#define CT_IS_VOIDCHAR_PTR 0x00001000
@@ -4728,8 +4728,8 @@ static PyObject *new_primitive_type(const char *name)
47284728
EPTYPE(f, float, CT_PRIMITIVE_FLOAT ) \
47294729
EPTYPE(d, double, CT_PRIMITIVE_FLOAT ) \
47304730
EPTYPE(ld, long double, CT_PRIMITIVE_FLOAT | CT_IS_LONGDOUBLE ) \
4731-
EPTYPE2(fc, "_cffi_float_complex_t", cffi_float_complex_t, CT_PRIMITIVE_COMPLEX)\
4732-
EPTYPE2(dc, "_cffi_double_complex_t", cffi_double_complex_t, CT_PRIMITIVE_COMPLEX)\
4731+
EPTYPE2(fc, "float _Complex", cffi_float_complex_t, CT_PRIMITIVE_COMPLEX ) \
4732+
EPTYPE2(dc, "double _Complex", cffi_double_complex_t, CT_PRIMITIVE_COMPLEX ) \
47334733
ENUM_PRIMITIVE_TYPES_WCHAR \
47344734
EPTYPE2(c16, "char16_t", cffi_char16_t, CT_PRIMITIVE_CHAR ) \
47354735
EPTYPE2(c32, "char32_t", cffi_char32_t, CT_PRIMITIVE_CHAR ) \
@@ -7656,13 +7656,14 @@ static int _testfunc23(char *p)
76567656
}
76577657

76587658
#if 0 /* libffi doesn't properly support complexes currently */
7659+
/* also, MSVC might not support _Complex... */
76597660
/* if this is enabled one day, remember to also add _Complex
76607661
* arguments in addition to return values. */
7661-
static _cffi_float_complex_t _testfunc24(float a, float b)
7662+
static float _Complex _testfunc24(float a, float b)
76627663
{
76637664
return a + I*2.0*b;
76647665
}
7665-
static _cffi_double_complex_t _testfunc25(double a, double b)
7666+
static double _Complex _testfunc25(double a, double b)
76667667
{
76677668
return a + I*2.0*b;
76687669
}

src/c/realize_c_type.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ static PyObject *build_primitive_type(int num)
151151
"uint_fast64_t",
152152
"intmax_t",
153153
"uintmax_t",
154-
"_cffi_float_complex_t",
155-
"_cffi_double_complex_t",
154+
"float _Complex",
155+
"double _Complex",
156156
"char16_t",
157157
"char32_t",
158158
};

src/c/test_c.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def test_float_types():
247247
def test_complex_types():
248248
INF = 1E200 * 1E200
249249
for name in ["float", "double"]:
250-
p = new_primitive_type("_cffi_" + name + "_complex_t")
250+
p = new_primitive_type(name + " _Complex")
251251
assert bool(cast(p, 0)) is False
252252
assert bool(cast(p, INF))
253253
assert bool(cast(p, -INF))
@@ -1246,7 +1246,7 @@ def test_call_function_9():
12461246

12471247
def test_call_function_24():
12481248
BFloat = new_primitive_type("float")
1249-
BFloatComplex = new_primitive_type("_cffi_float_complex_t")
1249+
BFloatComplex = new_primitive_type("float _Complex")
12501250
BFunc3 = new_function_type((BFloat, BFloat), BFloatComplex, False)
12511251
if 0: # libffi returning nonsense silently, so logic disabled for now
12521252
f = cast(BFunc3, _testfunc(24))
@@ -1260,7 +1260,7 @@ def test_call_function_24():
12601260

12611261
def test_call_function_25():
12621262
BDouble = new_primitive_type("double")
1263-
BDoubleComplex = new_primitive_type("_cffi_double_complex_t")
1263+
BDoubleComplex = new_primitive_type("double _Complex")
12641264
BFunc3 = new_function_type((BDouble, BDouble), BDoubleComplex, False)
12651265
if 0: # libffi returning nonsense silently, so logic disabled for now
12661266
f = cast(BFunc3, _testfunc(25))
@@ -4536,9 +4536,9 @@ def test_unaligned_types():
45364536
buf = buffer(pbuf)
45374537
#
45384538
for name in ['short', 'int', 'long', 'long long', 'float', 'double',
4539-
'_cffi_float_complex_t', '_cffi_double_complex_t']:
4539+
'float _Complex', 'double _Complex']:
45404540
p = new_primitive_type(name)
4541-
if name.endswith('_complex_t'):
4541+
if name.endswith(' _Complex'):
45424542
num = cast(p, 1.23 - 4.56j)
45434543
else:
45444544
num = cast(p, 0x0123456789abcdef)

0 commit comments

Comments
 (0)