BaseSpec "constructor" from C pointer.

This commit is contained in:
Marek Nečada 2021-08-21 19:05:49 +03:00
parent 80ee8b0d53
commit 314cde1b99
2 changed files with 13 additions and 0 deletions

View File

@ -6,4 +6,6 @@ cdef class BaseSpec:
cdef qpms_vswf_set_spec_t s cdef qpms_vswf_set_spec_t s
cdef np.ndarray __ilist cdef np.ndarray __ilist
@staticmethod
cdef BaseSpec from_cpointer(const qpms_vswf_set_spec_t *orig)
cdef qpms_vswf_set_spec_t *rawpointer(BaseSpec self) cdef qpms_vswf_set_spec_t *rawpointer(BaseSpec self)

View File

@ -27,6 +27,7 @@ try:
except AttributeError: # For older Python versions, use IntEnum instead except AttributeError: # For older Python versions, use IntEnum instead
VSWFNorm = enum.IntEnum('VSWFNorm', names=__VSWF_norm_dict, module=__name__) VSWFNorm = enum.IntEnum('VSWFNorm', names=__VSWF_norm_dict, module=__name__)
cdef class BaseSpec: cdef class BaseSpec:
'''Cython wrapper over qpms_vswf_set_spec_t. '''Cython wrapper over qpms_vswf_set_spec_t.
@ -39,6 +40,16 @@ cdef class BaseSpec:
#cdef np.ndarray __ilist # in pxd #cdef np.ndarray __ilist # in pxd
#cdef const qpms_uvswfi_t[:] __ilist #cdef const qpms_uvswfi_t[:] __ilist
@staticmethod
cdef BaseSpec from_cpointer(const qpms_vswf_set_spec_t *orig):
'''Makes an instance of BaseSpec from an existing
C pointer, copying the contents
'''
cdef const qpms_uvswfi_t[::1] ilist_orig = <qpms_uvswfi_t[:orig[0].n]> orig[0].ilist
cdef BaseSpec bs = BaseSpec(ilist_orig)
bs.s.norm = orig[0].norm
return bs
def __cinit__(self, *args, **kwargs): def __cinit__(self, *args, **kwargs):
cdef const qpms_uvswfi_t[:] ilist_memview cdef const qpms_uvswfi_t[:] ilist_memview
if len(args) == 0: if len(args) == 0: