Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(demos): Update code demo to use new script import names for generators #7213

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions demos/code/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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('');

Expand Down Expand Up @@ -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) {
Expand Down