Skip to content

Latest commit

 

History

History
45 lines (31 loc) · 1.46 KB

File metadata and controls

45 lines (31 loc) · 1.46 KB

cgotest

Prototype of Swift-to-Go bridge, using Cgo.

Subsequent work, including Java-to-Go bridge:

Building and running

First, install the v23:base profile for amd64-ios and arm64-ios:

jiri profile install -target=amd64-ios v23:base
jiri profile install -target=arm64-ios v23:base

Next, build the Cgo shared libraries:

make build-ios

Finally, open the CgoSwift project in Xcode and run the tests.

Design

Async, non-streaming:

  • Swift function F accepts callback B
  • F uses GCD to dispatch the Cgo function on a non-main queue
  • When the Cgo function returns, we dispatch B on the main queue

Async, streaming:

  • Swift function F accepts callback B
  • F uses GCD to dispatch the Cgo function on a non-main queue, passing it a C-style callback that curries a handle to B
  • When the C-style callback gets invoked, we retrieve B (via the handle) and dispatch it on the main queue

In both cases, we can also make the callback queue configurable instead of always using the main queue.

References