gpu: Tweak Android WebGL test expectations
[chromium-blink-merge.git] / ppapi / cpp / extensions / to_var_converter.h
blobe38499977fb328711bb122d23171ea5fcc37844a
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PPAPI_CPP_EXTENSIONS_TO_VAR_CONVERTOR_H_
6 #define PPAPI_CPP_EXTENSIONS_TO_VAR_CONVERTOR_H_
8 #include <string>
10 #include "ppapi/c/pp_var.h"
11 #include "ppapi/cpp/extensions/optional.h"
12 #include "ppapi/cpp/var.h"
13 #include "ppapi/cpp/var_array.h"
14 #include "ppapi/cpp/var_array_buffer.h"
15 #include "ppapi/cpp/var_dictionary.h"
17 namespace pp {
18 namespace ext {
19 namespace internal {
21 class ToVarConverterBase {
22 public:
23 PP_Var pp_var() const {
24 return var_.pp_var();
27 const Var& var() const {
28 return var_;
31 protected:
32 ToVarConverterBase() {
35 explicit ToVarConverterBase(const PP_Var& var) : var_(var) {
38 explicit ToVarConverterBase(const Var& var): var_(var) {
41 ~ToVarConverterBase() {
44 Var var_;
47 template <class T>
48 class ToVarConverter : public ToVarConverterBase {
49 public:
50 explicit ToVarConverter(const T& object)
51 : ToVarConverterBase(object.CreateVar()) {
54 ~ToVarConverter() {
58 template <class T>
59 class ToVarConverter<Optional<T> > : public ToVarConverterBase {
60 public:
61 explicit ToVarConverter(const Optional<T>& object)
62 : ToVarConverterBase(
63 object.IsSet() ? ToVarConverter<T>(*object).pp_var() :
64 PP_MakeUndefined()) {
67 ~ToVarConverter() {
71 template <>
72 class ToVarConverter<bool> : public ToVarConverterBase {
73 public:
74 explicit ToVarConverter(bool object) : ToVarConverterBase(Var(object)) {
77 ~ToVarConverter() {
81 template <>
82 class ToVarConverter<int32_t> : public ToVarConverterBase {
83 public:
84 explicit ToVarConverter(int32_t object) : ToVarConverterBase(Var(object)) {
87 ~ToVarConverter() {
91 template <>
92 class ToVarConverter<double> : public ToVarConverterBase {
93 public:
94 explicit ToVarConverter(double object) : ToVarConverterBase(Var(object)) {
97 ~ToVarConverter() {
101 template <>
102 class ToVarConverter<std::string> : public ToVarConverterBase {
103 public:
104 explicit ToVarConverter(const std::string& object)
105 : ToVarConverterBase(Var(object)) {
108 ~ToVarConverter() {
112 template <>
113 class ToVarConverter<Var> : public ToVarConverterBase {
114 public:
115 explicit ToVarConverter(const Var& object) : ToVarConverterBase(object) {
118 ~ToVarConverter() {
122 template <>
123 class ToVarConverter<VarArray> : public ToVarConverterBase {
124 public:
125 explicit ToVarConverter(const Var& object) : ToVarConverterBase(object) {
128 ~ToVarConverter() {
132 template <>
133 class ToVarConverter<VarDictionary> : public ToVarConverterBase {
134 public:
135 explicit ToVarConverter(const Var& object) : ToVarConverterBase(object) {
138 ~ToVarConverter() {
142 template <>
143 class ToVarConverter<VarArrayBuffer> : public ToVarConverterBase {
144 public:
145 explicit ToVarConverter(const Var& object) : ToVarConverterBase(object) {
148 ~ToVarConverter() {
152 } // namespace internal
153 } // namespace ext
154 } // namespace pp
156 #endif // PPAPI_CPP_EXTENSIONS_TO_VAR_CONVERTOR_H_