← Back to team overview

kicad-developers team mailing list archive

Re: Python binding of enums

 

On Thu, Aug 09, 2012 at 04:30:08PM +0200, Miguel Angel Ajo Pelayo wrote:
> and if somebody does layer[n] somehow with n> elementsOf(layer) , we will

And everyone is doing this XD even the legacy parser would die with
a malformed file calling for layer 45; it's debateable if such an error
from a file should be tolerated but a scripting iterface shouldn't crash
the host...

> And the proposal was to think about throwing an standard C++ exception in
> cases where it can be
> dangerous to receive some kind of unexpected parameter. That is, something
> that will yet compile and work
> even if scripting is compiled out. And it's even something that can be good
> the day we're reading (for example)
> from a broken file.

I usually trap these things with assertions; from assertions to
exception the way is not too long (maybe there is something in boost to
make them a little less obtrusive)

> Anyway, as I told before we have other options, we must choose the wise one.

Better sort off issues now before getting too committed... for example
did you look into Boost.Python? it seems to correctly support the
problem at hand
(http://www.boost.org/doc/libs/1_50_0/libs/python/doc/tutorial/doc/html/python/object.html#python.enums)
but maybe totally sucks for other stuff XD

-- 
Lorenzo Marcantonio
Logos Srl


References