From 56d437a1e7f374366764567b7dcc64f9efd6bb86 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 2 Dec 2017 17:21:49 -0600 Subject: [PATCH] alien.destructors: new functors. --- basis/alien/destructors/destructors.factor | 31 +++++++------------- basis/core-foundation/core-foundation.factor | 2 ++ basis/tools/deploy/backend/backend.factor | 9 +++--- core/words/words.factor | 18 ------------ 4 files changed, 18 insertions(+), 42 deletions(-) diff --git a/basis/alien/destructors/destructors.factor b/basis/alien/destructors/destructors.factor index 7582c1b263..b30cd0dce6 100644 --- a/basis/alien/destructors/destructors.factor +++ b/basis/alien/destructors/destructors.factor @@ -1,32 +1,23 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors destructors effects functors generalizations -kernel parser sequences ; +USING: functors2 ; IN: alien.destructors TUPLE: alien-destructor alien ; - DEFINES <${F}-destructor> -&F DEFINES &${F} -|F DEFINES |${F} -N [ F stack-effect out>> length ] +TUPLE: ${F}-destructor < alien-destructor ; -WHERE +: <${F}-destructor> ( alien -- destructor ) + ${F}-destructor boa ; inline -TUPLE: F-destructor < alien-destructor ; +: &${F} ( alien -- alien ) dup <${F}-destructor> &dispose drop ; inline -: ( alien -- destructor ) - F-destructor boa ; inline +: |${F} ( alien -- alien ) dup <${F}-destructor> |dispose drop ; inline -M: F-destructor dispose alien>> F N ndrop ; +M: ${F}-destructor dispose alien>> ${F} $[ \ ${F} stack-effect out>> length ] ndrop ; -: &F ( alien -- alien ) dup &dispose drop ; inline - -: |F ( alien -- alien ) dup |dispose drop ; inline - -;FUNCTOR> - -SYNTAX: \DESTRUCTOR: scan-word define-destructor ; +]] diff --git a/basis/core-foundation/core-foundation.factor b/basis/core-foundation/core-foundation.factor index e0e537b737..ecf2b2ce2f 100644 --- a/basis/core-foundation/core-foundation.factor +++ b/basis/core-foundation/core-foundation.factor @@ -38,6 +38,8 @@ STRUCT: CFRange FUNCTION: CFTypeRef CFRetain ( CFTypeRef cf ) +<< FUNCTION: void CFRelease ( CFTypeRef cf ) +>> DESTRUCTOR: CFRelease diff --git a/basis/tools/deploy/backend/backend.factor b/basis/tools/deploy/backend/backend.factor index ec86089dbe..1b209df192 100644 --- a/basis/tools/deploy/backend/backend.factor +++ b/basis/tools/deploy/backend/backend.factor @@ -1,9 +1,10 @@ ! Copyright (C) 2007, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs bootstrap.image hashtables io io.directories -io.encodings.utf8 io.files io.files.temp io.launcher io.pathnames -kernel locals make namespaces prettyprint sequences splitting system -tools.deploy.config tools.deploy.config.editor tools.deploy.embed +USING: accessors assocs bootstrap.image hashtables io +io.directories io.encodings.utf8 io.files io.files.temp +io.launcher io.pathnames kernel make namespaces prettyprint +sequences splitting system tools.deploy.config +tools.deploy.config.editor tools.deploy.embed tools.deploy.libraries vocabs.loader vocabs.metadata.resources webbrowser ; IN: tools.deploy.backend diff --git a/core/words/words.factor b/core/words/words.factor index def69b95eb..cee910b3b0 100644 --- a/core/words/words.factor +++ b/core/words/words.factor @@ -119,25 +119,7 @@ M: word parent-word drop f ; 2tri ] if ; -![[ -: inline-quotation? ( obj -- ? ) - { [ dup array? [ length>> 2 >= ] [ drop f ] if ] [ second quotation? ] } 1&& ; - -: effect>inline-quotations ( effect -- quot/f ) - in>> - [ dup inline-quotation? [ last ] [ drop [ ] ] if ] map - dup [ length 0 > ] any? [ '[ _ spread ] ] [ drop f ] if ; - -: apply-inlined-effects ( def effect -- def effect ) - dup effect>inline-quotations dup [ - swap [ prepose ] dip - ] [ - drop - ] if ; -]] - : define-declared ( word def effect -- ) - ! apply-inlined-effects [ nip swap set-stack-effect ] [ drop define ] 3bi ; : make-deprecated ( word -- )