From f0e14d1c3c5176df3d0c03a254a2641fcf168f3c Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Mon, 31 Aug 2009 19:27:29 -0500
Subject: [PATCH] mirrors on structs again, add summary method for structs

---
 basis/mirrors/mirrors.factor | 10 ++++++++++
 basis/summary/summary.factor | 11 ++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/basis/mirrors/mirrors.factor b/basis/mirrors/mirrors.factor
index 7190d61240..d9120da9dc 100644
--- a/basis/mirrors/mirrors.factor
+++ b/basis/mirrors/mirrors.factor
@@ -56,3 +56,13 @@ M: array make-mirror <enum> ;
 M: vector make-mirror <enum> ;
 M: quotation make-mirror <enum> ;
 M: object make-mirror <mirror> ;
+
+M: struct make-mirror
+    [
+        [ drop "underlying" ] [ (underlying)>> ] bi 2array 1array
+    ] [
+        '[
+            _ struct>assoc
+            [ [ [ name>> ] [ c-type>> ] bi 2array ] dip ] assoc-map
+        ] [ drop { } ] recover
+    ] bi append ;
diff --git a/basis/summary/summary.factor b/basis/summary/summary.factor
index 44e5374dc5..d8542c7f83 100644
--- a/basis/summary/summary.factor
+++ b/basis/summary/summary.factor
@@ -1,7 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors classes sequences kernel namespaces
-make words math math.parser assocs ;
+make words math math.parser assocs classes.struct
+alien.c-types ;
 IN: summary
 
 GENERIC: summary ( object -- string )
@@ -31,3 +32,11 @@ M: assoc summary
 M: f summary object-summary ;
 
 M: integer summary object-summary ;
+
+M: struct summary
+    [
+        dup class name>> %
+        " struct of " %
+        byte-length #
+        " bytes " %
+    ] "" make ;