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

Unified Diff: ppapi/cpp/output_traits.h

Issue 60173003: Draft: apps APIs in Pepper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/cpp/extensions/dev/alarms_dev_old.cc ('k') | ppapi/examples/extensions/extensions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/output_traits.h
diff --git a/ppapi/cpp/output_traits.h b/ppapi/cpp/output_traits.h
index 31cdbbe11220eccddd739c7fac6f00d27be6409f..f0f1809e1ba4b389f96023ab4c37bef1fdd5d3b6 100644
--- a/ppapi/cpp/output_traits.h
+++ b/ppapi/cpp/output_traits.h
@@ -9,6 +9,9 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/cpp/array_output.h"
+#include "ppapi/cpp/dev/array_dev.h"
+#include "ppapi/cpp/dev/from_c_type_converter_dev.h"
+#include "ppapi/cpp/dev/struct_wrapper_base_dev.h"
#include "ppapi/cpp/resource.h"
/// @file
@@ -123,17 +126,40 @@ struct ResourceCallbackOutputTraits {
}
};
+template<typename T>
+struct StructWrapperCallbackOutputTraits {
+ typedef typename T::COutputType APIArgType;
+ typedef FromCTypeConverter<T> StorageType;
+
+ static inline APIArgType StorageToAPIArg(StorageType& t) {
+ return t.StartRawUpdate();
+ }
+
+ static inline T& StorageToPluginArg(StorageType& t) {
+ t.EndRawUpdate();
+ return t.value();
+ }
+
+ static inline void Initialize(StorageType* /* t */) {}
+};
+
// The general templatized base class for all CallbackOutputTraits. This class
-// covers both resources and POD (ints, structs, etc.) by inheriting from the
-// appropriate base class depending on whether the given type derives from
-// pp::Resource. This trick allows us to do this once rather than writing
-// specializations for every resource object type.
+// covers resources, struct wrapper objects and POD (ints, structs, etc.)
+// by inheriting from the appropriate base class depending on whether the given
+// type derives from pp::Resource or StructWrapperIdentifier. This trick
+// allows us to do this once rather than writing specializations for every
+// object type.
+// TODO(yzshen): I will need to add specializtion for Optional<T>. Other than
+// that I think it should be fine.
template<typename T>
struct CallbackOutputTraits
- : public InheritIf<GenericCallbackOutputTraits<T>,
- !IsBaseOf<Resource, T>::value>,
- public InheritIf<ResourceCallbackOutputTraits<T>,
- IsBaseOf<Resource, T>::value> {
+ : public InheritIf<ResourceCallbackOutputTraits<T>,
+ IsBaseOf<Resource, T>::value>,
+ public InheritIf<StructWrapperCallbackOutputTraits<T>,
+ IsBaseOf<StructWrapperIdentifier, T>::value>,
+ public InheritIf<GenericCallbackOutputTraits<T>,
+ !IsBaseOf<Resource, T>::value &&
+ !IsBaseOf<StructWrapperIdentifier, T>::value> {
};
// A specialization of CallbackOutputTraits for pp::Var output parameters.
@@ -184,6 +210,24 @@ struct CallbackOutputTraits<bool> {
}
};
+template<typename T>
+struct CallbackOutputTraits<Array<T> > {
+ typedef typename Array<T>::COutputType APIArgType;
+ typedef Array<T> StorageType;
+
+ static inline APIArgType StorageToAPIArg(StorageType& t) {
+ return t.StartRawUpdate();
+ }
+
+ static inline Array<T>& StorageToPluginArg(StorageType& t) {
+ t.EndRawUpdate();
+ return t;
+ }
+
+ static inline void Initialize(StorageType* t) {
+ }
+};
+
// Array output parameters -----------------------------------------------------
// Output traits for vectors of all "plain old data" (POD) types. It is
« no previous file with comments | « ppapi/cpp/extensions/dev/alarms_dev_old.cc ('k') | ppapi/examples/extensions/extensions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698