Skip to content

Commit

Permalink
generator and schema version available through meta, new RPC code gen…
Browse files Browse the repository at this point in the history
…erated
  • Loading branch information
hrissan committed Sep 20, 2024
1 parent c24b0d5 commit 0a365c5
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 9 deletions.
7 changes: 6 additions & 1 deletion internal/tlcodegen/qt_meta.qtpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{%- import "fmt" -%}

{%- func (gen *Gen2) generateMeta() -%}
{%- func (gen *Gen2) generateMeta(tlgenVersion string) -%}
{%s= HeaderComment %}
{%- code typeWrappers := gen.generatedTypesList-%}
package {%s MetaGoPackageName %}
Expand All @@ -12,6 +12,11 @@ import (
"{%s= gen.options.TLPackageNameFull %}/internal"
)

func SchemaGenerator() string { return {%s= fmt.Sprintf("%#v", tlgenVersion) %} }
func SchemaURL() string { return {%s= fmt.Sprintf("%#v", gen.options.SchemaURL) %} }
func SchemaCommit() string { return {%s= fmt.Sprintf("%#v", gen.options.SchemaCommit) %} }
func SchemaTimestamp() uint32 { return {%v gen.options.SchemaTimestamp %} }

// We can create only types which have zero type arguments and zero nat arguments
type Object interface {
TLName() string // returns type's TL name. For union, returns constructor name depending on actual union value
Expand Down
23 changes: 18 additions & 5 deletions internal/tlcodegen/qt_meta.qtpl.go

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

6 changes: 5 additions & 1 deletion internal/tlcodegen/qt_namespace.qtpl
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,18 @@ func (c *Client) {%s= typeString %}(ctx context.Context, args {%s= typeString %}
{%- endif -%}
req.FunctionName = "{%s= tlName %}"
if extra != nil {
req.Extra = *extra
req.Extra = extra.RequestExtra
req.FailIfNoConnection = extra.FailIfNoConnection
}
rpc.UpdateExtraTimeout(&req.Extra, c.Timeout)
req.Body, err = args.WriteBoxedGeneral(req.Body)
if err != nil {
return internal.ErrorClientWrite("{%s= tlName %}", err)
}
resp, err := c.Client.Do(ctx, c.Network, c.Address, req)
if extra != nil && resp != nil {
extra.ResponseExtra = resp.Extra
}
defer c.Client.PutResponse(resp)
if err != nil {
return internal.ErrorClientDo("{%s= tlName %}", c.Network, c.ActorID, c.Address, err)
Expand Down
6 changes: 5 additions & 1 deletion internal/tlcodegen/qt_namespace.qtpl.go

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

5 changes: 5 additions & 0 deletions internal/tlcodegen/test/gen/cases/meta/meta.go

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

7 changes: 7 additions & 0 deletions internal/tlcodegen/test/gen/goldmaster/meta/meta.go

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

7 changes: 7 additions & 0 deletions internal/tlcodegen/test/gen/goldmaster_nosplit/meta/meta.go

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

2 changes: 1 addition & 1 deletion internal/tlcodegen/tlgen_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ var _ = basictl.NatWrite
if err := gen.addCodeFile(filepath.Join(FactoryGoPackageNameBytes, FactoryGoPackageNameBytes+goExt), gen.copyrightText+gen.generateFactoryBytes(sortedNames, directImports)); err != nil {
return err
}
if err := gen.addCodeFile(filepath.Join(MetaGoPackageName, MetaGoPackageName+goExt), gen.copyrightText+gen.generateMeta()); err != nil {
if err := gen.addCodeFile(filepath.Join(MetaGoPackageName, MetaGoPackageName+goExt), gen.copyrightText+gen.generateMeta(TLGenVersion())); err != nil {
return err
}
filepathName = filepath.Join("internal", "a_tlgen_helpers_code.go") // TODO decollision
Expand Down

0 comments on commit 0a365c5

Please sign in to comment.