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

Function genLuaEnumCode

v2/printer/lua.go:204–243  ·  view source on GitHub ↗

收集需要构建的索引的类型

(g *Globals, stream *Stream, globalFile *model.FileDescriptor)

Source from the content-addressed store, hash-verified

202
203// 收集需要构建的索引的类型
204func genLuaEnumCode(g *Globals, stream *Stream, globalFile *model.FileDescriptor) bool {
205
206 stream.Printf("\ntab.Enum = {\n")
207
208 // 遍历字段
209 for _, d := range globalFile.Descriptors {
210
211 if d.Kind != model.DescriptorKind_Enum {
212 continue
213 }
214
215 if anyFieldOutput(d) {
216 stream.Printf(" %s = {\n", d.Name)
217
218 for _, fd := range d.Fields {
219
220 if fd.Meta.GetBool("LuaValueMapperString") {
221 stream.Printf(" [%d] = \"%s\",\n", fd.EnumValue, fd.Name)
222 }
223
224 }
225
226 for _, fd := range d.Fields {
227
228 if fd.Meta.GetBool("LuaStringMapperValue") {
229 stream.Printf(" %s = %d,\n", fd.Name, fd.EnumValue)
230 }
231
232 }
233
234 stream.Printf(" },\n")
235 }
236
237 }
238
239 stream.Printf("}\n")
240
241 return true
242
243}
244
245// 收集需要构建的索引的类型
246func genLuaIndexCode(stream *Stream, combineStruct *model.Descriptor) bool {

Callers 1

RunMethod · 0.85

Calls 2

anyFieldOutputFunction · 0.85
PrintfMethod · 0.80

Tested by

no test coverage detected