From 077809fc67679ce00347c931179164d07cf35c55 Mon Sep 17 00:00:00 2001 From: "rossberg@chromium.org" Date: Tue, 21 Oct 2014 13:37:49 +0000 Subject: [PATCH] Fix incorrect private access (I'm puzzled why GCC did not report this error.) TBR=bmeurer@chromium.org BUG= Review URL: https://codereview.chromium.org/669733007 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24776 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/interface.cc | 35 ++++++++++++++++------------------- src/interface.h | 3 +-- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/interface.cc b/src/interface.cc index d325c0e..a45804c 100644 --- a/src/interface.cc +++ b/src/interface.cc @@ -14,36 +14,33 @@ namespace internal { // --------------------------------------------------------------------------- // Initialization. -struct Interface::ValueCreate { - static void Construct(Interface* ptr) { - ::new (ptr) Interface(VALUE + FROZEN); - } -}; - - -struct Interface::ConstCreate { - static void Construct(Interface* ptr) { - ::new (ptr) Interface(VALUE + CONST + FROZEN); - } +struct Interface::Cache { + template + struct Create { + static void Construct(Interface* ptr) { ::new (ptr) Interface(flags); } + }; + typedef Create ValueCreate; + typedef Create ConstCreate; + + static base::LazyInstance::type value_interface; + static base::LazyInstance::type const_interface; }; -namespace { - base::LazyInstance::type value_interface = - LAZY_INSTANCE_INITIALIZER; +base::LazyInstance::type + Interface::Cache::value_interface = LAZY_INSTANCE_INITIALIZER; - base::LazyInstance::type const_interface = - LAZY_INSTANCE_INITIALIZER; -} +base::LazyInstance::type + Interface::Cache::const_interface = LAZY_INSTANCE_INITIALIZER; Interface* Interface::NewValue() { - return value_interface.Pointer(); // Cached. + return Cache::value_interface.Pointer(); // Cached. } Interface* Interface::NewConst() { - return const_interface.Pointer(); // Cached. + return Cache::const_interface.Pointer(); // Cached. } diff --git a/src/interface.h b/src/interface.h index ae54963..19f89ce 100644 --- a/src/interface.h +++ b/src/interface.h @@ -172,8 +172,7 @@ class Interface : public ZoneObject { // --------------------------------------------------------------------------- // Implementation. private: - struct ValueCreate; - struct ConstCreate; + struct Cache; enum Flags { // All flags are monotonic NONE = 0, -- 2.7.4