chiark / gitweb /
Hopefully allow (require :glib) again.
[clg] / examples / ginspect.lisp
index 25b49d18a714e14781f58ca7a8d5f33bb0fa4da5..2e5d9a1d5b689fb00e4c3ed4aa6107f9fde64398 100644 (file)
 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-;; $Id: ginspect.lisp,v 1.8 2006-02-03 00:15:52 espen Exp $
+;; $Id: ginspect.lisp,v 1.14 2006-09-15 12:46:30 espen Exp $
 
 #+sbcl(require :gtk)
-#+cmu(asdf:oos 'asdf:load-op :gtk)
+#+(or cmu clisp)(asdf:oos 'asdf:load-op :gtk)
 
 (defpackage "GINSPECT"
-  (:use "COMMON-LISP" "GLIB" "GTK" #+cmu"PCL" #+sbcl"SB-PCL")
-  (:export "GINSPECT"))
+  (:use "COMMON-LISP" "GFFI" "GLIB" "GTK" #+cmu"PCL" #+sbcl"SB-PCL" #+clisp"MOP")
+  #+clisp(:shadowing-import-from "MOP" "SLOT-DEFINITION-TYPE")
+  (:export "GINSPECT" "GINSPECT-TOPLEVELS"))
 
 (in-package "GINSPECT")
 
 (defvar *ginspect-unbound-object-marker* 
-  #+cmu (gensym "UNBOUND-OBJECT-")
+  #+(or cmu clisp)(gensym "UNBOUND-OBJECT-")
   #+sbcl sb-impl::*inspect-unbound-object-marker*)
 
 
@@ -59,9 +60,9 @@ (defun ginspect (object)
          (object (make-instance 'cell-renderer-text)))   
       (tree-view-append-column view column)
       (cell-layout-pack column name :expand nil)
-      (cell-layout-add-attribute column name 'text (column-index store 'name))
+      (cell-layout-add-attribute column name :text (tree-model-column-index store 'name))
       (cell-layout-pack column object :expand t)
-      (cell-layout-add-attribute column object 'text (column-index store 'pprinted)))
+      (cell-layout-add-attribute column object :text (tree-model-column-index store 'pprinted)))
 
     (insert-object object store nil)
 
@@ -94,7 +95,8 @@ (defmethod decompose-describe-object ((object t))
     (if (equal parts (list object))
        (values description nil nil)
       (values description named-p parts)))
-  #+sbcl(sb-impl::inspected-parts object))
+  #+sbcl(sb-impl::inspected-parts object)
+  #+clisp(values (format nil "The object is an ATOM of type ~A" (type-of object) nil nil)))
 
 (defmethod decompose-describe-object ((object (eql t)))
   (values (call-next-method) nil nil))
@@ -110,6 +112,7 @@ (defmethod decompose-describe-object ((object cons))
       (values (call-next-method) nil object)
     (values "The object is a CONS." nil (list (car object) (cdr object)))))
 
+#+(or cmu sbcl)
 (defmethod decompose-describe-object ((object #+cmu alien:system-area-pointer
                                              #+sbcl sb-alien:system-area-pointer))
   (values "The object is a SYSTEM-AREA-POINTER" nil nil))
@@ -117,7 +120,7 @@ (defmethod decompose-describe-object ((object #+cmu alien:system-area-pointer
 (defmethod decompose-describe-object ((object (eql *ginspect-unbound-object-marker*)))
   (values "The slot is unbound" nil nil))
 
-#+cmu
+#+(or cmu clisp)
 (defmethod decompose-describe-object ((object symbol))
   (values 
    (call-next-method) t
@@ -132,18 +135,27 @@ (defmethod decompose-describe-object ((object symbol))
                       *ginspect-unbound-object-marker*))
     (cons "Plist" (symbol-plist object)))))
 
-#+cmu
 (defmethod decompose-describe-object ((object standard-object))
   (values 
-   (call-next-method) t
+   (format nil "The instance is an object of type ~A" 
+    (class-name (class-of object)))
+   t
    (loop
     for slotd in (class-slots (class-of object))
-    collect (let* ((slot-name (pcl:slot-definition-name slotd))
+    when (slot-readable-p slotd)
+    collect (let* ((slot-name (slot-definition-name slotd))
                   (slot-value (if (slot-boundp object slot-name)
                                   (slot-value object slot-name)
                                 *ginspect-unbound-object-marker*)))
              (cons (string slot-name) slot-value)))))
 
+#+clisp
+(defmethod decompose-describe-object ((object vector))
+  (values   
+   (format nil "The object is a ~A of length ~A" (type-of object) (length object))
+   nil
+   (coerce object 'list)))
+
 
 (defmethod object-has-parts-p ((object t))
   (nth-value 2 (decompose-describe-object object)))