forked from mkrautz/objc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobject64_386.go
83 lines (63 loc) · 1.68 KB
/
object64_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// 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 "C"
import (
"math"
"unsafe"
)
// object64 is an object that holds
// a 64-bit value on a 32-bit architecture.
type object64 struct {
big uint64
}
func (obj object64) SendMsg(selector string, args ...interface{}) Object {
return sendMsg(obj, "objc_msgSend", selector, args...)
}
func (obj object64) SendSuperMsg(selector string, args ...interface{}) Object {
return sendMsg(obj, "objc_msgSendSuper", selector, args...)
}
func (obj object64) Pointer() uintptr {
return uintptr(obj.big & 0xffffffff)
}
func (obj object64) Alloc() Object {
return obj.SendMsg("alloc")
}
func (obj object64) Init() Object {
return obj.SendMsg("init")
}
func (obj object64) Retain() Object {
return obj.SendMsg("retain")
}
func (obj object64) Release() Object {
return obj.SendMsg("release")
}
func (obj object64) AutoRelease() Object {
return obj.SendMsg("autorelease")
}
func (obj object64) Copy() Object {
return obj.SendMsg("copy")
}
func (obj object64) String() string {
pool := GetClass("NSAutoreleasePool").Alloc().Init()
defer pool.Release()
descString := obj.SendMsg("description")
utf8Bytes := descString.SendMsg("UTF8String")
if utf8Bytes.Pointer() != 0 {
return C.GoString((*C.char)(unsafe.Pointer(utf8Bytes.Pointer())))
}
return "(nil)"
}
func (obj object64) Uint() uint64 {
return uint64(obj.big)
}
func (obj object64) Int() int64 {
return int64(obj.big)
}
func (obj object64) Bool() bool {
return obj.big == 1
}
func (obj object64) Float() float64 {
return math.Float64frombits(obj.big)
}