OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "ppapi/cpp/dev/foobar_dev.h" |
| 6 |
| 7 #include "ppapi/cpp/completion_callback.h" |
| 8 #include "ppapi/cpp/dev/array_dev.h" |
| 9 #include "ppapi/cpp/dev/from_c_type_converter_dev.h" |
| 10 #include "ppapi/cpp/dev/to_c_type_converter_dev.h" |
| 11 #include "ppapi/cpp/module_impl.h" |
| 12 |
| 13 namespace pp { |
| 14 |
| 15 namespace { |
| 16 |
| 17 template <> const char* interface_name<PPB_Foobar_0_1>() { |
| 18 return PPB_FOOBAR_INTERFACE_0_1; |
| 19 } |
| 20 |
| 21 } // namespace |
| 22 |
| 23 namespace foobar { |
| 24 |
| 25 Foo::Foo() : b_wrapper_(&storage_->b, NOT_OWNED), |
| 26 c_wrapper_(&storage_->c, NOT_OWNED), |
| 27 d_wrapper_(&storage_->d, NOT_OWNED) { |
| 28 |
| 29 } |
| 30 |
| 31 Foo::Foo(const Foo& other) : b_wrapper_(&storage_->b, NOT_OWNED), |
| 32 c_wrapper_(&storage_->c, NOT_OWNED), |
| 33 d_wrapper_(&storage_->d, NOT_OWNED) { |
| 34 operator=(other); |
| 35 } |
| 36 |
| 37 Foo::Foo(const PP_Foo& other) : b_wrapper_(&storage_->b, NOT_OWNED), |
| 38 c_wrapper_(&storage_->c, NOT_OWNED), |
| 39 d_wrapper_(&storage_->d, NOT_OWNED) { |
| 40 operator=(other); |
| 41 } |
| 42 |
| 43 Foo::Foo(PP_Foo* storage, NotOwned) : StructWrapperBase(storage, NOT_OWNED), |
| 44 b_wrapper_(&storage_->b, NOT_OWNED), |
| 45 c_wrapper_(&storage_->c, NOT_OWNED), |
| 46 d_wrapper_(&storage_->d, NOT_OWNED) { |
| 47 } |
| 48 |
| 49 Foo::~Foo() { |
| 50 } |
| 51 |
| 52 Foo& Foo::operator=(const Foo& other) { |
| 53 return operator=(*other.storage_); |
| 54 } |
| 55 |
| 56 Foo& Foo::operator=(const PP_Foo& other) { |
| 57 if (storage_.get() == &other) |
| 58 return *this; |
| 59 |
| 60 storage_->a = other.a; |
| 61 b_wrapper_ = other.b; |
| 62 c_wrapper_ = other.c; |
| 63 d_wrapper_ = other.d; |
| 64 |
| 65 return *this; |
| 66 } |
| 67 |
| 68 double Foo::a() const { |
| 69 return storage_->a; |
| 70 } |
| 71 |
| 72 void Foo::set_a(double value) { |
| 73 storage_->a = value; |
| 74 } |
| 75 |
| 76 bool Foo::is_b_set() const { |
| 77 return b_wrapper_.is_set(); |
| 78 } |
| 79 |
| 80 void Foo::unset_b() { |
| 81 b_wrapper_.unset(); |
| 82 } |
| 83 |
| 84 double Foo::b() const { |
| 85 return b_wrapper_.get(); |
| 86 } |
| 87 |
| 88 void Foo::set_b(double value) { |
| 89 b_wrapper_.set(value); |
| 90 } |
| 91 |
| 92 Array<double>& Foo::c() { |
| 93 return c_wrapper_; |
| 94 } |
| 95 |
| 96 const Array<double>& Foo::c() const { |
| 97 return c_wrapper_; |
| 98 } |
| 99 |
| 100 bool Foo::is_d_set() const { |
| 101 return d_wrapper_.is_set(); |
| 102 } |
| 103 |
| 104 void Foo::unset_d() { |
| 105 d_wrapper_.unset(); |
| 106 } |
| 107 |
| 108 Array<double>& Foo::d() { |
| 109 return d_wrapper_.get(); |
| 110 } |
| 111 |
| 112 const Array<double>& Foo::d() const { |
| 113 return d_wrapper_.get(); |
| 114 } |
| 115 |
| 116 /* |
| 117 const std::string& e() const; |
| 118 void set_e(const std::string& value); |
| 119 |
| 120 bool is_f_set() const; |
| 121 void unset_f(); |
| 122 const std::string& f() const; |
| 123 void set_f(const std::string& value); |
| 124 |
| 125 Array<std::string>& g(); |
| 126 const Array<std::string>& g() const; |
| 127 |
| 128 bool is_h_set() const; |
| 129 void unset_h(); |
| 130 Array<std::string>& h(); |
| 131 const Array<std::string>& h() const; |
| 132 |
| 133 Bar& i(); |
| 134 const Bar& i() const; |
| 135 |
| 136 bool is_j_set() const; |
| 137 void unset_j(); |
| 138 Bar& j(); |
| 139 const Bar& j() const; |
| 140 |
| 141 Array<Bar>& k(); |
| 142 const Array<Bar>& k() const; |
| 143 |
| 144 bool is_l_set() const; |
| 145 void unset_l(); |
| 146 Array<Bar>& l(); |
| 147 const Array<Bar>& l() const; |
| 148 */ |
| 149 |
| 150 void Foo::NotifyStartRawUpdate() { |
| 151 b_wrapper_.StartRawUpdate(); |
| 152 c_wrapper_.StartRawUpdate(); |
| 153 d_wrapper_.StartRawUpdate(); |
| 154 } |
| 155 |
| 156 void Foo::NotifyEndRawUpdate() { |
| 157 b_wrapper_.EndRawUpdate(); |
| 158 c_wrapper_.EndRawUpdate(); |
| 159 d_wrapper_.EndRawUpdate(); |
| 160 } |
| 161 |
| 162 Foobar::Foobar(const InstanceHandle& instance) : instance_(instance) { |
| 163 } |
| 164 |
| 165 Foobar::~Foobar() { |
| 166 } |
| 167 |
| 168 int32_t Foobar::Baz(const std::string& str, |
| 169 const Optional<std::string>& optional_str, |
| 170 const Optional<double>& dbl, |
| 171 const BazCallback& callback) { |
| 172 if (!has_interface<PPB_Foobar_0_1>()) |
| 173 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 174 |
| 175 internal::ToCTypeConverter<std::string> str_converter(str); |
| 176 internal::ToCTypeConverter<Optional<std::string> > optional_str_converter( |
| 177 optional_str); |
| 178 internal::ToCTypeConverter<Optional<double> > dbl_converter(dbl); |
| 179 |
| 180 return get_interface<PPB_Foobar_0_1>()->Baz( |
| 181 instance_.pp_instance(), |
| 182 str_converter.GetArg(), |
| 183 optional_str_converter.GetArg(), |
| 184 dbl_converter.GetArg(), |
| 185 callback.output(), |
| 186 callback.pp_completion_callback()); |
| 187 } |
| 188 |
| 189 int32_t Foobar::Qux(const QuxCallback& callback) { |
| 190 if (!has_interface<PPB_Foobar_0_1>()) |
| 191 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 192 |
| 193 return get_interface<PPB_Foobar_0_1>()->Qux( |
| 194 instance_.pp_instance(), |
| 195 callback.output(), |
| 196 internal::ArrayAllocator::Get(), |
| 197 callback.pp_completion_callback()); |
| 198 } |
| 199 |
| 200 int32_t Foobar::Blah(const BlahCallback& callback) { |
| 201 if (!has_interface<PPB_Foobar_0_1>()) |
| 202 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 203 |
| 204 return get_interface<PPB_Foobar_0_1>()->Blah( |
| 205 instance_.pp_instance(), |
| 206 callback.output(), |
| 207 internal::ArrayAllocator::Get(), |
| 208 callback.pp_completion_callback()); |
| 209 } |
| 210 |
| 211 } // namespace foobar |
| 212 } // namespace pp |
OLD | NEW |