export-table-plugin-csharp 1.1.189

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.
Files changed (47) hide show
  1. package/.vscode/launch.json +21 -0
  2. package/bin/Json2LiteDB.exe +0 -0
  3. package/bin/Json2LiteDB.pdb +0 -0
  4. package/bin/LiteDB.dll +0 -0
  5. package/bin/LiteDB.xml +7288 -0
  6. package/dist/CSParseTool.d.ts +36 -0
  7. package/dist/CSParseTool.d.ts.map +1 -0
  8. package/dist/CSParseTool.js +533 -0
  9. package/dist/CSProtoParser.d.ts +22 -0
  10. package/dist/CSProtoParser.d.ts.map +1 -0
  11. package/dist/CSProtoParser.js +171 -0
  12. package/dist/ExportCSPlugin.d.ts +9 -0
  13. package/dist/ExportCSPlugin.d.ts.map +1 -0
  14. package/dist/ExportCSPlugin.js +290 -0
  15. package/dist/ExportLiteDBCSPlugin.d.ts +8 -0
  16. package/dist/ExportLiteDBCSPlugin.d.ts.map +1 -0
  17. package/dist/ExportLiteDBCSPlugin.js +221 -0
  18. package/dist/ExportLiteDBUnityCSJsonPlugin.d.ts +11 -0
  19. package/dist/ExportLiteDBUnityCSJsonPlugin.d.ts.map +1 -0
  20. package/dist/ExportLiteDBUnityCSJsonPlugin.js +190 -0
  21. package/dist/ExportUnityCSJsonPlugin.d.ts +10 -0
  22. package/dist/ExportUnityCSJsonPlugin.d.ts.map +1 -0
  23. package/dist/ExportUnityCSJsonPlugin.js +265 -0
  24. package/dist/ExportUnityMMPPlugin.d.ts +8 -0
  25. package/dist/ExportUnityMMPPlugin.d.ts.map +1 -0
  26. package/dist/ExportUnityMMPPlugin.js +116 -0
  27. package/dist/index.d.ts +7 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +15 -0
  30. package/package.json +24 -0
  31. package/res/mmp-cs/BitUtils.cs +171 -0
  32. package/res/mmp-cs/BitUtils.cs.meta +11 -0
  33. package/res/mmp-cs/WritableValueTuple.cs +40 -0
  34. package/res/mmp-cs/WritableValueTuple.cs.meta +11 -0
  35. package/src/CSParseTool.ts +425 -0
  36. package/src/CSProtoParser.ts +137 -0
  37. package/src/ExportCSPlugin.ts +321 -0
  38. package/src/ExportLiteDBCSPlugin.ts +245 -0
  39. package/src/ExportLiteDBUnityCSJsonPlugin.ts +175 -0
  40. package/src/ExportUnityCSJsonPlugin.ts +297 -0
  41. package/src/ExportUnityMMPPlugin.ts +127 -0
  42. package/src/index.ts +14 -0
  43. package/test/testCS.bat +1 -0
  44. package/test/testCSWithProto.bat +1 -0
  45. package/test/testLiteDB.bat +2 -0
  46. package/test/testUJson.bat +2 -0
  47. package/tsconfig.json +101 -0
