Move a few more things over to new disposable protocol

db4
Slava Pestov 2009-08-24 20:33:27 -05:00
parent adc154e06b
commit b2a1858f8f
5 changed files with 14 additions and 12 deletions

View File

@ -19,13 +19,13 @@ C: <openssl-checksum> openssl-checksum
<PRIVATE <PRIVATE
TUPLE: evp-md-context handle ; TUPLE: evp-md-context < disposable handle ;
: <evp-md-context> ( -- ctx ) : <evp-md-context> ( -- ctx )
"EVP_MD_CTX" <c-object> evp-md-context new-disposable
dup EVP_MD_CTX_init evp-md-context boa ; "EVP_MD_CTX" <c-object> dup EVP_MD_CTX_init >>handle ;
M: evp-md-context dispose M: evp-md-context dispose*
handle>> EVP_MD_CTX_cleanup drop ; handle>> EVP_MD_CTX_cleanup drop ;
: with-evp-md-context ( quot -- ) : with-evp-md-context ( quot -- )

View File

@ -18,7 +18,7 @@ TUPLE: epoll-mx < mx events ;
max-events epoll_create dup io-error >>fd max-events epoll_create dup io-error >>fd
max-events "epoll-event" <struct-array> >>events ; max-events "epoll-event" <struct-array> >>events ;
M: epoll-mx dispose fd>> close-file ; M: epoll-mx dispose* fd>> close-file ;
: make-event ( fd events -- event ) : make-event ( fd events -- event )
"epoll-event" <c-object> "epoll-event" <c-object>

View File

@ -17,7 +17,7 @@ TUPLE: kqueue-mx < mx events ;
kqueue dup io-error >>fd kqueue dup io-error >>fd
max-events "kevent" <struct-array> >>events ; max-events "kevent" <struct-array> >>events ;
M: kqueue-mx dispose fd>> close-file ; M: kqueue-mx dispose* fd>> close-file ;
: make-kevent ( fd filter flags -- event ) : make-kevent ( fd filter flags -- event )
"kevent" <c-object> "kevent" <c-object>

View File

@ -1,12 +1,12 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel accessors assocs sequences threads ; USING: kernel accessors assocs sequences threads destructors ;
IN: io.backend.unix.multiplexers IN: io.backend.unix.multiplexers
TUPLE: mx fd reads writes ; TUPLE: mx < disposable fd reads writes ;
: new-mx ( class -- obj ) : new-mx ( class -- obj )
new new-disposable
H{ } clone >>reads H{ } clone >>reads
H{ } clone >>writes ; inline H{ } clone >>writes ; inline

View File

@ -46,13 +46,15 @@ HOOK: (pixel-format-attribute) ui-backend ( pixel-format attribute-name -- value
ERROR: invalid-pixel-format-attributes world attributes ; ERROR: invalid-pixel-format-attributes world attributes ;
TUPLE: pixel-format world handle ; TUPLE: pixel-format < disposable world handle ;
: <pixel-format> ( world attributes -- pixel-format ) : <pixel-format> ( world attributes -- pixel-format )
2dup (make-pixel-format) 2dup (make-pixel-format)
[ nip pixel-format boa ] [ invalid-pixel-format-attributes ] if* ; [ pixel-format new swap >>handle swap >>world ]
[ invalid-pixel-format-attributes ]
?if ;
M: pixel-format dispose M: pixel-format dispose*
[ (free-pixel-format) ] [ f >>handle drop ] bi ; [ (free-pixel-format) ] [ f >>handle drop ] bi ;
: pixel-format-attribute ( pixel-format attribute-name -- value ) : pixel-format-attribute ( pixel-format attribute-name -- value )