summaryrefslogtreecommitdiff
path: root/starling/node.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2021-04-14 20:59:30 -0400
committerDavid Thompson <dthompson2@worcester.edu>2021-04-14 20:59:30 -0400
commit09357be710b046ae41bb85446f2a6ded9ba0fd4e (patch)
treeb7b866b562c97c07c5d44608aaed18cb21a86c60 /starling/node.scm
parentcc97cfe878f2e0cb010c26c0e5cb650720b06dfb (diff)
node: Add custom write method.
Diffstat (limited to 'starling/node.scm')
-rw-r--r--starling/node.scm15
1 files changed, 15 insertions, 0 deletions
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 @@
<developer-meta-node>
<meta-node>))
+(define-method (write (node <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 <node>) initargs)
(next-method)
;; Add node to global index.