-
-
Notifications
You must be signed in to change notification settings - Fork 164
/
Copy pathinit.go
57 lines (42 loc) · 833 Bytes
/
init.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
package core
/*
#cgo CFLAGS: -x objective-c
void dispatch(void *f);
*/
import "C"
import (
"github.com/progrium/macdriver/objc"
)
var (
True objc.Object
False objc.Object
dispatched chan func()
)
func init() {
True = NSNumber_WithBool(true)
False = NSNumber_WithBool(false)
dispatched = make(chan func(), 1)
}
//export dispatchCb
func dispatchCb() {
(<-dispatched)()
}
func Dispatch(fn func()) {
dispatched <- fn
C.dispatch(nil)
}
func String(str string) NSString {
return NSString_FromString(str)
}
func Point(x float64, y float64) NSPoint {
return NSPoint{X: x, Y: y}
}
func Size(width float64, height float64) NSSize {
return NSSize{Width: width, Height: height}
}
func Rect(x, y, w, h float64) NSRect {
return NSMakeRect(x, y, w, h)
}
func URL(url string) NSURL {
return NSURL_URLWithString(url)
}