Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a class for field types #605

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/master' into refactor_field_type
osa1 committed Jun 17, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit ffcb1e87639971fdd4d4d2b3254767f9f86199d7
12 changes: 3 additions & 9 deletions protobuf/lib/src/protobuf/pb_list.dart
Original file line number Diff line number Diff line change
@@ -23,15 +23,9 @@ class PbList<E> extends ListBase<E> {
_check = _checkNotNull,
_isReadOnly = true;

PbList.from(List from) : super._from(from);

@Deprecated('Instead use the default constructor with a check function.'
'This constructor will be removed in the next major version.')
PbList.forFieldType(FieldType fieldType)
: super._noList(check: getCheckFunction(fieldType));

/// Freezes the list by converting to [FrozenPbList].
FrozenPbList<E> toFrozenPbList() => FrozenPbList<E>.from(this);
PbList.from(List from)
: _wrappedList = List<E>.from(from),
_check = _checkNotNull;

@override
void add(E element) {
12 changes: 7 additions & 5 deletions protobuf/lib/src/protobuf/proto3_json.dart
Original file line number Diff line number Diff line change
@@ -252,7 +252,7 @@ void _mergeFromProto3Json(
throw context.parseException(
'Expected int or stringified int', value);
}
return check32BitUnsigned(result);
return _check32BitUnsignedProto3(result, context);

case FieldBaseType.int32:
case FieldBaseType.sint32:
@@ -328,22 +328,24 @@ void _mergeFromProto3Json(
case FieldBaseType.uint64:
// TODO(sigurdm): We do not throw on negative values here.
// That would probably require going via bignum.
return tryParse64Bit(key);
return _tryParse64BitProto3(json, key, context);

case FieldBaseType.int64:
case FieldBaseType.sint64:
case FieldBaseType.sfixed64:
case FieldBaseType.fixed64:
return tryParse64Bit(key);
return _tryParse64BitProto3(json, key, context);

case FieldBaseType.int32:
case FieldBaseType.sint32:
case FieldBaseType.fixed32:
case FieldBaseType.sfixed32:
return check32BitSigned(tryParse32Bit(key));
return _check32BitSignedProto3(
_tryParse32BitProto3(key, context), context);

case FieldBaseType.uint32:
return check32BitUnsigned(tryParse32Bit(key));
return _check32BitUnsignedProto3(
_tryParse32BitProto3(key, context), context);

case FieldBaseType.bytes:
case FieldBaseType.double:
5 changes: 2 additions & 3 deletions protobuf/test/readonly_message_test.dart
Original file line number Diff line number Diff line change
@@ -11,9 +11,8 @@ import 'package:protobuf/protobuf.dart'
FieldBaseType,
FieldType,
GeneratedMessage,
UnknownFieldSetField,
frozenMessageModificationHandler,
defaultFrozenMessageModificationHandler;
PbFieldType,
UnknownFieldSetField;
import 'package:test/test.dart';

Matcher throwsError(Type expectedType, Matcher expectedMessage) =>
You are viewing a condensed version of this merge commit. You can view the full changes here.