Automatic commit Wed Dec 18 03:00:02 PST 2013

This commit is contained in:
ellen.spertus
2013-12-18 03:00:02 -08:00
parent 7c57c3c758
commit 372d4248ca
44 changed files with 322 additions and 137 deletions

View File

@@ -1228,6 +1228,20 @@ Blockly.Block.prototype.setOutput = function(newBoolean, opt_check) {
}
};
/**
* Change the output type on a block.
* @param {string|Array.<string>|null} check Returned type or list of
* returned types. Null or undefined if any type could be returned
* (e.g. variable get). It is fine if this is the same as the old type.
* @throws {goog.asserts.AssertionError} if the block did not already have an
* output.
*/
Blockly.Block.prototype.changeOutput = function(check) {
goog.asserts.assert(this.outputConnection,
'Only use changeOutput() on blocks that already have an output.');
this.outputConnection.setCheck(check);
};
/**
* Set whether value inputs are arranged horizontally or vertically.
* @param {boolean} newBoolean True if inputs are horizontal.

View File

@@ -179,12 +179,18 @@ Blockly.Generator.prototype.valueToCode = function(block, name, order) {
throw 'Expecting valid order from value block "' + targetBlock.type + '".';
}
if (code && order <= innerOrder) {
// The operators outside this code are stonger than the operators
// inside this code. To prevent the code from being pulled apart,
// wrap the code in parentheses.
// Technically, this should be handled on a language-by-language basis.
// However all known (sane) languages use parentheses for grouping.
code = '(' + code + ')';
if (order == innerOrder || (order == 0 || order == 99)) {
// 0 is the atomic order, 99 is the none order. No parentheses needed.
// In all known languages multiple such code blocks are not order
// sensitive. In fact in Python ('a' 'b') 'c' would fail.
} else {
// The operators outside this code are stonger than the operators
// inside this code. To prevent the code from being pulled apart,
// wrap the code in parentheses.
// Technically, this should be handled on a language-by-language basis.
// However all known (sane) languages use parentheses for grouping.
code = '(' + code + ')';
}
}
return code;
};

View File

@@ -29,6 +29,7 @@ goog.provide('Blockly.Input');
// goog.require('Blockly.Block');
goog.require('Blockly.Connection');
goog.require('Blockly.FieldLabel');
goog.require('goog.asserts');
/**
@@ -91,6 +92,27 @@ Blockly.Input.prototype.appendTitle = function(title, opt_name) {
return this;
};
/**
* Remove a title from this input.
* @param {string} name The name of the title.
* @throws {goog.asserts.AssertionError} if the title is not present.
*/
Blockly.Input.prototype.removeTitle = function(name) {
for (var i = 0, title; title = this.titleRow[i]; i++) {
if (title.name === name) {
title.dispose();
this.titleRow.splice(i, 1);
if (this.sourceBlock_.rendered) {
this.sourceBlock_.render();
// Removing a title will cause the block to change shape.
this.sourceBlock_.bumpNeighbours_();
}
return;
}
}
goog.asserts.fail('Title "%s" not found.', name);
};
/**
* Gets whether this input is visible or not.
* @return {boolean} True if visible.