Sim: Sort the generated Sim.Pins by symbol pin numbers
They were sorted by model pin numbers, which weren't the keys in the key=value pairs generated into Sim.Pins.
This commit is contained in:
parent
74a2e4cad9
commit
6d5cc9e606
|
@ -29,6 +29,7 @@
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
#include <boost/algorithm/string/case_conv.hpp>
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
|
#include <string_utils.h>
|
||||||
|
|
||||||
|
|
||||||
namespace SIM_SERDE_PARSER
|
namespace SIM_SERDE_PARSER
|
||||||
|
@ -111,14 +112,27 @@ std::string SIM_SERDE::GeneratePins() const
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
|
|
||||||
for( int i = 0; i < m_model.GetPinCount(); ++i )
|
std::vector<std::reference_wrapper<const SIM_MODEL::PIN>> pins = m_model.GetPins();
|
||||||
{
|
|
||||||
const SIM_MODEL::PIN& pin = m_model.GetPin( i );
|
|
||||||
|
|
||||||
|
// m_model.GetPins() returns pins in the order they appear in the model, but the keys in the
|
||||||
|
// key=value pairs we create here are symbol pin numbers, so we sort the pins so that they are
|
||||||
|
// ordered by the latter instead.
|
||||||
|
std::sort( pins.begin(), pins.end(),
|
||||||
|
[]( const SIM_MODEL::PIN& lhs, const SIM_MODEL::PIN& rhs )
|
||||||
|
{
|
||||||
|
return StrNumCmp( lhs.symbolPinNumber, rhs.symbolPinNumber, true ) < 0;
|
||||||
|
} );
|
||||||
|
|
||||||
|
bool isFirst = true;
|
||||||
|
|
||||||
|
for( const SIM_MODEL::PIN& pin : pins )
|
||||||
|
{
|
||||||
if( pin.symbolPinNumber != "" )
|
if( pin.symbolPinNumber != "" )
|
||||||
{
|
{
|
||||||
if( i != 0 )
|
if( !isFirst )
|
||||||
result.append( " " );
|
result.append( " " );
|
||||||
|
else
|
||||||
|
isFirst = false;
|
||||||
|
|
||||||
result.append( fmt::format( "{}={}", pin.symbolPinNumber, pin.name ) );
|
result.append( fmt::format( "{}={}", pin.symbolPinNumber, pin.name ) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue