]> gitweb.factorcode.org Git - factor.git/commitdiff
hashcode* for structs
authorJoe Groff <arcata@gmail.com>
Mon, 31 Aug 2009 15:51:45 +0000 (10:51 -0500)
committerJoe Groff <arcata@gmail.com>
Mon, 31 Aug 2009 15:51:45 +0000 (10:51 -0500)
basis/classes/struct/struct-tests.factor
basis/classes/struct/struct.factor

index 86ac0c657a951a1e731efd48700c43b4a5a8d7c0..b31d8473ab89030a5a2076ffc9686b4a75e51281 100644 (file)
@@ -184,6 +184,14 @@ STRUCT: struct-test-equality-2
     ] with-destructors
 ] unit-test
 
+[ t ] [
+    [
+        struct-test-equality-1 <struct> 5 >>x
+        struct-test-equality-1 malloc-struct &free 5 >>x
+        [ hashcode ] bi@ =
+    ] with-destructors
+] unit-test
+
 STRUCT: struct-test-ffi-foo
     { x int }
     { y int } ;
index 45dd8405dc0a43746dd09844fd992c644d5173f4..87813f792f828003a1890a44d88575a2f132b689 100644 (file)
@@ -6,7 +6,7 @@ combinators combinators.short-circuit combinators.smart
 functors.backend fry generalizations generic.parser kernel
 kernel.private lexer libc locals macros make math math.order parser
 quotations sequences slots slots.private struct-arrays vectors
-words compiler.tree.propagation.transforms ;
+words compiler.tree.propagation.transforms specialized-arrays.direct.uchar ;
 FROM: slots => reader-word writer-word ;
 IN: classes.struct
 
@@ -35,7 +35,10 @@ M: struct equal?
     {
         [ [ class ] bi@ = ]
         [ [ >c-ptr ] [ [ >c-ptr ] [ byte-length ] bi ] bi* memory= ]
-    } 2&& ;
+    } 2&& ; inline
+
+M: struct hashcode*
+    [ >c-ptr ] [ byte-length ] bi <direct-uchar-array> hashcode* ; inline    
 
 : struct-prototype ( class -- prototype ) "prototype" word-prop ; foldable