;; 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.42 2006/02/04 12:15:32 espen Exp $
+;; $Id: gobject.lisp,v 1.44 2006/02/06 11:34:05 espen Exp $
(in-package "GLIB")
;;;; Metaclass used for subclasses of gobject
(eval-when (:compile-toplevel :load-toplevel :execute)
+;; (push :debug-ref-counting *features*)
(defclass gobject-class (ginstance-class)
((instance-slots-p :initform nil
:documentation "Non NIL if the class has slots with instance allocation")))
(eval-when (:compile-toplevel :load-toplevel :execute)
(defclass gobject (ginstance)
- ()
+ (#+debug-ref-counting
+ (ref-count :allocation :alien :type int :reader ref-count))
(:metaclass gobject-class)
(:gtype "GObject")))
+#+debug-ref-counting
+(defmethod print-object ((instance gobject) stream)
+ (print-unreadable-object (instance stream :type t :identity nil)
+ (if (slot-boundp instance 'location)
+ (format stream "at 0x~X (~D)" (sap-int (foreign-location instance)) (ref-count instance))
+ (write-string "at \"unbound\"" stream))))
+
(defun initial-add (object function initargs key pkey)
(loop
initargs key pkey))
+(defmethod make-proxy-instance ((class gobject-class) location &rest initargs)
+ (declare (ignore location initargs))
+ (if (slot-value class 'instance-slots-p)
+ (error "An object of class ~A has instance slots and should only be created with MAKE-INSTANCE" class)
+ (call-next-method)))
+
(defmethod initialize-instance :around ((object gobject) &rest initargs)
(declare (ignore initargs))
(call-next-method)