From f9bee87185511ddd980fb5c26c78697c02f0149d Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 26 Jan 2025 16:58:19 -0500 Subject: [PATCH] Handle disabled and hidden attributes --- common/libraries/library_table.cpp | 2 ++ common/libraries/library_table_parser.cpp | 14 ++++++++++++++ include/libraries/library_table.h | 4 ++++ include/libraries/library_table_grammar.h | 7 +++++++ include/libraries/library_table_parser.h | 2 ++ 5 files changed, 29 insertions(+) diff --git a/common/libraries/library_table.cpp b/common/libraries/library_table.cpp index aa684e72ce..0e34f2eaae 100644 --- a/common/libraries/library_table.cpp +++ b/common/libraries/library_table.cpp @@ -97,6 +97,8 @@ bool LIBRARY_TABLE::addRowFromIR( const LIBRARY_TABLE_ROW_IR& aIR ) row.m_type = wxString::FromUTF8( aIR.type ); row.m_options = wxString::FromUTF8( aIR.options ); row.m_description = wxString::FromUTF8( aIR.description ); + row.m_hidden = aIR.hidden; + row.m_disabled = aIR.disabled; row.m_ok = true; row.m_scope = m_scope; diff --git a/common/libraries/library_table_parser.cpp b/common/libraries/library_table_parser.cpp index 08c426b6d0..af01bebb47 100644 --- a/common/libraries/library_table_parser.cpp +++ b/common/libraries/library_table_parser.cpp @@ -122,6 +122,20 @@ DEFINE_STRING_ACTION( KEYWORDS::URI, current_row_model.uri ); DEFINE_STRING_ACTION( KEYWORDS::OPTIONS, current_row_model.options ); DEFINE_STRING_ACTION( KEYWORDS::DESCR, current_row_model.description ); +// Handle (hidden), (disabled) +#define DEFINE_FLAG_ACTION( Rule, StateVariable ) \ +template <> \ +struct LIBRARY_TABLE_PARSER_ACTION \ +{ \ + static void apply0( LIBRARY_TABLE_PARSER_STATE& s ) \ + { \ + s.StateVariable = true; \ + } \ +} \ + +DEFINE_FLAG_ACTION( HIDDEN_MARKER, current_row_model.hidden ); +DEFINE_FLAG_ACTION( DISABLED_MARKER, current_row_model.disabled ); + template <> struct LIBRARY_TABLE_PARSER_ACTION diff --git a/include/libraries/library_table.h b/include/libraries/library_table.h index 925218f25e..3da410f0c5 100644 --- a/include/libraries/library_table.h +++ b/include/libraries/library_table.h @@ -62,6 +62,8 @@ public: const wxString& Options() const { return m_options; } const wxString& Description() const { return m_description; } LIBRARY_TABLE_SCOPE Scope() const { return m_scope; } + bool Disabled() const { return m_disabled; } + bool Hidden() const { return m_hidden; } std::map GetOptionsMap() const; @@ -74,6 +76,8 @@ private: wxString m_type; wxString m_options; wxString m_description; + bool m_disabled; + bool m_hidden; bool m_ok = false; wxString m_errorDescription; diff --git a/include/libraries/library_table_grammar.h b/include/libraries/library_table_grammar.h index f6ded98054..512c718b4a 100644 --- a/include/libraries/library_table_grammar.h +++ b/include/libraries/library_table_grammar.h @@ -41,6 +41,8 @@ namespace KEYWORDS struct URI : TAO_PEGTL_STRING( "uri" ) {}; struct OPTIONS : TAO_PEGTL_STRING( "options" ) {}; struct DESCR : TAO_PEGTL_STRING( "descr" ) {}; + struct HIDDEN : TAO_PEGTL_STRING( "hidden" ) {}; + struct DISABLED : TAO_PEGTL_STRING( "disabled" ) {}; struct SYM_LIB_TABLE : TAO_PEGTL_STRING( "sym_lib_table" ) {}; struct FP_LIB_TABLE : TAO_PEGTL_STRING( "fp_lib_table" ) {}; @@ -99,12 +101,17 @@ struct TABLE_VERSION : seq< RPAREN > {}; +struct HIDDEN_MARKER : seq< LPAREN, KEYWORDS::HIDDEN, RPAREN > {}; +struct DISABLED_MARKER : seq< LPAREN, KEYWORDS::DISABLED, RPAREN > {}; + // (lib (name ...)(type ...)...) struct LIB_ROW : if_must< pad< LPAREN, space >, KEYWORDS::LIB, plus< space >, plus< pad< LIB_PROPERTY, space > >, + pad_opt, + pad_opt, pad< RPAREN, space> > {}; diff --git a/include/libraries/library_table_parser.h b/include/libraries/library_table_parser.h index 7ad48e5720..e16157f10a 100644 --- a/include/libraries/library_table_parser.h +++ b/include/libraries/library_table_parser.h @@ -37,6 +37,8 @@ struct LIBRARY_TABLE_ROW_IR std::string type; std::string options; std::string description; + bool disabled = false; + bool hidden = false; }; /**