diff --git a/core/interfaces/i_parameter_model.ts b/core/interfaces/i_parameter_model.ts new file mode 100644 index 000000000..00d117240 --- /dev/null +++ b/core/interfaces/i_parameter_model.ts @@ -0,0 +1,35 @@ +/** + * @license + * Copyright 2022 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * The interface for the data model of a procedure parameter. + * + * @namespace Blockly.IParameterModel + */ + + +/** + * A data model for a procedure. + */ +export interface IParameterModel { + /** + * Sets the name of this parameter to the given name. + */ + setName(name: string): this; + + /** + * Sets the types of this parameter to the given type. + */ + setTypes(types: string[]): this; + + /** + * Returns the unique language-neutral ID for the parameter. + * + * This represents the identify of the variable model which does not change + * over time. + */ + getId(): string; +} diff --git a/core/interfaces/i_procedure_model.ts b/core/interfaces/i_procedure_model.ts new file mode 100644 index 000000000..1950fff76 --- /dev/null +++ b/core/interfaces/i_procedure_model.ts @@ -0,0 +1,70 @@ +/** + * @license + * Copyright 2022 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * The interface for the data model of a procedure. + * + * @namespace Blockly.IProcedureModel + */ + +import {IParameterModel} from './i_parameter_model.js'; + + +/** + * A data model for a procedure. + */ +export interface IProcedureModel { + /** Sets the human-readable name of the procedure. */ + setName(name: string): this; + + /** + * Inserts a parameter into the list of parameters. + * + * To move a parameter, first delete it, and then re-insert. + */ + insertParameter(parameterModel: IParameterModel, index: number): this; + + /** Removes the parameter at the given index from the parameter list. */ + deleteParameter(index: number): this; + + /** + * Sets the return type(s) of the procedure. + * + * Pass null to represent a procedure that does not return. + */ + setReturnTypes(types: string[]|null): this; + + /** + * Sets whether this procedure is enabled/disabled. If a procedure is disabled + * all procedure caller blocks should be disabled as well. + */ + setEnabled(enabled: boolean): this; + + /** Returns the unique language-neutral ID for the procedure. */ + getId(): string; + + /** Returns the human-readable name of the procedure. */ + getName(): string; + + /** Returns the parameter at the given index in the parameter list. */ + getParameter(index: number): IParameterModel; + + /** Returns an array of all of the parameters in the parameter list. */ + getParameters(): IParameterModel[]; + + /** + * Returns the return type(s) of the procedure. + * + * Null represents a procedure that does not return a value. + */ + getReturnTypes(): string[]|null; + + /** + * Returns whether the procedure is enabled/disabled. If a procedure is + * disabled, all procedure caller blocks should be disabled as well. + */ + getEnabled(): boolean; +}