LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package xml | 5 package xml |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "fmt" | 9 "fmt" |
10 "io" | 10 "io" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 saveXML reflect.Value | 244 saveXML reflect.Value |
245 saveXMLIndex int | 245 saveXMLIndex int |
246 saveXMLData []byte | 246 saveXMLData []byte |
247 sv reflect.Value | 247 sv reflect.Value |
248 styp reflect.Type | 248 styp reflect.Type |
249 fieldPaths map[string]pathInfo | 249 fieldPaths map[string]pathInfo |
250 ) | 250 ) |
251 | 251 |
252 switch v := val; v.Kind() { | 252 switch v := val; v.Kind() { |
253 default: | 253 default: |
254 » » return os.ErrorString("unknown type " + v.Type().String()) | 254 » » return os.NewError("unknown type " + v.Type().String()) |
255 | 255 |
256 case reflect.Slice: | 256 case reflect.Slice: |
257 typ := v.Type() | 257 typ := v.Type() |
258 if typ.Elem().Kind() == reflect.Uint8 { | 258 if typ.Elem().Kind() == reflect.Uint8 { |
259 // []byte | 259 // []byte |
260 saveData = v | 260 saveData = v |
261 break | 261 break |
262 } | 262 } |
263 | 263 |
264 // Slice of element values. | 264 // Slice of element values. |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 ftmp, err = strconv.Atof64(string(src)) | 501 ftmp, err = strconv.Atof64(string(src)) |
502 // TODO: check for overflow? | 502 // TODO: check for overflow? |
503 return err == nil | 503 return err == nil |
504 } | 504 } |
505 | 505 |
506 // Save accumulated data and comments | 506 // Save accumulated data and comments |
507 switch t := dst; t.Kind() { | 507 switch t := dst; t.Kind() { |
508 case reflect.Invalid: | 508 case reflect.Invalid: |
509 // Probably a comment, handled below | 509 // Probably a comment, handled below |
510 default: | 510 default: |
511 » » return os.ErrorString("cannot happen: unknown type " + t.Type().
String()) | 511 » » return os.NewError("cannot happen: unknown type " + t.Type().Str
ing()) |
512 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.In
t64: | 512 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.In
t64: |
513 if !getInt64() { | 513 if !getInt64() { |
514 return err | 514 return err |
515 } | 515 } |
516 t.SetInt(itmp) | 516 t.SetInt(itmp) |
517 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflec
t.Uint64, reflect.Uintptr: | 517 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflec
t.Uint64, reflect.Uintptr: |
518 if !getUint64() { | 518 if !getUint64() { |
519 return err | 519 return err |
520 } | 520 } |
521 t.SetUint(utmp) | 521 t.SetUint(utmp) |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 case StartElement: | 621 case StartElement: |
622 if err := p.Skip(); err != nil { | 622 if err := p.Skip(); err != nil { |
623 return err | 623 return err |
624 } | 624 } |
625 case EndElement: | 625 case EndElement: |
626 return nil | 626 return nil |
627 } | 627 } |
628 } | 628 } |
629 panic("unreachable") | 629 panic("unreachable") |
630 } | 630 } |
LEFT | RIGHT |