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_dictionary_dev.h" | 5 #include "ppapi/cpp/var_dictionary.h" |
6 | 6 |
7 #include "ppapi/c/dev/ppb_var_dictionary_dev.h" | 7 #include "ppapi/c/ppb_var_dictionary.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_VarDictionary_Dev_0_1>() { | 15 template <> const char* interface_name<PPB_VarDictionary_1_0>() { |
16 return PPB_VAR_DICTIONARY_DEV_INTERFACE_0_1; | 16 return PPB_VAR_DICTIONARY_INTERFACE_1_0; |
17 } | 17 } |
18 | 18 |
19 } // namespace | 19 } // namespace |
20 | 20 |
21 VarDictionary_Dev::VarDictionary_Dev() : Var(Null()) { | 21 VarDictionary::VarDictionary() : Var(Null()) { |
22 if (has_interface<PPB_VarDictionary_Dev_0_1>()) | 22 if (has_interface<PPB_VarDictionary_1_0>()) |
23 var_ = get_interface<PPB_VarDictionary_Dev_0_1>()->Create(); | 23 var_ = get_interface<PPB_VarDictionary_1_0>()->Create(); |
24 else | 24 else |
25 PP_NOTREACHED(); | 25 PP_NOTREACHED(); |
26 } | 26 } |
27 | 27 |
28 VarDictionary_Dev::VarDictionary_Dev(const Var& var) : Var(var) { | 28 VarDictionary::VarDictionary(const Var& var) : Var(var) { |
29 if (!var.is_dictionary()) { | 29 if (!var.is_dictionary()) { |
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 VarDictionary_Dev::VarDictionary_Dev(const PP_Var& var) : Var(var) { | 37 VarDictionary::VarDictionary(const PP_Var& var) : Var(var) { |
38 if (var.type != PP_VARTYPE_DICTIONARY) { | 38 if (var.type != PP_VARTYPE_DICTIONARY) { |
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 VarDictionary_Dev::VarDictionary_Dev(const VarDictionary_Dev& other) | 46 VarDictionary::VarDictionary(const VarDictionary& other) |
47 : Var(other) { | 47 : Var(other) { |
48 } | 48 } |
49 | 49 |
50 VarDictionary_Dev::~VarDictionary_Dev() { | 50 VarDictionary::~VarDictionary() { |
51 } | 51 } |
52 | 52 |
53 VarDictionary_Dev& VarDictionary_Dev::operator=( | 53 VarDictionary& VarDictionary::operator=( |
54 const VarDictionary_Dev& other) { | 54 const VarDictionary& other) { |
55 Var::operator=(other); | 55 Var::operator=(other); |
56 return *this; | 56 return *this; |
57 } | 57 } |
58 | 58 |
59 Var& VarDictionary_Dev::operator=(const Var& other) { | 59 Var& VarDictionary::operator=(const Var& other) { |
60 if (other.is_dictionary()) { | 60 if (other.is_dictionary()) { |
61 Var::operator=(other); | 61 Var::operator=(other); |
62 } else { | 62 } else { |
63 PP_NOTREACHED(); | 63 PP_NOTREACHED(); |
64 Var::operator=(Var(Null())); | 64 Var::operator=(Var(Null())); |
65 } | 65 } |
66 return *this; | 66 return *this; |
67 } | 67 } |
68 | 68 |
69 Var VarDictionary_Dev::Get(const Var& key) const { | 69 Var VarDictionary::Get(const Var& key) const { |
70 if (!has_interface<PPB_VarDictionary_Dev_0_1>()) | 70 if (!has_interface<PPB_VarDictionary_1_0>()) |
71 return Var(); | 71 return Var(); |
72 | 72 |
73 return Var( | 73 return Var( |
74 PASS_REF, | 74 PASS_REF, |
75 get_interface<PPB_VarDictionary_Dev_0_1>()->Get(var_, key.pp_var())); | 75 get_interface<PPB_VarDictionary_1_0>()->Get(var_, key.pp_var())); |
76 } | 76 } |
77 | 77 |
78 PP_Bool VarDictionary_Dev::Set(const Var& key, const Var& value) { | 78 PP_Bool VarDictionary::Set(const Var& key, const Var& value) { |
noelallen1
2013/06/17 17:43:42
bool?
| |
79 if (!has_interface<PPB_VarDictionary_Dev_0_1>()) | 79 if (!has_interface<PPB_VarDictionary_1_0>()) |
80 return PP_FALSE; | 80 return PP_FALSE; |
81 | 81 |
82 return get_interface<PPB_VarDictionary_Dev_0_1>()->Set(var_, key.pp_var(), | 82 return get_interface<PPB_VarDictionary_1_0>()->Set(var_, key.pp_var(), |
83 value.pp_var()); | 83 value.pp_var()); |
84 } | 84 } |
85 | 85 |
86 void VarDictionary_Dev::Delete(const Var& key) { | 86 void VarDictionary::Delete(const Var& key) { |
87 if (has_interface<PPB_VarDictionary_Dev_0_1>()) | 87 if (has_interface<PPB_VarDictionary_1_0>()) |
88 get_interface<PPB_VarDictionary_Dev_0_1>()->Delete(var_, key.pp_var()); | 88 get_interface<PPB_VarDictionary_1_0>()->Delete(var_, key.pp_var()); |
89 } | 89 } |
90 | 90 |
91 PP_Bool VarDictionary_Dev::HasKey(const Var& key) const { | 91 PP_Bool VarDictionary::HasKey(const Var& key) const { |
noelallen1
2013/06/17 17:43:42
bool?
| |
92 if (!has_interface<PPB_VarDictionary_Dev_0_1>()) | 92 if (!has_interface<PPB_VarDictionary_1_0>()) |
93 return PP_FALSE; | 93 return PP_FALSE; |
94 | 94 |
95 return get_interface<PPB_VarDictionary_Dev_0_1>()->HasKey(var_, key.pp_var()); | 95 return get_interface<PPB_VarDictionary_1_0>()->HasKey(var_, key.pp_var()); |
96 } | 96 } |
97 | 97 |
98 VarArray_Dev VarDictionary_Dev::GetKeys() const { | 98 VarArray VarDictionary::GetKeys() const { |
99 if (!has_interface<PPB_VarDictionary_Dev_0_1>()) | 99 if (!has_interface<PPB_VarDictionary_1_0>()) |
100 return VarArray_Dev(); | 100 return VarArray(); |
101 | 101 |
102 Var result(PASS_REF, | 102 Var result(PASS_REF, |
103 get_interface<PPB_VarDictionary_Dev_0_1>()->GetKeys(var_)); | 103 get_interface<PPB_VarDictionary_1_0>()->GetKeys(var_)); |
104 if (result.is_array()) | 104 if (result.is_array()) |
105 return VarArray_Dev(result); | 105 return VarArray(result); |
106 else | 106 else |
107 return VarArray_Dev(); | 107 return VarArray(); |
108 } | 108 } |
109 | 109 |
110 } // namespace pp | 110 } // namespace pp |
OLD | NEW |