kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #08753
Re: Python binding of enums
2012/8/9 Lorenzo Marcantonio <l.marcantonio@xxxxxxxxxxxx>:
> I'm preparing the plot option class for script binding and I looked into
> the generated swig stuff (horrible stuff indeed!).
Haha, that .py and .cpp is not for humans, but for python and g++ :-)
> 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)
I'm not sure if it's checked in the C++ part of the wrapper, (cannot
tell you, never checked it),
but they do a ton of run-time checks for types, throwing python
exceptions for bad situations.
But for enums, I don't know, I'm checking and I tell you in some minutes.
>
> 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).
We should avoid that situation.
>
> It's all of this correct?
>
I'm checking :)
>
> --
> Lorenzo Marcantonio
> Logos Srl
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
--
Miguel Angel Ajo Pelayo
http://www.nbee.es
+34 636 52 25 69
skype: ajoajoajo
Follow ups
References