]> gitweb.factorcode.org Git - factor.git/commitdiff
Forget struct slot accessors when structs classes are redefined
authorDoug Coleman <doug.coleman@gmail.com>
Tue, 4 Oct 2011 00:12:49 +0000 (17:12 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Tue, 4 Oct 2011 00:12:49 +0000 (17:12 -0700)
basis/classes/struct/struct.factor

index 7a9b05aa67b23cbf5358c18d87f788076b21de80..f16b4be1d8c30e7519f86a042735188812562877 100644 (file)
@@ -321,13 +321,23 @@ ERROR: invalid-struct-slot token ;
     c-type c-type-boxed-class
     dup \ byte-array = [ drop \ c-ptr ] when ;
 
+: forget-struct-accessors ( class -- )
+    dup "c-type" word-prop fields>> [
+        name>>
+        [ reader-word ?lookup-method forget ]
+        [ writer-word ?lookup-method forget ] 2bi
+    ] with each ;
+
 M: struct-class reset-class
-    [ call-next-method ]
-    [
-        [ forget-struct-slot-values-method ]
-        [ forget-clone-method ] bi
-    ]
-    [ { "c-type" "layout" "struct-size" } reset-props ] tri ;
+    {
+        [ forget-struct-accessors ]
+        [
+            [ forget-struct-slot-values-method ]
+            [ forget-clone-method ] bi
+        ]
+        [ { "c-type" "layout" "struct-size" } reset-props ]
+        [ call-next-method ]
+    } cleave ;
 
 SYMBOL: bits: