-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExporter.ts
43 lines (35 loc) · 1.07 KB
/
Exporter.ts
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
import {EnumDef, Func, StructConst, StructDef} from "./c_types";
export class Exporter {
structs: Array<StructDef> = [];
globalFunctions: Array<Func> = [];
structConsts: Array<StructConst> = []
enums: Array<EnumDef> = [];
constructor() {
}
DefStruct(name: string): StructDef {
let s = new StructDef(name);
this.structs.push(s);
return s;
}
DefGlobalFunction(name: string): Func {
let s = new Func(name);
this.globalFunctions.push(s);
return s;
}
DefStructConst(name: string, structDef: StructDef, vals: any): any {
if(structDef == null) {
throw `struct not found`;
}
this.structConsts.push(new StructConst(structDef, name, vals));
}
// DefEnum(_enum: any, name: string) {
// this.enums.push(new EnumDef(name, _enum));
// }
GetStructForName(name: string) {
let results = this.structs.filter(value => value.name == name);
if(results.length == 1) {
return results[0];
}
return null;
}
}