Reviewers: Sven Panne,

Message:
Committed patchset #1 manually as r16231.

Description:
Add V8_FINAL and V8_OVERRIDE macros for C++11 final/override.

TBR=svenpa...@chromium.org

Committed: https://code.google.com/p/v8/source/detail?r=16231

Please review this at https://codereview.chromium.org/22914019/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/globals.h


Index: src/globals.h
diff --git a/src/globals.h b/src/globals.h
index 26fd53114c62d582501e5d37c2c7791cb60cd99b..58832df45d56541aac8da031208a221d286b667c 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -330,6 +330,50 @@ F FUNCTION_CAST(Address addr) {
 }


+// Compiler feature detection.
+#if defined(__clang__)
+
+// Compatibility with older clang versions.
+# ifndef __has_extension
+# define __has_extension __has_feature
+# endif
+
+# if __has_extension(cxx_override_control)
+#  define V8_HAVE_CXX11_FINAL
+#  define V8_HAVE_CXX11_OVERRIDE
+# endif
+
+#elif defined(__GNUC__)
+
+// g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality
+// without warnings (functionality used by the macros below).  These modes
+// are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or,
+// more standardly, by checking whether __cplusplus has a C++11 or greater
+// value. Current versions of g++ do not correctly set __cplusplus, so we check
+// both for forward compatibility.
+# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
+#  if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
+#   define V8_HAVE_CXX11_OVERRIDE
+#   define V8_HAVE_CXX11_FINAL
+#  endif
+# else
+// '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655.
+#  if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
+#   define V8_HAVE_GXX_FINAL
+#  endif
+# endif
+
+#elif defined(_MSC_VER)
+
+# if _MSC_VER >= 1400
+#  define V8_HAVE_CXX11_OVERRIDE
+// MSVC currently spells "final" as "sealed".
+#  define V8_HAVE_MSVC_SEALED
+# endif
+
+#endif
+
+
 #if __cplusplus >= 201103L
 #define DISALLOW_BY_DELETE = delete
 #else
@@ -375,6 +419,33 @@ F FUNCTION_CAST(Address addr) {
 #endif


+// Annotate a virtual method indicating it must be overriding a virtual
+// method in the parent class.
+// Use like:
+//   virtual void bar() V8_OVERRIDE;
+#if defined(V8_HAVE_CXX11_OVERRIDE)
+#define V8_OVERRIDE override
+#else
+#define V8_OVERRIDE
+#endif
+
+
+// Annotate a virtual method indicating that subclasses must not override it,
+// or annotate a class to indicate that it cannot be subclassed.
+// Use like:
+//   class B V8_FINAL : public A {};
+//   virtual void bar() V8_FINAL;
+#if defined(V8_HAVE_CXX11_FINAL)
+#define V8_FINAL final
+#elif defined(V8_HAVE_GXX_FINAL)
+#define V8_FINAL __final
+#elif defined(V8_HAVE_MSVC_SEALED)
+#define V8_FINAL sealed
+#else
+#define V8_FINAL
+#endif
+
+
 #if defined(__GNUC__) && __GNUC__ >= 4
 #define MUST_USE_RESULT __attribute__ ((warn_unused_result))
 #else


--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to