@@ -21,7 +21,7 @@ extern "C" {
2121#include " casts.h"
2222#include " dtype.h"
2323
24- #define NUM_CASTS 33 // 16 to_casts + 16 from_casts + 1 quad_to_quad
24+ #define NUM_CASTS 34 // 16 to_casts + 16 from_casts + 1 quad_to_quad + 1 void_to_quad
2525
2626static NPY_CASTING
2727quad_to_quad_resolve_descriptors (PyObject *NPY_UNUSED (self),
@@ -151,6 +151,27 @@ quad_to_quad_strided_loop_aligned(PyArrayMethod_Context *context, char *const da
151151 return 0 ;
152152}
153153
154+
155+ static NPY_CASTING
156+ void_to_quad_resolve_descriptors (PyObject *NPY_UNUSED (self), PyArray_DTypeMeta *dtypes[2],
157+ PyArray_Descr *given_descrs[2], PyArray_Descr *loop_descrs[2],
158+ npy_intp *view_offset)
159+ {
160+ PyErr_SetString (PyExc_TypeError,
161+ " Void to QuadPrecision cast is not implemented" );
162+ return (NPY_CASTING)-1 ;
163+ }
164+
165+ static int
166+ void_to_quad_strided_loop (PyArrayMethod_Context *context, char *const data[],
167+ npy_intp const dimensions[], npy_intp const strides[],
168+ void *NPY_UNUSED (auxdata))
169+ {
170+ PyErr_SetString (PyExc_RuntimeError, " void_to_quad_strided_loop should not be called" );
171+ return -1 ;
172+ }
173+
174+
154175// Tag dispatching to ensure npy_bool/npy_ubyte and npy_half/npy_ushort do not alias in templates
155176// see e.g. https://stackoverflow.com/q/32522279
156177struct spec_npy_bool {};
@@ -805,6 +826,24 @@ init_casts_internal(void)
805826
806827 add_spec (quad2quad_spec);
807828
829+ PyArray_DTypeMeta **void_dtypes = new PyArray_DTypeMeta *[2 ]{&PyArray_VoidDType, &QuadPrecDType};
830+ PyType_Slot *void_slots = new PyType_Slot[]{
831+ {NPY_METH_resolve_descriptors, (void *)&void_to_quad_resolve_descriptors},
832+ {NPY_METH_strided_loop, (void *)&void_to_quad_strided_loop},
833+ {NPY_METH_unaligned_strided_loop, (void *)&void_to_quad_strided_loop},
834+ {0 , nullptr }};
835+
836+ PyArrayMethod_Spec *void_spec = new PyArrayMethod_Spec{
837+ .name = " cast_Void_to_QuadPrec_ERROR" ,
838+ .nin = 1 ,
839+ .nout = 1 ,
840+ .casting = NPY_UNSAFE_CASTING,
841+ .flags = NPY_METH_SUPPORTS_UNALIGNED,
842+ .dtypes = void_dtypes,
843+ .slots = void_slots,
844+ };
845+ add_spec (void_spec);
846+
808847 add_cast_to<spec_npy_bool>(&PyArray_BoolDType);
809848 add_cast_to<npy_byte>(&PyArray_ByteDType);
810849 add_cast_to<npy_ubyte>(&PyArray_UByteDType);
0 commit comments