Skip to content

Commit

Permalink
[Python] Clarify CxxFunc1(Py) definition
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Jul 1, 2023
1 parent 1a73899 commit 16f9230
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions interfaces/cython/cantera/func1.pxd
Expand Up @@ -6,13 +6,20 @@

from .ctcxx cimport *

cdef extern from "cantera/numerics/Func1.h":
cdef cppclass CxxFunc1 "Cantera::Func1":
double eval(double) except +translate_exception

cdef cppclass CxxTabulated1 "Cantera::Tabulated1" (CxxFunc1):
CxxTabulated1(int, double*, double*, string) except +translate_exception
double eval(double) except +translate_exception

cdef extern from "cantera/cython/funcWrapper.h":
ctypedef double (*callback_wrapper)(double, void*, void**) except? 0.0
cdef int translate_exception()

cdef cppclass CxxFunc1 "Func1Py":
CxxFunc1(callback_wrapper, void*)
double eval(double) except +translate_exception
cdef cppclass CxxFunc1Py "Func1Py" (CxxFunc1):
CxxFunc1Py(callback_wrapper, void*)

cdef cppclass PyFuncInfo:
PyFuncInfo()
Expand All @@ -24,12 +31,6 @@ cdef extern from "cantera/cython/funcWrapper.h":
void setExceptionValue(PyObject*)


cdef extern from "cantera/numerics/Func1.h":
cdef cppclass CxxTabulated1 "Cantera::Tabulated1":
CxxTabulated1(int, double*, double*, string) except +translate_exception
double eval(double) except +translate_exception


cdef class Func1:
cdef shared_ptr[CxxFunc1] _func
cdef CxxFunc1* func
Expand Down
2 changes: 1 addition & 1 deletion interfaces/cython/cantera/func1.pyx
Expand Up @@ -90,7 +90,7 @@ cdef class Func1:

cpdef void _set_callback(self, c) except *:
self.callable = c
self._func.reset(new CxxFunc1(func_callback, <void*>self))
self._func.reset(new CxxFunc1Py(func_callback, <void*>self))
self.func = self._func.get()

def __call__(self, t):
Expand Down

0 comments on commit 16f9230

Please sign in to comment.