From 3fc3f05bb4c26ec8fa9d9f1f72ff7e76dbb82744 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 31 Oct 2014 08:53:25 +0100 Subject: [PATCH] Implement field attribute to hide fields in command auto-completion fixes #7403 --- lib/base/dynamicobject.ti | 6 +++--- lib/base/type.hpp | 3 ++- lib/cli/clicommand.cpp | 5 +---- tools/mkclass/class_lexer.ll | 1 + tools/mkclass/classcompiler.hpp | 3 ++- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/base/dynamicobject.ti b/lib/base/dynamicobject.ti index f123fbaf2..b9163262e 100644 --- a/lib/base/dynamicobject.ti +++ b/lib/base/dynamicobject.ti @@ -35,7 +35,7 @@ public: abstract class DynamicObject { - [config] String __name (Name); + [config, internal] String __name (Name); [config] String name (ShortName) { get {{{ if (m_ShortName.IsEmpty()) @@ -44,9 +44,9 @@ abstract class DynamicObject return m_ShortName; }}} }; - [config, get_protected] String type (TypeName); + [config, internal, get_protected] String type (TypeName); [config] String zone; - [config, get_protected] Array::Ptr templates; + [config, internal, get_protected] Array::Ptr templates; [config] Dictionary::Ptr methods; [config] Dictionary::Ptr vars (VarsRaw); [get_protected] bool active; diff --git a/lib/base/type.hpp b/lib/base/type.hpp index d8ebf8046..67ffceee9 100644 --- a/lib/base/type.hpp +++ b/lib/base/type.hpp @@ -33,7 +33,8 @@ namespace icinga enum FieldAttribute { FAConfig = 1, - FAState = 2 + FAState = 2, + FAInternal = 32 }; class Type; diff --git a/lib/cli/clicommand.cpp b/lib/cli/clicommand.cpp index 36bd388b7..159f9d7e5 100644 --- a/lib/cli/clicommand.cpp +++ b/lib/cli/clicommand.cpp @@ -75,7 +75,7 @@ std::vector icinga::GetFieldCompletionSuggestions(const Type *type, cons for (int i = 0; i < type->GetFieldCount(); i++) { Field field = type->GetFieldInfo(i); - if (!(field.Attributes & FAConfig)) + if (!(field.Attributes & FAConfig) || field.Attributes & FAInternal) continue; if (field.FType != Type::GetByName("int") && field.FType != Type::GetByName("double") @@ -84,9 +84,6 @@ std::vector icinga::GetFieldCompletionSuggestions(const Type *type, cons String fname = field.Name; - if (fname == "__name" || fname == "templates" || fname == "type") - continue; - String suggestion = fname + "="; if (suggestion.Find(word) == 0) diff --git a/tools/mkclass/class_lexer.ll b/tools/mkclass/class_lexer.ll index 00d1d89b3..8ecf95da7 100644 --- a/tools/mkclass/class_lexer.ll +++ b/tools/mkclass/class_lexer.ll @@ -139,6 +139,7 @@ enum { yylval->num = FAEnum; return T_FIELD_ATTRIBUTE; } get_protected { yylval->num = FAGetProtected; return T_FIELD_ATTRIBUTE; } set_protected { yylval->num = FASetProtected; return T_FIELD_ATTRIBUTE; } protected { yylval->num = FAGetProtected | FASetProtected; return T_FIELD_ATTRIBUTE; } +internal { yylval->num = FAInternal; return T_FIELD_ATTRIBUTE; } default { yylval->num = FTDefault; return T_FIELD_ACCESSOR_TYPE; } get { yylval->num = FTGet; return T_FIELD_ACCESSOR_TYPE; } set { yylval->num = FTSet; return T_FIELD_ACCESSOR_TYPE; } diff --git a/tools/mkclass/classcompiler.hpp b/tools/mkclass/classcompiler.hpp index f8ec30bf2..f317492f9 100644 --- a/tools/mkclass/classcompiler.hpp +++ b/tools/mkclass/classcompiler.hpp @@ -60,7 +60,8 @@ enum FieldAttribute FAState = 2, FAEnum = 4, FAGetProtected = 8, - FASetProtected = 16 + FASetProtected = 16, + FAInternal = 32 }; struct Field -- 2.40.0