| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/cpp/dev/var_array_dev.h" | 5 #include "ppapi/cpp/var_array.h" |
| 6 | 6 |
| 7 #include "ppapi/c/dev/ppb_var_array_dev.h" | 7 #include "ppapi/c/ppb_var_array.h" |
| 8 #include "ppapi/cpp/logging.h" | 8 #include "ppapi/cpp/logging.h" |
| 9 #include "ppapi/cpp/module_impl.h" | 9 #include "ppapi/cpp/module_impl.h" |
| 10 | 10 |
| 11 namespace pp { | 11 namespace pp { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 template <> const char* interface_name<PPB_VarArray_Dev_0_1>() { | 15 template <> const char* interface_name<PPB_VarArray_1_0>() { |
| 16 return PPB_VAR_ARRAY_DEV_INTERFACE_0_1; | 16 return PPB_VAR_ARRAY_INTERFACE_1_0; |
| 17 } | 17 } |
| 18 | 18 |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 VarArray_Dev::VarArray_Dev() : Var(Null()) { | 21 VarArray::VarArray() : Var(Null()) { |
| 22 if (has_interface<PPB_VarArray_Dev_0_1>()) | 22 if (has_interface<PPB_VarArray_1_0>()) |
| 23 var_ = get_interface<PPB_VarArray_Dev_0_1>()->Create(); | 23 var_ = get_interface<PPB_VarArray_1_0>()->Create(); |
| 24 else | 24 else |
| 25 PP_NOTREACHED(); | 25 PP_NOTREACHED(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 VarArray_Dev::VarArray_Dev(const Var& var) : Var(var) { | 28 VarArray::VarArray(const Var& var) : Var(var) { |
| 29 if (!var.is_array()) { | 29 if (!var.is_array()) { |
| 30 PP_NOTREACHED(); | 30 PP_NOTREACHED(); |
| 31 | 31 |
| 32 // This takes care of releasing the reference that this object holds. | 32 // This takes care of releasing the reference that this object holds. |
| 33 Var::operator=(Var(Null())); | 33 Var::operator=(Var(Null())); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 VarArray_Dev::VarArray_Dev(const PP_Var& var) : Var(var) { | 37 VarArray::VarArray(const PP_Var& var) : Var(var) { |
| 38 if (var.type != PP_VARTYPE_ARRAY) { | 38 if (var.type != PP_VARTYPE_ARRAY) { |
| 39 PP_NOTREACHED(); | 39 PP_NOTREACHED(); |
| 40 | 40 |
| 41 // This takes care of releasing the reference that this object holds. | 41 // This takes care of releasing the reference that this object holds. |
| 42 Var::operator=(Var(Null())); | 42 Var::operator=(Var(Null())); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 VarArray_Dev::VarArray_Dev(const VarArray_Dev& other) : Var(other) { | 46 VarArray::VarArray(const VarArray& other) : Var(other) { |
| 47 } | 47 } |
| 48 | 48 |
| 49 VarArray_Dev::~VarArray_Dev() { | 49 VarArray::~VarArray() { |
| 50 } | 50 } |
| 51 | 51 |
| 52 VarArray_Dev& VarArray_Dev::operator=(const VarArray_Dev& other) { | 52 VarArray& VarArray::operator=(const VarArray& other) { |
| 53 Var::operator=(other); | 53 Var::operator=(other); |
| 54 return *this; | 54 return *this; |
| 55 } | 55 } |
| 56 | 56 |
| 57 Var& VarArray_Dev::operator=(const Var& other) { | 57 Var& VarArray::operator=(const Var& other) { |
| 58 if (other.is_array()) { | 58 if (other.is_array()) { |
| 59 Var::operator=(other); | 59 Var::operator=(other); |
| 60 } else { | 60 } else { |
| 61 PP_NOTREACHED(); | 61 PP_NOTREACHED(); |
| 62 Var::operator=(Var(Null())); | 62 Var::operator=(Var(Null())); |
| 63 } | 63 } |
| 64 return *this; | 64 return *this; |
| 65 } | 65 } |
| 66 | 66 |
| 67 Var VarArray_Dev::Get(uint32_t index) const { | 67 Var VarArray::Get(uint32_t index) const { |
| 68 if (!has_interface<PPB_VarArray_Dev_0_1>()) | 68 if (!has_interface<PPB_VarArray_1_0>()) |
| 69 return Var(); | 69 return Var(); |
| 70 | 70 |
| 71 return Var(PASS_REF, get_interface<PPB_VarArray_Dev_0_1>()->Get(var_, index)); | 71 return Var(PASS_REF, get_interface<PPB_VarArray_1_0>()->Get(var_, index)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 PP_Bool VarArray_Dev::Set(uint32_t index, const Var& value) { | 74 PP_Bool VarArray::Set(uint32_t index, const Var& value) { |
| 75 if (!has_interface<PPB_VarArray_Dev_0_1>()) | 75 if (!has_interface<PPB_VarArray_1_0>()) |
| 76 return PP_FALSE; | 76 return PP_FALSE; |
| 77 | 77 |
| 78 return get_interface<PPB_VarArray_Dev_0_1>()->Set(var_, index, | 78 return get_interface<PPB_VarArray_1_0>()->Set(var_, index, |
| 79 value.pp_var()); | 79 value.pp_var()); |
| 80 } | 80 } |
| 81 | 81 |
| 82 uint32_t VarArray_Dev::GetLength() const { | 82 uint32_t VarArray::GetLength() const { |
| 83 if (!has_interface<PPB_VarArray_Dev_0_1>()) | 83 if (!has_interface<PPB_VarArray_1_0>()) |
| 84 return 0; | 84 return 0; |
| 85 | 85 |
| 86 return get_interface<PPB_VarArray_Dev_0_1>()->GetLength(var_); | 86 return get_interface<PPB_VarArray_1_0>()->GetLength(var_); |
| 87 } | 87 } |
| 88 | 88 |
| 89 PP_Bool VarArray_Dev::SetLength(uint32_t length) { | 89 PP_Bool VarArray::SetLength(uint32_t length) { |
| 90 if (!has_interface<PPB_VarArray_Dev_0_1>()) | 90 if (!has_interface<PPB_VarArray_1_0>()) |
| 91 return PP_FALSE; | 91 return PP_FALSE; |
| 92 | 92 |
| 93 return get_interface<PPB_VarArray_Dev_0_1>()->SetLength(var_, length); | 93 return get_interface<PPB_VarArray_1_0>()->SetLength(var_, length); |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace pp | 96 } // namespace pp |
| OLD | NEW |