Python クラスを .pyx ファイル内の拡張型に変換しました。このオブジェクトを別の Cython モジュールで作成できますが、静的型付けを行うことはできません。
これが私のクラスの一部です:
cdef class PatternTree:
cdef public PatternTree previous
cdef public PatternTree next
cdef public PatternTree parent
cdef public list children
cdef public int type
cdef public unicode name
cdef public dict attributes
cdef public list categories
cdef public unicode output
def __init__(self, name, parent=None, nodeType=XML):
# Some code
cpdef int isExpressions(self):
# Some code
cpdef MatchResult isMatch(self, PatternTree other):
# Some code
# More functions...
.pxd ファイルを使用して宣言しようとしましたが、すべての関数で「C メソッド [一部の関数] が宣言されていますが、定義されていません」と表示されます。また、実装の関数で C のものを削除して、拡張クラスのように動作させようとしましたが、それもうまくいきませんでした。
これが私の.pxdです。
cdef class PatternTree:
cdef public PatternTree previous
cdef public PatternTree next
cdef public PatternTree parent
cdef public list children
cdef public int type
cdef public unicode name
cdef public dict attributes
cdef public list categories
cdef public unicode output
# Functions
cpdef int isExpressions(self)
cpdef MatchResult isMatch(self, PatternTree other)
ご協力いただきありがとうございます!