name | mode | size |
---|---|---|
demo.app.template | 040000 | |
.gitignore | 100644 | 0 kb |
MainMenu.xib | 100644 | 54 kb |
Makefile | 100644 | 1 kb |
Makefile.minimal | 100644 | 1 kb |
README.org | 100644 | 2 kb |
build-reading-list-reader.sh | 100644 | 0 kb |
build.lisp | 100644 | 1 kb |
demo-app.lisp | 100644 | 9 kb |
demo-app.svg | 100644 | 12 kb |
gcd.lisp | 100644 | 1 kb |
mop-test.lisp | 100644 | 1 kb |
nsrect-expose.m | 100644 | 1 kb |
objc-data-extractors.lisp | 100644 | 4 kb |
objc-runtime-types.lisp | 100644 | 1 kb |
objc-runtime.asd | 100644 | 1 kb |
objc-runtime.lisp | 100644 | 11 kb |
package.lisp | 100644 | 1 kb |
reading-list-reader.lisp | 100644 | 2 kb |
readtable.lisp | 100644 | 3 kb |
save.lisp | 100644 | 0 kb |
* Intro
CCL and LispWorks and other implementations have their own bridges to
the objective-c runtime. This project is an attempt to create a
bridge that only uses CFFI so that arbitrary lisp implementations can
produce native mac GUIs. In the long run, I hope to use this as the
basis for a new mac-native backend for McClim: but we'll see if that
ever happens.
For the time being, though, this only works on CCL and (sort-of) on
LispWorks: it works like 95% on SBCL, but there's some weird issue
that's preventing the window from showing. I hae not tested the code
on any other implementations, but doing so will require changing a
couple places in objc-runtime.lisp to inform the code about the new
lisp's ffi types.
* Installing
1. clone fwoar.lisputils from
https://github.com/fiddlerwoaroof/fwoar.lisputils and put it
somewhere quicklisp can find it (e.g. ~/quicklisp/local-projects)
2. Install rsvg-convert:
#+BEGIN_SRC sh
brew install librsvg
#+END_SRC
3. build + run the demo:
#+BEGIN_SRC sh
make mkapp CCL=/path/to/ccl
open demo.app
#+END_SRC
* Show me the code!
From demo-app.lisp:
#+BEGIN_SRC lisp
(defun main ()
(trivial-main-thread:with-body-in-main-thread (:blocking t)
[#@NSAutoReleasePool @(new)]
[#@NSApplication @(sharedApplication)]
[objc-runtime::ns-app @(setActivationPolicy:) :int 0]
(objc-runtime::objc-register-class-pair
(demo-app::make-app-delegate-class '("actionButton"
"alertButton"
"profitButton")))
(demo-app::load-nib "MainMenu")
(let ((app-delegate [objc-runtime::ns-app @(delegate)]))
(demo-app::make-button-delegate (value-for-key app-delegate "actionButton")
(cffi:callback do-things-action))
(demo-app::make-button-delegate (value-for-key app-delegate "alertButton")
(cffi:callback alert-action))
(demo-app::make-button-delegate (value-for-key app-delegate "profitButton")
(cffi:callback profit-action)))
[objc-runtime::ns-app @(activateIgnoringOtherApps:) :boolean t]
[objc-runtime::ns-app @(run)]))
#+END_SRC