forked from mkrautz/objc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
typeinfo_386.go
56 lines (51 loc) · 1.17 KB
/
typeinfo_386.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
52
53
54
55
56
// Copyright (c) 2013 The 'objc' Package Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package objc
import (
"fmt"
"reflect"
)
func typeInfoForType(typ reflect.Type) string {
if typ.Implements(classInterfaceType) {
return encClass
} else if typ.Implements(objectInterfaceType) {
return encId
} else if typ.Implements(selectorInterfaceType) {
return encSelector
}
kind := typ.Kind()
switch kind {
case reflect.Bool:
return encBool
case reflect.Int:
return encInt
case reflect.Int8:
return encChar
case reflect.Int16:
return encShort
case reflect.Int32:
return encInt
case reflect.Int64:
return encLongLong
case reflect.Uint:
return encUInt
case reflect.Uint8:
return encUChar
case reflect.Uint16:
return encUShort
case reflect.Uint32:
return encUInt
case reflect.Uint64:
return encULongLong
case reflect.Uintptr:
return encPtr
case reflect.Float32:
return encFloat
case reflect.Float64:
return encDouble
case reflect.Ptr:
return encPtr
}
panic("typeinfo: unhandled/invalid kind " + fmt.Sprintf("%v", kind) + " " + fmt.Sprintf("%v", typ))
}