-
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
SDL-0234 Proxy Library RPC Generation #1556
SDL-0234 Proxy Library RPC Generation #1556
Conversation
@vladmu Thank you for all the work on implementing the RPC generator scripts. I ran the generator and used a diff tool to compare. It looks like many of the initializers are missing. In rare cases the classes contain outstanding methods like Another example where the developers manually deprecated a parameter:
Question: When creating new RPC files how are these files going to be added to the Xcode project? I doubt there is a way to add files programmatically to the pbxproj file. @joeljfischer I know this PR isn't ready for review but I believe this proposal implementation needs attention. Some details like the deprecation or the custom methods like |
@kshala-ford I pointed in the PR Summary regarding this. The effort for mapping all classes is more than simple manual coding, as we need to customize almost all RPCs. We agreed with PMs to postpone the mapping for the current stage.
I believe it should be done manually by the person who generates the particular RPC and tries to commit this code into the repository. |
@vladmu Good point. I should have had a closer look at the issue. Let's continue such discussions in the issue. |
@kshala-ford @theresalech respecting the committee decided to remove the following section from the proposal downsides:
It would be appreciated if you could summarize and define action points for us here regarding what we should do in this PR to follow the SDLC decision. As soon as Ford approves this PR, the status will be moved to "ready for review". |
Hi @vladmu - mappings for exceptions/corner cases should be removed from this PR. Please reference PM feedback provided on the Java Suite PR, and let us know if you have any additional questions. Thank you! |
I think the action item would look like this:
|
@theresalech @joeljfischer thank you for your answers and clarification. We are going to follow that now. @kshala-ford @mrapitis the PR is ready for Ford review, please take a look. |
I ran the scripts to generate all classes and manually reviewed the resulted code. I'm not looking for replacing existing RPCs but wanted to review and understand how the scripts behave if new RPCs would be added. Here a few things I found: 1. @interface SDLSetDisplayLayoutResponse : SDLRPCResponse __deprecated This results in an Xcode parser error. The error is __attribute__ ((deprecated))
@interface SDLSetDisplayLayoutResponse : SDLRPCResponse @joeljfischer please confirm if you're OK with this approach. 2. /**
* This RPC is deprecated. Use Show RPC to change layout.
*
* @deprecated
* @since SDL 6.0.0
*/
@interface SDLSetDisplayLayout : SDLRPCRequest 3. 4. I believe the reason was that I test with 5. 6. See example output of a numeric enum typedef NS_ENUM(NSUInteger, SDLPredefinedWindows){
/// The default window is a main window pre-created on behalf of the app.
SDLPredefinedWindowsDefaultWindow = 0,
/// The primary widget of the app.
SDLPredefinedWindowsPrimaryWidget = 1
}; 7. |
__deprecated
@interface SDLOnLockScreenStatus : SDLRPCNotification
3/4/5. This is annoying. I think we should just generate straight from the RPC_Spec, but I can see both arguments. Whichever way it goes, it needs to align with Java_Suite.
|
/**
* This RPC is deprecated. Use Show RPC to change layout.
*
* @deprecated
* @history SDL 3.0.0
* @since SDL 6.0.0
*/
__deprecated
@interface SDLSetDisplayLayout : SDLRPCRequest 3/4/5. Currently generator generate as is from the mobile API. Let me know if you would like to hardcode any other approach, e.g. capitalize Vr to VR and Hmi to HMI.
|
@kshala-ford @mrapitis please let us know once Ford has approved this PR and it is ready for Livio review, thanks! |
@theresalech Ford has approved of this PR. |
@theresalech I marked the PR as ready for Livio review in the description. Please take a look. |
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 getting too long, so review part 1
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 getting too long, so review part 1
@joeljfischer The PR is ready for review. |
Co-Authored-By: Joel Fischer <joeljfischer@gmail.com>
@joeljfischer The PR is ready for review. |
@o-mishch @vladmu Alongside the Java Suite and JavaScript Suite the iOS library generator will need to avoid using reserved keywords. See the PR description by @bilal-alsharifi (I have copied the current version below) for a list of rules that should be followed when avoiding these reserved keywords. Here is the PR: smartdevicelink/rpc_spec#232
Let me know if there are any questions. |
generator/templates/enums/template.h
Outdated
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
{%- endif %} | ||
extern {{ name }} const {{ name }}{{param.name}}{{ " __deprecated" if param.deprecated and param.deprecated }}; |
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.
Enums don't need to modify their object based on the reserved keywords unless the entire value (remember we prefix with SDL and the enum type) matches the reserved keyword.
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 if keyword would be SDLDisplayTypeCID
then it should be renamed as follow?
//DisplayType.h
extern SDLDisplayType const SDLDisplayTypeCidParam;
//DisplayType.m
SDLDisplayType const SDLDisplayTypeCidParam = @"CID_PARAM";
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.
If the keyword is CID, it would be:
//DisplayType.h
extern SDLDisplayType const SDLDisplayTypeCid;
//DisplayType.m
SDLDisplayType const SDLDisplayTypeCidParam = @"CID";
If the keyword were SDLDisplayTypeCID
it would be:
//DisplayType.h
extern SDLDisplayType const SDLDisplayTypeCidParam;
//DisplayType.m
SDLDisplayType const SDLDisplayTypeCidParam = @"CID";
The string value MUST remain as the constant (and having a string be a keyword is fine in any language anyway), or else SDL will fail.
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.
done in 8d53846
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 doesn't seem to be completely fixed. SDLImageType
's static
value: SDLImageTypeStatic
is being turned into SDLImageTypeStaticParam
. This shouldn't happen because SDLImageTypeStatic
is not a keyword even though static
is.
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 for SDLAppHMIDefaultParam
, that should be SDLAppHMIDefault
.
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 for SDLResultSuccessParam
. It should be SDLResultSuccess
.
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.
changed to following regex:
r'^(sdl)?({}){}$'.format(item_name.casefold(), name.casefold())
in e131215
@joeljfischer The PR is ready for review. |
Fixes #1298
This PR is [ready] for review.
Risk
This PR makes [no] API changes.
Testing Plan
Unit Tests
Covered by unit tests and PyLint.
Summary
According to [SDL-0234] Proxy Library RPC Generation proposal, this PR adds the Python generator script based on XML Parser from smartdevicelink/rpc_spec linked to the repository as Git submodule. Based on answers provided by PMs in the related issue #1298 all customizations are postponed at this stage, the generated code follows the naming convention described here #1298 (comment), requirements of initializers described here #1298 (comment) and common behavior of other code parts, defined from the existing source code. The generated code is not a full replacement of existing RPC classes and doesn't guarantee the build and existing unit tests will be passed after the full replacement. Meantime the generator includes the rich "custom mapping" tool which allows customizing classes over the generation process if needed.
Changelog
Enhancements
generator/rpc_spec
submodule pointed todevelop
branch ofsmartdevicelink/rpc_spec
repositoryProxy RPC Generator
based on Python 3.5 and linked with parser from thegenerator/rpc_spec
submoduleREADME.md
with usage descriptionCLA