From 09357be710b046ae41bb85446f2a6ded9ba0fd4e Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 14 Apr 2021 20:59:30 -0400 Subject: node: Add custom write method. --- starling/node.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/starling/node.scm b/starling/node.scm index 6461f58..14e4e17 100644 --- a/starling/node.scm +++ b/starling/node.scm @@ -22,6 +22,7 @@ (define-module (starling node) #:use-module (chickadee scripting) + #:use-module (ice-9 format) #:use-module (oop goops) #:use-module (starling asset) #:use-module (starling config) @@ -178,6 +179,20 @@ )) +(define-method (write (node ) port) + (define (strip-angle-brackets str) + (let ((start (if (string-prefix? "<" str) 1 0)) + (end (if (string-suffix? ">" str) + (- (string-length str) 1) + (string-length str)))) + (substring str start end))) + (format port "#<~a name: ~a id: ~d>" + (strip-angle-brackets + (symbol->string + (class-name (class-of node)))) + (name node) + (id node))) + (define-method (initialize (node ) initargs) (next-method) ;; Add node to global index. -- cgit v1.2.3