7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
59 lines
2.0 KiB
Cheetah
59 lines
2.0 KiB
Cheetah
{{- /*gotype: go.mau.fi/mautrix-telegram/pkg/gotd/gen.interfaceConfig*/ -}}
|
|
{{ define "interface" }}{{ $f := .Interface }}
|
|
|
|
// {{ $f.Name }}Name is schema name of {{ $f.Name }}.
|
|
const {{ $f.Name }}Name = "{{ $f.RawType }}"
|
|
|
|
// {{ $f.Name }} represents {{ $f.RawType }} generic type.
|
|
//
|
|
{{- if $f.URL }}
|
|
// See {{ $f.URL }} for reference.
|
|
//
|
|
{{- end }}
|
|
// Example:
|
|
// g, err := {{ $.Config.Package }}.Decode{{ $f.Func }}(buf)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// switch v := g.(type) {
|
|
{{ range $c := $f.Constructors -}}
|
|
// case *{{ $.Config.Package }}.{{ $c.Name }}: // {{ $c.RawType }}
|
|
{{ end -}}
|
|
// default: panic(v)
|
|
// }
|
|
type {{ $f.Name }} interface {
|
|
{{ template "class_interface_header" $f }}
|
|
|
|
{{ if $.Config.Flags.TDLibJSON }}
|
|
EncodeTDLibJSON(b tdjson.Encoder) error
|
|
DecodeTDLibJSON(b tdjson.Decoder) error
|
|
{{- end }}
|
|
|
|
{{ range $field := $f.SharedFields.Common -}}
|
|
{{- template "print_comment" $field.Comment }}
|
|
{{- if $field.Links }}
|
|
{{- template "print_links" $field.Links }}
|
|
{{- end }}
|
|
{{ if $.Config.Flags.GetSet }}{{ template "getter_func_type" $field -}}{{ end }}
|
|
|
|
{{- if and ($.Config.Flags.Mapping) (not $field.DoubleSlice) }}
|
|
{{- if not $field.Slice }}
|
|
{{- $mappings := index ($.Config.Mappings) ($field.Type) -}}
|
|
{{- range $mapping := $mappings -}}
|
|
{{- template "print_comment" $field.Comment }}
|
|
Get{{ $field.Name }}As{{ $mapping.MapperName }}() ({{ template "print_mapper_type" $mapping }}, bool)
|
|
{{- end }}
|
|
{{ else }}{{- if $field.Interface }}
|
|
{{- template "print_comment" $field.Comment }}
|
|
Map{{ $field.Name }}() (value {{ template "slice_field_name" $field }}{{ if $field.Conditional }}, ok bool{{ end }})
|
|
{{- end }}{{- end }}
|
|
|
|
{{- end }}
|
|
{{- end }}
|
|
{{ range $mapping := $f.Mappings -}}{{- if and ($.Config.Flags.Mapping) (not $mapping.Constructor) -}}
|
|
// As{{ $mapping.MapperName }} tries to map {{ $f.Name }} to {{ $mapping.Name }}.
|
|
{{ template "mapper_func_type" $mapping }}
|
|
{{ end }}{{ end }}
|
|
}
|
|
{{ end }}
|