From 717c7e76fe85093cbc4d616ad02ca5ce1d6c1c88 Mon Sep 17 00:00:00 2001 From: Greg Date: Sat, 4 May 2019 23:32:57 -0400 Subject: [PATCH] Change name of New* functions to *Alloc to mimic Objective-C's nested alloc/init call idiom. --- .gitignore | 1 - examples/bluetooth/main.go | 2 +- objc/main.m | 8 -------- wrap/main.go | 6 +++--- 4 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 objc/main.m diff --git a/.gitignore b/.gitignore index da9ce23..d3a2cb1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ clast ast.txt *.ast -program examples/bluetooth/bluetooth examples/bluetooth/ble/main.go examples/foundation/foundation diff --git a/examples/bluetooth/main.go b/examples/bluetooth/main.go index 9c5a6f8..35dcc8d 100644 --- a/examples/bluetooth/main.go +++ b/examples/bluetooth/main.go @@ -7,7 +7,7 @@ import ( ) func main() { - cd := ble.NewBle_delegate().Init() + cd := ble.Ble_delegateAlloc().Init() fmt.Println("LE capable:",cd.IsLECapableHardware()) time.Sleep(time.Second * 1) fmt.Println("LE capable:",cd.IsLECapableHardware()) diff --git a/objc/main.m b/objc/main.m deleted file mode 100644 index 21c4472..0000000 --- a/objc/main.m +++ /dev/null @@ -1,8 +0,0 @@ -#import - -int -main(int argc, char* argv[]) { - CBCentralManager *m; - return 0; -} - diff --git a/wrap/main.go b/wrap/main.go index e74a494..7c63dff 100644 --- a/wrap/main.go +++ b/wrap/main.go @@ -745,14 +745,14 @@ func (w *Wrapper) Wrap(toproc []string) { i.Name, len(i.Properties), len(i.Methods)) w.goCode.WriteString(fmt.Sprintf(` -func New%s() *%s { - return (*%s)(unsafe.Pointer(C.New%s())) +func %sAlloc() *%s { + return (*%s)(unsafe.Pointer(C.%sAlloc())) } `,i.GoName,i.GoName,i.GoName,i.Name)) w.cCode.WriteString(fmt.Sprintf(` %s* -New%s() { +%sAlloc() { return [%s alloc]; } `, i.Name, i.Name, i.Name))