Make colour optional in JSON. Add ;/n in generator stub.

This commit is contained in:
Neil Fraser
2016-01-28 14:25:38 -05:00
parent 9804b31bb0
commit 211595075e
4 changed files with 15 additions and 8 deletions

View File

@@ -647,7 +647,7 @@ Blockly.Blocks['procedures_callnoreturn'] = {
for (var i = 0; i < this.arguments_.length; i++) {
if (Blockly.Names.equals(oldName, this.arguments_[i])) {
this.arguments_[i] = newName;
this.getInput('ARG' + i).fieldRow[0].setText(newName);
this.getInput('ARG' + i).fieldRow[0].setValue(newName);
}
}
},

View File

@@ -929,7 +929,9 @@ Blockly.Block.prototype.jsonInit = function(json) {
'Must not have both an output and a previousStatement.');
// Set basic properties of block.
this.setColour(json['colour']);
if (json['colour'] !== undefined) {
this.setColour(json['colour']);
}
// Interpolate the message blocks.
var i = 0;

View File

@@ -642,11 +642,8 @@ Blockly.Connection.prototype.setCheck = function(check) {
this.check_ = check;
// The new value type may not be compatible with the existing connection.
if (this.targetConnection && !this.checkType_(this.targetConnection)) {
if (this.isSuperior()) {
this.targetBlock().setParent(null);
} else {
this.sourceBlock_.setParent(null);
}
var child = this.isSuperior() ? this.targetBlock() : this.sourceBlock_;
child.setParent(null);
// Bump away.
this.sourceBlock_.bumpNeighbours_();
}

View File

@@ -576,12 +576,20 @@ function updateGenerator(block) {
}
}
}
// Most languages end lines with a semicolon. Python does not.
var lineEnd = {
'JavaScript': ';',
'Python': '',
'PHP': ';',
'Dart': ';'
};
code.push(" // TODO: Assemble " + language + " into code variable.");
code.push(" var code = \'...\';");
if (block.outputConnection) {
code.push(" var code = '...';");
code.push(" // TODO: Change ORDER_NONE to the correct strength.");
code.push(" return [code, Blockly." + language + ".ORDER_NONE];");
} else {
code.push(" var code = '..." + (lineEnd[language] || '') + "\\n';");
code.push(" return code;");
}
code.push("};");