Switch shared_ptr creation to using make_shared

This commit is contained in:
Ian McInerney 2020-08-15 01:37:23 +01:00
parent 198d9a4243
commit ade7f529b8
2 changed files with 55 additions and 98 deletions

View File

@ -143,74 +143,33 @@ std::vector<std::reference_wrapper<RC_ITEM>> ERC_ITEM::allItemTypes( {
std::shared_ptr<ERC_ITEM> ERC_ITEM::Create( int aErrorCode )
{
ERC_ITEM *item;
switch( aErrorCode )
{
case ERCE_DUPLICATE_SHEET_NAME:
item = new ERC_ITEM( duplicateSheetName ); break;
case ERCE_PIN_NOT_CONNECTED:
item = new ERC_ITEM( pinNotConnected ); break;
case ERCE_PIN_NOT_DRIVEN:
item = new ERC_ITEM( pinNotDriven ); break;
case ERCE_PIN_TO_PIN_WARNING:
item = new ERC_ITEM( pinTableWarning ); break;
case ERCE_PIN_TO_PIN_ERROR:
item = new ERC_ITEM( pinTableError ); break;
case ERCE_HIERACHICAL_LABEL:
item = new ERC_ITEM( hierLabelMismatch ); break;
case ERCE_NOCONNECT_CONNECTED:
item = new ERC_ITEM( noConnectConnected ); break;
case ERCE_NOCONNECT_NOT_CONNECTED:
item = new ERC_ITEM( noConnectDangling ); break;
case ERCE_LABEL_NOT_CONNECTED:
item = new ERC_ITEM( labelDangling ); break;
case ERCE_SIMILAR_LABELS:
item = new ERC_ITEM( similarLabels ); break;
case ERCE_DIFFERENT_UNIT_FP:
item = new ERC_ITEM( differentUnitFootprint ); break;
case ERCE_DIFFERENT_UNIT_NET:
item = new ERC_ITEM( differentUnitNet ); break;
case ERCE_BUS_ALIAS_CONFLICT:
item = new ERC_ITEM( busDefinitionConflict ); break;
case ERCE_DRIVER_CONFLICT:
item = new ERC_ITEM( multipleNetNames ); break;
case ERCE_BUS_ENTRY_CONFLICT:
item = new ERC_ITEM( netNotBusMember ); break;
case ERCE_BUS_LABEL_ERROR:
item = new ERC_ITEM( busLabelSyntax ); break;
case ERCE_BUS_TO_BUS_CONFLICT:
item = new ERC_ITEM( busToBusConflict ); break;
case ERCE_BUS_TO_NET_CONFLICT:
item = new ERC_ITEM( busToNetConflict ); break;
case ERCE_GLOBLABEL:
item = new ERC_ITEM( globalLabelDangling ); break;
case ERCE_UNRESOLVED_VARIABLE:
item = new ERC_ITEM( unresolvedVariable ); break;
case ERCE_DUPLICATE_SHEET_NAME: return std::make_shared<ERC_ITEM>( duplicateSheetName );
case ERCE_PIN_NOT_CONNECTED: return std::make_shared<ERC_ITEM>( pinNotConnected );
case ERCE_PIN_NOT_DRIVEN: return std::make_shared<ERC_ITEM>( pinNotDriven );
case ERCE_PIN_TO_PIN_WARNING: return std::make_shared<ERC_ITEM>( pinTableWarning );
case ERCE_PIN_TO_PIN_ERROR: return std::make_shared<ERC_ITEM>( pinTableError );
case ERCE_HIERACHICAL_LABEL: return std::make_shared<ERC_ITEM>( hierLabelMismatch );
case ERCE_NOCONNECT_CONNECTED: return std::make_shared<ERC_ITEM>( noConnectConnected );
case ERCE_NOCONNECT_NOT_CONNECTED: return std::make_shared<ERC_ITEM>( noConnectDangling );
case ERCE_LABEL_NOT_CONNECTED: return std::make_shared<ERC_ITEM>( labelDangling );
case ERCE_SIMILAR_LABELS: return std::make_shared<ERC_ITEM>( similarLabels );
case ERCE_DIFFERENT_UNIT_FP: return std::make_shared<ERC_ITEM>( differentUnitFootprint );
case ERCE_DIFFERENT_UNIT_NET: return std::make_shared<ERC_ITEM>( differentUnitNet );
case ERCE_BUS_ALIAS_CONFLICT: return std::make_shared<ERC_ITEM>( busDefinitionConflict );
case ERCE_DRIVER_CONFLICT: return std::make_shared<ERC_ITEM>( multipleNetNames );
case ERCE_BUS_ENTRY_CONFLICT: return std::make_shared<ERC_ITEM>( netNotBusMember );
case ERCE_BUS_LABEL_ERROR: return std::make_shared<ERC_ITEM>( busLabelSyntax );
case ERCE_BUS_TO_BUS_CONFLICT: return std::make_shared<ERC_ITEM>( busToBusConflict );
case ERCE_BUS_TO_NET_CONFLICT: return std::make_shared<ERC_ITEM>( busToNetConflict );
case ERCE_GLOBLABEL: return std::make_shared<ERC_ITEM>( globalLabelDangling );
case ERCE_UNRESOLVED_VARIABLE: return std::make_shared<ERC_ITEM>( unresolvedVariable );
case ERCE_UNSPECIFIED:
default:
wxFAIL_MSG( "Unknown ERC error code" );
return nullptr;
}
return std::shared_ptr<ERC_ITEM>( item );
return nullptr;
}

View File

@ -201,48 +201,46 @@ std::vector<std::reference_wrapper<RC_ITEM>> DRC_ITEM::allItemTypes( {
std::shared_ptr<DRC_ITEM> DRC_ITEM::Create( int aErrorCode )
{
DRC_ITEM *item = nullptr;
switch( aErrorCode )
{
case DRCE_UNCONNECTED_ITEMS: item = new DRC_ITEM( unconnectedItems ); break;
case DRCE_SHORTING_ITEMS: item = new DRC_ITEM( shortingItems ); break;
case DRCE_ALLOWED_ITEMS: item = new DRC_ITEM( itemsNotAllowed ); break;
case DRCE_CLEARANCE: item = new DRC_ITEM( clearance ); break;
case DRCE_TRACKS_CROSSING: item = new DRC_ITEM( tracksCrossing ); break;
case DRCE_COPPER_EDGE_CLEARANCE: item = new DRC_ITEM( copperEdgeClearance ); break;
case DRCE_ZONES_INTERSECT: item = new DRC_ITEM( zonesIntersect ); break;
case DRCE_ZONE_HAS_EMPTY_NET: item = new DRC_ITEM( zoneHasEmptyNet ); break;
case DRCE_DANGLING_VIA: item = new DRC_ITEM( viaDangling ); break;
case DRCE_DANGLING_TRACK: item = new DRC_ITEM( trackDangling ); break;
case DRCE_DRILLED_HOLES_TOO_CLOSE: item = new DRC_ITEM( holeNearHole ); break;
case DRCE_TRACK_WIDTH: item = new DRC_ITEM( trackWidth ); break;
case DRCE_TOO_SMALL_VIA: item = new DRC_ITEM( viaTooSmall ); break;
case DRCE_VIA_ANNULUS: item = new DRC_ITEM( viaAnnulus ); break;
case DRCE_TOO_SMALL_DRILL: item = new DRC_ITEM( drillTooSmall ); break;
case DRCE_VIA_HOLE_BIGGER: item = new DRC_ITEM( viaHoleLargerThanPad ); break;
case DRCE_PADSTACK: item = new DRC_ITEM( padstack ); break;
case DRCE_TOO_SMALL_MICROVIA: item = new DRC_ITEM( microviaTooSmall ); break;
case DRCE_TOO_SMALL_MICROVIA_DRILL: item = new DRC_ITEM( microviaDrillTooSmall ); break;
case DRCE_KEEPOUT: item = new DRC_ITEM( keepout ); break;
case DRCE_OVERLAPPING_FOOTPRINTS: item = new DRC_ITEM( courtyardsOverlap ); break;
case DRCE_MISSING_COURTYARD: item = new DRC_ITEM( missingCourtyard ); break;
case DRCE_MALFORMED_COURTYARD: item = new DRC_ITEM( malformedCourtyard ); break;
case DRCE_PTH_IN_COURTYARD: item = new DRC_ITEM( pthInsideCourtyard ); break;
case DRCE_NPTH_IN_COURTYARD: item = new DRC_ITEM( npthInsideCourtyard ); break;
case DRCE_DISABLED_LAYER_ITEM: item = new DRC_ITEM( itemOnDisabledLayer ); break;
case DRCE_INVALID_OUTLINE: item = new DRC_ITEM( invalidOutline ); break;
case DRCE_MISSING_FOOTPRINT: item = new DRC_ITEM( duplicateFootprints ); break;
case DRCE_DUPLICATE_FOOTPRINT: item = new DRC_ITEM( missingFootprint ); break;
case DRCE_EXTRA_FOOTPRINT: item = new DRC_ITEM( extraFootprint ); break;
case DRCE_UNRESOLVED_VARIABLE: item = new DRC_ITEM( unresolvedVariable ); break;
case DRCE_UNCONNECTED_ITEMS: return std::make_shared<DRC_ITEM>( unconnectedItems );
case DRCE_SHORTING_ITEMS: return std::make_shared<DRC_ITEM>( shortingItems );
case DRCE_ALLOWED_ITEMS: return std::make_shared<DRC_ITEM>( itemsNotAllowed );
case DRCE_CLEARANCE: return std::make_shared<DRC_ITEM>( clearance );
case DRCE_TRACKS_CROSSING: return std::make_shared<DRC_ITEM>( tracksCrossing );
case DRCE_COPPER_EDGE_CLEARANCE: return std::make_shared<DRC_ITEM>( copperEdgeClearance );
case DRCE_ZONES_INTERSECT: return std::make_shared<DRC_ITEM>( zonesIntersect );
case DRCE_ZONE_HAS_EMPTY_NET: return std::make_shared<DRC_ITEM>( zoneHasEmptyNet );
case DRCE_DANGLING_VIA: return std::make_shared<DRC_ITEM>( viaDangling );
case DRCE_DANGLING_TRACK: return std::make_shared<DRC_ITEM>( trackDangling );
case DRCE_DRILLED_HOLES_TOO_CLOSE: return std::make_shared<DRC_ITEM>( holeNearHole );
case DRCE_TRACK_WIDTH: return std::make_shared<DRC_ITEM>( trackWidth );
case DRCE_TOO_SMALL_VIA: return std::make_shared<DRC_ITEM>( viaTooSmall );
case DRCE_VIA_ANNULUS: return std::make_shared<DRC_ITEM>( viaAnnulus );
case DRCE_TOO_SMALL_DRILL: return std::make_shared<DRC_ITEM>( drillTooSmall );
case DRCE_VIA_HOLE_BIGGER: return std::make_shared<DRC_ITEM>( viaHoleLargerThanPad );
case DRCE_PADSTACK: return std::make_shared<DRC_ITEM>( padstack );
case DRCE_TOO_SMALL_MICROVIA: return std::make_shared<DRC_ITEM>( microviaTooSmall );
case DRCE_TOO_SMALL_MICROVIA_DRILL: return std::make_shared<DRC_ITEM>( microviaDrillTooSmall );
case DRCE_KEEPOUT: return std::make_shared<DRC_ITEM>( keepout );
case DRCE_OVERLAPPING_FOOTPRINTS: return std::make_shared<DRC_ITEM>( courtyardsOverlap );
case DRCE_MISSING_COURTYARD: return std::make_shared<DRC_ITEM>( missingCourtyard );
case DRCE_MALFORMED_COURTYARD: return std::make_shared<DRC_ITEM>( malformedCourtyard );
case DRCE_PTH_IN_COURTYARD: return std::make_shared<DRC_ITEM>( pthInsideCourtyard );
case DRCE_NPTH_IN_COURTYARD: return std::make_shared<DRC_ITEM>( npthInsideCourtyard );
case DRCE_DISABLED_LAYER_ITEM: return std::make_shared<DRC_ITEM>( itemOnDisabledLayer );
case DRCE_INVALID_OUTLINE: return std::make_shared<DRC_ITEM>( invalidOutline );
case DRCE_MISSING_FOOTPRINT: return std::make_shared<DRC_ITEM>( duplicateFootprints );
case DRCE_DUPLICATE_FOOTPRINT: return std::make_shared<DRC_ITEM>( missingFootprint );
case DRCE_EXTRA_FOOTPRINT: return std::make_shared<DRC_ITEM>( extraFootprint );
case DRCE_UNRESOLVED_VARIABLE: return std::make_shared<DRC_ITEM>( unresolvedVariable );
default:
wxFAIL_MSG( "Unknown DRC error code" );
return nullptr;
}
return std::shared_ptr<DRC_ITEM>( item );
return nullptr;
}
@ -251,7 +249,7 @@ std::shared_ptr<DRC_ITEM> DRC_ITEM::Create( const wxString& aErrorKey )
for( const RC_ITEM& item : allItemTypes )
{
if( aErrorKey == item.GetSettingsKey() )
return std::shared_ptr<DRC_ITEM>( new DRC_ITEM( static_cast<const DRC_ITEM&>( item ) ) );
return std::make_shared<DRC_ITEM>( static_cast<const DRC_ITEM&>( item ) );
}
// This can happen if a project has old-format exclusions. Just drop these items.