Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: ppapi/cpp/output_traits.h

Issue 10068004: Fix IsBaseOf in output_traits.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes in response to David's suggestion. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/cpp/dev/audio_input_dev.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PPAPI_CPP_OUTPUT_TRAITS_H_ 5 #ifndef PPAPI_CPP_OUTPUT_TRAITS_H_
6 #define PPAPI_CPP_OUTPUT_TRAITS_H_ 6 #define PPAPI_CPP_OUTPUT_TRAITS_H_
7 7
8 #include "ppapi/c/pp_resource.h" 8 #include "ppapi/c/pp_resource.h"
9 #include "ppapi/cpp/array_output.h" 9 #include "ppapi/cpp/array_output.h"
10 10
(...skipping 17 matching lines...) Expand all
28 // This goop is a trick used to implement a template that can be used to 28 // This goop is a trick used to implement a template that can be used to
29 // determine if a given class is the base class of another given class. It is 29 // determine if a given class is the base class of another given class. It is
30 // used in the resource object partial specialization below. 30 // used in the resource object partial specialization below.
31 template<typename, typename> struct IsSame { 31 template<typename, typename> struct IsSame {
32 static bool const value = false; 32 static bool const value = false;
33 }; 33 };
34 template<typename A> struct IsSame<A, A> { 34 template<typename A> struct IsSame<A, A> {
35 static bool const value = true; 35 static bool const value = true;
36 }; 36 };
37 template<typename Base, typename Derived> struct IsBaseOf { 37 template<typename Base, typename Derived> struct IsBaseOf {
38 private:
39 // This class doesn't work correctly with forward declarations.
40 // Because sizeof cannot be applied to incomplete types, this line prevents us
41 // from passing in forward declarations.
42 typedef char (*EnsureTypesAreComplete)[sizeof(Base) + sizeof(Derived)];
43
38 static Derived* CreateDerived(); 44 static Derived* CreateDerived();
39 static char (&Check(Base*))[1]; 45 static char (&Check(Base*))[1];
40 static char (&Check(...))[2]; 46 static char (&Check(...))[2];
47
48 public:
41 static bool const value = sizeof Check(CreateDerived()) == 1 && 49 static bool const value = sizeof Check(CreateDerived()) == 1 &&
42 !IsSame<Base const, void const>::value; 50 !IsSame<Base const, void const>::value;
43 }; 51 };
44 52
45 // Template to optionally derive from a given base class T if the given 53 // Template to optionally derive from a given base class T if the given
46 // predicate P is true. 54 // predicate P is true.
47 template <class T, bool P> struct InheritIf {}; 55 template <class T, bool P> struct InheritIf {};
48 template <class T> struct InheritIf<T, true> : public T {}; 56 template <class T> struct InheritIf<T, true> : public T {};
49 57
50 // Single output parameters ---------------------------------------------------- 58 // Single output parameters ----------------------------------------------------
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // Retrieves the underlying vector that can be passed to the plugin. 230 // Retrieves the underlying vector that can be passed to the plugin.
223 static inline std::vector<pp::Var>& StorageToPluginArg(StorageType& t) { 231 static inline std::vector<pp::Var>& StorageToPluginArg(StorageType& t) {
224 return t.output(); 232 return t.output();
225 } 233 }
226 }; 234 };
227 235
228 } // namespace internal 236 } // namespace internal
229 } // namespace pp 237 } // namespace pp
230 238
231 #endif // PPAPI_CPP_OUTPUT_TRAITS_H_ 239 #endif // PPAPI_CPP_OUTPUT_TRAITS_H_
OLDNEW
« no previous file with comments | « ppapi/cpp/dev/audio_input_dev.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698