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

[SDL-0005] Immutable RPC collections #508

Merged
merged 5 commits into from
Jan 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion SmartDeviceLink-iOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ s.source_files = "SmartDeviceLink/*.{h,m}"
s.requires_arc = true
s.resource_bundles = { 'SmartDeviceLink' => ['SmartDeviceLink/Assets/**/*', 'SmartDeviceLink/iOS 7 Assets/*'] }
s.public_header_files = [
'SmartDeviceLink/NSMutableDictionary+Store.h',
'SmartDeviceLink/SmartDeviceLink.h',
'SmartDeviceLink/SDLJingle.h',
'SmartDeviceLink/SDLProxy.h',
Expand Down
2 changes: 1 addition & 1 deletion SmartDeviceLink-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@
5DFFB9151BD7C89700DB3F04 /* SDLConnectionManagerType.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DFFB9141BD7C89700DB3F04 /* SDLConnectionManagerType.h */; };
DA0C46AD1DCD35080001F2A8 /* SDLNames.m in Sources */ = {isa = PBXBuildFile; fileRef = DA0C46AC1DCD35080001F2A8 /* SDLNames.m */; };
DA0C46AF1DCD41E30001F2A8 /* SDLMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = DA0C46AE1DCD41E30001F2A8 /* SDLMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA318C1F1DD0F06C00C035AC /* NSMutableDictionary+Store.h in Headers */ = {isa = PBXBuildFile; fileRef = DA318C1D1DD0F06C00C035AC /* NSMutableDictionary+Store.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA318C1F1DD0F06C00C035AC /* NSMutableDictionary+Store.h in Headers */ = {isa = PBXBuildFile; fileRef = DA318C1D1DD0F06C00C035AC /* NSMutableDictionary+Store.h */; };
DA318C201DD0F06C00C035AC /* NSMutableDictionary+Store.m in Sources */ = {isa = PBXBuildFile; fileRef = DA318C1E1DD0F06C00C035AC /* NSMutableDictionary+Store.m */; };
DA4353DF1D271FD10099B8C4 /* CGPointUtilSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353DE1D271FD10099B8C4 /* CGPointUtilSpec.m */; };
DA4353E31D2720A30099B8C4 /* SDLPinchGestureSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353E21D2720A30099B8C4 /* SDLPinchGestureSpec.m */; };
Expand Down
3 changes: 1 addition & 2 deletions SmartDeviceLink/NSMutableDictionary+Store.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ typedef NSString* SDLEnum SDL_SWIFT_ENUM;
- (void)sdl_setObject:(NSObject *)object forName:(SDLName)name;
- (nullable id)sdl_objectForName:(SDLName)name;
- (nullable id)sdl_objectForName:(SDLName)name ofClass:(Class)classType;
- (NSMutableArray *)sdl_objectsForName:(SDLName)name ofClass:(Class)classType;
- (NSMutableArray<SDLEnum> *)sdl_enumsForName:(SDLName)name;
- (NSArray *)sdl_objectsForName:(SDLName)name ofClass:(Class)classType;

@end

Expand Down
23 changes: 6 additions & 17 deletions SmartDeviceLink/NSMutableDictionary+Store.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,18 @@ - (nullable id)sdl_objectForName:(SDLName)name ofClass:(Class)classType {
}
}

- (NSMutableArray *)sdl_objectsForName:(SDLName)name ofClass:(Class)classType {
NSMutableArray *array = [self sdl_objectForName:name];
if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:classType.class]) {
- (NSArray *)sdl_objectsForName:(SDLName)name ofClass:(Class)classType {
NSArray *array = [self sdl_objectForName:name];
if ([array count] < 1 || [array.firstObject isMemberOfClass:classType.class]) {
// It's an array of the actual class type, just return
return array;
} else {
// It's an array of dictionaries, make them into their class type
NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]];
for (NSDictionary<NSString *, id> *dict in array) {
[newList addObject:[[classType alloc] initWithDictionary:dict]];
}
return newList;
}
}

- (NSMutableArray<SDLEnum> *)sdl_enumsForName:(SDLName)name {
NSMutableArray<SDLEnum> *array = [self sdl_objectForName:name];
if ([array count] < 1) {
return array;
} else {
NSMutableArray<SDLEnum> *newList = [NSMutableArray arrayWithCapacity:[array count]];
for (SDLEnum enumString in array) {
[newList addObject:enumString];
}
return newList;
return [newList copy];
}
}

