diff --git a/Makefile b/Makefile index 6fc40d2f2..35f37bad8 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,16 @@ vdlgen: go run v.io/x/ref/cmd/vdl generate --errors-no-i18n=false --show-warnings=false --lang=go v.io/... go generate ./v23/vdl/vdltest +VDLROOT ?= $(shell pwd)/v23/vdlroot +export VDLROOT +vdlroot: + cd v23/vdlroot && \ + go run v.io/x/ref/cmd/vdl generate --errors-no-i18n=false --show-warnings=false --lang=go \ + ./vdltool \ + ./math \ + ./time \ + ./signature + .PHONY: test-integration test-integration: @echo "VDLPATH" "${VDLPATH}" diff --git a/go.mod b/go.mod index 887ccd737..ab0e69802 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.13 require ( github.com/DATA-DOG/go-sqlmock v1.3.3 github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect + github.com/cosnicolaou/go-bindata/v3 v3.0.8 // indirect github.com/go-ole/go-ole v1.2.4 // indirect github.com/go-sql-driver/mysql v1.4.1 github.com/golang/protobuf v1.3.2 @@ -18,9 +19,10 @@ require ( github.com/vanadium/go-mdns-sd v0.0.0-20181006014439-f1a1ccd1252e golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 golang.org/x/mod v0.3.0 - golang.org/x/net v0.0.0-20200822124328-c89045814202 + golang.org/x/net v0.0.0-20201021035429-f5854403a974 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 - golang.org/x/sync v0.0.0-20190423024810-112230192c58 + golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 + golang.org/x/tools v0.0.0-20201109182053-3db8fd265862 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/api v0.9.0 v.io/x/lib v0.1.6 diff --git a/go.sum b/go.sum index 403d86046..045c767d8 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cosnicolaou/go-bindata/v3 v3.0.8 h1:TFkRvB8gs11F8cTN+txbTQ27uH5/nKmANv9VWjMFFhw= +github.com/cosnicolaou/go-bindata/v3 v3.0.8/go.mod h1:0iCg7gGrUDn2i+XhRcis0RDdNsccqPBLJECyrlpJ21M= github.com/creack/pty v1.1.7 h1:6pwm8kMQKCmgUg0ZHTm5+/YvRK0s3THD/28+T6/kk4A= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= @@ -58,6 +60,7 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/vanadium/go-mdns-sd v0.0.0-20181006014439-f1a1ccd1252e h1:pHSeCN6iUoIWXqaMgi9TeKuESVQY1zThuhVjAHq3GpI= github.com/vanadium/go-mdns-sd v0.0.0-20181006014439-f1a1ccd1252e/go.mod h1:35fXDjvKtzyf89fHHhyTTNLHaG2CkI7u/GvO59PIjP4= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opencensus.io v0.21.0 h1:mU6zScU4U1YAFPHEHYk+3JC4SY7JxgkqS10ZOSyksNg= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -83,8 +86,8 @@ golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= @@ -95,18 +98,23 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b h1:ag/x1USPSsqHud38I9BAC88qdNLDHHtQ4mlgQIZPPNA= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d h1:nc5K6ox/4lTFbMVSL9WRR81ixkcwXThoiF6yf+R9scA= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -117,6 +125,8 @@ golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c h1:97SnQk1GYRXJgvwZ8fadnxD golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e h1:aZzprAO9/8oim3qStq3wc1Xuxx4QmAGriC4VU4ojemQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201109182053-3db8fd265862 h1:LeKnBqBqKuA2WEVPhyr22inXOMgckBKHfUvD0n5kyCg= +golang.org/x/tools v0.0.0-20201109182053-3db8fd265862/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/v23/security/internal/ecdsaonly/ecdsaonly.vdl.go b/v23/security/internal/ecdsaonly/ecdsaonly.vdl.go index f6ab9e411..4b6397539 100644 --- a/v23/security/internal/ecdsaonly/ecdsaonly.vdl.go +++ b/v23/security/internal/ecdsaonly/ecdsaonly.vdl.go @@ -1,3 +1,7 @@ +// Copyright 2020 The Vanadium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // This file was auto-generated by the vanadium vdl tool. // Package: ecdsaonly diff --git a/v23/security/internal/ecdsaonly/types.vdl b/v23/security/internal/ecdsaonly/types.vdl index 0e215ceb1..8c2768bfb 100644 --- a/v23/security/internal/ecdsaonly/types.vdl +++ b/v23/security/internal/ecdsaonly/types.vdl @@ -1,3 +1,7 @@ +// Copyright 2020 The Vanadium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package ecdsaonly type Hash string diff --git a/v23/vdl/errors_test.go b/v23/vdl/errors_test.go index 009be944f..d3ac26a29 100644 --- a/v23/vdl/errors_test.go +++ b/v23/vdl/errors_test.go @@ -1,3 +1,7 @@ +// Copyright 2020 The Vanadium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package vdl_test import ( diff --git a/v23/vdl/vdltest/vdltest.vdl.go b/v23/vdl/vdltest/vdltest.vdl.go index 184c0b529..c7c6b1ee7 100644 --- a/v23/vdl/vdltest/vdltest.vdl.go +++ b/v23/vdl/vdltest/vdltest.vdl.go @@ -14,6 +14,7 @@ import ( "reflect" "v.io/v23/context" + "v.io/v23/i18n" "v.io/v23/vdl" "v.io/v23/verror" ) @@ -93079,6 +93080,13 @@ var ( ErrThree = verror.NewIDAction("v.io/v23/vdl/vdltest.Three", verror.NoRetry) ) +// NewErrNone returns an error with the ErrNone ID. +// Deprecated: this function will be removed in the future, +// use ErrorfNone or MessageNone instead. +func NewErrNone(ctx *context.T) error { + return verror.New(ErrNone, ctx) +} + // ErrorfNone calls ErrNone.Errorf with the supplied arguments. func ErrorfNone(ctx *context.T, format string) error { return ErrNone.Errorf(ctx, format) @@ -93105,6 +93113,13 @@ func ParamsErrNone(argumentError error) (verrorComponent string, verrorOperation return } +// NewErrOne returns an error with the ErrOne ID. +// Deprecated: this function will be removed in the future, +// use ErrorfOne or MessageOne instead. +func NewErrOne(ctx *context.T, i int64) error { + return verror.New(ErrOne, ctx, i) +} + // ErrorfOne calls ErrOne.Errorf with the supplied arguments. func ErrorfOne(ctx *context.T, format string, i int64) error { return ErrOne.Errorf(ctx, format, i) @@ -93144,6 +93159,13 @@ func ParamsErrOne(argumentError error) (verrorComponent string, verrorOperation return } +// NewErrTwo returns an error with the ErrTwo ID. +// Deprecated: this function will be removed in the future, +// use ErrorfTwo or MessageTwo instead. +func NewErrTwo(ctx *context.T, a string, err error) error { + return verror.New(ErrTwo, ctx, a, err) +} + // ErrorfTwo calls ErrTwo.Errorf with the supplied arguments. func ErrorfTwo(ctx *context.T, format string, a string, err error) error { return ErrTwo.Errorf(ctx, format, a, err) @@ -93191,6 +93213,13 @@ func ParamsErrTwo(argumentError error) (verrorComponent string, verrorOperation return } +// NewErrThree returns an error with the ErrThree ID. +// Deprecated: this function will be removed in the future, +// use ErrorfThree or MessageThree instead. +func NewErrThree(ctx *context.T, a string, b int64, c float32) error { + return verror.New(ErrThree, ctx, a, b, c) +} + // ErrorfThree calls ErrThree.Errorf with the supplied arguments. func ErrorfThree(ctx *context.T, format string, a string, b int64, c float32) error { return ErrThree.Errorf(ctx, format, a, b, c) @@ -94398,5 +94427,11 @@ func initializeVDL() struct{} { vdlTypeUnion283 = vdl.TypeOf((*VWireUnionNIface)(nil)) vdlTypeStruct284 = vdl.TypeOf((*VWireAll)(nil)).Elem() + // Set error format strings. + i18n.Cat().SetWithBase(i18n.LangID("en"), i18n.MsgID(ErrNone.ID), "{1:}{2:} dummy") + i18n.Cat().SetWithBase(i18n.LangID("en"), i18n.MsgID(ErrOne.ID), "{1:}{2:} dummy") + i18n.Cat().SetWithBase(i18n.LangID("en"), i18n.MsgID(ErrTwo.ID), "{1:}{2:} dummy") + i18n.Cat().SetWithBase(i18n.LangID("en"), i18n.MsgID(ErrThree.ID), "{1:}{2:} dummy") + return struct{}{} } diff --git a/v23/vdlroot/vdltool/config.vdl b/v23/vdlroot/vdltool/config.vdl index 7aedf8072..646de0ab4 100644 --- a/v23/vdlroot/vdltool/config.vdl +++ b/v23/vdlroot/vdltool/config.vdl @@ -54,6 +54,17 @@ type GoConfig struct { // func fooToNative(x Foo, n *Native) error // func fooFromNative(x *Foo, n Native) error WireToNativeTypes map[string]GoType + + // StructTags specifies any go struct tags to be include with the generated + // go code. The StructTags map is keyed by the struct type's name. + StructTags map[string][]GoStructTag +} + +// GoStructTag specifies a single go struct tag and the field to which it +// should be applied. +type GoStructTag struct { + Field string + Tag string } // GoType describes the Go type information associated with a VDL type. diff --git a/v23/vdlroot/vdltool/config_test.go b/v23/vdlroot/vdltool/config_test.go index bde27a8e5..5833895fd 100644 --- a/v23/vdlroot/vdltool/config_test.go +++ b/v23/vdlroot/vdltool/config_test.go @@ -39,6 +39,11 @@ func TestLoadingVdlConfig(t *testing.T) { }, }, }, + StructTags: map[string][]GoStructTag{ + "StructTypeName": { + {Field: "NameOfField", Tag: `json:"name,omitempty" other:"name,,'quoted'"`}, + }, + }, }, Java: JavaConfig{ WireTypeRenames: map[string]string{ diff --git a/v23/vdlroot/vdltool/vdltool.vdl.go b/v23/vdlroot/vdltool/vdltool.vdl.go index 4cc71c22d..164c046d5 100644 --- a/v23/vdlroot/vdltool/vdltool.vdl.go +++ b/v23/vdlroot/vdltool/vdltool.vdl.go @@ -685,6 +685,84 @@ func vdlReadAnonList1(dec vdl.Decoder, x *[]GoImport) error { } } +// GoStructTag specifies a single go struct tag and the field to which it +// should be applied. +type GoStructTag struct { + Field string + Tag string +} + +func (GoStructTag) VDLReflect(struct { + Name string `vdl:"vdltool.GoStructTag"` +}) { +} + +func (x GoStructTag) VDLIsZero() bool { //nolint:gocyclo + return x == GoStructTag{} +} + +func (x GoStructTag) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo + if err := enc.StartValue(vdlTypeStruct8); err != nil { + return err + } + if x.Field != "" { + if err := enc.NextFieldValueString(0, vdl.StringType, x.Field); err != nil { + return err + } + } + if x.Tag != "" { + if err := enc.NextFieldValueString(1, vdl.StringType, x.Tag); err != nil { + return err + } + } + if err := enc.NextField(-1); err != nil { + return err + } + return enc.FinishValue() +} + +func (x *GoStructTag) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo + *x = GoStructTag{} + if err := dec.StartValue(vdlTypeStruct8); err != nil { + return err + } + decType := dec.Type() + for { + index, err := dec.NextField() + switch { + case err != nil: + return err + case index == -1: + return dec.FinishValue() + } + if decType != vdlTypeStruct8 { + index = vdlTypeStruct8.FieldIndexByName(decType.Field(index).Name) + if index == -1 { + if err := dec.SkipValue(); err != nil { + return err + } + continue + } + } + switch index { + case 0: + switch value, err := dec.ReadValueString(); { + case err != nil: + return err + default: + x.Field = value + } + case 1: + switch value, err := dec.ReadValueString(); { + case err != nil: + return err + default: + x.Tag = value + } + } + } +} + // GoConfig specifies go specific configuration. type GoConfig struct { // WireToNativeTypes specifies the mapping from a VDL wire type to its Go @@ -709,6 +787,9 @@ type GoConfig struct { // func fooToNative(x Foo, n *Native) error // func fooFromNative(x *Foo, n Native) error WireToNativeTypes map[string]GoType + // StructTags specifies any go struct tags to be include with the generated + // go code. The StructTags map is keyed by the struct type's name. + StructTags map[string][]GoStructTag } func (GoConfig) VDLReflect(struct { @@ -717,11 +798,17 @@ func (GoConfig) VDLReflect(struct { } func (x GoConfig) VDLIsZero() bool { //nolint:gocyclo - return len(x.WireToNativeTypes) == 0 + if len(x.WireToNativeTypes) != 0 { + return false + } + if len(x.StructTags) != 0 { + return false + } + return true } func (x GoConfig) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo - if err := enc.StartValue(vdlTypeStruct8); err != nil { + if err := enc.StartValue(vdlTypeStruct9); err != nil { return err } if len(x.WireToNativeTypes) != 0 { @@ -732,6 +819,14 @@ func (x GoConfig) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo return err } } + if len(x.StructTags) != 0 { + if err := enc.NextField(1); err != nil { + return err + } + if err := vdlWriteAnonMap3(enc, x.StructTags); err != nil { + return err + } + } if err := enc.NextField(-1); err != nil { return err } @@ -739,7 +834,7 @@ func (x GoConfig) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo } func vdlWriteAnonMap2(enc vdl.Encoder, x map[string]GoType) error { - if err := enc.StartValue(vdlTypeMap9); err != nil { + if err := enc.StartValue(vdlTypeMap10); err != nil { return err } if err := enc.SetLenHint(len(x)); err != nil { @@ -759,9 +854,51 @@ func vdlWriteAnonMap2(enc vdl.Encoder, x map[string]GoType) error { return enc.FinishValue() } +func vdlWriteAnonMap3(enc vdl.Encoder, x map[string][]GoStructTag) error { + if err := enc.StartValue(vdlTypeMap11); err != nil { + return err + } + if err := enc.SetLenHint(len(x)); err != nil { + return err + } + for key, elem := range x { + if err := enc.NextEntryValueString(vdl.StringType, key); err != nil { + return err + } + if err := vdlWriteAnonList4(enc, elem); err != nil { + return err + } + } + if err := enc.NextEntry(true); err != nil { + return err + } + return enc.FinishValue() +} + +func vdlWriteAnonList4(enc vdl.Encoder, x []GoStructTag) error { + if err := enc.StartValue(vdlTypeList12); err != nil { + return err + } + if err := enc.SetLenHint(len(x)); err != nil { + return err + } + for _, elem := range x { + if err := enc.NextEntry(false); err != nil { + return err + } + if err := elem.VDLWrite(enc); err != nil { + return err + } + } + if err := enc.NextEntry(true); err != nil { + return err + } + return enc.FinishValue() +} + func (x *GoConfig) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo *x = GoConfig{} - if err := dec.StartValue(vdlTypeStruct8); err != nil { + if err := dec.StartValue(vdlTypeStruct9); err != nil { return err } decType := dec.Type() @@ -773,8 +910,8 @@ func (x *GoConfig) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo case index == -1: return dec.FinishValue() } - if decType != vdlTypeStruct8 { - index = vdlTypeStruct8.FieldIndexByName(decType.Field(index).Name) + if decType != vdlTypeStruct9 { + index = vdlTypeStruct9.FieldIndexByName(decType.Field(index).Name) if index == -1 { if err := dec.SkipValue(); err != nil { return err @@ -782,17 +919,21 @@ func (x *GoConfig) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo continue } } - if index == 0 { - + switch index { + case 0: if err := vdlReadAnonMap2(dec, &x.WireToNativeTypes); err != nil { return err } + case 1: + if err := vdlReadAnonMap3(dec, &x.StructTags); err != nil { + return err + } } } } func vdlReadAnonMap2(dec vdl.Decoder, x *map[string]GoType) error { - if err := dec.StartValue(vdlTypeMap9); err != nil { + if err := dec.StartValue(vdlTypeMap10); err != nil { return err } var tmpMap map[string]GoType @@ -819,6 +960,59 @@ func vdlReadAnonMap2(dec vdl.Decoder, x *map[string]GoType) error { } } +func vdlReadAnonMap3(dec vdl.Decoder, x *map[string][]GoStructTag) error { + if err := dec.StartValue(vdlTypeMap11); err != nil { + return err + } + var tmpMap map[string][]GoStructTag + if len := dec.LenHint(); len > 0 { + tmpMap = make(map[string][]GoStructTag, len) + } + for { + switch done, key, err := dec.NextEntryValueString(); { + case err != nil: + return err + case done: + *x = tmpMap + return dec.FinishValue() + default: + var elem []GoStructTag + if err := vdlReadAnonList4(dec, &elem); err != nil { + return err + } + if tmpMap == nil { + tmpMap = make(map[string][]GoStructTag) + } + tmpMap[key] = elem + } + } +} + +func vdlReadAnonList4(dec vdl.Decoder, x *[]GoStructTag) error { + if err := dec.StartValue(vdlTypeList12); err != nil { + return err + } + if len := dec.LenHint(); len > 0 { + *x = make([]GoStructTag, 0, len) + } else { + *x = nil + } + for { + switch done, err := dec.NextEntry(); { + case err != nil: + return err + case done: + return dec.FinishValue() + default: + var elem GoStructTag + if err := elem.VDLRead(dec); err != nil { + return err + } + *x = append(*x, elem) + } + } +} + // JavaConfig specifies java specific configuration. type JavaConfig struct { // WireToNativeTypes specifies the mapping from a VDL wire type to its Java @@ -871,14 +1065,14 @@ func (x JavaConfig) VDLIsZero() bool { //nolint:gocyclo } func (x JavaConfig) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo - if err := enc.StartValue(vdlTypeStruct10); err != nil { + if err := enc.StartValue(vdlTypeStruct13); err != nil { return err } if len(x.WireToNativeTypes) != 0 { if err := enc.NextField(0); err != nil { return err } - if err := vdlWriteAnonMap3(enc, x.WireToNativeTypes); err != nil { + if err := vdlWriteAnonMap5(enc, x.WireToNativeTypes); err != nil { return err } } @@ -886,7 +1080,7 @@ func (x JavaConfig) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo if err := enc.NextField(1); err != nil { return err } - if err := vdlWriteAnonMap3(enc, x.WireTypeRenames); err != nil { + if err := vdlWriteAnonMap5(enc, x.WireTypeRenames); err != nil { return err } } @@ -896,8 +1090,8 @@ func (x JavaConfig) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo return enc.FinishValue() } -func vdlWriteAnonMap3(enc vdl.Encoder, x map[string]string) error { - if err := enc.StartValue(vdlTypeMap11); err != nil { +func vdlWriteAnonMap5(enc vdl.Encoder, x map[string]string) error { + if err := enc.StartValue(vdlTypeMap14); err != nil { return err } if err := enc.SetLenHint(len(x)); err != nil { @@ -919,7 +1113,7 @@ func vdlWriteAnonMap3(enc vdl.Encoder, x map[string]string) error { func (x *JavaConfig) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo *x = JavaConfig{} - if err := dec.StartValue(vdlTypeStruct10); err != nil { + if err := dec.StartValue(vdlTypeStruct13); err != nil { return err } decType := dec.Type() @@ -931,8 +1125,8 @@ func (x *JavaConfig) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo case index == -1: return dec.FinishValue() } - if decType != vdlTypeStruct10 { - index = vdlTypeStruct10.FieldIndexByName(decType.Field(index).Name) + if decType != vdlTypeStruct13 { + index = vdlTypeStruct13.FieldIndexByName(decType.Field(index).Name) if index == -1 { if err := dec.SkipValue(); err != nil { return err @@ -942,19 +1136,19 @@ func (x *JavaConfig) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo } switch index { case 0: - if err := vdlReadAnonMap3(dec, &x.WireToNativeTypes); err != nil { + if err := vdlReadAnonMap5(dec, &x.WireToNativeTypes); err != nil { return err } case 1: - if err := vdlReadAnonMap3(dec, &x.WireTypeRenames); err != nil { + if err := vdlReadAnonMap5(dec, &x.WireTypeRenames); err != nil { return err } } } } -func vdlReadAnonMap3(dec vdl.Decoder, x *map[string]string) error { - if err := dec.StartValue(vdlTypeMap11); err != nil { +func vdlReadAnonMap5(dec vdl.Decoder, x *map[string]string) error { + if err := dec.StartValue(vdlTypeMap14); err != nil { return err } var tmpMap map[string]string @@ -998,7 +1192,7 @@ func (x JavascriptConfig) VDLIsZero() bool { //nolint:gocyclo } func (x JavascriptConfig) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo - if err := enc.StartValue(vdlTypeStruct12); err != nil { + if err := enc.StartValue(vdlTypeStruct15); err != nil { return err } if err := enc.NextField(-1); err != nil { @@ -1009,7 +1203,7 @@ func (x JavascriptConfig) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo func (x *JavascriptConfig) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo *x = JavascriptConfig{} - if err := dec.StartValue(vdlTypeStruct12); err != nil { + if err := dec.StartValue(vdlTypeStruct15); err != nil { return err } decType := dec.Type() @@ -1021,8 +1215,8 @@ func (x *JavascriptConfig) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo case index == -1: return dec.FinishValue() } - if decType != vdlTypeStruct12 { - index = vdlTypeStruct12.FieldIndexByName(decType.Field(index).Name) + if decType != vdlTypeStruct15 { + index = vdlTypeStruct15.FieldIndexByName(decType.Field(index).Name) if index == -1 { if err := dec.SkipValue(); err != nil { return err @@ -1086,14 +1280,14 @@ func (x SwiftConfig) VDLIsZero() bool { //nolint:gocyclo } func (x SwiftConfig) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo - if err := enc.StartValue(vdlTypeStruct13); err != nil { + if err := enc.StartValue(vdlTypeStruct16); err != nil { return err } if len(x.WireToNativeTypes) != 0 { if err := enc.NextField(0); err != nil { return err } - if err := vdlWriteAnonMap3(enc, x.WireToNativeTypes); err != nil { + if err := vdlWriteAnonMap5(enc, x.WireToNativeTypes); err != nil { return err } } @@ -1105,7 +1299,7 @@ func (x SwiftConfig) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo func (x *SwiftConfig) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo *x = SwiftConfig{} - if err := dec.StartValue(vdlTypeStruct13); err != nil { + if err := dec.StartValue(vdlTypeStruct16); err != nil { return err } decType := dec.Type() @@ -1117,8 +1311,8 @@ func (x *SwiftConfig) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo case index == -1: return dec.FinishValue() } - if decType != vdlTypeStruct13 { - index = vdlTypeStruct13.FieldIndexByName(decType.Field(index).Name) + if decType != vdlTypeStruct16 { + index = vdlTypeStruct16.FieldIndexByName(decType.Field(index).Name) if index == -1 { if err := dec.SkipValue(); err != nil { return err @@ -1128,7 +1322,7 @@ func (x *SwiftConfig) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo } if index == 0 { - if err := vdlReadAnonMap3(dec, &x.WireToNativeTypes); err != nil { + if err := vdlReadAnonMap5(dec, &x.WireToNativeTypes); err != nil { return err } } @@ -1175,14 +1369,14 @@ func (x Config) VDLIsZero() bool { //nolint:gocyclo } func (x Config) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo - if err := enc.StartValue(vdlTypeStruct14); err != nil { + if err := enc.StartValue(vdlTypeStruct17); err != nil { return err } if len(x.GenLanguages) != 0 { if err := enc.NextField(0); err != nil { return err } - if err := vdlWriteAnonSet4(enc, x.GenLanguages); err != nil { + if err := vdlWriteAnonSet6(enc, x.GenLanguages); err != nil { return err } } @@ -1224,8 +1418,8 @@ func (x Config) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo return enc.FinishValue() } -func vdlWriteAnonSet4(enc vdl.Encoder, x map[GenLanguage]struct{}) error { - if err := enc.StartValue(vdlTypeSet15); err != nil { +func vdlWriteAnonSet6(enc vdl.Encoder, x map[GenLanguage]struct{}) error { + if err := enc.StartValue(vdlTypeSet18); err != nil { return err } if err := enc.SetLenHint(len(x)); err != nil { @@ -1244,7 +1438,7 @@ func vdlWriteAnonSet4(enc vdl.Encoder, x map[GenLanguage]struct{}) error { func (x *Config) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo *x = Config{} - if err := dec.StartValue(vdlTypeStruct14); err != nil { + if err := dec.StartValue(vdlTypeStruct17); err != nil { return err } decType := dec.Type() @@ -1256,8 +1450,8 @@ func (x *Config) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo case index == -1: return dec.FinishValue() } - if decType != vdlTypeStruct14 { - index = vdlTypeStruct14.FieldIndexByName(decType.Field(index).Name) + if decType != vdlTypeStruct17 { + index = vdlTypeStruct17.FieldIndexByName(decType.Field(index).Name) if index == -1 { if err := dec.SkipValue(); err != nil { return err @@ -1267,7 +1461,7 @@ func (x *Config) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo } switch index { case 0: - if err := vdlReadAnonSet4(dec, &x.GenLanguages); err != nil { + if err := vdlReadAnonSet6(dec, &x.GenLanguages); err != nil { return err } case 1: @@ -1290,8 +1484,8 @@ func (x *Config) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo } } -func vdlReadAnonSet4(dec vdl.Decoder, x *map[GenLanguage]struct{}) error { - if err := dec.StartValue(vdlTypeSet15); err != nil { +func vdlReadAnonSet6(dec vdl.Decoder, x *map[GenLanguage]struct{}) error { + if err := dec.StartValue(vdlTypeSet18); err != nil { return err } var tmpMap map[GenLanguage]struct{} @@ -1329,13 +1523,16 @@ var ( vdlTypeStruct6 *vdl.Type vdlTypeList7 *vdl.Type vdlTypeStruct8 *vdl.Type - vdlTypeMap9 *vdl.Type - vdlTypeStruct10 *vdl.Type + vdlTypeStruct9 *vdl.Type + vdlTypeMap10 *vdl.Type vdlTypeMap11 *vdl.Type - vdlTypeStruct12 *vdl.Type + vdlTypeList12 *vdl.Type vdlTypeStruct13 *vdl.Type - vdlTypeStruct14 *vdl.Type - vdlTypeSet15 *vdl.Type + vdlTypeMap14 *vdl.Type + vdlTypeStruct15 *vdl.Type + vdlTypeStruct16 *vdl.Type + vdlTypeStruct17 *vdl.Type + vdlTypeSet18 *vdl.Type ) var initializeVDLCalled bool @@ -1366,6 +1563,7 @@ func initializeVDL() struct{} { vdl.Register((*GoZero)(nil)) vdl.Register((*GoImport)(nil)) vdl.Register((*GoType)(nil)) + vdl.Register((*GoStructTag)(nil)) vdl.Register((*GoConfig)(nil)) vdl.Register((*JavaConfig)(nil)) vdl.Register((*JavascriptConfig)(nil)) @@ -1380,14 +1578,17 @@ func initializeVDL() struct{} { vdlTypeStruct5 = vdl.TypeOf((*GoImport)(nil)).Elem() vdlTypeStruct6 = vdl.TypeOf((*GoType)(nil)).Elem() vdlTypeList7 = vdl.TypeOf((*[]GoImport)(nil)) - vdlTypeStruct8 = vdl.TypeOf((*GoConfig)(nil)).Elem() - vdlTypeMap9 = vdl.TypeOf((*map[string]GoType)(nil)) - vdlTypeStruct10 = vdl.TypeOf((*JavaConfig)(nil)).Elem() - vdlTypeMap11 = vdl.TypeOf((*map[string]string)(nil)) - vdlTypeStruct12 = vdl.TypeOf((*JavascriptConfig)(nil)).Elem() - vdlTypeStruct13 = vdl.TypeOf((*SwiftConfig)(nil)).Elem() - vdlTypeStruct14 = vdl.TypeOf((*Config)(nil)).Elem() - vdlTypeSet15 = vdl.TypeOf((*map[GenLanguage]struct{})(nil)) + vdlTypeStruct8 = vdl.TypeOf((*GoStructTag)(nil)).Elem() + vdlTypeStruct9 = vdl.TypeOf((*GoConfig)(nil)).Elem() + vdlTypeMap10 = vdl.TypeOf((*map[string]GoType)(nil)) + vdlTypeMap11 = vdl.TypeOf((*map[string][]GoStructTag)(nil)) + vdlTypeList12 = vdl.TypeOf((*[]GoStructTag)(nil)) + vdlTypeStruct13 = vdl.TypeOf((*JavaConfig)(nil)).Elem() + vdlTypeMap14 = vdl.TypeOf((*map[string]string)(nil)) + vdlTypeStruct15 = vdl.TypeOf((*JavascriptConfig)(nil)).Elem() + vdlTypeStruct16 = vdl.TypeOf((*SwiftConfig)(nil)).Elem() + vdlTypeStruct17 = vdl.TypeOf((*Config)(nil)).Elem() + vdlTypeSet18 = vdl.TypeOf((*map[GenLanguage]struct{})(nil)) return struct{}{} } diff --git a/v23/verror/pkgpath_test.go b/v23/verror/pkgpath_test.go index 3c571685a..51b37a3fa 100644 --- a/v23/verror/pkgpath_test.go +++ b/v23/verror/pkgpath_test.go @@ -1,3 +1,7 @@ +// Copyright 2020 The Vanadium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package verror import ( diff --git a/v23/verror/verror_id_test.go b/v23/verror/verror_id_test.go index 3e0f94f31..707b55230 100644 --- a/v23/verror/verror_id_test.go +++ b/v23/verror/verror_id_test.go @@ -1,3 +1,7 @@ +// Copyright 2020 The Vanadium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package verror_test import ( diff --git a/x/ref/cmd/vdl/doc.go b/x/ref/cmd/vdl/doc.go index dfabbb290..8cfc33646 100644 --- a/x/ref/cmd/vdl/doc.go +++ b/x/ref/cmd/vdl/doc.go @@ -77,6 +77,8 @@ Usage: For more information, run "vdl help packages". The vdl generate flags are: + -errors-no-i18n=false + No longer support i18n formats for errors -go-out-dir= Go output directory. There are three modes: "" : Generate output in-place in the source tree @@ -118,6 +120,8 @@ The vdl generate flags are: -lang=Go Comma-separated list of languages to generate, currently supporting Go,Java,Javascript,Swift + -show-warnings=true + show warning messages -status=true Show package names as they are updated -swift-out-dir=release/go/src->release/swift/lib/generated-src/vdl,roadmap/go/src->release/swift/lib/generated-src/vdl @@ -153,6 +157,10 @@ Usage: For more information, run "vdl help packages". The vdl compile flags are: + -errors-no-i18n=false + No longer support i18n formats for errors + -show-warnings=true + show warning messages -status=true Show package names while we compile @@ -178,6 +186,8 @@ Usage: For more information, run "vdl help packages". The vdl audit flags are: + -errors-no-i18n=false + No longer support i18n formats for errors -go-out-dir= Go output directory. There are three modes: "" : Generate output in-place in the source tree @@ -219,6 +229,8 @@ The vdl audit flags are: -lang=Go Comma-separated list of languages to generate, currently supporting Go,Java,Javascript,Swift + -show-warnings=true + show warning messages -status=true Show package names as they are updated -swift-out-dir=release/go/src->release/swift/lib/generated-src/vdl,roadmap/go/src->release/swift/lib/generated-src/vdl diff --git a/x/ref/cmd/vdl/gotagtest/gotagtest.vdl.go b/x/ref/cmd/vdl/gotagtest/gotagtest.vdl.go new file mode 100644 index 000000000..e2b59df8f --- /dev/null +++ b/x/ref/cmd/vdl/gotagtest/gotagtest.vdl.go @@ -0,0 +1,205 @@ +// This file was auto-generated by the vanadium vdl tool. +// Package: gotagtest + +//nolint:golint +package gotagtest + +import ( + "v.io/v23/vdl" +) + +var _ = initializeVDL() // Must be first; see initializeVDL comments for details. + +// Type definitions +// ================ + +type TestStructA struct { + A string `json:"ja,omitempty"` + B int64 +} + +func (TestStructA) VDLReflect(struct { + Name string `vdl:"v.io/x/ref/cmd/vdl/gotagtest.TestStructA"` +}) { +} + +func (x TestStructA) VDLIsZero() bool { //nolint:gocyclo + return x == TestStructA{} +} + +func (x TestStructA) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo + if err := enc.StartValue(vdlTypeStruct1); err != nil { + return err + } + if x.A != "" { + if err := enc.NextFieldValueString(0, vdl.StringType, x.A); err != nil { + return err + } + } + if x.B != 0 { + if err := enc.NextFieldValueInt(1, vdl.Int64Type, x.B); err != nil { + return err + } + } + if err := enc.NextField(-1); err != nil { + return err + } + return enc.FinishValue() +} + +func (x *TestStructA) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo + *x = TestStructA{} + if err := dec.StartValue(vdlTypeStruct1); err != nil { + return err + } + decType := dec.Type() + for { + index, err := dec.NextField() + switch { + case err != nil: + return err + case index == -1: + return dec.FinishValue() + } + if decType != vdlTypeStruct1 { + index = vdlTypeStruct1.FieldIndexByName(decType.Field(index).Name) + if index == -1 { + if err := dec.SkipValue(); err != nil { + return err + } + continue + } + } + switch index { + case 0: + switch value, err := dec.ReadValueString(); { + case err != nil: + return err + default: + x.A = value + } + case 1: + switch value, err := dec.ReadValueInt(64); { + case err != nil: + return err + default: + x.B = value + } + } + } +} + +type TestStructB struct { + A int64 + B string `json:"jb,omitempty"` +} + +func (TestStructB) VDLReflect(struct { + Name string `vdl:"v.io/x/ref/cmd/vdl/gotagtest.TestStructB"` +}) { +} + +func (x TestStructB) VDLIsZero() bool { //nolint:gocyclo + return x == TestStructB{} +} + +func (x TestStructB) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo + if err := enc.StartValue(vdlTypeStruct2); err != nil { + return err + } + if x.A != 0 { + if err := enc.NextFieldValueInt(0, vdl.Int64Type, x.A); err != nil { + return err + } + } + if x.B != "" { + if err := enc.NextFieldValueString(1, vdl.StringType, x.B); err != nil { + return err + } + } + if err := enc.NextField(-1); err != nil { + return err + } + return enc.FinishValue() +} + +func (x *TestStructB) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo + *x = TestStructB{} + if err := dec.StartValue(vdlTypeStruct2); err != nil { + return err + } + decType := dec.Type() + for { + index, err := dec.NextField() + switch { + case err != nil: + return err + case index == -1: + return dec.FinishValue() + } + if decType != vdlTypeStruct2 { + index = vdlTypeStruct2.FieldIndexByName(decType.Field(index).Name) + if index == -1 { + if err := dec.SkipValue(); err != nil { + return err + } + continue + } + } + switch index { + case 0: + switch value, err := dec.ReadValueInt(64); { + case err != nil: + return err + default: + x.A = value + } + case 1: + switch value, err := dec.ReadValueString(); { + case err != nil: + return err + default: + x.B = value + } + } + } +} + +// Hold type definitions in package-level variables, for better performance. +//nolint:unused +var ( + vdlTypeStruct1 *vdl.Type + vdlTypeStruct2 *vdl.Type +) + +var initializeVDLCalled bool + +// initializeVDL performs vdl initialization. It is safe to call multiple times. +// If you have an init ordering issue, just insert the following line verbatim +// into your source files in this package, right after the "package foo" clause: +// +// var _ = initializeVDL() +// +// The purpose of this function is to ensure that vdl initialization occurs in +// the right order, and very early in the init sequence. In particular, vdl +// registration and package variable initialization needs to occur before +// functions like vdl.TypeOf will work properly. +// +// This function returns a dummy value, so that it can be used to initialize the +// first var in the file, to take advantage of Go's defined init order. +func initializeVDL() struct{} { + if initializeVDLCalled { + return struct{}{} + } + initializeVDLCalled = true + + // Register types. + vdl.Register((*TestStructA)(nil)) + vdl.Register((*TestStructB)(nil)) + + // Initialize type definitions. + vdlTypeStruct1 = vdl.TypeOf((*TestStructA)(nil)).Elem() + vdlTypeStruct2 = vdl.TypeOf((*TestStructB)(nil)).Elem() + + return struct{}{} +} diff --git a/x/ref/cmd/vdl/gotagtest/tag_test.go b/x/ref/cmd/vdl/gotagtest/tag_test.go new file mode 100644 index 000000000..28dc72649 --- /dev/null +++ b/x/ref/cmd/vdl/gotagtest/tag_test.go @@ -0,0 +1,27 @@ +// Copyright 2020 The Vanadium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gotagtest_test + +import ( + "bytes" + "encoding/json" + "testing" + + "v.io/x/ref/cmd/vdl/gotagtest" +) + +func TestTags(t *testing.T) { + buf := &bytes.Buffer{} + enc := json.NewEncoder(buf) + enc.Encode(gotagtest.TestStructA{"val", 64}) + if got, want := buf.String(), `{"ja":"val","B":64}`+"\n"; got != want { + t.Errorf("got %v, want %v", got, want) + } + buf.Reset() + enc.Encode(gotagtest.TestStructB{64, ""}) + if got, want := buf.String(), `{"A":64}`+"\n"; got != want { + t.Errorf("got %v, want %v", got, want) + } +} diff --git a/x/ref/cmd/vdl/gotagtest/types.vdl b/x/ref/cmd/vdl/gotagtest/types.vdl new file mode 100644 index 000000000..6102985b2 --- /dev/null +++ b/x/ref/cmd/vdl/gotagtest/types.vdl @@ -0,0 +1,11 @@ +package gotagtest + +type TestStructA struct { + A string + B int64 +} + +type TestStructB struct { + A int64 + B string +} diff --git a/x/ref/cmd/vdl/gotagtest/vdl.config b/x/ref/cmd/vdl/gotagtest/vdl.config new file mode 100644 index 000000000..b6cbee44e --- /dev/null +++ b/x/ref/cmd/vdl/gotagtest/vdl.config @@ -0,0 +1,12 @@ +config = vdltool.Config{ + Go: { + StructTags: map[string][]vdltool.GoStructTag{ + "TestStructA": []vdltool.GoStructTag{ + {Field: "A", Tag: `json:"ja,omitempty"`}, + }, + "TestStructB": []vdltool.GoStructTag{ + {Field: "B", Tag: `json:"jb,omitempty"`}, + }, + }, + }, +} diff --git a/x/ref/examples/echo/echo.vdl b/x/ref/examples/echo/echo.vdl index ab97109e1..0b699b078 100644 --- a/x/ref/examples/echo/echo.vdl +++ b/x/ref/examples/echo/echo.vdl @@ -1,3 +1,7 @@ +// Copyright 2020 The Vanadium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package echo import "v.io/v23/security/access" diff --git a/x/ref/examples/echo/echo.vdl.go b/x/ref/examples/echo/echo.vdl.go index a5068ac45..ac4d30568 100644 --- a/x/ref/examples/echo/echo.vdl.go +++ b/x/ref/examples/echo/echo.vdl.go @@ -1,3 +1,7 @@ +// Copyright 2020 The Vanadium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // This file was auto-generated by the vanadium vdl tool. // Package: echo diff --git a/x/ref/internal/logmanager.go b/x/ref/internal/logmanager.go index f17bb07ee..056d3ea66 100644 --- a/x/ref/internal/logmanager.go +++ b/x/ref/internal/logmanager.go @@ -1,3 +1,7 @@ +// Copyright 2020 The Vanadium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package internal import ( diff --git a/x/ref/lib/vdl/build/internal/builtinvdlroot/builtin_vdlroot.go b/x/ref/lib/vdl/build/internal/builtinvdlroot/builtin_vdlroot.go index 61ddc55b9..d05f14c06 100644 --- a/x/ref/lib/vdl/build/internal/builtinvdlroot/builtin_vdlroot.go +++ b/x/ref/lib/vdl/build/internal/builtinvdlroot/builtin_vdlroot.go @@ -177,7 +177,7 @@ func timeVdlConfig() (*asset, error) { return a, nil } -var _vdltoolConfigVdl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xe4\x5a\x5f\x73\xdb\x36\xb6\x7f\x96\x3e\xc5\x19\xcf\x9d\xb9\x76\x46\x25\xef\xed\xbd\xbb\x0f\xde\xe9\x43\x6a\x27\x1e\x77\x53\x27\x1b\xdb\xe9\xce\x76\xfa\x00\x91\x47\x12\x62\x12\x60\x01\x50\xb2\x9a\xc9\x77\xdf\x39\xe7\x00\x24\x28\x3b\x71\xd3\xed\x53\x9b\x87\x58\x22\x81\xf3\xf7\x77\xfe\x01\x2a\x4b\x38\xb3\xdd\xde\xe9\xf5\x26\xc0\xd7\xff\xf3\xbf\x7f\x81\x9b\x0d\xc2\x3b\x65\x54\xad\xfb\x16\x9e\xf7\x61\x63\x9d\x2f\xe0\x79\xd3\x00\x2f\xf2\xe0\xd0\xa3\xdb\x62\x5d\xcc\xcb\x12\x6e\x3d\x82\x5d\x41\xd8\x68\x0f\xde\xf6\xae\x42\xa8\x6c\x8d\xa0\x3d\xac\xed\x16\x9d\xc1\x1a\x96\x7b\x50\xf0\xed\xf5\xf9\x57\x3e\xec\x1b\xa4\x5d\x8d\xae\xd0\x78\x84\xb0\x51\x01\x2a\x65\x60\x89\xb0\xb2\xbd\xa9\x41\x1b\x08\x1b\x84\x57\x97\x67\x2f\xae\xae\x5f\xc0\x4a\x37\x58\xcc\x69\xcb\x1b\x55\xdd\xa9\x35\xc2\xb6\x6e\x82\xb5\x0d\xd4\xb8\xd2\x06\x3d\x84\x7d\x87\x1e\x7a\x2f\x7c\x68\xef\xb6\x6e\x80\x97\xe8\xe0\xb1\x59\x2d\x40\x9b\xaa\xe9\x6b\x6d\xd6\xf4\x9a\x68\xad\xac\x6b\x55\x20\xb9\xb7\x75\x53\x54\xd6\xac\xf4\x9a\x59\xf9\x62\xde\x4d\xf9\x30\xef\x33\x59\xe1\x3b\xac\xf4\x4a\x13\xd3\x0d\xa9\x49\x0f\x7b\xa7\x82\xb6\x86\x48\x4e\x98\x17\x00\x37\x64\x13\xcd\x12\xea\x4a\x35\xcd\x9e\x48\x39\xec\xc8\x7e\x26\x20\xeb\x6a\x3b\xda\xad\x1a\x38\x1a\x25\x39\x12\x51\xe8\x35\xaa\x6a\xc3\x24\xa3\x69\xa3\x70\x05\xc0\x0b\x55\x6d\x88\xde\x81\x02\xa0\xdb\xae\xd1\x95\x0e\xcd\x9e\x3e\x5a\x17\xbc\xf8\x26\xdb\x59\xac\x0b\xd8\xdb\x1e\x5a\xb5\x07\x87\x2b\x74\x10\x6c\x24\xc5\x92\x47\x6d\xa3\x27\x1e\x08\x06\x3b\x1d\x36\xb6\x0f\x80\xf7\x07\xac\xc8\xc2\x89\xc8\x9c\xfc\x32\x18\x2e\xb8\xbe\x0a\xf0\x61\x3e\x2b\x4b\xb8\x40\xf3\x4a\x99\x75\xaf\xd6\xc8\x58\x0a\x4e\x57\x41\x4c\xea\x91\x9d\xc2\x00\x5a\xa3\xc1\x68\xdb\x26\x2d\x2f\x00\x2e\x57\xc3\x4a\xed\x99\x1e\xb6\x5d\xd8\x2f\x40\x35\x0d\xf8\xbe\x23\x39\xb0\x1e\xb7\x80\x72\x48\xef\xec\x0e\x6b\x08\x96\x80\x16\x29\x13\x80\x67\x13\x61\x3c\x86\x1f\xb3\x07\x3f\xcd\x99\x7e\xfa\xfa\x55\x74\x7f\x35\xf5\xbc\x27\x2a\x16\xd2\xbf\x0b\x2b\x3a\xcf\x67\xdf\xa9\xad\x8a\x0f\xe9\x63\xfe\xd8\x57\x4e\x77\x01\xc6\x8f\xe9\xe5\xf5\x4e\xaf\x82\xec\xe1\x8f\xf1\xf9\x47\x46\x61\x26\x1a\xa0\xe9\x5b\x56\x42\x0c\x77\x67\xec\xce\x7c\xc6\x6e\xe2\x8d\x43\x02\xe4\x90\x0b\x2b\x22\xe5\x82\x45\x39\x12\x5b\xfb\x00\xfe\x6b\x0b\x8f\x1b\x23\x31\xb2\x8f\x39\xfe\x07\xed\xf0\xc6\x5e\xa9\xa0\xb7\x78\xc3\x51\x3b\x0d\xa8\x56\x75\x1d\x41\x68\xe5\x6c\x0b\x0a\xde\x9d\xbf\x82\x9d\x76\xc8\x11\x4e\xae\xd3\xc1\x03\x89\x5b\x96\x60\x98\x88\xbc\x19\x22\x4a\x24\x18\xe3\xce\x29\x87\xcd\x5e\x52\x83\x32\x35\xa0\xf2\x7b\xa2\x93\x24\x46\x26\xa5\x4d\x65\x9d\xc3\x2a\x34\xfb\xbf\x41\xef\xc9\x36\xda\x43\xd5\x3b\x87\x86\xa0\x9d\x10\x2a\xf0\x89\x61\xe4\x25\x73\x11\xb6\xc6\x28\x60\x72\xbb\x8d\x0e\xd8\x68\x2f\xf0\x2a\xcb\x4f\x68\x4e\x3b\x5b\x54\x26\x70\xe2\xf0\x15\x1a\xe5\xb4\xf5\xb0\xdb\x20\x69\xcc\xff\x6b\x0f\xca\x80\xae\xb5\x6d\x55\xd0\x55\xd2\x9d\x95\x66\xa5\xb4\xa1\x38\x76\xec\xf7\x05\x2c\xfb\xc0\x61\x6d\x90\xf4\x05\x1f\x94\xa9\x95\xab\xd9\x8e\x53\x1b\x31\x4f\x32\x2d\xd3\xab\x6c\xdb\xa9\xa0\x97\xba\xd1\x61\x9f\xf2\x03\xf9\x83\x36\x06\xdd\x0e\x59\x67\x48\xb9\xe7\x29\xe9\x91\x55\x6f\x68\xc5\xca\x3a\xd1\x9e\xfc\x35\x21\x28\x72\xed\x10\x76\xa4\x2c\x91\x1d\xc2\x4f\xf0\x1a\x2c\x29\x23\x41\x9d\x44\x4e\x9a\x66\xcc\x47\x63\x52\x7d\xba\xc3\xbd\x54\x1d\x46\x0d\x27\xd9\x0d\x82\x51\x2d\xa6\xc7\x2c\x3c\x59\xea\x58\xdd\x29\x71\xc0\xbe\xc3\x93\x05\x39\xa8\xda\x40\xdb\xfb\xc0\xd4\x96\x49\xad\xa1\xf4\x50\xba\x4d\x1a\x2b\xef\x6d\xa5\x59\x58\xca\x7a\xe9\x7d\x9e\x71\xa7\x82\xe5\x21\x68\x1d\xed\xef\xdb\x08\x6f\xbc\x27\x54\x98\x8a\x45\x54\xd0\x29\xed\x24\xd9\x99\x2d\x3a\xcf\x6e\xe9\x4d\xc5\x29\x25\xfa\x85\x5e\x70\x52\x5d\x62\xd8\x21\x8a\x78\x6c\x62\x32\x7c\x16\x03\x7e\xc1\x4f\x76\xba\x69\x40\xf5\x41\xf0\x42\x15\x07\xe8\x7f\xa6\x46\x52\xbf\xc5\x35\x89\xe0\x04\x88\x83\x46\x1e\x07\xce\x6c\x42\x3f\xaa\xf4\x9c\xe4\x8f\x85\x73\x62\xde\x64\x50\x32\xfd\x4b\x6b\x4f\x79\x35\x30\x1d\x58\x59\x9b\xc0\x7e\x7c\x4f\x6f\x17\x60\xe0\x99\x3c\x38\x01\x74\x2e\x82\x65\x5c\xfe\xd2\xd9\x76\xd8\xf0\x2c\xee\x38\xd8\xf0\x30\x86\x5a\xd5\xfd\x48\xb1\x69\xd6\x3f\x5d\x58\x7a\x34\x24\x2c\x96\xac\x46\xca\x66\xcb\x68\xfd\x0b\x2b\x70\xd0\x46\x8a\x3f\xc3\xf7\xc0\xbb\x6a\x40\x0d\xb7\x36\xd7\x88\xb0\x2d\xb4\x2d\xef\x4b\x87\xab\xb2\xd1\xcb\x72\x5b\x37\x65\x40\x1f\x6a\x15\x54\x19\x1d\x40\xc1\x84\xf7\xaa\xed\x9a\x31\xd1\x8a\x04\x93\xec\xf7\x77\x4d\xdd\x4d\x4c\xd7\xf4\xd9\xae\xe0\x86\x59\xcd\xf8\xd5\x85\xa5\x3f\x02\xa4\x68\xd8\x5c\xee\x18\x26\xda\x1c\xc4\x0f\x75\x37\x3e\xa0\xaa\x0f\x81\x5f\xcc\x67\x49\x08\x6d\xd6\x4c\xf7\x5f\xe8\x6c\x96\x73\x7f\xa1\xaf\x5b\xd5\xf4\x5c\x4e\x19\x68\x84\xa2\x6a\x83\xd5\x9d\xa0\x6e\xa3\xb6\xda\xba\x62\x3e\xe3\x9d\x17\x96\xfe\x88\x84\xd1\x11\xbc\x61\xf4\x1e\x50\xc7\xe7\x74\x8d\x63\x3c\xfa\x24\x57\xb4\xd6\x08\x77\x26\x34\x40\x5e\x4a\x7b\x6f\x92\x78\xf5\x82\x77\xd5\xb8\x52\x7d\x13\xc6\x75\x9c\x39\x23\x49\xf2\x64\x42\x5e\x02\xe4\x80\x3c\x8e\x93\xf4\x74\x91\xd8\x3f\x1b\x01\x34\x85\x62\x5a\x99\x41\x91\x29\x3c\x7b\x40\xe2\x11\x0a\x83\x39\x92\xb1\x33\x93\x64\xf6\xbf\x8c\x0d\x99\x92\x14\x4f\xbe\x4d\x3d\x1a\xf7\x61\x94\x1c\x86\x2e\x56\x78\x7e\xc2\xd0\x62\x3b\x8d\x4d\xcd\x86\x8b\x8d\x22\x3f\x58\x3c\x4c\xa7\x8d\xad\xd4\x98\xd3\xc8\x2b\x92\x2f\xc4\xd6\x52\xb7\x68\x83\x08\x33\x2c\xa4\x22\x34\xd4\x83\x04\x9c\x7d\xee\x4c\x41\xa6\x6e\xb1\xa0\x2a\x90\x5c\x21\xe8\xff\x10\xbf\x01\x23\xff\x94\x5b\x1a\x8e\x87\xc5\xf0\x82\x96\xf1\x8b\xa3\x81\xc6\xd1\xf8\x96\xc0\xc6\x6f\x3f\x7c\x6f\x6b\x3c\x85\x33\x65\xac\xa1\xb4\xb6\x80\x4b\x2f\x2f\x8f\x0a\xf9\x74\x7c\x72\xf4\x71\xdc\x18\xcd\x7c\x0a\x1f\x3e\xbc\x51\x61\x73\x2a\xe4\x8f\x16\x70\xa5\x5a\x4c\xdf\x3e\x0e\x1b\x3e\xce\x67\xc9\x31\x3f\xfe\x74\x61\xe5\xf3\x90\x4a\x38\x36\xa7\xa9\x24\x45\x6f\x0c\xcd\x21\xe6\x79\x69\xea\xab\x44\xd7\xf9\xec\x5b\x9a\x21\x66\x57\x7d\xbb\x44\xc7\x4f\x19\x0c\xcf\x9d\x53\xfb\xf9\xec\x9a\xe6\xa0\xf9\xec\x7b\xd5\xcd\x67\x6f\xac\x36\x81\xd6\x5c\xae\x54\x35\xa6\x32\x11\x27\x93\x60\x00\x4d\x9e\xca\x06\x19\xe2\xf2\x49\xe6\x21\x23\xa4\x74\x92\x7c\xdb\x29\xce\xfd\x2a\x40\x6f\xf4\xcf\x3d\xf5\x49\xba\x46\x13\xc6\x6e\x4c\x98\x60\x9d\x15\x60\x26\x94\xe1\x99\xec\xf9\x58\xed\x4d\x4c\x06\x8a\x0c\x6a\xda\x5d\x00\x9c\xf7\x9c\xcc\x2e\xac\xa4\x02\xc3\x51\x2d\xbe\xd0\x61\x32\x2e\xc1\xfb\xde\x4b\xcb\xb0\x54\x1e\x13\x03\x22\x23\x4d\x05\xcd\x2f\x4b\x19\x05\x08\x9e\xb6\xc5\xb0\x49\xa2\xd5\x7a\xc5\x01\x15\x40\xaf\x1e\x55\x07\x6a\x8b\xde\xfc\x37\xf5\x5f\x34\x1c\x1c\xc8\x53\xcc\x67\xac\x5c\x54\x36\x39\x83\xd3\xe0\xc4\x15\x59\x0e\x1d\xd3\x65\x59\xd2\xf2\xb7\x2f\xfe\x71\x7b\xf9\xf6\xc5\xf9\x29\xbc\xd0\xd4\xd0\x01\xc1\x18\xbe\xf9\x06\x6e\xd9\xe2\x60\x5d\xc4\x31\x29\xed\x31\x14\x00\x3f\xa0\xd4\x70\x63\x03\x74\xe8\xc8\xbd\xf3\xa1\xdb\x2d\x63\x73\x95\xf2\xa7\xe7\x5e\x96\x92\x75\x26\xc5\x58\x81\x24\xd9\x0f\x38\x60\xe6\xf2\x94\x3e\x4a\x3e\xf2\x07\x15\x41\xa5\x14\x42\xa6\xb4\x35\x89\x38\x74\x06\x0c\x16\x87\xa1\x77\xc4\xd9\xf5\x08\x7a\xc5\xa6\xcd\x1b\x72\xb1\xc4\xd0\x6d\xfa\xa1\x22\x8d\x12\x8e\xcd\xc5\xe5\x6a\x90\x20\x28\x0a\xbf\x58\x84\x6b\x1b\xe0\xb8\x38\x59\x44\x3c\x48\x0f\x95\x86\xb7\x28\x22\x89\x26\x42\x16\x43\xef\x25\x2f\x58\xfd\xe1\x6d\x94\x58\x9e\x52\xd3\x47\x34\x96\x32\x9f\x5f\x4c\x1b\x51\xb2\x3c\xd3\x52\x5d\xd7\x48\x9a\x1b\xc4\x73\x3c\xda\xa2\x5b\xaa\xa0\x5b\x92\x04\xef\x49\x45\x71\xc3\xb4\xc0\xc5\xda\xfb\x40\xc7\x84\x37\xd6\x35\x53\xf5\x73\x9a\x26\xdb\xef\x36\xd6\x8b\x9d\xbf\x4c\x1d\x6e\xff\xa4\x54\x0e\xa4\x98\x31\xd3\xf2\xda\xac\x1b\x04\xe5\xd6\x7d\x8b\xdc\x9c\xab\x10\x87\x8e\x51\xbd\xcf\x6a\x77\xf3\xfa\xfc\xf5\x71\xb0\x75\xbd\x3b\x39\x15\x17\x24\x36\x04\x5d\xda\x3a\x20\x9c\x54\xd7\xd4\x23\xb5\x7c\xf6\x51\xcc\x67\x13\xe3\x3e\x24\xf7\xbc\xa6\x29\xe6\x1a\x03\xaf\x8a\xb8\x94\xe6\x5d\x7b\x68\xf4\x5d\x72\x8f\x24\x83\x84\x4c\x25\x7d\x45\xa6\x00\xab\xe5\x31\x82\x31\x07\x62\x1e\xd6\x1c\x1f\xd3\x3c\xef\xb0\x91\x09\x7f\xa3\xbb\x49\x0b\x3e\x8d\xfb\x89\x81\xe6\x71\x40\x93\x02\xfb\x18\xfa\xb3\xf0\x64\x9e\xa9\x60\x94\x25\xdc\x1a\x99\xe3\xf3\xb1\x58\x85\x47\x58\x12\x96\x38\x49\x0c\x91\x36\x61\x25\x0d\x3f\xb3\xcb\x4e\xa1\xc6\x6e\x2a\x83\xa7\x91\xd3\xa1\x96\x11\x33\xce\x66\xe0\x29\x27\xa6\xf9\x2c\xa6\xa2\x4f\xe6\xa1\x34\xfd\xa5\x2e\x32\x4f\x47\x00\x37\x8f\x64\x29\xe2\xe5\xf0\xe7\x9e\xc7\xfb\xa4\xa3\xb8\x73\x6c\x6d\x1e\x4d\x43\x31\x57\xce\x67\xd1\x58\xbc\x7c\x68\x0d\x9e\x36\xdd\x43\x38\x47\xe3\xc8\xcc\x35\x10\x3a\x98\x98\xb3\xe6\x7a\x24\x26\xc8\xd3\xe2\x0a\x7a\x6d\x4d\xb3\x3f\xf0\xc0\xc3\xe3\x89\x61\xbe\x9e\x4a\x95\x24\x4a\x9d\xd0\xaf\x15\xeb\x97\x21\x04\x24\xc8\x26\x72\x50\x8c\x57\xc2\xc9\x83\x6a\xbc\x8d\xc1\xa1\xbd\x1c\x3c\x8c\x65\x92\x7a\xc4\x54\xfa\x9e\x02\xc7\x4a\xf9\x20\xe0\xe0\xc3\x8b\xa7\xbd\x3e\x9a\xe3\x73\x9e\xff\x35\x5e\x1f\x3c\x1d\x03\x86\x2b\xe9\x6f\x77\x3a\x5b\x2a\x26\xd6\xa7\xfd\xfd\x69\xe7\xb1\xd7\xd2\xb1\x08\xd3\x3b\x96\x54\xb5\x51\x9e\xbb\x97\x34\x7c\x86\xbf\xfe\xff\x49\xce\xfb\x13\x0e\xfd\x62\x27\x2c\x2d\xb5\x66\x8f\x4d\x71\x07\xf6\xe7\xc8\x21\xab\xc5\xec\x37\x1e\x4d\x66\x66\x7c\xaf\xb6\xea\xf3\x27\x7c\xf9\xb6\xdf\xfb\x8c\x4f\x8e\x23\xff\xac\xa7\x7c\x83\xf6\x7f\xdc\x73\x3e\xeb\xd6\xc5\x7b\x5b\xab\x82\xb8\x32\xbd\x3f\xc8\x21\x5f\x4c\x3e\x8f\x1d\xe9\x49\x3f\xb6\x24\x20\xcb\x21\x1c\xd6\x11\x98\x12\x6d\x99\x40\xc5\x13\x87\x5d\xb1\x63\x1a\x31\xb7\xef\xf0\x2d\xca\x61\xcb\x17\x44\x1b\x1b\x52\x42\x8e\x49\xf1\x7d\x45\x1e\x72\xb4\xe0\x00\xdd\x19\xa7\x27\xb1\x3d\xb2\xa3\x0d\xe9\x48\x73\xd5\xf0\x6d\x8f\x36\x3c\xb0\xc1\x4e\xed\x47\xa3\xe7\x12\x30\x93\x05\x60\xb1\x2e\x16\x51\xf4\x4b\x13\x70\x8d\x6e\x0c\x8e\xca\xf6\x4d\x4d\x36\xa5\xc5\x35\xbc\x8b\x0b\x58\xa0\xaa\x51\x8e\x70\x3e\xca\xbf\x41\x43\x90\x5d\x32\x0c\x98\xe7\x03\x2b\x2f\x24\xd7\xae\x50\x85\x3e\x5d\x1b\x79\xe8\x79\xd2\x52\x21\xa8\x6a\x33\x3d\xb4\xa2\xe7\x09\x83\x54\xf4\x5e\x8e\x47\x81\x0b\x8a\x05\xb9\x61\x63\x43\x3f\xaf\x2a\xf4\xfe\x15\x15\xde\xb4\x23\xfa\x3f\x58\x16\x24\x5b\x10\x5b\x47\xc3\xb0\x3f\x78\x17\x2c\x50\x2a\x38\x74\x96\x9c\xd6\x8e\xcb\x24\x00\x52\x20\x8f\x02\x5b\x33\xb8\xa6\x56\x41\xfd\x96\x80\x1b\x10\x94\x87\x19\x2c\x45\x84\xff\x38\xcc\x0e\x61\xf6\x10\xf7\x63\xdd\xca\xef\xce\x0e\xaa\x57\xbc\x61\x7b\xb2\x86\x4d\x49\xa4\x4a\x26\x2c\xb2\x1b\xb8\x8c\xba\xe7\x2b\xba\xc7\x09\xc7\x5b\xe0\xec\xba\x95\xe8\x5c\xd9\x10\x7b\x9d\x1a\x7d\xa7\x83\x44\x47\x4e\x5d\x6e\x81\xb9\x91\x06\x05\x6b\xbd\x45\x33\x98\x2d\x36\x12\x7e\x13\xc1\xce\x37\xb5\xe8\xf6\x5c\xf8\xc8\xce\x9d\x53\x55\xd0\x15\xa7\x3d\x04\x1f\xf8\x00\x01\xa5\x90\x51\x8b\xfc\xc0\x89\xa2\x41\x6b\xeb\x5e\x2e\xe3\x63\xde\x1a\xa5\x96\xc9\x07\x19\xde\x54\x0d\x9d\xed\xd0\x51\x8d\x35\x35\x3a\xae\x37\xe9\x08\x6a\x69\x7b\x2a\x3e\x64\x97\x38\x20\x11\xc1\xce\xd9\xf7\x58\x05\x5f\xae\x9c\x6a\x71\x67\xdd\x9d\x2f\x85\x9d\x4f\x87\x23\x3f\xd0\x10\x23\x4c\x97\x7b\x41\x0d\x77\x2e\x72\xc3\x4c\x63\x2b\xd6\x70\xc4\x92\xca\xce\xa3\xf8\x5b\x01\x6b\x82\xd2\xc6\xc3\x77\xb7\xd7\x37\xe9\x3a\x3f\x57\xee\x3a\x53\x0e\x62\x3e\x76\xd6\xf2\xbd\x32\x17\x51\x82\x70\xaa\xef\xc5\x24\x62\x89\x94\xe6\x55\xb0\x51\xdb\x31\x87\xc9\x6d\x3c\xf9\x86\x09\xfc\x93\xd3\x7f\xd4\xb1\x0c\xca\xad\x31\x24\x89\x6f\x97\xe8\x5e\x5a\x77\xa6\x82\x27\x6a\x2a\x40\x79\xeb\xd1\xf9\x52\x29\x67\x4d\xd9\x2f\x79\x92\xaa\x54\xf0\xe5\xb6\x6e\x16\x12\xe5\x95\x43\x15\x58\x91\xcf\x2d\x2e\x2b\xdb\x16\xf9\xb3\xcc\x38\x9c\x31\x58\x66\x1d\xe4\xd4\x2c\xda\x89\x88\x1e\x65\x42\x1d\x15\x64\x79\xe6\xca\xf5\x28\x10\x6b\x50\x66\x9f\x29\x1a\xb7\xa6\x20\x26\xd8\x6a\xea\x9c\xac\xdb\x13\x1f\xd6\xcb\xec\xc1\xf7\xcb\xf4\x9c\x8f\x8e\x08\x3d\x2e\x24\x37\x64\x3c\x27\x2e\x59\x40\xdf\x04\xdd\xaa\x40\x3d\x5b\x23\xfd\xea\x3c\x1e\x3f\x53\x3f\xa1\x1b\x74\x9f\xba\xcb\x62\xc0\xa0\xfc\x0a\x05\xf8\xa8\x8f\xdc\x65\xa9\x8d\xf2\x09\x90\xec\xa1\x3c\xf8\x2e\xc5\xa1\xb5\xa5\xd9\x28\x41\x8e\x0d\x60\xec\xd2\xd6\xfb\xa1\x2e\xab\x65\x23\xe5\x30\x23\x34\xe4\x76\x32\x05\xab\xb1\x10\xf5\x6b\xf9\x01\x05\x4b\x82\xa6\x86\xbe\x93\x9c\x86\xf7\xc1\x29\x68\xac\x59\x53\x01\xf2\xbe\xec\xee\xd6\xf1\x1a\xe4\xf8\xcc\xb6\x99\xfb\xae\xd1\x6d\x75\x85\xfe\x8d\xb3\x2b\x1d\x18\x7a\xe3\x3d\xce\xf4\x25\x43\xef\xbf\xde\x9d\xbf\x7a\xfb\xfa\xf5\xcd\x43\x18\xc4\xb5\x65\xc7\x8b\x4f\x52\x84\x45\xc5\x29\x49\x30\xc0\xc8\x5c\x2d\x19\xbf\x6b\xa6\x51\x32\x4d\x3b\x89\x8f\xd8\x88\xb1\xd4\x35\xaa\x62\x78\xe6\x88\x13\xac\xc4\x00\x6b\xec\x9a\xa7\xd3\x31\x1d\xc4\xc8\x1a\x4b\x61\x32\x3d\xf1\xe2\x4b\xb5\xed\xd7\xff\xc7\x8e\xe7\xb3\x2e\xbc\x8f\xa7\xb3\x41\x7c\x9c\x7e\x7f\x74\x66\x1d\xc2\x90\x45\xa4\xc7\x44\xca\x7e\xe2\x7e\x4e\x48\x03\xb9\xc1\x14\xf2\x0b\xa3\xad\xb8\x2d\x27\x97\xec\x3a\x92\x8c\xa5\x60\x92\xea\x7f\xef\x79\x46\x7e\x4c\xf1\xa7\x1d\x68\x46\xf5\xff\x98\x13\xcd\xd5\xf5\x39\xcd\xe3\xd6\xc1\xd5\x35\x91\xa4\x2e\xd4\x6d\xe5\x84\xe2\x4f\x37\xcb\x48\x62\xf9\xf2\x61\xe6\xe3\xfc\xdf\x01\x00\x00\xff\xff\xf9\x86\x52\x63\x89\x28\x00\x00") +var _vdltoolConfigVdl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xe4\x5a\x5f\x93\xd4\x36\x12\x7f\x9e\xf9\x14\x5d\x5b\x57\x15\xa0\x26\xf6\x5d\xee\xcf\x03\x57\x79\x20\x2c\x6c\x6d\x8e\x00\xc7\x2e\xe4\xea\x52\x79\xd0\xd8\x3d\x33\x62\x6d\xc9\x91\xe4\xd9\x9d\x50\x7c\xf7\xab\xee\x96\x64\x79\x76\x81\x90\xcb\x53\x92\x87\x30\x6b\x49\xfd\xbf\x7f\xdd\x6a\xbb\xae\xe1\xb1\x1d\x0e\x4e\x6f\x77\x01\xbe\xfa\xf3\x5f\xfe\x0e\x97\x3b\x84\x37\xca\xa8\x56\x8f\x3d\x3c\x1a\xc3\xce\x3a\x5f\xc1\xa3\xae\x03\xde\xe4\xc1\xa1\x47\xb7\xc7\xb6\x5a\xd6\x35\xbc\xf6\x08\x76\x03\x61\xa7\x3d\x78\x3b\xba\x06\xa1\xb1\x2d\x82\xf6\xb0\xb5\x7b\x74\x06\x5b\x58\x1f\x40\xc1\x37\x17\xa7\x5f\xfa\x70\xe8\x90\x4e\x75\xba\x41\xe3\x11\xc2\x4e\x05\x68\x94\x81\x35\xc2\xc6\x8e\xa6\x05\x6d\x20\xec\x10\x9e\x9d\x3f\x7e\xf2\xfc\xe2\x09\x6c\x74\x87\xd5\x92\x8e\xbc\x54\xcd\x95\xda\x22\xec\xdb\x2e\x58\xdb\x41\x8b\x1b\x6d\xd0\x43\x38\x0c\xe8\x61\xf4\xc2\x87\xce\xee\xdb\x0e\x78\x8b\x0e\x1e\xbb\xcd\x0a\xb4\x69\xba\xb1\xd5\x66\x4b\xcb\x44\x6b\x63\x5d\xaf\x02\xc9\xbd\x6f\xbb\xaa\xb1\x66\xa3\xb7\xcc\xca\x57\xcb\x61\xce\x87\x79\x3f\x96\x1d\x7e\xc0\x46\x6f\x34\x31\xdd\x91\x9a\xf4\x70\x74\x2a\x68\x6b\x88\xe4\x8c\x79\x05\x70\x49\x36\xd1\x2c\xa1\x6e\x54\xd7\x1d\x88\x94\xc3\x81\xec\x67\x02\xb2\xae\x76\xa0\xd3\xaa\x83\x93\x49\x92\x13\x11\x85\x96\x51\x35\x3b\x26\x19\x4d\x1b\x85\xab\x00\x9e\xa8\x66\x47\xf4\x8e\x14\x00\xdd\x0f\x9d\x6e\x74\xe8\x0e\xf4\xd3\xba\xe0\xc5\x37\xc5\xc9\x6a\x5b\xc1\xc1\x8e\xd0\xab\x03\x38\xdc\xa0\x83\x60\x23\x29\x96\x3c\x6a\x1b\x3d\x71\x4b\x30\xb8\xd6\x61\x67\xc7\x00\x78\x73\xc4\x8a\x2c\x9c\x88\x2c\xc9\x2f\xd9\x70\xc1\x8d\x4d\x80\x77\xcb\x45\x5d\xc3\x19\x9a\x67\xca\x6c\x47\xb5\x45\x8e\xa5\xe0\x74\x13\xc4\xa4\x1e\xd9\x29\x1c\x40\x5b\x34\x18\x6d\xdb\xa5\xed\x15\xc0\xf9\x26\xef\xd4\x9e\xe9\x61\x3f\x84\xc3\x0a\x54\xd7\x81\x1f\x07\x92\x03\xdb\xe9\x08\x28\x87\xb4\x66\xaf\xb1\x85\x60\x29\xd0\x22\x65\x0a\xe0\xc5\x4c\x18\x8f\xe1\x87\xe2\xc1\x8f\x4b\xa6\x9f\xfe\xfc\x32\xba\xbf\x99\x7b\xde\x13\x15\x0b\xe9\xbf\x33\x2b\x3a\x2f\x17\xdf\xaa\xbd\x8a\x0f\xe9\x67\xf9\xd8\x37\x4e\x0f\x01\xa6\x9f\x69\xf1\xe2\x5a\x6f\x82\x9c\xe1\x9f\xf1\xf9\x7b\x8e\xc2\x42\x34\x40\x33\xf6\xac\x84\x18\xee\xca\xd8\x6b\xf3\x11\xbb\x89\x37\x8e\x09\x90\x43\xce\xac\x88\x54\x0a\x16\xe5\x48\x6c\xed\xad\xf0\xdf\x5a\xb8\xdb\x18\x89\x91\xbd\xcb\xf1\xdf\x6b\x87\x97\xf6\xb9\x0a\x7a\x8f\x97\x9c\xb5\xf3\x84\xea\xd5\x30\x50\x08\x6d\x9c\xed\x41\xc1\x9b\xd3\x67\x70\xad\x1d\x72\x86\x93\xeb\x74\xf0\x40\xe2\xd6\x35\x18\x26\x22\x2b\x39\xa3\x44\x82\x29\xef\x9c\x72\xd8\x1d\x04\x1a\x94\x69\x01\x95\x3f\x10\x9d\x24\x31\x32\x29\x6d\x1a\xeb\x1c\x36\xa1\x3b\xfc\x13\x46\x4f\xb6\xd1\x1e\x9a\xd1\x39\x34\x14\xda\x29\x42\x25\x7c\x62\x1a\x79\x41\x2e\x8a\xad\x29\x0b\x98\xdc\xf5\x4e\x07\xec\xb4\x97\xf0\xaa\xeb\x0f\x68\x4e\x27\x7b\x54\x26\x30\x70\xf8\x06\x8d\x72\xda\x7a\xb8\xde\x21\x69\xcc\xff\xd7\x1e\x94\x01\xdd\x6a\xdb\xab\xa0\x9b\xa4\x3b\x2b\xcd\x4a\x69\x43\x79\xec\xd8\xef\x2b\x58\x8f\x81\xd3\xda\x20\xe9\x0b\x3e\x28\xd3\x2a\xd7\xb2\x1d\xe7\x36\x62\x9e\x64\x5a\xa6\xd7\xd8\x7e\x50\x41\xaf\x75\xa7\xc3\x21\xe1\x03\xf9\x83\x0e\x06\xdd\x67\xd4\xc9\x90\x7b\x9a\x40\x8f\xac\x7a\x49\x3b\x36\xd6\x89\xf6\xe4\xaf\x19\x41\x91\xeb\x1a\xe1\x9a\x94\x25\xb2\x39\xfd\x24\x5e\x83\x25\x65\x24\xa9\x93\xc8\x49\xd3\x82\xf9\x64\x4c\xaa\x4f\x57\x78\x90\xaa\xc3\x51\xc3\x20\xbb\x43\x30\xaa\xc7\xf4\x98\x85\x27\x4b\xdd\x53\x57\x4a\x1c\x70\x18\xf0\xfe\x8a\x1c\xd4\xec\xa0\x1f\x7d\x60\x6a\xeb\xa4\x56\x2e\x3d\x04\xb7\x49\x63\xe5\xbd\x6d\x34\x0b\x4b\xa8\x97\xd6\x4b\xc4\x9d\x0b\x56\xa6\xa0\x75\x74\x7e\xec\x63\x78\xe3\x0d\x45\x85\x69\x58\x44\x05\x83\xd2\x4e\xc0\xce\xec\xd1\x79\x76\xcb\x68\x1a\x86\x94\xe8\x17\x5a\x60\x50\x5d\x63\xb8\x46\x14\xf1\xd8\xc4\x64\xf8\x22\x07\xfc\x8a\x9f\x5c\xeb\xae\x03\x35\x06\x89\x17\xaa\x38\x40\xff\x67\x6a\x24\xf5\x2b\xdc\x92\x08\x4e\x02\x31\x6b\xe4\x31\x73\x66\x13\xfa\x49\xa5\x47\x24\x7f\x2c\x9c\x33\xf3\x26\x83\x92\xe9\x9f\x5a\xfb\x90\x77\x03\xd3\x81\x8d\xb5\x29\xd8\xef\xdd\xd0\xea\x0a\x0c\x3c\x90\x07\xf7\x01\x9d\x8b\xc1\x32\x6d\x7f\xea\x6c\x9f\x0f\x3c\x88\x27\x8e\x0e\xdc\xce\xa1\x5e\x0d\x3f\x50\x6e\x9a\xed\x8f\x67\x96\x1e\x09\x5e\x5f\x30\xe6\x5c\xaa\x6d\x89\x2f\xca\x1c\x18\xb5\x04\x8f\x02\x2d\x4a\x31\x90\xde\x60\x32\xc6\x14\x9e\x4c\x6c\x6b\xd9\xa5\x15\x3b\xb7\xa0\x1c\xa3\xee\x0a\x0f\x53\xdf\x91\x88\x1f\x06\xfc\xc2\xb3\xb5\xaa\xe5\x62\x7e\x26\xc9\xfb\xc3\x8f\x67\x36\xaf\x64\x9c\xcd\x4f\x4a\xc1\xc1\x6b\xb3\xed\x70\x2e\x3d\xbb\x9b\x78\x6e\x34\x76\x0c\x4c\x12\xd6\x3a\x10\x25\xbf\xb3\x63\xd7\x92\x76\x6a\x18\x3a\x4d\x48\x14\x61\xb9\xe0\x90\x91\xf9\x29\x93\x10\xc1\x96\x8b\xb8\x46\xbf\x93\x58\xec\xe7\x16\xa9\x36\xac\x63\x2c\x9f\x59\x49\x2e\x6d\xa4\x95\x62\x30\x38\xca\x15\x95\x73\x90\x1b\xc5\x0b\x44\xd8\x57\xda\xd6\x37\xb5\xc3\x4d\xdd\xe9\x75\xbd\x6f\xbb\x3a\xa0\x0f\xad\x0a\xaa\x8e\xe1\x4c\xd0\x84\x37\xaa\x1f\xba\xa9\x6c\x89\x04\xb3\x5a\xf2\x2f\x4d\xbd\x62\x2c\x7e\xf4\xdb\x6e\xe0\x92\x59\x2d\x78\xe9\xcc\xd2\x3f\x92\x96\x31\x4c\x4b\xb9\x23\xe8\x68\x73\x84\x46\xd4\x2b\xfa\x80\xaa\x3d\x86\x91\x6a\xb9\x48\x42\xb0\x99\xea\x1a\xfe\x8b\xce\x16\x8e\xfa\x99\xfe\xdc\xab\x6e\xe4\xe6\x84\xd3\x96\x9c\xd4\xec\xb0\xb9\x92\x1c\xde\xa9\xbd\xb6\xae\x5a\x2e\xf8\xe4\x99\xa5\x7f\x44\xc2\x18\xd6\x7c\x60\xca\x05\xa0\xfe\xd9\xe9\x16\x27\x74\xf3\x49\xae\x68\xad\x09\x3c\x98\x50\x06\x10\x69\x94\x46\x93\xc4\x6b\x57\x7c\xaa\xc5\x8d\x1a\xbb\x30\xed\xe3\x3a\x14\x49\x92\x27\x53\x1e\xa7\xf4\xce\x79\xcc\xa8\x93\x9e\xae\x12\xfb\x07\x53\x3a\xce\x13\x3b\xed\x2c\x12\x9b\x29\x3c\xb8\x45\xe2\x0e\x0a\xd9\x1c\xc9\xd8\x85\x49\x0a\xfb\x9f\xc7\xf6\x56\x49\xc1\x24\xdf\xa6\x8e\x97\xbb\x5a\x82\xda\x9c\x9b\xc2\xf3\x03\x86\x16\xdb\x51\x1a\xb0\xe1\x62\xdb\xcd\x0f\x56\xb7\x8b\x53\x67\x1b\x35\x55\x08\xf2\x8a\xa0\xaf\xd8\x5a\xba\x00\x3a\x20\xc2\xe4\x8d\x54\xd2\x73\x75\x4d\x81\x73\x28\x9d\x29\x91\xa9\x7b\xac\xa8\xa6\x26\x57\x48\xf4\xbf\x8b\x7f\x01\x47\xfe\x43\x6e\x10\x39\x1f\x56\x79\x81\xb6\xf1\xc2\x49\xa6\x71\x32\xad\x52\xb0\xf1\xea\xbb\xef\x6c\x8b\x0f\xe1\xb1\x32\xd6\x50\x91\x58\xc1\xb9\x97\xc5\x93\x4a\x7e\xdd\xbb\x7f\xf2\x7e\x3a\x18\xcd\xfc\x10\xde\xbd\x7b\xa9\xc2\xee\xa1\x90\x3f\x59\xc1\x73\xd5\x63\xfa\xeb\x7d\x3e\xf0\x7e\xb9\x48\x8e\x21\x90\x93\xdf\x19\x4a\x38\x37\xe7\x50\x92\xb2\x37\xa6\x66\xce\x79\xde\x9a\xba\x54\xd1\x75\xb9\xf8\x86\x6e\x64\x8b\xe7\x63\xbf\x46\xc7\x4f\x39\x18\x1e\x39\xa7\x0e\xcb\xc5\x05\xdd\x2a\x97\x8b\xef\xd4\xb0\x5c\xbc\xb4\xda\x04\xda\x73\xbe\x51\x0d\x66\xfe\x22\x4e\x21\x41\x0e\x9a\x12\xca\xb2\x0c\x71\xfb\x0c\x79\xc8\x08\x09\x4e\x92\x6f\x07\xc5\xc5\x43\x05\x18\x8d\xfe\x69\xa4\xae\x53\xb7\x68\xc2\xd4\xdb\x0a\x13\x6c\x8b\x76\x86\x09\x15\xf1\x4c\xf6\xbc\xab\x93\x49\x4c\x32\x45\x0e\x6a\x3a\x5d\x01\x9c\x8e\x0c\x66\x67\x56\xa0\xc0\x70\x56\x8b\x2f\x74\x98\x5d\x3e\xe1\xed\xe8\xa5\x01\x5b\x2b\x8f\x89\x01\x91\x91\x16\x8d\x6e\x83\x6b\xb9\x58\x51\x78\xda\x1e\xc3\x2e\x89\xd6\xea\x0d\x27\x54\x00\xbd\xb9\x53\x1d\x68\x2d\x7a\xf3\x05\x75\xb3\x74\xd5\x3a\x92\xa7\x5a\x2e\x58\xb9\xa3\xba\xc2\x30\x38\x73\x45\x81\xa1\x13\x5c\xd6\x35\x6d\x7f\xf5\xe4\xdf\xaf\xcf\x5f\x3d\x39\x7d\x08\x4f\x34\xb5\xc7\x40\x61\x0c\x5f\x7f\x0d\xaf\xd9\xe2\x60\x5d\x8c\x63\x52\xda\x63\xa8\x00\xbe\x47\xe9\x88\x8c\x0d\x30\xa0\x23\xf7\x2e\xf3\xdd\xa1\x8e\xad\x6a\xc2\x4f\xee\x07\x18\xac\x0b\x29\xa6\x0a\x24\x60\x9f\xe3\x80\x99\xcb\x53\xfa\x29\x78\xe4\x8f\x2a\x82\x4a\x10\x42\xa6\xb4\x2d\x89\x98\xfb\x2c\x0e\x16\x87\x61\x74\xc4\xd9\x8d\x08\x7a\xc3\xa6\x2d\xaf\x37\x62\x89\xdc\xbb\xfb\x5c\x91\x26\x09\xa7\x56\xed\x7c\x93\x25\x08\x8a\xd2\x2f\x16\xe1\xd6\x06\xb8\x57\xdd\x5f\xc5\x78\x90\x8e\x34\x5d\x85\xa3\x88\x24\x9a\x08\x59\xe5\x4e\x36\x76\x16\xa4\x7e\x5e\x8d\x12\xcb\x53\x6a\xa1\x89\xc6\x5a\xa6\x1d\x67\xf3\xb6\x9e\x2c\xcf\xb4\xa8\x05\x11\x98\xcb\xe2\x39\x1e\x14\xa0\x5b\xab\xa0\x7b\x92\x04\x6f\x48\x45\x71\xc3\xbc\xc0\xc5\xda\x7b\x4b\xc7\x14\x6f\xac\x6b\xa1\xea\xc7\x34\x4d\xb6\xbf\xde\x59\x2f\x76\xfe\x3c\x75\xb8\x99\x96\x52\x99\x49\x31\x63\xa6\x15\xdb\x34\xe5\xb6\x63\x8f\x7c\xd5\x51\x21\x5e\xe1\x26\xf5\x3e\xaa\xdd\xe5\x8b\xd3\x17\xf7\x82\x6d\xdb\xeb\xfb\x0f\xc5\x05\x89\x0d\x85\x2e\x1d\xcd\x11\x4e\xaa\x6b\xea\x91\x7a\x9e\x24\x55\xcb\xc5\xcc\xb8\xb7\xc9\x3d\x6a\xe9\x4e\x78\x81\x81\x77\xc5\xb8\x8c\x3d\xa3\x87\x4e\x5f\x25\xf7\x08\x18\xa4\xc8\x54\xd2\x57\x14\x0a\xb0\x5a\x1e\x63\x30\x96\x81\x58\xa6\x35\xe7\xc7\x1c\xe7\x1d\x76\x32\x2f\xd9\xe9\x61\x76\xa1\x99\xe7\xfd\xcc\x40\xcb\x78\xdd\x5d\xe5\x7e\xf7\x38\xfa\x8b\xf4\x64\x9e\xa9\x60\xd4\x35\xbc\x36\x32\x15\x29\x87\x0c\x2a\xdc\xc1\x92\x62\x89\x41\x22\x67\xda\x8c\x95\x5c\x9f\x98\x5d\x31\xd3\x9b\xba\xa9\x22\x3c\x8d\xcc\xda\x7a\x8e\x98\xe9\x2a\x01\x9e\x30\x31\xdd\x76\x23\x14\x7d\x10\x87\xd2\x5d\x3a\x75\x91\x25\x1c\x01\x5c\xde\x81\x52\xc4\xcb\xe1\x4f\x23\x0f\x4b\x92\x8e\xe2\xce\xa9\xb5\xb9\x13\x86\x22\x56\x2e\x17\xd1\x58\xbc\x3d\xb7\x06\x9f\x36\xdd\xed\x70\x8e\xc6\x91\x1b\x6c\x26\x74\x34\x7f\x28\x9a\xeb\x89\x98\x44\x9e\x16\x57\xd0\xb2\x35\xdd\xe1\xc8\x03\xb7\x87\x3d\x79\x5a\x31\x97\x2a\x49\x94\x3a\xa1\x5f\x2a\xd6\xcf\x39\x05\x24\xc9\x66\x72\x50\x8e\x37\xc2\xc9\x83\xea\xbc\x8d\xc9\xa1\xbd\x8c\x71\xa6\x32\x49\x3d\x62\x2a\x7d\x9f\x0a\x8e\x8d\xf2\x41\x82\x83\x47\x41\x9f\xf6\xfa\x64\x8e\x8f\x79\xfe\x97\x78\x3d\x7b\x3a\x26\x0c\x57\xd2\x5f\xef\x74\xb6\x54\x04\xd6\x4f\xfb\xfb\xc3\xce\x63\xaf\xa5\x21\x13\xd3\xbb\x27\x50\xb5\x53\x9e\xbb\x97\x74\xf9\x0c\xff\xf8\xdb\xfd\x92\xf7\x07\x1c\xfa\xd9\x4e\x58\x5b\x6a\xcd\xee\xba\xc5\x1d\xd9\x9f\x33\x87\xac\x16\xd1\x6f\x1a\xf4\x16\x66\x7c\xab\xf6\xea\xe3\xf3\xd2\xf2\xd8\x6f\x3d\x31\x95\xe1\xee\x1f\x75\x66\x9a\xb5\xff\xfd\x4e\x4d\xad\xdb\x56\x6f\x6d\xab\x2a\xe2\xca\xf4\x7e\x27\x23\xd3\x08\x3e\x77\x0d\x48\xa5\x1f\x5b\x53\x20\xcb\x48\x33\x8e\xeb\xb4\x91\x6c\x2b\x04\xaa\x3e\x31\x3a\x8c\x1d\xd3\x14\x73\x87\x01\x5f\xa1\x0c\x5b\x3e\x23\xdb\xd8\x90\x92\x72\x4c\x8a\xdf\xfe\x94\x29\x17\xe7\x81\x65\x74\x17\x9c\x3e\x19\xdb\x13\x3b\x3a\x90\x06\xc4\x9b\x8e\xdf\x9d\x69\xc3\x17\x36\xb8\x56\x87\xc9\xe8\xa5\x04\xcc\x64\x05\x58\x6d\xab\x55\x14\xfd\xdc\x04\xdc\xa2\x9b\x92\xa3\x49\x43\x43\xda\xdc\xc2\x9b\xb8\x81\x05\x6a\x3a\xe5\x28\xce\x27\xf9\x77\x68\x28\x64\xd7\x1c\x06\xcc\xf3\x96\x95\x57\x82\xb5\x1b\x54\x61\x4c\x2f\xe1\x3c\x8c\x7c\xd3\x52\x21\xa8\x66\x37\x1f\x5a\xd1\xf3\x14\x83\x54\xf4\x9e\x4e\xa3\xc0\x15\xe5\x82\xbc\xaf\x64\x43\x3f\x6a\x1a\xf4\xfe\x19\x15\xde\x74\x22\xfa\x3f\x58\x16\xa4\xd8\x10\x5b\x47\xc3\x61\x7f\xb4\x16\x2c\x10\x14\x1c\x3b\x4b\x66\xdf\xd3\x36\x49\x80\x94\xc8\x93\xc0\xd6\x64\xd7\xb4\x2a\xa8\x5f\x93\x70\x39\x82\xca\x34\x83\xb5\x88\xf0\x7f\xa7\xd9\x71\x98\xdd\x8e\xfb\xa9\x6e\x95\x6f\x22\x8f\xaa\x57\x7c\x5f\xf9\xc9\x1a\x36\x27\x91\x2a\x99\xb0\x28\xde\x67\x16\xd4\x3d\xbf\xf0\xbc\x9b\x70\x7c\xa7\x5e\xbc\xbc\x26\x3a\xcf\x6d\x88\xbd\x4e\x8b\x7e\xd0\x41\xb2\xa3\xa4\x2e\xef\xd4\xb9\x91\x06\x05\x5b\xbd\x47\x93\xcd\x16\x1b\x89\x3c\x21\xe7\xf7\xde\xe8\x0e\x5c\xf8\xc8\xce\x83\x53\x4d\xd0\x0d\xc3\x1e\x82\x0f\x3c\x40\x40\x29\x64\xd4\x22\xdf\x72\xa2\x68\xd0\xdb\x76\x94\x4f\x1b\x22\x6e\x4d\x52\xcb\xcd\x07\x39\xbc\xa9\x1a\x3a\x3b\xa0\xa3\x1a\x6b\x5a\x74\x5c\x6f\xd2\x08\x6a\x6d\x47\x2a\x3e\x64\x97\x78\x41\x22\x82\x83\xb3\x6f\xb1\x09\xbe\xde\x38\xd5\xe3\xb5\x75\x57\xbe\x16\x76\x3e\x0d\x47\xbe\xa7\x4b\x8c\x30\x5d\x1f\x24\x6a\xb8\x73\x91\xf7\xf5\x74\x6d\xc5\x16\x4e\x58\x52\x39\x79\x12\xbf\xbc\xb0\x26\x28\x6d\x3c\x7c\xfb\xfa\xe2\x32\x7d\x1c\x51\x2a\x77\x51\x28\x07\x11\x8f\x9d\xb5\xfc\x96\x9e\x8b\x28\x85\x70\xaa\xef\xd5\x2c\x63\x89\x94\xe6\x5d\xb0\x53\xfb\x09\xc3\xe4\xdb\x06\xf2\x0d\x13\xf8\x0f\xc3\x7f\xd4\xb1\x0e\xca\x6d\x31\x24\x89\x5f\xaf\xd1\x3d\xb5\xee\xb1\x0a\x9e\xa8\xa9\x00\xf5\x6b\x8f\xce\xd7\x4a\x39\x6b\xea\x71\xcd\x37\xa9\x46\x05\x5f\xef\xdb\x6e\x25\x59\xde\x38\x54\x81\x15\xf9\xd8\xe6\xba\xb1\x7d\x55\x3e\x2b\x8c\xc3\x88\xc1\x32\xeb\x20\x53\xb3\x68\x27\x22\x7a\x52\x08\x75\x52\x91\xe5\x99\x2b\xd7\xa3\x40\xac\xf9\x55\xd3\xa4\x68\x3c\x9a\x92\x98\xc2\x56\x53\xe7\x64\xdd\x81\xf8\xb0\x5e\xe6\x00\x7e\x5c\xa7\xe7\x3c\x3a\xa2\xe8\x71\x21\xb9\xa1\xe0\x39\x73\xc9\x0a\xc6\x2e\xe8\x5e\x05\xea\xd9\x3a\xe9\x57\x97\x71\xfc\x4c\xfd\x84\xee\xd0\x7d\xe8\xcd\x20\x07\x0c\xca\x37\x3d\xc0\xa3\x3e\x72\x97\xa5\x36\xca\xa7\x80\x64\x0f\x95\xc9\x77\x2e\x0e\x6d\x2d\xdd\x8d\x52\xc8\xb1\x01\x8c\x5d\xdb\xf6\x90\xeb\xb2\x5a\x77\x52\x0e\x0b\x42\x19\xdb\xc9\x14\xac\xc6\x4a\xd4\x6f\xe5\x73\x14\x96\x04\x4d\x0b\xe3\x20\x98\x86\x37\xc1\x29\xe8\xac\xd9\x52\x01\xf2\xbe\x1e\xae\xb6\xf1\x35\xc8\xbd\xc7\xb6\x2f\xdc\x77\x81\x6e\xaf\x1b\xf4\x2f\x9d\xdd\xc8\x3b\xb0\xe2\x3d\xce\x7c\x91\x43\xef\x4f\x6f\x4e\x9f\xbd\x7a\xf1\xe2\xf2\x76\x18\xc4\xbd\xf5\xc0\x9b\xef\xa7\x0c\x8b\x8a\x13\x48\x70\x80\x91\xb9\x7a\x32\xfe\xd0\xcd\xb3\x64\x0e\x3b\x89\x8f\xd8\x88\x63\x69\xe8\x54\xc3\xe1\x59\x46\x9c\xc4\x4a\x4c\xb0\xce\x6e\xf9\x76\x3a\xc1\x41\xcc\xac\xa9\x14\x26\xd3\x13\x2f\x7e\xa9\xb6\xff\xea\xaf\xec\x78\x9e\x75\xe1\x4d\x9c\xce\x06\xf1\x71\xfa\x9a\xeb\xb1\x75\x08\x19\x45\xa4\xc7\x44\x42\x3f\x71\x3f\x03\x52\x26\x97\x4d\x21\xdf\x6b\xed\xc5\x6d\x25\xb9\x64\xd7\x89\x64\x2c\x05\x33\xa8\xff\xad\xef\x33\xf2\x69\xca\x1f\xf6\x42\x33\xa9\xff\xfb\xbc\xd1\x3c\xbf\x38\xa5\xfb\xb8\x75\xf0\xfc\x82\x48\x52\x17\xea\xf6\x32\xa1\xf8\xc3\xdd\x65\x04\x58\x3e\xff\x32\xf3\x7e\xf9\xbf\x00\x00\x00\xff\xff\x8f\x81\x37\x9d\xd7\x29\x00\x00") func vdltoolConfigVdlBytes() ([]byte, error) { return bindataRead( @@ -201,7 +201,7 @@ func vdltoolConfigVdl() (*asset, error) { // It returns an error if the asset could not be found or // could not be loaded. func Asset(name string) ([]byte, error) { - cannonicalName := strings.ReplaceAll(name, "\\", "/") + cannonicalName := strings.Replace(name, "\\", "/", -1) if f, ok := _bindata[cannonicalName]; ok { a, err := f() if err != nil { @@ -227,7 +227,7 @@ func MustAsset(name string) []byte { // It returns an error if the asset could not be found or // could not be loaded. func AssetInfo(name string) (os.FileInfo, error) { - cannonicalName := strings.ReplaceAll(name, "\\", "/") + cannonicalName := strings.Replace(name, "\\", "/", -1) if f, ok := _bindata[cannonicalName]; ok { a, err := f() if err != nil { @@ -273,7 +273,7 @@ var _bindata = map[string]func() (*asset, error){ func AssetDir(name string) ([]string, error) { node := _bintree if len(name) != 0 { - cannonicalName := strings.ReplaceAll(name, "\\", "/") + cannonicalName := strings.Replace(name, "\\", "/", -1) pathList := strings.Split(cannonicalName, "/") for _, p := range pathList { node = node.Children[p] @@ -357,6 +357,6 @@ func RestoreAssets(dir, name string) error { } func _filePath(dir, name string) string { - cannonicalName := strings.ReplaceAll(name, "\\", "/") + cannonicalName := strings.Replace(name, "\\", "/", -1) return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) } diff --git a/x/ref/lib/vdl/codegen/golang/type.go b/x/ref/lib/vdl/codegen/golang/type.go index 4d66cec26..ce255563c 100644 --- a/x/ref/lib/vdl/codegen/golang/type.go +++ b/x/ref/lib/vdl/codegen/golang/type.go @@ -180,129 +180,163 @@ func goAnyRepMode(pkg *compile.Package) goAnyRep { return goAnyRepRawBytes } +func genEnumType(data *goData, def *compile.TypeDef) string { + t := def.Type + s := &strings.Builder{} + fmt.Fprintf(s, "%stype %s int%s\nconst (", def.Doc, def.Name, def.DocSuffix) + for ix := 0; ix < t.NumEnumLabel(); ix++ { + fmt.Fprintf(s, "\n\t%s%s%s", def.LabelDoc[ix], def.Name, t.EnumLabel(ix)) + if ix == 0 { + fmt.Fprintf(s, " %s = iota", def.Name) + } + s.WriteString(def.LabelDocSuffix[ix]) + } + disableGoCycloLint := "" + if t.NumEnumLabel() > 10 { + disableGoCycloLint = "//nolint:gocyclo" + } + fmt.Fprintf(s, "\n)"+ + "\n\n// %[1]sAll holds all labels for %[1]s."+ + "\nvar %[1]sAll = [...]%[1]s{%[2]s}"+ + "\n\n// %[1]sFromString creates a %[1]s from a string label."+ + "\n//nolint:deadcode,unused"+ + "\nfunc %[1]sFromString(label string) (x %[1]s, err error) {"+ + "\n\terr = x.Set(label)"+ + "\n\treturn"+ + "\n}"+ + "\n\n// Set assigns label to x."+ + "\nfunc (x *%[1]s) Set(label string) error {"+ + disableGoCycloLint+ + "\n\tswitch label {", + def.Name, + commaEnumLabels(def.Name, t)) + for ix := 0; ix < t.NumEnumLabel(); ix++ { + fmt.Fprintf(s, "\n\tcase %[2]q, %[3]q:"+ + "\n\t\t*x = %[1]s%[2]s"+ + "\n\t\treturn nil", def.Name, t.EnumLabel(ix), strings.ToLower(t.EnumLabel(ix))) + } + fmt.Fprintf(s, "\n\t}"+ + "\n\t*x = -1"+ + "\n\treturn "+data.Pkg("fmt")+"Errorf(\"unknown label %%q in %[2]s\", label)"+ + "\n}"+ + "\n\n// String returns the string label of x."+ + "\nfunc (x %[1]s) String() string {"+ + disableGoCycloLint+ + "\n\tswitch x {", def.Name, packageIdent(def.File, def.Name)) + for ix := 0; ix < t.NumEnumLabel(); ix++ { + fmt.Fprintf(s, "\n\tcase %[1]s%[2]s:"+ + "\n\t\treturn %[2]q", def.Name, t.EnumLabel(ix)) + } + fmt.Fprintf(s, "\n\t}"+ + "\n\treturn \"\""+ + "\n}"+ + "\n\nfunc (%[1]s) VDLReflect(struct{"+ + "\n\tName string `vdl:%[3]q`"+ + "\n\tEnum struct{ %[2]s string }"+ + "\n}) {"+ + "\n}", + def.Name, commaEnumLabels("", t), qualifiedIdent(def.File, def.Name)) + return s.String() +} + +func genStructType(data *goData, def *compile.TypeDef) string { + t := def.Type + var structTags map[string][]vdltool.GoStructTag + if data.Package != nil && data.Package.Config.Go.StructTags != nil { + structTags = data.Package.Config.Go.StructTags + } + if structTags == nil { + structTags = map[string][]vdltool.GoStructTag{} + } + s := &strings.Builder{} + fmt.Fprintf(s, "%stype %s struct {", def.Doc, def.Name) + for ix := 0; ix < t.NumField(); ix++ { + f := t.Field(ix) + fmt.Fprintf(s, "\n\t%s %s", def.FieldDoc[ix]+f.Name, typeGo(data, f.Type)+def.FieldDocSuffix[ix]) + if tags, ok := structTags[def.Name]; ok { + for _, tag := range tags { + if tag.Field == f.Name { + s.WriteString(" `" + tag.Tag + "`") + } + } + } + } + fmt.Fprintf(s, "\n}%s", def.DocSuffix) + fmt.Fprintf(s, "\n"+ + "\nfunc (%[1]s) VDLReflect(struct{"+ + "\n\tName string `vdl:%[2]q`"+ + "\n}) {"+ + "\n}", + def.Name, qualifiedIdent(def.File, def.Name)) + return s.String() +} + +func genUnionType(data *goData, def *compile.TypeDef) string { + t := def.Type + s := &strings.Builder{} + fmt.Fprintf(s, "type ("+ + "\n\t// %[1]s represents any single field of the %[1]s union type."+ + "\n\t%[2]s%[1]s interface {"+ + "\n\t\t// Index returns the field index."+ + "\n\t\tIndex() int"+ + "\n\t\t// Interface returns the field value as an interface."+ + "\n\t\tInterface() interface{}"+ + "\n\t\t// Name returns the field name."+ + "\n\t\tName() string"+ + "\n\t\t// VDLReflect describes the %[1]s union type."+ + "\n\t\tVDLReflect(vdl%[1]sReflect)", def.Name, docBreak(def.Doc)) + if !data.SkipGenZeroReadWrite(def) { + fmt.Fprintf(s, "\n\t\tVDLIsZero() bool"+ + "\n\t\tVDLWrite(%[1]sEncoder) error", data.Pkg("v.io/v23/vdl")) + } + fmt.Fprintf(s, "\n\t}%[1]s", def.DocSuffix) + for ix := 0; ix < t.NumField(); ix++ { + f := t.Field(ix) + fmt.Fprintf(s, "\n\t// %[1]s%[2]s represents field %[2]s of the %[1]s union type."+ + "\n\t%[4]s%[1]s%[2]s struct{ Value %[3]s }%[5]s", + def.Name, f.Name, typeGo(data, f.Type), + docBreak(def.FieldDoc[ix]), def.FieldDocSuffix[ix]) + } + fmt.Fprintf(s, "\n\t// vdl%[1]sReflect describes the %[1]s union type."+ + "\n\tvdl%[1]sReflect struct {"+ + "\n\t\tName string `vdl:%[2]q`"+ + "\n\t\tType %[1]s", def.Name, qualifiedIdent(def.File, def.Name)) + s.WriteString("\n\t\tUnion struct {") + for ix := 0; ix < t.NumField(); ix++ { + fmt.Fprintf(s, "\n\t\t\t%[2]s %[1]s%[2]s", def.Name, t.Field(ix).Name) + } + s.WriteString("\n\t\t}\n\t}\n)") + for ix := 0; ix < t.NumField(); ix++ { + f := t.Field(ix) + fmt.Fprintf(s, "\n\nfunc (x %[1]s%[2]s) Index() int { return %[3]d }"+ + "\nfunc (x %[1]s%[2]s) Interface() interface{} { return x.Value }"+ + "\nfunc (x %[1]s%[2]s) Name() string { return \"%[2]s\" }"+ + "\nfunc (x %[1]s%[2]s) VDLReflect(vdl%[1]sReflect) {}", + def.Name, f.Name, ix) + } + return s.String() +} + // defineType returns the type definition for def. func defineType(data *goData, def *compile.TypeDef) string { - s := fmt.Sprintf("%stype %s ", def.Doc, def.Name) switch t := def.Type; t.Kind() { case vdl.Enum: - s += fmt.Sprintf("int%s\nconst (", def.DocSuffix) - for ix := 0; ix < t.NumEnumLabel(); ix++ { - s += fmt.Sprintf("\n\t%s%s%s", def.LabelDoc[ix], def.Name, t.EnumLabel(ix)) - if ix == 0 { - s += fmt.Sprintf(" %s = iota", def.Name) - } - s += def.LabelDocSuffix[ix] - } - disableGoCycloLint := "" - if t.NumEnumLabel() > 10 { - disableGoCycloLint = "//nolint:gocyclo" - } - s += fmt.Sprintf("\n)"+ - "\n\n// %[1]sAll holds all labels for %[1]s."+ - "\nvar %[1]sAll = [...]%[1]s{%[2]s}"+ - "\n\n// %[1]sFromString creates a %[1]s from a string label."+ - "\n//nolint:deadcode,unused"+ - "\nfunc %[1]sFromString(label string) (x %[1]s, err error) {"+ - "\n\terr = x.Set(label)"+ - "\n\treturn"+ - "\n}"+ - "\n\n// Set assigns label to x."+ - "\nfunc (x *%[1]s) Set(label string) error {"+ - disableGoCycloLint+ - "\n\tswitch label {", - def.Name, - commaEnumLabels(def.Name, t)) - for ix := 0; ix < t.NumEnumLabel(); ix++ { - s += fmt.Sprintf("\n\tcase %[2]q, %[3]q:"+ - "\n\t\t*x = %[1]s%[2]s"+ - "\n\t\treturn nil", def.Name, t.EnumLabel(ix), strings.ToLower(t.EnumLabel(ix))) - } - s += fmt.Sprintf("\n\t}"+ - "\n\t*x = -1"+ - "\n\treturn "+data.Pkg("fmt")+"Errorf(\"unknown label %%q in %[2]s\", label)"+ - "\n}"+ - "\n\n// String returns the string label of x."+ - "\nfunc (x %[1]s) String() string {"+ - disableGoCycloLint+ - "\n\tswitch x {", def.Name, packageIdent(def.File, def.Name)) - for ix := 0; ix < t.NumEnumLabel(); ix++ { - s += fmt.Sprintf("\n\tcase %[1]s%[2]s:"+ - "\n\t\treturn %[2]q", def.Name, t.EnumLabel(ix)) - } - s += fmt.Sprintf("\n\t}"+ - "\n\treturn \"\""+ - "\n}"+ - "\n\nfunc (%[1]s) VDLReflect(struct{"+ - "\n\tName string `vdl:%[3]q`"+ - "\n\tEnum struct{ %[2]s string }"+ - "\n}) {"+ - "\n}", - def.Name, commaEnumLabels("", t), qualifiedIdent(def.File, def.Name)) + return genEnumType(data, def) case vdl.Struct: - s += "struct {" - for ix := 0; ix < t.NumField(); ix++ { - f := t.Field(ix) - s += "\n\t" + def.FieldDoc[ix] + f.Name + " " - s += typeGo(data, f.Type) + def.FieldDocSuffix[ix] - } - s += "\n}" + def.DocSuffix - s += fmt.Sprintf("\n"+ - "\nfunc (%[1]s) VDLReflect(struct{"+ - "\n\tName string `vdl:%[2]q`"+ - "\n}) {"+ - "\n}", - def.Name, qualifiedIdent(def.File, def.Name)) + return genStructType(data, def) case vdl.Union: - s = fmt.Sprintf("type ("+ - "\n\t// %[1]s represents any single field of the %[1]s union type."+ - "\n\t%[2]s%[1]s interface {"+ - "\n\t\t// Index returns the field index."+ - "\n\t\tIndex() int"+ - "\n\t\t// Interface returns the field value as an interface."+ - "\n\t\tInterface() interface{}"+ - "\n\t\t// Name returns the field name."+ - "\n\t\tName() string"+ - "\n\t\t// VDLReflect describes the %[1]s union type."+ - "\n\t\tVDLReflect(vdl%[1]sReflect)", def.Name, docBreak(def.Doc)) - if !data.SkipGenZeroReadWrite(def) { - s += fmt.Sprintf("\n\t\tVDLIsZero() bool"+ - "\n\t\tVDLWrite(%[1]sEncoder) error", data.Pkg("v.io/v23/vdl")) - } - s += fmt.Sprintf("\n\t}%[1]s", def.DocSuffix) - for ix := 0; ix < t.NumField(); ix++ { - f := t.Field(ix) - s += fmt.Sprintf("\n\t// %[1]s%[2]s represents field %[2]s of the %[1]s union type."+ - "\n\t%[4]s%[1]s%[2]s struct{ Value %[3]s }%[5]s", - def.Name, f.Name, typeGo(data, f.Type), - docBreak(def.FieldDoc[ix]), def.FieldDocSuffix[ix]) - } - s += fmt.Sprintf("\n\t// vdl%[1]sReflect describes the %[1]s union type."+ - "\n\tvdl%[1]sReflect struct {"+ - "\n\t\tName string `vdl:%[2]q`"+ - "\n\t\tType %[1]s", def.Name, qualifiedIdent(def.File, def.Name)) - s += "\n\t\tUnion struct {" - for ix := 0; ix < t.NumField(); ix++ { - s += fmt.Sprintf("\n\t\t\t%[2]s %[1]s%[2]s", def.Name, t.Field(ix).Name) - } - s += "\n\t\t}\n\t}\n)" - for ix := 0; ix < t.NumField(); ix++ { - f := t.Field(ix) - s += fmt.Sprintf("\n\nfunc (x %[1]s%[2]s) Index() int { return %[3]d }"+ - "\nfunc (x %[1]s%[2]s) Interface() interface{} { return x.Value }"+ - "\nfunc (x %[1]s%[2]s) Name() string { return \"%[2]s\" }"+ - "\nfunc (x %[1]s%[2]s) VDLReflect(vdl%[1]sReflect) {}", - def.Name, f.Name, ix) - } + return genUnionType(data, def) default: - s += typeGo(data, def.BaseType) + def.DocSuffix - s += fmt.Sprintf("\n"+ + s := &strings.Builder{} + fmt.Fprintf(s, "%stype %s %s", def.Doc, def.Name, typeGo(data, def.BaseType)+def.DocSuffix) + fmt.Fprintf(s, "\n"+ "\nfunc (%[1]s) VDLReflect(struct{"+ "\n\tName string `vdl:%[2]q`"+ "\n}) {"+ "\n}", def.Name, qualifiedIdent(def.File, def.Name)) + return s.String() } - return s } func commaEnumLabels(prefix string, t *vdl.Type) (s string) { diff --git a/x/ref/lib/vdl/codegen/golang/type_test.go b/x/ref/lib/vdl/codegen/golang/type_test.go index 9bc7daa9a..bc82383d2 100644 --- a/x/ref/lib/vdl/codegen/golang/type_test.go +++ b/x/ref/lib/vdl/codegen/golang/type_test.go @@ -5,11 +5,15 @@ package golang import ( + "bufio" + "fmt" + "strings" "testing" "unicode" "unicode/utf8" "v.io/v23/vdl" + "v.io/v23/vdlroot/vdltool" "v.io/x/ref/lib/vdl/compile" ) @@ -47,9 +51,7 @@ func TestType(t *testing.T) { } } -// TODO(bprosnitz) Disabled because frustrating while making changes. Either re-enable and fix output or re-write this test. -//nolint:deadcode,unused -func disabledTestTypeDef(t *testing.T) { +func TestTypeDef(t *testing.T) { testingMode = true tests := []struct { T *vdl.Type @@ -66,6 +68,7 @@ const ( var TestEnumAll = [...]TestEnum{TestEnumA, TestEnumB, TestEnumC} // TestEnumFromString creates a TestEnum from a string label. +//nolint:deadcode,unused func TestEnumFromString(label string) (x TestEnum, err error) { err = x.Set(label) return @@ -105,17 +108,6 @@ func (TestEnum) VDLReflect(struct{ Name string ` + "`" + `vdl:"TestEnum"` + "`" + ` Enum struct{ A, B, C string } }) { -} - -func (m TestEnum) FillVDLTarget(t vdl.Target, tt *vdl.Type) error { - if err := t.FromEnumLabel(m.String(), __VDLType__TestEnum); err != nil { - return err - } - return nil -} - -func (m TestEnum) MakeVDLTarget() vdl.Target { - return nil }`}, {tUnion, `type ( // TestUnion represents any single field of the TestUnion union type. @@ -127,15 +119,16 @@ func (m TestEnum) MakeVDLTarget() vdl.Target { // Name returns the field name. Name() string // VDLReflect describes the TestUnion union type. - VDLReflect(__TestUnionReflect) - FillVDLTarget(vdl.Target, *vdl.Type) error + VDLReflect(vdlTestUnionReflect) + VDLIsZero() bool + VDLWrite(vdl.Encoder) error } // TestUnionA represents field A of the TestUnion union type. TestUnionA struct{ Value string } // TestUnionB represents field B of the TestUnion union type. TestUnionB struct{ Value int64 } - // __TestUnionReflect describes the TestUnion union type. - __TestUnionReflect struct { + // vdlTestUnionReflect describes the TestUnion union type. + vdlTestUnionReflect struct { Name string ` + "`" + `vdl:"TestUnion"` + "`" + ` Type TestUnion Union struct { @@ -148,65 +141,21 @@ func (m TestEnum) MakeVDLTarget() vdl.Target { func (x TestUnionA) Index() int { return 0 } func (x TestUnionA) Interface() interface{} { return x.Value } func (x TestUnionA) Name() string { return "A" } -func (x TestUnionA) VDLReflect(__TestUnionReflect) {} - -func (m TestUnionA) FillVDLTarget(t vdl.Target, tt *vdl.Type) error { -` + "\t" + ` - fieldsTarget1, err := t.StartFields(__VDLType__TestUnion) - if err != nil { - return err - } - keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("A") - if err != nil { - return err - } - if err := fieldTarget3.FromString(string(m.Value), vdl.StringType); err != nil { - return err -} - if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil { - return err - } - if err := t.FinishFields(fieldsTarget1); err != nil { - return err - } -` + "\t" + ` - return nil -} - -func (m TestUnionA) MakeVDLTarget() vdl.Target { - return nil -} +func (x TestUnionA) VDLReflect(vdlTestUnionReflect) {} func (x TestUnionB) Index() int { return 1 } func (x TestUnionB) Interface() interface{} { return x.Value } func (x TestUnionB) Name() string { return "B" } -func (x TestUnionB) VDLReflect(__TestUnionReflect) {} - -func (m TestUnionB) FillVDLTarget(t vdl.Target, tt *vdl.Type) error { -` + "\t" + ` - fieldsTarget1, err := t.StartFields(__VDLType__TestUnion) - if err != nil { - return err - } - keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("B") - if err != nil { - return err - } - if err := fieldTarget3.FromInt(int64(m.Value), vdl.Int64Type); err != nil { - return err -} - if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil { - return err - } - if err := t.FinishFields(fieldsTarget1); err != nil { - return err - } -` + "\t" + ` - return nil +func (x TestUnionB) VDLReflect(vdlTestUnionReflect) {}`}, + {tStruct, `type TestStruct struct { + A string + B int64 + C int64 } -func (m TestUnionB) MakeVDLTarget() vdl.Target { - return nil +func (TestStruct) VDLReflect(struct{ + Name string ` + "`" + `vdl:"TestStruct"` + "`" + ` +}) { }`}, } data := &goData{ @@ -215,24 +164,55 @@ func (m TestUnionB) MakeVDLTarget() vdl.Target { createdTargets: make(map[*vdl.Type]bool), } for _, test := range tests { - firstLetter, _ := utf8.DecodeRuneInString(test.T.Name()) - def := &compile.TypeDef{ - NamePos: compile.NamePos{Name: test.T.Name()}, - Type: test.T, - Exported: unicode.IsUpper(firstLetter), + if got, want := defineTypeForTest(data, test.T), test.Want; got != want { + diffLines(got, want) + t.Errorf("%s\n GOT %s\nWANT %s", test.T, got, want) } - switch test.T.Kind() { - case vdl.Enum: - def.LabelDoc = make([]string, test.T.NumEnumLabel()) - def.LabelDocSuffix = make([]string, test.T.NumEnumLabel()) - case vdl.Struct, vdl.Union: - def.FieldDoc = make([]string, test.T.NumField()) - def.FieldDocSuffix = make([]string, test.T.NumField()) + } +} + +func defineTypeForTest(data *goData, vdlType *vdl.Type) string { + firstLetter, _ := utf8.DecodeRuneInString(vdlType.Name()) + def := &compile.TypeDef{ + NamePos: compile.NamePos{Name: vdlType.Name()}, + Type: vdlType, + Exported: unicode.IsUpper(firstLetter), + } + switch vdlType.Kind() { + case vdl.Enum: + def.LabelDoc = make([]string, vdlType.NumEnumLabel()) + def.LabelDocSuffix = make([]string, vdlType.NumEnumLabel()) + case vdl.Struct, vdl.Union: + def.FieldDoc = make([]string, vdlType.NumField()) + def.FieldDocSuffix = make([]string, vdlType.NumField()) + } + return defineType(data, def) +} + +func diffLines(a, b string) { + fmt.Printf("len(a) %d len(b) %d\n", len(a), len(b)) + sa := bufio.NewScanner(strings.NewReader(a)) + sb := bufio.NewScanner(strings.NewReader(b)) + + index := 0 + for { + index++ + var readSomething bool + var aline string + var bline string + if sa.Scan() { + aline = sa.Text() + readSomething = true } - if got, want := defineType(data, def), test.Want; got != want { - // TIP: Try https://gist.github.com/bprosnitz/60d93bdcc53d8148b8f9 for debugging - // invisible differences. - t.Errorf("%s\n GOT %s\nWANT %s", test.T, got, want) + if sb.Scan() { + bline = sb.Text() + readSomething = true + } + if !readSomething { + break + } + if aline != bline { + fmt.Printf("%4d:\ngot:\n%s\nwant:\n%s\n", index, aline, bline) } } } @@ -253,6 +233,10 @@ var ( Name: "B", Type: vdl.Int64Type, }, + vdl.Field{ + Name: "C", + Type: vdl.Int64Type, + }, )) tUnion = vdl.NamedType("TestUnion", vdl.UnionType( vdl.Field{ @@ -265,3 +249,46 @@ var ( }, )) ) + +func TestStructTags(t *testing.T) { + testingMode = true + + tagA := `json:"a,omitempty" other:"a,,'a quoted'"` + tagB := `json:"b" other:"b,,'b quoted'"` + + withTags := &goData{ + Env: compile.NewEnv(-1), + Package: &compile.Package{ + Config: vdltool.Config{ + Go: vdltool.GoConfig{ + StructTags: map[string][]vdltool.GoStructTag{ + "TestStruct": { + {Field: "A", Tag: tagA}, + {Field: "B", Tag: tagB}, + }, + }, + }, + }, + }, + } + noTags := &goData{Env: compile.NewEnv(-1)} + + typeDefWithTags := defineTypeForTest(withTags, tStruct) + typeDefNoTags := defineTypeForTest(noTags, tStruct) + for _, tag := range []string{ + "A string `" + tagA + "`\n", + "B int64 `" + tagB + "`\n", + } { + if !strings.Contains(typeDefWithTags, tag) { + t.Errorf("missing tag: %v", tag) + } + if strings.Contains(typeDefNoTags, tag) { + t.Errorf("contains tag: %v", tag) + } + } + for _, def := range []string{typeDefWithTags, typeDefNoTags} { + if !strings.Contains(def, "C int64\n") { + t.Errorf("missing field") + } + } +} diff --git a/x/ref/lib/vdl/parse/grammar.y.go b/x/ref/lib/vdl/parse/grammar.y.go index f943f2385..1c980d5ac 100644 --- a/x/ref/lib/vdl/parse/grammar.y.go +++ b/x/ref/lib/vdl/parse/grammar.y.go @@ -9,14 +9,15 @@ package parse +import __yyfmt__ "fmt" + +//line grammar.y:20 + import ( - __yyfmt__ "fmt" "math/big" "strings" ) -//line grammar.y:20 - type intPos struct { int *big.Int pos Pos diff --git a/x/ref/runtime/internal/rpc/requestid.go b/x/ref/runtime/internal/rpc/requestid.go index d58d35357..2f2197a67 100644 --- a/x/ref/runtime/internal/rpc/requestid.go +++ b/x/ref/runtime/internal/rpc/requestid.go @@ -1,3 +1,7 @@ +// Copyright 2020 The Vanadium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package rpc import ( diff --git a/x/ref/services/ben/benarchd/internal/assets/assets.go b/x/ref/services/ben/benarchd/internal/assets/assets.go index 1eecf6bbc..d0a249813 100644 --- a/x/ref/services/ben/benarchd/internal/assets/assets.go +++ b/x/ref/services/ben/benarchd/internal/assets/assets.go @@ -289,7 +289,7 @@ func stylingTmplHtml() (*asset, error) { // It returns an error if the asset could not be found or // could not be loaded. func Asset(name string) ([]byte, error) { - cannonicalName := strings.ReplaceAll(name, "\\", "/") + cannonicalName := strings.Replace(name, "\\", "/", -1) if f, ok := _bindata[cannonicalName]; ok { a, err := f() if err != nil { @@ -315,7 +315,7 @@ func MustAsset(name string) []byte { // It returns an error if the asset could not be found or // could not be loaded. func AssetInfo(name string) (os.FileInfo, error) { - cannonicalName := strings.ReplaceAll(name, "\\", "/") + cannonicalName := strings.Replace(name, "\\", "/", -1) if f, ok := _bindata[cannonicalName]; ok { a, err := f() if err != nil { @@ -365,7 +365,7 @@ var _bindata = map[string]func() (*asset, error){ func AssetDir(name string) ([]string, error) { node := _bintree if len(name) != 0 { - cannonicalName := strings.ReplaceAll(name, "\\", "/") + cannonicalName := strings.Replace(name, "\\", "/", -1) pathList := strings.Split(cannonicalName, "/") for _, p := range pathList { node = node.Children[p] @@ -445,6 +445,6 @@ func RestoreAssets(dir, name string) error { } func _filePath(dir, name string) string { - cannonicalName := strings.ReplaceAll(name, "\\", "/") + cannonicalName := strings.Replace(name, "\\", "/", -1) return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) } diff --git a/x/ref/services/debug/debug/browseserver/assets.go b/x/ref/services/debug/debug/browseserver/assets.go index 8e2ee9990..278e1ead1 100644 --- a/x/ref/services/debug/debug/browseserver/assets.go +++ b/x/ref/services/debug/debug/browseserver/assets.go @@ -285,7 +285,7 @@ func vtraceHtml() (*asset, error) { // It returns an error if the asset could not be found or // could not be loaded. func Asset(name string) ([]byte, error) { - cannonicalName := strings.ReplaceAll(name, "\\", "/") + cannonicalName := strings.Replace(name, "\\", "/", -1) if f, ok := _bindata[cannonicalName]; ok { a, err := f() if err != nil { @@ -311,7 +311,7 @@ func MustAsset(name string) []byte { // It returns an error if the asset could not be found or // could not be loaded. func AssetInfo(name string) (os.FileInfo, error) { - cannonicalName := strings.ReplaceAll(name, "\\", "/") + cannonicalName := strings.Replace(name, "\\", "/", -1) if f, ok := _bindata[cannonicalName]; ok { a, err := f() if err != nil { @@ -361,7 +361,7 @@ var _bindata = map[string]func() (*asset, error){ func AssetDir(name string) ([]string, error) { node := _bintree if len(name) != 0 { - cannonicalName := strings.ReplaceAll(name, "\\", "/") + cannonicalName := strings.Replace(name, "\\", "/", -1) pathList := strings.Split(cannonicalName, "/") for _, p := range pathList { node = node.Children[p] @@ -386,16 +386,16 @@ type bintree struct { } var _bintree = &bintree{nil, map[string]*bintree{ - "alltrace.html": {alltraceHtml, map[string]*bintree{}}, - "blessings.html": {blessingsHtml, map[string]*bintree{}}, - "chrome.html": {chromeHtml, map[string]*bintree{}}, - "collection.html": {collectionHtml, map[string]*bintree{}}, - "glob.html": {globHtml, map[string]*bintree{}}, - "logs.html": {logsHtml, map[string]*bintree{}}, - "profiles.html": {profilesHtml, map[string]*bintree{}}, - "resolve.html": {resolveHtml, map[string]*bintree{}}, - "stats.html": {statsHtml, map[string]*bintree{}}, - "vtrace.html": {vtraceHtml, map[string]*bintree{}}, + "alltrace.html": &bintree{alltraceHtml, map[string]*bintree{}}, + "blessings.html": &bintree{blessingsHtml, map[string]*bintree{}}, + "chrome.html": &bintree{chromeHtml, map[string]*bintree{}}, + "collection.html": &bintree{collectionHtml, map[string]*bintree{}}, + "glob.html": &bintree{globHtml, map[string]*bintree{}}, + "logs.html": &bintree{logsHtml, map[string]*bintree{}}, + "profiles.html": &bintree{profilesHtml, map[string]*bintree{}}, + "resolve.html": &bintree{resolveHtml, map[string]*bintree{}}, + "stats.html": &bintree{statsHtml, map[string]*bintree{}}, + "vtrace.html": &bintree{vtraceHtml, map[string]*bintree{}}, }} // RestoreAsset restores an asset under the given directory @@ -441,6 +441,6 @@ func RestoreAssets(dir, name string) error { } func _filePath(dir, name string) string { - cannonicalName := strings.ReplaceAll(name, "\\", "/") + cannonicalName := strings.Replace(name, "\\", "/", -1) return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) }