Skip to content

Commit

Permalink
Mark deprecated Flutter iOS APIs as unavailable (flutter#6124)
Browse files Browse the repository at this point in the history
The following were previously marked as deprecated over a month ago:
* `FlutterStandardBigInteger`
* `-[FlutterDartProject initFromDefaultSourceForConfiguration]`

Remove their implementations and mark them as unavailable.
  • Loading branch information
jamesderlin authored and Amir Hardon committed Sep 21, 2018
1 parent be5750b commit 984383a
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 84 deletions.
4 changes: 4 additions & 0 deletions shell/platform/darwin/ios/framework/Headers/Flutter.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
/**
BREAKING CHANGES:
August 31, 2018: Marked -[FlutterDartProject
initFromDefaultSourceForConfiguration] and FlutterStandardBigInteger as
unavailable.
July 26, 2018: Marked -[FlutterDartProject
initFromDefaultSourceForConfiguration] deprecated.
Expand Down
23 changes: 2 additions & 21 deletions shell/platform/darwin/ios/framework/Headers/FlutterCodecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,6 @@ FLUTTER_EXPORT
- `FlutterStandardTypedData`: `Uint8List`, `Int32List`, `Int64List`, or `Float64List`
- `NSArray`: `List`
- `NSDictionary`: `Map`
Support for `FlutterStandardBigInteger` has been deprecated on 2018-01-09 to be
made unavailable four weeks after this change is available on the Flutter alpha
branch. `FlutterStandardBigInteger` were needed because the Dart 1.0 `int` type
had no size limit. With Dart 2.0, the `int` type is a fixed-size, 64-bit signed
integer. If you need to communicate larger integers, use `NSString` encoding
instead.
*/
FLUTTER_EXPORT
@interface FlutterStandardMessageCodec : NSObject <FlutterMessageCodec>
Expand Down Expand Up @@ -309,25 +302,13 @@ FLUTTER_EXPORT
and `FlutterStandardMethodCodec`.
*/
FLUTTER_EXPORT
FLUTTER_DEPRECATED(
"Deprecated on 2018-01-09 to be made unavailable four weeks after the "
"deprecation is available on the flutter/flutter alpha branch. "
FLUTTER_UNAVAILABLE(
"Unavailable on 2018-08-31. Deprecated on 2018-01-09. "
"FlutterStandardBigInteger was needed because the Dart 1.0 int type had no "
"size limit. With Dart 2.0, the int type is a fixed-size, 64-bit signed "
"integer. If you need to communicate larger integers, use NSString encoding "
"instead.")
@interface FlutterStandardBigInteger : NSObject
/**
Creates a `FlutterStandardBigInteger` from a hexadecimal representation.
- Parameter hex: a hexadecimal string.
*/
+ (instancetype)bigIntegerWithHex:(NSString*)hex;

/**
The hexadecimal string representation of this integer.
*/
@property(readonly, nonatomic) NSString* hex;
@end

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ FLUTTER_EXPORT
- (instancetype)initWithFlutterAssetsWithScriptSnapshot:(NSURL*)flutterAssetsURL
NS_DESIGNATED_INITIALIZER;

- (instancetype)initFromDefaultSourceForConfiguration FLUTTER_DEPRECATED("Use -init instead.");
- (instancetype)initFromDefaultSourceForConfiguration FLUTTER_UNAVAILABLE("Use -init instead.");

/**
Returns the file name for the given asset.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#endif // defined(NS_ASSUME_NONNULL_BEGIN)

/**
Indicates that the API has been deprecated for the specifed reason. Code that
Indicates that the API has been deprecated for the specified reason. Code that
uses the deprecated API will continue to work as before. However, the API will
soon become unavailable and users are encouraged to immediately take the
appropriate action mentioned in the deprecation message and the BREAKING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,7 @@ - (instancetype)initWithFlutterAssetsWithScriptSnapshot:(NSURL*)flutterAssetsURL
return self;
}

#pragma mark - Convenience initializers

// Exists for backward-compatibility. Expect this to be removed.
- (instancetype)initFromDefaultSourceForConfiguration {
return [self init];
}
#pragma mark - Settings accessors

- (const blink::Settings&)settings {
return _settings;
Expand Down
41 changes: 0 additions & 41 deletions shell/platform/darwin/ios/framework/Source/FlutterStandardCodec.mm
Original file line number Diff line number Diff line change
Expand Up @@ -203,41 +203,6 @@ - (NSUInteger)hash {
}
@end

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

@implementation FlutterStandardBigInteger
+ (instancetype)bigIntegerWithHex:(NSString*)hex {
return [[[FlutterStandardBigInteger alloc] initWithHex:hex] autorelease];
}

- (instancetype)initWithHex:(NSString*)hex {
NSAssert(hex, @"Hex cannot be nil");
self = [super init];
NSAssert(self, @"Super init cannot be nil");
_hex = [hex retain];
return self;
}

- (void)dealloc {
[_hex release];
[super dealloc];
}

- (BOOL)isEqual:(id)object {
if (self == object)
return YES;
if (![object isKindOfClass:[FlutterStandardBigInteger class]])
return NO;
FlutterStandardBigInteger* other = (FlutterStandardBigInteger*)object;
return [self.hex isEqual:other.hex];
}

- (NSUInteger)hash {
return [self.hex hash];
}
@end

#pragma mark - Writer and reader of standard codec

@implementation FlutterStandardWriter {
Expand Down Expand Up @@ -336,10 +301,6 @@ - (void)writeValue:(id)value {
NSString* string = value;
[self writeByte:FlutterStandardFieldString];
[self writeUTF8:string];
} else if ([value isKindOfClass:[FlutterStandardBigInteger class]]) {
FlutterStandardBigInteger* bigInt = value;
[self writeByte:FlutterStandardFieldIntHex];
[self writeUTF8:bigInt.hex];
} else if ([value isKindOfClass:[FlutterStandardTypedData class]]) {
FlutterStandardTypedData* typedData = value;
[self writeByte:FlutterStandardFieldForDataType(typedData.type)];
Expand Down Expand Up @@ -479,7 +440,6 @@ - (id)readValueOfType:(UInt8)type {
return [NSNumber numberWithDouble:value];
}
case FlutterStandardFieldIntHex:
return [FlutterStandardBigInteger bigIntegerWithHex:[self readUTF8]];
case FlutterStandardFieldString:
return [self readUTF8];
case FlutterStandardFieldUInt8Data:
Expand Down Expand Up @@ -522,4 +482,3 @@ - (FlutterStandardReader*)readerWithData:(NSData*)data {
return [[[FlutterStandardReader alloc] initWithData:data] autorelease];
}
@end
#pragma clang diagnostic pop
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ typedef NS_ENUM(NSInteger, FlutterStandardField) {
FlutterStandardFieldIntHex,
FlutterStandardFieldFloat64,
FlutterStandardFieldString,
// The following must match the corresponding order from `FlutterStandardDataType`.
FlutterStandardFieldUInt8Data,
FlutterStandardFieldInt32Data,
FlutterStandardFieldInt64Data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,13 @@ void checkEncodeDecode(id value) {
checkEncodeDecode(@(value), [NSData dataWithBytes:bytes length:9]);
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
TEST(FlutterStandardCodec, CanEncodeAndDecodeUInt64AsHexString) {
FlutterStandardMessageCodec* codec = [FlutterStandardMessageCodec sharedInstance];
UInt64 u64 = 0xfffffffffffffffa;
NSData* encoded = [codec encode:@(u64)];
FlutterStandardBigInteger* decoded = [codec decode:encoded];
ASSERT_TRUE([decoded.hex isEqual:@"fffffffffffffffa"]);
NSString* decoded = [codec decode:encoded];
ASSERT_TRUE([decoded isEqual:@"fffffffffffffffa"]);
}
#pragma clang diagnostic pop

TEST(FlutterStandardCodec, CanEncodeAndDecodeSInt8) {
uint8_t bytes[5] = {0x03, 0xfe, 0xff, 0xff, 0xff};
Expand All @@ -99,15 +96,6 @@ void checkEncodeDecode(id value) {
checkEncodeDecode(@(0x1234567890abcdef), [NSData dataWithBytes:bytes length:9]);
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
TEST(FlutterStandardCodec, CanEncodeAndDecodeBigInteger) {
FlutterStandardBigInteger* value =
[FlutterStandardBigInteger bigIntegerWithHex:@"-abcdef0123456789abcdef01234567890"];
checkEncodeDecode(value);
}
#pragma clang diagnostic pop

TEST(FlutterStandardCodec, CanEncodeAndDecodeFloat32) {
uint8_t bytes[16] = {0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x60, 0xfb, 0x21, 0x09, 0x40};
Expand Down

0 comments on commit 984383a

Please sign in to comment.