Commit 56ce83f7 authored by Russ Cox's avatar Russ Cox

undo CL 12603044 / 2ca230b93195

fat fingers - did not intend to submit.
depends on the Unmarshaler CL anyway.

««« original CL description
encoding/xml: add, support Marshaler interface

See golang.org/s/go12xml for design.

Fixes #2771.
Fixes #4169.
Fixes #5975.
Fixes #6125.

R=golang-dev, iant, dan.kortschak
CC=golang-dev
https://golang.org/cl/12603044
»»»

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/12918043
parent ce3ba126
......@@ -92,6 +92,7 @@ pkg encoding/json, method (Number) String() string
pkg encoding/json, type Number string
pkg encoding/xml, func EscapeText(io.Writer, []uint8) error
pkg encoding/xml, method (*Encoder) Indent(string, string)
pkg encoding/xml, method (Encoder) ReadFrom(io.Reader) (int64, error)
pkg encoding/xml, type Decoder struct, DefaultSpace string
pkg go/ast, func NewCommentMap(*token.FileSet, Node, []*CommentGroup) CommentMap
pkg go/ast, method (CommentMap) Comments() []*CommentGroup
......
......@@ -2425,6 +2425,13 @@ pkg encoding/xml, method (*UnsupportedTypeError) Error() string
pkg encoding/xml, method (CharData) Copy() CharData
pkg encoding/xml, method (Comment) Copy() Comment
pkg encoding/xml, method (Directive) Copy() Directive
pkg encoding/xml, method (Encoder) Available() int
pkg encoding/xml, method (Encoder) Buffered() int
pkg encoding/xml, method (Encoder) Flush() error
pkg encoding/xml, method (Encoder) Write([]uint8) (int, error)
pkg encoding/xml, method (Encoder) WriteByte(uint8) error
pkg encoding/xml, method (Encoder) WriteRune(int32) (int, error)
pkg encoding/xml, method (Encoder) WriteString(string) (int, error)
pkg encoding/xml, method (ProcInst) Copy() ProcInst
pkg encoding/xml, method (StartElement) Copy() StartElement
pkg encoding/xml, method (UnmarshalError) Error() string
This diff is collapsed.
......@@ -289,31 +289,6 @@ type ChardataEmptyTest struct {
Contents *string `xml:",chardata"`
}
type MyMarshalerTest struct {
}
var _ Marshaler = (*MyMarshalerTest)(nil)
func (m *MyMarshalerTest) MarshalXML(e *Encoder, start StartElement) error {
e.EncodeToken(start)
e.EncodeToken(CharData([]byte("hello world")))
e.EncodeToken(EndElement{start.Name})
return nil
}
type MyMarshalerAttrTest struct {
}
var _ MarshalerAttr = (*MyMarshalerAttrTest)(nil)
func (m *MyMarshalerAttrTest) MarshalXMLAttr(name Name) (Attr, error) {
return Attr{name, "hello world"}, nil
}
type MarshalerStruct struct {
Foo MyMarshalerAttrTest `xml:",attr"`
}
var (
nameAttr = "Sarah"
ageAttr = uint(12)
......@@ -869,15 +844,6 @@ var marshalTests = []struct {
ExpectXML: `<Strings><A></A></Strings>`,
Value: &Strings{},
},
// Custom marshalers.
{
ExpectXML: `<MyMarshalerTest>hello world</MyMarshalerTest>`,
Value: &MyMarshalerTest{},
},
{
ExpectXML: `<MarshalerStruct Foo="hello world"></MarshalerStruct>`,
Value: &MarshalerStruct{},
},
}
func TestMarshal(t *testing.T) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment