(g *Globals)
| 29 | } |
| 30 | |
| 31 | func (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 | |
| 80 | func printTableLua(g *Globals, stream *Stream, tab *model.Table) bool { |
| 81 |
nothing calls this directly
no test coverage detected