]> gitweb.factorcode.org Git - factor.git/blobdiff - core/io/streams/c/c.factor
Disposables are now registered in a global disposables set. To take advantage of...
[factor.git] / core / io / streams / c / c.factor
index 7a7ac5a97ccfc7e42b2c2a42a9e3cefebbc7cc2c..aebc709a9e79372626c0bd6207d3bbf1cee93cda 100755 (executable)
@@ -6,7 +6,10 @@ io.encodings.utf8 alien.strings continuations destructors byte-arrays
 accessors combinators ;
 IN: io.streams.c
 
-TUPLE: c-stream handle disposed ;
+TUPLE: c-stream < disposable handle ;
+
+: new-c-stream ( handle class -- c-stream )
+    new-disposable swap >>handle ; inline
 
 M: c-stream dispose* handle>> fclose ;
 
@@ -20,7 +23,7 @@ M: c-stream stream-seek
 
 TUPLE: c-writer < c-stream ;
 
-: <c-writer> ( handle -- stream ) f c-writer boa ;
+: <c-writer> ( handle -- stream ) c-writer new-c-stream ;
 
 M: c-writer stream-element-type drop +byte+ ;
 
@@ -32,7 +35,7 @@ M: c-writer stream-flush dup check-disposed handle>> fflush ;
 
 TUPLE: c-reader < c-stream ;
 
-: <c-reader> ( handle -- stream ) f c-reader boa ;
+: <c-reader> ( handle -- stream ) c-reader new-c-stream ;
 
 M: c-reader stream-element-type drop +byte+ ;