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

Unified Diff: ppapi/cpp/var_array.cc

Issue 16136009: Move PPB_VarArray and PPB_VarDictionary out of dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 months 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
Index: ppapi/cpp/var_array.cc
diff --git a/ppapi/cpp/var_array.cc b/ppapi/cpp/var_array.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b0dcc3964642c061026ee7b70e16e1fc734191ff
--- /dev/null
+++ b/ppapi/cpp/var_array.cc
@@ -0,0 +1,96 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
dmichael (off chromium) 2013/06/11 17:19:47 Kind of weird git diff didn't detect this as the s
raymes 2013/06/16 23:35:36 Done.
+#include "ppapi/cpp/var_array.h"
+
+#include "ppapi/c/ppb_var_array.h"
+#include "ppapi/cpp/logging.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_VarArray_1_0>() {
+ return PPB_VAR_ARRAY_INTERFACE_1_0;
+}
+
+} // namespace
+
+VarArray::VarArray() : Var(Null()) {
+ if (has_interface<PPB_VarArray_1_0>())
+ var_ = get_interface<PPB_VarArray_1_0>()->Create();
+ else
+ PP_NOTREACHED();
+}
+
+VarArray::VarArray(const Var& var) : Var(var) {
+ if (!var.is_array()) {
+ PP_NOTREACHED();
+
+ // This takes care of releasing the reference that this object holds.
+ Var::operator=(Var(Null()));
+ }
+}
+
+VarArray::VarArray(const PP_Var& var) : Var(var) {
+ if (var.type != PP_VARTYPE_ARRAY) {
+ PP_NOTREACHED();
+
+ // This takes care of releasing the reference that this object holds.
+ Var::operator=(Var(Null()));
+ }
+}
+
+VarArray::VarArray(const VarArray& other) : Var(other) {
+}
+
+VarArray::~VarArray() {
+}
+
+VarArray& VarArray::operator=(const VarArray& other) {
+ Var::operator=(other);
+ return *this;
+}
+
+Var& VarArray::operator=(const Var& other) {
+ if (other.is_array()) {
+ Var::operator=(other);
+ } else {
+ PP_NOTREACHED();
+ Var::operator=(Var(Null()));
+ }
+ return *this;
+}
+
+Var VarArray::Get(uint32_t index) const {
+ if (!has_interface<PPB_VarArray_1_0>())
+ return Var();
+
+ return Var(PASS_REF, get_interface<PPB_VarArray_1_0>()->Get(var_, index));
+}
+
+PP_Bool VarArray::Set(uint32_t index, const Var& value) {
+ if (!has_interface<PPB_VarArray_1_0>())
+ return PP_FALSE;
+
+ return get_interface<PPB_VarArray_1_0>()->Set(var_, index,
+ value.pp_var());
+}
+
+uint32_t VarArray::GetLength() const {
+ if (!has_interface<PPB_VarArray_1_0>())
+ return 0;
+
+ return get_interface<PPB_VarArray_1_0>()->GetLength(var_);
+}
+
+PP_Bool VarArray::SetLength(uint32_t length) {
+ if (!has_interface<PPB_VarArray_1_0>())
+ return PP_FALSE;
+
+ return get_interface<PPB_VarArray_1_0>()->SetLength(var_, length);
+}
+
+} // namespace pp
« ppapi/c/ppb_var_array.h ('K') | « ppapi/cpp/var_array.h ('k') | ppapi/cpp/var_dictionary.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698