Expand Down
2 changes: 1 addition & 1 deletion SmartDeviceLink/SDLAddCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* Optional, Array of Strings, Max String length 99 chars, Array size 1 - 100
*/
@property (nullable, strong, nonatomic) NSMutableArray<NSString *> *vrCommands;
@property (nullable, strong, nonatomic) NSArray<NSString *> *vrCommands;

/**
* @abstract Image struct containing a static or dynamic icon
Expand Down
4 changes: 2 additions & 2 deletions SmartDeviceLink/SDLAddCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ - (nullable SDLMenuParams *)menuParams {
return [parameters sdl_objectForName:SDLNameMenuParams ofClass:SDLMenuParams.class];
}

- (void)setVrCommands:(nullable NSMutableArray<NSString *> *)vrCommands {
- (void)setVrCommands:(nullable NSArray<NSString *> *)vrCommands {
[parameters sdl_setObject:vrCommands forName:SDLNameVRCommands];
}

- (nullable NSMutableArray<NSString *> *)vrCommands {
- (nullable NSArray<NSString *> *)vrCommands {
return [parameters sdl_objectForName:SDLNameVRCommands];
}

Expand Down
4 changes: 2 additions & 2 deletions SmartDeviceLink/SDLAlert.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @see SDLTTSChunk
*/
@property (nullable, strong, nonatomic) NSMutableArray<SDLTTSChunk *> *ttsChunks;
@property (nullable, strong, nonatomic) NSArray<SDLTTSChunk *> *ttsChunks;

/**
* @abstract The duration of the displayed portion of the alert, in milliseconds.
Expand Down Expand Up @@ -153,7 +153,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @see SDLSoftButton
*/
@property (nullable, strong, nonatomic) NSMutableArray<SDLSoftButton *> *softButtons;
@property (nullable, strong, nonatomic) NSArray<SDLSoftButton *> *softButtons;

@end

Expand Down
10 changes: 5 additions & 5 deletions SmartDeviceLink/SDLAlert.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ - (instancetype)initWithTTS:(nullable NSString *)ttsText alertText1:(nullable NS
}

- (instancetype)initWithTTS:(nullable NSString *)ttsText alertText1:(nullable NSString *)alertText1 alertText2:(nullable NSString *)alertText2 alertText3:(nullable NSString *)alertText3 playTone:(BOOL)playTone duration:(UInt16)duration {
NSMutableArray *ttsChunks = [SDLTTSChunk textChunksFromString:ttsText];
NSArray *ttsChunks = [SDLTTSChunk textChunksFromString:ttsText];
return [self initWithTTSChunks:ttsChunks alertText1:alertText1 alertText2:alertText2 alertText3:alertText3 playTone:playTone duration:duration softButtons:nil];
}

Expand Down Expand Up @@ -97,11 +97,11 @@ - (nullable NSString *)alertText3 {
return [parameters sdl_objectForName:SDLNameAlertText3];
}

