We have old setup of blockly and javascript_compressed generator file and its working fine. and i have downloaded the latest python_compressed file to generate python code but unfortunately i'm get this error :
Uncaught TypeError: Cannot read property 'call' of undefined
at Blockly.Generator.Blockly.Python.init (python_compressed.js:18)
at Blockly.Generator.workspaceToCode (generator.js:98)
at eval (eval at mCompileCode (Main.js:58), <anonymous>:1:23)
at mCompileCode (Main.js:58)
at compileHandler (Main.js:522)
at Object.onFileOperation (Main.js:639)
at Object.onFileOperation (App.js:78)
at onClick (Header.js:222)
at HTMLUnknownElement.callCallback (react-dom.development.js:188)
at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
at invokeGuardedCallback (react-dom.development.js:292)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:306)
at executeDispatch (react-dom.development.js:389)
at executeDispatchesInOrder (react-dom.development.js:414)
at executeDispatchesAndRelease (react-dom.development.js:3278)
at executeDispatchesAndReleaseTopLevel (react-dom.development.js:3287)
at forEachAccumulated (react-dom.development.js:3259)
at runEventsInBatch (react-dom.development.js:3304)
at runExtractedPluginEventsInBatch (react-dom.development.js:3514)
at handleTopLevel (react-dom.development.js:3558)
at batchedEventUpdates$1 (react-dom.development.js:21871)
at batchedEventUpdates (react-dom.development.js:795)
at dispatchEventForLegacyPluginEventSystem (react-dom.development.js:3568)
at attemptToDispatchEvent (react-dom.development.js:4267)
at dispatchEvent (react-dom.development.js:4189)
at unstable_runWithPriority (scheduler.development.js:653)
at runWithPriority$1 (react-dom.development.js:11039)
at discreteUpdates$1 (react-dom.development.js:21887)
at discreteUpdates (react-dom.development.js:806)
at dispatchDiscreteEvent (react-dom.development.js:4168)
on calling this function window.Blockly.Python.workspaceToCode(workspace).
and i have notice difference in between javascript and python compressed file the init function is using this keyword and i guess this may be not working due to different vesion. could you please give me solution to fix it
compressed file init function code
Blockly.JavaScript.init = function (a) {
Blockly.JavaScript.definitions_ = Object.create(null);
Blockly.JavaScript.functionNames_ = Object.create(null);
Blockly.JavaScript.variableDB_
? Blockly.JavaScript.variableDB_.reset()
: (Blockly.JavaScript.variableDB_ = new Blockly.Names(
Blockly.JavaScript.RESERVED_WORDS_
));
var b = [];
a = a.getAllVariables();
if (a.length) {
for (var c = 0; c < a.length; c++)
b[c] = Blockly.JavaScript.variableDB_.getName(
a[c].name,
Blockly.Variables.NAME_TYPE
);
Blockly.JavaScript.definitions_.variables = "var " + b.join(", ") + ";";
}
};
Blockly.Python.init = function (a) {
Object.getPrototypeOf(this).init.call(this);
this.PASS = this.INDENT + "pass\n";
this.nameDB_
? this.nameDB_.reset()
: (this.nameDB_ = new Blockly.Names(this.RESERVED_WORDS_));
this.nameDB_.setVariableMap(a.getVariableMap());
this.nameDB_.populateVariables(a);
this.nameDB_.populateProcedures(a);
for (
var b = [], c = Blockly.Variables.allDeveloperVariables(a), d = 0;
d < c.length;
d++
)
b.push(
this.nameDB_.getName(c[d], Blockly.Names.DEVELOPER_VARIABLE_TYPE) +
" = None"
);
a = Blockly.Variables.allUsedVarModels(a);
for (d = 0; d < a.length; d++)
b.push(
this.nameDB_.getName(a[d].getId(), Blockly.VARIABLE_CATEGORY_NAME) +
" = None"
);
this.definitions_.variables = b.join("\n");
this.isInitialized = !0;
};