@@ -0,0 +1,425 @@
1
+
2
+ import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase, HandleBatchParams, iff, FieldType, makeFirstLetterLower, DataTable } from "export-table-lib"
3
+ import * as fs from "fs-extra"
4
+
5
+ export function TryConvValue(value: any, t: FieldType, f: Field): any {
6
+ try {
7
+ return ConvValue(value, t, f)
8
+ } catch (ex) {
9
+ if (ex instanceof TypeError) {
10
+ console.error(ex)
11
+ return null
12
+ } else {
13
+ return null
14
+ }
15
+ }
16
+ }
17
+
18
+ export function ConvValue(value: any, t: FieldType, f: Field): any {
19
+ if (t == "object") {
20
+ return JSON.parse(value)
21
+ } else if (t == "object[]") {
22
+ return JSON.parse(value)
23
+ } else if (t == "number" || t == "float") {
24
+ return JSON.parse(value)
25
+ } else if (t == "int" || t == "long") {
26
+ return parseInt(value)
27
+ } else if (t == "number[]" || t == "float[]") {
28
+ return JSON.parse(value)
29
+ } else if (t == "int[]") {
30
+ return JSON.parse(value)
31
+ } else if (t == "long[]") {
32
+ return JSON.parse(value)
33
+ } else if (t == "uid") {
34
+ return JSON.parse(value)
35
+ } else if (t == "bool") {
36
+ try {
37
+ return !!JSON.parse(value)
38
+ } catch (ex) {
39
+ console.log(ex)
40
+ return false
41
+ }
42
+ } else if (t == "bool[]") {
43
+ return JSON.parse(value)
44
+ } else if (t == "string") {
45
+ return value
46
+ } else if (t == "string[]") {
47
+ return JSON.parse(value)
48
+ } else if (t == "fk") {
49
+ return value
50
+ } else if (t == "fk[]") {
51
+ return value
52
+ } else if (t == "any") {
53
+ console.log(f)
54
+ throw new TypeError(`invalid type ${f.name}:<${f.rawType} => any>`)
55
+ } else if (t == "key") {
56
+ return JSON.parse(t)
57
+ }
58
+
59
+ throw new TypeError(`invalid unkown type ${f.name}:<${f.rawType} => ${f.type} << ${t}>`)
60
+ }
61
+
62
+ export type ValueTuple = {
63
+ Item1?: any,
64
+ Item2?: any,
65
+ }
66
+
67
+ export function genTupleArrayValue(f: Field, content: string): { isArray: boolean, objs: ValueTuple[] } | undefined {
68
+ var line = f.rawType.replaceAll(/(?<=[^\w])(boolean)(?=[^\w]|$)/g, "bool");
69
+ let m = line.match(/\@\((\w+),(\w+)\)(\[\])?/)
70
+ if (m != null) {
71
+ // [{"Item1":99,"Item2":"klwjefl"}]
72
+ let index = 0;
73
+ let objs: ValueTuple[] = []
74
+ let isArray = false
75
+ // console.log(`input: ${content}`)
76
+ while (0 <= index && index < content.length) {
77
+ let segIndex = content.indexOf(";;", index)
78
+ if (segIndex == -1) {
79
+ segIndex = content.length
80
+ }
81
+ let index2 = content.indexOf("|", index)
82
+ if (index2 == -1 || index2 >= segIndex) {
83
+ if (content.length > 0) {
84
+ console.error(`表格格式错误,缺少部分数据,将用默认值填充<${f.name}>: ${content}`)
85
+ }
86
+ index2 = segIndex
87
+ }
88
+ let numStr = content.substring(index, index2)
89
+ let t1 = m[1]
90
+ let v1 = index == index2 ? undefined : TryConvValue(numStr, t1 as any, f);
91
+ // console.log(`parseinfo1: ${content}, ${index}, ${index2}, ${numStr}, ${t1}, ${v1}`)
92
+
93
+ let index3 = Math.min(index2 + 1, segIndex)
94
+ let ssStr = content.substring(index3, segIndex)
95
+ let t2 = m[2]
96
+ let v2 = index3 == segIndex ? undefined : TryConvValue(ssStr, t2 as any, f);
97
+ // console.log(`parseinfo2: ${content}, ${index3}, ${segIndex}, ${ssStr}, ${t2}, ${v2}`)
98
+ let obj: ValueTuple = {}
99
+ if (v1 != undefined) {
100
+ obj.Item1 = v1
101
+ }
102
+ if (v2 != undefined) {
103
+ obj.Item2 = v2
104
+ }
105
+ objs.push(obj)
106
+
107
+ if (segIndex >= content.length) {
108
+ break
109
+ }
110
+ index = segIndex + 2
111
+ }
112
+
113
+ isArray = m[3] == "[]"
114
+
115
+ return { isArray, objs }
116
+ }
117
+
118
+ return undefined
119
+ }
120
+
121
+ export function ToNewTupleStatement(obj: ValueTuple) {
122
+ return `new(){${iff(obj.Item1 != null, () => `Item1=${obj.Item1},`)}${iff(obj.Item2 != null, () => `Item2=${obj.Item2},`)}}`
123
+ }
124
+
125
+ export function ConvValue2Literal(value: any, t: FieldType, f: Field): string {
126
+ // console.log(t)
127
+ if (t == "object") {
128
+ //throw new Error("invalid type <object>")
129
+ let convert: string[] = [];
130
+ for (let k in value) {
131
+ convert.push(`{"${k}","${(value as any)[k].toString()}"}`);
132
+ };
133
+ return `new Dictionary<string,string>(${convert.length}){${convert}}`;
134
+ } else if (t == "object[]") {
135
+ let values = value as object[];
136
+ //throw new Error("invalid type <object[]>")
137
+ return `new List<Dictionary<string,string>>(){${values.map((val) => {
138
+ let convert: string[] = [];
139
+ for (let k in val) {
140
+ convert.push(`{"${k}","${(val as any)[k].toString()}"}`);
141
+ };
142
+ return `new Dictionary<string,string>(${convert.length}){${convert}}`;
143
+ })}}`
144
+ } else if (t == "number" || t == "int" || t == "long") {
145
+ return `${value}`
146
+ } else if (t == "number[]") {
147
+ let values = value as number[]
148
+ return `new double[]{${values.join(", ")}}`
149
+ } else if (t == "float[]") {
150
+ let values = value as number[]
151
+ return `new float[]{${values.join(", ")}}`
152
+ } else if (t == "int[]") {
153
+ let values = value as number[]
154
+ return `new int[]{${values.join(", ")}}`
155
+ } else if (t == "long[]") {
156
+ let values = value as number[]
157
+ return `new long[]{${values.join(", ")}}`
158
+ } else if (t == "uid") {
159
+ return `${value}`
160
+ } else if (t == "bool") {
161
+ return `${value}`
162
+ } else if (t == "bool[]") {
163
+ let values = value as boolean[]
164
+ return `new bool[]{${values.join(", ")}}`
165
+ } else if (t == "string") {
166
+ // return `"${value}"`
167
+ return JSON.stringify(value)
168
+ } else if (t == "string[]") {
169
+ let values = value as string[]
170
+ return `new string[]{${values.map(v => JSON.stringify(v)).join(", ")}}`
171
+ } else if (t.startsWith("WritableValueTuple<")) {
172
+ let result = genTupleArrayValue(f, value)
173
+ // console.log(`result: ${value}=> ${JSON.stringify(result)}`)
174
+ if (result == null) {
175
+ throw new Error(`invalid tuple/tuple[] format: ${value}`)
176
+ }
177
+ let { isArray, objs } = result
178
+ if (isArray) {
179
+ return `new ${f.type}{${foreach(objs, obj => ToNewTupleStatement(obj), ",")}}`
180
+ } else {
181
+ let obj = objs[0] ?? {}
182
+ return ToNewTupleStatement(obj)
183
+ }
184
+ } else if (t == "fk") {
185
+ return `${value}`
186
+ } else if (t == "fk[]") {
187
+ let values = value as number[]
188
+ return `new int[]{${values.join(", ")}}`
189
+ } else if (t == "any") {
190
+ console.log(f)
191
+ throw new Error(`invalid type ${f.name}:<${f.rawType} | ${f.type} => any>`)
192
+ } else if (t == "key") {
193
+ return `${value}`
194
+ }
195
+
196
+ console.error(`invalid type ${f.name}`, f)
197
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => unkown>`)
198
+ }
199
+
200
+ export let isSkipExportDefaults0 = process.argv.findIndex(v => v == "--SkipDefaults") >= 0
201
+ let withProtoIndex = process.argv.findIndex(v => v == "--WithProto")
202
+ export let isOverwriteWithProto = withProtoIndex >= 0
203
+ export let overwriteWithProtoPath = isOverwriteWithProto ? process.argv[withProtoIndex + 1] : ""
204
+
205
+ export let firstLetterUpper = function (str: string) {
206
+ return str.charAt(0).toUpperCase() + str.slice(1);
207
+ };
208
+ export let firstLetterLower = function (str: string) {
209
+ return str.charAt(0).toLowerCase() + str.slice(1);
210
+ };
211
+ export let convMemberName = function (str: string) {
212
+ return str.split("_").map(s => firstLetterUpper(s)).join("")
213
+ }
214
+ export let convVarName = firstLetterLower
215
+
216
+ export let getFieldElementType = function (f: Field) {
217
+ let t = f.type
218
+ if (t.endsWith("[]")) {
219
+ var type = getFieldType(f)
220
+ return type.substring(0, type.length - 2)
221
+ } else if (t == "any") {
222
+ console.log(f)
223
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`)
224
+ } else if (t == "key") {
225
+ return "string";
226
+ } else {
227
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => unkown>`)
228
+ }
229
+ return t;
230
+ }
231
+
232
+ export let getFieldType = function (f: Field) {
233
+ let t = f.type
234
+ if (t == "object") {
235
+ //throw new Error("invalid type <Dictionary<string,string>>")
236
+ return "Dictionary<string,string>"
237
+ } else if (t == "object[]") {
238
+ //throw new Error("invalid type <Dictionary<string,string>[]>")
239
+ return "List<Dictionary<string,string>>"
240
+ } else if (t == "number") {
241
+ return "double";
242
+ } else if (t == "number[]") {
243
+ return "double[]";
244
+ } else if (t == "float") {
245
+ return "float";
246
+ } else if (t == "float[]") {
247
+ return "float[]";
248
+ } else if (t == "int") {
249
+ return "int";
250
+ } else if (t == "int[]") {
251
+ return "int[]";
252
+ } else if (t == "long") {
253
+ return "long";
254
+ } else if (t == "long[]") {
255
+ return "long[]";
256
+ } else if (t == "uid") {
257
+ return "int";
258
+ } else if (t == "bool") {
259
+ return "bool";
260
+ } else if (t == "bool[]") {
261
+ return "bool[]";
262
+ } else if (t == "string") {
263
+ return "string";
264
+ } else if (t == "string[]") {
265
+ return "string[]";
266
+ } else if (t == "fk") {
267
+ return "int";
268
+ } else if (t == "fk[]") {
269
+ return "int[]";
270
+ } else if (t.startsWith("WritableValueTuple<")) {
271
+ return t;
272
+ } else if (t == "any") {
273
+ console.log(f)
274
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`)
275
+ } else if (t == "key") {
276
+ return "string";
277
+ } else {
278
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => unkown>`)
279
+ }
280
+ return t;
281
+ }
282
+
283
+ export let isTypeArray = function (f: Field) {
284
+ let t = f.type
285
+ let isArray = t.endsWith("[]")
286
+ return isArray
287
+ }
288
+
289
+ export let getFieldAnnotation = function (f: Field) {
290
+ let anno = '[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0)]'
291
+ let t = f.type
292
+ if (t == "object") {
293
+ return ""
294
+ } else if (t == "object[]") {
295
+ //throw new Error("invalid type <Dictionary<string,string>[]>")
296
+ return ""
297
+ } else if (t == "number") {
298
+ return "";
299
+ } else if (t == "number[]") {
300
+ return anno;
301
+ } else if (t == "float") {
302
+ return "";
303
+ } else if (t == "float[]") {
304
+ return anno;
305
+ } else if (t == "int") {
306
+ return "";
307
+ } else if (t == "int[]") {
308
+ return anno;
309
+ } else if (t == "long") {
310
+ return "";
311
+ } else if (t == "long[]") {
312
+ return anno;
313
+ } else if (t == "uid") {
314
+ return "";
315
+ } else if (t == "bool") {
316
+ return "";
317
+ } else if (t == "bool[]") {
318
+ return anno;
319
+ } else if (t == "string") {
320
+ return "";
321
+ } else if (t == "string[]") {
322
+ return anno;
323
+ } else if (t == "fk") {
324
+ return "";
325
+ } else if (t == "fk[]") {
326
+ return anno;
327
+ } else if (t == "any") {
328
+ console.log(f)
329
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`)
330
+ } else if (t == "key") {
331
+ return "string";
332
+ } else {
333
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => unkown>`)
334
+ }
335
+ return t;
336
+ }
337
+
338
+ export let getCustomFieldTypeAnnotation = function (f: Field) {
339
+ let anno = '[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0)]'
340
+ let t = f.type
341
+ if (t == "string") {
342
+ if (f.rawType.endsWith("[]")) {
343
+ return anno;
344
+ }
345
+ return "";
346
+ } else if (t == "any") {
347
+ console.log(f)
348
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`)
349
+ } else if (t == "key") {
350
+ return "string";
351
+ } else {
352
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => unkown>`)
353
+ }
354
+ return t;
355
+ }
356
+
357
+ export let getFkFieldType = function (tables: DataTable[], field: Field) {
358
+ return tables.find(a => a.name == field.fkTableName)!.fields!.find(a => a.name == field.fkFieldName)!.type
359
+ }
360
+
361
+ export const genValue = (value: any, f: Field): string => {
362
+ return ConvValue2Literal(value, f.type, f)
363
+ }
364
+
365
+ export const getTitle = (v: Field) => {
366
+ return v.describe.split("\n")[0]
367
+ }
368
+
369
+ export const getDescripts = (v: Field) => {
370
+ return v.describe.split("\n")
371
+ }
372
+
373
+ export const convTupleArrayType = (f: Field) => {
374
+ let line0 = f.rawType.replaceAll(/(?<=[^\w])(number)(?=[^\w]|$)/g, "double").replaceAll(/(?<=[^\w])(boolean)(?=[^\w]|$)/g, "bool");
375
+ let m = line0.match(/\@\((\w+),(\w+)\)(\[\])?/)
376
+ if (m != null) {
377
+ let type1 = m[1]
378
+ let type2 = m[2]
379
+ let isArray = m[3] != null
380
+ let type = `WritableValueTuple<${type1}, ${type2}>${isArray ? "[]" : ""}`
381
+ let name = `${convMemberName(f.name)}Obj`
382
+ let f2 = { ...f, type, name }
383
+ return f2 as Field
384
+ } else {
385
+ return undefined;
386
+ }
387
+ }
388
+
389
+ export const convTupleArrayTypeDefine = (f: Field) => {
390
+ let line0 = f.rawType.replaceAll(/(?<=[^\w])(number)(?=[^\w]|$)/g, "double").replaceAll(/(?<=[^\w])(boolean)(?=[^\w]|$)/g, "bool");
391
+ let m = line0.match(/\@\((\w+),(\w+)\)(\[\])?/)
392
+ if (m != null) {
393
+ let type1 = m[1]
394
+ let type2 = m[2]
395
+ let isArray = m[3] != null
396
+ let line = `public WritableValueTuple<${type1}, ${type2}>${isArray ? "[]" : ""} ${convMemberName(f.name)}Obj;`
397
+ return line;
398
+ } else {
399
+ return `public ${line0} ${convMemberName(f.name)}Obj;`
400
+ }
401
+ }
402
+
403
+ export function GetUsingJsonToolNamespace() {
404
+ let jsonToolNamespaceIndex = process.argv.findIndex(v => v == "--AssetToolNamespace")
405
+ let jsonToolNamespace = null;
406
+ if (jsonToolNamespaceIndex >= 0 && process.argv.length > jsonToolNamespaceIndex + 1) {
407
+ jsonToolNamespace = process.argv[jsonToolNamespaceIndex + 1]
408
+ }
409
+ let useJsonToolNamesapce = jsonToolNamespace != null ? `using ${jsonToolNamespace};` : ``
410
+ return useJsonToolNamesapce
411
+ }
412
+
413
+ export let isEnableMMP = process.argv.findIndex(v => v == "--EnableMMPB") >= 0
414
+ export let useMMPNamespace = "using LoadTableMMP.Runtime;"
415
+
416
+ export function outputFileSync(savePath: string, content1: any, options: BufferEncoding): void {
417
+ if (fs.existsSync(savePath)) {
418
+ let content = fs.readFileSync(savePath, options)
419
+ if (content != content1) {
420
+ fs.outputFileSync(savePath, content1, options)
421
+ }
422
+ } else {
423
+ fs.outputFileSync(savePath, content1, options)
424
+ }
425
+ }
@@ -0,0 +1,137 @@
1
+ import * as fs from 'fs-extra';
2
+ import { firstLetterLower } from './CSParseTool';
3
+
4
+ let fieldTypeMap: { [key: string]: string } = {
5
+ ["float"]: "float",
6
+ ["double"]: "double",
7
+ ["int32"]: "int",
8
+ ["bool"]: "bool",
9
+ ["bytes"]: "byte[]",
10
+ }
11
+ export class FieldInfo {
12
+ name: string = ""
13
+ isArray: boolean = false
14
+ type: string = ""
15
+ csName: string = ""
16
+ csType: string = ""
17
+
18
+ setName(n: string) {
19
+ this.name = n
20
+
21
+ this.csName = firstLetterLower(this.name.split("_")
22
+ .map(t => t.slice(0, 1).toUpperCase() + t.slice(1))
23
+ .join(""))
24
+ }
25
+ setType(t: string, isArray: boolean) {
26
+ this.isArray = isArray
27
+ this.type = t;
28
+
29
+ let internalType = fieldTypeMap[this.type]
30
+ if (internalType != undefined) {
31
+ this.csType = this.isArray ? `${internalType}[]` : internalType
32
+ } else {
33
+ this.csType = this.isArray ? `${t}[]` : t
34
+ }
35
+ }
36
+
37
+ getFieldType() {
38
+ return this.csType
39
+ }
40
+ }
41
+
42
+ export class ClassInfo {
43
+ name: string = ""
44
+ type: "class" | "enum" = "class"
45
+ fields: FieldInfo[] = []
46
+
47
+ getFieldInfo(fieldName: string) {
48
+ return this.fields.find(field => field.csName == fieldName)
49
+ }
50
+
51
+ }
52
+
53
+ export class CSProtoParser {
54
+ typeMap: Map<string, ClassInfo> = new Map();
55
+ parseProtoFile(filePath: string) {
56
+ let content = fs.readFileSync(filePath, "utf-8");
57
+ let classMeta = new ClassInfo()
58
+ let curClass: ClassInfo | null = null
59
+ let codeLines = content.split("\n")
60
+ let classMapperRegex = /\/\/\!Mapper\((\w+)\)/
61
+ let messageRegex = /message (\w+)/
62
+ let enumRegex = /enum (\w+)/
63
+ let structEndRegex = /^\}/
64
+ let fieldRegex = /(?:(repeated) )?(\w+) (\w+)\s*=\s*\d+;/
65
+ let codeLinesLen = codeLines.length
66
+ let isInClass = false;
67
+ for (let i = 0; i < codeLinesLen; i++) {
68
+ let line = codeLines[i]
69
+ if (!isInClass) {
70
+ // check enter class
71
+ while (true) {
72
+ let mMapper = line.match(classMapperRegex)
73
+ if (mMapper) {
74
+ let mapName = mMapper[1]
75
+ classMeta.name = mapName
76
+ console.log(`mapper: ${mapName}`)
77
+ }
78
+ let m1 = line.match(messageRegex)
79
+ if (m1) {
80
+ let className = m1[1]
81
+ curClass = new ClassInfo()
82
+ // console.log(`find class: ${className}`)
83
+ curClass.name = className
84
+ curClass.type = "class"
85
+ if (classMeta.name != "") {
86
+ this.typeMap.set(classMeta.name, curClass)
87
+ } else {
88
+ this.typeMap.set(className, curClass)
89
+ }
90
+ isInClass = true
91
+ break
92
+ }
93
+ let m2 = line.match(enumRegex)
94
+ if (m2) {
95
+ let enumName = m2[1]
96
+ curClass = new ClassInfo()
97
+ curClass.name = enumName
98
+ curClass.type = "enum"
99
+ if (classMeta.name != "") {
100
+ this.typeMap.set(classMeta.name, curClass)
101
+ } else {
102
+ this.typeMap.set(enumName, curClass)
103
+ }
104
+ isInClass = true
105
+ break
106
+ }
107
+ break
108
+ }
109
+ } else {
110
+ // check leave class
111
+ let m3 = line.match(structEndRegex)
112
+ if (m3) {
113
+ curClass = null
114
+ classMeta.name = ""
115
+ isInClass = false;
116
+ } else {
117
+ // parse class fields
118
+ let mField = line.match(fieldRegex)
119
+ if (mField) {
120
+ let isArray = mField[1] == "repeated"
121
+ let fieldType = mField[2]
122
+ let fieldName = mField[3]
123
+ let field = new FieldInfo()
124
+ field.setName(fieldName)
125
+ field.setType(fieldType, isArray)
126
+ curClass!.fields.push(field)
127
+ // console.log(`find field: ${field.csName}, ${field.csType}, ${field.isArray}`)
128
+ }
129
+ }
130
+ }
131
+ }
132
+ }
133
+
134
+ getClassInfo(className: string) {
135
+ return this.typeMap.get(className)
136
+ }
137
+ }