-
Notifications
You must be signed in to change notification settings - Fork 9
Fixed mrc_class_method_def blocks for methods that return a value #299
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
base: main
Are you sure you want to change the base?
Fixed mrc_class_method_def blocks for methods that return a value #299
Conversation
Added constants for NO_RETURN_VALUE and UNTYPED_RETURN_VALUE. Added upgrade_004_to_005 to change mrcReturnType from 'Any' to UNTYPED_RETURN_VALUE. Changed createCustomMethodBlockWithReturn to use UNTYPED_RETURN_VALUE instead of 'Any'. In upgrade_project.ts: Incremented CURRENT_VERSION to 0.0.5. Changed switch statement in upgradeProjectIfNecessary to have the default case at the top. All other cases have @ts-ignore and blank lines so it is more clear that the @ts-ignore goes with the case after it. Added upgradeBlocksFiles function that can be called from other upgradeFrom_..._to_... functions. Added upgradeFrom_004_to_005.
Added upgrade_002_to_003 function. In upgrade_project.ts: Modified upgradeBlocksFiles to take a predicate function. Added anyModuleType and isOpMode functions that can be passed to upgradeBlocksFiles as the predicate function. Modified upgradeFrom_002_to_003 to call upgradeBlocksFiles. Modified upgradeFrom_004_to_005 to pass anyModuleType to upgradeBlocksFiles.
…cksFiles. Modified upgradeFrom_001_to_002 to call upgradeBlocksFiles.
Renamed function hidePrivateComponents to upgrade_001_to_002 and added code to check that the module type is ROBOT. In module_content.ts: Renamed addPrivateComponents to preupgrade_001_to_002. In upgrade_project.ts: Updated upgradeFrom_001_to_002.
alan412
left a comment
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.
How does this work when there are multiple blocks that need to be upgraded? Do you just create a method here that calls each one and then pass it in?
src/blocks/mrc_class_method_def.ts
Outdated
| */ | ||
| export function upgrade_002_to_003(workspace: Blockly.Workspace): void { | ||
| // Make sure the workspace is headless. | ||
| if (workspace.rendered) { |
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.
Should we pull these out and check it in the upgrade project so it doesn't have to be littered throughout the code?
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 purpose of checking it here is to make sure this function is not called from code other than the upgrade code. But, since these functions all have names upgrade_*_to_*, I guess it is not necessary.
Yes, I'd just create a lambda function that calls the other two functions: If the upgrade is more complicated, using upgradeBlocksFiles may not be possible, but it works for the cases we have so far. |
Fixed mrc_class_method_def blocks for methods that return a value.
Also, refactored upgrade functions: I added a new function named upgradeBlocksFiles that takes predicate functions that control what files should be upgraded and functions to do the upgrading. I updated the upgradeFrom_00*_to_00* functions to call upgradeBlocksFiles.
Fixes #296.
Fixes #238.