Add AppendXDR to XDR types, build.sh xdr

This commit is contained in:
Jakob Borg
2014-07-06 19:21:37 +02:00
parent b7ea695caf
commit e937e51476
8 changed files with 104 additions and 25 deletions

View File

@@ -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)
}