From 90adc26b73f347138d6e1f4f9e17896cd9e04480 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 21 Feb 2023 19:55:47 +0000 Subject: [PATCH] Remove dead and redundant code. --- eeschema/dialogs/dialog_sim_model.cpp | 10 ++-------- eeschema/sim/sim_model.cpp | 7 ++----- eeschema/sim/sim_model.h | 8 +++----- eeschema/sim/sim_model_ngspice.cpp | 4 ++-- eeschema/sim/sim_model_source.cpp | 6 +++--- eeschema/sim/sim_model_tline.cpp | 2 +- eeschema/sim/sim_value.cpp | 7 ------- eeschema/sim/sim_value.h | 3 --- 8 files changed, 13 insertions(+), 34 deletions(-) diff --git a/eeschema/dialogs/dialog_sim_model.cpp b/eeschema/dialogs/dialog_sim_model.cpp index 32c088ac57..afc5e2b83a 100644 --- a/eeschema/dialogs/dialog_sim_model.cpp +++ b/eeschema/dialogs/dialog_sim_model.cpp @@ -876,15 +876,9 @@ wxPGProperty* DIALOG_SIM_MODEL::newParamProperty( SIM_MODEL* // Legacy due to the way we extracted the parameters from Ngspice. #if wxCHECK_VERSION( 3, 1, 0 ) - if( param.isOtherVariant ) - prop->SetCell( 3, wxString::FromUTF8( param.info.defaultValueOfOtherVariant ) ); - else - prop->SetCell( 3, wxString::FromUTF8( param.info.defaultValue ) ); + prop->SetCell( 3, wxString::FromUTF8( param.info.defaultValue ) ); #else - if( param.isOtherVariant ) - prop->SetCell( 3, wxString::FromUTF8( param.info.defaultValueOfOtherVariant.c_str() ) ); - else - prop->SetCell( 3, wxString::FromUTF8( param.info.defaultValue.c_str() ) ); + prop->SetCell( 3, wxString::FromUTF8( param.info.defaultValue.c_str() ) ); #endif wxString typeStr; diff --git a/eeschema/sim/sim_model.cpp b/eeschema/sim/sim_model.cpp index c5f0d3d251..50024ff6b7 100644 --- a/eeschema/sim/sim_model.cpp +++ b/eeschema/sim/sim_model.cpp @@ -711,9 +711,9 @@ int SIM_MODEL::FindModelPinIndex( const std::string& aSymbolPinNumber ) } -void SIM_MODEL::AddParam( const PARAM::INFO& aInfo, bool aIsOtherVariant ) +void SIM_MODEL::AddParam( const PARAM::INFO& aInfo ) { - m_params.emplace_back( aInfo, aIsOtherVariant ); + m_params.emplace_back( aInfo ); // Enums are initialized with their default values. if( aInfo.enumValues.size() >= 1 ) @@ -1738,9 +1738,6 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject ) { model->SetParamValue( ii, tokenizer.GetNextToken().ToStdString(), SIM_VALUE_GRAMMAR::NOTATION::SPICE ); - - if( !model->GetParam( ii ).value->HasValue() ) - THROW_IO_ERROR( "fall back to raw SPICE" ); } spiceTypeInfo.m_Text = SIM_MODEL::TypeInfo( type ).fieldValue; diff --git a/eeschema/sim/sim_model.h b/eeschema/sim/sim_model.h index 107b8d429b..517ccdb817 100644 --- a/eeschema/sim/sim_model.h +++ b/eeschema/sim/sim_model.h @@ -379,12 +379,10 @@ public: std::unique_ptr value; const INFO& info; - bool isOtherVariant = false; // Legacy. - PARAM( const INFO& aInfo, bool aIsOtherVariant = false ) + PARAM( const INFO& aInfo ) : value( SIM_VALUE::Create( aInfo.type ) ), - info( aInfo ), - isOtherVariant( aIsOtherVariant ) + info( aInfo ) {} }; @@ -453,7 +451,7 @@ public: void ClearPins(); int FindModelPinIndex( const std::string& aSymbolPinNumber ); - void AddParam( const PARAM::INFO& aInfo, bool aIsOtherVariant = false ); + void AddParam( const PARAM::INFO& aInfo ); DEVICE_INFO GetDeviceInfo() const { return DeviceInfo( GetDeviceType() ); } INFO GetTypeInfo() const { return TypeInfo( GetType() ); } diff --git a/eeschema/sim/sim_model_ngspice.cpp b/eeschema/sim/sim_model_ngspice.cpp index 49729a3f2d..2c63a0fca8 100644 --- a/eeschema/sim/sim_model_ngspice.cpp +++ b/eeschema/sim/sim_model_ngspice.cpp @@ -72,12 +72,12 @@ SIM_MODEL_NGSPICE::SIM_MODEL_NGSPICE( TYPE aType ) : if( paramInfo.category == SIM_MODEL::PARAM::CATEGORY::PRINCIPAL || paramInfo.category == SIM_MODEL::PARAM::CATEGORY::GEOMETRY ) { - AddParam( paramInfo, getIsOtherVariant() ); + AddParam( paramInfo ); } } for( const SIM_MODEL::PARAM::INFO& paramInfo : modelInfo.modelParams ) - AddParam( paramInfo, getIsOtherVariant() ); + AddParam( paramInfo ); } diff --git a/eeschema/sim/sim_model_source.cpp b/eeschema/sim/sim_model_source.cpp index 09abb1831f..4d060013c2 100644 --- a/eeschema/sim/sim_model_source.cpp +++ b/eeschema/sim/sim_model_source.cpp @@ -149,12 +149,12 @@ std::string SPICE_GENERATOR_SOURCE::ItemLine( const SPICE_ITEM& aItem ) const SIM_VALUE_FLOAT min = dynamic_cast( *m_model.FindParam( "max" )->value ); - if( !min.HasValue() ) + if( !min.ToString().empty() ) min.FromString( "0" ); SIM_VALUE_FLOAT max = dynamic_cast( *m_model.FindParam( "min" )->value ); - if( !max.HasValue() ) + if( !max.ToString().empty() ) max.FromString( "0" ); SIM_VALUE_FLOAT range = max - min; @@ -257,7 +257,7 @@ void SIM_MODEL_SOURCE::SetParamValue( int aParamIndex, const SIM_VALUE& aValue ) { // Sources are special. All preceding parameter values must be filled. If they are not, fill // them out automatically. If a value is nulled, delete everything after it. - if( !aValue.HasValue() ) + if( aValue.ToString().empty() ) { for( int paramIndex = static_cast( aParamIndex ); paramIndex < GetParamCount(); diff --git a/eeschema/sim/sim_model_tline.cpp b/eeschema/sim/sim_model_tline.cpp index ee14676c91..b922effb34 100644 --- a/eeschema/sim/sim_model_tline.cpp +++ b/eeschema/sim/sim_model_tline.cpp @@ -40,7 +40,7 @@ std::string SPICE_GENERATOR_TLINE::ModelLine( const SPICE_ITEM& aItem ) const auto z0 = static_cast( *m_model.FindParam( "z0" )->value ); auto td = static_cast( *m_model.FindParam( "td" )->value ); - if( !z0.HasValue() || !td.HasValue() ) + if( !z0.ToString().empty() || !td.ToString().empty() ) return fmt::format( ".model {} LTRA()\n", aItem.modelName ); r = SIM_VALUE_FLOAT( 0 ).ToSpiceString(); diff --git a/eeschema/sim/sim_value.cpp b/eeschema/sim/sim_value.cpp index f6002336e9..f9fcde957c 100644 --- a/eeschema/sim/sim_value.cpp +++ b/eeschema/sim/sim_value.cpp @@ -425,13 +425,6 @@ template <> SIM_VALUE::TYPE SIM_VALUE_FLOAT_VECTOR::GetType() const { return TYP template <> SIM_VALUE::TYPE SIM_VALUE_COMPLEX_VECTOR::GetType() const { return TYPE_COMPLEX; }*/ -template -bool SIM_VALUE_INST::HasValue() const -{ - return m_value.has_value(); -} - - template <> bool SIM_VALUE_BOOL::FromString( const std::string& aString, NOTATION aNotation ) { diff --git a/eeschema/sim/sim_value.h b/eeschema/sim/sim_value.h index 1b7c4cc84f..83cec9172a 100644 --- a/eeschema/sim/sim_value.h +++ b/eeschema/sim/sim_value.h @@ -85,8 +85,6 @@ public: virtual TYPE GetType() const = 0; - virtual bool HasValue() const = 0; - SIM_VALUE& operator=( const std::string& aString ); virtual SIM_VALUE& operator=( const SIM_VALUE& aValue ) = 0; virtual bool operator==( const SIM_VALUE& aOther ) const = 0; @@ -109,7 +107,6 @@ public: SIM_VALUE_INST( const T& aValue ); TYPE GetType() const override; - bool HasValue() const override; // TODO: Don't pass aNotation. Make a FromSpiceString() function instead. // TODO: Don't use FromString(). Use assignment. Values should be immutable.