• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3* Licensed under the Apache License, Version 2.0 (the "License");
4* you may not use this file except in compliance with the License.
5* You may obtain a copy of the License at
6*
7* http://www.apache.org/licenses/LICENSE-2.0
8*
9* Unless required by applicable law or agreed to in writing, software
10* distributed under the License is distributed on an "AS IS" BASIS,
11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12* See the License for the specific language governing permissions and
13* limitations under the License.
14*/
15
16import * as vscode from 'vscode';
17import * as path from 'path';
18import * as ts from 'typescript';
19import { ParamObj, FuncObj, StructObj, ClassObj, EnumObj, UnionObj, ParseObj } from '../gen/datatype'
20import { Logger } from '../common/log';
21import fs = require('fs');
22
23export function doParseEnum(data: string) {
24  // const enumRegex = /typedef\s+enum\s+(\w*)\s*\{\s*([a-zA-Z0-9 _,]+)\}\s*(\w*)/g;
25  const enumRegex = /enum\s+(\w*)\s*{([^}]*)}/g;
26  const enums: EnumObj[] = [];
27  let match;
28  while ((match = enumRegex.exec(data)) !== null) {
29    const enumName = match[1] || match[3] || match[4];
30    const aliasName = match[3];
31    const membersString = match[2] || match[5];
32    const comregex = /,\s*\/\/.*$/gm;
33    const cleanedEnumString = membersString.replace(comregex, '');
34
35    const enumMembers = cleanedEnumString.split('\n')
36      .map(member => member.trim().replace(/[,\n\r\s]/g, ''))
37      .filter(member => member);
38
39    let enumItem = {
40      "name": enumName,
41      "alias": aliasName,
42      "members": enumMembers
43    };
44    enums.push(enumItem);
45  }
46  Logger.getInstance().info(` return enums: ${JSON.stringify(enums)}`);
47  return enums;
48}
49
50
51export function parseEnum(data: string) {
52  // 使用正则表达式提取枚举定义
53  const enumRegex = /typedef\s+enum\s+(\w*)\s*{([^}]*)}\s*(\w+)|enum\s+(\w*)\s*{([^}]*)}/g;
54  const enums: EnumObj[] = [];
55  let match;
56  while ((match = enumRegex.exec(data)) !== null) {
57    const enumName = match[1] || match[3] || match[4];
58    const aliasName = match[3];
59    const membersString = match[2] || match[5];
60    const comregex = /\/\/.*$/gm;
61    const cleanedEnumString = membersString.replace(comregex, '');
62
63    const enumMembers = cleanedEnumString.split(',')
64      .map(member => member.trim().replace(/[,\n\r\s]/g, ''))
65      .filter(member => member);
66
67    let enumItem = {
68      "name": enumName,
69      "alias": aliasName,
70      "members": enumMembers
71    };
72    enums.push(enumItem);
73  }
74  Logger.getInstance().info(` return enums: ${JSON.stringify(enums)}`);
75  return enums;
76}
77
78export function parseUnion(data: string) {
79  // 使用正则表达式提取联合体定义
80  const unionRegex = /typedef\s+union\s*(\w*)\s*{([^}]*)}\s*(\w+)\s*;|union\s+(\w+)\s*{([^}]*)}\s*;/g;
81  const unions: UnionObj[] = [];
82  let match;
83  while ((match = unionRegex.exec(data)) !== null) {
84    // 获取结构体名字
85    const unionName = match[1] || match[3] || match[4];
86    const aliasName = match[3];
87    // 获取成员声明
88    const membersString = match[2] || match[5];
89    const comregex = /\/\/.*$/gm;
90    const cleanedMembersString = membersString.replace(comregex, '');
91    const members = cleanedMembersString.split(';')
92        .map(member => member.trim().replace(/[\n\r]/g, ''))
93        .filter(member => member.length > 0);
94
95    let unionItem: UnionObj = {
96      "name": unionName,
97      "alias": aliasName,
98      "members": []
99    }
100
101    if (members.length >= 1) {
102      for (let i=0;i<members.length;i++) {
103        let declaration = members[i];
104      // members.forEach(declaration => {
105        // 使用正则表达式匹配类型和变量名
106        // const match = declaration.match(/(\w+)\s+(\w+)(\[(\d+)\])?/);
107        const memReg = /(\w[\w\s\*]+)\s+(\w+)\s*(\s*\[\s*\d+\s*(\]\s*\[\s*\d+\s*)*\])?/;
108        const match = declaration.match(memReg);
109        let arraySizes: string[] | null  = null;
110        if (match) {
111          // 类型
112          const type = match[1];
113          // 变量名
114          const variable = match[2];
115
116          // 解析数组长度
117          if ( match[3]) {
118            arraySizes = match[3]
119              .replace(/\s/g, '') // Remove all whitespace
120              .match(/\d+/g); // Find all numbers
121          }
122          // 解析数组长度
123          const numberList = arraySizes ? arraySizes.map(str => parseInt(str, 10)) : [];
124          // Logger.getInstance().debug(`Type: ${type}, Variable:${variable}, Size:${arrayLength}`);
125          let paramItem: ParamObj = {
126            "type": type,
127            "name": variable,
128            "arraySize": numberList.length>0 ? numberList[0] : -1,
129            "arraySizeList": numberList
130          }
131          unionItem.members.push(paramItem);
132        } else {
133          let paramItem: ParamObj = {
134            "type": declaration,
135            "name": '',
136            "arraySize": -1,
137            "arraySizeList": []
138          }
139          unionItem.members.push(paramItem);
140        }
141      }
142    } else if (members.length == 1) {
143      const type = members[0];
144      let paramItem: ParamObj = {
145        "type": type,
146        "name": "",
147        "arraySize": -1,
148        "arraySizeList": []
149      }
150      unionItem.members.push(paramItem);
151    }
152
153    unions.push(unionItem);
154  }
155  Logger.getInstance().info(` return unions: ${JSON.stringify(unions)}`);
156  return unions;
157}
158
159export function parseStruct(data: string) {
160  // 使用正则表达式提取结构体定义
161  // const structRegex = /typedef\s+struct\s+(\w+)\s*{([^}]*)}\s*(\w+);/g;
162  // const structRegex = /(\btypedef\b\s+)?struct\s+\w*\s*{([^}]*)}\s*(\w+);/g;
163  const structRegex = /typedef\s+struct\s*(\w*)\s*{([^}]*)}\s*(\w+)\s*;|struct\s+(\w+)\s*{([^}]*)}\s*;/g;
164  // const structs: Record<string, string[]> = {};
165  const structs: StructObj[] = [];
166  let match;
167  while ((match = structRegex.exec(data)) !== null) {
168    // 获取结构体名字
169    const structName = match[1] ||match[3] || match[4];
170    const alias = match[3];
171    // 获取成员声明
172    const membersString = match[2] || match[5];
173    // 去注释
174    const comregex = /\/\/.*$/gm;
175    const cleanedMembersString = membersString.replace(comregex, '');
176    const members = cleanedMembersString.split(';')
177        .map(member => member.trim().replace(/[\n\r]/g, ''))
178        .filter(member => member.length > 0);
179
180    const variables: string[] = [];
181    const methods: string[] = [];
182
183    members.forEach(member => {
184        // 匹配方法声明
185        const methodRegex = /(\w[\w\s\*]+)\s+(\w+)\(([^)]*)\)\s*/;
186        const variableRegex = /(\w[\w\s\*]+)\s+(\w+)\s*/;
187        const pattern = /(\w+)\s*\(\s*\*([^\)]+)\s*\)\s*\(\s*([\w\s,]*)\s*\)/;
188        if (methodRegex.test(member)) {
189            methods.push(member.trim().replace(/[\n\r]/g, ''));
190        } else if (variableRegex.test(member)) {
191            variables.push(member.trim().replace(/[\n\r]/g, ''));
192        } else if (pattern.test(member)) {
193          variables.push(member.trim().replace(/[\n\r]/g, ''));
194        }
195    });
196
197    let structItem: StructObj = {
198      "name": structName,
199      "alias": alias,
200      "members": parseMembers(variables),
201      "functions": parseMethods(methods)
202    }
203
204    structs.push(structItem);
205  }
206  // Logger.getInstance().info(` return structs: ${JSON.stringify(structs)}`);
207  return structs;
208}
209// /^(const\s+)?([\w\s*]+)\s+(\w+)(?:\[(\d+)\])?$/
210export function parseParameters(members: string[]): ParamObj[] {
211  // const memberRegex = /^(const\s+)?([\w\s*]+)\s+(\w+)(?:\[(\d+)\])?$/;
212  // const memberRegex = /^(const\s+)?([\w\:\<\>\,\s*]+)\s+(\w+)(?:\[(\d*)\])?$/;
213  const memberRegex = /^(const\s+)?([\w:<>,\s*()]+)\s+(\w+)(?:\[(\d*)])?$/;
214  // Logger.getInstance().info(` parseParameters members: ${JSON.stringify(members)}`);
215  return members.map(member => {
216      const match = member.trim().match(memberRegex);
217      // Logger.getInstance().info(` parseParameters match: ${JSON.stringify(match)}`);
218      if (match) {
219          const type = match[2].trim();
220          const name = match[3].trim();
221          // const arraySize = match[4] ? parseInt(match[4], 10) : -1;
222          const arraySize = match[4] && match[4] !== "" ? parseInt(match[4], 10) : -1;
223          return { type, name, arraySize };
224      } else {
225          const type = member;
226          const name = '';
227          // const arraySize = match[4] ? parseInt(match[4], 10) : -1;
228          const arraySize = -1;
229          return { type, name, arraySize };
230      }
231      return {};
232  // 类型保护
233  }).filter((m): m is ParamObj => m !== null);
234}
235
236export function parseMembers(members: string[]): ParamObj[] {
237  // const memberRegex = /(?:public:|private:)?\s*(\w+(?:\s+\w+)?)\s+(\w+)(?:\[(\d+)\])?/;
238  // // Logger.getInstance().info(` parseMembers members: ${JSON.stringify(members)}`);
239  // return members.map(member => {
240  //     const match = member.trim().match(memberRegex);
241  //     // Logger.getInstance().info(` parseMembers match: ${JSON.stringify(match)}`);
242  //     if (match) {
243  //         const type = match[1];
244  //         const name = match[2];
245  //         const arraySize = match[3] ? parseInt(match[3], 10) : -1;
246  //         return { type, name, arraySize };
247  //     }
248  //     return {};
249  // // 类型保护
250  // }).filter((m): m is ParamObj => m !== null);
251  const memReg = /(\w[\w\s\:\*]+)\s+(\w+)\s*(\s*\[\s*\d+\s*(\]\s*\[\s*\d+\s*)*\])?/;
252  const pattern = /(\w+)\s*\(\s*\*([^\)]+)\s*\)\s*\(\s*([\w\s,]*)\s*\)/;
253  const commPattern = /([\S\,\ ]+)\s+(\w+)/;
254  let arraySizes: string[] | null  = null;
255  return members.map(member => {
256    member = member.replace(/\s*private\s*:\s*/, '');
257    member = member.replace(/\s*public\s*:\s*/, '');
258    const match = member.trim().match(memReg);
259    if (match) {
260      const type = match[1].trim();
261      const name = match[2].trim();
262      let arraySize = 0;
263      // 解析数组长度
264      if ( match[3]) {
265        arraySizes = match[3]
266          .replace(/\s/g, '') // Remove all whitespace
267          .match(/\d+/g); // Find all numbers
268      }
269      // 解析数组长度
270      const numberList = arraySizes ? arraySizes.map(str => parseInt(str, 10)) : [];
271      let asize = numberList.length>0 ? numberList[0] : -1;
272      return {
273        "type": type,
274        "name": name,
275        "arraySize": asize,
276        "arraySizeList": numberList
277      };
278    } else {
279      let funcmatch = member.trim().match(pattern);
280      if (funcmatch) {
281          const type = funcmatch[1].trim();
282          const name = funcmatch[2].trim();
283          let paramstr = funcmatch[3];
284          paramstr = paramstr.replace(/\s+/g, '');
285          const paramlist = paramstr.split(',');
286          return {
287              "type": type,
288              "name": name,
289              "arraySize": paramlist.length,
290              "arraySizeList": paramlist.map(item => item.trim())
291          }
292      } else {
293        let cmatch = member.trim().match(commPattern);
294        if (cmatch) {
295          const type = cmatch[1].trim();
296          const name = cmatch[2].trim();
297          return {
298              "type": type,
299              "name": name,
300              "arraySize": -1,
301              "arraySizeList": []
302          }
303        } else {
304          return {
305              "type": member,
306              "name": '',
307              "arraySize": -1,
308              "arraySizeList": []
309          };
310        }
311      }
312    }
313    return {};
314  // 类型保护
315  }).filter((m): m is ParamObj => m !== null);
316}
317
318export function parseMethods(functions: string[]): FuncObj[] {
319  const functionRegex = /^(\w[\w\s]*\*?)\s+(\w+)\((.*?)\)$/;
320  // 正则表达式匹配返回值、函数名和参数
321  // const functionRegex = /(\w+)\s+(\w+)\(([^)]*)\)/;
322
323  return functions.map(func => {
324      const match = func.trim().match(functionRegex);
325      if (match) {
326          // 返回值类型
327          const returns = match[1];
328          // 方法名
329          const name = match[2];
330          // 分割参数并去除空值
331          const parameterstr = match[3].split(',').map(param => param.trim()).filter(Boolean);
332          const parameters = parseParameters(parameterstr);
333          return { returns, name, parameters };
334      }
335      return {};
336  // 类型保护
337  }).filter((f): f is FuncObj => f !== null);
338}
339
340export function parseClass(data: string) {
341  // 使用正则表达式提取类定义
342  const classRegex = /class\s+(\w+)\s*{([^}]*)}\s*(\w*)\s*;/g;
343  const classes: ClassObj[] = []
344  let match;
345  while ((match = classRegex.exec(data)) !== null) {
346    const className = match[1];
347    const alias = match[3];
348    const classMembers = match[2]
349    // 去注释
350    const comregex = /\/\/.*$/gm;
351    const cleanedMembersString = classMembers.replace(comregex, '');
352    const memlist = cleanedMembersString.split(';')
353      .map(member => member.trim().replace(/[\n\r]/g, ''))
354      .filter(member => member.length > 0);
355
356    const variables: string[] = [];
357    const methods: string[] = [];
358
359    memlist.forEach(member => {
360      // 匹配方法声明
361      const methodRegex = /(\w[\w\s\*]+)\s+(\w+)\(([^)]*)\)\s*/;
362      const variableRegex = /(\w[\w\s\*]+)\s+(\w+)\s*/;
363      const pattern = /(\w+)\s*\(\s*\*([^\)]+)\s*\)\s*\(\s*([\w\s,]*)\s*\)/;
364      const comParrtern = /([\S\,\ ]+)\s+(\w+)/;
365      if (methodRegex.test(member)) {
366        methods.push(member.trim().replace(/[\n\r]/g, ''));
367      } else if (variableRegex.test(member)) {
368        variables.push(member.trim().replace(/[\n\r]/g, ''));
369      } else if (pattern.test(member)) {
370        variables.push(member.trim().replace(/[\n\r]/g, ''));
371      } else if (comParrtern.test(member)) {
372        variables.push(member.trim().replace(/[\n\r]/g, ''));
373      } else if (member.length > 0) {
374        variables.push(member.trim().replace(/[\n\r]/g, ''));
375      }
376    });
377
378    const variableList = parseMembers(variables);
379    // Logger.getInstance().debug(`parseMembers: ${JSON.stringify(variableList)}`)
380
381    const functionList: FuncObj[] = parseMethods(methods);
382    // Logger.getInstance().debug(`parsedFunctions: ${JSON.stringify(functionList)}`);
383
384    const classItem: ClassObj = {
385      "name": className,
386      "alias": alias,
387      "variableList": variableList,
388      "functionList": functionList
389    }
390    classes.push(classItem);
391  }
392  // Logger.getInstance().info(` return classes: ${JSON.stringify(classes)}`);
393  return classes;
394}
395
396export function parseFunctionOld(data: string) {
397  // 使用正则表达式提取函数定义
398  const functionRegex1 = /([a-zA-Z_]\w*\s+)+([*a-zA-Z_]\w+)\s*\(([^)]*)\)\s*(?={|;)/g;
399  const functionRegex2 = /(\w+\s*\(.*?\)\s+)(\w+)\s*\((.*?)\);\s*/g;
400
401  let functions = data.match(functionRegex1) || [];
402  if (functions.length <= 0) {
403    Logger.getInstance().info("use functionRegex2");
404    functions = data.match(functionRegex2) || [];
405  }
406  const functionDetails: FuncObj[] = functions.map(func => {
407    // 函数解析逻辑...
408    // 普通类型的函数识别
409    if (func.trim().startsWith('typedef')) {
410      func = func.replace('typedef', '');
411    }
412    let parts = func.trim().match(/([a-zA-Z_]\w+)\s+\(*([*a-zA-Z_]\w+)\)*\s*\(([^)]*)\)/);
413    if (!parts) {
414      Logger.getInstance().info("use regex2");
415      parts = func.trim().match(/(\w+\s*\(.*?\)\s+)(\w+)\s*\((.*?)\);\s*/);
416    }
417    if (parts) {
418      let index = 1;
419      let returnType = parts[index].trim();
420      let functionName = parts[index + 1].trim();
421      let paramList = parts[index + 2].split(',');
422      if (parts[index].trim() === 'typedef') {
423          Logger.getInstance().info("typedef -------------" + parts);
424          returnType = parts[index + 1].trim();
425          functionName = parts[index + 2].trim();
426          paramList = parts[index + 3].split(',');
427      }
428
429      let paramResList = [];
430      for (let i=0; i<paramList.length; i++) {
431          let paramItem = paramList[i].trim();
432
433          let lastTabIndex = paramItem.lastIndexOf(' ');
434          let paramType = paramItem.substring(0, lastTabIndex).trim();
435          let paramName = paramItem.substring(lastTabIndex, paramItem.length).trim();
436          paramResList.push({
437              name: paramName,
438              type: paramType,
439              arraySize: 0,
440              arraySizeList: []
441          })
442      }
443      // Logger.getInstance().info(`ret: ${returnType} func: ${functionName} params:(${paramResList.map(ditem => {
444      //     return ' type: ' + ditem.type + ', ' + 'name: ' + ditem.name;
445      // })})`)
446      let funcRes: FuncObj = {
447        type: 'function',
448        name: functionName,
449        returns: returnType,
450        parameters: paramResList
451      }
452      return funcRes;
453    }
454    let res: FuncObj = {
455      type: '',
456      name: '',
457      returns: '',
458      parameters: []
459    }
460    return res;
461  })
462  .filter(detail => detail !== null);
463
464  Logger.getInstance().debug(`parse oldfunc : ${JSON.stringify(functionDetails)}`)
465  return functionDetails;
466  // if (functionDetails.length > 0) {
467  //   const funcs = [...functionDetails.filter((funcItem) : funcItem is FuncObj => funcItem !== null)];
468  //   const message = functionDetails.map(detail =>
469  //       `Function: ${detail!.name},
470  //       Return Type: ${detail!.returns},
471  //       Parameters: (${detail!.parameters.map(ditem => {
472  //           return ' type: ' + ditem.type + ', ' + 'name: ' + ditem.name;
473  //       })})`
474  //   ).join('\n');
475  //   Logger.getInstance().info(` return parseMethods: ${JSON.stringify(funcs)}`);
476  //   return funcs;
477  // } else {
478  //   vscode.window.showInformationMessage('No functions found.');
479  // }
480}
481
482export function parseFunction(data: string): FuncObj[] {
483  // const funcRegex = /^(static\s+)?(const\s+)?([\w\s\[\]*]+)\s+(\w+)\s*\(([^)]*)\);/gm;
484  // const funcRegex = /(?:typedef\s+([\w\:\<\>\s\[\]*]+)\s+\(\*\s*(\w+)\)\s*\(([^)]*)\);|^(static\s+)?(const\s+)?([\w\:\s\[\]*]+)\s+(\w+)\s*\(([^)]*)\);)/gm
485  // const funcRegex =
486  //                 /(?:typedef\s+([\S\,\ ]+)\s+\(\*\s*(\w+)\)\s*\(([^)]*)\);|^(static\s+)?(const\s+)?([\S\,\ ]+)\s+(\w+)\s*\(([^)]*)\);)/gm
487  let funcRegLines = '(?:typedef\\s+([\\S\\,\\ ]+)\\s+\\(\\*\\s*(\\w+)\\)\\s*\\(([^)]*)\\);|' +
488    '^(static\\s+)?(const\\s+)?([\\S\\,\\ ]+)\\s+(\\w+)\\s*\\(([^)]*)\\);)';
489  // let comfucRegex = /(static\s+)?(const\s+)?((?:[\w:]+\s*<[^<>]+>|[\w:*]+\s*)+)\s+(\w+)\s*\(\s*((?:[\w:]+\s*<[^<>]+>|[\w:*]+)\s+\w+(?:,\s*)*)*\s*\)/g;
490  let comfucRegex = /(static\s+)?(const\s+)?((?:[\w:]+\s*<[^<>]+>|[\w:*]+\s*)+)\s+(\w+)\s*\(\s*((?:[\w:]+\s*<[^<>]+>|[\w:*]+)\s+\w+(?:,\s*)*)*\s*\)/g;
491///(static\s+)?(const\s+)?((?:\w+(?:::\w+)*(?:<[^<>]+>)?\s*)+)\s+(\w+)\s*\(\s*((?:[\w\s:<>,*]+\s+\w+\s*,?\s*)*)\s*\)/g;
492  // const comfucRegex = /(static\s+)?(const\s+)?((?:(?:long|short|signed|unsigned)\s+){1,3}\w+|\w+[\w:*]*(?:::\w+[\w:*<>]*)*)\s+(\w+)\s*\(\s*((?:\s*(?:[\w\s:<>,*]+)\s+\w+\s*,?)*)\s*\)/g;
493  const funcRegex = new RegExp(funcRegLines, 'gm');
494  const functions: FuncObj[] = []
495  let match;
496  let isFind = false;
497  while ((match = funcRegex.exec(data)) !== null) {
498    // Logger.getInstance().debug(`func match: ${JSON.stringify(match)}`)
499    // match[3].trim();
500    const returnType = match[1] ? match[1].trim() : match[6].trim();
501    // match[4].trim();
502    const name = match[2] ? match[2].trim() : match[7].trim();
503    // match[5].split(',').map(param => param.trim()).filter(param => param);
504    let paramstr = (match[3] ? match[3] : match[8] || "")
505    let paramreg = /([\w\s\:\*]+<[^>]*>[\s\w\:\*]+|[\*\w\s\:]+)/g;
506    let pmatch;
507    let matches = [];
508
509    while ((pmatch = paramreg.exec(paramstr)) !== null) {
510        matches.push(pmatch[0].trim());
511    }
512
513    let isInterface = match[0].includes('typedef');
514    let funcItem: FuncObj = {
515      "type": isInterface ? "typedef" : "function",
516      "returns": returnType,
517      "name": name,
518      "parameters": parseParameters(matches)
519    }
520    isFind = true;
521    functions.push(funcItem);
522  }
523
524  if (!isFind) {
525    while ((match = comfucRegex.exec(data)) !== null) {
526      const returnType = match[3].trim();
527      const name = match[4].trim();
528      let paramstr = match[5];
529
530      let paramreg = /([\w\s\:\*]+<[^>]*>[\s\w\:\*]+|[\*\w\s\:]+)/g;
531      let pmatch;
532      let matches = [];
533
534      while ((pmatch = paramreg.exec(paramstr)) !== null) {
535          matches.push(pmatch[0].trim());
536      }
537
538      let funcItem: FuncObj = {
539        "type": "function",
540        "returns": returnType,
541        "name": name,
542        "parameters": parseParameters(matches)
543      }
544      isFind = true;
545      functions.push(funcItem);
546    }
547  }
548  // Logger.getInstance().info(` return functions: ${JSON.stringify(functions)}`);
549  return functions;
550}
551
552export function parseHeaderFile(filePath: string): Promise<ParseObj> {
553  return new Promise((resolve, reject) => {
554    let parseRes: ParseObj = {
555      enums: [],
556      unions: [],
557      structs: [],
558      classes: [],
559      funcs: []
560    };
561
562    // 读取文件内容
563    fs.readFile(filePath, 'utf8', (err: NodeJS.ErrnoException | null, data: string) => {
564      if (err) {
565        vscode.window.showErrorMessage(`Error reading file: ${err.message}`);
566        reject(err);
567        return;
568      }
569
570      const enumList = parseEnum(data);
571      const unionList = parseUnion(data);
572      const structList = parseStruct(data);
573      const classList = parseClass(data);
574      const funcList = parseFunction(data);
575      parseRes = {
576        enums: enumList,
577        unions: unionList,
578        structs: structList,
579        classes: classList,
580        funcs: funcList
581      }
582      // Logger.getInstance().info(` return parse result: ${JSON.stringify(parseRes)}`);
583      resolve(parseRes);
584    });
585  });
586}
587