ソースを参照

codec: remove "internal" deprecated methods of encDriver and decDriver

These are

- encDriver.EncodeString
- encDriver.EncodeStringBytes
- decDriver.DecodeInt
- decDriver.DecodeUint

Also, update codecgen genVersion to 11
  (matching the removal of deprecated internal methods)
Ugorji Nwoke 6 年 前
コミット
070826dc1c

+ 1 - 1
README.md

@@ -289,7 +289,7 @@ some caveats. See Encode documentation.
 
 ```go
 const CborStreamBytes byte = 0x5f ...
-const GenVersion = 10
+const GenVersion = 11
 var GoRpc goRpc
 var MsgpackSpecRpc msgpackSpecRpc
 func GenHelperDecoder(d *Decoder) (gd genHelperDecoder, dd genHelperDecDriver)

+ 0 - 24
codec/binc.go

@@ -308,18 +308,6 @@ func (e *bincEncDriver) EncodeSymbol(v string) {
 	}
 }
 
-func (e *bincEncDriver) EncodeString(c charEncoding, v string) {
-	if e.c == containerMapKey && c == cUTF8 && (e.h.AsSymbols == 0 || e.h.AsSymbols == 1) {
-		e.EncodeSymbol(v)
-		return
-	}
-	l := uint64(len(v))
-	e.encBytesLen(c, l)
-	if l > 0 {
-		e.w.writestr(v)
-	}
-}
-
 func (e *bincEncDriver) EncodeStringEnc(c charEncoding, v string) {
 	if e.c == containerMapKey && c == cUTF8 && (e.h.AsSymbols == 0 || e.h.AsSymbols == 1) {
 		e.EncodeSymbol(v)
@@ -333,18 +321,6 @@ func (e *bincEncDriver) EncodeStringEnc(c charEncoding, v string) {
 
 }
 
-func (e *bincEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
-	if v == nil {
-		e.EncodeNil()
-		return
-	}
-	l := uint64(len(v))
-	e.encBytesLen(c, l)
-	if l > 0 {
-		e.w.writeb(v)
-	}
-}
-
 func (e *bincEncDriver) EncodeStringBytesRaw(v []byte) {
 	if v == nil {
 		e.EncodeNil()

+ 0 - 14
codec/cbor.go

@@ -235,24 +235,10 @@ func (e *cborEncDriver) WriteArrayEnd() {
 	}
 }
 
-func (e *cborEncDriver) EncodeString(c charEncoding, v string) {
-	e.encStringBytesS(cborBaseString, v)
-}
-
 func (e *cborEncDriver) EncodeStringEnc(c charEncoding, v string) {
 	e.encStringBytesS(cborBaseString, v)
 }
 
-func (e *cborEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
-	if v == nil {
-		e.EncodeNil()
-	} else if c == cRAW {
-		e.encStringBytesS(cborBaseBytes, stringView(v))
-	} else {
-		e.encStringBytesS(cborBaseString, stringView(v))
-	}
-}
-
 func (e *cborEncDriver) EncodeStringBytesRaw(v []byte) {
 	if v == nil {
 		e.EncodeNil()

+ 0 - 4
codec/decode.go

@@ -96,10 +96,6 @@ type decDriver interface {
 	// kInterface will extract the detached byte slice if it has to pass it outside its realm.
 	DecodeNaked()
 
-	// Deprecated: use DecodeInt64 and DecodeUint64 instead
-	// DecodeInt(bitsize uint8) (i int64)
-	// DecodeUint(bitsize uint8) (ui uint64)
-
 	DecodeInt64() (i int64)
 	DecodeUint64() (ui uint64)
 

+ 0 - 4
codec/encode.go

@@ -49,10 +49,6 @@ type encDriver interface {
 	// encodeExtPreamble(xtag byte, length int)
 	EncodeRawExt(re *RawExt, e *Encoder)
 	EncodeExt(v interface{}, xtag uint64, ext Ext, e *Encoder)
-	// Deprecated: use EncodeStringEnc instead
-	EncodeString(c charEncoding, v string)
-	// Deprecated: use EncodeStringBytesRaw instead
-	EncodeStringBytes(c charEncoding, v []byte)
 	EncodeStringEnc(c charEncoding, v string) // c cannot be cRAW
 	// EncodeSymbol(v string)
 	EncodeStringBytesRaw(v []byte)

+ 1 - 1
codec/gen-helper.generated.go

@@ -13,7 +13,7 @@ import (
 )
 
 // GenVersion is the current version of codecgen.
-const GenVersion = 10
+const GenVersion = 11
 
 // This file is used to generate helper code for codecgen.
 // The values here i.e. genHelper(En|De)coder are not to be used directly by

+ 3 - 2
codec/gen.go

@@ -105,8 +105,9 @@ import (
 // v7:
 // v8: current - we now maintain compatibility with old generated code.
 // v9: skipped
-// v10: modified encDriver and decDriver interfaces. Remove deprecated methods after Jan 1, 2019
-const genVersion = 10
+// v10: modified encDriver and decDriver interfaces.
+// v11: remove deprecated methods of encDriver and decDriver.
+const genVersion = 11
 
 const (
 	genCodecPkg        = "codec1978"

+ 0 - 31
codec/json.go

@@ -450,41 +450,10 @@ func (e *jsonEncDriver) EncodeRawExt(re *RawExt, en *Encoder) {
 	}
 }
 
-func (e *jsonEncDriver) EncodeString(c charEncoding, v string) {
-	e.quoteStr(v)
-}
-
 func (e *jsonEncDriver) EncodeStringEnc(c charEncoding, v string) {
 	e.quoteStr(v)
 }
 
-func (e *jsonEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
-	// if encoding raw bytes and RawBytesExt is configured, use it to encode
-	if v == nil {
-		e.EncodeNil()
-		return
-	}
-	if c == cRAW {
-		if e.se.InterfaceExt != nil {
-			e.EncodeExt(v, 0, &e.se, e.e)
-			return
-		}
-
-		slen := base64.StdEncoding.EncodedLen(len(v)) + 2
-		if cap(e.bs) >= slen {
-			e.bs = e.bs[:slen]
-		} else {
-			e.bs = make([]byte, slen)
-		}
-		e.bs[0] = '"'
-		base64.StdEncoding.Encode(e.bs[1:], v)
-		e.bs[slen-1] = '"'
-		e.w.writeb(e.bs)
-	} else {
-		e.quoteStr(stringView(v))
-	}
-}
-
 func (e *jsonEncDriver) EncodeStringBytesRaw(v []byte) {
 	// if encoding raw bytes and RawBytesExt is configured, use it to encode
 	if v == nil {

+ 2 - 2
codec/mammoth2_codecgen_generated_test.go

@@ -33,9 +33,9 @@ type codecSelfer19781 struct{}
 func codecSelfer19781False() bool { return false }
 
 func init() {
-	if GenVersion != 10 {
+	if GenVersion != 11 {
 		_, file, _, _ := runtime.Caller(0)
-		panic("codecgen version mismatch: current: 10, need " + strconv.FormatInt(int64(GenVersion), 10) + ". Re-generate file: " + file)
+		panic("codecgen version mismatch: current: 11, need " + strconv.FormatInt(int64(GenVersion), 10) + ". Re-generate file: " + file)
 	}
 	if false {
 		var _ byte = 0 // reference the types, but skip this branch at build/run time

+ 0 - 28
codec/msgpack.go

@@ -370,18 +370,6 @@ func (e *msgpackEncDriver) WriteMapStart(length int) {
 	e.writeContainerLen(msgpackContainerMap, length)
 }
 
-func (e *msgpackEncDriver) EncodeString(c charEncoding, s string) {
-	slen := len(s)
-	if c == cRAW && e.h.WriteExt {
-		e.writeContainerLen(msgpackContainerBin, slen)
-	} else {
-		e.writeContainerLen(msgpackContainerRawLegacy, slen)
-	}
-	if slen > 0 {
-		e.w.writestr(s)
-	}
-}
-
 func (e *msgpackEncDriver) EncodeStringEnc(c charEncoding, s string) {
 	slen := len(s)
 	if e.h.WriteExt {
@@ -394,22 +382,6 @@ func (e *msgpackEncDriver) EncodeStringEnc(c charEncoding, s string) {
 	}
 }
 
-func (e *msgpackEncDriver) EncodeStringBytes(c charEncoding, bs []byte) {
-	if bs == nil {
-		e.EncodeNil()
-		return
-	}
-	slen := len(bs)
-	if c == cRAW && e.h.WriteExt {
-		e.writeContainerLen(msgpackContainerBin, slen)
-	} else {
-		e.writeContainerLen(msgpackContainerRawLegacy, slen)
-	}
-	if slen > 0 {
-		e.w.writeb(bs)
-	}
-}
-
 func (e *msgpackEncDriver) EncodeStringBytesRaw(bs []byte) {
 	if bs == nil {
 		e.EncodeNil()

+ 0 - 8
codec/simple.go

@@ -170,14 +170,6 @@ func (e *simpleEncDriver) EncodeStringEnc(c charEncoding, v string) {
 	e.w.writestr(v)
 }
 
-func (e *simpleEncDriver) EncodeString(c charEncoding, v string) {
-	e.EncodeStringEnc(c, v)
-}
-
-func (e *simpleEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
-	e.EncodeStringBytesRaw(v)
-}
-
 func (e *simpleEncDriver) EncodeStringBytesRaw(v []byte) {
 	// if e.h.EncZeroValuesAsNil && e.c != containerMapKey && v == nil {
 	if v == nil {

+ 2 - 2
codec/values_codecgen_generated_test.go

@@ -34,9 +34,9 @@ type codecSelfer19780 struct{}
 func codecSelfer19780False() bool { return false }
 
 func init() {
-	if GenVersion != 10 {
+	if GenVersion != 11 {
 		_, file, _, _ := runtime.Caller(0)
-		panic("codecgen version mismatch: current: 10, need " + strconv.FormatInt(int64(GenVersion), 10) + ". Re-generate file: " + file)
+		panic("codecgen version mismatch: current: 11, need " + strconv.FormatInt(int64(GenVersion), 10) + ". Re-generate file: " + file)
 	}
 	if false {
 		var _ byte = 0 // reference the types, but skip this branch at build/run time