Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
50 changes: 25 additions & 25 deletions src/blocks/mrc_call_python_function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import { createFieldDropdown } from '../fields/FieldDropdown';
import { createFieldNonEditableText } from '../fields/FieldNonEditableText';
import { MRC_STYLE_FUNCTIONS } from '../themes/styles'
import * as toolboxItems from '../toolbox/items';
import * as commonStorage from '../storage/common_storage';
import * as storageModule from '../storage/module';
import * as storageModuleContent from '../storage/module_content';


// A block to call a python function.
Expand Down Expand Up @@ -497,11 +497,11 @@ const CALL_PYTHON_FUNCTION = {
},
mutateMethodCaller: function(
this: CallPythonFunctionBlock,
methodOrEvent: commonStorage.Method | commonStorage.Event
methodOrEvent: storageModuleContent.Method | storageModuleContent.Event
): void {
// mutateMethodCaller is called when the method or event definition block in the same module is modified.
if (this.mrcFunctionKind == FunctionKind.EVENT) {
const event = methodOrEvent as commonStorage.Event;
const event = methodOrEvent as storageModuleContent.Event;
this.mrcArgs = [];
event.args.forEach((arg) => {
this.mrcArgs.push({
Expand All @@ -510,7 +510,7 @@ const CALL_PYTHON_FUNCTION = {
});
});
} else if (this.mrcFunctionKind == FunctionKind.INSTANCE_WITHIN) {
const method = methodOrEvent as commonStorage.Method;
const method = methodOrEvent as storageModuleContent.Method;
this.mrcReturnType = method.returnType;
this.mrcArgs = [];
// We don't include the arg for the self argument because we don't need a socket for it.
Expand All @@ -523,9 +523,9 @@ const CALL_PYTHON_FUNCTION = {
}
this.updateBlock_();
},
getComponentsFromRobot: function(this: CallPythonFunctionBlock): commonStorage.Component[] {
getComponentsFromRobot: function(this: CallPythonFunctionBlock): storageModuleContent.Component[] {
// Get the list of components whose type matches this.mrcComponentClassName.
const components: commonStorage.Component[] = [];
const components: storageModuleContent.Component[] = [];
const editor = Editor.getEditorForBlocklyWorkspace(this.workspace);
if (editor) {
editor.getComponentsFromRobot().forEach(component => {
Expand All @@ -551,7 +551,7 @@ const CALL_PYTHON_FUNCTION = {
// visible warning on it.
if (this.mrcFunctionKind === FunctionKind.INSTANCE_COMPONENT) {
let foundComponent = false;
const componentsInScope: commonStorage.Component[] = [];
const componentsInScope: storageModuleContent.Component[] = [];
componentsInScope.push(...this.getComponentsFromRobot());
if (editor.getCurrentModuleType() === storageModule.MODULE_TYPE_MECHANISM) {
componentsInScope.push(...editor.getComponentsFromWorkspace());
Expand Down Expand Up @@ -662,7 +662,7 @@ const CALL_PYTHON_FUNCTION = {

let foundMechanismMethod = false;
const mechanism = editor.getMechanism(mechanismInRobot);
const mechanismMethods: commonStorage.Method[] = mechanism
const mechanismMethods: storageModuleContent.Method[] = mechanism
? editor.getMethodsFromMechanism(mechanism) : [];
for (const mechanismMethod of mechanismMethods) {
if (mechanismMethod.blockId === this.mrcOtherBlockId) {
Expand Down Expand Up @@ -883,7 +883,7 @@ export function renameMethodCallers(workspace: Blockly.Workspace, otherBlockId:
}

export function mutateMethodCallers(
workspace: Blockly.Workspace, otherBlockId: string, methodOrEvent: commonStorage.Method | commonStorage.Event) {
workspace: Blockly.Workspace, otherBlockId: string, methodOrEvent: storageModuleContent.Method | storageModuleContent.Event) {
const oldRecordUndo = Blockly.Events.getRecordUndo();

getMethodCallers(workspace, otherBlockId).forEach(block => {
Expand Down Expand Up @@ -1071,14 +1071,14 @@ function createInstanceMethodBlock(
}

export function addInstanceWithinBlocks(
methods: commonStorage.Method[],
methods: storageModuleContent.Method[],
contents: toolboxItems.ContentsType[]) {
methods.forEach(method => {
contents.push(createInstanceWithinBlock(method));
});
}

function createInstanceWithinBlock(method: commonStorage.Method): toolboxItems.Block {
function createInstanceWithinBlock(method: storageModuleContent.Method): toolboxItems.Block {
const extraState: CallPythonFunctionExtraState = {
functionKind: FunctionKind.INSTANCE_WITHIN,
returnType: method.returnType,
Expand All @@ -1089,7 +1089,7 @@ function createInstanceWithinBlock(method: commonStorage.Method): toolboxItems.B
const fields: {[key: string]: any} = {};
fields[FIELD_FUNCTION_NAME] = method.visibleName;
const inputs: {[key: string]: any} = {};
// Convert method.args from commonStorage.MethodArg[] to ArgData[].
// Convert method.args from storageModuleContent.MethodArg[] to ArgData[].
const args: ArgData[] = [];
// We don't include the arg for the self argument because we don't need a socket for it.
for (let i = 1; i < method.args.length; i++) {
Expand All @@ -1104,7 +1104,7 @@ function createInstanceWithinBlock(method: commonStorage.Method): toolboxItems.B
}

export function getInstanceComponentBlocks(
component: commonStorage.Component): toolboxItems.ContentsType[] {
component: storageModuleContent.Component): toolboxItems.ContentsType[] {
const contents: toolboxItems.ContentsType[] = [];

const classData = getClassData(component.className);
Expand Down Expand Up @@ -1132,7 +1132,7 @@ export function getInstanceComponentBlocks(
}

function createInstanceComponentBlock(
component: commonStorage.Component, functionData: FunctionData): toolboxItems.Block {
component: storageModuleContent.Component, functionData: FunctionData): toolboxItems.Block {
const extraState: CallPythonFunctionExtraState = {
functionKind: FunctionKind.INSTANCE_COMPONENT,
returnType: functionData.returnType,
Expand All @@ -1156,14 +1156,14 @@ function createInstanceComponentBlock(
}

export function addInstanceRobotBlocks(
methods: commonStorage.Method[],
methods: storageModuleContent.Method[],
contents: toolboxItems.ContentsType[]) {
methods.forEach(method => {
contents.push(createInstanceRobotBlock(method));
});
}

function createInstanceRobotBlock(method: commonStorage.Method): toolboxItems.Block {
function createInstanceRobotBlock(method: storageModuleContent.Method): toolboxItems.Block {
const extraState: CallPythonFunctionExtraState = {
functionKind: FunctionKind.INSTANCE_ROBOT,
returnType: method.returnType,
Expand All @@ -1174,7 +1174,7 @@ function createInstanceRobotBlock(method: commonStorage.Method): toolboxItems.Bl
const fields: {[key: string]: any} = {};
fields[FIELD_FUNCTION_NAME] = method.visibleName;
const inputs: {[key: string]: any} = {};
// Convert method.args from commonStorage.MethodArg[] to ArgData[].
// Convert method.args from storageModuleContent.MethodArg[] to ArgData[].
const args: ArgData[] = [];
// We don't include the arg for the self argument because we don't need a socket for it.
for (let i = 1; i < method.args.length; i++) {
Expand All @@ -1189,17 +1189,17 @@ function createInstanceRobotBlock(method: commonStorage.Method): toolboxItems.Bl
}

export function addInstanceMechanismBlocks(
mechanismInRobot: commonStorage.MechanismInRobot,
methods: commonStorage.Method[],
mechanismInRobot: storageModuleContent.MechanismInRobot,
methods: storageModuleContent.Method[],
contents: toolboxItems.ContentsType[]) {
methods.forEach(method => {
contents.push(createInstanceMechanismBlock(mechanismInRobot, method));
});
}

function createInstanceMechanismBlock(
mechanismInRobot: commonStorage.MechanismInRobot,
method: commonStorage.Method): toolboxItems.Block {
mechanismInRobot: storageModuleContent.MechanismInRobot,
method: storageModuleContent.Method): toolboxItems.Block {
const extraState: CallPythonFunctionExtraState = {
functionKind: FunctionKind.INSTANCE_MECHANISM,
returnType: method.returnType,
Expand All @@ -1213,7 +1213,7 @@ function createInstanceMechanismBlock(
fields[FIELD_MECHANISM_NAME] = mechanismInRobot.name;
fields[FIELD_FUNCTION_NAME] = method.visibleName;
const inputs: {[key: string]: any} = {};
// Convert method.args from commonStorage.MethodArg[] to ArgData[].
// Convert method.args from storageModuleContent.MethodArg[] to ArgData[].
const args: ArgData[] = [];
// For INSTANCE_MECHANISM functions, the 0 argument is 'self', but
// self is represented by the FIELD_MECHANISM_NAME field.
Expand All @@ -1230,14 +1230,14 @@ function createInstanceMechanismBlock(
}

export function addFireEventBlocks(
events: commonStorage.Event[],
events: storageModuleContent.Event[],
contents: toolboxItems.ContentsType[]) {
events.forEach(event => {
contents.push(createFireEventBlock(event));
});
}

function createFireEventBlock(event: commonStorage.Event): toolboxItems.Block {
function createFireEventBlock(event: storageModuleContent.Event): toolboxItems.Block {
const extraState: CallPythonFunctionExtraState = {
functionKind: FunctionKind.EVENT,
returnType: RETURN_TYPE_NONE,
Expand All @@ -1247,7 +1247,7 @@ function createFireEventBlock(event: commonStorage.Event): toolboxItems.Block {
const fields: {[key: string]: any} = {};
fields[FIELD_EVENT_NAME] = event.name;
const inputs: {[key: string]: any} = {};
// Convert event.args from commonStorage.MethodArg[] to ArgData[].
// Convert event.args from storageModuleContent.MethodArg[] to ArgData[].
const args: ArgData[] = [];
event.args.forEach(methodArg => {
args.push({
Expand Down
16 changes: 8 additions & 8 deletions src/blocks/mrc_class_method_def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import { createFieldNonEditableText } from '../fields/FieldNonEditableText'
import { createFieldFlydown } from '../fields/field_flydown';
import { Order } from 'blockly/python';
import { ExtendedPythonGenerator } from '../editor/extended_python_generator';
import * as commonStorage from '../storage/common_storage';
import * as storageModule from '../storage/module';
import * as storageModuleContent from '../storage/module_content';
import { renameMethodCallers, mutateMethodCallers } from './mrc_call_python_function'
import * as toolboxItems from '../toolbox/items';
import { getClassData } from './utils/python';
Expand Down Expand Up @@ -267,8 +267,8 @@ const CLASS_METHOD_DEF = {
}
return legalName;
},
getMethod: function (this: ClassMethodDefBlock): commonStorage.Method | null {
const method: commonStorage.Method = {
getMethod: function (this: ClassMethodDefBlock): storageModuleContent.Method | null {
const method: storageModuleContent.Method = {
blockId: this.id,
visibleName: this.getFieldValue(FIELD_METHOD_NAME),
pythonName: this.mrcFuncName ? this.mrcFuncName : '',
Expand All @@ -289,13 +289,13 @@ const CLASS_METHOD_DEF = {
});
return method;
},
getMethodForWithin: function (this: ClassMethodDefBlock): commonStorage.Method | null {
getMethodForWithin: function (this: ClassMethodDefBlock): storageModuleContent.Method | null {
if (this.mrcCanBeCalledWithinClass) {
return this.getMethod();
}
return null;
},
getMethodForOutside: function (this: ClassMethodDefBlock): commonStorage.Method | null {
getMethodForOutside: function (this: ClassMethodDefBlock): storageModuleContent.Method | null {
if (this.mrcCanBeCalledOutsideClass) {
return this.getMethod();
}
Expand Down Expand Up @@ -453,7 +453,7 @@ export const pythonFromBlock = function (
code = generator.scrub_(block, code);
generator.addClassMethodDefinition(funcName, code);

// Save the name of the function we just generated so we can use it to create the commonStorage.Method.
// Save the name of the function we just generated so we can use it to create the storageModuleContent.Method.
// in the getMethod function.
block.mrcFuncName = funcName;

Expand Down Expand Up @@ -519,7 +519,7 @@ function createClassMethodDefBlock(

export function getMethodsForWithin(
workspace: Blockly.Workspace,
methods: commonStorage.Method[]): void {
methods: storageModuleContent.Method[]): void {
workspace.getBlocksByType(BLOCK_NAME).forEach(block => {
const method = (block as ClassMethodDefBlock).getMethodForWithin();
if (method) {
Expand All @@ -530,7 +530,7 @@ export function getMethodsForWithin(

export function getMethodsForOutside(
workspace: Blockly.Workspace,
methods: commonStorage.Method[]): void {
methods: storageModuleContent.Method[]): void {
workspace.getBlocksByType(BLOCK_NAME).forEach(block => {
const method = (block as ClassMethodDefBlock).getMethodForOutside();
if (method) {
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/mrc_component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import { Editor } from '../editor/editor';
import { ExtendedPythonGenerator } from '../editor/extended_python_generator';
import { getAllowedTypesForSetCheck, getClassData, getModuleData, getSubclassNames } from './utils/python';
import * as toolboxItems from '../toolbox/items';
import * as commonStorage from '../storage/common_storage';
import * as storageModule from '../storage/module';
import * as storageModuleContent from '../storage/module_content';
import * as storageNames from '../storage/names';
import { createPortShadow } from './mrc_port';
import { createNumberShadowValue } from './utils/value';
Expand Down Expand Up @@ -150,7 +150,7 @@ const COMPONENT = {
}
return legalName;
},
getComponent: function (this: ComponentBlock): commonStorage.Component | null {
getComponent: function (this: ComponentBlock): storageModuleContent.Component | null {
const componentName = this.getFieldValue(FIELD_NAME);
const componentType = this.getFieldValue(FIELD_TYPE);
const ports: {[port: string]: string} = {};
Expand Down
6 changes: 3 additions & 3 deletions src/blocks/mrc_event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { MUTATOR_BLOCK_NAME, PARAM_CONTAINER_BLOCK_NAME, MethodMutatorArgBlock }
import * as ChangeFramework from './utils/change_framework';
import { BLOCK_NAME as MRC_MECHANISM_COMPONENT_HOLDER } from './mrc_mechanism_component_holder';
import * as toolboxItems from '../toolbox/items';
import * as commonStorage from '../storage/common_storage';
import * as storageModuleContent from '../storage/module_content';
import { renameMethodCallers, mutateMethodCallers } from './mrc_call_python_function'

export const BLOCK_NAME = 'mrc_event';
Expand Down Expand Up @@ -210,8 +210,8 @@ const EVENT = {
blockBlock.getIcon(Blockly.icons.IconType.WARNING)!.setBubbleVisible(true);
}
},
getEvent: function (this: EventBlock): commonStorage.Event {
const event: commonStorage.Event = {
getEvent: function (this: EventBlock): storageModuleContent.Event {
const event: storageModuleContent.Event = {
blockId: this.id,
name: this.getFieldValue(FIELD_EVENT_NAME),
args: [],
Expand Down
6 changes: 3 additions & 3 deletions src/blocks/mrc_event_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { createFieldFlydown } from '../fields/field_flydown';
import { createFieldNonEditableText } from '../fields/FieldNonEditableText';
import { MRC_STYLE_EVENT_HANDLER } from '../themes/styles';
import * as toolboxItems from '../toolbox/items';
import * as commonStorage from '../storage/common_storage';
import * as storageModuleContent from '../storage/module_content';

export const BLOCK_NAME = 'mrc_event_handler';

Expand Down Expand Up @@ -290,15 +290,15 @@ export function pythonFromBlock(
// Functions used for creating blocks for the toolbox.

export function addRobotEventHandlerBlocks(
events: commonStorage.Event[],
events: storageModuleContent.Event[],
contents: toolboxItems.ContentsType[]) {
events.forEach(event => {
contents.push(createRobotEventHandlerBlock(event));
});
}

function createRobotEventHandlerBlock(
event: commonStorage.Event): toolboxItems.Block {
event: storageModuleContent.Event): toolboxItems.Block {
const extraState: EventHandlerExtraState = {
// TODO(lizlooney): ask Alan what pathOfSender is for.
pathOfSender: '',
Expand Down
8 changes: 4 additions & 4 deletions src/blocks/mrc_mechanism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import { Editor } from '../editor/editor';
import { ExtendedPythonGenerator } from '../editor/extended_python_generator';
import { getAllowedTypesForSetCheck } from './utils/python';
import * as toolboxItems from '../toolbox/items';
import * as commonStorage from '../storage/common_storage';
import * as storageModule from '../storage/module';
import * as storageModuleContent from '../storage/module_content';
import * as storageNames from '../storage/names';
import * as value from './utils/value';
import { renameMethodCallers } from './mrc_call_python_function'
Expand Down Expand Up @@ -153,7 +153,7 @@ const MECHANISM = {
}
return legalName;
},
getMechanism: function (this: MechanismBlock): commonStorage.MechanismInRobot | null {
getMechanism: function (this: MechanismBlock): storageModuleContent.MechanismInRobot | null {
const mechanismName = this.getFieldValue(FIELD_NAME);
const mechanismType = this.mrcImportModule + '.' + this.getFieldValue(FIELD_TYPE);
return {
Expand All @@ -174,7 +174,7 @@ const MECHANISM = {
// Then here, we'd look for the mechanism with the marching UUID, and we'd update the
// FIELD_TYPE value if the mechanism's class name had changed.
let foundMechanism: storageModule.Mechanism | null = null;
const components: commonStorage.Component[] = []
const components: storageModuleContent.Component[] = []
for (const mechanism of editor.getMechanisms()) {
if (mechanism.className === this.getFieldValue(FIELD_TYPE)) {
foundMechanism = mechanism;
Expand Down Expand Up @@ -247,7 +247,7 @@ export const pythonFromBlock = function (
}

export function createMechanismBlock(
mechanism: storageModule.Mechanism, components: commonStorage.Component[]): toolboxItems.Block {
mechanism: storageModule.Mechanism, components: storageModuleContent.Component[]): toolboxItems.Block {
const snakeCaseName = storageNames.pascalCaseToSnakeCase(mechanism.className);
const mechanismName = 'my_' + snakeCaseName;
const extraState: MechanismExtraState = {
Expand Down
Loading