From 0bc23404da92c14975be03d170fa2a422fd305f1 Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 25 Jun 2020 16:56:55 -0400 Subject: [PATCH] Doc updates. --- README.md | 28 +++++++++++++--------------- examples/bluetooth/main.go | 2 +- wrap/main.go | 4 ++-- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index cf24883..1e2c41f 100644 --- a/README.md +++ b/README.md @@ -379,8 +379,8 @@ An example in Core Foundation is the `getObjects:andKeys:count` method for ns.NSArrayWithObjects(nst("key1"),nst("key2")), ) va,ka := make([]*ns.Id,0,5), make([]*ns.Id,0,5) // length 0, capacity 5 slices - dict.GetObjects(&va,&ka,5) - // last parameter to GetObjects is the count, must be less than or equal to the input slice capacity + dict.GetObjectsAndKeysCount(&va,&ka,5) + // last parameter is the count, must be less than or equal to the input slice capacity fmt.Printf("Length of va is now %d\n",len(va)) // va and ka slices are now length = 2 for i,k := range ka { fmt.Printf("-- %s -> %s\n",k.NSString(),va[i].NSString()) @@ -469,10 +469,9 @@ results in: ```go //ns/main.go ... -type NSWindowOrderingMode C.enum_NSWindowOrderingMode -const NSWindowAbove NSWindowOrderingMode = C.NSWindowAbove -const NSWindowBelow NSWindowOrderingMode = C.NSWindowBelow -const NSWindowOut NSWindowOrderingMode = C.NSWindowOut +const NSWindowAbove NSInteger = C.NSWindowAbove +const NSWindowBelow NSInteger = C.NSWindowBelow +const NSWindowOut NSInteger = C.NSWindowOut const _CLOCK_REALTIME = C._CLOCK_REALTIME const _CLOCK_MONOTONIC = C._CLOCK_MONOTONIC @@ -534,7 +533,7 @@ registers a callback for `centralManagerDidUpdateState`, allocates a `CBCentralManager` object, and installs our delegate: ```go -func cb(c ns.CBCentralManager) { +func cb(self ns.CBDelegate, c *ns.CBCentralManager) { ... } @@ -558,8 +557,8 @@ messages will point you in the right direction. ``` $ go build -./main.go:127:43: cannot use didFinishLaunching (type func(*ns.NSNotification, bool)) as type -func(*ns.NSNotification) in argument to del.ApplicationDidFinishLaunchingCallback +./main.go:127:43: cannot use didFinishLaunching (type func(ns.CBDelegate, *ns.NSNotification, bool)) as type +func(ns.CBDelegate, *ns.NSNotification) in argument to del.ApplicationDidFinishLaunchingCallback ``` In the above example, the build failed because an extra `bool` parameter was included in the callback function. The compiler is telling you that the right @@ -648,7 +647,7 @@ func main() { } ``` -Pretty simple right? Not really, NSWrap just generated over 39,000 lines of +Pretty simple right? Not really, NSWrap just generated 114,000 lines of code. See `examples/app` for a slightly more complex example with working menus, visual format-based auto layout, and a custom button class. @@ -683,12 +682,11 @@ name, its return type, and the names and types of its parameters if any. Since multiple inheritance is not permitted in Objective-C, it is not possible to specify more than one superclass in a `subclasses` entry. -Go callbacks for overridden methods are passed a special struct -as their first parameter. This struct is filled with superclass methods, which -allows you to do things like this: +Go callbacks for overridden methods are passed a special struct filled with +superclass methods, which allows you to do things like this: ```go -func methodCallback(super ns.MyClassSupermethods, param NSString) { +func methodCallback(self ns.MyClass, super ns.MyClassSupermethods, param NSString) { ... super.Method(param) } @@ -709,7 +707,7 @@ subclasses: ``` ```go -func pressed() { +func pressed(self ns.GButton, super ns.GButtonSupermethods) { fmt.Println("Button pressed!") } ... diff --git a/examples/bluetooth/main.go b/examples/bluetooth/main.go index 6421231..ad2eae6 100644 --- a/examples/bluetooth/main.go +++ b/examples/bluetooth/main.go @@ -10,7 +10,7 @@ import ( "time" ) -func updateState(self ns.CBDelegate, c *ns.CBCentralManager) { +func updateState(self ns.CBDelegate, c *ns.CBCentralManager, b bool) { fmt.Printf("Go: did update state\n") switch ns.NSInteger(cm.CBManager.State()) { case ns.CBManagerStateUnknown: diff --git a/wrap/main.go b/wrap/main.go index af8beb7..af79d8f 100644 --- a/wrap/main.go +++ b/wrap/main.go @@ -852,7 +852,7 @@ func (w *Wrapper) AddTypedef(n, t string) { w._processType(tp) } else { cgt := tp.CGoType() - if Debug && false { + if Debug { fmt.Printf(" processing un-wrapped type for %s -> %s\n", n, cgt) } types.AddTypedef(n, tp) @@ -1372,7 +1372,7 @@ type %s %s fmt.Printf(" gtp = %s; ctp = %s\n", gtp, ctp) } for _, c := range e.Constants { - w.goConst.WriteString(fmt.Sprintf(`const %s %s= C.%s + w.goConst.WriteString(fmt.Sprintf(`const %s %s = C.%s `, c.name, gtp, c.name)) } w.goConst.WriteString("\n")