Skip to content

Commit

Permalink
Merge pull request #605 from tdakkota/fix/tdlib-int64-encoding
Browse files Browse the repository at this point in the history
fix(gen): separate int53 and int64 encoding
  • Loading branch information
ernado authored Dec 6, 2021
2 parents cc606bf + 4b7d600 commit eb4dea3
Show file tree
Hide file tree
Showing 241 changed files with 1,850 additions and 1,787 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ issues:
text: G(307|304)

- linters: [ goconst ]
text: 'string `bool`'
text: 'string `(bool|int64)`'

- path: tgtest
linters: [ revive, golint ]
Expand Down
5 changes: 5 additions & 0 deletions bin/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ func (b *Buffer) Double() (float64, error) {
return math.Float64frombits(uint64(v)), nil
}

// Int53 decodes 53-bit signed integer from Buffer.
func (b *Buffer) Int53() (int64, error) {
return b.Long()
}

// Long decodes 64-bit signed integer from Buffer.
func (b *Buffer) Long() (int64, error) {
v, err := b.Uint64()
Expand Down
5 changes: 5 additions & 0 deletions bin/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ func (b *Buffer) PutUint32(v uint32) {
b.Buf = append(b.Buf, t...)
}

// PutInt53 serializes v as signed integer.
func (b *Buffer) PutInt53(v int64) {
b.PutLong(v)
}

// PutLong serializes v as signed integer.
func (b *Buffer) PutLong(v int64) {
b.PutUint64(uint64(v))
Expand Down
5 changes: 4 additions & 1 deletion internal/gen/make_field.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ func (g *Generator) makeField(param tl.Parameter, annotations []tl.Annotation) (
case "double":
f.Func = "Double"
f.Type = "float64"
case "long", "int53", "int64":
case "int53":
f.Func = "Int53"
f.Type = "int64"
case "long", "int64":
f.Func = "Long"
f.Type = "int64"
case "string":
Expand Down
16 changes: 8 additions & 8 deletions tdapi/tl_add_chat_member_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions tdapi/tl_add_chat_members_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tdapi/tl_add_chat_to_list_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions tdapi/tl_add_local_message_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tdapi/tl_add_recently_found_chat_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tdapi/tl_add_sticker_to_set_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions tdapi/tl_approve_chat_join_request_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit eb4dea3

Please sign in to comment.