From 715eddf68b6a052576a9aa0f5d5772cb0ff4783e Mon Sep 17 00:00:00 2001 From: Simon Richter Date: Wed, 8 Jun 2016 08:32:01 +0200 Subject: [PATCH] Code cleanup: remove dead code, add comment. --- bitmap2component/bitmap2cmp_gui.cpp | 10 +-- eeschema/class_netlist_object.h | 2 +- eeschema/dialogs/dialog_erc.cpp | 9 +++ .../netlist_exporter_generic.cpp | 73 ------------------- .../netlist_exporter_generic.h | 7 -- pcb_calculator/pcb_calculator.cpp | 12 +-- 6 files changed, 12 insertions(+), 101 deletions(-) diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_gui.cpp index 5caa7a6296..99ad647795 100644 --- a/bitmap2component/bitmap2cmp_gui.cpp +++ b/bitmap2component/bitmap2cmp_gui.cpp @@ -672,15 +672,7 @@ static struct IFACE : public KIFACE_I wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) { - switch( aClassId ) - { - - default: - { - KIWAY_PLAYER* frame = new BM2CMP_FRAME( aKiway, aParent ); - return frame; - } - } + return new BM2CMP_FRAME( aKiway, aParent ); } /** diff --git a/eeschema/class_netlist_object.h b/eeschema/class_netlist_object.h index 9608f908ac..403badeb51 100644 --- a/eeschema/class_netlist_object.h +++ b/eeschema/class_netlist_object.h @@ -156,7 +156,7 @@ public: m_ConnectionType = aFlg; } - NET_CONNECTION_T GetConnectionType() + NET_CONNECTION_T GetConnectionType() const { return m_ConnectionType; } diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index c709c15e14..1c17aaf3bf 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -496,6 +496,15 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) unsigned nextNet = lastNet = 0; int MinConn = NOC; + /* The netlist generated by SCH_EDIT_FRAME::BuildNetListBase is sorted + * by net number, which means we can group netlist items into ranges + * that live in the same net. The range from nextItem to the current + * item (exclusive) needs to be checked against the current item. The + * lastItem variable is used as a helper to pass the last item's number + * from one loop iteration to the next, which simplifies the initial + * pass. + */ + for( unsigned net = 0; net < objectsConnectedList->size(); net++ ) { if( objectsConnectedList->GetItemNet( lastNet ) != diff --git a/eeschema/netlist_exporters/netlist_exporter_generic.cpp b/eeschema/netlist_exporters/netlist_exporter_generic.cpp index 420d8e36a8..398e62fc8a 100644 --- a/eeschema/netlist_exporters/netlist_exporter_generic.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_generic.cpp @@ -489,79 +489,6 @@ XNODE* NETLIST_EXPORTER_GENERIC::makeListOfNets() } -bool NETLIST_EXPORTER_GENERIC::writeListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjectsList ) -{ - int ret = 0; - int netCode; - int lastNetCode = -1; - int sameNetcodeCount = 0; - wxString netName; - wxString ref; - wxString netcodeName; - char firstItemInNet[256]; - - for( unsigned ii = 0; ii < aObjectsList.size(); ii++ ) - { - SCH_COMPONENT* comp; - NETLIST_OBJECT* nitem = aObjectsList[ii]; - - // New net found, write net id; - if( ( netCode = nitem->GetNet() ) != lastNetCode ) - { - sameNetcodeCount = 0; // Items count for this net - netName = nitem->GetNetName(); - - netcodeName.Printf( wxT( "Net %d " ), netCode ); - netcodeName << wxT( "\"" ) << netName << wxT( "\"" ); - - // Add the netname without prefix, in cases we need only the - // "short" netname - netcodeName += wxT( " \"" ) + nitem->GetShortNetName() + wxT( "\"" ); - lastNetCode = netCode; - } - - if( nitem->m_Type != NET_PIN ) - continue; - - if( nitem->m_Flag != 0 ) // Redundant pin, skip it - continue; - - comp = nitem->GetComponentParent(); - - // Get the reference for the net name and the main parent component - ref = comp->GetRef( &nitem->m_SheetPath ); - if( ref[0] == wxChar( '#' ) ) - continue; // Pseudo component (Like Power symbol) - - // Print the pin list for this net, use special handling if - // 2 or more items are connected: - - // if first item for this net found, defer printing this connection - // until a second item will is found - if( ++sameNetcodeCount == 1 ) - { - snprintf( firstItemInNet, sizeof(firstItemInNet), " %s %.4s\n", - TO_UTF8( ref ), - (const char*) &aObjectsList[ii]->m_PinNum ); - } - - // Second item for this net found, print the Net name, and the - // first item - if( sameNetcodeCount == 2 ) - { - ret |= fprintf( f, "%s\n", TO_UTF8( netcodeName ) ); - ret |= fputs( firstItemInNet, f ); - } - - if( sameNetcodeCount >= 2 ) - ret |= fprintf( f, " %s %.4s\n", TO_UTF8( ref ), - (const char*) &nitem->m_PinNum ); - } - - return ret >= 0; -} - - XNODE* NETLIST_EXPORTER_GENERIC::node( const wxString& aName, const wxString& aTextualContent /* = wxEmptyString*/ ) { XNODE* n = new XNODE( wxXML_ELEMENT_NODE, aName ); diff --git a/eeschema/netlist_exporters/netlist_exporter_generic.h b/eeschema/netlist_exporters/netlist_exporter_generic.h index 89d57d57ae..71d3e512ed 100644 --- a/eeschema/netlist_exporters/netlist_exporter_generic.h +++ b/eeschema/netlist_exporters/netlist_exporter_generic.h @@ -79,13 +79,6 @@ protected: */ XNODE* node( const wxString& aName, const wxString& aTextualContent = wxEmptyString ); - /** - * Function writeGENERICListOfNets - * writes out nets (ranked by Netcode), and elements that are - * connected as part of that net. - */ - bool writeListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjectsList ); - /** * Function makeGenericRoot * builds the entire document tree for the generic export. This is factored diff --git a/pcb_calculator/pcb_calculator.cpp b/pcb_calculator/pcb_calculator.cpp index 6a9f970cb3..384bc8ed20 100644 --- a/pcb_calculator/pcb_calculator.cpp +++ b/pcb_calculator/pcb_calculator.cpp @@ -61,17 +61,7 @@ static struct IFACE : public KIFACE_I wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) { - switch( aClassId ) - { - default: - { - PCB_CALCULATOR_FRAME* frame = new PCB_CALCULATOR_FRAME( aKiway, aParent ); - return frame; - } - break; - } - - return NULL; + return new PCB_CALCULATOR_FRAME( aKiway, aParent ); } /**