summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-05-13 09:40:19 -0400
committerPietro Gagliardi <[email protected]>2014-05-13 09:40:19 -0400
commit62b3c26107a90764e95b8ad0b87e4d021891f4d6 (patch)
treef19080e2ed6a1497b20655191ccddfd8b407faf3
parent11ef974b4875216b401584065d59e32b629bf5bc (diff)
Removed the class creation at runtime stuff and its residue from the Go files. This also cleans up the initialization stuff on the Go side too.
-rw-r--r--area_darwin.go4
-rw-r--r--delegate_darwin.go7
-rw-r--r--objc_darwin.go75
-rw-r--r--uitask_darwin.go11
4 files changed, 4 insertions, 93 deletions
diff --git a/area_darwin.go b/area_darwin.go
index 5409d2e..d7167a5 100644
--- a/area_darwin.go
+++ b/area_darwin.go
@@ -18,10 +18,6 @@ var (
_NSView = objc_getClass("NSView")
)
-func mkAreaClass() error {
- return nil
-}
-
func makeArea(parentWindow C.id, alternate bool, s *sysData) C.id {
area := C.makeArea()
area = newScrollView(area)
diff --git a/delegate_darwin.go b/delegate_darwin.go
index a3f7486..34dfec7 100644
--- a/delegate_darwin.go
+++ b/delegate_darwin.go
@@ -25,18 +25,13 @@ var (
appDelegate C.id
)
-const (
- _goAppDelegate = "goAppDelegate"
-)
-
var (
_uitask = sel_getUid("uitask:") // used by uitask_darwin.go
_buttonClicked = sel_getUid("buttonClicked:") // used by sysdata_darwin.go
)
-func mkAppDelegate() error {
+func makeAppDelegate() {
appDelegate = C.makeAppDelegate()
- return nil
}
//export appDelegate_windowShouldClose
diff --git a/objc_darwin.go b/objc_darwin.go
index c1b610d..2429779 100644
--- a/objc_darwin.go
+++ b/objc_darwin.go
@@ -3,7 +3,6 @@
package ui
import (
- "fmt"
"unsafe"
)
@@ -79,77 +78,3 @@ func newScrollView(content C.id) C.id {
func getScrollViewContent(scrollview C.id) C.id {
return C.objc_msgSend_noargs(scrollview, _documentView)
}
-
-// These create new classes.
-
-// selector contains the information for a new selector.
-type selector struct {
- name string
- imp uintptr // not unsafe.Pointer because https://code.google.com/p/go/issues/detail?id=7665
- itype itype
- desc string // for error reporting
-}
-
-// sel_[returntype] or sel_[returntype]_[arguments] (after the required self/sel arguments)
-type itype uint
-const (
- sel_void_id itype = iota
- sel_bool_id
- sel_bool
- sel_void_rect
- sel_terminatereply_id
- sel_void
- nitypes
-)
-
-var itypes = [nitypes][]C.char{
- sel_void_id: []C.char{'v', '@', ':', '@', 0},
- sel_bool_id: []C.char{'c', '@', ':', '@', 0},
- sel_bool: []C.char{'c', '@', ':', 0},
- sel_void_rect: nil, // see init() below
- sel_terminatereply_id: nil,
- sel_void: []C.char{'v', '@', ':', 0},
-}
-
-func init() {
- // see encodedNSRect in bleh_darwin.m
- x := make([]C.char, 0, 256) // more than enough
- x = append(x, 'v', '@', ':')
- y := C.GoString(C.encodedNSRect)
- for _, b := range y {
- x = append(x, C.char(b))
- }
- x = append(x, 0)
- itypes[sel_void_rect] = x
-
- x = make([]C.char, 0, 256) // more than enough
- y = C.GoString(C.encodedTerminateReply)
- for _, b := range y {
- x = append(x, C.char(b))
- }
- x = append(x, '@', ':', '@', 0)
- itypes[sel_terminatereply_id] = x
-}
-
-func makeClass(name string, super C.id, sels []selector, desc string) (id C.id, err error) {
- cname := C.CString(name)
- defer C.free(unsafe.Pointer(cname))
-
- // an id that describes a class is itself a Class
- // thanks to Psy| in irc.freenode.net/##objc
- c := C.objc_allocateClassPair(C.Class(unsafe.Pointer(super)), cname, 0)
- if c == C.NilClass {
- err = fmt.Errorf("unable to create Objective-C class %s for %s; reason unknown", name, desc)
- return
- }
- C.objc_registerClassPair(c)
- for _, v := range sels {
- ok := C.class_addMethod(c, sel_getUid(v.name),
- C.IMP(unsafe.Pointer(v.imp)), &itypes[v.itype][0])
- if ok == C.BOOL(C.NO) {
- err = fmt.Errorf("unable to add selector %s to class %s (needed for %s; reason unknown)", v.name, name, v.desc)
- return
- }
- }
- return objc_getClass(name), nil
-}
diff --git a/uitask_darwin.go b/uitask_darwin.go
index 6b886cf..ad63d29 100644
--- a/uitask_darwin.go
+++ b/uitask_darwin.go
@@ -69,16 +69,11 @@ var (
func initCocoa() (err error) {
C.initBleh() // initialize bleh_darwin.m functions
- err = mkAppDelegate()
- if err != nil {
- return
- }
+ makeAppDelegate()
if C.initCocoa(appDelegate) != C.YES {
- err = fmt.Errorf("error setting NSApplication activation policy (basically identifies our program as a separate program; needed for several things, such as Dock icon, application menu, window resizing, etc.) (unknown reason)")
- return
+ return fmt.Errorf("error setting NSApplication activation policy (basically identifies our program as a separate program; needed for several things, such as Dock icon, application menu, window resizing, etc.) (unknown reason)")
}
- err = mkAreaClass()
- return
+ return nil
}
//export appDelegate_uitask