git.fiddlerwoaroof.com
Browse code

Update readme + exports

Ed L authored on 09/01/2018 09:45:38
Showing 2 changed files
... ...
@@ -24,3 +24,31 @@ lisp's ffi types.
24 24
 make mkapp CCL=/path/to/ccl
25 25
 open demo.app
26 26
    #+END_SRC
27
+
28
+* Show me the code!
29
+  
30
+From demo-app.lisp:
31
+
32
+#+BEGIN_SRC lisp
33
+  (defun main ()
34
+    (trivial-main-thread:with-body-in-main-thread (:blocking t)
35
+      [#@NSAutoReleasePool @(new)]
36
+      [#@NSApplication @(sharedApplication)]
37
+      [objc-runtime::ns-app @(setActivationPolicy:) :int 0]
38
+
39
+      (let ((app-delegate (objc-runtime::objc-allocate-class-pair
40
+                           #@NSObject "AppDelegate" 0)))
41
+        (objc-runtime::add-pointer-ivar app-delegate "window")
42
+        (objc-runtime::add-pointer-ivar app-delegate "delegate"))
43
+
44
+      (let* ((bundle [#@NSBundle @(mainBundle)])
45
+             (nib [[#@NSNib @(alloc)] @(initWithNibNamed:bundle:)
46
+                                      :pointer @"MainMenu"
47
+                                      :pointer bundle]))
48
+        (cffi:with-foreign-object (p :pointer)
49
+          [nib @(instantiateWithOwner:topLevelObjects:)
50
+               :pointer objc-runtime::ns-app
51
+               :pointer p]))
52
+      [objc-runtime::ns-app @(activateIgnoringOtherApps:) :boolean t]
53
+      [objc-runtime::ns-app @(run)]))
54
+#+END_SRC
... ...
@@ -21,4 +21,5 @@
21 21
    #:ns-point-y
22 22
    #:ns-point
23 23
    #:ns-size
24
-   #:ns-rect))
24
+   #:ns-rect
25
+   #:get-method-names))