Index: scm/output-lib.scm |
diff --git a/scm/output-lib.scm b/scm/output-lib.scm |
index 2b2a65c719f12ec575c6587c206180e8bf89fb8b..a73e2c0324977e6046d45c8cfb736bd59ec4c644 100644 |
--- a/scm/output-lib.scm |
+++ b/scm/output-lib.scm |
@@ -130,6 +130,44 @@ |
line-thickness)) |
+(define (grob::objects-from-interface grob iface) |
+ "For grob @var{grob} return the name and contents of all properties |
+ within interface @var{iface} having type @code{ly:grob?} or |
+ @code{ly:grob-array?}." |
+ (let* ((iface-entry (hashq-ref (ly:all-grob-interfaces) iface)) |
+ (props (if iface-entry (last iface-entry) '())) |
+ (pointer-props |
+ (filter |
+ (lambda (prop) |
+ (let ((type (object-property prop 'backend-type?))) |
+ (or (eq? type ly:grob?) |
+ (eq? type ly:grob-array?)))) |
+ props))) |
+ (if (null? pointer-props) |
+ '() |
+ (list iface |
+ (map |
+ (lambda (prop) (list prop (ly:grob-object grob prop))) |
+ pointer-props))))) |
+ |
+(define-public (grob::all-objects grob) |
+ "Return a list of the names and contents of all properties having type |
+ @code{ly:grob?} or @code{ly:grob-array?} for all interfaces supported by |
+ grob @var{grob}." |
+ (let loop ((ifaces (ly:grob-interfaces grob)) (result '())) |
+ (if (null? ifaces) |
+ (cons grob (list result)) |
+ (let ((entry (grob::objects-from-interface grob (car ifaces)))) |
+ (if (pair? entry) |
+ (loop (cdr ifaces) (append result (list entry))) |
+ (loop (cdr ifaces) result)))))) |
+ |
+(use-modules (ice-9 pretty-print)) |
thomasmorley651
2015/03/24 21:58:28
I always regretted that (ice-9 pretty-print) is no
david.nalesnik
2015/03/25 00:15:45
It isn't loaded in scm/lily.scm where a number of
david.nalesnik
2015/03/25 01:13:20
Well, it's not much code of course. Would it even
david.nalesnik
2015/03/25 13:59:20
Looks like all that needs to be done is to add
(us
thomasmorley651
2015/03/27 01:12:15
Yes, would be great.
|
+(define-public (grob::display-objects grob) |
+ "Display all objects stored in properties of grob @var{grob}." |
+ (pretty-print (grob::all-objects grob)) |
+ (newline)) |
+ |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; beam slope |