← Back to team overview

kicad-developers team mailing list archive

Python binding of enums


I'm preparing the plot option class for script binding and I looked into
the generated swig stuff (horrible stuff indeed!). What concernes me are
enums... in its own typelessness it seems that python handles them as
int. Also it seems to me that no domain checking is done by SWIG (unless
I missed some magical function)

Am I right? Then I'd have to handle domain validation at least in the
accessor for the members. Example: colors; they go for 0 to 23 and are
in an enum so they are moderately checked at least by the compiler (I
have a ColorFromInt which asserts this fact);
after binding SetColor(100) would be accepted by python and trigger
a segfault on access (that's not good in my book).

It's all of this correct?

Lorenzo Marcantonio
Logos Srl

Follow ups