1 /** 2 Mirror _complexobject.h 3 */ 4 module deimos.python.complexobject; 5 6 import deimos.python.pyport; 7 import deimos.python.object; 8 import deimos.python.unicodeobject; 9 10 extern(C): 11 // Python-header-file: Include/complexobject.h: 12 13 /// _ 14 struct Py_complex { 15 /// _ 16 double real_; 17 /// _ 18 double imag; 19 } 20 21 /// _ 22 Py_complex c_sum(Py_complex, Py_complex); 23 /// _ 24 Py_complex c_diff(Py_complex, Py_complex); 25 /// _ 26 Py_complex c_neg(Py_complex); 27 /// _ 28 Py_complex c_prod(Py_complex, Py_complex); 29 /// _ 30 Py_complex c_quot(Py_complex, Py_complex); 31 /// _ 32 Py_complex c_pow(Py_complex, Py_complex); 33 version(Python_2_6_Or_Later){ 34 /// Availability: >= 2.6 35 double c_abs(Py_complex); 36 } 37 38 /** 39 PyComplexObject represents a complex number with double-precision 40 real and imaginary parts. 41 42 subclass of PyObject. 43 */ 44 struct PyComplexObject { 45 mixin PyObject_HEAD; 46 47 /// _ 48 Py_complex cval; 49 } 50 51 /// _ 52 mixin(PyAPI_DATA!"PyTypeObject PyComplex_Type"); 53 54 // D translation of C macro: 55 /// _ 56 int PyComplex_Check()(PyObject *op) { 57 return PyObject_TypeCheck(op, &PyComplex_Type); 58 } 59 // D translation of C macro: 60 /// _ 61 int PyComplex_CheckExact()(PyObject *op) { 62 return Py_TYPE(op) == &PyComplex_Type; 63 } 64 65 /// _ 66 PyObject* PyComplex_FromCComplex(Py_complex); 67 /// _ 68 PyObject* PyComplex_FromDoubles(double real_, double imag); 69 /// _ 70 double PyComplex_RealAsDouble(PyObject* op); 71 /// _ 72 double PyComplex_ImagAsDouble(PyObject* op); 73 /// _ 74 Py_complex PyComplex_AsCComplex(PyObject* op); 75 76 version(Python_3_0_Or_Later) { 77 /// Availability: 3.* 78 PyObject* _PyComplex_FormatAdvanced( 79 PyObject* obj, 80 Py_UNICODE* format_spec, 81 Py_ssize_t format_spec_len); 82 }else version(Python_2_7_Or_Later) { 83 /** Format the object based on the format_spec, as defined in PEP 3101 84 (Advanced String Formatting). */ 85 /// Availability: >= 2.6 86 PyObject* _PyComplex_FormatAdvanced( 87 PyObject* obj, 88 char* format_spec, 89 Py_ssize_t format_spec_len); 90 } 91 92