Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // This class doesn't work correctly with forward declarations. | |
| 39 // Because sizeof cannot be applied to incomplete types, this line prevents us | |
| 40 // from passing in forward declarations. | |
| 41 typedef char (*EnsureTypesAreComplete)[sizeof(Base) + sizeof(Derived)]; | |
|
dmichael (off chromium)
2012/04/12 16:09:35
might as well put this in a private section. (actu
yzshen1
2012/04/12 16:30:46
Done. Thanks!
The public section doesn't come fir
| |
| 42 | |
| 38 static Derived* CreateDerived(); | 43 static Derived* CreateDerived(); |
| 39 static char (&Check(Base*))[1]; | 44 static char (&Check(Base*))[1]; |
| 40 static char (&Check(...))[2]; | 45 static char (&Check(...))[2]; |
| 41 static bool const value = sizeof Check(CreateDerived()) == 1 && | 46 static bool const value = sizeof Check(CreateDerived()) == 1 && |
| 42 !IsSame<Base const, void const>::value; | 47 !IsSame<Base const, void const>::value; |
| 43 }; | 48 }; |
| 44 | 49 |
| 45 // Template to optionally derive from a given base class T if the given | 50 // Template to optionally derive from a given base class T if the given |
| 46 // predicate P is true. | 51 // predicate P is true. |
| 47 template <class T, bool P> struct InheritIf {}; | 52 template <class T, bool P> struct InheritIf {}; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 // Retrieves the underlying vector that can be passed to the plugin. | 227 // Retrieves the underlying vector that can be passed to the plugin. |
| 223 static inline std::vector<pp::Var>& StorageToPluginArg(StorageType& t) { | 228 static inline std::vector<pp::Var>& StorageToPluginArg(StorageType& t) { |
| 224 return t.output(); | 229 return t.output(); |
| 225 } | 230 } |
| 226 }; | 231 }; |
| 227 | 232 |
| 228 } // namespace internal | 233 } // namespace internal |
| 229 } // namespace pp | 234 } // namespace pp |
| 230 | 235 |
| 231 #endif // PPAPI_CPP_OUTPUT_TRAITS_H_ | 236 #endif // PPAPI_CPP_OUTPUT_TRAITS_H_ |
| OLD | NEW |