-
Notifications
You must be signed in to change notification settings - Fork 67
/
io_reader.go
51 lines (41 loc) · 830 Bytes
/
io_reader.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package core
import (
"io"
"unsafe"
)
type (
IOReader struct {
io.Reader
hash uint32
}
)
func MakeIOReader(r io.Reader) *IOReader {
res := &IOReader{r, 0}
res.hash = HashPtr(uintptr(unsafe.Pointer(res)))
return res
}
func (ior *IOReader) ToString(escape bool) string {
return "#object[IOReader]"
}
func (ior *IOReader) Equals(other interface{}) bool {
return ior == other
}
func (ior *IOReader) GetInfo() *ObjectInfo {
return nil
}
func (ior *IOReader) GetType() *Type {
return TYPE.IOReader
}
func (ior *IOReader) Hash() uint32 {
return ior.hash
}
func (ior *IOReader) WithInfo(info *ObjectInfo) Object {
return ior
}
func (ior *IOReader) Close() error {
if c, ok := ior.Reader.(io.Closer); ok {
return c.Close()
} else {
return RT.NewError("Object is not closable: " + ior.ToString(false))
}
}