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

Unified Diff: dbus/message.cc

Issue 1839943003: dbus changes: add SetGlobalOutputChannelRemix support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: additional size_t cast modification Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dbus/message.h ('k') | dbus/message_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/message.cc
diff --git a/dbus/message.cc b/dbus/message.cc
index 8a58dbaa3bf955c9f7ba9e1924437be577cd2038..fe497ba9a6e06e788e3fa1091e6afd1da024c980 100644
--- a/dbus/message.cc
+++ b/dbus/message.cc
@@ -599,6 +599,19 @@ void MessageWriter::AppendArrayOfBytes(const uint8_t* values, size_t length) {
CloseContainer(&array_writer);
}
+void MessageWriter::AppendArrayOfDoubles(const double* values, size_t length) {
+ DCHECK(!container_is_open_);
+ MessageWriter array_writer(message_);
+ OpenArray("d", &array_writer);
+ const bool success = dbus_message_iter_append_fixed_array(
+ &(array_writer.raw_message_iter_),
+ DBUS_TYPE_DOUBLE,
+ &values,
+ static_cast<int>(length));
+ CHECK(success) << "Unable to allocate memory";
+ CloseContainer(&array_writer);
+}
+
void MessageWriter::AppendArrayOfStrings(
const std::vector<std::string>& strings) {
DCHECK(!container_is_open_);
@@ -822,7 +835,26 @@ bool MessageReader::PopArrayOfBytes(const uint8_t** bytes, size_t* length) {
dbus_message_iter_get_fixed_array(&array_reader.raw_message_iter_,
bytes,
&int_length);
- *length = static_cast<int>(int_length);
+ *length = static_cast<size_t>(int_length);
+ return true;
+}
+
+bool MessageReader::PopArrayOfDoubles(const double** doubles, size_t* length) {
+ MessageReader array_reader(message_);
+ if (!PopArray(&array_reader))
+ return false;
+ if (!array_reader.HasMoreData()) {
+ *length = 0;
+ *doubles = nullptr;
+ return true;
+ }
+ if (!array_reader.CheckDataType(DBUS_TYPE_DOUBLE))
+ return false;
+ int int_length = 0;
+ dbus_message_iter_get_fixed_array(&array_reader.raw_message_iter_,
+ doubles,
+ &int_length);
+ *length = static_cast<size_t>(int_length);
return true;
}
« no previous file with comments | « dbus/message.h ('k') | dbus/message_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698