-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclass.js
More file actions
53 lines (49 loc) · 1.79 KB
/
Copy pathclass.js
File metadata and controls
53 lines (49 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Blockly.Blocks['class_creation'] = {
init: function() {
this.appendDummyInput()
.appendField("Create class")
.appendField(new Blockly.FieldVariable("new class"), "CLASS");
this.appendDummyInput()
.appendField("Inherits from")
.appendField(new Blockly.FieldVariable("j"), "NAME")
.appendField(",")
.appendField(new Blockly.FieldVariable("k"), "NAME");
this.appendStatementInput("BODY")
.setCheck(null);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(230);
this.setTooltip('');
this.setHelpUrl('http://www.example.com/');
}
};
Blockly.Python['class_creation'] = function(block) {
var class_name = Blockly.Python.variableDB_.getName(block.getFieldValue('CLASS'), Blockly.Variables.NAME_TYPE) || '___';
var body = Blockly.Python.statementToCode(block, 'BODY') ||
Blockly.Python.PASS;
// TODO: Assemble Python into code variable.
var code = 'class ' + class_name + ':\n' + body;
return code;
};
Blockly.Blocks['attribute_access'] = {
init: function() {
this.appendValueInput("MODULE")
.setCheck(null);
this.appendValueInput("NAME")
.setCheck(null)
.appendField(".");
this.setInputsInline(true);
this.setOutput(true, null);
this.setColour(230);
this.setTooltip('');
this.setHelpUrl('');
}
};
Blockly.Python['attribute_access'] = function(block) {
var value_module = Blockly.Python.valueToCode(block, 'MODULE', Blockly.Python.ORDER_MEMBER);
var value_name = Blockly.Python.valueToCode(block, 'NAME', Blockly.Python.ORDER_MEMBER);
// TODO: Assemble JavaScript into code variable.
var code = value_module+'.'+value_name;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};