2
0
mirror of synced 2025-02-24 07:18:15 +00:00
mobile/bind/objc/test.bash
Hyang-Ah (Hana) Kim 926122382b bind/objc: Interface binding support
Given a Go package defining an interface,

  package testpkg
  type I interface {
      Fn()
  }

I is mapped to an objective-c protocol and a proxy interface
that implements the routing of method calls from Go.

  @protocol GoTestpkgI
  -(void)Fn;
  @end

Users implement a class conforming the generated protocol. For example,

  @interface MyI <GoTestpkgI> {
  }
  @end

  @implementation MyI {
  }
  - (void)Fn { .... }
  @end

Gobind will also create a proxy interface to handle Go objects
implementing the interface and passed to Objective-C, but that will
be hidden from users.

  @interface GoTestpkgI : NSObject <GoTestpkgI> {
  ...
  -(void)Fn;
  @end

The gobind code to generate the objective-c binding is in a separate CL.

Change-Id: I6a72d34fe3a5b8d2774d2d53913229c1e71f2d60
Reviewed-on: https://go-review.googlesource.com/12389
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2015-07-31 20:12:03 +00:00

33 lines
836 B
Bash
Executable File

#!/usr/bin/env bash
# Copyright 2015 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.
# This is a script to compile and run SeqTest.
set -e
export GOARCH=amd64
export GOOS=darwin # TODO: arm, arm64.
export CGO_ENABLED=1
WORK=`mktemp -d /tmp/objctest.XXXXX`
function cleanup() {
rm -rf ${WORK}
}
trap cleanup EXIT
# TODO: reenable this when gobind can handle interfaces.
#(cd testpkg; go generate)
go build -x -v -buildmode=c-archive -o=${WORK}/libgo.a test_main.go
cp ./seq.h ${WORK}/
cp testpkg/objc_testpkg/GoTestpkg.* ${WORK}/
cp ./SeqTest.m ${WORK}/
ccargs="-Wl,-no_pie -framework Foundation -fobjc-arc"
$(go env CC) $(go env GOGCCFLAGS) $ccargs -o ${WORK}/a.out ${WORK}/libgo.a ${WORK}/GoTestpkg.m ${WORK}/SeqTest.m
${WORK}/a.out