1
私はcythonizeしようとしている次のC++クラスのインターフェイスを持っています。Cython:コピーコンストラクタ
class NetInfo
{
public:
NetInfo();
NetInfo(NetInfo const& rhs);
virtual ~NetInfo();
void swap(NetInfo& rhs) throw();
NetInfo& operator=(NetInfo rhs);
...
}
これまで私がこれまで行ってきたことです。コピーコンストラクタを実装する方法は完全にはわかりません。私はCythonユーザーガイドで例を見ていません。コピー構築の問題は、PyNetInfoオブジェクトである「その他」からNetInfoオブジェクトを取得する方法です。何か案は?
cdef extern from 'NetInfo.h' namespace '...':
cdef cppclass NetInfo:
NetInfo() except +
NetInfo(NetInfo&) except +
operator=(NetInfo) except +
...
cdef class PyNetInfo:
cdef NetInfo* thisptr
def __cinit__(self, PyNetInfo other=None):
cdef PyNetInfo ostr
if other and type(other) is PyNetInfo:
ostr = <PyNetInfo> other
self.thisptr = ostr.thisptr
else:
self.thisptr = new NetInfo()
def __dealloc__(self):
del self.thisptr