Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use prettier window mask in demo.go; gofmt run.

  • Loading branch information...
commit ded20f46509dc268be04e6ec323106c0ded9a1a8 1 parent ba5ae4f
Mikkel Krautz authored
14 AppKit/NSWindow.go
View
@@ -6,12 +6,12 @@ import (
)
const (
- NSBorderlessWindowMask = 0
- NSTitledWindowMask = 1 << 0
- NSClosableWindowMask = 1 << 1
- NSMiniaturizableWindowMask = 1 << 2
- NSResizableWindowMask = 1 << 3
- NSTexturedBackgroundWindowMask = 1 << 8
+ NSBorderlessWindowMask NSUInteger = 0
+ NSTitledWindowMask NSUInteger = 1 << 0
+ NSClosableWindowMask NSUInteger = 1 << 1
+ NSMiniaturizableWindowMask NSUInteger = 1 << 2
+ NSResizableWindowMask NSUInteger = 1 << 3
+ NSTexturedBackgroundWindowMask NSUInteger = 1 << 8
)
const (
@@ -29,7 +29,7 @@ type NSWindow struct {
func NewNSWindow(rect NSRect, windowStyle NSUInteger, bufferingType NSBackingStoreType, deferCreation bool) NSWindow {
obj := objc.GetClass("NSWindow").Alloc().
SendMsg("initWithContentRect:styleMask:backing:defer:",
- rect, windowStyle, bufferingType, deferCreation)
+ rect, windowStyle, bufferingType, deferCreation)
return NSWindow{obj}
}
2  AppKit/doc.go
View
@@ -1,2 +1,2 @@
// Package appkit implements access to Mac OS X's AppKit.framework
-package appkit
+package appkit
2  AppKit/init.go
View
@@ -3,4 +3,4 @@ package appkit
/*
#cgo LDFLAGS: -framework AppKit
*/
-import "C"
+import "C"
2  Foundation/NSUInteger.go
View
@@ -1,3 +1,3 @@
package foundation
-type NSUInteger uintptr
+type NSUInteger uintptr
3  demo/demo.go
View
@@ -17,7 +17,8 @@ func main() {
app := NSSharedApplication()
_ = app
- window := NewNSWindow(NSRectMake(0, 0, 500, 500), 0, NSBackingStoreBuffered, false)
+ mask := NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask
+ window := NewNSWindow(NSRectMake(0, 0, 500, 500), mask, NSBackingStoreBuffered, false)
window.AutoRelease()
window.Display()
window.MakeKeyAndOrderFront(window.Object)
30 objc.go
View
@@ -16,10 +16,10 @@ void *GoObjc_RegisterSelector(char *name) {
*/
import "C"
import (
- "unsafe"
- "reflect"
- "math"
"github.com/mkrautz/variadic"
+ "math"
+ "reflect"
+ "unsafe"
)
// A Selector represents an Objective-C selector.
@@ -32,7 +32,7 @@ func SelectorName(name string) Selector {
// Checks whether the Selector s is nil.
func (s Selector) IsNil() bool {
- return uintptr(s) == 0
+ return uintptr(s) == 0
}
// A Class represents an Objective-C class.
@@ -62,17 +62,17 @@ func unpackStruct(val reflect.Value) []uintptr {
v := val.Field(i)
kind := v.Kind()
switch kind {
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- memArgs = append(memArgs, uintptr(v.Int()))
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- memArgs = append(memArgs, uintptr(v.Uint()))
- case reflect.Float32, reflect.Float64:
- memArgs = append(memArgs, uintptr(math.Float64bits(v.Float())))
- case reflect.Ptr:
- memArgs = append(memArgs, val.Pointer())
- case reflect.Struct:
- args := unpackStruct(v)
- memArgs = append(memArgs, args...)
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ memArgs = append(memArgs, uintptr(v.Int()))
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ memArgs = append(memArgs, uintptr(v.Uint()))
+ case reflect.Float32, reflect.Float64:
+ memArgs = append(memArgs, uintptr(math.Float64bits(v.Float())))
+ case reflect.Ptr:
+ memArgs = append(memArgs, val.Pointer())
+ case reflect.Struct:
+ args := unpackStruct(v)
+ memArgs = append(memArgs, args...)
}
}
return memArgs
2  objc_test.go
View
@@ -12,4 +12,4 @@ func TestGetClass(t *testing.T) {
hdrp := (*reflect.StringHeader)(unsafe.Pointer(&helloWorld))
obj := GetClass("NSString").Alloc().SendMsg("initWithBytes:length:encoding:", hdrp.Data, hdrp.Len, 4)
log.Printf("%v", obj)
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.