Tuesday, March 21, 2006

Objective C FFI now supports super message sends

While the Objective C FFI has had the ability to define subclasses for a while now, you were unable to call the superclass method from inside a subclass. Well now you can, for example consider the following definition of the FactorView class from the UI backend:

"NSOpenGLView" "FactorView" {
....
{ "initWithFrame:pixelFormat:" "id" { "id" "SEL" "NSRect" "id" }
[
rot drop
SUPER-> [initWithFrame:pixelFormat:]
dup "updateFactorGadgetSize:" add-resize-observer
]
}

{ "dealloc" "void" { "id" "SEL" }
[
drop
dup view close-world
dup views get remove-hash
dup remove-observer
SUPER-> [dealloc]
]
}
....
} { } define-objc-class


The addition of this capability makes the Cocoa interface feature-complete. I have been able to implement the missing parts from the UI backend, and modulo bugs, its pretty much done.

I'm very happy with the level of integration I've managed to achieve with the Cocoa binding. Factor can introspect Cocoa classes, define new Objective C classes, catch and throw Cocoa exceptions, and resend methods to the superclass. I'm not aware of any other concatenative language with such a comprehensive Cocoa binding.

So my main focus is now the X11 backend, and helping Doug implement the Win32 backend. The cool thing is, when this is all done, not only will Factor have a more powerful cross-platform UI, but also top-notch bindings for native graphics libraries which developers can call directly if they wish. I intend to document everything at all layers of the graphics subsystem.

1 comment:

Chris Burnley said...

excellent, when will 0.81 be out, I'm keen to check it out but the sdl bindings have never worked under OS X for me