git.fiddlerwoaroof.com
Browse code

feat: use foreign-funcall in readmacro expansion, not the (bad) FFI wrapper

Edward authored on 14/03/2021 08:27:22
Showing 1 changed files
... ...
@@ -30,16 +30,20 @@
30 30
     (let* ((info (read-delimited-list #\] s t))
31 31
            (safe-p (when (eql #\? (peek-char nil s nil #\p t))
32 32
                      (read-char s t nil t)))
33
-           (msg-send (case (peek-char nil s nil #\p t)
34
-                       (#\# (read-char s t nil t) (get-call-form safe-p 'num 'objc-msg-send-int))
35
-                       (#\& (read-char s t nil t) (get-call-form safe-p 'id 'objc-msg-send))
36
-                       (#\@ (read-char s t nil t) (get-call-form safe-p 'nsstring 'objc-msg-send-nsstring))
37
-                       (#\b (read-char s t nil t) (get-call-form safe-p 'bool 'objc-msg-send-bool))
38
-                       (#\s (read-char s t nil t) (get-call-form safe-p 'string 'objc-msg-send-string))
39
-                       (t                         (get-call-form safe-p 'id 'objc-msg-send)))))
33
+           (return-type (case (peek-char nil s nil #\p t)
34
+                          (#\# (read-char s t nil t) :int #+(or)(get-call-form safe-p 'num 'objc-msg-send-int))
35
+                          (#\& (read-char s t nil t) :pointer #+(or)(get-call-form safe-p 'id 'objc-msg-send))
36
+                          (#\@ (read-char s t nil t) :pointer #+(or)(get-call-form safe-p 'nsstring 'objc-msg-send-nsstring))
37
+                          (#\b (read-char s t nil t) :bool #+(or)(get-call-form safe-p 'bool 'objc-msg-send-bool))
38
+                          (#\s (read-char s t nil t) :string #+(or)(get-call-form safe-p 'string 'objc-msg-send-string))
39
+                          (t                         :pointer #+(or)(get-call-form safe-p 'id 'objc-msg-send)))))
40 40
       (when info
41 41
         (destructuring-bind (obj message . args) info
42
-          `(,@msg-send ,obj ,message ,@args))))))
42
+          `(foreign-funcall "objc_msgSend"
43
+                            :pointer ,obj
44
+                            :pointer ,message
45
+                            ,@args
46
+                            ,return-type))))))
43 47
 
44 48
 (named-readtables:defreadtable :objc-readtable
45 49
   (:merge :standard)