MCPcopy
hub / github.com/davyxu/tabtoy / Run

Method Run

v2/printer/lua.go:31–78  ·  view source on GitHub ↗
(g *Globals)

Source from the content-addressed store, hash-verified

29}
30
31func (self *luaPrinter) Run(g *Globals) *Stream {
32
33 stream := NewStream()
34
35 stream.Printf("-- Generated by github.com/davyxu/tabtoy\n")
36 stream.Printf("-- Version: %s\n", g.Version)
37
38 if g.LuaTabHeader != "" {
39 stream.Printf("\n%s\n", g.LuaTabHeader)
40 }
41
42 stream.Printf("\nlocal tab = {\n")
43
44 for tabIndex, tab := range g.Tables {
45
46 if !tab.LocalFD.MatchTag(".lua") {
47 log.Infof("%s: %s", i18n.String(i18n.Printer_IgnoredByOutputTag), tab.Name())
48 continue
49 }
50
51 if !printTableLua(g, stream, tab) {
52 return nil
53 }
54
55 // 根字段分割
56 if tabIndex < len(g.Tables)-1 {
57 stream.Printf(", ")
58 }
59
60 stream.Printf("\n\n")
61 }
62
63 // local tab = {
64 stream.Printf("}\n\n")
65
66 if !genLuaIndexCode(stream, g.CombineStruct) {
67 return stream
68 }
69
70 // 生成枚举
71 if !genLuaEnumCode(g, stream, g.FileDescriptor) {
72 return stream
73 }
74
75 stream.Printf("\nreturn tab")
76
77 return stream
78}
79
80func printTableLua(g *Globals, stream *Stream, tab *model.Table) bool {
81

Callers

nothing calls this directly

Calls 8

PrintfMethod · 0.95
StringFunction · 0.92
NewStreamFunction · 0.85
printTableLuaFunction · 0.85
genLuaIndexCodeFunction · 0.85
genLuaEnumCodeFunction · 0.85
MatchTagMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected