-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.go
42 lines (35 loc) · 896 Bytes
/
extension.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
package nvim
import "log"
// Identifier represents raw vim objects like Buffer..
type Identifier interface {
GetId() uint8
}
type nvimExt struct{}
func (e nvimExt) WriteExt(val interface{}) []byte {
var b = make([]byte, 1)
switch v := val.(type) {
case BufferIdentifier:
b[0] = v.Id
case WindowIdentifier:
b[0] = v.Id
case TabpageIdentifier:
b[0] = v.Id
default:
log.Fatalf("Fail writing msgpack-Extension. Got %T", val)
}
return b
}
func (e nvimExt) ReadExt(dest interface{}, src []byte) {
switch v := dest.(type) {
case *BufferIdentifier:
v.Id = src[0]
case *WindowIdentifier:
v.Id = src[0]
case *TabpageIdentifier:
v.Id = src[0]
default:
log.Fatalf("Fail reading msgpack-Extension. Got %T", dest)
}
}
func (nvimExt) ConvertExt(v interface{}) interface{} { panic("no used") }
func (nvimExt) UpdateExt(dst interface{}, src interface{}) { panic("no used") }