1
0
mirror of https://github.com/fumiama/gozel.git synced 2026-06-28 14:50:28 +08:00

feat(gen): add more comments & support _t enum

This commit is contained in:
源文雨
2026-03-20 00:39:31 +08:00
parent 20cf04b2e9
commit a56666c826
4 changed files with 42 additions and 13 deletions

View File

@@ -81,19 +81,22 @@ func (s *symbol) replace(txt string) string {
return strings.ReplaceAll(txt, s.name, s.fields[0])
case symbolTypeFunc:
paras := strings.Split(s.fields[0], ",")
txts := []string{}
for {
args, a, b, err := s.extract1stFunc(txt)
if err == errNoSuchSymbol {
return txt
txts = append(txts, txt)
return strings.Join(txts, "")
}
if len(paras) != len(args) {
panic("args " + strings.Join(args, ", ") + " count " + strconv.Itoa(len(args)) + " is different from recorded " + s.fields[0])
}
txts := []string{txt[:a], "(", s.fields[1], txt[b:]}
n := len(txts)
txts = append(txts, []string{txt[:a], "/* ", txt[a:b], ") */(", s.fields[1]}...)
for i, p := range paras {
txts[2] = strings.ReplaceAll(txts[2], strings.TrimSpace(p), args[i])
txts[n+4] = strings.ReplaceAll(txts[n+4], strings.TrimSpace(p), args[i])
}
txt = strings.Join(txts, "")
txt = txt[b:]
}
}
panic("unsupported symbol type " + strconv.Itoa(int(s.stype)))