[Libreoffice-commits] core.git: 2 commits - config_host/config_global.h.in configure.ac sal/inc vcl/coretext

Tor Lillqvist tml at iki.fi
Mon Apr 8 01:47:33 PDT 2013


 config_host/config_global.h.in     |    1 
 configure.ac                       |   75 +++++++++++++++++++++++++++++++++++--
 sal/inc/sal/types.h                |   12 +++++
 vcl/coretext/salcoretextlayout.cxx |    2 
 4 files changed, 86 insertions(+), 4 deletions(-)

New commits:
commit 6fe69ec3c0b7c41f02fa8f789ef80f33b6b7d0bf
Author: Tor Lillqvist <tml at iki.fi>
Date:   Mon Apr 8 11:24:15 2013 +0300

    Use SAL_FINAL here
    
    Sure, not that useful in this case (where it is quite obvious anyway
    that the class is not derived from), but just to verify that the
    SAL_FINAL thing works.
    
    Change-Id: Icef6eb64e278354694145bf98f02b9ffe5db7da7

diff --git a/vcl/coretext/salcoretextlayout.cxx b/vcl/coretext/salcoretextlayout.cxx
index 6502b17..4dd4ff4 100644
--- a/vcl/coretext/salcoretextlayout.cxx
+++ b/vcl/coretext/salcoretextlayout.cxx
@@ -30,7 +30,7 @@
 #include "headless/svpgdi.hxx"
 #endif
 
-class CoreTextLayout : public SalLayout
+class CoreTextLayout SAL_FINAL : public SalLayout
 {
 public:
     CoreTextLayout( QuartzSalGraphics* graphics, CoreTextStyleInfo* style);
commit cdd1de0854c5fd55f7e99c5546ccf7a7245927f5
Author: Tor Lillqvist <tml at iki.fi>
Date:   Mon Apr 8 11:23:53 2013 +0300

    Check for the C++11 "final" specifier and introduce SAL_FINAL
    
    I think it is useful to use SAL_FINAL mainly as a documentation aid,
    to make it clear to a code reader when a class is not expected to be
    derived from, and when a virtual function is not expected to be
    overridden in a derived class.
    
    Possibly there is also some class of bugs that using SAL_FINAL will
    help find?
    
    Change-Id: I45002f020dcb52e8a9f2962ff98780f2b80627af

diff --git a/config_host/config_global.h.in b/config_host/config_global.h.in
index 19b13dc..02e284f 100644
--- a/config_host/config_global.h.in
+++ b/config_host/config_global.h.in
@@ -14,6 +14,7 @@ Any change in this header will cause a rebuild of almost everything.
 
 #define HAVE_CXX11_DELETE 0
 #define HAVE_CXX11_OVERRIDE 0
+#define HAVE_CXX11_FINAL 0
 #define HAVE_CXX11_PERFECT_FORWARDING 0
 #define HAVE_GCC_BUILTIN_ATOMIC 0
 #define HAVE_GCC_PRAGMA_DIAGNOSTIC_MODIFY 0
diff --git a/configure.ac b/configure.ac
index cdda016..90a2d89 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5585,14 +5585,14 @@ struct A
         AC_MSG_RESULT([no])
     fi
 else
-    AC_MSG_RESULT([no (C++11 disabled)])
+    AC_MSG_RESULT([no])
 fi
 
 dnl ==================================
 dnl Check for C++11 "override" support
 dnl ==================================
 
-AC_MSG_CHECKING([whether $CXX supports C++11 override syntax])
+AC_MSG_CHECKING([whether $CXX supports C++11 "override" syntax])
 if test "$HAVE_CXX0X" = "TRUE"; then
     save_CXXFLAGS=$CXXFLAGS
     CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
@@ -5618,7 +5618,76 @@ struct B : A
         AC_MSG_RESULT([no])
     fi
 else
-    AC_MSG_RESULT([no (C++11 disabled)])
+    AC_MSG_RESULT([no])
+fi
+
+dnl ==================================
+dnl Check for C++11 "final" support
+dnl ==================================
+
+AC_MSG_CHECKING([whether $CXX supports C++11 "final" syntax])
+if test "$HAVE_CXX0X" = "TRUE"; then
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+// First check that this correct program that uses "final" compiles
+struct A final
+{
+};
+
+struct B
+{
+        virtual void test();
+};
+
+struct C : B
+{
+        void test() final;
+};
+]])],[have_final=yes],[])
+
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+// Then check that the "final" works as expected,
+// that this program fails to compile
+struct A final
+{
+};
+
+struct B : A
+{
+};
+]])],[],[final_class_works=yes])
+
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+// Also this should fail to compile
+struct B
+{
+        virtual void test();
+};
+
+struct C : B
+{
+        void test() final;
+};
+
+struct D : C
+{
+        void test();
+};
+]])],[],[final_method_works=yes])
+    AC_LANG_POP([C++])
+
+    CXXFLAGS=$save_CXXFLAGS
+
+    if test "$have_final" = yes -a "$final_class_works" = yes -a "$final_method_works" = yes; then
+        AC_MSG_RESULT([yes])
+        AC_DEFINE([HAVE_CXX11_FINAL])
+    else
+        AC_MSG_RESULT([no])
+    fi
+else
+    AC_MSG_RESULT([no])
 fi
 
 dnl ===================================================================
diff --git a/sal/inc/sal/types.h b/sal/inc/sal/types.h
index 346abf6..55f2e72 100644
--- a/sal/inc/sal/types.h
+++ b/sal/inc/sal/types.h
@@ -409,6 +409,18 @@ namespace css = ::com::sun::star;
 #define SAL_OVERRIDE
 #endif
 
+/** C++11 "final" feature.
+
+    With HAVE_CXX11_FINAL, mark a class as non-derivable or a method as non-overridable.
+
+    @since LibreOffice 4.1
+*/
+#if HAVE_CXX11_FINAL
+#define SAL_FINAL final
+#else
+#define SAL_FINAL
+#endif
+
 #endif /* __cplusplus */
 
 #ifdef __cplusplus


More information about the Libreoffice-commits mailing list