Skip to content

Commit

Permalink
Release v1.19.0 (#412)
Browse files Browse the repository at this point in the history
This releases ThriftRW Go v1.19.0 which includes support for the
`go.type = "slice"` annotation on set types.

Code was regenerated with `make generate`.

I also fixed a typo in the `make verifyversion` target which made it
print its name as yarpc-go instead of thriftrw-go.
  • Loading branch information
abhinav authored Apr 26, 2019
2 parents 4b5c9b2 + 108d69c commit 8c0d416
Show file tree
Hide file tree
Showing 65 changed files with 1,623 additions and 62 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.19.0] - 2019-04-26
- Sets now support a `(go.type = "slice")` annotation to be generated as
slices rather than maps.

## [1.18.0] - 2019-03-28
### Added
- `Ptr` methods for primititve typedefs.
Expand Down Expand Up @@ -275,7 +279,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Initial release.

[Unreleased]: https://github.com/thriftrw/thriftrw-go/compare/v1.17.0...HEAD
[1.19.0]: https://github.com/thriftrw/thriftrw-go/compare/v1.18.0...v1.19.0
[1.18.0]: https://github.com/thriftrw/thriftrw-go/compare/v1.17.0...v1.18.0
[1.17.0]: https://github.com/thriftrw/thriftrw-go/compare/v1.16.1...v1.17.0
[1.16.1]: https://github.com/thriftrw/thriftrw-go/compare/v1.16.0...v1.16.1
[1.16.0]: https://github.com/thriftrw/thriftrw-go/compare/v1.15.0...v1.16.0
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ verifyversion: build
$(eval CHANGELOG_VERSION := $(shell perl -ne '/^## \[(\S+?)\]/ && print "v$$1\n"' CHANGELOG.md | head -n1))
$(eval INTHECODE_VERSION := $(shell perl -ne '/^const Version.*"([^"]+)".*$$/ && print "v$$1\n"' version/version.go))
@if [ "$(INTHECODE_VERSION)" = "$(CHANGELOG_VERSION)" ]; then \
echo "yarpc-go: $(CHANGELOG_VERSION)"; \
echo "thriftrw-go: $(CHANGELOG_VERSION)"; \
elif [ "$(CHANGELOG_VERSION)" = "vUnreleased" ]; then \
echo "yarpc-go (development): $(INTHECODE_VERSION)"; \
echo "thriftrw-go (development): $(INTHECODE_VERSION)"; \
else \
echo "Version number in version/version.go does not match CHANGELOG.md"; \
echo "version/version.go: $(INTHECODE_VERSION)"; \
Expand Down
9 changes: 6 additions & 3 deletions gen/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,26 @@ func constantMap(g Generator, v compile.ConstantMap, t compile.TypeSpec) (string
}

func constantSet(g Generator, v compile.ConstantSet, t compile.TypeSpec) (string, error) {
valueSpec := compile.RootTypeSpec(t).(*compile.SetSpec).ValueSpec
rootSpec := compile.RootTypeSpec(t).(*compile.SetSpec)
valueSpec := rootSpec.ValueSpec
return g.TextTemplate(
`
<- $rootSpec := .RootSpec ->
<- $valueType := .ValueSpec ->
<- typeReference .Spec>{
<range .Value>
<- if isHashable $valueType ->
<- if setUsesMap $rootSpec ->
<constantValue . $valueType>: struct{}{},
<- else ->
<constantValue . $valueType>,
<- end>
<end>
}`, struct {
RootSpec *compile.SetSpec
Spec compile.TypeSpec
ValueSpec compile.TypeSpec
Value compile.ConstantSet
}{Spec: t, ValueSpec: valueSpec, Value: v},
}{RootSpec: rootSpec, Spec: t, ValueSpec: valueSpec, Value: v},
TemplateFunc("constantValue", ConstantValue))
}

Expand Down
11 changes: 11 additions & 0 deletions gen/constant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
te "go.uber.org/thriftrw/gen/internal/tests/enums"
tx "go.uber.org/thriftrw/gen/internal/tests/exceptions"
tok "go.uber.org/thriftrw/gen/internal/tests/other_constants"
tss "go.uber.org/thriftrw/gen/internal/tests/set_to_slice"
ts "go.uber.org/thriftrw/gen/internal/tests/structs"
td "go.uber.org/thriftrw/gen/internal/tests/typedefs"
tu "go.uber.org/thriftrw/gen/internal/tests/unions"
Expand Down Expand Up @@ -288,6 +289,16 @@ func TestConstants(t *testing.T) {
tk.MyEnum,
td.MyEnum(te.EnumWithValuesY),
},
{
"setToSlice",
tss.ConstStringList,
[]string{"hello"},
},
{
"setToSliceNested",
tss.ConstListStringList,
[][]string{{"hello"}, {"world"}},
},
}

for _, tt := range tests {
Expand Down
1 change: 1 addition & 0 deletions gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func (g *generator) TextTemplate(s string, data interface{}, opts ...TemplateOpt
"goName": goName,
"import": g.Import,
"isHashable": isHashable,
"setUsesMap": setUsesMap,
"isPrimitiveType": isPrimitiveType,
"isStructType": isStructType,
"newNamespace": g.Namespace.Child,
Expand Down
35 changes: 35 additions & 0 deletions gen/gotype.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2019 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package gen

const (
// goTypeKey is a Thrift annotation that allows overriding the type of
// a typedef target type or a struct field type. By default, thrift set type
// corresponds to go map type. Following annotation on a typedef target type
// or struct field type, where the type is direct set type, causes thriftrw
// to generate go code with slice type instead of the default map type.
//
// (go.type = "slice")
//
// Currently, only thrift set to go slice type overriding is supported.
goTypeKey = "go.type"
sliceType = "slice"
)
2 changes: 1 addition & 1 deletion gen/internal/tests/collision/constants.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/collision/idl.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/collision/types.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/constants/constants.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/constants/idl.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/containers/idl.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/containers/types.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/enum_conflict/constants.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/enum_conflict/idl.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/enum_conflict/types.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/enums/idl.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/enums/types.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/exceptions/idl.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/exceptions/types.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/nozap/idl.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/nozap/types.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/other_constants/constants.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/other_constants/idl.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/services/cache_clear.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/services/cache_clearafter.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/services/conflictingnames_setvalue.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/services/idl.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/services/keyvalue_deletevalue.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/services/keyvalue_getmanyvalues.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/services/keyvalue_getvalue.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/services/keyvalue_setvalue.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/services/keyvalue_setvaluev2.go

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

2 changes: 1 addition & 1 deletion gen/internal/tests/services/keyvalue_size.go

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

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

2 changes: 1 addition & 1 deletion gen/internal/tests/services/types.go

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

19 changes: 19 additions & 0 deletions gen/internal/tests/set_to_slice/constants.go

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

17 changes: 17 additions & 0 deletions gen/internal/tests/set_to_slice/idl.go

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

Loading

0 comments on commit 8c0d416

Please sign in to comment.