Skip to content

Commit d58a98c

Browse files
authored
Merge branch 'main' into seriussoft-patch-3
2 parents e56a730 + 94a5730 commit d58a98c

2 files changed

Lines changed: 62 additions & 60 deletions

File tree

classes/switchmanager.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
namespace switchblock {
2-
class SwitchManager {
3-
private switches: { [name: string]: SwitchContext } = {};
4-
5-
create(name: string): SwitchContext {
6-
const ctx = new SwitchContext();
7-
this.switches[name] = ctx;
8-
return ctx;
9-
}
10-
11-
get(name: string): SwitchContext {
12-
return this.switches[name];
13-
}
14-
15-
debug(name: string): void {
16-
const ctx = this.switches[name];
17-
console.log(`Switch "${name}" has ${ctx.caseCount()} cases`);
18-
}
1+
import {SwitchContext} from 'SwitchContext'
2+
3+
class SwitchManager {
4+
private switches: { [name: string]: SwitchContext } = {};
5+
6+
create(name: string): SwitchContext {
7+
const ctx = new SwitchContext();
8+
this.switches[name] = ctx;
9+
return ctx;
10+
}
11+
12+
get(name: string): SwitchContext {
13+
return this.switches[name];
14+
}
15+
16+
debug(name: string): void {
17+
const ctx = this.switches[name];
18+
console.log(`Switch "${name}" has ${ctx.caseCount()} cases`);
1919
}
2020
}
21+

switch.ts

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,50 @@
1-
1+
import {SwitchContext} from './classes/SwitchContext'
2+
import {SwitchManager} from './classes/SwitchManager'
23

34

45
namespace switchcase {
56

6-
/**
7-
* Switch Block Container
8-
*/
9-
//% block="switch $value"
10-
//% blockId=switchcase_switch_block
11-
//% group="Control"
12-
//% weight=100
13-
//% draggableParameters
14-
export function switchBlock(value: any): void {
15-
//this is jut a container; actual logic is in codegen
16-
//Placeholder for CodeGen
17-
}
18-
19-
/**
20-
* Case Block Container
21-
*/
22-
/**********************
23-
//% block="case $match"
24-
//% blockId=switchcase_case_block
25-
//% group="Control"
26-
//% weight=90
27-
//% draggableParameters
28-
//% draggableStatement=true
29-
export function caseBlock(match: any): void {
30-
//Placeholder for CodeGen
31-
}
32-
*********************/
33-
34-
/**
35-
* Default-Case Block Container
36-
*/
37-
/**********************
38-
//% block="default case"
39-
//% blockId=switchcase_default_case_block
40-
//% group="Control"
41-
//% weight=80
42-
//% draggableStatement=true
43-
export function defaultCaseBlock(): void {
44-
//Placeholder for CodeGen
45-
}
46-
*********************/
7+
/**
8+
* Switch Block Container
9+
*/
10+
//% block="switch $value"
11+
//% blockId=switchcase_switch_block
12+
//% group="Control"
13+
//% weight=100
14+
//% draggableParameters
15+
export function switchBlock(value: any): void {
16+
//this is jut a container; actual logic is in codegen
17+
18+
}
19+
20+
/**
21+
* Case Block Container
22+
*/
23+
/**********************
24+
//% block="case $match"
25+
//% blockId=switchcase_case_block
26+
//% group="Control"
27+
//% weight=90
28+
//% draggableParameters
29+
//% draggableStatement=true
30+
export function caseBlock(match: any): void {
31+
//Placeholder for CodeGen
32+
}
33+
*********************/
34+
35+
/**
36+
* Default-Case Block Container
37+
*/
38+
/**********************
39+
//% block="default case"
40+
//% blockId=switchcase_default_case_block
41+
//% group="Control"
42+
//% weight=80
43+
//% draggableStatement=true
44+
export function defaultCaseBlock(): void {
45+
//Placeholder for CodeGen
46+
}
47+
*********************/
4748

4849

4950
}

0 commit comments

Comments
 (0)