Change name of New* functions to *Alloc to mimic Objective-C's

nested alloc/init call idiom.
This commit is contained in:
Greg 2019-05-04 23:32:57 -04:00
parent eced251710
commit 717c7e76fe
4 changed files with 4 additions and 13 deletions

1
.gitignore vendored
View File

@ -1,7 +1,6 @@
clast
ast.txt
*.ast
program
examples/bluetooth/bluetooth
examples/bluetooth/ble/main.go
examples/foundation/foundation

View File

@ -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())

View File

@ -1,8 +0,0 @@
#import <CoreBluetooth/CoreBluetooth.h>
int
main(int argc, char* argv[]) {
CBCentralManager *m;
return 0;
}

View File

@ -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))