nv-cli-creat-mach-proj-cmmn 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/creat-ha-case.js +44 -0
- package/creat-ha-switch.js +48 -0
- package/creat-one-act.js +20 -0
- package/creat-stt-switch.js +47 -0
- package/index.js +7 -0
- package/package.json +11 -0
package/creat-ha-case.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module.exports = (
|
|
2
|
+
STTENUM,
|
|
3
|
+
HIENUM,
|
|
4
|
+
ACTS,
|
|
5
|
+
hinm,
|
|
6
|
+
handle_dict,
|
|
7
|
+
ncfg,
|
|
8
|
+
depth,
|
|
9
|
+
)=> {
|
|
10
|
+
let {SELF,REF,HA,I,CD} = ncfg;
|
|
11
|
+
let indent_str = " ".repeat(depth);
|
|
12
|
+
let codes;
|
|
13
|
+
if(hinm!== "default"){
|
|
14
|
+
codes = [indent_str+`case ${HIENUM[hinm]}/*${hinm}*/: {`];
|
|
15
|
+
} else {
|
|
16
|
+
codes = [indent_str+`default: {`];
|
|
17
|
+
}
|
|
18
|
+
if(handle_dict.acts !== undefined) {
|
|
19
|
+
for(let actnm of handle_dict.acts) {
|
|
20
|
+
let code = ACTS[actnm];
|
|
21
|
+
code = code.replace(/[\s]+/,"");
|
|
22
|
+
code = code.replace(/[;]+/,";");
|
|
23
|
+
if(code[code.length-1]!=="}" && code[code.length-1]!==";") {code+=";"}
|
|
24
|
+
codes.push(indent_str+" "+code)
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
}
|
|
28
|
+
if(handle_dict.nstt !== undefined) {
|
|
29
|
+
if(handle_dict.nstt[0]!=="&") {
|
|
30
|
+
codes.push(indent_str+" "+`${SELF}.stt=${STTENUM[handle_dict.nstt]}/*${handle_dict.nstt}*/;`);
|
|
31
|
+
} else {
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
if(handle_dict.adv !== undefined) {
|
|
37
|
+
codes.push(indent_str+" "+`${I}+=${handle_dict.adv};`);
|
|
38
|
+
} else {
|
|
39
|
+
codes.push(indent_str+" "+`${I}+=1;`);
|
|
40
|
+
}
|
|
41
|
+
codes.push(indent_str+" "+"break;");
|
|
42
|
+
codes.push(indent_str+"}");
|
|
43
|
+
return codes.join("\n");
|
|
44
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const creat_one = require("./creat-ha-case");
|
|
2
|
+
|
|
3
|
+
module.exports = (
|
|
4
|
+
STTENUM,
|
|
5
|
+
HIENUM,
|
|
6
|
+
ACTS,
|
|
7
|
+
sttnm,
|
|
8
|
+
handle,
|
|
9
|
+
ncfg,
|
|
10
|
+
depth,
|
|
11
|
+
)=> {
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
let {SELF,REF,HA,I,CD} = ncfg;
|
|
15
|
+
let indent_str = " ".repeat(depth);
|
|
16
|
+
let codes = [indent_str + `case ${STTENUM[sttnm]}/*${sttnm}*/ : {`];
|
|
17
|
+
codes.push(indent_str + " " + `switch(${HA}) {`)
|
|
18
|
+
let all_hinms = Object.keys(HIENUM);
|
|
19
|
+
let hinms = [];
|
|
20
|
+
for(let hinm of all_hinms) {
|
|
21
|
+
if(handle[hinm] !== undefined) {
|
|
22
|
+
hinms.push(hinm);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
for(let hinm of hinms) {
|
|
26
|
+
let handle_dict = handle[hinm];
|
|
27
|
+
codes.push(creat_one(
|
|
28
|
+
STTENUM,
|
|
29
|
+
HIENUM,
|
|
30
|
+
ACTS,
|
|
31
|
+
hinm,
|
|
32
|
+
handle_dict,
|
|
33
|
+
ncfg,
|
|
34
|
+
depth +2,
|
|
35
|
+
));
|
|
36
|
+
}
|
|
37
|
+
////
|
|
38
|
+
if(!hinms.includes("default")) {
|
|
39
|
+
codes.push(indent_str + " " + "default : {");
|
|
40
|
+
codes.push(indent_str + " " + " " + `${I}+=1;`);
|
|
41
|
+
codes.push(indent_str + " " + " " + `break;`);
|
|
42
|
+
codes.push(indent_str + " " + "}");
|
|
43
|
+
}
|
|
44
|
+
codes.push(indent_str + " " + `}`)
|
|
45
|
+
codes.push(indent_str + " " + `break;`)
|
|
46
|
+
codes.push(indent_str + `}`);
|
|
47
|
+
return codes.join("\n");
|
|
48
|
+
}
|
package/creat-one-act.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module.exports = (
|
|
2
|
+
STTENUM,
|
|
3
|
+
HIENUM,
|
|
4
|
+
cfg,
|
|
5
|
+
code
|
|
6
|
+
)=>{
|
|
7
|
+
for(let k in cfg) {
|
|
8
|
+
let rgxstr = `##${k}`;
|
|
9
|
+
let rgx = new RegExp(rgxstr,'g');
|
|
10
|
+
let to = cfg[k];
|
|
11
|
+
code = code.replace(rgx,to);
|
|
12
|
+
}
|
|
13
|
+
code = code.replace(/#\.([a-zA-Z_][a-zA-Z_0-9]+)/g, (match, p1) => {
|
|
14
|
+
return STTENUM[p1]+`/*${p1}*/`;
|
|
15
|
+
});
|
|
16
|
+
code = code.replace(/#@([a-zA-Z_][a-zA-Z_0-9]+)/g, (match, p1) => {
|
|
17
|
+
return HIENUM[p1]+`/*${p1}*/`;
|
|
18
|
+
});
|
|
19
|
+
return code
|
|
20
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const creat_one = require("./creat-ha-switch");
|
|
2
|
+
const creat_case = require("./creat-ha-case");
|
|
3
|
+
|
|
4
|
+
module.exports = (
|
|
5
|
+
STTENUM,
|
|
6
|
+
HIENUM,
|
|
7
|
+
ACTS,
|
|
8
|
+
HANDLES,
|
|
9
|
+
ncfg,
|
|
10
|
+
depth,
|
|
11
|
+
)=> {
|
|
12
|
+
let {SELF,REF,HA,I,CD} = ncfg;
|
|
13
|
+
let indent_str = " ".repeat(depth);
|
|
14
|
+
let sttnms = Object.keys(STTENUM);
|
|
15
|
+
let codes = [indent_str+ `switch(${SELF}.stt) {`];
|
|
16
|
+
for(let sttnm of sttnms) {
|
|
17
|
+
let handle = HANDLES[sttnm];
|
|
18
|
+
if(handle!==undefined) {
|
|
19
|
+
let code = creat_one(
|
|
20
|
+
STTENUM,
|
|
21
|
+
HIENUM,
|
|
22
|
+
ACTS,
|
|
23
|
+
sttnm,
|
|
24
|
+
handle,
|
|
25
|
+
ncfg,
|
|
26
|
+
depth+1,
|
|
27
|
+
);
|
|
28
|
+
codes.push(code);
|
|
29
|
+
} else {
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
let handle_dict = HANDLES.default;
|
|
33
|
+
if(handle_dict!==undefined) {
|
|
34
|
+
codes.push(creat_case(
|
|
35
|
+
STTENUM,
|
|
36
|
+
HIENUM,
|
|
37
|
+
ACTS,
|
|
38
|
+
"default",
|
|
39
|
+
handle_dict,
|
|
40
|
+
ncfg,
|
|
41
|
+
depth +1
|
|
42
|
+
));
|
|
43
|
+
} else {
|
|
44
|
+
}
|
|
45
|
+
codes.push(indent_str+ `}`);
|
|
46
|
+
return codes.join("\n") + "\n";
|
|
47
|
+
}
|
package/index.js
ADDED