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

Side by Side Diff: dbus/values_util.cc

Issue 1541193002: Switch to standard integer types in dbus/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « dbus/values_util.h ('k') | dbus/values_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "dbus/values_util.h" 5 #include "dbus/values_util.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 } // namespace 88 } // namespace
89 89
90 base::Value* PopDataAsValue(MessageReader* reader) { 90 base::Value* PopDataAsValue(MessageReader* reader) {
91 base::Value* result = NULL; 91 base::Value* result = NULL;
92 switch (reader->GetDataType()) { 92 switch (reader->GetDataType()) {
93 case Message::INVALID_DATA: 93 case Message::INVALID_DATA:
94 // Do nothing. 94 // Do nothing.
95 break; 95 break;
96 case Message::BYTE: { 96 case Message::BYTE: {
97 uint8 value = 0; 97 uint8_t value = 0;
98 if (reader->PopByte(&value)) 98 if (reader->PopByte(&value))
99 result = new base::FundamentalValue(value); 99 result = new base::FundamentalValue(value);
100 break; 100 break;
101 } 101 }
102 case Message::BOOL: { 102 case Message::BOOL: {
103 bool value = false; 103 bool value = false;
104 if (reader->PopBool(&value)) 104 if (reader->PopBool(&value))
105 result = new base::FundamentalValue(value); 105 result = new base::FundamentalValue(value);
106 break; 106 break;
107 } 107 }
108 case Message::INT16: { 108 case Message::INT16: {
109 int16 value = 0; 109 int16_t value = 0;
110 if (reader->PopInt16(&value)) 110 if (reader->PopInt16(&value))
111 result = new base::FundamentalValue(value); 111 result = new base::FundamentalValue(value);
112 break; 112 break;
113 } 113 }
114 case Message::UINT16: { 114 case Message::UINT16: {
115 uint16 value = 0; 115 uint16_t value = 0;
116 if (reader->PopUint16(&value)) 116 if (reader->PopUint16(&value))
117 result = new base::FundamentalValue(value); 117 result = new base::FundamentalValue(value);
118 break; 118 break;
119 } 119 }
120 case Message::INT32: { 120 case Message::INT32: {
121 int32 value = 0; 121 int32_t value = 0;
122 if (reader->PopInt32(&value)) 122 if (reader->PopInt32(&value))
123 result = new base::FundamentalValue(value); 123 result = new base::FundamentalValue(value);
124 break; 124 break;
125 } 125 }
126 case Message::UINT32: { 126 case Message::UINT32: {
127 uint32 value = 0; 127 uint32_t value = 0;
128 if (reader->PopUint32(&value)) 128 if (reader->PopUint32(&value))
129 result = new base::FundamentalValue(static_cast<double>(value)); 129 result = new base::FundamentalValue(static_cast<double>(value));
130 break; 130 break;
131 } 131 }
132 case Message::INT64: { 132 case Message::INT64: {
133 int64 value = 0; 133 int64_t value = 0;
134 if (reader->PopInt64(&value)) { 134 if (reader->PopInt64(&value)) {
135 DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) << 135 DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) <<
136 value << " is not exactly representable by double"; 136 value << " is not exactly representable by double";
137 result = new base::FundamentalValue(static_cast<double>(value)); 137 result = new base::FundamentalValue(static_cast<double>(value));
138 } 138 }
139 break; 139 break;
140 } 140 }
141 case Message::UINT64: { 141 case Message::UINT64: {
142 uint64 value = 0; 142 uint64_t value = 0;
143 if (reader->PopUint64(&value)) { 143 if (reader->PopUint64(&value)) {
144 DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) << 144 DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) <<
145 value << " is not exactly representable by double"; 145 value << " is not exactly representable by double";
146 result = new base::FundamentalValue(static_cast<double>(value)); 146 result = new base::FundamentalValue(static_cast<double>(value));
147 } 147 }
148 break; 148 break;
149 } 149 }
150 case Message::DOUBLE: { 150 case Message::DOUBLE: {
151 double value = 0; 151 double value = 0;
152 if (reader->PopDouble(&value)) 152 if (reader->PopDouble(&value))
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 298 }
299 299
300 void AppendValueDataAsVariant(MessageWriter* writer, const base::Value& value) { 300 void AppendValueDataAsVariant(MessageWriter* writer, const base::Value& value) {
301 MessageWriter variant_writer(NULL); 301 MessageWriter variant_writer(NULL);
302 writer->OpenVariant(GetTypeSignature(value), &variant_writer); 302 writer->OpenVariant(GetTypeSignature(value), &variant_writer);
303 AppendValueData(&variant_writer, value); 303 AppendValueData(&variant_writer, value);
304 writer->CloseContainer(&variant_writer); 304 writer->CloseContainer(&variant_writer);
305 } 305 }
306 306
307 } // namespace dbus 307 } // namespace dbus
OLDNEW
« no previous file with comments | « dbus/values_util.h ('k') | dbus/values_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698