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

Side by Side Diff: ppapi/cpp/dev/var_array_dev.cc

Issue 12388083: Add PPB_VarArray_Dev support - part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/var_array_dev.h"
6
7 #include "ppapi/c/dev/ppb_var_array_dev.h"
8 #include "ppapi/cpp/logging.h"
9 #include "ppapi/cpp/module_impl.h"
10
11 namespace pp {
12
13 namespace {
14
15 template <> const char* interface_name<PPB_VarArray_Dev_0_1>() {
16 return PPB_VAR_ARRAY_DEV_INTERFACE_0_1;
17 }
18
19 } // namespace
20
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();
26 }
27
28 VarArray_Dev::VarArray_Dev(const Var& var) : Var(var) {
29 if (!var.is_array()) {
30 PP_NOTREACHED();
31
32 // This takes care of releasing the reference that this object holds.
33 Var::operator=(Var(Null()));
34 }
35 }
36
37 VarArray_Dev::VarArray_Dev(const VarArray_Dev& other) : Var(other) {
38 }
39
40 VarArray_Dev::~VarArray_Dev() {
41 }
42
43 VarArray_Dev& VarArray_Dev::operator=(const VarArray_Dev& other) {
44 Var::operator=(other);
45 return *this;
46 }
47
48 Var& VarArray_Dev::operator=(const Var& other) {
49 if (other.is_array()) {
50 Var::operator=(other);
51 } else {
52 PP_NOTREACHED();
53 Var::operator=(Var(Null()));
54 }
55 return *this;
56 }
57
58 Var VarArray_Dev::Get(uint32_t index) const {
59 if (!has_interface<PPB_VarArray_Dev_0_1>())
60 return Var();
61
62 return Var(PASS_REF, get_interface<PPB_VarArray_Dev_0_1>()->Get(var_, index));
63 }
64
65 PP_Bool VarArray_Dev::Set(uint32_t index, const Var& value) {
66 if (!has_interface<PPB_VarArray_Dev_0_1>())
67 return PP_FALSE;
68
69 return get_interface<PPB_VarArray_Dev_0_1>()->Set(var_, index,
70 value.pp_var());
71 }
72
73 uint32_t VarArray_Dev::GetLength() const {
74 if (!has_interface<PPB_VarArray_Dev_0_1>())
75 return 0;
76
77 return get_interface<PPB_VarArray_Dev_0_1>()->GetLength(var_);
78 }
79
80 PP_Bool VarArray_Dev::SetLength(uint32_t length) {
81 if (!has_interface<PPB_VarArray_Dev_0_1>())
82 return PP_FALSE;
83
84 return get_interface<PPB_VarArray_Dev_0_1>()->SetLength(var_, length);
85 }
86
87 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/dev/var_array_dev.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698