- (void)setTtsChunks:(nullable NSMutableArray<SDLTTSChunk *> *)ttsChunks {
- (void)setTtsChunks:(nullable NSArray<SDLTTSChunk *> *)ttsChunks {
[parameters sdl_setObject:ttsChunks forName:SDLNameTTSChunks];
}

- (nullable NSMutableArray<SDLTTSChunk *> *)ttsChunks {
- (nullable NSArray<SDLTTSChunk *> *)ttsChunks {
return [parameters sdl_objectsForName:SDLNameTTSChunks ofClass:SDLTTSChunk.class];
}

Expand Down Expand Up @@ -129,11 +129,11 @@ - (void)setProgressIndicator:(nullable NSNumber<SDLBool> *)progressIndicator {
return [parameters sdl_objectForName:SDLNameProgressIndicator];
}

- (void)setSoftButtons:(nullable NSMutableArray<SDLSoftButton *> *)softButtons {
- (void)setSoftButtons:(nullable NSArray<SDLSoftButton *> *)softButtons {
[parameters sdl_setObject:softButtons forName:SDLNameSoftButtons];
}

- (nullable NSMutableArray<SDLSoftButton *> *)softButtons {
- (nullable NSArray<SDLSoftButton *> *)softButtons {
return [parameters sdl_objectsForName:SDLNameSoftButtons ofClass:SDLSoftButton.class];
}

Expand Down
4 changes: 2 additions & 2 deletions SmartDeviceLink/SDLAlertManeuver.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithTTS:(nullable NSString *)ttsText softButtons:(nullable NSArray<SDLSoftButton *> *)softButtons;
- (instancetype)initWithTTSChunks:(nullable NSArray<SDLTTSChunk *> *)ttsChunks softButtons:(nullable NSArray<SDLSoftButton *> *)softButtons;

@property (nullable, strong, nonatomic) NSMutableArray<SDLTTSChunk *> *ttsChunks;
@property (nullable, strong, nonatomic) NSMutableArray<SDLSoftButton *> *softButtons;
@property (nullable, strong, nonatomic) NSArray<SDLTTSChunk *> *ttsChunks;
@property (nullable, strong, nonatomic) NSArray<SDLSoftButton *> *softButtons;

@end

Expand Down
10 changes: 5 additions & 5 deletions SmartDeviceLink/SDLAlertManeuver.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ - (instancetype)init {


- (instancetype)initWithTTS:(nullable NSString *)ttsText softButtons:(nullable NSArray<SDLSoftButton *> *)softButtons {
NSMutableArray *ttsChunks = [SDLTTSChunk textChunksFromString:ttsText];
NSArray *ttsChunks = [SDLTTSChunk textChunksFromString:ttsText];
return [self initWithTTSChunks:ttsChunks softButtons:softButtons];
}

Expand All @@ -37,19 +37,19 @@ - (instancetype)initWithTTSChunks:(nullable NSArray<SDLTTSChunk *> *)ttsChunks s
return self;
}

- (void)setTtsChunks:(nullable NSMutableArray<SDLTTSChunk *> *)ttsChunks {
- (void)setTtsChunks:(nullable NSArray<SDLTTSChunk *> *)ttsChunks {
[parameters sdl_setObject:ttsChunks forName:SDLNameTTSChunks];
}

- (nullable NSMutableArray<SDLTTSChunk *> *)ttsChunks {
- (nullable NSArray<SDLTTSChunk *> *)ttsChunks {
return [parameters sdl_objectsForName:SDLNameTTSChunks ofClass:SDLTTSChunk.class];
}

- (void)setSoftButtons:(nullable NSMutableArray<SDLSoftButton *> *)softButtons {
- (void)setSoftButtons:(nullable NSArray<SDLSoftButton *> *)softButtons {
[parameters sdl_setObject:softButtons forName:SDLNameSoftButtons];
}

- (nullable NSMutableArray<SDLSoftButton *> *)softButtons {
- (nullable NSArray<SDLSoftButton *> *)softButtons {
return [parameters sdl_objectsForName:SDLNameSoftButtons ofClass:SDLSoftButton.class];
}

Expand Down
4 changes: 2 additions & 2 deletions SmartDeviceLink/SDLChoice.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* </tr>
* <tr>
* <td>vrCommands</td>
* <td>NSMutableArray *</td>
* <td>NSArray *</td>
* <td>An array of strings to be used as VR synonyms for this choice. If this array is provided, it must have at least one non-empty element</td>
* <td>SmartDeviceLink 1.0</td>
* </tr>
Expand Down Expand Up @@ -77,7 +77,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* Required, Array of Strings, Array length 1 - 100, Max String length 99 chars
*/
@property (strong, nonatomic) NSMutableArray<NSString *> *vrCommands;
@property (strong, nonatomic) NSArray<NSString *> *vrCommands;

/**
* @abstract The image of the choice
Expand Down
4 changes: 2 additions & 2 deletions SmartDeviceLink/SDLChoice.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ - (NSString *)menuName {
return [store sdl_objectForName:SDLNameMenuName];
}

- (void)setVrCommands:(NSMutableArray<NSString *> *)vrCommands {
- (void)setVrCommands:(NSArray<NSString *> *)vrCommands {
[store sdl_setObject:vrCommands forName:SDLNameVRCommands];
}

- (NSMutableArray<NSString *> *)vrCommands {
- (NSArray<NSString *> *)vrCommands {
return [store sdl_objectForName:SDLNameVRCommands];
}

Expand Down
2 changes: 1 addition & 1 deletion SmartDeviceLink/SDLCreateInteractionChoiceSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* Required, SDLChoice, Array size 1 - 100
*/
@property (strong, nonatomic) NSMutableArray<SDLChoice *> *choiceSet;
@property (strong, nonatomic) NSArray<SDLChoice *> *choiceSet;

@end

Expand Down
4 changes: 2 additions & 2 deletions SmartDeviceLink/SDLCreateInteractionChoiceSet.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ - (void)setInteractionChoiceSetID:(NSNumber<SDLInt> *)interactionChoiceSetID {
return [parameters sdl_objectForName:SDLNameInteractionChoiceSetId];
}

- (void)setChoiceSet:(NSMutableArray<SDLChoice *> *)choiceSet {
- (void)setChoiceSet:(NSArray<SDLChoice *> *)choiceSet {
[parameters sdl_setObject:choiceSet forName:SDLNameChoiceSet];
}

- (NSMutableArray<SDLChoice *> *)choiceSet {
- (NSArray<SDLChoice *> *)choiceSet {
return [parameters sdl_objectsForName:SDLNameChoiceSet ofClass:SDLChoice.class];
}

Expand Down
2 changes: 1 addition & 1 deletion SmartDeviceLink/SDLDiagnosticMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* Required, Array of NSNumber (Integers), Array size 1 - 65535, Integer Size 0 - 255
*/
@property (strong, nonatomic) NSMutableArray<NSNumber<SDLInt> *> *messageData;
@property (strong, nonatomic) NSArray<NSNumber<SDLInt> *> *messageData;

@end

Expand Down
4 changes: 2 additions & 2 deletions SmartDeviceLink/SDLDiagnosticMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ - (void)setMessageLength:(NSNumber<SDLInt> *)messageLength {
return [parameters sdl_objectForName:SDLNameMessageLength];
}

- (void)setMessageData:(NSMutableArray<NSNumber<SDLInt> *> *)messageData {
- (void)setMessageData:(NSArray<NSNumber<SDLInt> *> *)messageData {
[parameters sdl_setObject:messageData forName:SDLNameMessageData];
}

- (NSMutableArray<NSNumber<SDLInt> *> *)messageData {
- (NSArray<NSNumber<SDLInt> *> *)messageData {
return [parameters sdl_objectForName:SDLNameMessageData];
}

Expand Down
2 changes: 1 addition & 1 deletion SmartDeviceLink/SDLDiagnosticMessageResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN

@interface SDLDiagnosticMessageResponse : SDLRPCResponse

@property (strong, nonatomic) NSMutableArray<NSNumber<SDLInt> *> *messageDataResult;
@property (strong, nonatomic) NSArray<NSNumber<SDLInt> *> *messageDataResult;

@end

Expand Down
4 changes: 2 additions & 2 deletions SmartDeviceLink/SDLDiagnosticMessageResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ - (instancetype)init {
return self;
}

- (void)setMessageDataResult:(NSMutableArray<NSNumber<SDLInt> *> *)messageDataResult {
- (void)setMessageDataResult:(NSArray<NSNumber<SDLInt> *> *)messageDataResult {
[parameters sdl_setObject:messageDataResult forName:SDLNameMessageDataResult];
}

- (NSMutableArray<NSNumber<SDLInt> *> *)messageDataResult {
- (NSArray<NSNumber<SDLInt> *> *)messageDataResult {
return [parameters objectForKey:SDLNameMessageDataResult];
}

Expand Down
8 changes: 4 additions & 4 deletions SmartDeviceLink/SDLDisplayCapabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* Required, Array of SDLTextField, 1 - 100 objects
*/
@property (strong, nonatomic) NSMutableArray<SDLTextField *> *textFields;
@property (strong, nonatomic) NSArray<SDLTextField *> *textFields;

/**
* @abstract An array of SDLImageField elements
Expand All @@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* Optional, Array of SDLImageField, 1 - 100 objects
*/
@property (nullable, strong, nonatomic) NSMutableArray<SDLImageField *> *imageFields;
@property (nullable, strong, nonatomic) NSArray<SDLImageField *> *imageFields;

/**
* @abstract An array of SDLMediaClockFormat elements, defining the valid string formats used in specifying the contents of the media clock field
Expand All @@ -56,7 +56,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* Required, Array of SDLMediaClockFormats, 0 - 100 objects
*/
@property (strong, nonatomic) NSMutableArray<SDLMediaClockFormat> *mediaClockFormats;
@property (strong, nonatomic) NSArray<SDLMediaClockFormat> *mediaClockFormats;

/**
* @abstract The display's persistent screen supports.
Expand All @@ -74,7 +74,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* Optional, Array of String, max string size 100, 0 - 100 objects
*/
@property (nullable, strong, nonatomic) NSMutableArray<NSString *> *templatesAvailable;
@property (nullable, strong, nonatomic) NSArray<NSString *> *templatesAvailable;

/**
* @abstract A set of all parameters related to a prescribed screen area (e.g. for video / touch input)
Expand Down
18 changes: 9 additions & 9 deletions SmartDeviceLink/SDLDisplayCapabilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@ - (SDLDisplayType)displayType {
return [store sdl_objectForName:SDLNameDisplayType];
}

- (void)setTextFields:(NSMutableArray<SDLTextField *> *)textFields {
- (void)setTextFields:(NSArray<SDLTextField *> *)textFields {
[store sdl_setObject:textFields forName:SDLNameTextFields];
}

- (NSMutableArray<SDLTextField *> *)textFields {
- (NSArray<SDLTextField *> *)textFields {
return [store sdl_objectsForName:SDLNameTextFields ofClass:SDLTextField.class];
}

- (void)setImageFields:(nullable NSMutableArray<SDLImageField *> *)imageFields {
- (void)setImageFields:(nullable NSArray<SDLImageField *> *)imageFields {
[store sdl_setObject:imageFields forName:SDLNameImageFields];
}

- (nullable NSMutableArray<SDLImageField *> *)imageFields {
- (nullable NSArray<SDLImageField *> *)imageFields {
return [store sdl_objectsForName:SDLNameImageFields ofClass:SDLImageField.class];
}

- (void)setMediaClockFormats:(NSMutableArray<SDLMediaClockFormat> *)mediaClockFormats {
- (void)setMediaClockFormats:(NSArray<SDLMediaClockFormat> *)mediaClockFormats {
[store sdl_setObject:mediaClockFormats forName:SDLNameMediaClockFormats];
}

- (NSMutableArray<SDLMediaClockFormat> *)mediaClockFormats {
return [store sdl_enumsForName:SDLNameMediaClockFormats];
- (NSArray<SDLMediaClockFormat> *)mediaClockFormats {
return [store sdl_objectForName:SDLNameMediaClockFormats];
}

- (void)setGraphicSupported:(NSNumber<SDLBool> *)graphicSupported {
Expand All @@ -53,11 +53,11 @@ - (void)setGraphicSupported:(NSNumber<SDLBool> *)graphicSupported {
return [store sdl_objectForName:SDLNameGraphicSupported];
}

- (void)setTemplatesAvailable:(nullable NSMutableArray<NSString *> *)templatesAvailable {
- (void)setTemplatesAvailable:(nullable NSArray<NSString *> *)templatesAvailable {
[store sdl_setObject:templatesAvailable forName:SDLNameTemplatesAvailable];
}

- (nullable NSMutableArray<NSString *> *)templatesAvailable {
- (nullable NSArray<NSString *> *)templatesAvailable {
return [store sdl_objectForName:SDLNameTemplatesAvailable];
}

Expand Down
2 changes: 1 addition & 1 deletion SmartDeviceLink/SDLEncodedSyncPData.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ NS_ASSUME_NONNULL_BEGIN

@interface SDLEncodedSyncPData : SDLRPCRequest

@property (strong, nonatomic) NSMutableArray<NSString *> *data;
@property (strong, nonatomic) NSArray<NSString *> *data;

@end

Expand Down
4 changes: 2 additions & 2 deletions SmartDeviceLink/SDLEncodedSyncPData.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ - (instancetype)init {
return self;
}

- (void)setData:(NSMutableArray<NSString *> *)data {
- (void)setData:(NSArray<NSString *> *)data {
[parameters sdl_setObject:data forName:SDLNameData];
}

- (NSMutableArray<NSString *> *)data {
- (NSArray<NSString *> *)data {
return [parameters sdl_objectForName:SDLNameData];
}

Expand Down
Loading