Skip to content
Bruce Mitchener edited this page Jan 27, 2014 · 13 revisions

There is the start of an Objective-C bridge available.

Notably, it lacks support for objc_msgSend.

We need a design for how this should work, preferably informed by other implementations. Some Common Lisp implementations have Objective-C bridges and may be a good place to look.

In Dylan, this may require some compiler support, similar to direct-c-ffi or the higher level c-ffi.

Some sources of information about the Objective-C run-time and other bridges to it:

Message Invocation

To support objc_msgSend invocations properly, we will probably need a compiler extension similar to %call-c-function, with the corresponding support in DFMC.

Relevant places to look at for how %call-c-function works are the references to <&c-function> in:

  • sources/dfmc/modeling/c-function-models.dylan
  • sources/dfmc/back-end/emit-object.dylan
  • sources/dfmc/back-end/heaps.dylan
  • sources/dfmc/c-back-end/c-emit-c-computation.dylan
  • sources/dfmc/c-linker/c-link-c-object.dylan
  • sources/dfmc/debug-back-end/c-debug.dylan
  • sources/dfmc/flow-graph/dfm-copier.dylan

BridgeSupport

We should be able to have melange read in BridgeSupport files and generate the appropriate bindings as defined in interface files like we do for C APIs.

Alternatively, we can do something like gir-dylan does for GTK+ rather than building upon melange.

Associated Objects

The Objective-C 2.0 run-time supports associating objects via objc_getAssociatedObject, objc_setAssociatedObject and friends. We need to provide a binding for this as well. This probably will relate to also supporting subclassing.

Subclassing and New Methods

The Objective-C 2.0 run-time provides enough support to allow Dylan programs to create new subclasses of Objective-C classes as well as to expose new method implementations.

Optimizing to use objc_msgSend_vtable

We will need compiler support to do this correctly, but some invocations of objc_msgSend could, in fact, become invocations of the objc_msgSend_vtable* functions. The code generated should actually be using objc_msgSend_fixup in this situation to enable this optimization within the Objective C run-time.

For details, see [objc-explain]: objc_msgSend_vtable by Greg Parker.

Clone this wiki locally