From 5904d3fffae0c1fed2797df1bde32f956130e32d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Mar 2008 15:24:49 -0500 Subject: [PATCH] Fix set-timeout with dan's new encoding stuff --- core/classes/classes-tests.factor | 12 +++++++----- core/io/encodings/encodings.factor | 26 ++++++++++++++------------ extra/io/timeouts/timeouts.factor | 6 +++++- extra/tools/deploy/deploy-tests.factor | 3 ++- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/core/classes/classes-tests.factor b/core/classes/classes-tests.factor index 7d43ee905a..f97f088845 100755 --- a/core/classes/classes-tests.factor +++ b/core/classes/classes-tests.factor @@ -1,6 +1,6 @@ USING: alien arrays definitions generic assocs hashtables io kernel math namespaces parser prettyprint sequences strings -tools.test vectors words quotations classes io.streams.string +tools.test vectors words quotations classes classes.private classes.union classes.mixin classes.predicate vectors definitions source-files compiler.units ; IN: classes.tests @@ -63,10 +63,6 @@ UNION: c a b ; UNION: bah fixnum alien ; [ bah ] [ \ bah? "predicating" word-prop ] unit-test -! Test generic see and parsing -[ "USING: alien math ;\nIN: classes.tests\nUNION: bah fixnum alien ;\n" ] -[ [ \ bah see ] with-string-writer ] unit-test - ! Test redefinition of classes UNION: union-1 fixnum float ; @@ -180,6 +176,8 @@ UNION: forget-class-bug-2 forget-class-bug-1 dll ; [ f ] [ forget-class-bug-2 typemap get values [ memq? ] with contains? ] unit-test +USE: io.streams.string + 2 [ [ "mixin-forget-test" forget-source ] with-compilation-unit @@ -224,3 +222,7 @@ MIXIN: flat-mx-2 INSTANCE: flat-mx-2 flat-mx-1 TUPLE: flat-mx-2-1 ; INSTANCE: flat-mx-2-1 flat-mx-2 [ t ] [ T{ flat-mx-2-1 } flat-mx-1? ] unit-test + +! Test generic see and parsing +[ "USING: alien math ;\nIN: classes.tests\nUNION: bah fixnum alien ;\n" ] +[ [ \ bah see ] with-string-writer ] unit-test diff --git a/core/io/encodings/encodings.factor b/core/io/encodings/encodings.factor index 4cd43ef455..03ea2262a8 100755 --- a/core/io/encodings/encodings.factor +++ b/core/io/encodings/encodings.factor @@ -14,19 +14,26 @@ GENERIC: encode-char ( char stream encoding -- ) GENERIC: ( stream decoding -- newstream ) -GENERIC: ( stream encoding -- newstream ) - : replacement-char HEX: fffd ; -! Decoding - - ( stream encoding -- newstream ) + +TUPLE: encoder stream code ; + +TUPLE: encode-error ; + +: encode-error ( -- * ) \ encode-error construct-empty throw ; + +! Decoding + + construct-empty ; M: tuple f decoder construct-boa ; @@ -101,12 +108,6 @@ M: decoder stream-readln ( stream -- str ) M: decoder dispose decoder-stream dispose ; ! Encoding - -TUPLE: encode-error ; - -: encode-error ( -- * ) \ encode-error construct-empty throw ; - -TUPLE: encoder stream code ; M: tuple-class construct-empty ; M: tuple encoder construct-boa ; @@ -132,6 +133,7 @@ INSTANCE: encoder plain-writer : redecode ( stream encoding -- newstream ) over decoder? [ >r decoder-stream r> ] when ; + PRIVATE> : ( stream-in stream-out encoding -- duplex ) diff --git a/extra/io/timeouts/timeouts.factor b/extra/io/timeouts/timeouts.factor index ef660a6f0d..f1031e98e2 100755 --- a/extra/io/timeouts/timeouts.factor +++ b/extra/io/timeouts/timeouts.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Slava Pestov, Doug Coleman ! See http://factorcode.org/license.txt for BSD license. -USING: kernel calendar alarms io.streams.duplex ; +USING: kernel calendar alarms io.streams.duplex io.encodings ; IN: io.timeouts ! Won't need this with new slot accessors @@ -12,6 +12,10 @@ M: duplex-stream set-timeout duplex-stream-in set-timeout duplex-stream-out set-timeout ; +M: decoder set-timeout decoder-stream set-timeout ; + +M: encoder set-timeout encoder-stream set-timeout ; + GENERIC: timed-out ( obj -- ) M: object timed-out drop ; diff --git a/extra/tools/deploy/deploy-tests.factor b/extra/tools/deploy/deploy-tests.factor index c7a97e7787..3b88d14fb3 100755 --- a/extra/tools/deploy/deploy-tests.factor +++ b/extra/tools/deploy/deploy-tests.factor @@ -1,6 +1,7 @@ IN: tools.deploy.tests USING: tools.test system io.files kernel tools.deploy.config -tools.deploy.backend math sequences io.launcher arrays ; +tools.deploy.backend math sequences io.launcher arrays +namespaces ; : shake-and-bake ( vocab -- ) "." resource-path [