From 1efcf36083b5737502383a4f925442049c5c4255 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 1 Sep 2009 14:47:04 -0500 Subject: [PATCH] struct-vectors: update unit test to use new structs --- basis/struct-vectors/struct-vectors-docs.factor | 4 ++-- basis/struct-vectors/struct-vectors-tests.factor | 15 +++++---------- basis/struct-vectors/struct-vectors.factor | 3 ++- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/basis/struct-vectors/struct-vectors-docs.factor b/basis/struct-vectors/struct-vectors-docs.factor index 368b054565..fe1b8991cf 100644 --- a/basis/struct-vectors/struct-vectors-docs.factor +++ b/basis/struct-vectors/struct-vectors-docs.factor @@ -1,11 +1,11 @@ IN: struct-vectors -USING: help.markup help.syntax alien strings math ; +USING: help.markup help.syntax classes.struct alien strings math ; HELP: struct-vector { $class-description "The class of growable C struct and union arrays." } ; HELP: -{ $values { "capacity" integer } { "c-type" string } { "struct-vector" struct-vector } } +{ $values { "capacity" integer } { "struct-class" struct-class } { "struct-vector" struct-vector } } { $description "Creates a new vector with the given initial capacity." } ; ARTICLE: "struct-vectors" "C struct and union vectors" diff --git a/basis/struct-vectors/struct-vectors-tests.factor b/basis/struct-vectors/struct-vectors-tests.factor index f57c64152c..dec2e96040 100644 --- a/basis/struct-vectors/struct-vectors-tests.factor +++ b/basis/struct-vectors/struct-vectors-tests.factor @@ -1,21 +1,16 @@ IN: struct-vectors.tests -USING: struct-vectors tools.test alien.c-types alien.syntax +USING: struct-vectors tools.test alien.c-types classes.struct accessors namespaces kernel sequences ; -C-STRUCT: point - { "float" "x" } - { "float" "y" } ; +STRUCT: point { x float } { y float } ; -: make-point ( x y -- point ) - "point" - [ set-point-y ] keep - [ set-point-x ] keep ; +: make-point ( x y -- point ) point ; -[ ] [ 1 "point" "v" set ] unit-test +[ ] [ 1 point "v" set ] unit-test [ 1.5 6.0 ] [ 1.0 2.0 make-point "v" get push 3.0 4.5 make-point "v" get push 1.5 6.0 make-point "v" get push - "v" get pop [ point-x ] [ point-y ] bi + "v" get pop [ x>> ] [ y>> ] bi ] unit-test \ No newline at end of file diff --git a/basis/struct-vectors/struct-vectors.factor b/basis/struct-vectors/struct-vectors.factor index 5a0654ea16..d4aa03c7ed 100644 --- a/basis/struct-vectors/struct-vectors.factor +++ b/basis/struct-vectors/struct-vectors.factor @@ -9,10 +9,11 @@ TUPLE: struct-vector { length array-capacity } { c-type read-only } ; -: ( capacity c-type -- struct-vector ) +: ( capacity struct-class -- struct-vector ) [ 0 ] keep struct-vector boa ; inline M: struct-vector byte-length underlying>> byte-length ; + M: struct-vector new-sequence [ c-type>> ] [ [ >fixnum ] [ c-type>> ] bi* ] 2bi struct-vector boa ;