← Back to team overview

kicad-developers team mailing list archive

Re: Python binding of enums

 

I keep reading and thinking.

And one idea comes to my mind:

Why don't we do those checks on the python side, but, with one
restriction (to cut out the maintenance drawback): have the MAX_VALUE
/ MIN_VALUE for every enum in C++, example:


#define LAYER_0 1
#define LAYER_1 2
#define LAYER_2 4
....
#define LAYER_31 (1<<31)
#define ALL_CU_LAYERS 65535

#define MIN_LAYER 0
#define MAX_LAYER ALL_CU_LAYERS

Swig will perfectly convert it to Python constants (
http://www.swig.org/Doc2.0/SWIGDocumentation.html#SWIG_nn12 )

So, in the end, the min/max checking is done in the scripting side,
and the MIN/MAX values are keep near the enum (or constants)
definition.

Then, those min/max values will be available for boundary checking in
IO, or other places were needed in KiCAD C++ too.


So we can start by "A" and plant the min/max and then go to "?"
(whatever was the option to check the parameters at .py land).


2012/8/10 Lorenzo Marcantonio <l.marcantonio@xxxxxxxxxxxx>:
> On Thu, Aug 09, 2012 at 02:00:45PM -0500, Dick Hollenbeck wrote:
>> I did not cast my vote.  I was just saying it should be discussed then decided upon.  Some
>> costs are worth the benefit.
>
> I agree that scripting would be very useful... never said the opposite.
>
> OK, another idea: we start with plan A (i.e. who care what garbage the
> user pass in) and, as a 'background project' python people implements
> the interface checks (this could be done while documenting, for example)
>
> It's a little dangerous but being open source and all we can survive
> without issues to scripting being in 'beta' until we have finished. In
> the meantime scripting is usable (with care) anyway.
>
> --
> 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