Skip to content

Commit

Permalink
destructors: fix some uses of new-disposable
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Jun 2, 2024
1 parent be9ad8e commit 884990e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
6 changes: 3 additions & 3 deletions basis/db/db.factor
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TUPLE: db-connection < disposable
<PRIVATE

: new-db-connection ( class -- obj )
new
new-disposable
H{ } clone >>insert-statements
H{ } clone >>update-statements
H{ } clone >>delete-statements ; inline
Expand Down Expand Up @@ -52,7 +52,7 @@ GENERIC: more-rows? ( result-set -- ? )
0 >>n drop ;

: new-result-set ( query handle class -- result-set )
new
new-disposable
swap >>handle
[ [ sql>> ] [ in-params>> ] [ out-params>> ] tri ] dip
swap >>out-params
Expand All @@ -66,7 +66,7 @@ TUPLE: prepared-statement < statement ;
M: statement dispose* drop ;

: new-statement ( sql in out class -- statement )
new
new-disposable
swap >>out-params
swap >>in-params
swap >>sql ;
Expand Down
4 changes: 2 additions & 2 deletions basis/html/streams/streams.factor
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ INSTANCE: html-writer output-stream
<PRIVATE

: new-html-writer ( class -- html-writer )
new V{ } clone >>data ; inline
new-disposable V{ } clone >>data ; inline

TUPLE: html-sub-stream < html-writer style parent ;

Expand Down Expand Up @@ -180,4 +180,4 @@ M: html-writer dispose* drop ;
html-writer new-html-writer ;

: with-html-writer ( quot -- xml )
<html-writer> [ swap with-output-stream* ] keep data>> ; inline
<html-writer> [ swap with-output-stream ] keep data>> ; inline
2 changes: 1 addition & 1 deletion extra/discord/discord.factor
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TUPLE: discord-bot < disposable
guilds channels ;

: <discord-bot> ( in out config -- discord-bot )
discord-bot new
discord-bot new-disposable
swap >>config
swap >>out
swap >>in
Expand Down
3 changes: 2 additions & 1 deletion extra/mongodb/connection/connection.factor
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ TUPLE: mdb-connection < disposable instance node handle remote local buffer ;

USE: mongodb.operations

CONSTRUCTOR: <mdb-connection> mdb-connection ( instance -- mdb-connection ) ;
: <mdb-connection> ( instance -- mdb-connection )
mdb-connection new-disposable swap >>instance ;

: check-ok ( result -- errmsg ? )
[ [ "errmsg" ] dip at ]
Expand Down
2 changes: 1 addition & 1 deletion extra/pdf/streams/streams.factor
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ PRIVATE>
TUPLE: pdf-writer < disposable data ;

: new-pdf-writer ( class -- pdf-writer )
new V{ } clone >>data ;
new-disposable V{ } clone >>data ;

: <pdf-writer> ( -- pdf-writer )
pdf-writer new-pdf-writer ;
Expand Down
12 changes: 8 additions & 4 deletions extra/rocksdb/lib/lib.factor
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ IN: rocksdb.lib
[ void* deref alien>native-string throw ] if ;

TUPLE: rocksdb-handle < disposable ptr ;
CONSTRUCTOR: <rocksdb-handle> rocksdb-handle ( ptr -- handle ) ;
: <rocksdb-handle> ( ptr -- handle )
rocksdb-handle new-disposable swap >>ptr ;
M: rocksdb-handle dispose* ptr>> rocksdb_close ;

TUPLE: rocksdb-options < disposable ptr ;
CONSTRUCTOR: <rocksdb-options> rocksdb-options ( ptr -- options ) ;
: <rocksdb-options> ( ptr -- options )
rocksdb-options new-disposable swap >>ptr ;
M: rocksdb-options dispose* ptr>> rocksdb_options_destroy ;

: set-create-if-missing ( options -- options )
Expand Down Expand Up @@ -45,7 +47,8 @@ SYMBOL: rocksdb-handle-var
SYMBOL: rocksdb-write-options-var

TUPLE: rocksdb-write-options < disposable ptr ;
CONSTRUCTOR: <rocksdb-write-options> rocksdb-write-options ( ptr -- options ) ;
: <rocksdb-write-options> ( ptr -- options )
rocksdb-write-options new-disposable swap >>ptr ;
M: rocksdb-write-options dispose*
ptr>> rocksdb_writeoptions_destroy ;

Expand All @@ -68,7 +71,8 @@ M: rocksdb-write-options dispose*
SYMBOL: rocksdb-read-options-var

TUPLE: rocksdb-read-options < disposable ptr ;
CONSTRUCTOR: <rocksdb-read-options> rocksdb-read-options ( ptr -- options ) ;
: <rocksdb-read-options> ( ptr -- options )
rocksdb-read-options new-disposable swap >>ptr ;
M: rocksdb-read-options dispose*
ptr>> rocksdb_readoptions_destroy ;

Expand Down

0 comments on commit 884990e

Please sign in to comment.