Skip to content

Commit e49c028

Browse files
authored
fix(demos): Update to use new script import names for generators (#7213)
This is mostly just chore updating to the new import names (e.g. BlocklyJavaScript -> javascript.javascriptGenerator), but the change to Code.checkAllGeneratorFunctionsDefined is a necessary fix due to the breaking change in PR #7150, implementing the .forBlock dictionary.
1 parent 5579098 commit e49c028

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

demos/code/code.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,15 @@ Code.renderContent = function() {
356356
Blockly.serialization.workspaces.save(Code.workspace), null, 2);
357357
jsonTextarea.focus();
358358
} else if (content.id === 'content_javascript') {
359-
Code.attemptCodeGeneration(Blockly.JavaScript);
359+
Code.attemptCodeGeneration(javascript.javascriptGenerator);
360360
} else if (content.id === 'content_python') {
361-
Code.attemptCodeGeneration(Blockly.Python);
361+
Code.attemptCodeGeneration(python.pythonGenerator);
362362
} else if (content.id === 'content_php') {
363-
Code.attemptCodeGeneration(Blockly.PHP);
363+
Code.attemptCodeGeneration(php.phpGenerator);
364364
} else if (content.id === 'content_dart') {
365-
Code.attemptCodeGeneration(Blockly.Dart);
365+
Code.attemptCodeGeneration(dart.dartGenerator);
366366
} else if (content.id === 'content_lua') {
367-
Code.attemptCodeGeneration(Blockly.Lua);
367+
Code.attemptCodeGeneration(lua.luaGenerator);
368368
}
369369
if (typeof PR === 'object') {
370370
PR.prettyPrint();
@@ -395,7 +395,7 @@ Code.checkAllGeneratorFunctionsDefined = function(generator) {
395395
var missingBlockGenerators = [];
396396
for (var i = 0; i < blocks.length; i++) {
397397
var blockType = blocks[i].type;
398-
if (!generator[blockType]) {
398+
if (!generator.forBlock[blockType]) {
399399
if (missingBlockGenerators.indexOf(blockType) === -1) {
400400
missingBlockGenerators.push(blockType);
401401
}
@@ -477,7 +477,7 @@ Code.init = function() {
477477

478478
// Add to reserved word list: Local variables in execution environment (runJS)
479479
// and the infinite loop detection function.
480-
Blockly.JavaScript.addReservedWords('code,timeouts,checkTimeout');
480+
javascript.javascriptGenerator.addReservedWords('code,timeouts,checkTimeout');
481481

482482
Code.loadBlocks('');
483483

@@ -588,15 +588,15 @@ Code.runJS = function(event) {
588588
event.preventDefault();
589589
}
590590

591-
Blockly.JavaScript.INFINITE_LOOP_TRAP = 'checkTimeout();\n';
591+
javascript.javascriptGenerator.INFINITE_LOOP_TRAP = 'checkTimeout();\n';
592592
var timeouts = 0;
593593
var checkTimeout = function() {
594594
if (timeouts++ > 1000000) {
595595
throw MSG['timeout'];
596596
}
597597
};
598-
var code = Blockly.JavaScript.workspaceToCode(Code.workspace);
599-
Blockly.JavaScript.INFINITE_LOOP_TRAP = null;
598+
var code = javascript.javascriptGenerator.workspaceToCode(Code.workspace);
599+
javascript.javascriptGenerator.INFINITE_LOOP_TRAP = null;
600600
try {
601601
eval(code);
602602
} catch (e) {

0 commit comments

Comments
 (0)