From ee86a20fd2564734d56f4a905bb7bbfb2e0a1e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Mon, 15 Jul 2019 17:26:32 +0300 Subject: [PATCH] Cython nested union declaration workaround. Former-commit-id: 283cd4a381b95928321a1b8b38ec5692cf657aba --- qpms/qpms_cdefs.pxd | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/qpms/qpms_cdefs.pxd b/qpms/qpms_cdefs.pxd index ddc1d8d..d315cb3 100644 --- a/qpms/qpms_cdefs.pxd +++ b/qpms/qpms_cdefs.pxd @@ -20,6 +20,14 @@ cdef extern from "qpms_types.h": double r double theta double phi + cdef struct csph_t: + cdouble r + double theta + double phi + cdef struct csphvec_t: + cdouble rc + cdouble thetac + cdouble phic cdef struct pol_t: double r double phi @@ -104,17 +112,22 @@ cdef extern from "qpms_error.h": qpms_dbgmsg_flags qpms_dbgmsg_enable(qpms_dbgmsg_flags types) qpms_dbgmsg_flags qpms_dbgmsg_disable(qpms_dbgmsg_flags types) + +# This is due to the fact that cython apparently cannot nest the unnamed struct/unions in an obvious way +ctypedef union qpms_incfield_planewave_params_k: + ccart3_t cart + csph_t sph +ctypedef union qpms_incfield_planewave_params_E: + ccart3_t cart + csphvec_t sph + cdef extern from "vswf.h": ctypedef qpms_errno_t (*qpms_incfield_t)(cdouble target, const qpms_vswf_set_spec_t *bspec, const cart3_t evalpoint, const void *args, bint add) ctypedef struct qpms_incfield_planewave_params_t: bint use_cartesian - union k: - ccart3_t cart - csph_t sph - union E: - ccart3_t cart - csph sph + qpms_incfield_planewave_params_k k + qpms_incfield_planewave_params_E E qpms_errno_t qpms_incfield_planewave(cdouble target, const qpms_vswf_set_spec_t *bspec, const cart3_t evalpoint, const void *args, bint add)