Get rid of m_sortedSymbolPinList in favour of a properly scoped variable.
Fixes https://gitlab.com/kicad/code/kicad/issues/14083
(cherry picked from commit 2a79a453ec
)
This commit is contained in:
parent
33f835a437
commit
e82c21e944
|
@ -113,16 +113,18 @@ SCH_SYMBOL* NETLIST_EXPORTER_BASE::findNextSymbol( EDA_ITEM* aItem, SCH_SHEET_PA
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NETLIST_EXPORTER_BASE::CreatePinList( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPath,
|
std::vector<PIN_INFO> NETLIST_EXPORTER_BASE::CreatePinList( SCH_SYMBOL* aSymbol,
|
||||||
bool aKeepUnconnectedPins )
|
SCH_SHEET_PATH* aSheetPath,
|
||||||
|
bool aKeepUnconnectedPins )
|
||||||
{
|
{
|
||||||
wxString ref( aSymbol->GetRef( aSheetPath ) );
|
wxString ref( aSymbol->GetRef( aSheetPath ) );
|
||||||
|
std::vector<PIN_INFO> pins;
|
||||||
|
|
||||||
// Power symbols and other symbols which have the reference starting with "#" are not
|
// Power symbols and other symbols which have the reference starting with "#" are not
|
||||||
// included in netlist (pseudo or virtual symbols)
|
// included in netlist (pseudo or virtual symbols)
|
||||||
|
|
||||||
if( ref[0] == wxChar( '#' ) )
|
if( ref[0] == wxChar( '#' ) )
|
||||||
return;
|
return pins;
|
||||||
|
|
||||||
// if( aSymbol->m_FlagControlMulti == 1 )
|
// if( aSymbol->m_FlagControlMulti == 1 )
|
||||||
// continue; /* yes */
|
// continue; /* yes */
|
||||||
|
@ -130,9 +132,7 @@ void NETLIST_EXPORTER_BASE::CreatePinList( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH*
|
||||||
// 1 screen), this will be erroneously be toggled.
|
// 1 screen), this will be erroneously be toggled.
|
||||||
|
|
||||||
if( !aSymbol->GetLibSymbolRef() )
|
if( !aSymbol->GetLibSymbolRef() )
|
||||||
return;
|
return pins;
|
||||||
|
|
||||||
m_sortedSymbolPinList.clear();
|
|
||||||
|
|
||||||
// If symbol is a "multi parts per package" type
|
// If symbol is a "multi parts per package" type
|
||||||
if( aSymbol->GetLibSymbolRef()->GetUnitCount() > 1 )
|
if( aSymbol->GetLibSymbolRef()->GetUnitCount() > 1 )
|
||||||
|
@ -140,7 +140,7 @@ void NETLIST_EXPORTER_BASE::CreatePinList( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH*
|
||||||
// Collect all pins for this reference designator by searching the entire design for
|
// Collect all pins for this reference designator by searching the entire design for
|
||||||
// other parts with the same reference designator.
|
// other parts with the same reference designator.
|
||||||
// This is only done once, it would be too expensive otherwise.
|
// This is only done once, it would be too expensive otherwise.
|
||||||
findAllUnitsOfSymbol( aSymbol, aSheetPath, aKeepUnconnectedPins );
|
findAllUnitsOfSymbol( aSymbol, aSheetPath, pins, aKeepUnconnectedPins );
|
||||||
}
|
}
|
||||||
|
|
||||||
else // GetUnitCount() <= 1 means one part per package
|
else // GetUnitCount() <= 1 means one part per package
|
||||||
|
@ -161,31 +161,33 @@ void NETLIST_EXPORTER_BASE::CreatePinList( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH*
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sortedSymbolPinList.emplace_back( pin->GetShownNumber(), netName );
|
pins.emplace_back( pin->GetShownNumber(), netName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort pins in m_SortedSymbolPinList by pin number
|
// Sort pins in m_SortedSymbolPinList by pin number
|
||||||
std::sort( m_sortedSymbolPinList.begin(), m_sortedSymbolPinList.end(),
|
std::sort( pins.begin(), pins.end(),
|
||||||
[]( const PIN_INFO& lhs, const PIN_INFO& rhs )
|
[]( const PIN_INFO& lhs, const PIN_INFO& rhs )
|
||||||
{
|
{
|
||||||
return StrNumCmp( lhs.num, rhs.num, true ) < 0;
|
return StrNumCmp( lhs.num, rhs.num, true ) < 0;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// Remove duplicate Pins in m_SortedSymbolPinList
|
// Remove duplicate Pins in m_SortedSymbolPinList
|
||||||
eraseDuplicatePins();
|
eraseDuplicatePins( pins );
|
||||||
|
|
||||||
// record the usage of this library symbol
|
// record the usage of this library symbol
|
||||||
m_libParts.insert( aSymbol->GetLibSymbolRef().get() ); // rejects non-unique pointers
|
m_libParts.insert( aSymbol->GetLibSymbolRef().get() ); // rejects non-unique pointers
|
||||||
|
|
||||||
|
return pins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NETLIST_EXPORTER_BASE::eraseDuplicatePins()
|
void NETLIST_EXPORTER_BASE::eraseDuplicatePins( std::vector<PIN_INFO>& aPins )
|
||||||
{
|
{
|
||||||
for( unsigned ii = 0; ii < m_sortedSymbolPinList.size(); ii++ )
|
for( unsigned ii = 0; ii < aPins.size(); ii++ )
|
||||||
{
|
{
|
||||||
if( m_sortedSymbolPinList[ii].num.empty() ) /* already deleted */
|
if( aPins[ii].num.empty() ) /* already deleted */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Search for duplicated pins
|
/* Search for duplicated pins
|
||||||
|
@ -198,17 +200,17 @@ void NETLIST_EXPORTER_BASE::eraseDuplicatePins()
|
||||||
*/
|
*/
|
||||||
int idxref = ii;
|
int idxref = ii;
|
||||||
|
|
||||||
for( unsigned jj = ii + 1; jj < m_sortedSymbolPinList.size(); jj++ )
|
for( unsigned jj = ii + 1; jj < aPins.size(); jj++ )
|
||||||
{
|
{
|
||||||
if( m_sortedSymbolPinList[jj].num.empty() ) // Already removed
|
if( aPins[jj].num.empty() ) // Already removed
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// if other pin num, stop search,
|
// if other pin num, stop search,
|
||||||
// because all pins having the same number are consecutive in list.
|
// because all pins having the same number are consecutive in list.
|
||||||
if( m_sortedSymbolPinList[idxref].num != m_sortedSymbolPinList[jj].num )
|
if( aPins[idxref].num != aPins[jj].num )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
m_sortedSymbolPinList[jj].num.clear();
|
aPins[jj].num.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,6 +218,7 @@ void NETLIST_EXPORTER_BASE::eraseDuplicatePins()
|
||||||
|
|
||||||
void NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol( SCH_SYMBOL* aSchSymbol,
|
void NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol( SCH_SYMBOL* aSchSymbol,
|
||||||
SCH_SHEET_PATH* aSheetPath,
|
SCH_SHEET_PATH* aSheetPath,
|
||||||
|
std::vector<PIN_INFO>& aPins,
|
||||||
bool aKeepUnconnectedPins )
|
bool aKeepUnconnectedPins )
|
||||||
{
|
{
|
||||||
wxString ref = aSchSymbol->GetRef( aSheetPath );
|
wxString ref = aSchSymbol->GetRef( aSheetPath );
|
||||||
|
@ -251,7 +254,7 @@ void NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol( SCH_SYMBOL* aSchSymbol,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sortedSymbolPinList.emplace_back( pin->GetShownNumber(), netName );
|
aPins.emplace_back( pin->GetShownNumber(), netName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Find a symbol from the DrawList and builds its pin list in m_sortedSymbolPinList.
|
* Find a symbol from the DrawList and builds its pin list.
|
||||||
*
|
*
|
||||||
* This list is sorted by pin number. The symbol is the next actual symbol after \a aSymbol.
|
* This list is sorted by pin number. The symbol is the next actual symbol after \a aSymbol.
|
||||||
* Power symbols and virtual symbols that have their reference designators starting with
|
* Power symbols and virtual symbols that have their reference designators starting with
|
||||||
|
@ -155,8 +155,8 @@ protected:
|
||||||
* if aKeepUnconnectedPins = false, unconnected pins will be removed from list
|
* if aKeepUnconnectedPins = false, unconnected pins will be removed from list
|
||||||
* but usually we need all pins in netlists.
|
* but usually we need all pins in netlists.
|
||||||
*/
|
*/
|
||||||
void CreatePinList( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPath,
|
std::vector<PIN_INFO> CreatePinList( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPath,
|
||||||
bool aKeepUnconnectedPins );
|
bool aKeepUnconnectedPins );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the given symbol should be processed for netlisting.
|
* Check if the given symbol should be processed for netlisting.
|
||||||
|
@ -170,7 +170,7 @@ protected:
|
||||||
SCH_SYMBOL* findNextSymbol( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheetPath );
|
SCH_SYMBOL* findNextSymbol( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheetPath );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Erase duplicate pins from m_sortedSymbolPinList (i.e. set pointer in this list to NULL).
|
* Erase duplicate pins.
|
||||||
*
|
*
|
||||||
* (This is a list of pins found in the whole schematic, for a single symbol.) These
|
* (This is a list of pins found in the whole schematic, for a single symbol.) These
|
||||||
* duplicate pins were put in list because some pins (power pins...) are found more than
|
* duplicate pins were put in list because some pins (power pins...) are found more than
|
||||||
|
@ -179,24 +179,18 @@ protected:
|
||||||
* Note: this list *MUST* be sorted by pin number (.m_PinNum member value)
|
* Note: this list *MUST* be sorted by pin number (.m_PinNum member value)
|
||||||
* Also set the m_Flag member of "removed" NETLIST_OBJECT pin item to 1
|
* Also set the m_Flag member of "removed" NETLIST_OBJECT pin item to 1
|
||||||
*/
|
*/
|
||||||
void eraseDuplicatePins();
|
void eraseDuplicatePins( std::vector<PIN_INFO>& pins );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find all units for symbols with multiple symbols per package.
|
* Find all units for symbols with multiple symbols per package.
|
||||||
*
|
*
|
||||||
* Search the entire design for all units of \a aSymbol based on matching reference
|
* Search the entire design for all units of \a aSymbol based on matching reference
|
||||||
* designator, and for each unit, add all its pins to the temporary sorted pin list,
|
* designator, and for each unit, add all its pins to the sorted pin list.
|
||||||
* m_sortedSymbolPinList.
|
|
||||||
* if aKeepUnconnectedPins = false, unconnected pins will be removed from list
|
* if aKeepUnconnectedPins = false, unconnected pins will be removed from list
|
||||||
* but usually we need all pins in netlists.
|
* but usually we need all pins in netlists.
|
||||||
*/
|
*/
|
||||||
void findAllUnitsOfSymbol( SCH_SYMBOL* aSchSymbol, SCH_SHEET_PATH* aSheetPath,
|
void findAllUnitsOfSymbol( SCH_SYMBOL* aSchSymbol, SCH_SHEET_PATH* aSheetPath,
|
||||||
bool aKeepUnconnectedPins );
|
std::vector<PIN_INFO>& aPins, bool aKeepUnconnectedPins );
|
||||||
|
|
||||||
/// Used to temporarily store and filter the list of pins of a schematic symbol when
|
|
||||||
/// generating schematic symbol data in netlist (comp section). No ownership of members.
|
|
||||||
/// TODO(snh): Descope this object
|
|
||||||
std::vector<PIN_INFO> m_sortedSymbolPinList;
|
|
||||||
|
|
||||||
/// Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than
|
/// Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than
|
||||||
/// once
|
/// once
|
||||||
|
|
|
@ -79,7 +79,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName,
|
||||||
if( !symbol->GetIncludeOnBoard() )
|
if( !symbol->GetIncludeOnBoard() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CreatePinList( symbol, &sheet, true );
|
std::vector<PIN_INFO> pins = CreatePinList( symbol, &sheet, true );
|
||||||
|
|
||||||
if( symbol->GetLibSymbolRef()
|
if( symbol->GetLibSymbolRef()
|
||||||
&& symbol->GetLibSymbolRef()->GetFPFilters().GetCount() != 0 )
|
&& symbol->GetLibSymbolRef()->GetFPFilters().GetCount() != 0 )
|
||||||
|
@ -110,7 +110,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName,
|
||||||
ret |= fprintf( f, "\n" );
|
ret |= fprintf( f, "\n" );
|
||||||
|
|
||||||
// Write pin list:
|
// Write pin list:
|
||||||
for( const PIN_INFO& pin : m_sortedSymbolPinList )
|
for( const PIN_INFO& pin : pins )
|
||||||
{
|
{
|
||||||
if( pin.num.IsEmpty() ) // Erased pin in list
|
if( pin.num.IsEmpty() ) // Erased pin in list
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -220,7 +220,7 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions
|
||||||
if( !symbol || symbol->GetFieldText( SIM_ENABLE_FIELD ) == wxT( "0" ) )
|
if( !symbol || symbol->GetFieldText( SIM_ENABLE_FIELD ) == wxT( "0" ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CreatePinList( symbol, &sheet, true );
|
std::vector<PIN_INFO> pins = CreatePinList( symbol, &sheet, true );
|
||||||
|
|
||||||
SPICE_ITEM spiceItem;
|
SPICE_ITEM spiceItem;
|
||||||
|
|
||||||
|
@ -267,8 +267,8 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions
|
||||||
{
|
{
|
||||||
readRefName( sheet, *symbol, spiceItem, refNames );
|
readRefName( sheet, *symbol, spiceItem, refNames );
|
||||||
readModel( sheet, *symbol, spiceItem );
|
readModel( sheet, *symbol, spiceItem );
|
||||||
readPinNumbers( *symbol, spiceItem );
|
readPinNumbers( *symbol, spiceItem, pins );
|
||||||
readPinNetNames( *symbol, spiceItem, ncCounter );
|
readPinNetNames( *symbol, spiceItem, pins, ncCounter );
|
||||||
|
|
||||||
// TODO: transmission line handling?
|
// TODO: transmission line handling?
|
||||||
|
|
||||||
|
@ -533,20 +533,20 @@ void NETLIST_EXPORTER_SPICE::readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSym
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NETLIST_EXPORTER_SPICE::readPinNumbers( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem )
|
void NETLIST_EXPORTER_SPICE::readPinNumbers( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem,
|
||||||
|
const std::vector<PIN_INFO>& aPins )
|
||||||
{
|
{
|
||||||
for( const PIN_INFO& pin : m_sortedSymbolPinList )
|
for( const PIN_INFO& pin : aPins )
|
||||||
aItem.pinNumbers.emplace_back( std::string( pin.num.ToUTF8() ) );
|
aItem.pinNumbers.emplace_back( pin.num.ToStdString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NETLIST_EXPORTER_SPICE::readPinNetNames( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem,
|
void NETLIST_EXPORTER_SPICE::readPinNetNames( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem,
|
||||||
int& aNcCounter )
|
const std::vector<PIN_INFO>& aPins, int& aNcCounter )
|
||||||
{
|
{
|
||||||
for( const PIN_INFO& pinInfo : m_sortedSymbolPinList )
|
for( const PIN_INFO& pinInfo : aPins )
|
||||||
{
|
{
|
||||||
std::string netName = GenerateItemPinNetName( std::string( pinInfo.netName.ToUTF8() ),
|
std::string netName = GenerateItemPinNetName( pinInfo.netName.ToStdString(), aNcCounter );
|
||||||
aNcCounter );
|
|
||||||
|
|
||||||
aItem.pinNetNames.push_back( netName );
|
aItem.pinNetNames.push_back( netName );
|
||||||
m_nets.insert( netName );
|
m_nets.insert( netName );
|
||||||
|
|
|
@ -144,8 +144,10 @@ private:
|
||||||
void readRefName( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem,
|
void readRefName( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem,
|
||||||
std::set<std::string>& aRefNames );
|
std::set<std::string>& aRefNames );
|
||||||
void readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem );
|
void readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem );
|
||||||
void readPinNumbers( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem );
|
void readPinNumbers( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem,
|
||||||
void readPinNetNames( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem, int& aNcCounter );
|
const std::vector<PIN_INFO>& aPins );
|
||||||
|
void readPinNetNames( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem,
|
||||||
|
const std::vector<PIN_INFO>& aPins, int& aNcCounter );
|
||||||
|
|
||||||
void writeInclude( OUTPUTFORMATTER& aFormatter, unsigned aNetlistOptions,
|
void writeInclude( OUTPUTFORMATTER& aFormatter, unsigned aNetlistOptions,
|
||||||
const wxString& aPath );
|
const wxString& aPath );
|
||||||
|
|
Loading…
Reference in New Issue