1 ;;; semantic-adebug-eieio.el --- EIEIO extensions to adebug
3 ;; Copyright (C) 2007 Eric M. Ludlam
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
6 ;; X-RCS: $Id: semantic-adebug-eieio.el,v 1.1 2007-11-26 15:10:31 michaels Exp $
8 ;; This program is free software; you can redistribute it and/or
9 ;; modify it under the terms of the GNU General Public License as
10 ;; published by the Free Software Foundation; either version 2, or (at
11 ;; your option) any later version.
13 ;; This program is distributed in the hope that it will be useful, but
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ;; General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
25 ;; Extensions to semantic Adebug for EIEIO objects.
29 (defun semantic-adebug-insert-object-fields (object prefix)
30 "Insert all the fields of OBJECT.
31 PREFIX specifies what to insert at the start of each line."
32 (let ((attrprefix (concat (make-string (length prefix) ? ) "] "))
34 (semantic-adebug/eieio-insert-fields object attrprefix)
38 (defun semantic-adebug-insert-object-fields-from-point (point)
39 "Insert the object fields found at the object button at POINT."
40 (let ((object (get-text-property point 'adebug))
41 (indent (get-text-property point 'adebug-indent))
47 (semantic-adebug-insert-object-fields object
48 (concat (make-string indent ? )
55 (defun semantic-adebug-insert-object-button (object prefix prebuttontext)
56 "Insert a button representing OBJECT.
57 PREFIX is the text that preceeds the button.
58 PREBUTTONTEXT is some text between PREFIX and the object button."
61 (str (object-name object))
62 (tip (format "Object %s\nClass: %S\nParent(s): %S\n%d slots"
63 (object-name-string object)
65 (class-parents (object-class object))
66 (length (object-slots object))
69 (insert prefix prebuttontext str)
71 (put-text-property (- end (length str)) end 'face 'font-lock-keyword-face)
72 (put-text-property start end 'adebug object)
73 (put-text-property start end 'adebug-indent(length prefix))
74 (put-text-property start end 'adebug-prefix prefix)
75 (put-text-property start end 'help-echo tip)
76 (put-text-property start end 'adebug-function
77 'semantic-adebug-insert-object-fields-from-point)
84 ;; Each object should have an opportunity to show stuff about itself.
86 (defmethod semantic-adebug/eieio-insert-fields ((obj eieio-default-superclass)
88 "Insert the fields of OBJ into the current ADEBUG buffer."
89 (semantic-adebug-insert-thing (object-name-string obj)
92 (let* ((cl (object-class obj))
94 (semantic-adebug-insert-thing (class-constructor cl)
97 ;; Loop over all the public slots
98 (let ((publa (aref cv class-public-a))
99 (publd (aref cv class-public-d))
102 (if (slot-boundp obj (car publa))
103 (let ((i (class-slot-initarg cl (car publa)))
104 (v (eieio-oref obj (car publa))))
105 (semantic-adebug-insert-thing
107 (if i (symbol-name i)
108 (symbol-name (car publa)))
111 (let ((i (class-slot-initarg cl (car publa))))
112 (semantic-adebug-insert-thing
114 (concat (if i (symbol-name i)
115 (symbol-name (car publa)))
118 (setq publa (cdr publa) publd (cdr publd)))
123 (provide 'semantic-adebug-eieio)
125 ;;; semantic-adebug-eieio.el ends here