mirror of
https://github.com/google/blockly.git
synced 2026-01-04 15:40:08 +01:00
chore: fix missing requires in generators (#5744)
* chore: fix some missing requires in generators * chore: fix missing requires in dart block generators * chore: replace Blockly.isNumber with Blockly.utils.string.isNumber in generators * chore: fix more missing requires in block generators
This commit is contained in:
@@ -13,9 +13,12 @@
|
||||
goog.provide('Blockly.Dart');
|
||||
|
||||
goog.require('Blockly.Generator');
|
||||
goog.require('Blockly.Names');
|
||||
goog.require('Blockly.Variables');
|
||||
goog.require('Blockly.inputTypes');
|
||||
goog.require('Blockly.utils.string');
|
||||
|
||||
goog.requireType('Blockly.Block');
|
||||
goog.requireType('Blockly.Workspace');
|
||||
|
||||
/**
|
||||
* Dart code generator.
|
||||
@@ -268,7 +271,7 @@ Blockly.Dart.getAdjusted = function(block, atId, opt_delta, opt_negate,
|
||||
/** @type {string|number} */
|
||||
let at = this.valueToCode(block, atId, outerOrder) || defaultAtIndex;
|
||||
|
||||
if (Blockly.isNumber(at)) {
|
||||
if (Blockly.utils.string.isNumber(at)) {
|
||||
// If the index is a naked number, adjust it right now.
|
||||
at = parseInt(at, 10) + delta;
|
||||
if (opt_negate) {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
goog.provide('Blockly.Dart.loops');
|
||||
|
||||
goog.require('Blockly.Dart');
|
||||
goog.require('Blockly.utils.string');
|
||||
|
||||
|
||||
Blockly.Dart['controls_repeat_ext'] = function(block) {
|
||||
@@ -32,7 +33,7 @@ Blockly.Dart['controls_repeat_ext'] = function(block) {
|
||||
const loopVar = Blockly.Dart.nameDB_.getDistinctName(
|
||||
'count', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
let endVar = repeats;
|
||||
if (!repeats.match(/^\w+$/) && !Blockly.isNumber(repeats)) {
|
||||
if (!repeats.match(/^\w+$/) && !Blockly.utils.string.isNumber(repeats)) {
|
||||
endVar = Blockly.Dart.nameDB_.getDistinctName(
|
||||
'repeat_end', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += 'var ' + endVar + ' = ' + repeats + ';\n';
|
||||
@@ -73,8 +74,8 @@ Blockly.Dart['controls_for'] = function(block) {
|
||||
let branch = Blockly.Dart.statementToCode(block, 'DO');
|
||||
branch = Blockly.Dart.addLoopTrap(branch, block);
|
||||
let code;
|
||||
if (Blockly.isNumber(argument0) && Blockly.isNumber(argument1) &&
|
||||
Blockly.isNumber(increment)) {
|
||||
if (Blockly.utils.string.isNumber(argument0) && Blockly.utils.string.isNumber(argument1) &&
|
||||
Blockly.utils.string.isNumber(increment)) {
|
||||
// All arguments are simple numbers.
|
||||
const up = Number(argument0) <= Number(argument1);
|
||||
code = 'for (' + variable0 + ' = ' + argument0 + '; ' +
|
||||
@@ -91,13 +92,13 @@ Blockly.Dart['controls_for'] = function(block) {
|
||||
code = '';
|
||||
// Cache non-trivial values to variables to prevent repeated look-ups.
|
||||
let startVar = argument0;
|
||||
if (!argument0.match(/^\w+$/) && !Blockly.isNumber(argument0)) {
|
||||
if (!argument0.match(/^\w+$/) && !Blockly.utils.string.isNumber(argument0)) {
|
||||
startVar = Blockly.Dart.nameDB_.getDistinctName(
|
||||
variable0 + '_start', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += 'var ' + startVar + ' = ' + argument0 + ';\n';
|
||||
}
|
||||
let endVar = argument1;
|
||||
if (!argument1.match(/^\w+$/) && !Blockly.isNumber(argument1)) {
|
||||
if (!argument1.match(/^\w+$/) && !Blockly.utils.string.isNumber(argument1)) {
|
||||
endVar = Blockly.Dart.nameDB_.getDistinctName(
|
||||
variable0 + '_end', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += 'var ' + endVar + ' = ' + argument1 + ';\n';
|
||||
@@ -107,7 +108,7 @@ Blockly.Dart['controls_for'] = function(block) {
|
||||
const incVar = Blockly.Dart.nameDB_.getDistinctName(
|
||||
variable0 + '_inc', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += 'num ' + incVar + ' = ';
|
||||
if (Blockly.isNumber(increment)) {
|
||||
if (Blockly.utils.string.isNumber(increment)) {
|
||||
code += Math.abs(increment) + ';\n';
|
||||
} else {
|
||||
code += '(' + increment + ').abs();\n';
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
/**
|
||||
* @fileoverview Generating Dart for dynamic variable blocks.
|
||||
* @suppress {extraRequire|missingRequire}
|
||||
* @suppress {extraRequire}
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -13,10 +13,14 @@
|
||||
goog.provide('Blockly.JavaScript');
|
||||
|
||||
goog.require('Blockly.Generator');
|
||||
goog.require('Blockly.Variables');
|
||||
goog.require('Blockly.Names');
|
||||
goog.require('Blockly.inputTypes');
|
||||
goog.require('Blockly.utils.global');
|
||||
goog.require('Blockly.utils.object');
|
||||
goog.require('Blockly.utils.string');
|
||||
goog.requireType('Blockly.Block');
|
||||
goog.requireType('Blockly.Workspace');
|
||||
|
||||
|
||||
/**
|
||||
@@ -289,7 +293,7 @@ Blockly.JavaScript.getAdjusted = function(block, atId, opt_delta, opt_negate,
|
||||
|
||||
let at = this.valueToCode(block, atId, outerOrder) || defaultAtIndex;
|
||||
|
||||
if (Blockly.isNumber(at)) {
|
||||
if (Blockly.utils.string.isNumber(at)) {
|
||||
// If the index is a naked number, adjust it right now.
|
||||
at = Number(at) + delta;
|
||||
if (opt_negate) {
|
||||
|
||||
@@ -14,6 +14,7 @@ goog.provide('Blockly.JavaScript.loops');
|
||||
|
||||
goog.require('Blockly.JavaScript');
|
||||
goog.require('Blockly.loopMixin');
|
||||
goog.require('Blockly.utils.string');
|
||||
|
||||
|
||||
Blockly.JavaScript['controls_repeat_ext'] = function(block) {
|
||||
@@ -33,7 +34,7 @@ Blockly.JavaScript['controls_repeat_ext'] = function(block) {
|
||||
const loopVar = Blockly.JavaScript.nameDB_.getDistinctName(
|
||||
'count', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
let endVar = repeats;
|
||||
if (!repeats.match(/^\w+$/) && !Blockly.isNumber(repeats)) {
|
||||
if (!repeats.match(/^\w+$/) && !Blockly.utils.string.isNumber(repeats)) {
|
||||
endVar = Blockly.JavaScript.nameDB_.getDistinctName(
|
||||
'repeat_end', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += 'var ' + endVar + ' = ' + repeats + ';\n';
|
||||
@@ -75,8 +76,8 @@ Blockly.JavaScript['controls_for'] = function(block) {
|
||||
let branch = Blockly.JavaScript.statementToCode(block, 'DO');
|
||||
branch = Blockly.JavaScript.addLoopTrap(branch, block);
|
||||
let code;
|
||||
if (Blockly.isNumber(argument0) && Blockly.isNumber(argument1) &&
|
||||
Blockly.isNumber(increment)) {
|
||||
if (Blockly.utils.string.isNumber(argument0) && Blockly.utils.string.isNumber(argument1) &&
|
||||
Blockly.utils.string.isNumber(increment)) {
|
||||
// All arguments are simple numbers.
|
||||
const up = Number(argument0) <= Number(argument1);
|
||||
code = 'for (' + variable0 + ' = ' + argument0 + '; ' +
|
||||
@@ -93,13 +94,13 @@ Blockly.JavaScript['controls_for'] = function(block) {
|
||||
code = '';
|
||||
// Cache non-trivial values to variables to prevent repeated look-ups.
|
||||
let startVar = argument0;
|
||||
if (!argument0.match(/^\w+$/) && !Blockly.isNumber(argument0)) {
|
||||
if (!argument0.match(/^\w+$/) && !Blockly.utils.string.isNumber(argument0)) {
|
||||
startVar = Blockly.JavaScript.nameDB_.getDistinctName(
|
||||
variable0 + '_start', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += 'var ' + startVar + ' = ' + argument0 + ';\n';
|
||||
}
|
||||
let endVar = argument1;
|
||||
if (!argument1.match(/^\w+$/) && !Blockly.isNumber(argument1)) {
|
||||
if (!argument1.match(/^\w+$/) && !Blockly.utils.string.isNumber(argument1)) {
|
||||
endVar = Blockly.JavaScript.nameDB_.getDistinctName(
|
||||
variable0 + '_end', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += 'var ' + endVar + ' = ' + argument1 + ';\n';
|
||||
@@ -109,7 +110,7 @@ Blockly.JavaScript['controls_for'] = function(block) {
|
||||
const incVar = Blockly.JavaScript.nameDB_.getDistinctName(
|
||||
variable0 + '_inc', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += 'var ' + incVar + ' = ';
|
||||
if (Blockly.isNumber(increment)) {
|
||||
if (Blockly.utils.string.isNumber(increment)) {
|
||||
code += Math.abs(increment) + ';\n';
|
||||
} else {
|
||||
code += 'Math.abs(' + increment + ');\n';
|
||||
|
||||
@@ -7,16 +7,19 @@
|
||||
/**
|
||||
* @fileoverview Helper functions for generating Lua for blocks.
|
||||
* Based on Ellen Spertus's blocky-lua project.
|
||||
* @suppress {missingRequire|checkTypes|globalThis}
|
||||
* @suppress {checkTypes|globalThis}
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.Lua');
|
||||
|
||||
goog.require('Blockly.Generator');
|
||||
goog.require('Blockly.Names');
|
||||
goog.require('Blockly.inputTypes');
|
||||
goog.require('Blockly.utils.object');
|
||||
goog.require('Blockly.utils.string');
|
||||
goog.requireType('Blockly.Block');
|
||||
goog.requireType('Blockly.Workspace');
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
goog.provide('Blockly.Lua.loops');
|
||||
|
||||
goog.require('Blockly.Lua');
|
||||
goog.require('Blockly.utils.string');
|
||||
|
||||
|
||||
/**
|
||||
@@ -53,7 +54,7 @@ Blockly.Lua['controls_repeat_ext'] = function(block) {
|
||||
repeats = Blockly.Lua.valueToCode(block, 'TIMES',
|
||||
Blockly.Lua.ORDER_NONE) || '0';
|
||||
}
|
||||
if (Blockly.isNumber(repeats)) {
|
||||
if (Blockly.utils.string.isNumber(repeats)) {
|
||||
repeats = parseInt(repeats, 10);
|
||||
} else {
|
||||
repeats = 'math.floor(' + repeats + ')';
|
||||
@@ -100,8 +101,8 @@ Blockly.Lua['controls_for'] = function(block) {
|
||||
branch = Blockly.Lua.addContinueLabel_(branch);
|
||||
let code = '';
|
||||
let incValue;
|
||||
if (Blockly.isNumber(startVar) && Blockly.isNumber(endVar) &&
|
||||
Blockly.isNumber(increment)) {
|
||||
if (Blockly.utils.string.isNumber(startVar) && Blockly.utils.string.isNumber(endVar) &&
|
||||
Blockly.utils.string.isNumber(increment)) {
|
||||
// All arguments are simple numbers.
|
||||
const up = Number(startVar) <= Number(endVar);
|
||||
const step = Math.abs(Number(increment));
|
||||
@@ -113,7 +114,7 @@ Blockly.Lua['controls_for'] = function(block) {
|
||||
incValue = Blockly.Lua.nameDB_.getDistinctName(
|
||||
variable0 + '_inc', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += incValue + ' = ';
|
||||
if (Blockly.isNumber(increment)) {
|
||||
if (Blockly.utils.string.isNumber(increment)) {
|
||||
code += Math.abs(increment) + '\n';
|
||||
} else {
|
||||
code += 'math.abs(' + increment + ')\n';
|
||||
|
||||
@@ -6,16 +6,19 @@
|
||||
|
||||
/**
|
||||
* @fileoverview Helper functions for generating PHP for blocks.
|
||||
* @suppress {missingRequire|checkTypes|globalThis}
|
||||
* @suppress {checkTypes|globalThis}
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.PHP');
|
||||
|
||||
goog.require('Blockly.Generator');
|
||||
goog.require('Blockly.Names');
|
||||
goog.require('Blockly.inputTypes');
|
||||
goog.require('Blockly.utils.object');
|
||||
goog.require('Blockly.utils.string');
|
||||
goog.requireType('Blockly.Block');
|
||||
goog.requireType('Blockly.Workspace');
|
||||
|
||||
|
||||
/**
|
||||
@@ -271,7 +274,7 @@ Blockly.PHP.getAdjusted = function(block, atId, opt_delta, opt_negate,
|
||||
}
|
||||
let at = this.valueToCode(block, atId, outerOrder) || defaultAtIndex;
|
||||
|
||||
if (Blockly.isNumber(at)) {
|
||||
if (Blockly.utils.string.isNumber(at)) {
|
||||
// If the index is a naked number, adjust it right now.
|
||||
at = Number(at) + delta;
|
||||
if (opt_negate) {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
goog.provide('Blockly.PHP.lists');
|
||||
|
||||
goog.require('Blockly.PHP');
|
||||
goog.require('Blockly.utils.string');
|
||||
|
||||
|
||||
Blockly.PHP['lists_create_empty'] = function(block) {
|
||||
@@ -387,7 +388,7 @@ Blockly.PHP['lists_getSublist'] = function(block) {
|
||||
at2 = Blockly.PHP.getAdjusted(block, 'AT2', 0, false,
|
||||
Blockly.PHP.ORDER_SUBTRACTION);
|
||||
length = at2 + ' - ';
|
||||
if (Blockly.isNumber(String(at1)) || String(at1).match(/^\(.+\)$/)) {
|
||||
if (Blockly.utils.string.isNumber(String(at1)) || String(at1).match(/^\(.+\)$/)) {
|
||||
length += at1;
|
||||
} else {
|
||||
length += '(' + at1 + ')';
|
||||
@@ -398,7 +399,7 @@ Blockly.PHP['lists_getSublist'] = function(block) {
|
||||
at2 = Blockly.PHP.getAdjusted(block, 'AT2', 0, false,
|
||||
Blockly.PHP.ORDER_SUBTRACTION);
|
||||
length = 'count(' + list + ') - ' + at2 + ' - ';
|
||||
if (Blockly.isNumber(String(at1)) || String(at1).match(/^\(.+\)$/)) {
|
||||
if (Blockly.utils.string.isNumber(String(at1)) || String(at1).match(/^\(.+\)$/)) {
|
||||
length += at1;
|
||||
} else {
|
||||
length += '(' + at1 + ')';
|
||||
@@ -406,7 +407,7 @@ Blockly.PHP['lists_getSublist'] = function(block) {
|
||||
break;
|
||||
case 'LAST':
|
||||
length = 'count(' + list + ') - ';
|
||||
if (Blockly.isNumber(String(at1)) || String(at1).match(/^\(.+\)$/)) {
|
||||
if (Blockly.utils.string.isNumber(String(at1)) || String(at1).match(/^\(.+\)$/)) {
|
||||
length += at1;
|
||||
} else {
|
||||
length += '(' + at1 + ')';
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
goog.provide('Blockly.PHP.loops');
|
||||
|
||||
goog.require('Blockly.PHP');
|
||||
goog.require('Blockly.utils.string');
|
||||
|
||||
|
||||
Blockly.PHP['controls_repeat_ext'] = function(block) {
|
||||
@@ -32,7 +33,7 @@ Blockly.PHP['controls_repeat_ext'] = function(block) {
|
||||
const loopVar = Blockly.PHP.nameDB_.getDistinctName(
|
||||
'count', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
let endVar = repeats;
|
||||
if (!repeats.match(/^\w+$/) && !Blockly.isNumber(repeats)) {
|
||||
if (!repeats.match(/^\w+$/) && !Blockly.utils.string.isNumber(repeats)) {
|
||||
endVar = Blockly.PHP.nameDB_.getDistinctName(
|
||||
'repeat_end', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += endVar + ' = ' + repeats + ';\n';
|
||||
@@ -73,8 +74,8 @@ Blockly.PHP['controls_for'] = function(block) {
|
||||
let branch = Blockly.PHP.statementToCode(block, 'DO');
|
||||
branch = Blockly.PHP.addLoopTrap(branch, block);
|
||||
let code;
|
||||
if (Blockly.isNumber(argument0) && Blockly.isNumber(argument1) &&
|
||||
Blockly.isNumber(increment)) {
|
||||
if (Blockly.utils.string.isNumber(argument0) && Blockly.utils.string.isNumber(argument1) &&
|
||||
Blockly.utils.string.isNumber(increment)) {
|
||||
// All arguments are simple numbers.
|
||||
const up = Number(argument0) <= Number(argument1);
|
||||
code = 'for (' + variable0 + ' = ' + argument0 + '; ' +
|
||||
@@ -91,13 +92,13 @@ Blockly.PHP['controls_for'] = function(block) {
|
||||
code = '';
|
||||
// Cache non-trivial values to variables to prevent repeated look-ups.
|
||||
let startVar = argument0;
|
||||
if (!argument0.match(/^\w+$/) && !Blockly.isNumber(argument0)) {
|
||||
if (!argument0.match(/^\w+$/) && !Blockly.utils.string.isNumber(argument0)) {
|
||||
startVar = Blockly.PHP.nameDB_.getDistinctName(
|
||||
variable0 + '_start', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += startVar + ' = ' + argument0 + ';\n';
|
||||
}
|
||||
let endVar = argument1;
|
||||
if (!argument1.match(/^\w+$/) && !Blockly.isNumber(argument1)) {
|
||||
if (!argument1.match(/^\w+$/) && !Blockly.utils.string.isNumber(argument1)) {
|
||||
endVar = Blockly.PHP.nameDB_.getDistinctName(
|
||||
variable0 + '_end', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += endVar + ' = ' + argument1 + ';\n';
|
||||
@@ -107,7 +108,7 @@ Blockly.PHP['controls_for'] = function(block) {
|
||||
const incVar = Blockly.PHP.nameDB_.getDistinctName(
|
||||
variable0 + '_inc', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += incVar + ' = ';
|
||||
if (Blockly.isNumber(increment)) {
|
||||
if (Blockly.utils.string.isNumber(increment)) {
|
||||
code += Math.abs(increment) + ';\n';
|
||||
} else {
|
||||
code += 'abs(' + increment + ');\n';
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
goog.provide('Blockly.PHP.procedures');
|
||||
|
||||
goog.require('Blockly.PHP');
|
||||
goog.require('Blockly.Names');
|
||||
goog.require('Blockly.Variables');
|
||||
|
||||
|
||||
Blockly.PHP['procedures_defreturn'] = function(block) {
|
||||
|
||||
@@ -13,8 +13,12 @@
|
||||
goog.provide('Blockly.Python');
|
||||
|
||||
goog.require('Blockly.Generator');
|
||||
goog.require('Blockly.Names');
|
||||
goog.require('Blockly.Variables');
|
||||
goog.require('Blockly.inputTypes');
|
||||
goog.require('Blockly.utils.string');
|
||||
goog.requireType('Blockly.Block');
|
||||
goog.requireType('Blockly.Workspace');
|
||||
|
||||
|
||||
/**
|
||||
@@ -305,7 +309,7 @@ Blockly.Python.getAdjustedInt = function(block, atId, opt_delta, opt_negate) {
|
||||
const atOrder = delta ? this.ORDER_ADDITIVE : this.ORDER_NONE;
|
||||
let at = this.valueToCode(block, atId, atOrder) || defaultAtIndex;
|
||||
|
||||
if (Blockly.isNumber(at)) {
|
||||
if (Blockly.utils.string.isNumber(at)) {
|
||||
// If the index is a naked number, adjust it right now.
|
||||
at = parseInt(at, 10) + delta;
|
||||
if (opt_negate) {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
goog.provide('Blockly.Python.lists');
|
||||
|
||||
goog.require('Blockly.Python');
|
||||
goog.require('Blockly.utils.string');
|
||||
|
||||
|
||||
Blockly.Python['lists_create_empty'] = function(block) {
|
||||
@@ -282,7 +283,7 @@ Blockly.Python['lists_getSublist'] = function(block) {
|
||||
at2 = Blockly.Python.getAdjustedInt(block, 'AT2', 0, true);
|
||||
// Ensure that if the result calculated is 0 that sub-sequence will
|
||||
// include all elements as expected.
|
||||
if (!Blockly.isNumber(String(at2))) {
|
||||
if (!Blockly.utils.string.isNumber(String(at2))) {
|
||||
Blockly.Python.definitions_['import_sys'] = 'import sys';
|
||||
at2 += ' or sys.maxsize';
|
||||
} else if (at2 === 0) {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
goog.provide('Blockly.Python.loops');
|
||||
|
||||
goog.require('Blockly.Python');
|
||||
goog.require('Blockly.utils.string');
|
||||
|
||||
|
||||
Blockly.Python['controls_repeat_ext'] = function(block) {
|
||||
@@ -26,7 +27,7 @@ Blockly.Python['controls_repeat_ext'] = function(block) {
|
||||
repeats = Blockly.Python.valueToCode(block, 'TIMES',
|
||||
Blockly.Python.ORDER_NONE) || '0';
|
||||
}
|
||||
if (Blockly.isNumber(repeats)) {
|
||||
if (Blockly.utils.string.isNumber(repeats)) {
|
||||
repeats = parseInt(repeats, 10);
|
||||
} else {
|
||||
repeats = 'int(' + repeats + ')';
|
||||
@@ -97,8 +98,8 @@ Blockly.Python['controls_for'] = function(block) {
|
||||
defineDownRange() + '(' + start + ', ' + end + ', ' + inc + ')';
|
||||
};
|
||||
|
||||
if (Blockly.isNumber(argument0) && Blockly.isNumber(argument1) &&
|
||||
Blockly.isNumber(increment)) {
|
||||
if (Blockly.utils.string.isNumber(argument0) && Blockly.utils.string.isNumber(argument1) &&
|
||||
Blockly.utils.string.isNumber(increment)) {
|
||||
// All parameters are simple numbers.
|
||||
argument0 = Number(argument0);
|
||||
argument1 = Number(argument1);
|
||||
@@ -136,7 +137,7 @@ Blockly.Python['controls_for'] = function(block) {
|
||||
} else {
|
||||
// Cache non-trivial values to variables to prevent repeated look-ups.
|
||||
const scrub = function(arg, suffix) {
|
||||
if (Blockly.isNumber(arg)) {
|
||||
if (Blockly.utils.string.isNumber(arg)) {
|
||||
// Simple number.
|
||||
arg = Number(arg);
|
||||
} else if (arg.match(/^\w+$/)) {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
goog.provide('Blockly.Python.procedures');
|
||||
|
||||
goog.require('Blockly.Python');
|
||||
goog.require('Blockly.Variables');
|
||||
|
||||
|
||||
Blockly.Python['procedures_defreturn'] = function(block) {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
goog.provide('Blockly.Python.texts');
|
||||
|
||||
goog.require('Blockly.Python');
|
||||
goog.require('Blockly.utils.string');
|
||||
|
||||
|
||||
Blockly.Python['text'] = function(block) {
|
||||
@@ -200,7 +201,7 @@ Blockly.Python['text_getSubstring'] = function(block) {
|
||||
at2 = Blockly.Python.getAdjustedInt(block, 'AT2', 0, true);
|
||||
// Ensure that if the result calculated is 0 that sub-sequence will
|
||||
// include all elements as expected.
|
||||
if (!Blockly.isNumber(String(at2))) {
|
||||
if (!Blockly.utils.string.isNumber(String(at2))) {
|
||||
Blockly.Python.definitions_['import_sys'] = 'import sys';
|
||||
at2 += ' or sys.maxsize';
|
||||
} else if (at2 === 0) {
|
||||
|
||||
Reference in New Issue
Block a user