Changeset 432
- Timestamp:
- Jan 30, 2004, 11:55:34 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/ccl/examples/objc-support.lisp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/examples/objc-support.lisp
r227 r432 5 5 (eval-when (:compile-toplevel :load-toplevel :execute) 6 6 (require "BRIDGE")) 7 8 9 #+apple-objc 10 (progn 11 (let* ((class-count 0)) 12 (declare (fixnum class-count)) 13 (defun reset-objc-class-count () (setq class-count 0)) 14 (defun map-objc-classes () 15 (let* ((n (#_objc_getClassList (%null-ptr) 0))) 16 (declare (fixnum n)) 17 (if (> n class-count) 18 (%stack-block ((buffer (the fixnum (ash n ppc32::word-shift)))) 19 (#_objc_getClassList buffer n) 20 (do* ((i class-count (1+ i))) 21 ((= i n (setq class-count i))) 22 (declare (fixnum i)) 23 (install-foreign-objc-class 24 (%get-ptr buffer (the fixnum (ash i ppc32::word-shift)))))))))) 25 (def-ccl-pointers revive-objc-classes () 26 (reset-objc-class-count) 27 (map-objc-classes))) 28 29 #+gnu-objc 30 (defun iterate-over-class-methods (class method-function) 31 (do* ((mlist (pref class :objc_class.methods) 32 (pref mlist :objc_method_list.method_next))) 33 ((%null-ptr-p mlist)) 34 (do* ((n (pref mlist :objc_method_list.method_count)) 35 (i 0 (1+ i)) 36 (method (pref mlist :objc_method_list.method_list) 37 (%incf-ptr method (record-length :objc_method)))) 38 ((= i n)) 39 (declare (fixnum i n)) 40 (funcall method-function method class)))) 41 42 #+gnu-objc 43 (progn 44 (let* ((objc-class-count 0)) 45 (defun reset-objc-class-count () (setq objc-class-count 0)) 46 (defun note-all-library-methods (method-function) 47 (do* ((i objc-class-count (1+ i)) 48 (class (id->objc-class i) (id->objc-class i))) 49 ((eq class 0)) 50 (iterate-over-class-methods class method-function) 51 (iterate-over-class-methods (id->objc-metaclass i) method-function)))) 52 (def-ccl-pointers revive-objc-classes () 53 (reset-objc-class-count))) 54 55 (defun retain-obcj-object (x) 56 (objc-message-send x "retain")) 7 57 8 58 #+apple-objc … … 76 126 (nsobject-description (ns-exception c)))))) 77 127 78 (def-objc-class ns-lisp-exception ns-exception 79 (lispid :unsigned)) 128 129 130 (defclass ns-lisp-exception (ns::ns-exception) 131 ((lispid :foreign-type :unsigned)) 132 (:metaclass ns::+ns-object)) 80 133 81 134 (define-objc-method ((:id :init-with-lisp-id (:unsigned lisp-id)) … … 84 137 :reason #@"lisp exception" 85 138 :user-info (%null-ptr))) 86 (set q lispidlisp-id)139 (setf (slot-value self 'lispid) lisp-id) 87 140 self) 88 141 89 142 (define-objc-method ((:unsigned lisp-id) ns-lisp-exception) 90 lispid)143 (slot-value self 'lispid)) 91 144 92 145 (defun ns-exception->lisp-condition (nsexception) … … 95 148 (id-map-free-object *condition-id-map* (send nsexception 'lisp-id)) 96 149 (make-condition 'ns-exception :ns-exception nsexception))) 150 97 151 98 152 (defmethod ns-exception ((c condition)) … … 106 160 #|(dbg (format nil "~a" c))|# 107 161 (make-objc-instance 'ns-lisp-exception 108 :with-lisp-id (assign-id-map-id *condition-id-map* c))) 162 :with-lisp-id (assign-id-map-id *condition-id-map* c))) 163 164 165 166 (defun ns-exception->lisp-condition (nsexception) 167 (if (typep nsexception 'ns-lisp-exception) 168 (id-map-free-object *condition-id-map* (slot-value nsexception 'lispid)) 169 (make-condition 'ns-exception :ns-exception nsexception))) 109 170 110 171 #+apple-objc … … 124 185 125 186 ) 187 188 126 189 127 190 (defun open-main-bundle ()
Note:
See TracChangeset
for help on using the changeset viewer.
