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

Unified Diff: pkg/analyzer/lib/src/summary/flat_buffers.dart

Issue 1612533002: Add support for Uint32 fields and lists in Flat Buffers. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | pkg/analyzer/test/src/summary/flat_buffers_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/flat_buffers.dart
diff --git a/pkg/analyzer/lib/src/summary/flat_buffers.dart b/pkg/analyzer/lib/src/summary/flat_buffers.dart
index 65e7c28b1a13cc9d4fc6b7d30261580b8164f0cf..c56b2986e287e28de1b60400f2e16e8efddffee9 100644
--- a/pkg/analyzer/lib/src/summary/flat_buffers.dart
+++ b/pkg/analyzer/lib/src/summary/flat_buffers.dart
@@ -178,6 +178,22 @@ class Builder {
}
/**
+ * Add the [field] with the given 32-bit unsigned integer [value]. The field
+ * is not added if the [value] is equal to [def].
+ */
+ void addUint32(int field, int value, [int def]) {
+ if (_currentVTable == null) {
+ throw new StateError('Start a table before adding values.');
+ }
+ if (value != null && value != def) {
+ int size = 4;
+ _prepare(size, 1);
+ _trackField(field);
+ _setUint32AtTail(_buf, _tail, value);
+ }
+ }
+
+ /**
* End the current table and return its offset.
*/
Offset endTable() {
@@ -342,6 +358,26 @@ class Builder {
}
/**
+ * Write the given list of unsigned 32-bit integer [values].
+ */
+ Offset writeListUint32(List<int> values) {
+ if (_currentVTable != null) {
+ throw new StateError(
+ 'Cannot write a non-scalar value while writing a table.');
+ }
+ _prepare(4, 1 + values.length);
+ Offset result = new Offset(_tail);
+ int tail = _tail;
+ _setUint32AtTail(_buf, tail, values.length);
+ tail -= 4;
+ for (int value in values) {
+ _setUint32AtTail(_buf, tail, value);
+ tail -= 4;
+ }
+ return result;
+ }
+
+ /**
* Write the given string [value] and return its [Offset], or `null` if
* the [value] is equal to [def].
*/
@@ -435,7 +471,7 @@ class Float64ListReader extends Reader<List<double>> {
}
/**
- * The reader of 32-bit signed integers.
+ * The reader of signed 32-bit integers.
*/
class Int32Reader extends Reader<int> {
const Int32Reader() : super();
@@ -562,6 +598,19 @@ abstract class TableReader<T> extends Reader<T> {
}
/**
+ * The reader of unsigned 32-bit integers.
+ */
+class Uint32Reader extends Reader<int> {
+ const Uint32Reader() : super();
+
+ @override
+ int get size => 4;
+
+ @override
+ int read(BufferPointer bp) => bp._getUint32();
+}
+
+/**
* The list backed by 64-bit values - Uint64 length and Float64.
*/
class _FbFloat64List extends _FbList<double> {
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/flat_buffers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698