;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-;; $Id: gobject.lisp,v 1.48 2006/02/19 19:31:14 espen Exp $
+;; $Id: gobject.lisp,v 1.51 2006/03/03 10:01:01 espen Exp $
(in-package "GLIB")
(progn
(define-callback toggle-ref-callback nil
((data pointer) (location pointer) (last-ref-p boolean))
+ (declare (ignore data))
#+debug-ref-counting
(if last-ref-p
(format t "Object at 0x~8,'0X has no foreign references~%" (sap-int location))
(cache-instance (find-cached-instance location) t)
(cache-instance (find-cached-instance location) nil)))
- (defbinding %object-add-toggle-ref () pointer
+ (defbinding %object-add-toggle-ref (location) pointer
(location pointer)
(toggle-ref-callback callback)
(nil null))
- (defbinding %object-remove-toggle-ref () pointer
+ (defbinding %object-remove-toggle-ref (location) pointer
(location pointer)
(toggle-ref-callback callback)
(nil null)))
(define-callback weak-ref-callback nil ((data pointer) (location pointer))
(format t "Object at 0x~8,'0X being finalized~%" (sap-int location)))
- (defbinding %object-weak-ref () pointer
+ (defbinding %object-weak-ref (location) pointer
(location pointer)
(weak-ref-callback callback)
(nil null)))
(setf (slot-value class 'instance-slots-p) t)))
-
;;;; Super class for all classes in the GObject type hierarchy
(eval-when (:compile-toplevel :load-toplevel :execute)
(:metaclass gobject-class)
(:gtype "GObject")))
+(define-type-method callback-from-alien-form ((type gobject) form)
+ (from-alien-form type form))
+
#+debug-ref-counting
(defmethod print-object ((instance gobject) stream)
(print-unreadable-object (instance stream :type t :identity nil)
;;; Pseudo type for gobject instances which have their reference count
;;; increased by the returning function
-(defmethod alien-type ((type (eql 'referenced)) &rest args)
- (declare (ignore type args))
- (alien-type 'gobject))
+(deftype referenced (type) type)
-(defmethod from-alien-form (form (type (eql 'referenced)) &rest args)
+(define-type-method alien-type ((type referenced))
(declare (ignore type))
- (destructuring-bind (type) args
+ (alien-type 'gobject))
+
+(define-type-method from-alien-form ((type referenced) form)
+ (let ((class (second (type-expand-to 'referenced type))))
(if (subtypep type 'gobject)
(let ((instance (make-symbol "INSTANCE")))
- `(let ((,instance ,(from-alien-form form type)))
+ `(let ((,instance ,(from-alien-form class form)))
(when ,instance
(%object-unref (foreign-location ,instance)))
,instance))