收集需要构建的索引的类型
(g *Globals, stream *Stream, globalFile *model.FileDescriptor)
| 202 | |
| 203 | // 收集需要构建的索引的类型 |
| 204 | func 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 | // 收集需要构建的索引的类型 |
| 246 | func genLuaIndexCode(stream *Stream, combineStruct *model.Descriptor) bool { |
no test coverage detected