2
0
mirror of synced 2025-02-24 15:28:28 +00:00
Elias Naur 6ecf8eedb8 bind,cmd: add generator for ObjC API wrappers
Using the new ObjC type analyzer API, scan the bound packages for
references to ObjC classes and protocols and generate Go wrappers for them.

This is the second part of the implementation of proposal golang/go#17102.

For golang/go#17102

Change-Id: I773db7b0362a7ff526d0a0fd6da5b2fa33301144
Reviewed-on: https://go-review.googlesource.com/29174
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-16 10:25:40 +00:00

48 lines
1.1 KiB
Go

// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package objcpkg
import (
"ObjC/Foundation/NSDate"
"ObjC/Foundation/NSString"
"ObjC/QuartzCore/CAMediaTimingFunction"
)
func Func() {
NSDate.Date()
CAMediaTimingFunction.FunctionWithControlPoints(0, 0, 0, 0)
}
func Method() string {
d := NSDate.Date()
return d.Description()
}
func New() {
NSDate.New()
CAMediaTimingFunction.NewWithControlPoints(0, 0, 0, 0)
}
func Error() {
str, err := NSString.StringWithContentsOfFileEncodingError("<non-existent>", 0)
if err == nil {
panic("no error from stringWithContentsOfFile")
}
// Assert err is an error
err = err.(error)
if str != "" {
panic("non-empty string from stringWithContentsOfFile")
}
str, err = NSString.NewWithContentsOfFileEncodingError("<non-existent>", 0)
if err == nil {
panic("no error from stringWithContentsOfFile")
}
// Assert err is an error
err = err.(error)
if str != "" {
panic("non-empty string from initWithContentsOfFile")
}
}