]> granicus.if.org Git - icinga2/commitdiff
Make default getters and setters non-virtual
authorGunnar Beutner <gunnar.beutner@icinga.com>
Wed, 15 Nov 2017 08:47:23 +0000 (09:47 +0100)
committerNoah Hilverling <noah.hilverling@icinga.com>
Wed, 17 Jan 2018 14:58:58 +0000 (15:58 +0100)
tools/mkclass/class_lexer.ll
tools/mkclass/classcompiler.cpp
tools/mkclass/classcompiler.hpp

index 0b919546466474f9a4fda7484beaa2a0766a430e..625a99f22cde5a97941d2c90eda876c97019e901 100644 (file)
@@ -148,6 +148,9 @@ no_storage                  { yylval->num = FANoStorage; return T_FIELD_ATTRIBUTE; }
 no_user_modify                 { yylval->num = FANoUserModify; return T_FIELD_ATTRIBUTE; }
 no_user_view                   { yylval->num = FANoUserView; return T_FIELD_ATTRIBUTE; }
 deprecated                     { yylval->num = FADeprecated; return T_FIELD_ATTRIBUTE; }
+get_virtual                    { yylval->num = FAGetVirtual; return T_FIELD_ATTRIBUTE; }
+set_virtual                    { yylval->num = FASetVirtual; return T_FIELD_ATTRIBUTE; }
+virtual                                { yylval->num = FAGetVirtual | FASetVirtual; return T_FIELD_ATTRIBUTE; }
 navigation                     { return T_NAVIGATION; }
 validator                      { return T_VALIDATOR; }
 required                       { return T_REQUIRED; }
index 04e9abdeb8e29dd747a75a57348d24f90c2ef35d..7d068bcd5d2dedff1236c5b60f1033e2b011a6f3 100644 (file)
@@ -706,7 +706,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
 
                /* NotifyField */
                m_Header << "public:" << std::endl
-                        << "\t" << "virtual void NotifyField(int id, const Value& cookie = Empty) override;" << std::endl;
+                        << "\t" << "void NotifyField(int id, const Value& cookie = Empty) override;" << std::endl;
 
                m_Impl << "void ObjectImpl<" << klass.Name << ">::NotifyField(int id, const Value& cookie)" << std::endl
                       << "{" << std::endl;
@@ -784,7 +784,12 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
                                prot = "public";
 
                        m_Header << prot << ":" << std::endl
-                                << "\t" << "virtual " << field.Type.GetRealType() << " Get" << field.GetFriendlyName() << "(void) const";
+                                << "\t";
+
+                       if (field.Attributes & FAGetVirtual || field.PureGetAccessor)
+                               m_Header << "virtual ";
+
+                       m_Header << field.Type.GetRealType() << " Get" << field.GetFriendlyName() << "(void) const";
 
                        if (field.PureGetAccessor) {
                                m_Header << " = 0;" << std::endl;
@@ -813,7 +818,12 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
                                prot = "public";
 
                        m_Header << prot << ":" << std::endl
-                                << "\t" << "virtual void Set" << field.GetFriendlyName() << "(" << field.Type.GetArgumentType() << " value, bool suppress_events = false, const Value& cookie = Empty)";
+                                << "\t";
+
+                       if (field.Attributes & FASetVirtual || field.PureSetAccessor)
+                               m_Header << "virtual ";
+
+                       m_Header << "void Set" << field.GetFriendlyName() << "(" << field.Type.GetArgumentType() << " value, bool suppress_events = false, const Value& cookie = Empty)";
 
                        if (field.PureSetAccessor) {
                                m_Header << " = 0;" << std::endl;
@@ -859,7 +869,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
 
                        needs_tracking = true;
 
-                       m_Header << "\t" << "virtual void Track" << field.GetFriendlyName() << "(" << field.Type.GetArgumentType() << " oldValue, " << field.Type.GetArgumentType() << " newValue);";
+                       m_Header << "\t" << "void Track" << field.GetFriendlyName() << "(" << field.Type.GetArgumentType() << " oldValue, " << field.Type.GetArgumentType() << " newValue);" << std::endl;
 
                        m_Impl << "void ObjectImpl<" << klass.Name << ">::Track" << field.GetFriendlyName() << "(" << field.Type.GetArgumentType() << " oldValue, " << field.Type.GetArgumentType() << " newValue)" << std::endl
                               << "{" << std::endl;
@@ -930,7 +940,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
                                continue;
 
                        m_Header << "public:" << std::endl
-                                << "\t" << "virtual Object::Ptr Navigate" << field.GetFriendlyName() << "(void) const";
+                                << "\t" << "Object::Ptr Navigate" << field.GetFriendlyName() << "(void) const";
 
                        if (field.PureNavigateAccessor) {
                                m_Header << " = 0;" << std::endl;
@@ -951,8 +961,9 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
 
                /* start/stop */
                if (needs_tracking) {
-                       m_Header << "virtual void Start(bool runtimeCreated = false) override;" << std::endl
-                                << "virtual void Stop(bool runtimeRemoved = false) override;" << std::endl;
+                       m_Header << "protected:" << std::endl
+                                << "\tvirtual void Start(bool runtimeCreated = false) override;" << std::endl
+                                << "\tvirtual void Stop(bool runtimeRemoved = false) override;" << std::endl;
 
                        m_Impl << "void ObjectImpl<" << klass.Name << ">::Start(bool runtimeCreated)" << std::endl
                               << "{" << std::endl
index 06bf100d3f990951e91d98b3dff0311099b2663c..ab9422220bc008cee3cae3bbfb2b8a8e27acc156 100644 (file)
@@ -73,7 +73,9 @@ enum FieldAttribute
        FANavigation = 512,
        FANoUserModify = 1024,
        FANoUserView = 2048,
-       FADeprecated = 4096
+       FADeprecated = 4096,
+       FAGetVirtual = 8192,
+       FASetVirtual = 16384
 };
 
 struct FieldType