Fix pcbnew api for DIMENSIONs
DIMENSION is now an abstract class and we should cast to concrete implementations instead. Also change broken 'return none' to throwing an exception which will give feedback about what is not supported by the API instead of silently returning a non-object.
This commit is contained in:
parent
ef48dba7ff
commit
5e0d79449e
|
@ -48,7 +48,9 @@
|
|||
|
||||
%{
|
||||
class TEXTE_PCB;
|
||||
class DIMENSION;
|
||||
class ALIGNED_DIMENSION;
|
||||
class LEADER;
|
||||
class CENTER_DIMENSION;
|
||||
class MODULE;
|
||||
class PCB_GROUP;
|
||||
class TEXTE_MODULE;
|
||||
|
@ -68,20 +70,22 @@ class PCB_TARGET;
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static TEXTE_PCB* Cast_to_TEXTE_PCB( BOARD_ITEM* );
|
||||
static DIMENSION* Cast_to_DIMENSION( BOARD_ITEM* );
|
||||
static MODULE* Cast_to_MODULE( BOARD_ITEM* );
|
||||
static PCB_GROUP* Cast_to_PCB_GROUP( BOARD_ITEM* );
|
||||
static TEXTE_MODULE* Cast_to_TEXTE_MODULE( BOARD_ITEM* );
|
||||
static DRAWSEGMENT* Cast_to_DRAWSEGMENT( BOARD_ITEM* );
|
||||
static MARKER_PCB* Cast_to_MARKER_PCB( BOARD_ITEM* );
|
||||
static BOARD* Cast_to_BOARD( BOARD_ITEM* );
|
||||
static EDGE_MODULE* Cast_to_EDGE_MODULE( BOARD_ITEM* );
|
||||
static D_PAD* Cast_to_D_PAD( BOARD_ITEM* );
|
||||
static TRACK* Cast_to_TRACK( BOARD_ITEM* );
|
||||
static VIA* Cast_to_VIA( BOARD_ITEM* );
|
||||
static ZONE_CONTAINER* Cast_to_ZONE_CONTAINER( BOARD_ITEM* );
|
||||
static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* );
|
||||
static TEXTE_PCB* Cast_to_TEXTE_PCB( BOARD_ITEM* );
|
||||
static ALIGNED_DIMENSION* Cast_to_ALIGNED_DIMENSION( BOARD_ITEM* );
|
||||
static LEADER* Cast_to_LEADER( BOARD_ITEM* );
|
||||
static CENTER_DIMENSION* Cast_to_CENTER_DIMENSION( BOARD_ITEM* );
|
||||
static MODULE* Cast_to_MODULE( BOARD_ITEM* );
|
||||
static PCB_GROUP* Cast_to_PCB_GROUP( BOARD_ITEM* );
|
||||
static TEXTE_MODULE* Cast_to_TEXTE_MODULE( BOARD_ITEM* );
|
||||
static DRAWSEGMENT* Cast_to_DRAWSEGMENT( BOARD_ITEM* );
|
||||
static MARKER_PCB* Cast_to_MARKER_PCB( BOARD_ITEM* );
|
||||
static BOARD* Cast_to_BOARD( BOARD_ITEM* );
|
||||
static EDGE_MODULE* Cast_to_EDGE_MODULE( BOARD_ITEM* );
|
||||
static D_PAD* Cast_to_D_PAD( BOARD_ITEM* );
|
||||
static TRACK* Cast_to_TRACK( BOARD_ITEM* );
|
||||
static VIA* Cast_to_VIA( BOARD_ITEM* );
|
||||
static ZONE_CONTAINER* Cast_to_ZONE_CONTAINER( BOARD_ITEM* );
|
||||
static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* );
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
@ -89,20 +93,22 @@ static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* );
|
|||
%}
|
||||
|
||||
|
||||
static TEXTE_PCB* Cast_to_TEXTE_PCB( BOARD_ITEM* );
|
||||
static DIMENSION* Cast_to_DIMENSION( BOARD_ITEM* );
|
||||
static MODULE* Cast_to_MODULE( BOARD_ITEM* );
|
||||
static PCB_GROUP* Cast_to_PCB_GROUP( BOARD_ITEM* );
|
||||
static TEXTE_MODULE* Cast_to_TEXTE_MODULE( BOARD_ITEM* );
|
||||
static DRAWSEGMENT* Cast_to_DRAWSEGMENT( BOARD_ITEM* );
|
||||
static MARKER_PCB* Cast_to_MARKER_PCB( BOARD_ITEM* );
|
||||
static BOARD* Cast_to_BOARD( BOARD_ITEM* );
|
||||
static EDGE_MODULE* Cast_to_EDGE_MODULE( BOARD_ITEM* );
|
||||
static D_PAD* Cast_to_D_PAD( BOARD_ITEM* );
|
||||
static TRACK* Cast_to_TRACK( BOARD_ITEM* );
|
||||
static VIA* Cast_to_VIA( BOARD_ITEM* );
|
||||
static ZONE_CONTAINER* Cast_to_ZONE_CONTAINER( BOARD_ITEM* );
|
||||
static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* );
|
||||
static TEXTE_PCB* Cast_to_TEXTE_PCB( BOARD_ITEM* );
|
||||
static ALIGNED_DIMENSION* Cast_to_ALIGNED_DIMENSION( BOARD_ITEM* );
|
||||
static LEADER* Cast_to_LEADER( BOARD_ITEM* );
|
||||
static CENTER_DIMENSION* Cast_to_CENTER_DIMENSION( BOARD_ITEM* );
|
||||
static MODULE* Cast_to_MODULE( BOARD_ITEM* );
|
||||
static PCB_GROUP* Cast_to_PCB_GROUP( BOARD_ITEM* );
|
||||
static TEXTE_MODULE* Cast_to_TEXTE_MODULE( BOARD_ITEM* );
|
||||
static DRAWSEGMENT* Cast_to_DRAWSEGMENT( BOARD_ITEM* );
|
||||
static MARKER_PCB* Cast_to_MARKER_PCB( BOARD_ITEM* );
|
||||
static BOARD* Cast_to_BOARD( BOARD_ITEM* );
|
||||
static EDGE_MODULE* Cast_to_EDGE_MODULE( BOARD_ITEM* );
|
||||
static D_PAD* Cast_to_D_PAD( BOARD_ITEM* );
|
||||
static TRACK* Cast_to_TRACK( BOARD_ITEM* );
|
||||
static VIA* Cast_to_VIA( BOARD_ITEM* );
|
||||
static ZONE_CONTAINER* Cast_to_ZONE_CONTAINER( BOARD_ITEM* );
|
||||
static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* );
|
||||
|
||||
|
||||
%extend BOARD_ITEM
|
||||
|
@ -117,8 +123,12 @@ static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* );
|
|||
return Cast_to_TEXTE_PCB(self)
|
||||
elif ct=="BOARD":
|
||||
return Cast_to_BOARD(self)
|
||||
elif ct=="DIMENSION":
|
||||
return Cast_to_DIMENSION(self)
|
||||
elif ct=="ALIGNED_DIMENSION":
|
||||
return Cast_to_ALIGNED_DIMENSION(self)
|
||||
elif ct=="LEADER":
|
||||
return Cast_to_LEADER(self)
|
||||
elif ct=="CENTER_DIMENSION":
|
||||
return Cast_to_CENTER_DIMENSION(self)
|
||||
elif ct=="DRAWSEGMENT":
|
||||
return Cast_to_DRAWSEGMENT(self)
|
||||
elif ct=="MGRAPHIC":
|
||||
|
@ -140,7 +150,7 @@ static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* );
|
|||
elif ct=="ZONE_CONTAINER":
|
||||
return Cast_to_ZONE_CONTAINER(self)
|
||||
else:
|
||||
return none
|
||||
raise TypeError("Unsupported drawing class: %s" % ct)
|
||||
|
||||
def Duplicate(self):
|
||||
ct = self.GetClass()
|
||||
|
@ -167,18 +177,20 @@ static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* );
|
|||
// classes and therefore will C++ compile due to the respective headers which will go into
|
||||
// the %header section. See section 5.6.2 of SWIG 3.0 documentation.
|
||||
%wrapper %{
|
||||
static TEXTE_PCB* Cast_to_TEXTE_PCB( BOARD_ITEM* self ) { return dynamic_cast<TEXTE_PCB*>(self); }
|
||||
static DIMENSION* Cast_to_DIMENSION( BOARD_ITEM* self ) { return dynamic_cast<DIMENSION*>(self); }
|
||||
static MODULE* Cast_to_MODULE( BOARD_ITEM* self ) { return dynamic_cast<MODULE*>(self); }
|
||||
static PCB_GROUP* Cast_to_PCB_GROUP( BOARD_ITEM* self ) { return dynamic_cast<PCB_GROUP*>(self); }
|
||||
static TEXTE_MODULE* Cast_to_TEXTE_MODULE( BOARD_ITEM* self ) { return dynamic_cast<TEXTE_MODULE*>(self); }
|
||||
static DRAWSEGMENT* Cast_to_DRAWSEGMENT( BOARD_ITEM* self ) { return dynamic_cast<DRAWSEGMENT*>(self); }
|
||||
static MARKER_PCB* Cast_to_MARKER_PCB( BOARD_ITEM* self ) { return dynamic_cast<MARKER_PCB*>(self); }
|
||||
static BOARD* Cast_to_BOARD( BOARD_ITEM* self ) { return dynamic_cast<BOARD*>(self); }
|
||||
static EDGE_MODULE* Cast_to_EDGE_MODULE( BOARD_ITEM* self ) { return dynamic_cast<EDGE_MODULE*>(self); }
|
||||
static D_PAD* Cast_to_D_PAD( BOARD_ITEM* self ) { return dynamic_cast<D_PAD*>(self); }
|
||||
static TRACK* Cast_to_TRACK( BOARD_ITEM* self ) { return dynamic_cast<TRACK*>(self); }
|
||||
static VIA* Cast_to_VIA( BOARD_ITEM* self ) { return dynamic_cast<VIA*>(self); }
|
||||
static ZONE_CONTAINER* Cast_to_ZONE_CONTAINER( BOARD_ITEM* self ) { return dynamic_cast<ZONE_CONTAINER*>(self); }
|
||||
static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* self ) { return dynamic_cast<PCB_TARGET*>(self); }
|
||||
static TEXTE_PCB* Cast_to_TEXTE_PCB( BOARD_ITEM* self ) { return dynamic_cast<TEXTE_PCB*>(self); }
|
||||
static ALIGNED_DIMENSION* Cast_to_ALIGNED_DIMENSION( BOARD_ITEM* self ) { return dynamic_cast<ALIGNED_DIMENSION*>(self); }
|
||||
static LEADER* Cast_to_LEADER( BOARD_ITEM* self ) { return dynamic_cast<LEADER*>(self); }
|
||||
static CENTER_DIMENSION* Cast_to_CENTER_DIMENSION( BOARD_ITEM* self ) { return dynamic_cast<CENTER_DIMENSION*>(self); }
|
||||
static MODULE* Cast_to_MODULE( BOARD_ITEM* self ) { return dynamic_cast<MODULE*>(self); }
|
||||
static PCB_GROUP* Cast_to_PCB_GROUP( BOARD_ITEM* self ) { return dynamic_cast<PCB_GROUP*>(self); }
|
||||
static TEXTE_MODULE* Cast_to_TEXTE_MODULE( BOARD_ITEM* self ) { return dynamic_cast<TEXTE_MODULE*>(self); }
|
||||
static DRAWSEGMENT* Cast_to_DRAWSEGMENT( BOARD_ITEM* self ) { return dynamic_cast<DRAWSEGMENT*>(self); }
|
||||
static MARKER_PCB* Cast_to_MARKER_PCB( BOARD_ITEM* self ) { return dynamic_cast<MARKER_PCB*>(self); }
|
||||
static BOARD* Cast_to_BOARD( BOARD_ITEM* self ) { return dynamic_cast<BOARD*>(self); }
|
||||
static EDGE_MODULE* Cast_to_EDGE_MODULE( BOARD_ITEM* self ) { return dynamic_cast<EDGE_MODULE*>(self); }
|
||||
static D_PAD* Cast_to_D_PAD( BOARD_ITEM* self ) { return dynamic_cast<D_PAD*>(self); }
|
||||
static TRACK* Cast_to_TRACK( BOARD_ITEM* self ) { return dynamic_cast<TRACK*>(self); }
|
||||
static VIA* Cast_to_VIA( BOARD_ITEM* self ) { return dynamic_cast<VIA*>(self); }
|
||||
static ZONE_CONTAINER* Cast_to_ZONE_CONTAINER( BOARD_ITEM* self ) { return dynamic_cast<ZONE_CONTAINER*>(self); }
|
||||
static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* self ) { return dynamic_cast<PCB_TARGET*>(self); }
|
||||
%}
|
||||
|
|
Loading…
Reference in New Issue