Skip to content

Commit

Permalink
When clearing a field make the field state "does not exist"
Browse files Browse the repository at this point in the history
This does not change the fact that the default value is returned when the field is cleared.

Tests for this in the dart-protoc-plugin package.

R=sigmund@google.com
BUG=#17

Review URL: https://chromiumcodereview.appspot.com//106663007
  • Loading branch information
sgjesse committed Dec 10, 2013
1 parent ad69bce commit 189e461
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
12 changes: 0 additions & 12 deletions lib/generated_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -874,18 +874,6 @@ abstract class GeneratedMessage {

void clearField(int tagNumber) {
_fieldValues.remove(tagNumber);
// Restore the default value for the field.
// For repeated fields, the default is an empty list.
// For required/optional fields, the BuilderInfo contains the initializer.
int fieldType = _getFieldType(tagNumber);
if ((fieldType & _REPEATED_BIT) != 0) {
_fieldValues[tagNumber] = new PbList();
} else {
var defaultValue = info_.defaultValue(tagNumber);
if (defaultValue != null) {
_fieldValues[tagNumber] = defaultValue;
}
}
}

bool extensionsAreInitialized() {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: protobuf
version: 0.3.2
version: 0.3.3
authors:
- Dart Team <misc@dartlang.org>
description: Runtime library for protobuf support.
Expand Down

0 comments on commit 189e461

Please sign in to comment.