-
Notifications
You must be signed in to change notification settings - Fork 103
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
Converting SDLNames Defines to Constants #446
Conversation
…so modified SDLFunctionID to use a static dictionary.
@@ -505,7 +505,7 @@ | |||
5D61FCF91A84238C00846EE7 /* SDLMenuParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D61FB0C1A84238A00846EE7 /* SDLMenuParams.m */; }; | |||
5D61FCFA1A84238C00846EE7 /* SDLMyKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D61FB0D1A84238A00846EE7 /* SDLMyKey.h */; settings = {ATTRIBUTES = (Public, ); }; }; | |||
5D61FCFB1A84238C00846EE7 /* SDLMyKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D61FB0E1A84238A00846EE7 /* SDLMyKey.m */; }; | |||
5D61FCFC1A84238C00846EE7 /* SDLNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D61FB0F1A84238A00846EE7 /* SDLNames.h */; }; | |||
5D61FCFC1A84238C00846EE7 /* SDLNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D61FB0F1A84238A00846EE7 /* SDLNames.h */; settings = {ATTRIBUTES = (Public, ); }; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this have to be public now?
} else { | ||
[parameters removeObjectForKey:NAMES_ttsName]; | ||
[parameters removeObjectForKey:SDLNameTtsName]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be SDLNameTTSName
?
@98305: SDLNameOnSyncPData | ||
}; | ||
} | ||
self.functionIDs = functionIDs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be better as a singleton? Kind of weird to have to create a new object every time.
- (NSString *)getFunctionName:(int)functionID { | ||
return [functionIDs objectForKey:[NSString stringWithFormat:@"%d", functionID]]; | ||
- (SDLName)getFunctionName:(int)functionID { | ||
return [self.functionIDs objectForKey:@(functionID)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can use shortened syntax: self.functionIDs[@(functionID)]
|
||
@property (nonatomic, strong, nonnull) NSDictionary* functionIDs; | ||
|
||
@end | ||
|
||
@implementation SDLFunctionID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class can be private
} | ||
return self; | ||
} | ||
|
||
- (NSString *)getFunctionName:(int)functionID { | ||
return [functionIDs objectForKey:[NSString stringWithFormat:@"%d", functionID]]; | ||
- (SDLName)getFunctionName:(int)functionID { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The get
function naming is very Java. Should probably be more like functionNameForId:
} | ||
|
||
- (void)setUtcYear:(NSNumber *)utcYear { | ||
if (utcYear != nil) { | ||
[store setObject:utcYear forKey:NAMES_utcYear]; | ||
[store setObject:utcYear forKey:SDLNameUtcYear]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above comment regarding capitalization?
@joeljfischer I think this is ready, can you validate? |
…into feature/issue_3_constant_names * 'develop' of https://github.com/smartdevicelink/sdl_ios: Update public imports for organization and to remove a duplicate A few more updates to travis scripts Try better Travis CI build formatting
Current coverage is 67.39% (diff: 69.55%)@@ develop #446 diff @@
==========================================
Files 334 334
Lines 10451 10515 +64
Methods 3059 3061 +2
Messages 0 0
Branches 799 799
==========================================
+ Hits 2893 7087 +4194
+ Misses 7500 3036 -4464
- Partials 58 392 +334
|
@@ -427,7 +427,7 @@ | |||
5D61FCAA1A84238C00846EE7 /* SDLFileType.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D61FABD1A84238A00846EE7 /* SDLFileType.m */; }; | |||
5D61FCAB1A84238C00846EE7 /* SDLFuelCutoffStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D61FABE1A84238A00846EE7 /* SDLFuelCutoffStatus.h */; settings = {ATTRIBUTES = (Public, ); }; }; | |||
5D61FCAC1A84238C00846EE7 /* SDLFuelCutoffStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D61FABF1A84238A00846EE7 /* SDLFuelCutoffStatus.m */; }; | |||
5D61FCAD1A84238C00846EE7 /* SDLFunctionID.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D61FAC01A84238A00846EE7 /* SDLFunctionID.h */; }; | |||
5D61FCAD1A84238C00846EE7 /* SDLFunctionID.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D61FAC01A84238A00846EE7 /* SDLFunctionID.h */; settings = {ATTRIBUTES = (Private, ); }; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, we don't actually want 'private', we want 'project'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that was a needle in haystack hunt...
@@ -42,7 +42,7 @@ __deprecated_msg("Use SDLManager instead") | |||
- (void)sendRPCRequest:(SDLRPCMessage *)msg __deprecated_msg("use -sendRPC: instead"); | |||
|
|||
- (void)handleRPCDictionary:(NSDictionary *)dictionary; | |||
- (void)handleRpcMessage:(NSDictionary *)msg __deprecated_msg("use -handleRPCDictionary: instead"); | |||
- (void)handleRPCMessage:(NSDictionary *)msg __deprecated_msg("use -handleRPCDictionary: instead"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cannot be changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a mis-commit when using regex to modify the 1,000,000 files involved in this PR.
@@ -203,7 +203,7 @@ - (BOOL)sendRPC:(SDLRPCMessage *)message encrypted:(BOOL)encryption error:(NSErr | |||
// Build a binary header | |||
// Serialize the RPC data into an NSData | |||
SDLRPCPayload *rpcPayload = [[SDLRPCPayload alloc] init]; | |||
rpcPayload.functionID = [[[[SDLFunctionID alloc] init] getFunctionID:[message getFunctionName]] intValue]; | |||
rpcPayload.functionID = [[[SDLFunctionID sharedInstance] functionIdForName:[message functionNameForId]] intValue]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things about this seem odd.
- Why are we getting the name for the id, then the id for the name? Seems circular?
- Wouldn't the message's
functionNameForId
method just befunctionName
if we're not passing anything? Can't find if or where that changed in this PR though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems we need a way to retrieve the id for a function name (as a response perhaps?) and the function name for the id (to send a request?). This is just a slight modification/improvement over how it's already been done. A full revamp can be done for 5.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think i was just confused by the change in [message functionNameForId]
. It's actually getting the function name not the id.
@@ -13,7 +13,7 @@ | |||
|
|||
- (instancetype)initWithName:(NSString *)name; | |||
- (instancetype)initWithDictionary:(NSMutableDictionary *)dict; | |||
- (NSString *)getFunctionName; | |||
- (NSString *)functionNameForId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, here it is, guessing a copy-paste error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So to be clear, this has to stay the same to preserve the impact of this PR.
Fixes #3
This PR is ready for review.
Risk
This PR makes no API changes.
Testing Plan
These changes have 100% passing tests.
Summary
This PR changes all
#define
s in SDLNames.h to use a typedef ofNSString*
calledSDLName
. Also,SDLFunctionID
now uses a staticNSDictionary
for function names/ids to improve performance, and only one should ever need to be allocated.Changelog
Enchancements