Skip to content

Commit

Permalink
seperate core and c_core, auto-generate dependency, update google-blo…
Browse files Browse the repository at this point in the history
…ckly
  • Loading branch information
zhaofeng-shu33 committed Mar 11, 2018
1 parent b6a710a commit 6de4295
Show file tree
Hide file tree
Showing 174 changed files with 49,254 additions and 10,745 deletions.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,33 @@ use node_compressed_generator.js to build "node_compressed_generator.js" from ge

index.html is the release version of mbed-blockly.

## Version

The current implementation supports mbed OS 2 only. Mbed OS 5 will be considered in the future release.

## Enhanced feature to core library of blockly

To make Blockly support code generation of C code, we add a few js files under the folder "c_core" without changing the original code of blockly.

instances.js
field_variable.js
field_instance.js
block.js
blockly.js

## Keep up-to-date with upstream library

To make the development up-to-date, I should manually download the latest version of [https://github.com/google/closure-compiler-js](google-closure-compiler) and [https://github.com/google/blockly](google-blockly). The former is easier to handle since all I should do is downloading the compressed library and extract it.
For the latter (blockly), I only need parts of it. Therefore, I should manually download the following parts:

* `core/*`
* `blocks/*`
* `msg/js/en.js`

## Reference

* [https://os.mbed.com/platforms/ST-Nucleo-F103RB/](https://os.mbed.com/platforms/ST-Nucleo-F103RB/) hardware information

* [https://developer-sjc-indigo-border.mbed.org/cookbook/Homepage](https://developer-sjc-indigo-border.mbed.org/cookbook/Homepage) SDK API reference

* [https://developers.google.com/blockly/guides/overview](https://developers.google.com/blockly/guides/overview) Google Blockly reference
* [https://developers.google.com/blockly/guides/overview](https://developers.google.com/blockly/guides/overview) Google Blockly reference
381 changes: 199 additions & 182 deletions blockly_compressed.js

Large diffs are not rendered by default.

3,535 changes: 1,793 additions & 1,742 deletions blockly_uncompressed.js

Large diffs are not rendered by default.

195 changes: 99 additions & 96 deletions blocks/colour.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,115 +20,118 @@

/**
* @fileoverview Colour blocks for Blockly.
*
* This file is scraped to extract a .json file of block definitions. The array
* passed to defineBlocksWithJsonArray(..) must be strict JSON: double quotes
* only, no outside references, no functions, no trailing commas, etc. The one
* exception is end-of-line comments, which the scraper will remove.
* @author [email protected] (Neil Fraser)
*/
'use strict';

goog.provide('Blockly.Blocks.colour');
goog.provide('Blockly.Blocks.colour'); // Deprecated
goog.provide('Blockly.Constants.Colour');

goog.require('Blockly.Blocks');
goog.require('Blockly.Types');
goog.require('Blockly');


/**
* Common HSV hue for all blocks in this category.
* This should be the same as Blockly.Msg.COLOUR_HUE.
* @readonly
*/
Blockly.Blocks.colour.HUE = 20;
Blockly.Constants.Colour.HUE = 20;
/** @deprecated Use Blockly.Constants.Colour.HUE */
Blockly.Blocks.colour.HUE = Blockly.Constants.Colour.HUE;

Blockly.Blocks['colour_picker'] = {
/**
* Block for colour picker.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_colour",
"name": "COLOUR",
"colour": "#ff0000"
}
],
"output": "Colour",
"colour": Blockly.Blocks.colour.HUE,
"helpUrl": Blockly.Msg.COLOUR_PICKER_HELPURL
});
// Assign 'this' to a variable for use in the tooltip closure below.
var thisBlock = this;
// Colour block is trivial. Use tooltip of parent block if it exists.
this.setTooltip(function() {
var parent = thisBlock.getParent();
return (parent && parent.getInputsInline() && parent.tooltip) ||
Blockly.Msg.COLOUR_PICKER_TOOLTIP;
});
}
};
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
// Block for colour picker.
{
"type": "colour_picker",
"message0": "%1",
"args0": [
{
"type": "field_colour",
"name": "COLOUR",
"colour": "#ff0000"
}
],
"output": "Colour",
"colour": "%{BKY_COLOUR_HUE}",
"helpUrl": "%{BKY_COLOUR_PICKER_HELPURL}",
"tooltip": "%{BKY_COLOUR_PICKER_TOOLTIP}",
"extensions": ["parent_tooltip_when_inline"]
},

Blockly.Blocks['colour_random'] = {
/**
* Block for random colour.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"message0": Blockly.Msg.COLOUR_RANDOM_TITLE,
"output": "Colour",
"colour": Blockly.Blocks.colour.HUE,
"tooltip": Blockly.Msg.COLOUR_RANDOM_TOOLTIP,
"helpUrl": Blockly.Msg.COLOUR_RANDOM_HELPURL
});
}
};
// Block for random colour.
{
"type": "colour_random",
"message0": "%{BKY_COLOUR_RANDOM_TITLE}",
"output": "Colour",
"colour": "%{BKY_COLOUR_HUE}",
"helpUrl": "%{BKY_COLOUR_RANDOM_HELPURL}",
"tooltip": "%{BKY_COLOUR_RANDOM_TOOLTIP}"
},

Blockly.Blocks['colour_rgb'] = {
/**
* Block for composing a colour from RGB components.
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl(Blockly.Msg.COLOUR_RGB_HELPURL);
this.setColour(Blockly.Blocks.colour.HUE);
this.appendValueInput('RED')
.setCheck(Blockly.Types.NUMBER.checkList)
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.COLOUR_RGB_TITLE)
.appendField(Blockly.Msg.COLOUR_RGB_RED);
this.appendValueInput('GREEN')
.setCheck(Blockly.Types.NUMBER.checkList)
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.COLOUR_RGB_GREEN);
this.appendValueInput('BLUE')
.setCheck(Blockly.Types.NUMBER.checkList)
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.COLOUR_RGB_BLUE);
this.setOutput(true, 'Colour');
this.setTooltip(Blockly.Msg.COLOUR_RGB_TOOLTIP);
}
};
// Block for composing a colour from RGB components.
{
"type": "colour_rgb",
"message0": "%{BKY_COLOUR_RGB_TITLE} %{BKY_COLOUR_RGB_RED} %1 %{BKY_COLOUR_RGB_GREEN} %2 %{BKY_COLOUR_RGB_BLUE} %3",
"args0": [
{
"type": "input_value",
"name": "RED",
"check": "Number",
"align": "RIGHT"
},
{
"type": "input_value",
"name": "GREEN",
"check": "Number",
"align": "RIGHT"
},
{
"type": "input_value",
"name": "BLUE",
"check": "Number",
"align": "RIGHT"
}
],
"output": "Colour",
"colour": "%{BKY_COLOUR_HUE}",
"helpUrl": "%{BKY_COLOUR_RGB_HELPURL}",
"tooltip": "%{BKY_COLOUR_RGB_TOOLTIP}"
},

Blockly.Blocks['colour_blend'] = {
/**
* Block for blending two colours together.
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl(Blockly.Msg.COLOUR_BLEND_HELPURL);
this.setColour(Blockly.Blocks.colour.HUE);
this.appendValueInput('COLOUR1')
.setCheck('Colour')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.COLOUR_BLEND_TITLE)
.appendField(Blockly.Msg.COLOUR_BLEND_COLOUR1);
this.appendValueInput('COLOUR2')
.setCheck('Colour')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.COLOUR_BLEND_COLOUR2);
this.appendValueInput('RATIO')
.setCheck(Blockly.Types.NUMBER.checkList)
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.COLOUR_BLEND_RATIO);
this.setOutput(true, 'Colour');
this.setTooltip(Blockly.Msg.COLOUR_BLEND_TOOLTIP);
// Block for blending two colours together.
{
"type": "colour_blend",
"message0": "%{BKY_COLOUR_BLEND_TITLE} %{BKY_COLOUR_BLEND_COLOUR1} " +
"%1 %{BKY_COLOUR_BLEND_COLOUR2} %2 %{BKY_COLOUR_BLEND_RATIO} %3",
"args0": [
{
"type": "input_value",
"name": "COLOUR1",
"check": "Colour",
"align": "RIGHT"
},
{
"type": "input_value",
"name": "COLOUR2",
"check": "Colour",
"align": "RIGHT"
},
{
"type": "input_value",
"name": "RATIO",
"check": "Number",
"align": "RIGHT"
}
],
"output": "Colour",
"colour": "%{BKY_COLOUR_HUE}",
"helpUrl": "%{BKY_COLOUR_BLEND_HELPURL}",
"tooltip": "%{BKY_COLOUR_BLEND_TOOLTIP}"
}
};
]); // END JSON EXTRACT (Do not delete this comment.)
Loading

0 comments on commit 6de4295

Please sign in to comment.