From 3bd573fe13446ff4ec8b8fa15a93aec5a0b1f646 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Fri, 20 Feb 2009 01:02:24 +0100 Subject: [PATCH 01/85] FUEL: New refactoring command: fuel-refactor-make-generic. --- misc/fuel/README | 2 ++ misc/fuel/fuel-mode.el | 1 + misc/fuel/fuel-refactor.el | 22 ++++++++++++++++++++++ misc/fuel/fuel-syntax.el | 7 ++++--- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/misc/fuel/README b/misc/fuel/README index 79b8f49f9a..0411e0709b 100644 --- a/misc/fuel/README +++ b/misc/fuel/README @@ -139,6 +139,8 @@ beast. | C-cC-xi | replace word by its definition (fuel-refactor-inline-word) | | C-cC-xw | rename all uses of a word (fuel-refactor-rename-word) | | C-cC-xa | extract region as a separate ARTICLE: form | + | C-cC-xg | convert current word definition into GENERIC + method | + | | (fuel-refactor-make-generic) | |-----------------+------------------------------------------------------------| *** In the listener: diff --git a/misc/fuel/fuel-mode.el b/misc/fuel/fuel-mode.el index c4f08f3c62..aa9a7d944e 100644 --- a/misc/fuel/fuel-mode.el +++ b/misc/fuel/fuel-mode.el @@ -213,6 +213,7 @@ interacting with a factor listener is at your disposal. (fuel-mode--key ?x ?a 'fuel-refactor-extract-article) (fuel-mode--key ?x ?i 'fuel-refactor-inline-word) +(fuel-mode--key ?x ?g 'fuel-refactor-make-generic) (fuel-mode--key ?x ?r 'fuel-refactor-extract-region) (fuel-mode--key ?x ?s 'fuel-refactor-extract-sexp) (fuel-mode--key ?x ?v 'fuel-refactor-extract-vocab) diff --git a/misc/fuel/fuel-refactor.el b/misc/fuel/fuel-refactor.el index bd62227755..942d439466 100644 --- a/misc/fuel/fuel-refactor.el +++ b/misc/fuel/fuel-refactor.el @@ -145,6 +145,28 @@ word." (if (looking-at-p ";") (point) (fuel-syntax--end-of-symbol-pos)))) + +;;; Convert word to generic + method: + +(defun fuel-refactor-make-generic () + "Inserts a new generic definition with the current word's stack effect. +The word's body is put in a new method for the generic." + (interactive) + (let ((p (point))) + (fuel-syntax--beginning-of-defun) + (unless (re-search-forward fuel-syntax--word-signature-regex nil t) + (goto-char p) + (error "Cannot find a proper word definition here")) + (let ((begin (match-beginning 0)) + (end (match-end 0)) + (name (match-string-no-properties 1)) + (cls (read-string "Method's class (object): " nil nil "object"))) + (goto-char begin) + (insert "GENERIC") + (goto-char (+ end 7)) + (newline 2) + (insert "M: " cls " " name " ")))) + ;;; Inline word: diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index 67341120c1..b6409b2fea 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -212,10 +212,11 @@ fuel-syntax--end-of-def-line-regex fuel-syntax--single-liner-regex)) +(defconst fuel-syntax--word-signature-regex + (format ":[^ ]* \\([^ ]+\\)\\(%s\\)*" fuel-syntax--stack-effect-regex)) + (defconst fuel-syntax--defun-signature-regex - (format "\\(%s\\|%s\\)" - (format ":[^ ]* [^ ]+\\(%s\\)*" fuel-syntax--stack-effect-regex) - "M[^:]*: [^ ]+ [^ ]+")) + (format "\\(%s\\|%s\\)" fuel-syntax--word-signature-regex "M[^:]*: [^ ]+ [^ ]+")) (defconst fuel-syntax--constructor-decl-regex "\\_ Date: Fri, 20 Feb 2009 16:55:08 +0100 Subject: [PATCH 02/85] FUEL: Support for $or markup (still elisp-based, sorry). --- misc/fuel/fuel-markup.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/misc/fuel/fuel-markup.el b/misc/fuel/fuel-markup.el index 980ea111a6..3a00b70ab1 100644 --- a/misc/fuel/fuel-markup.el +++ b/misc/fuel/fuel-markup.el @@ -118,6 +118,7 @@ ($nl . fuel-markup--newline) ($notes . fuel-markup--notes) ($operation . fuel-markup--link) + ($or . fuel-markup--or) ($parsing-note . fuel-markup--parsing-note) ($predicate . fuel-markup--predicate) ($prettyprinting-note . fuel-markup--prettyprinting-note) @@ -468,6 +469,14 @@ (fuel-markup--instance (cons '$instance (cdr e))) (insert " or f ")) +(defun fuel-markup--or (e) + (let ((fst (car (cdr e))) + (mid (butlast (cddr e))) + (lst (car (last (cdr e))))) + (insert (format "%s" fst)) + (dolist (m mid) (insert (format ", %s" m))) + (insert (format " or %s" lst)))) + (defun fuel-markup--values (e) (fuel-markup--insert-heading "Inputs and outputs") (dolist (val (cdr e)) From 19acf89d82b0f7f33f58b02cbe505930432a036d Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 20 Feb 2009 12:12:00 -0600 Subject: [PATCH 03/85] fix find-in-program-files --- basis/io/directories/search/search.factor | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/basis/io/directories/search/search.factor b/basis/io/directories/search/search.factor index 41031f8ac3..b56fb7b6a3 100755 --- a/basis/io/directories/search/search.factor +++ b/basis/io/directories/search/search.factor @@ -57,8 +57,14 @@ PRIVATE> pusher [ [ f ] compose iterate-directory drop ] dip ] [ drop f ] recover ; inline +ERROR: file-not-found ; + : find-in-directories ( directories bfs? quot: ( obj -- ? ) -- path'/f ) - '[ _ _ find-file ] attempt-all ; + [ + '[ _ _ find-file [ file-not-found ] unless* ] attempt-all + ] [ + drop f + ] recover ; : find-all-in-directories ( directories bfs? quot: ( obj -- ? ) -- paths/f ) '[ _ _ find-all-files ] map concat ; From 394ec538a1afdd8d695b4aeb3b44e87147285006 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 20 Feb 2009 12:15:26 -0600 Subject: [PATCH 04/85] make emacsw32 work on windows out of the box --- basis/editors/emacs/emacs.factor | 13 +++++++++---- basis/editors/emacs/windows/authors.txt | 1 + basis/editors/emacs/windows/windows.factor | 9 +++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100755 basis/editors/emacs/windows/authors.txt create mode 100755 basis/editors/emacs/windows/windows.factor diff --git a/basis/editors/emacs/emacs.factor b/basis/editors/emacs/emacs.factor index 79387f9820..fa78c1b429 100644 --- a/basis/editors/emacs/emacs.factor +++ b/basis/editors/emacs/emacs.factor @@ -1,12 +1,18 @@ USING: definitions io.launcher kernel parser words sequences math -math.parser namespaces editors make system ; +math.parser namespaces editors make system combinators.short-circuit ; IN: editors.emacs +SYMBOL: emacsclient-path + +HOOK: default-emacsclient os ( -- path ) + +M: object default-emacsclient ( -- path ) "emacsclient" ; + : emacsclient ( file line -- ) [ - \ emacsclient get "emacsclient" or , + { [ \ emacsclient-path get ] [ default-emacsclient ] } 0|| , os windows? [ "--no-wait" , ] unless - "+" swap number>string append , + number>string "+" prepend , , ] { } make try-process ; @@ -14,4 +20,3 @@ IN: editors.emacs where first2 emacsclient ; [ emacsclient ] edit-hook set-global - diff --git a/basis/editors/emacs/windows/authors.txt b/basis/editors/emacs/windows/authors.txt new file mode 100755 index 0000000000..7c1b2f2279 --- /dev/null +++ b/basis/editors/emacs/windows/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/basis/editors/emacs/windows/windows.factor b/basis/editors/emacs/windows/windows.factor new file mode 100755 index 0000000000..d5c1e7811c --- /dev/null +++ b/basis/editors/emacs/windows/windows.factor @@ -0,0 +1,9 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: editors.emacs io.directories.search.windows kernel sequences +system ; +IN: editors.emacs.windows + +M: windows default-emacsclient + "Emacs" t [ "emacsclient.exe" tail? ] find-in-program-files + "emacsclient.exe" or ; From 114d9bb21c2d8079b9d3ffb1f2ff14f5f21cd148 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 20 Feb 2009 12:25:55 -0600 Subject: [PATCH 05/85] run with --no-wait on windows so emacsclient doesn't block, use run-detached so that errors on emacsclient exit are ignored. emacs on windows is fully usable now --- basis/editors/emacs/emacs.factor | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/basis/editors/emacs/emacs.factor b/basis/editors/emacs/emacs.factor index fa78c1b429..0aeb7bb467 100644 --- a/basis/editors/emacs/emacs.factor +++ b/basis/editors/emacs/emacs.factor @@ -1,5 +1,6 @@ USING: definitions io.launcher kernel parser words sequences math -math.parser namespaces editors make system combinators.short-circuit ; +math.parser namespaces editors make system combinators.short-circuit +fry threads ; IN: editors.emacs SYMBOL: emacsclient-path @@ -11,10 +12,10 @@ M: object default-emacsclient ( -- path ) "emacsclient" ; : emacsclient ( file line -- ) [ { [ \ emacsclient-path get ] [ default-emacsclient ] } 0|| , - os windows? [ "--no-wait" , ] unless + "--no-wait" , number>string "+" prepend , , - ] { } make try-process ; + ] { } make run-detached drop ; : emacs ( word -- ) where first2 emacsclient ; From 1b9208490bb1d29cf67fb49f043a20cf9cdb92ae Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 20 Feb 2009 12:32:07 -0600 Subject: [PATCH 06/85] keep the old emacs behavior on unix systems --- basis/editors/emacs/emacs.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basis/editors/emacs/emacs.factor b/basis/editors/emacs/emacs.factor index 0aeb7bb467..fa717a70fa 100644 --- a/basis/editors/emacs/emacs.factor +++ b/basis/editors/emacs/emacs.factor @@ -15,7 +15,8 @@ M: object default-emacsclient ( -- path ) "emacsclient" ; "--no-wait" , number>string "+" prepend , , - ] { } make run-detached drop ; + ] { } make + os windows? [ run-detached drop ] [ try-process ] if ; : emacs ( word -- ) where first2 emacsclient ; From 624719c18fb1894f09c278b4417f5e88475eb64e Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 20 Feb 2009 12:58:19 -0600 Subject: [PATCH 07/85] emacsclient.exe is a console app, so whenever it's run a console box pops up. run emacsclientw.exe instead if it exists --- basis/editors/emacs/windows/windows.factor | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/basis/editors/emacs/windows/windows.factor b/basis/editors/emacs/windows/windows.factor index d5c1e7811c..e18c39ed60 100755 --- a/basis/editors/emacs/windows/windows.factor +++ b/basis/editors/emacs/windows/windows.factor @@ -1,9 +1,12 @@ ! Copyright (C) 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: editors.emacs io.directories.search.windows kernel sequences -system ; +system combinators.short-circuit ; IN: editors.emacs.windows M: windows default-emacsclient - "Emacs" t [ "emacsclient.exe" tail? ] find-in-program-files - "emacsclient.exe" or ; + { + [ "Emacs" t [ "emacsclientw.exe" tail? ] find-in-program-files ] + [ "Emacs" t [ "emacsclient.exe" tail? ] find-in-program-files ] + [ "emacsclient.exe" ] + } 0|| ; From 8b5a2f4a0e94d91557b7ac8fe0b91285178dcfda Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 20 Feb 2009 14:52:38 -0600 Subject: [PATCH 08/85] fix sqlite triggers -- NEW.table-id not NEW.foreign-table-id --- basis/db/sqlite/sqlite-tests.factor | 20 ++++++++------------ basis/db/sqlite/sqlite.factor | 27 ++++++++++++++------------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/basis/db/sqlite/sqlite-tests.factor b/basis/db/sqlite/sqlite-tests.factor index fd730f07ae..b6e756a3dd 100644 --- a/basis/db/sqlite/sqlite-tests.factor +++ b/basis/db/sqlite/sqlite-tests.factor @@ -123,12 +123,8 @@ hi "HELLO" { ] with-db ] unit-test -[ ] [ - test.db [ - hi create-table - hi drop-table - ] with-db -] unit-test + +! Test SQLite triggers TUPLE: show id ; TUPLE: user username data ; @@ -144,12 +140,12 @@ show "SHOW" { } define-persistent watch "WATCH" { - { "user" "USER" TEXT +not-null+ - { +foreign-id+ user "USERNAME" } +user-assigned-id+ } - { "show" "SHOW" BIG-INTEGER +not-null+ - { +foreign-id+ show "ID" } +user-assigned-id+ } + { "user" "USER" TEXT +not-null+ +user-assigned-id+ + { +foreign-id+ user "USERNAME" } } + { "show" "SHOW" BIG-INTEGER +not-null+ +user-assigned-id+ + { +foreign-id+ show "ID" } } } define-persistent - + [ T{ user { username "littledan" } { data "foo" } } ] [ test.db [ user create-table @@ -160,7 +156,7 @@ watch "WATCH" { show new insert-tuple show new select-tuple "littledan" f user boa select-tuple - swap [ username>> ] [ id>> ] bi* + [ id>> ] [ username>> ] bi* watch boa insert-tuple watch new select-tuple user>> f user boa select-tuple diff --git a/basis/db/sqlite/sqlite.factor b/basis/db/sqlite/sqlite.factor index 62a1b4714f..c94de27894 100755 --- a/basis/db/sqlite/sqlite.factor +++ b/basis/db/sqlite/sqlite.factor @@ -204,7 +204,7 @@ M: sqlite-db-connection persistent-table ( -- assoc ) CREATE TRIGGER fki_${table-name}_${table-id}_${foreign-table-name}_${foreign-table-id}_id BEFORE INSERT ON ${table-name} FOR EACH ROW BEGIN - SELECT RAISE(ROLLBACK, 'insert on table "${table-name}" violates foreign key constraint "fk_${foreign-table-name}_id"') + SELECT RAISE(ROLLBACK, 'insert on table "${table-name}" violates foreign key constraint "fki_${table-name}_$table-id}_${foreign-table-name}_${foreign-table-id}_id"') WHERE (SELECT ${foreign-table-id} FROM ${foreign-table-name} WHERE ${foreign-table-id} = NEW.${table-id}) IS NULL; END; "> interpolate @@ -216,8 +216,8 @@ M: sqlite-db-connection persistent-table ( -- assoc ) CREATE TRIGGER fki_${table-name}_${table-id}_${foreign-table-name}_${foreign-table-id}_id BEFORE INSERT ON ${table-name} FOR EACH ROW BEGIN - SELECT RAISE(ROLLBACK, 'insert on table "${table-name}" violates foreign key constraint "fk_${foreign-table-name}_id"') - WHERE NEW.${foreign-table-id} IS NOT NULL + SELECT RAISE(ROLLBACK, 'insert on table "${table-name}" violates foreign key constraint "fki_${table-name}_$table-id}_${foreign-table-name}_${foreign-table-id}_id"') + WHERE NEW.${table-id} IS NOT NULL AND (SELECT ${foreign-table-id} FROM ${foreign-table-name} WHERE ${foreign-table-id} = NEW.${table-id}) IS NULL; END; "> interpolate @@ -236,8 +236,8 @@ M: sqlite-db-connection persistent-table ( -- assoc ) CREATE TRIGGER fku_${table-name}_${table-id}_${foreign-table-name}_${foreign-table-id}_id BEFORE UPDATE ON ${table-name} FOR EACH ROW BEGIN - SELECT RAISE(ROLLBACK, 'update on table "${table-name}" violates foreign key constraint "fk_${foreign-table-name}_id"') - WHERE (SELECT ${foreign-table-id} FROM ${foreign-table-name} WHERE ${foreign-table-id} = NEW.${table-id}) IS NULL; + SELECT RAISE(ROLLBACK, 'update on table "${table-name}" violates foreign key constraint "fku_${table-name}_$table-id}_${foreign-table-name}_${foreign-table-id}_id"') + WHERE (SELECT ${foreign-table-id} FROM ${foreign-table-name} WHERE ${foreign-table-id} = NEW.${table-id}) IS NULL; END; "> interpolate ] with-string-writer ; @@ -248,8 +248,8 @@ M: sqlite-db-connection persistent-table ( -- assoc ) CREATE TRIGGER fku_${table-name}_${table-id}_${foreign-table-name}_${foreign-table-id}_id BEFORE UPDATE ON ${table-name} FOR EACH ROW BEGIN - SELECT RAISE(ROLLBACK, 'update on table "${table-name}" violates foreign key constraint "fk_${foreign-table-name}_id"') - WHERE NEW.${foreign-table-id} IS NOT NULL + SELECT RAISE(ROLLBACK, 'update on table "${table-name}" violates foreign key constraint "fku_${table-name}_$table-id}_${foreign-table-name}_${foreign-table-id}_id"') + WHERE NEW.${table-id} IS NOT NULL AND (SELECT ${foreign-table-id} FROM ${foreign-table-name} WHERE ${foreign-table-id} = NEW.${table-id}) IS NULL; END; "> interpolate @@ -268,8 +268,8 @@ M: sqlite-db-connection persistent-table ( -- assoc ) CREATE TRIGGER fkd_${table-name}_${table-id}_${foreign-table-name}_${foreign-table-id}_id BEFORE DELETE ON ${foreign-table-name} FOR EACH ROW BEGIN - SELECT RAISE(ROLLBACK, 'delete on table "${foreign-table-name}" violates foreign key constraint "fk_${foreign-table-name}_id"') - WHERE (SELECT ${foreign-table-id} FROM ${foreign-table-name} WHERE ${foreign-table-id} = OLD.${foreign-table-id}) IS NOT NULL; + SELECT RAISE(ROLLBACK, 'delete on table "${foreign-table-name}" violates foreign key constraint "fkd_${table-name}_$table-id}_${foreign-table-name}_${foreign-table-id}_id"') + WHERE (SELECT ${foreign-table-id} FROM ${foreign-table-name} WHERE ${foreign-table-id} = OLD.${foreign-table-id}) IS NOT NULL; END; "> interpolate ] with-string-writer ; @@ -336,15 +336,17 @@ M: sqlite-db-connection persistent-table ( -- assoc ) [ modifiers>> [ +foreign-id+ = ] deep-any? ] filter [ [ class>> db-table-name "db-table" set ] - [ column-name>> "table-id" set ] [ + [ "sql-spec" set ] + [ column-name>> "table-id" set ] + [ ] tri modifiers>> [ [ +foreign-id+ = ] deep-any? ] filter [ [ second db-table-name "foreign-table-name" set ] [ third "foreign-table-id" set ] bi _ execute ] each - ] tri + ] bi ] each ] call ; @@ -378,8 +380,7 @@ M: sqlite-db-connection create-sql-statement ( class -- statement ) M: sqlite-db-connection drop-sql-statement ( class -- statements ) [ - [ nip "drop table " 0% 0% ";" 0% ] - [ drop \ drop-sqlite-triggers db-triggers ] 2bi + nip "drop table " 0% 0% ";" 0% ] query-make ; M: sqlite-db-connection compound ( string seq -- new-string ) From 6eaa5aee2457b0eaad5020445f13b12299f8a4fc Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 20 Feb 2009 17:29:11 -0600 Subject: [PATCH 09/85] fix compile error --- basis/db/sqlite/sqlite.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/db/sqlite/sqlite.factor b/basis/db/sqlite/sqlite.factor index c94de27894..19cfc5d0b7 100755 --- a/basis/db/sqlite/sqlite.factor +++ b/basis/db/sqlite/sqlite.factor @@ -348,7 +348,7 @@ M: sqlite-db-connection persistent-table ( -- assoc ) ] each ] bi ] each - ] call ; + ] call ; inline : sqlite-create-table ( sql-specs class-name -- ) [ From b54833c728fa0a0bc40e236fa7287b78e609364f Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 20 Feb 2009 20:11:26 -0600 Subject: [PATCH 10/85] remove a bunch of trigger deletion code -- triggers get deleted when tables are dropped --- basis/db/sqlite/sqlite.factor | 74 ++++++++--------------------------- 1 file changed, 16 insertions(+), 58 deletions(-) diff --git a/basis/db/sqlite/sqlite.factor b/basis/db/sqlite/sqlite.factor index 19cfc5d0b7..a4adba3473 100755 --- a/basis/db/sqlite/sqlite.factor +++ b/basis/db/sqlite/sqlite.factor @@ -223,13 +223,6 @@ M: sqlite-db-connection persistent-table ( -- assoc ) "> interpolate ] with-string-writer ; -: drop-insert-trigger ( -- string ) - [ - <" - DROP TRIGGER fki_${table-name}_${table-id}_${foreign-table-name}_${foreign-table-id}_id; - "> interpolate - ] with-string-writer ; - : update-trigger ( -- string ) [ <" @@ -255,13 +248,6 @@ M: sqlite-db-connection persistent-table ( -- assoc ) "> interpolate ] with-string-writer ; -: drop-update-trigger ( -- string ) - [ - <" - DROP TRIGGER fku_${table-name}_${table-id}_${foreign-table-name}_${foreign-table-id}_id; - "> interpolate - ] with-string-writer ; - : delete-trigger-restrict ( -- string ) [ <" @@ -274,13 +260,6 @@ M: sqlite-db-connection persistent-table ( -- assoc ) "> interpolate ] with-string-writer ; -: drop-delete-trigger-restrict ( -- string ) - [ - <" - DROP TRIGGER fkd_${table-name}_${table-id}_${foreign-table-name}_${foreign-table-id}_id; - "> interpolate - ] with-string-writer ; - : delete-trigger-cascade ( -- string ) [ <" @@ -292,13 +271,6 @@ M: sqlite-db-connection persistent-table ( -- assoc ) "> interpolate ] with-string-writer ; -: drop-delete-trigger-cascade ( -- string ) - [ - <" - DROP TRIGGER fkd_${table-name}_${table-id}_${foreign-table-name}_${foreign-table-id}_id; - "> interpolate - ] with-string-writer ; - : can-be-null? ( -- ? ) "sql-spec" get modifiers>> [ +not-null+ = ] any? not ; @@ -322,33 +294,22 @@ M: sqlite-db-connection persistent-table ( -- assoc ) delete-trigger-restrict sqlite-trigger, ] if ; -: drop-sqlite-triggers ( -- ) - drop-insert-trigger sqlite-trigger, - drop-update-trigger sqlite-trigger, - delete-cascade? [ - drop-delete-trigger-cascade sqlite-trigger, - ] [ - drop-delete-trigger-restrict sqlite-trigger, - ] if ; - -: db-triggers ( sql-specs word -- ) - '[ - [ modifiers>> [ +foreign-id+ = ] deep-any? ] filter +: create-db-triggers ( sql-specs -- ) + [ modifiers>> [ +foreign-id+ = ] deep-any? ] filter + [ + [ class>> db-table-name "db-table" set ] [ - [ class>> db-table-name "db-table" set ] + [ "sql-spec" set ] + [ column-name>> "table-id" set ] + [ ] tri + modifiers>> [ [ +foreign-id+ = ] deep-any? ] filter [ - [ "sql-spec" set ] - [ column-name>> "table-id" set ] - [ ] tri - modifiers>> [ [ +foreign-id+ = ] deep-any? ] filter - [ - [ second db-table-name "foreign-table-name" set ] - [ third "foreign-table-id" set ] bi - _ execute - ] each - ] bi - ] each - ] call ; inline + [ second db-table-name "foreign-table-name" set ] + [ third "foreign-table-id" set ] bi + create-sqlite-triggers + ] each + ] bi + ] each ; : sqlite-create-table ( sql-specs class-name -- ) [ @@ -373,15 +334,12 @@ M: sqlite-db-connection persistent-table ( -- assoc ) M: sqlite-db-connection create-sql-statement ( class -- statement ) [ - ! specs name [ sqlite-create-table ] - [ drop \ create-sqlite-triggers db-triggers ] 2bi + [ drop create-db-triggers ] 2bi ] query-make ; M: sqlite-db-connection drop-sql-statement ( class -- statements ) - [ - nip "drop table " 0% 0% ";" 0% - ] query-make ; + [ nip "drop table " 0% 0% ";" 0% ] query-make ; M: sqlite-db-connection compound ( string seq -- new-string ) over { From 70d931d0b2197da63474e3f817cc8cf27e0cf5b9 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Fri, 20 Feb 2009 20:14:54 -0600 Subject: [PATCH 11/85] Creating math.bits --- basis/math/bits/authors.txt | 1 + basis/math/bits/bits-docs.factor | 26 ++++++++++++++++++++++ basis/math/bits/bits-tests.factor | 16 +++++++++++++ basis/math/bits/bits.factor | 16 +++++++++++++ basis/math/bits/summary.txt | 1 + basis/math/bitwise/bitwise.factor | 4 ++-- basis/math/functions/functions-docs.factor | 8 ------- basis/math/functions/functions.factor | 18 ++++----------- extra/crypto/passwd-md5/passwd-md5.factor | 6 ++--- 9 files changed, 69 insertions(+), 27 deletions(-) create mode 100644 basis/math/bits/authors.txt create mode 100644 basis/math/bits/bits-docs.factor create mode 100644 basis/math/bits/bits-tests.factor create mode 100644 basis/math/bits/bits.factor create mode 100644 basis/math/bits/summary.txt diff --git a/basis/math/bits/authors.txt b/basis/math/bits/authors.txt new file mode 100644 index 0000000000..f990dd0ed2 --- /dev/null +++ b/basis/math/bits/authors.txt @@ -0,0 +1 @@ +Daniel Ehrenberg diff --git a/basis/math/bits/bits-docs.factor b/basis/math/bits/bits-docs.factor new file mode 100644 index 0000000000..6ae83f7af0 --- /dev/null +++ b/basis/math/bits/bits-docs.factor @@ -0,0 +1,26 @@ +! Copyright (C) 2009 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: help.syntax help.markup math ; +IN: math.bits + +ABOUT: "math.bits" + +ARTICLE: "math.bits" "Number bits virtual sequence" +{ $subsection bits } +{ $subsection } +{ $subsection make-bits } ; + +HELP: bits +{ $class-description "Virtual sequence class of bits of a number. The first bit is the least significant bit. This can be constructed with " { $link } " or " { $link make-bits } "." } ; + +HELP: +{ $values { "number" integer } { "length" integer } { "bits" bits } } +{ $description "Creates a virtual sequence of bits of a number in little endian order, with the given length." } ; + +HELP: make-bits +{ $values { "number" integer } { "bits" bits } } +{ $description "Creates a " { $link bits } " object out of the given number, using its log base 2 as the length. This implies that the last element, corresponding to the most significant bit, will be 1." } +{ $examples + { $example "USING: math.bits prettyprint arrays ;" "BIN: 1101 make-bits >array ." "{ t f t t }" } + { $example "USING: math.bits prettyprint arrays ;" "-3 make-bits >array ." "{ t f }" } +} ; diff --git a/basis/math/bits/bits-tests.factor b/basis/math/bits/bits-tests.factor new file mode 100644 index 0000000000..0503d27f33 --- /dev/null +++ b/basis/math/bits/bits-tests.factor @@ -0,0 +1,16 @@ +! Copyright (C) 2009 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: tools.test math.bits sequences arrays ; +IN: math.bits.tests + +[ t ] [ BIN: 111111 3 second ] unit-test +[ { t t t } ] [ BIN: 111111 3 >array ] unit-test +[ f ] [ BIN: 111101 3 second ] unit-test +[ { f f t } ] [ BIN: 111100 3 >array ] unit-test +[ 3 ] [ BIN: 111111 3 length ] unit-test +[ 6 ] [ BIN: 111111 make-bits length ] unit-test +[ 0 ] [ 0 make-bits length ] unit-test +[ 2 ] [ 3 make-bits length ] unit-test +[ 2 ] [ -3 make-bits length ] unit-test +[ 1 ] [ 1 make-bits length ] unit-test +[ 1 ] [ -1 make-bits length ] unit-test diff --git a/basis/math/bits/bits.factor b/basis/math/bits/bits.factor new file mode 100644 index 0000000000..8920955df3 --- /dev/null +++ b/basis/math/bits/bits.factor @@ -0,0 +1,16 @@ +! Copyright (C) 2009 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: sequences kernel math accessors sequences.private ; +IN: math.bits + +TUPLE: bits { number read-only } { length read-only } ; +C: bits + +: make-bits ( number -- bits ) + dup zero? [ drop T{ bits f 0 0 } ] [ dup abs log2 1+ ] if ; inline + +M: bits length length>> ; + +M: bits nth-unsafe number>> swap bit? ; + +INSTANCE: bits immutable-sequence diff --git a/basis/math/bits/summary.txt b/basis/math/bits/summary.txt new file mode 100644 index 0000000000..265a7b8277 --- /dev/null +++ b/basis/math/bits/summary.txt @@ -0,0 +1 @@ +Virtual sequence for bits of an integer diff --git a/basis/math/bitwise/bitwise.factor b/basis/math/bitwise/bitwise.factor index 339703c0a6..4f639c02a7 100755 --- a/basis/math/bitwise/bitwise.factor +++ b/basis/math/bitwise/bitwise.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007, 2008 Slava Pestov, Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays kernel math math.functions sequences +USING: arrays kernel math sequences accessors math.bits sequences.private words namespaces macros hints combinators fry io.binary combinators.smart ; IN: math.bitwise @@ -65,7 +65,7 @@ DEFER: byte-bit-count \ byte-bit-count 256 [ - 0 swap [ [ 1+ ] when ] each-bit + 8 0 [ [ 1+ ] when ] reduce ] B{ } map-as '[ HEX: ff bitand _ nth-unsafe ] (( byte -- table )) define-declared diff --git a/basis/math/functions/functions-docs.factor b/basis/math/functions/functions-docs.factor index b463a48e49..33a5d96fc4 100644 --- a/basis/math/functions/functions-docs.factor +++ b/basis/math/functions/functions-docs.factor @@ -278,14 +278,6 @@ HELP: mod-inv { $example "USING: math prettyprint ;" "173 815 * 1119 mod ." "1" } } ; -HELP: each-bit -{ $values { "n" integer } { "quot" { $quotation "( ? -- )" } } } -{ $description "Applies the quotation to each bit of the integer, starting from the least significant bit, and stopping at the last bit from which point on all bits are either clear (if the integer is positive) or all bits are set (if the integer is negataive)." } -{ $examples - { $example "USING: math.functions make prettyprint ;" "[ BIN: 1101 [ , ] each-bit ] { } make ." "{ t f t t }" } - { $example "USING: math.functions make prettyprint ;" "[ -3 [ , ] each-bit ] { } make ." "{ t f }" } -} ; - HELP: ~ { $values { "x" real } { "y" real } { "epsilon" real } { "?" "a boolean" } } { $description "Tests if " { $snippet "x" } " and " { $snippet "y" } " are approximately equal to each other. There are three possible comparison tests, chosen based on the sign of " { $snippet "epsilon" } ":" diff --git a/basis/math/functions/functions.factor b/basis/math/functions/functions.factor index 85b4d711ac..7e2ac0884c 100644 --- a/basis/math/functions/functions.factor +++ b/basis/math/functions/functions.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: math kernel math.constants math.private +USING: math kernel math.constants math.private math.bits math.libm combinators math.order sequences ; IN: math.functions @@ -26,16 +26,6 @@ GENERIC: sqrt ( x -- y ) foldable M: real sqrt >float dup 0.0 < [ neg fsqrt 0.0 swap rect> ] [ fsqrt ] if ; -: each-bit ( n quot: ( ? -- ) -- ) - over [ 0 = ] [ -1 = ] bi or [ - 2drop - ] [ - 2dup { [ odd? ] [ call ] [ 2/ ] [ each-bit ] } spread - ] if ; inline recursive - -: map-bits ( n quot: ( ? -- obj ) -- seq ) - accumulator [ each-bit ] dip ; inline - : factor-2s ( n -- r s ) #! factor an integer into 2^r * s dup 0 = [ 1 ] [ @@ -47,7 +37,7 @@ M: real sqrt GENERIC# ^n 1 ( z w -- z^w ) : (^n) ( z w -- z^w ) - 1 swap [ [ dupd * ] when [ sq ] dip ] each-bit nip ; inline + make-bits 1 [ [ dupd * ] when [ sq ] dip ] reduce nip ; inline M: integer ^n [ factor-2s ] dip [ (^n) ] keep rot * shift ; @@ -94,9 +84,9 @@ PRIVATE> dup zero? [ drop 0./0. ] [ 0 < 1./0. 0 ? ] if ; inline : (^mod) ( n x y -- z ) - 1 swap [ + make-bits 1 [ [ dupd * pick mod ] when [ sq over mod ] dip - ] each-bit 2nip ; inline + ] reduce 2nip ; inline : (gcd) ( b a x y -- a d ) over zero? [ diff --git a/extra/crypto/passwd-md5/passwd-md5.factor b/extra/crypto/passwd-md5/passwd-md5.factor index e292981876..286a313fda 100644 --- a/extra/crypto/passwd-md5/passwd-md5.factor +++ b/extra/crypto/passwd-md5/passwd-md5.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: kernel base64 checksums.md5 sequences checksums -locals prettyprint math math.bitwise grouping io combinators +locals prettyprint math math.bits grouping io combinators fry make combinators.short-circuit math.functions splitting ; IN: crypto.passwd-md5 @@ -22,8 +22,8 @@ PRIVATE> password length [ 16 / ceiling swap concat ] keep head-slice append - password [ length ] [ first ] bi - '[ [ CHAR: \0 _ ? , ] each-bit ] "" make append + password [ length make-bits ] [ first ] bi + '[ CHAR: \0 _ ? ] "" map-as append md5 checksum-bytes ] | 1000 [ "" swap From 985597ba6858552d22294dc40e5794170fdaa3d6 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 20 Feb 2009 20:40:17 -0600 Subject: [PATCH 12/85] add error handling to sqlite, postgresql is next. switching computers.. --- basis/db/db.factor | 8 +++-- basis/db/errors/errors.factor | 12 ++++++- basis/db/errors/postgresql/authors.txt | 1 + .../errors/postgresql/postgresql-tests.factor | 4 +++ basis/db/errors/postgresql/postgresql.factor | 7 +++++ basis/db/errors/sqlite/authors.txt | 1 + basis/db/errors/sqlite/sqlite-tests.factor | 26 ++++++++++++++++ basis/db/errors/sqlite/sqlite.factor | 31 +++++++++++++++++++ basis/db/postgresql/postgresql-tests.factor | 22 ++++++------- 9 files changed, 98 insertions(+), 14 deletions(-) create mode 100644 basis/db/errors/postgresql/authors.txt create mode 100644 basis/db/errors/postgresql/postgresql-tests.factor create mode 100644 basis/db/errors/postgresql/postgresql.factor create mode 100644 basis/db/errors/sqlite/authors.txt create mode 100644 basis/db/errors/sqlite/sqlite-tests.factor create mode 100644 basis/db/errors/sqlite/sqlite.factor diff --git a/basis/db/db.factor b/basis/db/db.factor index 0b18044f2b..eb06f0c894 100644 --- a/basis/db/db.factor +++ b/basis/db/db.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays assocs classes continuations destructors kernel math namespaces sequences classes.tuple words strings -tools.walker accessors combinators fry ; +tools.walker accessors combinators fry db.errors ; IN: db > execute-statement* ; diff --git a/basis/db/errors/errors.factor b/basis/db/errors/errors.factor index da6301639f..1d48012cf9 100644 --- a/basis/db/errors/errors.factor +++ b/basis/db/errors/errors.factor @@ -1,10 +1,20 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel ; +USING: kernel db.private ; IN: db.errors +HOOK: parse-db-error db-connection ( error -- error' ) + ERROR: db-error ; ERROR: sql-error ; ERROR: table-exists ; ERROR: bad-schema ; + +ERROR: sql-syntax-error error ; + +ERROR: sql-table-exists table ; +C: sql-table-exists + +ERROR: sql-table-missing table ; +C: sql-table-missing diff --git a/basis/db/errors/postgresql/authors.txt b/basis/db/errors/postgresql/authors.txt new file mode 100644 index 0000000000..b4bd0e7b35 --- /dev/null +++ b/basis/db/errors/postgresql/authors.txt @@ -0,0 +1 @@ +Doug Coleman \ No newline at end of file diff --git a/basis/db/errors/postgresql/postgresql-tests.factor b/basis/db/errors/postgresql/postgresql-tests.factor new file mode 100644 index 0000000000..59b9bfe4a8 --- /dev/null +++ b/basis/db/errors/postgresql/postgresql-tests.factor @@ -0,0 +1,4 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: tools.test db.errors.postgresql ; +IN: db.errors.postgresql.tests diff --git a/basis/db/errors/postgresql/postgresql.factor b/basis/db/errors/postgresql/postgresql.factor new file mode 100644 index 0000000000..9d88c96cb1 --- /dev/null +++ b/basis/db/errors/postgresql/postgresql.factor @@ -0,0 +1,7 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: ; +IN: db.errors.postgresql + +M: postgresql-db-connection parse-db-error + ; \ No newline at end of file diff --git a/basis/db/errors/sqlite/authors.txt b/basis/db/errors/sqlite/authors.txt new file mode 100644 index 0000000000..b4bd0e7b35 --- /dev/null +++ b/basis/db/errors/sqlite/authors.txt @@ -0,0 +1 @@ +Doug Coleman \ No newline at end of file diff --git a/basis/db/errors/sqlite/sqlite-tests.factor b/basis/db/errors/sqlite/sqlite-tests.factor new file mode 100644 index 0000000000..68ae55f8a8 --- /dev/null +++ b/basis/db/errors/sqlite/sqlite-tests.factor @@ -0,0 +1,26 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors combinators.short-circuit db db.errors +db.errors.sqlite db.sqlite io.files.unique kernel namespaces +tools.test ; +IN: db.errors.sqlite.tests + +: sqlite-error-test-db-path ( -- path ) + "sqlite" "error-test" make-unique-file ; + +sqlite-error-test-db-path [ + + [ + "insert into foo (id) values('1');" sql-command + ] [ + { [ sql-table-missing? ] [ table>> "foo" = ] } 1&& + ] must-fail-with + + [ + "create table foo(id);" sql-command + "create table foo(id);" sql-command + ] [ + { [ sql-table-exists? ] [ table>> "foo" = ] } 1&& + ] must-fail-with + +] with-db \ No newline at end of file diff --git a/basis/db/errors/sqlite/sqlite.factor b/basis/db/errors/sqlite/sqlite.factor new file mode 100644 index 0000000000..770a12b2a1 --- /dev/null +++ b/basis/db/errors/sqlite/sqlite.factor @@ -0,0 +1,31 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors combinators db.errors db.sqlite.private kernel +sequences peg.ebnf strings ; +IN: db.errors.sqlite + +ERROR: unparsed-sqlite-error error ; + +SINGLETONS: table-exists table-missing ; + +: sqlite-table-error ( table message -- error ) + { + { table-exists [ ] } + } case ; + +EBNF: parse-sqlite-sql-error + +TableMessage = " already exists" => [[ table-exists ]] + +SqliteError = + "table " (!(TableMessage).)+:table TableMessage:message + => [[ table >string message sqlite-table-error ]] + | "no such table: " .+:table + => [[ table >string ]] +;EBNF + +M: sqlite-db-connection parse-db-error + dup n>> { + { 1 [ string>> parse-sqlite-sql-error ] } + [ drop ] + } case ; \ No newline at end of file diff --git a/basis/db/postgresql/postgresql-tests.factor b/basis/db/postgresql/postgresql-tests.factor index cf6dc903f1..e2e2cbf7c0 100644 --- a/basis/db/postgresql/postgresql-tests.factor +++ b/basis/db/postgresql/postgresql-tests.factor @@ -3,7 +3,7 @@ prettyprint sequences namespaces tools.test db db.private db.tuples db.types unicode.case accessors system ; IN: db.postgresql.tests -: test-db ( -- postgresql-db ) +: postgresql-test-db ( -- postgresql-db ) "localhost" >>host "postgres" >>username @@ -11,10 +11,10 @@ IN: db.postgresql.tests "factor-test" >>database ; os windows? cpu x86.64? and [ - [ ] [ test-db [ ] with-db ] unit-test + [ ] [ postgresql-test-db [ ] with-db ] unit-test [ ] [ - test-db [ + postgresql-test-db [ [ "drop table person;" sql-command ] ignore-errors "create table person (name varchar(30), country varchar(30));" sql-command @@ -30,7 +30,7 @@ os windows? cpu x86.64? and [ { "Jane" "New Zealand" } } ] [ - test-db [ + postgresql-test-db [ "select * from person" sql-query ] with-db ] unit-test @@ -40,11 +40,11 @@ os windows? cpu x86.64? and [ { "John" "America" } { "Jane" "New Zealand" } } - ] [ test-db [ "select * from person" sql-query ] with-db ] unit-test + ] [ postgresql-test-db [ "select * from person" sql-query ] with-db ] unit-test [ ] [ - test-db [ + postgresql-test-db [ "insert into person(name, country) values('Jimmy', 'Canada')" sql-command ] with-db @@ -56,10 +56,10 @@ os windows? cpu x86.64? and [ { "Jane" "New Zealand" } { "Jimmy" "Canada" } } - ] [ test-db [ "select * from person" sql-query ] with-db ] unit-test + ] [ postgresql-test-db [ "select * from person" sql-query ] with-db ] unit-test [ - test-db [ + postgresql-test-db [ [ "insert into person(name, country) values('Jose', 'Mexico')" sql-command "insert into person(name, country) values('Jose', 'Mexico')" sql-command @@ -69,14 +69,14 @@ os windows? cpu x86.64? and [ ] must-fail [ 3 ] [ - test-db [ + postgresql-test-db [ "select * from person" sql-query length ] with-db ] unit-test [ ] [ - test-db [ + postgresql-test-db [ [ "insert into person(name, country) values('Jose', 'Mexico')" sql-command @@ -87,7 +87,7 @@ os windows? cpu x86.64? and [ ] unit-test [ 5 ] [ - test-db [ + postgresql-test-db [ "select * from person" sql-query length ] with-db ] unit-test From a1f3e5695b9dc3dd1feec2bd6c1498ca006a4283 Mon Sep 17 00:00:00 2001 From: sheeple Date: Fri, 20 Feb 2009 22:59:01 -0600 Subject: [PATCH 13/85] fix circularity in db --- basis/db/db.factor | 5 +++-- basis/db/errors/errors.factor | 4 +--- basis/db/errors/postgresql/postgresql.factor | 3 --- basis/db/errors/sqlite/sqlite.factor | 10 ++-------- basis/db/postgresql/postgresql.factor | 7 +++++-- basis/db/sqlite/sqlite.factor | 9 ++++++++- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/basis/db/db.factor b/basis/db/db.factor index eb06f0c894..96b72b8865 100644 --- a/basis/db/db.factor +++ b/basis/db/db.factor @@ -5,14 +5,14 @@ namespaces sequences classes.tuple words strings tools.walker accessors combinators fry db.errors ; IN: db ->insert-statements @@ -23,6 +23,7 @@ PRIVATE> GENERIC: db-open ( db -- db-connection ) HOOK: db-close db-connection ( handle -- ) +HOOK: parse-db-error db-connection ( error -- error' ) : dispose-statements ( assoc -- ) values dispose-each ; diff --git a/basis/db/errors/errors.factor b/basis/db/errors/errors.factor index 1d48012cf9..9420dbbfc4 100644 --- a/basis/db/errors/errors.factor +++ b/basis/db/errors/errors.factor @@ -1,10 +1,8 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel db.private ; +USING: kernel ; IN: db.errors -HOOK: parse-db-error db-connection ( error -- error' ) - ERROR: db-error ; ERROR: sql-error ; diff --git a/basis/db/errors/postgresql/postgresql.factor b/basis/db/errors/postgresql/postgresql.factor index 9d88c96cb1..e45ff092e8 100644 --- a/basis/db/errors/postgresql/postgresql.factor +++ b/basis/db/errors/postgresql/postgresql.factor @@ -2,6 +2,3 @@ ! See http://factorcode.org/license.txt for BSD license. USING: ; IN: db.errors.postgresql - -M: postgresql-db-connection parse-db-error - ; \ No newline at end of file diff --git a/basis/db/errors/sqlite/sqlite.factor b/basis/db/errors/sqlite/sqlite.factor index 770a12b2a1..c247a36257 100644 --- a/basis/db/errors/sqlite/sqlite.factor +++ b/basis/db/errors/sqlite/sqlite.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors combinators db.errors db.sqlite.private kernel -sequences peg.ebnf strings ; +USING: accessors combinators db kernel sequences peg.ebnf +strings db.errors ; IN: db.errors.sqlite ERROR: unparsed-sqlite-error error ; @@ -23,9 +23,3 @@ SqliteError = | "no such table: " .+:table => [[ table >string ]] ;EBNF - -M: sqlite-db-connection parse-db-error - dup n>> { - { 1 [ string>> parse-sqlite-sql-error ] } - [ drop ] - } case ; \ No newline at end of file diff --git a/basis/db/postgresql/postgresql.factor b/basis/db/postgresql/postgresql.factor index 1f55dcf769..1c39166071 100644 --- a/basis/db/postgresql/postgresql.factor +++ b/basis/db/postgresql/postgresql.factor @@ -5,8 +5,8 @@ kernel math math.parser namespaces make prettyprint quotations sequences debugger db db.postgresql.lib db.postgresql.ffi db.tuples db.types tools.annotations math.ranges combinators classes locals words tools.walker db.private -nmake accessors random db.queries destructors db.tuples.private ; -USE: tools.walker +nmake accessors random db.queries destructors db.tuples.private +db.postgresql ; IN: db.postgresql TUPLE: postgresql-db host port pgopts pgtty database username password ; @@ -280,3 +280,6 @@ M: postgresql-db-connection compound ( string object -- string' ) { "references" [ >reference-string ] } [ drop no-compound-found ] } case ; + +M: postgresql-db-connection parse-db-error + ; diff --git a/basis/db/sqlite/sqlite.factor b/basis/db/sqlite/sqlite.factor index a4adba3473..5b658f36c9 100755 --- a/basis/db/sqlite/sqlite.factor +++ b/basis/db/sqlite/sqlite.factor @@ -6,7 +6,8 @@ sequences strings classes.tuple alien.c-types continuations db.sqlite.lib db.sqlite.ffi db.tuples words db.types combinators math.intervals io nmake accessors vectors math.ranges random math.bitwise db.queries destructors db.tuples.private interpolate -io.streams.string multiline make db.private sequences.deep ; +io.streams.string multiline make db.private sequences.deep +db.errors.sqlite ; IN: db.sqlite TUPLE: sqlite-db path ; @@ -347,3 +348,9 @@ M: sqlite-db-connection compound ( string seq -- new-string ) { "references" [ >reference-string ] } [ 2drop ] } case ; + +M: sqlite-db-connection parse-db-error + dup n>> { + { 1 [ string>> parse-sqlite-sql-error ] } + [ drop ] + } case ; From d6d89e0a40418f7e80d2b51cd8b1bb7b7b854524 Mon Sep 17 00:00:00 2001 From: sheeple Date: Sat, 21 Feb 2009 21:22:51 -0600 Subject: [PATCH 14/85] add parsing for postgresql errors and some unit tests --- basis/db/errors/errors.factor | 22 ++++--- .../errors/postgresql/postgresql-tests.factor | 30 +++++++++- basis/db/errors/postgresql/postgresql.factor | 58 ++++++++++++++++++- basis/db/postgresql/postgresql-tests.factor | 9 +-- basis/db/postgresql/postgresql.factor | 12 +++- basis/db/sqlite/lib/lib.factor | 7 ++- basis/db/tester/tester.factor | 38 ++++++++++-- basis/db/tuples/tuples-tests.factor | 34 +---------- 8 files changed, 153 insertions(+), 57 deletions(-) diff --git a/basis/db/errors/errors.factor b/basis/db/errors/errors.factor index 9420dbbfc4..00aa568154 100644 --- a/basis/db/errors/errors.factor +++ b/basis/db/errors/errors.factor @@ -1,18 +1,24 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel ; +USING: accessors kernel ; IN: db.errors ERROR: db-error ; -ERROR: sql-error ; +ERROR: sql-error location ; -ERROR: table-exists ; ERROR: bad-schema ; -ERROR: sql-syntax-error error ; +ERROR: sql-table-exists < sql-error table ; +: ( table -- error ) + \ sql-table-exists new + swap >>table ; -ERROR: sql-table-exists table ; -C: sql-table-exists +ERROR: sql-table-missing < sql-error table ; +: ( table -- error ) + \ sql-table-missing new + swap >>table ; -ERROR: sql-table-missing table ; -C: sql-table-missing +ERROR: sql-syntax-error < sql-error message ; +: ( message -- error ) + \ sql-syntax-error new + swap >>message ; diff --git a/basis/db/errors/postgresql/postgresql-tests.factor b/basis/db/errors/postgresql/postgresql-tests.factor index 59b9bfe4a8..770b325086 100644 --- a/basis/db/errors/postgresql/postgresql-tests.factor +++ b/basis/db/errors/postgresql/postgresql-tests.factor @@ -1,4 +1,32 @@ ! Copyright (C) 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: tools.test db.errors.postgresql ; +USING: accessors combinators.short-circuit db db.errors +db.errors.postgresql db.postgresql io.files.unique kernel namespaces +tools.test db.tester ; IN: db.errors.postgresql.tests + +postgresql-test-db [ + + [ "drop table foo;" sql-command ] ignore-errors + [ "drop table ship;" sql-command ] ignore-errors + + [ + "insert into foo (id) values('1');" sql-command + ] [ + { [ sql-table-missing? ] [ table>> "foo" = ] } 1&& + ] must-fail-with + + [ + "create table ship(id integer);" sql-command + "create table ship(id integer);" sql-command + ] [ + { [ sql-table-exists? ] [ table>> "ship" = ] } 1&& + ] must-fail-with + + [ + "create table foo(id) lol;" sql-command + ] [ + sql-syntax-error? + ] must-fail-with + +] with-db diff --git a/basis/db/errors/postgresql/postgresql.factor b/basis/db/errors/postgresql/postgresql.factor index e45ff092e8..fac10d092f 100644 --- a/basis/db/errors/postgresql/postgresql.factor +++ b/basis/db/errors/postgresql/postgresql.factor @@ -1,4 +1,60 @@ ! Copyright (C) 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: ; +USING: kernel db.errors peg.ebnf strings sequences math +combinators.short-circuit accessors math.parser ; IN: db.errors.postgresql + +! ERROR: relation "foo" does not exist + +: quote? ( ch -- ? ) "'\"" member? ; + +: quoted? ( str -- ? ) + { + [ length 1 > ] + [ first quote? ] + [ [ first ] [ peek ] bi = ] + } 1&& ; + +: unquote ( str -- newstr ) + dup quoted? [ but-last-slice rest-slice >string ] when ; + + +EBNF: parse-postgresql-sql-error + +Error = "ERROR:" [ ]+ + +TableError = + Error "relation " (!(" already exists").)+:table " already exists" + => [[ table >string unquote ]] + | Error "relation " (!(" does not exist").)+:table " does not exist" + => [[ table >string unquote ]] + +SyntaxError = + Error "syntax error at end of input":error + => [[ error >string ]] + | Error "syntax error at or near " .+:syntaxerror + => [[ syntaxerror >string unquote ]] + +PostgresqlSqlError = (TableError | SyntaxError) + +;EBNF + + +ERROR: parse-postgresql-location column line text ; +C: parse-postgresql-location + +EBNF: parse-postgresql-line-error + +Line = "LINE " [0-9]+:line ": " .+:sql + => [[ f line >string string>number sql >string ]] + +;EBNF + +:: set-caret-position ( error caret-line -- error ) + caret-line length + error line>> number>string length "LINE : " length + + - [ error ] dip >>column ; + +: postgresql-location ( line column -- obj ) + [ parse-postgresql-line-error ] dip + set-caret-position ; diff --git a/basis/db/postgresql/postgresql-tests.factor b/basis/db/postgresql/postgresql-tests.factor index e2e2cbf7c0..266337b8c8 100644 --- a/basis/db/postgresql/postgresql-tests.factor +++ b/basis/db/postgresql/postgresql-tests.factor @@ -1,15 +1,8 @@ USING: kernel db.postgresql alien continuations io classes prettyprint sequences namespaces tools.test db db.private -db.tuples db.types unicode.case accessors system ; +db.tuples db.types unicode.case accessors system db.tester ; IN: db.postgresql.tests -: postgresql-test-db ( -- postgresql-db ) - - "localhost" >>host - "postgres" >>username - "thepasswordistrust" >>password - "factor-test" >>database ; - os windows? cpu x86.64? and [ [ ] [ postgresql-test-db [ ] with-db ] unit-test diff --git a/basis/db/postgresql/postgresql.factor b/basis/db/postgresql/postgresql.factor index 1c39166071..9e51f41ff1 100644 --- a/basis/db/postgresql/postgresql.factor +++ b/basis/db/postgresql/postgresql.factor @@ -6,7 +6,7 @@ sequences debugger db db.postgresql.lib db.postgresql.ffi db.tuples db.types tools.annotations math.ranges combinators classes locals words tools.walker db.private nmake accessors random db.queries destructors db.tuples.private -db.postgresql ; +db.postgresql db.errors.postgresql splitting ; IN: db.postgresql TUPLE: postgresql-db host port pgopts pgtty database username password ; @@ -282,4 +282,12 @@ M: postgresql-db-connection compound ( string object -- string' ) } case ; M: postgresql-db-connection parse-db-error - ; + "\n" split dup length { + { 1 [ first parse-postgresql-sql-error ] } + { 3 [ + first3 + [ parse-postgresql-sql-error ] 2dip + postgresql-location >>location + ] } + } case ; + diff --git a/basis/db/sqlite/lib/lib.factor b/basis/db/sqlite/lib/lib.factor index 60141bc830..3565b09856 100644 --- a/basis/db/sqlite/lib/lib.factor +++ b/basis/db/sqlite/lib/lib.factor @@ -11,12 +11,17 @@ IN: db.sqlite.lib ERROR: sqlite-error < db-error n string ; ERROR: sqlite-sql-error < sql-error n string ; +: ( n string -- error ) + \ sqlite-sql-error new + swap >>string + swap >>n ; + : throw-sqlite-error ( n -- * ) dup sqlite-error-messages nth sqlite-error ; : sqlite-statement-error ( -- * ) SQLITE_ERROR - db-connection get handle>> sqlite3_errmsg sqlite-sql-error ; + db-connection get handle>> sqlite3_errmsg throw ; : sqlite-check-result ( n -- ) { diff --git a/basis/db/tester/tester.factor b/basis/db/tester/tester.factor index 490f6bbef5..fcc5abf1cf 100644 --- a/basis/db/tester/tester.factor +++ b/basis/db/tester/tester.factor @@ -2,9 +2,42 @@ ! See http://factorcode.org/license.txt for BSD license. USING: concurrency.combinators db.pools db.sqlite db.tuples db.types kernel math random threads tools.test db sequences -io prettyprint ; +io prettyprint db.postgresql db.sqlite accessors io.files.temp +namespaces fry system ; IN: db.tester +: postgresql-test-db ( -- postgresql-db ) + + "localhost" >>host + "postgres" >>username + "thepasswordistrust" >>password + "factor-test" >>database ; + +: sqlite-test-db ( -- sqlite-db ) + "tuples-test.db" temp-file ; + + +! These words leak resources, but are useful for interactivel testing +: set-sqlite-db ( -- ) + sqlite-db db-open db-connection set ; + +: set-postgresql-db ( -- ) + postgresql-db db-open db-connection set ; + + +: test-sqlite ( quot -- ) + '[ + [ ] [ sqlite-test-db _ with-db ] unit-test + ] call ; inline + +: test-postgresql ( quot -- ) + '[ + os windows? cpu x86.64? and [ + [ ] [ postgresql-test-db _ with-db ] unit-test + ] unless + ] call ; inline + + TUPLE: test-1 id a b c ; test-1 "TEST1" { @@ -23,9 +56,6 @@ test-2 "TEST2" { { "z" "Z" { VARCHAR 256 } +not-null+ } } define-persistent -: sqlite-test-db ( -- db ) "test.db" ; -: test-db ( -- db ) "test.db" ; - : db-tester ( test-db -- ) [ [ diff --git a/basis/db/tuples/tuples-tests.factor b/basis/db/tuples/tuples-tests.factor index 246946c715..af77ce6ac1 100644 --- a/basis/db/tuples/tuples-tests.factor +++ b/basis/db/tuples/tuples-tests.factor @@ -4,40 +4,10 @@ USING: io.files io.files.temp kernel tools.test db db.tuples classes db.types continuations namespaces math math.ranges prettyprint calendar sequences db.sqlite math.intervals db.postgresql accessors random math.bitwise system -math.ranges strings urls fry db.tuples.private db.private ; +math.ranges strings urls fry db.tuples.private db.private +db.tester ; IN: db.tuples.tests -: sqlite-db ( -- sqlite-db ) - "tuples-test.db" temp-file ; - -: test-sqlite ( quot -- ) - '[ - [ ] [ - "tuples-test.db" temp-file _ with-db - ] unit-test - ] call ; inline - -: postgresql-db ( -- postgresql-db ) - - "localhost" >>host - "postgres" >>username - "thepasswordistrust" >>password - "factor-test" >>database ; - -: test-postgresql ( quot -- ) - '[ - os windows? cpu x86.64? and [ - [ ] [ postgresql-db _ with-db ] unit-test - ] unless - ] call ; inline - -! These words leak resources, but are useful for interactivel testing -: sqlite-test-db ( -- ) - sqlite-db db-open db-connection set ; - -: postgresql-test-db ( -- ) - postgresql-db db-open db-connection set ; - TUPLE: person the-id the-name the-number the-real ts date time blob factor-blob url ; From 02cec3a9f41e7b89f027eea21fd05c09834a8872 Mon Sep 17 00:00:00 2001 From: sheeple Date: Sat, 21 Feb 2009 21:59:23 -0600 Subject: [PATCH 15/85] add more postgres error handling, remove usage of ignore-errors in db.tuples --- basis/db/errors/errors.factor | 32 ++++++++++++++++++- .../errors/postgresql/postgresql-tests.factor | 2 +- basis/db/errors/postgresql/postgresql.factor | 16 +++++++--- basis/db/tuples/tuples.factor | 10 +++--- 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/basis/db/errors/errors.factor b/basis/db/errors/errors.factor index 00aa568154..5239086f93 100644 --- a/basis/db/errors/errors.factor +++ b/basis/db/errors/errors.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel ; +USING: accessors kernel continuations fry words ; IN: db.errors ERROR: db-error ; @@ -8,6 +8,11 @@ ERROR: sql-error location ; ERROR: bad-schema ; +ERROR: sql-unknown-error < sql-error message ; +: ( message -- error ) + \ sql-unknown-error new + swap >>message ; + ERROR: sql-table-exists < sql-error table ; : ( table -- error ) \ sql-table-exists new @@ -22,3 +27,28 @@ ERROR: sql-syntax-error < sql-error message ; : ( message -- error ) \ sql-syntax-error new swap >>message ; + +ERROR: sql-function-exists < sql-error message ; +: ( message -- error ) + \ sql-function-exists new + swap >>message ; + +ERROR: sql-function-missing < sql-error message ; +: ( message -- error ) + \ sql-function-missing new + swap >>message ; + +: ignore-error ( quot word -- ) + '[ dup _ execute [ drop ] [ rethrow ] if ] recover ; inline + +: ignore-table-exists ( quot -- ) + \ sql-table-exists? ignore-error ; inline + +: ignore-table-missing ( quot -- ) + \ sql-table-missing? ignore-error ; inline + +: ignore-function-exists ( quot -- ) + \ sql-function-exists? ignore-error ; inline + +: ignore-function-missing ( quot -- ) + \ sql-function-missing? ignore-error ; inline diff --git a/basis/db/errors/postgresql/postgresql-tests.factor b/basis/db/errors/postgresql/postgresql-tests.factor index 770b325086..9dbebe0712 100644 --- a/basis/db/errors/postgresql/postgresql-tests.factor +++ b/basis/db/errors/postgresql/postgresql-tests.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors combinators.short-circuit db db.errors db.errors.postgresql db.postgresql io.files.unique kernel namespaces -tools.test db.tester ; +tools.test db.tester continuations ; IN: db.errors.postgresql.tests postgresql-test-db [ diff --git a/basis/db/errors/postgresql/postgresql.factor b/basis/db/errors/postgresql/postgresql.factor index fac10d092f..2b79859050 100644 --- a/basis/db/errors/postgresql/postgresql.factor +++ b/basis/db/errors/postgresql/postgresql.factor @@ -4,8 +4,6 @@ USING: kernel db.errors peg.ebnf strings sequences math combinators.short-circuit accessors math.parser ; IN: db.errors.postgresql -! ERROR: relation "foo" does not exist - : quote? ( ch -- ? ) "'\"" member? ; : quoted? ( str -- ? ) @@ -24,18 +22,26 @@ EBNF: parse-postgresql-sql-error Error = "ERROR:" [ ]+ TableError = - Error "relation " (!(" already exists").)+:table " already exists" + Error ("relation "|"table ")(!(" already exists").)+:table " already exists" => [[ table >string unquote ]] - | Error "relation " (!(" does not exist").)+:table " does not exist" + | Error ("relation "|"table ")(!(" does not exist").)+:table " does not exist" => [[ table >string unquote ]] +FunctionError = + Error "function" (!(" already exists").)+:table " already exists" + => [[ table >string ]] + | Error "function" (!(" does not exist").)+:table " does not exist" + => [[ table >string ]] + SyntaxError = Error "syntax error at end of input":error => [[ error >string ]] | Error "syntax error at or near " .+:syntaxerror => [[ syntaxerror >string unquote ]] -PostgresqlSqlError = (TableError | SyntaxError) +UnknownError = .* => [[ >string ]] + +PostgresqlSqlError = (TableError | FunctionError | SyntaxError | UnknownError) ;EBNF diff --git a/basis/db/tuples/tuples.factor b/basis/db/tuples/tuples.factor index 9edd5bac69..19d4be5fc8 100644 --- a/basis/db/tuples/tuples.factor +++ b/basis/db/tuples/tuples.factor @@ -4,7 +4,7 @@ USING: arrays assocs classes db kernel namespaces classes.tuple words sequences slots math accessors math.parser io prettyprint db.types continuations destructors mirrors sets db.types db.private fry -combinators.short-circuit ; +combinators.short-circuit db.errors ; IN: db.tuples HOOK: create-sql-statement db-connection ( class -- object ) @@ -118,13 +118,15 @@ ERROR: no-defined-persistent object ; ensure-defined-persistent [ '[ - _ drop-sql-statement [ execute-statement ] with-disposals - ] ignore-errors + [ + _ drop-sql-statement [ execute-statement ] with-disposals + ] ignore-table-missing + ] ignore-function-missing ] [ create-table ] bi ; : ensure-table ( class -- ) ensure-defined-persistent - '[ _ create-table ] ignore-errors ; + '[ [ _ create-table ] ignore-table-exists ] ignore-function-exists ; : ensure-tables ( classes -- ) [ ensure-table ] each ; From 785d7ac9afb64283676e015b2e74bf4b96978249 Mon Sep 17 00:00:00 2001 From: sheeple Date: Sat, 21 Feb 2009 22:18:02 -0600 Subject: [PATCH 16/85] clean up scaffold tool a bit, don't create a -tests.factor file when scaffolding a new vocab --- basis/tools/scaffold/scaffold.factor | 50 +++++++++++++++------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/basis/tools/scaffold/scaffold.factor b/basis/tools/scaffold/scaffold.factor index acea984700..d1623b223a 100755 --- a/basis/tools/scaffold/scaffold.factor +++ b/basis/tools/scaffold/scaffold.factor @@ -5,7 +5,7 @@ io.encodings.utf8 hashtables kernel namespaces sequences vocabs.loader io combinators calendar accessors math.parser io.streams.string ui.tools.operations quotations strings arrays prettyprint words vocabs sorting sets classes math alien urls -splitting ascii ; +splitting ascii combinators.short-circuit ; IN: tools.scaffold SYMBOL: developer-name @@ -18,18 +18,19 @@ ERROR: no-vocab vocab ; . ; +: not-scaffolding ( path -- path ) + "Not creating scaffolding for " write dup . ; -: scaffolding ( path -- ) - "Creating scaffolding for " write . ; +: scaffolding ( path -- path ) + "Creating scaffolding for " write dup . ; : (scaffold-path) ( path string -- path ) - dupd [ file-name ] dip append append-path ; + [ dup file-name ] dip append append-path ; : scaffold-path ( path string -- path ? ) (scaffold-path) - dup exists? [ dup not-scaffolding f ] [ dup scaffolding t ] if ; + dup exists? [ not-scaffolding f ] [ scaffolding t ] if ; : scaffold-copyright ( -- ) "! Copyright (C) " write now year>> number>string write @@ -85,14 +86,14 @@ ERROR: no-vocab vocab ; : scaffold-authors ( path -- ) "authors.txt" append-path dup exists? [ - not-scaffolding + not-scaffolding drop ] [ - dup scaffolding + scaffolding developer-name get swap utf8 set-file-contents ] if ; : lookup-type ( string -- object/string ? ) - "new" ?head drop [ [ CHAR: ' = ] [ digit? ] bi or ] trim-tail + "new" ?head drop [ { [ CHAR: ' = ] [ digit? ] } 1|| ] trim-tail H{ { "object" object } { "obj" object } { "quot" quotation } @@ -134,6 +135,9 @@ ERROR: no-vocab vocab ; " }" write ] each ; +: 4bl ( -- ) + " " write ; inline + : $values. ( word -- ) "declared-effect" word-prop [ [ in>> ] [ out>> ] bi @@ -141,8 +145,8 @@ ERROR: no-vocab vocab ; 2drop ] [ "{ $values" print - [ " " write ($values.) ] - [ [ nl " " write ($values.) ] unless-empty ] bi* + [ 4bl ($values.) ] + [ [ nl 4bl ($values.) ] unless-empty ] bi* nl "}" print ] if ] when* ; @@ -159,7 +163,7 @@ ERROR: no-vocab vocab ; : interesting-words ( vocab -- array ) words - [ [ "help" word-prop ] [ predicate? ] bi or not ] filter + [ { [ "help" word-prop ] [ predicate? ] } 1|| not ] filter natural-sort ; : interesting-words. ( vocab -- ) @@ -237,7 +241,6 @@ PRIVATE> { [ drop scaffold-directory ] [ scaffold-main ] - [ scaffold-tests ] [ drop scaffold-authors ] [ nip require ] } 2cleave ; @@ -250,7 +253,7 @@ SYMBOL: examples-flag " \"\"" " \"\"" "}" - } [ examples-flag get [ " " write ] when print ] each ; + } [ examples-flag get [ 4bl ] when print ] each ; : examples ( n -- ) t \ examples-flag [ @@ -260,10 +263,11 @@ SYMBOL: examples-flag ] with-variable ; : scaffold-rc ( path -- ) + [ home ] dip append-path [ touch-file ] [ "Click to edit: " write . ] bi ; -: scaffold-factor-boot-rc ( -- ) - home ".factor-boot-rc" append-path scaffold-rc ; +: scaffold-factor-boot-rc ( -- ) ".factor-boot-rc" scaffold-rc ; -: scaffold-factor-rc ( -- ) - home ".factor-rc" append-path scaffold-rc ; +: scaffold-factor-rc ( -- ) ".factor-rc" scaffold-rc ; + +: scaffold-emacs ( -- ) ".emacs" scaffold-rc ; From 405b3dc1ad97525fd5a31aae405284bfbe2d4fea Mon Sep 17 00:00:00 2001 From: sheeple Date: Sun, 22 Feb 2009 00:19:10 -0600 Subject: [PATCH 17/85] refactor tools.scaffold -- scaffold-help -> scaffold-docs, it takes a vocab name now --- basis/tools/scaffold/scaffold.factor | 146 +++++++++++++++------------ 1 file changed, 80 insertions(+), 66 deletions(-) diff --git a/basis/tools/scaffold/scaffold.factor b/basis/tools/scaffold/scaffold.factor index d1623b223a..eb7017f57f 100755 --- a/basis/tools/scaffold/scaffold.factor +++ b/basis/tools/scaffold/scaffold.factor @@ -32,10 +32,37 @@ ERROR: no-vocab vocab ; : check-root ( string -- string ) dup vocab-root? [ not-a-vocab-root ] unless ; +: check-vocab ( vocab -- vocab ) + dup find-vocab-root [ no-vocab ] unless ; + +: check-vocab-root/vocab ( vocab-root string -- vocab-root string ) + [ check-root ] [ check-vocab-name ] bi* ; + +: replace-vocab-separators ( vocab -- path ) + path-separator first CHAR: . associate substitute ; inline + +: vocab-root/vocab>path ( vocab-root vocab -- path ) + check-vocab-root/vocab + [ ] [ replace-vocab-separators ] bi* append-path ; + +: vocab>path ( vocab -- path ) + check-vocab + [ find-vocab-root ] keep vocab-root/vocab>path ; + +: vocab-root/vocab/file>path ( vocab-root vocab file -- path ) + [ vocab-root/vocab>path ] dip append-path ; + +: vocab-root/vocab/suffix>path ( vocab-root vocab suffix -- path ) + [ vocab-root/vocab>path dup file-name append-path ] dip append ; + +: vocab/suffix>path ( vocab suffix -- path ) + [ vocab>path dup file-name append-path ] dip append ; + : directory-exists ( path -- ) "Not creating a directory, it already exists: " write print ; -: scaffold-directory ( path -- ) +: scaffold-directory ( vocab-root vocab -- ) + vocab-root/vocab>path dup exists? [ directory-exists ] [ make-directories ] if ; : not-scaffolding ( path -- path ) @@ -44,11 +71,7 @@ ERROR: no-vocab vocab ; : scaffolding ( path -- path ) "Creating scaffolding for " write dup . ; -: (scaffold-path) ( path string -- path ) - [ dup file-name ] dip append append-path ; - -: scaffold-path ( path string -- path ? ) - (scaffold-path) +: scaffolding? ( path -- path ? ) dup exists? [ not-scaffolding f ] [ scaffolding t ] if ; : scaffold-copyright ( -- ) @@ -63,33 +86,21 @@ ERROR: no-vocab vocab ; "IN: " write print ] with-string-writer ; -: set-scaffold-main-file ( path vocab -- ) - main-file-string swap utf8 set-file-contents ; +: set-scaffold-main-file ( vocab path -- ) + [ main-file-string ] dip utf8 set-file-contents ; -: scaffold-main ( path vocab -- ) - [ ".factor" scaffold-path ] dip - swap [ set-scaffold-main-file ] [ 2drop ] if ; - -: tests-file-string ( vocab -- string ) - [ - scaffold-copyright - "USING: tools.test " write dup write " ;" print - "IN: " write write ".tests" print - ] with-string-writer ; - -: set-scaffold-tests-file ( path vocab -- ) - tests-file-string swap utf8 set-file-contents ; - -: scaffold-tests ( path vocab -- ) - [ "-tests.factor" scaffold-path ] dip - swap [ set-scaffold-tests-file ] [ 2drop ] if ; - -: scaffold-authors ( path -- ) - "authors.txt" append-path dup exists? [ - not-scaffolding drop +: scaffold-main ( vocab-root vocab -- ) + tuck ".factor" vocab-root/vocab/suffix>path scaffolding? [ + set-scaffold-main-file ] [ - scaffolding - developer-name get swap utf8 set-file-contents + 2drop + ] if ; + +: scaffold-authors ( vocab-root vocab -- ) + "authors.txt" vocab-root/vocab/file>path scaffolding? [ + [ developer-name get ] dip utf8 set-file-contents + ] [ + drop ] if ; : lookup-type ( string -- object/string ? ) @@ -155,11 +166,11 @@ ERROR: no-vocab vocab ; drop "{ $description \"\" } ;" print ; -: help-header. ( word -- ) +: docs-header. ( word -- ) "HELP: " write name>> print ; -: (help.) ( word -- ) - [ help-header. ] [ $values. ] [ $description. ] tri ; +: (docs.) ( word -- ) + [ docs-header. ] [ $values. ] [ $description. ] tri ; : interesting-words ( vocab -- array ) words @@ -167,9 +178,9 @@ ERROR: no-vocab vocab ; natural-sort ; : interesting-words. ( vocab -- ) - interesting-words [ (help.) nl ] each ; + interesting-words [ (docs.) nl ] each ; -: help-file-string ( vocab -- str2 ) +: docs-file-string ( vocab -- str2 ) [ { [ "IN: " write print nl ] @@ -190,61 +201,64 @@ ERROR: no-vocab vocab ; [ bl write ] each " ;" print ; -: set-scaffold-help-file ( path vocab -- ) - swap utf8 [ +: set-scaffold-docs-file ( vocab path -- ) + utf8 [ scaffold-copyright - [ help-file-string ] [ write-using ] bi + [ docs-file-string ] [ write-using ] bi write ] with-output-stream ; -: check-scaffold ( vocab-root string -- vocab-root string ) - [ check-root ] [ check-vocab-name ] bi* ; - -: vocab>scaffold-path ( vocab-root string -- path ) - path-separator first CHAR: . associate substitute - append-path ; - -: prepare-scaffold ( vocab-root string -- string path ) - check-scaffold [ vocab>scaffold-path ] keep ; - : with-scaffold ( quot -- ) [ H{ } clone using ] dip with-variable ; inline -: check-vocab ( vocab -- vocab ) - dup find-vocab-root [ no-vocab ] unless ; - PRIVATE> : link-vocab ( vocab -- ) check-vocab "Edit documentation: " write - [ find-vocab-root ] - [ vocab>scaffold-path ] bi - "-docs.factor" (scaffold-path) . ; + "-docs.factor" vocab/suffix>path . ; -: help. ( word -- ) - [ (help.) ] [ nl vocabulary>> link-vocab ] bi ; +: docs. ( word -- ) + [ (docs.) ] [ nl vocabulary>> link-vocab ] bi ; -: scaffold-help ( string -- ) +: scaffold-docs ( vocab -- ) [ - [ find-vocab-root ] [ check-vocab ] bi - prepare-scaffold - [ "-docs.factor" scaffold-path ] dip - swap [ set-scaffold-help-file ] [ 2drop ] if + dup "-docs.factor" vocab/suffix>path scaffolding? [ + set-scaffold-docs-file + ] [ + 2drop + ] if ] with-scaffold ; : scaffold-undocumented ( string -- ) [ interesting-words. ] [ link-vocab ] bi ; -: scaffold-vocab ( vocab-root string -- ) - prepare-scaffold +: scaffold-vocab ( vocab-root vocab -- ) { - [ drop scaffold-directory ] + [ scaffold-directory ] [ scaffold-main ] - [ drop scaffold-authors ] + [ scaffold-authors ] [ nip require ] } 2cleave ; +: tests-file-string ( vocab -- string ) + [ + scaffold-copyright + "USING: tools.test " write dup write " ;" print + "IN: " write write ".tests" print + ] with-string-writer ; + +: set-scaffold-tests-file ( vocab path -- ) + [ tests-file-string ] dip utf8 set-file-contents ; + +: scaffold-tests ( vocab -- ) + dup "-tests.factor" vocab/suffix>path + scaffolding? [ + set-scaffold-tests-file + ] [ + 2drop + ] if ; + SYMBOL: examples-flag : example ( -- ) From 43679966789315c76caa14a81f8dc692971d6767 Mon Sep 17 00:00:00 2001 From: sheeple Date: Sun, 22 Feb 2009 00:33:00 -0600 Subject: [PATCH 18/85] make some more words private, rename scaffold-docs back to scaffold-help --- basis/tools/scaffold/scaffold.factor | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/basis/tools/scaffold/scaffold.factor b/basis/tools/scaffold/scaffold.factor index eb7017f57f..5a0bf66e26 100755 --- a/basis/tools/scaffold/scaffold.factor +++ b/basis/tools/scaffold/scaffold.factor @@ -211,8 +211,6 @@ ERROR: no-vocab vocab ; : with-scaffold ( quot -- ) [ H{ } clone using ] dip with-variable ; inline -PRIVATE> - : link-vocab ( vocab -- ) check-vocab "Edit documentation: " write @@ -221,7 +219,9 @@ PRIVATE> : docs. ( word -- ) [ (docs.) ] [ nl vocabulary>> link-vocab ] bi ; -: scaffold-docs ( vocab -- ) +PRIVATE> + +: scaffold-help ( vocab -- ) [ dup "-docs.factor" vocab/suffix>path scaffolding? [ set-scaffold-docs-file @@ -233,7 +233,7 @@ PRIVATE> : scaffold-undocumented ( string -- ) [ interesting-words. ] [ link-vocab ] bi ; -: scaffold-vocab ( vocab-root vocab -- ) +: scaffold-vocab ( vocab-root string -- ) { [ scaffold-directory ] [ scaffold-main ] @@ -241,6 +241,8 @@ PRIVATE> [ nip require ] } 2cleave ; + : set-scaffold-tests-file ( vocab path -- ) [ tests-file-string ] dip utf8 set-file-contents ; +PRIVATE> + : scaffold-tests ( vocab -- ) dup "-tests.factor" vocab/suffix>path scaffolding? [ From 57bd819886d5dc36e259f327c74919eacd17924f Mon Sep 17 00:00:00 2001 From: sheeple Date: Sun, 22 Feb 2009 00:42:21 -0600 Subject: [PATCH 19/85] add quoting vocab --- basis/quoting/authors.txt | 1 + basis/quoting/quoting-docs.factor | 32 ++++++++++++++++++++++++++++++ basis/quoting/quoting-tests.factor | 10 ++++++++++ basis/quoting/quoting.factor | 16 +++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 basis/quoting/authors.txt create mode 100644 basis/quoting/quoting-docs.factor create mode 100644 basis/quoting/quoting-tests.factor create mode 100644 basis/quoting/quoting.factor diff --git a/basis/quoting/authors.txt b/basis/quoting/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/basis/quoting/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/basis/quoting/quoting-docs.factor b/basis/quoting/quoting-docs.factor new file mode 100644 index 0000000000..5fb68db719 --- /dev/null +++ b/basis/quoting/quoting-docs.factor @@ -0,0 +1,32 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: help.markup help.syntax strings ; +IN: quoting + +HELP: quote? +{ $values + { "ch" "a character" } + { "?" "a boolean" } +} +{ $description "Returns true if the character is a single or double quote." } ; + +HELP: quoted? +{ $values + { "str" string } + { "?" "a boolean" } +} +{ $description "Returns true if a string is surrounded by matching single or double quotes as the first and last characters." } ; + +HELP: unquote +{ $values + { "str" string } + { "newstr" string } +} +{ $description "Removes a pair of matching single or double quotes from a string." } ; + +ARTICLE: "quoting" "Quotation marks" +"The " { $vocab-link "quoting" } " vocabulary is for removing quotes from a string." $nl +"Removing quotes:" +{ $subsection unquote } ; + +ABOUT: "quoting" diff --git a/basis/quoting/quoting-tests.factor b/basis/quoting/quoting-tests.factor new file mode 100644 index 0000000000..0cc28a1354 --- /dev/null +++ b/basis/quoting/quoting-tests.factor @@ -0,0 +1,10 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: tools.test quoting ; +IN: quoting.tests + + +[ "abc" ] [ "'abc'" unquote ] unit-test +[ "abc" ] [ "\"abc\"" unquote ] unit-test +[ "'abc" ] [ "'abc" unquote ] unit-test +[ "abc'" ] [ "abc'" unquote ] unit-test diff --git a/basis/quoting/quoting.factor b/basis/quoting/quoting.factor new file mode 100644 index 0000000000..9e25037cd9 --- /dev/null +++ b/basis/quoting/quoting.factor @@ -0,0 +1,16 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: combinators.short-circuit kernel math sequences strings ; +IN: quoting + +: quote? ( ch -- ? ) "'\"" member? ; + +: quoted? ( str -- ? ) + { + [ length 1 > ] + [ first quote? ] + [ [ first ] [ peek ] bi = ] + } 1&& ; + +: unquote ( str -- newstr ) + dup quoted? [ but-last-slice rest-slice >string ] when ; From 06f6eb98aa1b8a9009a557acfeb3b3f59b9e7e37 Mon Sep 17 00:00:00 2001 From: sheeple Date: Sun, 22 Feb 2009 00:42:35 -0600 Subject: [PATCH 20/85] use quoting vocab --- basis/db/errors/postgresql/postgresql.factor | 15 +-------------- basis/mime/multipart/multipart.factor | 15 ++------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/basis/db/errors/postgresql/postgresql.factor b/basis/db/errors/postgresql/postgresql.factor index 2b79859050..02b43ecd88 100644 --- a/basis/db/errors/postgresql/postgresql.factor +++ b/basis/db/errors/postgresql/postgresql.factor @@ -1,22 +1,9 @@ ! Copyright (C) 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: kernel db.errors peg.ebnf strings sequences math -combinators.short-circuit accessors math.parser ; +combinators.short-circuit accessors math.parser quoting ; IN: db.errors.postgresql -: quote? ( ch -- ? ) "'\"" member? ; - -: quoted? ( str -- ? ) - { - [ length 1 > ] - [ first quote? ] - [ [ first ] [ peek ] bi = ] - } 1&& ; - -: unquote ( str -- newstr ) - dup quoted? [ but-last-slice rest-slice >string ] when ; - - EBNF: parse-postgresql-sql-error Error = "ERROR:" [ ]+ diff --git a/basis/mime/multipart/multipart.factor b/basis/mime/multipart/multipart.factor index 37d5e13129..0edfb05a30 100755 --- a/basis/mime/multipart/multipart.factor +++ b/basis/mime/multipart/multipart.factor @@ -3,7 +3,8 @@ USING: multiline kernel sequences io splitting fry namespaces http.parsers hashtables assocs combinators ascii io.files.unique accessors io.encodings.binary io.files byte-arrays math -io.streams.string combinators.short-circuit strings math.order ; +io.streams.string combinators.short-circuit strings math.order +quoting ; IN: mime.multipart CONSTANT: buffer-size 65536 @@ -75,18 +76,6 @@ ERROR: end-of-stream multipart ; : empty-name? ( string -- ? ) { "''" "\"\"" "" f } member? ; -: quote? ( ch -- ? ) "'\"" member? ; - -: quoted? ( str -- ? ) - { - [ length 1 > ] - [ first quote? ] - [ [ first ] [ peek ] bi = ] - } 1&& ; - -: unquote ( str -- newstr ) - dup quoted? [ but-last-slice rest-slice >string ] when ; - : save-uploaded-file ( multipart -- ) dup filename>> empty-name? [ drop From 1f5a701f6809ba7d7004fe167f6de61eed40f6af Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 10:03:37 -0600 Subject: [PATCH 21/85] fix load error in scaffold --- basis/tools/scaffold/scaffold-docs.factor | 4 ++-- basis/tools/scaffold/scaffold.factor | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/basis/tools/scaffold/scaffold-docs.factor b/basis/tools/scaffold/scaffold-docs.factor index 9074c80986..0a75732553 100644 --- a/basis/tools/scaffold/scaffold-docs.factor +++ b/basis/tools/scaffold/scaffold-docs.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: help.markup help.syntax kernel strings words ; +USING: help.markup help.syntax kernel strings words vocabs ; IN: tools.scaffold HELP: developer-name @@ -13,7 +13,7 @@ HELP: help. { $description "Prints out scaffold help markup for a given word." } ; HELP: scaffold-help -{ $values { "string" string } } +{ $values { "vocab" vocab } } { $description "Takes an existing vocabulary and creates a help file with scaffolded help for each word. This word only works if no help file yet exists." } ; HELP: scaffold-undocumented diff --git a/basis/tools/scaffold/scaffold.factor b/basis/tools/scaffold/scaffold.factor index 5a0bf66e26..16729394bf 100755 --- a/basis/tools/scaffold/scaffold.factor +++ b/basis/tools/scaffold/scaffold.factor @@ -169,7 +169,7 @@ ERROR: no-vocab vocab ; : docs-header. ( word -- ) "HELP: " write name>> print ; -: (docs.) ( word -- ) +: (help.) ( word -- ) [ docs-header. ] [ $values. ] [ $description. ] tri ; : interesting-words ( vocab -- array ) @@ -178,7 +178,7 @@ ERROR: no-vocab vocab ; natural-sort ; : interesting-words. ( vocab -- ) - interesting-words [ (docs.) nl ] each ; + interesting-words [ (help.) nl ] each ; : docs-file-string ( vocab -- str2 ) [ @@ -216,11 +216,11 @@ ERROR: no-vocab vocab ; "Edit documentation: " write "-docs.factor" vocab/suffix>path . ; -: docs. ( word -- ) - [ (docs.) ] [ nl vocabulary>> link-vocab ] bi ; - PRIVATE> +: help. ( word -- ) + [ (help.) ] [ nl vocabulary>> link-vocab ] bi ; + : scaffold-help ( vocab -- ) [ dup "-docs.factor" vocab/suffix>path scaffolding? [ From b78d8a491fd069935475cd05d245c30b1c7daea0 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 10:27:29 -0600 Subject: [PATCH 22/85] add docs for scaffold-rc --- basis/tools/scaffold/scaffold-docs.factor | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/basis/tools/scaffold/scaffold-docs.factor b/basis/tools/scaffold/scaffold-docs.factor index 0a75732553..4d1240ad38 100644 --- a/basis/tools/scaffold/scaffold-docs.factor +++ b/basis/tools/scaffold/scaffold-docs.factor @@ -28,6 +28,21 @@ HELP: scaffold-vocab { "vocab-root" "a vocabulary root string" } { "string" string } } { $description "Creates a directory in the given root for a new vocabulary and adds a main .factor file, a tests file, and an authors.txt file." } ; +HELP: scaffold-emacs +{ $description "Touches the .emacs file in your home directory and provides a clickable link to open it in an editor." } ; + +HELP: scaffold-factor-boot-rc +{ $description "Touches the .factor-boot-rc file in your home directory and provides a clickable link to open it in an editor." } ; + +HELP: scaffold-factor-rc +{ $description "Touches the .factor-rc file in your home directory and provides a clickable link to open it in an editor." } ; + +HELP: scaffold-rc +{ $values + { "path" "a pathname string" } +} +{ $description "Touches the given path in your home directory and provides a clickable link to open it in an editor." } ; + HELP: using { $description "Stores the vocabularies that are pulled into the documentation file from looking up the stack effect types." } ; @@ -40,7 +55,12 @@ ARTICLE: "tools.scaffold" "Scaffold tool" { $subsection scaffold-help } { $subsection scaffold-undocumented } { $subsection help. } -"Types that are unrecognized by the scaffold generator will be of type " { $link null } ". The developer should change these to strings that describe the stack effect names instead." +"Types that are unrecognized by the scaffold generator will be of type " { $link null } ". The developer should change these to strings that describe the stack effect names instead." $nl +"Scaffolding a configuration file:" +{ $subsection scaffold-rc } +{ $subsection scaffold-factor-boot-rc } +{ $subsection scaffold-factor-rc } +{ $subsection scaffold-emacs } ; ABOUT: "tools.scaffold" From 50bf9228323d64f4391143d9bb68a3d48b126908 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 22 Feb 2009 12:35:18 -0600 Subject: [PATCH 23/85] Tweak annotations docs so that help-lint passes --- extra/annotations/annotations-docs.factor | 34 +++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/extra/annotations/annotations-docs.factor b/extra/annotations/annotations-docs.factor index bf8aef3a07..1bece9d4fb 100644 --- a/extra/annotations/annotations-docs.factor +++ b/extra/annotations/annotations-docs.factor @@ -1,6 +1,6 @@ USING: accessors arrays combinators definitions generalizations help help.markup help.topics kernel sequences sorting vocabs -words ; +words combinators.smart ; IN: annotations first [ "!" " your comment here" surround 1array $syntax ] [ [ "Treats the rest of the line after the exclamation point as a code annotation that can be looked up with the " \ $link ] dip comment-usage.-word 2array " word." 3array $description ] - [ ": foo ( x y z -- w )\n !" " --w-ó()ò-w-- kilroy was here\n + * ;" surround 1array $unchecked-example ] + [ ": foo ( x y z -- w )\n !" " --w-ó()ò-w-- kilroy was here\n + * ;" surround 1array $code ] tri ; +: <$annotation> ( word -- element ) + \ $annotation swap 2array 1array ; + : $annotation-usage. ( element -- ) first [ "Displays a list of words, help articles, and vocabularies that contain " \ $link ] dip comment-word 2array " annotations." 3array $description ; +: <$annotation-usage.> ( word -- element ) + \ $annotation-usage. swap 2array 1array ; + : $annotation-usage ( element -- ) - first - { "usages" sequence } $values - [ "Returns a list of words, help articles, and vocabularies that contain " \ $link ] dip [ comment-word 2array " annotations. For a more user-friendly display, use the " \ $link ] [ comment-usage.-word 2array " word." 6 narray ] bi 1array $description ; + first [ + [ "Returns a list of words, help articles, and vocabularies that contain " ] dip + [ + comment-word <$link> + " annotations. For a more user-friendly display, use the " + ] [ + comment-usage.-word <$link> + " word." + ] bi + ] output>array $description ; + +: <$annotation-usage> ( word -- element ) + [ { $values { "usages" sequence } } ] dip + \ $annotation-usage swap 2array + 2array ; "Code annotations" { @@ -42,9 +60,9 @@ annotation-tags natural-sort annotation-tags [ { - [ [ \ $annotation swap 2array 1array ] [ comment-word set-word-help ] bi ] - [ [ \ $annotation-usage swap 2array 1array ] [ comment-usage-word set-word-help ] bi ] - [ [ \ $annotation-usage. swap 2array 1array ] [ comment-usage.-word set-word-help ] bi ] + [ [ <$annotation> ] [ comment-word set-word-help ] bi ] + [ [ <$annotation-usage> ] [ comment-usage-word set-word-help ] bi ] + [ [ <$annotation-usage.> ] [ comment-usage.-word set-word-help ] bi ] [ [ comment-word ] [ comment-usage-word ] [ comment-usage.-word ] tri 3array related-words ] } cleave ] each From 90dac6f881726f68edf72b9a18901df2c148713d Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Sun, 22 Feb 2009 20:20:46 +0100 Subject: [PATCH 24/85] FUEL: C-uC-co won't ask for file creation while cycling. --- misc/fuel/factor-mode.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/misc/fuel/factor-mode.el b/misc/fuel/factor-mode.el index ba9be2edd3..b302fb6b8f 100644 --- a/misc/fuel/factor-mode.el +++ b/misc/fuel/factor-mode.el @@ -197,7 +197,7 @@ code in the buffer." (when (string-match factor-mode--cycle-basename-regex basename) (cons (match-string 1 basename) (match-string 2 basename)))) -(defun factor-mode--cycle-next (file) +(defun factor-mode--cycle-next (file skip) (let* ((dir (file-name-directory file)) (basename (file-name-nondirectory file)) (p/s (factor-mode--cycle-split basename)) @@ -211,7 +211,8 @@ code in the buffer." (let* ((suffix (ring-ref ring (+ i idx))) (path (expand-file-name (concat prefix suffix) dir))) (when (or (file-exists-p path) - (and (not (member suffix factor-mode--cycling-no-ask)) + (and (not skip) + (not (member suffix factor-mode--cycling-no-ask)) (y-or-n-p (format "Create %s? " path)))) (setq result path)) (when (and (not factor-mode-cycle-always-ask-p) @@ -224,10 +225,11 @@ code in the buffer." (defsubst factor-mode--cycling-setup () (setq factor-mode--cycling-no-ask nil)) -(defun factor-mode-visit-other-file (&optional file) - "Cycle between code, tests and docs factor files." - (interactive) - (let ((file (factor-mode--cycle-next (or file (buffer-file-name))))) +(defun factor-mode-visit-other-file (&optional skip) + "Cycle between code, tests and docs factor files. +With prefix, non-existing files will be skipped." + (interactive "P") + (let ((file (factor-mode--cycle-next (buffer-file-name) skip))) (unless file (error "No other file found")) (find-file file) (unless (file-exists-p file) From ff44ef224d7585efef9430b8cf8b73549d4ba8ef Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 17:13:18 -0600 Subject: [PATCH 25/85] add ?at, tests, documentation --- core/assocs/assocs-docs.factor | 7 ++++++- core/assocs/assocs-tests.factor | 5 ++++- core/assocs/assocs.factor | 7 +++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/core/assocs/assocs-docs.factor b/core/assocs/assocs-docs.factor index e5c43f3ed6..9576a41b7b 100755 --- a/core/assocs/assocs-docs.factor +++ b/core/assocs/assocs-docs.factor @@ -58,6 +58,7 @@ ARTICLE: "assocs-lookup" "Lookup and querying of assocs" "Utility operations built up from the " { $link "assocs-protocol" } ":" { $subsection key? } { $subsection at } +{ $subsection ?at } { $subsection assoc-empty? } { $subsection keys } { $subsection values } @@ -188,12 +189,16 @@ HELP: key? { $values { "key" object } { "assoc" assoc } { "?" "a boolean" } } { $description "Tests if an assoc contains a key." } ; -{ at at* key? } related-words +{ at at* key? ?at } related-words HELP: at { $values { "key" "an object" } { "assoc" assoc } { "value/f" "the value associated to the key, or " { $link f } " if the key is not present in the assoc" } } { $description "Looks up the value associated with a key. This word makes no distinction between a missing value and a value set to " { $link f } "; if the difference is important, use " { $link at* } "." } ; +HELP: ?at +{ $values { "key" "an object" } { "assoc" assoc } { "value/key" "the value associated to the key, or the key if the key is not present in the assoc" } { "?" "a boolean" } } +{ $description "Looks up the value associated with a key. If the key was not present, an error can be thrown without extra stack shuffling. This word handles assocs that store " { $link f } "." } ; + HELP: assoc-each { $values { "assoc" assoc } { "quot" { $quotation "( key value -- )" } } } { $description "Applies a quotation to each entry in the assoc." } diff --git a/core/assocs/assocs-tests.factor b/core/assocs/assocs-tests.factor index 5617888148..fc74df6d45 100644 --- a/core/assocs/assocs-tests.factor +++ b/core/assocs/assocs-tests.factor @@ -138,4 +138,7 @@ unit-test { "c" [ 3 ] } { "d" [ 4 ] } } [ nip first even? ] assoc-partition -] unit-test \ No newline at end of file +] unit-test + +[ 1 f ] [ 1 H{ } ?at ] unit-test +[ 2 t ] [ 1 H{ { 1 2 } } ?at ] unit-test diff --git a/core/assocs/assocs.factor b/core/assocs/assocs.factor index e46bb7abb6..fdaa02e6c4 100755 --- a/core/assocs/assocs.factor +++ b/core/assocs/assocs.factor @@ -19,6 +19,9 @@ GENERIC: >alist ( assoc -- newassoc ) M: assoc assoc-like drop ; +: ?at ( key assoc -- value/key ? ) + dupd at* [ [ nip ] [ drop ] if ] keep ; inline + at* drop ; inline : at-default ( key assoc -- value/key ) - 2dup at* [ 2nip ] [ 2drop ] if ; inline + ?at drop ; inline M: assoc assoc-clone-like ( assoc exemplar -- newassoc ) [ dup assoc-size ] dip new-assoc From 7a3c086178687d951b4e7233d1647fdde4bbadbd Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 17:14:46 -0600 Subject: [PATCH 26/85] remove ?at from db.types, images.tiff --- basis/db/types/types.factor | 3 --- basis/images/tiff/tiff.factor | 3 --- 2 files changed, 6 deletions(-) diff --git a/basis/db/types/types.factor b/basis/db/types/types.factor index e39a5977ef..30116e3fc5 100755 --- a/basis/db/types/types.factor +++ b/basis/db/types/types.factor @@ -124,9 +124,6 @@ FACTOR-BLOB NULL URL ; ! PostgreSQL Types: ! http://developer.postgresql.org/pgdocs/postgres/datatype.html -: ?at ( obj assoc -- value/obj ? ) - dupd at* [ [ nip ] [ drop ] if ] keep ; - ERROR: unknown-modifier modifier ; : lookup-modifier ( obj -- string ) diff --git a/basis/images/tiff/tiff.factor b/basis/images/tiff/tiff.factor index 02440deea5..a50ac0cad9 100755 --- a/basis/images/tiff/tiff.factor +++ b/basis/images/tiff/tiff.factor @@ -243,9 +243,6 @@ ERROR: bad-tiff-magic bytes ; ERROR: no-tag class ; -: ?at ( key assoc -- value/key ? ) - dupd at* [ nip t ] [ drop f ] if ; inline - : find-tag ( idf class -- tag ) swap processed-tags>> ?at [ no-tag ] unless ; From edbaba2322a1bddd9a25e457afe1be4d304fd39c Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 17:29:27 -0600 Subject: [PATCH 27/85] report the value not found in lzw --- basis/compression/lzw/lzw.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/compression/lzw/lzw.factor b/basis/compression/lzw/lzw.factor index 67248474d3..29cbe96d69 100644 --- a/basis/compression/lzw/lzw.factor +++ b/basis/compression/lzw/lzw.factor @@ -69,11 +69,11 @@ ERROR: index-too-big n ; : omega-k-in-table? ( lzw -- ? ) [ omega-k>> ] [ table>> ] bi key? ; -ERROR: not-in-table ; +ERROR: not-in-table value ; : write-output ( lzw -- ) [ - [ omega>> ] [ table>> ] bi at* [ not-in-table ] unless + [ omega>> ] [ table>> ] bi ?at [ not-in-table ] unless ] [ [ lzw-bit-width-compress ] [ output>> write-bits ] bi From d0030ba8995babe6964d967e900127f7ccbafda1 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 17:44:09 -0600 Subject: [PATCH 28/85] remove old io.serial --- extra/io/serial/authors.txt | 1 - extra/io/serial/serial.factor | 21 --- extra/io/serial/summary.txt | 1 - extra/io/serial/tags.txt | 1 - extra/io/serial/unix/bsd/bsd.factor | 86 ------------ extra/io/serial/unix/bsd/tags.txt | 1 - extra/io/serial/unix/linux/linux.factor | 130 ------------------ extra/io/serial/unix/linux/tags.txt | 1 - extra/io/serial/unix/tags.txt | 1 - extra/io/serial/unix/termios/bsd/bsd.factor | 19 --- extra/io/serial/unix/termios/bsd/tags.txt | 1 - .../io/serial/unix/termios/linux/linux.factor | 20 --- extra/io/serial/unix/termios/linux/tags.txt | 1 - extra/io/serial/unix/termios/tags.txt | 1 - extra/io/serial/unix/termios/termios.factor | 9 -- extra/io/serial/unix/unix-tests.factor | 21 --- extra/io/serial/unix/unix.factor | 62 --------- 17 files changed, 377 deletions(-) delete mode 100644 extra/io/serial/authors.txt delete mode 100644 extra/io/serial/serial.factor delete mode 100644 extra/io/serial/summary.txt delete mode 100644 extra/io/serial/tags.txt delete mode 100644 extra/io/serial/unix/bsd/bsd.factor delete mode 100644 extra/io/serial/unix/bsd/tags.txt delete mode 100644 extra/io/serial/unix/linux/linux.factor delete mode 100644 extra/io/serial/unix/linux/tags.txt delete mode 100644 extra/io/serial/unix/tags.txt delete mode 100644 extra/io/serial/unix/termios/bsd/bsd.factor delete mode 100644 extra/io/serial/unix/termios/bsd/tags.txt delete mode 100644 extra/io/serial/unix/termios/linux/linux.factor delete mode 100644 extra/io/serial/unix/termios/linux/tags.txt delete mode 100644 extra/io/serial/unix/termios/tags.txt delete mode 100644 extra/io/serial/unix/termios/termios.factor delete mode 100644 extra/io/serial/unix/unix-tests.factor delete mode 100644 extra/io/serial/unix/unix.factor diff --git a/extra/io/serial/authors.txt b/extra/io/serial/authors.txt deleted file mode 100644 index 7c1b2f2279..0000000000 --- a/extra/io/serial/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Doug Coleman diff --git a/extra/io/serial/serial.factor b/extra/io/serial/serial.factor deleted file mode 100644 index bcea984579..0000000000 --- a/extra/io/serial/serial.factor +++ /dev/null @@ -1,21 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types assocs combinators destructors -kernel math math.bitwise math.parser sequences summary system -vocabs.loader ; -IN: io.serial - -TUPLE: serial stream path baud - termios iflag oflag cflag lflag ; - -ERROR: invalid-baud baud ; -M: invalid-baud summary ( invalid-baud -- string ) - baud>> number>string - "Baud rate " " not supported" surround ; - -HOOK: lookup-baud os ( m -- n ) -HOOK: open-serial os ( serial -- stream ) - -{ - { [ os unix? ] [ "io.serial.unix" ] } -} cond require diff --git a/extra/io/serial/summary.txt b/extra/io/serial/summary.txt deleted file mode 100644 index 5ccd99dbaa..0000000000 --- a/extra/io/serial/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Serial port library diff --git a/extra/io/serial/tags.txt b/extra/io/serial/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/extra/io/serial/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/extra/io/serial/unix/bsd/bsd.factor b/extra/io/serial/unix/bsd/bsd.factor deleted file mode 100644 index b684190698..0000000000 --- a/extra/io/serial/unix/bsd/bsd.factor +++ /dev/null @@ -1,86 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax kernel math.bitwise sequences system io.serial ; -IN: io.serial.unix - -M: bsd lookup-baud ( m -- n ) - dup { - 0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 - 7200 9600 14400 19200 28800 38400 57600 76800 115200 - 230400 460800 921600 - } member? [ invalid-baud ] unless ; - -: TCSANOW 0 ; inline -: TCSADRAIN 1 ; inline -: TCSAFLUSH 2 ; inline -: TCSASOFT HEX: 10 ; inline - -: TCIFLUSH 1 ; inline -: TCOFLUSH 2 ; inline -: TCIOFLUSH 3 ; inline -: TCOOFF 1 ; inline -: TCOON 2 ; inline -: TCIOFF 3 ; inline -: TCION 4 ; inline - -! iflags -: IGNBRK HEX: 00000001 ; inline -: BRKINT HEX: 00000002 ; inline -: IGNPAR HEX: 00000004 ; inline -: PARMRK HEX: 00000008 ; inline -: INPCK HEX: 00000010 ; inline -: ISTRIP HEX: 00000020 ; inline -: INLCR HEX: 00000040 ; inline -: IGNCR HEX: 00000080 ; inline -: ICRNL HEX: 00000100 ; inline -: IXON HEX: 00000200 ; inline -: IXOFF HEX: 00000400 ; inline -: IXANY HEX: 00000800 ; inline -: IMAXBEL HEX: 00002000 ; inline -: IUTF8 HEX: 00004000 ; inline - -! oflags -: OPOST HEX: 00000001 ; inline -: ONLCR HEX: 00000002 ; inline -: OXTABS HEX: 00000004 ; inline -: ONOEOT HEX: 00000008 ; inline - -! cflags -: CIGNORE HEX: 00000001 ; inline -: CSIZE HEX: 00000300 ; inline -: CS5 HEX: 00000000 ; inline -: CS6 HEX: 00000100 ; inline -: CS7 HEX: 00000200 ; inline -: CS8 HEX: 00000300 ; inline -: CSTOPB HEX: 00000400 ; inline -: CREAD HEX: 00000800 ; inline -: PARENB HEX: 00001000 ; inline -: PARODD HEX: 00002000 ; inline -: HUPCL HEX: 00004000 ; inline -: CLOCAL HEX: 00008000 ; inline -: CCTS_OFLOW HEX: 00010000 ; inline -: CRTS_IFLOW HEX: 00020000 ; inline -: CRTSCTS { CCTS_OFLOW CRTS_IFLOW } flags ; inline -: CDTR_IFLOW HEX: 00040000 ; inline -: CDSR_OFLOW HEX: 00080000 ; inline -: CCAR_OFLOW HEX: 00100000 ; inline -: MDMBUF HEX: 00100000 ; inline - -! lflags -: ECHOKE HEX: 00000001 ; inline -: ECHOE HEX: 00000002 ; inline -: ECHOK HEX: 00000004 ; inline -: ECHO HEX: 00000008 ; inline -: ECHONL HEX: 00000010 ; inline -: ECHOPRT HEX: 00000020 ; inline -: ECHOCTL HEX: 00000040 ; inline -: ISIG HEX: 00000080 ; inline -: ICANON HEX: 00000100 ; inline -: ALTWERASE HEX: 00000200 ; inline -: IEXTEN HEX: 00000400 ; inline -: EXTPROC HEX: 00000800 ; inline -: TOSTOP HEX: 00400000 ; inline -: FLUSHO HEX: 00800000 ; inline -: NOKERNINFO HEX: 02000000 ; inline -: PENDIN HEX: 20000000 ; inline -: NOFLSH HEX: 80000000 ; inline diff --git a/extra/io/serial/unix/bsd/tags.txt b/extra/io/serial/unix/bsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/extra/io/serial/unix/bsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/extra/io/serial/unix/linux/linux.factor b/extra/io/serial/unix/linux/linux.factor deleted file mode 100644 index 342ff4499f..0000000000 --- a/extra/io/serial/unix/linux/linux.factor +++ /dev/null @@ -1,130 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: assocs alien.syntax kernel io.serial system unix ; -IN: io.serial.unix - -: TCSANOW 0 ; inline -: TCSADRAIN 1 ; inline -: TCSAFLUSH 2 ; inline - -: TCIFLUSH 0 ; inline -: TCOFLUSH 1 ; inline -: TCIOFLUSH 2 ; inline - -: TCOOFF 0 ; inline -: TCOON 1 ; inline -: TCIOFF 2 ; inline -: TCION 3 ; inline - -! iflag -: IGNBRK OCT: 0000001 ; inline -: BRKINT OCT: 0000002 ; inline -: IGNPAR OCT: 0000004 ; inline -: PARMRK OCT: 0000010 ; inline -: INPCK OCT: 0000020 ; inline -: ISTRIP OCT: 0000040 ; inline -: INLCR OCT: 0000100 ; inline -: IGNCR OCT: 0000200 ; inline -: ICRNL OCT: 0000400 ; inline -: IUCLC OCT: 0001000 ; inline -: IXON OCT: 0002000 ; inline -: IXANY OCT: 0004000 ; inline -: IXOFF OCT: 0010000 ; inline -: IMAXBEL OCT: 0020000 ; inline -: IUTF8 OCT: 0040000 ; inline - -! oflag -: OPOST OCT: 0000001 ; inline -: OLCUC OCT: 0000002 ; inline -: ONLCR OCT: 0000004 ; inline -: OCRNL OCT: 0000010 ; inline -: ONOCR OCT: 0000020 ; inline -: ONLRET OCT: 0000040 ; inline -: OFILL OCT: 0000100 ; inline -: OFDEL OCT: 0000200 ; inline -: NLDLY OCT: 0000400 ; inline -: NL0 OCT: 0000000 ; inline -: NL1 OCT: 0000400 ; inline -: CRDLY OCT: 0003000 ; inline -: CR0 OCT: 0000000 ; inline -: CR1 OCT: 0001000 ; inline -: CR2 OCT: 0002000 ; inline -: CR3 OCT: 0003000 ; inline -: TABDLY OCT: 0014000 ; inline -: TAB0 OCT: 0000000 ; inline -: TAB1 OCT: 0004000 ; inline -: TAB2 OCT: 0010000 ; inline -: TAB3 OCT: 0014000 ; inline -: BSDLY OCT: 0020000 ; inline -: BS0 OCT: 0000000 ; inline -: BS1 OCT: 0020000 ; inline -: FFDLY OCT: 0100000 ; inline -: FF0 OCT: 0000000 ; inline -: FF1 OCT: 0100000 ; inline - -! cflags -: CSIZE OCT: 0000060 ; inline -: CS5 OCT: 0000000 ; inline -: CS6 OCT: 0000020 ; inline -: CS7 OCT: 0000040 ; inline -: CS8 OCT: 0000060 ; inline -: CSTOPB OCT: 0000100 ; inline -: CREAD OCT: 0000200 ; inline -: PARENB OCT: 0000400 ; inline -: PARODD OCT: 0001000 ; inline -: HUPCL OCT: 0002000 ; inline -: CLOCAL OCT: 0004000 ; inline -: CIBAUD OCT: 002003600000 ; inline -: CRTSCTS OCT: 020000000000 ; inline - -! lflags -: ISIG OCT: 0000001 ; inline -: ICANON OCT: 0000002 ; inline -: XCASE OCT: 0000004 ; inline -: ECHO OCT: 0000010 ; inline -: ECHOE OCT: 0000020 ; inline -: ECHOK OCT: 0000040 ; inline -: ECHONL OCT: 0000100 ; inline -: NOFLSH OCT: 0000200 ; inline -: TOSTOP OCT: 0000400 ; inline -: ECHOCTL OCT: 0001000 ; inline -: ECHOPRT OCT: 0002000 ; inline -: ECHOKE OCT: 0004000 ; inline -: FLUSHO OCT: 0010000 ; inline -: PENDIN OCT: 0040000 ; inline -: IEXTEN OCT: 0100000 ; inline - -M: linux lookup-baud ( n -- n ) - dup H{ - { 0 OCT: 0000000 } - { 50 OCT: 0000001 } - { 75 OCT: 0000002 } - { 110 OCT: 0000003 } - { 134 OCT: 0000004 } - { 150 OCT: 0000005 } - { 200 OCT: 0000006 } - { 300 OCT: 0000007 } - { 600 OCT: 0000010 } - { 1200 OCT: 0000011 } - { 1800 OCT: 0000012 } - { 2400 OCT: 0000013 } - { 4800 OCT: 0000014 } - { 9600 OCT: 0000015 } - { 19200 OCT: 0000016 } - { 38400 OCT: 0000017 } - { 57600 OCT: 0010001 } - { 115200 OCT: 0010002 } - { 230400 OCT: 0010003 } - { 460800 OCT: 0010004 } - { 500000 OCT: 0010005 } - { 576000 OCT: 0010006 } - { 921600 OCT: 0010007 } - { 1000000 OCT: 0010010 } - { 1152000 OCT: 0010011 } - { 1500000 OCT: 0010012 } - { 2000000 OCT: 0010013 } - { 2500000 OCT: 0010014 } - { 3000000 OCT: 0010015 } - { 3500000 OCT: 0010016 } - { 4000000 OCT: 0010017 } - } at* [ nip ] [ drop invalid-baud ] if ; diff --git a/extra/io/serial/unix/linux/tags.txt b/extra/io/serial/unix/linux/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/extra/io/serial/unix/linux/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/extra/io/serial/unix/tags.txt b/extra/io/serial/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/extra/io/serial/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/extra/io/serial/unix/termios/bsd/bsd.factor b/extra/io/serial/unix/termios/bsd/bsd.factor deleted file mode 100644 index 414ec98438..0000000000 --- a/extra/io/serial/unix/termios/bsd/bsd.factor +++ /dev/null @@ -1,19 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax kernel sequences system ; -IN: io.serial.unix.termios - -: NCCS 20 ; inline - -TYPEDEF: uint tcflag_t -TYPEDEF: uchar cc_t -TYPEDEF: uint speed_t - -C-STRUCT: termios - { "tcflag_t" "iflag" } ! input mode flags - { "tcflag_t" "oflag" } ! output mode flags - { "tcflag_t" "cflag" } ! control mode flags - { "tcflag_t" "lflag" } ! local mode flags - { { "cc_t" NCCS } "cc" } ! control characters - { "speed_t" "ispeed" } ! input speed - { "speed_t" "ospeed" } ; ! output speed diff --git a/extra/io/serial/unix/termios/bsd/tags.txt b/extra/io/serial/unix/termios/bsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/extra/io/serial/unix/termios/bsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/extra/io/serial/unix/termios/linux/linux.factor b/extra/io/serial/unix/termios/linux/linux.factor deleted file mode 100644 index c7da10a6f5..0000000000 --- a/extra/io/serial/unix/termios/linux/linux.factor +++ /dev/null @@ -1,20 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax kernel system unix ; -IN: io.serial.unix.termios - -: NCCS 32 ; inline - -TYPEDEF: uchar cc_t -TYPEDEF: uint speed_t -TYPEDEF: uint tcflag_t - -C-STRUCT: termios - { "tcflag_t" "iflag" } ! input mode flags - { "tcflag_t" "oflag" } ! output mode flags - { "tcflag_t" "cflag" } ! control mode flags - { "tcflag_t" "lflag" } ! local mode flags - { "cc_t" "line" } ! line discipline - { { "cc_t" NCCS } "cc" } ! control characters - { "speed_t" "ispeed" } ! input speed - { "speed_t" "ospeed" } ; ! output speed diff --git a/extra/io/serial/unix/termios/linux/tags.txt b/extra/io/serial/unix/termios/linux/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/extra/io/serial/unix/termios/linux/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/extra/io/serial/unix/termios/tags.txt b/extra/io/serial/unix/termios/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/extra/io/serial/unix/termios/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/extra/io/serial/unix/termios/termios.factor b/extra/io/serial/unix/termios/termios.factor deleted file mode 100644 index e5ccd37e87..0000000000 --- a/extra/io/serial/unix/termios/termios.factor +++ /dev/null @@ -1,9 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: combinators system vocabs.loader ; -IN: io.serial.unix.termios - -{ - { [ os linux? ] [ "io.serial.unix.termios.linux" ] } - { [ os bsd? ] [ "io.serial.unix.termios.bsd" ] } -} cond require diff --git a/extra/io/serial/unix/unix-tests.factor b/extra/io/serial/unix/unix-tests.factor deleted file mode 100644 index 6dd056feb5..0000000000 --- a/extra/io/serial/unix/unix-tests.factor +++ /dev/null @@ -1,21 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel math.bitwise serial serial.unix ; -IN: io.serial.unix - -: serial-obj ( -- obj ) - serial new - "/dev/ttyS0" >>path - 19200 >>baud - { IGNPAR ICRNL } flags >>iflag - { } flags >>oflag - { CS8 CLOCAL CREAD } flags >>cflag - { ICANON } flags >>lflag ; - -: serial-test ( -- serial ) - serial-obj - open-serial - dup get-termios >>termios - dup configure-termios - dup tciflush - dup apply-termios ; diff --git a/extra/io/serial/unix/unix.factor b/extra/io/serial/unix/unix.factor deleted file mode 100644 index 1da6385f96..0000000000 --- a/extra/io/serial/unix/unix.factor +++ /dev/null @@ -1,62 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types alien.syntax combinators io.ports -io.streams.duplex io.unix.backend system kernel math math.bitwise -vocabs.loader unix io.serial io.serial.unix.termios ; -IN: io.serial.unix - -<< { - { [ os linux? ] [ "io.serial.unix.linux" ] } - { [ os bsd? ] [ "io.serial.unix.bsd" ] } -} cond require >> - -FUNCTION: speed_t cfgetispeed ( termios* t ) ; -FUNCTION: speed_t cfgetospeed ( termios* t ) ; -FUNCTION: int cfsetispeed ( termios* t, speed_t s ) ; -FUNCTION: int cfsetospeed ( termios* t, speed_t s ) ; -FUNCTION: int tcgetattr ( int i1, termios* t ) ; -FUNCTION: int tcsetattr ( int i1, int i2, termios* t ) ; -FUNCTION: int tcdrain ( int i1 ) ; -FUNCTION: int tcflow ( int i1, int i2 ) ; -FUNCTION: int tcflush ( int i1, int i2 ) ; -FUNCTION: int tcsendbreak ( int i1, int i2 ) ; -FUNCTION: void cfmakeraw ( termios* t ) ; -FUNCTION: int cfsetspeed ( termios* t, speed_t s ) ; - -: fd>duplex-stream ( fd -- duplex-stream ) - init-fd - [ ] [ ] bi ; - -: open-rw ( path -- fd ) O_RDWR file-mode open-file ; -: ( path -- stream ) open-rw fd>duplex-stream ; - -M: unix open-serial ( serial -- serial' ) - path>> { O_RDWR O_NOCTTY O_NDELAY } flags file-mode open-file - fd>duplex-stream ; - -: serial-fd ( serial -- fd ) - stream>> in>> handle>> fd>> ; - -: get-termios ( serial -- termios ) - serial-fd - "termios" [ tcgetattr io-error ] keep ; - -: configure-termios ( serial -- ) - dup termios>> - { - [ [ iflag>> ] dip over [ set-termios-iflag ] [ 2drop ] if ] - [ [ oflag>> ] dip over [ set-termios-oflag ] [ 2drop ] if ] - [ - [ - [ cflag>> 0 or ] [ baud>> lookup-baud ] bi bitor - ] dip set-termios-cflag - ] - [ [ lflag>> ] dip over [ set-termios-lflag ] [ 2drop ] if ] - } 2cleave ; - -: tciflush ( serial -- ) - serial-fd TCIFLUSH tcflush io-error ; - -: apply-termios ( serial -- ) - [ serial-fd TCSANOW ] - [ termios>> ] bi tcsetattr io-error ; From 0ccb04e50f4ab92375b97f6bfc5c692444112c3b Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 17:45:04 -0600 Subject: [PATCH 29/85] use CONSTANT: in lots of places --- extra/serial/unix/bsd/bsd.factor | 130 +++++++-------- extra/serial/unix/linux/linux.factor | 162 +++++++++---------- extra/serial/unix/termios/bsd/bsd.factor | 2 +- extra/serial/unix/termios/linux/linux.factor | 2 +- extra/serial/unix/unix.factor | 4 +- 5 files changed, 150 insertions(+), 150 deletions(-) diff --git a/extra/serial/unix/bsd/bsd.factor b/extra/serial/unix/bsd/bsd.factor index d31d947dcb..22886ecb15 100644 --- a/extra/serial/unix/bsd/bsd.factor +++ b/extra/serial/unix/bsd/bsd.factor @@ -10,77 +10,77 @@ M: bsd lookup-baud ( m -- n ) 230400 460800 921600 } member? [ invalid-baud ] unless ; -: TCSANOW 0 ; inline -: TCSADRAIN 1 ; inline -: TCSAFLUSH 2 ; inline -: TCSASOFT HEX: 10 ; inline +CONSTANT: TCSANOW 0 +CONSTANT: TCSADRAIN 1 +CONSTANT: TCSAFLUSH 2 +CONSTANT: TCSASOFT HEX: 10 -: TCIFLUSH 1 ; inline -: TCOFLUSH 2 ; inline -: TCIOFLUSH 3 ; inline -: TCOOFF 1 ; inline -: TCOON 2 ; inline -: TCIOFF 3 ; inline -: TCION 4 ; inline +CONSTANT: TCIFLUSH 1 +CONSTANT: TCOFLUSH 2 +CONSTANT: TCIOFLUSH 3 +CONSTANT: TCOOFF 1 +CONSTANT: TCOON 2 +CONSTANT: TCIOFF 3 +CONSTANT: TCION 4 ! iflags -: IGNBRK HEX: 00000001 ; inline -: BRKINT HEX: 00000002 ; inline -: IGNPAR HEX: 00000004 ; inline -: PARMRK HEX: 00000008 ; inline -: INPCK HEX: 00000010 ; inline -: ISTRIP HEX: 00000020 ; inline -: INLCR HEX: 00000040 ; inline -: IGNCR HEX: 00000080 ; inline -: ICRNL HEX: 00000100 ; inline -: IXON HEX: 00000200 ; inline -: IXOFF HEX: 00000400 ; inline -: IXANY HEX: 00000800 ; inline -: IMAXBEL HEX: 00002000 ; inline -: IUTF8 HEX: 00004000 ; inline +CONSTANT: IGNBRK HEX: 00000001 +CONSTANT: BRKINT HEX: 00000002 +CONSTANT: IGNPAR HEX: 00000004 +CONSTANT: PARMRK HEX: 00000008 +CONSTANT: INPCK HEX: 00000010 +CONSTANT: ISTRIP HEX: 00000020 +CONSTANT: INLCR HEX: 00000040 +CONSTANT: IGNCR HEX: 00000080 +CONSTANT: ICRNL HEX: 00000100 +CONSTANT: IXON HEX: 00000200 +CONSTANT: IXOFF HEX: 00000400 +CONSTANT: IXANY HEX: 00000800 +CONSTANT: IMAXBEL HEX: 00002000 +CONSTANT: IUTF8 HEX: 00004000 ! oflags -: OPOST HEX: 00000001 ; inline -: ONLCR HEX: 00000002 ; inline -: OXTABS HEX: 00000004 ; inline -: ONOEOT HEX: 00000008 ; inline +CONSTANT: OPOST HEX: 00000001 +CONSTANT: ONLCR HEX: 00000002 +CONSTANT: OXTABS HEX: 00000004 +CONSTANT: ONOEOT HEX: 00000008 ! cflags -: CIGNORE HEX: 00000001 ; inline -: CSIZE HEX: 00000300 ; inline -: CS5 HEX: 00000000 ; inline -: CS6 HEX: 00000100 ; inline -: CS7 HEX: 00000200 ; inline -: CS8 HEX: 00000300 ; inline -: CSTOPB HEX: 00000400 ; inline -: CREAD HEX: 00000800 ; inline -: PARENB HEX: 00001000 ; inline -: PARODD HEX: 00002000 ; inline -: HUPCL HEX: 00004000 ; inline -: CLOCAL HEX: 00008000 ; inline -: CCTS_OFLOW HEX: 00010000 ; inline -: CRTS_IFLOW HEX: 00020000 ; inline -: CRTSCTS { CCTS_OFLOW CRTS_IFLOW } flags ; inline -: CDTR_IFLOW HEX: 00040000 ; inline -: CDSR_OFLOW HEX: 00080000 ; inline -: CCAR_OFLOW HEX: 00100000 ; inline -: MDMBUF HEX: 00100000 ; inline +CONSTANT: CIGNORE HEX: 00000001 +CONSTANT: CSIZE HEX: 00000300 +CONSTANT: CS5 HEX: 00000000 +CONSTANT: CS6 HEX: 00000100 +CONSTANT: CS7 HEX: 00000200 +CONSTANT: CS8 HEX: 00000300 +CONSTANT: CSTOPB HEX: 00000400 +CONSTANT: CREAD HEX: 00000800 +CONSTANT: PARENB HEX: 00001000 +CONSTANT: PARODD HEX: 00002000 +CONSTANT: HUPCL HEX: 00004000 +CONSTANT: CLOCAL HEX: 00008000 +CONSTANT: CCTS_OFLOW HEX: 00010000 +CONSTANT: CRTS_IFLOW HEX: 00020000 +: CRTSCTS ( -- n ) { CCTS_OFLOW CRTS_IFLOW } flags ; inline +CONSTANT: CDTR_IFLOW HEX: 00040000 +CONSTANT: CDSR_OFLOW HEX: 00080000 +CONSTANT: CCAR_OFLOW HEX: 00100000 +CONSTANT: MDMBUF HEX: 00100000 ! lflags -: ECHOKE HEX: 00000001 ; inline -: ECHOE HEX: 00000002 ; inline -: ECHOK HEX: 00000004 ; inline -: ECHO HEX: 00000008 ; inline -: ECHONL HEX: 00000010 ; inline -: ECHOPRT HEX: 00000020 ; inline -: ECHOCTL HEX: 00000040 ; inline -: ISIG HEX: 00000080 ; inline -: ICANON HEX: 00000100 ; inline -: ALTWERASE HEX: 00000200 ; inline -: IEXTEN HEX: 00000400 ; inline -: EXTPROC HEX: 00000800 ; inline -: TOSTOP HEX: 00400000 ; inline -: FLUSHO HEX: 00800000 ; inline -: NOKERNINFO HEX: 02000000 ; inline -: PENDIN HEX: 20000000 ; inline -: NOFLSH HEX: 80000000 ; inline +CONSTANT: ECHOKE HEX: 00000001 +CONSTANT: ECHOE HEX: 00000002 +CONSTANT: ECHOK HEX: 00000004 +CONSTANT: ECHO HEX: 00000008 +CONSTANT: ECHONL HEX: 00000010 +CONSTANT: ECHOPRT HEX: 00000020 +CONSTANT: ECHOCTL HEX: 00000040 +CONSTANT: ISIG HEX: 00000080 +CONSTANT: ICANON HEX: 00000100 +CONSTANT: ALTWERASE HEX: 00000200 +CONSTANT: IEXTEN HEX: 00000400 +CONSTANT: EXTPROC HEX: 00000800 +CONSTANT: TOSTOP HEX: 00400000 +CONSTANT: FLUSHO HEX: 00800000 +CONSTANT: NOKERNINFO HEX: 02000000 +CONSTANT: PENDIN HEX: 20000000 +CONSTANT: NOFLSH HEX: 80000000 diff --git a/extra/serial/unix/linux/linux.factor b/extra/serial/unix/linux/linux.factor index 3ad5088fc8..9511ec45bf 100644 --- a/extra/serial/unix/linux/linux.factor +++ b/extra/serial/unix/linux/linux.factor @@ -3,96 +3,96 @@ USING: assocs alien.syntax kernel serial system unix ; IN: serial.unix -: TCSANOW 0 ; inline -: TCSADRAIN 1 ; inline -: TCSAFLUSH 2 ; inline +CONSTANT: TCSANOW 0 +CONSTANT: TCSADRAIN 1 +CONSTANT: TCSAFLUSH 2 -: TCIFLUSH 0 ; inline -: TCOFLUSH 1 ; inline -: TCIOFLUSH 2 ; inline +CONSTANT: TCIFLUSH 0 +CONSTANT: TCOFLUSH 1 +CONSTANT: TCIOFLUSH 2 -: TCOOFF 0 ; inline -: TCOON 1 ; inline -: TCIOFF 2 ; inline -: TCION 3 ; inline +CONSTANT: TCOOFF 0 +CONSTANT: TCOON 1 +CONSTANT: TCIOFF 2 +CONSTANT: TCION 3 ! iflag -: IGNBRK OCT: 0000001 ; inline -: BRKINT OCT: 0000002 ; inline -: IGNPAR OCT: 0000004 ; inline -: PARMRK OCT: 0000010 ; inline -: INPCK OCT: 0000020 ; inline -: ISTRIP OCT: 0000040 ; inline -: INLCR OCT: 0000100 ; inline -: IGNCR OCT: 0000200 ; inline -: ICRNL OCT: 0000400 ; inline -: IUCLC OCT: 0001000 ; inline -: IXON OCT: 0002000 ; inline -: IXANY OCT: 0004000 ; inline -: IXOFF OCT: 0010000 ; inline -: IMAXBEL OCT: 0020000 ; inline -: IUTF8 OCT: 0040000 ; inline +CONSTANT: IGNBRK OCT: 0000001 +CONSTANT: BRKINT OCT: 0000002 +CONSTANT: IGNPAR OCT: 0000004 +CONSTANT: PARMRK OCT: 0000010 +CONSTANT: INPCK OCT: 0000020 +CONSTANT: ISTRIP OCT: 0000040 +CONSTANT: INLCR OCT: 0000100 +CONSTANT: IGNCR OCT: 0000200 +CONSTANT: ICRNL OCT: 0000400 +CONSTANT: IUCLC OCT: 0001000 +CONSTANT: IXON OCT: 0002000 +CONSTANT: IXANY OCT: 0004000 +CONSTANT: IXOFF OCT: 0010000 +CONSTANT: IMAXBEL OCT: 0020000 +CONSTANT: IUTF8 OCT: 0040000 ! oflag -: OPOST OCT: 0000001 ; inline -: OLCUC OCT: 0000002 ; inline -: ONLCR OCT: 0000004 ; inline -: OCRNL OCT: 0000010 ; inline -: ONOCR OCT: 0000020 ; inline -: ONLRET OCT: 0000040 ; inline -: OFILL OCT: 0000100 ; inline -: OFDEL OCT: 0000200 ; inline -: NLDLY OCT: 0000400 ; inline -: NL0 OCT: 0000000 ; inline -: NL1 OCT: 0000400 ; inline -: CRDLY OCT: 0003000 ; inline -: CR0 OCT: 0000000 ; inline -: CR1 OCT: 0001000 ; inline -: CR2 OCT: 0002000 ; inline -: CR3 OCT: 0003000 ; inline -: TABDLY OCT: 0014000 ; inline -: TAB0 OCT: 0000000 ; inline -: TAB1 OCT: 0004000 ; inline -: TAB2 OCT: 0010000 ; inline -: TAB3 OCT: 0014000 ; inline -: BSDLY OCT: 0020000 ; inline -: BS0 OCT: 0000000 ; inline -: BS1 OCT: 0020000 ; inline -: FFDLY OCT: 0100000 ; inline -: FF0 OCT: 0000000 ; inline -: FF1 OCT: 0100000 ; inline +CONSTANT: OPOST OCT: 0000001 +CONSTANT: OLCUC OCT: 0000002 +CONSTANT: ONLCR OCT: 0000004 +CONSTANT: OCRNL OCT: 0000010 +CONSTANT: ONOCR OCT: 0000020 +CONSTANT: ONLRET OCT: 0000040 +CONSTANT: OFILL OCT: 0000100 +CONSTANT: OFDEL OCT: 0000200 +CONSTANT: NLDLY OCT: 0000400 +CONSTANT: NL0 OCT: 0000000 +CONSTANT: NL1 OCT: 0000400 +CONSTANT: CRDLY OCT: 0003000 +CONSTANT: CR0 OCT: 0000000 +CONSTANT: CR1 OCT: 0001000 +CONSTANT: CR2 OCT: 0002000 +CONSTANT: CR3 OCT: 0003000 +CONSTANT: TABDLY OCT: 0014000 +CONSTANT: TAB0 OCT: 0000000 +CONSTANT: TAB1 OCT: 0004000 +CONSTANT: TAB2 OCT: 0010000 +CONSTANT: TAB3 OCT: 0014000 +CONSTANT: BSDLY OCT: 0020000 +CONSTANT: BS0 OCT: 0000000 +CONSTANT: BS1 OCT: 0020000 +CONSTANT: FFDLY OCT: 0100000 +CONSTANT: FF0 OCT: 0000000 +CONSTANT: FF1 OCT: 0100000 ! cflags -: CSIZE OCT: 0000060 ; inline -: CS5 OCT: 0000000 ; inline -: CS6 OCT: 0000020 ; inline -: CS7 OCT: 0000040 ; inline -: CS8 OCT: 0000060 ; inline -: CSTOPB OCT: 0000100 ; inline -: CREAD OCT: 0000200 ; inline -: PARENB OCT: 0000400 ; inline -: PARODD OCT: 0001000 ; inline -: HUPCL OCT: 0002000 ; inline -: CLOCAL OCT: 0004000 ; inline -: CIBAUD OCT: 002003600000 ; inline -: CRTSCTS OCT: 020000000000 ; inline +CONSTANT: CSIZE OCT: 0000060 +CONSTANT: CS5 OCT: 0000000 +CONSTANT: CS6 OCT: 0000020 +CONSTANT: CS7 OCT: 0000040 +CONSTANT: CS8 OCT: 0000060 +CONSTANT: CSTOPB OCT: 0000100 +CONSTANT: CREAD OCT: 0000200 +CONSTANT: PARENB OCT: 0000400 +CONSTANT: PARODD OCT: 0001000 +CONSTANT: HUPCL OCT: 0002000 +CONSTANT: CLOCAL OCT: 0004000 +CONSTANT: CIBAUD OCT: 002003600000 +CONSTANT: CRTSCTS OCT: 020000000000 ! lflags -: ISIG OCT: 0000001 ; inline -: ICANON OCT: 0000002 ; inline -: XCASE OCT: 0000004 ; inline -: ECHO OCT: 0000010 ; inline -: ECHOE OCT: 0000020 ; inline -: ECHOK OCT: 0000040 ; inline -: ECHONL OCT: 0000100 ; inline -: NOFLSH OCT: 0000200 ; inline -: TOSTOP OCT: 0000400 ; inline -: ECHOCTL OCT: 0001000 ; inline -: ECHOPRT OCT: 0002000 ; inline -: ECHOKE OCT: 0004000 ; inline -: FLUSHO OCT: 0010000 ; inline -: PENDIN OCT: 0040000 ; inline -: IEXTEN OCT: 0100000 ; inline +CONSTANT: ISIG OCT: 0000001 +CONSTANT: ICANON OCT: 0000002 +CONSTANT: XCASE OCT: 0000004 +CONSTANT: ECHO OCT: 0000010 +CONSTANT: ECHOE OCT: 0000020 +CONSTANT: ECHOK OCT: 0000040 +CONSTANT: ECHONL OCT: 0000100 +CONSTANT: NOFLSH OCT: 0000200 +CONSTANT: TOSTOP OCT: 0000400 +CONSTANT: ECHOCTL OCT: 0001000 +CONSTANT: ECHOPRT OCT: 0002000 +CONSTANT: ECHOKE OCT: 0004000 +CONSTANT: FLUSHO OCT: 0010000 +CONSTANT: PENDIN OCT: 0040000 +CONSTANT: IEXTEN OCT: 0100000 M: linux lookup-baud ( n -- n ) dup H{ @@ -127,4 +127,4 @@ M: linux lookup-baud ( n -- n ) { 3000000 OCT: 0010015 } { 3500000 OCT: 0010016 } { 4000000 OCT: 0010017 } - } at* [ nip ] [ drop invalid-baud ] if ; + } ?at [ invalid-baud ] unless ; diff --git a/extra/serial/unix/termios/bsd/bsd.factor b/extra/serial/unix/termios/bsd/bsd.factor index 5fbc571519..87414089cc 100644 --- a/extra/serial/unix/termios/bsd/bsd.factor +++ b/extra/serial/unix/termios/bsd/bsd.factor @@ -3,7 +3,7 @@ USING: alien.syntax kernel sequences system ; IN: serial.unix.termios -: NCCS 20 ; inline +CONSTANT: NCCS 20 TYPEDEF: uint tcflag_t TYPEDEF: uchar cc_t diff --git a/extra/serial/unix/termios/linux/linux.factor b/extra/serial/unix/termios/linux/linux.factor index de9906e2b9..41df31db09 100644 --- a/extra/serial/unix/termios/linux/linux.factor +++ b/extra/serial/unix/termios/linux/linux.factor @@ -3,7 +3,7 @@ USING: alien.syntax kernel system unix ; IN: serial.unix.termios -: NCCS 32 ; inline +CONSTANT: NCCS 32 TYPEDEF: uchar cc_t TYPEDEF: uint speed_t diff --git a/extra/serial/unix/unix.factor b/extra/serial/unix/unix.factor index 90dbd185bd..ee320b0d2e 100644 --- a/extra/serial/unix/unix.factor +++ b/extra/serial/unix/unix.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.syntax combinators io.ports -io.streams.duplex io.unix.backend system kernel math math.bitwise -vocabs.loader unix serial serial.unix.termios ; +io.streams.duplex system kernel math math.bitwise +vocabs.loader unix serial serial.unix.termios io.backend.unix ; IN: serial.unix << { From 378c8f90ffd3367c9ad608a76e06d12302357fab Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 17:50:29 -0600 Subject: [PATCH 30/85] move serial to io.serial --- extra/{ => io}/serial/authors.txt | 0 extra/{ => io}/serial/serial.factor | 11 +++++------ extra/{ => io}/serial/summary.txt | 0 extra/{ => io}/serial/tags.txt | 0 extra/{ => io}/serial/unix/bsd/bsd.factor | 4 ++-- extra/{ => io}/serial/unix/bsd/tags.txt | 0 extra/{ => io}/serial/unix/linux/linux.factor | 4 ++-- extra/{ => io}/serial/unix/linux/tags.txt | 0 extra/{ => io}/serial/unix/tags.txt | 0 extra/{ => io}/serial/unix/termios/bsd/bsd.factor | 2 +- extra/{ => io}/serial/unix/termios/bsd/tags.txt | 0 extra/{ => io}/serial/unix/termios/linux/linux.factor | 2 +- extra/{ => io}/serial/unix/termios/linux/tags.txt | 0 extra/{ => io}/serial/unix/termios/tags.txt | 0 extra/{ => io}/serial/unix/termios/termios.factor | 6 +++--- extra/{ => io}/serial/unix/unix-tests.factor | 4 ++-- extra/{ => io}/serial/unix/unix.factor | 8 ++++---- extra/{ => io}/serial/windows/authors.txt | 0 extra/{ => io}/serial/windows/tags.txt | 0 extra/{ => io}/serial/windows/windows.factor | 2 +- extra/serial/windows/windows-tests.factor | 4 ---- 21 files changed, 21 insertions(+), 26 deletions(-) rename extra/{ => io}/serial/authors.txt (100%) rename extra/{ => io}/serial/serial.factor (75%) rename extra/{ => io}/serial/summary.txt (100%) rename extra/{ => io}/serial/tags.txt (100%) rename extra/{ => io}/serial/unix/bsd/bsd.factor (96%) rename extra/{ => io}/serial/unix/bsd/tags.txt (100%) rename extra/{ => io}/serial/unix/linux/linux.factor (97%) rename extra/{ => io}/serial/unix/linux/tags.txt (100%) rename extra/{ => io}/serial/unix/tags.txt (100%) rename extra/{ => io}/serial/unix/termios/bsd/bsd.factor (95%) rename extra/{ => io}/serial/unix/termios/bsd/tags.txt (100%) rename extra/{ => io}/serial/unix/termios/linux/linux.factor (96%) rename extra/{ => io}/serial/unix/termios/linux/tags.txt (100%) rename extra/{ => io}/serial/unix/termios/tags.txt (100%) rename extra/{ => io}/serial/unix/termios/termios.factor (52%) rename extra/{ => io}/serial/unix/unix-tests.factor (84%) rename extra/{ => io}/serial/unix/unix.factor (91%) rename extra/{ => io}/serial/windows/authors.txt (100%) rename extra/{ => io}/serial/windows/tags.txt (100%) rename extra/{ => io}/serial/windows/windows.factor (96%) delete mode 100755 extra/serial/windows/windows-tests.factor diff --git a/extra/serial/authors.txt b/extra/io/serial/authors.txt similarity index 100% rename from extra/serial/authors.txt rename to extra/io/serial/authors.txt diff --git a/extra/serial/serial.factor b/extra/io/serial/serial.factor similarity index 75% rename from extra/serial/serial.factor rename to extra/io/serial/serial.factor index 96900fb6e4..f7324acd05 100644 --- a/extra/serial/serial.factor +++ b/extra/io/serial/serial.factor @@ -3,22 +3,21 @@ USING: accessors alien.c-types assocs combinators destructors kernel math math.bitwise math.parser sequences summary system vocabs.loader ; -IN: serial +IN: io.serial TUPLE: serial stream path baud termios iflag oflag cflag lflag ; ERROR: invalid-baud baud ; M: invalid-baud summary ( invalid-baud -- string ) - "Baud rate " - swap baud>> number>string - " not supported" 3append ; + baud>> number>string + "Baud rate " " not supported" surround ; HOOK: lookup-baud os ( m -- n ) HOOK: open-serial os ( serial -- serial' ) M: serial dispose ( serial -- ) stream>> dispose ; { - { [ os unix? ] [ "serial.unix" ] } - { [ os windows? ] [ "serial.windows" ] } + { [ os unix? ] [ "io.serial.unix" ] } + { [ os windows? ] [ "io.serial.windows" ] } } cond require diff --git a/extra/serial/summary.txt b/extra/io/serial/summary.txt similarity index 100% rename from extra/serial/summary.txt rename to extra/io/serial/summary.txt diff --git a/extra/serial/tags.txt b/extra/io/serial/tags.txt similarity index 100% rename from extra/serial/tags.txt rename to extra/io/serial/tags.txt diff --git a/extra/serial/unix/bsd/bsd.factor b/extra/io/serial/unix/bsd/bsd.factor similarity index 96% rename from extra/serial/unix/bsd/bsd.factor rename to extra/io/serial/unix/bsd/bsd.factor index 22886ecb15..dbb013aca0 100644 --- a/extra/serial/unix/bsd/bsd.factor +++ b/extra/io/serial/unix/bsd/bsd.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax kernel math.bitwise sequences system serial ; -IN: serial.unix +USING: alien.syntax kernel math.bitwise sequences system io.serial ; +IN: io.serial.unix M: bsd lookup-baud ( m -- n ) dup { diff --git a/extra/serial/unix/bsd/tags.txt b/extra/io/serial/unix/bsd/tags.txt similarity index 100% rename from extra/serial/unix/bsd/tags.txt rename to extra/io/serial/unix/bsd/tags.txt diff --git a/extra/serial/unix/linux/linux.factor b/extra/io/serial/unix/linux/linux.factor similarity index 97% rename from extra/serial/unix/linux/linux.factor rename to extra/io/serial/unix/linux/linux.factor index 9511ec45bf..4d1878d2a9 100644 --- a/extra/serial/unix/linux/linux.factor +++ b/extra/io/serial/unix/linux/linux.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: assocs alien.syntax kernel serial system unix ; -IN: serial.unix +USING: assocs alien.syntax kernel io.serial system unix ; +IN: io.serial.unix CONSTANT: TCSANOW 0 CONSTANT: TCSADRAIN 1 diff --git a/extra/serial/unix/linux/tags.txt b/extra/io/serial/unix/linux/tags.txt similarity index 100% rename from extra/serial/unix/linux/tags.txt rename to extra/io/serial/unix/linux/tags.txt diff --git a/extra/serial/unix/tags.txt b/extra/io/serial/unix/tags.txt similarity index 100% rename from extra/serial/unix/tags.txt rename to extra/io/serial/unix/tags.txt diff --git a/extra/serial/unix/termios/bsd/bsd.factor b/extra/io/serial/unix/termios/bsd/bsd.factor similarity index 95% rename from extra/serial/unix/termios/bsd/bsd.factor rename to extra/io/serial/unix/termios/bsd/bsd.factor index 87414089cc..63d0157780 100644 --- a/extra/serial/unix/termios/bsd/bsd.factor +++ b/extra/io/serial/unix/termios/bsd/bsd.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien.syntax kernel sequences system ; -IN: serial.unix.termios +IN: io.serial.unix.termios CONSTANT: NCCS 20 diff --git a/extra/serial/unix/termios/bsd/tags.txt b/extra/io/serial/unix/termios/bsd/tags.txt similarity index 100% rename from extra/serial/unix/termios/bsd/tags.txt rename to extra/io/serial/unix/termios/bsd/tags.txt diff --git a/extra/serial/unix/termios/linux/linux.factor b/extra/io/serial/unix/termios/linux/linux.factor similarity index 96% rename from extra/serial/unix/termios/linux/linux.factor rename to extra/io/serial/unix/termios/linux/linux.factor index 41df31db09..4b8c52c7fb 100644 --- a/extra/serial/unix/termios/linux/linux.factor +++ b/extra/io/serial/unix/termios/linux/linux.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien.syntax kernel system unix ; -IN: serial.unix.termios +IN: io.serial.unix.termios CONSTANT: NCCS 32 diff --git a/extra/serial/unix/termios/linux/tags.txt b/extra/io/serial/unix/termios/linux/tags.txt similarity index 100% rename from extra/serial/unix/termios/linux/tags.txt rename to extra/io/serial/unix/termios/linux/tags.txt diff --git a/extra/serial/unix/termios/tags.txt b/extra/io/serial/unix/termios/tags.txt similarity index 100% rename from extra/serial/unix/termios/tags.txt rename to extra/io/serial/unix/termios/tags.txt diff --git a/extra/serial/unix/termios/termios.factor b/extra/io/serial/unix/termios/termios.factor similarity index 52% rename from extra/serial/unix/termios/termios.factor rename to extra/io/serial/unix/termios/termios.factor index 901416d62c..e5ccd37e87 100644 --- a/extra/serial/unix/termios/termios.factor +++ b/extra/io/serial/unix/termios/termios.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: combinators system vocabs.loader ; -IN: serial.unix.termios +IN: io.serial.unix.termios { - { [ os linux? ] [ "serial.unix.termios.linux" ] } - { [ os bsd? ] [ "serial.unix.termios.bsd" ] } + { [ os linux? ] [ "io.serial.unix.termios.linux" ] } + { [ os bsd? ] [ "io.serial.unix.termios.bsd" ] } } cond require diff --git a/extra/serial/unix/unix-tests.factor b/extra/io/serial/unix/unix-tests.factor similarity index 84% rename from extra/serial/unix/unix-tests.factor rename to extra/io/serial/unix/unix-tests.factor index e9126a5961..e9b8d78e4b 100644 --- a/extra/serial/unix/unix-tests.factor +++ b/extra/io/serial/unix/unix-tests.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel math.bitwise serial serial.unix ; -IN: serial.unix +USING: accessors kernel math.bitwise io.serial io.serial.unix ; +IN: io.serial.unix : serial-obj ( -- obj ) serial new diff --git a/extra/serial/unix/unix.factor b/extra/io/serial/unix/unix.factor similarity index 91% rename from extra/serial/unix/unix.factor rename to extra/io/serial/unix/unix.factor index ee320b0d2e..1ba8031dfc 100644 --- a/extra/serial/unix/unix.factor +++ b/extra/io/serial/unix/unix.factor @@ -2,12 +2,12 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.syntax combinators io.ports io.streams.duplex system kernel math math.bitwise -vocabs.loader unix serial serial.unix.termios io.backend.unix ; -IN: serial.unix +vocabs.loader unix io.serial io.serial.unix.termios io.backend.unix ; +IN: io.serial.unix << { - { [ os linux? ] [ "serial.unix.linux" ] } - { [ os bsd? ] [ "serial.unix.bsd" ] } + { [ os linux? ] [ "io.serial.unix.linux" ] } + { [ os bsd? ] [ "io.serial.unix.bsd" ] } } cond require >> FUNCTION: speed_t cfgetispeed ( termios* t ) ; diff --git a/extra/serial/windows/authors.txt b/extra/io/serial/windows/authors.txt similarity index 100% rename from extra/serial/windows/authors.txt rename to extra/io/serial/windows/authors.txt diff --git a/extra/serial/windows/tags.txt b/extra/io/serial/windows/tags.txt similarity index 100% rename from extra/serial/windows/tags.txt rename to extra/io/serial/windows/tags.txt diff --git a/extra/serial/windows/windows.factor b/extra/io/serial/windows/windows.factor similarity index 96% rename from extra/serial/windows/windows.factor rename to extra/io/serial/windows/windows.factor index a80366cb9f..2d27a489ef 100755 --- a/extra/serial/windows/windows.factor +++ b/extra/io/serial/windows/windows.factor @@ -3,7 +3,7 @@ USING: io.files.windows io.streams.duplex kernel math math.bitwise windows.kernel32 accessors alien.c-types windows io.files.windows fry locals continuations ; -IN: serial.windows +IN: io.serial.windows : ( path encoding -- duplex ) [ open-r/w dup ] dip ; diff --git a/extra/serial/windows/windows-tests.factor b/extra/serial/windows/windows-tests.factor deleted file mode 100755 index bd67f77eae..0000000000 --- a/extra/serial/windows/windows-tests.factor +++ /dev/null @@ -1,4 +0,0 @@ -! Copyright (C) 2009 Your name. -! See http://factorcode.org/license.txt for BSD license. -USING: tools.test serial.windows ; -IN: serial.windows.tests From 59b7b95063ca00a2ba999e0ea81ea1f6500c36d8 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 17:50:56 -0600 Subject: [PATCH 31/85] remove empty tests file --- extra/fuel/fuel-tests.factor | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 extra/fuel/fuel-tests.factor diff --git a/extra/fuel/fuel-tests.factor b/extra/fuel/fuel-tests.factor deleted file mode 100644 index 74bc5d4d45..0000000000 --- a/extra/fuel/fuel-tests.factor +++ /dev/null @@ -1,4 +0,0 @@ -! Copyright (C) 2008 Your name. -! See http://factorcode.org/license.txt for BSD license. -USING: tools.test fuel ; -IN: fuel.tests From 4b3f646cc0092bbe040c2756cbd414fc92ce71b8 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 17:51:43 -0600 Subject: [PATCH 32/85] Your name -> his name --- extra/adsoda/combinators/combinators-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/adsoda/combinators/combinators-docs.factor b/extra/adsoda/combinators/combinators-docs.factor index 0121dce32b..5b540e7a7f 100755 --- a/extra/adsoda/combinators/combinators-docs.factor +++ b/extra/adsoda/combinators/combinators-docs.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Your name. +! Copyright (C) 2008 Jeff Bigot. ! See http://factorcode.org/license.txt for BSD license. USING: arrays help.markup help.syntax kernel sequences ; IN: adsoda.combinators From f7165e115e03a50b0c5e107759eb7133fb644e52 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 17:52:04 -0600 Subject: [PATCH 33/85] remove extra ?at definition --- extra/infix/infix.factor | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/extra/infix/infix.factor b/extra/infix/infix.factor index 3e2ba49e3c..d39c0b3c2d 100644 --- a/extra/infix/infix.factor +++ b/extra/infix/infix.factor @@ -14,11 +14,8 @@ ERROR: local-not-defined name ; M: local-not-defined summary drop "local is not defined" ; -: at? ( key assoc -- value/key ? ) - dupd at* [ nip t ] [ drop f ] if ; - : >local-word ( string -- word ) - locals get at? [ local-not-defined ] unless ; + locals get ?at [ local-not-defined ] unless ; : select-op ( string -- word ) { From 917296670df442e5c7a864fa7bf1770271393904 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 17:52:27 -0600 Subject: [PATCH 34/85] use CONSTANT: --- extra/iokit/hid/hid.factor | 188 ++++++++++++++++++------------------- 1 file changed, 94 insertions(+), 94 deletions(-) diff --git a/extra/iokit/hid/hid.factor b/extra/iokit/hid/hid.factor index 465c55c833..cd9eea1409 100644 --- a/extra/iokit/hid/hid.factor +++ b/extra/iokit/hid/hid.factor @@ -2,117 +2,117 @@ USING: iokit alien alien.syntax alien.c-types kernel system core-foundation ; IN: iokit.hid -: kIOHIDDeviceKey "IOHIDDevice" ; inline +CONSTANT: kIOHIDDeviceKey "IOHIDDevice" -: kIOHIDTransportKey "Transport" ; inline -: kIOHIDVendorIDKey "VendorID" ; inline -: kIOHIDVendorIDSourceKey "VendorIDSource" ; inline -: kIOHIDProductIDKey "ProductID" ; inline -: kIOHIDVersionNumberKey "VersionNumber" ; inline -: kIOHIDManufacturerKey "Manufacturer" ; inline -: kIOHIDProductKey "Product" ; inline -: kIOHIDSerialNumberKey "SerialNumber" ; inline -: kIOHIDCountryCodeKey "CountryCode" ; inline -: kIOHIDLocationIDKey "LocationID" ; inline -: kIOHIDDeviceUsageKey "DeviceUsage" ; inline -: kIOHIDDeviceUsagePageKey "DeviceUsagePage" ; inline -: kIOHIDDeviceUsagePairsKey "DeviceUsagePairs" ; inline -: kIOHIDPrimaryUsageKey "PrimaryUsage" ; inline -: kIOHIDPrimaryUsagePageKey "PrimaryUsagePage" ; inline -: kIOHIDMaxInputReportSizeKey "MaxInputReportSize" ; inline -: kIOHIDMaxOutputReportSizeKey "MaxOutputReportSize" ; inline -: kIOHIDMaxFeatureReportSizeKey "MaxFeatureReportSize" ; inline -: kIOHIDReportIntervalKey "ReportInterval" ; inline +CONSTANT: kIOHIDTransportKey "Transport" +CONSTANT: kIOHIDVendorIDKey "VendorID" +CONSTANT: kIOHIDVendorIDSourceKey "VendorIDSource" +CONSTANT: kIOHIDProductIDKey "ProductID" +CONSTANT: kIOHIDVersionNumberKey "VersionNumber" +CONSTANT: kIOHIDManufacturerKey "Manufacturer" +CONSTANT: kIOHIDProductKey "Product" +CONSTANT: kIOHIDSerialNumberKey "SerialNumber" +CONSTANT: kIOHIDCountryCodeKey "CountryCode" +CONSTANT: kIOHIDLocationIDKey "LocationID" +CONSTANT: kIOHIDDeviceUsageKey "DeviceUsage" +CONSTANT: kIOHIDDeviceUsagePageKey "DeviceUsagePage" +CONSTANT: kIOHIDDeviceUsagePairsKey "DeviceUsagePairs" +CONSTANT: kIOHIDPrimaryUsageKey "PrimaryUsage" +CONSTANT: kIOHIDPrimaryUsagePageKey "PrimaryUsagePage" +CONSTANT: kIOHIDMaxInputReportSizeKey "MaxInputReportSize" +CONSTANT: kIOHIDMaxOutputReportSizeKey "MaxOutputReportSize" +CONSTANT: kIOHIDMaxFeatureReportSizeKey "MaxFeatureReportSize" +CONSTANT: kIOHIDReportIntervalKey "ReportInterval" -: kIOHIDElementKey "Elements" ; inline +CONSTANT: kIOHIDElementKey "Elements" -: kIOHIDElementCookieKey "ElementCookie" ; inline -: kIOHIDElementTypeKey "Type" ; inline -: kIOHIDElementCollectionTypeKey "CollectionType" ; inline -: kIOHIDElementUsageKey "Usage" ; inline -: kIOHIDElementUsagePageKey "UsagePage" ; inline -: kIOHIDElementMinKey "Min" ; inline -: kIOHIDElementMaxKey "Max" ; inline -: kIOHIDElementScaledMinKey "ScaledMin" ; inline -: kIOHIDElementScaledMaxKey "ScaledMax" ; inline -: kIOHIDElementSizeKey "Size" ; inline -: kIOHIDElementReportSizeKey "ReportSize" ; inline -: kIOHIDElementReportCountKey "ReportCount" ; inline -: kIOHIDElementReportIDKey "ReportID" ; inline -: kIOHIDElementIsArrayKey "IsArray" ; inline -: kIOHIDElementIsRelativeKey "IsRelative" ; inline -: kIOHIDElementIsWrappingKey "IsWrapping" ; inline -: kIOHIDElementIsNonLinearKey "IsNonLinear" ; inline -: kIOHIDElementHasPreferredStateKey "HasPreferredState" ; inline -: kIOHIDElementHasNullStateKey "HasNullState" ; inline -: kIOHIDElementFlagsKey "Flags" ; inline -: kIOHIDElementUnitKey "Unit" ; inline -: kIOHIDElementUnitExponentKey "UnitExponent" ; inline -: kIOHIDElementNameKey "Name" ; inline -: kIOHIDElementValueLocationKey "ValueLocation" ; inline -: kIOHIDElementDuplicateIndexKey "DuplicateIndex" ; inline -: kIOHIDElementParentCollectionKey "ParentCollection" ; inline +CONSTANT: kIOHIDElementCookieKey "ElementCookie" +CONSTANT: kIOHIDElementTypeKey "Type" +CONSTANT: kIOHIDElementCollectionTypeKey "CollectionType" +CONSTANT: kIOHIDElementUsageKey "Usage" +CONSTANT: kIOHIDElementUsagePageKey "UsagePage" +CONSTANT: kIOHIDElementMinKey "Min" +CONSTANT: kIOHIDElementMaxKey "Max" +CONSTANT: kIOHIDElementScaledMinKey "ScaledMin" +CONSTANT: kIOHIDElementScaledMaxKey "ScaledMax" +CONSTANT: kIOHIDElementSizeKey "Size" +CONSTANT: kIOHIDElementReportSizeKey "ReportSize" +CONSTANT: kIOHIDElementReportCountKey "ReportCount" +CONSTANT: kIOHIDElementReportIDKey "ReportID" +CONSTANT: kIOHIDElementIsArrayKey "IsArray" +CONSTANT: kIOHIDElementIsRelativeKey "IsRelative" +CONSTANT: kIOHIDElementIsWrappingKey "IsWrapping" +CONSTANT: kIOHIDElementIsNonLinearKey "IsNonLinear" +CONSTANT: kIOHIDElementHasPreferredStateKey "HasPreferredState" +CONSTANT: kIOHIDElementHasNullStateKey "HasNullState" +CONSTANT: kIOHIDElementFlagsKey "Flags" +CONSTANT: kIOHIDElementUnitKey "Unit" +CONSTANT: kIOHIDElementUnitExponentKey "UnitExponent" +CONSTANT: kIOHIDElementNameKey "Name" +CONSTANT: kIOHIDElementValueLocationKey "ValueLocation" +CONSTANT: kIOHIDElementDuplicateIndexKey "DuplicateIndex" +CONSTANT: kIOHIDElementParentCollectionKey "ParentCollection" : kIOHIDElementVendorSpecificKey ( -- str ) cpu ppc? "VendorSpecifc" "VendorSpecific" ? ; inline -: kIOHIDElementCookieMinKey "ElementCookieMin" ; inline -: kIOHIDElementCookieMaxKey "ElementCookieMax" ; inline -: kIOHIDElementUsageMinKey "UsageMin" ; inline -: kIOHIDElementUsageMaxKey "UsageMax" ; inline +CONSTANT: kIOHIDElementCookieMinKey "ElementCookieMin" +CONSTANT: kIOHIDElementCookieMaxKey "ElementCookieMax" +CONSTANT: kIOHIDElementUsageMinKey "UsageMin" +CONSTANT: kIOHIDElementUsageMaxKey "UsageMax" -: kIOHIDElementCalibrationMinKey "CalibrationMin" ; inline -: kIOHIDElementCalibrationMaxKey "CalibrationMax" ; inline -: kIOHIDElementCalibrationSaturationMinKey "CalibrationSaturationMin" ; inline -: kIOHIDElementCalibrationSaturationMaxKey "CalibrationSaturationMax" ; inline -: kIOHIDElementCalibrationDeadZoneMinKey "CalibrationDeadZoneMin" ; inline -: kIOHIDElementCalibrationDeadZoneMaxKey "CalibrationDeadZoneMax" ; inline -: kIOHIDElementCalibrationGranularityKey "CalibrationGranularity" ; inline +CONSTANT: kIOHIDElementCalibrationMinKey "CalibrationMin" +CONSTANT: kIOHIDElementCalibrationMaxKey "CalibrationMax" +CONSTANT: kIOHIDElementCalibrationSaturationMinKey "CalibrationSaturationMin" +CONSTANT: kIOHIDElementCalibrationSaturationMaxKey "CalibrationSaturationMax" +CONSTANT: kIOHIDElementCalibrationDeadZoneMinKey "CalibrationDeadZoneMin" +CONSTANT: kIOHIDElementCalibrationDeadZoneMaxKey "CalibrationDeadZoneMax" +CONSTANT: kIOHIDElementCalibrationGranularityKey "CalibrationGranularity" -: kIOHIDElementTypeInput_Misc 1 ; inline -: kIOHIDElementTypeInput_Button 2 ; inline -: kIOHIDElementTypeInput_Axis 3 ; inline -: kIOHIDElementTypeInput_ScanCodes 4 ; inline -: kIOHIDElementTypeOutput 129 ; inline -: kIOHIDElementTypeFeature 257 ; inline -: kIOHIDElementTypeCollection 513 ; inline +CONSTANT: kIOHIDElementTypeInput_Misc 1 +CONSTANT: kIOHIDElementTypeInput_Button 2 +CONSTANT: kIOHIDElementTypeInput_Axis 3 +CONSTANT: kIOHIDElementTypeInput_ScanCodes 4 +CONSTANT: kIOHIDElementTypeOutput 129 +CONSTANT: kIOHIDElementTypeFeature 257 +CONSTANT: kIOHIDElementTypeCollection 513 -: kIOHIDElementCollectionTypePhysical HEX: 00 ; inline -: kIOHIDElementCollectionTypeApplication HEX: 01 ; inline -: kIOHIDElementCollectionTypeLogical HEX: 02 ; inline -: kIOHIDElementCollectionTypeReport HEX: 03 ; inline -: kIOHIDElementCollectionTypeNamedArray HEX: 04 ; inline -: kIOHIDElementCollectionTypeUsageSwitch HEX: 05 ; inline -: kIOHIDElementCollectionTypeUsageModifier HEX: 06 ; inline +CONSTANT: kIOHIDElementCollectionTypePhysical HEX: 00 +CONSTANT: kIOHIDElementCollectionTypeApplication HEX: 01 +CONSTANT: kIOHIDElementCollectionTypeLogical HEX: 02 +CONSTANT: kIOHIDElementCollectionTypeReport HEX: 03 +CONSTANT: kIOHIDElementCollectionTypeNamedArray HEX: 04 +CONSTANT: kIOHIDElementCollectionTypeUsageSwitch HEX: 05 +CONSTANT: kIOHIDElementCollectionTypeUsageModifier HEX: 06 -: kIOHIDReportTypeInput 0 ; inline -: kIOHIDReportTypeOutput 1 ; inline -: kIOHIDReportTypeFeature 2 ; inline -: kIOHIDReportTypeCount 3 ; inline +CONSTANT: kIOHIDReportTypeInput 0 +CONSTANT: kIOHIDReportTypeOutput 1 +CONSTANT: kIOHIDReportTypeFeature 2 +CONSTANT: kIOHIDReportTypeCount 3 -: kIOHIDOptionsTypeNone HEX: 00 ; inline -: kIOHIDOptionsTypeSeizeDevice HEX: 01 ; inline +CONSTANT: kIOHIDOptionsTypeNone HEX: 00 +CONSTANT: kIOHIDOptionsTypeSeizeDevice HEX: 01 -: kIOHIDQueueOptionsTypeNone HEX: 00 ; inline -: kIOHIDQueueOptionsTypeEnqueueAll HEX: 01 ; inline +CONSTANT: kIOHIDQueueOptionsTypeNone HEX: 00 +CONSTANT: kIOHIDQueueOptionsTypeEnqueueAll HEX: 01 -: kIOHIDElementFlagsConstantMask HEX: 0001 ; inline -: kIOHIDElementFlagsVariableMask HEX: 0002 ; inline -: kIOHIDElementFlagsRelativeMask HEX: 0004 ; inline -: kIOHIDElementFlagsWrapMask HEX: 0008 ; inline -: kIOHIDElementFlagsNonLinearMask HEX: 0010 ; inline -: kIOHIDElementFlagsNoPreferredMask HEX: 0020 ; inline -: kIOHIDElementFlagsNullStateMask HEX: 0040 ; inline -: kIOHIDElementFlagsVolativeMask HEX: 0080 ; inline -: kIOHIDElementFlagsBufferedByteMask HEX: 0100 ; inline +CONSTANT: kIOHIDElementFlagsConstantMask HEX: 0001 +CONSTANT: kIOHIDElementFlagsVariableMask HEX: 0002 +CONSTANT: kIOHIDElementFlagsRelativeMask HEX: 0004 +CONSTANT: kIOHIDElementFlagsWrapMask HEX: 0008 +CONSTANT: kIOHIDElementFlagsNonLinearMask HEX: 0010 +CONSTANT: kIOHIDElementFlagsNoPreferredMask HEX: 0020 +CONSTANT: kIOHIDElementFlagsNullStateMask HEX: 0040 +CONSTANT: kIOHIDElementFlagsVolativeMask HEX: 0080 +CONSTANT: kIOHIDElementFlagsBufferedByteMask HEX: 0100 -: kIOHIDValueScaleTypeCalibrated 0 ; inline -: kIOHIDValueScaleTypePhysical 1 ; inline +CONSTANT: kIOHIDValueScaleTypeCalibrated 0 +CONSTANT: kIOHIDValueScaleTypePhysical 1 -: kIOHIDTransactionDirectionTypeInput 0 ; inline -: kIOHIDTransactionDirectionTypeOutput 1 ; inline +CONSTANT: kIOHIDTransactionDirectionTypeInput 0 +CONSTANT: kIOHIDTransactionDirectionTypeOutput 1 -: kIOHIDTransactionOptionDefaultOutputValue 1 ; inline +CONSTANT: kIOHIDTransactionOptionDefaultOutputValue 1 TYPEDEF: ptrdiff_t IOHIDElementCookie TYPEDEF: int IOHIDElementType From 8b0b5878d23f2f95d38199ea69f63916fdef48ab Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 17:52:59 -0600 Subject: [PATCH 35/85] at* -> ?at in a couple places --- basis/help/topics/topics.factor | 2 +- basis/unix/groups/groups.factor | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/help/topics/topics.factor b/basis/help/topics/topics.factor index 8c687eb1d5..9fba09913d 100644 --- a/basis/help/topics/topics.factor +++ b/basis/help/topics/topics.factor @@ -54,7 +54,7 @@ M: no-article summary drop "Help article does not exist" ; : article ( name -- article ) - dup articles get at* [ nip ] [ drop no-article ] if ; + articles get ?at [ no-article ] unless ; M: object article-name article article-name ; M: object article-title article article-title ; diff --git a/basis/unix/groups/groups.factor b/basis/unix/groups/groups.factor index f4d91df245..b2a50b7374 100644 --- a/basis/unix/groups/groups.factor +++ b/basis/unix/groups/groups.factor @@ -46,7 +46,7 @@ PRIVATE> : group-name ( id -- string ) dup group-cache get [ - dupd at* [ name>> nip ] [ drop number>string ] if + ?at [ name>> ] [ number>string ] if ] [ group-struct [ group-gr_name ] [ f ] if* ] if* From 6282b552c1eeb3998ab880aa68a590c75f0f1b19 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 17:56:12 -0600 Subject: [PATCH 36/85] use CONSTANT: --- extra/iokit/iokit.factor | 134 +++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/extra/iokit/iokit.factor b/extra/iokit/iokit.factor index 2317d21ed5..3fb14e8ec5 100755 --- a/extra/iokit/iokit.factor +++ b/extra/iokit/iokit.factor @@ -9,95 +9,95 @@ IN: iokit when >> -: kIOKitBuildVersionKey "IOKitBuildVersion" ; inline -: kIOKitDiagnosticsKey "IOKitDiagnostics" ; inline +CONSTANT: kIOKitBuildVersionKey "IOKitBuildVersion" +CONSTANT: kIOKitDiagnosticsKey "IOKitDiagnostics" -: kIORegistryPlanesKey "IORegistryPlanes" ; inline -: kIOCatalogueKey "IOCatalogue" ; inline +CONSTANT: kIORegistryPlanesKey "IORegistryPlanes" +CONSTANT: kIOCatalogueKey "IOCatalogue" -: kIOServicePlane "IOService" ; inline -: kIOPowerPlane "IOPower" ; inline -: kIODeviceTreePlane "IODeviceTree" ; inline -: kIOAudioPlane "IOAudio" ; inline -: kIOFireWirePlane "IOFireWire" ; inline -: kIOUSBPlane "IOUSB" ; inline +CONSTANT: kIOServicePlane "IOService" +CONSTANT: kIOPowerPlane "IOPower" +CONSTANT: kIODeviceTreePlane "IODeviceTree" +CONSTANT: kIOAudioPlane "IOAudio" +CONSTANT: kIOFireWirePlane "IOFireWire" +CONSTANT: kIOUSBPlane "IOUSB" -: kIOServiceClass "IOService" ; inline +CONSTANT: kIOServiceClass "IOService" -: kIOResourcesClass "IOResources" ; inline +CONSTANT: kIOResourcesClass "IOResources" -: kIOClassKey "IOClass" ; inline -: kIOProbeScoreKey "IOProbeScore" ; inline -: kIOKitDebugKey "IOKitDebug" ; inline +CONSTANT: kIOClassKey "IOClass" +CONSTANT: kIOProbeScoreKey "IOProbeScore" +CONSTANT: kIOKitDebugKey "IOKitDebug" -: kIOProviderClassKey "IOProviderClass" ; inline -: kIONameMatchKey "IONameMatch" ; inline -: kIOPropertyMatchKey "IOPropertyMatch" ; inline -: kIOPathMatchKey "IOPathMatch" ; inline -: kIOLocationMatchKey "IOLocationMatch" ; inline -: kIOParentMatchKey "IOParentMatch" ; inline -: kIOResourceMatchKey "IOResourceMatch" ; inline -: kIOMatchedServiceCountKey "IOMatchedServiceCountMatch" ; inline +CONSTANT: kIOProviderClassKey "IOProviderClass" +CONSTANT: kIONameMatchKey "IONameMatch" +CONSTANT: kIOPropertyMatchKey "IOPropertyMatch" +CONSTANT: kIOPathMatchKey "IOPathMatch" +CONSTANT: kIOLocationMatchKey "IOLocationMatch" +CONSTANT: kIOParentMatchKey "IOParentMatch" +CONSTANT: kIOResourceMatchKey "IOResourceMatch" +CONSTANT: kIOMatchedServiceCountKey "IOMatchedServiceCountMatch" -: kIONameMatchedKey "IONameMatched" ; inline +CONSTANT: kIONameMatchedKey "IONameMatched" -: kIOMatchCategoryKey "IOMatchCategory" ; inline -: kIODefaultMatchCategoryKey "IODefaultMatchCategory" ; inline +CONSTANT: kIOMatchCategoryKey "IOMatchCategory" +CONSTANT: kIODefaultMatchCategoryKey "IODefaultMatchCategory" -: kIOUserClientClassKey "IOUserClientClass" ; inline +CONSTANT: kIOUserClientClassKey "IOUserClientClass" -: kIOUserClientCrossEndianKey "IOUserClientCrossEndian" ; inline -: kIOUserClientCrossEndianCompatibleKey "IOUserClientCrossEndianCompatible" ; inline -: kIOUserClientSharedInstanceKey "IOUserClientSharedInstance" ; inline +CONSTANT: kIOUserClientCrossEndianKey "IOUserClientCrossEndian" +CONSTANT: kIOUserClientCrossEndianCompatibleKey "IOUserClientCrossEndianCompatible" +CONSTANT: kIOUserClientSharedInstanceKey "IOUserClientSharedInstance" -: kIOPublishNotification "IOServicePublish" ; inline -: kIOFirstPublishNotification "IOServiceFirstPublish" ; inline -: kIOMatchedNotification "IOServiceMatched" ; inline -: kIOFirstMatchNotification "IOServiceFirstMatch" ; inline -: kIOTerminatedNotification "IOServiceTerminate" ; inline +CONSTANT: kIOPublishNotification "IOServicePublish" +CONSTANT: kIOFirstPublishNotification "IOServiceFirstPublish" +CONSTANT: kIOMatchedNotification "IOServiceMatched" +CONSTANT: kIOFirstMatchNotification "IOServiceFirstMatch" +CONSTANT: kIOTerminatedNotification "IOServiceTerminate" -: kIOGeneralInterest "IOGeneralInterest" ; inline -: kIOBusyInterest "IOBusyInterest" ; inline -: kIOAppPowerStateInterest "IOAppPowerStateInterest" ; inline -: kIOPriorityPowerStateInterest "IOPriorityPowerStateInterest" ; inline +CONSTANT: kIOGeneralInterest "IOGeneralInterest" +CONSTANT: kIOBusyInterest "IOBusyInterest" +CONSTANT: kIOAppPowerStateInterest "IOAppPowerStateInterest" +CONSTANT: kIOPriorityPowerStateInterest "IOPriorityPowerStateInterest" -: kIOPlatformDeviceMessageKey "IOPlatformDeviceMessage" ; inline +CONSTANT: kIOPlatformDeviceMessageKey "IOPlatformDeviceMessage" -: kIOCFPlugInTypesKey "IOCFPlugInTypes" ; inline +CONSTANT: kIOCFPlugInTypesKey "IOCFPlugInTypes" -: kIOCommandPoolSizeKey "IOCommandPoolSize" ; inline +CONSTANT: kIOCommandPoolSizeKey "IOCommandPoolSize" -: kIOMaximumBlockCountReadKey "IOMaximumBlockCountRead" ; inline -: kIOMaximumBlockCountWriteKey "IOMaximumBlockCountWrite" ; inline -: kIOMaximumByteCountReadKey "IOMaximumByteCountRead" ; inline -: kIOMaximumByteCountWriteKey "IOMaximumByteCountWrite" ; inline -: kIOMaximumSegmentCountReadKey "IOMaximumSegmentCountRead" ; inline -: kIOMaximumSegmentCountWriteKey "IOMaximumSegmentCountWrite" ; inline -: kIOMaximumSegmentByteCountReadKey "IOMaximumSegmentByteCountRead" ; inline -: kIOMaximumSegmentByteCountWriteKey "IOMaximumSegmentByteCountWrite" ; inline -: kIOMinimumSegmentAlignmentByteCountKey "IOMinimumSegmentAlignmentByteCount" ; inline -: kIOMaximumSegmentAddressableBitCountKey "IOMaximumSegmentAddressableBitCount" ; inline +CONSTANT: kIOMaximumBlockCountReadKey "IOMaximumBlockCountRead" +CONSTANT: kIOMaximumBlockCountWriteKey "IOMaximumBlockCountWrite" +CONSTANT: kIOMaximumByteCountReadKey "IOMaximumByteCountRead" +CONSTANT: kIOMaximumByteCountWriteKey "IOMaximumByteCountWrite" +CONSTANT: kIOMaximumSegmentCountReadKey "IOMaximumSegmentCountRead" +CONSTANT: kIOMaximumSegmentCountWriteKey "IOMaximumSegmentCountWrite" +CONSTANT: kIOMaximumSegmentByteCountReadKey "IOMaximumSegmentByteCountRead" +CONSTANT: kIOMaximumSegmentByteCountWriteKey "IOMaximumSegmentByteCountWrite" +CONSTANT: kIOMinimumSegmentAlignmentByteCountKey "IOMinimumSegmentAlignmentByteCount" +CONSTANT: kIOMaximumSegmentAddressableBitCountKey "IOMaximumSegmentAddressableBitCount" -: kIOIconKey "IOIcon" ; inline -: kIOBundleResourceFileKey "IOBundleResourceFile" ; inline +CONSTANT: kIOIconKey "IOIcon" +CONSTANT: kIOBundleResourceFileKey "IOBundleResourceFile" -: kIOBusBadgeKey "IOBusBadge" ; inline -: kIODeviceIconKey "IODeviceIcon" ; inline +CONSTANT: kIOBusBadgeKey "IOBusBadge" +CONSTANT: kIODeviceIconKey "IODeviceIcon" -: kIOPlatformSerialNumberKey "IOPlatformSerialNumber" ; inline +CONSTANT: kIOPlatformSerialNumberKey "IOPlatformSerialNumber" -: kIOPlatformUUIDKey "IOPlatformUUID" ; inline +CONSTANT: kIOPlatformUUIDKey "IOPlatformUUID" -: kIONVRAMDeletePropertyKey "IONVRAM-DELETE-PROPERTY" ; inline -: kIODTNVRAMPanicInfoKey "aapl,panic-info" ; inline +CONSTANT: kIONVRAMDeletePropertyKey "IONVRAM-DELETE-PROPERTY" +CONSTANT: kIODTNVRAMPanicInfoKey "aapl,panic-info" -: kIOBootDeviceKey "IOBootDevice" ; inline -: kIOBootDevicePathKey "IOBootDevicePath" ; inline -: kIOBootDeviceSizeKey "IOBootDeviceSize" ; inline +CONSTANT: kIOBootDeviceKey "IOBootDevice" +CONSTANT: kIOBootDevicePathKey "IOBootDevicePath" +CONSTANT: kIOBootDeviceSizeKey "IOBootDeviceSize" -: kOSBuildVersionKey "OS Build Version" ; inline +CONSTANT: kOSBuildVersionKey "OS Build Version" -: kNilOptions 0 ; inline +CONSTANT: kNilOptions 0 TYPEDEF: uint mach_port_t TYPEDEF: int kern_return_t @@ -112,8 +112,8 @@ TYPEDEF: kern_return_t IOReturn TYPEDEF: uint IOOptionBits -: MACH_PORT_NULL 0 ; inline -: KERN_SUCCESS 0 ; inline +CONSTANT: MACH_PORT_NULL 0 +CONSTANT: KERN_SUCCESS 0 FUNCTION: IOReturn IOMasterPort ( mach_port_t bootstrap, mach_port_t* master ) ; From e99dfc25e8695b673e19835791317d3917359873 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 17:57:31 -0600 Subject: [PATCH 37/85] use CONSTANT: --- extra/game-input/scancodes/scancodes.factor | 346 ++++++++++---------- 1 file changed, 173 insertions(+), 173 deletions(-) diff --git a/extra/game-input/scancodes/scancodes.factor b/extra/game-input/scancodes/scancodes.factor index 7b0e39ee9b..3303a51c6f 100644 --- a/extra/game-input/scancodes/scancodes.factor +++ b/extra/game-input/scancodes/scancodes.factor @@ -1,175 +1,175 @@ IN: game-input.scancodes -: key-undefined HEX: 0000 ; inline -: key-error-roll-over HEX: 0001 ; inline -: key-error-post-fail HEX: 0002 ; inline -: key-error-undefined HEX: 0003 ; inline -: key-a HEX: 0004 ; inline -: key-b HEX: 0005 ; inline -: key-c HEX: 0006 ; inline -: key-d HEX: 0007 ; inline -: key-e HEX: 0008 ; inline -: key-f HEX: 0009 ; inline -: key-g HEX: 000a ; inline -: key-h HEX: 000b ; inline -: key-i HEX: 000c ; inline -: key-j HEX: 000d ; inline -: key-k HEX: 000e ; inline -: key-l HEX: 000f ; inline -: key-m HEX: 0010 ; inline -: key-n HEX: 0011 ; inline -: key-o HEX: 0012 ; inline -: key-p HEX: 0013 ; inline -: key-q HEX: 0014 ; inline -: key-r HEX: 0015 ; inline -: key-s HEX: 0016 ; inline -: key-t HEX: 0017 ; inline -: key-u HEX: 0018 ; inline -: key-v HEX: 0019 ; inline -: key-w HEX: 001a ; inline -: key-x HEX: 001b ; inline -: key-y HEX: 001c ; inline -: key-z HEX: 001d ; inline -: key-1 HEX: 001e ; inline -: key-2 HEX: 001f ; inline -: key-3 HEX: 0020 ; inline -: key-4 HEX: 0021 ; inline -: key-5 HEX: 0022 ; inline -: key-6 HEX: 0023 ; inline -: key-7 HEX: 0024 ; inline -: key-8 HEX: 0025 ; inline -: key-9 HEX: 0026 ; inline -: key-0 HEX: 0027 ; inline -: key-return HEX: 0028 ; inline -: key-escape HEX: 0029 ; inline -: key-backspace HEX: 002a ; inline -: key-tab HEX: 002b ; inline -: key-space HEX: 002c ; inline -: key-- HEX: 002d ; inline -: key-= HEX: 002e ; inline -: key-[ HEX: 002f ; inline -: key-] HEX: 0030 ; inline -: key-\ HEX: 0031 ; inline -: key-#-non-us HEX: 0032 ; inline -: key-; HEX: 0033 ; inline -: key-' HEX: 0034 ; inline -: key-` HEX: 0035 ; inline -: key-, HEX: 0036 ; inline -: key-. HEX: 0037 ; inline -: key-/ HEX: 0038 ; inline -: key-caps-lock HEX: 0039 ; inline -: key-f1 HEX: 003a ; inline -: key-f2 HEX: 003b ; inline -: key-f3 HEX: 003c ; inline -: key-f4 HEX: 003d ; inline -: key-f5 HEX: 003e ; inline -: key-f6 HEX: 003f ; inline -: key-f7 HEX: 0040 ; inline -: key-f8 HEX: 0041 ; inline -: key-f9 HEX: 0042 ; inline -: key-f10 HEX: 0043 ; inline -: key-f11 HEX: 0044 ; inline -: key-f12 HEX: 0045 ; inline -: key-print-screen HEX: 0046 ; inline -: key-scroll-lock HEX: 0047 ; inline -: key-pause HEX: 0048 ; inline -: key-insert HEX: 0049 ; inline -: key-home HEX: 004a ; inline -: key-page-up HEX: 004b ; inline -: key-delete HEX: 004c ; inline -: key-end HEX: 004d ; inline -: key-page-down HEX: 004e ; inline -: key-right-arrow HEX: 004f ; inline -: key-left-arrow HEX: 0050 ; inline -: key-down-arrow HEX: 0051 ; inline -: key-up-arrow HEX: 0052 ; inline -: key-keypad-numlock HEX: 0053 ; inline -: key-keypad-/ HEX: 0054 ; inline -: key-keypad-* HEX: 0055 ; inline -: key-keypad-- HEX: 0056 ; inline -: key-keypad-+ HEX: 0057 ; inline -: key-keypad-enter HEX: 0058 ; inline -: key-keypad-1 HEX: 0059 ; inline -: key-keypad-2 HEX: 005a ; inline -: key-keypad-3 HEX: 005b ; inline -: key-keypad-4 HEX: 005c ; inline -: key-keypad-5 HEX: 005d ; inline -: key-keypad-6 HEX: 005e ; inline -: key-keypad-7 HEX: 005f ; inline -: key-keypad-8 HEX: 0060 ; inline -: key-keypad-9 HEX: 0061 ; inline -: key-keypad-0 HEX: 0062 ; inline -: key-keypad-. HEX: 0063 ; inline -: key-\-non-us HEX: 0064 ; inline -: key-application HEX: 0065 ; inline -: key-power HEX: 0066 ; inline -: key-keypad-= HEX: 0067 ; inline -: key-f13 HEX: 0068 ; inline -: key-f14 HEX: 0069 ; inline -: key-f15 HEX: 006a ; inline -: key-f16 HEX: 006b ; inline -: key-f17 HEX: 006c ; inline -: key-f18 HEX: 006d ; inline -: key-f19 HEX: 006e ; inline -: key-f20 HEX: 006f ; inline -: key-f21 HEX: 0070 ; inline -: key-f22 HEX: 0071 ; inline -: key-f23 HEX: 0072 ; inline -: key-f24 HEX: 0073 ; inline -: key-execute HEX: 0074 ; inline -: key-help HEX: 0075 ; inline -: key-menu HEX: 0076 ; inline -: key-select HEX: 0077 ; inline -: key-stop HEX: 0078 ; inline -: key-again HEX: 0079 ; inline -: key-undo HEX: 007a ; inline -: key-cut HEX: 007b ; inline -: key-copy HEX: 007c ; inline -: key-paste HEX: 007d ; inline -: key-find HEX: 007e ; inline -: key-mute HEX: 007f ; inline -: key-volume-up HEX: 0080 ; inline -: key-volume-down HEX: 0081 ; inline -: key-locking-caps-lock HEX: 0082 ; inline -: key-locking-num-lock HEX: 0083 ; inline -: key-locking-scroll-lock HEX: 0084 ; inline -: key-keypad-, HEX: 0085 ; inline -: key-keypad-=-as-400 HEX: 0086 ; inline -: key-international-1 HEX: 0087 ; inline -: key-international-2 HEX: 0088 ; inline -: key-international-3 HEX: 0089 ; inline -: key-international-4 HEX: 008a ; inline -: key-international-5 HEX: 008b ; inline -: key-international-6 HEX: 008c ; inline -: key-international-7 HEX: 008d ; inline -: key-international-8 HEX: 008e ; inline -: key-international-9 HEX: 008f ; inline -: key-lang-1 HEX: 0090 ; inline -: key-lang-2 HEX: 0091 ; inline -: key-lang-3 HEX: 0092 ; inline -: key-lang-4 HEX: 0093 ; inline -: key-lang-5 HEX: 0094 ; inline -: key-lang-6 HEX: 0095 ; inline -: key-lang-7 HEX: 0096 ; inline -: key-lang-8 HEX: 0097 ; inline -: key-lang-9 HEX: 0098 ; inline -: key-alternate-erase HEX: 0099 ; inline -: key-sysreq HEX: 009a ; inline -: key-cancel HEX: 009b ; inline -: key-clear HEX: 009c ; inline -: key-prior HEX: 009d ; inline -: key-enter HEX: 009e ; inline -: key-separator HEX: 009f ; inline -: key-out HEX: 00a0 ; inline -: key-oper HEX: 00a1 ; inline -: key-clear-again HEX: 00a2 ; inline -: key-crsel-props HEX: 00a3 ; inline -: key-exsel HEX: 00a4 ; inline -: key-left-control HEX: 00e0 ; inline -: key-left-shift HEX: 00e1 ; inline -: key-left-alt HEX: 00e2 ; inline -: key-left-gui HEX: 00e3 ; inline -: key-right-control HEX: 00e4 ; inline -: key-right-shift HEX: 00e5 ; inline -: key-right-alt HEX: 00e6 ; inline -: key-right-gui HEX: 00e7 ; inline +CONSTANT: key-undefined HEX: 0000 +CONSTANT: key-error-roll-over HEX: 0001 +CONSTANT: key-error-post-fail HEX: 0002 +CONSTANT: key-error-undefined HEX: 0003 +CONSTANT: key-a HEX: 0004 +CONSTANT: key-b HEX: 0005 +CONSTANT: key-c HEX: 0006 +CONSTANT: key-d HEX: 0007 +CONSTANT: key-e HEX: 0008 +CONSTANT: key-f HEX: 0009 +CONSTANT: key-g HEX: 000a +CONSTANT: key-h HEX: 000b +CONSTANT: key-i HEX: 000c +CONSTANT: key-j HEX: 000d +CONSTANT: key-k HEX: 000e +CONSTANT: key-l HEX: 000f +CONSTANT: key-m HEX: 0010 +CONSTANT: key-n HEX: 0011 +CONSTANT: key-o HEX: 0012 +CONSTANT: key-p HEX: 0013 +CONSTANT: key-q HEX: 0014 +CONSTANT: key-r HEX: 0015 +CONSTANT: key-s HEX: 0016 +CONSTANT: key-t HEX: 0017 +CONSTANT: key-u HEX: 0018 +CONSTANT: key-v HEX: 0019 +CONSTANT: key-w HEX: 001a +CONSTANT: key-x HEX: 001b +CONSTANT: key-y HEX: 001c +CONSTANT: key-z HEX: 001d +CONSTANT: key-1 HEX: 001e +CONSTANT: key-2 HEX: 001f +CONSTANT: key-3 HEX: 0020 +CONSTANT: key-4 HEX: 0021 +CONSTANT: key-5 HEX: 0022 +CONSTANT: key-6 HEX: 0023 +CONSTANT: key-7 HEX: 0024 +CONSTANT: key-8 HEX: 0025 +CONSTANT: key-9 HEX: 0026 +CONSTANT: key-0 HEX: 0027 +CONSTANT: key-return HEX: 0028 +CONSTANT: key-escape HEX: 0029 +CONSTANT: key-backspace HEX: 002a +CONSTANT: key-tab HEX: 002b +CONSTANT: key-space HEX: 002c +CONSTANT: key-- HEX: 002d +CONSTANT: key-= HEX: 002e +CONSTANT: key-[ HEX: 002f +CONSTANT: key-] HEX: 0030 +CONSTANT: key-\ HEX: 0031 +CONSTANT: key-#-non-us HEX: 0032 +CONSTANT: key-; HEX: 0033 +CONSTANT: key-' HEX: 0034 +CONSTANT: key-` HEX: 0035 +CONSTANT: key-, HEX: 0036 +CONSTANT: key-. HEX: 0037 +CONSTANT: key-/ HEX: 0038 +CONSTANT: key-caps-lock HEX: 0039 +CONSTANT: key-f1 HEX: 003a +CONSTANT: key-f2 HEX: 003b +CONSTANT: key-f3 HEX: 003c +CONSTANT: key-f4 HEX: 003d +CONSTANT: key-f5 HEX: 003e +CONSTANT: key-f6 HEX: 003f +CONSTANT: key-f7 HEX: 0040 +CONSTANT: key-f8 HEX: 0041 +CONSTANT: key-f9 HEX: 0042 +CONSTANT: key-f10 HEX: 0043 +CONSTANT: key-f11 HEX: 0044 +CONSTANT: key-f12 HEX: 0045 +CONSTANT: key-print-screen HEX: 0046 +CONSTANT: key-scroll-lock HEX: 0047 +CONSTANT: key-pause HEX: 0048 +CONSTANT: key-insert HEX: 0049 +CONSTANT: key-home HEX: 004a +CONSTANT: key-page-up HEX: 004b +CONSTANT: key-delete HEX: 004c +CONSTANT: key-end HEX: 004d +CONSTANT: key-page-down HEX: 004e +CONSTANT: key-right-arrow HEX: 004f +CONSTANT: key-left-arrow HEX: 0050 +CONSTANT: key-down-arrow HEX: 0051 +CONSTANT: key-up-arrow HEX: 0052 +CONSTANT: key-keypad-numlock HEX: 0053 +CONSTANT: key-keypad-/ HEX: 0054 +CONSTANT: key-keypad-* HEX: 0055 +CONSTANT: key-keypad-- HEX: 0056 +CONSTANT: key-keypad-+ HEX: 0057 +CONSTANT: key-keypad-enter HEX: 0058 +CONSTANT: key-keypad-1 HEX: 0059 +CONSTANT: key-keypad-2 HEX: 005a +CONSTANT: key-keypad-3 HEX: 005b +CONSTANT: key-keypad-4 HEX: 005c +CONSTANT: key-keypad-5 HEX: 005d +CONSTANT: key-keypad-6 HEX: 005e +CONSTANT: key-keypad-7 HEX: 005f +CONSTANT: key-keypad-8 HEX: 0060 +CONSTANT: key-keypad-9 HEX: 0061 +CONSTANT: key-keypad-0 HEX: 0062 +CONSTANT: key-keypad-. HEX: 0063 +CONSTANT: key-\-non-us HEX: 0064 +CONSTANT: key-application HEX: 0065 +CONSTANT: key-power HEX: 0066 +CONSTANT: key-keypad-= HEX: 0067 +CONSTANT: key-f13 HEX: 0068 +CONSTANT: key-f14 HEX: 0069 +CONSTANT: key-f15 HEX: 006a +CONSTANT: key-f16 HEX: 006b +CONSTANT: key-f17 HEX: 006c +CONSTANT: key-f18 HEX: 006d +CONSTANT: key-f19 HEX: 006e +CONSTANT: key-f20 HEX: 006f +CONSTANT: key-f21 HEX: 0070 +CONSTANT: key-f22 HEX: 0071 +CONSTANT: key-f23 HEX: 0072 +CONSTANT: key-f24 HEX: 0073 +CONSTANT: key-execute HEX: 0074 +CONSTANT: key-help HEX: 0075 +CONSTANT: key-menu HEX: 0076 +CONSTANT: key-select HEX: 0077 +CONSTANT: key-stop HEX: 0078 +CONSTANT: key-again HEX: 0079 +CONSTANT: key-undo HEX: 007a +CONSTANT: key-cut HEX: 007b +CONSTANT: key-copy HEX: 007c +CONSTANT: key-paste HEX: 007d +CONSTANT: key-find HEX: 007e +CONSTANT: key-mute HEX: 007f +CONSTANT: key-volume-up HEX: 0080 +CONSTANT: key-volume-down HEX: 0081 +CONSTANT: key-locking-caps-lock HEX: 0082 +CONSTANT: key-locking-num-lock HEX: 0083 +CONSTANT: key-locking-scroll-lock HEX: 0084 +CONSTANT: key-keypad-, HEX: 0085 +CONSTANT: key-keypad-=-as-400 HEX: 0086 +CONSTANT: key-international-1 HEX: 0087 +CONSTANT: key-international-2 HEX: 0088 +CONSTANT: key-international-3 HEX: 0089 +CONSTANT: key-international-4 HEX: 008a +CONSTANT: key-international-5 HEX: 008b +CONSTANT: key-international-6 HEX: 008c +CONSTANT: key-international-7 HEX: 008d +CONSTANT: key-international-8 HEX: 008e +CONSTANT: key-international-9 HEX: 008f +CONSTANT: key-lang-1 HEX: 0090 +CONSTANT: key-lang-2 HEX: 0091 +CONSTANT: key-lang-3 HEX: 0092 +CONSTANT: key-lang-4 HEX: 0093 +CONSTANT: key-lang-5 HEX: 0094 +CONSTANT: key-lang-6 HEX: 0095 +CONSTANT: key-lang-7 HEX: 0096 +CONSTANT: key-lang-8 HEX: 0097 +CONSTANT: key-lang-9 HEX: 0098 +CONSTANT: key-alternate-erase HEX: 0099 +CONSTANT: key-sysreq HEX: 009a +CONSTANT: key-cancel HEX: 009b +CONSTANT: key-clear HEX: 009c +CONSTANT: key-prior HEX: 009d +CONSTANT: key-enter HEX: 009e +CONSTANT: key-separator HEX: 009f +CONSTANT: key-out HEX: 00a0 +CONSTANT: key-oper HEX: 00a1 +CONSTANT: key-clear-again HEX: 00a2 +CONSTANT: key-crsel-props HEX: 00a3 +CONSTANT: key-exsel HEX: 00a4 +CONSTANT: key-left-control HEX: 00e0 +CONSTANT: key-left-shift HEX: 00e1 +CONSTANT: key-left-alt HEX: 00e2 +CONSTANT: key-left-gui HEX: 00e3 +CONSTANT: key-right-control HEX: 00e4 +CONSTANT: key-right-shift HEX: 00e5 +CONSTANT: key-right-alt HEX: 00e6 +CONSTANT: key-right-gui HEX: 00e7 From adf6e97e175c357a29ccfaa427df82761318b49b Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 17:58:14 -0600 Subject: [PATCH 38/85] use CONSTANT: --- extra/asn1/ldap/ldap.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extra/asn1/ldap/ldap.factor b/extra/asn1/ldap/ldap.factor index 8e93b140bf..449c9dcbd0 100644 --- a/extra/asn1/ldap/ldap.factor +++ b/extra/asn1/ldap/ldap.factor @@ -3,9 +3,9 @@ IN: asn1.ldap -: SearchScope_BaseObject 0 ; inline -: SearchScope_SingleLevel 1 ; inline -: SearchScope_WholeSubtree 2 ; inline +CONSTANT: SearchScope_BaseObject 0 +CONSTANT: SearchScope_SingleLevel 1 +CONSTANT: SearchScope_WholeSubtree 2 : asn-syntax ( -- hashtable ) H{ From 7aa8e7320d1876ef86de87ea6fc79cf2bd2518e3 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 18:00:43 -0600 Subject: [PATCH 39/85] use CONSTANT: --- extra/game-input/iokit/iokit.factor | 44 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/extra/game-input/iokit/iokit.factor b/extra/game-input/iokit/iokit.factor index 26f2c40464..8a10535306 100755 --- a/extra/game-input/iokit/iokit.factor +++ b/extra/game-input/iokit/iokit.factor @@ -21,33 +21,33 @@ iokit-game-input-backend game-input-backend set-global [ &CFRelease NSFastEnumeration>vector ] [ f ] if* ] with-destructors ; -: game-devices-matching-seq +CONSTANT: game-devices-matching-seq { H{ { "DeviceUsage" 4 } { "DeviceUsagePage" 1 } } ! joysticks H{ { "DeviceUsage" 5 } { "DeviceUsagePage" 1 } } ! gamepads H{ { "DeviceUsage" 6 } { "DeviceUsagePage" 1 } } ! keyboards - } ; inline + } -: buttons-matching-hash - H{ { "UsagePage" 9 } { "Type" 2 } } ; inline -: keys-matching-hash - H{ { "UsagePage" 7 } { "Type" 2 } } ; inline -: x-axis-matching-hash - H{ { "UsagePage" 1 } { "Usage" HEX: 30 } { "Type" 1 } } ; inline -: y-axis-matching-hash - H{ { "UsagePage" 1 } { "Usage" HEX: 31 } { "Type" 1 } } ; inline -: z-axis-matching-hash - H{ { "UsagePage" 1 } { "Usage" HEX: 32 } { "Type" 1 } } ; inline -: rx-axis-matching-hash - H{ { "UsagePage" 1 } { "Usage" HEX: 33 } { "Type" 1 } } ; inline -: ry-axis-matching-hash - H{ { "UsagePage" 1 } { "Usage" HEX: 34 } { "Type" 1 } } ; inline -: rz-axis-matching-hash - H{ { "UsagePage" 1 } { "Usage" HEX: 35 } { "Type" 1 } } ; inline -: slider-matching-hash - H{ { "UsagePage" 1 } { "Usage" HEX: 36 } { "Type" 1 } } ; inline -: hat-switch-matching-hash - H{ { "UsagePage" 1 } { "Usage" HEX: 39 } { "Type" 1 } } ; inline +CONSTANT: buttons-matching-hash + H{ { "UsagePage" 9 } { "Type" 2 } } +CONSTANT: keys-matching-hash + H{ { "UsagePage" 7 } { "Type" 2 } } +CONSTANT: x-axis-matching-hash + H{ { "UsagePage" 1 } { "Usage" HEX: 30 } { "Type" 1 } } +CONSTANT: y-axis-matching-hash + H{ { "UsagePage" 1 } { "Usage" HEX: 31 } { "Type" 1 } } +CONSTANT: z-axis-matching-hash + H{ { "UsagePage" 1 } { "Usage" HEX: 32 } { "Type" 1 } } +CONSTANT: rx-axis-matching-hash + H{ { "UsagePage" 1 } { "Usage" HEX: 33 } { "Type" 1 } } +CONSTANT: ry-axis-matching-hash + H{ { "UsagePage" 1 } { "Usage" HEX: 34 } { "Type" 1 } } +CONSTANT: rz-axis-matching-hash + H{ { "UsagePage" 1 } { "Usage" HEX: 35 } { "Type" 1 } } +CONSTANT: slider-matching-hash + H{ { "UsagePage" 1 } { "Usage" HEX: 36 } { "Type" 1 } } +CONSTANT: hat-switch-matching-hash + H{ { "UsagePage" 1 } { "Usage" HEX: 39 } { "Type" 1 } } : device-elements-matching ( device matching-hash -- vector ) [ From 0e91003e19316533c39d8ebb1dd5381663b91474 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 18:04:52 -0600 Subject: [PATCH 40/85] use CONSTANT: --- basis/x11/xlib/xlib.factor | 424 ++++++++++++++++++------------------- 1 file changed, 212 insertions(+), 212 deletions(-) diff --git a/basis/x11/xlib/xlib.factor b/basis/x11/xlib/xlib.factor index f86c24b845..d9a7380593 100644 --- a/basis/x11/xlib/xlib.factor +++ b/basis/x11/xlib/xlib.factor @@ -131,19 +131,19 @@ C-STRUCT: XSetWindowAttributes { "Colormap" "colormap" } { "Cursor" "cursor" } ; -: UnmapGravity 0 ; inline +CONSTANT: UnmapGravity 0 -: ForgetGravity 0 ; inline -: NorthWestGravity 1 ; inline -: NorthGravity 2 ; inline -: NorthEastGravity 3 ; inline -: WestGravity 4 ; inline -: CenterGravity 5 ; inline -: EastGravity 6 ; inline -: SouthWestGravity 7 ; inline -: SouthGravity 8 ; inline -: SouthEastGravity 9 ; inline -: StaticGravity 10 ; inline +CONSTANT: ForgetGravity 0 +CONSTANT: NorthWestGravity 1 +CONSTANT: NorthGravity 2 +CONSTANT: NorthEastGravity 3 +CONSTANT: WestGravity 4 +CONSTANT: CenterGravity 5 +CONSTANT: EastGravity 6 +CONSTANT: SouthWestGravity 7 +CONSTANT: SouthGravity 8 +CONSTANT: SouthEastGravity 9 +CONSTANT: StaticGravity 10 ! 3.3 - Creating Windows @@ -238,9 +238,9 @@ C-STRUCT: XWindowAttributes FUNCTION: Status XGetWindowAttributes ( Display* display, Window w, XWindowAttributes* attr ) ; -: IsUnmapped 0 ; inline -: IsUnviewable 1 ; inline -: IsViewable 2 ; inline +CONSTANT: IsUnmapped 0 +CONSTANT: IsUnviewable 1 +CONSTANT: IsViewable 2 FUNCTION: Status XGetGeometry ( Display* display, @@ -336,22 +336,22 @@ FUNCTION: Colormap XCreateColormap ( Display* display, Window w, Visual* visual, : GCDashList ( -- n ) 21 2^ ; inline : GCArcMode ( -- n ) 22 2^ ; inline -: GXclear HEX: 0 ; inline -: GXand HEX: 1 ; inline -: GXandReverse HEX: 2 ; inline -: GXcopy HEX: 3 ; inline -: GXandInverted HEX: 4 ; inline -: GXnoop HEX: 5 ; inline -: GXxor HEX: 6 ; inline -: GXor HEX: 7 ; inline -: GXnor HEX: 8 ; inline -: GXequiv HEX: 9 ; inline -: GXinvert HEX: a ; inline -: GXorReverse HEX: b ; inline -: GXcopyInverted HEX: c ; inline -: GXorInverted HEX: d ; inline -: GXnand HEX: e ; inline -: GXset HEX: f ; inline +CONSTANT: GXclear HEX: 0 +CONSTANT: GXand HEX: 1 +CONSTANT: GXandReverse HEX: 2 +CONSTANT: GXcopy HEX: 3 +CONSTANT: GXandInverted HEX: 4 +CONSTANT: GXnoop HEX: 5 +CONSTANT: GXxor HEX: 6 +CONSTANT: GXor HEX: 7 +CONSTANT: GXnor HEX: 8 +CONSTANT: GXequiv HEX: 9 +CONSTANT: GXinvert HEX: a +CONSTANT: GXorReverse HEX: b +CONSTANT: GXcopyInverted HEX: c +CONSTANT: GXorInverted HEX: d +CONSTANT: GXnand HEX: e +CONSTANT: GXset HEX: f C-STRUCT: XGCValues { "int" "function" } @@ -532,40 +532,40 @@ FUNCTION: Status XKillClient ( Display* display, XID resource ) ; : ColormapChangeMask ( -- n ) 23 2^ ; inline : OwnerGrabButtonMask ( -- n ) 24 2^ ; inline -: KeyPress 2 ; inline -: KeyRelease 3 ; inline -: ButtonPress 4 ; inline -: ButtonRelease 5 ; inline -: MotionNotify 6 ; inline -: EnterNotify 7 ; inline -: LeaveNotify 8 ; inline -: FocusIn 9 ; inline -: FocusOut 10 ; inline -: KeymapNotify 11 ; inline -: Expose 12 ; inline -: GraphicsExpose 13 ; inline -: NoExpose 14 ; inline -: VisibilityNotify 15 ; inline -: CreateNotify 16 ; inline -: DestroyNotify 17 ; inline -: UnmapNotify 18 ; inline -: MapNotify 19 ; inline -: MapRequest 20 ; inline -: ReparentNotify 21 ; inline -: ConfigureNotify 22 ; inline -: ConfigureRequest 23 ; inline -: GravityNotify 24 ; inline -: ResizeRequest 25 ; inline -: CirculateNotify 26 ; inline -: CirculateRequest 27 ; inline -: PropertyNotify 28 ; inline -: SelectionClear 29 ; inline -: SelectionRequest 30 ; inline -: SelectionNotify 31 ; inline -: ColormapNotify 32 ; inline -: ClientMessage 33 ; inline -: MappingNotify 34 ; inline -: LASTEvent 35 ; inline +CONSTANT: KeyPress 2 +CONSTANT: KeyRelease 3 +CONSTANT: ButtonPress 4 +CONSTANT: ButtonRelease 5 +CONSTANT: MotionNotify 6 +CONSTANT: EnterNotify 7 +CONSTANT: LeaveNotify 8 +CONSTANT: FocusIn 9 +CONSTANT: FocusOut 10 +CONSTANT: KeymapNotify 11 +CONSTANT: Expose 12 +CONSTANT: GraphicsExpose 13 +CONSTANT: NoExpose 14 +CONSTANT: VisibilityNotify 15 +CONSTANT: CreateNotify 16 +CONSTANT: DestroyNotify 17 +CONSTANT: UnmapNotify 18 +CONSTANT: MapNotify 19 +CONSTANT: MapRequest 20 +CONSTANT: ReparentNotify 21 +CONSTANT: ConfigureNotify 22 +CONSTANT: ConfigureRequest 23 +CONSTANT: GravityNotify 24 +CONSTANT: ResizeRequest 25 +CONSTANT: CirculateNotify 26 +CONSTANT: CirculateRequest 27 +CONSTANT: PropertyNotify 28 +CONSTANT: SelectionClear 29 +CONSTANT: SelectionRequest 30 +CONSTANT: SelectionNotify 31 +CONSTANT: ColormapNotify 32 +CONSTANT: ClientMessage 33 +CONSTANT: MappingNotify 34 +CONSTANT: LASTEvent 35 C-STRUCT: XAnyEvent { "int" "type" } @@ -578,11 +578,11 @@ C-STRUCT: XAnyEvent ! 10.5 Keyboard and Pointer Events -: Button1 1 ; inline -: Button2 2 ; inline -: Button3 3 ; inline -: Button4 4 ; inline -: Button5 5 ; inline +CONSTANT: Button1 1 +CONSTANT: Button2 2 +CONSTANT: Button3 3 +CONSTANT: Button4 4 +CONSTANT: Button5 5 : Button1Mask ( -- n ) 1 8 shift ; inline : Button2Mask ( -- n ) 1 9 shift ; inline @@ -1199,17 +1199,17 @@ FUNCTION: int XLookupString ( ! 16.7 Determining the Appropriate Visual Type -: VisualNoMask HEX: 0 ; inline -: VisualIDMask HEX: 1 ; inline -: VisualScreenMask HEX: 2 ; inline -: VisualDepthMask HEX: 4 ; inline -: VisualClassMask HEX: 8 ; inline -: VisualRedMaskMask HEX: 10 ; inline -: VisualGreenMaskMask HEX: 20 ; inline -: VisualBlueMaskMask HEX: 40 ; inline -: VisualColormapSizeMask HEX: 80 ; inline -: VisualBitsPerRGBMask HEX: 100 ; inline -: VisualAllMask HEX: 1FF ; inline +CONSTANT: VisualNoMask HEX: 0 +CONSTANT: VisualIDMask HEX: 1 +CONSTANT: VisualScreenMask HEX: 2 +CONSTANT: VisualDepthMask HEX: 4 +CONSTANT: VisualClassMask HEX: 8 +CONSTANT: VisualRedMaskMask HEX: 10 +CONSTANT: VisualGreenMaskMask HEX: 20 +CONSTANT: VisualBlueMaskMask HEX: 40 +CONSTANT: VisualColormapSizeMask HEX: 80 +CONSTANT: VisualBitsPerRGBMask HEX: 100 +CONSTANT: VisualAllMask HEX: 1FF C-STRUCT: XVisualInfo { "Visual*" "visual" } @@ -1239,76 +1239,76 @@ FUNCTION: Status XSetStandardProperties ( ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -: XA_PRIMARY 1 ; inline -: XA_SECONDARY 2 ; inline -: XA_ARC 3 ; inline -: XA_ATOM 4 ; inline -: XA_BITMAP 5 ; inline -: XA_CARDINAL 6 ; inline -: XA_COLORMAP 7 ; inline -: XA_CURSOR 8 ; inline -: XA_CUT_BUFFER0 9 ; inline -: XA_CUT_BUFFER1 10 ; inline -: XA_CUT_BUFFER2 11 ; inline -: XA_CUT_BUFFER3 12 ; inline -: XA_CUT_BUFFER4 13 ; inline -: XA_CUT_BUFFER5 14 ; inline -: XA_CUT_BUFFER6 15 ; inline -: XA_CUT_BUFFER7 16 ; inline -: XA_DRAWABLE 17 ; inline -: XA_FONT 18 ; inline -: XA_INTEGER 19 ; inline -: XA_PIXMAP 20 ; inline -: XA_POINT 21 ; inline -: XA_RECTANGLE 22 ; inline -: XA_RESOURCE_MANAGER 23 ; inline -: XA_RGB_COLOR_MAP 24 ; inline -: XA_RGB_BEST_MAP 25 ; inline -: XA_RGB_BLUE_MAP 26 ; inline -: XA_RGB_DEFAULT_MAP 27 ; inline -: XA_RGB_GRAY_MAP 28 ; inline -: XA_RGB_GREEN_MAP 29 ; inline -: XA_RGB_RED_MAP 30 ; inline -: XA_STRING 31 ; inline -: XA_VISUALID 32 ; inline -: XA_WINDOW 33 ; inline -: XA_WM_COMMAND 34 ; inline -: XA_WM_HINTS 35 ; inline -: XA_WM_CLIENT_MACHINE 36 ; inline -: XA_WM_ICON_NAME 37 ; inline -: XA_WM_ICON_SIZE 38 ; inline -: XA_WM_NAME 39 ; inline -: XA_WM_NORMAL_HINTS 40 ; inline -: XA_WM_SIZE_HINTS 41 ; inline -: XA_WM_ZOOM_HINTS 42 ; inline -: XA_MIN_SPACE 43 ; inline -: XA_NORM_SPACE 44 ; inline -: XA_MAX_SPACE 45 ; inline -: XA_END_SPACE 46 ; inline -: XA_SUPERSCRIPT_X 47 ; inline -: XA_SUPERSCRIPT_Y 48 ; inline -: XA_SUBSCRIPT_X 49 ; inline -: XA_SUBSCRIPT_Y 50 ; inline -: XA_UNDERLINE_POSITION 51 ; inline -: XA_UNDERLINE_THICKNESS 52 ; inline -: XA_STRIKEOUT_ASCENT 53 ; inline -: XA_STRIKEOUT_DESCENT 54 ; inline -: XA_ITALIC_ANGLE 55 ; inline -: XA_X_HEIGHT 56 ; inline -: XA_QUAD_WIDTH 57 ; inline -: XA_WEIGHT 58 ; inline -: XA_POINT_SIZE 59 ; inline -: XA_RESOLUTION 60 ; inline -: XA_COPYRIGHT 61 ; inline -: XA_NOTICE 62 ; inline -: XA_FONT_NAME 63 ; inline -: XA_FAMILY_NAME 64 ; inline -: XA_FULL_NAME 65 ; inline -: XA_CAP_HEIGHT 66 ; inline -: XA_WM_CLASS 67 ; inline -: XA_WM_TRANSIENT_FOR 68 ; inline +CONSTANT: XA_PRIMARY 1 +CONSTANT: XA_SECONDARY 2 +CONSTANT: XA_ARC 3 +CONSTANT: XA_ATOM 4 +CONSTANT: XA_BITMAP 5 +CONSTANT: XA_CARDINAL 6 +CONSTANT: XA_COLORMAP 7 +CONSTANT: XA_CURSOR 8 +CONSTANT: XA_CUT_BUFFER0 9 +CONSTANT: XA_CUT_BUFFER1 10 +CONSTANT: XA_CUT_BUFFER2 11 +CONSTANT: XA_CUT_BUFFER3 12 +CONSTANT: XA_CUT_BUFFER4 13 +CONSTANT: XA_CUT_BUFFER5 14 +CONSTANT: XA_CUT_BUFFER6 15 +CONSTANT: XA_CUT_BUFFER7 16 +CONSTANT: XA_DRAWABLE 17 +CONSTANT: XA_FONT 18 +CONSTANT: XA_INTEGER 19 +CONSTANT: XA_PIXMAP 20 +CONSTANT: XA_POINT 21 +CONSTANT: XA_RECTANGLE 22 +CONSTANT: XA_RESOURCE_MANAGER 23 +CONSTANT: XA_RGB_COLOR_MAP 24 +CONSTANT: XA_RGB_BEST_MAP 25 +CONSTANT: XA_RGB_BLUE_MAP 26 +CONSTANT: XA_RGB_DEFAULT_MAP 27 +CONSTANT: XA_RGB_GRAY_MAP 28 +CONSTANT: XA_RGB_GREEN_MAP 29 +CONSTANT: XA_RGB_RED_MAP 30 +CONSTANT: XA_STRING 31 +CONSTANT: XA_VISUALID 32 +CONSTANT: XA_WINDOW 33 +CONSTANT: XA_WM_COMMAND 34 +CONSTANT: XA_WM_HINTS 35 +CONSTANT: XA_WM_CLIENT_MACHINE 36 +CONSTANT: XA_WM_ICON_NAME 37 +CONSTANT: XA_WM_ICON_SIZE 38 +CONSTANT: XA_WM_NAME 39 +CONSTANT: XA_WM_NORMAL_HINTS 40 +CONSTANT: XA_WM_SIZE_HINTS 41 +CONSTANT: XA_WM_ZOOM_HINTS 42 +CONSTANT: XA_MIN_SPACE 43 +CONSTANT: XA_NORM_SPACE 44 +CONSTANT: XA_MAX_SPACE 45 +CONSTANT: XA_END_SPACE 46 +CONSTANT: XA_SUPERSCRIPT_X 47 +CONSTANT: XA_SUPERSCRIPT_Y 48 +CONSTANT: XA_SUBSCRIPT_X 49 +CONSTANT: XA_SUBSCRIPT_Y 50 +CONSTANT: XA_UNDERLINE_POSITION 51 +CONSTANT: XA_UNDERLINE_THICKNESS 52 +CONSTANT: XA_STRIKEOUT_ASCENT 53 +CONSTANT: XA_STRIKEOUT_DESCENT 54 +CONSTANT: XA_ITALIC_ANGLE 55 +CONSTANT: XA_X_HEIGHT 56 +CONSTANT: XA_QUAD_WIDTH 57 +CONSTANT: XA_WEIGHT 58 +CONSTANT: XA_POINT_SIZE 59 +CONSTANT: XA_RESOLUTION 60 +CONSTANT: XA_COPYRIGHT 61 +CONSTANT: XA_NOTICE 62 +CONSTANT: XA_FONT_NAME 63 +CONSTANT: XA_FAMILY_NAME 64 +CONSTANT: XA_FULL_NAME 65 +CONSTANT: XA_CAP_HEIGHT 66 +CONSTANT: XA_WM_CLASS 67 +CONSTANT: XA_WM_TRANSIENT_FOR 68 -: XA_LAST_PREDEFINED 68 ; inline +CONSTANT: XA_LAST_PREDEFINED 68 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! The rest of the stuff is not from the book. @@ -1321,65 +1321,65 @@ FUNCTION: int XBell ( Display* display, int percent ) ; ! !!! INPUT METHODS -: XIMPreeditArea HEX: 0001 ; inline -: XIMPreeditCallbacks HEX: 0002 ; inline -: XIMPreeditPosition HEX: 0004 ; inline -: XIMPreeditNothing HEX: 0008 ; inline -: XIMPreeditNone HEX: 0010 ; inline -: XIMStatusArea HEX: 0100 ; inline -: XIMStatusCallbacks HEX: 0200 ; inline -: XIMStatusNothing HEX: 0400 ; inline -: XIMStatusNone HEX: 0800 ; inline +CONSTANT: XIMPreeditArea HEX: 0001 +CONSTANT: XIMPreeditCallbacks HEX: 0002 +CONSTANT: XIMPreeditPosition HEX: 0004 +CONSTANT: XIMPreeditNothing HEX: 0008 +CONSTANT: XIMPreeditNone HEX: 0010 +CONSTANT: XIMStatusArea HEX: 0100 +CONSTANT: XIMStatusCallbacks HEX: 0200 +CONSTANT: XIMStatusNothing HEX: 0400 +CONSTANT: XIMStatusNone HEX: 0800 -: XNVaNestedList "XNVaNestedList" ; -: XNQueryInputStyle "queryInputStyle" ; -: XNClientWindow "clientWindow" ; -: XNInputStyle "inputStyle" ; -: XNFocusWindow "focusWindow" ; -: XNResourceName "resourceName" ; -: XNResourceClass "resourceClass" ; -: XNGeometryCallback "geometryCallback" ; -: XNDestroyCallback "destroyCallback" ; -: XNFilterEvents "filterEvents" ; -: XNPreeditStartCallback "preeditStartCallback" ; -: XNPreeditDoneCallback "preeditDoneCallback" ; -: XNPreeditDrawCallback "preeditDrawCallback" ; -: XNPreeditCaretCallback "preeditCaretCallback" ; -: XNPreeditStateNotifyCallback "preeditStateNotifyCallback" ; -: XNPreeditAttributes "preeditAttributes" ; -: XNStatusStartCallback "statusStartCallback" ; -: XNStatusDoneCallback "statusDoneCallback" ; -: XNStatusDrawCallback "statusDrawCallback" ; -: XNStatusAttributes "statusAttributes" ; -: XNArea "area" ; -: XNAreaNeeded "areaNeeded" ; -: XNSpotLocation "spotLocation" ; -: XNColormap "colorMap" ; -: XNStdColormap "stdColorMap" ; -: XNForeground "foreground" ; -: XNBackground "background" ; -: XNBackgroundPixmap "backgroundPixmap" ; -: XNFontSet "fontSet" ; -: XNLineSpace "lineSpace" ; -: XNCursor "cursor" ; +CONSTANT: XNVaNestedList "XNVaNestedList" +CONSTANT: XNQueryInputStyle "queryInputStyle" +CONSTANT: XNClientWindow "clientWindow" +CONSTANT: XNInputStyle "inputStyle" +CONSTANT: XNFocusWindow "focusWindow" +CONSTANT: XNResourceName "resourceName" +CONSTANT: XNResourceClass "resourceClass" +CONSTANT: XNGeometryCallback "geometryCallback" +CONSTANT: XNDestroyCallback "destroyCallback" +CONSTANT: XNFilterEvents "filterEvents" +CONSTANT: XNPreeditStartCallback "preeditStartCallback" +CONSTANT: XNPreeditDoneCallback "preeditDoneCallback" +CONSTANT: XNPreeditDrawCallback "preeditDrawCallback" +CONSTANT: XNPreeditCaretCallback "preeditCaretCallback" +CONSTANT: XNPreeditStateNotifyCallback "preeditStateNotifyCallback" +CONSTANT: XNPreeditAttributes "preeditAttributes" +CONSTANT: XNStatusStartCallback "statusStartCallback" +CONSTANT: XNStatusDoneCallback "statusDoneCallback" +CONSTANT: XNStatusDrawCallback "statusDrawCallback" +CONSTANT: XNStatusAttributes "statusAttributes" +CONSTANT: XNArea "area" +CONSTANT: XNAreaNeeded "areaNeeded" +CONSTANT: XNSpotLocation "spotLocation" +CONSTANT: XNColormap "colorMap" +CONSTANT: XNStdColormap "stdColorMap" +CONSTANT: XNForeground "foreground" +CONSTANT: XNBackground "background" +CONSTANT: XNBackgroundPixmap "backgroundPixmap" +CONSTANT: XNFontSet "fontSet" +CONSTANT: XNLineSpace "lineSpace" +CONSTANT: XNCursor "cursor" -: XNQueryIMValuesList "queryIMValuesList" ; -: XNQueryICValuesList "queryICValuesList" ; -: XNVisiblePosition "visiblePosition" ; -: XNR6PreeditCallback "r6PreeditCallback" ; -: XNStringConversionCallback "stringConversionCallback" ; -: XNStringConversion "stringConversion" ; -: XNResetState "resetState" ; -: XNHotKey "hotKey" ; -: XNHotKeyState "hotKeyState" ; -: XNPreeditState "preeditState" ; -: XNSeparatorofNestedList "separatorofNestedList" ; +CONSTANT: XNQueryIMValuesList "queryIMValuesList" +CONSTANT: XNQueryICValuesList "queryICValuesList" +CONSTANT: XNVisiblePosition "visiblePosition" +CONSTANT: XNR6PreeditCallback "r6PreeditCallback" +CONSTANT: XNStringConversionCallback "stringConversionCallback" +CONSTANT: XNStringConversion "stringConversion" +CONSTANT: XNResetState "resetState" +CONSTANT: XNHotKey "hotKey" +CONSTANT: XNHotKeyState "hotKeyState" +CONSTANT: XNPreeditState "preeditState" +CONSTANT: XNSeparatorofNestedList "separatorofNestedList" -: XBufferOverflow -1 ; -: XLookupNone 1 ; -: XLookupChars 2 ; -: XLookupKeySym 3 ; -: XLookupBoth 4 ; +CONSTANT: XBufferOverflow -1 +CONSTANT: XLookupNone 1 +CONSTANT: XLookupChars 2 +CONSTANT: XLookupKeySym 3 +CONSTANT: XLookupBoth 4 FUNCTION: Bool XFilterEvent ( XEvent* event, Window w ) ; @@ -1400,12 +1400,12 @@ FUNCTION: int XwcLookupString ( XIC ic, XKeyPressedEvent* event, ulong* buffer_r FUNCTION: int Xutf8LookupString ( XIC ic, XKeyPressedEvent* event, char* buffer_return, int bytes_buffer, KeySym* keysym_return, Status* status_return ) ; ! !!! category of setlocale -: LC_ALL 0 ; inline -: LC_COLLATE 1 ; inline -: LC_CTYPE 2 ; inline -: LC_MONETARY 3 ; inline -: LC_NUMERIC 4 ; inline -: LC_TIME 5 ; inline +CONSTANT: LC_ALL 0 +CONSTANT: LC_COLLATE 1 +CONSTANT: LC_CTYPE 2 +CONSTANT: LC_MONETARY 3 +CONSTANT: LC_NUMERIC 4 +CONSTANT: LC_TIME 5 FUNCTION: char* setlocale ( int category, char* name ) ; From 58abcec1276319a449f38a93747d0a3a4155241c Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 18:09:10 -0600 Subject: [PATCH 41/85] use CONSTANT: in win32 bindings --- basis/windows/user32/user32.factor | 605 ++++++++++++++--------------- 1 file changed, 302 insertions(+), 303 deletions(-) diff --git a/basis/windows/user32/user32.factor b/basis/windows/user32/user32.factor index e2e2c7e150..9daac21697 100644 --- a/basis/windows/user32/user32.factor +++ b/basis/windows/user32/user32.factor @@ -150,377 +150,377 @@ CONSTANT: PM_NOYIELD 2 ! ! Standard Cursor IDs ! -: IDC_ARROW 32512 ; inline -: IDC_IBEAM 32513 ; inline -: IDC_WAIT 32514 ; inline -: IDC_CROSS 32515 ; inline -: IDC_UPARROW 32516 ; inline -: IDC_SIZE 32640 ; inline ! OBSOLETE: use IDC_SIZEALL -: IDC_ICON 32641 ; inline ! OBSOLETE: use IDC_ARROW -: IDC_SIZENWSE 32642 ; inline -: IDC_SIZENESW 32643 ; inline -: IDC_SIZEWE 32644 ; inline -: IDC_SIZENS 32645 ; inline -: IDC_SIZEALL 32646 ; inline -: IDC_NO 32648 ; inline ! not in win3.1 -: IDC_HAND 32649 ; inline -: IDC_APPSTARTING 32650 ; inline ! not in win3.1 -: IDC_HELP 32651 ; inline +CONSTANT: IDC_ARROW 32512 +CONSTANT: IDC_IBEAM 32513 +CONSTANT: IDC_WAIT 32514 +CONSTANT: IDC_CROSS 32515 +CONSTANT: IDC_UPARROW 32516 +CONSTANT: IDC_SIZE 32640 ! OBSOLETE: use IDC_SIZEALL +CONSTANT: IDC_ICON 32641 ! OBSOLETE: use IDC_ARROW +CONSTANT: IDC_SIZENWSE 32642 +CONSTANT: IDC_SIZENESW 32643 +CONSTANT: IDC_SIZEWE 32644 +CONSTANT: IDC_SIZENS 32645 +CONSTANT: IDC_SIZEALL 32646 +CONSTANT: IDC_NO 32648 ! not in win3.1 +CONSTANT: IDC_HAND 32649 +CONSTANT: IDC_APPSTARTING 32650 ! not in win3.1 +CONSTANT: IDC_HELP 32651 ! Predefined Clipboard Formats -: CF_TEXT 1 ; inline -: CF_BITMAP 2 ; inline -: CF_METAFILEPICT 3 ; inline -: CF_SYLK 4 ; inline -: CF_DIF 5 ; inline -: CF_TIFF 6 ; inline -: CF_OEMTEXT 7 ; inline -: CF_DIB 8 ; inline -: CF_PALETTE 9 ; inline -: CF_PENDATA 10 ; inline -: CF_RIFF 11 ; inline -: CF_WAVE 12 ; inline -: CF_UNICODETEXT 13 ; inline -: CF_ENHMETAFILE 14 ; inline -: CF_HDROP 15 ; inline -: CF_LOCALE 16 ; inline -: CF_DIBV5 17 ; inline -: CF_MAX 18 ; inline +CONSTANT: CF_TEXT 1 +CONSTANT: CF_BITMAP 2 +CONSTANT: CF_METAFILEPICT 3 +CONSTANT: CF_SYLK 4 +CONSTANT: CF_DIF 5 +CONSTANT: CF_TIFF 6 +CONSTANT: CF_OEMTEXT 7 +CONSTANT: CF_DIB 8 +CONSTANT: CF_PALETTE 9 +CONSTANT: CF_PENDATA 10 +CONSTANT: CF_RIFF 11 +CONSTANT: CF_WAVE 12 +CONSTANT: CF_UNICODETEXT 13 +CONSTANT: CF_ENHMETAFILE 14 +CONSTANT: CF_HDROP 15 +CONSTANT: CF_LOCALE 16 +CONSTANT: CF_DIBV5 17 +CONSTANT: CF_MAX 18 -: CF_OWNERDISPLAY HEX: 0080 ; inline -: CF_DSPTEXT HEX: 0081 ; inline -: CF_DSPBITMAP HEX: 0082 ; inline -: CF_DSPMETAFILEPICT HEX: 0083 ; inline -: CF_DSPENHMETAFILE HEX: 008E ; inline +CONSTANT: CF_OWNERDISPLAY HEX: 0080 +CONSTANT: CF_DSPTEXT HEX: 0081 +CONSTANT: CF_DSPBITMAP HEX: 0082 +CONSTANT: CF_DSPMETAFILEPICT HEX: 0083 +CONSTANT: CF_DSPENHMETAFILE HEX: 008E ! "Private" formats don't get GlobalFree()'d -: CF_PRIVATEFIRST HEX: 200 ; inline -: CF_PRIVATELAST HEX: 2FF ; inline +CONSTANT: CF_PRIVATEFIRST HEX: 200 +CONSTANT: CF_PRIVATELAST HEX: 2FF ! "GDIOBJ" formats do get DeleteObject()'d -: CF_GDIOBJFIRST HEX: 300 ; inline -: CF_GDIOBJLAST HEX: 3FF ; inline +CONSTANT: CF_GDIOBJFIRST HEX: 300 +CONSTANT: CF_GDIOBJLAST HEX: 3FF ! Virtual Keys, Standard Set -: VK_LBUTTON HEX: 01 ; inline -: VK_RBUTTON HEX: 02 ; inline -: VK_CANCEL HEX: 03 ; inline -: VK_MBUTTON HEX: 04 ; inline ! NOT contiguous with L & RBUTTON -: VK_XBUTTON1 HEX: 05 ; inline ! NOT contiguous with L & RBUTTON -: VK_XBUTTON2 HEX: 06 ; inline ! NOT contiguous with L & RBUTTON +CONSTANT: VK_LBUTTON HEX: 01 +CONSTANT: VK_RBUTTON HEX: 02 +CONSTANT: VK_CANCEL HEX: 03 +CONSTANT: VK_MBUTTON HEX: 04 ! NOT contiguous with L & RBUTTON +CONSTANT: VK_XBUTTON1 HEX: 05 ! NOT contiguous with L & RBUTTON +CONSTANT: VK_XBUTTON2 HEX: 06 ! NOT contiguous with L & RBUTTON ! 0x07 : unassigned -: VK_BACK HEX: 08 ; inline -: VK_TAB HEX: 09 ; inline +CONSTANT: VK_BACK HEX: 08 +CONSTANT: VK_TAB HEX: 09 ! 0x0A - 0x0B : reserved -: VK_CLEAR HEX: 0C ; inline -: VK_RETURN HEX: 0D ; inline +CONSTANT: VK_CLEAR HEX: 0C +CONSTANT: VK_RETURN HEX: 0D -: VK_SHIFT HEX: 10 ; inline -: VK_CONTROL HEX: 11 ; inline -: VK_MENU HEX: 12 ; inline -: VK_PAUSE HEX: 13 ; inline -: VK_CAPITAL HEX: 14 ; inline +CONSTANT: VK_SHIFT HEX: 10 +CONSTANT: VK_CONTROL HEX: 11 +CONSTANT: VK_MENU HEX: 12 +CONSTANT: VK_PAUSE HEX: 13 +CONSTANT: VK_CAPITAL HEX: 14 -: VK_KANA HEX: 15 ; inline -: VK_HANGEUL HEX: 15 ; inline ! old name - here for compatibility -: VK_HANGUL HEX: 15 ; inline -: VK_JUNJA HEX: 17 ; inline -: VK_FINAL HEX: 18 ; inline -: VK_HANJA HEX: 19 ; inline -: VK_KANJI HEX: 19 ; inline +CONSTANT: VK_KANA HEX: 15 +CONSTANT: VK_HANGEUL HEX: 15 ! old name - here for compatibility +CONSTANT: VK_HANGUL HEX: 15 +CONSTANT: VK_JUNJA HEX: 17 +CONSTANT: VK_FINAL HEX: 18 +CONSTANT: VK_HANJA HEX: 19 +CONSTANT: VK_KANJI HEX: 19 -: VK_ESCAPE HEX: 1B ; inline +CONSTANT: VK_ESCAPE HEX: 1B -: VK_CONVERT HEX: 1C ; inline -: VK_NONCONVERT HEX: 1D ; inline -: VK_ACCEPT HEX: 1E ; inline -: VK_MODECHANGE HEX: 1F ; inline +CONSTANT: VK_CONVERT HEX: 1C +CONSTANT: VK_NONCONVERT HEX: 1D +CONSTANT: VK_ACCEPT HEX: 1E +CONSTANT: VK_MODECHANGE HEX: 1F -: VK_SPACE HEX: 20 ; inline -: VK_PRIOR HEX: 21 ; inline -: VK_NEXT HEX: 22 ; inline -: VK_END HEX: 23 ; inline -: VK_HOME HEX: 24 ; inline -: VK_LEFT HEX: 25 ; inline -: VK_UP HEX: 26 ; inline -: VK_RIGHT HEX: 27 ; inline -: VK_DOWN HEX: 28 ; inline -: VK_SELECT HEX: 29 ; inline -: VK_PRINT HEX: 2A ; inline -: VK_EXECUTE HEX: 2B ; inline -: VK_SNAPSHOT HEX: 2C ; inline -: VK_INSERT HEX: 2D ; inline -: VK_DELETE HEX: 2E ; inline -: VK_HELP HEX: 2F ; inline +CONSTANT: VK_SPACE HEX: 20 +CONSTANT: VK_PRIOR HEX: 21 +CONSTANT: VK_NEXT HEX: 22 +CONSTANT: VK_END HEX: 23 +CONSTANT: VK_HOME HEX: 24 +CONSTANT: VK_LEFT HEX: 25 +CONSTANT: VK_UP HEX: 26 +CONSTANT: VK_RIGHT HEX: 27 +CONSTANT: VK_DOWN HEX: 28 +CONSTANT: VK_SELECT HEX: 29 +CONSTANT: VK_PRINT HEX: 2A +CONSTANT: VK_EXECUTE HEX: 2B +CONSTANT: VK_SNAPSHOT HEX: 2C +CONSTANT: VK_INSERT HEX: 2D +CONSTANT: VK_DELETE HEX: 2E +CONSTANT: VK_HELP HEX: 2F -: VK_0 CHAR: 0 ; inline -: VK_1 CHAR: 1 ; inline -: VK_2 CHAR: 2 ; inline -: VK_3 CHAR: 3 ; inline -: VK_4 CHAR: 4 ; inline -: VK_5 CHAR: 5 ; inline -: VK_6 CHAR: 6 ; inline -: VK_7 CHAR: 7 ; inline -: VK_8 CHAR: 8 ; inline -: VK_9 CHAR: 9 ; inline +CONSTANT: VK_0 CHAR: 0 +CONSTANT: VK_1 CHAR: 1 +CONSTANT: VK_2 CHAR: 2 +CONSTANT: VK_3 CHAR: 3 +CONSTANT: VK_4 CHAR: 4 +CONSTANT: VK_5 CHAR: 5 +CONSTANT: VK_6 CHAR: 6 +CONSTANT: VK_7 CHAR: 7 +CONSTANT: VK_8 CHAR: 8 +CONSTANT: VK_9 CHAR: 9 -: VK_A CHAR: A ; inline -: VK_B CHAR: B ; inline -: VK_C CHAR: C ; inline -: VK_D CHAR: D ; inline -: VK_E CHAR: E ; inline -: VK_F CHAR: F ; inline -: VK_G CHAR: G ; inline -: VK_H CHAR: H ; inline -: VK_I CHAR: I ; inline -: VK_J CHAR: J ; inline -: VK_K CHAR: K ; inline -: VK_L CHAR: L ; inline -: VK_M CHAR: M ; inline -: VK_N CHAR: N ; inline -: VK_O CHAR: O ; inline -: VK_P CHAR: P ; inline -: VK_Q CHAR: Q ; inline -: VK_R CHAR: R ; inline -: VK_S CHAR: S ; inline -: VK_T CHAR: T ; inline -: VK_U CHAR: U ; inline -: VK_V CHAR: V ; inline -: VK_W CHAR: W ; inline -: VK_X CHAR: X ; inline -: VK_Y CHAR: Y ; inline -: VK_Z CHAR: Z ; inline +CONSTANT: VK_A CHAR: A +CONSTANT: VK_B CHAR: B +CONSTANT: VK_C CHAR: C +CONSTANT: VK_D CHAR: D +CONSTANT: VK_E CHAR: E +CONSTANT: VK_F CHAR: F +CONSTANT: VK_G CHAR: G +CONSTANT: VK_H CHAR: H +CONSTANT: VK_I CHAR: I +CONSTANT: VK_J CHAR: J +CONSTANT: VK_K CHAR: K +CONSTANT: VK_L CHAR: L +CONSTANT: VK_M CHAR: M +CONSTANT: VK_N CHAR: N +CONSTANT: VK_O CHAR: O +CONSTANT: VK_P CHAR: P +CONSTANT: VK_Q CHAR: Q +CONSTANT: VK_R CHAR: R +CONSTANT: VK_S CHAR: S +CONSTANT: VK_T CHAR: T +CONSTANT: VK_U CHAR: U +CONSTANT: VK_V CHAR: V +CONSTANT: VK_W CHAR: W +CONSTANT: VK_X CHAR: X +CONSTANT: VK_Y CHAR: Y +CONSTANT: VK_Z CHAR: Z -: VK_LWIN HEX: 5B ; inline -: VK_RWIN HEX: 5C ; inline -: VK_APPS HEX: 5D ; inline +CONSTANT: VK_LWIN HEX: 5B +CONSTANT: VK_RWIN HEX: 5C +CONSTANT: VK_APPS HEX: 5D ! 0x5E : reserved -: VK_SLEEP HEX: 5F ; inline +CONSTANT: VK_SLEEP HEX: 5F -: VK_NUMPAD0 HEX: 60 ; inline -: VK_NUMPAD1 HEX: 61 ; inline -: VK_NUMPAD2 HEX: 62 ; inline -: VK_NUMPAD3 HEX: 63 ; inline -: VK_NUMPAD4 HEX: 64 ; inline -: VK_NUMPAD5 HEX: 65 ; inline -: VK_NUMPAD6 HEX: 66 ; inline -: VK_NUMPAD7 HEX: 67 ; inline -: VK_NUMPAD8 HEX: 68 ; inline -: VK_NUMPAD9 HEX: 69 ; inline -: VK_MULTIPLY HEX: 6A ; inline -: VK_ADD HEX: 6B ; inline -: VK_SEPARATOR HEX: 6C ; inline -: VK_SUBTRACT HEX: 6D ; inline -: VK_DECIMAL HEX: 6E ; inline -: VK_DIVIDE HEX: 6F ; inline -: VK_F1 HEX: 70 ; inline -: VK_F2 HEX: 71 ; inline -: VK_F3 HEX: 72 ; inline -: VK_F4 HEX: 73 ; inline -: VK_F5 HEX: 74 ; inline -: VK_F6 HEX: 75 ; inline -: VK_F7 HEX: 76 ; inline -: VK_F8 HEX: 77 ; inline -: VK_F9 HEX: 78 ; inline -: VK_F10 HEX: 79 ; inline -: VK_F11 HEX: 7A ; inline -: VK_F12 HEX: 7B ; inline -: VK_F13 HEX: 7C ; inline -: VK_F14 HEX: 7D ; inline -: VK_F15 HEX: 7E ; inline -: VK_F16 HEX: 7F ; inline -: VK_F17 HEX: 80 ; inline -: VK_F18 HEX: 81 ; inline -: VK_F19 HEX: 82 ; inline -: VK_F20 HEX: 83 ; inline -: VK_F21 HEX: 84 ; inline -: VK_F22 HEX: 85 ; inline -: VK_F23 HEX: 86 ; inline -: VK_F24 HEX: 87 ; inline +CONSTANT: VK_NUMPAD0 HEX: 60 +CONSTANT: VK_NUMPAD1 HEX: 61 +CONSTANT: VK_NUMPAD2 HEX: 62 +CONSTANT: VK_NUMPAD3 HEX: 63 +CONSTANT: VK_NUMPAD4 HEX: 64 +CONSTANT: VK_NUMPAD5 HEX: 65 +CONSTANT: VK_NUMPAD6 HEX: 66 +CONSTANT: VK_NUMPAD7 HEX: 67 +CONSTANT: VK_NUMPAD8 HEX: 68 +CONSTANT: VK_NUMPAD9 HEX: 69 +CONSTANT: VK_MULTIPLY HEX: 6A +CONSTANT: VK_ADD HEX: 6B +CONSTANT: VK_SEPARATOR HEX: 6C +CONSTANT: VK_SUBTRACT HEX: 6D +CONSTANT: VK_DECIMAL HEX: 6E +CONSTANT: VK_DIVIDE HEX: 6F +CONSTANT: VK_F1 HEX: 70 +CONSTANT: VK_F2 HEX: 71 +CONSTANT: VK_F3 HEX: 72 +CONSTANT: VK_F4 HEX: 73 +CONSTANT: VK_F5 HEX: 74 +CONSTANT: VK_F6 HEX: 75 +CONSTANT: VK_F7 HEX: 76 +CONSTANT: VK_F8 HEX: 77 +CONSTANT: VK_F9 HEX: 78 +CONSTANT: VK_F10 HEX: 79 +CONSTANT: VK_F11 HEX: 7A +CONSTANT: VK_F12 HEX: 7B +CONSTANT: VK_F13 HEX: 7C +CONSTANT: VK_F14 HEX: 7D +CONSTANT: VK_F15 HEX: 7E +CONSTANT: VK_F16 HEX: 7F +CONSTANT: VK_F17 HEX: 80 +CONSTANT: VK_F18 HEX: 81 +CONSTANT: VK_F19 HEX: 82 +CONSTANT: VK_F20 HEX: 83 +CONSTANT: VK_F21 HEX: 84 +CONSTANT: VK_F22 HEX: 85 +CONSTANT: VK_F23 HEX: 86 +CONSTANT: VK_F24 HEX: 87 ! 0x88 - 0x8F : unassigned -: VK_NUMLOCK HEX: 90 ; inline -: VK_SCROLL HEX: 91 ; inline +CONSTANT: VK_NUMLOCK HEX: 90 +CONSTANT: VK_SCROLL HEX: 91 ! NEC PC-9800 kbd definitions -: VK_OEM_NEC_EQUAL HEX: 92 ; inline ! '=' key on numpad +CONSTANT: VK_OEM_NEC_EQUAL HEX: 92 ! '=' key on numpad ! Fujitsu/OASYS kbd definitions -: VK_OEM_FJ_JISHO HEX: 92 ; inline ! 'Dictionary' key -: VK_OEM_FJ_MASSHOU HEX: 93 ; inline ! 'Unregister word' key -: VK_OEM_FJ_TOUROKU HEX: 94 ; inline ! 'Register word' key -: VK_OEM_FJ_LOYA HEX: 95 ; inline ! 'Left OYAYUBI' key -: VK_OEM_FJ_ROYA HEX: 96 ; inline ! 'Right OYAYUBI' key +CONSTANT: VK_OEM_FJ_JISHO HEX: 92 ! 'Dictionary' key +CONSTANT: VK_OEM_FJ_MASSHOU HEX: 93 ! 'Unregister word' key +CONSTANT: VK_OEM_FJ_TOUROKU HEX: 94 ! 'Register word' key +CONSTANT: VK_OEM_FJ_LOYA HEX: 95 ! 'Left OYAYUBI' key +CONSTANT: VK_OEM_FJ_ROYA HEX: 96 ! 'Right OYAYUBI' key ! 0x97 - 0x9F : unassigned ! VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys. ! Used only as parameters to GetAsyncKeyState() and GetKeyState(). ! No other API or message will distinguish left and right keys in this way. -: VK_LSHIFT HEX: A0 ; inline -: VK_RSHIFT HEX: A1 ; inline -: VK_LCONTROL HEX: A2 ; inline -: VK_RCONTROL HEX: A3 ; inline -: VK_LMENU HEX: A4 ; inline -: VK_RMENU HEX: A5 ; inline +CONSTANT: VK_LSHIFT HEX: A0 +CONSTANT: VK_RSHIFT HEX: A1 +CONSTANT: VK_LCONTROL HEX: A2 +CONSTANT: VK_RCONTROL HEX: A3 +CONSTANT: VK_LMENU HEX: A4 +CONSTANT: VK_RMENU HEX: A5 -: VK_BROWSER_BACK HEX: A6 ; inline -: VK_BROWSER_FORWARD HEX: A7 ; inline -: VK_BROWSER_REFRESH HEX: A8 ; inline -: VK_BROWSER_STOP HEX: A9 ; inline -: VK_BROWSER_SEARCH HEX: AA ; inline -: VK_BROWSER_FAVORITES HEX: AB ; inline -: VK_BROWSER_HOME HEX: AC ; inline +CONSTANT: VK_BROWSER_BACK HEX: A6 +CONSTANT: VK_BROWSER_FORWARD HEX: A7 +CONSTANT: VK_BROWSER_REFRESH HEX: A8 +CONSTANT: VK_BROWSER_STOP HEX: A9 +CONSTANT: VK_BROWSER_SEARCH HEX: AA +CONSTANT: VK_BROWSER_FAVORITES HEX: AB +CONSTANT: VK_BROWSER_HOME HEX: AC -: VK_VOLUME_MUTE HEX: AD ; inline -: VK_VOLUME_DOWN HEX: AE ; inline -: VK_VOLUME_UP HEX: AF ; inline -: VK_MEDIA_NEXT_TRACK HEX: B0 ; inline -: VK_MEDIA_PREV_TRACK HEX: B1 ; inline -: VK_MEDIA_STOP HEX: B2 ; inline -: VK_MEDIA_PLAY_PAUSE HEX: B3 ; inline -: VK_LAUNCH_MAIL HEX: B4 ; inline -: VK_LAUNCH_MEDIA_SELECT HEX: B5 ; inline -: VK_LAUNCH_APP1 HEX: B6 ; inline -: VK_LAUNCH_APP2 HEX: B7 ; inline +CONSTANT: VK_VOLUME_MUTE HEX: AD +CONSTANT: VK_VOLUME_DOWN HEX: AE +CONSTANT: VK_VOLUME_UP HEX: AF +CONSTANT: VK_MEDIA_NEXT_TRACK HEX: B0 +CONSTANT: VK_MEDIA_PREV_TRACK HEX: B1 +CONSTANT: VK_MEDIA_STOP HEX: B2 +CONSTANT: VK_MEDIA_PLAY_PAUSE HEX: B3 +CONSTANT: VK_LAUNCH_MAIL HEX: B4 +CONSTANT: VK_LAUNCH_MEDIA_SELECT HEX: B5 +CONSTANT: VK_LAUNCH_APP1 HEX: B6 +CONSTANT: VK_LAUNCH_APP2 HEX: B7 ! 0xB8 - 0xB9 : reserved -: VK_OEM_1 HEX: BA ; inline ! ';:' for US -: VK_OEM_PLUS HEX: BB ; inline ! '+' any country -: VK_OEM_COMMA HEX: BC ; inline ! ',' any country -: VK_OEM_MINUS HEX: BD ; inline ! '-' any country -: VK_OEM_PERIOD HEX: BE ; inline ! '.' any country -: VK_OEM_2 HEX: BF ; inline ! '/?' for US -: VK_OEM_3 HEX: C0 ; inline ! '`~' for US +CONSTANT: VK_OEM_1 HEX: BA ! ';:' for US +CONSTANT: VK_OEM_PLUS HEX: BB ! '+' any country +CONSTANT: VK_OEM_COMMA HEX: BC ! ',' any country +CONSTANT: VK_OEM_MINUS HEX: BD ! '-' any country +CONSTANT: VK_OEM_PERIOD HEX: BE ! '.' any country +CONSTANT: VK_OEM_2 HEX: BF ! '/?' for US +CONSTANT: VK_OEM_3 HEX: C0 ! '`~' for US ! 0xC1 - 0xD7 : reserved ! 0xD8 - 0xDA : unassigned -: VK_OEM_4 HEX: DB ; inline ! '[{' for US -: VK_OEM_5 HEX: DC ; inline ! '\|' for US -: VK_OEM_6 HEX: DD ; inline ! ']}' for US -: VK_OEM_7 HEX: DE ; inline ! ''"' for US -: VK_OEM_8 HEX: DF ; inline +CONSTANT: VK_OEM_4 HEX: DB ! '[{' for US +CONSTANT: VK_OEM_5 HEX: DC ! '\|' for US +CONSTANT: VK_OEM_6 HEX: DD ! ']}' for US +CONSTANT: VK_OEM_7 HEX: DE ! ''"' for US +CONSTANT: VK_OEM_8 HEX: DF ! 0xE0 : reserved ! Various extended or enhanced keyboards -: VK_OEM_AX HEX: E1 ; inline ! 'AX' key on Japanese AX kbd -: VK_OEM_102 HEX: E2 ; inline ! "<>" or "\|" on RT 102-key kbd. -: VK_ICO_HELP HEX: E3 ; inline ! Help key on ICO -: VK_ICO_00 HEX: E4 ; inline ! 00 key on ICO +CONSTANT: VK_OEM_AX HEX: E1 ! 'AX' key on Japanese AX kbd +CONSTANT: VK_OEM_102 HEX: E2 ! "<>" or "\|" on RT 102-key kbd. +CONSTANT: VK_ICO_HELP HEX: E3 ! Help key on ICO +CONSTANT: VK_ICO_00 HEX: E4 ! 00 key on ICO -: VK_PROCESSKEY HEX: E5 ; inline +CONSTANT: VK_PROCESSKEY HEX: E5 -: VK_ICO_CLEAR HEX: E6 ; inline +CONSTANT: VK_ICO_CLEAR HEX: E6 -: VK_PACKET HEX: E7 ; inline +CONSTANT: VK_PACKET HEX: E7 ! 0xE8 : unassigned ! Nokia/Ericsson definitions -: VK_OEM_RESET HEX: E9 ; inline -: VK_OEM_JUMP HEX: EA ; inline -: VK_OEM_PA1 HEX: EB ; inline -: VK_OEM_PA2 HEX: EC ; inline -: VK_OEM_PA3 HEX: ED ; inline -: VK_OEM_WSCTRL HEX: EE ; inline -: VK_OEM_CUSEL HEX: EF ; inline -: VK_OEM_ATTN HEX: F0 ; inline -: VK_OEM_FINISH HEX: F1 ; inline -: VK_OEM_COPY HEX: F2 ; inline -: VK_OEM_AUTO HEX: F3 ; inline -: VK_OEM_ENLW HEX: F4 ; inline -: VK_OEM_BACKTAB HEX: F5 ; inline +CONSTANT: VK_OEM_RESET HEX: E9 +CONSTANT: VK_OEM_JUMP HEX: EA +CONSTANT: VK_OEM_PA1 HEX: EB +CONSTANT: VK_OEM_PA2 HEX: EC +CONSTANT: VK_OEM_PA3 HEX: ED +CONSTANT: VK_OEM_WSCTRL HEX: EE +CONSTANT: VK_OEM_CUSEL HEX: EF +CONSTANT: VK_OEM_ATTN HEX: F0 +CONSTANT: VK_OEM_FINISH HEX: F1 +CONSTANT: VK_OEM_COPY HEX: F2 +CONSTANT: VK_OEM_AUTO HEX: F3 +CONSTANT: VK_OEM_ENLW HEX: F4 +CONSTANT: VK_OEM_BACKTAB HEX: F5 -: VK_ATTN HEX: F6 ; inline -: VK_CRSEL HEX: F7 ; inline -: VK_EXSEL HEX: F8 ; inline -: VK_EREOF HEX: F9 ; inline -: VK_PLAY HEX: FA ; inline -: VK_ZOOM HEX: FB ; inline -: VK_NONAME HEX: FC ; inline -: VK_PA1 HEX: FD ; inline -: VK_OEM_CLEAR HEX: FE ; inline +CONSTANT: VK_ATTN HEX: F6 +CONSTANT: VK_CRSEL HEX: F7 +CONSTANT: VK_EXSEL HEX: F8 +CONSTANT: VK_EREOF HEX: F9 +CONSTANT: VK_PLAY HEX: FA +CONSTANT: VK_ZOOM HEX: FB +CONSTANT: VK_NONAME HEX: FC +CONSTANT: VK_PA1 HEX: FD +CONSTANT: VK_OEM_CLEAR HEX: FE ! 0xFF : reserved ! Key State Masks for Mouse Messages -: MK_LBUTTON HEX: 0001 ; inline -: MK_RBUTTON HEX: 0002 ; inline -: MK_SHIFT HEX: 0004 ; inline -: MK_CONTROL HEX: 0008 ; inline -: MK_MBUTTON HEX: 0010 ; inline -: MK_XBUTTON1 HEX: 0020 ; inline -: MK_XBUTTON2 HEX: 0040 ; inline +CONSTANT: MK_LBUTTON HEX: 0001 +CONSTANT: MK_RBUTTON HEX: 0002 +CONSTANT: MK_SHIFT HEX: 0004 +CONSTANT: MK_CONTROL HEX: 0008 +CONSTANT: MK_MBUTTON HEX: 0010 +CONSTANT: MK_XBUTTON1 HEX: 0020 +CONSTANT: MK_XBUTTON2 HEX: 0040 ! Some fields are not defined for win64 ! Window field offsets for GetWindowLong() -: GWL_WNDPROC -4 ; inline -: GWL_HINSTANCE -6 ; inline -: GWL_HWNDPARENT -8 ; inline -: GWL_USERDATA -21 ; inline -: GWL_ID -12 ; inline +CONSTANT: GWL_WNDPROC -4 +CONSTANT: GWL_HINSTANCE -6 +CONSTANT: GWL_HWNDPARENT -8 +CONSTANT: GWL_USERDATA -21 +CONSTANT: GWL_ID -12 -: GWL_STYLE -16 ; inline -: GWL_EXSTYLE -20 ; inline +CONSTANT: GWL_STYLE -16 +CONSTANT: GWL_EXSTYLE -20 -: GWLP_WNDPROC -4 ; inline -: GWLP_HINSTANCE -6 ; inline -: GWLP_HWNDPARENT -8 ; inline -: GWLP_USERDATA -21 ; inline -: GWLP_ID -12 ; inline +CONSTANT: GWLP_WNDPROC -4 +CONSTANT: GWLP_HINSTANCE -6 +CONSTANT: GWLP_HWNDPARENT -8 +CONSTANT: GWLP_USERDATA -21 +CONSTANT: GWLP_ID -12 ! Class field offsets for GetClassLong() -: GCL_MENUNAME -8 ; inline -: GCL_HBRBACKGROUND -10 ; inline -: GCL_HCURSOR -12 ; inline -: GCL_HICON -14 ; inline -: GCL_HMODULE -16 ; inline -: GCL_WNDPROC -24 ; inline -: GCL_HICONSM -34 ; inline -: GCL_CBWNDEXTRA -18 ; inline -: GCL_CBCLSEXTRA -20 ; inline -: GCL_STYLE -26 ; inline -: GCW_ATOM -32 ; inline +CONSTANT: GCL_MENUNAME -8 +CONSTANT: GCL_HBRBACKGROUND -10 +CONSTANT: GCL_HCURSOR -12 +CONSTANT: GCL_HICON -14 +CONSTANT: GCL_HMODULE -16 +CONSTANT: GCL_WNDPROC -24 +CONSTANT: GCL_HICONSM -34 +CONSTANT: GCL_CBWNDEXTRA -18 +CONSTANT: GCL_CBCLSEXTRA -20 +CONSTANT: GCL_STYLE -26 +CONSTANT: GCW_ATOM -32 -: GCLP_MENUNAME -8 ; inline -: GCLP_HBRBACKGROUND -10 ; inline -: GCLP_HCURSOR -12 ; inline -: GCLP_HICON -14 ; inline -: GCLP_HMODULE -16 ; inline -: GCLP_WNDPROC -24 ; inline -: GCLP_HICONSM -34 ; inline +CONSTANT: GCLP_MENUNAME -8 +CONSTANT: GCLP_HBRBACKGROUND -10 +CONSTANT: GCLP_HCURSOR -12 +CONSTANT: GCLP_HICON -14 +CONSTANT: GCLP_HMODULE -16 +CONSTANT: GCLP_WNDPROC -24 +CONSTANT: GCLP_HICONSM -34 -: MB_ICONASTERISK HEX: 00000040 ; inline -: MB_ICONEXCLAMATION HEX: 00000030 ; inline -: MB_ICONHAND HEX: 00000010 ; inline -: MB_ICONQUESTION HEX: 00000020 ; inline -: MB_OK HEX: 00000000 ; inline +CONSTANT: MB_ICONASTERISK HEX: 00000040 +CONSTANT: MB_ICONEXCLAMATION HEX: 00000030 +CONSTANT: MB_ICONHAND HEX: 00000010 +CONSTANT: MB_ICONQUESTION HEX: 00000020 +CONSTANT: MB_OK HEX: 00000000 ALIAS: FVIRTKEY TRUE -: FNOINVERT 2 ; inline -: FSHIFT 4 ; inline -: FCONTROL 8 ; inline -: FALT 16 ; inline +CONSTANT: FNOINVERT 2 +CONSTANT: FSHIFT 4 +CONSTANT: FCONTROL 8 +CONSTANT: FALT 16 -: MAPVK_VK_TO_VSC 0 ; inline -: MAPVK_VSC_TO_VK 1 ; inline -: MAPVK_VK_TO_CHAR 2 ; inline -: MAPVK_VSC_TO_VK_EX 3 ; inline -: MAPVK_VK_TO_VSC_EX 3 ; inline +CONSTANT: MAPVK_VK_TO_VSC 0 +CONSTANT: MAPVK_VSC_TO_VK 1 +CONSTANT: MAPVK_VK_TO_CHAR 2 +CONSTANT: MAPVK_VSC_TO_VK_EX 3 +CONSTANT: MAPVK_VK_TO_VSC_EX 3 -: TME_HOVER 1 ; inline -: TME_LEAVE 2 ; inline -: TME_NONCLIENT 16 ; inline -: TME_QUERY HEX: 40000000 ; inline -: TME_CANCEL HEX: 80000000 ; inline -: HOVER_DEFAULT HEX: ffffffff ; inline +CONSTANT: TME_HOVER 1 +CONSTANT: TME_LEAVE 2 +CONSTANT: TME_NONCLIENT 16 +CONSTANT: TME_QUERY HEX: 40000000 +CONSTANT: TME_CANCEL HEX: 80000000 +CONSTANT: HOVER_DEFAULT HEX: ffffffff C-STRUCT: TRACKMOUSEEVENT { "DWORD" "cbSize" } { "DWORD" "dwFlags" } @@ -528,15 +528,15 @@ C-STRUCT: TRACKMOUSEEVENT { "DWORD" "dwHoverTime" } ; TYPEDEF: TRACKMOUSEEVENT* LPTRACKMOUSEEVENT -: DBT_DEVICEARRIVAL HEX: 8000 ; inline -: DBT_DEVICEREMOVECOMPLETE HEX: 8004 ; inline +CONSTANT: DBT_DEVICEARRIVAL HEX: 8000 +CONSTANT: DBT_DEVICEREMOVECOMPLETE HEX: 8004 -: DBT_DEVTYP_DEVICEINTERFACE 5 ; inline +CONSTANT: DBT_DEVTYP_DEVICEINTERFACE 5 -: DEVICE_NOTIFY_WINDOW_HANDLE 0 ; inline -: DEVICE_NOTIFY_SERVICE_HANDLE 1 ; inline +CONSTANT: DEVICE_NOTIFY_WINDOW_HANDLE 0 +CONSTANT: DEVICE_NOTIFY_SERVICE_HANDLE 1 -: DEVICE_NOTIFY_ALL_INTERFACE_CLASSES 4 ; inline +CONSTANT: DEVICE_NOTIFY_ALL_INTERFACE_CLASSES 4 C-STRUCT: DEV_BROADCAST_HDR { "DWORD" "dbch_size" } @@ -672,7 +672,6 @@ ALIAS: CreateWindowEx CreateWindowExW : CreateWindow ( a b c d e f g h i j k -- hwnd ) 0 12 -nrot CreateWindowEx ; inline - ! FUNCTION: CreateWindowStationA ! FUNCTION: CreateWindowStationW ! FUNCTION: CsrBroadcastSystemMessageExW From 2f868b38c2796031c9bb2794b4db519288ef100d Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 18:12:54 -0600 Subject: [PATCH 42/85] more CONSTANT: usage --- basis/windows/kernel32/kernel32.factor | 2 +- basis/windows/ole32/ole32.factor | 108 ++++++++++++------------ basis/windows/opengl32/opengl32.factor | 110 ++++++++++++------------- basis/windows/shell32/shell32.factor | 6 +- basis/windows/types/types.factor | 6 +- basis/windows/windows.factor | 2 +- 6 files changed, 117 insertions(+), 117 deletions(-) diff --git a/basis/windows/kernel32/kernel32.factor b/basis/windows/kernel32/kernel32.factor index 3494e83e83..8a271f7210 100755 --- a/basis/windows/kernel32/kernel32.factor +++ b/basis/windows/kernel32/kernel32.factor @@ -1226,7 +1226,7 @@ FUNCTION: BOOL GetExitCodeProcess ( HANDLE hProcess, LPDWORD lpExitCode ) ; FUNCTION: DWORD GetFileAttributesW ( LPCTSTR lpFileName ) ; ! FUNCTION: GetFileAttributesExA -: GetFileExInfoStandard 0 ; inline +CONSTANT: GetFileExInfoStandard 0 FUNCTION: BOOL GetFileAttributesExW ( LPCTSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation ) ; diff --git a/basis/windows/ole32/ole32.factor b/basis/windows/ole32/ole32.factor index 3d080817bf..e69a9213b0 100755 --- a/basis/windows/ole32/ole32.factor +++ b/basis/windows/ole32/ole32.factor @@ -20,61 +20,61 @@ FUNCTION: BOOL IsEqualGUID ( REFGUID rguid1, REFGUID rguid2 ) ; FUNCTION: int StringFromGUID2 ( REFGUID rguid, LPOLESTR lpsz, int cchMax ) ; FUNCTION: HRESULT CLSIDFromString ( LPOLESTR lpsz, REFGUID out_rguid ) ; -: S_OK 0 ; inline -: S_FALSE 1 ; inline -: E_NOINTERFACE HEX: 80004002 ; inline -: E_FAIL HEX: 80004005 ; inline -: E_INVALIDARG HEX: 80070057 ; inline +CONSTANT: S_OK 0 +CONSTANT: S_FALSE 1 +CONSTANT: E_NOINTERFACE HEX: 80004002 +CONSTANT: E_FAIL HEX: 80004005 +CONSTANT: E_INVALIDARG HEX: 80070057 -: MK_ALT HEX: 20 ; inline -: DROPEFFECT_NONE 0 ; inline -: DROPEFFECT_COPY 1 ; inline -: DROPEFFECT_MOVE 2 ; inline -: DROPEFFECT_LINK 4 ; inline -: DROPEFFECT_SCROLL HEX: 80000000 ; inline -: DD_DEFSCROLLINSET 11 ; inline -: DD_DEFSCROLLDELAY 50 ; inline -: DD_DEFSCROLLINTERVAL 50 ; inline -: DD_DEFDRAGDELAY 200 ; inline -: DD_DEFDRAGMINDIST 2 ; inline +CONSTANT: MK_ALT HEX: 20 +CONSTANT: DROPEFFECT_NONE 0 +CONSTANT: DROPEFFECT_COPY 1 +CONSTANT: DROPEFFECT_MOVE 2 +CONSTANT: DROPEFFECT_LINK 4 +CONSTANT: DROPEFFECT_SCROLL HEX: 80000000 +CONSTANT: DD_DEFSCROLLINSET 11 +CONSTANT: DD_DEFSCROLLDELAY 50 +CONSTANT: DD_DEFSCROLLINTERVAL 50 +CONSTANT: DD_DEFDRAGDELAY 200 +CONSTANT: DD_DEFDRAGMINDIST 2 -: CF_TEXT 1 ; inline -: CF_BITMAP 2 ; inline -: CF_METAFILEPICT 3 ; inline -: CF_SYLK 4 ; inline -: CF_DIF 5 ; inline -: CF_TIFF 6 ; inline -: CF_OEMTEXT 7 ; inline -: CF_DIB 8 ; inline -: CF_PALETTE 9 ; inline -: CF_PENDATA 10 ; inline -: CF_RIFF 11 ; inline -: CF_WAVE 12 ; inline -: CF_UNICODETEXT 13 ; inline -: CF_ENHMETAFILE 14 ; inline -: CF_HDROP 15 ; inline -: CF_LOCALE 16 ; inline -: CF_MAX 17 ; inline +CONSTANT: CF_TEXT 1 +CONSTANT: CF_BITMAP 2 +CONSTANT: CF_METAFILEPICT 3 +CONSTANT: CF_SYLK 4 +CONSTANT: CF_DIF 5 +CONSTANT: CF_TIFF 6 +CONSTANT: CF_OEMTEXT 7 +CONSTANT: CF_DIB 8 +CONSTANT: CF_PALETTE 9 +CONSTANT: CF_PENDATA 10 +CONSTANT: CF_RIFF 11 +CONSTANT: CF_WAVE 12 +CONSTANT: CF_UNICODETEXT 13 +CONSTANT: CF_ENHMETAFILE 14 +CONSTANT: CF_HDROP 15 +CONSTANT: CF_LOCALE 16 +CONSTANT: CF_MAX 17 -: CF_OWNERDISPLAY HEX: 0080 ; inline -: CF_DSPTEXT HEX: 0081 ; inline -: CF_DSPBITMAP HEX: 0082 ; inline -: CF_DSPMETAFILEPICT HEX: 0083 ; inline -: CF_DSPENHMETAFILE HEX: 008E ; inline +CONSTANT: CF_OWNERDISPLAY HEX: 0080 +CONSTANT: CF_DSPTEXT HEX: 0081 +CONSTANT: CF_DSPBITMAP HEX: 0082 +CONSTANT: CF_DSPMETAFILEPICT HEX: 0083 +CONSTANT: CF_DSPENHMETAFILE HEX: 008E -: DVASPECT_CONTENT 1 ; inline -: DVASPECT_THUMBNAIL 2 ; inline -: DVASPECT_ICON 4 ; inline -: DVASPECT_DOCPRINT 8 ; inline +CONSTANT: DVASPECT_CONTENT 1 +CONSTANT: DVASPECT_THUMBNAIL 2 +CONSTANT: DVASPECT_ICON 4 +CONSTANT: DVASPECT_DOCPRINT 8 -: TYMED_HGLOBAL 1 ; inline -: TYMED_FILE 2 ; inline -: TYMED_ISTREAM 4 ; inline -: TYMED_ISTORAGE 8 ; inline -: TYMED_GDI 16 ; inline -: TYMED_MFPICT 32 ; inline -: TYMED_ENHMF 64 ; inline -: TYMED_NULL 0 ; inline +CONSTANT: TYMED_HGLOBAL 1 +CONSTANT: TYMED_FILE 2 +CONSTANT: TYMED_ISTREAM 4 +CONSTANT: TYMED_ISTORAGE 8 +CONSTANT: TYMED_GDI 16 +CONSTANT: TYMED_MFPICT 32 +CONSTANT: TYMED_ENHMF 64 +CONSTANT: TYMED_NULL 0 C-STRUCT: DVTARGETDEVICE { "DWORD" "tdSize" } @@ -101,10 +101,10 @@ C-STRUCT: STGMEDIUM { "LPUNKNOWN" "punkForRelease" } ; TYPEDEF: STGMEDIUM* LPSTGMEDIUM -: COINIT_MULTITHREADED 0 ; inline -: COINIT_APARTMENTTHREADED 2 ; inline -: COINIT_DISABLE_OLE1DDE 4 ; inline -: COINIT_SPEED_OVER_MEMORY 8 ; inline +CONSTANT: COINIT_MULTITHREADED 0 +CONSTANT: COINIT_APARTMENTTHREADED 2 +CONSTANT: COINIT_DISABLE_OLE1DDE 4 +CONSTANT: COINIT_SPEED_OVER_MEMORY 8 FUNCTION: HRESULT OleInitialize ( void* reserved ) ; FUNCTION: HRESULT CoInitializeEx ( void* reserved, DWORD dwCoInit ) ; diff --git a/basis/windows/opengl32/opengl32.factor b/basis/windows/opengl32/opengl32.factor index 63384e8858..d0b396eba2 100755 --- a/basis/windows/opengl32/opengl32.factor +++ b/basis/windows/opengl32/opengl32.factor @@ -6,70 +6,70 @@ sequences libc ; IN: windows.opengl32 ! PIXELFORMATDESCRIPTOR flags -: PFD_DOUBLEBUFFER HEX: 00000001 ; inline -: PFD_STEREO HEX: 00000002 ; inline -: PFD_DRAW_TO_WINDOW HEX: 00000004 ; inline -: PFD_DRAW_TO_BITMAP HEX: 00000008 ; inline -: PFD_SUPPORT_GDI HEX: 00000010 ; inline -: PFD_SUPPORT_OPENGL HEX: 00000020 ; inline -: PFD_GENERIC_FORMAT HEX: 00000040 ; inline -: PFD_NEED_PALETTE HEX: 00000080 ; inline -: PFD_NEED_SYSTEM_PALETTE HEX: 00000100 ; inline -: PFD_SWAP_EXCHANGE HEX: 00000200 ; inline -: PFD_SWAP_COPY HEX: 00000400 ; inline -: PFD_SWAP_LAYER_BUFFERS HEX: 00000800 ; inline -: PFD_GENERIC_ACCELERATED HEX: 00001000 ; inline -: PFD_SUPPORT_DIRECTDRAW HEX: 00002000 ; inline +CONSTANT: PFD_DOUBLEBUFFER HEX: 00000001 +CONSTANT: PFD_STEREO HEX: 00000002 +CONSTANT: PFD_DRAW_TO_WINDOW HEX: 00000004 +CONSTANT: PFD_DRAW_TO_BITMAP HEX: 00000008 +CONSTANT: PFD_SUPPORT_GDI HEX: 00000010 +CONSTANT: PFD_SUPPORT_OPENGL HEX: 00000020 +CONSTANT: PFD_GENERIC_FORMAT HEX: 00000040 +CONSTANT: PFD_NEED_PALETTE HEX: 00000080 +CONSTANT: PFD_NEED_SYSTEM_PALETTE HEX: 00000100 +CONSTANT: PFD_SWAP_EXCHANGE HEX: 00000200 +CONSTANT: PFD_SWAP_COPY HEX: 00000400 +CONSTANT: PFD_SWAP_LAYER_BUFFERS HEX: 00000800 +CONSTANT: PFD_GENERIC_ACCELERATED HEX: 00001000 +CONSTANT: PFD_SUPPORT_DIRECTDRAW HEX: 00002000 ! PIXELFORMATDESCRIPTOR flags for use in ChoosePixelFormat only -: PFD_DEPTH_DONTCARE HEX: 20000000 ; inline -: PFD_DOUBLEBUFFER_DONTCARE HEX: 40000000 ; inline -: PFD_STEREO_DONTCARE HEX: 80000000 ; inline +CONSTANT: PFD_DEPTH_DONTCARE HEX: 20000000 +CONSTANT: PFD_DOUBLEBUFFER_DONTCARE HEX: 40000000 +CONSTANT: PFD_STEREO_DONTCARE HEX: 80000000 ! pixel types -: PFD_TYPE_RGBA 0 ; inline -: PFD_TYPE_COLORINDEX 1 ; inline +CONSTANT: PFD_TYPE_RGBA 0 +CONSTANT: PFD_TYPE_COLORINDEX 1 ! layer types -: PFD_MAIN_PLANE 0 ; inline -: PFD_OVERLAY_PLANE 1 ; inline -: PFD_UNDERLAY_PLANE -1 ; inline +CONSTANT: PFD_MAIN_PLANE 0 +CONSTANT: PFD_OVERLAY_PLANE 1 +CONSTANT: PFD_UNDERLAY_PLANE -1 -: LPD_TYPE_RGBA 0 ; inline -: LPD_TYPE_COLORINDEX 1 ; inline +CONSTANT: LPD_TYPE_RGBA 0 +CONSTANT: LPD_TYPE_COLORINDEX 1 ! wglSwapLayerBuffers flags -: WGL_SWAP_MAIN_PLANE HEX: 00000001 ; inline -: WGL_SWAP_OVERLAY1 HEX: 00000002 ; inline -: WGL_SWAP_OVERLAY2 HEX: 00000004 ; inline -: WGL_SWAP_OVERLAY3 HEX: 00000008 ; inline -: WGL_SWAP_OVERLAY4 HEX: 00000010 ; inline -: WGL_SWAP_OVERLAY5 HEX: 00000020 ; inline -: WGL_SWAP_OVERLAY6 HEX: 00000040 ; inline -: WGL_SWAP_OVERLAY7 HEX: 00000080 ; inline -: WGL_SWAP_OVERLAY8 HEX: 00000100 ; inline -: WGL_SWAP_OVERLAY9 HEX: 00000200 ; inline -: WGL_SWAP_OVERLAY10 HEX: 00000400 ; inline -: WGL_SWAP_OVERLAY11 HEX: 00000800 ; inline -: WGL_SWAP_OVERLAY12 HEX: 00001000 ; inline -: WGL_SWAP_OVERLAY13 HEX: 00002000 ; inline -: WGL_SWAP_OVERLAY14 HEX: 00004000 ; inline -: WGL_SWAP_OVERLAY15 HEX: 00008000 ; inline -: WGL_SWAP_UNDERLAY1 HEX: 00010000 ; inline -: WGL_SWAP_UNDERLAY2 HEX: 00020000 ; inline -: WGL_SWAP_UNDERLAY3 HEX: 00040000 ; inline -: WGL_SWAP_UNDERLAY4 HEX: 00080000 ; inline -: WGL_SWAP_UNDERLAY5 HEX: 00100000 ; inline -: WGL_SWAP_UNDERLAY6 HEX: 00200000 ; inline -: WGL_SWAP_UNDERLAY7 HEX: 00400000 ; inline -: WGL_SWAP_UNDERLAY8 HEX: 00800000 ; inline -: WGL_SWAP_UNDERLAY9 HEX: 01000000 ; inline -: WGL_SWAP_UNDERLAY10 HEX: 02000000 ; inline -: WGL_SWAP_UNDERLAY11 HEX: 04000000 ; inline -: WGL_SWAP_UNDERLAY12 HEX: 08000000 ; inline -: WGL_SWAP_UNDERLAY13 HEX: 10000000 ; inline -: WGL_SWAP_UNDERLAY14 HEX: 20000000 ; inline -: WGL_SWAP_UNDERLAY15 HEX: 40000000 ; inline +CONSTANT: WGL_SWAP_MAIN_PLANE HEX: 00000001 +CONSTANT: WGL_SWAP_OVERLAY1 HEX: 00000002 +CONSTANT: WGL_SWAP_OVERLAY2 HEX: 00000004 +CONSTANT: WGL_SWAP_OVERLAY3 HEX: 00000008 +CONSTANT: WGL_SWAP_OVERLAY4 HEX: 00000010 +CONSTANT: WGL_SWAP_OVERLAY5 HEX: 00000020 +CONSTANT: WGL_SWAP_OVERLAY6 HEX: 00000040 +CONSTANT: WGL_SWAP_OVERLAY7 HEX: 00000080 +CONSTANT: WGL_SWAP_OVERLAY8 HEX: 00000100 +CONSTANT: WGL_SWAP_OVERLAY9 HEX: 00000200 +CONSTANT: WGL_SWAP_OVERLAY10 HEX: 00000400 +CONSTANT: WGL_SWAP_OVERLAY11 HEX: 00000800 +CONSTANT: WGL_SWAP_OVERLAY12 HEX: 00001000 +CONSTANT: WGL_SWAP_OVERLAY13 HEX: 00002000 +CONSTANT: WGL_SWAP_OVERLAY14 HEX: 00004000 +CONSTANT: WGL_SWAP_OVERLAY15 HEX: 00008000 +CONSTANT: WGL_SWAP_UNDERLAY1 HEX: 00010000 +CONSTANT: WGL_SWAP_UNDERLAY2 HEX: 00020000 +CONSTANT: WGL_SWAP_UNDERLAY3 HEX: 00040000 +CONSTANT: WGL_SWAP_UNDERLAY4 HEX: 00080000 +CONSTANT: WGL_SWAP_UNDERLAY5 HEX: 00100000 +CONSTANT: WGL_SWAP_UNDERLAY6 HEX: 00200000 +CONSTANT: WGL_SWAP_UNDERLAY7 HEX: 00400000 +CONSTANT: WGL_SWAP_UNDERLAY8 HEX: 00800000 +CONSTANT: WGL_SWAP_UNDERLAY9 HEX: 01000000 +CONSTANT: WGL_SWAP_UNDERLAY10 HEX: 02000000 +CONSTANT: WGL_SWAP_UNDERLAY11 HEX: 04000000 +CONSTANT: WGL_SWAP_UNDERLAY12 HEX: 08000000 +CONSTANT: WGL_SWAP_UNDERLAY13 HEX: 10000000 +CONSTANT: WGL_SWAP_UNDERLAY14 HEX: 20000000 +CONSTANT: WGL_SWAP_UNDERLAY15 HEX: 40000000 : windowed-pfd-dwFlags ( -- n ) { PFD_DRAW_TO_WINDOW PFD_SUPPORT_OPENGL PFD_DOUBLEBUFFER } flags ; diff --git a/basis/windows/shell32/shell32.factor b/basis/windows/shell32/shell32.factor index c8dbe4b91c..7802ceb297 100644 --- a/basis/windows/shell32/shell32.factor +++ b/basis/windows/shell32/shell32.factor @@ -190,9 +190,9 @@ TYPEDEF: ITEMIDLIST ITEMID_CHILD TYPEDEF: ITEMID_CHILD* PITEMID_CHILD TYPEDEF: ITEMID_CHILD* PCUITEMID_CHILD -: STRRET_WSTR 0 ; inline -: STRRET_OFFSET 1 ; inline -: STRRET_CSTR 2 ; inline +CONSTANT: STRRET_WSTR 0 +CONSTANT: STRRET_OFFSET 1 +CONSTANT: STRRET_CSTR 2 C-UNION: STRRET-union "LPWSTR" "LPSTR" "UINT" "char[260]" ; C-STRUCT: STRRET diff --git a/basis/windows/types/types.factor b/basis/windows/types/types.factor index 8cc18d4039..ee74e47fea 100755 --- a/basis/windows/types/types.factor +++ b/basis/windows/types/types.factor @@ -205,10 +205,10 @@ TYPEDEF: size_t socklen_t TYPEDEF: void* WNDPROC -: FALSE 0 ; inline -: TRUE 1 ; inline +CONSTANT: FALSE 0 +CONSTANT: TRUE 1 -: >BOOLEAN ( ? -- 1/0 ) 1 0 ? ; inline +: >BOOLEAN ( ? -- 1/0 ) TRUE FALSE ? ; inline ! typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM); diff --git a/basis/windows/windows.factor b/basis/windows/windows.factor index d2250d6f7e..44db355c99 100644 --- a/basis/windows/windows.factor +++ b/basis/windows/windows.factor @@ -8,7 +8,7 @@ IN: windows : lo-word ( wparam -- lo ) *short ; inline : hi-word ( wparam -- hi ) -16 shift lo-word ; inline -: MAX_UNICODE_PATH 32768 ; inline +CONSTANT: MAX_UNICODE_PATH 32768 ! You must LocalFree the return value! FUNCTION: void* error_message ( DWORD id ) ; From e026b554a99628682b50857b4fcc9e22ecae719d Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 19:08:45 -0600 Subject: [PATCH 43/85] use CONSTANT: in extra --- extra/benchmark/binary-trees/binary-trees.factor | 2 +- extra/benchmark/fasta/fasta.factor | 12 ++++++------ extra/benchmark/mandel/colors/colors.factor | 4 ++-- extra/benchmark/mandel/params/params.factor | 12 ++++++------ extra/benchmark/nbody/nbody.factor | 2 +- extra/benchmark/raytracer/raytracer.factor | 10 +++++----- extra/crypto/aes/aes.factor | 2 +- extra/crypto/rsa/rsa.factor | 2 +- extra/curses/curses.factor | 6 +++--- extra/curses/ffi/ffi.factor | 2 +- extra/math/analysis/analysis.factor | 2 +- extra/opengl/demo-support/demo-support.factor | 4 ++-- extra/tetris/game/game.factor | 4 ++-- 13 files changed, 32 insertions(+), 32 deletions(-) diff --git a/extra/benchmark/binary-trees/binary-trees.factor b/extra/benchmark/binary-trees/binary-trees.factor index 8e3918656a..21ff7fbbef 100644 --- a/extra/benchmark/binary-trees/binary-trees.factor +++ b/extra/benchmark/binary-trees/binary-trees.factor @@ -23,7 +23,7 @@ M: tree-node item-check M: f item-check drop 0 ; -: min-depth 4 ; inline +CONSTANT: min-depth 4 : stretch-tree ( max-depth -- ) 1 + 0 over bottom-up-tree item-check diff --git a/extra/benchmark/fasta/fasta.factor b/extra/benchmark/fasta/fasta.factor index 32d3534920..61d9e9fd43 100755 --- a/extra/benchmark/fasta/fasta.factor +++ b/extra/benchmark/fasta/fasta.factor @@ -4,11 +4,11 @@ sequences.private benchmark.reverse-complement hints io.encodings.ascii byte-arrays specialized-arrays.double ; IN: benchmark.fasta -: IM 139968 ; inline -: IA 3877 ; inline -: IC 29573 ; inline -: initial-seed 42 ; inline -: line-length 60 ; inline +CONSTANT: IM 139968 +CONSTANT: IA 3877 +CONSTANT: IC 29573 +CONSTANT: initial-seed 42 +CONSTANT: line-length 60 USE: math.private @@ -17,7 +17,7 @@ USE: math.private HINTS: random fixnum ; -: ALU "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA" ; inline +CONSTANT: ALU "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA" : IUB { diff --git a/extra/benchmark/mandel/colors/colors.factor b/extra/benchmark/mandel/colors/colors.factor index edc848a0ca..9e0f2472e2 100644 --- a/extra/benchmark/mandel/colors/colors.factor +++ b/extra/benchmark/mandel/colors/colors.factor @@ -7,8 +7,8 @@ IN: benchmark.mandel.colors : scale-rgb ( rgba -- n ) [ red>> scale ] [ green>> scale ] [ blue>> scale ] tri 3byte-array ; -: sat 0.85 ; inline -: val 0.85 ; inline +CONSTANT: sat 0.85 +CONSTANT: val 0.85 : ( nb-cols -- map ) dup [ diff --git a/extra/benchmark/mandel/params/params.factor b/extra/benchmark/mandel/params/params.factor index c40d3c1f2d..8a19180d73 100644 --- a/extra/benchmark/mandel/params/params.factor +++ b/extra/benchmark/mandel/params/params.factor @@ -1,8 +1,8 @@ IN: benchmark.mandel.params -: max-color 360 ; inline -: zoom-fact 0.8 ; inline -: width 640 ; inline -: height 480 ; inline -: max-iterations 40 ; inline -: center -0.65 ; inline +CONSTANT: max-color 360 +CONSTANT: zoom-fact 0.8 +CONSTANT: width 640 +CONSTANT: height 480 +CONSTANT: max-iterations 40 +CONSTANT: center -0.65 diff --git a/extra/benchmark/nbody/nbody.factor b/extra/benchmark/nbody/nbody.factor index 37c4fc43c5..f72ceb4629 100644 --- a/extra/benchmark/nbody/nbody.factor +++ b/extra/benchmark/nbody/nbody.factor @@ -6,7 +6,7 @@ sequences hints arrays ; IN: benchmark.nbody : solar-mass ( -- x ) 4 pi sq * ; inline -: days-per-year 365.24 ; inline +CONSTANT: days-per-year 365.24 TUPLE: body { location double-array } diff --git a/extra/benchmark/raytracer/raytracer.factor b/extra/benchmark/raytracer/raytracer.factor index c16e47846e..8d07ae1c65 100755 --- a/extra/benchmark/raytracer/raytracer.factor +++ b/extra/benchmark/raytracer/raytracer.factor @@ -16,13 +16,13 @@ IN: benchmark.raytracer 0.5345224838248488 } ; inline -: oversampling 4 ; inline +CONSTANT: oversampling 4 -: levels 3 ; inline +CONSTANT: levels 3 -: size 200 ; inline +CONSTANT: size 200 -: delta 1.4901161193847656E-8 ; inline +CONSTANT: delta 1.4901161193847656E-8 TUPLE: ray { orig double-array read-only } { dir double-array read-only } ; @@ -88,7 +88,7 @@ TUPLE: group < sphere { objs array read-only } ; M: group intersect-scene ( hit ray group -- hit ) [ drop objs>> [ intersect-scene ] with each ] if-ray-sphere ; -: initial-hit T{ hit f double-array{ 0.0 0.0 0.0 } 1/0. } ; inline +CONSTANT: initial-hit T{ hit f double-array{ 0.0 0.0 0.0 } 1/0. } : initial-intersect ( ray scene -- hit ) [ initial-hit ] 2dip intersect-scene ; inline diff --git a/extra/crypto/aes/aes.factor b/extra/crypto/aes/aes.factor index cacfc5971a..0807420266 100644 --- a/extra/crypto/aes/aes.factor +++ b/extra/crypto/aes/aes.factor @@ -4,7 +4,7 @@ USING: arrays kernel math memoize sequences math.bitwise locals ; IN: crypto.aes -: AES_BLOCK_SIZE 16 ; inline +CONSTANT: AES_BLOCK_SIZE 16 : sbox ( -- array ) { diff --git a/extra/crypto/rsa/rsa.factor b/extra/crypto/rsa/rsa.factor index b1eb907547..373dd9637c 100644 --- a/extra/crypto/rsa/rsa.factor +++ b/extra/crypto/rsa/rsa.factor @@ -18,7 +18,7 @@ C: rsa BOOLEAN ( n -- TRUE/FALSE ) >boolean TRUE FALSE ? ; inline ERROR: duplicate-window window ; diff --git a/extra/curses/ffi/ffi.factor b/extra/curses/ffi/ffi.factor index 8d4a7ddb4b..b1c481a576 100644 --- a/extra/curses/ffi/ffi.factor +++ b/extra/curses/ffi/ffi.factor @@ -18,7 +18,7 @@ TYPEDEF: chtype attr_t TYPEDEF: short NCURSES_SIZE_T TYPEDEF: ushort wchar_t -: CCHARW_MAX 5 ; inline +CONSTANT: CCHARW_MAX 5 C-STRUCT: cchar_t { "attr_t" "attr" } diff --git a/extra/math/analysis/analysis.factor b/extra/math/analysis/analysis.factor index b5f6a547ba..9c773f748e 100755 --- a/extra/math/analysis/analysis.factor +++ b/extra/math/analysis/analysis.factor @@ -9,7 +9,7 @@ IN: math.analysis ! http://www.rskey.org/gamma.htm "Lanczos Approximation" ! n=6: error ~ 3 x 10^-11 -: gamma-g6 5.15 ; inline +CONSTANT: gamma-g6 5.15 : gamma-p6 { diff --git a/extra/opengl/demo-support/demo-support.factor b/extra/opengl/demo-support/demo-support.factor index c8fe2b4882..9f05482b30 100755 --- a/extra/opengl/demo-support/demo-support.factor +++ b/extra/opengl/demo-support/demo-support.factor @@ -4,8 +4,8 @@ ui.render accessors combinators ; IN: opengl.demo-support : FOV ( -- x ) 2.0 sqrt 1+ ; inline -: MOUSE-MOTION-SCALE 0.5 ; inline -: KEY-ROTATE-STEP 10.0 ; inline +CONSTANT: MOUSE-MOTION-SCALE 0.5 +CONSTANT: KEY-ROTATE-STEP 10.0 SYMBOL: last-drag-loc diff --git a/extra/tetris/game/game.factor b/extra/tetris/game/game.factor index ef5ffcc344..00b5bb6c41 100644 --- a/extra/tetris/game/game.factor +++ b/extra/tetris/game/game.factor @@ -12,8 +12,8 @@ TUPLE: tetris { paused? initial: f } { running? initial: t } ; -: default-width 10 ; inline -: default-height 20 ; inline +CONSTANT: default-width 10 +CONSTANT: default-height 20 : ( width height -- tetris ) dupd swap From a6b40707df0466d51464d3587ac608d9bba02dfd Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 19:09:49 -0600 Subject: [PATCH 44/85] use CONSTANT: in core/ --- core/checksums/crc32/crc32.factor | 4 ++-- core/combinators/combinators-tests.factor | 4 ++-- core/io/encodings/encodings.factor | 2 +- core/words/words.factor | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/checksums/crc32/crc32.factor b/core/checksums/crc32/crc32.factor index d373a96f39..7ea2964411 100644 --- a/core/checksums/crc32/crc32.factor +++ b/core/checksums/crc32/crc32.factor @@ -5,9 +5,9 @@ words io io.binary io.files io.streams.string quotations definitions checksums ; IN: checksums.crc32 -: crc32-polynomial HEX: edb88320 ; inline +CONSTANT: crc32-polynomial HEX: edb88320 -: crc32-table V{ } ; inline +CONSTANT: crc32-table V{ } 256 [ 8 [ diff --git a/core/combinators/combinators-tests.factor b/core/combinators/combinators-tests.factor index beb50f1162..1ee3a4e3ed 100644 --- a/core/combinators/combinators-tests.factor +++ b/core/combinators/combinators-tests.factor @@ -176,8 +176,8 @@ IN: combinators.tests [ "an array" ] [ { 1 2 3 } case-test-3 ] unit-test -: case-const-1 1 ; -: case-const-2 2 ; inline +CONSTANT: case-const-1 1 +CONSTANT: case-const-2 2 ! Compiled : case-test-4 ( obj -- str ) diff --git a/core/io/encodings/encodings.factor b/core/io/encodings/encodings.factor index 94d2115478..e8735afa6a 100644 --- a/core/io/encodings/encodings.factor +++ b/core/io/encodings/encodings.factor @@ -14,7 +14,7 @@ GENERIC: encode-char ( char stream encoding -- ) GENERIC: ( stream encoding -- newstream ) -: replacement-char HEX: fffd ; inline +CONSTANT: replacement-char HEX: fffd TUPLE: decoder stream code cr ; diff --git a/core/words/words.factor b/core/words/words.factor index 8648664031..4a3c1b2d52 100755 --- a/core/words/words.factor +++ b/core/words/words.factor @@ -134,7 +134,7 @@ compiled-generic-crossref [ H{ } clone ] initialize SYMBOL: visited -: reset-on-redefine { "inferred-effect" "cannot-infer" } ; inline +CONSTANT: reset-on-redefine { "inferred-effect" "cannot-infer" } : (redefined) ( word -- ) dup visited get key? [ drop ] [ From 990513db600192f44c01a2ea0f5d9b205e2aeb3e Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 19:13:08 -0600 Subject: [PATCH 45/85] use CONSTANT: in basis --- basis/bootstrap/image/image.factor | 20 +++++----- basis/calendar/calendar.factor | 2 +- basis/checksums/adler-32/adler-32.factor | 2 +- basis/checksums/sha2/sha2.factor | 16 ++++---- basis/cocoa/enumeration/enumeration.factor | 2 +- basis/cocoa/windows/windows.factor | 16 ++++---- basis/colors/colors.factor | 26 ++++++------ basis/compiler/constants/constants.factor | 38 +++++++++--------- .../tree/propagation/info/info.factor | 4 +- basis/core-foundation/core-foundation.factor | 2 +- basis/core-foundation/data/data.factor | 40 +++++++++---------- .../file-descriptors/file-descriptors.factor | 4 +- .../core-foundation/fsevents/fsevents.factor | 22 +++++----- .../core-foundation/run-loop/run-loop.factor | 8 ++-- basis/core-foundation/urls/urls.factor | 2 +- basis/cpu/ppc/ppc.factor | 8 ++-- basis/io/files/info/unix/unix.factor | 30 +++++++------- basis/io/sockets/unix/unix.factor | 2 +- basis/math/bitwise/bitwise-tests.factor | 4 +- basis/openssl/libcrypto/libcrypto.factor | 12 +++--- basis/persistent/vectors/vectors.factor | 2 +- .../mersenne-twister/mersenne-twister.factor | 6 +-- .../transforms/transforms.factor | 2 +- basis/tools/disassembler/udis/udis.factor | 8 ++-- basis/unix/stat/netbsd/netbsd.factor | 4 +- basis/unrolled-lists/unrolled-lists.factor | 2 +- basis/x11/xlib/xlib.factor | 16 ++++---- 27 files changed, 150 insertions(+), 150 deletions(-) diff --git a/basis/bootstrap/image/image.factor b/basis/bootstrap/image/image.factor index 221ffffb91..10cde266cc 100644 --- a/basis/bootstrap/image/image.factor +++ b/basis/bootstrap/image/image.factor @@ -77,20 +77,20 @@ SYMBOL: objects ! Constants -: image-magic HEX: 0f0e0d0c ; inline -: image-version 4 ; inline +CONSTANT: image-magic HEX: 0f0e0d0c +CONSTANT: image-version 4 -: data-base 1024 ; inline +CONSTANT: data-base 1024 -: userenv-size 70 ; inline +CONSTANT: userenv-size 70 -: header-size 10 ; inline +CONSTANT: header-size 10 -: data-heap-size-offset 3 ; inline -: t-offset 6 ; inline -: 0-offset 7 ; inline -: 1-offset 8 ; inline -: -1-offset 9 ; inline +CONSTANT: data-heap-size-offset 3 +CONSTANT: t-offset 6 +CONSTANT: 0-offset 7 +CONSTANT: 1-offset 8 +CONSTANT: -1-offset 9 SYMBOL: sub-primitives diff --git a/basis/calendar/calendar.factor b/basis/calendar/calendar.factor index 522e0c52f3..dc9442259b 100644 --- a/basis/calendar/calendar.factor +++ b/basis/calendar/calendar.factor @@ -61,7 +61,7 @@ PRIVATE> : month-abbreviation ( n -- string ) check-month 1- month-abbreviations nth ; -: day-counts { 0 31 28 31 30 31 30 31 31 30 31 30 31 } ; inline +CONSTANT: day-counts { 0 31 28 31 30 31 30 31 31 30 31 30 31 } : day-names ( -- array ) { diff --git a/basis/checksums/adler-32/adler-32.factor b/basis/checksums/adler-32/adler-32.factor index 1be4bfb584..d5e153ba99 100644 --- a/basis/checksums/adler-32/adler-32.factor +++ b/basis/checksums/adler-32/adler-32.factor @@ -6,7 +6,7 @@ IN: checksums.adler-32 SINGLETON: adler-32 -: adler-32-modulus 65521 ; inline +CONSTANT: adler-32-modulus 65521 M: adler-32 checksum-bytes ( bytes checksum -- value ) drop diff --git a/basis/checksums/sha2/sha2.factor b/basis/checksums/sha2/sha2.factor index 026c4d6f27..3b092a78de 100644 --- a/basis/checksums/sha2/sha2.factor +++ b/basis/checksums/sha2/sha2.factor @@ -9,14 +9,14 @@ IN: checksums.sha2 SYMBOLS: vars M K H S0 S1 process-M word-size block-size ; -: a 0 ; inline -: b 1 ; inline -: c 2 ; inline -: d 3 ; inline -: e 4 ; inline -: f 5 ; inline -: g 6 ; inline -: h 7 ; inline +CONSTANT: a 0 +CONSTANT: b 1 +CONSTANT: c 2 +CONSTANT: d 3 +CONSTANT: e 4 +CONSTANT: f 5 +CONSTANT: g 6 +CONSTANT: h 7 : initial-H-256 ( -- seq ) { diff --git a/basis/cocoa/enumeration/enumeration.factor b/basis/cocoa/enumeration/enumeration.factor index 7f5b777283..919e8f86c5 100644 --- a/basis/cocoa/enumeration/enumeration.factor +++ b/basis/cocoa/enumeration/enumeration.factor @@ -5,7 +5,7 @@ sequences vectors fry libc destructors specialized-arrays.direct.alien ; IN: cocoa.enumeration -: NS-EACH-BUFFER-SIZE 16 ; inline +CONSTANT: NS-EACH-BUFFER-SIZE 16 : with-enumeration-buffers ( quot -- ) [ diff --git a/basis/cocoa/windows/windows.factor b/basis/cocoa/windows/windows.factor index 51f692d02d..4e0f768b96 100644 --- a/basis/cocoa/windows/windows.factor +++ b/basis/cocoa/windows/windows.factor @@ -4,15 +4,15 @@ USING: arrays kernel math cocoa cocoa.messages cocoa.classes sequences math.bitwise ; IN: cocoa.windows -: NSBorderlessWindowMask 0 ; inline -: NSTitledWindowMask 1 ; inline -: NSClosableWindowMask 2 ; inline -: NSMiniaturizableWindowMask 4 ; inline -: NSResizableWindowMask 8 ; inline +CONSTANT: NSBorderlessWindowMask 0 +CONSTANT: NSTitledWindowMask 1 +CONSTANT: NSClosableWindowMask 2 +CONSTANT: NSMiniaturizableWindowMask 4 +CONSTANT: NSResizableWindowMask 8 -: NSBackingStoreRetained 0 ; inline -: NSBackingStoreNonretained 1 ; inline -: NSBackingStoreBuffered 2 ; inline +CONSTANT: NSBackingStoreRetained 0 +CONSTANT: NSBackingStoreNonretained 1 +CONSTANT: NSBackingStoreBuffered 2 : standard-window-type ( -- n ) { diff --git a/basis/colors/colors.factor b/basis/colors/colors.factor index 1183c2e46c..9c55b1f29a 100644 --- a/basis/colors/colors.factor +++ b/basis/colors/colors.factor @@ -18,16 +18,16 @@ M: color red>> ( color -- red ) >rgba red>> ; M: color green>> ( color -- green ) >rgba green>> ; M: color blue>> ( color -- blue ) >rgba blue>> ; -: black T{ rgba f 0.0 0.0 0.0 1.0 } ; inline -: blue T{ rgba f 0.0 0.0 1.0 1.0 } ; inline -: cyan T{ rgba f 0 0.941 0.941 1 } ; inline -: gray T{ rgba f 0.6 0.6 0.6 1.0 } ; inline -: green T{ rgba f 0.0 1.0 0.0 1.0 } ; inline -: light-gray T{ rgba f 0.95 0.95 0.95 0.95 } ; inline -: light-purple T{ rgba f 0.8 0.8 1.0 1.0 } ; inline -: magenta T{ rgba f 0.941 0 0.941 1 } ; inline -: orange T{ rgba f 0.941 0.627 0 1 } ; inline -: purple T{ rgba f 0.627 0 0.941 1 } ; inline -: red T{ rgba f 1.0 0.0 0.0 1.0 } ; inline -: white T{ rgba f 1.0 1.0 1.0 1.0 } ; inline -: yellow T{ rgba f 1.0 1.0 0.0 1.0 } ; inline +CONSTANT: black T{ rgba f 0.0 0.0 0.0 1.0 } +CONSTANT: blue T{ rgba f 0.0 0.0 1.0 1.0 } +CONSTANT: cyan T{ rgba f 0 0.941 0.941 1 } +CONSTANT: gray T{ rgba f 0.6 0.6 0.6 1.0 } +CONSTANT: green T{ rgba f 0.0 1.0 0.0 1.0 } +CONSTANT: light-gray T{ rgba f 0.95 0.95 0.95 0.95 } +CONSTANT: light-purple T{ rgba f 0.8 0.8 1.0 1.0 } +CONSTANT: magenta T{ rgba f 0.941 0 0.941 1 } +CONSTANT: orange T{ rgba f 0.941 0.627 0 1 } +CONSTANT: purple T{ rgba f 0.627 0 0.941 1 } +CONSTANT: red T{ rgba f 1.0 0.0 0.0 1.0 } +CONSTANT: white T{ rgba f 1.0 1.0 1.0 1.0 } +CONSTANT: yellow T{ rgba f 1.0 1.0 0.0 1.0 } diff --git a/basis/compiler/constants/constants.factor b/basis/compiler/constants/constants.factor index 48ea958818..e03c062e9e 100644 --- a/basis/compiler/constants/constants.factor +++ b/basis/compiler/constants/constants.factor @@ -4,8 +4,8 @@ USING: math kernel layouts system strings ; IN: compiler.constants ! These constants must match vm/memory.h -: card-bits 8 ; inline -: deck-bits 18 ; inline +CONSTANT: card-bits 8 +CONSTANT: deck-bits 18 : card-mark ( -- n ) HEX: 40 HEX: 80 bitor ; inline ! These constants must match vm/layouts.h @@ -26,25 +26,25 @@ IN: compiler.constants : compiled-header-size ( -- n ) 4 bootstrap-cells ; inline ! Relocation classes -: rc-absolute-cell 0 ; inline -: rc-absolute 1 ; inline -: rc-relative 2 ; inline -: rc-absolute-ppc-2/2 3 ; inline -: rc-relative-ppc-2 4 ; inline -: rc-relative-ppc-3 5 ; inline -: rc-relative-arm-3 6 ; inline -: rc-indirect-arm 7 ; inline -: rc-indirect-arm-pc 8 ; inline +CONSTANT: rc-absolute-cell 0 +CONSTANT: rc-absolute 1 +CONSTANT: rc-relative 2 +CONSTANT: rc-absolute-ppc-2/2 3 +CONSTANT: rc-relative-ppc-2 4 +CONSTANT: rc-relative-ppc-3 5 +CONSTANT: rc-relative-arm-3 6 +CONSTANT: rc-indirect-arm 7 +CONSTANT: rc-indirect-arm-pc 8 ! Relocation types -: rt-primitive 0 ; inline -: rt-dlsym 1 ; inline -: rt-dispatch 2 ; inline -: rt-xt 3 ; inline -: rt-here 4 ; inline -: rt-label 5 ; inline -: rt-immediate 6 ; inline -: rt-stack-chain 7 ; inline +CONSTANT: rt-primitive 0 +CONSTANT: rt-dlsym 1 +CONSTANT: rt-dispatch 2 +CONSTANT: rt-xt 3 +CONSTANT: rt-here 4 +CONSTANT: rt-label 5 +CONSTANT: rt-immediate 6 +CONSTANT: rt-stack-chain 7 : rc-absolute? ( n -- ? ) [ rc-absolute-ppc-2/2 = ] diff --git a/basis/compiler/tree/propagation/info/info.factor b/basis/compiler/tree/propagation/info/info.factor index 771d3800df..7b1723620b 100644 --- a/basis/compiler/tree/propagation/info/info.factor +++ b/basis/compiler/tree/propagation/info/info.factor @@ -32,9 +32,9 @@ literal? length slots ; -: null-info T{ value-info f null empty-interval } ; inline +CONSTANT: null-info T{ value-info f null empty-interval } -: object-info T{ value-info f object full-interval } ; inline +CONSTANT: object-info T{ value-info f object full-interval } : class-interval ( class -- interval ) dup real class<= diff --git a/basis/core-foundation/core-foundation.factor b/basis/core-foundation/core-foundation.factor index ec83ba7a8b..40269ae3be 100644 --- a/basis/core-foundation/core-foundation.factor +++ b/basis/core-foundation/core-foundation.factor @@ -6,7 +6,7 @@ IN: core-foundation TYPEDEF: void* CFTypeRef TYPEDEF: void* CFAllocatorRef -: kCFAllocatorDefault f ; inline +CONSTANT: kCFAllocatorDefault f TYPEDEF: bool Boolean TYPEDEF: long CFIndex diff --git a/basis/core-foundation/data/data.factor b/basis/core-foundation/data/data.factor index f4d2babca7..fb5ecaa043 100644 --- a/basis/core-foundation/data/data.factor +++ b/basis/core-foundation/data/data.factor @@ -10,28 +10,28 @@ TYPEDEF: void* CFNumberRef TYPEDEF: void* CFSetRef TYPEDEF: int CFNumberType -: kCFNumberSInt8Type 1 ; inline -: kCFNumberSInt16Type 2 ; inline -: kCFNumberSInt32Type 3 ; inline -: kCFNumberSInt64Type 4 ; inline -: kCFNumberFloat32Type 5 ; inline -: kCFNumberFloat64Type 6 ; inline -: kCFNumberCharType 7 ; inline -: kCFNumberShortType 8 ; inline -: kCFNumberIntType 9 ; inline -: kCFNumberLongType 10 ; inline -: kCFNumberLongLongType 11 ; inline -: kCFNumberFloatType 12 ; inline -: kCFNumberDoubleType 13 ; inline -: kCFNumberCFIndexType 14 ; inline -: kCFNumberNSIntegerType 15 ; inline -: kCFNumberCGFloatType 16 ; inline -: kCFNumberMaxType 16 ; inline +CONSTANT: kCFNumberSInt8Type 1 +CONSTANT: kCFNumberSInt16Type 2 +CONSTANT: kCFNumberSInt32Type 3 +CONSTANT: kCFNumberSInt64Type 4 +CONSTANT: kCFNumberFloat32Type 5 +CONSTANT: kCFNumberFloat64Type 6 +CONSTANT: kCFNumberCharType 7 +CONSTANT: kCFNumberShortType 8 +CONSTANT: kCFNumberIntType 9 +CONSTANT: kCFNumberLongType 10 +CONSTANT: kCFNumberLongLongType 11 +CONSTANT: kCFNumberFloatType 12 +CONSTANT: kCFNumberDoubleType 13 +CONSTANT: kCFNumberCFIndexType 14 +CONSTANT: kCFNumberNSIntegerType 15 +CONSTANT: kCFNumberCGFloatType 16 +CONSTANT: kCFNumberMaxType 16 TYPEDEF: int CFPropertyListMutabilityOptions -: kCFPropertyListImmutable 0 ; inline -: kCFPropertyListMutableContainers 1 ; inline -: kCFPropertyListMutableContainersAndLeaves 2 ; inline +CONSTANT: kCFPropertyListImmutable 0 +CONSTANT: kCFPropertyListMutableContainers 1 +CONSTANT: kCFPropertyListMutableContainersAndLeaves 2 FUNCTION: CFNumberRef CFNumberCreate ( CFAllocatorRef allocator, CFNumberType theType, void* valuePtr ) ; diff --git a/basis/core-foundation/file-descriptors/file-descriptors.factor b/basis/core-foundation/file-descriptors/file-descriptors.factor index 29c4219678..c9fe3131b1 100644 --- a/basis/core-foundation/file-descriptors/file-descriptors.factor +++ b/basis/core-foundation/file-descriptors/file-descriptors.factor @@ -15,8 +15,8 @@ FUNCTION: CFFileDescriptorRef CFFileDescriptorCreate ( CFFileDescriptorContext* context ) ; -: kCFFileDescriptorReadCallBack 1 ; inline -: kCFFileDescriptorWriteCallBack 2 ; inline +CONSTANT: kCFFileDescriptorReadCallBack 1 +CONSTANT: kCFFileDescriptorWriteCallBack 2 FUNCTION: void CFFileDescriptorEnableCallBacks ( CFFileDescriptorRef f, diff --git a/basis/core-foundation/fsevents/fsevents.factor b/basis/core-foundation/fsevents/fsevents.factor index b0c299a831..06b9c6407b 100644 --- a/basis/core-foundation/fsevents/fsevents.factor +++ b/basis/core-foundation/fsevents/fsevents.factor @@ -9,17 +9,17 @@ core-foundation core-foundation.run-loop core-foundation.strings core-foundation.time ; IN: core-foundation.fsevents -: kFSEventStreamCreateFlagUseCFTypes 2 ; inline -: kFSEventStreamCreateFlagWatchRoot 4 ; inline +CONSTANT: kFSEventStreamCreateFlagUseCFTypes 2 +CONSTANT: kFSEventStreamCreateFlagWatchRoot 4 -: kFSEventStreamEventFlagMustScanSubDirs 1 ; inline -: kFSEventStreamEventFlagUserDropped 2 ; inline -: kFSEventStreamEventFlagKernelDropped 4 ; inline -: kFSEventStreamEventFlagEventIdsWrapped 8 ; inline -: kFSEventStreamEventFlagHistoryDone 16 ; inline -: kFSEventStreamEventFlagRootChanged 32 ; inline -: kFSEventStreamEventFlagMount 64 ; inline -: kFSEventStreamEventFlagUnmount 128 ; inline +CONSTANT: kFSEventStreamEventFlagMustScanSubDirs 1 +CONSTANT: kFSEventStreamEventFlagUserDropped 2 +CONSTANT: kFSEventStreamEventFlagKernelDropped 4 +CONSTANT: kFSEventStreamEventFlagEventIdsWrapped 8 +CONSTANT: kFSEventStreamEventFlagHistoryDone 16 +CONSTANT: kFSEventStreamEventFlagRootChanged 32 +CONSTANT: kFSEventStreamEventFlagMount 64 +CONSTANT: kFSEventStreamEventFlagUnmount 128 TYPEDEF: int FSEventStreamCreateFlags TYPEDEF: int FSEventStreamEventFlags @@ -36,7 +36,7 @@ C-STRUCT: FSEventStreamContext ! callback(FSEventStreamRef streamRef, void *clientCallBackInfo, size_t numEvents, void *eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]); TYPEDEF: void* FSEventStreamCallback -: FSEventStreamEventIdSinceNow HEX: FFFFFFFFFFFFFFFF ; inline +CONSTANT: FSEventStreamEventIdSinceNow HEX: FFFFFFFFFFFFFFFF FUNCTION: FSEventStreamRef FSEventStreamCreate ( CFAllocatorRef allocator, diff --git a/basis/core-foundation/run-loop/run-loop.factor b/basis/core-foundation/run-loop/run-loop.factor index 4b98e9a410..8bdce2ec37 100644 --- a/basis/core-foundation/run-loop/run-loop.factor +++ b/basis/core-foundation/run-loop/run-loop.factor @@ -7,10 +7,10 @@ core-foundation.file-descriptors core-foundation.timers core-foundation.time ; IN: core-foundation.run-loop -: kCFRunLoopRunFinished 1 ; inline -: kCFRunLoopRunStopped 2 ; inline -: kCFRunLoopRunTimedOut 3 ; inline -: kCFRunLoopRunHandledSource 4 ; inline +CONSTANT: kCFRunLoopRunFinished 1 +CONSTANT: kCFRunLoopRunStopped 2 +CONSTANT: kCFRunLoopRunTimedOut 3 +CONSTANT: kCFRunLoopRunHandledSource 4 TYPEDEF: void* CFRunLoopRef TYPEDEF: void* CFRunLoopSourceRef diff --git a/basis/core-foundation/urls/urls.factor b/basis/core-foundation/urls/urls.factor index 9f9d3a67cb..7ffef498b6 100644 --- a/basis/core-foundation/urls/urls.factor +++ b/basis/core-foundation/urls/urls.factor @@ -4,7 +4,7 @@ USING: alien.syntax kernel core-foundation.strings core-foundation ; IN: core-foundation.urls -: kCFURLPOSIXPathStyle 0 ; inline +CONSTANT: kCFURLPOSIXPathStyle 0 TYPEDEF: void* CFURLRef diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor index f245bcb7e1..8b6b4fbb11 100644 --- a/basis/cpu/ppc/ppc.factor +++ b/basis/cpu/ppc/ppc.factor @@ -27,8 +27,8 @@ M: ppc machine-registers { double-float-regs T{ range f 0 29 1 } } } ; -: scratch-reg 28 ; inline -: fp-scratch-reg 30 ; inline +CONSTANT: scratch-reg 28 +CONSTANT: fp-scratch-reg 30 M: ppc two-operand? f ; @@ -40,8 +40,8 @@ M: ppc %load-reference ( reg obj -- ) M: ppc %alien-global ( register symbol dll -- ) [ 0 swap LOAD32 ] 2dip rc-absolute-ppc-2/2 rel-dlsym ; -: ds-reg 29 ; inline -: rs-reg 30 ; inline +CONSTANT: ds-reg 29 +CONSTANT: rs-reg 30 GENERIC: loc-reg ( loc -- reg ) diff --git a/basis/io/files/info/unix/unix.factor b/basis/io/files/info/unix/unix.factor index b7edc14c2c..616f70cccc 100644 --- a/basis/io/files/info/unix/unix.factor +++ b/basis/io/files/info/unix/unix.factor @@ -114,21 +114,21 @@ M: file-info file-mode? [ permissions>> ] dip mask? ; PRIVATE> -: UID OCT: 0004000 ; inline -: GID OCT: 0002000 ; inline -: STICKY OCT: 0001000 ; inline -: USER-ALL OCT: 0000700 ; inline -: USER-READ OCT: 0000400 ; inline -: USER-WRITE OCT: 0000200 ; inline -: USER-EXECUTE OCT: 0000100 ; inline -: GROUP-ALL OCT: 0000070 ; inline -: GROUP-READ OCT: 0000040 ; inline -: GROUP-WRITE OCT: 0000020 ; inline -: GROUP-EXECUTE OCT: 0000010 ; inline -: OTHER-ALL OCT: 0000007 ; inline -: OTHER-READ OCT: 0000004 ; inline -: OTHER-WRITE OCT: 0000002 ; inline -: OTHER-EXECUTE OCT: 0000001 ; inline +CONSTANT: UID OCT: 0004000 +CONSTANT: GID OCT: 0002000 +CONSTANT: STICKY OCT: 0001000 +CONSTANT: USER-ALL OCT: 0000700 +CONSTANT: USER-READ OCT: 0000400 +CONSTANT: USER-WRITE OCT: 0000200 +CONSTANT: USER-EXECUTE OCT: 0000100 +CONSTANT: GROUP-ALL OCT: 0000070 +CONSTANT: GROUP-READ OCT: 0000040 +CONSTANT: GROUP-WRITE OCT: 0000020 +CONSTANT: GROUP-EXECUTE OCT: 0000010 +CONSTANT: OTHER-ALL OCT: 0000007 +CONSTANT: OTHER-READ OCT: 0000004 +CONSTANT: OTHER-WRITE OCT: 0000002 +CONSTANT: OTHER-EXECUTE OCT: 0000001 : uid? ( obj -- ? ) UID file-mode? ; : gid? ( obj -- ? ) GID file-mode? ; diff --git a/basis/io/sockets/unix/unix.factor b/basis/io/sockets/unix/unix.factor index e701874afd..799dfa78d5 100644 --- a/basis/io/sockets/unix/unix.factor +++ b/basis/io/sockets/unix/unix.factor @@ -94,7 +94,7 @@ M: unix (datagram) SYMBOL: receive-buffer -: packet-size 65536 ; inline +CONSTANT: packet-size 65536 [ packet-size malloc receive-buffer set-global ] "io.sockets.unix" add-init-hook diff --git a/basis/math/bitwise/bitwise-tests.factor b/basis/math/bitwise/bitwise-tests.factor index 40eb20642c..7698760f84 100644 --- a/basis/math/bitwise/bitwise-tests.factor +++ b/basis/math/bitwise/bitwise-tests.factor @@ -19,8 +19,8 @@ IN: math.bitwise.tests [ 268 ] [ 1 { 8 { 3 2 } } bitfield ] unit-test [ 512 ] [ 1 { { 1+ 8 } } bitfield ] unit-test -: a 1 ; inline -: b 2 ; inline +CONSTANT: a 1 +CONSTANT: b 2 : foo ( -- flags ) { a b } flags ; diff --git a/basis/openssl/libcrypto/libcrypto.factor b/basis/openssl/libcrypto/libcrypto.factor index 80bf3b1772..3204b83bbb 100644 --- a/basis/openssl/libcrypto/libcrypto.factor +++ b/basis/openssl/libcrypto/libcrypto.factor @@ -48,14 +48,14 @@ C-STRUCT: bio { "void*" "crypto-ex-data-stack" } { "int" "crypto-ex-data-dummy" } ; -: BIO_NOCLOSE HEX: 00 ; inline -: BIO_CLOSE HEX: 01 ; inline +CONSTANT: BIO_NOCLOSE HEX: 00 +CONSTANT: BIO_CLOSE HEX: 01 -: RSA_3 HEX: 3 ; inline -: RSA_F4 HEX: 10001 ; inline +CONSTANT: RSA_3 HEX: 3 +CONSTANT: RSA_F4 HEX: 10001 -: BIO_C_SET_SSL 109 ; inline -: BIO_C_GET_SSL 110 ; inline +CONSTANT: BIO_C_SET_SSL 109 +CONSTANT: BIO_C_GET_SSL 110 LIBRARY: libcrypto diff --git a/basis/persistent/vectors/vectors.factor b/basis/persistent/vectors/vectors.factor index 554db08e70..478fc0ad25 100644 --- a/basis/persistent/vectors/vectors.factor +++ b/basis/persistent/vectors/vectors.factor @@ -20,7 +20,7 @@ TUPLE: persistent-vector M: persistent-vector length count>> ; -: node-size 32 ; inline +CONSTANT: node-size 32 : node-mask ( m -- n ) node-size mod ; inline diff --git a/basis/random/mersenne-twister/mersenne-twister.factor b/basis/random/mersenne-twister/mersenne-twister.factor index 67b0fa23e7..361ba7719e 100644 --- a/basis/random/mersenne-twister/mersenne-twister.factor +++ b/basis/random/mersenne-twister/mersenne-twister.factor @@ -11,9 +11,9 @@ IN: random.mersenne-twister TUPLE: mersenne-twister { seq uint-array } { i fixnum } ; -: n 624 ; inline -: m 397 ; inline -: a uint-array{ 0 HEX: 9908b0df } ; inline +CONSTANT: n 624 +CONSTANT: m 397 +CONSTANT: a uint-array{ 0 HEX: 9908b0df } : y ( n seq -- y ) [ nth-unsafe 31 mask-bit ] diff --git a/basis/stack-checker/transforms/transforms.factor b/basis/stack-checker/transforms/transforms.factor index a2f616480a..afb7e0843c 100755 --- a/basis/stack-checker/transforms/transforms.factor +++ b/basis/stack-checker/transforms/transforms.factor @@ -105,7 +105,7 @@ IN: stack-checker.transforms ] 1 define-transform ! Membership testing -: bit-member-n 256 ; inline +CONSTANT: bit-member-n 256 : bit-member? ( seq -- ? ) #! Can we use a fast byte array test here? diff --git a/basis/tools/disassembler/udis/udis.factor b/basis/tools/disassembler/udis/udis.factor index cfa2483c7e..8f99e4f440 100644 --- a/basis/tools/disassembler/udis/udis.factor +++ b/basis/tools/disassembler/udis/udis.factor @@ -24,10 +24,10 @@ FUNCTION: void ud_translate_att ( ud* u ) ; : UD_SYN_INTEL ( -- addr ) &: ud_translate_intel ; inline : UD_SYN_ATT ( -- addr ) &: ud_translate_att ; inline -: UD_EOI -1 ; inline -: UD_INP_CACHE_SZ 32 ; inline -: UD_VENDOR_AMD 0 ; inline -: UD_VENDOR_INTEL 1 ; inline +CONSTANT: UD_EOI -1 +CONSTANT: UD_INP_CACHE_SZ 32 +CONSTANT: UD_VENDOR_AMD 0 +CONSTANT: UD_VENDOR_INTEL 1 FUNCTION: void ud_init ( ud* u ) ; FUNCTION: void ud_set_mode ( ud* u, uint8_t mode ) ; diff --git a/basis/unix/stat/netbsd/netbsd.factor b/basis/unix/stat/netbsd/netbsd.factor index 0bcb886417..b60a0b1adc 100644 --- a/basis/unix/stat/netbsd/netbsd.factor +++ b/basis/unix/stat/netbsd/netbsd.factor @@ -6,8 +6,8 @@ cell-bits { { 64 [ "unix.stat.netbsd.64" require ] } } case -: _VFS_NAMELEN 32 ; inline -: _VFS_MNAMELEN 1024 ; inline +CONSTANT: _VFS_NAMELEN 32 +CONSTANT: _VFS_MNAMELEN 1024 C-STRUCT: statvfs { "ulong" "f_flag" } diff --git a/basis/unrolled-lists/unrolled-lists.factor b/basis/unrolled-lists/unrolled-lists.factor index d434632abd..bd4a2c1114 100644 --- a/basis/unrolled-lists/unrolled-lists.factor +++ b/basis/unrolled-lists/unrolled-lists.factor @@ -4,7 +4,7 @@ USING: arrays math kernel accessors sequences sequences.private deques search-deques hashtables ; IN: unrolled-lists -: unroll-factor 32 ; inline +CONSTANT: unroll-factor 32 Date: Sun, 22 Feb 2009 19:20:28 -0600 Subject: [PATCH 46/85] use ?at instead of at* --- basis/alien/fortran/fortran.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/alien/fortran/fortran.factor b/basis/alien/fortran/fortran.factor index 915b7d3d4f..5e3dc24476 100644 --- a/basis/alien/fortran/fortran.factor +++ b/basis/alien/fortran/fortran.factor @@ -170,8 +170,8 @@ M: character-type (fortran-type>c-type) : (parse-fortran-type) ( fortran-type-string -- type ) parse-out swap parse-dims swap parse-size swap - dup >lower fortran>c-types at* - [ nip new-fortran-type ] [ drop misc-type boa ] if ; + >lower fortran>c-types ?at + [ new-fortran-type ] [ misc-type boa ] if ; : parse-fortran-type ( fortran-type-string/f -- type/f ) dup [ (parse-fortran-type) ] when ; From 127f9b357854626e8263b1b00898128dfee4ddc1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 22 Feb 2009 19:41:47 -0600 Subject: [PATCH 47/85] Add unit tests for bignum bug --- basis/math/bits/bits-tests.factor | 17 ++++++++++++++++- basis/math/functions/functions-tests.factor | 14 ++++++++++++++ .../math/miller-rabin/miller-rabin-tests.factor | 3 ++- core/math/integers/integers-tests.factor | 2 ++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/basis/math/bits/bits-tests.factor b/basis/math/bits/bits-tests.factor index 0503d27f33..ed4e8419c9 100644 --- a/basis/math/bits/bits-tests.factor +++ b/basis/math/bits/bits-tests.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. -USING: tools.test math.bits sequences arrays ; +USING: tools.test math math.bits sequences arrays ; IN: math.bits.tests [ t ] [ BIN: 111111 3 second ] unit-test @@ -14,3 +14,18 @@ IN: math.bits.tests [ 2 ] [ -3 make-bits length ] unit-test [ 1 ] [ 1 make-bits length ] unit-test [ 1 ] [ -1 make-bits length ] unit-test + +! Odd bug +[ t ] [ + 1067811677921310779 make-bits + 1067811677921310779 >bignum make-bits + sequence= +] unit-test + +[ t ] [ + 1067811677921310779 make-bits peek +] unit-test + +[ t ] [ + 1067811677921310779 >bignum make-bits peek +] unit-test \ No newline at end of file diff --git a/basis/math/functions/functions-tests.factor b/basis/math/functions/functions-tests.factor index cf0ce5f0bb..9f5ce36be1 100644 --- a/basis/math/functions/functions-tests.factor +++ b/basis/math/functions/functions-tests.factor @@ -137,3 +137,17 @@ IN: math.functions.tests [ 6 59967 ] [ 3837888 factor-2s ] unit-test [ 6 -59967 ] [ -3837888 factor-2s ] unit-test + +[ 1 ] [ + 183009416410801897 + 1067811677921310779 + 2135623355842621559 + ^mod +] unit-test + +[ 1 ] [ + 183009416410801897 + 1067811677921310779 + 2135623355842621559 + [ >bignum ] tri@ ^mod +] unit-test \ No newline at end of file diff --git a/basis/math/miller-rabin/miller-rabin-tests.factor b/basis/math/miller-rabin/miller-rabin-tests.factor index 9ca85ea72c..5f1b9835e4 100644 --- a/basis/math/miller-rabin/miller-rabin-tests.factor +++ b/basis/math/miller-rabin/miller-rabin-tests.factor @@ -7,4 +7,5 @@ IN: math.miller-rabin.tests [ f ] [ 36 miller-rabin ] unit-test [ t ] [ 37 miller-rabin ] unit-test [ 101 ] [ 100 next-prime ] unit-test -[ 100000000000031 ] [ 100000000000000 next-prime ] unit-test +[ t ] [ 2135623355842621559 miller-rabin ] unit-test +[ 100000000000031 ] [ 100000000000000 next-prime ] unit-test \ No newline at end of file diff --git a/core/math/integers/integers-tests.factor b/core/math/integers/integers-tests.factor index 5a649120a0..6bd3e9b094 100644 --- a/core/math/integers/integers-tests.factor +++ b/core/math/integers/integers-tests.factor @@ -91,6 +91,8 @@ unit-test [ f ] [ BIN: -1101 >bignum 3 bit? ] unit-test [ t ] [ BIN: -1101 >bignum 4 bit? ] unit-test +[ t ] [ 1067811677921310779 >bignum 59 bit? ] unit-test + [ 2 ] [ 0 next-power-of-2 ] unit-test [ 2 ] [ 1 next-power-of-2 ] unit-test [ 2 ] [ 2 next-power-of-2 ] unit-test From 4257cd55e0ea37f1e279dd2f8c5abe2996284cca Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 22 Feb 2009 19:45:05 -0600 Subject: [PATCH 48/85] fix problem with bignum-bit? -- return value would be truncated if sizeof(int) != sizeof(bignum_digit_type) --- vm/bignum.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/vm/bignum.c b/vm/bignum.c index 1f4bc3ce76..497a4bbf62 100644 --- a/vm/bignum.c +++ b/vm/bignum.c @@ -1827,14 +1827,13 @@ int bignum_unsigned_logbitp(int shift, bignum_type bignum) { bignum_length_type len = (BIGNUM_LENGTH (bignum)); - bignum_digit_type digit; int index = shift / BIGNUM_DIGIT_LENGTH; - int p; if (index >= len) return 0; - digit = (BIGNUM_REF (bignum, index)); - p = shift % BIGNUM_DIGIT_LENGTH; - return digit & (1 << p); + bignum_digit_type digit = (BIGNUM_REF (bignum, index)); + int p = shift % BIGNUM_DIGIT_LENGTH; + bignum_digit_type mask = ((F_FIXNUM)1) << p; + return (digit & mask) ? 1 : 0; } /* Allocates memory */ From 2dcbd5b3db15e16464f4057dc5578900216dd056 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 22 Feb 2009 21:26:16 -0600 Subject: [PATCH 49/85] fix docs for a word --- core/io/encodings/encodings-docs.factor | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/io/encodings/encodings-docs.factor b/core/io/encodings/encodings-docs.factor index 509757c68a..e13e05bf40 100644 --- a/core/io/encodings/encodings-docs.factor +++ b/core/io/encodings/encodings-docs.factor @@ -1,4 +1,4 @@ -USING: help.markup help.syntax io quotations ; +USING: help.markup help.syntax io quotations math ; IN: io.encodings HELP: @@ -71,6 +71,9 @@ HELP: with-encoded-output { $description "Creates a new encoder with the given encoding descriptor and calls the quotation using this encoder. The original encoder object is restored after the quotation returns and the stream is kept open for future output operations." } ; HELP: replacement-char +{ $values + { "value" integer } +} { $description "A code point that replaces input that could not be decoded. The presence of this character in the decoded data usually signifies an error." } ; ARTICLE: "encodings-descriptors" "Encoding descriptors" From a4817a0e1712f0b1c521dc3a22de84f45493398c Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 23 Feb 2009 08:37:38 -0600 Subject: [PATCH 50/85] dont run postgresql tests on win64 --- basis/db/errors/postgresql/postgresql-tests.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/db/errors/postgresql/postgresql-tests.factor b/basis/db/errors/postgresql/postgresql-tests.factor index 9dbebe0712..f6668031e5 100644 --- a/basis/db/errors/postgresql/postgresql-tests.factor +++ b/basis/db/errors/postgresql/postgresql-tests.factor @@ -5,7 +5,7 @@ db.errors.postgresql db.postgresql io.files.unique kernel namespaces tools.test db.tester continuations ; IN: db.errors.postgresql.tests -postgresql-test-db [ +[ [ "drop table foo;" sql-command ] ignore-errors [ "drop table ship;" sql-command ] ignore-errors @@ -29,4 +29,4 @@ postgresql-test-db [ sql-syntax-error? ] must-fail-with -] with-db +] test-postgresql From c3ef25f81c1a8b0a11b8ad5ac5c214f482a30dfd Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 23 Feb 2009 10:35:42 -0600 Subject: [PATCH 51/85] made editors.emacs load windows file on windows --- basis/editors/emacs/emacs.factor | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/basis/editors/emacs/emacs.factor b/basis/editors/emacs/emacs.factor index fa717a70fa..05b879770e 100644 --- a/basis/editors/emacs/emacs.factor +++ b/basis/editors/emacs/emacs.factor @@ -1,6 +1,6 @@ USING: definitions io.launcher kernel parser words sequences math math.parser namespaces editors make system combinators.short-circuit -fry threads ; +fry threads vocabs.loader ; IN: editors.emacs SYMBOL: emacsclient-path @@ -22,3 +22,5 @@ M: object default-emacsclient ( -- path ) "emacsclient" ; where first2 emacsclient ; [ emacsclient ] edit-hook set-global + +os windows? [ "editors.emacs.windows" require ] when From ea851e3a3281db27f60ef3b1653738147435f7e4 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 23 Feb 2009 16:47:07 -0600 Subject: [PATCH 52/85] refactor cairo-demo a bit --- extra/cairo-demo/cairo-demo.factor | 66 +++++++++++++++++------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/extra/cairo-demo/cairo-demo.factor b/extra/cairo-demo/cairo-demo.factor index cec6702ce0..29eb5f4986 100644 --- a/extra/cairo-demo/cairo-demo.factor +++ b/extra/cairo-demo/cairo-demo.factor @@ -7,17 +7,16 @@ USING: cairo.ffi math math.constants byte-arrays kernel ui ui.render - ui.gadgets opengl.gl accessors ; +combinators ui.gadgets opengl.gl accessors ; IN: cairo-demo - : make-image-array ( -- array ) - 384 256 4 * * ; + 384 256 4 * * ; : convert-array-to-surface ( array -- cairo_surface_t ) - CAIRO_FORMAT_ARGB32 384 256 over 4 * - cairo_image_surface_create_for_data ; + CAIRO_FORMAT_ARGB32 384 256 over 4 * + cairo_image_surface_create_for_data ; TUPLE: cairo-demo-gadget < gadget image-array cairo-t ; @@ -33,41 +32,52 @@ M: cairo-demo-gadget draw-gadget* ( gadget -- ) convert-array-to-surface ; : init-cairo ( gadget -- cairo_t ) - create-surface cairo_create ; + create-surface cairo_create ; M: cairo-demo-gadget pref-dim* drop { 384 256 0 } ; +ERROR: no-cairo-t ; + +> - dup "Sans" CAIRO_FONT_SLANT_NORMAL CAIRO_FONT_WEIGHT_BOLD cairo_select_font_face - dup 90.0 cairo_set_font_size - dup 10.0 135.0 cairo_move_to - dup "Hello" cairo_show_text - dup 70.0 165.0 cairo_move_to - dup "World" cairo_text_path - dup 0.5 0.5 1 cairo_set_source_rgb - dup cairo_fill_preserve - dup 0 0 0 cairo_set_source_rgb - dup 2.56 cairo_set_line_width - dup cairo_stroke - dup 1 0.2 0.2 0.6 cairo_set_source_rgba - dup 10.0 135.0 5.12 0 pi 2 * cairo_arc - dup cairo_close_path - dup 70.0 165.0 5.12 0 pi 2 * cairo_arc - cairo_fill ; + cairo-t>> [ no-cairo-t ] unless* + { + [ + "Sans" CAIRO_FONT_SLANT_NORMAL CAIRO_FONT_WEIGHT_BOLD + cairo_select_font_face + ] + [ 90.0 cairo_set_font_size ] + [ 10.0 135.0 cairo_move_to ] + [ "Hello" cairo_show_text ] + [ 70.0 165.0 cairo_move_to ] + [ "World" cairo_text_path ] + [ 0.5 0.5 1 cairo_set_source_rgb ] + [ cairo_fill_preserve ] + [ 0 0 0 cairo_set_source_rgb ] + [ 2.56 cairo_set_line_width ] + [ cairo_stroke ] + [ 1 0.2 0.2 0.6 cairo_set_source_rgba ] + [ 10.0 135.0 5.12 0 pi 2 * cairo_arc ] + [ cairo_close_path ] + [ 70.0 165.0 5.12 0 pi 2 * cairo_arc ] + [ cairo_fill ] + } cleave ; + +PRIVATE> M: cairo-demo-gadget graft* ( gadget -- ) - dup dup init-cairo swap (>>cairo-t) draw-hello-world ; + dup dup init-cairo swap (>>cairo-t) draw-hello-world ; M: cairo-demo-gadget ungraft* ( gadget -- ) - cairo-t>> cairo_destroy ; + cairo-t>> cairo_destroy ; : ( -- gadget ) - cairo-demo-gadget new-gadget ; + cairo-demo-gadget new-gadget ; : run ( -- ) - [ + [ "Hello World from Factor!" open-window - ] with-ui ; + ] with-ui ; MAIN: run From f32f94c763a5192f94a4a04d6b6f134b75807722 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 23 Feb 2009 16:53:05 -0600 Subject: [PATCH 53/85] fix cairo-demo drawing --- extra/cairo-demo/cairo-demo.factor | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/extra/cairo-demo/cairo-demo.factor b/extra/cairo-demo/cairo-demo.factor index 29eb5f4986..da744e1d53 100644 --- a/extra/cairo-demo/cairo-demo.factor +++ b/extra/cairo-demo/cairo-demo.factor @@ -6,8 +6,9 @@ ! http://cairographics.org/samples/text/ -USING: cairo.ffi math math.constants byte-arrays kernel ui ui.render -combinators ui.gadgets opengl.gl accessors ; +USING: cairo.ffi math math.constants byte-arrays kernel ui +ui.render combinators ui.gadgets opengl.gl accessors +namespaces opengl ; IN: cairo-demo @@ -18,14 +19,15 @@ IN: cairo-demo CAIRO_FORMAT_ARGB32 384 256 over 4 * cairo_image_surface_create_for_data ; - TUPLE: cairo-demo-gadget < gadget image-array cairo-t ; M: cairo-demo-gadget draw-gadget* ( gadget -- ) - 0 0 glRasterPos2i - 1.0 -1.0 glPixelZoom - [ 384 256 GL_RGBA GL_UNSIGNED_BYTE ] dip - image-array>> glDrawPixels ; + origin get [ + 0 0 glRasterPos2i + 1.0 -1.0 glPixelZoom + [ 384 256 GL_RGBA GL_UNSIGNED_BYTE ] dip + image-array>> glDrawPixels + ] with-translation ; : create-surface ( gadget -- cairo_surface_t ) make-image-array [ swap (>>image-array) ] keep @@ -34,7 +36,7 @@ M: cairo-demo-gadget draw-gadget* ( gadget -- ) : init-cairo ( gadget -- cairo_t ) create-surface cairo_create ; -M: cairo-demo-gadget pref-dim* drop { 384 256 0 } ; +M: cairo-demo-gadget pref-dim* drop { 384 256 } ; ERROR: no-cairo-t ; From 1951d739a0f699b62e2aec683580f87845a29495 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 23 Feb 2009 20:27:05 -0600 Subject: [PATCH 54/85] Stack effect declarations are mandatory on all words now define-temp now takes an effect parameter Fix compiler bug that Dan found Stricter enforcement of * effects Move compile-call from compiler.units to compiler --- basis/alien/c-types/c-types.factor | 6 +- basis/checksums/openssl/openssl.factor | 4 +- basis/cocoa/application/application.factor | 6 +- basis/cocoa/dialogs/dialogs.factor | 4 +- basis/cocoa/messages/messages.factor | 14 +- basis/cocoa/pasteboard/pasteboard.factor | 2 +- basis/cocoa/runtime/runtime.factor | 18 +- basis/cocoa/subclassing/subclassing.factor | 6 +- basis/cocoa/views/views.factor | 74 ++--- basis/compiler/compiler-docs.factor | 9 +- basis/compiler/compiler.factor | 5 +- basis/compiler/tests/codegen.factor | 4 +- basis/compiler/tests/curry.factor | 8 +- basis/compiler/tests/float.factor | 2 +- basis/compiler/tests/intrinsics.factor | 2 +- basis/compiler/tests/optimizer.factor | 9 +- basis/compiler/tests/peg-regression-2.factor | 15 + basis/compiler/tests/simple.factor | 2 +- basis/compiler/tests/tuples.factor | 2 +- .../tree/comparisons/comparisons.factor | 4 +- basis/core-foundation/strings/strings.factor | 28 +- basis/functors/functors.factor | 4 +- basis/io/backend/unix/unix.factor | 2 +- basis/none/none.factor | 2 +- basis/opengl/glu/glu.factor | 294 +++++++++--------- basis/openssl/libcrypto/libcrypto.factor | 2 +- basis/peg/parsers/parsers.factor | 4 +- basis/stack-checker/backend/backend.factor | 48 +-- .../known-words/known-words.factor | 6 + basis/threads/threads.factor | 2 +- basis/tools/deploy/config/config.factor | 8 +- basis/tools/deploy/shaker/shaker.factor | 2 +- basis/ui/cocoa/views/views.factor | 8 +- basis/ui/gadgets/buttons/buttons.factor | 2 +- basis/ui/gadgets/frames/frames.factor | 18 +- basis/ui/gadgets/sliders/sliders.factor | 2 +- basis/ui/gadgets/theme/theme.factor | 4 +- basis/ui/render/render.factor | 10 +- basis/unicode/data/data.factor | 8 +- core/bootstrap/primitives.factor | 2 +- core/compiler/units/units-docs.factor | 4 - core/compiler/units/units.factor | 3 - core/continuations/continuations.factor | 8 +- core/effects/effects.factor | 2 + core/generic/standard/standard.factor | 12 +- core/words/words-docs.factor | 4 +- core/words/words.factor | 4 +- 47 files changed, 349 insertions(+), 340 deletions(-) create mode 100644 basis/compiler/tests/peg-regression-2.factor diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor index a44b5cf2b6..c3fd41e689 100755 --- a/basis/alien/c-types/c-types.factor +++ b/basis/alien/c-types/c-types.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2004, 2008 Slava Pestov. +! Copyright (C) 2004, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: byte-arrays arrays assocs kernel kernel.private libc math namespaces make parser sequences strings words assocs splitting @@ -275,7 +275,7 @@ M: long-long-type box-return ( type -- ) : if-void ( type true false -- ) pick "void" = [ drop nip call ] [ nip call ] if ; inline -: primitive-types +CONSTANT: primitive-types { "char" "uchar" "short" "ushort" @@ -284,7 +284,7 @@ M: long-long-type box-return ( type -- ) "longlong" "ulonglong" "float" "double" "void*" "bool" - } ; + } [ diff --git a/basis/checksums/openssl/openssl.factor b/basis/checksums/openssl/openssl.factor index 4bc7a7964a..58748b7c29 100644 --- a/basis/checksums/openssl/openssl.factor +++ b/basis/checksums/openssl/openssl.factor @@ -9,9 +9,9 @@ ERROR: unknown-digest name ; TUPLE: openssl-checksum name ; -: openssl-md5 T{ openssl-checksum f "md5" } ; +CONSTANT: openssl-md5 T{ openssl-checksum f "md5" } -: openssl-sha1 T{ openssl-checksum f "sha1" } ; +CONSTANT: openssl-sha1 T{ openssl-checksum f "sha1" } INSTANCE: openssl-checksum stream-checksum diff --git a/basis/cocoa/application/application.factor b/basis/cocoa/application/application.factor index ab2b6375a9..19d83b86d7 100644 --- a/basis/cocoa/application/application.factor +++ b/basis/cocoa/application/application.factor @@ -19,9 +19,9 @@ IN: cocoa.application ] curry assoc-each ] keep ; -: NSApplicationDelegateReplySuccess 0 ; -: NSApplicationDelegateReplyCancel 1 ; -: NSApplicationDelegateReplyFailure 2 ; +CONSTANT: NSApplicationDelegateReplySuccess 0 +CONSTANT: NSApplicationDelegateReplyCancel 1 +CONSTANT: NSApplicationDelegateReplyFailure 2 : with-autorelease-pool ( quot -- ) NSAutoreleasePool -> new slip -> release ; inline diff --git a/basis/cocoa/dialogs/dialogs.factor b/basis/cocoa/dialogs/dialogs.factor index 13f6f0b7d6..84a1ad46a3 100644 --- a/basis/cocoa/dialogs/dialogs.factor +++ b/basis/cocoa/dialogs/dialogs.factor @@ -18,8 +18,8 @@ IN: cocoa.dialogs dup 0 -> setCanChooseDirectories: dup 0 -> setAllowsMultipleSelection: ; -: NSOKButton 1 ; -: NSCancelButton 0 ; +CONSTANT: NSOKButton 1 +CONSTANT: NSCancelButton 0 : open-panel ( -- paths ) diff --git a/basis/cocoa/messages/messages.factor b/basis/cocoa/messages/messages.factor index ce66467203..9a1bebd38f 100644 --- a/basis/cocoa/messages/messages.factor +++ b/basis/cocoa/messages/messages.factor @@ -1,11 +1,11 @@ -! Copyright (C) 2006, 2008 Slava Pestov. +! Copyright (C) 2006, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien alien.c-types alien.strings arrays assocs -continuations combinators compiler compiler.alien kernel math -namespaces make parser quotations sequences strings words -cocoa.runtime io macros memoize io.encodings.utf8 -effects libc libc.private parser lexer init core-foundation fry -generalizations specialized-arrays.direct.alien call ; +continuations combinators compiler compiler.alien stack-checker kernel +math namespaces make parser quotations sequences strings words +cocoa.runtime io macros memoize io.encodings.utf8 effects libc +libc.private parser lexer init core-foundation fry generalizations +specialized-arrays.direct.alien call ; IN: cocoa.messages : make-sender ( method function -- quot ) @@ -14,7 +14,7 @@ IN: cocoa.messages : sender-stub ( method function -- word ) [ "( sender-stub )" f dup ] 2dip over first large-struct? [ "_stret" append ] when - make-sender define ; + make-sender dup infer define-declared ; SYMBOL: message-senders SYMBOL: super-message-senders diff --git a/basis/cocoa/pasteboard/pasteboard.factor b/basis/cocoa/pasteboard/pasteboard.factor index 888f5452e2..1a21b338be 100644 --- a/basis/cocoa/pasteboard/pasteboard.factor +++ b/basis/cocoa/pasteboard/pasteboard.factor @@ -5,7 +5,7 @@ cocoa.classes cocoa.application sequences cocoa core-foundation core-foundation.strings core-foundation.arrays ; IN: cocoa.pasteboard -: NSStringPboardType "NSStringPboardType" ; +CONSTANT: NSStringPboardType "NSStringPboardType" : pasteboard-string? ( pasteboard -- ? ) NSStringPboardType swap -> types CF>string-array member? ; diff --git a/basis/cocoa/runtime/runtime.factor b/basis/cocoa/runtime/runtime.factor index 1a741b789f..7817d0006c 100644 --- a/basis/cocoa/runtime/runtime.factor +++ b/basis/cocoa/runtime/runtime.factor @@ -21,15 +21,15 @@ C-STRUCT: objc-super { "id" "receiver" } { "Class" "class" } ; -: CLS_CLASS HEX: 1 ; -: CLS_META HEX: 2 ; -: CLS_INITIALIZED HEX: 4 ; -: CLS_POSING HEX: 8 ; -: CLS_MAPPED HEX: 10 ; -: CLS_FLUSH_CACHE HEX: 20 ; -: CLS_GROW_CACHE HEX: 40 ; -: CLS_NEED_BIND HEX: 80 ; -: CLS_METHOD_ARRAY HEX: 100 ; +CONSTANT: CLS_CLASS HEX: 1 +CONSTANT: CLS_META HEX: 2 +CONSTANT: CLS_INITIALIZED HEX: 4 +CONSTANT: CLS_POSING HEX: 8 +CONSTANT: CLS_MAPPED HEX: 10 +CONSTANT: CLS_FLUSH_CACHE HEX: 20 +CONSTANT: CLS_GROW_CACHE HEX: 40 +CONSTANT: CLS_NEED_BIND HEX: 80 +CONSTANT: CLS_METHOD_ARRAY HEX: 100 FUNCTION: int objc_getClassList ( void* buffer, int bufferLen ) ; diff --git a/basis/cocoa/subclassing/subclassing.factor b/basis/cocoa/subclassing/subclassing.factor index be53364185..0896312670 100644 --- a/basis/cocoa/subclassing/subclassing.factor +++ b/basis/cocoa/subclassing/subclassing.factor @@ -38,9 +38,9 @@ IN: cocoa.subclassing ] map concat ; : prepare-method ( ret types quot -- type imp ) - [ [ encode-types ] 2keep ] dip [ - "cdecl" swap 4array % \ alien-callback , - ] [ ] make define-temp ; + [ [ encode-types ] 2keep ] dip + '[ _ _ "cdecl" _ alien-callback ] + (( -- callback )) define-temp ; : prepare-methods ( methods -- methods ) [ diff --git a/basis/cocoa/views/views.factor b/basis/cocoa/views/views.factor index e74e912202..4bb6468fa6 100644 --- a/basis/cocoa/views/views.factor +++ b/basis/cocoa/views/views.factor @@ -5,43 +5,43 @@ cocoa cocoa.messages cocoa.classes cocoa.types sequences continuations accessors ; IN: cocoa.views -: NSOpenGLPFAAllRenderers 1 ; -: NSOpenGLPFADoubleBuffer 5 ; -: NSOpenGLPFAStereo 6 ; -: NSOpenGLPFAAuxBuffers 7 ; -: NSOpenGLPFAColorSize 8 ; -: NSOpenGLPFAAlphaSize 11 ; -: NSOpenGLPFADepthSize 12 ; -: NSOpenGLPFAStencilSize 13 ; -: NSOpenGLPFAAccumSize 14 ; -: NSOpenGLPFAMinimumPolicy 51 ; -: NSOpenGLPFAMaximumPolicy 52 ; -: NSOpenGLPFAOffScreen 53 ; -: NSOpenGLPFAFullScreen 54 ; -: NSOpenGLPFASampleBuffers 55 ; -: NSOpenGLPFASamples 56 ; -: NSOpenGLPFAAuxDepthStencil 57 ; -: NSOpenGLPFAColorFloat 58 ; -: NSOpenGLPFAMultisample 59 ; -: NSOpenGLPFASupersample 60 ; -: NSOpenGLPFASampleAlpha 61 ; -: NSOpenGLPFARendererID 70 ; -: NSOpenGLPFASingleRenderer 71 ; -: NSOpenGLPFANoRecovery 72 ; -: NSOpenGLPFAAccelerated 73 ; -: NSOpenGLPFAClosestPolicy 74 ; -: NSOpenGLPFARobust 75 ; -: NSOpenGLPFABackingStore 76 ; -: NSOpenGLPFAMPSafe 78 ; -: NSOpenGLPFAWindow 80 ; -: NSOpenGLPFAMultiScreen 81 ; -: NSOpenGLPFACompliant 83 ; -: NSOpenGLPFAScreenMask 84 ; -: NSOpenGLPFAPixelBuffer 90 ; -: NSOpenGLPFAAllowOfflineRenderers 96 ; -: NSOpenGLPFAVirtualScreenCount 128 ; +CONSTANT: NSOpenGLPFAAllRenderers 1 +CONSTANT: NSOpenGLPFADoubleBuffer 5 +CONSTANT: NSOpenGLPFAStereo 6 +CONSTANT: NSOpenGLPFAAuxBuffers 7 +CONSTANT: NSOpenGLPFAColorSize 8 +CONSTANT: NSOpenGLPFAAlphaSize 11 +CONSTANT: NSOpenGLPFADepthSize 12 +CONSTANT: NSOpenGLPFAStencilSize 13 +CONSTANT: NSOpenGLPFAAccumSize 14 +CONSTANT: NSOpenGLPFAMinimumPolicy 51 +CONSTANT: NSOpenGLPFAMaximumPolicy 52 +CONSTANT: NSOpenGLPFAOffScreen 53 +CONSTANT: NSOpenGLPFAFullScreen 54 +CONSTANT: NSOpenGLPFASampleBuffers 55 +CONSTANT: NSOpenGLPFASamples 56 +CONSTANT: NSOpenGLPFAAuxDepthStencil 57 +CONSTANT: NSOpenGLPFAColorFloat 58 +CONSTANT: NSOpenGLPFAMultisample 59 +CONSTANT: NSOpenGLPFASupersample 60 +CONSTANT: NSOpenGLPFASampleAlpha 61 +CONSTANT: NSOpenGLPFARendererID 70 +CONSTANT: NSOpenGLPFASingleRenderer 71 +CONSTANT: NSOpenGLPFANoRecovery 72 +CONSTANT: NSOpenGLPFAAccelerated 73 +CONSTANT: NSOpenGLPFAClosestPolicy 74 +CONSTANT: NSOpenGLPFARobust 75 +CONSTANT: NSOpenGLPFABackingStore 76 +CONSTANT: NSOpenGLPFAMPSafe 78 +CONSTANT: NSOpenGLPFAWindow 80 +CONSTANT: NSOpenGLPFAMultiScreen 81 +CONSTANT: NSOpenGLPFACompliant 83 +CONSTANT: NSOpenGLPFAScreenMask 84 +CONSTANT: NSOpenGLPFAPixelBuffer 90 +CONSTANT: NSOpenGLPFAAllowOfflineRenderers 96 +CONSTANT: NSOpenGLPFAVirtualScreenCount 128 -: kCGLRendererGenericFloatID HEX: 00020400 ; +CONSTANT: kCGLRendererGenericFloatID HEX: 00020400 USE: opengl.gl USE: alien.syntax -: NSOpenGLCPSwapInterval 222 ; +CONSTANT: NSOpenGLCPSwapInterval 222 LIBRARY: OpenGL diff --git a/basis/compiler/compiler-docs.factor b/basis/compiler/compiler-docs.factor index 1c6e7b796e..9169e9e0fa 100644 --- a/basis/compiler/compiler-docs.factor +++ b/basis/compiler/compiler-docs.factor @@ -1,5 +1,5 @@ USING: help.markup help.syntax words io parser -assocs words.private sequences compiler.units ; +assocs words.private sequences compiler.units quotations ; IN: compiler HELP: enable-compiler @@ -16,6 +16,8 @@ ARTICLE: "compiler-usage" "Calling the optimizing compiler" { $subsection optimized-recompile-hook } "Removing a word's optimized definition:" { $subsection decompile } +"Compiling a single quotation:" +{ $subsection compile-call } "Higher-level words can be found in " { $link "compilation-units" } "." ; ARTICLE: "compiler" "Optimizing compiler" @@ -48,3 +50,8 @@ HELP: optimized-recompile-hook { $values { "words" "a sequence of words" } { "alist" "an association list" } } { $description "Compile a set of words." } { $notes "This is an internal word, and user code should call " { $link compile } " instead." } ; + +HELP: compile-call +{ $values { "quot" quotation } } +{ $description "Compiles and runs a quotation." } +{ $notes "This word is used by compiler unit tests to test compilation of small pieces of code." } ; diff --git a/basis/compiler/compiler.factor b/basis/compiler/compiler.factor index f2f4e7aa9e..d707dff983 100644 --- a/basis/compiler/compiler.factor +++ b/basis/compiler/compiler.factor @@ -49,7 +49,7 @@ SYMBOL: +failed+ H{ } clone generic-dependencies set f swap compiler-error ; -: fail ( word error -- ) +: fail ( word error -- * ) [ swap compiler-error ] [ drop @@ -112,6 +112,9 @@ t compile-dependencies? set-global : decompile ( word -- ) f 2array 1array modify-code-heap ; +: compile-call ( quot -- ) + [ dup infer define-temp ] with-compilation-unit execute ; + : optimized-recompile-hook ( words -- alist ) [ compile-queue set diff --git a/basis/compiler/tests/codegen.factor b/basis/compiler/tests/codegen.factor index 78e95ffb91..2e02e5476c 100644 --- a/basis/compiler/tests/codegen.factor +++ b/basis/compiler/tests/codegen.factor @@ -51,7 +51,7 @@ unit-test \ foo [ global >n get ndrop ] compile-call ] unit-test -: blech drop ; +: blech ( x -- ) drop ; [ 3 ] [ @@ -102,7 +102,7 @@ unit-test [ ] [ [ [ 200 dup [ 200 3array ] curry map drop ] times - ] [ define-temp ] with-compilation-unit drop + ] [ (( n -- )) define-temp ] with-compilation-unit drop ] unit-test ! Test how dispatch handles the end of a basic block diff --git a/basis/compiler/tests/curry.factor b/basis/compiler/tests/curry.factor index 1857baf503..2d1f15b9a8 100644 --- a/basis/compiler/tests/curry.factor +++ b/basis/compiler/tests/curry.factor @@ -1,5 +1,5 @@ USING: tools.test quotations math kernel sequences -assocs namespaces make compiler.units ; +assocs namespaces make compiler.units compiler ; IN: compiler.tests [ 3 ] [ 5 [ [ 2 - ] curry call ] compile-call ] unit-test @@ -32,15 +32,15 @@ IN: compiler.tests compile-call ] unit-test -: foobar ( quot -- ) - dup slip swap [ foobar ] [ drop ] if ; inline +: foobar ( quot: ( -- ) -- ) + dup slip swap [ foobar ] [ drop ] if ; inline recursive [ ] [ [ [ f ] foobar ] compile-call ] unit-test [ { 6 7 8 } ] [ { 1 2 3 } 5 [ [ + ] curry map ] compile-call ] unit-test [ { 6 7 8 } ] [ { 1 2 3 } [ 5 [ + ] curry map ] compile-call ] unit-test -: funky-assoc>map +: funky-assoc>map ( assoc quot -- seq ) [ [ call f ] curry assoc-find 3drop ] { } make ; inline diff --git a/basis/compiler/tests/float.factor b/basis/compiler/tests/float.factor index 81ab750305..b439b5f6a4 100644 --- a/basis/compiler/tests/float.factor +++ b/basis/compiler/tests/float.factor @@ -1,5 +1,5 @@ IN: compiler.tests -USING: compiler.units kernel kernel.private memory math +USING: compiler.units compiler kernel kernel.private memory math math.private tools.test math.floats.private ; [ 5.0 ] [ [ 5.0 ] compile-call gc gc gc ] unit-test diff --git a/basis/compiler/tests/intrinsics.factor b/basis/compiler/tests/intrinsics.factor index df5f484952..6c6d580c87 100644 --- a/basis/compiler/tests/intrinsics.factor +++ b/basis/compiler/tests/intrinsics.factor @@ -5,7 +5,7 @@ strings.private system random layouts vectors sbufs strings.private slots.private alien math.order alien.accessors alien.c-types alien.syntax alien.strings namespaces libc sequences.private io.encodings.ascii -classes ; +classes compiler ; IN: compiler.tests ! Make sure that intrinsic ops compile to correct code. diff --git a/basis/compiler/tests/optimizer.factor b/basis/compiler/tests/optimizer.factor index c5bbe4a6c3..708d17f3d3 100644 --- a/basis/compiler/tests/optimizer.factor +++ b/basis/compiler/tests/optimizer.factor @@ -3,7 +3,8 @@ stack-checker kernel kernel.private math prettyprint sequences sbufs strings tools.test vectors words sequences.private quotations classes classes.algebra classes.tuple.private continuations growable namespaces hints alien.accessors -compiler.tree.builder compiler.tree.optimizer sequences.deep ; +compiler.tree.builder compiler.tree.optimizer sequences.deep +compiler ; IN: optimizer.tests GENERIC: xyz ( obj -- obj ) @@ -208,14 +209,14 @@ USE: sorting USE: binary-search USE: binary-search.private -: old-binsearch ( elt quot seq -- elt quot i ) +: old-binsearch ( elt quot: ( -- ) seq -- elt quot i ) dup length 1 <= [ from>> ] [ [ midpoint swap call ] 3keep roll dup zero? [ drop dup from>> swap midpoint@ + ] - [ dup midpoint@ cut-slice old-binsearch ] if - ] if ; inline + [ drop dup midpoint@ head-slice old-binsearch ] if + ] if ; inline recursive [ 10 ] [ 10 20 >vector diff --git a/basis/compiler/tests/peg-regression-2.factor b/basis/compiler/tests/peg-regression-2.factor new file mode 100644 index 0000000000..1efadba3aa --- /dev/null +++ b/basis/compiler/tests/peg-regression-2.factor @@ -0,0 +1,15 @@ +IN: compiler.tests +USING: peg.ebnf strings tools.test ; + +GENERIC: ( times -- term' ) +M: string ; + +EBNF: parse-regexp + +Times = .* => [[ "foo" ]] + +Regexp = Times:t => [[ t ]] + +;EBNF + +[ "foo" ] [ "a" parse-regexp ] unit-test \ No newline at end of file diff --git a/basis/compiler/tests/simple.factor b/basis/compiler/tests/simple.factor index a6d6c5dfb9..0fde270eac 100644 --- a/basis/compiler/tests/simple.factor +++ b/basis/compiler/tests/simple.factor @@ -54,7 +54,7 @@ IN: compiler.tests ! Labels -: recursive-test ( ? -- ) [ f recursive-test ] when ; inline +: recursive-test ( ? -- ) [ f recursive-test ] when ; inline recursive [ ] [ t [ recursive-test ] compile-call ] unit-test diff --git a/basis/compiler/tests/tuples.factor b/basis/compiler/tests/tuples.factor index 602b438432..caa214b70c 100644 --- a/basis/compiler/tests/tuples.factor +++ b/basis/compiler/tests/tuples.factor @@ -1,5 +1,5 @@ IN: compiler.tests -USING: kernel tools.test compiler.units ; +USING: kernel tools.test compiler.units compiler ; TUPLE: color red green blue ; diff --git a/basis/compiler/tree/comparisons/comparisons.factor b/basis/compiler/tree/comparisons/comparisons.factor index 5242302411..5f4b1e8dab 100644 --- a/basis/compiler/tree/comparisons/comparisons.factor +++ b/basis/compiler/tree/comparisons/comparisons.factor @@ -5,9 +5,9 @@ IN: compiler.tree.comparisons ! Some utilities for working with comparison operations. -: comparison-ops { < > <= >= } ; +CONSTANT: comparison-ops { < > <= >= } -: generic-comparison-ops { before? after? before=? after=? } ; +CONSTANT: generic-comparison-ops { before? after? before=? after=? } : assumption ( i1 i2 op -- i3 ) { diff --git a/basis/core-foundation/strings/strings.factor b/basis/core-foundation/strings/strings.factor index c3a969a325..50c17dc6fd 100644 --- a/basis/core-foundation/strings/strings.factor +++ b/basis/core-foundation/strings/strings.factor @@ -7,20 +7,20 @@ IN: core-foundation.strings TYPEDEF: void* CFStringRef TYPEDEF: int CFStringEncoding -: kCFStringEncodingMacRoman HEX: 0 ; -: kCFStringEncodingWindowsLatin1 HEX: 0500 ; -: kCFStringEncodingISOLatin1 HEX: 0201 ; -: kCFStringEncodingNextStepLatin HEX: 0B01 ; -: kCFStringEncodingASCII HEX: 0600 ; -: kCFStringEncodingUnicode HEX: 0100 ; -: kCFStringEncodingUTF8 HEX: 08000100 ; -: kCFStringEncodingNonLossyASCII HEX: 0BFF ; -: kCFStringEncodingUTF16 HEX: 0100 ; -: kCFStringEncodingUTF16BE HEX: 10000100 ; -: kCFStringEncodingUTF16LE HEX: 14000100 ; -: kCFStringEncodingUTF32 HEX: 0c000100 ; -: kCFStringEncodingUTF32BE HEX: 18000100 ; -: kCFStringEncodingUTF32LE HEX: 1c000100 ; +CONSTANT: kCFStringEncodingMacRoman HEX: 0 +CONSTANT: kCFStringEncodingWindowsLatin1 HEX: 0500 +CONSTANT: kCFStringEncodingISOLatin1 HEX: 0201 +CONSTANT: kCFStringEncodingNextStepLatin HEX: 0B01 +CONSTANT: kCFStringEncodingASCII HEX: 0600 +CONSTANT: kCFStringEncodingUnicode HEX: 0100 +CONSTANT: kCFStringEncodingUTF8 HEX: 08000100 +CONSTANT: kCFStringEncodingNonLossyASCII HEX: 0BFF +CONSTANT: kCFStringEncodingUTF16 HEX: 0100 +CONSTANT: kCFStringEncodingUTF16BE HEX: 10000100 +CONSTANT: kCFStringEncodingUTF16LE HEX: 14000100 +CONSTANT: kCFStringEncodingUTF32 HEX: 0c000100 +CONSTANT: kCFStringEncodingUTF32BE HEX: 18000100 +CONSTANT: kCFStringEncodingUTF32LE HEX: 1c000100 FUNCTION: CFStringRef CFStringCreateWithBytes ( CFAllocatorRef alloc, diff --git a/basis/functors/functors.factor b/basis/functors/functors.factor index 14151692f0..0b9c9caa45 100644 --- a/basis/functors/functors.factor +++ b/basis/functors/functors.factor @@ -80,9 +80,9 @@ M: object fake-quotations> ; scan-param parsed \ add-mixin-instance parsed ; parsing -: `inline \ inline parsed ; parsing +: `inline [ word make-inline ] over push-all ; parsing -: `parsing \ parsing parsed ; parsing +: `parsing [ word make-parsing ] over push-all ; parsing : `( ")" parse-effect effect set ; parsing diff --git a/basis/io/backend/unix/unix.factor b/basis/io/backend/unix/unix.factor index f5e6426859..f210180517 100644 --- a/basis/io/backend/unix/unix.factor +++ b/basis/io/backend/unix/unix.factor @@ -77,7 +77,7 @@ M: io-timeout summary drop "I/O operation timed out" ; '[ handle>> _ wait-for-fd ] with-timeout ; ! Some general stuff -: file-mode OCT: 0666 ; +CONSTANT: file-mode OCT: 0666 ! Readers : (refill) ( port -- n ) diff --git a/basis/none/none.factor b/basis/none/none.factor index 66a0de8328..77941479aa 100644 --- a/basis/none/none.factor +++ b/basis/none/none.factor @@ -1,6 +1,6 @@ ! Just a dummy shell for the -run switch... IN: none -: none ; +: none ( -- ) ; MAIN: none diff --git a/basis/opengl/glu/glu.factor b/basis/opengl/glu/glu.factor index da19ac52fc..d603724a55 100644 --- a/basis/opengl/glu/glu.factor +++ b/basis/opengl/glu/glu.factor @@ -11,183 +11,183 @@ TYPEDEF: void* GLubyte* TYPEDEF: void* GLUfuncptr ! StringName -: GLU_VERSION 100800 ; -: GLU_EXTENSIONS 100801 ; +CONSTANT: GLU_VERSION 100800 +CONSTANT: GLU_EXTENSIONS 100801 ! ErrorCode -: GLU_INVALID_ENUM 100900 ; -: GLU_INVALID_VALUE 100901 ; -: GLU_OUT_OF_MEMORY 100902 ; -: GLU_INCOMPATIBLE_GL_VERSION 100903 ; -: GLU_INVALID_OPERATION 100904 ; +CONSTANT: GLU_INVALID_ENUM 100900 +CONSTANT: GLU_INVALID_VALUE 100901 +CONSTANT: GLU_OUT_OF_MEMORY 100902 +CONSTANT: GLU_INCOMPATIBLE_GL_VERSION 100903 +CONSTANT: GLU_INVALID_OPERATION 100904 ! NurbsDisplay -: GLU_OUTLINE_POLYGON 100240 ; -: GLU_OUTLINE_PATCH 100241 ; +CONSTANT: GLU_OUTLINE_POLYGON 100240 +CONSTANT: GLU_OUTLINE_PATCH 100241 ! NurbsCallback -: GLU_NURBS_ERROR 100103 ; -: GLU_ERROR 100103 ; -: GLU_NURBS_BEGIN 100164 ; -: GLU_NURBS_BEGIN_EXT 100164 ; -: GLU_NURBS_VERTEX 100165 ; -: GLU_NURBS_VERTEX_EXT 100165 ; -: GLU_NURBS_NORMAL 100166 ; -: GLU_NURBS_NORMAL_EXT 100166 ; -: GLU_NURBS_COLOR 100167 ; -: GLU_NURBS_COLOR_EXT 100167 ; -: GLU_NURBS_TEXTURE_COORD 100168 ; -: GLU_NURBS_TEX_COORD_EXT 100168 ; -: GLU_NURBS_END 100169 ; -: GLU_NURBS_END_EXT 100169 ; -: GLU_NURBS_BEGIN_DATA 100170 ; -: GLU_NURBS_BEGIN_DATA_EXT 100170 ; -: GLU_NURBS_VERTEX_DATA 100171 ; -: GLU_NURBS_VERTEX_DATA_EXT 100171 ; -: GLU_NURBS_NORMAL_DATA 100172 ; -: GLU_NURBS_NORMAL_DATA_EXT 100172 ; -: GLU_NURBS_COLOR_DATA 100173 ; -: GLU_NURBS_COLOR_DATA_EXT 100173 ; -: GLU_NURBS_TEXTURE_COORD_DATA 100174 ; -: GLU_NURBS_TEX_COORD_DATA_EXT 100174 ; -: GLU_NURBS_END_DATA 100175 ; -: GLU_NURBS_END_DATA_EXT 100175 ; +CONSTANT: GLU_NURBS_ERROR 100103 +CONSTANT: GLU_ERROR 100103 +CONSTANT: GLU_NURBS_BEGIN 100164 +CONSTANT: GLU_NURBS_BEGIN_EXT 100164 +CONSTANT: GLU_NURBS_VERTEX 100165 +CONSTANT: GLU_NURBS_VERTEX_EXT 100165 +CONSTANT: GLU_NURBS_NORMAL 100166 +CONSTANT: GLU_NURBS_NORMAL_EXT 100166 +CONSTANT: GLU_NURBS_COLOR 100167 +CONSTANT: GLU_NURBS_COLOR_EXT 100167 +CONSTANT: GLU_NURBS_TEXTURE_COORD 100168 +CONSTANT: GLU_NURBS_TEX_COORD_EXT 100168 +CONSTANT: GLU_NURBS_END 100169 +CONSTANT: GLU_NURBS_END_EXT 100169 +CONSTANT: GLU_NURBS_BEGIN_DATA 100170 +CONSTANT: GLU_NURBS_BEGIN_DATA_EXT 100170 +CONSTANT: GLU_NURBS_VERTEX_DATA 100171 +CONSTANT: GLU_NURBS_VERTEX_DATA_EXT 100171 +CONSTANT: GLU_NURBS_NORMAL_DATA 100172 +CONSTANT: GLU_NURBS_NORMAL_DATA_EXT 100172 +CONSTANT: GLU_NURBS_COLOR_DATA 100173 +CONSTANT: GLU_NURBS_COLOR_DATA_EXT 100173 +CONSTANT: GLU_NURBS_TEXTURE_COORD_DATA 100174 +CONSTANT: GLU_NURBS_TEX_COORD_DATA_EXT 100174 +CONSTANT: GLU_NURBS_END_DATA 100175 +CONSTANT: GLU_NURBS_END_DATA_EXT 100175 ! NurbsError -: GLU_NURBS_ERROR1 100251 ; -: GLU_NURBS_ERROR2 100252 ; -: GLU_NURBS_ERROR3 100253 ; -: GLU_NURBS_ERROR4 100254 ; -: GLU_NURBS_ERROR5 100255 ; -: GLU_NURBS_ERROR6 100256 ; -: GLU_NURBS_ERROR7 100257 ; -: GLU_NURBS_ERROR8 100258 ; -: GLU_NURBS_ERROR9 100259 ; -: GLU_NURBS_ERROR10 100260 ; -: GLU_NURBS_ERROR11 100261 ; -: GLU_NURBS_ERROR12 100262 ; -: GLU_NURBS_ERROR13 100263 ; -: GLU_NURBS_ERROR14 100264 ; -: GLU_NURBS_ERROR15 100265 ; -: GLU_NURBS_ERROR16 100266 ; -: GLU_NURBS_ERROR17 100267 ; -: GLU_NURBS_ERROR18 100268 ; -: GLU_NURBS_ERROR19 100269 ; -: GLU_NURBS_ERROR20 100270 ; -: GLU_NURBS_ERROR21 100271 ; -: GLU_NURBS_ERROR22 100272 ; -: GLU_NURBS_ERROR23 100273 ; -: GLU_NURBS_ERROR24 100274 ; -: GLU_NURBS_ERROR25 100275 ; -: GLU_NURBS_ERROR26 100276 ; -: GLU_NURBS_ERROR27 100277 ; -: GLU_NURBS_ERROR28 100278 ; -: GLU_NURBS_ERROR29 100279 ; -: GLU_NURBS_ERROR30 100280 ; -: GLU_NURBS_ERROR31 100281 ; -: GLU_NURBS_ERROR32 100282 ; -: GLU_NURBS_ERROR33 100283 ; -: GLU_NURBS_ERROR34 100284 ; -: GLU_NURBS_ERROR35 100285 ; -: GLU_NURBS_ERROR36 100286 ; -: GLU_NURBS_ERROR37 100287 ; +CONSTANT: GLU_NURBS_ERROR1 100251 +CONSTANT: GLU_NURBS_ERROR2 100252 +CONSTANT: GLU_NURBS_ERROR3 100253 +CONSTANT: GLU_NURBS_ERROR4 100254 +CONSTANT: GLU_NURBS_ERROR5 100255 +CONSTANT: GLU_NURBS_ERROR6 100256 +CONSTANT: GLU_NURBS_ERROR7 100257 +CONSTANT: GLU_NURBS_ERROR8 100258 +CONSTANT: GLU_NURBS_ERROR9 100259 +CONSTANT: GLU_NURBS_ERROR10 100260 +CONSTANT: GLU_NURBS_ERROR11 100261 +CONSTANT: GLU_NURBS_ERROR12 100262 +CONSTANT: GLU_NURBS_ERROR13 100263 +CONSTANT: GLU_NURBS_ERROR14 100264 +CONSTANT: GLU_NURBS_ERROR15 100265 +CONSTANT: GLU_NURBS_ERROR16 100266 +CONSTANT: GLU_NURBS_ERROR17 100267 +CONSTANT: GLU_NURBS_ERROR18 100268 +CONSTANT: GLU_NURBS_ERROR19 100269 +CONSTANT: GLU_NURBS_ERROR20 100270 +CONSTANT: GLU_NURBS_ERROR21 100271 +CONSTANT: GLU_NURBS_ERROR22 100272 +CONSTANT: GLU_NURBS_ERROR23 100273 +CONSTANT: GLU_NURBS_ERROR24 100274 +CONSTANT: GLU_NURBS_ERROR25 100275 +CONSTANT: GLU_NURBS_ERROR26 100276 +CONSTANT: GLU_NURBS_ERROR27 100277 +CONSTANT: GLU_NURBS_ERROR28 100278 +CONSTANT: GLU_NURBS_ERROR29 100279 +CONSTANT: GLU_NURBS_ERROR30 100280 +CONSTANT: GLU_NURBS_ERROR31 100281 +CONSTANT: GLU_NURBS_ERROR32 100282 +CONSTANT: GLU_NURBS_ERROR33 100283 +CONSTANT: GLU_NURBS_ERROR34 100284 +CONSTANT: GLU_NURBS_ERROR35 100285 +CONSTANT: GLU_NURBS_ERROR36 100286 +CONSTANT: GLU_NURBS_ERROR37 100287 ! NurbsProperty -: GLU_AUTO_LOAD_MATRIX 100200 ; -: GLU_CULLING 100201 ; -: GLU_SAMPLING_TOLERANCE 100203 ; -: GLU_DISPLAY_MODE 100204 ; -: GLU_PARAMETRIC_TOLERANCE 100202 ; -: GLU_SAMPLING_METHOD 100205 ; -: GLU_U_STEP 100206 ; -: GLU_V_STEP 100207 ; -: GLU_NURBS_MODE 100160 ; -: GLU_NURBS_MODE_EXT 100160 ; -: GLU_NURBS_TESSELLATOR 100161 ; -: GLU_NURBS_TESSELLATOR_EXT 100161 ; -: GLU_NURBS_RENDERER 100162 ; -: GLU_NURBS_RENDERER_EXT 100162 ; +CONSTANT: GLU_AUTO_LOAD_MATRIX 100200 +CONSTANT: GLU_CULLING 100201 +CONSTANT: GLU_SAMPLING_TOLERANCE 100203 +CONSTANT: GLU_DISPLAY_MODE 100204 +CONSTANT: GLU_PARAMETRIC_TOLERANCE 100202 +CONSTANT: GLU_SAMPLING_METHOD 100205 +CONSTANT: GLU_U_STEP 100206 +CONSTANT: GLU_V_STEP 100207 +CONSTANT: GLU_NURBS_MODE 100160 +CONSTANT: GLU_NURBS_MODE_EXT 100160 +CONSTANT: GLU_NURBS_TESSELLATOR 100161 +CONSTANT: GLU_NURBS_TESSELLATOR_EXT 100161 +CONSTANT: GLU_NURBS_RENDERER 100162 +CONSTANT: GLU_NURBS_RENDERER_EXT 100162 ! NurbsSampling -: GLU_OBJECT_PARAMETRIC_ERROR 100208 ; -: GLU_OBJECT_PARAMETRIC_ERROR_EXT 100208 ; -: GLU_OBJECT_PATH_LENGTH 100209 ; -: GLU_OBJECT_PATH_LENGTH_EXT 100209 ; -: GLU_PATH_LENGTH 100215 ; -: GLU_PARAMETRIC_ERROR 100216 ; -: GLU_DOMAIN_DISTANCE 100217 ; +CONSTANT: GLU_OBJECT_PARAMETRIC_ERROR 100208 +CONSTANT: GLU_OBJECT_PARAMETRIC_ERROR_EXT 100208 +CONSTANT: GLU_OBJECT_PATH_LENGTH 100209 +CONSTANT: GLU_OBJECT_PATH_LENGTH_EXT 100209 +CONSTANT: GLU_PATH_LENGTH 100215 +CONSTANT: GLU_PARAMETRIC_ERROR 100216 +CONSTANT: GLU_DOMAIN_DISTANCE 100217 ! NurbsTrim -: GLU_MAP1_TRIM_2 100210 ; -: GLU_MAP1_TRIM_3 100211 ; +CONSTANT: GLU_MAP1_TRIM_2 100210 +CONSTANT: GLU_MAP1_TRIM_3 100211 ! QuadricDrawStyle -: GLU_POINT 100010 ; -: GLU_LINE 100011 ; -: GLU_FILL 100012 ; -: GLU_SILHOUETTE 100013 ; +CONSTANT: GLU_POINT 100010 +CONSTANT: GLU_LINE 100011 +CONSTANT: GLU_FILL 100012 +CONSTANT: GLU_SILHOUETTE 100013 ! QuadricNormal -: GLU_SMOOTH 100000 ; -: GLU_FLAT 100001 ; -: GLU_NONE 100002 ; +CONSTANT: GLU_SMOOTH 100000 +CONSTANT: GLU_FLAT 100001 +CONSTANT: GLU_NONE 100002 ! QuadricOrientation -: GLU_OUTSIDE 100020 ; -: GLU_INSIDE 100021 ; +CONSTANT: GLU_OUTSIDE 100020 +CONSTANT: GLU_INSIDE 100021 ! TessCallback -: GLU_TESS_BEGIN 100100 ; -: GLU_BEGIN 100100 ; -: GLU_TESS_VERTEX 100101 ; -: GLU_VERTEX 100101 ; -: GLU_TESS_END 100102 ; -: GLU_END 100102 ; -: GLU_TESS_ERROR 100103 ; -: GLU_TESS_EDGE_FLAG 100104 ; -: GLU_EDGE_FLAG 100104 ; -: GLU_TESS_COMBINE 100105 ; -: GLU_TESS_BEGIN_DATA 100106 ; -: GLU_TESS_VERTEX_DATA 100107 ; -: GLU_TESS_END_DATA 100108 ; -: GLU_TESS_ERROR_DATA 100109 ; -: GLU_TESS_EDGE_FLAG_DATA 100110 ; -: GLU_TESS_COMBINE_DATA 100111 ; +CONSTANT: GLU_TESS_BEGIN 100100 +CONSTANT: GLU_BEGIN 100100 +CONSTANT: GLU_TESS_VERTEX 100101 +CONSTANT: GLU_VERTEX 100101 +CONSTANT: GLU_TESS_END 100102 +CONSTANT: GLU_END 100102 +CONSTANT: GLU_TESS_ERROR 100103 +CONSTANT: GLU_TESS_EDGE_FLAG 100104 +CONSTANT: GLU_EDGE_FLAG 100104 +CONSTANT: GLU_TESS_COMBINE 100105 +CONSTANT: GLU_TESS_BEGIN_DATA 100106 +CONSTANT: GLU_TESS_VERTEX_DATA 100107 +CONSTANT: GLU_TESS_END_DATA 100108 +CONSTANT: GLU_TESS_ERROR_DATA 100109 +CONSTANT: GLU_TESS_EDGE_FLAG_DATA 100110 +CONSTANT: GLU_TESS_COMBINE_DATA 100111 ! TessContour -: GLU_CW 100120 ; -: GLU_CCW 100121 ; -: GLU_INTERIOR 100122 ; -: GLU_EXTERIOR 100123 ; -: GLU_UNKNOWN 100124 ; +CONSTANT: GLU_CW 100120 +CONSTANT: GLU_CCW 100121 +CONSTANT: GLU_INTERIOR 100122 +CONSTANT: GLU_EXTERIOR 100123 +CONSTANT: GLU_UNKNOWN 100124 ! TessProperty -: GLU_TESS_WINDING_RULE 100140 ; -: GLU_TESS_BOUNDARY_ONLY 100141 ; -: GLU_TESS_TOLERANCE 100142 ; +CONSTANT: GLU_TESS_WINDING_RULE 100140 +CONSTANT: GLU_TESS_BOUNDARY_ONLY 100141 +CONSTANT: GLU_TESS_TOLERANCE 100142 ! TessError -: GLU_TESS_ERROR1 100151 ; -: GLU_TESS_ERROR2 100152 ; -: GLU_TESS_ERROR3 100153 ; -: GLU_TESS_ERROR4 100154 ; -: GLU_TESS_ERROR5 100155 ; -: GLU_TESS_ERROR6 100156 ; -: GLU_TESS_ERROR7 100157 ; -: GLU_TESS_ERROR8 100158 ; -: GLU_TESS_MISSING_BEGIN_POLYGON 100151 ; -: GLU_TESS_MISSING_BEGIN_CONTOUR 100152 ; -: GLU_TESS_MISSING_END_POLYGON 100153 ; -: GLU_TESS_MISSING_END_CONTOUR 100154 ; -: GLU_TESS_COORD_TOO_LARGE 100155 ; -: GLU_TESS_NEED_COMBINE_CALLBACK 100156 ; +CONSTANT: GLU_TESS_ERROR1 100151 +CONSTANT: GLU_TESS_ERROR2 100152 +CONSTANT: GLU_TESS_ERROR3 100153 +CONSTANT: GLU_TESS_ERROR4 100154 +CONSTANT: GLU_TESS_ERROR5 100155 +CONSTANT: GLU_TESS_ERROR6 100156 +CONSTANT: GLU_TESS_ERROR7 100157 +CONSTANT: GLU_TESS_ERROR8 100158 +CONSTANT: GLU_TESS_MISSING_BEGIN_POLYGON 100151 +CONSTANT: GLU_TESS_MISSING_BEGIN_CONTOUR 100152 +CONSTANT: GLU_TESS_MISSING_END_POLYGON 100153 +CONSTANT: GLU_TESS_MISSING_END_CONTOUR 100154 +CONSTANT: GLU_TESS_COORD_TOO_LARGE 100155 +CONSTANT: GLU_TESS_NEED_COMBINE_CALLBACK 100156 ! TessWinding -: GLU_TESS_WINDING_ODD 100130 ; -: GLU_TESS_WINDING_NONZERO 100131 ; -: GLU_TESS_WINDING_POSITIVE 100132 ; -: GLU_TESS_WINDING_NEGATIVE 100133 ; -: GLU_TESS_WINDING_ABS_GEQ_TWO 100134 ; +CONSTANT: GLU_TESS_WINDING_ODD 100130 +CONSTANT: GLU_TESS_WINDING_NONZERO 100131 +CONSTANT: GLU_TESS_WINDING_POSITIVE 100132 +CONSTANT: GLU_TESS_WINDING_NEGATIVE 100133 +CONSTANT: GLU_TESS_WINDING_ABS_GEQ_TWO 100134 LIBRARY: glu diff --git a/basis/openssl/libcrypto/libcrypto.factor b/basis/openssl/libcrypto/libcrypto.factor index 3204b83bbb..9cbed1f752 100644 --- a/basis/openssl/libcrypto/libcrypto.factor +++ b/basis/openssl/libcrypto/libcrypto.factor @@ -99,7 +99,7 @@ FUNCTION: void* BIO_f_buffer ( ) ; ! evp.h ! =============================================== -: EVP_MAX_MD_SIZE 64 ; +CONSTANT: EVP_MAX_MD_SIZE 64 C-STRUCT: EVP_MD_CTX { "EVP_MD*" "digest" } diff --git a/basis/peg/parsers/parsers.factor b/basis/peg/parsers/parsers.factor index a9fb366812..aadbbaff16 100644 --- a/basis/peg/parsers/parsers.factor +++ b/basis/peg/parsers/parsers.factor @@ -7,12 +7,12 @@ IN: peg.parsers TUPLE: just-parser p1 ; -: just-pattern +CONSTANT: just-pattern [ execute dup [ dup remaining>> empty? [ drop f ] unless ] when - ] ; + ] M: just-parser (compile) ( parser -- quot ) diff --git a/basis/stack-checker/backend/backend.factor b/basis/stack-checker/backend/backend.factor index b08bdd8436..5f7eb5ceae 100755 --- a/basis/stack-checker/backend/backend.factor +++ b/basis/stack-checker/backend/backend.factor @@ -124,18 +124,13 @@ M: object apply-object push-literal ; : undo-infer ( -- ) recorded get [ f "inferred-effect" set-word-prop ] each ; -: consume/produce ( effect quot -- ) - #! quot is ( inputs outputs -- ) - [ - [ - [ in>> length consume-d ] - [ out>> length produce-d ] - bi - ] dip call - ] [ - drop - terminated?>> [ terminate ] when - ] 2bi ; inline +: (consume/produce) ( effect -- inputs outputs ) + [ in>> length consume-d ] [ out>> length produce-d ] bi ; + +: consume/produce ( effect quot: ( inputs outputs -- ) -- ) + '[ (consume/produce) @ ] + [ terminated?>> [ terminate ] when ] + bi ; inline : infer-word-def ( word -- ) [ specialized-def ] [ add-recursive-state ] bi infer-quot ; @@ -143,23 +138,12 @@ M: object apply-object push-literal ; : end-infer ( -- ) meta-d clone #return, ; -: effect-required? ( word -- ? ) - { - { [ dup deferred? ] [ drop f ] } - { [ dup crossref? not ] [ drop f ] } - [ def>> [ word? ] any? ] - } cond ; - -: ?missing-effect ( word -- ) - dup effect-required? - [ missing-effect inference-error ] [ drop ] if ; +: required-stack-effect ( word -- effect ) + dup stack-effect [ ] [ missing-effect inference-error ] ?if ; : check-effect ( word effect -- ) - over stack-effect { - { [ dup not ] [ 2drop ?missing-effect ] } - { [ 2dup effect<= ] [ 3drop ] } - [ effect-error ] - } cond ; + over required-stack-effect 2dup effect<= + [ 3drop ] [ effect-error ] if ; : finish-word ( word -- ) current-effect @@ -183,22 +167,20 @@ M: object apply-object push-literal ; dependencies off generic-dependencies off [ infer-word-def end-infer ] - [ finish-word current-effect ] - bi + [ finish-word ] + [ stack-effect ] + tri ] with-scope ] maybe-cannot-infer ; : apply-word/effect ( word effect -- ) swap '[ _ #call, ] consume/produce ; -: required-stack-effect ( word -- effect ) - dup stack-effect [ ] [ \ missing-effect inference-error ] ?if ; - : call-recursive-word ( word -- ) dup required-stack-effect apply-word/effect ; : cached-infer ( word -- ) - dup "inferred-effect" word-prop apply-word/effect ; + dup stack-effect apply-word/effect ; : with-infer ( quot -- effect visitor ) [ diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 56aebb20e7..4ac9d802ed 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -319,12 +319,18 @@ M: object infer-call* \ fixnum/i { fixnum fixnum } { integer } define-primitive \ fixnum/i make-foldable +\ fixnum/i-fast { fixnum fixnum } { fixnum } define-primitive +\ fixnum/i-fast make-foldable + \ fixnum-mod { fixnum fixnum } { fixnum } define-primitive \ fixnum-mod make-foldable \ fixnum/mod { fixnum fixnum } { integer fixnum } define-primitive \ fixnum/mod make-foldable +\ fixnum/mod-fast { fixnum fixnum } { fixnum fixnum } define-primitive +\ fixnum/mod-fast make-foldable + \ fixnum-bitand { fixnum fixnum } { fixnum } define-primitive \ fixnum-bitand make-foldable diff --git a/basis/threads/threads.factor b/basis/threads/threads.factor index 305ef0cca3..8556167009 100644 --- a/basis/threads/threads.factor +++ b/basis/threads/threads.factor @@ -118,7 +118,7 @@ DEFER: stop [ ] while drop ; -: start ( namestack thread -- ) +: start ( namestack thread -- * ) [ set-self set-namestack diff --git a/basis/tools/deploy/config/config.factor b/basis/tools/deploy/config/config.factor index 1d9761e885..63c8393b51 100644 --- a/basis/tools/deploy/config/config.factor +++ b/basis/tools/deploy/config/config.factor @@ -14,12 +14,12 @@ SYMBOL: deploy-threads? SYMBOL: deploy-io -: deploy-io-options +CONSTANT: deploy-io-options { { 1 "Level 1 - No input/output" } { 2 "Level 2 - Basic ANSI C streams" } { 3 "Level 3 - Non-blocking streams and networking" } - } ; + } : strip-io? ( -- ? ) deploy-io get 1 = ; @@ -27,7 +27,7 @@ SYMBOL: deploy-io SYMBOL: deploy-reflection -: deploy-reflection-options +CONSTANT: deploy-reflection-options { { 1 "Level 1 - No reflection" } { 2 "Level 2 - Retain word names" } @@ -35,7 +35,7 @@ SYMBOL: deploy-reflection { 4 "Level 4 - Debugger" } { 5 "Level 5 - Parser" } { 6 "Level 6 - Full environment" } - } ; + } : strip-word-names? ( -- ? ) deploy-reflection get 2 < ; : strip-prettyprint? ( -- ? ) deploy-reflection get 3 < ; diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index 5095f9e93e..e61021e633 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -190,7 +190,7 @@ IN: tools.deploy.shaker "Stripping default methods" show [ [ generic? ] instances - [ "No method" throw ] define-temp + [ "No method" throw ] (( -- * )) define-temp dup t "default" set-word-prop '[ [ _ "default-method" set-word-prop ] [ make-generic ] bi diff --git a/basis/ui/cocoa/views/views.factor b/basis/ui/cocoa/views/views.factor index 3201779cc5..9e32f2f4de 100644 --- a/basis/ui/cocoa/views/views.factor +++ b/basis/ui/cocoa/views/views.factor @@ -14,15 +14,15 @@ IN: ui.cocoa.views #! Cocoa -> Factor UI button mapping -> buttonNumber H{ { 0 1 } { 2 2 } { 1 3 } } at ; -: modifiers +CONSTANT: modifiers { { S+ HEX: 20000 } { C+ HEX: 40000 } { A+ HEX: 100000 } { M+ HEX: 80000 } - } ; + } -: key-codes +CONSTANT: key-codes H{ { 71 "CLEAR" } { 36 "RET" } @@ -47,7 +47,7 @@ IN: ui.cocoa.views { 126 "UP" } { 116 "PAGE_UP" } { 121 "PAGE_DOWN" } - } ; + } : key-code ( event -- string ? ) dup -> keyCode key-codes at diff --git a/basis/ui/gadgets/buttons/buttons.factor b/basis/ui/gadgets/buttons/buttons.factor index dabc12d3ae..3deb280c83 100644 --- a/basis/ui/gadgets/buttons/buttons.factor +++ b/basis/ui/gadgets/buttons/buttons.factor @@ -173,7 +173,7 @@ TUPLE: radio-paint < caching-pen color interior-vertices boundary-vertices ; diff --git a/basis/ui/gadgets/frames/frames.factor b/basis/ui/gadgets/frames/frames.factor index ae4c7d929a..a4d6b46129 100644 --- a/basis/ui/gadgets/frames/frames.factor +++ b/basis/ui/gadgets/frames/frames.factor @@ -13,16 +13,16 @@ M: glue pref-dim* drop { 0 0 } ; : ( -- grid ) 9 [ ] replicate 3 group ; -: @center 1 1 ; inline -: @left 0 1 ; inline -: @right 2 1 ; inline -: @top 1 0 ; inline -: @bottom 1 2 ; inline +: @center ( -- i j ) 1 1 ; inline +: @left ( -- i j ) 0 1 ; inline +: @right ( -- i j ) 2 1 ; inline +: @top ( -- i j ) 1 0 ; inline +: @bottom ( -- i j ) 1 2 ; inline -: @top-left 0 0 ; inline -: @top-right 2 0 ; inline -: @bottom-left 0 2 ; inline -: @bottom-right 2 2 ; inline +: @top-left ( -- i j ) 0 0 ; inline +: @top-right ( -- i j ) 2 0 ; inline +: @bottom-left ( -- i j ) 0 2 ; inline +: @bottom-right ( -- i j ) 2 2 ; inline TUPLE: frame < grid ; diff --git a/basis/ui/gadgets/sliders/sliders.factor b/basis/ui/gadgets/sliders/sliders.factor index 1c2055156e..f22bd08ba2 100644 --- a/basis/ui/gadgets/sliders/sliders.factor +++ b/basis/ui/gadgets/sliders/sliders.factor @@ -18,7 +18,7 @@ TUPLE: slider < frame elevator thumb saved line ; : elevator-length ( slider -- n ) [ elevator>> dim>> ] [ orientation>> ] bi v. ; -: min-thumb-dim 15 ; +CONSTANT: min-thumb-dim 15 : slider-value ( gadget -- n ) model>> range-value >fixnum ; : slider-page ( gadget -- n ) model>> range-page-value ; diff --git a/basis/ui/gadgets/theme/theme.factor b/basis/ui/gadgets/theme/theme.factor index 6ca3868d87..7dabd994c2 100644 --- a/basis/ui/gadgets/theme/theme.factor +++ b/basis/ui/gadgets/theme/theme.factor @@ -56,6 +56,6 @@ IN: ui.gadgets.theme T{ gray f 0.5 1.0 } } ; -: sans-serif-font { "sans-serif" plain 12 } ; +CONSTANT: sans-serif-font { "sans-serif" plain 12 } -: monospace-font { "monospace" plain 12 } ; +CONSTANT: monospace-font { "monospace" plain 12 } diff --git a/basis/ui/render/render.factor b/basis/ui/render/render.factor index 5cbac9798a..a913c78f7d 100755 --- a/basis/ui/render/render.factor +++ b/basis/ui/render/render.factor @@ -191,11 +191,11 @@ M: polygon draw-interior [ [ GL_POLYGON 0 ] dip interior-count>> glDrawArrays ] tri ; -: arrow-up { { 3 0 } { 6 6 } { 0 6 } } ; -: arrow-right { { 0 0 } { 6 3 } { 0 6 } } ; -: arrow-down { { 0 0 } { 6 0 } { 3 6 } } ; -: arrow-left { { 0 3 } { 6 0 } { 6 6 } } ; -: close-box { { 0 0 } { 6 0 } { 6 6 } { 0 6 } } ; +CONSTANT: arrow-up { { 3 0 } { 6 6 } { 0 6 } } +CONSTANT: arrow-right { { 0 0 } { 6 3 } { 0 6 } } +CONSTANT: arrow-down { { 0 0 } { 6 0 } { 3 6 } } +CONSTANT: arrow-left { { 0 3 } { 6 0 } { 6 6 } } +CONSTANT: close-box { { 0 0 } { 6 0 } { 6 6 } { 0 6 } } : ( color points -- gadget ) dup max-dim diff --git a/basis/unicode/data/data.factor b/basis/unicode/data/data.factor index de8d28ad2e..bff4ddeaab 100644 --- a/basis/unicode/data/data.factor +++ b/basis/unicode/data/data.factor @@ -97,8 +97,8 @@ VALUE: properties [ nip zero? not ] assoc-filter >hashtable ; -: categories ( -- names ) - ! For non-existent characters, use Cn +! For non-existent characters, use Cn +CONSTANT: categories { "Cn" "Lu" "Ll" "Lt" "Lm" "Lo" "Mn" "Mc" "Me" @@ -106,9 +106,9 @@ VALUE: properties "Pc" "Pd" "Ps" "Pe" "Pi" "Pf" "Po" "Sm" "Sc" "Sk" "So" "Zs" "Zl" "Zp" - "Cc" "Cf" "Cs" "Co" } ; + "Cc" "Cf" "Cs" "Co" } -: num-chars HEX: 2FA1E ; +CONSTANT: num-chars HEX: 2FA1E ! the maximum unicode char in the first 3 planes diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index ceeab571b8..9e064cf99c 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -538,4 +538,4 @@ tuple [ [ first2 ] dip make-primitive ] each-index ! Bump build number -"build" "kernel" create build 1+ 1quotation define +"build" "kernel" create build 1+ [ ] curry (( -- n )) define-declared diff --git a/core/compiler/units/units-docs.factor b/core/compiler/units/units-docs.factor index 09baf91018..46d3dbc33f 100644 --- a/core/compiler/units/units-docs.factor +++ b/core/compiler/units/units-docs.factor @@ -67,7 +67,3 @@ HELP: modify-code-heap ( alist -- ) HELP: compile { $values { "words" "a sequence of words" } } { $description "Compiles a set of words." } ; - -HELP: compile-call -{ $values { "quot" "a quotation" } } -{ $description "Compiles and runs a quotation." } ; diff --git a/core/compiler/units/units.factor b/core/compiler/units/units.factor index ac3e99e24c..0577f8b83c 100644 --- a/core/compiler/units/units.factor +++ b/core/compiler/units/units.factor @@ -172,9 +172,6 @@ SYMBOL: remake-generics-hook ] [ ] cleanup ] with-scope ; inline -: compile-call ( quot -- ) - [ define-temp ] with-compilation-unit execute ; - : default-recompile-hook ( words -- alist ) [ f ] { } map>assoc ; diff --git a/core/continuations/continuations.factor b/core/continuations/continuations.factor index c7056856b6..37418b85f5 100644 --- a/core/continuations/continuations.factor +++ b/core/continuations/continuations.factor @@ -92,10 +92,10 @@ C: continuation PRIVATE> -: continue-with ( obj continuation -- ) +: continue-with ( obj continuation -- * ) [ (continue-with) ] 2 (throw) ; -: continue ( continuation -- ) +: continue ( continuation -- * ) f swap continue-with ; SYMBOL: return-continuation @@ -103,7 +103,7 @@ SYMBOL: return-continuation : with-return ( quot -- ) [ [ return-continuation set ] prepose callcc0 ] with-scope ; inline -: return ( -- ) +: return ( -- * ) return-continuation get continue ; : with-datastack ( stack quot -- newstack ) @@ -173,7 +173,7 @@ TUPLE: restart name obj continuation ; C: restart -: restart ( restart -- ) +: restart ( restart -- * ) [ obj>> ] [ continuation>> ] bi continue-with ; M: object compute-restarts drop { } ; diff --git a/core/effects/effects.factor b/core/effects/effects.factor index 8a06653eb8..0e40d926d8 100644 --- a/core/effects/effects.factor +++ b/core/effects/effects.factor @@ -48,6 +48,8 @@ M: word stack-effect { "declared-effect" "inferred-effect" } swap props>> [ at ] curry map [ ] find nip ; +M: deferred stack-effect call-next-method (( -- * )) or ; + M: effect clone [ in>> clone ] [ out>> clone ] bi ; diff --git a/core/generic/standard/standard.factor b/core/generic/standard/standard.factor index 9ace1a01f4..f9fe3a6e9e 100644 --- a/core/generic/standard/standard.factor +++ b/core/generic/standard/standard.factor @@ -50,16 +50,16 @@ ERROR: no-method object generic ; convert-hi-tag-methods ; +: mangle-method ( method -- quot ) + 1quotation generic get extra-values \ drop + prepend [ ] like ; + : find-default ( methods -- quot ) #! Side-effects methods. object bootstrap-word swap delete-at* [ - drop generic get "default-method" word-prop 1quotation + drop generic get "default-method" word-prop mangle-method ] unless ; -: mangle-method ( method generic -- quot ) - [ 1quotation ] [ extra-values \ drop ] bi* - prepend [ ] like ; - : ( word -- engine ) object bootstrap-word assumed set { [ generic set ] @@ -67,7 +67,7 @@ ERROR: no-method object generic ; [ V{ } clone "engines" set-word-prop ] [ "methods" word-prop - [ generic get mangle-method ] assoc-map + [ mangle-method ] assoc-map [ find-default default set ] [ ] bi diff --git a/core/words/words-docs.factor b/core/words/words-docs.factor index 4dfa2d49bc..f5990c295e 100644 --- a/core/words/words-docs.factor +++ b/core/words/words-docs.factor @@ -288,12 +288,12 @@ HELP: define-declared { $side-effects "word" } ; HELP: define-temp -{ $values { "quot" quotation } { "word" word } } +{ $values { "quot" quotation } { "effect" effect } { "word" word } } { $description "Creates an uninterned word that will call " { $snippet "quot" } " when executed." } { $notes "The following phrases are equivalent:" { $code "[ 2 2 + . ] call" } - { $code "[ 2 2 + . ] define-temp execute" } + { $code "[ 2 2 + . ] (( -- )) define-temp execute" } "This word must be called from inside " { $link with-compilation-unit } "." } ; diff --git a/core/words/words.factor b/core/words/words.factor index 4a3c1b2d52..43a391e46a 100755 --- a/core/words/words.factor +++ b/core/words/words.factor @@ -212,8 +212,8 @@ M: word subwords drop f ; : gensym ( -- word ) "( gensym )" f ; -: define-temp ( quot -- word ) - [ gensym dup ] dip define ; +: define-temp ( quot effect -- word ) + [ gensym dup ] 2dip define-declared ; : reveal ( word -- ) dup [ name>> ] [ vocabulary>> ] bi dup vocab-words From f1d20719b2b7a75662cea4037c61b2b589da6e94 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 23 Feb 2009 20:51:14 -0600 Subject: [PATCH 55/85] inferred-effect word prop is just a boolean now, not an effect object --- basis/stack-checker/backend/backend.factor | 9 ++++----- core/effects/effects.factor | 4 +--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/basis/stack-checker/backend/backend.factor b/basis/stack-checker/backend/backend.factor index 5f7eb5ceae..3c298bdfed 100755 --- a/basis/stack-checker/backend/backend.factor +++ b/basis/stack-checker/backend/backend.factor @@ -146,11 +146,10 @@ M: object apply-object push-literal ; [ 3drop ] [ effect-error ] if ; : finish-word ( word -- ) - current-effect - [ check-effect ] - [ drop recorded get push ] - [ "inferred-effect" set-word-prop ] - 2tri ; + [ current-effect check-effect ] + [ recorded get push ] + [ t "inferred-effect" set-word-prop ] + tri ; : cannot-infer-effect ( word -- * ) "cannot-infer" word-prop throw ; diff --git a/core/effects/effects.factor b/core/effects/effects.factor index 0e40d926d8..a9f9634d46 100644 --- a/core/effects/effects.factor +++ b/core/effects/effects.factor @@ -44,9 +44,7 @@ M: effect effect>string ( effect -- string ) GENERIC: stack-effect ( word -- effect/f ) -M: word stack-effect - { "declared-effect" "inferred-effect" } - swap props>> [ at ] curry map [ ] find nip ; +M: word stack-effect "declared-effect" word-prop ; M: deferred stack-effect call-next-method (( -- * )) or ; From eaad0c766018f8c3eec6cb242a3169e911f975bb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 23 Feb 2009 21:40:17 -0600 Subject: [PATCH 56/85] Updating code to use CONSTANT: instead of : foo 123 ; inline --- .../bootstrap/image/download/download.factor | 2 +- basis/cairo/ffi/ffi.factor | 6 +- basis/farkup/farkup.factor | 2 +- basis/furnace/actions/actions.factor | 2 +- basis/furnace/alloy/alloy.factor | 2 +- basis/furnace/asides/asides.factor | 2 +- basis/furnace/auth/login/login.factor | 2 +- basis/furnace/auth/providers/null/null.factor | 4 +- .../conversations/conversations.factor | 2 +- basis/furnace/sessions/sessions.factor | 2 +- basis/furnace/utilities/utilities.factor | 4 +- .../html/templates/chloe/syntax/syntax.factor | 2 +- basis/io/encodings/8-bit/8-bit.factor | 11 +- basis/logging/server/server.factor | 2 +- basis/math/quaternions/quaternions.factor | 10 +- basis/windows/kernel32/kernel32.factor | 4 +- basis/x11/constants/constants.factor | 350 +++++++++--------- basis/x11/glx/glx.factor | 34 +- basis/x11/xim/xim.factor | 2 +- basis/xml/entities/entities.factor | 12 +- basis/xml/errors/errors.factor | 4 +- extra/24-game/24-game.factor | 2 +- extra/benchmark/backtrack/backtrack.factor | 4 +- extra/benchmark/fasta/fasta.factor | 10 +- extra/benchmark/raytracer/raytracer.factor | 7 +- extra/benchmark/sockets/sockets.factor | 2 +- extra/galois-talk/galois-talk.factor | 4 +- extra/game-input/iokit/iokit.factor | 4 +- .../google-tech-talk/google-tech-talk.factor | 4 +- extra/irc/client/client.factor | 2 +- extra/irc/ui/ui.factor | 6 +- extra/joystick-demo/joystick-demo.factor | 8 +- extra/key-caps/key-caps.factor | 6 +- extra/lint/lint.factor | 2 +- extra/lisppaste/lisppaste.factor | 2 +- extra/mason/common/common.factor | 28 +- extra/math/analysis/analysis.factor | 4 +- extra/maze/maze.factor | 2 +- .../minneapolis-talk/minneapolis-talk.factor | 4 +- extra/minneapolis-talk/minneapolis-talk.txt | 116 ------ extra/nehe/2/2.factor | 4 +- extra/nehe/3/3.factor | 4 +- extra/nehe/4/4.factor | 4 +- extra/nehe/5/5.factor | 4 +- extra/otug-talk/otug-talk.factor | 4 +- extra/slides/slides.factor | 4 +- extra/vpri-talk/vpri-talk.factor | 4 +- extra/yahoo/yahoo.factor | 6 +- unfinished/benchmark/richards/richards.factor | 272 -------------- unfinished/sql/sql-tests.factor | 42 --- unfinished/sql/sql.factor | 172 --------- 51 files changed, 295 insertions(+), 903 deletions(-) delete mode 100755 extra/minneapolis-talk/minneapolis-talk.txt delete mode 100644 unfinished/benchmark/richards/richards.factor delete mode 100644 unfinished/sql/sql-tests.factor delete mode 100755 unfinished/sql/sql.factor diff --git a/basis/bootstrap/image/download/download.factor b/basis/bootstrap/image/download/download.factor index f9b7b56779..5bfc5f7ccc 100644 --- a/basis/bootstrap/image/download/download.factor +++ b/basis/bootstrap/image/download/download.factor @@ -4,7 +4,7 @@ USING: http.client checksums checksums.md5 splitting assocs kernel io.files bootstrap.image sequences io urls ; IN: bootstrap.image.download -: url URL" http://factorcode.org/images/latest/" ; +CONSTANT: url URL" http://factorcode.org/images/latest/" : download-checksums ( -- alist ) url "checksums.txt" >url derive-url http-get nip diff --git a/basis/cairo/ffi/ffi.factor b/basis/cairo/ffi/ffi.factor index d29a3fb097..c2daa05374 100644 --- a/basis/cairo/ffi/ffi.factor +++ b/basis/cairo/ffi/ffi.factor @@ -72,9 +72,9 @@ C-ENUM: CAIRO_STATUS_INVALID_STRIDE ; TYPEDEF: int cairo_content_t -: CAIRO_CONTENT_COLOR HEX: 1000 ; -: CAIRO_CONTENT_ALPHA HEX: 2000 ; -: CAIRO_CONTENT_COLOR_ALPHA HEX: 3000 ; +CONSTANT: CAIRO_CONTENT_COLOR HEX: 1000 +CONSTANT: CAIRO_CONTENT_ALPHA HEX: 2000 +CONSTANT: CAIRO_CONTENT_COLOR_ALPHA HEX: 3000 TYPEDEF: void* cairo_write_func_t : cairo-write-func ( quot -- callback ) diff --git a/basis/farkup/farkup.factor b/basis/farkup/farkup.factor index eea30a3040..50ee938659 100755 --- a/basis/farkup/farkup.factor +++ b/basis/farkup/farkup.factor @@ -157,7 +157,7 @@ stand-alone = (line | code | heading | list | table | paragraph | nl)* ;EBNF -: invalid-url "javascript:alert('Invalid URL in farkup');" ; +CONSTANT: invalid-url "javascript:alert('Invalid URL in farkup');" : check-url ( href -- href' ) { diff --git a/basis/furnace/actions/actions.factor b/basis/furnace/actions/actions.factor index 97cb73c9cb..166d2a88a2 100644 --- a/basis/furnace/actions/actions.factor +++ b/basis/furnace/actions/actions.factor @@ -63,7 +63,7 @@ TUPLE: action rest init authorize display validate submit ; : param ( name -- value ) params get at ; -: revalidate-url-key "__u" ; +CONSTANT: revalidate-url-key "__u" : revalidate-url ( -- url/f ) revalidate-url-key param diff --git a/basis/furnace/alloy/alloy.factor b/basis/furnace/alloy/alloy.factor index 0fe80427b9..dc280c1e44 100644 --- a/basis/furnace/alloy/alloy.factor +++ b/basis/furnace/alloy/alloy.factor @@ -10,7 +10,7 @@ furnace.auth.providers furnace.auth.login.permits ; IN: furnace.alloy -: state-classes { session aside conversation permit } ; inline +CONSTANT: state-classes { session aside conversation permit } : init-furnace-tables ( -- ) state-classes ensure-tables diff --git a/basis/furnace/asides/asides.factor b/basis/furnace/asides/asides.factor index 7489d19f94..ecf6d0a628 100644 --- a/basis/furnace/asides/asides.factor +++ b/basis/furnace/asides/asides.factor @@ -23,7 +23,7 @@ aside "ASIDES" { { "post-data" "POST_DATA" FACTOR-BLOB } } define-persistent -: aside-id-key "__a" ; +CONSTANT: aside-id-key "__a" TUPLE: asides < server-state-manager ; diff --git a/basis/furnace/auth/login/login.factor b/basis/furnace/auth/login/login.factor index 0ceafa7f86..915ae1c224 100644 --- a/basis/furnace/auth/login/login.factor +++ b/basis/furnace/auth/login/login.factor @@ -64,7 +64,7 @@ SYMBOL: capabilities PRIVATE> -: flashed-variables { description capabilities } ; +CONSTANT: flashed-variables { description capabilities } : login-failed ( -- * ) "invalid username or password" validation-error diff --git a/basis/furnace/auth/providers/null/null.factor b/basis/furnace/auth/providers/null/null.factor index 39ea812ae7..0fab3c5b09 100644 --- a/basis/furnace/auth/providers/null/null.factor +++ b/basis/furnace/auth/providers/null/null.factor @@ -3,9 +3,7 @@ USING: furnace.auth.providers kernel ; IN: furnace.auth.providers.null -TUPLE: no-users ; - -: no-users T{ no-users } ; +SINGLETON: no-users M: no-users get-user 2drop f ; diff --git a/basis/furnace/conversations/conversations.factor b/basis/furnace/conversations/conversations.factor index 266958c8a4..bbb84e2f05 100644 --- a/basis/furnace/conversations/conversations.factor +++ b/basis/furnace/conversations/conversations.factor @@ -20,7 +20,7 @@ conversation "CONVERSATIONS" { { "session" "SESSION" BIG-INTEGER +not-null+ } } define-persistent -: conversation-id-key "__c" ; +CONSTANT: conversation-id-key "__c" TUPLE: conversations < server-state-manager ; diff --git a/basis/furnace/sessions/sessions.factor b/basis/furnace/sessions/sessions.factor index 52e705c153..3eb7a11215 100644 --- a/basis/furnace/sessions/sessions.factor +++ b/basis/furnace/sessions/sessions.factor @@ -73,7 +73,7 @@ TUPLE: sessions < server-state-manager domain verify? ; [ session set ] [ save-session-after ] bi sessions get responder>> call-responder ; -: session-id-key "__s" ; +CONSTANT: session-id-key "__s" : verify-session ( session -- session ) sessions get verify?>> [ diff --git a/basis/furnace/utilities/utilities.factor b/basis/furnace/utilities/utilities.factor index 4fc68f7735..c0cb7dbced 100755 --- a/basis/furnace/utilities/utilities.factor +++ b/basis/furnace/utilities/utilities.factor @@ -89,7 +89,7 @@ M: object modify-form drop f ; [XML name=<->/> XML] ] [ drop ] if ; -: nested-forms-key "__n" ; +CONSTANT: nested-forms-key "__n" : request-params ( request -- assoc ) dup method>> { @@ -131,7 +131,7 @@ M: object modify-form drop f ; SYMBOL: exit-continuation -: exit-with ( value -- ) +: exit-with ( value -- * ) exit-continuation get continue-with ; : with-exit-continuation ( quot -- value ) diff --git a/basis/html/templates/chloe/syntax/syntax.factor b/basis/html/templates/chloe/syntax/syntax.factor index faf8bed66b..9e7079023d 100644 --- a/basis/html/templates/chloe/syntax/syntax.factor +++ b/basis/html/templates/chloe/syntax/syntax.factor @@ -18,7 +18,7 @@ tags [ H{ } clone ] initialize : CHLOE: scan parse-definition define-chloe-tag ; parsing -: chloe-ns "http://factorcode.org/chloe/1.0" ; inline +CONSTANT: chloe-ns "http://factorcode.org/chloe/1.0" : chloe-name? ( name -- ? ) url>> chloe-ns = ; diff --git a/basis/io/encodings/8-bit/8-bit.factor b/basis/io/encodings/8-bit/8-bit.factor index bad2d9fd82..9ef2b07322 100644 --- a/basis/io/encodings/8-bit/8-bit.factor +++ b/basis/io/encodings/8-bit/8-bit.factor @@ -4,12 +4,12 @@ USING: math.parser arrays io.encodings sequences kernel assocs hashtables io.encodings.ascii generic parser classes.tuple words words.symbol io io.files splitting namespaces math compiler.units accessors classes.singleton classes.mixin -io.encodings.iana ; +io.encodings.iana fry ; IN: io.encodings.8-bit ch ( assoc -- array ) 256 replacement-char - [ [ swapd set-nth ] curry assoc-each ] keep ; + [ '[ swap _ set-nth ] assoc-each ] keep ; : ch>byte ( assoc -- newassoc ) [ swap ] assoc-map >hashtable ; diff --git a/basis/logging/server/server.factor b/basis/logging/server/server.factor index 618dba544c..7dced852fd 100644 --- a/basis/logging/server/server.factor +++ b/basis/logging/server/server.factor @@ -63,7 +63,7 @@ SYMBOL: log-files dup values [ try-dispose ] each clear-assoc ; -: keep-logs 10 ; +CONSTANT: keep-logs 10 : ?delete-file ( path -- ) dup exists? [ delete-file ] [ drop ] if ; diff --git a/basis/math/quaternions/quaternions.factor b/basis/math/quaternions/quaternions.factor index bc6da9f564..f2c2c6d226 100755 --- a/basis/math/quaternions/quaternions.factor +++ b/basis/math/quaternions/quaternions.factor @@ -45,13 +45,13 @@ PRIVATE> first2 [ imaginary-part ] dip >rect 3array ; ! Zero -: q0 { 0 0 } ; +CONSTANT: q0 { 0 0 } ! Units -: q1 { 1 0 } ; -: qi { C{ 0 1 } 0 } ; -: qj { 0 1 } ; -: qk { 0 C{ 0 1 } } ; +CONSTANT: q1 { 1 0 } +CONSTANT: qi { C{ 0 1 } 0 } +CONSTANT: qj { 0 1 } +CONSTANT: qk { 0 C{ 0 1 } } ! Euler angles diff --git a/basis/windows/kernel32/kernel32.factor b/basis/windows/kernel32/kernel32.factor index 8a271f7210..36acc5e346 100755 --- a/basis/windows/kernel32/kernel32.factor +++ b/basis/windows/kernel32/kernel32.factor @@ -993,8 +993,8 @@ FUNCTION: BOOL DuplicateHandle ( BOOL bInheritHandle, DWORD dwOptions ) ; -: DUPLICATE_CLOSE_SOURCE 1 ; -: DUPLICATE_SAME_ACCESS 2 ; +CONSTANT: DUPLICATE_CLOSE_SOURCE 1 +CONSTANT: DUPLICATE_SAME_ACCESS 2 ! FUNCTION: EncodePointer ! FUNCTION: EncodeSystemPointer diff --git a/basis/x11/constants/constants.factor b/basis/x11/constants/constants.factor index fcce09380f..1fe825d6af 100644 --- a/basis/x11/constants/constants.factor +++ b/basis/x11/constants/constants.factor @@ -12,17 +12,17 @@ TYPEDEF: uchar KeyCode ! Reserved Resource and Constant Definitions -: ParentRelative 1 ; -: CopyFromParent 0 ; -: PointerWindow 0 ; -: InputFocus 1 ; -: PointerRoot 1 ; -: AnyPropertyType 0 ; -: AnyKey 0 ; -: AnyButton 0 ; -: AllTemporary 0 ; -: CurrentTime 0 ; -: NoSymbol 0 ; +CONSTANT: ParentRelative 1 +CONSTANT: CopyFromParent 0 +CONSTANT: PointerWindow 0 +CONSTANT: InputFocus 1 +CONSTANT: PointerRoot 1 +CONSTANT: AnyPropertyType 0 +CONSTANT: AnyKey 0 +CONSTANT: AnyButton 0 +CONSTANT: AllTemporary 0 +CONSTANT: CurrentTime 0 +CONSTANT: NoSymbol 0 ! Key masks. Used as modifiers to GrabButton and GrabKey, results of QueryPointer, ! state in various key-, mouse-, and button-related events. @@ -31,14 +31,14 @@ TYPEDEF: uchar KeyCode ! modifier names. Used to build a SetModifierMapping request or ! to read a GetModifierMapping request. These correspond to the ! masks defined above. -: ShiftMapIndex 0 ; -: LockMapIndex 1 ; -: ControlMapIndex 2 ; -: Mod1MapIndex 3 ; -: Mod2MapIndex 4 ; -: Mod3MapIndex 5 ; -: Mod4MapIndex 6 ; -: Mod5MapIndex 7 ; +CONSTANT: ShiftMapIndex 0 +CONSTANT: LockMapIndex 1 +CONSTANT: ControlMapIndex 2 +CONSTANT: Mod1MapIndex 3 +CONSTANT: Mod2MapIndex 4 +CONSTANT: Mod3MapIndex 5 +CONSTANT: Mod4MapIndex 6 +CONSTANT: Mod5MapIndex 7 ! button masks. Used in same manner as Key masks above. Not to be confused @@ -53,100 +53,100 @@ TYPEDEF: uchar KeyCode ! Notify modes -: NotifyNormal 0 ; -: NotifyGrab 1 ; -: NotifyUngrab 2 ; -: NotifyWhileGrabbed 3 ; +CONSTANT: NotifyNormal 0 +CONSTANT: NotifyGrab 1 +CONSTANT: NotifyUngrab 2 +CONSTANT: NotifyWhileGrabbed 3 -: NotifyHint 1 ; ! for MotionNotify events +CONSTANT: NotifyHint 1 ! for MotionNotify events ! Notify detail -: NotifyAncestor 0 ; -: NotifyVirtual 1 ; -: NotifyInferior 2 ; -: NotifyNonlinear 3 ; -: NotifyNonlinearVirtual 4 ; -: NotifyPointer 5 ; -: NotifyPointerRoot 6 ; -: NotifyDetailNone 7 ; +CONSTANT: NotifyAncestor 0 +CONSTANT: NotifyVirtual 1 +CONSTANT: NotifyInferior 2 +CONSTANT: NotifyNonlinear 3 +CONSTANT: NotifyNonlinearVirtual 4 +CONSTANT: NotifyPointer 5 +CONSTANT: NotifyPointerRoot 6 +CONSTANT: NotifyDetailNone 7 ! Visibility notify -: VisibilityUnobscured 0 ; -: VisibilityPartiallyObscured 1 ; -: VisibilityFullyObscured 2 ; +CONSTANT: VisibilityUnobscured 0 +CONSTANT: VisibilityPartiallyObscured 1 +CONSTANT: VisibilityFullyObscured 2 ! Circulation request -: PlaceOnTop 0 ; -: PlaceOnBottom 1 ; +CONSTANT: PlaceOnTop 0 +CONSTANT: PlaceOnBottom 1 ! protocol families -: FamilyInternet 0 ; ! IPv4 -: FamilyDECnet 1 ; -: FamilyChaos 2 ; -: FamilyInternet6 6 ; ! IPv6 +CONSTANT: FamilyInternet 0 ! IPv4 +CONSTANT: FamilyDECnet 1 +CONSTANT: FamilyChaos 2 +CONSTANT: FamilyInternet6 6 ! IPv6 ! authentication families not tied to a specific protocol -: FamilyServerInterpreted 5 ; +CONSTANT: FamilyServerInterpreted 5 ! Property notification -: PropertyNewValue 0 ; -: PropertyDelete 1 ; +CONSTANT: PropertyNewValue 0 +CONSTANT: PropertyDelete 1 ! Color Map notification -: ColormapUninstalled 0 ; -: ColormapInstalled 1 ; +CONSTANT: ColormapUninstalled 0 +CONSTANT: ColormapInstalled 1 ! GrabPointer, GrabButton, GrabKeyboard, GrabKey Modes -: GrabModeSync 0 ; -: GrabModeAsync 1 ; +CONSTANT: GrabModeSync 0 +CONSTANT: GrabModeAsync 1 ! GrabPointer, GrabKeyboard reply status -: GrabSuccess 0 ; -: AlreadyGrabbed 1 ; -: GrabInvalidTime 2 ; -: GrabNotViewable 3 ; -: GrabFrozen 4 ; +CONSTANT: GrabSuccess 0 +CONSTANT: AlreadyGrabbed 1 +CONSTANT: GrabInvalidTime 2 +CONSTANT: GrabNotViewable 3 +CONSTANT: GrabFrozen 4 ! AllowEvents modes -: AsyncPointer 0 ; -: SyncPointer 1 ; -: ReplayPointer 2 ; -: AsyncKeyboard 3 ; -: SyncKeyboard 4 ; -: ReplayKeyboard 5 ; -: AsyncBoth 6 ; -: SyncBoth 7 ; +CONSTANT: AsyncPointer 0 +CONSTANT: SyncPointer 1 +CONSTANT: ReplayPointer 2 +CONSTANT: AsyncKeyboard 3 +CONSTANT: SyncKeyboard 4 +CONSTANT: ReplayKeyboard 5 +CONSTANT: AsyncBoth 6 +CONSTANT: SyncBoth 7 ! Used in SetInputFocus, GetInputFocus : RevertToNone ( -- n ) None ; : RevertToPointerRoot ( -- n ) PointerRoot ; -: RevertToParent 2 ; +CONSTANT: RevertToParent 2 ! ***************************************************************** ! * ERROR CODES ! ***************************************************************** -: Success 0 ; ! everything's okay -: BadRequest 1 ; ! bad request code -: BadValue 2 ; ! int parameter out of range -: BadWindow 3 ; ! parameter not a Window -: BadPixmap 4 ; ! parameter not a Pixmap -: BadAtom 5 ; ! parameter not an Atom -: BadCursor 6 ; ! parameter not a Cursor -: BadFont 7 ; ! parameter not a Font -: BadMatch 8 ; ! parameter mismatch -: BadDrawable 9 ; ! parameter not a Pixmap or Window -: BadAccess 10 ; ! depending on context: +CONSTANT: Success 0 ! everything's okay +CONSTANT: BadRequest 1 ! bad request code +CONSTANT: BadValue 2 ! int parameter out of range +CONSTANT: BadWindow 3 ! parameter not a Window +CONSTANT: BadPixmap 4 ! parameter not a Pixmap +CONSTANT: BadAtom 5 ! parameter not an Atom +CONSTANT: BadCursor 6 ! parameter not a Cursor +CONSTANT: BadFont 7 ! parameter not a Font +CONSTANT: BadMatch 8 ! parameter mismatch +CONSTANT: BadDrawable 9 ! parameter not a Pixmap or Window +CONSTANT: BadAccess 10 ! depending on context: ! - key/button already grabbed ! - attempt to free an illegal ! cmap entry @@ -154,16 +154,16 @@ TYPEDEF: uchar KeyCode ! color map entry. ! - attempt to modify the access control ! list from other than the local host. -: BadAlloc 11 ; ! insufficient resources -: BadColor 12 ; ! no such colormap -: BadGC 13 ; ! parameter not a GC -: BadIDChoice 14 ; ! choice not in range or already used -: BadName 15 ; ! font or color name doesn't exist -: BadLength 16 ; ! Request length incorrect -: BadImplementation 17 ; ! server is defective +CONSTANT: BadAlloc 11 ! insufficient resources +CONSTANT: BadColor 12 ! no such colormap +CONSTANT: BadGC 13 ! parameter not a GC +CONSTANT: BadIDChoice 14 ! choice not in range or already used +CONSTANT: BadName 15 ! font or color name doesn't exist +CONSTANT: BadLength 16 ! Request length incorrect +CONSTANT: BadImplementation 17 ! server is defective -: FirstExtensionError 128 ; -: LastExtensionError 255 ; +CONSTANT: FirstExtensionError 128 +CONSTANT: LastExtensionError 255 ! ***************************************************************** ! * WINDOW DEFINITIONS @@ -172,44 +172,44 @@ TYPEDEF: uchar KeyCode ! Window classes used by CreateWindow ! Note that CopyFromParent is already defined as 0 above -: InputOutput 1 ; -: InputOnly 2 ; +CONSTANT: InputOutput 1 +CONSTANT: InputOnly 2 ! Used in CreateWindow for backing-store hint -: NotUseful 0 ; -: WhenMapped 1 ; -: Always 2 ; +CONSTANT: NotUseful 0 +CONSTANT: WhenMapped 1 +CONSTANT: Always 2 ! Used in ChangeSaveSet -: SetModeInsert 0 ; -: SetModeDelete 1 ; +CONSTANT: SetModeInsert 0 +CONSTANT: SetModeDelete 1 ! Used in ChangeCloseDownMode -: DestroyAll 0 ; -: RetainPermanent 1 ; -: RetainTemporary 2 ; +CONSTANT: DestroyAll 0 +CONSTANT: RetainPermanent 1 +CONSTANT: RetainTemporary 2 ! Window stacking method (in configureWindow) -: Above 0 ; -: Below 1 ; -: TopIf 2 ; -: BottomIf 3 ; -: Opposite 4 ; +CONSTANT: Above 0 +CONSTANT: Below 1 +CONSTANT: TopIf 2 +CONSTANT: BottomIf 3 +CONSTANT: Opposite 4 ! Circulation direction -: RaiseLowest 0 ; -: LowerHighest 1 ; +CONSTANT: RaiseLowest 0 +CONSTANT: LowerHighest 1 ! Property modes -: PropModeReplace 0 ; -: PropModePrepend 1 ; -: PropModeAppend 2 ; +CONSTANT: PropModeReplace 0 +CONSTANT: PropModePrepend 1 +CONSTANT: PropModeAppend 2 ! ***************************************************************** ! * GRAPHICS DEFINITIONS @@ -217,62 +217,62 @@ TYPEDEF: uchar KeyCode ! LineStyle -: LineSolid 0 ; -: LineOnOffDash 1 ; -: LineDoubleDash 2 ; +CONSTANT: LineSolid 0 +CONSTANT: LineOnOffDash 1 +CONSTANT: LineDoubleDash 2 ! capStyle -: CapNotLast 0 ; -: CapButt 1 ; -: CapRound 2 ; -: CapProjecting 3 ; +CONSTANT: CapNotLast 0 +CONSTANT: CapButt 1 +CONSTANT: CapRound 2 +CONSTANT: CapProjecting 3 ! joinStyle -: JoinMiter 0 ; -: JoinRound 1 ; -: JoinBevel 2 ; +CONSTANT: JoinMiter 0 +CONSTANT: JoinRound 1 +CONSTANT: JoinBevel 2 ! fillStyle -: FillSolid 0 ; -: FillTiled 1 ; -: FillStippled 2 ; -: FillOpaqueStippled 3 ; +CONSTANT: FillSolid 0 +CONSTANT: FillTiled 1 +CONSTANT: FillStippled 2 +CONSTANT: FillOpaqueStippled 3 ! fillRule -: EvenOddRule 0 ; -: WindingRule 1 ; +CONSTANT: EvenOddRule 0 +CONSTANT: WindingRule 1 ! subwindow mode -: ClipByChildren 0 ; -: IncludeInferiors 1 ; +CONSTANT: ClipByChildren 0 +CONSTANT: IncludeInferiors 1 ! SetClipRectangles ordering -: Unsorted 0 ; -: YSorted 1 ; -: YXSorted 2 ; -: YXBanded 3 ; +CONSTANT: Unsorted 0 +CONSTANT: YSorted 1 +CONSTANT: YXSorted 2 +CONSTANT: YXBanded 3 ! CoordinateMode for drawing routines -: CoordModeOrigin 0 ; ! relative to the origin -: CoordModePrevious 1 ; ! relative to previous point +CONSTANT: CoordModeOrigin 0 ! relative to the origin +CONSTANT: CoordModePrevious 1 ! relative to previous point ! Polygon shapes -: Complex 0 ; ! paths may intersect -: Nonconvex 1 ; ! no paths intersect, but not convex -: Convex 2 ; ! wholly convex +CONSTANT: Complex 0 ! paths may intersect +CONSTANT: Nonconvex 1 ! no paths intersect, but not convex +CONSTANT: Convex 2 ! wholly convex ! Arc modes for PolyFillArc -: ArcChord 0 ; ! join endpoints of arc -: ArcPieSlice 1 ; ! join endpoints to center of arc +CONSTANT: ArcChord 0 ! join endpoints of arc +CONSTANT: ArcPieSlice 1 ! join endpoints to center of arc ! ***************************************************************** ! * FONTS @@ -280,10 +280,10 @@ TYPEDEF: uchar KeyCode ! used in QueryFont -- draw direction -: FontLeftToRight 0 ; -: FontRightToLeft 1 ; +CONSTANT: FontLeftToRight 0 +CONSTANT: FontRightToLeft 1 -: FontChange 255 ; +CONSTANT: FontChange 255 ! ***************************************************************** ! * IMAGING @@ -291,9 +291,9 @@ TYPEDEF: uchar KeyCode ! ImageFormat -- PutImage, GetImage -: XYBitmap 0 ; ! depth 1, XYFormat -: XYPixmap 1 ; ! depth == drawable depth -: ZPixmap 2 ; ! depth == drawable depth +CONSTANT: XYBitmap 0 ! depth 1, XYFormat +CONSTANT: XYPixmap 1 ! depth == drawable depth +CONSTANT: ZPixmap 2 ! depth == drawable depth ! ***************************************************************** ! * COLOR MAP STUFF @@ -301,8 +301,8 @@ TYPEDEF: uchar KeyCode ! For CreateColormap -: AllocNone 0 ; ! create map with no entries -: AllocAll 1 ; ! allocate entire map writeable +CONSTANT: AllocNone 0 ! create map with no entries +CONSTANT: AllocAll 1 ! allocate entire map writeable ! Flags used in StoreNamedColor, StoreColors @@ -317,20 +317,20 @@ TYPEDEF: uchar KeyCode ! QueryBestSize Class -: CursorShape 0 ; ! largest size that can be displayed -: TileShape 1 ; ! size tiled fastest -: StippleShape 2 ; ! size stippled fastest +CONSTANT: CursorShape 0 ! largest size that can be displayed +CONSTANT: TileShape 1 ! size tiled fastest +CONSTANT: StippleShape 2 ! size stippled fastest ! ***************************************************************** ! * KEYBOARD/POINTER STUFF ! ***************************************************************** -: AutoRepeatModeOff 0 ; -: AutoRepeatModeOn 1 ; -: AutoRepeatModeDefault 2 ; +CONSTANT: AutoRepeatModeOff 0 +CONSTANT: AutoRepeatModeOn 1 +CONSTANT: AutoRepeatModeDefault 2 -: LedModeOff 0 ; -: LedModeOn 1 ; +CONSTANT: LedModeOff 0 +CONSTANT: LedModeOn 1 ! masks for ChangeKeyboardControl @@ -343,33 +343,33 @@ TYPEDEF: uchar KeyCode : KBKey ( -- n ) 6 2^ ; : KBAutoRepeatMode ( -- n ) 7 2^ ; -: MappingSuccess 0 ; -: MappingBusy 1 ; -: MappingFailed 2 ; +CONSTANT: MappingSuccess 0 +CONSTANT: MappingBusy 1 +CONSTANT: MappingFailed 2 -: MappingModifier 0 ; -: MappingKeyboard 1 ; -: MappingPointer 2 ; +CONSTANT: MappingModifier 0 +CONSTANT: MappingKeyboard 1 +CONSTANT: MappingPointer 2 ! ***************************************************************** ! * SCREEN SAVER STUFF ! ***************************************************************** -: DontPreferBlanking 0 ; -: PreferBlanking 1 ; -: DefaultBlanking 2 ; +CONSTANT: DontPreferBlanking 0 +CONSTANT: PreferBlanking 1 +CONSTANT: DefaultBlanking 2 -: DisableScreenSaver 0 ; -: DisableScreenInterval 0 ; +CONSTANT: DisableScreenSaver 0 +CONSTANT: DisableScreenInterval 0 -: DontAllowExposures 0 ; -: AllowExposures 1 ; -: DefaultExposures 2 ; +CONSTANT: DontAllowExposures 0 +CONSTANT: AllowExposures 1 +CONSTANT: DefaultExposures 2 ! for ForceScreenSaver -: ScreenSaverReset 0 ; -: ScreenSaverActive 1 ; +CONSTANT: ScreenSaverReset 0 +CONSTANT: ScreenSaverActive 1 ! ***************************************************************** ! * HOSTS AND CONNECTIONS @@ -377,30 +377,30 @@ TYPEDEF: uchar KeyCode ! for ChangeHosts -: HostInsert 0 ; -: HostDelete 1 ; +CONSTANT: HostInsert 0 +CONSTANT: HostDelete 1 ! for ChangeAccessControl -: EnableAccess 1 ; -: DisableAccess 0 ; +CONSTANT: EnableAccess 1 +CONSTANT: DisableAccess 0 ! Display classes used in opening the connection ! Note that the statically allocated ones are even numbered and the ! dynamically changeable ones are odd numbered -: StaticGray 0 ; -: GrayScale 1 ; -: StaticColor 2 ; -: PseudoColor 3 ; -: TrueColor 4 ; -: DirectColor 5 ; +CONSTANT: StaticGray 0 +CONSTANT: GrayScale 1 +CONSTANT: StaticColor 2 +CONSTANT: PseudoColor 3 +CONSTANT: TrueColor 4 +CONSTANT: DirectColor 5 ! Byte order used in imageByteOrder and bitmapBitOrder -: LSBFirst 0 ; -: MSBFirst 1 ; +CONSTANT: LSBFirst 0 +CONSTANT: MSBFirst 1 ! ***************************************************************** ! * EXTENDED WINDOW MANAGER HINTS diff --git a/basis/x11/glx/glx.factor b/basis/x11/glx/glx.factor index 11473d6e83..e6001d3e59 100644 --- a/basis/x11/glx/glx.factor +++ b/basis/x11/glx/glx.factor @@ -9,23 +9,23 @@ IN: x11.glx LIBRARY: glx ! Visual Config Attributes (glXGetConfig, glXGetFBConfigAttrib) -: GLX_USE_GL 1 ; ! support GLX rendering -: GLX_BUFFER_SIZE 2 ; ! depth of the color buffer -: GLX_LEVEL 3 ; ! level in plane stacking -: GLX_RGBA 4 ; ! true if RGBA mode -: GLX_DOUBLEBUFFER 5 ; ! double buffering supported -: GLX_STEREO 6 ; ! stereo buffering supported -: GLX_AUX_BUFFERS 7 ; ! number of aux buffers -: GLX_RED_SIZE 8 ; ! number of red component bits -: GLX_GREEN_SIZE 9 ; ! number of green component bits -: GLX_BLUE_SIZE 10 ; ! number of blue component bits -: GLX_ALPHA_SIZE 11 ; ! number of alpha component bits -: GLX_DEPTH_SIZE 12 ; ! number of depth bits -: GLX_STENCIL_SIZE 13 ; ! number of stencil bits -: GLX_ACCUM_RED_SIZE 14 ; ! number of red accum bits -: GLX_ACCUM_GREEN_SIZE 15 ; ! number of green accum bits -: GLX_ACCUM_BLUE_SIZE 16 ; ! number of blue accum bits -: GLX_ACCUM_ALPHA_SIZE 17 ; ! number of alpha accum bits +CONSTANT: GLX_USE_GL 1 ! support GLX rendering +CONSTANT: GLX_BUFFER_SIZE 2 ! depth of the color buffer +CONSTANT: GLX_LEVEL 3 ! level in plane stacking +CONSTANT: GLX_RGBA 4 ! true if RGBA mode +CONSTANT: GLX_DOUBLEBUFFER 5 ! double buffering supported +CONSTANT: GLX_STEREO 6 ! stereo buffering supported +CONSTANT: GLX_AUX_BUFFERS 7 ! number of aux buffers +CONSTANT: GLX_RED_SIZE 8 ! number of red component bits +CONSTANT: GLX_GREEN_SIZE 9 ! number of green component bits +CONSTANT: GLX_BLUE_SIZE 10 ! number of blue component bits +CONSTANT: GLX_ALPHA_SIZE 11 ! number of alpha component bits +CONSTANT: GLX_DEPTH_SIZE 12 ! number of depth bits +CONSTANT: GLX_STENCIL_SIZE 13 ! number of stencil bits +CONSTANT: GLX_ACCUM_RED_SIZE 14 ! number of red accum bits +CONSTANT: GLX_ACCUM_GREEN_SIZE 15 ! number of green accum bits +CONSTANT: GLX_ACCUM_BLUE_SIZE 16 ! number of blue accum bits +CONSTANT: GLX_ACCUM_ALPHA_SIZE 17 ! number of alpha accum bits TYPEDEF: XID GLXContextID TYPEDEF: XID GLXPixmap diff --git a/basis/x11/xim/xim.factor b/basis/x11/xim/xim.factor index 534e47ac37..e06872fa83 100644 --- a/basis/x11/xim/xim.factor +++ b/basis/x11/xim/xim.factor @@ -34,7 +34,7 @@ SYMBOL: xim XNResourceClass over 0 XCreateIC [ "XCreateIC() failed" throw ] unless* ; -: buf-size 100 ; +CONSTANT: buf-size 100 SYMBOL: keybuf SYMBOL: keysym diff --git a/basis/xml/entities/entities.factor b/basis/xml/entities/entities.factor index 3e768b1b88..7eac725052 100644 --- a/basis/xml/entities/entities.factor +++ b/basis/xml/entities/entities.factor @@ -4,20 +4,20 @@ USING: namespaces make kernel assocs sequences fry values io.files io.encodings.binary xml.state ; IN: xml.entities -: entities-out +CONSTANT: entities-out H{ { CHAR: < "<" } { CHAR: > ">" } { CHAR: & "&" } - } ; + } -: quoted-entities-out +CONSTANT: quoted-entities-out H{ { CHAR: & "&" } { CHAR: ' "'" } { CHAR: " """ } { CHAR: < "<" } - } ; + } : escape-string-by ( str table -- escaped ) #! Convert <, >, &, ' and " to HTML entities. @@ -29,14 +29,14 @@ IN: xml.entities : escape-quoted-string ( str -- newstr ) quoted-entities-out escape-string-by ; -: entities +CONSTANT: entities H{ { "lt" CHAR: < } { "gt" CHAR: > } { "amp" CHAR: & } { "apos" CHAR: ' } { "quot" CHAR: " } - } ; + } : with-entities ( entities quot -- ) [ swap extra-entities set call ] with-scope ; inline diff --git a/basis/xml/errors/errors.factor b/basis/xml/errors/errors.factor index 304b38f2bd..35111f5a54 100644 --- a/basis/xml/errors/errors.factor +++ b/basis/xml/errors/errors.factor @@ -290,7 +290,7 @@ M: quoteless-attr summary TUPLE: attr-w/< < xml-error-at ; -: attr-w/< ( value -- * ) +: attr-w/< ( -- * ) \ attr-w/< xml-error-at throw ; M: attr-w/< summary @@ -299,7 +299,7 @@ M: attr-w/< summary TUPLE: text-w/]]> < xml-error-at ; -: text-w/]]> ( text -- * ) +: text-w/]]> ( -- * ) \ text-w/]]> xml-error-at throw ; M: text-w/]]> summary diff --git a/extra/24-game/24-game.factor b/extra/24-game/24-game.factor index f842d5f4cb..f22ca001f4 100644 --- a/extra/24-game/24-game.factor +++ b/extra/24-game/24-game.factor @@ -7,7 +7,7 @@ arrays words quotations accessors math.parser backtrack assocs ; IN: 24-game SYMBOL: commands -: nop ; +: nop ( -- ) ; : do-something ( a b -- c ) { + - * } amb-execute ; : maybe-swap ( a b -- a b ) { nop swap } amb-execute ; : some-rots ( a b c -- a b c ) diff --git a/extra/benchmark/backtrack/backtrack.factor b/extra/benchmark/backtrack/backtrack.factor index df67872b11..0ae7d792dd 100755 --- a/extra/benchmark/backtrack/backtrack.factor +++ b/extra/benchmark/backtrack/backtrack.factor @@ -10,7 +10,7 @@ IN: benchmark.backtrack ! placing them on the stack, and applying the operations ! +, -, * and rot as many times as we wish. -: nop ; +: nop ( -- ) ; : do-something ( a b -- c ) { + - * } amb-execute ; @@ -42,7 +42,7 @@ MEMO: 24-from-4 ( a b c d -- ? ) ] sigma ] sigma ; -: words { 24-from-1 24-from-2 24-from-3 24-from-4 } ; +CONSTANT: words { 24-from-1 24-from-2 24-from-3 24-from-4 } : backtrack-benchmark ( -- ) words [ reset-memoized ] each diff --git a/extra/benchmark/fasta/fasta.factor b/extra/benchmark/fasta/fasta.factor index 61d9e9fd43..2ae5ada8a1 100755 --- a/extra/benchmark/fasta/fasta.factor +++ b/extra/benchmark/fasta/fasta.factor @@ -10,8 +10,6 @@ CONSTANT: IC 29573 CONSTANT: initial-seed 42 CONSTANT: line-length 60 -USE: math.private - : random ( seed -- n seed ) >float IA * IC + IM mod [ IM /f ] keep ; inline @@ -19,7 +17,7 @@ HINTS: random fixnum ; CONSTANT: ALU "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA" -: IUB +CONSTANT: IUB { { CHAR: a 0.27 } { CHAR: c 0.12 } @@ -37,15 +35,15 @@ CONSTANT: ALU "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACC { CHAR: V 0.02 } { CHAR: W 0.02 } { CHAR: Y 0.02 } - } ; inline + } -: homo-sapiens +CONSTANT: homo-sapiens { { CHAR: a 0.3029549426680 } { CHAR: c 0.1979883004921 } { CHAR: g 0.1975473066391 } { CHAR: t 0.3015094502008 } - } ; inline + } : make-cumulative ( freq -- chars floats ) dup keys >byte-array diff --git a/extra/benchmark/raytracer/raytracer.factor b/extra/benchmark/raytracer/raytracer.factor index 8d07ae1c65..a4df1fe04d 100755 --- a/extra/benchmark/raytracer/raytracer.factor +++ b/extra/benchmark/raytracer/raytracer.factor @@ -8,13 +8,14 @@ hints ; IN: benchmark.raytracer ! parameters -: light - #! Normalized { -1 -3 2 }. + +! Normalized { -1 -3 2 }. +CONSTANT: light double-array{ -0.2672612419124244 -0.8017837257372732 0.5345224838248488 - } ; inline + } CONSTANT: oversampling 4 diff --git a/extra/benchmark/sockets/sockets.factor b/extra/benchmark/sockets/sockets.factor index 20c905156b..d6e4f29b86 100755 --- a/extra/benchmark/sockets/sockets.factor +++ b/extra/benchmark/sockets/sockets.factor @@ -10,7 +10,7 @@ SYMBOL: counter SYMBOL: port-promise SYMBOL: server -: number-of-requests 1000 ; +CONSTANT: number-of-requests 1000 : server-addr ( -- addr ) "127.0.0.1" port-promise get ?promise ; diff --git a/extra/galois-talk/galois-talk.factor b/extra/galois-talk/galois-talk.factor index 259fa446af..ccba90fb6f 100644 --- a/extra/galois-talk/galois-talk.factor +++ b/extra/galois-talk/galois-talk.factor @@ -8,7 +8,7 @@ help.topics math.functions compiler.tree.optimizer compiler.cfg.optimizer fry ; IN: galois-talk -: galois-slides +CONSTANT: galois-slides { { $slide "Factor!" { $url "http://factorcode.org" } @@ -305,7 +305,7 @@ IN: galois-talk "Factor has many cool things that I didn't talk about" "Questions?" } -} ; +} : galois-talk ( -- ) galois-slides slides-window ; diff --git a/extra/game-input/iokit/iokit.factor b/extra/game-input/iokit/iokit.factor index 8a10535306..254ed61ab0 100755 --- a/extra/game-input/iokit/iokit.factor +++ b/extra/game-input/iokit/iokit.factor @@ -121,12 +121,12 @@ CONSTANT: hat-switch-matching-hash : hat-switch? ( {usage-page,usage} -- ? ) { 1 HEX: 39 } = ; inline -: pov-values +CONSTANT: pov-values { pov-up pov-up-right pov-right pov-down-right pov-down pov-down-left pov-left pov-up-left pov-neutral - } ; inline + } : button-value ( value -- f/(0,1] ) IOHIDValueGetIntegerValue dup zero? [ drop f ] when ; diff --git a/extra/google-tech-talk/google-tech-talk.factor b/extra/google-tech-talk/google-tech-talk.factor index 9bd3c5854b..4d4e3b0507 100644 --- a/extra/google-tech-talk/google-tech-talk.factor +++ b/extra/google-tech-talk/google-tech-talk.factor @@ -8,7 +8,7 @@ help.topics math.functions compiler.tree.optimizer compiler.cfg.optimizer fry ; IN: google-tech-talk -: google-slides +CONSTANT: google-slides { { $slide "Factor!" { $url "http://factorcode.org" } @@ -562,7 +562,7 @@ IN: google-tech-talk "Put your prejudices aside and give it a shot!" } { $slide "Questions?" } -} ; +} : google-talk ( -- ) google-slides slides-window ; diff --git a/extra/irc/client/client.factor b/extra/irc/client/client.factor index 0eba6f6af5..2770471093 100755 --- a/extra/irc/client/client.factor +++ b/extra/irc/client/client.factor @@ -12,7 +12,7 @@ IN: irc.client ! Setup and running objects ! ====================================== -: irc-port 6667 ; ! Default irc port +CONSTANT: irc-port 6667 ! Default irc port TUPLE: irc-profile server port nickname password ; C: irc-profile diff --git a/extra/irc/ui/ui.factor b/extra/irc/ui/ui.factor index 59e4cf6cb4..791639d260 100755 --- a/extra/irc/ui/ui.factor +++ b/extra/irc/ui/ui.factor @@ -28,9 +28,9 @@ TUPLE: irc-tab < frame chat client window ; : write-color ( str color -- ) foreground associate format ; -: dark-red T{ rgba f 0.5 0.0 0.0 1 } ; -: dark-green T{ rgba f 0.0 0.5 0.0 1 } ; -: dark-blue T{ rgba f 0.0 0.0 0.5 1 } ; +CONSTANT: dark-red T{ rgba f 0.5 0.0 0.0 1 } +CONSTANT: dark-green T{ rgba f 0.0 0.5 0.0 1 } +CONSTANT: dark-blue T{ rgba f 0.0 0.0 0.5 1 } : dot-or-parens ( string -- string ) [ "." ] diff --git a/extra/joystick-demo/joystick-demo.factor b/extra/joystick-demo/joystick-demo.factor index 9e457c7bdd..188095dd2e 100755 --- a/extra/joystick-demo/joystick-demo.factor +++ b/extra/joystick-demo/joystick-demo.factor @@ -5,8 +5,8 @@ calendar locals strings ui.gadgets.buttons combinators math.parser assocs threads ; IN: joystick-demo -: SIZE { 151 151 } ; -: INDICATOR-SIZE { 4 4 } ; +CONSTANT: SIZE { 151 151 } +CONSTANT: INDICATOR-SIZE { 4 4 } : FREQUENCY ( -- f ) 30 recip seconds ; TUPLE: axis-gadget < gadget indicator z-indicator pov ; @@ -21,7 +21,7 @@ M: axis-gadget pref-dim* drop SIZE ; : indicator-polygon ( -- polygon ) { 0 0 } INDICATOR-SIZE (rect-polygon) ; -: pov-polygons +CONSTANT: pov-polygons V{ { pov-neutral { { 70 75 } { 75 70 } { 80 75 } { 75 80 } } } { pov-up { { 70 65 } { 75 60 } { 80 65 } } } @@ -32,7 +32,7 @@ M: axis-gadget pref-dim* drop SIZE ; { pov-down-left { { 67 90 } { 60 90 } { 60 83 } } } { pov-left { { 65 70 } { 60 75 } { 65 80 } } } { pov-up-left { { 67 60 } { 60 60 } { 60 67 } } } - } ; + } : ( color -- indicator ) indicator-polygon ; diff --git a/extra/key-caps/key-caps.factor b/extra/key-caps/key-caps.factor index 05edb205d2..acf20f90ab 100755 --- a/extra/key-caps/key-caps.factor +++ b/extra/key-caps/key-caps.factor @@ -4,7 +4,7 @@ words arrays assocs math calendar fry alarms ui ui.gadgets.borders ui.gestures ; IN: key-caps -: key-locations H{ +CONSTANT: key-locations H{ { key-escape { { 0 0 } { 10 10 } } } { key-f1 { { 20 0 } { 10 10 } } } @@ -129,9 +129,9 @@ IN: key-caps { key-keypad-0 { { 190 55 } { 20 10 } } } { key-keypad-. { { 210 55 } { 10 10 } } } -} ; +} -: KEYBOARD-SIZE { 230 65 } ; +CONSTANT: KEYBOARD-SIZE { 230 65 } : FREQUENCY ( -- f ) 30 recip seconds ; TUPLE: key-caps-gadget < gadget keys alarm ; diff --git a/extra/lint/lint.factor b/extra/lint/lint.factor index 849cc540a3..9877c70062 100755 --- a/extra/lint/lint.factor +++ b/extra/lint/lint.factor @@ -42,7 +42,7 @@ SYMBOL: def-hash-keys set-alien-float alien-float } ; -: trivial-defs +: trivial-defs ( -- seq ) { [ drop ] [ 2array ] [ bitand ] diff --git a/extra/lisppaste/lisppaste.factor b/extra/lisppaste/lisppaste.factor index df85f01f26..43b5b78097 100644 --- a/extra/lisppaste/lisppaste.factor +++ b/extra/lisppaste/lisppaste.factor @@ -1,7 +1,7 @@ USING: arrays kernel xml-rpc ; IN: lisppaste -: url "http://www.common-lisp.net:8185/RPC2" ; +CONSTANT: url "http://www.common-lisp.net:8185/RPC2" : channels ( -- seq ) { } "listchannels" url invoke-method ; diff --git a/extra/mason/common/common.factor b/extra/mason/common/common.factor index ec0cbdbc9c..3cd38e1ff4 100644 --- a/extra/mason/common/common.factor +++ b/extra/mason/common/common.factor @@ -67,24 +67,24 @@ SYMBOL: stamp : ?prepare-build-machine ( -- ) builds/factor exists? [ prepare-build-machine ] unless ; -: load-everything-vocabs-file "load-everything-vocabs" ; -: load-everything-errors-file "load-everything-errors" ; +CONSTANT: load-everything-vocabs-file "load-everything-vocabs" +CONSTANT: load-everything-errors-file "load-everything-errors" -: test-all-vocabs-file "test-all-vocabs" ; -: test-all-errors-file "test-all-errors" ; +CONSTANT: test-all-vocabs-file "test-all-vocabs" +CONSTANT: test-all-errors-file "test-all-errors" -: help-lint-vocabs-file "help-lint-vocabs" ; -: help-lint-errors-file "help-lint-errors" ; +CONSTANT: help-lint-vocabs-file "help-lint-vocabs" +CONSTANT: help-lint-errors-file "help-lint-errors" -: boot-time-file "boot-time" ; -: load-time-file "load-time" ; -: compiler-errors-file "compiler-errors" ; -: test-time-file "test-time" ; -: help-lint-time-file "help-lint-time" ; -: benchmark-time-file "benchmark-time" ; -: html-help-time-file "html-help-time" ; +CONSTANT: boot-time-file "boot-time" +CONSTANT: load-time-file "load-time" +CONSTANT: compiler-errors-file "compiler-errors" +CONSTANT: test-time-file "test-time" +CONSTANT: help-lint-time-file "help-lint-time" +CONSTANT: benchmark-time-file "benchmark-time" +CONSTANT: html-help-time-file "html-help-time" -: benchmarks-file "benchmarks" ; +CONSTANT: benchmarks-file "benchmarks" SYMBOL: status diff --git a/extra/math/analysis/analysis.factor b/extra/math/analysis/analysis.factor index 9c773f748e..fa01b0376d 100755 --- a/extra/math/analysis/analysis.factor +++ b/extra/math/analysis/analysis.factor @@ -11,11 +11,11 @@ IN: math.analysis CONSTANT: gamma-g6 5.15 -: gamma-p6 +CONSTANT: gamma-p6 { 2.50662827563479526904 225.525584619175212544 -268.295973841304927459 80.9030806934622512966 -5.00757863970517583837 0.0114684895434781459556 - } ; inline + } : gamma-z ( x n -- seq ) [ + recip ] with map 1.0 0 pick set-nth ; diff --git a/extra/maze/maze.factor b/extra/maze/maze.factor index de345e732e..a490a8bbfc 100644 --- a/extra/maze/maze.factor +++ b/extra/maze/maze.factor @@ -4,7 +4,7 @@ arrays kernel random ui ui.gadgets ui.gadgets.canvas ui.render math.order math.geometry.rect ; IN: maze -: line-width 8 ; +CONSTANT: line-width 8 SYMBOL: visited diff --git a/extra/minneapolis-talk/minneapolis-talk.factor b/extra/minneapolis-talk/minneapolis-talk.factor index 25bad4061a..6f1df44bfb 100755 --- a/extra/minneapolis-talk/minneapolis-talk.factor +++ b/extra/minneapolis-talk/minneapolis-talk.factor @@ -2,7 +2,7 @@ USING: slides help.markup math arrays hashtables namespaces sequences kernel sequences parser memoize ; IN: minneapolis-talk -: minneapolis-slides +CONSTANT: minneapolis-slides { { $slide "What is Factor?" "Dynamically typed, stack language" @@ -175,7 +175,7 @@ IN: minneapolis-talk "Mailing list: factor-talk@lists.sf.net" } { $slide "Questions?" } -} ; +} : minneapolis-talk ( -- ) minneapolis-slides slides-window ; diff --git a/extra/minneapolis-talk/minneapolis-talk.txt b/extra/minneapolis-talk/minneapolis-talk.txt deleted file mode 100755 index 5310accf5b..0000000000 --- a/extra/minneapolis-talk/minneapolis-talk.txt +++ /dev/null @@ -1,116 +0,0 @@ -- how to create a small module -- editor integration -- presentations -- module system -- copy and paste factoring, inverse -- help system -- tetris -- memoization -- editing inspector demo -- dynamic scope, lexical scope - -Factor: contradictions? ------------------------ - -Have our cake and eat it too - -Research -vs- practical -High level -vs- fast -Interactive -vs- deployment - -Factor from 10,000 feet ------------------------ - -word: named function -vocabulary: module -quotation: anonymous function -classes, objects, etc. - -The stack ---------- - -- Stack -vs- applicative -- Pass by reference, dynamically typed -- Stack languages: you can omit names where they're not needed -- More compositional style -- If you need to name things for clarity, you can: - lexical vars, dynamic vars, sequences, assocs, objects... - -Functional programming ----------------------- - -Quotations -Curry -Continuations - -Object-oriented programming ---------------------------- - -Generic words: sort of like open classes -Tuple reshaping -Editing inspector - -Meta programming ----------------- - -Simple, orthogonal core - -Why use a stack at all? ------------------------ - -Nice idioms: 10 days ago -Copy and paste factoring -Easy meta-programming -Sequence operations correspond to functional operations: -- curry is adding at the front -- compose is append - -UI --- - -Written in Factor -renders with OpenGL -Windows, X11, Cocoa backends -You can call Windows, X11, Cocoa APIs directly -OpenGL 2.1 shaders, OpenAL 3D audio... - -Tools ------ - -Edit -Usages -Profiler -Easy to make your own tools - -Implementation --------------- - -Two compilers -Generational garbage collector -Non-blocking I/O - -Hands on --------- - -Community ---------- - -Factor started in 2003 -About a dozen contributors -Handful of "core contributors" -Web site: http://factorcode.org -IRC: #concatenative on irc.freenode.net -Mailing list: factor-talk@lists.sf.net - -C library interface -------------------- - -Efficient -No need to write C code -Supports floats, structs, unions, ... -Function pointers, callbacks -Here is an example - -TerminateProcess - -process-handle TerminateProcess diff --git a/extra/nehe/2/2.factor b/extra/nehe/2/2.factor index 29d4ccffc1..fdb53ef254 100644 --- a/extra/nehe/2/2.factor +++ b/extra/nehe/2/2.factor @@ -4,8 +4,8 @@ IN: nehe.2 TUPLE: nehe2-gadget < gadget ; -: width 256 ; -: height 256 ; +CONSTANT: width 256 +CONSTANT: height 256 : ( -- gadget ) nehe2-gadget new-gadget ; diff --git a/extra/nehe/3/3.factor b/extra/nehe/3/3.factor index 75f2e573cc..557655a029 100644 --- a/extra/nehe/3/3.factor +++ b/extra/nehe/3/3.factor @@ -4,8 +4,8 @@ IN: nehe.3 TUPLE: nehe3-gadget < gadget ; -: width 256 ; -: height 256 ; +CONSTANT: width 256 +CONSTANT: height 256 : ( -- gadget ) nehe3-gadget new-gadget ; diff --git a/extra/nehe/4/4.factor b/extra/nehe/4/4.factor index fda22d2f1e..00308277ea 100644 --- a/extra/nehe/4/4.factor +++ b/extra/nehe/4/4.factor @@ -5,8 +5,8 @@ IN: nehe.4 TUPLE: nehe4-gadget < gadget rtri rquad thread quit? ; -: width 256 ; -: height 256 ; +CONSTANT: width 256 +CONSTANT: height 256 : redraw-interval ( -- dt ) 10 milliseconds ; : ( -- gadget ) diff --git a/extra/nehe/5/5.factor b/extra/nehe/5/5.factor index 30d0991fd8..3723014c83 100755 --- a/extra/nehe/5/5.factor +++ b/extra/nehe/5/5.factor @@ -4,8 +4,8 @@ calendar ; IN: nehe.5 TUPLE: nehe5-gadget < gadget rtri rquad thread quit? ; -: width 256 ; -: height 256 ; +CONSTANT: width 256 +CONSTANT: height 256 : redraw-interval ( -- dt ) 10 milliseconds ; : ( -- gadget ) diff --git a/extra/otug-talk/otug-talk.factor b/extra/otug-talk/otug-talk.factor index b52749dbe1..ef5782dda7 100644 --- a/extra/otug-talk/otug-talk.factor +++ b/extra/otug-talk/otug-talk.factor @@ -39,7 +39,7 @@ M: png-gadget ungraft* ( gadget -- ) : $tetris ( element -- ) drop [ gadget. ] ($block) ; -: otug-slides +CONSTANT: otug-slides { { $slide "Factor!" { $url "http://factorcode.org" } @@ -361,7 +361,7 @@ var price = (order == null ? null : order.price);"> } "Factor has many cool things that I didn't talk about" "Questions?" } -} ; +} : otug-talk ( -- ) otug-slides slides-window ; diff --git a/extra/slides/slides.factor b/extra/slides/slides.factor index 0ce946dc49..ba21ba9c84 100755 --- a/extra/slides/slides.factor +++ b/extra/slides/slides.factor @@ -6,7 +6,7 @@ ui.gadgets.books ui.gadgets.panes ui.gestures ui.render parser accessors colors ; IN: slides -: stylesheet +CONSTANT: stylesheet H{ { default-span-style H{ @@ -40,7 +40,7 @@ IN: slides H{ { table-gap { 10 20 } } } } { bullet "\u0000b7" } - } ; + } : $title ( string -- ) [ H{ { font "sans-serif" } { font-size 48 } } format ] ($block) ; diff --git a/extra/vpri-talk/vpri-talk.factor b/extra/vpri-talk/vpri-talk.factor index 35d8bb52ff..5d7620101f 100644 --- a/extra/vpri-talk/vpri-talk.factor +++ b/extra/vpri-talk/vpri-talk.factor @@ -8,7 +8,7 @@ help.topics math.functions compiler.tree.optimizer compiler.cfg.optimizer fry ; IN: vpri-talk -: vpri-slides +CONSTANT: vpri-slides { { $slide "Factor!" { $url "http://factorcode.org" } @@ -485,7 +485,7 @@ IN: vpri-talk "Factor has many cool things that I didn't talk about" "Questions?" } -} ; +} : vpri-talk ( -- ) vpri-slides slides-window ; diff --git a/extra/yahoo/yahoo.factor b/extra/yahoo/yahoo.factor index b58a11747f..5e0c08b430 100755 --- a/extra/yahoo/yahoo.factor +++ b/extra/yahoo/yahoo.factor @@ -18,8 +18,7 @@ format similar-ok language country site subscription license ; first3 ] map ; -: yahoo-url ( -- str ) - URL" http://search.yahooapis.com/WebSearchService/V1/webSearch" ; +CONSTANT: yahoo-url URL" http://search.yahooapis.com/WebSearchService/V1/webSearch" :: param ( search url name quot -- search url ) search url search quot call @@ -49,8 +48,7 @@ format similar-ok language country site subscription license ; "similar_ok" [ similar-ok>> ] bool-param nip ; -: factor-id - "fRrVAKzV34GDyeRw6bUHDhEWHRedwfOC7e61wwXZLgGF80E67spxdQXuugBe2pgIevMmKwA-" ; +CONSTANT: factor-id "fRrVAKzV34GDyeRw6bUHDhEWHRedwfOC7e61wwXZLgGF80E67spxdQXuugBe2pgIevMmKwA-" : ( query -- search ) search new diff --git a/unfinished/benchmark/richards/richards.factor b/unfinished/benchmark/richards/richards.factor deleted file mode 100644 index 90d4304eee..0000000000 --- a/unfinished/benchmark/richards/richards.factor +++ /dev/null @@ -1,272 +0,0 @@ -! Based on http://research.sun.com/people/mario/java_benchmarking/ -! Ported by Factor by Slava Pestov -! -! Based on original version written in BCPL by Dr Martin Richards -! in 1981 at Cambridge University Computer Laboratory, England -! Java version: Copyright (C) 1995 Sun Microsystems, Inc. -! by Jonathan Gibbons. -! Outer loop added 8/7/96 by Alex Jacoby -USING: values kernel accessors math math.bitwise sequences -arrays combinators fry locals ; -IN: benchmark.richards - -! Packets -TUPLE: packet link id kind a1 a2 ; - -: BUFSIZE 4 ; inline - -: ( link id kind -- packet ) - packet new - swap >>kind - swap >>id - swap >>link - 0 >>a1 - BUFSIZE 0 >>a2 ; - -: last-packet ( packet -- last ) - dup link>> [ last-packet ] [ ] ?if ; - -: append-to ( packet list -- packet ) - [ f >>link ] dip - [ tuck last-packet >>link drop ] when* ; - -! Tasks -: I_IDLE 1 ; inline -: I_WORK 2 ; inline -: I_HANDLERA 3 ; inline -: I_HANDLERB 4 ; inline -: I_DEVA 5 ; inline -: I_DEVB 6 ; inline - -! Packet types -: K_DEV 1000 ; inline -: K_WORK 1001 ; inline - -: PKTBIT 1 ; inline -: WAITBIT 2 ; inline -: HOLDBIT 4 ; inline - -: S_RUN 0 ; inline -: S_RUNPKT ( -- n ) { PKTBIT } flags ; inline -: S_WAIT ( -- n ) { WAITBIT } flags ; inline -: S_WAITPKT ( -- n ) { WAITBIT PKTBIT } flags ; inline -: S_HOLD ( -- n ) { HOLDBIT } flags ; inline -: S_HOLDPKT ( -- n ) { HOLDBIT PKTBIT } flags ; inline -: S_HOLDWAIT ( -- n ) { HOLDBIT WAITBIT } flags ; inline -: S_HOLDWAITPKT ( -- n ) { HOLDBIT WAITBIT PKTBIT } flags ; inline - -: task-tab-size 10 ; inline - -VALUE: task-tab -VALUE: task-list -VALUE: tracing -VALUE: hold-count -VALUE: qpkt-count - -TUPLE: task link id pri wkq state ; - -: new-task ( id pri wkq state class -- task ) - new - swap >>state - swap >>wkq - swap >>pri - swap >>id - task-list >>link - dup to: task-list - dup dup id>> task-tab set-nth ; inline - -GENERIC: fn ( packet task -- task ) - -: state-on ( task flag -- task ) - '[ _ bitor ] change-state ; inline - -: state-off ( task flag -- task ) - '[ _ bitnot bitand ] change-state ; inline - -: wait-task ( task -- task ) - WAITBIT state-on ; - -: hold ( task -- task ) - hold-count 1+ to: hold-count - HOLDBIT state-on - link>> ; - -: highest-priority ( t1 t2 -- t1/t2 ) - [ [ pri>> ] bi@ > ] most ; - -: find-tcb ( i -- task ) - task-tab nth [ "Bad task" throw ] unless* ; - -: release ( task i -- task ) - find-tcb HOLDBIT state-off highest-priority ; - -:: qpkt ( task pkt -- task ) - [let | t [ pkt id>> find-tcb ] | - t [ - qpkt-count 1+ to: qpkt-count - f pkt (>>link) - task id>> pkt (>>id) - t wkq>> [ - pkt t wkq>> append-to t (>>wkq) - task - ] [ - pkt t (>>wkq) - t PKTBIT state-on drop - t task highest-priority - ] if - ] [ task ] if - ] ; - -: schedule-waitpkt ( task -- task pkt ) - dup wkq>> - 2dup link>> >>wkq drop - 2dup S_RUNPKT S_RUN ? >>state drop ; inline - -: schedule-run ( task pkt -- task ) - swap fn ; inline - -: schedule-wait ( task -- task ) - link>> ; inline - -: (schedule) ( task -- ) - [ - dup state>> { - { S_WAITPKT [ schedule-waitpkt schedule-run (schedule) ] } - { S_RUN [ f schedule-run (schedule) ] } - { S_RUNPKT [ f schedule-run (schedule) ] } - { S_WAIT [ schedule-wait (schedule) ] } - { S_HOLD [ schedule-wait (schedule) ] } - { S_HOLDPKT [ schedule-wait (schedule) ] } - { S_HOLDWAIT [ schedule-wait (schedule) ] } - { S_HOLDWAITPKT [ schedule-wait (schedule) ] } - [ 2drop ] - } case - ] when* ; - -: schedule ( -- ) - task-list (schedule) ; - -! Device task -TUPLE: device-task < task v1 ; - -: ( id pri wkq -- task ) - dup S_WAITPKT S_WAIT ? device-task new-task ; - -M:: device-task fn ( pkt task -- task ) - pkt [ - task dup v1>> - [ wait-task ] - [ [ f ] change-v1 swap qpkt ] if - ] [ pkt task (>>v1) task hold ] if ; - -TUPLE: handler-task < task workpkts devpkts ; - -: ( id pri wkq -- task ) - dup S_WAITPKT S_WAIT ? handler-task new-task ; - -M:: handler-task fn ( pkt task -- task ) - pkt [ - task over kind>> K_WORK = - [ [ append-to ] change-workpkts ] - [ [ append-to ] change-devpkts ] - if drop - ] when* - - task workpkts>> [ - [let* | devpkt [ task devpkts>> ] - workpkt [ task workpkts>> ] - count [ workpkt a1>> ] | - count BUFSIZE > [ - workpkt link>> task (>>workpkts) - task workpkt qpkt - ] [ - devpkt [ - devpkt link>> task (>>devpkts) - count workpkt a2>> nth devpkt (>>a1) - count 1+ workpkt (>>a1) - task devpkt qpkt - ] [ - task wait-task - ] if - ] if - ] - ] [ task wait-task ] if ; - -! Idle task -TUPLE: idle-task < task { v1 fixnum } { v2 fixnum } ; - -: ( i a1 a2 -- task ) - [ 0 f S_RUN idle-task new-task ] 2dip - [ >>v1 ] [ >>v2 ] bi* ; - -M: idle-task fn ( pkt task -- task ) - nip - [ 1- ] change-v2 - dup v2>> 0 = [ hold ] [ - dup v1>> 1 bitand 0 = [ - [ -1 shift ] change-v1 - I_DEVA release - ] [ - [ -1 shift HEX: d008 bitor ] change-v1 - I_DEVB release - ] if - ] if ; - -! Work task -TUPLE: work-task < task { handler fixnum } { n fixnum } ; - -: ( id pri w -- work-task ) - dup S_WAITPKT S_WAIT ? work-task new-task - I_HANDLERA >>handler - 0 >>n ; - -M:: work-task fn ( pkt task -- task ) - pkt [ - task [ I_HANDLERA = I_HANDLERB I_HANDLERA ? ] change-handler drop - task handler>> pkt (>>id) - 0 pkt (>>a1) - BUFSIZE [| i | - task [ 1+ ] change-n drop - task n>> 26 > [ 1 task (>>n) ] when - task n>> 1 - CHAR: A + i pkt a2>> set-nth - ] each - task pkt qpkt - ] [ task wait-task ] if ; - -! Main -: init ( -- ) - task-tab-size f to: task-tab - f to: tracing - 0 to: hold-count - 0 to: qpkt-count ; - -: start ( -- ) - I_IDLE 1 10000 drop - - I_WORK 1000 - f 0 K_WORK 0 K_WORK - drop - - I_HANDLERA 2000 - f I_DEVA K_DEV - I_DEVA K_DEV - I_DEVA K_DEV - drop - - I_HANDLERB 3000 - f I_DEVB K_DEV - I_DEVB K_DEV - I_DEVB K_DEV - drop - - I_DEVA 4000 f drop - I_DEVB 4000 f drop ; - -: check ( -- ) - qpkt-count 23246 assert= - hold-count 9297 assert= ; - -: run ( -- ) - init - start - schedule check ; diff --git a/unfinished/sql/sql-tests.factor b/unfinished/sql/sql-tests.factor deleted file mode 100644 index 0b57c2d8fa..0000000000 --- a/unfinished/sql/sql-tests.factor +++ /dev/null @@ -1,42 +0,0 @@ -USING: kernel namespaces db.sql sequences math ; -IN: db.sql.tests - -! TUPLE: person name age ; -: insert-1 - { insert - { - { table "person" } - { columns "name" "age" } - { values "erg" 26 } - } - } ; - -: update-1 - { update "person" - { set { "name" "erg" } - { "age" 6 } } - { where { "age" 6 } } - } ; - -: select-1 - { select - { columns - "branchno" - { count "staffno" as "mycount" } - { sum "salary" as "mysum" } } - { from "staff" "lol" } - { where - { "salary" > all - { select - { columns "salary" } - { from "staff" } - { where { "branchno" = "b003" } } - } - } - { "branchno" > 3 } } - { group-by "branchno" "lol2" } - { having { count "staffno" > 1 } } - { order-by "branchno" } - { offset 40 } - { limit 20 } - } ; diff --git a/unfinished/sql/sql.factor b/unfinished/sql/sql.factor deleted file mode 100755 index ba0673ae24..0000000000 --- a/unfinished/sql/sql.factor +++ /dev/null @@ -1,172 +0,0 @@ -USING: kernel parser quotations classes.tuple words math.order -nmake namespaces sequences arrays combinators -prettyprint strings math.parser math symbols db ; -IN: db.sql - -SYMBOLS: insert update delete select distinct columns from as -where group-by having order-by limit offset is-null desc all -any count avg table values ; - -: input-spec, ( obj -- ) 1, ; -: output-spec, ( obj -- ) 2, ; -: input, ( obj -- ) 3, ; -: output, ( obj -- ) 4, ; - -DEFER: sql% - -: (sql-interleave) ( seq sep -- ) - [ sql% ] curry [ sql% ] interleave ; - -: sql-interleave ( seq str sep -- ) - swap sql% (sql-interleave) ; - -: sql-function, ( seq function -- ) - sql% "(" sql% unclip sql% ")" sql% [ sql% ] each ; - -: sql-where, ( seq -- ) - [ - [ second 0, ] - [ first 0, ] - [ third 1, \ ? 0, ] tri - ] each ; - -HOOK: sql-create db ( object -- ) -M: db sql-create ( object -- ) - drop - "create table" sql% ; - -HOOK: sql-drop db ( object -- ) -M: db sql-drop ( object -- ) - drop - "drop table" sql% ; - -HOOK: sql-insert db ( object -- ) -M: db sql-insert ( object -- ) - drop - "insert into" sql% ; - -HOOK: sql-update db ( object -- ) -M: db sql-update ( object -- ) - drop - "update" sql% ; - -HOOK: sql-delete db ( object -- ) -M: db sql-delete ( object -- ) - drop - "delete" sql% ; - -HOOK: sql-select db ( object -- ) -M: db sql-select ( object -- ) - "select" sql% "," (sql-interleave) ; - -HOOK: sql-columns db ( object -- ) -M: db sql-columns ( object -- ) - "," (sql-interleave) ; - -HOOK: sql-from db ( object -- ) -M: db sql-from ( object -- ) - "from" "," sql-interleave ; - -HOOK: sql-where db ( object -- ) -M: db sql-where ( object -- ) - "where" 0, sql-where, ; - -HOOK: sql-group-by db ( object -- ) -M: db sql-group-by ( object -- ) - "group by" "," sql-interleave ; - -HOOK: sql-having db ( object -- ) -M: db sql-having ( object -- ) - "having" "," sql-interleave ; - -HOOK: sql-order-by db ( object -- ) -M: db sql-order-by ( object -- ) - "order by" "," sql-interleave ; - -HOOK: sql-offset db ( object -- ) -M: db sql-offset ( object -- ) - "offset" sql% sql% ; - -HOOK: sql-limit db ( object -- ) -M: db sql-limit ( object -- ) - "limit" sql% sql% ; - -! GENERIC: sql-subselect db ( object -- ) -! M: db sql-subselectselect ( object -- ) - ! "(select" sql% sql% ")" sql% ; - -HOOK: sql-table db ( object -- ) -M: db sql-table ( object -- ) - sql% ; - -HOOK: sql-set db ( object -- ) -M: db sql-set ( object -- ) - "set" "," sql-interleave ; - -HOOK: sql-values db ( object -- ) -M: db sql-values ( object -- ) - "values(" sql% "," (sql-interleave) ")" sql% ; - -HOOK: sql-count db ( object -- ) -M: db sql-count ( object -- ) - "count" sql-function, ; - -HOOK: sql-sum db ( object -- ) -M: db sql-sum ( object -- ) - "sum" sql-function, ; - -HOOK: sql-avg db ( object -- ) -M: db sql-avg ( object -- ) - "avg" sql-function, ; - -HOOK: sql-min db ( object -- ) -M: db sql-min ( object -- ) - "min" sql-function, ; - -HOOK: sql-max db ( object -- ) -M: db sql-max ( object -- ) - "max" sql-function, ; - -: sql-array% ( array -- ) - unclip - { - { \ create [ sql-create ] } - { \ drop [ sql-drop ] } - { \ insert [ sql-insert ] } - { \ update [ sql-update ] } - { \ delete [ sql-delete ] } - { \ select [ sql-select ] } - { \ columns [ sql-columns ] } - { \ from [ sql-from ] } - { \ where [ sql-where ] } - { \ group-by [ sql-group-by ] } - { \ having [ sql-having ] } - { \ order-by [ sql-order-by ] } - { \ offset [ sql-offset ] } - { \ limit [ sql-limit ] } - { \ table [ sql-table ] } - { \ set [ sql-set ] } - { \ values [ sql-values ] } - { \ count [ sql-count ] } - { \ sum [ sql-sum ] } - { \ avg [ sql-avg ] } - { \ min [ sql-min ] } - { \ max [ sql-max ] } - [ sql% [ sql% ] each ] - } case ; - -ERROR: no-sql-match ; -: sql% ( obj -- ) - { - { [ dup string? ] [ 0, ] } - { [ dup array? ] [ sql-array% ] } - { [ dup number? ] [ number>string sql% ] } - { [ dup symbol? ] [ unparse sql% ] } - { [ dup word? ] [ unparse sql% ] } - { [ dup quotation? ] [ call ] } - [ no-sql-match ] - } cond ; - -: parse-sql ( obj -- sql in-spec out-spec in out ) - [ [ sql% ] each ] { { } { } { } } nmake - [ " " join ] 2dip ; From 901bcccc1c6d70e5beeaf96cd0dc32ed40291d21 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 23 Feb 2009 23:25:13 -0600 Subject: [PATCH 57/85] Fix remaining text failures --- basis/compiler/compiler.factor | 5 +---- basis/compiler/tests/optimizer.factor | 22 ++++++++++--------- basis/compiler/tests/simple.factor | 4 ++-- .../tree/cleanup/cleanup-tests.factor | 2 +- .../tree/recursive/recursive-tests.factor | 2 +- basis/tools/profiler/profiler-tests.factor | 2 +- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/basis/compiler/compiler.factor b/basis/compiler/compiler.factor index d707dff983..f2f4e7aa9e 100644 --- a/basis/compiler/compiler.factor +++ b/basis/compiler/compiler.factor @@ -49,7 +49,7 @@ SYMBOL: +failed+ H{ } clone generic-dependencies set f swap compiler-error ; -: fail ( word error -- * ) +: fail ( word error -- ) [ swap compiler-error ] [ drop @@ -112,9 +112,6 @@ t compile-dependencies? set-global : decompile ( word -- ) f 2array 1array modify-code-heap ; -: compile-call ( quot -- ) - [ dup infer define-temp ] with-compilation-unit execute ; - : optimized-recompile-hook ( words -- alist ) [ compile-queue set diff --git a/basis/compiler/tests/optimizer.factor b/basis/compiler/tests/optimizer.factor index 708d17f3d3..cfeb5d01ac 100644 --- a/basis/compiler/tests/optimizer.factor +++ b/basis/compiler/tests/optimizer.factor @@ -55,7 +55,7 @@ TUPLE: pred-test ; ! regression -: literal-not-branch 0 not [ ] [ ] if ; +: literal-not-branch ( -- ) 0 not [ ] [ ] if ; [ ] [ literal-not-branch ] unit-test @@ -108,12 +108,12 @@ GENERIC: void-generic ( obj -- * ) [ 10 ] [ branch-fold-regression-1 ] unit-test ! another regression -: constant-branch-fold-0 "hey" ; foldable +: constant-branch-fold-0 ( -- value ) "hey" ; foldable : constant-branch-fold-1 ( -- ? ) constant-branch-fold-0 "hey" = ; inline [ 1 ] [ [ constant-branch-fold-1 [ 1 ] [ 2 ] if ] compile-call ] unit-test ! another regression -: foo f ; +: foo ( -- value ) f ; : bar ( -- ? ) foo 4 4 = and ; [ f ] [ bar ] unit-test @@ -134,15 +134,15 @@ M: slice foozul ; ] unit-test ! regression -: constant-fold-2 f ; foldable -: constant-fold-3 4 ; foldable +: constant-fold-2 ( -- value ) f ; foldable +: constant-fold-3 ( -- value ) 4 ; foldable [ f t ] [ [ constant-fold-2 constant-fold-3 4 = ] compile-call ] unit-test -: constant-fold-4 f ; foldable -: constant-fold-5 f ; foldable +: constant-fold-4 ( -- value ) f ; foldable +: constant-fold-5 ( -- value ) f ; foldable [ f ] [ [ constant-fold-4 constant-fold-5 or ] compile-call @@ -247,7 +247,7 @@ USE: binary-search.private [ 3 "an integer" ] [ 3 lift-throw-tail-regression ] unit-test [ "hi" "a string" ] [ "hi" lift-throw-tail-regression ] unit-test -: lift-loop-tail-test-1 ( a quot -- ) +: lift-loop-tail-test-1 ( a quot: ( -- ) -- ) over even? [ [ [ 3 - ] dip call ] keep lift-loop-tail-test-1 ] [ @@ -256,11 +256,13 @@ USE: binary-search.private ] [ [ [ 2 - ] dip call ] keep lift-loop-tail-test-1 ] if - ] if ; inline + ] if ; inline recursive -: lift-loop-tail-test-2 +: lift-loop-tail-test-2 ( -- a b c ) 10 [ ] lift-loop-tail-test-1 1 2 3 ; +\ lift-loop-tail-test-2 must-infer + [ 1 2 3 ] [ lift-loop-tail-test-2 ] unit-test ! Forgot a recursive inline check diff --git a/basis/compiler/tests/simple.factor b/basis/compiler/tests/simple.factor index 0fde270eac..d53b864b06 100644 --- a/basis/compiler/tests/simple.factor +++ b/basis/compiler/tests/simple.factor @@ -18,13 +18,13 @@ IN: compiler.tests [ "hey" ] [ [ "hey" ] compile-call ] unit-test ! Calls -: no-op ; +: no-op ( -- ) ; [ ] [ [ no-op ] compile-call ] unit-test [ 3 ] [ [ no-op 3 ] compile-call ] unit-test [ 3 ] [ [ 3 no-op ] compile-call ] unit-test -: bar 4 ; +: bar ( -- value ) 4 ; [ 4 ] [ [ bar no-op ] compile-call ] unit-test [ 4 3 ] [ [ no-op bar 3 ] compile-call ] unit-test diff --git a/basis/compiler/tree/cleanup/cleanup-tests.factor b/basis/compiler/tree/cleanup/cleanup-tests.factor index 751a335a13..54f8aaf20e 100755 --- a/basis/compiler/tree/cleanup/cleanup-tests.factor +++ b/basis/compiler/tree/cleanup/cleanup-tests.factor @@ -474,7 +474,7 @@ cell-bits 32 = [ ] unit-test ! A reduction -: buffalo-sauce f ; +: buffalo-sauce ( -- value ) f ; : steak ( -- ) buffalo-sauce [ steak ] when ; inline recursive diff --git a/basis/compiler/tree/recursive/recursive-tests.factor b/basis/compiler/tree/recursive/recursive-tests.factor index b1f9406092..d548d58bc6 100644 --- a/basis/compiler/tree/recursive/recursive-tests.factor +++ b/basis/compiler/tree/recursive/recursive-tests.factor @@ -87,7 +87,7 @@ compiler.tree.combinators ; ] contains-node? ] unit-test -: blah f ; +: blah ( -- value ) f ; DEFER: a diff --git a/basis/tools/profiler/profiler-tests.factor b/basis/tools/profiler/profiler-tests.factor index 197ace74d8..5bf62ef156 100644 --- a/basis/tools/profiler/profiler-tests.factor +++ b/basis/tools/profiler/profiler-tests.factor @@ -1,6 +1,6 @@ IN: tools.profiler.tests USING: accessors tools.profiler tools.test kernel memory math -threads alien tools.profiler.private sequences compiler.units +threads alien tools.profiler.private sequences compiler words ; [ t ] [ From e7243da0b80dda06cfea3e55954431a7c70b8fb7 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 23 Feb 2009 23:28:02 -0600 Subject: [PATCH 58/85] Clean up memoize code to not use gensym anymore --- basis/macros/macros.factor | 4 +- basis/memoize/memoize-tests.factor | 8 ++- basis/memoize/memoize.factor | 67 ++++++++++++------------- basis/tools/deploy/shaker/shaker.factor | 2 +- 4 files changed, 41 insertions(+), 40 deletions(-) diff --git a/basis/macros/macros.factor b/basis/macros/macros.factor index 4fba7efba3..21a91e567d 100644 --- a/basis/macros/macros.factor +++ b/basis/macros/macros.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2007, 2008 Slava Pestov. +! Copyright (C) 2007, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: parser kernel sequences words effects combinators assocs definitions quotations namespaces memoize accessors ; @@ -7,7 +7,7 @@ IN: macros > 1 ; + stack-effect in>> 1 ; PRIVATE> diff --git a/basis/memoize/memoize-tests.factor b/basis/memoize/memoize-tests.factor index 7ee56866ce..03549d9b80 100644 --- a/basis/memoize/memoize-tests.factor +++ b/basis/memoize/memoize-tests.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2007 Slava Pestov, Daniel Ehrenberg. +! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. USING: math kernel memoize tools.test parser generalizations prettyprint io.streams.string sequences eval ; @@ -17,6 +17,10 @@ MEMO: see-test ( a -- b ) reverse ; [ [ \ see-test see ] with-string-writer ] unit-test -[ ] [ "IN: memoize.tests : fib ;" eval ] unit-test +[ ] [ "IN: memoize.tests : fib ( -- ) ;" eval ] unit-test [ "IN: memoize.tests\n: fib ( -- ) ;\n" ] [ [ \ fib see ] with-string-writer ] unit-test + +[ sq ] (( a -- b )) memoize-quot "q" set + +[ 9 ] [ 3 "q" get call ] unit-test diff --git a/basis/memoize/memoize.factor b/basis/memoize/memoize.factor index 7b8c30c534..3bc573dff5 100644 --- a/basis/memoize/memoize.factor +++ b/basis/memoize/memoize.factor @@ -1,47 +1,45 @@ -! Copyright (C) 2007 Slava Pestov, Daniel Ehrenberg. +! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. USING: kernel hashtables sequences arrays words namespaces make parser math assocs effects definitions quotations summary -accessors ; +accessors fry ; IN: memoize -: packer ( n -- quot ) - { [ f ] [ ] [ 2array ] [ 3array ] [ 4array ] } nth ; - -: unpacker ( n -- quot ) - { [ drop ] [ ] [ first2 ] [ first3 ] [ first4 ] } nth ; - -: #in ( word -- n ) - stack-effect in>> length ; - -: #out ( word -- n ) - stack-effect out>> length ; - -: pack/unpack ( quot word -- newquot ) - [ dup #in unpacker % swap % #out packer % ] [ ] make ; - -: make-memoizer ( quot word -- quot ) - [ - [ #in packer % ] keep - [ "memoize" word-prop , ] keep - [ pack/unpack , ] keep - \ cache , - #out unpacker % - ] [ ] make ; - ERROR: too-many-arguments ; M: too-many-arguments summary drop "There must be no more than 4 input and 4 output arguments" ; -: check-memoized ( word -- ) - [ #in ] [ #out ] bi [ 4 > ] either? [ too-many-arguments ] when ; +> packer ] [ out>> unpacker ] bi surround ; + +: unpack/pack ( quot effect -- newquot ) + [ in>> unpacker ] [ out>> packer ] bi surround ; + +: check-memoized ( effect -- ) + [ in>> ] [ out>> ] bi [ length 4 > ] either? [ too-many-arguments ] when ; + +: make-memoizer ( table quot effect -- quot ) + [ check-memoized ] keep + [ unpack/pack '[ _ _ cache ] ] keep + pack/unpack ; + +PRIVATE> : define-memoized ( word quot -- ) - over check-memoized - 2dup "memo-quot" set-word-prop - over H{ } clone "memoize" set-word-prop - over make-memoizer define ; + [ H{ } clone ] dip + [ pick stack-effect make-memoizer define ] + [ nip "memo-quot" set-word-prop ] + [ drop "memoize" set-word-prop ] + 3tri ; : MEMO: (:) define-memoized ; parsing @@ -57,11 +55,10 @@ M: memoized reset-word bi ; : memoize-quot ( quot effect -- memo-quot ) - gensym swap dupd "declared-effect" set-word-prop - dup rot define-memoized 1quotation ; + [ H{ } clone ] 2dip make-memoizer ; : reset-memoized ( word -- ) "memoize" word-prop clear-assoc ; : invalidate-memoized ( inputs... word -- ) - [ #in packer call ] [ "memoize" word-prop delete-at ] bi ; + [ stack-effect in>> packer call ] [ "memoize" word-prop delete-at ] bi ; diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index e61021e633..5095f9e93e 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -190,7 +190,7 @@ IN: tools.deploy.shaker "Stripping default methods" show [ [ generic? ] instances - [ "No method" throw ] (( -- * )) define-temp + [ "No method" throw ] define-temp dup t "default" set-word-prop '[ [ _ "default-method" set-word-prop ] [ make-generic ] bi From b06903b0efc727bcce5c7269aa033cf94dcc2400 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 23 Feb 2009 23:28:22 -0600 Subject: [PATCH 59/85] Update tree shaker for define-temp changes --- basis/tools/deploy/shaker/shaker.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index 5095f9e93e..961d0ff26d 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -95,7 +95,7 @@ IN: tools.deploy.shaker "cannot-infer" "coercer" "combination" - "compiled-effect" + "compiled-status" "compiled-generic-uses" "compiled-uses" "constraints" @@ -190,7 +190,7 @@ IN: tools.deploy.shaker "Stripping default methods" show [ [ generic? ] instances - [ "No method" throw ] define-temp + [ "No method" throw ] (( -- * )) define-temp dup t "default" set-word-prop '[ [ _ "default-method" set-word-prop ] [ make-generic ] bi From 65a53e1fa5fa120988ec108ed57358bba221c94a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 23 Feb 2009 23:55:16 -0600 Subject: [PATCH 60/85] Don't keep compiled-effect around anymore --- basis/compiler/cfg/debugger/debugger.factor | 2 +- basis/compiler/compiler.factor | 62 ++++++++++--------- basis/compiler/tests/optimizer.factor | 2 +- .../tree/builder/builder-tests.factor | 2 +- basis/compiler/tree/builder/builder.factor | 8 +-- basis/compiler/tree/debugger/debugger.factor | 2 +- 6 files changed, 41 insertions(+), 37 deletions(-) diff --git a/basis/compiler/cfg/debugger/debugger.factor b/basis/compiler/cfg/debugger/debugger.factor index ba58e60a4a..6d0a8f8c8e 100644 --- a/basis/compiler/cfg/debugger/debugger.factor +++ b/basis/compiler/cfg/debugger/debugger.factor @@ -16,7 +16,7 @@ M: callable test-cfg build-tree optimize-tree gensym build-cfg ; M: word test-cfg - [ build-tree-from-word nip optimize-tree ] keep build-cfg ; + [ build-tree-from-word optimize-tree ] keep build-cfg ; SYMBOL: allocate-registers? diff --git a/basis/compiler/compiler.factor b/basis/compiler/compiler.factor index f2f4e7aa9e..d6da95408d 100644 --- a/basis/compiler/compiler.factor +++ b/basis/compiler/compiler.factor @@ -1,46 +1,47 @@ ! Copyright (C) 2004, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel namespaces arrays sequences io -words fry continuations vocabs assocs dlists definitions math -graphs generic combinators deques search-deques io -stack-checker stack-checker.state stack-checker.inlining -compiler.errors compiler.units compiler.tree.builder -compiler.tree.optimizer compiler.cfg.builder -compiler.cfg.optimizer compiler.cfg.linearization -compiler.cfg.two-operand compiler.cfg.linear-scan -compiler.cfg.stack-frame compiler.codegen compiler.utilities ; +USING: accessors kernel namespaces arrays sequences io words fry +continuations vocabs assocs dlists definitions math graphs +generic combinators deques search-deques io stack-checker +stack-checker.state stack-checker.inlining +combinators.short-circuit compiler.errors compiler.units +compiler.tree.builder compiler.tree.optimizer +compiler.cfg.builder compiler.cfg.optimizer +compiler.cfg.linearization compiler.cfg.two-operand +compiler.cfg.linear-scan compiler.cfg.stack-frame +compiler.codegen compiler.utilities ; IN: compiler SYMBOL: compile-queue SYMBOL: compiled -: queue-compile ( word -- ) +: queue-compile? ( word -- ? ) { - { [ dup "forgotten" word-prop ] [ ] } - { [ dup compiled get key? ] [ ] } - { [ dup inlined-block? ] [ ] } - { [ dup primitive? ] [ ] } - [ dup compile-queue get push-front ] - } cond drop ; + [ "forgotten" word-prop ] + [ compiled get key? ] + [ inlined-block? ] + [ primitive? ] + } 1|| not ; + +: queue-compile ( word -- ) + dup queue-compile? [ compile-queue get push-front ] [ drop ] if ; : maybe-compile ( word -- ) dup optimized>> [ drop ] [ queue-compile ] if ; -SYMBOL: +failed+ +SYMBOLS: +optimized+ +unoptimized+ ; : ripple-up ( words -- ) - dup "compiled-effect" word-prop +failed+ eq? + dup "compiled-status" word-prop +unoptimized+ eq? [ usage [ word? ] filter ] [ compiled-usage keys ] if [ queue-compile ] each ; -: ripple-up? ( word effect -- ? ) - #! If the word has previously been compiled and had a - #! different stack effect, we have to recompile any callers. - swap "compiled-effect" word-prop [ = not ] keep and ; +: ripple-up? ( word status -- ? ) + swap "compiled-status" word-prop [ = not ] keep and ; -: save-effect ( word effect -- ) +: save-compiled-status ( word status -- ) [ dupd ripple-up? [ ripple-up ] [ drop ] if ] - [ "compiled-effect" set-word-prop ] + [ "compiled-status" set-word-prop ] 2bi ; : start ( word -- ) @@ -49,18 +50,18 @@ SYMBOL: +failed+ H{ } clone generic-dependencies set f swap compiler-error ; -: fail ( word error -- ) +: fail ( word error -- * ) [ swap compiler-error ] [ drop [ compiled-unxref ] [ f swap compiled get set-at ] - [ +failed+ save-effect ] + [ +unoptimized+ save-compiled-status ] tri ] 2bi return ; -: frontend ( word -- effect nodes ) +: frontend ( word -- nodes ) [ build-tree-from-word ] [ fail ] recover optimize-tree ; ! Only switch this off for debugging. @@ -84,8 +85,8 @@ t compile-dependencies? set-global save-asm ] each ; -: finish ( effect word -- ) - [ swap save-effect ] +: finish ( word -- ) + [ +optimized+ save-compiled-status ] [ compiled-unxref ] [ dup crossref? @@ -112,6 +113,9 @@ t compile-dependencies? set-global : decompile ( word -- ) f 2array 1array modify-code-heap ; +: compile-call ( quot -- ) + [ dup infer define-temp ] with-compilation-unit execute ; + : optimized-recompile-hook ( words -- alist ) [ compile-queue set diff --git a/basis/compiler/tests/optimizer.factor b/basis/compiler/tests/optimizer.factor index cfeb5d01ac..b5cb0ddbdb 100644 --- a/basis/compiler/tests/optimizer.factor +++ b/basis/compiler/tests/optimizer.factor @@ -303,7 +303,7 @@ HINTS: recursive-inline-hang-3 array ; : member-test ( obj -- ? ) { + - * / /i } member? ; \ member-test must-infer -[ ] [ \ member-test build-tree-from-word optimize-tree 2drop ] unit-test +[ ] [ \ member-test build-tree-from-word optimize-tree drop ] unit-test [ t ] [ \ + member-test ] unit-test [ f ] [ \ append member-test ] unit-test diff --git a/basis/compiler/tree/builder/builder-tests.factor b/basis/compiler/tree/builder/builder-tests.factor index d758e2a34d..4982a3986c 100755 --- a/basis/compiler/tree/builder/builder-tests.factor +++ b/basis/compiler/tree/builder/builder-tests.factor @@ -8,4 +8,4 @@ compiler.tree ; : inline-recursive ( -- ) inline-recursive ; inline recursive -[ t ] [ \ inline-recursive build-tree-from-word [ #recursive? ] any? nip ] unit-test +[ t ] [ \ inline-recursive build-tree-from-word [ #recursive? ] any? ] unit-test diff --git a/basis/compiler/tree/builder/builder.factor b/basis/compiler/tree/builder/builder.factor index b715223445..4cb7650b1d 100644 --- a/basis/compiler/tree/builder/builder.factor +++ b/basis/compiler/tree/builder/builder.factor @@ -12,18 +12,18 @@ IN: compiler.tree.builder : with-tree-builder ( quot -- nodes ) '[ V{ } clone stack-visitor set @ ] - with-infer ; inline + with-infer nip ; inline : build-tree ( quot -- nodes ) #! Not safe to call from inference transforms. - [ f initial-recursive-state infer-quot ] with-tree-builder nip ; + [ f initial-recursive-state infer-quot ] with-tree-builder ; : build-tree-with ( in-stack quot -- nodes out-stack ) #! Not safe to call from inference transforms. [ [ >vector \ meta-d set ] [ f initial-recursive-state infer-quot ] bi* - ] with-tree-builder nip + ] with-tree-builder unclip-last in-d>> ; : build-sub-tree ( #call quot -- nodes ) @@ -45,7 +45,7 @@ IN: compiler.tree.builder : check-no-compile ( word -- ) dup "no-compile" word-prop [ cannot-infer-effect ] [ drop ] if ; -: build-tree-from-word ( word -- effect nodes ) +: build-tree-from-word ( word -- nodes ) [ [ { diff --git a/basis/compiler/tree/debugger/debugger.factor b/basis/compiler/tree/debugger/debugger.factor index 9f2cc0536e..188dcdb935 100644 --- a/basis/compiler/tree/debugger/debugger.factor +++ b/basis/compiler/tree/debugger/debugger.factor @@ -144,7 +144,7 @@ SYMBOL: node-count : make-report ( word/quot -- assoc ) [ - dup word? [ build-tree-from-word nip ] [ build-tree ] if + dup word? [ build-tree-from-word ] [ build-tree ] if optimize-tree H{ } clone words-called set From b8ed7d20de7b33c20d8308db151355f4ae5519fd Mon Sep 17 00:00:00 2001 From: "U-SLAVA-DFB8FF805\\Slava" Date: Wed, 28 Jan 2009 02:46:29 -0600 Subject: [PATCH 61/85] Update Windows-specific code for stricter stack checking --- basis/ui/windows/windows.factor | 14 +++++++------- basis/windows/winsock/winsock.factor | 5 ++--- 2 files changed, 9 insertions(+), 10 deletions(-) mode change 100644 => 100755 basis/windows/winsock/winsock.factor diff --git a/basis/ui/windows/windows.factor b/basis/ui/windows/windows.factor index c22fcb6cbe..9df694ee37 100755 --- a/basis/ui/windows/windows.factor +++ b/basis/ui/windows/windows.factor @@ -104,7 +104,7 @@ SYMBOLS: msg-obj class-name-ptr mouse-captured ; [ lo-word ] keep hi-word 2array swap window (>>window-loc) ; -: wm-keydown-codes ( -- key ) +CONSTANT: wm-keydown-codes H{ { 8 "BACKSPACE" } { 9 "TAB" } @@ -132,7 +132,7 @@ SYMBOLS: msg-obj class-name-ptr mouse-captured ; { 121 "F10" } { 122 "F11" } { 123 "F12" } - } ; + } : key-state-down? ( key -- ? ) GetKeyState 16 bit? ; @@ -155,22 +155,22 @@ SYMBOLS: msg-obj class-name-ptr mouse-captured ; alt? [ A+ , ] when ] { } make [ empty? not ] keep f ? ; -: exclude-keys-wm-keydown +CONSTANT: exclude-keys-wm-keydown H{ { 16 "SHIFT" } { 17 "CTRL" } { 18 "ALT" } { 20 "CAPS-LOCK" } - } ; + } -: exclude-keys-wm-char - ! Values are ignored +! Values are ignored +CONSTANT: exclude-keys-wm-char H{ { 8 "BACKSPACE" } { 9 "TAB" } { 13 "RET" } { 27 "ESC" } - } ; + } : exclude-key-wm-keydown? ( n -- ? ) exclude-keys-wm-keydown key? ; diff --git a/basis/windows/winsock/winsock.factor b/basis/windows/winsock/winsock.factor old mode 100644 new mode 100755 index 27069ed743..06df74cd4c --- a/basis/windows/winsock/winsock.factor +++ b/basis/windows/winsock/winsock.factor @@ -257,12 +257,11 @@ TYPEDEF: WSANAMESPACE_INFOW WSANAMESPACE_INFO TYPEDEF: WSANAMESPACE_INFO* PWSANAMESPACE_INFO TYPEDEF: WSANAMESPACE_INFO* LPWSANAMESPACE_INFO -: FD_MAX_EVENTS 10 ; +CONSTANT: FD_MAX_EVENTS 10 C-STRUCT: WSANETWORKEVENTS { "long" "lNetworkEvents" } - ! { { "int" "FD_MAX_EVENTS" } "iErrorCode" } ; - { { "int" 10 } "iErrorCode" } ; + { { "int" FD_MAX_EVENTS } "iErrorCode" } ; TYPEDEF: WSANETWORKEVENTS* PWSANETWORKEVENTS TYPEDEF: WSANETWORKEVENTS* LPWSANETWORKEVENTS From e8361b99806c781e7c966e6e7fb7dafb272316dc Mon Sep 17 00:00:00 2001 From: slava Date: Tue, 24 Feb 2009 01:06:50 -0600 Subject: [PATCH 62/85] Updating X11 UI backend for stricter stack effect checking --- basis/ui/x11/x11.factor | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/basis/ui/x11/x11.factor b/basis/ui/x11/x11.factor index 34cff42777..d0d7eeb234 100755 --- a/basis/ui/x11/x11.factor +++ b/basis/ui/x11/x11.factor @@ -29,14 +29,14 @@ M: world configure-event ! In case dimensions didn't change relayout-1 ; -: modifiers +CONSTANT: modifiers { { S+ HEX: 1 } { C+ HEX: 4 } { A+ HEX: 8 } - } ; - -: key-codes + } + +CONSTANT: key-codes H{ { HEX: FF08 "BACKSPACE" } { HEX: FF09 "TAB" } @@ -62,7 +62,7 @@ M: world configure-event { HEX: FFC4 "F7" } { HEX: FFC5 "F8" } { HEX: FFC6 "F9" } - } ; + } : key-code ( keysym -- keycode action? ) dup key-codes at [ t ] [ 1string f ] ?if ; From 442652625285b0a4e865b2be839dfebb7efce7ea Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 25 Feb 2009 23:30:30 -0600 Subject: [PATCH 63/85] Fixing some things I broke --- basis/checksums/openssl/openssl-docs.factor | 4 +++- basis/memoize/memoize-tests.factor | 2 +- basis/tools/profiler/profiler-tests.factor | 2 +- basis/ui/gadgets/frames/frames-docs.factor | 20 ++++++++++---------- basis/ui/x11/x11.factor | 6 +++--- basis/xml/entities/entities-docs.factor | 3 ++- core/kernel/kernel-docs.factor | 1 + extra/game-input/dinput/dinput.factor | 4 ++-- 8 files changed, 23 insertions(+), 19 deletions(-) diff --git a/basis/checksums/openssl/openssl-docs.factor b/basis/checksums/openssl/openssl-docs.factor index 750e05f3c8..234e032406 100644 --- a/basis/checksums/openssl/openssl-docs.factor +++ b/basis/checksums/openssl/openssl-docs.factor @@ -1,5 +1,5 @@ IN: checksums.openssl -USING: help.syntax help.markup ; +USING: checksums help.syntax help.markup ; HELP: openssl-checksum { $class-description "The class of checksum algorithms implemented by OpenSSL. The exact set of algorithms supported depends on how the OpenSSL library was compiled; " { $snippet "md5" } " and " { $snippet "sha1" } " should be universally available." } ; @@ -9,9 +9,11 @@ HELP: { $description "Creates a new OpenSSL checksum object." } ; HELP: openssl-md5 +{ $values { "value" checksum } } { $description "The OpenSSL MD5 message digest implementation." } ; HELP: openssl-sha1 +{ $values { "value" checksum } } { $description "The OpenSSL SHA1 message digest implementation." } ; HELP: unknown-digest diff --git a/basis/memoize/memoize-tests.factor b/basis/memoize/memoize-tests.factor index 03549d9b80..168a0061e3 100644 --- a/basis/memoize/memoize-tests.factor +++ b/basis/memoize/memoize-tests.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. USING: math kernel memoize tools.test parser generalizations -prettyprint io.streams.string sequences eval ; +prettyprint io.streams.string sequences eval namespaces ; IN: memoize.tests MEMO: fib ( m -- n ) diff --git a/basis/tools/profiler/profiler-tests.factor b/basis/tools/profiler/profiler-tests.factor index 5bf62ef156..3924cc7b83 100644 --- a/basis/tools/profiler/profiler-tests.factor +++ b/basis/tools/profiler/profiler-tests.factor @@ -1,6 +1,6 @@ IN: tools.profiler.tests USING: accessors tools.profiler tools.test kernel memory math -threads alien tools.profiler.private sequences compiler +threads alien tools.profiler.private sequences compiler compiler.units words ; [ t ] [ diff --git a/basis/ui/gadgets/frames/frames-docs.factor b/basis/ui/gadgets/frames/frames-docs.factor index 36c7feed97..9b7bafd914 100644 --- a/basis/ui/gadgets/frames/frames-docs.factor +++ b/basis/ui/gadgets/frames/frames-docs.factor @@ -1,4 +1,4 @@ -USING: help.syntax help.markup ui.gadgets kernel arrays +USING: help.syntax help.markup ui.gadgets kernel arrays math help sequences quotations classes.tuple ui.gadgets.grids ; IN: ui.gadgets.frames @@ -22,15 +22,15 @@ ARTICLE: "ui-frame-layout" "Frame layouts" drop { $description "Symbolic constant for a common input to " { $link grid-add } "." } print-element ; -HELP: @center $ui-frame-constant ; -HELP: @left $ui-frame-constant ; -HELP: @right $ui-frame-constant ; -HELP: @top $ui-frame-constant ; -HELP: @bottom $ui-frame-constant ; -HELP: @top-left $ui-frame-constant ; -HELP: @top-right $ui-frame-constant ; -HELP: @bottom-left $ui-frame-constant ; -HELP: @bottom-right $ui-frame-constant ; +{ @center @left @right @top @bottom @top-left @top-right @bottom-left @bottom-right } +[ + [ + { + { $values { "i" integer } { "j" integer } } + { $ui-frame-constant } + } + ] dip set-word-help +] each HELP: frame { $class-description "A frame is a gadget which lays out its children in a 3x3 grid. If the frame is enlarged past its preferred size, the center gadget fills up available room." diff --git a/basis/ui/x11/x11.factor b/basis/ui/x11/x11.factor index d0d7eeb234..2a622a6985 100755 --- a/basis/ui/x11/x11.factor +++ b/basis/ui/x11/x11.factor @@ -5,7 +5,7 @@ ui.gestures ui.backend ui.clipboards ui.gadgets.worlds ui.render ui.event-loop assocs kernel math namespaces opengl sequences strings x11.xlib x11.events x11.xim x11.glx x11.clipboard x11.constants x11.windows io.encodings.string io.encodings.ascii -io.encodings.utf8 combinators command-line +io.encodings.utf8 combinators combinators.short-circuit command-line math.vectors classes.tuple opengl.gl threads math.geometry.rect environment ascii ; IN: ui.x11 @@ -73,9 +73,9 @@ CONSTANT: key-codes : valid-input? ( string gesture -- ? ) over empty? [ 2drop f ] [ mods>> { f { S+ } } member? [ - [ [ 127 = not ] [ CHAR: \s >= ] bi and ] all? + [ { [ 127 = not ] [ CHAR: \s >= ] } 1&& ] all? ] [ - [ [ 127 = not ] [ CHAR: \s >= ] [ alpha? not ] tri and and ] all? + [ { [ 127 = not ] [ CHAR: \s >= ] [ alpha? not ] } 1&& ] all? ] if ] if ; diff --git a/basis/xml/entities/entities-docs.factor b/basis/xml/entities/entities-docs.factor index 2fccb500a4..158b83d9a8 100644 --- a/basis/xml/entities/entities-docs.factor +++ b/basis/xml/entities/entities-docs.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2005, 2009 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. -USING: help.markup help.syntax ; +USING: help.markup help.syntax assocs ; IN: xml.entities ABOUT: "xml.entities" @@ -12,6 +12,7 @@ ARTICLE: "xml.entities" "XML entities" "For entities used in HTML/XHTML, see " { $vocab-link "xml.entities.html" } ; HELP: entities +{ $values { "value" assoc } } { $description "A hash table from default XML entity names (like " { $snippet "&" } " and " { $snippet "<" } ") to the characters they represent. This is automatically included when parsing any XML document." } { $see-also with-entities } ; diff --git a/core/kernel/kernel-docs.factor b/core/kernel/kernel-docs.factor index b8191004db..342376fb22 100644 --- a/core/kernel/kernel-docs.factor +++ b/core/kernel/kernel-docs.factor @@ -57,6 +57,7 @@ HELP: clear { $description "Clears the data stack." } ; HELP: build +{ $values { "n" integer } } { $description "The current build number. Factor increments this number whenever a new boot image is created." } ; HELP: hashcode* diff --git a/extra/game-input/dinput/dinput.factor b/extra/game-input/dinput/dinput.factor index 328e4ff013..d13fca28cb 100755 --- a/extra/game-input/dinput/dinput.factor +++ b/extra/game-input/dinput/dinput.factor @@ -235,11 +235,11 @@ M: dinput-game-input-backend instance-id succeeded-quot call ] failed-quot if ; inline -: pov-values +CONSTANT: pov-values { pov-up pov-up-right pov-right pov-down-right pov-down pov-down-left pov-left pov-up-left - } ; inline + } : >axis ( long -- float ) 32767 - 32767.0 /f ; From efede1957148aa229a79029b5ce05f38cda547b4 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 26 Feb 2009 01:25:13 -0600 Subject: [PATCH 64/85] Make some errors better in the stack checker --- basis/stack-checker/backend/backend.factor | 10 +++--- basis/stack-checker/errors/errors.factor | 34 +++++++++++++++++-- .../errors/prettyprint/prettyprint.factor | 4 +-- .../known-words/known-words.factor | 2 +- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/basis/stack-checker/backend/backend.factor b/basis/stack-checker/backend/backend.factor index 3c298bdfed..0596f3d0bd 100755 --- a/basis/stack-checker/backend/backend.factor +++ b/basis/stack-checker/backend/backend.factor @@ -44,11 +44,11 @@ IN: stack-checker.backend : pop-r ( -- obj ) meta-r dup empty? - [ too-many-r> inference-error ] [ pop ] if ; + [ too-many-r> ] [ pop ] if ; : consume-r ( n -- seq ) meta-r 2dup length > - [ too-many-r> inference-error ] when + [ too-many-r> ] when [ swap tail* ] [ shorten-by ] 2bi ; : output-r ( seq -- ) meta-r push-all ; @@ -81,7 +81,7 @@ M: object apply-object push-literal ; terminated? on meta-d clone meta-r clone #terminate, ; : check->r ( -- ) - meta-r empty? [ \ too-many->r inference-error ] unless ; + meta-r empty? [ too-many->r ] unless ; : infer-quot-here ( quot -- ) meta-r [ @@ -104,7 +104,7 @@ M: object apply-object push-literal ; : infer-literal-quot ( literal -- ) dup recursive-quotation? [ - value>> recursive-quotation-error inference-error + value>> recursive-quotation-error ] [ dup value>> callable? [ [ value>> ] @@ -139,7 +139,7 @@ M: object apply-object push-literal ; meta-d clone #return, ; : required-stack-effect ( word -- effect ) - dup stack-effect [ ] [ missing-effect inference-error ] ?if ; + dup stack-effect [ ] [ missing-effect ] ?if ; : check-effect ( word effect -- ) over required-stack-effect 2dup effect<= diff --git a/basis/stack-checker/errors/errors.factor b/basis/stack-checker/errors/errors.factor index 58944e7bc4..6a9a7cb8af 100644 --- a/basis/stack-checker/errors/errors.factor +++ b/basis/stack-checker/errors/errors.factor @@ -5,6 +5,9 @@ assocs accessors namespaces compiler.errors stack-checker.values stack-checker.recursive-state ; IN: stack-checker.errors +: pretty-word ( word -- word' ) + dup method-body? [ "method-generic" word-prop ] when ; + TUPLE: inference-error error type word ; M: inference-error compiler-error-type type>> ; @@ -20,9 +23,11 @@ M: inference-error compiler-error-type type>> ; : inference-warning ( ... class -- * ) +warning+ (inference-error) ; inline -TUPLE: literal-expected ; +TUPLE: literal-expected what ; -M: object (literal) \ literal-expected inference-warning ; +: literal-expected ( what -- * ) \ literal-expected inference-warning ; + +M: object (literal) "literal value" literal-expected ; TUPLE: unbalanced-branches-error branches quots ; @@ -31,10 +36,17 @@ TUPLE: unbalanced-branches-error branches quots ; TUPLE: too-many->r ; +: too-many->r ( -- * ) \ too-many->r inference-error ; + TUPLE: too-many-r> ; +: too-many-r> ( -- * ) \ too-many-r> inference-error ; + TUPLE: missing-effect word ; +: missing-effect ( word -- * ) + pretty-word \ missing-effect inference-error ; + TUPLE: effect-error word inferred declared ; : effect-error ( word inferred declared -- * ) @@ -42,12 +54,30 @@ TUPLE: effect-error word inferred declared ; TUPLE: recursive-quotation-error quot ; +: recursive-quotation-error ( word -- * ) + \ recursive-quotation-error inference-error ; + TUPLE: undeclared-recursion-error word ; +: undeclared-recursion-error ( word -- * ) + \ undeclared-recursion-error inference-error ; + TUPLE: diverging-recursion-error word ; +: diverging-recursion-error ( word -- * ) + \ diverging-recursion-error inference-error ; + TUPLE: unbalanced-recursion-error word height ; +: unbalanced-recursion-error ( word height -- * ) + \ unbalanced-recursion-error inference-error ; + TUPLE: inconsistent-recursive-call-error word ; +: inconsistent-recursive-call-error ( word -- * ) + \ inconsistent-recursive-call-error inference-error ; + TUPLE: unknown-primitive-error ; + +: unknown-primitive-error ( -- * ) + \ unknown-primitive-error inference-error ; diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor index 21c6d64402..9dc82339b5 100644 --- a/basis/stack-checker/errors/prettyprint/prettyprint.factor +++ b/basis/stack-checker/errors/prettyprint/prettyprint.factor @@ -9,8 +9,8 @@ M: inference-error error-help error>> error-help ; M: inference-error error. [ word>> [ "In word: " write . ] when* ] [ error>> error. ] bi ; -M: literal-expected summary - drop "Literal value expected" ; +M: literal-expected error. + "Got a computed value where a " write what>> write " was expected" print ; M: unbalanced-branches-error error. "Unbalanced branches:" print diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 4ac9d802ed..0c20c41d99 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -87,7 +87,7 @@ M: composed infer-call* terminated? get [ 1 infer-r> infer-call ] unless ; M: object infer-call* - \ literal-expected inference-warning ; + "literal quotation" literal-expected ; : infer-nslip ( n -- ) [ infer->r infer-call ] [ infer-r> ] bi ; From 1efbd686a1ce15b65bb12f720338f8d639d87009 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 26 Feb 2009 01:37:05 -0600 Subject: [PATCH 65/85] Remove two useless files: grovel.c and factor.el (superceded by fu/fu.el) --- build-support/grovel.c | 179 -------- misc/factor.el | 917 ----------------------------------------- 2 files changed, 1096 deletions(-) delete mode 100644 build-support/grovel.c delete mode 100644 misc/factor.el diff --git a/build-support/grovel.c b/build-support/grovel.c deleted file mode 100644 index db16aa9bca..0000000000 --- a/build-support/grovel.c +++ /dev/null @@ -1,179 +0,0 @@ -#include -#include - -#if defined(__FreeBSD__) - #define BSD - #define FREEBSD - #define UNIX -#endif - -#if defined(__NetBSD__) - #define BSD - #define NETBSD - #define UNIX -#endif - -#if defined(__OpenBSD__) - #define BSD - #define OPENBSD - #define UNIX -#endif - -#if defined(__APPLE__) - #define BSD - #define MACOSX - #define UNIX -#endif - -#if defined(linux) - #define LINUX - #define UNIX -#endif - -#if defined(__amd64__) || defined(__x86_64__) - #define BIT64 -#else - #define BIT32 -#endif - -#if defined(UNIX) - #include - #include - #include - #include - #include - #include - #include - #include -#endif - -#define BL printf(" "); -#define QUOT printf("\""); -#define NL printf("\n"); -#define LB printf("{"); BL -#define RB BL printf("}"); -#define SEMI printf(";"); -#define grovel(t) printf("TYPEDEF: "); printf("%d", sizeof(t)); BL printf(#t); NL -#define grovel2impl(t,n) BL BL BL BL LB QUOT printf(#t); QUOT BL QUOT printf((n)); QUOT RB -#define grovel2(t,n) grovel2impl(t,n) NL -#define grovel2end(t,n) grovel2impl(t,n) BL SEMI NL -#define header(os) printf("vvv %s vvv", (os)); NL -#define footer(os) printf("^^^ %s ^^^", (os)); NL -#define header2(os,struct) printf("vvv %s %s vvv", (os), (struct)); NL -#define footer2(os,struct) printf("^^^ %s %s ^^^", (os), (struct)); NL -#define struct(n) printf("C-STRUCT: %s\n", (n)); -#define constant(n) printf("#define "); printf(#n); printf(" %d (HEX: %04x)", (n), (n)); NL - -void openbsd_types() -{ - header2("openbsd", "types"); - grovel(dev_t); - grovel(gid_t); - grovel(ino_t); - grovel(int32_t); - grovel(int64_t); - grovel(mode_t); - grovel(nlink_t); - grovel(off_t); - grovel(struct timespec); - grovel(uid_t); - footer2("openbsd", "types"); -} - -void openbsd_stat() -{ - header2("openbsd", "stat"); - struct("stat"); - grovel2(dev_t, "st_dev"); - grovel2(ino_t, "st_ino"); - grovel2(mode_t, "st_mode"); - grovel2(nlink_t, "st_nlink"); - grovel2(uid_t, "st_uid"); - grovel2(gid_t, "st_gid"); - grovel2(dev_t, "st_rdev"); - grovel2(int32_t, "st_lspare0"); - grovel2(struct timespec, "st_atim"); - grovel2(struct timespec, "st_mtim"); - grovel2(struct timespec, "st_ctim"); - grovel2(off_t, "st_size"); - grovel2(int64_t, "st_blocks"); - grovel2(u_int32_t, "st_blksize"); - grovel2(u_int32_t, "st_flags"); - grovel2(u_int32_t, "st_gen"); - grovel2(int32_t, "st_lspare1"); - grovel2(struct timespec, "st_birthtimespec"); - grovel2(int64_t, "st_qspare1"); - grovel2end(int64_t, "st_qspare2"); - footer2("openbsd", "stat"); -} - -void unix_types() -{ - grovel(dev_t); - grovel(gid_t); - grovel(ino_t); - grovel(int32_t); - grovel(int64_t); - grovel(mode_t); - grovel(nlink_t); - grovel(off_t); - grovel(struct timespec); - grovel(struct stat); - grovel(time_t); - grovel(uid_t); -} - -void unix_constants() -{ - constant(O_RDONLY); - constant(O_WRONLY); - constant(O_RDWR); - constant(O_APPEND); - constant(O_CREAT); - constant(O_TRUNC); - constant(O_EXCL); - constant(FD_SETSIZE); - constant(SOL_SOCKET); - constant(SO_REUSEADDR); - constant(SO_OOBINLINE); - constant(SO_SNDTIMEO); - constant(SO_RCVTIMEO); - constant(F_SETFL); - constant(O_NONBLOCK); - constant(EINTR); - constant(EAGAIN); - constant(EINPROGRESS); - constant(PROT_READ); - constant(PROT_WRITE); - constant(MAP_FILE); - constant(MAP_SHARED); - constant(PATH_MAX); - grovel(pid_t); - -} - -int main() { -#ifdef FREEBSD - grovel(blkcnt_t); - grovel(blksize_t); - grovel(fflags_t); -#endif - -#ifdef OPENBSD - openbsd_stat(); - openbsd_types(); -#endif - grovel(blkcnt_t); - grovel(blksize_t); - //grovel(fflags_t); - grovel(ssize_t); - - grovel(size_t); - grovel(struct kevent); -#ifdef UNIX - unix_types(); - unix_constants(); -#endif - - return 0; -} diff --git a/misc/factor.el b/misc/factor.el deleted file mode 100644 index 5f56072c1d..0000000000 --- a/misc/factor.el +++ /dev/null @@ -1,917 +0,0 @@ -;;; factor.el --- Interacting with Factor within emacs -;; -;; Authors: Eduardo Cavazos -;; Jose A Ortega Ruiz -;; Keywords: languages - -;;; Commentary: - -;;; Quick setup: - -;; Add these lines to your .emacs file: -;; -;; (load-file "/scratch/repos/Factor/misc/factor.el") -;; (setq factor-binary "/scratch/repos/Factor/factor") -;; (setq factor-image "/scratch/repos/Factor/factor.image") -;; -;; Of course, you'll have to edit the directory paths for your system -;; accordingly. Alternatively, put this file in your load-path and use -;; -;; (require 'factor) -;; -;; instead of load-file. -;; -;; That's all you have to do to "install" factor.el on your -;; system. Whenever you edit a factor file, Emacs will know to switch -;; to Factor mode. -;; -;; For further customization options, -;; M-x customize-group RET factor -;; -;; To start a Factor listener inside Emacs, -;; M-x run-factor - -;;; Requirements: - -(require 'font-lock) -(require 'comint) -(require 'view) -(require 'ring) - -;;; Customization: - -(defgroup factor nil - "Factor mode" - :group 'languages) - -(defcustom factor-default-indent-width 4 - "Default indentantion width for factor-mode. - -This value will be used for the local variable -`factor-indent-width' in new factor buffers. For existing code, -we first check if `factor-indent-width' is set explicitly in a -local variable section or line (e.g. '! -*- factor-indent-witdth: 2 -*-'). -If that's not the case, `factor-mode' tries to infer its correct -value from the existing code in the buffer." - :type 'integer - :group 'factor) - -(defcustom factor-binary "~/factor/factor" - "Full path to the factor executable to use when starting a listener." - :type '(file :must-match t) - :group 'factor) - -(defcustom factor-image "~/factor/factor.image" - "Full path to the factor image to use when starting a listener." - :type '(file :must-match t) - :group 'factor) - -(defcustom factor-use-doc-window t - "When on, use a separate window to display help information. -Disable to see that information in the factor-listener comint -window." - :type 'boolean - :group 'factor) - -(defcustom factor-listener-use-other-window t - "Use a window other than the current buffer's when switching to -the factor-listener buffer." - :type 'boolean - :group 'factor) - -(defcustom factor-listener-window-allow-split t - "Allow window splitting when switching to the factor-listener -buffer." - :type 'boolean - :group 'factor) - -(defcustom factor-help-always-ask t - "When enabled, always ask for confirmation in help prompts." - :type 'boolean - :group 'factor) - -(defcustom factor-help-use-minibuffer t - "When enabled, use the minibuffer for short help messages." - :type 'boolean - :group 'factor) - -(defcustom factor-display-compilation-output t - "Display the REPL buffer before compiling files." - :type 'boolean - :group 'factor) - -(defcustom factor-mode-hook nil - "Hook run when entering Factor mode." - :type 'hook - :group 'factor) - -(defcustom factor-help-mode-hook nil - "Hook run by `factor-help-mode'." - :type 'hook - :group 'factor) - -(defgroup factor-faces nil - "Faces used in Factor mode" - :group 'factor - :group 'faces) - -(defface factor-font-lock-parsing-word (face-default-spec font-lock-keyword-face) - "Face for parsing words." - :group 'factor-faces) - -(defface factor-font-lock-declaration (face-default-spec font-lock-keyword-face) - "Face for declaration words (inline, parsing ...)." - :group 'factor-faces) - -(defface factor-font-lock-comment (face-default-spec font-lock-comment-face) - "Face for comments." - :group 'factor-faces) - -(defface factor-font-lock-string (face-default-spec font-lock-string-face) - "Face for strings." - :group 'factor-faces) - -(defface factor-font-lock-stack-effect (face-default-spec font-lock-comment-face) - "Face for stack effect specifications." - :group 'factor-faces) - -(defface factor-font-lock-word-definition (face-default-spec font-lock-function-name-face) - "Face for word, generic or method being defined." - :group 'factor-faces) - -(defface factor-font-lock-symbol-definition (face-default-spec font-lock-variable-name-face) - "Face for name of symbol being defined." - :group 'factor-faces) - -(defface factor-font-lock-vocabulary-name (face-default-spec font-lock-constant-face) - "Face for names of vocabularies in USE or USING." - :group 'factor-faces) - -(defface factor-font-lock-type-definition (face-default-spec font-lock-type-face) - "Face for type (tuple) names." - :group 'factor-faces) - -(defface factor-font-lock-constructor (face-default-spec font-lock-type-face) - "Face for constructors ()." - :group 'factor-faces) - -(defface factor-font-lock-setter-word (face-default-spec font-lock-function-name-face) - "Face for setter words (>>foo)." - :group 'factor-faces) - -(defface factor-font-lock-parsing-word (face-default-spec font-lock-keyword-face) - "Face for parsing words." - :group 'factor-faces) - -(defface factor-font-lock-help-mode-headlines '((t (:bold t :weight bold))) - "Face for headlines in help buffers." - :group 'factor-faces) - - -;;; Compatibility -(when (not (fboundp 'ring-member)) - (defun ring-member (ring item) - (catch 'found - (dotimes (ind (ring-length ring) nil) - (when (equal item (ring-ref ring ind)) - (throw 'found ind)))))) - - -;;; Factor mode font lock: - -(defconst factor--parsing-words - '("{" "}" "^:" "^::" ";" "<<" ">" - "BIN:" "BV{" "B{" "C:" "C-STRUCT:" "C-UNION:" "CHAR:" "CS{" "C{" - "DEFER:" "ERROR:" "EXCLUDE:" "FORGET:" - "GENERIC#" "GENERIC:" "HEX:" "HOOK:" "H{" - "IN:" "INSTANCE:" "INTERSECTION:" - "M:" "MACRO:" "MACRO::" "MAIN:" "MATH:" "METHOD:" "MIXIN:" - "OCT:" "POSTPONE:" "PREDICATE:" "PRIMITIVE:" "PRIVATE>" "PROVIDE:" - "REQUIRE:" "REQUIRES:" "SINGLETON:" "SLOT:" "SYMBOL:" "SYMBOLS:" - "TUPLE:" "T{" "t\\??" "TYPEDEF:" - "UNION:" "USE:" "USING:" "V{" "VARS:" "W{")) - -(defconst factor--regex-parsing-words-ext - (regexp-opt '("B" "call-next-method" "delimiter" "f" "initial:" "read-only") - 'words)) - -(defconst factor--declaration-words - '("flushable" "foldable" "inline" "parsing" "recursive")) - -(defconst factor--regex-declaration-words - (regexp-opt factor--declaration-words 'words)) - -(defsubst factor--regex-second-word (prefixes) - (format "^%s +\\([^ \r\n]+\\)" (regexp-opt prefixes t))) - -(defconst factor--regex-method-definition - "^M: +\\([^ ]+\\) +\\([^ ]+\\)") - -(defconst factor--regex-word-definition - (factor--regex-second-word '(":" "::" "GENERIC:"))) - -(defconst factor--regex-type-definition - (factor--regex-second-word '("TUPLE:" "SINGLETON:"))) - -(defconst factor--regex-parent-type "^TUPLE: +[^ ]+ +< +\\([^ ]+\\)") - -(defconst factor--regex-constructor "<[^ >]+>") - -(defconst factor--regex-setter "\\W>>[^ ]+\\b") - -(defconst factor--regex-symbol-definition - (factor--regex-second-word '("SYMBOL:" "VAR:"))) - -(defconst factor--regex-stack-effect " ( .* )") - -(defconst factor--regex-using-lines "^USING: +\\(\\([^;]\\|[\n\r\f]\\)*\\);") - -(defconst factor--regex-use-line "^USE: +\\(.*\\)$") - -(defconst factor--font-lock-keywords - `((,factor--regex-stack-effect . 'factor-font-lock-stack-effect) - ("\\(P\\|SBUF\\)\"" 1 'factor-font-lock-parsing-word) - ,@(mapcar #'(lambda (w) (cons (concat "\\(^\\| \\)\\(" w "\\)\\($\\| \\)") - '(2 'factor-font-lock-parsing-word))) - factor--parsing-words) - (,factor--regex-parsing-words-ext . 'factor-font-lock-parsing-word) - (,factor--regex-declaration-words 1 'factor-font-lock-declaration) - (,factor--regex-word-definition 2 'factor-font-lock-word-definition) - (,factor--regex-type-definition 2 'factor-font-lock-type-definition) - (,factor--regex-method-definition (1 'factor-font-lock-type-definition) - (2 'factor-font-lock-word-definition)) - (,factor--regex-parent-type 1 'factor-font-lock-type-definition) - (,factor--regex-constructor . 'factor-font-lock-constructor) - (,factor--regex-setter . 'factor-font-lock-setter-word) - (,factor--regex-symbol-definition 2 'factor-font-lock-symbol-definition) - (,factor--regex-use-line 1 'factor-font-lock-vocabulary-name)) - "Font lock keywords definition for Factor mode.") - - -;;; Factor mode syntax: - -(defconst factor--regex-definition-starters - (regexp-opt '("VARS" "TUPLE" "MACRO" "MACRO:" "M" ":" ""))) - -(defconst factor--regex-definition-start - (format "^\\(%s:\\) " factor--regex-definition-starters)) - -(defconst factor--regex-definition-end - (format "\\(;\\( +%s\\)*\\)" factor--regex-declaration-words)) - -(defconst factor--font-lock-syntactic-keywords - `(("\\(#!\\)" (1 "<")) - (" \\(!\\)" (1 "<")) - ("^\\(!\\)" (1 "<")) - ("\\(!(\\) .* \\()\\)" (1 "<") (2 ">")))) - -(defvar factor-mode-syntax-table nil - "Syntax table used while in Factor mode.") - -(if factor-mode-syntax-table - () - (let ((i 0)) - (setq factor-mode-syntax-table (make-syntax-table)) - - ;; Default is atom-constituent - (while (< i 256) - (modify-syntax-entry i "_ " factor-mode-syntax-table) - (setq i (1+ i))) - - ;; Word components. - (setq i ?0) - (while (<= i ?9) - (modify-syntax-entry i "w " factor-mode-syntax-table) - (setq i (1+ i))) - (setq i ?A) - (while (<= i ?Z) - (modify-syntax-entry i "w " factor-mode-syntax-table) - (setq i (1+ i))) - (setq i ?a) - (while (<= i ?z) - (modify-syntax-entry i "w " factor-mode-syntax-table) - (setq i (1+ i))) - - ;; Whitespace - (modify-syntax-entry ?\t " " factor-mode-syntax-table) - (modify-syntax-entry ?\f " " factor-mode-syntax-table) - (modify-syntax-entry ?\r " " factor-mode-syntax-table) - (modify-syntax-entry ? " " factor-mode-syntax-table) - - ;; (end of) Comments - (modify-syntax-entry ?\n ">" factor-mode-syntax-table) - - ;; Parenthesis - (modify-syntax-entry ?\[ "(] " factor-mode-syntax-table) - (modify-syntax-entry ?\] ")[ " factor-mode-syntax-table) - (modify-syntax-entry ?{ "(} " factor-mode-syntax-table) - (modify-syntax-entry ?} "){ " factor-mode-syntax-table) - - (modify-syntax-entry ?\( "()" factor-mode-syntax-table) - (modify-syntax-entry ?\) ")(" factor-mode-syntax-table) - - ;; Strings - (modify-syntax-entry ?\" "\"" factor-mode-syntax-table) - (modify-syntax-entry ?\\ "/" factor-mode-syntax-table))) - - -;;; symbol-at-point - -(defun factor--beginning-of-symbol () - "Move point to the beginning of the current symbol." - (while (eq (char-before) ?:) (backward-char)) - (skip-syntax-backward "w_")) - -(defun factor--end-of-symbol () - "Move point to the end of the current symbol." - (skip-syntax-forward "w_") - (while (looking-at ":") (forward-char))) - -(put 'factor-symbol 'end-op 'factor--end-of-symbol) -(put 'factor-symbol 'beginning-op 'factor--beginning-of-symbol) - -(defsubst factor--symbol-at-point () - (let ((s (substring-no-properties (thing-at-point 'factor-symbol)))) - (and (> (length s) 0) s))) - - -;;; Factor mode indentation: - -(make-variable-buffer-local - (defvar factor-indent-width factor-default-indent-width - "Indentation width in factor buffers. A local variable.")) - -(defun factor--guess-indent-width () - "Chooses an indentation value from existing code." - (let ((word-cont "^ +[^ ]") - (iw)) - (save-excursion - (beginning-of-buffer) - (while (not iw) - (if (not (re-search-forward factor--regex-definition-start nil t)) - (setq iw factor-default-indent-width) - (forward-line) - (when (looking-at word-cont) - (setq iw (current-indentation)))))) - iw)) - -(defsubst factor--ppss-brackets-depth () - (nth 0 (syntax-ppss))) - -(defsubst factor--ppss-brackets-start () - (nth 1 (syntax-ppss))) - -(defun factor--ppss-brackets-end () - (save-excursion - (goto-char (factor--ppss-brackets-start)) - (condition-case nil - (progn (forward-sexp) - (1- (point))) - (error -1)))) - -(defsubst factor--indentation-at (pos) - (save-excursion (goto-char pos) (current-indentation))) - -(defsubst factor--at-first-char-p () - (= (- (point) (line-beginning-position)) (current-indentation))) - -(defconst factor--regex-single-liner - (format "^%s" (regexp-opt '("DEFER:" "GENERIC:" "IN:" - "PRIVATE>" " (factor--ppss-brackets-depth) 0) - (let ((op (factor--ppss-brackets-start)) - (cl (factor--ppss-brackets-end)) - (ln (line-number-at-pos))) - (when (> ln (line-number-at-pos op)) - (if (and (> cl 0) (= ln (line-number-at-pos cl))) - (factor--indentation-at op) - (factor--increased-indentation (factor--indentation-at op)))))))) - -(defun factor--indent-definition () - (save-excursion - (beginning-of-line) - (when (factor--at-begin-of-def) 0))) - -(defun factor--indent-setter-line () - (when (factor--at-setter-line) - (save-excursion - (let ((indent (and (factor--at-constructor-line) (current-indentation)))) - (while (not (or indent - (bobp) - (factor--at-begin-of-def) - (factor--at-end-of-def))) - (if (factor--at-constructor-line) - (setq indent (factor--increased-indentation)) - (forward-line -1))) - indent)))) - -(defun factor--indent-continuation () - (save-excursion - (forward-line -1) - (while (and (not (bobp)) (factor--looking-at-emptiness)) - (forward-line -1)) - (if (or (factor--at-end-of-def) (factor--at-setter-line)) - (factor--decreased-indentation) - (if (and (factor--at-begin-of-def) - (not (looking-at factor--regex-using-lines))) - (factor--increased-indentation) - (current-indentation))))) - -(defun factor--calculate-indentation () - "Calculate Factor indentation for line at point." - (or (and (bobp) 0) - (factor--indent-definition) - (factor--indent-in-brackets) - (factor--indent-setter-line) - (factor--indent-continuation) - 0)) - -(defun factor--indent-line () - "Indent current line as Factor code" - (let ((target (factor--calculate-indentation)) - (pos (- (point-max) (point)))) - (if (= target (current-indentation)) - (if (< (current-column) (current-indentation)) - (back-to-indentation)) - (beginning-of-line) - (delete-horizontal-space) - (indent-to target) - (if (> (- (point-max) pos) (point)) - (goto-char (- (point-max) pos)))))) - - -;; Factor mode: -(defvar factor-mode-map (make-sparse-keymap) - "Key map used by Factor mode.") - -(defsubst factor--beginning-of-defun (&optional times) - (re-search-backward factor--regex-begin-of-def nil t times)) - -(defsubst factor--end-of-defun () - (re-search-forward factor--regex-end-of-def nil t)) - -;;;###autoload -(defun factor-mode () - "A mode for editing programs written in the Factor programming language. -\\{factor-mode-map}" - (interactive) - (kill-all-local-variables) - (use-local-map factor-mode-map) - (setq major-mode 'factor-mode) - (setq mode-name "Factor") - ;; Font locking - (set (make-local-variable 'comment-start) "! ") - (set (make-local-variable 'parse-sexp-lookup-properties) t) - (set (make-local-variable 'font-lock-comment-face) 'factor-font-lock-comment) - (set (make-local-variable 'font-lock-string-face) 'factor-font-lock-string) - (set (make-local-variable 'font-lock-defaults) - `(factor--font-lock-keywords - nil nil nil nil - (font-lock-syntactic-keywords . ,factor--font-lock-syntactic-keywords))) - - (set-syntax-table factor-mode-syntax-table) - ;; Defun navigation - (set (make-local-variable 'beginning-of-defun-function) 'factor--beginning-of-defun) - (set (make-local-variable 'end-of-defun-function) 'factor--end-of-defun) - (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil) - ;; Indentation - (set (make-local-variable 'indent-line-function) 'factor--indent-line) - (setq factor-indent-width (factor--guess-indent-width)) - (setq indent-tabs-mode nil) - ;; ElDoc - (set (make-local-variable 'eldoc-documentation-function) 'factor--eldoc) - - (run-hooks 'factor-mode-hook)) - -(add-to-list 'auto-mode-alist '("\\.factor\\'" . factor-mode)) - - -;;; Factor listener mode: - -;;;###autoload -(define-derived-mode factor-listener-mode comint-mode "Factor Listener" - "Major mode for interacting with an inferior Factor listener process. -\\{factor-listener-mode-map}" - (set (make-local-variable 'comint-prompt-regexp) "^( [^)]+ ) ")) - -(defvar factor--listener-buffer nil - "The buffer in which the Factor listener is running.") - -(defun factor--listener-start-process () - "Start an inferior Factor listener process, using -`factor-binary' and `factor-image'." - (setq factor--listener-buffer - (apply 'make-comint "factor" (expand-file-name factor-binary) nil - `("-run=listener" ,(format "-i=%s" (expand-file-name factor-image))))) - (with-current-buffer factor--listener-buffer - (factor-listener-mode))) - -(defun factor--listener-process (&optional start) - (or (and (buffer-live-p factor--listener-buffer) - (get-buffer-process factor--listener-buffer)) - (if (not start) - (error "No running factor listener. Try M-x run-factor.") - (factor--listener-start-process) - (factor--listener-process t)))) - -;;;###autoload -(defalias 'switch-to-factor 'run-factor) -;;;###autoload -(defun run-factor (&optional arg) - "Show the factor-listener buffer, starting the process if needed." - (interactive) - (let ((buf (process-buffer (factor--listener-process t))) - (pop-up-windows factor-listener-window-allow-split)) - (if factor-listener-use-other-window - (pop-to-buffer buf) - (switch-to-buffer buf)))) - -(defun factor-telnet-to-port (port) - (interactive "nPort: ") - (switch-to-buffer - (make-comint-in-buffer "factor-telnet" nil (cons "localhost" port)))) - -(defun factor-telnet () - (interactive) - (factor-telnet-to-port 9000)) - -(defun factor-telnet-factory () - (interactive) - (factor-telnet-to-port 9010)) - - -;;; Factor listener interaction: - -(defun factor--listener-send-cmd (cmd) - (let ((proc (factor--listener-process))) - (when proc - (let* ((out (get-buffer-create "*factor messages*")) - (beg (with-current-buffer out (goto-char (point-max))))) - (comint-redirect-send-command-to-process cmd out proc nil t) - (with-current-buffer factor--listener-buffer - (while (not comint-redirect-completed) (sleep-for 0 1))) - (with-current-buffer out - (split-string (buffer-substring-no-properties beg (point-max)) - "[\"\f\n\r\v]+" t)))))) - -;;;;; Current vocabulary: -(make-variable-buffer-local - (defvar factor--current-vocab nil - "Current vocabulary.")) - -(defconst factor--regexp-current-vocab "^IN: +\\([^ \r\n\f]+\\)") - -(defun factor--current-buffer-vocab () - (save-excursion - (when (or (re-search-backward factor--regexp-current-vocab nil t) - (re-search-forward factor--regexp-current-vocab nil t)) - (setq factor--current-vocab (match-string-no-properties 1))))) - -(defun factor--current-listener-vocab () - (car (factor--listener-send-cmd "USING: parser ; in get ."))) - -(defun factor--set-current-listener-vocab (&optional vocab) - (factor--listener-send-cmd - (format "IN: %s" (or vocab (factor--current-buffer-vocab)))) - t) - -(defmacro factor--with-vocab (vocab &rest body) - (let ((current (make-symbol "current"))) - `(let ((,current (factor--current-listener-vocab))) - (factor--set-current-listener-vocab ,vocab) - (prog1 (condition-case nil (progn . ,body) (error nil)) - (factor--set-current-listener-vocab ,current))))) - -(put 'factor--with-vocab 'lisp-indent-function 1) - -;;;;; Synchronous interaction: - -(defsubst factor--listener-vocab-cmds (cmds &optional vocab) - (factor--with-vocab vocab - (mapcar #'factor--listener-send-cmd cmds))) - -(defsubst factor--listener-vocab-cmd (cmd &optional vocab) - (factor--with-vocab vocab - (factor--listener-send-cmd cmd))) - - -;;;;; Buffer cycling and docs - - -(defconst factor--cycle-endings - '(".factor" "-tests.factor" "-docs.factor")) - -(defconst factor--regex-cycle-endings - (format "\\(.*?\\)\\(%s\\)$" - (regexp-opt factor--cycle-endings))) - -(defconst factor--cycle-endings-ring - (let ((ring (make-ring (length factor--cycle-endings)))) - (dolist (e factor--cycle-endings ring) - (ring-insert ring e)))) - -(defun factor--cycle-next (file) - (let* ((match (string-match factor--regex-cycle-endings file)) - (base (and match (match-string-no-properties 1 file))) - (ending (and match (match-string-no-properties 2 file))) - (idx (and ending (ring-member factor--cycle-endings-ring ending))) - (gfl (lambda (i) (concat base (ring-ref factor--cycle-endings-ring i))))) - (if (not idx) file - (let ((l (length factor--cycle-endings)) (i 1) next) - (while (and (not next) (< i l)) - (when (file-exists-p (funcall gfl (+ idx i))) - (setq next (+ idx i))) - (setq i (1+ i))) - (funcall gfl (or next idx)))))) - -(defun factor-visit-other-file (&optional file) - "Cycle between code, tests and docs factor files." - (interactive) - (find-file (factor--cycle-next (or file (buffer-file-name))))) - - -;;;;; Interface: See - -(defconst factor--regex-error-marker "^Type :help for debugging") -(defconst factor--regex-data-stack "^--- Data stack:") - -(defun factor--prune-ans-strings (ans) - (nreverse - (catch 'done - (let ((res)) - (dolist (a ans res) - (cond ((string-match factor--regex-stack-effect a) - (throw 'done (cons a res))) - ((string-match factor--regex-data-stack a) - (throw 'done res)) - ((string-match factor--regex-error-marker a) - (throw 'done nil)) - (t (push a res)))))))) - -(defun factor--see-ans-to-string (ans) - (let ((s (mapconcat #'identity (factor--prune-ans-strings ans) " ")) - (font-lock-verbose nil)) - (and (> (length s) 0) - (with-temp-buffer - (insert s) - (factor-mode) - (font-lock-fontify-buffer) - (buffer-string))))) - -(defun factor--see-current-word (&optional word) - (let ((word (or word (factor--symbol-at-point)))) - (when word - (let ((answer (factor--listener-send-cmd (format "\\ %s see" word)))) - (and answer (factor--see-ans-to-string answer)))))) - -(defalias 'factor--eldoc 'factor--see-current-word) - -(defun factor-see-current-word (&optional word) - "Echo in the minibuffer information about word at point." - (interactive) - (let* ((proc (factor--listener-process)) - (word (or word (factor--symbol-at-point))) - (msg (factor--see-current-word word))) - (if msg (message "%s" msg) - (if word (message "No help found for '%s'" word) - (message "No word at point"))))) - -;;; to fix: -(defun factor-run-file () - (interactive) - (when (and (buffer-modified-p) - (y-or-n-p (format "Save file %s? " (buffer-file-name)))) - (save-buffer)) - (when factor-display-compilation-output - (factor-display-output-buffer)) - (comint-send-string "*factor*" (format "\"%s\"" (buffer-file-name))) - (comint-send-string "*factor*" " run-file\n")) - -(defun factor-display-output-buffer () - (with-current-buffer "*factor*" - (goto-char (point-max)) - (unless (get-buffer-window (current-buffer) t) - (display-buffer (current-buffer) t)))) - -(defun factor-send-string (str) - (let ((n (length (split-string str "\n")))) - (save-excursion - (set-buffer "*factor*") - (goto-char (point-max)) - (if (> n 1) (newline)) - (insert str) - (comint-send-input)))) - -(defun factor-send-region (start end) - (interactive "r") - (let ((str (buffer-substring start end)) - (n (count-lines start end))) - (save-excursion - (set-buffer "*factor*") - (goto-char (point-max)) - (if (> n 1) (newline)) - (insert str) - (comint-send-input)))) - -(defun factor-send-definition () - (interactive) - (factor-send-region (search-backward ":") - (search-forward ";"))) - -(defun factor-edit () - (interactive) - (comint-send-string "*factor*" "\\ ") - (comint-send-string "*factor*" (thing-at-point 'sexp)) - (comint-send-string "*factor*" " edit\n")) - -(defun factor-clear () - (interactive) - (factor-send-string "clear")) - -(defun factor-comment-line () - (interactive) - (beginning-of-line) - (insert "! ")) - - -;;;; Factor help mode: - -(defvar factor-help-mode-map (make-sparse-keymap) - "Keymap for Factor help mode.") - -(defconst factor--help-headlines - (regexp-opt '("Definition" - "Examples" - "Generic word contract" - "Inputs and outputs" - "Parent topics:" - "See also" - "Syntax" - "Vocabulary" - "Warning" - "Word description") - t)) - -(defconst factor--help-headlines-regexp (format "^%s" factor--help-headlines)) - -(defconst factor--help-font-lock-keywords - `((,factor--help-headlines-regexp . 'factor-font-lock-help-mode-headlines) - ,@factor--font-lock-keywords)) - -(defun factor-help-mode () - "Major mode for displaying Factor help messages. -\\{factor-help-mode-map}" - (interactive) - (kill-all-local-variables) - (use-local-map factor-help-mode-map) - (setq mode-name "Factor Help") - (setq major-mode 'factor-help-mode) - (set (make-local-variable 'font-lock-defaults) - '(factor--help-font-lock-keywords t nil nil nil)) - (set (make-local-variable 'comint-redirect-subvert-readonly) t) - (set (make-local-variable 'comint-redirect-echo-input) nil) - (set (make-local-variable 'view-no-disable-on-exit) t) - (view-mode) - (setq view-exit-action - (lambda (buffer) - ;; Use `with-current-buffer' to make sure that `bury-buffer' - ;; also removes BUFFER from the selected window. - (with-current-buffer buffer - (bury-buffer)))) - (run-mode-hooks 'factor-help-mode-hook)) - -(defun factor--listener-help-buffer () - (with-current-buffer (get-buffer-create "*factor-help*") - (let ((inhibit-read-only t)) (erase-buffer)) - (factor-help-mode) - (current-buffer))) - -(defvar factor--help-history nil) - -(defun factor--listener-show-help (&optional see) - (let* ((proc (factor--listener-process)) - (def (factor--symbol-at-point)) - (prompt (format "See%s help on%s: " (if see " short" "") - (if def (format " (%s)" def) ""))) - (ask (or (not (eq major-mode 'factor-mode)) - (not def) - factor-help-always-ask)) - (cmd (format "\\ %s %s" - (if ask (read-string prompt nil 'factor--help-history def) def) - (if see "see" "help"))) - (hb (factor--listener-help-buffer))) - (comint-redirect-send-command-to-process cmd hb proc nil) - (pop-to-buffer hb) - (beginning-of-buffer hb))) - -;;;; Interface: see/help commands - -(defun factor-see (&optional arg) - "See a help summary of symbol at point. -By default, the information is shown in the minibuffer. When -called with a prefix argument, the information is displayed in a -separate help buffer." - (interactive "P") - (if (if factor-help-use-minibuffer (not arg) arg) - (factor-see-current-word) - (factor--listener-show-help t))) - -(defun factor-help () - "Show extended help about the symbol at point, using a help -buffer." - (interactive) - (factor--listener-show-help)) - - - -(defun factor-refresh-all () - "Reload source files and documentation for all loaded -vocabularies which have been modified on disk." - (interactive) - (comint-send-string "*factor*" "refresh-all\n")) - - -;;; Key bindings: - -(defun factor--define-key (key cmd &optional both) - (let ((ms (list factor-mode-map))) - (when both (push factor-help-mode-map ms)) - (dolist (m ms) - (define-key m (vector '(control ?c) key) cmd) - (define-key m (vector '(control ?c) `(control ,key)) cmd)))) - -(defun factor--define-auto-indent-key (key) - (define-key factor-mode-map (vector key) - (lambda (n) - (interactive "p") - (self-insert-command n) - (indent-for-tab-command)))) - -(factor--define-key ?f 'factor-run-file) -(factor--define-key ?r 'factor-send-region) -(factor--define-key ?d 'factor-send-definition) -(factor--define-key ?s 'factor-see t) -(factor--define-key ?e 'factor-edit) -(factor--define-key ?z 'switch-to-factor t) -(factor--define-key ?o 'factor-visit-other-file) -(factor--define-key ?c 'comment-region) - -(factor--define-auto-indent-key ?\]) -(factor--define-auto-indent-key ?\}) - -(define-key factor-mode-map "\C-ch" 'factor-help) -(define-key factor-help-mode-map "\C-ch" 'factor-help) -(define-key factor-mode-map "\C-m" 'newline-and-indent) - -(define-key factor-listener-mode-map [f8] 'factor-refresh-all) - - - -(provide 'factor) -;;; factor.el ends here From 8f10b7d9660fa4b9a4e5de69c93f7b64d7e0b90d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 26 Feb 2009 01:38:01 -0600 Subject: [PATCH 66/85] mason.release.tidy: get list of files to delete from build-support/cleanup --- extra/mason/release/tidy/tidy.factor | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/extra/mason/release/tidy/tidy.factor b/extra/mason/release/tidy/tidy.factor index 7327209a06..497be09044 100644 --- a/extra/mason/release/tidy/tidy.factor +++ b/extra/mason/release/tidy/tidy.factor @@ -1,24 +1,14 @@ ! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: bootstrap.image continuations debugger fry -io.directories io.directories.hierarchy io.files io.launcher +USING: bootstrap.image continuations debugger fry io.directories +io.directories.hierarchy io.encodings.ascii io.files io.launcher kernel mason.common namespaces sequences ; FROM: mason.config => target-os ; IN: mason.release.tidy : common-files ( -- seq ) + "build-support/cleanup" ascii file-lines images [ boot-image-name ] map - { - "vm" - "temp" - "logs" - ".git" - ".gitignore" - "Makefile" - "unmaintained" - "unfinished" - "build-support" - } append ; : remove-common-files ( -- ) From a5561146b88ae82062275b2e09e4a6c2f56ee2f1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 26 Feb 2009 01:45:15 -0600 Subject: [PATCH 67/85] mason: still send a report of post-build tasks (binary packaging, etc) fail --- extra/mason/build/build.factor | 4 +--- extra/mason/child/child.factor | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/extra/mason/build/build.factor b/extra/mason/build/build.factor index 4d705610b4..706dc12616 100644 --- a/extra/mason/build/build.factor +++ b/extra/mason/build/build.factor @@ -2,8 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays calendar io.directories io.encodings.utf8 io.files io.launcher mason.child mason.cleanup mason.common -mason.email mason.help mason.release mason.report namespaces -prettyprint ; +mason.help mason.release mason.report namespaces prettyprint ; IN: mason.build : create-build-dir ( -- ) @@ -26,7 +25,6 @@ IN: mason.build build-child upload-help release - email-report cleanup ; MAIN: build \ No newline at end of file diff --git a/extra/mason/child/child.factor b/extra/mason/child/child.factor index 5a3a0d6ceb..087ed2c3cb 100644 --- a/extra/mason/child/child.factor +++ b/extra/mason/child/child.factor @@ -3,7 +3,7 @@ USING: accessors arrays calendar combinators.short-circuit continuations debugger http.client io.directories io.files io.launcher io.pathnames kernel make mason.common mason.config -mason.platform mason.report namespaces sequences ; +mason.platform mason.report mason.email namespaces sequences ; IN: mason.child : make-cmd ( -- args ) @@ -90,4 +90,5 @@ IN: mason.child build-clean? status-clean status-dirty ? return-with ] callcc1 - status set ; \ No newline at end of file + status set + email-report ; \ No newline at end of file From 063e4571095699d46f419a422258f8d9a72f61fc Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 26 Feb 2009 13:41:30 -0600 Subject: [PATCH 68/85] Remove superflous \ --- basis/editors/emacs/emacs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/editors/emacs/emacs.factor b/basis/editors/emacs/emacs.factor index 05b879770e..366bc53104 100644 --- a/basis/editors/emacs/emacs.factor +++ b/basis/editors/emacs/emacs.factor @@ -11,7 +11,7 @@ M: object default-emacsclient ( -- path ) "emacsclient" ; : emacsclient ( file line -- ) [ - { [ \ emacsclient-path get ] [ default-emacsclient ] } 0|| , + { [ emacsclient-path get ] [ default-emacsclient ] } 0|| , "--no-wait" , number>string "+" prepend , , From 3f70bb3b22d2854c97fc08e4ad1bb6b6bd446b02 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 26 Feb 2009 13:41:50 -0600 Subject: [PATCH 69/85] Update docs for improved error reporting --- basis/stack-checker/stack-checker-docs.factor | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/basis/stack-checker/stack-checker-docs.factor b/basis/stack-checker/stack-checker-docs.factor index db8abac441..088fab34d0 100644 --- a/basis/stack-checker/stack-checker-docs.factor +++ b/basis/stack-checker/stack-checker-docs.factor @@ -21,7 +21,7 @@ $nl ARTICLE: "inference-combinators" "Combinator stack effects" "Without further information, one cannot say what the stack effect of " { $link call } " is; it depends on the given quotation. If the inferencer encounters a " { $link call } " without further information, a " { $link literal-expected } " error is raised." -{ $example "[ dup call ] infer." "Literal value expected\n\nType :help for debugging help." } +{ $example "[ dup call ] infer." "Got a computed value where a literal quotation was expected\n\nType :help for debugging help." } "On the other hand, the stack effect of applying " { $link call } " to a literal quotation or a " { $link curry } " of a literal quotation is easy to compute; it behaves as if the quotation was substituted at that point:" { $example "[ [ 2 + ] call ] infer." "( object -- object )" } "Consider a combinator such as " { $link keep } ". The combinator itself does not have a stack effect, because it applies " { $link call } " to a potentially arbitrary quotation. However, since the combinator is declared " { $link POSTPONE: inline } ", a given usage of it can have a stack effect:" @@ -38,7 +38,7 @@ $nl { $example ": foo 0 [ + ] ; inline" "[ foo reduce ] infer." "( object -- object )" } "Passing a literal quotation on the data stack through an inlined recursive combinator nullifies its literal status. For example, the following will not infer:" { $example - "[ [ reverse ] swap [ reverse ] map swap call ] infer." "Literal value expected\n\nType :help for debugging help." + "[ [ reverse ] swap [ reverse ] map swap call ] infer." "Got a computed value where a literal quotation was expected\n\nType :help for debugging help." } "To make this work, pass the quotation on the retain stack instead:" { $example @@ -67,11 +67,11 @@ $nl "If a recursive word takes quotation parameters from the stack and calls them, it must be declared " { $link POSTPONE: inline } " (as documented in " { $link "inference-combinators" } ") as well as " { $link POSTPONE: recursive } "." $nl "Furthermore, the input parameters which are quotations must be annotated in the stack effect. For example, the following will not infer:" -{ $example ": bad ( quot -- ) [ call ] keep foo ; inline recursive" "[ [ ] bad ] infer." "Literal value expected\n\nType :help for debugging help." } +{ $example ": bad ( quot -- ) [ call ] keep foo ; inline recursive" "[ [ ] bad ] infer." "Got a computed value where a literal quotation was expected\n\nType :help for debugging help." } "The following is correct:" { $example ": good ( quot: ( -- ) -- ) [ call ] keep good ; inline recursive" "[ [ ] good ] infer." "( -- )" } "An inline recursive word cannot pass a quotation on the data stack through the recursive call. For example, the following will not infer:" -{ $example ": bad ( ? quot: ( ? -- ) -- ) 2dup [ not ] dip bad call ; inline recursive" "[ [ drop ] bad ] infer." "Literal value expected\n\nType :help for debugging help." } +{ $example ": bad ( ? quot: ( ? -- ) -- ) 2dup [ not ] dip bad call ; inline recursive" "[ [ drop ] bad ] infer." "Got a computed value where a literal quotation was expected\n\nType :help for debugging help." } "However a small change can be made:" { $example ": good ( ? quot: ( ? -- ) -- ) [ good ] 2keep [ not ] dip call ; inline recursive" "[ [ drop ] good ] infer." "( object -- )" } "An inline recursive word must have a fixed stack effect in its base case. The following will not infer:" From a2404fad9490e6ed2af2fd7a39fdf19bf6d7c522 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 26 Feb 2009 13:44:37 -0600 Subject: [PATCH 70/85] Add missing file --- build-support/cleanup | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 build-support/cleanup diff --git a/build-support/cleanup b/build-support/cleanup new file mode 100644 index 0000000000..2d2aab0bba --- /dev/null +++ b/build-support/cleanup @@ -0,0 +1,8 @@ +vm +temp +logs +.git +.gitignore +Makefile +unmaintained +build-support From bda8b2dda63687176c35602c86a10accb3f3b100 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 26 Feb 2009 14:11:26 -0600 Subject: [PATCH 71/85] Better inlining for both-fixnums? --- basis/compiler/tree/cleanup/cleanup-tests.factor | 5 +++++ .../tree/propagation/known-words/known-words.factor | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/basis/compiler/tree/cleanup/cleanup-tests.factor b/basis/compiler/tree/cleanup/cleanup-tests.factor index 54f8aaf20e..4a2e8671fb 100755 --- a/basis/compiler/tree/cleanup/cleanup-tests.factor +++ b/basis/compiler/tree/cleanup/cleanup-tests.factor @@ -510,3 +510,8 @@ cell-bits 32 = [ [ { array } declare 2 [ . . ] assoc-each ] \ nth-unsafe inlined? ] unit-test + +[ t ] [ + [ { fixnum fixnum } declare = ] + \ both-fixnums? inlined? +] unit-test \ No newline at end of file diff --git a/basis/compiler/tree/propagation/known-words/known-words.factor b/basis/compiler/tree/propagation/known-words/known-words.factor index d5aa5318a4..ecfd415579 100644 --- a/basis/compiler/tree/propagation/known-words/known-words.factor +++ b/basis/compiler/tree/propagation/known-words/known-words.factor @@ -199,8 +199,11 @@ generic-comparison-ops [ ] "outputs" set-word-prop \ both-fixnums? [ - [ class>> fixnum classes-intersect? not ] either? - f object-info ? + [ class>> ] bi@ { + { [ 2dup [ fixnum classes-intersect? not ] either? ] [ f ] } + { [ 2dup [ fixnum class<= ] both? ] [ t ] } + [ object-info ] + } cond 2nip ] "outputs" set-word-prop { From dc370e56abf0d6888388921a0a5d053847a3e84f Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Feb 2009 17:34:26 -0600 Subject: [PATCH 72/85] mmap now throws an understandable exception upon trying to mmap a zero length file. fix a bug with calling |dispose on an integer if mmap failed on unix --- basis/io/mmap/mmap-tests.factor | 20 ++++++++++++++++++++ basis/io/mmap/mmap.factor | 9 +++++++-- basis/io/mmap/unix/unix.factor | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/basis/io/mmap/mmap-tests.factor b/basis/io/mmap/mmap-tests.factor index 166167a7e7..b892bded20 100644 --- a/basis/io/mmap/mmap-tests.factor +++ b/basis/io/mmap/mmap-tests.factor @@ -9,3 +9,23 @@ IN: io.mmap.tests [ 5 ] [ "mmap-test-file.txt" temp-file [ length ] with-mapped-char-file ] unit-test [ "22345" ] [ "mmap-test-file.txt" temp-file ascii file-contents ] unit-test [ "mmap-test-file.txt" temp-file delete-file ] ignore-errors + + +[ ] +[ "mmap-empty-file.txt" temp-file touch-file ] unit-test + +! Test for leaking resources bug on Unix +[ ] +[ + 100000 [ + [ + "mmap-empty-file.txt" temp-file [ + drop + ] with-mapped-file + ] [ dup bad-mmap-size? [ drop ] [ rethrow ] if ] recover + ] times + + "asdf" "mmap-asdf-file.txt" temp-file [ ascii set-file-contents ] keep [ + drop + ] with-mapped-file +] unit-test diff --git a/basis/io/mmap/mmap.factor b/basis/io/mmap/mmap.factor index 6f2fabb709..1a58471514 100644 --- a/basis/io/mmap/mmap.factor +++ b/basis/io/mmap/mmap.factor @@ -2,15 +2,20 @@ ! See http://factorcode.org/license.txt for BSD license. USING: continuations destructors io.files io.files.info io.backend kernel quotations system alien alien.accessors -accessors system vocabs.loader combinators alien.c-types ; +accessors system vocabs.loader combinators alien.c-types +math ; IN: io.mmap TUPLE: mapped-file address handle length disposed ; HOOK: (mapped-file) os ( path length -- address handle ) +ERROR: bad-mmap-size path size ; + : ( path -- mmap ) - [ normalize-path ] [ file-info size>> ] bi [ (mapped-file) ] keep + [ normalize-path ] [ file-info size>> ] bi + dup 0 <= [ bad-mmap-size ] when + [ (mapped-file) ] keep f mapped-file boa ; HOOK: close-mapped-file io-backend ( mmap -- ) diff --git a/basis/io/mmap/unix/unix.factor b/basis/io/mmap/unix/unix.factor index 9325dcd632..0fa8e1151f 100644 --- a/basis/io/mmap/unix/unix.factor +++ b/basis/io/mmap/unix/unix.factor @@ -9,7 +9,7 @@ IN: io.mmap.unix :: mmap-open ( path length prot flags -- alien fd ) [ f length prot flags - path open-r/w |dispose + path open-r/w [ |dispose drop ] keep [ 0 mmap dup MAP_FAILED = [ (io-error) ] when ] keep ] with-destructors ; From e986a604876d66d27f08c04aa893b4b4372686cf Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Feb 2009 17:54:44 -0600 Subject: [PATCH 73/85] id3 shouldn't fail on files with length < 128 --- extra/id3/id3.factor | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extra/id3/id3.factor b/extra/id3/id3.factor index f2bbd08996..289cc27b6b 100644 --- a/extra/id3/id3.factor +++ b/extra/id3/id3.factor @@ -1,6 +1,10 @@ ! Copyright (C) 2009 Tim Wawrzynczak ! See http://factorcode.org/license.txt for BSD license. -USING: sequences io io.encodings.binary io.files io.pathnames strings kernel math io.mmap io.mmap.uchar accessors syntax combinators math.ranges unicode.categories byte-arrays io.encodings.string io.encodings.utf8 assocs math.parser ; +USING: sequences io io.encodings.binary io.files io.pathnames +strings kernel math io.mmap io.mmap.uchar accessors syntax +combinators math.ranges unicode.categories byte-arrays +io.encodings.string io.encodings.utf8 assocs math.parser +combinators.short-circuit ; IN: id3 = ] [ 128 tail-slice* "TAG" head? ] } 1&& ; : >28bitword ( seq -- int ) 0 [ swap 7 shift bitor ] reduce ; From 16d3562b238382db24ef49df7a19a53dddc0adc9 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Feb 2009 18:03:15 -0600 Subject: [PATCH 74/85] factor id3 a bit --- extra/id3/id3.factor | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/extra/id3/id3.factor b/extra/id3/id3.factor index 289cc27b6b..abfe01c3e4 100644 --- a/extra/id3/id3.factor +++ b/extra/id3/id3.factor @@ -4,12 +4,11 @@ USING: sequences io io.encodings.binary io.files io.pathnames strings kernel math io.mmap io.mmap.uchar accessors syntax combinators math.ranges unicode.categories byte-arrays io.encodings.string io.encodings.utf8 assocs math.parser -combinators.short-circuit ; +combinators.short-circuit fry ; IN: id3 ] dip { - [ read-header-supported-version? >>version ] + [ read-header-supported-version? >>version ] [ read-header-flags >>flags ] [ read-header-size >>size ] } cleave ; @@ -233,16 +232,19 @@ TUPLE: id3-info title artist album year comment genre ; : drop-header ( mmap -- seq1 seq2 ) dup 10 tail-slice swap ; +: frame-tag ( frame string -- tag/f ) + '[ frame-id>> _ = ] find nip ; inline + : parse-frames ( id3v2-info -- id3-info ) [ ] dip frames>> { - [ [ frame-id>> "TIT2" = ] find nip [ data>> >>title ] when* ] - [ [ frame-id>> "TALB" = ] find nip [ data>> >>album ] when* ] - [ [ frame-id>> "TPE1" = ] find nip [ data>> >>artist ] when* ] - [ [ frame-id>> "TCON" = ] find nip [ data>> [ [ digit? ] filter string>number ] keep swap [ genres at nip ] when* + [ "TIT2" frame-tag [ data>> >>title ] when* ] + [ "TALB" frame-tag [ data>> >>album ] when* ] + [ "TPE1" frame-tag [ data>> >>artist ] when* ] + [ "TCON" frame-tag [ data>> [ [ digit? ] filter string>number ] keep swap [ genres at nip ] when* >>genre ] when* ] - [ [ frame-id>> "COMM" = ] find nip [ data>> >>comment ] when* ] - [ [ frame-id>> "TYER" = ] find nip [ data>> >>year ] when* ] + [ "COMM" frame-tag [ data>> >>comment ] when* ] + [ "TYER" frame-tag [ data>> >>year ] when* ] } cleave ; : read-v2-tag-data ( seq -- id3-info ) From a083832ab497392ed008467389554b63d4089f5f Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Feb 2009 18:10:11 -0600 Subject: [PATCH 75/85] fix typo in math docs --- core/math/math-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor index 94ff2c1f29..101557d0cf 100644 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -308,7 +308,7 @@ HELP: find-last-integer HELP: byte-array>bignum { $values { "byte-array" byte-array } { "n" integer } } -{ $description "Converts a byte-array, interpreted as little-endian, into a bignum integer. User code should call " { $link >le } " or " { $link >be } " instead." } ; +{ $description "Converts a byte-array, interpreted as little-endian, into a bignum integer. User code should call " { $link le> } " or " { $link be> } " instead." } ; ARTICLE: "division-by-zero" "Division by zero" "Floating point division never raises an error if the denominator is zero. This means that if at least one of the two inputs to " { $link / } ", " { $link /f } " or " { $link mod } " is a float, the result will be a floating point infinity or not a number value." From 084311750e2b0e2be608dcfc17ddfb91d6ffce2f Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Feb 2009 18:11:07 -0600 Subject: [PATCH 76/85] add using to mmap tests --- basis/io/mmap/mmap-tests.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/io/mmap/mmap-tests.factor b/basis/io/mmap/mmap-tests.factor index b892bded20..70a1869bd0 100644 --- a/basis/io/mmap/mmap-tests.factor +++ b/basis/io/mmap/mmap-tests.factor @@ -1,6 +1,6 @@ USING: io io.mmap io.mmap.char io.files io.files.temp io.directories kernel tools.test continuations sequences -io.encodings.ascii accessors ; +io.encodings.ascii accessors math ; IN: io.mmap.tests [ "mmap-test-file.txt" temp-file delete-file ] ignore-errors From 1bd35e6f625fc257ef677ccbc50696b9db0eafec Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Feb 2009 19:58:25 -0600 Subject: [PATCH 77/85] better io.mmap test --- basis/io/mmap/mmap-tests.factor | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/basis/io/mmap/mmap-tests.factor b/basis/io/mmap/mmap-tests.factor index 70a1869bd0..a4d55f3c1e 100644 --- a/basis/io/mmap/mmap-tests.factor +++ b/basis/io/mmap/mmap-tests.factor @@ -11,21 +11,11 @@ IN: io.mmap.tests [ "mmap-test-file.txt" temp-file delete-file ] ignore-errors -[ ] -[ "mmap-empty-file.txt" temp-file touch-file ] unit-test +[ "mmap-empty-file.txt" temp-file delete-file ] ignore-errors +[ ] [ "mmap-empty-file.txt" temp-file touch-file ] unit-test -! Test for leaking resources bug on Unix -[ ] [ - 100000 [ - [ - "mmap-empty-file.txt" temp-file [ - drop - ] with-mapped-file - ] [ dup bad-mmap-size? [ drop ] [ rethrow ] if ] recover - ] times - - "asdf" "mmap-asdf-file.txt" temp-file [ ascii set-file-contents ] keep [ + "mmap-empty-file.txt" temp-file [ drop ] with-mapped-file -] unit-test +] [ bad-mmap-size? ] must-fail-with From e1b4e8c66fcf81a5e3c60a47468e7fa8f53a27ea Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Feb 2009 21:39:53 -0600 Subject: [PATCH 78/85] id3 outputs id3v2-info objects or f now. id3v1 info is turned into id3v2. you can access the title, album, etc fields by calling id3-title, etc, but also other frames are saved and can be accessed --- extra/id3/authors.txt | 2 +- extra/id3/id3-docs.factor | 2 +- extra/id3/id3-tests.factor | 59 +++--- extra/id3/id3.factor | 405 +++++++++++++++++++------------------ 4 files changed, 246 insertions(+), 222 deletions(-) diff --git a/extra/id3/authors.txt b/extra/id3/authors.txt index ece617b969..2bd5c6037e 100644 --- a/extra/id3/authors.txt +++ b/extra/id3/authors.txt @@ -1,2 +1,2 @@ Tim Wawrzynczak - +Doug Coleman diff --git a/extra/id3/id3-docs.factor b/extra/id3/id3-docs.factor index a54bba1629..d171d03798 100644 --- a/extra/id3/id3-docs.factor +++ b/extra/id3/id3-docs.factor @@ -6,7 +6,7 @@ IN: id3 HELP: file-id3-tags { $values { "path" "a path string" } - { "object/f" "a tuple storing ID3 metadata or f" } } + { "id3v2-info/f" "a tuple storing ID3v2 metadata or f" } } { $description "Return a tuple containing the ID3 information parsed out of the MP3 file, or " { $link f } " if no metadata is present. Currently, the parser supports the following tags: " $nl { $link title>> } $nl { $link artist>> } diff --git a/extra/id3/id3-tests.factor b/extra/id3/id3-tests.factor index bcdc312440..eabbf00ad7 100644 --- a/extra/id3/id3-tests.factor +++ b/extra/id3/id3-tests.factor @@ -1,35 +1,42 @@ ! Copyright (C) 2009 Tim Wawrzynczak ! See http://factorcode.org/license.txt for BSD license. -USING: tools.test id3 id3.private ; +USING: tools.test id3 combinators ; IN: id3.tests -[ - T{ id3-info - { title "BLAH" } - { artist "ARTIST" } - { album "ALBUM" } - { year "2009" } - { comment "COMMENT" } - { genre "Bluegrass" } - } -] [ "resource:extra/id3/tests/blah.mp3" file-id3-tags ] unit-test +: id3-params ( id3 -- title artist album year comment genre ) + { + [ id3-title ] + [ id3-artist ] + [ id3-album ] + [ id3-year ] + [ id3-comment ] + [ id3-genre ] + } cleave ; [ - T{ id3-info - { title "Anthem of the Trinity" } - { artist "Terry Riley" } - { album "Shri Camel" } - { genre "Classical" } - } -] [ "resource:extra/id3/tests/blah2.mp3" file-id3-tags ] unit-test + "BLAH" + "ARTIST" + "ALBUM" + "2009" + "COMMENT" + "Bluegrass" +] [ "resource:extra/id3/tests/blah.mp3" file-id3-tags id3-params ] unit-test + +[ + "Anthem of the Trinity" + "Terry Riley" + "Shri Camel" + f + f + "Classical" +] [ "resource:extra/id3/tests/blah2.mp3" file-id3-tags id3-params ] unit-test [ - T{ id3-info - { title "Stormy Weather" } - { artist "Frank Sinatra" } - { album "Night and Day Frank Sinatra" } - { comment "eng, AG# 08E1C12E" } - { genre "Big Band" } - } -] [ "resource:extra/id3/tests/blah3.mp3" file-id3-tags ] unit-test + "Stormy Weather" + "Frank Sinatra" + "Night and Day Frank Sinatra" + f + "eng, AG# 08E1C12E" + "Big Band" +] [ "resource:extra/id3/tests/blah3.mp3" file-id3-tags id3-params ] unit-test diff --git a/extra/id3/id3.factor b/extra/id3/id3.factor index abfe01c3e4..fba6188b1e 100644 --- a/extra/id3/id3.factor +++ b/extra/id3/id3.factor @@ -1,145 +1,144 @@ -! Copyright (C) 2009 Tim Wawrzynczak +! Copyright (C) 2009 Tim Wawrzynczak, Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: sequences io io.encodings.binary io.files io.pathnames strings kernel math io.mmap io.mmap.uchar accessors syntax combinators math.ranges unicode.categories byte-arrays io.encodings.string io.encodings.utf8 assocs math.parser -combinators.short-circuit fry ; +combinators.short-circuit fry namespaces multiline +combinators.smart splitting ; IN: id3 ( -- object ) id3-info new ; -: ( header frames -- object ) id3v2-info boa ; +: ( header frames -- object ) + [ [ frame-id>> ] keep ] H{ } map>assoc + id3v2-info boa ; :
( -- object ) header new ; : ( -- object ) frame new ; -! utility words - -: id3v2? ( mmap -- ? ) - "ID3" head? ; +: id3v2? ( mmap -- ? ) "ID3" head? ; inline : id3v1? ( mmap -- ? ) - { [ length 128 >= ] [ 128 tail-slice* "TAG" head? ] } 1&& ; + { [ length 128 >= ] [ 128 tail-slice* "TAG" head? ] } 1&& ; inline + +: id3v1-frame ( string key -- frame ) + + swap >>frame-id + swap >>data ; + +: id3v1>id3v2 ( id3v1 -- id3v2 ) + [ + { + [ title>> "TIT2" id3v1-frame ] + [ artist>> "TPE1" id3v1-frame ] + [ album>> "TALB" id3v1-frame ] + [ year>> "TYER" id3v1-frame ] + [ comment>> "COMM" id3v1-frame ] + [ genre>> "TCON" id3v1-frame ] + } cleave + ] output>array f swap ; : >28bitword ( seq -- int ) - 0 [ swap 7 shift bitor ] reduce ; + 0 [ [ 7 shift ] dip bitor ] reduce ; inline : filter-text-data ( data -- filtered ) - [ printable? ] filter ; + [ printable? ] filter ; inline ! frame details stuff : valid-frame-id? ( id -- ? ) - [ [ digit? ] [ LETTER? ] bi or ] all? ; + [ { [ digit? ] [ LETTER? ] } 1|| ] all? ; inline : read-frame-id ( mmap -- id ) - 4 head-slice ; + 4 head-slice ; inline : read-frame-size ( mmap -- size ) - [ 4 8 ] dip subseq ; + [ 4 8 ] dip subseq ; inline : read-frame-flags ( mmap -- flags ) - [ 8 10 ] dip subseq ; + [ 8 10 ] dip subseq ; inline : read-frame-data ( frame mmap -- frame data ) - [ 10 over size>> 10 + ] dip filter-text-data ; + [ 10 over size>> 10 + ] dip filter-text-data ; inline ! read whole frames @@ -200,10 +215,11 @@ TUPLE: id3-info title artist album year comment genre ; } cleave ; : read-frame ( mmap -- frame/f ) - dup read-frame-id valid-frame-id? [ (read-frame) ] [ drop f ] if ; + dup read-frame-id valid-frame-id? + [ (read-frame) ] [ drop f ] if ; : remove-frame ( mmap frame -- mmap ) - size>> 10 + tail-slice ; + size>> 10 + tail-slice ; inline : read-frames ( mmap -- frames ) [ dup read-frame dup ] @@ -213,13 +229,12 @@ TUPLE: id3-info title artist album year comment genre ; ! header stuff : read-header-supported-version? ( mmap -- ? ) - 3 tail-slice [ { 4 } head? ] [ { 3 } head? ] bi or ; + 3 tail-slice first { 3 4 } member? ; inline -: read-header-flags ( mmap -- flags ) - 5 swap nth ; +: read-header-flags ( mmap -- flags ) 5 swap nth ; inline : read-header-size ( mmap -- size ) - [ 6 10 ] dip >28bitword ; + [ 6 10 ] dip >28bitword ; inline : read-v2-header ( mmap -- id3header ) [
] dip @@ -227,51 +242,30 @@ TUPLE: id3-info title artist album year comment genre ; [ read-header-supported-version? >>version ] [ read-header-flags >>flags ] [ read-header-size >>size ] - } cleave ; + } cleave ; inline : drop-header ( mmap -- seq1 seq2 ) - dup 10 tail-slice swap ; + [ 10 tail-slice ] [ ] bi ; inline -: frame-tag ( frame string -- tag/f ) - '[ frame-id>> _ = ] find nip ; inline - -: parse-frames ( id3v2-info -- id3-info ) - [ ] dip frames>> - { - [ "TIT2" frame-tag [ data>> >>title ] when* ] - [ "TALB" frame-tag [ data>> >>album ] when* ] - [ "TPE1" frame-tag [ data>> >>artist ] when* ] - [ "TCON" frame-tag [ data>> [ [ digit? ] filter string>number ] keep swap [ genres at nip ] when* - >>genre ] when* ] - [ "COMM" frame-tag [ data>> >>comment ] when* ] - [ "TYER" frame-tag [ data>> >>year ] when* ] - } cleave ; - -: read-v2-tag-data ( seq -- id3-info ) - drop-header read-v2-header swap read-frames parse-frames ; +: read-v2-tag-data ( seq -- id3v2-info ) + drop-header read-v2-header + swap read-frames ; inline ! v1 information -: skip-to-v1-data ( seq -- seq ) - 125 tail-slice* ; +: skip-to-v1-data ( seq -- seq ) 125 tail-slice* ; inline -: read-title ( seq -- title ) - 30 head-slice ; +: read-title ( seq -- title ) 30 head-slice ; inline -: read-artist ( seq -- title ) - [ 30 60 ] dip subseq ; +: read-artist ( seq -- title ) [ 30 60 ] dip subseq ; inline -: read-album ( seq -- album ) - [ 60 90 ] dip subseq ; +: read-album ( seq -- album ) [ 60 90 ] dip subseq ; inline -: read-year ( seq -- year ) - [ 90 94 ] dip subseq ; +: read-year ( seq -- year ) [ 90 94 ] dip subseq ; inline -: read-comment ( seq -- comment ) - [ 94 124 ] dip subseq ; +: read-comment ( seq -- comment ) [ 94 124 ] dip subseq ; inline -: read-genre ( seq -- genre ) - [ 124 ] dip nth ; +: read-genre ( seq -- genre ) [ 124 ] dip nth ; inline : (read-v1-tag-data) ( seq -- mp3-file ) [ ] dip @@ -281,23 +275,46 @@ TUPLE: id3-info title artist album year comment genre ; [ read-album utf8 decode filter-text-data >>album ] [ read-year utf8 decode filter-text-data >>year ] [ read-comment utf8 decode filter-text-data >>comment ] - [ read-genre >fixnum genres at >>genre ] - } cleave ; + [ read-genre number>string >>genre ] + } cleave ; inline : read-v1-tag-data ( seq -- mp3-file ) - skip-to-v1-data (read-v1-tag-data) ; + skip-to-v1-data (read-v1-tag-data) ; inline + +: parse-genre ( string -- n/f ) + dup "(" ?head-slice drop ")" ?tail-slice drop + string>number dup number? [ + genres ?nth swap or + ] [ + drop + ] if ; inline PRIVATE> -! public interface +: frame-named ( id3 name quot -- obj ) + [ swap frames>> at* ] dip + [ data>> ] prepose [ drop f ] if ; inline -: file-id3-tags ( path -- object/f ) +: id3-title ( id3 -- title/f ) "TIT2" [ ] frame-named ; inline + +: id3-artist ( id3 -- artist/f ) "TPE1" [ ] frame-named ; inline + +: id3-album ( id3 -- album/f ) "TALB" [ ] frame-named ; inline + +: id3-year ( id3 -- year/f ) "TYER" [ ] frame-named ; inline + +: id3-comment ( id3 -- comment/f ) "COMM" [ ] frame-named ; inline + +: id3-genre ( id3 -- genre/f ) + "TCON" [ parse-genre ] frame-named ; inline + +: id3-frame ( id3 key -- value/f ) [ ] frame-named ; inline + +: file-id3-tags ( path -- id3v2-info/f ) [ { - { [ dup id3v2? ] [ read-v2-tag-data ] } ! ( ? -- id3v2 ) - { [ dup id3v1? ] [ read-v1-tag-data ] } ! ( ? -- id3-info ) - [ drop f ] ! ( mmap -- f ) + { [ dup id3v2? ] [ read-v2-tag-data ] } + { [ dup id3v1? ] [ read-v1-tag-data id3v1>id3v2 ] } + [ drop f ] } cond ] with-mapped-uchar-file ; - -! end From de9154fc5e7cf979e1d59205433c4b2d2ae25b44 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Feb 2009 21:50:01 -0600 Subject: [PATCH 79/85] make find-all-files and find-in-program-files not take the traversal method --- basis/io/directories/search/search-docs.factor | 2 +- basis/io/directories/search/search-tests.factor | 2 +- basis/io/directories/search/search.factor | 3 ++- basis/io/directories/search/windows/windows.factor | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/basis/io/directories/search/search-docs.factor b/basis/io/directories/search/search-docs.factor index 99135b7953..818899606d 100644 --- a/basis/io/directories/search/search-docs.factor +++ b/basis/io/directories/search/search-docs.factor @@ -38,7 +38,7 @@ HELP: find-in-directories HELP: find-all-files { $values - { "path" "a pathname string" } { "bfs?" "a boolean, breadth-first or depth-first" } { "quot" quotation } + { "path" "a pathname string" } { "quot" quotation } { "paths/f" "a sequence of pathname strings or f" } } { $description "Finds all files in the input directory matching the predicate quotation in a breadth-first or depth-first traversal." } ; diff --git a/basis/io/directories/search/search-tests.factor b/basis/io/directories/search/search-tests.factor index a8b8bf9215..ba1b9cdbe1 100644 --- a/basis/io/directories/search/search-tests.factor +++ b/basis/io/directories/search/search-tests.factor @@ -5,6 +5,6 @@ IN: io.directories.search.tests [ t ] [ [ 10 [ "io.paths.test" "gogogo" make-unique-file ] replicate - current-temporary-directory get t [ ] find-all-files + current-temporary-directory get [ ] find-all-files ] with-unique-directory drop [ natural-sort ] bi@ = ] unit-test diff --git a/basis/io/directories/search/search.factor b/basis/io/directories/search/search.factor index b56fb7b6a3..ee8fd129a7 100755 --- a/basis/io/directories/search/search.factor +++ b/basis/io/directories/search/search.factor @@ -51,7 +51,8 @@ PRIVATE> [ keep and ] curry iterate-directory ] [ drop f ] recover ; inline -: find-all-files ( path bfs? quot: ( obj -- ? ) -- paths/f ) +: find-all-files ( path quot: ( obj -- ? ) -- paths/f ) + f swap '[ _ _ _ [ ] dip pusher [ [ f ] compose iterate-directory drop ] dip diff --git a/basis/io/directories/search/windows/windows.factor b/basis/io/directories/search/windows/windows.factor index 755710befd..cda9403417 100644 --- a/basis/io/directories/search/windows/windows.factor +++ b/basis/io/directories/search/windows/windows.factor @@ -7,7 +7,7 @@ IN: io.directories.search.windows : program-files-directories ( -- array ) program-files program-files-x86 2array harvest ; inline -: find-in-program-files ( base-directory bfs? quot -- path ) - [ +: find-in-program-files ( base-directory quot -- path ) + t swap [ [ program-files-directories ] dip '[ _ append-path ] map ] 2dip find-in-directories ; inline From efe701af9b614255ab1ca75a9806e06e5abc8fda Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Feb 2009 21:50:20 -0600 Subject: [PATCH 80/85] fix editors for find-in-program-files change --- basis/editors/editpadlite/editpadlite.factor | 2 +- basis/editors/editpadpro/editpadpro.factor | 2 +- basis/editors/editplus/editplus.factor | 2 +- basis/editors/emacs/windows/windows.factor | 4 ++-- basis/editors/emeditor/emeditor.factor | 2 +- basis/editors/etexteditor/etexteditor.factor | 2 +- basis/editors/gvim/windows/windows.factor | 2 +- basis/editors/notepadpp/notepadpp.factor | 2 +- basis/editors/scite/scite.factor | 4 ++-- basis/editors/ted-notepad/ted-notepad.factor | 2 +- basis/editors/textpad/textpad.factor | 2 +- basis/editors/ultraedit/ultraedit.factor | 2 +- basis/editors/wordpad/wordpad.factor | 2 +- 13 files changed, 15 insertions(+), 15 deletions(-) diff --git a/basis/editors/editpadlite/editpadlite.factor b/basis/editors/editpadlite/editpadlite.factor index d487ca776f..043ef7ef27 100644 --- a/basis/editors/editpadlite/editpadlite.factor +++ b/basis/editors/editpadlite/editpadlite.factor @@ -5,7 +5,7 @@ IN: editors.editpadlite : editpadlite-path ( -- path ) \ editpadlite-path get-global [ - "JGsoft" t [ >lower "editpadlite.exe" tail? ] find-in-program-files + "JGsoft" [ >lower "editpadlite.exe" tail? ] find-in-program-files [ "editpadlite.exe" ] unless* ] unless* ; diff --git a/basis/editors/editpadpro/editpadpro.factor b/basis/editors/editpadpro/editpadpro.factor index 09bfd69de8..571c20fd6a 100644 --- a/basis/editors/editpadpro/editpadpro.factor +++ b/basis/editors/editpadpro/editpadpro.factor @@ -5,7 +5,7 @@ IN: editors.editpadpro : editpadpro-path ( -- path ) \ editpadpro-path get-global [ - "JGsoft" t [ >lower "editpadpro.exe" tail? ] find-in-program-files + "JGsoft" [ >lower "editpadpro.exe" tail? ] find-in-program-files [ "editpadpro.exe" ] unless* ] unless* ; diff --git a/basis/editors/editplus/editplus.factor b/basis/editors/editplus/editplus.factor index affbcd4eb6..a3150dc961 100644 --- a/basis/editors/editplus/editplus.factor +++ b/basis/editors/editplus/editplus.factor @@ -5,7 +5,7 @@ IN: editors.editplus : editplus-path ( -- path ) \ editplus-path get-global [ - "EditPlus 2" t [ "editplus.exe" tail? ] find-in-program-files + "EditPlus 2" [ "editplus.exe" tail? ] find-in-program-files [ "editplus.exe" ] unless* ] unless* ; diff --git a/basis/editors/emacs/windows/windows.factor b/basis/editors/emacs/windows/windows.factor index e18c39ed60..91d6e878e4 100755 --- a/basis/editors/emacs/windows/windows.factor +++ b/basis/editors/emacs/windows/windows.factor @@ -6,7 +6,7 @@ IN: editors.emacs.windows M: windows default-emacsclient { - [ "Emacs" t [ "emacsclientw.exe" tail? ] find-in-program-files ] - [ "Emacs" t [ "emacsclient.exe" tail? ] find-in-program-files ] + [ "Emacs" [ "emacsclientw.exe" tail? ] find-in-program-files ] + [ "Emacs" [ "emacsclient.exe" tail? ] find-in-program-files ] [ "emacsclient.exe" ] } 0|| ; diff --git a/basis/editors/emeditor/emeditor.factor b/basis/editors/emeditor/emeditor.factor index 52c52bbb8b..3380f5c974 100644 --- a/basis/editors/emeditor/emeditor.factor +++ b/basis/editors/emeditor/emeditor.factor @@ -5,7 +5,7 @@ IN: editors.emeditor : emeditor-path ( -- path ) \ emeditor-path get-global [ - "EmEditor" t [ "EmEditor.exe" tail? ] find-in-program-files + "EmEditor" [ "EmEditor.exe" tail? ] find-in-program-files [ "EmEditor.exe" ] unless* ] unless* ; diff --git a/basis/editors/etexteditor/etexteditor.factor b/basis/editors/etexteditor/etexteditor.factor index 37c8d1b572..8b76b3b473 100755 --- a/basis/editors/etexteditor/etexteditor.factor +++ b/basis/editors/etexteditor/etexteditor.factor @@ -6,7 +6,7 @@ IN: editors.etexteditor : etexteditor-path ( -- str ) \ etexteditor-path get-global [ - "e" t [ "e.exe" tail? ] find-in-program-files + "e" [ "e.exe" tail? ] find-in-program-files [ "e" ] unless* ] unless* ; diff --git a/basis/editors/gvim/windows/windows.factor b/basis/editors/gvim/windows/windows.factor index 4edc13b90c..3fe228a403 100644 --- a/basis/editors/gvim/windows/windows.factor +++ b/basis/editors/gvim/windows/windows.factor @@ -5,6 +5,6 @@ IN: editors.gvim.windows M: windows gvim-path \ gvim-path get-global [ - "vim" t [ "gvim.exe" tail? ] find-in-program-files + "vim" [ "gvim.exe" tail? ] find-in-program-files [ "gvim.exe" ] unless* ] unless* ; diff --git a/basis/editors/notepadpp/notepadpp.factor b/basis/editors/notepadpp/notepadpp.factor index 1c856bd761..7b0f2bb72a 100644 --- a/basis/editors/notepadpp/notepadpp.factor +++ b/basis/editors/notepadpp/notepadpp.factor @@ -4,7 +4,7 @@ IN: editors.notepadpp : notepadpp-path ( -- path ) \ notepadpp-path get-global [ - "notepad++" t [ "notepad++.exe" tail? ] find-in-program-files + "notepad++" [ "notepad++.exe" tail? ] find-in-program-files [ "notepad++.exe" ] unless* ] unless* ; diff --git a/basis/editors/scite/scite.factor b/basis/editors/scite/scite.factor index fc7e9e319e..7e8a540b73 100644 --- a/basis/editors/scite/scite.factor +++ b/basis/editors/scite/scite.factor @@ -7,11 +7,11 @@ IN: editors.scite : scite-path ( -- path ) \ scite-path get-global [ - "Scintilla Text Editor" t + "Scintilla Text Editor" [ >lower "scite.exe" tail? ] find-in-program-files [ - "SciTE Source Code Editor" t + "SciTE Source Code Editor" [ >lower "scite.exe" tail? ] find-in-program-files ] unless* [ "scite.exe" ] unless* diff --git a/basis/editors/ted-notepad/ted-notepad.factor b/basis/editors/ted-notepad/ted-notepad.factor index 301e82225c..6f954febe8 100644 --- a/basis/editors/ted-notepad/ted-notepad.factor +++ b/basis/editors/ted-notepad/ted-notepad.factor @@ -4,7 +4,7 @@ IN: editors.ted-notepad : ted-notepad-path ( -- path ) \ ted-notepad-path get-global [ - "TED Notepad" t [ "TedNPad.exe" tail? ] find-in-program-files + "TED Notepad" [ "TedNPad.exe" tail? ] find-in-program-files [ "TedNPad.exe" ] unless* ] unless* ; diff --git a/basis/editors/textpad/textpad.factor b/basis/editors/textpad/textpad.factor index ca9d5c486a..925f75400f 100644 --- a/basis/editors/textpad/textpad.factor +++ b/basis/editors/textpad/textpad.factor @@ -5,7 +5,7 @@ IN: editors.textpad : textpad-path ( -- path ) \ textpad-path get-global [ - "TextPad 5" t [ "TextPad.exe" tail? ] find-in-program-files + "TextPad 5" [ "TextPad.exe" tail? ] find-in-program-files [ "TextPad.exe" ] unless* ] unless* ; diff --git a/basis/editors/ultraedit/ultraedit.factor b/basis/editors/ultraedit/ultraedit.factor index b5bc229743..3069d78925 100644 --- a/basis/editors/ultraedit/ultraedit.factor +++ b/basis/editors/ultraedit/ultraedit.factor @@ -4,7 +4,7 @@ IN: editors.ultraedit : ultraedit-path ( -- path ) \ ultraedit-path get-global [ - "IDM Computer Solutions" t [ "uedit32.exe" tail? ] find-in-program-files + "IDM Computer Solutions" [ "uedit32.exe" tail? ] find-in-program-files [ "uedit32.exe" ] unless* ] unless* ; diff --git a/basis/editors/wordpad/wordpad.factor b/basis/editors/wordpad/wordpad.factor index ef670d5d28..103b69ba4c 100644 --- a/basis/editors/wordpad/wordpad.factor +++ b/basis/editors/wordpad/wordpad.factor @@ -4,7 +4,7 @@ IN: editors.wordpad : wordpad-path ( -- path ) \ wordpad-path get [ - "Windows NT\\Accessories" t + "Windows NT\\Accessories" [ "wordpad.exe" tail? ] find-in-program-files ] unless* ; From 63c9b1a6b8d0dae85a1c0c7aba6ad7a81c9560c2 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Feb 2009 22:33:43 -0600 Subject: [PATCH 81/85] try to detect the encoding for id3 headers. need to try this on some mp3s from the wild --- extra/id3/id3.factor | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/extra/id3/id3.factor b/extra/id3/id3.factor index fba6188b1e..a4adeedaa5 100644 --- a/extra/id3/id3.factor +++ b/extra/id3/id3.factor @@ -3,9 +3,9 @@ USING: sequences io io.encodings.binary io.files io.pathnames strings kernel math io.mmap io.mmap.uchar accessors syntax combinators math.ranges unicode.categories byte-arrays -io.encodings.string io.encodings.utf8 assocs math.parser +io.encodings.string io.encodings.utf16 assocs math.parser combinators.short-circuit fry namespaces multiline -combinators.smart splitting ; +combinators.smart splitting io.encodings.ascii ; IN: id3 ] dip { - [ read-frame-id utf8 decode >>frame-id ] - [ read-frame-flags >byte-array >>flags ] - [ read-frame-size >28bitword >>size ] - [ read-frame-data utf8 decode >>data ] + [ read-frame-id decode-text >>frame-id ] + [ read-frame-flags >byte-array >>flags ] + [ read-frame-size >28bitword >>size ] + [ read-frame-data decode-text >>data ] } cleave ; : read-frame ( mmap -- frame/f ) @@ -270,12 +275,12 @@ TUPLE: id3-info title artist album year comment genre ; : (read-v1-tag-data) ( seq -- mp3-file ) [ ] dip { - [ read-title utf8 decode filter-text-data >>title ] - [ read-artist utf8 decode filter-text-data >>artist ] - [ read-album utf8 decode filter-text-data >>album ] - [ read-year utf8 decode filter-text-data >>year ] - [ read-comment utf8 decode filter-text-data >>comment ] - [ read-genre number>string >>genre ] + [ read-title decode-text filter-text-data >>title ] + [ read-artist decode-text filter-text-data >>artist ] + [ read-album decode-text filter-text-data >>album ] + [ read-year decode-text filter-text-data >>year ] + [ read-comment decode-text filter-text-data >>comment ] + [ read-genre number>string >>genre ] } cleave ; inline : read-v1-tag-data ( seq -- mp3-file ) From 11117648ea21caa85d057117a2e546c89b6fdee3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 26 Feb 2009 23:30:48 -0600 Subject: [PATCH 82/85] Fix stack checker regressions --- basis/stack-checker/errors/errors.factor | 2 +- basis/stack-checker/known-words/known-words.factor | 8 +++----- basis/stack-checker/stack-checker-tests.factor | 7 +++++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/basis/stack-checker/errors/errors.factor b/basis/stack-checker/errors/errors.factor index 6a9a7cb8af..7f35ece714 100644 --- a/basis/stack-checker/errors/errors.factor +++ b/basis/stack-checker/errors/errors.factor @@ -80,4 +80,4 @@ TUPLE: inconsistent-recursive-call-error word ; TUPLE: unknown-primitive-error ; : unknown-primitive-error ( -- * ) - \ unknown-primitive-error inference-error ; + \ unknown-primitive-error inference-warning ; diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 0c20c41d99..1b4d9012db 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -141,9 +141,7 @@ M: object infer-call* apply-word/effect ; : infer-exit ( -- ) - \ exit - { integer } { } t >>terminated? - apply-word/effect ; + \ exit (( n -- * )) apply-word/effect ; : infer-load-locals ( -- ) pop-literal nip @@ -189,7 +187,7 @@ M: object infer-call* { \ load-locals [ infer-load-locals ] } { \ get-local [ infer-get-local ] } { \ drop-locals [ infer-drop-locals ] } - { \ do-primitive [ unknown-primitive-error inference-warning ] } + { \ do-primitive [ unknown-primitive-error ] } { \ alien-invoke [ infer-alien-invoke ] } { \ alien-indirect [ infer-alien-indirect ] } { \ alien-callback [ infer-alien-callback ] } @@ -207,7 +205,7 @@ M: object infer-call* { declare call (call) slip 2slip 3slip dip 2dip 3dip curry compose execute (execute) if dispatch - (throw) load-local load-locals get-local drop-locals do-primitive + (throw) exit load-local load-locals get-local drop-locals do-primitive alien-invoke alien-indirect alien-callback } [ t "special" set-word-prop ] each diff --git a/basis/stack-checker/stack-checker-tests.factor b/basis/stack-checker/stack-checker-tests.factor index bc6eb9f092..fadfadd885 100644 --- a/basis/stack-checker/stack-checker-tests.factor +++ b/basis/stack-checker/stack-checker-tests.factor @@ -6,7 +6,8 @@ quotations effects tools.test continuations generic.standard sorting assocs definitions prettyprint io inspector classes.tuple classes.union classes.predicate debugger threads.private io.streams.string io.timeouts io.thread -sequences.private destructors combinators eval locals.backend ; +sequences.private destructors combinators eval locals.backend +system ; IN: stack-checker.tests \ infer. must-infer @@ -581,4 +582,6 @@ DEFER: eee' : debugging-curry-folding ( quot -- ) [ debugging-curry-folding ] curry call ; inline recursive -[ [ ] debugging-curry-folding ] must-infer \ No newline at end of file +[ [ ] debugging-curry-folding ] must-infer + +[ [ exit ] [ 1 2 3 ] if ] must-infer \ No newline at end of file From 16e394517c278639bc7a05012a33cffc12a0a0b3 Mon Sep 17 00:00:00 2001 From: sheeple Date: Fri, 27 Feb 2009 00:23:04 -0600 Subject: [PATCH 83/85] use vocab: in id3 tests, remove lots of helper words because it's clear what they do --- extra/id3/id3-tests.factor | 6 +- extra/id3/id3.factor | 229 ++++++++----------------------------- 2 files changed, 52 insertions(+), 183 deletions(-) diff --git a/extra/id3/id3-tests.factor b/extra/id3/id3-tests.factor index eabbf00ad7..aefbec8550 100644 --- a/extra/id3/id3-tests.factor +++ b/extra/id3/id3-tests.factor @@ -20,7 +20,7 @@ IN: id3.tests "2009" "COMMENT" "Bluegrass" -] [ "resource:extra/id3/tests/blah.mp3" file-id3-tags id3-params ] unit-test +] [ "vocab:id3/tests/blah.mp3" file-id3-tags id3-params ] unit-test [ "Anthem of the Trinity" @@ -29,7 +29,7 @@ IN: id3.tests f f "Classical" -] [ "resource:extra/id3/tests/blah2.mp3" file-id3-tags id3-params ] unit-test +] [ "vocab:id3/tests/blah2.mp3" file-id3-tags id3-params ] unit-test [ "Stormy Weather" @@ -38,5 +38,5 @@ IN: id3.tests f "eng, AG# 08E1C12E" "Big Band" -] [ "resource:extra/id3/tests/blah3.mp3" file-id3-tags id3-params ] unit-test +] [ "vocab:id3/tests/blah3.mp3" file-id3-tags id3-params ] unit-test diff --git a/extra/id3/id3.factor b/extra/id3/id3.factor index a4adeedaa5..aa27fb95c7 100644 --- a/extra/id3/id3.factor +++ b/extra/id3/id3.factor @@ -4,140 +4,39 @@ USING: sequences io io.encodings.binary io.files io.pathnames strings kernel math io.mmap io.mmap.uchar accessors syntax combinators math.ranges unicode.categories byte-arrays io.encodings.string io.encodings.utf16 assocs math.parser -combinators.short-circuit fry namespaces multiline -combinators.smart splitting io.encodings.ascii ; +combinators.short-circuit fry namespaces combinators.smart +splitting io.encodings.ascii arrays ; IN: id3 > 10 + ] dip filter-text-data ; inline -! read whole frames - : decode-text ( string -- string' ) dup 2 short head { { HEX: ff HEX: fe } { HEX: fe HEX: ff } } member? @@ -213,14 +99,14 @@ TUPLE: id3-info title artist album year comment genre ; : (read-frame) ( mmap -- frame ) [ ] dip { - [ read-frame-id decode-text >>frame-id ] - [ read-frame-flags >byte-array >>flags ] - [ read-frame-size >28bitword >>size ] + [ 4 head-slice decode-text >>frame-id ] + [ [ 4 8 ] dip subseq >28bitword >>size ] + [ [ 8 10 ] dip subseq >byte-array >>flags ] [ read-frame-data decode-text >>data ] } cleave ; : read-frame ( mmap -- frame/f ) - dup read-frame-id valid-frame-id? + dup 4 head-slice valid-frame-id? [ (read-frame) ] [ drop f ] if ; : remove-frame ( mmap frame -- mmap ) @@ -233,54 +119,32 @@ TUPLE: id3-info title artist album year comment genre ; ! header stuff -: read-header-supported-version? ( mmap -- ? ) - 3 tail-slice first { 3 4 } member? ; inline - -: read-header-flags ( mmap -- flags ) 5 swap nth ; inline - -: read-header-size ( mmap -- size ) - [ 6 10 ] dip >28bitword ; inline - -: read-v2-header ( mmap -- id3header ) +: read-v2-header ( seq -- id3header ) [
] dip { - [ read-header-supported-version? >>version ] - [ read-header-flags >>flags ] - [ read-header-size >>size ] + [ [ 3 5 ] dip >array >>version ] + [ [ 5 ] dip nth >>flags ] + [ [ 6 10 ] dip >28bitword >>size ] } cleave ; inline -: drop-header ( mmap -- seq1 seq2 ) - [ 10 tail-slice ] [ ] bi ; inline - : read-v2-tag-data ( seq -- id3v2-info ) - drop-header read-v2-header - swap read-frames ; inline + 10 cut-slice + [ read-v2-header ] + [ read-frames ] bi* ; inline ! v1 information : skip-to-v1-data ( seq -- seq ) 125 tail-slice* ; inline -: read-title ( seq -- title ) 30 head-slice ; inline - -: read-artist ( seq -- title ) [ 30 60 ] dip subseq ; inline - -: read-album ( seq -- album ) [ 60 90 ] dip subseq ; inline - -: read-year ( seq -- year ) [ 90 94 ] dip subseq ; inline - -: read-comment ( seq -- comment ) [ 94 124 ] dip subseq ; inline - -: read-genre ( seq -- genre ) [ 124 ] dip nth ; inline - : (read-v1-tag-data) ( seq -- mp3-file ) [ ] dip { - [ read-title decode-text filter-text-data >>title ] - [ read-artist decode-text filter-text-data >>artist ] - [ read-album decode-text filter-text-data >>album ] - [ read-year decode-text filter-text-data >>year ] - [ read-comment decode-text filter-text-data >>comment ] - [ read-genre number>string >>genre ] + [ 30 head-slice decode-text filter-text-data >>title ] + [ [ 30 60 ] dip subseq decode-text filter-text-data >>artist ] + [ [ 60 90 ] dip subseq decode-text filter-text-data >>album ] + [ [ 90 94 ] dip subseq decode-text filter-text-data >>year ] + [ [ 94 124 ] dip subseq decode-text filter-text-data >>comment ] + [ [ 124 ] dip nth number>string >>genre ] } cleave ; inline : read-v1-tag-data ( seq -- mp3-file ) @@ -323,3 +187,8 @@ PRIVATE> [ drop f ] } cond ] with-mapped-uchar-file ; + +: write-id3-tags ( id3v2-info path -- ) + binary [ + + ] with-file-writer ; From ec51a3a1a1fce19fc6ec3e1707d8d919e461f77f Mon Sep 17 00:00:00 2001 From: sheeple Date: Fri, 27 Feb 2009 00:27:39 -0600 Subject: [PATCH 84/85] id3-info -> id3v1-info, remove work in progress --- extra/id3/id3.factor | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/extra/id3/id3.factor b/extra/id3/id3.factor index aa27fb95c7..d1397285d7 100644 --- a/extra/id3/id3.factor +++ b/extra/id3/id3.factor @@ -45,9 +45,9 @@ TUPLE: frame frame-id flags size data ; TUPLE: id3v2-info header frames ; -TUPLE: id3-info title artist album year comment genre ; +TUPLE: id3v1-info title artist album year comment genre ; -: ( -- object ) id3-info new ; +: ( -- object ) id3v1-info new ; : ( header frames -- object ) [ [ frame-id>> ] keep ] H{ } map>assoc @@ -137,7 +137,7 @@ TUPLE: id3-info title artist album year comment genre ; : skip-to-v1-data ( seq -- seq ) 125 tail-slice* ; inline : (read-v1-tag-data) ( seq -- mp3-file ) - [ ] dip + [ ] dip { [ 30 head-slice decode-text filter-text-data >>title ] [ [ 30 60 ] dip subseq decode-text filter-text-data >>artist ] @@ -187,8 +187,3 @@ PRIVATE> [ drop f ] } cond ] with-mapped-uchar-file ; - -: write-id3-tags ( id3v2-info path -- ) - binary [ - - ] with-file-writer ; From 2c462745f126a2fba9563a2516c8ce321229f5ea Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Fri, 27 Feb 2009 00:53:05 -0600 Subject: [PATCH 85/85] Redoing string streams and byte-array streams without copying --- basis/hints/hints.factor | 2 - basis/io/streams/byte-array/byte-array.factor | 15 ++++++- core/checksums/crc32/crc32.factor | 2 +- core/io/streams/sequence/sequence.factor | 38 ++++++++++++++++ core/io/streams/string/string-tests.factor | 10 ++--- core/io/streams/string/string.factor | 44 +++++-------------- 6 files changed, 68 insertions(+), 43 deletions(-) create mode 100644 core/io/streams/sequence/sequence.factor diff --git a/basis/hints/hints.factor b/basis/hints/hints.factor index b6af773ce5..4093666eb7 100644 --- a/basis/hints/hints.factor +++ b/basis/hints/hints.factor @@ -96,8 +96,6 @@ M: object specializer-declaration class ; { string string } "specializer" set-word-prop -\ find-last-sep { string sbuf } "specializer" set-word-prop - \ >string { sbuf } "specializer" set-word-prop \ >array { { vector } } "specializer" set-word-prop diff --git a/basis/io/streams/byte-array/byte-array.factor b/basis/io/streams/byte-array/byte-array.factor index 9d89c3d814..b877e97cf1 100644 --- a/basis/io/streams/byte-array/byte-array.factor +++ b/basis/io/streams/byte-array/byte-array.factor @@ -1,5 +1,8 @@ +! Copyright (C) 2008, 2009 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. USING: byte-arrays byte-vectors kernel io.encodings io.streams.string -sequences io namespaces io.encodings.private accessors ; +sequences io namespaces io.encodings.private accessors sequences.private +io.streams.sequence destructors ; IN: io.streams.byte-array : ( encoding -- stream ) @@ -9,8 +12,16 @@ IN: io.streams.byte-array [ ] dip [ output-stream get ] compose with-output-stream* dup encoder? [ stream>> ] when >byte-array ; inline +TUPLE: byte-reader { underlying byte-array read-only } { i array-capacity } ; + +M: byte-reader stream-read-partial stream-read ; +M: byte-reader stream-read sequence-read ; +M: byte-reader stream-read1 sequence-read1 ; +M: byte-reader stream-read-until sequence-read-until ; +M: byte-reader dispose drop ; + : ( byte-array encoding -- stream ) - [ >byte-vector dup reverse-here ] dip ; + [ B{ } like 0 byte-reader boa ] dip ; : with-byte-reader ( byte-array encoding quot -- ) [ ] dip with-input-stream* ; inline diff --git a/core/checksums/crc32/crc32.factor b/core/checksums/crc32/crc32.factor index 7ea2964411..47da144d4d 100644 --- a/core/checksums/crc32/crc32.factor +++ b/core/checksums/crc32/crc32.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2006 Doug Coleman ! See http://factorcode.org/license.txt for BSD license. USING: kernel math sequences sequences.private namespaces -words io io.binary io.files io.streams.string quotations +words io io.binary io.files quotations definitions checksums ; IN: checksums.crc32 diff --git a/core/io/streams/sequence/sequence.factor b/core/io/streams/sequence/sequence.factor new file mode 100644 index 0000000000..bbb3576c05 --- /dev/null +++ b/core/io/streams/sequence/sequence.factor @@ -0,0 +1,38 @@ +! Copyright (C) 2009 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: sequences io kernel accessors math math.order ; +IN: io.streams.sequence + +SLOT: underlying +SLOT: i + +: >sequence-stream< ( stream -- i underlying ) + [ i>> ] [ underlying>> ] bi ; inline + +: next ( stream -- ) + [ 1+ ] change-i drop ; + +: sequence-read1 ( stream -- elt/f ) + [ >sequence-stream< ?nth ] + [ next ] bi ; inline + +: add-length ( n stream -- i+n ) + [ i>> + ] [ underlying>> length ] bi min ; + +: (sequence-read) ( n stream -- seq/f ) + [ add-length ] keep + [ [ swap dup ] change-i drop ] + [ underlying>> ] bi + subseq ; inline + +: sequence-read ( n stream -- seq/f ) + dup >sequence-stream< bounds-check? + [ (sequence-read) ] [ 2drop f ] if ; inline + +: find-sep ( seps stream -- sep/f n ) + swap [ >sequence-stream< ] dip + [ memq? ] curry find-from swap ; inline + +: sequence-read-until ( separators stream -- seq sep/f ) + [ find-sep ] keep + [ sequence-read ] [ next ] bi swap ; inline diff --git a/core/io/streams/string/string-tests.factor b/core/io/streams/string/string-tests.factor index a6502046c8..967c0d4613 100644 --- a/core/io/streams/string/string-tests.factor +++ b/core/io/streams/string/string-tests.factor @@ -15,12 +15,12 @@ unit-test [ "xyzzy" ] [ [ "xyzzy" write ] with-string-writer ] unit-test -[ "a" ] [ 1 SBUF" cba" stream-read ] unit-test -[ "ab" ] [ 2 SBUF" cba" stream-read ] unit-test -[ "abc" ] [ 3 SBUF" cba" stream-read ] unit-test -[ "abc" ] [ 4 SBUF" cba" stream-read ] unit-test +[ "a" ] [ 1 "abc" stream-read ] unit-test +[ "ab" ] [ 2 "abc" stream-read ] unit-test +[ "abc" ] [ 3 "abc" stream-read ] unit-test +[ "abc" ] [ 4 "abc" stream-read ] unit-test [ "abc" f ] [ - 3 SBUF" cba" [ stream-read ] keep stream-read1 + 3 "abc" [ stream-read ] keep stream-read1 ] unit-test [ diff --git a/core/io/streams/string/string.factor b/core/io/streams/string/string.factor index 4582490726..73bf5f5efe 100644 --- a/core/io/streams/string/string.factor +++ b/core/io/streams/string/string.factor @@ -1,18 +1,12 @@ -! Copyright (C) 2003, 2009 Slava Pestov. +! Copyright (C) 2003, 2009 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. USING: accessors io kernel math namespaces sequences sbufs -strings generic splitting continuations destructors -io.streams.plain io.encodings math.order growable ; +strings generic splitting continuations destructors sequences.private +io.streams.plain io.encodings math.order growable io.streams.sequence ; IN: io.streams.string > like ; - -: growable-read-until ( growable n -- str ) - >fixnum dupd tail-slice swap harden-as dup reverse-here ; - SINGLETON: null-encoding M: null-encoding decode-char drop stream-read1 ; @@ -32,34 +26,18 @@ M: growable stream-flush drop ; swap [ output-stream get ] compose with-output-stream* >string ; inline -M: growable stream-read1 [ f ] [ pop ] if-empty ; +! New implementation -: find-last-sep ( seq seps -- n ) - swap [ memq? ] curry find-last drop ; +TUPLE: string-reader { underlying string read-only } { i array-capacity } ; -M: growable stream-read-until - [ find-last-sep ] keep over [ - [ swap 1+ growable-read-until ] 2keep [ nth ] 2keep - set-length - ] [ - [ swap drop 0 growable-read-until f like f ] keep - delete-all - ] if ; - -M: growable stream-read - [ - drop f - ] [ - [ length swap - 0 max ] keep - [ swap growable-read-until ] 2keep - set-length - ] if-empty ; - -M: growable stream-read-partial - stream-read ; +M: string-reader stream-read-partial stream-read ; +M: string-reader stream-read sequence-read ; +M: string-reader stream-read1 sequence-read1 ; +M: string-reader stream-read-until sequence-read-until ; +M: string-reader dispose drop ; : ( str -- stream ) - >sbuf dup reverse-here null-encoding ; + 0 string-reader boa null-encoding ; : with-string-reader ( str quot -- ) [ ] dip with-input-stream ; inline