Removed objc_alloc(). This should be all of them. Now to redo how classes are handled...

This commit is contained in:
Pietro Gagliardi 2014-04-04 20:34:35 -04:00
parent 5a5b486b6a
commit e35457b968
4 changed files with 14 additions and 20 deletions

View File

@ -277,7 +277,7 @@ func areaView_flagsChanged(self C.id, sel C.SEL, e C.id) {
// TODO combine these with the listbox functions? // TODO combine these with the listbox functions?
func newAreaScrollView(area C.id) C.id { func newAreaScrollView(area C.id) C.id {
scrollview := objc_alloc(_NSScrollView) scrollview := C.objc_msgSend_noargs(_NSScrollView, _alloc)
scrollview = initWithDummyFrame(scrollview) scrollview = initWithDummyFrame(scrollview)
C.objc_msgSend_bool(scrollview, _setHasHorizontalScroller, C.BOOL(C.YES)) C.objc_msgSend_bool(scrollview, _setHasHorizontalScroller, C.BOOL(C.YES))
C.objc_msgSend_bool(scrollview, _setHasVerticalScroller, C.BOOL(C.YES)) C.objc_msgSend_bool(scrollview, _setHasVerticalScroller, C.BOOL(C.YES))
@ -291,7 +291,7 @@ func areaInScrollView(scrollview C.id) C.id {
} }
func makeArea(parentWindow C.id, alternate bool) C.id { func makeArea(parentWindow C.id, alternate bool) C.id {
area := objc_alloc(_goArea) area := C.objc_msgSend_noargs(_goArea, _alloc)
area = initWithDummyFrame(area) area = initWithDummyFrame(area)
// TODO others? // TODO others?
area = newAreaScrollView(area) area = newAreaScrollView(area)

View File

@ -165,7 +165,7 @@ var (
) )
func newListboxTableColumn() C.id { func newListboxTableColumn() C.id {
column := objc_alloc(_NSTableColumn) column := C.objc_msgSend_noargs(_NSTableColumn, _alloc)
column = C.objc_msgSend_id(column, _initWithIdentifier, listboxItemKey) column = C.objc_msgSend_id(column, _initWithIdentifier, listboxItemKey)
C.objc_msgSend_bool(column, _setEditable, C.BOOL(C.NO)) C.objc_msgSend_bool(column, _setEditable, C.BOOL(C.NO))
// TODO other properties? // TODO other properties?
@ -192,7 +192,7 @@ var (
) )
func newListboxScrollView(listbox C.id) C.id { func newListboxScrollView(listbox C.id) C.id {
scrollview := objc_alloc(_NSScrollView) scrollview := C.objc_msgSend_noargs(_NSScrollView, _alloc)
scrollview = initWithDummyFrame(scrollview) scrollview = initWithDummyFrame(scrollview)
C.objc_msgSend_bool(scrollview, _setHasHorizontalScroller, C.BOOL(C.YES)) C.objc_msgSend_bool(scrollview, _setHasHorizontalScroller, C.BOOL(C.YES))
C.objc_msgSend_bool(scrollview, _setHasVerticalScroller, C.BOOL(C.YES)) C.objc_msgSend_bool(scrollview, _setHasVerticalScroller, C.BOOL(C.YES))
@ -232,7 +232,7 @@ var (
) )
func makeListbox(parentWindow C.id, alternate bool) C.id { func makeListbox(parentWindow C.id, alternate bool) C.id {
listbox := objc_alloc(_NSTableView) listbox := C.objc_msgSend_noargs(_NSTableView, _alloc)
listbox = initWithDummyFrame(listbox) listbox = initWithDummyFrame(listbox)
C.objc_msgSend_id(listbox, _addTableColumn, newListboxTableColumn()) C.objc_msgSend_id(listbox, _addTableColumn, newListboxTableColumn())
multi := C.BOOL(C.NO) multi := C.BOOL(C.NO)

View File

@ -37,12 +37,6 @@ var (
_UTF8String = sel_getUid("UTF8String") _UTF8String = sel_getUid("UTF8String")
) )
// some helper functions
func objc_alloc(class C.id) C.id {
return C.objc_msgSend_noargs(class, _alloc)
}
func toNSString(str string) C.id { func toNSString(str string) C.id {
cstr := C.CString(str) cstr := C.CString(str)
defer C.free(unsafe.Pointer(cstr)) defer C.free(unsafe.Pointer(cstr))

View File

@ -116,7 +116,7 @@ var classTypes = [nctypes]*classData{
) )
// we have to specify a content rect to start; it will be overridden soon though // we have to specify a content rect to start; it will be overridden soon though
win := objc_alloc(_NSWindow) win := C.objc_msgSend_noargs(_NSWindow, _alloc)
win = C.objc_msgSend_rect_uint_uint_bool(win, win = C.objc_msgSend_rect_uint_uint_bool(win,
_initWithContentRect, _initWithContentRect,
C.int64_t(0), C.int64_t(0), C.int64_t(100), C.int64_t(100), C.int64_t(0), C.int64_t(0), C.int64_t(100), C.int64_t(100),
@ -139,7 +139,7 @@ var classTypes = [nctypes]*classData{
}, },
c_button: &classData{ c_button: &classData{
make: func(parentWindow C.id, alternate bool) C.id { make: func(parentWindow C.id, alternate bool) C.id {
button := objc_alloc(_NSButton) button := C.objc_msgSend_noargs(_NSButton, _alloc)
button = initWithDummyFrame(button) button = initWithDummyFrame(button)
C.objc_msgSend_uint(button, _setBezelStyle, C.uintptr_t(1)) // NSRoundedBezelStyle C.objc_msgSend_uint(button, _setBezelStyle, C.uintptr_t(1)) // NSRoundedBezelStyle
C.objc_msgSend_id(button, _setTarget, appDelegate) C.objc_msgSend_id(button, _setTarget, appDelegate)
@ -157,7 +157,7 @@ var classTypes = [nctypes]*classData{
}, },
c_checkbox: &classData{ c_checkbox: &classData{
make: func(parentWindow C.id, alternate bool) C.id { make: func(parentWindow C.id, alternate bool) C.id {
checkbox := objc_alloc(_NSButton) checkbox := C.objc_msgSend_noargs(_NSButton, _alloc)
checkbox = initWithDummyFrame(checkbox) checkbox = initWithDummyFrame(checkbox)
C.objc_msgSend_uint(checkbox, _setButtonType, C.uintptr_t(3)) // NSSwitchButton C.objc_msgSend_uint(checkbox, _setButtonType, C.uintptr_t(3)) // NSSwitchButton
addControl(parentWindow, checkbox) addControl(parentWindow, checkbox)
@ -173,11 +173,11 @@ var classTypes = [nctypes]*classData{
var combobox C.id var combobox C.id
if alternate { if alternate {
combobox = objc_alloc(_NSComboBox) combobox = C.objc_msgSend_noargs(_NSComboBox, _alloc)
combobox = initWithDummyFrame(combobox) combobox = initWithDummyFrame(combobox)
C.objc_msgSend_bool(combobox, _setUsesDataSource, C.BOOL(C.NO)) C.objc_msgSend_bool(combobox, _setUsesDataSource, C.BOOL(C.NO))
} else { } else {
combobox = objc_alloc(_NSPopUpButton) combobox = C.objc_msgSend_noargs(_NSPopUpButton, _alloc)
combobox = C.objc_msgSend_rect_bool(combobox, _initWithFramePullsDown, combobox = C.objc_msgSend_rect_bool(combobox, _initWithFramePullsDown,
C.int64_t(0), C.int64_t(0), C.int64_t(100), C.int64_t(100), C.int64_t(0), C.int64_t(0), C.int64_t(100), C.int64_t(100),
C.BOOL(C.NO)) C.BOOL(C.NO))
@ -220,9 +220,9 @@ var classTypes = [nctypes]*classData{
var lineedit C.id var lineedit C.id
if alternate { if alternate {
lineedit = objc_alloc(_NSSecureTextField) lineedit = C.objc_msgSend_noargs(_NSSecureTextField, _alloc)
} else { } else {
lineedit = objc_alloc(_NSTextField) lineedit = C.objc_msgSend_noargs(_NSTextField, _alloc)
} }
lineedit = initWithDummyFrame(lineedit) lineedit = initWithDummyFrame(lineedit)
addControl(parentWindow, lineedit) addControl(parentWindow, lineedit)
@ -236,7 +236,7 @@ var classTypes = [nctypes]*classData{
}, },
c_label: &classData{ c_label: &classData{
make: func(parentWindow C.id, alternate bool) C.id { make: func(parentWindow C.id, alternate bool) C.id {
label := objc_alloc(_NSTextField) label := C.objc_msgSend_noargs(_NSTextField, _alloc)
label = initWithDummyFrame(label) label = initWithDummyFrame(label)
C.objc_msgSend_bool(label, _setEditable, C.BOOL(C.NO)) C.objc_msgSend_bool(label, _setEditable, C.BOOL(C.NO))
C.objc_msgSend_bool(label, _setBordered, C.BOOL(C.NO)) C.objc_msgSend_bool(label, _setBordered, C.BOOL(C.NO))
@ -263,7 +263,7 @@ var classTypes = [nctypes]*classData{
}, },
c_progressbar: &classData{ c_progressbar: &classData{
make: func(parentWindow C.id, alternate bool) C.id { make: func(parentWindow C.id, alternate bool) C.id {
pbar := objc_alloc(_NSProgressIndicator) pbar := C.objc_msgSend_noargs(_NSProgressIndicator, _alloc)
pbar = initWithDummyFrame(pbar) pbar = initWithDummyFrame(pbar)
// TODO really int? // TODO really int?
C.objc_msgSend_int(pbar, _setStyle, 0) // NSProgressIndicatorBarStyle C.objc_msgSend_int(pbar, _setStyle, 0) // NSProgressIndicatorBarStyle