Skip to content

Commit

Permalink
rename internal to utilties for 1.5 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
tmc committed Aug 13, 2015
1 parent d78477d commit a17462a
Show file tree
Hide file tree
Showing 20 changed files with 223 additions and 223 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ GO_PLUGIN=bin/protoc-gen-go
GO_PLUGIN_PKG=github.com/golang/protobuf/protoc-gen-go
GATEWAY_PLUGIN=bin/protoc-gen-grpc-gateway
GATEWAY_PLUGIN_PKG=$(PKG)/protoc-gen-grpc-gateway
GATEWAY_PLUGIN_SRC= internal/doc.go \
internal/name.go \
internal/pattern.go \
GATEWAY_PLUGIN_SRC= utilities/doc.go \
utilities/name.go \
utilities/pattern.go \
protoc-gen-grpc-gateway/descriptor/registry.go \
protoc-gen-grpc-gateway/descriptor/services.go \
protoc-gen-grpc-gateway/descriptor/types.go \
Expand Down
8 changes: 4 additions & 4 deletions examples/a_bit_of_everything.pb.gw.go

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

4 changes: 2 additions & 2 deletions examples/echo_service.pb.gw.go

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

2 changes: 0 additions & 2 deletions internal/doc.go

This file was deleted.

8 changes: 4 additions & 4 deletions protoc-gen-grpc-gateway/descriptor/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/gengo/grpc-gateway/internal"
"github.com/gengo/grpc-gateway/utilities"
"github.com/gengo/grpc-gateway/protoc-gen-grpc-gateway/httprule"
descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
)
Expand Down Expand Up @@ -233,15 +233,15 @@ type FieldPathComponent struct {

// RHS returns a right-hand-side expression in go for this field.
func (c FieldPathComponent) RHS() string {
return internal.PascalFromSnake(c.Name)
return utilities.PascalFromSnake(c.Name)
}

// LHS returns a left-hand-side expression in go for this field.
func (c FieldPathComponent) LHS() string {
if c.Target.Message.File.proto2() {
return fmt.Sprintf("Get%s()", internal.PascalFromSnake(c.Name))
return fmt.Sprintf("Get%s()", utilities.PascalFromSnake(c.Name))
}
return internal.PascalFromSnake(c.Name)
return utilities.PascalFromSnake(c.Name)
}

var (
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-grpc-gateway/gengateway/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func New(reg *descriptor.Registry) *generator {
"io",
"net/http",
"github.com/gengo/grpc-gateway/runtime",
"github.com/gengo/grpc-gateway/internal",
"github.com/gengo/grpc-gateway/utilities",
"github.com/golang/glog",
"github.com/golang/protobuf/proto",
"golang.org/x/net/context",
Expand Down
12 changes: 6 additions & 6 deletions protoc-gen-grpc-gateway/gengateway/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"text/template"

"github.com/gengo/grpc-gateway/internal"
"github.com/gengo/grpc-gateway/utilities"
"github.com/gengo/grpc-gateway/protoc-gen-grpc-gateway/descriptor"
"github.com/golang/glog"
)
Expand Down Expand Up @@ -49,12 +49,12 @@ func (b binding) QueryParamFilter() queryParamFilter {
for _, p := range b.PathParams {
seqs = append(seqs, strings.Split(p.FieldPath.String(), "."))
}
return queryParamFilter{internal.NewDoubleArray(seqs)}
return queryParamFilter{utilities.NewDoubleArray(seqs)}
}

// queryParamFilter is a wrapper of internal.DoubleArray which provides String() to output DoubleArray.Encoding in a stable and predictable format.
// queryParamFilter is a wrapper of utilities.DoubleArray which provides String() to output DoubleArray.Encoding in a stable and predictable format.
type queryParamFilter struct {
*internal.DoubleArray
*utilities.DoubleArray
}

func (f queryParamFilter) String() string {
Expand All @@ -63,7 +63,7 @@ func (f queryParamFilter) String() string {
encodings[enc] = fmt.Sprintf("%q: %d", str, enc)
}
e := strings.Join(encodings, ", ")
return fmt.Sprintf("&internal.DoubleArray{Encoding: map[string]int{%s}, Base: %#v, Check: %#v}", e, f.Base, f.Check)
return fmt.Sprintf("&utilities.DoubleArray{Encoding: map[string]int{%s}, Base: %#v, Check: %#v}", e, f.Base, f.Check)
}

func applyTemplate(p param) (string, error) {
Expand Down Expand Up @@ -114,7 +114,7 @@ var _ codes.Code
var _ io.Reader
var _ = runtime.String
var _ = json.Marshal
var _ = internal.PascalFromSnake
var _ = utilities.PascalFromSnake
`))

handlerTemplate = template.Must(template.New("handler").Parse(`
Expand Down
18 changes: 9 additions & 9 deletions protoc-gen-grpc-gateway/httprule/compile.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package httprule

import (
"github.com/gengo/grpc-gateway/internal"
"github.com/gengo/grpc-gateway/utilities"
)

const (
Expand All @@ -22,15 +22,15 @@ type Template struct {
Fields []string
}

// Compiler compiles internal representation of path templates into marshallable operations.
// Compiler compiles utilities representation of path templates into marshallable operations.
// They can be unmarshalled by runtime.NewPattern.
type Compiler interface {
Compile() Template
}

type op struct {
// code is the opcode of the operation
code internal.OpCode
code utilities.OpCode

// str is a string operand of the code.
// num is ignored if str is not empty.
Expand All @@ -42,20 +42,20 @@ type op struct {

func (w wildcard) compile() []op {
return []op{
{code: internal.OpPush},
{code: utilities.OpPush},
}
}

func (w deepWildcard) compile() []op {
return []op{
{code: internal.OpPushM},
{code: utilities.OpPushM},
}
}

func (l literal) compile() []op {
return []op{
{
code: internal.OpLitPush,
code: utilities.OpLitPush,
str: string(l),
},
}
Expand All @@ -67,10 +67,10 @@ func (v variable) compile() []op {
ops = append(ops, s.compile()...)
}
ops = append(ops, op{
code: internal.OpConcatN,
code: utilities.OpConcatN,
num: len(v.segments),
}, op{
code: internal.OpCapture,
code: utilities.OpCapture,
str: v.path,
})

Expand Down Expand Up @@ -100,7 +100,7 @@ func (t template) Compile() Template {
}
ops = append(ops, consts[op.str])
}
if op.code == internal.OpCapture {
if op.code == utilities.OpCapture {
fields = append(fields, op.str)
}
}
Expand Down
34 changes: 17 additions & 17 deletions protoc-gen-grpc-gateway/httprule/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/gengo/grpc-gateway/internal"
"github.com/gengo/grpc-gateway/utilities"
)

const (
Expand All @@ -25,27 +25,27 @@ func TestCompile(t *testing.T) {
segs: []segment{
wildcard{},
},
ops: []int{int(internal.OpPush), operandFiller},
ops: []int{int(utilities.OpPush), operandFiller},
},
{
segs: []segment{
deepWildcard{},
},
ops: []int{int(internal.OpPushM), operandFiller},
ops: []int{int(utilities.OpPushM), operandFiller},
},
{
segs: []segment{
literal("v1"),
},
ops: []int{int(internal.OpLitPush), 0},
ops: []int{int(utilities.OpLitPush), 0},
pool: []string{"v1"},
},
{
segs: []segment{
literal("v1"),
},
verb: "LOCK",
ops: []int{int(internal.OpLitPush), 0},
ops: []int{int(utilities.OpLitPush), 0},
pool: []string{"v1"},
},
{
Expand All @@ -58,9 +58,9 @@ func TestCompile(t *testing.T) {
},
},
ops: []int{
int(internal.OpPush), operandFiller,
int(internal.OpConcatN), 1,
int(internal.OpCapture), 0,
int(utilities.OpPush), operandFiller,
int(utilities.OpConcatN), 1,
int(utilities.OpCapture), 0,
},
pool: []string{"name.nested"},
fields: []string{"name.nested"},
Expand All @@ -84,15 +84,15 @@ func TestCompile(t *testing.T) {
},
},
ops: []int{
int(internal.OpLitPush), 0,
int(internal.OpLitPush), 1,
int(internal.OpPush), operandFiller,
int(internal.OpLitPush), 2,
int(internal.OpConcatN), 3,
int(internal.OpCapture), 3,
int(internal.OpPushM), operandFiller,
int(internal.OpConcatN), 1,
int(internal.OpCapture), 0,
int(utilities.OpLitPush), 0,
int(utilities.OpLitPush), 1,
int(utilities.OpPush), operandFiller,
int(utilities.OpLitPush), 2,
int(utilities.OpConcatN), 3,
int(utilities.OpCapture), 3,
int(utilities.OpPushM), operandFiller,
int(utilities.OpConcatN), 1,
int(utilities.OpCapture), 0,
},
pool: []string{"obj", "a", "b", "name.nested"},
fields: []string{"name.nested", "obj"},
Expand Down
24 changes: 12 additions & 12 deletions runtime/mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http/httptest"
"testing"

"github.com/gengo/grpc-gateway/internal"
"github.com/gengo/grpc-gateway/utilities"
"github.com/gengo/grpc-gateway/runtime"
)

Expand Down Expand Up @@ -37,7 +37,7 @@ func TestMuxServeHTTP(t *testing.T) {
patterns: []stubPattern{
{
method: "GET",
ops: []int{int(internal.OpLitPush), 0},
ops: []int{int(utilities.OpLitPush), 0},
pool: []string{"foo"},
},
},
Expand All @@ -50,7 +50,7 @@ func TestMuxServeHTTP(t *testing.T) {
patterns: []stubPattern{
{
method: "GET",
ops: []int{int(internal.OpLitPush), 0},
ops: []int{int(utilities.OpLitPush), 0},
pool: []string{"foo"},
},
},
Expand All @@ -62,12 +62,12 @@ func TestMuxServeHTTP(t *testing.T) {
patterns: []stubPattern{
{
method: "GET",
ops: []int{int(internal.OpLitPush), 0},
ops: []int{int(utilities.OpLitPush), 0},
pool: []string{"foo"},
},
{
method: "GET",
ops: []int{int(internal.OpPush), 0},
ops: []int{int(utilities.OpPush), 0},
},
},
reqMethod: "GET",
Expand All @@ -79,12 +79,12 @@ func TestMuxServeHTTP(t *testing.T) {
patterns: []stubPattern{
{
method: "GET",
ops: []int{int(internal.OpLitPush), 0},
ops: []int{int(utilities.OpLitPush), 0},
pool: []string{"foo"},
},
{
method: "POST",
ops: []int{int(internal.OpLitPush), 0},
ops: []int{int(utilities.OpLitPush), 0},
pool: []string{"foo"},
},
},
Expand All @@ -97,7 +97,7 @@ func TestMuxServeHTTP(t *testing.T) {
patterns: []stubPattern{
{
method: "GET",
ops: []int{int(internal.OpLitPush), 0},
ops: []int{int(utilities.OpLitPush), 0},
pool: []string{"foo"},
},
},
Expand All @@ -109,7 +109,7 @@ func TestMuxServeHTTP(t *testing.T) {
patterns: []stubPattern{
{
method: "GET",
ops: []int{int(internal.OpLitPush), 0},
ops: []int{int(utilities.OpLitPush), 0},
pool: []string{"foo"},
},
},
Expand All @@ -125,12 +125,12 @@ func TestMuxServeHTTP(t *testing.T) {
patterns: []stubPattern{
{
method: "GET",
ops: []int{int(internal.OpLitPush), 0},
ops: []int{int(utilities.OpLitPush), 0},
pool: []string{"foo"},
},
{
method: "POST",
ops: []int{int(internal.OpLitPush), 0},
ops: []int{int(utilities.OpLitPush), 0},
pool: []string{"foo"},
},
},
Expand All @@ -147,7 +147,7 @@ func TestMuxServeHTTP(t *testing.T) {
patterns: []stubPattern{
{
method: "GET",
ops: []int{int(internal.OpLitPush), 0},
ops: []int{int(utilities.OpLitPush), 0},
pool: []string{"foo"},
},
},
Expand Down
Loading

0 comments on commit a17462a

Please sign in to comment.