From 1bcf21011e93f281afdbf8129abc5ea67422227e Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Tue, 27 Jun 2023 16:36:10 +0100 Subject: [PATCH] fix(demos): Update to use new script import names for generators 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. --- demos/code/code.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/demos/code/code.js b/demos/code/code.js index 7752e67632a..63b776aab9c 100644 --- a/demos/code/code.js +++ b/demos/code/code.js @@ -356,15 +356,15 @@ Code.renderContent = function() { Blockly.serialization.workspaces.save(Code.workspace), null, 2); jsonTextarea.focus(); } else if (content.id === 'content_javascript') { - Code.attemptCodeGeneration(Blockly.JavaScript); + Code.attemptCodeGeneration(javascript.javascriptGenerator); } else if (content.id === 'content_python') { - Code.attemptCodeGeneration(Blockly.Python); + Code.attemptCodeGeneration(python.pythonGenerator); } else if (content.id === 'content_php') { - Code.attemptCodeGeneration(Blockly.PHP); + Code.attemptCodeGeneration(php.phpGenerator); } else if (content.id === 'content_dart') { - Code.attemptCodeGeneration(Blockly.Dart); + Code.attemptCodeGeneration(dart.dartGenerator); } else if (content.id === 'content_lua') { - Code.attemptCodeGeneration(Blockly.Lua); + Code.attemptCodeGeneration(lua.luaGenerator); } if (typeof PR === 'object') { PR.prettyPrint(); @@ -395,7 +395,7 @@ Code.checkAllGeneratorFunctionsDefined = function(generator) { var missingBlockGenerators = []; for (var i = 0; i < blocks.length; i++) { var blockType = blocks[i].type; - if (!generator[blockType]) { + if (!generator.forBlock[blockType]) { if (missingBlockGenerators.indexOf(blockType) === -1) { missingBlockGenerators.push(blockType); } @@ -477,7 +477,7 @@ Code.init = function() { // Add to reserved word list: Local variables in execution environment (runJS) // and the infinite loop detection function. - Blockly.JavaScript.addReservedWords('code,timeouts,checkTimeout'); + javascript.javascriptGenerator.addReservedWords('code,timeouts,checkTimeout'); Code.loadBlocks(''); @@ -588,15 +588,15 @@ Code.runJS = function(event) { event.preventDefault(); } - Blockly.JavaScript.INFINITE_LOOP_TRAP = 'checkTimeout();\n'; + javascript.javascriptGenerator.INFINITE_LOOP_TRAP = 'checkTimeout();\n'; var timeouts = 0; var checkTimeout = function() { if (timeouts++ > 1000000) { throw MSG['timeout']; } }; - var code = Blockly.JavaScript.workspaceToCode(Code.workspace); - Blockly.JavaScript.INFINITE_LOOP_TRAP = null; + var code = javascript.javascriptGenerator.workspaceToCode(Code.workspace); + javascript.javascriptGenerator.INFINITE_LOOP_TRAP = null; try { eval(code); } catch (e) {