From: John Benediktsson Date: Mon, 10 Jan 2022 21:34:50 +0000 (-0800) Subject: basis: use check-instance in a few places X-Git-Tag: 0.99~1903 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=42b1470c694fb399146e5f1068a8ff0268113233 basis: use check-instance in a few places --- diff --git a/basis/html/forms/forms.factor b/basis/html/forms/forms.factor index c6e32d5b15..a80f80ed43 100644 --- a/basis/html/forms/forms.factor +++ b/basis/html/forms/forms.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008, 2009 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. -USING: kernel accessors strings namespaces assocs hashtables io -mirrors math fry sequences words continuations -xml.entities xml.writer xml.syntax ; +USING: accessors assocs classes continuations hashtables kernel +math mirrors namespaces sequences strings words xml.syntax +xml.writer ; IN: html.forms TUPLE: form errors values validation-failed ; @@ -18,7 +18,7 @@ M: form clone [ clone ] change-values ; : check-value-name ( name -- name ) - dup string? [ "Value name not a string" throw ] unless ; + string check-instance ; : values ( -- assoc ) form get values>> ; diff --git a/basis/regexp/regexp.factor b/basis/regexp/regexp.factor index a421d26265..b243f16f58 100644 --- a/basis/regexp/regexp.factor +++ b/basis/regexp/regexp.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays compiler.units kernel kernel.private -lexer make math ranges namespaces regexp.ast +USING: accessors arrays classes compiler.units kernel +kernel.private lexer make math ranges namespaces regexp.ast regexp.compiler regexp.negation regexp.parser sequences sequences.private splitting strings vocabs.loader words ; IN: regexp @@ -29,10 +29,6 @@ M: lookbehind question>quot ast>dfa dfa>reverse-shortest-word '[ [ 1 - ] dip f _ execute ] ; -: check-string ( string -- string ) - ! Make this configurable - dup string? [ "String required" throw ] unless ; - : match-index-from ( i string regexp -- index/f ) ! This word is unsafe. It assumes that i is a fixnum ! and that string is a string. @@ -45,7 +41,7 @@ M: reverse-regexp end/start drop length 1 - -1 swap ; PRIVATE> : matches? ( string regexp -- ? ) - [ check-string ] dip + [ string check-instance ] dip [ end/start ] 2keep match-index-from [ = ] [ drop f ] if* ; @@ -94,7 +90,7 @@ M: regexp match-iterator-start 2drop 0 ; M: reverse-regexp match-iterator-start drop length ; : prepare-match-iterator ( string regexp -- i string regexp ) - [ check-string ] dip [ match-iterator-start ] 2keep ; inline + [ string check-instance ] dip [ match-iterator-start ] 2keep ; inline PRIVATE> diff --git a/basis/xmode/catalog/catalog.factor b/basis/xmode/catalog/catalog.factor index a96389d30a..e1f70d6a94 100644 --- a/basis/xmode/catalog/catalog.factor +++ b/basis/xmode/catalog/catalog.factor @@ -1,5 +1,5 @@ -USING: accessors assocs globs io.pathnames kernel memoize -namespaces regexp sequences sorting splitting strings +USING: accessors assocs classes globs io.pathnames kernel +memoize namespaces regexp sequences sorting splitting strings unicode xml xml.data xml.syntax xml.traversal xmode.loader xmode.rules xmode.utilities ; IN: xmode.catalog @@ -57,7 +57,7 @@ DEFER: finalize-rule-set : resolve-delegate ( rule -- ) dup delegate>> dup string? [ get-rule-set - dup rule-set? [ "not a rule set" throw ] unless + rule-set check-instance swap rule-sets [ dup finalize-rule-set ] with-variable >>delegate drop ] [ 2drop ] if ;