Roll leveldb from r73 to r75.
[chromium-blink-merge.git] / ppapi / cpp / dev / var_array_dev.cc
blob247e9c442040e8dc8afee7ea5db8b63697003a0a
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 #include "ppapi/cpp/dev/var_array_dev.h"
7 #include "ppapi/c/dev/ppb_var_array_dev.h"
8 #include "ppapi/cpp/logging.h"
9 #include "ppapi/cpp/module_impl.h"
11 namespace pp {
13 namespace {
15 template <> const char* interface_name<PPB_VarArray_Dev_0_1>() {
16 return PPB_VAR_ARRAY_DEV_INTERFACE_0_1;
19 } // namespace
21 VarArray_Dev::VarArray_Dev() : Var(Null()) {
22 if (has_interface<PPB_VarArray_Dev_0_1>())
23 var_ = get_interface<PPB_VarArray_Dev_0_1>()->Create();
24 else
25 PP_NOTREACHED();
28 VarArray_Dev::VarArray_Dev(const Var& var) : Var(var) {
29 if (!var.is_array()) {
30 PP_NOTREACHED();
32 // This takes care of releasing the reference that this object holds.
33 Var::operator=(Var(Null()));
37 VarArray_Dev::VarArray_Dev(const PP_Var& var) : Var(var) {
38 if (var.type != PP_VARTYPE_ARRAY) {
39 PP_NOTREACHED();
41 // This takes care of releasing the reference that this object holds.
42 Var::operator=(Var(Null()));
46 VarArray_Dev::VarArray_Dev(const VarArray_Dev& other) : Var(other) {
49 VarArray_Dev::~VarArray_Dev() {
52 VarArray_Dev& VarArray_Dev::operator=(const VarArray_Dev& other) {
53 Var::operator=(other);
54 return *this;
57 Var& VarArray_Dev::operator=(const Var& other) {
58 if (other.is_array()) {
59 Var::operator=(other);
60 } else {
61 PP_NOTREACHED();
62 Var::operator=(Var(Null()));
64 return *this;
67 Var VarArray_Dev::Get(uint32_t index) const {
68 if (!has_interface<PPB_VarArray_Dev_0_1>())
69 return Var();
71 return Var(PASS_REF, get_interface<PPB_VarArray_Dev_0_1>()->Get(var_, index));
74 PP_Bool VarArray_Dev::Set(uint32_t index, const Var& value) {
75 if (!has_interface<PPB_VarArray_Dev_0_1>())
76 return PP_FALSE;
78 return get_interface<PPB_VarArray_Dev_0_1>()->Set(var_, index,
79 value.pp_var());
82 uint32_t VarArray_Dev::GetLength() const {
83 if (!has_interface<PPB_VarArray_Dev_0_1>())
84 return 0;
86 return get_interface<PPB_VarArray_Dev_0_1>()->GetLength(var_);
89 PP_Bool VarArray_Dev::SetLength(uint32_t length) {
90 if (!has_interface<PPB_VarArray_Dev_0_1>())
91 return PP_FALSE;
93 return get_interface<PPB_VarArray_Dev_0_1>()->SetLength(var_, length);
96 } // namespace pp