]> gitweb.factorcode.org Git - factor.git/commitdiff
basis: use check-instance in a few places
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 10 Jan 2022 21:34:50 +0000 (13:34 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 10 Jan 2022 21:34:50 +0000 (13:34 -0800)
basis/html/forms/forms.factor
basis/regexp/regexp.factor
basis/xmode/catalog/catalog.factor

index c6e32d5b159b3c424be7d98990417e40cb374d0c..a80f80ed434e2c4eaf537776e87181f58bf60a12 100644 (file)
@@ -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>> ;
index a421d262652b339f347501b71db2e933c728baa2..b243f16f588d1fdc2992eeaad51040f5ada91ae0 100644 (file)
@@ -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>
 
index a96389d30a523d6b95a5e663fcef8d3cc58e1714..e1f70d6a94f3054e83d470bbac3cf5b18c453654 100644 (file)
@@ -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 ;