mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-16 02:18:44 -07:00
Add AppendXDR to XDR types, build.sh xdr
This commit is contained in:
parent
b7ea695caf
commit
e937e51476
11
build.sh
11
build.sh
@ -98,6 +98,13 @@ setup() {
|
||||
go get -u code.google.com/p/go.tools/cmd/vet
|
||||
}
|
||||
|
||||
xdr() {
|
||||
go install ./xdr/cmd/genxdr
|
||||
for f in discover/packets files/leveldb protocol/message scanner/blocks scanner/file ; do
|
||||
genxdr "${f}.go" > "${f}_xdr.go"
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"")
|
||||
shift
|
||||
@ -201,6 +208,10 @@ case "$1" in
|
||||
setup
|
||||
;;
|
||||
|
||||
xdr)
|
||||
xdr
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown build parameter $1"
|
||||
;;
|
||||
|
@ -13,7 +13,11 @@ func (o QueryV2) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o QueryV2) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o QueryV2) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
||||
@ -51,7 +55,11 @@ func (o AnnounceV2) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o AnnounceV2) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o AnnounceV2) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
||||
@ -101,7 +109,11 @@ func (o Node) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o Node) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o Node) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
||||
@ -152,7 +164,11 @@ func (o Address) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o Address) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o Address) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
||||
|
@ -13,7 +13,11 @@ func (o fileVersion) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o fileVersion) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o fileVersion) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
||||
@ -48,7 +52,11 @@ func (o versionList) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o versionList) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o versionList) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
||||
|
@ -13,7 +13,11 @@ func (o IndexMessage) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o IndexMessage) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o IndexMessage) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
||||
@ -64,7 +68,11 @@ func (o FileInfo) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o FileInfo) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o FileInfo) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
||||
@ -121,7 +129,11 @@ func (o BlockInfo) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o BlockInfo) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o BlockInfo) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
||||
@ -159,7 +171,11 @@ func (o RequestMessage) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o RequestMessage) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o RequestMessage) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
||||
@ -204,7 +220,11 @@ func (o ClusterConfigMessage) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o ClusterConfigMessage) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o ClusterConfigMessage) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
||||
@ -275,7 +295,11 @@ func (o Repository) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o Repository) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o Repository) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
||||
@ -326,7 +350,11 @@ func (o Node) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o Node) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o Node) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
||||
@ -366,7 +394,11 @@ func (o Option) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o Option) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o Option) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
||||
|
@ -13,10 +13,14 @@ func (o Block) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o Block) MarshalXDR() []byte {
|
||||
var buf bytes.Buffer
|
||||
var xw = xdr.NewWriter(&buf)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o Block) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return buf.Bytes()
|
||||
return []byte(aw)
|
||||
}
|
||||
|
||||
func (o Block) encodeXDR(xw *xdr.Writer) (int, error) {
|
||||
@ -32,8 +36,8 @@ func (o *Block) DecodeXDR(r io.Reader) error {
|
||||
}
|
||||
|
||||
func (o *Block) UnmarshalXDR(bs []byte) error {
|
||||
var buf = bytes.NewBuffer(bs)
|
||||
var xr = xdr.NewReader(buf)
|
||||
var br = bytes.NewReader(bs)
|
||||
var xr = xdr.NewReader(br)
|
||||
return o.decodeXDR(xr)
|
||||
}
|
||||
|
||||
|
@ -13,10 +13,14 @@ func (o File) EncodeXDR(w io.Writer) (int, error) {
|
||||
}
|
||||
|
||||
func (o File) MarshalXDR() []byte {
|
||||
var buf bytes.Buffer
|
||||
var xw = xdr.NewWriter(&buf)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}
|
||||
|
||||
func (o File) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return buf.Bytes()
|
||||
return []byte(aw)
|
||||
}
|
||||
|
||||
func (o File) encodeXDR(xw *xdr.Writer) (int, error) {
|
||||
@ -39,8 +43,8 @@ func (o *File) DecodeXDR(r io.Reader) error {
|
||||
}
|
||||
|
||||
func (o *File) UnmarshalXDR(bs []byte) error {
|
||||
var buf = bytes.NewBuffer(bs)
|
||||
var xr = xdr.NewReader(buf)
|
||||
var br = bytes.NewReader(bs)
|
||||
var xr = xdr.NewReader(br)
|
||||
return o.decodeXDR(xr)
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,11 @@ func (o {{.TypeName}}) EncodeXDR(w io.Writer) (int, error) {
|
||||
}//+n
|
||||
|
||||
func (o {{.TypeName}}) MarshalXDR() []byte {
|
||||
var aw = make(xdr.AppendWriter, 0, 128)
|
||||
return o.AppendXDR(make([]byte, 0, 128))
|
||||
}//+n
|
||||
|
||||
func (o {{.TypeName}}) AppendXDR(bs []byte) []byte {
|
||||
var aw = xdr.AppendWriter(bs)
|
||||
var xw = xdr.NewWriter(&aw)
|
||||
o.encodeXDR(xw)
|
||||
return []byte(aw)
|
Loading…
Reference in New Issue
Block a user