5 #ifndef PPAPI_CPP_OUTPUT_TRAITS_H_ 
    6 #define PPAPI_CPP_OUTPUT_TRAITS_H_ 
   10 #include "ppapi/c/pp_resource.h" 
   11 #include "ppapi/cpp/array_output.h" 
   33 template<
typename, 
typename> 
struct IsSame {
 
   34   static bool const value = 
false;
 
   36 template<
typename A> 
struct IsSame<A, A> {
 
   37   static bool const value = 
true;
 
   39 template<
typename Base, 
typename Derived> 
struct IsBaseOf {
 
   44   typedef char (*EnsureTypesAreComplete)[
sizeof(Base) + 
sizeof(Derived)];
 
   46   static Derived* CreateDerived();
 
   47   static char (&Check(Base*))[1];
 
   48   static char (&Check(...))[2];
 
   51   static bool const value = 
sizeof Check(CreateDerived()) == 1 &&
 
   58 template <
class T> 
struct InheritIf<T, true> : 
public T {};
 
   71   typedef T* APIArgType;
 
   77   typedef T StorageType;
 
   82   static inline APIArgType StorageToAPIArg(StorageType& t) { 
return &t; }
 
   87   static inline T& StorageToPluginArg(StorageType& t) { 
return t; }
 
   91   static inline void Initialize(StorageType* ) {}
 
  105   typedef PP_Resource* APIArgType;
 
  106   typedef PP_Resource StorageType;
 
  108   static inline APIArgType StorageToAPIArg(StorageType& t) {
 
  117   static inline T StorageToPluginArg(StorageType& t) {
 
  118     return T(PASS_REF, t);
 
  121   static inline void Initialize(StorageType* t) {
 
  133     : 
public InheritIf<GenericCallbackOutputTraits<T>,
 
  134                        !IsBaseOf<Resource, T>::value>,
 
  135       public InheritIf<ResourceCallbackOutputTraits<T>,
 
  136                        IsBaseOf<Resource, T>::value> {
 
  145   typedef PP_Var* APIArgType;
 
  146   typedef PP_Var StorageType;
 
  148   static inline APIArgType StorageToAPIArg(StorageType& t) {
 
  155   static inline pp::Var StorageToPluginArg(StorageType& t) {
 
  156     return Var(PASS_REF, t);
 
  159   static inline void Initialize(StorageType* t) {
 
  160     *t = PP_MakeUndefined();
 
  170   typedef PP_Bool* APIArgType;
 
  171   typedef PP_Bool StorageType;
 
  173   static inline APIArgType StorageToAPIArg(StorageType& t) {
 
  178   static inline bool StorageToPluginArg(StorageType& t) {
 
  182   static inline void Initialize(StorageType* t) {
 
  197   typedef PP_ArrayOutput APIArgType;
 
  205   static inline APIArgType StorageToAPIArg(
StorageType& t) {
 
  206     return t.pp_array_output();
 
  210   static inline std::vector<T>& StorageToPluginArg(
StorageType& t) {
 
  227   typedef PP_ArrayOutput APIArgType;
 
  230   static inline APIArgType StorageToAPIArg(
StorageType& t) {
 
  231     return t.pp_array_output();
 
  233   static inline std::vector<T>& StorageToPluginArg(
StorageType& t) {
 
  247     : 
public InheritIf<GenericVectorCallbackOutputTraits<T>,
 
  248                        !IsBaseOf<Resource, T>::value>,
 
  249       public InheritIf<ResourceVectorCallbackOutputTraits<T>,
 
  250                        IsBaseOf<Resource, T>::value> {
 
  259   typedef PP_ArrayOutput APIArgType;
 
  267   static inline APIArgType StorageToAPIArg(
StorageType& t) {
 
  268     return t.pp_array_output();
 
  272   static inline std::vector<pp::Var>& StorageToPluginArg(
StorageType& t) {
 
  282 #endif  // PPAPI_CPP_OUTPUT_TRAITS_H_ 
Definition: output_traits.h:103
 
Definition: output_traits.h:226
 
Definition: output_traits.h:68
 
Definition: output_traits.h:132
 
Definition: array_output.h:237
 
Definition: output_traits.h:33
 
Definition: array_output.h:204
 
Definition: output_traits.h:195
 
Definition: output_traits.h:39
 
Definition: output_traits.h:57
 
A generic type used for passing data types between the module and the page. 
Definition: var.h:23
 
Definition: array_output.h:179