diff --git a/internal/tlcodegen/qt_meta.qtpl b/internal/tlcodegen/qt_meta.qtpl index 1d6b8ac2..c5e5fdcb 100644 --- a/internal/tlcodegen/qt_meta.qtpl +++ b/internal/tlcodegen/qt_meta.qtpl @@ -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 %} @@ -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 diff --git a/internal/tlcodegen/qt_meta.qtpl.go b/internal/tlcodegen/qt_meta.qtpl.go index aa3b6025..65bce294 100644 --- a/internal/tlcodegen/qt_meta.qtpl.go +++ b/internal/tlcodegen/qt_meta.qtpl.go @@ -16,7 +16,7 @@ var ( _ = qt422016.AcquireByteBuffer ) -func (gen *Gen2) streamgenerateMeta(qw422016 *qt422016.Writer) { +func (gen *Gen2) streamgenerateMeta(qw422016 *qt422016.Writer, tlgenVersion string) { qw422016.N().S(HeaderComment) qw422016.N().S(` `) @@ -37,6 +37,19 @@ import ( qw422016.N().S(`/internal" ) +func SchemaGenerator() string { return `) + qw422016.N().S(fmt.Sprintf("%#v", tlgenVersion)) + qw422016.N().S(` } +func SchemaURL() string { return `) + qw422016.N().S(fmt.Sprintf("%#v", gen.options.SchemaURL)) + qw422016.N().S(` } +func SchemaCommit() string { return `) + qw422016.N().S(fmt.Sprintf("%#v", gen.options.SchemaCommit)) + qw422016.N().S(` } +func SchemaTimestamp() uint32 { return `) + qw422016.E().V(gen.options.SchemaTimestamp) + qw422016.N().S(` } + // 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 @@ -399,15 +412,15 @@ func init() { `) } -func (gen *Gen2) writegenerateMeta(qq422016 qtio422016.Writer) { +func (gen *Gen2) writegenerateMeta(qq422016 qtio422016.Writer, tlgenVersion string) { qw422016 := qt422016.AcquireWriter(qq422016) - gen.streamgenerateMeta(qw422016) + gen.streamgenerateMeta(qw422016, tlgenVersion) qt422016.ReleaseWriter(qw422016) } -func (gen *Gen2) generateMeta() string { +func (gen *Gen2) generateMeta(tlgenVersion string) string { qb422016 := qt422016.AcquireByteBuffer() - gen.writegenerateMeta(qb422016) + gen.writegenerateMeta(qb422016, tlgenVersion) qs422016 := string(qb422016.B) qt422016.ReleaseByteBuffer(qb422016) return qs422016 diff --git a/internal/tlcodegen/qt_namespace.qtpl b/internal/tlcodegen/qt_namespace.qtpl index 472ac02f..cf8cc28e 100644 --- a/internal/tlcodegen/qt_namespace.qtpl +++ b/internal/tlcodegen/qt_namespace.qtpl @@ -122,7 +122,8 @@ 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) @@ -130,6 +131,9 @@ func (c *Client) {%s= typeString %}(ctx context.Context, args {%s= typeString %} 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) diff --git a/internal/tlcodegen/qt_namespace.qtpl.go b/internal/tlcodegen/qt_namespace.qtpl.go index 32d1e839..c80102d7 100644 --- a/internal/tlcodegen/qt_namespace.qtpl.go +++ b/internal/tlcodegen/qt_namespace.qtpl.go @@ -243,7 +243,8 @@ func streamwriteClientCode(qw422016 *qt422016.Writer, bytesVersion bool, shortPa qw422016.N().S(tlName) qw422016.N().S(`" 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) @@ -253,6 +254,9 @@ func streamwriteClientCode(qw422016 *qt422016.Writer, bytesVersion bool, shortPa qw422016.N().S(`", 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("`) diff --git a/internal/tlcodegen/test/gen/cases/meta/meta.go b/internal/tlcodegen/test/gen/cases/meta/meta.go index c61eeed2..8276c719 100644 --- a/internal/tlcodegen/test/gen/cases/meta/meta.go +++ b/internal/tlcodegen/test/gen/cases/meta/meta.go @@ -14,6 +14,11 @@ import ( "github.com/vkcom/tl/pkg/basictl" ) +func SchemaGenerator() string { return "(devel)" } +func SchemaURL() string { return "" } +func SchemaCommit() string { return "" } +func SchemaTimestamp() uint32 { return 0 } + // 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 diff --git a/internal/tlcodegen/test/gen/goldmaster/meta/meta.go b/internal/tlcodegen/test/gen/goldmaster/meta/meta.go index 231d21e1..ff04033d 100644 --- a/internal/tlcodegen/test/gen/goldmaster/meta/meta.go +++ b/internal/tlcodegen/test/gen/goldmaster/meta/meta.go @@ -14,6 +14,13 @@ import ( "github.com/vkcom/tl/pkg/basictl" ) +func SchemaGenerator() string { return "(devel)" } +func SchemaURL() string { + return "https://github.com/VKCOM/tl/blob/master/internal/tlcodegen/test/tls/goldmaster.tl" +} +func SchemaCommit() string { return "abcdefgh" } +func SchemaTimestamp() uint32 { return 301822800 } + // 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 diff --git a/internal/tlcodegen/test/gen/goldmaster_nosplit/meta/meta.go b/internal/tlcodegen/test/gen/goldmaster_nosplit/meta/meta.go index 90f5954a..0fede745 100644 --- a/internal/tlcodegen/test/gen/goldmaster_nosplit/meta/meta.go +++ b/internal/tlcodegen/test/gen/goldmaster_nosplit/meta/meta.go @@ -14,6 +14,13 @@ import ( "github.com/vkcom/tl/pkg/basictl" ) +func SchemaGenerator() string { return "(devel)" } +func SchemaURL() string { + return "https://github.com/VKCOM/tl/blob/master/internal/tlcodegen/test/tls/goldmaster.tl" +} +func SchemaCommit() string { return "abcdefgh" } +func SchemaTimestamp() uint32 { return 301822800 } + // 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 diff --git a/internal/tlcodegen/tlgen_go.go b/internal/tlcodegen/tlgen_go.go index 61f1fc83..d1d9238c 100644 --- a/internal/tlcodegen/tlgen_go.go +++ b/internal/tlcodegen/tlgen_go.go @@ -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