lua.type.tpl 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. -- this file is auto create by program, don't edit manually
  2. -- template document https://pkg.go.dev/text/template@go1.17.2
  3. -- enums
  4. {{- range .CustomEnums}}
  5. {{.Name}} = {
  6. {{- $maxNameLen := (CustomEnumNameMaxLen .)}}
  7. {{- $nameFmt := (printf "%%-%ds" $maxNameLen)}}
  8. {{- $maxValueLen := (CustomEnumValueMaxLen .)}}
  9. {{- $maxValueLen = (Add $maxValueLen 1)}}
  10. {{- $valueFmt := (printf "%%-%ds" $maxValueLen)}}
  11. {{- $m := (len .Values)}}{{$m = (Add $m -1)}}
  12. {{- range $index, $element := .Values}}
  13. {{ .Name | printf $nameFmt}} =
  14. {{- if lt $index $m}} {{printf "%d," .Value | printf $valueFmt}}
  15. {{- else}} {{printf "%d " .Value | printf $valueFmt}}{{end}} -- {{.Comment}}
  16. {{- end}}
  17. }
  18. {{end}}
  19. -- custom types
  20. ConfigType = {}
  21. {{- range .CustomTypes}}
  22. function ConfigType.{{.Name}}(
  23. {{- range $index, $element := .Fields}}{{if ge $index 1}},{{end}}{{.Name}}{{end}})
  24. local o = {
  25. {{- $maxNameLen := (CustomTypeNameMaxLen .)}}
  26. {{- $nameFmt := (printf "%%-%ds" $maxNameLen)}}
  27. {{- $maxNameLen = (Add $maxNameLen 1)}}
  28. {{- $nameFmt2 := (printf "%%-%ds" $maxNameLen)}}
  29. {{- $m := (len .Fields)}}{{$m = (Add $m -1)}}
  30. {{- range $index, $element := .Fields}}
  31. {{.Name | printf $nameFmt}} =
  32. {{- if lt $index $m}} {{printf "%s," .Name | printf $nameFmt2}}
  33. {{- else}} {{printf "%s " .Name | printf $nameFmt2}}{{end}}--{{.Comment}}
  34. {{- end}}
  35. }
  36. return o
  37. end
  38. {{end}}