Skip to content

Commit 6ca6b65

Browse files
committed
Revert "Make it so you can make methods that return a value"
This reverts commit 71f27ca.
1 parent 71f27ca commit 6ca6b65

File tree

2 files changed

+1
-37
lines changed

2 files changed

+1
-37
lines changed

src/blocks/mrc_class_method_def.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import { MUTATOR_BLOCK_NAME, PARAM_CONTAINER_BLOCK_NAME, MethodMutatorArgBlock }
3838
export const BLOCK_NAME = 'mrc_class_method_def';
3939

4040
export const FIELD_METHOD_NAME = 'NAME';
41-
export const RETURN_VALUE = 'RETURN';
4241

4342
type Parameter = {
4443
name: string,
@@ -55,7 +54,6 @@ interface ClassMethodDefMixin extends ClassMethodDefMixinType {
5554
mrcParameters: Parameter[],
5655
mrcPythonMethodName: string,
5756
mrcFuncName: string | null,
58-
mrcUpdateReturnInput(): void,
5957
}
6058
type ClassMethodDefMixinType = typeof CLASS_METHOD_DEF;
6159

@@ -181,7 +179,6 @@ const CLASS_METHOD_DEF = {
181179
(this as Blockly.BlockSvg).setMutator(null);
182180
}
183181
this.mrcUpdateParams();
184-
this.mrcUpdateReturnInput();
185182
},
186183
compose: function (this: ClassMethodDefBlock, containerBlock: any) {
187184
// Parameter list.
@@ -253,21 +250,6 @@ const CLASS_METHOD_DEF = {
253250
}
254251
}
255252
},
256-
mrcUpdateReturnInput: function (this: ClassMethodDefBlock) {
257-
// Remove existing return input if it exists
258-
if (this.getInput(RETURN_VALUE)) {
259-
this.removeInput(RETURN_VALUE);
260-
}
261-
262-
// Add return input if return type is not 'None'
263-
if (this.mrcReturnType && this.mrcReturnType !== 'None') {
264-
this.appendValueInput(RETURN_VALUE)
265-
.setAlign(Blockly.inputs.Align.RIGHT)
266-
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN);
267-
// Move the return input to be before the statement input
268-
this.moveInputBefore(RETURN_VALUE, 'STACK');
269-
}
270-
},
271253
removeParameterFields: function (input: Blockly.Input) {
272254
const fieldsToRemove = input.fieldRow
273255
.filter(field => field.name?.startsWith('PARAM_'))
@@ -520,23 +502,6 @@ export function createCustomMethodBlock(): toolboxItems.Block {
520502
return new toolboxItems.Block(BLOCK_NAME, extraState, fields, null);
521503
}
522504

523-
export function createCustomMethodBlockWithReturn(): toolboxItems.Block {
524-
const extraState: ClassMethodDefExtraState = {
525-
canChangeSignature: true,
526-
canBeCalledWithinClass: true,
527-
canBeCalledOutsideClass: true,
528-
returnType: 'Any',
529-
params: [],
530-
};
531-
const fields: {[key: string]: any} = {};
532-
fields[FIELD_METHOD_NAME] = 'my_method_with_return';
533-
const inputs: {[key: string]: any} = {};
534-
inputs[RETURN_VALUE] = {
535-
'type': 'input_value',
536-
};
537-
return new toolboxItems.Block(BLOCK_NAME, extraState, fields, inputs);
538-
}
539-
540505
export function getBaseClassBlocks(
541506
baseClassName: string): toolboxItems.Block[] {
542507
const blocks: toolboxItems.Block[] = [];

src/toolbox/methods_category.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import * as storageModule from '../storage/module';
2626
import { MRC_CATEGORY_STYLE_METHODS } from '../themes/styles';
2727
import { CLASS_NAME_ROBOT_BASE, CLASS_NAME_OPMODE, CLASS_NAME_MECHANISM } from '../blocks/utils/python';
2828
import { addInstanceWithinBlocks } from '../blocks/mrc_call_python_function';
29-
import { createCustomMethodBlock, getBaseClassBlocks, FIELD_METHOD_NAME, createCustomMethodBlockWithReturn } from '../blocks/mrc_class_method_def';
29+
import { createCustomMethodBlock, getBaseClassBlocks, FIELD_METHOD_NAME } from '../blocks/mrc_class_method_def';
3030
import { Editor } from '../editor/editor';
3131

3232

@@ -113,7 +113,6 @@ class MethodsCategory {
113113
text: 'Custom Methods',
114114
},
115115
createCustomMethodBlock(),
116-
createCustomMethodBlockWithReturn()
117116
);
118117

119118
// Get blocks for calling methods defined in the current workspace.

0 commit comments

Comments
 (0)