Browse Source

codec: attempt to use maps for descriptors of bd in cbor, binc. rescinded.

Ugorji Nwoke 6 years ago
parent
commit
cce4f01546
2 changed files with 74 additions and 2 deletions
  1. 37 1
      codec/binc.go
  2. 37 1
      codec/cbor.go

+ 37 - 1
codec/binc.go

@@ -54,7 +54,43 @@ const (
 	// others not currently supported
 )
 
-func bincdesc(vd, vs byte) string {
+// var (
+// 	bincdescSpecialVsNames = map[byte]string{
+// 		bincSpNil:       "nil",
+// 		bincSpFalse:     "false",
+// 		bincSpTrue:      "true",
+// 		bincSpNan:       "float",
+// 		bincSpPosInf:    "float",
+// 		bincSpNegInf:    "float",
+// 		bincSpZeroFloat: "float",
+// 		bincSpZero:      "uint",
+// 		bincSpNegOne:    "int",
+// 	}
+// 	bincdescVdNames = map[byte]string{
+// 		bincVdSpecial:   "special",
+// 		bincVdSmallInt:  "uint",
+// 		bincVdPosInt:    "uint",
+// 		bincVdFloat:     "float",
+// 		bincVdSymbol:    "string",
+// 		bincVdString:    "string",
+// 		bincVdByteArray: "bytes",
+// 		bincVdTimestamp: "time",
+// 		bincVdCustomExt: "ext",
+// 		bincVdArray:     "array",
+// 		bincVdMap:       "map",
+// 	}
+// )
+
+func bincdesc(vd, vs byte) (s string) {
+	// s = bincdescVdNames[vd]
+	// if s == "special" {
+	// 	s = bincdescSpecialVsNames[vs]
+	// }
+	// if s == "" {
+	// 	s = "unknown"
+	// }
+	// return
+
 	switch vd {
 	case bincVdSpecial:
 		switch vs {

+ 37 - 1
codec/cbor.go

@@ -69,7 +69,43 @@ const (
 // 	cborSelfDesrTag3 byte = 0xf7
 // )
 
-func cbordesc(bd byte) string {
+// var (
+// 	cbordescSimpleNames = map[byte]string{
+// 		cborBdNil:              "nil",
+// 		cborBdFalse:            "false",
+// 		cborBdTrue:             "true",
+// 		cborBdFloat16:          "float",
+// 		cborBdFloat32:          "float",
+// 		cborBdFloat64:          "float",
+// 		cborBdIndefiniteBytes:  "bytes*",
+// 		cborBdIndefiniteString: "string*",
+// 		cborBdIndefiniteArray:  "array*",
+// 		cborBdIndefiniteMap:    "map*",
+// 	}
+// 	cbordescMajorNames = map[byte]string{
+// 		cborMajorUint:          "(u)int",
+// 		cborMajorNegInt:        "int",
+// 		cborMajorBytes:         "bytes",
+// 		cborMajorString:        "string",
+// 		cborMajorArray:         "array",
+// 		cborMajorMap:           "map",
+// 		cborMajorTag:           "tag",
+// 		cborMajorSimpleOrFloat: "simple",
+// 	}
+// )
+
+func cbordesc(bd byte) (s string) {
+	// s = cbordescMajorNames[bd>>5]
+	// if s == "" {
+	// 	s = "unknown"
+	// } else if s == "simple" {
+	// 	s = cbordescMajorNames[bd]
+	// 	if s == "" {
+	// 		s = "unknown(simple)"
+	// 	}
+	// }
+	// return
+
 	switch bd >> 5 {
 	case cborMajorUint:
 		return "(u)int"