aboutsummaryrefslogtreecommitdiff
path: root/ber
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-06-27 15:03:22 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-06-27 15:03:22 +0200
commit35611186639bd1632ae4be124133f866ab6a2107 (patch)
treec89b35c02f62b541d973555b0f0b13f235d3bed8 /ber
parent6b6c369b624b9ddccd9a23eed78e0340db99ad85 (diff)
Isolate reflect
Diffstat (limited to 'ber')
-rw-r--r--ber/int.go7
-rw-r--r--ber/marshal.go10
-rw-r--r--ber/obj.go8
3 files changed, 15 insertions, 10 deletions
diff --git a/ber/int.go b/ber/int.go
index 97fd7b8..85d99e8 100644
--- a/ber/int.go
+++ b/ber/int.go
@@ -1,7 +1,5 @@
package ber
-import "reflect"
-
func intLen(i int64) int {
n := 1
for i > 255 {
@@ -46,8 +44,3 @@ func marshalInt(i int64) (b []byte) {
}
return
}
-
-func intEncoder(e *encodeState, v reflect.Value) {
- b := marshalInt(v.Int())
- e.Write(b)
-}
diff --git a/ber/marshal.go b/ber/marshal.go
index ca91271..130bef5 100644
--- a/ber/marshal.go
+++ b/ber/marshal.go
@@ -80,3 +80,13 @@ func unsupportedTypeEncoder(e *encodeState, v reflect.Value) {
func (e *encodeState) error(err error) {
panic(err)
}
+
+func intEncoder(e *encodeState, v reflect.Value) {
+ b := marshalInt(v.Int())
+ e.Write(b)
+}
+
+func objEncoder(e *encodeState, v reflect.Value) {
+ b := marshalObj(v.Interface().(Obj))
+ e.Write(b)
+}
diff --git a/ber/obj.go b/ber/obj.go
index ff8aef8..5482cd1 100644
--- a/ber/obj.go
+++ b/ber/obj.go
@@ -1,5 +1,7 @@
package ber
+type Obj []int
+
func base128(n int) (b []byte) {
if n == 0 {
return []byte{0}
@@ -23,7 +25,7 @@ func debase128(b []byte) int {
return 0
}
-func marshalObj(obj []int) (b []byte) {
+func marshalObj(obj Obj) (b []byte) {
if len(obj) < 2 || obj[0] > 2 {
return []byte{}
}
@@ -38,6 +40,6 @@ func marshalObj(obj []int) (b []byte) {
return b
}
-func unmarshalObj(b []byte) []int {
- return []int{}
+func unmarshalObj(b []byte) Obj {
+ return Obj{}
}