2
のC部に使用されるCythonコードで列挙Iが定義されているとcythonヘッダーファイルapi.pxd
でenum
:cdef
にctypedef
を回転する動作になる場合、私もチェックして定義コード
ctypedef enum InstructionType:
default = 0
end_if = 1
end_loop = 2
backward_jump_here = 4
(それしなかった)。
そして、私はいくつかのクラスFO __cinit__
メソッドでこの列挙からの値を使用したい:
from api cimport Instruction, CLinVM, InstructionType
# (...) some other classes
cdef class EndIf(Noop):
def __cinit__(self):
self.type = InstructionType.end_if
そして、私はコンパイルエラーを取得:ように列挙型を定義し、使用する
self.type = InstructionType.end_if
^
------------------------------------------------------------
/home/(...)/instructions.pyx:149:35: 'InstructionType' is not a constant,
任意の方法を?
この定数には、 'end_if'という名前でアクセスできます。ヒントありがとう! –