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

Unified Diff: lib/src/protobuf/wire_format.dart

Issue 1277863003: cleanup: move fieldType constants and functions to a separate file (Closed) Base URL: git@github.com:dart-lang/dart-protobuf.git@master
Patch Set: _validateMessage should call _baseType, not callers Created 5 years, 4 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 | « lib/src/protobuf/unknown_field_set.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/protobuf/wire_format.dart
diff --git a/lib/src/protobuf/wire_format.dart b/lib/src/protobuf/wire_format.dart
index 6b6b1bdafcf9a9cd95469837fe7bfe3ce0ebcd60..daa2a706bc28a2afa0b48c6c36f0251f9ba6de58 100644
--- a/lib/src/protobuf/wire_format.dart
+++ b/lib/src/protobuf/wire_format.dart
@@ -19,3 +19,37 @@ int getTagFieldNumber(int tag) => (tag & 0x7fffffff) >> TAG_TYPE_BITS;
int getTagWireType(int tag) => tag & TAG_TYPE_MASK;
int makeTag(int fieldNumber, int tag) => (fieldNumber << TAG_TYPE_BITS) | tag;
+
+/// Returns true if the wireType can be merged into the given fieldType.
+bool _wireTypeMatches(int fieldType, int wireType) {
+ switch (FieldType._baseType(fieldType)) {
+ case FieldType._BOOL_BIT:
+ case FieldType._ENUM_BIT:
+ case FieldType._INT32_BIT:
+ case FieldType._INT64_BIT:
+ case FieldType._SINT32_BIT:
+ case FieldType._SINT64_BIT:
+ case FieldType._UINT32_BIT:
+ case FieldType._UINT64_BIT:
+ return wireType == WIRETYPE_VARINT ||
+ wireType == WIRETYPE_LENGTH_DELIMITED;
+ case FieldType._FLOAT_BIT:
+ case FieldType._FIXED32_BIT:
+ case FieldType._SFIXED32_BIT:
+ return wireType == WIRETYPE_FIXED32 ||
+ wireType == WIRETYPE_LENGTH_DELIMITED;
+ case FieldType._DOUBLE_BIT:
+ case FieldType._FIXED64_BIT:
+ case FieldType._SFIXED64_BIT:
+ return wireType == WIRETYPE_FIXED64 ||
+ wireType == WIRETYPE_LENGTH_DELIMITED;
+ case FieldType._BYTES_BIT:
+ case FieldType._STRING_BIT:
+ case FieldType._MESSAGE_BIT:
+ return wireType == WIRETYPE_LENGTH_DELIMITED;
+ case FieldType._GROUP_BIT:
+ return wireType == WIRETYPE_START_GROUP;
+ default:
+ return false;
+ }
+}
« no previous file with comments | « lib/src/protobuf/unknown_field_set.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698