あなたが何を求めているのかはわかりませんが、私が理解している限りでは、必要なものを公開するだけです (ここではState
タイプ)。
あなた.pyx
またはあなたの.pxd
:
(質問のコードが という名前のファイルの一部であると仮定しますmy_eigen.h
)
# Expose State
cdef extern from "some_path/my_eigen.h" namespace "xyz" :
cdef cppclass States:
# Expose only what you need here
pass
上記のラッピングが完了State
すると、Cython コードの必要な場所で自由に使用できます。
# Use State as is in your custom wrapped class
cdef extern from "my_class_header.h" namespace "my_ns" :
cdef cppclass MyClassUsingStates:
double getElement(States s, int row, int col)
...
例:
ここで私の必要性は次のとおりでした:Pythonハンドラーを持ち、std::ofstream
そのメソッドを公開する必要はありません(したがって、何も公開しませんでしたが、可能だったでしょう...)
cdef extern from "<fstream>" namespace "std" :
cdef cppclass ofstream:
pass
cdef class Py_ofstream:
cdef ofstream *thisptr
def __cinit__(self):
self.thisptr = new ofstream()
def __dealloc__(self):
if self.thisptr:
del self.thisptr
.pyx
注:ここでは、 (追加なしで)単一のブロックとして直接使用しました.pyd
。
質問を誤解していたら教えてください...