← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Type refactoring - needs *extensive* testing


Good work :D,and also fast! ;)

2012/5/9 Lorenzo Marcantonio <l.marcantonio@xxxxxxxxxxxx>

> The witch hunt gave its fruits. The patch is a biggie, now I'm testing
> it but obviously some bug could have crept it (aka the 'shit happens'
> principle).
> This would contribute to the C++-ification of kicad and also remove some
> slight nearly-impossible-to-hit bugs (bonus point: what's the difference
> compiler tags the error).
> What happened:
> - On the exterior *nothing*, I hope. It's only an innard rework.
> - PCB/gerber layers representation changed from int to enum (and
>  corresponding operators added). Newer g++ flags as error the assigment
>  of an int to and enum! So it's more like a 'lightweight' class...
>  We now have the PCB_LAYER_NUMBER and the PCB_LAYER_MASK. The
>  GetLayerMask() was put inline in the header so we'll never seen the
>  ugly (1 << layer) construct. PCB_LAYER_MASK has the appropriate
>  boolean operators so they're handy to manipulate. Bonus: it's a big
>  step for adding new layers since these are some big abstractions
>  anyway (at least they flag every place where a layer/mask is used).
>  Calls to LayerFromInt and static_cast mark 'difficult' places.
> - Many #defines converted to static const; that's the C++ style
> - The same enum-conversion was applied to colors. Now colors are not
>  anymore anonymous ints but the EDA_COLOR_T is fully employed. As
>  someone already know EDA_COLOR_T also carries some flags and the alpha
>  should value in the higher bits. Some functions help encapsulate this.
>  Also used the MakeColour when possible instead of accessing the raw
>  rgb fields.
> - GRDrawMode encapsulated as an enum, too (it's a bit field struct,
>  anyway, but enums help the compiler keeping them separate).
> - Completely removed m_Layer from the SCH_ITEM classes; now these are
>  identified by the class only (i.e. no more subtype for lines which
>  before could represent wires, buses or even graphic lines). The
>  refactored classes were the line and bus entry. A factory load
>  function is used to create the right class depending on the input
>  record.
> - Removed SCH_POLYLINE since it was never implemented anyway
> - Some global renamed with the proper prefix (eg. Drc_On -> g_Drc_on)
> (still have to find the source for the 'same color of the background'
> message, 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
+34 636 52 25 69
skype: ajoajoajo

Follow ups