From 2b05f90c7bd5ecc9edb8159c9775e5154c82d7a7 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 13 Feb 2010 12:52:32 -0800 Subject: [PATCH 001/713] io.directories: add "directory-tree-files" and "with-directory-tree-files" words --- basis/io/directories/directories-docs.factor | 8 ++++++++ basis/io/directories/directories-tests.factor | 12 ++++++++++++ basis/io/directories/directories.factor | 17 ++++++++++++++--- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/basis/io/directories/directories-docs.factor b/basis/io/directories/directories-docs.factor index 4af5ee4592..a9dcea8a8f 100644 --- a/basis/io/directories/directories-docs.factor +++ b/basis/io/directories/directories-docs.factor @@ -46,10 +46,18 @@ HELP: directory-files { $values { "path" "a pathname string" } { "seq" "a sequence of filenames" } } { $description "Outputs the contents of a directory named by " { $snippet "path" } "." } ; +HELP: directory-tree-files +{ $values { "path" "a pathname string" } { "seq" "a sequence of filenames" } } +{ $description "Outputs a sequence of all non-directory files inside the directory named by " { $snippet "path" } " and its subdirectories." } ; + HELP: with-directory-files { $values { "path" "a pathname string" } { "quot" quotation } } { $description "Calls the quotation with the directory file names on the stack and with the directory set as the " { $link current-directory } ". Restores the current directory after the quotation is called." } ; +HELP: with-directory-tree-files +{ $values { "path" "a pathname string" } { "quot" quotation } } +{ $description "Calls the quotation with the recursive directory file names on the stack and with the directory set as the " { $link current-directory } ". Restores the current directory after the quotation is called." } ; + HELP: with-directory-entries { $values { "path" "a pathname string" } { "quot" quotation } } { $description "Calls the quotation with the directory entries on the stack and with the directory set as the " { $link current-directory } ". Restores the current directory after the quotation is called." } ; diff --git a/basis/io/directories/directories-tests.factor b/basis/io/directories/directories-tests.factor index b703421b45..92e35557e2 100644 --- a/basis/io/directories/directories-tests.factor +++ b/basis/io/directories/directories-tests.factor @@ -22,6 +22,18 @@ IN: io.directories.tests ] with-directory-files ] unit-test +[ { "classes/tuple/tuple.factor" } ] [ + "resource:core" [ + "." directory-tree-files [ "classes/tuple/tuple.factor" = ] filter + ] with-directory +] unit-test + +[ { "classes/tuple/tuple.factor" } ] [ + "resource:core" [ + [ "classes/tuple/tuple.factor" = ] filter + ] with-directory-tree-files +] unit-test + [ ] [ "blahblah" temp-file dup exists? [ delete-directory ] [ drop ] if ] unit-test [ ] [ "blahblah" temp-file make-directory ] unit-test [ t ] [ "blahblah" temp-file file-info directory? ] unit-test diff --git a/basis/io/directories/directories.factor b/basis/io/directories/directories.factor index 0524398304..3158f6ca41 100644 --- a/basis/io/directories/directories.factor +++ b/basis/io/directories/directories.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2004, 2008 Slava Pestov, Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors combinators destructors io io.backend -io.encodings.binary io.files io.pathnames kernel namespaces -sequences system vocabs.loader fry ; +USING: accessors arrays combinators destructors io io.backend +io.encodings.binary io.files io.files.types io.pathnames +kernel namespaces sequences system vocabs.loader fry ; IN: io.directories : set-current-directory ( path -- ) @@ -41,12 +41,23 @@ HOOK: (directory-entries) os ( path -- seq ) : directory-files ( path -- seq ) directory-entries [ name>> ] map ; +: directory-tree-files ( path -- seq ) + dup directory-entries + [ + dup type>> +directory+ = + [ name>> [ append-path directory-tree-files ] [ [ prepend-path ] curry map ] bi ] + [ nip name>> 1array ] if + ] with map concat ; + : with-directory-entries ( path quot -- ) '[ "" directory-entries @ ] with-directory ; inline : with-directory-files ( path quot -- ) '[ "" directory-files @ ] with-directory ; inline +: with-directory-tree-files ( path quot -- ) + '[ "" directory-tree-files @ ] with-directory ; inline + ! Touching files HOOK: touch-file io-backend ( path -- ) From 72de727d0ec5319c28a00a24a2db245f354e0ae4 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 13 Feb 2010 13:35:04 -0800 Subject: [PATCH 002/713] globs: * and ? should not match path-separator --- basis/globs/globs-tests.factor | 7 ++++++- basis/globs/globs.factor | 11 +++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/basis/globs/globs-tests.factor b/basis/globs/globs-tests.factor index bdc0623d54..eceb6bab7b 100644 --- a/basis/globs/globs-tests.factor +++ b/basis/globs/globs-tests.factor @@ -1,4 +1,4 @@ -USING: tools.test globs ; +USING: tools.test globs io.pathnames ; IN: globs.tests [ f ] [ "abd" "fdf" glob-matches? ] unit-test @@ -17,3 +17,8 @@ IN: globs.tests [ f ] [ "foo." "*.{xml,txt}" glob-matches? ] unit-test [ t ] [ "foo." "*.{,xml,txt}" glob-matches? ] unit-test [ t ] [ "foo.{" "*.{" glob-matches? ] unit-test + +[ f ] [ "foo" "bar" append-path "*" glob-matches? ] unit-test +[ t ] [ "foo" "bar" append-path "*" "*" append-path glob-matches? ] unit-test +[ f ] [ "foo" "bar" append-path "foo?bar" glob-matches? ] unit-test +[ t ] [ "foo" "bar" append-path "fo?" "bar" append-path glob-matches? ] unit-test diff --git a/basis/globs/globs.factor b/basis/globs/globs.factor index cac7fd9a2f..47c8fca528 100644 --- a/basis/globs/globs.factor +++ b/basis/globs/globs.factor @@ -1,9 +1,12 @@ ! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: sequences kernel regexp.combinators strings unicode.case -peg.ebnf regexp arrays ; +USING: sequences io.pathnames kernel regexp.combinators +strings unicode.case peg.ebnf regexp arrays ; IN: globs +: not-path-separator ( -- sep ) + "[^" path-separator "]" 3append ; foldable + EBNF: Character = "\\" .:c => [[ c 1string ]] @@ -24,8 +27,8 @@ CharClass = "^"?:n Ranges:e => [[ e n [ ] when ]] AlternationBody = Concatenation:c "," AlternationBody:a => [[ a c prefix ]] | Concatenation => [[ 1array ]] -Element = "*" => [[ R/ .*/ ]] - | "?" => [[ R/ ./ ]] +Element = "*" => [[ not-path-separator ]] + | "?" => [[ not-path-separator ]] | "[" CharClass:c "]" => [[ c ]] | "{" AlternationBody:b "}" => [[ b ]] | Character From 1632fa64482c09be434bd1d086782b8e7d4f7a02 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 13 Feb 2010 13:57:58 -0800 Subject: [PATCH 003/713] io.directories: directory-tree-files should include the directories too, not just their contents --- basis/io/directories/directories-docs.factor | 2 +- basis/io/directories/directories-tests.factor | 6 ++++++ basis/io/directories/directories.factor | 7 +++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/basis/io/directories/directories-docs.factor b/basis/io/directories/directories-docs.factor index a9dcea8a8f..804a2f4a8d 100644 --- a/basis/io/directories/directories-docs.factor +++ b/basis/io/directories/directories-docs.factor @@ -48,7 +48,7 @@ HELP: directory-files HELP: directory-tree-files { $values { "path" "a pathname string" } { "seq" "a sequence of filenames" } } -{ $description "Outputs a sequence of all non-directory files inside the directory named by " { $snippet "path" } " and its subdirectories." } ; +{ $description "Outputs a sequence of all files and subdirectories inside the directory named by " { $snippet "path" } " or recursively inside its subdirectories." } ; HELP: with-directory-files { $values { "path" "a pathname string" } { "quot" quotation } } diff --git a/basis/io/directories/directories-tests.factor b/basis/io/directories/directories-tests.factor index 92e35557e2..742a927b4b 100644 --- a/basis/io/directories/directories-tests.factor +++ b/basis/io/directories/directories-tests.factor @@ -28,6 +28,12 @@ IN: io.directories.tests ] with-directory ] unit-test +[ { "classes/tuple" } ] [ + "resource:core" [ + "." directory-tree-files [ "classes/tuple" = ] filter + ] with-directory +] unit-test + [ { "classes/tuple/tuple.factor" } ] [ "resource:core" [ [ "classes/tuple/tuple.factor" = ] filter diff --git a/basis/io/directories/directories.factor b/basis/io/directories/directories.factor index 3158f6ca41..d12adc5f41 100644 --- a/basis/io/directories/directories.factor +++ b/basis/io/directories/directories.factor @@ -45,8 +45,11 @@ HOOK: (directory-entries) os ( path -- seq ) dup directory-entries [ dup type>> +directory+ = - [ name>> [ append-path directory-tree-files ] [ [ prepend-path ] curry map ] bi ] - [ nip name>> 1array ] if + [ name>> + [ append-path directory-tree-files ] + [ [ prepend-path ] curry map ] + [ prefix ] tri + ] [ nip name>> 1array ] if ] with map concat ; : with-directory-entries ( path quot -- ) From c0aee1908229c9fe7bda8aaaa46b09abe57fcb11 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 13 Feb 2010 14:15:27 -0800 Subject: [PATCH 004/713] vocabs.metadata: add "vocab-resources" word to read list of deployable resource files from a "resources.txt" file in the vocab directory. add "vocabs.metadata.resources" subvocab that expands globs and directory names in resources.txt entries --- basis/vocabs/metadata/metadata-docs.factor | 13 ++++++++++ basis/vocabs/metadata/metadata.factor | 11 +++++++- .../metadata/resources/resources-docs.factor | 26 +++++++++++++++++++ .../metadata/resources/resources-tests.factor | 19 ++++++++++++++ .../metadata/resources/resources.factor | 24 +++++++++++++++++ .../vocabs/metadata/resources/test/1/1.factor | 6 +++++ basis/vocabs/metadata/resources/test/1/bar | 0 basis/vocabs/metadata/resources/test/1/bas | 0 basis/vocabs/metadata/resources/test/1/foo | 0 .../metadata/resources/test/1/resources.txt | 3 +++ .../vocabs/metadata/resources/test/2/2.factor | 6 +++++ .../vocabs/metadata/resources/test/2/bar.wtf | 0 .../vocabs/metadata/resources/test/2/bas.ftw | 0 .../vocabs/metadata/resources/test/2/foo.wtf | 0 .../test/2/no-resources-here/zim.wtf | 0 .../metadata/resources/test/2/resources.txt | 1 + .../vocabs/metadata/resources/test/3/3.factor | 6 +++++ .../resources/test/3/resource-dir/bar | 0 .../resources/test/3/resource-dir/bas/zang | 0 .../resources/test/3/resource-dir/bas/zim | 0 .../resources/test/3/resource-dir/foo | 0 .../metadata/resources/test/3/resources.txt | 1 + 22 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 basis/vocabs/metadata/resources/resources-docs.factor create mode 100644 basis/vocabs/metadata/resources/resources-tests.factor create mode 100644 basis/vocabs/metadata/resources/resources.factor create mode 100644 basis/vocabs/metadata/resources/test/1/1.factor create mode 100644 basis/vocabs/metadata/resources/test/1/bar create mode 100644 basis/vocabs/metadata/resources/test/1/bas create mode 100644 basis/vocabs/metadata/resources/test/1/foo create mode 100644 basis/vocabs/metadata/resources/test/1/resources.txt create mode 100644 basis/vocabs/metadata/resources/test/2/2.factor create mode 100644 basis/vocabs/metadata/resources/test/2/bar.wtf create mode 100644 basis/vocabs/metadata/resources/test/2/bas.ftw create mode 100644 basis/vocabs/metadata/resources/test/2/foo.wtf create mode 100644 basis/vocabs/metadata/resources/test/2/no-resources-here/zim.wtf create mode 100644 basis/vocabs/metadata/resources/test/2/resources.txt create mode 100644 basis/vocabs/metadata/resources/test/3/3.factor create mode 100644 basis/vocabs/metadata/resources/test/3/resource-dir/bar create mode 100644 basis/vocabs/metadata/resources/test/3/resource-dir/bas/zang create mode 100644 basis/vocabs/metadata/resources/test/3/resource-dir/bas/zim create mode 100644 basis/vocabs/metadata/resources/test/3/resource-dir/foo create mode 100644 basis/vocabs/metadata/resources/test/3/resources.txt diff --git a/basis/vocabs/metadata/metadata-docs.factor b/basis/vocabs/metadata/metadata-docs.factor index 66041e249c..95c8083e0f 100644 --- a/basis/vocabs/metadata/metadata-docs.factor +++ b/basis/vocabs/metadata/metadata-docs.factor @@ -18,6 +18,11 @@ ARTICLE: "vocabs.metadata" "Vocabulary metadata" set-vocab-tags add-vocab-tags } +"Vocabulary resources:" +{ $subsections + vocab-resources + set-vocab-resources +} "Getting and setting arbitrary vocabulary metadata:" { $subsections vocab-file-contents @@ -50,3 +55,11 @@ HELP: set-vocab-tags { $values { "tags" "a sequence of strings" } { "vocab" "a vocabulary specifier" } } { $description "Stores a list of short tags classifying the vocabulary to the " { $snippet "tags.txt" } " file in the vocabulary's directory." } ; +HELP: vocab-resources +{ $values { "vocab" "a vocabulary specifier" } { "patterns" "a sequence of glob patterns" } } +{ $description "Outputs a list of glob patterns matching files that will be deployed with an application that includes " { $snippet "vocab" } ", as specified by the " { $snippet "resources.txt" } " file in the vocabulary's directory. Outputs an empty array if the file doesn't exist." } +{ $notes "The " { $vocab-link "vocabs.metadata.resources" } " vocabulary contains words that will expand the glob patterns and directory names in " { $snippet "patterns" } " and return all the matching files." } ; + +HELP: set-vocab-resources +{ $values { "patterns" "a sequence of glob patterns" } { "vocab" "a vocabulary specifier" } } +{ $description "Stores a list of glob patterns matching files that will be deployed with an application that includes " { $snippet "vocab" } " to the " { $snippet "resources.txt" } " file in the vocabulary's directory." } ; diff --git a/basis/vocabs/metadata/metadata.factor b/basis/vocabs/metadata/metadata.factor index 85a503c7f0..43c7641577 100644 --- a/basis/vocabs/metadata/metadata.factor +++ b/basis/vocabs/metadata/metadata.factor @@ -19,6 +19,15 @@ MEMO: vocab-file-contents ( vocab name -- seq ) 3append throw ] ?if ; +: vocab-resources-path ( vocab -- string ) + vocab-dir "resources.txt" append-path ; + +: vocab-resources ( vocab -- patterns ) + dup vocab-resources-path vocab-file-contents harvest ; + +: set-vocab-resources ( patterns vocab -- ) + dup vocab-resources-path set-vocab-file-contents ; + : vocab-summary-path ( vocab -- string ) vocab-dir "summary.txt" append-path ; @@ -67,4 +76,4 @@ M: vocab-link summary vocab-summary ; dup vocab-authors-path set-vocab-file-contents ; : unportable? ( vocab -- ? ) - vocab-tags "unportable" swap member? ; \ No newline at end of file + vocab-tags "unportable" swap member? ; diff --git a/basis/vocabs/metadata/resources/resources-docs.factor b/basis/vocabs/metadata/resources/resources-docs.factor new file mode 100644 index 0000000000..b4289ff388 --- /dev/null +++ b/basis/vocabs/metadata/resources/resources-docs.factor @@ -0,0 +1,26 @@ +! (c)2010 Joe Groff bsd license +USING: help.markup help.syntax kernel ; +IN: vocabs.metadata.resources + +HELP: expand-vocab-resource-files +{ $values + { "vocab" "a vocabulary specifier" } { "resource-glob-strings" "a sequence of glob patterns" } + { "filenames" "a sequence of filenames" } +} +{ $description "Matches all the glob patterns in " { $snippet "resource-glob-strings" } " to the set of files inside " { $snippet "vocab" } "'s directory and outputs a sequence containing the individual files and directories that match. Any matching directories will also have their contents recursively included in the output. The paths in the output will be relative to " { $snippet "vocab" } "'s directory." } ; + +HELP: vocab-resource-files +{ $values + { "vocab" "a vocabulary specifier" } + { "filenames" "a sequence of filenames" } +} +{ $description "Outputs a sequence containing the individual resource files and directories that match the patterns specified in " { $snippet "vocab" } "'s " { $snippet "resources.txt" } " file. Any matching directories will also have their contents recursively included in the output. The paths in the output will be relative to " { $snippet "vocab" } "'s directory." } ; + +ARTICLE: "vocabs.metadata.resources" "vocabs.metadata.resources" +"The " { $vocab-link "vocabs.metadata.resources" } " vocabulary contains words to retrieve the full list of files that match the patterns specified in a vocabulary's " { $snippet "resources.txt" } " file." +{ $subsections + vocab-resource-files + expand-vocab-resource-files +} ; + +ABOUT: "vocabs.metadata.resources" diff --git a/basis/vocabs/metadata/resources/resources-tests.factor b/basis/vocabs/metadata/resources/resources-tests.factor new file mode 100644 index 0000000000..36fd13125e --- /dev/null +++ b/basis/vocabs/metadata/resources/resources-tests.factor @@ -0,0 +1,19 @@ +! (c)2010 Joe Groff bsd license +USING: sorting tools.test vocabs.metadata.resources ; +IN: vocabs.metadata.resources.tests + +[ { "bar" "bas" "foo" } ] +[ "vocabs.metadata.resources.test.1" vocab-resource-files natural-sort ] unit-test + +[ { "bar.wtf" "foo.wtf" } ] +[ "vocabs.metadata.resources.test.2" vocab-resource-files natural-sort ] unit-test + +[ { + "resource-dir" + "resource-dir/bar" + "resource-dir/bas" + "resource-dir/bas/zang" + "resource-dir/bas/zim" + "resource-dir/buh" + "resource-dir/foo" +} ] [ "vocabs.metadata.resources.test.3" vocab-resource-files natural-sort ] unit-test diff --git a/basis/vocabs/metadata/resources/resources.factor b/basis/vocabs/metadata/resources/resources.factor new file mode 100644 index 0000000000..1da15f6b9e --- /dev/null +++ b/basis/vocabs/metadata/resources/resources.factor @@ -0,0 +1,24 @@ +! (c)2010 Joe Groff bsd license +USING: arrays fry globs io.directories io.files.info +io.pathnames kernel regexp sequences vocabs.loader +vocabs.metadata ; +IN: vocabs.metadata.resources + + + +: expand-vocab-resource-files ( vocab resource-glob-strings -- filenames ) + [ [ find-vocab-root ] [ vocab-dir ] bi append-path ] dip [ ] map '[ + _ filter-resources + [ (expand-vocab-resource) ] map concat + ] with-directory-tree-files ; + +: vocab-resource-files ( vocab -- filenames ) + dup vocab-resources expand-vocab-resource-files ; diff --git a/basis/vocabs/metadata/resources/test/1/1.factor b/basis/vocabs/metadata/resources/test/1/1.factor new file mode 100644 index 0000000000..dddc0ddd58 --- /dev/null +++ b/basis/vocabs/metadata/resources/test/1/1.factor @@ -0,0 +1,6 @@ +USING: io kernel ; +IN: vocabs.metadata.resources.test.1 + +: main ( -- ) "Resources test 1" print ; + +MAIN: main diff --git a/basis/vocabs/metadata/resources/test/1/bar b/basis/vocabs/metadata/resources/test/1/bar new file mode 100644 index 0000000000..e69de29bb2 diff --git a/basis/vocabs/metadata/resources/test/1/bas b/basis/vocabs/metadata/resources/test/1/bas new file mode 100644 index 0000000000..e69de29bb2 diff --git a/basis/vocabs/metadata/resources/test/1/foo b/basis/vocabs/metadata/resources/test/1/foo new file mode 100644 index 0000000000..e69de29bb2 diff --git a/basis/vocabs/metadata/resources/test/1/resources.txt b/basis/vocabs/metadata/resources/test/1/resources.txt new file mode 100644 index 0000000000..ce0f4c956c --- /dev/null +++ b/basis/vocabs/metadata/resources/test/1/resources.txt @@ -0,0 +1,3 @@ +foo +bar +bas diff --git a/basis/vocabs/metadata/resources/test/2/2.factor b/basis/vocabs/metadata/resources/test/2/2.factor new file mode 100644 index 0000000000..82a5a11d18 --- /dev/null +++ b/basis/vocabs/metadata/resources/test/2/2.factor @@ -0,0 +1,6 @@ +USING: io kernel ; +IN: vocabs.metadata.resources.test.2 + +: main ( -- ) "Resources test 2" print ; + +MAIN: main diff --git a/basis/vocabs/metadata/resources/test/2/bar.wtf b/basis/vocabs/metadata/resources/test/2/bar.wtf new file mode 100644 index 0000000000..e69de29bb2 diff --git a/basis/vocabs/metadata/resources/test/2/bas.ftw b/basis/vocabs/metadata/resources/test/2/bas.ftw new file mode 100644 index 0000000000..e69de29bb2 diff --git a/basis/vocabs/metadata/resources/test/2/foo.wtf b/basis/vocabs/metadata/resources/test/2/foo.wtf new file mode 100644 index 0000000000..e69de29bb2 diff --git a/basis/vocabs/metadata/resources/test/2/no-resources-here/zim.wtf b/basis/vocabs/metadata/resources/test/2/no-resources-here/zim.wtf new file mode 100644 index 0000000000..e69de29bb2 diff --git a/basis/vocabs/metadata/resources/test/2/resources.txt b/basis/vocabs/metadata/resources/test/2/resources.txt new file mode 100644 index 0000000000..8dfd81c911 --- /dev/null +++ b/basis/vocabs/metadata/resources/test/2/resources.txt @@ -0,0 +1 @@ +*.wtf diff --git a/basis/vocabs/metadata/resources/test/3/3.factor b/basis/vocabs/metadata/resources/test/3/3.factor new file mode 100644 index 0000000000..a81fd707c5 --- /dev/null +++ b/basis/vocabs/metadata/resources/test/3/3.factor @@ -0,0 +1,6 @@ +USING: io kernel ; +IN: vocabs.metadata.resources.test.3 + +: main ( -- ) "Resources test 3" print ; + +MAIN: main diff --git a/basis/vocabs/metadata/resources/test/3/resource-dir/bar b/basis/vocabs/metadata/resources/test/3/resource-dir/bar new file mode 100644 index 0000000000..e69de29bb2 diff --git a/basis/vocabs/metadata/resources/test/3/resource-dir/bas/zang b/basis/vocabs/metadata/resources/test/3/resource-dir/bas/zang new file mode 100644 index 0000000000..e69de29bb2 diff --git a/basis/vocabs/metadata/resources/test/3/resource-dir/bas/zim b/basis/vocabs/metadata/resources/test/3/resource-dir/bas/zim new file mode 100644 index 0000000000..e69de29bb2 diff --git a/basis/vocabs/metadata/resources/test/3/resource-dir/foo b/basis/vocabs/metadata/resources/test/3/resource-dir/foo new file mode 100644 index 0000000000..e69de29bb2 diff --git a/basis/vocabs/metadata/resources/test/3/resources.txt b/basis/vocabs/metadata/resources/test/3/resources.txt new file mode 100644 index 0000000000..c27d538826 --- /dev/null +++ b/basis/vocabs/metadata/resources/test/3/resources.txt @@ -0,0 +1 @@ +resource-dir From 8a4fb8cbcec5d28430e89ab7c6302366d21c81a5 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 13 Feb 2010 18:06:48 -0800 Subject: [PATCH 005/713] gpu.textures: add symbolic constants for LATC compression --- extra/gpu/textures/textures-docs.factor | 6 +++++- extra/gpu/textures/textures.factor | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/extra/gpu/textures/textures-docs.factor b/extra/gpu/textures/textures-docs.factor index ffac0bc29b..09906d623a 100644 --- a/extra/gpu/textures/textures-docs.factor +++ b/extra/gpu/textures/textures-docs.factor @@ -335,12 +335,16 @@ HELP: compressed-texture-format { { $link DXT1-RGBA } } { { $link DXT3 } } { { $link DXT5 } } +{ { $link LATC1 } } +{ { $link LATC1-SIGNED } } +{ { $link LATC2 } } +{ { $link LATC2-SIGNED } } { { $link RGTC1 } } { { $link RGTC1-SIGNED } } { { $link RGTC2 } } { { $link RGTC2-SIGNED } } } } -{ $notes "The " { $snippet "DXT1" } " formats require either the " { $snippet "GL_EXT_texture_compression_s3tc" } " or " { $snippet "GL_EXT_texture_compression_dxt1" } " extension. The other " { $snippet "DXT" } " formats require the " { $snippet "GL_EXT_texture_compression_s3tc" } " extension. The " { $snippet "RGTC" } " formats require OpenGL 3.0 or later or the " { $snippet "GL_EXT_texture_compression_rgtc" } " extension." } ; +{ $notes "The " { $snippet "DXT1" } " formats require either the " { $snippet "GL_EXT_texture_compression_s3tc" } " or " { $snippet "GL_EXT_texture_compression_dxt1" } " extension. The other " { $snippet "DXT" } " formats require the " { $snippet "GL_EXT_texture_compression_s3tc" } " extension. The " { $snippet "LATC" } " formats require the " { $snippet "GL_EXT_texture_compression_latc" } " extension. The " { $snippet "RGTC" } " formats require OpenGL 3.0 or later or the " { $snippet "GL_EXT_texture_compression_rgtc" } " extension." } ; HELP: compressed-texture-data { $class-description { $snippet "compressed-texture-data" } " tuples are used to feed compressed texture data to " { $link allocate-compressed-texture } " and " { $link update-compressed-texture } "." diff --git a/extra/gpu/textures/textures.factor b/extra/gpu/textures/textures.factor index e1afc20f88..132e4303e7 100644 --- a/extra/gpu/textures/textures.factor +++ b/extra/gpu/textures/textures.factor @@ -51,6 +51,7 @@ UNION: ?float-array float-array POSTPONE: f ; VARIANT: compressed-texture-format DXT1-RGB DXT1-RGBA DXT3 DXT5 + LATC1 LATC1-SIGNED LATC2 LATC2-SIGNED RGTC1 RGTC1-SIGNED RGTC2 RGTC2-SIGNED ; TUPLE: compressed-texture-data From 072dd3b0d077b104e829709880f97976394bbd31 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 14 Feb 2010 09:59:36 -0800 Subject: [PATCH 006/713] vocabs.metadata.resources: don't try to expand resource patterns for vocabs without a resources.txt --- basis/vocabs/metadata/resources/resources.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basis/vocabs/metadata/resources/resources.factor b/basis/vocabs/metadata/resources/resources.factor index 1da15f6b9e..e37bdc273f 100644 --- a/basis/vocabs/metadata/resources/resources.factor +++ b/basis/vocabs/metadata/resources/resources.factor @@ -21,4 +21,5 @@ PRIVATE> ] with-directory-tree-files ; : vocab-resource-files ( vocab -- filenames ) - dup vocab-resources expand-vocab-resource-files ; + dup vocab-resources + [ drop f ] [ expand-vocab-resource-files ] if-empty ; From 9c77d7bde8d4dbd4dc3950895efd0b106c18df72 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 14 Feb 2010 11:29:37 -0800 Subject: [PATCH 007/713] have tools.deploy.shaker write a manifest of loaded vocabs to a file. have tools.deploy.backend read in this manifest. have tools.deploy.macosx copy resources for the manifest vocabs to the deployed bundle --- basis/tools/deploy/backend/backend.factor | 23 ++++++------ basis/tools/deploy/macosx/macosx.factor | 2 +- basis/tools/deploy/shaker/shaker.factor | 35 +++++++++++-------- .../metadata/resources/resources.factor | 22 +++++++++++- 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/basis/tools/deploy/backend/backend.factor b/basis/tools/deploy/backend/backend.factor index fe8049e9e3..9d6b8d4c08 100644 --- a/basis/tools/deploy/backend/backend.factor +++ b/basis/tools/deploy/backend/backend.factor @@ -7,21 +7,15 @@ summary layouts vocabs.loader prettyprint.config prettyprint debugger io.streams.c io.files io.files.temp io.pathnames io.directories io.directories.hierarchy io.backend quotations io.launcher tools.deploy.config tools.deploy.config.editor bootstrap.image -io.encodings.utf8 destructors accessors hashtables ; +io.encodings.utf8 destructors accessors hashtables +vocabs.metadata.resources ; IN: tools.deploy.backend : copy-vm ( executable bundle-name -- vm ) prepend-path vm over copy-file ; -CONSTANT: theme-path "basis/ui/gadgets/theme/" - -: copy-theme ( name dir -- ) - deploy-ui? get [ - append-path - theme-path append-path - [ make-directories ] - [ theme-path "resource:" prepend swap copy-tree ] bi - ] [ 2drop ] if ; +: copy-resources ( manifest name dir -- ) + append-path swap [ copy-vocab-resources ] with each ; : image-name ( vocab bundle-name -- str ) prepend-path ".image" append ; @@ -89,7 +83,7 @@ DEFER: ?make-staging-image [ "deploy-config-" prepend temp-file ] bi [ utf8 set-file-contents ] keep ; -: deploy-command-line ( image vocab config -- flags ) +: deploy-command-line ( image vocab manifest-file config -- flags ) [ bootstrap-profile ?make-staging-image @@ -97,6 +91,7 @@ DEFER: ?make-staging-image "-i=" bootstrap-profile staging-image-name append , "-resource-path=" "" resource-path append , "-run=tools.deploy.shaker" , + "-vocab-manifest-out=" prepend , [ "-deploy-vocab=" prepend , ] [ make-deploy-config "-deploy-config=" prepend , ] bi "-output-image=" prepend , @@ -104,8 +99,10 @@ DEFER: ?make-staging-image ] { } make ] bind ; -: make-deploy-image ( vm image vocab config -- ) +: make-deploy-image ( vm image vocab config -- manifest ) make-boot-image - deploy-command-line run-factor ; + over "vocab-manifest-" prepend temp-file + [ swap deploy-command-line run-factor ] + [ utf8 file-lines ] bi ; HOOK: deploy* os ( vocab -- ) diff --git a/basis/tools/deploy/macosx/macosx.factor b/basis/tools/deploy/macosx/macosx.factor index f753e38fb2..bec3e78cbd 100644 --- a/basis/tools/deploy/macosx/macosx.factor +++ b/basis/tools/deploy/macosx/macosx.factor @@ -46,7 +46,6 @@ IN: tools.deploy.macosx [ copy-dll ] [ copy-nib ] [ "Contents/Resources" append-path make-directories ] - [ "Contents/Resources" copy-theme ] } cleave ] [ create-app-plist ] @@ -72,6 +71,7 @@ M: macosx deploy* ( vocab -- ) [ bundle-name create-app-dir ] keep [ bundle-name deploy.app-image ] keep namespace make-deploy-image + bundle-name "Contents/Resources" copy-resources bundle-name show-in-finder ] bind ] with-directory ; diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index 5897712a02..e020980233 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -1,11 +1,11 @@ ! Copyright (C) 2007, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays accessors io.backend io.streams.c init fry -namespaces math make assocs kernel parser parser.notes lexer -strings.parser vocabs sequences sequences.deep sequences.private -words memory kernel.private continuations io vocabs.loader -system strings sets vectors quotations byte-arrays sorting -compiler.units definitions generic generic.standard +USING: arrays accessors io.backend io.encodings.utf8 io.files +io.streams.c init fry namespaces math make assocs kernel parser +parser.notes lexer strings.parser vocabs sequences sequences.deep +sequences.private words memory kernel.private continuations io +vocabs.loader system strings sets vectors quotations byte-arrays +sorting compiler.units definitions generic generic.standard generic.single tools.deploy.config combinators classes classes.builtin slots.private grouping command-line ; QUALIFIED: bootstrap.stage2 @@ -465,7 +465,8 @@ SYMBOL: deploy-vocab : startup-stripper ( -- ) t "quiet" set-global - f output-stream set-global ; + f output-stream set-global + V{ "resource:" } clone vocab-roots set-global ; : next-method* ( method -- quot ) [ "method-class" word-prop ] @@ -501,7 +502,12 @@ SYMBOL: deploy-vocab "Clearing megamorphic caches" show [ clear-megamorphic-cache ] each ; -: strip ( -- ) +: write-vocab-manifest ( vocab-manifest-out -- ) + "Writing vocabulary manifest to " write dup print flush + vocabs swap utf8 set-file-lines ; + +: strip ( vocab-manifest-out -- ) + [ write-vocab-manifest ] when* startup-stripper strip-libc strip-destructors @@ -535,7 +541,7 @@ SYMBOL: deploy-vocab 1 exit ] recover ; inline -: (deploy) ( final-image vocab config -- ) +: (deploy) ( final-image vocab-manifest-out vocab config -- ) #! Does the actual work of a deployment in the slave #! stage2 image [ @@ -548,11 +554,11 @@ SYMBOL: deploy-vocab "ui.debugger" require ] when ] unless - deploy-vocab set - deploy-vocab get require - deploy-vocab get vocab-main [ - "Vocabulary has no MAIN: word." print flush 1 exit - ] unless + [ deploy-vocab set ] [ require ] [ + vocab-main [ + "Vocabulary has no MAIN: word." print flush 1 exit + ] unless + ] tri strip "Saving final image" show save-image-and-exit @@ -561,6 +567,7 @@ SYMBOL: deploy-vocab : do-deploy ( -- ) "output-image" get + "vocab-manifest-out" get "deploy-vocab" get "Deploying " write dup write "..." print "deploy-config" get parse-file first diff --git a/basis/vocabs/metadata/resources/resources.factor b/basis/vocabs/metadata/resources/resources.factor index e37bdc273f..62036be408 100644 --- a/basis/vocabs/metadata/resources/resources.factor +++ b/basis/vocabs/metadata/resources/resources.factor @@ -5,6 +5,7 @@ vocabs.metadata ; IN: vocabs.metadata.resources +: vocab-dir-in-root ( vocab -- dir ) + [ find-vocab-root ] [ vocab-dir ] bi append-path ; + : expand-vocab-resource-files ( vocab resource-glob-strings -- filenames ) - [ [ find-vocab-root ] [ vocab-dir ] bi append-path ] dip [ ] map '[ + [ vocab-dir-in-root ] dip [ ] map '[ _ filter-resources [ (expand-vocab-resource) ] map concat ] with-directory-tree-files ; @@ -23,3 +34,12 @@ PRIVATE> : vocab-resource-files ( vocab -- filenames ) dup vocab-resources [ drop f ] [ expand-vocab-resource-files ] if-empty ; + +: copy-vocab-resources ( dir vocab -- ) + dup vocab-resource-files + [ 2drop ] [ + [ [ vocab-dir append-path P ] [ vocab-dir-in-root P ] bi ] dip + [ 2drop make-directories ] + [ [ copy-vocab-resource ] with with each ] 3bi + ] if-empty ; + From 5f0855c5c25c59a59d67a4335df47f311f6dbe93 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 14 Feb 2010 11:49:33 -0800 Subject: [PATCH 008/713] globs: add "glob-parent-directory" word that returns the deepest level of a path without glob symbols --- basis/globs/globs-tests.factor | 18 +++++++++++++++++- basis/globs/globs.factor | 7 +++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/basis/globs/globs-tests.factor b/basis/globs/globs-tests.factor index eceb6bab7b..c9903b1633 100644 --- a/basis/globs/globs-tests.factor +++ b/basis/globs/globs-tests.factor @@ -1,4 +1,4 @@ -USING: tools.test globs io.pathnames ; +USING: arrays tools.test globs io.pathnames sequences ; IN: globs.tests [ f ] [ "abd" "fdf" glob-matches? ] unit-test @@ -22,3 +22,19 @@ IN: globs.tests [ t ] [ "foo" "bar" append-path "*" "*" append-path glob-matches? ] unit-test [ f ] [ "foo" "bar" append-path "foo?bar" glob-matches? ] unit-test [ t ] [ "foo" "bar" append-path "fo?" "bar" append-path glob-matches? ] unit-test + +[ f ] [ "foo" glob-pattern? ] unit-test +[ t ] [ "fo?" glob-pattern? ] unit-test +[ t ] [ "fo*" glob-pattern? ] unit-test +[ t ] [ "fo[mno]" glob-pattern? ] unit-test +[ t ] [ "fo\\*" glob-pattern? ] unit-test +[ t ] [ "fo{o,bro}" glob-pattern? ] unit-test + +"foo" "bar" append-path 1array +[ { "foo" "bar" "ba?" } path-separator join glob-parent-directory ] unit-test + +[ "foo" ] +[ { "foo" "b?r" "bas" } path-separator join glob-parent-directory ] unit-test + +[ "" ] +[ { "f*" "bar" "bas" } path-separator join glob-parent-directory ] unit-test diff --git a/basis/globs/globs.factor b/basis/globs/globs.factor index 47c8fca528..72b686c3b1 100644 --- a/basis/globs/globs.factor +++ b/basis/globs/globs.factor @@ -43,3 +43,10 @@ Main = Concatenation End : glob-matches? ( input glob -- ? ) [ >case-fold ] bi@ matches? ; + +: glob-pattern? ( string -- ? ) + [ "\\*?[{" member? ] any? ; + +: glob-parent-directory ( glob -- parent-directory ) + path-components dup [ glob-pattern? ] find drop head + path-separator join ; From 281ddf5b27a0f00141f1c0b8499e4f885cca71c1 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 14 Feb 2010 12:08:13 -0800 Subject: [PATCH 009/713] remove debug output from vocab.metadata.resources --- basis/vocabs/metadata/resources/resources.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/vocabs/metadata/resources/resources.factor b/basis/vocabs/metadata/resources/resources.factor index 62036be408..d8f9bdcffd 100644 --- a/basis/vocabs/metadata/resources/resources.factor +++ b/basis/vocabs/metadata/resources/resources.factor @@ -38,7 +38,7 @@ PRIVATE> : copy-vocab-resources ( dir vocab -- ) dup vocab-resource-files [ 2drop ] [ - [ [ vocab-dir append-path P ] [ vocab-dir-in-root P ] bi ] dip + [ [ vocab-dir append-path ] [ vocab-dir-in-root ] bi ] dip [ 2drop make-directories ] [ [ copy-vocab-resource ] with with each ] 3bi ] if-empty ; From eb875e1e7845831045ef60be208ef7b6205e7558 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 14 Feb 2010 12:42:03 -0800 Subject: [PATCH 010/713] create a real "ui.gadgets.theme" vocab, move theme-image word into it, and add theme images to resources.txt --- basis/ui/gadgets/buttons/buttons.factor | 6 +++--- basis/ui/gadgets/corners/corners.factor | 4 ++-- basis/ui/gadgets/search-tables/search-tables.factor | 4 ++-- basis/ui/gadgets/sliders/sliders.factor | 2 +- basis/ui/gadgets/tabbed/tabbed.factor | 5 +++-- basis/ui/gadgets/theme/authors.txt | 1 + basis/ui/gadgets/theme/resources.txt | 1 + basis/ui/gadgets/theme/theme.factor | 6 ++++++ basis/ui/pens/image/image.factor | 2 -- 9 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 basis/ui/gadgets/theme/resources.txt create mode 100644 basis/ui/gadgets/theme/theme.factor diff --git a/basis/ui/gadgets/buttons/buttons.factor b/basis/ui/gadgets/buttons/buttons.factor index 061fd8d364..d0d25a0630 100644 --- a/basis/ui/gadgets/buttons/buttons.factor +++ b/basis/ui/gadgets/buttons/buttons.factor @@ -5,9 +5,9 @@ colors.constants combinators combinators.short-circuit combinators.smart fry kernel locals math math.rectangles math.vectors models namespaces opengl opengl.gl quotations sequences strings ui.commands ui.gadgets ui.gadgets.borders -ui.gadgets.labels ui.gadgets.packs ui.gadgets.tracks -ui.gadgets.worlds ui.gestures ui.pens ui.pens.image -ui.pens.solid ui.pens.tile ; +ui.gadgets.labels ui.gadgets.packs ui.gadgets.theme +ui.gadgets.tracks ui.gadgets.worlds ui.gestures ui.pens +ui.pens.image ui.pens.solid ui.pens.tile ; FROM: models => change-model ; IN: ui.gadgets.buttons diff --git a/basis/ui/gadgets/corners/corners.factor b/basis/ui/gadgets/corners/corners.factor index 7f558fca19..31b7d5db2e 100644 --- a/basis/ui/gadgets/corners/corners.factor +++ b/basis/ui/gadgets/corners/corners.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel sequences namespaces ui.gadgets.frames -ui.pens.image ui.gadgets.icons ui.gadgets.grids ; +ui.pens.image ui.gadgets.icons ui.gadgets.grids ui.gadgets.theme ; IN: ui.gadgets.corners CONSTANT: @center { 1 1 } @@ -40,4 +40,4 @@ SYMBOL: name : make-corners ( class name quot -- corners ) [ [ [ 3 3 ] dip new-frame { 1 1 } >>filled-cell ] dip name ] dip - with-variable ; inline \ No newline at end of file + with-variable ; inline diff --git a/basis/ui/gadgets/search-tables/search-tables.factor b/basis/ui/gadgets/search-tables/search-tables.factor index dd2232df60..1da137270a 100644 --- a/basis/ui/gadgets/search-tables/search-tables.factor +++ b/basis/ui/gadgets/search-tables/search-tables.factor @@ -3,7 +3,7 @@ USING: accessors kernel delegate fry sequences models combinators.short-circuit models.search models.delay calendar locals ui.gestures ui.pens ui.pens.image ui.gadgets.editors ui.gadgets.labels -ui.gadgets.scrollers ui.gadgets.tables ui.gadgets.tracks +ui.gadgets.scrollers ui.gadgets.tables ui.gadgets.theme ui.gadgets.tracks ui.gadgets.borders ui.gadgets.buttons ui.baseline-alignment ui.gadgets ; IN: ui.gadgets.search-tables @@ -78,4 +78,4 @@ CONSULT: table-protocol search-table table>> ; M: search-table model-changed nip field>> clear-search-field ; -M: search-table focusable-child* field>> ; \ No newline at end of file +M: search-table focusable-child* field>> ; diff --git a/basis/ui/gadgets/sliders/sliders.factor b/basis/ui/gadgets/sliders/sliders.factor index b98a0d152e..6851ff4be7 100644 --- a/basis/ui/gadgets/sliders/sliders.factor +++ b/basis/ui/gadgets/sliders/sliders.factor @@ -4,7 +4,7 @@ USING: accessors arrays assocs kernel math namespaces sequences vectors models models.range math.vectors math.functions quotations colors colors.constants math.rectangles fry combinators ui.gestures ui.pens ui.gadgets ui.gadgets.buttons ui.gadgets.tracks math.order -ui.gadgets.icons ui.pens.tile ui.pens.image ; +ui.gadgets.icons ui.gadgets.theme ui.pens.tile ui.pens.image ; IN: ui.gadgets.sliders TUPLE: slider < track elevator thumb saved line ; diff --git a/basis/ui/gadgets/tabbed/tabbed.factor b/basis/ui/gadgets/tabbed/tabbed.factor index 23881103a9..77ddb90270 100644 --- a/basis/ui/gadgets/tabbed/tabbed.factor +++ b/basis/ui/gadgets/tabbed/tabbed.factor @@ -2,8 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license. USING: ui.pens ui.gadgets.tracks ui.gadgets.buttons ui.gadgets.buttons.private ui.gadgets.books ui.gadgets.packs -ui.gadgets.borders ui.gadgets.icons ui.gadgets ui.pens.image -sequences models accessors kernel colors colors.constants ; +ui.gadgets.borders ui.gadgets.icons ui.gadgets ui.gadgets.theme +ui.pens.image sequences models accessors kernel colors +colors.constants ; IN: ui.gadgets.tabbed TUPLE: tabbed-gadget < track tabs book ; diff --git a/basis/ui/gadgets/theme/authors.txt b/basis/ui/gadgets/theme/authors.txt index 1901f27a24..580f882c8d 100644 --- a/basis/ui/gadgets/theme/authors.txt +++ b/basis/ui/gadgets/theme/authors.txt @@ -1 +1,2 @@ Slava Pestov +Joe Groff diff --git a/basis/ui/gadgets/theme/resources.txt b/basis/ui/gadgets/theme/resources.txt new file mode 100644 index 0000000000..72238b4d93 --- /dev/null +++ b/basis/ui/gadgets/theme/resources.txt @@ -0,0 +1 @@ +*.tiff diff --git a/basis/ui/gadgets/theme/theme.factor b/basis/ui/gadgets/theme/theme.factor new file mode 100644 index 0000000000..ab10999021 --- /dev/null +++ b/basis/ui/gadgets/theme/theme.factor @@ -0,0 +1,6 @@ +! (c)2009, 2010 Slava Pestov, Joe Groff bsd license +USING: io.pathnames sequences ui.images ; +IN: ui.gadgets.theme + +: theme-image ( name -- image-name ) + "vocab:ui/gadgets/theme/" prepend-path ".tiff" append ; diff --git a/basis/ui/pens/image/image.factor b/basis/ui/pens/image/image.factor index da253f8b0c..be37e6e129 100644 --- a/basis/ui/pens/image/image.factor +++ b/basis/ui/pens/image/image.factor @@ -18,5 +18,3 @@ M: image-pen draw-interior M: image-pen pen-pref-dim nip image>> image-dim ; -: theme-image ( name -- image-name ) - "vocab:ui/gadgets/theme/" prepend-path ".tiff" append ; \ No newline at end of file From ad63314a9e3da465762ae72b93824dc5df342e70 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 14 Feb 2010 13:58:24 -0800 Subject: [PATCH 011/713] audio.chunked-file: inline "check-chunk" so heap-size call can be folded away and audio can be deployed --- extra/audio/chunked-file/chunked-file.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/audio/chunked-file/chunked-file.factor b/extra/audio/chunked-file/chunked-file.factor index a450790ec6..f5844a60d0 100644 --- a/extra/audio/chunked-file/chunked-file.factor +++ b/extra/audio/chunked-file/chunked-file.factor @@ -24,5 +24,5 @@ ERROR: invalid-audio-file ; } case ; : check-chunk ( chunk id class -- ? ) - heap-size [ id= ] [ [ length ] dip >= ] bi-curry* bi and ; + heap-size [ id= ] [ [ length ] dip >= ] bi-curry* bi and ; inline From 06f4a218159a4e08a0ef73180bba149cf51f41f3 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 14 Feb 2010 14:01:07 -0800 Subject: [PATCH 012/713] gpu.demos.raytrace: add deploy config and resources.txt --- extra/gpu/demos/raytrace/deploy.factor | 14 ++++++++++++++ extra/gpu/demos/raytrace/resources.txt | 4 ++++ 2 files changed, 18 insertions(+) create mode 100644 extra/gpu/demos/raytrace/deploy.factor create mode 100644 extra/gpu/demos/raytrace/resources.txt diff --git a/extra/gpu/demos/raytrace/deploy.factor b/extra/gpu/demos/raytrace/deploy.factor new file mode 100644 index 0000000000..b01a64ccbc --- /dev/null +++ b/extra/gpu/demos/raytrace/deploy.factor @@ -0,0 +1,14 @@ +USING: tools.deploy.config ; +H{ + { deploy-name "Raytrace" } + { deploy-ui? t } + { deploy-c-types? f } + { deploy-unicode? f } + { "stop-after-last-window?" t } + { deploy-io 2 } + { deploy-reflection 2 } + { deploy-word-props? f } + { deploy-math? t } + { deploy-threads? t } + { deploy-word-defs? f } +} diff --git a/extra/gpu/demos/raytrace/resources.txt b/extra/gpu/demos/raytrace/resources.txt new file mode 100644 index 0000000000..24d3bb9b79 --- /dev/null +++ b/extra/gpu/demos/raytrace/resources.txt @@ -0,0 +1,4 @@ +green-ball.aiff +mirror-ball.aiff +red-ball.aiff +yellow-ball.aiff From f02fb684cdc3b4d1e74da44fcaf21ede47014e3a Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 14 Feb 2010 14:03:19 -0800 Subject: [PATCH 013/713] add resources.txt for gpu.demos.bunny --- extra/gpu/demos/bunny/deploy.factor | 20 ++++++++++---------- extra/gpu/demos/bunny/resources.txt | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 extra/gpu/demos/bunny/resources.txt diff --git a/extra/gpu/demos/bunny/deploy.factor b/extra/gpu/demos/bunny/deploy.factor index fe80da122e..1289caadb6 100644 --- a/extra/gpu/demos/bunny/deploy.factor +++ b/extra/gpu/demos/bunny/deploy.factor @@ -1,14 +1,14 @@ USING: tools.deploy.config ; H{ - { deploy-name "gpu.demos.bunny" } - { deploy-word-defs? f } - { deploy-io 3 } - { "stop-after-last-window?" t } - { deploy-math? t } - { deploy-word-props? f } - { deploy-threads? t } - { deploy-c-types? f } - { deploy-reflection 2 } - { deploy-unicode? f } + { deploy-name "Bunny" } { deploy-ui? t } + { deploy-c-types? f } + { deploy-unicode? f } + { "stop-after-last-window?" t } + { deploy-io 3 } + { deploy-reflection 2 } + { deploy-word-props? f } + { deploy-math? t } + { deploy-threads? t } + { deploy-word-defs? f } } diff --git a/extra/gpu/demos/bunny/resources.txt b/extra/gpu/demos/bunny/resources.txt new file mode 100644 index 0000000000..7aa9238e48 --- /dev/null +++ b/extra/gpu/demos/bunny/resources.txt @@ -0,0 +1 @@ +loading.tiff From a6bbb6dca6583c353ea4797934245b4c76742b9c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 14 Feb 2010 23:10:05 -0800 Subject: [PATCH 014/713] update unix, windows, and test deploy backends --- basis/tools/deploy/test/test.factor | 2 +- basis/tools/deploy/unix/unix.factor | 4 ++-- basis/tools/deploy/windows/windows.factor | 14 ++++++-------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/basis/tools/deploy/test/test.factor b/basis/tools/deploy/test/test.factor index d8414baba7..bc458dde36 100644 --- a/basis/tools/deploy/test/test.factor +++ b/basis/tools/deploy/test/test.factor @@ -7,7 +7,7 @@ IN: tools.deploy.test [ "test.image" temp-file delete-file ] ignore-errors "resource:" [ [ vm "test.image" temp-file ] dip - dup deploy-config make-deploy-image + dup deploy-config make-deploy-image drop ] with-directory ; ERROR: image-too-big actual-size max-size ; diff --git a/basis/tools/deploy/unix/unix.factor b/basis/tools/deploy/unix/unix.factor index f88cf06ef7..2646f2d5a4 100644 --- a/basis/tools/deploy/unix/unix.factor +++ b/basis/tools/deploy/unix/unix.factor @@ -7,7 +7,6 @@ tools.deploy.config.editor assocs hashtables prettyprint ; IN: tools.deploy.unix : create-app-dir ( vocab bundle-name -- vm ) - dup "" copy-theme copy-vm dup OCT: 755 set-file-permissions ; @@ -20,6 +19,7 @@ M: unix deploy* ( vocab -- ) [ bundle-name create-app-dir ] keep [ bundle-name image-name ] keep namespace make-deploy-image + bundle-name "" copy-resources bundle-name normalize-path [ "Binary deployed to " % % "." % ] "" make print ] bind - ] with-directory ; \ No newline at end of file + ] with-directory ; diff --git a/basis/tools/deploy/windows/windows.factor b/basis/tools/deploy/windows/windows.factor index f21f4ac363..4dad875128 100644 --- a/basis/tools/deploy/windows/windows.factor +++ b/basis/tools/deploy/windows/windows.factor @@ -16,20 +16,18 @@ IN: tools.deploy.windows : create-exe-dir ( vocab bundle-name -- vm ) dup copy-dll - deploy-ui? get [ - [ "" copy-theme ] [ ".exe" copy-vm ] bi - ] [ ".com" copy-vm ] if ; + deploy-ui? get ".exe" ".com" ? copy-vm ; M: winnt deploy* "resource:" [ dup deploy-config [ deploy-name get - [ + { [ create-exe-dir ] [ image-name ] - [ drop ] - 2tri namespace make-deploy-image - ] - [ nip open-in-explorer ] 2bi + [ drop namespace make-deploy-image ] + [ nip "" copy-resources ] + [ nip open-in-explorer ] + } 2cleave ] bind ] with-directory ; From 642d48cd0592ab20046c7b07061b43dd2ce47208 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 14 Feb 2010 23:27:48 -0800 Subject: [PATCH 015/713] gpu.demos.bunny: use images.tiff so that it's present in deployed bundle --- extra/gpu/demos/bunny/bunny.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/gpu/demos/bunny/bunny.factor b/extra/gpu/demos/bunny/bunny.factor index 987d3d1507..bee94d302a 100644 --- a/extra/gpu/demos/bunny/bunny.factor +++ b/extra/gpu/demos/bunny/bunny.factor @@ -3,8 +3,8 @@ USING: accessors alien.c-types arrays classes.struct combinators combinators.short-circuit game.loop game.worlds gpu gpu.buffers gpu.util.wasd gpu.framebuffers gpu.render gpu.shaders gpu.state gpu.textures gpu.util grouping http.client images images.loader -io io.encodings.ascii io.files io.files.temp kernel locals math -math.matrices math.vectors.simd math.parser math.vectors +images.tiff io io.encodings.ascii io.files io.files.temp kernel +locals math math.matrices math.vectors.simd math.parser math.vectors method-chains namespaces sequences splitting threads ui ui.gadgets ui.gadgets.worlds ui.pixel-formats specialized-arrays specialized-vectors literals ; From 3bdc84a07ab33fd6bccabbf5304a8d98703aa5fb Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sun, 14 Feb 2010 23:41:44 -0800 Subject: [PATCH 016/713] Fix D3D9 constants that I punted on calculating initially. --- .../directx/d3d9types/d3d9types.factor | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/basis/windows/directx/d3d9types/d3d9types.factor b/basis/windows/directx/d3d9types/d3d9types.factor index 9f4358f658..dc02849553 100644 --- a/basis/windows/directx/d3d9types/d3d9types.factor +++ b/basis/windows/directx/d3d9types/d3d9types.factor @@ -900,12 +900,6 @@ CONSTANT: D3DMULTISAMPLE_14_SAMPLES 14 CONSTANT: D3DMULTISAMPLE_15_SAMPLES 15 CONSTANT: D3DMULTISAMPLE_16_SAMPLES 16 CONSTANT: D3DMULTISAMPLE_FORCE_DWORD HEX: 7fffffff - -:: MAKEFOURCC ( ch0 ch1 ch2 ch3 -- n ) - ch3 HEX: ff bitand 24 shift - ch2 HEX: ff bitand 16 shift - ch1 HEX: ff bitand 8 shift - ch0 HEX: ff bitand bitor bitor bitor ; inline TYPEDEF: int D3DFORMAT CONSTANT: D3DFMT_UNKNOWN 0 @@ -937,15 +931,15 @@ CONSTANT: D3DFMT_X8L8V8U8 62 CONSTANT: D3DFMT_Q8W8V8U8 63 CONSTANT: D3DFMT_V16U16 64 CONSTANT: D3DFMT_A2W10V10U10 67 -#! : D3DFMT_UYVY ( -- n ) 'U' 'Y' 'V' 'Y' MAKEFOURCC -#! D3DFMT_R8G8_B8G8 = MAKEFOURCC('R', 'G', 'B', 'G'), -#! D3DFMT_YUY2 = MAKEFOURCC('Y', 'U', 'Y', '2'), -#! D3DFMT_G8R8_G8B8 = MAKEFOURCC('G', 'R', 'G', 'B'), -#! D3DFMT_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'), -#! D3DFMT_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'), -#! D3DFMT_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'), -#! D3DFMT_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'), -#! D3DFMT_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'), +CONSTANT: D3DFMT_UYVY HEX: 55595659 +CONSTANT: D3DFMT_R8G8_B8G8 HEX: 52474247 +CONSTANT: D3DFMT_YUY2 HEX: 59555932 +CONSTANT: D3DFMT_G8R8_G8B8 HEX: 47524742 +CONSTANT: D3DFMT_DXT1 HEX: 44585431 +CONSTANT: D3DFMT_DXT2 HEX: 44585432 +CONSTANT: D3DFMT_DXT3 HEX: 44585433 +CONSTANT: D3DFMT_DXT4 HEX: 44585434 +CONSTANT: D3DFMT_DXT5 HEX: 44585435 CONSTANT: D3DFMT_D16_LOCKABLE 70 CONSTANT: D3DFMT_D32 71 CONSTANT: D3DFMT_D15S1 73 @@ -962,7 +956,7 @@ CONSTANT: D3DFMT_VERTEXDATA 100 CONSTANT: D3DFMT_INDEX16 101 CONSTANT: D3DFMT_INDEX32 102 CONSTANT: D3DFMT_Q16W16V16U16 110 -#! D3DFMT_MULTI2_ARGB8 = MAKEFOURCC('M', 'E', 'T', '1'), +CONSTANT: D3DFMT_MULTI2_ARGB8 HEX: 4d455431 CONSTANT: D3DFMT_R16F 111 CONSTANT: D3DFMT_G16R16F 112 CONSTANT: D3DFMT_A16B16G16R16F 113 From 45c85d1851544225c5ffc8b9134b2a4e7e8406d0 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 14 Feb 2010 23:55:38 -0800 Subject: [PATCH 017/713] update vocabs and deploy docs to mention resources.txt --- basis/tools/deploy/deploy-docs.factor | 4 ++++ core/vocabs/loader/loader-docs.factor | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/basis/tools/deploy/deploy-docs.factor b/basis/tools/deploy/deploy-docs.factor index 948db1c833..2cbb2869de 100644 --- a/basis/tools/deploy/deploy-docs.factor +++ b/basis/tools/deploy/deploy-docs.factor @@ -7,8 +7,12 @@ ARTICLE: "prepare-deploy" "Preparing to deploy an application" { $subsections "deploy-config" "deploy-flags" + "deploy-resources" } ; +ARTICLE: "deploy-resources" "Deployed resource files" +"To include additional files in your deployed application, specify their names in a vocabulary's " { $snippet "resources.txt" } " file. The " { $snippet "resources.txt" } " file contains one glob pattern per line. These patterns are expanded relative to the vocabulary directory; files outside of the vocabulary directory cannot be referenced. If a file inside the vocabulary directory matches any of these patterns, it will be included in deployed applications that reference the vocabulary. If a subdirectory matches, its contents will be included recursively." ; + ARTICLE: "tools.deploy.usage" "Deploy tool usage" "Once the necessary deployment flags have been set, the application can be deployed:" { $subsections deploy } diff --git a/core/vocabs/loader/loader-docs.factor b/core/vocabs/loader/loader-docs.factor index 7d00cbe2ad..7db3cdd5c2 100644 --- a/core/vocabs/loader/loader-docs.factor +++ b/core/vocabs/loader/loader-docs.factor @@ -45,11 +45,12 @@ $nl { { $snippet "foo/bar/bar-docs.factor" } " - documentation, see " { $link "writing-help" } } { { $snippet "foo/bar/bar-tests.factor" } " - unit tests, see " { $link "tools.test" } } } -"Finally, optional three text files may contain meta-data:" +"Finally, four optional text files may contain metadata:" { $list - { { $snippet "foo/bar/authors.txt" } " - a series of lines, with one author name per line. These are listed under " { $link "vocab-authors" } } - { { $snippet "foo/bar/summary.txt" } " - a one-line description" } - { { $snippet "foo/bar/tags.txt" } " - a whitespace-separated list of tags which classify the vocabulary. Consult " { $link "vocab-tags" } " for a list of existing tags you can re-use" } + { { $snippet "foo/bar/authors.txt" } " - a series of lines, with one author name per line. These are listed under " { $link "vocab-authors" } "." } + { { $snippet "foo/bar/resources.txt" } " - a series of lines with one file glob pattern per line. Files inside the vocabulary directory whose names match any of these glob patterns will be included with the compiled application as " { $link "deploy-resources" } "." } + { { $snippet "foo/bar/summary.txt" } " - a one-line description." } + { { $snippet "foo/bar/tags.txt" } " - a whitespace-separated list of tags which classify the vocabulary. Consult " { $link "vocab-tags" } " for a list of existing tags you can reuse." } } "The " { $link POSTPONE: USE: } " and " { $link POSTPONE: USING: } " words load vocabularies which have not been loaded yet, as needed." $nl From f9d6ba0339815322cf1e42065841b5a2acedfde1 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 15 Feb 2010 10:56:23 -0800 Subject: [PATCH 018/713] tools.deploy.macosx: copy "icon.icns" from deployed vocab to app bundle as app icon --- basis/tools/deploy/macosx/macosx.factor | 34 ++++++++++++++++--------- basis/vocabs/metadata/metadata.factor | 6 +++++ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/basis/tools/deploy/macosx/macosx.factor b/basis/tools/deploy/macosx/macosx.factor index bec3e78cbd..8bd3749093 100644 --- a/basis/tools/deploy/macosx/macosx.factor +++ b/basis/tools/deploy/macosx/macosx.factor @@ -6,7 +6,7 @@ sequences system tools.deploy.backend tools.deploy.config tools.deploy.config.editor assocs hashtables prettyprint io.backend.unix cocoa io.encodings.utf8 io.backend cocoa.application cocoa.classes cocoa.plists -combinators ; +combinators vocabs.metadata vocabs.loader ; IN: tools.deploy.macosx : bundle-dir ( -- dir ) @@ -16,7 +16,7 @@ IN: tools.deploy.macosx [ bundle-dir prepend-path swap ] keep "Contents" prepend-path append-path copy-tree ; -: app-plist ( executable bundle-name -- assoc ) +: app-plist ( icon? executable bundle-name -- assoc ) [ "6.0" "CFBundleInfoDictionaryVersion" set "APPL" "CFBundlePackageType" set @@ -25,9 +25,11 @@ IN: tools.deploy.macosx [ "CFBundleExecutable" set ] [ "org.factor." prepend "CFBundleIdentifier" set ] bi + + [ "Icon.icns" "CFBundleIconFile" set ] when ] H{ } make-assoc ; -: create-app-plist ( executable bundle-name -- ) +: create-app-plist ( icon? executable bundle-name -- ) [ app-plist ] keep "Contents/Info.plist" append-path write-plist ; @@ -40,16 +42,24 @@ IN: tools.deploy.macosx "Resources/English.lproj/MiniFactor.nib" copy-bundle-dir ] [ drop ] if ; +: copy-icns ( vocab bundle-name -- icon? ) + swap dup vocab-mac-icon-path vocab-append-path dup exists? + [ swap "Contents/Resources/Icon.icns" append-path copy-file t ] + [ 2drop f ] if ; + : create-app-dir ( vocab bundle-name -- vm ) - [ - nip { - [ copy-dll ] - [ copy-nib ] - [ "Contents/Resources" append-path make-directories ] - } cleave - ] - [ create-app-plist ] - [ "Contents/MacOS/" append-path copy-vm ] 2tri + { + [ + nip { + [ copy-dll ] + [ copy-nib ] + [ "Contents/Resources" append-path make-directories ] + } cleave + ] + [ copy-icns ] + [ create-app-plist ] + [ "Contents/MacOS/" append-path copy-vm ] + } 2cleave dup OCT: 755 set-file-permissions ; : deploy.app-image ( vocab bundle-name -- str ) diff --git a/basis/vocabs/metadata/metadata.factor b/basis/vocabs/metadata/metadata.factor index 43c7641577..04a0ea7546 100644 --- a/basis/vocabs/metadata/metadata.factor +++ b/basis/vocabs/metadata/metadata.factor @@ -19,6 +19,12 @@ MEMO: vocab-file-contents ( vocab name -- seq ) 3append throw ] ?if ; +: vocab-windows-icon-path ( vocab -- string ) + vocab-dir "icon.ico" append-path ; + +: vocab-mac-icon-path ( vocab -- string ) + vocab-dir "icon.icns" append-path ; + : vocab-resources-path ( vocab -- string ) vocab-dir "resources.txt" append-path ; From bfa5f5ad9b2037c8dc012212bf207754cd16920b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 15 Feb 2010 10:58:26 -0800 Subject: [PATCH 019/713] icon for gpu.demos.bunny --- extra/gpu/demos/bunny/icon.icns | Bin 0 -> 30278 bytes extra/gpu/demos/bunny/icon.ico | Bin 0 -> 9854 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 extra/gpu/demos/bunny/icon.icns create mode 100644 extra/gpu/demos/bunny/icon.ico diff --git a/extra/gpu/demos/bunny/icon.icns b/extra/gpu/demos/bunny/icon.icns new file mode 100644 index 0000000000000000000000000000000000000000..ef7ed0af6ff9a8871d8203be227168da6be3b9d1 GIT binary patch literal 30278 zcmeHv2Y6i9b>^M-ruWxofI%Bz(5JjMz*K;p5PL;$RHaCFl4I@0-pK7s9Iu_tw=SPzYi-AIV#TtP*m04Y3iiKm0E(bUkN}y_-)1%XBw*&9 zcF#TM+;jf9(7sy_-A%}Et>1T#t`XANN${Gz?CblpCGv||o8)!a98Qscb=K}7HkXSK zcj$##me_sdqq9yzgkWQfgV-hViCGIVTg?o4Zq`N2QXr`5e!}|sKcBS`k0=Rtf+r@z z6$18XuEI?0LM8dwtetoR!9Y-?4}D+@288G;)lZ1kUkL>!A{7H{5bvLx^%J`Y(xzyq z9I)VdfIK^E^3&&1*bQ2qID>(JC{#DA5wDrB4!>0W)GR{;sT5$82q+ksTMYOl5!Q)* zr-iUiuTUZVDISPYAz%@kyEPV?%!G*b(p1153`(5KLLiH)kUlW$@=8)5AO-bo)&p@C z;*Qk^rD;kR5d2P-5C_MT_d%RnECj4lbtaRq0-@Dn4$ILR>3EGpB za0KgHDh=A|$FMcT7c77nQZqRb#BLBvRUMj|j@D4oPAS;X6tEH2T}d9DWi8l4N-u*x zUt>6$c!N@1Dyej4^*S*S49G z0)9zqPUkXdSd+~wwaA15L`?*Iq8P07BSl?e6~wqK1!A#!cu_*`n1V)lh=LU49p(aI z%}xjTlUbG{TyQ!dh}9{$3KCQKyb`Xh5CZ|wli*~43kG>4g%ycLY!HSArvm<M*on@Z;i`1LtE;0e*#JK~f&t!RGuu1@EIo^4uWVNfX%}`i z*~&w**^NwMgRB#=!%0%GE}F^b;HXR%GV-mb5T=4aGd_3@dsvS!DyH43R63hh!W=T) zO8$VBGc)ptmn5;Or9Fv_&t$T>T(=THcAF&;{EuL7YqOJ?i8Px^g!v+}5+3jcPt$rL z2I~{4EL3K5-D+?OM#6Is1_-S@i1?{YA?=_6(9z~07V`KkBM`?qB)(MDp3db8SyPuX z6<|bBdLUo{Yh`t)7%+?V`79I`)Am$nM@sX7lV-P@c+Mke#p-Y(lh5b6!%$L`&R}Z; z!P-VSozK+LB2}HsO=SyEY=dIWYcQKd2jPR~krkp;)ug4{DvjzX1;EZrjao9_-3^KD z*eR(NvS%Q`Mq@>H5u0JP^HJCp2+^=8N~htPrta>pQr^_9Blat_u3~OF>wx>xsZ1+M z{9~w*PT~}?HAE_i6HrGG&eU8}N7q!I>8eKnGC{4o2xWFKrn1clLh$i!V&f4=aAW}H z1}p08n-U4REfKB=2&m00K1R}8@Hp5>MRms^$}CnV^Z5dV5iH%52^Qcpzr>r(KB=Oz zG9-kXn>$k=x1`jzh=^t2q%s7twbf$H48$}bWtoPoA;dO1liEf0QGf*8(bmS4E z5H*!C=d)USbwRRFF+n7cU2N*gL3}PZ30Wxw6(dHwO7O24vU2SO1fV%6@osC8I2>MI zO_Q3+bmbr^+m#UEXhy1l7;7-yMU5@wCa_EDG^Et#OR&gFrBo8+j*a+mdbu5zBC%V& zwR)a16f$PyKnVHAO0C^+28-B+45qsU6^yA&Ul7vaCFK3HD7&1*Lkdzo)U2nlEb6+D zcpL(PYF8m|G6Fr9D?vuHI1?~wU6WXiC6mr3tmMgAzbJZ8*;%L5pyu-VbQM_blH8rc zn_RAl6;K(~Gl;WPeyYrwt0CmWvtAMueNHP%fhQExt09{aBVCl9fUlHex@GJP6Uuc> z8#%#r*vT_ET7rVlQ6MHKKLZ5dl-jv_efk@%3(U4$xAHdiw2tfy^=orKUk5LbW( zA@pR6hGEEJ@MWtgpVSV%ncM`nDxLL_=V#609K94wA|49(*Gm1_6+=&8N_I`=C&8PA z3=0ZRD?ww#c!{6-t~QI6lwg}Bo6YB{D18U$r$A2~3Jn=wnVdTju!^->4&Ex|t#Dg+ zvKAR)(z~V&@n!N{BO!k_%X(1=PQX$rOr=}8x|3~{I1Cx7v3n*z4Y#qGq=OQ2AUqv# zbNkz*1db zUl|b32biktTXJe?Q^0`YewZPO597bh-6yb8xGIxP+UQfsY&jd_z_i1Rx$6ecr86TU86#RXhoaf-UmTs!Wl1*(o;I}+U8!qRw7e2OT zazE)HNE!m;cj9#p7Oy*Xo%o;|bj(Bb{J z-+7yNPT=`~IhZJ)3)QsJtDr3+w@Nu@wsY{~IZ8#E z^7xM{o!NEl;QoCFjvU(zY7;R(2!bqvA7ubB2pgu5Wu9z$-EDUtzH9%%V`I19W}}2G zA`786MTJtrD1M#F`O>NU;L&4;4jedgXt=ZYXsuxZM|%nk4Ow~`bymP!9mm5&j)&Nh zeRm%@eCW`z;qG**|DF{vf#oBG4j$|4S)I*uZ$7f`Kz}-iEwp5B zJ91BRIU?Nja6uQ*i6-S#j>%M^#F~Xxh@hJ6>CwY?9_UTev)GbZbLi0FiYJXs5x~ai z-N+v>bv25mKuI#Spv0B!yW{ZQ{e5YwD!uFI;Zd3_eyj-xsgy)LJ%Pwji;`UoR0L~f z%{b`|8#f#|c*ouzTEeZ_-0g?&$s38u;53E!`t(HhB;q93T2)oorlipM=d;wUlR0}f zcgN8Kx8J!M#oLnFa_rz;zNcrMI1z&tt!hlkL#J_WP0;f%lR^0?A4X+vKHYcsp}TI| zza|66rPd!hc(5A<1YNYbse_jH=`6_|H#(6*W-5Co$ESPlK74TBZ3ow7a@o%HhY^P; zURDe7cc#+mLgo~uO`#y5(@z&O6WP;0#$Cs-`GgwO*e>Mwe zWHYIrGf%wt_qXZEjzXs?l`esQCMTqG!}lIObl~Phsn zDX221lIynMr!PD5=wt7l=-GZ#Ck8UZ_{nT#F4LKUU)ItrI=FXi@4=00hmIXRv|XYn zq7VaRp|b`HPpvuf_#bUW*R2oy@q7RH;p4x5U$#SuD|C59xV$3O(LK5&mEL^#?!$)< z-g)z_hYlY&cI@aaG3%etn#87w&U`A>v2E%-Cm-3IN_QPD7Vp^E)16CoZ{Lz`O?0Hv zI3d%z-nsR69)EnZw(juJ!v_!CdF$;5jvPIDXgucyZo!fUJu`vfsw3I8X>B^)o$sX0 zdOFj2;1l2Y`!gF7F|9L|%@M~?cHFdXmEK+#j*%}wY$zCtq!8l_LUtlwN&A9qs&ifM z%9|fw**`WsuzTmmwQHj-jpQq{-o`wp>pTijCY3_JRm=%lHKRurrE~osZ5`;{b<5s6 z_S`|fHA_fwcH#nH^aZ?s9sg4N=ofQ87h*}DTln_EyLoWQVY685{xY~kY&Oj9oB=M` zftp}EbPF{#7GmMBNfU@&OuBwiXm16e;WBU~tH(!s>E~uW#DOWVQQ^@*di=B>A{Jjk zKofPgvp#GUcbM{Gp!+z;C%L!1S`i0g3pQJ*=+UtD6r%rULR(0E}U$e z1D3p%{ItOGpehoU&gLJOWgH%Vfwu@zMW#5Gh1kO(fu9nrqR8`JI*YRypD`z6By#h- zz*Q)UDuL2!VS|nJ75piI@l!I!O;IIK`6yLHRg|_es^n{EYN;0Z6M_>W{lF$LlVN^< zckG}PxMq;X%w=ErgyyE^mN3ts6dYo8-5l{_bcwE_z(8z4G5JA@UGQ*$XlqNn3FbmJ zCsfz?F_GH^z)Fk-kda|gysaswM5`d($qN-#680RnJVcuT3s2>@ zXpr9o1|Tv{cs-PewYDj0bAUT3n0X=GCSajpIX}zzh_f`u!8FnCkuz9$e<%@eYm2FJ zV-R}GTvei#r;R=UC6+j_^@4+!;#jkaX4t@!oI-(j`$I7~+7^{{ImFZT@IrGZ(wkVk z$ z;NgWvRgTAEaam~)xKo0ord^LyTm68OoC0zCy&jj-$?+u)=;H-2iSUzxm**Q)C6S27 z5^A)TuGGZ~!El|3t+4t5Bw2v~xm_$Nni-4DUbGf0lf=xr9Ay}Zc&DJA56g;74N$b! zPysT0Jcj`erdt491vv*>AXdb;+w1dB^ERIs|9GtCB4KP4JYpQgJ0tkHinyjI5EECm z*6NUiNVbW*8&X(%kyz|*FUJd~cp3(kvG&%QkQe#K*eGVic!={jJ`Xg)d5U3(uE!#= z8tO-pr>L#j?)Jlh1gSK^dpN0~O_mdioM;dGkt`;=fxxo169Na@Lyd|CF$qQ0^rYT! zQm`TQoYa8x*r%G9subly!XhVHLS8K6575n6iC3h~M$fsb6k-ThibA-oP0D1tN(d>VKR+?Z0wjx#Z)(OFi4MsKM&mxQ&sWL$Gs9Kv=3bGa39F4W2@I3~L z9muhB)Z&V&76n0-tm2B0J_eNY-xek0)g`t{DeO(m}2^r#^}{F z(Zsf7Y0hpLBPFmTGmjI%3Bjm!1Y_G zsW2v)5T_uj5u#=kCZRM?T!{@zUVDi+EN)LlZA)C%5r%GA(Odj9IJr4Ntf=T(31W)6 zDcL>^_lC47l|eL@6y%8_&4Wumzum?biOuW`wraYf7O5{4(OcwAeq%eWk)%dTTtPKy zT0v*EWIYFYlA=u_!ihQoh8TQ44>P&k^t2Fbqj4+}Wk?Yq3$+dz1#e01$)aYa)m@#y zE{3@ofoV@d)HK8>%@$xyfLf`mSQ}r3Xx9>gcald+fw?tV(g;l}%1kQ2D#>~g>!LO& z73G0H==Y#J+1yg36+zEU@D@~%8l9?x+5%j{0GkGHP(@HvURI9U<}fFx4ef!=#rX|B zE~IKy6I7N|1|foVb2Z6naM9yJsVa9UArVE6WWBz=*`@5nkzH&((5SFWcCs#t&>HxAY4e%)hR?MtEoX`0~^;h zy=)9CCp@4=3cI-yA_;lJg`(=TW>K|dlpcMisD1*HiwXl+&cK*Fh*J|i=~#}hQYSTw zo{U8T+zG@=U9zB=bmZA2Wr*6r0Gn~Jlqkof;EEw8P)sx>EOMu@4GH}u)=*SfHAH;^ zcMy+&+Tmyfl@hDL*92!FHv+i?E2N}M%w|y9h*v>Q0gCQ6T8v&33>{=))^O&dFk&(Uibz>^IhGdQCs^+_;T%1y;b z&@Z@%`zh2G#5VE_YoS{JjR`cJK$8giNBTINr1^sq1Gz{hh1Ia-cHw&Ks28X$l|^kDv1zOn-PMO@3;3F_z&|CB_(^Ch8pZ&aHIOJ9G7W}eKTklK z@l00c&?qsP4QZO_9`KqCObQ(k{i^9n z>@NtYQahe2J4Zt#_#tc&ap8n6;5oxJB&W2AGJ%{K9#$zn1p=Qz@F2=I&z++YM5#)e zgNoTY(zn3{wBZ8T{Q}z6U~{yksgmw>K*2s2;DMrQOZ1El?COm#q-JUw)k4zL(M|)S zE_s{=9Hq7^9Ye$YyLxxHJ_PjJuz`m_v)E#sLZkwb(4IUCPdJst#<9V^-u{s=@RbX+ zXK0{xOlc&D-vX+B8bV!)vTk&+zi(hAv z4-NDWjc?t(-Au71Gkj&@5UD80NN37n<{QCLKn`-$^V-I-v7y0%k)h48^}|8KB7`d~ z92gU2MmHF>!9AnH!=qy(>ydUlMpuH5L3dw5!7=lJcoOSC<)`M>A^gkA^nu~Qp|PG^ zC(5s)^o~)~4At6;5Sv1{`x}!*)C@)mpkOe36=Hh=ezqqz5A~02Kr2L}FEun$)??wkW$s#_Pa|A;(4=3@k4k*HO7~kf^AzsO5;@B3wFYg!q=>zJc{h z!AOVn@X(O(BuzdK)yYPasxqyXD5qYBQi=W_VNkE1fg-EYJKWpfQ|6S{jgD+Yc0#Fx zp3G)G3YVQxy;>U>&>f0Gs5Ppor@?5G^P_{icjs`n*i=Q`Jv^p>6HOIvSYR7DzPhBG zMhvPA!C*uoGb96}4}4aA$8yrAKUHC88M+m&1k$TBvVpY}F=|lQ`aK1yYGp zoa4C(fw`kUO?$*det2k5F5_BkEg%6EMN8{n3uzCD(Z zWi-xUbg8S?=40sFApjqpQU#O-s2kYcw;oN&rkh7cdPAu5_$I!p6?_TEHznc)#S!l+ z-hb}Y+O}x45Hls@Y2`S0)y+4L3=i(yGQ1)tZ`(66wnf6x!;wH+TRX-nXjPPWG`B`B zD!v`3&Yb(Lu6128Ooj9bT}Xw3u}Mv2`o~9y2X}AUJ=B%iG&VZ4!cPxfcO=>lT{R$% zr*A)del6V9zV+dA51;tmQ^%BObELVvtcrLvxpRF&UNM5a9PHh?V|aLQd~9@UJ^6DC zHnq`GEFVuq*S-7beJ59={krYmdxv}SNj1^2Zgspi5;csJVeguQXV0!~&%)nB1HC(T z4UUYC4sD7#0hgFbb*r2x#?y&dG^(%4%1Tm?p^wLm61(}C7hfuMH8ixw5>ah@$FWcT za21C)iU$dvVsj@65Gq!!j zO*?mP-?nZ0_MN+SZClac@fxUB6Iwk~(t_&6NF*m#9ewo3iU__*TwPq_Sdr3|hAKe_ z8OW9=DAgvA|7IG~NaqSoS2a1F+t|^6Hrcaj!@4yqQ%NmcOQ9`Gqb8$AEU1heL)sDa z>WG2rP*e%Gc0amq-P*OiyLN8Z{{yfsugl?Ziw3rZ5`b>sYh0Z2l`l>Ka;j@^5NG+~ zl*j9$@C&{e!uZi1^AodBMK4a#n+pa=g^N%H!QMnK#yE|OQ$XSbd~ZQpAs>aefN!Ou zP-4YXif^Hwup(v)3RD2MaE6-_Z4$0c3FT{3^f6!U1S!w@fPMkps&B9J;tH3`xHg50 zS{O0fYC(W&GpJ%f4Frr!ZaZssl`l=1ybxmH>yuFmZ2?%RsGb(wB5q6gJkI$mQxk$k zjH;S}Ygwh{S`nqxg^Lax){8N?%D62hP(c8-k`)H1<*#XPrv0Q7x5j)ZaaNAPT7=M2 z+N3L5%mB6AVskWFBjDsKh*rQzfO#;wn25cE5vN60)I|BBlt++I0NUpOt(pkERKDCF5w}M=20l5#i*Wl)AB@qSK0W|BhV6Tr=z~LaLSe8>Pp}he;p3xG8I&v0N zvywDGEXD?~$Y9iwuBgP?9ER22k*uL^0EWe26H64r>d-N9rVI#+ar%IDup+jyDC3Zv z$FGtqg4?(b#Q=H4;1H@RgzS~@sBi8rl-n;N!Xj`f9s2Z(z^iZt#zVx_{4FSl3j!uN zm*4Gn(cypo4wP4%5zO@fIOy1{>TL#e1(a0``axE{{N%MeonD_vp(xzy2nmk2?mRJ^ zLz+PsSAhnEim>Z?8-=YX{D~`6oZD)#I~{fxumMrLA2}0}6VY%rt_#fFbYeUX@i@Xb z&!RQU$0A zppW>Fz}6(_nC?)O_8MGTGp;o;#OXuRiJrNkF@}1KDN|#U?E?P+v|b?`z$RMW&8pm1 z!%<`k%M;HEnDND$7FokV5744r{GecJ(I+v~W4D^h_m@}*6@fxQGPMPBd$R2bbX-iJ zGDvZj8hsk$7e#*L*!;aEuUUK$kx)_H0uHUCntufTDdSB#!j$4g1r2=x#eL*h`N9$_ zqJlnzG!iJ<)F?fI<<~95m{8A;gUKSxG2@aFi#7^$fS7`h;@5CTGFbvXQO1?f!BGts zS&5j5k0N4Dn_oI9O!I#znBvK4-Bg3Q7624b07_`q8Vm%9-bO-nO;Dr|m*Q%w!>!G& zkro3#dKfhjWm-;70Zo~MjAC@opaM*)G=Brh;uq*$B@TBV5|r2?w?}}!J}6j#5ruSv zy^IiPbIh#969D3~NP_vkEu%88;rRJ3|WzAze1z-@gnrc8x zo}=H_iGtHSrvp>?JOdm=r;o;t0-7T$nkfah`JM-aiep$dU=$jA6x>Np0E98b zB6R6BA{Pn{%ZF6hT>>$qYeDcOKz9;!tfG3$WYP%~wop`q8;eLPR_};~PEvtW5J>fE zVT$TNAQA>pYBiN-NnQl#OzX!{QRBu^rIscUeiP^8A;Gd>T` zf1bpK(R)HR@oA9PBu{}HVzhR8O^9(i#g71+Ib*~xi@h@N7Ym0^88I9Gr73sg``9DHF*z z?HTGD&@T`%xNk_Im1r4SnMA};+{UhUj*JfW_V?m05Nwbh6ii}EA!(t>saG1X$|SOZ zf?ZBk-n3_UU|?vx$-osn_+EiJzXVZbTtx$@05p~k`ii=Ke0XqRXl&0agP6l1X$mS6 z1}z03YC(Hk1Kge4ee=lB;K-isy}NN2h#{PKj%E+S9SNwT)-Zfi$0Ro1r^x!Iaf*vz z>;x)OO{v{DwOI{jyY{T5ELQQ1fZI_WNmx!{!7_XjMo5=gMu$hnZ_1~D zXQ*o5o;Ai|{pdv)t|^Iv2rkrvleDVn-~ku`lx%Q(BbtGNW>M0^2>5e<=P zU|s|~K(dhtbiRT0RqGZ!-?b>N_-p$4Mp(FOL)cVGNz@))tkyimlFu)Lt zPm&_-&F%OWgw}CHN)k~@)Cb_-4Tz`RgBi?@RyjX1GMqy01Cca0B;fK%(BmK|0`NJD zEzj>69U0s`k_B#($OF#UMj>L{8w8jDnA2lP^PdfgvcP`ufKP&6XkWy*!bAa zz_XCexLV_K0VD+S?Q7O{C5(o*02!w+yeiv($_?!v=)w8B`IfP<;RaMm{1Hb(G!8uz zs!2{1RENBxbnd}3>+r>N!H{*Fj=fuM866q!1(Fw6w%;-~zN?0!?xY6DN&&2>D$)E} zAaEXS*O~ht{O#_Z74$1Ouv6nJl(?*Ea&BPH=;(0Yj=tgU>}FsV>&v%!T0mHoE76!| z_ul`|TKpADbo-+ZK62{5Gxwf|nCMqVctd?tfrSdu|l?%TWLB-r=#a z@sS-Uvj*k?0IeveG5f@lYjTRxk&I()6w$fmqks2}<7--*qrg9sdv@LP$?v{vZEo`r z3>fI|?H?W;-rm(L8aH|B(3$Hv$1Ff0uq{(+6CmI%5B>dL9$O_hH*R|OOD})ttGBP| z9T^1<+t=4WI5NB;e&HrhxB&or0ox?v3w9;fy)wUYZ1buO8*kmUc1vIH?!qp|?%jQT zyLuAFO&+Ve2`Z962GRQ{4te$6PyAL-d$wy$X@g_^ihMTFT3ZtV;sG3uA|8{v+30c% zzyn(m&uvN#KA76Lee0&1*01QwwM8i4;c7(fz_6vO3jhyX=9vRLHuVlI7x1_zeef<~(6B5o`kwzey-WMU_vKC3qn|tTuU~%ma!zy8Onmmbv#-7Uk+J1j;Q32K#OuGa z90$1H2j9)TzW>ZvWEs1-;)iAa&jajQ`fK<1=hfrqD=*A!Zv@`BlovB;#PICwPj@VZ zZJw6?pt8R8~^gT^INK~rKXqHF|E2UmQ_Ke&kJwbfUoyYd6;f4fM+<$nF?C-z@4 z4lKtPa7TpE+2{Yf46}CFBb9Cl?*UFut3D+-~8|sw*@XEz%=x; z1@x}~%3kWrG`&E?mEOGk2R&~OM9Z0l#Hy(oegid*pR&9D5fd})4#o?AdN zJ6pPx;u`GPw9to_NWAFntN&y0k_2ljw=ZweJaG9iS=0*cdvEby<+pF2U9q57T{~a< z=lMR_yRyZx#A7J>PxIVY|M}~$o?3xBqIj_Zwg2d!{qho)U;W^fm)`f=Ta+65_f*&T zYJ2$-A&b8K^;b`?6s&=+qaXUx4}Nv|$och8Uis3e&TOd$ym~FK+Lsnp__l|?dhw6% z`{38E8Z@tec3x}@rHf+Eqze~EQkK>hN-%|pl>LP z8c=!eLJxU){_FnqQ;~%+cgeeszrAh^iwk(|vkjN1T=3Su?;jWEzwW26eGq?ia^;uz zz&Ed3#o_{9Ke1>nbnp7?;{4bB^ySQzmyajRnrDA<-8vQ%@W!Wc19Op=srkOoedp5i zbTNTTefGv(izXp%C^hxG=c&*B;|~ltW2w@wf&T0GpR8QvW#J;Lcl?(Jp7^V;|NAd* z_^I&g{a10ooN;EWuPL+V(8FK6>KT6xi@uoTE8(jwf5Bsq_U=!9^QYH%)L*RTiod`9 z%+lIpd;O|g3r~OftqJ#vlCSZ>k2fw@;kCT622%UZf989yU89D@$zFQ~x3HG{GC7-f z{?V(8OTNaZFQu2Pz09!b3Mk1n>YXS1*|}?MiZ3;@=h}yqd0m(N`StvzlCSOkO*csY zFF$&{(M;=6}dtCk3D&D@nh)n%V+PtVYTp=gO^va=%?2EFB?tE`S6WT z;~Mo+U$(Q$QFVEqSJp07J0TTMU0&95KK=EhORoXymzSgI3OrwFT&e?1V>fa_`SI;b zI|lK0b?0wnGxFwhm%vC@bw}`pE4XrbAAf)KRW&XoP;cyX@aEa2MWAW?2DhXyUcD2& z*a5aDZshi3&wje-GZp z#_NCc+%@Q(Ct8l7^#^YDkFVwNv zJLdUiD7XsC>xUQ9xbT_j(Hk>;E->l+*M>zHmh8V_&G%a-eCFD}pds;#zvO*O#C84l z#UedfAUU6%Q;me7JQzx~E#Wn9mP&o5#9MElP5sJblg6HDoVoquwJ8=%?O_ASh@ z#ow8>+{pf)`r~`y#Wh~?)c?`TI&t|QKCl$`8%wl=J0vS9AB@K{wnyB542shq$U2^eE)Sq@xS;;$5M`+x0&Y{ z{=~BD(3{`>U!O1HFK4gs<=y!FGQT5xXHq)$ literal 0 HcmV?d00001 diff --git a/extra/gpu/demos/bunny/icon.ico b/extra/gpu/demos/bunny/icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..0fd376bc5134def5ad574135895ea9f1608d5b66 GIT binary patch literal 9854 zcmeI0TWlOx8ONu#V|y>Nvv=?Mw!2>M#n)V%=4L0cRim+=G9cHW~OoYn&+>M$#~hG8%@AN6|R0f3bjJu<4&t%DCI^ z>fo*q+&LdWtliVp+IauJs&lf<&dzqQ;kr$8^4iPI`<0cIb~g7}+j--B+lsN$F7F$S z@9TB$R1b#ssi~XiEPa_9O>lbKBMV6iy*sbX>L`H}ME#d3M#nNn%u zD}g}r66U{O`-5C*&Zz zUO$)1W%9Z52Z!?`FAn8OS8~~+8X4KB3d3V6ozAGi!C^HtG@|amZ$*9liKo=Qy$fn` zbV@z?@G14&m%gk{pZbv6JF~17_dlR!cOOzSI~U%*ck}emvOU=y`Wx)=YtWVV+09&g z*)zSlv-w={jZ$GuWith}Z*EDQJn;zFM{B!w&Q{+0&|~(};?e5F_>}$F`_5F(zW>Aa zXnC^Qm(JFvw(O{#e*A3p$xnQ`IyZaJp5C=sJ$mF}b#U>7wEgqPuFURUzBILQdQS7* z4jHh9*fteQJ(7p6!K$Ep8+x~=w(P9#-Lp_l^$gYyE#0r4dh)zFa`?C!AKj$Y_YXma!%vg*{Q2{@xAA;#-+9oTBH z`OPlh6Jao*+2L?hg~Jg=J~EZ4N9xn%r%rS5335AgqjF7IXcPL5!%Z7N7To9aW#OjZ z@7TT%J~gaznL=e6v9PfJfy?XV_0FU3=zGfyy%YgA^jHx&z%P0Yg^@1@MBkKy{z0B> zW?1B-oKACOpgi<3&LO*Q)c5GfCh?!cjDx+0)!69f%H~Zw)c(2qUiPwRrW^HmM`8xO z88$<&@Y~>r{>2V;u0SBD;_;-gP`6~GziYo)mBFzYWs`XE@KcTg>^A}#W~LV6e+c})ZP34$U)ZSIkcvj*DwXO}@mR7Y zKVv2qOF-A75;x-ikfBs^W14;iAH=>;ou50Zrgtt>!Lj#7tgW8oy}JL0{DGe~`@h#O zygp7H(;f}aT^VVUNTe|aBo~n%P2{2f3-3D-Cvs6VVf#*aerU-ulR0}Z1~k{>$O;0jpMy~ z-C_FtKP0ymcJ~06$?@qJa%himJN|FA^q~;sWWA&FXG0F+{>N4vzseqd_I=F+j(RNW zvGw%i*Rq@4{%^Ycb^Vi_ycy(l`Y!SYYL_A8n55Wa)z6q?EtO2B9pB+zr}fTW*rlGT za-91#zPpc%`ujKH#XLD%alYFcWDaz8evvT@CgG>AFqaIXKI1o~j$mF#V{MvF^}8}S z{zN&Q`T@0G1H0yT;+C=`6Y1}2UUKQ{=H6xI*}J8GxpEAlKN;xq|62I1NLA{%U`VBU z`s($JFyY%|r!0BY2~N&+>LBv>p>EZ_Z`4AT; zhUEIJX{08|7HZ)T;#c^QTOb3O=tHa@MX$mGor0Zpbbo(V;v*7?sbJ7t=5I6FKI^jA^B(VY)9mPb z0-e5JIq@j*RbyPj29-p-$3~v0!f&A4nCLhJ-({{5X4CDtchz%fLp0d$tWRkp#>FZ(^*&mIj;`i&C1nQ9m%-&*iyzPGaU9&xb-`u7iaf&ol>EXP3b_hs**ymDqltgxo%Ugh`uC8v^|^(B0~hE|0f@b@u$ z7&$i@j{gRHDVP14xb%((4PzWZY^wv zE8;`AclTPJ3n+`MqvL}2)C=sudZt2N9kbjk2K#d=7LHTzQlp`7>GLkXJPWpWK4>BC zobN_!{1&fy7UbUym;>18%dExeN0g28(46xlxI(@lTHrP4;vF}yk`;EOOz!!NK8Jhi zgXb+eF ze!P{PQKRldjjAlLV_pq9K@C}ku6zH4`J-N5ea&^yTIL!(NB4T3y|7%zy<5^GkZH#qt%x4(=@TEV~ci=NN{Lf|%N~QYi ze?P!nU7PUTdOp!>Ua!~lQOCTHjHmeb37g!ksUS}kjlRuRgZ`*P?zeB5LF-$1ccWh0 zWvJ_n>*}>p<2}!uit|?m`j<0EB9Z<)-@RRbZ;zVRO9Q=G=0@AYE&Hf^+l0@W)?b4D z;5VAM$=T9RF)q2m?C|ZfOzR!ySMJ~Z8&o))*h79jN9*BMdaMzTS+Q3mVcD1d&3rA) zsKv}c@b`Y7|HZBiT_3@`f_Hs>8*NQ{ce?VGta z+x Date: Mon, 15 Feb 2010 11:26:26 -0800 Subject: [PATCH 020/713] windows.kernel32: bindings for BeginUpdateResource, UpdateResource, EndUpdateResource --- basis/windows/kernel32/kernel32.factor | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/basis/windows/kernel32/kernel32.factor b/basis/windows/kernel32/kernel32.factor index 80f50ef2b0..1e9a387646 100644 --- a/basis/windows/kernel32/kernel32.factor +++ b/basis/windows/kernel32/kernel32.factor @@ -826,7 +826,8 @@ FUNCTION: BOOL AllocConsole ( ) ; ! FUNCTION: BaseUpdateAppcompatCache ! FUNCTION: Beep ! FUNCTION: BeginUpdateResourceA -! FUNCTION: BeginUpdateResourceW +FUNCTION: HANDLE BeginUpdateResource ( LPCTSTR pFileName, BOOL bDeleteExistingResources ) ; +ALIAS: BeginUpdateResource BeginUpdateResourceW ! FUNCTION: BindIoCompletionCallback ! FUNCTION: BuildCommDCBA ! FUNCTION: BuildCommDCBAndTimeoutsA @@ -1013,7 +1014,8 @@ CONSTANT: DUPLICATE_SAME_ACCESS 2 ! FUNCTION: EncodePointer ! FUNCTION: EncodeSystemPointer ! FUNCTION: EndUpdateResourceA -! FUNCTION: EndUpdateResourceW +FUNCTION: BOOL EndUpdateResourceW ( HANDLE hUpdate, BOOL fDiscard ) ; +ALIAS: EndUpdateResource EndUpdateResourceW ! FUNCTION: EnterCriticalSection ! FUNCTION: EnumCalendarInfoA ! FUNCTION: EnumCalendarInfoExA @@ -1831,7 +1833,8 @@ FUNCTION: BOOL UnmapViewOfFile ( LPCVOID lpBaseAddress ) ; ! FUNCTION: UnregisterWait ! FUNCTION: UnregisterWaitEx ! FUNCTION: UpdateResourceA -! FUNCTION: UpdateResourceW +FUNCTION: BOOL UpdateResourceW ( HANDLE hUpdate, LPCTSTR lpType, LPCTSTR lpName, WORD wLanguage, LPVOID lpData, DWORD cbData ) ; +ALIAS: UpdateResource UpdateResourceW ! FUNCTION: UTRegister ! FUNCTION: UTUnRegister ! FUNCTION: ValidateLCType From c3e60fc9c3fa8abedd12e9f63c8e67e989ed030f Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 15 Feb 2010 11:26:56 -0800 Subject: [PATCH 021/713] vm: change id of windows app icon resource to more standard "APPICON" --- vm/factor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/factor.rs b/vm/factor.rs index 47f899fef6..a36ef297f1 100644 --- a/vm/factor.rs +++ b/vm/factor.rs @@ -1,2 +1,2 @@ -fraptor ICON "misc/icons/Factor.ico" +APPICON ICON "misc/icons/Factor.ico" From f1d60827389004d4ce60e5d8dbc600dd7f977e96 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 15 Feb 2010 11:43:30 -0800 Subject: [PATCH 022/713] windows.kernel32: add MAKEINTRESOURCE, standard resource types --- basis/windows/kernel32/kernel32.factor | 28 ++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/basis/windows/kernel32/kernel32.factor b/basis/windows/kernel32/kernel32.factor index 1e9a387646..576fac3a06 100644 --- a/basis/windows/kernel32/kernel32.factor +++ b/basis/windows/kernel32/kernel32.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005, 2006 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.syntax kernel windows.types -multiline classes.struct ; +math multiline classes.struct ; IN: windows.kernel32 CONSTANT: MAX_PATH 260 @@ -787,6 +787,30 @@ CONSTANT: STATUS_CONTROL_C_EXIT HEX: C000013A CONSTANT: STATUS_FLOAT_MULTIPLE_FAULTS HEX: C00002B4 CONSTANT: STATUS_FLOAT_MULTIPLE_TRAPS HEX: C00002B5 +! Resource IDs +: MAKEINTRESOURCE ( int -- resource ) HEX: ffff bitand ; inline + +: RT_CURSOR ( -- id ) 1 MAKEINTRESOURCE ; inline +: RT_BITMAP ( -- id ) 2 MAKEINTRESOURCE ; inline +: RT_ICON ( -- id ) 3 MAKEINTRESOURCE ; inline +: RT_MENU ( -- id ) 4 MAKEINTRESOURCE ; inline +: RT_DIALOG ( -- id ) 5 MAKEINTRESOURCE ; inline +: RT_STRING ( -- id ) 6 MAKEINTRESOURCE ; inline +: RT_FONTDIR ( -- id ) 7 MAKEINTRESOURCE ; inline +: RT_FONT ( -- id ) 8 MAKEINTRESOURCE ; inline +: RT_ACCELERATOR ( -- id ) 9 MAKEINTRESOURCE ; inline +: RT_RCDATA ( -- id ) 10 MAKEINTRESOURCE ; inline +: RT_MESSAGETABLE ( -- id ) 11 MAKEINTRESOURCE ; inline +: RT_GROUP_CURSOR ( -- id ) 12 MAKEINTRESOURCE ; inline +: RT_GROUP_ICON ( -- id ) 14 MAKEINTRESOURCE ; inline +: RT_VERSION ( -- id ) 16 MAKEINTRESOURCE ; inline +: RT_DLGINCLUDE ( -- id ) 17 MAKEINTRESOURCE ; inline +: RT_PLUGPLAY ( -- id ) 19 MAKEINTRESOURCE ; inline +: RT_VXD ( -- id ) 20 MAKEINTRESOURCE ; inline +: RT_ANICURSOR ( -- id ) 21 MAKEINTRESOURCE ; inline +: RT_ANIICON ( -- id ) 22 MAKEINTRESOURCE ; inline +: RT_MANIFEST ( -- id ) 24 MAKEINTRESOURCE ; inline + LIBRARY: kernel32 ! FUNCTION: _hread ! FUNCTION: _hwrite @@ -826,7 +850,7 @@ FUNCTION: BOOL AllocConsole ( ) ; ! FUNCTION: BaseUpdateAppcompatCache ! FUNCTION: Beep ! FUNCTION: BeginUpdateResourceA -FUNCTION: HANDLE BeginUpdateResource ( LPCTSTR pFileName, BOOL bDeleteExistingResources ) ; +FUNCTION: HANDLE BeginUpdateResourceW ( LPCTSTR pFileName, BOOL bDeleteExistingResources ) ; ALIAS: BeginUpdateResource BeginUpdateResourceW ! FUNCTION: BindIoCompletionCallback ! FUNCTION: BuildCommDCBA From b1160f6b36aac54d743d5a7cd76906aa74804132 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 15 Feb 2010 11:49:03 -0800 Subject: [PATCH 023/713] tools.deploy.windows: embed icon.ico from deployed vocab dir into deployed exe --- basis/tools/deploy/windows/windows.factor | 24 ++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/basis/tools/deploy/windows/windows.factor b/basis/tools/deploy/windows/windows.factor index 4dad875128..9df13a9cdd 100644 --- a/basis/tools/deploy/windows/windows.factor +++ b/basis/tools/deploy/windows/windows.factor @@ -1,11 +1,15 @@ ! Copyright (C) 2007, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io io.files io.pathnames io.directories io.encodings.ascii kernel namespaces +USING: io io.encodings.binary io.files io.pathnames io.directories +io.encodings.ascii kernel namespaces sequences locals system splitting tools.deploy.backend tools.deploy.config tools.deploy.config.editor assocs hashtables -prettyprint combinators windows.shell32 windows.user32 ; +prettyprint combinators windows.kernel32 windows.shell32 windows.user32 +alien.c-types vocabs.metadata vocabs.loader ; IN: tools.deploy.windows +CONSTANT: app-icon-resource-id "APPICON" + : copy-dll ( bundle-name -- ) "resource:factor.dll" swap copy-file-into ; @@ -18,12 +22,26 @@ IN: tools.deploy.windows dup copy-dll deploy-ui? get ".exe" ".com" ? copy-vm ; +:: (embed-ico) ( vm ico-bytes -- ) + vm 0 BeginUpdateResource :> hUpdate + hUpdate [ + hUpdate RT_ICON app-icon-resource-id 0 ico-bytes dup byte-length + UpdateResource drop + hUpdate 0 EndUpdateResource drop + ] when ; + +: embed-ico ( vm vocab -- ) + dup vocab-windows-icon-path vocab-append-path dup exists? + [ binary file-contents (embed-ico) ] + [ 2drop ] if ; + M: winnt deploy* "resource:" [ dup deploy-config [ deploy-name get { - [ create-exe-dir ] + [ create-exe-dir dup ] + [ drop embed-ico ] [ image-name ] [ drop namespace make-deploy-image ] [ nip "" copy-resources ] From 4ebfd1ef3a84e9788a85d4b4386c2b6b0fb83305 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 15 Feb 2010 14:04:11 -0800 Subject: [PATCH 024/713] you have to parse the .ico file yourself and update individual RT_ICON and RT_GROUP_ICON resources. lame --- basis/tools/deploy/windows/ico/ico.factor | 72 +++++++++++++++++++++++ basis/tools/deploy/windows/windows.factor | 12 +--- 2 files changed, 74 insertions(+), 10 deletions(-) create mode 100755 basis/tools/deploy/windows/ico/ico.factor mode change 100644 => 100755 basis/tools/deploy/windows/windows.factor diff --git a/basis/tools/deploy/windows/ico/ico.factor b/basis/tools/deploy/windows/ico/ico.factor new file mode 100755 index 0000000000..8ea7af348d --- /dev/null +++ b/basis/tools/deploy/windows/ico/ico.factor @@ -0,0 +1,72 @@ +USING: accessors alien alien.c-types arrays classes.struct combinators +io.backend kernel locals math sequences specialized-arrays +tools.deploy.windows windows.kernel32 windows.types ; +IN: tools.deploy.windows.ico + +group-directory-entry ( ico i -- group ) + [ { + [ Width>> ] [ Height>> ] [ Colors>> ] [ Reserved>> ] + [ Planes>> ] [ BitsPerPixel>> ] [ ImageSize>> ] + } cleave ] [ 1 + ] bi* group-directory-entry >c-ptr ; inline + +: ico-icon ( directory-entry bytes -- subbytes ) + [ [ ImageOffset>> dup ] [ ImageSize>> + ] bi ] dip subseq ; inline + +:: ico-group-and-icons ( bytes -- group-bytes icon-bytes ) + bytes ico-header memory>struct :> header + + ico-header heap-size bytes + header ImageCount>> :> directory + + directory dup length iota [ ico>group-directory-entry ] { } 2map-as + :> group-directory + directory [ bytes ico-icon ] { } map-as :> icon-bytes + + header clone >c-ptr group-directory concat append + icon-bytes ; inline + +PRIVATE> + +:: embed-icon-resource ( exe ico-bytes id -- ) + exe normalize-path 1 BeginUpdateResource :> hUpdate + hUpdate [ + ico-bytes ico-group-and-icons :> ( group icons ) + hUpdate RT_GROUP_ICON id 0 group dup byte-length + UpdateResource drop + + icons [| icon i | + hUpdate RT_ICON i 1 + MAKEINTRESOURCE 0 icon dup byte-length + UpdateResource drop + ] each-index + + hUpdate 0 EndUpdateResource drop + ] when ; + diff --git a/basis/tools/deploy/windows/windows.factor b/basis/tools/deploy/windows/windows.factor old mode 100644 new mode 100755 index 9df13a9cdd..9f0b22847b --- a/basis/tools/deploy/windows/windows.factor +++ b/basis/tools/deploy/windows/windows.factor @@ -5,7 +5,7 @@ io.encodings.ascii kernel namespaces sequences locals system splitting tools.deploy.backend tools.deploy.config tools.deploy.config.editor assocs hashtables prettyprint combinators windows.kernel32 windows.shell32 windows.user32 -alien.c-types vocabs.metadata vocabs.loader ; +alien.c-types vocabs.metadata vocabs.loader tools.deploy.windows.ico ; IN: tools.deploy.windows CONSTANT: app-icon-resource-id "APPICON" @@ -22,17 +22,9 @@ CONSTANT: app-icon-resource-id "APPICON" dup copy-dll deploy-ui? get ".exe" ".com" ? copy-vm ; -:: (embed-ico) ( vm ico-bytes -- ) - vm 0 BeginUpdateResource :> hUpdate - hUpdate [ - hUpdate RT_ICON app-icon-resource-id 0 ico-bytes dup byte-length - UpdateResource drop - hUpdate 0 EndUpdateResource drop - ] when ; - : embed-ico ( vm vocab -- ) dup vocab-windows-icon-path vocab-append-path dup exists? - [ binary file-contents (embed-ico) ] + [ binary file-contents app-icon-resource-id embed-icon-resource ] [ 2drop ] if ; M: winnt deploy* From bd2b72ad08348337e4d04f830f7d09c2abea1f21 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 15 Feb 2010 14:18:26 -0800 Subject: [PATCH 025/713] update vocabs and tools.deploy docs to mention icon files --- basis/tools/deploy/deploy-docs.factor | 4 +++- core/vocabs/loader/loader-docs.factor | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) mode change 100644 => 100755 basis/tools/deploy/deploy-docs.factor mode change 100644 => 100755 core/vocabs/loader/loader-docs.factor diff --git a/basis/tools/deploy/deploy-docs.factor b/basis/tools/deploy/deploy-docs.factor old mode 100644 new mode 100755 index 2cbb2869de..a552bd04fb --- a/basis/tools/deploy/deploy-docs.factor +++ b/basis/tools/deploy/deploy-docs.factor @@ -11,7 +11,9 @@ ARTICLE: "prepare-deploy" "Preparing to deploy an application" } ; ARTICLE: "deploy-resources" "Deployed resource files" -"To include additional files in your deployed application, specify their names in a vocabulary's " { $snippet "resources.txt" } " file. The " { $snippet "resources.txt" } " file contains one glob pattern per line. These patterns are expanded relative to the vocabulary directory; files outside of the vocabulary directory cannot be referenced. If a file inside the vocabulary directory matches any of these patterns, it will be included in deployed applications that reference the vocabulary. If a subdirectory matches, its contents will be included recursively." ; +"To include additional files in your deployed application, specify their names in a vocabulary's " { $snippet "resources.txt" } " file. The " { $snippet "resources.txt" } " file contains one glob pattern per line. These patterns are expanded relative to the vocabulary directory; files outside of the vocabulary directory cannot be referenced. If a file inside the vocabulary directory matches any of these patterns, it will be included in deployed applications that reference the vocabulary. If a subdirectory matches, its contents will be included recursively." +$nl +"If the deployed vocabulary includes an icon file for the current platform (" { $snippet "icon.ico" } " on Windows, or " { $snippet "icon.icns" } " on MacOS X), it will be embedded in the deployed application as its GUI icon." ; ARTICLE: "tools.deploy.usage" "Deploy tool usage" "Once the necessary deployment flags have been set, the application can be deployed:" diff --git a/core/vocabs/loader/loader-docs.factor b/core/vocabs/loader/loader-docs.factor old mode 100644 new mode 100755 index 7db3cdd5c2..ce4a319a42 --- a/core/vocabs/loader/loader-docs.factor +++ b/core/vocabs/loader/loader-docs.factor @@ -52,6 +52,8 @@ $nl { { $snippet "foo/bar/summary.txt" } " - a one-line description." } { { $snippet "foo/bar/tags.txt" } " - a whitespace-separated list of tags which classify the vocabulary. Consult " { $link "vocab-tags" } " for a list of existing tags you can reuse." } } +"An icon file representing the vocabulary can also be provided. A file named " { $snippet "icon.ico" } " will be used as the application icon when the application is deployed on Windows. A file named " { $snippet "icon.icns" } " will be used when the application is deployed on MacOS X." +$nl "The " { $link POSTPONE: USE: } " and " { $link POSTPONE: USING: } " words load vocabularies which have not been loaded yet, as needed." $nl "Vocabularies can also be loaded at run time, without altering the vocabulary search path. This is done by calling a word which loads a vocabulary if it is not in the image, doing nothing if it is:" From f37fcf7eb73f004fdcef8f35dd6248748855200f Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 15 Feb 2010 14:29:36 -0800 Subject: [PATCH 026/713] add icons for gpu.demos.raytrace --- extra/gpu/demos/raytrace/icon.icns | Bin 0 -> 44630 bytes extra/gpu/demos/raytrace/icon.ico | Bin 0 -> 9854 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 extra/gpu/demos/raytrace/icon.icns create mode 100644 extra/gpu/demos/raytrace/icon.ico diff --git a/extra/gpu/demos/raytrace/icon.icns b/extra/gpu/demos/raytrace/icon.icns new file mode 100644 index 0000000000000000000000000000000000000000..38288036baa024af238df95e765878622f7e625e GIT binary patch literal 44630 zcmbrm2bdI9+BV!h)3G|o>aMD;>aNadx+l+&1q2ZjuBaF>V-^DvsB79))YaFt>aH8~d$+#(^uVsZ@9uY9|Mjag&P><2pLo(!_c=FTcgH;% z&95%L`QF9`jpmLK8vJuWHEV`kc*#xI-*oMmvEQi9QRD7hu>ZFw)&Ks-U*0~k@qzK0 z&sE*nTNc0ew;r|jnE{_)@cQ2+YUJs+#q z%R1lu?(46={qy&K`P<+BUi!iG_rL$``|tnu)yAtnQ0+smd-UWdAAkD!mw)``+duvJ z&!z9pfBy5IzWw8uUw-@2EY+ zzxc}W-<){!Ej;@1cmMt4cc1+Jz4zXI_nqIq^~P_GzjSQhoo}hG3G;V6wfEWQe|`Aa zORpS%?Kdah`BqV#-@W(Nn{S*r@tfnXzI5#H^9MKHd|YLRTzSbkLmIEzvSs^Id!E^U z@P$K%j~;vRl{e|*fBx<9S6_YQl^2g4J@mrCXZGx_yrkCOe))NANx`bqI65EMxMkap zr}jMk?EVAKzwqlr$A0_m|M@?Ee)pB5M-Lx9^y?Q69(eZY-A_KT{*EK6Zv42xDPKjC z8n@=b^&2-ow(W^0ckSN$^fPGq!m-zW^Wv|cKX~xKf&I@u^YotGPd%}9^M=k}BX*Y$ zj5`#KqW5dW^1@{gu6uanrpJD@ZTpTVpW3y1&z`+|m8YG1_wL!Vd-tvcG#ZSzHQsD z9^3rrhKJU!Ts-N3YPs<&S*OwH_4sB`^d1c}q0}*J-lC-|9$d5Tp+`1se00-hvZeBv zW6PG!n;zY`;oqv4!Y}}DG!u7x@XS? zz|v(aR<3+-)tWWswaztbR;_w)<%(rX7cH1OtFtuaj=ie+sye$yZ-ClRTBB1mLA_pc z&ds;qbN_Tws&w|wnlo?yf`yBgELpa6xw6c)eEHI)OBO9!Fn{ix-p&e{e$QRIRm-Gd z0gXmytb&xN8j8kmKmVGWZku@Th0<%lLw~U zd)sZ~Db;ji&Okk9tXg3x>p2~~$X{^T_#1Ayed0ZnCQq9&la$Jpj?T`mu1dGFtE;o4 zQZA7Prca)9_w6^_IAy2GkTC*WcnYLOr!!Ra0iA|B`=ZOPzV4=5Zolj9dnZkvGHu2K zGYL@?v{me6<^waPO}YQRyYIa9rtw!!+Mycm9_ZHSsS-6t1KdGT%6e848h*|%F1_OF z>u#KI>+N^kb@x5@PMUQ85YcH3Kn-Z3gU%d%!9|x|an&`~-Eh;*x88R99e3U}apK)~EBBDQT@&xR^N!nZ zyJfAj=DqdSTW+~|!i_gvcg@vTj2nBw=r)a~b<*RiFTP~lWtUxk#TDf% z{a0LZ`Q_s-y=3e~W6nQk)QB?%q%=m2yLi_o)p3n%)|jerr}5Akj0CuTjVqC=Yi#X5 z_>AErMxA}mx#wLl=E7fGbP*X#E)I+xd(lO|xNyw*=bkg_tTTrWYHyUF6Cm%{sMcN= zXEel!enoB8_gPy4B&*lQlc`*NQ)|D0gU=Xt=7_UKjXHbuIp>~RJ}+?Yx#x^Nd(^0r zXAT=Os9$S+#!pRz!T0`BHBU&pG)AKdK*Xr4LMrf|MprWWHIY;@na&j(np@ik3>rM- zjG@EMJafc|^2p$b5oZn`Hgw3~f&JTB8tT#sn;y|LYS{i$9!Ae8`ZVS~NMKfzL}OHt zy40B(KBXjW>1@6psIBe&`VSa1sB3Uw(7*xx+gn>2>+_jZDpHMr$)MqfOh+|GSfjBg%1I`b&gKgB^^Hxj4pGfKFvOkXcOVjH#+R z=fT~_-#hs+`AGZLujXLX7%Eu}0D+N;QEM_$14~u&kS}IE515)1PqPRptjP>xJjsj5 ztcRaD^6H7VG0UDj`N1oiUe!AB;)OY6?LYj|Yp=iY*4uBtdE)5Y9@TbRt3Z+Z)B;Y8fhwk8h^!dR2K-`i*qB&q zb<&VZxHa&CV&tf5W+ZBC#QaTLcRh3P@QL?MVCp?~XdmfPo#hcppT<-*lbT93q@ZP3 zTE_2Ir&;ez0Z@mhOa{fsn*m25jlsf=>wo#!_Fd1u|LMEGe&PB3`<{BZOSN9tB-kL2 z>PQ1%Hkhr|u4^(?07(F8v%^4t>cONAfi%IVA;49en04;x(5}_%Hf;XY-b2ss+V#}V zZJXE4?ofS|p((%SwAoZwo829>qQjaxj5cbv*~S=*jM<+~Edwk~kdje?7FAqoKEoHT znYU>9n)MI=a^t4Wn>IeOc1ce~b&;!@C8r*mQiahy%ywd{;Uq(ajt$V*Vm4dwSB5cr z;;AJ`T{`a6=oO=`3QbHd>RPi&_;y$}07v!t0{8&e zTRrtw1Js6waF32*AeJz-CWo9}nAE4zl2ykLV+~9qMiJjnd)p~Cjhiw<>FDmAJqMFy zcX`I`(@Lt7T-hE)c2)JKHdqy#(dtPv)cai!qL_3>xW=q7Ix`bYrROHCsdUVTfxgc- zh|p;v2$$I%%$|AOo%h^7W%`VnGiOYndf%N_-Ct4zGtO)XxeS1$BGABQwc2b}9}id5 z;!lu7%r%fwW@^oLK0#7lNs`jVd}ci&uBAB@sY;=lL**GYzG(knTyy<|TW-7K&O7h8 z?Uoy_zF=xebzD0z8?;c>t6wIIVl~*TerI2jo6!m3H~6K(Ko=`3B~l$}Ln2 zz;DD9t_Hp8H{j^pV#C=Nj=l8qtFF5G>Z`82?Ber>5k+Onqx;2K+8?RSH728_WYyU{ z_?4J2R+tr2Euw<(bir$8n>$eE^nRxm9jszB(A)=nwcneAeR*rNbGcz>ojK~9^UuHF zg7eQidqn?1H)4%@>yXB8NN8XT78Fdw^ib6K@a9z3{S4%jdt z(b!a#gPJ8EB6k6(HJWK`W-+sk)EW4sY6YTYw(326s%`kFC?C#_DRrpkYlieMMgk6_ zi7B7bi)vSf=b&9D8X~v|FqE5vQKOpAG(1$nl9{1sEkj3+x_(k;r)pnu!Qg%cIp8*! zO?|3SD5_QkZlgIv0eXxW4>91G=hK-DDN51k_cAiZ2e=_aZ|hO5vqlVUFUo=HsKAhF zU{9lIj2$o%9p7Yr2ty@J4OmDWMgh^e{X(i~(6Eb1w`!U+cu0FO7WBgFT2mDVA%j*> zOF=xls!;$;r7w_u5RA!WWrbApz+s~w1jfyS2DcYtoR5JN=BF5yDn>V&V+=ymYEDrd ztPFawofR`JgNB{i)2*6+F?evlVuJVEs<8k@H6S#js3{tVUym+yD)tn?1_ZOg9SCPz z2Ms@CS{L1A3>?&6p9--qM5o5YFf`k#a}lSmzMunx4jv_ZfB-Sn8G3I}&bJL3HsoeN z%*D#Gy)h#NJP-?a&<9UNdKMI@oNlL>8Kce5#R{#1h7P$5lkVKXg9o-Z=H#FcNmrqH zLVbZL_a|wx7V$W3SPjEK3&!YXL&;*>pfd&o#5Q-(;DP;`@(F=;W5(;CVPF75v!jeo zRl}G~Yx;)!lDP&UsF*E`FAz>Qv=2JtjFEGZU-z~R8qlw$kdgvE8*-?#526f+PK+DK z`ZY#aOQ?*WQ9XPOmOMOP>{B8rn#dP%nRH!MlVEk%0 zk9JZtH+3P1K2}T=n)_o-J$ydePir19pkHfaJ|VI`JAC)A2r$qE#JAV4v;XW+!7d+NkJ!Q`>;S zLk6FL#?C2Cklo%=pG&}ax4s&EW)>PNXpD}q5}m0RDiO1t@%ecYLL2F4ZEtOAs7uAf z0EMALDT9Fv&7eGD2s6x!(LeBqve^qqI(;k`N#^RCF}n>IJa9liB!XvEb4z=_e(hAD zTq+t0_&nC?;KU%e39|_KV>U0uU#cjC@tUYUTsV;{VBdzl(7^ufLkQfmxS^@7UweC7 zYcqfnGJw2J3@qrsRiMQf;;M6Q#T-CNVV&oJS>br5(Ad(}zyH8N{RcLk*QM$fH8-@j zk#@N`VVM08&H~I zbuF!=-PJ~SX~2q#LBH371v3<)YW0|V5u;u@z5_`yV_)I)`B)*608|s81`OywU|?I} z%5Ie#k!!-}3loK`x~5@s!e;Wrx%X1mMl^96V@5{J3i(8GhIziGe#q-|Ss=ImZIIy_!zY-$7= zM8Rh4p9|RY#$_N868n!=Hjbtj?vwa%i~2%I584SV*lNM-8ZyEWbkiWYg2uE zLa&+}AITM)urY6IYj0_(;zCoHPJuZJ3}hQ7*0p91%L&Hr1g4J-@De~X`MUbXM)a?K zrFIh(Yi_E~$2xk|TyH#`D>OH^G__E70u}zG+x-kY5D|GOOf`04Ly1XiF@~}%HbZu& z+v7#Z1Dqhqae(KG4ajlmj9lv9AAJ`1g;Xo)Rm}^FFG~GU-H2 z4u|+43qKQ&nM$#t3mT2R=mfQPo6}7^iK-1;NQy)gsca4ohsV(|k@Bc`^dHdL-qcjA zlgG?fZNHGRSp>MXxvizWrB!JOG{g1On0z*!qM}5Bqq2P7l1JlKTxGk)p}6pqM}!bR zwT6m`Cs9%6dKSOTiRROl{T)mPgZ>) zpF^c25syY7jpu>^*01<_yo#^R&q4q%h>#FVq%zrj9m*^XO-*erE&ckV%Rmfue`{lN zeIc29WVY(uoR>1$LiI63y}6~i(!w`4HB>FiXS1nfA|8_?VMz=LJVXUM0{F&32FwUY zj3m^d}~Kl2S|1K@cDC9{<1(KlP}aY*4H;THp73d7%maR zW=L%$4UQsQn9pX?kO<47GKr9INz#VHB;t~zu~;0Hp$sg7q+)#oY2s*@s~G+Jx1kGQ zK5ecq7W28JIBTxzS|x;&sXF8%QU=M4eo|^N}~VaOgAe=*uRQ(i8~8K%^_uz5%l* z%x^*KK56YRwyn7tZf$8qk84Eckj7ew!2h)LXH64nR$8KHgbst$=nr8q5!u+>Ood@| zDPZbN$^NSss?9S3Vpyg%%tF2ZxTaP*6wzTF=FxAhNMu+Ekr!Ql{r@f)i-Y90PcT5H1a-0RW>8 zx)l73&Y4D63G?ywOVpOL*l;)!PbN}%q*cC%k);KzBTQh_qN)^XR@IX$iIE`$GQzQS>kMh6?@BOTQ0^67X~mLv5 zvlw;4Q5hpyI+LlZZz!TuHX!gyqlcywMov1=0|xeB4kImkm;#TH7B~I~OE9k?GISVf z#28cWLP}wr&gOF&I(CLcuC!duZmtVTAv%~vcFa5?MgF5 zAkA8oRtH2O@c0ZJ6q$-K%-@JMw3EuRy5iukN$E;LqW&{K!++&)TaZsH-5cp@2~YHl$N2Ov@1{&letgP?g8| zM3EX2mZ`&1_{yUrW0a#A4$ZJCA+07l_#y)^RyS!{m9{jHfr_9*IM#Pf7%%!HU>?L^ ziqSuc`7oI;VmJ~(R4@f4Q|PKNg5;SxI>OPRxv7cN>tIk*qtZ}nRT_8* zfEpN05kTY;it}&}9eFWbDiIxZ5i0YB6>%;sh9na4NMRY{J-|`a&sX0RG!#jl4rVme zD@APsCV5R$xn9$#pyOj~BSj_eN8swR=``G)s!muDI7SQ%S*J#(VHqk>o$(FGNq8m& z#gS4_iu$KPX*A&ns&i9AxuAh-qBQgI7mT~mfsWf*3`=ym62|08p}Fis>($!Z`4HwQ zcl9q)I0l_De_^IdXGxtNgFI#{Qm?5ac~aL=(AMFHn!5UWQsnBgS-3ZcHDD|jrOO7a z3V;F&nqsM5TgWL{LnaH~W-}yZ zL>8ywu_%1YVBQW($OwTi;nmT3Y?z9WBvA=j!%?8du}r}Hog%b|ikC9ktdh~@3Q8R? zNv518NegDxpQjGN>OF z$kaxo9WsL$QV+q^ayep@@L2@E0VE;|+>KjR9T9j5zZ=3bx=utYi#0Hwgvw$q1~|0Q z&_6->63oVPHBwk2q8=!L2E5EQ-&J7Y2;f4Z9@RhmQhl-vyE`IUIou`IQh!!N2L8ii zayZaNcA(BP*k4U71YVJ9salnY0Vx4j;3ustb&6U^>VS15VvzAcC_H8t!Vuwr0mKSE zp#o%tI2^9fU?I>tOg1vr81_OTc!kT|xJT99+Q5R{yS|=K4!Y~oPQpeUn z2?&EVyf{env}!(At_p)&Do_R%YNQ_gAa`KlhY^%6Gb7Zwq9D{=zF*akZ-;gfBEwT1 zBDCri%T)~{_AsFFEKRHsmpcD>l^N3}^K`U=X$l2bB5*w9zz$gt`|yh*T2N4>Z3I4c zj^>bRAJ-;BYIVS%fC^-hhyn+8iRLi$z*0CfXw)%PH=-#c(ilR;NSBN}EW;@#8YoPX z>7mC}-SAwDKB23^m1Rx18@?bBoggL}N1ad&*#WsI1ee5;R0D~nur+c@T`>}^AM}pO zXqsE{aS@XhO+8ppmd#RCy?DN<@uX@HS_(-iBXo)eDa|#6S~X9plvCuZOAKfoP?ySr zQxt2yVCoakzw)Q={`C2C2YbeZ!70+WpFeHi*MIN&LHGBMmz+&mMZVPZcmML2Z@&A} z_uv2ZujFsWzy9_6zy0v-fni`31uuW`o6kP|{Hw43_|13UmHuSe*bqLegtL_ z7(?3s`Y-aC36!9dX!YhOu!_#TX#2}AzWN)ydVKHw-~Il>56MaLkp+CA-~aCYci(>V zt;3gsRiwFi>+=T>9eersZ(avo=yJOpvyQ?&z zBgbBR>E+iy|KZ0UfB5pv*N(sX^2;yv@r0gTHvqIE4a;%SNm%Z9zAjd?<1dk_UTpxX)Eg<+OXwU+jc&+d+$Cl zgr0lhH=lq1{a0@sc^)L8=k`DQ^uFCs?b!OOWpzi?CMUseb2t|;!D5Y|IE`*@7uR`H{Mh3*!KA5Up_MB*D7AO^WjvXP_FkE8)wc1 zw`k2nkDQ_iJ+WiwP7s8iaz6Rw&Ye4UJh2rdp^cBMTQ&ErgQ|g#hZ5Kp5=0fP&YM3zjTf@!;wzGw7FOLuI35!-ii{deE9xE0-;rH+Mq#8C4exg|kJaP%0|* zzGCy8lctl79*}|-p(!XqtJkbs*SX%lZp~_tf|gTGP*3H)Vf$3$o*RHqa=ivGg6S6zSe9TV@ne=2QX?(FLB>Fu30t1{a;YgTVhcUNawnK^yxq=~m& zKmIATc9fLF3}3D*L1%y6d6!&y?M=7bao0Wf-9Kg8bZ~x@QmG97kh5GaDd7D~pE~)z zd+xmDx~s0*sp@ZO3S{!w4_45)gvMuGc*zyxuLo!7&WZQjH|hQRUzK4V7t0W!lr zecIG1_fNX_?mKS-+vn`M9coP~5mL~$6KzS+pBsAin6cxo7=PUj6K=Wnc5r*{x#!;d zCQT~e@18X2zWeUI=kB}k8g#-9*IYSnNKms~#qb@*qL=`n3jl#)dcd$z=Uq5<+~rq+ z(R1U3n{S~MA-p_Q?jm=(Kn}X~mYZ+7;kxlxjvIU704XSKRcpmyJWqh27_eBpVcTJsV+7L%+T zjOQ|RL8Ih*>-@z`T}%HV!$*!j?}7_2y7*F%fvyA_Xgs-wT7#5ZaKuXYqEu@omP3;4RfUZLsKp^W}e90x3jvH6L%s+12 zrI%hj_M!_fJpbIYM-Cs{FP+Qgd49|$)e!YZvsf9Hsvuo;-a%r~^O4;(yn_=vN> z&pGe>3&xZ#B)?ED^p3gU{BuX2J#xgbAp=?);#hm-1fhMSsta>5)D$vhV3grfAJ!U~ zLIcW4l;<;i#E6k+f#@^3d`@8W=(9(iHFCt6!_F8ypsl%(j#n4PJTLuHH8gv~zNKC{ zTh3LGj@m+uBwV!k*@)c^EvOGUW7x3a!^>y7hJ)L41||1kSzn(|q1dKig~&$4hgIV^ zHb}PuSbCMSm0Tz44TW;Tft5Ag6VR<+KNJ-QmIt{8qI696e^~sZc$$djvINVl8a67d z#~LW&OJRwqr8t#r2NbHQ%f>4SD{4#_?C8pw?!#LxboYW?3Tio-l#cF0H!nBiC}B%qTLB_5olqD)RhZZ=EITcWI0h2%RmET8oQiK$XCP$LDS+7 zfghw$HOgq;ozv9KOK6h-tfh~UWOqUvg+!`ms)iM!l&*9C*kQR$qQ7Ros*AHetUgZz zbiq{!1Emmmu4997SWo^T?epe;#PGQG(4+B_2M zAu6!iR7u&f?&a8oFi1oR4oyoTEeBGLQ3wZFtf3*egvK42o~!{|iejCZT$j+qPHC$o z%?VF1$NE_m*9fl&H9XheqZ(zw6Qzw6G*;4`u$ne*5G~QQiCPpz5h9=_orx6BM!kNN z|AL$t3-LVRw5+B}H4H-85i4g>)xDhVMjGfbyxGmpwFzxJt5lmS35%QOX?cM@BHK{mV5e+=6oGQbuHMx{c0V%{2OD;+1QZaW5 zP^IePJ|0W>{SgmArMKkOp@QukTUHIXMSbqR{R1^nn*>;GsP6V`N2-JFuyPV(0iMYo zNi9N#igqKHEv3py_zK03xZsvpr_<%?aM!w=wh<-OsA-klUhD&um@bYj6V{crLhkZR zH{fb>tl3hcyqG{DH4mCceRzH2?1O_b*bhbBY}8?QI69oQ4!dP!Ni_*^-W8-f93{pe z0|dI!5{iRL$=;McozD5qmI|W>2L^@Fo`f!$jQXr4MjK97k|jhInEGhU?~VnDt;1ex zvzmVac7&7=99a1iU}_Vx5~>x2#%v|olfv%I(N*QT_{Dg#Bc)5mLT+n?(XyFxAD$93 zMPor{AZoW*I;^!8#(XX~9KNLNchU7VRa2XY08$8NLCWb))!G@x(ghXq;(_Iqpq}$N zL2~L~H1-l8NnDAMs6ONjX8h((1kPv%-NKCYcf08(2}+vb=Lq^>NQ{&cz32f|$X*Z- z@QT+ADvLIfs#JlLs3GiN<8jKEz&j-RR$uQ>Fl2-Rg40ho96A9KBrHn+Y(?vrKli;v2%`hCVG+@ zJK|_r3pZiIt5h+}bO+*b3rU}@11#BL$c)SC<3R@(!RAAY-9%IqBZ!U??@pAH+Jqgi z-z0q zjAKVjq7XtNM%nKUNNJa@g!c6WvA@eNNL~l8^tCTVJJB8kX3Dn|&3l*{TMV+5zSfSg z?6Z4ONYYUfsP#CZO65^mltk@2DoxWfu zn>xeGcdATxRulqWhnH^Is_o0sSumj{5w&)rF?cD^qSl7e5d|n=!)9y?TijTm`85#oGyH{E)n zVHpiOqP=M7e~8h#;B2KTiNVI%;qnE&Qe6jVBAG;-=UfhFb;l-^(X1qQ!r|Jugl6s- zq+_c`Bok+M`r>jZcN-c7li0uo-8N3ahPjNrc1iAzmSY;ndZyMFquccowxA}j-5ZR@ zv(lAasznouMr4k4+Po4(5vhV=Kw0jIYUBR(j5ZjpM9PrDh?0{w5)#t+U8-4#MzDWo zU3P~OLfJ+^tFA~zu0(5Ml4Tvb11u^-l0g)Co6{#?qb;_9GU5wIMNDmeyFI8tnj&?C zyRqx7iN-u@8I4VebU+qC0Rrv{vLTeNir|Z|Y#h}?f6!@nivmHrlGGLMg>5xa$+`wU zlsoX62YYbAZu79H)M4|i=~QiaBg}>c&g-_@f+5sSX~XXD9MoGpXcdT5pdk_M7#qAc zyUT~#o1BRvO{~|3cogS&=xKF@NVR1dEqfz1vS?YwXssgR4}m0Pg-EBD(ekGnI)qTr?r?k22_o@uqT2LEyuS~jL>KUT99DM)3x|@} z0kPT$zmm~9VJON2At%-%cBG3>Kv6uL7EoAGomY7vG$aW^zyqCqDDw$rlpDHXur}gb z&eU4@FiH|77~=@JtWI|zAPOiCi7Cm~sk*OZVXg$VL#)SPv$J@`R|Y^uoQ+)9IF~V6 zPZ%x;DS|WPvDuyAu}Gn46xAge&0Uv!F*f7fYJkQG@&f`v`%0)&oFi$ROVAlHWp#u~ zf-B^)(kO9U1SQx|)GJcyH{fMYC=v>BA=c}Id>bn$d`0L8^@v?)znIZ-QYBOo+-Plg zdht432yxM1I-HFm(E0_k04I`=SqOl(;kH|CY?<#6xF}Ky` zaARpDpw7c5WN#{f9P{5D3h*%rMM8n&S*H&WRu5isDtwpF8|tc}U}*58KG`Aofx*WHdU`48xN57ACyB&6`0~uK6yM+az8d37jVQMUXu@mO` zgn->@cep&P5DH6NC?-0^qMrqd2FeBED1C;6K#;{7WRKHkwfnJk2zpWlzhCH91AZY84a9jF`2v3hSr67HR+}rxD?nO|KByN^ z7GrX{AP3EYEC>c(fsd!_ z5`Im$Dmna)tkWqbebq|2ByqgogNNNNr^5<+*je04zJm*6ba8^042FW&;|s9pzY)Aj z%*Ij)Fp~0F-rcK4!k$nzW@AtW|%rDs$ zt75BlIP5Ossdc+OZUssz*0kN`z-R_3-T*j2$hwd>=@C+_TP!98hu4)8!7RyyL;l2U zRh;aU!gkIWWW+q*Am{MHBo&iFte+DRQolg_T3^*Fz1?9)H!5LqY_(b{2x|=jL7YjK z3)~>=tvE`Y2m}RBmht&AAj3B$GD3XeY&AAlbR_wV+r}C_7KAGRXS-QJ zmcjK4iWr3OpN}QJk(g%O=razd!-1Yd18&D}4vcaxr`rYV5y+rF5cCQDP(bpAd3QGK ziquEEF1a=~ZDzc4 z3UV{%s&{mlnUE`=NHxal8pFkgSU%1M-EJ(_h>Jnc09hlXrW=$-K)HO+=eyqnoh{_5wH>x3y{< zMmA%GnlgM!{IqTxn z9yaX@$U#oRG7H9lcf|=9M=&dfWI>QIf1!>idtwQDr0C`95>98TO*T6ln*-<(X1+db z6U~~Ig=*_WhsSFW-FhME@HgiZ@kYsH14kNslX*c6)M?Gn#b@DNOlXK#F3a zD!{5jfKH{>K_oaQF zx?CjLP_Ws(E{CJ8HRG^)b4AJNN!A4&u^j7*r(Jw1?33a`Fcin6h}jP-8v%G9-JK6f~cOiU!>$bJ#k49&@@9 z?OB__o@>h5?QXl?m+(7nwk7I~gWVDzjK%E1yr4JPc-9_nYK@wV?)sKG595>zaksxN z%R7U)h}RL%OI|LS4P!t~rE*~}-Vd`*As_d<8*;qeo%Wk;LVbJO?F>b+f#%srBIngx z@D|YTSgPJwa=XGdf5M}8gczfNYs_ajpWyX+gf!M4DE|6vc3(d3aEo<0yDON2+OBlI zK7t86)>Mpo?-O09k9<1{h+OnoNiy2*M&PV~dTA zA*U;l1j*LP=V-9xeBQ-aTyjzf1%mVyVmwz!GiHl3$=XaNSIUXAQc|%o>yQf>x8BIa zb19brxK7c%QoYuTQ*L^l&1KNDpcc5yHir*$d5p#Ung(S!=3!j%3~M(tTrnOFI#Zx( z#Tko*Ni^q^F%bt)TLV^qtiCDklnRZFS+Ch>4RIcaN5o_(vU-!ivJa}`U8s@hjT~pU z$avLm!BM?%L!mB$lU0mATVDt{l3;)}Mtt#NOMB75VC9i+0ISPo!HF)py_gbwDSVy{ z*yQ>;kv13d`Hb73H;3eqS?8C6tMH!As&m+N_6YV=LNqNYMoGx$iWxV~+z1gXh`dfA z9k+ud>f~Zxr;~AlyXCCM#OdZlw+)n3dk)qTqYr9>?HWU+4(>7r!;)R+5ZE>9P_M-p zbm+0M3Bmb6%H=eR2}$-jQsBMCyr5h%kvQvuRU&29R7zoUbX(J9f8q9?zP}!1RA(03FjWs&LxqK#{#-b$|wG+L`jdi@M_7zhRftqoXr-Dd_Zi!oSYnN-MuGn{$`%VDev*Z|5}rn`TsW{25PUN)FqEQ3Og z9z$p>Az5q~1QP;|Q__R4T!Jq4Ek?1Z)YTLsIE(7B*gRglkse0IfMBO5vGpz@nIlLU zK=@6!Z&b4*eUi-L=s6ScxLgh|=6ajOmp~;snF_n1QiQU?OfP2g+&{6vg|WY+@dDWu{a_=0NU`@JsfuHs|RmsjWZhd zm<<+`(4vVXtH+_es9r#YnsQz+?F(`gszoFR2WEiG!Fy&d=4bADTyl7&Sm&0t83h< zIwm`GR;y93V>nroWWk0r>IOTHzN9CJs9qO9Jtjo3Ukjo?QvrINQw9kj*?fb}6Co&%)ye_AzKk>G=CBlS znswAGMvveyn7p#+v}$&!o{0@Qon4Xwfsn_Iy`9>Oam{9HA8j8+#^N+1fqm2yX`K(5y@lF*;&^fRZ3YfX~1p?X$W=oW=|-B;9vxSOuZf_0cx>D{fJJ8x1VAPUSWS8xhYD;6-HW1_9F$Sy(CZZgt%N$OOb$1Q%Yxa# zN_bG_tvbD%bAwo-fg7Btchv@MdL$;SHu`a}l%SAXgTfS;X_O}-`0ZGbLjw+|wt)Y6 zmBX^z9ROh?%DGHPR~ur3$6R&>$C!1f5z9Ua3oW2j5wdY_Ip@l|R{jV9X)77j<5DTY{cA(@CsBx;bQh$#B#Z8swa zB|@l`8bH#D2pLdQbl6!$P*v`Z)xtrckJTE=50mFcYr;WLP;dnRM_|8#5-X8)=oM1? z@6?)ehamB2vAmlSc)}X?J^Za7Ps^kVs)6Vuk|f05QMH-@M5v`NS5RjIOr=`I)P`E# zR`o%;T*ZEyR%8uWQe_hn)bRij((=i-RBavhJ9wv1EixLz$pM#M+CLdCqduq;1YQJx z#GyeN#oE~<=jl(nH3W_B-`L@Cg)8v}0kt(Oa5_*j(glM7 zw(x7!tzp~l-~TPhEr0#%-~RUFF`P^A6IL4tD8UX$=-@~YzYtb4@Sy6q<;VT%+aG`U z{!ickrTX+l?Dp^`Phm-*GpOab&LF{~HQ10HPy>$Wq}PA=;oEO1Ux+^brkD|CddsQwveABmIRBtVU2*{us z{q2VwcE&E^R?w*8)1ZOY?=SlZ&VZm0;1qYO(wWg|pM3erANpEWo6@#Fd=kLIgudD% z?viI7j&T^=wEhzY!6Q6m;4@#JJc%}+eU3|#zW(|fD)75M{kY3Qx8P_+T#9>vM{yfm zw9XT}b*JhbTR-mYKm7i~)2;fNk#CLP{kWUK*>*cYi9m5Jz*!Lk-NM_QV04JG-0_F^ z-$Sd9KKYai`{K*f;(mOXv0z-#+R?D&obN(4#i2*t!Nr5i;b!y8KYIIJdL_h1pHy3Z z{ssBc@)cF}#|dUEP0^ItOOAO?R6^_q9Iemy_(9?D1k+D`^yb^|yhpEW`skBCz{1Zy zCtqm4{E~cS{&6BbCy2IaT(Zw|D7am~Xth|9Uzfe-J+6BB)QqqWzV)qFs&`kMMxe(3;SU6KGvnvq zy+CIk%pM9;vdpmp1+7iSYrlBo#D~+^=8YCoFyaKN-=o`<7%ID}`!a^c{6Ctg4P>N^(%!PXGQxvzfX5O7{S{`zSk_~aB4 z`G|a?{hpMtZXia*G>@KD#jPTAmh1n?8z){n{_-oY_Txd<5HI7}j=XT_$g!89&?z9O z^d3yBLMbO}Kl%zkMREw_C_%2Zh!8X1JAwC zce57-qo%$2)?06rceL-mOWq^z>wf?H4?oR5tQUPp-vSc7^6T*PhqqyZ`=5jkkqdcO z9@w}4IouR>XG1oc#m7J59Hr^{Z&v6j~zX7=!Js^_8-W4 zDfJ^j=Lk$jm=wVM5apn_Y0vJxPeaM)51j&qnx{|!OWrcQ4OhPRZ4Yl=s}I>8d*{_x zUWUy_4ug}p|LH@M-9Mp(C|pgDGD4(5l5NcX9lQ4IdwTx?uo({>KKAO1FTM;1P-r-n zoFH$Q;Mcc5c%wPSuF;FuW$(T6auxRwa1T7QZ||NA%8;koA|zNFsM1A3X9Ya-ckOtR zG9IbUhu=7~^_AoBZ67vyO-sSeZ=i>KHb0bd=vM2+2`4G?u_IJvIO6HOyPvz;_P;44 z(shz^;O=ct?4)Wxv;V-+qgV2V!md}29fRtxKy`AQyka)kv)jMOCr*%0Y(t*d^w`$zRS}0Llr#pNeBkh*Lx;(cT51J(k-Thp z<&}4D5|eycQ-j6hJV-G463OsT+;vB7IQU$j2w1Uw`=+o5gcRbaoF=3=g*a!w?eRx9 z_X*jvS1M^3-5JLZK93|ibQp59M~^DU3@^U;_BALjci=X*x%#lthqoe$xV-vh;P(kY z{y@SL+a7=NY}?Q1DNZTD`4&D34(sF8j%OC?OB%C&;nC-iOwYgY0y(6mQpi!mi^m2< z5;0>ZL=b%ks2VjWR+kcjc;l;72DJi0c0IWhLbmL@-V%_1N?LJ(wBk-a^6&s( z0$28J-r9*8{!d6OPAuQ-jT_dVmaunLNn;cC9C#Y3yZ=B{3VB|6!FcG%^X(A8FV<)* z9SI?xSpUK^Rn7P8!exMfetgTO&C5A2<+W5VL!q1&H|4Z2zjzea`BAzqh{D^VNY=Xb z2lnjU2MJXX3vN&pf#k5rzS{ zoA8m1O}3xVVPc@e1nd*nuU-qv@y16f<9Nq2`=8#qW9O5*`mRKzBFHmjzy831gU_@? z2}mmL1sZKA1p(m;o~KtOQd0BwZ6GLbdUV6X4{bTu@>8meOsO({`_wfnAp%#(|GKYSFc#LhRWDLWjyxy)@^-4s;2BFkV5w9o__ksm0~%eam}F;x^Zl!Ve77{ z{@WgZ{4w0axZ#n9)~$JT6!UY!jZ6tQUi;*g%U7;i1B!Lu?Tu7O^$N%;!<+0PRVg(u z+#LpGG9{RMG&PKr>PbXm#Vt=hvHg?{RT=BouHG<;`6(kOP8m5K+s!MNE?==~_1bk0 z!H}xAKmw?QqwY>b;fVm{Tz;R_86J7(TH+hL3sl%7u`!l3GLWtAsf;GL+R0w{0Wa zwNE^u>>xX9_6!e$e+4pLC|2CCwR#;U?!$b9-fX#g)r#dSWb0`T5GehW1H=@T%%{*R zR<1sE7v=`)t139q$yV*QZOV4?M9tIJOY0J$@LAh8Z=w#_P}Ow}lwG#Gn{}M#2uXb$ zA*I&peA1r)Pb;hR6xB-+rraZ2LKl;lQ^{Q?E!~_kWf-YJ)+Wb$N zQQ|bs$UJ&6z0GqGuJc43`}BpAtH|&(fzHYn-D8jKx>lsH_dX6isiG8g#d2KPxnNm_ z`6m%6b()A|iOm5kfBu3+i~H^gT}>T<=uu><^hWZi0_fVUOH#4b36P(<9;K+KV3#df zylBDVDU|AUim4Pi%~Y~E@1BFZL*d{)l~+<9SFy=MwG^CeARCoOYd1Y{v9ucRd>U3G zt4_m0-GvM0E*oX~7nuoL^HXFdrgeUI (h)`8}IkJNKW6fH!u68{%Cl8ZHlnuI# zTNbBcs}fT9tc`%JdI2XDpzr*-^DC_7Cw!;mKlx5J`^4V9V+v3k9-+R5;#G9Gg{&tJ zl^)hT^2pY)VTydmBY=f>tGG~j&g>B5mm1&Jgqv8 zXi$8znygXQD(h-CT_&we1jAzxia;iRVsG? z9_Kpd(2&A6a6I+=GP0aNKzUW|!!u*CWvKp)Sk;Hzr*&^nS5Jw<8?2v_vXVa`Wua(( zUXMcWjP35}nMKc@oW_R$vXnqTc}4BYhpq}QO~|p-%;k#~QioLUrlqG#W*5!QpL4d7 zKjUm!oi}yOtlmjWy)$d}X#uc+EGCdpUZz{VV)bxoNkR@^yb7mXC^jy>1$alt?6c^r zjGuA3l0WBkS=|#lXDa^`a9RR7`o%Hr}8-O?3H&Im6`MCHag3+K}N0%!HYE%a{O zStHHh%>116mHZ#1FUECa=gfaffDKgd>8f zrn945?j3>GRsWF}7CFTWGrO;?%$U(917U`vsz-R>t2tz@GQYAwzi{D_g+s#gaMMNf z+C`@X^j+>-=^Snbx8{E`$CCexImTGes?3~TwdB+d!QIptGKB0d73bhCfwL~Tv(i(+C-`_~XvXxJ z9TOYuxRK}Iv)SVRfz8I4A{R|nrcHq~m^VYg@h^J*tG80q+0#op^xZgerod&988fC& zpINzgsKGrE8$FKu89mNwHrZoCubeb} z=Cmo3?Q)W*sPf1UmF>}VmU$pa9GxPtSE{DsO4Ax-bjLYwuJOjt`CQmNk-#OV& z@8?Euo%Vm*yZ)G}syKf6&5PfX3W}98VIXOf@aGJDjLa2C3bHj7!&xm8tSlyqBI#N- zEq^d`*xaz$m`S3wM9nPCV7fMZ1|c9S#z0%(2(%FByr1XX_s+fdoO{o?ⓈFaPB$Z z^Z9(vdH2UT=YH;c`KuSri2+|h7GPc?rg6^!Dg;cG88YchdPjGETZ=22MKggwSfG3mCT2>1w6((Q2g&bG6bH`S=Z6>4vRz z3u|W6f$onCmZS-#h|=TW>OWr@>b{7Bzz3q@~4&&RjK_OqVM5L>FPVEj|eh25(P;~>C$)YR1MeUeAMNJs%=e!sZPg3@z!9d|@5(mOZf843tZDLmTP z*(-n4J89X&ir;s}w(72jRNQ7MZEOy~@D<1J_B%C=Y`2g>2Ta&lbDxaOHR@8RRsm64 zZ@9t|=iHmAjXyZ=8Zj3(aE&JZ1=Uzkip)|C{A2b%pkTs>{;Ym{nf?bJk}9`e?MNhW z$A45r62UFt2VK={(LYE4(q@0^r-t6xOv@t~UlBi$9DPAe46T57v>*4V%!V0s z0ya?JXHYgwy46S{U?XdKa34%27m&}MesHjr_&%_T$!YKMA=Jl_^+3AIe9i?*UB<<+ zBmxq&+-&8Al^c`=L|l}|&{PT>iJOy4y zaT6Ghk9%$3ukHVIch#0I9_6fHD#@hAfuyh%G?f1-3C*4qIF@w3~aUSQ-!hd`?z_T~yzx+<9gp58y)$GDdqmd3MV24YJ)czd8e~7deySRTdA;0%2cDTey`H+9CJMO&)Apg^C z#H!f^ehK-X>0k#-jC2ytycY6VaFLf%3on1mUGHPmeEfONWOX+$E?st6_9naQqAm0_|(Zvs22YfAG zg=y*QF5NE(^O-Wpf?bD0KPbdozd?v~$rn;vQ%htuGc3H}c;Y6K;B|o^haA*85iQ(F zm8->BRVx2VwP0pLp5VyDy;J?0@*m~-E*Lx*+99@k5som~(Nn$3=ihshSmhDjwU zd&(6VWCJb)U|5kX&I7T|1cVEh^g1FdUu)qi9H%HR@~T!2nfiN0RQR1){7%9%3Lm~z z&>~*P;BQ3!FG0wY=|K%eZH}j1_>PCU#Tr;7t9B$o0;SYeNfgxucjhUPqUBpu^GH-| zr)a%d$a=ODvXqyd>EZ4-UCy-EzV~p1&x{^M-Vx$AQ7>wrmX}-HH8^mRyzpJx9!=d^E;HI95g;U;$9<+`dG||HzIuQv^IzFO z#^xL~aAFpUqdpzJq173iV88kmvA0w`zaWf$x0Zkr33*VNrs|~&Ns$4IEAcPdBBYMw ztrejWXeB1`u(>Q}JOPmU5RY*$7gqd^xi|H9 qRDbdI>=5J-53nUHiSaj%i*wghb(K0R5i7)Eay_AeXvj1n9*}T z^ceof!nSJoZEY>|Mk2|@KA-lo!x1B|SEEoUPSI$bVzD@>sxd}9WVNc)(xQ^nso^@6 z?PJW}+T0vJ(CHj-H+%+DB_R|r#j4S$RtW^u zs>c%>aXMo)Nm6RaNe%NO(7)pM$142U=Ti}50`Y3(a;bl{*-}Ra0z24v4b}+ugXE&_ zOJ^?@cXr$DsdM~(wW=s_^7&N)U)63`n7O7X8nJb#>PEdbI4oG=~SwSV+47?{TgD;EfRwC z8Un-jilNS~`zV)t_78;;pEoxv)Y_^JLu1qe*RrDP%=&U2@%k2vifg#;xi%7HwZ+NQ z%=#t}OOhgTf_;Edqj)^7=Y`{8f02kbY_lnPF2do|&3o)|fU90l|5Oa4buSisey%79 zuqkA>$A($oa75KLx7k#kD;`gyE;5KGjrlBPG6hN`^5D$ja}MY7h$qLoB8D8sS?Hc5 zhck(Bit7gZJEq5iI7V7pqE+k@_$WL)bLOF~MhxG*mIeonoXK+kPh{v7iNuKao!P8l zEfowY)K3QSFmI01={B$ysMXU3_A+=&WV02)Q^L7+aFoGW#0|#<{Wt2(V%e_OZjW#BdZX~EVV}jx z<4Gb9Y2>|t7~06;Xw%s;nGVENrev}cEL~vfz_<&H-QerQ{axs#UHUmbABl7z{tkTZ zKs+U!E5T$GNn@&9%`OZ+R5Lh%b{ly2WnKtd=C1`}S}! znAA0jMhnojfVIldnVH*lCQa+cnq8F3^+MxrF!bss%e}a^k5cJA#MuYtUaX}~;`;Om`T+Vb_DiT|7W3lYH|7B6^qyNNbf3mOB@l=Y zyWMHzlWVs~g+eDdJFreC#=X#`n^LJ>=xcB)N+0sl2d;5go0-Rf*BEQsIK(s#=f|Ob zjBzYx#HFfye-F-g!&fJKc0!vX?k{4!Y=wI;a`KTguyfpq;j4Aj=(Uq4Pwj}slAm$C zXj*ouV$hQ@(F57y}0%*`Ck#jMQF>^#TDbIi+Qo>vs(I-ZNi`}NO>M8AFw z$HzJ2{P_Ky$Z;p?zldI(8wL~hN82U!9Psn)OLf%voJ_VaL)|0(9G*!B4 z+S-Bj+DGE?Jf0h=&$HPbx{MgU+K(nq+&v!(Wj;0fTzN!QJE04&*{kcv+`J~|o9owL z#s0*8jE2h;2^A?EERf%qhkiNo`f}t8WGR3i6$<7l94g?tA}Ns)?rDd0Lho+)<{C6& z(X@W}@7Hs~x#KwU`5xq;z2b1>5L4F$^&EWV`$aC-GoSY;dff=uN(_vwH`fH`UzVXA z;*oXU5_r)w{TVWQlO#ME3G@o#jF51IaSWlq2g&IOQZtUi$#Xd8#xoc_ShOa{=|lew z;Mou=A*K$nHnbXt+8+;&e$>!-%=e-Gd#c>8GMUnv9e3O_#4${t{>46+K7D9xB+~w1 zBvOXP-4$J9J-G@z8HP zxch6G)`Ps3vHpa;>p9r`T=saT=Fz`CBaZRarnNAdVvnCdB}(7J-$;~z|GpR zuDm{THh4~qSU2-7z?kQMTQ?q`A{)ln&BwjJ!{>#t-{IT|i0#ObmG<#ED2H5fojH*Y zImpj&&IR|Z3Fxl_6|N`j?}vq0pljdg`F{Vz6O3NhUs0mGZ@`Ya^s(ls=N{yH4!C(O z=3=G><4JWk=J}7hojU4xree{V_whftl?h)dGzrY6YhT<~(A^S`BNA%_cMLkG$~x z?349ah*(&Y<56opZjWBOdXGX~tLoO+&m6;)!O{Gs(vA22m3wj0ygk6^Mx2M)hsj*``QJ~(_qfQQZOE~@t9-Dz`}^{IOLaoupXSZ z)1p>ApS)k%oL=nfB&pGE@K2<;Hi#H@+kP~ExjY5@1Ek8`Rqo~6dfa*~v)-%)`)x3v zU*~1kKfo@5T?+eS{dhUp&s8KU+0CTXbsx<>I)*~Mu6A`xdhDzP>%wcDff&w)pCdwc zJVQd{54P1bbpZQ#JM`AwCy(ZjC#K$_Dig^YDpgutAv!u_qs8Fnn&!F~&3tj4b19C0 z0_!r^Ww6UNNw=Z6L%XjoOrG*H$<7b8;k( zeH@QZ!an%Xz-WF&nQ~z&z6}XquCha`2ka6wx9VE3uZGTC7rX|uE{9zS)~jGw$1ONo zXhl*&{YZMPbIo&&d>!}bIj$`y>TF)f@YBd6ugSV`JsuObk;M}ok?~y1q_+QCclX|H zqxn;*-HuKt2T6Dn)j5F{)U*V4tDaM?59YpX6f^SX!*x14K^gX^f*6R5PHHx>(1UY|aFu8;W}-<$h; z_ueI$8l*9({bR${8sB%3Y9+1_u8rj|)_Eu)>Acs2cLnSQFyC0WTT&9;j4}5_8}w`g zKXY?!XjX|-SOVilER8sr-v<5}=tJz2b>X$HfN`!b1;-_-nRfSjDk9KJrTnh9F}tC^ z{;p`NJ$E`ZrY0wS81*L5b4*p%oAbz8u&?XD%^EW|Gv5Sb-dka})$N|Nab0hVL^66x z4*X%Og=|(UiMmNR1~8XGEF6cfKdxi_ng3?^S_$8rhejOBG%M=WMEm*OHGyYqI=;<1 zi=}vNFgQ4^5eFX&<(+QQ!g)Gf7M103zQ=;Pmgsu0Uju)vEweKB?XWw+dl&5Px;>ON zV%5NvgayH=bK7hr*f<7@VQ!AWCQ%y3b;k8}D4rF6fiGT%bIQ5k`n(dgdUagT%pkra zDdTHFyaNy-g5LvaJO{cKHe$$Remut>?!@zBYz;l6#`m$GW$@7*wbKmMuIqhI+Dvz6 zB)S)NAM63x{jgOzgI~tJm7(ueb>=42(pIKs8Y4;6gczDR4vb~f7|Kawz|Z@IpY0N{ z2CNP1#Bp#g{+zJVHQ=8X#&>UJfIODYn#t7pxey)rZHwO>k%3(}hQ7#LSwttSJyv$p z%EZ{}5bnDJe*S=?knOnFLB|zb^hnkMX0yK5!&vW8*dtjpJ(Dxj3gjvV?Hyn=Su8Zh zWTG+nZrv1#P!rz6HEVdE1rr!M!(mFg9F#E$a+^*1K6@N~I0u~5JM>&wP^(tDQWLaw z7~jQ$yMTWmvbW3t`;5O!(%yJ)G4&#RkJEqGi^498X5gLA4GB?QnY8ITaGmV0Apf$1 zw%IyD50zW!@l+E%2EA8dy(hu_1nl{|SmJ{*Y=p^#E7Y@5zC*ilv zuP(xm8J*v?(-E-_wflqRi1)6PrONlSKaOD@{9MrCrl<1~Jqhlo!TStsb=_VlnCX=^ zn_kDlWFtS`e~N6*;O7{&u(9~;$#5Jw+BK=s!#Nvr*rex|^U5`OciKkxq)oM>qSzyW z!zkpr81JI4!S8^TfA{&W#qXIR*peS}{cO%bbf;g>S5&$$EvkP>+iG0jkHg<;X#5;B zdM0PmnOW}_U@sL+^fK&4*qRdZokFgnF`c~yj7?i`ZyARV=S4b4v(qZpFwxVn$FLsn zg@-cE+Kov;eUWXeB6t__iAw0-}Nrge-rb&-}cD3J8uNX zW7(~SAIe(6Z`8@N;AQR?p*1tV3VRLqSN&+F4~l|T6!3c&Jj`ile$+_wR}A^U+*p_u z=1ilGQaQRf8-hQ9dX%uXwfbaM(EJ#FFUO|s*PFd8Bkdbenz85!))RF=Zv z;u<&Q@?>f&lBrZCbGd`e?VX147;~afqyXwnq_Z?7m7r(y7UWl|y^s?lE7Cp+M7KV< z!8m>TVoO`w^MOL)MN?xAdVlF%#9;lMyD03o?HQW(*(=avb>1?p*Ee*29rh-e--f*d z-Zijyi)Q+$BO`E7Zp2PcqSl99|IE~+oUwo!9Te3IK4K?~vY{#9KCY8Ux-6ptJhF>d~ zYpnM>#b#Oyd%t9&4|Frr-^zmSDBu}WER$#a1hQ{8nXFTHCflxiko`x~$Ubc^YMGAS zx7WU8-}@)VaoXPcISJRuQ>Ky_7_41bQt8b?6CIK&UoX0zY-Xm$yIJNHVhDeS`?BT@ z?#7Y##O4?xJ8XAlO8Jm$``x0bzFjm|*FtmVURP?S4Y2iPi9Q4W)mU2$PNMLxyOSNP zj{Rnm!?51DHikLMgp&Y#aA`%e#|;C?e|V$bPxR9`opDJL%$ z3k=2vdxPz}9`$|Q$U|ng%;mY{{cB4$+K4*&u+%)fu4Jx$1on+(Si6NPn7^eLy=2e5 zCs{@*Kawu=zM1cLI5SGoRc?&LihxhgVt;`31G? zw$I82qYz(xPuMv3U61$H|DGWR?`=9Ooj>M@g8$>sI+|%yyP!|XO(Xx+-dz2p-8xb& zirN$X;6HE{wH|&H`HltKZ%?Myg^S3$Xfb)uIGcQnmyqx5^9(y{33<;vhrFksMc##{ zaTc{Mxq$o^UP^&WmQi5oati$E3d5FNNrB6*!WeUxUPk_l{#f(j zTJNcgNj~V9J()!e4SnOg{%>RbrgL~_GzMNb`|ME$;y}*fYO#2*{`c(0cY<%?`M&e|z8>}doqNIjRA=tSa@$^S$He^G2F6_zy71D9 z8*I^=@2E!Zet@F)Jwn0zAEoxU-=`^?DwKNVO$tA>ilPrcLGpc%j708wU_`&}{AGtQ z*AK1z*Tp)-e{ZVqjV;gTPWk;j1fzWkFV&*Yze@S{Hqf|FKcgh#P+ok! z7JL4+in99Un)>=Xq}+PX)eS#lf$?3S@%exAh(0w&-{Tz1sCU}grPrPqd-4U+)_qLc zn)Rfu-B69KU0;o?SzpyY_|Izm!;O^qcoW4pd`jx7=dLOErrVkG|3dq3(_{2|dFAY@ zchR1D`O(Dt8!1&IO5?^1jE~7pHHxqMD@i#ONKm~@A(({4Qk-u|NgDO_g3J4007NtQUCw| literal 0 HcmV?d00001 From fd7b7ba2476e7bed37c7e59d1b54fb98501ff17e Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Mon, 15 Feb 2010 20:48:06 -0600 Subject: [PATCH 027/713] The set protocol, with implementations on hashsets, sequences and bitsets --- extra/bags/bags-tests.factor | 127 +++++++++++++++++++++++++++++++ extra/bags/bags.factor | 143 +++++++++++++++++++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 extra/bags/bags-tests.factor create mode 100644 extra/bags/bags.factor diff --git a/extra/bags/bags-tests.factor b/extra/bags/bags-tests.factor new file mode 100644 index 0000000000..d5d4fc0001 --- /dev/null +++ b/extra/bags/bags-tests.factor @@ -0,0 +1,127 @@ +! Copyright (C) 2010 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: bags tools.test kernel sorting prettyprint bit-arrays arrays ; +IN: bags.tests + +[ { } ] [ { } { } intersect ] unit-test +[ { 2 3 } ] [ { 1 2 3 } { 2 3 4 } intersect ] unit-test + +[ { } ] [ { } { } diff ] unit-test +[ { 1 } ] [ { 1 2 3 } { 2 3 4 } diff ] unit-test + +[ { } ] [ { } { } union ] unit-test +[ { 1 2 3 4 } ] [ { 1 2 3 } { 2 3 4 } union ] unit-test + +[ t ] [ { 1 2 } { 1 3 } intersects? ] unit-test + +[ f ] [ { 4 2 } { 1 3 } intersects? ] unit-test + +[ f ] [ { } { 1 } intersects? ] unit-test + +[ f ] [ { 1 } { } intersects? ] unit-test + +[ t ] [ 4 { 2 4 5 } in? ] unit-test +[ f ] [ 1 { 2 4 5 } in? ] unit-test + +[ V{ 1 2 3 } ] [ 3 V{ 1 2 } clone [ add ] keep ] unit-test +[ V{ 1 2 2 } ] [ 2 V{ 1 2 } clone [ add ] keep ] unit-test +[ V{ 1 2 } ] [ 3 V{ 1 2 } clone [ delete ] keep ] unit-test +[ V{ 2 } ] [ 1 V{ 1 2 } clone [ delete ] keep ] unit-test + +[ t ] [ { 1 2 3 } { 2 1 3 } set= ] unit-test +[ f ] [ { 2 3 } { 1 2 3 } set= ] unit-test +[ f ] [ { 1 2 3 } { 2 3 } set= ] unit-test + +[ { 1 } ] [ { 1 } items ] unit-test + +[ { 1 2 3 } ] [ { 1 1 1 2 2 3 3 3 3 3 } dup set-like natural-sort ] unit-test +[ { 1 2 3 } ] [ HS{ 1 2 3 } { } set-like natural-sort ] unit-test + +[ HS{ 1 2 3 } ] [ { 1 2 3 } fast-set ] unit-test + +[ { 1 2 3 } ] [ HS{ 1 2 3 } items natural-sort ] unit-test + +[ "HS{ 1 2 3 4 }" ] [ HS{ 1 2 3 4 } unparse ] unit-test + +[ t ] [ 1 HS{ 0 1 2 } in? ] unit-test +[ f ] [ 3 HS{ 0 1 2 } in? ] unit-test +[ HS{ 1 2 3 } ] [ 3 HS{ 1 2 } clone [ add ] keep ] unit-test +[ HS{ 1 2 } ] [ 2 HS{ 1 2 } clone [ add ] keep ] unit-test +[ HS{ 1 2 3 } ] [ 4 HS{ 1 2 3 } clone [ delete ] keep ] unit-test +[ HS{ 1 2 } ] [ 3 HS{ 1 2 3 } clone [ delete ] keep ] unit-test +[ HS{ 1 2 } ] [ HS{ 1 2 } fast-set ] unit-test +[ { 1 2 } ] [ HS{ 1 2 } items natural-sort ] unit-test + +[ HS{ 1 2 3 4 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } union ] unit-test +[ HS{ 2 3 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } intersect ] unit-test +[ t ] [ HS{ 1 2 3 } HS{ 2 3 4 } intersects? ] unit-test +[ f ] [ HS{ 1 } HS{ 2 3 4 } intersects? ] unit-test +[ f ] [ HS{ 1 } HS{ 2 3 4 } subset? ] unit-test +[ f ] [ HS{ 1 2 3 } HS{ 2 3 4 } subset? ] unit-test +[ t ] [ HS{ 2 3 } HS{ 2 3 4 } subset? ] unit-test +[ t ] [ HS{ } HS{ 2 3 4 } subset? ] unit-test +[ HS{ 1 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } diff ] unit-test +[ t ] [ HS{ 1 2 3 } HS{ 2 1 3 } set= ] unit-test +[ t ] [ HS{ 1 2 3 } HS{ 2 1 3 } = ] unit-test +[ f ] [ HS{ 2 3 } HS{ 2 1 3 } set= ] unit-test +[ f ] [ HS{ 1 2 3 } HS{ 2 3 } set= ] unit-test + +[ HS{ 1 2 } HS{ 1 2 3 } ] [ HS{ 1 2 } clone dup clone [ 3 swap add ] keep ] unit-test + +[ T{ bit-set f ?{ t f t f t f } } ] [ + T{ bit-set f ?{ t f f f t f } } + T{ bit-set f ?{ f f t f t f } } union +] unit-test + +[ T{ bit-set f ?{ f f f f t f } } ] [ + T{ bit-set f ?{ t f f f t f } } + T{ bit-set f ?{ f f t f t f } } intersect +] unit-test + +[ T{ bit-set f ?{ t f t f f f } } ] [ + T{ bit-set f ?{ t t t f f f } } + T{ bit-set f ?{ f t f f t t } } diff +] unit-test + +[ f ] [ + T{ bit-set f ?{ t t t f f f } } + T{ bit-set f ?{ f t f f t t } } subset? +] unit-test + +[ t ] [ + T{ bit-set f ?{ t t t f f f } } + T{ bit-set f ?{ f t f f f f } } subset? +] unit-test + +[ t ] [ + { 0 1 2 } + T{ bit-set f ?{ f t f f f f } } subset? +] unit-test + +[ f ] [ + T{ bit-set f ?{ f t f f f f } } + T{ bit-set f ?{ t t t f f f } } subset? +] unit-test + +[ f ] [ + { 1 } + T{ bit-set f ?{ t t t f f f } } subset? +] unit-test + +[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } items ] unit-test + +[ t { 1 2 3 } ] [ + { 1 2 } 5 set-like + [ bit-set? ] keep + 3 over add + items >array natural-sort +] unit-test + +[ V{ 0 1 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 1 swap add ] keep items ] unit-test +[ T{ bit-set f ?{ t f t f f t } } clone [ 9 swap add ] keep items ] must-fail +[ T{ bit-set f ?{ t f t f f t } } clone [ "foo" swap add ] keep items ] must-fail + +[ V{ 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 0 swap delete ] keep items ] unit-test +[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 1 swap delete ] keep items ] unit-test +[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 9 swap delete ] keep items ] unit-test +[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ "foo" swap delete ] keep items ] unit-test diff --git a/extra/bags/bags.factor b/extra/bags/bags.factor new file mode 100644 index 0000000000..9988291612 --- /dev/null +++ b/extra/bags/bags.factor @@ -0,0 +1,143 @@ +! Copyright (C) 2010 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: accessors assocs bit-arrays bit-sets hashtables kernel +math sequences parser prettyprint.custom ; +QUALIFIED: sets +IN: bags +! The vocab is called bags for now, but only until it gets into core +! All the code here is in the style that could be put in core + +! Set protocol +MIXIN: set +GENERIC: adjoin ( elt set -- ) +GENERIC: in? ( elt set -- ? ) +GENERIC: delete ( elt set -- ) +GENERIC: set-like ( set exemplar -- set' ) +GENERIC: fast-set ( set -- set' ) +GENERIC: items ( set -- sequence ) +GENERIC: union ( set1 set2 -- set ) +GENERIC: intersect ( set1 set2 -- set ) +GENERIC: intersects? ( set1 set2 -- ? ) +GENERIC: diff ( set1 set2 -- set ) +GENERIC: subset? ( set1 set2 -- ? ) +GENERIC: set= ( set1 set2 -- ? ) + +! Defaults for some methods. +! Override them for efficiency + +M: set union + [ [ items ] bi@ append ] keep set-like ; + + + +M: set intersect + [ sequence/tester filter ] keep set-like ; + +M: set diff + [ sequence/tester [ not ] compose filter ] keep set-like ; + +M: set intersects? + sequence/tester any? ; + +M: set subset? + sequence/tester all? ; + +M: set set= + 2dup subset? [ swap subset? ] [ 2drop f ] if ; + +M: set fast-set ; + +! Hash sets +! In a better implementation, less memory would be used +TUPLE: hash-set { table hashtable read-only } ; + +: ( items -- hash-set ) + sets:unique hash-set boa ; + +INSTANCE: hash-set set +M: hash-set in? table>> key? ; inline +M: hash-set adjoin table>> dupd set-at ; inline +M: hash-set delete table>> delete-at ; inline +M: hash-set items table>> keys ; inline +M: hash-set set-like + drop dup hash-set? [ items ] unless ; +M: hash-set clone + table>> clone hash-set boa ; + +SYNTAX: HS{ + \ } [ ] parse-literal ; + +M: hash-set pprint* pprint-object ; +M: hash-set pprint-delims drop \ HS{ \ } ; +M: hash-set >pprint-sequence items ; + +! Sequences are sets +INSTANCE: sequence set +M: sequence in? member? ; inline +M: sequence adjoin sets:adjoin ; inline +M: sequence delete remove! drop ; inline +M: sequence set-like + [ dup sequence? [ sets:prune ] [ items ] if ] dip + like ; +M: sequence items ; +M: sequence fast-set ; + +! Bit sets are sets +TUPLE: bit-set { table bit-array read-only } ; + +: ( capacity -- bit-set ) + bit-set boa ; + +INSTANCE: bit-set set + +M: bit-set in? + over integer? [ table>> ?nth ] [ 2drop f ] if ; inline + +M: bit-set adjoin + ! This is allowed to crash when the elt couldn't go in the set + [ t ] 2dip table>> set-nth ; + +M: bit-set delete + ! This isn't allowed to crash if the elt wasn't in the set + over integer? [ + table>> 2dup bounds-check? [ + [ f ] 2dip set-nth + ] [ 2drop ] if + ] [ 2drop ] if ; + +! If you do binary set operations with a bitset, it's expected +! that the other thing can also be represented as a bitset +! of the same length. +: (bit-set-op) ( set1 set2 -- table1 table2 ) + [ set-like ] keep [ table>> ] bi@ ; inline + +: bit-set-op ( set1 set2 quot: ( table1 table2 -- table ) -- bit-set ) + [ (bit-set-op) ] dip call bit-set boa ; inline + +M: bit-set union + [ bit-set-union ] bit-set-op ; + +M: bit-set intersect + [ bit-set-intersect ] bit-set-op ; + +M: bit-set diff + [ bit-set-diff ] bit-set-op ; + +M: bit-set subset? + (bit-set-op) swap bit-set-subset? ; + +M: bit-set items + [ table>> length iota ] keep [ in? ] curry filter ; + +M: bit-set set-like + ! This crashes if there are keys that can't be put in the bit set + over bit-set? [ 2dup [ table>> ] bi@ length = ] [ f ] if + [ drop ] [ + [ items ] dip table>> length + [ [ adjoin ] curry each ] keep + ] if ; From 8c322a9bf8934c2d7338b1aa0ace61b1ec662c01 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Mon, 15 Feb 2010 20:52:49 -0600 Subject: [PATCH 028/713] Fixing sets unit tests --- extra/bags/bags-tests.factor | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/extra/bags/bags-tests.factor b/extra/bags/bags-tests.factor index d5d4fc0001..c9112a677b 100644 --- a/extra/bags/bags-tests.factor +++ b/extra/bags/bags-tests.factor @@ -23,8 +23,8 @@ IN: bags.tests [ t ] [ 4 { 2 4 5 } in? ] unit-test [ f ] [ 1 { 2 4 5 } in? ] unit-test -[ V{ 1 2 3 } ] [ 3 V{ 1 2 } clone [ add ] keep ] unit-test -[ V{ 1 2 2 } ] [ 2 V{ 1 2 } clone [ add ] keep ] unit-test +[ V{ 1 2 3 } ] [ 3 V{ 1 2 } clone [ adjoin ] keep ] unit-test +[ V{ 1 2 } ] [ 2 V{ 1 2 } clone [ adjoin ] keep ] unit-test [ V{ 1 2 } ] [ 3 V{ 1 2 } clone [ delete ] keep ] unit-test [ V{ 2 } ] [ 1 V{ 1 2 } clone [ delete ] keep ] unit-test @@ -45,8 +45,8 @@ IN: bags.tests [ t ] [ 1 HS{ 0 1 2 } in? ] unit-test [ f ] [ 3 HS{ 0 1 2 } in? ] unit-test -[ HS{ 1 2 3 } ] [ 3 HS{ 1 2 } clone [ add ] keep ] unit-test -[ HS{ 1 2 } ] [ 2 HS{ 1 2 } clone [ add ] keep ] unit-test +[ HS{ 1 2 3 } ] [ 3 HS{ 1 2 } clone [ adjoin ] keep ] unit-test +[ HS{ 1 2 } ] [ 2 HS{ 1 2 } clone [ adjoin ] keep ] unit-test [ HS{ 1 2 3 } ] [ 4 HS{ 1 2 3 } clone [ delete ] keep ] unit-test [ HS{ 1 2 } ] [ 3 HS{ 1 2 3 } clone [ delete ] keep ] unit-test [ HS{ 1 2 } ] [ HS{ 1 2 } fast-set ] unit-test @@ -66,7 +66,7 @@ IN: bags.tests [ f ] [ HS{ 2 3 } HS{ 2 1 3 } set= ] unit-test [ f ] [ HS{ 1 2 3 } HS{ 2 3 } set= ] unit-test -[ HS{ 1 2 } HS{ 1 2 3 } ] [ HS{ 1 2 } clone dup clone [ 3 swap add ] keep ] unit-test +[ HS{ 1 2 } HS{ 1 2 3 } ] [ HS{ 1 2 } clone dup clone [ 3 swap adjoin ] keep ] unit-test [ T{ bit-set f ?{ t f t f t f } } ] [ T{ bit-set f ?{ t f f f t f } } @@ -113,13 +113,13 @@ IN: bags.tests [ t { 1 2 3 } ] [ { 1 2 } 5 set-like [ bit-set? ] keep - 3 over add + 3 over adjoin items >array natural-sort ] unit-test -[ V{ 0 1 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 1 swap add ] keep items ] unit-test -[ T{ bit-set f ?{ t f t f f t } } clone [ 9 swap add ] keep items ] must-fail -[ T{ bit-set f ?{ t f t f f t } } clone [ "foo" swap add ] keep items ] must-fail +[ V{ 0 1 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 1 swap adjoin ] keep items ] unit-test +[ T{ bit-set f ?{ t f t f f t } } clone [ 9 swap adjoin ] keep items ] must-fail +[ T{ bit-set f ?{ t f t f f t } } clone [ "foo" swap adjoin ] keep items ] must-fail [ V{ 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 0 swap delete ] keep items ] unit-test [ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 1 swap delete ] keep items ] unit-test From c36ff9dab88fbe7bdbaa86e33d4590c6e9df28f6 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Mon, 15 Feb 2010 21:08:54 -0600 Subject: [PATCH 029/713] Renaming items->members in sets --- extra/bags/bags-tests.factor | 24 ++++++++++++------------ extra/bags/bags.factor | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/extra/bags/bags-tests.factor b/extra/bags/bags-tests.factor index c9112a677b..13b5894ce1 100644 --- a/extra/bags/bags-tests.factor +++ b/extra/bags/bags-tests.factor @@ -32,14 +32,14 @@ IN: bags.tests [ f ] [ { 2 3 } { 1 2 3 } set= ] unit-test [ f ] [ { 1 2 3 } { 2 3 } set= ] unit-test -[ { 1 } ] [ { 1 } items ] unit-test +[ { 1 } ] [ { 1 } members ] unit-test [ { 1 2 3 } ] [ { 1 1 1 2 2 3 3 3 3 3 } dup set-like natural-sort ] unit-test [ { 1 2 3 } ] [ HS{ 1 2 3 } { } set-like natural-sort ] unit-test [ HS{ 1 2 3 } ] [ { 1 2 3 } fast-set ] unit-test -[ { 1 2 3 } ] [ HS{ 1 2 3 } items natural-sort ] unit-test +[ { 1 2 3 } ] [ HS{ 1 2 3 } members natural-sort ] unit-test [ "HS{ 1 2 3 4 }" ] [ HS{ 1 2 3 4 } unparse ] unit-test @@ -50,7 +50,7 @@ IN: bags.tests [ HS{ 1 2 3 } ] [ 4 HS{ 1 2 3 } clone [ delete ] keep ] unit-test [ HS{ 1 2 } ] [ 3 HS{ 1 2 3 } clone [ delete ] keep ] unit-test [ HS{ 1 2 } ] [ HS{ 1 2 } fast-set ] unit-test -[ { 1 2 } ] [ HS{ 1 2 } items natural-sort ] unit-test +[ { 1 2 } ] [ HS{ 1 2 } members natural-sort ] unit-test [ HS{ 1 2 3 4 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } union ] unit-test [ HS{ 2 3 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } intersect ] unit-test @@ -108,20 +108,20 @@ IN: bags.tests T{ bit-set f ?{ t t t f f f } } subset? ] unit-test -[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } items ] unit-test +[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } members ] unit-test [ t { 1 2 3 } ] [ { 1 2 } 5 set-like [ bit-set? ] keep 3 over adjoin - items >array natural-sort + members >array natural-sort ] unit-test -[ V{ 0 1 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 1 swap adjoin ] keep items ] unit-test -[ T{ bit-set f ?{ t f t f f t } } clone [ 9 swap adjoin ] keep items ] must-fail -[ T{ bit-set f ?{ t f t f f t } } clone [ "foo" swap adjoin ] keep items ] must-fail +[ V{ 0 1 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 1 swap adjoin ] keep members ] unit-test +[ T{ bit-set f ?{ t f t f f t } } clone [ 9 swap adjoin ] keep members ] must-fail +[ T{ bit-set f ?{ t f t f f t } } clone [ "foo" swap adjoin ] keep members ] must-fail -[ V{ 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 0 swap delete ] keep items ] unit-test -[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 1 swap delete ] keep items ] unit-test -[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 9 swap delete ] keep items ] unit-test -[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ "foo" swap delete ] keep items ] unit-test +[ V{ 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 0 swap delete ] keep members ] unit-test +[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 1 swap delete ] keep members ] unit-test +[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 9 swap delete ] keep members ] unit-test +[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ "foo" swap delete ] keep members ] unit-test diff --git a/extra/bags/bags.factor b/extra/bags/bags.factor index 9988291612..78ffd8f781 100644 --- a/extra/bags/bags.factor +++ b/extra/bags/bags.factor @@ -14,7 +14,7 @@ GENERIC: in? ( elt set -- ? ) GENERIC: delete ( elt set -- ) GENERIC: set-like ( set exemplar -- set' ) GENERIC: fast-set ( set -- set' ) -GENERIC: items ( set -- sequence ) +GENERIC: members ( set -- sequence ) GENERIC: union ( set1 set2 -- set ) GENERIC: intersect ( set1 set2 -- set ) GENERIC: intersects? ( set1 set2 -- ? ) @@ -26,12 +26,12 @@ GENERIC: set= ( set1 set2 -- ? ) ! Override them for efficiency M: set union - [ [ items ] bi@ append ] keep set-like ; + [ [ members ] bi@ append ] keep set-like ; @@ -56,16 +56,16 @@ M: set fast-set ; ! In a better implementation, less memory would be used TUPLE: hash-set { table hashtable read-only } ; -: ( items -- hash-set ) +: ( members -- hash-set ) sets:unique hash-set boa ; INSTANCE: hash-set set M: hash-set in? table>> key? ; inline M: hash-set adjoin table>> dupd set-at ; inline M: hash-set delete table>> delete-at ; inline -M: hash-set items table>> keys ; inline +M: hash-set members table>> keys ; inline M: hash-set set-like - drop dup hash-set? [ items ] unless ; + drop dup hash-set? [ members ] unless ; M: hash-set clone table>> clone hash-set boa ; @@ -74,7 +74,7 @@ SYNTAX: HS{ M: hash-set pprint* pprint-object ; M: hash-set pprint-delims drop \ HS{ \ } ; -M: hash-set >pprint-sequence items ; +M: hash-set >pprint-sequence members ; ! Sequences are sets INSTANCE: sequence set @@ -82,9 +82,9 @@ M: sequence in? member? ; inline M: sequence adjoin sets:adjoin ; inline M: sequence delete remove! drop ; inline M: sequence set-like - [ dup sequence? [ sets:prune ] [ items ] if ] dip + [ dup sequence? [ sets:prune ] [ members ] if ] dip like ; -M: sequence items ; +M: sequence members ; M: sequence fast-set ; ! Bit sets are sets @@ -131,13 +131,13 @@ M: bit-set diff M: bit-set subset? (bit-set-op) swap bit-set-subset? ; -M: bit-set items +M: bit-set members [ table>> length iota ] keep [ in? ] curry filter ; M: bit-set set-like ! This crashes if there are keys that can't be put in the bit set over bit-set? [ 2dup [ table>> ] bi@ length = ] [ f ] if [ drop ] [ - [ items ] dip table>> length + [ members ] dip table>> length [ [ adjoin ] curry each ] keep ] if ; From f01487eb8351fba796ca65a821df8ad89eeb3415 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 16 Feb 2010 23:52:38 +1300 Subject: [PATCH 030/713] A few documentation fixes --- basis/math/vectors/simd/simd-docs.factor | 24 ++++++++++++++++--- basis/stack-checker/errors/errors-docs.factor | 6 ++--- core/combinators/combinators-docs.factor | 6 ++--- core/sequences/sequences-docs.factor | 4 +--- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/basis/math/vectors/simd/simd-docs.factor b/basis/math/vectors/simd/simd-docs.factor index 540838bdd5..bcc05564fc 100644 --- a/basis/math/vectors/simd/simd-docs.factor +++ b/basis/math/vectors/simd/simd-docs.factor @@ -8,7 +8,7 @@ ARTICLE: "math.vectors.simd.intro" "Introduction to SIMD support" $nl "SIMD support in the processor takes the form of instruction sets which operate on vector registers. By operating on multiple scalar values at the same time, code which operates on points, colors, and other vector data can be sped up." $nl -"In Factor, SIMD support is exposed in the form of special-purpose SIMD " { $link "sequence-protocol" } " implementations. These are fixed-length, homogeneous sequences. They are referred to as vectors, but should not be confused with Factor's " { $link "vectors" } ", which can hold any type of object and can be resized.)." +"In Factor, SIMD support is exposed in the form of special-purpose SIMD " { $link "sequence-protocol" } " implementations. These are fixed-length, homogeneous sequences. They are referred to as vectors, but should not be confused with Factor's " { $link "vectors" } ", which can hold any type of object and can be resized." $nl "The words in the " { $vocab-link "math.vectors" } " vocabulary, which can be used with any sequence of numbers, are special-cased by the compiler. If the compiler can prove that only SIMD vectors are used, it expands " { $link "math-vectors" } " into " { $link "math.vectors.simd.intrinsics" } ". While in the general case, SIMD intrinsics operate on heap-allocated SIMD vectors, that too can be optimized since in many cases the compiler unbox SIMD vectors, storing them directly in registers." $nl @@ -36,7 +36,7 @@ $nl ARTICLE: "math.vectors.simd.types" "SIMD vector types" "Each SIMD vector type is named " { $snippet "scalar-count" } ", where " { $snippet "scalar" } " is a scalar C type and " { $snippet "count" } " is a vector dimension." $nl -"The following vector types are available:" +"The following 128-bit vector types are defined in the " { $vocab-link "math.vectors.simd" } " vocabulary:" { $code "char-16" "uchar-16" @@ -48,6 +48,19 @@ $nl "ulonglong-2" "float-4" "double-2" +} +"Double-width 256-bit vector types are defined in the " { $vocab-link "math.vectors.simd.cords" } " vocabulary:" +{ $code + "char-32" + "uchar-32" + "short-16" + "ushort-16" + "int-8" + "uint-8" + "longlong-4" + "ulonglong-4" + "float-8" + "double-4" } ; ARTICLE: "math.vectors.simd.words" "SIMD vector words" @@ -142,7 +155,12 @@ M\\ actor advance optimized.""" """USE: compiler.tree.debugger M\\ actor advance test-mr mr.""" } -"An example of a high-performance algorithm that uses SIMD primitives can be found in the " { $vocab-link "benchmark.nbody-simd" } " vocabulary." ; +"Example of a high-performance algorithms that use SIMD primitives can be found in the following vocabularies:" +{ $list + { $vocab-link "benchmark.nbody-simd" } + { $vocab-link "benchmark.raytracer-simd" } + { $vocab-link "random.sfmt" } +} ; ARTICLE: "math.vectors.simd.intrinsics" "Low-level SIMD primitives" "The words in the " { $vocab-link "math.vectors.simd.intrinsics" } " vocabulary are used to implement SIMD support. These words have three disadvantages compared to the higher-level " { $link "math-vectors" } " words:" diff --git a/basis/stack-checker/errors/errors-docs.factor b/basis/stack-checker/errors/errors-docs.factor index 4b432e733f..9aa7ed0d14 100644 --- a/basis/stack-checker/errors/errors-docs.factor +++ b/basis/stack-checker/errors/errors-docs.factor @@ -134,10 +134,10 @@ HELP: inconsistent-recursive-call-error } ; ARTICLE: "inference-errors" "Stack checker errors" -"These " { $link "inference" } " failure conditions are reported in one of two ways:" +"Stack effect checking failure conditions are reported in one of two ways:" { $list - { { $link "tools.inference" } " throws them as errors" } - { "The " { $link "compiler" } " reports them via " { $link "tools.errors" } } + { { $link "tools.inference" } " report them when fed quotations interactively" } + { "The " { $link "compiler" } " reports them while compiling words, via the " { $link "tools.errors" } " mechanism" } } "Errors thrown when insufficient information is available to calculate the stack effect of a call to a combinator or macro (see " { $link "inference-combinators" } "):" { $subsections diff --git a/core/combinators/combinators-docs.factor b/core/combinators/combinators-docs.factor index 02114496f4..31183a629e 100644 --- a/core/combinators/combinators-docs.factor +++ b/core/combinators/combinators-docs.factor @@ -176,15 +176,15 @@ ARTICLE: "conditionals" "Conditional combinators" { $subsections "conditionals-boolean-equivalence" } { $see-also "booleans" "bitwise-arithmetic" both? either? } ; -ARTICLE: "dataflow-combinators" "Data flow combinators" -"Data flow combinators express common dataflow patterns such as performing a operation while preserving its inputs, applying multiple operations to a single value, applying a set of operations to a set of values, or applying a single operation to multiple values." +ARTICLE: "dataflow-combinators" "Dataflow combinators" +"Dataflow combinators express common dataflow patterns such as performing a operation while preserving its inputs, applying multiple operations to a single value, applying a set of operations to a set of values, or applying a single operation to multiple values." { $subsections "dip-keep-combinators" "cleave-combinators" "spread-combinators" "apply-combinators" } -"More intricate data flow can be constructed by composing " { $link "curried-dataflow" } "." ; +"More intricate dataflow can be constructed by composing " { $link "curried-dataflow" } "." ; ARTICLE: "combinators-quot" "Quotation construction utilities" "Some words for creating quotations which can be useful for implementing method combinations and compiler transforms:" diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 819b5b2115..02dadb323c 100644 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -1416,9 +1416,7 @@ $nl ARTICLE: "sequences-integers" "Counted loops" "A virtual sequence is defined for iterating over integers from zero." { $subsection iota } -"For example, calling " { $link iota } " on the integer 3 produces a sequence containing the elements 0, 1, and 2. This is very useful for performing counted loops." -$nl -"This means the " { $link each } " combinator, given an integer, simply calls a quotation that number of times, pushing a counter on each iteration that ranges from 0 up to that integer:" +"For example, calling " { $link iota } " on the integer 3 produces a sequence containing the elements 0, 1, and 2. This is very useful for performing counted loops using words such as " { $link each } ":" { $example "3 iota [ . ] each" "0\n1\n2" } "A common idiom is to iterate over a sequence, while also maintaining a loop counter. This can be done using " { $link each-index } ", " { $link map-index } " and " { $link reduce-index } "." $nl From bd0ca0e2aa61db6c1d966e2e7979f23136dd3627 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 17 Feb 2010 00:12:55 +1300 Subject: [PATCH 031/713] Clean up some tags --- basis/cocoa/tags.txt | 1 + basis/images/tags.txt | 2 +- basis/windows/com/tags.txt | 1 + core/alien/tags.txt | 1 + extra/annotations/tags.txt | 3 +-- extra/gpu/demos/bunny/tags.txt | 1 + extra/gpu/demos/raytrace/tags.txt | 1 + extra/svg/tags.txt | 1 - extra/terrain/tags.txt | 1 + extra/trees/splay/tags.txt | 1 - extra/trees/tags.txt | 1 - extra/tty-server/tags.txt | 2 +- extra/webapps/fjsc/tags.txt | 3 ++- 13 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 extra/gpu/demos/bunny/tags.txt create mode 100644 extra/gpu/demos/raytrace/tags.txt create mode 100644 extra/terrain/tags.txt diff --git a/basis/cocoa/tags.txt b/basis/cocoa/tags.txt index 2320bdd648..86dd9eeb91 100644 --- a/basis/cocoa/tags.txt +++ b/basis/cocoa/tags.txt @@ -1,2 +1,3 @@ unportable bindings +ffi diff --git a/basis/images/tags.txt b/basis/images/tags.txt index 04b54a06f4..9347bd326b 100644 --- a/basis/images/tags.txt +++ b/basis/images/tags.txt @@ -1 +1 @@ -bitmap graphics +graphics diff --git a/basis/windows/com/tags.txt b/basis/windows/com/tags.txt index 2320bdd648..86dd9eeb91 100755 --- a/basis/windows/com/tags.txt +++ b/basis/windows/com/tags.txt @@ -1,2 +1,3 @@ unportable bindings +ffi diff --git a/core/alien/tags.txt b/core/alien/tags.txt index 86a7c8e637..7ea420feed 100644 --- a/core/alien/tags.txt +++ b/core/alien/tags.txt @@ -1 +1,2 @@ compiler +ffi diff --git a/extra/annotations/tags.txt b/extra/annotations/tags.txt index 278296de5e..ef1aab0d0e 100644 --- a/extra/annotations/tags.txt +++ b/extra/annotations/tags.txt @@ -1,2 +1 @@ -comments -annotation +tools diff --git a/extra/gpu/demos/bunny/tags.txt b/extra/gpu/demos/bunny/tags.txt new file mode 100644 index 0000000000..cb5fc203e1 --- /dev/null +++ b/extra/gpu/demos/bunny/tags.txt @@ -0,0 +1 @@ +demos diff --git a/extra/gpu/demos/raytrace/tags.txt b/extra/gpu/demos/raytrace/tags.txt new file mode 100644 index 0000000000..cb5fc203e1 --- /dev/null +++ b/extra/gpu/demos/raytrace/tags.txt @@ -0,0 +1 @@ +demos diff --git a/extra/svg/tags.txt b/extra/svg/tags.txt index 0cf061a252..65e8f3eddb 100644 --- a/extra/svg/tags.txt +++ b/extra/svg/tags.txt @@ -1,3 +1,2 @@ xml graphics -svg diff --git a/extra/terrain/tags.txt b/extra/terrain/tags.txt new file mode 100644 index 0000000000..cb5fc203e1 --- /dev/null +++ b/extra/terrain/tags.txt @@ -0,0 +1 @@ +demos diff --git a/extra/trees/splay/tags.txt b/extra/trees/splay/tags.txt index fb6cea7147..42d711b32b 100644 --- a/extra/trees/splay/tags.txt +++ b/extra/trees/splay/tags.txt @@ -1,2 +1 @@ collections -trees diff --git a/extra/trees/tags.txt b/extra/trees/tags.txt index fb6cea7147..42d711b32b 100644 --- a/extra/trees/tags.txt +++ b/extra/trees/tags.txt @@ -1,2 +1 @@ collections -trees diff --git a/extra/tty-server/tags.txt b/extra/tty-server/tags.txt index 587fb228f3..8dfb43b578 100644 --- a/extra/tty-server/tags.txt +++ b/extra/tty-server/tags.txt @@ -1,4 +1,4 @@ tools applications demos -networking +network diff --git a/extra/webapps/fjsc/tags.txt b/extra/webapps/fjsc/tags.txt index 1b93c9eb4d..14d6b62728 100644 --- a/extra/webapps/fjsc/tags.txt +++ b/extra/webapps/fjsc/tags.txt @@ -1 +1,2 @@ -webapp +web +examples From 59bd725c378f4bff12affd8177deb9dddbe4c685 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 17 Feb 2010 00:13:08 +1300 Subject: [PATCH 032/713] websites.concatenative: fix mason web app invocation --- extra/websites/concatenative/concatenative.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/websites/concatenative/concatenative.factor b/extra/websites/concatenative/concatenative.factor index fd4fb7515f..92a4942fe6 100644 --- a/extra/websites/concatenative/concatenative.factor +++ b/extra/websites/concatenative/concatenative.factor @@ -98,7 +98,7 @@ SYMBOL: dh-file test-db "concatenative.org" add-responder test-db "paste.factorcode.org" add-responder test-db "planet.factorcode.org" add-responder - "builds.factorcode.org" add-responder + test-db "builds.factorcode.org" add-responder home "docs" append-path "docs.factorcode.org" add-responder home "cgi" append-path "gitweb.factorcode.org" add-responder main-responder set-global ; From d8c452270596bad65be18dc58295a1635379ca05 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Tue, 16 Feb 2010 03:14:30 -0800 Subject: [PATCH 033/713] Fix docs typo --- basis/command-line/command-line-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/command-line/command-line-docs.factor b/basis/command-line/command-line-docs.factor index 11ee46c227..9a69614766 100644 --- a/basis/command-line/command-line-docs.factor +++ b/basis/command-line/command-line-docs.factor @@ -91,7 +91,7 @@ ARTICLE: "standard-cli-args" "Command line switches for general usage" } ; ARTICLE: "factor-boot-rc" "Bootstrap initialization file" -"The botstrap initialization file is named " { $snippet "factor-boot-rc" } " on Windows and " { $snippet ".factor-boot-rc" } " on Unix. This file can contain " { $link require } " calls for vocabularies you use frequently, and other such long-running tasks that you do not want to perform every time Factor starts." +"The bootstrap initialization file is named " { $snippet "factor-boot-rc" } " on Windows and " { $snippet ".factor-boot-rc" } " on Unix. This file can contain " { $link require } " calls for vocabularies you use frequently, and other such long-running tasks that you do not want to perform every time Factor starts." $nl "A word to run this file from an existing Factor session:" { $subsections run-bootstrap-init } From 4c1cd406c909b967caa61ca31a92f966b64654b1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 17 Feb 2010 00:16:08 +1300 Subject: [PATCH 034/713] Bump version number to 0.93 --- Factor.app/Contents/Info.plist | 4 +++- GNUmakefile | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Factor.app/Contents/Info.plist b/Factor.app/Contents/Info.plist index c87520d0fd..1c07f95643 100644 --- a/Factor.app/Contents/Info.plist +++ b/Factor.app/Contents/Info.plist @@ -31,8 +31,10 @@ Factor CFBundlePackageType APPL + CFBundleVersion + 0.93 NSHumanReadableCopyright - Copyright © 2003-2009, Slava Pestov and friends + Copyright © 2003-2010 Factor developers NSServices diff --git a/GNUmakefile b/GNUmakefile index c4796de63b..eac1c696df 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,7 +4,7 @@ ifdef CONFIG AR = ar LD = ld - VERSION = 0.92 + VERSION = 0.93 BUNDLE = Factor.app LIBPATH = -L/usr/X11R6/lib From c8192adf7113c996adb546c4e8a3fe8619b0ba08 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Tue, 16 Feb 2010 03:25:03 -0800 Subject: [PATCH 035/713] Fix some doc typos, metadata --- basis/db/tuples/tuples-docs.factor | 2 +- core/classes/tuple/tuple-docs.factor | 2 +- extra/chipmunk/summary.txt | 2 +- extra/chipmunk/tags.txt | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 extra/chipmunk/tags.txt diff --git a/basis/db/tuples/tuples-docs.factor b/basis/db/tuples/tuples-docs.factor index 01d65484f3..ebf86371a7 100644 --- a/basis/db/tuples/tuples-docs.factor +++ b/basis/db/tuples/tuples-docs.factor @@ -267,7 +267,7 @@ T{ book { $list "Make a new tuple to represent your data" { "Map the Factor types to the database types with " { $link define-persistent } } - { "Make a custom database combinator (see" { $link "db-custom-database-combinators" } ") to open your database and run a " { $link quotation } } + { "Make a custom database combinator (see " { $link "db-custom-database-combinators" } ") to open your database and run a " { $link quotation } } { "Create a table with " { $link create-table } ", " { $link ensure-table } ", or " { $link recreate-table } } { "Start making and storing objects with " { $link insert-tuple } ", " { $link update-tuple } ", " { $link delete-tuples } ", and " { $link select-tuples } } } ; diff --git a/core/classes/tuple/tuple-docs.factor b/core/classes/tuple/tuple-docs.factor index 2b3e80da1d..0fd7907492 100644 --- a/core/classes/tuple/tuple-docs.factor +++ b/core/classes/tuple/tuple-docs.factor @@ -440,4 +440,4 @@ HELP: boa { $values { "..." "slot values" } { "class" tuple-class } { "tuple" tuple } } { $description "Creates a new instance of " { $snippet "class" } " and fill in the slots from the stack, with the top-most stack element being stored in the right-most slot." } { $notes "The name " { $snippet "boa" } " is shorthand for “by order of arguments”, and “BOA constructor” is a pun on “boa constrictor”." } -{ $errors "Throws an error if the slot values do not match class declarations on slots (see" { $link "tuple-declarations" } ")." } ; +{ $errors "Throws an error if the slot values do not match class declarations on slots (see " { $link "tuple-declarations" } ")." } ; diff --git a/extra/chipmunk/summary.txt b/extra/chipmunk/summary.txt index ebc56a79ed..2859b353f2 100644 --- a/extra/chipmunk/summary.txt +++ b/extra/chipmunk/summary.txt @@ -1 +1 @@ -FFI bindings to the Chipmunk 2D physics library. +Chipmunk 2D physics library binding diff --git a/extra/chipmunk/tags.txt b/extra/chipmunk/tags.txt new file mode 100644 index 0000000000..bb863cf9a0 --- /dev/null +++ b/extra/chipmunk/tags.txt @@ -0,0 +1 @@ +bindings From 941c09d73a1f5d571a6a39255e03e0b896302c83 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Tue, 16 Feb 2010 03:26:36 -0800 Subject: [PATCH 036/713] Splines: catmull-rom, bezier curve, cubic hermite, kochanek-bartels --- extra/math/splines/authors.txt | 1 + extra/math/splines/splines-docs.factor | 44 ++++++++++++ extra/math/splines/splines.factor | 84 +++++++++++++++++++++++ extra/math/splines/summary.txt | 1 + extra/math/splines/testing/authors.txt | 1 + extra/math/splines/testing/testing.factor | 49 +++++++++++++ extra/math/splines/viewer/authors.txt | 1 + extra/math/splines/viewer/viewer.factor | 49 +++++++++++++ 8 files changed, 230 insertions(+) create mode 100644 extra/math/splines/authors.txt create mode 100644 extra/math/splines/splines-docs.factor create mode 100644 extra/math/splines/splines.factor create mode 100644 extra/math/splines/summary.txt create mode 100644 extra/math/splines/testing/authors.txt create mode 100644 extra/math/splines/testing/testing.factor create mode 100644 extra/math/splines/viewer/authors.txt create mode 100644 extra/math/splines/viewer/viewer.factor diff --git a/extra/math/splines/authors.txt b/extra/math/splines/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/extra/math/splines/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/extra/math/splines/splines-docs.factor b/extra/math/splines/splines-docs.factor new file mode 100644 index 0000000000..62ff1418cd --- /dev/null +++ b/extra/math/splines/splines-docs.factor @@ -0,0 +1,44 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: help.markup help.syntax math ; +IN: math.splines + +HELP: +{ $values + { "control-points" "sequence of control points same dimension" } + { "polynomials" "sequence of polynomials for each dimension" } +} +{ $description "Creates bezier curve polynomials for the given control points." } ; + +HELP: +{ $values + { "points" "points on the spline" } { "m0" "initial tangent vector" } { "mn" "final tangent vector" } + { "polynomials-sequence" "sequence of sequences of polynomials" } +} +{ $description "Creates a sequence of cubic hermite curves (each a sequence of polynomials) passing through the given points and generating tangents for C1 continuity." } ; + +HELP: +{ $values + { "p0" "start point" } { "m0" "start tangent" } { "p1" "end point" } { "m1" "end tangent" } + { "polynomials" "sequence of polynomials" } +} +{ $description "Creates a sequence of polynomials (one per dimension) for the curve passing through " { $emphasis "p0" } " and " { $emphasis "p1" } "." } ; + +HELP: +{ $values + { "point-tangent-pairs" "sequence of point and tangent pairs" } + { "polynomials-sequence" "sequence of sequences of polynomials" } +} +{ $description "Creates a sequence of cubic hermite curves (each a sequence of polynomials) passing through the given points with the given tangents." } ; + +HELP: +{ $values + { "points" "points on the spline" } { "m0" "start tangent" } { "mn" "end tangent" } { "tension" number } { "bias" number } { "continuity" number } + { "polynomials-sequence" "sequence of sequence of polynomials" } +} +{ $description "Creates a sequence of cubic hermite curves (each a sequence of polynomials) passing through the given points, generating tangents with the given tuning parameters." } ; + +ARTICLE: "math.splines" "Common parametric curves." +"The curve creating functions create sequences of polynomials, one for each degree of the input points. The spline creating functions create sequences of these curve polynomial sequences. The " { $vocab-link "math.splines.viewer" } " vocabulary provides a gadget to evaluate the generated polynomials and view the results."; + +ABOUT: "math.splines" diff --git a/extra/math/splines/splines.factor b/extra/math/splines/splines.factor new file mode 100644 index 0000000000..dc22224416 --- /dev/null +++ b/extra/math/splines/splines.factor @@ -0,0 +1,84 @@ +! Copyright (C) 2010 Erik Charlebois +! See http://factorcode.org/license.txt for BSD license. +USING: accessors combinators kernel locals math math.combinatorics +math.polynomials opengl.gl sequences ui.gadgets ui.gadgets.panes +ui.render arrays grouping math.vectors assocs +ui.gestures ; +IN: math.splines + + ( pi-1 pi pi+1 ) + pi pi-1 v- c1 v*n + pi+1 pi v- c2 v*n v+ + ] map + m0 prefix + mn suffix ; +PRIVATE> + +:: ( control-points -- polynomials ) + control-points + [ length 1 - ] + [ first length [ { 0 } ] replicate ] + bi :> ( n acc ) + + control-points [| pt i | + n i bernstein-polynomial-ith :> poly + pt [| v j | + j acc [ v poly n*p p+ ] change-nth + ] each-index + ] each-index + acc ; + +:: ( p0 m0 p1 m1 -- polynomials ) + p0 length iota [ + { + [ p0 nth ] [ m0 nth ] + [ p1 nth ] [ m1 nth ] + } cleave + hermite-polynomial + ] map ; + + + ] map ; +PRIVATE> + +: ( point-tangent-pairs -- polynomials-sequence ) + 2 clump [ first2 [ first2 ] bi@ ] map ; + +:: ( points m0 mn tension bias continuity -- polynomials-sequence ) + tension bias continuity kochanek-bartels-coefficients :> ( s1 d1 s2 d2 ) + points m0 mn + [ s1 s2 kochanek-bartels-tangents ] + [ d1 d2 kochanek-bartels-tangents ] 3bi :> ( in out ) + points in out [ 3array ] 3map (cubic-hermite-spline) ; + +: ( points m0 mn -- polynomials-sequence ) + 0 0 0 ; diff --git a/extra/math/splines/summary.txt b/extra/math/splines/summary.txt new file mode 100644 index 0000000000..229b05edc9 --- /dev/null +++ b/extra/math/splines/summary.txt @@ -0,0 +1 @@ +Common parametric curves diff --git a/extra/math/splines/testing/authors.txt b/extra/math/splines/testing/authors.txt new file mode 100644 index 0000000000..67cf648cf5 --- /dev/null +++ b/extra/math/splines/testing/authors.txt @@ -0,0 +1 @@ +Erik Charlebois \ No newline at end of file diff --git a/extra/math/splines/testing/testing.factor b/extra/math/splines/testing/testing.factor new file mode 100644 index 0000000000..bbb5cd6a6a --- /dev/null +++ b/extra/math/splines/testing/testing.factor @@ -0,0 +1,49 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: locals math.splines math.splines.viewer arrays ; +IN: math.splines.testing + +: test1 ( -- ) + { + { { 0 0 } { 0 200 } } + { { 100 50 } { 0 -200 } } + { { 300 300 } { 500 200 } } + { { 400 400 } { 300 0 } } + } { 50 100 } 4 spline. ; + +: test2 ( -- ) + { + { 50 50 } + { 100 100 } + { 300 200 } + { 350 0 } + { 400 400 } + } { 0 100 } { 100 0 } { 100 50 } 50 spline. ; + +:: test3 ( x y z -- ) + { + { 100 50 } + { 200 350 } + { 300 50 } + } { 0 100 } { 0 -100 } x y z { 50 50 } 1000 spline. ; + +: test4 ( -- ) + { + { 0 5 } + { 0.5 3 } + { 10 10 } + { 12 4 } + { 15 5 } + } 1array { 100 100 } 100 spline. ; + +: test-splines ( -- ) + test1 test2 + 1 0 0 test3 + -1 0 0 test3 + 0 1 0 test3 + 0 -1 0 test3 + 0 0 1 test3 + 0 0 -1 test3 + test4 ; + + diff --git a/extra/math/splines/viewer/authors.txt b/extra/math/splines/viewer/authors.txt new file mode 100644 index 0000000000..67cf648cf5 --- /dev/null +++ b/extra/math/splines/viewer/authors.txt @@ -0,0 +1 @@ +Erik Charlebois \ No newline at end of file diff --git a/extra/math/splines/viewer/viewer.factor b/extra/math/splines/viewer/viewer.factor new file mode 100644 index 0000000000..f1ec1a2445 --- /dev/null +++ b/extra/math/splines/viewer/viewer.factor @@ -0,0 +1,49 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors kernel locals math math.order math.polynomials +math.splines opengl.gl sequences ui.gadgets ui.gadgets.panes ui.render +arrays ; +IN: math.splines.viewer + + + +TUPLE: spline-gadget < gadget polynomials steps spline-dim ; + +M: spline-gadget pref-dim* spline-dim>> ; + +M:: spline-gadget draw-gadget* ( gadget -- ) + 0 0 0 glColor3f + + gadget [ polynomials>> ] [ steps>> ] bi eval-polynomials :> pts + + pts [ first ] [ max ] map-reduce :> x-max + pts [ first ] [ min ] map-reduce :> x-min + pts [ second ] [ max ] map-reduce :> y-max + pts [ second ] [ min ] map-reduce :> y-min + + pts [ + [ first x-min - x-max x-min - / gadget spline-dim>> first * ] + [ second y-min - y-max y-min - / gadget spline-dim>> second * ] bi 2array + ] map :> pts + + GL_LINE_STRIP glBegin + pts [ + first2 neg gadget spline-dim>> second + glVertex2f + ] each + glEnd ; + +:: ( polynomials dim steps -- gadget ) + spline-gadget new + dim >>spline-dim + polynomials >>polynomials + steps >>steps ; + +: spline. ( curve dim steps -- ) + gadget. ; From 55cf38163f1b9cc3ce5368b90f96a9041240398a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 17 Feb 2010 00:32:53 +1300 Subject: [PATCH 037/713] inverse: remove unnecessary dependency on debugger --- basis/inverse/inverse.factor | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/basis/inverse/inverse.factor b/basis/inverse/inverse.factor index d112e4e6eb..3485b3efa7 100644 --- a/basis/inverse/inverse.factor +++ b/basis/inverse/inverse.factor @@ -1,10 +1,10 @@ ! Copyright (C) 2007, 2009 Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel locals words summary slots quotations -sequences assocs math arrays stack-checker effects -continuations debugger classes.tuple namespaces make vectors -bit-arrays byte-arrays strings sbufs math.functions macros -sequences.private combinators mirrors splitting combinators.smart +sequences assocs math arrays stack-checker effects continuations +classes.tuple namespaces make vectors bit-arrays byte-arrays +strings sbufs math.functions macros sequences.private +combinators mirrors splitting combinators.smart combinators.short-circuit fry words.symbol generalizations classes ; IN: inverse From 177e741ea073b0c4982f5317224284ba7394f94d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 17 Feb 2010 00:33:08 +1300 Subject: [PATCH 038/713] tools.deploy: add deploy tests for gpu.demos.raytrace and gpu.demos.bunny --- basis/tools/deploy/deploy-tests.factor | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/basis/tools/deploy/deploy-tests.factor b/basis/tools/deploy/deploy-tests.factor index 987b4aa8a1..8e25afdcfe 100644 --- a/basis/tools/deploy/deploy-tests.factor +++ b/basis/tools/deploy/deploy-tests.factor @@ -24,8 +24,12 @@ IN: tools.deploy.tests [ ] [ "terrain" shake-and-bake 1700000 small-enough? ] unit-test +[ ] [ "gpu.demos.raytrace" shake-and-bake 2500000 small-enough? ] unit-test + [ ] [ "bunny" shake-and-bake 2500000 small-enough? ] unit-test +[ ] [ "gpu.demos.bunny" shake-and-bake 3500000 small-enough? ] unit-test + os macosx? [ [ ] [ "webkit-demo" shake-and-bake 500000 small-enough? ] unit-test ] when From 5557353f97a67b5791d149f0b20d7584e0023857 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 17 Feb 2010 01:52:09 +1300 Subject: [PATCH 039/713] tools.deploy.windows.ico: add unportable tag so that load-all doesn't load Win32 bindings on non-Windows platforms --- basis/tools/deploy/windows/ico/tags.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 basis/tools/deploy/windows/ico/tags.txt diff --git a/basis/tools/deploy/windows/ico/tags.txt b/basis/tools/deploy/windows/ico/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/tools/deploy/windows/ico/tags.txt @@ -0,0 +1 @@ +unportable From 4b41d8e83e93807439749ae9c8d6c42755cd2217 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 17 Feb 2010 01:52:16 +1300 Subject: [PATCH 040/713] vocabs.metadata.resources: fix help lint --- basis/vocabs/metadata/resources/resources-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/vocabs/metadata/resources/resources-docs.factor b/basis/vocabs/metadata/resources/resources-docs.factor index b4289ff388..a20775e937 100644 --- a/basis/vocabs/metadata/resources/resources-docs.factor +++ b/basis/vocabs/metadata/resources/resources-docs.factor @@ -16,7 +16,7 @@ HELP: vocab-resource-files } { $description "Outputs a sequence containing the individual resource files and directories that match the patterns specified in " { $snippet "vocab" } "'s " { $snippet "resources.txt" } " file. Any matching directories will also have their contents recursively included in the output. The paths in the output will be relative to " { $snippet "vocab" } "'s directory." } ; -ARTICLE: "vocabs.metadata.resources" "vocabs.metadata.resources" +ARTICLE: "vocabs.metadata.resources" "Vocabulary resource metadata" "The " { $vocab-link "vocabs.metadata.resources" } " vocabulary contains words to retrieve the full list of files that match the patterns specified in a vocabulary's " { $snippet "resources.txt" } " file." { $subsections vocab-resource-files From 25b93af7df84bf81dfc851d690a95247759cb85a Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 10:29:18 -0800 Subject: [PATCH 041/713] git doesn't track empty directories. remove that from the vocab.metadata.resources tests --- basis/vocabs/metadata/resources/resources-tests.factor | 1 - 1 file changed, 1 deletion(-) diff --git a/basis/vocabs/metadata/resources/resources-tests.factor b/basis/vocabs/metadata/resources/resources-tests.factor index 36fd13125e..5c50406a26 100644 --- a/basis/vocabs/metadata/resources/resources-tests.factor +++ b/basis/vocabs/metadata/resources/resources-tests.factor @@ -14,6 +14,5 @@ IN: vocabs.metadata.resources.tests "resource-dir/bas" "resource-dir/bas/zang" "resource-dir/bas/zim" - "resource-dir/buh" "resource-dir/foo" } ] [ "vocabs.metadata.resources.test.3" vocab-resource-files natural-sort ] unit-test From bf7371c32ecdf18bfc75f84e7ff39cd698ce7fad Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 10:30:20 -0800 Subject: [PATCH 042/713] reduce reflection level on gpu.demos.bunny deployment to hopefully get it back below the tools.deploy test limit size --- extra/gpu/demos/bunny/deploy.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/gpu/demos/bunny/deploy.factor b/extra/gpu/demos/bunny/deploy.factor index 1289caadb6..048d710a41 100644 --- a/extra/gpu/demos/bunny/deploy.factor +++ b/extra/gpu/demos/bunny/deploy.factor @@ -6,7 +6,7 @@ H{ { deploy-unicode? f } { "stop-after-last-window?" t } { deploy-io 3 } - { deploy-reflection 2 } + { deploy-reflection 1 } { deploy-word-props? f } { deploy-math? t } { deploy-threads? t } From fcbeb3467d39f0bedf022046121a95141ae9ff92 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Tue, 16 Feb 2010 10:33:19 -0800 Subject: [PATCH 043/713] Line endings --- basis/tools/deploy/deploy-tests.factor | 250 ++++++++++++------------- 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/basis/tools/deploy/deploy-tests.factor b/basis/tools/deploy/deploy-tests.factor index 987b4aa8a1..f76ad7a557 100644 --- a/basis/tools/deploy/deploy-tests.factor +++ b/basis/tools/deploy/deploy-tests.factor @@ -1,125 +1,125 @@ -USING: tools.test system io io.encodings.ascii io.pathnames -io.files io.files.info io.files.temp kernel tools.deploy.config -tools.deploy.config.editor tools.deploy.backend math sequences -io.launcher arrays namespaces continuations layouts accessors -urls math.parser io.directories tools.deploy.test ; -IN: tools.deploy.tests - -[ ] [ "hello-world" shake-and-bake 500000 small-enough? ] unit-test - -[ ] [ "sudoku" shake-and-bake 800000 small-enough? ] unit-test - -[ ] [ "hello-ui" shake-and-bake 1300000 small-enough? ] unit-test - -[ "staging.math-threads-compiler-ui.image" ] [ - "hello-ui" deploy-config - [ bootstrap-profile staging-image-name file-name ] bind -] unit-test - -[ ] [ "maze" shake-and-bake 1200000 small-enough? ] unit-test - -[ ] [ "tetris" shake-and-bake 1500000 small-enough? ] unit-test - -[ ] [ "spheres" shake-and-bake 1500000 small-enough? ] unit-test - -[ ] [ "terrain" shake-and-bake 1700000 small-enough? ] unit-test - -[ ] [ "bunny" shake-and-bake 2500000 small-enough? ] unit-test - -os macosx? [ - [ ] [ "webkit-demo" shake-and-bake 500000 small-enough? ] unit-test -] when - -[ ] [ "benchmark.regex-dna" shake-and-bake 900000 small-enough? ] unit-test - -{ - "tools.deploy.test.1" - "tools.deploy.test.2" - "tools.deploy.test.3" - "tools.deploy.test.4" -} [ - [ ] swap [ - shake-and-bake - run-temp-image - ] curry unit-test -] each - -USING: http.client http.server http.server.dispatchers -http.server.responses http.server.static io.servers.connection ; - -SINGLETON: quit-responder - -M: quit-responder call-responder* - 2drop stop-this-server "Goodbye" "text/html" ; - -: add-quot-responder ( responder -- responder ) - quit-responder "quit" add-responder ; - -: test-httpd ( responder -- ) - [ - main-responder set - - 0 >>insecure - f >>secure - dup start-server* - sockets>> first addr>> port>> - dup number>string "resource:temp/port-number" ascii set-file-contents - ] with-scope - "port" set ; - -[ ] [ - - add-quot-responder - "vocab:http/test" >>default - - test-httpd -] unit-test - -[ ] [ - "tools.deploy.test.5" shake-and-bake - run-temp-image -] unit-test - -: add-port ( url -- url' ) - >url clone "port" get >>port ; - -[ ] [ "http://localhost/quit" add-port http-get 2drop ] unit-test - -{ - "tools.deploy.test.6" - "tools.deploy.test.7" - "tools.deploy.test.9" - "tools.deploy.test.10" - "tools.deploy.test.11" - "tools.deploy.test.12" -} [ - [ ] swap [ - shake-and-bake - run-temp-image - ] curry unit-test -] each - -os windows? os macosx? or [ - [ ] [ "tools.deploy.test.8" shake-and-bake run-temp-image ] unit-test -] when - -os macosx? [ - [ ] [ "tools.deploy.test.14" shake-and-bake run-temp-image ] unit-test -] when - -[ { "a" "b" "c" } ] [ - "tools.deploy.test.15" shake-and-bake deploy-test-command - { "a" "b" "c" } append - ascii [ lines ] with-process-reader - rest -] unit-test - -[ ] [ "tools.deploy.test.16" shake-and-bake run-temp-image ] unit-test - -[ ] [ "tools.deploy.test.17" shake-and-bake run-temp-image ] unit-test - -[ t ] [ - "tools.deploy.test.18" shake-and-bake - deploy-test-command ascii [ readln ] with-process-reader - "test.image" temp-file = -] unit-test +USING: tools.test system io io.encodings.ascii io.pathnames +io.files io.files.info io.files.temp kernel tools.deploy.config +tools.deploy.config.editor tools.deploy.backend math sequences +io.launcher arrays namespaces continuations layouts accessors +urls math.parser io.directories tools.deploy.test ; +IN: tools.deploy.tests + +[ ] [ "hello-world" shake-and-bake 500000 small-enough? ] unit-test + +[ ] [ "sudoku" shake-and-bake 800000 small-enough? ] unit-test + +[ ] [ "hello-ui" shake-and-bake 1300000 small-enough? ] unit-test + +[ "staging.math-threads-compiler-ui.image" ] [ + "hello-ui" deploy-config + [ bootstrap-profile staging-image-name file-name ] bind +] unit-test + +[ ] [ "maze" shake-and-bake 1200000 small-enough? ] unit-test + +[ ] [ "tetris" shake-and-bake 1500000 small-enough? ] unit-test + +[ ] [ "spheres" shake-and-bake 1500000 small-enough? ] unit-test + +[ ] [ "terrain" shake-and-bake 1700000 small-enough? ] unit-test + +[ ] [ "bunny" shake-and-bake 2500000 small-enough? ] unit-test + +os macosx? [ + [ ] [ "webkit-demo" shake-and-bake 500000 small-enough? ] unit-test +] when + +[ ] [ "benchmark.regex-dna" shake-and-bake 900000 small-enough? ] unit-test + +{ + "tools.deploy.test.1" + "tools.deploy.test.2" + "tools.deploy.test.3" + "tools.deploy.test.4" +} [ + [ ] swap [ + shake-and-bake + run-temp-image + ] curry unit-test +] each + +USING: http.client http.server http.server.dispatchers +http.server.responses http.server.static io.servers.connection ; + +SINGLETON: quit-responder + +M: quit-responder call-responder* + 2drop stop-this-server "Goodbye" "text/html" ; + +: add-quot-responder ( responder -- responder ) + quit-responder "quit" add-responder ; + +: test-httpd ( responder -- ) + [ + main-responder set + + 0 >>insecure + f >>secure + dup start-server* + sockets>> first addr>> port>> + dup number>string "resource:temp/port-number" ascii set-file-contents + ] with-scope + "port" set ; + +[ ] [ + + add-quot-responder + "vocab:http/test" >>default + + test-httpd +] unit-test + +[ ] [ + "tools.deploy.test.5" shake-and-bake + run-temp-image +] unit-test + +: add-port ( url -- url' ) + >url clone "port" get >>port ; + +[ ] [ "http://localhost/quit" add-port http-get 2drop ] unit-test + +{ + "tools.deploy.test.6" + "tools.deploy.test.7" + "tools.deploy.test.9" + "tools.deploy.test.10" + "tools.deploy.test.11" + "tools.deploy.test.12" +} [ + [ ] swap [ + shake-and-bake + run-temp-image + ] curry unit-test +] each + +os windows? os macosx? or [ + [ ] [ "tools.deploy.test.8" shake-and-bake run-temp-image ] unit-test +] when + +os macosx? [ + [ ] [ "tools.deploy.test.14" shake-and-bake run-temp-image ] unit-test +] when + +[ { "a" "b" "c" } ] [ + "tools.deploy.test.15" shake-and-bake deploy-test-command + { "a" "b" "c" } append + ascii [ lines ] with-process-reader + rest +] unit-test + +[ ] [ "tools.deploy.test.16" shake-and-bake run-temp-image ] unit-test + +[ ] [ "tools.deploy.test.17" shake-and-bake run-temp-image ] unit-test + +[ t ] [ + "tools.deploy.test.18" shake-and-bake + deploy-test-command ascii [ readln ] with-process-reader + "test.image" temp-file = +] unit-test From 9af0f8d426262e6ff9c46d9b770199c031332973 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 10:33:21 -0800 Subject: [PATCH 044/713] fix globs tests --- basis/globs/globs.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/basis/globs/globs.factor b/basis/globs/globs.factor index 72b686c3b1..9cd6a73891 100644 --- a/basis/globs/globs.factor +++ b/basis/globs/globs.factor @@ -1,11 +1,11 @@ ! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. USING: sequences io.pathnames kernel regexp.combinators -strings unicode.case peg.ebnf regexp arrays ; +strings splitting system unicode.case peg.ebnf regexp arrays ; IN: globs : not-path-separator ( -- sep ) - "[^" path-separator "]" 3append ; foldable + os windows? R! [^/\\]! R! [^/]! ? ; foldable EBNF: @@ -48,5 +48,5 @@ Main = Concatenation End [ "\\*?[{" member? ] any? ; : glob-parent-directory ( glob -- parent-directory ) - path-components dup [ glob-pattern? ] find drop head + path-separator split harvest dup [ glob-pattern? ] find drop head path-separator join ; From 30cc248bb39eb1221f6f3d2a1fe032091f323b62 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Tue, 16 Feb 2010 15:14:32 -0600 Subject: [PATCH 045/713] Bit sets use new new set protocol, and compiler.cfg.ssa.construction.tdmsc is updated for it --- basis/bit-sets/bit-sets-tests.factor | 63 ++++++++++--- basis/bit-sets/bit-sets.factor | 58 ++++++++++-- .../cfg/ssa/construction/tdmsc/tdmsc.factor | 29 +++--- basis/new-sets/new-sets-tests.factor | 69 +++++++++++++++ basis/new-sets/new-sets.factor | 88 +++++++++++++++++++ 5 files changed, 269 insertions(+), 38 deletions(-) create mode 100644 basis/new-sets/new-sets-tests.factor create mode 100644 basis/new-sets/new-sets.factor diff --git a/basis/bit-sets/bit-sets-tests.factor b/basis/bit-sets/bit-sets-tests.factor index 6a1366a1ea..c4260915ac 100644 --- a/basis/bit-sets/bit-sets-tests.factor +++ b/basis/bit-sets/bit-sets-tests.factor @@ -1,17 +1,60 @@ -USING: bit-sets tools.test bit-arrays ; +USING: bit-sets tools.test new-sets kernel bit-arrays ; IN: bit-sets.tests -[ ?{ t f t f t f } ] [ - ?{ t f f f t f } - ?{ f f t f t f } bit-set-union +[ T{ bit-set f ?{ t f t f t f } } ] [ + T{ bit-set f ?{ t f f f t f } } + T{ bit-set f ?{ f f t f t f } } union ] unit-test -[ ?{ f f f f t f } ] [ - ?{ t f f f t f } - ?{ f f t f t f } bit-set-intersect +[ T{ bit-set f ?{ f f f f t f } } ] [ + T{ bit-set f ?{ t f f f t f } } + T{ bit-set f ?{ f f t f t f } } intersect ] unit-test -[ ?{ t f t f f f } ] [ - ?{ t t t f f f } - ?{ f t f f t t } bit-set-diff +[ T{ bit-set f ?{ t f t f f f } } ] [ + T{ bit-set f ?{ t t t f f f } } + T{ bit-set f ?{ f t f f t t } } diff ] unit-test + +[ f ] [ + T{ bit-set f ?{ t t t f f f } } + T{ bit-set f ?{ f t f f t t } } subset? +] unit-test + +[ t ] [ + T{ bit-set f ?{ t t t f f f } } + T{ bit-set f ?{ f t f f f f } } subset? +] unit-test + +[ t ] [ + { 0 1 2 } + T{ bit-set f ?{ f t f f f f } } subset? +] unit-test + +[ f ] [ + T{ bit-set f ?{ f t f f f f } } + T{ bit-set f ?{ t t t f f f } } subset? +] unit-test + +[ f ] [ + { 1 } + T{ bit-set f ?{ t t t f f f } } subset? +] unit-test + +[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } members ] unit-test + +[ t V{ 1 2 3 } ] [ + { 1 2 } 5 set-like + [ bit-set? ] keep + 3 over adjoin + members +] unit-test + +[ V{ 0 1 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 1 swap adjoin ] keep members ] unit-test +[ T{ bit-set f ?{ t f t f f t } } clone [ 9 swap adjoin ] keep members ] must-fail +[ T{ bit-set f ?{ t f t f f t } } clone [ "foo" swap adjoin ] keep members ] must-fail + +[ V{ 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 0 swap delete ] keep members ] unit-test +[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 1 swap delete ] keep members ] unit-test +[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 9 swap delete ] keep members ] unit-test +[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ "foo" swap delete ] keep members ] unit-test diff --git a/basis/bit-sets/bit-sets.factor b/basis/bit-sets/bit-sets.factor index 34b7f13dc2..d6c9a48bed 100644 --- a/basis/bit-sets/bit-sets.factor +++ b/basis/bit-sets/bit-sets.factor @@ -1,8 +1,33 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel accessors sequences byte-arrays bit-arrays math hints ; +USING: kernel accessors sequences byte-arrays bit-arrays math hints new-sets ; IN: bit-sets +TUPLE: bit-set { table bit-array read-only } ; + +: ( capacity -- bit-set ) + bit-set boa ; + +INSTANCE: bit-set set + +M: bit-set in? + over integer? [ table>> ?nth ] [ 2drop f ] if ; inline + +M: bit-set adjoin + ! This is allowed to crash when the elt couldn't go in the set + [ t ] 2dip table>> set-nth ; + +M: bit-set delete + ! This isn't allowed to crash if the elt wasn't in the set + over integer? [ + table>> 2dup bounds-check? [ + [ f ] 2dip set-nth + ] [ 2drop ] if + ] [ 2drop ] if ; + +! If you do binary set operations with a bitset, it's expected +! that the other thing can also be represented as a bitset +! of the same length. > ] bi@ ; inline + +: bit-set-op ( set1 set2 quot: ( a b -- c ) -- bit-set ) + [ (bit-set-op) ] dip bit-set-map bit-set boa ; inline + PRIVATE> -: bit-set-union ( seq1 seq2 -- seq ) [ bitor ] bit-set-map ; +M: bit-set union + [ bitor ] bit-set-op ; -HINTS: bit-set-union bit-array bit-array ; +M: bit-set intersect + [ bitand ] bit-set-op ; -: bit-set-intersect ( seq1 seq2 -- seq ) [ bitand ] bit-set-map ; +M: bit-set diff + [ bitnot bitand ] bit-set-op ; -HINTS: bit-set-intersect bit-array bit-array ; +M: bit-set subset? + [ intersect ] keep = ; -: bit-set-diff ( seq1 seq2 -- seq ) [ bitnot bitand ] bit-set-map ; +M: bit-set members + [ table>> length iota ] keep [ in? ] curry filter ; -HINTS: bit-set-diff bit-array bit-array ; - -: bit-set-subset? ( seq1 seq2 -- ? ) dupd bit-set-intersect = ; \ No newline at end of file +M: bit-set set-like + ! This crashes if there are keys that can't be put in the bit set + over bit-set? [ 2dup [ table>> ] bi@ length = ] [ f ] if + [ drop ] [ + [ members ] dip table>> length + [ [ adjoin ] curry each ] keep + ] if ; diff --git a/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor b/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor index 4b459e90fb..ae3a20e800 100644 --- a/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor +++ b/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor @@ -3,6 +3,7 @@ USING: accessors arrays assocs bit-arrays bit-sets fry hashtables hints kernel locals math namespaces sequences sets compiler.cfg compiler.cfg.dominance compiler.cfg.rpo ; +QUALIFIED: new-sets IN: compiler.cfg.ssa.construction.tdmsc ! TDMSC-I algorithm from "A Practical and Fast Iterative Algorithm for @@ -15,7 +16,7 @@ IN: compiler.cfg.ssa.construction.tdmsc SYMBOLS: visited merge-sets levels again? ; : init-merge-sets ( cfg -- ) - post-order dup length '[ _ ] H{ } map>assoc merge-sets set ; + post-order dup length '[ _ ] H{ } map>assoc merge-sets set ; : compute-levels ( cfg -- ) 0 over entry>> associate [ @@ -29,15 +30,12 @@ SYMBOLS: visited merge-sets levels again? ; : level ( bb -- n ) levels get at ; inline -: set-bit ( bit-array n -- ) - [ t ] 2dip swap set-nth ; - : update-merge-set ( tmp to -- ) [ merge-sets get ] dip '[ _ - [ merge-sets get at bit-set-union ] - [ dupd number>> set-bit ] + [ merge-sets get at new-sets:union ] + [ number>> over new-sets:adjoin ] bi ] change-at ; @@ -54,7 +52,7 @@ SYMBOLS: visited merge-sets levels again? ; : visited? ( pair -- ? ) visited get key? ; : consistent? ( snode lnode -- ? ) - [ merge-sets get at ] bi@ swap bit-set-subset? ; + [ merge-sets get at ] bi@ new-sets:subset? ; : (process-edge) ( from to -- ) f walk [ @@ -82,14 +80,9 @@ SYMBOLS: visited merge-sets levels again? ; loop ; : (merge-set) ( bbs -- flags rpo ) - merge-sets get '[ _ at ] [ bit-set-union ] map-reduce + merge-sets get '[ _ at ] [ new-sets:union ] map-reduce cfg get reverse-post-order ; inline -: filter-by ( flags seq -- seq' ) - [ drop ] selector [ 2each ] dip ; - -HINTS: filter-by { bit-array object } ; - PRIVATE> : compute-merge-sets ( cfg -- ) @@ -101,10 +94,8 @@ PRIVATE> [ compute-merge-set-loop ] tri ; -: merge-set-each ( bbs quot: ( bb -- ) -- ) - [ (merge-set) ] dip '[ - swap _ [ drop ] if - ] 2each ; inline - : merge-set ( bbs -- bbs' ) - (merge-set) filter-by ; + (merge-set) [ new-sets:members ] dip nths ; + +: merge-set-each ( bbs quot: ( bb -- ) -- ) + [ merge-set ] dip each ; inline diff --git a/basis/new-sets/new-sets-tests.factor b/basis/new-sets/new-sets-tests.factor new file mode 100644 index 0000000000..a03ab9f18e --- /dev/null +++ b/basis/new-sets/new-sets-tests.factor @@ -0,0 +1,69 @@ +! Copyright (C) 2010 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: new-sets tools.test kernel sorting prettyprint bit-arrays arrays ; +IN: new-sets.tests + +[ { } ] [ { } { } intersect ] unit-test +[ { 2 3 } ] [ { 1 2 3 } { 2 3 4 } intersect ] unit-test + +[ { } ] [ { } { } diff ] unit-test +[ { 1 } ] [ { 1 2 3 } { 2 3 4 } diff ] unit-test + +[ { } ] [ { } { } union ] unit-test +[ { 1 2 3 4 } ] [ { 1 2 3 } { 2 3 4 } union ] unit-test + +[ t ] [ { 1 2 } { 1 3 } intersects? ] unit-test + +[ f ] [ { 4 2 } { 1 3 } intersects? ] unit-test + +[ f ] [ { } { 1 } intersects? ] unit-test + +[ f ] [ { 1 } { } intersects? ] unit-test + +[ t ] [ 4 { 2 4 5 } in? ] unit-test +[ f ] [ 1 { 2 4 5 } in? ] unit-test + +[ V{ 1 2 3 } ] [ 3 V{ 1 2 } clone [ adjoin ] keep ] unit-test +[ V{ 1 2 } ] [ 2 V{ 1 2 } clone [ adjoin ] keep ] unit-test +[ V{ 1 2 } ] [ 3 V{ 1 2 } clone [ delete ] keep ] unit-test +[ V{ 2 } ] [ 1 V{ 1 2 } clone [ delete ] keep ] unit-test + +[ t ] [ { 1 2 3 } { 2 1 3 } set= ] unit-test +[ f ] [ { 2 3 } { 1 2 3 } set= ] unit-test +[ f ] [ { 1 2 3 } { 2 3 } set= ] unit-test + +[ { 1 } ] [ { 1 } members ] unit-test + +[ { 1 2 3 } ] [ { 1 1 1 2 2 3 3 3 3 3 } dup set-like natural-sort ] unit-test +[ { 1 2 3 } ] [ HS{ 1 2 3 } { } set-like natural-sort ] unit-test + +[ HS{ 1 2 3 } ] [ { 1 2 3 } fast-set ] unit-test + +[ { 1 2 3 } ] [ HS{ 1 2 3 } members natural-sort ] unit-test + +[ "HS{ 1 2 3 4 }" ] [ HS{ 1 2 3 4 } unparse ] unit-test + +[ t ] [ 1 HS{ 0 1 2 } in? ] unit-test +[ f ] [ 3 HS{ 0 1 2 } in? ] unit-test +[ HS{ 1 2 3 } ] [ 3 HS{ 1 2 } clone [ adjoin ] keep ] unit-test +[ HS{ 1 2 } ] [ 2 HS{ 1 2 } clone [ adjoin ] keep ] unit-test +[ HS{ 1 2 3 } ] [ 4 HS{ 1 2 3 } clone [ delete ] keep ] unit-test +[ HS{ 1 2 } ] [ 3 HS{ 1 2 3 } clone [ delete ] keep ] unit-test +[ HS{ 1 2 } ] [ HS{ 1 2 } fast-set ] unit-test +[ { 1 2 } ] [ HS{ 1 2 } members natural-sort ] unit-test + +[ HS{ 1 2 3 4 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } union ] unit-test +[ HS{ 2 3 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } intersect ] unit-test +[ t ] [ HS{ 1 2 3 } HS{ 2 3 4 } intersects? ] unit-test +[ f ] [ HS{ 1 } HS{ 2 3 4 } intersects? ] unit-test +[ f ] [ HS{ 1 } HS{ 2 3 4 } subset? ] unit-test +[ f ] [ HS{ 1 2 3 } HS{ 2 3 4 } subset? ] unit-test +[ t ] [ HS{ 2 3 } HS{ 2 3 4 } subset? ] unit-test +[ t ] [ HS{ } HS{ 2 3 4 } subset? ] unit-test +[ HS{ 1 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } diff ] unit-test +[ t ] [ HS{ 1 2 3 } HS{ 2 1 3 } set= ] unit-test +[ t ] [ HS{ 1 2 3 } HS{ 2 1 3 } = ] unit-test +[ f ] [ HS{ 2 3 } HS{ 2 1 3 } set= ] unit-test +[ f ] [ HS{ 1 2 3 } HS{ 2 3 } set= ] unit-test + +[ HS{ 1 2 } HS{ 1 2 3 } ] [ HS{ 1 2 } clone dup clone [ 3 swap adjoin ] keep ] unit-test diff --git a/basis/new-sets/new-sets.factor b/basis/new-sets/new-sets.factor new file mode 100644 index 0000000000..770368ae3b --- /dev/null +++ b/basis/new-sets/new-sets.factor @@ -0,0 +1,88 @@ +! Copyright (C) 2010 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: accessors assocs hashtables kernel +math sequences parser prettyprint.custom ; +QUALIFIED: sets +IN: new-sets +! The vocab is called new-sets for now, but only until it gets into core +! All the code here is in the style that could be put in core + +! Set protocol +MIXIN: set +GENERIC: adjoin ( elt set -- ) +GENERIC: in? ( elt set -- ? ) +GENERIC: delete ( elt set -- ) +GENERIC: set-like ( set exemplar -- set' ) +GENERIC: fast-set ( set -- set' ) +GENERIC: members ( set -- sequence ) +GENERIC: union ( set1 set2 -- set ) +GENERIC: intersect ( set1 set2 -- set ) +GENERIC: intersects? ( set1 set2 -- ? ) +GENERIC: diff ( set1 set2 -- set ) +GENERIC: subset? ( set1 set2 -- ? ) +GENERIC: set= ( set1 set2 -- ? ) + +! Defaults for some methods. +! Override them for efficiency + +M: set union + [ [ members ] bi@ append ] keep set-like ; + + + +M: set intersect + [ sequence/tester filter ] keep set-like ; + +M: set diff + [ sequence/tester [ not ] compose filter ] keep set-like ; + +M: set intersects? + sequence/tester any? ; + +M: set subset? + sequence/tester all? ; + +M: set set= + 2dup subset? [ swap subset? ] [ 2drop f ] if ; + +M: set fast-set ; + +! Hash sets +! In a better implementation, less memory would be used +TUPLE: hash-set { table hashtable read-only } ; + +: ( members -- hash-set ) + sets:unique hash-set boa ; + +INSTANCE: hash-set set +M: hash-set in? table>> key? ; inline +M: hash-set adjoin table>> dupd set-at ; inline +M: hash-set delete table>> delete-at ; inline +M: hash-set members table>> keys ; inline +M: hash-set set-like + drop dup hash-set? [ members ] unless ; +M: hash-set clone + table>> clone hash-set boa ; + +SYNTAX: HS{ + \ } [ ] parse-literal ; + +M: hash-set pprint* pprint-object ; +M: hash-set pprint-delims drop \ HS{ \ } ; +M: hash-set >pprint-sequence members ; + +! Sequences are sets +INSTANCE: sequence set +M: sequence in? member? ; inline +M: sequence adjoin sets:adjoin ; inline +M: sequence delete remove! drop ; inline +M: sequence set-like + [ dup sequence? [ sets:prune ] [ members ] if ] dip + like ; +M: sequence members ; +M: sequence fast-set ; From 05df3b3fd0a9344168d3cd95d44983af8c35cf24 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Tue, 16 Feb 2010 15:15:12 -0600 Subject: [PATCH 046/713] Finishing moving new-sets to basis --- extra/bags/bags-tests.factor | 127 ------------------------------- extra/bags/bags.factor | 143 ----------------------------------- 2 files changed, 270 deletions(-) delete mode 100644 extra/bags/bags-tests.factor delete mode 100644 extra/bags/bags.factor diff --git a/extra/bags/bags-tests.factor b/extra/bags/bags-tests.factor deleted file mode 100644 index 13b5894ce1..0000000000 --- a/extra/bags/bags-tests.factor +++ /dev/null @@ -1,127 +0,0 @@ -! Copyright (C) 2010 Daniel Ehrenberg -! See http://factorcode.org/license.txt for BSD license. -USING: bags tools.test kernel sorting prettyprint bit-arrays arrays ; -IN: bags.tests - -[ { } ] [ { } { } intersect ] unit-test -[ { 2 3 } ] [ { 1 2 3 } { 2 3 4 } intersect ] unit-test - -[ { } ] [ { } { } diff ] unit-test -[ { 1 } ] [ { 1 2 3 } { 2 3 4 } diff ] unit-test - -[ { } ] [ { } { } union ] unit-test -[ { 1 2 3 4 } ] [ { 1 2 3 } { 2 3 4 } union ] unit-test - -[ t ] [ { 1 2 } { 1 3 } intersects? ] unit-test - -[ f ] [ { 4 2 } { 1 3 } intersects? ] unit-test - -[ f ] [ { } { 1 } intersects? ] unit-test - -[ f ] [ { 1 } { } intersects? ] unit-test - -[ t ] [ 4 { 2 4 5 } in? ] unit-test -[ f ] [ 1 { 2 4 5 } in? ] unit-test - -[ V{ 1 2 3 } ] [ 3 V{ 1 2 } clone [ adjoin ] keep ] unit-test -[ V{ 1 2 } ] [ 2 V{ 1 2 } clone [ adjoin ] keep ] unit-test -[ V{ 1 2 } ] [ 3 V{ 1 2 } clone [ delete ] keep ] unit-test -[ V{ 2 } ] [ 1 V{ 1 2 } clone [ delete ] keep ] unit-test - -[ t ] [ { 1 2 3 } { 2 1 3 } set= ] unit-test -[ f ] [ { 2 3 } { 1 2 3 } set= ] unit-test -[ f ] [ { 1 2 3 } { 2 3 } set= ] unit-test - -[ { 1 } ] [ { 1 } members ] unit-test - -[ { 1 2 3 } ] [ { 1 1 1 2 2 3 3 3 3 3 } dup set-like natural-sort ] unit-test -[ { 1 2 3 } ] [ HS{ 1 2 3 } { } set-like natural-sort ] unit-test - -[ HS{ 1 2 3 } ] [ { 1 2 3 } fast-set ] unit-test - -[ { 1 2 3 } ] [ HS{ 1 2 3 } members natural-sort ] unit-test - -[ "HS{ 1 2 3 4 }" ] [ HS{ 1 2 3 4 } unparse ] unit-test - -[ t ] [ 1 HS{ 0 1 2 } in? ] unit-test -[ f ] [ 3 HS{ 0 1 2 } in? ] unit-test -[ HS{ 1 2 3 } ] [ 3 HS{ 1 2 } clone [ adjoin ] keep ] unit-test -[ HS{ 1 2 } ] [ 2 HS{ 1 2 } clone [ adjoin ] keep ] unit-test -[ HS{ 1 2 3 } ] [ 4 HS{ 1 2 3 } clone [ delete ] keep ] unit-test -[ HS{ 1 2 } ] [ 3 HS{ 1 2 3 } clone [ delete ] keep ] unit-test -[ HS{ 1 2 } ] [ HS{ 1 2 } fast-set ] unit-test -[ { 1 2 } ] [ HS{ 1 2 } members natural-sort ] unit-test - -[ HS{ 1 2 3 4 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } union ] unit-test -[ HS{ 2 3 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } intersect ] unit-test -[ t ] [ HS{ 1 2 3 } HS{ 2 3 4 } intersects? ] unit-test -[ f ] [ HS{ 1 } HS{ 2 3 4 } intersects? ] unit-test -[ f ] [ HS{ 1 } HS{ 2 3 4 } subset? ] unit-test -[ f ] [ HS{ 1 2 3 } HS{ 2 3 4 } subset? ] unit-test -[ t ] [ HS{ 2 3 } HS{ 2 3 4 } subset? ] unit-test -[ t ] [ HS{ } HS{ 2 3 4 } subset? ] unit-test -[ HS{ 1 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } diff ] unit-test -[ t ] [ HS{ 1 2 3 } HS{ 2 1 3 } set= ] unit-test -[ t ] [ HS{ 1 2 3 } HS{ 2 1 3 } = ] unit-test -[ f ] [ HS{ 2 3 } HS{ 2 1 3 } set= ] unit-test -[ f ] [ HS{ 1 2 3 } HS{ 2 3 } set= ] unit-test - -[ HS{ 1 2 } HS{ 1 2 3 } ] [ HS{ 1 2 } clone dup clone [ 3 swap adjoin ] keep ] unit-test - -[ T{ bit-set f ?{ t f t f t f } } ] [ - T{ bit-set f ?{ t f f f t f } } - T{ bit-set f ?{ f f t f t f } } union -] unit-test - -[ T{ bit-set f ?{ f f f f t f } } ] [ - T{ bit-set f ?{ t f f f t f } } - T{ bit-set f ?{ f f t f t f } } intersect -] unit-test - -[ T{ bit-set f ?{ t f t f f f } } ] [ - T{ bit-set f ?{ t t t f f f } } - T{ bit-set f ?{ f t f f t t } } diff -] unit-test - -[ f ] [ - T{ bit-set f ?{ t t t f f f } } - T{ bit-set f ?{ f t f f t t } } subset? -] unit-test - -[ t ] [ - T{ bit-set f ?{ t t t f f f } } - T{ bit-set f ?{ f t f f f f } } subset? -] unit-test - -[ t ] [ - { 0 1 2 } - T{ bit-set f ?{ f t f f f f } } subset? -] unit-test - -[ f ] [ - T{ bit-set f ?{ f t f f f f } } - T{ bit-set f ?{ t t t f f f } } subset? -] unit-test - -[ f ] [ - { 1 } - T{ bit-set f ?{ t t t f f f } } subset? -] unit-test - -[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } members ] unit-test - -[ t { 1 2 3 } ] [ - { 1 2 } 5 set-like - [ bit-set? ] keep - 3 over adjoin - members >array natural-sort -] unit-test - -[ V{ 0 1 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 1 swap adjoin ] keep members ] unit-test -[ T{ bit-set f ?{ t f t f f t } } clone [ 9 swap adjoin ] keep members ] must-fail -[ T{ bit-set f ?{ t f t f f t } } clone [ "foo" swap adjoin ] keep members ] must-fail - -[ V{ 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 0 swap delete ] keep members ] unit-test -[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 1 swap delete ] keep members ] unit-test -[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 9 swap delete ] keep members ] unit-test -[ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ "foo" swap delete ] keep members ] unit-test diff --git a/extra/bags/bags.factor b/extra/bags/bags.factor deleted file mode 100644 index 78ffd8f781..0000000000 --- a/extra/bags/bags.factor +++ /dev/null @@ -1,143 +0,0 @@ -! Copyright (C) 2010 Daniel Ehrenberg -! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs bit-arrays bit-sets hashtables kernel -math sequences parser prettyprint.custom ; -QUALIFIED: sets -IN: bags -! The vocab is called bags for now, but only until it gets into core -! All the code here is in the style that could be put in core - -! Set protocol -MIXIN: set -GENERIC: adjoin ( elt set -- ) -GENERIC: in? ( elt set -- ? ) -GENERIC: delete ( elt set -- ) -GENERIC: set-like ( set exemplar -- set' ) -GENERIC: fast-set ( set -- set' ) -GENERIC: members ( set -- sequence ) -GENERIC: union ( set1 set2 -- set ) -GENERIC: intersect ( set1 set2 -- set ) -GENERIC: intersects? ( set1 set2 -- ? ) -GENERIC: diff ( set1 set2 -- set ) -GENERIC: subset? ( set1 set2 -- ? ) -GENERIC: set= ( set1 set2 -- ? ) - -! Defaults for some methods. -! Override them for efficiency - -M: set union - [ [ members ] bi@ append ] keep set-like ; - - - -M: set intersect - [ sequence/tester filter ] keep set-like ; - -M: set diff - [ sequence/tester [ not ] compose filter ] keep set-like ; - -M: set intersects? - sequence/tester any? ; - -M: set subset? - sequence/tester all? ; - -M: set set= - 2dup subset? [ swap subset? ] [ 2drop f ] if ; - -M: set fast-set ; - -! Hash sets -! In a better implementation, less memory would be used -TUPLE: hash-set { table hashtable read-only } ; - -: ( members -- hash-set ) - sets:unique hash-set boa ; - -INSTANCE: hash-set set -M: hash-set in? table>> key? ; inline -M: hash-set adjoin table>> dupd set-at ; inline -M: hash-set delete table>> delete-at ; inline -M: hash-set members table>> keys ; inline -M: hash-set set-like - drop dup hash-set? [ members ] unless ; -M: hash-set clone - table>> clone hash-set boa ; - -SYNTAX: HS{ - \ } [ ] parse-literal ; - -M: hash-set pprint* pprint-object ; -M: hash-set pprint-delims drop \ HS{ \ } ; -M: hash-set >pprint-sequence members ; - -! Sequences are sets -INSTANCE: sequence set -M: sequence in? member? ; inline -M: sequence adjoin sets:adjoin ; inline -M: sequence delete remove! drop ; inline -M: sequence set-like - [ dup sequence? [ sets:prune ] [ members ] if ] dip - like ; -M: sequence members ; -M: sequence fast-set ; - -! Bit sets are sets -TUPLE: bit-set { table bit-array read-only } ; - -: ( capacity -- bit-set ) - bit-set boa ; - -INSTANCE: bit-set set - -M: bit-set in? - over integer? [ table>> ?nth ] [ 2drop f ] if ; inline - -M: bit-set adjoin - ! This is allowed to crash when the elt couldn't go in the set - [ t ] 2dip table>> set-nth ; - -M: bit-set delete - ! This isn't allowed to crash if the elt wasn't in the set - over integer? [ - table>> 2dup bounds-check? [ - [ f ] 2dip set-nth - ] [ 2drop ] if - ] [ 2drop ] if ; - -! If you do binary set operations with a bitset, it's expected -! that the other thing can also be represented as a bitset -! of the same length. -: (bit-set-op) ( set1 set2 -- table1 table2 ) - [ set-like ] keep [ table>> ] bi@ ; inline - -: bit-set-op ( set1 set2 quot: ( table1 table2 -- table ) -- bit-set ) - [ (bit-set-op) ] dip call bit-set boa ; inline - -M: bit-set union - [ bit-set-union ] bit-set-op ; - -M: bit-set intersect - [ bit-set-intersect ] bit-set-op ; - -M: bit-set diff - [ bit-set-diff ] bit-set-op ; - -M: bit-set subset? - (bit-set-op) swap bit-set-subset? ; - -M: bit-set members - [ table>> length iota ] keep [ in? ] curry filter ; - -M: bit-set set-like - ! This crashes if there are keys that can't be put in the bit set - over bit-set? [ 2dup [ table>> ] bi@ length = ] [ f ] if - [ drop ] [ - [ members ] dip table>> length - [ [ adjoin ] curry each ] keep - ] if ; From 42089b6586f51485e2f446385c471b00278c245e Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 13:32:14 -0800 Subject: [PATCH 047/713] alien.libraries: add a "deploy-library" word that marks a library to have its dll deployed with applications that use it. add support to tools.deploy to find and copy deployed libraries into target bundle --- basis/alien/libraries/libraries-docs.factor | 11 +++++++- basis/alien/libraries/libraries.factor | 24 ++++++++++++++++-- basis/tools/deploy/backend/backend.factor | 25 ++++++++++++++++--- basis/tools/deploy/libraries/libraries.factor | 11 ++++++++ basis/tools/deploy/libraries/tags.txt | 1 + basis/tools/deploy/libraries/unix/tags.txt | 1 + basis/tools/deploy/libraries/unix/unix.factor | 16 ++++++++++++ .../deploy/libraries/windows/windows.factor | 16 ++++++++++++ basis/tools/deploy/macosx/macosx.factor | 4 ++- basis/tools/deploy/shaker/shaker.factor | 22 ++++++++++++++-- basis/tools/deploy/unix/unix.factor | 2 +- basis/tools/deploy/windows/windows.factor | 2 +- basis/windows/kernel32/kernel32.factor | 7 ++++-- 13 files changed, 129 insertions(+), 13 deletions(-) create mode 100644 basis/tools/deploy/libraries/libraries.factor create mode 100644 basis/tools/deploy/libraries/tags.txt create mode 100644 basis/tools/deploy/libraries/unix/tags.txt create mode 100644 basis/tools/deploy/libraries/unix/unix.factor create mode 100644 basis/tools/deploy/libraries/windows/windows.factor diff --git a/basis/alien/libraries/libraries-docs.factor b/basis/alien/libraries/libraries-docs.factor index 245565d9ed..59142733b9 100644 --- a/basis/alien/libraries/libraries-docs.factor +++ b/basis/alien/libraries/libraries-docs.factor @@ -60,6 +60,10 @@ $nl } "Note the parse time evaluation with " { $link POSTPONE: << } "." } ; +HELP: deploy-library +{ $values { "name" string } } +{ $description "Specifies that the logical library named " { $snippet "name" } " should be included during " { $link "tools.deploy" } ". " { $snippet "name" } " must be the name of a library previously loaded with " { $link add-library } "." } ; + HELP: remove-library { $values { "name" string } } { $description "Unloads a library and removes it from the internal list of libraries. The " { $snippet "name" } " parameter should be a name that was previously passed to " { $link add-library } ". If no library with that name exists, this word does nothing." } ; @@ -72,4 +76,9 @@ ARTICLE: "loading-libs" "Loading native libraries" } "Once a library has been defined, you can try loading it to see if the path name is correct:" { $subsections load-library } -"If the compiler cannot load a library, or cannot resolve a symbol in a library, a linkage error is reported using the compiler error mechanism (see " { $link "compiler-errors" } "). Once you install the right library, reload the source file containing the " { $link add-library } " form to force the compiler to try loading the library again." ; +"If the compiler cannot load a library, or cannot resolve a symbol in a library, a linkage error is reported using the compiler error mechanism (see " { $link "compiler-errors" } "). Once you install the right library, reload the source file containing the " { $link add-library } " form to force the compiler to try loading the library again." +$nl +"Libraries that do not come standard with the operating system need to be included with deployed applications that use them. A word is provided to instruct " { $link "tools.deploy" } " that a library must be so deployed:" +{ $subsections + deploy-library +} ; diff --git a/basis/alien/libraries/libraries.factor b/basis/alien/libraries/libraries.factor index 0d255b8d07..6f80900da0 100644 --- a/basis/alien/libraries/libraries.factor +++ b/basis/alien/libraries/libraries.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien alien.strings assocs io.backend -kernel namespaces destructors ; +kernel namespaces destructors sequences system io.pathnames ; IN: alien.libraries : dlopen ( path -- dll ) native-string>alien (dlopen) ; @@ -9,11 +9,15 @@ IN: alien.libraries : dlsym ( name dll -- alien ) [ string>symbol ] dip (dlsym) ; SYMBOL: libraries +SYMBOL: deploy-libraries libraries [ H{ } clone ] initialize +deploy-libraries [ V{ } clone ] initialize TUPLE: library path abi dll ; +ERROR: no-library name ; + : library ( name -- library ) libraries get at ; : ( path abi -- library ) @@ -31,4 +35,20 @@ M: library dispose dll>> [ dispose ] when* ; : add-library ( name path abi -- ) [ 2drop remove-library ] - [ swap libraries get set-at ] 3bi ; \ No newline at end of file + [ swap libraries get set-at ] 3bi ; + +: deploy-library ( name -- ) + dup libraries get key? + [ deploy-libraries get 2dup member? [ 2drop ] [ push ] if ] + [ no-library ] if ; + +deployed-library-path os ( path -- path' ) + +M: windows >deployed-library-path + file-name ; +M: unix >deployed-library-path + file-name "$ORIGIN" prepend-path ; +M: macosx >deployed-library-path + file-name "@executable_path/../Frameworks" prepend-path ; +PRIVATE> diff --git a/basis/tools/deploy/backend/backend.factor b/basis/tools/deploy/backend/backend.factor index 9d6b8d4c08..4a4037d754 100644 --- a/basis/tools/deploy/backend/backend.factor +++ b/basis/tools/deploy/backend/backend.factor @@ -8,14 +8,27 @@ io.streams.c io.files io.files.temp io.pathnames io.directories io.directories.hierarchy io.backend quotations io.launcher tools.deploy.config tools.deploy.config.editor bootstrap.image io.encodings.utf8 destructors accessors hashtables -vocabs.metadata.resources ; +tools.deploy.libraries vocabs.metadata.resources ; IN: tools.deploy.backend : copy-vm ( executable bundle-name -- vm ) prepend-path vm over copy-file ; +TUPLE: vocab-manifest vocabs libraries ; + : copy-resources ( manifest name dir -- ) - append-path swap [ copy-vocab-resources ] with each ; + append-path swap vocabs>> [ copy-vocab-resources ] with each ; + +ERROR: cant-deploy-library-file library ; + + +: copy-libraries ( manifest name dir -- ) + append-path swap libraries>> [ copy-library ] with each ; : image-name ( vocab bundle-name -- str ) prepend-path ".image" append ; @@ -99,10 +112,16 @@ DEFER: ?make-staging-image ] { } make ] bind ; +: parse-vocab-manifest-file ( path -- vocab-manifest ) + utf8 file-lines + dup first "VOCABS:" = + [ "LIBRARIES:" split1 vocab-manifest boa ] + [ "invalid vocab manifest!" throw ] if ; + : make-deploy-image ( vm image vocab config -- manifest ) make-boot-image over "vocab-manifest-" prepend temp-file [ swap deploy-command-line run-factor ] - [ utf8 file-lines ] bi ; + [ parse-vocab-manifest-file ] bi ; HOOK: deploy* os ( vocab -- ) diff --git a/basis/tools/deploy/libraries/libraries.factor b/basis/tools/deploy/libraries/libraries.factor new file mode 100644 index 0000000000..36fe3037de --- /dev/null +++ b/basis/tools/deploy/libraries/libraries.factor @@ -0,0 +1,11 @@ +! (c)2010 Joe Groff bsd license +USING: alien.libraries io.pathnames io.pathnames.private kernel +system vocabs.loader ; +IN: tools.deploy.libraries + +HOOK: find-library-file os ( file -- path ) + +os windows? +"tools.deploy.libraries.windows" +"tools.deploy.libraries.unix" ? require + diff --git a/basis/tools/deploy/libraries/tags.txt b/basis/tools/deploy/libraries/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/tools/deploy/libraries/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/basis/tools/deploy/libraries/unix/tags.txt b/basis/tools/deploy/libraries/unix/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/tools/deploy/libraries/unix/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/basis/tools/deploy/libraries/unix/unix.factor b/basis/tools/deploy/libraries/unix/unix.factor new file mode 100644 index 0000000000..6c3dbb4d91 --- /dev/null +++ b/basis/tools/deploy/libraries/unix/unix.factor @@ -0,0 +1,16 @@ +! (c)2010 Joe Groff bsd license +USING: io.files io.pathnames io.pathnames.private kernel +sequences system tools.deploy.libraries ; +IN: tools.deploy.libraries.unix + +! stupid hack. better ways to find the library name would be open the library, +! note a symbol address found in the library, then call dladdr (or use +: ?exists ( path -- path/f ) + dup exists? [ drop f ] unless ; inline + +M: unix find-library-file + dup absolute-path? [ ?exists ] [ + { "/lib" "/usr/lib" "/usr/local/lib" } + [ prepend-path ?exists ] with map-find drop + ] if ; + diff --git a/basis/tools/deploy/libraries/windows/windows.factor b/basis/tools/deploy/libraries/windows/windows.factor new file mode 100644 index 0000000000..4698754f07 --- /dev/null +++ b/basis/tools/deploy/libraries/windows/windows.factor @@ -0,0 +1,16 @@ +! (c)2010 Joe Groff bsd license +USING: alien.strings byte-arrays io.encodings.utf16n kernel +specialized-arrays system tools.deploy.libraries windows.kernel32 +windows.types ; +FROM: alien.c-types => ushort ; +SPECIALIZED-ARRAY: ushort +IN: tools.deploy.libraries.windows + +M: windows find-library-file + f DONT_RESOLVE_DLL_REFERENCES LoadLibraryEx [ + [ + 32768 (ushort-array) [ 32768 GetModuleFileName drop ] keep + utf16n alien>string + ] [ FreeLibrary drop ] bi + ] [ f ] if* ; + diff --git a/basis/tools/deploy/macosx/macosx.factor b/basis/tools/deploy/macosx/macosx.factor index 8bd3749093..c02642ba1d 100644 --- a/basis/tools/deploy/macosx/macosx.factor +++ b/basis/tools/deploy/macosx/macosx.factor @@ -81,7 +81,9 @@ M: macosx deploy* ( vocab -- ) [ bundle-name create-app-dir ] keep [ bundle-name deploy.app-image ] keep namespace make-deploy-image - bundle-name "Contents/Resources" copy-resources + bundle-name + [ "Contents/Resources" copy-resources ] + [ "Contents/Frameworks" copy-libraries ] 2bi bundle-name show-in-finder ] bind ] with-directory ; diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index d8a653c021..5630275aa1 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays accessors io.backend io.encodings.utf8 io.files +USING: arrays alien.libraries accessors io.backend io.encodings.utf8 io.files io.streams.c init fry namespaces math make assocs kernel parser parser.notes lexer strings.parser vocabs sequences sequences.deep sequences.private words memory kernel.private continuations io @@ -19,6 +19,7 @@ QUALIFIED: layouts QUALIFIED: source-files QUALIFIED: source-files.errors QUALIFIED: vocabs +FROM: alien.libraries.private => >deployed-library-path ; IN: tools.deploy.shaker ! This file is some hairy shit. @@ -505,11 +506,28 @@ SYMBOL: deploy-vocab : write-vocab-manifest ( vocab-manifest-out -- ) "Writing vocabulary manifest to " write dup print flush - vocabs swap utf8 set-file-lines ; + vocabs "VOCABS:" prefix + deploy-libraries get [ libraries get path>> ] map "LIBRARIES:" prefix append + swap utf8 set-file-lines ; + +: prepare-deploy-libraries ( -- ) + "Preparing deployed libraries" print flush + deploy-libraries get [ + libraries get [ + [ path>> >deployed-library-path ] [ abi>> ] bi + ] change-at + ] each + + [ + "deploy-libraries" "alien.libraries" lookup forget + "deploy-library" "alien.libraries" lookup forget + ">deployed-library-path" "alien.libraries.private" lookup forget + ] with-compilation-unit ; : strip ( vocab-manifest-out -- ) [ write-vocab-manifest ] when* startup-stripper + prepare-deploy-libraries strip-libc strip-destructors strip-call diff --git a/basis/tools/deploy/unix/unix.factor b/basis/tools/deploy/unix/unix.factor index 2646f2d5a4..1b6b8596e2 100644 --- a/basis/tools/deploy/unix/unix.factor +++ b/basis/tools/deploy/unix/unix.factor @@ -19,7 +19,7 @@ M: unix deploy* ( vocab -- ) [ bundle-name create-app-dir ] keep [ bundle-name image-name ] keep namespace make-deploy-image - bundle-name "" copy-resources + bundle-name "" [ copy-resources ] [ copy-libraries ] 3bi bundle-name normalize-path [ "Binary deployed to " % % "." % ] "" make print ] bind ] with-directory ; diff --git a/basis/tools/deploy/windows/windows.factor b/basis/tools/deploy/windows/windows.factor index 9f0b22847b..1dd60583fa 100755 --- a/basis/tools/deploy/windows/windows.factor +++ b/basis/tools/deploy/windows/windows.factor @@ -36,7 +36,7 @@ M: winnt deploy* [ drop embed-ico ] [ image-name ] [ drop namespace make-deploy-image ] - [ nip "" copy-resources ] + [ nip "" [ copy-resources ] [ copy-libraries ] 3bi ] [ nip open-in-explorer ] } 2cleave ] bind diff --git a/basis/windows/kernel32/kernel32.factor b/basis/windows/kernel32/kernel32.factor index 576fac3a06..db0005e219 100644 --- a/basis/windows/kernel32/kernel32.factor +++ b/basis/windows/kernel32/kernel32.factor @@ -90,6 +90,8 @@ CONSTANT: FILE_ACTION_MODIFIED 3 CONSTANT: FILE_ACTION_RENAMED_OLD_NAME 4 CONSTANT: FILE_ACTION_RENAMED_NEW_NAME 5 +CONSTANT: DONT_RESOLVE_DLL_REFERENCES 1 + STRUCT: FILE_NOTIFY_INFORMATION { NextEntryOffset DWORD } { Action DWORD } @@ -1167,7 +1169,7 @@ FUNCTION: BOOL FreeConsole ( ) ; ! FUNCTION: FreeEnvironmentStringsA FUNCTION: BOOL FreeEnvironmentStringsW ( LPTCH lpszEnvironmentBlock ) ; ALIAS: FreeEnvironmentStrings FreeEnvironmentStringsW -! FUNCTION: FreeLibrary +FUNCTION: BOOL FreeLibrary ( HMODULE hModule ) ; ! FUNCTION: FreeLibraryAndExitThread ! FUNCTION: FreeResource ! FUNCTION: FreeUserPhysicalPages @@ -1314,7 +1316,8 @@ FUNCTION: DWORD GetLogicalDrives ( ) ; ! FUNCTION: GetLongPathNameW ! FUNCTION: GetMailslotInfo ! FUNCTION: GetModuleFileNameA -! FUNCTION: GetModuleFileNameW +FUNCTION: DWORD GetModuleFileNameW ( HMODULE hModule, LPTSTR lpFilename, DWORD nSize ) ; +ALIAS: GetModuleFileName GetModuleFileNameW FUNCTION: HMODULE GetModuleHandleW ( LPCWSTR lpModuleName ) ; ALIAS: GetModuleHandle GetModuleHandleW ! FUNCTION: GetModuleHandleExA From 08a20f94788e7f7ceb7006dead57401dcfe5aaa5 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 13:38:29 -0800 Subject: [PATCH 048/713] math.blas.config: add deploy-blas? variable --- basis/math/blas/config/config-docs.factor | 9 +++++++-- basis/math/blas/config/config.factor | 4 +++- basis/math/blas/ffi/ffi.factor | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/basis/math/blas/config/config-docs.factor b/basis/math/blas/config/config-docs.factor index 5c6cef83b8..826f26c646 100644 --- a/basis/math/blas/config/config-docs.factor +++ b/basis/math/blas/config/config-docs.factor @@ -6,20 +6,25 @@ ARTICLE: "math.blas.config" "Configuring the BLAS interface" { $subsections blas-library blas-fortran-abi + deploy-blas? } "The interface attempts to set default values based on the ones encountered on the Factor project's build machines. If these settings don't work with your system's BLAS, or you wish to use a commercial BLAS, you may change the global values of those variables in your " { $link "factor-rc" } ". For example, to use AMD's ACML library on Windows with " { $snippet "math.blas" } ", your " { $snippet "factor-rc" } " would look like this:" { $code """ USING: math.blas.config namespaces ; "X:\\path\\to\\acml.dll" blas-library set-global intel-windows-abi blas-fortran-abi set-global +t deploy-blas? set-global """ } "To take effect, the " { $snippet "blas-library" } " and " { $snippet "blas-fortran-abi" } " variables must be set before any other " { $snippet "math.blas" } " vocabularies are loaded." ; HELP: blas-library -{ $description "The name of the shared library containing the BLAS interface to load. The value of this variable must be a valid shared library name that can be passed to " { $link add-fortran-library } ". To take effect, this variable must be set before any other " { $snippet "math.blas" } " vocabularies are loaded. See " { $link "math.blas.config" } " for details and examples." } ; +{ $var-description "The name of the shared library containing the BLAS interface to load. The value of this variable must be a valid shared library name that can be passed to " { $link add-fortran-library } ". To take effect, this variable must be set before any other " { $snippet "math.blas" } " vocabularies are loaded. See " { $link "math.blas.config" } " for details and examples." } ; HELP: blas-fortran-abi -{ $description "The Fortran ABI used by the BLAS interface specified in the " { $link blas-library } " variable. The value of " { $snippet "blas-fortran-abi" } " must be one of the " { $link "alien.fortran-abis" } " that can be passed to " { $link add-fortran-library } ". To take effect, this variable must be set before any other " { $snippet "math.blas" } " vocabularies are loaded. See " { $link "math.blas.config" } " for details and examples." } ; +{ $var-description "The Fortran ABI used by the BLAS interface specified in the " { $link blas-library } " variable. The value of " { $snippet "blas-fortran-abi" } " must be one of the " { $link "alien.fortran-abis" } " that can be passed to " { $link add-fortran-library } ". To take effect, this variable must be set before any other " { $snippet "math.blas" } " vocabularies are loaded. See " { $link "math.blas.config" } " for details and examples." } ; + +HELP: deploy-blas? +{ $var-description "If set to a true value, the BLAS library will be configured to deploy with applications that use it. To take effect, this variable must be set before any other " { $snippet "math.blas" } " vocabularies are loaded. See " { $link "math.blas.config" } " for details and examples." } ; ABOUT: "math.blas.config" diff --git a/basis/math/blas/config/config.factor b/basis/math/blas/config/config.factor index bce6e663af..76524d80ee 100644 --- a/basis/math/blas/config/config.factor +++ b/basis/math/blas/config/config.factor @@ -1,7 +1,7 @@ USING: alien.fortran combinators kernel namespaces system ; IN: math.blas.config -SYMBOLS: blas-library blas-fortran-abi ; +SYMBOLS: blas-library blas-fortran-abi deploy-blas? ; blas-library [ { @@ -21,3 +21,5 @@ blas-fortran-abi [ [ f2c-abi ] } cond ] initialize + +deploy-blas? [ os macosx? not ] initialize diff --git a/basis/math/blas/ffi/ffi.factor b/basis/math/blas/ffi/ffi.factor index b7748f500f..5cc6a18b6d 100644 --- a/basis/math/blas/ffi/ffi.factor +++ b/basis/math/blas/ffi/ffi.factor @@ -1,9 +1,12 @@ USING: alien.fortran kernel math.blas.config namespaces ; +FROM: alien.libraries => deploy-library ; IN: math.blas.ffi << "blas" blas-library blas-fortran-abi [ get ] bi@ add-fortran-library + +deploy-blas? get [ "blas" deploy-library ] when >> LIBRARY: blas From b208c30fd3bb9f8dc73559acf4d831bbcd65a7c8 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 13:41:35 -0800 Subject: [PATCH 049/713] tools.deploy.shaker: prune library manifest --- basis/tools/deploy/shaker/shaker.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index 5630275aa1..4a9882c2e6 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -507,7 +507,7 @@ SYMBOL: deploy-vocab : write-vocab-manifest ( vocab-manifest-out -- ) "Writing vocabulary manifest to " write dup print flush vocabs "VOCABS:" prefix - deploy-libraries get [ libraries get path>> ] map "LIBRARIES:" prefix append + deploy-libraries get [ libraries get path>> ] map prune "LIBRARIES:" prefix append swap utf8 set-file-lines ; : prepare-deploy-libraries ( -- ) From 2f17248094ba2693b38ca9b70bdafaf8077c65c7 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 13:42:01 -0800 Subject: [PATCH 050/713] deploy openal and alut libraries except on OS X --- extra/openal/openal.factor | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extra/openal/openal.factor b/extra/openal/openal.factor index 85b150ce09..d3c2b0a5cc 100644 --- a/extra/openal/openal.factor +++ b/extra/openal/openal.factor @@ -24,6 +24,8 @@ IN: openal { [ os unix? ] [ "libopenal.so" ] } } cond "cdecl" add-library >> +<< os macosx? [ "openal" deploy-library "alut" deploy-library ] unless >> + LIBRARY: openal TYPEDEF: char ALboolean From 04878057aff1288f8b7347964c657d5ddadaa571 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Tue, 16 Feb 2010 15:48:07 -0600 Subject: [PATCH 051/713] Compiler.cfg.{dce,linearization} use new-sets --- basis/bit-sets/bit-sets-tests.factor | 3 ++ basis/bit-sets/bit-sets.factor | 3 ++ basis/compiler/cfg/dce/dce.factor | 19 +++++----- .../cfg/linearization/order/order.factor | 16 ++++---- basis/new-sets/new-sets-tests.factor | 31 +--------------- basis/new-sets/new-sets.factor | 37 ++++--------------- 6 files changed, 33 insertions(+), 76 deletions(-) diff --git a/basis/bit-sets/bit-sets-tests.factor b/basis/bit-sets/bit-sets-tests.factor index c4260915ac..26010a3337 100644 --- a/basis/bit-sets/bit-sets-tests.factor +++ b/basis/bit-sets/bit-sets-tests.factor @@ -58,3 +58,6 @@ IN: bit-sets.tests [ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 1 swap delete ] keep members ] unit-test [ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ 9 swap delete ] keep members ] unit-test [ V{ 0 2 5 } ] [ T{ bit-set f ?{ t f t f f t } } clone [ "foo" swap delete ] keep members ] unit-test + +[ T{ bit-set f ?{ f } } T{ bit-set f ?{ t } } ] +[ 1 dup clone 0 over adjoin ] unit-test diff --git a/basis/bit-sets/bit-sets.factor b/basis/bit-sets/bit-sets.factor index d6c9a48bed..a3cac64295 100644 --- a/basis/bit-sets/bit-sets.factor +++ b/basis/bit-sets/bit-sets.factor @@ -69,3 +69,6 @@ M: bit-set set-like [ members ] dip table>> length [ [ adjoin ] curry each ] keep ] if ; + +M: bit-set clone + table>> clone bit-set boa ; diff --git a/basis/compiler/cfg/dce/dce.factor b/basis/compiler/cfg/dce/dce.factor index 03a43d0ab7..c8010d9aa8 100644 --- a/basis/compiler/cfg/dce/dce.factor +++ b/basis/compiler/cfg/dce/dce.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2008, 2009 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs sets kernel namespaces sequences +USING: accessors assocs kernel namespaces sequences compiler.cfg.instructions compiler.cfg.def-use -compiler.cfg.rpo compiler.cfg.predecessors ; +compiler.cfg.rpo compiler.cfg.predecessors hash-sets new-sets ; +FROM: namespaces => set ; IN: compiler.cfg.dce ! Maps vregs to sequences of vregs @@ -12,18 +13,18 @@ SYMBOL: liveness-graph SYMBOL: live-vregs : live-vreg? ( vreg -- ? ) - live-vregs get key? ; + live-vregs get in? ; ! vregs which are the result of an allocation SYMBOL: allocations : allocation? ( vreg -- ? ) - allocations get key? ; + allocations get in? ; : init-dead-code ( -- ) H{ } clone liveness-graph set - H{ } clone live-vregs set - H{ } clone allocations set ; + HS{ } clone live-vregs set + HS{ } clone allocations set ; GENERIC: build-liveness-graph ( insn -- ) @@ -46,7 +47,7 @@ M: ##write-barrier-imm build-liveness-graph dup src>> setter-liveness-graph ; M: ##allot build-liveness-graph - [ dst>> allocations get conjoin ] [ call-next-method ] bi ; + [ dst>> allocations get adjoin ] [ call-next-method ] bi ; M: insn build-liveness-graph dup defs-vreg dup [ add-edges ] [ 2drop ] if ; @@ -55,8 +56,8 @@ GENERIC: compute-live-vregs ( insn -- ) : (record-live) ( vregs -- ) [ - dup live-vregs get key? [ drop ] [ - [ live-vregs get conjoin ] + dup live-vreg? [ drop ] [ + [ live-vregs get adjoin ] [ liveness-graph get at (record-live) ] bi ] if diff --git a/basis/compiler/cfg/linearization/order/order.factor b/basis/compiler/cfg/linearization/order/order.factor index 1fcc137c60..f48816d1b9 100644 --- a/basis/compiler/cfg/linearization/order/order.factor +++ b/basis/compiler/cfg/linearization/order/order.factor @@ -2,8 +2,10 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs deques dlists kernel make sorting namespaces sequences combinators combinators.short-circuit -fry math sets compiler.cfg.rpo compiler.cfg.utilities -compiler.cfg.loop-detection compiler.cfg.predecessors ; +fry math compiler.cfg.rpo compiler.cfg.utilities +compiler.cfg.loop-detection compiler.cfg.predecessors +new-sets hash-sets ; +FROM: namespaces => set ; IN: compiler.cfg.linearization.order ! This is RPO except loops are rotated. Based on SBCL's src/compiler/control.lisp @@ -12,16 +14,16 @@ IN: compiler.cfg.linearization.order SYMBOLS: work-list loop-heads visited ; -: visited? ( bb -- ? ) visited get key? ; +: visited? ( bb -- ? ) visited get in? ; : add-to-work-list ( bb -- ) - dup visited get key? [ drop ] [ + dup visited? [ drop ] [ work-list get push-back ] if ; : init-linearization-order ( cfg -- ) work-list set - H{ } clone visited set + HS{ } clone visited set entry>> add-to-work-list ; : (find-alternate-loop-head) ( bb -- bb' ) @@ -58,7 +60,7 @@ SYMBOLS: work-list loop-heads visited ; : process-block ( bb -- ) dup visited? [ drop ] [ [ , ] - [ visited get conjoin ] + [ visited get adjoin ] [ sorted-successors [ process-successor ] each ] tri ] if ; @@ -76,4 +78,4 @@ PRIVATE> dup linear-order>> [ ] [ dup (linearization-order) >>linear-order linear-order>> - ] ?if ; \ No newline at end of file + ] ?if ; diff --git a/basis/new-sets/new-sets-tests.factor b/basis/new-sets/new-sets-tests.factor index a03ab9f18e..12da3a7515 100644 --- a/basis/new-sets/new-sets-tests.factor +++ b/basis/new-sets/new-sets-tests.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2010 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. -USING: new-sets tools.test kernel sorting prettyprint bit-arrays arrays ; +USING: new-sets tools.test kernel prettyprint hash-sets sorting ; IN: new-sets.tests [ { } ] [ { } { } intersect ] unit-test @@ -38,32 +38,3 @@ IN: new-sets.tests [ { 1 2 3 } ] [ HS{ 1 2 3 } { } set-like natural-sort ] unit-test [ HS{ 1 2 3 } ] [ { 1 2 3 } fast-set ] unit-test - -[ { 1 2 3 } ] [ HS{ 1 2 3 } members natural-sort ] unit-test - -[ "HS{ 1 2 3 4 }" ] [ HS{ 1 2 3 4 } unparse ] unit-test - -[ t ] [ 1 HS{ 0 1 2 } in? ] unit-test -[ f ] [ 3 HS{ 0 1 2 } in? ] unit-test -[ HS{ 1 2 3 } ] [ 3 HS{ 1 2 } clone [ adjoin ] keep ] unit-test -[ HS{ 1 2 } ] [ 2 HS{ 1 2 } clone [ adjoin ] keep ] unit-test -[ HS{ 1 2 3 } ] [ 4 HS{ 1 2 3 } clone [ delete ] keep ] unit-test -[ HS{ 1 2 } ] [ 3 HS{ 1 2 3 } clone [ delete ] keep ] unit-test -[ HS{ 1 2 } ] [ HS{ 1 2 } fast-set ] unit-test -[ { 1 2 } ] [ HS{ 1 2 } members natural-sort ] unit-test - -[ HS{ 1 2 3 4 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } union ] unit-test -[ HS{ 2 3 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } intersect ] unit-test -[ t ] [ HS{ 1 2 3 } HS{ 2 3 4 } intersects? ] unit-test -[ f ] [ HS{ 1 } HS{ 2 3 4 } intersects? ] unit-test -[ f ] [ HS{ 1 } HS{ 2 3 4 } subset? ] unit-test -[ f ] [ HS{ 1 2 3 } HS{ 2 3 4 } subset? ] unit-test -[ t ] [ HS{ 2 3 } HS{ 2 3 4 } subset? ] unit-test -[ t ] [ HS{ } HS{ 2 3 4 } subset? ] unit-test -[ HS{ 1 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } diff ] unit-test -[ t ] [ HS{ 1 2 3 } HS{ 2 1 3 } set= ] unit-test -[ t ] [ HS{ 1 2 3 } HS{ 2 1 3 } = ] unit-test -[ f ] [ HS{ 2 3 } HS{ 2 1 3 } set= ] unit-test -[ f ] [ HS{ 1 2 3 } HS{ 2 3 } set= ] unit-test - -[ HS{ 1 2 } HS{ 1 2 3 } ] [ HS{ 1 2 } clone dup clone [ 3 swap adjoin ] keep ] unit-test diff --git a/basis/new-sets/new-sets.factor b/basis/new-sets/new-sets.factor index 770368ae3b..5f42dc40af 100644 --- a/basis/new-sets/new-sets.factor +++ b/basis/new-sets/new-sets.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs hashtables kernel math sequences parser prettyprint.custom ; -QUALIFIED: sets +FROM: sets => prune ; IN: new-sets ! The vocab is called new-sets for now, but only until it gets into core ! All the code here is in the style that could be put in core @@ -52,37 +52,14 @@ M: set set= M: set fast-set ; -! Hash sets -! In a better implementation, less memory would be used -TUPLE: hash-set { table hashtable read-only } ; - -: ( members -- hash-set ) - sets:unique hash-set boa ; - -INSTANCE: hash-set set -M: hash-set in? table>> key? ; inline -M: hash-set adjoin table>> dupd set-at ; inline -M: hash-set delete table>> delete-at ; inline -M: hash-set members table>> keys ; inline -M: hash-set set-like - drop dup hash-set? [ members ] unless ; -M: hash-set clone - table>> clone hash-set boa ; - -SYNTAX: HS{ - \ } [ ] parse-literal ; - -M: hash-set pprint* pprint-object ; -M: hash-set pprint-delims drop \ HS{ \ } ; -M: hash-set >pprint-sequence members ; - ! Sequences are sets INSTANCE: sequence set M: sequence in? member? ; inline -M: sequence adjoin sets:adjoin ; inline +M: sequence adjoin [ delete ] [ push ] 2bi ; M: sequence delete remove! drop ; inline M: sequence set-like - [ dup sequence? [ sets:prune ] [ members ] if ] dip - like ; -M: sequence members ; -M: sequence fast-set ; + [ dup sequence? [ prune ] [ members ] if ] dip like ; +M: sequence members fast-set members ; + +USE: vocabs.loader +"hash-sets" require From b64f694e7ebe3f2e87c26fe79b74f2a6dab191c0 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 14:23:51 -0800 Subject: [PATCH 052/713] tools.deploy.shaker typos --- 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 4a9882c2e6..54058f1b0d 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -507,11 +507,11 @@ SYMBOL: deploy-vocab : write-vocab-manifest ( vocab-manifest-out -- ) "Writing vocabulary manifest to " write dup print flush vocabs "VOCABS:" prefix - deploy-libraries get [ libraries get path>> ] map prune "LIBRARIES:" prefix append + deploy-libraries get [ libraries get at path>> ] map prune "LIBRARIES:" prefix append swap utf8 set-file-lines ; : prepare-deploy-libraries ( -- ) - "Preparing deployed libraries" print flush + "Preparing deployed libraries" show deploy-libraries get [ libraries get [ [ path>> >deployed-library-path ] [ abi>> ] bi From dcac051a4d467ca0f60923e731875b099cdccd25 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 14:24:04 -0800 Subject: [PATCH 053/713] deploy ogg and vorbis libraries --- extra/ogg/ogg.factor | 2 ++ extra/ogg/vorbis/vorbis.factor | 2 ++ 2 files changed, 4 insertions(+) diff --git a/extra/ogg/ogg.factor b/extra/ogg/ogg.factor index 24227167c9..d7abece8bc 100644 --- a/extra/ogg/ogg.factor +++ b/extra/ogg/ogg.factor @@ -19,6 +19,8 @@ IN: ogg { [ os macosx? ] [ "libogg.0.dylib" ] } { [ os unix? ] [ "libogg.so" ] } } cond "cdecl" add-library + +"ogg" deploy-library >> LIBRARY: ogg diff --git a/extra/ogg/vorbis/vorbis.factor b/extra/ogg/vorbis/vorbis.factor index 8cf79fecaf..d5905dac9e 100644 --- a/extra/ogg/vorbis/vorbis.factor +++ b/extra/ogg/vorbis/vorbis.factor @@ -20,6 +20,8 @@ IN: ogg.vorbis { [ os macosx? ] [ "libvorbis.0.dylib" ] } { [ os unix? ] [ "libvorbis.so" ] } } cond "cdecl" add-library + +"vorbis" deploy-library >> LIBRARY: vorbis From 38f98afe6f8787b634a84e53d86567291ddd1239 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 14:24:29 -0800 Subject: [PATCH 054/713] search resource: for unix libraries too --- basis/tools/deploy/libraries/unix/unix.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/tools/deploy/libraries/unix/unix.factor b/basis/tools/deploy/libraries/unix/unix.factor index 6c3dbb4d91..db3e9fa134 100644 --- a/basis/tools/deploy/libraries/unix/unix.factor +++ b/basis/tools/deploy/libraries/unix/unix.factor @@ -10,7 +10,7 @@ IN: tools.deploy.libraries.unix M: unix find-library-file dup absolute-path? [ ?exists ] [ - { "/lib" "/usr/lib" "/usr/local/lib" } + { "/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" "resource:" } [ prepend-path ?exists ] with map-find drop ] if ; From 10bc247ed4681b936bdefd4eac35ba54d3c38fc8 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 14:33:57 -0800 Subject: [PATCH 055/713] typo in tools.deploy.backend --- basis/tools/deploy/backend/backend.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/tools/deploy/backend/backend.factor b/basis/tools/deploy/backend/backend.factor index 4a4037d754..fe63071998 100644 --- a/basis/tools/deploy/backend/backend.factor +++ b/basis/tools/deploy/backend/backend.factor @@ -115,7 +115,7 @@ DEFER: ?make-staging-image : parse-vocab-manifest-file ( path -- vocab-manifest ) utf8 file-lines dup first "VOCABS:" = - [ "LIBRARIES:" split1 vocab-manifest boa ] + [ { "LIBRARIES:" } split1 vocab-manifest boa ] [ "invalid vocab manifest!" throw ] if ; : make-deploy-image ( vm image vocab config -- manifest ) From 4a182cfbade49380fcd18fd47707bc4d4f8d6044 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 18:40:40 -0800 Subject: [PATCH 056/713] fix append-path and vocab-dir to use path-separator --- core/io/pathnames/pathnames.factor | 2 +- core/vocabs/loader/loader.factor | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/io/pathnames/pathnames.factor b/core/io/pathnames/pathnames.factor index b307128efb..5a9c647973 100644 --- a/core/io/pathnames/pathnames.factor +++ b/core/io/pathnames/pathnames.factor @@ -103,7 +103,7 @@ PRIVATE> ] } [ [ trim-tail-separators ] - [ trim-head-separators ] bi* "/" glue + [ trim-head-separators ] bi* path-separator glue ] } cond ; diff --git a/core/vocabs/loader/loader.factor b/core/vocabs/loader/loader.factor index 2c0f67641d..0f2e3f7178 100644 --- a/core/vocabs/loader/loader.factor +++ b/core/vocabs/loader/loader.factor @@ -35,7 +35,9 @@ M: string vocab-path ( string -- path/f ) PRIVATE> : vocab-dir ( vocab -- dir ) - vocab-name { { CHAR: . CHAR: / } } substitute ; + vocab-name + os windows? { { CHAR: . CHAR: \\ } } { { CHAR: . CHAR: / } } ? + substitute ; : vocab-dir+ ( vocab str/f -- path ) [ vocab-name "." split ] dip From f59f28d78861dc7aa861f3333eecf7e31075dcfa Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 19:01:44 -0800 Subject: [PATCH 057/713] io.pathnames: make absolute-path? public --- core/io/pathnames/pathnames.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/io/pathnames/pathnames.factor b/core/io/pathnames/pathnames.factor index 5a9c647973..2be66ef186 100644 --- a/core/io/pathnames/pathnames.factor +++ b/core/io/pathnames/pathnames.factor @@ -76,6 +76,8 @@ ERROR: no-parent-directory path ; [ f ] } cond ; +PRIVATE> + : absolute-path? ( path -- ? ) { { [ dup empty? ] [ f ] } @@ -85,8 +87,6 @@ ERROR: no-parent-directory path ; [ f ] } cond nip ; -PRIVATE> - : append-path ( path1 path2 -- path ) { { [ over empty? ] [ append-path-empty ] } From 6ac33f6dea2bbb8f274d14cfa9ff141a4a7cd229 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 19:28:51 -0800 Subject: [PATCH 058/713] make io.pathnames tests path-separator-neutral --- core/io/pathnames/pathnames-tests.factor | 35 +++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/core/io/pathnames/pathnames-tests.factor b/core/io/pathnames/pathnames-tests.factor index f23a1ac1f4..38cfe330fb 100644 --- a/core/io/pathnames/pathnames-tests.factor +++ b/core/io/pathnames/pathnames-tests.factor @@ -1,6 +1,6 @@ USING: io.pathnames io.files.temp io.directories continuations math io.files.private kernel -namespaces tools.test io.pathnames.private ; +namespaces sequences tools.test io.pathnames.private ; IN: io.pathnames.tests [ "passwd" ] [ "/etc/passwd" file-name ] unit-test @@ -11,20 +11,23 @@ IN: io.pathnames.tests [ "freetype6.dll" ] [ "resource:freetype6.dll" file-name ] unit-test [ "freetype6.dll" ] [ "resource:/freetype6.dll" file-name ] unit-test -[ "/usr/lib" ] [ "/usr" "lib" append-path ] unit-test -[ "/usr/lib" ] [ "/usr/" "lib" append-path ] unit-test -[ "/usr/lib" ] [ "/usr" "./lib" append-path ] unit-test -[ "/usr/lib/" ] [ "/usr" "./lib/" append-path ] unit-test -[ "/lib" ] [ "/usr" "../lib" append-path ] unit-test -[ "/lib/" ] [ "/usr" "../lib/" append-path ] unit-test +: >test-path ( path -- path' ) + [ dup path-separator? [ drop CHAR: / ] when ] map ; + +[ "/usr/lib" ] [ "/usr" "lib" append-path >test-path ] unit-test +[ "/usr/lib" ] [ "/usr/" "lib" append-path >test-path ] unit-test +[ "/usr/lib" ] [ "/usr" "./lib" append-path >test-path ] unit-test +[ "/usr/lib/" ] [ "/usr" "./lib/" append-path >test-path ] unit-test +[ "/lib" ] [ "/usr" "../lib" append-path >test-path ] unit-test +[ "/lib/" ] [ "/usr" "../lib/" append-path >test-path ] unit-test [ "" ] [ "" "." append-path ] unit-test [ "" ".." append-path ] must-fail -[ "/" ] [ "/" "./." append-path ] unit-test -[ "/" ] [ "/" "././" append-path ] unit-test -[ "/a/b/lib" ] [ "/a/b/c/d/e/f/" "../../../../lib" append-path ] unit-test -[ "/a/b/lib/" ] [ "/a/b/c/d/e/f/" "../../../../lib/" append-path ] unit-test +[ "/" ] [ "/" "./." append-path >test-path ] unit-test +[ "/" ] [ "/" "././" append-path >test-path ] unit-test +[ "/a/b/lib" ] [ "/a/b/c/d/e/f/" "../../../../lib" append-path >test-path ] unit-test +[ "/a/b/lib/" ] [ "/a/b/c/d/e/f/" "../../../../lib/" append-path >test-path ] unit-test [ "" "../lib/" append-path ] must-fail [ "lib" ] [ "" "lib" append-path ] unit-test @@ -45,10 +48,10 @@ IN: io.pathnames.tests [ "" parent-directory ] must-fail [ "." ] [ "boot.x86.64.image" parent-directory ] unit-test -[ "bar/foo" ] [ "bar/baz" "..///foo" append-path ] unit-test -[ "bar/baz/foo" ] [ "bar/baz" ".///foo" append-path ] unit-test -[ "bar/foo" ] [ "bar/baz" "./..//foo" append-path ] unit-test -[ "bar/foo" ] [ "bar/baz" "./../././././././///foo" append-path ] unit-test +[ "bar/foo" ] [ "bar/baz" "..///foo" append-path >test-path ] unit-test +[ "bar/baz/foo" ] [ "bar/baz" ".///foo" append-path >test-path ] unit-test +[ "bar/foo" ] [ "bar/baz" "./..//foo" append-path >test-path ] unit-test +[ "bar/foo" ] [ "bar/baz" "./../././././././///foo" append-path >test-path ] unit-test [ t ] [ "resource:core" absolute-path? ] unit-test [ f ] [ "" absolute-path? ] unit-test @@ -61,7 +64,7 @@ IN: io.pathnames.tests "." current-directory set ".." "resource-path" set [ "../core/bootstrap/stage2.factor" ] - [ "resource:core/bootstrap/stage2.factor" absolute-path ] + [ "resource:core/bootstrap/stage2.factor" absolute-path >test-path ] unit-test ] with-scope From 27cfeec43a5e4e23a1c329e8459b474c0f9cd1a3 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 19:29:42 -0800 Subject: [PATCH 059/713] vocabs.loader: make vocab-dir+ use path-separator too --- core/vocabs/loader/loader.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/vocabs/loader/loader.factor b/core/vocabs/loader/loader.factor index 0f2e3f7178..390cfceb95 100644 --- a/core/vocabs/loader/loader.factor +++ b/core/vocabs/loader/loader.factor @@ -42,7 +42,7 @@ PRIVATE> : vocab-dir+ ( vocab str/f -- path ) [ vocab-name "." split ] dip [ [ dup last ] dip append suffix ] when* - "/" join ; + path-separator join ; : find-vocab-root ( vocab -- path/f ) vocab-name dup root-cache get at From a9c13e03017da324a8130729256e31f9395ad657 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 22:19:56 -0800 Subject: [PATCH 060/713] fix last globs test on windows --- basis/globs/globs-tests.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 basis/globs/globs-tests.factor diff --git a/basis/globs/globs-tests.factor b/basis/globs/globs-tests.factor old mode 100644 new mode 100755 index c9903b1633..b2432754b1 --- a/basis/globs/globs-tests.factor +++ b/basis/globs/globs-tests.factor @@ -30,7 +30,7 @@ IN: globs.tests [ t ] [ "fo\\*" glob-pattern? ] unit-test [ t ] [ "fo{o,bro}" glob-pattern? ] unit-test -"foo" "bar" append-path 1array +{ "foo" "bar" } path-separator join 1array [ { "foo" "bar" "ba?" } path-separator join glob-parent-directory ] unit-test [ "foo" ] From a64d6e27ecc0a1b3673277aedbdc3a981a9f91a2 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Feb 2010 22:31:21 -0800 Subject: [PATCH 061/713] move alut stuff to openal.alut so alut only gets deployed if we use it --- extra/morse/morse.factor | 2 +- extra/openal/alut/alut.factor | 103 ++++++++++++++++++ extra/openal/{ => alut}/backend/authors.txt | 0 .../openal/{ => alut}/backend/backend.factor | 2 +- extra/openal/{ => alut}/macosx/authors.txt | 0 extra/openal/{ => alut}/macosx/macosx.factor | 4 +- extra/openal/{ => alut}/macosx/tags.txt | 0 extra/openal/{ => alut}/other/authors.txt | 0 extra/openal/{ => alut}/other/other.factor | 4 +- extra/openal/example/example.factor | 2 +- extra/openal/openal.factor | 95 +--------------- extra/space-invaders/space-invaders.factor | 1 + extra/synth/example/example.factor | 2 +- extra/synth/synth.factor | 2 +- 14 files changed, 115 insertions(+), 102 deletions(-) mode change 100644 => 100755 extra/morse/morse.factor create mode 100755 extra/openal/alut/alut.factor rename extra/openal/{ => alut}/backend/authors.txt (100%) rename extra/openal/{ => alut}/backend/backend.factor (79%) mode change 100644 => 100755 rename extra/openal/{ => alut}/macosx/authors.txt (100%) rename extra/openal/{ => alut}/macosx/macosx.factor (84%) mode change 100644 => 100755 rename extra/openal/{ => alut}/macosx/tags.txt (100%) rename extra/openal/{ => alut}/other/authors.txt (100%) rename extra/openal/{ => alut}/other/other.factor (89%) mode change 100644 => 100755 mode change 100644 => 100755 extra/openal/example/example.factor mode change 100644 => 100755 extra/openal/openal.factor mode change 100644 => 100755 extra/space-invaders/space-invaders.factor mode change 100644 => 100755 extra/synth/example/example.factor mode change 100644 => 100755 extra/synth/synth.factor diff --git a/extra/morse/morse.factor b/extra/morse/morse.factor old mode 100644 new mode 100755 index cbe3c0f2fa..c6f1601955 --- a/extra/morse/morse.factor +++ b/extra/morse/morse.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007, 2008, 2009 Alex Chapman, 2009 Diego Martinelli ! See http://factorcode.org/license.txt for BSD license. -USING: accessors ascii assocs biassocs combinators hashtables kernel lists literals math namespaces make multiline openal parser sequences splitting strings synth synth.buffers ; +USING: accessors ascii assocs biassocs combinators hashtables kernel lists literals math namespaces make multiline openal openal.alut parser sequences splitting strings synth synth.buffers ; IN: morse ERROR: no-morse-ch ch ; diff --git a/extra/openal/alut/alut.factor b/extra/openal/alut/alut.factor new file mode 100755 index 0000000000..d1b8d2600d --- /dev/null +++ b/extra/openal/alut/alut.factor @@ -0,0 +1,103 @@ +! Copyright (C) 2007 Chris Double. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel accessors arrays alien system combinators +alien.syntax namespaces alien.c-types sequences vocabs.loader +shuffle openal openal.alut.backend alien.libraries generalizations +specialized-arrays alien.destructors ; +FROM: alien.c-types => float short ; +SPECIALIZED-ARRAY: uint +IN: openal.alut + +<< "alut" { + { [ os windows? ] [ "alut.dll" ] } + { [ os macosx? ] [ + "/System/Library/Frameworks/OpenAL.framework/OpenAL" + ] } + { [ os unix? ] [ "libalut.so" ] } + } cond "cdecl" add-library >> + +<< os macosx? [ "alut" deploy-library ] unless >> + +LIBRARY: alut + +CONSTANT: ALUT_API_MAJOR_VERSION 1 +CONSTANT: ALUT_API_MINOR_VERSION 1 +CONSTANT: ALUT_ERROR_NO_ERROR 0 +CONSTANT: ALUT_ERROR_OUT_OF_MEMORY HEX: 200 +CONSTANT: ALUT_ERROR_INVALID_ENUM HEX: 201 +CONSTANT: ALUT_ERROR_INVALID_VALUE HEX: 202 +CONSTANT: ALUT_ERROR_INVALID_OPERATION HEX: 203 +CONSTANT: ALUT_ERROR_NO_CURRENT_CONTEXT HEX: 204 +CONSTANT: ALUT_ERROR_AL_ERROR_ON_ENTRY HEX: 205 +CONSTANT: ALUT_ERROR_ALC_ERROR_ON_ENTRY HEX: 206 +CONSTANT: ALUT_ERROR_OPEN_DEVICE HEX: 207 +CONSTANT: ALUT_ERROR_CLOSE_DEVICE HEX: 208 +CONSTANT: ALUT_ERROR_CREATE_CONTEXT HEX: 209 +CONSTANT: ALUT_ERROR_MAKE_CONTEXT_CURRENT HEX: 20A +CONSTANT: ALUT_ERROR_DESTRY_CONTEXT HEX: 20B +CONSTANT: ALUT_ERROR_GEN_BUFFERS HEX: 20C +CONSTANT: ALUT_ERROR_BUFFER_DATA HEX: 20D +CONSTANT: ALUT_ERROR_IO_ERROR HEX: 20E +CONSTANT: ALUT_ERROR_UNSUPPORTED_FILE_TYPE HEX: 20F +CONSTANT: ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE HEX: 210 +CONSTANT: ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA HEX: 211 +CONSTANT: ALUT_WAVEFORM_SINE HEX: 100 +CONSTANT: ALUT_WAVEFORM_SQUARE HEX: 101 +CONSTANT: ALUT_WAVEFORM_SAWTOOTH HEX: 102 +CONSTANT: ALUT_WAVEFORM_WHITENOISE HEX: 103 +CONSTANT: ALUT_WAVEFORM_IMPULSE HEX: 104 +CONSTANT: ALUT_LOADER_BUFFER HEX: 300 +CONSTANT: ALUT_LOADER_MEMORY HEX: 301 + +FUNCTION: ALboolean alutInit ( int* argcp, char** argv ) ; +FUNCTION: ALboolean alutInitWithoutContext ( int* argcp, char** argv ) ; +FUNCTION: ALboolean alutExit ( ) ; +FUNCTION: ALenum alutGetError ( ) ; +FUNCTION: char* alutGetErrorString ( ALenum error ) ; +FUNCTION: ALuint alutCreateBufferFromFile ( char* fileName ) ; +FUNCTION: ALuint alutCreateBufferFromFileImage ( void* data, ALsizei length ) ; +FUNCTION: ALuint alutCreateBufferHelloWorld ( ) ; +FUNCTION: ALuint alutCreateBufferWaveform ( ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration ) ; +FUNCTION: void* alutLoadMemoryFromFile ( char* fileName, ALenum* format, ALsizei* size, ALfloat* frequency ) ; +FUNCTION: void* alutLoadMemoryFromFileImage ( void* data, ALsizei length, ALenum* format, ALsizei* size, ALfloat* frequency ) ; +FUNCTION: void* alutLoadMemoryHelloWorld ( ALenum* format, ALsizei* size, ALfloat* frequency ) ; +FUNCTION: void* alutLoadMemoryWaveform ( ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration, ALenum* format, ALsizei* size, ALfloat* freq ) ; +FUNCTION: char* alutGetMIMETypes ( ALenum loader ) ; +FUNCTION: ALint alutGetMajorVersion ( ) ; +FUNCTION: ALint alutGetMinorVersion ( ) ; +FUNCTION: ALboolean alutSleep ( ALfloat duration ) ; + +FUNCTION: void alutUnloadWAV ( ALenum format, void* data, ALsizei size, ALsizei frequency ) ; + +SYMBOL: init + +: init-openal ( -- ) + init get-global expired? [ + f f alutInit 0 = [ "Could not initialize OpenAL" throw ] when + 1337 init set-global + ] when ; + +: exit-openal ( -- ) + init get-global expired? [ + alutExit 0 = [ "Could not close OpenAL" throw ] when + f init set-global + ] unless ; + +: create-buffer-from-file ( filename -- buffer ) + alutCreateBufferFromFile dup AL_NONE = [ + "create-buffer-from-file failed" throw + ] when ; + +os macosx? "openal.alut.macosx" "openal.alut.other" ? require + +: create-buffer-from-wav ( filename -- buffer ) + gen-buffer dup rot load-wav-file + [ alBufferData ] 4 nkeep alutUnloadWAV ; + +: check-error ( -- ) + alGetError dup ALUT_ERROR_NO_ERROR = [ + drop + ] [ + alGetString throw + ] if ; + diff --git a/extra/openal/backend/authors.txt b/extra/openal/alut/backend/authors.txt similarity index 100% rename from extra/openal/backend/authors.txt rename to extra/openal/alut/backend/authors.txt diff --git a/extra/openal/backend/backend.factor b/extra/openal/alut/backend/backend.factor old mode 100644 new mode 100755 similarity index 79% rename from extra/openal/backend/backend.factor rename to extra/openal/alut/backend/backend.factor index 41069dcddf..fc50d3d15e --- a/extra/openal/backend/backend.factor +++ b/extra/openal/alut/backend/backend.factor @@ -1,4 +1,4 @@ USING: namespaces system ; -IN: openal.backend +IN: openal.alut.backend HOOK: load-wav-file os ( filename -- format data size frequency ) diff --git a/extra/openal/macosx/authors.txt b/extra/openal/alut/macosx/authors.txt similarity index 100% rename from extra/openal/macosx/authors.txt rename to extra/openal/alut/macosx/authors.txt diff --git a/extra/openal/macosx/macosx.factor b/extra/openal/alut/macosx/macosx.factor old mode 100644 new mode 100755 similarity index 84% rename from extra/openal/macosx/macosx.factor rename to extra/openal/alut/macosx/macosx.factor index f0a6b928e9..3c0a4672cb --- a/extra/openal/macosx/macosx.factor +++ b/extra/openal/alut/macosx/macosx.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2007 Chris Double. ! See http://factorcode.org/license.txt for BSD license. USING: alien.c-types kernel alien alien.syntax shuffle -openal openal.backend namespaces system generalizations ; -IN: openal.macosx +openal openal.alut.backend namespaces system generalizations ; +IN: openal.alut.macosx LIBRARY: alut diff --git a/extra/openal/macosx/tags.txt b/extra/openal/alut/macosx/tags.txt similarity index 100% rename from extra/openal/macosx/tags.txt rename to extra/openal/alut/macosx/tags.txt diff --git a/extra/openal/other/authors.txt b/extra/openal/alut/other/authors.txt similarity index 100% rename from extra/openal/other/authors.txt rename to extra/openal/alut/other/authors.txt diff --git a/extra/openal/other/other.factor b/extra/openal/alut/other/other.factor old mode 100644 new mode 100755 similarity index 89% rename from extra/openal/other/other.factor rename to extra/openal/alut/other/other.factor index ada8d6b1fb..b19579286b --- a/extra/openal/other/other.factor +++ b/extra/openal/alut/other/other.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2007 Chris Double. ! See http://factorcode.org/license.txt for BSD license. USING: alien.c-types alien.syntax combinators generalizations -kernel openal openal.backend ; -IN: openal.other +kernel openal openal.alut.backend ; +IN: openal.alut.other LIBRARY: alut diff --git a/extra/openal/example/example.factor b/extra/openal/example/example.factor old mode 100644 new mode 100755 index 4d979a8fa7..7789ee6e0a --- a/extra/openal/example/example.factor +++ b/extra/openal/example/example.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007 Chris Double. ! See http://factorcode.org/license.txt for BSD license. -USING: calendar kernel openal sequences threads ; +USING: calendar kernel openal openal.alut sequences threads ; IN: openal.example : play-hello ( -- ) diff --git a/extra/openal/openal.factor b/extra/openal/openal.factor old mode 100644 new mode 100755 index d3c2b0a5cc..bbe61f9dc3 --- a/extra/openal/openal.factor +++ b/extra/openal/openal.factor @@ -2,20 +2,12 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel accessors arrays alien system combinators alien.syntax namespaces alien.c-types sequences vocabs.loader -shuffle openal.backend alien.libraries generalizations +shuffle alien.libraries generalizations specialized-arrays alien.destructors ; FROM: alien.c-types => float short ; SPECIALIZED-ARRAY: uint IN: openal -<< "alut" { - { [ os windows? ] [ "alut.dll" ] } - { [ os macosx? ] [ - "/System/Library/Frameworks/OpenAL.framework/OpenAL" - ] } - { [ os unix? ] [ "libalut.so" ] } - } cond "cdecl" add-library >> - << "openal" { { [ os windows? ] [ "OpenAL32.dll" ] } { [ os macosx? ] [ @@ -24,7 +16,7 @@ IN: openal { [ os unix? ] [ "libopenal.so" ] } } cond "cdecl" add-library >> -<< os macosx? [ "openal" deploy-library "alut" deploy-library ] unless >> +<< os macosx? [ "openal" deploy-library ] unless >> LIBRARY: openal @@ -254,71 +246,6 @@ FUNCTION: void alcCaptureSamples ( ALCdevice* device, void* buf, ALCsizei samps DESTRUCTOR: alcCloseDevice* DESTRUCTOR: alcDestroyContext -LIBRARY: alut - -CONSTANT: ALUT_API_MAJOR_VERSION 1 -CONSTANT: ALUT_API_MINOR_VERSION 1 -CONSTANT: ALUT_ERROR_NO_ERROR 0 -CONSTANT: ALUT_ERROR_OUT_OF_MEMORY HEX: 200 -CONSTANT: ALUT_ERROR_INVALID_ENUM HEX: 201 -CONSTANT: ALUT_ERROR_INVALID_VALUE HEX: 202 -CONSTANT: ALUT_ERROR_INVALID_OPERATION HEX: 203 -CONSTANT: ALUT_ERROR_NO_CURRENT_CONTEXT HEX: 204 -CONSTANT: ALUT_ERROR_AL_ERROR_ON_ENTRY HEX: 205 -CONSTANT: ALUT_ERROR_ALC_ERROR_ON_ENTRY HEX: 206 -CONSTANT: ALUT_ERROR_OPEN_DEVICE HEX: 207 -CONSTANT: ALUT_ERROR_CLOSE_DEVICE HEX: 208 -CONSTANT: ALUT_ERROR_CREATE_CONTEXT HEX: 209 -CONSTANT: ALUT_ERROR_MAKE_CONTEXT_CURRENT HEX: 20A -CONSTANT: ALUT_ERROR_DESTRY_CONTEXT HEX: 20B -CONSTANT: ALUT_ERROR_GEN_BUFFERS HEX: 20C -CONSTANT: ALUT_ERROR_BUFFER_DATA HEX: 20D -CONSTANT: ALUT_ERROR_IO_ERROR HEX: 20E -CONSTANT: ALUT_ERROR_UNSUPPORTED_FILE_TYPE HEX: 20F -CONSTANT: ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE HEX: 210 -CONSTANT: ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA HEX: 211 -CONSTANT: ALUT_WAVEFORM_SINE HEX: 100 -CONSTANT: ALUT_WAVEFORM_SQUARE HEX: 101 -CONSTANT: ALUT_WAVEFORM_SAWTOOTH HEX: 102 -CONSTANT: ALUT_WAVEFORM_WHITENOISE HEX: 103 -CONSTANT: ALUT_WAVEFORM_IMPULSE HEX: 104 -CONSTANT: ALUT_LOADER_BUFFER HEX: 300 -CONSTANT: ALUT_LOADER_MEMORY HEX: 301 - -FUNCTION: ALboolean alutInit ( int* argcp, char** argv ) ; -FUNCTION: ALboolean alutInitWithoutContext ( int* argcp, char** argv ) ; -FUNCTION: ALboolean alutExit ( ) ; -FUNCTION: ALenum alutGetError ( ) ; -FUNCTION: char* alutGetErrorString ( ALenum error ) ; -FUNCTION: ALuint alutCreateBufferFromFile ( char* fileName ) ; -FUNCTION: ALuint alutCreateBufferFromFileImage ( void* data, ALsizei length ) ; -FUNCTION: ALuint alutCreateBufferHelloWorld ( ) ; -FUNCTION: ALuint alutCreateBufferWaveform ( ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration ) ; -FUNCTION: void* alutLoadMemoryFromFile ( char* fileName, ALenum* format, ALsizei* size, ALfloat* frequency ) ; -FUNCTION: void* alutLoadMemoryFromFileImage ( void* data, ALsizei length, ALenum* format, ALsizei* size, ALfloat* frequency ) ; -FUNCTION: void* alutLoadMemoryHelloWorld ( ALenum* format, ALsizei* size, ALfloat* frequency ) ; -FUNCTION: void* alutLoadMemoryWaveform ( ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration, ALenum* format, ALsizei* size, ALfloat* freq ) ; -FUNCTION: char* alutGetMIMETypes ( ALenum loader ) ; -FUNCTION: ALint alutGetMajorVersion ( ) ; -FUNCTION: ALint alutGetMinorVersion ( ) ; -FUNCTION: ALboolean alutSleep ( ALfloat duration ) ; - -FUNCTION: void alutUnloadWAV ( ALenum format, void* data, ALsizei size, ALsizei frequency ) ; - -SYMBOL: init - -: init-openal ( -- ) - init get-global expired? [ - f f alutInit 0 = [ "Could not initialize OpenAL" throw ] when - 1337 init set-global - ] when ; - -: exit-openal ( -- ) - init get-global expired? [ - alutExit 0 = [ "Could not close OpenAL" throw ] when - f init set-global - ] unless ; - : gen-sources ( size -- seq ) dup [ alGenSources ] keep ; @@ -327,17 +254,6 @@ SYMBOL: init : gen-buffer ( -- buffer ) 1 gen-buffers first ; -: create-buffer-from-file ( filename -- buffer ) - alutCreateBufferFromFile dup AL_NONE = [ - "create-buffer-from-file failed" throw - ] when ; - -os macosx? "openal.macosx" "openal.other" ? require - -: create-buffer-from-wav ( filename -- buffer ) - gen-buffer dup rot load-wav-file - [ alBufferData ] 4 nkeep alutUnloadWAV ; - : queue-buffers ( source buffers -- ) [ length ] [ >uint-array ] bi alSourceQueueBuffers ; @@ -360,12 +276,5 @@ os macosx? "openal.macosx" "openal.other" ? require : source-stop ( source -- ) alSourceStop ; -: check-error ( -- ) - alGetError dup ALUT_ERROR_NO_ERROR = [ - drop - ] [ - alGetString throw - ] if ; - : source-playing? ( source -- bool ) AL_SOURCE_STATE get-source-param AL_PLAYING = ; diff --git a/extra/space-invaders/space-invaders.factor b/extra/space-invaders/space-invaders.factor old mode 100644 new mode 100755 index 17e277fb6a..01bf621769 --- a/extra/space-invaders/space-invaders.factor +++ b/extra/space-invaders/space-invaders.factor @@ -18,6 +18,7 @@ USING: math math.order openal + openal.alut opengl.gl sequences ui diff --git a/extra/synth/example/example.factor b/extra/synth/example/example.factor old mode 100644 new mode 100755 index 747cfb9c86..e09d903afb --- a/extra/synth/example/example.factor +++ b/extra/synth/example/example.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Alex Chapman ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays kernel namespaces make openal sequences +USING: accessors arrays kernel namespaces make openal openal.alut sequences synth synth.buffers ; IN: synth.example diff --git a/extra/synth/synth.factor b/extra/synth/synth.factor old mode 100644 new mode 100755 index def610d356..90645e3562 --- a/extra/synth/synth.factor +++ b/extra/synth/synth.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Alex Chapman ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel locals math math.constants math.functions memoize openal synth.buffers sequences sequences.modified sequences.repeating ; +USING: accessors kernel locals math math.constants math.functions memoize openal openal.alut synth.buffers sequences sequences.modified sequences.repeating ; IN: synth MEMO: single-sine-wave ( samples/wave -- seq ) From 7b22818192aec8638039f42a89e64f976eab7ac9 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Tue, 16 Feb 2010 22:37:31 -0800 Subject: [PATCH 062/713] Remove game.input dependency from chipmunk.demo so it works on linux --- extra/chipmunk/demo/demo.factor | 42 +++++++++++++++------------------ 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/extra/chipmunk/demo/demo.factor b/extra/chipmunk/demo/demo.factor index 031ed576b6..06f3c32dbe 100644 --- a/extra/chipmunk/demo/demo.factor +++ b/extra/chipmunk/demo/demo.factor @@ -1,9 +1,8 @@ ! Copyright (C) 2010 Erik Charlebois ! See http:// factorcode.org/license.txt for BSD license. -USING: accessors chipmunk classes.struct game.loop game.worlds gpu -gpu.util.wasd kernel literals locals math method-chains opengl.gl -random sequences specialized-arrays -specialized-arrays.instances.alien.c-types.void* ui.gadgets.worlds +USING: accessors chipmunk classes.struct game.worlds kernel locals +math method-chains opengl.gl random sequences specialized-arrays +specialized-arrays.instances.alien.c-types.void* ui ui.gadgets.worlds ui.pixel-formats ; IN: chipmunk.demo @@ -56,7 +55,7 @@ CONSTANT: image-bitmap B{ cpCircleShapeAlloc body 0.95 0 0 cpv cpCircleShapeInit cpCircleShape memory>struct [ shape>> 0 >>e ] [ shape>> 0 >>u ] bi drop ; -TUPLE: chipmunk-world < wasd-world +TUPLE: chipmunk-world < game-world space ; AFTER: chipmunk-world tick-game-world @@ -97,8 +96,6 @@ M:: chipmunk-world draw-world* ( world -- ) M:: chipmunk-world begin-game-world ( world -- ) cpInitChipmunk - init-gpu - world { -0.2 0.13 0.1 } 1.1 0.2 set-wasd-view drop cpSpaceAlloc cpSpaceInit cpSpace memory>struct :> space @@ -132,20 +129,19 @@ M: chipmunk-world end-game-world [ cpSpaceFreeChildren ] [ cpSpaceFree ] bi ; -M: chipmunk-world wasd-movement-speed drop 1/160. ; -M: chipmunk-world wasd-near-plane drop 1/32. ; -M: chipmunk-world wasd-far-plane drop 256.0 ; +: chipmunk-demo ( -- ) + [ + f + T{ game-attributes + { world-class chipmunk-world } + { title "Chipmunk Physics Demo" } + { pixel-format-attributes + { windowed double-buffered } + } + { pref-dim { 640 480 } } + { tick-interval-micros 16666 } + } + clone + open-window + ] with-ui ; -GAME: chipmunk-demo { - { world-class chipmunk-world } - { title "Chipmunk Physics Demo" } - { pixel-format-attributes { - windowed - double-buffered - T{ depth-bits { value 24 } } - } } - { grab-input? t } - { use-game-input? t } - { pref-dim { 640 480 } } - { tick-interval-micros $[ 60 fps ] } - } ; From da7cd4186ab0a9e70709fdaa5514d5c4d647b24a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 01:18:48 +1300 Subject: [PATCH 063/713] help.markup: make $example render slightly nicer --- basis/help/markup/markup.factor | 4 ++-- basis/help/stylesheet/stylesheet.factor | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/basis/help/markup/markup.factor b/basis/help/markup/markup.factor index 75e6538243..f951f30b2f 100644 --- a/basis/help/markup/markup.factor +++ b/basis/help/markup/markup.factor @@ -129,8 +129,8 @@ ALIAS: $slot $snippet "Examples" $heading print-element ; : $example ( element -- ) - 1 cut* swap "\n" join dup [ - input-style get format nl print-element + 1 cut* [ "\n" join ] bi@ over [ + [ print ] [ output-style get format ] bi* ] ($code) ; : $unchecked-example ( element -- ) diff --git a/basis/help/stylesheet/stylesheet.factor b/basis/help/stylesheet/stylesheet.factor index 8a119823cc..d5b783fef8 100644 --- a/basis/help/stylesheet/stylesheet.factor +++ b/basis/help/stylesheet/stylesheet.factor @@ -80,8 +80,11 @@ H{ { wrap-margin f } } code-style set-global -SYMBOL: input-style -H{ { font-style bold } } input-style set-global +SYMBOL: output-style +H{ + { font-style bold } + { foreground COLOR: dark-red } +} output-style set-global SYMBOL: url-style H{ From 36cff8ed6e8ff8900ac2bf99d70db97033ea55f0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 01:19:26 +1300 Subject: [PATCH 064/713] combinators: better wrong-values error --- core/combinators/combinators.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/combinators/combinators.factor b/core/combinators/combinators.factor index 95b62fc3f3..9016d540d7 100644 --- a/core/combinators/combinators.factor +++ b/core/combinators/combinators.factor @@ -17,7 +17,7 @@ M: object throw PRIVATE> -ERROR: wrong-values quot effect ; +ERROR: wrong-values quot call-site ; ! We can't USE: effects here so we forward reference slots instead SLOT: in From 63928191e719c041624300c37e9e855c550a2b46 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 01:19:39 +1300 Subject: [PATCH 065/713] Minor documentation fixes --- basis/listener/listener-docs.factor | 28 ++++++++++++++++++++-------- core/generic/generic-docs.factor | 8 +++++++- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/basis/listener/listener-docs.factor b/basis/listener/listener-docs.factor index 77bec12c1a..a35f43e848 100644 --- a/basis/listener/listener-docs.factor +++ b/basis/listener/listener-docs.factor @@ -1,8 +1,8 @@ -USING: help.markup help.syntax kernel io system prettyprint continuations quotations ; +USING: help.markup help.syntax kernel io system prettyprint continuations quotations vocabs.loader vocabs.refresh parser ; IN: listener ARTICLE: "listener-watch" "Watching variables in the listener" -"The listener prints the concepts of the data and retain stacks after every expression. It can also print values of dynamic variables which are added to a watch list:" +"The listener prints values of dynamic variables which are added to a watch list:" { $subsections visible-vars } "To add or remove a single variable:" { $subsections @@ -14,7 +14,7 @@ ARTICLE: "listener-watch" "Watching variables in the listener" show-vars hide-vars } -"Hiding all visible variables:" +"Clearing the watch list:" { $subsections hide-all-vars } ; HELP: only-use-vocabs @@ -46,21 +46,33 @@ HELP: hide-all-vars { $description "Removes all variables from the watch list." } ; ARTICLE: "listener" "The listener" -"The listener evaluates Factor expressions read from a stream. The listener is the primary interface to the Factor runtime. Typically, you write Factor code in a text editor, then load it using the listener and test it." +"The listener evaluates Factor expressions read from the input stream. Typically, you write Factor code in a text editor, load it from the listener by calling " { $link require } ", " { $link refresh-all } " or " { $link run-file } ", and then test it from interactively." $nl "The classical first program can be run in the listener:" { $example "\"Hello, world\" print" "Hello, world" } +"New words can also be defined in the listener:" +{ $example + "USE: math.functions" + ": twice ( word -- ) [ execute ] [ execute ] bi ; inline" + "81 \\ sqrt twice ." + "3" +} "Multi-line expressions are supported:" { $example "{ 1 2 3 } [\n .\n] each" "1\n2\n3" } -"The listener knows when to expect more input by looking at the height of the stack. Parsing words such as " { $link POSTPONE: { } " leave elements on the parser stack, and corresponding words such as " { $link POSTPONE: } } " pop them." +"The listener will display the current contents of the datastack after every line of input." $nl -"The listener will display the current contents of the datastack after every expression is evaluated. The listener can additionally watch dynamic variables:" +"The listener can watch dynamic variables:" { $subsections "listener-watch" } -"To start a nested listener:" +"Nested listeners can be useful for testing code in other dynamic scopes. For example, when doing database maintanance using the " { $vocab-link "db.tuples" } " vocabulary, it can be useful to start a listener with a database connection:" +{ $code + "USING: db db.sqlite listener ;" + "\"data.db\" [ listener ] with-db" +} +"Starting a nested listener:" { $subsections listener } "To exit a listener, invoke the " { $link return } " word." $nl -"Multi-line quotations can be read independently of the rest of the listener:" +"The listener's mechanism for reading multi-line expressions from the input stream can be called from user code:" { $subsections read-quot } ; ABOUT: "listener" diff --git a/core/generic/generic-docs.factor b/core/generic/generic-docs.factor index 3a9314fb56..8d4f1f61a5 100644 --- a/core/generic/generic-docs.factor +++ b/core/generic/generic-docs.factor @@ -166,7 +166,13 @@ HELP: create-method HELP: (call-next-method) { $values { "method" method } } { $description "Low-level word implementing " { $link POSTPONE: call-next-method } "." } -{ $notes "In most cases, " { $link POSTPONE: call-next-method } " should be used instead." } ; +{ $notes + "The " { $link POSTPONE: call-next-method } " word parses into this word. The following are equivalent:" + { $code + "M: class generic call-next-method ;" + "M: class generic M\\ class generic (call-next-method) ;" + } +} ; HELP: no-next-method { $error-description "Thrown by " { $link POSTPONE: call-next-method } " if the current method is already the least specific method." } From 41433da61bb490011d62acff99cdc34711cf44c5 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 01:57:22 +1300 Subject: [PATCH 066/713] core: minor cleanups --- core/arrays/arrays.factor | 14 +++----------- core/combinators/combinators.factor | 4 ++++ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/core/arrays/arrays.factor b/core/arrays/arrays.factor index fa4d4b2f69..62a0774444 100644 --- a/core/arrays/arrays.factor +++ b/core/arrays/arrays.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2005, 2008 Slava Pestov. +! Copyright (C) 2005, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel kernel.private math math.private sequences sequences.private ; @@ -9,24 +9,16 @@ M: array length length>> ; inline M: array nth-unsafe [ >fixnum ] dip array-nth ; inline M: array set-nth-unsafe [ >fixnum ] dip set-array-nth ; inline M: array resize resize-array ; inline - -: >array ( seq -- array ) { } clone-like ; - +M: array equal? over array? [ sequence= ] [ 2drop f ] if ; M: object new-sequence drop 0 ; inline - M: f new-sequence drop [ f ] [ 0 ] if-zero ; inline -M: array equal? - over array? [ sequence= ] [ 2drop f ] if ; - INSTANCE: array sequence +: >array ( seq -- array ) { } clone-like ; : 1array ( x -- array ) 1 swap ; inline - : 2array ( x y -- array ) { } 2sequence ; inline - : 3array ( x y z -- array ) { } 3sequence ; inline - : 4array ( w x y z -- array ) { } 4sequence ; inline PREDICATE: pair < array length 2 number= ; diff --git a/core/combinators/combinators.factor b/core/combinators/combinators.factor index 9016d540d7..7b9481825b 100644 --- a/core/combinators/combinators.factor +++ b/core/combinators/combinators.factor @@ -5,6 +5,10 @@ kernel kernel.private math assocs quotations vectors hashtables sorting words sets math.order make ; IN: combinators +! Most of these combinators have compile-time expansions in +! the optimizing compiler. See stack-checker.transforms and +! compiler.tree.propagation.call-effect + Date: Thu, 18 Feb 2010 02:19:57 +1300 Subject: [PATCH 067/713] Add support for final tuple classes which cannot be subclassed: TUPLE: foo ... ; final --- basis/classes/struct/struct-tests.factor | 25 +++++++++++++++++----- basis/classes/struct/struct.factor | 4 +--- basis/debugger/debugger.factor | 2 +- basis/functors/functors.factor | 3 +++ basis/typed/typed-tests.factor | 8 +++++++ core/bootstrap/syntax.factor | 1 + core/classes/parser/parser.factor | 3 ++- core/classes/tuple/tuple-tests.factor | 27 ++++++++++++++++++++++++ core/classes/tuple/tuple.factor | 12 +++++++++-- core/syntax/syntax.factor | 4 ++++ 10 files changed, 77 insertions(+), 12 deletions(-) diff --git a/basis/classes/struct/struct-tests.factor b/basis/classes/struct/struct-tests.factor index 2c0db93522..cb7e4ee2b0 100644 --- a/basis/classes/struct/struct-tests.factor +++ b/basis/classes/struct/struct-tests.factor @@ -1,11 +1,11 @@ ! (c)Joe Groff bsd license USING: accessors alien alien.c-types alien.data ascii -assocs byte-arrays classes.struct classes.tuple.private +assocs byte-arrays classes.struct classes.tuple.private classes.tuple combinators compiler.tree.debugger compiler.units destructors io.encodings.utf8 io.pathnames io.streams.string kernel libc literals math mirrors namespaces prettyprint prettyprint.config see sequences specialized-arrays system -tools.test parser lexer eval layouts ; +tools.test parser lexer eval layouts generic.single classes ; FROM: math => float ; QUALIFIED-WITH: alien.c-types c SPECIALIZED-ARRAY: char @@ -338,13 +338,28 @@ STRUCT: struct-that's-a-word { x int } ; [ "USE: classes.struct IN: classes.struct.tests TUPLE: not-a-struct ; S{ not-a-struct }" eval( -- value ) -] must-fail +] [ error>> no-method? ] must-fail-with ! Subclassing a struct class should not be allowed [ - "USE: classes.struct IN: classes.struct.tests STRUCT: a-struct { x int } ; TUPLE: not-a-struct < a-struct ;" + "USING: alien.c-types classes.struct ; IN: classes.struct.tests STRUCT: a-struct { x int } ; TUPLE: not-a-struct < a-struct ;" eval( -- ) -] must-fail +] [ error>> bad-superclass? ] must-fail-with + +! Changing a superclass into a struct should reset the subclass +TUPLE: will-become-struct ; + +TUPLE: a-subclass < will-become-struct ; + +[ f ] [ will-become-struct struct-class? ] unit-test + +[ will-become-struct ] [ a-subclass superclass ] unit-test + +[ ] [ "IN: classes.struct.tests USING: classes.struct alien.c-types ; STRUCT: will-become-struct { x int } ;" eval( -- ) ] unit-test + +[ t ] [ will-become-struct struct-class? ] unit-test + +[ tuple ] [ a-subclass superclass ] unit-test ! Remove c-type when struct class is forgotten [ ] [ diff --git a/basis/classes/struct/struct.factor b/basis/classes/struct/struct.factor index fae39cd229..a5711de609 100644 --- a/basis/classes/struct/struct.factor +++ b/basis/classes/struct/struct.factor @@ -32,8 +32,6 @@ TUPLE: struct-bit-slot-spec < struct-slot-spec PREDICATE: struct-class < tuple-class superclass \ struct eq? ; -M: struct-class valid-superclass? drop f ; - SLOT: fields : struct-slots ( struct-class -- slots ) @@ -273,7 +271,7 @@ M: struct binary-zero? >c-ptr [ 0 = ] all? ; [ type>> c-type drop ] each ; : redefine-struct-tuple-class ( class -- ) - [ dup class? [ forget-class ] [ drop ] if ] [ struct f define-tuple-class ] bi ; + [ struct f define-tuple-class ] [ make-final ] bi ; :: (define-struct-class) ( class slots offsets-quot -- ) slots empty? [ struct-must-have-slots ] when diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index 815304b21f..b6497c52a9 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -194,7 +194,7 @@ M: not-a-tuple summary drop "Not a tuple" ; M: bad-superclass summary - drop "Tuple classes can only inherit from other tuple classes" ; + drop "Tuple classes can only inherit from non-final tuple classes" ; M: no-initial-value summary drop "Initial value must be provided for slots specialized to this class" ; diff --git a/basis/functors/functors.factor b/basis/functors/functors.factor index ac2e52f68e..6678613002 100644 --- a/basis/functors/functors.factor +++ b/basis/functors/functors.factor @@ -63,6 +63,9 @@ FUNCTOR-SYNTAX: TUPLE: } case \ define-tuple-class suffix! ; +FUNCTOR-SYNTAX: final + [ word make-final ] append! ; + FUNCTOR-SYNTAX: SINGLETON: scan-param suffix! \ define-singleton-class suffix! ; diff --git a/basis/typed/typed-tests.factor b/basis/typed/typed-tests.factor index f7b853cff7..f1e151b985 100644 --- a/basis/typed/typed-tests.factor +++ b/basis/typed/typed-tests.factor @@ -97,3 +97,11 @@ TYPED: no-outputs-unboxable-input ( x: unboxable3 -- ) buh set ; [ T{ unboxable3 } ] [ T{ unboxable3 } no-outputs-unboxable-input buh get ] unit-test + +! Reported by littledan +TUPLE: superclass x ; +TUPLE: subclass < superclass y ; + +TYPED: unbox-fail ( superclass: a -- ? ) subclass? ; + +[ t ] [ subclass new unbox-fail ] unit-test diff --git a/core/bootstrap/syntax.factor b/core/bootstrap/syntax.factor index bb159f04df..1870f4ac1b 100644 --- a/core/bootstrap/syntax.factor +++ b/core/bootstrap/syntax.factor @@ -49,6 +49,7 @@ IN: bootstrap.syntax "SYMBOLS:" "CONSTANT:" "TUPLE:" + "final" "SLOT:" "T{" "UNION:" diff --git a/core/classes/parser/parser.factor b/core/classes/parser/parser.factor index 8233d8cff3..41ce32105d 100644 --- a/core/classes/parser/parser.factor +++ b/core/classes/parser/parser.factor @@ -8,8 +8,9 @@ IN: classes.parser : create-class-in ( string -- word ) current-vocab create + dup set-word dup save-class-location - dup create-predicate-word dup set-word save-location ; + dup create-predicate-word save-location ; : CREATE-CLASS ( -- word ) scan create-class-in ; diff --git a/core/classes/tuple/tuple-tests.factor b/core/classes/tuple/tuple-tests.factor index 36d402c61d..6711c5705e 100644 --- a/core/classes/tuple/tuple-tests.factor +++ b/core/classes/tuple/tuple-tests.factor @@ -770,3 +770,30 @@ TUPLE: tuple-predicate-redefine-test ; [ ] [ "IN: classes.tuple.tests TUPLE: tuple-predicate-redefine-test ;" eval( -- ) ] unit-test [ t ] [ \ tuple-predicate-redefine-test? predicate? ] unit-test + +! Final classes +TUPLE: final-superclass ; +TUPLE: final-subclass < final-superclass ; + +[ final-superclass ] [ final-subclass superclass ] unit-test + +! Making the superclass final should change the superclass of the subclass +[ ] [ "IN: classes.tuple.tests TUPLE: final-superclass ; final" eval( -- ) ] unit-test + +[ tuple ] [ final-subclass superclass ] unit-test + +[ t ] [ \ final-subclass valid-superclass? ] unit-test + +! Subclassing a final class should fail +[ "IN: classes.tuple.tests TUPLE: final-subclass < final-superclass ;" eval( -- ) ] +[ error>> bad-superclass? ] must-fail-with + +! Making a final class non-final should work +[ ] [ "IN: classes.tuple.tests TUPLE: final-superclass ;" eval( -- ) ] unit-test + +[ ] [ "IN: classes.tuple.tests TUPLE: final-subclass < final-superclass ; final" eval( -- ) ] unit-test + +! Changing a superclass should not change the final status of a subclass +[ ] [ "IN: classes.tuple.tests TUPLE: final-superclass x ;" eval( -- ) ] unit-test + +[ f ] [ \ final-subclass valid-superclass? ] unit-test diff --git a/core/classes/tuple/tuple.factor b/core/classes/tuple/tuple.factor index 363c2879e9..c7a3afdd6d 100644 --- a/core/classes/tuple/tuple.factor +++ b/core/classes/tuple/tuple.factor @@ -240,7 +240,7 @@ M: tuple-class update-class GENERIC: valid-superclass? ( class -- ? ) -M: tuple-class valid-superclass? drop t ; +M: tuple-class valid-superclass? "final" word-prop not ; M: builtin-class valid-superclass? tuple eq? ; @@ -266,8 +266,16 @@ PRIVATE> : define-tuple-class ( class superclass slots -- ) over check-superclass over prepare-slots + pick f "final" set-word-prop (define-tuple-class) ; +GENERIC: make-final ( class -- ) + +M: tuple-class make-final + [ dup class-usage keys ?metaclass-changed ] + [ t "final" set-word-prop ] + bi ; + M: word (define-tuple-class) define-new-tuple-class ; @@ -301,7 +309,7 @@ M: tuple-class reset-class ] with each ] [ [ call-next-method ] - [ { "layout" "slots" "boa-check" "prototype" } reset-props ] + [ { "layout" "slots" "boa-check" "prototype" "final" } reset-props ] bi ] bi ; diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index cf2c49fff9..0b5b32e289 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -204,6 +204,10 @@ IN: bootstrap.syntax parse-tuple-definition define-tuple-class ] define-core-syntax + "final" [ + word make-final + ] define-core-syntax + "SLOT:" [ scan define-protocol-slot ] define-core-syntax From 60296be9641543c403098cf7f1b2cd5d9dbaa84a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 02:39:12 +1300 Subject: [PATCH 068/713] typed: only unbox final classes. Fixes bug reported by littledan --- .../dependencies/dependencies.factor | 12 +++++- basis/typed/typed-tests.factor | 37 ++++++++++++++----- basis/typed/typed.factor | 12 ++++-- core/classes/tuple/tuple.factor | 27 +++++++++----- 4 files changed, 64 insertions(+), 24 deletions(-) diff --git a/basis/stack-checker/dependencies/dependencies.factor b/basis/stack-checker/dependencies/dependencies.factor index d995354a52..df68fa8961 100644 --- a/basis/stack-checker/dependencies/dependencies.factor +++ b/basis/stack-checker/dependencies/dependencies.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2009, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: assocs accessors classes.algebra fry generic kernel math -namespaces sequences words sets combinators.short-circuit ; +namespaces sequences words sets combinators.short-circuit +classes.tuple ; FROM: classes.tuple.private => tuple-layout ; IN: stack-checker.dependencies @@ -122,6 +123,15 @@ TUPLE: depends-on-flushable word ; M: depends-on-flushable satisfied? word>> flushable? ; +TUPLE: depends-on-final class ; + +: depends-on-final ( word -- ) + [ depends-on-conditionally ] + [ \ depends-on-final add-conditional-dependency ] bi ; + +M: depends-on-final satisfied? + class>> final-class? ; + : init-dependencies ( -- ) H{ } clone dependencies set H{ } clone generic-dependencies set diff --git a/basis/typed/typed-tests.factor b/basis/typed/typed-tests.factor index f1e151b985..7f984ccaf2 100644 --- a/basis/typed/typed-tests.factor +++ b/basis/typed/typed-tests.factor @@ -14,8 +14,8 @@ TYPED: fix+ ( a: fixnum b: fixnum -- c: fixnum ) most-positive-fixnum neg 1 - 1quotation [ most-positive-fixnum 1 fix+ ] unit-test -TUPLE: tweedle-dee ; -TUPLE: tweedle-dum ; +TUPLE: tweedle-dee ; final +TUPLE: tweedle-dum ; final TYPED: dee ( x: tweedle-dee -- y ) drop \ tweedle-dee ; @@ -39,11 +39,11 @@ TYPED:: f+locals ( a: float b: float -- c: float ) TUPLE: unboxable { x fixnum read-only } - { y fixnum read-only } ; + { y fixnum read-only } ; final TUPLE: unboxable2 { u unboxable read-only } - { xy fixnum read-only } ; + { xy fixnum read-only } ; final TYPED: unboxy ( in: unboxable -- out: unboxable2 ) dup [ x>> ] [ y>> ] bi - unboxable2 boa ; @@ -63,7 +63,7 @@ IN: typed.tests TUPLE: unboxable { x fixnum read-only } { y fixnum read-only } - { z float read-only } ; + { z float read-only } ; final """ eval( -- ) """ @@ -79,13 +79,15 @@ TYPED: no-inputs ( -- out: integer ) [ 1 ] [ no-inputs ] unit-test TUPLE: unboxable3 - { x read-only } ; + { x read-only } ; final TYPED: no-inputs-unboxable-output ( -- out: unboxable3 ) T{ unboxable3 } ; [ T{ unboxable3 } ] [ no-inputs-unboxable-output ] unit-test +[ f ] [ no-inputs-unboxable-output no-inputs-unboxable-output eq? ] unit-test + SYMBOL: buh TYPED: no-outputs ( x: integer -- ) @@ -98,10 +100,25 @@ TYPED: no-outputs-unboxable-input ( x: unboxable3 -- ) [ T{ unboxable3 } ] [ T{ unboxable3 } no-outputs-unboxable-input buh get ] unit-test -! Reported by littledan -TUPLE: superclass x ; -TUPLE: subclass < superclass y ; +[ f ] [ + T{ unboxable3 } no-outputs-unboxable-input buh get + T{ unboxable3 } no-outputs-unboxable-input buh get + eq? +] unit-test -TYPED: unbox-fail ( superclass: a -- ? ) subclass? ; +! Reported by littledan +TUPLE: superclass { x read-only } ; +TUPLE: subclass < superclass { y read-only } ; final + +TYPED: unbox-fail ( a: superclass -- ? ) subclass? ; [ t ] [ subclass new unbox-fail ] unit-test + +! If a final class becomes non-final, typed words need to be recompiled +TYPED: recompile-fail ( a: subclass -- ? ) buh get eq? ; + +[ f ] [ subclass new [ buh set ] [ recompile-fail ] bi ] unit-test + +[ ] [ "IN: typed.tests TUPLE: subclass < superclass { y read-only } ;" eval( -- ) ] unit-test + +[ t ] [ subclass new [ buh set ] [ recompile-fail ] bi ] unit-test diff --git a/basis/typed/typed.factor b/basis/typed/typed.factor index e71196e3ee..8a85ca1afb 100644 --- a/basis/typed/typed.factor +++ b/basis/typed/typed.factor @@ -20,6 +20,7 @@ PREDICATE: typed-word < word "typed-word" word-prop ; { [ all-slots empty? not ] [ immutable-tuple-class? ] + [ final-class? ] } 1&& ; ! typed inputs @@ -30,9 +31,14 @@ PREDICATE: typed-word < word "typed-word" word-prop ; : input-mismatch-quot ( word types -- quot ) [ input-mismatch-error ] 2curry ; +: depends-on-unboxing ( class -- ) + [ dup tuple-layout depends-on-tuple-layout ] + [ depends-on-final ] + bi ; + : (unboxer) ( type -- quot ) dup unboxable-tuple-class? [ - dup dup tuple-layout depends-on-tuple-layout + dup depends-on-unboxing all-slots [ [ name>> reader-word 1quotation ] [ class>> (unboxer) ] bi compose @@ -52,7 +58,7 @@ PREDICATE: typed-word < word "typed-word" word-prop ; : (unboxed-types) ( type -- types ) dup unboxable-tuple-class? [ - dup dup tuple-layout depends-on-tuple-layout + dup depends-on-unboxing all-slots [ class>> (unboxed-types) ] map concat ] [ 1array ] if ; @@ -81,7 +87,7 @@ DEFER: make-boxer : boxer ( type -- quot ) dup unboxable-tuple-class? [ - dup dup tuple-layout depends-on-tuple-layout + dup depends-on-unboxing [ all-slots [ class>> ] map make-boxer ] [ [ boa ] curry ] bi compose diff --git a/core/classes/tuple/tuple.factor b/core/classes/tuple/tuple.factor index c7a3afdd6d..b590826511 100644 --- a/core/classes/tuple/tuple.factor +++ b/core/classes/tuple/tuple.factor @@ -93,6 +93,14 @@ ERROR: bad-superclass class ; ] [ 2drop f ] if ] [ 2drop f ] if ; inline +GENERIC: final-class? ( class -- ? ) + +M: tuple-class final-class? "final" word-prop ; + +M: builtin-class final-class? tuple eq? not ; + +M: class final-class? drop t ; + : define-tuple-class ( class superclass slots -- ) over check-superclass over prepare-slots - pick f "final" set-word-prop + pick reset-final (define-tuple-class) ; GENERIC: make-final ( class -- ) From ff172f4132b3938e3aa83df3d5da0b973fd9e096 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 02:39:40 +1300 Subject: [PATCH 069/713] Make specialized arrays and SIMD types final so that typed can unbox them --- basis/math/vectors/simd/simd.factor | 2 +- basis/sequences/cords/cords.factor | 6 +++--- basis/specialized-arrays/specialized-arrays.factor | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/basis/math/vectors/simd/simd.factor b/basis/math/vectors/simd/simd.factor index acf13599c1..a60026317d 100644 --- a/basis/math/vectors/simd/simd.factor +++ b/basis/math/vectors/simd/simd.factor @@ -251,7 +251,7 @@ BOA-EFFECT [ N "n" { "v" } ] WHERE -TUPLE: A < simd-128 ; +TUPLE: A < simd-128 ; final M: A new-underlying drop \ A boa ; inline M: A simd-rep drop A-rep ; inline diff --git a/basis/sequences/cords/cords.factor b/basis/sequences/cords/cords.factor index fca005fa6e..4a2d267a12 100644 --- a/basis/sequences/cords/cords.factor +++ b/basis/sequences/cords/cords.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov, Joe Groff. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs sequences sorting binary-search fry math math.order arrays classes combinators kernel functors math.functions @@ -8,7 +8,7 @@ IN: sequences.cords MIXIN: cord TUPLE: generic-cord - { head read-only } { tail read-only } ; + { head read-only } { tail read-only } ; final INSTANCE: generic-cord cord M: cord length @@ -34,7 +34,7 @@ T-cord DEFINES-CLASS ${C} WHERE TUPLE: T-cord - { head T read-only } { tail T read-only } ; + { head T read-only } { tail T read-only } ; final INSTANCE: T-cord cord M: T cord-append diff --git a/basis/specialized-arrays/specialized-arrays.factor b/basis/specialized-arrays/specialized-arrays.factor index eda793ff22..d3db93e788 100644 --- a/basis/specialized-arrays/specialized-arrays.factor +++ b/basis/specialized-arrays/specialized-arrays.factor @@ -47,7 +47,7 @@ WHERE TUPLE: A { underlying c-ptr read-only } -{ length array-capacity read-only } ; +{ length array-capacity read-only } ; final : ( alien len -- specialized-array ) A boa ; inline From c4c14c7cebeac1adc48d00ead76fad8bcac299b9 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 03:00:43 +1300 Subject: [PATCH 070/713] classes.tuple: fix screwup --- core/classes/tuple/tuple.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/classes/tuple/tuple.factor b/core/classes/tuple/tuple.factor index b590826511..64c34d221a 100644 --- a/core/classes/tuple/tuple.factor +++ b/core/classes/tuple/tuple.factor @@ -273,7 +273,6 @@ PRIVATE> : define-tuple-class ( class superclass slots -- ) over check-superclass over prepare-slots - pick reset-final (define-tuple-class) ; GENERIC: make-final ( class -- ) @@ -287,6 +286,7 @@ M: word (define-tuple-class) define-new-tuple-class ; M: tuple-class (define-tuple-class) + pick reset-final 3dup tuple-class-unchanged? [ 2drop ?define-symbol ] [ redefine-tuple-class ] if ; From 9df8a3adbd5362ec6d8674a29440f984a5c48537 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 03:01:26 +1300 Subject: [PATCH 071/713] see: show final declaration on tuples --- basis/prettyprint/prettyprint-tests.factor | 12 ++++++++++++ basis/see/see.factor | 21 ++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/basis/prettyprint/prettyprint-tests.factor b/basis/prettyprint/prettyprint-tests.factor index 8ba6e94a49..ec0e20a393 100644 --- a/basis/prettyprint/prettyprint-tests.factor +++ b/basis/prettyprint/prettyprint-tests.factor @@ -362,3 +362,15 @@ TUPLE: tuple-with-initial-declared-slot { x integer initial: 123 } ; ] [ [ \ tuple-with-initial-declared-slot see ] with-string-writer "\n" split ] unit-test + +TUPLE: final-tuple ; final + +[ + { + "IN: prettyprint.tests" + "TUPLE: final-tuple ; final" + "" + } +] [ + [ \ final-tuple see ] with-string-writer "\n" split +] unit-test diff --git a/basis/see/see.factor b/basis/see/see.factor index 0d2388114a..326e051219 100644 --- a/basis/see/see.factor +++ b/basis/see/see.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2009 Slava Pestov. +! Copyright (C) 2009, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs classes classes.builtin classes.intersection classes.mixin classes.predicate classes.singleton @@ -182,14 +182,21 @@ M: array pprint-slot-name dup length 1 = [ first ] when pprint-slot-name ; +: tuple-declarations. ( class -- ) + \ final declaration. ; + +: superclass. ( class -- ) + superclass dup tuple eq? [ drop ] [ "<" text pprint-word ] if ; + M: tuple-class see-class* - pprint-; block> ; + { + [ pprint-word ] + [ superclass. ] + [ pprint-; ] + [ tuple-declarations. ] + } cleave + block> ; M: word see-class* drop ; From d2ae4ff4bada2584fbde4a486f5da1712e2d99ae Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 03:36:43 +1300 Subject: [PATCH 072/713] listener: fix docs --- basis/listener/listener-docs.factor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/basis/listener/listener-docs.factor b/basis/listener/listener-docs.factor index a35f43e848..bb20fe62ae 100644 --- a/basis/listener/listener-docs.factor +++ b/basis/listener/listener-docs.factor @@ -1,4 +1,5 @@ -USING: help.markup help.syntax kernel io system prettyprint continuations quotations vocabs.loader vocabs.refresh parser ; +USING: help.markup help.syntax kernel io system prettyprint +continuations quotations vocabs.loader parser ; IN: listener ARTICLE: "listener-watch" "Watching variables in the listener" @@ -46,7 +47,7 @@ HELP: hide-all-vars { $description "Removes all variables from the watch list." } ; ARTICLE: "listener" "The listener" -"The listener evaluates Factor expressions read from the input stream. Typically, you write Factor code in a text editor, load it from the listener by calling " { $link require } ", " { $link refresh-all } " or " { $link run-file } ", and then test it from interactively." +"The listener evaluates Factor expressions read from the input stream. Typically, you write Factor code in a text editor, load it from the listener by calling " { $link require } ", " { $link reload } " or " { $link run-file } ", and then test it from interactively." $nl "The classical first program can be run in the listener:" { $example "\"Hello, world\" print" "Hello, world" } From 4b76e2a61dc933ea39d4431d076bb9f47e94f883 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 03:56:41 +1300 Subject: [PATCH 073/713] functors: make 'final' declarations work in functors --- basis/functors/backend/backend.factor | 10 ++++-- basis/functors/functors-tests.factor | 47 +++++++++++++++++++++++++-- basis/functors/functors.factor | 2 +- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/basis/functors/backend/backend.factor b/basis/functors/backend/backend.factor index dd3d891f7b..331864417e 100644 --- a/basis/functors/backend/backend.factor +++ b/basis/functors/backend/backend.factor @@ -1,6 +1,6 @@ USING: accessors arrays assocs generic.standard kernel lexer locals.types namespaces parser quotations vocabs.parser -words ; +words classes.tuple ; IN: functors.backend DEFER: functor-words @@ -27,7 +27,11 @@ SYNTAX: FUNCTOR-SYNTAX: : define* ( word def -- ) over set-word define ; -: define-declared* ( word def effect -- ) pick set-word define-declared ; +: define-declared* ( word def effect -- ) + pick set-word define-declared ; -: define-simple-generic* ( word effect -- ) over set-word define-simple-generic ; +: define-simple-generic* ( word effect -- ) + over set-word define-simple-generic ; +: define-tuple-class* ( class superclass slots -- ) + pick set-word define-tuple-class ; diff --git a/basis/functors/functors-tests.factor b/basis/functors/functors-tests.factor index 544c2ed1e4..c756d1b83d 100644 --- a/basis/functors/functors-tests.factor +++ b/basis/functors/functors-tests.factor @@ -1,5 +1,5 @@ -USING: classes.struct functors tools.test math words kernel -multiline parser io.streams.string generic ; +USING: classes.struct classes.tuple functors tools.test math +words kernel multiline parser io.streams.string generic ; QUALIFIED-WITH: alien.c-types c IN: functors.tests @@ -36,7 +36,7 @@ WW DEFINES ${W}${W} WHERE -: WW ( a -- b ) \ W twice ; inline +: WW ( a -- b ) \ W twice ; ;FUNCTOR @@ -211,3 +211,44 @@ STRUCT: T-class } ] [ a-struct struct-slots ] unit-test +<< + +FUNCTOR: define-an-inline-word ( W -- ) + +W DEFINES ${W} +W-W DEFINES ${W}-${W} + +WHERE + +: W ( -- ) ; inline +: W-W ( -- ) W W ; + +;FUNCTOR + +"an-inline-word" define-an-inline-word + +>> + +[ t ] [ \ an-inline-word inline? ] unit-test +[ f ] [ \ an-inline-word-an-inline-word inline? ] unit-test + +<< + +FUNCTOR: define-a-final-class ( T W -- ) + +T DEFINES-CLASS ${T} +W DEFINES ${W} + +WHERE + +TUPLE: T ; final + +: W ( -- ) ; + +;FUNCTOR + +"a-final-tuple" "a-word" define-a-final-class + +>> + +[ t ] [ a-final-tuple final-class? ] unit-test diff --git a/basis/functors/functors.factor b/basis/functors/functors.factor index 6678613002..1895c6e0f4 100644 --- a/basis/functors/functors.factor +++ b/basis/functors/functors.factor @@ -61,7 +61,7 @@ FUNCTOR-SYNTAX: TUPLE: make suffix! ] } case - \ define-tuple-class suffix! ; + \ define-tuple-class* suffix! ; FUNCTOR-SYNTAX: final [ word make-final ] append! ; From 049b87bda9b71f5e29d6aa804285e7b31ec9f5bd Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 03:57:02 +1300 Subject: [PATCH 074/713] tuple-arrays: require that base type be final --- basis/tuple-arrays/tuple-arrays-docs.factor | 12 ++++++---- basis/tuple-arrays/tuple-arrays-tests.factor | 22 ++++++++++++++----- basis/tuple-arrays/tuple-arrays.factor | 15 +++++++++++-- .../tuple-arrays/tuple-arrays.factor | 4 ++-- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/basis/tuple-arrays/tuple-arrays-docs.factor b/basis/tuple-arrays/tuple-arrays-docs.factor index 5e70e15aa7..72a5ae4df3 100644 --- a/basis/tuple-arrays/tuple-arrays-docs.factor +++ b/basis/tuple-arrays/tuple-arrays-docs.factor @@ -3,20 +3,24 @@ USING: help.markup help.syntax sequences ; HELP: TUPLE-ARRAY: { $syntax "TUPLE-ARRAY: class" } +{ $values { "class" "a final tuple class" } } { $description "Generates a new data type in the current vocabulary named " { $snippet { $emphasis "class" } "-array" } " for holding instances of " { $snippet "class" } ", which must be a tuple class word. Together with the class itself, this also generates words named " { $snippet "<" { $emphasis "class" } "-array>" } " and " { $snippet ">" { $emphasis "class" } "-array" } ", for creating new instances of this tuple array type." } ; ARTICLE: "tuple-arrays" "Tuple arrays" -"The " { $vocab-link "tuple-arrays" } " vocabulary implements space-efficient unboxed tuple arrays. Whereas an ordinary array of tuples would consist of pointers to heap-allocated objects, a tuple array stores its elements inline. Calling " { $link nth } " copies an element into a new tuple, and calling " { $link set-nth } " copies an existing tuple's slots into an array." +"The " { $vocab-link "tuple-arrays" } " vocabulary implements space-efficient unboxed tuple arrays. Whereas an ordinary array of tuples would consist of references to heap-allocated objects, a tuple array stores its elements as values." $nl -"Since value semantics differ from reference semantics, it is best to use tuple arrays with tuples where all slots are declared " { $link read-only } "." +"Calling " { $link nth } " copies an element into a new tuple, and calling " { $link set-nth } " copies an existing tuple's slots into an array." +$nl +"Since value semantics are incompatible with inheritance, the base type of a tuple array must be declared " { $link POSTPONE: final } ". A best practice that is not enforced is to have all slots in the tuple declared " { $link read-only } "." +$nl +"Tuple arrays do not get updated if tuples are redefined to add or remove slots, so caution should be exercised when doing interactive development on code that uses tuple arrays." $nl -"Tuple arrays should not be used with inheritance; storing an instance of a subclass in a tuple array will slice off the subclass slots, and getting the same value out again will yield an instance of the superclass. Also, tuple arrays do not get updated if tuples are redefined to add or remove slots, so caution should be exercised when doing interactive development on code that uses tuple arrays." { $subsections POSTPONE: TUPLE-ARRAY: } "An example:" { $example "USE: tuple-arrays" "IN: scratchpad" - "TUPLE: point x y ;" + "TUPLE: point x y ; final" "TUPLE-ARRAY: point" "{ T{ point f 1 2 } T{ point f 1 3 } T{ point f 2 3 } } >point-array first short." "T{ point f 1 2 }" diff --git a/basis/tuple-arrays/tuple-arrays-tests.factor b/basis/tuple-arrays/tuple-arrays-tests.factor index 2eeae20aa1..0fbf0eeaa0 100644 --- a/basis/tuple-arrays/tuple-arrays-tests.factor +++ b/basis/tuple-arrays/tuple-arrays-tests.factor @@ -1,9 +1,9 @@ USING: tuple-arrays sequences tools.test namespaces kernel -math accessors ; +math accessors classes.tuple eval ; IN: tuple-arrays.tests SYMBOL: mat -TUPLE: foo bar ; +TUPLE: foo bar ; final C: foo TUPLE-ARRAY: foo @@ -18,15 +18,27 @@ TUPLE-ARRAY: foo [ T{ foo } ] [ mat get first ] unit-test [ T{ foo f 1 } ] [ T{ foo f 1 } 0 mat get [ set-nth ] keep first ] unit-test -TUPLE: baz { bing integer } bong ; +TUPLE: baz { bing integer } bong ; final TUPLE-ARRAY: baz [ 0 ] [ 1 first bing>> ] unit-test [ f ] [ 1 first bong>> ] unit-test -TUPLE: broken x ; +TUPLE: broken x ; final : broken ( -- ) ; TUPLE-ARRAY: broken -[ 100 ] [ 100 length ] unit-test \ No newline at end of file +[ 100 ] [ 100 length ] unit-test + +! Can't define a tuple array for a non-tuple class +[ "IN: tuple-arrays.tests USING: tuple-arrays words ; TUPLE-ARRAY: word" eval( -- ) ] +[ error>> not-a-tuple? ] +must-fail-with + +! Can't define a tuple array for a non-final class +TUPLE: non-final x ; + +[ "IN: tuple-arrays.tests USE: tuple-arrays TUPLE-ARRAY: non-final" eval( -- ) ] +[ error>> not-final? ] +must-fail-with \ No newline at end of file diff --git a/basis/tuple-arrays/tuple-arrays.factor b/basis/tuple-arrays/tuple-arrays.factor index aea51f7820..1a3091c1e2 100644 --- a/basis/tuple-arrays/tuple-arrays.factor +++ b/basis/tuple-arrays/tuple-arrays.factor @@ -1,11 +1,13 @@ -! Copyright (C) 2009 Slava Pestov. +! Copyright (C) 2009, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays combinators.smart fry functors kernel kernel.private macros sequences combinators sequences.private -stack-checker parser math classes.tuple.private ; +stack-checker parser math classes.tuple classes.tuple.private ; FROM: inverse => undo ; IN: tuple-arrays +ERROR: not-final class ; + ] ; @@ -29,6 +31,13 @@ MACRO: write-tuple ( class -- quot ) [ tuple-arity iota [ '[ [ _ ] dip set-nth-unsafe ] ] map '[ _ cleave ] ] bi '[ _ dip @ ] ; +: check-final ( class -- ) + { + { [ dup tuple-class? not ] [ not-a-tuple ] } + { [ dup final-class? not ] [ not-final ] } + [ drop ] + } cond ; + PRIVATE> FUNCTOR: define-tuple-array ( CLASS -- ) @@ -43,6 +52,8 @@ CLASS-array? IS ${CLASS-array}? WHERE +CLASS check-final + TUPLE: CLASS-array { seq array read-only } { n array-capacity read-only } diff --git a/extra/benchmark/tuple-arrays/tuple-arrays.factor b/extra/benchmark/tuple-arrays/tuple-arrays.factor index 701db77135..80c31553c1 100644 --- a/extra/benchmark/tuple-arrays/tuple-arrays.factor +++ b/extra/benchmark/tuple-arrays/tuple-arrays.factor @@ -1,10 +1,10 @@ -! Copyright (C) 2009 Slava Pestov. +! Copyright (C) 2009, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel math math.functions tuple-arrays accessors fry sequences prettyprint ; IN: benchmark.tuple-arrays -TUPLE: point { x float } { y float } { z float } ; +TUPLE: point { x float } { y float } { z float } ; final TUPLE-ARRAY: point From bf72c890603b00757f0ea8334888908b52af9e34 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 03:57:10 +1300 Subject: [PATCH 075/713] tools.deploy.backend: clean up --- basis/tools/deploy/backend/backend.factor | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/basis/tools/deploy/backend/backend.factor b/basis/tools/deploy/backend/backend.factor index fe63071998..9f25808c9e 100644 --- a/basis/tools/deploy/backend/backend.factor +++ b/basis/tools/deploy/backend/backend.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2007, 2009 Slava Pestov. +! Copyright (C) 2007, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: namespaces make continuations.private kernel.private init assocs kernel vocabs words sequences memory io system arrays @@ -19,13 +19,12 @@ TUPLE: vocab-manifest vocabs libraries ; : copy-resources ( manifest name dir -- ) append-path swap vocabs>> [ copy-vocab-resources ] with each ; -ERROR: cant-deploy-library-file library ; - + [ swap over file-name append-path copy-file ] + [ can't-deploy-library-file ] ?if ; : copy-libraries ( manifest name dir -- ) append-path swap libraries>> [ copy-library ] with each ; From 9debed1c75490b451c7268a7a3043b3e184a6fee Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 04:13:21 +1300 Subject: [PATCH 076/713] typed: update documentation --- basis/typed/typed-docs.factor | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/basis/typed/typed-docs.factor b/basis/typed/typed-docs.factor index 0b6838379c..c6f80a48bc 100644 --- a/basis/typed/typed-docs.factor +++ b/basis/typed/typed-docs.factor @@ -58,10 +58,18 @@ HELP: output-mismatch-error ARTICLE: "typed" "Strongly-typed word definitions" "The Factor compiler supports advanced compiler optimizations that take advantage of the type information it can glean from source code. The " { $vocab-link "typed" } " vocabulary provides syntax that allows words to provide checked type information about their inputs and outputs and improve the performance of compiled code." +$nl +"Parameters and return values of typed words where the type is declared to be a " { $link POSTPONE: final } " tuple class with all slots " { $link read-only } " are passed by value." { $subsections POSTPONE: TYPED: POSTPONE: TYPED:: +} +"Defining typed words at run time:" +{ $subsections define-typed +} +"Errors:" +{ $subsections input-mismatch-error output-mismatch-error } ; From c5259f2e2c54fb44642d322b7fc6bb5836bc99b0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 04:13:34 +1300 Subject: [PATCH 077/713] classes.tuple: document final class declaration --- core/classes/tuple/tuple-docs.factor | 5 +++++ core/syntax/syntax-docs.factor | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/core/classes/tuple/tuple-docs.factor b/core/classes/tuple/tuple-docs.factor index 2b3e80da1d..7f6078e321 100644 --- a/core/classes/tuple/tuple-docs.factor +++ b/core/classes/tuple/tuple-docs.factor @@ -191,6 +191,8 @@ $nl "tuple-inheritance-example" "tuple-inheritance-anti-example" } +"Declaring a tuple class final prohibits other classes from subclassing it:" +{ $subsections POSTPONE: final } { $see-also "call-next-method" "parametrized-constructors" "unions" "mixins" } ; ARTICLE: "tuple-introspection" "Tuple introspection" @@ -441,3 +443,6 @@ HELP: boa { $description "Creates a new instance of " { $snippet "class" } " and fill in the slots from the stack, with the top-most stack element being stored in the right-most slot." } { $notes "The name " { $snippet "boa" } " is shorthand for “by order of arguments”, and “BOA constructor” is a pun on “boa constrictor”." } { $errors "Throws an error if the slot values do not match class declarations on slots (see" { $link "tuple-declarations" } ")." } ; + +HELP: bad-superclass +{ $error-description "Thrown if an attempt is made to subclass a class that is not a tuple class, or a tuple class declared " { $link POSTPONE: final } "." } ; diff --git a/core/syntax/syntax-docs.factor b/core/syntax/syntax-docs.factor index 8ad6084188..4a1af4c578 100644 --- a/core/syntax/syntax-docs.factor +++ b/core/syntax/syntax-docs.factor @@ -792,6 +792,10 @@ $nl { $code "TUPLE: person" "{ age integer initial: 0 }" "{ department string initial: \"Marketing\" }" "manager ;" } } ; +HELP: final +{ $syntax "TUPLE: ... ; final" } +{ $description "Declares the most recently defined word as a final tuple class which cannot be subclassed. Attempting to subclass a final class raises a " { $link bad-superclass } " error." } ; + HELP: initial: { $syntax "TUPLE: ... { slot initial: value } ... ;" } { $values { "slot" "a slot name" } { "value" "any literal" } } From 31ccfa2e5d8633c7e09aa26754bc3a197daf4860 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 04:58:30 +1300 Subject: [PATCH 078/713] Fix unit test failures --- core/classes/tuple/tuple-tests.factor | 4 ++-- core/parser/parser-tests.factor | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/classes/tuple/tuple-tests.factor b/core/classes/tuple/tuple-tests.factor index 6711c5705e..276c6b407c 100644 --- a/core/classes/tuple/tuple-tests.factor +++ b/core/classes/tuple/tuple-tests.factor @@ -782,7 +782,7 @@ TUPLE: final-subclass < final-superclass ; [ tuple ] [ final-subclass superclass ] unit-test -[ t ] [ \ final-subclass valid-superclass? ] unit-test +[ f ] [ \ final-subclass final-class? ] unit-test ! Subclassing a final class should fail [ "IN: classes.tuple.tests TUPLE: final-subclass < final-superclass ;" eval( -- ) ] @@ -796,4 +796,4 @@ TUPLE: final-subclass < final-superclass ; ! Changing a superclass should not change the final status of a subclass [ ] [ "IN: classes.tuple.tests TUPLE: final-superclass x ;" eval( -- ) ] unit-test -[ f ] [ \ final-subclass valid-superclass? ] unit-test +[ t ] [ \ final-subclass final-class? ] unit-test diff --git a/core/parser/parser-tests.factor b/core/parser/parser-tests.factor index f30eb68684..266a65b957 100644 --- a/core/parser/parser-tests.factor +++ b/core/parser/parser-tests.factor @@ -339,7 +339,7 @@ IN: parser.tests ] unit-test [ t ] [ - "foo?" "parser.tests" lookup word eq? + "foo" "parser.tests" lookup word eq? ] unit-test [ ] [ From 9da061de5eb4d6d45a60a34eef4ca6814f13234c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 07:02:22 +1300 Subject: [PATCH 079/713] listener: fix help lint --- basis/listener/listener-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/listener/listener-docs.factor b/basis/listener/listener-docs.factor index bb20fe62ae..bb014fef62 100644 --- a/basis/listener/listener-docs.factor +++ b/basis/listener/listener-docs.factor @@ -56,7 +56,7 @@ $nl "USE: math.functions" ": twice ( word -- ) [ execute ] [ execute ] bi ; inline" "81 \\ sqrt twice ." - "3" + "3.0" } "Multi-line expressions are supported:" { $example "{ 1 2 3 } [\n .\n] each" "1\n2\n3" } From 31d97a8ff7cddd6c0a23ca284d5c9c4c5f32112e Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 17 Feb 2010 11:26:32 -0800 Subject: [PATCH 080/713] fall back to manual gl vertex attribute management when GL_APPLE_vertex_array_object is not present, so gpu can support vanilla GL 2.0 --- extra/gpu/gpu.factor | 4 +- extra/gpu/render/render.factor | 5 +- extra/gpu/shaders/shaders.factor | 80 ++++++++++++++++++++++++++------ extra/gpu/state/state.factor | 4 -- 4 files changed, 71 insertions(+), 22 deletions(-) mode change 100644 => 100755 extra/gpu/gpu.factor mode change 100644 => 100755 extra/gpu/render/render.factor mode change 100644 => 100755 extra/gpu/shaders/shaders.factor mode change 100644 => 100755 extra/gpu/state/state.factor diff --git a/extra/gpu/gpu.factor b/extra/gpu/gpu.factor old mode 100644 new mode 100755 index 6a61e2ec4f..1d02b3f07a --- a/extra/gpu/gpu.factor +++ b/extra/gpu/gpu.factor @@ -9,10 +9,12 @@ TUPLE: gpu-object < identity-tuple handle ; VARIANT: gpu-api opengl-2 opengl-3 ; +SYMBOL: has-vertex-array-objects? + : set-gpu-api ( -- ) "2.0" require-gl-version "3.0" { { "GL_ARB_vertex_array_object" "GL_APPLE_vertex_array_object" } } - require-gl-version-or-extensions + has-gl-version-or-extensions? has-vertex-array-objects? set-global "3.0" has-gl-version? opengl-3 opengl-2 ? gpu-api set-global ; HOOK: init-gpu-api gpu-api ( -- ) diff --git a/extra/gpu/render/render.factor b/extra/gpu/render/render.factor old mode 100644 new mode 100755 index 1d4813ab54..2b7d75a3ae --- a/extra/gpu/render/render.factor +++ b/extra/gpu/render/render.factor @@ -520,9 +520,6 @@ SYNTAX: UNIFORM-TUPLE: > glBindVertexArray ; - : bind-unnamed-output-attachments ( framebuffer attachments -- ) [ gl-attachment ] with map dup length 1 = @@ -567,7 +564,7 @@ UNION: transform-feedback-output buffer buffer-range POSTPONE: f ; TUPLE: render-set { primitive-mode primitive-mode read-only } - { vertex-array vertex-array read-only } + { vertex-array vertex-array initial: T{ vertex-array-collection } read-only } { uniforms uniform-tuple read-only } { indexes vertex-indexes initial: T{ index-range } read-only } { instances ?integer initial: f read-only } diff --git a/extra/gpu/shaders/shaders.factor b/extra/gpu/shaders/shaders.factor old mode 100644 new mode 100755 index 0401584f7c..025acba896 --- a/extra/gpu/shaders/shaders.factor +++ b/extra/gpu/shaders/shaders.factor @@ -2,9 +2,9 @@ USING: accessors alien alien.c-types alien.data alien.strings arrays assocs byte-arrays classes.mixin classes.parser classes.singleton classes.struct combinators combinators.short-circuit -definitions destructors fry generic.parser gpu gpu.buffers hashtables -images io.encodings.ascii io.files io.pathnames kernel lexer -literals locals math math.parser memoize multiline namespaces +definitions destructors fry generic.parser gpu gpu.buffers gpu.private +gpu.state hashtables images io.encodings.ascii io.files io.pathnames +kernel lexer literals locals math math.parser memoize multiline namespaces opengl opengl.gl opengl.shaders parser quotations sequences specialized-arrays splitting strings tr ui.gadgets.worlds variants vectors vocabs vocabs.loader vocabs.parser words @@ -319,11 +319,18 @@ SYNTAX: VERTEX-FORMAT: SYNTAX: VERTEX-STRUCT: CREATE-CLASS scan-word define-vertex-struct ; -TUPLE: vertex-array < gpu-object +TUPLE: vertex-array-object < gpu-object { program-instance program-instance read-only } { vertex-buffers sequence read-only } ; -M: vertex-array dispose +TUPLE: vertex-array-collection + { vertex-formats sequence read-only } + { program-instance program-instance read-only } ; + +UNION: vertex-array + vertex-array-object vertex-array-collection ; + +M: vertex-array-object dispose [ [ delete-vertex-array ] when* f ] change-handle drop ; : ?>buffer-ptr ( buffer/ptr -- buffer-ptr ) @@ -331,26 +338,73 @@ M: vertex-array dispose : ?>buffer ( buffer/ptr -- buffer ) dup buffer? [ buffer>> ] unless ; inline -:: ( vertex-formats program-instance -- vertex-array ) +buffer-ptr ] dip 2array ] map ; inline + +: (bind-vertex-array) ( vertex-formats program-instance -- ) + '[ _ swap first2 bind-vertex-format ] each ; inline + +: (reset-vertex-array) ( -- ) + GL_MAX_VERTEX_ATTRIBS get-gl-int iota [ glDisableVertexAttribArray ] each ; inline + +:: ( vertex-formats program-instance -- vertex-array ) gen-vertex-array :> handle handle glBindVertexArray - vertex-formats [ program-instance swap first2 [ ?>buffer-ptr ] dip bind-vertex-format ] each - handle program-instance vertex-formats [ first ?>buffer ] map - vertex-array boa window-resource ; inline + vertex-formats normalize-vertex-formats program-instance (bind-vertex-array) -:: ( vertex-buffer program-instance format -- vertex-array ) + handle program-instance vertex-formats [ first ?>buffer ] map + vertex-array-object boa window-resource ; inline + +: ( vertex-formats program-instance -- vertex-array ) + [ normalize-vertex-formats ] dip vertex-array-collection boa ; inline + +:: ( vertex-buffer program-instance format -- vertex-array ) gen-vertex-array :> handle handle glBindVertexArray program-instance vertex-buffer ?>buffer-ptr format bind-vertex-format handle program-instance vertex-buffer ?>buffer 1array - vertex-array boa window-resource ; inline + vertex-array-object boa window-resource ; inline + +: ( vertex-buffer program-instance format -- vertex-array ) + swap [ [ ?>buffer-ptr ] dip 2array 1array ] dip ; inline + +PRIVATE> + +GENERIC: bind-vertex-array ( vertex-array -- ) + +M: vertex-array-object bind-vertex-array + handle>> glBindVertexArray ; inline + +M: vertex-array-collection bind-vertex-array + (reset-vertex-array) + [ vertex-formats>> ] [ program-instance>> ] bi (bind-vertex-array) ; inline + +: ( vertex-formats program-instance -- vertex-array ) + has-vertex-array-objects? get + [ ] + [ ] if ; inline + +: ( vertex-buffer program-instance format -- vertex-array ) + has-vertex-array-objects? get + [ ] + [ ] if ; inline : ( vertex-buffer program-instance -- vertex-array ) dup program>> vertex-formats>> first ; inline -TYPED: vertex-array-buffer ( vertex-array: vertex-array -- vertex-buffer: buffer ) - vertex-buffers>> first ; +GENERIC: vertex-array-buffers ( vertex-array -- buffers ) + +M: vertex-array-object vertex-array-buffers + vertex-buffers>> ; inline + +M: vertex-array-collection vertex-array-buffers + vertex-formats>> [ first buffer>> ] map ; inline + +: vertex-array-buffer ( vertex-array: vertex-array -- vertex-buffer: buffer ) + vertex-array-buffers first ; inline TUPLE: compile-shader-error shader log ; TUPLE: link-program-error program log ; diff --git a/extra/gpu/state/state.factor b/extra/gpu/state/state.factor old mode 100644 new mode 100755 index 3064ed4b82..db76774038 --- a/extra/gpu/state/state.factor +++ b/extra/gpu/state/state.factor @@ -415,8 +415,6 @@ M: mask-state set-gpu-state* [ [ set-gpu-state* ] each ] [ set-gpu-state* ] if ; inline - [ glGetBooleanv ] keep *uchar c-bool> ; : get-gl-int ( enum -- value ) @@ -437,8 +435,6 @@ M: mask-state set-gpu-state* : gl-enabled? ( enum -- ? ) glIsEnabled c-bool> ; -PRIVATE> - TYPED: get-viewport-state ( -- viewport-state: viewport-state ) GL_VIEWPORT get-gl-rect ; From 33bbd05507e57b212ced8856d40423a344b07281 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Feb 2010 08:38:45 +1300 Subject: [PATCH 081/713] io.pathnames: fix doc typo --- core/io/pathnames/pathnames-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/io/pathnames/pathnames-docs.factor b/core/io/pathnames/pathnames-docs.factor index 8dacef6f8c..cc637b59c3 100644 --- a/core/io/pathnames/pathnames-docs.factor +++ b/core/io/pathnames/pathnames-docs.factor @@ -92,7 +92,7 @@ HELP: normalize-path { $values { "path" "a pathname string" } { "path'" "a new pathname string" } } { $description "Prepends the " { $link current-directory } " to the pathname, resolves a " { $snippet "resource:" } " or " { $snippet "vocab:" } " prefix, if present (see " { $link "io.pathnames.special" } "). Also converts the path into a UNC path on Windows." } { $notes "High-level words, such as " { $link } " and " { $link delete-file } " call this word for you. It only needs to be called directly when passing pathnames to C functions or external processes. This is because Factor does not use the operating system's notion of a current directory, and instead maintains its own dynamically-scoped " { $link current-directory } " variable." } -{ $notes "On Windows NT platforms, this word does prepends the Unicode path prefix." } +{ $notes "On Windows NT platforms, this word prepends the Unicode path prefix." } { $examples "For example, if you create a file named " { $snippet "data.txt" } " in the current directory, and wish to pass it to a process, you must normalize it:" { $code From 236b2e6dc5fe8c594570af4110a943fc5a5b277d Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 17 Feb 2010 12:50:32 -0800 Subject: [PATCH 082/713] =?UTF-8?q?update=20gpu=20docs=E2=80=94VAOs=20no?= =?UTF-8?q?=20longer=20required?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extra/gpu/gpu-docs.factor | 2 +- extra/gpu/shaders/shaders-docs.factor | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/extra/gpu/gpu-docs.factor b/extra/gpu/gpu-docs.factor index 3c0c24e97e..103e0c60a1 100644 --- a/extra/gpu/gpu-docs.factor +++ b/extra/gpu/gpu-docs.factor @@ -42,6 +42,6 @@ ARTICLE: "gpu-summary" "GPU-accelerated rendering" "gpu.shaders" "gpu.render" } -"The library is built on top of the OpenGL API, but it aims to be complete enough that raw OpenGL calls are never needed. OpenGL 2.0 with the vertex array object extension (" { $snippet "GL_APPLE_vertex_array_object" } " or " { $snippet "GL_ARB_vertex_array_object" } ") is required. Some features require later OpenGL versions or additional extensions; these requirements are documented alongside individual words. To make full use of the library, an OpenGL 3.1 or later implementation is recommended." ; +"The library is built on top of the OpenGL API, but it aims to be complete enough that raw OpenGL calls are never needed. OpenGL 2.0 is required. Some features require later OpenGL versions or additional extensions; these requirements are documented alongside individual words. To make full use of the library, an OpenGL 3.1 or later implementation is recommended." ; ABOUT: "gpu-summary" diff --git a/extra/gpu/shaders/shaders-docs.factor b/extra/gpu/shaders/shaders-docs.factor index dd16224529..96a8561e9f 100644 --- a/extra/gpu/shaders/shaders-docs.factor +++ b/extra/gpu/shaders/shaders-docs.factor @@ -167,14 +167,23 @@ HELP: vertex-shader { $class-description "This " { $link shader-kind } " indicates that a " { $link shader } " is a vertex shader." } ; HELP: vertex-array -{ $class-description "A " { $snippet "vertex-array" } " object associates a shader " { $link program-instance } " with vertex attribute data from one or more " { $link buffer } "s. The format of the binary data inside these buffers is described using " { $link vertex-format } "s. " { $snippet "vertex-array" } "s are constructed using the " { $link } " or " { $link } " words." } ; +{ $class-description "A " { $snippet "vertex-array" } " object associates a shader " { $link program-instance } " with vertex attribute data from one or more " { $link buffer } "s. The format of the binary data inside these buffers is described using " { $link vertex-format } "s. " { $snippet "vertex-array" } "s are constructed using the " { $link } " or " { $link } " words. The actual type of a vertex-array object is opaque, but the " { $link vertex-array-buffers } " word can be used to query a vertex array object for its component buffers." } ; + +HELP: vertex-array-buffers +{ $values + { "vertex-array" vertex-array } + { "vertex-buffer" buffer } +} +{ $description "Returns a sequence containing all of the " { $link buffer } " objects that make up " { $snippet "vertex-array" } "." } ; HELP: vertex-array-buffer { $values { "vertex-array" vertex-array } { "vertex-buffer" buffer } } -{ $description "Returns the first " { $link buffer } " object comprised in " { $snippet "vertex-array" } "." } ; +{ $description "Returns the first " { $link buffer } " object that makes up " { $snippet "vertex-array" } "." } ; + +{ vertex-array-buffer vertex-array-buffers } related-words HELP: vertex-attribute { $class-description "This tuple type is passed to " { $link define-vertex-format } " to define a new " { $link vertex-format } " type." } ; @@ -204,7 +213,8 @@ ARTICLE: "gpu.shaders" "Shader objects" { $subsections vertex-array - vertex-array + + POSTPONE: VERTEX-FORMAT: } ; From f26460450e5ea4de9cf7cf7217d540b856e09ea1 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 17 Feb 2010 16:05:59 -0800 Subject: [PATCH 083/713] Revert "vocabs.loader: make vocab-dir+ use path-separator too" This reverts commit 2dcc7206292cde1ba52b12620a12848f58223a1b. --- core/vocabs/loader/loader.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/vocabs/loader/loader.factor b/core/vocabs/loader/loader.factor index 390cfceb95..0f2e3f7178 100644 --- a/core/vocabs/loader/loader.factor +++ b/core/vocabs/loader/loader.factor @@ -42,7 +42,7 @@ PRIVATE> : vocab-dir+ ( vocab str/f -- path ) [ vocab-name "." split ] dip [ [ dup last ] dip append suffix ] when* - path-separator join ; + "/" join ; : find-vocab-root ( vocab -- path/f ) vocab-name dup root-cache get at From 1250a0fcfd2a23edb3504ad81cfa83285d6677f7 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 17 Feb 2010 16:06:13 -0800 Subject: [PATCH 084/713] Revert "make io.pathnames tests path-separator-neutral" This reverts commit f344c0062966a8c7ff9a9c8e57d06316941f8c12. --- core/io/pathnames/pathnames-tests.factor | 35 +++++++++++------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/core/io/pathnames/pathnames-tests.factor b/core/io/pathnames/pathnames-tests.factor index 38cfe330fb..f23a1ac1f4 100644 --- a/core/io/pathnames/pathnames-tests.factor +++ b/core/io/pathnames/pathnames-tests.factor @@ -1,6 +1,6 @@ USING: io.pathnames io.files.temp io.directories continuations math io.files.private kernel -namespaces sequences tools.test io.pathnames.private ; +namespaces tools.test io.pathnames.private ; IN: io.pathnames.tests [ "passwd" ] [ "/etc/passwd" file-name ] unit-test @@ -11,23 +11,20 @@ IN: io.pathnames.tests [ "freetype6.dll" ] [ "resource:freetype6.dll" file-name ] unit-test [ "freetype6.dll" ] [ "resource:/freetype6.dll" file-name ] unit-test -: >test-path ( path -- path' ) - [ dup path-separator? [ drop CHAR: / ] when ] map ; - -[ "/usr/lib" ] [ "/usr" "lib" append-path >test-path ] unit-test -[ "/usr/lib" ] [ "/usr/" "lib" append-path >test-path ] unit-test -[ "/usr/lib" ] [ "/usr" "./lib" append-path >test-path ] unit-test -[ "/usr/lib/" ] [ "/usr" "./lib/" append-path >test-path ] unit-test -[ "/lib" ] [ "/usr" "../lib" append-path >test-path ] unit-test -[ "/lib/" ] [ "/usr" "../lib/" append-path >test-path ] unit-test +[ "/usr/lib" ] [ "/usr" "lib" append-path ] unit-test +[ "/usr/lib" ] [ "/usr/" "lib" append-path ] unit-test +[ "/usr/lib" ] [ "/usr" "./lib" append-path ] unit-test +[ "/usr/lib/" ] [ "/usr" "./lib/" append-path ] unit-test +[ "/lib" ] [ "/usr" "../lib" append-path ] unit-test +[ "/lib/" ] [ "/usr" "../lib/" append-path ] unit-test [ "" ] [ "" "." append-path ] unit-test [ "" ".." append-path ] must-fail -[ "/" ] [ "/" "./." append-path >test-path ] unit-test -[ "/" ] [ "/" "././" append-path >test-path ] unit-test -[ "/a/b/lib" ] [ "/a/b/c/d/e/f/" "../../../../lib" append-path >test-path ] unit-test -[ "/a/b/lib/" ] [ "/a/b/c/d/e/f/" "../../../../lib/" append-path >test-path ] unit-test +[ "/" ] [ "/" "./." append-path ] unit-test +[ "/" ] [ "/" "././" append-path ] unit-test +[ "/a/b/lib" ] [ "/a/b/c/d/e/f/" "../../../../lib" append-path ] unit-test +[ "/a/b/lib/" ] [ "/a/b/c/d/e/f/" "../../../../lib/" append-path ] unit-test [ "" "../lib/" append-path ] must-fail [ "lib" ] [ "" "lib" append-path ] unit-test @@ -48,10 +45,10 @@ IN: io.pathnames.tests [ "" parent-directory ] must-fail [ "." ] [ "boot.x86.64.image" parent-directory ] unit-test -[ "bar/foo" ] [ "bar/baz" "..///foo" append-path >test-path ] unit-test -[ "bar/baz/foo" ] [ "bar/baz" ".///foo" append-path >test-path ] unit-test -[ "bar/foo" ] [ "bar/baz" "./..//foo" append-path >test-path ] unit-test -[ "bar/foo" ] [ "bar/baz" "./../././././././///foo" append-path >test-path ] unit-test +[ "bar/foo" ] [ "bar/baz" "..///foo" append-path ] unit-test +[ "bar/baz/foo" ] [ "bar/baz" ".///foo" append-path ] unit-test +[ "bar/foo" ] [ "bar/baz" "./..//foo" append-path ] unit-test +[ "bar/foo" ] [ "bar/baz" "./../././././././///foo" append-path ] unit-test [ t ] [ "resource:core" absolute-path? ] unit-test [ f ] [ "" absolute-path? ] unit-test @@ -64,7 +61,7 @@ IN: io.pathnames.tests "." current-directory set ".." "resource-path" set [ "../core/bootstrap/stage2.factor" ] - [ "resource:core/bootstrap/stage2.factor" absolute-path >test-path ] + [ "resource:core/bootstrap/stage2.factor" absolute-path ] unit-test ] with-scope From 97654b67c1109b3f130b773b0af05396ec7c1a99 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 17 Feb 2010 16:06:30 -0800 Subject: [PATCH 085/713] Revert "io.pathnames: make absolute-path? public" This reverts commit 48756c9fca10a3a89ab8bb4b55c4fa711e524f74. --- core/io/pathnames/pathnames.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/io/pathnames/pathnames.factor b/core/io/pathnames/pathnames.factor index 2be66ef186..5a9c647973 100644 --- a/core/io/pathnames/pathnames.factor +++ b/core/io/pathnames/pathnames.factor @@ -76,8 +76,6 @@ ERROR: no-parent-directory path ; [ f ] } cond ; -PRIVATE> - : absolute-path? ( path -- ? ) { { [ dup empty? ] [ f ] } @@ -87,6 +85,8 @@ PRIVATE> [ f ] } cond nip ; +PRIVATE> + : append-path ( path1 path2 -- path ) { { [ over empty? ] [ append-path-empty ] } From e70fcf159d9f8d48c8e575324aeec8da66c98486 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 17 Feb 2010 16:06:45 -0800 Subject: [PATCH 086/713] Revert "fix append-path and vocab-dir to use path-separator" This reverts commit 0f3026b8712816d29143ff49dea807acbf03e0e0. --- core/io/pathnames/pathnames.factor | 2 +- core/vocabs/loader/loader.factor | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/core/io/pathnames/pathnames.factor b/core/io/pathnames/pathnames.factor index 5a9c647973..b307128efb 100644 --- a/core/io/pathnames/pathnames.factor +++ b/core/io/pathnames/pathnames.factor @@ -103,7 +103,7 @@ PRIVATE> ] } [ [ trim-tail-separators ] - [ trim-head-separators ] bi* path-separator glue + [ trim-head-separators ] bi* "/" glue ] } cond ; diff --git a/core/vocabs/loader/loader.factor b/core/vocabs/loader/loader.factor index 0f2e3f7178..2c0f67641d 100644 --- a/core/vocabs/loader/loader.factor +++ b/core/vocabs/loader/loader.factor @@ -35,9 +35,7 @@ M: string vocab-path ( string -- path/f ) PRIVATE> : vocab-dir ( vocab -- dir ) - vocab-name - os windows? { { CHAR: . CHAR: \\ } } { { CHAR: . CHAR: / } } ? - substitute ; + vocab-name { { CHAR: . CHAR: / } } substitute ; : vocab-dir+ ( vocab str/f -- path ) [ vocab-name "." split ] dip From 02d868dabe29f4a22fd8c29c504f3c7d0bccb3ea Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Wed, 17 Feb 2010 22:25:53 -0600 Subject: [PATCH 087/713] Solution to Project Euler problem 206 --- extra/project-euler/206/206-tests.factor | 4 +++ extra/project-euler/206/206.factor | 46 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 extra/project-euler/206/206-tests.factor create mode 100644 extra/project-euler/206/206.factor diff --git a/extra/project-euler/206/206-tests.factor b/extra/project-euler/206/206-tests.factor new file mode 100644 index 0000000000..132adfb05e --- /dev/null +++ b/extra/project-euler/206/206-tests.factor @@ -0,0 +1,4 @@ +USING: project-euler.206 tools.test ; +IN: project-euler.206.tests + +[ 1389019170 ] [ euler206 ] unit-test diff --git a/extra/project-euler/206/206.factor b/extra/project-euler/206/206.factor new file mode 100644 index 0000000000..06946d4db7 --- /dev/null +++ b/extra/project-euler/206/206.factor @@ -0,0 +1,46 @@ +! Copyright (c) 2010 Aaron Schaefer. All rights reserved. +! The contents of this file are licensed under the Simplified BSD License +! A copy of the license is available at http://factorcode.org/license.txt +USING: grouping kernel math math.ranges project-euler.common sequences ; +IN: project-euler.206 + +! http://projecteuler.net/index.php?section=problems&id=206 + +! DESCRIPTION +! ----------- + +! Find the unique positive integer whose square has the form +! 1_2_3_4_5_6_7_8_9_0, where each “_” is a single digit. + + +! SOLUTION +! -------- + +! Through mathematical analysis, we know that the number must end in 00, and +! the only way to get the last digits to be 900, is for our answer to end in +! 30 or 70. + +digits 2 group [ first ] map + { 1 2 3 4 5 6 7 8 9 0 } = ; + +: candidates ( -- seq ) + lo lo 40 + [ hi 100 ] bi@ append ; + +PRIVATE> + +: euler206 ( -- answer ) + candidates [ sq form-fitting? ] find-last nip ; + +! [ euler206 ] 100 ave-time +! 321 ms ave run time - 8.33 SD (100 trials) + +SOLUTION: euler206 From 488e5ead26d7757671ba8f748c80f1d7ce11706f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 19 Feb 2010 04:11:48 +1300 Subject: [PATCH 088/713] tools.deploy.libraries.windows: add unportable tag to avoid loading windows.kernel32 on non-windows platforms --- basis/tools/deploy/libraries/windows/tags.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 basis/tools/deploy/libraries/windows/tags.txt diff --git a/basis/tools/deploy/libraries/windows/tags.txt b/basis/tools/deploy/libraries/windows/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/tools/deploy/libraries/windows/tags.txt @@ -0,0 +1 @@ +unportable From 2a517d31dffff7e0b6ef9056f6edf6b033ce81bd Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 19 Feb 2010 04:11:57 +1300 Subject: [PATCH 089/713] help.stylesheet: tweak color --- basis/help/stylesheet/stylesheet.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/help/stylesheet/stylesheet.factor b/basis/help/stylesheet/stylesheet.factor index d5b783fef8..254b65e5ac 100644 --- a/basis/help/stylesheet/stylesheet.factor +++ b/basis/help/stylesheet/stylesheet.factor @@ -83,7 +83,7 @@ H{ SYMBOL: output-style H{ { font-style bold } - { foreground COLOR: dark-red } + { foreground COLOR: DarkOrange4 } } output-style set-global SYMBOL: url-style From d3d7392fa9424383d71e7af0dce8d9f5853fa174 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Thu, 18 Feb 2010 12:52:33 -0800 Subject: [PATCH 090/713] Implement input grabbing for x11; add do-nothing game.input backend for linux. The game and gpu demos now run correctly. --- basis/game/input/input.factor | 2 +- basis/game/input/linux/authors.txt | 1 + basis/game/input/linux/linux.factor | 49 +++++++++++++++++++++++++++++ basis/game/input/linux/summary.txt | 1 + basis/game/input/linux/tags.txt | 1 + basis/ui/backend/x11/x11.factor | 33 +++++++++++++------ basis/x11/xlib/xlib.factor | 14 +++++++++ 7 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 basis/game/input/linux/authors.txt create mode 100644 basis/game/input/linux/linux.factor create mode 100644 basis/game/input/linux/summary.txt create mode 100644 basis/game/input/linux/tags.txt diff --git a/basis/game/input/input.factor b/basis/game/input/input.factor index a2afbe92a3..7543a05c60 100644 --- a/basis/game/input/input.factor +++ b/basis/game/input/input.factor @@ -93,5 +93,5 @@ M: mouse-state clone { { [ os windows? ] [ "game.input.xinput" require ] } { [ os macosx? ] [ "game.input.iokit" require ] } - { [ t ] [ ] } + { [ os linux? ] [ "game.input.linux" require ] } } cond diff --git a/basis/game/input/linux/authors.txt b/basis/game/input/linux/authors.txt new file mode 100644 index 0000000000..67cf648cf5 --- /dev/null +++ b/basis/game/input/linux/authors.txt @@ -0,0 +1 @@ +Erik Charlebois \ No newline at end of file diff --git a/basis/game/input/linux/linux.factor b/basis/game/input/linux/linux.factor new file mode 100644 index 0000000000..465cefa84b --- /dev/null +++ b/basis/game/input/linux/linux.factor @@ -0,0 +1,49 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel game.input namespaces classes windows.com.syntax +bit-arrays +vectors ; +IN: game.input.linux + +SINGLETON: linux-game-input-backend + +linux-game-input-backend game-input-backend set-global + +M: linux-game-input-backend (open-game-input) + ; + +M: linux-game-input-backend (close-game-input) + ; + +M: linux-game-input-backend (reset-game-input) + ; + +M: linux-game-input-backend get-controllers + { } ; + +M: linux-game-input-backend product-string + drop "" ; + +M: linux-game-input-backend product-id + drop GUID: {00000000-0000-0000-0000-000000000000} ; + +M: linux-game-input-backend instance-id + drop GUID: {00000000-0000-0000-0000-000000000000} ; + +M: linux-game-input-backend read-controller + drop controller-state new ; + +M: linux-game-input-backend calibrate-controller + drop ; + +M: linux-game-input-backend vibrate-controller + 3drop ; + +M: linux-game-input-backend read-keyboard + 256 keyboard-state boa ; + +M: linux-game-input-backend read-mouse + 0 0 0 0 2 mouse-state boa ; + +M: linux-game-input-backend reset-mouse + ; diff --git a/basis/game/input/linux/summary.txt b/basis/game/input/linux/summary.txt new file mode 100644 index 0000000000..5c88274722 --- /dev/null +++ b/basis/game/input/linux/summary.txt @@ -0,0 +1 @@ +Linux backend for game input. diff --git a/basis/game/input/linux/tags.txt b/basis/game/input/linux/tags.txt new file mode 100644 index 0000000000..84d4140a70 --- /dev/null +++ b/basis/game/input/linux/tags.txt @@ -0,0 +1 @@ +games diff --git a/basis/ui/backend/x11/x11.factor b/basis/ui/backend/x11/x11.factor index 4c977f17a4..673dd8e9c3 100644 --- a/basis/ui/backend/x11/x11.factor +++ b/basis/ui/backend/x11/x11.factor @@ -1,14 +1,13 @@ ! Copyright (C) 2005, 2009 Eduardo Cavazos and Slava Pestov ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types arrays ascii assocs colors -classes.struct combinators io.encodings.ascii -io.encodings.string io.encodings.utf8 kernel literals math -namespaces sequences strings ui ui.backend ui.clipboards -ui.event-loop ui.gadgets ui.gadgets.private ui.gadgets.worlds -ui.gestures ui.pixel-formats ui.pixel-formats.private -ui.private x11 x11.clipboard x11.constants x11.events x11.glx -x11.io x11.windows x11.xim x11.xlib environment command-line -combinators.short-circuit ; +USING: accessors alien.c-types ascii assocs classes.struct combinators +combinators.short-circuit command-line environment io.encodings.ascii +io.encodings.string io.encodings.utf8 kernel literals locals math +namespaces sequences specialized-arrays.instances.alien.c-types.uchar +strings ui ui.backend ui.clipboards ui.event-loop ui.gadgets +ui.gadgets.private ui.gadgets.worlds ui.gestures ui.pixel-formats +ui.pixel-formats.private ui.private x11 x11.clipboard x11.constants +x11.events x11.glx x11.io x11.windows x11.xim x11.xlib ; IN: ui.backend.x11 SINGLETON: x11-ui-backend @@ -328,6 +327,22 @@ M: x11-ui-backend (with-ui) ( quot -- ) M: x11-ui-backend beep ( -- ) dpy get 100 XBell drop ; +: black ( -- xcolor ) 0 0 0 0 0 0 XColor ; inline + +M:: x11-ui-backend (grab-input) ( handle -- ) + handle window>> :> wnd + dpy get :> dpy + dpy wnd uchar-array{ 0 0 0 0 0 0 0 0 } 8 8 XCreateBitmapFromData :> pixmap + dpy pixmap dup black dup 0 0 XCreatePixmapCursor :> cursor + + dpy wnd 1 NoEventMask GrabModeAsync dup wnd cursor CurrentTime XGrabPointer drop + + dpy cursor XFreeCursor drop + dpy pixmap XFreePixmap drop ; + +M: x11-ui-backend (ungrab-input) + drop dpy get CurrentTime XUngrabPointer drop ; + x11-ui-backend ui-backend set-global [ "DISPLAY" os-env "ui.tools" "listener" ? ] diff --git a/basis/x11/xlib/xlib.factor b/basis/x11/xlib/xlib.factor index a6097c9dad..7235aaf679 100644 --- a/basis/x11/xlib/xlib.factor +++ b/basis/x11/xlib/xlib.factor @@ -284,6 +284,11 @@ X-FUNCTION: int XConvertSelection ( Display* display, Atom selection, Atom targe X-FUNCTION: Pixmap XCreatePixmap ( Display* display, Drawable d, uint width, uint height, uint depth ) ; X-FUNCTION: int XFreePixmap ( Display* display, Pixmap pixmap ) ; +! 5.2 - Creating, Recoloring, and Freeing Cursors + +C-TYPE: XColor +X-FUNCTION: Cursor XCreatePixmapCursor ( Display* display, Pixmap source, Pixmap mask, XColor* foreground_color, XColor* background_color, uint x, uint y ) ; +X-FUNCTION: int XFreeCursor ( Display* display, Cursor cursor ) ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! 6 - Color Management Functions @@ -1096,6 +1101,7 @@ X-FUNCTION: int XGrabPointer ( X-FUNCTION: Status XUngrabPointer ( Display* display, Time time ) ; X-FUNCTION: Status XChangeActivePointerGrab ( Display* display, uint event_mask, Cursor cursor, Time time ) ; X-FUNCTION: Status XGrabKey ( Display* display, int keycode, uint modifiers, Window grab_window, Bool owner_events, int pointer_mode, int keyboard_mode ) ; +X-FUNCTION: int XGrabKeyboard ( Display* display, Window grab_window, Bool owner_events, int pointer_mode, int keyboard_mode, Time time ) ; X-FUNCTION: Status XSetInputFocus ( Display* display, Window focus, int revert_to, Time time ) ; X-FUNCTION: Status XGetInputFocus ( Display* display, @@ -1210,6 +1216,14 @@ STRUCT: XVisualInfo { colormap_size int } { bits_per_rgb int } ; +! 16.9 Manipulating Bitmaps +X-FUNCTION: Pixmap XCreateBitmapFromData ( + Display* display, + Drawable d, + char* data, + uint width, + uint height ) ; + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Appendix D - Compatibility Functions ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! From 5d80153d53671a6691feb1c72abffa38c902d940 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Thu, 18 Feb 2010 12:53:15 -0800 Subject: [PATCH 091/713] Bindings to libusb --- extra/libusb/authors.txt | 1 + extra/libusb/libusb.factor | 422 +++++++++++++++++++++++++++++++++++++ extra/libusb/summary.txt | 1 + extra/libusb/tags.txt | 1 + 4 files changed, 425 insertions(+) create mode 100644 extra/libusb/authors.txt create mode 100644 extra/libusb/libusb.factor create mode 100644 extra/libusb/summary.txt create mode 100644 extra/libusb/tags.txt diff --git a/extra/libusb/authors.txt b/extra/libusb/authors.txt new file mode 100644 index 0000000000..67cf648cf5 --- /dev/null +++ b/extra/libusb/authors.txt @@ -0,0 +1 @@ +Erik Charlebois \ No newline at end of file diff --git a/extra/libusb/libusb.factor b/extra/libusb/libusb.factor new file mode 100644 index 0000000000..d521015d6f --- /dev/null +++ b/extra/libusb/libusb.factor @@ -0,0 +1,422 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien alien.c-types alien.libraries +alien.syntax classes.struct combinators endian io.binary +kernel locals math sequences specialized-arrays +system unix.time unix.types ; +FROM: alien.c-types => short ; +IN: libusb + +<< "libusb" { + { [ os windows? ] [ "libusb-1.0.dll" ] } + { [ os macosx? ] [ "libusb-1.0.dylib" ] } + { [ os unix? ] [ "libusb-1.0.so" ] } + } cond "cdecl" add-library >> +LIBRARY: libusb + +: libusb_cpu_to_le16 ( x -- y ) + 2 >native-endian le> ; inline + +ALIAS: libusb_le16_to_cpu libusb_cpu_to_le16 + +CONSTANT: LIBUSB_CLASS_PER_INTERFACE 0 +CONSTANT: LIBUSB_CLASS_AUDIO 1 +CONSTANT: LIBUSB_CLASS_COMM 2 +CONSTANT: LIBUSB_CLASS_HID 3 +CONSTANT: LIBUSB_CLASS_PRINTER 7 +CONSTANT: LIBUSB_CLASS_PTP 6 +CONSTANT: LIBUSB_CLASS_MASS_STORAGE 8 +CONSTANT: LIBUSB_CLASS_HUB 9 +CONSTANT: LIBUSB_CLASS_DATA 10 +CONSTANT: LIBUSB_CLASS_VENDOR_SPEC HEX: ff +TYPEDEF: int libusb_class_code + +CONSTANT: LIBUSB_DT_DEVICE HEX: 01 +CONSTANT: LIBUSB_DT_CONFIG HEX: 02 +CONSTANT: LIBUSB_DT_STRING HEX: 03 +CONSTANT: LIBUSB_DT_INTERFACE HEX: 04 +CONSTANT: LIBUSB_DT_ENDPOINT HEX: 05 +CONSTANT: LIBUSB_DT_HID HEX: 21 +CONSTANT: LIBUSB_DT_REPORT HEX: 22 +CONSTANT: LIBUSB_DT_PHYSICAL HEX: 23 +CONSTANT: LIBUSB_DT_HUB HEX: 29 +TYPEDEF: int libusb_descriptor_type + +CONSTANT: LIBUSB_DT_DEVICE_SIZE 18 +CONSTANT: LIBUSB_DT_CONFIG_SIZE 9 +CONSTANT: LIBUSB_DT_INTERFACE_SIZE 9 +CONSTANT: LIBUSB_DT_ENDPOINT_SIZE 7 +CONSTANT: LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9 +CONSTANT: LIBUSB_DT_HUB_NONVAR_SIZE 7 + +CONSTANT: LIBUSB_ENDPOINT_ADDRESS_MASK HEX: 0f +CONSTANT: LIBUSB_ENDPOINT_DIR_MASK HEX: 80 + +CONSTANT: LIBUSB_ENDPOINT_IN HEX: 80 +CONSTANT: LIBUSB_ENDPOINT_OUT HEX: 00 +TYPEDEF: int libusb_endpoint_direction + +CONSTANT: LIBUSB_TRANSFER_TYPE_MASK HEX: 03 + +CONSTANT: LIBUSB_TRANSFER_TYPE_CONTROL 0 +CONSTANT: LIBUSB_TRANSFER_TYPE_ISOCHRONOUS 1 +CONSTANT: LIBUSB_TRANSFER_TYPE_BULK 2 +CONSTANT: LIBUSB_TRANSFER_TYPE_INTERRUPT 3 +TYPEDEF: int libusb_transfer_type + +CONSTANT: LIBUSB_REQUEST_GET_STATUS HEX: 00 +CONSTANT: LIBUSB_REQUEST_CLEAR_FEATURE HEX: 01 +CONSTANT: LIBUSB_REQUEST_SET_FEATURE HEX: 03 +CONSTANT: LIBUSB_REQUEST_SET_ADDRESS HEX: 05 +CONSTANT: LIBUSB_REQUEST_GET_DESCRIPTOR HEX: 06 +CONSTANT: LIBUSB_REQUEST_SET_DESCRIPTOR HEX: 07 +CONSTANT: LIBUSB_REQUEST_GET_CONFIGURATION HEX: 08 +CONSTANT: LIBUSB_REQUEST_SET_CONFIGURATION HEX: 09 +CONSTANT: LIBUSB_REQUEST_GET_INTERFACE HEX: 0A +CONSTANT: LIBUSB_REQUEST_SET_INTERFACE HEX: 0B +CONSTANT: LIBUSB_REQUEST_SYNCH_FRAME HEX: 0C +TYPEDEF: int libusb_standard_request + +CONSTANT: LIBUSB_REQUEST_TYPE_STANDARD HEX: 00 +CONSTANT: LIBUSB_REQUEST_TYPE_CLASS HEX: 20 +CONSTANT: LIBUSB_REQUEST_TYPE_VENDOR HEX: 40 +CONSTANT: LIBUSB_REQUEST_TYPE_RESERVED HEX: 60 + +CONSTANT: LIBUSB_RECIPIENT_DEVICE HEX: 00 +CONSTANT: LIBUSB_RECIPIENT_INTERFACE HEX: 01 +CONSTANT: LIBUSB_RECIPIENT_ENDPOINT HEX: 02 +CONSTANT: LIBUSB_RECIPIENT_OTHER HEX: 03 +TYPEDEF: int libusb_request_recipient + +CONSTANT: LIBUSB_ISO_SYNC_TYPE_MASK HEX: 0C + +CONSTANT: LIBUSB_ISO_SYNC_TYPE_NONE 0 +CONSTANT: LIBUSB_ISO_SYNC_TYPE_ASYNC 1 +CONSTANT: LIBUSB_ISO_SYNC_TYPE_ADAPTIVE 2 +CONSTANT: LIBUSB_ISO_SYNC_TYPE_SYNC 3 +TYPEDEF: int libusb_iso_sync_type + +CONSTANT: LIBUSB_ISO_USAGE_TYPE_MASK HEX: 30 + +CONSTANT: LIBUSB_ISO_USAGE_TYPE_DATA 0 +CONSTANT: LIBUSB_ISO_USAGE_TYPE_FEEDBACK 1 +CONSTANT: LIBUSB_ISO_USAGE_TYPE_IMPLICIT 2 +TYPEDEF: int libusb_iso_usage_type + +STRUCT: libusb_device_descriptor + { bLength uint8_t } + { bDescriptorType uint8_t } + { bcdUSB uint16_t } + { bDeviceClass uint8_t } + { bDeviceSubClass uint8_t } + { bDeviceProtocol uint8_t } + { bMaxPacketSize0 uint8_t } + { idVendor uint16_t } + { idProduct uint16_t } + { bcdDevice uint16_t } + { iManufacturer uint8_t } + { iProduct uint8_t } + { iSerialNumber uint8_t } + { bNumConfigurations uint8_t } ; + +STRUCT: libusb_endpoint_descriptor + { bLength uint8_t } + { bDescriptorType uint8_t } + { bEndpointAddress uint8_t } + { bmAttributes uint8_t } + { wMaxPacketSize uint16_t } + { bInterval uint8_t } + { bRefresh uint8_t } + { bSynchAddress uint8_t } + { extra uchar* } + { extra_length int } ; + +STRUCT: libusb_interface_descriptor + { bLength uint8_t } + { bDescriptorType uint8_t } + { bInterfaceNumber uint8_t } + { bAlternateSetting uint8_t } + { bNumEndpoints uint8_t } + { bInterfaceClass uint8_t } + { bInterfaceSubClass uint8_t } + { bInterfaceProtocol uint8_t } + { iInterface uint8_t } + { endpoint libusb_endpoint_descriptor* } + { extra uchar* } + { extra_length int } ; + +STRUCT: libusb_interface + { altsetting libusb_interface_descriptor* } + { num_altsetting int } ; + +STRUCT: libusb_config_descriptor + { bLength uint8_t } + { bDescriptorType uint8_t } + { wTotalLength uint16_t } + { bNumInterfaces uint8_t } + { bConfigurationValue uint8_t } + { iConfiguration uint8_t } + { bmAttributes uint8_t } + { MaxPower uint8_t } + { interface libusb_interface* } + { extra uchar* } + { extra_length int } ; + +STRUCT: libusb_control_setup + { bmRequestType uint8_t } + { bRequest uint8_t } + { wValue uint16_t } + { wIndex uint16_t } + { wLength uint16_t } ; + +: LIBUSB_CONTROL_SETUP_SIZE ( -- x ) libusb_control_setup heap-size ; inline + +C-TYPE: libusb_context +C-TYPE: libusb_device +C-TYPE: libusb_device_handle + +CONSTANT: LIBUSB_SUCCESS 0 +CONSTANT: LIBUSB_ERROR_IO -1 +CONSTANT: LIBUSB_ERROR_INVALID_PARAM -2 +CONSTANT: LIBUSB_ERROR_ACCESS -3 +CONSTANT: LIBUSB_ERROR_NO_DEVICE -4 +CONSTANT: LIBUSB_ERROR_NOT_FOUND -5 +CONSTANT: LIBUSB_ERROR_BUSY -6 +CONSTANT: LIBUSB_ERROR_TIMEOUT -7 +CONSTANT: LIBUSB_ERROR_OVERFLOW -8 +CONSTANT: LIBUSB_ERROR_PIPE -9 +CONSTANT: LIBUSB_ERROR_INTERRUPTED -10 +CONSTANT: LIBUSB_ERROR_NO_MEM -11 +CONSTANT: LIBUSB_ERROR_NOT_SUPPORTED -12 +CONSTANT: LIBUSB_ERROR_OTHER -99 +TYPEDEF: int libusb_error + +C-ENUM: + LIBUSB_TRANSFER_COMPLETED + LIBUSB_TRANSFER_ERROR + LIBUSB_TRANSFER_TIMED_OUT + LIBUSB_TRANSFER_CANCELLED + LIBUSB_TRANSFER_STALL + LIBUSB_TRANSFER_NO_DEVICE + LIBUSB_TRANSFER_OVERFLOW ; +TYPEDEF: int libusb_transfer_status + +CONSTANT: LIBUSB_TRANSFER_SHORT_NOT_OK 1 +CONSTANT: LIBUSB_TRANSFER_FREE_BUFFER 2 +CONSTANT: LIBUSB_TRANSFER_FREE_TRANSFER 4 +TYPEDEF: int libusb_transfer_flags + +STRUCT: libusb_iso_packet_descriptor + { length uint } + { actual_length uint } + { status libusb_transfer_status } ; +SPECIALIZED-ARRAY: libusb_iso_packet_descriptor + +C-TYPE: libusb_transfer + +CALLBACK: void libusb_transfer_cb_fn ( libusb_transfer* transfer ) ; + +STRUCT: libusb_transfer + { dev_handle libusb_device_handle* } + { flags uint8_t } + { endpoint uchar } + { type uchar } + { timeout uint } + { status libusb_transfer_status } + { length int } + { actual_length int } + { callback libusb_transfer_cb_fn } + { user_data void* } + { buffer uchar* } + { num_iso_packets int } + { iso_packet_desc libusb_iso_packet_descriptor[0] } ; + +FUNCTION: int libusb_init ( libusb_context** ctx ) ; +FUNCTION: void libusb_exit ( libusb_context* ctx ) ; +FUNCTION: void libusb_set_debug ( libusb_context* ctx, int level ) ; + +FUNCTION: ssize_t libusb_get_device_list ( libusb_context* ctx, libusb_device*** list ) ; +FUNCTION: void libusb_free_device_list ( libusb_device** list, int unref_devices ) ; +FUNCTION: libusb_device* libusb_ref_device ( libusb_device* dev ) ; +FUNCTION: void libusb_unref_device ( libusb_device* dev ) ; + +FUNCTION: int libusb_get_configuration ( libusb_device_handle* dev, int* config ) ; +FUNCTION: int libusb_get_device_descriptor ( libusb_device* dev, libusb_device_descriptor* desc ) ; +FUNCTION: int libusb_get_active_config_descriptor ( libusb_device* dev, libusb_config_descriptor** config ) ; +FUNCTION: int libusb_get_config_descriptor ( libusb_device* dev, uint8_t config_index, libusb_config_descriptor** config ) ; +FUNCTION: int libusb_get_config_descriptor_by_value ( libusb_device* dev, uint8_t bConfigurationValue, libusb_config_descriptor** config ) ; +FUNCTION: void libusb_free_config_descriptor ( libusb_config_descriptor* config ) ; +FUNCTION: uint8_t libusb_get_bus_number ( libusb_device* dev ) ; +FUNCTION: uint8_t libusb_get_device_address ( libusb_device* dev ) ; +FUNCTION: int libusb_get_max_packet_size ( libusb_device* dev, uchar endpoint ) ; + +FUNCTION: int libusb_open ( libusb_device* dev, libusb_device_handle** handle ) ; +FUNCTION: void libusb_close ( libusb_device_handle* dev_handle ) ; +FUNCTION: libusb_device* libusb_get_device ( libusb_device_handle* dev_handle ) ; + +FUNCTION: int libusb_set_configuration ( libusb_device_handle* dev, int configuration ) ; +FUNCTION: int libusb_claim_interface ( libusb_device_handle* dev, int iface ) ; +FUNCTION: int libusb_release_interface ( libusb_device_handle* dev, int iface ) ; + +FUNCTION: libusb_device_handle* libusb_open_device_with_vid_pid ( libusb_context* ctx, uint16_t vendor_id, uint16_t product_id ) ; + +FUNCTION: int libusb_set_interface_alt_setting ( libusb_device_handle* dev, int interface_number, int alternate_setting ) ; +FUNCTION: int libusb_clear_halt ( libusb_device_handle* dev, uchar endpoint ) ; +FUNCTION: int libusb_reset_device ( libusb_device_handle* dev ) ; + +FUNCTION: int libusb_kernel_driver_active ( libusb_device_handle* dev, int interface ) ; +FUNCTION: int libusb_detach_kernel_driver ( libusb_device_handle* dev, int interface ) ; +FUNCTION: int libusb_attach_kernel_driver ( libusb_device_handle* dev, int interface ) ; + +: libusb_control_transfer_get_data ( transfer -- data ) + buffer>> LIBUSB_CONTROL_SETUP_SIZE swap ; inline + +: libusb_control_transfer_get_setup ( transfer -- setup ) + buffer>> libusb_control_setup memory>struct ; inline + +:: libusb_fill_control_setup ( buffer bmRequestType bRequest wValue wIndex wLength -- ) + buffer libusb_control_setup memory>struct + bmRequestType >>bmRequestType + bRequest >>bRequest + wValue libusb_cpu_to_le16 >>wValue + wIndex libusb_cpu_to_le16 >>wIndex + wLength libusb_cpu_to_le16 >>wLength drop ; inline + +FUNCTION: libusb_transfer* libusb_alloc_transfer ( int iso_packets ) ; +FUNCTION: int libusb_submit_transfer ( libusb_transfer* transfer ) ; +FUNCTION: int libusb_cancel_transfer ( libusb_transfer* transfer ) ; +FUNCTION: void libusb_free_transfer ( libusb_transfer* transfer ) ; + +:: libusb_fill_control_transfer ( transfer dev_handle buffer callback user_data timeout -- ) + transfer + dev_handle >>dev_handle + 0 >>endpoint + LIBUSB_TRANSFER_TYPE_CONTROL >>type + timeout >>timeout + buffer >>buffer + user_data >>user_data + callback >>callback + + buffer [ + libusb_control_setup memory>struct wLength>> LIBUSB_CONTROL_SETUP_SIZE + + ] [ 0 ] if* >>length drop ; inline + +:: libusb_fill_bulk_transfer ( transfer dev_handle endpoint buffer length callback user_data timeout -- ) + transfer + dev_handle >>dev_handle + endpoint >>endpoint + LIBUSB_TRANSFER_TYPE_BULK >>type + timeout >>timeout + buffer >>buffer + length >>length + user_data >>user_data + callback >>callback + drop ; inline + +:: libusb_fill_interrupt_transfer ( transfer dev_handle endpoint buffer length callback user_data timeout -- ) + transfer + dev_handle >>dev_handle + endpoint >>endpoint + LIBUSB_TRANSFER_TYPE_INTERRUPT >>type + timeout >>timeout + buffer >>buffer + length >>length + user_data >>user_data + callback >>callback + drop ; inline + +:: libusb_fill_iso_transfer ( transfer dev_handle endpoint buffer length num_iso_packets callback user_data timeout -- ) + transfer + dev_handle >>dev_handle + endpoint >>endpoint + LIBUSB_TRANSFER_TYPE_ISOCHRONOUS >>type + timeout >>timeout + buffer >>buffer + length >>length + num_iso_packets >>num_iso_packets + user_data >>user_data + callback >>callback + drop ; inline + +: libusb_set_iso_packet_lengths ( transfer length -- ) + [ [ iso_packet_desc>> >c-ptr ] + [ num_iso_packets>> ] bi + + ] dip [ >>length drop ] curry each ; inline + +:: libusb_get_iso_packet_buffer ( transfer packet -- data ) + packet transfer num_iso_packets>> >= + [ f ] + [ + transfer + [ iso_packet_desc>> >c-ptr ] + [ num_iso_packets>> ] bi + 0 + [ length>> + ] reduce + transfer buffer>> + ] if ; + +:: libusb_get_iso_packet_buffer_simple ( transfer packet -- data ) + packet transfer num_iso_packets>> >= + [ f ] + [ + 0 transfer + [ iso_packet_desc>> >c-ptr ] + [ num_iso_packets>> ] bi + nth + length>> packet * + transfer buffer>> + ] if ; + +FUNCTION: int libusb_control_transfer ( libusb_device_handle* dev_handle, + uint8_t request_type, uint8_t request, uint16_t value, uint16_t index, + uchar* data, uint16_t length, uint timeout ) ; + +FUNCTION: int libusb_bulk_transfer ( libusb_device_handle* dev_handle, + uchar endpoint, uchar* data, int length, + int* actual_length, uint timeout ) ; + +FUNCTION: int libusb_interrupt_transfer ( libusb_device_handle* dev_handle, + uchar endpoint, uchar* data, int length, + int* actual_length, int timeout ) ; + +:: libusb_get_descriptor ( dev desc_type desc_index data length -- int ) + dev LIBUSB_ENDPOINT_IN LIBUSB_REQUEST_GET_DESCRIPTOR + desc_type 8 shift desc_index bitor 0 data + length 1000 libusb_control_transfer ; inline + +:: libusb_get_string_descriptor ( dev desc_index langid data length -- int ) + dev LIBUSB_ENDPOINT_IN LIBUSB_REQUEST_GET_DESCRIPTOR + LIBUSB_DT_STRING 8 shift desc_index bitor + langid data length 1000 libusb_control_transfer ; inline + +FUNCTION: int libusb_get_string_descriptor_ascii ( libusb_device_handle* dev, + uint8_t index, + uchar* data, + int length ) ; + +FUNCTION: int libusb_try_lock_events ( libusb_context* ctx ) ; +FUNCTION: void libusb_lock_events ( libusb_context* ctx ) ; +FUNCTION: void libusb_unlock_events ( libusb_context* ctx ) ; +FUNCTION: int libusb_event_handling_ok ( libusb_context* ctx ) ; +FUNCTION: int libusb_event_handler_active ( libusb_context* ctx ) ; +FUNCTION: void libusb_lock_event_waiters ( libusb_context* ctx ) ; +FUNCTION: void libusb_unlock_event_waiters ( libusb_context* ctx ) ; +FUNCTION: int libusb_wait_for_event ( libusb_context* ctx, timeval* tv ) ; +FUNCTION: int libusb_handle_events_timeout ( libusb_context* ctx, timeval* tv ) ; +FUNCTION: int libusb_handle_events ( libusb_context* ctx ) ; +FUNCTION: int libusb_handle_events_locked ( libusb_context* ctx, timeval* tv ) ; +FUNCTION: int libusb_get_next_timeout ( libusb_context* ctx, timeval* tv ) ; + +STRUCT: libusb_pollfd + { fd int } + { events short } ; + +CALLBACK: void libusb_pollfd_added_cb ( int fd, short events, void* user_data ) ; +CALLBACK: void libusb_pollfd_removed_cb ( int fd, void* user_data ) ; + +FUNCTION: libusb_pollfd** libusb_get_pollfds ( libusb_context* ctx ) ; +FUNCTION: void libusb_set_pollfd_notifiers ( libusb_context* ctx, + libusb_pollfd_added_cb added_cb, + libusb_pollfd_removed_cb removed_cb, + void* user_data ) ; diff --git a/extra/libusb/summary.txt b/extra/libusb/summary.txt new file mode 100644 index 0000000000..fc00ac5307 --- /dev/null +++ b/extra/libusb/summary.txt @@ -0,0 +1 @@ +Bindings to libusb diff --git a/extra/libusb/tags.txt b/extra/libusb/tags.txt new file mode 100644 index 0000000000..bb863cf9a0 --- /dev/null +++ b/extra/libusb/tags.txt @@ -0,0 +1 @@ +bindings From 220dd88a2ca6d2b7cac84d54773cb055cf253411 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 19 Feb 2010 12:31:52 +1300 Subject: [PATCH 092/713] Update documentation for new help lint check --- basis/calendar/calendar-docs.factor | 6 +-- basis/calendar/calendar.factor | 6 +-- basis/compression/lzw/lzw-docs.factor | 2 - basis/db/tuples/tuples-docs.factor | 2 +- basis/db/tuples/tuples.factor | 2 +- basis/dlists/dlists-docs.factor | 2 +- basis/dlists/dlists.factor | 2 +- .../normalization/normalization-docs.factor | 4 +- .../images/normalization/normalization.factor | 6 +-- basis/lists/lazy/lazy-docs.factor | 2 +- basis/math/bitwise/bitwise-docs.factor | 30 +++++++-------- basis/math/bitwise/bitwise.factor | 38 ++++++++----------- .../combinatorics/combinatorics-docs.factor | 8 ++-- basis/math/combinatorics/combinatorics.factor | 8 ++-- .../math/polynomials/polynomials-docs.factor | 6 +-- basis/math/polynomials/polynomials.factor | 6 +-- .../math/quaternions/quaternions-docs.factor | 2 +- basis/math/quaternions/quaternions.factor | 6 +-- basis/math/statistics/statistics-docs.factor | 2 - basis/opengl/shaders/shaders-docs.factor | 2 +- basis/random/random-docs.factor | 2 +- basis/random/random.factor | 2 +- basis/roman/roman-docs.factor | 10 ++--- basis/roman/roman.factor | 17 +++++---- basis/sequences/deep/deep-docs.factor | 2 +- basis/ui/gadgets/worlds/worlds-docs.factor | 2 +- basis/xml-rpc/xml-rpc-docs.factor | 2 +- basis/xml-rpc/xml-rpc.factor | 2 +- basis/xml/traversal/traversal-docs.factor | 2 +- basis/xml/traversal/traversal.factor | 2 +- core/kernel/kernel-docs.factor | 2 +- core/parser/parser-docs.factor | 2 +- core/sequences/sequences-docs.factor | 23 ++++++----- core/sequences/sequences.factor | 6 +-- extra/game/models/collada/collada-docs.factor | 4 +- extra/game/models/collada/collada.factor | 2 +- extra/game/models/obj/obj-docs.factor | 2 +- extra/gpu/shaders/shaders-docs.factor | 2 +- extra/math/transforms/fft/fft-docs.factor | 2 +- extra/math/transforms/fft/fft.factor | 12 +++--- extra/math/transforms/haar/haar-docs.factor | 4 +- extra/math/transforms/haar/haar.factor | 6 +-- extra/memory/piles/piles-docs.factor | 1 - extra/mongodb/driver/driver-docs.factor | 5 --- extra/spider/spider-docs.factor | 1 - 45 files changed, 120 insertions(+), 139 deletions(-) diff --git a/basis/calendar/calendar-docs.factor b/basis/calendar/calendar-docs.factor index 616c4d2c2c..6ce8b1d5fd 100644 --- a/basis/calendar/calendar-docs.factor +++ b/basis/calendar/calendar-docs.factor @@ -309,7 +309,7 @@ HELP: time- } ; HELP: convert-timezone -{ $values { "timestamp" timestamp } { "duration" duration } { "timestamp" timestamp } } +{ $values { "timestamp" timestamp } { "duration" duration } { "timestamp'" timestamp } } { $description "Converts the " { $snippet "timestamp" } "'s " { $snippet "gmt-offset" } " to the GMT offset represented by the " { $snippet "duration" } "." } { $examples { $example "USING: accessors calendar prettyprint ;" @@ -319,7 +319,7 @@ HELP: convert-timezone } ; HELP: >local-time -{ $values { "timestamp" timestamp } { "timestamp" timestamp } } +{ $values { "timestamp" timestamp } { "timestamp'" timestamp } } { $description "Converts the " { $snippet "timestamp" } " to the timezone of your computer." } { $examples { $example "USING: accessors calendar kernel prettyprint ;" @@ -329,7 +329,7 @@ HELP: >local-time } ; HELP: >gmt -{ $values { "timestamp" timestamp } { "timestamp" timestamp } } +{ $values { "timestamp" timestamp } { "timestamp'" timestamp } } { $description "Converts the " { $snippet "timestamp" } " to the GMT timezone." } { $examples { $example "USING: accessors calendar kernel prettyprint ;" diff --git a/basis/calendar/calendar.factor b/basis/calendar/calendar.factor index 3940af4856..1a64ceb646 100644 --- a/basis/calendar/calendar.factor +++ b/basis/calendar/calendar.factor @@ -316,15 +316,15 @@ M: duration <=> [ duration>years ] compare ; GENERIC: time- ( time1 time2 -- time3 ) -: convert-timezone ( timestamp duration -- timestamp ) +: convert-timezone ( timestamp duration -- timestamp' ) over gmt-offset>> over = [ drop ] [ [ over gmt-offset>> time- time+ ] keep >>gmt-offset ] if ; -: >local-time ( timestamp -- timestamp ) +: >local-time ( timestamp -- timestamp' ) gmt-offset-duration convert-timezone ; -: >gmt ( timestamp -- timestamp ) +: >gmt ( timestamp -- timestamp' ) instant convert-timezone ; M: timestamp <=> ( ts1 ts2 -- n ) diff --git a/basis/compression/lzw/lzw-docs.factor b/basis/compression/lzw/lzw-docs.factor index 28dc36902b..55c54bc9f7 100644 --- a/basis/compression/lzw/lzw-docs.factor +++ b/basis/compression/lzw/lzw-docs.factor @@ -20,7 +20,6 @@ HELP: tiff-lzw-uncompress HELP: lzw-read { $values - { "lzw" lzw } { "lzw" lzw } { "n" integer } } { $description "Read the next LZW code." } ; @@ -48,7 +47,6 @@ HELP: code-space-full? HELP: reset-lzw-uncompress { $values { "lzw" lzw } - { "lzw" lzw } } { $description "Reset the LZW uncompressor state (either at initialization time or immediately after receiving a Clear Code). " } ; diff --git a/basis/db/tuples/tuples-docs.factor b/basis/db/tuples/tuples-docs.factor index 01d65484f3..2c5db1c90d 100644 --- a/basis/db/tuples/tuples-docs.factor +++ b/basis/db/tuples/tuples-docs.factor @@ -51,7 +51,7 @@ HELP: HELP: { $values { "tuple" tuple } { "class" class } - { "tuple" tuple } } + { "statement" tuple } } { $description "A database-specific hook for generating the SQL for a select statement." } ; HELP: diff --git a/basis/db/tuples/tuples.factor b/basis/db/tuples/tuples.factor index 388c9ba47e..d193b5921e 100644 --- a/basis/db/tuples/tuples.factor +++ b/basis/db/tuples/tuples.factor @@ -14,7 +14,7 @@ HOOK: db-connection ( class -- object ) HOOK: db-connection ( class -- object ) HOOK: db-connection ( class -- object ) HOOK: db-connection ( tuple class -- object ) -HOOK: db-connection ( tuple class -- tuple ) +HOOK: db-connection ( tuple class -- statement ) HOOK: db-connection ( query -- statement ) HOOK: query>statement db-connection ( query -- statement ) HOOK: insert-tuple-set-key db-connection ( tuple statement -- ) diff --git a/basis/dlists/dlists-docs.factor b/basis/dlists/dlists-docs.factor index 716c20d6f6..5036441f60 100644 --- a/basis/dlists/dlists-docs.factor +++ b/basis/dlists/dlists-docs.factor @@ -48,7 +48,7 @@ HELP: dlist-find } ; HELP: dlist-filter -{ $values { "dlist" { $link dlist } } { "quot" quotation } { "dlist" { $link dlist } } } +{ $values { "dlist" { $link dlist } } { "quot" quotation } { "dlist'" { $link dlist } } } { $description "Applies the quotation to each element of the " { $link dlist } " in turn, removing the corresponding nodes if the quotation returns " { $link f } "." } { $side-effects { "dlist" } } ; diff --git a/basis/dlists/dlists.factor b/basis/dlists/dlists.factor index 668ba23054..317ed81e3e 100644 --- a/basis/dlists/dlists.factor +++ b/basis/dlists/dlists.factor @@ -157,7 +157,7 @@ M: dlist clear-deque ( dlist -- ) : 1dlist ( obj -- dlist ) [ push-front ] keep ; -: dlist-filter ( dlist quot -- dlist ) +: dlist-filter ( dlist quot -- dlist' ) over [ '[ dup obj>> @ [ drop ] [ _ delete-node ] if ] dlist-each-node ] keep ; inline M: dlist clone diff --git a/basis/images/normalization/normalization-docs.factor b/basis/images/normalization/normalization-docs.factor index 8ed4b659ed..39e2fee769 100644 --- a/basis/images/normalization/normalization-docs.factor +++ b/basis/images/normalization/normalization-docs.factor @@ -6,14 +6,14 @@ IN: images.normalization HELP: normalize-image { $values { "image" image } - { "image" image } + { "image'" image } } { $description "Converts the image to RGBA with ubyte-components. If the image is upside-down, it will be flipped right side up such that the 1st byte in the bitmap slot's byte array corresponds to the first color component of the pixel in the upper-left corner of the image." } ; HELP: reorder-components { $values { "image" image } { "component-order" component-order } - { "image" image } + { "image'" image } } { $description "Convert the bitmap in " { $snippet "image" } " such that the pixel sample layout corresponds to " { $snippet "component-order" } ". If the destination layout cannot find a corresponding value from the source layout, the value " { $snippet "255" } " will be substituted for that byte." } { $warning "The image's " { $snippet "component-type" } " will be changed to " { $snippet "ubyte-components" } " if it is not already in that format." diff --git a/basis/images/normalization/normalization.factor b/basis/images/normalization/normalization.factor index 2bd7e6883f..6eaca01e15 100644 --- a/basis/images/normalization/normalization.factor +++ b/basis/images/normalization/normalization.factor @@ -55,7 +55,7 @@ M: ushort-components normalize-component-type* M: ubyte-components normalize-component-type* drop ; -: normalize-scan-line-order ( image -- image ) +: normalize-scan-line-order ( image -- image' ) dup upside-down?>> [ dup dim>> first 4 * '[ _ reverse concat @@ -71,14 +71,14 @@ M: ubyte-components normalize-component-type* PRIVATE> -: reorder-components ( image component-order -- image ) +: reorder-components ( image component-order -- image' ) [ dup component-type>> '[ _ normalize-component-type* ] change-bitmap dup component-order>> ] dip validate-request [ (reorder-components) ] keep >>component-order ; -: normalize-image ( image -- image ) +: normalize-image ( image -- image' ) [ >byte-array ] change-bitmap RGBA reorder-components normalize-scan-line-order ; diff --git a/basis/lists/lazy/lazy-docs.factor b/basis/lists/lazy/lazy-docs.factor index 3b23e1186e..201764bd95 100644 --- a/basis/lists/lazy/lazy-docs.factor +++ b/basis/lists/lazy/lazy-docs.factor @@ -144,7 +144,7 @@ HELP: lcomp { $description "Get the cartesian product of the lists in " { $snippet "list" } " and call " { $snippet "quot" } " call with each element from the cartesian product on the stack, the result of which is returned in the final " { $snippet "list" } "." } ; HELP: lcomp* -{ $values { "list" "a list of lists" } { "guards" "a sequence of quotations with stack effect ( seq -- bool )" } { "quot" { $quotation "( seq -- X )" } } { "list" "the resulting list" } { "result" "a list" } } +{ $values { "list" "a list of lists" } { "guards" "a sequence of quotations with stack effect ( seq -- bool )" } { "quot" { $quotation "( seq -- X )" } } { "result" "a list" } } { $description "Get the cartesian product of the lists in " { $snippet "list" } ", filter it by applying each guard quotation to it and call " { $snippet "quot" } " call with each element from the remaining cartesian product items on the stack, the result of which is returned in the final " { $snippet "list" } "." } { $examples { $code "{ 1 2 3 } >list { 4 5 6 } >list 2list { [ first odd? ] } [ first2 + ] lcomp*" } diff --git a/basis/math/bitwise/bitwise-docs.factor b/basis/math/bitwise/bitwise-docs.factor index 5dce9646f4..bbc72d99e4 100644 --- a/basis/math/bitwise/bitwise-docs.factor +++ b/basis/math/bitwise/bitwise-docs.factor @@ -88,10 +88,10 @@ HELP: bit-count HELP: bitroll-32 { $values - { "n" integer } { "s" integer } - { "n'" integer } + { "m" integer } { "s" integer } + { "n" integer } } -{ $description "Rolls the number " { $snippet "n" } " by " { $snippet "s" } " bits to the left, wrapping around after 32 bits." } +{ $description "Rolls the number " { $snippet "m" } " by " { $snippet "s" } " bits to the left, wrapping around after 32 bits." } { $examples { $example "USING: math.bitwise prettyprint ;" "HEX: 1 10 bitroll-32 .h" @@ -105,10 +105,10 @@ HELP: bitroll-32 HELP: bitroll-64 { $values - { "n" integer } { "s" "a shift integer" } - { "n'" integer } + { "m" integer } { "s" "a shift integer" } + { "n" integer } } -{ $description "Rolls the number " { $snippet "n" } " by " { $snippet "s" } " bits to the left, wrapping around after 64 bits." } +{ $description "Rolls the number " { $snippet "m" } " by " { $snippet "s" } " bits to the left, wrapping around after 64 bits." } { $examples { $example "USING: math.bitwise prettyprint ;" "HEX: 1 10 bitroll-64 .h" @@ -226,10 +226,10 @@ HELP: odd-parity? HELP: on-bits { $values - { "n" integer } { "m" integer } + { "n" integer } } -{ $description "Returns an integer with " { $snippet "n" } " bits set." } +{ $description "Returns an integer with " { $snippet "m" } " bits set." } { $examples { $example "USING: math.bitwise kernel prettyprint ;" "6 on-bits .h" @@ -274,7 +274,7 @@ HELP: set-bit HELP: shift-mod { $values - { "n" integer } { "s" integer } { "w" integer } + { "m" integer } { "s" integer } { "w" integer } { "n" integer } } { $description "Calls " { $link shift } " on " { $snippet "n" } " and " { $snippet "s" } ", wrapping the result to " { $snippet "w" } " bits." } ; @@ -307,8 +307,8 @@ HELP: unmask? HELP: w* { $values - { "int" integer } { "int" integer } - { "int" integer } + { "x" integer } { "y" integer } + { "z" integer } } { $description "Multiplies two integers and wraps the result to 32 bits." } { $examples @@ -320,8 +320,8 @@ HELP: w* HELP: w+ { $values - { "int" integer } { "int" integer } - { "int" integer } + { "x" integer } { "y" integer } + { "z" integer } } { $description "Adds two integers and wraps the result to 32 bits." } { $examples @@ -333,8 +333,8 @@ HELP: w+ HELP: w- { $values - { "int" integer } { "int" integer } - { "int" integer } + { "x" integer } { "y" integer } + { "z" integer } } { $description "Subtracts two integers and wraps the result to 32 bits." } { $examples diff --git a/basis/math/bitwise/bitwise.factor b/basis/math/bitwise/bitwise.factor index 6b301fa97b..e508b49a19 100644 --- a/basis/math/bitwise/bitwise.factor +++ b/basis/math/bitwise/bitwise.factor @@ -17,29 +17,32 @@ IN: math.bitwise : wrap ( m n -- m' ) 1 - bitand ; inline : bits ( m n -- m' ) 2^ wrap ; inline : mask-bit ( m n -- m' ) 2^ mask ; inline -: on-bits ( n -- m ) 2^ 1 - ; inline +: on-bits ( m -- n ) 2^ 1 - ; inline : toggle-bit ( m n -- m' ) 2^ bitxor ; inline - -: shift-mod ( n s w -- n ) - [ shift ] dip 2^ wrap ; inline +: >signed ( x n -- y ) 2dup neg 1 + shift 1 = [ 2^ - ] [ drop ] if ; +: >odd ( m -- n ) 0 set-bit ; foldable +: >even ( m -- n ) 0 clear-bit ; foldable +: next-even ( m -- n ) >even 2 + ; foldable +: next-odd ( m -- n ) dup even? [ 1 + ] [ 2 + ] if ; foldable +: shift-mod ( m s w -- n ) [ shift ] dip 2^ wrap ; inline : bitroll ( x s w -- y ) [ wrap ] keep [ shift-mod ] [ [ - ] keep shift-mod ] 3bi bitor ; inline -: bitroll-32 ( n s -- n' ) 32 bitroll ; inline +: bitroll-32 ( m s -- n ) 32 bitroll ; inline -: bitroll-64 ( n s -- n' ) 64 bitroll ; inline +: bitroll-64 ( m s -- n ) 64 bitroll ; inline ! 32-bit arithmetic -: w+ ( int int -- int ) + 32 bits ; inline -: w- ( int int -- int ) - 32 bits ; inline -: w* ( int int -- int ) * 32 bits ; inline +: w+ ( x y -- z ) + 32 bits ; inline +: w- ( x y -- z ) - 32 bits ; inline +: w* ( x y -- z ) * 32 bits ; inline ! 64-bit arithmetic -: W+ ( int int -- int ) + 64 bits ; inline -: W- ( int int -- int ) - 64 bits ; inline -: W* ( int int -- int ) * 64 bits ; inline +: W+ ( x y -- z ) + 64 bits ; inline +: W- ( x y -- z ) - 64 bits ; inline +: W* ( x y -- z ) * 64 bits ; inline ! flags MACRO: flags ( values -- ) @@ -117,17 +120,6 @@ M: object bit-count [ >c-ptr ] [ byte-length ] bi byte-array-bit-count ; -: >signed ( x n -- y ) - 2dup neg 1 + shift 1 = [ 2^ - ] [ drop ] if ; - -: >odd ( n -- int ) 0 set-bit ; foldable - -: >even ( n -- int ) 0 clear-bit ; foldable - -: next-even ( m -- n ) >even 2 + ; foldable - -: next-odd ( m -- n ) dup even? [ 1 + ] [ 2 + ] if ; foldable - : even-parity? ( obj -- ? ) bit-count even? ; : odd-parity? ( obj -- ? ) bit-count odd? ; diff --git a/basis/math/combinatorics/combinatorics-docs.factor b/basis/math/combinatorics/combinatorics-docs.factor index ec3cd6ee76..0a2a0d4011 100644 --- a/basis/math/combinatorics/combinatorics-docs.factor +++ b/basis/math/combinatorics/combinatorics-docs.factor @@ -26,7 +26,7 @@ HELP: nCk } ; HELP: permutation -{ $values { "n" "a non-negative integer" } { "seq" sequence } { "seq" sequence } } +{ $values { "n" "a non-negative integer" } { "seq" sequence } { "seq'" sequence } } { $description "Outputs the " { $snippet "nth" } " lexicographical permutation of " { $snippet "seq" } "." } { $notes "Permutations are 0-based and a bounds error will be thrown if " { $snippet "n" } " is larger than " { $snippet "seq length factorial 1 -" } "." } { $examples @@ -37,7 +37,7 @@ HELP: permutation } ; HELP: all-permutations -{ $values { "seq" sequence } { "seq" sequence } } +{ $values { "seq" sequence } { "seq'" sequence } } { $description "Outputs a sequence containing all permutations of " { $snippet "seq" } " in lexicographical order." } { $examples { $example "USING: math.combinatorics prettyprint ;" @@ -60,7 +60,7 @@ HELP: inverse-permutation } ; HELP: combination -{ $values { "m" "a non-negative integer" } { "seq" sequence } { "k" "a non-negative integer" } { "seq" sequence } } +{ $values { "m" "a non-negative integer" } { "seq" sequence } { "k" "a non-negative integer" } { "seq'" sequence } } { $description "Outputs the " { $snippet "mth" } " lexicographical combination of " { $snippet "seq" } " choosing " { $snippet "k" } " elements." } { $notes "Combinations are 0-based and a bounds error will be thrown if " { $snippet "m" } " is larger than " { $snippet "seq length k nCk" } "." } { $examples @@ -71,7 +71,7 @@ HELP: combination } ; HELP: all-combinations -{ $values { "seq" sequence } { "k" "a non-negative integer" } { "seq" sequence } } +{ $values { "seq" sequence } { "k" "a non-negative integer" } { "seq'" sequence } } { $description "Outputs a sequence containing all combinations of " { $snippet "seq" } " choosing " { $snippet "k" } " elements, in lexicographical order." } { $examples { $example "USING: math.combinatorics prettyprint ;" diff --git a/basis/math/combinatorics/combinatorics.factor b/basis/math/combinatorics/combinatorics.factor index 7c68aede09..5a9f627015 100644 --- a/basis/math/combinatorics/combinatorics.factor +++ b/basis/math/combinatorics/combinatorics.factor @@ -42,10 +42,10 @@ PRIVATE> PRIVATE> -: permutation ( n seq -- seq ) +: permutation ( n seq -- seq' ) [ permutation-indices ] keep nths ; -: all-permutations ( seq -- seq ) +: all-permutations ( seq -- seq' ) [ length factorial iota ] keep '[ _ permutation ] map ; @@ -118,10 +118,10 @@ PRIVATE> : map>assoc-combinations ( seq k quot exemplar -- ) [ combinations-quot ] dip map>assoc ; inline -: combination ( m seq k -- seq ) +: combination ( m seq k -- seq' ) apply-combination ; -: all-combinations ( seq k -- seq ) +: all-combinations ( seq k -- seq' ) [ ] combinations-quot map ; : reduce-combinations ( seq k identity quot -- result ) diff --git a/basis/math/polynomials/polynomials-docs.factor b/basis/math/polynomials/polynomials-docs.factor index 9c16bf8a7e..3b8885cc88 100644 --- a/basis/math/polynomials/polynomials-docs.factor +++ b/basis/math/polynomials/polynomials-docs.factor @@ -36,12 +36,12 @@ HELP: p= { $examples { $example "USING: math.polynomials prettyprint ;" "{ 0 1 } { 0 1 0 } p= ." "t" } } ; HELP: ptrim -{ $values { "p" "a polynomial" } { "p" "a polynomial" } } +{ $values { "p" "a polynomial" } { "q" "a polynomial" } } { $description "Trims excess zeros from a polynomial." } { $examples { $example "USING: math.polynomials prettyprint ;" "{ 0 1 0 0 } ptrim ." "{ 0 1 }" } } ; HELP: 2ptrim -{ $values { "p" "a polynomial" } { "q" "a polynomial" } { "p" "a polynomial" } { "q" "a polynomial" } } +{ $values { "p" "a polynomial" } { "q" "a polynomial" } { "p'" "a polynomial" } { "q'" "a polynomial" } } { $description "Trims excess zeros from two polynomials." } { $examples { $example "USING: kernel math.polynomials prettyprint ;" "{ 0 1 0 0 } { 1 0 0 } 2ptrim [ . ] bi@" "{ 0 1 }\n{ 1 }" } } ; @@ -61,7 +61,7 @@ HELP: n*p { $examples { $example "USING: math.polynomials prettyprint ;" "4 { 3 0 1 } n*p ." "{ 12 0 4 }" } } ; HELP: pextend-conv -{ $values { "p" "a polynomial" } { "q" "a polynomial" } { "p" "a polynomial" } { "q" "a polynomial" } } +{ $values { "p" "a polynomial" } { "q" "a polynomial" } { "p'" "a polynomial" } { "q'" "a polynomial" } } { $description "Convulution, extending to " { $snippet "p_m + q_n - 1" } "." } { $examples { $example "USING: kernel math.polynomials prettyprint ;" "{ 1 0 1 } { 0 1 } pextend-conv [ . ] bi@" "V{ 1 0 1 0 }\nV{ 0 1 0 0 }" } } ; diff --git a/basis/math/polynomials/polynomials.factor b/basis/math/polynomials/polynomials.factor index b994410283..31152016ea 100644 --- a/basis/math/polynomials/polynomials.factor +++ b/basis/math/polynomials/polynomials.factor @@ -20,15 +20,15 @@ PRIVATE> : p= ( p q -- ? ) pextend = ; -: ptrim ( p -- p ) +: ptrim ( p -- q ) dup length 1 = [ [ zero? ] trim-tail ] unless ; -: 2ptrim ( p q -- p q ) [ ptrim ] bi@ ; +: 2ptrim ( p q -- p' q' ) [ ptrim ] bi@ ; : p+ ( p q -- r ) pextend v+ ; : p- ( p q -- r ) pextend v- ; : n*p ( n p -- n*p ) n*v ; -: pextend-conv ( p q -- p q ) +: pextend-conv ( p q -- p' q' ) 2dup [ length ] bi@ + 1 - 2pad-tail [ >vector ] bi@ ; : p* ( p q -- r ) diff --git a/basis/math/quaternions/quaternions-docs.factor b/basis/math/quaternions/quaternions-docs.factor index 1a381c6287..d3bead7dea 100644 --- a/basis/math/quaternions/quaternions-docs.factor +++ b/basis/math/quaternions/quaternions-docs.factor @@ -30,7 +30,7 @@ HELP: q/ { $examples { $example "USING: math.quaternions prettyprint ;" "{ 0 0 0 1 } { 0 0 1 0 } q/ ." "{ 0 1 0 0 }" } } ; HELP: q*n -{ $values { "q" "a quaternion" } { "n" real } { "q" "a quaternion" } } +{ $values { "q" "a quaternion" } { "n" real } { "r" "a quaternion" } } { $description "Multiplies each element of " { $snippet "q" } " by real value " { $snippet "n" } "." } { $notes "To multiply a quaternion with a complex value, use " { $link c>q } " " { $link q* } "." } ; diff --git a/basis/math/quaternions/quaternions.factor b/basis/math/quaternions/quaternions.factor index e659cf5f61..4173507e6c 100644 --- a/basis/math/quaternions/quaternions.factor +++ b/basis/math/quaternions/quaternions.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2005, 2007 Slava Pestov. +! Copyright (C) 2005, 2010 Joe Groff, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays combinators kernel locals math math.functions math.libm math.order math.vectors sequences ; @@ -35,10 +35,10 @@ M: object qconjugate ( u -- u' ) : q/ ( u v -- u/v ) qrecip q* ; inline -: n*q ( q n -- q ) +: n*q ( q n -- r ) v*n ; inline -: q*n ( q n -- q ) +: q*n ( q n -- r ) v*n ; inline : n>q ( n -- q ) diff --git a/basis/math/statistics/statistics-docs.factor b/basis/math/statistics/statistics-docs.factor index 6fa7d79f77..f7d108dddb 100644 --- a/basis/math/statistics/statistics-docs.factor +++ b/basis/math/statistics/statistics-docs.factor @@ -87,7 +87,6 @@ HELP: histogram HELP: histogram! { $values { "hashtable" hashtable } { "seq" sequence } - { "hashtable" hashtable } } { $examples { $example "! Count the number of times the elements of two sequences appear." @@ -128,7 +127,6 @@ HELP: sequence>assoc HELP: sequence>assoc! { $values { "assoc" assoc } { "seq" sequence } { "quot" quotation } - { "assoc" assoc } } { $examples { $example "! Iterate over a sequence and add the counts to an existing assoc" diff --git a/basis/opengl/shaders/shaders-docs.factor b/basis/opengl/shaders/shaders-docs.factor index 1a10071ddf..c3e4d045ef 100644 --- a/basis/opengl/shaders/shaders-docs.factor +++ b/basis/opengl/shaders/shaders-docs.factor @@ -52,7 +52,7 @@ HELP: delete-gl-shader { $description "Deletes the shader object, invalidating it and releasing any resources allocated for it by the OpenGL implementation." } ; HELP: gl-shader-info-log -{ $values { "shader" "A " { $link gl-shader } " object" } { "shader" "a new " { $link gl-shader } } { "log" string } } +{ $values { "shader" "A " { $link gl-shader } " object" } { "log" string } } { $description "Retrieves the info log for " { $snippet "shader" } ", including any errors or warnings generated in compiling the shader object." } ; HELP: gl-program diff --git a/basis/random/random-docs.factor b/basis/random/random-docs.factor index 175c34ad9d..20d5dc0214 100644 --- a/basis/random/random-docs.factor +++ b/basis/random/random-docs.factor @@ -75,7 +75,7 @@ HELP: with-system-random HELP: randomize { $values { "seq" sequence } - { "seq" sequence } + { "randomized" sequence } } { $description "Randomizes a sequence in-place with the Fisher-Yates algorithm and returns the sequence." } ; diff --git a/basis/random/random.factor b/basis/random/random.factor index eeaa1f8f2c..ba5d9c7ca3 100644 --- a/basis/random/random.factor +++ b/basis/random/random.factor @@ -67,7 +67,7 @@ M: sequence random [ [ random ] [ 1 - ] bi [ pick exchange ] keep ] while drop ; -: randomize ( seq -- seq ) +: randomize ( seq -- randomized ) dup length randomize-n-last ; ERROR: too-many-samples seq n ; diff --git a/basis/roman/roman-docs.factor b/basis/roman/roman-docs.factor index c81ed0ae42..c9c3db71b5 100644 --- a/basis/roman/roman-docs.factor +++ b/basis/roman/roman-docs.factor @@ -39,7 +39,7 @@ HELP: roman> { >roman >ROMAN roman> } related-words HELP: roman+ -{ $values { "x" string } { "x" string } { "x" string } } +{ $values { "x" string } { "y" string } { "z" string } } { $description "Adds two Roman numerals." } { $examples { $example "USING: io roman ;" @@ -49,7 +49,7 @@ HELP: roman+ } ; HELP: roman- -{ $values { "x" string } { "x" string } { "x" string } } +{ $values { "x" string } { "y" string } { "z" string } } { $description "Subtracts two Roman numerals." } { $examples { $example "USING: io roman ;" @@ -61,7 +61,7 @@ HELP: roman- { roman+ roman- } related-words HELP: roman* -{ $values { "x" string } { "x" string } { "x" string } } +{ $values { "x" string } { "y" string } { "z" string } } { $description "Multiplies two Roman numerals." } { $examples { $example "USING: io roman ;" @@ -71,7 +71,7 @@ HELP: roman* } ; HELP: roman/i -{ $values { "x" string } { "x" string } { "x" string } } +{ $values { "x" string } { "y" string } { "z" string } } { $description "Computes the integer division of two Roman numerals." } { $examples { $example "USING: io roman ;" @@ -81,7 +81,7 @@ HELP: roman/i } ; HELP: roman/mod -{ $values { "x" string } { "x" string } { "x" string } { "x" string } } +{ $values { "x" string } { "y" string } { "z" string } { "w" string } } { $description "Computes the quotient and remainder of two Roman numerals." } { $examples { $example "USING: kernel io roman ;" diff --git a/basis/roman/roman.factor b/basis/roman/roman.factor index a783e7973c..588166829a 100644 --- a/basis/roman/roman.factor +++ b/basis/roman/roman.factor @@ -2,8 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs effects fry generalizations grouping kernel lexer macros math math.order math.vectors -namespaces parser quotations sequences sequences.private -splitting.monotonic stack-checker strings unicode.case words ; +namespaces parser effects.parser quotations sequences +sequences.private splitting.monotonic stack-checker strings +unicode.case words ; IN: roman SYNTAX: ROMAN-OP: scan-word [ name>> "roman" prepend create-in ] keep 1quotation '[ _ binary-roman-op ] - dup infer define-declared ; + complete-effect define-declared ; >> -ROMAN-OP: + -ROMAN-OP: - -ROMAN-OP: * -ROMAN-OP: /i -ROMAN-OP: /mod +ROMAN-OP: + ( x y -- z ) +ROMAN-OP: - ( x y -- z ) +ROMAN-OP: * ( x y -- z ) +ROMAN-OP: /i ( x y -- z ) +ROMAN-OP: /mod ( x y -- z w ) SYNTAX: ROMAN: scan roman> suffix! ; diff --git a/basis/sequences/deep/deep-docs.factor b/basis/sequences/deep/deep-docs.factor index e8b9ddea6d..6f479e48b6 100644 --- a/basis/sequences/deep/deep-docs.factor +++ b/basis/sequences/deep/deep-docs.factor @@ -31,7 +31,7 @@ HELP: flatten { $description "Creates a sequence of all of the leaf nodes (non-sequence nodes, but including strings and numbers) in the object." } ; HELP: deep-map! -{ $values { "obj" object } { "quot" { $quotation "( elt -- newelt )" } } { "obj" object } } +{ $values { "obj" object } { "quot" { $quotation "( elt -- newelt )" } } } { $description "Modifies each sub-node of an object in place, in preorder, and returns that object." } { $see-also map! } ; diff --git a/basis/ui/gadgets/worlds/worlds-docs.factor b/basis/ui/gadgets/worlds/worlds-docs.factor index 83d042db43..0d7e40a789 100644 --- a/basis/ui/gadgets/worlds/worlds-docs.factor +++ b/basis/ui/gadgets/worlds/worlds-docs.factor @@ -33,7 +33,7 @@ HELP: set-gl-context { $description "Selects an OpenGL context to be the implicit destination for subsequent GL rendering calls. This word is called automatically by the UI before drawing a " { $link world } "." } ; HELP: window-resource -{ $values { "resource" disposable } { "resource" disposable } } +{ $values { "resource" disposable } } { $description "Marks " { $snippet "resource" } " to be destroyed with " { $link dispose } " when the window with the currently active OpenGL context (set by " { $link set-gl-context } ") is closed. " { $snippet "resource" } " is left unmodified at the top of the stack." } ; HELP: flush-gl-context diff --git a/basis/xml-rpc/xml-rpc-docs.factor b/basis/xml-rpc/xml-rpc-docs.factor index 113fc00407..aeb29c5d07 100644 --- a/basis/xml-rpc/xml-rpc-docs.factor +++ b/basis/xml-rpc/xml-rpc-docs.factor @@ -49,7 +49,7 @@ HELP: rpc-fault HELP: post-rpc { $values { "rpc" "an XML-RPC input tuple" } { "url" "a URL" } - { "rpc" "an XML-RPC output tuple" } } + { "rpc'" "an XML-RPC output tuple" } } { $description "posts an XML-RPC document to the specified URL, receives the response and parses it as XML-RPC, returning the tuple" } ; ARTICLE: { "xml-rpc" "intro" } "XML-RPC" diff --git a/basis/xml-rpc/xml-rpc.factor b/basis/xml-rpc/xml-rpc.factor index 370c778787..4c6570c4de 100644 --- a/basis/xml-rpc/xml-rpc.factor +++ b/basis/xml-rpc/xml-rpc.factor @@ -186,7 +186,7 @@ TAG: array xml>item PRIVATE> -: post-rpc ( rpc url -- rpc ) +: post-rpc ( rpc url -- rpc' ) ! This needs to do something in the event of an error rpc-post-request http-request nip string>xml receive-rpc ; diff --git a/basis/xml/traversal/traversal-docs.factor b/basis/xml/traversal/traversal-docs.factor index bb7ce7ce31..d8032d99fc 100644 --- a/basis/xml/traversal/traversal-docs.factor +++ b/basis/xml/traversal/traversal-docs.factor @@ -58,7 +58,7 @@ HELP: children-tags { $see-also first-child-tag } ; HELP: first-child-tag -{ $values { "tag" "an XML tag or document" } { "tag" tag } } +{ $values { "tag" "an XML tag or document" } { "child" tag } } { $description "Returns the first child of the given tag that is a tag." } { $see-also children-tags } ; diff --git a/basis/xml/traversal/traversal.factor b/basis/xml/traversal/traversal.factor index b337ea1472..46a5896814 100644 --- a/basis/xml/traversal/traversal.factor +++ b/basis/xml/traversal/traversal.factor @@ -18,7 +18,7 @@ IN: xml.traversal : children-tags ( tag -- sequence ) children>> [ tag? ] filter ; -: first-child-tag ( tag -- tag ) +: first-child-tag ( tag -- child ) children>> [ tag? ] find nip ; : tag-named? ( name elem -- ? ) diff --git a/core/kernel/kernel-docs.factor b/core/kernel/kernel-docs.factor index c92ef7d599..8b9650fc31 100644 --- a/core/kernel/kernel-docs.factor +++ b/core/kernel/kernel-docs.factor @@ -708,7 +708,7 @@ HELP: 3curry { $notes "This operation is efficient and does not copy the quotation." } ; HELP: with -{ $values { "param" object } { "obj" object } { "quot" { $quotation "( param elt -- ... )" } } { "obj" object } { "curry" curry } } +{ $values { "param" object } { "obj" object } { "quot" { $quotation "( param elt -- ... )" } } { "curry" curry } } { $description "Partial application on the left. The following two lines are equivalent:" { $code "swap [ swap A ] curry B" } { $code "[ A ] with B" } diff --git a/core/parser/parser-docs.factor b/core/parser/parser-docs.factor index 3062f55a42..b024d1d968 100644 --- a/core/parser/parser-docs.factor +++ b/core/parser/parser-docs.factor @@ -177,7 +177,7 @@ HELP: parse-lines { $errors "Throws a " { $link lexer-error } " if the input is malformed." } ; HELP: parse-base -{ $values { "parsed" integer } { "base" "an integer between 2 and 36" } { "parsed" integer } } +{ $values { "parsed" integer } { "base" "an integer between 2 and 36" } } { $description "Reads an integer in a specific numerical base from the parser input." } $parsing-note ; diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 02dadb323c..38eadc745d 100644 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -296,7 +296,7 @@ $nl } ; HELP: accumulate! -{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( prev elt -- next )" } } { "final" "the final result" } { "seq" sequence } } +{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( prev elt -- next )" } } { "final" "the final result" } } { $description "Combines successive elements of the sequence using a binary operation, and outputs the original sequence of intermediate results, together with the final result." $nl "The first element of the new sequence is " { $snippet "identity" } ". Then, on the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the old sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the old sequence." @@ -344,7 +344,7 @@ HELP: change-nth { $side-effects "seq" } ; HELP: map! -{ $values { "seq" "a mutable sequence" } { "quot" { $quotation "( old -- new )" } } { "seq" "a mutable sequence" } } +{ $values { "seq" "a mutable sequence" } { "quot" { $quotation "( old -- new )" } } } { $description "Applies the quotation to each element yielding a new element, storing the new elements back in the original sequence. Returns the original sequence." } { $errors "Throws an error if the sequence is immutable, or the sequence cannot hold elements of the type output by " { $snippet "quot" } "." } { $side-effects "seq" } ; @@ -442,7 +442,7 @@ HELP: filter-as { $description "Applies the quotation to each element in turn, and outputs a new sequence of the same type as " { $snippet "exemplar" } " containing the elements of the original sequence for which the quotation output a true value." } ; HELP: filter! -{ $values { "seq" "a resizable mutable sequence" } { "quot" { $quotation "( elt -- ? )" } } { "seq" "a resizable mutable sequence" } } +{ $values { "seq" "a resizable mutable sequence" } { "quot" { $quotation "( elt -- ? )" } } } { $description "Applies the quotation to each element in turn, and removes elements for which the quotation outputs a false value." } { $side-effects "seq" } ; @@ -503,19 +503,19 @@ HELP: move { $side-effects "seq" } ; HELP: remove! -{ $values { "elt" object } { "seq" "a resizable mutable sequence" } { "elt" object } } +{ $values { "elt" object } { "seq" "a resizable mutable sequence" } } { $description "Removes all elements equal to " { $snippet "elt" } " from " { $snippet "seq" } " and returns " { $snippet "seq" } "." } { $notes "This word uses equality comparison (" { $link = } ")." } { $side-effects "seq" } ; HELP: remove-eq! -{ $values { "elt" object } { "seq" "a resizable mutable sequence" } { "seq" "a resizable mutable sequence" } } +{ $values { "elt" object } { "seq" "a resizable mutable sequence" } } { $description "Outputs a new sequence containing all elements of the input sequence except the given element." } { $notes "This word uses identity comparison (" { $link eq? } ")." } { $side-effects "seq" } ; HELP: remove-nth! -{ $values { "n" "a non-negative integer" } { "seq" "a resizable mutable sequence" } { "seq" "a resizable mutable sequence" } } +{ $values { "n" "a non-negative integer" } { "seq" "a resizable mutable sequence" } } { $description "Removes the " { $snippet "n" } "th element from the sequence, shifting all other elements down and reducing its length by one." } { $side-effects "seq" } ; @@ -540,7 +540,7 @@ HELP: suffix } ; HELP: suffix! -{ $values { "seq" sequence } { "elt" object } { "seq" sequence } } +{ $values { "seq" sequence } { "elt" object } } { $description "Modifiers a sequence in-place by adding " { $snippet "elt" } " to the end of " { $snippet "seq" } ". Outputs " { $snippet "seq" } "." } { $errors "Throws an error if the type of " { $snippet "elt" } " is not permitted in sequences of the same class as " { $snippet "seq" } "." } { $examples @@ -548,7 +548,7 @@ HELP: suffix! } ; HELP: append! -{ $values { "seq1" sequence } { "seq2" sequence } { "seq1" sequence } } +{ $values { "seq1" sequence } { "seq2" sequence } } { $description "Modifiers " { $snippet "seq1" } " in-place by adding the elements from " { $snippet "seq2" } " to the end and outputs " { $snippet "seq1" } "." } { $examples { $example "USING: prettyprint sequences ;" "V{ 1 2 3 } { 4 5 6 } append! ." "V{ 1 2 3 4 5 6 }" } @@ -996,7 +996,7 @@ HELP: count HELP: selector { $values { "quot" "a predicate quotation" } - { "quot" quotation } { "accum" vector } } + { "selector" quotation } { "accum" vector } } { $description "Creates a new vector to accumulate the values which return true for a predicate. Returns a new quotation which accepts an object to be tested and stored in the collector if the test yields true. The collector is left on the stack for convenience." } { $example "! Find all the even numbers:" "USING: prettyprint sequences math kernel ;" "10 iota [ even? ] selector [ each ] dip ." @@ -1202,7 +1202,7 @@ HELP: 2map-reduce HELP: 2selector { $values { "quot" quotation } - { "quot" quotation } { "accum1" vector } { "accum2" vector } } + { "selector" quotation } { "accum1" vector } { "accum2" vector } } { $description "Creates two new vectors to accumultate values based on a predicate. The first vector accumulates values for which the predicate yields true; the second for false." } ; HELP: 2reverse-each @@ -1323,8 +1323,7 @@ HELP: sequence-hashcode-step HELP: short { $values - { "seq" sequence } { "n" integer } - { "seq" sequence } { "n'" integer } } + { "seq" sequence } { "n" integer } { "n'" integer } } { $description "Returns the input sequence and its length or " { $snippet "n" } ", whichever is less." } { $examples { $example "USING: sequences kernel prettyprint ;" "\"abcd\" 3 short [ . ] bi@" diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 23ab4b5d84..2eafe2ceb8 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -486,10 +486,10 @@ PRIVATE> : push-if ( elt quot accum -- ) [ keep ] dip rot [ push ] [ 2drop ] if ; inline -: selector-for ( quot exemplar -- quot accum ) +: selector-for ( quot exemplar -- selector accum ) [ length ] keep new-resizable [ [ push-if ] 2curry ] keep ; inline -: selector ( quot -- quot accum ) +: selector ( quot -- selector accum ) V{ } selector-for ; inline : filter-as ( seq quot exemplar -- subseq ) @@ -501,7 +501,7 @@ PRIVATE> : push-either ( elt quot accum1 accum2 -- ) [ keep swap ] 2dip ? push ; inline -: 2selector ( quot -- quot accum1 accum2 ) +: 2selector ( quot -- selector accum1 accum2 ) V{ } clone V{ } clone [ [ push-either ] 3curry ] 2keep ; inline : partition ( seq quot -- trueseq falseseq ) diff --git a/extra/game/models/collada/collada-docs.factor b/extra/game/models/collada/collada-docs.factor index 5be2e19790..b8dad530a4 100644 --- a/extra/game/models/collada/collada-docs.factor +++ b/extra/game/models/collada/collada-docs.factor @@ -33,7 +33,7 @@ HELP: y-up { $class-description "Right-handed 3D coordinate system where Y is up HELP: z-up { $class-description "Right-handed 3D coordinate system where Z is up." } ; HELP: >y-up-axis! -{ $values { "seq" sequence } { "from-axis" rh-up } { "seq" sequence } } +{ $values { "seq" sequence } { "from-axis" rh-up } } { $description "Destructively swizzles the first three elements of the input sequence to a right-handed 3D coordinate system where Y is up and returns the modified sequence." } ; HELP: source>seq @@ -53,7 +53,7 @@ HELP: mesh>vertices { $description "Convert the mesh tag's vertices element to a pair for further lookup in " { $link collect-sources } ". " } ; HELP: collect-sources -{ $values { "sources" hashtable } { "vertices" pair } { "inputs" tag sequence } { "sources" sequence } } +{ $values { "sources" hashtable } { "vertices" pair } { "inputs" tag sequence } { "seq" sequence } } { $description "Look up the sources for these " { $emphasis "input" } " elements and return a sequence of " { $link source } " tuples." } ; HELP: group-indices diff --git a/extra/game/models/collada/collada.factor b/extra/game/models/collada/collada.factor index ef1c55049b..bb7c73c2c7 100644 --- a/extra/game/models/collada/collada.factor +++ b/extra/game/models/collada/collada.factor @@ -94,7 +94,7 @@ M: z-up >y-up-axis! ] x* ] bi 2array ; -:: collect-sources ( sources vertices inputs -- sources ) +:: collect-sources ( sources vertices inputs -- seq ) inputs [| input | input "source" x@ rest vertices first = diff --git a/extra/game/models/obj/obj-docs.factor b/extra/game/models/obj/obj-docs.factor index ceb61dbb17..a41ca13b8e 100644 --- a/extra/game/models/obj/obj-docs.factor +++ b/extra/game/models/obj/obj-docs.factor @@ -58,7 +58,7 @@ HELP: face>aos { $description "Convert a face line to a sequence of vertex attributes." } ; HELP: push* -{ $values { "elt" "an object" } { "seq" sequence } { "seq" sequence } } +{ $values { "elt" "an object" } { "seq" sequence } } { $description "Push the value onto the sequence, keeping the sequence on the stack." } ; HELP: push-current-model diff --git a/extra/gpu/shaders/shaders-docs.factor b/extra/gpu/shaders/shaders-docs.factor index 96a8561e9f..54822c2fbb 100644 --- a/extra/gpu/shaders/shaders-docs.factor +++ b/extra/gpu/shaders/shaders-docs.factor @@ -172,7 +172,7 @@ HELP: vertex-array HELP: vertex-array-buffers { $values { "vertex-array" vertex-array } - { "vertex-buffer" buffer } + { "buffers" sequence } } { $description "Returns a sequence containing all of the " { $link buffer } " objects that make up " { $snippet "vertex-array" } "." } ; diff --git a/extra/math/transforms/fft/fft-docs.factor b/extra/math/transforms/fft/fft-docs.factor index 430058b362..93d72f39a4 100644 --- a/extra/math/transforms/fft/fft-docs.factor +++ b/extra/math/transforms/fft/fft-docs.factor @@ -2,6 +2,6 @@ USING: help.markup help.syntax sequences ; IN: math.transforms.fft HELP: fft -{ $values { "seq" sequence } { "seq" sequence } } +{ $values { "seq" sequence } { "seq'" sequence } } { $description "Fast Fourier transform function." } ; diff --git a/extra/math/transforms/fft/fft.factor b/extra/math/transforms/fft/fft.factor index 0688c00468..440243a968 100644 --- a/extra/math/transforms/fft/fft.factor +++ b/extra/math/transforms/fft/fft.factor @@ -13,26 +13,26 @@ IN: math.transforms.fft : omega ( n -- n' ) recip -2 pi i* * * exp ; -: twiddle ( seq -- seq ) +: twiddle ( seq -- seq' ) dup length [ omega ] [ n^v ] bi v* ; PRIVATE> DEFER: fft -: two ( seq -- seq ) +: two ( seq -- seq' ) fft 2 v/n dup append ; ; -: odd ( seq -- seq ) 2 group 1 ; +: even ( seq -- seq' ) 2 group 0 ; +: odd ( seq -- seq' ) 2 group 1 ; -: (fft) ( seq -- seq ) +: (fft) ( seq -- seq' ) [ odd two twiddle ] [ even two ] bi v+ ; PRIVATE> -: fft ( seq -- seq ) +: fft ( seq -- seq' ) dup length 1 = [ (fft) ] unless ; diff --git a/extra/math/transforms/haar/haar-docs.factor b/extra/math/transforms/haar/haar-docs.factor index 218a63a480..a9a4fd111f 100644 --- a/extra/math/transforms/haar/haar-docs.factor +++ b/extra/math/transforms/haar/haar-docs.factor @@ -2,13 +2,13 @@ USING: help.markup help.syntax sequences ; IN: math.transforms.haar HELP: haar -{ $values { "seq" sequence } { "seq" sequence } } +{ $values { "seq" sequence } { "seq'" sequence } } { $description "Haar wavelet transform function." } { $notes "The sequence length should be a power of two." } { $examples { $example "USING: math.transforms.haar prettyprint ;" "{ 7 1 6 6 3 -5 4 2 } haar ." "{ 3 2 -1 -2 3 0 4 1 }" } } ; HELP: rev-haar -{ $values { "seq" sequence } { "seq" sequence } } +{ $values { "seq" sequence } { "seq'" sequence } } { $description "Reverse Haar wavelet transform function." } { $notes "The sequence length should be a power of two." } { $examples { $example "USING: math.transforms.haar prettyprint ;" "{ 3 2 -1 -2 3 0 4 1 } rev-haar ." "{ 7 1 6 6 3 -5 4 2 }" } } ; diff --git a/extra/math/transforms/haar/haar.factor b/extra/math/transforms/haar/haar.factor index c0359b8e7b..e9b430a802 100644 --- a/extra/math/transforms/haar/haar.factor +++ b/extra/math/transforms/haar/haar.factor @@ -8,7 +8,7 @@ IN: math.transforms.haar -: haar ( seq -- seq ) +: haar ( seq -- seq' ) dup length 1 <= [ haar-step haar prepend ] unless ; -: rev-haar ( seq -- seq ) +: rev-haar ( seq -- seq' ) dup length 2 > [ halves swap rev-haar prepend ] when rev-haar-step ; diff --git a/extra/memory/piles/piles-docs.factor b/extra/memory/piles/piles-docs.factor index 20568f2226..94a3e7736f 100644 --- a/extra/memory/piles/piles-docs.factor +++ b/extra/memory/piles/piles-docs.factor @@ -21,7 +21,6 @@ HELP: pile HELP: pile-align { $values { "pile" pile } { "align" "a power of two" } - { "pile" pile } } { $description "Adjusts a " { $link pile } "'s internal state so that the next call to " { $link pile-alloc } " will return a pointer aligned to " { $snippet "align" } " bytes relative to the pile's initial offset." } ; diff --git a/extra/mongodb/driver/driver-docs.factor b/extra/mongodb/driver/driver-docs.factor index 532dfe1dce..95acd523b3 100644 --- a/extra/mongodb/driver/driver-docs.factor +++ b/extra/mongodb/driver/driver-docs.factor @@ -49,7 +49,6 @@ HELP: HELP: >upsert { $values { "mdb-update-msg" "a mdb-update-msg" } - { "mdb-update-msg" "mdb-update-msg with the upsert indicator set to t" } } { $description "Marks a mdb-update-msg as upsert operation" "(inserts object identified by the update selector if it doesn't exist in the collection)" } ; @@ -162,7 +161,6 @@ HELP: hint { $values { "mdb-query-msg" "a query" } { "index-hint" "a hint to an index" } - { "mdb-query-msg" "modified query object" } } { $description "Annotates the query with a hint to an index. " "For detailed information see: " { $url "http://www.mongodb.org/display/DOCS/Optimizing+Mongo+Performance#OptimizingMongoPerformance-Hint" } } @@ -183,7 +181,6 @@ HELP: limit { $values { "mdb-query-msg" "a query" } { "limit#" "number of objects that should be returned at most" } - { "mdb-query-msg" "modified query object" } } { $description "Limits the number of returned objects to limit#" } { $examples @@ -243,7 +240,6 @@ HELP: skip { $values { "mdb-query-msg" "a query message" } { "skip#" "number of objects to skip" } - { "mdb-query-msg" "annotated query message" } } { $description "annotates a query message with a number of objects to skip when returning the results" } ; @@ -251,7 +247,6 @@ HELP: sort { $values { "mdb-query-msg" "a query message" } { "sort-quot" "a quotation with sort specifiers" } - { "mdb-query-msg" "annotated query message" } } { $description "annotates the query message for sort specifiers" } ; diff --git a/extra/spider/spider-docs.factor b/extra/spider/spider-docs.factor index 83d93268b5..a39515379a 100644 --- a/extra/spider/spider-docs.factor +++ b/extra/spider/spider-docs.factor @@ -12,7 +12,6 @@ HELP: HELP: run-spider { $values - { "spider" spider } { "spider" spider } } { $description "Runs a spider until completion. See the " { $subsection "spider-tutorial" } " for a complete description of the tuple slots that affect how thet spider works." } ; From c3de89c808ea483fc2d88e10596ccdf4d6a3eba3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 19 Feb 2010 12:32:03 +1300 Subject: [PATCH 093/713] help.lint.checks: you can't have duplicate names in $values anymore --- basis/help/lint/checks/checks.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/help/lint/checks/checks.factor b/basis/help/lint/checks/checks.factor index 340f9b16d3..632cdb46e2 100644 --- a/basis/help/lint/checks/checks.factor +++ b/basis/help/lint/checks/checks.factor @@ -33,7 +33,7 @@ SYMBOL: vocab-articles : extract-values ( element -- seq ) \ $values swap elements dup empty? [ - first rest [ first ] map prune + first rest [ first ] map ] unless ; : effect-values ( word -- seq ) From 3f53d189fe6789eb7a647f2a59e239e4b41c1de8 Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Thu, 18 Feb 2010 20:46:18 -0600 Subject: [PATCH 094/713] update project-euler common files --- extra/project-euler/common/common.factor | 4 ++-- extra/project-euler/project-euler.factor | 27 ++++++++++++------------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/extra/project-euler/common/common.factor b/extra/project-euler/common/common.factor index a84f4fa48b..6995adcd6a 100644 --- a/extra/project-euler/common/common.factor +++ b/extra/project-euler/common/common.factor @@ -1,4 +1,4 @@ -! Copyright (c) 2007-2009 Aaron Schaefer. +! Copyright (c) 2007-2010 Aaron Schaefer. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays kernel lists make math math.functions math.matrices math.primes.miller-rabin math.order math.parser math.primes.factors @@ -19,7 +19,7 @@ IN: project-euler.common ! mediant - #71, #73 ! nth-prime - #7, #69 ! nth-triangle - #12, #42 -! number>digits - #16, #20, #30, #34, #35, #38, #43, #52, #55, #56, #92 +! number>digits - #16, #20, #30, #34, #35, #38, #43, #52, #55, #56, #92, #206 ! palindrome? - #4, #36, #55 ! pandigital? - #32, #38 ! pentagonal? - #44, #45 diff --git a/extra/project-euler/project-euler.factor b/extra/project-euler/project-euler.factor index 66f4296827..ce58e7009a 100644 --- a/extra/project-euler/project-euler.factor +++ b/extra/project-euler/project-euler.factor @@ -1,4 +1,4 @@ -! Copyright (c) 2007-2009 Aaron Schaefer, Samuel Tardieu. +! Copyright (c) 2007-2010 Aaron Schaefer, Samuel Tardieu. ! See http://factorcode.org/license.txt for BSD license. USING: definitions io io.files io.pathnames kernel math math.parser prettyprint project-euler.ave-time sequences vocabs vocabs.loader @@ -14,18 +14,19 @@ USING: definitions io io.files io.pathnames kernel math math.parser project-euler.037 project-euler.038 project-euler.039 project-euler.040 project-euler.041 project-euler.042 project-euler.043 project-euler.044 project-euler.045 project-euler.046 project-euler.047 project-euler.048 - project-euler.049 project-euler.051 project-euler.052 project-euler.053 - project-euler.054 project-euler.055 project-euler.056 project-euler.057 - project-euler.058 project-euler.059 project-euler.062 project-euler.063 - project-euler.065 project-euler.067 project-euler.069 project-euler.071 - project-euler.072 project-euler.073 project-euler.074 project-euler.075 - project-euler.076 project-euler.079 project-euler.081 project-euler.085 - project-euler.092 project-euler.097 project-euler.099 project-euler.100 - project-euler.102 project-euler.112 project-euler.116 project-euler.117 - project-euler.124 project-euler.134 project-euler.148 project-euler.150 - project-euler.151 project-euler.164 project-euler.169 project-euler.173 - project-euler.175 project-euler.186 project-euler.188 project-euler.190 - project-euler.203 project-euler.215 ; + project-euler.049 project-euler.050 project-euler.051 project-euler.052 + project-euler.053 project-euler.054 project-euler.055 project-euler.056 + project-euler.057 project-euler.058 project-euler.059 project-euler.062 + project-euler.063 project-euler.065 project-euler.067 project-euler.069 + project-euler.071 project-euler.072 project-euler.073 project-euler.074 + project-euler.075 project-euler.076 project-euler.079 project-euler.081 + project-euler.085 project-euler.089 project-euler.092 project-euler.097 + project-euler.099 project-euler.100 project-euler.102 project-euler.112 + project-euler.116 project-euler.117 project-euler.124 project-euler.134 + project-euler.148 project-euler.150 project-euler.151 project-euler.164 + project-euler.169 project-euler.173 project-euler.175 project-euler.186 + project-euler.188 project-euler.190 project-euler.203 project-euler.206 + project-euler.215 project-euler.255 ; IN: project-euler Date: Fri, 19 Feb 2010 18:24:23 +1300 Subject: [PATCH 095/713] game.input: fix load error on *BSD, remove dependency on windows.com from game.input.linux --- basis/game/input/input.factor | 1 + basis/game/input/linux/linux.factor | 8 +++----- basis/game/input/linux/tags.txt | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/basis/game/input/input.factor b/basis/game/input/input.factor index 7543a05c60..8a269cd51a 100644 --- a/basis/game/input/input.factor +++ b/basis/game/input/input.factor @@ -94,4 +94,5 @@ M: mouse-state clone { [ os windows? ] [ "game.input.xinput" require ] } { [ os macosx? ] [ "game.input.iokit" require ] } { [ os linux? ] [ "game.input.linux" require ] } + [ ] } cond diff --git a/basis/game/input/linux/linux.factor b/basis/game/input/linux/linux.factor index 465cefa84b..0d451e96f0 100644 --- a/basis/game/input/linux/linux.factor +++ b/basis/game/input/linux/linux.factor @@ -1,8 +1,6 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel game.input namespaces classes windows.com.syntax -bit-arrays -vectors ; +USING: kernel game.input namespaces classes bit-arrays vectors ; IN: game.input.linux SINGLETON: linux-game-input-backend @@ -25,10 +23,10 @@ M: linux-game-input-backend product-string drop "" ; M: linux-game-input-backend product-id - drop GUID: {00000000-0000-0000-0000-000000000000} ; + drop f ; M: linux-game-input-backend instance-id - drop GUID: {00000000-0000-0000-0000-000000000000} ; + drop f ; M: linux-game-input-backend read-controller drop controller-state new ; diff --git a/basis/game/input/linux/tags.txt b/basis/game/input/linux/tags.txt index 84d4140a70..82506ff250 100644 --- a/basis/game/input/linux/tags.txt +++ b/basis/game/input/linux/tags.txt @@ -1 +1,2 @@ +unportable games From 48fe9029af23b64d8ba4df68c6e849704a847737 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 19 Feb 2010 18:24:36 +1300 Subject: [PATCH 096/713] libusb: add unportable tag since it depends on the unix vocab --- extra/libusb/tags.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/libusb/tags.txt b/extra/libusb/tags.txt index bb863cf9a0..bf2a35f15b 100644 --- a/extra/libusb/tags.txt +++ b/extra/libusb/tags.txt @@ -1 +1,2 @@ bindings +unportable From 7692bd1715db1a8cd5e12452f97bf7465ea73de0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 19 Feb 2010 21:45:43 +1300 Subject: [PATCH 097/713] concurrency.mailboxes: mailboxes should not be disposable, since futures and promises use them in a transient fashion, causing leaks --- .../mailboxes/mailboxes-tests.factor | 35 ------------------- basis/concurrency/mailboxes/mailboxes.factor | 20 +++++------ 2 files changed, 9 insertions(+), 46 deletions(-) diff --git a/basis/concurrency/mailboxes/mailboxes-tests.factor b/basis/concurrency/mailboxes/mailboxes-tests.factor index 56d579d6c7..3435a01455 100644 --- a/basis/concurrency/mailboxes/mailboxes-tests.factor +++ b/basis/concurrency/mailboxes/mailboxes-tests.factor @@ -42,40 +42,6 @@ IN: concurrency.mailboxes.tests mailbox-get ] unit-test - "m" set - -1 "c" set -1 "d" set - -[ - "c" get await - [ "m" get mailbox-get drop ] - [ drop "d" get count-down ] recover -] "Mailbox close test" spawn drop - -[ ] [ "c" get count-down ] unit-test -[ ] [ "m" get dispose ] unit-test -[ ] [ "d" get 5 seconds await-timeout ] unit-test - -[ ] [ "m" get dispose ] unit-test - - "m" set - -1 "c" set -1 "d" set - -[ - "c" get await - "m" get wait-for-close - "d" get count-down -] "Mailbox close test" spawn drop - -[ ] [ "c" get count-down ] unit-test -[ ] [ "m" get dispose ] unit-test -[ ] [ "d" get 5 seconds await-timeout ] unit-test - -[ ] [ "m" get dispose ] unit-test - [ { "foo" "bar" } ] [ "foo" over mailbox-put @@ -86,4 +52,3 @@ IN: concurrency.mailboxes.tests [ 1 seconds mailbox-get-timeout ] [ wait-timeout? ] must-fail-with - diff --git a/basis/concurrency/mailboxes/mailboxes.factor b/basis/concurrency/mailboxes/mailboxes.factor index 7834a2a3e1..06da3b34a6 100644 --- a/basis/concurrency/mailboxes/mailboxes.factor +++ b/basis/concurrency/mailboxes/mailboxes.factor @@ -1,17 +1,17 @@ -! Copyright (C) 2005, 2008 Chris Double, Slava Pestov. +! Copyright (C) 2005, 2010 Chris Double, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: dlists deques threads sequences continuations -destructors namespaces math quotations words kernel -arrays assocs init system concurrency.conditions accessors -debugger debugger.threads locals fry ; +USING: dlists deques threads sequences continuations namespaces +math quotations words kernel arrays assocs init system +concurrency.conditions accessors debugger debugger.threads +locals fry ; IN: concurrency.mailboxes -TUPLE: mailbox < disposable threads data ; - -M: mailbox dispose* threads>> notify-all ; +TUPLE: mailbox threads data ; : ( -- mailbox ) - mailbox new-disposable >>threads >>data ; + mailbox new + >>threads + >>data ; : mailbox-empty? ( mailbox -- bool ) data>> deque-empty? ; @@ -24,14 +24,12 @@ M: mailbox dispose* threads>> notify-all ; [ threads>> ] dip "mailbox" wait ; :: block-unless-pred ( mailbox timeout pred: ( message -- ? ) -- ) - mailbox check-disposed mailbox data>> pred dlist-any? [ mailbox timeout wait-for-mailbox mailbox timeout pred block-unless-pred ] unless ; inline recursive : block-if-empty ( mailbox timeout -- mailbox ) - over check-disposed over mailbox-empty? [ 2dup wait-for-mailbox block-if-empty ] [ From be8a0f777998a459a31a3fe606c9cd8723f66c33 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 19 Feb 2010 21:45:50 +1300 Subject: [PATCH 098/713] concurrency.promises: fix formatting --- basis/concurrency/promises/promises.factor | 1 + 1 file changed, 1 insertion(+) diff --git a/basis/concurrency/promises/promises.factor b/basis/concurrency/promises/promises.factor index 2ff338c4e3..3381bcc00b 100644 --- a/basis/concurrency/promises/promises.factor +++ b/basis/concurrency/promises/promises.factor @@ -12,6 +12,7 @@ TUPLE: promise mailbox ; mailbox>> mailbox-empty? not ; ERROR: promise-already-fulfilled promise ; + : fulfill ( value promise -- ) dup promise-fulfilled? [ promise-already-fulfilled From a615700af1f6d969b394ba8ea6a451025df2a7c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= Date: Tue, 20 Oct 2009 13:55:29 +0200 Subject: [PATCH 099/713] ui.tools.listener docs: typo --- basis/ui/tools/listener/listener-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/ui/tools/listener/listener-docs.factor b/basis/ui/tools/listener/listener-docs.factor index b762e036e6..966ac37d30 100644 --- a/basis/ui/tools/listener/listener-docs.factor +++ b/basis/ui/tools/listener/listener-docs.factor @@ -9,7 +9,7 @@ HELP: interactor $nl "Interactors are created by calling " { $link } "." $nl -"Interactors implement the " { $link stream-readln } ", " { $link stream-read } " and " { $link read-quot } " generic words." } ; +"Interactors implement the " { $link stream-readln } ", " { $link stream-read } " and " { $link stream-read-quot } " generic words." } ; ARTICLE: "ui-listener" "UI listener" "The graphical listener adds input history and word and vocabulary completion. See " { $link "listener" } " for general information on the listener." From db663548f9cd4615c31efa81b1b109a12ca2cfba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= Date: Wed, 21 Oct 2009 19:48:49 +0200 Subject: [PATCH 100/713] math: typo in rem 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 1e107124a2..6357c8bd98 100644 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -212,7 +212,7 @@ HELP: recip HELP: rem { $values { "x" rational } { "y" rational } { "z" rational } } { $description - "Computes the remainder of dividing " { $snippet "x" } " by " { $snippet "y" } ", with the remainder always positive." + "Computes the remainder of dividing " { $snippet "x" } " by " { $snippet "y" } ", with the remainder always positive or zero." { $list "Given fixnums, always yields a fixnum." "Given bignums, always yields a bignum." From caf978588bf9521cde6a1d6d518c5954cb4d150e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= Date: Thu, 18 Feb 2010 18:18:26 +0100 Subject: [PATCH 101/713] sequences: clarify some stack effect and examlpes in docs --- core/sequences/sequences-docs.factor | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 38eadc745d..dc26933af4 100644 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -269,7 +269,7 @@ HELP: reduce HELP: reduce-index { $values - { "seq" sequence } { "identity" object } { "quot" quotation } } + { "seq" sequence } { "identity" object } { "quot" { $quotation "( prev elt index -- result )" } } } { $description "Combines successive elements of the sequence and their indices binary operations, and outputs the final result. On the first iteration, the three inputs to the quotation are " { $snippet "identity" } ", the first element of the sequence, and its index, 0. On successive iterations, the first input is the result of the previous iteration, the second input is the corresponding element of the sequence, and the third is its index." } { $examples { $example "USING: sequences prettyprint math ;" "{ 10 50 90 } 0 [ + + ] reduce-index ." @@ -321,20 +321,20 @@ HELP: map-as HELP: each-index { $values - { "seq" sequence } { "quot" quotation } } + { "seq" sequence } { "quot" { $quotation "( elt index -- )" } } } { $description "Calls the quotation with the element of the sequence and its index on the stack, with the index on the top of the stack." } -{ $examples { $example "USING: sequences prettyprint math ;" -"{ 10 20 30 } [ + . ] each-index" -"10\n21\n32" +{ $examples { $example "USING: arrays sequences prettyprint ;" +"{ 10 20 30 } [ 2array . ] each-index" +"{ 10 0 }\n{ 20 1 }\n{ 30 2 }" } } ; HELP: map-index { $values - { "seq" sequence } { "quot" quotation } { "newseq" sequence } } + { "seq" sequence } { "quot" { $quotation "( elt index -- result )" } } { "newseq" sequence } } { $description "Calls the quotation with the element of the sequence and its index on the stack, with the index on the top of the stack. Collects the outputs of the quotation and outputs them in a sequence of the same type as the input sequence." } -{ $examples { $example "USING: sequences prettyprint math ;" -"{ 10 20 30 } [ + ] map-index ." -"{ 10 21 32 }" +{ $examples { $example "USING: arrays sequences prettyprint ;" +"{ 10 20 30 } [ 2array ] map-index ." +"{ { 10 0 } { 20 1 } { 30 2 } }" } } ; HELP: change-nth @@ -995,8 +995,8 @@ HELP: count HELP: selector { $values - { "quot" "a predicate quotation" } - { "selector" quotation } { "accum" vector } } + { "quot" { $quotation "( elt -- ? )" } } + { "selector" { $quotation "( elt -- )" } } { "accum" vector } } { $description "Creates a new vector to accumulate the values which return true for a predicate. Returns a new quotation which accepts an object to be tested and stored in the collector if the test yields true. The collector is left on the stack for convenience." } { $example "! Find all the even numbers:" "USING: prettyprint sequences math kernel ;" "10 iota [ even? ] selector [ each ] dip ." @@ -1152,7 +1152,7 @@ HELP: replicate HELP: replicate-as { $values - { "len" integer } { "quot" quotation } { "exemplar" sequence } + { "len" integer } { "quot" { $quotation "( -- elt )" } } { "exemplar" sequence } { "newseq" sequence } } { $description "Calls the quotation " { $snippet "len" } " times, collecting results into a new sequence of the same type as the exemplar sequence." } { $examples @@ -1190,7 +1190,7 @@ HELP: virtual@ HELP: 2map-reduce { $values - { "seq1" sequence } { "seq2" sequence } { "map-quot" quotation } { "reduce-quot" quotation } + { "seq1" sequence } { "seq2" sequence } { "map-quot" { $quotation "( elt1 elt2 -- intermediate )" } } { "reduce-quot" { $quotation "( prev intermediate -- result )" } } { "result" object } } { $description "Calls " { $snippet "map-quot" } " on each pair of elements from " { $snippet "seq1" } " and " { $snippet "seq2" } " and combines the results using " { $snippet "reduce-quot" } " in the same manner as " { $link reduce } ", except that there is no identity element, and the sequence must have a length of at least 1." } { $errors "Throws an error if the sequence is empty." } @@ -1236,7 +1236,7 @@ HELP: collector HELP: binary-reduce { $values - { "seq" sequence } { "start" integer } { "quot" quotation } + { "seq" sequence } { "start" integer } { "quot" { $quotation "( elt1 elt2 -- newelt )" } } { "value" object } } { $description "Like " { $link reduce } ", but splits the sequence in half recursively until each sequence is small enough, and calls the quotation on these smaller sequences. If the quotation computes values that depend on the size of their input, such as bignum arithmetic, then this algorithm can be more efficient than using " { $link reduce } "." } { $examples "Computing factorial:" @@ -1247,7 +1247,7 @@ HELP: binary-reduce HELP: follow { $values - { "obj" object } { "quot" quotation } + { "obj" object } { "quot" { $quotation "( prev -- result/f )" } } { "seq" sequence } } { $description "Outputs a sequence containing the input object and all of the objects generated by successively feeding the result of the quotation called on the input object to the quotation recursuively. Objects yielded by the quotation are added to the output sequence until the quotation yields " { $link f } ", at which point the recursion terminates." } { $examples "Get random numbers until zero is reached:" From eb8344a5a5494276e5f7d5f16372d87364e6bdd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= Date: Thu, 18 Feb 2010 18:43:13 +0100 Subject: [PATCH 102/713] assocs: doc fixes --- core/assocs/assocs-docs.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/assocs/assocs-docs.factor b/core/assocs/assocs-docs.factor index 0d5a884832..8f93c5a9d1 100644 --- a/core/assocs/assocs-docs.factor +++ b/core/assocs/assocs-docs.factor @@ -221,7 +221,7 @@ HELP: assoc-size HELP: assoc-like { $values { "assoc" assoc } { "exemplar" assoc } { "newassoc" "a new assoc" } } -{ $contract "Creates a new assoc having the same entries as "{ $snippet "assoc" } " and the same type as " { $snippet "exemplar" } "." } ; +{ $contract "Creates a new assoc having the same entries as " { $snippet "assoc" } " and the same type as " { $snippet "exemplar" } "." } ; HELP: assoc-empty? { $values { "assoc" assoc } { "?" "a boolean" } } @@ -383,7 +383,7 @@ HELP: cache { $side-effects "assoc" } ; HELP: 2cache -{ $values { "key1" "a key" } { "key2" "a key" } { "assoc" assoc } { "quot" { $quotation "( key -- value )" } } { "value" "a previously-retained or freshly-computed value" } } +{ $values { "key1" "a key" } { "key2" "a key" } { "assoc" assoc } { "quot" { $quotation "( key1 key2 -- value )" } } { "value" "a previously-retained or freshly-computed value" } } { $description "If a single key composed of the input keys is present in the assoc, outputs the associated value, otherwise calls the quotation to produce a value and stores the keys/value pair into the assoc. Returns the value stored in the assoc. Returns a value either looked up or newly stored in the assoc." } { $side-effects "assoc" } ; @@ -432,7 +432,7 @@ HELP: assoc-combine HELP: assoc-map-as { $values - { "assoc" assoc } { "quot" quotation } { "exemplar" assoc } + { "assoc" assoc } { "quot" { $quotation "( key value -- newkey newvalue )" } } { "exemplar" assoc } { "newassoc" assoc } } { $description "Applies the quotation to each entry in the input assoc and collects the results in a new assoc of the stame type as the exemplar." } { $examples { $example "USING: prettyprint assocs hashtables math ;" " H{ { 1 2 } { 3 4 } } [ sq ] { } assoc-map-as ." "{ { 1 4 } { 3 16 } }" } } ; From aec0243f8331f69f2c71804e312b58baca56252a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= Date: Thu, 18 Feb 2010 18:47:02 +0100 Subject: [PATCH 103/713] infix: part about integers as sequences doesn't apply anymore --- extra/infix/infix-docs.factor | 8 -------- 1 file changed, 8 deletions(-) diff --git a/extra/infix/infix-docs.factor b/extra/infix/infix-docs.factor index 9c42bf256b..3885fcc613 100644 --- a/extra/infix/infix-docs.factor +++ b/extra/infix/infix-docs.factor @@ -65,14 +65,6 @@ $nl "[let { 1 2 3 4 } :> myarr [infix myarr[4/2]*3 infix] ] ." "9" } -"Please note: in Factor " { $emphasis "fixnums are sequences too." } " If you are not careful with sequence accesses you may introduce subtle bugs:" -{ $example - "USING: arrays infix locals ;" - ":: add-2nd-elements ( x y -- res )" - " [infix x[1] + y[1] infix] ;" - "{ 1 2 3 } { 0 1 2 3 } add-2nd-elements ." - "3" -} ; ABOUT: "infix" From a343f8a31ccf418e39e0a5c5e18a9dfe51034efa Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Feb 2010 00:23:24 +1300 Subject: [PATCH 104/713] io.monitors: if a monitor is disposed while other threads are waiting on it, an error will be thrown from next-change, instead of those threads hanging forever. This makes monitors consistent with streams and other native resources that behave in a similar manner --- basis/io/monitors/linux/linux.factor | 4 +++- basis/io/monitors/macosx/macosx.factor | 5 ++-- basis/io/monitors/monitors-tests.factor | 21 ++++++++++++++++- basis/io/monitors/monitors.factor | 24 ++++++++++++++++---- basis/io/monitors/recursive/recursive.factor | 2 +- basis/io/monitors/windows/nt/nt.factor | 2 +- 6 files changed, 48 insertions(+), 10 deletions(-) diff --git a/basis/io/monitors/linux/linux.factor b/basis/io/monitors/linux/linux.factor index 7653eaa84c..eacc920303 100644 --- a/basis/io/monitors/linux/linux.factor +++ b/basis/io/monitors/linux/linux.factor @@ -59,7 +59,9 @@ M: linux-monitor dispose* ( monitor -- ) [ inotify>> handle>> handle-fd ] [ wd>> ] bi inotify_rm_watch io-error ] if - ] bi ; + ] + [ call-next-method ] + tri ; : ignore-flags? ( mask -- ? ) { diff --git a/basis/io/monitors/macosx/macosx.factor b/basis/io/monitors/macosx/macosx.factor index e71fb2eca2..dbbbe7c7e3 100644 --- a/basis/io/monitors/macosx/macosx.factor +++ b/basis/io/monitors/macosx/macosx.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: io.backend io.monitors core-foundation.fsevents continuations kernel sequences @@ -16,6 +16,7 @@ M:: macosx (monitor) ( path recursive? mailbox -- monitor ) dup [ enqueue-notifications ] curry path 1array 0 0 >>handle ; -M: macosx-monitor dispose* handle>> dispose ; +M: macosx-monitor dispose* + [ handle>> dispose ] [ call-next-method ] bi ; macosx set-io-backend diff --git a/basis/io/monitors/monitors-tests.factor b/basis/io/monitors/monitors-tests.factor index 576ac7ca30..ac17c4a39f 100644 --- a/basis/io/monitors/monitors-tests.factor +++ b/basis/io/monitors/monitors-tests.factor @@ -3,7 +3,7 @@ USING: io.monitors tools.test io.files system sequences continuations namespaces concurrency.count-downs kernel io threads calendar prettyprint destructors io.timeouts io.files.temp io.directories io.directories.hierarchy -io.pathnames accessors ; +io.pathnames accessors concurrency.promises ; os { winnt linux macosx } member? [ [ @@ -110,4 +110,23 @@ os { winnt linux macosx } member? [ [ [ t ] [ "m" get next-change drop ] while ] must-fail [ ] [ "m" get dispose ] unit-test ] with-monitors + + ! Disposing a monitor should throw an error in any threads + ! waiting on notifications + [ + [ ] [ + "p" set + "monitor-test" temp-file t "m" set + 10 seconds "m" get set-timeout + ] unit-test + + [ + [ "m" get next-change ] [ ] recover + "p" get fulfill + ] in-thread + + [ ] [ 1 seconds sleep ] unit-test + [ ] [ "m" get dispose ] unit-test + [ t ] [ "p" get 10 seconds ?promise-timeout already-disposed? ] unit-test + ] with-monitors ] when diff --git a/basis/io/monitors/monitors.factor b/basis/io/monitors/monitors.factor index cb2f552a32..731798c424 100644 --- a/basis/io/monitors/monitors.factor +++ b/basis/io/monitors/monitors.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008, 2009 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: io.backend kernel continuations destructors namespaces sequences assocs hashtables sorting arrays threads boxes @@ -26,6 +26,15 @@ M: monitor timeout timeout>> ; M: monitor set-timeout (>>timeout) ; + + +M: monitor dispose* + [ monitor-disposed ] dip queue>> mailbox-put ; + : new-monitor ( path mailbox class -- monitor ) new-disposable swap >>queue @@ -34,8 +43,11 @@ M: monitor set-timeout (>>timeout) ; TUPLE: file-change path changed monitor ; : queue-change ( path changes monitor -- ) - 3dup and and - [ [ file-change boa ] keep queue>> mailbox-put ] [ 3drop ] if ; + 3dup and and [ + [ check-disposed ] keep + [ file-change boa ] keep + queue>> mailbox-put + ] [ 3drop ] if ; HOOK: (monitor) io-backend ( path recursive? mailbox -- monitor ) @@ -43,7 +55,11 @@ HOOK: (monitor) io-backend ( path recursive? mailbox -- monitor ) (monitor) ; : next-change ( monitor -- change ) - [ queue>> ] [ timeout ] bi mailbox-get-timeout ; + [ check-disposed ] + [ + [ ] [ queue>> ] [ timeout ] tri mailbox-get-timeout + dup monitor-disposed eq? [ drop already-disposed ] [ nip ] if + ] bi ; SYMBOL: +add-file+ SYMBOL: +remove-file+ diff --git a/basis/io/monitors/recursive/recursive.factor b/basis/io/monitors/recursive/recursive.factor index 33477abdb6..83c088e882 100644 --- a/basis/io/monitors/recursive/recursive.factor +++ b/basis/io/monitors/recursive/recursive.factor @@ -41,7 +41,7 @@ DEFER: add-child-monitor M: recursive-monitor dispose* [ "stop" swap thread>> send-synchronous drop ] - [ queue>> dispose ] + [ call-next-method ] bi ; : stop-pump ( -- ) diff --git a/basis/io/monitors/windows/nt/nt.factor b/basis/io/monitors/windows/nt/nt.factor index 9cd8bc4df8..4d061cbb1a 100644 --- a/basis/io/monitors/windows/nt/nt.factor +++ b/basis/io/monitors/windows/nt/nt.factor @@ -100,4 +100,4 @@ M:: winnt (monitor) ( path recursive? mailbox -- monitor ) ] with-destructors ; M: win32-monitor dispose - port>> dispose ; + [ port>> dispose ] [ call-next-method ] bi ; From 5336d6f287fcbd59d59ca075ef29d67c1b0b84da Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 19 Feb 2010 07:36:12 -0500 Subject: [PATCH 105/713] io.monitors.recursive: fix hang introduced by recent io.monitors change --- basis/io/monitors/recursive/recursive.factor | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/basis/io/monitors/recursive/recursive.factor b/basis/io/monitors/recursive/recursive.factor index 83c088e882..b573e2fa2b 100644 --- a/basis/io/monitors/recursive/recursive.factor +++ b/basis/io/monitors/recursive/recursive.factor @@ -39,17 +39,19 @@ DEFER: add-child-monitor : remove-child-monitor ( monitor -- ) monitor tget children>> delete-at* [ dispose ] [ drop ] if ; +SYMBOL: +stop+ + M: recursive-monitor dispose* - [ "stop" swap thread>> send-synchronous drop ] - [ call-next-method ] - bi ; + [ [ +stop+ ] dip thread>> send ] [ call-next-method ] bi ; : stop-pump ( -- ) monitor tget children>> values dispose-each ; : pump-step ( msg -- ) - [ [ monitor>> path>> ] [ path>> ] bi append-path ] [ changed>> ] bi - monitor tget queue-change ; + monitor tget disposed>> [ drop ] [ + [ [ monitor>> path>> ] [ path>> ] bi append-path ] [ changed>> ] bi + monitor tget queue-change + ] if ; : child-added ( path monitor -- ) path>> prepend-path add-child-monitor ; @@ -69,8 +71,8 @@ M: recursive-monitor dispose* ] with with each ; : pump-loop ( -- ) - receive dup synchronous? [ - [ stop-pump t ] dip reply-synchronous + receive dup +stop+ eq? [ + drop stop-pump ] [ [ '[ _ update-hierarchy ] ignore-errors ] [ pump-step ] bi pump-loop From 6501480a0e7eb83511aa1d70194eb3a756e8689f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Feb 2010 12:01:47 +1300 Subject: [PATCH 106/713] Fix two problems with recompilation: predicate constant folding was recording unsatisfied dependencies in some cases, and literal tuple instances of forgotten classes would cause problems for method inlining --- basis/compiler/crossref/crossref-tests.factor | 9 ++++++ basis/compiler/tests/redefine22.factor | 11 +++++++ basis/compiler/tests/redefine23.factor | 13 ++++++++ basis/compiler/tree/cleanup/cleanup.factor | 13 +++++--- .../tree/propagation/info/info.factor | 21 ++++++++---- .../tree/propagation/propagation-tests.factor | 6 ++-- .../tree/propagation/simple/simple.factor | 9 ++---- .../dependencies/dependencies.factor | 32 +++++++++---------- core/classes/algebra/algebra.factor | 9 ++++++ 9 files changed, 87 insertions(+), 36 deletions(-) create mode 100644 basis/compiler/crossref/crossref-tests.factor create mode 100644 basis/compiler/tests/redefine22.factor create mode 100644 basis/compiler/tests/redefine23.factor diff --git a/basis/compiler/crossref/crossref-tests.factor b/basis/compiler/crossref/crossref-tests.factor new file mode 100644 index 0000000000..9cd475b2de --- /dev/null +++ b/basis/compiler/crossref/crossref-tests.factor @@ -0,0 +1,9 @@ +USING: compiler.crossref fry kernel sequences tools.test vocabs words ; +IN: compiler.crossref.tests + +! Dependencies of all words should always be satisfied unless we're +! in the middle of recompiling something +[ { } ] [ + all-words dup [ subwords ] map concat append + H{ } clone '[ _ dependencies-satisfied? not ] filter +] unit-test diff --git a/basis/compiler/tests/redefine22.factor b/basis/compiler/tests/redefine22.factor new file mode 100644 index 0000000000..5837d68c73 --- /dev/null +++ b/basis/compiler/tests/redefine22.factor @@ -0,0 +1,11 @@ +IN: compiler.tests.redefine22 +USING: kernel sequences compiler.units vocabs tools.test definitions ; + +TUPLE: ttt ; +INSTANCE: ttt sequence +M: ttt new-sequence 2drop ttt new ; + +: www-1 ( a -- b ) T{ ttt } new-sequence ; + +! This used to break with a compiler error in the above word +[ ] [ [ \ ttt forget ] with-compilation-unit ] unit-test diff --git a/basis/compiler/tests/redefine23.factor b/basis/compiler/tests/redefine23.factor new file mode 100644 index 0000000000..e6061937b6 --- /dev/null +++ b/basis/compiler/tests/redefine23.factor @@ -0,0 +1,13 @@ +IN: compiler.tests.redefine23 +USING: classes.struct specialized-arrays alien.c-types sequences +compiler.units vocabs tools.test ; + +STRUCT: my-struct { x int } ; +SPECIALIZED-ARRAY: my-struct +: my-word ( a -- b ) iota [ my-struct ] my-struct-array{ } map-as ; + +[ ] [ + [ + "specialized-arrays.instances.compiler.tests.redefine23" forget-vocab + ] with-compilation-unit +] unit-test diff --git a/basis/compiler/tree/cleanup/cleanup.factor b/basis/compiler/tree/cleanup/cleanup.factor index b19c99c360..b69f053898 100644 --- a/basis/compiler/tree/cleanup/cleanup.factor +++ b/basis/compiler/tree/cleanup/cleanup.factor @@ -51,11 +51,16 @@ GENERIC: cleanup* ( node -- node/nodes ) [ in-d>> #drop ] bi prefix ; -: record-predicate-folding ( #call -- ) - [ node-input-infos first class>> ] +: >predicate-folding< ( #call -- value-info class result ) + [ node-input-infos first ] [ word>> "predicating" word-prop ] - [ node-output-infos first literal>> ] tri - [ depends-on-class<= ] [ depends-on-classes-disjoint ] if ; + [ node-output-infos first literal>> ] tri ; + +: record-predicate-folding ( #call -- ) + >predicate-folding< pick literal?>> + [ [ literal>> ] 2dip depends-on-instance-predicate ] + [ [ class>> ] 2dip depends-on-class-predicate ] + if ; : record-folding ( #call -- ) dup word>> predicate? diff --git a/basis/compiler/tree/propagation/info/info.factor b/basis/compiler/tree/propagation/info/info.factor index 28ffb96f8f..7f5b9f6fcd 100644 --- a/basis/compiler/tree/propagation/info/info.factor +++ b/basis/compiler/tree/propagation/info/info.factor @@ -1,10 +1,11 @@ -! Copyright (C) 2008, 2009 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: assocs classes classes.algebra classes.tuple -classes.tuple.private kernel accessors math math.intervals namespaces -sequences sequences.private words combinators memoize -combinators.short-circuit byte-arrays strings arrays layouts -cpu.architecture compiler.tree.propagation.copy ; +classes.tuple.private classes.singleton kernel accessors math +math.intervals namespaces sequences sequences.private words +combinators memoize combinators.short-circuit byte-arrays +strings arrays layouts cpu.architecture +compiler.tree.propagation.copy ; IN: compiler.tree.propagation.info : false-class? ( class -- ? ) \ f class<= ; @@ -65,9 +66,17 @@ DEFER: UNION: fixed-length array byte-array string ; +: literal-class ( obj -- class ) + #! Handle forgotten tuples and singleton classes properly + dup singleton-class? [ + class dup class? [ + drop tuple + ] unless + ] unless ; + : init-literal-info ( info -- info ) empty-interval >>interval - dup literal>> class >>class + dup literal>> literal-class >>class dup literal>> { { [ dup real? ] [ [a,a] >>interval ] } { [ dup tuple? ] [ tuple-slot-infos >>slots ] } diff --git a/basis/compiler/tree/propagation/propagation-tests.factor b/basis/compiler/tree/propagation/propagation-tests.factor index e2bfe58788..444a424766 100644 --- a/basis/compiler/tree/propagation/propagation-tests.factor +++ b/basis/compiler/tree/propagation/propagation-tests.factor @@ -648,7 +648,7 @@ M: array iterate first t ; inline ] final-info drop ] unit-test -[ V{ word } ] [ +[ V{ t } ] [ [ { hashtable } declare hashtable instance? ] final-classes ] unit-test @@ -660,7 +660,7 @@ M: array iterate first t ; inline [ { assoc } declare hashtable instance? ] final-classes ] unit-test -[ V{ word } ] [ +[ V{ t } ] [ [ { string } declare string? ] final-classes ] unit-test @@ -774,7 +774,7 @@ MIXIN: empty-mixin [ { fixnum } declare log2 ] final-classes ] unit-test -[ V{ word } ] [ +[ V{ t } ] [ [ { fixnum } declare log2 0 >= ] final-classes ] unit-test diff --git a/basis/compiler/tree/propagation/simple/simple.factor b/basis/compiler/tree/propagation/simple/simple.factor index ccfd6ffabd..ed417ef9d7 100644 --- a/basis/compiler/tree/propagation/simple/simple.factor +++ b/basis/compiler/tree/propagation/simple/simple.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008, 2009 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: fry accessors kernel sequences sequences.private assocs words namespaces classes.algebra combinators @@ -93,11 +93,8 @@ M: #declare propagate-before recover ; : predicate-output-infos/class ( info class -- info ) - [ class>> ] dip { - { [ 2dup class<= ] [ t ] } - { [ 2dup classes-intersect? not ] [ f ] } - [ object-info ] - } cond 2nip ; + [ class>> ] dip compare-classes + dup +incomparable+ eq? [ drop object-info ] [ ] if ; : predicate-output-infos ( info class -- info ) over literal?>> diff --git a/basis/stack-checker/dependencies/dependencies.factor b/basis/stack-checker/dependencies/dependencies.factor index df68fa8961..5469000e84 100644 --- a/basis/stack-checker/dependencies/dependencies.factor +++ b/basis/stack-checker/dependencies/dependencies.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2009, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: assocs accessors classes.algebra fry generic kernel math -namespaces sequences words sets combinators.short-circuit -classes.tuple ; +USING: assocs accessors classes classes.algebra fry generic +kernel math namespaces sequences words sets +combinators.short-circuit classes.tuple ; FROM: classes.tuple.private => tuple-layout ; IN: stack-checker.dependencies @@ -57,28 +57,26 @@ GENERIC: satisfied? ( dependency -- ? ) boa conditional-dependencies get dup [ conjoin ] [ 2drop ] if ; inline -TUPLE: depends-on-class<= class1 class2 ; +TUPLE: depends-on-class-predicate class1 class2 result ; -: depends-on-class<= ( class1 class2 -- ) - \ depends-on-class<= add-conditional-dependency ; +: depends-on-class-predicate ( class1 class2 result -- ) + \ depends-on-class-predicate add-conditional-dependency ; -M: depends-on-class<= satisfied? +M: depends-on-class-predicate satisfied? { - [ class1>> classoid? ] - [ class2>> classoid? ] - [ [ class1>> ] [ class2>> ] bi class<= ] + [ [ class1>> classoid? ] [ class2>> classoid? ] bi and ] + [ [ [ class1>> ] [ class2>> ] bi compare-classes ] [ result>> ] bi eq? ] } 1&& ; -TUPLE: depends-on-classes-disjoint class1 class2 ; +TUPLE: depends-on-instance-predicate object class result ; -: depends-on-classes-disjoint ( class1 class2 -- ) - \ depends-on-classes-disjoint add-conditional-dependency ; +: depends-on-instance-predicate ( object class result -- ) + \ depends-on-instance-predicate add-conditional-dependency ; -M: depends-on-classes-disjoint satisfied? +M: depends-on-instance-predicate satisfied? { - [ class1>> classoid? ] - [ class2>> classoid? ] - [ [ class1>> ] [ class2>> ] bi classes-intersect? not ] + [ class>> classoid? ] + [ [ [ object>> ] [ class>> ] bi instance? ] [ result>> ] bi eq? ] } 1&& ; TUPLE: depends-on-next-method class generic next-method ; diff --git a/core/classes/algebra/algebra.factor b/core/classes/algebra/algebra.factor index 69289600e4..f9aaf3eaa5 100644 --- a/core/classes/algebra/algebra.factor +++ b/core/classes/algebra/algebra.factor @@ -234,3 +234,12 @@ ERROR: topological-sort-failed ; : flatten-class ( class -- assoc ) [ (flatten-class) ] H{ } make-assoc ; + +SYMBOL: +incomparable+ + +: compare-classes ( class1 class2 -- ? ) + { + { [ 2dup class<= ] [ t ] } + { [ 2dup classes-intersect? not ] [ f ] } + [ +incomparable+ ] + } cond 2nip ; From 08a80e5ba22ac457da60c526c1c06f73a83b123d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Feb 2010 12:05:12 +1300 Subject: [PATCH 107/713] specialized-arrays: generate slightly more efficient byte-array>T-array words --- .../specialized-arrays/specialized-arrays.factor | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/basis/specialized-arrays/specialized-arrays.factor b/basis/specialized-arrays/specialized-arrays.factor index d3db93e788..e2840b89dd 100644 --- a/basis/specialized-arrays/specialized-arrays.factor +++ b/basis/specialized-arrays/specialized-arrays.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008, 2009 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien alien.c-types alien.data alien.parser assocs byte-arrays classes compiler.units functors kernel lexer @@ -19,6 +19,11 @@ ERROR: bad-byte-array-length byte-array type ; M: bad-byte-array-length summary drop "Byte array length doesn't divide type width" ; +ERROR: not-a-byte-array alien ; + +M: not-a-byte-array summary + drop "Not a byte array" ; + : (underlying) ( n c-type -- array ) heap-size * (byte-array) ; inline @@ -61,9 +66,11 @@ TUPLE: A [ \ T heap-size calloc ] keep ; inline : byte-array>A ( byte-array -- specialized-array ) - >c-ptr dup length \ T heap-size /mod 0 = - [ drop \ T bad-byte-array-length ] unless - ; inline + >c-ptr dup byte-array? [ + dup length \ T heap-size /mod 0 = + [ ] + [ drop \ T bad-byte-array-length ] if + ] [ not-a-byte-array ] if ; inline M: A clone [ underlying>> clone ] [ length>> ] bi ; inline From 9cd164f3acc03d783278abf6e9af7ff30032b678 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Feb 2010 12:05:52 +1300 Subject: [PATCH 108/713] tools.crossref: don't include generic words in usage lists, since the results are useless and arbitrary -- they depend on the contents of megamorphic caches --- basis/tools/crossref/crossref.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/tools/crossref/crossref.factor b/basis/tools/crossref/crossref.factor index 3bdf2f83ae..50034822b2 100644 --- a/basis/tools/crossref/crossref.factor +++ b/basis/tools/crossref/crossref.factor @@ -71,7 +71,7 @@ M: word crossref-def : defs-to-crossref ( -- seq ) [ - all-words + all-words [ generic? not ] filter all-articles [ >link ] map source-files get keys [ ] map ] append-outputs ; From c5a62b14e786781fde0b860b08fb16d21a6c507c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Feb 2010 12:08:14 +1300 Subject: [PATCH 109/713] stack-checker.dependencies: fix load error --- basis/stack-checker/dependencies/dependencies.factor | 1 + 1 file changed, 1 insertion(+) diff --git a/basis/stack-checker/dependencies/dependencies.factor b/basis/stack-checker/dependencies/dependencies.factor index 5469000e84..ece943acac 100644 --- a/basis/stack-checker/dependencies/dependencies.factor +++ b/basis/stack-checker/dependencies/dependencies.factor @@ -4,6 +4,7 @@ USING: assocs accessors classes classes.algebra fry generic kernel math namespaces sequences words sets combinators.short-circuit classes.tuple ; FROM: classes.tuple.private => tuple-layout ; +FROM: assocs => change-at ; IN: stack-checker.dependencies ! Words that the current quotation depends on From 66bb912641871b5d64681c2b9b1e94cd8a5e5074 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Feb 2010 12:18:16 +1300 Subject: [PATCH 110/713] prettyprint.config: set some output limits by default. Use the new without-limits combinator to get the old behavior --- basis/prettyprint/config/config-docs.factor | 10 ++++++- basis/prettyprint/config/config.factor | 30 ++++++++++++++++--- basis/prettyprint/prettyprint-docs.factor | 9 ++---- basis/prettyprint/prettyprint.factor | 8 +---- .../tools/deploy/config/editor/editor.factor | 9 +++--- 5 files changed, 44 insertions(+), 22 deletions(-) diff --git a/basis/prettyprint/config/config-docs.factor b/basis/prettyprint/config/config-docs.factor index ccc63c61cb..7cd4b31c8b 100644 --- a/basis/prettyprint/config/config-docs.factor +++ b/basis/prettyprint/config/config-docs.factor @@ -1,5 +1,5 @@ USING: help.markup help.syntax io kernel -prettyprint.sections words ; +prettyprint.sections words quotations ; IN: prettyprint.config ABOUT: "prettyprint-variables" @@ -31,3 +31,11 @@ HELP: boa-tuples? HELP: c-object-pointers? { $var-description "Toggles whether C objects such as structs and direct arrays only print their underlying address. If this flag isn't set, C objects will attempt to print their contents. If a C object points to invalid memory, it will display only its address regardless." } ; + +HELP: with-short-limits +{ $values { "quot" quotation } } +{ $description "Calls a quotation in a new dynamic scope with prettyprinter limits set to produce a single line of output." } ; + +HELP: without-limits +{ $values { "quot" quotation } } +{ $description "Calls a quotation in a new dynamic scope with prettyprinter limits set to produce unlimited output." } ; diff --git a/basis/prettyprint/config/config.factor b/basis/prettyprint/config/config.factor index dd61e3e23d..a8848f9061 100644 --- a/basis/prettyprint/config/config.factor +++ b/basis/prettyprint/config/config.factor @@ -1,8 +1,6 @@ -! Copyright (C) 2003, 2008 Slava Pestov. +! Copyright (C) 2003, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays generic assocs io kernel math -namespaces sequences strings vectors words -continuations ; +USING: kernel namespaces ; IN: prettyprint.config ! Configuration @@ -18,4 +16,28 @@ SYMBOL: c-object-pointers? 4 tab-size set-global 64 margin set-global +15 nesting-limit set-global +100 length-limit set-global 10 number-base set-global +string-limit? on + +: with-short-limits ( quot -- ) + [ + 1 line-limit set + 15 length-limit set + 2 nesting-limit set + string-limit? on + boa-tuples? on + c-object-pointers? on + call + ] with-scope ; inline + +: without-limits ( quot -- ) + [ + nesting-limit off + length-limit off + line-limit off + string-limit? off + c-object-pointers? off + call + ] with-scope ; inline diff --git a/basis/prettyprint/prettyprint-docs.factor b/basis/prettyprint/prettyprint-docs.factor index bd2c4bd924..33e1857260 100644 --- a/basis/prettyprint/prettyprint-docs.factor +++ b/basis/prettyprint/prettyprint-docs.factor @@ -38,12 +38,9 @@ ARTICLE: "prettyprint-variables" "Prettyprint control variables" boa-tuples? c-object-pointers? } -"Note that the " { $link short. } " and " { $link pprint-short } " variables override some of these variables." -{ - $warning "Treat the global variables as essentially being constants. Only ever rebind them in a nested scope." - $nl - "Some of the globals are safe to change, like the tab size and wrap margin. However setting limits globally could break code which uses the prettyprinter as a serialization mechanism." -} ; +"The default limits are meant to strike a balance between readability, and not producing too much output when large structures are given. There are two combinators that override the defaults:" +{ $subsections with-short-limits without-limits } +"That the " { $link short. } " and " { $link pprint-short } " words wrap calls to " { $link . } " and " { $link pprint } " in " { $link with-short-limits } ". Code that uses the prettyprinter for serialization should use " { $link without-limits } " to avoid producing unreadable output." ; ARTICLE: "prettyprint-limitations" "Prettyprinter limitations" "When using the prettyprinter as a serialization mechanism, keep the following points in mind:" diff --git a/basis/prettyprint/prettyprint.factor b/basis/prettyprint/prettyprint.factor index 7b1538b1dc..23cf956a1d 100644 --- a/basis/prettyprint/prettyprint.factor +++ b/basis/prettyprint/prettyprint.factor @@ -26,13 +26,7 @@ IN: prettyprint : unparse-use ( obj -- str ) [ pprint-use ] with-string-writer ; : pprint-short ( obj -- ) - H{ - { line-limit 1 } - { length-limit 15 } - { nesting-limit 2 } - { string-limit? t } - { boa-tuples? t } - } clone [ pprint ] bind ; + [ pprint ] with-short-limits ; : unparse-short ( obj -- str ) [ pprint-short ] with-string-writer ; diff --git a/basis/tools/deploy/config/editor/editor.factor b/basis/tools/deploy/config/editor/editor.factor index 78d86a4707..e10d20e8b3 100644 --- a/basis/tools/deploy/config/editor/editor.factor +++ b/basis/tools/deploy/config/editor/editor.factor @@ -1,7 +1,8 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: assocs io.pathnames kernel parser prettyprint sequences -splitting tools.deploy.config vocabs.loader vocabs.metadata ; +USING: assocs io.pathnames kernel parser prettyprint +prettyprint.config sequences splitting tools.deploy.config +vocabs.loader vocabs.metadata ; IN: tools.deploy.config.editor : deploy-config-path ( vocab -- string ) @@ -13,7 +14,7 @@ IN: tools.deploy.config.editor parse-fresh [ first assoc-union ] unless-empty ; : set-deploy-config ( assoc vocab -- ) - [ unparse-use string-lines ] dip + [ [ unparse-use ] without-limits string-lines ] dip dup deploy-config-path set-vocab-file-contents ; : set-deploy-flag ( value key vocab -- ) From 51922a2fb96efa9797bc47a6d654742dd3b8dd2c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Feb 2010 12:18:29 +1300 Subject: [PATCH 111/713] make: documentation tweak --- core/make/make-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/make/make-docs.factor b/core/make/make-docs.factor index 5e4e04c270..2cbf82ae33 100644 --- a/core/make/make-docs.factor +++ b/core/make/make-docs.factor @@ -63,7 +63,7 @@ HELP: building HELP: make { $values { "quot" quotation } { "exemplar" sequence } { "seq" "a new sequence" } } -{ $description "Calls the quotation in a new " { $emphasis "dynamic scope" } ". The quotation and any words it calls can execute the " { $link , } " and " { $link % } " words to accumulate elements. When the quotation returns, all accumulated elements are collected into a sequence with the same type as " { $snippet "exemplar" } "." } +{ $description "Calls the quotation in a new dynamic scope with the " { $link building } " variable bound to a new resizable mutable sequence. The quotation and any words it calls can execute the " { $link , } " and " { $link % } " words to accumulate elements. When the quotation returns, all accumulated elements are collected into a sequence with the same type as " { $snippet "exemplar" } "." } { $examples { $example "USING: make prettyprint ;" "[ 1 , 2 , 3 , ] { } make ." "{ 1 2 3 }" } } ; HELP: , From daed64d8b4f8510e4080cf8abf74630da7e69ff6 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Feb 2010 12:24:25 +1300 Subject: [PATCH 112/713] ui.gadgets.worlds: support S+DELETE as an alternative shortcut for cut-action --- basis/ui/gadgets/editors/editors.factor | 1 - basis/ui/gadgets/worlds/worlds.factor | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/ui/gadgets/editors/editors.factor b/basis/ui/gadgets/editors/editors.factor index f42fdf4616..da60d66aff 100644 --- a/basis/ui/gadgets/editors/editors.factor +++ b/basis/ui/gadgets/editors/editors.factor @@ -365,7 +365,6 @@ editor "editing" f { { undo-action com-undo } { redo-action com-redo } { T{ key-down f f "DELETE" } delete-next-character } - { T{ key-down f { S+ } "DELETE" } delete-next-character } { T{ key-down f f "BACKSPACE" } delete-previous-character } { T{ key-down f { S+ } "BACKSPACE" } delete-previous-character } { T{ key-down f { C+ } "DELETE" } delete-previous-word } diff --git a/basis/ui/gadgets/worlds/worlds.factor b/basis/ui/gadgets/worlds/worlds.factor index 7e54b823e8..526fc77c57 100644 --- a/basis/ui/gadgets/worlds/worlds.factor +++ b/basis/ui/gadgets/worlds/worlds.factor @@ -230,6 +230,7 @@ action-gestures [ bi* ] H{ } assoc-map-as H{ + { T{ key-down f { S+ } "DELETE" } [ \ cut-action send-action ] } { T{ button-down f { C+ } 1 } [ drop T{ button-down f f 3 } button-gesture ] } { T{ button-down f { A+ } 1 } [ drop T{ button-down f f 2 } button-gesture ] } { T{ button-down f { M+ } 1 } [ drop T{ button-down f f 2 } button-gesture ] } From 95bfc8a240bbe08d1190e3f3535d335ae421e109 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Feb 2010 13:25:26 +1300 Subject: [PATCH 113/713] vocabs.metadata: replace unportable tag with a platforms.txt file for more fine-grained control. Rename unportable tag to untested for remaining cases --- basis/bootstrap/compiler/timing/tags.txt | 2 +- basis/calendar/unix/platforms.txt | 1 + basis/calendar/unix/tags.txt | 1 - basis/calendar/windows/platforms.txt | 1 + basis/calendar/windows/tags.txt | 1 - basis/cocoa/application/platforms.txt | 1 + basis/cocoa/application/tags.txt | 1 - basis/cocoa/callbacks/platforms.txt | 1 + basis/cocoa/callbacks/tags.txt | 1 - basis/cocoa/dialogs/platforms.txt | 1 + basis/cocoa/dialogs/tags.txt | 1 - basis/cocoa/enumeration/platforms.txt | 1 + basis/cocoa/enumeration/tags.txt | 1 - basis/cocoa/messages/platforms.txt | 1 + basis/cocoa/messages/tags.txt | 1 - basis/cocoa/nibs/platforms.txt | 1 + basis/cocoa/nibs/tags.txt | 1 - basis/cocoa/pasteboard/platforms.txt | 1 + basis/cocoa/pasteboard/tags.txt | 1 - basis/cocoa/platforms.txt | 1 + basis/cocoa/plists/platforms.txt | 1 + basis/cocoa/plists/tags.txt | 1 - basis/cocoa/runtime/platforms.txt | 1 + basis/cocoa/runtime/tags.txt | 1 - basis/cocoa/subclassing/platforms.txt | 1 + basis/cocoa/subclassing/tags.txt | 1 - basis/cocoa/tags.txt | 1 - basis/cocoa/types/platforms.txt | 1 + basis/cocoa/types/tags.txt | 1 - basis/cocoa/views/platforms.txt | 1 + basis/cocoa/views/tags.txt | 1 - basis/cocoa/windows/platforms.txt | 1 + basis/cocoa/windows/tags.txt | 1 - basis/core-foundation/arrays/platforms.txt | 1 + basis/core-foundation/arrays/tags.txt | 1 - .../attributed-strings/platforms.txt | 1 + .../attributed-strings/tags.txt | 1 - basis/core-foundation/bundles/platforms.txt | 1 + basis/core-foundation/bundles/tags.txt | 1 - basis/core-foundation/data/platforms.txt | 1 + basis/core-foundation/data/tags.txt | 1 - .../dictionaries/platforms.txt | 1 + basis/core-foundation/dictionaries/tags.txt | 1 - .../file-descriptors/platforms.txt | 1 + .../core-foundation/file-descriptors/tags.txt | 1 - basis/core-foundation/fsevents/platforms.txt | 1 + basis/core-foundation/fsevents/tags.txt | 1 - basis/core-foundation/numbers/platforms.txt | 1 + basis/core-foundation/numbers/tags.txt | 1 - basis/core-foundation/platforms.txt | 1 + basis/core-foundation/run-loop/platforms.txt | 1 + basis/core-foundation/run-loop/tags.txt | 1 - basis/core-foundation/strings/platforms.txt | 1 + basis/core-foundation/strings/tags.txt | 1 - basis/core-foundation/tags.txt | 1 - basis/core-foundation/timers/platforms.txt | 1 + basis/core-foundation/timers/tags.txt | 1 - basis/core-foundation/urls/platforms.txt | 1 + basis/core-foundation/urls/tags.txt | 1 - basis/core-foundation/utilities/platforms.txt | 1 + basis/core-foundation/utilities/tags.txt | 1 - basis/core-graphics/platforms.txt | 1 + basis/core-graphics/tags.txt | 1 - basis/core-text/fonts/platforms.txt | 1 + basis/core-text/fonts/tags.txt | 1 - basis/core-text/platforms.txt | 1 + basis/core-text/tags.txt | 1 - basis/cpu/ppc/assembler/backend/tags.txt | 1 - basis/cpu/ppc/linux/tags.txt | 2 +- basis/cpu/ppc/macosx/tags.txt | 2 +- basis/cpu/ppc/tags.txt | 2 +- basis/cpu/x86/32/tags.txt | 2 +- basis/cpu/x86/64/tags.txt | 2 +- basis/cpu/x86/64/unix/tags.txt | 2 +- basis/cpu/x86/64/winnt/tags.txt | 2 +- basis/cpu/x86/assembler/syntax/tags.txt | 1 - basis/cpu/x86/features/tags.txt | 2 +- basis/cpu/x86/tags.txt | 2 +- basis/debugger/windows/platforms.txt | 1 + basis/debugger/windows/tags.txt | 1 - basis/editors/editpadlite/tags.txt | 2 +- basis/editors/editpadpro/tags.txt | 2 +- basis/editors/editplus/tags.txt | 2 +- basis/editors/emacs/tags.txt | 2 +- basis/editors/emacs/windows/tags.txt | 2 +- basis/editors/emeditor/tags.txt | 2 +- basis/editors/etexteditor/tags.txt | 2 +- basis/editors/gedit/tags.txt | 2 +- basis/editors/gvim/tags.txt | 2 +- basis/editors/gvim/unix/tags.txt | 2 +- basis/editors/gvim/windows/tags.txt | 2 +- basis/editors/jedit/tags.txt | 2 +- basis/editors/macvim/tags.txt | 2 +- basis/editors/notepad/tags.txt | 2 +- basis/editors/notepad2/tags.txt | 2 +- basis/editors/notepadpp/tags.txt | 2 +- basis/editors/scite/tags.txt | 2 +- basis/editors/ted-notepad/tags.txt | 2 +- basis/editors/textedit/tags.txt | 2 +- basis/editors/textmate/tags.txt | 2 +- basis/editors/textpad/tags.txt | 2 +- basis/editors/textwrangler/tags.txt | 2 +- basis/editors/ultraedit/tags.txt | 2 +- basis/editors/vim/generate-syntax/tags.txt | 2 +- basis/editors/vim/tags.txt | 2 +- basis/editors/wordpad/tags.txt | 2 +- basis/environment/unix/macosx/platforms.txt | 1 + basis/environment/unix/macosx/tags.txt | 1 - basis/environment/unix/platforms.txt | 1 + basis/environment/unix/tags.txt | 1 - basis/environment/winnt/platforms.txt | 1 + basis/environment/winnt/tags.txt | 1 - basis/game/input/dinput/platforms.txt | 1 + basis/game/input/dinput/tags.txt | 1 - basis/game/input/iokit/platforms.txt | 1 + basis/game/input/iokit/tags.txt | 1 - basis/game/input/linux/platforms.txt | 1 + basis/game/input/linux/tags.txt | 1 - basis/game/input/xinput/platforms.txt | 1 + basis/game/input/xinput/tags.txt | 1 - basis/io/backend/unix/bsd/platforms.txt | 1 + basis/io/backend/unix/bsd/tags.txt | 1 - basis/io/backend/unix/freebsd/platforms.txt | 1 + basis/io/backend/unix/freebsd/tags.txt | 1 - basis/io/backend/unix/linux/platforms.txt | 1 + basis/io/backend/unix/linux/tags.txt | 1 - basis/io/backend/unix/macosx/platforms.txt | 1 + basis/io/backend/unix/macosx/tags.txt | 1 - .../unix/multiplexers/epoll/platforms.txt | 1 + .../backend/unix/multiplexers/epoll/tags.txt | 1 - .../unix/multiplexers/kqueue/platforms.txt | 1 + .../backend/unix/multiplexers/kqueue/tags.txt | 1 - .../backend/unix/multiplexers/platforms.txt | 1 + .../unix/multiplexers/run-loop/platforms.txt | 1 + .../unix/multiplexers/run-loop/tags.txt | 1 - .../unix/multiplexers/select/platforms.txt | 1 + .../backend/unix/multiplexers/select/tags.txt | 1 - basis/io/backend/unix/multiplexers/tags.txt | 1 - basis/io/backend/unix/netbsd/platforms.txt | 1 + basis/io/backend/unix/netbsd/tags.txt | 1 - basis/io/backend/unix/openbsd/platforms.txt | 1 + basis/io/backend/unix/openbsd/tags.txt | 1 - basis/io/backend/unix/platforms.txt | 1 + basis/io/backend/unix/tags.txt | 1 - basis/io/backend/windows/nt/platforms.txt | 1 + .../windows/nt/privileges/platforms.txt | 1 + .../io/backend/windows/nt/privileges/tags.txt | 1 - basis/io/backend/windows/nt/tags.txt | 1 - basis/io/backend/windows/platforms.txt | 1 + .../backend/windows/privileges/platforms.txt | 1 + basis/io/backend/windows/privileges/tags.txt | 1 - basis/io/backend/windows/tags.txt | 1 - .../directories/search/windows/platforms.txt | 1 + basis/io/directories/search/windows/tags.txt | 1 - basis/io/directories/unix/linux/platforms.txt | 1 + basis/io/directories/unix/linux/tags.txt | 1 - basis/io/directories/unix/platforms.txt | 1 + basis/io/directories/unix/tags.txt | 1 - basis/io/directories/windows/platforms.txt | 1 + basis/io/directories/windows/tags.txt | 1 - basis/io/files/info/unix/bsd/platforms.txt | 1 + basis/io/files/info/unix/bsd/tags.txt | 1 - .../io/files/info/unix/freebsd/platforms.txt | 1 + basis/io/files/info/unix/freebsd/tags.txt | 1 - basis/io/files/info/unix/linux/platforms.txt | 1 + basis/io/files/info/unix/linux/tags.txt | 1 - basis/io/files/info/unix/macosx/platforms.txt | 1 + basis/io/files/info/unix/macosx/tags.txt | 1 - basis/io/files/info/unix/netbsd/platforms.txt | 1 + basis/io/files/info/unix/netbsd/tags.txt | 1 - .../io/files/info/unix/openbsd/platforms.txt | 1 + basis/io/files/info/unix/openbsd/tags.txt | 1 - basis/io/files/info/unix/platforms.txt | 1 + basis/io/files/info/unix/tags.txt | 1 - basis/io/files/info/windows/platforms.txt | 1 + basis/io/files/info/windows/tags.txt | 1 - basis/io/files/links/unix/platforms.txt | 1 + basis/io/files/links/unix/tags.txt | 1 - basis/io/files/unique/unix/platforms.txt | 1 + basis/io/files/unique/unix/tags.txt | 1 - basis/io/files/unique/windows/platforms.txt | 1 + basis/io/files/unique/windows/tags.txt | 1 - basis/io/files/unix/platforms.txt | 1 + basis/io/files/unix/tags.txt | 1 - basis/io/files/windows/nt/platforms.txt | 1 + basis/io/files/windows/nt/tags.txt | 1 - basis/io/files/windows/platforms.txt | 1 + basis/io/files/windows/tags.txt | 1 - basis/io/launcher/unix/parser/platforms.txt | 1 + basis/io/launcher/unix/parser/tags.txt | 1 - basis/io/launcher/unix/platforms.txt | 1 + basis/io/launcher/unix/tags.txt | 1 - basis/io/launcher/windows/nt/platforms.txt | 1 + basis/io/launcher/windows/nt/tags.txt | 1 - basis/io/launcher/windows/platforms.txt | 1 + basis/io/launcher/windows/tags.txt | 1 - basis/io/mmap/unix/platforms.txt | 1 + basis/io/mmap/unix/tags.txt | 1 - basis/io/mmap/windows/platforms.txt | 1 + basis/io/mmap/windows/tags.txt | 1 - basis/io/monitors/linux/platforms.txt | 1 + basis/io/monitors/linux/tags.txt | 1 - basis/io/monitors/macosx/platforms.txt | 1 + basis/io/monitors/macosx/tags.txt | 1 - basis/io/monitors/windows/nt/platforms.txt | 1 + basis/io/monitors/windows/nt/tags.txt | 1 - basis/io/pipes/unix/platforms.txt | 1 + basis/io/pipes/unix/tags.txt | 1 - basis/io/pipes/windows/nt/platforms.txt | 1 + basis/io/pipes/windows/nt/tags.txt | 1 - basis/io/sockets/secure/unix/platforms.txt | 1 + basis/io/sockets/secure/unix/tags.txt | 1 - basis/io/sockets/unix/platforms.txt | 1 + basis/io/sockets/unix/tags.txt | 1 - basis/io/sockets/windows/nt/platforms.txt | 1 + basis/io/sockets/windows/nt/tags.txt | 1 - basis/io/sockets/windows/platforms.txt | 1 + basis/io/sockets/windows/tags.txt | 1 - basis/iokit/hid/platforms.txt | 1 + basis/iokit/hid/tags.txt | 1 - basis/iokit/platforms.txt | 1 + basis/iokit/tags.txt | 1 - basis/math/floats/env/ppc/tags.txt | 2 +- basis/math/floats/env/x86/32/tags.txt | 2 +- basis/math/floats/env/x86/64/tags.txt | 2 +- basis/math/floats/env/x86/tags.txt | 2 +- basis/opengl/gl/macosx/platforms.txt | 1 + basis/opengl/gl/macosx/tags.txt | 1 - basis/opengl/gl/unix/platforms.txt | 1 + basis/opengl/gl/unix/tags.txt | 1 - basis/opengl/gl/windows/platforms.txt | 1 + basis/opengl/gl/windows/tags.txt | 1 - basis/random/unix/platforms.txt | 1 + basis/random/unix/tags.txt | 1 - basis/random/windows/platforms.txt | 1 + basis/random/windows/tags.txt | 1 - basis/system-info/linux/platforms.txt | 1 + basis/system-info/linux/tags.txt | 1 - basis/system-info/macosx/platforms.txt | 1 + basis/system-info/macosx/tags.txt | 1 - basis/system-info/windows/ce/platforms.txt | 1 + basis/system-info/windows/ce/tags.txt | 1 - basis/system-info/windows/nt/platforms.txt | 1 + basis/system-info/windows/nt/tags.txt | 1 - basis/system-info/windows/platforms.txt | 1 + basis/system-info/windows/tags.txt | 1 - basis/tools/cocoa/platforms.txt | 1 + basis/tools/cocoa/tags.txt | 1 - basis/tools/deploy/libraries/tags.txt | 1 - .../tools/deploy/libraries/unix/platforms.txt | 1 + basis/tools/deploy/libraries/unix/tags.txt | 1 - .../deploy/libraries/windows/platforms.txt | 1 + basis/tools/deploy/libraries/windows/tags.txt | 1 - basis/tools/deploy/macosx/platforms.txt | 1 + basis/tools/deploy/macosx/tags.txt | 1 - basis/tools/deploy/test/14/platforms.txt | 1 + basis/tools/deploy/test/14/tags.txt | 1 - basis/tools/deploy/unix/platforms.txt | 1 + basis/tools/deploy/unix/tags.txt | 1 - basis/tools/deploy/windows/ico/platforms.txt | 1 + basis/tools/deploy/windows/ico/tags.txt | 1 - basis/tools/deploy/windows/platforms.txt | 1 + basis/tools/deploy/windows/tags.txt | 1 - basis/tools/disassembler/gdb/tags.txt | 2 +- basis/tools/disassembler/udis/tags.txt | 2 +- basis/tools/files/tags.txt | 1 - basis/tools/files/unix/platforms.txt | 1 + basis/tools/files/unix/tags.txt | 1 - basis/tools/files/windows/platforms.txt | 1 + basis/tools/files/windows/tags.txt | 1 - basis/tools/scaffold/scaffold.factor | 14 ++--- basis/tools/scaffold/windows/platforms.txt | 1 + basis/tools/scaffold/windows/tags.txt | 1 - basis/ui/backend/cocoa/platforms.txt | 1 + basis/ui/backend/cocoa/tags.txt | 1 - basis/ui/backend/cocoa/tools/platforms.txt | 1 + basis/ui/backend/cocoa/tools/tags.txt | 1 - basis/ui/backend/cocoa/views/platforms.txt | 1 + basis/ui/backend/cocoa/views/tags.txt | 1 - basis/ui/backend/windows/platforms.txt | 1 + basis/ui/backend/windows/tags.txt | 1 - basis/ui/backend/x11/tags.txt | 2 +- basis/ui/text/core-text/platforms.txt | 1 + basis/ui/text/core-text/tags.txt | 1 - basis/ui/text/pango/tags.txt | 2 +- basis/ui/text/uniscribe/platforms.txt | 1 + basis/ui/text/uniscribe/tags.txt | 1 - basis/unix/debugger/platforms.txt | 1 + basis/unix/debugger/tags.txt | 1 - basis/unix/ffi/bsd/freebsd/platforms.txt | 1 + basis/unix/ffi/bsd/freebsd/tags.txt | 1 - basis/unix/ffi/bsd/macosx/platforms.txt | 1 + basis/unix/ffi/bsd/macosx/tags.txt | 1 - basis/unix/ffi/bsd/netbsd/platforms.txt | 1 + basis/unix/ffi/bsd/netbsd/tags.txt | 1 - basis/unix/ffi/bsd/openbsd/platforms.txt | 1 + basis/unix/ffi/bsd/openbsd/tags.txt | 1 - basis/unix/ffi/bsd/platforms.txt | 1 + basis/unix/ffi/bsd/tags.txt | 1 - basis/unix/ffi/linux/platforms.txt | 1 + basis/unix/ffi/linux/tags.txt | 1 - basis/unix/ffi/platforms.txt | 1 + basis/unix/ffi/solaris/platforms.txt | 1 + basis/unix/ffi/solaris/tags.txt | 1 - basis/unix/ffi/tags.txt | 1 - basis/unix/getfsstat/freebsd/platforms.txt | 1 + basis/unix/getfsstat/freebsd/tags.txt | 1 - basis/unix/getfsstat/macosx/platforms.txt | 1 + basis/unix/getfsstat/macosx/tags.txt | 1 - basis/unix/getfsstat/netbsd/platforms.txt | 1 + basis/unix/getfsstat/netbsd/tags.txt | 1 - basis/unix/getfsstat/openbsd/platforms.txt | 1 + basis/unix/getfsstat/openbsd/tags.txt | 1 - basis/unix/groups/platforms.txt | 1 + basis/unix/groups/tags.txt | 1 - basis/unix/kqueue/freebsd/platforms.txt | 1 + basis/unix/kqueue/freebsd/tags.txt | 1 - basis/unix/kqueue/macosx/platforms.txt | 1 + basis/unix/kqueue/macosx/tags.txt | 1 - basis/unix/kqueue/netbsd/platforms.txt | 1 + basis/unix/kqueue/netbsd/tags.txt | 1 - basis/unix/kqueue/openbsd/platforms.txt | 1 + basis/unix/kqueue/openbsd/tags.txt | 1 - basis/unix/kqueue/platforms.txt | 1 + basis/unix/kqueue/tags.txt | 1 - basis/unix/linux/epoll/platforms.txt | 1 + basis/unix/linux/epoll/tags.txt | 1 - basis/unix/linux/inotify/platforms.txt | 1 + basis/unix/linux/inotify/tags.txt | 1 - basis/unix/linux/platforms.txt | 1 + basis/unix/linux/tags.txt | 1 - basis/unix/platforms.txt | 1 + basis/unix/process/platforms.txt | 1 + basis/unix/process/tags.txt | 1 - basis/unix/stat/freebsd/platforms.txt | 1 + basis/unix/stat/freebsd/tags.txt | 1 - basis/unix/stat/linux/32/tags.txt | 2 +- basis/unix/stat/linux/64/tags.txt | 2 +- basis/unix/stat/linux/platforms.txt | 1 + basis/unix/stat/linux/tags.txt | 1 - basis/unix/stat/macosx/platforms.txt | 1 + basis/unix/stat/macosx/tags.txt | 1 - basis/unix/stat/netbsd/32/tags.txt | 2 +- basis/unix/stat/netbsd/64/tags.txt | 2 +- basis/unix/stat/netbsd/platforms.txt | 1 + basis/unix/stat/netbsd/tags.txt | 1 - basis/unix/stat/openbsd/platforms.txt | 1 + basis/unix/stat/openbsd/tags.txt | 1 - basis/unix/stat/platforms.txt | 1 + basis/unix/stat/tags.txt | 1 - basis/unix/statfs/freebsd/platforms.txt | 1 + basis/unix/statfs/freebsd/tags.txt | 1 - basis/unix/statfs/linux/platforms.txt | 1 + basis/unix/statfs/linux/tags.txt | 1 - basis/unix/statfs/macosx/platforms.txt | 1 + basis/unix/statfs/macosx/tags.txt | 1 - basis/unix/statfs/openbsd/platforms.txt | 1 + basis/unix/statfs/openbsd/tags.txt | 1 - basis/unix/statvfs/freebsd/platforms.txt | 1 + basis/unix/statvfs/freebsd/tags.txt | 1 - basis/unix/statvfs/linux/platforms.txt | 1 + basis/unix/statvfs/linux/tags.txt | 1 - basis/unix/statvfs/macosx/platforms.txt | 1 + basis/unix/statvfs/macosx/tags.txt | 1 - basis/unix/statvfs/netbsd/platforms.txt | 1 + basis/unix/statvfs/netbsd/tags.txt | 1 - basis/unix/statvfs/openbsd/platforms.txt | 1 + basis/unix/statvfs/openbsd/tags.txt | 1 - basis/unix/statvfs/platforms.txt | 1 + basis/unix/statvfs/tags.txt | 1 - basis/unix/tags.txt | 1 - basis/unix/time/platforms.txt | 1 + basis/unix/time/tags.txt | 1 - basis/unix/types/freebsd/platforms.txt | 1 + basis/unix/types/freebsd/tags.txt | 1 - basis/unix/types/linux/platforms.txt | 1 + basis/unix/types/linux/tags.txt | 1 - basis/unix/types/macosx/platforms.txt | 1 + basis/unix/types/macosx/tags.txt | 1 - basis/unix/types/netbsd/32/tags.txt | 2 +- basis/unix/types/netbsd/64/tags.txt | 2 +- basis/unix/types/netbsd/platforms.txt | 1 + basis/unix/types/netbsd/tags.txt | 1 - basis/unix/types/openbsd/platforms.txt | 1 + basis/unix/types/openbsd/tags.txt | 1 - basis/unix/types/platforms.txt | 1 + basis/unix/types/tags.txt | 1 - basis/unix/users/bsd/platforms.txt | 1 + basis/unix/users/bsd/tags.txt | 1 - basis/unix/users/platforms.txt | 1 + basis/unix/users/tags.txt | 1 - basis/unix/utilities/platforms.txt | 1 + basis/unix/utilities/tags.txt | 1 - basis/unix/utmpx/macosx/platforms.txt | 1 + basis/unix/utmpx/macosx/tags.txt | 1 - basis/unix/utmpx/netbsd/platforms.txt | 1 + basis/unix/utmpx/netbsd/tags.txt | 1 - basis/unix/utmpx/platforms.txt | 1 + basis/unix/utmpx/tags.txt | 1 - basis/vocabs/metadata/authors.txt | 3 +- basis/vocabs/metadata/metadata.factor | 55 +++++++++++++++---- basis/windows/advapi32/platforms.txt | 1 + basis/windows/advapi32/tags.txt | 1 - basis/windows/ce/platforms.txt | 1 + basis/windows/ce/tags.txt | 1 - basis/windows/com/platforms.txt | 1 + basis/windows/com/prettyprint/platforms.txt | 1 + basis/windows/com/prettyprint/tags.txt | 1 - basis/windows/com/syntax/platforms.txt | 1 + basis/windows/com/syntax/tags.txt | 1 - basis/windows/com/tags.txt | 1 - basis/windows/com/wrapper/platforms.txt | 1 + basis/windows/com/wrapper/tags.txt | 1 - basis/windows/directx/audiodefs/platforms.txt | 1 + basis/windows/directx/audiodefs/tags.txt | 1 - basis/windows/directx/d2d1/platforms.txt | 1 + basis/windows/directx/d2d1/tags.txt | 1 - .../directx/d2dbasetypes/platforms.txt | 1 + basis/windows/directx/d2dbasetypes/tags.txt | 1 - basis/windows/directx/d2derr/platforms.txt | 1 + basis/windows/directx/d2derr/tags.txt | 1 - basis/windows/directx/d3d10/platforms.txt | 1 + basis/windows/directx/d3d10/tags.txt | 1 - basis/windows/directx/d3d10_1/platforms.txt | 1 + basis/windows/directx/d3d10_1/tags.txt | 1 - .../directx/d3d10_1shader/platforms.txt | 1 + basis/windows/directx/d3d10_1shader/tags.txt | 1 - .../windows/directx/d3d10effect/platforms.txt | 1 + basis/windows/directx/d3d10effect/tags.txt | 1 - basis/windows/directx/d3d10misc/platforms.txt | 1 + basis/windows/directx/d3d10misc/tags.txt | 1 - .../windows/directx/d3d10shader/platforms.txt | 1 + basis/windows/directx/d3d10shader/tags.txt | 1 - basis/windows/directx/d3d11/platforms.txt | 1 + basis/windows/directx/d3d11/tags.txt | 1 - .../windows/directx/d3d11shader/platforms.txt | 1 + basis/windows/directx/d3d11shader/tags.txt | 1 - basis/windows/directx/d3d9/platforms.txt | 1 + basis/windows/directx/d3d9/tags.txt | 1 - basis/windows/directx/d3d9caps/platforms.txt | 1 + basis/windows/directx/d3d9caps/tags.txt | 1 - basis/windows/directx/d3d9types/platforms.txt | 1 + basis/windows/directx/d3d9types/tags.txt | 1 - basis/windows/directx/d3dcommon/platforms.txt | 1 + basis/windows/directx/d3dcommon/tags.txt | 1 - .../windows/directx/d3dcompiler/platforms.txt | 1 + basis/windows/directx/d3dcompiler/tags.txt | 1 - basis/windows/directx/d3dcsx/platforms.txt | 1 + basis/windows/directx/d3dcsx/tags.txt | 1 - basis/windows/directx/d3dx10/platforms.txt | 1 + basis/windows/directx/d3dx10/tags.txt | 1 - .../windows/directx/d3dx10async/platforms.txt | 1 + basis/windows/directx/d3dx10async/tags.txt | 1 - .../windows/directx/d3dx10core/platforms.txt | 1 + basis/windows/directx/d3dx10core/tags.txt | 1 - .../windows/directx/d3dx10math/platforms.txt | 1 + basis/windows/directx/d3dx10math/tags.txt | 1 - .../windows/directx/d3dx10mesh/platforms.txt | 1 + basis/windows/directx/d3dx10mesh/tags.txt | 1 - basis/windows/directx/d3dx10tex/platforms.txt | 1 + basis/windows/directx/d3dx10tex/tags.txt | 1 - basis/windows/directx/d3dx11/platforms.txt | 1 + basis/windows/directx/d3dx11/tags.txt | 1 - .../windows/directx/d3dx11async/platforms.txt | 1 + basis/windows/directx/d3dx11async/tags.txt | 1 - .../windows/directx/d3dx11core/platforms.txt | 1 + basis/windows/directx/d3dx11core/tags.txt | 1 - basis/windows/directx/d3dx11tex/platforms.txt | 1 + basis/windows/directx/d3dx11tex/tags.txt | 1 - basis/windows/directx/d3dx9/platforms.txt | 1 + basis/windows/directx/d3dx9/tags.txt | 1 - basis/windows/directx/d3dx9anim/platforms.txt | 1 + basis/windows/directx/d3dx9anim/tags.txt | 1 - basis/windows/directx/d3dx9core/platforms.txt | 1 + basis/windows/directx/d3dx9core/tags.txt | 1 - .../windows/directx/d3dx9effect/platforms.txt | 1 + basis/windows/directx/d3dx9effect/tags.txt | 1 - basis/windows/directx/d3dx9math/platforms.txt | 1 + basis/windows/directx/d3dx9math/tags.txt | 1 - basis/windows/directx/d3dx9mesh/platforms.txt | 1 + basis/windows/directx/d3dx9mesh/tags.txt | 1 - .../windows/directx/d3dx9shader/platforms.txt | 1 + basis/windows/directx/d3dx9shader/tags.txt | 1 - .../windows/directx/d3dx9shape/platforms.txt | 1 + basis/windows/directx/d3dx9shape/tags.txt | 1 - basis/windows/directx/d3dx9tex/platforms.txt | 1 + basis/windows/directx/d3dx9tex/tags.txt | 1 - basis/windows/directx/d3dx9xof/platforms.txt | 1 + basis/windows/directx/d3dx9xof/tags.txt | 1 - basis/windows/directx/dcommon/platforms.txt | 1 + basis/windows/directx/dcommon/tags.txt | 1 - .../directx/dinput/constants/platforms.txt | 1 + .../windows/directx/dinput/constants/tags.txt | 1 - basis/windows/directx/dinput/platforms.txt | 1 + basis/windows/directx/dinput/tags.txt | 1 - basis/windows/directx/dwrite/platforms.txt | 1 + basis/windows/directx/dwrite/tags.txt | 1 - basis/windows/directx/dxfile/platforms.txt | 1 + basis/windows/directx/dxfile/tags.txt | 1 - basis/windows/directx/dxgi/platforms.txt | 1 + basis/windows/directx/dxgi/tags.txt | 1 - .../windows/directx/dxgiformat/platforms.txt | 1 + basis/windows/directx/dxgiformat/tags.txt | 1 - basis/windows/directx/dxgitype/platforms.txt | 1 + basis/windows/directx/dxgitype/tags.txt | 1 - basis/windows/directx/x3daudio/platforms.txt | 1 + basis/windows/directx/x3daudio/tags.txt | 1 - basis/windows/directx/xact3/platforms.txt | 1 + basis/windows/directx/xact3/tags.txt | 1 - basis/windows/directx/xapo/platforms.txt | 1 + basis/windows/directx/xapo/tags.txt | 1 - basis/windows/directx/xapofx/platforms.txt | 1 + basis/windows/directx/xapofx/tags.txt | 1 - basis/windows/directx/xaudio2/platforms.txt | 1 + basis/windows/directx/xaudio2/tags.txt | 1 - basis/windows/directx/xaudio2fx/platforms.txt | 1 + basis/windows/directx/xaudio2fx/tags.txt | 1 - basis/windows/directx/xinput/platforms.txt | 1 + basis/windows/directx/xinput/tags.txt | 1 - basis/windows/dragdrop-listener/platforms.txt | 1 + basis/windows/dragdrop-listener/tags.txt | 1 - basis/windows/dwmapi/platforms.txt | 1 + basis/windows/dwmapi/tags.txt | 1 - basis/windows/errors/platforms.txt | 1 + basis/windows/errors/tags.txt | 1 - basis/windows/fonts/platforms.txt | 1 + basis/windows/fonts/tags.txt | 1 - basis/windows/gdi32/platforms.txt | 1 + basis/windows/gdi32/tags.txt | 1 - basis/windows/kernel32/platforms.txt | 1 + basis/windows/kernel32/tags.txt | 1 - basis/windows/messages/platforms.txt | 1 + basis/windows/messages/tags.txt | 1 - basis/windows/nt/platforms.txt | 1 + basis/windows/nt/tags.txt | 1 - basis/windows/offscreen/platforms.txt | 1 + basis/windows/offscreen/tags.txt | 1 - basis/windows/ole32/platforms.txt | 1 + basis/windows/ole32/tags.txt | 1 - basis/windows/opengl32/platforms.txt | 1 + basis/windows/opengl32/tags.txt | 1 - basis/windows/platforms.txt | 1 + basis/windows/psapi/platforms.txt | 1 + basis/windows/psapi/tags.txt | 1 - basis/windows/shell32/platforms.txt | 1 + basis/windows/shell32/tags.txt | 1 - basis/windows/tags.txt | 1 - basis/windows/time/platforms.txt | 1 + basis/windows/time/tags.txt | 1 - basis/windows/types/platforms.txt | 1 + basis/windows/types/tags.txt | 1 - basis/windows/uniscribe/platforms.txt | 1 + basis/windows/uniscribe/tags.txt | 1 - basis/windows/user32/platforms.txt | 1 + basis/windows/user32/tags.txt | 1 - basis/windows/usp10/platforms.txt | 1 + basis/windows/usp10/tags.txt | 1 - basis/windows/winsock/platforms.txt | 1 + basis/windows/winsock/tags.txt | 1 - basis/x11/io/unix/platforms.txt | 1 + basis/x11/io/unix/tags.txt | 1 - basis/x11/windows/platforms.txt | 1 + basis/x11/windows/tags.txt | 1 - core/vocabs/loader/loader.factor | 11 +++- core/vocabs/loader/test/a/a.factor | 2 +- core/vocabs/loader/test/a/tags.txt | 2 +- core/vocabs/loader/test/b/tags.txt | 2 +- core/vocabs/loader/test/c/tags.txt | 2 +- core/vocabs/loader/test/d/tags.txt | 2 +- core/vocabs/loader/test/e/tags.txt | 2 +- core/vocabs/loader/test/f/tags.txt | 2 +- core/vocabs/loader/test/g/tags.txt | 2 +- core/vocabs/loader/test/h/tags.txt | 2 +- core/vocabs/loader/test/i/tags.txt | 2 +- core/vocabs/loader/test/j/tags.txt | 2 +- core/vocabs/loader/test/k/tags.txt | 2 +- core/vocabs/loader/test/l/tags.txt | 2 +- extra/couchdb/tags.txt | 2 +- extra/curses/ffi/platforms.txt | 1 + extra/curses/ffi/tags.txt | 1 - extra/curses/platforms.txt | 1 + extra/curses/tags.txt | 1 - extra/ecdsa/tags.txt | 2 +- extra/io/serial/tags.txt | 1 - extra/io/serial/unix/bsd/platforms.txt | 1 + extra/io/serial/unix/bsd/tags.txt | 1 - extra/io/serial/unix/linux/platforms.txt | 1 + extra/io/serial/unix/linux/tags.txt | 1 - extra/io/serial/unix/platforms.txt | 1 + extra/io/serial/unix/tags.txt | 1 - .../io/serial/unix/termios/bsd/platforms.txt | 1 + extra/io/serial/unix/termios/bsd/tags.txt | 1 - .../serial/unix/termios/linux/platforms.txt | 1 + extra/io/serial/unix/termios/linux/tags.txt | 1 - extra/io/serial/unix/termios/platforms.txt | 1 + extra/io/serial/unix/termios/tags.txt | 1 - extra/io/serial/windows/platforms.txt | 1 + extra/io/serial/windows/tags.txt | 1 - extra/libusb/platforms.txt | 1 + extra/libusb/tags.txt | 1 - extra/llvm/core/tags.txt | 2 +- extra/llvm/engine/tags.txt | 2 +- extra/llvm/invoker/tags.txt | 2 +- extra/llvm/jit/tags.txt | 2 +- extra/llvm/reader/tags.txt | 2 +- extra/llvm/tags.txt | 2 +- extra/llvm/types/tags.txt | 2 +- extra/llvm/wrappers/tags.txt | 2 +- extra/merger/platforms.txt | 1 + extra/merger/tags.txt | 2 - extra/openal/alut/macosx/platforms.txt | 1 + extra/openal/alut/macosx/tags.txt | 1 - extra/qtkit/platforms.txt | 1 + extra/qtkit/tags.txt | 1 - extra/webkit-demo/platforms.txt | 1 + extra/webkit-demo/tags.txt | 1 - 616 files changed, 400 insertions(+), 369 deletions(-) create mode 100644 basis/calendar/unix/platforms.txt delete mode 100644 basis/calendar/unix/tags.txt create mode 100644 basis/calendar/windows/platforms.txt delete mode 100755 basis/calendar/windows/tags.txt create mode 100644 basis/cocoa/application/platforms.txt delete mode 100644 basis/cocoa/application/tags.txt create mode 100644 basis/cocoa/callbacks/platforms.txt delete mode 100644 basis/cocoa/callbacks/tags.txt create mode 100644 basis/cocoa/dialogs/platforms.txt delete mode 100644 basis/cocoa/dialogs/tags.txt create mode 100644 basis/cocoa/enumeration/platforms.txt delete mode 100644 basis/cocoa/enumeration/tags.txt create mode 100644 basis/cocoa/messages/platforms.txt delete mode 100644 basis/cocoa/messages/tags.txt create mode 100644 basis/cocoa/nibs/platforms.txt delete mode 100644 basis/cocoa/nibs/tags.txt create mode 100644 basis/cocoa/pasteboard/platforms.txt delete mode 100644 basis/cocoa/pasteboard/tags.txt create mode 100644 basis/cocoa/platforms.txt create mode 100644 basis/cocoa/plists/platforms.txt delete mode 100644 basis/cocoa/plists/tags.txt create mode 100644 basis/cocoa/runtime/platforms.txt delete mode 100644 basis/cocoa/runtime/tags.txt create mode 100644 basis/cocoa/subclassing/platforms.txt delete mode 100644 basis/cocoa/subclassing/tags.txt create mode 100644 basis/cocoa/types/platforms.txt delete mode 100644 basis/cocoa/types/tags.txt create mode 100644 basis/cocoa/views/platforms.txt delete mode 100644 basis/cocoa/views/tags.txt create mode 100644 basis/cocoa/windows/platforms.txt delete mode 100644 basis/cocoa/windows/tags.txt create mode 100644 basis/core-foundation/arrays/platforms.txt create mode 100644 basis/core-foundation/attributed-strings/platforms.txt create mode 100644 basis/core-foundation/bundles/platforms.txt create mode 100644 basis/core-foundation/data/platforms.txt create mode 100644 basis/core-foundation/dictionaries/platforms.txt create mode 100644 basis/core-foundation/file-descriptors/platforms.txt create mode 100644 basis/core-foundation/fsevents/platforms.txt delete mode 100644 basis/core-foundation/fsevents/tags.txt create mode 100644 basis/core-foundation/numbers/platforms.txt delete mode 100644 basis/core-foundation/numbers/tags.txt create mode 100644 basis/core-foundation/platforms.txt create mode 100644 basis/core-foundation/run-loop/platforms.txt delete mode 100644 basis/core-foundation/run-loop/tags.txt create mode 100644 basis/core-foundation/strings/platforms.txt create mode 100644 basis/core-foundation/timers/platforms.txt create mode 100644 basis/core-foundation/urls/platforms.txt create mode 100644 basis/core-foundation/utilities/platforms.txt delete mode 100644 basis/core-foundation/utilities/tags.txt create mode 100644 basis/core-graphics/platforms.txt create mode 100644 basis/core-text/fonts/platforms.txt create mode 100644 basis/core-text/platforms.txt delete mode 100644 basis/cpu/ppc/assembler/backend/tags.txt delete mode 100644 basis/cpu/x86/assembler/syntax/tags.txt create mode 100644 basis/debugger/windows/platforms.txt delete mode 100644 basis/debugger/windows/tags.txt create mode 100644 basis/environment/unix/macosx/platforms.txt delete mode 100644 basis/environment/unix/macosx/tags.txt create mode 100644 basis/environment/unix/platforms.txt delete mode 100644 basis/environment/unix/tags.txt create mode 100644 basis/environment/winnt/platforms.txt delete mode 100644 basis/environment/winnt/tags.txt create mode 100644 basis/game/input/dinput/platforms.txt create mode 100644 basis/game/input/iokit/platforms.txt create mode 100644 basis/game/input/linux/platforms.txt create mode 100644 basis/game/input/xinput/platforms.txt create mode 100644 basis/io/backend/unix/bsd/platforms.txt delete mode 100644 basis/io/backend/unix/bsd/tags.txt create mode 100644 basis/io/backend/unix/freebsd/platforms.txt delete mode 100644 basis/io/backend/unix/freebsd/tags.txt create mode 100644 basis/io/backend/unix/linux/platforms.txt delete mode 100644 basis/io/backend/unix/linux/tags.txt create mode 100644 basis/io/backend/unix/macosx/platforms.txt delete mode 100644 basis/io/backend/unix/macosx/tags.txt create mode 100644 basis/io/backend/unix/multiplexers/epoll/platforms.txt delete mode 100644 basis/io/backend/unix/multiplexers/epoll/tags.txt create mode 100644 basis/io/backend/unix/multiplexers/kqueue/platforms.txt delete mode 100644 basis/io/backend/unix/multiplexers/kqueue/tags.txt create mode 100644 basis/io/backend/unix/multiplexers/platforms.txt create mode 100644 basis/io/backend/unix/multiplexers/run-loop/platforms.txt delete mode 100644 basis/io/backend/unix/multiplexers/run-loop/tags.txt create mode 100644 basis/io/backend/unix/multiplexers/select/platforms.txt delete mode 100644 basis/io/backend/unix/multiplexers/select/tags.txt delete mode 100755 basis/io/backend/unix/multiplexers/tags.txt create mode 100644 basis/io/backend/unix/netbsd/platforms.txt delete mode 100644 basis/io/backend/unix/netbsd/tags.txt create mode 100644 basis/io/backend/unix/openbsd/platforms.txt delete mode 100644 basis/io/backend/unix/openbsd/tags.txt create mode 100644 basis/io/backend/unix/platforms.txt delete mode 100644 basis/io/backend/unix/tags.txt create mode 100644 basis/io/backend/windows/nt/platforms.txt create mode 100644 basis/io/backend/windows/nt/privileges/platforms.txt delete mode 100644 basis/io/backend/windows/nt/privileges/tags.txt delete mode 100644 basis/io/backend/windows/nt/tags.txt create mode 100644 basis/io/backend/windows/platforms.txt create mode 100644 basis/io/backend/windows/privileges/platforms.txt delete mode 100644 basis/io/backend/windows/privileges/tags.txt delete mode 100755 basis/io/backend/windows/tags.txt create mode 100644 basis/io/directories/search/windows/platforms.txt delete mode 100644 basis/io/directories/search/windows/tags.txt create mode 100644 basis/io/directories/unix/linux/platforms.txt delete mode 100644 basis/io/directories/unix/linux/tags.txt create mode 100644 basis/io/directories/unix/platforms.txt delete mode 100644 basis/io/directories/unix/tags.txt create mode 100644 basis/io/directories/windows/platforms.txt delete mode 100644 basis/io/directories/windows/tags.txt create mode 100644 basis/io/files/info/unix/bsd/platforms.txt delete mode 100644 basis/io/files/info/unix/bsd/tags.txt create mode 100644 basis/io/files/info/unix/freebsd/platforms.txt delete mode 100644 basis/io/files/info/unix/freebsd/tags.txt create mode 100644 basis/io/files/info/unix/linux/platforms.txt delete mode 100644 basis/io/files/info/unix/linux/tags.txt create mode 100644 basis/io/files/info/unix/macosx/platforms.txt delete mode 100644 basis/io/files/info/unix/macosx/tags.txt create mode 100644 basis/io/files/info/unix/netbsd/platforms.txt delete mode 100644 basis/io/files/info/unix/netbsd/tags.txt create mode 100644 basis/io/files/info/unix/openbsd/platforms.txt delete mode 100644 basis/io/files/info/unix/openbsd/tags.txt create mode 100644 basis/io/files/info/unix/platforms.txt delete mode 100644 basis/io/files/info/unix/tags.txt create mode 100644 basis/io/files/info/windows/platforms.txt delete mode 100644 basis/io/files/info/windows/tags.txt create mode 100644 basis/io/files/links/unix/platforms.txt delete mode 100644 basis/io/files/links/unix/tags.txt create mode 100644 basis/io/files/unique/unix/platforms.txt delete mode 100644 basis/io/files/unique/unix/tags.txt create mode 100644 basis/io/files/unique/windows/platforms.txt delete mode 100644 basis/io/files/unique/windows/tags.txt create mode 100644 basis/io/files/unix/platforms.txt delete mode 100644 basis/io/files/unix/tags.txt create mode 100644 basis/io/files/windows/nt/platforms.txt delete mode 100644 basis/io/files/windows/nt/tags.txt create mode 100644 basis/io/files/windows/platforms.txt delete mode 100644 basis/io/files/windows/tags.txt create mode 100644 basis/io/launcher/unix/parser/platforms.txt delete mode 100644 basis/io/launcher/unix/parser/tags.txt create mode 100644 basis/io/launcher/unix/platforms.txt delete mode 100644 basis/io/launcher/unix/tags.txt create mode 100644 basis/io/launcher/windows/nt/platforms.txt delete mode 100644 basis/io/launcher/windows/nt/tags.txt create mode 100644 basis/io/launcher/windows/platforms.txt delete mode 100644 basis/io/launcher/windows/tags.txt create mode 100644 basis/io/mmap/unix/platforms.txt delete mode 100644 basis/io/mmap/unix/tags.txt create mode 100644 basis/io/mmap/windows/platforms.txt delete mode 100644 basis/io/mmap/windows/tags.txt create mode 100644 basis/io/monitors/linux/platforms.txt delete mode 100644 basis/io/monitors/linux/tags.txt create mode 100644 basis/io/monitors/macosx/platforms.txt delete mode 100644 basis/io/monitors/macosx/tags.txt create mode 100644 basis/io/monitors/windows/nt/platforms.txt delete mode 100644 basis/io/monitors/windows/nt/tags.txt create mode 100644 basis/io/pipes/unix/platforms.txt delete mode 100644 basis/io/pipes/unix/tags.txt create mode 100644 basis/io/pipes/windows/nt/platforms.txt delete mode 100644 basis/io/pipes/windows/nt/tags.txt create mode 100644 basis/io/sockets/secure/unix/platforms.txt delete mode 100644 basis/io/sockets/secure/unix/tags.txt create mode 100644 basis/io/sockets/unix/platforms.txt delete mode 100644 basis/io/sockets/unix/tags.txt create mode 100644 basis/io/sockets/windows/nt/platforms.txt delete mode 100644 basis/io/sockets/windows/nt/tags.txt create mode 100644 basis/io/sockets/windows/platforms.txt delete mode 100644 basis/io/sockets/windows/tags.txt create mode 100644 basis/iokit/hid/platforms.txt create mode 100644 basis/iokit/platforms.txt create mode 100644 basis/opengl/gl/macosx/platforms.txt delete mode 100644 basis/opengl/gl/macosx/tags.txt create mode 100644 basis/opengl/gl/unix/platforms.txt delete mode 100644 basis/opengl/gl/unix/tags.txt create mode 100644 basis/opengl/gl/windows/platforms.txt delete mode 100755 basis/opengl/gl/windows/tags.txt create mode 100644 basis/random/unix/platforms.txt delete mode 100644 basis/random/unix/tags.txt create mode 100644 basis/random/windows/platforms.txt delete mode 100755 basis/random/windows/tags.txt create mode 100644 basis/system-info/linux/platforms.txt delete mode 100644 basis/system-info/linux/tags.txt create mode 100644 basis/system-info/macosx/platforms.txt delete mode 100644 basis/system-info/macosx/tags.txt create mode 100644 basis/system-info/windows/ce/platforms.txt delete mode 100644 basis/system-info/windows/ce/tags.txt create mode 100644 basis/system-info/windows/nt/platforms.txt delete mode 100644 basis/system-info/windows/nt/tags.txt create mode 100644 basis/system-info/windows/platforms.txt delete mode 100755 basis/system-info/windows/tags.txt create mode 100644 basis/tools/cocoa/platforms.txt delete mode 100644 basis/tools/cocoa/tags.txt delete mode 100644 basis/tools/deploy/libraries/tags.txt create mode 100644 basis/tools/deploy/libraries/unix/platforms.txt delete mode 100644 basis/tools/deploy/libraries/unix/tags.txt create mode 100644 basis/tools/deploy/libraries/windows/platforms.txt delete mode 100644 basis/tools/deploy/libraries/windows/tags.txt create mode 100644 basis/tools/deploy/macosx/platforms.txt create mode 100644 basis/tools/deploy/test/14/platforms.txt delete mode 100644 basis/tools/deploy/test/14/tags.txt create mode 100644 basis/tools/deploy/unix/platforms.txt create mode 100644 basis/tools/deploy/windows/ico/platforms.txt delete mode 100644 basis/tools/deploy/windows/ico/tags.txt create mode 100644 basis/tools/deploy/windows/platforms.txt delete mode 100644 basis/tools/files/tags.txt create mode 100644 basis/tools/files/unix/platforms.txt delete mode 100644 basis/tools/files/unix/tags.txt create mode 100644 basis/tools/files/windows/platforms.txt delete mode 100644 basis/tools/files/windows/tags.txt create mode 100644 basis/tools/scaffold/windows/platforms.txt delete mode 100644 basis/tools/scaffold/windows/tags.txt create mode 100644 basis/ui/backend/cocoa/platforms.txt delete mode 100644 basis/ui/backend/cocoa/tags.txt create mode 100644 basis/ui/backend/cocoa/tools/platforms.txt delete mode 100644 basis/ui/backend/cocoa/tools/tags.txt create mode 100644 basis/ui/backend/cocoa/views/platforms.txt delete mode 100644 basis/ui/backend/cocoa/views/tags.txt create mode 100644 basis/ui/backend/windows/platforms.txt delete mode 100644 basis/ui/backend/windows/tags.txt create mode 100644 basis/ui/text/core-text/platforms.txt delete mode 100644 basis/ui/text/core-text/tags.txt create mode 100644 basis/ui/text/uniscribe/platforms.txt delete mode 100755 basis/ui/text/uniscribe/tags.txt create mode 100644 basis/unix/debugger/platforms.txt delete mode 100644 basis/unix/debugger/tags.txt create mode 100644 basis/unix/ffi/bsd/freebsd/platforms.txt delete mode 100644 basis/unix/ffi/bsd/freebsd/tags.txt create mode 100644 basis/unix/ffi/bsd/macosx/platforms.txt delete mode 100644 basis/unix/ffi/bsd/macosx/tags.txt create mode 100644 basis/unix/ffi/bsd/netbsd/platforms.txt delete mode 100644 basis/unix/ffi/bsd/netbsd/tags.txt create mode 100644 basis/unix/ffi/bsd/openbsd/platforms.txt delete mode 100644 basis/unix/ffi/bsd/openbsd/tags.txt create mode 100644 basis/unix/ffi/bsd/platforms.txt delete mode 100644 basis/unix/ffi/bsd/tags.txt create mode 100644 basis/unix/ffi/linux/platforms.txt delete mode 100644 basis/unix/ffi/linux/tags.txt create mode 100644 basis/unix/ffi/platforms.txt create mode 100644 basis/unix/ffi/solaris/platforms.txt delete mode 100644 basis/unix/ffi/solaris/tags.txt delete mode 100644 basis/unix/ffi/tags.txt create mode 100644 basis/unix/getfsstat/freebsd/platforms.txt delete mode 100644 basis/unix/getfsstat/freebsd/tags.txt create mode 100644 basis/unix/getfsstat/macosx/platforms.txt delete mode 100644 basis/unix/getfsstat/macosx/tags.txt create mode 100644 basis/unix/getfsstat/netbsd/platforms.txt delete mode 100644 basis/unix/getfsstat/netbsd/tags.txt create mode 100644 basis/unix/getfsstat/openbsd/platforms.txt delete mode 100644 basis/unix/getfsstat/openbsd/tags.txt create mode 100644 basis/unix/groups/platforms.txt delete mode 100644 basis/unix/groups/tags.txt create mode 100644 basis/unix/kqueue/freebsd/platforms.txt delete mode 100644 basis/unix/kqueue/freebsd/tags.txt create mode 100644 basis/unix/kqueue/macosx/platforms.txt delete mode 100644 basis/unix/kqueue/macosx/tags.txt create mode 100644 basis/unix/kqueue/netbsd/platforms.txt delete mode 100644 basis/unix/kqueue/netbsd/tags.txt create mode 100644 basis/unix/kqueue/openbsd/platforms.txt delete mode 100644 basis/unix/kqueue/openbsd/tags.txt create mode 100644 basis/unix/kqueue/platforms.txt delete mode 100644 basis/unix/kqueue/tags.txt create mode 100644 basis/unix/linux/epoll/platforms.txt delete mode 100644 basis/unix/linux/epoll/tags.txt create mode 100644 basis/unix/linux/inotify/platforms.txt delete mode 100644 basis/unix/linux/inotify/tags.txt create mode 100644 basis/unix/linux/platforms.txt delete mode 100644 basis/unix/linux/tags.txt create mode 100644 basis/unix/platforms.txt create mode 100644 basis/unix/process/platforms.txt delete mode 100644 basis/unix/process/tags.txt create mode 100644 basis/unix/stat/freebsd/platforms.txt delete mode 100644 basis/unix/stat/freebsd/tags.txt create mode 100644 basis/unix/stat/linux/platforms.txt delete mode 100644 basis/unix/stat/linux/tags.txt create mode 100644 basis/unix/stat/macosx/platforms.txt delete mode 100644 basis/unix/stat/macosx/tags.txt create mode 100644 basis/unix/stat/netbsd/platforms.txt delete mode 100644 basis/unix/stat/netbsd/tags.txt create mode 100644 basis/unix/stat/openbsd/platforms.txt delete mode 100644 basis/unix/stat/openbsd/tags.txt create mode 100644 basis/unix/stat/platforms.txt delete mode 100644 basis/unix/stat/tags.txt create mode 100644 basis/unix/statfs/freebsd/platforms.txt delete mode 100644 basis/unix/statfs/freebsd/tags.txt create mode 100644 basis/unix/statfs/linux/platforms.txt delete mode 100644 basis/unix/statfs/linux/tags.txt create mode 100644 basis/unix/statfs/macosx/platforms.txt delete mode 100644 basis/unix/statfs/macosx/tags.txt create mode 100644 basis/unix/statfs/openbsd/platforms.txt delete mode 100644 basis/unix/statfs/openbsd/tags.txt create mode 100644 basis/unix/statvfs/freebsd/platforms.txt delete mode 100644 basis/unix/statvfs/freebsd/tags.txt create mode 100644 basis/unix/statvfs/linux/platforms.txt delete mode 100644 basis/unix/statvfs/linux/tags.txt create mode 100644 basis/unix/statvfs/macosx/platforms.txt delete mode 100644 basis/unix/statvfs/macosx/tags.txt create mode 100644 basis/unix/statvfs/netbsd/platforms.txt delete mode 100644 basis/unix/statvfs/netbsd/tags.txt create mode 100644 basis/unix/statvfs/openbsd/platforms.txt delete mode 100644 basis/unix/statvfs/openbsd/tags.txt create mode 100644 basis/unix/statvfs/platforms.txt delete mode 100644 basis/unix/statvfs/tags.txt create mode 100644 basis/unix/time/platforms.txt delete mode 100644 basis/unix/time/tags.txt create mode 100644 basis/unix/types/freebsd/platforms.txt delete mode 100644 basis/unix/types/freebsd/tags.txt create mode 100644 basis/unix/types/linux/platforms.txt delete mode 100644 basis/unix/types/linux/tags.txt create mode 100644 basis/unix/types/macosx/platforms.txt delete mode 100644 basis/unix/types/macosx/tags.txt create mode 100644 basis/unix/types/netbsd/platforms.txt delete mode 100644 basis/unix/types/netbsd/tags.txt create mode 100644 basis/unix/types/openbsd/platforms.txt delete mode 100644 basis/unix/types/openbsd/tags.txt create mode 100644 basis/unix/types/platforms.txt delete mode 100644 basis/unix/types/tags.txt create mode 100644 basis/unix/users/bsd/platforms.txt delete mode 100644 basis/unix/users/bsd/tags.txt create mode 100644 basis/unix/users/platforms.txt delete mode 100644 basis/unix/users/tags.txt create mode 100644 basis/unix/utilities/platforms.txt delete mode 100644 basis/unix/utilities/tags.txt create mode 100644 basis/unix/utmpx/macosx/platforms.txt delete mode 100644 basis/unix/utmpx/macosx/tags.txt create mode 100644 basis/unix/utmpx/netbsd/platforms.txt delete mode 100644 basis/unix/utmpx/netbsd/tags.txt create mode 100644 basis/unix/utmpx/platforms.txt delete mode 100644 basis/unix/utmpx/tags.txt create mode 100644 basis/windows/advapi32/platforms.txt delete mode 100644 basis/windows/advapi32/tags.txt create mode 100644 basis/windows/ce/platforms.txt delete mode 100644 basis/windows/ce/tags.txt create mode 100644 basis/windows/com/platforms.txt create mode 100644 basis/windows/com/prettyprint/platforms.txt delete mode 100644 basis/windows/com/prettyprint/tags.txt create mode 100644 basis/windows/com/syntax/platforms.txt create mode 100644 basis/windows/com/wrapper/platforms.txt create mode 100644 basis/windows/directx/audiodefs/platforms.txt create mode 100644 basis/windows/directx/d2d1/platforms.txt create mode 100644 basis/windows/directx/d2dbasetypes/platforms.txt create mode 100644 basis/windows/directx/d2derr/platforms.txt create mode 100644 basis/windows/directx/d3d10/platforms.txt create mode 100644 basis/windows/directx/d3d10_1/platforms.txt create mode 100644 basis/windows/directx/d3d10_1shader/platforms.txt create mode 100644 basis/windows/directx/d3d10effect/platforms.txt create mode 100644 basis/windows/directx/d3d10misc/platforms.txt create mode 100644 basis/windows/directx/d3d10shader/platforms.txt create mode 100644 basis/windows/directx/d3d11/platforms.txt create mode 100644 basis/windows/directx/d3d11shader/platforms.txt create mode 100644 basis/windows/directx/d3d9/platforms.txt create mode 100644 basis/windows/directx/d3d9caps/platforms.txt create mode 100644 basis/windows/directx/d3d9types/platforms.txt create mode 100644 basis/windows/directx/d3dcommon/platforms.txt create mode 100644 basis/windows/directx/d3dcompiler/platforms.txt create mode 100644 basis/windows/directx/d3dcsx/platforms.txt create mode 100644 basis/windows/directx/d3dx10/platforms.txt create mode 100644 basis/windows/directx/d3dx10async/platforms.txt create mode 100644 basis/windows/directx/d3dx10core/platforms.txt create mode 100644 basis/windows/directx/d3dx10math/platforms.txt create mode 100644 basis/windows/directx/d3dx10mesh/platforms.txt create mode 100644 basis/windows/directx/d3dx10tex/platforms.txt create mode 100644 basis/windows/directx/d3dx11/platforms.txt create mode 100644 basis/windows/directx/d3dx11async/platforms.txt create mode 100644 basis/windows/directx/d3dx11core/platforms.txt create mode 100644 basis/windows/directx/d3dx11tex/platforms.txt create mode 100644 basis/windows/directx/d3dx9/platforms.txt create mode 100644 basis/windows/directx/d3dx9anim/platforms.txt create mode 100644 basis/windows/directx/d3dx9core/platforms.txt create mode 100644 basis/windows/directx/d3dx9effect/platforms.txt create mode 100644 basis/windows/directx/d3dx9math/platforms.txt create mode 100644 basis/windows/directx/d3dx9mesh/platforms.txt create mode 100644 basis/windows/directx/d3dx9shader/platforms.txt create mode 100644 basis/windows/directx/d3dx9shape/platforms.txt create mode 100644 basis/windows/directx/d3dx9tex/platforms.txt create mode 100644 basis/windows/directx/d3dx9xof/platforms.txt create mode 100644 basis/windows/directx/dcommon/platforms.txt create mode 100644 basis/windows/directx/dinput/constants/platforms.txt delete mode 100644 basis/windows/directx/dinput/constants/tags.txt create mode 100644 basis/windows/directx/dinput/platforms.txt create mode 100644 basis/windows/directx/dwrite/platforms.txt create mode 100644 basis/windows/directx/dxfile/platforms.txt create mode 100644 basis/windows/directx/dxgi/platforms.txt create mode 100644 basis/windows/directx/dxgiformat/platforms.txt create mode 100644 basis/windows/directx/dxgitype/platforms.txt create mode 100644 basis/windows/directx/x3daudio/platforms.txt create mode 100644 basis/windows/directx/xact3/platforms.txt create mode 100644 basis/windows/directx/xapo/platforms.txt create mode 100644 basis/windows/directx/xapofx/platforms.txt create mode 100644 basis/windows/directx/xaudio2/platforms.txt create mode 100644 basis/windows/directx/xaudio2fx/platforms.txt create mode 100644 basis/windows/directx/xinput/platforms.txt create mode 100644 basis/windows/dragdrop-listener/platforms.txt delete mode 100644 basis/windows/dragdrop-listener/tags.txt create mode 100644 basis/windows/dwmapi/platforms.txt create mode 100644 basis/windows/errors/platforms.txt delete mode 100644 basis/windows/errors/tags.txt create mode 100644 basis/windows/fonts/platforms.txt delete mode 100644 basis/windows/fonts/tags.txt create mode 100644 basis/windows/gdi32/platforms.txt create mode 100644 basis/windows/kernel32/platforms.txt delete mode 100644 basis/windows/kernel32/tags.txt create mode 100644 basis/windows/messages/platforms.txt delete mode 100644 basis/windows/messages/tags.txt create mode 100644 basis/windows/nt/platforms.txt delete mode 100644 basis/windows/nt/tags.txt create mode 100644 basis/windows/offscreen/platforms.txt delete mode 100755 basis/windows/offscreen/tags.txt create mode 100644 basis/windows/ole32/platforms.txt delete mode 100644 basis/windows/ole32/tags.txt create mode 100644 basis/windows/opengl32/platforms.txt delete mode 100644 basis/windows/opengl32/tags.txt create mode 100644 basis/windows/platforms.txt create mode 100644 basis/windows/psapi/platforms.txt create mode 100644 basis/windows/shell32/platforms.txt delete mode 100644 basis/windows/shell32/tags.txt create mode 100644 basis/windows/time/platforms.txt delete mode 100644 basis/windows/time/tags.txt create mode 100644 basis/windows/types/platforms.txt delete mode 100644 basis/windows/types/tags.txt create mode 100644 basis/windows/uniscribe/platforms.txt delete mode 100755 basis/windows/uniscribe/tags.txt create mode 100644 basis/windows/user32/platforms.txt delete mode 100644 basis/windows/user32/tags.txt create mode 100644 basis/windows/usp10/platforms.txt create mode 100644 basis/windows/winsock/platforms.txt delete mode 100644 basis/windows/winsock/tags.txt create mode 100644 basis/x11/io/unix/platforms.txt delete mode 100644 basis/x11/io/unix/tags.txt create mode 100644 basis/x11/windows/platforms.txt delete mode 100644 basis/x11/windows/tags.txt create mode 100644 extra/curses/ffi/platforms.txt delete mode 100644 extra/curses/ffi/tags.txt create mode 100644 extra/curses/platforms.txt delete mode 100644 extra/curses/tags.txt delete mode 100644 extra/io/serial/tags.txt create mode 100644 extra/io/serial/unix/bsd/platforms.txt delete mode 100644 extra/io/serial/unix/bsd/tags.txt create mode 100644 extra/io/serial/unix/linux/platforms.txt delete mode 100644 extra/io/serial/unix/linux/tags.txt create mode 100644 extra/io/serial/unix/platforms.txt delete mode 100644 extra/io/serial/unix/tags.txt create mode 100644 extra/io/serial/unix/termios/bsd/platforms.txt delete mode 100644 extra/io/serial/unix/termios/bsd/tags.txt create mode 100644 extra/io/serial/unix/termios/linux/platforms.txt delete mode 100644 extra/io/serial/unix/termios/linux/tags.txt create mode 100644 extra/io/serial/unix/termios/platforms.txt delete mode 100644 extra/io/serial/unix/termios/tags.txt create mode 100644 extra/io/serial/windows/platforms.txt delete mode 100644 extra/io/serial/windows/tags.txt create mode 100644 extra/libusb/platforms.txt create mode 100644 extra/merger/platforms.txt delete mode 100644 extra/merger/tags.txt create mode 100644 extra/openal/alut/macosx/platforms.txt delete mode 100644 extra/openal/alut/macosx/tags.txt create mode 100644 extra/qtkit/platforms.txt delete mode 100644 extra/qtkit/tags.txt create mode 100644 extra/webkit-demo/platforms.txt delete mode 100644 extra/webkit-demo/tags.txt diff --git a/basis/bootstrap/compiler/timing/tags.txt b/basis/bootstrap/compiler/timing/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/bootstrap/compiler/timing/tags.txt +++ b/basis/bootstrap/compiler/timing/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/calendar/unix/platforms.txt b/basis/calendar/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/calendar/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/calendar/unix/tags.txt b/basis/calendar/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/calendar/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/calendar/windows/platforms.txt b/basis/calendar/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/calendar/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/calendar/windows/tags.txt b/basis/calendar/windows/tags.txt deleted file mode 100755 index 6bf68304bb..0000000000 --- a/basis/calendar/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cocoa/application/platforms.txt b/basis/cocoa/application/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/cocoa/application/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/cocoa/application/tags.txt b/basis/cocoa/application/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cocoa/application/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cocoa/callbacks/platforms.txt b/basis/cocoa/callbacks/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/cocoa/callbacks/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/cocoa/callbacks/tags.txt b/basis/cocoa/callbacks/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cocoa/callbacks/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cocoa/dialogs/platforms.txt b/basis/cocoa/dialogs/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/cocoa/dialogs/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/cocoa/dialogs/tags.txt b/basis/cocoa/dialogs/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cocoa/dialogs/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cocoa/enumeration/platforms.txt b/basis/cocoa/enumeration/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/cocoa/enumeration/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/cocoa/enumeration/tags.txt b/basis/cocoa/enumeration/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cocoa/enumeration/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cocoa/messages/platforms.txt b/basis/cocoa/messages/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/cocoa/messages/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/cocoa/messages/tags.txt b/basis/cocoa/messages/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cocoa/messages/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cocoa/nibs/platforms.txt b/basis/cocoa/nibs/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/cocoa/nibs/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/cocoa/nibs/tags.txt b/basis/cocoa/nibs/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cocoa/nibs/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cocoa/pasteboard/platforms.txt b/basis/cocoa/pasteboard/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/cocoa/pasteboard/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/cocoa/pasteboard/tags.txt b/basis/cocoa/pasteboard/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cocoa/pasteboard/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cocoa/platforms.txt b/basis/cocoa/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/cocoa/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/cocoa/plists/platforms.txt b/basis/cocoa/plists/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/cocoa/plists/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/cocoa/plists/tags.txt b/basis/cocoa/plists/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cocoa/plists/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cocoa/runtime/platforms.txt b/basis/cocoa/runtime/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/cocoa/runtime/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/cocoa/runtime/tags.txt b/basis/cocoa/runtime/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cocoa/runtime/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cocoa/subclassing/platforms.txt b/basis/cocoa/subclassing/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/cocoa/subclassing/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/cocoa/subclassing/tags.txt b/basis/cocoa/subclassing/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cocoa/subclassing/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cocoa/tags.txt b/basis/cocoa/tags.txt index 86dd9eeb91..40fc52b29b 100644 --- a/basis/cocoa/tags.txt +++ b/basis/cocoa/tags.txt @@ -1,3 +1,2 @@ -unportable bindings ffi diff --git a/basis/cocoa/types/platforms.txt b/basis/cocoa/types/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/cocoa/types/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/cocoa/types/tags.txt b/basis/cocoa/types/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cocoa/types/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cocoa/views/platforms.txt b/basis/cocoa/views/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/cocoa/views/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/cocoa/views/tags.txt b/basis/cocoa/views/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cocoa/views/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cocoa/windows/platforms.txt b/basis/cocoa/windows/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/cocoa/windows/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/cocoa/windows/tags.txt b/basis/cocoa/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cocoa/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/core-foundation/arrays/platforms.txt b/basis/core-foundation/arrays/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-foundation/arrays/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-foundation/arrays/tags.txt b/basis/core-foundation/arrays/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/core-foundation/arrays/tags.txt +++ b/basis/core-foundation/arrays/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/core-foundation/attributed-strings/platforms.txt b/basis/core-foundation/attributed-strings/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-foundation/attributed-strings/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-foundation/attributed-strings/tags.txt b/basis/core-foundation/attributed-strings/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/core-foundation/attributed-strings/tags.txt +++ b/basis/core-foundation/attributed-strings/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/core-foundation/bundles/platforms.txt b/basis/core-foundation/bundles/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-foundation/bundles/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-foundation/bundles/tags.txt b/basis/core-foundation/bundles/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/core-foundation/bundles/tags.txt +++ b/basis/core-foundation/bundles/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/core-foundation/data/platforms.txt b/basis/core-foundation/data/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-foundation/data/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-foundation/data/tags.txt b/basis/core-foundation/data/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/core-foundation/data/tags.txt +++ b/basis/core-foundation/data/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/core-foundation/dictionaries/platforms.txt b/basis/core-foundation/dictionaries/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-foundation/dictionaries/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-foundation/dictionaries/tags.txt b/basis/core-foundation/dictionaries/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/core-foundation/dictionaries/tags.txt +++ b/basis/core-foundation/dictionaries/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/core-foundation/file-descriptors/platforms.txt b/basis/core-foundation/file-descriptors/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-foundation/file-descriptors/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-foundation/file-descriptors/tags.txt b/basis/core-foundation/file-descriptors/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/core-foundation/file-descriptors/tags.txt +++ b/basis/core-foundation/file-descriptors/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/core-foundation/fsevents/platforms.txt b/basis/core-foundation/fsevents/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-foundation/fsevents/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-foundation/fsevents/tags.txt b/basis/core-foundation/fsevents/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/core-foundation/fsevents/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/core-foundation/numbers/platforms.txt b/basis/core-foundation/numbers/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-foundation/numbers/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-foundation/numbers/tags.txt b/basis/core-foundation/numbers/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/core-foundation/numbers/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/core-foundation/platforms.txt b/basis/core-foundation/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-foundation/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-foundation/run-loop/platforms.txt b/basis/core-foundation/run-loop/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-foundation/run-loop/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-foundation/run-loop/tags.txt b/basis/core-foundation/run-loop/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/core-foundation/run-loop/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/core-foundation/strings/platforms.txt b/basis/core-foundation/strings/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-foundation/strings/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-foundation/strings/tags.txt b/basis/core-foundation/strings/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/core-foundation/strings/tags.txt +++ b/basis/core-foundation/strings/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/core-foundation/tags.txt b/basis/core-foundation/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/core-foundation/tags.txt +++ b/basis/core-foundation/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/core-foundation/timers/platforms.txt b/basis/core-foundation/timers/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-foundation/timers/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-foundation/timers/tags.txt b/basis/core-foundation/timers/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/core-foundation/timers/tags.txt +++ b/basis/core-foundation/timers/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/core-foundation/urls/platforms.txt b/basis/core-foundation/urls/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-foundation/urls/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-foundation/urls/tags.txt b/basis/core-foundation/urls/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/core-foundation/urls/tags.txt +++ b/basis/core-foundation/urls/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/core-foundation/utilities/platforms.txt b/basis/core-foundation/utilities/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-foundation/utilities/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-foundation/utilities/tags.txt b/basis/core-foundation/utilities/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/core-foundation/utilities/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/core-graphics/platforms.txt b/basis/core-graphics/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-graphics/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-graphics/tags.txt b/basis/core-graphics/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/core-graphics/tags.txt +++ b/basis/core-graphics/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/core-text/fonts/platforms.txt b/basis/core-text/fonts/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-text/fonts/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-text/fonts/tags.txt b/basis/core-text/fonts/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/core-text/fonts/tags.txt +++ b/basis/core-text/fonts/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/core-text/platforms.txt b/basis/core-text/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/core-text/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/core-text/tags.txt b/basis/core-text/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/core-text/tags.txt +++ b/basis/core-text/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/cpu/ppc/assembler/backend/tags.txt b/basis/cpu/ppc/assembler/backend/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cpu/ppc/assembler/backend/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cpu/ppc/linux/tags.txt b/basis/cpu/ppc/linux/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/cpu/ppc/linux/tags.txt +++ b/basis/cpu/ppc/linux/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/cpu/ppc/macosx/tags.txt b/basis/cpu/ppc/macosx/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/cpu/ppc/macosx/tags.txt +++ b/basis/cpu/ppc/macosx/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/cpu/ppc/tags.txt b/basis/cpu/ppc/tags.txt index 8e66660f70..6c8f59c757 100644 --- a/basis/cpu/ppc/tags.txt +++ b/basis/cpu/ppc/tags.txt @@ -1,2 +1,2 @@ -unportable compiler +untested diff --git a/basis/cpu/x86/32/tags.txt b/basis/cpu/x86/32/tags.txt index 8e66660f70..50dfc5156e 100644 --- a/basis/cpu/x86/32/tags.txt +++ b/basis/cpu/x86/32/tags.txt @@ -1,2 +1,2 @@ -unportable +untested compiler diff --git a/basis/cpu/x86/64/tags.txt b/basis/cpu/x86/64/tags.txt index 8e66660f70..50dfc5156e 100644 --- a/basis/cpu/x86/64/tags.txt +++ b/basis/cpu/x86/64/tags.txt @@ -1,2 +1,2 @@ -unportable +untested compiler diff --git a/basis/cpu/x86/64/unix/tags.txt b/basis/cpu/x86/64/unix/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/cpu/x86/64/unix/tags.txt +++ b/basis/cpu/x86/64/unix/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/cpu/x86/64/winnt/tags.txt b/basis/cpu/x86/64/winnt/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/cpu/x86/64/winnt/tags.txt +++ b/basis/cpu/x86/64/winnt/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/cpu/x86/assembler/syntax/tags.txt b/basis/cpu/x86/assembler/syntax/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/cpu/x86/assembler/syntax/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/cpu/x86/features/tags.txt b/basis/cpu/x86/features/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/cpu/x86/features/tags.txt +++ b/basis/cpu/x86/features/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/cpu/x86/tags.txt b/basis/cpu/x86/tags.txt index 8e66660f70..50dfc5156e 100644 --- a/basis/cpu/x86/tags.txt +++ b/basis/cpu/x86/tags.txt @@ -1,2 +1,2 @@ -unportable +untested compiler diff --git a/basis/debugger/windows/platforms.txt b/basis/debugger/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/debugger/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/debugger/windows/tags.txt b/basis/debugger/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/debugger/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/editors/editpadlite/tags.txt b/basis/editors/editpadlite/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/editpadlite/tags.txt +++ b/basis/editors/editpadlite/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/editpadpro/tags.txt b/basis/editors/editpadpro/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/editpadpro/tags.txt +++ b/basis/editors/editpadpro/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/editplus/tags.txt b/basis/editors/editplus/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/editplus/tags.txt +++ b/basis/editors/editplus/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/emacs/tags.txt b/basis/editors/emacs/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/emacs/tags.txt +++ b/basis/editors/emacs/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/emacs/windows/tags.txt b/basis/editors/emacs/windows/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/emacs/windows/tags.txt +++ b/basis/editors/emacs/windows/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/emeditor/tags.txt b/basis/editors/emeditor/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/emeditor/tags.txt +++ b/basis/editors/emeditor/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/etexteditor/tags.txt b/basis/editors/etexteditor/tags.txt index 6bf68304bb..5d77766703 100755 --- a/basis/editors/etexteditor/tags.txt +++ b/basis/editors/etexteditor/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/gedit/tags.txt b/basis/editors/gedit/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/gedit/tags.txt +++ b/basis/editors/gedit/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/gvim/tags.txt b/basis/editors/gvim/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/gvim/tags.txt +++ b/basis/editors/gvim/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/gvim/unix/tags.txt b/basis/editors/gvim/unix/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/gvim/unix/tags.txt +++ b/basis/editors/gvim/unix/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/gvim/windows/tags.txt b/basis/editors/gvim/windows/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/gvim/windows/tags.txt +++ b/basis/editors/gvim/windows/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/jedit/tags.txt b/basis/editors/jedit/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/jedit/tags.txt +++ b/basis/editors/jedit/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/macvim/tags.txt b/basis/editors/macvim/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/macvim/tags.txt +++ b/basis/editors/macvim/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/notepad/tags.txt b/basis/editors/notepad/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/notepad/tags.txt +++ b/basis/editors/notepad/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/notepad2/tags.txt b/basis/editors/notepad2/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/notepad2/tags.txt +++ b/basis/editors/notepad2/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/notepadpp/tags.txt b/basis/editors/notepadpp/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/notepadpp/tags.txt +++ b/basis/editors/notepadpp/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/scite/tags.txt b/basis/editors/scite/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/scite/tags.txt +++ b/basis/editors/scite/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/ted-notepad/tags.txt b/basis/editors/ted-notepad/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/ted-notepad/tags.txt +++ b/basis/editors/ted-notepad/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/textedit/tags.txt b/basis/editors/textedit/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/textedit/tags.txt +++ b/basis/editors/textedit/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/textmate/tags.txt b/basis/editors/textmate/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/textmate/tags.txt +++ b/basis/editors/textmate/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/textpad/tags.txt b/basis/editors/textpad/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/textpad/tags.txt +++ b/basis/editors/textpad/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/textwrangler/tags.txt b/basis/editors/textwrangler/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/textwrangler/tags.txt +++ b/basis/editors/textwrangler/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/ultraedit/tags.txt b/basis/editors/ultraedit/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/ultraedit/tags.txt +++ b/basis/editors/ultraedit/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/vim/generate-syntax/tags.txt b/basis/editors/vim/generate-syntax/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/vim/generate-syntax/tags.txt +++ b/basis/editors/vim/generate-syntax/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/vim/tags.txt b/basis/editors/vim/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/vim/tags.txt +++ b/basis/editors/vim/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/editors/wordpad/tags.txt b/basis/editors/wordpad/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/editors/wordpad/tags.txt +++ b/basis/editors/wordpad/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/environment/unix/macosx/platforms.txt b/basis/environment/unix/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/environment/unix/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/environment/unix/macosx/tags.txt b/basis/environment/unix/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/environment/unix/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/environment/unix/platforms.txt b/basis/environment/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/environment/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/environment/unix/tags.txt b/basis/environment/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/environment/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/environment/winnt/platforms.txt b/basis/environment/winnt/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/environment/winnt/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/environment/winnt/tags.txt b/basis/environment/winnt/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/environment/winnt/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/game/input/dinput/platforms.txt b/basis/game/input/dinput/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/game/input/dinput/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/game/input/dinput/tags.txt b/basis/game/input/dinput/tags.txt index 82506ff250..84d4140a70 100755 --- a/basis/game/input/dinput/tags.txt +++ b/basis/game/input/dinput/tags.txt @@ -1,2 +1 @@ -unportable games diff --git a/basis/game/input/iokit/platforms.txt b/basis/game/input/iokit/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/game/input/iokit/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/game/input/iokit/tags.txt b/basis/game/input/iokit/tags.txt index 82506ff250..84d4140a70 100755 --- a/basis/game/input/iokit/tags.txt +++ b/basis/game/input/iokit/tags.txt @@ -1,2 +1 @@ -unportable games diff --git a/basis/game/input/linux/platforms.txt b/basis/game/input/linux/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/game/input/linux/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/game/input/linux/tags.txt b/basis/game/input/linux/tags.txt index 82506ff250..84d4140a70 100644 --- a/basis/game/input/linux/tags.txt +++ b/basis/game/input/linux/tags.txt @@ -1,2 +1 @@ -unportable games diff --git a/basis/game/input/xinput/platforms.txt b/basis/game/input/xinput/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/game/input/xinput/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/game/input/xinput/tags.txt b/basis/game/input/xinput/tags.txt index 82506ff250..84d4140a70 100644 --- a/basis/game/input/xinput/tags.txt +++ b/basis/game/input/xinput/tags.txt @@ -1,2 +1 @@ -unportable games diff --git a/basis/io/backend/unix/bsd/platforms.txt b/basis/io/backend/unix/bsd/platforms.txt new file mode 100644 index 0000000000..df796f15d4 --- /dev/null +++ b/basis/io/backend/unix/bsd/platforms.txt @@ -0,0 +1 @@ +bsd diff --git a/basis/io/backend/unix/bsd/tags.txt b/basis/io/backend/unix/bsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/backend/unix/bsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/unix/freebsd/platforms.txt b/basis/io/backend/unix/freebsd/platforms.txt new file mode 100644 index 0000000000..edfe86017d --- /dev/null +++ b/basis/io/backend/unix/freebsd/platforms.txt @@ -0,0 +1 @@ +freebsd diff --git a/basis/io/backend/unix/freebsd/tags.txt b/basis/io/backend/unix/freebsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/backend/unix/freebsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/unix/linux/platforms.txt b/basis/io/backend/unix/linux/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/io/backend/unix/linux/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/io/backend/unix/linux/tags.txt b/basis/io/backend/unix/linux/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/backend/unix/linux/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/unix/macosx/platforms.txt b/basis/io/backend/unix/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/io/backend/unix/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/io/backend/unix/macosx/tags.txt b/basis/io/backend/unix/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/backend/unix/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/unix/multiplexers/epoll/platforms.txt b/basis/io/backend/unix/multiplexers/epoll/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/io/backend/unix/multiplexers/epoll/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/io/backend/unix/multiplexers/epoll/tags.txt b/basis/io/backend/unix/multiplexers/epoll/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/backend/unix/multiplexers/epoll/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/unix/multiplexers/kqueue/platforms.txt b/basis/io/backend/unix/multiplexers/kqueue/platforms.txt new file mode 100644 index 0000000000..df796f15d4 --- /dev/null +++ b/basis/io/backend/unix/multiplexers/kqueue/platforms.txt @@ -0,0 +1 @@ +bsd diff --git a/basis/io/backend/unix/multiplexers/kqueue/tags.txt b/basis/io/backend/unix/multiplexers/kqueue/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/backend/unix/multiplexers/kqueue/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/unix/multiplexers/platforms.txt b/basis/io/backend/unix/multiplexers/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/io/backend/unix/multiplexers/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/io/backend/unix/multiplexers/run-loop/platforms.txt b/basis/io/backend/unix/multiplexers/run-loop/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/io/backend/unix/multiplexers/run-loop/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/io/backend/unix/multiplexers/run-loop/tags.txt b/basis/io/backend/unix/multiplexers/run-loop/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/backend/unix/multiplexers/run-loop/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/unix/multiplexers/select/platforms.txt b/basis/io/backend/unix/multiplexers/select/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/io/backend/unix/multiplexers/select/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/io/backend/unix/multiplexers/select/tags.txt b/basis/io/backend/unix/multiplexers/select/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/backend/unix/multiplexers/select/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/unix/multiplexers/tags.txt b/basis/io/backend/unix/multiplexers/tags.txt deleted file mode 100755 index 6abe115b12..0000000000 --- a/basis/io/backend/unix/multiplexers/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/unix/netbsd/platforms.txt b/basis/io/backend/unix/netbsd/platforms.txt new file mode 100644 index 0000000000..dccfe71042 --- /dev/null +++ b/basis/io/backend/unix/netbsd/platforms.txt @@ -0,0 +1 @@ +netbsd diff --git a/basis/io/backend/unix/netbsd/tags.txt b/basis/io/backend/unix/netbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/backend/unix/netbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/unix/openbsd/platforms.txt b/basis/io/backend/unix/openbsd/platforms.txt new file mode 100644 index 0000000000..389b028aca --- /dev/null +++ b/basis/io/backend/unix/openbsd/platforms.txt @@ -0,0 +1 @@ +openbsd diff --git a/basis/io/backend/unix/openbsd/tags.txt b/basis/io/backend/unix/openbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/backend/unix/openbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/unix/platforms.txt b/basis/io/backend/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/io/backend/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/io/backend/unix/tags.txt b/basis/io/backend/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/backend/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/windows/nt/platforms.txt b/basis/io/backend/windows/nt/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/io/backend/windows/nt/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/io/backend/windows/nt/privileges/platforms.txt b/basis/io/backend/windows/nt/privileges/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/io/backend/windows/nt/privileges/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/io/backend/windows/nt/privileges/tags.txt b/basis/io/backend/windows/nt/privileges/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/backend/windows/nt/privileges/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/windows/nt/tags.txt b/basis/io/backend/windows/nt/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/backend/windows/nt/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/windows/platforms.txt b/basis/io/backend/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/io/backend/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/io/backend/windows/privileges/platforms.txt b/basis/io/backend/windows/privileges/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/io/backend/windows/privileges/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/io/backend/windows/privileges/tags.txt b/basis/io/backend/windows/privileges/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/backend/windows/privileges/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/backend/windows/tags.txt b/basis/io/backend/windows/tags.txt deleted file mode 100755 index 6bf68304bb..0000000000 --- a/basis/io/backend/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/directories/search/windows/platforms.txt b/basis/io/directories/search/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/io/directories/search/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/io/directories/search/windows/tags.txt b/basis/io/directories/search/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/directories/search/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/directories/unix/linux/platforms.txt b/basis/io/directories/unix/linux/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/io/directories/unix/linux/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/io/directories/unix/linux/tags.txt b/basis/io/directories/unix/linux/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/directories/unix/linux/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/directories/unix/platforms.txt b/basis/io/directories/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/io/directories/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/io/directories/unix/tags.txt b/basis/io/directories/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/directories/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/directories/windows/platforms.txt b/basis/io/directories/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/io/directories/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/io/directories/windows/tags.txt b/basis/io/directories/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/directories/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/files/info/unix/bsd/platforms.txt b/basis/io/files/info/unix/bsd/platforms.txt new file mode 100644 index 0000000000..df796f15d4 --- /dev/null +++ b/basis/io/files/info/unix/bsd/platforms.txt @@ -0,0 +1 @@ +bsd diff --git a/basis/io/files/info/unix/bsd/tags.txt b/basis/io/files/info/unix/bsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/files/info/unix/bsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/files/info/unix/freebsd/platforms.txt b/basis/io/files/info/unix/freebsd/platforms.txt new file mode 100644 index 0000000000..edfe86017d --- /dev/null +++ b/basis/io/files/info/unix/freebsd/platforms.txt @@ -0,0 +1 @@ +freebsd diff --git a/basis/io/files/info/unix/freebsd/tags.txt b/basis/io/files/info/unix/freebsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/files/info/unix/freebsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/files/info/unix/linux/platforms.txt b/basis/io/files/info/unix/linux/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/io/files/info/unix/linux/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/io/files/info/unix/linux/tags.txt b/basis/io/files/info/unix/linux/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/files/info/unix/linux/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/files/info/unix/macosx/platforms.txt b/basis/io/files/info/unix/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/io/files/info/unix/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/io/files/info/unix/macosx/tags.txt b/basis/io/files/info/unix/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/files/info/unix/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/files/info/unix/netbsd/platforms.txt b/basis/io/files/info/unix/netbsd/platforms.txt new file mode 100644 index 0000000000..dccfe71042 --- /dev/null +++ b/basis/io/files/info/unix/netbsd/platforms.txt @@ -0,0 +1 @@ +netbsd diff --git a/basis/io/files/info/unix/netbsd/tags.txt b/basis/io/files/info/unix/netbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/files/info/unix/netbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/files/info/unix/openbsd/platforms.txt b/basis/io/files/info/unix/openbsd/platforms.txt new file mode 100644 index 0000000000..389b028aca --- /dev/null +++ b/basis/io/files/info/unix/openbsd/platforms.txt @@ -0,0 +1 @@ +openbsd diff --git a/basis/io/files/info/unix/openbsd/tags.txt b/basis/io/files/info/unix/openbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/files/info/unix/openbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/files/info/unix/platforms.txt b/basis/io/files/info/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/io/files/info/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/io/files/info/unix/tags.txt b/basis/io/files/info/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/files/info/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/files/info/windows/platforms.txt b/basis/io/files/info/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/io/files/info/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/io/files/info/windows/tags.txt b/basis/io/files/info/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/files/info/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/files/links/unix/platforms.txt b/basis/io/files/links/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/io/files/links/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/io/files/links/unix/tags.txt b/basis/io/files/links/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/files/links/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/files/unique/unix/platforms.txt b/basis/io/files/unique/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/io/files/unique/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/io/files/unique/unix/tags.txt b/basis/io/files/unique/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/files/unique/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/files/unique/windows/platforms.txt b/basis/io/files/unique/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/io/files/unique/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/io/files/unique/windows/tags.txt b/basis/io/files/unique/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/files/unique/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/files/unix/platforms.txt b/basis/io/files/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/io/files/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/io/files/unix/tags.txt b/basis/io/files/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/files/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/files/windows/nt/platforms.txt b/basis/io/files/windows/nt/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/io/files/windows/nt/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/io/files/windows/nt/tags.txt b/basis/io/files/windows/nt/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/files/windows/nt/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/files/windows/platforms.txt b/basis/io/files/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/io/files/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/io/files/windows/tags.txt b/basis/io/files/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/files/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/launcher/unix/parser/platforms.txt b/basis/io/launcher/unix/parser/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/io/launcher/unix/parser/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/io/launcher/unix/parser/tags.txt b/basis/io/launcher/unix/parser/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/launcher/unix/parser/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/launcher/unix/platforms.txt b/basis/io/launcher/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/io/launcher/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/io/launcher/unix/tags.txt b/basis/io/launcher/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/launcher/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/launcher/windows/nt/platforms.txt b/basis/io/launcher/windows/nt/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/io/launcher/windows/nt/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/io/launcher/windows/nt/tags.txt b/basis/io/launcher/windows/nt/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/launcher/windows/nt/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/launcher/windows/platforms.txt b/basis/io/launcher/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/io/launcher/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/io/launcher/windows/tags.txt b/basis/io/launcher/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/launcher/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/mmap/unix/platforms.txt b/basis/io/mmap/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/io/mmap/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/io/mmap/unix/tags.txt b/basis/io/mmap/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/mmap/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/mmap/windows/platforms.txt b/basis/io/mmap/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/io/mmap/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/io/mmap/windows/tags.txt b/basis/io/mmap/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/mmap/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/monitors/linux/platforms.txt b/basis/io/monitors/linux/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/io/monitors/linux/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/io/monitors/linux/tags.txt b/basis/io/monitors/linux/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/monitors/linux/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/monitors/macosx/platforms.txt b/basis/io/monitors/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/io/monitors/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/io/monitors/macosx/tags.txt b/basis/io/monitors/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/monitors/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/monitors/windows/nt/platforms.txt b/basis/io/monitors/windows/nt/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/io/monitors/windows/nt/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/io/monitors/windows/nt/tags.txt b/basis/io/monitors/windows/nt/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/monitors/windows/nt/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/pipes/unix/platforms.txt b/basis/io/pipes/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/io/pipes/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/io/pipes/unix/tags.txt b/basis/io/pipes/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/pipes/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/pipes/windows/nt/platforms.txt b/basis/io/pipes/windows/nt/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/io/pipes/windows/nt/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/io/pipes/windows/nt/tags.txt b/basis/io/pipes/windows/nt/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/pipes/windows/nt/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/sockets/secure/unix/platforms.txt b/basis/io/sockets/secure/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/io/sockets/secure/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/io/sockets/secure/unix/tags.txt b/basis/io/sockets/secure/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/sockets/secure/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/sockets/unix/platforms.txt b/basis/io/sockets/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/io/sockets/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/io/sockets/unix/tags.txt b/basis/io/sockets/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/sockets/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/sockets/windows/nt/platforms.txt b/basis/io/sockets/windows/nt/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/io/sockets/windows/nt/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/io/sockets/windows/nt/tags.txt b/basis/io/sockets/windows/nt/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/sockets/windows/nt/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/sockets/windows/platforms.txt b/basis/io/sockets/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/io/sockets/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/io/sockets/windows/tags.txt b/basis/io/sockets/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/sockets/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/iokit/hid/platforms.txt b/basis/iokit/hid/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/iokit/hid/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/iokit/hid/tags.txt b/basis/iokit/hid/tags.txt index bf2a35f15b..bb863cf9a0 100755 --- a/basis/iokit/hid/tags.txt +++ b/basis/iokit/hid/tags.txt @@ -1,2 +1 @@ bindings -unportable diff --git a/basis/iokit/platforms.txt b/basis/iokit/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/iokit/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/iokit/tags.txt b/basis/iokit/tags.txt index bf2a35f15b..bb863cf9a0 100755 --- a/basis/iokit/tags.txt +++ b/basis/iokit/tags.txt @@ -1,2 +1 @@ bindings -unportable diff --git a/basis/math/floats/env/ppc/tags.txt b/basis/math/floats/env/ppc/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/math/floats/env/ppc/tags.txt +++ b/basis/math/floats/env/ppc/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/math/floats/env/x86/32/tags.txt b/basis/math/floats/env/x86/32/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/math/floats/env/x86/32/tags.txt +++ b/basis/math/floats/env/x86/32/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/math/floats/env/x86/64/tags.txt b/basis/math/floats/env/x86/64/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/math/floats/env/x86/64/tags.txt +++ b/basis/math/floats/env/x86/64/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/math/floats/env/x86/tags.txt b/basis/math/floats/env/x86/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/math/floats/env/x86/tags.txt +++ b/basis/math/floats/env/x86/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/opengl/gl/macosx/platforms.txt b/basis/opengl/gl/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/opengl/gl/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/opengl/gl/macosx/tags.txt b/basis/opengl/gl/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/opengl/gl/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/opengl/gl/unix/platforms.txt b/basis/opengl/gl/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/opengl/gl/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/opengl/gl/unix/tags.txt b/basis/opengl/gl/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/opengl/gl/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/opengl/gl/windows/platforms.txt b/basis/opengl/gl/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/opengl/gl/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/opengl/gl/windows/tags.txt b/basis/opengl/gl/windows/tags.txt deleted file mode 100755 index 6bf68304bb..0000000000 --- a/basis/opengl/gl/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/random/unix/platforms.txt b/basis/random/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/random/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/random/unix/tags.txt b/basis/random/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/random/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/random/windows/platforms.txt b/basis/random/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/random/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/random/windows/tags.txt b/basis/random/windows/tags.txt deleted file mode 100755 index 6bf68304bb..0000000000 --- a/basis/random/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/system-info/linux/platforms.txt b/basis/system-info/linux/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/system-info/linux/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/system-info/linux/tags.txt b/basis/system-info/linux/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/system-info/linux/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/system-info/macosx/platforms.txt b/basis/system-info/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/system-info/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/system-info/macosx/tags.txt b/basis/system-info/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/system-info/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/system-info/windows/ce/platforms.txt b/basis/system-info/windows/ce/platforms.txt new file mode 100644 index 0000000000..cd0d980f6f --- /dev/null +++ b/basis/system-info/windows/ce/platforms.txt @@ -0,0 +1 @@ +wince diff --git a/basis/system-info/windows/ce/tags.txt b/basis/system-info/windows/ce/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/system-info/windows/ce/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/system-info/windows/nt/platforms.txt b/basis/system-info/windows/nt/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/system-info/windows/nt/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/system-info/windows/nt/tags.txt b/basis/system-info/windows/nt/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/system-info/windows/nt/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/system-info/windows/platforms.txt b/basis/system-info/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/system-info/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/system-info/windows/tags.txt b/basis/system-info/windows/tags.txt deleted file mode 100755 index 6bf68304bb..0000000000 --- a/basis/system-info/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/tools/cocoa/platforms.txt b/basis/tools/cocoa/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/tools/cocoa/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/tools/cocoa/tags.txt b/basis/tools/cocoa/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/tools/cocoa/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/tools/deploy/libraries/tags.txt b/basis/tools/deploy/libraries/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/tools/deploy/libraries/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/tools/deploy/libraries/unix/platforms.txt b/basis/tools/deploy/libraries/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/tools/deploy/libraries/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/tools/deploy/libraries/unix/tags.txt b/basis/tools/deploy/libraries/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/tools/deploy/libraries/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/tools/deploy/libraries/windows/platforms.txt b/basis/tools/deploy/libraries/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/tools/deploy/libraries/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/tools/deploy/libraries/windows/tags.txt b/basis/tools/deploy/libraries/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/tools/deploy/libraries/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/tools/deploy/macosx/platforms.txt b/basis/tools/deploy/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/tools/deploy/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/tools/deploy/macosx/tags.txt b/basis/tools/deploy/macosx/tags.txt index 660d511420..ef1aab0d0e 100644 --- a/basis/tools/deploy/macosx/tags.txt +++ b/basis/tools/deploy/macosx/tags.txt @@ -1,2 +1 @@ -unportable tools diff --git a/basis/tools/deploy/test/14/platforms.txt b/basis/tools/deploy/test/14/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/tools/deploy/test/14/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/tools/deploy/test/14/tags.txt b/basis/tools/deploy/test/14/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/tools/deploy/test/14/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/tools/deploy/unix/platforms.txt b/basis/tools/deploy/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/tools/deploy/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/tools/deploy/unix/tags.txt b/basis/tools/deploy/unix/tags.txt index 660d511420..ef1aab0d0e 100644 --- a/basis/tools/deploy/unix/tags.txt +++ b/basis/tools/deploy/unix/tags.txt @@ -1,2 +1 @@ -unportable tools diff --git a/basis/tools/deploy/windows/ico/platforms.txt b/basis/tools/deploy/windows/ico/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/tools/deploy/windows/ico/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/tools/deploy/windows/ico/tags.txt b/basis/tools/deploy/windows/ico/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/tools/deploy/windows/ico/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/tools/deploy/windows/platforms.txt b/basis/tools/deploy/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/tools/deploy/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/tools/deploy/windows/tags.txt b/basis/tools/deploy/windows/tags.txt index 660d511420..ef1aab0d0e 100755 --- a/basis/tools/deploy/windows/tags.txt +++ b/basis/tools/deploy/windows/tags.txt @@ -1,2 +1 @@ -unportable tools diff --git a/basis/tools/disassembler/gdb/tags.txt b/basis/tools/disassembler/gdb/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/tools/disassembler/gdb/tags.txt +++ b/basis/tools/disassembler/gdb/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/tools/disassembler/udis/tags.txt b/basis/tools/disassembler/udis/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/tools/disassembler/udis/tags.txt +++ b/basis/tools/disassembler/udis/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/tools/files/tags.txt b/basis/tools/files/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/tools/files/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/tools/files/unix/platforms.txt b/basis/tools/files/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/tools/files/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/tools/files/unix/tags.txt b/basis/tools/files/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/tools/files/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/tools/files/windows/platforms.txt b/basis/tools/files/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/tools/files/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/tools/files/windows/tags.txt b/basis/tools/files/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/tools/files/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/tools/scaffold/scaffold.factor b/basis/tools/scaffold/scaffold.factor index 936d388b01..a8565fccf9 100644 --- a/basis/tools/scaffold/scaffold.factor +++ b/basis/tools/scaffold/scaffold.factor @@ -2,11 +2,11 @@ ! See http://factorcode.org/license.txt for BSD license. USING: assocs io.files io.pathnames io.directories 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 combinators.short-circuit alarms words.symbol -system summary ; +vocabs.loader vocabs.metadata 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 combinators.short-circuit alarms +words.symbol system summary ; IN: tools.scaffold SYMBOL: developer-name @@ -15,7 +15,6 @@ SYMBOL: using ERROR: not-a-vocab-root string ; ERROR: vocab-name-contains-separator path ; ERROR: vocab-name-contains-dot path ; -ERROR: no-vocab vocab ; ERROR: bad-developer-name name ; M: bad-developer-name summary @@ -40,9 +39,6 @@ M: bad-developer-name summary : 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* ; diff --git a/basis/tools/scaffold/windows/platforms.txt b/basis/tools/scaffold/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/tools/scaffold/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/tools/scaffold/windows/tags.txt b/basis/tools/scaffold/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/tools/scaffold/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/ui/backend/cocoa/platforms.txt b/basis/ui/backend/cocoa/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/ui/backend/cocoa/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/ui/backend/cocoa/tags.txt b/basis/ui/backend/cocoa/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/ui/backend/cocoa/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/ui/backend/cocoa/tools/platforms.txt b/basis/ui/backend/cocoa/tools/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/ui/backend/cocoa/tools/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/ui/backend/cocoa/tools/tags.txt b/basis/ui/backend/cocoa/tools/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/ui/backend/cocoa/tools/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/ui/backend/cocoa/views/platforms.txt b/basis/ui/backend/cocoa/views/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/ui/backend/cocoa/views/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/ui/backend/cocoa/views/tags.txt b/basis/ui/backend/cocoa/views/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/ui/backend/cocoa/views/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/ui/backend/windows/platforms.txt b/basis/ui/backend/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/ui/backend/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/ui/backend/windows/tags.txt b/basis/ui/backend/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/ui/backend/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/ui/backend/x11/tags.txt b/basis/ui/backend/x11/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/ui/backend/x11/tags.txt +++ b/basis/ui/backend/x11/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/ui/text/core-text/platforms.txt b/basis/ui/text/core-text/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/ui/text/core-text/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/ui/text/core-text/tags.txt b/basis/ui/text/core-text/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/ui/text/core-text/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/ui/text/pango/tags.txt b/basis/ui/text/pango/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/ui/text/pango/tags.txt +++ b/basis/ui/text/pango/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/ui/text/uniscribe/platforms.txt b/basis/ui/text/uniscribe/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/ui/text/uniscribe/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/ui/text/uniscribe/tags.txt b/basis/ui/text/uniscribe/tags.txt deleted file mode 100755 index 6abe115b12..0000000000 --- a/basis/ui/text/uniscribe/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/debugger/platforms.txt b/basis/unix/debugger/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/unix/debugger/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/unix/debugger/tags.txt b/basis/unix/debugger/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/debugger/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/ffi/bsd/freebsd/platforms.txt b/basis/unix/ffi/bsd/freebsd/platforms.txt new file mode 100644 index 0000000000..edfe86017d --- /dev/null +++ b/basis/unix/ffi/bsd/freebsd/platforms.txt @@ -0,0 +1 @@ +freebsd diff --git a/basis/unix/ffi/bsd/freebsd/tags.txt b/basis/unix/ffi/bsd/freebsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/ffi/bsd/freebsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/ffi/bsd/macosx/platforms.txt b/basis/unix/ffi/bsd/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/unix/ffi/bsd/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/unix/ffi/bsd/macosx/tags.txt b/basis/unix/ffi/bsd/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/ffi/bsd/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/ffi/bsd/netbsd/platforms.txt b/basis/unix/ffi/bsd/netbsd/platforms.txt new file mode 100644 index 0000000000..dccfe71042 --- /dev/null +++ b/basis/unix/ffi/bsd/netbsd/platforms.txt @@ -0,0 +1 @@ +netbsd diff --git a/basis/unix/ffi/bsd/netbsd/tags.txt b/basis/unix/ffi/bsd/netbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/ffi/bsd/netbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/ffi/bsd/openbsd/platforms.txt b/basis/unix/ffi/bsd/openbsd/platforms.txt new file mode 100644 index 0000000000..389b028aca --- /dev/null +++ b/basis/unix/ffi/bsd/openbsd/platforms.txt @@ -0,0 +1 @@ +openbsd diff --git a/basis/unix/ffi/bsd/openbsd/tags.txt b/basis/unix/ffi/bsd/openbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/ffi/bsd/openbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/ffi/bsd/platforms.txt b/basis/unix/ffi/bsd/platforms.txt new file mode 100644 index 0000000000..df796f15d4 --- /dev/null +++ b/basis/unix/ffi/bsd/platforms.txt @@ -0,0 +1 @@ +bsd diff --git a/basis/unix/ffi/bsd/tags.txt b/basis/unix/ffi/bsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/ffi/bsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/ffi/linux/platforms.txt b/basis/unix/ffi/linux/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/unix/ffi/linux/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/unix/ffi/linux/tags.txt b/basis/unix/ffi/linux/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/ffi/linux/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/ffi/platforms.txt b/basis/unix/ffi/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/unix/ffi/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/unix/ffi/solaris/platforms.txt b/basis/unix/ffi/solaris/platforms.txt new file mode 100644 index 0000000000..613a93b535 --- /dev/null +++ b/basis/unix/ffi/solaris/platforms.txt @@ -0,0 +1 @@ +solaris diff --git a/basis/unix/ffi/solaris/tags.txt b/basis/unix/ffi/solaris/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/ffi/solaris/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/ffi/tags.txt b/basis/unix/ffi/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/ffi/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/getfsstat/freebsd/platforms.txt b/basis/unix/getfsstat/freebsd/platforms.txt new file mode 100644 index 0000000000..edfe86017d --- /dev/null +++ b/basis/unix/getfsstat/freebsd/platforms.txt @@ -0,0 +1 @@ +freebsd diff --git a/basis/unix/getfsstat/freebsd/tags.txt b/basis/unix/getfsstat/freebsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/getfsstat/freebsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/getfsstat/macosx/platforms.txt b/basis/unix/getfsstat/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/unix/getfsstat/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/unix/getfsstat/macosx/tags.txt b/basis/unix/getfsstat/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/getfsstat/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/getfsstat/netbsd/platforms.txt b/basis/unix/getfsstat/netbsd/platforms.txt new file mode 100644 index 0000000000..dccfe71042 --- /dev/null +++ b/basis/unix/getfsstat/netbsd/platforms.txt @@ -0,0 +1 @@ +netbsd diff --git a/basis/unix/getfsstat/netbsd/tags.txt b/basis/unix/getfsstat/netbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/getfsstat/netbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/getfsstat/openbsd/platforms.txt b/basis/unix/getfsstat/openbsd/platforms.txt new file mode 100644 index 0000000000..389b028aca --- /dev/null +++ b/basis/unix/getfsstat/openbsd/platforms.txt @@ -0,0 +1 @@ +openbsd diff --git a/basis/unix/getfsstat/openbsd/tags.txt b/basis/unix/getfsstat/openbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/getfsstat/openbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/groups/platforms.txt b/basis/unix/groups/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/unix/groups/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/unix/groups/tags.txt b/basis/unix/groups/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/groups/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/kqueue/freebsd/platforms.txt b/basis/unix/kqueue/freebsd/platforms.txt new file mode 100644 index 0000000000..edfe86017d --- /dev/null +++ b/basis/unix/kqueue/freebsd/platforms.txt @@ -0,0 +1 @@ +freebsd diff --git a/basis/unix/kqueue/freebsd/tags.txt b/basis/unix/kqueue/freebsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/kqueue/freebsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/kqueue/macosx/platforms.txt b/basis/unix/kqueue/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/unix/kqueue/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/unix/kqueue/macosx/tags.txt b/basis/unix/kqueue/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/kqueue/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/kqueue/netbsd/platforms.txt b/basis/unix/kqueue/netbsd/platforms.txt new file mode 100644 index 0000000000..dccfe71042 --- /dev/null +++ b/basis/unix/kqueue/netbsd/platforms.txt @@ -0,0 +1 @@ +netbsd diff --git a/basis/unix/kqueue/netbsd/tags.txt b/basis/unix/kqueue/netbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/kqueue/netbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/kqueue/openbsd/platforms.txt b/basis/unix/kqueue/openbsd/platforms.txt new file mode 100644 index 0000000000..389b028aca --- /dev/null +++ b/basis/unix/kqueue/openbsd/platforms.txt @@ -0,0 +1 @@ +openbsd diff --git a/basis/unix/kqueue/openbsd/tags.txt b/basis/unix/kqueue/openbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/kqueue/openbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/kqueue/platforms.txt b/basis/unix/kqueue/platforms.txt new file mode 100644 index 0000000000..df796f15d4 --- /dev/null +++ b/basis/unix/kqueue/platforms.txt @@ -0,0 +1 @@ +bsd diff --git a/basis/unix/kqueue/tags.txt b/basis/unix/kqueue/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/kqueue/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/linux/epoll/platforms.txt b/basis/unix/linux/epoll/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/unix/linux/epoll/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/unix/linux/epoll/tags.txt b/basis/unix/linux/epoll/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/linux/epoll/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/linux/inotify/platforms.txt b/basis/unix/linux/inotify/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/unix/linux/inotify/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/unix/linux/inotify/tags.txt b/basis/unix/linux/inotify/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/linux/inotify/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/linux/platforms.txt b/basis/unix/linux/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/unix/linux/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/unix/linux/tags.txt b/basis/unix/linux/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/linux/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/platforms.txt b/basis/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/unix/process/platforms.txt b/basis/unix/process/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/unix/process/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/unix/process/tags.txt b/basis/unix/process/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/process/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/stat/freebsd/platforms.txt b/basis/unix/stat/freebsd/platforms.txt new file mode 100644 index 0000000000..edfe86017d --- /dev/null +++ b/basis/unix/stat/freebsd/platforms.txt @@ -0,0 +1 @@ +freebsd diff --git a/basis/unix/stat/freebsd/tags.txt b/basis/unix/stat/freebsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/stat/freebsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/stat/linux/32/tags.txt b/basis/unix/stat/linux/32/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/unix/stat/linux/32/tags.txt +++ b/basis/unix/stat/linux/32/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/unix/stat/linux/64/tags.txt b/basis/unix/stat/linux/64/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/unix/stat/linux/64/tags.txt +++ b/basis/unix/stat/linux/64/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/unix/stat/linux/platforms.txt b/basis/unix/stat/linux/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/unix/stat/linux/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/unix/stat/linux/tags.txt b/basis/unix/stat/linux/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/stat/linux/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/stat/macosx/platforms.txt b/basis/unix/stat/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/unix/stat/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/unix/stat/macosx/tags.txt b/basis/unix/stat/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/stat/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/stat/netbsd/32/tags.txt b/basis/unix/stat/netbsd/32/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/unix/stat/netbsd/32/tags.txt +++ b/basis/unix/stat/netbsd/32/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/unix/stat/netbsd/64/tags.txt b/basis/unix/stat/netbsd/64/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/unix/stat/netbsd/64/tags.txt +++ b/basis/unix/stat/netbsd/64/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/unix/stat/netbsd/platforms.txt b/basis/unix/stat/netbsd/platforms.txt new file mode 100644 index 0000000000..dccfe71042 --- /dev/null +++ b/basis/unix/stat/netbsd/platforms.txt @@ -0,0 +1 @@ +netbsd diff --git a/basis/unix/stat/netbsd/tags.txt b/basis/unix/stat/netbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/stat/netbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/stat/openbsd/platforms.txt b/basis/unix/stat/openbsd/platforms.txt new file mode 100644 index 0000000000..389b028aca --- /dev/null +++ b/basis/unix/stat/openbsd/platforms.txt @@ -0,0 +1 @@ +openbsd diff --git a/basis/unix/stat/openbsd/tags.txt b/basis/unix/stat/openbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/stat/openbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/stat/platforms.txt b/basis/unix/stat/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/unix/stat/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/unix/stat/tags.txt b/basis/unix/stat/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/stat/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/statfs/freebsd/platforms.txt b/basis/unix/statfs/freebsd/platforms.txt new file mode 100644 index 0000000000..edfe86017d --- /dev/null +++ b/basis/unix/statfs/freebsd/platforms.txt @@ -0,0 +1 @@ +freebsd diff --git a/basis/unix/statfs/freebsd/tags.txt b/basis/unix/statfs/freebsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/statfs/freebsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/statfs/linux/platforms.txt b/basis/unix/statfs/linux/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/unix/statfs/linux/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/unix/statfs/linux/tags.txt b/basis/unix/statfs/linux/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/statfs/linux/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/statfs/macosx/platforms.txt b/basis/unix/statfs/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/unix/statfs/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/unix/statfs/macosx/tags.txt b/basis/unix/statfs/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/statfs/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/statfs/openbsd/platforms.txt b/basis/unix/statfs/openbsd/platforms.txt new file mode 100644 index 0000000000..389b028aca --- /dev/null +++ b/basis/unix/statfs/openbsd/platforms.txt @@ -0,0 +1 @@ +openbsd diff --git a/basis/unix/statfs/openbsd/tags.txt b/basis/unix/statfs/openbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/statfs/openbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/statvfs/freebsd/platforms.txt b/basis/unix/statvfs/freebsd/platforms.txt new file mode 100644 index 0000000000..edfe86017d --- /dev/null +++ b/basis/unix/statvfs/freebsd/platforms.txt @@ -0,0 +1 @@ +freebsd diff --git a/basis/unix/statvfs/freebsd/tags.txt b/basis/unix/statvfs/freebsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/statvfs/freebsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/statvfs/linux/platforms.txt b/basis/unix/statvfs/linux/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/unix/statvfs/linux/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/unix/statvfs/linux/tags.txt b/basis/unix/statvfs/linux/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/statvfs/linux/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/statvfs/macosx/platforms.txt b/basis/unix/statvfs/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/unix/statvfs/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/unix/statvfs/macosx/tags.txt b/basis/unix/statvfs/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/statvfs/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/statvfs/netbsd/platforms.txt b/basis/unix/statvfs/netbsd/platforms.txt new file mode 100644 index 0000000000..dccfe71042 --- /dev/null +++ b/basis/unix/statvfs/netbsd/platforms.txt @@ -0,0 +1 @@ +netbsd diff --git a/basis/unix/statvfs/netbsd/tags.txt b/basis/unix/statvfs/netbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/statvfs/netbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/statvfs/openbsd/platforms.txt b/basis/unix/statvfs/openbsd/platforms.txt new file mode 100644 index 0000000000..389b028aca --- /dev/null +++ b/basis/unix/statvfs/openbsd/platforms.txt @@ -0,0 +1 @@ +openbsd diff --git a/basis/unix/statvfs/openbsd/tags.txt b/basis/unix/statvfs/openbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/statvfs/openbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/statvfs/platforms.txt b/basis/unix/statvfs/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/unix/statvfs/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/unix/statvfs/tags.txt b/basis/unix/statvfs/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/statvfs/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/tags.txt b/basis/unix/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/unix/tags.txt +++ b/basis/unix/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/unix/time/platforms.txt b/basis/unix/time/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/unix/time/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/unix/time/tags.txt b/basis/unix/time/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/time/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/types/freebsd/platforms.txt b/basis/unix/types/freebsd/platforms.txt new file mode 100644 index 0000000000..edfe86017d --- /dev/null +++ b/basis/unix/types/freebsd/platforms.txt @@ -0,0 +1 @@ +freebsd diff --git a/basis/unix/types/freebsd/tags.txt b/basis/unix/types/freebsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/types/freebsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/types/linux/platforms.txt b/basis/unix/types/linux/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/basis/unix/types/linux/platforms.txt @@ -0,0 +1 @@ +linux diff --git a/basis/unix/types/linux/tags.txt b/basis/unix/types/linux/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/types/linux/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/types/macosx/platforms.txt b/basis/unix/types/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/unix/types/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/unix/types/macosx/tags.txt b/basis/unix/types/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/types/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/types/netbsd/32/tags.txt b/basis/unix/types/netbsd/32/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/unix/types/netbsd/32/tags.txt +++ b/basis/unix/types/netbsd/32/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/unix/types/netbsd/64/tags.txt b/basis/unix/types/netbsd/64/tags.txt index 6bf68304bb..5d77766703 100644 --- a/basis/unix/types/netbsd/64/tags.txt +++ b/basis/unix/types/netbsd/64/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/basis/unix/types/netbsd/platforms.txt b/basis/unix/types/netbsd/platforms.txt new file mode 100644 index 0000000000..dccfe71042 --- /dev/null +++ b/basis/unix/types/netbsd/platforms.txt @@ -0,0 +1 @@ +netbsd diff --git a/basis/unix/types/netbsd/tags.txt b/basis/unix/types/netbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/types/netbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/types/openbsd/platforms.txt b/basis/unix/types/openbsd/platforms.txt new file mode 100644 index 0000000000..389b028aca --- /dev/null +++ b/basis/unix/types/openbsd/platforms.txt @@ -0,0 +1 @@ +openbsd diff --git a/basis/unix/types/openbsd/tags.txt b/basis/unix/types/openbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/types/openbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/types/platforms.txt b/basis/unix/types/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/unix/types/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/unix/types/tags.txt b/basis/unix/types/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/types/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/users/bsd/platforms.txt b/basis/unix/users/bsd/platforms.txt new file mode 100644 index 0000000000..df796f15d4 --- /dev/null +++ b/basis/unix/users/bsd/platforms.txt @@ -0,0 +1 @@ +bsd diff --git a/basis/unix/users/bsd/tags.txt b/basis/unix/users/bsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/users/bsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/users/platforms.txt b/basis/unix/users/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/unix/users/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/unix/users/tags.txt b/basis/unix/users/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/users/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/utilities/platforms.txt b/basis/unix/utilities/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/unix/utilities/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/unix/utilities/tags.txt b/basis/unix/utilities/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/utilities/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/utmpx/macosx/platforms.txt b/basis/unix/utmpx/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/basis/unix/utmpx/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/basis/unix/utmpx/macosx/tags.txt b/basis/unix/utmpx/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/utmpx/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/utmpx/netbsd/platforms.txt b/basis/unix/utmpx/netbsd/platforms.txt new file mode 100644 index 0000000000..dccfe71042 --- /dev/null +++ b/basis/unix/utmpx/netbsd/platforms.txt @@ -0,0 +1 @@ +netbsd diff --git a/basis/unix/utmpx/netbsd/tags.txt b/basis/unix/utmpx/netbsd/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/utmpx/netbsd/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/unix/utmpx/platforms.txt b/basis/unix/utmpx/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/unix/utmpx/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/unix/utmpx/tags.txt b/basis/unix/utmpx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/unix/utmpx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/vocabs/metadata/authors.txt b/basis/vocabs/metadata/authors.txt index d4f5d6b3ae..1ad6ff84f7 100644 --- a/basis/vocabs/metadata/authors.txt +++ b/basis/vocabs/metadata/authors.txt @@ -1 +1,2 @@ -Slava Pestov \ No newline at end of file +Slava Pestov +Joe Groff \ No newline at end of file diff --git a/basis/vocabs/metadata/metadata.factor b/basis/vocabs/metadata/metadata.factor index 04a0ea7546..10e4eac2a2 100644 --- a/basis/vocabs/metadata/metadata.factor +++ b/basis/vocabs/metadata/metadata.factor @@ -1,23 +1,26 @@ -! Copyright (C) 2009 Slava Pestov. +! Copyright (C) 2009, 2010 Slava Pestov, Joe Groff. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays assocs io.encodings.utf8 io.files -io.pathnames kernel make math.parser memoize sequences sets -sorting summary vocabs vocabs.loader ; +USING: accessors arrays assocs io.directories io.encodings.utf8 +io.files io.pathnames kernel make math.parser memoize sequences +sets sorting summary vocabs vocabs.loader words system +classes.algebra combinators.short-circuit fry continuations +namespaces ; IN: vocabs.metadata +: check-vocab ( vocab -- vocab ) + dup find-vocab-root [ no-vocab ] unless ; + MEMO: vocab-file-contents ( vocab name -- seq ) vocab-append-path dup [ dup exists? [ utf8 file-lines ] [ drop f ] if ] when ; +: ?delete-file ( pathname -- ) '[ _ delete-file ] ignore-errors ; + : set-vocab-file-contents ( seq vocab name -- ) dupd vocab-append-path [ - utf8 set-file-lines + swap [ ?delete-file ] [ swap utf8 set-file-lines ] if-empty \ vocab-file-contents reset-memoized - ] [ - "The " swap vocab-name - " vocabulary was not loaded from the file system" - 3append throw - ] ?if ; + ] [ vocab-name no-vocab ] ?if ; : vocab-windows-icon-path ( vocab -- string ) vocab-dir "icon.ico" append-path ; @@ -72,6 +75,9 @@ M: vocab-link summary vocab-summary ; : add-vocab-tags ( tags vocab -- ) [ vocab-tags append prune ] keep set-vocab-tags ; +: remove-vocab-tags ( tags vocab -- ) + [ vocab-tags swap diff ] keep set-vocab-tags ; + : vocab-authors-path ( vocab -- string ) vocab-dir "authors.txt" append-path ; @@ -81,5 +87,32 @@ M: vocab-link summary vocab-summary ; : set-vocab-authors ( authors vocab -- ) dup vocab-authors-path set-vocab-file-contents ; +: vocab-platforms-path ( vocab -- string ) + vocab-dir "platforms.txt" append-path ; + +ERROR: bad-platform name ; + +: vocab-platforms ( vocab -- platforms ) + dup vocab-platforms-path vocab-file-contents + [ dup "system" lookup [ ] [ bad-platform ] ?if ] map ; + +: set-vocab-platforms ( platforms vocab -- ) + [ [ name>> ] map ] dip + dup vocab-platforms-path set-vocab-file-contents ; + +: supported-platform? ( vocab -- ? ) + vocab-platforms [ t ] [ [ os swap class<= ] any? ] if-empty ; + : unportable? ( vocab -- ? ) - vocab-tags "unportable" swap member? ; + { + [ vocab-tags "untested" swap member? ] + [ supported-platform? not ] + } 1|| ; + +ERROR: unsupported-platform vocab ; + +M: unsupported-platform summary + drop "Current operating system not supported by this vocabulary" ; + +[ dup supported-platform? [ drop ] [ vocab-name unsupported-platform ] if ] +check-vocab-hook set-global diff --git a/basis/windows/advapi32/platforms.txt b/basis/windows/advapi32/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/advapi32/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/advapi32/tags.txt b/basis/windows/advapi32/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/advapi32/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/ce/platforms.txt b/basis/windows/ce/platforms.txt new file mode 100644 index 0000000000..cd0d980f6f --- /dev/null +++ b/basis/windows/ce/platforms.txt @@ -0,0 +1 @@ +wince diff --git a/basis/windows/ce/tags.txt b/basis/windows/ce/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/ce/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/com/platforms.txt b/basis/windows/com/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/com/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/com/prettyprint/platforms.txt b/basis/windows/com/prettyprint/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/com/prettyprint/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/com/prettyprint/tags.txt b/basis/windows/com/prettyprint/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/com/prettyprint/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/com/syntax/platforms.txt b/basis/windows/com/syntax/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/com/syntax/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/com/syntax/tags.txt b/basis/windows/com/syntax/tags.txt index 2320bdd648..bb863cf9a0 100755 --- a/basis/windows/com/syntax/tags.txt +++ b/basis/windows/com/syntax/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/com/tags.txt b/basis/windows/com/tags.txt index 86dd9eeb91..40fc52b29b 100755 --- a/basis/windows/com/tags.txt +++ b/basis/windows/com/tags.txt @@ -1,3 +1,2 @@ -unportable bindings ffi diff --git a/basis/windows/com/wrapper/platforms.txt b/basis/windows/com/wrapper/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/com/wrapper/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/com/wrapper/tags.txt b/basis/windows/com/wrapper/tags.txt index 2320bdd648..bb863cf9a0 100755 --- a/basis/windows/com/wrapper/tags.txt +++ b/basis/windows/com/wrapper/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/audiodefs/platforms.txt b/basis/windows/directx/audiodefs/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/audiodefs/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/audiodefs/tags.txt b/basis/windows/directx/audiodefs/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/audiodefs/tags.txt +++ b/basis/windows/directx/audiodefs/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d2d1/platforms.txt b/basis/windows/directx/d2d1/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d2d1/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d2d1/tags.txt b/basis/windows/directx/d2d1/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d2d1/tags.txt +++ b/basis/windows/directx/d2d1/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d2dbasetypes/platforms.txt b/basis/windows/directx/d2dbasetypes/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d2dbasetypes/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d2dbasetypes/tags.txt b/basis/windows/directx/d2dbasetypes/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d2dbasetypes/tags.txt +++ b/basis/windows/directx/d2dbasetypes/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d2derr/platforms.txt b/basis/windows/directx/d2derr/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d2derr/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d2derr/tags.txt b/basis/windows/directx/d2derr/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d2derr/tags.txt +++ b/basis/windows/directx/d2derr/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3d10/platforms.txt b/basis/windows/directx/d3d10/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3d10/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3d10/tags.txt b/basis/windows/directx/d3d10/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3d10/tags.txt +++ b/basis/windows/directx/d3d10/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3d10_1/platforms.txt b/basis/windows/directx/d3d10_1/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3d10_1/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3d10_1/tags.txt b/basis/windows/directx/d3d10_1/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3d10_1/tags.txt +++ b/basis/windows/directx/d3d10_1/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3d10_1shader/platforms.txt b/basis/windows/directx/d3d10_1shader/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3d10_1shader/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3d10_1shader/tags.txt b/basis/windows/directx/d3d10_1shader/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3d10_1shader/tags.txt +++ b/basis/windows/directx/d3d10_1shader/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3d10effect/platforms.txt b/basis/windows/directx/d3d10effect/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3d10effect/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3d10effect/tags.txt b/basis/windows/directx/d3d10effect/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3d10effect/tags.txt +++ b/basis/windows/directx/d3d10effect/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3d10misc/platforms.txt b/basis/windows/directx/d3d10misc/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3d10misc/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3d10misc/tags.txt b/basis/windows/directx/d3d10misc/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3d10misc/tags.txt +++ b/basis/windows/directx/d3d10misc/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3d10shader/platforms.txt b/basis/windows/directx/d3d10shader/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3d10shader/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3d10shader/tags.txt b/basis/windows/directx/d3d10shader/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3d10shader/tags.txt +++ b/basis/windows/directx/d3d10shader/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3d11/platforms.txt b/basis/windows/directx/d3d11/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3d11/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3d11/tags.txt b/basis/windows/directx/d3d11/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3d11/tags.txt +++ b/basis/windows/directx/d3d11/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3d11shader/platforms.txt b/basis/windows/directx/d3d11shader/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3d11shader/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3d11shader/tags.txt b/basis/windows/directx/d3d11shader/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3d11shader/tags.txt +++ b/basis/windows/directx/d3d11shader/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3d9/platforms.txt b/basis/windows/directx/d3d9/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3d9/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3d9/tags.txt b/basis/windows/directx/d3d9/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3d9/tags.txt +++ b/basis/windows/directx/d3d9/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3d9caps/platforms.txt b/basis/windows/directx/d3d9caps/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3d9caps/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3d9caps/tags.txt b/basis/windows/directx/d3d9caps/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3d9caps/tags.txt +++ b/basis/windows/directx/d3d9caps/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3d9types/platforms.txt b/basis/windows/directx/d3d9types/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3d9types/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3d9types/tags.txt b/basis/windows/directx/d3d9types/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3d9types/tags.txt +++ b/basis/windows/directx/d3d9types/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dcommon/platforms.txt b/basis/windows/directx/d3dcommon/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dcommon/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dcommon/tags.txt b/basis/windows/directx/d3dcommon/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dcommon/tags.txt +++ b/basis/windows/directx/d3dcommon/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dcompiler/platforms.txt b/basis/windows/directx/d3dcompiler/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dcompiler/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dcompiler/tags.txt b/basis/windows/directx/d3dcompiler/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dcompiler/tags.txt +++ b/basis/windows/directx/d3dcompiler/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dcsx/platforms.txt b/basis/windows/directx/d3dcsx/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dcsx/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dcsx/tags.txt b/basis/windows/directx/d3dcsx/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dcsx/tags.txt +++ b/basis/windows/directx/d3dcsx/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx10/platforms.txt b/basis/windows/directx/d3dx10/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx10/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx10/tags.txt b/basis/windows/directx/d3dx10/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx10/tags.txt +++ b/basis/windows/directx/d3dx10/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx10async/platforms.txt b/basis/windows/directx/d3dx10async/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx10async/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx10async/tags.txt b/basis/windows/directx/d3dx10async/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx10async/tags.txt +++ b/basis/windows/directx/d3dx10async/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx10core/platforms.txt b/basis/windows/directx/d3dx10core/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx10core/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx10core/tags.txt b/basis/windows/directx/d3dx10core/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx10core/tags.txt +++ b/basis/windows/directx/d3dx10core/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx10math/platforms.txt b/basis/windows/directx/d3dx10math/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx10math/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx10math/tags.txt b/basis/windows/directx/d3dx10math/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx10math/tags.txt +++ b/basis/windows/directx/d3dx10math/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx10mesh/platforms.txt b/basis/windows/directx/d3dx10mesh/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx10mesh/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx10mesh/tags.txt b/basis/windows/directx/d3dx10mesh/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx10mesh/tags.txt +++ b/basis/windows/directx/d3dx10mesh/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx10tex/platforms.txt b/basis/windows/directx/d3dx10tex/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx10tex/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx10tex/tags.txt b/basis/windows/directx/d3dx10tex/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx10tex/tags.txt +++ b/basis/windows/directx/d3dx10tex/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx11/platforms.txt b/basis/windows/directx/d3dx11/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx11/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx11/tags.txt b/basis/windows/directx/d3dx11/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx11/tags.txt +++ b/basis/windows/directx/d3dx11/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx11async/platforms.txt b/basis/windows/directx/d3dx11async/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx11async/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx11async/tags.txt b/basis/windows/directx/d3dx11async/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx11async/tags.txt +++ b/basis/windows/directx/d3dx11async/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx11core/platforms.txt b/basis/windows/directx/d3dx11core/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx11core/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx11core/tags.txt b/basis/windows/directx/d3dx11core/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx11core/tags.txt +++ b/basis/windows/directx/d3dx11core/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx11tex/platforms.txt b/basis/windows/directx/d3dx11tex/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx11tex/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx11tex/tags.txt b/basis/windows/directx/d3dx11tex/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx11tex/tags.txt +++ b/basis/windows/directx/d3dx11tex/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx9/platforms.txt b/basis/windows/directx/d3dx9/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx9/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx9/tags.txt b/basis/windows/directx/d3dx9/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx9/tags.txt +++ b/basis/windows/directx/d3dx9/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx9anim/platforms.txt b/basis/windows/directx/d3dx9anim/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx9anim/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx9anim/tags.txt b/basis/windows/directx/d3dx9anim/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx9anim/tags.txt +++ b/basis/windows/directx/d3dx9anim/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx9core/platforms.txt b/basis/windows/directx/d3dx9core/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx9core/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx9core/tags.txt b/basis/windows/directx/d3dx9core/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx9core/tags.txt +++ b/basis/windows/directx/d3dx9core/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx9effect/platforms.txt b/basis/windows/directx/d3dx9effect/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx9effect/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx9effect/tags.txt b/basis/windows/directx/d3dx9effect/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx9effect/tags.txt +++ b/basis/windows/directx/d3dx9effect/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx9math/platforms.txt b/basis/windows/directx/d3dx9math/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx9math/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx9math/tags.txt b/basis/windows/directx/d3dx9math/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx9math/tags.txt +++ b/basis/windows/directx/d3dx9math/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx9mesh/platforms.txt b/basis/windows/directx/d3dx9mesh/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx9mesh/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx9mesh/tags.txt b/basis/windows/directx/d3dx9mesh/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx9mesh/tags.txt +++ b/basis/windows/directx/d3dx9mesh/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx9shader/platforms.txt b/basis/windows/directx/d3dx9shader/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx9shader/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx9shader/tags.txt b/basis/windows/directx/d3dx9shader/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx9shader/tags.txt +++ b/basis/windows/directx/d3dx9shader/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx9shape/platforms.txt b/basis/windows/directx/d3dx9shape/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx9shape/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx9shape/tags.txt b/basis/windows/directx/d3dx9shape/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx9shape/tags.txt +++ b/basis/windows/directx/d3dx9shape/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx9tex/platforms.txt b/basis/windows/directx/d3dx9tex/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx9tex/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx9tex/tags.txt b/basis/windows/directx/d3dx9tex/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx9tex/tags.txt +++ b/basis/windows/directx/d3dx9tex/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/d3dx9xof/platforms.txt b/basis/windows/directx/d3dx9xof/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/d3dx9xof/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/d3dx9xof/tags.txt b/basis/windows/directx/d3dx9xof/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/d3dx9xof/tags.txt +++ b/basis/windows/directx/d3dx9xof/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/dcommon/platforms.txt b/basis/windows/directx/dcommon/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/dcommon/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/dcommon/tags.txt b/basis/windows/directx/dcommon/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/dcommon/tags.txt +++ b/basis/windows/directx/dcommon/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/dinput/constants/platforms.txt b/basis/windows/directx/dinput/constants/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/dinput/constants/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/dinput/constants/tags.txt b/basis/windows/directx/dinput/constants/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/directx/dinput/constants/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/directx/dinput/platforms.txt b/basis/windows/directx/dinput/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/dinput/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/dinput/tags.txt b/basis/windows/directx/dinput/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/dinput/tags.txt +++ b/basis/windows/directx/dinput/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/dwrite/platforms.txt b/basis/windows/directx/dwrite/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/dwrite/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/dwrite/tags.txt b/basis/windows/directx/dwrite/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/dwrite/tags.txt +++ b/basis/windows/directx/dwrite/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/dxfile/platforms.txt b/basis/windows/directx/dxfile/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/dxfile/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/dxfile/tags.txt b/basis/windows/directx/dxfile/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/dxfile/tags.txt +++ b/basis/windows/directx/dxfile/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/dxgi/platforms.txt b/basis/windows/directx/dxgi/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/dxgi/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/dxgi/tags.txt b/basis/windows/directx/dxgi/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/dxgi/tags.txt +++ b/basis/windows/directx/dxgi/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/dxgiformat/platforms.txt b/basis/windows/directx/dxgiformat/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/dxgiformat/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/dxgiformat/tags.txt b/basis/windows/directx/dxgiformat/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/dxgiformat/tags.txt +++ b/basis/windows/directx/dxgiformat/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/dxgitype/platforms.txt b/basis/windows/directx/dxgitype/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/dxgitype/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/dxgitype/tags.txt b/basis/windows/directx/dxgitype/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/dxgitype/tags.txt +++ b/basis/windows/directx/dxgitype/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/x3daudio/platforms.txt b/basis/windows/directx/x3daudio/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/x3daudio/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/x3daudio/tags.txt b/basis/windows/directx/x3daudio/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/x3daudio/tags.txt +++ b/basis/windows/directx/x3daudio/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/xact3/platforms.txt b/basis/windows/directx/xact3/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/xact3/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/xact3/tags.txt b/basis/windows/directx/xact3/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/xact3/tags.txt +++ b/basis/windows/directx/xact3/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/xapo/platforms.txt b/basis/windows/directx/xapo/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/xapo/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/xapo/tags.txt b/basis/windows/directx/xapo/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/xapo/tags.txt +++ b/basis/windows/directx/xapo/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/xapofx/platforms.txt b/basis/windows/directx/xapofx/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/xapofx/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/xapofx/tags.txt b/basis/windows/directx/xapofx/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/xapofx/tags.txt +++ b/basis/windows/directx/xapofx/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/xaudio2/platforms.txt b/basis/windows/directx/xaudio2/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/xaudio2/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/xaudio2/tags.txt b/basis/windows/directx/xaudio2/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/xaudio2/tags.txt +++ b/basis/windows/directx/xaudio2/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/xaudio2fx/platforms.txt b/basis/windows/directx/xaudio2fx/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/xaudio2fx/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/xaudio2fx/tags.txt b/basis/windows/directx/xaudio2fx/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/xaudio2fx/tags.txt +++ b/basis/windows/directx/xaudio2fx/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/directx/xinput/platforms.txt b/basis/windows/directx/xinput/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/directx/xinput/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/directx/xinput/tags.txt b/basis/windows/directx/xinput/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/directx/xinput/tags.txt +++ b/basis/windows/directx/xinput/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/dragdrop-listener/platforms.txt b/basis/windows/dragdrop-listener/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/dragdrop-listener/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/dragdrop-listener/tags.txt b/basis/windows/dragdrop-listener/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/dragdrop-listener/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/dwmapi/platforms.txt b/basis/windows/dwmapi/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/dwmapi/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/dwmapi/tags.txt b/basis/windows/dwmapi/tags.txt index 43bc035447..8e1a55995e 100755 --- a/basis/windows/dwmapi/tags.txt +++ b/basis/windows/dwmapi/tags.txt @@ -1,2 +1 @@ windows -unportable diff --git a/basis/windows/errors/platforms.txt b/basis/windows/errors/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/errors/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/errors/tags.txt b/basis/windows/errors/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/errors/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/fonts/platforms.txt b/basis/windows/fonts/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/fonts/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/fonts/tags.txt b/basis/windows/fonts/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/fonts/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/gdi32/platforms.txt b/basis/windows/gdi32/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/gdi32/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/gdi32/tags.txt b/basis/windows/gdi32/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/gdi32/tags.txt +++ b/basis/windows/gdi32/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/kernel32/platforms.txt b/basis/windows/kernel32/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/kernel32/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/kernel32/tags.txt b/basis/windows/kernel32/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/kernel32/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/messages/platforms.txt b/basis/windows/messages/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/messages/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/messages/tags.txt b/basis/windows/messages/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/messages/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/nt/platforms.txt b/basis/windows/nt/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/nt/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/nt/tags.txt b/basis/windows/nt/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/nt/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/offscreen/platforms.txt b/basis/windows/offscreen/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/offscreen/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/offscreen/tags.txt b/basis/windows/offscreen/tags.txt deleted file mode 100755 index 6abe115b12..0000000000 --- a/basis/windows/offscreen/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/ole32/platforms.txt b/basis/windows/ole32/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/ole32/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/ole32/tags.txt b/basis/windows/ole32/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/ole32/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/opengl32/platforms.txt b/basis/windows/opengl32/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/opengl32/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/opengl32/tags.txt b/basis/windows/opengl32/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/opengl32/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/platforms.txt b/basis/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/psapi/platforms.txt b/basis/windows/psapi/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/psapi/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/psapi/tags.txt b/basis/windows/psapi/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/psapi/tags.txt +++ b/basis/windows/psapi/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/shell32/platforms.txt b/basis/windows/shell32/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/shell32/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/shell32/tags.txt b/basis/windows/shell32/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/shell32/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/tags.txt b/basis/windows/tags.txt index 2320bdd648..bb863cf9a0 100755 --- a/basis/windows/tags.txt +++ b/basis/windows/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/time/platforms.txt b/basis/windows/time/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/time/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/time/tags.txt b/basis/windows/time/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/time/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/types/platforms.txt b/basis/windows/types/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/types/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/types/tags.txt b/basis/windows/types/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/types/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/uniscribe/platforms.txt b/basis/windows/uniscribe/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/uniscribe/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/uniscribe/tags.txt b/basis/windows/uniscribe/tags.txt deleted file mode 100755 index 6abe115b12..0000000000 --- a/basis/windows/uniscribe/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/user32/platforms.txt b/basis/windows/user32/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/user32/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/user32/tags.txt b/basis/windows/user32/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/user32/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/windows/usp10/platforms.txt b/basis/windows/usp10/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/usp10/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/usp10/tags.txt b/basis/windows/usp10/tags.txt index 2320bdd648..bb863cf9a0 100644 --- a/basis/windows/usp10/tags.txt +++ b/basis/windows/usp10/tags.txt @@ -1,2 +1 @@ -unportable bindings diff --git a/basis/windows/winsock/platforms.txt b/basis/windows/winsock/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/basis/windows/winsock/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/basis/windows/winsock/tags.txt b/basis/windows/winsock/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/windows/winsock/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/x11/io/unix/platforms.txt b/basis/x11/io/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/x11/io/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/x11/io/unix/tags.txt b/basis/x11/io/unix/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/x11/io/unix/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/x11/windows/platforms.txt b/basis/x11/windows/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/basis/x11/windows/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/basis/x11/windows/tags.txt b/basis/x11/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/x11/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/core/vocabs/loader/loader.factor b/core/vocabs/loader/loader.factor index 2c0f67641d..67d7d7677d 100644 --- a/core/vocabs/loader/loader.factor +++ b/core/vocabs/loader/loader.factor @@ -99,6 +99,11 @@ PRIVATE> SYMBOL: blacklist +! Defined by vocabs.metadata +SYMBOL: check-vocab-hook + +check-vocab-hook [ [ drop ] ] initialize + diff --git a/core/vocabs/loader/test/a/a.factor b/core/vocabs/loader/test/a/a.factor index 03a2f8a091..18ed045936 100644 --- a/core/vocabs/loader/test/a/a.factor +++ b/core/vocabs/loader/test/a/a.factor @@ -3,7 +3,7 @@ IN: vocabs.loader.test.a << global [ "count-me" inc ] bind >> -: v-l-t-a-hello 4 ; +: v-l-t-a-hello ( -- a ) 4 ; : byebye v-l-t-a-hello ; diff --git a/core/vocabs/loader/test/a/tags.txt b/core/vocabs/loader/test/a/tags.txt index 6bf68304bb..5d77766703 100644 --- a/core/vocabs/loader/test/a/tags.txt +++ b/core/vocabs/loader/test/a/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/core/vocabs/loader/test/b/tags.txt b/core/vocabs/loader/test/b/tags.txt index 6bf68304bb..5d77766703 100644 --- a/core/vocabs/loader/test/b/tags.txt +++ b/core/vocabs/loader/test/b/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/core/vocabs/loader/test/c/tags.txt b/core/vocabs/loader/test/c/tags.txt index 6bf68304bb..5d77766703 100644 --- a/core/vocabs/loader/test/c/tags.txt +++ b/core/vocabs/loader/test/c/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/core/vocabs/loader/test/d/tags.txt b/core/vocabs/loader/test/d/tags.txt index 6bf68304bb..5d77766703 100644 --- a/core/vocabs/loader/test/d/tags.txt +++ b/core/vocabs/loader/test/d/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/core/vocabs/loader/test/e/tags.txt b/core/vocabs/loader/test/e/tags.txt index 6bf68304bb..5d77766703 100644 --- a/core/vocabs/loader/test/e/tags.txt +++ b/core/vocabs/loader/test/e/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/core/vocabs/loader/test/f/tags.txt b/core/vocabs/loader/test/f/tags.txt index 6bf68304bb..5d77766703 100644 --- a/core/vocabs/loader/test/f/tags.txt +++ b/core/vocabs/loader/test/f/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/core/vocabs/loader/test/g/tags.txt b/core/vocabs/loader/test/g/tags.txt index 6bf68304bb..5d77766703 100644 --- a/core/vocabs/loader/test/g/tags.txt +++ b/core/vocabs/loader/test/g/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/core/vocabs/loader/test/h/tags.txt b/core/vocabs/loader/test/h/tags.txt index 6bf68304bb..5d77766703 100644 --- a/core/vocabs/loader/test/h/tags.txt +++ b/core/vocabs/loader/test/h/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/core/vocabs/loader/test/i/tags.txt b/core/vocabs/loader/test/i/tags.txt index 6bf68304bb..5d77766703 100644 --- a/core/vocabs/loader/test/i/tags.txt +++ b/core/vocabs/loader/test/i/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/core/vocabs/loader/test/j/tags.txt b/core/vocabs/loader/test/j/tags.txt index 6bf68304bb..5d77766703 100644 --- a/core/vocabs/loader/test/j/tags.txt +++ b/core/vocabs/loader/test/j/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/core/vocabs/loader/test/k/tags.txt b/core/vocabs/loader/test/k/tags.txt index 6bf68304bb..5d77766703 100644 --- a/core/vocabs/loader/test/k/tags.txt +++ b/core/vocabs/loader/test/k/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/core/vocabs/loader/test/l/tags.txt b/core/vocabs/loader/test/l/tags.txt index 6bf68304bb..5d77766703 100644 --- a/core/vocabs/loader/test/l/tags.txt +++ b/core/vocabs/loader/test/l/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/extra/couchdb/tags.txt b/extra/couchdb/tags.txt index 6bf68304bb..5d77766703 100644 --- a/extra/couchdb/tags.txt +++ b/extra/couchdb/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/extra/curses/ffi/platforms.txt b/extra/curses/ffi/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/extra/curses/ffi/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/extra/curses/ffi/tags.txt b/extra/curses/ffi/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/extra/curses/ffi/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/extra/curses/platforms.txt b/extra/curses/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/extra/curses/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/extra/curses/tags.txt b/extra/curses/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/extra/curses/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/extra/ecdsa/tags.txt b/extra/ecdsa/tags.txt index 6bf68304bb..5d77766703 100644 --- a/extra/ecdsa/tags.txt +++ b/extra/ecdsa/tags.txt @@ -1 +1 @@ -unportable +untested 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/platforms.txt b/extra/io/serial/unix/bsd/platforms.txt new file mode 100644 index 0000000000..df796f15d4 --- /dev/null +++ b/extra/io/serial/unix/bsd/platforms.txt @@ -0,0 +1 @@ +bsd 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/platforms.txt b/extra/io/serial/unix/linux/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/extra/io/serial/unix/linux/platforms.txt @@ -0,0 +1 @@ +linux 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/platforms.txt b/extra/io/serial/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/extra/io/serial/unix/platforms.txt @@ -0,0 +1 @@ +unix 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/platforms.txt b/extra/io/serial/unix/termios/bsd/platforms.txt new file mode 100644 index 0000000000..df796f15d4 --- /dev/null +++ b/extra/io/serial/unix/termios/bsd/platforms.txt @@ -0,0 +1 @@ +bsd 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/platforms.txt b/extra/io/serial/unix/termios/linux/platforms.txt new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/extra/io/serial/unix/termios/linux/platforms.txt @@ -0,0 +1 @@ +linux 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/platforms.txt b/extra/io/serial/unix/termios/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/extra/io/serial/unix/termios/platforms.txt @@ -0,0 +1 @@ +unix 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/windows/platforms.txt b/extra/io/serial/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/extra/io/serial/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/extra/io/serial/windows/tags.txt b/extra/io/serial/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/extra/io/serial/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/extra/libusb/platforms.txt b/extra/libusb/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/extra/libusb/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/extra/libusb/tags.txt b/extra/libusb/tags.txt index bf2a35f15b..bb863cf9a0 100644 --- a/extra/libusb/tags.txt +++ b/extra/libusb/tags.txt @@ -1,2 +1 @@ bindings -unportable diff --git a/extra/llvm/core/tags.txt b/extra/llvm/core/tags.txt index 6bf68304bb..5d77766703 100644 --- a/extra/llvm/core/tags.txt +++ b/extra/llvm/core/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/extra/llvm/engine/tags.txt b/extra/llvm/engine/tags.txt index 6bf68304bb..5d77766703 100644 --- a/extra/llvm/engine/tags.txt +++ b/extra/llvm/engine/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/extra/llvm/invoker/tags.txt b/extra/llvm/invoker/tags.txt index 6bf68304bb..5d77766703 100644 --- a/extra/llvm/invoker/tags.txt +++ b/extra/llvm/invoker/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/extra/llvm/jit/tags.txt b/extra/llvm/jit/tags.txt index 6bf68304bb..5d77766703 100644 --- a/extra/llvm/jit/tags.txt +++ b/extra/llvm/jit/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/extra/llvm/reader/tags.txt b/extra/llvm/reader/tags.txt index 6bf68304bb..5d77766703 100644 --- a/extra/llvm/reader/tags.txt +++ b/extra/llvm/reader/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/extra/llvm/tags.txt b/extra/llvm/tags.txt index bf2a35f15b..a9d28becd8 100644 --- a/extra/llvm/tags.txt +++ b/extra/llvm/tags.txt @@ -1,2 +1,2 @@ bindings -unportable +untested diff --git a/extra/llvm/types/tags.txt b/extra/llvm/types/tags.txt index 6bf68304bb..5d77766703 100644 --- a/extra/llvm/types/tags.txt +++ b/extra/llvm/types/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/extra/llvm/wrappers/tags.txt b/extra/llvm/wrappers/tags.txt index 6bf68304bb..5d77766703 100644 --- a/extra/llvm/wrappers/tags.txt +++ b/extra/llvm/wrappers/tags.txt @@ -1 +1 @@ -unportable +untested diff --git a/extra/merger/platforms.txt b/extra/merger/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/extra/merger/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/extra/merger/tags.txt b/extra/merger/tags.txt deleted file mode 100644 index c80b8b4fe1..0000000000 --- a/extra/merger/tags.txt +++ /dev/null @@ -1,2 +0,0 @@ -unportable - diff --git a/extra/openal/alut/macosx/platforms.txt b/extra/openal/alut/macosx/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/extra/openal/alut/macosx/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/extra/openal/alut/macosx/tags.txt b/extra/openal/alut/macosx/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/extra/openal/alut/macosx/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/extra/qtkit/platforms.txt b/extra/qtkit/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/extra/qtkit/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/extra/qtkit/tags.txt b/extra/qtkit/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/extra/qtkit/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/extra/webkit-demo/platforms.txt b/extra/webkit-demo/platforms.txt new file mode 100644 index 0000000000..6e806f449e --- /dev/null +++ b/extra/webkit-demo/platforms.txt @@ -0,0 +1 @@ +macosx diff --git a/extra/webkit-demo/tags.txt b/extra/webkit-demo/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/extra/webkit-demo/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable From c3f4bcb616140027d10326794ce5eb3aa4235785 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Feb 2010 13:31:09 +1300 Subject: [PATCH 114/713] Fix load errors exposed by platforms.txt change --- basis/cocoa/callbacks/callbacks.factor | 4 ++-- basis/io/backend/unix/multiplexers/select/select.factor | 7 ++++--- basis/unix/utmpx/macosx/macosx.factor | 2 +- basis/unix/utmpx/utmpx.factor | 6 ++++-- extra/io/serial/unix/unix.factor | 4 ++-- extra/qtkit/qtkit.factor | 5 +++-- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/basis/cocoa/callbacks/callbacks.factor b/basis/cocoa/callbacks/callbacks.factor index e1ec43f1dc..87b5f628a9 100644 --- a/basis/cocoa/callbacks/callbacks.factor +++ b/basis/cocoa/callbacks/callbacks.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005, 2006 Kevin Reid. ! See http://factorcode.org/license.txt for BSD license. -USING: assocs kernel namespaces cocoa cocoa.classes -cocoa.subclassing debugger ; +USING: alien.c-types assocs kernel namespaces cocoa +cocoa.classes cocoa.runtime cocoa.subclassing debugger ; IN: cocoa.callbacks SYMBOL: callbacks diff --git a/basis/io/backend/unix/multiplexers/select/select.factor b/basis/io/backend/unix/multiplexers/select/select.factor index f2d1a3a3b7..5a3dab4dcc 100644 --- a/basis/io/backend/unix/multiplexers/select/select.factor +++ b/basis/io/backend/unix/multiplexers/select/select.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types kernel bit-arrays sequences assocs unix -math namespaces accessors math.order locals unix.time fry -io.ports io.backend.unix io.backend.unix.multiplexers ; +USING: alien.c-types kernel bit-arrays sequences assocs math +namespaces accessors math.order locals fry io.ports +io.backend.unix io.backend.unix.multiplexers unix unix.ffi +unix.time ; IN: io.backend.unix.multiplexers.select TUPLE: select-mx < mx read-fdset write-fdset ; diff --git a/basis/unix/utmpx/macosx/macosx.factor b/basis/unix/utmpx/macosx/macosx.factor index 92a0d9e3a4..faae29ffa4 100644 --- a/basis/unix/utmpx/macosx/macosx.factor +++ b/basis/unix/utmpx/macosx/macosx.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax unix.bsd.macosx ; +USING: alien.syntax unix.ffi.bsd.macosx ; IN: unix.utmpx.macosx ! empty diff --git a/basis/unix/utmpx/utmpx.factor b/basis/unix/utmpx/utmpx.factor index 6083776fc6..78556ab225 100644 --- a/basis/unix/utmpx/utmpx.factor +++ b/basis/unix/utmpx/utmpx.factor @@ -2,8 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien.c-types alien.data alien.syntax combinators continuations io.encodings.string io.encodings.utf8 kernel -sequences strings unix calendar system accessors unix.time -calendar.unix vocabs.loader classes.struct ; +sequences strings calendar system accessors unix unix.time +unix.ffi calendar.unix vocabs.loader classes.struct ; IN: unix.utmpx CONSTANT: EMPTY 0 @@ -19,6 +19,8 @@ CONSTANT: ACCOUNTING 9 CONSTANT: SIGNATURE 10 CONSTANT: SHUTDOWN_TIME 11 +C-TYPE: utmpx + FUNCTION: void setutxent ( ) ; FUNCTION: void endutxent ( ) ; FUNCTION: utmpx* getutxent ( ) ; diff --git a/extra/io/serial/unix/unix.factor b/extra/io/serial/unix/unix.factor index 8ee115ca45..6c0de55ec8 100644 --- a/extra/io/serial/unix/unix.factor +++ b/extra/io/serial/unix/unix.factor @@ -2,8 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.syntax alien.data classes.struct combinators io.ports io.streams.duplex -system kernel math math.bitwise vocabs.loader unix io.serial -io.serial.unix.termios io.backend.unix ; +system kernel math math.bitwise vocabs.loader io.serial +io.serial.unix.termios io.backend.unix unix unix.ffi ; IN: io.serial.unix << { diff --git a/extra/qtkit/qtkit.factor b/extra/qtkit/qtkit.factor index b573cd51ab..919e0d2d29 100644 --- a/extra/qtkit/qtkit.factor +++ b/extra/qtkit/qtkit.factor @@ -1,5 +1,6 @@ -USING: classes.struct cocoa cocoa.application cocoa.classes -cocoa.enumeration cocoa.plists core-foundation.strings kernel ; +USING: alien.c-types classes.struct cocoa cocoa.application +cocoa.classes cocoa.enumeration cocoa.plists core-foundation +core-foundation.strings kernel ; IN: qtkit STRUCT: QTTime From 1915b7e955787ea49a62f8dbe6acc7d7e241dcd5 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Feb 2010 13:31:51 +1300 Subject: [PATCH 115/713] vocabs.loader.test.a: fix --- core/vocabs/loader/test/a/a.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/vocabs/loader/test/a/a.factor b/core/vocabs/loader/test/a/a.factor index 18ed045936..b1fa5aaed8 100644 --- a/core/vocabs/loader/test/a/a.factor +++ b/core/vocabs/loader/test/a/a.factor @@ -5,6 +5,6 @@ IN: vocabs.loader.test.a : v-l-t-a-hello ( -- a ) 4 ; -: byebye v-l-t-a-hello ; +: byebye ( -- a ) v-l-t-a-hello ; [ this is an error From 6e516789d5c8f9072347c846fd1e8ea8cbd75924 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Feb 2010 13:41:33 +1300 Subject: [PATCH 116/713] continuations: add a throw-continue word for resumable errors, and change vocabs.metadata to throw a resumable error if the current platform is not supported --- basis/vocabs/metadata/metadata.factor | 17 +++++++++++------ core/compiler/units/units.factor | 3 +-- core/continuations/continuations-docs.factor | 12 ++++++++++-- core/continuations/continuations.factor | 3 +++ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/basis/vocabs/metadata/metadata.factor b/basis/vocabs/metadata/metadata.factor index 10e4eac2a2..09ca012fcc 100644 --- a/basis/vocabs/metadata/metadata.factor +++ b/basis/vocabs/metadata/metadata.factor @@ -100,19 +100,24 @@ ERROR: bad-platform name ; [ [ name>> ] map ] dip dup vocab-platforms-path set-vocab-file-contents ; -: supported-platform? ( vocab -- ? ) - vocab-platforms [ t ] [ [ os swap class<= ] any? ] if-empty ; +: supported-platform? ( platforms -- ? ) + [ t ] [ [ os swap class<= ] any? ] if-empty ; : unportable? ( vocab -- ? ) { [ vocab-tags "untested" swap member? ] - [ supported-platform? not ] + [ vocab-platforms supported-platform? not ] } 1|| ; -ERROR: unsupported-platform vocab ; +TUPLE: unsupported-platform vocab requires ; + +: unsupported-platform ( vocab requires -- ) + \ unsupported-platform boa throw-continue ; M: unsupported-platform summary drop "Current operating system not supported by this vocabulary" ; -[ dup supported-platform? [ drop ] [ vocab-name unsupported-platform ] if ] -check-vocab-hook set-global +[ + dup vocab-platforms dup supported-platform? + [ 2drop ] [ [ vocab-name ] dip unsupported-platform ] if +] check-vocab-hook set-global diff --git a/core/compiler/units/units.factor b/core/compiler/units/units.factor index 9582ebadb6..b024ed2c65 100644 --- a/core/compiler/units/units.factor +++ b/core/compiler/units/units.factor @@ -12,8 +12,7 @@ SYMBOL: new-definitions TUPLE: redefine-error def ; : redefine-error ( definition -- ) - \ redefine-error boa - { { "Continue" t } } throw-restarts drop ; + \ redefine-error boa throw-continue ; condition ( error restarts cc -- condition ) : rethrow-restarts ( error restarts -- restart ) [ rethrow ] callcc1 2nip ; +: throw-continue ( error -- ) + { { "Continue" t } } throw-restarts drop ; + TUPLE: restart name obj continuation ; C: restart From 0f1aa770a193867e6f286f2b44b2f028c54c0f9e Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sat, 20 Feb 2010 00:22:01 -0800 Subject: [PATCH 117/713] Merge up --- extra/openal/alut/alut.factor | 206 ++++++++++++++-------------- extra/openal/example/example.factor | 66 ++++----- 2 files changed, 136 insertions(+), 136 deletions(-) diff --git a/extra/openal/alut/alut.factor b/extra/openal/alut/alut.factor index d1b8d2600d..9e37d9886c 100755 --- a/extra/openal/alut/alut.factor +++ b/extra/openal/alut/alut.factor @@ -1,103 +1,103 @@ -! Copyright (C) 2007 Chris Double. -! See http://factorcode.org/license.txt for BSD license. -USING: kernel accessors arrays alien system combinators -alien.syntax namespaces alien.c-types sequences vocabs.loader -shuffle openal openal.alut.backend alien.libraries generalizations -specialized-arrays alien.destructors ; -FROM: alien.c-types => float short ; -SPECIALIZED-ARRAY: uint -IN: openal.alut - -<< "alut" { - { [ os windows? ] [ "alut.dll" ] } - { [ os macosx? ] [ - "/System/Library/Frameworks/OpenAL.framework/OpenAL" - ] } - { [ os unix? ] [ "libalut.so" ] } - } cond "cdecl" add-library >> - -<< os macosx? [ "alut" deploy-library ] unless >> - -LIBRARY: alut - -CONSTANT: ALUT_API_MAJOR_VERSION 1 -CONSTANT: ALUT_API_MINOR_VERSION 1 -CONSTANT: ALUT_ERROR_NO_ERROR 0 -CONSTANT: ALUT_ERROR_OUT_OF_MEMORY HEX: 200 -CONSTANT: ALUT_ERROR_INVALID_ENUM HEX: 201 -CONSTANT: ALUT_ERROR_INVALID_VALUE HEX: 202 -CONSTANT: ALUT_ERROR_INVALID_OPERATION HEX: 203 -CONSTANT: ALUT_ERROR_NO_CURRENT_CONTEXT HEX: 204 -CONSTANT: ALUT_ERROR_AL_ERROR_ON_ENTRY HEX: 205 -CONSTANT: ALUT_ERROR_ALC_ERROR_ON_ENTRY HEX: 206 -CONSTANT: ALUT_ERROR_OPEN_DEVICE HEX: 207 -CONSTANT: ALUT_ERROR_CLOSE_DEVICE HEX: 208 -CONSTANT: ALUT_ERROR_CREATE_CONTEXT HEX: 209 -CONSTANT: ALUT_ERROR_MAKE_CONTEXT_CURRENT HEX: 20A -CONSTANT: ALUT_ERROR_DESTRY_CONTEXT HEX: 20B -CONSTANT: ALUT_ERROR_GEN_BUFFERS HEX: 20C -CONSTANT: ALUT_ERROR_BUFFER_DATA HEX: 20D -CONSTANT: ALUT_ERROR_IO_ERROR HEX: 20E -CONSTANT: ALUT_ERROR_UNSUPPORTED_FILE_TYPE HEX: 20F -CONSTANT: ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE HEX: 210 -CONSTANT: ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA HEX: 211 -CONSTANT: ALUT_WAVEFORM_SINE HEX: 100 -CONSTANT: ALUT_WAVEFORM_SQUARE HEX: 101 -CONSTANT: ALUT_WAVEFORM_SAWTOOTH HEX: 102 -CONSTANT: ALUT_WAVEFORM_WHITENOISE HEX: 103 -CONSTANT: ALUT_WAVEFORM_IMPULSE HEX: 104 -CONSTANT: ALUT_LOADER_BUFFER HEX: 300 -CONSTANT: ALUT_LOADER_MEMORY HEX: 301 - -FUNCTION: ALboolean alutInit ( int* argcp, char** argv ) ; -FUNCTION: ALboolean alutInitWithoutContext ( int* argcp, char** argv ) ; -FUNCTION: ALboolean alutExit ( ) ; -FUNCTION: ALenum alutGetError ( ) ; -FUNCTION: char* alutGetErrorString ( ALenum error ) ; -FUNCTION: ALuint alutCreateBufferFromFile ( char* fileName ) ; -FUNCTION: ALuint alutCreateBufferFromFileImage ( void* data, ALsizei length ) ; -FUNCTION: ALuint alutCreateBufferHelloWorld ( ) ; -FUNCTION: ALuint alutCreateBufferWaveform ( ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration ) ; -FUNCTION: void* alutLoadMemoryFromFile ( char* fileName, ALenum* format, ALsizei* size, ALfloat* frequency ) ; -FUNCTION: void* alutLoadMemoryFromFileImage ( void* data, ALsizei length, ALenum* format, ALsizei* size, ALfloat* frequency ) ; -FUNCTION: void* alutLoadMemoryHelloWorld ( ALenum* format, ALsizei* size, ALfloat* frequency ) ; -FUNCTION: void* alutLoadMemoryWaveform ( ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration, ALenum* format, ALsizei* size, ALfloat* freq ) ; -FUNCTION: char* alutGetMIMETypes ( ALenum loader ) ; -FUNCTION: ALint alutGetMajorVersion ( ) ; -FUNCTION: ALint alutGetMinorVersion ( ) ; -FUNCTION: ALboolean alutSleep ( ALfloat duration ) ; - -FUNCTION: void alutUnloadWAV ( ALenum format, void* data, ALsizei size, ALsizei frequency ) ; - -SYMBOL: init - -: init-openal ( -- ) - init get-global expired? [ - f f alutInit 0 = [ "Could not initialize OpenAL" throw ] when - 1337 init set-global - ] when ; - -: exit-openal ( -- ) - init get-global expired? [ - alutExit 0 = [ "Could not close OpenAL" throw ] when - f init set-global - ] unless ; - -: create-buffer-from-file ( filename -- buffer ) - alutCreateBufferFromFile dup AL_NONE = [ - "create-buffer-from-file failed" throw - ] when ; - -os macosx? "openal.alut.macosx" "openal.alut.other" ? require - -: create-buffer-from-wav ( filename -- buffer ) - gen-buffer dup rot load-wav-file - [ alBufferData ] 4 nkeep alutUnloadWAV ; - -: check-error ( -- ) - alGetError dup ALUT_ERROR_NO_ERROR = [ - drop - ] [ - alGetString throw - ] if ; - +! Copyright (C) 2007 Chris Double. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel accessors arrays alien system combinators +alien.syntax namespaces alien.c-types sequences vocabs.loader +shuffle openal openal.alut.backend alien.libraries generalizations +specialized-arrays alien.destructors ; +FROM: alien.c-types => float short ; +SPECIALIZED-ARRAY: uint +IN: openal.alut + +<< "alut" { + { [ os windows? ] [ "alut.dll" ] } + { [ os macosx? ] [ + "/System/Library/Frameworks/OpenAL.framework/OpenAL" + ] } + { [ os unix? ] [ "libalut.so" ] } + } cond "cdecl" add-library >> + +<< os macosx? [ "alut" deploy-library ] unless >> + +LIBRARY: alut + +CONSTANT: ALUT_API_MAJOR_VERSION 1 +CONSTANT: ALUT_API_MINOR_VERSION 1 +CONSTANT: ALUT_ERROR_NO_ERROR 0 +CONSTANT: ALUT_ERROR_OUT_OF_MEMORY HEX: 200 +CONSTANT: ALUT_ERROR_INVALID_ENUM HEX: 201 +CONSTANT: ALUT_ERROR_INVALID_VALUE HEX: 202 +CONSTANT: ALUT_ERROR_INVALID_OPERATION HEX: 203 +CONSTANT: ALUT_ERROR_NO_CURRENT_CONTEXT HEX: 204 +CONSTANT: ALUT_ERROR_AL_ERROR_ON_ENTRY HEX: 205 +CONSTANT: ALUT_ERROR_ALC_ERROR_ON_ENTRY HEX: 206 +CONSTANT: ALUT_ERROR_OPEN_DEVICE HEX: 207 +CONSTANT: ALUT_ERROR_CLOSE_DEVICE HEX: 208 +CONSTANT: ALUT_ERROR_CREATE_CONTEXT HEX: 209 +CONSTANT: ALUT_ERROR_MAKE_CONTEXT_CURRENT HEX: 20A +CONSTANT: ALUT_ERROR_DESTRY_CONTEXT HEX: 20B +CONSTANT: ALUT_ERROR_GEN_BUFFERS HEX: 20C +CONSTANT: ALUT_ERROR_BUFFER_DATA HEX: 20D +CONSTANT: ALUT_ERROR_IO_ERROR HEX: 20E +CONSTANT: ALUT_ERROR_UNSUPPORTED_FILE_TYPE HEX: 20F +CONSTANT: ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE HEX: 210 +CONSTANT: ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA HEX: 211 +CONSTANT: ALUT_WAVEFORM_SINE HEX: 100 +CONSTANT: ALUT_WAVEFORM_SQUARE HEX: 101 +CONSTANT: ALUT_WAVEFORM_SAWTOOTH HEX: 102 +CONSTANT: ALUT_WAVEFORM_WHITENOISE HEX: 103 +CONSTANT: ALUT_WAVEFORM_IMPULSE HEX: 104 +CONSTANT: ALUT_LOADER_BUFFER HEX: 300 +CONSTANT: ALUT_LOADER_MEMORY HEX: 301 + +FUNCTION: ALboolean alutInit ( int* argcp, char** argv ) ; +FUNCTION: ALboolean alutInitWithoutContext ( int* argcp, char** argv ) ; +FUNCTION: ALboolean alutExit ( ) ; +FUNCTION: ALenum alutGetError ( ) ; +FUNCTION: char* alutGetErrorString ( ALenum error ) ; +FUNCTION: ALuint alutCreateBufferFromFile ( char* fileName ) ; +FUNCTION: ALuint alutCreateBufferFromFileImage ( void* data, ALsizei length ) ; +FUNCTION: ALuint alutCreateBufferHelloWorld ( ) ; +FUNCTION: ALuint alutCreateBufferWaveform ( ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration ) ; +FUNCTION: void* alutLoadMemoryFromFile ( char* fileName, ALenum* format, ALsizei* size, ALfloat* frequency ) ; +FUNCTION: void* alutLoadMemoryFromFileImage ( void* data, ALsizei length, ALenum* format, ALsizei* size, ALfloat* frequency ) ; +FUNCTION: void* alutLoadMemoryHelloWorld ( ALenum* format, ALsizei* size, ALfloat* frequency ) ; +FUNCTION: void* alutLoadMemoryWaveform ( ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration, ALenum* format, ALsizei* size, ALfloat* freq ) ; +FUNCTION: char* alutGetMIMETypes ( ALenum loader ) ; +FUNCTION: ALint alutGetMajorVersion ( ) ; +FUNCTION: ALint alutGetMinorVersion ( ) ; +FUNCTION: ALboolean alutSleep ( ALfloat duration ) ; + +FUNCTION: void alutUnloadWAV ( ALenum format, void* data, ALsizei size, ALsizei frequency ) ; + +SYMBOL: init + +: init-openal ( -- ) + init get-global expired? [ + f f alutInit 0 = [ "Could not initialize OpenAL" throw ] when + 1337 init set-global + ] when ; + +: exit-openal ( -- ) + init get-global expired? [ + alutExit 0 = [ "Could not close OpenAL" throw ] when + f init set-global + ] unless ; + +: create-buffer-from-file ( filename -- buffer ) + alutCreateBufferFromFile dup AL_NONE = [ + "create-buffer-from-file failed" throw + ] when ; + +os macosx? "openal.alut.macosx" "openal.alut.other" ? require + +: create-buffer-from-wav ( filename -- buffer ) + gen-buffer dup rot load-wav-file + [ alBufferData ] 4 nkeep alutUnloadWAV ; + +: check-error ( -- ) + alGetError dup ALUT_ERROR_NO_ERROR = [ + drop + ] [ + alGetString throw + ] if ; + diff --git a/extra/openal/example/example.factor b/extra/openal/example/example.factor index 7789ee6e0a..54ce402957 100755 --- a/extra/openal/example/example.factor +++ b/extra/openal/example/example.factor @@ -1,33 +1,33 @@ -! Copyright (C) 2007 Chris Double. -! See http://factorcode.org/license.txt for BSD license. -USING: calendar kernel openal openal.alut sequences threads ; -IN: openal.example - -: play-hello ( -- ) - init-openal - 1 gen-sources - first dup AL_BUFFER alutCreateBufferHelloWorld set-source-param - source-play - 1000 milliseconds sleep ; - -: (play-file) ( source -- ) - 100 milliseconds sleep - dup source-playing? [ (play-file) ] [ drop ] if ; - -: play-file ( filename -- ) - init-openal - create-buffer-from-file - 1 gen-sources - first dup [ AL_BUFFER rot set-source-param ] dip - dup source-play - check-error - (play-file) ; - -: play-wav ( filename -- ) - init-openal - create-buffer-from-wav - 1 gen-sources - first dup [ AL_BUFFER rot set-source-param ] dip - dup source-play - check-error - (play-file) ; +! Copyright (C) 2007 Chris Double. +! See http://factorcode.org/license.txt for BSD license. +USING: calendar kernel openal openal.alut sequences threads ; +IN: openal.example + +: play-hello ( -- ) + init-openal + 1 gen-sources + first dup AL_BUFFER alutCreateBufferHelloWorld set-source-param + source-play + 1000 milliseconds sleep ; + +: (play-file) ( source -- ) + 100 milliseconds sleep + dup source-playing? [ (play-file) ] [ drop ] if ; + +: play-file ( filename -- ) + init-openal + create-buffer-from-file + 1 gen-sources + first dup [ AL_BUFFER rot set-source-param ] dip + dup source-play + check-error + (play-file) ; + +: play-wav ( filename -- ) + init-openal + create-buffer-from-wav + 1 gen-sources + first dup [ AL_BUFFER rot set-source-param ] dip + dup source-play + check-error + (play-file) ; From 30b586ef5fd035bc5d681cf7a0e14a952a3407b9 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sat, 20 Feb 2010 00:24:37 -0800 Subject: [PATCH 118/713] Merge up --- .../mailboxes/mailboxes-tests.factor | 108 +++++----- basis/concurrency/mailboxes/mailboxes.factor | 188 +++++++++--------- basis/concurrency/promises/promises.factor | 54 ++--- 3 files changed, 175 insertions(+), 175 deletions(-) diff --git a/basis/concurrency/mailboxes/mailboxes-tests.factor b/basis/concurrency/mailboxes/mailboxes-tests.factor index 3435a01455..87a4c3cdba 100644 --- a/basis/concurrency/mailboxes/mailboxes-tests.factor +++ b/basis/concurrency/mailboxes/mailboxes-tests.factor @@ -1,54 +1,54 @@ -USING: concurrency.mailboxes concurrency.count-downs concurrency.conditions -vectors sequences threads tools.test math kernel strings namespaces -continuations calendar destructors ; -IN: concurrency.mailboxes.tests - -{ 1 1 } [ [ integer? ] mailbox-get? ] must-infer-as - -[ V{ 1 2 3 } ] [ - 0 - - [ mailbox-get swap push ] in-thread - [ mailbox-get swap push ] in-thread - [ mailbox-get swap push ] in-thread - 1 over mailbox-put - 2 over mailbox-put - 3 swap mailbox-put -] unit-test - -[ V{ 1 2 3 } ] [ - 0 - - [ [ integer? ] mailbox-get? swap push ] in-thread - [ [ integer? ] mailbox-get? swap push ] in-thread - [ [ integer? ] mailbox-get? swap push ] in-thread - 1 over mailbox-put - 2 over mailbox-put - 3 swap mailbox-put -] unit-test - -[ V{ 1 "junk" 3 "junk2" } [ 456 ] ] [ - 0 - - [ [ integer? ] mailbox-get? swap push ] in-thread - [ [ integer? ] mailbox-get? swap push ] in-thread - [ [ string? ] mailbox-get? swap push ] in-thread - [ [ string? ] mailbox-get? swap push ] in-thread - 1 over mailbox-put - "junk" over mailbox-put - [ 456 ] over mailbox-put - 3 over mailbox-put - "junk2" over mailbox-put - mailbox-get -] unit-test - -[ { "foo" "bar" } ] [ - - "foo" over mailbox-put - "bar" over mailbox-put - mailbox-get-all -] unit-test - -[ - 1 seconds mailbox-get-timeout -] [ wait-timeout? ] must-fail-with +USING: concurrency.mailboxes concurrency.count-downs concurrency.conditions +vectors sequences threads tools.test math kernel strings namespaces +continuations calendar destructors ; +IN: concurrency.mailboxes.tests + +{ 1 1 } [ [ integer? ] mailbox-get? ] must-infer-as + +[ V{ 1 2 3 } ] [ + 0 + + [ mailbox-get swap push ] in-thread + [ mailbox-get swap push ] in-thread + [ mailbox-get swap push ] in-thread + 1 over mailbox-put + 2 over mailbox-put + 3 swap mailbox-put +] unit-test + +[ V{ 1 2 3 } ] [ + 0 + + [ [ integer? ] mailbox-get? swap push ] in-thread + [ [ integer? ] mailbox-get? swap push ] in-thread + [ [ integer? ] mailbox-get? swap push ] in-thread + 1 over mailbox-put + 2 over mailbox-put + 3 swap mailbox-put +] unit-test + +[ V{ 1 "junk" 3 "junk2" } [ 456 ] ] [ + 0 + + [ [ integer? ] mailbox-get? swap push ] in-thread + [ [ integer? ] mailbox-get? swap push ] in-thread + [ [ string? ] mailbox-get? swap push ] in-thread + [ [ string? ] mailbox-get? swap push ] in-thread + 1 over mailbox-put + "junk" over mailbox-put + [ 456 ] over mailbox-put + 3 over mailbox-put + "junk2" over mailbox-put + mailbox-get +] unit-test + +[ { "foo" "bar" } ] [ + + "foo" over mailbox-put + "bar" over mailbox-put + mailbox-get-all +] unit-test + +[ + 1 seconds mailbox-get-timeout +] [ wait-timeout? ] must-fail-with diff --git a/basis/concurrency/mailboxes/mailboxes.factor b/basis/concurrency/mailboxes/mailboxes.factor index 06da3b34a6..221a5a1fa3 100644 --- a/basis/concurrency/mailboxes/mailboxes.factor +++ b/basis/concurrency/mailboxes/mailboxes.factor @@ -1,94 +1,94 @@ -! Copyright (C) 2005, 2010 Chris Double, Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: dlists deques threads sequences continuations namespaces -math quotations words kernel arrays assocs init system -concurrency.conditions accessors debugger debugger.threads -locals fry ; -IN: concurrency.mailboxes - -TUPLE: mailbox threads data ; - -: ( -- mailbox ) - mailbox new - >>threads - >>data ; - -: mailbox-empty? ( mailbox -- bool ) - data>> deque-empty? ; - -: mailbox-put ( obj mailbox -- ) - [ data>> push-front ] - [ threads>> notify-all ] bi yield ; - -: wait-for-mailbox ( mailbox timeout -- ) - [ threads>> ] dip "mailbox" wait ; - -:: block-unless-pred ( mailbox timeout pred: ( message -- ? ) -- ) - mailbox data>> pred dlist-any? [ - mailbox timeout wait-for-mailbox - mailbox timeout pred block-unless-pred - ] unless ; inline recursive - -: block-if-empty ( mailbox timeout -- mailbox ) - over mailbox-empty? [ - 2dup wait-for-mailbox block-if-empty - ] [ - drop - ] if ; - -: mailbox-peek ( mailbox -- obj ) - data>> peek-back ; - -: mailbox-get-timeout ( mailbox timeout -- obj ) - block-if-empty data>> pop-back ; - -: mailbox-get ( mailbox -- obj ) - f mailbox-get-timeout ; - -: mailbox-get-all-timeout ( mailbox timeout -- array ) - block-if-empty - [ dup mailbox-empty? not ] - [ dup data>> pop-back ] - produce nip ; - -: mailbox-get-all ( mailbox -- array ) - f mailbox-get-all-timeout ; - -: while-mailbox-empty ( mailbox quot -- ) - [ '[ _ mailbox-empty? ] ] dip while ; inline - -: mailbox-get-timeout? ( mailbox timeout pred -- obj ) - [ block-unless-pred ] - [ [ drop data>> ] dip delete-node-if ] - 3bi ; inline - -: mailbox-get? ( mailbox pred -- obj ) - f swap mailbox-get-timeout? ; inline - -: wait-for-close-timeout ( mailbox timeout -- ) - over disposed>> - [ 2drop ] [ 2dup wait-for-mailbox wait-for-close-timeout ] if ; - -: wait-for-close ( mailbox -- ) - f wait-for-close-timeout ; - -TUPLE: linked-error error thread ; - -M: linked-error error. - [ thread>> error-in-thread. ] [ error>> error. ] bi ; - -C: linked-error - -: ?linked ( message -- message ) - dup linked-error? [ rethrow ] when ; - -TUPLE: linked-thread < thread supervisor ; - -M: linked-thread error-in-thread - [ ] [ supervisor>> ] bi mailbox-put ; - -: ( quot name mailbox -- thread' ) - [ linked-thread new-thread ] dip >>supervisor ; - -: spawn-linked-to ( quot name mailbox -- thread ) - [ (spawn) ] keep ; +! Copyright (C) 2005, 2010 Chris Double, Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: dlists deques threads sequences continuations namespaces +math quotations words kernel arrays assocs init system +concurrency.conditions accessors debugger debugger.threads +locals fry ; +IN: concurrency.mailboxes + +TUPLE: mailbox threads data ; + +: ( -- mailbox ) + mailbox new + >>threads + >>data ; + +: mailbox-empty? ( mailbox -- bool ) + data>> deque-empty? ; + +: mailbox-put ( obj mailbox -- ) + [ data>> push-front ] + [ threads>> notify-all ] bi yield ; + +: wait-for-mailbox ( mailbox timeout -- ) + [ threads>> ] dip "mailbox" wait ; + +:: block-unless-pred ( mailbox timeout pred: ( message -- ? ) -- ) + mailbox data>> pred dlist-any? [ + mailbox timeout wait-for-mailbox + mailbox timeout pred block-unless-pred + ] unless ; inline recursive + +: block-if-empty ( mailbox timeout -- mailbox ) + over mailbox-empty? [ + 2dup wait-for-mailbox block-if-empty + ] [ + drop + ] if ; + +: mailbox-peek ( mailbox -- obj ) + data>> peek-back ; + +: mailbox-get-timeout ( mailbox timeout -- obj ) + block-if-empty data>> pop-back ; + +: mailbox-get ( mailbox -- obj ) + f mailbox-get-timeout ; + +: mailbox-get-all-timeout ( mailbox timeout -- array ) + block-if-empty + [ dup mailbox-empty? not ] + [ dup data>> pop-back ] + produce nip ; + +: mailbox-get-all ( mailbox -- array ) + f mailbox-get-all-timeout ; + +: while-mailbox-empty ( mailbox quot -- ) + [ '[ _ mailbox-empty? ] ] dip while ; inline + +: mailbox-get-timeout? ( mailbox timeout pred -- obj ) + [ block-unless-pred ] + [ [ drop data>> ] dip delete-node-if ] + 3bi ; inline + +: mailbox-get? ( mailbox pred -- obj ) + f swap mailbox-get-timeout? ; inline + +: wait-for-close-timeout ( mailbox timeout -- ) + over disposed>> + [ 2drop ] [ 2dup wait-for-mailbox wait-for-close-timeout ] if ; + +: wait-for-close ( mailbox -- ) + f wait-for-close-timeout ; + +TUPLE: linked-error error thread ; + +M: linked-error error. + [ thread>> error-in-thread. ] [ error>> error. ] bi ; + +C: linked-error + +: ?linked ( message -- message ) + dup linked-error? [ rethrow ] when ; + +TUPLE: linked-thread < thread supervisor ; + +M: linked-thread error-in-thread + [ ] [ supervisor>> ] bi mailbox-put ; + +: ( quot name mailbox -- thread' ) + [ linked-thread new-thread ] dip >>supervisor ; + +: spawn-linked-to ( quot name mailbox -- thread ) + [ (spawn) ] keep ; diff --git a/basis/concurrency/promises/promises.factor b/basis/concurrency/promises/promises.factor index 3381bcc00b..4d6439cf30 100644 --- a/basis/concurrency/promises/promises.factor +++ b/basis/concurrency/promises/promises.factor @@ -1,27 +1,27 @@ -! Copyright (C) 2005, 2008 Chris Double, Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors concurrency.mailboxes kernel continuations ; -IN: concurrency.promises - -TUPLE: promise mailbox ; - -: ( -- promise ) - promise boa ; - -: promise-fulfilled? ( promise -- ? ) - mailbox>> mailbox-empty? not ; - -ERROR: promise-already-fulfilled promise ; - -: fulfill ( value promise -- ) - dup promise-fulfilled? [ - promise-already-fulfilled - ] [ - mailbox>> mailbox-put - ] if ; - -: ?promise-timeout ( promise timeout -- result ) - [ mailbox>> ] dip block-if-empty mailbox-peek ; - -: ?promise ( promise -- result ) - f ?promise-timeout ; +! Copyright (C) 2005, 2008 Chris Double, Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors concurrency.mailboxes kernel continuations ; +IN: concurrency.promises + +TUPLE: promise mailbox ; + +: ( -- promise ) + promise boa ; + +: promise-fulfilled? ( promise -- ? ) + mailbox>> mailbox-empty? not ; + +ERROR: promise-already-fulfilled promise ; + +: fulfill ( value promise -- ) + dup promise-fulfilled? [ + promise-already-fulfilled + ] [ + mailbox>> mailbox-put + ] if ; + +: ?promise-timeout ( promise timeout -- result ) + [ mailbox>> ] dip block-if-empty mailbox-peek ; + +: ?promise ( promise -- result ) + f ?promise-timeout ; From b25e945c746e357b54107fa6212184555dd83f94 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sat, 20 Feb 2010 03:02:56 -0800 Subject: [PATCH 119/713] The return values in the stack effects of FUNCTION: words were c-types rather than strings. This was causing scaffold-help to fail on vocabularies with FUNCTION:. --- basis/alien/parser/parser.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index 0cf495fd25..d706446799 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -72,10 +72,10 @@ IN: alien.parser : function-quot ( return library function types -- quot ) '[ _ _ _ _ alien-invoke ] ; -:: make-function ( return! library function! parameters -- word quot effect ) - return function normalize-c-arg function! return! +:: make-function ( return library function parameters -- word quot effect ) + return function normalize-c-arg :> ( return-c-type function ) function create-in dup reset-generic - return library function + return-c-type library function parameters return parse-arglist [ function-quot ] dip ; : parse-arg-tokens ( -- tokens ) From ea4d261a45ba7c24bf2ca19d21c73a5fda13b22b Mon Sep 17 00:00:00 2001 From: William Schlieper Date: Sat, 20 Feb 2010 08:09:49 -0500 Subject: [PATCH 120/713] Added rudimentary x11 support in game.input --- basis/game/input/input.factor | 1 + basis/game/input/x11/x11.factor | 67 +++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 basis/game/input/x11/x11.factor diff --git a/basis/game/input/input.factor b/basis/game/input/input.factor index a2afbe92a3..923d5d6107 100644 --- a/basis/game/input/input.factor +++ b/basis/game/input/input.factor @@ -93,5 +93,6 @@ M: mouse-state clone { { [ os windows? ] [ "game.input.xinput" require ] } { [ os macosx? ] [ "game.input.iokit" require ] } + { [ os linux? ] [ "game.input.x11" require ] } { [ t ] [ ] } } cond diff --git a/basis/game/input/x11/x11.factor b/basis/game/input/x11/x11.factor new file mode 100644 index 0000000000..c54fc4be5d --- /dev/null +++ b/basis/game/input/x11/x11.factor @@ -0,0 +1,67 @@ +USING: alien.c-types alien.syntax arrays bit-arrays game.input +kernel namespaces sequences x11 x11.xlib ; +IN: game.input.x11 + +SINGLETON: x11-game-input-backend + +x11-game-input-backend game-input-backend set-global + +LIBRARY: xlib +FUNCTION: int XQueryKeymap ( Display* display, char[32] keys_return ) ; + +CONSTANT: x>hid-bit-order { + 0 0 0 0 0 0 0 0 + 0 41 30 31 32 33 34 35 + 36 37 38 39 45 46 42 43 + 20 26 8 21 23 28 24 12 + 18 19 47 48 40 224 4 22 + 7 9 10 11 13 14 15 51 + 52 53 225 49 29 27 6 25 + 5 17 16 54 55 56 229 85 + 226 44 57 58 59 60 61 62 + 63 64 65 66 67 83 71 95 + 96 97 86 92 93 94 87 91 + 90 89 99 0 0 0 68 69 + 0 0 0 0 0 0 0 88 + 228 84 70 0 0 74 82 75 + 80 79 77 81 78 73 76 127 + 129 128 102 103 0 72 0 0 + 0 0 227 231 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 +} + +M: x11-game-input-backend (open-game-input) ; ! assume X was already started for now +M: x11-game-input-backend (close-game-input) ; ! let someone else stop X +M: x11-game-input-backend (reset-game-input) ; ! nothing to reset at this point + +! No controller support yet--if this works, I shouldn't even need to define the other methods +M: x11-game-input-backend get-controllers f ; + + +: x-bits>hid-bits ( bit-array -- bit-array ) + 256 iota [ 2array ] 2map [ first ] filter [ second ] map + x>hid-bit-order [ nth ] with map + ?{ } swap [ t swap pick set-nth ] each ; + +M: x11-game-input-backend read-keyboard + dpy get 256 [ XQueryKeymap drop ] keep + x-bits>hid-bits keyboard-state boa ; + +M: x11-game-input-backend read-mouse + 0 0 0 0 ?{ f f f } mouse-state boa ; + +M: x11-game-input-backend reset-mouse ; \ No newline at end of file From 47666f0049f045177956c43693ec0659b363b706 Mon Sep 17 00:00:00 2001 From: William Schlieper Date: Sat, 20 Feb 2010 08:35:02 -0500 Subject: [PATCH 121/713] Fixed a bug in the linux version of game.input --- basis/game/input/linux/linux.factor | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/basis/game/input/linux/linux.factor b/basis/game/input/linux/linux.factor index b307835d70..b6f3d43956 100644 --- a/basis/game/input/linux/linux.factor +++ b/basis/game/input/linux/linux.factor @@ -4,6 +4,9 @@ USING: alien.c-types alien.syntax arrays kernel game.input namespaces classes bit-arrays sequences vectors x11 x11.xlib ; IN: game.input.linux +LIBRARY: xlib +FUNCTION: int XQueryKeymap ( Display* display, char[32] keys_return ) ; + SINGLETON: linux-game-input-backend linux-game-input-backend game-input-backend set-global @@ -74,9 +77,9 @@ CONSTANT: x>hid-bit-order { } : x-bits>hid-bits ( bit-array -- bit-array ) - 256 iota [ 2array ] 2map [ first ] filter [ second ] map - x>hid-bit-order [ nth ] with map - ?{ } swap [ t swap pick set-nth ] each ; + 256 iota [ 2array ] { } 2map-as [ first ] filter [ second ] map + x>hid-bit-order [ nth ] curry map + 256 swap [ t swap pick set-nth ] each ; M: linux-game-input-backend read-keyboard dpy get 256 [ XQueryKeymap drop ] keep From f71e22eda57f6fccba98957b482a9a17d956fffd Mon Sep 17 00:00:00 2001 From: William Schlieper Date: Sat, 20 Feb 2010 09:36:58 -0500 Subject: [PATCH 122/713] Fixed ridiculously stupid error in Linux game.input library --- basis/game/input/linux/linux.factor | 65 +++++++++++++++-------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/basis/game/input/linux/linux.factor b/basis/game/input/linux/linux.factor index b6f3d43956..07889c8298 100644 --- a/basis/game/input/linux/linux.factor +++ b/basis/game/input/linux/linux.factor @@ -42,38 +42,39 @@ M: linux-game-input-backend vibrate-controller 3drop ; CONSTANT: x>hid-bit-order { - 0 0 0 0 0 0 0 0 - 0 41 30 31 32 33 34 35 - 36 37 38 39 45 46 42 43 - 20 26 8 21 23 28 24 12 - 18 19 47 48 40 224 4 22 - 7 9 10 11 13 14 15 51 - 52 53 225 49 29 27 6 25 - 5 17 16 54 55 56 229 85 - 226 44 57 58 59 60 61 62 - 63 64 65 66 67 83 71 95 - 96 97 86 92 93 94 87 91 - 90 89 99 0 0 0 68 69 - 0 0 0 0 0 0 0 88 - 228 84 70 0 0 74 82 75 - 80 79 77 81 78 73 76 127 - 129 128 102 103 0 72 0 0 - 0 0 227 231 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 +0 41 30 31 32 33 34 35 +36 37 38 39 45 46 42 43 +20 26 8 21 23 28 24 12 +18 19 47 48 40 224 4 22 +7 9 10 11 13 14 15 51 +52 53 225 49 29 27 6 25 +5 17 16 54 55 56 229 85 +226 44 57 58 59 60 61 62 +63 64 65 66 67 83 71 95 +96 97 86 92 93 94 87 91 +90 89 98 99 0 0 0 68 +69 0 0 0 0 0 0 0 +88 228 84 70 0 0 74 82 +75 80 79 77 81 78 73 76 +127 129 128 102 103 0 72 0 +0 0 0 227 231 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 } : x-bits>hid-bits ( bit-array -- bit-array ) From d0f4239d58ba61b8ca74bd094bbb2bcd698cec7c Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Sat, 20 Feb 2010 09:15:05 -0600 Subject: [PATCH 123/713] Solution to Project Euler problem 70 --- extra/project-euler/049/049.factor | 14 +---- extra/project-euler/070/070-tests.factor | 4 ++ extra/project-euler/070/070.factor | 67 ++++++++++++++++++++++++ extra/project-euler/common/common.factor | 24 ++++++--- 4 files changed, 91 insertions(+), 18 deletions(-) create mode 100644 extra/project-euler/070/070-tests.factor create mode 100644 extra/project-euler/070/070.factor diff --git a/extra/project-euler/049/049.factor b/extra/project-euler/049/049.factor index 8b6f635ee4..08244ea023 100644 --- a/extra/project-euler/049/049.factor +++ b/extra/project-euler/049/049.factor @@ -1,7 +1,7 @@ ! Copyright (c) 2009 Aaron Schaefer. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays byte-arrays fry hints kernel math math.combinatorics - math.functions math.parser math.primes project-euler.common sequences sets ; +USING: arrays byte-arrays fry kernel math math.combinatorics math.functions + math.parser math.primes project-euler.common sequences sets ; IN: project-euler.049 ! http://projecteuler.net/index.php?section=problems&id=49 @@ -25,16 +25,6 @@ IN: project-euler.049 [ - '[ 10 /mod _ [ 1 + ] change-nth dup 0 > ] loop drop - ] keep ; - -HINTS: count-digits fixnum ; - -: permutations? ( n m -- ? ) - [ count-digits ] bi@ = ; - : collect-permutations ( seq -- seq ) [ V{ } clone ] [ dup ] bi* [ dupd '[ _ permutations? ] filter diff --git a/extra/project-euler/070/070-tests.factor b/extra/project-euler/070/070-tests.factor new file mode 100644 index 0000000000..d402b16902 --- /dev/null +++ b/extra/project-euler/070/070-tests.factor @@ -0,0 +1,4 @@ +USING: project-euler.070 tools.test ; +IN: project-euler.070.tests + +[ 8319823 ] [ euler070 ] unit-test diff --git a/extra/project-euler/070/070.factor b/extra/project-euler/070/070.factor new file mode 100644 index 0000000000..eed179851e --- /dev/null +++ b/extra/project-euler/070/070.factor @@ -0,0 +1,67 @@ +! Copyright (c) 2010 Aaron Schaefer. All rights reserved. +! The contents of this file are licensed under the Simplified BSD License +! A copy of the license is available at http://factorcode.org/license.txt +USING: arrays assocs combinators.short-circuit kernel math math.combinatorics + math.functions math.primes math.ranges project-euler.common sequences ; +IN: project-euler.070 + +! http://projecteuler.net/index.php?section=problems&id=70 + +! DESCRIPTION +! ----------- + +! Euler's Totient function, φ(n) [sometimes called the phi function], is used +! to determine the number of positive numbers less than or equal to n which are +! relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all less +! than nine and relatively prime to nine, φ(9)=6. The number 1 is considered to +! be relatively prime to every positive number, so φ(1)=1. + +! Interestingly, φ(87109)=79180, and it can be seen that 87109 is a permutation +! of 79180. + +! Find the value of n, 1 < n < 10^(7), for which φ(n) is a permutation of n and +! the ratio n/φ(n) produces a minimum. + + +! SOLUTION +! -------- + +! For n/φ(n) to be minimised, φ(n) must be as close to n as possible; that is, +! we want to maximise φ(n). The minimal solution for n/φ(n) would be if n was +! prime giving n/(n-1) but since n-1 never is a permutation of n it cannot be +! prime. + +! The next best thing would be if n only consisted of 2 prime factors close to +! (in this case) sqrt(10000000). Hence n = p1*p2 and we only need to search +! through a list of known prime pairs. In addition: + +! φ(p1*p2) = p1*p2*(1-1/p1)(1-1/p2) = (p1-1)(p2-1) + +! ...so we can compute φ(n) more efficiently. + +integer 1000 [ - ] [ + ] 2bi primes-between ; inline + +: n-and-phi ( seq -- seq' ) + #! ( seq = { p1, p2 } -- seq' = { n, φ(n) } ) + [ product ] [ [ 1 - ] map product ] bi 2array ; + +: fit-requirements? ( seq -- ? ) + first2 { [ drop 7 10^ < ] [ permutations? ] } 2&& ; + +: minimum-ratio ( seq -- n ) + [ [ first2 / ] map [ infimum ] keep index ] keep nth first ; + +PRIVATE> + +: euler070 ( -- answer ) + likely-prime-factors 2 all-combinations [ n-and-phi ] map + [ fit-requirements? ] filter minimum-ratio ; + +! [ euler070 ] 100 ave-time +! 379 ms ave run time - 1.15 SD (100 trials) + +SOLUTION: euler070 diff --git a/extra/project-euler/common/common.factor b/extra/project-euler/common/common.factor index 6995adcd6a..1f29ca0af5 100644 --- a/extra/project-euler/common/common.factor +++ b/extra/project-euler/common/common.factor @@ -1,10 +1,11 @@ ! Copyright (c) 2007-2010 Aaron Schaefer. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays kernel lists make math math.functions math.matrices - math.primes.miller-rabin math.order math.parser math.primes.factors - math.primes.lists math.ranges math.ratios namespaces parser prettyprint - quotations sequences sorting strings unicode.case vocabs vocabs.parser - words ; +! The contents of this file are licensed under the Simplified BSD License +! A copy of the license is available at http://factorcode.org/license.txt +USING: accessors arrays byte-arrays fry hints kernel lists make math + math.functions math.matrices math.order math.parser math.primes.factors + math.primes.lists math.primes.miller-rabin math.ranges math.ratios + namespaces parser prettyprint quotations sequences sorting strings + unicode.case vocabs vocabs.parser words ; IN: project-euler.common ! A collection of words used by more than one Project Euler solution @@ -25,6 +26,7 @@ IN: project-euler.common ! pentagonal? - #44, #45 ! penultimate - #69, #71 ! propagate-all - #18, #67 +! permutations? - #49, #70 ! sum-proper-divisors - #21 ! tau* - #12 ! [uad]-transform - #39, #75 @@ -38,6 +40,13 @@ IN: project-euler.common [ + '[ 10 /mod _ [ 1 + ] change-nth dup 0 > ] loop drop + ] keep ; + +HINTS: count-digits fixnum ; + : max-children ( seq -- seq ) [ dup length 1 - iota [ nth-pair max , ] with each ] { } make ; @@ -107,6 +116,9 @@ PRIVATE> reverse [ first dup ] [ rest ] bi [ propagate dup ] map nip reverse swap suffix ; +: permutations? ( n m -- ? ) + [ count-digits ] bi@ = ; + : sum-divisors ( n -- sum ) dup 4 < [ { 0 1 3 4 } nth ] [ (sum-divisors) ] if ; From 6cc9348dfab6f03628caaaf990e37ddefcc362b4 Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Sat, 20 Feb 2010 09:16:53 -0600 Subject: [PATCH 124/713] Add PE problem 70 to common project file --- extra/project-euler/project-euler.factor | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/extra/project-euler/project-euler.factor b/extra/project-euler/project-euler.factor index ce58e7009a..4131f41b1f 100644 --- a/extra/project-euler/project-euler.factor +++ b/extra/project-euler/project-euler.factor @@ -18,15 +18,15 @@ USING: definitions io io.files io.pathnames kernel math math.parser project-euler.053 project-euler.054 project-euler.055 project-euler.056 project-euler.057 project-euler.058 project-euler.059 project-euler.062 project-euler.063 project-euler.065 project-euler.067 project-euler.069 - project-euler.071 project-euler.072 project-euler.073 project-euler.074 - project-euler.075 project-euler.076 project-euler.079 project-euler.081 - project-euler.085 project-euler.089 project-euler.092 project-euler.097 - project-euler.099 project-euler.100 project-euler.102 project-euler.112 - project-euler.116 project-euler.117 project-euler.124 project-euler.134 - project-euler.148 project-euler.150 project-euler.151 project-euler.164 - project-euler.169 project-euler.173 project-euler.175 project-euler.186 - project-euler.188 project-euler.190 project-euler.203 project-euler.206 - project-euler.215 project-euler.255 ; + project-euler.070 project-euler.071 project-euler.072 project-euler.073 + project-euler.074 project-euler.075 project-euler.076 project-euler.079 + project-euler.081 project-euler.085 project-euler.089 project-euler.092 + project-euler.097 project-euler.099 project-euler.100 project-euler.102 + project-euler.112 project-euler.116 project-euler.117 project-euler.124 + project-euler.134 project-euler.148 project-euler.150 project-euler.151 + project-euler.164 project-euler.169 project-euler.173 project-euler.175 + project-euler.186 project-euler.188 project-euler.190 project-euler.203 + project-euler.206 project-euler.215 project-euler.255 ; IN: project-euler Date: Sat, 20 Feb 2010 11:20:21 -0600 Subject: [PATCH 125/713] clean up PE solution 255 --- extra/project-euler/255/255.factor | 102 +++++++++++++---------- extra/project-euler/common/common.factor | 3 + 2 files changed, 61 insertions(+), 44 deletions(-) diff --git a/extra/project-euler/255/255.factor b/extra/project-euler/255/255.factor index 57a5c5fec7..40bcce4b90 100644 --- a/extra/project-euler/255/255.factor +++ b/extra/project-euler/255/255.factor @@ -1,49 +1,64 @@ -! Copyright (C) 2009 Jon Harper. +! Copyright (c) 2009 Jon Harper. ! See http://factorcode.org/license.txt for BSD license. -USING: project-euler.common math kernel sequences math.functions math.ranges prettyprint io threads math.parser locals arrays namespaces ; +USING: arrays io kernel locals math math.functions math.parser math.ranges + namespaces prettyprint project-euler.common sequences threads ; IN: project-euler.255 ! http://projecteuler.net/index.php?section=problems&id=255 ! DESCRIPTION ! ----------- -! We define the rounded-square-root of a positive integer n as the square root of n rounded to the nearest integer. -! -! The following procedure (essentially Heron's method adapted to integer arithmetic) finds the rounded-square-root of n: -! -! Let d be the number of digits of the number n. -! If d is odd, set x_(0) = 2×10^((d-1)⁄2). -! If d is even, set x_(0) = 7×10^((d-2)⁄2). -! Repeat: -! -! until x_(k+1) = x_(k). -! + +! We define the rounded-square-root of a positive integer n as the square root +! of n rounded to the nearest integer. + +! The following procedure (essentially Heron's method adapted to integer +! arithmetic) finds the rounded-square-root of n: + +! Let d be the number of digits of the number n. +! If d is odd, set x_(0) = 2×10^((d-1)⁄2). +! If d is even, set x_(0) = 7×10^((d-2)⁄2). + +! Repeat: [see URL for figure ] + +! until x_(k+1) = x_(k). + ! As an example, let us find the rounded-square-root of n = 4321. ! n has 4 digits, so x_(0) = 7×10^((4-2)⁄2) = 70. -! -! Since x_(2) = x_(1), we stop here. -! So, after just two iterations, we have found that the rounded-square-root of 4321 is 66 (the actual square root is 65.7343137…). -! -! The number of iterations required when using this method is surprisingly low. -! For example, we can find the rounded-square-root of a 5-digit integer (10,000 ≤ n ≤ 99,999) with an average of 3.2102888889 iterations (the average value was rounded to 10 decimal places). -! -! Using the procedure described above, what is the average number of iterations required to find the rounded-square-root of a 14-digit number (10^(13) ≤ n < 10^(14))? -! Give your answer rounded to 10 decimal places. -! -! Note: The symbols ⌊x⌋ and ⌈x⌉ represent the floor function and ceiling function respectively. -! - -: euler255 ( -- answer ) - 13 14 (euler255) round-to-10-decimals ; +: euler255 ( -- answer ) + 13 14 (euler255) 10 nth-place ; + +! [ euler255 ] gc time +! Running time: 37.468911341 seconds SOLUTION: euler255 - diff --git a/extra/project-euler/common/common.factor b/extra/project-euler/common/common.factor index 1f29ca0af5..48520ef565 100644 --- a/extra/project-euler/common/common.factor +++ b/extra/project-euler/common/common.factor @@ -92,6 +92,9 @@ PRIVATE> [ [ 10 * ] [ 1 + ] bi* ] while 2nip ] if-zero ; +: nth-place ( x n -- y ) + 10^ [ * round >integer ] keep /f ; + : nth-prime ( n -- n ) 1 - lprimes lnth ; From 83d6f7fc6f746a0d7289eda78e5224133f8e6696 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 20 Feb 2010 09:45:42 -0800 Subject: [PATCH 126/713] if you're going to support shift-del, you should also support shift-ins and ctrl-ins --- basis/ui/gadgets/worlds/worlds.factor | 2 ++ 1 file changed, 2 insertions(+) diff --git a/basis/ui/gadgets/worlds/worlds.factor b/basis/ui/gadgets/worlds/worlds.factor index 526fc77c57..eea2933b04 100644 --- a/basis/ui/gadgets/worlds/worlds.factor +++ b/basis/ui/gadgets/worlds/worlds.factor @@ -231,6 +231,8 @@ action-gestures [ ] H{ } assoc-map-as H{ { T{ key-down f { S+ } "DELETE" } [ \ cut-action send-action ] } + { T{ key-down f { S+ } "INSERT" } [ \ paste-action send-action ] } + { T{ key-down f { C+ } "INSERT" } [ \ copy-action send-action ] } { T{ button-down f { C+ } 1 } [ drop T{ button-down f f 3 } button-gesture ] } { T{ button-down f { A+ } 1 } [ drop T{ button-down f f 2 } button-gesture ] } { T{ button-down f { M+ } 1 } [ drop T{ button-down f f 2 } button-gesture ] } From d6731085183bef23d926f6b70ddc8fb504a08945 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 20 Feb 2010 10:10:02 -0800 Subject: [PATCH 127/713] game.input: add a convenient "buttons-delta" word to convert two key/button state samples into pressed/released values --- basis/game/input/input-docs.factor | 33 +++++++++++++++++++++++++++-- basis/game/input/input-tests.factor | 11 ++++++++++ basis/game/input/input.factor | 15 +++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/basis/game/input/input-docs.factor b/basis/game/input/input-docs.factor index 29b74ff570..1ea5dcc650 100644 --- a/basis/game/input/input-docs.factor +++ b/basis/game/input/input-docs.factor @@ -32,6 +32,12 @@ ARTICLE: "game-input" "Game controller input" controller-state keyboard-state mouse-state +} +"Convenience functions are provided to convert a pair of key or button state sequences into a sequence of " { $link pressed } "/" { $link released } " deltas:" +{ $subsections + button-delta + buttons-delta + buttons-delta-as } ; HELP: open-game-input @@ -136,7 +142,7 @@ HELP: controller-state { "A value of " { $link f } " in any slot (besides the elements of " { $snippet "buttons" } ") indicates that the corresponding element is not present on the device." } } } ; HELP: keyboard-state -{ $class-description "The " { $link read-keyboard } " word returns objects of this class. The " { $snippet "keys" } " slot of a " { $snippet "keyboard-state" } " object contains a " { $link sequence } " of 256 members representing the state of the keys on the keyboard. Each element is a boolean value indicating whether the corresponding key is pressed. The sequence is indexed by scancode as defined under usage page 7 of the USB HID standard. Named scancode constants are provided in the " { $vocab-link "game.input.scancodes" } " vocabulary." } +{ $class-description "The " { $link read-keyboard } " word returns objects of this class. The " { $snippet "keys" } " slot of a " { $snippet "keyboard-state" } " object contains a " { $link sequence } " of 256 members representing the state of the keys on the keyboard. Each element is a boolean value indicating whether the corresponding key is pressed. The sequence is indexed by scancode as defined by the USB HID standard. Named scancode constants are provided in the " { $vocab-link "game.input.scancodes" } " vocabulary." } { $warning "The scancodes used to index " { $snippet "keyboard-state" } " objects correspond to physical key positions on the keyboard--they are unaffected by keymaps, modifier keys, or other operating environment postprocessing. The face value of the constants in " { $vocab-link "game.input.scancodes" } " do not necessarily correspond to what the user expects the key to type. Because of this, " { $link read-keyboard } " should not be used for text entry purposes. The Factor UI's standard gesture mechanism should be used in cases where the logical meaning of keypresses is needed; see " { $link "keyboard-gestures" } "." } ; HELP: mouse-state @@ -151,7 +157,30 @@ HELP: mouse-state "Mouse movement is recorded relative to when the game input interface was opened with " { $link open-game-input } " or the mouse state is reset with " { $link reset-mouse } "." } ; - { keyboard-state read-keyboard } related-words +HELP: button-delta +{ $values { "old?" boolean } { "new?" boolean } { "delta" { $link pressed } ", " { $link released } ", or " { $link POSTPONE: f } } } +{ $description "Outputs a symbol representing the change in a key or button's state given a \"before\" and \"after\" sample of its state. Outputs " { $link pressed } " if " { $snippet "old?" } " is false and " { $snippet "new?" } " is true, " { $link released } " if " { $snippet "old?" } " is true and " { $snippet "new?" } " is false, or " { $link POSTPONE: f } " if the two inputs have the same boolean value." } ; + +HELP: buttons-delta +{ $values { "old-buttons" sequence } { "new-buttons" sequence } { "delta" "an array of " { $link pressed } ", " { $link released } ", or " { $link POSTPONE: f } } } +{ $description "Outputs an array of symbols representing the change in a set of keys or buttons' states given \"before\" and \"after\" samples of their state. For each corresponding pair of values in the two input sequences, outputs " { $link pressed } " if " { $snippet "old-buttons" } " contains a false and " { $snippet "new-buttons" } " a true value, " { $link released } " if " { $snippet "old-buttons" } " contains true and " { $snippet "new-buttons" } " false, or " { $link POSTPONE: f } " if the two elements have the same boolean value." +$nl +"This word can be used with two samples of a " { $link keyboard-state } "'s " { $snippet "keys" } " slot or of a " { $link mouse-state } "'s or " { $link controller-state } "'s " { $snippet "buttons" } " slot to convert the button states into pressed/released values. Remember to " { $link clone } " state objects to record snapshots of their state." } ; + +HELP: buttons-delta-as +{ $values { "old-buttons" sequence } { "new-buttons" sequence } { "exemplar" sequence } { "delta" "a sequence of " { $link pressed } ", " { $link released } ", or " { $link POSTPONE: f } } } +{ $description "Like " { $link buttons-delta } ", but returns a sequence matching the type of the " { $snippet "exemplar" } "." } ; + +{ button-delta buttons-delta buttons-delta-as } related-words + +HELP: pressed +{ $class-description "This symbol is returned by " { $link button-delta } " or " { $link buttons-delta } " to represent a button or key being pressed between two samples of its state." } ; + +HELP: released +{ $class-description "This symbol is returned by " { $link button-delta } " or " { $link buttons-delta } " to represent a button or key being released between two samples of its state." } ; + +{ pressed released } related-words + ABOUT: "game-input" diff --git a/basis/game/input/input-tests.factor b/basis/game/input/input-tests.factor index bd993bf811..923815328e 100644 --- a/basis/game/input/input-tests.factor +++ b/basis/game/input/input-tests.factor @@ -7,3 +7,14 @@ os { [ windows? ] [ macosx? ] } 1|| [ [ ] [ 1 seconds sleep ] unit-test [ ] [ close-game-input ] unit-test ] when + +[ f ] [ t t button-delta ] unit-test +[ pressed ] [ f t button-delta ] unit-test +[ released ] [ t f button-delta ] unit-test + +[ f ] [ 0.5 1.0 button-delta ] unit-test +[ pressed ] [ f 0.7 button-delta ] unit-test +[ released ] [ 0.2 f button-delta ] unit-test + +[ { pressed f f released } ] [ { f t f t } { t t f f } buttons-delta ] unit-test +[ V{ pressed f f released } ] [ { f t f t } { t t f f } V{ } buttons-delta-as ] unit-test diff --git a/basis/game/input/input.factor b/basis/game/input/input.factor index 8a269cd51a..f27e1f36d1 100644 --- a/basis/game/input/input.factor +++ b/basis/game/input/input.factor @@ -90,6 +90,21 @@ TUPLE: mouse-state dx dy scroll-dx scroll-dy buttons ; M: mouse-state clone call-next-method dup buttons>> clone >>buttons ; +SYMBOLS: pressed released ; + +: button-delta ( old? new? -- delta ) + { + { [ 2dup xor not ] [ 2drop f ] } + { [ dup not ] [ 2drop released ] } + { [ over not ] [ 2drop pressed ] } + } cond ; inline + +: buttons-delta-as ( old-buttons new-buttons exemplar -- delta ) + [ button-delta ] swap 2map-as ; inline + +: buttons-delta ( old-buttons new-buttons -- delta ) + { } buttons-delta-as ; inline + { { [ os windows? ] [ "game.input.xinput" require ] } { [ os macosx? ] [ "game.input.iokit" require ] } From 271afe3fde888c6ff0c7e79810fde7c02362b231 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 20 Feb 2010 10:47:03 -0800 Subject: [PATCH 128/713] game.loop: separate delegate into tick-delegate and draw-delegate --- extra/game/loop/loop-docs.factor | 34 ++++++++++++++++++++++++-------- extra/game/loop/loop.factor | 12 +++++++---- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/extra/game/loop/loop-docs.factor b/extra/game/loop/loop-docs.factor index cd8660e465..e4946d160c 100644 --- a/extra/game/loop/loop-docs.factor +++ b/extra/game/loop/loop-docs.factor @@ -11,7 +11,20 @@ HELP: { "tick-interval-micros" integer } { "delegate" "a " { $link "game.loop-delegates" } } { "loop" game-loop } } -{ $description "Constructs a new stopped " { $link game-loop } " object. When started, the game loop will call the " { $link tick* } " method on the " { $snippet "delegate" } " every " { $snippet "tick-interval-micros" } " microseconds, and " { $link draw* } " on the delegate as frequently as possible. The " { $link start-loop } " and " { $link stop-loop } " words start and stop the game loop." } ; +{ $description "Constructs a new stopped " { $link game-loop } " object. When started, the game loop will call the " { $link tick* } " method on the " { $snippet "delegate" } " every " { $snippet "tick-interval-micros" } " microseconds, and " { $link draw* } " on the same delegate object as frequently as possible. The " { $link start-loop } " and " { $link stop-loop } " words start and stop the game loop." +$nl +"To initialize the game loop with separate tick and draw delegates, use " { $link } "." } ; + +HELP: +{ $values + { "tick-interval-micros" integer } { "tick-delegate" "a " { $link "game.loop-delegates" } } { "draw-delegate" "a " { $link "game.loop-delegates" } } + { "loop" game-loop } +} +{ $description "Constructs a new stopped " { $link game-loop } " object. When started, the game loop will call the " { $link tick* } " method on the " { $snippet "tick-delegate" } " every " { $snippet "tick-interval-micros" } " microseconds, and " { $link draw* } " on the " { $snippet "draw-delegate" } " as frequently as possible. The " { $link start-loop } " and " { $link stop-loop } " words start and stop the game loop." +$nl +"The " { $link } " word provides a shorthand for initializing a game loop that uses the same object for the " { $snippet "tick-delegate" } " and " { $snippet "draw-delegate" } "." } ; + +{ } related-words HELP: benchmark-frames-per-second { $values @@ -25,7 +38,7 @@ HELP: benchmark-ticks-per-second { "loop" game-loop } { "n" float } } -{ $description "Returns the average number of times per second the game loop has called " { $link tick* } " on its delegate since the game loop was started with " { $link start-loop } " or since the benchmark counters have been reset with " { $link reset-loop-benchmark } "." } ; +{ $description "Returns the average number of times per second the game loop has called " { $link tick* } " on its tick delegate since the game loop was started with " { $link start-loop } " or since the benchmark counters have been reset with " { $link reset-loop-benchmark } "." } ; { reset-loop-benchmark benchmark-frames-per-second benchmark-ticks-per-second } related-words @@ -33,10 +46,12 @@ HELP: draw* { $values { "tick-slice" float } { "delegate" "a " { $link "game.loop-delegates" } } } -{ $description "This generic word is called by a " { $link game-loop } " on its " { $snippet "delegate" } " object in a tight loop while the game loop is running. The " { $snippet "tick-slice" } " value represents what fraction of the game loop's " { $snippet "tick-interval-micros" } " time period has passed since " { $link tick* } " was most recently called on the delegate." } ; +{ $description "This generic word is called by a " { $link game-loop } " on its " { $snippet "draw-delegate" } " object in a tight loop while the game loop is running. The " { $snippet "tick-slice" } " value represents what fraction of the game loop's " { $snippet "tick-interval-micros" } " time period has passed since " { $link tick* } " was most recently called on the " { $snippet "tick-delegate" } "." } ; HELP: game-loop -{ $class-description "Objects of the " { $snippet "game-loop" } " class manage game loops. See " { $link "game.loop" } " for an overview of the game loop library. To construct a game loop, use " { $link } ". To start and stop a game loop, use the " { $link start-loop } " and " { $link stop-loop } " words." } ; +{ $class-description "Objects of the " { $snippet "game-loop" } " class manage game loops. See " { $link "game.loop" } " for an overview of the game loop library. To construct a game loop, use " { $link } ". To start and stop a game loop, use the " { $link start-loop } " and " { $link stop-loop } " words." +$nl +"The " { $snippet "tick-delegate" } " and " { $snippet "draw-delegate" } " slots of a game loop object determine where the loop sends its " { $link tick* } " and " { $link draw* } " events. These slots can be changed while the game loop is running." } ; HELP: game-loop-error { $values @@ -68,23 +83,26 @@ HELP: tick* { $values { "delegate" "a " { $link "game.loop-delegates" } } } -{ $description "This generic word is called by a " { $link game-loop } " on its " { $snippet "delegate" } " object at regular intervals while the game loop is running. The game loop's " { $snippet "tick-interval-micros" } " attribute determines the number of microseconds between invocations of " { $snippet "tick*" } "." } ; +{ $description "This generic word is called by a " { $link game-loop } " on its " { $snippet "tick-delegate" } " object at regular intervals while the game loop is running. The game loop's " { $snippet "tick-interval-micros" } " attribute determines the number of microseconds between invocations of " { $snippet "tick*" } "." } ; { draw* tick* } related-words ARTICLE: "game.loop-delegates" "Game loop delegate" -"A " { $link game-loop } " object requires a " { $snippet "delegate" } " that implements the logic that controls the game. A game loop delegate can be any object that provides two methods for the following generic words:" +"A " { $link game-loop } " object requires a " { $snippet "tick-delegate" } " and " { $snippet "draw-delegate" } " that together implement the logic that controls the game. Both delegates can also be the same object. A game loop delegate can be any object that provides two methods for the following generic words:" { $subsections tick* draw* } -{ $snippet "tick*" } " will be called at a regular interval determined by the game loop's " { $snippet "tick-interval-micros" } " attribute. " { $snippet "draw*" } " will be invoked in a tight loop, updating as frequently as possible." ; +{ $snippet "tick*" } " will be called at a regular interval determined by the game loop's " { $snippet "tick-interval-micros" } " attribute on the tick delegate. " { $snippet "draw*" } " will be invoked on the draw delegate in a tight loop, updating as frequently as possible." +$nl +"It is possible to change the " { $snippet "tick-delegate" } " and " { $snippet "draw-delegate" } " slots of a game loop while it is running, for example, to use different delegates to control a game while it's in the menu, paused, or running the main game." ; ARTICLE: "game.loop" "Game loops" -"The " { $vocab-link "game.loop" } " vocabulary contains the implementation of a game loop. The game loop supports decoupled rendering and game logic timers; given a delegate object with methods on the " { $link tick* } " and " { $link draw* } " methods, the game loop will invoke the " { $snippet "tick*" } " method at regular intervals while invoking the " { $snippet "draw*" } " method as frequently as possible. Game loop objects must first be constructed:" +"The " { $vocab-link "game.loop" } " vocabulary contains the implementation of a game loop. The game loop supports decoupled rendering and game logic timers; given a \"tick delegate\" object with a method on the " { $link tick* } " generic and a \"draw delegate\" with a " { $link draw* } " method, the game loop will invoke the " { $snippet "tick*" } " method on the former at regular intervals while invoking the " { $snippet "draw*" } " method on the latter as frequently as possible. Game loop objects must first be constructed:" { $subsections "game.loop-delegates" + } "Once constructed, the game loop can be started and stopped:" { $subsections diff --git a/extra/game/loop/loop.factor b/extra/game/loop/loop.factor index afe011cb7b..9e46535b4e 100644 --- a/extra/game/loop/loop.factor +++ b/extra/game/loop/loop.factor @@ -6,7 +6,8 @@ IN: game.loop TUPLE: game-loop { tick-interval-micros integer read-only } - delegate + tick-delegate + draw-delegate { last-tick integer } thread { running? boolean } @@ -46,10 +47,10 @@ TUPLE: game-loop-error game-loop error ; : redraw ( loop -- ) [ 1 + ] change-frame-number - [ tick-slice ] [ delegate>> ] bi draw* ; + [ tick-slice ] [ draw-delegate>> ] bi draw* ; : tick ( loop -- ) - delegate>> tick* ; + tick-delegate>> tick* ; : increment-tick ( loop -- ) [ 1 + ] change-tick-number @@ -101,10 +102,13 @@ PRIVATE> f >>thread drop ; -: ( tick-interval-micros delegate -- loop ) +: ( tick-interval-micros tick-delegate draw-delegate -- loop ) system-micros f f 0 0 system-micros 0 0 game-loop boa ; +: ( tick-interval-micros delegate -- loop ) + dup ; inline + M: game-loop dispose stop-loop ; From 41afc11ccab73524a12b83704e7cb51210802d87 Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Sat, 20 Feb 2010 13:15:46 -0600 Subject: [PATCH 129/713] minor poker vocab cleanup --- extra/poker/poker-tests.factor | 3 +-- extra/poker/poker.factor | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/extra/poker/poker-tests.factor b/extra/poker/poker-tests.factor index fc10a13659..18f596c0e0 100644 --- a/extra/poker/poker-tests.factor +++ b/extra/poker/poker-tests.factor @@ -1,5 +1,4 @@ -USING: accessors kernel math math.order poker poker.private -tools.test ; +USING: accessors kernel math math.order poker poker.private tools.test ; IN: poker.tests [ 134236965 ] [ "KD" >ckf ] unit-test diff --git a/extra/poker/poker.factor b/extra/poker/poker.factor index 59f50509e4..b33b8e5710 100644 --- a/extra/poker/poker.factor +++ b/extra/poker/poker.factor @@ -1,5 +1,4 @@ -! Copyright (c) 2009 Aaron Schaefer. All rights reserved. -! Copyright (c) 2009 Doug Coleman. +! Copyright (c) 2009 Aaron Schaefer, Doug Coleman. All rights reserved. ! The contents of this file are licensed under the Simplified BSD License ! A copy of the license is available at http://factorcode.org/license.txt USING: accessors arrays ascii assocs binary-search combinators From e26393394d89f7d29784f36defea18a4282f3654 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 21 Feb 2010 16:21:54 +1300 Subject: [PATCH 130/713] tools.crossref: fix method cross-referencing --- basis/tools/crossref/crossref.factor | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/basis/tools/crossref/crossref.factor b/basis/tools/crossref/crossref.factor index 50034822b2..30ec4b2b65 100644 --- a/basis/tools/crossref/crossref.factor +++ b/basis/tools/crossref/crossref.factor @@ -61,18 +61,17 @@ M: pathname uses string>> source-file top-level-form>> [ uses ] [ { } ] if* ; ! To make UI browser happy M: vocab uses drop f ; -GENERIC: crossref-def ( defspec -- ) - -M: object crossref-def +: crossref-def ( defspec -- ) dup uses crossref get add-vertex ; -M: word crossref-def - [ call-next-method ] [ subwords [ crossref-def ] each ] bi ; - : defs-to-crossref ( -- seq ) [ - all-words [ generic? not ] filter + all-words + [ [ generic? not ] filter ] + [ [ subwords ] map concat ] bi + all-articles [ >link ] map + source-files get keys [ ] map ] append-outputs ; From f78e5c74308a84d77e994c9b5c9c918b8a78ab1e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 21 Feb 2010 16:47:55 +1300 Subject: [PATCH 131/713] ui.text.pango: add a platforms.txt --- basis/ui/text/pango/platforms.txt | 4 ++++ basis/ui/text/pango/tags.txt | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 basis/ui/text/pango/platforms.txt delete mode 100644 basis/ui/text/pango/tags.txt diff --git a/basis/ui/text/pango/platforms.txt b/basis/ui/text/pango/platforms.txt new file mode 100644 index 0000000000..b60912bb4a --- /dev/null +++ b/basis/ui/text/pango/platforms.txt @@ -0,0 +1,4 @@ +linux +freebsd +netbsd +openbsd diff --git a/basis/ui/text/pango/tags.txt b/basis/ui/text/pango/tags.txt deleted file mode 100644 index 5d77766703..0000000000 --- a/basis/ui/text/pango/tags.txt +++ /dev/null @@ -1 +0,0 @@ -untested From eab105590be0f1c7b59ae260198eec88e8219796 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 21 Feb 2010 17:00:48 +1300 Subject: [PATCH 132/713] Rename io.launcher.unix.parser to simple-tokenizer since ftp.server uses it --- basis/ftp/server/server.factor | 21 ++++++------ .../launcher/unix/parser/parser-tests.factor | 33 ------------------- basis/io/launcher/unix/parser/platforms.txt | 1 - basis/io/launcher/unix/unix.factor | 11 +++---- basis/simple-tokenizer/authors.txt | 1 + .../simple-tokenizer-docs.factor | 13 ++++++++ .../simple-tokenizer-tests.factor | 33 +++++++++++++++++++ .../simple-tokenizer.factor} | 10 ++---- basis/simple-tokenizer/tags.txt | 1 + 9 files changed, 66 insertions(+), 58 deletions(-) delete mode 100644 basis/io/launcher/unix/parser/parser-tests.factor delete mode 100644 basis/io/launcher/unix/parser/platforms.txt create mode 100644 basis/simple-tokenizer/authors.txt create mode 100644 basis/simple-tokenizer/simple-tokenizer-docs.factor create mode 100644 basis/simple-tokenizer/simple-tokenizer-tests.factor rename basis/{io/launcher/unix/parser/parser.factor => simple-tokenizer/simple-tokenizer.factor} (62%) create mode 100644 basis/simple-tokenizer/tags.txt diff --git a/basis/ftp/server/server.factor b/basis/ftp/server/server.factor index 1077aebf07..f1bc8adef9 100644 --- a/basis/ftp/server/server.factor +++ b/basis/ftp/server/server.factor @@ -1,15 +1,14 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs byte-arrays calendar classes -combinators combinators.short-circuit concurrency.promises -continuations destructors ftp io io.backend io.directories -io.encodings io.encodings.binary -tools.files io.encodings.utf8 io.files io.files.info -io.pathnames io.launcher.unix.parser io.servers.connection -io.sockets io.streams.duplex io.streams.string io.timeouts -kernel make math math.bitwise math.parser namespaces sequences -splitting threads unicode.case logging calendar.format -strings io.files.links io.files.types io.encodings.8-bit.latin1 ; +USING: accessors assocs byte-arrays calendar classes combinators +combinators.short-circuit concurrency.promises continuations +destructors ftp io io.backend io.directories io.encodings +io.encodings.binary tools.files io.encodings.utf8 io.files +io.files.info io.pathnames io.servers.connection io.sockets +io.streams.duplex io.streams.string io.timeouts kernel make math +math.bitwise math.parser namespaces sequences splitting threads +unicode.case logging calendar.format strings io.files.links +io.files.types io.encodings.8-bit.latin1 simple-tokenizer ; IN: ftp.server SYMBOL: server @@ -24,7 +23,7 @@ TUPLE: ftp-command raw tokenized ; dup \ DEBUG log-message ftp-command new over >>raw - swap tokenize-command >>tokenized ; + swap tokenize >>tokenized ; TUPLE: ftp-get path ; : ( path -- obj ) diff --git a/basis/io/launcher/unix/parser/parser-tests.factor b/basis/io/launcher/unix/parser/parser-tests.factor deleted file mode 100644 index 90504ccac2..0000000000 --- a/basis/io/launcher/unix/parser/parser-tests.factor +++ /dev/null @@ -1,33 +0,0 @@ -IN: io.launcher.unix.parser.tests -USING: io.launcher.unix.parser tools.test ; - -[ "" tokenize-command ] must-fail -[ " " tokenize-command ] must-fail -[ V{ "a" } ] [ "a" tokenize-command ] unit-test -[ V{ "abc" } ] [ "abc" tokenize-command ] unit-test -[ V{ "abc" } ] [ "abc " tokenize-command ] unit-test -[ V{ "abc" } ] [ " abc" tokenize-command ] unit-test -[ V{ "abc" "def" } ] [ "abc def" tokenize-command ] unit-test -[ V{ "abc def" } ] [ "abc\\ def" tokenize-command ] unit-test -[ V{ "abc\\" "def" } ] [ "abc\\\\ def" tokenize-command ] unit-test -[ V{ "abc\\ def" } ] [ "\"abc\\\\ def\"" tokenize-command ] unit-test -[ V{ "abc\\ def" } ] [ " \"abc\\\\ def\"" tokenize-command ] unit-test -[ V{ "abc\\ def" "hey" } ] [ "\"abc\\\\ def\" hey" tokenize-command ] unit-test -[ V{ "abc def" "hey" } ] [ "\"abc def\" \"hey\"" tokenize-command ] unit-test -[ "\"abc def\" \"hey" tokenize-command ] must-fail -[ "\"abc def" tokenize-command ] must-fail -[ V{ "abc def" "h\"ey" } ] [ "\"abc def\" \"h\\\"ey\" " tokenize-command ] unit-test - -[ - V{ - "Hello world.app/Contents/MacOS/hello-ui" - "-i=boot.macosx-ppc.image" - "-include= math compiler ui" - "-deploy-vocab=hello-ui" - "-output-image=Hello world.app/Contents/Resources/hello-ui.image" - "-no-stack-traces" - "-no-user-init" - } -] [ - "\"Hello world.app/Contents/MacOS/hello-ui\" -i=boot.macosx-ppc.image \"-include= math compiler ui\" -deploy-vocab=hello-ui \"-output-image=Hello world.app/Contents/Resources/hello-ui.image\" -no-stack-traces -no-user-init" tokenize-command -] unit-test diff --git a/basis/io/launcher/unix/parser/platforms.txt b/basis/io/launcher/unix/parser/platforms.txt deleted file mode 100644 index 509143d863..0000000000 --- a/basis/io/launcher/unix/parser/platforms.txt +++ /dev/null @@ -1 +0,0 @@ -unix diff --git a/basis/io/launcher/unix/unix.factor b/basis/io/launcher/unix/unix.factor index d8b55d3d17..aaaccd4719 100644 --- a/basis/io/launcher/unix/unix.factor +++ b/basis/io/launcher/unix/unix.factor @@ -1,15 +1,14 @@ -! Copyright (C) 2007, 2008 Slava Pestov. +! Copyright (C) 2007, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types arrays assocs combinators continuations environment io io.backend io.backend.unix -io.files io.files.private io.files.unix io.launcher -io.launcher.unix.parser io.pathnames io.ports kernel math -namespaces sequences strings system threads unix -unix.process unix.ffi ; +io.files io.files.private io.files.unix io.launcher io.pathnames +io.ports kernel math namespaces sequences strings system threads +unix unix.process unix.ffi simple-tokenizer ; IN: io.launcher.unix : get-arguments ( process -- seq ) - command>> dup string? [ tokenize-command ] when ; + command>> dup string? [ tokenize ] when ; : assoc>env ( assoc -- env ) [ "=" glue ] { } assoc>map ; diff --git a/basis/simple-tokenizer/authors.txt b/basis/simple-tokenizer/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/basis/simple-tokenizer/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/basis/simple-tokenizer/simple-tokenizer-docs.factor b/basis/simple-tokenizer/simple-tokenizer-docs.factor new file mode 100644 index 0000000000..57e14f09ba --- /dev/null +++ b/basis/simple-tokenizer/simple-tokenizer-docs.factor @@ -0,0 +1,13 @@ +USING: help.markup help.syntax strings ; +IN: simple-tokenizer + +HELP: tokenize +{ $values { "input" string } { "ast" "a sequence of strings" } } +{ $description + "Tokenize a string. Supported syntax:" + { $list + { { $snippet "foo bar baz" } " - simple tokens" } + { { $snippet "foo\\ bar" } " - token with an escaped space"} + { { $snippet "\"foo bar\"" } " - quoted token" } + } +} ; diff --git a/basis/simple-tokenizer/simple-tokenizer-tests.factor b/basis/simple-tokenizer/simple-tokenizer-tests.factor new file mode 100644 index 0000000000..3b44f03650 --- /dev/null +++ b/basis/simple-tokenizer/simple-tokenizer-tests.factor @@ -0,0 +1,33 @@ +IN: simple-tokenizer.tests +USING: simple-tokenizer tools.test ; + +[ "" tokenize ] must-fail +[ " " tokenize ] must-fail +[ V{ "a" } ] [ "a" tokenize ] unit-test +[ V{ "abc" } ] [ "abc" tokenize ] unit-test +[ V{ "abc" } ] [ "abc " tokenize ] unit-test +[ V{ "abc" } ] [ " abc" tokenize ] unit-test +[ V{ "abc" "def" } ] [ "abc def" tokenize ] unit-test +[ V{ "abc def" } ] [ "abc\\ def" tokenize ] unit-test +[ V{ "abc\\" "def" } ] [ "abc\\\\ def" tokenize ] unit-test +[ V{ "abc\\ def" } ] [ "\"abc\\\\ def\"" tokenize ] unit-test +[ V{ "abc\\ def" } ] [ " \"abc\\\\ def\"" tokenize ] unit-test +[ V{ "abc\\ def" "hey" } ] [ "\"abc\\\\ def\" hey" tokenize ] unit-test +[ V{ "abc def" "hey" } ] [ "\"abc def\" \"hey\"" tokenize ] unit-test +[ "\"abc def\" \"hey" tokenize ] must-fail +[ "\"abc def" tokenize ] must-fail +[ V{ "abc def" "h\"ey" } ] [ "\"abc def\" \"h\\\"ey\" " tokenize ] unit-test + +[ + V{ + "Hello world.app/Contents/MacOS/hello-ui" + "-i=boot.macosx-ppc.image" + "-include= math compiler ui" + "-deploy-vocab=hello-ui" + "-output-image=Hello world.app/Contents/Resources/hello-ui.image" + "-no-stack-traces" + "-no-user-init" + } +] [ + "\"Hello world.app/Contents/MacOS/hello-ui\" -i=boot.macosx-ppc.image \"-include= math compiler ui\" -deploy-vocab=hello-ui \"-output-image=Hello world.app/Contents/Resources/hello-ui.image\" -no-stack-traces -no-user-init" tokenize +] unit-test diff --git a/basis/io/launcher/unix/parser/parser.factor b/basis/simple-tokenizer/simple-tokenizer.factor similarity index 62% rename from basis/io/launcher/unix/parser/parser.factor rename to basis/simple-tokenizer/simple-tokenizer.factor index bcc5f965e9..f6698a65f0 100644 --- a/basis/io/launcher/unix/parser/parser.factor +++ b/basis/simple-tokenizer/simple-tokenizer.factor @@ -1,13 +1,9 @@ -! Copyright (C) 2008 Slava Pestov +! Copyright (C) 2008, 2010 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. USING: peg peg.ebnf arrays sequences strings kernel ; -IN: io.launcher.unix.parser +IN: simple-tokenizer -! Our command line parser. Supported syntax: -! foo bar baz -- simple tokens -! foo\ bar -- escaping the space -! "foo bar" -- quotation -EBNF: tokenize-command +EBNF: tokenize space = " " escaped-char = "\" .:ch => [[ ch ]] quoted = '"' (escaped-char | [^"])*:a '"' => [[ a ]] diff --git a/basis/simple-tokenizer/tags.txt b/basis/simple-tokenizer/tags.txt new file mode 100644 index 0000000000..8e27be7d61 --- /dev/null +++ b/basis/simple-tokenizer/tags.txt @@ -0,0 +1 @@ +text From 5700d94e2bb649c2027cac16bdd40e959d64716e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 21 Feb 2010 17:40:05 +1300 Subject: [PATCH 133/713] unix.utilities: remove platforms.txt since its portable --- basis/unix/utilities/platforms.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 basis/unix/utilities/platforms.txt diff --git a/basis/unix/utilities/platforms.txt b/basis/unix/utilities/platforms.txt deleted file mode 100644 index 509143d863..0000000000 --- a/basis/unix/utilities/platforms.txt +++ /dev/null @@ -1 +0,0 @@ -unix From 6367c8ec85e1ad2417fa60530371ea3c7557bc45 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 21 Feb 2010 17:40:19 +1300 Subject: [PATCH 134/713] native-thread-test: clean up --- core/alien/strings/strings.factor | 17 ++++++----- .../native-thread-test.factor | 28 +++++++++---------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/core/alien/strings/strings.factor b/core/alien/strings/strings.factor index 15e0370ba0..0ad4f6c85a 100644 --- a/core/alien/strings/strings.factor +++ b/core/alien/strings/strings.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008, 2009 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays sequences kernel kernel.private accessors math alien.accessors byte-arrays io io.encodings io.encodings.utf8 @@ -37,17 +37,16 @@ M: string string>alien M: tuple string>alien drop underlying>> ; -HOOK: alien>native-string os ( alien -- string ) +HOOK: native-string-encoding os ( -- encoding ) foldable -M: windows alien>native-string utf16n alien>string ; +M: unix native-string-encoding utf8 ; +M: windows native-string-encoding utf16n ; -M: unix alien>native-string utf8 alien>string ; +: alien>native-string ( alien -- string ) + native-string-encoding alien>string ; inline -HOOK: native-string>alien os ( string -- alien ) - -M: windows native-string>alien utf16n string>alien ; - -M: unix native-string>alien utf8 string>alien ; +: native-string>alien ( string -- alien ) + native-string-encoding string>alien ; inline : dll-path ( dll -- string ) path>> alien>native-string ; diff --git a/extra/native-thread-test/native-thread-test.factor b/extra/native-thread-test/native-thread-test.factor index 508e590d01..4d0df1f454 100644 --- a/extra/native-thread-test/native-thread-test.factor +++ b/extra/native-thread-test/native-thread-test.factor @@ -1,26 +1,24 @@ -USING: alien.c-types alien.syntax io io.encodings.utf16n -io.encodings.utf8 io.files kernel namespaces sequences system threads +! Copyright (C) 2009 Phil Dawes. +! See http://factorcode.org/license.txt for BSD license. +USING: alien.c-types alien.strings alien.syntax io +io.encodings.utf8 io.files kernel sequences system threads unix.utilities ; IN: native-thread-test FUNCTION: void* start_standalone_factor_in_new_thread ( int argc, char** argv ) ; -HOOK: native-string-encoding os ( -- encoding ) -M: windows native-string-encoding utf16n ; -M: unix native-string-encoding utf8 ; - : start-vm-in-os-thread ( args -- threadhandle ) - \ vm get-global prefix + vm prefix [ length ] [ native-string-encoding strings>alien ] bi - start_standalone_factor_in_new_thread ; + start_standalone_factor_in_new_thread ; : start-tetris-in-os-thread ( -- ) - { "-run=tetris" } start-vm-in-os-thread drop ; + { "-run=tetris" } start-vm-in-os-thread drop ; -: start-testthread-in-os-thread ( -- ) - { "-run=native-thread-test" } start-vm-in-os-thread drop ; - -: testthread ( -- ) - "/tmp/hello" utf8 [ "hello!\n" write ] with-file-appender 5000000 sleep ; +: start-test-thread-in-os-thread ( -- ) + { "-run=native-thread-test" } start-vm-in-os-thread drop ; -MAIN: testthread +: test-thread ( -- ) + "/tmp/hello" utf8 [ "hello!\n" write ] with-file-appender 5000000 sleep ; + +MAIN: test-thread From 0161f4e8d2ba2968bc02cfec560bdfff04a029c8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 21 Feb 2010 17:42:40 +1300 Subject: [PATCH 135/713] io.serial.windows: fix load error --- extra/io/serial/windows/windows.factor | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/extra/io/serial/windows/windows.factor b/extra/io/serial/windows/windows.factor index 645e4939de..4ea3d5e9e4 100644 --- a/extra/io/serial/windows/windows.factor +++ b/extra/io/serial/windows/windows.factor @@ -1,9 +1,8 @@ ! Copyright (C) 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: io.files.windows io.streams.duplex kernel math -math.bitwise windows.kernel32 accessors alien.c-types -windows io.files.windows fry locals continuations -classes.struct ; +math.bitwise windows windows.kernel32 windows.errors accessors +alien.c-types fry locals continuations classes.struct ; IN: io.serial.windows : ( path encoding -- duplex ) From 0e8f3670a3f64d07f5c0e7371ddd978341639797 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 21 Feb 2010 17:46:25 +1300 Subject: [PATCH 136/713] Move windows.dragdrop-listener to unmaintained --- .../dragdrop-listener/dragdrop-listener.factor | 0 {basis/windows => unmaintained}/dragdrop-listener/platforms.txt | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {basis/windows => unmaintained}/dragdrop-listener/dragdrop-listener.factor (100%) rename {basis/windows => unmaintained}/dragdrop-listener/platforms.txt (100%) diff --git a/basis/windows/dragdrop-listener/dragdrop-listener.factor b/unmaintained/dragdrop-listener/dragdrop-listener.factor similarity index 100% rename from basis/windows/dragdrop-listener/dragdrop-listener.factor rename to unmaintained/dragdrop-listener/dragdrop-listener.factor diff --git a/basis/windows/dragdrop-listener/platforms.txt b/unmaintained/dragdrop-listener/platforms.txt similarity index 100% rename from basis/windows/dragdrop-listener/platforms.txt rename to unmaintained/dragdrop-listener/platforms.txt From 536ae3c64856a95f18eb96f62adca63a3b022caa Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sat, 20 Feb 2010 21:15:47 -0800 Subject: [PATCH 137/713] Unit test checking the stack effects from FUNCTION:. --- basis/alien/parser/parser-tests.factor | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/basis/alien/parser/parser-tests.factor b/basis/alien/parser/parser-tests.factor index e405f49995..2fec2d9a4c 100644 --- a/basis/alien/parser/parser-tests.factor +++ b/basis/alien/parser/parser-tests.factor @@ -1,7 +1,7 @@ ! (c)2009 Joe Groff bsd license USING: accessors alien.c-types alien.parser alien.syntax -tools.test vocabs.parser parser eval vocabs.parser debugger -continuations ; +tools.test vocabs.parser parser eval debugger kernel +continuations words ; IN: alien.parser.tests TYPEDEF: char char2 @@ -34,6 +34,11 @@ CONSTANT: eleven 11 ] with-file-vocabs +FUNCTION: void* alien-parser-effect-test ( int *arg1 float arg2 ) ; +[ (( arg1 arg2 -- void* )) ] [ + \ alien-parser-effect-test "declared-effect" word-prop +] unit-test + ! Reported by mnestic TYPEDEF: int alien-parser-test-int ! reasonably unique name... From 22ce5eb45cfd9b51886931d6ad33cd73361212f2 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 20 Feb 2010 21:58:09 -0800 Subject: [PATCH 138/713] adjust wording in game.loop docs --- extra/game/loop/loop-docs.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/game/loop/loop-docs.factor b/extra/game/loop/loop-docs.factor index e4946d160c..b48f01cd82 100644 --- a/extra/game/loop/loop-docs.factor +++ b/extra/game/loop/loop-docs.factor @@ -109,13 +109,13 @@ ARTICLE: "game.loop" "Game loops" start-loop stop-loop } -"The game loop maintains performance counters for measuring drawing frames and ticks per second:" +"The game loop maintains performance counters:" { $subsections reset-loop-benchmark benchmark-frames-per-second benchmark-ticks-per-second } -"The game loop manages errors that occur in the delegate's methods during the course of the game loop:" +"The game loop catches errors that occur in the delegate's methods during the course of the game loop:" { $subsections game-loop-error } From 570a2d0b37099ee7c207a8e85176a9781584d481 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 21 Feb 2010 20:19:11 +1300 Subject: [PATCH 139/713] unix.utmpx: fix load errors --- basis/unix/utmpx/netbsd/netbsd.factor | 30 +++++++++++++-------------- basis/unix/utmpx/platforms.txt | 3 ++- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/basis/unix/utmpx/netbsd/netbsd.factor b/basis/unix/utmpx/netbsd/netbsd.factor index 40fce746b1..93092a7cbf 100644 --- a/basis/unix/utmpx/netbsd/netbsd.factor +++ b/basis/unix/utmpx/netbsd/netbsd.factor @@ -1,22 +1,20 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax unix.utmpx unix.bsd.netbsd accessors -unix.utmpx system kernel unix combinators ; +USING: alien.syntax unix unix.utmpx unix.ffi.bsd.netbsd accessors +system kernel combinators ; IN: unix.utmpx.netbsd -TUPLE: netbsd-utmpx-record < utmpx-record termination exit -sockaddr ; - +TUPLE: netbsd-utmpx-record < utmpx-record +termination exit sockaddr ; + M: netbsd new-utmpx-record ( -- utmpx-record ) - netbsd-utmpx-record new ; - + netbsd-utmpx-record new ; + M: netbsd utmpx>utmpx-record ( utmpx -- record ) - [ new-utmpx-record ] keep - { - [ - utmpx-ut_exit - [ exit_struct-e_termination >>termination ] - [ exit_struct-e_exit >>exit ] bi - ] - [ utmpx-ut_ss >>sockaddr ] - } cleave ; + [ new-utmpx-record ] dip + [ + ut_exit>> + [ e_termination>> >>termination ] + [ e_exit>> >>exit ] bi + ] + [ ut_ss>> >>sockaddr ] bi ; diff --git a/basis/unix/utmpx/platforms.txt b/basis/unix/utmpx/platforms.txt index 509143d863..abe56c1458 100644 --- a/basis/unix/utmpx/platforms.txt +++ b/basis/unix/utmpx/platforms.txt @@ -1 +1,2 @@ -unix +macosx +netbsd From 2f70ebd4d02dab0c06835f071b0045b39d624cc2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 21 Feb 2010 20:38:09 +1300 Subject: [PATCH 140/713] vocabs: document platforms.txt --- basis/tools/deploy/deploy-docs.factor | 2 +- basis/vocabs/metadata/metadata-docs.factor | 31 +++++++++++++++++++--- core/vocabs/loader/loader-docs.factor | 20 +++++--------- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/basis/tools/deploy/deploy-docs.factor b/basis/tools/deploy/deploy-docs.factor index a552bd04fb..976fc25357 100755 --- a/basis/tools/deploy/deploy-docs.factor +++ b/basis/tools/deploy/deploy-docs.factor @@ -13,7 +13,7 @@ ARTICLE: "prepare-deploy" "Preparing to deploy an application" ARTICLE: "deploy-resources" "Deployed resource files" "To include additional files in your deployed application, specify their names in a vocabulary's " { $snippet "resources.txt" } " file. The " { $snippet "resources.txt" } " file contains one glob pattern per line. These patterns are expanded relative to the vocabulary directory; files outside of the vocabulary directory cannot be referenced. If a file inside the vocabulary directory matches any of these patterns, it will be included in deployed applications that reference the vocabulary. If a subdirectory matches, its contents will be included recursively." $nl -"If the deployed vocabulary includes an icon file for the current platform (" { $snippet "icon.ico" } " on Windows, or " { $snippet "icon.icns" } " on MacOS X), it will be embedded in the deployed application as its GUI icon." ; +"If the deployed vocabulary includes an icon file for the current platform, it will be embedded in the deployed application as its GUI icon. See " { $link "vocabs.icons" } "." ; ARTICLE: "tools.deploy.usage" "Deploy tool usage" "Once the necessary deployment flags have been set, the application can be deployed:" diff --git a/basis/vocabs/metadata/metadata-docs.factor b/basis/vocabs/metadata/metadata-docs.factor index 95c8083e0f..c3dce45c09 100644 --- a/basis/vocabs/metadata/metadata-docs.factor +++ b/basis/vocabs/metadata/metadata-docs.factor @@ -2,23 +2,36 @@ USING: help.markup help.syntax strings ; IN: vocabs.metadata ARTICLE: "vocabs.metadata" "Vocabulary metadata" -"Vocabulary summaries:" +"Vocabulary directories can contain text files with metadata:" +{ $list + { { $snippet "authors.txt" } " - a series of lines, with one author name per line. These are listed under " { $link "vocab-authors" } "." } + { { $snippet "platforms.txt" } " - a series of lines, with one operating system name per line." } + { { $snippet "resources.txt" } " - a series of lines, with one file glob pattern per line. Files inside the vocabulary directory whose names match any of these glob patterns will be included with the compiled application as " { $link "deploy-resources" } "." } + { { $snippet "summary.txt" } " - a one-line description." } + { { $snippet "tags.txt" } " - a series of lines, with one tag per line. Tags help classify the vocabulary. Consult " { $link "vocab-tags" } " for a list of existing tags you can reuse." } +} +"Words for reading and writing " { $snippet "summary.txt" } ":" { $subsections vocab-summary set-vocab-summary } -"Vocabulary authors:" +"Words for reading and writing " { $snippet "authors.txt" } ":" { $subsections vocab-authors set-vocab-authors } -"Vocabulary tags:" +"Words for reading and writing " { $snippet "tags.txt" } ":" { $subsections vocab-tags set-vocab-tags add-vocab-tags } -"Vocabulary resources:" +"Words for reading and writing " { $snippet "platforms.txt" } ":" +{ $subsections + vocab-platforms + set-vocab-platforms +} +"Words for reading and writing " { $snippet "resources.txt" } ":" { $subsections vocab-resources set-vocab-resources @@ -55,6 +68,16 @@ HELP: set-vocab-tags { $values { "tags" "a sequence of strings" } { "vocab" "a vocabulary specifier" } } { $description "Stores a list of short tags classifying the vocabulary to the " { $snippet "tags.txt" } " file in the vocabulary's directory." } ; +HELP: vocab-platforms +{ $values { "vocab" "a vocabulary specifier" } { "platforms" "a sequence of operating system symbols" } } +{ $description "Outputs a list of operating systems supported by " { $snippet "vocab" } ", as specified by the " { $snippet "platforms.txt" } " file in the vocabulary's directory. Outputs an empty array if the file doesn't exist." } +{ $notes "Operating system symbols are defined in the " { $vocab-link "system" } " vocabulary." } ; + +HELP: set-vocab-platforms +{ $values { "platforms" "a sequence of operating system symbols" } { "vocab" "a vocabulary specifier" } } +{ $description "Stores a list of operating systems supported by " { $snippet "vocab" } " to the " { $snippet "platforms.txt" } " file in the vocabulary's directory." } +{ $notes "Operating system symbols are defined in the " { $vocab-link "system" } " vocabulary." } ; + HELP: vocab-resources { $values { "vocab" "a vocabulary specifier" } { "patterns" "a sequence of glob patterns" } } { $description "Outputs a list of glob patterns matching files that will be deployed with an application that includes " { $snippet "vocab" } ", as specified by the " { $snippet "resources.txt" } " file in the vocabulary's directory. Outputs an empty array if the file doesn't exist." } diff --git a/core/vocabs/loader/loader-docs.factor b/core/vocabs/loader/loader-docs.factor index ce4a319a42..08ab729b6d 100755 --- a/core/vocabs/loader/loader-docs.factor +++ b/core/vocabs/loader/loader-docs.factor @@ -27,10 +27,11 @@ ARTICLE: "vocabs.roots" "Vocabulary roots" "You can store your own vocabularies in the " { $snippet "work" } " directory." { $subsections "add-vocab-roots" } ; +ARTICLE: "vocabs.icons" "Vocabulary icons" +"An icon file representing the vocabulary can be provided for use by " { $link "tools.deploy" } ". A file named " { $snippet "icon.ico" } " will be used as the application icon when the application is deployed on Windows. A file named " { $snippet "icon.icns" } " will be used when the application is deployed on MacOS X." ; + ARTICLE: "vocabs.loader" "Vocabulary loader" -"The vocabulary loader combines the vocabulary system with " { $link "parser" } " in order to implement automatic loading of vocabulary source files. The vocabulary loader is implemented in the " { $vocab-link "vocabs.loader" } " vocabulary." -$nl -"When an attempt is made to use a vocabulary that has not been loaded into the image, the vocabulary loader is asked to locate the vocabulary's source files, and load them." +"The " { $link POSTPONE: USE: } " and " { $link POSTPONE: USING: } " words load vocabularies using the vocabulary loader. The vocabulary loader is implemented in the " { $vocab-link "vocabs.loader" } " vocabulary." $nl "The vocabulary loader searches for vocabularies in a set of directories known as vocabulary roots." { $subsections "vocabs.roots" } @@ -45,17 +46,8 @@ $nl { { $snippet "foo/bar/bar-docs.factor" } " - documentation, see " { $link "writing-help" } } { { $snippet "foo/bar/bar-tests.factor" } " - unit tests, see " { $link "tools.test" } } } -"Finally, four optional text files may contain metadata:" -{ $list - { { $snippet "foo/bar/authors.txt" } " - a series of lines, with one author name per line. These are listed under " { $link "vocab-authors" } "." } - { { $snippet "foo/bar/resources.txt" } " - a series of lines with one file glob pattern per line. Files inside the vocabulary directory whose names match any of these glob patterns will be included with the compiled application as " { $link "deploy-resources" } "." } - { { $snippet "foo/bar/summary.txt" } " - a one-line description." } - { { $snippet "foo/bar/tags.txt" } " - a whitespace-separated list of tags which classify the vocabulary. Consult " { $link "vocab-tags" } " for a list of existing tags you can reuse." } -} -"An icon file representing the vocabulary can also be provided. A file named " { $snippet "icon.ico" } " will be used as the application icon when the application is deployed on Windows. A file named " { $snippet "icon.icns" } " will be used when the application is deployed on MacOS X." -$nl -"The " { $link POSTPONE: USE: } " and " { $link POSTPONE: USING: } " words load vocabularies which have not been loaded yet, as needed." -$nl +"Optional text files may contain metadata." +{ $subsections "vocabs.metadata" "vocabs.icons" } "Vocabularies can also be loaded at run time, without altering the vocabulary search path. This is done by calling a word which loads a vocabulary if it is not in the image, doing nothing if it is:" { $subsections require } "The above word will only ever load a vocabulary once in a given session. There is another word which unconditionally loads vocabulary from disk, regardless of whether or not is has already been loaded:" From 0da6f780888e85ab01b706ade6b98dc9e8093735 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 21 Feb 2010 22:27:32 +1300 Subject: [PATCH 141/713] cocoa.messages: if a class cannot be found, IMPORT: no longer fails at parse time. Instead, there will be a runtime error when the class word is executed --- basis/cocoa/messages/messages.factor | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/basis/cocoa/messages/messages.factor b/basis/cocoa/messages/messages.factor index 02e6335c54..eab301add7 100644 --- a/basis/cocoa/messages/messages.factor +++ b/basis/cocoa/messages/messages.factor @@ -76,13 +76,13 @@ MACRO: (send) ( selector super? -- quot ) : super-send ( receiver args... selector -- return... ) t (send) ; inline ! Runtime introspection -SYMBOL: class-startup-hooks +SYMBOL: class-init-hooks -class-startup-hooks [ H{ } clone ] initialize +class-init-hooks [ H{ } clone ] initialize : (objc-class) ( name word -- class ) 2dup execute dup [ 2nip ] [ - drop over class-startup-hooks get at [ call( -- ) ] when* + drop over class-init-hooks get at [ call( -- ) ] when* 2dup execute dup [ 2nip ] [ 2drop "No such class: " prepend throw ] if @@ -229,7 +229,7 @@ ERROR: no-objc-type name ; : class-exists? ( string -- class ) objc_getClass >boolean ; : define-objc-class-word ( quot name -- ) - [ class-startup-hooks get set-at ] + [ class-init-hooks get set-at ] [ [ "cocoa.classes" create ] [ '[ _ objc-class ] ] bi (( -- class )) define-declared @@ -237,8 +237,10 @@ ERROR: no-objc-type name ; : import-objc-class ( name quot -- ) over define-objc-class-word - [ objc-class register-objc-methods ] - [ objc-meta-class register-objc-methods ] bi ; + dup objc_getClass [ + [ objc-class register-objc-methods ] + [ objc-meta-class register-objc-methods ] bi + ] [ drop ] if ; : root-class ( class -- root ) dup class_getSuperclass [ root-class ] [ ] ?if ; From bb3665f37e7a7f9a101ff88c7820ec5d37d8c8cb Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sun, 21 Feb 2010 03:27:16 -0800 Subject: [PATCH 142/713] FUEL: Flip the default behavior of visit-other-file so that it does not try to create -docs or -tests files if they do not exist by default. This is the more common case when spelunking in code and in general you want to scaffold those files anyway. --- misc/fuel/factor-mode.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/misc/fuel/factor-mode.el b/misc/fuel/factor-mode.el index bef6e4c774..c26abab997 100644 --- a/misc/fuel/factor-mode.el +++ b/misc/fuel/factor-mode.el @@ -245,11 +245,11 @@ code in the buffer." (defsubst factor-mode--in-tests (&optional file) (factor-mode--code-file "tests")) -(defun factor-mode-visit-other-file (&optional skip) +(defun factor-mode-visit-other-file (&optional create) "Cycle between code, tests and docs factor files. -With prefix, non-existing files will be skipped." +With prefix, non-existing files will be created." (interactive "P") - (let ((file (factor-mode--cycle-next (buffer-file-name) skip))) + (let ((file (factor-mode--cycle-next (buffer-file-name) (not create)))) (unless file (error "No other file found")) (find-file file) (unless (file-exists-p file) From ffddca36b74ea54be2f52b8ada2b0e17802a3582 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sun, 21 Feb 2010 03:34:08 -0800 Subject: [PATCH 143/713] Add scaffolding words for tags, summary and authors and hook these up to FUEL. Modified fuel-scaffold-vocab to prompt the user for tags, summary and whether to create help and test files immediately. --- basis/tools/scaffold/scaffold-docs.factor | 26 ++++++- basis/tools/scaffold/scaffold.factor | 27 +++++-- basis/vocabs/files/files-docs.factor | 8 +++ basis/vocabs/files/files.factor | 6 +- extra/fuel/fuel.factor | 19 ++++- misc/fuel/fuel-scaffold.el | 88 ++++++++++++++++++++++- 6 files changed, 159 insertions(+), 15 deletions(-) diff --git a/basis/tools/scaffold/scaffold-docs.factor b/basis/tools/scaffold/scaffold-docs.factor index f4200f8cb2..4476f5ec9f 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 vocabs ; +USING: help.markup help.syntax kernel strings words vocabs sequences ; IN: tools.scaffold HELP: developer-name @@ -23,6 +23,30 @@ HELP: scaffold-undocumented { scaffold-help scaffold-undocumented } related-words +HELP: scaffold-authors +{ $values + { "vocab" "a vocabulary specifier" } +} +{ $description "Creates an authors.txt file using the value in " { $link developer-name } ". This word only works if no authors.txt file yet exists." } ; + +HELP: scaffold-summary +{ $values + { "vocab" "a vocabulary specifier" } { "summary" string } +} +{ $description "Creates a summary.txt file with the given summary. This word only works if no summary.txt file yet exists." } ; + +HELP: scaffold-tags +{ $values + { "vocab" "a vocabulary specifier" } { "tags" string } +} +{ $description "Creates a tags.txt file with the given tags. This word only works if no tags.txt file yet exists." } ; + +HELP: scaffold-tests +{ $values + { "vocab" "a vocabulary specifier" } +} +{ $description "Takes an existing vocabulary and creates an empty tests file help for each word. This word only works if no tests file yet exists." } ; + HELP: scaffold-vocab { $values { "vocab-root" "a vocabulary root string" } { "string" string } } diff --git a/basis/tools/scaffold/scaffold.factor b/basis/tools/scaffold/scaffold.factor index 936d388b01..151d98a134 100644 --- a/basis/tools/scaffold/scaffold.factor +++ b/basis/tools/scaffold/scaffold.factor @@ -63,6 +63,9 @@ M: bad-developer-name summary : vocab-root/vocab/suffix>path ( vocab-root vocab suffix -- path ) [ vocab-root/vocab>path dup file-name append-path ] dip append ; +: vocab/file>path ( vocab file -- path ) + [ vocab>path ] dip append-path ; + : vocab/suffix>path ( vocab suffix -- path ) [ vocab>path dup file-name append-path ] dip append ; @@ -104,16 +107,17 @@ M: bad-developer-name summary 2drop ] if ; -: scaffold-authors ( vocab-root vocab -- ) - developer-name get [ - "authors.txt" vocab-root/vocab/file>path scaffolding? [ - developer-name get swap utf8 set-file-contents +: scaffold-metadata ( vocab file contents -- ) + [ ensure-vocab-exists ] 2dip + [ + [ vocab/file>path ] dip swap scaffolding? [ + utf8 set-file-contents ] [ - drop + 2drop ] if ] [ 2drop - ] if ; + ] if* ; : lookup-type ( string -- object/string ? ) "new" ?head drop [ { [ CHAR: ' = ] [ digit? ] } 1|| ] trim-tail @@ -258,12 +262,21 @@ PRIVATE> : scaffold-undocumented ( string -- ) [ interesting-words. ] [ link-vocab ] bi ; +: scaffold-authors ( vocab -- ) + "authors.txt" developer-name get scaffold-metadata ; + +: scaffold-tags ( vocab tags -- ) + [ "tags.txt" ] dip scaffold-metadata ; + +: scaffold-summary ( vocab summary -- ) + [ "summary.txt" ] dip scaffold-metadata ; + : scaffold-vocab ( vocab-root string -- ) { [ scaffold-directory ] [ scaffold-main ] - [ scaffold-authors ] [ nip require ] + [ nip scaffold-authors ] } 2cleave ; : scaffold-core ( string -- ) "resource:core" swap scaffold-vocab ; diff --git a/basis/vocabs/files/files-docs.factor b/basis/vocabs/files/files-docs.factor index e2c6a5f373..61a2e68707 100644 --- a/basis/vocabs/files/files-docs.factor +++ b/basis/vocabs/files/files-docs.factor @@ -1,6 +1,14 @@ USING: help.markup help.syntax strings ; IN: vocabs.files +HELP: vocab-tests-file +{ $values { "vocab" "a vocabulary specifier" } { "path" "pathname string to test file" } } +{ $description "Outputs a pathname where the unit test file is located." } ; + +HELP: vocab-tests-dir +{ $values { "vocab" "a vocabulary specifier" } { "paths" "a sequence of pathname strings" } } +{ $description "Outputs a sequence of pathnames for the tests in the test directory." } ; + HELP: vocab-files { $values { "vocab" "a vocabulary specifier" } { "seq" "a sequence of pathname strings" } } { $description "Outputs a sequence of files comprising this vocabulary, or " { $link f } " if the vocabulary does not have a directory on disk." } ; diff --git a/basis/vocabs/files/files.factor b/basis/vocabs/files/files.factor index c1d7dcfd59..1c3e3731bd 100644 --- a/basis/vocabs/files/files.factor +++ b/basis/vocabs/files/files.factor @@ -4,8 +4,6 @@ USING: io.directories io.files io.pathnames kernel make sequences vocabs.loader ; IN: vocabs.files - - : vocab-tests ( vocab -- tests ) [ [ vocab-tests-file [ , ] when* ] @@ -31,4 +27,4 @@ PRIVATE> [ vocab-source-path [ , ] when* ] [ vocab-docs-path [ , ] when* ] [ vocab-tests % ] tri - ] { } make ; \ No newline at end of file + ] { } make ; diff --git a/extra/fuel/fuel.factor b/extra/fuel/fuel.factor index d64ef41f8c..2934d5d43c 100644 --- a/extra/fuel/fuel.factor +++ b/extra/fuel/fuel.factor @@ -3,7 +3,8 @@ USING: accessors assocs compiler.units continuations fuel.eval fuel.help fuel.remote fuel.xref help.topics io.pathnames kernel namespaces parser -sequences tools.scaffold vocabs.loader vocabs.parser words ; +sequences tools.scaffold vocabs.loader vocabs.parser words vocabs.files +vocabs.metadata ; IN: fuel @@ -145,6 +146,22 @@ PRIVATE> [ fuel-scaffold-name dup require dup scaffold-help ] with-scope vocab-docs-path absolute-path fuel-eval-set-result ; +: fuel-scaffold-tests ( name devname -- ) + [ fuel-scaffold-name dup require dup scaffold-tests ] with-scope + vocab-tests-file absolute-path fuel-eval-set-result ; + +: fuel-scaffold-authors ( name devname -- ) + [ fuel-scaffold-name dup require dup scaffold-authors ] with-scope + [ vocab-authors-path ] keep swap vocab-append-path absolute-path fuel-eval-set-result ; + +: fuel-scaffold-tags ( name tags -- ) + [ scaffold-tags ] + [ drop [ vocab-tags-path ] keep swap vocab-append-path absolute-path fuel-eval-set-result ] 2bi ; + +: fuel-scaffold-summary ( name summary -- ) + [ scaffold-summary ] + [ drop [ vocab-summary-path ] keep swap vocab-append-path absolute-path fuel-eval-set-result ] 2bi ; + : fuel-scaffold-get-root ( name -- ) find-vocab-root fuel-eval-set-result ; ! Remote connection diff --git a/misc/fuel/fuel-scaffold.el b/misc/fuel/fuel-scaffold.el index 9b7d9861c7..9e8e56475d 100644 --- a/misc/fuel/fuel-scaffold.el +++ b/misc/fuel/fuel-scaffold.el @@ -79,6 +79,25 @@ IN: %s "fuel"))) (fuel-eval--send/wait cmd))) +(defsubst fuel-scaffold--create-tests (vocab) + (let ((cmd `(:fuel* (,vocab ,fuel-scaffold-developer-name fuel-scaffold-tests) + "fuel"))) + (fuel-eval--send/wait cmd))) + +(defsubst fuel-scaffold--create-authors (vocab) + (let ((cmd `(:fuel* (,vocab ,fuel-scaffold-developer-name fuel-scaffold-authors) "fuel"))) + (fuel-eval--send/wait cmd))) + +(defsubst fuel-scaffold--create-tags (vocab tags) + (let ((cmd `(:fuel* (,vocab ,tags fuel-scaffold-tags) "fuel"))) + (fuel-eval--send/wait cmd))) + +(defsubst fuel-scaffold--create-summary (vocab summary) + (let ((cmd `(:fuel* (,vocab ,summary fuel-scaffold-summary) "fuel"))) + (fuel-eval--send/wait cmd))) + +(defsubst fuel-scaffold--creaet- + (defun fuel-scaffold--help (parent) (when (and parent (fuel-scaffold--check-auto fuel-scaffold-help-autoinsert-p)) (let* ((ret (fuel-scaffold--create-docs (fuel-scaffold--vocab parent))) @@ -102,7 +121,8 @@ IN: %s (defun fuel-scaffold-vocab (&optional other-window name-hint root-hint) "Creates a directory in the given root for a new vocabulary and -adds source, tests and authors.txt files. +adds source and authors.txt files. Prompts the user for optional summary, +tags, help, and test file creation. You can configure `fuel-scaffold-developer-name' (set by default to `user-full-name') for the name to be inserted in the generated files." @@ -111,12 +131,24 @@ You can configure `fuel-scaffold-developer-name' (set by default to (root (completing-read "Vocab root: " (fuel-scaffold--vocab-roots) nil t (or root-hint "resource:"))) + (summary (read-string "Vocab summary (empty for none): ")) + (tags (read-string "Vocab tags (empty for none): ")) + (help (y-or-n-p "Scaffold help? ")) + (tests (y-or-n-p "Scaffold tests? ")) (cmd `(:fuel* ((,root ,name ,fuel-scaffold-developer-name) (fuel-scaffold-vocab)) "fuel")) (ret (fuel-eval--send/wait cmd)) (file (fuel-eval--retort-result ret))) (unless file (error "Error creating vocab (%s)" (car (fuel-eval--retort-error ret)))) + (when (not (equal "" summary)) + (fuel-scaffold--create-summary name summary)) + (when (not (equal "" tags)) + (fuel-scaffold--create-tags name tags)) + (when help + (fuel-scaffold--create-docs name)) + (when tests + (fuel-scaffold--create-tests name)) (if other-window (find-file-other-window file) (find-file file)) (goto-char (point-max)) name)) @@ -137,6 +169,60 @@ You can configure `fuel-scaffold-developer-name' (set by default to (error "Error creating help file" (car (fuel-eval--retort-error ret)))) (find-file file))) +(defun fuel-scaffold-tests (&optional arg) + "Creates, if it does not already exist, a tests file for the current vocabulary. + +With prefix argument, ask for the vocabulary name. +You can configure `fuel-scaffold-developer-name' (set by default to +`user-full-name') for the name to be inserted in the generated file." + (interactive "P") + (let* ((vocab (or (and (not arg) (fuel-syntax--current-vocab)) + (fuel-completion--read-vocab nil))) + (ret (fuel-scaffold--create-tests vocab)) + (file (fuel-eval--retort-result ret))) + (unless file + (error "Error creating tests file" (car (fuel-eval--retort-error ret)))) + (find-file file))) + +(defun fuel-scaffold-authors (&optional arg) + "Creates, if it does not already exist, an authors file for the current vocabulary. + +With prefix argument, ask for the vocabulary name. +You can configure `fuel-scaffold-developer-name' (set by default to +`user-full-name') for the name to be inserted in the generated file." + (interactive "P") + (let* ((vocab (or (and (not arg) (fuel-syntax--current-vocab)) + (fuel-completion--read-vocab nil))) + (ret (fuel-scaffold--create-authors vocab)) + (file (fuel-eval--retort-result ret))) + (unless file + (error "Error creating authors file" (car (fuel-eval--retort-error ret)))) + (find-file file))) + +(defun fuel-scaffold-tags (&optional arg) + "Creates, if it does not already exist, a tags file for the current vocabulary." + (interactive "P") + (let* ((vocab (or (and (not arg) (fuel-syntax--current-vocab)) + (fuel-completion--read-vocab nil))) + (tags (read-string "Tags: ")) + (ret (fuel-scaffold--create-tags vocab tags)) + (file (fuel-eval--retort-result ret))) + (unless file + (error "Error creating tags file" (car (fuel-eval--retort-error ret)))) + (find-file file))) + +(defun fuel-scaffold-summary (&optional arg) + "Creates, if it does not already exist, a summary file for the current vocabulary." + (interactive "P") + (let* ((vocab (or (and (not arg ) (fuel-syntax--current-vocab)) + (fuel-completion--read-vocab nil))) + (summary (read-string "Summary: ")) + (ret (fuel-scaffold--create-summary vocab summary)) + (file (fuel-eval--retort-result ret))) + (unless file + (error "Error creating summary file" (car (fuel-eval--retort-error ret)))) + (find-file file))) + (provide 'fuel-scaffold) ;;; fuel-scaffold.el ends here From a452966af9724f83260204ea4cc1abab6aa810b0 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sun, 21 Feb 2010 03:35:15 -0800 Subject: [PATCH 144/713] FUEL: Add prefix key behavior to fuel-test-vocab so that it is similar to other FUEL interactive functions. --- misc/fuel/fuel-listener.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/misc/fuel/fuel-listener.el b/misc/fuel/fuel-listener.el index d5fec4bf5f..485d97e81f 100644 --- a/misc/fuel/fuel-listener.el +++ b/misc/fuel/fuel-listener.el @@ -192,12 +192,15 @@ With prefix, you're teletransported to the listener's buffer." (comint-send-string nil "\"Refreshing loaded vocabs...\" write nl flush") (comint-send-string nil " refresh-all \"Done!\" write nl flush\n"))) -(defun fuel-test-vocab (vocab) - "Run the unit tests for the specified vocabulary." - (interactive (list (fuel-completion--read-vocab nil (fuel-syntax--current-vocab)))) - (comint-send-string (fuel-listener--process) - (concat "\"" vocab "\" reload nl flush\n" - "\"" vocab "\" test nl flush\n"))) +(defun fuel-test-vocab (&optional arg) + "Run the unit tests for the current vocabulary. With prefix argument, ask for +the vocabulary name." + (interactive "P") + (let* ((vocab (or (and (not arg) (fuel-syntax--current-vocab)) + (fuel-completion--read-vocab nil)))) + (comint-send-string (fuel-listener--process) + (concat "\"" vocab "\" reload nl flush\n" + "\"" vocab "\" test nl flush\n")))) ;;; Completion support From 9b8fd8d160adb77ea560aa31f1aa2ac1b33aa5e6 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sun, 21 Feb 2010 04:39:44 -0800 Subject: [PATCH 145/713] Fix parse error in elisp file --- misc/fuel/fuel-scaffold.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/misc/fuel/fuel-scaffold.el b/misc/fuel/fuel-scaffold.el index 9e8e56475d..dc2a09713d 100644 --- a/misc/fuel/fuel-scaffold.el +++ b/misc/fuel/fuel-scaffold.el @@ -96,8 +96,6 @@ IN: %s (let ((cmd `(:fuel* (,vocab ,summary fuel-scaffold-summary) "fuel"))) (fuel-eval--send/wait cmd))) -(defsubst fuel-scaffold--creaet- - (defun fuel-scaffold--help (parent) (when (and parent (fuel-scaffold--check-auto fuel-scaffold-help-autoinsert-p)) (let* ((ret (fuel-scaffold--create-docs (fuel-scaffold--vocab parent))) From 62e97c138ab5a792ab027b154c0a82c7b9bc7241 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 10:28:42 -0800 Subject: [PATCH 146/713] ditch string c-types --- basis/alien/c-types/c-types-docs.factor | 5 +--- basis/alien/c-types/c-types.factor | 26 ------------------- basis/alien/complex/complex-tests.factor | 4 +-- basis/alien/complex/complex.factor | 4 ++- basis/alien/complex/functor/functor.factor | 4 ++- basis/classes/struct/struct-tests.factor | 7 ----- basis/classes/struct/struct.factor | 3 --- .../specialized-arrays.factor | 5 +--- 8 files changed, 10 insertions(+), 48 deletions(-) diff --git a/basis/alien/c-types/c-types-docs.factor b/basis/alien/c-types/c-types-docs.factor index b221051efc..215ca1b0ef 100644 --- a/basis/alien/c-types/c-types-docs.factor +++ b/basis/alien/c-types/c-types-docs.factor @@ -32,13 +32,10 @@ HELP: no-c-type { $description "Throws a " { $link no-c-type } " error." } { $error-description "Thrown by " { $link c-type } " if a given string does not name a C type. When thrown during compile time, indicates a typo in an " { $link alien-invoke } " or " { $link alien-callback } " form." } ; -HELP: c-types -{ $var-description "Global variable holding a hashtable mapping C type names to C types. Use the " { $link c-type } " word to look up C types." } ; - HELP: c-type { $values { "name" "a C type" } { "c-type" c-type } } { $description "Looks up a C type by name." } -{ $errors "Throws a " { $link no-c-type } " error if the type does not exist." } ; +{ $errors "Throws a " { $link no-c-type } " error if the type does not exist, or the word is not a C type." } ; HELP: c-getter { $values { "name" "a C type" } { "quot" { $quotation "( c-ptr n -- obj )" } } } diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor index e2f15f5de8..a929cba954 100644 --- a/basis/alien/c-types/c-types.factor +++ b/basis/alien/c-types/c-types.factor @@ -43,12 +43,6 @@ stack-align? ; : ( -- c-type ) \ c-type new ; inline -SYMBOL: c-types - -global [ - c-types [ H{ } assoc-like ] change -] bind - ERROR: no-c-type name ; PREDICATE: c-type-word < word @@ -70,14 +64,6 @@ M: word resolve-pointer-type dup "pointer-c-type" word-prop [ ] [ drop void* ] ?if ; -M: string resolve-pointer-type - dup "*" append dup c-types get at - [ nip ] [ - drop - c-types get at dup c-type-name? - [ resolve-pointer-type ] [ drop void* ] if - ] if ; - M: array resolve-pointer-type first resolve-pointer-type ; @@ -93,15 +79,6 @@ M: array resolve-pointer-type PRIVATE> -M: string c-type ( name -- c-type ) - CHAR: ] over member? [ - parse-array-type prefix - ] [ - dup c-types get at [ ] [ - "*" ?tail [ resolve-pointer-type ] [ no-c-type ] if - ] ?if resolve-typedef - ] if ; - M: word c-type dup "c-type" word-prop resolve-typedef [ ] [ no-c-type ] ?if ; @@ -268,12 +245,9 @@ GENERIC: typedef ( old new -- ) PREDICATE: typedef-word < c-type-word "c-type" word-prop c-type-name? ; -M: string typedef ( old new -- ) c-types get set-at ; - M: word typedef ( old new -- ) { [ nip define-symbol ] - [ name>> typedef ] [ swap "c-type" set-word-prop ] [ swap dup c-type-name? [ diff --git a/basis/alien/complex/complex-tests.factor b/basis/alien/complex/complex-tests.factor index 87f0c98b47..63d73ef029 100644 --- a/basis/alien/complex/complex-tests.factor +++ b/basis/alien/complex/complex-tests.factor @@ -16,6 +16,6 @@ STRUCT: complex-holder [ C{ 1.0 2.0 } ] [ "h" get z>> ] unit-test -[ complex ] [ "complex-float" c-type-boxed-class ] unit-test +[ complex ] [ complex-float c-type-boxed-class ] unit-test -[ complex ] [ "complex-double" c-type-boxed-class ] unit-test +[ complex ] [ complex-double c-type-boxed-class ] unit-test diff --git a/basis/alien/complex/complex.factor b/basis/alien/complex/complex.factor index 65c4095e25..fbf28071d0 100644 --- a/basis/alien/complex/complex.factor +++ b/basis/alien/complex/complex.factor @@ -6,8 +6,10 @@ IN: alien.complex << { "float" "double" } [ dup "complex-" prepend define-complex-type ] each +>> +<< ! This overrides the fact that small structures are never returned ! in registers on NetBSD, Linux and Solaris running on 32-bit x86. -"complex-float" c-type t >>return-in-registers? drop +\ complex-float c-type t >>return-in-registers? drop >> diff --git a/basis/alien/complex/functor/functor.factor b/basis/alien/complex/functor/functor.factor index cb46f2d67a..90fb5174c1 100644 --- a/basis/alien/complex/functor/functor.factor +++ b/basis/alien/complex/functor/functor.factor @@ -7,6 +7,8 @@ IN: alien.complex.functor FUNCTOR: define-complex-type ( N T -- ) +N-type IS ${N} + T-class DEFINES-CLASS ${T} DEFINES <${T}> @@ -14,7 +16,7 @@ T-class DEFINES-CLASS ${T} WHERE -STRUCT: T-class { real N } { imaginary N } ; +STRUCT: T-class { real N-type } { imaginary N-type } ; : ( z -- alien ) >rect T-class >c-ptr ; diff --git a/basis/classes/struct/struct-tests.factor b/basis/classes/struct/struct-tests.factor index cb7e4ee2b0..44a2be5a70 100644 --- a/basis/classes/struct/struct-tests.factor +++ b/basis/classes/struct/struct-tests.factor @@ -361,13 +361,6 @@ TUPLE: a-subclass < will-become-struct ; [ tuple ] [ a-subclass superclass ] unit-test -! Remove c-type when struct class is forgotten -[ ] [ - "USE: classes.struct IN: classes.struct.tests TUPLE: a-struct ;" eval( -- ) -] unit-test - -[ f ] [ "a-struct" c-types get key? ] unit-test - STRUCT: bit-field-test { a uint bits: 12 } { b int bits: 2 } diff --git a/basis/classes/struct/struct.factor b/basis/classes/struct/struct.factor index a5711de609..4e7a565a5a 100644 --- a/basis/classes/struct/struct.factor +++ b/basis/classes/struct/struct.factor @@ -296,9 +296,6 @@ PRIVATE> : define-union-struct-class ( class slots -- ) [ compute-union-offsets ] (define-struct-class) ; -M: struct-class reset-class - [ call-next-method ] [ name>> c-types get delete-at ] bi ; - ERROR: invalid-struct-slot token ; : struct-slot-class ( c-type -- class' ) diff --git a/basis/specialized-arrays/specialized-arrays.factor b/basis/specialized-arrays/specialized-arrays.factor index e2840b89dd..fe2a93844c 100644 --- a/basis/specialized-arrays/specialized-arrays.factor +++ b/basis/specialized-arrays/specialized-arrays.factor @@ -116,10 +116,7 @@ M: A v*high [ * \ T heap-size neg shift ] 2map ; inline ;FUNCTOR -GENERIC: (underlying-type) ( c-type -- c-type' ) - -M: string (underlying-type) c-types get at ; -M: word (underlying-type) "c-type" word-prop ; +: (underlying-type) ( word -- c-type ) "c-type" word-prop ; inline : underlying-type ( c-type -- c-type' ) dup (underlying-type) { From 1a0fda2a5b06f49653db969e0cba985d50b389a0 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 11:10:52 -0800 Subject: [PATCH 147/713] remove references to c-types hash from deploy tool --- basis/tools/deploy/config/config-docs.factor | 4 ++-- basis/tools/deploy/shaker/shaker.factor | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/basis/tools/deploy/config/config-docs.factor b/basis/tools/deploy/config/config-docs.factor index 1df76856ba..740abb0feb 100644 --- a/basis/tools/deploy/config/config-docs.factor +++ b/basis/tools/deploy/config/config-docs.factor @@ -36,7 +36,7 @@ $nl "Off by default. During normal execution, the word definition quotation of a word compiled with the optimizing compiler is not used, so disabling this flag can save space. However, some libraries introspect word definitions dynamically (for example, " { $vocab-link "inverse" } ") and so programs using these libraries must retain word definition quotations." } ; HELP: deploy-c-types? -{ $description "Deploy flag. If set, the deploy tool retains the " { $link c-types } " table, otherwise this table is stripped out, saving space." +{ $description "Deploy flag. If set, the deploy tool retains word properties containing metadata for C types and struct classes; otherwise, these properties are stripped out, saving space." $nl "Off by default." $nl @@ -49,7 +49,7 @@ $nl { $link malloc-object } { $link malloc-array } } -"If your program looks up C types dynamically or from words which do not have a stack effect, you must enable this flag, because in these situations the C type lookup is not folded away and the global table must be consulted at runtime." } ; +"If your program looks up C types dynamically or from words which do not have a stack effect, you must enable this flag, because in these situations the C type lookup code is not folded away and the word properties must be consulted at runtime." } ; HELP: deploy-math? { $description "Deploy flag. If set, the deployed image will contain support for " { $link ratio } " and " { $link complex } " types." diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index 54058f1b0d..09219a8e5e 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -378,10 +378,6 @@ IN: tools.deploy.shaker ] when ] when - deploy-c-types? get [ - "c-types" "alien.c-types" lookup , - ] unless - "windows-messages" "windows.messages" lookup [ , ] when* ] { } make ; From 347003eb64fd65744c494ac7d5e460d740db6ab8 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 11:17:25 -0800 Subject: [PATCH 148/713] core-foundation.fsevents: use CALLBACK: type to define master-event-source-callback --- basis/core-foundation/fsevents/fsevents.factor | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/basis/core-foundation/fsevents/fsevents.factor b/basis/core-foundation/fsevents/fsevents.factor index 37dbcd1e4f..ef1a3ff7f1 100644 --- a/basis/core-foundation/fsevents/fsevents.factor +++ b/basis/core-foundation/fsevents/fsevents.factor @@ -36,7 +36,6 @@ STRUCT: FSEventStreamContext { release void* } { copyDescription void* } ; -! callback( CALLBACK: void FSEventStreamCallback ( FSEventStreamRef streamRef, void* clientCallBackInfo, size_t numEvents, void* eventPaths, FSEventStreamEventFlags* eventFlags, FSEventStreamEventId* eventIds ) ; CONSTANT: FSEventStreamEventIdSinceNow HEX: FFFFFFFFFFFFFFFF @@ -173,16 +172,7 @@ SYMBOL: event-stream-callbacks info event-stream-callbacks get at [ drop ] or call( changes -- ) ; : master-event-source-callback ( -- alien ) - "void" - { - "FSEventStreamRef" - "void*" ! info - "size_t" ! numEvents - "void*" ! eventPaths - "FSEventStreamEventFlags*" - "FSEventStreamEventId*" - } - "cdecl" [ (master-event-source-callback) ] alien-callback ; + [ (master-event-source-callback) ] FSEventStreamCallback ; TUPLE: event-stream < disposable info handle ; From a2c9563bb7a1306160f18b98dfa85713c97e9696 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 11:36:59 -0800 Subject: [PATCH 149/713] opengl.gl.extensions: scan return type of GL-FUNCTION: as c-type --- basis/opengl/gl/extensions/extensions.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/opengl/gl/extensions/extensions.factor b/basis/opengl/gl/extensions/extensions.factor index 540fba40f0..17813b8c82 100644 --- a/basis/opengl/gl/extensions/extensions.factor +++ b/basis/opengl/gl/extensions/extensions.factor @@ -49,7 +49,7 @@ reset-gl-function-number-counter SYNTAX: GL-FUNCTION: gl-function-calling-convention - scan + scan-c-type scan dup scan drop "}" parse-tokens swap prefix gl-function-number From f07ec8bc1b554d092877e67505ef6a5a3694977b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 11:56:35 -0800 Subject: [PATCH 150/713] windows.com.syntax: parse return c-type of COM-INTERFACE: functions --- basis/windows/com/syntax/syntax.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/windows/com/syntax/syntax.factor b/basis/windows/com/syntax/syntax.factor index fc7d986cbc..5e08454d5a 100644 --- a/basis/windows/com/syntax/syntax.factor +++ b/basis/windows/com/syntax/syntax.factor @@ -38,7 +38,7 @@ ERROR: no-com-interface interface ; : (parse-com-function) ( tokens -- definition ) [ second ] - [ first ] + [ first parse-c-type ] [ 3 tail [ CHAR: , swap remove ] map 2 group [ first2 normalize-c-arg 2array ] map From 9b0530dc9772aa314c19a62ec83c295732cd28c6 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 13:01:29 -0800 Subject: [PATCH 151/713] remove string c-types from classes.struct tests --- basis/classes/struct/struct-tests.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/classes/struct/struct-tests.factor b/basis/classes/struct/struct-tests.factor index 44a2be5a70..cddca71188 100644 --- a/basis/classes/struct/struct-tests.factor +++ b/basis/classes/struct/struct-tests.factor @@ -219,7 +219,7 @@ UNION-STRUCT: struct-test-float-and-bits { type bool } { class object } } -} ] [ "struct-test-foo" c-type fields>> ] unit-test +} ] [ struct-test-foo c-type fields>> ] unit-test [ { T{ struct-slot-spec @@ -236,7 +236,7 @@ UNION-STRUCT: struct-test-float-and-bits { class integer } { initial 0 } } -} ] [ "struct-test-float-and-bits" c-type fields>> ] unit-test +} ] [ struct-test-float-and-bits c-type fields>> ] unit-test STRUCT: struct-test-equality-1 { x int } ; From 1b508b9c376ea04577232b50d17d4a9af0545716 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 22 Feb 2010 13:10:20 +1300 Subject: [PATCH 152/713] cocoa.messages: fix --- basis/cocoa/messages/messages.factor | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/basis/cocoa/messages/messages.factor b/basis/cocoa/messages/messages.factor index eab301add7..76b77721ff 100644 --- a/basis/cocoa/messages/messages.factor +++ b/basis/cocoa/messages/messages.factor @@ -236,10 +236,11 @@ ERROR: no-objc-type name ; ] bi ; : import-objc-class ( name quot -- ) - over define-objc-class-word + 2dup swap define-objc-class-word + over objc_getClass [ drop ] [ call( -- ) ] if dup objc_getClass [ - [ objc-class register-objc-methods ] - [ objc-meta-class register-objc-methods ] bi + [ objc_getClass register-objc-methods ] + [ objc_getMetaClass register-objc-methods ] bi ] [ drop ] if ; : root-class ( class -- root ) From 2ab1be755cfa1e20516d945934af7d799a85dfac Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 22 Feb 2010 13:16:34 +1300 Subject: [PATCH 153/713] vocabs.loader: tweak platform checking logic --- core/vocabs/loader/loader.factor | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/core/vocabs/loader/loader.factor b/core/vocabs/loader/loader.factor index 67d7d7677d..c8cf77b795 100644 --- a/core/vocabs/loader/loader.factor +++ b/core/vocabs/loader/loader.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2007, 2009 Eduardo Cavazos, Slava Pestov. +! Copyright (C) 2007, 2010 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: namespaces make sequences io io.files io.pathnames kernel assocs words vocabs definitions parser continuations hashtables @@ -57,9 +57,15 @@ PRIVATE> SYMBOL: load-help? +! Defined by vocabs.metadata +SYMBOL: check-vocab-hook + +check-vocab-hook [ [ drop ] ] initialize + >source-loaded? dup vocab-source-path [ parse-file ] [ [ ] ] if* @@ -99,11 +105,6 @@ PRIVATE> SYMBOL: blacklist -! Defined by vocabs.metadata -SYMBOL: check-vocab-hook - -check-vocab-hook [ [ drop ] ] initialize - From 5fe49b13bfbeba4628f72b3c40ef9ddf26f85000 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 22 Feb 2010 13:16:46 +1300 Subject: [PATCH 154/713] windows.com.prettyprint: remove circular dependency on windows.com --- basis/windows/com/prettyprint/prettyprint.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/windows/com/prettyprint/prettyprint.factor b/basis/windows/com/prettyprint/prettyprint.factor index c75f43f560..ef79a58600 100644 --- a/basis/windows/com/prettyprint/prettyprint.factor +++ b/basis/windows/com/prettyprint/prettyprint.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: windows.com windows.kernel32 windows.ole32 -prettyprint.custom prettyprint.sections sequences ; +USING: windows.kernel32 windows.ole32 prettyprint.custom +prettyprint.sections sequences ; IN: windows.com.prettyprint M: GUID pprint* guid>string "GUID: " prepend text ; From f9d6191c4bc2399d3f66a121351959db23bb4ee1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 22 Feb 2010 13:18:45 +1300 Subject: [PATCH 155/713] cpu.ppc: fix string c-type usage --- basis/cpu/ppc/ppc.factor | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor index 22eb2543b4..6d84aad8d5 100644 --- a/basis/cpu/ppc/ppc.factor +++ b/basis/cpu/ppc/ppc.factor @@ -2,8 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs sequences kernel combinators make math math.order math.ranges system namespaces locals layouts words -alien alien.accessors alien.c-types alien.data literals cpu.architecture -cpu.ppc.assembler cpu.ppc.assembler.backend compiler.cfg.registers +alien alien.accessors alien.c-types alien.complex alien.data +literals cpu.architecture cpu.ppc.assembler +cpu.ppc.assembler.backend compiler.cfg.registers compiler.cfg.instructions compiler.cfg.comparisons compiler.codegen.fixup compiler.cfg.intrinsics compiler.cfg.stack-frame compiler.cfg.build-stack-frame @@ -780,4 +781,4 @@ USE: vocabs.loader { [ os linux? ] [ "cpu.ppc.linux" require ] } } cond -"complex-double" c-type t >>return-in-registers? drop +complex-double c-type t >>return-in-registers? drop From 5955ba06df0505ae5a7f4335170f982e8645355b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 16:27:36 -0800 Subject: [PATCH 156/713] use a "pointer" wrapper tuple to indicate pointer types instead of the current slipshod approach --- basis/alien/arrays/arrays.factor | 5 +- basis/alien/c-types/c-types-tests.factor | 33 ++++--- basis/alien/c-types/c-types.factor | 97 +++++++++++-------- basis/alien/fortran/fortran.factor | 4 +- basis/alien/parser/parser-tests.factor | 18 ++-- basis/alien/parser/parser.factor | 5 +- basis/alien/prettyprint/prettyprint.factor | 3 + basis/alien/syntax/syntax.factor | 3 + basis/classes/struct/struct-tests.factor | 57 +++++++++++ basis/compiler/codegen/codegen.factor | 2 +- .../specialized-arrays.factor | 14 ++- basis/windows/types/types.factor | 6 +- extra/alien/data/map/map.factor | 4 +- 13 files changed, 159 insertions(+), 92 deletions(-) diff --git a/basis/alien/arrays/arrays.factor b/basis/alien/arrays/arrays.factor index 7eed1a0664..cf6e8640f0 100644 --- a/basis/alien/arrays/arrays.factor +++ b/basis/alien/arrays/arrays.factor @@ -99,8 +99,5 @@ M: string-type c-type-getter M: string-type c-type-setter drop [ set-alien-cell ] ; -{ char* utf8 } char* typedef -char* uchar* typedef +TYPEDEF: { char* utf8 } char* -char char* "pointer-c-type" set-word-prop -uchar uchar* "pointer-c-type" set-word-prop diff --git a/basis/alien/c-types/c-types-tests.factor b/basis/alien/c-types/c-types-tests.factor index faee8955e9..5f903c9a34 100644 --- a/basis/alien/c-types/c-types-tests.factor +++ b/basis/alien/c-types/c-types-tests.factor @@ -16,41 +16,46 @@ UNION-STRUCT: foo { a int } { b int } ; -[ f ] [ char resolve-pointer-type c-type void* c-type eq? ] unit-test -[ t ] [ char* resolve-pointer-type c-type void* c-type eq? ] unit-test +[ t ] [ pointer: void c-type void* c-type eq? ] unit-test +[ t ] [ pointer: int c-type void* c-type eq? ] unit-test +[ t ] [ pointer: int* c-type void* c-type eq? ] unit-test +[ f ] [ pointer: foo c-type void* c-type eq? ] unit-test +[ t ] [ pointer: foo* c-type void* c-type eq? ] unit-test + +[ t ] [ pointer: char c-type c-string c-type eq? ] unit-test + +[ t ] [ pointer: foo c-type-boxer-quot foo c-type-boxer-quot = ] unit-test [ t ] [ foo heap-size int heap-size = ] unit-test TYPEDEF: int MyInt -[ t ] [ int c-type MyInt c-type eq? ] unit-test -[ t ] [ void* c-type MyInt resolve-pointer-type c-type eq? ] unit-test - -TYPEDEF: char MyChar - -[ t ] [ char c-type MyChar c-type eq? ] unit-test -[ f ] [ void* c-type MyChar resolve-pointer-type c-type eq? ] unit-test -[ t ] [ char* c-type MyChar resolve-pointer-type c-type eq? ] unit-test +[ t ] [ int c-type MyInt c-type eq? ] unit-test +[ t ] [ void* c-type pointer: MyInt c-type eq? ] unit-test [ 32 ] [ { int 8 } heap-size ] unit-test TYPEDEF: char* MyString -[ t ] [ char* c-type MyString c-type eq? ] unit-test -[ t ] [ void* c-type MyString resolve-pointer-type c-type eq? ] unit-test +[ t ] [ c-string c-type MyString c-type eq? ] unit-test +[ t ] [ void* c-type pointer: MyString c-type eq? ] unit-test TYPEDEF: int* MyIntArray [ t ] [ void* c-type MyIntArray c-type eq? ] unit-test -TYPEDEF: uchar* MyLPBYTE +TYPEDEF: c-string MyLPBYTE -[ t ] [ { char* utf8 } c-type MyLPBYTE c-type = ] unit-test +[ t ] [ { c-string utf8 } c-type MyLPBYTE c-type = ] unit-test [ 0 B{ 1 2 3 4 } ] must-fail +C-TYPE: MyOpaqueType + +[ f ] [ pointer: MyOpaqueType c-type void* c-type eq? ] unit-test + os windows? cpu x86.64? and [ [ -2147467259 ] [ 2147500037 *long ] unit-test ] when diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor index a929cba954..4a7fd840ef 100644 --- a/basis/alien/c-types/c-types.factor +++ b/basis/alien/c-types/c-types.factor @@ -17,7 +17,7 @@ SYMBOLS: long ulong longlong ulonglong float double - void* bool + bool void* void ; DEFER: @@ -48,28 +48,18 @@ ERROR: no-c-type name ; PREDICATE: c-type-word < word "c-type" word-prop ; -UNION: c-type-name string c-type-word ; - ! C type protocol GENERIC: c-type ( name -- c-type ) foldable -GENERIC: resolve-pointer-type ( name -- c-type ) - -<< \ void \ void* "pointer-c-type" set-word-prop >> - : void? ( c-type -- ? ) - { void "void" } member? ; + void = ; inline -M: word resolve-pointer-type - dup "pointer-c-type" word-prop - [ ] [ drop void* ] ?if ; - -M: array resolve-pointer-type - first resolve-pointer-type ; +TUPLE: pointer { to initial: void read-only } ; +C: pointer : resolve-typedef ( name -- c-type ) dup void? [ no-c-type ] when - dup c-type-name? [ c-type ] when ; + dup c-type-word? [ c-type ] when ; > ; -M: c-type-name c-type-class c-type c-type-class ; +M: c-type-word c-type-class c-type c-type-class ; GENERIC: c-type-boxed-class ( name -- class ) M: abstract-c-type c-type-boxed-class boxed-class>> ; -M: c-type-name c-type-boxed-class c-type c-type-boxed-class ; +M: c-type-word c-type-boxed-class c-type c-type-boxed-class ; GENERIC: c-type-boxer ( name -- boxer ) M: c-type c-type-boxer boxer>> ; -M: c-type-name c-type-boxer c-type c-type-boxer ; +M: c-type-word c-type-boxer c-type c-type-boxer ; GENERIC: c-type-boxer-quot ( name -- quot ) M: abstract-c-type c-type-boxer-quot boxer-quot>> ; -M: c-type-name c-type-boxer-quot c-type c-type-boxer-quot ; +M: c-type-word c-type-boxer-quot c-type c-type-boxer-quot ; GENERIC: c-type-unboxer ( name -- boxer ) M: c-type c-type-unboxer unboxer>> ; -M: c-type-name c-type-unboxer c-type c-type-unboxer ; +M: c-type-word c-type-unboxer c-type c-type-unboxer ; GENERIC: c-type-unboxer-quot ( name -- quot ) M: abstract-c-type c-type-unboxer-quot unboxer-quot>> ; -M: c-type-name c-type-unboxer-quot c-type c-type-unboxer-quot ; +M: c-type-word c-type-unboxer-quot c-type c-type-unboxer-quot ; GENERIC: c-type-rep ( name -- rep ) M: c-type c-type-rep rep>> ; -M: c-type-name c-type-rep c-type c-type-rep ; +M: c-type-word c-type-rep c-type c-type-rep ; GENERIC: c-type-getter ( name -- quot ) M: c-type c-type-getter getter>> ; -M: c-type-name c-type-getter c-type c-type-getter ; +M: c-type-word c-type-getter c-type c-type-getter ; GENERIC: c-type-setter ( name -- quot ) M: c-type c-type-setter setter>> ; -M: c-type-name c-type-setter c-type c-type-setter ; +M: c-type-word c-type-setter c-type c-type-setter ; GENERIC: c-type-align ( name -- n ) M: abstract-c-type c-type-align align>> ; -M: c-type-name c-type-align c-type c-type-align ; +M: c-type-word c-type-align c-type c-type-align ; GENERIC: c-type-align-first ( name -- n ) -M: c-type-name c-type-align-first c-type c-type-align-first ; +M: c-type-word c-type-align-first c-type c-type-align-first ; M: abstract-c-type c-type-align-first align-first>> ; @@ -162,7 +152,7 @@ GENERIC: c-type-stack-align? ( name -- ? ) M: c-type c-type-stack-align? stack-align?>> ; -M: c-type-name c-type-stack-align? c-type c-type-stack-align? ; +M: c-type-word c-type-stack-align? c-type c-type-stack-align? ; : c-type-box ( n c-type -- ) [ c-type-rep ] [ c-type-boxer [ "No boxer" throw ] unless* ] bi @@ -176,37 +166,37 @@ GENERIC: box-parameter ( n c-type -- ) M: c-type box-parameter c-type-box ; -M: c-type-name box-parameter c-type box-parameter ; +M: c-type-word box-parameter c-type box-parameter ; GENERIC: box-return ( c-type -- ) M: c-type box-return f swap c-type-box ; -M: c-type-name box-return c-type box-return ; +M: c-type-word box-return c-type box-return ; GENERIC: unbox-parameter ( n c-type -- ) M: c-type unbox-parameter c-type-unbox ; -M: c-type-name unbox-parameter c-type unbox-parameter ; +M: c-type-word unbox-parameter c-type unbox-parameter ; GENERIC: unbox-return ( c-type -- ) M: c-type unbox-return f swap c-type-unbox ; -M: c-type-name unbox-return c-type unbox-return ; +M: c-type-word unbox-return c-type unbox-return ; : little-endian? ( -- ? ) 1 *char 1 = ; foldable GENERIC: heap-size ( name -- size ) -M: c-type-name heap-size c-type heap-size ; +M: c-type-word heap-size c-type heap-size ; M: abstract-c-type heap-size size>> ; GENERIC: stack-size ( name -- size ) -M: c-type-name stack-size c-type stack-size ; +M: c-type-word stack-size c-type stack-size ; M: c-type stack-size size>> cell align ; @@ -243,20 +233,19 @@ MIXIN: value-type GENERIC: typedef ( old new -- ) PREDICATE: typedef-word < c-type-word - "c-type" word-prop c-type-name? ; + "c-type" word-prop c-type-word? ; M: word typedef ( old new -- ) { [ nip define-symbol ] [ swap "c-type" set-word-prop ] - [ - swap dup c-type-name? [ - resolve-pointer-type - "pointer-c-type" set-word-prop - ] [ 2drop ] if - ] } 2cleave ; +M: pointer typedef ( old new -- ) + to>> dup c-type-word? + [ ] + [ 2drop ] if ; + TUPLE: long-long-type < c-type ; : ( -- c-type ) @@ -302,7 +291,31 @@ CONSTANT: primitive-types SYMBOLS: ptrdiff_t intptr_t uintptr_t size_t - char* uchar* ; + char* ; + +>boxer-quot ; + +: string-pointer-type? ( type -- ? ) + dup pointer? [ drop f ] + [ resolve-typedef { char uchar } member? ] if ; + +: primitive-pointer-type? ( type -- ? ) + dup pointer? [ drop t ] [ + resolve-typedef [ void? ] [ primitive-types member? ] bi or + ] if ; + +PRIVATE> + +M: pointer c-type + [ \ void* c-type ] dip + to>> { + { [ dup string-pointer-type? ] [ drop \ char* c-type ] } + { [ dup primitive-pointer-type? ] [ drop ] } + [ (pointer-c-type) ] + } cond ; : 8-byte-alignment ( c-type -- c-type ) { diff --git a/basis/alien/fortran/fortran.factor b/basis/alien/fortran/fortran.factor index 65e927f85a..9255c66c9f 100644 --- a/basis/alien/fortran/fortran.factor +++ b/basis/alien/fortran/fortran.factor @@ -392,13 +392,13 @@ PRIVATE> : fortran-arg-type>c-type ( fortran-type -- c-type added-args ) parse-fortran-type - [ (fortran-type>c-type) resolve-pointer-type ] + [ (fortran-type>c-type) ] [ added-c-args ] bi ; : fortran-ret-type>c-type ( fortran-type -- c-type added-args ) parse-fortran-type dup returns-by-value? [ (fortran-ret-type>c-type) { } ] [ c:void swap - [ added-c-args ] [ (fortran-type>c-type) resolve-pointer-type ] bi prefix + [ added-c-args ] [ (fortran-type>c-type) ] bi prefix ] if ; : fortran-arg-types>c-types ( fortran-types -- c-types ) diff --git a/basis/alien/parser/parser-tests.factor b/basis/alien/parser/parser-tests.factor index e405f49995..b7f7b10628 100644 --- a/basis/alien/parser/parser-tests.factor +++ b/basis/alien/parser/parser-tests.factor @@ -18,20 +18,16 @@ CONSTANT: eleven 11 [ { int 5 } ] [ "int[5]" parse-c-type ] unit-test [ { int 5 10 11 } ] [ "int[5][10][11]" parse-c-type ] unit-test [ { int 5 10 eleven } ] [ "int[5][10][eleven]" parse-c-type ] unit-test - [ void* ] [ "int*" parse-c-type ] unit-test - [ void* ] [ "int**" parse-c-type ] unit-test - [ void* ] [ "int***" parse-c-type ] unit-test - [ void* ] [ "int****" parse-c-type ] unit-test - [ char* ] [ "char*" parse-c-type ] unit-test - [ void* ] [ "char**" parse-c-type ] unit-test - [ void* ] [ "char***" parse-c-type ] unit-test - [ void* ] [ "char****" parse-c-type ] unit-test + [ pointer: void ] [ "void*" parse-c-type ] unit-test + [ pointer: int ] [ "int*" parse-c-type ] unit-test + [ pointer: int* ] [ "int**" parse-c-type ] unit-test + [ pointer: int** ] [ "int***" parse-c-type ] unit-test + [ pointer: int*** ] [ "int****" parse-c-type ] unit-test + [ pointer: char ] [ "char*" parse-c-type ] unit-test [ char2 ] [ "char2" parse-c-type ] unit-test - [ char* ] [ "char2*" parse-c-type ] unit-test + [ pointer: char2 ] [ "char2*" parse-c-type ] unit-test - [ "not-c-type" parse-c-type ] [ no-c-type? ] must-fail-with [ "not-word" parse-c-type ] [ error>> no-word-error? ] must-fail-with - ] with-file-vocabs ! Reported by mnestic diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index 0cf495fd25..09ee88c173 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -19,13 +19,12 @@ IN: alien.parser { [ dup "void" = ] [ drop void ] } { [ CHAR: ] over member? ] [ parse-array-type parse-c-type-name prefix ] } { [ dup search ] [ parse-c-type-name ] } - { [ "**" ?tail ] [ drop void* ] } - { [ "*" ?tail ] [ parse-c-type-name resolve-pointer-type ] } + { [ "*" ?tail ] [ (parse-c-type) ] } [ dup search [ ] [ no-word ] ?if ] } cond ; : valid-c-type? ( c-type -- ? ) - { [ array? ] [ c-type-name? ] [ void? ] } 1|| ; + { [ array? ] [ c-type-word? ] [ pointer? ] [ void? ] } 1|| ; : parse-c-type ( string -- type ) (parse-c-type) dup valid-c-type? [ no-c-type ] unless ; diff --git a/basis/alien/prettyprint/prettyprint.factor b/basis/alien/prettyprint/prettyprint.factor index ded8f692cd..6bfbf313a1 100644 --- a/basis/alien/prettyprint/prettyprint.factor +++ b/basis/alien/prettyprint/prettyprint.factor @@ -21,10 +21,13 @@ M: c-type-word declarations. drop ; GENERIC: pprint-c-type ( c-type -- ) M: word pprint-c-type pprint-word ; +M: pointer pprint-c-type to>> pprint-c-type "*" text ; M: wrapper pprint-c-type wrapped>> pprint-word ; M: string pprint-c-type text ; M: array pprint-c-type pprint* ; +M: pointer pprint* \ pointer: pprint-word to>> pprint-c-type ; + M: typedef-word definer drop \ TYPEDEF: f ; M: typedef-word synopsis* diff --git a/basis/alien/syntax/syntax.factor b/basis/alien/syntax/syntax.factor index 295bcff089..9eb8ca6287 100644 --- a/basis/alien/syntax/syntax.factor +++ b/basis/alien/syntax/syntax.factor @@ -47,3 +47,6 @@ SYNTAX: &: [ nip ] [ global-quot ] 2bi (( -- value )) define-declared ; SYNTAX: C-GLOBAL: scan-c-type CREATE-WORD define-global ; + +SYNTAX: pointer: + scan-c-type suffix! ; diff --git a/basis/classes/struct/struct-tests.factor b/basis/classes/struct/struct-tests.factor index cddca71188..0316b1fae0 100644 --- a/basis/classes/struct/struct-tests.factor +++ b/basis/classes/struct/struct-tests.factor @@ -374,6 +374,63 @@ STRUCT: bit-field-test [ 1 ] [ bit-field-test 257 >>c c>> ] unit-test [ 3 ] [ bit-field-test heap-size ] unit-test +STRUCT: referent + { y int } ; +STRUCT: referrer + { x referent* } ; + +[ 57 ] [ + [ + referrer + referent malloc-struct &free + 57 >>y + >>x + x>> y>> + ] with-destructors +] unit-test + +STRUCT: self-referent + { x self-referent* } + { y int } ; + +[ 75 ] [ + [ + self-referent + self-referent malloc-struct &free + 75 >>y + >>x + x>> y>> + ] with-destructors +] unit-test + +C-TYPE: forward-referent +STRUCT: backward-referent + { x forward-referent* } + { y int } ; +STRUCT: forward-referent + { x backward-referent* } + { y int } ; + +[ 41 ] [ + [ + forward-referent + backward-referent malloc-struct &free + 41 >>y + >>x + x>> y>> + ] with-destructors +] unit-test + +[ 14 ] [ + [ + backward-referent + forward-referent malloc-struct &free + 14 >>y + >>x + x>> y>> + ] with-destructors +] unit-test + cpu ppc? [ STRUCT: ppc-align-test-1 { x longlong } diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index 963ed0ab28..d6e58f7ac1 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -325,7 +325,7 @@ GENERIC: flatten-value-type ( type -- types ) M: object flatten-value-type 1array ; M: struct-c-type flatten-value-type (flatten-int-type) ; M: long-long-type flatten-value-type (flatten-int-type) ; -M: c-type-name flatten-value-type c-type flatten-value-type ; +M: c-type-word flatten-value-type c-type flatten-value-type ; : flatten-value-types ( params -- params ) #! Convert value type structs to consecutive void*s. diff --git a/basis/specialized-arrays/specialized-arrays.factor b/basis/specialized-arrays/specialized-arrays.factor index fe2a93844c..67689998ab 100644 --- a/basis/specialized-arrays/specialized-arrays.factor +++ b/basis/specialized-arrays/specialized-arrays.factor @@ -116,12 +116,10 @@ M: A v*high [ * \ T heap-size neg shift ] 2map ; inline ;FUNCTOR -: (underlying-type) ( word -- c-type ) "c-type" word-prop ; inline - : underlying-type ( c-type -- c-type' ) - dup (underlying-type) { + dup "c-type" word-prop { { [ dup not ] [ drop no-c-type ] } - { [ dup c-type-name? ] [ nip underlying-type ] } + { [ dup c-type-word? ] [ nip underlying-type ] } [ drop ] } cond ; @@ -140,21 +138,21 @@ PRIVATE> [ specialized-array-vocab ] [ '[ _ define-array ] ] bi generate-vocab ; -M: c-type-name require-c-array define-array-vocab drop ; +M: c-type-word require-c-array define-array-vocab drop ; ERROR: specialized-array-vocab-not-loaded c-type ; -M: c-type-name c-array-constructor +M: c-type-word c-array-constructor underlying-type dup [ name>> "<" "-array>" surround ] [ specialized-array-vocab ] bi lookup [ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable -M: c-type-name c-(array)-constructor +M: c-type-word c-(array)-constructor underlying-type dup [ name>> "(" "-array)" surround ] [ specialized-array-vocab ] bi lookup [ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable -M: c-type-name c-direct-array-constructor +M: c-type-word c-direct-array-constructor underlying-type dup [ name>> "" surround ] [ specialized-array-vocab ] bi lookup [ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable diff --git a/basis/windows/types/types.factor b/basis/windows/types/types.factor index 9e322d9cde..4f527513fc 100644 --- a/basis/windows/types/types.factor +++ b/basis/windows/types/types.factor @@ -11,11 +11,7 @@ TYPEDEF: uchar UCHAR TYPEDEF: uchar BYTE TYPEDEF: ushort wchar_t -SYMBOL: wchar_t* -<< -{ char* utf16n } \ wchar_t* typedef -\ wchar_t \ wchar_t* "pointer-c-type" set-word-prop ->> +TYPEDEF: { char* utf16n } wchar_t* TYPEDEF: wchar_t WCHAR diff --git a/extra/alien/data/map/map.factor b/extra/alien/data/map/map.factor index 6c93e8f4b6..06997bce56 100644 --- a/extra/alien/data/map/map.factor +++ b/extra/alien/data/map/map.factor @@ -54,7 +54,7 @@ INSTANCE: data-map-param immutable-sequence nip '[ _ ] ; : [>param] ( type -- quot ) - c-type-count over c-type-name? + c-type-count over c-type-word? [ [>c-type-param] ] [ [>object-param] ] if ; MACRO: >param ( in -- quot: ( array -- param ) ) @@ -74,7 +74,7 @@ MACRO: >param ( in -- quot: ( array -- param ) ) "Factor sequences as data-map outputs not supported" throw ; : [alloc-param] ( type -- quot ) - c-type-count over c-type-name? + c-type-count over c-type-word? [ [alloc-c-type-param] ] [ [alloc-object-param] ] if ; MACRO: alloc-param ( out -- quot: ( len -- param ) ) From 52a8c3ebc9cec2943ad1dc02a69d6d66cc62e56f Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sun, 21 Feb 2010 16:42:31 -0800 Subject: [PATCH 157/713] FUEL: Add UNION-STRUCT: to syntax highlighting. --- misc/fuel/fuel-syntax.el | 912 +++++++++++++++++++-------------------- 1 file changed, 456 insertions(+), 456 deletions(-) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index 1b060e5dd1..7de627f8f5 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -1,456 +1,456 @@ -;;; fuel-syntax.el --- auxiliar definitions for factor code navigation. - -;; Copyright (C) 2008, 2009 Jose Antonio Ortega Ruiz -;; See http://factorcode.org/license.txt for BSD license. - -;; Author: Jose Antonio Ortega Ruiz -;; Keywords: languages - -;;; Commentary: - -;; Auxiliar constants and functions to parse factor code. - -;;; Code: - -(require 'thingatpt) - - -;;; Thing-at-point support for factor symbols: - -(defun fuel-syntax--beginning-of-symbol () - "Move point to the beginning of the current symbol." - (skip-syntax-backward "w_()")) - -(defsubst fuel-syntax--beginning-of-symbol-pos () - (save-excursion (fuel-syntax--beginning-of-symbol) (point))) - -(defun fuel-syntax--end-of-symbol () - "Move point to the end of the current symbol." - (skip-syntax-forward "w_()")) - -(defsubst fuel-syntax--end-of-symbol-pos () - (save-excursion (fuel-syntax--end-of-symbol) (point))) - -(put 'factor-symbol 'end-op 'fuel-syntax--end-of-symbol) -(put 'factor-symbol 'beginning-op 'fuel-syntax--beginning-of-symbol) - -(defsubst fuel-syntax-symbol-at-point () - (let ((s (substring-no-properties (thing-at-point 'factor-symbol)))) - (and (> (length s) 0) s))) - - - -;;; Regexps galore: - -(defconst fuel-syntax--parsing-words - '(":" "::" ";" "&:" "<<" ">" - "ABOUT:" "ALIAS:" "ALIEN:" "ARTICLE:" - "B" "BIN:" - "C:" "CALLBACK:" "C-ENUM:" "C-STRUCT:" "C-TYPE:" "C-UNION:" "CHAR:" "CONSTANT:" "call-next-method" - "DEFER:" - "EBNF:" ";EBNF" "ERROR:" "EXCLUDE:" - "f" "FORGET:" "FROM:" "FUNCTION:" - "GAME:" "GENERIC#" "GENERIC:" - "GLSL-SHADER:" "GLSL-PROGRAM:" - "HELP:" "HEX:" "HOOK:" - "IN:" "initial:" "INSTANCE:" "INTERSECTION:" - "LIBRARY:" - "M:" "M::" "MACRO:" "MACRO::" "MAIN:" "MATH:" - "MEMO:" "MEMO:" "METHOD:" "MIXIN:" - "OCT:" - "POSTPONE:" "PREDICATE:" "PRIMITIVE:" "PRIVATE>" "PROVIDE:" - "QUALIFIED-WITH:" "QUALIFIED:" - "read-only" "RENAME:" "REQUIRE:" "REQUIRES:" - "SINGLETON:" "SINGLETONS:" "SLOT:" "SPECIALIZED-ARRAY:" "SPECIALIZED-ARRAYS:" "STRING:" "STRUCT:" "SYMBOL:" "SYMBOLS:" "SYNTAX:" - "TUPLE:" "t" "t?" "TYPEDEF:" "TYPED:" "TYPED::" - "UNIFORM-TUPLE:" "UNION:" "USE:" "USING:" - "VARS:" "VERTEX-FORMAT:")) - -(defconst fuel-syntax--parsing-words-regex - (regexp-opt fuel-syntax--parsing-words 'words)) - -(defconst fuel-syntax--bracers - '("B" "BV" "C" "CS" "H" "T" "V" "W")) - -(defconst fuel-syntax--brace-words-regex - (format "%s{" (regexp-opt fuel-syntax--bracers t))) - -(defconst fuel-syntax--declaration-words - '("flushable" "foldable" "inline" "parsing" "recursive" "delimiter")) - -(defconst fuel-syntax--declaration-words-regex - (regexp-opt fuel-syntax--declaration-words 'words)) - -(defsubst fuel-syntax--second-word-regex (prefixes) - (format "%s +\\([^ \r\n]+\\)" (regexp-opt prefixes t))) - -(defconst fuel-syntax--method-definition-regex - "^M::? +\\([^ ]+\\) +\\([^ ]+\\)") - -(defconst fuel-syntax--integer-regex - "\\_<-?[0-9]+\\_>") - -(defconst fuel-syntax--raw-float-regex - "[0-9]*\\.[0-9]*\\([eE][+-]?[0-9]+\\)?") - -(defconst fuel-syntax--float-regex - (format "\\_<-?%s\\_>" fuel-syntax--raw-float-regex)) - -(defconst fuel-syntax--number-regex - (format "\\([0-9]+\\|%s\\)" fuel-syntax--raw-float-regex)) - -(defconst fuel-syntax--ratio-regex - (format "\\_<[+-]?%s/-?%s\\_>" - fuel-syntax--number-regex - fuel-syntax--number-regex)) - -(defconst fuel-syntax--bad-string-regex - "\\_<\"[^>]\\([^\"\n]\\|\\\\\"\\)*\n") - -(defconst fuel-syntax--word-definition-regex - (format "\\_<\\(%s\\)?: +\\_<\\(\\w+\\)\\_>" - (regexp-opt - '(":" "GENERIC" "DEFER" "HOOK" "MAIN" "MATH" "POSTPONE" - "SYMBOL" "SYNTAX" "TYPED" "RENAME")))) - -(defconst fuel-syntax--alias-definition-regex - "^ALIAS: +\\(\\_<.+?\\_>\\) +\\(\\_<.+?\\_>\\)") - -(defconst fuel-syntax--vocab-ref-regexp - (fuel-syntax--second-word-regex - '("IN:" "USE:" "FROM:" "EXCLUDE:" "QUALIFIED:" "QUALIFIED-WITH:"))) - -(defconst fuel-syntax--int-constant-def-regex - (fuel-syntax--second-word-regex '("ALIEN:" "CHAR:" "BIN:" "HEX:" "OCT:"))) - -(defconst fuel-syntax--type-definition-regex - (fuel-syntax--second-word-regex - '("C-STRUCT:" "C-UNION:" "MIXIN:" "TUPLE:" "SINGLETON:" "SPECIALIZED-ARRAY:" "STRUCT:" "UNION:"))) - -(defconst fuel-syntax--tuple-decl-regex - "^TUPLE: +\\([^ \n]+\\) +< +\\([^ \n]+\\)\\_>") - -(defconst fuel-syntax--constructor-regex "<[^ >]+>") - -(defconst fuel-syntax--getter-regex "\\(^\\|\\_<\\)[^ ]+?>>\\_>") -(defconst fuel-syntax--setter-regex "\\_<>>.+?\\_>") - -(defconst fuel-syntax--symbol-definition-regex - (fuel-syntax--second-word-regex '("&:" "SYMBOL:" "VAR:"))) - -(defconst fuel-syntax--stack-effect-regex - "\\( ( [^\n]* )\\)\\|\\( (( [^\n]* ))\\)") - -(defconst fuel-syntax--using-lines-regex "^USING: +\\([^;]+\\);") - -(defconst fuel-syntax--use-line-regex "^USE: +\\(.*\\)$") - -(defconst fuel-syntax--current-vocab-regex "^IN: +\\([^ \r\n\f]+\\)") - -(defconst fuel-syntax--sub-vocab-regex "^<\\([^ \n]+\\) *$") - -(defconst fuel-syntax--alien-function-regex - "\\_" " +\\(\\w+\\)\\( .*\\)?$") - - -;;; Factor syntax table - -(setq fuel-syntax--syntax-table - (let ((table (make-syntax-table))) - ;; Default is word constituent - (dotimes (i 256) - (modify-syntax-entry i "w" table)) - ;; Whitespace (TAB is not whitespace) - (modify-syntax-entry ?\f " " table) - (modify-syntax-entry ?\r " " table) - (modify-syntax-entry ?\ " " table) - (modify-syntax-entry ?\n " " table) - table)) - -(defconst fuel-syntax--syntactic-keywords - `(;; Strings and chars - ("\\_<<\\(\"\\)\\_>" (1 "\\_>" (1 ">b")) - ("\\( \\|^\\)\\(DLL\\|P\\|SBUF\\)?\\(\"\\)\\(\\([^\n\r\f\"\\]\\|\\\\.\\)*\\)\\(\"\\)" - (3 "\"") (6 "\"")) - ("CHAR: \\(\"\\) [^\\\"]*?\\(\"\\)\\([^\\\"]\\|\\\\.\\)*?\\(\"\\)" - (1 "w") (2 "b")) - ("\\(CHAR:\\|\\\\\\) \\(\\w\\|!\\)\\( \\|$\\)" (2 "w")) - ;; Comments - ("\\_<\\(#?!\\) .*\\(\n\\|$\\)" (1 "<") (2 ">")) - ("\\_<\\(#?!\\)\\(\n\\|$\\)" (1 "<") (2 ">")) - ;; postpone - ("\\_b")) - ;; Multiline constructs - ("\\_<\\(E\\)BNF:\\( \\|\n\\)" (1 "" (1 ">b")) - ("\\_<\\(U\\)SING: \\(;\\)" (1 "b")) - ("\\_b")) - ("\\_\\)" (1 "\\)" - (2 "" (1 ">b")) - ;; Let and lambda: - ("\\_<\\(!(\\) .* \\()\\)" (1 "<") (2 ">")) - ("\\(\\[\\)\\(let\\|let\\*\\)\\( \\|$\\)" (1 "(]")) - ("\\(\\[\\)\\(|\\) +[^|]* \\(|\\)" (1 "(]") (2 "(|") (3 ")|")) - (" \\(|\\) " (1 "(|")) - (" \\(|\\)$" (1 ")")) - ;; Opening brace words: - ("\\_<\\w*\\({\\)\\_>" (1 "(}")) - ("\\_<\\(}\\)\\_>" (1 "){")) - ;; Parenthesis: - ("\\_<\\((\\)\\_>" (1 "()")) - ("\\_<\\w*\\((\\)\\_>" (1 "()")) - ("\\_<\\()\\)\\_>" (1 ")(")) - ("\\_<(\\((\\)\\_>" (1 "()")) - ("\\_<\\()\\))\\_>" (1 ")(")) - ;; Quotations: - ("\\_<'\\(\\[\\)\\_>" (1 "(]")) ; fried - ("\\_<$\\(\\[\\)\\_>" (1 "(]")) ; parse-time - ("\\_<\\(\\[\\)\\_>" (1 "(]")) - ("\\_<\\(\\]\\)\\_>" (1 ")[")))) - - -;;; Source code analysis: - -(defsubst fuel-syntax--brackets-depth () - (nth 0 (syntax-ppss))) - -(defsubst fuel-syntax--brackets-start () - (nth 1 (syntax-ppss))) - -(defun fuel-syntax--brackets-end () - (save-excursion - (goto-char (fuel-syntax--brackets-start)) - (condition-case nil - (progn (forward-sexp) - (1- (point))) - (error -1)))) - -(defsubst fuel-syntax--indentation-at (pos) - (save-excursion (goto-char pos) (current-indentation))) - -(defsubst fuel-syntax--increased-indentation (&optional i) - (+ (or i (current-indentation)) factor-indent-width)) -(defsubst fuel-syntax--decreased-indentation (&optional i) - (- (or i (current-indentation)) factor-indent-width)) - -(defsubst fuel-syntax--at-begin-of-def () - (looking-at fuel-syntax--begin-of-def-regex)) - -(defsubst fuel-syntax--at-begin-of-indent-def () - (looking-at fuel-syntax--indent-def-start-regex)) - -(defsubst fuel-syntax--at-end-of-def () - (looking-at fuel-syntax--end-of-def-regex)) - -(defsubst fuel-syntax--looking-at-emptiness () - (looking-at "^[ ]*$\\|$")) - -(defsubst fuel-syntax--is-last-char (pos) - (save-excursion - (goto-char (1+ pos)) - (looking-at-p "[ ]*$"))) - -(defsubst fuel-syntax--line-offset (pos) - (- pos (save-excursion - (goto-char pos) - (beginning-of-line) - (point)))) - -(defun fuel-syntax--previous-non-blank () - (forward-line -1) - (while (and (not (bobp)) (fuel-syntax--looking-at-emptiness)) - (forward-line -1))) - -(defun fuel-syntax--beginning-of-block-pos () - (save-excursion - (if (> (fuel-syntax--brackets-depth) 0) - (fuel-syntax--brackets-start) - (fuel-syntax--beginning-of-defun) - (point)))) - -(defun fuel-syntax--at-setter-line () - (save-excursion - (beginning-of-line) - (when (re-search-forward fuel-syntax--setter-regex - (line-end-position) - t) - (let* ((to (match-beginning 0)) - (from (fuel-syntax--beginning-of-block-pos))) - (goto-char from) - (let ((depth (fuel-syntax--brackets-depth))) - (and (or (re-search-forward fuel-syntax--constructor-regex to t) - (re-search-forward fuel-syntax--setter-regex to t)) - (= depth (fuel-syntax--brackets-depth)))))))) - -(defun fuel-syntax--at-constructor-line () - (save-excursion - (beginning-of-line) - (re-search-forward fuel-syntax--constructor-regex (line-end-position) t))) - -(defsubst fuel-syntax--at-using () - (looking-at fuel-syntax--using-lines-regex)) - -(defun fuel-syntax--in-using () - (let ((p (point))) - (save-excursion - (and (re-search-backward "^USING: " nil t) - (re-search-forward " ;" nil t) - (< p (match-end 0)))))) - -(defsubst fuel-syntax--beginning-of-defun (&optional times) - (re-search-backward fuel-syntax--begin-of-def-regex nil t times)) - -(defsubst fuel-syntax--end-of-defun () - (re-search-forward fuel-syntax--end-of-def-regex nil t)) - -(defsubst fuel-syntax--end-of-defun-pos () - (save-excursion - (re-search-forward fuel-syntax--end-of-def-regex nil t) - (point))) - -(defun fuel-syntax--beginning-of-body () - (let ((p (point))) - (and (fuel-syntax--beginning-of-defun) - (re-search-forward fuel-syntax--defun-signature-regex p t) - (not (re-search-forward fuel-syntax--end-of-def-regex p t))))) - -(defun fuel-syntax--beginning-of-sexp () - (if (> (fuel-syntax--brackets-depth) 0) - (goto-char (fuel-syntax--brackets-start)) - (fuel-syntax--beginning-of-body))) - -(defsubst fuel-syntax--beginning-of-sexp-pos () - (save-excursion (fuel-syntax--beginning-of-sexp) (point))) - - -;;; USING/IN: - -(make-variable-buffer-local - (defvar fuel-syntax--current-vocab-function 'fuel-syntax--find-in)) - -(defsubst fuel-syntax--current-vocab () - (funcall fuel-syntax--current-vocab-function)) - -(defun fuel-syntax--find-in () - (save-excursion - (when (re-search-backward fuel-syntax--current-vocab-regex nil t) - (match-string-no-properties 1)))) - -(make-variable-buffer-local - (defvar fuel-syntax--usings-function 'fuel-syntax--find-usings)) - -(defsubst fuel-syntax--usings () - (funcall fuel-syntax--usings-function)) - -(defun fuel-syntax--file-has-private () - (save-excursion - (goto-char (point-min)) - (and (re-search-forward "\\_<" nil t) - (re-search-forward "\\_\\_>" nil t)))) - -(defun fuel-syntax--find-usings (&optional no-private) - (save-excursion - (let ((usings)) - (goto-char (point-max)) - (while (re-search-backward fuel-syntax--using-lines-regex nil t) - (dolist (u (split-string (match-string-no-properties 1) nil t)) - (push u usings))) - (when (and (not no-private) (fuel-syntax--file-has-private)) - (goto-char (point-max)) - (push (concat (fuel-syntax--find-in) ".private") usings)) - usings))) - - -(provide 'fuel-syntax) -;;; fuel-syntax.el ends here +;;; fuel-syntax.el --- auxiliar definitions for factor code navigation. + +;; Copyright (C) 2008, 2009 Jose Antonio Ortega Ruiz +;; See http://factorcode.org/license.txt for BSD license. + +;; Author: Jose Antonio Ortega Ruiz +;; Keywords: languages + +;;; Commentary: + +;; Auxiliar constants and functions to parse factor code. + +;;; Code: + +(require 'thingatpt) + + +;;; Thing-at-point support for factor symbols: + +(defun fuel-syntax--beginning-of-symbol () + "Move point to the beginning of the current symbol." + (skip-syntax-backward "w_()")) + +(defsubst fuel-syntax--beginning-of-symbol-pos () + (save-excursion (fuel-syntax--beginning-of-symbol) (point))) + +(defun fuel-syntax--end-of-symbol () + "Move point to the end of the current symbol." + (skip-syntax-forward "w_()")) + +(defsubst fuel-syntax--end-of-symbol-pos () + (save-excursion (fuel-syntax--end-of-symbol) (point))) + +(put 'factor-symbol 'end-op 'fuel-syntax--end-of-symbol) +(put 'factor-symbol 'beginning-op 'fuel-syntax--beginning-of-symbol) + +(defsubst fuel-syntax-symbol-at-point () + (let ((s (substring-no-properties (thing-at-point 'factor-symbol)))) + (and (> (length s) 0) s))) + + + +;;; Regexps galore: + +(defconst fuel-syntax--parsing-words + '(":" "::" ";" "&:" "<<" ">" + "ABOUT:" "ALIAS:" "ALIEN:" "ARTICLE:" + "B" "BIN:" + "C:" "CALLBACK:" "C-ENUM:" "C-STRUCT:" "C-TYPE:" "C-UNION:" "CHAR:" "CONSTANT:" "call-next-method" + "DEFER:" + "EBNF:" ";EBNF" "ERROR:" "EXCLUDE:" + "f" "FORGET:" "FROM:" "FUNCTION:" + "GAME:" "GENERIC#" "GENERIC:" + "GLSL-SHADER:" "GLSL-PROGRAM:" + "HELP:" "HEX:" "HOOK:" + "IN:" "initial:" "INSTANCE:" "INTERSECTION:" + "LIBRARY:" + "M:" "M::" "MACRO:" "MACRO::" "MAIN:" "MATH:" + "MEMO:" "MEMO:" "METHOD:" "MIXIN:" + "OCT:" + "POSTPONE:" "PREDICATE:" "PRIMITIVE:" "PRIVATE>" "PROVIDE:" + "QUALIFIED-WITH:" "QUALIFIED:" + "read-only" "RENAME:" "REQUIRE:" "REQUIRES:" + "SINGLETON:" "SINGLETONS:" "SLOT:" "SPECIALIZED-ARRAY:" "SPECIALIZED-ARRAYS:" "STRING:" "STRUCT:" "SYMBOL:" "SYMBOLS:" "SYNTAX:" + "TUPLE:" "t" "t?" "TYPEDEF:" "TYPED:" "TYPED::" + "UNIFORM-TUPLE:" "UNION:" "UNION-STRUCT:" "USE:" "USING:" + "VARS:" "VERTEX-FORMAT:")) + +(defconst fuel-syntax--parsing-words-regex + (regexp-opt fuel-syntax--parsing-words 'words)) + +(defconst fuel-syntax--bracers + '("B" "BV" "C" "CS" "H" "T" "V" "W")) + +(defconst fuel-syntax--brace-words-regex + (format "%s{" (regexp-opt fuel-syntax--bracers t))) + +(defconst fuel-syntax--declaration-words + '("flushable" "foldable" "inline" "parsing" "recursive" "delimiter")) + +(defconst fuel-syntax--declaration-words-regex + (regexp-opt fuel-syntax--declaration-words 'words)) + +(defsubst fuel-syntax--second-word-regex (prefixes) + (format "%s +\\([^ \r\n]+\\)" (regexp-opt prefixes t))) + +(defconst fuel-syntax--method-definition-regex + "^M::? +\\([^ ]+\\) +\\([^ ]+\\)") + +(defconst fuel-syntax--integer-regex + "\\_<-?[0-9]+\\_>") + +(defconst fuel-syntax--raw-float-regex + "[0-9]*\\.[0-9]*\\([eE][+-]?[0-9]+\\)?") + +(defconst fuel-syntax--float-regex + (format "\\_<-?%s\\_>" fuel-syntax--raw-float-regex)) + +(defconst fuel-syntax--number-regex + (format "\\([0-9]+\\|%s\\)" fuel-syntax--raw-float-regex)) + +(defconst fuel-syntax--ratio-regex + (format "\\_<[+-]?%s/-?%s\\_>" + fuel-syntax--number-regex + fuel-syntax--number-regex)) + +(defconst fuel-syntax--bad-string-regex + "\\_<\"[^>]\\([^\"\n]\\|\\\\\"\\)*\n") + +(defconst fuel-syntax--word-definition-regex + (format "\\_<\\(%s\\)?: +\\_<\\(\\w+\\)\\_>" + (regexp-opt + '(":" "GENERIC" "DEFER" "HOOK" "MAIN" "MATH" "POSTPONE" + "SYMBOL" "SYNTAX" "TYPED" "RENAME")))) + +(defconst fuel-syntax--alias-definition-regex + "^ALIAS: +\\(\\_<.+?\\_>\\) +\\(\\_<.+?\\_>\\)") + +(defconst fuel-syntax--vocab-ref-regexp + (fuel-syntax--second-word-regex + '("IN:" "USE:" "FROM:" "EXCLUDE:" "QUALIFIED:" "QUALIFIED-WITH:"))) + +(defconst fuel-syntax--int-constant-def-regex + (fuel-syntax--second-word-regex '("ALIEN:" "CHAR:" "BIN:" "HEX:" "OCT:"))) + +(defconst fuel-syntax--type-definition-regex + (fuel-syntax--second-word-regex + '("C-STRUCT:" "C-UNION:" "MIXIN:" "TUPLE:" "SINGLETON:" "SPECIALIZED-ARRAY:" "STRUCT:" "UNION:" "UNION-STRUCT:"))) + +(defconst fuel-syntax--tuple-decl-regex + "^TUPLE: +\\([^ \n]+\\) +< +\\([^ \n]+\\)\\_>") + +(defconst fuel-syntax--constructor-regex "<[^ >]+>") + +(defconst fuel-syntax--getter-regex "\\(^\\|\\_<\\)[^ ]+?>>\\_>") +(defconst fuel-syntax--setter-regex "\\_<>>.+?\\_>") + +(defconst fuel-syntax--symbol-definition-regex + (fuel-syntax--second-word-regex '("&:" "SYMBOL:" "VAR:"))) + +(defconst fuel-syntax--stack-effect-regex + "\\( ( [^\n]* )\\)\\|\\( (( [^\n]* ))\\)") + +(defconst fuel-syntax--using-lines-regex "^USING: +\\([^;]+\\);") + +(defconst fuel-syntax--use-line-regex "^USE: +\\(.*\\)$") + +(defconst fuel-syntax--current-vocab-regex "^IN: +\\([^ \r\n\f]+\\)") + +(defconst fuel-syntax--sub-vocab-regex "^<\\([^ \n]+\\) *$") + +(defconst fuel-syntax--alien-function-regex + "\\_" " +\\(\\w+\\)\\( .*\\)?$") + + +;;; Factor syntax table + +(setq fuel-syntax--syntax-table + (let ((table (make-syntax-table))) + ;; Default is word constituent + (dotimes (i 256) + (modify-syntax-entry i "w" table)) + ;; Whitespace (TAB is not whitespace) + (modify-syntax-entry ?\f " " table) + (modify-syntax-entry ?\r " " table) + (modify-syntax-entry ?\ " " table) + (modify-syntax-entry ?\n " " table) + table)) + +(defconst fuel-syntax--syntactic-keywords + `(;; Strings and chars + ("\\_<<\\(\"\\)\\_>" (1 "\\_>" (1 ">b")) + ("\\( \\|^\\)\\(DLL\\|P\\|SBUF\\)?\\(\"\\)\\(\\([^\n\r\f\"\\]\\|\\\\.\\)*\\)\\(\"\\)" + (3 "\"") (6 "\"")) + ("CHAR: \\(\"\\) [^\\\"]*?\\(\"\\)\\([^\\\"]\\|\\\\.\\)*?\\(\"\\)" + (1 "w") (2 "b")) + ("\\(CHAR:\\|\\\\\\) \\(\\w\\|!\\)\\( \\|$\\)" (2 "w")) + ;; Comments + ("\\_<\\(#?!\\) .*\\(\n\\|$\\)" (1 "<") (2 ">")) + ("\\_<\\(#?!\\)\\(\n\\|$\\)" (1 "<") (2 ">")) + ;; postpone + ("\\_b")) + ;; Multiline constructs + ("\\_<\\(E\\)BNF:\\( \\|\n\\)" (1 "" (1 ">b")) + ("\\_<\\(U\\)SING: \\(;\\)" (1 "b")) + ("\\_b")) + ("\\_\\)" (1 "\\)" + (2 "" (1 ">b")) + ;; Let and lambda: + ("\\_<\\(!(\\) .* \\()\\)" (1 "<") (2 ">")) + ("\\(\\[\\)\\(let\\|let\\*\\)\\( \\|$\\)" (1 "(]")) + ("\\(\\[\\)\\(|\\) +[^|]* \\(|\\)" (1 "(]") (2 "(|") (3 ")|")) + (" \\(|\\) " (1 "(|")) + (" \\(|\\)$" (1 ")")) + ;; Opening brace words: + ("\\_<\\w*\\({\\)\\_>" (1 "(}")) + ("\\_<\\(}\\)\\_>" (1 "){")) + ;; Parenthesis: + ("\\_<\\((\\)\\_>" (1 "()")) + ("\\_<\\w*\\((\\)\\_>" (1 "()")) + ("\\_<\\()\\)\\_>" (1 ")(")) + ("\\_<(\\((\\)\\_>" (1 "()")) + ("\\_<\\()\\))\\_>" (1 ")(")) + ;; Quotations: + ("\\_<'\\(\\[\\)\\_>" (1 "(]")) ; fried + ("\\_<$\\(\\[\\)\\_>" (1 "(]")) ; parse-time + ("\\_<\\(\\[\\)\\_>" (1 "(]")) + ("\\_<\\(\\]\\)\\_>" (1 ")[")))) + + +;;; Source code analysis: + +(defsubst fuel-syntax--brackets-depth () + (nth 0 (syntax-ppss))) + +(defsubst fuel-syntax--brackets-start () + (nth 1 (syntax-ppss))) + +(defun fuel-syntax--brackets-end () + (save-excursion + (goto-char (fuel-syntax--brackets-start)) + (condition-case nil + (progn (forward-sexp) + (1- (point))) + (error -1)))) + +(defsubst fuel-syntax--indentation-at (pos) + (save-excursion (goto-char pos) (current-indentation))) + +(defsubst fuel-syntax--increased-indentation (&optional i) + (+ (or i (current-indentation)) factor-indent-width)) +(defsubst fuel-syntax--decreased-indentation (&optional i) + (- (or i (current-indentation)) factor-indent-width)) + +(defsubst fuel-syntax--at-begin-of-def () + (looking-at fuel-syntax--begin-of-def-regex)) + +(defsubst fuel-syntax--at-begin-of-indent-def () + (looking-at fuel-syntax--indent-def-start-regex)) + +(defsubst fuel-syntax--at-end-of-def () + (looking-at fuel-syntax--end-of-def-regex)) + +(defsubst fuel-syntax--looking-at-emptiness () + (looking-at "^[ ]*$\\|$")) + +(defsubst fuel-syntax--is-last-char (pos) + (save-excursion + (goto-char (1+ pos)) + (looking-at-p "[ ]*$"))) + +(defsubst fuel-syntax--line-offset (pos) + (- pos (save-excursion + (goto-char pos) + (beginning-of-line) + (point)))) + +(defun fuel-syntax--previous-non-blank () + (forward-line -1) + (while (and (not (bobp)) (fuel-syntax--looking-at-emptiness)) + (forward-line -1))) + +(defun fuel-syntax--beginning-of-block-pos () + (save-excursion + (if (> (fuel-syntax--brackets-depth) 0) + (fuel-syntax--brackets-start) + (fuel-syntax--beginning-of-defun) + (point)))) + +(defun fuel-syntax--at-setter-line () + (save-excursion + (beginning-of-line) + (when (re-search-forward fuel-syntax--setter-regex + (line-end-position) + t) + (let* ((to (match-beginning 0)) + (from (fuel-syntax--beginning-of-block-pos))) + (goto-char from) + (let ((depth (fuel-syntax--brackets-depth))) + (and (or (re-search-forward fuel-syntax--constructor-regex to t) + (re-search-forward fuel-syntax--setter-regex to t)) + (= depth (fuel-syntax--brackets-depth)))))))) + +(defun fuel-syntax--at-constructor-line () + (save-excursion + (beginning-of-line) + (re-search-forward fuel-syntax--constructor-regex (line-end-position) t))) + +(defsubst fuel-syntax--at-using () + (looking-at fuel-syntax--using-lines-regex)) + +(defun fuel-syntax--in-using () + (let ((p (point))) + (save-excursion + (and (re-search-backward "^USING: " nil t) + (re-search-forward " ;" nil t) + (< p (match-end 0)))))) + +(defsubst fuel-syntax--beginning-of-defun (&optional times) + (re-search-backward fuel-syntax--begin-of-def-regex nil t times)) + +(defsubst fuel-syntax--end-of-defun () + (re-search-forward fuel-syntax--end-of-def-regex nil t)) + +(defsubst fuel-syntax--end-of-defun-pos () + (save-excursion + (re-search-forward fuel-syntax--end-of-def-regex nil t) + (point))) + +(defun fuel-syntax--beginning-of-body () + (let ((p (point))) + (and (fuel-syntax--beginning-of-defun) + (re-search-forward fuel-syntax--defun-signature-regex p t) + (not (re-search-forward fuel-syntax--end-of-def-regex p t))))) + +(defun fuel-syntax--beginning-of-sexp () + (if (> (fuel-syntax--brackets-depth) 0) + (goto-char (fuel-syntax--brackets-start)) + (fuel-syntax--beginning-of-body))) + +(defsubst fuel-syntax--beginning-of-sexp-pos () + (save-excursion (fuel-syntax--beginning-of-sexp) (point))) + + +;;; USING/IN: + +(make-variable-buffer-local + (defvar fuel-syntax--current-vocab-function 'fuel-syntax--find-in)) + +(defsubst fuel-syntax--current-vocab () + (funcall fuel-syntax--current-vocab-function)) + +(defun fuel-syntax--find-in () + (save-excursion + (when (re-search-backward fuel-syntax--current-vocab-regex nil t) + (match-string-no-properties 1)))) + +(make-variable-buffer-local + (defvar fuel-syntax--usings-function 'fuel-syntax--find-usings)) + +(defsubst fuel-syntax--usings () + (funcall fuel-syntax--usings-function)) + +(defun fuel-syntax--file-has-private () + (save-excursion + (goto-char (point-min)) + (and (re-search-forward "\\_<" nil t) + (re-search-forward "\\_\\_>" nil t)))) + +(defun fuel-syntax--find-usings (&optional no-private) + (save-excursion + (let ((usings)) + (goto-char (point-max)) + (while (re-search-backward fuel-syntax--using-lines-regex nil t) + (dolist (u (split-string (match-string-no-properties 1) nil t)) + (push u usings))) + (when (and (not no-private) (fuel-syntax--file-has-private)) + (goto-char (point-max)) + (push (concat (fuel-syntax--find-in) ".private") usings)) + usings))) + + +(provide 'fuel-syntax) +;;; fuel-syntax.el ends here From a56d0a760283d928017ab9b20ca4873de9ff92a7 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sun, 21 Feb 2010 16:43:09 -0800 Subject: [PATCH 158/713] Bindings to the HID portion of the Windows DDK. --- basis/windows/ddk/hid/authors.txt | 1 + basis/windows/ddk/hid/hid.factor | 805 ++++++++++++++++++++++++++++++ 2 files changed, 806 insertions(+) create mode 100644 basis/windows/ddk/hid/authors.txt create mode 100644 basis/windows/ddk/hid/hid.factor diff --git a/basis/windows/ddk/hid/authors.txt b/basis/windows/ddk/hid/authors.txt new file mode 100644 index 0000000000..67cf648cf5 --- /dev/null +++ b/basis/windows/ddk/hid/authors.txt @@ -0,0 +1 @@ +Erik Charlebois \ No newline at end of file diff --git a/basis/windows/ddk/hid/hid.factor b/basis/windows/ddk/hid/hid.factor new file mode 100644 index 0000000000..9c8a55ee7c --- /dev/null +++ b/basis/windows/ddk/hid/hid.factor @@ -0,0 +1,805 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: alien.c-types alien.libraries alien.syntax classes.struct +kernel math windows.types windows.ole32 ; +IN: windows.ddk.hid + +<< "hid" "hid.dll" "stdcall" add-library >> +LIBRARY: hid + +TYPEDEF: LONG NTSTATUS +TYPEDEF: USHORT USAGE +TYPEDEF: USAGE* PUSAGE + +CONSTANT: HID_USAGE_PAGE_UNDEFINED HEX: 00 +CONSTANT: HID_USAGE_PAGE_GENERIC HEX: 01 +CONSTANT: HID_USAGE_PAGE_SIMULATION HEX: 02 +CONSTANT: HID_USAGE_PAGE_VR HEX: 03 +CONSTANT: HID_USAGE_PAGE_SPORT HEX: 04 +CONSTANT: HID_USAGE_PAGE_GAME HEX: 05 +CONSTANT: HID_USAGE_PAGE_KEYBOARD HEX: 07 +CONSTANT: HID_USAGE_PAGE_LED HEX: 08 +CONSTANT: HID_USAGE_PAGE_BUTTON HEX: 09 +CONSTANT: HID_USAGE_PAGE_ORDINAL HEX: 0A +CONSTANT: HID_USAGE_PAGE_TELEPHONY HEX: 0B +CONSTANT: HID_USAGE_PAGE_CONSUMER HEX: 0C +CONSTANT: HID_USAGE_PAGE_DIGITIZER HEX: 0D +CONSTANT: HID_USAGE_PAGE_UNICODE HEX: 10 +CONSTANT: HID_USAGE_PAGE_ALPHANUMERIC HEX: 14 + +CONSTANT: HID_USAGE_PAGE_MICROSOFT_BLUETOOTH_HANDSFREE HEX: FFF3 + +CONSTANT: HID_USAGE_GENERIC_POINTER HEX: 01 +CONSTANT: HID_USAGE_GENERIC_MOUSE HEX: 02 +CONSTANT: HID_USAGE_GENERIC_JOYSTICK HEX: 04 +CONSTANT: HID_USAGE_GENERIC_GAMEPAD HEX: 05 +CONSTANT: HID_USAGE_GENERIC_KEYBOARD HEX: 06 +CONSTANT: HID_USAGE_GENERIC_KEYPAD HEX: 07 +CONSTANT: HID_USAGE_GENERIC_SYSTEM_CTL HEX: 80 + +CONSTANT: HID_USAGE_GENERIC_X HEX: 30 +CONSTANT: HID_USAGE_GENERIC_Y HEX: 31 +CONSTANT: HID_USAGE_GENERIC_Z HEX: 32 +CONSTANT: HID_USAGE_GENERIC_RX HEX: 33 +CONSTANT: HID_USAGE_GENERIC_RY HEX: 34 +CONSTANT: HID_USAGE_GENERIC_RZ HEX: 35 +CONSTANT: HID_USAGE_GENERIC_SLIDER HEX: 36 +CONSTANT: HID_USAGE_GENERIC_DIAL HEX: 37 +CONSTANT: HID_USAGE_GENERIC_WHEEL HEX: 38 +CONSTANT: HID_USAGE_GENERIC_HATSWITCH HEX: 39 +CONSTANT: HID_USAGE_GENERIC_COUNTED_BUFFER HEX: 3A +CONSTANT: HID_USAGE_GENERIC_BYTE_COUNT HEX: 3B +CONSTANT: HID_USAGE_GENERIC_MOTION_WAKEUP HEX: 3C +CONSTANT: HID_USAGE_GENERIC_VX HEX: 40 +CONSTANT: HID_USAGE_GENERIC_VY HEX: 41 +CONSTANT: HID_USAGE_GENERIC_VZ HEX: 42 +CONSTANT: HID_USAGE_GENERIC_VBRX HEX: 43 +CONSTANT: HID_USAGE_GENERIC_VBRY HEX: 44 +CONSTANT: HID_USAGE_GENERIC_VBRZ HEX: 45 +CONSTANT: HID_USAGE_GENERIC_VNO HEX: 46 +CONSTANT: HID_USAGE_GENERIC_SYSCTL_POWER HEX: 81 +CONSTANT: HID_USAGE_GENERIC_SYSCTL_SLEEP HEX: 82 +CONSTANT: HID_USAGE_GENERIC_SYSCTL_WAKE HEX: 83 +CONSTANT: HID_USAGE_GENERIC_SYSCTL_CONTEXT_MENU HEX: 84 +CONSTANT: HID_USAGE_GENERIC_SYSCTL_MAIN_MENU HEX: 85 +CONSTANT: HID_USAGE_GENERIC_SYSCTL_APP_MENU HEX: 86 +CONSTANT: HID_USAGE_GENERIC_SYSCTL_HELP_MENU HEX: 87 +CONSTANT: HID_USAGE_GENERIC_SYSCTL_MENU_EXIT HEX: 88 +CONSTANT: HID_USAGE_GENERIC_SYSCTL_MENU_SELECT HEX: 89 +CONSTANT: HID_USAGE_GENERIC_SYSCTL_MENU_RIGHT HEX: 8A +CONSTANT: HID_USAGE_GENERIC_SYSCTL_MENU_LEFT HEX: 8B +CONSTANT: HID_USAGE_GENERIC_SYSCTL_MENU_UP HEX: 8C +CONSTANT: HID_USAGE_GENERIC_SYSCTL_MENU_DOWN HEX: 8D + +CONSTANT: HID_USAGE_SIMULATION_RUDDER HEX: BA +CONSTANT: HID_USAGE_SIMULATION_THROTTLE HEX: BB + +CONSTANT: HID_USAGE_KEYBOARD_NOEVENT HEX: 00 +CONSTANT: HID_USAGE_KEYBOARD_ROLLOVER HEX: 01 +CONSTANT: HID_USAGE_KEYBOARD_POSTFAIL HEX: 02 +CONSTANT: HID_USAGE_KEYBOARD_UNDEFINED HEX: 03 + +CONSTANT: HID_USAGE_KEYBOARD_aA HEX: 04 +CONSTANT: HID_USAGE_KEYBOARD_zZ HEX: 1D +CONSTANT: HID_USAGE_KEYBOARD_ONE HEX: 1E +CONSTANT: HID_USAGE_KEYBOARD_ZERO HEX: 27 +CONSTANT: HID_USAGE_KEYBOARD_LCTRL HEX: E0 +CONSTANT: HID_USAGE_KEYBOARD_LSHFT HEX: E1 +CONSTANT: HID_USAGE_KEYBOARD_LALT HEX: E2 +CONSTANT: HID_USAGE_KEYBOARD_LGUI HEX: E3 +CONSTANT: HID_USAGE_KEYBOARD_RCTRL HEX: E4 +CONSTANT: HID_USAGE_KEYBOARD_RSHFT HEX: E5 +CONSTANT: HID_USAGE_KEYBOARD_RALT HEX: E6 +CONSTANT: HID_USAGE_KEYBOARD_RGUI HEX: E7 +CONSTANT: HID_USAGE_KEYBOARD_SCROLL_LOCK HEX: 47 +CONSTANT: HID_USAGE_KEYBOARD_NUM_LOCK HEX: 53 +CONSTANT: HID_USAGE_KEYBOARD_CAPS_LOCK HEX: 39 +CONSTANT: HID_USAGE_KEYBOARD_F1 HEX: 3A +CONSTANT: HID_USAGE_KEYBOARD_F12 HEX: 45 +CONSTANT: HID_USAGE_KEYBOARD_RETURN HEX: 28 +CONSTANT: HID_USAGE_KEYBOARD_ESCAPE HEX: 29 +CONSTANT: HID_USAGE_KEYBOARD_DELETE HEX: 2A +CONSTANT: HID_USAGE_KEYBOARD_PRINT_SCREEN HEX: 46 + +CONSTANT: HID_USAGE_LED_NUM_LOCK HEX: 01 +CONSTANT: HID_USAGE_LED_CAPS_LOCK HEX: 02 +CONSTANT: HID_USAGE_LED_SCROLL_LOCK HEX: 03 +CONSTANT: HID_USAGE_LED_COMPOSE HEX: 04 +CONSTANT: HID_USAGE_LED_KANA HEX: 05 +CONSTANT: HID_USAGE_LED_POWER HEX: 06 +CONSTANT: HID_USAGE_LED_SHIFT HEX: 07 +CONSTANT: HID_USAGE_LED_DO_NOT_DISTURB HEX: 08 +CONSTANT: HID_USAGE_LED_MUTE HEX: 09 +CONSTANT: HID_USAGE_LED_TONE_ENABLE HEX: 0A +CONSTANT: HID_USAGE_LED_HIGH_CUT_FILTER HEX: 0B +CONSTANT: HID_USAGE_LED_LOW_CUT_FILTER HEX: 0C +CONSTANT: HID_USAGE_LED_EQUALIZER_ENABLE HEX: 0D +CONSTANT: HID_USAGE_LED_SOUND_FIELD_ON HEX: 0E +CONSTANT: HID_USAGE_LED_SURROUND_FIELD_ON HEX: 0F +CONSTANT: HID_USAGE_LED_REPEAT HEX: 10 +CONSTANT: HID_USAGE_LED_STEREO HEX: 11 +CONSTANT: HID_USAGE_LED_SAMPLING_RATE_DETECT HEX: 12 +CONSTANT: HID_USAGE_LED_SPINNING HEX: 13 +CONSTANT: HID_USAGE_LED_CAV HEX: 14 +CONSTANT: HID_USAGE_LED_CLV HEX: 15 +CONSTANT: HID_USAGE_LED_RECORDING_FORMAT_DET HEX: 16 +CONSTANT: HID_USAGE_LED_OFF_HOOK HEX: 17 +CONSTANT: HID_USAGE_LED_RING HEX: 18 +CONSTANT: HID_USAGE_LED_MESSAGE_WAITING HEX: 19 +CONSTANT: HID_USAGE_LED_DATA_MODE HEX: 1A +CONSTANT: HID_USAGE_LED_BATTERY_OPERATION HEX: 1B +CONSTANT: HID_USAGE_LED_BATTERY_OK HEX: 1C +CONSTANT: HID_USAGE_LED_BATTERY_LOW HEX: 1D +CONSTANT: HID_USAGE_LED_SPEAKER HEX: 1E +CONSTANT: HID_USAGE_LED_HEAD_SET HEX: 1F +CONSTANT: HID_USAGE_LED_HOLD HEX: 20 +CONSTANT: HID_USAGE_LED_MICROPHONE HEX: 21 +CONSTANT: HID_USAGE_LED_COVERAGE HEX: 22 +CONSTANT: HID_USAGE_LED_NIGHT_MODE HEX: 23 +CONSTANT: HID_USAGE_LED_SEND_CALLS HEX: 24 +CONSTANT: HID_USAGE_LED_CALL_PICKUP HEX: 25 +CONSTANT: HID_USAGE_LED_CONFERENCE HEX: 26 +CONSTANT: HID_USAGE_LED_STAND_BY HEX: 27 +CONSTANT: HID_USAGE_LED_CAMERA_ON HEX: 28 +CONSTANT: HID_USAGE_LED_CAMERA_OFF HEX: 29 +CONSTANT: HID_USAGE_LED_ON_LINE HEX: 2A +CONSTANT: HID_USAGE_LED_OFF_LINE HEX: 2B +CONSTANT: HID_USAGE_LED_BUSY HEX: 2C +CONSTANT: HID_USAGE_LED_READY HEX: 2D +CONSTANT: HID_USAGE_LED_PAPER_OUT HEX: 2E +CONSTANT: HID_USAGE_LED_PAPER_JAM HEX: 2F +CONSTANT: HID_USAGE_LED_REMOTE HEX: 30 +CONSTANT: HID_USAGE_LED_FORWARD HEX: 31 +CONSTANT: HID_USAGE_LED_REVERSE HEX: 32 +CONSTANT: HID_USAGE_LED_STOP HEX: 33 +CONSTANT: HID_USAGE_LED_REWIND HEX: 34 +CONSTANT: HID_USAGE_LED_FAST_FORWARD HEX: 35 +CONSTANT: HID_USAGE_LED_PLAY HEX: 36 +CONSTANT: HID_USAGE_LED_PAUSE HEX: 37 +CONSTANT: HID_USAGE_LED_RECORD HEX: 38 +CONSTANT: HID_USAGE_LED_ERROR HEX: 39 +CONSTANT: HID_USAGE_LED_SELECTED_INDICATOR HEX: 3A +CONSTANT: HID_USAGE_LED_IN_USE_INDICATOR HEX: 3B +CONSTANT: HID_USAGE_LED_MULTI_MODE_INDICATOR HEX: 3C +CONSTANT: HID_USAGE_LED_INDICATOR_ON HEX: 3D +CONSTANT: HID_USAGE_LED_INDICATOR_FLASH HEX: 3E +CONSTANT: HID_USAGE_LED_INDICATOR_SLOW_BLINK HEX: 3F +CONSTANT: HID_USAGE_LED_INDICATOR_FAST_BLINK HEX: 40 +CONSTANT: HID_USAGE_LED_INDICATOR_OFF HEX: 41 +CONSTANT: HID_USAGE_LED_FLASH_ON_TIME HEX: 42 +CONSTANT: HID_USAGE_LED_SLOW_BLINK_ON_TIME HEX: 43 +CONSTANT: HID_USAGE_LED_SLOW_BLINK_OFF_TIME HEX: 44 +CONSTANT: HID_USAGE_LED_FAST_BLINK_ON_TIME HEX: 45 +CONSTANT: HID_USAGE_LED_FAST_BLINK_OFF_TIME HEX: 46 +CONSTANT: HID_USAGE_LED_INDICATOR_COLOR HEX: 47 +CONSTANT: HID_USAGE_LED_RED HEX: 48 +CONSTANT: HID_USAGE_LED_GREEN HEX: 49 +CONSTANT: HID_USAGE_LED_AMBER HEX: 4A +CONSTANT: HID_USAGE_LED_GENERIC_INDICATOR HEX: 4B + +CONSTANT: HID_USAGE_TELEPHONY_PHONE HEX: 01 +CONSTANT: HID_USAGE_TELEPHONY_ANSWERING_MACHINE HEX: 02 +CONSTANT: HID_USAGE_TELEPHONY_MESSAGE_CONTROLS HEX: 03 +CONSTANT: HID_USAGE_TELEPHONY_HANDSET HEX: 04 +CONSTANT: HID_USAGE_TELEPHONY_HEADSET HEX: 05 +CONSTANT: HID_USAGE_TELEPHONY_KEYPAD HEX: 06 +CONSTANT: HID_USAGE_TELEPHONY_PROGRAMMABLE_BUTTON HEX: 07 +CONSTANT: HID_USAGE_TELEPHONY_REDIAL HEX: 24 +CONSTANT: HID_USAGE_TELEPHONY_TRANSFER HEX: 25 +CONSTANT: HID_USAGE_TELEPHONY_DROP HEX: 26 +CONSTANT: HID_USAGE_TELEPHONY_LINE HEX: 2A +CONSTANT: HID_USAGE_TELEPHONY_RING_ENABLE HEX: 2D +CONSTANT: HID_USAGE_TELEPHONY_SEND HEX: 31 +CONSTANT: HID_USAGE_TELEPHONY_KEYPAD_0 HEX: B0 +CONSTANT: HID_USAGE_TELEPHONY_KEYPAD_D HEX: BF +CONSTANT: HID_USAGE_TELEPHONY_HOST_AVAILABLE HEX: F1 + +CONSTANT: HID_USAGE_MS_BTH_HF_DIALNUMBER HEX: 21 +CONSTANT: HID_USAGE_MS_BTH_HF_DIALMEMORY HEX: 22 + +CONSTANT: HID_USAGE_CONSUMERCTRL HEX: 01 +CONSTANT: HID_USAGE_DIGITIZER_PEN HEX: 02 +CONSTANT: HID_USAGE_DIGITIZER_IN_RANGE HEX: 32 +CONSTANT: HID_USAGE_DIGITIZER_TIP_SWITCH HEX: 42 +CONSTANT: HID_USAGE_DIGITIZER_BARREL_SWITCH HEX: 44 + +CONSTANT: HIDP_LINK_COLLECTION_ROOT -1 +CONSTANT: HIDP_LINK_COLLECTION_UNSPECIFIED 0 + +C-ENUM: + HidP_Input + HidP_Output + HidP_Feature ; +TYPEDEF: int HIDP_REPORT_TYPE + +STRUCT: USAGE_AND_PAGE + { Usage USAGE } + { UsagePage USAGE } ; +TYPEDEF: USAGE_AND_PAGE* PUSAGE_AND_PAGE + +: HidP_IsSameUsageAndPage ( u1 u2 -- ? ) = ; inline + +STRUCT: HIDP_BUTTONS_CAPS_range + { UsageMin USAGE } + { UsageMax USAGE } + { StringMin USHORT } + { StringMax USHORT } + { DesignatorMin USHORT } + { DesignatorMax USHORT } + { DataIndexMin USHORT } + { DataIndexMax USHORT } ; + +STRUCT: HIDP_BUTTONS_CAPS_not_range + { Usage USAGE } + { Reserved1 USAGE } + { StringIndex USHORT } + { Reserved2 USHORT } + { DesignatorIndex USHORT } + { Reserved3 USHORT } + { DataIndex USHORT } + { Reserved4 USHORT } ; + +UNION-STRUCT: HIDP_BUTTONS_CAPS_union + { Range HIDP_BUTTONS_CAPS_range } + { NotRange HIDP_BUTTONS_CAPS_not_range } ; + +STRUCT: HIDP_BUTTON_CAPS + { UsagePage USAGE } + { ReportID UCHAR } + { IsAlias BOOLEAN } + { BitField USHORT } + { LinkCollection USHORT } + { LinkUsage USAGE } + { LinkUsagePage USAGE } + { IsRange BOOLEAN } + { IsStringRange BOOLEAN } + { IsDesignatorRange BOOLEAN } + { IsAbsolute BOOLEAN } + { Reserved ULONG[10] } + { Union HIDP_BUTTONS_CAPS_union } ; +TYPEDEF: HIDP_BUTTON_CAPS* PHIDP_BUTTON_CAPS + +STRUCT: HIDP_VALUE_CAPS_range + { UsageMin USAGE } + { UsageMax USAGE } + { StringMin USHORT } + { StringMax USHORT } + { DesignatorMin USHORT } + { DesignatorMax USHORT } + { DataIndexMin USHORT } + { DataIndexMax USHORT } ; + +STRUCT: HIDP_VALUE_CAPS_not_range + { Usage USAGE } + { Reserved1 USAGE } + { StringIndex USHORT } + { Reserved2 USHORT } + { DesignatorIndex USHORT } + { Reserved3 USHORT } + { DataIndex USHORT } + { Reserved4 USHORT } ; + +UNION-STRUCT: HIDP_VALUE_CAPS_union + { Range HIDP_VALUE_CAPS_range } + { NotRange HIDP_VALUE_CAPS_not_range } ; + +STRUCT: HIDP_VALUE_CAPS + { UsagePage USAGE } + { ReportID UCHAR } + { IsAlias BOOLEAN } + { BitField USHORT } + { LinkCollection USHORT } + { LinkUsage USAGE } + { LinkUsagePage USAGE } + { IsRange BOOLEAN } + { IsStringRange BOOLEAN } + { IsDesignatorRange BOOLEAN } + { IsAbsolute BOOLEAN } + { HasNull BOOLEAN } + { Reserved UCHAR } + { BitSize USHORT } + { ReportCount USHORT } + { Reserved2 USHORT[5] } + { UnitsExp ULONG } + { Units ULONG } + { LogicalMin LONG } + { LogicalMax LONG } + { PhysicalMin LONG } + { PhysicalMax LONG } + { Union HIDP_VALUE_CAPS_union } ; +TYPEDEF: HIDP_VALUE_CAPS* PHIDP_VALUE_CAPS + +STRUCT: HIDP_LINK_COLLECTION_NODE + { LinkUsage USAGE } + { LinkUsagePage USAGE } + { Parent USHORT } + { NumberOfChildren USHORT } + { NextSibling USHORT } + { FirstChild USHORT } + { CollectionTypeIsAliasBitfield ULONG } + { UserContext PVOID } ; +TYPEDEF: HIDP_LINK_COLLECTION_NODE* PHIDP_LINK_COLLECTION_NODE + +TYPEDEF: PUCHAR PHIDP_REPORT_DESCRIPTOR +C-TYPE: HIDP_PREPARSED_DATA +TYPEDEF: HIDP_PREPARSED_DATA* PHIDP_PREPARSED_DATA + +STRUCT: HIDP_CAPS + { Usage USAGE } + { UsagePage USAGE } + { InputReportByteLength USHORT } + { OutputReportByteLength USHORT } + { FeatureReportByteLength USHORT } + { Reserved USHORT[17] } + { NumberLinkCollectionNodes USHORT } + { NumberInputButtonCaps USHORT } + { NumberInputValueCaps USHORT } + { NumberInputDataIndices USHORT } + { NumberOutputButtonCaps USHORT } + { NumberOutputValueCaps USHORT } + { NumberOutputDataIndices USHORT } + { NumberFeatureButtonCaps USHORT } + { NumberFeatureValueCaps USHORT } + { NumberFeatureDataIndices USHORT } ; +TYPEDEF: HIDP_CAPS* PHIDP_CAPS + +STRUCT: HIDP_DATA + { DataIndex USHORT } + { Reserved USHORT } + { RawValue ULONG } ; +TYPEDEF: HIDP_DATA* PHIDP_DATA + +STRUCT: HIDP_UNKNOWN_TOKEN + { Token UCHAR } + { Reserved UCHAR[3] } + { BitField ULONG } ; +TYPEDEF: HIDP_UNKNOWN_TOKEN* PHIDP_UNKNOWN_TOKEN + +STRUCT: HIDP_EXTENDED_ATTRIBUTES + { NumGlobalUnknowns UCHAR } + { Reserved UCHAR[3] } + { GlobalUnknowns PHIDP_UNKNOWN_TOKEN } + { Data ULONG[1] } ; +TYPEDEF: HIDP_EXTENDED_ATTRIBUTES* PHIDP_EXTENDED_ATTRIBUTES + +FUNCTION: NTSTATUS +HidP_GetCaps ( + PHIDP_PREPARSED_DATA PreparsedData, + PHIDP_CAPS Capabilities + ) ; + +FUNCTION: NTSTATUS +HidP_GetLinkCollectionNodes ( + PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes, + PULONG LinkCollectionNodesLength, + PHIDP_PREPARSED_DATA PreparsedData + ) ; + +FUNCTION: NTSTATUS +HidP_GetSpecificButtonCaps ( + HIDP_REPORT_TYPE ReportType, + USAGE UsagePage, + USHORT LinkCollection, + USAGE Usage, + PHIDP_BUTTON_CAPS ButtonCaps, + PUSHORT ButtonCapsLength, + PHIDP_PREPARSED_DATA PreparsedData + ) ; + +FUNCTION: NTSTATUS +HidP_GetButtonCaps ( + HIDP_REPORT_TYPE ReportType, + PHIDP_BUTTON_CAPS ButtonCaps, + PUSHORT ButtonCapsLength, + PHIDP_PREPARSED_DATA PreparsedData +) ; + +FUNCTION: NTSTATUS +HidP_GetSpecificValueCaps ( + HIDP_REPORT_TYPE ReportType, + USAGE UsagePage, + USHORT LinkCollection, + USAGE Usage, + PHIDP_VALUE_CAPS ValueCaps, + PUSHORT ValueCapsLength, + PHIDP_PREPARSED_DATA PreparsedData + ) ; + +FUNCTION: NTSTATUS +HidP_GetValueCaps ( + HIDP_REPORT_TYPE ReportType, + PHIDP_VALUE_CAPS ValueCaps, + PUSHORT ValueCapsLength, + PHIDP_PREPARSED_DATA PreparsedData +) ; + +FUNCTION: NTSTATUS +HidP_GetExtendedAttributes ( + HIDP_REPORT_TYPE ReportType, + USHORT DataIndex, + PHIDP_PREPARSED_DATA PreparsedData, + PHIDP_EXTENDED_ATTRIBUTES Attributes, + PULONG LengthAttributes + ) ; + +FUNCTION: NTSTATUS +HidP_InitializeReportForID ( + HIDP_REPORT_TYPE ReportType, + UCHAR ReportID, + PHIDP_PREPARSED_DATA PreparsedData, + PCHAR Report, + ULONG ReportLength + ) ; + +FUNCTION: NTSTATUS +HidP_SetData ( + HIDP_REPORT_TYPE ReportType, + PHIDP_DATA DataList, + PULONG DataLength, + PHIDP_PREPARSED_DATA PreparsedData, + PCHAR Report, + ULONG ReportLength + ) ; + +FUNCTION: NTSTATUS +HidP_GetData ( + HIDP_REPORT_TYPE ReportType, + PHIDP_DATA DataList, + PULONG DataLength, + PHIDP_PREPARSED_DATA PreparsedData, + PCHAR Report, + ULONG ReportLength + ) ; + +FUNCTION: ULONG +HidP_MaxDataListLength ( + HIDP_REPORT_TYPE ReportType, + PHIDP_PREPARSED_DATA PreparsedData + ) ; + +FUNCTION: NTSTATUS +HidP_SetUsages ( + HIDP_REPORT_TYPE ReportType, + USAGE UsagePage, + USHORT LinkCollection, + PUSAGE UsageList, + PULONG UsageLength, + PHIDP_PREPARSED_DATA PreparsedData, + PCHAR Report, + ULONG ReportLength + ) ; +ALIAS: HidP_SetButtons HidP_SetUsages + +FUNCTION: NTSTATUS +HidP_UnsetUsages ( + HIDP_REPORT_TYPE ReportType, + USAGE UsagePage, + USHORT LinkCollection, + PUSAGE UsageList, + PULONG UsageLength, + PHIDP_PREPARSED_DATA PreparsedData, + PCHAR Report, + ULONG ReportLength + ) ; +ALIAS: HidP_UnsetButtons HidP_UnsetUsages + +FUNCTION: NTSTATUS +HidP_GetUsages ( + HIDP_REPORT_TYPE ReportType, + USAGE UsagePage, + USHORT LinkCollection, + PUSAGE UsageList, + PULONG UsageLength, + PHIDP_PREPARSED_DATA PreparsedData, + PCHAR Report, + ULONG ReportLength + ) ; +ALIAS: HidP_GetButtons HidP_GetUsages + +FUNCTION: NTSTATUS +HidP_GetUsagesEx ( + HIDP_REPORT_TYPE ReportType, + USHORT LinkCollection, + PUSAGE_AND_PAGE ButtonList, + ULONG* UsageLength, + PHIDP_PREPARSED_DATA PreparsedData, + PCHAR Report, + ULONG ReportLength + ) ; +ALIAS: HidP_GetButtonsEx HidP_GetUsagesEx + +FUNCTION: ULONG +HidP_MaxUsageListLength ( + HIDP_REPORT_TYPE ReportType, + USAGE UsagePage, + PHIDP_PREPARSED_DATA PreparsedData + ) ; + +FUNCTION: NTSTATUS +HidP_SetUsageValue ( + HIDP_REPORT_TYPE ReportType, + USAGE UsagePage, + USHORT LinkCollection, + USAGE Usage, + ULONG UsageValue, + PHIDP_PREPARSED_DATA PreparsedData, + PCHAR Report, + ULONG ReportLength + ) ; + +FUNCTION: NTSTATUS +HidP_SetScaledUsageValue ( + HIDP_REPORT_TYPE ReportType, + USAGE UsagePage, + USHORT LinkCollection, + USAGE Usage, + LONG UsageValue, + PHIDP_PREPARSED_DATA PreparsedData, + PCHAR Report, + ULONG ReportLength + ) ; + +FUNCTION: NTSTATUS +HidP_SetUsageValueArray ( + HIDP_REPORT_TYPE ReportType, + USAGE UsagePage, + USHORT LinkCollection, + USAGE Usage, + PCHAR UsageValue, + USHORT UsageValueByteLength, + PHIDP_PREPARSED_DATA PreparsedData, + PCHAR Report, + ULONG ReportLength + ) ; + + +FUNCTION: NTSTATUS +HidP_GetUsageValue ( + HIDP_REPORT_TYPE ReportType, + USAGE UsagePage, + USHORT LinkCollection, + USAGE Usage, + PULONG UsageValue, + PHIDP_PREPARSED_DATA PreparsedData, + PCHAR Report, + ULONG ReportLength + ) ; + +FUNCTION: NTSTATUS +HidP_GetScaledUsageValue ( + HIDP_REPORT_TYPE ReportType, + USAGE UsagePage, + USHORT LinkCollection, + USAGE Usage, + PLONG UsageValue, + PHIDP_PREPARSED_DATA PreparsedData, + PCHAR Report, + ULONG ReportLength + ) ; + +FUNCTION: NTSTATUS +HidP_GetUsageValueArray ( + HIDP_REPORT_TYPE ReportType, + USAGE UsagePage, + USHORT LinkCollection, + USAGE Usage, + PCHAR UsageValue, + USHORT UsageValueByteLength, + PHIDP_PREPARSED_DATA PreparsedData, + PCHAR Report, + ULONG ReportLength + ) ; + +FUNCTION: NTSTATUS +HidP_UsageListDifference ( + PUSAGE PreviousUsageList, + PUSAGE CurrentUsageList, + PUSAGE BreakUsageList, + PUSAGE MakeUsageList, + ULONG UsageListLength + ) ; + +FUNCTION: NTSTATUS +HidP_UsageAndPageListDifference ( + PUSAGE_AND_PAGE PreviousUsageList, + PUSAGE_AND_PAGE CurrentUsageList, + PUSAGE_AND_PAGE BreakUsageList, + PUSAGE_AND_PAGE MakeUsageList, + ULONG UsageListLength + ) ; + +C-ENUM: + HidP_Keyboard_Break + HidP_Keyboard_Make ; +TYPEDEF: int HIDP_KEYBOARD_DIRECTION + +STRUCT: HIDP_KEYBOARD_MODIFIER_STATE + { ul ULONG } ; +TYPEDEF: HIDP_KEYBOARD_MODIFIER_STATE* PHIDP_KEYBOARD_MODIFIER_STATE + +CALLBACK: BOOLEAN PHIDP_INSERT_SCANCODES ( + PVOID Context, + PCHAR NewScanCodes, + ULONG Length ) ; + +FUNCTION: NTSTATUS +HidP_TranslateUsageAndPagesToI8042ScanCodes ( + PUSAGE_AND_PAGE ChangedUsageList, + ULONG UsageListLength, + HIDP_KEYBOARD_DIRECTION KeyAction, + PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, + PHIDP_INSERT_SCANCODES InsertCodesProcedure, + PVOID InsertCodesContext + ) ; + + +FUNCTION: NTSTATUS +HidP_TranslateUsagesToI8042ScanCodes ( + PUSAGE ChangedUsageList, + ULONG UsageListLength, + HIDP_KEYBOARD_DIRECTION KeyAction, + PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, + PHIDP_INSERT_SCANCODES InsertCodesProcedure, + PVOID InsertCodesContext + ) ; + +CONSTANT: FACILITY_HID_ERROR_CODE HEX: 11 +: HIDP_ERROR_CODES ( SEV CODE -- HRESULT ) + [ 28 shift ] dip bitor FACILITY_HID_ERROR_CODE 16 shift bitor ; inline +: HIDP_STATUS_SUCCESS ( -- HRESULT ) HEX: 0 HEX: 0 HIDP_ERROR_CODES ; inline +: HIDP_STATUS_NULL ( -- HRESULT ) HEX: 8 HEX: 1 HIDP_ERROR_CODES ; inline +: HIDP_STATUS_INVALID_PREPARSED_DATA ( -- HRESULT ) HEX: C HEX: 1 HIDP_ERROR_CODES ; inline +: HIDP_STATUS_INVALID_REPORT_TYPE ( -- HRESULT ) HEX: C HEX: 2 HIDP_ERROR_CODES ; inline +: HIDP_STATUS_INVALID_REPORT_LENGTH ( -- HRESULT ) HEX: C HEX: 3 HIDP_ERROR_CODES ; inline +: HIDP_STATUS_USAGE_NOT_FOUND ( -- HRESULT ) HEX: C HEX: 4 HIDP_ERROR_CODES ; inline +: HIDP_STATUS_VALUE_OUT_OF_RANGE ( -- HRESULT ) HEX: C HEX: 5 HIDP_ERROR_CODES ; inline +: HIDP_STATUS_BAD_LOG_PHY_VALUES ( -- HRESULT ) HEX: C HEX: 6 HIDP_ERROR_CODES ; inline +: HIDP_STATUS_BUFFER_TOO_SMALL ( -- HRESULT ) HEX: C HEX: 7 HIDP_ERROR_CODES ; inline +: HIDP_STATUS_INTERNAL_ERROR ( -- HRESULT ) HEX: C HEX: 8 HIDP_ERROR_CODES ; inline +: HIDP_STATUS_I8042_TRANS_UNKNOWN ( -- HRESULT ) HEX: C HEX: 9 HIDP_ERROR_CODES ; inline +: HIDP_STATUS_INCOMPATIBLE_REPORT_ID ( -- HRESULT ) HEX: C HEX: A HIDP_ERROR_CODES ; inline +: HIDP_STATUS_NOT_VALUE_ARRAY ( -- HRESULT ) HEX: C HEX: B HIDP_ERROR_CODES ; inline +: HIDP_STATUS_IS_VALUE_ARRAY ( -- HRESULT ) HEX: C HEX: C HIDP_ERROR_CODES ; inline +: HIDP_STATUS_DATA_INDEX_NOT_FOUND ( -- HRESULT ) HEX: C HEX: D HIDP_ERROR_CODES ; inline +: HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE ( -- HRESULT ) HEX: C HEX: E HIDP_ERROR_CODES ; inline +: HIDP_STATUS_BUTTON_NOT_PRESSED ( -- HRESULT ) HEX: C HEX: F HIDP_ERROR_CODES ; inline +: HIDP_STATUS_REPORT_DOES_NOT_EXIST ( -- HRESULT ) HEX: C HEX: 10 HIDP_ERROR_CODES ; inline +: HIDP_STATUS_NOT_IMPLEMENTED ( -- HRESULT ) HEX: C HEX: 20 HIDP_ERROR_CODES ; inline +: HIDP_STATUS_I8242_TRANS_UNKNOWN ( -- HRESULT ) HIDP_STATUS_I8042_TRANS_UNKNOWN ; inline + +STRUCT: HIDD_CONFIGURATION + { cookie PVOID } + { size ULONG } + { RingBufferSize ULONG } ; +TYPEDEF: HIDD_CONFIGURATION* PHIDD_CONFIGURATION + +STRUCT: HIDD_ATTRIBUTES + { Size ULONG } + { VendorID USHORT } + { ProductID USHORT } + { VersionNumber USHORT } ; +TYPEDEF: HIDD_ATTRIBUTES* PHIDD_ATTRIBUTES + +FUNCTION: BOOLEAN +HidD_GetAttributes ( + HANDLE HidDeviceObject, + PHIDD_ATTRIBUTES Attributes + ) ; + +FUNCTION: void +HidD_GetHidGuid ( + LPGUID HidGuid + ) ; + +FUNCTION: BOOLEAN +HidD_GetPreparsedData ( + HANDLE HidDeviceObject, + PHIDP_PREPARSED_DATA* PreparsedData + ) ; + +FUNCTION: BOOLEAN +HidD_FreePreparsedData ( + PHIDP_PREPARSED_DATA PreparsedData + ) ; + +FUNCTION: BOOLEAN +HidD_FlushQueue ( + HANDLE HidDeviceObject + ) ; + +FUNCTION: BOOLEAN +HidD_GetConfiguration ( + HANDLE HidDeviceObject, + PHIDD_CONFIGURATION Configuration, + ULONG ConfigurationLength + ) ; + +FUNCTION: BOOLEAN +HidD_SetConfiguration ( + HANDLE HidDeviceObject, + PHIDD_CONFIGURATION Configuration, + ULONG ConfigurationLength + ) ; + +FUNCTION: BOOLEAN +HidD_GetFeature ( + HANDLE HidDeviceObject, + PVOID ReportBuffer, + ULONG ReportBufferLength + ) ; + +FUNCTION: BOOLEAN +HidD_SetFeature ( + HANDLE HidDeviceObject, + PVOID ReportBuffer, + ULONG ReportBufferLength + ) ; + +FUNCTION: BOOLEAN +HidD_GetInputReport ( + HANDLE HidDeviceObject, + PVOID ReportBuffer, + ULONG ReportBufferLength + ) ; + +FUNCTION: BOOLEAN +HidD_SetOutputReport ( + HANDLE HidDeviceObject, + PVOID ReportBuffer, + ULONG ReportBufferLength + ) ; + +FUNCTION: BOOLEAN +HidD_GetNumInputBuffers ( + HANDLE HidDeviceObject, + PULONG NumberBuffers + ) ; + +FUNCTION: BOOLEAN +HidD_SetNumInputBuffers ( + HANDLE HidDeviceObject, + ULONG NumberBuffers + ) ; + +FUNCTION: BOOLEAN +HidD_GetPhysicalDescriptor ( + HANDLE HidDeviceObject, + PVOID Buffer, + ULONG BufferLength + ) ; + +FUNCTION: BOOLEAN +HidD_GetManufacturerString ( + HANDLE HidDeviceObject, + PVOID Buffer, + ULONG BufferLength + ) ; + +FUNCTION: BOOLEAN +HidD_GetProductString ( + HANDLE HidDeviceObject, + PVOID Buffer, + ULONG BufferLength + ) ; + +FUNCTION: BOOLEAN +HidD_GetIndexedString ( + HANDLE HidDeviceObject, + ULONG StringIndex, + PVOID Buffer, + ULONG BufferLength + ) ; + +FUNCTION: BOOLEAN +HidD_GetSerialNumberString ( + HANDLE HidDeviceObject, + PVOID Buffer, + ULONG BufferLength + ) ; + +FUNCTION: BOOLEAN +HidD_GetMsGenreDescriptor ( + HANDLE HidDeviceObject, + PVOID Buffer, + ULONG BufferLength + ) ; From ed18b911c83e6b3f697731affb0744b2a56182a1 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 16:49:44 -0800 Subject: [PATCH 159/713] io.sockets.windows.nt: update string c-types in alien-indirect --- basis/io/sockets/windows/nt/nt.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/io/sockets/windows/nt/nt.factor b/basis/io/sockets/windows/nt/nt.factor index 0dd85954ac..8eb2df5b46 100644 --- a/basis/io/sockets/windows/nt/nt.factor +++ b/basis/io/sockets/windows/nt/nt.factor @@ -55,8 +55,8 @@ TUPLE: ConnectEx-args port [ lpOverlapped>> ] [ ptr>> ] } cleave - "int" - { "SOCKET" "sockaddr_in*" "int" "PVOID" "DWORD" "LPDWORD" "void*" } + int + { SOCKET void* int PVOID DWORD LPDWORD void* } "stdcall" alien-indirect drop winsock-error-string [ throw ] when* ; inline From 92e1ca8b612977f8090a1e8ac7fdb1f95a2b467c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 16:49:58 -0800 Subject: [PATCH 160/713] math.blas: update string c-types --- basis/math/blas/matrices/matrices.factor | 8 ++++---- basis/math/blas/vectors/vectors.factor | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/basis/math/blas/matrices/matrices.factor b/basis/math/blas/matrices/matrices.factor index 0a6fc147ad..22c649c544 100644 --- a/basis/math/blas/matrices/matrices.factor +++ b/basis/math/blas/matrices/matrices.factor @@ -305,10 +305,10 @@ M: MATRIX pprint-delims : define-complex-blas-matrix ( TYPE T -- ) "U" "C" (define-blas-matrix) ; -"float" "S" define-real-blas-matrix -"double" "D" define-real-blas-matrix -"complex-float" "C" define-complex-blas-matrix -"complex-double" "Z" define-complex-blas-matrix +float "S" define-real-blas-matrix +double "D" define-real-blas-matrix +complex-float "C" define-complex-blas-matrix +complex-double "Z" define-complex-blas-matrix >> diff --git a/basis/math/blas/vectors/vectors.factor b/basis/math/blas/vectors/vectors.factor index 083400224e..caf0984aa4 100644 --- a/basis/math/blas/vectors/vectors.factor +++ b/basis/math/blas/vectors/vectors.factor @@ -238,10 +238,10 @@ M: VECTOR Vasum [ drop (define-blas-vector) ] [ (define-complex-blas-vector) ] 3bi ; -"float" "S" define-real-blas-vector -"double" "D" define-real-blas-vector -"complex-float" "C" "S" define-complex-blas-vector -"complex-double" "Z" "D" define-complex-blas-vector +float "S" define-real-blas-vector +double "D" define-real-blas-vector +complex-float "C" "S" define-complex-blas-vector +complex-double "Z" "D" define-complex-blas-vector >> From d5bf6e55cd5ab4a0d544bd541bd7c1229592337f Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 19:23:47 -0800 Subject: [PATCH 161/713] more implementation of pointer c-types. make it so that { char* binary } acts like a real pointer to char instead of stringifying, and add byte* typedef for { char* binary } --- basis/alien/arrays/arrays.factor | 15 ++- basis/alien/c-types/c-types-tests.factor | 45 +++++---- basis/alien/c-types/c-types.factor | 96 +++++++++++-------- basis/alien/parser/parser.factor | 8 +- basis/alien/prettyprint/prettyprint.factor | 2 +- basis/compiler/codegen/codegen.factor | 2 +- .../specialized-arrays.factor | 5 + extra/alien/data/map/map.factor | 4 +- 8 files changed, 105 insertions(+), 72 deletions(-) diff --git a/basis/alien/arrays/arrays.factor b/basis/alien/arrays/arrays.factor index cf6e8640f0..c62800df36 100644 --- a/basis/alien/arrays/arrays.factor +++ b/basis/alien/arrays/arrays.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.strings alien.c-types alien.data alien.accessors arrays words sequences math kernel namespaces fry cpu.architecture -io.encodings.utf8 accessors ; +io.encodings.binary io.encodings.utf8 accessors ; IN: alien.arrays INSTANCE: array value-type @@ -88,10 +88,14 @@ M: string-type c-type-unboxer drop void* c-type-unboxer ; M: string-type c-type-boxer-quot - second '[ _ alien>string ] ; + second dup binary = + [ drop void* c-type-boxer-quot ] + [ '[ _ alien>string ] ] if ; M: string-type c-type-unboxer-quot - second '[ _ string>alien ] ; + second dup binary = + [ drop void* c-type-unboxer-quot ] + [ '[ _ string>alien ] ] if ; M: string-type c-type-getter drop [ alien-cell ] ; @@ -99,5 +103,8 @@ M: string-type c-type-getter M: string-type c-type-setter drop [ set-alien-cell ] ; -TYPEDEF: { char* utf8 } char* +{ char* utf8 } char typedef +{ char* utf8 } uchar typedef +{ char* binary } byte typedef +{ char* binary } ubyte typedef diff --git a/basis/alien/c-types/c-types-tests.factor b/basis/alien/c-types/c-types-tests.factor index 5f903c9a34..13bdfa742a 100644 --- a/basis/alien/c-types/c-types-tests.factor +++ b/basis/alien/c-types/c-types-tests.factor @@ -1,6 +1,6 @@ USING: alien alien.syntax alien.c-types alien.parser eval kernel tools.test sequences system libc alien.strings -io.encodings.utf8 math.constants classes.struct classes +io.encodings.ascii io.encodings.utf8 math.constants classes.struct classes accessors compiler.units ; IN: alien.c-types.tests @@ -16,13 +16,13 @@ UNION-STRUCT: foo { a int } { b int } ; -[ t ] [ pointer: void c-type void* c-type eq? ] unit-test -[ t ] [ pointer: int c-type void* c-type eq? ] unit-test -[ t ] [ pointer: int* c-type void* c-type eq? ] unit-test -[ f ] [ pointer: foo c-type void* c-type eq? ] unit-test -[ t ] [ pointer: foo* c-type void* c-type eq? ] unit-test +[ t ] [ pointer: void c-type void* c-type = ] unit-test +[ t ] [ pointer: int c-type void* c-type = ] unit-test +[ t ] [ pointer: int* c-type void* c-type = ] unit-test +[ f ] [ pointer: foo c-type void* c-type = ] unit-test +[ t ] [ pointer: foo* c-type void* c-type = ] unit-test -[ t ] [ pointer: char c-type c-string c-type eq? ] unit-test +[ t ] [ pointer: char c-type char* c-type = ] unit-test [ t ] [ pointer: foo c-type-boxer-quot foo c-type-boxer-quot = ] unit-test @@ -30,32 +30,39 @@ UNION-STRUCT: foo TYPEDEF: int MyInt -[ t ] [ int c-type MyInt c-type eq? ] unit-test -[ t ] [ void* c-type pointer: MyInt c-type eq? ] unit-test +[ t ] [ int c-type MyInt c-type = ] unit-test +[ t ] [ void* c-type pointer: MyInt c-type = ] unit-test [ 32 ] [ { int 8 } heap-size ] unit-test +TYPEDEF: char MyChar + +[ t ] [ pointer: char c-type pointer: MyChar c-type = ] unit-test +[ t ] [ char* c-type pointer: MyChar c-type = ] unit-test + +TYPEDEF: char MyFunkyChar +{ char* ascii } pointer: MyFunkyChar typedef + +[ f ] [ pointer: char c-type pointer: MyFunkyChar c-type = ] unit-test +[ { char* ascii } ] [ pointer: MyFunkyChar c-type ] unit-test + TYPEDEF: char* MyString -[ t ] [ c-string c-type MyString c-type eq? ] unit-test -[ t ] [ void* c-type pointer: MyString c-type eq? ] unit-test +[ t ] [ char* c-type MyString c-type = ] unit-test +[ t ] [ void* c-type pointer: MyString c-type = ] unit-test TYPEDEF: int* MyIntArray -[ t ] [ void* c-type MyIntArray c-type eq? ] unit-test +[ t ] [ void* c-type MyIntArray c-type = ] unit-test -TYPEDEF: c-string MyLPBYTE +TYPEDEF: char* MyLPBYTE -[ t ] [ { c-string utf8 } c-type MyLPBYTE c-type = ] unit-test +[ t ] [ { char* utf8 } c-type MyLPBYTE c-type = ] unit-test [ 0 B{ 1 2 3 4 } ] must-fail -C-TYPE: MyOpaqueType - -[ f ] [ pointer: MyOpaqueType c-type void* c-type eq? ] unit-test - os windows? cpu x86.64? and [ [ -2147467259 ] [ 2147500037 *long ] unit-test ] when @@ -68,7 +75,7 @@ os windows? cpu x86.64? and [ C-TYPE: opaque -[ t ] [ void* c-type opaque resolve-pointer-type c-type eq? ] unit-test +[ t ] [ void* c-type pointer: opaque c-type = ] unit-test [ opaque c-type ] [ no-c-type? ] must-fail-with [ """ diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor index 4a7fd840ef..b038244cdd 100644 --- a/basis/alien/c-types/c-types.factor +++ b/basis/alien/c-types/c-types.factor @@ -45,21 +45,24 @@ stack-align? ; ERROR: no-c-type name ; -PREDICATE: c-type-word < word - "c-type" word-prop ; - ! C type protocol GENERIC: c-type ( name -- c-type ) foldable : void? ( c-type -- ? ) void = ; inline +PREDICATE: c-type-word < word + "c-type" word-prop ; + TUPLE: pointer { to initial: void read-only } ; C: pointer +UNION: c-type-name + c-type-word pointer ; + : resolve-typedef ( name -- c-type ) dup void? [ no-c-type ] when - dup c-type-word? [ c-type ] when ; + dup c-type-name? [ c-type ] when ; > ; -M: c-type-word c-type-class c-type c-type-class ; +M: c-type-name c-type-class c-type c-type-class ; GENERIC: c-type-boxed-class ( name -- class ) M: abstract-c-type c-type-boxed-class boxed-class>> ; -M: c-type-word c-type-boxed-class c-type c-type-boxed-class ; +M: c-type-name c-type-boxed-class c-type c-type-boxed-class ; GENERIC: c-type-boxer ( name -- boxer ) M: c-type c-type-boxer boxer>> ; -M: c-type-word c-type-boxer c-type c-type-boxer ; +M: c-type-name c-type-boxer c-type c-type-boxer ; GENERIC: c-type-boxer-quot ( name -- quot ) M: abstract-c-type c-type-boxer-quot boxer-quot>> ; -M: c-type-word c-type-boxer-quot c-type c-type-boxer-quot ; +M: c-type-name c-type-boxer-quot c-type c-type-boxer-quot ; GENERIC: c-type-unboxer ( name -- boxer ) M: c-type c-type-unboxer unboxer>> ; -M: c-type-word c-type-unboxer c-type c-type-unboxer ; +M: c-type-name c-type-unboxer c-type c-type-unboxer ; GENERIC: c-type-unboxer-quot ( name -- quot ) M: abstract-c-type c-type-unboxer-quot unboxer-quot>> ; -M: c-type-word c-type-unboxer-quot c-type c-type-unboxer-quot ; +M: c-type-name c-type-unboxer-quot c-type c-type-unboxer-quot ; GENERIC: c-type-rep ( name -- rep ) M: c-type c-type-rep rep>> ; -M: c-type-word c-type-rep c-type c-type-rep ; +M: c-type-name c-type-rep c-type c-type-rep ; GENERIC: c-type-getter ( name -- quot ) M: c-type c-type-getter getter>> ; -M: c-type-word c-type-getter c-type c-type-getter ; +M: c-type-name c-type-getter c-type c-type-getter ; GENERIC: c-type-setter ( name -- quot ) M: c-type c-type-setter setter>> ; -M: c-type-word c-type-setter c-type c-type-setter ; +M: c-type-name c-type-setter c-type c-type-setter ; GENERIC: c-type-align ( name -- n ) M: abstract-c-type c-type-align align>> ; -M: c-type-word c-type-align c-type c-type-align ; +M: c-type-name c-type-align c-type c-type-align ; GENERIC: c-type-align-first ( name -- n ) -M: c-type-word c-type-align-first c-type c-type-align-first ; +M: c-type-name c-type-align-first c-type c-type-align-first ; M: abstract-c-type c-type-align-first align-first>> ; @@ -152,7 +155,7 @@ GENERIC: c-type-stack-align? ( name -- ? ) M: c-type c-type-stack-align? stack-align?>> ; -M: c-type-word c-type-stack-align? c-type c-type-stack-align? ; +M: c-type-name c-type-stack-align? c-type c-type-stack-align? ; : c-type-box ( n c-type -- ) [ c-type-rep ] [ c-type-boxer [ "No boxer" throw ] unless* ] bi @@ -166,37 +169,37 @@ GENERIC: box-parameter ( n c-type -- ) M: c-type box-parameter c-type-box ; -M: c-type-word box-parameter c-type box-parameter ; +M: c-type-name box-parameter c-type box-parameter ; GENERIC: box-return ( c-type -- ) M: c-type box-return f swap c-type-box ; -M: c-type-word box-return c-type box-return ; +M: c-type-name box-return c-type box-return ; GENERIC: unbox-parameter ( n c-type -- ) M: c-type unbox-parameter c-type-unbox ; -M: c-type-word unbox-parameter c-type unbox-parameter ; +M: c-type-name unbox-parameter c-type unbox-parameter ; GENERIC: unbox-return ( c-type -- ) M: c-type unbox-return f swap c-type-unbox ; -M: c-type-word unbox-return c-type unbox-return ; +M: c-type-name unbox-return c-type unbox-return ; : little-endian? ( -- ? ) 1 *char 1 = ; foldable GENERIC: heap-size ( name -- size ) -M: c-type-word heap-size c-type heap-size ; +M: c-type-name heap-size c-type heap-size ; M: abstract-c-type heap-size size>> ; GENERIC: stack-size ( name -- size ) -M: c-type-word stack-size c-type stack-size ; +M: c-type-name stack-size c-type stack-size ; M: c-type stack-size size>> cell align ; @@ -233,7 +236,7 @@ MIXIN: value-type GENERIC: typedef ( old new -- ) PREDICATE: typedef-word < c-type-word - "c-type" word-prop c-type-word? ; + "c-type" word-prop c-type-name? ; M: word typedef ( old new -- ) { @@ -243,7 +246,7 @@ M: word typedef ( old new -- ) M: pointer typedef ( old new -- ) to>> dup c-type-word? - [ ] + [ swap "pointer-c-type" set-word-prop ] [ 2drop ] if ; TUPLE: long-long-type < c-type ; @@ -278,6 +281,10 @@ M: long-long-type box-return ( c-type -- ) : if-void ( c-type true false -- ) pick void? [ drop nip call ] [ nip call ] if ; inline +SYMBOLS: + ptrdiff_t intptr_t uintptr_t size_t + byte ubyte char* ; + CONSTANT: primitive-types { char uchar @@ -287,35 +294,37 @@ CONSTANT: primitive-types longlong ulonglong float double void* bool + char* } -SYMBOLS: - ptrdiff_t intptr_t uintptr_t size_t - char* ; - ->boxer-quot ; -: string-pointer-type? ( type -- ? ) - dup pointer? [ drop f ] - [ resolve-typedef { char uchar } member? ] if ; + M: pointer c-type [ \ void* c-type ] dip - to>> { - { [ dup string-pointer-type? ] [ drop \ char* c-type ] } - { [ dup primitive-pointer-type? ] [ drop ] } - [ (pointer-c-type) ] - } cond ; + to>> dup special-pointer-type + [ nip ] [ + dup primitive-pointer-type? [ drop ] [ (pointer-c-type) ] if + ] ?if ; : 8-byte-alignment ( c-type -- c-type ) { @@ -528,6 +537,9 @@ M: pointer c-type \ uint c-type \ uintptr_t typedef \ uint c-type \ size_t typedef ] if + + \ char \ byte typedef + \ uchar \ ubyte typedef ] with-compilation-unit M: char-16-rep rep-component-type drop char ; diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index 09ee88c173..50d1bfd320 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -30,9 +30,11 @@ IN: alien.parser (parse-c-type) dup valid-c-type? [ no-c-type ] unless ; : scan-c-type ( -- c-type ) - scan dup "{" = - [ drop \ } parse-until >array ] - [ parse-c-type ] if ; + scan { + { [ dup "{" = ] [ drop \ } parse-until >array ] } + { [ dup "pointer:" = ] [ drop scan-c-type ] } + [ parse-c-type ] + } cond ; : reset-c-type ( word -- ) dup "struct-size" word-prop diff --git a/basis/alien/prettyprint/prettyprint.factor b/basis/alien/prettyprint/prettyprint.factor index 6bfbf313a1..489ea0b10a 100644 --- a/basis/alien/prettyprint/prettyprint.factor +++ b/basis/alien/prettyprint/prettyprint.factor @@ -21,7 +21,7 @@ M: c-type-word declarations. drop ; GENERIC: pprint-c-type ( c-type -- ) M: word pprint-c-type pprint-word ; -M: pointer pprint-c-type to>> pprint-c-type "*" text ; +M: pointer pprint-c-type pprint* ; M: wrapper pprint-c-type wrapped>> pprint-word ; M: string pprint-c-type text ; M: array pprint-c-type pprint* ; diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index d6e58f7ac1..963ed0ab28 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -325,7 +325,7 @@ GENERIC: flatten-value-type ( type -- types ) M: object flatten-value-type 1array ; M: struct-c-type flatten-value-type (flatten-int-type) ; M: long-long-type flatten-value-type (flatten-int-type) ; -M: c-type-word flatten-value-type c-type flatten-value-type ; +M: c-type-name flatten-value-type c-type flatten-value-type ; : flatten-value-types ( params -- params ) #! Convert value type structs to consecutive void*s. diff --git a/basis/specialized-arrays/specialized-arrays.factor b/basis/specialized-arrays/specialized-arrays.factor index 67689998ab..992dbac6d6 100644 --- a/basis/specialized-arrays/specialized-arrays.factor +++ b/basis/specialized-arrays/specialized-arrays.factor @@ -119,6 +119,7 @@ M: A v*high [ * \ T heap-size neg shift ] 2map ; inline : underlying-type ( c-type -- c-type' ) dup "c-type" word-prop { { [ dup not ] [ drop no-c-type ] } + { [ dup pointer? ] [ 2drop void* ] } { [ dup c-type-word? ] [ nip underlying-type ] } [ drop ] } cond ; @@ -139,6 +140,7 @@ PRIVATE> generate-vocab ; M: c-type-word require-c-array define-array-vocab drop ; +M: pointer require-c-array drop void* require-c-array ; ERROR: specialized-array-vocab-not-loaded c-type ; @@ -146,16 +148,19 @@ M: c-type-word c-array-constructor underlying-type dup [ name>> "<" "-array>" surround ] [ specialized-array-vocab ] bi lookup [ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable +M: pointer c-array-constructor drop void* c-array-constructor ; M: c-type-word c-(array)-constructor underlying-type dup [ name>> "(" "-array)" surround ] [ specialized-array-vocab ] bi lookup [ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable +M: pointer c-(array)-constructor drop void* c-(array)-constructor ; M: c-type-word c-direct-array-constructor underlying-type dup [ name>> "" surround ] [ specialized-array-vocab ] bi lookup [ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable +M: pointer c-direct-array-constructor drop void* c-direct-array-constructor ; SYNTAX: SPECIALIZED-ARRAYS: ";" parse-tokens [ parse-c-type define-array-vocab use-vocab ] each ; diff --git a/extra/alien/data/map/map.factor b/extra/alien/data/map/map.factor index 06997bce56..6c93e8f4b6 100644 --- a/extra/alien/data/map/map.factor +++ b/extra/alien/data/map/map.factor @@ -54,7 +54,7 @@ INSTANCE: data-map-param immutable-sequence nip '[ _ ] ; : [>param] ( type -- quot ) - c-type-count over c-type-word? + c-type-count over c-type-name? [ [>c-type-param] ] [ [>object-param] ] if ; MACRO: >param ( in -- quot: ( array -- param ) ) @@ -74,7 +74,7 @@ MACRO: >param ( in -- quot: ( array -- param ) ) "Factor sequences as data-map outputs not supported" throw ; : [alloc-param] ( type -- quot ) - c-type-count over c-type-word? + c-type-count over c-type-name? [ [alloc-c-type-param] ] [ [alloc-object-param] ] if ; MACRO: alloc-param ( out -- quot: ( len -- param ) ) From 5faa97e42c5cd5f838ad9b26fd340b6b946930e2 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 21:06:00 -0800 Subject: [PATCH 162/713] alien.parser: favor parsing "foo*" as pointer-to-foo now --- basis/alien/c-types/c-types.factor | 4 +++- basis/alien/parser/parser.factor | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor index b038244cdd..9db6ac7f4a 100644 --- a/basis/alien/c-types/c-types.factor +++ b/basis/alien/c-types/c-types.factor @@ -304,7 +304,9 @@ CONSTANT: primitive-types : resolve-pointer-typedef ( type -- base-type ) dup "c-type" word-prop dup word? - [ nip resolve-pointer-typedef ] [ drop ] if ; + [ nip resolve-pointer-typedef ] [ + pointer? [ drop void* ] when + ] if ; : special-pointer-type ( type -- special-type ) dup c-type-word? [ diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index 50d1bfd320..dee5c6e1dd 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -18,8 +18,8 @@ IN: alien.parser { { [ dup "void" = ] [ drop void ] } { [ CHAR: ] over member? ] [ parse-array-type parse-c-type-name prefix ] } - { [ dup search ] [ parse-c-type-name ] } { [ "*" ?tail ] [ (parse-c-type) ] } + { [ dup search ] [ parse-c-type-name ] } [ dup search [ ] [ no-word ] ?if ] } cond ; From 04cc3052b67f3bc7a1d6a93aedca319610e68c84 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 21:32:34 -0800 Subject: [PATCH 163/713] alien.prettyprint: pprint pointer objects as "type*" in c-type contexts --- basis/alien/prettyprint/prettyprint.factor | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/basis/alien/prettyprint/prettyprint.factor b/basis/alien/prettyprint/prettyprint.factor index 489ea0b10a..52e9978a5f 100644 --- a/basis/alien/prettyprint/prettyprint.factor +++ b/basis/alien/prettyprint/prettyprint.factor @@ -19,9 +19,19 @@ M: c-type-word definer drop \ C-TYPE: f ; M: c-type-word definition drop f ; M: c-type-word declarations. drop ; +> ; +M: pointer pointer-string to>> pointer-string [ CHAR: * suffix ] [ f ] if* ; +PRIVATE> + GENERIC: pprint-c-type ( c-type -- ) M: word pprint-c-type pprint-word ; -M: pointer pprint-c-type pprint* ; +M: pointer pprint-c-type + dup pointer-string + [ swap present-text ] + [ pprint* ] if* ; M: wrapper pprint-c-type wrapped>> pprint-word ; M: string pprint-c-type text ; M: array pprint-c-type pprint* ; From 957f2d9ff61234ec90cf8c5a8a2aa9ac51ff7e04 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 21 Feb 2010 23:37:33 -0600 Subject: [PATCH 164/713] Check if we're using ttys before starting curses, since initscr exits on error for some dumb reason --- basis/unix/ffi/ffi.factor | 1 + extra/curses/curses-tests.factor | 5 +++-- extra/curses/curses.factor | 7 ++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/basis/unix/ffi/ffi.factor b/basis/unix/ffi/ffi.factor index 3882f6fc80..10346cff2c 100644 --- a/basis/unix/ffi/ffi.factor +++ b/basis/unix/ffi/ffi.factor @@ -101,6 +101,7 @@ FUNCTION: uid_t getuid ; FUNCTION: uint htonl ( uint n ) ; FUNCTION: ushort htons ( ushort n ) ; ! FUNCTION: int issetugid ; +FUNCTION: int isatty ( int fildes ) ; FUNCTION: int ioctl ( int fd, ulong request, char* argp ) ; FUNCTION: int lchown ( char* path, uid_t owner, gid_t group ) ; FUNCTION: int listen ( int s, int backlog ) ; diff --git a/extra/curses/curses-tests.factor b/extra/curses/curses-tests.factor index 21463b207b..bd98a7aff1 100644 --- a/extra/curses/curses-tests.factor +++ b/extra/curses/curses-tests.factor @@ -14,5 +14,6 @@ IN: curses.tests 2000000 sleep ] with-curses ; -[ -] [ hello-curses ] unit-test +curses-ok? [ + [ ] [ hello-curses ] unit-test +] when diff --git a/extra/curses/curses.factor b/extra/curses/curses.factor index 69c6503aa2..dfb1b8672a 100644 --- a/extra/curses/curses.factor +++ b/extra/curses/curses.factor @@ -4,7 +4,7 @@ USING: accessors alien.c-types alien.strings assocs byte-arrays combinators continuations destructors fry io.encodings.8-bit io io.encodings.string io.encodings.utf8 kernel locals math namespaces prettyprint sequences classes.struct -strings threads curses.ffi ; +strings threads curses.ffi unix.ffi ; IN: curses SYMBOL: curses-windows @@ -19,6 +19,7 @@ ERROR: duplicate-window window ; ERROR: unnamed-window window ; ERROR: window-not-found window ; ERROR: curses-failed ; +ERROR: unsupported-curses-terminal ; : get-window ( string -- window ) dup curses-windows get at* @@ -28,7 +29,11 @@ ERROR: curses-failed ; : curses-error ( n -- ) ERR = [ curses-failed ] when ; +: curses-ok? ( -- ? ) + { 0 1 2 } [ isatty 0 = not ] all? ; + : with-curses ( quot -- ) + curses-ok? [ unsupported-curses-terminal ] unless H{ } clone curses-windows [ initscr curses-error [ From 5b726f0af9fef70236fe856dc455237f087d08cc Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 22:04:23 -0800 Subject: [PATCH 165/713] add missing using to classes.struct tests --- basis/classes/struct/struct-tests.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/classes/struct/struct-tests.factor b/basis/classes/struct/struct-tests.factor index 0316b1fae0..82530614bf 100644 --- a/basis/classes/struct/struct-tests.factor +++ b/basis/classes/struct/struct-tests.factor @@ -1,5 +1,5 @@ ! (c)Joe Groff bsd license -USING: accessors alien alien.c-types alien.data ascii +USING: accessors alien alien.c-types alien.data alien.syntax ascii assocs byte-arrays classes.struct classes.tuple.private classes.tuple combinators compiler.tree.debugger compiler.units destructors io.encodings.utf8 io.pathnames io.streams.string kernel libc From dcd76d2abe08c343d1efccaf94593f28ff21c700 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 22:07:32 -0800 Subject: [PATCH 166/713] windows.com.syntax: don't put c-type words inside stack effect of Interface::Method words --- basis/windows/com/syntax/syntax.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/windows/com/syntax/syntax.factor b/basis/windows/com/syntax/syntax.factor index 5e08454d5a..7e93a6e9f8 100644 --- a/basis/windows/com/syntax/syntax.factor +++ b/basis/windows/com/syntax/syntax.factor @@ -71,7 +71,7 @@ ERROR: no-com-interface interface ; : (stack-effect-from-return-and-parameters) ( return parameters -- stack-effect ) swap [ [ second ] map ] - [ dup void? [ drop { } ] [ 1array ] if ] bi* + [ dup void? [ drop { } ] [ name>> 1array ] if ] bi* ; : (define-word-for-function) ( function interface n -- ) From 525a57fa3d84ff7a614f84d933d83558972d9719 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 22:07:53 -0800 Subject: [PATCH 167/713] windows.com: add missing USING: windows.types --- basis/windows/com/com-tests.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/windows/com/com-tests.factor b/basis/windows/com/com-tests.factor index 329a84ef13..f0b4eadb9f 100644 --- a/basis/windows/com/com-tests.factor +++ b/basis/windows/com/com-tests.factor @@ -1,5 +1,5 @@ USING: kernel windows.com windows.com.syntax windows.ole32 -alien alien.syntax tools.test libc alien.c-types +windows.types alien alien.syntax tools.test libc alien.c-types namespaces arrays continuations accessors math windows.com.wrapper windows.com.wrapper.private destructors effects compiler.units ; IN: windows.com.tests From a0b3a370b8d19f51e8471c543e0ce447bf548431 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 17 Feb 2010 16:42:53 -0600 Subject: [PATCH 168/713] Fix quirk in open-in-explorer -- msft explorer wouldn't go to previous directory correctly if / was a path separator --- basis/tools/deploy/windows/windows.factor | 7 ++++++- basis/windows/shell32/shell32.factor | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/basis/tools/deploy/windows/windows.factor b/basis/tools/deploy/windows/windows.factor index 1dd60583fa..f52154ccd0 100755 --- a/basis/tools/deploy/windows/windows.factor +++ b/basis/tools/deploy/windows/windows.factor @@ -5,7 +5,8 @@ io.encodings.ascii kernel namespaces sequences locals system splitting tools.deploy.backend tools.deploy.config tools.deploy.config.editor assocs hashtables prettyprint combinators windows.kernel32 windows.shell32 windows.user32 -alien.c-types vocabs.metadata vocabs.loader tools.deploy.windows.ico ; +alien.c-types vocabs.metadata vocabs.loader tools.deploy.windows.ico +io.files.windows.nt ; IN: tools.deploy.windows CONSTANT: app-icon-resource-id "APPICON" @@ -22,6 +23,10 @@ CONSTANT: app-icon-resource-id "APPICON" dup copy-dll deploy-ui? get ".exe" ".com" ? copy-vm ; +: open-in-explorer ( dir -- ) + [ f "open" ] dip absolute-path normalize-separators + f f SW_SHOWNORMAL ShellExecute drop ; + : embed-ico ( vm vocab -- ) dup vocab-windows-icon-path vocab-append-path dup exists? [ binary file-contents app-icon-resource-id embed-icon-resource ] diff --git a/basis/windows/shell32/shell32.factor b/basis/windows/shell32/shell32.factor index 08474d4bdd..30104e7723 100644 --- a/basis/windows/shell32/shell32.factor +++ b/basis/windows/shell32/shell32.factor @@ -87,9 +87,6 @@ ALIAS: SHGetFolderPath SHGetFolderPathW FUNCTION: HINSTANCE ShellExecuteW ( HWND hwnd, LPCTSTR lpOperation, LPCTSTR lpFile, LPCTSTR lpParameters, LPCTSTR lpDirectory, INT nShowCmd ) ; ALIAS: ShellExecute ShellExecuteW -: open-in-explorer ( dir -- ) - [ f "open" ] dip absolute-path f f SW_SHOWNORMAL ShellExecute drop ; - : shell32-directory ( n -- str ) f swap f SHGFP_TYPE_DEFAULT MAX_UNICODE_PATH From 82e773f8ba97411758b42351afe453962aa3f5dd Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 17 Feb 2010 16:43:53 -0600 Subject: [PATCH 169/713] Add some more win32 symbols --- basis/windows/advapi32/advapi32.factor | 12 +- basis/windows/user32/user32.factor | 149 ++++++++++++++++++++++++- 2 files changed, 158 insertions(+), 3 deletions(-) diff --git a/basis/windows/advapi32/advapi32.factor b/basis/windows/advapi32/advapi32.factor index fa478b03ed..d5fe33b745 100644 --- a/basis/windows/advapi32/advapi32.factor +++ b/basis/windows/advapi32/advapi32.factor @@ -405,7 +405,7 @@ CONSTANT: KEY_READ HEX: 20019 CONSTANT: KEY_WOW64_32KEY HEX: 0200 CONSTANT: KEY_WOW64_64KEY HEX: 0100 CONSTANT: KEY_WRITE HEX: 20006 -CONSTANT: KEY_EXECUTE KEY_READ +ALIAS: KEY_EXECUTE KEY_READ CONSTANT: KEY_ALL_ACCESS HEX: F003F CONSTANT: REG_NONE 0 @@ -423,6 +423,9 @@ CONSTANT: REG_RESOURCE_REQUIREMENTS_LIST 10 CONSTANT: REG_QWORD 11 CONSTANT: REG_QWORD_LITTLE_ENDIAN 11 +CONSTANT: REG_CREATED_NEW_KEY 1 +CONSTANT: REG_OPENED_EXISTING_KEY 2 + TYPEDEF: DWORD REGSAM ! : I_ScGetCurrentGroupStateW ; @@ -926,6 +929,7 @@ FUNCTION: LONG RegCloseKey ( HKEY hKey ) ; ! : RegCreateKeyA ; ! : RegCreateKeyExA ; FUNCTION: LONG RegCreateKeyExW ( HKEY hKey, LPCTSTR lpSubKey, DWORD Reserved, LPTSTR lpClass, DWORD dwOptions, REGSAM samDesired, LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, LPDWORD lpdwDisposition ) ; +ALIAS: RegCreateKeyEx RegCreateKeyExW ! : RegCreateKeyW ! : RegDeleteKeyA ; ! : RegDeleteKeyW ; @@ -949,6 +953,7 @@ ALIAS: RegDeleteKeyEx RegDeleteKeyExW ! : RegDisablePredefinedCache ; ! : RegEnumKeyA ; ! : RegEnumKeyExA ; + FUNCTION: LONG RegEnumKeyExW ( HKEY hKey, DWORD dwIndex, @@ -959,6 +964,8 @@ FUNCTION: LONG RegEnumKeyExW ( LPDWORD lpcClass, PFILETIME lpftLastWriteTime ) ; +ALIAS: RegEnumKeyEx RegEnumKeyExW + ! : RegEnumKeyW ; ! : RegEnumValueA ; @@ -1023,7 +1030,8 @@ ALIAS: RegQueryValueEx RegQueryValueExW ! : RegSetValueA ; ! : RegSetValueExA ; ! : RegSetValueExW ; -! : RegSetValueW ; +FUNCTION: LONG RegSetValueExW ( HKEY hKey, LPCTSTR lpValueName, DWORD Reserved, DWORD dwType, BYTE* lpData, DWORD cbData ) ; +ALIAS: RegSetValueEx RegSetValueExW ! : RegUnLoadKeyA ; ! : RegUnLoadKeyW ; ! : RegisterEventSourceA ; diff --git a/basis/windows/user32/user32.factor b/basis/windows/user32/user32.factor index 15eb9ba2f5..27636271cb 100644 --- a/basis/windows/user32/user32.factor +++ b/basis/windows/user32/user32.factor @@ -608,6 +608,150 @@ CONSTANT: MF_HELP HEX: 4000 CONSTANT: MF_RIGHTJUSTIFY HEX: 4000 CONSTANT: MF_MOUSESELECT HEX: 8000 +CONSTANT: SPI_GETBEEP 1 +CONSTANT: SPI_SETBEEP 2 +CONSTANT: SPI_GETMOUSE 3 +CONSTANT: SPI_SETMOUSE 4 +CONSTANT: SPI_GETBORDER 5 +CONSTANT: SPI_SETBORDER 6 +CONSTANT: SPI_GETKEYBOARDSPEED 10 +CONSTANT: SPI_SETKEYBOARDSPEED 11 +CONSTANT: SPI_LANGDRIVER 12 +CONSTANT: SPI_ICONHORIZONTALSPACING 13 +CONSTANT: SPI_GETSCREENSAVETIMEOUT 14 +CONSTANT: SPI_SETSCREENSAVETIMEOUT 15 +CONSTANT: SPI_GETSCREENSAVEACTIVE 16 +CONSTANT: SPI_SETSCREENSAVEACTIVE 17 +CONSTANT: SPI_GETGRIDGRANULARITY 18 +CONSTANT: SPI_SETGRIDGRANULARITY 19 +CONSTANT: SPI_SETDESKWALLPAPER 20 +CONSTANT: SPI_SETDESKPATTERN 21 +CONSTANT: SPI_GETKEYBOARDDELAY 22 +CONSTANT: SPI_SETKEYBOARDDELAY 23 +CONSTANT: SPI_ICONVERTICALSPACING 24 +CONSTANT: SPI_GETICONTITLEWRAP 25 +CONSTANT: SPI_SETICONTITLEWRAP 26 +CONSTANT: SPI_GETMENUDROPALIGNMENT 27 +CONSTANT: SPI_SETMENUDROPALIGNMENT 28 +CONSTANT: SPI_SETDOUBLECLKWIDTH 29 +CONSTANT: SPI_SETDOUBLECLKHEIGHT 30 +CONSTANT: SPI_GETICONTITLELOGFONT 31 +CONSTANT: SPI_SETDOUBLECLICKTIME 32 +CONSTANT: SPI_SETMOUSEBUTTONSWAP 33 +CONSTANT: SPI_SETICONTITLELOGFONT 34 +CONSTANT: SPI_GETFASTTASKSWITCH 35 +CONSTANT: SPI_SETFASTTASKSWITCH 36 +CONSTANT: SPI_SETDRAGFULLWINDOWS 37 +CONSTANT: SPI_GETDRAGFULLWINDOWS 38 + +CONSTANT: SPI_GETFILTERKEYS 50 +CONSTANT: SPI_SETFILTERKEYS 51 +CONSTANT: SPI_GETTOGGLEKEYS 52 +CONSTANT: SPI_SETTOGGLEKEYS 53 +CONSTANT: SPI_GETMOUSEKEYS 54 +CONSTANT: SPI_SETMOUSEKEYS 55 +CONSTANT: SPI_GETSHOWSOUNDS 56 +CONSTANT: SPI_SETSHOWSOUNDS 57 +CONSTANT: SPI_GETSTICKYKEYS 58 +CONSTANT: SPI_SETSTICKYKEYS 59 +CONSTANT: SPI_GETACCESSTIMEOUT 60 +CONSTANT: SPI_SETACCESSTIMEOUT 61 + +CONSTANT: SPI_GETSOUNDSENTRY 64 +CONSTANT: SPI_SETSOUNDSENTRY 65 + +! WINVER >= 0x0400 +CONSTANT: SPI_GETNONCLIENTMETRICS 41 +CONSTANT: SPI_SETNONCLIENTMETRICS 42 +CONSTANT: SPI_GETMINIMIZEDMETRICS 43 +CONSTANT: SPI_SETMINIMIZEDMETRICS 44 +CONSTANT: SPI_GETICONMETRICS 45 +CONSTANT: SPI_SETICONMETRICS 46 +CONSTANT: SPI_SETWORKAREA 47 +CONSTANT: SPI_GETWORKAREA 48 +CONSTANT: SPI_SETPENWINDOWS 49 + +CONSTANT: SPI_GETSERIALKEYS 62 +CONSTANT: SPI_SETSERIALKEYS 63 +CONSTANT: SPI_GETHIGHCONTRAST 66 +CONSTANT: SPI_SETHIGHCONTRAST 67 +CONSTANT: SPI_GETKEYBOARDPREF 68 +CONSTANT: SPI_SETKEYBOARDPREF 69 +CONSTANT: SPI_GETSCREENREADER 70 +CONSTANT: SPI_SETSCREENREADER 71 +CONSTANT: SPI_GETANIMATION 72 +CONSTANT: SPI_SETANIMATION 73 +CONSTANT: SPI_GETFONTSMOOTHING 74 +CONSTANT: SPI_SETFONTSMOOTHING 75 +CONSTANT: SPI_SETDRAGWIDTH 76 +CONSTANT: SPI_SETDRAGHEIGHT 77 +CONSTANT: SPI_SETHANDHELD 78 +CONSTANT: SPI_GETLOWPOWERTIMEOUT 79 +CONSTANT: SPI_GETPOWEROFFTIMEOUT 80 +CONSTANT: SPI_SETLOWPOWERTIMEOUT 81 +CONSTANT: SPI_SETPOWEROFFTIMEOUT 82 +CONSTANT: SPI_GETLOWPOWERACTIVE 83 +CONSTANT: SPI_GETPOWEROFFACTIVE 84 +CONSTANT: SPI_SETLOWPOWERACTIVE 85 +CONSTANT: SPI_SETPOWEROFFACTIVE 86 +CONSTANT: SPI_SETCURSORS 87 +CONSTANT: SPI_SETICONS 88 +CONSTANT: SPI_GETDEFAULTINPUTLANG 89 +CONSTANT: SPI_SETDEFAULTINPUTLANG 90 +CONSTANT: SPI_SETLANGTOGGLE 91 +CONSTANT: SPI_GETWINDOWSEXTENSION 92 +CONSTANT: SPI_SETMOUSETRAILS 93 +CONSTANT: SPI_GETMOUSETRAILS 94 +CONSTANT: SPI_SETSCREENSAVERRUNNING 97 +ALIAS: SPI_SCREENSAVERRUNNING SPI_SETSCREENSAVERRUNNING + +! WIN32_WINNT >= 0x0400 || WIN32_WINDOWS > 0x0400 +CONSTANT: SPI_GETMOUSEHOVERWIDTH 98 +CONSTANT: SPI_SETMOUSEHOVERWIDTH 99 +CONSTANT: SPI_GETMOUSEHOVERHEIGHT 100 +CONSTANT: SPI_SETMOUSEHOVERHEIGHT 101 +CONSTANT: SPI_GETMOUSEHOVERTIME 102 +CONSTANT: SPI_SETMOUSEHOVERTIME 103 +CONSTANT: SPI_GETWHEELSCROLLLINES 104 +CONSTANT: SPI_SETWHEELSCROLLLINES 105 + +CONSTANT: SPI_GETSHOWIMEUI 110 +CONSTANT: SPI_SETSHOWIMEUI 111 + +! WINVER >= 0x0500 +CONSTANT: SPI_GETMOUSESPEED 112 +CONSTANT: SPI_SETMOUSESPEED 113 +CONSTANT: SPI_GETSCREENSAVERRUNNING 114 + +CONSTANT: SPI_GETACTIVEWINDOWTRACKING HEX: 1000 +CONSTANT: SPI_SETACTIVEWINDOWTRACKING HEX: 1001 +CONSTANT: SPI_GETMENUANIMATION HEX: 1002 +CONSTANT: SPI_SETMENUANIMATION HEX: 1003 +CONSTANT: SPI_GETCOMBOBOXANIMATION HEX: 1004 +CONSTANT: SPI_SETCOMBOBOXANIMATION HEX: 1005 +CONSTANT: SPI_GETLISTBOXSMOOTHSCROLLING HEX: 1006 +CONSTANT: SPI_SETLISTBOXSMOOTHSCROLLING HEX: 1007 +CONSTANT: SPI_GETGRADIENTCAPTIONS HEX: 1008 +CONSTANT: SPI_SETGRADIENTCAPTIONS HEX: 1009 +CONSTANT: SPI_GETMENUUNDERLINES HEX: 100A +CONSTANT: SPI_SETMENUUNDERLINES HEX: 100B +CONSTANT: SPI_GETACTIVEWNDTRKZORDER HEX: 100C +CONSTANT: SPI_SETACTIVEWNDTRKZORDER HEX: 100D +CONSTANT: SPI_GETHOTTRACKING HEX: 100E +CONSTANT: SPI_SETHOTTRACKING HEX: 100F +CONSTANT: SPI_GETFOREGROUNDLOCKTIMEOUT HEX: 2000 +CONSTANT: SPI_SETFOREGROUNDLOCKTIMEOUT HEX: 2001 +CONSTANT: SPI_GETACTIVEWNDTRKTIMEOUT HEX: 2002 +CONSTANT: SPI_SETACTIVEWNDTRKTIMEOUT HEX: 2003 +CONSTANT: SPI_GETFOREGROUNDFLASHCOUNT HEX: 2004 +CONSTANT: SPI_SETFOREGROUNDFLASHCOUNT HEX: 2005 + +! SystemParamInfo Flags +CONSTANT: SPIF_UPDATEINIFILE 1 +CONSTANT: SPIF_SENDWININICHANGE 2 +ALIAS: SPIF_SENDCHANGE SPIF_SENDWININICHANGE + + TYPEDEF: HANDLE HRAWINPUT : GET_RAWINPUT_CODE_WPARAM ( wParam -- n ) HEX: ff bitand ; inline @@ -1578,7 +1722,10 @@ FUNCTION: BOOL ShowWindow ( HWND hWnd, int nCmdShow ) ; ! FUNCTION: SwitchDesktop ! FUNCTION: SwitchToThisWindow ! FUNCTION: SystemParametersInfoA -! FUNCTION: SystemParametersInfoW + +FUNCTION: BOOL SystemParametersInfoW ( UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni ) ; +ALIAS: SystemParametersInfo SystemParametersInfoW + ! FUNCTION: TabbedTextOutA ! FUNCTION: TabbedTextOutW ! FUNCTION: TileChildWindows From bb06e4671a49b1fa926097617e7121ac280e8e63 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 22 Feb 2010 00:20:00 -0600 Subject: [PATCH 170/713] Require that g++ or cl be present to use factor.sh --- build-support/factor.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build-support/factor.sh b/build-support/factor.sh index a02a2fad7e..3a5fb4e253 100755 --- a/build-support/factor.sh +++ b/build-support/factor.sh @@ -107,6 +107,7 @@ check_installed_programs() { ensure_program_installed git ensure_program_installed wget curl ensure_program_installed gcc + ensure_program_installed g++ cl ensure_program_installed make gmake ensure_program_installed md5sum md5 ensure_program_installed cut From db3a23ffe05184f54c798972e2d3f7345ac2f33a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 22 Feb 2010 19:15:53 +1300 Subject: [PATCH 171/713] parser: auto-use prefers non-private words to private words --- core/parser/parser.factor | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/core/parser/parser.factor b/core/parser/parser.factor index e23673a479..544d75b244 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2005, 2009 Slava Pestov. +! Copyright (C) 2005, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays definitions generic assocs kernel math namespaces sequences strings vectors words words.symbol quotations io @@ -33,11 +33,19 @@ SYMBOL: auto-use? [ "Added \"" "\" vocabulary to search path" surround note. ] bi ] [ create-in ] if ; +: ignore-forwards ( seq -- seq' ) + [ forward-reference? not ] filter ; + +: private? ( word -- ? ) vocabulary>> ".private" tail? ; + +: ignore-privates ( seq -- seq' ) + dup [ private? ] all? [ [ private? not ] filter ] unless ; + : no-word ( name -- newword ) - dup words-named [ forward-reference? not ] filter - dup length 1 = auto-use? get and - [ nip first no-word-restarted ] - [ throw-restarts no-word-restarted ] + dup words-named ignore-forwards + dup ignore-privates dup length 1 = auto-use? get and + [ 2nip first no-word-restarted ] + [ drop throw-restarts no-word-restarted ] if ; : parse-word ( string -- word/number ) From 2c34ecbdb54a5f5900c27184be1bac45b84c4329 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 22 Feb 2010 19:21:56 +1300 Subject: [PATCH 172/713] stack-checker.dependencies: add depends-on-c-type --- .../stack-checker/dependencies/dependencies.factor | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/basis/stack-checker/dependencies/dependencies.factor b/basis/stack-checker/dependencies/dependencies.factor index ece943acac..1bd7cdcd31 100644 --- a/basis/stack-checker/dependencies/dependencies.factor +++ b/basis/stack-checker/dependencies/dependencies.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2009, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: assocs accessors classes classes.algebra fry generic -kernel math namespaces sequences words sets -combinators.short-circuit classes.tuple ; +USING: arrays assocs accessors classes classes.algebra fry +generic kernel math namespaces sequences words sets +combinators.short-circuit classes.tuple alien.c-types ; FROM: classes.tuple.private => tuple-layout ; FROM: assocs => change-at ; IN: stack-checker.dependencies @@ -38,6 +38,13 @@ SYMBOLS: effect-dependency conditional-dependency definition-dependency ; : depends-on-definition ( word -- ) definition-dependency depends-on ; +GENERIC: depends-on-c-type ( c-type -- ) + +M: c-type-word depends-on-c-type depends-on-definition ; + +M: array depends-on-c-type + [ word? ] filter [ depends-on-definition ] each ; + ! Generic words that the current quotation depends on SYMBOL: generic-dependencies From 310b3df2ec5b32929093dbd6922e9fb5f9465806 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 22:31:32 -0800 Subject: [PATCH 173/713] stack-checker.dependencies: add method for pointers to depends-on-c-type --- basis/stack-checker/dependencies/dependencies.factor | 3 +++ 1 file changed, 3 insertions(+) diff --git a/basis/stack-checker/dependencies/dependencies.factor b/basis/stack-checker/dependencies/dependencies.factor index 1bd7cdcd31..4c5529d424 100644 --- a/basis/stack-checker/dependencies/dependencies.factor +++ b/basis/stack-checker/dependencies/dependencies.factor @@ -45,6 +45,9 @@ M: c-type-word depends-on-c-type depends-on-definition ; M: array depends-on-c-type [ word? ] filter [ depends-on-definition ] each ; +M: pointer depends-on-c-type + to>> depends-on-c-type ; + ! Generic words that the current quotation depends on SYMBOL: generic-dependencies From c7acbda342115e0a8fb5aa287126b9595c934920 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 22:46:52 -0800 Subject: [PATCH 174/713] classes.struct: set dependency on slot types in slot accessors, so that accessors update when types change. enables pointers to make circular references between struct types --- basis/classes/struct/struct.factor | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/basis/classes/struct/struct.factor b/basis/classes/struct/struct.factor index 4e7a565a5a..af73be3aa4 100644 --- a/basis/classes/struct/struct.factor +++ b/basis/classes/struct/struct.factor @@ -8,7 +8,8 @@ generalizations generic.parser kernel kernel.private lexer libc locals macros make math math.order parser quotations sequences slots slots.private specialized-arrays vectors words summary namespaces assocs vocabs.parser math.functions -classes.struct.bit-accessors bit-arrays ; +classes.struct.bit-accessors bit-arrays +stack-checker.dependencies ; QUALIFIED: math IN: classes.struct @@ -124,6 +125,14 @@ M: struct-bit-slot-spec (writer-quot) : (unboxer-quot) ( class -- quot ) drop [ >c-ptr ] ; + +MACRO: read-struct-slot ( slot -- ) + dup type>> depends-on-c-type + (reader-quot) ; + +MACRO: write-struct-slot ( slot -- ) + dup type>> depends-on-c-type + (writer-quot) ; PRIVATE> M: struct-class boa>object @@ -138,10 +147,10 @@ M: struct-class initial-value* ; inline GENERIC: struct-slot-values ( struct -- sequence ) M: struct-class reader-quot - nip (reader-quot) ; + nip '[ _ read-struct-slot ] ; M: struct-class writer-quot - nip (writer-quot) ; + nip '[ _ write-struct-slot ] ; : offset-of ( field struct -- offset ) struct-slots slot-named offset>> ; inline From 0bc8e8f40844179cee3e7df116915f5d7dd2a97c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 23:11:59 -0800 Subject: [PATCH 175/713] alien.arrays: typedef special char* symbol so it still works as expected --- basis/alien/arrays/arrays.factor | 1 + 1 file changed, 1 insertion(+) diff --git a/basis/alien/arrays/arrays.factor b/basis/alien/arrays/arrays.factor index c62800df36..4fddba1de6 100644 --- a/basis/alien/arrays/arrays.factor +++ b/basis/alien/arrays/arrays.factor @@ -104,6 +104,7 @@ M: string-type c-type-setter drop [ set-alien-cell ] ; { char* utf8 } char typedef +{ char* utf8 } char* typedef { char* utf8 } uchar typedef { char* binary } byte typedef { char* binary } ubyte typedef From d8432db49557fd20a5edee219ddc1211e442a7f8 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 23:12:28 -0800 Subject: [PATCH 176/713] openssl: replace some TYPEDEF: void* foo* (which won't work anymore) with C-TYPE: foo --- basis/openssl/libcrypto/libcrypto.factor | 2 +- basis/openssl/libssl/libssl.factor | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/basis/openssl/libcrypto/libcrypto.factor b/basis/openssl/libcrypto/libcrypto.factor index dbc5b9e43c..fd5c757bc4 100644 --- a/basis/openssl/libcrypto/libcrypto.factor +++ b/basis/openssl/libcrypto/libcrypto.factor @@ -103,7 +103,7 @@ FUNCTION: void* BIO_f_buffer ( ) ; CONSTANT: EVP_MAX_MD_SIZE 64 -TYPEDEF: void* EVP_MD* +C-TYPE: EVP_MD C-TYPE: ENGINE STRUCT: EVP_MD_CTX diff --git a/basis/openssl/libssl/libssl.factor b/basis/openssl/libssl/libssl.factor index 225d4b3da1..1c6fbec011 100644 --- a/basis/openssl/libssl/libssl.factor +++ b/basis/openssl/libssl/libssl.factor @@ -89,8 +89,8 @@ CONSTANT: SSL_ERROR_WANT_ACCEPT 8 } ; TYPEDEF: void* ssl-method -TYPEDEF: void* SSL_CTX* -TYPEDEF: void* SSL_SESSION* +C-TYPE: SSL_CTX +C-TYPE: SSL_SESSION C-TYPE: SSL LIBRARY: libssl @@ -99,8 +99,7 @@ LIBRARY: libssl ! x509.h ! =============================================== -TYPEDEF: void* X509_NAME* - +C-TYPE: X509_NAME C-TYPE: X509 FUNCTION: int X509_NAME_get_text_by_NID ( X509_NAME* name, int nid, void* buf, int len ) ; From c4cc70b92c041a3723c8c9b9e303f7701fc3384b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 23:13:12 -0800 Subject: [PATCH 177/713] stack-checker.dependencies: extend c-type-word method for depends-on-c-type to all words (so it works for non-c-types like void) --- basis/stack-checker/dependencies/dependencies.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/stack-checker/dependencies/dependencies.factor b/basis/stack-checker/dependencies/dependencies.factor index 4c5529d424..ffa021c9f6 100644 --- a/basis/stack-checker/dependencies/dependencies.factor +++ b/basis/stack-checker/dependencies/dependencies.factor @@ -40,7 +40,7 @@ SYMBOLS: effect-dependency conditional-dependency definition-dependency ; GENERIC: depends-on-c-type ( c-type -- ) -M: c-type-word depends-on-c-type depends-on-definition ; +M: word depends-on-c-type depends-on-definition ; M: array depends-on-c-type [ word? ] filter [ depends-on-definition ] each ; From d64653ee9a86adc373e86cc2e4f84909de0823b5 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 23:13:31 -0800 Subject: [PATCH 178/713] specialized-arrays: fix underlying-type so it always returns void* for pointer types --- basis/specialized-arrays/specialized-arrays.factor | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/basis/specialized-arrays/specialized-arrays.factor b/basis/specialized-arrays/specialized-arrays.factor index 992dbac6d6..97ce2ed1ff 100644 --- a/basis/specialized-arrays/specialized-arrays.factor +++ b/basis/specialized-arrays/specialized-arrays.factor @@ -116,7 +116,8 @@ M: A v*high [ * \ T heap-size neg shift ] 2map ; inline ;FUNCTOR -: underlying-type ( c-type -- c-type' ) +GENERIC: underlying-type ( c-type -- c-type' ) +M: c-type-word underlying-type dup "c-type" word-prop { { [ dup not ] [ drop no-c-type ] } { [ dup pointer? ] [ 2drop void* ] } @@ -124,6 +125,9 @@ M: A v*high [ * \ T heap-size neg shift ] 2map ; inline [ drop ] } cond ; +M: pointer underlying-type + drop void* ; + : specialized-array-vocab ( c-type -- vocab ) [ "specialized-arrays.instances." % From cdde1aa92a4aa0b65201bdd6737ee11143bf117f Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 21 Feb 2010 23:13:56 -0800 Subject: [PATCH 179/713] opengl.gl: TYPEDEF: void* GLvoid* => C-TYPE: GLvoid --- basis/opengl/gl/gl.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/opengl/gl/gl.factor b/basis/opengl/gl/gl.factor index d89cee57d4..27d24718c2 100644 --- a/basis/opengl/gl/gl.factor +++ b/basis/opengl/gl/gl.factor @@ -22,7 +22,7 @@ TYPEDEF: float GLfloat TYPEDEF: float GLclampf TYPEDEF: double GLdouble TYPEDEF: double GLclampd -TYPEDEF: void* GLvoid* +C-TYPE: GLvoid ! Constants From 757842969255009581ff81d00ca4e12806fbad99 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 22 Feb 2010 21:31:41 +1300 Subject: [PATCH 180/713] alien.c-types: remove void? word --- basis/alien/c-types/c-types.factor | 8 +++----- basis/alien/parser/parser.factor | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor index a929cba954..c25f465600 100644 --- a/basis/alien/c-types/c-types.factor +++ b/basis/alien/c-types/c-types.factor @@ -17,8 +17,9 @@ SYMBOLS: long ulong longlong ulonglong float double - void* bool - void ; + void* bool ; + +SINGLETON: void DEFER: DEFER: *char @@ -57,9 +58,6 @@ GENERIC: resolve-pointer-type ( name -- c-type ) << \ void \ void* "pointer-c-type" set-word-prop >> -: void? ( c-type -- ? ) - { void "void" } member? ; - M: word resolve-pointer-type dup "pointer-c-type" word-prop [ ] [ drop void* ] ?if ; diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index d706446799..dc0a1701f2 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008, 2009 Slava Pestov, Doug Coleman. +! Copyright (C) 2008, 2010 Slava Pestov, Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien alien.c-types alien.parser alien.libraries arrays assocs classes combinators @@ -66,7 +66,7 @@ IN: alien.parser 2 group [ first2 normalize-c-arg 2array ] map unzip [ "," ?tail drop ] map ] - [ [ { } ] [ 1array ] if-void ] + [ dup "void" = [ drop { } ] [ 1array ] if ] bi* ; : function-quot ( return library function types -- quot ) From eb3f8632dd347cc1a1364b4a5388257335884c8b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 22 Feb 2010 21:32:41 +1300 Subject: [PATCH 181/713] stack-checker.alien: now that C types are words, the compiler can add dependencies on them when compiling alien words. This triggers the necessary recompilation when C types are redefined --- basis/compiler/tests/redefine24.factor | 39 ++++++++++ basis/stack-checker/alien/alien.factor | 76 +++++++++++++------ .../dependencies/dependencies.factor | 2 + 3 files changed, 92 insertions(+), 25 deletions(-) create mode 100644 basis/compiler/tests/redefine24.factor diff --git a/basis/compiler/tests/redefine24.factor b/basis/compiler/tests/redefine24.factor new file mode 100644 index 0000000000..391102102e --- /dev/null +++ b/basis/compiler/tests/redefine24.factor @@ -0,0 +1,39 @@ +USING: alien alien.syntax eval math tools.test ; +QUALIFIED: alien.c-types +IN: compiler.tests.redefine24 + +TYPEDEF: alien.c-types:int type-1 + +TYPEDEF: alien.c-types:int type-3 + +: callback ( -- ptr ) + type-3 { type-1 type-1 } "cdecl" [ + >integer ] alien-callback ; + +TYPEDEF: alien.c-types:float type-2 + +: indirect ( x y ptr -- z ) + type-3 { type-2 type-2 } "cdecl" alien-indirect ; + +[ ] [ + "USING: alien.c-types alien.syntax ; + IN: compiler.tests.redefine24 TYPEDEF: int type-2" eval( -- ) +] unit-test + +[ 3 ] [ 1 2 callback indirect ] unit-test + +[ ] [ + "USING: alien.c-types alien.syntax ; + IN: compiler.tests.redefine24 + TYPEDEF: float type-1 + TYPEDEF: float type-2" eval( -- ) +] unit-test + +[ 3 ] [ 1.0 2.0 callback indirect ] unit-test + +[ ] [ + "USING: alien.c-types alien.syntax ; + IN: compiler.tests.redefine24 + TYPEDEF: float type-3" eval( -- ) +] unit-test + +[ 3.0 ] [ 1.0 2.0 callback indirect ] unit-test diff --git a/basis/stack-checker/alien/alien.factor b/basis/stack-checker/alien/alien.factor index fdfda6dd9e..09121488ef 100644 --- a/basis/stack-checker/alien/alien.factor +++ b/basis/stack-checker/alien/alien.factor @@ -3,7 +3,7 @@ USING: kernel sequences accessors combinators math namespaces init sets words assocs alien.libraries alien alien.c-types cpu.architecture fry stack-checker.backend stack-checker.errors -stack-checker.visitor ; +stack-checker.visitor stack-checker.dependencies ; IN: stack-checker.alien TUPLE: alien-node-params return parameters abi in-d out-d ; @@ -16,65 +16,91 @@ TUPLE: alien-assembly-params < alien-node-params quot ; TUPLE: alien-callback-params < alien-node-params quot xt ; -: param-prep-quot ( node -- quot ) +: param-prep-quot ( params -- quot ) parameters>> [ c-type c-type-unboxer-quot ] map spread>quot ; +: infer-params ( params -- ) + param-prep-quot infer-quot-here ; + : alien-stack ( params extra -- ) over parameters>> length + consume-d >>in-d dup return>> void? 0 1 ? produce-d >>out-d drop ; -: return-prep-quot ( node -- quot ) +: return-prep-quot ( params -- quot ) return>> [ [ ] ] [ c-type c-type-boxer-quot ] if-void ; +: infer-return ( params -- ) + return-prep-quot infer-quot-here ; + +: pop-return ( params -- params ) + pop-literal [ depends-on-c-type ] [ nip >>return ] bi ; + +: pop-library ( params -- params ) + pop-literal nip >>library ; + +: pop-function ( params -- params ) + pop-literal nip >>function ; + +: pop-params ( params -- params ) + pop-literal [ [ depends-on-c-type ] each ] [ nip >>parameters ] bi ; + +: pop-abi ( params -- params ) + pop-literal nip >>abi ; + +: pop-quot ( params -- params ) + pop-literal nip >>quot ; + : infer-alien-invoke ( -- ) alien-invoke-params new ! Compile-time parameters - pop-literal nip >>parameters - pop-literal nip >>function - pop-literal nip >>library - pop-literal nip >>return - ! Quotation which coerces parameters to required types - dup param-prep-quot infer-quot-here + pop-params + pop-function + pop-library + pop-return ! Set ABI dup library>> library [ abi>> ] [ "cdecl" ] if* >>abi + ! Quotation which coerces parameters to required types + dup infer-params ! Magic #: consume exactly the number of inputs dup 0 alien-stack ! Add node to IR dup #alien-invoke, ! Quotation which coerces return value to required type - return-prep-quot infer-quot-here ; + infer-return ; : infer-alien-indirect ( -- ) alien-indirect-params new ! Compile-time parameters - pop-literal nip >>abi - pop-literal nip >>parameters - pop-literal nip >>return + pop-abi + pop-params + pop-return ! Quotation which coerces parameters to required types - dup param-prep-quot '[ _ dip ] infer-quot-here + 1 infer->r + dup infer-params + 1 infer-r> ! Magic #: consume the function pointer, too dup 1 alien-stack ! Add node to IR dup #alien-indirect, ! Quotation which coerces return value to required type - return-prep-quot infer-quot-here ; + infer-return ; : infer-alien-assembly ( -- ) alien-assembly-params new ! Compile-time parameters - pop-literal nip >>quot - pop-literal nip >>abi - pop-literal nip >>parameters - pop-literal nip >>return + pop-quot + pop-abi + pop-params + pop-return ! Quotation which coerces parameters to required types - dup param-prep-quot infer-quot-here + dup infer-params ! Magic #: consume exactly the number of inputs dup 0 alien-stack ! Add node to IR dup #alien-assembly, ! Quotation which coerces return value to required type - return-prep-quot infer-quot-here ; + infer-return ; : callback-xt ( word return-rewind -- alien ) [ callbacks get ] dip '[ _ ] cache ; @@ -85,10 +111,10 @@ TUPLE: alien-callback-params < alien-node-params quot xt ; : infer-alien-callback ( -- ) alien-callback-params new - pop-literal nip >>quot - pop-literal nip >>abi - pop-literal nip >>parameters - pop-literal nip >>return + pop-quot + pop-abi + pop-params + pop-return "( callback )" >>xt dup callback-bottom #alien-callback, ; diff --git a/basis/stack-checker/dependencies/dependencies.factor b/basis/stack-checker/dependencies/dependencies.factor index 1bd7cdcd31..25fe12cbc5 100644 --- a/basis/stack-checker/dependencies/dependencies.factor +++ b/basis/stack-checker/dependencies/dependencies.factor @@ -40,6 +40,8 @@ SYMBOLS: effect-dependency conditional-dependency definition-dependency ; GENERIC: depends-on-c-type ( c-type -- ) +M: void depends-on-c-type drop ; + M: c-type-word depends-on-c-type depends-on-definition ; M: array depends-on-c-type From 58485af60b8aaa3bdb57791f18cc7975fda11e6a Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 22 Feb 2010 00:45:54 -0800 Subject: [PATCH 182/713] Fix CALLBACK: effect return type also not a string. Added accompanying unit test. --- basis/alien/parser/parser-tests.factor | 9 +++++++-- basis/alien/parser/parser.factor | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/basis/alien/parser/parser-tests.factor b/basis/alien/parser/parser-tests.factor index 2fec2d9a4c..84eefe9df6 100644 --- a/basis/alien/parser/parser-tests.factor +++ b/basis/alien/parser/parser-tests.factor @@ -34,9 +34,14 @@ CONSTANT: eleven 11 ] with-file-vocabs -FUNCTION: void* alien-parser-effect-test ( int *arg1 float arg2 ) ; +FUNCTION: void* alien-parser-function-effect-test ( int *arg1 float arg2 ) ; [ (( arg1 arg2 -- void* )) ] [ - \ alien-parser-effect-test "declared-effect" word-prop + \ alien-parser-function-effect-test "declared-effect" word-prop +] unit-test + +CALLBACK: void* alien-parser-callback-effect-test ( int *arg1 float arg2 ) ; +[ (( arg1 arg2 -- void* )) ] [ + \ alien-parser-callback-effect-test "callback-effect" word-prop ] unit-test ! Reported by mnestic diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index dc0a1701f2..d073a4caac 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -93,15 +93,15 @@ IN: alien.parser : library-abi ( lib -- abi ) library [ abi>> ] [ "cdecl" ] if* ; -:: make-callback-type ( lib return! type-name! parameters -- word quot effect ) - return type-name normalize-c-arg type-name! return! +:: make-callback-type ( lib return type-name parameters -- word quot effect ) + return type-name normalize-c-arg :> ( return-c-type type-name ) type-name current-vocab create :> type-word type-word [ reset-generic ] [ reset-c-type ] bi void* type-word typedef parameters return parse-arglist :> ( types callback-effect ) type-word callback-effect "callback-effect" set-word-prop type-word lib "callback-library" set-word-prop - type-word return types lib library-abi callback-quot (( quot -- alien )) ; + type-word return-c-type types lib library-abi callback-quot (( quot -- alien )) ; : (CALLBACK:) ( -- word quot effect ) "c-library" get From 869e95717c44ff2042769218cd1c1d83bf95d3c3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 23 Feb 2010 00:23:30 +1300 Subject: [PATCH 183/713] windows.ddk.hid: add platforms.txt --- basis/windows/ddk/hid/platforms.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 basis/windows/ddk/hid/platforms.txt diff --git a/basis/windows/ddk/hid/platforms.txt b/basis/windows/ddk/hid/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/ddk/hid/platforms.txt @@ -0,0 +1 @@ +winnt From 23a1f0ed8c11f8e7ddc0d4a71ca76c30744c1c10 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 23 Feb 2010 01:28:56 +1300 Subject: [PATCH 184/713] alien: some code cleanups and fixes --- basis/alien/c-types/c-types.factor | 8 -------- basis/alien/libraries/authors.txt | 1 + basis/alien/libraries/libraries.factor | 15 ++++++++++++--- basis/alien/parser/parser.factor | 16 ++++++---------- basis/stack-checker/alien/alien.factor | 2 +- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor index c25f465600..fff49a4480 100644 --- a/basis/alien/c-types/c-types.factor +++ b/basis/alien/c-types/c-types.factor @@ -69,14 +69,6 @@ M: array resolve-pointer-type dup void? [ no-c-type ] when dup c-type-name? [ c-type ] when ; -number ] map ] dip ; - -PRIVATE> - M: word c-type dup "c-type" word-prop resolve-typedef [ ] [ no-c-type ] ?if ; diff --git a/basis/alien/libraries/authors.txt b/basis/alien/libraries/authors.txt index 1901f27a24..580f882c8d 100644 --- a/basis/alien/libraries/authors.txt +++ b/basis/alien/libraries/authors.txt @@ -1 +1,2 @@ Slava Pestov +Joe Groff diff --git a/basis/alien/libraries/libraries.factor b/basis/alien/libraries/libraries.factor index 6f80900da0..47e34fe5ff 100644 --- a/basis/alien/libraries/libraries.factor +++ b/basis/alien/libraries/libraries.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2009 Slava Pestov. +! Copyright (C) 2009, 2010 Slava Pestov, Joe Groff. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien alien.strings assocs io.backend kernel namespaces destructors sequences system io.pathnames ; @@ -9,10 +9,8 @@ IN: alien.libraries : dlsym ( name dll -- alien ) [ string>symbol ] dip (dlsym) ; SYMBOL: libraries -SYMBOL: deploy-libraries libraries [ H{ } clone ] initialize -deploy-libraries [ V{ } clone ] initialize TUPLE: library path abi dll ; @@ -37,18 +35,29 @@ M: library dispose dll>> [ dispose ] when* ; [ 2drop remove-library ] [ swap libraries get set-at ] 3bi ; +: library-abi ( library -- abi ) + library [ abi>> ] [ "cdecl" ] if* ; + +SYMBOL: deploy-libraries + +deploy-libraries [ V{ } clone ] initialize + : deploy-library ( name -- ) dup libraries get key? [ deploy-libraries get 2dup member? [ 2drop ] [ push ] if ] [ no-library ] if ; deployed-library-path os ( path -- path' ) M: windows >deployed-library-path file-name ; + M: unix >deployed-library-path file-name "$ORIGIN" prepend-path ; + M: macosx >deployed-library-path file-name "@executable_path/../Frameworks" prepend-path ; + PRIVATE> diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index dc0a1701f2..8385bfb97f 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -66,16 +66,16 @@ IN: alien.parser 2 group [ first2 normalize-c-arg 2array ] map unzip [ "," ?tail drop ] map ] - [ dup "void" = [ drop { } ] [ 1array ] if ] + [ [ { } ] [ name>> 1array ] if-void ] bi* ; : function-quot ( return library function types -- quot ) '[ _ _ _ _ alien-invoke ] ; :: make-function ( return library function parameters -- word quot effect ) - return function normalize-c-arg :> ( return-c-type function ) + return function normalize-c-arg :> ( return function ) function create-in dup reset-generic - return-c-type library function + return library function parameters return parse-arglist [ function-quot ] dip ; : parse-arg-tokens ( -- tokens ) @@ -88,13 +88,10 @@ IN: alien.parser make-function define-declared ; : callback-quot ( return types abi -- quot ) - [ [ ] 3curry dip alien-callback ] 3curry ; + '[ [ _ _ _ ] dip alien-callback ] ; -: library-abi ( lib -- abi ) - library [ abi>> ] [ "cdecl" ] if* ; - -:: make-callback-type ( lib return! type-name! parameters -- word quot effect ) - return type-name normalize-c-arg type-name! return! +:: make-callback-type ( lib return type-name parameters -- word quot effect ) + return type-name normalize-c-arg :> ( return type-name ) type-name current-vocab create :> type-word type-word [ reset-generic ] [ reset-c-type ] bi void* type-word typedef @@ -115,4 +112,3 @@ PREDICATE: alien-function-word < word PREDICATE: alien-callback-type-word < typedef-word "callback-effect" word-prop ; - diff --git a/basis/stack-checker/alien/alien.factor b/basis/stack-checker/alien/alien.factor index 09121488ef..81d8a93240 100644 --- a/basis/stack-checker/alien/alien.factor +++ b/basis/stack-checker/alien/alien.factor @@ -59,7 +59,7 @@ TUPLE: alien-callback-params < alien-node-params quot xt ; pop-library pop-return ! Set ABI - dup library>> library [ abi>> ] [ "cdecl" ] if* >>abi + dup library>> library-abi >>abi ! Quotation which coerces parameters to required types dup infer-params ! Magic #: consume exactly the number of inputs From a15c09b3968a5620bc59652a8cb535baa63534c7 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 22 Feb 2010 10:39:50 -0800 Subject: [PATCH 185/713] Add some additional error masks and codes --- basis/windows/errors/errors.factor | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/basis/windows/errors/errors.factor b/basis/windows/errors/errors.factor index a7a41433f7..c5dedb090a 100644 --- a/basis/windows/errors/errors.factor +++ b/basis/windows/errors/errors.factor @@ -5,6 +5,12 @@ arrays literals windows.types specialized-arrays ; SPECIALIZED-ARRAY: TCHAR IN: windows.errors +CONSTANT: APPLICATION_ERROR_MASK HEX: 20000000 +CONSTANT: ERROR_SEVERITY_SUCCESS HEX: 00000000 +CONSTANT: ERROR_SEVERITY_INFORMATIONAL HEX: 40000000 +CONSTANT: ERROR_SEVERITY_WARNING HEX: 80000000 +CONSTANT: ERROR_SEVERITY_ERROR HEX: C0000000 + CONSTANT: ERROR_SUCCESS 0 CONSTANT: ERROR_INVALID_FUNCTION 1 CONSTANT: ERROR_FILE_NOT_FOUND 2 From 124982ce23478e1723ec40bb72f9e4213e0c414e Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 22 Feb 2010 00:45:54 -0800 Subject: [PATCH 186/713] Fix CALLBACK: effect return type also not a string. Added accompanying unit test. --- basis/alien/parser/parser-tests.factor | 9 +++++++-- basis/alien/parser/parser.factor | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/basis/alien/parser/parser-tests.factor b/basis/alien/parser/parser-tests.factor index 2fec2d9a4c..84eefe9df6 100644 --- a/basis/alien/parser/parser-tests.factor +++ b/basis/alien/parser/parser-tests.factor @@ -34,9 +34,14 @@ CONSTANT: eleven 11 ] with-file-vocabs -FUNCTION: void* alien-parser-effect-test ( int *arg1 float arg2 ) ; +FUNCTION: void* alien-parser-function-effect-test ( int *arg1 float arg2 ) ; [ (( arg1 arg2 -- void* )) ] [ - \ alien-parser-effect-test "declared-effect" word-prop + \ alien-parser-function-effect-test "declared-effect" word-prop +] unit-test + +CALLBACK: void* alien-parser-callback-effect-test ( int *arg1 float arg2 ) ; +[ (( arg1 arg2 -- void* )) ] [ + \ alien-parser-callback-effect-test "callback-effect" word-prop ] unit-test ! Reported by mnestic diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index dc0a1701f2..d073a4caac 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -93,15 +93,15 @@ IN: alien.parser : library-abi ( lib -- abi ) library [ abi>> ] [ "cdecl" ] if* ; -:: make-callback-type ( lib return! type-name! parameters -- word quot effect ) - return type-name normalize-c-arg type-name! return! +:: make-callback-type ( lib return type-name parameters -- word quot effect ) + return type-name normalize-c-arg :> ( return-c-type type-name ) type-name current-vocab create :> type-word type-word [ reset-generic ] [ reset-c-type ] bi void* type-word typedef parameters return parse-arglist :> ( types callback-effect ) type-word callback-effect "callback-effect" set-word-prop type-word lib "callback-library" set-word-prop - type-word return types lib library-abi callback-quot (( quot -- alien )) ; + type-word return-c-type types lib library-abi callback-quot (( quot -- alien )) ; : (CALLBACK:) ( -- word quot effect ) "c-library" get From b2fe49704e26f7dd4ea41ce6cc2a09e23bd74e3b Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 22 Feb 2010 10:39:50 -0800 Subject: [PATCH 187/713] Add some additional error masks and codes --- basis/windows/errors/errors.factor | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/basis/windows/errors/errors.factor b/basis/windows/errors/errors.factor index a7a41433f7..c5dedb090a 100644 --- a/basis/windows/errors/errors.factor +++ b/basis/windows/errors/errors.factor @@ -5,6 +5,12 @@ arrays literals windows.types specialized-arrays ; SPECIALIZED-ARRAY: TCHAR IN: windows.errors +CONSTANT: APPLICATION_ERROR_MASK HEX: 20000000 +CONSTANT: ERROR_SEVERITY_SUCCESS HEX: 00000000 +CONSTANT: ERROR_SEVERITY_INFORMATIONAL HEX: 40000000 +CONSTANT: ERROR_SEVERITY_WARNING HEX: 80000000 +CONSTANT: ERROR_SEVERITY_ERROR HEX: C0000000 + CONSTANT: ERROR_SUCCESS 0 CONSTANT: ERROR_INVALID_FUNCTION 1 CONSTANT: ERROR_FILE_NOT_FOUND 2 From 4d2ded634b081afc7e6f2d9a7f506f36678ec967 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 22 Feb 2010 11:25:01 -0800 Subject: [PATCH 188/713] alien.parser: properly generate return type name for FUNCTION: stack effects --- basis/alien/parser/parser.factor | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index 474bb77dc6..14078f3137 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -62,12 +62,20 @@ IN: alien.parser ] bi [ parse-c-type ] dip ; +> ; +M: pointer return-type-name to>> return-type-name CHAR: * suffix ; +PRIVATE> + : parse-arglist ( parameters return -- types effect ) [ 2 group [ first2 normalize-c-arg 2array ] map unzip [ "," ?tail drop ] map ] - [ [ { } ] [ name>> 1array ] if-void ] + [ [ { } ] [ return-type-name 1array ] if-void ] bi* ; : function-quot ( return library function types -- quot ) From 1bf37f01e57d531fe37076a6a666933535dc8468 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 22 Feb 2010 12:21:29 -0800 Subject: [PATCH 189/713] alien.arrays/classes.struct: ensure specialized array types for struct array slots get instantiated at parse time --- basis/alien/arrays/arrays.factor | 5 +---- basis/classes/struct/struct.factor | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/basis/alien/arrays/arrays.factor b/basis/alien/arrays/arrays.factor index 4fddba1de6..f9a47f256c 100644 --- a/basis/alien/arrays/arrays.factor +++ b/basis/alien/arrays/arrays.factor @@ -35,10 +35,7 @@ M: array box-return drop void* box-return ; M: array stack-size drop void* stack-size ; M: array c-type-boxer-quot - unclip - [ array-length ] - [ [ require-c-array ] keep ] bi* - [ ] 2curry ; + unclip [ array-length ] dip [ ] 2curry ; M: array c-type-unboxer-quot drop [ >c-ptr ] ; diff --git a/basis/classes/struct/struct.factor b/basis/classes/struct/struct.factor index af73be3aa4..3b2fc875c4 100644 --- a/basis/classes/struct/struct.factor +++ b/basis/classes/struct/struct.factor @@ -147,6 +147,7 @@ M: struct-class initial-value* ; inline GENERIC: struct-slot-values ( struct -- sequence ) M: struct-class reader-quot + dup array? [ dup first define-array-vocab drop ] when nip '[ _ read-struct-slot ] ; M: struct-class writer-quot From 6d4724a095fc81b30fdb3661d9fd24b07058df01 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 22 Feb 2010 12:22:29 -0800 Subject: [PATCH 190/713] scrub memory>struct calls made redundant --- basis/calendar/unix/unix.factor | 2 +- basis/game/input/dinput/dinput.factor | 3 +-- basis/specialized-arrays/specialized-arrays.factor | 3 --- basis/ui/backend/x11/x11.factor | 3 +-- basis/unix/groups/groups.factor | 2 +- basis/unix/users/users.factor | 6 +++--- basis/unix/utmpx/utmpx.factor | 2 +- basis/windows/com/wrapper/wrapper.factor | 3 +-- basis/windows/uniscribe/uniscribe.factor | 1 - 9 files changed, 9 insertions(+), 16 deletions(-) diff --git a/basis/calendar/unix/unix.factor b/basis/calendar/unix/unix.factor index ac72385d8c..fdc85c943a 100644 --- a/basis/calendar/unix/unix.factor +++ b/basis/calendar/unix/unix.factor @@ -21,7 +21,7 @@ IN: calendar.unix timespec>seconds since-1970 ; : get-time ( -- alien ) - f time localtime tm memory>struct ; + f time localtime ; : timezone-name ( -- string ) get-time zone>> ; diff --git a/basis/game/input/dinput/dinput.factor b/basis/game/input/dinput/dinput.factor index e2c1fda759..a95dbd06c3 100755 --- a/basis/game/input/dinput/dinput.factor +++ b/basis/game/input/dinput/dinput.factor @@ -94,7 +94,6 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ : find-device-axes-callback ( -- alien ) [ ! ( lpddoi pvRef -- BOOL ) - [ DIDEVICEOBJECTINSTANCEW memory>struct ] dip +controller-devices+ get at swap guidType>> { { [ dup GUID_XAxis = ] [ drop 0.0 >>x ] } @@ -142,7 +141,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ : find-controller-callback ( -- alien ) [ ! ( lpddi pvRef -- BOOL ) - drop DIDEVICEINSTANCEW memory>struct guidInstance>> add-controller + drop guidInstance>> add-controller DIENUM_CONTINUE ] LPDIENUMDEVICESCALLBACKW ; inline diff --git a/basis/specialized-arrays/specialized-arrays.factor b/basis/specialized-arrays/specialized-arrays.factor index 97ce2ed1ff..2aca62cc77 100644 --- a/basis/specialized-arrays/specialized-arrays.factor +++ b/basis/specialized-arrays/specialized-arrays.factor @@ -143,9 +143,6 @@ PRIVATE> [ specialized-array-vocab ] [ '[ _ define-array ] ] bi generate-vocab ; -M: c-type-word require-c-array define-array-vocab drop ; -M: pointer require-c-array drop void* require-c-array ; - ERROR: specialized-array-vocab-not-loaded c-type ; M: c-type-word c-array-constructor diff --git a/basis/ui/backend/x11/x11.factor b/basis/ui/backend/x11/x11.factor index 673dd8e9c3..74d911ef90 100644 --- a/basis/ui/backend/x11/x11.factor +++ b/basis/ui/backend/x11/x11.factor @@ -49,8 +49,7 @@ PIXEL-FORMAT-ATTRIBUTE-TABLE: glx-visual { $ GLX_USE_GL $ GLX_RGBA } H{ M: x11-ui-backend (make-pixel-format) [ drop dpy get scr get ] dip - >glx-visual-int-array glXChooseVisual - XVisualInfo memory>struct ; + >glx-visual-int-array glXChooseVisual ; M: x11-ui-backend (free-pixel-format) handle>> XFree ; diff --git a/basis/unix/groups/groups.factor b/basis/unix/groups/groups.factor index b009fe529f..7be124ced4 100644 --- a/basis/unix/groups/groups.factor +++ b/basis/unix/groups/groups.factor @@ -83,7 +83,7 @@ M: integer user-groups ( id -- seq ) user-name (user-groups) ; : all-groups ( -- seq ) - [ unix.ffi:getgrent dup ] [ \ unix.ffi:group memory>struct group-struct>group ] produce nip ; + [ unix.ffi:getgrent dup ] [ group-struct>group ] produce nip ; : ( -- assoc ) all-groups [ [ id>> ] keep ] H{ } map>assoc ; diff --git a/basis/unix/users/users.factor b/basis/unix/users/users.factor index 5de176e242..0575538b87 100644 --- a/basis/unix/users/users.factor +++ b/basis/unix/users/users.factor @@ -37,7 +37,7 @@ PRIVATE> : all-users ( -- seq ) [ - [ unix.ffi:getpwent dup ] [ unix.ffi:passwd memory>struct passwd>new-passwd ] produce nip + [ unix.ffi:getpwent dup ] [ passwd>new-passwd ] produce nip ] with-pwent ; SYMBOL: user-cache @@ -52,10 +52,10 @@ GENERIC: user-passwd ( obj -- passwd/f ) M: integer user-passwd ( id -- passwd/f ) user-cache get - [ at ] [ unix.ffi:getpwuid [ unix.ffi:passwd memory>struct passwd>new-passwd ] [ f ] if* ] if* ; + [ at ] [ unix.ffi:getpwuid [ passwd>new-passwd ] [ f ] if* ] if* ; M: string user-passwd ( string -- passwd/f ) - unix.ffi:getpwnam dup [ unix.ffi:passwd memory>struct passwd>new-passwd ] when ; + unix.ffi:getpwnam dup [ passwd>new-passwd ] when ; : user-name ( id -- string ) dup user-passwd diff --git a/basis/unix/utmpx/utmpx.factor b/basis/unix/utmpx/utmpx.factor index 78556ab225..1d6dfdedec 100644 --- a/basis/unix/utmpx/utmpx.factor +++ b/basis/unix/utmpx/utmpx.factor @@ -41,7 +41,7 @@ M: unix new-utmpx-record utmpx-record new ; M: unix utmpx>utmpx-record ( utmpx -- utmpx-record ) - [ new-utmpx-record ] dip \ utmpx memory>struct + [ new-utmpx-record ] dip { [ ut_user>> _UTX_USERSIZE memory>string >>user ] [ ut_id>> _UTX_IDSIZE memory>string >>id ] diff --git a/basis/windows/com/wrapper/wrapper.factor b/basis/windows/com/wrapper/wrapper.factor index 696902439c..623a9c8db3 100644 --- a/basis/windows/com/wrapper/wrapper.factor +++ b/basis/windows/com/wrapper/wrapper.factor @@ -49,8 +49,7 @@ unless : (make-query-interface) ( interfaces -- quot ) (query-interface-cases) '[ - swap GUID memory>struct - _ case + swap _ case [ void* heap-size * rot com-add-ref swap 0 set-alien-cell S_OK diff --git a/basis/windows/uniscribe/uniscribe.factor b/basis/windows/uniscribe/uniscribe.factor index 87540dc24f..2783840df0 100644 --- a/basis/windows/uniscribe/uniscribe.factor +++ b/basis/windows/uniscribe/uniscribe.factor @@ -82,7 +82,6 @@ TUPLE: script-string < disposable font string metrics ssa size image ; : script-string-size ( script-string -- dim ) ssa>> ScriptString_pSize dup win32-error=0/f - SIZE memory>struct [ cx>> ] [ cy>> ] bi 2array ; : dc-metrics ( dc -- metrics ) From 8628b6032738dd5612805db6c26f1e8273a47d26 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 22 Feb 2010 12:34:38 -0800 Subject: [PATCH 191/713] remove unnecessary memory>structs from extra/ too --- extra/chipmunk/chipmunk.factor | 4 ++-- extra/chipmunk/demo/demo.factor | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/extra/chipmunk/chipmunk.factor b/extra/chipmunk/chipmunk.factor index c56e15e12e..a7cd5e0fd2 100644 --- a/extra/chipmunk/chipmunk.factor +++ b/extra/chipmunk/chipmunk.factor @@ -512,9 +512,9 @@ FUNCTION: void cpArbiterIgnore ( cpArbiter* arb ) ; TYPED: cpArbiterGetShapes ( arb: cpArbiter -- a: cpShape b: cpShape ) dup swappedColl>> 0 = [ - [ a>> cpShape memory>struct ] [ b>> cpShape memory>struct ] bi + [ a>> ] [ b>> ] bi ] [ - [ b>> cpShape memory>struct ] [ a>> cpShape memory>struct ] bi + [ b>> ] [ a>> ] bi ] if ; inline TYPED: cpArbiterIsFirstContact ( arb: cpArbiter -- ? ) diff --git a/extra/chipmunk/demo/demo.factor b/extra/chipmunk/demo/demo.factor index 06f3c32dbe..38a8689bec 100644 --- a/extra/chipmunk/demo/demo.factor +++ b/extra/chipmunk/demo/demo.factor @@ -50,9 +50,9 @@ CONSTANT: image-bitmap B{ x bitnot 7 bitand neg shift 1 bitand 1 = ; :: make-ball ( x y -- shape ) - cpBodyAlloc 1.0 NAN: 0 cpBodyInit cpBody memory>struct + cpBodyAlloc 1.0 NAN: 0 cpBodyInit x y cpv >>p :> body - cpCircleShapeAlloc body 0.95 0 0 cpv cpCircleShapeInit cpCircleShape memory>struct + cpCircleShapeAlloc body 0.95 0 0 cpv cpCircleShapeInit [ shape>> 0 >>e ] [ shape>> 0 >>u ] bi drop ; TUPLE: chipmunk-world < game-world @@ -76,7 +76,7 @@ M:: chipmunk-world draw-world* ( world -- ) 3 glPointSize 0 0 0 glColor3f GL_POINTS glBegin - space bodies>> cpArray memory>struct + space bodies>> [ num>> ] [ arr>> swap ] bi [ cpBody memory>struct p>> [ x>> ] [ y>> ] bi glVertex2f ] each @@ -85,7 +85,7 @@ M:: chipmunk-world draw-world* ( world -- ) 2 glPointSize 1 0 0 glColor3f GL_POINTS glBegin - space arbiters>> cpArray memory>struct + space arbiters>> [ num>> ] [ arr>> swap ] bi [ cpArbiter memory>struct [ numContacts>> ] [ contacts>> swap ] bi [ @@ -97,7 +97,7 @@ M:: chipmunk-world draw-world* ( world -- ) M:: chipmunk-world begin-game-world ( world -- ) cpInitChipmunk - cpSpaceAlloc cpSpaceInit cpSpace memory>struct :> space + cpSpaceAlloc cpSpaceInit :> space world space >>space drop space 2.0 10000 cpSpaceResizeActiveHash @@ -115,11 +115,11 @@ M:: chipmunk-world begin-game-world ( world -- ) ] each ] each - space cpBodyAlloc NAN: 0 dup cpBodyInit cpSpaceAddBody cpBody memory>struct :> body + space cpBodyAlloc NAN: 0 dup cpBodyInit cpSpaceAddBody :> body body -1000 -10 cpv >>p drop body 400 0 cpv >>v drop - space cpCircleShapeAlloc body 8 0 0 cpv cpCircleShapeInit cpSpaceAddShape cpCircleShape memory>struct :> shape + space cpCircleShapeAlloc body 8 0 0 cpv cpCircleShapeInit cpSpaceAddShape :> shape shape [ shape>> 0 >>e drop ] [ shape>> 0 >>u drop ] bi ; From 949f658928c724e00df8634d5ecf776591abcb77 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 22 Feb 2010 17:39:30 -0600 Subject: [PATCH 192/713] Fix a couple of typos in complex number docs --- core/math/math-docs.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor index 6357c8bd98..50a31434f4 100644 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -385,14 +385,14 @@ HELP: prev-float HELP: real-part { $values { "z" number } { "x" real } } { $description "Outputs the real part of a complex number. This acts as the identity on real numbers." } -{ $examples { $example "USING: math prettyprint ; C{ 1 2 } real-part ." "1" } } ; +{ $examples { $example "USING: math prettyprint ;" "C{ 1 2 } real-part ." "1" } } ; HELP: imaginary-part { $values { "z" number } { "y" real } } { $description "Outputs the imaginary part of a complex number. This outputs zero for real numbers." } { $examples - { $example "USING: math prettyprint ; C{ 1 2 } imaginary-part ." "2" } - { $example "USING: math prettyprint ; 3 imaginary-part ." "0" } + { $example "USING: math prettyprint ;" "C{ 1 2 } imaginary-part ." "2" } + { $example "USING: math prettyprint ;" "3 imaginary-part ." "0" } } ; HELP: real From 829351f2f28f61ec1d5ec10ba93025401b38a8ca Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 22 Feb 2010 19:08:43 -0800 Subject: [PATCH 193/713] don't box struct pointer values when they're null --- basis/alien/c-types/c-types-tests.factor | 2 -- basis/alien/c-types/c-types.factor | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/basis/alien/c-types/c-types-tests.factor b/basis/alien/c-types/c-types-tests.factor index 13bdfa742a..ad53dc487b 100644 --- a/basis/alien/c-types/c-types-tests.factor +++ b/basis/alien/c-types/c-types-tests.factor @@ -24,8 +24,6 @@ UNION-STRUCT: foo [ t ] [ pointer: char c-type char* c-type = ] unit-test -[ t ] [ pointer: foo c-type-boxer-quot foo c-type-boxer-quot = ] unit-test - [ t ] [ foo heap-size int heap-size = ] unit-test TYPEDEF: int MyInt diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor index a9392b03d7..316377dc27 100644 --- a/basis/alien/c-types/c-types.factor +++ b/basis/alien/c-types/c-types.factor @@ -288,7 +288,7 @@ CONSTANT: primitive-types } : (pointer-c-type) ( void* type -- void*' ) - [ clone ] dip c-type-boxer-quot >>boxer-quot ; + [ clone ] dip c-type-boxer-quot '[ _ [ f ] if* ] >>boxer-quot ; Date: Mon, 22 Feb 2010 19:09:03 -0800 Subject: [PATCH 194/713] missed a dead memory>struct in io.sockets --- basis/io/sockets/sockets.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/io/sockets/sockets.factor b/basis/io/sockets/sockets.factor index 59d12f95bc..a1260e80be 100644 --- a/basis/io/sockets/sockets.factor +++ b/basis/io/sockets/sockets.factor @@ -241,7 +241,7 @@ HOOK: (send) io-backend ( packet addrspec datagram -- ) parse-sockaddr ; : parse-addrinfo-list ( addrinfo -- seq ) - [ next>> dup [ addrinfo memory>struct ] when ] follow + [ next>> ] follow [ addrinfo>addrspec ] map sift ; From aead6e7dd879b2458e84f282fba61d6b70727ca1 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 22 Feb 2010 19:34:34 -0800 Subject: [PATCH 195/713] Revert change to make-callback-type cause Slava already fixed it in parse-arglist --- basis/alien/parser/parser.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index 8d850c47ee..8385bfb97f 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -91,14 +91,14 @@ IN: alien.parser '[ [ _ _ _ ] dip alien-callback ] ; :: make-callback-type ( lib return type-name parameters -- word quot effect ) - return type-name normalize-c-arg :> ( return-c-type type-name ) + return type-name normalize-c-arg :> ( return type-name ) type-name current-vocab create :> type-word type-word [ reset-generic ] [ reset-c-type ] bi void* type-word typedef parameters return parse-arglist :> ( types callback-effect ) type-word callback-effect "callback-effect" set-word-prop type-word lib "callback-library" set-word-prop - type-word return-c-type types lib library-abi callback-quot (( quot -- alien )) ; + type-word return types lib library-abi callback-quot (( quot -- alien )) ; : (CALLBACK:) ( -- word quot effect ) "c-library" get From 4f8a6a032ca1f9fa551f970d4e30056506a49cce Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 22 Feb 2010 19:34:54 -0800 Subject: [PATCH 196/713] Syntax highlighting for COM-INTERFACE: --- misc/fuel/fuel-syntax.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index 7de627f8f5..67a8ee89e0 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -46,7 +46,7 @@ '(":" "::" ";" "&:" "<<" ">" "ABOUT:" "ALIAS:" "ALIEN:" "ARTICLE:" "B" "BIN:" - "C:" "CALLBACK:" "C-ENUM:" "C-STRUCT:" "C-TYPE:" "C-UNION:" "CHAR:" "CONSTANT:" "call-next-method" + "C:" "CALLBACK:" "C-ENUM:" "C-STRUCT:" "C-TYPE:" "C-UNION:" "CHAR:" "COM-INTERFACE:" "CONSTANT:" "call-next-method" "DEFER:" "EBNF:" ";EBNF" "ERROR:" "EXCLUDE:" "f" "FORGET:" "FROM:" "FUNCTION:" @@ -125,7 +125,7 @@ (defconst fuel-syntax--type-definition-regex (fuel-syntax--second-word-regex - '("C-STRUCT:" "C-UNION:" "MIXIN:" "TUPLE:" "SINGLETON:" "SPECIALIZED-ARRAY:" "STRUCT:" "UNION:" "UNION-STRUCT:"))) + '("C-STRUCT:" "C-UNION:" "COM-INTERFACE:" "MIXIN:" "TUPLE:" "SINGLETON:" "SPECIALIZED-ARRAY:" "STRUCT:" "UNION:" "UNION-STRUCT:"))) (defconst fuel-syntax--tuple-decl-regex "^TUPLE: +\\([^ \n]+\\) +< +\\([^ \n]+\\)\\_>") @@ -156,7 +156,7 @@ "\\_ Date: Mon, 22 Feb 2010 19:35:52 -0800 Subject: [PATCH 197/713] repeated runs of classes.tuple test would fail because partially defined classes.tuple.tests:bad-superclass type would shadow classes.tuple:bad-superclass --- core/classes/tuple/tuple-tests.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/classes/tuple/tuple-tests.factor b/core/classes/tuple/tuple-tests.factor index 276c6b407c..1609c1eeca 100644 --- a/core/classes/tuple/tuple-tests.factor +++ b/core/classes/tuple/tuple-tests.factor @@ -267,7 +267,7 @@ test-server-slot-values ] unit-test [ - "IN: classes.tuple.tests TUPLE: bad-superclass < word ;" eval( -- ) + "IN: classes.tuple.tests TUPLE: invalid-superclass < word ;" eval( -- ) ] must-fail ! Dynamically changing inheritance hierarchy From 33f1a7b03b674993b0c81d55a8e3bfdbfcfdcb16 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 22 Feb 2010 19:36:14 -0800 Subject: [PATCH 198/713] db.sqlite.ffi: replace some TYPEDEF: void* foo* with C-TYPE: foo --- basis/db/sqlite/ffi/ffi.factor | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/basis/db/sqlite/ffi/ffi.factor b/basis/db/sqlite/ffi/ffi.factor index c180df9bf5..53562fd87e 100644 --- a/basis/db/sqlite/ffi/ffi.factor +++ b/basis/db/sqlite/ffi/ffi.factor @@ -99,8 +99,8 @@ CONSTANT: SQLITE_OPEN_TEMP_JOURNAL HEX: 00001000 CONSTANT: SQLITE_OPEN_SUBJOURNAL HEX: 00002000 CONSTANT: SQLITE_OPEN_MASTER_JOURNAL HEX: 00004000 -TYPEDEF: void* sqlite3* -TYPEDEF: void* sqlite3_stmt* +C-TYPE: sqlite3 +C-TYPE: sqlite3_stmt TYPEDEF: longlong sqlite3_int64 TYPEDEF: ulonglong sqlite3_uint64 @@ -121,7 +121,7 @@ FUNCTION: int sqlite3_bind_int64 ( sqlite3_stmt* pStmt, int index, sqlite3_int64 ! Bind the same function as above, but for unsigned 64bit integers : sqlite3-bind-uint64 ( pStmt index in64 -- int ) int "sqlite" "sqlite3_bind_int64" - { sqlite3_stmt* int sqlite3_uint64 } alien-invoke ; + { pointer: sqlite3_stmt int sqlite3_uint64 } alien-invoke ; FUNCTION: int sqlite3_bind_null ( sqlite3_stmt* pStmt, int n ) ; FUNCTION: int sqlite3_bind_text ( sqlite3_stmt* pStmt, int index, char* text, int len, int destructor ) ; FUNCTION: int sqlite3_bind_parameter_index ( sqlite3_stmt* pStmt, char* name ) ; @@ -135,7 +135,7 @@ FUNCTION: sqlite3_int64 sqlite3_column_int64 ( sqlite3_stmt* pStmt, int col ) ; ! Bind the same function as above, but for unsigned 64bit integers : sqlite3-column-uint64 ( pStmt col -- uint64 ) sqlite3_uint64 "sqlite" "sqlite3_column_int64" - { sqlite3_stmt* int } alien-invoke ; + { pointer: sqlite3_stmt int } alien-invoke ; FUNCTION: double sqlite3_column_double ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: char* sqlite3_column_name ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: char* sqlite3_column_text ( sqlite3_stmt* pStmt, int col ) ; From 0142d46688d7846b702aeae6a8d82ee045d60b2f Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 22 Feb 2010 20:17:49 -0800 Subject: [PATCH 199/713] Add scaffolding for platforms.txt, add option to fuel-scaffold-vocab --- basis/tools/scaffold/scaffold.factor | 3 +++ extra/fuel/fuel.factor | 4 ++++ misc/fuel/fuel-scaffold.el | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/basis/tools/scaffold/scaffold.factor b/basis/tools/scaffold/scaffold.factor index fee37496c8..9e1d08e352 100644 --- a/basis/tools/scaffold/scaffold.factor +++ b/basis/tools/scaffold/scaffold.factor @@ -267,6 +267,9 @@ PRIVATE> : scaffold-summary ( vocab summary -- ) [ "summary.txt" ] dip scaffold-metadata ; +: scaffold-platforms ( vocab platforms -- ) + [ "platforms.txt" ] dip scaffold-metadata ; + : scaffold-vocab ( vocab-root string -- ) { [ scaffold-directory ] diff --git a/extra/fuel/fuel.factor b/extra/fuel/fuel.factor index 2934d5d43c..9d47bf8cc4 100644 --- a/extra/fuel/fuel.factor +++ b/extra/fuel/fuel.factor @@ -162,6 +162,10 @@ PRIVATE> [ scaffold-summary ] [ drop [ vocab-summary-path ] keep swap vocab-append-path absolute-path fuel-eval-set-result ] 2bi ; +: fuel-scaffold-platforms ( name platforms -- ) + [ scaffold-platforms ] + [ drop [ vocab-platforms-path ] keep swap vocab-append-path absolute-path fuel-eval-set-result ] 2bi ; + : fuel-scaffold-get-root ( name -- ) find-vocab-root fuel-eval-set-result ; ! Remote connection diff --git a/misc/fuel/fuel-scaffold.el b/misc/fuel/fuel-scaffold.el index dc2a09713d..0078300fd1 100644 --- a/misc/fuel/fuel-scaffold.el +++ b/misc/fuel/fuel-scaffold.el @@ -96,6 +96,10 @@ IN: %s (let ((cmd `(:fuel* (,vocab ,summary fuel-scaffold-summary) "fuel"))) (fuel-eval--send/wait cmd))) +(defsubst fuel-scaffold--create-platforms (vocab platforms) + (let ((cmd `(:fuel* (,vocab ,platforms fuel-scaffold-platforms) "fuel"))) + (fuel-eval--send/wait cmd))) + (defun fuel-scaffold--help (parent) (when (and parent (fuel-scaffold--check-auto fuel-scaffold-help-autoinsert-p)) (let* ((ret (fuel-scaffold--create-docs (fuel-scaffold--vocab parent))) @@ -131,6 +135,7 @@ You can configure `fuel-scaffold-developer-name' (set by default to nil t (or root-hint "resource:"))) (summary (read-string "Vocab summary (empty for none): ")) (tags (read-string "Vocab tags (empty for none): ")) + (platforms (read-string "Vocab platforms (empty for all): ")) (help (y-or-n-p "Scaffold help? ")) (tests (y-or-n-p "Scaffold tests? ")) (cmd `(:fuel* ((,root ,name ,fuel-scaffold-developer-name) @@ -143,6 +148,8 @@ You can configure `fuel-scaffold-developer-name' (set by default to (fuel-scaffold--create-summary name summary)) (when (not (equal "" tags)) (fuel-scaffold--create-tags name tags)) + (when (not (equal "" platforms)) + (fuel-scaffold--create-platforms name platforms)) (when help (fuel-scaffold--create-docs name)) (when tests @@ -221,6 +228,18 @@ You can configure `fuel-scaffold-developer-name' (set by default to (error "Error creating summary file" (car (fuel-eval--retort-error ret)))) (find-file file))) +(defun fuel-scaffold-platforms (&optional arg) + "Creates, if it does not already exist, a platforms file for the current vocabulary." + (interactive "P") + (let* ((vocab (or (and (not arg ) (fuel-syntax--current-vocab)) + (fuel-completion--read-vocab nil))) + (platforms (read-string "Platforms: ")) + (ret (fuel-scaffold--create-platforms vocab platforms)) + (file (fuel-eval--retort-result ret))) + (unless file + (error "Error creating platforms file" (car (fuel-eval--retort-error ret)))) + (find-file file))) + (provide 'fuel-scaffold) ;;; fuel-scaffold.el ends here From ea2fcd2aedac8b26a7a5587aa082054db118fbd2 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 22 Feb 2010 20:18:15 -0800 Subject: [PATCH 200/713] Fix new compile errors in d3d bindings --- .../windows/directx/d3d10effect/d3d10effect.factor | 14 ++++++++++++++ .../windows/directx/d3d11shader/d3d11shader.factor | 3 +++ 2 files changed, 17 insertions(+) diff --git a/basis/windows/directx/d3d10effect/d3d10effect.factor b/basis/windows/directx/d3d10effect/d3d10effect.factor index 5b4fbb4ca5..1d809b3862 100644 --- a/basis/windows/directx/d3d10effect/d3d10effect.factor +++ b/basis/windows/directx/d3d10effect/d3d10effect.factor @@ -113,6 +113,20 @@ STRUCT: D3D10_EFFECT_VARIABLE_DESC { BufferOffset UINT } { ExplicitBindPoint UINT } ; +C-TYPE: ID3D10EffectConstantBuffer +C-TYPE: ID3D10EffectScalarVariable +C-TYPE: ID3D10EffectVectorVariable +C-TYPE: ID3D10EffectMatrixVariable +C-TYPE: ID3D10EffectStringVariable +C-TYPE: ID3D10EffectShaderResourceVariable +C-TYPE: ID3D10EffectRenderTargetViewVariable +C-TYPE: ID3D10EffectDepthStencilViewVariable +C-TYPE: ID3D10EffectShaderVariable +C-TYPE: ID3D10EffectBlendVariable +C-TYPE: ID3D10EffectDepthStencilVariable +C-TYPE: ID3D10EffectRasterizerVariable +C-TYPE: ID3D10EffectSamplerVariable + COM-INTERFACE: ID3D10EffectVariable f {AE897105-00E6-45bf-BB8E-281DD6DB8E1B} BOOL IsValid ( ) ID3D10EffectType* GetType ( ) diff --git a/basis/windows/directx/d3d11shader/d3d11shader.factor b/basis/windows/directx/d3d11shader/d3d11shader.factor index a0437e3e65..02ab9bb177 100644 --- a/basis/windows/directx/d3d11shader/d3d11shader.factor +++ b/basis/windows/directx/d3d11shader/d3d11shader.factor @@ -152,6 +152,9 @@ COM-INTERFACE: ID3D11ShaderReflectionType f {6E6FFA6A-9BAE-4613-A51E-91652D508C2 HRESULT IsOfType ( ID3D11ShaderReflectionType* pType ) HRESULT ImplementsInterface ( ID3D11ShaderReflectionType* pBase ) ; +C-TYPE: ID3D11ShaderReflectionType +C-TYPE: ID3D11ShaderReflectionConstantBuffer + COM-INTERFACE: ID3D11ShaderReflectionVariable f {51F23923-F3E5-4BD1-91CB-606177D8DB4C} HRESULT GetDesc ( D3D11_SHADER_VARIABLE_DESC* pDesc ) ID3D11ShaderReflectionType* GetType ( ) From e513151e1d93f1c90132146ecfb4916b20b27a73 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 22 Feb 2010 20:19:04 -0800 Subject: [PATCH 201/713] Summary and tags file for windows.ddk.hid --- basis/windows/ddk/hid/summary.txt | 1 + basis/windows/ddk/hid/tags.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 basis/windows/ddk/hid/summary.txt create mode 100644 basis/windows/ddk/hid/tags.txt diff --git a/basis/windows/ddk/hid/summary.txt b/basis/windows/ddk/hid/summary.txt new file mode 100644 index 0000000000..71ad299177 --- /dev/null +++ b/basis/windows/ddk/hid/summary.txt @@ -0,0 +1 @@ +Bindings to the HID section of the Windows DDK \ No newline at end of file diff --git a/basis/windows/ddk/hid/tags.txt b/basis/windows/ddk/hid/tags.txt new file mode 100644 index 0000000000..fdce1614de --- /dev/null +++ b/basis/windows/ddk/hid/tags.txt @@ -0,0 +1 @@ +unportable bindings \ No newline at end of file From 234fa6e20d0471b955a49e6262c0052cb7b325eb Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 22 Feb 2010 20:37:06 -0800 Subject: [PATCH 202/713] Windows DDK SetupAPI bindings -- used for hardware device discovery --- basis/windows/ddk/setupapi/authors.txt | 1 + basis/windows/ddk/setupapi/platforms.txt | 1 + basis/windows/ddk/setupapi/setupapi.factor | 2033 ++++++++++++++++++++ basis/windows/ddk/setupapi/summary.txt | 1 + basis/windows/ddk/setupapi/tags.txt | 1 + 5 files changed, 2037 insertions(+) create mode 100644 basis/windows/ddk/setupapi/authors.txt create mode 100644 basis/windows/ddk/setupapi/platforms.txt create mode 100644 basis/windows/ddk/setupapi/setupapi.factor create mode 100644 basis/windows/ddk/setupapi/summary.txt create mode 100644 basis/windows/ddk/setupapi/tags.txt diff --git a/basis/windows/ddk/setupapi/authors.txt b/basis/windows/ddk/setupapi/authors.txt new file mode 100644 index 0000000000..f596342efa --- /dev/null +++ b/basis/windows/ddk/setupapi/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/basis/windows/ddk/setupapi/platforms.txt b/basis/windows/ddk/setupapi/platforms.txt new file mode 100644 index 0000000000..d2e9c5bf45 --- /dev/null +++ b/basis/windows/ddk/setupapi/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/ddk/setupapi/setupapi.factor b/basis/windows/ddk/setupapi/setupapi.factor new file mode 100644 index 0000000000..06d32725f7 --- /dev/null +++ b/basis/windows/ddk/setupapi/setupapi.factor @@ -0,0 +1,2033 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: literals windows.kernel32 math alien.syntax windows.types classes.struct +alien.c-types windows.errors windows.ole32 windows.advapi32 alien.libraries ; +IN: windows.ddk.setupapi + +<< "setupapi" "setupapi.dll" "stdcall" add-library >> +LIBRARY: setupapi + +TYPEDEF: DWORDLONG SP_LOG_TOKEN +TYPEDEF: DWORDLONG* PSP_LOG_TOKEN + +CONSTANT: LOGTOKEN_TYPE_MASK 3 +CONSTANT: LOGTOKEN_UNSPECIFIED 0 +CONSTANT: LOGTOKEN_NO_LOG 1 +CONSTANT: LOGTOKEN_SETUPAPI_APPLOG 2 +CONSTANT: LOGTOKEN_SETUPAPI_DEVLOG 3 + +CONSTANT: TXTLOG_SETUPAPI_DEVLOG HEX: 00000001 +CONSTANT: TXTLOG_SETUPAPI_CMDLINE HEX: 00000002 +CONSTANT: TXTLOG_SETUPAPI_BITS HEX: 00000003 + +CONSTANT: TXTLOG_ERROR HEX: 1 +CONSTANT: TXTLOG_WARNING HEX: 2 +CONSTANT: TXTLOG_SYSTEM_STATE_CHANGE HEX: 3 +CONSTANT: TXTLOG_SUMMARY HEX: 4 +CONSTANT: TXTLOG_DETAILS HEX: 5 +CONSTANT: TXTLOG_VERBOSE HEX: 6 +CONSTANT: TXTLOG_VERY_VERBOSE HEX: 7 + +CONSTANT: TXTLOG_RESERVED_FLAGS HEX: 0000FFF0 + +CONSTANT: TXTLOG_TIMESTAMP HEX: 00010000 +CONSTANT: TXTLOG_DEPTH_INCR HEX: 00020000 +CONSTANT: TXTLOG_DEPTH_DECR HEX: 00040000 +CONSTANT: TXTLOG_TAB_1 HEX: 00080000 +CONSTANT: TXTLOG_FLUSH_FILE HEX: 00100000 + +: TXTLOG_LEVEL ( flags -- n ) HEX: f bitand ; inline + +CONSTANT: TXTLOG_DEVINST HEX: 00000001 +CONSTANT: TXTLOG_INF HEX: 00000002 +CONSTANT: TXTLOG_FILEQ HEX: 00000004 +CONSTANT: TXTLOG_COPYFILES HEX: 00000008 +CONSTANT: TXTLOG_SIGVERIF HEX: 00000020 +CONSTANT: TXTLOG_BACKUP HEX: 00000080 +CONSTANT: TXTLOG_UI HEX: 00000100 +CONSTANT: TXTLOG_UTIL HEX: 00000200 +CONSTANT: TXTLOG_INFDB HEX: 00000400 +CONSTANT: TXTLOG_POLICY HEX: 00800000 +CONSTANT: TXTLOG_NEWDEV HEX: 01000000 +CONSTANT: TXTLOG_UMPNPMGR HEX: 02000000 +CONSTANT: TXTLOG_DRIVER_STORE HEX: 04000000 +CONSTANT: TXTLOG_SETUP HEX: 08000000 +CONSTANT: TXTLOG_CMI HEX: 10000000 +CONSTANT: TXTLOG_DEVMGR HEX: 20000000 +CONSTANT: TXTLOG_INSTALLER HEX: 40000000 +CONSTANT: TXTLOG_VENDOR HEX: 80000000 + +TYPEDEF: void* HPROPSHEETPAGE +TYPEDEF: void* HIMAGELIST +C-TYPE: DEVPROPKEY +TYPEDEF: ULONG DEVPROPTYPE +TYPEDEF: DEVPROPTYPE* PDEVPROPTYPE +TYPEDEF: void* LPPROPSHEETHEADERA +TYPEDEF: void* LPPROPSHEETHEADERW + +CONSTANT: LINE_LEN 256 +CONSTANT: LINE_LEN*2 512 +CONSTANT: MAX_INF_STRING_LENGTH 4096 +CONSTANT: MAX_INF_SECTION_NAME_LENGTH 255 +CONSTANT: MAX_TITLE_LEN 60 +CONSTANT: MAX_INSTRUCTION_LEN 256 +CONSTANT: MAX_LABEL_LEN 30 +CONSTANT: MAX_SERVICE_NAME_LEN 256 +CONSTANT: MAX_SUBTITLE_LEN 256 +CONSTANT: SP_MAX_MACHINENAME_LENGTH $[ MAX_PATH 3 + ] + +TYPEDEF: PVOID HINF + +STRUCT: INFCONTEXT + { Inf PVOID } + { CurrentInf PVOID } + { Section UINT } + { Line UINT } ; +TYPEDEF: INFCONTEXT* PINFCONTEXT + +STRUCT: SP_INF_INFORMATION + { InfStyle DWORD } + { InfCount DWORD } + { VersionDat BYTE[ANYSIZE_ARRAY] } ; +TYPEDEF: SP_INF_INFORMATION* PSP_INF_INFORMATION + +STRUCT: SP_ALTPLATFORM_INFO_V2 + { cbSize DWORD } + { Platform DWORD } + { MajorVersion DWORD } + { MinorVersion DWORD } + { ProcessorArchitecture WORD } + { Flags WORD } + { FirstValidatedMajorVersion DWORD } + { FirstValidatedMinorVersion DWORD } ; +TYPEDEF: SP_ALTPLATFORM_INFO_V2* PSP_ALTPLATFORM_INFO_V2 + +STRUCT: SP_ALTPLATFORM_INFO_V1 + { cbSize DWORD } + { Platform DWORD } + { MajorVersion DWORD } + { MinorVersion DWORD } + { ProcessorArchitecture WORD } + { Reserved WORD } ; +TYPEDEF: SP_ALTPLATFORM_INFO_V1* PSP_ALTPLATFORM_INFO_V1 +TYPEDEF: SP_ALTPLATFORM_INFO_V2 SP_ALTPLATFORM_INFO +TYPEDEF: PSP_ALTPLATFORM_INFO_V2 PSP_ALTPLATFORM_INFO + +CONSTANT: SP_ALTPLATFORM_FLAGS_VERSION_RANGE 1 + +STRUCT: SP_ORIGINAL_FILE_INFO_A + { cbSize DWORD } + { OriginalInfName CHAR[MAX_PATH] } + { OriginalCatalogName CHAR[MAX_PATH] } ; +TYPEDEF: SP_ORIGINAL_FILE_INFO_A* PSP_ORIGINAL_FILE_INFO_A +STRUCT: SP_ORIGINAL_FILE_INFO_W + { cbSize DWORD } + { OriginalInfName WCHAR[MAX_PATH] } + { OriginalCatalogName WCHAR[MAX_PATH] } ; +TYPEDEF: SP_ORIGINAL_FILE_INFO_W* PSP_ORIGINAL_FILE_INFO_W +TYPEDEF: SP_ORIGINAL_FILE_INFO_W SP_ORIGINAL_FILE_INFO +TYPEDEF: PSP_ORIGINAL_FILE_INFO_W PSP_ORIGINAL_FILE_INFO + +CONSTANT: INF_STYLE_NONE HEX: 00000000 +CONSTANT: INF_STYLE_OLDNT HEX: 00000001 +CONSTANT: INF_STYLE_WIN4 HEX: 00000002 +CONSTANT: INF_STYLE_CACHE_ENABLE HEX: 00000010 +CONSTANT: INF_STYLE_CACHE_DISABLE HEX: 00000020 +CONSTANT: INF_STYLE_CACHE_IGNORE HEX: 00000040 +CONSTANT: DIRID_ABSOLUTE -1 +CONSTANT: DIRID_ABSOLUTE_16BIT HEX: ffff +CONSTANT: DIRID_NULL 0 +CONSTANT: DIRID_SRCPATH 1 +CONSTANT: DIRID_WINDOWS 10 +CONSTANT: DIRID_SYSTEM 11 +CONSTANT: DIRID_DRIVERS 12 +CONSTANT: DIRID_IOSUBSYS $ DIRID_DRIVERS +CONSTANT: DIRID_INF 17 +CONSTANT: DIRID_HELP 18 +CONSTANT: DIRID_FONTS 20 +CONSTANT: DIRID_VIEWERS 21 +CONSTANT: DIRID_COLOR 23 +CONSTANT: DIRID_APPS 24 +CONSTANT: DIRID_SHARED 25 +CONSTANT: DIRID_BOOT 30 +CONSTANT: DIRID_SYSTEM16 50 +CONSTANT: DIRID_SPOOL 51 +CONSTANT: DIRID_SPOOLDRIVERS 52 +CONSTANT: DIRID_USERPROFILE 53 +CONSTANT: DIRID_LOADER 54 +CONSTANT: DIRID_PRINTPROCESSOR 55 +CONSTANT: DIRID_DEFAULT $ DIRID_SYSTEM +CONSTANT: DIRID_COMMON_STARTMENU 16406 +CONSTANT: DIRID_COMMON_PROGRAMS 16407 +CONSTANT: DIRID_COMMON_STARTUP 16408 +CONSTANT: DIRID_COMMON_DESKTOPDIRECTORY 16409 +CONSTANT: DIRID_COMMON_FAVORITES 16415 +CONSTANT: DIRID_COMMON_APPDATA 16419 +CONSTANT: DIRID_PROGRAM_FILES 16422 +CONSTANT: DIRID_SYSTEM_X86 16425 +CONSTANT: DIRID_PROGRAM_FILES_X86 16426 +CONSTANT: DIRID_PROGRAM_FILES_COMMON 16427 +CONSTANT: DIRID_PROGRAM_FILES_COMMONX86 16428 +CONSTANT: DIRID_COMMON_TEMPLATES 16429 +CONSTANT: DIRID_COMMON_DOCUMENTS 16430 +CONSTANT: DIRID_USER HEX: 8000 +CALLBACK: UINT PSP_FILE_CALLBACK_A ( PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2 ) ; +CALLBACK: UINT PSP_FILE_CALLBACK_W ( PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2 ) ; +TYPEDEF: PSP_FILE_CALLBACK_W PSP_FILE_CALLBACK +CONSTANT: SPFILENOTIFY_STARTQUEUE HEX: 00000001 +CONSTANT: SPFILENOTIFY_ENDQUEUE HEX: 00000002 +CONSTANT: SPFILENOTIFY_STARTSUBQUEUE HEX: 00000003 +CONSTANT: SPFILENOTIFY_ENDSUBQUEUE HEX: 00000004 +CONSTANT: SPFILENOTIFY_STARTDELETE HEX: 00000005 +CONSTANT: SPFILENOTIFY_ENDDELETE HEX: 00000006 +CONSTANT: SPFILENOTIFY_DELETEERROR HEX: 00000007 +CONSTANT: SPFILENOTIFY_STARTRENAME HEX: 00000008 +CONSTANT: SPFILENOTIFY_ENDRENAME HEX: 00000009 +CONSTANT: SPFILENOTIFY_RENAMEERROR HEX: 0000000a +CONSTANT: SPFILENOTIFY_STARTCOPY HEX: 0000000b +CONSTANT: SPFILENOTIFY_ENDCOPY HEX: 0000000c +CONSTANT: SPFILENOTIFY_COPYERROR HEX: 0000000d +CONSTANT: SPFILENOTIFY_NEEDMEDIA HEX: 0000000e +CONSTANT: SPFILENOTIFY_QUEUESCAN HEX: 0000000f +CONSTANT: SPFILENOTIFY_CABINETINFO HEX: 00000010 +CONSTANT: SPFILENOTIFY_FILEINCABINET HEX: 00000011 +CONSTANT: SPFILENOTIFY_NEEDNEWCABINET HEX: 00000012 +CONSTANT: SPFILENOTIFY_FILEEXTRACTED HEX: 00000013 +CONSTANT: SPFILENOTIFY_FILEOPDELAYED HEX: 00000014 +CONSTANT: SPFILENOTIFY_STARTBACKUP HEX: 00000015 +CONSTANT: SPFILENOTIFY_BACKUPERROR HEX: 00000016 +CONSTANT: SPFILENOTIFY_ENDBACKUP HEX: 00000017 +CONSTANT: SPFILENOTIFY_QUEUESCAN_EX HEX: 00000018 +CONSTANT: SPFILENOTIFY_STARTREGISTRATION HEX: 00000019 +CONSTANT: SPFILENOTIFY_ENDREGISTRATION HEX: 00000020 +CONSTANT: SPFILENOTIFY_QUEUESCAN_SIGNERINFO HEX: 00000040 +CONSTANT: SPFILENOTIFY_LANGMISMATCH HEX: 00010000 +CONSTANT: SPFILENOTIFY_TARGETEXISTS HEX: 00020000 +CONSTANT: SPFILENOTIFY_TARGETNEWER HEX: 00040000 +CONSTANT: FILEOP_COPY 0 +CONSTANT: FILEOP_RENAME 1 +CONSTANT: FILEOP_DELETE 2 +CONSTANT: FILEOP_BACKUP 3 +CONSTANT: FILEOP_ABORT 0 +CONSTANT: FILEOP_DOIT 1 +CONSTANT: FILEOP_SKIP 2 +CONSTANT: FILEOP_RETRY $ FILEOP_DOIT +CONSTANT: FILEOP_NEWPATH 4 +CONSTANT: COPYFLG_WARN_IF_SKIP HEX: 00000001 +CONSTANT: COPYFLG_NOSKIP HEX: 00000002 +CONSTANT: COPYFLG_NOVERSIONCHECK HEX: 00000004 +CONSTANT: COPYFLG_FORCE_FILE_IN_USE HEX: 00000008 +CONSTANT: COPYFLG_NO_OVERWRITE HEX: 00000010 +CONSTANT: COPYFLG_NO_VERSION_DIALOG HEX: 00000020 +CONSTANT: COPYFLG_OVERWRITE_OLDER_ONLY HEX: 00000040 +CONSTANT: COPYFLG_PROTECTED_WINDOWS_DRIVER_FILE HEX: 00000100 +CONSTANT: COPYFLG_REPLACEONLY HEX: 00000400 +CONSTANT: COPYFLG_NODECOMP HEX: 00000800 +CONSTANT: COPYFLG_REPLACE_BOOT_FILE HEX: 00001000 +CONSTANT: COPYFLG_NOPRUNE HEX: 00002000 +CONSTANT: COPYFLG_IN_USE_TRY_RENAME HEX: 00004000 +CONSTANT: DELFLG_IN_USE HEX: 00000001 +CONSTANT: DELFLG_IN_USE1 HEX: 00010000 +STRUCT: FILEPATHS_A + { Target PCSTR } + { Source PCSTR } + { Win32Error UINT } + { Flags DWORD } ; +TYPEDEF: FILEPATHS_A* PFILEPATHS_A +STRUCT: FILEPATHS_W + { Target PCWSTR } + { Source PCWSTR } + { Win32Error UINT } + { Flags DWORD } ; +TYPEDEF: FILEPATHS_W* PFILEPATHS_W +TYPEDEF: FILEPATHS_W FILEPATHS +TYPEDEF: PFILEPATHS_W PFILEPATHS +STRUCT: FILEPATHS_SIGNERINFO_A + { Target PCSTR } + { Source PCSTR } + { Win32Error UINT } + { Flags DWORD } + { DigitalSigner PCSTR } + { Version PCSTR } + { CatalogFile PCSTR } ; +TYPEDEF: FILEPATHS_SIGNERINFO_A* PFILEPATHS_SIGNERINFO_A +STRUCT: FILEPATHS_SIGNERINFO_W + { Target PCWSTR } + { Source PCWSTR } + { Win32Error UINT } + { Flags DWORD } + { DigitalSigner PCWSTR } + { Version PCWSTR } + { CatalogFile PCWSTR } ; +TYPEDEF: FILEPATHS_SIGNERINFO_W* PFILEPATHS_SIGNERINFO_W +TYPEDEF: FILEPATHS_SIGNERINFO_W FILEPATHS_SIGNERINFO +TYPEDEF: PFILEPATHS_SIGNERINFO_W PFILEPATHS_SIGNERINFO + +STRUCT: SOURCE_MEDIA_A + { Reserved PCSTR } + { Tagfile PCSTR } + { Description PCSTR } + { SourcePath PCSTR } + { SourceFile PCSTR } + { Flags DWORD } ; +TYPEDEF: SOURCE_MEDIA_A* PSOURCE_MEDIA_A +STRUCT: SOURCE_MEDIA_W + { Reserved PCWSTR } + { Tagfile PCWSTR } + { Description PCWSTR } + { SourcePath PCWSTR } + { SourceFile PCWSTR } + { Flags DWORD } ; +TYPEDEF: SOURCE_MEDIA_W* PSOURCE_MEDIA_W +TYPEDEF: SOURCE_MEDIA_W SOURCE_MEDIA +TYPEDEF: PSOURCE_MEDIA_W PSOURCE_MEDIA + +STRUCT: CABINET_INFO_A + { CabinetPath PCSTR } + { CabinetFile PCSTR } + { DiskName PCSTR } + { SetId USHORT } + { CabinetNumber USHORT } ; +TYPEDEF: CABINET_INFO_A* PCABINET_INFO_A +STRUCT: CABINET_INFO_W + { CabinetPath PCWSTR } + { CabinetFile PCWSTR } + { DiskName PCWSTR } + { SetId USHORT } + { CabinetNumber USHORT } ; +TYPEDEF: CABINET_INFO_W* PCABINET_INFO_W +TYPEDEF: CABINET_INFO_W CABINET_INFO +TYPEDEF: PCABINET_INFO_W PCABINET_INFO + +STRUCT: FILE_IN_CABINET_INFO_A + { NameInCabinet PCSTR } + { FileSize DWORD } + { Win32Error DWORD } + { DosDate WORD } + { DosTime WORD } + { DosAttribs WORD } + { FullTargetName CHAR[MAX_PATH] } ; +TYPEDEF: FILE_IN_CABINET_INFO_A* PFILE_IN_CABINET_INFO_A +STRUCT: FILE_IN_CABINET_INFO_W + { NameInCabinet PCWSTR } + { FileSize DWORD } + { Win32Error DWORD } + { DosDate WORD } + { DosTime WORD } + { DosAttribs WORD } + { FullTargetName WCHAR[MAX_PATH] } ; +TYPEDEF: FILE_IN_CABINET_INFO_W* PFILE_IN_CABINET_INFO_W +TYPEDEF: FILE_IN_CABINET_INFO_W FILE_IN_CABINET_INFO +TYPEDEF: PFILE_IN_CABINET_INFO_W PFILE_IN_CABINET_INFO + +STRUCT: SP_REGISTER_CONTROL_STATUSA + { cbSize DWORD } + { FileName PCSTR } + { Win32Error DWORD } + { FailureCode DWORD } ; +TYPEDEF: SP_REGISTER_CONTROL_STATUSA* PSP_REGISTER_CONTROL_STATUSA +STRUCT: SP_REGISTER_CONTROL_STATUSW + { cbSize DWORD } + { FileName PCWSTR } + { Win32Error DWORD } + { FailureCode DWORD } ; +TYPEDEF: SP_REGISTER_CONTROL_STATUSW* PSP_REGISTER_CONTROL_STATUSW + +TYPEDEF: SP_REGISTER_CONTROL_STATUSW SP_REGISTER_CONTROL_STATUS +TYPEDEF: PSP_REGISTER_CONTROL_STATUSW PSP_REGISTER_CONTROL_STATUS + +CONSTANT: SPREG_SUCCESS HEX: 00000000 +CONSTANT: SPREG_LOADLIBRARY HEX: 00000001 +CONSTANT: SPREG_GETPROCADDR HEX: 00000002 +CONSTANT: SPREG_REGSVR HEX: 00000003 +CONSTANT: SPREG_DLLINSTALL HEX: 00000004 +CONSTANT: SPREG_TIMEOUT HEX: 00000005 +CONSTANT: SPREG_UNKNOWN HEX: FFFFFFFF + +TYPEDEF: PVOID HSPFILEQ + +STRUCT: SP_FILE_COPY_PARAMS_A + { cbSize DWORD } + { QueueHandle HSPFILEQ } + { SourceRootPath PCSTR } + { SourcePath PCSTR } + { SourceFilename PCSTR } + { SourceDescription PCSTR } + { SourceTagfile PCSTR } + { TargetDirectory PCSTR } + { TargetFilename PCSTR } + { CopyStyle DWORD } + { LayoutInf HINF } + { SecurityDescriptor PCSTR } ; +TYPEDEF: SP_FILE_COPY_PARAMS_A* PSP_FILE_COPY_PARAMS_A +STRUCT: SP_FILE_COPY_PARAMS_W + { cbSize DWORD } + { QueueHandle HSPFILEQ } + { SourceRootPath PCWSTR } + { SourcePath PCWSTR } + { SourceFilename PCWSTR } + { SourceDescription PCWSTR } + { SourceTagfile PCWSTR } + { TargetDirectory PCWSTR } + { TargetFilename PCWSTR } + { CopyStyle DWORD } + { LayoutInf HINF } + { SecurityDescriptor PCWSTR } ; +TYPEDEF: SP_FILE_COPY_PARAMS_W* PSP_FILE_COPY_PARAMS_W + +TYPEDEF: SP_FILE_COPY_PARAMS_W SP_FILE_COPY_PARAMS +TYPEDEF: PSP_FILE_COPY_PARAMS_W PSP_FILE_COPY_PARAMS + +TYPEDEF: PVOID HDSKSPC +TYPEDEF: PVOID HDEVINFO + +STRUCT: SP_DEVINFO_DATA + { cbSize DWORD } + { ClassGuid GUID } + { DevInst DWORD } + { Reserved ULONG_PTR } ; +TYPEDEF: SP_DEVINFO_DATA* PSP_DEVINFO_DATA +STRUCT: SP_DEVICE_INTERFACE_DATA + { cbSize DWORD } + { InterfaceClassGuid GUID } + { Flags DWORD } + { Reserved ULONG_PTR } ; +TYPEDEF: SP_DEVICE_INTERFACE_DATA* PSP_DEVICE_INTERFACE_DATA + +CONSTANT: SPINT_ACTIVE HEX: 00000001 +CONSTANT: SPINT_DEFAULT HEX: 00000002 +CONSTANT: SPINT_REMOVED HEX: 00000004 +TYPEDEF: SP_DEVICE_INTERFACE_DATA SP_INTERFACE_DEVICE_DATA +TYPEDEF: PSP_DEVICE_INTERFACE_DATA PSP_INTERFACE_DEVICE_DAT +CONSTANT: SPID_ACTIVE $ SPINT_ACTIVE +CONSTANT: SPID_DEFAULT $ SPINT_DEFAULT +CONSTANT: SPID_REMOVED $ SPINT_REMOVED + +STRUCT: SP_DEVICE_INTERFACE_DETAIL_DATA_A + { cbSize DWORD } + { DevicePath CHAR[ANYSIZE_ARRAY] } ; +TYPEDEF: SP_DEVICE_INTERFACE_DETAIL_DATA_A* PSP_DEVICE_INTERFACE_DETAIL_DATA_A +STRUCT: SP_DEVICE_INTERFACE_DETAIL_DATA_W + { cbSize DWORD } + { DevicePath WCHAR[ANYSIZE_ARRAY] } ; +TYPEDEF: SP_DEVICE_INTERFACE_DETAIL_DATA_W* PSP_DEVICE_INTERFACE_DETAIL_DATA_W +TYPEDEF: SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_DEVICE_INTERFACE_DETAIL_DATA +TYPEDEF: PSP_DEVICE_INTERFACE_DETAIL_DATA_W PSP_DEVICE_INTERFACE_DETAIL_DATA +TYPEDEF: SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_INTERFACE_DEVICE_DETAIL_DATA_W +TYPEDEF: PSP_DEVICE_INTERFACE_DETAIL_DATA_W PSP_INTERFACE_DEVICE_DETAIL_DATA_W +TYPEDEF: SP_DEVICE_INTERFACE_DETAIL_DATA_A SP_INTERFACE_DEVICE_DETAIL_DATA_A +TYPEDEF: PSP_DEVICE_INTERFACE_DETAIL_DATA_A PSP_INTERFACE_DEVICE_DETAIL_DATA_A + +TYPEDEF: SP_INTERFACE_DEVICE_DETAIL_DATA_W SP_INTERFACE_DEVICE_DETAIL_DATA +TYPEDEF: PSP_INTERFACE_DEVICE_DETAIL_DATA_W PSP_INTERFACE_DEVICE_DETAIL_DATA + +STRUCT: SP_DEVINFO_LIST_DETAIL_DATA_A + { cbSize DWORD } + { ClassGuid GUID } + { RemoteMachineHandle HANDLE } + { RemoteMachineName CHAR[SP_MAX_MACHINENAME_LENGTH] } ; +TYPEDEF: SP_DEVINFO_LIST_DETAIL_DATA_A* PSP_DEVINFO_LIST_DETAIL_DATA_A +STRUCT: SP_DEVINFO_LIST_DETAIL_DATA_W + { cbSize DWORD } + { ClassGuid GUID } + { RemoteMachineHandle HANDLE } + { RemoteMachineName WCHAR[SP_MAX_MACHINENAME_LENGTH] } ; +TYPEDEF: SP_DEVINFO_LIST_DETAIL_DATA_W* PSP_DEVINFO_LIST_DETAIL_DATA_W + +TYPEDEF: SP_DEVINFO_LIST_DETAIL_DATA_W SP_DEVINFO_LIST_DETAIL_DATA +TYPEDEF: PSP_DEVINFO_LIST_DETAIL_DATA_W PSP_DEVINFO_LIST_DETAIL_DATA + +CONSTANT: DIF_SELECTDEVICE HEX: 00000001 +CONSTANT: DIF_INSTALLDEVICE HEX: 00000002 +CONSTANT: DIF_ASSIGNRESOURCES HEX: 00000003 +CONSTANT: DIF_PROPERTIES HEX: 00000004 +CONSTANT: DIF_REMOVE HEX: 00000005 +CONSTANT: DIF_FIRSTTIMESETUP HEX: 00000006 +CONSTANT: DIF_FOUNDDEVICE HEX: 00000007 +CONSTANT: DIF_SELECTCLASSDRIVERS HEX: 00000008 +CONSTANT: DIF_VALIDATECLASSDRIVERS HEX: 00000009 +CONSTANT: DIF_INSTALLCLASSDRIVERS HEX: 0000000A +CONSTANT: DIF_CALCDISKSPACE HEX: 0000000B +CONSTANT: DIF_DESTROYPRIVATEDATA HEX: 0000000C +CONSTANT: DIF_VALIDATEDRIVER HEX: 0000000D +CONSTANT: DIF_DETECT HEX: 0000000F +CONSTANT: DIF_INSTALLWIZARD HEX: 00000010 +CONSTANT: DIF_DESTROYWIZARDDATA HEX: 00000011 +CONSTANT: DIF_PROPERTYCHANGE HEX: 00000012 +CONSTANT: DIF_ENABLECLASS HEX: 00000013 +CONSTANT: DIF_DETECTVERIFY HEX: 00000014 +CONSTANT: DIF_INSTALLDEVICEFILES HEX: 00000015 +CONSTANT: DIF_UNREMOVE HEX: 00000016 +CONSTANT: DIF_SELECTBESTCOMPATDRV HEX: 00000017 +CONSTANT: DIF_ALLOW_INSTALL HEX: 00000018 +CONSTANT: DIF_REGISTERDEVICE HEX: 00000019 +CONSTANT: DIF_NEWDEVICEWIZARD_PRESELECT HEX: 0000001A +CONSTANT: DIF_NEWDEVICEWIZARD_SELECT HEX: 0000001B +CONSTANT: DIF_NEWDEVICEWIZARD_PREANALYZE HEX: 0000001C +CONSTANT: DIF_NEWDEVICEWIZARD_POSTANALYZE HEX: 0000001D +CONSTANT: DIF_NEWDEVICEWIZARD_FINISHINSTALL HEX: 0000001E +CONSTANT: DIF_UNUSED1 HEX: 0000001F +CONSTANT: DIF_INSTALLINTERFACES HEX: 00000020 +CONSTANT: DIF_DETECTCANCEL HEX: 00000021 +CONSTANT: DIF_REGISTER_COINSTALLERS HEX: 00000022 +CONSTANT: DIF_ADDPROPERTYPAGE_ADVANCED HEX: 00000023 +CONSTANT: DIF_ADDPROPERTYPAGE_BASIC HEX: 00000024 +CONSTANT: DIF_RESERVED1 HEX: 00000025 +CONSTANT: DIF_TROUBLESHOOTER HEX: 00000026 +CONSTANT: DIF_POWERMESSAGEWAKE HEX: 00000027 +CONSTANT: DIF_ADDREMOTEPROPERTYPAGE_ADVANCED HEX: 00000028 +CONSTANT: DIF_UPDATEDRIVER_UI HEX: 00000029 +CONSTANT: DIF_FINISHINSTALL_ACTION HEX: 0000002A +CONSTANT: DIF_RESERVED2 HEX: 00000030 +CONSTANT: DIF_MOVEDEVICE HEX: 0000000E +TYPEDEF: UINT DI_FUNCTION + +STRUCT: SP_DEVINSTALL_PARAMS_A + { cbSize DWORD } + { Flags DWORD } + { FlagsEx DWORD } + { hwndParent HWND } + { InstallMsgHandler PSP_FILE_CALLBACK } + { InstallMsgHandlerContext PVOID } + { FileQueue HSPFILEQ } + { ClassInstallReserved ULONG_PTR } + { Reserved DWORD } + { DriverPath CHAR[MAX_PATH] } ; +TYPEDEF: SP_DEVINSTALL_PARAMS_A* PSP_DEVINSTALL_PARAMS_A +STRUCT: SP_DEVINSTALL_PARAMS_W + { cbSize DWORD } + { Flags DWORD } + { FlagsEx DWORD } + { hwndParent HWND } + { InstallMsgHandler PSP_FILE_CALLBACK } + { InstallMsgHandlerContext PVOID } + { FileQueue HSPFILEQ } + { ClassInstallReserved ULONG_PTR } + { Reserved DWORD } + { DriverPath WCHAR[MAX_PATH] } ; +TYPEDEF: SP_DEVINSTALL_PARAMS_W* PSP_DEVINSTALL_PARAMS_W +TYPEDEF: SP_DEVINSTALL_PARAMS_W SP_DEVINSTALL_PARAMS +TYPEDEF: PSP_DEVINSTALL_PARAMS_W PSP_DEVINSTALL_PARAMS + +CONSTANT: DI_SHOWOEM HEX: 00000001 +CONSTANT: DI_SHOWCOMPAT HEX: 00000002 +CONSTANT: DI_SHOWCLASS HEX: 00000004 +CONSTANT: DI_SHOWALL HEX: 00000007 +CONSTANT: DI_NOVCP HEX: 00000008 +CONSTANT: DI_DIDCOMPAT HEX: 00000010 +CONSTANT: DI_DIDCLASS HEX: 00000020 +CONSTANT: DI_AUTOASSIGNRES HEX: 00000040 +CONSTANT: DI_NEEDRESTART HEX: 00000080 +CONSTANT: DI_NEEDREBOOT HEX: 00000100 +CONSTANT: DI_NOBROWSE HEX: 00000200 +CONSTANT: DI_MULTMFGS HEX: 00000400 +CONSTANT: DI_DISABLED HEX: 00000800 +CONSTANT: DI_GENERALPAGE_ADDED HEX: 00001000 +CONSTANT: DI_RESOURCEPAGE_ADDED HEX: 00002000 +CONSTANT: DI_PROPERTIES_CHANGE HEX: 00004000 +CONSTANT: DI_INF_IS_SORTED HEX: 00008000 +CONSTANT: DI_ENUMSINGLEINF HEX: 00010000 +CONSTANT: DI_DONOTCALLCONFIGMG HEX: 00020000 +CONSTANT: DI_INSTALLDISABLED HEX: 00040000 +CONSTANT: DI_COMPAT_FROM_CLASS HEX: 00080000 +CONSTANT: DI_CLASSINSTALLPARAMS HEX: 00100000 +CONSTANT: DI_NODI_DEFAULTACTION HEX: 00200000 +CONSTANT: DI_QUIETINSTALL HEX: 00800000 +CONSTANT: DI_NOFILECOPY HEX: 01000000 +CONSTANT: DI_FORCECOPY HEX: 02000000 +CONSTANT: DI_DRIVERPAGE_ADDED HEX: 04000000 +CONSTANT: DI_USECI_SELECTSTRINGS HEX: 08000000 +CONSTANT: DI_OVERRIDE_INFFLAGS HEX: 10000000 +CONSTANT: DI_PROPS_NOCHANGEUSAGE HEX: 20000000 +CONSTANT: DI_NOSELECTICONS HEX: 40000000 +CONSTANT: DI_NOWRITE_IDS HEX: 80000000 +CONSTANT: DI_FLAGSEX_RESERVED2 HEX: 00000001 +CONSTANT: DI_FLAGSEX_RESERVED3 HEX: 00000002 +CONSTANT: DI_FLAGSEX_CI_FAILED HEX: 00000004 +CONSTANT: DI_FLAGSEX_FINISHINSTALL_ACTION HEX: 00000008 +CONSTANT: DI_FLAGSEX_DIDINFOLIST HEX: 00000010 +CONSTANT: DI_FLAGSEX_DIDCOMPATINFO HEX: 00000020 +CONSTANT: DI_FLAGSEX_FILTERCLASSES HEX: 00000040 +CONSTANT: DI_FLAGSEX_SETFAILEDINSTALL HEX: 00000080 +CONSTANT: DI_FLAGSEX_DEVICECHANGE HEX: 00000100 +CONSTANT: DI_FLAGSEX_ALWAYSWRITEIDS HEX: 00000200 +CONSTANT: DI_FLAGSEX_PROPCHANGE_PENDING HEX: 00000400 +CONSTANT: DI_FLAGSEX_ALLOWEXCLUDEDDRVS HEX: 00000800 +CONSTANT: DI_FLAGSEX_NOUIONQUERYREMOVE HEX: 00001000 +CONSTANT: DI_FLAGSEX_USECLASSFORCOMPAT HEX: 00002000 +CONSTANT: DI_FLAGSEX_RESERVED4 HEX: 00004000 +CONSTANT: DI_FLAGSEX_NO_DRVREG_MODIFY HEX: 00008000 +CONSTANT: DI_FLAGSEX_IN_SYSTEM_SETUP HEX: 00010000 +CONSTANT: DI_FLAGSEX_INET_DRIVER HEX: 00020000 +CONSTANT: DI_FLAGSEX_APPENDDRIVERLIST HEX: 00040000 +CONSTANT: DI_FLAGSEX_PREINSTALLBACKUP HEX: 00080000 +CONSTANT: DI_FLAGSEX_BACKUPONREPLACE HEX: 00100000 +CONSTANT: DI_FLAGSEX_DRIVERLIST_FROM_URL HEX: 00200000 +CONSTANT: DI_FLAGSEX_RESERVED1 HEX: 00400000 +CONSTANT: DI_FLAGSEX_EXCLUDE_OLD_INET_DRIVERS HEX: 00800000 +CONSTANT: DI_FLAGSEX_POWERPAGE_ADDED HEX: 01000000 +CONSTANT: DI_FLAGSEX_FILTERSIMILARDRIVERS HEX: 02000000 +CONSTANT: DI_FLAGSEX_INSTALLEDDRIVER HEX: 04000000 +CONSTANT: DI_FLAGSEX_NO_CLASSLIST_NODE_MERGE HEX: 08000000 +CONSTANT: DI_FLAGSEX_ALTPLATFORM_DRVSEARCH HEX: 10000000 +CONSTANT: DI_FLAGSEX_RESTART_DEVICE_ONLY HEX: 20000000 +CONSTANT: DI_FLAGSEX_RECURSIVESEARCH HEX: 40000000 +CONSTANT: DI_FLAGSEX_SEARCH_PUBLISHED_INFS HEX: 80000000 + +STRUCT: SP_CLASSINSTALL_HEADER + { cbSize DWORD } + { InstallFunction DI_FUNCTION } ; +TYPEDEF: SP_CLASSINSTALL_HEADER* PSP_CLASSINSTALL_HEADER + +STRUCT: SP_ENABLECLASS_PARAMS + { ClassInstallHeader SP_CLASSINSTALL_HEADER } + { ClassGuid GUID } + { EnableMessage DWORD } ; +TYPEDEF: SP_ENABLECLASS_PARAMS* PSP_ENABLECLASS_PARAMS + +CONSTANT: ENABLECLASS_QUERY 0 +CONSTANT: ENABLECLASS_SUCCESS 1 +CONSTANT: ENABLECLASS_FAILURE 2 +CONSTANT: DICS_ENABLE HEX: 00000001 +CONSTANT: DICS_DISABLE HEX: 00000002 +CONSTANT: DICS_PROPCHANGE HEX: 00000003 +CONSTANT: DICS_START HEX: 00000004 +CONSTANT: DICS_STOP HEX: 00000005 +CONSTANT: DICS_FLAG_GLOBAL HEX: 00000001 +CONSTANT: DICS_FLAG_CONFIGSPECIFIC HEX: 00000002 +CONSTANT: DICS_FLAG_CONFIGGENERAL HEX: 00000004 + +STRUCT: SP_PROPCHANGE_PARAMS + { ClassInstallHeader SP_CLASSINSTALL_HEADER } + { StateChange DWORD } + { Scope DWORD } + { HwProfile DWORD } ; +TYPEDEF: SP_PROPCHANGE_PARAMS* PSP_PROPCHANGE_PARAMS + +STRUCT: SP_REMOVEDEVICE_PARAMS + { ClassInstallHeader SP_CLASSINSTALL_HEADER } + { Scope DWORD } + { HwProfile DWORD } ; +TYPEDEF: SP_REMOVEDEVICE_PARAMS* PSP_REMOVEDEVICE_PARAMS + +CONSTANT: DI_REMOVEDEVICE_GLOBAL HEX: 00000001 +CONSTANT: DI_REMOVEDEVICE_CONFIGSPECIFIC HEX: 00000002 + +STRUCT: SP_UNREMOVEDEVICE_PARAMS + { ClassInstallHeader SP_CLASSINSTALL_HEADER } + { Scope DWORD } + { HwProfile DWORD } ; +TYPEDEF: SP_UNREMOVEDEVICE_PARAMS* PSP_UNREMOVEDEVICE_PARAMS + +CONSTANT: DI_UNREMOVEDEVICE_CONFIGSPECIFIC HEX: 00000002 + +STRUCT: SP_SELECTDEVICE_PARAMS_A + { ClassInstallHeader SP_CLASSINSTALL_HEADER } + { Title CHAR[MAX_TITLE_LEN] } + { Instructions CHAR[MAX_INSTRUCTION_LEN] } + { ListLabel CHAR[MAX_LABEL_LEN] } + { SubTitle CHAR[MAX_SUBTITLE_LEN] } + { Reserved BYTE[2] } ; +TYPEDEF: SP_SELECTDEVICE_PARAMS_A* PSP_SELECTDEVICE_PARAMS_A +STRUCT: SP_SELECTDEVICE_PARAMS_W + { ClassInstallHeader SP_CLASSINSTALL_HEADER } + { Title WCHAR[MAX_TITLE_LEN] } + { Instructions WCHAR[MAX_INSTRUCTION_LEN] } + { ListLabel WCHAR[MAX_LABEL_LEN] } + { SubTitle WCHAR[MAX_SUBTITLE_LEN] } ; +TYPEDEF: SP_SELECTDEVICE_PARAMS_W* PSP_SELECTDEVICE_PARAMS_W +TYPEDEF: SP_SELECTDEVICE_PARAMS_W SP_SELECTDEVICE_PARAMS +TYPEDEF: PSP_SELECTDEVICE_PARAMS_W PSP_SELECTDEVICE_PARAMS + +CALLBACK: BOOL PDETECT_PROGRESS_NOTIFY ( PVOID ProgressNotifyParam, DWORD DetectComplete ) ; + +STRUCT: SP_DETECTDEVICE_PARAMS + { ClassInstallHeader SP_CLASSINSTALL_HEADER } + { DetectProgressNotify PDETECT_PROGRESS_NOTIFY } + { ProgressNotifyParam PVOID } ; +TYPEDEF: SP_DETECTDEVICE_PARAMS* PSP_DETECTDEVICE_PARAMS + +CONSTANT: MAX_INSTALLWIZARD_DYNAPAGES 20 + +STRUCT: SP_INSTALLWIZARD_DATA + { ClassInstallHeader SP_CLASSINSTALL_HEADER } + { Flags DWORD } + { DynamicPages HPROPSHEETPAGE[MAX_INSTALLWIZARD_DYNAPAGES] } + { NumDynamicPages DWORD } + { DynamicPageFlags DWORD } + { PrivateFlags DWORD } + { PrivateData LPARAM } + { hwndWizardDlg HWND } ; +TYPEDEF: SP_INSTALLWIZARD_DATA* PSP_INSTALLWIZARD_DATA + +CONSTANT: NDW_INSTALLFLAG_DIDFACTDEFS HEX: 00000001 +CONSTANT: NDW_INSTALLFLAG_HARDWAREALLREADYIN HEX: 00000002 +CONSTANT: NDW_INSTALLFLAG_NEEDRESTART $ DI_NEEDRESTART +CONSTANT: NDW_INSTALLFLAG_NEEDREBOOT $ DI_NEEDREBOOT +CONSTANT: NDW_INSTALLFLAG_NEEDSHUTDOWN HEX: 00000200 +CONSTANT: NDW_INSTALLFLAG_EXPRESSINTRO HEX: 00000400 +CONSTANT: NDW_INSTALLFLAG_SKIPISDEVINSTALLED HEX: 00000800 +CONSTANT: NDW_INSTALLFLAG_NODETECTEDDEVS HEX: 00001000 +CONSTANT: NDW_INSTALLFLAG_INSTALLSPECIFIC HEX: 00002000 +CONSTANT: NDW_INSTALLFLAG_SKIPCLASSLIST HEX: 00004000 +CONSTANT: NDW_INSTALLFLAG_CI_PICKED_OEM HEX: 00008000 +CONSTANT: NDW_INSTALLFLAG_PCMCIAMODE HEX: 00010000 +CONSTANT: NDW_INSTALLFLAG_PCMCIADEVICE HEX: 00020000 +CONSTANT: NDW_INSTALLFLAG_USERCANCEL HEX: 00040000 +CONSTANT: NDW_INSTALLFLAG_KNOWNCLASS HEX: 00080000 +CONSTANT: DYNAWIZ_FLAG_PAGESADDED HEX: 00000001 +CONSTANT: DYNAWIZ_FLAG_ANALYZE_HANDLECONFLICT HEX: 00000008 +CONSTANT: DYNAWIZ_FLAG_INSTALLDET_NEXT HEX: 00000002 +CONSTANT: DYNAWIZ_FLAG_INSTALLDET_PREV HEX: 00000004 +CONSTANT: MIN_IDD_DYNAWIZ_RESOURCE_ID 10000 +CONSTANT: MAX_IDD_DYNAWIZ_RESOURCE_ID 11000 +CONSTANT: IDD_DYNAWIZ_FIRSTPAGE 10000 +CONSTANT: IDD_DYNAWIZ_SELECT_PREVPAGE 10001 +CONSTANT: IDD_DYNAWIZ_SELECT_NEXTPAGE 10002 +CONSTANT: IDD_DYNAWIZ_ANALYZE_PREVPAGE 10003 +CONSTANT: IDD_DYNAWIZ_ANALYZE_NEXTPAGE 10004 +CONSTANT: IDD_DYNAWIZ_SELECTDEV_PAGE 10009 +CONSTANT: IDD_DYNAWIZ_ANALYZEDEV_PAGE 10010 +CONSTANT: IDD_DYNAWIZ_INSTALLDETECTEDDEVS_PAGE 10011 +CONSTANT: IDD_DYNAWIZ_SELECTCLASS_PAGE 10012 +CONSTANT: IDD_DYNAWIZ_INSTALLDETECTED_PREVPAGE 10006 +CONSTANT: IDD_DYNAWIZ_INSTALLDETECTED_NEXTPAGE 10007 +CONSTANT: IDD_DYNAWIZ_INSTALLDETECTED_NODEVS 10008 + +STRUCT: SP_NEWDEVICEWIZARD_DATA + { ClassInstallHeader SP_CLASSINSTALL_HEADER } + { Flags DWORD } + { DynamicPages HPROPSHEETPAGE[MAX_INSTALLWIZARD_DYNAPAGES] } + { NumDynamicPages DWORD } + { hwndWizardDlg HWND } ; +TYPEDEF: SP_NEWDEVICEWIZARD_DATA* PSP_NEWDEVICEWIZARD_DATA +TYPEDEF: SP_NEWDEVICEWIZARD_DATA SP_ADDPROPERTYPAGE_DATA +TYPEDEF: PSP_NEWDEVICEWIZARD_DATA PSP_ADDPROPERTYPAGE_DATA + +STRUCT: SP_TROUBLESHOOTER_PARAMS_A + { ClassInstallHeader SP_CLASSINSTALL_HEADER } + { ChmFile CHAR[MAX_PATH] } + { HtmlTroubleShooter CHAR[MAX_PATH] } ; +TYPEDEF: SP_TROUBLESHOOTER_PARAMS_A* PSP_TROUBLESHOOTER_PARAMS_A +STRUCT: SP_TROUBLESHOOTER_PARAMS_W + { ClassInstallHeader SP_CLASSINSTALL_HEADER } + { ChmFile WCHAR[MAX_PATH] } + { HtmlTroubleShooter WCHAR[MAX_PATH] } ; +TYPEDEF: SP_TROUBLESHOOTER_PARAMS_W* PSP_TROUBLESHOOTER_PARAMS_W +TYPEDEF: SP_TROUBLESHOOTER_PARAMS_W SP_TROUBLESHOOTER_PARAMS +TYPEDEF: PSP_TROUBLESHOOTER_PARAMS_W PSP_TROUBLESHOOTER_PARAMS + +STRUCT: SP_POWERMESSAGEWAKE_PARAMS_A + { ClassInstallHeader SP_CLASSINSTALL_HEADER } + { PowerMessageWake CHAR[LINE_LEN*2] } ; +TYPEDEF: SP_POWERMESSAGEWAKE_PARAMS_A* PSP_POWERMESSAGEWAKE_PARAMS_A +STRUCT: SP_POWERMESSAGEWAKE_PARAMS_W + { ClassInstallHeader SP_CLASSINSTALL_HEADER } + { PowerMessageWake WCHAR[LINE_LEN*2] } ; +TYPEDEF: SP_POWERMESSAGEWAKE_PARAMS_W* PSP_POWERMESSAGEWAKE_PARAMS_W +TYPEDEF: SP_POWERMESSAGEWAKE_PARAMS_W SP_POWERMESSAGEWAKE_PARAMS +TYPEDEF: PSP_POWERMESSAGEWAKE_PARAMS_W PSP_POWERMESSAGEWAKE_PARAMS + +STRUCT: SP_DRVINFO_DATA_V2_A + { cbSize DWORD } + { DriverType DWORD } + { Reserved ULONG_PTR } + { Description CHAR[LINE_LEN] } + { MfgName CHAR[LINE_LEN] } + { ProviderName CHAR[LINE_LEN] } + { DriverDate FILETIME } + { DriverVersion DWORDLONG } ; +TYPEDEF: SP_DRVINFO_DATA_V2_A* PSP_DRVINFO_DATA_V2_A +STRUCT: SP_DRVINFO_DATA_V2_W + { cbSize DWORD } + { DriverType DWORD } + { Reserved ULONG_PTR } + { Description WCHAR[LINE_LEN] } + { MfgName WCHAR[LINE_LEN] } + { ProviderName WCHAR[LINE_LEN] } + { DriverDate FILETIME } + { DriverVersion DWORDLONG } ; +TYPEDEF: SP_DRVINFO_DATA_V2_W* PSP_DRVINFO_DATA_V2_W +STRUCT: SP_DRVINFO_DATA_V1_A + { cbSize DWORD } + { DriverType DWORD } + { Reserved ULONG_PTR } + { Description CHAR[LINE_LEN] } + { MfgName CHAR[LINE_LEN] } + { ProviderName CHAR[LINE_LEN] } ; +TYPEDEF: SP_DRVINFO_DATA_V1_A* PSP_DRVINFO_DATA_V1_A +STRUCT: SP_DRVINFO_DATA_V1_W + { cbSize DWORD } + { DriverType DWORD } + { Reserved ULONG_PTR } + { Description WCHAR[LINE_LEN] } + { MfgName WCHAR[LINE_LEN] } + { ProviderName WCHAR[LINE_LEN] } ; +TYPEDEF: SP_DRVINFO_DATA_V1_W* PSP_DRVINFO_DATA_V1_W +TYPEDEF: SP_DRVINFO_DATA_V1_W SP_DRVINFO_DATA_V1 +TYPEDEF: PSP_DRVINFO_DATA_V1_W PSP_DRVINFO_DATA_V1 +TYPEDEF: SP_DRVINFO_DATA_V2_W SP_DRVINFO_DATA_V2 +TYPEDEF: PSP_DRVINFO_DATA_V2_W PSP_DRVINFO_DATA_V2 +TYPEDEF: SP_DRVINFO_DATA_V2_A SP_DRVINFO_DATA_A +TYPEDEF: PSP_DRVINFO_DATA_V2_A PSP_DRVINFO_DATA_A +TYPEDEF: SP_DRVINFO_DATA_V2_W SP_DRVINFO_DATA_W +TYPEDEF: PSP_DRVINFO_DATA_V2_W PSP_DRVINFO_DATA_W +TYPEDEF: SP_DRVINFO_DATA_V2 SP_DRVINFO_DATA +TYPEDEF: PSP_DRVINFO_DATA_V2 PSP_DRVINFO_DATA + +STRUCT: SP_DRVINFO_DETAIL_DATA_A + { cbSize DWORD } + { InfDate FILETIME } + { CompatIDsOffset DWORD } + { CompatIDsLength DWORD } + { Reserved ULONG_PTR } + { SectionName CHAR[LINE_LEN] } + { InfFileName CHAR[MAX_PATH] } + { DrvDescription CHAR[LINE_LEN] } + { HardwareID CHAR[ANYSIZE_ARRAY] } ; +TYPEDEF: SP_DRVINFO_DETAIL_DATA_A* PSP_DRVINFO_DETAIL_DATA_A +STRUCT: SP_DRVINFO_DETAIL_DATA_W + { cbSize DWORD } + { InfDate FILETIME } + { CompatIDsOffset DWORD } + { CompatIDsLength DWORD } + { Reserved ULONG_PTR } + { SectionName WCHAR[LINE_LEN] } + { InfFileName WCHAR[MAX_PATH] } + { DrvDescription WCHAR[LINE_LEN] } + { HardwareID WCHAR[ANYSIZE_ARRAY] } ; +TYPEDEF: SP_DRVINFO_DETAIL_DATA_W* PSP_DRVINFO_DETAIL_DATA_W + +TYPEDEF: SP_DRVINFO_DETAIL_DATA_W SP_DRVINFO_DETAIL_DATA +TYPEDEF: PSP_DRVINFO_DETAIL_DATA_W PSP_DRVINFO_DETAIL_DATA + +STRUCT: SP_DRVINSTALL_PARAMS + { cbSize DWORD } + { Rank DWORD } + { Flags DWORD } + { PrivateData DWORD_PTR } + { Reserved DWORD } ; +TYPEDEF: SP_DRVINSTALL_PARAMS* PSP_DRVINSTALL_PARAMS + +CONSTANT: DNF_DUPDESC HEX: 00000001 +CONSTANT: DNF_OLDDRIVER HEX: 00000002 +CONSTANT: DNF_EXCLUDEFROMLIST HEX: 00000004 +CONSTANT: DNF_NODRIVER HEX: 00000008 +CONSTANT: DNF_LEGACYINF HEX: 00000010 +CONSTANT: DNF_CLASS_DRIVER HEX: 00000020 +CONSTANT: DNF_COMPATIBLE_DRIVER HEX: 00000040 +CONSTANT: DNF_INET_DRIVER HEX: 00000080 +CONSTANT: DNF_UNUSED1 HEX: 00000100 +CONSTANT: DNF_UNUSED2 HEX: 00000200 +CONSTANT: DNF_OLD_INET_DRIVER HEX: 00000400 +CONSTANT: DNF_BAD_DRIVER HEX: 00000800 +CONSTANT: DNF_DUPPROVIDER HEX: 00001000 +CONSTANT: DNF_INF_IS_SIGNED HEX: 00002000 +CONSTANT: DNF_OEM_F6_INF HEX: 00004000 +CONSTANT: DNF_DUPDRIVERVER HEX: 00008000 +CONSTANT: DNF_BASIC_DRIVER HEX: 00010000 +CONSTANT: DNF_AUTHENTICODE_SIGNED HEX: 00020000 +CONSTANT: DNF_INSTALLEDDRIVER HEX: 00040000 +CONSTANT: DNF_ALWAYSEXCLUDEFROMLIST HEX: 00080000 +CONSTANT: DNF_INBOX_DRIVER HEX: 00100000 +CONSTANT: DNF_REQUESTADDITIONALSOFTWARE HEX: 00200000 +CONSTANT: DNF_UNUSED_22 HEX: 00400000 +CONSTANT: DNF_UNUSED_23 HEX: 00800000 +CONSTANT: DNF_UNUSED_24 HEX: 01000000 +CONSTANT: DNF_UNUSED_25 HEX: 02000000 +CONSTANT: DNF_UNUSED_26 HEX: 04000000 +CONSTANT: DNF_UNUSED_27 HEX: 08000000 +CONSTANT: DNF_UNUSED_28 HEX: 10000000 +CONSTANT: DNF_UNUSED_29 HEX: 20000000 +CONSTANT: DNF_UNUSED_30 HEX: 40000000 +CONSTANT: DNF_UNUSED_31 HEX: 80000000 +CONSTANT: DRIVER_HARDWAREID_RANK HEX: 00000FFF +CONSTANT: DRIVER_HARDWAREID_MASK HEX: 80000FFF +CONSTANT: DRIVER_UNTRUSTED_RANK HEX: 80000000 +CONSTANT: DRIVER_W9X_SUSPECT_RANK HEX: C0000000 + +CALLBACK: DWORD PSP_DETSIG_CMPPROC ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA NewDeviceData, PSP_DEVINFO_DATA ExistingDeviceData, PVOID CompareContext ) ; + +STRUCT: COINSTALLER_CONTEXT_DATA + { PostProcessing BOOL } + { InstallResult DWORD } + { PrivateData PVOID } ; +TYPEDEF: COINSTALLER_CONTEXT_DATA* PCOINSTALLER_CONTEXT_DATA + +STRUCT: SP_CLASSIMAGELIST_DATA + { cbSize DWORD } + { ImageList HIMAGELIST } + { Reserved ULONG_PTR } ; +TYPEDEF: SP_CLASSIMAGELIST_DATA* PSP_CLASSIMAGELIST_DATA + +STRUCT: SP_PROPSHEETPAGE_REQUEST + { cbSize DWORD } + { PageRequested DWORD } + { DeviceInfoSet HDEVINFO } + { DeviceInfoData PSP_DEVINFO_DATA } ; +TYPEDEF: SP_PROPSHEETPAGE_REQUEST* PSP_PROPSHEETPAGE_REQUEST + +CONSTANT: SPPSR_SELECT_DEVICE_RESOURCES 1 +CONSTANT: SPPSR_ENUM_BASIC_DEVICE_PROPERTIES 2 +CONSTANT: SPPSR_ENUM_ADV_DEVICE_PROPERTIES 3 + +STRUCT: SP_BACKUP_QUEUE_PARAMS_V2_A + { cbSize DWORD } + { FullInfPath CHAR[MAX_PATH] } + { FilenameOffset INT } + { ReinstallInstance CHAR[MAX_PATH] } ; +TYPEDEF: SP_BACKUP_QUEUE_PARAMS_V2_A* PSP_BACKUP_QUEUE_PARAMS_V2_A + +STRUCT: SP_BACKUP_QUEUE_PARAMS_V2_W + { cbSize DWORD } + { FullInfPath WCHAR[MAX_PATH] } + { FilenameOffset INT } + { ReinstallInstance WCHAR[MAX_PATH] } ; +TYPEDEF: SP_BACKUP_QUEUE_PARAMS_V2_W* PSP_BACKUP_QUEUE_PARAMS_V2_W + +STRUCT: SP_BACKUP_QUEUE_PARAMS_V1_A + { cbSize DWORD } + { FullInfPath CHAR[MAX_PATH] } + { FilenameOffset INT } ; +TYPEDEF: SP_BACKUP_QUEUE_PARAMS_V1_A* PSP_BACKUP_QUEUE_PARAMS_V1_A + +STRUCT: SP_BACKUP_QUEUE_PARAMS_V1_W + { cbSize DWORD } + { FullInfPath WCHAR[MAX_PATH] } + { FilenameOffset INT } ; +TYPEDEF: SP_BACKUP_QUEUE_PARAMS_V1_W* PSP_BACKUP_QUEUE_PARAMS_V1_W + +TYPEDEF: SP_BACKUP_QUEUE_PARAMS_V1_W SP_BACKUP_QUEUE_PARAMS_V1 +TYPEDEF: PSP_BACKUP_QUEUE_PARAMS_V1_W PSP_BACKUP_QUEUE_PARAMS_V1 +TYPEDEF: SP_BACKUP_QUEUE_PARAMS_V2_W SP_BACKUP_QUEUE_PARAMS_V2 +TYPEDEF: PSP_BACKUP_QUEUE_PARAMS_V2_W PSP_BACKUP_QUEUE_PARAMS_V2 +TYPEDEF: SP_BACKUP_QUEUE_PARAMS_V2_A SP_BACKUP_QUEUE_PARAMS_A +TYPEDEF: PSP_BACKUP_QUEUE_PARAMS_V2_A PSP_BACKUP_QUEUE_PARAMS_A +TYPEDEF: SP_BACKUP_QUEUE_PARAMS_V2_W SP_BACKUP_QUEUE_PARAMS_W +TYPEDEF: PSP_BACKUP_QUEUE_PARAMS_V2_W PSP_BACKUP_QUEUE_PARAMS_W +TYPEDEF: SP_BACKUP_QUEUE_PARAMS_V2 SP_BACKUP_QUEUE_PARAMS +TYPEDEF: PSP_BACKUP_QUEUE_PARAMS_V2 PSP_BACKUP_QUEUE_PARAMS + +CONSTANT: ERROR_EXPECTED_SECTION_NAME $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR 0 bitor bitor ] +CONSTANT: ERROR_BAD_SECTION_NAME_LINE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR 1 bitor bitor ] +CONSTANT: ERROR_SECTION_NAME_TOO_LONG $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR 2 bitor bitor ] +CONSTANT: ERROR_GENERAL_SYNTAX $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR 3 bitor bitor ] +CONSTANT: ERROR_WRONG_INF_STYLE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 100 bitor bitor ] +CONSTANT: ERROR_SECTION_NOT_FOUND $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 101 bitor bitor ] +CONSTANT: ERROR_LINE_NOT_FOUND $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 102 bitor bitor ] +CONSTANT: ERROR_NO_BACKUP $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 103 bitor bitor ] +CONSTANT: ERROR_NO_ASSOCIATED_CLASS $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 200 bitor bitor ] +CONSTANT: ERROR_CLASS_MISMATCH $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 201 bitor bitor ] +CONSTANT: ERROR_DUPLICATE_FOUND $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 202 bitor bitor ] +CONSTANT: ERROR_NO_DRIVER_SELECTED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 203 bitor bitor ] +CONSTANT: ERROR_KEY_DOES_NOT_EXIST $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 204 bitor bitor ] +CONSTANT: ERROR_INVALID_DEVINST_NAME $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 205 bitor bitor ] +CONSTANT: ERROR_INVALID_CLASS $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 206 bitor bitor ] +CONSTANT: ERROR_DEVINST_ALREADY_EXISTS $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 207 bitor bitor ] +CONSTANT: ERROR_DEVINFO_NOT_REGISTERED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 208 bitor bitor ] +CONSTANT: ERROR_INVALID_REG_PROPERTY $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 209 bitor bitor ] +CONSTANT: ERROR_NO_INF $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 20A bitor bitor ] +CONSTANT: ERROR_NO_SUCH_DEVINST $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 20B bitor bitor ] +CONSTANT: ERROR_CANT_LOAD_CLASS_ICON $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 20C bitor bitor ] +CONSTANT: ERROR_INVALID_CLASS_INSTALLER $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 20D bitor bitor ] +CONSTANT: ERROR_DI_DO_DEFAULT $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 20E bitor bitor ] +CONSTANT: ERROR_DI_NOFILECOPY $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 20F bitor bitor ] +CONSTANT: ERROR_INVALID_HWPROFILE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 210 bitor bitor ] +CONSTANT: ERROR_NO_DEVICE_SELECTED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 211 bitor bitor ] +CONSTANT: ERROR_DEVINFO_LIST_LOCKED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 212 bitor bitor ] +CONSTANT: ERROR_DEVINFO_DATA_LOCKED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 213 bitor bitor ] +CONSTANT: ERROR_DI_BAD_PATH $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 214 bitor bitor ] +CONSTANT: ERROR_NO_CLASSINSTALL_PARAMS $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 215 bitor bitor ] +CONSTANT: ERROR_FILEQUEUE_LOCKED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 216 bitor bitor ] +CONSTANT: ERROR_BAD_SERVICE_INSTALLSECT $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 217 bitor bitor ] +CONSTANT: ERROR_NO_CLASS_DRIVER_LIST $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 218 bitor bitor ] +CONSTANT: ERROR_NO_ASSOCIATED_SERVICE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 219 bitor bitor ] +CONSTANT: ERROR_NO_DEFAULT_DEVICE_INTERFACE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 21A bitor bitor ] +CONSTANT: ERROR_DEVICE_INTERFACE_ACTIVE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 21B bitor bitor ] +CONSTANT: ERROR_DEVICE_INTERFACE_REMOVED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 21C bitor bitor ] +CONSTANT: ERROR_BAD_INTERFACE_INSTALLSECT $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 21D bitor bitor ] +CONSTANT: ERROR_NO_SUCH_INTERFACE_CLASS $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 21E bitor bitor ] +CONSTANT: ERROR_INVALID_REFERENCE_STRING $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 21F bitor bitor ] +CONSTANT: ERROR_INVALID_MACHINENAME $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 220 bitor bitor ] +CONSTANT: ERROR_REMOTE_COMM_FAILURE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 221 bitor bitor ] +CONSTANT: ERROR_MACHINE_UNAVAILABLE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 222 bitor bitor ] +CONSTANT: ERROR_NO_CONFIGMGR_SERVICES $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 223 bitor bitor ] +CONSTANT: ERROR_INVALID_PROPPAGE_PROVIDER $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 224 bitor bitor ] +CONSTANT: ERROR_NO_SUCH_DEVICE_INTERFACE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 225 bitor bitor ] +CONSTANT: ERROR_DI_POSTPROCESSING_REQUIRED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 226 bitor bitor ] +CONSTANT: ERROR_INVALID_COINSTALLER $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 227 bitor bitor ] +CONSTANT: ERROR_NO_COMPAT_DRIVERS $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 228 bitor bitor ] +CONSTANT: ERROR_NO_DEVICE_ICON $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 229 bitor bitor ] +CONSTANT: ERROR_INVALID_INF_LOGCONFIG $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 22A bitor bitor ] +CONSTANT: ERROR_DI_DONT_INSTALL $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 22B bitor bitor ] +CONSTANT: ERROR_INVALID_FILTER_DRIVER $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 22C bitor bitor ] +CONSTANT: ERROR_NON_WINDOWS_NT_DRIVER $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 22D bitor bitor ] +CONSTANT: ERROR_NON_WINDOWS_DRIVER $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 22E bitor bitor ] +CONSTANT: ERROR_NO_CATALOG_FOR_OEM_INF $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 22F bitor bitor ] +CONSTANT: ERROR_DEVINSTALL_QUEUE_NONNATIVE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 230 bitor bitor ] +CONSTANT: ERROR_NOT_DISABLEABLE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 231 bitor bitor ] +CONSTANT: ERROR_CANT_REMOVE_DEVINST $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 232 bitor bitor ] +CONSTANT: ERROR_INVALID_TARGET $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 233 bitor bitor ] +CONSTANT: ERROR_DRIVER_NONNATIVE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 234 bitor bitor ] +CONSTANT: ERROR_IN_WOW64 $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 235 bitor bitor ] +CONSTANT: ERROR_SET_SYSTEM_RESTORE_POINT $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 236 bitor bitor ] +CONSTANT: ERROR_SCE_DISABLED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 238 bitor bitor ] +CONSTANT: ERROR_UNKNOWN_EXCEPTION $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 239 bitor bitor ] +CONSTANT: ERROR_PNP_REGISTRY_ERROR $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 23A bitor bitor ] +CONSTANT: ERROR_REMOTE_REQUEST_UNSUPPORTED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 23B bitor bitor ] +CONSTANT: ERROR_NOT_AN_INSTALLED_OEM_INF $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 23C bitor bitor ] +CONSTANT: ERROR_INF_IN_USE_BY_DEVICES $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 23D bitor bitor ] +CONSTANT: ERROR_DI_FUNCTION_OBSOLETE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 23E bitor bitor ] +CONSTANT: ERROR_NO_AUTHENTICODE_CATALOG $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 23F bitor bitor ] +CONSTANT: ERROR_AUTHENTICODE_DISALLOWED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 240 bitor bitor ] +CONSTANT: ERROR_AUTHENTICODE_TRUSTED_PUBLISHER $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 241 bitor bitor ] +CONSTANT: ERROR_AUTHENTICODE_TRUST_NOT_ESTABLISHED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 242 bitor bitor ] +CONSTANT: ERROR_AUTHENTICODE_PUBLISHER_NOT_TRUSTED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 243 bitor bitor ] +CONSTANT: ERROR_SIGNATURE_OSATTRIBUTE_MISMATCH $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 244 bitor bitor ] +CONSTANT: ERROR_ONLY_VALIDATE_VIA_AUTHENTICODE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 245 bitor bitor ] +CONSTANT: ERROR_DEVICE_INSTALLER_NOT_READY $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 246 bitor bitor ] +CONSTANT: ERROR_DRIVER_STORE_ADD_FAILED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 247 bitor bitor ] +CONSTANT: ERROR_DEVICE_INSTALL_BLOCKED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 248 bitor bitor ] +CONSTANT: ERROR_DRIVER_INSTALL_BLOCKED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 249 bitor bitor ] +CONSTANT: ERROR_WRONG_INF_TYPE $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 24A bitor bitor ] +CONSTANT: ERROR_FILE_HASH_NOT_IN_CATALOG $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 24B bitor bitor ] +CONSTANT: ERROR_DRIVER_STORE_DELETE_FAILED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 24C bitor bitor ] +CONSTANT: ERROR_UNRECOVERABLE_STACK_OVERFLOW $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 300 bitor bitor ] +CONSTANT: EXCEPTION_SPAPI_UNRECOVERABLE_STACK_OVERFLOW $ ERROR_UNRECOVERABLE_STACK_OVERFLOW +CONSTANT: ERROR_NO_DEFAULT_INTERFACE_DEVICE $ ERROR_NO_DEFAULT_DEVICE_INTERFACE +CONSTANT: ERROR_INTERFACE_DEVICE_ACTIVE $ ERROR_DEVICE_INTERFACE_ACTIVE +CONSTANT: ERROR_INTERFACE_DEVICE_REMOVED $ ERROR_DEVICE_INTERFACE_REMOVED +CONSTANT: ERROR_NO_SUCH_INTERFACE_DEVICE $ ERROR_NO_SUCH_DEVICE_INTERFACE +CONSTANT: ERROR_NOT_INSTALLED $[ APPLICATION_ERROR_MASK ERROR_SEVERITY_ERROR HEX: 1000 bitor bitor ] + +FUNCTION: BOOL SetupGetInfInformationA ( LPCVOID InfSpec, DWORD SearchControl, PSP_INF_INFORMATION ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupGetInfInformationW ( LPCVOID InfSpec, DWORD SearchControl, PSP_INF_INFORMATION ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +CONSTANT: INFINFO_INF_SPEC_IS_HINF 1 +CONSTANT: INFINFO_INF_NAME_IS_ABSOLUTE 2 +CONSTANT: INFINFO_DEFAULT_SEARCH 3 +CONSTANT: INFINFO_REVERSE_DEFAULT_SEARCH 4 +CONSTANT: INFINFO_INF_PATH_LIST_SEARCH 5 +ALIAS: SetupGetInfInformation SetupGetInfInformationW + +FUNCTION: BOOL SetupQueryInfFileInformationA ( PSP_INF_INFORMATION InfInformation, UINT InfIndex, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupQueryInfFileInformationW ( PSP_INF_INFORMATION InfInformation, UINT InfIndex, PWSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +ALIAS: SetupQueryInfFileInformation SetupQueryInfFileInformationW + +FUNCTION: BOOL SetupQueryInfOriginalFileInformationA ( PSP_INF_INFORMATION InfInformation, UINT InfIndex, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PSP_ORIGINAL_FILE_INFO_A OriginalFileInfo ) ; +FUNCTION: BOOL SetupQueryInfOriginalFileInformationW ( PSP_INF_INFORMATION InfInformation, UINT InfIndex, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PSP_ORIGINAL_FILE_INFO_W OriginalFileInfo ) ; +ALIAS: SetupQueryInfOriginalFileInformation SetupQueryInfOriginalFileInformationW + +FUNCTION: BOOL SetupQueryInfVersionInformationA ( PSP_INF_INFORMATION InfInformation, UINT InfIndex, PCSTR Key, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupQueryInfVersionInformationW ( PSP_INF_INFORMATION InfInformation, UINT InfIndex, PCWSTR Key, PWSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +ALIAS: SetupQueryInfVersionInformation SetupQueryInfVersionInformationW + +FUNCTION: BOOL SetupGetInfDriverStoreLocationA ( PCSTR FileName, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PCSTR LocaleName, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupGetInfDriverStoreLocationW ( PCWSTR FileName, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PCWSTR LocaleName, PWSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +ALIAS: SetupGetInfDriverStoreLocation SetupGetInfDriverStoreLocationW + +FUNCTION: BOOL SetupGetInfPublishedNameA ( PCSTR DriverStoreLocation, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupGetInfPublishedNameW ( PCWSTR DriverStoreLocation, PWSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +ALIAS: SetupGetInfPublishedName SetupGetInfPublishedNameW + +FUNCTION: BOOL SetupGetInfFileListA ( PCSTR DirectoryPath, DWORD InfStyle, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupGetInfFileListW ( PCWSTR DirectoryPath, DWORD InfStyle, PWSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +ALIAS: SetupGetInfFileList SetupGetInfFileListW + +FUNCTION: HINF SetupOpenInfFileW ( PCWSTR FileName, PCWSTR InfClass, DWORD InfStyle, PUINT ErrorLine ) ; +FUNCTION: HINF SetupOpenInfFileA ( PCSTR FileName, PCSTR InfClass, DWORD InfStyle, PUINT ErrorLine ) ; +ALIAS: SetupOpenInfFile SetupOpenInfFileW + +FUNCTION: HINF SetupOpenMasterInf ( ) ; + +FUNCTION: BOOL SetupOpenAppendInfFileW ( PCWSTR FileName, HINF InfHandle, PUINT ErrorLine ) ; +FUNCTION: BOOL SetupOpenAppendInfFileA ( PCSTR FileName, HINF InfHandle, PUINT ErrorLine ) ; +ALIAS: SetupOpenAppendInfFile SetupOpenAppendInfFileW + +FUNCTION: void SetupCloseInfFile ( HINF InfHandle ) ; +FUNCTION: BOOL SetupFindFirstLineA ( HINF InfHandle, PCSTR Section, PCSTR Key, PINFCONTEXT Context ) ; +FUNCTION: BOOL SetupFindFirstLineW ( HINF InfHandle, PCWSTR Section, PCWSTR Key, PINFCONTEXT Context ) ; +ALIAS: SetupFindFirstLine SetupFindFirstLineW + +FUNCTION: BOOL SetupFindNextLine ( PINFCONTEXT ContextIn, PINFCONTEXT ContextOut ) ; +FUNCTION: BOOL SetupFindNextMatchLineA ( PINFCONTEXT ContextIn, PCSTR Key, PINFCONTEXT ContextOut ) ; +FUNCTION: BOOL SetupFindNextMatchLineW ( PINFCONTEXT ContextIn, PCWSTR Key, PINFCONTEXT ContextOut ) ; +ALIAS: SetupFindNextMatchLine SetupFindNextMatchLineW + +FUNCTION: BOOL SetupGetLineByIndexA ( HINF InfHandle, PCSTR Section, DWORD Index, PINFCONTEXT Context ) ; +FUNCTION: BOOL SetupGetLineByIndexW ( HINF InfHandle, PCWSTR Section, DWORD Index, PINFCONTEXT Context ) ; +ALIAS: SetupGetLineByIndex SetupGetLineByIndexW + +FUNCTION: LONG SetupGetLineCountA ( HINF InfHandle, PCSTR Section ) ; +FUNCTION: LONG SetupGetLineCountW ( HINF InfHandle, PCWSTR Section ) ; +ALIAS: SetupGetLineCount SetupGetLineCountW + +FUNCTION: BOOL SetupGetLineTextA ( PINFCONTEXT Context, HINF InfHandle, PCSTR Section, PCSTR Key, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupGetLineTextW ( PINFCONTEXT Context, HINF InfHandle, PCWSTR Section, PCWSTR Key, PWSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +ALIAS: SetupGetLineText SetupGetLineTextW + +FUNCTION: DWORD SetupGetFieldCount ( PINFCONTEXT Context ) ; +FUNCTION: BOOL SetupGetStringFieldA ( PINFCONTEXT Context, DWORD FieldIndex, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupGetStringFieldW ( PINFCONTEXT Context, DWORD FieldIndex, PWSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +ALIAS: SetupGetStringField SetupGetStringFieldW + +FUNCTION: BOOL SetupGetIntField ( PINFCONTEXT Context, DWORD FieldIndex, PINT IntegerValue ) ; +FUNCTION: BOOL SetupGetMultiSzFieldA ( PINFCONTEXT Context, DWORD FieldIndex, PSTR ReturnBuffer, DWORD ReturnBufferSize, LPDWORD RequiredSize ) ; +FUNCTION: BOOL SetupGetMultiSzFieldW ( PINFCONTEXT Context, DWORD FieldIndex, PWSTR ReturnBuffer, DWORD ReturnBufferSize, LPDWORD RequiredSize ) ; +ALIAS: SetupGetMultiSzField SetupGetMultiSzFieldW + +FUNCTION: BOOL SetupGetBinaryField ( PINFCONTEXT Context, DWORD FieldIndex, PBYTE ReturnBuffer, DWORD ReturnBufferSize, LPDWORD RequiredSize ) ; +FUNCTION: DWORD SetupGetFileCompressionInfoA ( PCSTR SourceFileName, PSTR* ActualSourceFileName, PDWORD SourceFileSize, PDWORD TargetFileSize, PUINT CompressionType ) ; +FUNCTION: DWORD SetupGetFileCompressionInfoW ( PCWSTR SourceFileName, PWSTR* ActualSourceFileName, PDWORD SourceFileSize, PDWORD TargetFileSize, PUINT CompressionType ) ; +ALIAS: SetupGetFileCompressionInfo SetupGetFileCompressionInfoW + +FUNCTION: BOOL SetupGetFileCompressionInfoExA ( PCSTR SourceFileName, PSTR ActualSourceFileNameBuffer, DWORD ActualSourceFileNameBufferLen, PDWORD RequiredBufferLen, PDWORD SourceFileSize, PDWORD TargetFileSize, PUINT CompressionType ) ; +FUNCTION: BOOL SetupGetFileCompressionInfoExW ( PCWSTR SourceFileName, PWSTR ActualSourceFileNameBuffer, DWORD ActualSourceFileNameBufferLen, PDWORD RequiredBufferLen, PDWORD SourceFileSize, PDWORD TargetFileSize, PUINT CompressionType ) ; +ALIAS: SetupGetFileCompressionInfoEx SetupGetFileCompressionInfoExW + +CONSTANT: FILE_COMPRESSION_NONE 0 +CONSTANT: FILE_COMPRESSION_WINLZA 1 +CONSTANT: FILE_COMPRESSION_MSZIP 2 +CONSTANT: FILE_COMPRESSION_NTCAB 3 + +FUNCTION: DWORD SetupDecompressOrCopyFileA ( PCSTR SourceFileName, PCSTR TargetFileName, PUINT CompressionType ) ; +FUNCTION: DWORD SetupDecompressOrCopyFileW ( PCWSTR SourceFileName, PCWSTR TargetFileName, PUINT CompressionType ) ; +ALIAS: SetupDecompressOrCopyFile SetupDecompressOrCopyFileW + +FUNCTION: BOOL SetupGetSourceFileLocationA ( HINF InfHandle, PINFCONTEXT InfContext, PCSTR FileName, PUINT SourceId, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupGetSourceFileLocationW ( HINF InfHandle, PINFCONTEXT InfContext, PCWSTR FileName, PUINT SourceId, PWSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +ALIAS: SetupGetSourceFileLocation SetupGetSourceFileLocationW + +FUNCTION: BOOL SetupGetSourceFileSizeA ( HINF InfHandle, PINFCONTEXT InfContext, PCSTR FileName, PCSTR Section, PDWORD FileSize, UINT RoundingFactor ) ; +FUNCTION: BOOL SetupGetSourceFileSizeW ( HINF InfHandle, PINFCONTEXT InfContext, PCWSTR FileName, PCWSTR Section, PDWORD FileSize, UINT RoundingFactor ) ; +ALIAS: SetupGetSourceFileSize SetupGetSourceFileSizeW + +FUNCTION: BOOL SetupGetTargetPathA ( HINF InfHandle, PINFCONTEXT InfContext, PCSTR Section, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupGetTargetPathW ( HINF InfHandle, PINFCONTEXT InfContext, PCWSTR Section, PWSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +ALIAS: SetupGetTargetPath SetupGetTargetPathW + +CONSTANT: SRCLIST_TEMPORARY HEX: 00000001 +CONSTANT: SRCLIST_NOBROWSE HEX: 00000002 +CONSTANT: SRCLIST_SYSTEM HEX: 00000010 +CONSTANT: SRCLIST_USER HEX: 00000020 +CONSTANT: SRCLIST_SYSIFADMIN HEX: 00000040 +CONSTANT: SRCLIST_SUBDIRS HEX: 00000100 +CONSTANT: SRCLIST_APPEND HEX: 00000200 +CONSTANT: SRCLIST_NOSTRIPPLATFORM HEX: 00000400 + +FUNCTION: BOOL SetupSetSourceListA ( DWORD Flags, PCSTR* SourceList, UINT SourceCount ) ; +FUNCTION: BOOL SetupSetSourceListW ( DWORD Flags, PCWSTR* SourceList, UINT SourceCount ) ; +ALIAS: SetupSetSourceList SetupSetSourceListW + +FUNCTION: BOOL SetupCancelTemporarySourceList( ) ; +FUNCTION: BOOL SetupAddToSourceListA ( DWORD Flags, PCSTR Source ) ; +FUNCTION: BOOL SetupAddToSourceListW ( DWORD Flags, PCWSTR Source ) ; +ALIAS: SetupAddToSourceList SetupAddToSourceListW + +FUNCTION: BOOL SetupRemoveFromSourceListA ( DWORD Flags, PCSTR Source ) ; +FUNCTION: BOOL SetupRemoveFromSourceListW ( DWORD Flags, PCWSTR Source ) ; +ALIAS: SetupRemoveFromSourceList SetupRemoveFromSourceListW + +FUNCTION: BOOL SetupQuerySourceListA ( DWORD Flags, PCSTR** List, PUINT Count ) ; +FUNCTION: BOOL SetupQuerySourceListW ( DWORD Flags, PCWSTR** List, PUINT Count ) ; +ALIAS: SetupQuerySourceList SetupQuerySourceListW + +FUNCTION: BOOL SetupFreeSourceListA ( PCSTR** List, UINT Count ) ; +FUNCTION: BOOL SetupFreeSourceListW ( PCWSTR** List, UINT Count ) ; +ALIAS: SetupFreeSourceList SetupFreeSourceListW + +FUNCTION: UINT SetupPromptForDiskA ( HWND hwndParent, PCSTR DialogTitle, PCSTR DiskName, PCSTR PathToSource, PCSTR FileSought, PCSTR TagFile, DWORD DiskPromptStyle, PSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize ) ; +FUNCTION: UINT SetupPromptForDiskW ( HWND hwndParent, PCWSTR DialogTitle, PCWSTR DiskName, PCWSTR PathToSource, PCWSTR FileSought, PCWSTR TagFile, DWORD DiskPromptStyle, PWSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize ) ; +ALIAS: SetupPromptForDisk SetupPromptForDiskW + +FUNCTION: UINT SetupCopyErrorA ( HWND hwndParent, PCSTR DialogTitle, PCSTR DiskName, PCSTR PathToSource, PCSTR SourceFile, PCSTR TargetPathFile, UINT Win32ErrorCode, DWORD Style, PSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize ) ; +FUNCTION: UINT SetupCopyErrorW ( HWND hwndParent, PCWSTR DialogTitle, PCWSTR DiskName, PCWSTR PathToSource, PCWSTR SourceFile, PCWSTR TargetPathFile, UINT Win32ErrorCode, DWORD Style, PWSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize ) ; +ALIAS: SetupCopyError SetupCopyErrorW + +FUNCTION: UINT SetupRenameErrorA ( HWND hwndParent, PCSTR DialogTitle, PCSTR SourceFile, PCSTR TargetFile, UINT Win32ErrorCode, DWORD Style ) ; +FUNCTION: UINT SetupRenameErrorW ( HWND hwndParent, PCWSTR DialogTitle, PCWSTR SourceFile, PCWSTR TargetFile, UINT Win32ErrorCode, DWORD Style ) ; +ALIAS: SetupRenameError SetupRenameErrorW + +FUNCTION: UINT SetupDeleteErrorA ( HWND hwndParent, PCSTR DialogTitle, PCSTR File, UINT Win32ErrorCode, DWORD Style ) ; +FUNCTION: UINT SetupDeleteErrorW ( HWND hwndParent, PCWSTR DialogTitle, PCWSTR File, UINT Win32ErrorCode, DWORD Style ) ; +ALIAS: SetupDeleteError SetupDeleteErrorW + +FUNCTION: UINT SetupBackupErrorA ( HWND hwndParent, PCSTR DialogTitle, PCSTR SourceFile, PCSTR TargetFile, UINT Win32ErrorCode, DWORD Style ) ; +FUNCTION: UINT SetupBackupErrorW ( HWND hwndParent, PCWSTR DialogTitle, PCWSTR SourceFile, PCWSTR TargetFile, UINT Win32ErrorCode, DWORD Style ) ; +ALIAS: SetupBackupError SetupBackupErrorW + +CONSTANT: IDF_NOBROWSE HEX: 00000001 +CONSTANT: IDF_NOSKIP HEX: 00000002 +CONSTANT: IDF_NODETAILS HEX: 00000004 +CONSTANT: IDF_NOCOMPRESSED HEX: 00000008 +CONSTANT: IDF_CHECKFIRST HEX: 00000100 +CONSTANT: IDF_NOBEEP HEX: 00000200 +CONSTANT: IDF_NOFOREGROUND HEX: 00000400 +CONSTANT: IDF_WARNIFSKIP HEX: 00000800 +CONSTANT: IDF_NOREMOVABLEMEDIAPROMPT HEX: 00001000 +CONSTANT: IDF_USEDISKNAMEASPROMPT HEX: 00002000 +CONSTANT: IDF_OEMDISK HEX: 80000000 + +CONSTANT: DPROMPT_SUCCESS 0 +CONSTANT: DPROMPT_CANCEL 1 +CONSTANT: DPROMPT_SKIPFILE 2 +CONSTANT: DPROMPT_BUFFERTOOSMALL 3 +CONSTANT: DPROMPT_OUTOFMEMORY 4 + +FUNCTION: BOOL SetupSetDirectoryIdA ( HINF InfHandle, DWORD Id, PCSTR Directory ) ; +FUNCTION: BOOL SetupSetDirectoryIdW ( HINF InfHandle, DWORD Id, PCWSTR Directory ) ; +ALIAS: SetupSetDirectoryId SetupSetDirectoryIdW + +FUNCTION: BOOL SetupSetDirectoryIdExA ( HINF InfHandle, DWORD Id, PCSTR Directory, DWORD Flags, DWORD Reserved1, PVOID Reserved2 ) ; +FUNCTION: BOOL SetupSetDirectoryIdExW ( HINF InfHandle, DWORD Id, PCWSTR Directory, DWORD Flags, DWORD Reserved1, PVOID Reserved2 ) ; +ALIAS: SetupSetDirectoryIdEx SetupSetDirectoryIdExW + +CONSTANT: SETDIRID_NOT_FULL_PATH HEX: 00000001 + +FUNCTION: BOOL SetupGetSourceInfoA ( HINF InfHandle, UINT SourceId, UINT InfoDesired, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupGetSourceInfoW ( HINF InfHandle, UINT SourceId, UINT InfoDesired, PWSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +ALIAS: SetupGetSourceInfo SetupGetSourceInfoW + +CONSTANT: SRCINFO_PATH 1 +CONSTANT: SRCINFO_TAGFILE 2 +CONSTANT: SRCINFO_DESCRIPTION 3 +CONSTANT: SRCINFO_FLAGS 4 +CONSTANT: SRCINFO_TAGFILE2 5 +CONSTANT: SRC_FLAGS_CABFILE HEX: 0010 + +FUNCTION: BOOL SetupInstallFileA ( HINF InfHandle, PINFCONTEXT InfContext, PCSTR SourceFile, PCSTR SourcePathRoot, PCSTR DestinationName, DWORD CopyStyle, PSP_FILE_CALLBACK_A CopyMsgHandler, PVOID Context ) ; +FUNCTION: BOOL SetupInstallFileW ( HINF InfHandle, PINFCONTEXT InfContext, PCWSTR SourceFile, PCWSTR SourcePathRoot, PCWSTR DestinationName, DWORD CopyStyle, PSP_FILE_CALLBACK_W CopyMsgHandler, PVOID Context ) ; +ALIAS: SetupInstallFile SetupInstallFileW + +FUNCTION: BOOL SetupInstallFileExA ( HINF InfHandle, PINFCONTEXT InfContext, PCSTR SourceFile, PCSTR SourcePathRoot, PCSTR DestinationName, DWORD CopyStyle, PSP_FILE_CALLBACK_A CopyMsgHandler, PVOID Context, PBOOL FileWasInUse ) ; +FUNCTION: BOOL SetupInstallFileExW ( HINF InfHandle, PINFCONTEXT InfContext, PCWSTR SourceFile, PCWSTR SourcePathRoot, PCWSTR DestinationName, DWORD CopyStyle, PSP_FILE_CALLBACK_W CopyMsgHandler, PVOID Context, PBOOL FileWasInUse ) ; +ALIAS: SetupInstallFileEx SetupInstallFileExW + +CONSTANT: SP_COPY_DELETESOURCE HEX: 0000001 +CONSTANT: SP_COPY_REPLACEONLY HEX: 0000002 +CONSTANT: SP_COPY_NEWER HEX: 0000004 +CONSTANT: SP_COPY_NEWER_OR_SAME $ SP_COPY_NEWER +CONSTANT: SP_COPY_NOOVERWRITE HEX: 0000008 +CONSTANT: SP_COPY_NODECOMP HEX: 0000010 +CONSTANT: SP_COPY_LANGUAGEAWARE HEX: 0000020 +CONSTANT: SP_COPY_SOURCE_ABSOLUTE HEX: 0000040 +CONSTANT: SP_COPY_SOURCEPATH_ABSOLUTE HEX: 0000080 +CONSTANT: SP_COPY_IN_USE_NEEDS_REBOOT HEX: 0000100 +CONSTANT: SP_COPY_FORCE_IN_USE HEX: 0000200 +CONSTANT: SP_COPY_NOSKIP HEX: 0000400 +CONSTANT: SP_FLAG_CABINETCONTINUATION HEX: 0000800 +CONSTANT: SP_COPY_FORCE_NOOVERWRITE HEX: 0001000 +CONSTANT: SP_COPY_FORCE_NEWER HEX: 0002000 +CONSTANT: SP_COPY_WARNIFSKIP HEX: 0004000 +CONSTANT: SP_COPY_NOBROWSE HEX: 0008000 +CONSTANT: SP_COPY_NEWER_ONLY HEX: 0010000 +CONSTANT: SP_COPY_RESERVED HEX: 0020000 +CONSTANT: SP_COPY_OEMINF_CATALOG_ONLY HEX: 0040000 +CONSTANT: SP_COPY_REPLACE_BOOT_FILE HEX: 0080000 +CONSTANT: SP_COPY_NOPRUNE HEX: 0100000 +CONSTANT: SP_COPY_OEM_F6_INF HEX: 0200000 +CONSTANT: SP_COPY_ALREADYDECOMP HEX: 0400000 +CONSTANT: SP_COPY_WINDOWS_SIGNED HEX: 1000000 +CONSTANT: SP_COPY_PNPLOCKED HEX: 2000000 +CONSTANT: SP_COPY_IN_USE_TRY_RENAME HEX: 4000000 +CONSTANT: SP_COPY_INBOX_INF HEX: 8000000 +CONSTANT: SP_COPY_HARDLINK HEX: 10000000 + +CONSTANT: SP_BACKUP_BACKUPPASS HEX: 00000001 +CONSTANT: SP_BACKUP_DEMANDPASS HEX: 00000002 +CONSTANT: SP_BACKUP_SPECIAL HEX: 00000004 +CONSTANT: SP_BACKUP_BOOTFILE HEX: 00000008 + +FUNCTION: HSPFILEQ SetupOpenFileQueue ( ) ; +FUNCTION: BOOL SetupCloseFileQueue ( HSPFILEQ QueueHandle ) ; +FUNCTION: BOOL SetupSetFileQueueAlternatePlatformA ( HSPFILEQ QueueHandle, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PCSTR AlternateDefaultCatalogFile ) ; +FUNCTION: BOOL SetupSetFileQueueAlternatePlatformW ( HSPFILEQ QueueHandle, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PCWSTR AlternateDefaultCatalogFile ) ; +ALIAS: SetupSetFileQueueAlternatePlatform SetupSetFileQueueAlternatePlatformW + +FUNCTION: BOOL SetupSetPlatformPathOverrideA ( PCSTR Override ) ; +FUNCTION: BOOL SetupSetPlatformPathOverrideW ( PCWSTR Override ) ; +ALIAS: SetupSetPlatformPathOverride SetupSetPlatformPathOverrideW + +FUNCTION: BOOL SetupQueueCopyA ( HSPFILEQ QueueHandle, PCSTR SourceRootPath, PCSTR SourcePath, PCSTR SourceFilename, PCSTR SourceDescription, PCSTR SourceTagfile, PCSTR TargetDirectory, PCSTR TargetFilename, DWORD CopyStyle ) ; +FUNCTION: BOOL SetupQueueCopyW ( HSPFILEQ QueueHandle, PCWSTR SourceRootPath, PCWSTR SourcePath, PCWSTR SourceFilename, PCWSTR SourceDescription, PCWSTR SourceTagfile, PCWSTR TargetDirectory, PCWSTR TargetFilename, DWORD CopyStyle ) ; +ALIAS: SetupQueueCopy SetupQueueCopyW + +FUNCTION: BOOL SetupQueueCopyIndirectA ( PSP_FILE_COPY_PARAMS_A CopyParams ) ; +FUNCTION: BOOL SetupQueueCopyIndirectW ( PSP_FILE_COPY_PARAMS_W CopyParams ) ; +ALIAS: SetupQueueCopyIndirect SetupQueueCopyIndirectW + +FUNCTION: BOOL SetupQueueDefaultCopyA ( HSPFILEQ QueueHandle, HINF InfHandle, PCSTR SourceRootPath, PCSTR SourceFilename, PCSTR TargetFilename, DWORD CopyStyle ) ; +FUNCTION: BOOL SetupQueueDefaultCopyW ( HSPFILEQ QueueHandle, HINF InfHandle, PCWSTR SourceRootPath, PCWSTR SourceFilename, PCWSTR TargetFilename, DWORD CopyStyle ) ; +ALIAS: SetupQueueDefaultCopy SetupQueueDefaultCopyW + +FUNCTION: BOOL SetupQueueCopySectionA ( HSPFILEQ QueueHandle, PCSTR SourceRootPath, HINF InfHandle, HINF ListInfHandle, PCSTR Section, DWORD CopyStyle ) ; +FUNCTION: BOOL SetupQueueCopySectionW ( HSPFILEQ QueueHandle, PCWSTR SourceRootPath, HINF InfHandle, HINF ListInfHandle, PCWSTR Section, DWORD CopyStyle ) ; +ALIAS: SetupQueueCopySection SetupQueueCopySectionW + +FUNCTION: BOOL SetupQueueDeleteA ( HSPFILEQ QueueHandle, PCSTR PathPart1, PCSTR PathPart2 ) ; +FUNCTION: BOOL SetupQueueDeleteW ( HSPFILEQ QueueHandle, PCWSTR PathPart1, PCWSTR PathPart2 ) ; +ALIAS: SetupQueueDelete SetupQueueDeleteW + +FUNCTION: BOOL SetupQueueDeleteSectionA ( HSPFILEQ QueueHandle, HINF InfHandle, HINF ListInfHandle, PCSTR Section ) ; +FUNCTION: BOOL SetupQueueDeleteSectionW ( HSPFILEQ QueueHandle, HINF InfHandle, HINF ListInfHandle, PCWSTR Section ) ; +ALIAS: SetupQueueDeleteSection SetupQueueDeleteSectionW + +FUNCTION: BOOL SetupQueueRenameA ( HSPFILEQ QueueHandle, PCSTR SourcePath, PCSTR SourceFilename, PCSTR TargetPath, PCSTR TargetFilename ) ; +FUNCTION: BOOL SetupQueueRenameW ( HSPFILEQ QueueHandle, PCWSTR SourcePath, PCWSTR SourceFilename, PCWSTR TargetPath, PCWSTR TargetFilename ) ; +ALIAS: SetupQueueRename SetupQueueRenameW + +FUNCTION: BOOL SetupQueueRenameSectionA ( HSPFILEQ QueueHandle, HINF InfHandle, HINF ListInfHandle, PCSTR Section ) ; +FUNCTION: BOOL SetupQueueRenameSectionW ( HSPFILEQ QueueHandle, HINF InfHandle, HINF ListInfHandle, PCWSTR Section ) ; +ALIAS: SetupQueueRenameSection SetupQueueRenameSectionW + +FUNCTION: BOOL SetupCommitFileQueueA ( HWND Owner, HSPFILEQ QueueHandle, PSP_FILE_CALLBACK_A MsgHandler, PVOID Context ) ; +FUNCTION: BOOL SetupCommitFileQueueW ( HWND Owner, HSPFILEQ QueueHandle, PSP_FILE_CALLBACK_W MsgHandler, PVOID Context ) ; +ALIAS: SetupCommitFileQueue SetupCommitFileQueueW + +FUNCTION: BOOL SetupScanFileQueueA ( HSPFILEQ FileQueue, DWORD Flags, HWND Window, PSP_FILE_CALLBACK_A CallbackRoutine, PVOID CallbackContext, PDWORD Result ) ; +FUNCTION: BOOL SetupScanFileQueueW ( HSPFILEQ FileQueue, DWORD Flags, HWND Window, PSP_FILE_CALLBACK_W CallbackRoutine, PVOID CallbackContext, PDWORD Result ) ; +ALIAS: SetupScanFileQueue SetupScanFileQueueW + +CONSTANT: SPQ_SCAN_FILE_PRESENCE HEX: 00000001 +CONSTANT: SPQ_SCAN_FILE_VALIDITY HEX: 00000002 +CONSTANT: SPQ_SCAN_USE_CALLBACK HEX: 00000004 +CONSTANT: SPQ_SCAN_USE_CALLBACKEX HEX: 00000008 +CONSTANT: SPQ_SCAN_INFORM_USER HEX: 00000010 +CONSTANT: SPQ_SCAN_PRUNE_COPY_QUEUE HEX: 00000020 +CONSTANT: SPQ_SCAN_USE_CALLBACK_SIGNERINFO HEX: 00000040 +CONSTANT: SPQ_SCAN_PRUNE_DELREN HEX: 00000080 +CONSTANT: SPQ_SCAN_FILE_PRESENCE_WITHOUT_SOURCE HEX: 00000100 +CONSTANT: SPQ_SCAN_FILE_COMPARISON HEX: 00000200 +CONSTANT: SPQ_SCAN_ACTIVATE_DRP HEX: 00000400 +CONSTANT: SPQ_DELAYED_COPY HEX: 00000001 + +FUNCTION: BOOL SetupGetFileQueueCount ( HSPFILEQ FileQueue, UINT SubQueueFileOp, PUINT NumOperations ) ; +FUNCTION: BOOL SetupGetFileQueueFlags ( HSPFILEQ FileQueue, PDWORD Flags ) ; +FUNCTION: BOOL SetupSetFileQueueFlags ( HSPFILEQ FileQueue, DWORD FlagMask, DWORD Flags ) ; + +CONSTANT: SPQ_FLAG_BACKUP_AWARE HEX: 00000001 +CONSTANT: SPQ_FLAG_ABORT_IF_UNSIGNED HEX: 00000002 +CONSTANT: SPQ_FLAG_FILES_MODIFIED HEX: 00000004 +CONSTANT: SPQ_FLAG_DO_SHUFFLEMOVE HEX: 00000008 +CONSTANT: SPQ_FLAG_VALID HEX: 0000000F + +CONSTANT: SPOST_NONE 0 +CONSTANT: SPOST_PATH 1 +CONSTANT: SPOST_URL 2 +CONSTANT: SPOST_MAX 3 + +FUNCTION: BOOL SetupCopyOEMInfA ( PCSTR SourceInfFileName, PCSTR OEMSourceMediaLocation, DWORD OEMSourceMediaType, DWORD CopyStyle, PSTR DestinationInfFileName, DWORD DestinationInfFileNameSize, PDWORD RequiredSize, PSTR* DestinationInfFileNameComponent ) ; +FUNCTION: BOOL SetupCopyOEMInfW ( PCWSTR SourceInfFileName, PCWSTR OEMSourceMediaLocation, DWORD OEMSourceMediaType, DWORD CopyStyle, PWSTR DestinationInfFileName, DWORD DestinationInfFileNameSize, PDWORD RequiredSize, PWSTR* DestinationInfFileNameComponent ) ; +ALIAS: SetupCopyOEMInf SetupCopyOEMInfW + +CONSTANT: SUOI_FORCEDELETE HEX: 00000001 +CONSTANT: SUOI_INTERNAL1 HEX: 00000002 + +FUNCTION: BOOL SetupUninstallOEMInfA ( PCSTR InfFileName, DWORD Flags, PVOID Reserved ) ; +FUNCTION: BOOL SetupUninstallOEMInfW ( PCWSTR InfFileName, DWORD Flags, PVOID Reserved ) ; +ALIAS: SetupUninstallOEMInf SetupUninstallOEMInfW + +FUNCTION: BOOL SetupUninstallNewlyCopiedInfs( HSPFILEQ FileQueue, DWORD Flags, PVOID Reserved ) ; + +FUNCTION: HDSKSPC SetupCreateDiskSpaceListA ( PVOID Reserved1, DWORD Reserved2, UINT Flags ) ; +FUNCTION: HDSKSPC SetupCreateDiskSpaceListW ( PVOID Reserved1, DWORD Reserved2, UINT Flags ) ; +ALIAS: SetupCreateDiskSpaceList SetupCreateDiskSpaceListW + +CONSTANT: SPDSL_IGNORE_DISK HEX: 00000001 +CONSTANT: SPDSL_DISALLOW_NEGATIVE_ADJUST HEX: 00000002 + +FUNCTION: HDSKSPC SetupDuplicateDiskSpaceListA ( HDSKSPC DiskSpace, PVOID Reserved1, DWORD Reserved2, UINT Flags ) ; +FUNCTION: HDSKSPC SetupDuplicateDiskSpaceListW ( HDSKSPC DiskSpace, PVOID Reserved1, DWORD Reserved2, UINT Flags ) ; +ALIAS: SetupDuplicateDiskSpaceList SetupDuplicateDiskSpaceListW + +FUNCTION: BOOL SetupDestroyDiskSpaceList( HDSKSPC DiskSpace ) ; +FUNCTION: BOOL SetupQueryDrivesInDiskSpaceListA ( HDSKSPC DiskSpace, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupQueryDrivesInDiskSpaceListW ( HDSKSPC DiskSpace, PWSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +ALIAS: SetupQueryDrivesInDiskSpaceList SetupQueryDrivesInDiskSpaceListW + +FUNCTION: BOOL SetupQuerySpaceRequiredOnDriveA ( HDSKSPC DiskSpace, PCSTR DriveSpec, LONGLONG* SpaceRequired, PVOID Reserved1, UINT Reserved2 ) ; +FUNCTION: BOOL SetupQuerySpaceRequiredOnDriveW ( HDSKSPC DiskSpace, PCWSTR DriveSpec, LONGLONG* SpaceRequired, PVOID Reserved1, UINT Reserved2 ) ; +ALIAS: SetupQuerySpaceRequiredOnDrive SetupQuerySpaceRequiredOnDriveW + +FUNCTION: BOOL SetupAdjustDiskSpaceListA ( HDSKSPC DiskSpace, LPCSTR DriveRoot, LONGLONG Amount, PVOID Reserved1, UINT Reserved2 ) ; +FUNCTION: BOOL SetupAdjustDiskSpaceListW ( HDSKSPC DiskSpace, LPCWSTR DriveRoot, LONGLONG Amount, PVOID Reserved1, UINT Reserved2 ) ; +ALIAS: SetupAdjustDiskSpaceList SetupAdjustDiskSpaceListW + +FUNCTION: BOOL SetupAddToDiskSpaceListA ( HDSKSPC DiskSpace, PCSTR TargetFilespec, LONGLONG FileSize, UINT Operation, PVOID Reserved1, UINT Reserved2 ) ; +FUNCTION: BOOL SetupAddToDiskSpaceListW ( HDSKSPC DiskSpace, PCWSTR TargetFilespec, LONGLONG FileSize, UINT Operation, PVOID Reserved1, UINT Reserved2 ) ; +ALIAS: SetupAddToDiskSpaceList SetupAddToDiskSpaceListW + +FUNCTION: BOOL SetupAddSectionToDiskSpaceListA ( HDSKSPC DiskSpace, HINF InfHandle, HINF ListInfHandle, PCSTR SectionName, UINT Operation, PVOID Reserved1, UINT Reserved2 ) ; +FUNCTION: BOOL SetupAddSectionToDiskSpaceListW ( HDSKSPC DiskSpace, HINF InfHandle, HINF ListInfHandle, PCWSTR SectionName, UINT Operation, PVOID Reserved1, UINT Reserved2 ) ; +ALIAS: SetupAddSectionToDiskSpaceList SetupAddSectionToDiskSpaceListW + +FUNCTION: BOOL SetupAddInstallSectionToDiskSpaceListA ( HDSKSPC DiskSpace, HINF InfHandle, HINF LayoutInfHandle, PCSTR SectionName, PVOID Reserved1, UINT Reserved2 ) ; +FUNCTION: BOOL SetupAddInstallSectionToDiskSpaceListW ( HDSKSPC DiskSpace, HINF InfHandle, HINF LayoutInfHandle, PCWSTR SectionName, PVOID Reserved1, UINT Reserved2 ) ; +ALIAS: SetupAddInstallSectionToDiskSpaceList SetupAddInstallSectionToDiskSpaceListW + +FUNCTION: BOOL SetupRemoveFromDiskSpaceListA ( HDSKSPC DiskSpace, PCSTR TargetFilespec, UINT Operation, PVOID Reserved1, UINT Reserved2 ) ; +FUNCTION: BOOL SetupRemoveFromDiskSpaceListW ( HDSKSPC DiskSpace, PCWSTR TargetFilespec, UINT Operation, PVOID Reserved1, UINT Reserved2 ) ; +ALIAS: SetupRemoveFromDiskSpaceList SetupRemoveFromDiskSpaceListW + +FUNCTION: BOOL SetupRemoveSectionFromDiskSpaceListA ( HDSKSPC DiskSpace, HINF InfHandle, HINF ListInfHandle, PCSTR SectionName, UINT Operation, PVOID Reserved1, UINT Reserved2 ) ; +FUNCTION: BOOL SetupRemoveSectionFromDiskSpaceListW ( HDSKSPC DiskSpace, HINF InfHandle, HINF ListInfHandle, PCWSTR SectionName, UINT Operation, PVOID Reserved1, UINT Reserved2 ) ; +ALIAS: SetupRemoveSectionFromDiskSpaceList SetupRemoveSectionFromDiskSpaceListW + +FUNCTION: BOOL SetupRemoveInstallSectionFromDiskSpaceListA ( HDSKSPC DiskSpace, HINF InfHandle, HINF LayoutInfHandle, PCSTR SectionName, PVOID Reserved1, UINT Reserved2 ) ; +FUNCTION: BOOL SetupRemoveInstallSectionFromDiskSpaceListW ( HDSKSPC DiskSpace, HINF InfHandle, HINF LayoutInfHandle, PCWSTR SectionName, PVOID Reserved1, UINT Reserved2 ) ; +ALIAS: SetupRemoveInstallSectionFromDiskSpaceList SetupRemoveInstallSectionFromDiskSpaceListW + +FUNCTION: BOOL SetupIterateCabinetA ( PCSTR CabinetFile, DWORD Reserved, PSP_FILE_CALLBACK_A MsgHandler, PVOID Context ) ; +FUNCTION: BOOL SetupIterateCabinetW ( PCWSTR CabinetFile, DWORD Reserved, PSP_FILE_CALLBACK_W MsgHandler, PVOID Context ) ; +ALIAS: SetupIterateCabinet SetupIterateCabinetW + +FUNCTION: INT SetupPromptReboot ( HSPFILEQ FileQueue, HWND Owner, BOOL ScanOnly ) ; + +CONSTANT: SPFILEQ_FILE_IN_USE HEX: 00000001 +CONSTANT: SPFILEQ_REBOOT_RECOMMENDED HEX: 00000002 +CONSTANT: SPFILEQ_REBOOT_IN_PROGRESS HEX: 00000004 + +FUNCTION: PVOID SetupInitDefaultQueueCallback ( HWND OwnerWindow ) ; +FUNCTION: PVOID SetupInitDefaultQueueCallbackEx ( HWND OwnerWindow, HWND AlternateProgressWindow, UINT ProgressMessage, DWORD Reserved1, PVOID Reserved2 ) ; +FUNCTION: void SetupTermDefaultQueueCallback ( PVOID Context ) ; + +FUNCTION: UINT SetupDefaultQueueCallbackA ( PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2 ) ; +FUNCTION: UINT SetupDefaultQueueCallbackW ( PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2 ) ; +ALIAS: SetupDefaultQueueCallback SetupDefaultQueueCallbackW + +CONSTANT: FLG_ADDREG_DELREG_BIT HEX: 00008000 +CONSTANT: FLG_ADDREG_BINVALUETYPE HEX: 00000001 +CONSTANT: FLG_ADDREG_NOCLOBBER HEX: 00000002 +CONSTANT: FLG_ADDREG_DELVAL HEX: 00000004 +CONSTANT: FLG_ADDREG_APPEND HEX: 00000008 +CONSTANT: FLG_ADDREG_KEYONLY HEX: 00000010 +CONSTANT: FLG_ADDREG_OVERWRITEONLY HEX: 00000020 +CONSTANT: FLG_ADDREG_64BITKEY HEX: 00001000 +CONSTANT: FLG_ADDREG_KEYONLY_COMMON HEX: 00002000 +CONSTANT: FLG_ADDREG_32BITKEY HEX: 00004000 +CONSTANT: FLG_ADDREG_TYPE_MASK HEX: FFFF0001 +CONSTANT: FLG_ADDREG_TYPE_SZ HEX: 00000000 +CONSTANT: FLG_ADDREG_TYPE_MULTI_SZ HEX: 00010000 +CONSTANT: FLG_ADDREG_TYPE_EXPAND_SZ HEX: 00020000 +CONSTANT: FLG_ADDREG_TYPE_BINARY HEX: 00000001 +CONSTANT: FLG_ADDREG_TYPE_DWORD HEX: 00010001 +CONSTANT: FLG_ADDREG_TYPE_NONE HEX: 00020001 +CONSTANT: FLG_DELREG_VALUE HEX: 00000000 +CONSTANT: FLG_DELREG_TYPE_MASK $ FLG_ADDREG_TYPE_MASK +CONSTANT: FLG_DELREG_TYPE_SZ $ FLG_ADDREG_TYPE_SZ +CONSTANT: FLG_DELREG_TYPE_MULTI_SZ $ FLG_ADDREG_TYPE_MULTI_SZ +CONSTANT: FLG_DELREG_TYPE_EXPAND_SZ $ FLG_ADDREG_TYPE_EXPAND_SZ +CONSTANT: FLG_DELREG_TYPE_BINARY $ FLG_ADDREG_TYPE_BINARY +CONSTANT: FLG_DELREG_TYPE_DWORD $ FLG_ADDREG_TYPE_DWORD +CONSTANT: FLG_DELREG_TYPE_NONE $ FLG_ADDREG_TYPE_NONE +CONSTANT: FLG_DELREG_64BITKEY $ FLG_ADDREG_64BITKEY +CONSTANT: FLG_DELREG_KEYONLY_COMMON $ FLG_ADDREG_KEYONLY_COMMON +CONSTANT: FLG_DELREG_32BITKEY $ FLG_ADDREG_32BITKEY +CONSTANT: FLG_DELREG_OPERATION_MASK HEX: 000000FE +CONSTANT: FLG_DELREG_MULTI_SZ_DELSTRING HEX: 00018002 +CONSTANT: FLG_BITREG_CLEARBITS HEX: 00000000 +CONSTANT: FLG_BITREG_SETBITS HEX: 00000001 +CONSTANT: FLG_BITREG_64BITKEY HEX: 00001000 +CONSTANT: FLG_BITREG_32BITKEY HEX: 00004000 +CONSTANT: FLG_INI2REG_64BITKEY HEX: 00001000 +CONSTANT: FLG_INI2REG_32BITKEY HEX: 00004000 +CONSTANT: FLG_REGSVR_DLLREGISTER HEX: 00000001 +CONSTANT: FLG_REGSVR_DLLINSTALL HEX: 00000002 +CONSTANT: FLG_PROFITEM_CURRENTUSER HEX: 00000001 +CONSTANT: FLG_PROFITEM_DELETE HEX: 00000002 +CONSTANT: FLG_PROFITEM_GROUP HEX: 00000004 +CONSTANT: FLG_PROFITEM_CSIDL HEX: 00000008 +CONSTANT: FLG_ADDPROPERTY_NOCLOBBER HEX: 00000001 +CONSTANT: FLG_ADDPROPERTY_OVERWRITEONLY HEX: 00000002 +CONSTANT: FLG_ADDPROPERTY_APPEND HEX: 00000004 +CONSTANT: FLG_ADDPROPERTY_OR HEX: 00000008 +CONSTANT: FLG_ADDPROPERTY_AND HEX: 00000010 +CONSTANT: FLG_DELPROPERTY_MULTI_SZ_DELSTRING HEX: 00000001 + +FUNCTION: BOOL SetupInstallFromInfSectionA ( HWND Owner, HINF InfHandle, PCSTR SectionName, UINT Flags, HKEY RelativeKeyRoot, PCSTR SourceRootPath, UINT CopyFlags, PSP_FILE_CALLBACK_A MsgHandler, PVOID Context, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupInstallFromInfSectionW ( HWND Owner, HINF InfHandle, PCWSTR SectionName, UINT Flags, HKEY RelativeKeyRoot, PCWSTR SourceRootPath, UINT CopyFlags, PSP_FILE_CALLBACK_W MsgHandler, PVOID Context, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +ALIAS: SetupInstallFromInfSection SetupInstallFromInfSectionW + +CONSTANT: SPINST_LOGCONFIG HEX: 00000001 +CONSTANT: SPINST_INIFILES HEX: 00000002 +CONSTANT: SPINST_REGISTRY HEX: 00000004 +CONSTANT: SPINST_INI2REG HEX: 00000008 +CONSTANT: SPINST_FILES HEX: 00000010 +CONSTANT: SPINST_BITREG HEX: 00000020 +CONSTANT: SPINST_REGSVR HEX: 00000040 +CONSTANT: SPINST_UNREGSVR HEX: 00000080 +CONSTANT: SPINST_PROFILEITEMS HEX: 00000100 +CONSTANT: SPINST_COPYINF HEX: 00000200 +CONSTANT: SPINST_PROPERTIES HEX: 00000400 +CONSTANT: SPINST_ALL HEX: 000007ff +CONSTANT: SPINST_SINGLESECTION HEX: 00010000 +CONSTANT: SPINST_LOGCONFIG_IS_FORCED HEX: 00020000 +CONSTANT: SPINST_LOGCONFIGS_ARE_OVERRIDES HEX: 00040000 +CONSTANT: SPINST_REGISTERCALLBACKAWARE HEX: 00080000 +CONSTANT: SPINST_DEVICEINSTALL HEX: 00100000 + +FUNCTION: BOOL SetupInstallFilesFromInfSectionA ( HINF InfHandle, HINF LayoutInfHandle, HSPFILEQ FileQueue, PCSTR SectionName, PCSTR SourceRootPath, UINT CopyFlags ) ; +FUNCTION: BOOL SetupInstallFilesFromInfSectionW ( HINF InfHandle, HINF LayoutInfHandle, HSPFILEQ FileQueue, PCWSTR SectionName, PCWSTR SourceRootPath, UINT CopyFlags ) ; +ALIAS: SetupInstallFilesFromInfSection SetupInstallFilesFromInfSectionW + +CONSTANT: SPSVCINST_TAGTOFRONT HEX: 00000001 +CONSTANT: SPSVCINST_ASSOCSERVICE HEX: 00000002 +CONSTANT: SPSVCINST_DELETEEVENTLOGENTRY HEX: 00000004 +CONSTANT: SPSVCINST_NOCLOBBER_DISPLAYNAME HEX: 00000008 +CONSTANT: SPSVCINST_NOCLOBBER_STARTTYPE HEX: 00000010 +CONSTANT: SPSVCINST_NOCLOBBER_ERRORCONTROL HEX: 00000020 +CONSTANT: SPSVCINST_NOCLOBBER_LOADORDERGROUP HEX: 00000040 +CONSTANT: SPSVCINST_NOCLOBBER_DEPENDENCIES HEX: 00000080 +CONSTANT: SPSVCINST_NOCLOBBER_DESCRIPTION HEX: 00000100 +CONSTANT: SPSVCINST_STOPSERVICE HEX: 00000200 +CONSTANT: SPSVCINST_CLOBBER_SECURITY HEX: 00000400 +CONSTANT: SPSVCINST_STARTSERVICE HEX: 00000800 +CONSTANT: SPSVCINST_NOCLOBBER_REQUIREDPRIVILEGES HEX: 00001000 + +FUNCTION: BOOL SetupInstallServicesFromInfSectionA ( HINF InfHandle, PCSTR SectionName, DWORD Flags ) ; +FUNCTION: BOOL SetupInstallServicesFromInfSectionW ( HINF InfHandle, PCWSTR SectionName, DWORD Flags ) ; +ALIAS: SetupInstallServicesFromInfSection SetupInstallServicesFromInfSectionW + +FUNCTION: BOOL SetupInstallServicesFromInfSectionExA ( HINF InfHandle, PCSTR SectionName, DWORD Flags, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PVOID Reserved1, PVOID Reserved2 ) ; +FUNCTION: BOOL SetupInstallServicesFromInfSectionExW ( HINF InfHandle, PCWSTR SectionName, DWORD Flags, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PVOID Reserved1, PVOID Reserved2 ) ; +ALIAS: SetupInstallServicesFromInfSectionEx SetupInstallServicesFromInfSectionExW + +FUNCTION: void InstallHinfSectionA ( HWND Window, HINSTANCE ModuleHandle, PCSTR CommandLine, INT ShowCommand ) ; +FUNCTION: void InstallHinfSectionW ( HWND Window, HINSTANCE ModuleHandle, PCWSTR CommandLine, INT ShowCommand ) ; +ALIAS: InstallHinfSection InstallHinfSectionW + +TYPEDEF: PVOID HSPFILELOG + +FUNCTION: HSPFILELOG SetupInitializeFileLogA ( PCSTR LogFileName, DWORD Flags ) ; +FUNCTION: HSPFILELOG SetupInitializeFileLogW ( PCWSTR LogFileName, DWORD Flags ) ; +ALIAS: SetupInitializeFileLog SetupInitializeFileLogW + +CONSTANT: SPFILELOG_SYSTEMLOG HEX: 00000001 +CONSTANT: SPFILELOG_FORCENEW HEX: 00000002 +CONSTANT: SPFILELOG_QUERYONLY HEX: 00000004 + +FUNCTION: BOOL SetupTerminateFileLog ( HSPFILELOG FileLogHandle ) ; +FUNCTION: BOOL SetupLogFileA ( HSPFILELOG FileLogHandle, PCSTR LogSectionName, PCSTR SourceFilename, PCSTR TargetFilename, DWORD Checksum, PCSTR DiskTagfile, PCSTR DiskDescription, PCSTR OtherInfo, DWORD Flags ) ; +FUNCTION: BOOL SetupLogFileW ( HSPFILELOG FileLogHandle, PCWSTR LogSectionName, PCWSTR SourceFilename, PCWSTR TargetFilename, DWORD Checksum, PCWSTR DiskTagfile, PCWSTR DiskDescription, PCWSTR OtherInfo, DWORD Flags ) ; +ALIAS: SetupLogFile SetupLogFileW + +CONSTANT: SPFILELOG_OEMFILE HEX: 00000001 +FUNCTION: BOOL SetupRemoveFileLogEntryA ( HSPFILELOG FileLogHandle, PCSTR LogSectionName, PCSTR TargetFilename ) ; +FUNCTION: BOOL SetupRemoveFileLogEntryW ( HSPFILELOG FileLogHandle, PCWSTR LogSectionName, PCWSTR TargetFilename ) ; +ALIAS: SetupRemoveFileLogEntry SetupRemoveFileLogEntryW + +C-ENUM: + SetupFileLogSourceFilename + SetupFileLogChecksum + SetupFileLogDiskTagfile + SetupFileLogDiskDescription + SetupFileLogOtherInfo + SetupFileLogMax ; +TYPEDEF: int SetupFileLogInfo + +FUNCTION: BOOL SetupQueryFileLogA ( HSPFILELOG FileLogHandle, PCSTR LogSectionName, PCSTR TargetFilename, SetupFileLogInfo DesiredInfo, PSTR DataOut, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupQueryFileLogW ( HSPFILELOG FileLogHandle, PCWSTR LogSectionName, PCWSTR TargetFilename, SetupFileLogInfo DesiredInfo, PWSTR DataOut, DWORD ReturnBufferSize, PDWORD RequiredSize ) ; +ALIAS: SetupQueryFileLog SetupQueryFileLogW + +TYPEDEF: DWORD LogSeverity +CONSTANT: LogSevInformation HEX: 00000000 +CONSTANT: LogSevWarning HEX: 00000001 +CONSTANT: LogSevError HEX: 00000002 +CONSTANT: LogSevFatalError HEX: 00000003 +CONSTANT: LogSevMaximum HEX: 00000004 + +FUNCTION: BOOL SetupOpenLog ( BOOL Erase ) ; +FUNCTION: BOOL SetupLogErrorA ( LPCSTR MessageString, LogSeverity Severity ) ; +FUNCTION: BOOL SetupLogErrorW ( LPCWSTR MessageString, LogSeverity Severity ) ; +ALIAS: SetupLogError SetupLogErrorW + +FUNCTION: void SetupCloseLog ( ) ; +FUNCTION: SP_LOG_TOKEN SetupGetThreadLogToken ( ) ; +FUNCTION: void SetupSetThreadLogToken ( SP_LOG_TOKEN LogToken ) ; +! Unavailable until FFI to vargargs is supported. +! FUNCTION: void SetupWriteTextLog ( SP_LOG_TOKEN LogToken, DWORD Category, DWORD Flags, PCSTR MessageStr, ... ) ; +! FUNCTION: void SetupWriteTextLogError ( SP_LOG_TOKEN LogToken, DWORD Category, DWORD LogFlags, DWORD Error, PCSTR MessageStr, ... ) ; +FUNCTION: void SetupWriteTextLogInfLine ( SP_LOG_TOKEN LogToken, DWORD Flags, HINF InfHandle, PINFCONTEXT Context ) ; + +FUNCTION: BOOL SetupGetBackupInformationA ( HSPFILEQ QueueHandle, PSP_BACKUP_QUEUE_PARAMS_A BackupParams ) ; +FUNCTION: BOOL SetupGetBackupInformationW ( HSPFILEQ QueueHandle, PSP_BACKUP_QUEUE_PARAMS_W BackupParams ) ; +ALIAS: SetupGetBackupInformation SetupGetBackupInformationW + +FUNCTION: BOOL SetupPrepareQueueForRestoreA ( HSPFILEQ QueueHandle, PCSTR BackupPath, DWORD RestoreFlags ) ; +FUNCTION: BOOL SetupPrepareQueueForRestoreW ( HSPFILEQ QueueHandle, PCWSTR BackupPath, DWORD RestoreFlags ) ; +ALIAS: SetupPrepareQueueForRestore SetupPrepareQueueForRestoreW + +FUNCTION: BOOL SetupSetNonInteractiveMode ( BOOL NonInteractiveFlag ) ; +FUNCTION: BOOL SetupGetNonInteractiveMode ( ) ; + +FUNCTION: HDEVINFO SetupDiCreateDeviceInfoList ( GUID* ClassGuid, HWND hwndParent ) ; +FUNCTION: HDEVINFO SetupDiCreateDeviceInfoListExA ( GUID* ClassGuid, HWND hwndParent, PCSTR MachineName, PVOID Reserved ) ; +FUNCTION: HDEVINFO SetupDiCreateDeviceInfoListExW ( GUID* ClassGuid, HWND hwndParent, PCWSTR MachineName, PVOID Reserved ) ; + +ALIAS: SetupDiCreateDeviceInfoListEx SetupDiCreateDeviceInfoListExW + +FUNCTION: BOOL SetupDiGetDeviceInfoListClass( HDEVINFO DeviceInfoSet, LPGUID ClassGuid ) ; +FUNCTION: BOOL SetupDiGetDeviceInfoListDetailA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_LIST_DETAIL_DATA_A DeviceInfoSetDetailData ) ; +FUNCTION: BOOL SetupDiGetDeviceInfoListDetailW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_LIST_DETAIL_DATA_W DeviceInfoSetDetailData ) ; +ALIAS: SetupDiGetDeviceInfoListDetail SetupDiGetDeviceInfoListDetailW + +CONSTANT: DICD_GENERATE_ID HEX: 00000001 +CONSTANT: DICD_INHERIT_CLASSDRVS HEX: 00000002 + +FUNCTION: BOOL SetupDiCreateDeviceInfoA ( HDEVINFO DeviceInfoSet, PCSTR DeviceName, GUID* ClassGuid, PCSTR DeviceDescription, HWND hwndParent, DWORD CreationFlags, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiCreateDeviceInfoW ( HDEVINFO DeviceInfoSet, PCWSTR DeviceName, GUID* ClassGuid, PCWSTR DeviceDescription, HWND hwndParent, DWORD CreationFlags, PSP_DEVINFO_DATA DeviceInfoData ) ; +ALIAS: SetupDiCreateDeviceInfo SetupDiCreateDeviceInfoW + +CONSTANT: DIOD_INHERIT_CLASSDRVS HEX: 00000002 +CONSTANT: DIOD_CANCEL_REMOVE HEX: 00000004 + +FUNCTION: BOOL SetupDiOpenDeviceInfoA ( HDEVINFO DeviceInfoSet, PCSTR DeviceInstanceId, HWND hwndParent, DWORD OpenFlags, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiOpenDeviceInfoW ( HDEVINFO DeviceInfoSet, PCWSTR DeviceInstanceId, HWND hwndParent, DWORD OpenFlags, PSP_DEVINFO_DATA DeviceInfoData ) ; +ALIAS: SetupDiOpenDeviceInfo SetupDiOpenDeviceInfoW + +FUNCTION: BOOL SetupDiGetDeviceInstanceIdA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSTR DeviceInstanceId, DWORD DeviceInstanceIdSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupDiGetDeviceInstanceIdW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PWSTR DeviceInstanceId, DWORD DeviceInstanceIdSize, PDWORD RequiredSize ) ; +ALIAS: SetupDiGetDeviceInstanceId SetupDiGetDeviceInstanceIdW + +FUNCTION: BOOL SetupDiDeleteDeviceInfo ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiEnumDeviceInfo ( HDEVINFO DeviceInfoSet, DWORD MemberIndex, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiDestroyDeviceInfoList ( HDEVINFO DeviceInfoSet ) ; +FUNCTION: BOOL SetupDiEnumDeviceInterfaces ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, GUID* InterfaceClassGuid, DWORD MemberIndex, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData ) ; +ALIAS: SetupDiEnumInterfaceDevice SetupDiEnumDeviceInterfaces + +FUNCTION: BOOL SetupDiCreateDeviceInterfaceA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, GUID* InterfaceClassGuid, PCSTR ReferenceString, DWORD CreationFlags, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData ) ; +FUNCTION: BOOL SetupDiCreateDeviceInterfaceW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, GUID* InterfaceClassGuid, PCWSTR ReferenceString, DWORD CreationFlags, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData ) ; +ALIAS: SetupDiCreateDeviceInterface SetupDiCreateDeviceInterfaceW + +ALIAS: SetupDiCreateInterfaceDeviceW SetupDiCreateDeviceInterfaceW +ALIAS: SetupDiCreateInterfaceDeviceA SetupDiCreateDeviceInterfaceA + +ALIAS: SetupDiCreateInterfaceDevice SetupDiCreateDeviceInterfaceW + +CONSTANT: DIODI_NO_ADD HEX: 00000001 + +FUNCTION: BOOL SetupDiOpenDeviceInterfaceA ( HDEVINFO DeviceInfoSet, PCSTR DevicePath, DWORD OpenFlags, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData ) ; +FUNCTION: BOOL SetupDiOpenDeviceInterfaceW ( HDEVINFO DeviceInfoSet, PCWSTR DevicePath, DWORD OpenFlags, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData ) ; +ALIAS: SetupDiOpenDeviceInterface SetupDiOpenDeviceInterfaceW + +ALIAS: SetupDiOpenInterfaceDeviceW SetupDiOpenDeviceInterfaceW +ALIAS: SetupDiOpenInterfaceDeviceA SetupDiOpenDeviceInterfaceA + +ALIAS: SetupDiOpenInterfaceDevice SetupDiOpenDeviceInterfaceW + +FUNCTION: BOOL SetupDiGetDeviceInterfaceAlias ( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, GUID* AliasInterfaceClassGuid, PSP_DEVICE_INTERFACE_DATA AliasDeviceInterfaceData ) ; +ALIAS: SetupDiGetInterfaceDeviceAlias SetupDiGetDeviceInterfaceAlias + +FUNCTION: BOOL SetupDiDeleteDeviceInterfaceData ( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData ) ; +ALIAS: SetupDiDeleteInterfaceDeviceData SetupDiDeleteDeviceInterfaceData + +FUNCTION: BOOL SetupDiRemoveDeviceInterface ( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData ) ; +ALIAS: SetupDiRemoveInterfaceDevice SetupDiRemoveDeviceInterface + +FUNCTION: BOOL SetupDiGetDeviceInterfaceDetailA ( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData, DWORD DeviceInterfaceDetailDataSize, PDWORD RequiredSize, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiGetDeviceInterfaceDetailW ( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData, DWORD DeviceInterfaceDetailDataSize, PDWORD RequiredSize, PSP_DEVINFO_DATA DeviceInfoData ) ; +ALIAS: SetupDiGetDeviceInterfaceDetail SetupDiGetDeviceInterfaceDetailW + +ALIAS: SetupDiGetInterfaceDeviceDetailW SetupDiGetDeviceInterfaceDetailW +ALIAS: SetupDiGetInterfaceDeviceDetailA SetupDiGetDeviceInterfaceDetailA + +ALIAS: SetupDiGetInterfaceDeviceDetail SetupDiGetDeviceInterfaceDetailW + +FUNCTION: BOOL SetupDiInstallDeviceInterfaces ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +ALIAS: SetupDiInstallInterfaceDevices SetupDiInstallDeviceInterfaces + +FUNCTION: BOOL SetupDiSetDeviceInterfaceDefault ( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DWORD Flags, PVOID Reserved ) ; + +CONSTANT: SPRDI_FIND_DUPS HEX: 00000001 + +FUNCTION: BOOL SetupDiRegisterDeviceInfo ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Flags, PSP_DETSIG_CMPPROC CompareProc, PVOID CompareContext, PSP_DEVINFO_DATA DupDeviceInfoData ) ; + +CONSTANT: SPDIT_NODRIVER HEX: 00000000 +CONSTANT: SPDIT_CLASSDRIVER HEX: 00000001 +CONSTANT: SPDIT_COMPATDRIVER HEX: 00000002 + +FUNCTION: BOOL SetupDiBuildDriverInfoList ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD DriverType ) ; +FUNCTION: BOOL SetupDiCancelDriverInfoSearch ( HDEVINFO DeviceInfoSet ) ; +FUNCTION: BOOL SetupDiEnumDriverInfoA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD DriverType, DWORD MemberIndex, PSP_DRVINFO_DATA_A DriverInfoData ) ; +FUNCTION: BOOL SetupDiEnumDriverInfoW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD DriverType, DWORD MemberIndex, PSP_DRVINFO_DATA_W DriverInfoData ) ; +ALIAS: SetupDiEnumDriverInfo SetupDiEnumDriverInfoW + +FUNCTION: BOOL SetupDiGetSelectedDriverA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_A DriverInfoData ) ; +FUNCTION: BOOL SetupDiGetSelectedDriverW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_W DriverInfoData ) ; +ALIAS: SetupDiGetSelectedDriver SetupDiGetSelectedDriverW + +FUNCTION: BOOL SetupDiSetSelectedDriverA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_A DriverInfoData ) ; +FUNCTION: BOOL SetupDiSetSelectedDriverW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_W DriverInfoData ) ; +ALIAS: SetupDiSetSelectedDriver SetupDiSetSelectedDriverW + +FUNCTION: BOOL SetupDiGetDriverInfoDetailA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_A DriverInfoData, PSP_DRVINFO_DETAIL_DATA_A DriverInfoDetailData, DWORD DriverInfoDetailDataSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupDiGetDriverInfoDetailW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_W DriverInfoData, PSP_DRVINFO_DETAIL_DATA_W DriverInfoDetailData, DWORD DriverInfoDetailDataSize, PDWORD RequiredSize ) ; +ALIAS: SetupDiGetDriverInfoDetail SetupDiGetDriverInfoDetailW + +FUNCTION: BOOL SetupDiDestroyDriverInfoList ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD DriverType ) ; + +CONSTANT: DIGCF_DEFAULT HEX: 00000001 +CONSTANT: DIGCF_PRESENT HEX: 00000002 +CONSTANT: DIGCF_ALLCLASSES HEX: 00000004 +CONSTANT: DIGCF_PROFILE HEX: 00000008 +CONSTANT: DIGCF_DEVICEINTERFACE HEX: 00000010 +CONSTANT: DIGCF_INTERFACEDEVICE $ DIGCF_DEVICEINTERFACE + +FUNCTION: HDEVINFO SetupDiGetClassDevsA ( GUID* ClassGuid, PCSTR Enumerator, HWND hwndParent, DWORD Flags ) ; +FUNCTION: HDEVINFO SetupDiGetClassDevsW ( GUID* ClassGuid, PCWSTR Enumerator, HWND hwndParent, DWORD Flags ) ; +ALIAS: SetupDiGetClassDevs SetupDiGetClassDevsW + +FUNCTION: HDEVINFO SetupDiGetClassDevsExA ( GUID* ClassGuid, PCSTR Enumerator, HWND hwndParent, DWORD Flags, HDEVINFO DeviceInfoSet, PCSTR MachineName, PVOID Reserved ) ; +FUNCTION: HDEVINFO SetupDiGetClassDevsExW ( GUID* ClassGuid, PCWSTR Enumerator, HWND hwndParent, DWORD Flags, HDEVINFO DeviceInfoSet, PCWSTR MachineName, PVOID Reserved ) ; +ALIAS: SetupDiGetClassDevsEx SetupDiGetClassDevsExW + +FUNCTION: BOOL SetupDiGetINFClassA ( PCSTR InfName, LPGUID ClassGuid, PSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupDiGetINFClassW ( PCWSTR InfName, LPGUID ClassGuid, PWSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize ) ; +ALIAS: SetupDiGetINFClass SetupDiGetINFClassW + +CONSTANT: DIBCI_NOINSTALLCLASS HEX: 00000001 +CONSTANT: DIBCI_NODISPLAYCLASS HEX: 00000002 + +FUNCTION: BOOL SetupDiBuildClassInfoList ( DWORD Flags, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupDiBuildClassInfoListExA ( DWORD Flags, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, PCSTR MachineName, PVOID Reserved ) ; +FUNCTION: BOOL SetupDiBuildClassInfoListExW ( DWORD Flags, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, PCWSTR MachineName, PVOID Reserved ) ; +ALIAS: SetupDiBuildClassInfoListEx SetupDiBuildClassInfoListExW + +FUNCTION: BOOL SetupDiGetClassDescriptionA ( GUID* ClassGuid, PSTR ClassDescription, DWORD ClassDescriptionSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupDiGetClassDescriptionW ( GUID* ClassGuid, PWSTR ClassDescription, DWORD ClassDescriptionSize, PDWORD RequiredSize ) ; +ALIAS: SetupDiGetClassDescription SetupDiGetClassDescriptionW + +FUNCTION: BOOL SetupDiGetClassDescriptionExA ( GUID* ClassGuid, PSTR ClassDescription, DWORD ClassDescriptionSize, PDWORD RequiredSize, PCSTR MachineName, PVOID Reserved ) ; +FUNCTION: BOOL SetupDiGetClassDescriptionExW ( GUID* ClassGuid, PWSTR ClassDescription, DWORD ClassDescriptionSize, PDWORD RequiredSize, PCWSTR MachineName, PVOID Reserved ) ; +ALIAS: SetupDiGetClassDescriptionEx SetupDiGetClassDescriptionExW + +FUNCTION: BOOL SetupDiCallClassInstaller ( DI_FUNCTION InstallFunction, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiSelectDevice ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiSelectBestCompatDrv ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiInstallDevice ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiInstallDriverFiles ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiRegisterCoDeviceInstallers( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiRemoveDevice ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiUnremoveDevice ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiRestartDevices ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiChangeState ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiFinishInstallAction ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; + +FUNCTION: BOOL SetupDiInstallClassA ( HWND hwndParent, PCSTR InfFileName, DWORD Flags, HSPFILEQ FileQueue ) ; +FUNCTION: BOOL SetupDiInstallClassW ( HWND hwndParent, PCWSTR InfFileName, DWORD Flags, HSPFILEQ FileQueue ) ; +ALIAS: SetupDiInstallClass SetupDiInstallClassW + +FUNCTION: BOOL SetupDiInstallClassExA ( HWND hwndParent, PCSTR InfFileName, DWORD Flags, HSPFILEQ FileQueue, GUID* InterfaceClassGuid, PVOID Reserved1, PVOID Reserved2 ) ; +FUNCTION: BOOL SetupDiInstallClassExW ( HWND hwndParent, PCWSTR InfFileName, DWORD Flags, HSPFILEQ FileQueue, GUID* InterfaceClassGuid, PVOID Reserved1, PVOID Reserved2 ) ; +ALIAS: SetupDiInstallClassEx SetupDiInstallClassExW + +FUNCTION: HKEY SetupDiOpenClassRegKey ( GUID* ClassGuid, REGSAM samDesired ) ; + +CONSTANT: DIOCR_INSTALLER HEX: 00000001 +CONSTANT: DIOCR_INTERFACE HEX: 00000002 + +FUNCTION: HKEY SetupDiOpenClassRegKeyExA ( GUID* ClassGuid, REGSAM samDesired, DWORD Flags, PCSTR MachineName, PVOID Reserved ) ; +FUNCTION: HKEY SetupDiOpenClassRegKeyExW ( GUID* ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved ) ; +ALIAS: SetupDiOpenClassRegKeyEx SetupDiOpenClassRegKeyExW + +FUNCTION: HKEY SetupDiCreateDeviceInterfaceRegKeyA ( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DWORD Reserved, REGSAM samDesired, HINF InfHandle, PCSTR InfSectionName ) ; +FUNCTION: HKEY SetupDiCreateDeviceInterfaceRegKeyW ( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DWORD Reserved, REGSAM samDesired, HINF InfHandle, PCWSTR InfSectionName ) ; +ALIAS: SetupDiCreateDeviceInterfaceRegKey SetupDiCreateDeviceInterfaceRegKeyW +ALIAS: SetupDiCreateInterfaceDeviceRegKeyW SetupDiCreateDeviceInterfaceRegKeyW +ALIAS: SetupDiCreateInterfaceDeviceRegKeyA SetupDiCreateDeviceInterfaceRegKeyA +ALIAS: SetupDiCreateInterfaceDeviceRegKey SetupDiCreateDeviceInterfaceRegKeyW + +FUNCTION: HKEY SetupDiOpenDeviceInterfaceRegKey ( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DWORD Reserved, REGSAM samDesired ) ; +ALIAS: SetupDiOpenInterfaceDeviceRegKey SetupDiOpenDeviceInterfaceRegKey + +FUNCTION: BOOL SetupDiDeleteDeviceInterfaceRegKey ( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DWORD Reserved ) ; +ALIAS: SetupDiDeleteInterfaceDeviceRegKey SetupDiDeleteDeviceInterfaceRegKey + +CONSTANT: DIREG_DEV HEX: 00000001 +CONSTANT: DIREG_DRV HEX: 00000002 +CONSTANT: DIREG_BOTH HEX: 00000004 + +FUNCTION: HKEY SetupDiCreateDevRegKeyA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, HINF InfHandle, PCSTR InfSectionName ) ; +FUNCTION: HKEY SetupDiCreateDevRegKeyW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, HINF InfHandle, PCWSTR InfSectionName ) ; +ALIAS: SetupDiCreateDevRegKey SetupDiCreateDevRegKeyW + +FUNCTION: HKEY SetupDiOpenDevRegKey ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired ) ; +FUNCTION: BOOL SetupDiDeleteDevRegKey ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType ) ; +FUNCTION: BOOL SetupDiGetHwProfileList ( PDWORD HwProfileList, DWORD HwProfileListSize, PDWORD RequiredSize, PDWORD CurrentlyActiveIndex ) ; +FUNCTION: BOOL SetupDiGetHwProfileListExA ( PDWORD HwProfileList, DWORD HwProfileListSize, PDWORD RequiredSize, PDWORD CurrentlyActiveIndex, PCSTR MachineName, PVOID Reserved ) ; +FUNCTION: BOOL SetupDiGetHwProfileListExW ( PDWORD HwProfileList, DWORD HwProfileListSize, PDWORD RequiredSize, PDWORD CurrentlyActiveIndex, PCWSTR MachineName, PVOID Reserved ) ; +ALIAS: SetupDiGetHwProfileListEx SetupDiGetHwProfileListExW + +FUNCTION: BOOL SetupDiGetDevicePropertyKeys ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DEVPROPKEY* PropertyKeyArray, DWORD PropertyKeyCount, PDWORD RequiredPropertyKeyCount, DWORD Flags ) ; +FUNCTION: BOOL SetupDiGetDevicePropertyW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DEVPROPKEY* PropertyKey, DEVPROPTYPE* PropertyType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize, DWORD Flags ) ; +ALIAS: SetupDiGetDeviceProperty SetupDiGetDevicePropertyW + +FUNCTION: BOOL SetupDiSetDevicePropertyW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DEVPROPKEY* PropertyKey, DEVPROPTYPE PropertyType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, DWORD Flags ) ; +ALIAS: SetupDiSetDeviceProperty SetupDiSetDevicePropertyW + +FUNCTION: BOOL SetupDiGetDeviceInterfacePropertyKeys ( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DEVPROPKEY* PropertyKeyArray, DWORD PropertyKeyCount, PDWORD RequiredPropertyKeyCount, DWORD Flags ) ; +FUNCTION: BOOL SetupDiGetDeviceInterfacePropertyW ( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DEVPROPKEY* PropertyKey, DEVPROPTYPE* PropertyType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize, DWORD Flags ) ; +ALIAS: SetupDiGetDeviceInterfaceProperty SetupDiGetDeviceInterfacePropertyW + +FUNCTION: BOOL SetupDiSetDeviceInterfacePropertyW ( HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DEVPROPKEY* PropertyKey, DEVPROPTYPE PropertyType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, DWORD Flags ) ; +ALIAS: SetupDiSetDeviceInterfaceProperty SetupDiSetDeviceInterfacePropertyW + +CONSTANT: DICLASSPROP_INSTALLER HEX: 00000001 +CONSTANT: DICLASSPROP_INTERFACE HEX: 00000002 + +FUNCTION: BOOL SetupDiGetClassPropertyKeys ( GUID* ClassGuid, DEVPROPKEY* PropertyKeyArray, DWORD PropertyKeyCount, PDWORD RequiredPropertyKeyCount, DWORD Flags ) ; +FUNCTION: BOOL SetupDiGetClassPropertyKeysExW ( GUID* ClassGuid, DEVPROPKEY* PropertyKeyArray, DWORD PropertyKeyCount, PDWORD RequiredPropertyKeyCount, DWORD Flags, PCWSTR MachineName, PVOID Reserved ) ; +ALIAS: SetupDiGetClassPropertyKeysEx SetupDiGetClassPropertyKeysExW + +FUNCTION: BOOL SetupDiGetClassPropertyW ( GUID* ClassGuid, DEVPROPKEY* PropertyKey, DEVPROPTYPE* PropertyType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize, DWORD Flags ) ; +ALIAS: SetupDiGetClassProperty SetupDiGetClassPropertyW + +FUNCTION: BOOL SetupDiGetClassPropertyExW ( GUID* ClassGuid, DEVPROPKEY* PropertyKey, DEVPROPTYPE* PropertyType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize, DWORD Flags, PCWSTR MachineName, PVOID Reserved ) ; +ALIAS: SetupDiGetClassPropertyEx SetupDiGetClassPropertyExW + +FUNCTION: BOOL SetupDiSetClassPropertyW ( GUID* ClassGuid, DEVPROPKEY* PropertyKey, DEVPROPTYPE PropertyType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, DWORD Flags ) ; +ALIAS: SetupDiSetClassProperty SetupDiSetClassPropertyW + +FUNCTION: BOOL SetupDiSetClassPropertyExW ( GUID* ClassGuid, DEVPROPKEY* PropertyKey, DEVPROPTYPE PropertyType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, DWORD Flags, PCWSTR MachineName, PVOID Reserved ) ; +ALIAS: SetupDiSetClassPropertyEx SetupDiSetClassPropertyExW + +CONSTANT: SPDRP_DEVICEDESC HEX: 00000000 +CONSTANT: SPDRP_HARDWAREID HEX: 00000001 +CONSTANT: SPDRP_COMPATIBLEIDS HEX: 00000002 +CONSTANT: SPDRP_UNUSED0 HEX: 00000003 +CONSTANT: SPDRP_SERVICE HEX: 00000004 +CONSTANT: SPDRP_UNUSED1 HEX: 00000005 +CONSTANT: SPDRP_UNUSED2 HEX: 00000006 +CONSTANT: SPDRP_CLASS HEX: 00000007 +CONSTANT: SPDRP_CLASSGUID HEX: 00000008 +CONSTANT: SPDRP_DRIVER HEX: 00000009 +CONSTANT: SPDRP_CONFIGFLAGS HEX: 0000000A +CONSTANT: SPDRP_MFG HEX: 0000000B +CONSTANT: SPDRP_FRIENDLYNAME HEX: 0000000C +CONSTANT: SPDRP_LOCATION_INFORMATION HEX: 0000000D +CONSTANT: SPDRP_PHYSICAL_DEVICE_OBJECT_NAME HEX: 0000000E +CONSTANT: SPDRP_CAPABILITIES HEX: 0000000F +CONSTANT: SPDRP_UI_NUMBER HEX: 00000010 +CONSTANT: SPDRP_UPPERFILTERS HEX: 00000011 +CONSTANT: SPDRP_LOWERFILTERS HEX: 00000012 +CONSTANT: SPDRP_BUSTYPEGUID HEX: 00000013 +CONSTANT: SPDRP_LEGACYBUSTYPE HEX: 00000014 +CONSTANT: SPDRP_BUSNUMBER HEX: 00000015 +CONSTANT: SPDRP_ENUMERATOR_NAME HEX: 00000016 +CONSTANT: SPDRP_SECURITY HEX: 00000017 +CONSTANT: SPDRP_SECURITY_SDS HEX: 00000018 +CONSTANT: SPDRP_DEVTYPE HEX: 00000019 +CONSTANT: SPDRP_EXCLUSIVE HEX: 0000001A +CONSTANT: SPDRP_CHARACTERISTICS HEX: 0000001B +CONSTANT: SPDRP_ADDRESS HEX: 0000001C +CONSTANT: SPDRP_UI_NUMBER_DESC_FORMAT HEX: 0000001D +CONSTANT: SPDRP_DEVICE_POWER_DATA HEX: 0000001E +CONSTANT: SPDRP_REMOVAL_POLICY HEX: 0000001F +CONSTANT: SPDRP_REMOVAL_POLICY_HW_DEFAULT HEX: 00000020 +CONSTANT: SPDRP_REMOVAL_POLICY_OVERRIDE HEX: 00000021 +CONSTANT: SPDRP_INSTALL_STATE HEX: 00000022 +CONSTANT: SPDRP_LOCATION_PATHS HEX: 00000023 +CONSTANT: SPDRP_BASE_CONTAINERID HEX: 00000024 +CONSTANT: SPDRP_MAXIMUM_PROPERTY HEX: 00000025 +CONSTANT: SPCRP_UPPERFILTERS HEX: 00000011 +CONSTANT: SPCRP_LOWERFILTERS HEX: 00000012 +CONSTANT: SPCRP_SECURITY HEX: 00000017 +CONSTANT: SPCRP_SECURITY_SDS HEX: 00000018 +CONSTANT: SPCRP_DEVTYPE HEX: 00000019 +CONSTANT: SPCRP_EXCLUSIVE HEX: 0000001A +CONSTANT: SPCRP_CHARACTERISTICS HEX: 0000001B +CONSTANT: SPCRP_MAXIMUM_PROPERTY HEX: 0000001C + +FUNCTION: BOOL SetupDiGetDeviceRegistryPropertyA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupDiGetDeviceRegistryPropertyW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize ) ; +ALIAS: SetupDiGetDeviceRegistryProperty SetupDiGetDeviceRegistryPropertyW + +FUNCTION: BOOL SetupDiGetClassRegistryPropertyA ( GUID* ClassGuid, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize, PCSTR MachineName, PVOID Reserved ) ; +FUNCTION: BOOL SetupDiGetClassRegistryPropertyW ( GUID* ClassGuid, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize, PCWSTR MachineName, PVOID Reserved ) ; +ALIAS: SetupDiGetClassRegistryProperty SetupDiGetClassRegistryPropertyW + +FUNCTION: BOOL SetupDiSetDeviceRegistryPropertyA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, BYTE* PropertyBuffer, DWORD PropertyBufferSize ) ; +FUNCTION: BOOL SetupDiSetDeviceRegistryPropertyW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, BYTE* PropertyBuffer, DWORD PropertyBufferSize ) ; +ALIAS: SetupDiSetDeviceRegistryProperty SetupDiSetDeviceRegistryPropertyW + +FUNCTION: BOOL SetupDiSetClassRegistryPropertyA ( GUID* ClassGuid, DWORD Property, BYTE* PropertyBuffer, DWORD PropertyBufferSize, PCSTR MachineName, PVOID Reserved ) ; +FUNCTION: BOOL SetupDiSetClassRegistryPropertyW ( GUID* ClassGuid, DWORD Property, BYTE* PropertyBuffer, DWORD PropertyBufferSize, PCWSTR MachineName, PVOID Reserved ) ; +ALIAS: SetupDiSetClassRegistryProperty SetupDiSetClassRegistryPropertyW + +FUNCTION: BOOL SetupDiGetDeviceInstallParamsA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DEVINSTALL_PARAMS_A DeviceInstallParams ) ; +FUNCTION: BOOL SetupDiGetDeviceInstallParamsW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DEVINSTALL_PARAMS_W DeviceInstallParams ) ; +ALIAS: SetupDiGetDeviceInstallParams SetupDiGetDeviceInstallParamsW + +FUNCTION: BOOL SetupDiGetClassInstallParamsA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_CLASSINSTALL_HEADER ClassInstallParams, DWORD ClassInstallParamsSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupDiGetClassInstallParamsW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_CLASSINSTALL_HEADER ClassInstallParams, DWORD ClassInstallParamsSize, PDWORD RequiredSize ) ; +ALIAS: SetupDiGetClassInstallParams SetupDiGetClassInstallParamsW + +FUNCTION: BOOL SetupDiSetDeviceInstallParamsA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DEVINSTALL_PARAMS_A DeviceInstallParams ) ; +FUNCTION: BOOL SetupDiSetDeviceInstallParamsW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DEVINSTALL_PARAMS_W DeviceInstallParams ) ; +ALIAS: SetupDiSetDeviceInstallParams SetupDiSetDeviceInstallParamsW + +FUNCTION: BOOL SetupDiSetClassInstallParamsA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_CLASSINSTALL_HEADER ClassInstallParams, DWORD ClassInstallParamsSize ) ; +FUNCTION: BOOL SetupDiSetClassInstallParamsW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_CLASSINSTALL_HEADER ClassInstallParams, DWORD ClassInstallParamsSize ) ; +ALIAS: SetupDiSetClassInstallParams SetupDiSetClassInstallParamsW + +FUNCTION: BOOL SetupDiGetDriverInstallParamsA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_A DriverInfoData, PSP_DRVINSTALL_PARAMS DriverInstallParams ) ; +FUNCTION: BOOL SetupDiGetDriverInstallParamsW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_W DriverInfoData, PSP_DRVINSTALL_PARAMS DriverInstallParams ) ; +ALIAS: SetupDiGetDriverInstallParams SetupDiGetDriverInstallParamsW + +FUNCTION: BOOL SetupDiSetDriverInstallParamsA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_A DriverInfoData, PSP_DRVINSTALL_PARAMS DriverInstallParams ) ; +FUNCTION: BOOL SetupDiSetDriverInstallParamsW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DRVINFO_DATA_W DriverInfoData, PSP_DRVINSTALL_PARAMS DriverInstallParams ) ; +ALIAS: SetupDiSetDriverInstallParams SetupDiSetDriverInstallParamsW + +FUNCTION: BOOL SetupDiLoadClassIcon ( GUID* ClassGuid, HICON* LargeIcon, PINT MiniIconIndex ) ; +FUNCTION: BOOL SetupDiLoadDeviceIcon ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, UINT cxIcon, UINT cyIcon, DWORD Flags, HICON* hIcon ) ; + +CONSTANT: DMI_MASK HEX: 00000001 +CONSTANT: DMI_BKCOLOR HEX: 00000002 +CONSTANT: DMI_USERECT HEX: 00000004 + +FUNCTION: INT SetupDiDrawMiniIcon ( HDC hdc, RECT rc, INT MiniIconIndex, DWORD Flags ) ; +FUNCTION: BOOL SetupDiGetClassBitmapIndex ( GUID* ClassGuid, PINT MiniIconIndex ) ; +FUNCTION: BOOL SetupDiGetClassImageList ( PSP_CLASSIMAGELIST_DATA ClassImageListData ) ; +FUNCTION: BOOL SetupDiGetClassImageListExA ( PSP_CLASSIMAGELIST_DATA ClassImageListData, PCSTR MachineName, PVOID Reserved ) ; +FUNCTION: BOOL SetupDiGetClassImageListExW ( PSP_CLASSIMAGELIST_DATA ClassImageListData, PCWSTR MachineName, PVOID Reserved ) ; +ALIAS: SetupDiGetClassImageListEx SetupDiGetClassImageListExW + +FUNCTION: BOOL SetupDiGetClassImageIndex ( PSP_CLASSIMAGELIST_DATA ClassImageListData, GUID* ClassGuid, PINT ImageIndex ) ; +FUNCTION: BOOL SetupDiDestroyClassImageList ( PSP_CLASSIMAGELIST_DATA ClassImageListData ) ; + +CONSTANT: DIGCDP_FLAG_BASIC HEX: 00000001 +CONSTANT: DIGCDP_FLAG_ADVANCED HEX: 00000002 +CONSTANT: DIGCDP_FLAG_REMOTE_BASIC HEX: 00000003 +CONSTANT: DIGCDP_FLAG_REMOTE_ADVANCED HEX: 00000004 + +FUNCTION: BOOL SetupDiGetClassDevPropertySheetsA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, LPPROPSHEETHEADERA PropertySheetHeader, DWORD PropertySheetHeaderPageListSize, PDWORD RequiredSize, DWORD PropertySheetType ) ; +FUNCTION: BOOL SetupDiGetClassDevPropertySheetsW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, LPPROPSHEETHEADERW PropertySheetHeader, DWORD PropertySheetHeaderPageListSize, PDWORD RequiredSize, DWORD PropertySheetType ) ; +ALIAS: SetupDiGetClassDevPropertySheets SetupDiGetClassDevPropertySheetsW + +CONSTANT: IDI_RESOURCEFIRST 159 +CONSTANT: IDI_RESOURCE 159 +CONSTANT: IDI_RESOURCELAST 161 +CONSTANT: IDI_RESOURCEOVERLAYFIRST 161 +CONSTANT: IDI_RESOURCEOVERLAYLAST 161 +CONSTANT: IDI_CONFLICT 161 +CONSTANT: IDI_CLASSICON_OVERLAYFIRST 500 +CONSTANT: IDI_CLASSICON_OVERLAYLAST 502 +CONSTANT: IDI_PROBLEM_OVL 500 +CONSTANT: IDI_DISABLED_OVL 501 +CONSTANT: IDI_FORCED_OVL 502 + +FUNCTION: BOOL SetupDiAskForOEMDisk ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiSelectOEMDrv ( HWND hwndParent, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiClassNameFromGuidA ( GUID* ClassGuid, PSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupDiClassNameFromGuidW ( GUID* ClassGuid, PWSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize ) ; +ALIAS: SetupDiClassNameFromGuid SetupDiClassNameFromGuidW + +FUNCTION: BOOL SetupDiClassNameFromGuidExA ( GUID* ClassGuid, PSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize, PCSTR MachineName, PVOID Reserved ) ; +FUNCTION: BOOL SetupDiClassNameFromGuidExW ( GUID* ClassGuid, PWSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize, PCWSTR MachineName, PVOID Reserved ) ; +ALIAS: SetupDiClassNameFromGuidEx SetupDiClassNameFromGuidExW + +FUNCTION: BOOL SetupDiClassGuidsFromNameA ( PCSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupDiClassGuidsFromNameW ( PCWSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize ) ; +ALIAS: SetupDiClassGuidsFromName SetupDiClassGuidsFromNameW + +FUNCTION: BOOL SetupDiClassGuidsFromNameExA ( PCSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, PCSTR MachineName, PVOID Reserved ) ; +FUNCTION: BOOL SetupDiClassGuidsFromNameExW ( PCWSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, PCWSTR MachineName, PVOID Reserved ) ; +ALIAS: SetupDiClassGuidsFromNameEx SetupDiClassGuidsFromNameExW + +FUNCTION: BOOL SetupDiGetHwProfileFriendlyNameA ( DWORD HwProfile, PSTR FriendlyName, DWORD FriendlyNameSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupDiGetHwProfileFriendlyNameW ( DWORD HwProfile, PWSTR FriendlyName, DWORD FriendlyNameSize, PDWORD RequiredSize ) ; +ALIAS: SetupDiGetHwProfileFriendlyName SetupDiGetHwProfileFriendlyNameW + +FUNCTION: BOOL SetupDiGetHwProfileFriendlyNameExA ( DWORD HwProfile, PSTR FriendlyName, DWORD FriendlyNameSize, PDWORD RequiredSize, PCSTR MachineName, PVOID Reserved ) ; +FUNCTION: BOOL SetupDiGetHwProfileFriendlyNameExW ( DWORD HwProfile, PWSTR FriendlyName, DWORD FriendlyNameSize, PDWORD RequiredSize, PCWSTR MachineName, PVOID Reserved ) ; +ALIAS: SetupDiGetHwProfileFriendlyNameEx SetupDiGetHwProfileFriendlyNameExW + +CONSTANT: SPWPT_SELECTDEVICE HEX: 00000001 +CONSTANT: SPWP_USE_DEVINFO_DATA HEX: 00000001 + +FUNCTION: HPROPSHEETPAGE SetupDiGetWizardPage ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_INSTALLWIZARD_DATA InstallWizardData, DWORD PageType, DWORD Flags ) ; +FUNCTION: BOOL SetupDiGetSelectedDevice ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; +FUNCTION: BOOL SetupDiSetSelectedDevice ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData ) ; + +FUNCTION: BOOL SetupDiGetActualModelsSectionA ( PINFCONTEXT Context, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PSTR InfSectionWithExt, DWORD InfSectionWithExtSize, PDWORD RequiredSize, PVOID Reserved ) ; +FUNCTION: BOOL SetupDiGetActualModelsSectionW ( PINFCONTEXT Context, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PWSTR InfSectionWithExt, DWORD InfSectionWithExtSize, PDWORD RequiredSize, PVOID Reserved ) ; + +ALIAS: SetupDiGetActualModelsSection SetupDiGetActualModelsSectionW + +FUNCTION: BOOL SetupDiGetActualSectionToInstallA ( HINF InfHandle, PCSTR InfSectionName, PSTR InfSectionWithExt, DWORD InfSectionWithExtSize, PDWORD RequiredSize, PSTR* Extension ) ; +FUNCTION: BOOL SetupDiGetActualSectionToInstallW ( HINF InfHandle, PCWSTR InfSectionName, PWSTR InfSectionWithExt, DWORD InfSectionWithExtSize, PDWORD RequiredSize, PWSTR* Extension ) ; +ALIAS: SetupDiGetActualSectionToInstall SetupDiGetActualSectionToInstallW + +FUNCTION: BOOL SetupDiGetActualSectionToInstallExA ( HINF InfHandle, PCSTR InfSectionName, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PSTR InfSectionWithExt, DWORD InfSectionWithExtSize, PDWORD RequiredSize, PSTR* Extension, PVOID Reserved ) ; +FUNCTION: BOOL SetupDiGetActualSectionToInstallExW ( HINF InfHandle, PCWSTR InfSectionName, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PWSTR InfSectionWithExt, DWORD InfSectionWithExtSize, PDWORD RequiredSize, PWSTR* Extension, PVOID Reserved ) ; +ALIAS: SetupDiGetActualSectionToInstallEx SetupDiGetActualSectionToInstallExW + +FUNCTION: BOOL SetupEnumInfSectionsA ( HINF InfHandle, UINT Index, PSTR Buffer, UINT Size, UINT* SizeNeeded ) ; +FUNCTION: BOOL SetupEnumInfSectionsW ( HINF InfHandle, UINT Index, PWSTR Buffer, UINT Size, UINT* SizeNeeded ) ; +ALIAS: SetupEnumInfSections SetupEnumInfSectionsW + +STRUCT: SP_INF_SIGNER_INFO_V1_A + { cbSize DWORD } + { CatalogFile CHAR[MAX_PATH] } + { DigitalSigner CHAR[MAX_PATH] } + { DigitalSignerVersion CHAR[MAX_PATH] } ; +TYPEDEF: SP_INF_SIGNER_INFO_V1_A* PSP_INF_SIGNER_INFO_V1_A +STRUCT: SP_INF_SIGNER_INFO_V1_W + { cbSize DWORD } + { CatalogFile WCHAR[MAX_PATH] } + { DigitalSigner WCHAR[MAX_PATH] } + { DigitalSignerVersion WCHAR[MAX_PATH] } ; +TYPEDEF: SP_INF_SIGNER_INFO_V1_W* PSP_INF_SIGNER_INFO_V1_W +TYPEDEF: SP_INF_SIGNER_INFO_V1_W SP_INF_SIGNER_INFO_V1 +TYPEDEF: PSP_INF_SIGNER_INFO_V1_W PSP_INF_SIGNER_INFO_V1 + +STRUCT: SP_INF_SIGNER_INFO_V2_A + { cbSize DWORD } + { CatalogFile CHAR[MAX_PATH] } + { DigitalSigner CHAR[MAX_PATH] } + { DigitalSignerVersion CHAR[MAX_PATH] } + { SignerScore DWORD } ; +TYPEDEF: SP_INF_SIGNER_INFO_V2_A* PSP_INF_SIGNER_INFO_V2_A +STRUCT: SP_INF_SIGNER_INFO_V2_W + { cbSize DWORD } + { CatalogFile WCHAR[MAX_PATH] } + { DigitalSigner WCHAR[MAX_PATH] } + { DigitalSignerVersion WCHAR[MAX_PATH] } + { SignerScore DWORD } ; +TYPEDEF: SP_INF_SIGNER_INFO_V2_W* PSP_INF_SIGNER_INFO_V2_W + +TYPEDEF: SP_INF_SIGNER_INFO_V2_W SP_INF_SIGNER_INFO_V2 +TYPEDEF: PSP_INF_SIGNER_INFO_V2_W PSP_INF_SIGNER_INFO_V2 + +CONSTANT: SIGNERSCORE_UNKNOWN HEX: FF000000 +CONSTANT: SIGNERSCORE_W9X_SUSPECT HEX: C0000000 +CONSTANT: SIGNERSCORE_UNSIGNED HEX: 80000000 +CONSTANT: SIGNERSCORE_AUTHENTICODE HEX: 0F000000 +CONSTANT: SIGNERSCORE_WHQL HEX: 0D000005 +CONSTANT: SIGNERSCORE_UNCLASSIFIED HEX: 0D000004 +CONSTANT: SIGNERSCORE_INBOX HEX: 0D000003 +CONSTANT: SIGNERSCORE_LOGO_STANDARD HEX: 0D000002 +CONSTANT: SIGNERSCORE_LOGO_PREMIUM HEX: 0D000001 +CONSTANT: SIGNERSCORE_MASK HEX: FF000000 +CONSTANT: SIGNERSCORE_SIGNED_MASK HEX: F0000000 + +TYPEDEF: SP_INF_SIGNER_INFO_V2_A SP_INF_SIGNER_INFO_A +TYPEDEF: PSP_INF_SIGNER_INFO_V2_A PSP_INF_SIGNER_INFO_A +TYPEDEF: SP_INF_SIGNER_INFO_V2_W SP_INF_SIGNER_INFO_W +TYPEDEF: PSP_INF_SIGNER_INFO_V2_W PSP_INF_SIGNER_INFO_W +TYPEDEF: SP_INF_SIGNER_INFO_V2 SP_INF_SIGNER_INFO +TYPEDEF: PSP_INF_SIGNER_INFO_V2 PSP_INF_SIGNER_INFO + +FUNCTION: BOOL SetupVerifyInfFileA ( PCSTR InfName, PSP_ALTPLATFORM_INFO AltPlatformInfo, PSP_INF_SIGNER_INFO_A InfSignerInfo ) ; +FUNCTION: BOOL SetupVerifyInfFileW ( PCWSTR InfName, PSP_ALTPLATFORM_INFO AltPlatformInfo, PSP_INF_SIGNER_INFO_W InfSignerInfo ) ; +ALIAS: SetupVerifyInfFile SetupVerifyInfFileW + +CONSTANT: DICUSTOMDEVPROP_MERGE_MULTISZ HEX: 00000001 +FUNCTION: BOOL SetupDiGetCustomDevicePropertyA ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PCSTR CustomPropertyName, DWORD Flags, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize ) ; +FUNCTION: BOOL SetupDiGetCustomDevicePropertyW ( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PCWSTR CustomPropertyName, DWORD Flags, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize ) ; +ALIAS: SetupDiGetCustomDeviceProperty SetupDiGetCustomDevicePropertyW + +CONSTANT: SCWMI_CLOBBER_SECURITY HEX: 00000001 +FUNCTION: BOOL SetupConfigureWmiFromInfSectionA ( HINF InfHandle, PCSTR SectionName, DWORD Flags ) ; +FUNCTION: BOOL SetupConfigureWmiFromInfSectionW ( HINF InfHandle, PCWSTR SectionName, DWORD Flags ) ; +ALIAS: SetupConfigureWmiFromInfSection SetupConfigureWmiFromInfSectionW + diff --git a/basis/windows/ddk/setupapi/summary.txt b/basis/windows/ddk/setupapi/summary.txt new file mode 100644 index 0000000000..3a6ad610e7 --- /dev/null +++ b/basis/windows/ddk/setupapi/summary.txt @@ -0,0 +1 @@ +Bindings to the SetupAPI section of the Windows DDK. diff --git a/basis/windows/ddk/setupapi/tags.txt b/basis/windows/ddk/setupapi/tags.txt new file mode 100644 index 0000000000..25fe231655 --- /dev/null +++ b/basis/windows/ddk/setupapi/tags.txt @@ -0,0 +1 @@ +unportable bindings From cdb297f6f3e91ff764d88588319f24e07e9f900a Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 22 Feb 2010 20:39:45 -0800 Subject: [PATCH 203/713] Make scaffolding use set-file-lines so that generated text files end with a newline. --- basis/tools/scaffold/scaffold.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/basis/tools/scaffold/scaffold.factor b/basis/tools/scaffold/scaffold.factor index 9e1d08e352..8fd3e53e19 100644 --- a/basis/tools/scaffold/scaffold.factor +++ b/basis/tools/scaffold/scaffold.factor @@ -94,7 +94,7 @@ M: bad-developer-name summary ] with-string-writer ; : set-scaffold-main-file ( vocab path -- ) - [ main-file-string ] dip utf8 set-file-contents ; + [ main-file-string 1array ] dip utf8 set-file-lines ; : scaffold-main ( vocab-root vocab -- ) [ ".factor" vocab-root/vocab/suffix>path ] keep swap scaffolding? [ @@ -106,8 +106,8 @@ M: bad-developer-name summary : scaffold-metadata ( vocab file contents -- ) [ ensure-vocab-exists ] 2dip [ - [ vocab/file>path ] dip swap scaffolding? [ - utf8 set-file-contents + [ vocab/file>path ] dip 1array swap scaffolding? [ + utf8 set-file-lines ] [ 2drop ] if From ff9fc2713b7f990620df243bc8d884005bbead73 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 22 Feb 2010 21:57:56 -0800 Subject: [PATCH 204/713] cairo.ffi: update references to pointer types in alien-callbacks --- basis/cairo/ffi/ffi.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/basis/cairo/ffi/ffi.factor b/basis/cairo/ffi/ffi.factor index 947869e357..49975afc61 100644 --- a/basis/cairo/ffi/ffi.factor +++ b/basis/cairo/ffi/ffi.factor @@ -38,7 +38,7 @@ TYPEDEF: void* cairo_pattern_t TYPEDEF: void* cairo_destroy_func_t : cairo-destroy-func ( quot -- callback ) - [ void { void* } "cdecl" ] dip alien-callback ; inline + [ void { pointer: void } "cdecl" ] dip alien-callback ; inline ! See cairo.h for details STRUCT: cairo_user_data_key_t @@ -79,11 +79,11 @@ CONSTANT: CAIRO_CONTENT_COLOR_ALPHA HEX: 3000 TYPEDEF: void* cairo_write_func_t : cairo-write-func ( quot -- callback ) - [ cairo_status_t { void* uchar* int } "cdecl" ] dip alien-callback ; inline + [ cairo_status_t { pointer: void pointer: uchar int } "cdecl" ] dip alien-callback ; inline TYPEDEF: void* cairo_read_func_t : cairo-read-func ( quot -- callback ) - [ cairo_status_t { void* uchar* int } "cdecl" ] dip alien-callback ; inline + [ cairo_status_t { pointer: void pointer: uchar int } "cdecl" ] dip alien-callback ; inline ! Functions for manipulating state objects FUNCTION: cairo_t* From aef979b552924bf95ade129676c8452be1124005 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 22 Feb 2010 21:58:18 -0800 Subject: [PATCH 205/713] alien.fortran: update tests to reflect new pointer c-type objects --- basis/alien/fortran/fortran-tests.factor | 59 ++++++++++++------------ 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/basis/alien/fortran/fortran-tests.factor b/basis/alien/fortran/fortran-tests.factor index 80a5ec8bae..dc0585cab8 100644 --- a/basis/alien/fortran/fortran-tests.factor +++ b/basis/alien/fortran/fortran-tests.factor @@ -4,6 +4,7 @@ alien.data alien.fortran alien.fortran.private alien.strings classes.struct arrays assocs byte-arrays combinators fry generalizations io.encodings.ascii kernel macros macros.expander namespaces sequences shuffle tools.test vocabs.parser ; +FROM: alien.syntax => pointer: ; QUALIFIED-WITH: alien.c-types c IN: alien.fortran.tests @@ -100,16 +101,16 @@ intel-unix-abi fortran-abi [ ! fortran-arg-type>c-type - [ c:void* { } ] + [ pointer: c:int { } ] [ "integer" fortran-arg-type>c-type ] unit-test - [ c:void* { } ] + [ pointer: { c:int 3 } { } ] [ "integer(3)" fortran-arg-type>c-type ] unit-test - [ c:void* { } ] + [ pointer: { c:int 0 } { } ] [ "integer(*)" fortran-arg-type>c-type ] unit-test - [ c:void* { } ] + [ pointer: fortran_test_record { } ] [ [ "alien.fortran.tests" use-vocab @@ -117,13 +118,13 @@ intel-unix-abi fortran-abi [ ] with-manifest ] unit-test - [ c:char* { } ] + [ pointer: c:char { } ] [ "character" fortran-arg-type>c-type ] unit-test - [ c:char* { } ] + [ pointer: c:char { } ] [ "character(1)" fortran-arg-type>c-type ] unit-test - [ c:char* { long } ] + [ pointer: { c:char 17 } { long } ] [ "character(17)" fortran-arg-type>c-type ] unit-test ! fortran-ret-type>c-type @@ -131,7 +132,7 @@ intel-unix-abi fortran-abi [ [ c:char { } ] [ "character(1)" fortran-ret-type>c-type ] unit-test - [ c:void { c:char* long } ] + [ c:void { pointer: { c:char 17 } long } ] [ "character(17)" fortran-ret-type>c-type ] unit-test [ c:int { } ] @@ -143,22 +144,22 @@ intel-unix-abi fortran-abi [ [ c:float { } ] [ "real" fortran-ret-type>c-type ] unit-test - [ c:void { c:void* } ] + [ c:void { pointer: { c:float 0 } } ] [ "real(*)" fortran-ret-type>c-type ] unit-test [ c:double { } ] [ "double-precision" fortran-ret-type>c-type ] unit-test - [ c:void { c:void* } ] + [ c:void { pointer: complex-float } ] [ "complex" fortran-ret-type>c-type ] unit-test - [ c:void { c:void* } ] + [ c:void { pointer: complex-double } ] [ "double-complex" fortran-ret-type>c-type ] unit-test - [ c:void { c:void* } ] + [ c:void { pointer: { c:int 0 } } ] [ "integer(*)" fortran-ret-type>c-type ] unit-test - [ c:void { c:void* } ] + [ c:void { pointer: fortran_test_record } ] [ [ "alien.fortran.tests" use-vocab @@ -168,19 +169,19 @@ intel-unix-abi fortran-abi [ ! fortran-sig>c-sig - [ c:float { c:void* c:char* c:void* c:void* c:long } ] + [ c:float { pointer: c:int pointer: { c:char 17 } pointer: c:float pointer: c:double c:long } ] [ "real" { "integer" "character*17" "real" "real*8" } fortran-sig>c-sig ] unit-test - [ c:char { c:char* c:char* c:void* c:long } ] + [ c:char { pointer: { c:char 17 } pointer: c:char pointer: c:int c:long } ] [ "character(1)" { "character*17" "character" "integer" } fortran-sig>c-sig ] unit-test - [ c:void { c:char* c:long c:char* c:char* c:void* c:long } ] + [ c:void { pointer: { c:char 18 } c:long pointer: { c:char 17 } pointer: c:char pointer: c:int c:long } ] [ "character*18" { "character*17" "character" "integer" } fortran-sig>c-sig ] unit-test - [ c:void { c:void* c:char* c:char* c:void* c:long } ] + [ c:void { pointer: complex-float pointer: { c:char 17 } pointer: c:char pointer: c:int c:long } ] [ "complex" { "character*17" "character" "integer" } fortran-sig>c-sig ] unit-test @@ -201,7 +202,7 @@ intel-unix-abi fortran-abi [ ! [fortran-invoke] [ c:void "funpack" "funtimes_" - { c:char* c:void* c:void* c:void* c:void* c:long } + { pointer: { c:char 12 } pointer: c:longlong pointer: c:float pointer: complex-float pointer: c:short c:long } alien-invoke ] 6 nkeep ! [fortran-results>] @@ -226,7 +227,7 @@ intel-unix-abi fortran-abi [ [ { [ drop ] } spread ] } 1 ncleave ! [fortran-invoke] - [ c:float "funpack" "fun_times_" { void* } alien-invoke ] + [ c:float "funpack" "fun_times_" { pointer: { c:float 0 } } alien-invoke ] 1 nkeep ! [fortran-results>] shuffle( reta aa -- reta aa ) @@ -244,7 +245,7 @@ intel-unix-abi fortran-abi [ ! [fortran-invoke] [ c:void "funpack" "fun_times_" - { void* void* } + { pointer: complex-float pointer: { c:float 0 } } alien-invoke ] 2 nkeep ! [fortran-results>] @@ -261,7 +262,7 @@ intel-unix-abi fortran-abi [ ! [fortran-invoke] [ c:void "funpack" "fun_times_" - { c:char* long } + { pointer: { c:char 20 } long } alien-invoke ] 2 nkeep ! [fortran-results>] @@ -287,7 +288,7 @@ intel-unix-abi fortran-abi [ ! [fortran-invoke] [ c:void "funpack" "fun_times_" - { c:char* long c:char* c:void* c:char* c:long c:long } + { pointer: { c:char 10 } long pointer: { c:char 20 } pointer: c:float pointer: { c:char 30 } c:long c:long } alien-invoke ] 7 nkeep ! [fortran-results>] @@ -321,16 +322,16 @@ f2c-abi fortran-abi [ [ { c:char 1 } ] [ "character(1)" fortran-type>c-type ] unit-test - [ c:char* { c:long } ] + [ pointer: c:char { c:long } ] [ "character" fortran-arg-type>c-type ] unit-test - [ c:void { c:char* c:long } ] + [ c:void { pointer: c:char c:long } ] [ "character" fortran-ret-type>c-type ] unit-test [ c:double { } ] [ "real" fortran-ret-type>c-type ] unit-test - [ c:void { void* } ] + [ c:void { pointer: { c:float 0 } } ] [ "real(*)" fortran-ret-type>c-type ] unit-test [ "fun_" ] [ "FUN" fortran-name>symbol-name ] unit-test @@ -344,7 +345,7 @@ gfortran-abi fortran-abi [ [ c:float { } ] [ "real" fortran-ret-type>c-type ] unit-test - [ c:void { void* } ] + [ c:void { pointer: { c:float 0 } } ] [ "real(*)" fortran-ret-type>c-type ] unit-test [ complex-float { } ] @@ -356,10 +357,10 @@ gfortran-abi fortran-abi [ [ { char 1 } ] [ "character(1)" fortran-type>c-type ] unit-test - [ c:char* { c:long } ] + [ pointer: c:char { c:long } ] [ "character" fortran-arg-type>c-type ] unit-test - [ c:void { c:char* c:long } ] + [ c:void { pointer: c:char c:long } ] [ "character" fortran-ret-type>c-type ] unit-test [ complex-float { } ] @@ -368,7 +369,7 @@ gfortran-abi fortran-abi [ [ complex-double { } ] [ "double-complex" fortran-ret-type>c-type ] unit-test - [ c:void { c:void* } ] + [ c:void { pointer: { complex-double 3 } } ] [ "double-complex(3)" fortran-ret-type>c-type ] unit-test ] with-variable From 53e601c5f08bf096ad413ca47ed8066923b55f3f Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 22 Feb 2010 23:55:52 -0800 Subject: [PATCH 206/713] _DARWIN_MAXNAMELEN+1 should actually be _DARWIN_MAXNAMELEN + 1 --- basis/unix/ffi/bsd/macosx/macosx.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/unix/ffi/bsd/macosx/macosx.factor b/basis/unix/ffi/bsd/macosx/macosx.factor index a2e75b6ca6..a7c47f0ff8 100644 --- a/basis/unix/ffi/bsd/macosx/macosx.factor +++ b/basis/unix/ffi/bsd/macosx/macosx.factor @@ -32,7 +32,7 @@ STRUCT: utmpx CONSTANT: __DARWIN_MAXPATHLEN 1024 CONSTANT: __DARWIN_MAXNAMELEN 255 -CONSTANT: __DARWIN_MAXNAMELEN+1 255 +CONSTANT: __DARWIN_MAXNAMELEN+1 256 STRUCT: dirent { d_ino ino_t } From b8bd5fe6301bd48aea30f9f2e485d1536e357e98 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 22 Feb 2010 23:57:10 -0800 Subject: [PATCH 207/713] classes.struct: reader-quot was checking struct-slot-spec for array-ness, not the type! derp --- basis/classes/struct/struct.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/classes/struct/struct.factor b/basis/classes/struct/struct.factor index 3b2fc875c4..204b05517b 100644 --- a/basis/classes/struct/struct.factor +++ b/basis/classes/struct/struct.factor @@ -147,7 +147,7 @@ M: struct-class initial-value* ; inline GENERIC: struct-slot-values ( struct -- sequence ) M: struct-class reader-quot - dup array? [ dup first define-array-vocab drop ] when + dup type>> array? [ dup type>> first define-array-vocab drop ] when nip '[ _ read-struct-slot ] ; M: struct-class writer-quot From 3d97bd2ae0538a6df3233295012bfc6200b93c69 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 00:03:18 -0800 Subject: [PATCH 208/713] add opaque C-TYPEs for sundry interfaces to windows.com --- basis/windows/com/com.factor | 2 ++ 1 file changed, 2 insertions(+) diff --git a/basis/windows/com/com.factor b/basis/windows/com/com.factor index 33164f52c4..094859009d 100644 --- a/basis/windows/com/com.factor +++ b/basis/windows/com/com.factor @@ -11,6 +11,8 @@ COM-INTERFACE: IUnknown f {00000000-0000-0000-C000-000000000046} ULONG Release ( ) ; C-TYPE: IAdviseSink +C-TYPE: IEnumFORMATETC +C-TYPE: IEnumSTATDATA COM-INTERFACE: IDataObject IUnknown {0000010E-0000-0000-C000-000000000046} HRESULT GetData ( FORMATETC* pFormatetc, STGMEDIUM* pmedium ) From 050d0424499cbd7696c475a71f2d638eb3cc2a0f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 23 Feb 2010 21:19:06 +1300 Subject: [PATCH 209/713] formatting: fix docs --- basis/formatting/formatting-docs.factor | 2 +- basis/formatting/formatting.factor | 26 ++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/basis/formatting/formatting-docs.factor b/basis/formatting/formatting-docs.factor index 47720ad671..9625c40577 100644 --- a/basis/formatting/formatting-docs.factor +++ b/basis/formatting/formatting-docs.factor @@ -36,7 +36,7 @@ HELP: printf "For example:\n" { $list "\"%5s\" formats a string padding with spaces up to 5 characters wide." - "\"%08d\" formats an integer padding with zeros up to 3 characters wide." + "\"%03d\" formats an integer padding with zeros up to 3 characters wide." "\"%'#5f\" formats a float padding with '#' up to 3 characters wide." "\"%-10d\" formats an integer to 10 characters wide and left-aligns." } diff --git a/basis/formatting/formatting.factor b/basis/formatting/formatting.factor index 40279749d6..ec3c9f1d8e 100644 --- a/basis/formatting/formatting.factor +++ b/basis/formatting/formatting.factor @@ -12,18 +12,18 @@ IN: formatting [ ] [ compose ] reduce ; : fix-sign ( string -- string ) - dup CHAR: 0 swap index 0 = + dup CHAR: 0 swap index 0 = [ dup 0 swap [ [ CHAR: 0 = not ] keep digit? and ] find-from [ dup 1 - rot dup [ nth ] dip swap { { CHAR: - [ [ 1 - ] dip remove-nth "-" prepend ] } { CHAR: + [ [ 1 - ] dip remove-nth "+" prepend ] } - [ drop swap drop ] - } case + [ drop swap drop ] + } case ] [ drop ] if ] when ; -: >digits ( string -- digits ) +: >digits ( string -- digits ) [ 0 ] [ string>number ] if-empty ; : pad-digits ( string digits -- string' ) @@ -33,20 +33,20 @@ IN: formatting 10^ [ * round ] keep / ; inline : >exp ( x -- exp base ) - [ + [ abs 0 swap [ dup [ 10.0 >= ] [ 1.0 < ] bi or ] [ dup 10.0 >= [ 10.0 / [ 1 + ] dip ] [ 10.0 * [ 1 - ] dip ] if - ] while + ] while ] keep 0 < [ neg ] when ; : exp>string ( exp base digits -- string ) [ max-digits ] keep -rot [ [ 0 < "-" "+" ? ] - [ abs number>string 2 CHAR: 0 pad-head ] bi + [ abs number>string 2 CHAR: 0 pad-head ] bi "e" -rot 3append ] [ number>string ] bi* @@ -58,19 +58,19 @@ zero = "0" => [[ CHAR: 0 ]] char = "'" (.) => [[ second ]] pad-char = (zero|char)? => [[ CHAR: \s or ]] -pad-align = ("-")? => [[ \ pad-tail \ pad-head ? ]] +pad-align = ("-")? => [[ \ pad-tail \ pad-head ? ]] pad-width = ([0-9])* => [[ >digits ]] pad = pad-align pad-char pad-width => [[ reverse >quotation dup first 0 = [ drop [ ] ] when ]] sign = ("+")? => [[ [ dup CHAR: - swap index [ "+" prepend ] unless ] [ ] ? ]] width_ = "." ([0-9])* => [[ second >digits '[ _ short head ] ]] -width = (width_)? => [[ [ ] or ]] +width = (width_)? => [[ [ ] or ]] digits_ = "." ([0-9])* => [[ second >digits ]] digits = (digits_)? => [[ 6 or ]] -fmt-% = "%" => [[ [ "%" ] ]] +fmt-% = "%" => [[ [ "%" ] ]] fmt-c = "c" => [[ [ 1string ] ]] fmt-C = "C" => [[ [ 1string >upper ] ]] fmt-s = "s" => [[ [ dup number? [ number>string ] when ] ]] @@ -78,7 +78,7 @@ fmt-S = "S" => [[ [ dup number? [ number>string ] when >upp fmt-d = "d" => [[ [ >fixnum number>string ] ]] fmt-e = digits "e" => [[ first '[ >exp _ exp>string ] ]] fmt-E = digits "E" => [[ first '[ >exp _ exp>string >upper ] ]] -fmt-f = digits "f" => [[ first dup '[ >float _ max-digits number>string _ pad-digits ] ]] +fmt-f = digits "f" => [[ first dup '[ >float _ max-digits number>string _ pad-digits ] ]] fmt-x = "x" => [[ [ >hex ] ]] fmt-X = "X" => [[ [ >hex >upper ] ]] unknown = (.)* => [[ "Unknown directive" throw ]] @@ -89,9 +89,9 @@ strings = pad width strings_ => [[ reverse compose-all ]] numbers_ = fmt-d|fmt-e|fmt-E|fmt-f|fmt-x|fmt-X numbers = sign pad numbers_ => [[ unclip-last prefix compose-all [ fix-sign ] append ]] -types = strings|numbers +types = strings|numbers -lists = "[%" types ", %]" => [[ second '[ _ map ", " join "{ " prepend " }" append ] ]] +lists = "[%" types ", %]" => [[ second '[ _ map ", " join "{ " prepend " }" append ] ]] assocs = "[%" types ": %" types " %]" => [[ [ second ] [ fourth ] bi '[ unzip [ _ map ] dip _ map zip [ ":" join ] map ", " join "{ " prepend " }" append ] ]] From f0aa694c7e8f253aa0909585cd6655435798fcef Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 23 Feb 2010 23:57:13 +1300 Subject: [PATCH 210/713] effects.parser: throw a proper no-word error if effect references an unknown class word --- basis/macros/macros.factor | 6 +++--- basis/memoize/memoize.factor | 6 +++--- basis/peg/peg.factor | 6 +++--- basis/promises/promises.factor | 2 +- basis/typed/typed.factor | 2 +- core/effects/parser/parser.factor | 12 ++++++++---- core/parser/parser.factor | 7 +------ 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/basis/macros/macros.factor b/basis/macros/macros.factor index 91ca2f301c..9137588e6c 100644 --- a/basis/macros/macros.factor +++ b/basis/macros/macros.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2007, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: parser kernel sequences words effects combinators assocs -definitions quotations namespaces memoize accessors fry -compiler.units ; +USING: parser effects.parser kernel sequences words effects +combinators assocs definitions quotations namespaces memoize +accessors fry compiler.units ; IN: macros tuple-layout ; IN: typed diff --git a/core/effects/parser/parser.factor b/core/effects/parser/parser.factor index a77ea34c30..842d4f6447 100644 --- a/core/effects/parser/parser.factor +++ b/core/effects/parser/parser.factor @@ -1,7 +1,7 @@ -! Copyright (C) 2008, 2009 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: lexer sets sequences kernel splitting effects -combinators arrays vocabs.parser classes ; +combinators arrays vocabs.parser classes parser ; IN: effects.parser DEFER: parse-effect @@ -14,9 +14,8 @@ ERROR: bad-effect ; ":" ?tail [ scan { { [ dup "(" = ] [ drop ")" parse-effect ] } - { [ dup search class? ] [ search ] } { [ dup f = ] [ ")" unexpected-eof ] } - [ bad-effect ] + [ parse-word dup class? [ bad-effect ] unless ] } cond 2array ] when ] if @@ -36,3 +35,8 @@ ERROR: stack-effect-omits-dashes tokens ; : parse-call( ( accum word -- accum ) [ ")" parse-effect ] dip 2array append! ; + +: (:) ( -- word def effect ) + CREATE-WORD + complete-effect + parse-definition swap ; diff --git a/core/parser/parser.factor b/core/parser/parser.factor index 544d75b244..e3e7d79c40 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -5,7 +5,7 @@ sequences strings vectors words words.symbol quotations io combinators sorting splitting math.parser effects continuations io.files vocabs io.encodings.utf8 source-files classes hashtables compiler.units accessors sets lexer vocabs.parser -effects.parser slots parser.notes ; + slots parser.notes ; IN: parser : location ( -- loc ) @@ -102,11 +102,6 @@ M: f parse-quotation \ ] parse-until >quotation ; : parse-definition ( -- quot ) \ ; parse-until >quotation ; -: (:) ( -- word def effect ) - CREATE-WORD - complete-effect - parse-definition swap ; - ERROR: bad-number ; : scan-base ( base -- n ) From ae25cfe7127ae4fdecebcc6d2fe24c6e8469bb4f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 24 Feb 2010 00:16:55 +1300 Subject: [PATCH 211/713] Get foldable and flushable declarations working on typed words --- .../tree/propagation/simple/simple.factor | 2 +- basis/typed/typed-tests.factor | 29 +++++++++++++++- basis/typed/typed.factor | 12 +++---- core/effects/effects.factor | 9 +++-- core/generic/generic-tests.factor | 13 ++++++++ core/generic/generic.factor | 12 ++----- core/words/words.factor | 33 +++++++++++++------ 7 files changed, 80 insertions(+), 30 deletions(-) diff --git a/basis/compiler/tree/propagation/simple/simple.factor b/basis/compiler/tree/propagation/simple/simple.factor index ed417ef9d7..ce169233c1 100644 --- a/basis/compiler/tree/propagation/simple/simple.factor +++ b/basis/compiler/tree/propagation/simple/simple.factor @@ -72,7 +72,7 @@ M: #declare propagate-before : foldable-call? ( #call word -- ? ) { - [ nip "foldable" word-prop ] + [ nip foldable? ] [ drop literal-inputs? ] [ input-classes-match? ] } 2&& ; diff --git a/basis/typed/typed-tests.factor b/basis/typed/typed-tests.factor index 7f984ccaf2..28ec2b6e86 100644 --- a/basis/typed/typed-tests.factor +++ b/basis/typed/typed-tests.factor @@ -1,5 +1,6 @@ USING: accessors effects eval kernel layouts math namespaces -quotations tools.test typed words ; +quotations tools.test typed words words.symbol +compiler.tree.debugger prettyprint ; IN: typed.tests TYPED: f+ ( a: float b: float -- c: float ) @@ -122,3 +123,29 @@ TYPED: recompile-fail ( a: subclass -- ? ) buh get eq? ; [ ] [ "IN: typed.tests TUPLE: subclass < superclass { y read-only } ;" eval( -- ) ] unit-test [ t ] [ subclass new [ buh set ] [ recompile-fail ] bi ] unit-test + +! Make sure that foldable and flushable work on typed words +TYPED: add ( a: integer b: integer -- c: integer ) + ; foldable + +[ [ 3 ] ] [ [ 1 2 add ] cleaned-up-tree nodes>quot ] unit-test + +TYPED: flush-test ( s: symbol -- ? ) on t ; flushable + +: flush-print-1 ( symbol -- ) flush-test drop ; +: flush-print-2 ( symbol -- ) flush-test . ; + +SYMBOL: a-symbol + +[ f ] [ + f a-symbol [ + a-symbol flush-print-1 + a-symbol get + ] with-variable +] unit-test + +[ t ] [ + f a-symbol [ + a-symbol flush-print-2 + a-symbol get + ] with-variable +] unit-test diff --git a/basis/typed/typed.factor b/basis/typed/typed.factor index e104c69da9..6ab4e0334d 100644 --- a/basis/typed/typed.factor +++ b/basis/typed/typed.factor @@ -11,8 +11,8 @@ ERROR: type-mismatch-error word expected-types ; ERROR: input-mismatch-error < type-mismatch-error ; ERROR: output-mismatch-error < type-mismatch-error ; -PREDICATE: typed-gensym < word "typed-gensym" word-prop ; -PREDICATE: typed-word < word "typed-word" word-prop ; +PREDICATE: typed-gensym < word "typed-gensym" word-prop >boolean ; +PREDICATE: typed-word < word "typed-word" word-prop >boolean ; ; -M: typed-gensym stack-effect - call-next-method unboxed-effect ; -M: typed-gensym crossref? - "typed-gensym" word-prop crossref? ; +M: typed-gensym stack-effect call-next-method unboxed-effect ; +M: typed-gensym parent-word "typed-gensym" word-prop ; +M: typed-gensym crossref? parent-word crossref? ; +M: typed-gensym where parent-word where ; : define-typed-gensym ( word def effect -- gensym ) [ 2drop dup ] diff --git a/core/effects/effects.factor b/core/effects/effects.factor index 1790399e04..fea50d2981 100644 --- a/core/effects/effects.factor +++ b/core/effects/effects.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2006, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel math math.parser math.order namespaces make sequences strings -words assocs combinators accessors arrays quotations ; +USING: kernel math math.parser math.order namespaces make +sequences strings words assocs combinators accessors arrays +quotations ; IN: effects TUPLE: effect @@ -64,7 +65,9 @@ M: pair effect>type second effect>type ; GENERIC: stack-effect ( word -- effect/f ) -M: word stack-effect "declared-effect" word-prop ; +M: word stack-effect + [ "declared-effect" word-prop ] + [ parent-word dup [ stack-effect ] when ] bi or ; M: deferred stack-effect call-next-method (( -- * )) or ; diff --git a/core/generic/generic-tests.factor b/core/generic/generic-tests.factor index 700448805c..805c3a4be4 100644 --- a/core/generic/generic-tests.factor +++ b/core/generic/generic-tests.factor @@ -212,3 +212,16 @@ M: integer forget-test 3 + ; ] unit-test [ 10 forget-test ] [ no-method? ] must-fail-with + +! Declarations on methods +GENERIC: flushable-generic ( a -- b ) flushable +M: integer flushable-generic ; + +[ t ] [ \ flushable-generic flushable? ] unit-test +[ t ] [ M\ integer flushable-generic flushable? ] unit-test + +GENERIC: non-flushable-generic ( a -- b ) +M: integer non-flushable-generic ; flushable + +[ f ] [ \ non-flushable-generic flushable? ] unit-test +[ t ] [ M\ integer non-flushable-generic flushable? ] unit-test diff --git a/core/generic/generic.factor b/core/generic/generic.factor index 9fd7a5be85..0c626ac1d6 100644 --- a/core/generic/generic.factor +++ b/core/generic/generic.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2006, 2009 Slava Pestov. +! Copyright (C) 2006, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors words kernel sequences namespaces make assocs hashtables definitions kernel.private classes classes.private @@ -104,11 +104,8 @@ GENERIC: update-generic ( class generic -- ) : method-word-name ( class generic -- string ) [ name>> ] bi@ "=>" glue ; -M: method flushable? - "method-generic" word-prop flushable? ; - -M: method stack-effect - "method-generic" word-prop stack-effect ; +M: method parent-word + "method-generic" word-prop ; M: method crossref? "forgotten" word-prop not ; @@ -196,8 +193,5 @@ M: generic subwords tri ] { } make ; -M: generic forget* - [ subwords forget-all ] [ call-next-method ] bi ; - M: class forget-methods [ implementors ] [ [ swap method ] curry ] bi map forget-all ; diff --git a/core/words/words.factor b/core/words/words.factor index 5b057230fe..2a4c2c4c06 100644 --- a/core/words/words.factor +++ b/core/words/words.factor @@ -73,12 +73,14 @@ GENERIC: crossref? ( word -- ? ) M: word crossref? dup "forgotten" word-prop [ drop f ] [ vocabulary>> >boolean ] if ; -: inline? ( word -- ? ) "inline" word-prop ; inline - GENERIC: subwords ( word -- seq ) M: word subwords drop f ; +GENERIC: parent-word ( word -- word/f ) + +M: word parent-word drop f ; + : define ( word def -- ) over changed-definition [ ] like >>def drop ; @@ -100,6 +102,8 @@ M: word subwords drop f ; : make-deprecated ( word -- ) t "deprecated" set-word-prop ; +: inline? ( word -- ? ) "inline" word-prop ; inline + ERROR: cannot-be-inline word ; GENERIC: make-inline ( word -- ) @@ -111,22 +115,30 @@ M: word make-inline bi ] if ; +: define-inline ( word def effect -- ) + [ define-declared ] [ 2drop make-inline ] 3bi ; + : make-recursive ( word -- ) t "recursive" set-word-prop ; +GENERIC: flushable? ( word -- ? ) + +M: word flushable? + [ "flushable" word-prop ] + [ parent-word dup [ flushable? ] when ] bi or ; + : make-flushable ( word -- ) t "flushable" set-word-prop ; +GENERIC: foldable? ( word -- ? ) + +M: word foldable? + [ "foldable" word-prop ] + [ parent-word dup [ foldable? ] when ] bi or ; + : make-foldable ( word -- ) dup make-flushable t "foldable" set-word-prop ; -: define-inline ( word def effect -- ) - [ define-declared ] [ 2drop make-inline ] 3bi ; - -GENERIC: flushable? ( word -- ? ) - -M: word flushable? "flushable" word-prop ; - GENERIC: reset-word ( word -- ) M: word reset-word @@ -208,9 +220,10 @@ M: word set-where swap "loc" set-word-prop ; M: word forget* dup "forgotten" word-prop [ drop ] [ + [ subwords forget-all ] [ [ name>> ] [ vocabulary>> vocab-words ] bi delete-at ] [ t "forgotten" set-word-prop ] - bi + tri ] if ; M: word hashcode* From 282f284515c90cadf4b1e262087ee8469f80b348 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 24 Feb 2010 00:46:11 +1300 Subject: [PATCH 212/713] freetype: fix load error --- extra/freetype/freetype.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/freetype/freetype.factor b/extra/freetype/freetype.factor index 23dd62b340..955672d03b 100644 --- a/extra/freetype/freetype.factor +++ b/extra/freetype/freetype.factor @@ -166,7 +166,7 @@ STRUCT: FT_Bitmap { palette_mode char } { palette void* } ; -TYPEDEF: void* FT_Face* +C-TYPE: FT_Face FUNCTION: FT_Error FT_New_Face ( void* library, FT_Char* font, FT_Long index, face* face ) ; From 75e2a5098ec13b43e8639efd34e0f307585713b5 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 08:09:33 -0800 Subject: [PATCH 213/713] if any typedef in the chain has a pointer-c-type, use it --- basis/alien/c-types/c-types-tests.factor | 8 ++++++++ basis/alien/c-types/c-types.factor | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/basis/alien/c-types/c-types-tests.factor b/basis/alien/c-types/c-types-tests.factor index ad53dc487b..10a7b50ebb 100644 --- a/basis/alien/c-types/c-types-tests.factor +++ b/basis/alien/c-types/c-types-tests.factor @@ -44,6 +44,14 @@ TYPEDEF: char MyFunkyChar [ f ] [ pointer: char c-type pointer: MyFunkyChar c-type = ] unit-test [ { char* ascii } ] [ pointer: MyFunkyChar c-type ] unit-test +TYPEDEF: MyFunkyChar MyFunkyTypedef + +[ { char* ascii } ] [ pointer: MyFunkyTypedef c-type ] unit-test + +TYPEDEF: MyFunkyChar* MyFunkyString + +[ { char* ascii } ] [ MyFunkyString c-type ] unit-test + TYPEDEF: char* MyString [ t ] [ char* c-type MyString c-type = ] unit-test diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor index 316377dc27..3255d16d80 100644 --- a/basis/alien/c-types/c-types.factor +++ b/basis/alien/c-types/c-types.factor @@ -301,7 +301,7 @@ CONSTANT: primitive-types : special-pointer-type ( type -- special-type ) dup c-type-word? [ dup "pointer-c-type" word-prop - [ ] [ resolve-pointer-typedef "pointer-c-type" word-prop ] ?if + [ ] [ "c-type" word-prop special-pointer-type ] ?if ] [ drop f ] if ; : primitive-pointer-type? ( type -- ? ) From 8aa10c528312c8e12020c9306ce70136d08e049e Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 08:10:01 -0800 Subject: [PATCH 214/713] windows.types: fix definition of wchar_t* as { char* utf16n } --- basis/windows/types/types.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/windows/types/types.factor b/basis/windows/types/types.factor index 4f527513fc..d0dac31ea9 100644 --- a/basis/windows/types/types.factor +++ b/basis/windows/types/types.factor @@ -11,7 +11,7 @@ TYPEDEF: uchar UCHAR TYPEDEF: uchar BYTE TYPEDEF: ushort wchar_t -TYPEDEF: { char* utf16n } wchar_t* +<< { char* utf16n } pointer: wchar_t typedef >> TYPEDEF: wchar_t WCHAR From 00a7559d55bcdb92872273f3697e91c764434102 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 10:16:18 -0800 Subject: [PATCH 215/713] have TYPEDEF:, STRUCT: etc. throw an error if you try to define a c type name ending with asterisk --- basis/alien/parser/parser.factor | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index 14078f3137..f5fdced048 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -46,8 +46,14 @@ IN: alien.parser "callback-library" } reset-props ; +ERROR: *-in-c-type-name name ; + +: validate-c-type-name ( name -- name ) + dup "*" tail? + [ *-in-c-type-name ] when ; + : CREATE-C-TYPE ( -- word ) - scan current-vocab create { + scan validate-c-type-name current-vocab create { [ fake-definition ] [ set-word ] [ reset-c-type ] From b0bf5f310606545607b74d363b76202bf5674218 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 10:17:48 -0800 Subject: [PATCH 216/713] get rid of the last few pointer typedefs in db.postgresql.ffi, windows.usp10, and windows.winsock --- basis/db/postgresql/ffi/ffi.factor | 1 - basis/windows/usp10/usp10.factor | 2 +- basis/windows/winsock/winsock.factor | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/basis/db/postgresql/ffi/ffi.factor b/basis/db/postgresql/ffi/ffi.factor index f4a55e3280..69ac2c5e5e 100644 --- a/basis/db/postgresql/ffi/ffi.factor +++ b/basis/db/postgresql/ffi/ffi.factor @@ -63,7 +63,6 @@ C-TYPE: PGconn C-TYPE: PGresult C-TYPE: PGcancel TYPEDEF: uint Oid -TYPEDEF: uint* Oid* TYPEDEF: char pqbool C-TYPE: PQconninfoOption C-TYPE: PGnotify diff --git a/basis/windows/usp10/usp10.factor b/basis/windows/usp10/usp10.factor index 57702d8780..1c33aaf940 100644 --- a/basis/windows/usp10/usp10.factor +++ b/basis/windows/usp10/usp10.factor @@ -57,7 +57,7 @@ SCRIPT_JUSTIFFY_RESERVED4 ; STRUCT: SCRIPT_VISATTR { flags WORD } ; -TYPEDEF: void* SCRIPT_CACHE* +C-TYPE: SCRIPT_CACHE C-TYPE: ABC FUNCTION: HRESULT ScriptShape ( diff --git a/basis/windows/winsock/winsock.factor b/basis/windows/winsock/winsock.factor index b8d1f099d2..818737ca5a 100644 --- a/basis/windows/winsock/winsock.factor +++ b/basis/windows/winsock/winsock.factor @@ -141,7 +141,7 @@ STRUCT: timeval { sec long } { usec long } ; -TYPEDEF: void* fd_set* +C-TYPE: fd_set LIBRARY: winsock From 818bbb4984e556fbdb7f46a6a5a2d42e704ac904 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 11:03:48 -0800 Subject: [PATCH 217/713] update docs about pointer types --- basis/alien/c-types/c-types-docs.factor | 21 +++++++++++++++++---- basis/alien/syntax/syntax-docs.factor | 8 ++++---- core/alien/alien-docs.factor | 4 ++-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/basis/alien/c-types/c-types-docs.factor b/basis/alien/c-types/c-types-docs.factor index 215ca1b0ef..f0a339b1aa 100644 --- a/basis/alien/c-types/c-types-docs.factor +++ b/basis/alien/c-types/c-types-docs.factor @@ -103,7 +103,7 @@ HELP: ulonglong HELP: void { $description "This symbol is not a valid C type, but it can be used as the return type for a " { $link POSTPONE: FUNCTION: } " or " { $link POSTPONE: CALLBACK: } " definition or for an " { $link alien-invoke } " or " { $link alien-callback } " call." } ; HELP: void* -{ $description "This C type represents a pointer to C memory. " { $link byte-array } " and " { $link alien } " values can be passed as " { $snippet "void*" } " function inputs, but see " { $link "byte-arrays-gc" } " for notes about passing byte arrays into C functions. " { $snippet "void*" } " output values are returned as " { $link alien } "s." } ; +{ $description "This C type represents a generic pointer to C memory. See " { $link pointer } " for information on pointer C types." } HELP: char* { $description "This C type represents a pointer to a C string. See " { $link "c-strings" } " for details about using strings with the FFI." } ; HELP: float @@ -115,6 +115,19 @@ HELP: complex-float HELP: complex-double { $description "This C type represents a double-precision IEEE 754 floating-point complex type. Input values will be converted from Factor " { $link math:complex } " objects into a double-precision complex float type; output values will be returned as Factor " { $link math:complex } " objects." } ; +HELP: pointer: +{ $syntax "pointer: c-type" } +{ $description "Constructs a " { $link pointer } " C type." } ; + +HELP: pointer +{ $class-description "Represents a pointer C type. The " { $snippet "to" } " slot contains the C type being pointed to." { $link byte-array } " and " { $link alien } " values can be provided as pointer function inputs, but see " { $link "byte-arrays-gc" } " for notes about passing byte arrays into C functions. Objects with methods on " { $link >c-ptr } ", such as structs and specialized arrays, may also be used as pointer inputs." +$nl +"Pointer output values are represented in Factor as " { $link alien } "s. If the pointed-to type is a struct, the alien will automatically be wrapped in a struct object if it is not null." +$nl +"In " { $link POSTPONE: TYPEDEF: } ", " { $link POSTPONE: FUNCTION: } ", " { $link POSTPONE: CALLBACK: } ", and " { $link POSTPONE: STRUCT: } " definitions, pointer types can be created by suffixing " { $snippet "*" } " to a C type name. Outside of FFI definitions, a pointer C type can be created using the " { $link POSTPONE: pointer: } " syntax word:" +{ $unchecked-example "FUNCTION: int* foo ( char* bar ) ;" } +{ $unchecked-example """: foo ( bar -- int* ) + pointer: int f \"foo\" { pointer: char } alien-invoke ;""" } } ; ARTICLE: "byte-arrays-gc" "Byte arrays and the garbage collector" "The Factor garbage collector can move byte arrays around, and it is only safe to pass byte arrays to C functions if the garbage collector will not run while C code still has a reference to the data." @@ -191,11 +204,11 @@ ARTICLE: "c-types.primitives" "Primitive C types" "When making alien calls, Factor numbers are converted to and from the above types in a canonical way. Converting a Factor number to a C value may result in a loss of precision." ; ARTICLE: "c-types.pointers" "Pointer and array types" -"Pointer types are specified by suffixing a C type with " { $snippet "*" } ", for example " { $snippet "float*" } ". One special case is " { $link void* } ", which denotes a generic pointer; " { $link void } " by itself is not a valid C type specifier. With the exception of strings (see " { $link "c-strings" } "), all pointer types are identical to " { $snippet "void*" } " as far as the C library interface is concerned." +"Pointer types are specified by suffixing a C type with " { $snippet "*" } ", for example " { $snippet "float*" } ". One special case is " { $link void* } ", which denotes a generic pointer; " { $link void } " by itself is not a valid C type specifier. This syntax constructs a " { $link pointer } " object to represent the C type." $nl "Fixed-size array types are supported; the syntax consists of a C type name followed by dimension sizes in brackets; the following denotes a 3 by 4 array of integers:" { $code "int[3][4]" } -"Fixed-size arrays differ from pointers in that they are allocated inside structures and unions; however when used as function parameters they behave exactly like pointers and thus the dimensions only serve as documentation." ; +"Fixed-size arrays differ from pointers in that they are allocated inside structures and unions; however, when used as function parameters, they behave exactly like pointers with the dimensions only serving as documentation." ; ARTICLE: "c-types.ambiguity" "Word name clashes with C types" "Note that some of the C type word names clash with commonly-used Factor words:" @@ -228,7 +241,7 @@ ARTICLE: "c-types.structs" "Struct and union types" "Struct and union types are identified by their class word. See " { $link "classes.struct" } "." ; ARTICLE: "c-types-specs" "C type specifiers" -"C types are identified by special words, and type names occur as parameters to the " { $link alien-invoke } ", " { $link alien-indirect } " and " { $link alien-callback } " words." +"C types are identified by special words. Type names occur as parameters to the " { $link alien-invoke } ", " { $link alien-indirect } " and " { $link alien-callback } " words." $nl "Defining new C types:" { $subsections diff --git a/basis/alien/syntax/syntax-docs.factor b/basis/alien/syntax/syntax-docs.factor index a8d3048b82..8ec67d2f65 100644 --- a/basis/alien/syntax/syntax-docs.factor +++ b/basis/alien/syntax/syntax-docs.factor @@ -54,7 +54,7 @@ $nl HELP: TYPEDEF: { $syntax "TYPEDEF: old new" } { $values { "old" "a C type" } { "new" "a C type" } } -{ $description "Aliases the C type " { $snippet "old" } " under the name " { $snippet "new" } " if ." } +{ $description "Aliases the C type " { $snippet "old" } " under the name " { $snippet "new" } "." } { $notes "This word differs from " { $link typedef } " in that it runs at parse time, to ensure correct ordering of operations when loading source files. Words defined in source files are compiled before top-level forms are run, so if a source file defines C binding words and uses " { $link typedef } ", the type alias won't be available at compile time." } ; HELP: C-ENUM: @@ -72,12 +72,12 @@ HELP: C-ENUM: HELP: C-TYPE: { $syntax "C-TYPE: type" } { $values { "type" "a new C type" } } -{ $description "Defines a new, opaque C type. Since it is opaque, " { $snippet "type" } " will not be directly usable as a parameter or return type of a " { $link POSTPONE: FUNCTION: } " or as a slot of a " { $link POSTPONE: STRUCT: } ". However, it can be used as the type of a pointer (that is, as " { $snippet "type*" } ")." $nl -{ $snippet "C-TYPE:" } " can also be used to forward-declare C types to enable circular dependencies. For example:" +{ $description "Defines a new, opaque C type. Since it is opaque, " { $snippet "type" } " will not be directly usable as a parameter or return type of a " { $link POSTPONE: FUNCTION: } " or as a slot of a " { $link POSTPONE: STRUCT: } ". However, it can be used as the type of a " { $link pointer } "." +{ $snippet "C-TYPE:" } " can also be used to forward declare C types, allowing circular dependencies to occur between types. For example:" { $code """C-TYPE: forward STRUCT: backward { x forward* } ; STRUCT: forward { x backward* } ; """ } } -{ $notes "Primitive C types are also displayed using " { $snippet "C-TYPE:" } " syntax when they are displayed by " { $link see } "." } ; +{ $notes "Primitive C types are displayed using " { $snippet "C-TYPE:" } " syntax when they are " { $link see } "n." } ; HELP: CALLBACK: { $syntax "CALLBACK: return type ( parameters ) ;" } diff --git a/core/alien/alien-docs.factor b/core/alien/alien-docs.factor index 98292b8728..0b4976fcbe 100644 --- a/core/alien/alien-docs.factor +++ b/core/alien/alien-docs.factor @@ -42,7 +42,7 @@ HELP: { $notes "Alien objects are invalidated between image saves and loads." } ; HELP: c-ptr -{ $class-description "Class of objects consisting of aliens, byte arrays and " { $link f } ". These objects can convert to pointer C types, which are all aliases of " { $snippet "void*" } "." } ; +{ $class-description "Class of objects consisting of aliens, byte arrays and " { $link f } ". These objects all can be used as values of " { $link pointer } " C types." } ; HELP: alien-invoke-error { $error-description "Thrown if the word calling " { $link alien-invoke } " was not compiled with the optimizing compiler. This may be a result of one of several failure conditions:" @@ -136,7 +136,7 @@ ARTICLE: "aliens" "Alien addresses" } "Anywhere that a " { $link alien } " instance is accepted, the " { $link f } " singleton may be passed in to denote a null pointer." $nl -"Usually alien objects do not have to created and dereferenced directly; instead declaring C function parameters and return values as having a pointer type such as " { $snippet "void*" } " takes care of the details." +"Usually alien objects do not have to created and dereferenced directly; instead declaring C function parameters and return values as having a " pointer type such as " { $snippet "void*" } " takes care of the details." { $subsections "syntax-aliens" "alien-expiry" From 4cfa1a6c77465f75745da24ce92456bae7258e10 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 11:42:02 -0800 Subject: [PATCH 218/713] rename current string-mangling "char*" to "c-string". char* is now just a boring old pointer to char --- basis/alien/arrays/arrays.factor | 8 +- basis/alien/c-types/c-types-docs.factor | 2 +- basis/alien/c-types/c-types-tests.factor | 27 +--- basis/alien/c-types/c-types.factor | 6 +- basis/alien/data/data-docs.factor | 10 +- basis/alien/parser/parser-tests.factor | 4 +- .../remote-control/remote-control.factor | 2 +- basis/alien/syntax/syntax-docs.factor | 4 +- basis/cairo/ffi/ffi.factor | 26 ++-- basis/classes/struct/struct-docs.factor | 2 +- basis/classes/struct/struct-tests.factor | 2 +- basis/cocoa/messages/messages.factor | 2 +- basis/cocoa/runtime/runtime.factor | 16 +-- basis/compiler/tests/alien.factor | 4 +- basis/core-foundation/data/data.factor | 2 +- basis/core-foundation/strings/strings.factor | 4 +- basis/db/postgresql/ffi/ffi.factor | 124 +++++++++--------- basis/db/sqlite/ffi/ffi.factor | 18 +-- basis/iokit/hid/hid.factor | 18 +-- basis/iokit/iokit.factor | 8 +- basis/libc/libc.factor | 2 +- basis/opengl/gl/gl.factor | 2 +- basis/opengl/gl/windows/windows.factor | 2 +- basis/openssl/libcrypto/libcrypto.factor | 14 +- basis/openssl/libssl/libssl.factor | 20 +-- basis/pango/fonts/fonts.factor | 12 +- basis/pango/layouts/layouts.factor | 4 +- basis/system-info/linux/linux.factor | 2 +- basis/tools/disassembler/udis/udis.factor | 12 +- basis/unix/ffi/bsd/bsd.factor | 12 +- basis/unix/ffi/bsd/freebsd/freebsd.factor | 2 +- basis/unix/ffi/bsd/macosx/macosx.factor | 2 +- basis/unix/ffi/bsd/netbsd/netbsd.factor | 2 +- basis/unix/ffi/bsd/openbsd/openbsd.factor | 2 +- basis/unix/ffi/ffi.factor | 70 +++++----- basis/unix/ffi/linux/linux.factor | 14 +- basis/unix/ffi/solaris/solaris.factor | 2 +- basis/unix/linux/inotify/inotify.factor | 2 +- basis/unix/process/process.factor | 6 +- basis/unix/stat/freebsd/freebsd.factor | 4 +- basis/unix/stat/linux/32/32.factor | 4 +- basis/unix/stat/linux/64/64.factor | 4 +- basis/unix/stat/macosx/macosx.factor | 4 +- basis/unix/stat/netbsd/32/32.factor | 4 +- basis/unix/stat/netbsd/64/64.factor | 4 +- basis/unix/stat/openbsd/openbsd.factor | 4 +- basis/unix/statfs/freebsd/freebsd.factor | 2 +- basis/unix/statfs/linux/linux.factor | 2 +- basis/unix/statfs/macosx/macosx.factor | 2 +- basis/unix/statfs/openbsd/openbsd.factor | 2 +- basis/unix/statvfs/freebsd/freebsd.factor | 2 +- basis/unix/statvfs/linux/linux.factor | 2 +- basis/unix/statvfs/macosx/macosx.factor | 2 +- basis/unix/statvfs/netbsd/netbsd.factor | 2 +- basis/unix/statvfs/openbsd/openbsd.factor | 2 +- basis/unix/time/time.factor | 2 +- basis/windows/kernel32/kernel32.factor | 2 +- basis/windows/ole32/ole32.factor | 4 +- basis/windows/opengl32/opengl32.factor | 2 +- basis/windows/types/types.factor | 23 ++-- basis/windows/user32/user32.factor | 6 +- basis/windows/winsock/winsock.factor | 20 +-- basis/x11/glx/glx.factor | 10 +- basis/x11/xlib/xlib.factor | 42 +++--- extra/chipmunk/chipmunk.factor | 2 +- extra/curses/ffi/ffi.factor | 48 +++---- extra/freetype/freetype.factor | 2 +- extra/libusb/libusb.factor | 16 +-- extra/llvm/core/core.factor | 114 ++++++++-------- extra/llvm/engine/engine.factor | 8 +- extra/llvm/types/types.factor | 2 +- extra/llvm/wrappers/wrappers.factor | 2 +- .../native-thread-test.factor | 2 +- extra/ogg/ogg.factor | 22 ++-- extra/ogg/theora/theora.factor | 16 +-- extra/ogg/vorbis/vorbis.factor | 12 +- extra/openal/alut/alut.factor | 12 +- extra/opengl/glu/glu.factor | 4 +- extra/tokyo/alien/tcadb/tcadb.factor | 28 ++-- extra/tokyo/alien/tcbdb/tcbdb.factor | 44 +++---- extra/tokyo/alien/tcfdb/tcfdb.factor | 30 ++--- extra/tokyo/alien/tchdb/tchdb.factor | 34 ++--- extra/tokyo/alien/tcrdb/tcrdb.factor | 56 ++++---- extra/tokyo/alien/tctdb/tctdb.factor | 44 +++---- extra/tokyo/alien/tcutil/tcutil.factor | 4 +- 85 files changed, 556 insertions(+), 576 deletions(-) diff --git a/basis/alien/arrays/arrays.factor b/basis/alien/arrays/arrays.factor index f9a47f256c..ce6eb85245 100644 --- a/basis/alien/arrays/arrays.factor +++ b/basis/alien/arrays/arrays.factor @@ -40,7 +40,7 @@ M: array c-type-boxer-quot M: array c-type-unboxer-quot drop [ >c-ptr ] ; PREDICATE: string-type < pair - first2 [ char* = ] [ word? ] bi* and ; + first2 [ c-string = ] [ word? ] bi* and ; M: string-type c-type ; @@ -100,9 +100,5 @@ M: string-type c-type-getter M: string-type c-type-setter drop [ set-alien-cell ] ; -{ char* utf8 } char typedef -{ char* utf8 } char* typedef -{ char* utf8 } uchar typedef -{ char* binary } byte typedef -{ char* binary } ubyte typedef +{ c-string utf8 } c-string typedef diff --git a/basis/alien/c-types/c-types-docs.factor b/basis/alien/c-types/c-types-docs.factor index f0a339b1aa..e73ce556b5 100644 --- a/basis/alien/c-types/c-types-docs.factor +++ b/basis/alien/c-types/c-types-docs.factor @@ -104,7 +104,7 @@ HELP: void { $description "This symbol is not a valid C type, but it can be used as the return type for a " { $link POSTPONE: FUNCTION: } " or " { $link POSTPONE: CALLBACK: } " definition or for an " { $link alien-invoke } " or " { $link alien-callback } " call." } ; HELP: void* { $description "This C type represents a generic pointer to C memory. See " { $link pointer } " for information on pointer C types." } -HELP: char* +HELP: c-string { $description "This C type represents a pointer to a C string. See " { $link "c-strings" } " for details about using strings with the FFI." } ; HELP: float { $description "This C type represents a single-precision IEEE 754 floating-point type. Input values will be converted to Factor " { $link math:float } "s and demoted to single-precision; output values will be returned as Factor " { $link math:float } "s." } ; diff --git a/basis/alien/c-types/c-types-tests.factor b/basis/alien/c-types/c-types-tests.factor index 10a7b50ebb..7ad4bbb074 100644 --- a/basis/alien/c-types/c-types-tests.factor +++ b/basis/alien/c-types/c-types-tests.factor @@ -22,7 +22,7 @@ UNION-STRUCT: foo [ f ] [ pointer: foo c-type void* c-type = ] unit-test [ t ] [ pointer: foo* c-type void* c-type = ] unit-test -[ t ] [ pointer: char c-type char* c-type = ] unit-test +[ t ] [ c-string c-type c-string c-type = ] unit-test [ t ] [ foo heap-size int heap-size = ] unit-test @@ -35,36 +35,21 @@ TYPEDEF: int MyInt TYPEDEF: char MyChar -[ t ] [ pointer: char c-type pointer: MyChar c-type = ] unit-test -[ t ] [ char* c-type pointer: MyChar c-type = ] unit-test +[ t ] [ pointer: void c-type pointer: MyChar c-type = ] unit-test -TYPEDEF: char MyFunkyChar -{ char* ascii } pointer: MyFunkyChar typedef +TYPEDEF: { c-string ascii } MyFunkyString -[ f ] [ pointer: char c-type pointer: MyFunkyChar c-type = ] unit-test -[ { char* ascii } ] [ pointer: MyFunkyChar c-type ] unit-test +[ { c-string ascii } ] [ MyFunkyString c-type ] unit-test -TYPEDEF: MyFunkyChar MyFunkyTypedef +TYPEDEF: c-string MyString -[ { char* ascii } ] [ pointer: MyFunkyTypedef c-type ] unit-test - -TYPEDEF: MyFunkyChar* MyFunkyString - -[ { char* ascii } ] [ MyFunkyString c-type ] unit-test - -TYPEDEF: char* MyString - -[ t ] [ char* c-type MyString c-type = ] unit-test +[ t ] [ c-string c-type MyString c-type = ] unit-test [ t ] [ void* c-type pointer: MyString c-type = ] unit-test TYPEDEF: int* MyIntArray [ t ] [ void* c-type MyIntArray c-type = ] unit-test -TYPEDEF: char* MyLPBYTE - -[ t ] [ { char* utf8 } c-type MyLPBYTE c-type = ] unit-test - [ 0 B{ 1 2 3 4 } ] must-fail diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor index 3255d16d80..73da41cc69 100644 --- a/basis/alien/c-types/c-types.factor +++ b/basis/alien/c-types/c-types.factor @@ -273,7 +273,7 @@ M: long-long-type box-return ( c-type -- ) SYMBOLS: ptrdiff_t intptr_t uintptr_t size_t - byte ubyte char* ; + c-string ; CONSTANT: primitive-types { @@ -284,7 +284,7 @@ CONSTANT: primitive-types longlong ulonglong float double void* bool - char* + c-string } : (pointer-c-type) ( void* type -- void*' ) @@ -530,8 +530,6 @@ M: pointer c-type \ uint c-type \ size_t typedef ] if - \ char \ byte typedef - \ uchar \ ubyte typedef ] with-compilation-unit M: char-16-rep rep-component-type drop char ; diff --git a/basis/alien/data/data-docs.factor b/basis/alien/data/data-docs.factor index 0536d15736..895b8536f7 100644 --- a/basis/alien/data/data-docs.factor +++ b/basis/alien/data/data-docs.factor @@ -140,13 +140,13 @@ HELP: { $notes "The appropriate specialized array vocabulary must be loaded; otherwise, an error will be thrown. The vocabulary can be loaded with the " { $link require-c-array } " word. See the " { $vocab-link "specialized-arrays" } " vocabulary for details on the underlying sequence type constructed." } ; ARTICLE: "c-strings" "C strings" -"C string types are arrays with shape " { $snippet "{ char* encoding }" } ", where " { $snippet "encoding" } " is an encoding descriptor. The type " { $link char* } " is an alias for " { $snippet "{ char* utf8 }" } ". See " { $link "encodings-descriptors" } " for information about encoding descriptors." +"C string types are arrays with shape " { $snippet "{ c-string encoding }" } ", where " { $snippet "encoding" } " is an encoding descriptor. The type " { $link c-string } " is an alias for " { $snippet "{ c-string utf8 }" } ". See " { $link "encodings-descriptors" } " for information about encoding descriptors. In " { $link POSTPONE: TYPEDEF: } ", " { $link POSTPONE: FUNCTION: } ", " { $link POSTPONE: CALLBACK: } ", and " { $link POSTPONE: STRUCT: } " definitions, the shorthand syntax " { $snippet "c-string[encoding]" } " can be used to specify the string encoding." $nl -"Passing a Factor string to a C function expecting a C string allocates a " { $link byte-array } " in the Factor heap; the string is then converted to the requested format and a raw pointer is passed to the function." +"Passing a Factor string to a C function expecting a " { $link c-string } " allocates a " { $link byte-array } " in the Factor heap; the string is then converted to the requested format and a raw pointer is passed to the function." $nl "If the conversion fails, for example if the string contains null bytes or characters with values higher than 255, a " { $link c-string-error. } " is thrown." $nl -"Care must be taken if the C function expects a " { $link char* } " with a length in bytes, rather than a null-terminated " { $link char* } "; passing the result of calling " { $link length } " on the string object will not suffice. This is because a Factor string of " { $emphasis "n" } " characters will not necessarily encode to " { $emphasis "n" } " bytes. The correct idiom for C functions which take a string with a length is to first encode the string using " { $link encode } ", and then pass the resulting byte array together with the length of this byte array." +"Care must be taken if the C function expects a pointer to a string with its length represented by another parameter rather than a null terminator. Passing the result of calling " { $link length } " on the string object will not suffice. This is because a Factor string of " { $emphasis "n" } " characters will not necessarily encode to " { $emphasis "n" } " bytes. The correct idiom for C functions which take a string with a length is to first encode the string using " { $link encode } ", and then pass the resulting byte array together with the length of this byte array." $nl "Sometimes a C function has a parameter type of " { $link void* } ", and various data types, among them strings, can be passed in. In this case, strings are not automatically converted to aliens, and instead you must call one of these words:" { $subsections @@ -155,7 +155,9 @@ $nl } "The first allocates " { $link byte-array } "s, and the latter allocates manually-managed memory which is not moved by the garbage collector and has to be explicitly freed by calling " { $link free } ". See " { $link "byte-arrays-gc" } " for a discussion of the two approaches." $nl +"The C type " { $link char } { $snippet "*" } " represents a generic pointer to " { $snippet "char" } "; arguments with this type will expect and return " { $link alien } "s, and won't perform any implicit string conversion." +$nl "A word to read strings from arbitrary addresses:" { $subsections alien>string } -"For example, if a C function returns a " { $link char* } " but stipulates that the caller must deallocate the memory afterward, you must define the function as returning " { $link void* } ", and call one of the above words before passing the pointer to " { $link free } "." ; +"For example, if a C function returns a " { $link c-string } " but stipulates that the caller must deallocate the memory afterward, you must define the function as returning " { $snippet "char*" } " and call one of the above words before passing the pointer to " { $link free } "." ; diff --git a/basis/alien/parser/parser-tests.factor b/basis/alien/parser/parser-tests.factor index 37f10722d1..a730e3084f 100644 --- a/basis/alien/parser/parser-tests.factor +++ b/basis/alien/parser/parser-tests.factor @@ -23,9 +23,9 @@ CONSTANT: eleven 11 [ pointer: int* ] [ "int**" parse-c-type ] unit-test [ pointer: int** ] [ "int***" parse-c-type ] unit-test [ pointer: int*** ] [ "int****" parse-c-type ] unit-test - [ pointer: char ] [ "char*" parse-c-type ] unit-test + [ c-string ] [ "c-string" parse-c-type ] unit-test [ char2 ] [ "char2" parse-c-type ] unit-test - [ pointer: char2 ] [ "char2*" parse-c-type ] unit-test + [ c-string2 ] [ "char2*" parse-c-type ] unit-test [ "not-word" parse-c-type ] [ error>> no-word-error? ] must-fail-with ] with-file-vocabs diff --git a/basis/alien/remote-control/remote-control.factor b/basis/alien/remote-control/remote-control.factor index ae694bed9c..c305d720f0 100644 --- a/basis/alien/remote-control/remote-control.factor +++ b/basis/alien/remote-control/remote-control.factor @@ -6,7 +6,7 @@ eval ; IN: alien.remote-control : eval-callback ( -- callback ) - void* { char* } "cdecl" + void* { c-string } "cdecl" [ eval>string utf8 malloc-string ] alien-callback ; : yield-callback ( -- callback ) diff --git a/basis/alien/syntax/syntax-docs.factor b/basis/alien/syntax/syntax-docs.factor index 8ec67d2f65..3d1c757035 100644 --- a/basis/alien/syntax/syntax-docs.factor +++ b/basis/alien/syntax/syntax-docs.factor @@ -40,11 +40,11 @@ $nl } "You can define a word for invoking it:" { $unchecked-example - "LIBRARY: foo\nFUNCTION: void the_answer ( char* question, int value ) ;" - "USE: compiler" + "LIBRARY: foo\nFUNCTION: void the_answer ( c-string question, int value ) ;" "\"the question\" 42 the_answer" "The answer to the question is 42." } } +"Using the " { $link c-string } " type instead of " { $snippet "char*" } " causes the FFI to automatically convert Factor strings to C strings. See " { $link "c-strings" } " for more information on using strings with the FFI." { $notes "Note that the parentheses and commas are only syntax sugar and can be omitted; they serve no purpose other than to make the declaration slightly easier to read:" { $code "FUNCTION: void glHint ( GLenum target, GLenum mode ) ;" diff --git a/basis/cairo/ffi/ffi.factor b/basis/cairo/ffi/ffi.factor index 49975afc61..bca02c1f17 100644 --- a/basis/cairo/ffi/ffi.factor +++ b/basis/cairo/ffi/ffi.factor @@ -18,7 +18,7 @@ IN: cairo.ffi LIBRARY: cairo FUNCTION: int cairo_version ( ) ; -FUNCTION: char* cairo_version_string ( ) ; +FUNCTION: c-string cairo_version_string ( ) ; TYPEDEF: int cairo_bool_t @@ -79,11 +79,11 @@ CONSTANT: CAIRO_CONTENT_COLOR_ALPHA HEX: 3000 TYPEDEF: void* cairo_write_func_t : cairo-write-func ( quot -- callback ) - [ cairo_status_t { pointer: void pointer: uchar int } "cdecl" ] dip alien-callback ; inline + [ cairo_status_t { pointer: void c-string int } "cdecl" ] dip alien-callback ; inline TYPEDEF: void* cairo_read_func_t : cairo-read-func ( quot -- callback ) - [ cairo_status_t { pointer: void pointer: uchar int } "cdecl" ] dip alien-callback ; inline + [ cairo_status_t { pointer: void c-string int } "cdecl" ] dip alien-callback ; inline ! Functions for manipulating state objects FUNCTION: cairo_t* @@ -463,7 +463,7 @@ cairo_font_options_get_hint_metrics ( cairo_font_options_t* options ) ; ! font object inside the the cairo_t. FUNCTION: void -cairo_select_font_face ( cairo_t* cr, char* family, cairo_font_slant_t slant, cairo_font_weight_t weight ) ; +cairo_select_font_face ( cairo_t* cr, c-string family, cairo_font_slant_t slant, cairo_font_weight_t weight ) ; FUNCTION: void cairo_set_font_size ( cairo_t* cr, double size ) ; @@ -493,19 +493,19 @@ FUNCTION: cairo_scaled_font_t* cairo_get_scaled_font ( cairo_t* cr ) ; FUNCTION: void -cairo_show_text ( cairo_t* cr, char* utf8 ) ; +cairo_show_text ( cairo_t* cr, c-string utf8 ) ; FUNCTION: void cairo_show_glyphs ( cairo_t* cr, cairo_glyph_t* glyphs, int num_glyphs ) ; FUNCTION: void -cairo_text_path ( cairo_t* cr, char* utf8 ) ; +cairo_text_path ( cairo_t* cr, c-string utf8 ) ; FUNCTION: void cairo_glyph_path ( cairo_t* cr, cairo_glyph_t* glyphs, int num_glyphs ) ; FUNCTION: void -cairo_text_extents ( cairo_t* cr, char* utf8, cairo_text_extents_t* extents ) ; +cairo_text_extents ( cairo_t* cr, c-string utf8, cairo_text_extents_t* extents ) ; FUNCTION: void cairo_glyph_extents ( cairo_t* cr, cairo_glyph_t* glyphs, int num_glyphs, cairo_text_extents_t* extents ) ; @@ -573,7 +573,7 @@ FUNCTION: void cairo_scaled_font_extents ( cairo_scaled_font_t* scaled_font, cairo_font_extents_t* extents ) ; FUNCTION: void -cairo_scaled_font_text_extents ( cairo_scaled_font_t* scaled_font, char* utf8, cairo_text_extents_t* extents ) ; +cairo_scaled_font_text_extents ( cairo_scaled_font_t* scaled_font, c-string utf8, cairo_text_extents_t* extents ) ; FUNCTION: void cairo_scaled_font_glyph_extents ( cairo_scaled_font_t* scaled_font, cairo_glyph_t* glyphs, int num_glyphs, cairo_text_extents_t* extents ) ; @@ -682,7 +682,7 @@ cairo_path_destroy ( cairo_path_t* path ) ; FUNCTION: cairo_status_t cairo_status ( cairo_t* cr ) ; -FUNCTION: char* +FUNCTION: c-string cairo_status_to_string ( cairo_status_t status ) ; ! Surface manipulation @@ -731,7 +731,7 @@ FUNCTION: cairo_content_t cairo_surface_get_content ( cairo_surface_t* surface ) ; FUNCTION: cairo_status_t -cairo_surface_write_to_png ( cairo_surface_t* surface, char* filename ) ; +cairo_surface_write_to_png ( cairo_surface_t* surface, c-string filename ) ; FUNCTION: cairo_status_t cairo_surface_write_to_png_stream ( cairo_surface_t* surface, cairo_write_func_t write_func, void* closure ) ; @@ -786,9 +786,9 @@ FUNCTION: int cairo_format_stride_for_width ( cairo_format_t format, int width ) ; FUNCTION: cairo_surface_t* -cairo_image_surface_create_for_data ( uchar* data, cairo_format_t format, int width, int height, int stride ) ; +cairo_image_surface_create_for_data ( c-string data, cairo_format_t format, int width, int height, int stride ) ; -FUNCTION: uchar* +FUNCTION: c-string cairo_image_surface_get_data ( cairo_surface_t* surface ) ; FUNCTION: cairo_format_t @@ -804,7 +804,7 @@ FUNCTION: int cairo_image_surface_get_stride ( cairo_surface_t* surface ) ; FUNCTION: cairo_surface_t* -cairo_image_surface_create_from_png ( char* filename ) ; +cairo_image_surface_create_from_png ( c-string filename ) ; FUNCTION: cairo_surface_t* cairo_image_surface_create_from_png_stream ( cairo_read_func_t read_func, void* closure ) ; diff --git a/basis/classes/struct/struct-docs.factor b/basis/classes/struct/struct-docs.factor index 1a5294992e..7dbfda1f4f 100644 --- a/basis/classes/struct/struct-docs.factor +++ b/basis/classes/struct/struct-docs.factor @@ -159,7 +159,7 @@ $nl "A C function which returns a struct by value:" { $code "USING: alien.syntax ;" - "FUNCTION: Point give_me_a_point ( char* description ) ;" + "FUNCTION: Point give_me_a_point ( c-string description ) ;" } "A C function which takes a struct parameter by reference:" { $code diff --git a/basis/classes/struct/struct-tests.factor b/basis/classes/struct/struct-tests.factor index 82530614bf..c94ef48f4c 100644 --- a/basis/classes/struct/struct-tests.factor +++ b/basis/classes/struct/struct-tests.factor @@ -139,7 +139,7 @@ UNION-STRUCT: struct-test-float-and-bits [ 123 ] [ [ struct-test-foo malloc-struct &free y>> ] with-destructors ] unit-test STRUCT: struct-test-string-ptr - { x char* } ; + { x c-string } ; [ "hello world" ] [ [ diff --git a/basis/cocoa/messages/messages.factor b/basis/cocoa/messages/messages.factor index 76b77721ff..2569c391d1 100644 --- a/basis/cocoa/messages/messages.factor +++ b/basis/cocoa/messages/messages.factor @@ -110,7 +110,7 @@ H{ { "d" c:double } { "B" c:bool } { "v" c:void } - { "*" c:char* } + { "*" c:c-string } { "?" unknown_type } { "@" id } { "#" Class } diff --git a/basis/cocoa/runtime/runtime.factor b/basis/cocoa/runtime/runtime.factor index f02f1f6182..9e49835242 100644 --- a/basis/cocoa/runtime/runtime.factor +++ b/basis/cocoa/runtime/runtime.factor @@ -7,11 +7,11 @@ TYPEDEF: void* SEL TYPEDEF: void* id -FUNCTION: char* sel_getName ( SEL aSelector ) ; +FUNCTION: c-string sel_getName ( SEL aSelector ) ; FUNCTION: char sel_isMapped ( SEL aSelector ) ; -FUNCTION: SEL sel_registerName ( char* str ) ; +FUNCTION: SEL sel_registerName ( c-string str ) ; TYPEDEF: void* Class TYPEDEF: void* Method @@ -33,13 +33,13 @@ CONSTANT: CLS_METHOD_ARRAY HEX: 100 FUNCTION: int objc_getClassList ( void* buffer, int bufferLen ) ; -FUNCTION: Class objc_getClass ( char* class ) ; +FUNCTION: Class objc_getClass ( c-string class ) ; -FUNCTION: Class objc_getMetaClass ( char* class ) ; +FUNCTION: Class objc_getMetaClass ( c-string class ) ; -FUNCTION: Protocol objc_getProtocol ( char* class ) ; +FUNCTION: Protocol objc_getProtocol ( c-string class ) ; -FUNCTION: Class objc_allocateClassPair ( Class superclass, char* name, size_t extraBytes ) ; +FUNCTION: Class objc_allocateClassPair ( Class superclass, c-string name, size_t extraBytes ) ; FUNCTION: void objc_registerClassPair ( Class cls ) ; FUNCTION: id class_createInstance ( Class class, uint additionalByteCount ) ; @@ -54,7 +54,7 @@ FUNCTION: Method* class_copyMethodList ( Class class, uint* outCount ) ; FUNCTION: Class class_getSuperclass ( Class cls ) ; -FUNCTION: char* class_getName ( Class cls ) ; +FUNCTION: c-string class_getName ( Class cls ) ; FUNCTION: char class_addMethod ( Class class, SEL name, void* imp, void* types ) ; @@ -64,7 +64,7 @@ FUNCTION: uint method_getNumberOfArguments ( Method method ) ; FUNCTION: uint method_getSizeOfArguments ( Method method ) ; -FUNCTION: uint method_getArgumentInfo ( Method method, int argIndex, char** type, int* offset ) ; +FUNCTION: uint method_getArgumentInfo ( Method method, int argIndex, c-string* type, int* offset ) ; FUNCTION: void* method_copyReturnType ( Method method ) ; diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index aba73d1a22..acb5555bc3 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -67,7 +67,7 @@ FUNCTION: FOO ffi_test_14 int x int y ; [ 11 6 ] [ 11 6 ffi_test_14 [ x>> ] [ y>> ] bi ] unit-test -FUNCTION: char* ffi_test_15 char* x char* y ; +FUNCTION: c-string ffi_test_15 c-string x c-string y ; [ "foo" ] [ "xy" "zt" ffi_test_15 ] unit-test [ "bar" ] [ "xy" "xy" ffi_test_15 ] unit-test @@ -576,7 +576,7 @@ FUNCTION: complex-float ffi_test_47 ( complex-float x, complex-double y ) ; ! Reported by jedahu STRUCT: bool-field-test - { name char* } + { name c-string } { on bool } { parents short } ; diff --git a/basis/core-foundation/data/data.factor b/basis/core-foundation/data/data.factor index c4c09d0cc5..65d6d728c1 100644 --- a/basis/core-foundation/data/data.factor +++ b/basis/core-foundation/data/data.factor @@ -12,7 +12,7 @@ CONSTANT: kCFPropertyListImmutable 0 CONSTANT: kCFPropertyListMutableContainers 1 CONSTANT: kCFPropertyListMutableContainersAndLeaves 2 -FUNCTION: CFDataRef CFDataCreate ( CFAllocatorRef allocator, uchar* bytes, CFIndex length ) ; +FUNCTION: CFDataRef CFDataCreate ( CFAllocatorRef allocator, c-string bytes, CFIndex length ) ; FUNCTION: CFTypeID CFGetTypeID ( CFTypeRef cf ) ; diff --git a/basis/core-foundation/strings/strings.factor b/basis/core-foundation/strings/strings.factor index cbabb083aa..9a91335ae2 100644 --- a/basis/core-foundation/strings/strings.factor +++ b/basis/core-foundation/strings/strings.factor @@ -37,7 +37,7 @@ FUNCTION: void CFStringGetCharacters ( void* theString, CFIndex start, CFIndex l FUNCTION: Boolean CFStringGetCString ( CFStringRef theString, - char* buffer, + c-string buffer, CFIndex bufferSize, CFStringEncoding encoding ) ; @@ -55,7 +55,7 @@ FUNCTION: CFIndex CFStringGetBytes ( FUNCTION: CFStringRef CFStringCreateWithCString ( CFAllocatorRef alloc, - char* cStr, + c-string cStr, CFStringEncoding encoding ) ; diff --git a/basis/db/postgresql/ffi/ffi.factor b/basis/db/postgresql/ffi/ffi.factor index 69ac2c5e5e..812507a20f 100644 --- a/basis/db/postgresql/ffi/ffi.factor +++ b/basis/db/postgresql/ffi/ffi.factor @@ -77,15 +77,15 @@ LIBRARY: postgresql ! make a new client connection to the backend ! Asynchronous (non-blocking) -FUNCTION: PGconn* PQconnectStart ( char* conninfo ) ; +FUNCTION: PGconn* PQconnectStart ( c-string conninfo ) ; FUNCTION: PostgresPollingStatusType PQconnectPoll ( PGconn* conn ) ; ! Synchronous (blocking) -FUNCTION: PGconn* PQconnectdb ( char* conninfo ) ; -FUNCTION: PGconn* PQsetdbLogin ( char* pghost, char* pgport, - char* pgoptions, char* pgtty, - char* dbName, - char* login, char* pwd ) ; +FUNCTION: PGconn* PQconnectdb ( c-string conninfo ) ; +FUNCTION: PGconn* PQsetdbLogin ( c-string pghost, c-string pgport, + c-string pgoptions, c-string pgtty, + c-string dbName, + c-string login, c-string pwd ) ; : PQsetdb ( M_PGHOST M_PGPORT M_PGOPT M_PGTTY M_DBNAME -- PGconn* ) f f PQsetdbLogin ; @@ -116,24 +116,24 @@ FUNCTION: void PQfreeCancel ( PGcancel* cancel ) ; FUNCTION: int PQrequestCancel ( PGconn* conn ) ; ! Accessor functions for PGconn objects -FUNCTION: char* PQdb ( PGconn* conn ) ; -FUNCTION: char* PQuser ( PGconn* conn ) ; -FUNCTION: char* PQpass ( PGconn* conn ) ; -FUNCTION: char* PQhost ( PGconn* conn ) ; -FUNCTION: char* PQport ( PGconn* conn ) ; -FUNCTION: char* PQtty ( PGconn* conn ) ; -FUNCTION: char* PQoptions ( PGconn* conn ) ; +FUNCTION: c-string PQdb ( PGconn* conn ) ; +FUNCTION: c-string PQuser ( PGconn* conn ) ; +FUNCTION: c-string PQpass ( PGconn* conn ) ; +FUNCTION: c-string PQhost ( PGconn* conn ) ; +FUNCTION: c-string PQport ( PGconn* conn ) ; +FUNCTION: c-string PQtty ( PGconn* conn ) ; +FUNCTION: c-string PQoptions ( PGconn* conn ) ; FUNCTION: ConnStatusType PQstatus ( PGconn* conn ) ; FUNCTION: PGTransactionStatusType PQtransactionStatus ( PGconn* conn ) ; -FUNCTION: char* PQparameterStatus ( PGconn* conn, - char* paramName ) ; +FUNCTION: c-string PQparameterStatus ( PGconn* conn, + c-string paramName ) ; FUNCTION: int PQprotocolVersion ( PGconn* conn ) ; ! FUNCTION: int PQServerVersion ( PGconn* conn ) ; -FUNCTION: char* PQerrorMessage ( PGconn* conn ) ; +FUNCTION: c-string PQerrorMessage ( PGconn* conn ) ; FUNCTION: int PQsocket ( PGconn* conn ) ; FUNCTION: int PQbackendPID ( PGconn* conn ) ; FUNCTION: int PQclientEncoding ( PGconn* conn ) ; -FUNCTION: int PQsetClientEncoding ( PGconn* conn, char* encoding ) ; +FUNCTION: int PQsetClientEncoding ( PGconn* conn, c-string encoding ) ; ! May not be compiled into libpq ! Get the SSL structure associated with a connection @@ -153,7 +153,7 @@ FUNCTION: void PQuntrace ( PGconn* conn ) ; ! BROKEN ! Function types for notice-handling callbacks ! typedef void (*PQnoticeReceiver) (void *arg, PGresult *res); -! typedef void (*PQnoticeProcessor) (void *arg, char* message); +! typedef void (*PQnoticeProcessor) (void *arg, c-string message); ! ALIAS: void* PQnoticeReceiver ! ALIAS: void* PQnoticeProcessor @@ -169,43 +169,43 @@ FUNCTION: void PQuntrace ( PGconn* conn ) ; ! === in fe-exec.c === ! Simple synchronous query -FUNCTION: PGresult* PQexec ( PGconn* conn, char* query ) ; +FUNCTION: PGresult* PQexec ( PGconn* conn, c-string query ) ; FUNCTION: PGresult* PQexecParams ( PGconn* conn, - char* command, + c-string command, int nParams, Oid* paramTypes, - char** paramValues, + c-string* paramValues, int* paramLengths, int* paramFormats, int resultFormat ) ; -FUNCTION: PGresult* PQprepare ( PGconn* conn, char* stmtName, - char* query, int nParams, +FUNCTION: PGresult* PQprepare ( PGconn* conn, c-string stmtName, + c-string query, int nParams, Oid* paramTypes ) ; FUNCTION: PGresult* PQexecPrepared ( PGconn* conn, - char* stmtName, + c-string stmtName, int nParams, - char** paramValues, + c-string* paramValues, int* paramLengths, int* paramFormats, int resultFormat ) ; ! Interface for multiple-result or asynchronous queries -FUNCTION: int PQsendQuery ( PGconn* conn, char* query ) ; +FUNCTION: int PQsendQuery ( PGconn* conn, c-string query ) ; FUNCTION: int PQsendQueryParams ( PGconn* conn, - char* command, + c-string command, int nParams, Oid* paramTypes, - char** paramValues, + c-string* paramValues, int* paramLengths, int* paramFormats, int resultFormat ) ; -FUNCTION: PGresult* PQsendPrepare ( PGconn* conn, char* stmtName, - char* query, int nParams, +FUNCTION: PGresult* PQsendPrepare ( PGconn* conn, c-string stmtName, + c-string query, int nParams, Oid* paramTypes ) ; FUNCTION: int PQsendQueryPrepared ( PGconn* conn, - char* stmtName, + c-string stmtName, int nParams, - char** paramValues, + c-string* paramValues, int *paramLengths, int *paramFormats, int resultFormat ) ; @@ -219,15 +219,15 @@ FUNCTION: int PQconsumeInput ( PGconn* conn ) ; FUNCTION: PGnotify* PQnotifies ( PGconn* conn ) ; ! Routines for copy in/out -FUNCTION: int PQputCopyData ( PGconn* conn, char* buffer, int nbytes ) ; -FUNCTION: int PQputCopyEnd ( PGconn* conn, char* errormsg ) ; -FUNCTION: int PQgetCopyData ( PGconn* conn, char** buffer, int async ) ; +FUNCTION: int PQputCopyData ( PGconn* conn, c-string buffer, int nbytes ) ; +FUNCTION: int PQputCopyEnd ( PGconn* conn, c-string errormsg ) ; +FUNCTION: int PQgetCopyData ( PGconn* conn, c-string* buffer, int async ) ; ! Deprecated routines for copy in/out -FUNCTION: int PQgetline ( PGconn* conn, char* string, int length ) ; -FUNCTION: int PQputline ( PGconn* conn, char* string ) ; -FUNCTION: int PQgetlineAsync ( PGconn* conn, char* buffer, int bufsize ) ; -FUNCTION: int PQputnbytes ( PGconn* conn, char* buffer, int nbytes ) ; +FUNCTION: int PQgetline ( PGconn* conn, c-string string, int length ) ; +FUNCTION: int PQputline ( PGconn* conn, c-string string ) ; +FUNCTION: int PQgetlineAsync ( PGconn* conn, c-string buffer, int bufsize ) ; +FUNCTION: int PQputnbytes ( PGconn* conn, c-string buffer, int nbytes ) ; FUNCTION: int PQendcopy ( PGconn* conn ) ; ! Set blocking/nonblocking connection to the backend @@ -251,25 +251,25 @@ FUNCTION: PGresult* PQfn ( PGconn* conn, ! Accessor functions for PGresult objects FUNCTION: ExecStatusType PQresultStatus ( PGresult* res ) ; -FUNCTION: char* PQresStatus ( ExecStatusType status ) ; -FUNCTION: char* PQresultErrorMessage ( PGresult* res ) ; -FUNCTION: char* PQresultErrorField ( PGresult* res, int fieldcode ) ; +FUNCTION: c-string PQresStatus ( ExecStatusType status ) ; +FUNCTION: c-string PQresultErrorMessage ( PGresult* res ) ; +FUNCTION: c-string PQresultErrorField ( PGresult* res, int fieldcode ) ; FUNCTION: int PQntuples ( PGresult* res ) ; FUNCTION: int PQnfields ( PGresult* res ) ; FUNCTION: int PQbinaryTuples ( PGresult* res ) ; -FUNCTION: char* PQfname ( PGresult* res, int field_num ) ; -FUNCTION: int PQfnumber ( PGresult* res, char* field_name ) ; +FUNCTION: c-string PQfname ( PGresult* res, int field_num ) ; +FUNCTION: int PQfnumber ( PGresult* res, c-string field_name ) ; FUNCTION: Oid PQftable ( PGresult* res, int field_num ) ; FUNCTION: int PQftablecol ( PGresult* res, int field_num ) ; FUNCTION: int PQfformat ( PGresult* res, int field_num ) ; FUNCTION: Oid PQftype ( PGresult* res, int field_num ) ; FUNCTION: int PQfsize ( PGresult* res, int field_num ) ; FUNCTION: int PQfmod ( PGresult* res, int field_num ) ; -FUNCTION: char* PQcmdStatus ( PGresult* res ) ; -FUNCTION: char* PQoidStatus ( PGresult* res ) ; +FUNCTION: c-string PQcmdStatus ( PGresult* res ) ; +FUNCTION: c-string PQoidStatus ( PGresult* res ) ; FUNCTION: Oid PQoidValue ( PGresult* res ) ; -FUNCTION: char* PQcmdTuples ( PGresult* res ) ; -! FUNCTION: char* PQgetvalue ( PGresult* res, int tup_num, int field_num ) ; +FUNCTION: c-string PQcmdTuples ( PGresult* res ) ; +! FUNCTION: c-string PQgetvalue ( PGresult* res, int tup_num, int field_num ) ; FUNCTION: void* PQgetvalue ( PGresult* res, int tup_num, int field_num ) ; FUNCTION: int PQgetlength ( PGresult* res, int tup_num, int field_num ) ; FUNCTION: int PQgetisnull ( PGresult* res, int tup_num, int field_num ) ; @@ -292,16 +292,16 @@ FUNCTION: PGresult* PQmakeEmptyPGresult ( PGconn* conn, ExecStatusType status ) ! Quoting strings before inclusion in queries. FUNCTION: size_t PQescapeStringConn ( PGconn* conn, - char* to, char* from, size_t length, + c-string to, c-string from, size_t length, int* error ) ; -FUNCTION: uchar* PQescapeByteaConn ( PGconn* conn, - char* from, size_t length, +FUNCTION: c-string PQescapeByteaConn ( PGconn* conn, + c-string from, size_t length, size_t* to_length ) ; -FUNCTION: void* PQunescapeBytea ( uchar* strtext, size_t* retbuflen ) ; -! FUNCTION: uchar* PQunescapeBytea ( uchar* strtext, size_t* retbuflen ) ; +FUNCTION: void* PQunescapeBytea ( c-string strtext, size_t* retbuflen ) ; +! FUNCTION: c-string PQunescapeBytea ( c-string strtext, size_t* retbuflen ) ; ! These forms are deprecated! -FUNCTION: size_t PQescapeString ( void* to, char* from, size_t length ) ; -FUNCTION: uchar* PQescapeBytea ( uchar* bintext, size_t binlen, +FUNCTION: size_t PQescapeString ( void* to, c-string from, size_t length ) ; +FUNCTION: c-string PQescapeBytea ( c-string bintext, size_t binlen, size_t* bytealen ) ; ! === in fe-print.c === @@ -312,7 +312,7 @@ FUNCTION: void PQprint ( FILE* fout, PGresult* res, PQprintOpt* ps ) ; FUNCTION: void PQdisplayTuples ( PGresult* res, FILE* fp, int fillAlign, - char* fieldSep, + c-string fieldSep, int printHeader, int quiet ) ; @@ -326,23 +326,23 @@ FUNCTION: void PQprintTuples ( PGresult* res, ! Large-object access routines FUNCTION: int lo_open ( PGconn* conn, Oid lobjId, int mode ) ; FUNCTION: int lo_close ( PGconn* conn, int fd ) ; -FUNCTION: int lo_read ( PGconn* conn, int fd, char* buf, size_t len ) ; -FUNCTION: int lo_write ( PGconn* conn, int fd, char* buf, size_t len ) ; +FUNCTION: int lo_read ( PGconn* conn, int fd, c-string buf, size_t len ) ; +FUNCTION: int lo_write ( PGconn* conn, int fd, c-string buf, size_t len ) ; FUNCTION: int lo_lseek ( PGconn* conn, int fd, int offset, int whence ) ; FUNCTION: Oid lo_creat ( PGconn* conn, int mode ) ; ! FUNCTION: Oid lo_creat ( PGconn* conn, Oid lobjId ) ; FUNCTION: int lo_tell ( PGconn* conn, int fd ) ; FUNCTION: int lo_unlink ( PGconn* conn, Oid lobjId ) ; -FUNCTION: Oid lo_import ( PGconn* conn, char* filename ) ; -FUNCTION: int lo_export ( PGconn* conn, Oid lobjId, char* filename ) ; +FUNCTION: Oid lo_import ( PGconn* conn, c-string filename ) ; +FUNCTION: int lo_export ( PGconn* conn, Oid lobjId, c-string filename ) ; ! === in fe-misc.c === ! Determine length of multibyte encoded char at *s -FUNCTION: int PQmblen ( uchar* s, int encoding ) ; +FUNCTION: int PQmblen ( c-string s, int encoding ) ; ! Determine display length of multibyte encoded char at *s -FUNCTION: int PQdsplen ( uchar* s, int encoding ) ; +FUNCTION: int PQdsplen ( c-string s, int encoding ) ; ! Get encoding id from environment variable PGCLIENTENCODING FUNCTION: int PQenv2encoding ( ) ; diff --git a/basis/db/sqlite/ffi/ffi.factor b/basis/db/sqlite/ffi/ffi.factor index 53562fd87e..f93b961799 100644 --- a/basis/db/sqlite/ffi/ffi.factor +++ b/basis/db/sqlite/ffi/ffi.factor @@ -105,11 +105,11 @@ TYPEDEF: longlong sqlite3_int64 TYPEDEF: ulonglong sqlite3_uint64 LIBRARY: sqlite -FUNCTION: int sqlite3_open ( char* filename, void* ppDb ) ; +FUNCTION: int sqlite3_open ( c-string filename, void* ppDb ) ; FUNCTION: int sqlite3_close ( sqlite3* pDb ) ; -FUNCTION: char* sqlite3_errmsg ( sqlite3* pDb ) ; -FUNCTION: int sqlite3_prepare ( sqlite3* pDb, char* zSql, int nBytes, void* ppStmt, void* pzTail ) ; -FUNCTION: int sqlite3_prepare_v2 ( sqlite3* pDb, char* zSql, int nBytes, void* ppStmt, void* pzTail ) ; +FUNCTION: c-string sqlite3_errmsg ( sqlite3* pDb ) ; +FUNCTION: int sqlite3_prepare ( sqlite3* pDb, c-string zSql, int nBytes, void* ppStmt, void* pzTail ) ; +FUNCTION: int sqlite3_prepare_v2 ( sqlite3* pDb, c-string zSql, int nBytes, void* ppStmt, void* pzTail ) ; FUNCTION: int sqlite3_finalize ( sqlite3_stmt* pStmt ) ; FUNCTION: int sqlite3_reset ( sqlite3_stmt* pStmt ) ; FUNCTION: int sqlite3_step ( sqlite3_stmt* pStmt ) ; @@ -123,13 +123,13 @@ FUNCTION: int sqlite3_bind_int64 ( sqlite3_stmt* pStmt, int index, sqlite3_int64 int "sqlite" "sqlite3_bind_int64" { pointer: sqlite3_stmt int sqlite3_uint64 } alien-invoke ; FUNCTION: int sqlite3_bind_null ( sqlite3_stmt* pStmt, int n ) ; -FUNCTION: int sqlite3_bind_text ( sqlite3_stmt* pStmt, int index, char* text, int len, int destructor ) ; -FUNCTION: int sqlite3_bind_parameter_index ( sqlite3_stmt* pStmt, char* name ) ; +FUNCTION: int sqlite3_bind_text ( sqlite3_stmt* pStmt, int index, c-string text, int len, int destructor ) ; +FUNCTION: int sqlite3_bind_parameter_index ( sqlite3_stmt* pStmt, c-string name ) ; FUNCTION: int sqlite3_clear_bindings ( sqlite3_stmt* pStmt ) ; FUNCTION: int sqlite3_column_count ( sqlite3_stmt* pStmt ) ; FUNCTION: void* sqlite3_column_blob ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: int sqlite3_column_bytes ( sqlite3_stmt* pStmt, int col ) ; -FUNCTION: char* sqlite3_column_decltype ( sqlite3_stmt* pStmt, int col ) ; +FUNCTION: c-string sqlite3_column_decltype ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: int sqlite3_column_int ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: sqlite3_int64 sqlite3_column_int64 ( sqlite3_stmt* pStmt, int col ) ; ! Bind the same function as above, but for unsigned 64bit integers @@ -137,6 +137,6 @@ FUNCTION: sqlite3_int64 sqlite3_column_int64 ( sqlite3_stmt* pStmt, int col ) ; sqlite3_uint64 "sqlite" "sqlite3_column_int64" { pointer: sqlite3_stmt int } alien-invoke ; FUNCTION: double sqlite3_column_double ( sqlite3_stmt* pStmt, int col ) ; -FUNCTION: char* sqlite3_column_name ( sqlite3_stmt* pStmt, int col ) ; -FUNCTION: char* sqlite3_column_text ( sqlite3_stmt* pStmt, int col ) ; +FUNCTION: c-string sqlite3_column_name ( sqlite3_stmt* pStmt, int col ) ; +FUNCTION: c-string sqlite3_column_text ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: int sqlite3_column_type ( sqlite3_stmt* pStmt, int col ) ; diff --git a/basis/iokit/hid/hid.factor b/basis/iokit/hid/hid.factor index ca339a78ef..bd3fc1e968 100644 --- a/basis/iokit/hid/hid.factor +++ b/basis/iokit/hid/hid.factor @@ -132,7 +132,7 @@ TYPEDEF: UInt32 IOHIDValueScaleType TYPEDEF: UInt32 IOHIDTransactionDirectionType CALLBACK: void IOHIDCallback ( void* context, IOReturn result, void* sender ) ; -CALLBACK: void IOHIDReportCallback ( void* context, IOReturn result, void* sender, IOHIDReportType type, UInt32 reportID, uchar* report, CFIndex reportLength ) ; +CALLBACK: void IOHIDReportCallback ( void* context, IOReturn result, void* sender, IOHIDReportType type, UInt32 reportID, c-string report, CFIndex reportLength ) ; CALLBACK: void IOHIDValueCallback ( void* context, IOReturn result, void* sender, IOHIDValueRef value ) ; CALLBACK: void IOHIDValueMultipleCallback ( void* context, IOReturn result, void* sender, CFDictionaryRef multiple ) ; CALLBACK: void IOHIDDeviceCallback ( void* context, IOReturn result, void* sender, IOHIDDeviceRef device ) ; @@ -151,7 +151,7 @@ FUNCTION: void IOHIDDeviceScheduleWithRunLoop ( IOHIDDeviceRef device, CFRunLoop FUNCTION: void IOHIDDeviceUnscheduleFromRunLoop ( IOHIDDeviceRef device, CFRunLoopRef runLoop, CFStringRef runLoopMode ) ; FUNCTION: void IOHIDDeviceRegisterRemovalCallback ( IOHIDDeviceRef device, IOHIDCallback callback, void* context ) ; FUNCTION: void IOHIDDeviceRegisterInputValueCallback ( IOHIDDeviceRef device, IOHIDValueCallback callback, void* context ) ; -FUNCTION: void IOHIDDeviceRegisterInputReportCallback ( IOHIDDeviceRef device, uchar* report, CFIndex reportLength, IOHIDReportCallback callback, void* context ) ; +FUNCTION: void IOHIDDeviceRegisterInputReportCallback ( IOHIDDeviceRef device, c-string report, CFIndex reportLength, IOHIDReportCallback callback, void* context ) ; FUNCTION: void IOHIDDeviceSetInputValueMatching ( IOHIDDeviceRef device, CFDictionaryRef matching ) ; FUNCTION: void IOHIDDeviceSetInputValueMatchingMultiple ( IOHIDDeviceRef device, CFArrayRef multiple ) ; FUNCTION: IOReturn IOHIDDeviceSetValue ( IOHIDDeviceRef device, IOHIDElementRef element, IOHIDValueRef value ) ; @@ -162,10 +162,10 @@ FUNCTION: IOReturn IOHIDDeviceGetValue ( IOHIDDeviceRef device, IOHIDElementRef FUNCTION: IOReturn IOHIDDeviceCopyValueMultiple ( IOHIDDeviceRef device, CFArrayRef elements, CFDictionaryRef* pMultiple ) ; FUNCTION: IOReturn IOHIDDeviceGetValueWithCallback ( IOHIDDeviceRef device, IOHIDElementRef element, IOHIDValueRef* pValue, CFTimeInterval timeout, IOHIDValueCallback callback, void* context ) ; FUNCTION: IOReturn IOHIDDeviceCopyValueMultipleWithCallback ( IOHIDDeviceRef device, CFArrayRef elements, CFDictionaryRef* pMultiple, CFTimeInterval timeout, IOHIDValueMultipleCallback callback, void* context ) ; -FUNCTION: IOReturn IOHIDDeviceSetReport ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, uchar* report, CFIndex reportLength ) ; -FUNCTION: IOReturn IOHIDDeviceSetReportWithCallback ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, uchar* report, CFIndex reportLength, CFTimeInterval timeout, IOHIDReportCallback callback, void* context ) ; -FUNCTION: IOReturn IOHIDDeviceGetReport ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, uchar* report, CFIndex* pReportLength ) ; -FUNCTION: IOReturn IOHIDDeviceGetReportWithCallback ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, uchar* report, CFIndex* pReportLength, CFTimeInterval timeout, IOHIDReportCallback callback, void* context ) ; +FUNCTION: IOReturn IOHIDDeviceSetReport ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, c-string report, CFIndex reportLength ) ; +FUNCTION: IOReturn IOHIDDeviceSetReportWithCallback ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, c-string report, CFIndex reportLength, CFTimeInterval timeout, IOHIDReportCallback callback, void* context ) ; +FUNCTION: IOReturn IOHIDDeviceGetReport ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, c-string report, CFIndex* pReportLength ) ; +FUNCTION: IOReturn IOHIDDeviceGetReportWithCallback ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, c-string report, CFIndex* pReportLength, CFTimeInterval timeout, IOHIDReportCallback callback, void* context ) ; ! IOHIDManager @@ -226,12 +226,12 @@ FUNCTION: Boolean IOHIDElementSetProperty ( IOHIDElementRef element, CFStringRef FUNCTION: CFTypeID IOHIDValueGetTypeID ( ) ; FUNCTION: IOHIDValueRef IOHIDValueCreateWithIntegerValue ( CFAllocatorRef allocator, IOHIDElementRef element, ulonglong timeStamp, CFIndex value ) ; -FUNCTION: IOHIDValueRef IOHIDValueCreateWithBytes ( CFAllocatorRef allocator, IOHIDElementRef element, ulonglong timeStamp, uchar* bytes, CFIndex length ) ; -FUNCTION: IOHIDValueRef IOHIDValueCreateWithBytesNoCopy ( CFAllocatorRef allocator, IOHIDElementRef element, ulonglong timeStamp, uchar* bytes, CFIndex length ) ; +FUNCTION: IOHIDValueRef IOHIDValueCreateWithBytes ( CFAllocatorRef allocator, IOHIDElementRef element, ulonglong timeStamp, c-string bytes, CFIndex length ) ; +FUNCTION: IOHIDValueRef IOHIDValueCreateWithBytesNoCopy ( CFAllocatorRef allocator, IOHIDElementRef element, ulonglong timeStamp, c-string bytes, CFIndex length ) ; FUNCTION: IOHIDElementRef IOHIDValueGetElement ( IOHIDValueRef value ) ; FUNCTION: ulonglong IOHIDValueGetTimeStamp ( IOHIDValueRef value ) ; FUNCTION: CFIndex IOHIDValueGetLength ( IOHIDValueRef value ) ; -FUNCTION: uchar* IOHIDValueGetBytePtr ( IOHIDValueRef value ) ; +FUNCTION: c-string IOHIDValueGetBytePtr ( IOHIDValueRef value ) ; FUNCTION: CFIndex IOHIDValueGetIntegerValue ( IOHIDValueRef value ) ; FUNCTION: double IOHIDValueGetScaledValue ( IOHIDValueRef value, IOHIDValueScaleType type ) ; diff --git a/basis/iokit/iokit.factor b/basis/iokit/iokit.factor index 2b31e5c8a8..577c9e1273 100644 --- a/basis/iokit/iokit.factor +++ b/basis/iokit/iokit.factor @@ -104,9 +104,9 @@ CONSTANT: KERN_SUCCESS 0 FUNCTION: IOReturn IOMasterPort ( mach_port_t bootstrap, mach_port_t* master ) ; -FUNCTION: CFDictionaryRef IOServiceMatching ( char* name ) ; -FUNCTION: CFDictionaryRef IOServiceNameMatching ( char* name ) ; -FUNCTION: CFDictionaryRef IOBSDNameMatching ( char* name ) ; +FUNCTION: CFDictionaryRef IOServiceMatching ( c-string name ) ; +FUNCTION: CFDictionaryRef IOServiceNameMatching ( c-string name ) ; +FUNCTION: CFDictionaryRef IOBSDNameMatching ( c-string name ) ; FUNCTION: IOReturn IOObjectRetain ( io_object_t o ) ; FUNCTION: IOReturn IOObjectRelease ( io_object_t o ) ; @@ -121,7 +121,7 @@ FUNCTION: IOReturn IORegistryEntryGetPath ( io_registry_entry_t entry, io_name_t FUNCTION: IOReturn IORegistryEntryCreateCFProperties ( io_registry_entry_t entry, CFMutableDictionaryRef properties, CFAllocatorRef allocator, IOOptionBits options ) ; -FUNCTION: char* mach_error_string ( IOReturn error ) ; +FUNCTION: c-string mach_error_string ( IOReturn error ) ; TUPLE: mach-error error-code error-string ; : ( code -- error ) diff --git a/basis/libc/libc.factor b/basis/libc/libc.factor index e935d49748..5f6a808b2e 100644 --- a/basis/libc/libc.factor +++ b/basis/libc/libc.factor @@ -96,6 +96,6 @@ PRIVATE> memcmp 0 = ; : strlen ( alien -- len ) - size_t "libc" "strlen" { char* } alien-invoke ; + size_t "libc" "strlen" { c-string } alien-invoke ; DESTRUCTOR: free diff --git a/basis/opengl/gl/gl.factor b/basis/opengl/gl/gl.factor index 27d24718c2..7652720f1a 100644 --- a/basis/opengl/gl/gl.factor +++ b/basis/opengl/gl/gl.factor @@ -668,7 +668,7 @@ FUNCTION: void glPopClientAttrib ( ) ; FUNCTION: GLint glRenderMode ( GLenum mode ) ; FUNCTION: GLenum glGetError ( ) ; -FUNCTION: char* glGetString ( GLenum name ) ; +FUNCTION: c-string glGetString ( GLenum name ) ; FUNCTION: void glFinish ( ) ; FUNCTION: void glFlush ( ) ; FUNCTION: void glHint ( GLenum target, GLenum mode ) ; diff --git a/basis/opengl/gl/windows/windows.factor b/basis/opengl/gl/windows/windows.factor index 5821e3f212..8bceb865e2 100644 --- a/basis/opengl/gl/windows/windows.factor +++ b/basis/opengl/gl/windows/windows.factor @@ -4,7 +4,7 @@ IN: opengl.gl.windows LIBRARY: gl FUNCTION: HGLRC wglGetCurrentContext ( ) ; -FUNCTION: void* wglGetProcAddress ( char* name ) ; +FUNCTION: void* wglGetProcAddress ( c-string name ) ; : gl-function-context ( -- context ) wglGetCurrentContext ; inline : gl-function-address ( name -- address ) wglGetProcAddress ; inline diff --git a/basis/openssl/libcrypto/libcrypto.factor b/basis/openssl/libcrypto/libcrypto.factor index fd5c757bc4..f9983d7813 100644 --- a/basis/openssl/libcrypto/libcrypto.factor +++ b/basis/openssl/libcrypto/libcrypto.factor @@ -65,9 +65,9 @@ LIBRARY: libcrypto ! bio.h ! =============================================== -FUNCTION: bio* BIO_new_file ( char* filename, char* mode ) ; +FUNCTION: bio* BIO_new_file ( c-string filename, c-string mode ) ; -FUNCTION: int BIO_printf ( bio* bio, char* format ) ; +FUNCTION: int BIO_printf ( bio* bio, c-string format ) ; FUNCTION: long BIO_ctrl ( void* bio, int cmd, long larg, void* parg ) ; @@ -83,17 +83,17 @@ FUNCTION: void* BIO_push ( void* bio, void* append ) ; FUNCTION: int BIO_read ( void* b, void* buf, int len ) ; -FUNCTION: int BIO_gets ( void* b, char* buf, int size ) ; +FUNCTION: int BIO_gets ( void* b, c-string buf, int size ) ; FUNCTION: int BIO_write ( void* b, void* buf, int len ) ; -FUNCTION: int BIO_puts ( void* bp, char* buf ) ; +FUNCTION: int BIO_puts ( void* bp, c-string buf ) ; FUNCTION: ulong ERR_get_error ( ) ; FUNCTION: void ERR_clear_error ( ) ; -FUNCTION: char* ERR_error_string ( ulong e, void* buf ) ; +FUNCTION: c-string ERR_error_string ( ulong e, void* buf ) ; FUNCTION: void* BIO_f_buffer ( ) ; @@ -120,7 +120,7 @@ FUNCTION: void OpenSSL_add_all_digests ( ) ; ! Clean them up before exiting FUNCTION: void EVP_cleanup ( ) ; -FUNCTION: EVP_MD* EVP_get_digestbyname ( char* name ) ; +FUNCTION: EVP_MD* EVP_get_digestbyname ( c-string name ) ; FUNCTION: void EVP_MD_CTX_init ( EVP_MD* ctx ) ; @@ -166,7 +166,7 @@ FUNCTION: int RSA_print_fp ( void* fp, void* x, int offset ) ; ! objects.h ! =============================================== -FUNCTION: int OBJ_sn2nid ( char* s ) ; +FUNCTION: int OBJ_sn2nid ( c-string s ) ; ! =============================================== ! bn.h diff --git a/basis/openssl/libssl/libssl.factor b/basis/openssl/libssl/libssl.factor index 1c6fbec011..bfd59cde25 100644 --- a/basis/openssl/libssl/libssl.factor +++ b/basis/openssl/libssl/libssl.factor @@ -109,7 +109,7 @@ FUNCTION: X509_NAME* X509_get_subject_name ( X509* a ) ; ! ssl.h ! =============================================== -FUNCTION: char* SSL_get_version ( SSL* ssl ) ; +FUNCTION: c-string SSL_get_version ( SSL* ssl ) ; ! Maps OpenSSL errors to strings FUNCTION: void SSL_load_error_strings ( ) ; @@ -143,7 +143,7 @@ FUNCTION: SSL_CTX* SSL_CTX_new ( ssl-method method ) ; ! Load the certificates and private keys into the SSL_CTX FUNCTION: int SSL_CTX_use_certificate_chain_file ( SSL_CTX* ctx, - char* file ) ; ! PEM type + c-string file ) ; ! PEM type FUNCTION: SSL* SSL_new ( SSL_CTX* ctx ) ; @@ -174,7 +174,7 @@ CONSTANT: SSL_RECEIVED_SHUTDOWN 2 FUNCTION: int SSL_get_shutdown ( SSL* ssl ) ; -FUNCTION: int SSL_CTX_set_session_id_context ( SSL_CTX* ctx, char* sid_ctx, uint len ) ; +FUNCTION: int SSL_CTX_set_session_id_context ( SSL_CTX* ctx, c-string sid_ctx, uint len ) ; FUNCTION: SSL_SESSION* SSL_get1_session ( SSL* ssl ) ; @@ -197,17 +197,17 @@ FUNCTION: void SSL_CTX_free ( SSL_CTX* ctx ) ; FUNCTION: void RAND_seed ( void* buf, int num ) ; -FUNCTION: int SSL_set_cipher_list ( SSL* ssl, char* str ) ; +FUNCTION: int SSL_set_cipher_list ( SSL* ssl, c-string str ) ; -FUNCTION: int SSL_use_RSAPrivateKey_file ( SSL* ssl, char* str ) ; +FUNCTION: int SSL_use_RSAPrivateKey_file ( SSL* ssl, c-string str ) ; FUNCTION: int SSL_CTX_use_RSAPrivateKey_file ( SSL_CTX* ctx, int type ) ; FUNCTION: int SSL_use_certificate_file ( SSL* ssl, - char* str, int type ) ; + c-string str, int type ) ; -FUNCTION: int SSL_CTX_load_verify_locations ( SSL_CTX* ctx, char* CAfile, - char* CApath ) ; +FUNCTION: int SSL_CTX_load_verify_locations ( SSL_CTX* ctx, c-string CAfile, + c-string CApath ) ; FUNCTION: int SSL_CTX_set_default_verify_paths ( SSL_CTX* ctx ) ; @@ -220,7 +220,7 @@ FUNCTION: void SSL_CTX_set_verify ( SSL_CTX* ctx, int mode, void* callback ) ; FUNCTION: void SSL_CTX_set_client_CA_list ( SSL_CTX* ctx, SSL* list ) ; -FUNCTION: SSL* SSL_load_client_CA_file ( char* file ) ; +FUNCTION: SSL* SSL_load_client_CA_file ( c-string file ) ; ! Used to manipulate settings of the SSL_CTX and SSL objects. ! This function should never be called directly @@ -231,7 +231,7 @@ FUNCTION: void SSL_CTX_set_default_passwd_cb ( SSL_CTX* ctx, void* cb ) ; FUNCTION: void SSL_CTX_set_default_passwd_cb_userdata ( SSL_CTX* ctx, void* u ) ; -FUNCTION: int SSL_CTX_use_PrivateKey_file ( SSL_CTX* ctx, char* file, +FUNCTION: int SSL_CTX_use_PrivateKey_file ( SSL_CTX* ctx, c-string file, int type ) ; ! Sets the maximum depth for the allowed ctx certificate chain verification diff --git a/basis/pango/fonts/fonts.factor b/basis/pango/fonts/fonts.factor index 31a51e3f12..c2a7ef128d 100644 --- a/basis/pango/fonts/fonts.factor +++ b/basis/pango/fonts/fonts.factor @@ -45,16 +45,16 @@ pango_font_description_free ( PangoFontDescription* desc ) ; DESTRUCTOR: pango_font_description_free FUNCTION: PangoFontDescription* -pango_font_description_from_string ( char* str ) ; +pango_font_description_from_string ( c-string str ) ; -FUNCTION: char* +FUNCTION: c-string pango_font_description_to_string ( PangoFontDescription* desc ) ; -FUNCTION: char* +FUNCTION: c-string pango_font_description_to_filename ( PangoFontDescription* desc ) ; FUNCTION: void -pango_font_description_set_family ( PangoFontDescription* desc, char* family ) ; +pango_font_description_set_family ( PangoFontDescription* desc, c-string family ) ; FUNCTION: void pango_font_description_set_style ( PangoFontDescription* desc, PangoStyle style ) ; @@ -68,7 +68,7 @@ pango_font_description_set_size ( PangoFontDescription* desc, gint size ) ; FUNCTION: void pango_font_map_list_families ( PangoFontMap* fontmap, PangoFontFamily*** families, int* n_families ) ; -FUNCTION: char* +FUNCTION: c-string pango_font_family_get_name ( PangoFontFamily* family ) ; FUNCTION: int @@ -77,7 +77,7 @@ pango_font_family_is_monospace ( PangoFontFamily* family ) ; FUNCTION: void pango_font_family_list_faces ( PangoFontFamily* family, PangoFontFace*** faces, int* n_faces ) ; -FUNCTION: char* +FUNCTION: c-string pango_font_face_get_face_name ( PangoFontFace* face ) ; FUNCTION: void diff --git a/basis/pango/layouts/layouts.factor b/basis/pango/layouts/layouts.factor index 74b6d0b0c3..3f3b02c7c7 100644 --- a/basis/pango/layouts/layouts.factor +++ b/basis/pango/layouts/layouts.factor @@ -21,9 +21,9 @@ FUNCTION: PangoContext* pango_layout_get_context ( PangoLayout* layout ) ; FUNCTION: void -pango_layout_set_text ( PangoLayout* layout, char* text, int length ) ; +pango_layout_set_text ( PangoLayout* layout, c-string text, int length ) ; -FUNCTION: char* +FUNCTION: c-string pango_layout_get_text ( PangoLayout* layout ) ; FUNCTION: void diff --git a/basis/system-info/linux/linux.factor b/basis/system-info/linux/linux.factor index 0c21597a2f..1a565705fb 100644 --- a/basis/system-info/linux/linux.factor +++ b/basis/system-info/linux/linux.factor @@ -7,7 +7,7 @@ SPECIALIZED-ARRAY: char IN: system-info.linux : (uname) ( buf -- int ) - int f "uname" { char* } alien-invoke ; + int f "uname" { c-string } alien-invoke ; : uname ( -- seq ) 65536 [ (uname) io-error ] keep diff --git a/basis/tools/disassembler/udis/udis.factor b/basis/tools/disassembler/udis/udis.factor index ee77268e22..ae8827e093 100644 --- a/basis/tools/disassembler/udis/udis.factor +++ b/basis/tools/disassembler/udis/udis.factor @@ -32,8 +32,8 @@ STRUCT: ud { inp_fill uchar } { inp_file void* } { inp_ctr uchar } - { inp_buff uchar* } - { inp_buff_end uchar* } + { inp_buff c-string } + { inp_buff_end c-string } { inp_end uchar } { translator void* } { insn_offset ulonglong } @@ -83,19 +83,19 @@ CONSTANT: UD_VENDOR_INTEL 1 FUNCTION: void ud_init ( ud* u ) ; FUNCTION: void ud_set_mode ( ud* u, uchar mode ) ; FUNCTION: void ud_set_pc ( ud* u, ulonglong pc ) ; -FUNCTION: void ud_set_input_buffer ( ud* u, uchar* offset, size_t size ) ; +FUNCTION: void ud_set_input_buffer ( ud* u, c-string offset, size_t size ) ; FUNCTION: void ud_set_vendor ( ud* u, uint vendor ) ; FUNCTION: void ud_set_syntax ( ud* u, void* syntax ) ; FUNCTION: void ud_input_skip ( ud* u, size_t size ) ; FUNCTION: int ud_input_end ( ud* u ) ; FUNCTION: uint ud_decode ( ud* u ) ; FUNCTION: uint ud_disassemble ( ud* u ) ; -FUNCTION: char* ud_insn_asm ( ud* u ) ; +FUNCTION: c-string ud_insn_asm ( ud* u ) ; FUNCTION: void* ud_insn_ptr ( ud* u ) ; FUNCTION: ulonglong ud_insn_off ( ud* u ) ; -FUNCTION: char* ud_insn_hex ( ud* u ) ; +FUNCTION: c-string ud_insn_hex ( ud* u ) ; FUNCTION: uint ud_insn_len ( ud* u ) ; -FUNCTION: char* ud_lookup_mnemonic ( int c ) ; +FUNCTION: c-string ud_lookup_mnemonic ( int c ) ; : ( -- ud ) ud malloc-struct &free diff --git a/basis/unix/ffi/bsd/bsd.factor b/basis/unix/ffi/bsd/bsd.factor index bda99422fc..ad323bf14a 100644 --- a/basis/unix/ffi/bsd/bsd.factor +++ b/basis/unix/ffi/bsd/bsd.factor @@ -48,15 +48,15 @@ STRUCT: sockaddr-un { path char[104] } ; STRUCT: passwd - { pw_name char* } - { pw_passwd char* } + { pw_name c-string } + { pw_passwd c-string } { pw_uid uid_t } { pw_gid gid_t } { pw_change time_t } - { pw_class char* } - { pw_gecos char* } - { pw_dir char* } - { pw_shell char* } + { pw_class c-string } + { pw_gecos c-string } + { pw_dir c-string } + { pw_shell c-string } { pw_expire time_t } { pw_fields int } ; diff --git a/basis/unix/ffi/bsd/freebsd/freebsd.factor b/basis/unix/ffi/bsd/freebsd/freebsd.factor index 992d1c3ad0..112758a3e8 100644 --- a/basis/unix/ffi/bsd/freebsd/freebsd.factor +++ b/basis/unix/ffi/bsd/freebsd/freebsd.factor @@ -9,7 +9,7 @@ STRUCT: addrinfo { socktype int } { protocol int } { addrlen socklen_t } - { canonname char* } + { canonname c-string } { addr void* } { next addrinfo* } ; diff --git a/basis/unix/ffi/bsd/macosx/macosx.factor b/basis/unix/ffi/bsd/macosx/macosx.factor index a7c47f0ff8..2ca1d9315d 100644 --- a/basis/unix/ffi/bsd/macosx/macosx.factor +++ b/basis/unix/ffi/bsd/macosx/macosx.factor @@ -11,7 +11,7 @@ STRUCT: addrinfo { socktype int } { protocol int } { addrlen socklen_t } - { canonname char* } + { canonname c-string } { addr void* } { next addrinfo* } ; diff --git a/basis/unix/ffi/bsd/netbsd/netbsd.factor b/basis/unix/ffi/bsd/netbsd/netbsd.factor index d755caf874..e15971b150 100644 --- a/basis/unix/ffi/bsd/netbsd/netbsd.factor +++ b/basis/unix/ffi/bsd/netbsd/netbsd.factor @@ -10,7 +10,7 @@ STRUCT: addrinfo { socktype int } { protocol int } { addrlen socklen_t } - { canonname char* } + { canonname c-string } { addr void* } { next addrinfo* } ; diff --git a/basis/unix/ffi/bsd/openbsd/openbsd.factor b/basis/unix/ffi/bsd/openbsd/openbsd.factor index 076dbdfd24..1f4eddef66 100644 --- a/basis/unix/ffi/bsd/openbsd/openbsd.factor +++ b/basis/unix/ffi/bsd/openbsd/openbsd.factor @@ -10,7 +10,7 @@ STRUCT: addrinfo { protocol int } { addrlen socklen_t } { addr void* } - { canonname char* } + { canonname c-string } { next addrinfo* } ; STRUCT: dirent diff --git a/basis/unix/ffi/ffi.factor b/basis/unix/ffi/ffi.factor index 10346cff2c..555bab32e4 100644 --- a/basis/unix/ffi/ffi.factor +++ b/basis/unix/ffi/ffi.factor @@ -44,21 +44,21 @@ CONSTANT: DT_WHT 14 LIBRARY: libc -FUNCTION: char* strerror ( int errno ) ; +FUNCTION: c-string strerror ( int errno ) ; STRUCT: group - { gr_name char* } - { gr_passwd char* } + { gr_name c-string } + { gr_passwd c-string } { gr_gid int } - { gr_mem char** } ; + { gr_mem c-string* } ; FUNCTION: int accept ( int s, void* sockaddr, socklen_t* socklen ) ; FUNCTION: int bind ( int s, void* name, socklen_t namelen ) ; -FUNCTION: int chdir ( char* path ) ; -FUNCTION: int chmod ( char* path, mode_t mode ) ; +FUNCTION: int chdir ( c-string path ) ; +FUNCTION: int chmod ( c-string path, mode_t mode ) ; FUNCTION: int fchmod ( int fd, mode_t mode ) ; -FUNCTION: int chown ( char* path, uid_t owner, gid_t group ) ; -FUNCTION: int chroot ( char* path ) ; +FUNCTION: int chown ( c-string path, uid_t owner, gid_t group ) ; +FUNCTION: int chroot ( c-string path ) ; FUNCTION: int close ( int fd ) ; FUNCTION: int closedir ( DIR* dirp ) ; FUNCTION: int connect ( int s, void* name, socklen_t namelen ) ; @@ -70,31 +70,31 @@ FUNCTION: int fcntl ( int fd, int cmd, int arg ) ; FUNCTION: int flock ( int fd, int operation ) ; FUNCTION: void freeaddrinfo ( addrinfo* ai ) ; FUNCTION: int futimes ( int id, timeval[2] times ) ; -FUNCTION: char* gai_strerror ( int ecode ) ; -FUNCTION: int getaddrinfo ( char* hostname, char* servname, addrinfo* hints, addrinfo** res ) ; -FUNCTION: char* getcwd ( char* buf, size_t size ) ; +FUNCTION: c-string gai_strerror ( int ecode ) ; +FUNCTION: int getaddrinfo ( c-string hostname, c-string servname, addrinfo* hints, addrinfo** res ) ; +FUNCTION: c-string getcwd ( c-string buf, size_t size ) ; FUNCTION: pid_t getpid ; FUNCTION: int getdtablesize ; FUNCTION: gid_t getegid ; FUNCTION: uid_t geteuid ; FUNCTION: gid_t getgid ; -FUNCTION: char* getenv ( char* name ) ; +FUNCTION: c-string getenv ( c-string name ) ; -FUNCTION: int getgrgid_r ( gid_t gid, group* grp, char* buffer, size_t bufsize, group** result ) ; -FUNCTION: int getgrnam_r ( char* name, group* grp, char* buffer, size_t bufsize, group** result ) ; +FUNCTION: int getgrgid_r ( gid_t gid, group* grp, c-string buffer, size_t bufsize, group** result ) ; +FUNCTION: int getgrnam_r ( c-string name, group* grp, c-string buffer, size_t bufsize, group** result ) ; FUNCTION: passwd* getpwent ( ) ; FUNCTION: passwd* getpwuid ( uid_t uid ) ; -FUNCTION: passwd* getpwnam ( char* login ) ; -FUNCTION: int getpwnam_r ( char* login, passwd* pwd, char* buffer, size_t bufsize, passwd** result ) ; +FUNCTION: passwd* getpwnam ( c-string login ) ; +FUNCTION: int getpwnam_r ( c-string login, passwd* pwd, c-string buffer, size_t bufsize, passwd** result ) ; FUNCTION: int getgroups ( int gidsetlen, gid_t* gidset ) ; -FUNCTION: int getgrouplist ( char* name, int basegid, int* groups, int* ngroups ) ; +FUNCTION: int getgrouplist ( c-string name, int basegid, int* groups, int* ngroups ) ; FUNCTION: int getrlimit ( int resource, rlimit* rlp ) ; FUNCTION: int setrlimit ( int resource, rlimit* rlp ) ; FUNCTION: int getpriority ( int which, id_t who ) ; FUNCTION: int setpriority ( int which, id_t who, int prio ) ; FUNCTION: int getrusage ( int who, rusage* r_usage ) ; FUNCTION: group* getgrent ; -FUNCTION: int gethostname ( char* name, int len ) ; +FUNCTION: int gethostname ( c-string name, int len ) ; FUNCTION: int getsockname ( int socket, sockaddr* address, socklen_t* address_len ) ; FUNCTION: int getpeername ( int socket, sockaddr* address, socklen_t* address_len ) ; FUNCTION: uid_t getuid ; @@ -102,44 +102,44 @@ FUNCTION: uint htonl ( uint n ) ; FUNCTION: ushort htons ( ushort n ) ; ! FUNCTION: int issetugid ; FUNCTION: int isatty ( int fildes ) ; -FUNCTION: int ioctl ( int fd, ulong request, char* argp ) ; -FUNCTION: int lchown ( char* path, uid_t owner, gid_t group ) ; +FUNCTION: int ioctl ( int fd, ulong request, c-string argp ) ; +FUNCTION: int lchown ( c-string path, uid_t owner, gid_t group ) ; FUNCTION: int listen ( int s, int backlog ) ; FUNCTION: off_t lseek ( int fildes, off_t offset, int whence ) ; -FUNCTION: int mkdir ( char* path, mode_t mode ) ; +FUNCTION: int mkdir ( c-string path, mode_t mode ) ; FUNCTION: void* mmap ( void* addr, size_t len, int prot, int flags, int fd, off_t offset ) ; FUNCTION: int munmap ( void* addr, size_t len ) ; FUNCTION: uint ntohl ( uint n ) ; FUNCTION: ushort ntohs ( ushort n ) ; FUNCTION: int shutdown ( int fd, int how ) ; -FUNCTION: int open ( char* path, int flags, int prot ) ; -FUNCTION: DIR* opendir ( char* path ) ; +FUNCTION: int open ( c-string path, int flags, int prot ) ; +FUNCTION: DIR* opendir ( c-string path ) ; STRUCT: utimbuf { actime time_t } { modtime time_t } ; -FUNCTION: int utime ( char* path, utimbuf* buf ) ; +FUNCTION: int utime ( c-string path, utimbuf* buf ) ; FUNCTION: int pclose ( void* file ) ; FUNCTION: int pipe ( int* filedes ) ; -FUNCTION: void* popen ( char* command, char* type ) ; +FUNCTION: void* popen ( c-string command, c-string type ) ; FUNCTION: ssize_t read ( int fd, void* buf, size_t nbytes ) ; FUNCTION: dirent* readdir ( DIR* dirp ) ; FUNCTION: int readdir_r ( void* dirp, dirent* entry, dirent** result ) ; -FUNCTION: ssize_t readlink ( char* path, char* buf, size_t bufsize ) ; +FUNCTION: ssize_t readlink ( c-string path, c-string buf, size_t bufsize ) ; CONSTANT: PATH_MAX 1024 FUNCTION: ssize_t recv ( int s, void* buf, size_t nbytes, int flags ) ; FUNCTION: ssize_t recvfrom ( int s, void* buf, size_t nbytes, int flags, sockaddr-in* from, socklen_t* fromlen ) ; -FUNCTION: int rename ( char* from, char* to ) ; -FUNCTION: int rmdir ( char* path ) ; +FUNCTION: int rename ( c-string from, c-string to ) ; +FUNCTION: int rmdir ( c-string path ) ; FUNCTION: int select ( int nfds, void* readfds, void* writefds, void* exceptfds, timeval* timeout ) ; FUNCTION: ssize_t sendto ( int s, void* buf, size_t len, int flags, sockaddr-in* to, socklen_t tolen ) ; -FUNCTION: int setenv ( char* name, char* value, int overwrite ) ; -FUNCTION: int unsetenv ( char* name ) ; +FUNCTION: int setenv ( c-string name, c-string value, int overwrite ) ; +FUNCTION: int unsetenv ( c-string name ) ; FUNCTION: int setegid ( gid_t egid ) ; FUNCTION: int seteuid ( uid_t euid ) ; FUNCTION: int setgid ( gid_t gid ) ; @@ -149,11 +149,11 @@ FUNCTION: int setreuid ( uid_t ruid, uid_t euid ) ; FUNCTION: int setsockopt ( int s, int level, int optname, void* optval, socklen_t optlen ) ; FUNCTION: int setuid ( uid_t uid ) ; FUNCTION: int socket ( int domain, int type, int protocol ) ; -FUNCTION: int symlink ( char* path1, char* path2 ) ; -FUNCTION: int link ( char* path1, char* path2 ) ; -FUNCTION: int system ( char* command ) ; -FUNCTION: int unlink ( char* path ) ; -FUNCTION: int utimes ( char* path, timeval[2] times ) ; +FUNCTION: int symlink ( c-string path1, c-string path2 ) ; +FUNCTION: int link ( c-string path1, c-string path2 ) ; +FUNCTION: int system ( c-string command ) ; +FUNCTION: int unlink ( c-string path ) ; +FUNCTION: int utimes ( c-string path, timeval[2] times ) ; FUNCTION: ssize_t write ( int fd, void* buf, size_t nbytes ) ; "librt" "librt.so" "cdecl" add-library diff --git a/basis/unix/ffi/linux/linux.factor b/basis/unix/ffi/linux/linux.factor index 260796b5e4..3f19e18c14 100644 --- a/basis/unix/ffi/linux/linux.factor +++ b/basis/unix/ffi/linux/linux.factor @@ -38,7 +38,7 @@ STRUCT: addrinfo { protocol int } { addrlen socklen_t } { addr void* } - { canonname char* } + { canonname c-string } { next addrinfo* } ; STRUCT: sockaddr-in @@ -83,13 +83,13 @@ CONSTANT: SEEK_CUR 1 CONSTANT: SEEK_END 2 STRUCT: passwd - { pw_name char* } - { pw_passwd char* } + { pw_name c-string } + { pw_passwd c-string } { pw_uid uid_t } { pw_gid gid_t } - { pw_gecos char* } - { pw_dir char* } - { pw_shell char* } ; + { pw_gecos c-string } + { pw_dir c-string } + { pw_shell c-string } ; ! dirent64 STRUCT: dirent @@ -99,7 +99,7 @@ STRUCT: dirent { d_type uchar } { d_name char[256] } ; -FUNCTION: int open64 ( char* path, int flags, int prot ) ; +FUNCTION: int open64 ( c-string path, int flags, int prot ) ; FUNCTION: dirent* readdir64 ( DIR* dirp ) ; FUNCTION: int readdir64_r ( void* dirp, dirent* entry, dirent** result ) ; diff --git a/basis/unix/ffi/solaris/solaris.factor b/basis/unix/ffi/solaris/solaris.factor index d641961a25..a08785823a 100644 --- a/basis/unix/ffi/solaris/solaris.factor +++ b/basis/unix/ffi/solaris/solaris.factor @@ -35,7 +35,7 @@ STRUCT: addrinfo ! int _ai_pad; ! #endif { addrlen int } - { canonname char* } + { canonname c-string } { addr void* } { next void* } ; diff --git a/basis/unix/linux/inotify/inotify.factor b/basis/unix/linux/inotify/inotify.factor index f589c17e28..c296cc8166 100644 --- a/basis/unix/linux/inotify/inotify.factor +++ b/basis/unix/linux/inotify/inotify.factor @@ -52,5 +52,5 @@ CONSTANT: IN_ONESHOT HEX: 80000000 ! only send event once } flags ; foldable FUNCTION: int inotify_init ( ) ; -FUNCTION: int inotify_add_watch ( int fd, char* name, uint mask ) ; +FUNCTION: int inotify_add_watch ( int fd, c-string name, uint mask ) ; FUNCTION: int inotify_rm_watch ( int fd, uint wd ) ; diff --git a/basis/unix/process/process.factor b/basis/unix/process/process.factor index ab10aef3ea..4b33c37d07 100644 --- a/basis/unix/process/process.factor +++ b/basis/unix/process/process.factor @@ -11,9 +11,9 @@ FUNCTION: pid_t fork ( ) ; : fork-process ( -- pid ) [ fork ] unix-system-call ; -FUNCTION: int execv ( char* path, char** argv ) ; -FUNCTION: int execvp ( char* path, char** argv ) ; -FUNCTION: int execve ( char* path, char** argv, char** envp ) ; +FUNCTION: int execv ( c-string path, c-string* argv ) ; +FUNCTION: int execvp ( c-string path, c-string* argv ) ; +FUNCTION: int execve ( c-string path, c-string* argv, c-string* envp ) ; : exec ( pathname argv -- int ) [ utf8 malloc-string ] [ utf8 strings>alien ] bi* execv ; diff --git a/basis/unix/stat/freebsd/freebsd.factor b/basis/unix/stat/freebsd/freebsd.factor index 04f884e496..93ed1a42db 100644 --- a/basis/unix/stat/freebsd/freebsd.factor +++ b/basis/unix/stat/freebsd/freebsd.factor @@ -24,5 +24,5 @@ STRUCT: stat { st_birthtimespec timespec } { pad0 __int32_t[2] } ; -FUNCTION: int stat ( char* pathname, stat* buf ) ; -FUNCTION: int lstat ( char* pathname, stat* buf ) ; +FUNCTION: int stat ( c-string pathname, stat* buf ) ; +FUNCTION: int lstat ( c-string pathname, stat* buf ) ; diff --git a/basis/unix/stat/linux/32/32.factor b/basis/unix/stat/linux/32/32.factor index f01140ff4b..b3becff240 100644 --- a/basis/unix/stat/linux/32/32.factor +++ b/basis/unix/stat/linux/32/32.factor @@ -21,8 +21,8 @@ STRUCT: stat { st_ctimespec timespec } { st_ino ulonglong } ; -FUNCTION: int __xstat64 ( int ver, char* pathname, stat* buf ) ; -FUNCTION: int __lxstat64 ( int ver, char* pathname, stat* buf ) ; +FUNCTION: int __xstat64 ( int ver, c-string pathname, stat* buf ) ; +FUNCTION: int __lxstat64 ( int ver, c-string pathname, stat* buf ) ; : stat ( pathname buf -- int ) [ 1 ] 2dip __xstat64 ; : lstat ( pathname buf -- int ) [ 1 ] 2dip __lxstat64 ; diff --git a/basis/unix/stat/linux/64/64.factor b/basis/unix/stat/linux/64/64.factor index bb16133c76..0862bf82a0 100644 --- a/basis/unix/stat/linux/64/64.factor +++ b/basis/unix/stat/linux/64/64.factor @@ -21,8 +21,8 @@ STRUCT: stat { st_ctimespec timespec } { __unused0 long[3] } ; -FUNCTION: int __xstat64 ( int ver, char* pathname, stat* buf ) ; -FUNCTION: int __lxstat64 ( int ver, char* pathname, stat* buf ) ; +FUNCTION: int __xstat64 ( int ver, c-string pathname, stat* buf ) ; +FUNCTION: int __lxstat64 ( int ver, c-string pathname, stat* buf ) ; : stat ( pathname buf -- int ) [ 1 ] 2dip __xstat64 ; : lstat ( pathname buf -- int ) [ 1 ] 2dip __lxstat64 ; diff --git a/basis/unix/stat/macosx/macosx.factor b/basis/unix/stat/macosx/macosx.factor index 4e6b2dfb21..024cd317e8 100644 --- a/basis/unix/stat/macosx/macosx.factor +++ b/basis/unix/stat/macosx/macosx.factor @@ -26,8 +26,8 @@ STRUCT: stat { st_qspare0 __int64_t } { st_qspare1 __int64_t } ; -FUNCTION: int stat64 ( char* pathname, stat* buf ) ; -FUNCTION: int lstat64 ( char* pathname, stat* buf ) ; +FUNCTION: int stat64 ( c-string pathname, stat* buf ) ; +FUNCTION: int lstat64 ( c-string pathname, stat* buf ) ; : stat ( path buf -- n ) stat64 ; : lstat ( path buf -- n ) lstat64 ; diff --git a/basis/unix/stat/netbsd/32/32.factor b/basis/unix/stat/netbsd/32/32.factor index fb0d61b7e9..bb0a403751 100644 --- a/basis/unix/stat/netbsd/32/32.factor +++ b/basis/unix/stat/netbsd/32/32.factor @@ -23,8 +23,8 @@ STRUCT: stat { st_gen uint32_t } { st_qspare uint32_t[2] } ; -FUNCTION: int __stat30 ( char* pathname, stat* buf ) ; -FUNCTION: int __lstat30 ( char* pathname, stat* buf ) ; +FUNCTION: int __stat30 ( c-string pathname, stat* buf ) ; +FUNCTION: int __lstat30 ( c-string pathname, stat* buf ) ; : stat ( pathname buf -- n ) __stat30 ; : lstat ( pathname buf -- n ) __lstat30 ; diff --git a/basis/unix/stat/netbsd/64/64.factor b/basis/unix/stat/netbsd/64/64.factor index 47c4e0c129..010dcca724 100644 --- a/basis/unix/stat/netbsd/64/64.factor +++ b/basis/unix/stat/netbsd/64/64.factor @@ -23,8 +23,8 @@ STRUCT: stat { st_spare0 uint32_t } { st_birthtimespec timespec } ; -FUNCTION: int __stat13 ( char* pathname, stat* buf ) ; -FUNCTION: int __lstat13 ( char* pathname, stat* buf ) ; +FUNCTION: int __stat13 ( c-string pathname, stat* buf ) ; +FUNCTION: int __lstat13 ( c-string pathname, stat* buf ) ; : stat ( pathname buf -- n ) __stat13 ; : lstat ( pathname buf -- n ) __lstat13 ; diff --git a/basis/unix/stat/openbsd/openbsd.factor b/basis/unix/stat/openbsd/openbsd.factor index 2702e60f6c..b562d085b3 100644 --- a/basis/unix/stat/openbsd/openbsd.factor +++ b/basis/unix/stat/openbsd/openbsd.factor @@ -25,5 +25,5 @@ STRUCT: stat { st_birthtimespec timespec } { st_qspare int64_t[2] } ; -FUNCTION: int stat ( char* pathname, stat* buf ) ; -FUNCTION: int lstat ( char* pathname, stat* buf ) ; +FUNCTION: int stat ( c-string pathname, stat* buf ) ; +FUNCTION: int lstat ( c-string pathname, stat* buf ) ; diff --git a/basis/unix/statfs/freebsd/freebsd.factor b/basis/unix/statfs/freebsd/freebsd.factor index ae418e6eb4..f12473da92 100644 --- a/basis/unix/statfs/freebsd/freebsd.factor +++ b/basis/unix/statfs/freebsd/freebsd.factor @@ -31,4 +31,4 @@ STRUCT: statfs { f_mntfromname { char MNAMELEN } } { f_mntonname { char MNAMELEN } } ; -FUNCTION: int statfs ( char* path, statfs* buf ) ; +FUNCTION: int statfs ( c-string path, statfs* buf ) ; diff --git a/basis/unix/statfs/linux/linux.factor b/basis/unix/statfs/linux/linux.factor index ab37ab9605..2cf2541a10 100644 --- a/basis/unix/statfs/linux/linux.factor +++ b/basis/unix/statfs/linux/linux.factor @@ -16,4 +16,4 @@ STRUCT: statfs64 { f_frsize __SWORD_TYPE } { f_spare __SWORD_TYPE[5] } ; -FUNCTION: int statfs64 ( char* path, statfs64* buf ) ; +FUNCTION: int statfs64 ( c-string path, statfs64* buf ) ; diff --git a/basis/unix/statfs/macosx/macosx.factor b/basis/unix/statfs/macosx/macosx.factor index 56c8989895..75b231da96 100644 --- a/basis/unix/statfs/macosx/macosx.factor +++ b/basis/unix/statfs/macosx/macosx.factor @@ -116,5 +116,5 @@ STRUCT: statfs64 { f_mntfromname { char MAXPATHLEN } } { f_reserved uint32_t[8] } ; -FUNCTION: int statfs64 ( char* path, statfs64* buf ) ; +FUNCTION: int statfs64 ( c-string path, statfs64* buf ) ; FUNCTION: int getmntinfo64 ( statfs64** mntbufp, int flags ) ; diff --git a/basis/unix/statfs/openbsd/openbsd.factor b/basis/unix/statfs/openbsd/openbsd.factor index 4e65e74c2c..9c63bfa96b 100644 --- a/basis/unix/statfs/openbsd/openbsd.factor +++ b/basis/unix/statfs/openbsd/openbsd.factor @@ -31,4 +31,4 @@ STRUCT: statfs { f_mntfromname { char MNAMELEN } } { mount_info char[160] } ; -FUNCTION: int statfs ( char* path, statfs* buf ) ; +FUNCTION: int statfs ( c-string path, statfs* buf ) ; diff --git a/basis/unix/statvfs/freebsd/freebsd.factor b/basis/unix/statvfs/freebsd/freebsd.factor index c2834736b7..5e66a7daf9 100644 --- a/basis/unix/statvfs/freebsd/freebsd.factor +++ b/basis/unix/statvfs/freebsd/freebsd.factor @@ -20,4 +20,4 @@ STRUCT: statvfs CONSTANT: ST_RDONLY HEX: 1 ! Read-only file system CONSTANT: ST_NOSUID HEX: 2 ! Does not honor setuid/setgid -FUNCTION: int statvfs ( char* path, statvfs* buf ) ; +FUNCTION: int statvfs ( c-string path, statvfs* buf ) ; diff --git a/basis/unix/statvfs/linux/linux.factor b/basis/unix/statvfs/linux/linux.factor index d7139d84b2..bda1eb9605 100644 --- a/basis/unix/statvfs/linux/linux.factor +++ b/basis/unix/statvfs/linux/linux.factor @@ -17,7 +17,7 @@ STRUCT: statvfs64 { f_namemax ulong } { __f_spare int[6] } ; -FUNCTION: int statvfs64 ( char* path, statvfs64* buf ) ; +FUNCTION: int statvfs64 ( c-string path, statvfs64* buf ) ; CONSTANT: ST_RDONLY 1 ! Mount read-only. CONSTANT: ST_NOSUID 2 ! Ignore suid and sgid bits. diff --git a/basis/unix/statvfs/macosx/macosx.factor b/basis/unix/statvfs/macosx/macosx.factor index 3fe44a28d0..18b794acbf 100644 --- a/basis/unix/statvfs/macosx/macosx.factor +++ b/basis/unix/statvfs/macosx/macosx.factor @@ -20,4 +20,4 @@ STRUCT: statvfs CONSTANT: ST_RDONLY HEX: 1 ! Read-only file system CONSTANT: ST_NOSUID HEX: 2 ! Does not honor setuid/setgid -FUNCTION: int statvfs ( char* path, statvfs* buf ) ; +FUNCTION: int statvfs ( c-string path, statvfs* buf ) ; diff --git a/basis/unix/statvfs/netbsd/netbsd.factor b/basis/unix/statvfs/netbsd/netbsd.factor index a76774b656..f53d72f02e 100644 --- a/basis/unix/statvfs/netbsd/netbsd.factor +++ b/basis/unix/statvfs/netbsd/netbsd.factor @@ -33,4 +33,4 @@ STRUCT: statvfs { f_mntonname { char _VFS_MNAMELEN } } { f_mntfromname { char _VFS_MNAMELEN } } ; -FUNCTION: int statvfs ( char* path, statvfs* buf ) ; +FUNCTION: int statvfs ( c-string path, statvfs* buf ) ; diff --git a/basis/unix/statvfs/openbsd/openbsd.factor b/basis/unix/statvfs/openbsd/openbsd.factor index d5b2ee30a8..146db770ef 100644 --- a/basis/unix/statvfs/openbsd/openbsd.factor +++ b/basis/unix/statvfs/openbsd/openbsd.factor @@ -19,4 +19,4 @@ STRUCT: statvfs CONSTANT: ST_RDONLY 1 CONSTANT: ST_NOSUID 2 -FUNCTION: int statvfs ( char* path, statvfs* buf ) ; +FUNCTION: int statvfs ( c-string path, statvfs* buf ) ; diff --git a/basis/unix/time/time.factor b/basis/unix/time/time.factor index 0a63965c20..72132bb132 100644 --- a/basis/unix/time/time.factor +++ b/basis/unix/time/time.factor @@ -35,7 +35,7 @@ STRUCT: tm { yday int } { isdst int } { gmtoff long } - { zone char* } ; + { zone c-string } ; FUNCTION: time_t time ( time_t* t ) ; FUNCTION: tm* localtime ( time_t* clock ) ; diff --git a/basis/windows/kernel32/kernel32.factor b/basis/windows/kernel32/kernel32.factor index db0005e219..c2622cbf48 100644 --- a/basis/windows/kernel32/kernel32.factor +++ b/basis/windows/kernel32/kernel32.factor @@ -1352,7 +1352,7 @@ FUNCTION: DWORD GetPriorityClass ( HANDLE hProcess ) ; ! FUNCTION: GetPrivateProfileStringW ! FUNCTION: GetPrivateProfileStructA ! FUNCTION: GetPrivateProfileStructW -FUNCTION: LPVOID GetProcAddress ( HMODULE hModule, char* lpProcName ) ; +FUNCTION: LPVOID GetProcAddress ( HMODULE hModule, c-string lpProcName ) ; ! FUNCTION: GetProcessAffinityMask ! FUNCTION: GetProcessHandleCount ! FUNCTION: GetProcessHeap diff --git a/basis/windows/ole32/ole32.factor b/basis/windows/ole32/ole32.factor index 6e90cae89a..538a142878 100644 --- a/basis/windows/ole32/ole32.factor +++ b/basis/windows/ole32/ole32.factor @@ -10,8 +10,8 @@ LIBRARY: ole32 TYPEDEF: GUID* REFGUID TYPEDEF: void* LPUNKNOWN -TYPEDEF: wchar_t* LPOLESTR -TYPEDEF: wchar_t* LPCOLESTR +TYPEDEF: LPWSTR LPOLESTR +TYPEDEF: LPWSTR LPCOLESTR TYPEDEF: REFGUID LPGUID TYPEDEF: REFGUID REFIID diff --git a/basis/windows/opengl32/opengl32.factor b/basis/windows/opengl32/opengl32.factor index 63f705263c..32e067a200 100644 --- a/basis/windows/opengl32/opengl32.factor +++ b/basis/windows/opengl32/opengl32.factor @@ -57,7 +57,7 @@ FUNCTION: BOOL wglMakeCurrent ( HDC hDC, HGLRC hglrc ) ; ! WGL_ARB_extensions_string extension -GL-FUNCTION: char* wglGetExtensionsStringARB { } ( HDC hDC ) ; +GL-FUNCTION: c-string wglGetExtensionsStringARB { } ( HDC hDC ) ; ! WGL_ARB_pixel_format extension diff --git a/basis/windows/types/types.factor b/basis/windows/types/types.factor index d0dac31ea9..e2e4b113a4 100644 --- a/basis/windows/types/types.factor +++ b/basis/windows/types/types.factor @@ -11,7 +11,6 @@ TYPEDEF: uchar UCHAR TYPEDEF: uchar BYTE TYPEDEF: ushort wchar_t -<< { char* utf16n } pointer: wchar_t typedef >> TYPEDEF: wchar_t WCHAR @@ -70,8 +69,8 @@ TYPEDEF: ULARGE_INTEGER* PULARGE_INTEGER TYPEDEF: size_t SIZE_T TYPEDEF: ptrdiff_t SSIZE_T -TYPEDEF: wchar_t* LPCSTR -TYPEDEF: wchar_t* LPWSTR +TYPEDEF: { c-string utf16n } LPCSTR +TYPEDEF: { c-string utf16n } LPWSTR TYPEDEF: WCHAR TCHAR TYPEDEF: LPWSTR LPTCH TYPEDEF: LPWSTR PTCH @@ -125,14 +124,14 @@ TYPEDEF: DWORD LGRPID TYPEDEF: LONG_PTR LPARAM TYPEDEF: BOOL* LPBOOL TYPEDEF: BYTE* LPBYTE -TYPEDEF: WCHAR* LPCWSTR +TYPEDEF: { c-string utf16n } LPCWSTR ! TYPEDEF: WCHAR* LPWSTR -TYPEDEF: WCHAR* LPSTR -TYPEDEF: wchar_t* LPCTSTR -TYPEDEF: wchar_t* LPWTSTR +TYPEDEF: { c-string utf16n } LPSTR +TYPEDEF: { c-string utf16n } LPCTSTR +TYPEDEF: { c-string utf16n } LPWTSTR -TYPEDEF: wchar_t* LPTSTR +TYPEDEF: { c-string utf16n } LPTSTR TYPEDEF: LPCSTR PCTSTR TYPEDEF: LPSTR PTSTR @@ -145,7 +144,7 @@ TYPEDEF: BOOLEAN* PBOOLEAN TYPEDEF: BYTE* PBYTE TYPEDEF: CHAR* PCHAR TYPEDEF: CHAR* PCSTR -TYPEDEF: WCHAR* PCWSTR +TYPEDEF: { c-string utf16n } PCWSTR TYPEDEF: DWORD* PDWORD TYPEDEF: DWORDLONG* PDWORDLONG TYPEDEF: DWORD_PTR* PDWORD_PTR @@ -182,9 +181,9 @@ TYPEDEF: ULONG_PTR* PULONG_PTR TYPEDEF: ULONG32* PULONG32 TYPEDEF: ULONG64* PULONG64 TYPEDEF: USHORT* PUSHORT -TYPEDEF: WCHAR* PWCHAR +TYPEDEF: { c-string utf16n } PWCHAR TYPEDEF: WORD* PWORD -TYPEDEF: WCHAR* PWSTR +TYPEDEF: { c-string utf16n } PWSTR TYPEDEF: HANDLE SC_HANDLE TYPEDEF: LPVOID SC_LOCK TYPEDEF: HANDLE SERVICE_STATUS_HANDLE @@ -350,7 +349,7 @@ STRUCT: LVITEM STRUCT: LVFINDINFO { flags uint } - { psz char* } + { psz c-string } { lParam long } { pt POINT } { vkDirection uint } ; diff --git a/basis/windows/user32/user32.factor b/basis/windows/user32/user32.factor index 27636271cb..a966b63308 100644 --- a/basis/windows/user32/user32.factor +++ b/basis/windows/user32/user32.factor @@ -1186,8 +1186,8 @@ FUNCTION: UINT EnumClipboardFormats ( UINT format ) ; ! FUNCTION: ExcludeUpdateRgn ! FUNCTION: ExitWindowsEx FUNCTION: int FillRect ( HDC hDC, RECT* lprc, HBRUSH hbr ) ; -FUNCTION: HWND FindWindowA ( char* lpClassName, char* lpWindowName ) ; -FUNCTION: HWND FindWindowExA ( HWND hwndParent, HWND childAfter, char* lpClassName, char* lpWindowName ) ; +FUNCTION: HWND FindWindowA ( c-string lpClassName, c-string lpWindowName ) ; +FUNCTION: HWND FindWindowExA ( HWND hwndParent, HWND childAfter, c-string lpClassName, c-string lpWindowName ) ; ! FUNCTION: FindWindowExW ! FUNCTION: FindWindowW ! FUNCTION: FlashWindow @@ -1352,7 +1352,7 @@ ALIAS: GetWindowLong GetWindowLongW FUNCTION: BOOL GetWindowRect ( HWND hWnd, LPRECT lpRect ) ; ! FUNCTION: GetWindowRgn ! FUNCTION: GetWindowRgnBox -FUNCTION: int GetWindowTextA ( HWND hWnd, char* lpString, int nMaxCount ) ; +FUNCTION: int GetWindowTextA ( HWND hWnd, c-string lpString, int nMaxCount ) ; ! FUNCTION: GetWindowTextLengthA ! FUNCTION: GetWindowTextLengthW ! FUNCTION: GetWindowTextW diff --git a/basis/windows/winsock/winsock.factor b/basis/windows/winsock/winsock.factor index 818737ca5a..b58cbcacbd 100644 --- a/basis/windows/winsock/winsock.factor +++ b/basis/windows/winsock/winsock.factor @@ -121,7 +121,7 @@ STRUCT: sockaddr-in6 { scopeid uint } ; STRUCT: hostent - { name char* } + { name c-string } { aliases void* } { addrtype short } { length short } @@ -133,7 +133,7 @@ STRUCT: addrinfo { socktype int } { protocol int } { addrlen size_t } - { canonname char* } + { canonname c-string } { addr sockaddr* } { next addrinfo* } ; @@ -145,29 +145,29 @@ C-TYPE: fd_set LIBRARY: winsock -FUNCTION: int setsockopt ( SOCKET s, int level, int optname, char* optval, int optlen ) ; +FUNCTION: int setsockopt ( SOCKET s, int level, int optname, c-string optval, int optlen ) ; FUNCTION: ushort htons ( ushort n ) ; FUNCTION: ushort ntohs ( ushort n ) ; FUNCTION: int bind ( void* socket, sockaddr-in* sockaddr, int len ) ; FUNCTION: int listen ( void* socket, int backlog ) ; -FUNCTION: char* inet_ntoa ( int in-addr ) ; -FUNCTION: int getaddrinfo ( char* nodename, - char* servername, +FUNCTION: c-string inet_ntoa ( int in-addr ) ; +FUNCTION: int getaddrinfo ( c-string nodename, + c-string servername, addrinfo* hints, addrinfo** res ) ; FUNCTION: void freeaddrinfo ( addrinfo* ai ) ; -FUNCTION: hostent* gethostbyname ( char* name ) ; -FUNCTION: int gethostname ( char* name, int len ) ; +FUNCTION: hostent* gethostbyname ( c-string name ) ; +FUNCTION: int gethostname ( c-string name, int len ) ; FUNCTION: int connect ( void* socket, sockaddr-in* sockaddr, int addrlen ) ; FUNCTION: int select ( int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, timeval* timeout ) ; FUNCTION: int closesocket ( SOCKET s ) ; FUNCTION: int shutdown ( SOCKET s, int how ) ; -FUNCTION: int send ( SOCKET s, char* buf, int len, int flags ) ; -FUNCTION: int recv ( SOCKET s, char* buf, int len, int flags ) ; +FUNCTION: int send ( SOCKET s, c-string buf, int len, int flags ) ; +FUNCTION: int recv ( SOCKET s, c-string buf, int len, int flags ) ; FUNCTION: int getsockname ( SOCKET s, sockaddr-in* address, int* addrlen ) ; FUNCTION: int getpeername ( SOCKET s, sockaddr-in* address, int* addrlen ) ; diff --git a/basis/x11/glx/glx.factor b/basis/x11/glx/glx.factor index 5bc58e5f0a..d095853913 100644 --- a/basis/x11/glx/glx.factor +++ b/basis/x11/glx/glx.factor @@ -55,9 +55,9 @@ X-FUNCTION: void glXSwapBuffers ( Display* dpy, GLXDrawable drawable ) ; X-FUNCTION: void glXUseXFont ( Font font, int first, int count, int listBase ) ; X-FUNCTION: void glXWaitGL ( ) ; X-FUNCTION: void glXWaitX ( ) ; -X-FUNCTION: char* glXGetClientString ( Display* dpy, int name ) ; -X-FUNCTION: char* glXQueryServerString ( Display* dpy, int screen, int name ) ; -X-FUNCTION: char* glXQueryExtensionsString ( Display* dpy, int screen ) ; +X-FUNCTION: c-string glXGetClientString ( Display* dpy, int name ) ; +X-FUNCTION: c-string glXQueryServerString ( Display* dpy, int screen, int name ) ; +X-FUNCTION: c-string glXQueryExtensionsString ( Display* dpy, int screen ) ; ! New for GLX 1.3 X-FUNCTION: GLXFBConfig* glXGetFBConfigs ( Display* dpy, int screen, int* nelements ) ; @@ -80,10 +80,10 @@ X-FUNCTION: void glXSelectEvent ( Display* dpy, GLXDrawable draw, ulong event_ma X-FUNCTION: void glXGetSelectedEvent ( Display* dpy, GLXDrawable draw, ulong* event_mask ) ; ! GLX 1.4 and later -X-FUNCTION: void* glXGetProcAddress ( char* procname ) ; +X-FUNCTION: void* glXGetProcAddress ( c-string procname ) ; ! GLX_ARB_get_proc_address extension -X-FUNCTION: void* glXGetProcAddressARB ( char* procname ) ; +X-FUNCTION: void* glXGetProcAddressARB ( c-string procname ) ; ! GLX_ARB_multisample CONSTANT: GLX_SAMPLE_BUFFERS 100000 diff --git a/basis/x11/xlib/xlib.factor b/basis/x11/xlib/xlib.factor index 7235aaf679..88b058abea 100644 --- a/basis/x11/xlib/xlib.factor +++ b/basis/x11/xlib/xlib.factor @@ -30,7 +30,7 @@ TYPEDEF: XID KeySym TYPEDEF: ulong Atom -TYPEDEF: char* XPointer +TYPEDEF: c-string XPointer C-TYPE: Screen TYPEDEF: void* GC C-TYPE: Visual @@ -256,13 +256,13 @@ X-FUNCTION: Bool XQueryPointer ( Display* display, Window w, Window* root_return ! 4.3 - Properties and Atoms -X-FUNCTION: Atom XInternAtom ( Display* display, char* atom_name, Bool only_if_exists ) ; +X-FUNCTION: Atom XInternAtom ( Display* display, c-string atom_name, Bool only_if_exists ) ; -X-FUNCTION: char* XGetAtomName ( Display* display, Atom atom ) ; +X-FUNCTION: c-string XGetAtomName ( Display* display, Atom atom ) ; ! 4.4 - Obtaining and Changing Window Properties -X-FUNCTION: int XGetWindowProperty ( Display* display, Window w, Atom property, long long_offset, long long_length, Bool delete, Atom req_type, Atom* actual_type_return, int* actual_format_return, ulong* nitems_return, ulong* bytes_after_return, char** prop_return ) ; +X-FUNCTION: int XGetWindowProperty ( Display* display, Window w, Atom property, long long_offset, long long_length, Bool delete, Atom req_type, Atom* actual_type_return, int* actual_format_return, ulong* nitems_return, ulong* bytes_after_return, c-string* prop_return ) ; X-FUNCTION: int XChangeProperty ( Display* display, Window w, Atom property, Atom type, int format, int mode, void* data, int nelements ) ; @@ -302,7 +302,7 @@ STRUCT: XColor { flags char } { pad char } ; -X-FUNCTION: Status XLookupColor ( Display* display, Colormap colormap, char* color_name, XColor* exact_def_return, XColor* screen_def_return ) ; +X-FUNCTION: Status XLookupColor ( Display* display, Colormap colormap, c-string color_name, XColor* exact_def_return, XColor* screen_def_return ) ; X-FUNCTION: Status XAllocColor ( Display* display, Colormap colormap, XColor* screen_in_out ) ; X-FUNCTION: Status XQueryColor ( Display* display, Colormap colormap, XColor* def_in_out ) ; @@ -430,11 +430,11 @@ STRUCT: XFontStruct { ascent int } { descent int } ; -X-FUNCTION: Font XLoadFont ( Display* display, char* name ) ; +X-FUNCTION: Font XLoadFont ( Display* display, c-string name ) ; X-FUNCTION: XFontStruct* XQueryFont ( Display* display, XID font_ID ) ; -X-FUNCTION: XFontStruct* XLoadQueryFont ( Display* display, char* name ) ; +X-FUNCTION: XFontStruct* XLoadQueryFont ( Display* display, c-string name ) ; -X-FUNCTION: int XTextWidth ( XFontStruct* font_struct, char* string, int count ) ; +X-FUNCTION: int XTextWidth ( XFontStruct* font_struct, c-string string, int count ) ; ! 8.6 - Drawing Text @@ -444,7 +444,7 @@ X-FUNCTION: Status XDrawString ( GC gc, int x, int y, - char* string, + c-string string, int length ) ; ! 8.7 - Transferring Images between Client and Server @@ -464,7 +464,7 @@ STRUCT: XImage { height int } { xoffset int } { format int } -{ data char* } +{ data c-string } { byte_order int } { bitmap_unit int } { bitmap_bit_order int } @@ -1116,7 +1116,7 @@ X-FUNCTION: Status XWarpPointer ( Display* display, Window src_w, Window dest_w, ! 14.1 Client to Window Manager Communication -X-FUNCTION: Status XFetchName ( Display* display, Window w, char** window_name_return ) ; +X-FUNCTION: Status XFetchName ( Display* display, Window w, c-string* window_name_return ) ; X-FUNCTION: Status XGetTransientForHint ( Display* display, Window w, Window* prop_window_return ) ; ! 14.1.1. Manipulating Top-Level Windows @@ -1220,7 +1220,7 @@ STRUCT: XVisualInfo X-FUNCTION: Pixmap XCreateBitmapFromData ( Display* display, Drawable d, - char* data, + c-string data, uint width, uint height ) ; @@ -1231,10 +1231,10 @@ X-FUNCTION: Pixmap XCreateBitmapFromData ( X-FUNCTION: Status XSetStandardProperties ( Display* display, Window w, - char* window_name, - char* icon_name, + c-string window_name, + c-string icon_name, Pixmap icon_pixmap, - char** argv, + c-string* argv, int argc, XSizeHints* hints ) ; @@ -1316,7 +1316,7 @@ CONSTANT: XA_LAST_PREDEFINED 68 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! X-FUNCTION: void XFree ( void* data ) ; -X-FUNCTION: int XStoreName ( Display* display, Window w, char* window_name ) ; +X-FUNCTION: int XStoreName ( Display* display, Window w, c-string window_name ) ; X-FUNCTION: void XSetWMNormalHints ( Display* display, Window w, XSizeHints* hints ) ; X-FUNCTION: int XBell ( Display* display, int percent ) ; @@ -1384,11 +1384,11 @@ CONSTANT: XLookupBoth 4 X-FUNCTION: Bool XFilterEvent ( XEvent* event, Window w ) ; -X-FUNCTION: XIM XOpenIM ( Display* dpy, void* rdb, char* res_name, char* res_class ) ; +X-FUNCTION: XIM XOpenIM ( Display* dpy, void* rdb, c-string res_name, c-string res_class ) ; X-FUNCTION: Status XCloseIM ( XIM im ) ; -X-FUNCTION: XIC XCreateIC ( XIM im, char* key1, Window value1, char* key2, Window value2, char* key3, int value3, char* key4, char* value4, char* key5, char* value5, int key6 ) ; +X-FUNCTION: XIC XCreateIC ( XIM im, c-string key1, Window value1, c-string key2, Window value2, c-string key3, int value3, c-string key4, c-string value4, c-string key5, c-string value5, int key6 ) ; X-FUNCTION: void XDestroyIC ( XIC ic ) ; @@ -1398,7 +1398,7 @@ X-FUNCTION: void XUnsetICFocus ( XIC ic ) ; X-FUNCTION: int XwcLookupString ( XIC ic, XKeyPressedEvent* event, ulong* buffer_return, int bytes_buffer, KeySym* keysym_return, Status* status_return ) ; -X-FUNCTION: int Xutf8LookupString ( XIC ic, XKeyPressedEvent* event, char* buffer_return, int bytes_buffer, KeySym* keysym_return, Status* status_return ) ; +X-FUNCTION: int Xutf8LookupString ( XIC ic, XKeyPressedEvent* event, c-string buffer_return, int bytes_buffer, KeySym* keysym_return, Status* status_return ) ; ! !!! category of setlocale CONSTANT: LC_ALL 0 @@ -1408,8 +1408,8 @@ CONSTANT: LC_MONETARY 3 CONSTANT: LC_NUMERIC 4 CONSTANT: LC_TIME 5 -X-FUNCTION: char* setlocale ( int category, char* name ) ; +X-FUNCTION: c-string setlocale ( int category, c-string name ) ; X-FUNCTION: Bool XSupportsLocale ( ) ; -X-FUNCTION: char* XSetLocaleModifiers ( char* modifier_list ) ; +X-FUNCTION: c-string XSetLocaleModifiers ( c-string modifier_list ) ; diff --git a/extra/chipmunk/chipmunk.factor b/extra/chipmunk/chipmunk.factor index a7cd5e0fd2..b24232147c 100644 --- a/extra/chipmunk/chipmunk.factor +++ b/extra/chipmunk/chipmunk.factor @@ -41,7 +41,7 @@ FUNCTION: cpVect cpvslerp ( cpVect v1, cpVect v2, cpFloat t ) ; FUNCTION: cpVect cpvslerpconst ( cpVect v1, cpVect v2, cpFloat a ) ; FUNCTION: cpVect cpvforangle ( cpFloat a ) ; FUNCTION: cpFloat cpvtoangle ( cpVect v ) ; -FUNCTION: char* cpvstr ( cpVect v ) ; +FUNCTION: c-string cpvstr ( cpVect v ) ; TYPED: cpvadd ( v1: cpVect v2: cpVect -- v3: cpVect ) [ [ x>> ] bi@ + ] diff --git a/extra/curses/ffi/ffi.factor b/extra/curses/ffi/ffi.factor index a9edc2e92b..222885b72c 100644 --- a/extra/curses/ffi/ffi.factor +++ b/extra/curses/ffi/ffi.factor @@ -58,7 +58,7 @@ STRUCT: c-window { _use_keypad bool } { _delay int } - { _line char* } + { _line c-string } { _regtop NCURSES_SIZE_T } { _regbottom NCURSES_SIZE_T } @@ -79,7 +79,7 @@ C-GLOBAL: void* stdscr FUNCTION: WINDOW* initscr ( ) ; FUNCTION: int endwin ( ) ; FUNCTION: bool isendwin ( ) ; -FUNCTION: SCREEN* newterm ( char* type, FILE* outfd, FILE* infd ) ; +FUNCTION: SCREEN* newterm ( c-string type, FILE* outfd, FILE* infd ) ; FUNCTION: SCREEN* set_term ( SCREEN* new ) ; FUNCTION: void delscreen ( SCREEN* sp ) ; @@ -157,21 +157,21 @@ FUNCTION: int mvwgetch ( WINDOW* win, int y, int x ) ; FUNCTION: int ungetch ( int ch ) ; FUNCTION: int has_key ( int ch ) ; -FUNCTION: int getstr ( char* str ) ; -FUNCTION: int getnstr ( char* str, int n ) ; -FUNCTION: int wgetstr ( WINDOW* win, char* str ) ; -FUNCTION: int wgetnstr ( WINDOW* win, char* str, int n ) ; -FUNCTION: int mvgetstr ( int y, int x, char* str ) ; -FUNCTION: int mvwgetstr ( WINDOW* win, int y, int x, char* str ) ; -FUNCTION: int mvgetnstr ( int y, int x, char* str, int n ) ; -FUNCTION: int mvwgetnstr ( WINDOW* win, int y, int x, char* str, int n ) ; +FUNCTION: int getstr ( c-string str ) ; +FUNCTION: int getnstr ( c-string str, int n ) ; +FUNCTION: int wgetstr ( WINDOW* win, c-string str ) ; +FUNCTION: int wgetnstr ( WINDOW* win, c-string str, int n ) ; +FUNCTION: int mvgetstr ( int y, int x, c-string str ) ; +FUNCTION: int mvwgetstr ( WINDOW* win, int y, int x, c-string str ) ; +FUNCTION: int mvgetnstr ( int y, int x, c-string str, int n ) ; +FUNCTION: int mvwgetnstr ( WINDOW* win, int y, int x, c-string str, int n ) ; -FUNCTION: int printw ( char* fmt, int lol ) ; -FUNCTION: int wprintw ( WINDOW* win, char* fmt, int lol ) ; -FUNCTION: int mvprintw ( int y, int x, char* fmt, int lol ) ; -FUNCTION: int mvwprintw ( WINDOW* win, int y, int x, char* fmt, int lol ) ; -FUNCTION: int vwprintw ( WINDOW* win, char* fmt, va_list varglist ) ; -FUNCTION: int vw_printw ( WINDOW* win, char* fmt, va_list varglist ) ; +FUNCTION: int printw ( c-string fmt, int lol ) ; +FUNCTION: int wprintw ( WINDOW* win, c-string fmt, int lol ) ; +FUNCTION: int mvprintw ( int y, int x, c-string fmt, int lol ) ; +FUNCTION: int mvwprintw ( WINDOW* win, int y, int x, c-string fmt, int lol ) ; +FUNCTION: int vwprintw ( WINDOW* win, c-string fmt, va_list varglist ) ; +FUNCTION: int vw_printw ( WINDOW* win, c-string fmt, va_list varglist ) ; FUNCTION: int move ( int y, int x ) ; FUNCTION: int wmove ( WINDOW* win, int y, int x ) ; @@ -221,11 +221,11 @@ FUNCTION: int winsdelln ( WINDOW* win, int n ) ; FUNCTION: int insertln ( ) ; FUNCTION: int winsertln ( WINDOW* win ) ; -FUNCTION: int addstr ( char* str ) ; -FUNCTION: int addnstr ( char* str, int n ) ; -FUNCTION: int waddstr ( WINDOW* win, char* str ) ; -FUNCTION: int waddnstr ( WINDOW* win, char* str, int n ) ; -FUNCTION: int mvaddstr ( int y, int x, char* str ) ; -FUNCTION: int mvaddnstr ( int y, int x, char* str, int n ) ; -FUNCTION: int mvwaddstr ( WINDOW* win, int y, int x, char* str ) ; -FUNCTION: int mvwaddnstr ( WINDOW* win, int y, int x, char* str, int n ) ; +FUNCTION: int addstr ( c-string str ) ; +FUNCTION: int addnstr ( c-string str, int n ) ; +FUNCTION: int waddstr ( WINDOW* win, c-string str ) ; +FUNCTION: int waddnstr ( WINDOW* win, c-string str, int n ) ; +FUNCTION: int mvaddstr ( int y, int x, c-string str ) ; +FUNCTION: int mvaddnstr ( int y, int x, c-string str, int n ) ; +FUNCTION: int mvwaddstr ( WINDOW* win, int y, int x, c-string str ) ; +FUNCTION: int mvwaddnstr ( WINDOW* win, int y, int x, c-string str, int n ) ; diff --git a/extra/freetype/freetype.factor b/extra/freetype/freetype.factor index 955672d03b..d131d2eb35 100644 --- a/extra/freetype/freetype.factor +++ b/extra/freetype/freetype.factor @@ -83,7 +83,7 @@ STRUCT: glyph { n-points short } { points void* } - { tags char* } + { tags c-string } { contours short* } { outline-flags int } diff --git a/extra/libusb/libusb.factor b/extra/libusb/libusb.factor index d521015d6f..38bf49ed5b 100644 --- a/extra/libusb/libusb.factor +++ b/extra/libusb/libusb.factor @@ -128,7 +128,7 @@ STRUCT: libusb_endpoint_descriptor { bInterval uint8_t } { bRefresh uint8_t } { bSynchAddress uint8_t } - { extra uchar* } + { extra c-string } { extra_length int } ; STRUCT: libusb_interface_descriptor @@ -142,7 +142,7 @@ STRUCT: libusb_interface_descriptor { bInterfaceProtocol uint8_t } { iInterface uint8_t } { endpoint libusb_endpoint_descriptor* } - { extra uchar* } + { extra c-string } { extra_length int } ; STRUCT: libusb_interface @@ -159,7 +159,7 @@ STRUCT: libusb_config_descriptor { bmAttributes uint8_t } { MaxPower uint8_t } { interface libusb_interface* } - { extra uchar* } + { extra c-string } { extra_length int } ; STRUCT: libusb_control_setup @@ -227,7 +227,7 @@ STRUCT: libusb_transfer { actual_length int } { callback libusb_transfer_cb_fn } { user_data void* } - { buffer uchar* } + { buffer c-string } { num_iso_packets int } { iso_packet_desc libusb_iso_packet_descriptor[0] } ; @@ -370,14 +370,14 @@ FUNCTION: void libusb_free_transfer ( libusb_transfer* transfer ) ; FUNCTION: int libusb_control_transfer ( libusb_device_handle* dev_handle, uint8_t request_type, uint8_t request, uint16_t value, uint16_t index, - uchar* data, uint16_t length, uint timeout ) ; + c-string data, uint16_t length, uint timeout ) ; FUNCTION: int libusb_bulk_transfer ( libusb_device_handle* dev_handle, - uchar endpoint, uchar* data, int length, + uchar endpoint, c-string data, int length, int* actual_length, uint timeout ) ; FUNCTION: int libusb_interrupt_transfer ( libusb_device_handle* dev_handle, - uchar endpoint, uchar* data, int length, + uchar endpoint, c-string data, int length, int* actual_length, int timeout ) ; :: libusb_get_descriptor ( dev desc_type desc_index data length -- int ) @@ -392,7 +392,7 @@ FUNCTION: int libusb_interrupt_transfer ( libusb_device_handle* dev_handle, FUNCTION: int libusb_get_string_descriptor_ascii ( libusb_device_handle* dev, uint8_t index, - uchar* data, + c-string data, int length ) ; FUNCTION: int libusb_try_lock_events ( libusb_context* ctx ) ; diff --git a/extra/llvm/core/core.factor b/extra/llvm/core/core.factor index 0d1b22e288..f0a3cafe33 100644 --- a/extra/llvm/core/core.factor +++ b/extra/llvm/core/core.factor @@ -137,11 +137,11 @@ TYPEDEF: void* LLVMMemoryBufferRef ! Functions -FUNCTION: void LLVMDisposeMessage ( char* Message ) ; +FUNCTION: void LLVMDisposeMessage ( c-string Message ) ; -FUNCTION: LLVMModuleRef LLVMModuleCreateWithName ( char* ModuleID ) ; +FUNCTION: LLVMModuleRef LLVMModuleCreateWithName ( c-string ModuleID ) ; -FUNCTION: int LLVMAddTypeName ( LLVMModuleRef M, char* Name, LLVMTypeRef Ty ) ; +FUNCTION: int LLVMAddTypeName ( LLVMModuleRef M, c-string Name, LLVMTypeRef Ty ) ; FUNCTION: void LLVMDisposeModule ( LLVMModuleRef M ) ; @@ -230,7 +230,7 @@ FUNCTION: unsigned LLVMCountParams ( LLVMValueRef Fn ) ; FUNCTION: void LLVMGetParams ( LLVMValueRef Fn, LLVMValueRef* Params ) ; FUNCTION: LLVMValueRef -LLVMAddFunction ( LLVMModuleRef M, char* Name, LLVMTypeRef FunctionTy ) ; +LLVMAddFunction ( LLVMModuleRef M, c-string Name, LLVMTypeRef FunctionTy ) ; FUNCTION: LLVMValueRef LLVMGetFirstFunction ( LLVMModuleRef M ) ; @@ -241,15 +241,15 @@ FUNCTION: unsigned LLVMGetFunctionCallConv ( LLVMValueRef Fn ) ; FUNCTION: void LLVMSetFunctionCallConv ( LLVMValueRef Fn, unsigned CC ) ; FUNCTION: LLVMBasicBlockRef -LLVMAppendBasicBlock ( LLVMValueRef Fn, char* Name ) ; +LLVMAppendBasicBlock ( LLVMValueRef Fn, c-string Name ) ; FUNCTION: LLVMValueRef LLVMGetBasicBlockParent ( LLVMBasicBlockRef BB ) ; ! Values FUNCTION: LLVMTypeRef LLVMTypeOf ( LLVMValueRef Val ) ; -FUNCTION: char* LLVMGetValueName ( LLVMValueRef Val ) ; -FUNCTION: void LLVMSetValueName ( LLVMValueRef Val, char* Name ) ; +FUNCTION: c-string LLVMGetValueName ( LLVMValueRef Val ) ; +FUNCTION: void LLVMSetValueName ( LLVMValueRef Val, c-string Name ) ; FUNCTION: void LLVMDumpValue ( LLVMValueRef Val ) ; ! Instruction Builders @@ -284,7 +284,7 @@ FUNCTION: LLVMValueRef LLVMBuildSwitch ( LLVMBuilderRef Builder, LLVMValueRef V, LLVMBasicBlockRef Else, unsigned NumCases ) ; FUNCTION: LLVMValueRef LLVMBuildInvoke ( LLVMBuilderRef Builder, LLVMValueRef Fn, LLVMValueRef* Args, unsigned NumArgs, - LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, char* Name ) ; + LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildUnwind ( LLVMBuilderRef Builder ) ; FUNCTION: LLVMValueRef LLVMBuildUnreachable @@ -298,126 +298,126 @@ FUNCTION: void LLVMAddCase ! IB Arithmetic FUNCTION: LLVMValueRef LLVMBuildAdd -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildSub -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildMul -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildUDiv -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildSDiv -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildFDiv -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildURem -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildSRem -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildFRem -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildShl -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildLShr -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildAShr -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildAnd -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildOr -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildXor -( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildNeg -( LLVMBuilderRef Builder, LLVMValueRef V, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef V, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildNot -( LLVMBuilderRef Builder, LLVMValueRef V, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef V, c-string Name ) ; ! IB Memory FUNCTION: LLVMValueRef LLVMBuildMalloc -( LLVMBuilderRef Builder, LLVMTypeRef Ty, char* Name ) ; +( LLVMBuilderRef Builder, LLVMTypeRef Ty, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildArrayMalloc -( LLVMBuilderRef Builder, LLVMTypeRef Ty, LLVMValueRef Val, char* Name ) ; +( LLVMBuilderRef Builder, LLVMTypeRef Ty, LLVMValueRef Val, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildAlloca -( LLVMBuilderRef Builder, LLVMTypeRef Ty, char* Name ) ; +( LLVMBuilderRef Builder, LLVMTypeRef Ty, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildArrayAlloca -( LLVMBuilderRef Builder, LLVMTypeRef Ty, LLVMValueRef Val, char* Name ) ; +( LLVMBuilderRef Builder, LLVMTypeRef Ty, LLVMValueRef Val, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildFree ( LLVMBuilderRef Builder, LLVMValueRef PointerVal ) ; FUNCTION: LLVMValueRef LLVMBuildLoad -( LLVMBuilderRef Builder, LLVMValueRef PointerVal, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef PointerVal, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildStore ( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMValueRef Ptr ) ; FUNCTION: LLVMValueRef LLVMBuildGEP ( LLVMBuilderRef B, LLVMValueRef Pointer, LLVMValueRef* Indices, - unsigned NumIndices, char* Name ) ; + unsigned NumIndices, c-string Name ) ; ! IB Casts FUNCTION: LLVMValueRef LLVMBuildTrunc -( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildZExt -( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildSExt -( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildFPToUI -( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildFPToSI -( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildUIToFP -( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildSIToFP -( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildFPTrunc -( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildFPExt -( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildPtrToInt -( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildIntToPtr -( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildBitCast -( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef Val, LLVMTypeRef DestTy, c-string Name ) ; ! IB Comparisons FUNCTION: LLVMValueRef LLVMBuildICmp -( LLVMBuilderRef Builder, LLVMIntPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMIntPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildFCmp -( LLVMBuilderRef Builder, LLVMRealPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, char* Name ) ; +( LLVMBuilderRef Builder, LLVMRealPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, c-string Name ) ; ! IB Misc Instructions FUNCTION: LLVMValueRef LLVMBuildPhi -( LLVMBuilderRef Builder, LLVMTypeRef Ty, char* Name ) ; +( LLVMBuilderRef Builder, LLVMTypeRef Ty, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildCall -( LLVMBuilderRef Builder, LLVMValueRef Fn, LLVMValueRef* Args, unsigned NumArgs, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef Fn, LLVMValueRef* Args, unsigned NumArgs, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildSelect -( LLVMBuilderRef Builder, LLVMValueRef If, LLVMValueRef Then, LLVMValueRef Else, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef If, LLVMValueRef Then, LLVMValueRef Else, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildVAArg -( LLVMBuilderRef Builder, LLVMValueRef List, LLVMTypeRef Ty, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef List, LLVMTypeRef Ty, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildExtractElement -( LLVMBuilderRef Builder, LLVMValueRef VecVal, LLVMValueRef Index, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef VecVal, LLVMValueRef Index, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildInsertElement -( LLVMBuilderRef Builder, LLVMValueRef VecVal, LLVMValueRef EltVal, LLVMValueRef Index, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef VecVal, LLVMValueRef EltVal, LLVMValueRef Index, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildShuffleVector -( LLVMBuilderRef Builder, LLVMValueRef V1, LLVMValueRef V2, LLVMValueRef Mask, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef V1, LLVMValueRef V2, LLVMValueRef Mask, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildExtractValue -( LLVMBuilderRef Builder, LLVMValueRef AggVal, unsigned Index, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef AggVal, unsigned Index, c-string Name ) ; FUNCTION: LLVMValueRef LLVMBuildInsertValue -( LLVMBuilderRef Builder, LLVMValueRef AggVal, LLVMValueRef EltVal, unsigned Index, char* Name ) ; +( LLVMBuilderRef Builder, LLVMValueRef AggVal, LLVMValueRef EltVal, unsigned Index, c-string Name ) ; ! Memory Buffers/Bit Reader FUNCTION: int LLVMCreateMemoryBufferWithContentsOfFile -( char* Path, LLVMMemoryBufferRef* OutMemBuf, char** OutMessage ) ; +( c-string Path, LLVMMemoryBufferRef* OutMemBuf, c-string* OutMessage ) ; FUNCTION: void LLVMDisposeMemoryBuffer ( LLVMMemoryBufferRef MemBuf ) ; LIBRARY: LLVMBitReader FUNCTION: int LLVMParseBitcode -( LLVMMemoryBufferRef MemBuf, LLVMModuleRef* OutModule, char** OutMessage ) ; +( LLVMMemoryBufferRef MemBuf, LLVMModuleRef* OutModule, c-string* OutMessage ) ; FUNCTION: int LLVMGetBitcodeModuleProvider -( LLVMMemoryBufferRef MemBuf, LLVMModuleProviderRef* OutMP, char** OutMessage ) ; +( LLVMMemoryBufferRef MemBuf, LLVMModuleProviderRef* OutMP, c-string* OutMessage ) ; diff --git a/extra/llvm/engine/engine.factor b/extra/llvm/engine/engine.factor index d259c740e6..95e425c425 100644 --- a/extra/llvm/engine/engine.factor +++ b/extra/llvm/engine/engine.factor @@ -34,10 +34,10 @@ FUNCTION: ulonglong LLVMGenericValueToInt ( LLVMGenericValueRef GenVal, int IsSigned ) ; FUNCTION: int LLVMCreateExecutionEngine -( LLVMExecutionEngineRef *OutEE, LLVMModuleProviderRef MP, char** OutError ) ; +( LLVMExecutionEngineRef *OutEE, LLVMModuleProviderRef MP, c-string* OutError ) ; FUNCTION: int LLVMCreateJITCompiler -( LLVMExecutionEngineRef* OutJIT, LLVMModuleProviderRef MP, unsigned OptLevel, char** OutError ) ; +( LLVMExecutionEngineRef* OutJIT, LLVMModuleProviderRef MP, unsigned OptLevel, c-string* OutError ) ; FUNCTION: void LLVMDisposeExecutionEngine ( LLVMExecutionEngineRef EE ) ; @@ -46,10 +46,10 @@ FUNCTION: void LLVMFreeMachineCodeForFunction ( LLVMExecutionEngineRef EE, LLVMV FUNCTION: void LLVMAddModuleProvider ( LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP ) ; FUNCTION: int LLVMRemoveModuleProvider -( LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP, LLVMModuleRef* OutMod, char** OutError ) ; +( LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP, LLVMModuleRef* OutMod, c-string* OutError ) ; FUNCTION: int LLVMFindFunction -( LLVMExecutionEngineRef EE, char* Name, LLVMValueRef* OutFn ) ; +( LLVMExecutionEngineRef EE, c-string Name, LLVMValueRef* OutFn ) ; FUNCTION: void* LLVMGetPointerToGlobal ( LLVMExecutionEngineRef EE, LLVMValueRef Global ) ; diff --git a/extra/llvm/types/types.factor b/extra/llvm/types/types.factor index ddb54ecb27..e93cf7a44b 100644 --- a/extra/llvm/types/types.factor +++ b/extra/llvm/types/types.factor @@ -99,7 +99,7 @@ TUPLE: pointer < enclosing type ; M: pointer (>tref)* type>> (>tref) 0 LLVMPointerType ; M: pointer clean* type>> clean ; M: pointer (tref>)* swap LLVMGetElementType (tref>) >>type ; -M: pointer c-type type>> 8 = "char*" "void*" ? ; +M: pointer c-type type>> 8 = "c-string" "void*" ? ; TUPLE: vector < enclosing size type ; : ( s t -- o ) diff --git a/extra/llvm/wrappers/wrappers.factor b/extra/llvm/wrappers/wrappers.factor index a1d757e7e9..05aafce973 100644 --- a/extra/llvm/wrappers/wrappers.factor +++ b/extra/llvm/wrappers/wrappers.factor @@ -6,7 +6,7 @@ llvm.core llvm.engine ; IN: llvm.wrappers -: llvm-throw ( char* -- ) +: llvm-throw ( c-string -- ) [ utf8 alien>string ] [ LLVMDisposeMessage ] bi throw ; : ( alien class -- disposable ) new swap >>value ; diff --git a/extra/native-thread-test/native-thread-test.factor b/extra/native-thread-test/native-thread-test.factor index 4d0df1f454..73b86f53a0 100644 --- a/extra/native-thread-test/native-thread-test.factor +++ b/extra/native-thread-test/native-thread-test.factor @@ -5,7 +5,7 @@ io.encodings.utf8 io.files kernel sequences system threads unix.utilities ; IN: native-thread-test -FUNCTION: void* start_standalone_factor_in_new_thread ( int argc, char** argv ) ; +FUNCTION: void* start_standalone_factor_in_new_thread ( int argc, c-string* argv ) ; : start-vm-in-os-thread ( args -- threadhandle ) vm prefix diff --git a/extra/ogg/ogg.factor b/extra/ogg/ogg.factor index d7abece8bc..ed25740ff6 100644 --- a/extra/ogg/ogg.factor +++ b/extra/ogg/ogg.factor @@ -28,18 +28,18 @@ LIBRARY: ogg STRUCT: oggpack-buffer { endbyte long } { endbit int } - { buffer uchar* } - { ptr uchar* } + { buffer c-string } + { ptr c-string } { storage long } ; STRUCT: ogg-page - { header uchar* } + { header c-string } { header_len long } - { body uchar* } + { body c-string } { body_len long } ; STRUCT: ogg-stream-state - { body_data uchar* } + { body_data c-string } { body_storage long } { body_fill long } { body_returned long } @@ -59,7 +59,7 @@ STRUCT: ogg-stream-state { granulepos longlong } ; STRUCT: ogg-packet - { packet uchar* } + { packet c-string } { bytes long } { b_o_s long } { e_o_s long } @@ -67,7 +67,7 @@ STRUCT: ogg-packet { packetno longlong } ; STRUCT: ogg-sync-state - { data uchar* } + { data c-string } { storage int } { fill int } { returned int } @@ -81,7 +81,7 @@ FUNCTION: void oggpack_writealign ( oggpack-buffer* b) ; FUNCTION: void oggpack_writecopy ( oggpack-buffer* b, void* source, long bits ) ; FUNCTION: void oggpack_reset ( oggpack-buffer* b ) ; FUNCTION: void oggpack_writeclear ( oggpack-buffer* b ) ; -FUNCTION: void oggpack_readinit ( oggpack-buffer* b, uchar* buf, int bytes ) ; +FUNCTION: void oggpack_readinit ( oggpack-buffer* b, c-string buf, int bytes ) ; FUNCTION: void oggpack_write ( oggpack-buffer* b, ulong value, int bits ) ; FUNCTION: long oggpack_look ( oggpack-buffer* b, int bits ) ; FUNCTION: long oggpack_look1 ( oggpack-buffer* b ) ; @@ -91,14 +91,14 @@ FUNCTION: long oggpack_read ( oggpack-buffer* b, int bits ) ; FUNCTION: long oggpack_read1 ( oggpack-buffer* b ) ; FUNCTION: long oggpack_bytes ( oggpack-buffer* b ) ; FUNCTION: long oggpack_bits ( oggpack-buffer* b ) ; -FUNCTION: uchar* oggpack_get_buffer ( oggpack-buffer* b ) ; +FUNCTION: c-string oggpack_get_buffer ( oggpack-buffer* b ) ; FUNCTION: void oggpackB_writeinit ( oggpack-buffer* b ) ; FUNCTION: void oggpackB_writetrunc ( oggpack-buffer* b, long bits ) ; FUNCTION: void oggpackB_writealign ( oggpack-buffer* b ) ; FUNCTION: void oggpackB_writecopy ( oggpack-buffer* b, void* source, long bits ) ; FUNCTION: void oggpackB_reset ( oggpack-buffer* b ) ; FUNCTION: void oggpackB_writeclear ( oggpack-buffer* b ) ; -FUNCTION: void oggpackB_readinit ( oggpack-buffer* b, uchar* buf, int bytes ) ; +FUNCTION: void oggpackB_readinit ( oggpack-buffer* b, c-string buf, int bytes ) ; FUNCTION: void oggpackB_write ( oggpack-buffer* b, ulong value, int bits ) ; FUNCTION: long oggpackB_look ( oggpack-buffer* b, int bits ) ; FUNCTION: long oggpackB_look1 ( oggpack-buffer* b ) ; @@ -108,7 +108,7 @@ FUNCTION: long oggpackB_read ( oggpack-buffer* b, int bits ) ; FUNCTION: long oggpackB_read1 ( oggpack-buffer* b ) ; FUNCTION: long oggpackB_bytes ( oggpack-buffer* b ) ; FUNCTION: long oggpackB_bits ( oggpack-buffer* b ) ; -FUNCTION: uchar* oggpackB_get_buffer ( oggpack-buffer* b ) ; +FUNCTION: c-string oggpackB_get_buffer ( oggpack-buffer* b ) ; FUNCTION: int ogg_stream_packetin ( ogg-stream-state* os, ogg-packet* op ) ; FUNCTION: int ogg_stream_pageout ( ogg-stream-state* os, ogg-page* og ) ; FUNCTION: int ogg_stream_flush ( ogg-stream-state* os, ogg-page* og ) ; diff --git a/extra/ogg/theora/theora.factor b/extra/ogg/theora/theora.factor index c9141fb9e3..3e28129252 100644 --- a/extra/ogg/theora/theora.factor +++ b/extra/ogg/theora/theora.factor @@ -53,7 +53,7 @@ STRUCT: th-img-plane { width int } { height int } { stride int } - { data uchar* } + { data c-string } ; TYPEDEF: th-img-plane[3] th-ycbcr-buffer @@ -80,10 +80,10 @@ STRUCT: th-info ; STRUCT: th-comment - { user-comments char** } + { user-comments c-string* } { comment-lengths int* } { comments int } - { vendor char* } + { vendor c-string } ; TYPEDEF: uchar[64] th-quant-base @@ -110,7 +110,7 @@ STRUCT: th-huff-code ; LIBRARY: theoradec -FUNCTION: char* th_version_string ( ) ; +FUNCTION: c-string th_version_string ( ) ; FUNCTION: uint th_version_number ( ) ; FUNCTION: longlong th_granule_frame ( void* encdec, longlong granpos) ; FUNCTION: int th_packet_isheader ( ogg-packet* op ) ; @@ -118,10 +118,10 @@ FUNCTION: int th_packet_iskeyframe ( ogg-packet* op ) ; FUNCTION: void th_info_init ( th-info* info ) ; FUNCTION: void th_info_clear ( th-info* info ) ; FUNCTION: void th_comment_init ( th-comment* tc ) ; -FUNCTION: void th_comment_add ( th-comment* tc, char* comment ) ; -FUNCTION: void th_comment_add_tag ( th-comment* tc, char* tag, char* value ) ; -FUNCTION: char* th_comment_query ( th-comment* tc, char* tag, int count ) ; -FUNCTION: int th_comment_query_count ( th-comment* tc, char* tag ) ; +FUNCTION: void th_comment_add ( th-comment* tc, c-string comment ) ; +FUNCTION: void th_comment_add_tag ( th-comment* tc, c-string tag, c-string value ) ; +FUNCTION: c-string th_comment_query ( th-comment* tc, c-string tag, int count ) ; +FUNCTION: int th_comment_query_count ( th-comment* tc, c-string tag ) ; FUNCTION: void th_comment_clear ( th-comment* tc ) ; CONSTANT: TH-ENCCTL-SET-HUFFMAN-CODES 0 diff --git a/extra/ogg/vorbis/vorbis.factor b/extra/ogg/vorbis/vorbis.factor index d5905dac9e..ad43750e27 100644 --- a/extra/ogg/vorbis/vorbis.factor +++ b/extra/ogg/vorbis/vorbis.factor @@ -90,20 +90,20 @@ STRUCT: vorbis-block ; STRUCT: vorbis-comment - { usercomments char** } + { usercomments c-string* } { comment_lengths int* } { comments int } - { vendor char* } + { vendor c-string } ; FUNCTION: void vorbis_info_init ( vorbis-info* vi ) ; FUNCTION: void vorbis_info_clear ( vorbis-info* vi ) ; FUNCTION: int vorbis_info_blocksize ( vorbis-info* vi, int zo ) ; FUNCTION: void vorbis_comment_init ( vorbis-comment* vc ) ; -FUNCTION: void vorbis_comment_add ( vorbis-comment* vc, char* comment ) ; -FUNCTION: void vorbis_comment_add_tag ( vorbis-comment* vc, char* tag, char* contents ) ; -FUNCTION: char* vorbis_comment_query ( vorbis-comment* vc, char* tag, int count ) ; -FUNCTION: int vorbis_comment_query_count ( vorbis-comment* vc, char* tag ) ; +FUNCTION: void vorbis_comment_add ( vorbis-comment* vc, c-string comment ) ; +FUNCTION: void vorbis_comment_add_tag ( vorbis-comment* vc, c-string tag, c-string contents ) ; +FUNCTION: c-string vorbis_comment_query ( vorbis-comment* vc, c-string tag, int count ) ; +FUNCTION: int vorbis_comment_query_count ( vorbis-comment* vc, c-string tag ) ; FUNCTION: void vorbis_comment_clear ( vorbis-comment* vc ) ; FUNCTION: int vorbis_block_init ( vorbis-dsp-state* v, vorbis-block* vb ) ; FUNCTION: int vorbis_block_clear ( vorbis-block* vb ) ; diff --git a/extra/openal/alut/alut.factor b/extra/openal/alut/alut.factor index 9e37d9886c..0bf8511647 100755 --- a/extra/openal/alut/alut.factor +++ b/extra/openal/alut/alut.factor @@ -49,20 +49,20 @@ CONSTANT: ALUT_WAVEFORM_IMPULSE HEX: 104 CONSTANT: ALUT_LOADER_BUFFER HEX: 300 CONSTANT: ALUT_LOADER_MEMORY HEX: 301 -FUNCTION: ALboolean alutInit ( int* argcp, char** argv ) ; -FUNCTION: ALboolean alutInitWithoutContext ( int* argcp, char** argv ) ; +FUNCTION: ALboolean alutInit ( int* argcp, c-string* argv ) ; +FUNCTION: ALboolean alutInitWithoutContext ( int* argcp, c-string* argv ) ; FUNCTION: ALboolean alutExit ( ) ; FUNCTION: ALenum alutGetError ( ) ; -FUNCTION: char* alutGetErrorString ( ALenum error ) ; -FUNCTION: ALuint alutCreateBufferFromFile ( char* fileName ) ; +FUNCTION: c-string alutGetErrorString ( ALenum error ) ; +FUNCTION: ALuint alutCreateBufferFromFile ( c-string fileName ) ; FUNCTION: ALuint alutCreateBufferFromFileImage ( void* data, ALsizei length ) ; FUNCTION: ALuint alutCreateBufferHelloWorld ( ) ; FUNCTION: ALuint alutCreateBufferWaveform ( ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration ) ; -FUNCTION: void* alutLoadMemoryFromFile ( char* fileName, ALenum* format, ALsizei* size, ALfloat* frequency ) ; +FUNCTION: void* alutLoadMemoryFromFile ( c-string fileName, ALenum* format, ALsizei* size, ALfloat* frequency ) ; FUNCTION: void* alutLoadMemoryFromFileImage ( void* data, ALsizei length, ALenum* format, ALsizei* size, ALfloat* frequency ) ; FUNCTION: void* alutLoadMemoryHelloWorld ( ALenum* format, ALsizei* size, ALfloat* frequency ) ; FUNCTION: void* alutLoadMemoryWaveform ( ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration, ALenum* format, ALsizei* size, ALfloat* freq ) ; -FUNCTION: char* alutGetMIMETypes ( ALenum loader ) ; +FUNCTION: c-string alutGetMIMETypes ( ALenum loader ) ; FUNCTION: ALint alutGetMajorVersion ( ) ; FUNCTION: ALint alutGetMinorVersion ( ) ; FUNCTION: ALboolean alutSleep ( ALfloat duration ) ; diff --git a/extra/opengl/glu/glu.factor b/extra/opengl/glu/glu.factor index 6409a3781b..86936fdd65 100644 --- a/extra/opengl/glu/glu.factor +++ b/extra/opengl/glu/glu.factor @@ -218,9 +218,9 @@ FUNCTION: void gluEndCurve ( GLUnurbs* nurb ) ; FUNCTION: void gluEndPolygon ( GLUtesselator* tess ) ; FUNCTION: void gluEndSurface ( GLUnurbs* nurb ) ; FUNCTION: void gluEndTrim ( GLUnurbs* nurb ) ; -FUNCTION: char* gluErrorString ( GLenum error ) ; +FUNCTION: c-string gluErrorString ( GLenum error ) ; FUNCTION: void gluGetNurbsProperty ( GLUnurbs* nurb, GLenum property, GLfloat* data ) ; -FUNCTION: char* gluGetString ( GLenum name ) ; +FUNCTION: c-string gluGetString ( GLenum name ) ; FUNCTION: void gluGetTessProperty ( GLUtesselator* tess, GLenum which, GLdouble* data ) ; FUNCTION: void gluLoadSamplingMatrices ( GLUnurbs* nurb, GLfloat* model, GLfloat* perspective, GLint* view ) ; FUNCTION: void gluLookAt ( GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ ) ; diff --git a/extra/tokyo/alien/tcadb/tcadb.factor b/extra/tokyo/alien/tcadb/tcadb.factor index efba5f0374..7e3a2d47c2 100644 --- a/extra/tokyo/alien/tcadb/tcadb.factor +++ b/extra/tokyo/alien/tcadb/tcadb.factor @@ -21,38 +21,38 @@ C-ENUM: FUNCTION: TCADB* tcadbnew ( ) ; FUNCTION: void tcadbdel ( TCADB* adb ) ; -FUNCTION: bool tcadbopen ( TCADB* adb, char* name ) ; +FUNCTION: bool tcadbopen ( TCADB* adb, c-string name ) ; FUNCTION: bool tcadbclose ( TCADB* adb ) ; FUNCTION: bool tcadbput ( TCADB* adb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcadbput2 ( TCADB* adb, char* kstr, char* vstr ) ; +FUNCTION: bool tcadbput2 ( TCADB* adb, c-string kstr, c-string vstr ) ; FUNCTION: bool tcadbputkeep ( TCADB* adb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcadbputkeep2 ( TCADB* adb, char* kstr, char* vstr ) ; +FUNCTION: bool tcadbputkeep2 ( TCADB* adb, c-string kstr, c-string vstr ) ; FUNCTION: bool tcadbputcat ( TCADB* adb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcadbputcat2 ( TCADB* adb, char* kstr, char* vstr ) ; +FUNCTION: bool tcadbputcat2 ( TCADB* adb, c-string kstr, c-string vstr ) ; FUNCTION: bool tcadbout ( TCADB* adb, void* kbuf, int ksiz ) ; -FUNCTION: bool tcadbout2 ( TCADB* adb, char* kstr ) ; +FUNCTION: bool tcadbout2 ( TCADB* adb, c-string kstr ) ; FUNCTION: void* tcadbget ( TCADB* adb, void* kbuf, int ksiz, int* sp ) ; -FUNCTION: char* tcadbget2 ( TCADB* adb, char* kstr ) ; +FUNCTION: c-string tcadbget2 ( TCADB* adb, c-string kstr ) ; FUNCTION: int tcadbvsiz ( TCADB* adb, void* kbuf, int ksiz ) ; -FUNCTION: int tcadbvsiz2 ( TCADB* adb, char* kstr ) ; +FUNCTION: int tcadbvsiz2 ( TCADB* adb, c-string kstr ) ; FUNCTION: bool tcadbiterinit ( TCADB* adb ) ; FUNCTION: void* tcadbiternext ( TCADB* adb, int* sp ) ; -FUNCTION: char* tcadbiternext2 ( TCADB* adb ) ; +FUNCTION: c-string tcadbiternext2 ( TCADB* adb ) ; FUNCTION: TCLIST* tcadbfwmkeys ( TCADB* adb, void* pbuf, int psiz, int max ) ; -FUNCTION: TCLIST* tcadbfwmkeys2 ( TCADB* adb, char* pstr, int max ) ; +FUNCTION: TCLIST* tcadbfwmkeys2 ( TCADB* adb, c-string pstr, int max ) ; FUNCTION: int tcadbaddint ( TCADB* adb, void* kbuf, int ksiz, int num ) ; FUNCTION: double tcadbadddouble ( TCADB* adb, void* kbuf, int ksiz, double num ) ; FUNCTION: bool tcadbsync ( TCADB* adb ) ; -FUNCTION: bool tcadboptimize ( TCADB* adb, char* params ) ; +FUNCTION: bool tcadboptimize ( TCADB* adb, c-string params ) ; FUNCTION: bool tcadbvanish ( TCADB* adb ) ; -FUNCTION: bool tcadbcopy ( TCADB* adb, char* path ) ; +FUNCTION: bool tcadbcopy ( TCADB* adb, c-string path ) ; FUNCTION: bool tcadbtranbegin ( TCADB* adb ) ; FUNCTION: bool tcadbtrancommit ( TCADB* adb ) ; FUNCTION: bool tcadbtranabort ( TCADB* adb ) ; -FUNCTION: char* tcadbpath ( TCADB* adb ) ; +FUNCTION: c-string tcadbpath ( TCADB* adb ) ; FUNCTION: ulonglong tcadbrnum ( TCADB* adb ) ; FUNCTION: ulonglong tcadbsize ( TCADB* adb ) ; -FUNCTION: TCLIST* tcadbmisc ( TCADB* adb, char* name, TCLIST* args ) ; +FUNCTION: TCLIST* tcadbmisc ( TCADB* adb, c-string name, TCLIST* args ) ; ! ----- @@ -66,4 +66,4 @@ FUNCTION: void* tcadbreveal ( TCADB* adb ) ; FUNCTION: bool tcadbputproc ( TCADB* adb, void* kbuf, int ksiz, void* vbuf, int vsiz, TCPDPROC proc, void* op ) ; FUNCTION: bool tcadbforeach ( TCADB* adb, TCITER iter, void* op ) ; FUNCTION: bool tcadbmapbdb ( TCADB* adb, TCLIST* keys, TCBDB* bdb, ADBMAPPROC proc, void* op, longlong csiz ) ; -FUNCTION: bool tcadbmapbdbemit ( void* map, char* kbuf, int ksiz, char* vbuf, int vsiz ) ; +FUNCTION: bool tcadbmapbdbemit ( void* map, c-string kbuf, int ksiz, c-string vbuf, int vsiz ) ; diff --git a/extra/tokyo/alien/tcbdb/tcbdb.factor b/extra/tokyo/alien/tcbdb/tcbdb.factor index 8739e04608..6454e6b2fa 100644 --- a/extra/tokyo/alien/tcbdb/tcbdb.factor +++ b/extra/tokyo/alien/tcbdb/tcbdb.factor @@ -32,7 +32,7 @@ C-ENUM: BDBCPBEFORE BDBCPAFTER ; -FUNCTION: char* tcbdberrmsg ( int ecode ) ; +FUNCTION: c-string tcbdberrmsg ( int ecode ) ; FUNCTION: TCBDB* tcbdbnew ( ) ; FUNCTION: void tcbdbdel ( TCBDB* bdb ) ; FUNCTION: int tcbdbecode ( TCBDB* bdb ) ; @@ -41,42 +41,42 @@ FUNCTION: bool tcbdbsetcmpfunc ( TCBDB* bdb, TCCMP cmp, void* cmpop ) ; FUNCTION: bool tcbdbtune ( TCBDB* bdb, int lmemb, int nmemb, longlong bnum, char apow, char fpow, uchar opts ) ; FUNCTION: bool tcbdbsetcache ( TCBDB* bdb, int lcnum, int ncnum ) ; FUNCTION: bool tcbdbsetxmsiz ( TCBDB* bdb, longlong xmsiz ) ; -FUNCTION: bool tcbdbopen ( TCBDB* bdb, char* path, int omode ) ; +FUNCTION: bool tcbdbopen ( TCBDB* bdb, c-string path, int omode ) ; FUNCTION: bool tcbdbclose ( TCBDB* bdb ) ; FUNCTION: bool tcbdbput ( TCBDB* bdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcbdbput2 ( TCBDB* bdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcbdbput2 ( TCBDB* bdb, c-string kstr, c-string vstr ) ; FUNCTION: bool tcbdbputkeep ( TCBDB* bdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcbdbputkeep2 ( TCBDB* bdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcbdbputkeep2 ( TCBDB* bdb, c-string kstr, c-string vstr ) ; FUNCTION: bool tcbdbputcat ( TCBDB* bdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcbdbputcat2 ( TCBDB* bdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcbdbputcat2 ( TCBDB* bdb, c-string kstr, c-string vstr ) ; FUNCTION: bool tcbdbputdup ( TCBDB* bdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcbdbputdup2 ( TCBDB* bdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcbdbputdup2 ( TCBDB* bdb, c-string kstr, c-string vstr ) ; FUNCTION: bool tcbdbputdup3 ( TCBDB* bdb, void* kbuf, int ksiz, TCLIST* vals ) ; FUNCTION: bool tcbdbout ( TCBDB* bdb, void* kbuf, int ksiz ) ; -FUNCTION: bool tcbdbout2 ( TCBDB* bdb, char* kstr ) ; +FUNCTION: bool tcbdbout2 ( TCBDB* bdb, c-string kstr ) ; FUNCTION: bool tcbdbout3 ( TCBDB* bdb, void* kbuf, int ksiz ) ; FUNCTION: void* tcbdbget ( TCBDB* bdb, void* kbuf, int ksiz, int* sp ) ; -FUNCTION: char* tcbdbget2 ( TCBDB* bdb, char* kstr ) ; +FUNCTION: c-string tcbdbget2 ( TCBDB* bdb, c-string kstr ) ; FUNCTION: void* tcbdbget3 ( TCBDB* bdb, void* kbuf, int ksiz, int* sp ) ; FUNCTION: TCLIST* tcbdbget4 ( TCBDB* bdb, void* kbuf, int ksiz ) ; FUNCTION: int tcbdbvnum ( TCBDB* bdb, void* kbuf, int ksiz ) ; -FUNCTION: int tcbdbvnum2 ( TCBDB* bdb, char* kstr ) ; +FUNCTION: int tcbdbvnum2 ( TCBDB* bdb, c-string kstr ) ; FUNCTION: int tcbdbvsiz ( TCBDB* bdb, void* kbuf, int ksiz ) ; -FUNCTION: int tcbdbvsiz2 ( TCBDB* bdb, char* kstr ) ; +FUNCTION: int tcbdbvsiz2 ( TCBDB* bdb, c-string kstr ) ; FUNCTION: TCLIST* tcbdbrange ( TCBDB* bdb, void* bkbuf, int bksiz, bool binc, void* ekbuf, int eksiz, bool einc, int max ) ; -FUNCTION: TCLIST* tcbdbrange2 ( TCBDB* bdb, char* bkstr, bool binc, char* ekstr, bool einc, int max ) ; +FUNCTION: TCLIST* tcbdbrange2 ( TCBDB* bdb, c-string bkstr, bool binc, c-string ekstr, bool einc, int max ) ; FUNCTION: TCLIST* tcbdbfwmkeys ( TCBDB* bdb, void* pbuf, int psiz, int max ) ; -FUNCTION: TCLIST* tcbdbfwmkeys2 ( TCBDB* bdb, char* pstr, int max ) ; +FUNCTION: TCLIST* tcbdbfwmkeys2 ( TCBDB* bdb, c-string pstr, int max ) ; FUNCTION: int tcbdbaddint ( TCBDB* bdb, void* kbuf, int ksiz, int num ) ; FUNCTION: double tcbdbadddouble ( TCBDB* bdb, void* kbuf, int ksiz, double num ) ; FUNCTION: bool tcbdbsync ( TCBDB* bdb ) ; FUNCTION: bool tcbdboptimize ( TCBDB* bdb, int lmemb, int nmemb, longlong bnum, char apow, char fpow, uchar opts ) ; FUNCTION: bool tcbdbvanish ( TCBDB* bdb ) ; -FUNCTION: bool tcbdbcopy ( TCBDB* bdb, char* path ) ; +FUNCTION: bool tcbdbcopy ( TCBDB* bdb, c-string path ) ; FUNCTION: bool tcbdbtranbegin ( TCBDB* bdb ) ; FUNCTION: bool tcbdbtrancommit ( TCBDB* bdb ) ; FUNCTION: bool tcbdbtranabort ( TCBDB* bdb ) ; -FUNCTION: char* tcbdbpath ( TCBDB* bdb ) ; +FUNCTION: c-string tcbdbpath ( TCBDB* bdb ) ; FUNCTION: ulonglong tcbdbrnum ( TCBDB* bdb ) ; FUNCTION: ulonglong tcbdbfsiz ( TCBDB* bdb ) ; FUNCTION: BDBCUR* tcbdbcurnew ( TCBDB* bdb ) ; @@ -84,23 +84,23 @@ FUNCTION: void tcbdbcurdel ( BDBCUR* cur ) ; FUNCTION: bool tcbdbcurfirst ( BDBCUR* cur ) ; FUNCTION: bool tcbdbcurlast ( BDBCUR* cur ) ; FUNCTION: bool tcbdbcurjump ( BDBCUR* cur, void* kbuf, int ksiz ) ; -FUNCTION: bool tcbdbcurjump2 ( BDBCUR* cur, char* kstr ) ; +FUNCTION: bool tcbdbcurjump2 ( BDBCUR* cur, c-string kstr ) ; FUNCTION: bool tcbdbcurprev ( BDBCUR* cur ) ; FUNCTION: bool tcbdbcurnext ( BDBCUR* cur ) ; FUNCTION: bool tcbdbcurput ( BDBCUR* cur, void* vbuf, int vsiz, int cpmode ) ; -FUNCTION: bool tcbdbcurput2 ( BDBCUR* cur, char* vstr, int cpmode ) ; +FUNCTION: bool tcbdbcurput2 ( BDBCUR* cur, c-string vstr, int cpmode ) ; FUNCTION: bool tcbdbcurout ( BDBCUR* cur ) ; FUNCTION: void* tcbdbcurkey ( BDBCUR* cur, int* sp ) ; -FUNCTION: char* tcbdbcurkey2 ( BDBCUR* cur ) ; +FUNCTION: c-string tcbdbcurkey2 ( BDBCUR* cur ) ; FUNCTION: void* tcbdbcurkey3 ( BDBCUR* cur, int* sp ) ; FUNCTION: void* tcbdbcurval ( BDBCUR* cur, int* sp ) ; -FUNCTION: char* tcbdbcurval2 ( BDBCUR* cur ) ; +FUNCTION: c-string tcbdbcurval2 ( BDBCUR* cur ) ; FUNCTION: void* tcbdbcurval3 ( BDBCUR* cur, int* sp ) ; FUNCTION: bool tcbdbcurrec ( BDBCUR* cur, TCXSTR* kxstr, TCXSTR* vxstr ) ; ! ----------- -FUNCTION: void tcbdbsetecode ( TCBDB* bdb, int ecode, char* filename, int line, char* func ) ; +FUNCTION: void tcbdbsetecode ( TCBDB* bdb, int ecode, c-string filename, int line, c-string func ) ; FUNCTION: void tcbdbsetdbgfd ( TCBDB* bdb, int fd ) ; FUNCTION: int tcbdbdbgfd ( TCBDB* bdb ) ; FUNCTION: bool tcbdbhasmutex ( TCBDB* bdb ) ; @@ -119,14 +119,14 @@ FUNCTION: ulonglong tcbdbinode ( TCBDB* bdb ) ; FUNCTION: tokyo_time_t tcbdbmtime ( TCBDB* bdb ) ; FUNCTION: uchar tcbdbflags ( TCBDB* bdb ) ; FUNCTION: uchar tcbdbopts ( TCBDB* bdb ) ; -FUNCTION: char* tcbdbopaque ( TCBDB* bdb ) ; +FUNCTION: c-string tcbdbopaque ( TCBDB* bdb ) ; FUNCTION: ulonglong tcbdbbnumused ( TCBDB* bdb ) ; FUNCTION: bool tcbdbsetlsmax ( TCBDB* bdb, uint lsmax ) ; FUNCTION: bool tcbdbsetcapnum ( TCBDB* bdb, ulonglong capnum ) ; FUNCTION: bool tcbdbsetcodecfunc ( TCBDB* bdb, TCCODEC enc, void* encop, TCCODEC dec, void* decop ) ; FUNCTION: bool tcbdbputdupback ( TCBDB* bdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcbdbputdupback2 ( TCBDB* bdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcbdbputdupback2 ( TCBDB* bdb, c-string kstr, c-string vstr ) ; FUNCTION: bool tcbdbputproc ( TCBDB* bdb, void* kbuf, int ksiz, void* vbuf, int vsiz, TCPDPROC proc, void* op ) ; FUNCTION: bool tcbdbcurjumpback ( BDBCUR* cur, void* kbuf, int ksiz ) ; -FUNCTION: bool tcbdbcurjumpback2 ( BDBCUR* cur, char* kstr ) ; +FUNCTION: bool tcbdbcurjumpback2 ( BDBCUR* cur, c-string kstr ) ; FUNCTION: bool tcbdbforeach ( TCBDB* bdb, TCITER iter, void* op ) ; diff --git a/extra/tokyo/alien/tcfdb/tcfdb.factor b/extra/tokyo/alien/tcfdb/tcfdb.factor index 91400aaf4e..cde71f27a5 100644 --- a/extra/tokyo/alien/tcfdb/tcfdb.factor +++ b/extra/tokyo/alien/tcfdb/tcfdb.factor @@ -22,40 +22,40 @@ CONSTANT: FDBIDPREV -2 CONSTANT: FDBIDMAX -3 CONSTANT: FDBIDNEXT -4 -FUNCTION: char* tcfdberrmsg ( int ecode ) ; +FUNCTION: c-string tcfdberrmsg ( int ecode ) ; FUNCTION: TCFDB* tcfdbnew ( ) ; FUNCTION: void tcfdbdel ( TCFDB* fdb ) ; FUNCTION: int tcfdbecode ( TCFDB* fdb ) ; FUNCTION: bool tcfdbsetmutex ( TCFDB* fdb ) ; FUNCTION: bool tcfdbtune ( TCFDB* fdb, int width, longlong limsiz ) ; -FUNCTION: bool tcfdbopen ( TCFDB* fdb, char* path, int omode ) ; +FUNCTION: bool tcfdbopen ( TCFDB* fdb, c-string path, int omode ) ; FUNCTION: bool tcfdbclose ( TCFDB* fdb ) ; FUNCTION: bool tcfdbput ( TCFDB* fdb, longlong id, void* vbuf, int vsiz ) ; FUNCTION: bool tcfdbput2 ( TCFDB* fdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcfdbput3 ( TCFDB* fdb, char* kstr, void* vstr ) ; +FUNCTION: bool tcfdbput3 ( TCFDB* fdb, c-string kstr, void* vstr ) ; FUNCTION: bool tcfdbputkeep ( TCFDB* fdb, longlong id, void* vbuf, int vsiz ) ; FUNCTION: bool tcfdbputkeep2 ( TCFDB* fdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcfdbputkeep3 ( TCFDB* fdb, char* kstr, void* vstr ) ; +FUNCTION: bool tcfdbputkeep3 ( TCFDB* fdb, c-string kstr, void* vstr ) ; FUNCTION: bool tcfdbputcat ( TCFDB* fdb, longlong id, void* vbuf, int vsiz ) ; FUNCTION: bool tcfdbputcat2 ( TCFDB* fdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcfdbputcat3 ( TCFDB* fdb, char* kstr, void* vstr ) ; +FUNCTION: bool tcfdbputcat3 ( TCFDB* fdb, c-string kstr, void* vstr ) ; FUNCTION: bool tcfdbout ( TCFDB* fdb, longlong id ) ; FUNCTION: bool tcfdbout2 ( TCFDB* fdb, void* kbuf, int ksiz ) ; -FUNCTION: bool tcfdbout3 ( TCFDB* fdb, char* kstr ) ; +FUNCTION: bool tcfdbout3 ( TCFDB* fdb, c-string kstr ) ; FUNCTION: void* tcfdbget ( TCFDB* fdb, longlong id, int* sp ) ; FUNCTION: void* tcfdbget2 ( TCFDB* fdb, void* kbuf, int ksiz, int* sp ) ; -FUNCTION: char* tcfdbget3 ( TCFDB* fdb, char* kstr ) ; +FUNCTION: c-string tcfdbget3 ( TCFDB* fdb, c-string kstr ) ; FUNCTION: int tcfdbget4 ( TCFDB* fdb, longlong id, void* vbuf, int max ) ; FUNCTION: int tcfdbvsiz ( TCFDB* fdb, longlong id ) ; FUNCTION: int tcfdbvsiz2 ( TCFDB* fdb, void* kbuf, int ksiz ) ; -FUNCTION: int tcfdbvsiz3 ( TCFDB* fdb, char* kstr ) ; +FUNCTION: int tcfdbvsiz3 ( TCFDB* fdb, c-string kstr ) ; FUNCTION: bool tcfdbiterinit ( TCFDB* fdb ) ; FUNCTION: ulonglong tcfdbiternext ( TCFDB* fdb ) ; FUNCTION: void* tcfdbiternext2 ( TCFDB* fdb, int* sp ) ; -FUNCTION: char* tcfdbiternext3 ( TCFDB* fdb ) ; +FUNCTION: c-string tcfdbiternext3 ( TCFDB* fdb ) ; FUNCTION: ulonglong* tcfdbrange ( TCFDB* fdb, longlong lower, longlong upper, int max, int* np ) ; FUNCTION: TCLIST* tcfdbrange2 ( TCFDB* fdb, void* lbuf, int lsiz, void* ubuf, int usiz, int max ) ; -FUNCTION: TCLIST* tcfdbrange3 ( TCFDB* fdb, char* lstr, char* ustr, int max ) ; +FUNCTION: TCLIST* tcfdbrange3 ( TCFDB* fdb, c-string lstr, c-string ustr, int max ) ; FUNCTION: TCLIST* tcfdbrange4 ( TCFDB* fdb, void* ibuf, int isiz, int max ) ; FUNCTION: TCLIST* tcfdbrange5 ( TCFDB* fdb, void* istr, int max ) ; FUNCTION: int tcfdbaddint ( TCFDB* fdb, longlong id, int num ) ; @@ -63,17 +63,17 @@ FUNCTION: double tcfdbadddouble ( TCFDB* fdb, longlong id, double num ) ; FUNCTION: bool tcfdbsync ( TCFDB* fdb ) ; FUNCTION: bool tcfdboptimize ( TCFDB* fdb, int width, longlong limsiz ) ; FUNCTION: bool tcfdbvanish ( TCFDB* fdb ) ; -FUNCTION: bool tcfdbcopy ( TCFDB* fdb, char* path ) ; +FUNCTION: bool tcfdbcopy ( TCFDB* fdb, c-string path ) ; FUNCTION: bool tcfdbtranbegin ( TCFDB* fdb ) ; FUNCTION: bool tcfdbtrancommit ( TCFDB* fdb ) ; FUNCTION: bool tcfdbtranabort ( TCFDB* fdb ) ; -FUNCTION: char* tcfdbpath ( TCFDB* fdb ) ; +FUNCTION: c-string tcfdbpath ( TCFDB* fdb ) ; FUNCTION: ulonglong tcfdbrnum ( TCFDB* fdb ) ; FUNCTION: ulonglong tcfdbfsiz ( TCFDB* fdb ) ; ! -------- -FUNCTION: void tcfdbsetecode ( TCFDB* fdb, int ecode, char* filename, int line, char* func ) ; +FUNCTION: void tcfdbsetecode ( TCFDB* fdb, int ecode, c-string filename, int line, c-string func ) ; FUNCTION: void tcfdbsetdbgfd ( TCFDB* fdb, int fd ) ; FUNCTION: int tcfdbdbgfd ( TCFDB* fdb ) ; FUNCTION: bool tcfdbhasmutex ( TCFDB* fdb ) ; @@ -88,7 +88,7 @@ FUNCTION: tokyo_time_t tcfdbmtime ( TCFDB* fdb ) ; FUNCTION: int tcfdbomode ( TCFDB* fdb ) ; FUNCTION: uchar tcfdbtype ( TCFDB* fdb ) ; FUNCTION: uchar tcfdbflags ( TCFDB* fdb ) ; -FUNCTION: char* tcfdbopaque ( TCFDB* fdb ) ; +FUNCTION: c-string tcfdbopaque ( TCFDB* fdb ) ; FUNCTION: bool tcfdbputproc ( TCFDB* fdb, longlong id, void* vbuf, int vsiz, TCPDPROC proc, void* op ) ; FUNCTION: bool tcfdbforeach ( TCFDB* fdb, TCITER iter, void* op ) ; -FUNCTION: longlong tcfdbkeytoid ( char* kbuf, int ksiz ) ; +FUNCTION: longlong tcfdbkeytoid ( c-string kbuf, int ksiz ) ; diff --git a/extra/tokyo/alien/tchdb/tchdb.factor b/extra/tokyo/alien/tchdb/tchdb.factor index fd0464fcec..65d00b2a69 100644 --- a/extra/tokyo/alien/tchdb/tchdb.factor +++ b/extra/tokyo/alien/tchdb/tchdb.factor @@ -26,7 +26,7 @@ CONSTANT: HDBONOLCK 16 CONSTANT: HDBOLCKNB 32 CONSTANT: HDBOTSYNC 64 -FUNCTION: char* tchdberrmsg ( int ecode ) ; +FUNCTION: c-string tchdberrmsg ( int ecode ) ; FUNCTION: TCHDB* tchdbnew ( ) ; FUNCTION: void tchdbdel ( TCHDB* hdb ) ; FUNCTION: int tchdbecode ( TCHDB* hdb ) ; @@ -34,45 +34,45 @@ FUNCTION: bool tchdbsetmutex ( TCHDB* hdb ) ; FUNCTION: bool tchdbtune ( TCHDB* hdb, longlong bnum, char apow, char fpow, uchar opts ) ; FUNCTION: bool tchdbsetcache ( TCHDB* hdb, int rcnum ) ; FUNCTION: bool tchdbsetxmsiz ( TCHDB* hdb, longlong xmsiz ) ; -FUNCTION: bool tchdbopen ( TCHDB* hdb, char* path, int omode ) ; +FUNCTION: bool tchdbopen ( TCHDB* hdb, c-string path, int omode ) ; FUNCTION: bool tchdbclose ( TCHDB* hdb ) ; FUNCTION: bool tchdbput ( TCHDB* hdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tchdbput2 ( TCHDB* hdb, char* kstr, char* vstr ) ; +FUNCTION: bool tchdbput2 ( TCHDB* hdb, c-string kstr, c-string vstr ) ; FUNCTION: bool tchdbputkeep ( TCHDB* hdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tchdbputkeep2 ( TCHDB* hdb, char* kstr, char* vstr ) ; +FUNCTION: bool tchdbputkeep2 ( TCHDB* hdb, c-string kstr, c-string vstr ) ; FUNCTION: bool tchdbputcat ( TCHDB* hdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tchdbputcat2 ( TCHDB* hdb, char* kstr, char* vstr ) ; +FUNCTION: bool tchdbputcat2 ( TCHDB* hdb, c-string kstr, c-string vstr ) ; FUNCTION: bool tchdbputasync ( TCHDB* hdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tchdbputasync2 ( TCHDB* hdb, char* kstr, char* vstr ) ; +FUNCTION: bool tchdbputasync2 ( TCHDB* hdb, c-string kstr, c-string vstr ) ; FUNCTION: bool tchdbout ( TCHDB* hdb, void* kbuf, int ksiz ) ; -FUNCTION: bool tchdbout2 ( TCHDB* hdb, char* kstr ) ; +FUNCTION: bool tchdbout2 ( TCHDB* hdb, c-string kstr ) ; FUNCTION: void* tchdbget ( TCHDB* hdb, void* kbuf, int ksiz, int* sp ) ; -FUNCTION: char* tchdbget2 ( TCHDB* hdb, char* kstr ) ; +FUNCTION: c-string tchdbget2 ( TCHDB* hdb, c-string kstr ) ; FUNCTION: int tchdbget3 ( TCHDB* hdb, void* kbuf, int ksiz, void* vbuf, int max ) ; FUNCTION: int tchdbvsiz ( TCHDB* hdb, void* kbuf, int ksiz ) ; -FUNCTION: int tchdbvsiz2 ( TCHDB* hdb, char* kstr ) ; +FUNCTION: int tchdbvsiz2 ( TCHDB* hdb, c-string kstr ) ; FUNCTION: bool tchdbiterinit ( TCHDB* hdb ) ; FUNCTION: void* tchdbiternext ( TCHDB* hdb, int* sp ) ; -FUNCTION: char* tchdbiternext2 ( TCHDB* hdb ) ; +FUNCTION: c-string tchdbiternext2 ( TCHDB* hdb ) ; FUNCTION: bool tchdbiternext3 ( TCHDB* hdb, TCXSTR* kxstr, TCXSTR* vxstr ) ; FUNCTION: TCLIST* tchdbfwmkeys ( TCHDB* hdb, void* pbuf, int psiz, int max ) ; -FUNCTION: TCLIST* tchdbfwmkeys2 ( TCHDB* hdb, char* pstr, int max ) ; +FUNCTION: TCLIST* tchdbfwmkeys2 ( TCHDB* hdb, c-string pstr, int max ) ; FUNCTION: int tchdbaddint ( TCHDB* hdb, void* kbuf, int ksiz, int num ) ; FUNCTION: double tchdbadddouble ( TCHDB* hdb, void* kbuf, int ksiz, double num ) ; FUNCTION: bool tchdbsync ( TCHDB* hdb ) ; FUNCTION: bool tchdboptimize ( TCHDB* hdb, longlong bnum, char apow, char fpow, uchar opts ) ; FUNCTION: bool tchdbvanish ( TCHDB* hdb ) ; -FUNCTION: bool tchdbcopy ( TCHDB* hdb, char* path ) ; +FUNCTION: bool tchdbcopy ( TCHDB* hdb, c-string path ) ; FUNCTION: bool tchdbtranbegin ( TCHDB* hdb ) ; FUNCTION: bool tchdbtrancommit ( TCHDB* hdb ) ; FUNCTION: bool tchdbtranabort ( TCHDB* hdb ) ; -FUNCTION: char* tchdbpath ( TCHDB* hdb ) ; +FUNCTION: c-string tchdbpath ( TCHDB* hdb ) ; FUNCTION: ulonglong tchdbrnum ( TCHDB* hdb ) ; FUNCTION: ulonglong tchdbfsiz ( TCHDB* hdb ) ; ! -------- -FUNCTION: void tchdbsetecode ( TCHDB* hdb, int ecode, char* filename, int line, char* func ) ; +FUNCTION: void tchdbsetecode ( TCHDB* hdb, int ecode, c-string filename, int line, c-string func ) ; FUNCTION: void tchdbsettype ( TCHDB* hdb, uchar type ) ; FUNCTION: void tchdbsetdbgfd ( TCHDB* hdb, int fd ) ; FUNCTION: int tchdbdbgfd ( TCHDB* hdb ) ; @@ -89,13 +89,13 @@ FUNCTION: int tchdbomode ( TCHDB* hdb ) ; FUNCTION: uchar tchdbtype ( TCHDB* hdb ) ; FUNCTION: uchar tchdbflags ( TCHDB* hdb ) ; FUNCTION: uchar tchdbopts ( TCHDB* hdb ) ; -FUNCTION: char* tchdbopaque ( TCHDB* hdb ) ; +FUNCTION: c-string tchdbopaque ( TCHDB* hdb ) ; FUNCTION: ulonglong tchdbbnumused ( TCHDB* hdb ) ; FUNCTION: bool tchdbsetcodecfunc ( TCHDB* hdb, TCCODEC enc, void* encop, TCCODEC dec, void* decop ) ; FUNCTION: void tchdbcodecfunc ( TCHDB* hdb, TCCODEC* ep, void* *eop, TCCODEC* dp, void* *dop ) ; FUNCTION: bool tchdbputproc ( TCHDB* hdb, void* kbuf, int ksiz, void* vbuf, int vsiz, TCPDPROC proc, void* op ) ; FUNCTION: void* tchdbgetnext ( TCHDB* hdb, void* kbuf, int ksiz, int* sp ) ; -FUNCTION: char* tchdbgetnext2 ( TCHDB* hdb, char* kstr ) ; -FUNCTION: char* tchdbgetnext3 ( TCHDB* hdb, char* kbuf, int ksiz, int* sp, char* *vbp, int* vsp ) ; +FUNCTION: c-string tchdbgetnext2 ( TCHDB* hdb, c-string kstr ) ; +FUNCTION: c-string tchdbgetnext3 ( TCHDB* hdb, c-string kbuf, int ksiz, int* sp, c-string *vbp, int* vsp ) ; FUNCTION: bool tchdbforeach ( TCHDB* hdb, TCITER iter, void* op ) ; FUNCTION: bool tchdbtranvoid ( TCHDB* hdb ) ; diff --git a/extra/tokyo/alien/tcrdb/tcrdb.factor b/extra/tokyo/alien/tcrdb/tcrdb.factor index a6e59dbe03..da4a750444 100644 --- a/extra/tokyo/alien/tcrdb/tcrdb.factor +++ b/extra/tokyo/alien/tcrdb/tcrdb.factor @@ -17,9 +17,9 @@ C-TYPE: TCRDB ! STRUCT: TCRDB ! { mmtx pthread_mutex_t } ! { eckey pthread_key_t } -! { host char* } +! { host c-string } ! { port int } -! { expr char* } +! { expr c-string } ! { fd int } ! { sock TTSOCK* } ! { timeout double } @@ -42,52 +42,52 @@ CONSTANT: RDBXOLCKGLB 2 CONSTANT: RDBROCHKCON 1 CONSTANT: RDBMONOULOG 1 -FUNCTION: char* tcrdberrmsg ( int ecode ) ; +FUNCTION: c-string tcrdberrmsg ( int ecode ) ; FUNCTION: TCRDB* tcrdbnew ( ) ; FUNCTION: void tcrdbdel ( TCRDB* rdb ) ; FUNCTION: int tcrdbecode ( TCRDB* rdb ) ; FUNCTION: bool tcrdbtune ( TCRDB* rdb, double timeout, int opts ) ; -FUNCTION: bool tcrdbopen ( TCRDB* rdb, char* host, int port ) ; -FUNCTION: bool tcrdbopen2 ( TCRDB* rdb, char* expr ) ; +FUNCTION: bool tcrdbopen ( TCRDB* rdb, c-string host, int port ) ; +FUNCTION: bool tcrdbopen2 ( TCRDB* rdb, c-string expr ) ; FUNCTION: bool tcrdbclose ( TCRDB* rdb ) ; FUNCTION: bool tcrdbput ( TCRDB* rdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcrdbput2 ( TCRDB* rdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcrdbput2 ( TCRDB* rdb, c-string kstr, c-string vstr ) ; FUNCTION: bool tcrdbputkeep ( TCRDB* rdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcrdbputkeep2 ( TCRDB* rdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcrdbputkeep2 ( TCRDB* rdb, c-string kstr, c-string vstr ) ; FUNCTION: bool tcrdbputcat ( TCRDB* rdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcrdbputcat2 ( TCRDB* rdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcrdbputcat2 ( TCRDB* rdb, c-string kstr, c-string vstr ) ; FUNCTION: bool tcrdbputshl ( TCRDB* rdb, void* kbuf, int ksiz, void* vbuf, int vsiz, int width ) ; -FUNCTION: bool tcrdbputshl2 ( TCRDB* rdb, char* kstr, char* vstr, int width ) ; +FUNCTION: bool tcrdbputshl2 ( TCRDB* rdb, c-string kstr, c-string vstr, int width ) ; FUNCTION: bool tcrdbputnr ( TCRDB* rdb, void* kbuf, int ksiz, void* vbuf, int vsiz ) ; -FUNCTION: bool tcrdbputnr2 ( TCRDB* rdb, char* kstr, char* vstr ) ; +FUNCTION: bool tcrdbputnr2 ( TCRDB* rdb, c-string kstr, c-string vstr ) ; FUNCTION: bool tcrdbout ( TCRDB* rdb, void* kbuf, int ksiz ) ; -FUNCTION: bool tcrdbout2 ( TCRDB* rdb, char* kstr ) ; +FUNCTION: bool tcrdbout2 ( TCRDB* rdb, c-string kstr ) ; FUNCTION: void* tcrdbget ( TCRDB* rdb, void* kbuf, int ksiz, int* sp ) ; -FUNCTION: char* tcrdbget2 ( TCRDB* rdb, char* kstr ) ; +FUNCTION: c-string tcrdbget2 ( TCRDB* rdb, c-string kstr ) ; FUNCTION: bool tcrdbget3 ( TCRDB* rdb, TCMAP* recs ) ; FUNCTION: int tcrdbvsiz ( TCRDB* rdb, void* kbuf, int ksiz ) ; -FUNCTION: int tcrdbvsiz2 ( TCRDB* rdb, char* kstr ) ; +FUNCTION: int tcrdbvsiz2 ( TCRDB* rdb, c-string kstr ) ; FUNCTION: bool tcrdbiterinit ( TCRDB* rdb ) ; FUNCTION: void* tcrdbiternext ( TCRDB* rdb, int* sp ) ; -FUNCTION: char* tcrdbiternext2 ( TCRDB* rdb ) ; +FUNCTION: c-string tcrdbiternext2 ( TCRDB* rdb ) ; FUNCTION: TCLIST* tcrdbfwmkeys ( TCRDB* rdb, void* pbuf, int psiz, int max ) ; -FUNCTION: TCLIST* tcrdbfwmkeys2 ( TCRDB* rdb, char* pstr, int max ) ; +FUNCTION: TCLIST* tcrdbfwmkeys2 ( TCRDB* rdb, c-string pstr, int max ) ; FUNCTION: int tcrdbaddint ( TCRDB* rdb, void* kbuf, int ksiz, int num ) ; FUNCTION: double tcrdbadddouble ( TCRDB* rdb, void* kbuf, int ksiz, double num ) ; -FUNCTION: void* tcrdbext ( TCRDB* rdb, char* name, int opts, void* kbuf, int ksiz, void* vbuf, int vsiz, int* sp ) ; -FUNCTION: char* tcrdbext2 ( TCRDB* rdb, char* name, int opts, char* kstr, char* vstr ) ; +FUNCTION: void* tcrdbext ( TCRDB* rdb, c-string name, int opts, void* kbuf, int ksiz, void* vbuf, int vsiz, int* sp ) ; +FUNCTION: c-string tcrdbext2 ( TCRDB* rdb, c-string name, int opts, c-string kstr, c-string vstr ) ; FUNCTION: bool tcrdbsync ( TCRDB* rdb ) ; -FUNCTION: bool tcrdboptimize ( TCRDB* rdb, char* params ) ; +FUNCTION: bool tcrdboptimize ( TCRDB* rdb, c-string params ) ; FUNCTION: bool tcrdbvanish ( TCRDB* rdb ) ; -FUNCTION: bool tcrdbcopy ( TCRDB* rdb, char* path ) ; -FUNCTION: bool tcrdbrestore ( TCRDB* rdb, char* path, ulonglong ts, int opts ) ; -FUNCTION: bool tcrdbsetmst ( TCRDB* rdb, char* host, int port, int opts ) ; -FUNCTION: bool tcrdbsetmst2 ( TCRDB* rdb, char* expr, int opts ) ; -FUNCTION: char* tcrdbexpr ( TCRDB* rdb ) ; +FUNCTION: bool tcrdbcopy ( TCRDB* rdb, c-string path ) ; +FUNCTION: bool tcrdbrestore ( TCRDB* rdb, c-string path, ulonglong ts, int opts ) ; +FUNCTION: bool tcrdbsetmst ( TCRDB* rdb, c-string host, int port, int opts ) ; +FUNCTION: bool tcrdbsetmst2 ( TCRDB* rdb, c-string expr, int opts ) ; +FUNCTION: c-string tcrdbexpr ( TCRDB* rdb ) ; FUNCTION: ulonglong tcrdbrnum ( TCRDB* rdb ) ; FUNCTION: ulonglong tcrdbsize ( TCRDB* rdb ) ; -FUNCTION: char* tcrdbstat ( TCRDB* rdb ) ; -FUNCTION: TCLIST* tcrdbmisc ( TCRDB* rdb, char* name, int opts, TCLIST* args ) ; +FUNCTION: c-string tcrdbstat ( TCRDB* rdb ) ; +FUNCTION: TCLIST* tcrdbmisc ( TCRDB* rdb, c-string name, int opts, TCLIST* args ) ; CONSTANT: RDBITLEXICAL TDBITLEXICAL CONSTANT: RDBITDECIMAL TDBITDECIMAL @@ -128,12 +128,12 @@ FUNCTION: bool tcrdbtblputkeep ( TCRDB* rdb, void* pkbuf, int pksiz, TCMAP* cols FUNCTION: bool tcrdbtblputcat ( TCRDB* rdb, void* pkbuf, int pksiz, TCMAP* cols ) ; FUNCTION: bool tcrdbtblout ( TCRDB* rdb, void* pkbuf, int pksiz ) ; FUNCTION: TCMAP* tcrdbtblget ( TCRDB* rdb, void* pkbuf, int pksiz ) ; -FUNCTION: bool tcrdbtblsetindex ( TCRDB* rdb, char* name, int type ) ; +FUNCTION: bool tcrdbtblsetindex ( TCRDB* rdb, c-string name, int type ) ; FUNCTION: longlong tcrdbtblgenuid ( TCRDB* rdb ) ; FUNCTION: RDBQRY* tcrdbqrynew ( TCRDB* rdb ) ; FUNCTION: void tcrdbqrydel ( RDBQRY* qry ) ; -FUNCTION: void tcrdbqryaddcond ( RDBQRY* qry, char* name, int op, char* expr ) ; -FUNCTION: void tcrdbqrysetorder ( RDBQRY* qry, char* name, int type ) ; +FUNCTION: void tcrdbqryaddcond ( RDBQRY* qry, c-string name, int op, c-string expr ) ; +FUNCTION: void tcrdbqrysetorder ( RDBQRY* qry, c-string name, int type ) ; FUNCTION: void tcrdbqrysetlimit ( RDBQRY* qry, int max, int skip ) ; FUNCTION: TCLIST* tcrdbqrysearch ( RDBQRY* qry ) ; FUNCTION: bool tcrdbqrysearchout ( RDBQRY* qry ) ; diff --git a/extra/tokyo/alien/tctdb/tctdb.factor b/extra/tokyo/alien/tctdb/tctdb.factor index 9e8071d0df..82100e23c8 100644 --- a/extra/tokyo/alien/tctdb/tctdb.factor +++ b/extra/tokyo/alien/tctdb/tctdb.factor @@ -71,7 +71,7 @@ CONSTANT: TDBQPSTOP 16777216 ! int (*)(const void *pkbuf, int pksiz, TCMAP *cols, void *op); TYPEDEF: void* TDBQRYPROC -FUNCTION: char* tctdberrmsg ( int ecode ) ; +FUNCTION: c-string tctdberrmsg ( int ecode ) ; FUNCTION: TCTDB* tctdbnew ( ) ; FUNCTION: void tctdbdel ( TCTDB* tdb ) ; FUNCTION: int tctdbecode ( TCTDB* tdb ) ; @@ -79,56 +79,56 @@ FUNCTION: bool tctdbsetmutex ( TCTDB* tdb ) ; FUNCTION: bool tctdbtune ( TCTDB* tdb, longlong bnum, char apow, char fpow, uchar opts ) ; FUNCTION: bool tctdbsetcache ( TCTDB* tdb, int rcnum, int lcnum, int ncnum ) ; FUNCTION: bool tctdbsetxmsiz ( TCTDB* tdb, longlong xmsiz ) ; -FUNCTION: bool tctdbopen ( TCTDB* tdb, char* path, int omode ) ; +FUNCTION: bool tctdbopen ( TCTDB* tdb, c-string path, int omode ) ; FUNCTION: bool tctdbclose ( TCTDB* tdb ) ; FUNCTION: bool tctdbput ( TCTDB* tdb, void* pkbuf, int pksiz, TCMAP* cols ) ; FUNCTION: bool tctdbput2 ( TCTDB* tdb, void* pkbuf, int pksiz, void* cbuf, int csiz ) ; -FUNCTION: bool tctdbput3 ( TCTDB* tdb, char* pkstr, char* cstr ) ; +FUNCTION: bool tctdbput3 ( TCTDB* tdb, c-string pkstr, c-string cstr ) ; FUNCTION: bool tctdbputkeep ( TCTDB* tdb, void* pkbuf, int pksiz, TCMAP* cols ) ; FUNCTION: bool tctdbputkeep2 ( TCTDB* tdb, void* pkbuf, int pksiz, void* cbuf, int csiz ) ; -FUNCTION: bool tctdbputkeep3 ( TCTDB* tdb, char* pkstr, char* cstr ) ; +FUNCTION: bool tctdbputkeep3 ( TCTDB* tdb, c-string pkstr, c-string cstr ) ; FUNCTION: bool tctdbputcat ( TCTDB* tdb, void* pkbuf, int pksiz, TCMAP* cols ) ; FUNCTION: bool tctdbputcat2 ( TCTDB* tdb, void* pkbuf, int pksiz, void* cbuf, int csiz ) ; -FUNCTION: bool tctdbputcat3 ( TCTDB* tdb, char* pkstr, char* cstr ) ; +FUNCTION: bool tctdbputcat3 ( TCTDB* tdb, c-string pkstr, c-string cstr ) ; FUNCTION: bool tctdbout ( TCTDB* tdb, void* pkbuf, int pksiz ) ; -FUNCTION: bool tctdbout2 ( TCTDB* tdb, char* pkstr ) ; +FUNCTION: bool tctdbout2 ( TCTDB* tdb, c-string pkstr ) ; FUNCTION: TCMAP* tctdbget ( TCTDB* tdb, void* pkbuf, int pksiz ) ; -FUNCTION: char* tctdbget2 ( TCTDB* tdb, void* pkbuf, int pksiz, int* sp ) ; -FUNCTION: char* tctdbget3 ( TCTDB* tdb, char* pkstr ) ; +FUNCTION: c-string tctdbget2 ( TCTDB* tdb, void* pkbuf, int pksiz, int* sp ) ; +FUNCTION: c-string tctdbget3 ( TCTDB* tdb, c-string pkstr ) ; FUNCTION: int tctdbvsiz ( TCTDB* tdb, void* pkbuf, int pksiz ) ; -FUNCTION: int tctdbvsiz2 ( TCTDB* tdb, char* pkstr ) ; +FUNCTION: int tctdbvsiz2 ( TCTDB* tdb, c-string pkstr ) ; FUNCTION: bool tctdbiterinit ( TCTDB* tdb ) ; FUNCTION: void* tctdbiternext ( TCTDB* tdb, int* sp ) ; -FUNCTION: char* tctdbiternext2 ( TCTDB* tdb ) ; +FUNCTION: c-string tctdbiternext2 ( TCTDB* tdb ) ; FUNCTION: TCLIST* tctdbfwmkeys ( TCTDB* tdb, void* pbuf, int psiz, int max ) ; -FUNCTION: TCLIST* tctdbfwmkeys2 ( TCTDB* tdb, char* pstr, int max ) ; +FUNCTION: TCLIST* tctdbfwmkeys2 ( TCTDB* tdb, c-string pstr, int max ) ; FUNCTION: int tctdbaddint ( TCTDB* tdb, void* pkbuf, int pksiz, int num ) ; FUNCTION: double tctdbadddouble ( TCTDB* tdb, void* pkbuf, int pksiz, double num ) ; FUNCTION: bool tctdbsync ( TCTDB* tdb ) ; FUNCTION: bool tctdboptimize ( TCTDB* tdb, longlong bnum, char apow, char fpow, uchar opts ) ; FUNCTION: bool tctdbvanish ( TCTDB* tdb ) ; -FUNCTION: bool tctdbcopy ( TCTDB* tdb, char* path ) ; +FUNCTION: bool tctdbcopy ( TCTDB* tdb, c-string path ) ; FUNCTION: bool tctdbtranbegin ( TCTDB* tdb ) ; FUNCTION: bool tctdbtrancommit ( TCTDB* tdb ) ; FUNCTION: bool tctdbtranabort ( TCTDB* tdb ) ; -FUNCTION: char* tctdbpath ( TCTDB* tdb ) ; +FUNCTION: c-string tctdbpath ( TCTDB* tdb ) ; FUNCTION: ulonglong tctdbrnum ( TCTDB* tdb ) ; FUNCTION: ulonglong tctdbfsiz ( TCTDB* tdb ) ; -FUNCTION: bool tctdbsetindex ( TCTDB* tdb, char* name, int type ) ; +FUNCTION: bool tctdbsetindex ( TCTDB* tdb, c-string name, int type ) ; FUNCTION: longlong tctdbgenuid ( TCTDB* tdb ) ; FUNCTION: TDBQRY* tctdbqrynew ( TCTDB* tdb ) ; FUNCTION: void tctdbqrydel ( TDBQRY* qry ) ; -FUNCTION: void tctdbqryaddcond ( TDBQRY* qry, char* name, int op, char* expr ) ; -FUNCTION: void tctdbqrysetorder ( TDBQRY* qry, char* name, int type ) ; +FUNCTION: void tctdbqryaddcond ( TDBQRY* qry, c-string name, int op, c-string expr ) ; +FUNCTION: void tctdbqrysetorder ( TDBQRY* qry, c-string name, int type ) ; FUNCTION: void tctdbqrysetlimit ( TDBQRY* qry, int max, int skip ) ; FUNCTION: TCLIST* tctdbqrysearch ( TDBQRY* qry ) ; FUNCTION: bool tctdbqrysearchout ( TDBQRY* qry ) ; FUNCTION: bool tctdbqryproc ( TDBQRY* qry, TDBQRYPROC proc, void* op ) ; -FUNCTION: char* tctdbqryhint ( TDBQRY* qry ) ; +FUNCTION: c-string tctdbqryhint ( TDBQRY* qry ) ; ! ======= -FUNCTION: void tctdbsetecode ( TCTDB* tdb, int ecode, char* filename, int line, char* func ) ; +FUNCTION: void tctdbsetecode ( TCTDB* tdb, int ecode, c-string filename, int line, c-string func ) ; FUNCTION: void tctdbsetdbgfd ( TCTDB* tdb, int fd ) ; FUNCTION: int tctdbdbgfd ( TCTDB* tdb ) ; FUNCTION: bool tctdbhasmutex ( TCTDB* tdb ) ; @@ -140,7 +140,7 @@ FUNCTION: ulonglong tctdbinode ( TCTDB* tdb ) ; FUNCTION: tokyo_time_t tctdbmtime ( TCTDB* tdb ) ; FUNCTION: uchar tctdbflags ( TCTDB* tdb ) ; FUNCTION: uchar tctdbopts ( TCTDB* tdb ) ; -FUNCTION: char* tctdbopaque ( TCTDB* tdb ) ; +FUNCTION: c-string tctdbopaque ( TCTDB* tdb ) ; FUNCTION: ulonglong tctdbbnumused ( TCTDB* tdb ) ; FUNCTION: int tctdbinum ( TCTDB* tdb ) ; FUNCTION: longlong tctdbuidseed ( TCTDB* tdb ) ; @@ -150,7 +150,7 @@ FUNCTION: bool tctdbputproc ( TCTDB* tdb, void* pkbuf, int pksiz, void* cbuf, in FUNCTION: bool tctdbforeach ( TCTDB* tdb, TCITER iter, void* op ) ; FUNCTION: bool tctdbqryproc2 ( TDBQRY* qry, TDBQRYPROC proc, void* op ) ; FUNCTION: bool tctdbqrysearchout2 ( TDBQRY* qry ) ; -FUNCTION: int tctdbstrtoindextype ( char* str ) ; +FUNCTION: int tctdbstrtoindextype ( c-string str ) ; FUNCTION: int tctdbqrycount ( TDBQRY* qry ) ; -FUNCTION: int tctdbqrystrtocondop ( char* str ) ; -FUNCTION: int tctdbqrystrtoordertype ( char* str ) ; +FUNCTION: int tctdbqrystrtocondop ( c-string str ) ; +FUNCTION: int tctdbqrystrtoordertype ( c-string str ) ; diff --git a/extra/tokyo/alien/tcutil/tcutil.factor b/extra/tokyo/alien/tcutil/tcutil.factor index 7cb6c5e092..afb78dba22 100644 --- a/extra/tokyo/alien/tcutil/tcutil.factor +++ b/extra/tokyo/alien/tcutil/tcutil.factor @@ -28,9 +28,9 @@ FUNCTION: TCLIST* tclistnew2 ( int anum ) ; FUNCTION: void tclistdel ( TCLIST* list ) ; FUNCTION: int tclistnum ( TCLIST* list ) ; FUNCTION: void* tclistval ( TCLIST* list, int index, int* sp ) ; -FUNCTION: char* tclistval2 ( TCLIST* list, int index ) ; +FUNCTION: c-string tclistval2 ( TCLIST* list, int index ) ; FUNCTION: void tclistpush ( TCLIST* list, void* ptr, int size ) ; -FUNCTION: void tclistpush2 ( TCLIST* list, char* str ) ; +FUNCTION: void tclistpush2 ( TCLIST* list, c-string str ) ; FUNCTION: void tcfree ( void* ptr ) ; TYPEDEF: void* TCCMP From 71d169e42088b940fe025966309d31fe6f4ea976 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 11:56:10 -0800 Subject: [PATCH 219/713] fix typos in alien docs --- basis/alien/c-types/c-types-docs.factor | 2 +- core/alien/alien-docs.factor | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/alien/c-types/c-types-docs.factor b/basis/alien/c-types/c-types-docs.factor index e73ce556b5..0bcb7b9401 100644 --- a/basis/alien/c-types/c-types-docs.factor +++ b/basis/alien/c-types/c-types-docs.factor @@ -103,7 +103,7 @@ HELP: ulonglong HELP: void { $description "This symbol is not a valid C type, but it can be used as the return type for a " { $link POSTPONE: FUNCTION: } " or " { $link POSTPONE: CALLBACK: } " definition or for an " { $link alien-invoke } " or " { $link alien-callback } " call." } ; HELP: void* -{ $description "This C type represents a generic pointer to C memory. See " { $link pointer } " for information on pointer C types." } +{ $description "This C type represents a generic pointer to C memory. See " { $link pointer } " for information on pointer C types." } ; HELP: c-string { $description "This C type represents a pointer to a C string. See " { $link "c-strings" } " for details about using strings with the FFI." } ; HELP: float diff --git a/core/alien/alien-docs.factor b/core/alien/alien-docs.factor index 0b4976fcbe..9389b24227 100644 --- a/core/alien/alien-docs.factor +++ b/core/alien/alien-docs.factor @@ -136,7 +136,7 @@ ARTICLE: "aliens" "Alien addresses" } "Anywhere that a " { $link alien } " instance is accepted, the " { $link f } " singleton may be passed in to denote a null pointer." $nl -"Usually alien objects do not have to created and dereferenced directly; instead declaring C function parameters and return values as having a " pointer type such as " { $snippet "void*" } " takes care of the details." +"Usually alien objects do not have to created and dereferenced directly; instead declaring C function parameters and return values as having a " { $link pointer } " type such as " { $snippet "void*" } " takes care of the details." { $subsections "syntax-aliens" "alien-expiry" From db8b6baa2f14b0b9d6a55374664ea612d526fe53 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 11:59:53 -0800 Subject: [PATCH 220/713] typo in alien.parser test --- basis/alien/parser/parser-tests.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/alien/parser/parser-tests.factor b/basis/alien/parser/parser-tests.factor index a730e3084f..26a71e9623 100644 --- a/basis/alien/parser/parser-tests.factor +++ b/basis/alien/parser/parser-tests.factor @@ -25,7 +25,7 @@ CONSTANT: eleven 11 [ pointer: int*** ] [ "int****" parse-c-type ] unit-test [ c-string ] [ "c-string" parse-c-type ] unit-test [ char2 ] [ "char2" parse-c-type ] unit-test - [ c-string2 ] [ "char2*" parse-c-type ] unit-test + [ pointer: char2 ] [ "char2*" parse-c-type ] unit-test [ "not-word" parse-c-type ] [ error>> no-word-error? ] must-fail-with ] with-file-vocabs From 1916b9269ea5d1162f7cb40944c18bca846a1d26 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 12:07:55 -0800 Subject: [PATCH 221/713] "pointer-c-type" word-prop hack is now unnecessary since all pointer types behave uniformly now --- basis/alien/c-types/c-types.factor | 20 ++------------------ basis/alien/parser/parser.factor | 1 - 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor index 73da41cc69..ef47f4b69c 100644 --- a/basis/alien/c-types/c-types.factor +++ b/basis/alien/c-types/c-types.factor @@ -223,22 +223,15 @@ MIXIN: value-type \ swap , [ heap-size , [ * >fixnum ] % ] [ % ] bi* ] [ ] make ; -GENERIC: typedef ( old new -- ) - PREDICATE: typedef-word < c-type-word "c-type" word-prop c-type-name? ; -M: word typedef ( old new -- ) +: typedef ( old new -- ) { [ nip define-symbol ] [ swap "c-type" set-word-prop ] } 2cleave ; -M: pointer typedef ( old new -- ) - to>> dup c-type-word? - [ swap "pointer-c-type" set-word-prop ] - [ 2drop ] if ; - TUPLE: long-long-type < c-type ; : ( -- c-type ) @@ -298,12 +291,6 @@ CONSTANT: primitive-types pointer? [ drop void* ] when ] if ; -: special-pointer-type ( type -- special-type ) - dup c-type-word? [ - dup "pointer-c-type" word-prop - [ ] [ "c-type" word-prop special-pointer-type ] ?if - ] [ drop f ] if ; - : primitive-pointer-type? ( type -- ? ) dup c-type-word? [ resolve-pointer-typedef [ void? ] [ primitive-types member? ] bi or @@ -313,10 +300,7 @@ PRIVATE> M: pointer c-type [ \ void* c-type ] dip - to>> dup special-pointer-type - [ nip ] [ - dup primitive-pointer-type? [ drop ] [ (pointer-c-type) ] if - ] ?if ; + to>> dup primitive-pointer-type? [ drop ] [ (pointer-c-type) ] if ; : 8-byte-alignment ( c-type -- c-type ) { diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index f5fdced048..cf8c878589 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -41,7 +41,6 @@ IN: alien.parser [ dup [ forget-class ] [ { "struct-size" } reset-props ] bi ] when { "c-type" - "pointer-c-type" "callback-effect" "callback-library" } reset-props ; From b45ec6397baf393d341d4be65ac9b07ca5f94181 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 12:20:47 -0800 Subject: [PATCH 222/713] typo in alien.data docs --- basis/alien/data/data-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/alien/data/data-docs.factor b/basis/alien/data/data-docs.factor index 895b8536f7..6ab6d56bc7 100644 --- a/basis/alien/data/data-docs.factor +++ b/basis/alien/data/data-docs.factor @@ -111,7 +111,7 @@ $nl { $subsections "byte-arrays-gc" } "C-style enumerated types are supported:" { $subsections POSTPONE: C-ENUM: } -"C types can be aliased for convenience and consitency with native library documentation:" +"C types can be aliased for convenience and consistency with native library documentation:" { $subsections POSTPONE: TYPEDEF: } "A utility for defining " { $link "destructors" } " for deallocating memory:" { $subsections "alien.destructors" } From 125c680e2f1d0ad6f6497f4f4e0a7ab5452a9364 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 12:53:09 -0800 Subject: [PATCH 223/713] cairo.ffi, core-foundation.strings: change some functions that don't really expect strings to use char* instead of c-string (reported by Blei) --- basis/cairo/ffi/ffi.factor | 2 +- basis/core-foundation/strings/strings.factor | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/basis/cairo/ffi/ffi.factor b/basis/cairo/ffi/ffi.factor index bca02c1f17..dc68af64dc 100644 --- a/basis/cairo/ffi/ffi.factor +++ b/basis/cairo/ffi/ffi.factor @@ -786,7 +786,7 @@ FUNCTION: int cairo_format_stride_for_width ( cairo_format_t format, int width ) ; FUNCTION: cairo_surface_t* -cairo_image_surface_create_for_data ( c-string data, cairo_format_t format, int width, int height, int stride ) ; +cairo_image_surface_create_for_data ( char* data, cairo_format_t format, int width, int height, int stride ) ; FUNCTION: c-string cairo_image_surface_get_data ( cairo_surface_t* surface ) ; diff --git a/basis/core-foundation/strings/strings.factor b/basis/core-foundation/strings/strings.factor index 9a91335ae2..4c7e9ba261 100644 --- a/basis/core-foundation/strings/strings.factor +++ b/basis/core-foundation/strings/strings.factor @@ -37,7 +37,7 @@ FUNCTION: void CFStringGetCharacters ( void* theString, CFIndex start, CFIndex l FUNCTION: Boolean CFStringGetCString ( CFStringRef theString, - c-string buffer, + UInt8* buffer, CFIndex bufferSize, CFStringEncoding encoding ) ; @@ -55,7 +55,7 @@ FUNCTION: CFIndex CFStringGetBytes ( FUNCTION: CFStringRef CFStringCreateWithCString ( CFAllocatorRef alloc, - c-string cStr, + UInt8* cStr, CFStringEncoding encoding ) ; From db6c083162cd83687a75ace9dd8f451ed54e0b09 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 13:15:16 -0800 Subject: [PATCH 224/713] change back other char/uchar* parameters that don't look like actual string types --- basis/core-foundation/data/data.factor | 2 +- basis/iokit/hid/hid.factor | 14 +++++++------- basis/windows/user32/user32.factor | 2 +- basis/x11/xlib/xlib.factor | 2 +- extra/libusb/libusb.factor | 16 ++++++++-------- extra/ogg/ogg.factor | 22 +++++++++++----------- extra/ogg/theora/theora.factor | 2 +- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/basis/core-foundation/data/data.factor b/basis/core-foundation/data/data.factor index 65d6d728c1..bb04431a0e 100644 --- a/basis/core-foundation/data/data.factor +++ b/basis/core-foundation/data/data.factor @@ -12,7 +12,7 @@ CONSTANT: kCFPropertyListImmutable 0 CONSTANT: kCFPropertyListMutableContainers 1 CONSTANT: kCFPropertyListMutableContainersAndLeaves 2 -FUNCTION: CFDataRef CFDataCreate ( CFAllocatorRef allocator, c-string bytes, CFIndex length ) ; +FUNCTION: CFDataRef CFDataCreate ( CFAllocatorRef allocator, UInt8* bytes, CFIndex length ) ; FUNCTION: CFTypeID CFGetTypeID ( CFTypeRef cf ) ; diff --git a/basis/iokit/hid/hid.factor b/basis/iokit/hid/hid.factor index bd3fc1e968..a2ac0d5e6f 100644 --- a/basis/iokit/hid/hid.factor +++ b/basis/iokit/hid/hid.factor @@ -132,7 +132,7 @@ TYPEDEF: UInt32 IOHIDValueScaleType TYPEDEF: UInt32 IOHIDTransactionDirectionType CALLBACK: void IOHIDCallback ( void* context, IOReturn result, void* sender ) ; -CALLBACK: void IOHIDReportCallback ( void* context, IOReturn result, void* sender, IOHIDReportType type, UInt32 reportID, c-string report, CFIndex reportLength ) ; +CALLBACK: void IOHIDReportCallback ( void* context, IOReturn result, void* sender, IOHIDReportType type, UInt32 reportID, uchar* report, CFIndex reportLength ) ; CALLBACK: void IOHIDValueCallback ( void* context, IOReturn result, void* sender, IOHIDValueRef value ) ; CALLBACK: void IOHIDValueMultipleCallback ( void* context, IOReturn result, void* sender, CFDictionaryRef multiple ) ; CALLBACK: void IOHIDDeviceCallback ( void* context, IOReturn result, void* sender, IOHIDDeviceRef device ) ; @@ -151,7 +151,7 @@ FUNCTION: void IOHIDDeviceScheduleWithRunLoop ( IOHIDDeviceRef device, CFRunLoop FUNCTION: void IOHIDDeviceUnscheduleFromRunLoop ( IOHIDDeviceRef device, CFRunLoopRef runLoop, CFStringRef runLoopMode ) ; FUNCTION: void IOHIDDeviceRegisterRemovalCallback ( IOHIDDeviceRef device, IOHIDCallback callback, void* context ) ; FUNCTION: void IOHIDDeviceRegisterInputValueCallback ( IOHIDDeviceRef device, IOHIDValueCallback callback, void* context ) ; -FUNCTION: void IOHIDDeviceRegisterInputReportCallback ( IOHIDDeviceRef device, c-string report, CFIndex reportLength, IOHIDReportCallback callback, void* context ) ; +FUNCTION: void IOHIDDeviceRegisterInputReportCallback ( IOHIDDeviceRef device, uchar* report, CFIndex reportLength, IOHIDReportCallback callback, void* context ) ; FUNCTION: void IOHIDDeviceSetInputValueMatching ( IOHIDDeviceRef device, CFDictionaryRef matching ) ; FUNCTION: void IOHIDDeviceSetInputValueMatchingMultiple ( IOHIDDeviceRef device, CFArrayRef multiple ) ; FUNCTION: IOReturn IOHIDDeviceSetValue ( IOHIDDeviceRef device, IOHIDElementRef element, IOHIDValueRef value ) ; @@ -162,10 +162,10 @@ FUNCTION: IOReturn IOHIDDeviceGetValue ( IOHIDDeviceRef device, IOHIDElementRef FUNCTION: IOReturn IOHIDDeviceCopyValueMultiple ( IOHIDDeviceRef device, CFArrayRef elements, CFDictionaryRef* pMultiple ) ; FUNCTION: IOReturn IOHIDDeviceGetValueWithCallback ( IOHIDDeviceRef device, IOHIDElementRef element, IOHIDValueRef* pValue, CFTimeInterval timeout, IOHIDValueCallback callback, void* context ) ; FUNCTION: IOReturn IOHIDDeviceCopyValueMultipleWithCallback ( IOHIDDeviceRef device, CFArrayRef elements, CFDictionaryRef* pMultiple, CFTimeInterval timeout, IOHIDValueMultipleCallback callback, void* context ) ; -FUNCTION: IOReturn IOHIDDeviceSetReport ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, c-string report, CFIndex reportLength ) ; -FUNCTION: IOReturn IOHIDDeviceSetReportWithCallback ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, c-string report, CFIndex reportLength, CFTimeInterval timeout, IOHIDReportCallback callback, void* context ) ; -FUNCTION: IOReturn IOHIDDeviceGetReport ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, c-string report, CFIndex* pReportLength ) ; -FUNCTION: IOReturn IOHIDDeviceGetReportWithCallback ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, c-string report, CFIndex* pReportLength, CFTimeInterval timeout, IOHIDReportCallback callback, void* context ) ; +FUNCTION: IOReturn IOHIDDeviceSetReport ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, char* report, CFIndex reportLength ) ; +FUNCTION: IOReturn IOHIDDeviceSetReportWithCallback ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, char* report, CFIndex reportLength, CFTimeInterval timeout, IOHIDReportCallback callback, void* context ) ; +FUNCTION: IOReturn IOHIDDeviceGetReport ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, char* report, CFIndex* pReportLength ) ; +FUNCTION: IOReturn IOHIDDeviceGetReportWithCallback ( IOHIDDeviceRef device, IOHIDReportType reportType, CFIndex reportID, char* report, CFIndex* pReportLength, CFTimeInterval timeout, IOHIDReportCallback callback, void* context ) ; ! IOHIDManager @@ -231,7 +231,7 @@ FUNCTION: IOHIDValueRef IOHIDValueCreateWithBytesNoCopy ( CFAllocatorRef allocat FUNCTION: IOHIDElementRef IOHIDValueGetElement ( IOHIDValueRef value ) ; FUNCTION: ulonglong IOHIDValueGetTimeStamp ( IOHIDValueRef value ) ; FUNCTION: CFIndex IOHIDValueGetLength ( IOHIDValueRef value ) ; -FUNCTION: c-string IOHIDValueGetBytePtr ( IOHIDValueRef value ) ; +FUNCTION: uchar* IOHIDValueGetBytePtr ( IOHIDValueRef value ) ; FUNCTION: CFIndex IOHIDValueGetIntegerValue ( IOHIDValueRef value ) ; FUNCTION: double IOHIDValueGetScaledValue ( IOHIDValueRef value, IOHIDValueScaleType type ) ; diff --git a/basis/windows/user32/user32.factor b/basis/windows/user32/user32.factor index a966b63308..9908bb1f1b 100644 --- a/basis/windows/user32/user32.factor +++ b/basis/windows/user32/user32.factor @@ -1352,7 +1352,7 @@ ALIAS: GetWindowLong GetWindowLongW FUNCTION: BOOL GetWindowRect ( HWND hWnd, LPRECT lpRect ) ; ! FUNCTION: GetWindowRgn ! FUNCTION: GetWindowRgnBox -FUNCTION: int GetWindowTextA ( HWND hWnd, c-string lpString, int nMaxCount ) ; +FUNCTION: int GetWindowTextA ( HWND hWnd, char* lpString, int nMaxCount ) ; ! FUNCTION: GetWindowTextLengthA ! FUNCTION: GetWindowTextLengthW ! FUNCTION: GetWindowTextW diff --git a/basis/x11/xlib/xlib.factor b/basis/x11/xlib/xlib.factor index 88b058abea..de01d509dd 100644 --- a/basis/x11/xlib/xlib.factor +++ b/basis/x11/xlib/xlib.factor @@ -464,7 +464,7 @@ STRUCT: XImage { height int } { xoffset int } { format int } -{ data c-string } +{ data uchar* } { byte_order int } { bitmap_unit int } { bitmap_bit_order int } diff --git a/extra/libusb/libusb.factor b/extra/libusb/libusb.factor index 38bf49ed5b..d521015d6f 100644 --- a/extra/libusb/libusb.factor +++ b/extra/libusb/libusb.factor @@ -128,7 +128,7 @@ STRUCT: libusb_endpoint_descriptor { bInterval uint8_t } { bRefresh uint8_t } { bSynchAddress uint8_t } - { extra c-string } + { extra uchar* } { extra_length int } ; STRUCT: libusb_interface_descriptor @@ -142,7 +142,7 @@ STRUCT: libusb_interface_descriptor { bInterfaceProtocol uint8_t } { iInterface uint8_t } { endpoint libusb_endpoint_descriptor* } - { extra c-string } + { extra uchar* } { extra_length int } ; STRUCT: libusb_interface @@ -159,7 +159,7 @@ STRUCT: libusb_config_descriptor { bmAttributes uint8_t } { MaxPower uint8_t } { interface libusb_interface* } - { extra c-string } + { extra uchar* } { extra_length int } ; STRUCT: libusb_control_setup @@ -227,7 +227,7 @@ STRUCT: libusb_transfer { actual_length int } { callback libusb_transfer_cb_fn } { user_data void* } - { buffer c-string } + { buffer uchar* } { num_iso_packets int } { iso_packet_desc libusb_iso_packet_descriptor[0] } ; @@ -370,14 +370,14 @@ FUNCTION: void libusb_free_transfer ( libusb_transfer* transfer ) ; FUNCTION: int libusb_control_transfer ( libusb_device_handle* dev_handle, uint8_t request_type, uint8_t request, uint16_t value, uint16_t index, - c-string data, uint16_t length, uint timeout ) ; + uchar* data, uint16_t length, uint timeout ) ; FUNCTION: int libusb_bulk_transfer ( libusb_device_handle* dev_handle, - uchar endpoint, c-string data, int length, + uchar endpoint, uchar* data, int length, int* actual_length, uint timeout ) ; FUNCTION: int libusb_interrupt_transfer ( libusb_device_handle* dev_handle, - uchar endpoint, c-string data, int length, + uchar endpoint, uchar* data, int length, int* actual_length, int timeout ) ; :: libusb_get_descriptor ( dev desc_type desc_index data length -- int ) @@ -392,7 +392,7 @@ FUNCTION: int libusb_interrupt_transfer ( libusb_device_handle* dev_handle, FUNCTION: int libusb_get_string_descriptor_ascii ( libusb_device_handle* dev, uint8_t index, - c-string data, + uchar* data, int length ) ; FUNCTION: int libusb_try_lock_events ( libusb_context* ctx ) ; diff --git a/extra/ogg/ogg.factor b/extra/ogg/ogg.factor index ed25740ff6..d7abece8bc 100644 --- a/extra/ogg/ogg.factor +++ b/extra/ogg/ogg.factor @@ -28,18 +28,18 @@ LIBRARY: ogg STRUCT: oggpack-buffer { endbyte long } { endbit int } - { buffer c-string } - { ptr c-string } + { buffer uchar* } + { ptr uchar* } { storage long } ; STRUCT: ogg-page - { header c-string } + { header uchar* } { header_len long } - { body c-string } + { body uchar* } { body_len long } ; STRUCT: ogg-stream-state - { body_data c-string } + { body_data uchar* } { body_storage long } { body_fill long } { body_returned long } @@ -59,7 +59,7 @@ STRUCT: ogg-stream-state { granulepos longlong } ; STRUCT: ogg-packet - { packet c-string } + { packet uchar* } { bytes long } { b_o_s long } { e_o_s long } @@ -67,7 +67,7 @@ STRUCT: ogg-packet { packetno longlong } ; STRUCT: ogg-sync-state - { data c-string } + { data uchar* } { storage int } { fill int } { returned int } @@ -81,7 +81,7 @@ FUNCTION: void oggpack_writealign ( oggpack-buffer* b) ; FUNCTION: void oggpack_writecopy ( oggpack-buffer* b, void* source, long bits ) ; FUNCTION: void oggpack_reset ( oggpack-buffer* b ) ; FUNCTION: void oggpack_writeclear ( oggpack-buffer* b ) ; -FUNCTION: void oggpack_readinit ( oggpack-buffer* b, c-string buf, int bytes ) ; +FUNCTION: void oggpack_readinit ( oggpack-buffer* b, uchar* buf, int bytes ) ; FUNCTION: void oggpack_write ( oggpack-buffer* b, ulong value, int bits ) ; FUNCTION: long oggpack_look ( oggpack-buffer* b, int bits ) ; FUNCTION: long oggpack_look1 ( oggpack-buffer* b ) ; @@ -91,14 +91,14 @@ FUNCTION: long oggpack_read ( oggpack-buffer* b, int bits ) ; FUNCTION: long oggpack_read1 ( oggpack-buffer* b ) ; FUNCTION: long oggpack_bytes ( oggpack-buffer* b ) ; FUNCTION: long oggpack_bits ( oggpack-buffer* b ) ; -FUNCTION: c-string oggpack_get_buffer ( oggpack-buffer* b ) ; +FUNCTION: uchar* oggpack_get_buffer ( oggpack-buffer* b ) ; FUNCTION: void oggpackB_writeinit ( oggpack-buffer* b ) ; FUNCTION: void oggpackB_writetrunc ( oggpack-buffer* b, long bits ) ; FUNCTION: void oggpackB_writealign ( oggpack-buffer* b ) ; FUNCTION: void oggpackB_writecopy ( oggpack-buffer* b, void* source, long bits ) ; FUNCTION: void oggpackB_reset ( oggpack-buffer* b ) ; FUNCTION: void oggpackB_writeclear ( oggpack-buffer* b ) ; -FUNCTION: void oggpackB_readinit ( oggpack-buffer* b, c-string buf, int bytes ) ; +FUNCTION: void oggpackB_readinit ( oggpack-buffer* b, uchar* buf, int bytes ) ; FUNCTION: void oggpackB_write ( oggpack-buffer* b, ulong value, int bits ) ; FUNCTION: long oggpackB_look ( oggpack-buffer* b, int bits ) ; FUNCTION: long oggpackB_look1 ( oggpack-buffer* b ) ; @@ -108,7 +108,7 @@ FUNCTION: long oggpackB_read ( oggpack-buffer* b, int bits ) ; FUNCTION: long oggpackB_read1 ( oggpack-buffer* b ) ; FUNCTION: long oggpackB_bytes ( oggpack-buffer* b ) ; FUNCTION: long oggpackB_bits ( oggpack-buffer* b ) ; -FUNCTION: c-string oggpackB_get_buffer ( oggpack-buffer* b ) ; +FUNCTION: uchar* oggpackB_get_buffer ( oggpack-buffer* b ) ; FUNCTION: int ogg_stream_packetin ( ogg-stream-state* os, ogg-packet* op ) ; FUNCTION: int ogg_stream_pageout ( ogg-stream-state* os, ogg-page* og ) ; FUNCTION: int ogg_stream_flush ( ogg-stream-state* os, ogg-page* og ) ; diff --git a/extra/ogg/theora/theora.factor b/extra/ogg/theora/theora.factor index 3e28129252..eb79613496 100644 --- a/extra/ogg/theora/theora.factor +++ b/extra/ogg/theora/theora.factor @@ -53,7 +53,7 @@ STRUCT: th-img-plane { width int } { height int } { stride int } - { data c-string } + { data uchar* } ; TYPEDEF: th-img-plane[3] th-ycbcr-buffer From 211004f7e0a82daa5b2d8cbaf637d68538219afb Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 13:27:18 -0800 Subject: [PATCH 225/713] add missing USING: effects.parser to descriptive, set-n --- extra/descriptive/descriptive.factor | 2 +- extra/set-n/set-n.factor | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/descriptive/descriptive.factor b/extra/descriptive/descriptive.factor index 0756c5c975..5c6b5028f8 100644 --- a/extra/descriptive/descriptive.factor +++ b/extra/descriptive/descriptive.factor @@ -3,7 +3,7 @@ USING: words kernel sequences locals locals.parser fry locals.definitions accessors parser namespaces continuations summary definitions generalizations arrays prettyprint debugger io -effects tools.annotations ; +effects tools.annotations effects.parser ; IN: descriptive ERROR: descriptive-error args underlying word ; diff --git a/extra/set-n/set-n.factor b/extra/set-n/set-n.factor index 80d8bf2246..0807b76b5c 100644 --- a/extra/set-n/set-n.factor +++ b/extra/set-n/set-n.factor @@ -1,5 +1,5 @@ USING: accessors assocs fry generalizations kernel locals math -namespaces parser sequences shuffle words ; +namespaces parser sequences shuffle words effects.parser ; IN: set-n : get* ( var n -- val ) namestack dup length rot - head assoc-stack ; From 0975b9a268cda8012140f176680e564b95da90ed Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 14:02:55 -0800 Subject: [PATCH 226/713] missed a uchar* in cairo.ffi --- basis/cairo/ffi/ffi.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/cairo/ffi/ffi.factor b/basis/cairo/ffi/ffi.factor index dc68af64dc..c4700d2dad 100644 --- a/basis/cairo/ffi/ffi.factor +++ b/basis/cairo/ffi/ffi.factor @@ -788,7 +788,7 @@ cairo_format_stride_for_width ( cairo_format_t format, int width ) ; FUNCTION: cairo_surface_t* cairo_image_surface_create_for_data ( char* data, cairo_format_t format, int width, int height, int stride ) ; -FUNCTION: c-string +FUNCTION: uchar* cairo_image_surface_get_data ( cairo_surface_t* surface ) ; FUNCTION: cairo_format_t From f6183703b29e015710b2d3396d744b02ae036663 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 19:28:57 -0800 Subject: [PATCH 227/713] ui: add a "system-alert" hook that can raise a system modal dialog without involving any potentially stripped gadget, io, or debugger code --- basis/cocoa/cocoa.factor | 1 + basis/ui/backend/cocoa/cocoa.factor | 10 ++++++++++ basis/ui/backend/windows/windows.factor | 3 +++ basis/ui/backend/x11/x11.factor | 12 ++++++++++++ basis/ui/ui.factor | 2 ++ 5 files changed, 28 insertions(+) diff --git a/basis/cocoa/cocoa.factor b/basis/cocoa/cocoa.factor index 34bac0a505..fb21843c0f 100644 --- a/basis/cocoa/cocoa.factor +++ b/basis/cocoa/cocoa.factor @@ -39,6 +39,7 @@ SYNTAX: IMPORT: scan [ ] import-objc-class ; [ { + "NSAlert" "NSApplication" "NSArray" "NSAutoreleasePool" diff --git a/basis/ui/backend/cocoa/cocoa.factor b/basis/ui/backend/cocoa/cocoa.factor index 8eeca89c2f..6e64c35e49 100644 --- a/basis/ui/backend/cocoa/cocoa.factor +++ b/basis/ui/backend/cocoa/cocoa.factor @@ -213,6 +213,16 @@ M: cocoa-ui-backend offscreen-pixels ( world -- alien w h ) M: cocoa-ui-backend beep ( -- ) NSBeep ; +M: cocoa-ui-backend system-alert + NSAlert -> alloc -> init -> autorelease [ + { + [ swap -> setInformativeText: ] + [ swap -> setMessageText: ] + [ "OK" -> addButtonWithTitle: drop ] + [ -> runModal drop ] + } cleave + ] [ 2drop ] if* ; + CLASS: { { +superclass+ "NSObject" } { +name+ "FactorApplicationDelegate" } diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index 69b09dcba0..5863d3f39d 100644 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -783,6 +783,9 @@ M: windows-ui-backend (with-ui) M: windows-ui-backend beep ( -- ) 0 MessageBeep drop ; +M: windows-ui-backend system-alert + [ f ] 2dip swap MB_OK MessageBox drop ; + : fullscreen-RECT ( hwnd -- RECT ) MONITOR_DEFAULTTONEAREST MonitorFromWindow MONITORINFOEX diff --git a/basis/ui/backend/x11/x11.factor b/basis/ui/backend/x11/x11.factor index 74d911ef90..ee6eb813b0 100644 --- a/basis/ui/backend/x11/x11.factor +++ b/basis/ui/backend/x11/x11.factor @@ -8,6 +8,7 @@ strings ui ui.backend ui.clipboards ui.event-loop ui.gadgets ui.gadgets.private ui.gadgets.worlds ui.gestures ui.pixel-formats ui.pixel-formats.private ui.private x11 x11.clipboard x11.constants x11.events x11.glx x11.io x11.windows x11.xim x11.xlib ; +FROM: unix.ffi => system ; IN: ui.backend.x11 SINGLETON: x11-ui-backend @@ -326,6 +327,17 @@ M: x11-ui-backend (with-ui) ( quot -- ) M: x11-ui-backend beep ( -- ) dpy get 100 XBell drop ; + + +M: x11-ui-backend system-alert + "\n\n" glue xmessage ; + : black ( -- xcolor ) 0 0 0 0 0 0 XColor ; inline M:: x11-ui-backend (grab-input) ( handle -- ) diff --git a/basis/ui/ui.factor b/basis/ui/ui.factor index e0fa560935..824ffb8351 100644 --- a/basis/ui/ui.factor +++ b/basis/ui/ui.factor @@ -243,6 +243,8 @@ M: object close-window HOOK: beep ui-backend ( -- ) +HOOK: system-alert ui-backend ( caption text -- ) + : parse-main-window-attributes ( class -- attributes ) "{" expect dup all-slots parse-tuple-literal-slots ; From cdc17e38e85cef6046d71114f5162faa6d1137cc Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 20:29:31 -0800 Subject: [PATCH 228/713] opengl.gl: all those GLchar* should be c-string[ascii] --- basis/opengl/gl/gl.factor | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/basis/opengl/gl/gl.factor b/basis/opengl/gl/gl.factor index 7652720f1a..58039558d7 100644 --- a/basis/opengl/gl/gl.factor +++ b/basis/opengl/gl/gl.factor @@ -4,7 +4,7 @@ ! This file is based on the gl.h that comes with xorg-x11 6.8.2 USING: alien alien.c-types alien.syntax combinators kernel parser -sequences system words opengl.gl.extensions ; +sequences system words opengl.gl.extensions io.encodings.ascii ; FROM: alien.c-types => short ; IN: opengl.gl @@ -24,6 +24,8 @@ TYPEDEF: double GLdouble TYPEDEF: double GLclampd C-TYPE: GLvoid +TYPEDEF: c-string[ascii] GLstring + ! Constants ! Boolean values @@ -668,7 +670,7 @@ FUNCTION: void glPopClientAttrib ( ) ; FUNCTION: GLint glRenderMode ( GLenum mode ) ; FUNCTION: GLenum glGetError ( ) ; -FUNCTION: c-string glGetString ( GLenum name ) ; +FUNCTION: GLstring glGetString ( GLenum name ) ; FUNCTION: void glFinish ( ) ; FUNCTION: void glFlush ( ) ; FUNCTION: void glHint ( GLenum target, GLenum mode ) ; @@ -1587,10 +1589,8 @@ CONSTANT: GL_STENCIL_BACK_VALUE_MASK HEX: 8CA4 CONSTANT: GL_STENCIL_BACK_WRITEMASK HEX: 8CA5 ALIAS: GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION -TYPEDEF: char GLchar - GL-FUNCTION: void glAttachShader { glAttachObjectARB } ( GLuint program, GLuint shader ) ; -GL-FUNCTION: void glBindAttribLocation { glBindAttribLocationARB } ( GLuint program, GLuint index, GLchar* name ) ; +GL-FUNCTION: void glBindAttribLocation { glBindAttribLocationARB } ( GLuint program, GLuint index, GLstring name ) ; GL-FUNCTION: void glBlendEquationSeparate { glBlendEquationSeparateEXT } ( GLenum modeRGB, GLenum modeAlpha ) ; GL-FUNCTION: void glCompileShader { glCompileShaderARB } ( GLuint shader ) ; GL-FUNCTION: GLuint glCreateProgram { glCreateProgramObjectARB } ( ) ; @@ -1601,16 +1601,16 @@ GL-FUNCTION: void glDetachShader { glDetachObjectARB } ( GLuint program, GLuint GL-FUNCTION: void glDisableVertexAttribArray { glDisableVertexAttribArrayARB } ( GLuint index ) ; GL-FUNCTION: void glDrawBuffers { glDrawBuffersARB glDrawBuffersATI } ( GLsizei n, GLenum* bufs ) ; GL-FUNCTION: void glEnableVertexAttribArray { glEnableVertexAttribArrayARB } ( GLuint index ) ; -GL-FUNCTION: void glGetActiveAttrib { glGetActiveAttribARB } ( GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name ) ; -GL-FUNCTION: void glGetActiveUniform { glGetActiveUniformARB } ( GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name ) ; +GL-FUNCTION: void glGetActiveAttrib { glGetActiveAttribARB } ( GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLstring name ) ; +GL-FUNCTION: void glGetActiveUniform { glGetActiveUniformARB } ( GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLstring name ) ; GL-FUNCTION: void glGetAttachedShaders { glGetAttachedObjectsARB } ( GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders ) ; -GL-FUNCTION: GLint glGetAttribLocation { glGetAttribLocationARB } ( GLuint program, GLchar* name ) ; -GL-FUNCTION: void glGetProgramInfoLog { glGetInfoLogARB } ( GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog ) ; +GL-FUNCTION: GLint glGetAttribLocation { glGetAttribLocationARB } ( GLuint program, GLstring name ) ; +GL-FUNCTION: void glGetProgramInfoLog { glGetInfoLogARB } ( GLuint program, GLsizei bufSize, GLsizei* length, GLstring infoLog ) ; GL-FUNCTION: void glGetProgramiv { glGetObjectParameterivARB } ( GLuint program, GLenum pname, GLint* param ) ; -GL-FUNCTION: void glGetShaderInfoLog { glGetInfoLogARB } ( GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog ) ; -GL-FUNCTION: void glGetShaderSource { glGetShaderSourceARB } ( GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source ) ; +GL-FUNCTION: void glGetShaderInfoLog { glGetInfoLogARB } ( GLuint shader, GLsizei bufSize, GLsizei* length, GLstring infoLog ) ; +GL-FUNCTION: void glGetShaderSource { glGetShaderSourceARB } ( GLint obj, GLsizei maxLength, GLsizei* length, GLstring source ) ; GL-FUNCTION: void glGetShaderiv { glGetObjectParameterivARB } ( GLuint shader, GLenum pname, GLint* param ) ; -GL-FUNCTION: GLint glGetUniformLocation { glGetUniformLocationARB } ( GLint programObj, GLchar* name ) ; +GL-FUNCTION: GLint glGetUniformLocation { glGetUniformLocationARB } ( GLint programObj, GLstring name ) ; GL-FUNCTION: void glGetUniformfv { glGetUniformfvARB } ( GLuint program, GLint location, GLfloat* params ) ; GL-FUNCTION: void glGetUniformiv { glGetUniformivARB } ( GLuint program, GLint location, GLint* params ) ; GL-FUNCTION: void glGetVertexAttribPointerv { glGetVertexAttribPointervARB } ( GLuint index, GLenum pname, GLvoid** pointer ) ; @@ -1620,7 +1620,7 @@ GL-FUNCTION: void glGetVertexAttribiv { glGetVertexAttribivARB } ( GLuint index, GL-FUNCTION: GLboolean glIsProgram { glIsProgramARB } ( GLuint program ) ; GL-FUNCTION: GLboolean glIsShader { glIsShaderARB } ( GLuint shader ) ; GL-FUNCTION: void glLinkProgram { glLinkProgramARB } ( GLuint program ) ; -GL-FUNCTION: void glShaderSource { glShaderSourceARB } ( GLuint shader, GLsizei count, GLchar** strings, GLint* lengths ) ; +GL-FUNCTION: void glShaderSource { glShaderSourceARB } ( GLuint shader, GLsizei count, GLstring* strings, GLint* lengths ) ; GL-FUNCTION: void glStencilFuncSeparate { glStencilFuncSeparateATI } ( GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask ) ; GL-FUNCTION: void glStencilMaskSeparate { } ( GLenum face, GLuint mask ) ; GL-FUNCTION: void glStencilOpSeparate { glStencilOpSeparateATI } ( GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass ) ; @@ -1991,8 +1991,8 @@ GL-FUNCTION: void glUniform4uiv { glUniform4uivEXT } ( GLint location, GLsizei c GL-FUNCTION: void glGetUniformuiv { glGetUniformuivEXT } ( GLuint program, GLint location, GLuint* params ) ; -GL-FUNCTION: void glBindFragDataLocation { glBindFragDataLocationEXT } ( GLuint program, GLuint colorNumber, GLchar* name ) ; -GL-FUNCTION: GLint glGetFragDataLocation { glGetFragDataLocationEXT } ( GLuint program, GLchar* name ) ; +GL-FUNCTION: void glBindFragDataLocation { glBindFragDataLocationEXT } ( GLuint program, GLuint colorNumber, GLstring name ) ; +GL-FUNCTION: GLint glGetFragDataLocation { glGetFragDataLocationEXT } ( GLuint program, GLstring name ) ; GL-FUNCTION: void glBeginConditionalRender { glBeginConditionalRenderNV } ( GLuint id, GLenum mode ) ; GL-FUNCTION: void glEndConditionalRender { glEndConditionalRenderNV } ( ) ; @@ -2061,10 +2061,10 @@ GL-FUNCTION: void glBeginTransformFeedback { glBeginTransformFeedbackEXT } ( GLe GL-FUNCTION: void glEndTransformFeedback { glEndTransformFeedbackEXT } ( ) ; GL-FUNCTION: void glTransformFeedbackVaryings { glTransformFeedbackVaryingsEXT } ( GLuint program, GLsizei count, - GLchar** varyings, GLenum bufferMode ) ; + GLstring* varyings, GLenum bufferMode ) ; GL-FUNCTION: void glGetTransformFeedbackVarying { glGetTransformFeedbackVaryingEXT } ( GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, - GLsizei* size, GLenum* type, GLchar* name ) ; + GLsizei* size, GLenum* type, GLstring name ) ; GL-FUNCTION: void glClearBufferiv { } ( GLenum buffer, GLint drawbuffer, GLint* value ) ; GL-FUNCTION: void glClearBufferuiv { } ( GLenum buffer, GLint drawbuffer, GLuint* value ) ; @@ -2156,12 +2156,12 @@ GL-FUNCTION: void glDrawElementsInstanced { glDrawElementsInstancedARB } ( GLenu GL-FUNCTION: void glTexBuffer { glTexBufferEXT } ( GLenum target, GLenum internalformat, GLuint buffer ) ; GL-FUNCTION: void glPrimitiveRestartIndex { } ( GLuint index ) ; -GL-FUNCTION: void glGetUniformIndices { } ( GLuint program, GLsizei uniformCount, GLchar** uniformNames, GLuint* uniformIndices ) ; +GL-FUNCTION: void glGetUniformIndices { } ( GLuint program, GLsizei uniformCount, GLstring* uniformNames, GLuint* uniformIndices ) ; GL-FUNCTION: void glGetActiveUniformsiv { } ( GLuint program, GLsizei uniformCount, GLuint* uniformIndices, GLenum pname, GLint* params ) ; -GL-FUNCTION: void glGetActiveUniformName { } ( GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformName ) ; -GL-FUNCTION: GLuint glGetUniformBlockIndex { } ( GLuint program, GLchar* uniformBlockName ) ; +GL-FUNCTION: void glGetActiveUniformName { } ( GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei* length, GLstring uniformName ) ; +GL-FUNCTION: GLuint glGetUniformBlockIndex { } ( GLuint program, GLstring uniformBlockName ) ; GL-FUNCTION: void glGetActiveUniformBlockiv { } ( GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params ) ; -GL-FUNCTION: void glGetActiveUniformBlockName { } ( GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformName ) ; +GL-FUNCTION: void glGetActiveUniformBlockName { } ( GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLstring uniformName ) ; GL-FUNCTION: void glUniformBlockBinding { } ( GLuint buffer, GLuint uniformBlockIndex, GLuint uniformBlockBinding ) ; GL-FUNCTION: void glCopyBufferSubData { glCopyBufferSubDataEXT } ( GLenum readtarget, GLenum writetarget, GLintptr readoffset, GLintptr writeoffset, GLsizeiptr size ) ; From 0eb6355827574f78391cacae19f2fcc2976c057f Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 20:29:51 -0800 Subject: [PATCH 229/713] document system-alert --- basis/ui/ui-docs.factor | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/basis/ui/ui-docs.factor b/basis/ui/ui-docs.factor index b55ea44c6b..b2f97857f6 100644 --- a/basis/ui/ui-docs.factor +++ b/basis/ui/ui-docs.factor @@ -81,6 +81,11 @@ HELP: with-ui HELP: beep { $description "Plays the system beep sound." } ; +HELP: system-alert +{ $values { "caption" string } { "text" string } } +{ $description "Displays an application-modal alert dialog box with the given caption and text." } +{ $notes "Since the window raised by this word is modal, all processing in all Factor threads will halt until the dialog is dismissed. In an application that makes full use of the UI framework, it would be more appropriate to display a pane gadget in a Factor window. This word is meant primarily to be used to display errors in deployed applications with minimal dependencies on the UI library, such as games." } ; + HELP: topmost-window { $values { "world" world } } { $description "Returns the " { $link world } " representing the currently focused window." } ; From 32b42185e6aecc530aa7f960bf1fac8ff6652794 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 20:42:36 -0800 Subject: [PATCH 230/713] tools.deploy.shaker: raise a generic "This application died" system-alert instead of quietly crashing and burning in the ui-error-hook for deployed apps with the debugger stripped --- basis/tools/deploy/shaker/shaker.factor | 12 ++++++++---- basis/tools/deploy/shaker/strip-ui-error-hook.factor | 7 +++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 basis/tools/deploy/shaker/strip-ui-error-hook.factor diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index 09219a8e5e..9a5f89fae0 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -62,6 +62,13 @@ IN: tools.deploy.shaker run-file ] when ; +: strip-ui-error-hook ( -- ) + strip-debugger? deploy-ui? get and "ui" vocab and [ + "Installing generic UI error hook" show + "vocab:tools/deploy/shaker/strip-ui-error-hook.factor" + run-file + ] when ; + : strip-libc ( -- ) "libc" vocab [ "Stripping manual memory management debug code" show @@ -372,10 +379,6 @@ IN: tools.deploy.shaker compiler.errors:compiler-errors continuations:thread-error-hook } % - - deploy-ui? get [ - "ui-error-hook" "ui.gadgets.worlds" lookup , - ] when ] when "windows-messages" "windows.messages" lookup [ , ] when* @@ -529,6 +532,7 @@ SYMBOL: deploy-vocab strip-call strip-cocoa strip-debugger + strip-ui-error-hook strip-specialized-arrays compute-next-methods strip-startup-hooks diff --git a/basis/tools/deploy/shaker/strip-ui-error-hook.factor b/basis/tools/deploy/shaker/strip-ui-error-hook.factor new file mode 100644 index 0000000000..2525145828 --- /dev/null +++ b/basis/tools/deploy/shaker/strip-ui-error-hook.factor @@ -0,0 +1,7 @@ +USING: namespaces tools.deploy.config fry sequences system kernel ui ui.gadgets.worlds ; + +deploy-name get "Factor" or '[ + _ " encountered an unhandled error." append + "The application will now exit." + system-alert die +] ui-error-hook set-global From b7727bc69561a07ff3d3282858310ecfb945868c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 22:55:57 -0800 Subject: [PATCH 231/713] ui.gadgets.worlds: deactivate world before calling the ui-error-hook --- basis/ui/gadgets/worlds/worlds.factor | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/basis/ui/gadgets/worlds/worlds.factor b/basis/ui/gadgets/worlds/worlds.factor index eea2933b04..05466f4673 100644 --- a/basis/ui/gadgets/worlds/worlds.factor +++ b/basis/ui/gadgets/worlds/worlds.factor @@ -217,8 +217,7 @@ ui-error-hook [ [ rethrow ] ] initialize dup [ draw-world* ] with-gl-context flush-layout-cache-hook get call( -- ) ] [ - over ui-error - f >>active? drop + swap f >>active? ui-error ] recover ] with-variable ] [ drop ] if ; From 856674f1106c23e33476f781a017824bdb3f286e Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Tue, 23 Feb 2010 23:00:24 -0800 Subject: [PATCH 232/713] Bindings to the WinUSB part of the Windows DDK --- basis/windows/ddk/winusb/authors.txt | 1 + basis/windows/ddk/winusb/platforms.txt | 1 + basis/windows/ddk/winusb/summary.txt | 1 + basis/windows/ddk/winusb/tags.txt | 1 + basis/windows/ddk/winusb/winusb.factor | 66 ++++++++++++++++++++++++++ 5 files changed, 70 insertions(+) create mode 100644 basis/windows/ddk/winusb/authors.txt create mode 100644 basis/windows/ddk/winusb/platforms.txt create mode 100644 basis/windows/ddk/winusb/summary.txt create mode 100644 basis/windows/ddk/winusb/tags.txt create mode 100644 basis/windows/ddk/winusb/winusb.factor diff --git a/basis/windows/ddk/winusb/authors.txt b/basis/windows/ddk/winusb/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/basis/windows/ddk/winusb/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/basis/windows/ddk/winusb/platforms.txt b/basis/windows/ddk/winusb/platforms.txt new file mode 100644 index 0000000000..205e64323d --- /dev/null +++ b/basis/windows/ddk/winusb/platforms.txt @@ -0,0 +1 @@ +winnt diff --git a/basis/windows/ddk/winusb/summary.txt b/basis/windows/ddk/winusb/summary.txt new file mode 100644 index 0000000000..0d95f10574 --- /dev/null +++ b/basis/windows/ddk/winusb/summary.txt @@ -0,0 +1 @@ +Bindings to the USB section of the Windows DDK. diff --git a/basis/windows/ddk/winusb/tags.txt b/basis/windows/ddk/winusb/tags.txt new file mode 100644 index 0000000000..ee46b6bc1f --- /dev/null +++ b/basis/windows/ddk/winusb/tags.txt @@ -0,0 +1 @@ +unportable bindings diff --git a/basis/windows/ddk/winusb/winusb.factor b/basis/windows/ddk/winusb/winusb.factor new file mode 100644 index 0000000000..3b98e7e8ca --- /dev/null +++ b/basis/windows/ddk/winusb/winusb.factor @@ -0,0 +1,66 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: alien.c-types alien.syntax classes.struct windows.kernel32 +windows.types alien.libraries ; +IN: windows.ddk.winusb + +<< "winusb" "winusb.dll" "stdcall" add-library >> +LIBRARY: winusb + +TYPEDEF: PVOID WINUSB_INTERFACE_HANDLE +TYPEDEF: WINUSB_INTERFACE_HANDLE* PWINUSB_INTERFACE_HANDLE + +STRUCT: USB_INTERFACE_DESCRIPTOR + { bLength UCHAR } + { bDescriptorType UCHAR } + { bInterfaceNumber UCHAR } + { bAlternateSetting UCHAR } + { bNumEndpoints UCHAR } + { bInterfaceClass UCHAR } + { bInterfaceSubClass UCHAR } + { bInterfaceProtocol UCHAR } + { iInterface UCHAR } ; +TYPEDEF: USB_INTERFACE_DESCRIPTOR* PUSB_INTERFACE_DESCRIPTOR + +C-ENUM: + UsbdPipeTypeControl + UsbdPipeTypeIsochronous + UsbdPipeTypeBulk + UsbdPipeTypeInterrupt ; +TYPEDEF: int USBD_PIPE_TYPE + +STRUCT: WINUSB_PIPE_INFORMATION + { PipeType USBD_PIPE_TYPE } + { PipeId UCHAR } + { MaximumPacketSize USHORT } + { Interval UCHAR } ; +TYPEDEF: WINUSB_PIPE_INFORMATION* PWINUSB_PIPE_INFORMATION + +STRUCT: WINUSB_SETUP_PACKET + { RequestType UCHAR } + { Request UCHAR } + { Value USHORT } + { Index USHORT } + { Length USHORT } ; +TYPEDEF: WINUSB_SETUP_PACKET* PWINUSB_SETUP_PACKET + +FUNCTION: BOOL WinUsb_AbortPipe ( WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR PipeID ) ; +FUNCTION: BOOL WinUsb_FlushPipe ( WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR PipeID ) ; +FUNCTION: BOOL WinUsb_ControlTransfer ( WINUSB_INTERFACE_HANDLE InterfaceHandle, WINUSB_SETUP_PACKET SetupPacket, PUCHAR Buffer, ULONG BufferLength, PULONG LengthTransferred, LPOVERLAPPED Overlapped ) ; +FUNCTION: BOOL WinUsb_Initialize ( HANDLE DeviceHandle, PWINUSB_INTERFACE_HANDLE InterfaceHandle ) ; +FUNCTION: BOOL WinUsb_Free ( WINUSB_INTERFACE_HANDLE InterfaceHandle ) ; +FUNCTION: BOOL WinUsb_GetAssociatedInterface ( WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR AssociatedInterfaceIndex, PWINUSB_INTERFACE_HANDLE AssociatedInterfaceHandle ) ; +FUNCTION: BOOL WinUsb_GetCurrentAlternateSetting ( WINUSB_INTERFACE_HANDLE InterfaceHandle, PUCHAR SettingNumber ) ; +FUNCTION: BOOL WinUsb_GetDescriptor ( WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR DescriptorType, UCHAR Index, USHORT LanguageID, PUCHAR Buffer, ULONG BufferLength, PULONG LengthTransferred ) ; +FUNCTION: BOOL WinUsb_GetPowerPolicy ( WINUSB_INTERFACE_HANDLE InterfaceHandle, ULONG PolicyType, PULONG ValueLength, PVOID Value ) ; +FUNCTION: BOOL WinUsb_GetOverlappedResult ( WINUSB_INTERFACE_HANDLE InterfaceHandle, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait ) ; +FUNCTION: BOOL WinUsb_GetPipePolicy ( WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR PipeID, ULONG PolicyType, PULONG ValueLength, PVOID Value ) ; +FUNCTION: BOOL WinUsb_QueryInterfaceSettings ( WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR AlternateInterfaceNumber, PUSB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor ) ; +FUNCTION: BOOL WinUsb_QueryDeviceInformation ( WINUSB_INTERFACE_HANDLE InterfaceHandle, ULONG InformationType, PULONG BufferLength, PVOID Buffer ) ; +FUNCTION: BOOL WinUsb_QueryPipe ( WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR AlternateInterfaceNumber, UCHAR PipeIndex, PWINUSB_PIPE_INFORMATION PipeInformation ) ; +FUNCTION: BOOL WinUsb_ReadPipe ( WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR PipeID, PUCHAR Buffer, ULONG BufferLength, PULONG LengthTransferred, LPOVERLAPPED Overlapped ) ; +FUNCTION: BOOL WinUsb_ResetPipe ( WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR PipeID ) ; +FUNCTION: BOOL WinUsb_SetCurrentAlternateSetting ( WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR SettingNumber ) ; +FUNCTION: BOOL WinUsb_SetPowerPolicy ( WINUSB_INTERFACE_HANDLE InterfaceHandle, ULONG PolicyType, ULONG ValueLength, PVOID Value ) ; +FUNCTION: BOOL WinUsb_SetPipePolicy ( WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR PipeID, ULONG PolicyType, ULONG ValueLength, PVOID Value ) ; +FUNCTION: BOOL WinUsb_WritePipe ( WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR PipeID, PUCHAR Buffer, ULONG BufferLength, PULONG LengthTransferred, LPOVERLAPPED Overlapped ) ; From af0ddd5985f325c5b7c75a84850cdcfa8dbffc09 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 24 Feb 2010 20:18:41 +1300 Subject: [PATCH 233/713] Specialized arrays, structs and other objects responding to the >c-ptr / byte-length protocol can now be written to binary streams --- basis/alien/c-types/c-types-docs.factor | 4 --- basis/alien/c-types/c-types.factor | 6 ---- basis/alien/data/data.factor | 11 ++++-- basis/bit-arrays/bit-arrays.factor | 2 +- basis/classes/struct/struct.factor | 10 +++--- basis/io/buffers/buffers.factor | 2 +- basis/io/ports/ports-tests.factor | 23 +++++++++++++ basis/io/ports/ports.factor | 22 +++++++----- basis/math/bitwise/bitwise.factor | 3 +- .../math/vectors/conversion/conversion.factor | 8 ++--- basis/math/vectors/simd/simd.factor | 12 +++---- basis/nibble-arrays/nibble-arrays.factor | 2 +- .../specialized-arrays.factor | 4 +++ .../specialized-vectors.factor | 6 ++-- .../known-words/known-words.factor | 6 ++-- core/alien/alien-docs.factor | 12 ++++++- core/alien/alien.factor | 11 +++++- core/bootstrap/primitives.factor | 2 +- core/io/files/files-tests.factor | 27 +++++++++++++-- core/io/io-docs.factor | 34 +++++++++++-------- core/io/io.factor | 2 +- .../byte-array/byte-array-tests.factor | 11 +++++- core/io/streams/c/c-docs.factor | 10 +++--- core/io/streams/c/c-tests.factor | 25 +++++++++++++- core/io/streams/c/c.factor | 30 +++++++++------- extra/audio/vorbis/vorbis.factor | 9 ++--- extra/mongodb/operations/operations.factor | 13 +++---- extra/synth/buffers/buffers.factor | 4 +-- vm/io.cpp | 9 +++-- 29 files changed, 212 insertions(+), 108 deletions(-) create mode 100644 basis/io/ports/ports-tests.factor diff --git a/basis/alien/c-types/c-types-docs.factor b/basis/alien/c-types/c-types-docs.factor index 0bcb7b9401..9592fb1812 100644 --- a/basis/alien/c-types/c-types-docs.factor +++ b/basis/alien/c-types/c-types-docs.factor @@ -6,10 +6,6 @@ QUALIFIED: math QUALIFIED: sequences IN: alien.c-types -HELP: byte-length -{ $values { "seq" "A byte array or float array" } { "n" "a non-negative integer" } } -{ $contract "Outputs the size of the byte array, struct, or specialized array data in bytes." } ; - HELP: heap-size { $values { "name" "a C type name" } { "size" math:integer } } { $description "Outputs the number of bytes needed for a heap-allocated value of this C type." } diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor index ef47f4b69c..17bf4765b8 100644 --- a/basis/alien/c-types/c-types.factor +++ b/basis/alien/c-types/c-types.factor @@ -193,12 +193,6 @@ M: c-type-name stack-size c-type stack-size ; M: c-type stack-size size>> cell align ; -GENERIC: byte-length ( seq -- n ) flushable - -M: byte-array byte-length length ; inline - -M: f byte-length drop 0 ; inline - : >c-bool ( ? -- int ) 1 0 ? ; inline : c-bool> ( int -- ? ) 0 = not ; inline diff --git a/basis/alien/data/data.factor b/basis/alien/data/data.factor index 93b1afd436..462bed8b76 100644 --- a/basis/alien/data/data.factor +++ b/basis/alien/data/data.factor @@ -1,7 +1,8 @@ -! (c)2009 Slava Pestov, Joe Groff bsd license +! (c)2009, 2010 Slava Pestov, Joe Groff bsd license USING: accessors alien alien.c-types alien.strings arrays byte-arrays cpu.architecture fry io io.encodings.binary -io.files io.streams.memory kernel libc math sequences words ; +io.files io.streams.memory kernel libc math sequences words +byte-vectors ; IN: alien.data GENERIC: require-c-array ( c-type -- ) @@ -65,6 +66,12 @@ M: memory-stream stream-read : byte-array>memory ( byte-array base -- ) swap dup byte-length memcpy ; inline +M: byte-vector stream-write + [ binary-object ] dip + [ [ length + ] keep lengthen drop ] + [ '[ _ underlying>> ] 2dip memcpy ] + 3bi ; + M: value-type c-type-rep drop int-rep ; M: value-type c-type-getter diff --git a/basis/bit-arrays/bit-arrays.factor b/basis/bit-arrays/bit-arrays.factor index 4fafc528fd..798bfb8ae9 100644 --- a/basis/bit-arrays/bit-arrays.factor +++ b/basis/bit-arrays/bit-arrays.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.data accessors math alien.accessors kernel +USING: alien alien.data accessors math alien.accessors kernel kernel.private sequences sequences.private byte-arrays parser prettyprint.custom fry ; IN: bit-arrays diff --git a/basis/classes/struct/struct.factor b/basis/classes/struct/struct.factor index 204b05517b..a3b198bd94 100644 --- a/basis/classes/struct/struct.factor +++ b/basis/classes/struct/struct.factor @@ -46,11 +46,11 @@ M: struct >c-ptr M: struct equal? { [ [ class ] bi@ = ] - [ [ >c-ptr ] [ [ >c-ptr ] [ byte-length ] bi ] bi* memory= ] + [ [ >c-ptr ] [ binary-object ] bi* memory= ] } 2&& ; inline M: struct hashcode* - [ >c-ptr ] [ byte-length ] bi hashcode* ; inline + binary-object hashcode* ; inline : struct-prototype ( class -- prototype ) "prototype" word-prop ; foldable @@ -137,7 +137,7 @@ PRIVATE> M: struct-class boa>object swap pad-struct-slots - [ ] [ struct-slots ] bi + [ ] [ struct-slots ] bi [ [ (writer-quot) call( value struct -- ) ] with 2each ] curry keep ; M: struct-class initial-value* ; inline @@ -203,7 +203,7 @@ M: struct-c-type c-struct? drop t ; define-inline-method ; : clone-underlying ( struct -- byte-array ) - [ >c-ptr ] [ byte-length ] bi memory>byte-array ; inline + binary-object memory>byte-array ; inline : (define-clone-method) ( class -- ) [ \ clone ] @@ -353,7 +353,7 @@ PRIVATE> ; - + : parse-struct-slots ( slots -- slots' more? ) scan { { ";" [ f ] } diff --git a/basis/io/buffers/buffers.factor b/basis/io/buffers/buffers.factor index 23358d9a0e..ce5ad2c9a0 100644 --- a/basis/io/buffers/buffers.factor +++ b/basis/io/buffers/buffers.factor @@ -61,7 +61,7 @@ HINTS: n>buffer fixnum buffer ; : >buffer ( byte-array buffer -- ) [ buffer-end byte-array>memory ] - [ [ length ] dip n>buffer ] + [ [ byte-length ] dip n>buffer ] 2bi ; HINTS: >buffer byte-array buffer ; diff --git a/basis/io/ports/ports-tests.factor b/basis/io/ports/ports-tests.factor new file mode 100644 index 0000000000..e637999880 --- /dev/null +++ b/basis/io/ports/ports-tests.factor @@ -0,0 +1,23 @@ +USING: destructors io io.encodings.binary io.files io.directories +io.files.temp io.ports kernel sequences math +specialized-arrays.instances.alien.c-types.int tools.test ; +IN: io.ports.tests + +! Make sure that writing malloced storage to a file works, and +! also make sure that writes larger than the buffer size work + +[ ] [ + "test.txt" temp-file binary [ + 100,000 iota + 0 + 100,000 malloc-int-array &dispose [ copy ] keep write + ] with-file-writer +] unit-test + +[ t ] [ + "test.txt" temp-file binary [ + 100,000 4 * read byte-array>int-array 100,000 iota sequence= + ] with-file-reader +] unit-test + +[ ] [ "test.txt" temp-file delete-file ] unit-test diff --git a/basis/io/ports/ports.factor b/basis/io/ports/ports.factor index 727d69adf8..0927e7e480 100644 --- a/basis/io/ports/ports.factor +++ b/basis/io/ports/ports.factor @@ -1,10 +1,11 @@ -! Copyright (C) 2005, 2008 Slava Pestov, Doug Coleman +! Copyright (C) 2005, 2010 Slava Pestov, Doug Coleman ! See http://factorcode.org/license.txt for BSD license. USING: math kernel io sequences io.buffers io.timeouts generic byte-vectors system io.encodings math.order io.backend -continuations classes byte-arrays namespaces splitting -grouping dlists assocs io.encodings.binary summary accessors -destructors combinators ; +continuations classes byte-arrays namespaces splitting grouping +dlists alien alien.c-types assocs io.encodings.binary summary +accessors destructors combinators fry specialized-arrays ; +SPECIALIZED-ARRAY: uchar IN: io.ports SYMBOL: default-buffer-size @@ -111,14 +112,17 @@ M: output-port stream-write1 1 over wait-to-write buffer>> byte>buffer ; inline +: write-in-groups ( byte-array port -- ) + [ binary-object ] dip + [ buffer>> size>> ] [ '[ _ stream-write ] ] bi + each ; + M: output-port stream-write dup check-disposed - over length over buffer>> size>> > [ - [ buffer>> size>> ] - [ [ stream-write ] curry ] bi - each + 2dup [ byte-length ] [ buffer>> size>> ] bi* > [ + write-in-groups ] [ - [ [ length ] dip wait-to-write ] + [ [ byte-length ] dip wait-to-write ] [ buffer>> >buffer ] 2bi ] if ; diff --git a/basis/math/bitwise/bitwise.factor b/basis/math/bitwise/bitwise.factor index e508b49a19..15db425137 100644 --- a/basis/math/bitwise/bitwise.factor +++ b/basis/math/bitwise/bitwise.factor @@ -117,8 +117,7 @@ M: byte-array bit-count byte-array-bit-count ; M: object bit-count - [ >c-ptr ] [ byte-length ] bi - byte-array-bit-count ; + binary-object byte-array-bit-count ; : even-parity? ( obj -- ? ) bit-count even? ; diff --git a/basis/math/vectors/conversion/conversion.factor b/basis/math/vectors/conversion/conversion.factor index 6148962ee0..9d60dd03d4 100644 --- a/basis/math/vectors/conversion/conversion.factor +++ b/basis/math/vectors/conversion/conversion.factor @@ -1,10 +1,10 @@ ! (c)Joe Groff bsd license -USING: accessors alien.c-types arrays assocs classes combinators -combinators.short-circuit fry kernel locals math -math.vectors math.vectors.simd math.vectors.simd.intrinsics sequences ; +USING: accessors alien arrays assocs classes combinators +combinators.short-circuit fry kernel locals math math.vectors +math.vectors.simd math.vectors.simd.intrinsics sequences ; FROM: alien.c-types => char uchar short ushort int uint longlong ulonglong - float double ; + float double heap-size ; IN: math.vectors.conversion ERROR: bad-vconvert from-type to-type ; diff --git a/basis/math/vectors/simd/simd.factor b/basis/math/vectors/simd/simd.factor index a60026317d..8d804247d3 100644 --- a/basis/math/vectors/simd/simd.factor +++ b/basis/math/vectors/simd/simd.factor @@ -1,9 +1,9 @@ -USING: accessors alien.c-types arrays byte-arrays classes combinators +USING: accessors alien arrays byte-arrays classes combinators cpu.architecture effects fry functors generalizations generic generic.parser kernel lexer literals macros math math.functions -math.vectors math.vectors.private math.vectors.simd.intrinsics namespaces parser -prettyprint.custom quotations sequences sequences.private vocabs -vocabs.loader words ; +math.vectors math.vectors.private math.vectors.simd.intrinsics +namespaces parser prettyprint.custom quotations sequences +sequences.private vocabs vocabs.loader words ; QUALIFIED-WITH: alien.c-types c IN: math.vectors.simd @@ -107,7 +107,7 @@ PRIVATE> M: simd-128 hashcode* underlying>> hashcode* ; inline M: simd-128 clone [ clone ] change-underlying ; inline -M: simd-128 c:byte-length drop 16 ; inline +M: simd-128 byte-length drop 16 ; inline M: simd-128 new-sequence 2dup length = @@ -243,7 +243,7 @@ A{ DEFINES ${T}{ ELT [ A-rep rep-component-type ] N [ A-rep rep-length ] -COERCER [ ELT c-type-class "coercer" word-prop [ ] or ] +COERCER [ ELT c:c-type-class "coercer" word-prop [ ] or ] SET-NTH [ ELT dup c:c-setter c:array-accessor ] diff --git a/basis/nibble-arrays/nibble-arrays.factor b/basis/nibble-arrays/nibble-arrays.factor index 16bea56862..865491ed21 100644 --- a/basis/nibble-arrays/nibble-arrays.factor +++ b/basis/nibble-arrays/nibble-arrays.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: math kernel sequences sequences.private byte-arrays -alien.c-types prettyprint.custom parser accessors ; +alien prettyprint.custom parser accessors ; IN: nibble-arrays TUPLE: nibble-array diff --git a/basis/specialized-arrays/specialized-arrays.factor b/basis/specialized-arrays/specialized-arrays.factor index 2aca62cc77..f7070c68e1 100644 --- a/basis/specialized-arrays/specialized-arrays.factor +++ b/basis/specialized-arrays/specialized-arrays.factor @@ -117,6 +117,7 @@ M: A v*high [ * \ T heap-size neg shift ] 2map ; inline ;FUNCTOR GENERIC: underlying-type ( c-type -- c-type' ) + M: c-type-word underlying-type dup "c-type" word-prop { { [ dup not ] [ drop no-c-type ] } @@ -149,18 +150,21 @@ M: c-type-word c-array-constructor underlying-type dup [ name>> "<" "-array>" surround ] [ specialized-array-vocab ] bi lookup [ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable + M: pointer c-array-constructor drop void* c-array-constructor ; M: c-type-word c-(array)-constructor underlying-type dup [ name>> "(" "-array)" surround ] [ specialized-array-vocab ] bi lookup [ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable + M: pointer c-(array)-constructor drop void* c-(array)-constructor ; M: c-type-word c-direct-array-constructor underlying-type dup [ name>> "" surround ] [ specialized-array-vocab ] bi lookup [ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable + M: pointer c-direct-array-constructor drop void* c-direct-array-constructor ; SYNTAX: SPECIALIZED-ARRAYS: diff --git a/basis/specialized-vectors/specialized-vectors.factor b/basis/specialized-vectors/specialized-vectors.factor index 557ca25cd5..c16fe2510d 100644 --- a/basis/specialized-vectors/specialized-vectors.factor +++ b/basis/specialized-vectors/specialized-vectors.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types alien.parser assocs -compiler.units functors growable kernel lexer math namespaces parser -prettyprint.custom sequences specialized-arrays +USING: accessors alien alien.c-types alien.parser assocs +compiler.units functors growable kernel lexer math namespaces +parser prettyprint.custom sequences specialized-arrays specialized-arrays.private strings vocabs vocabs.parser vocabs.generated fry make ; QUALIFIED: vectors.functor diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 4bf7dfe0fd..e93dca9072 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -652,15 +652,15 @@ M: bad-executable summary \ fgetc { alien } { object } define-primitive -\ fwrite { string alien } { } define-primitive +\ fwrite { c-ptr integer alien } { } define-primitive \ fputc { object alien } { } define-primitive -\ fread { integer string } { object } define-primitive +\ fread { integer alien } { object } define-primitive \ fflush { alien } { } define-primitive -\ fseek { alien integer integer } { } define-primitive +\ fseek { integer integer alien } { } define-primitive \ ftell { alien } { integer } define-primitive diff --git a/core/alien/alien-docs.factor b/core/alien/alien-docs.factor index 9389b24227..60c1cdaf69 100644 --- a/core/alien/alien-docs.factor +++ b/core/alien/alien-docs.factor @@ -1,9 +1,19 @@ USING: byte-arrays arrays help.syntax help.markup alien.syntax compiler definitions math libc eval debugger parser io io.backend system alien.accessors -alien.libraries alien.c-types quotations ; +alien.libraries alien.c-types quotations kernel ; IN: alien +HELP: >c-ptr +{ $values { "object" object } { "c-ptr" c-ptr } } +{ $contract "Outputs a pointer to the binary data of this object." } ; + +HELP: byte-length +{ $values { "object" object } { "n" "a non-negative integer" } } +{ $contract "Outputs the number of bytes of binary data that will be output by " { $link >c-ptr } "." } ; + +{ >c-ptr byte-length } related-words + HELP: alien { $class-description "The class of alien pointers. See " { $link "syntax-aliens" } " for syntax and " { $link "c-data" } " for general information." } ; diff --git a/core/alien/alien.factor b/core/alien/alien.factor index 16c33fc1c3..42f48f97aa 100644 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -8,10 +8,19 @@ PREDICATE: pinned-alien < alien underlying>> not ; UNION: pinned-c-ptr pinned-alien POSTPONE: f ; -GENERIC: >c-ptr ( obj -- c-ptr ) +GENERIC: >c-ptr ( obj -- c-ptr ) flushable M: c-ptr >c-ptr ; inline +GENERIC: byte-length ( seq -- n ) flushable + +M: byte-array byte-length length ; inline + +M: f byte-length drop 0 ; inline + +: binary-object ( obj -- c-ptr n ) + [ >c-ptr ] [ byte-length ] bi ; inline + SLOT: underlying M: object >c-ptr underlying>> ; inline diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 367dc4d942..43aeb6bd70 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -434,7 +434,7 @@ tuple { "fread" "io.streams.c" "primitive_fread" (( n alien -- str/f )) } { "fseek" "io.streams.c" "primitive_fseek" (( alien offset whence -- )) } { "ftell" "io.streams.c" "primitive_ftell" (( alien -- n )) } - { "fwrite" "io.streams.c" "primitive_fwrite" (( string alien -- )) } + { "fwrite" "io.streams.c" "primitive_fwrite" (( data length alien -- )) } { "(clone)" "kernel" "primitive_clone" (( obj -- newobj )) } { "" "kernel" "primitive_wrapper" (( obj -- wrapper )) } { "callstack" "kernel" "primitive_callstack" (( -- cs )) } diff --git a/core/io/files/files-tests.factor b/core/io/files/files-tests.factor index da5d670659..cf58dbfe05 100644 --- a/core/io/files/files-tests.factor +++ b/core/io/files/files-tests.factor @@ -2,7 +2,8 @@ USING: arrays debugger.threads destructors io io.directories io.encodings.ascii io.encodings.binary io.encodings.string io.encodings.8-bit.latin1 io.files io.files.private io.files.temp io.files.unique kernel make math sequences system -threads tools.test generic.single ; +threads tools.test generic.single specialized-arrays alien.c-types ; +SPECIALIZED-ARRAY: int IN: io.files.tests [ ] [ "append-test" temp-file dup exists? [ delete-file ] [ drop ] if ] unit-test @@ -65,6 +66,27 @@ IN: io.files.tests ] with-file-reader ] unit-test +! Writing specialized arrays to binary streams should work +[ ] [ + "test.txt" temp-file binary [ + int-array{ 1 2 3 } write + ] with-file-writer +] unit-test + +[ int-array{ 1 2 3 } ] [ + "test.txt" temp-file binary [ + 3 4 * read + ] with-file-reader + byte-array>int-array +] unit-test + +! Writing strings to binary streams should fail +[ + "test.txt" temp-file binary [ + "OMGFAIL" write + ] with-file-writer +] must-fail + ! Test EOF behavior [ 10 ] [ image binary [ @@ -73,8 +95,7 @@ IN: io.files.tests ] with-file-reader ] unit-test -USE: debugger.threads - +! Make sure that writing to a closed stream from another thread doesn't crash [ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test [ ] [ "test-quux.txt" temp-file delete-file ] unit-test diff --git a/core/io/io-docs.factor b/core/io/io-docs.factor index aa6e087442..11848cfa03 100644 --- a/core/io/io-docs.factor +++ b/core/io/io-docs.factor @@ -1,7 +1,21 @@ USING: help.markup help.syntax quotations hashtables kernel -classes strings continuations destructors math byte-arrays ; +classes strings continuations destructors math byte-arrays +alien ; IN: io +ARTICLE: "stream-types" "Binary and text streams" +"A word which outputs the stream element type:" +{ $subsections stream-element-type } +"Stream element types:" +{ $subsections +byte+ +character+ } +"The stream element type is the data type read and written by " { $link stream-read1 } " and " { $link stream-write1 } "." +$nl +"Binary streams have an element type of " { $link +byte+ } ". Elements are integers in the range " { $snippet "[0,255]" } ", representing bytes. Reading a sequence of elements produces a " { $link byte-array } ". Any object implementing the " { $link >c-ptr } " and " { $link byte-length } " generic words can be written to a binary stream." +$nl +"Character streams have an element tye of " { $link +character+ } ". Elements are non-negative integers, representing Unicode code points. Only instances of the " { $link string } " class can be read or written on a character stream." +$nl +"Most external streams are binary streams, and can be wrapped in string streams once a suitable encoding has been provided; see " { $link "io.encodings" } "." ; + HELP: +byte+ { $description "A stream element type. See " { $link stream-element-type } " for explanation." } ; @@ -10,15 +24,7 @@ HELP: +character+ HELP: stream-element-type { $values { "stream" "a stream" } { "type" { $link +byte+ } " or " { $link +character+ } } } -{ $description - "Outputs one of the following two values:" - { $list - { { $link +byte+ } " - indicates that stream elements are integers in the range " { $snippet "[0,255]" } "; they represent bytes. Reading a sequence of elements produces a " { $link byte-array } "." } - { { $link +character+ } " - indicates that stream elements are non-negative integers, representing Unicode code points. Reading a sequence of elements produces a " { $link string } "." } - } - "Most external streams are binary streams, and can be wrapped in string streams once a suitable encoding has been provided; see " { $link "io.encodings" } "." - -} ; +{ $contract "Outputs one of " { $link +byte+ } " or " { $link +character+ } "." } ; HELP: stream-readln { $values { "stream" "an input stream" } { "str/f" "a string or " { $link f } } } @@ -57,8 +63,8 @@ HELP: stream-write1 $io-error ; HELP: stream-write -{ $values { "seq" "a byte array or string" } { "stream" "an output stream" } } -{ $contract "Writes a sequence of elements to the stream. If the stream does buffering, output may not be performed immediately; use " { $link stream-flush } " to force output." } +{ $values { "data" "binary data or a string" } { "stream" "an output stream" } } +{ $contract "Writes a piece of data to the stream. If the stream performs buffering, output may not be performed immediately; use " { $link stream-flush } " to force output." } { $notes "Most code only works on one stream at a time and should instead use " { $link write } "; see " { $link "stdio" } "." } $io-error ; @@ -262,9 +268,7 @@ $nl "Stream protocol words are rarely called directly, since code which only works with one stream at a time should be written to use " { $link "stdio" } " instead, wrapping I/O operations such as " { $link read } " and " { $link write } " in " { $link with-input-stream } " and " { $link with-output-stream } "." $nl "All streams must implement the " { $link dispose } " word in addition to the stream protocol." -$nl -"The following word is required for all input and output streams:" -{ $subsections stream-element-type } +{ $subsections "stream-types" } "These words are required for binary and string input streams:" { $subsections stream-read1 diff --git a/core/io/io.factor b/core/io/io.factor index 48d7f413b8..519d6535b9 100644 --- a/core/io/io.factor +++ b/core/io/io.factor @@ -15,7 +15,7 @@ GENERIC: stream-read-partial ( n stream -- seq ) GENERIC: stream-readln ( stream -- str/f ) GENERIC: stream-write1 ( elt stream -- ) -GENERIC: stream-write ( seq stream -- ) +GENERIC: stream-write ( data stream -- ) GENERIC: stream-flush ( stream -- ) GENERIC: stream-nl ( stream -- ) diff --git a/core/io/streams/byte-array/byte-array-tests.factor b/core/io/streams/byte-array/byte-array-tests.factor index 96b122549d..dc95d454fa 100644 --- a/core/io/streams/byte-array/byte-array-tests.factor +++ b/core/io/streams/byte-array/byte-array-tests.factor @@ -1,5 +1,8 @@ USING: tools.test io.streams.byte-array io.encodings.binary -io.encodings.utf8 io kernel arrays strings namespaces math ; +io.encodings.utf8 io kernel arrays strings namespaces math +specialized-arrays alien.c-types ; +SPECIALIZED-ARRAY: int +IN: io.streams.byte-array.tests [ B{ } ] [ B{ } binary [ contents ] with-byte-reader ] unit-test [ B{ 1 2 3 } ] [ binary [ B{ 1 2 3 } write ] with-byte-writer ] unit-test @@ -37,3 +40,9 @@ io.encodings.utf8 io kernel arrays strings namespaces math ; [ B{ 123 } ] [ binary [ 123 >bignum write1 ] with-byte-writer ] unit-test + +! Writing specialized arrays to byte writers +[ int-array{ 1 2 3 } ] [ + binary [ int-array{ 1 2 3 } write ] with-byte-writer + byte-array>int-array +] unit-test diff --git a/core/io/streams/c/c-docs.factor b/core/io/streams/c/c-docs.factor index 7103e49f4a..246f65de98 100644 --- a/core/io/streams/c/c-docs.factor +++ b/core/io/streams/c/c-docs.factor @@ -1,5 +1,5 @@ USING: help.markup help.syntax io io.files threads -strings byte-arrays io.streams.plain ; +strings byte-arrays io.streams.plain alien math ; IN: io.streams.c ARTICLE: "io.streams.c" "ANSI C streams" @@ -42,9 +42,9 @@ HELP: fopen { $errors "Throws an error if the file could not be opened." } { $notes "User code should call " { $link } " or " { $link } " to get a high level stream." } ; -HELP: fwrite ( string alien -- ) -{ $values { "string" "a string" } { "alien" "a C FILE* handle" } } -{ $description "Writes a string of text to a C FILE* handle." } +HELP: fwrite +{ $values { "data" c-ptr } { "length" integer } { "alien" "a C FILE* handle" } } +{ $description "Writes some bytes to a C FILE* handle." } { $errors "Throws an error if the output operation failed." } ; HELP: fflush ( alien -- ) @@ -62,7 +62,7 @@ HELP: fgetc ( alien -- ch/f ) { $errors "Throws an error if the input operation failed." } ; HELP: fread ( n alien -- str/f ) -{ $values { "n" "a positive integer" } { "alien" "a C FILE* handle" } { "str/f" "a string or " { $link f } } } +{ $values { "n" "a positive integer" } { "alien" "a C FILE* handle" } { "str/f" { $maybe string } } } { $description "Reads a sequence of characters from a C FILE* handle, and outputs " { $link f } " on end of file." } { $errors "Throws an error if the input operation failed." } ; diff --git a/core/io/streams/c/c-tests.factor b/core/io/streams/c/c-tests.factor index 657c6ccd75..d05daf3662 100644 --- a/core/io/streams/c/c-tests.factor +++ b/core/io/streams/c/c-tests.factor @@ -1,5 +1,7 @@ USING: tools.test io.files io.files.temp io io.streams.c -io.encodings.ascii strings destructors kernel ; +io.encodings.ascii strings destructors kernel specialized-arrays +alien.c-types math ; +SPECIALIZED-ARRAY: int IN: io.streams.c.tests [ "hello world" ] [ @@ -17,3 +19,24 @@ IN: io.streams.c.tests 3 over stream-read drop [ stream-tell ] [ dispose ] bi ] unit-test + +! Writing specialized arrays to binary streams +[ ] [ + "test.txt" temp-file "wb" fopen [ + int-array{ 1 2 3 } write + ] with-output-stream +] unit-test + +[ int-array{ 1 2 3 } ] [ + "test.txt" temp-file "rb" fopen [ + 3 4 * read + ] with-input-stream + byte-array>int-array +] unit-test + +! Writing strings to binary streams should fail +[ + "test.txt" temp-file "wb" fopen [ + "OMGFAIL" write + ] with-output-stream +] must-fail diff --git a/core/io/streams/c/c.factor b/core/io/streams/c/c.factor index d26f03aa5e..9ebf7f7018 100644 --- a/core/io/streams/c/c.factor +++ b/core/io/streams/c/c.factor @@ -1,9 +1,9 @@ -! Copyright (C) 2004, 2009 Slava Pestov. +! Copyright (C) 2004, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel kernel.private namespaces make io io.encodings sequences -math generic threads.private classes io.backend io.files -io.encodings.utf8 alien.strings continuations destructors byte-arrays -accessors combinators ; +USING: alien alien.strings kernel kernel.private namespaces make +io io.encodings sequences math generic threads.private classes +io.backend io.files io.encodings.utf8 continuations destructors +byte-arrays accessors combinators ; IN: io.streams.c TUPLE: c-stream < disposable handle ; @@ -16,12 +16,14 @@ M: c-stream dispose* handle>> fclose ; M: c-stream stream-tell handle>> ftell ; M: c-stream stream-seek - handle>> swap { - { seek-absolute [ 0 ] } - { seek-relative [ 1 ] } - { seek-end [ 2 ] } - [ bad-seek-type ] - } case fseek ; + [ + { + { seek-absolute [ 0 ] } + { seek-relative [ 1 ] } + { seek-end [ 2 ] } + [ bad-seek-type ] + } case + ] [ handle>> ] bi* fseek ; TUPLE: c-writer < c-stream ; @@ -31,7 +33,9 @@ M: c-writer stream-element-type drop +byte+ ; M: c-writer stream-write1 dup check-disposed handle>> fputc ; -M: c-writer stream-write dup check-disposed handle>> fwrite ; +M: c-writer stream-write + dup check-disposed + [ [ >c-ptr ] [ byte-length ] bi ] [ handle>> ] bi* fwrite ; M: c-writer stream-flush dup check-disposed handle>> fflush ; @@ -93,6 +97,6 @@ M: c-io-backend (file-appender) #! print stuff from contexts where the I/O system would #! otherwise not work (tools.deploy.shaker, the I/O #! multiplexer thread). - "\n" append >byte-array + "\n" append >byte-array dup length stdout-handle fwrite stdout-handle fflush ; diff --git a/extra/audio/vorbis/vorbis.factor b/extra/audio/vorbis/vorbis.factor index 78f637770f..e67c7b7934 100644 --- a/extra/audio/vorbis/vorbis.factor +++ b/extra/audio/vorbis/vorbis.factor @@ -1,8 +1,9 @@ ! (c)2007, 2010 Chris Double, Joe Groff bsd license -USING: accessors alien.c-types audio.engine byte-arrays classes.struct -combinators destructors fry io io.files io.encodings.binary -kernel libc locals make math math.order math.parser ogg ogg.vorbis -sequences specialized-arrays specialized-vectors ; +USING: accessors alien alien.c-types audio.engine byte-arrays +classes.struct combinators destructors fry io io.files +io.encodings.binary kernel libc locals make math math.order +math.parser ogg ogg.vorbis sequences specialized-arrays +specialized-vectors ; FROM: alien.c-types => float short void* ; SPECIALIZED-ARRAYS: float void* ; SPECIALIZED-VECTOR: short diff --git a/extra/mongodb/operations/operations.factor b/extra/mongodb/operations/operations.factor index 8ecd5df54c..56e560f07a 100644 --- a/extra/mongodb/operations/operations.factor +++ b/extra/mongodb/operations/operations.factor @@ -1,12 +1,9 @@ USING: accessors assocs bson.reader bson.writer byte-arrays -byte-vectors combinators formatting fry io io.binary io.encodings.private -io.encodings.binary io.encodings.string io.encodings.utf8 io.encodings.utf8.private io.files -kernel locals math mongodb.msg namespaces sequences uuid bson.writer.private ; - -IN: alien.c-types - -M: byte-vector byte-length length ; - +byte-vectors combinators formatting fry io io.binary +io.encodings.private io.encodings.binary io.encodings.string +io.encodings.utf8 io.encodings.utf8.private io.files kernel +locals math mongodb.msg namespaces sequences uuid +bson.writer.private ; IN: mongodb.operations short ; +FROM: alien.c-types => short uchar ; SPECIALIZED-ARRAY: uchar SPECIALIZED-ARRAY: short IN: synth.buffers diff --git a/vm/io.cpp b/vm/io.cpp index 8eaaa453b5..0682a1d124 100755 --- a/vm/io.cpp +++ b/vm/io.cpp @@ -218,14 +218,13 @@ void factor_vm::primitive_fputc() void factor_vm::primitive_fwrite() { FILE *file = pop_file_handle(); - byte_array *text = untag_check(ctx->pop()); - cell length = array_capacity(text); - char *string = (char *)(text + 1); + cell length = to_cell(ctx->pop()); + char *text = alien_offset(ctx->pop()); if(length == 0) return; - size_t written = safe_fwrite(string,1,length,file); + size_t written = safe_fwrite(text,1,length,file); if(written != length) io_error(); } @@ -238,8 +237,8 @@ void factor_vm::primitive_ftell() void factor_vm::primitive_fseek() { - int whence = to_fixnum(ctx->pop()); FILE *file = pop_file_handle(); + int whence = to_fixnum(ctx->pop()); off_t offset = to_signed_8(ctx->pop()); safe_fseek(file,offset,whence); } From fa6c8117aad6c7bc7a5b489b258ef50c1a893306 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 24 Feb 2010 20:18:48 +1300 Subject: [PATCH 234/713] cocoa.messages: cleanup --- basis/cocoa/messages/messages.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/cocoa/messages/messages.factor b/basis/cocoa/messages/messages.factor index 2569c391d1..a744087037 100644 --- a/basis/cocoa/messages/messages.factor +++ b/basis/cocoa/messages/messages.factor @@ -237,8 +237,8 @@ ERROR: no-objc-type name ; : import-objc-class ( name quot -- ) 2dup swap define-objc-class-word - over objc_getClass [ drop ] [ call( -- ) ] if - dup objc_getClass [ + over class-exists? [ drop ] [ call( -- ) ] if + dup class-exists? [ [ objc_getClass register-objc-methods ] [ objc_getMetaClass register-objc-methods ] bi ] [ drop ] if ; From 187e0f96ca3e03bae45ca56eb958157f6a3f801d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 24 Feb 2010 20:24:32 +1300 Subject: [PATCH 235/713] Move closures, fries and set-n to unmaintained --- {extra => unmaintained}/closures/closures.factor | 0 {extra => unmaintained}/fries/authors.txt | 0 {extra => unmaintained}/fries/fries.factor | 0 {extra => unmaintained}/fries/summary.txt | 0 {extra => unmaintained}/set-n/set-n.factor | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename {extra => unmaintained}/closures/closures.factor (100%) rename {extra => unmaintained}/fries/authors.txt (100%) rename {extra => unmaintained}/fries/fries.factor (100%) rename {extra => unmaintained}/fries/summary.txt (100%) rename {extra => unmaintained}/set-n/set-n.factor (100%) diff --git a/extra/closures/closures.factor b/unmaintained/closures/closures.factor similarity index 100% rename from extra/closures/closures.factor rename to unmaintained/closures/closures.factor diff --git a/extra/fries/authors.txt b/unmaintained/fries/authors.txt similarity index 100% rename from extra/fries/authors.txt rename to unmaintained/fries/authors.txt diff --git a/extra/fries/fries.factor b/unmaintained/fries/fries.factor similarity index 100% rename from extra/fries/fries.factor rename to unmaintained/fries/fries.factor diff --git a/extra/fries/summary.txt b/unmaintained/fries/summary.txt similarity index 100% rename from extra/fries/summary.txt rename to unmaintained/fries/summary.txt diff --git a/extra/set-n/set-n.factor b/unmaintained/set-n/set-n.factor similarity index 100% rename from extra/set-n/set-n.factor rename to unmaintained/set-n/set-n.factor From 2aa1a3dbd7f14836c0c19692b9b0ba6562046aca Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Feb 2010 23:50:34 -0800 Subject: [PATCH 236/713] ui.backend.cocoa: invalidate run loop timers before raising an NSAlert and add them back when runModal returns to avoid run loop callbacks reentering Factor --- basis/core-foundation/run-loop/run-loop.factor | 3 +++ basis/ui/backend/cocoa/cocoa.factor | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/basis/core-foundation/run-loop/run-loop.factor b/basis/core-foundation/run-loop/run-loop.factor index 2370dd4562..e2ba06d61f 100644 --- a/basis/core-foundation/run-loop/run-loop.factor +++ b/basis/core-foundation/run-loop/run-loop.factor @@ -91,6 +91,9 @@ TUPLE: run-loop fds sources timers ; CFRunLoopAddTimer ] bi ; +: invalidate-run-loop-timers ( -- ) + run-loop [ [ [ CFRunLoopTimerInvalidate ] [ CFRelease ] bi ] each V{ } ] change-timers drop ; + alloc -> init -> autorelease [ { [ swap -> setInformativeText: ] @@ -221,7 +222,8 @@ M: cocoa-ui-backend system-alert [ "OK" -> addButtonWithTitle: drop ] [ -> runModal drop ] } cleave - ] [ 2drop ] if* ; + ] [ 2drop ] if* + init-thread-timer ; CLASS: { { +superclass+ "NSObject" } From 570e332f849b34db4fa44612b9d7c65572a38d25 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 24 Feb 2010 21:18:29 +1300 Subject: [PATCH 237/713] core-foundation.run-loop: cleanup --- basis/core-foundation/run-loop/run-loop.factor | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/basis/core-foundation/run-loop/run-loop.factor b/basis/core-foundation/run-loop/run-loop.factor index e2ba06d61f..56b5a9c798 100644 --- a/basis/core-foundation/run-loop/run-loop.factor +++ b/basis/core-foundation/run-loop/run-loop.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov +! Copyright (C) 2008, 2010 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien alien.c-types alien.syntax kernel math namespaces sequences destructors combinators threads heaps @@ -92,7 +92,10 @@ TUPLE: run-loop fds sources timers ; ] bi ; : invalidate-run-loop-timers ( -- ) - run-loop [ [ [ CFRunLoopTimerInvalidate ] [ CFRelease ] bi ] each V{ } ] change-timers drop ; + run-loop [ + [ [ CFRunLoopTimerInvalidate ] [ CFRelease ] bi ] each + V{ } clone + ] change-timers drop ; Date: Wed, 24 Feb 2010 21:20:21 +1300 Subject: [PATCH 238/713] io.files.unix: fix load errors arising from byte-length being moved --- basis/io/files/info/unix/freebsd/freebsd.factor | 2 +- basis/io/files/info/unix/netbsd/netbsd.factor | 2 +- basis/io/files/info/unix/openbsd/openbsd.factor | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/basis/io/files/info/unix/freebsd/freebsd.factor b/basis/io/files/info/unix/freebsd/freebsd.factor index f1d6b4db66..7c13d86a3c 100644 --- a/basis/io/files/info/unix/freebsd/freebsd.factor +++ b/basis/io/files/info/unix/freebsd/freebsd.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types alien.syntax combinators +USING: accessors alien alien.c-types alien.syntax combinators io.backend io.files io.files.info io.files.unix kernel math system unix unix.statfs.freebsd unix.statvfs.freebsd unix.getfsstat.freebsd sequences grouping alien.strings io.encodings.utf8 unix.types diff --git a/basis/io/files/info/unix/netbsd/netbsd.factor b/basis/io/files/info/unix/netbsd/netbsd.factor index 9e37ec8aa9..9ea475433b 100644 --- a/basis/io/files/info/unix/netbsd/netbsd.factor +++ b/basis/io/files/info/unix/netbsd/netbsd.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax kernel unix.stat math unix +USING: alien alien.syntax kernel unix.stat math unix combinators system io.backend accessors alien.c-types io.encodings.utf8 alien.strings unix.types io.files.unix io.files io.files.info unix.statvfs.netbsd unix.getfsstat.netbsd arrays diff --git a/basis/io/files/info/unix/openbsd/openbsd.factor b/basis/io/files/info/unix/openbsd/openbsd.factor index be88929f2e..e80a4fdafd 100644 --- a/basis/io/files/info/unix/openbsd/openbsd.factor +++ b/basis/io/files/info/unix/openbsd/openbsd.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types alien.strings alien.syntax +USING: accessors alien alien.c-types alien.strings alien.syntax combinators io.backend io.files io.files.info io.files.unix kernel math sequences system unix unix.getfsstat.openbsd grouping unix.statfs.openbsd unix.statvfs.openbsd unix.types From dad3870abd4d994fb490f5cb6f24c28a372a9abc Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 24 Feb 2010 02:47:45 -0600 Subject: [PATCH 239/713] Use for(;;) instead of do/while in a few places, fix safe_fread's error handling --- vm/io.cpp | 66 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/vm/io.cpp b/vm/io.cpp index 0682a1d124..fdd872457e 100755 --- a/vm/io.cpp +++ b/vm/io.cpp @@ -34,20 +34,22 @@ void factor_vm::io_error() FILE *factor_vm::safe_fopen(char *filename, char *mode) { FILE *file; - do { + for(;;) + { file = fopen(filename,mode); if(file == NULL) io_error(); else break; - } while(errno == EINTR); + } return file; } int factor_vm::safe_fgetc(FILE *stream) { int c; - do { + for(;;) + { c = fgetc(stream); if(c == EOF) { @@ -58,38 +60,53 @@ int factor_vm::safe_fgetc(FILE *stream) } else break; - } while(errno == EINTR); + } return c; } size_t factor_vm::safe_fread(void *ptr, size_t size, size_t nitems, FILE *stream) { size_t items_read = 0; + size_t ret = 0; - do { - items_read += fread((void*)((int*)ptr+items_read*size),size,nitems-items_read,stream); - } while(items_read != nitems && errno == EINTR); + do + { + ret = fread((void*)((int*)ptr+items_read*size),size,nitems-items_read,stream); + if(ret == 0) + { + if(feof(stream)) + break; + else + io_error(); + } + items_read += ret; + } while(items_read != nitems); return items_read; } void factor_vm::safe_fputc(int c, FILE *stream) { - do { + for(;;) + { if(fputc(c,stream) == EOF) io_error(); else break; - } while(errno == EINTR); + } } size_t factor_vm::safe_fwrite(void *ptr, size_t size, size_t nitems, FILE *stream) { size_t items_written = 0; + size_t ret = 0; do { - items_written += fwrite((void*)((int*)ptr+items_written*size),size,nitems-items_written,stream); - } while(items_written != nitems && errno == EINTR); + ret = fwrite((void*)((int*)ptr+items_written*size),size,nitems-items_written,stream); + if(ret == 0) + io_error(); + items_written += ret; + } while(items_written != nitems); return items_written; } @@ -97,12 +114,13 @@ size_t factor_vm::safe_fwrite(void *ptr, size_t size, size_t nitems, FILE *strea int factor_vm::safe_ftell(FILE *stream) { off_t offset; - do { + for(;;) + { if((offset = FTELL(stream)) == -1) io_error(); else break; - } while(errno == EINTR); + } return offset; } @@ -117,32 +135,35 @@ void factor_vm::safe_fseek(FILE *stream, off_t offset, int whence) critical_error("Bad value for whence",whence); } - do { + for(;;) + { if(FSEEK(stream,offset,whence) == -1) io_error(); else break; - } while(errno == EINTR); + } } void factor_vm::safe_fflush(FILE *stream) { - do { + for(;;) + { if(fflush(stream) == EOF) io_error(); else break; - } while(errno == EINTR); + } } void factor_vm::safe_fclose(FILE *stream) { - do { + for(;;) + { if(fclose(stream) == EOF) io_error(); else break; - } while(errno == EINTR); + } } void factor_vm::primitive_fopen() @@ -189,12 +210,7 @@ void factor_vm::primitive_fread() int c = safe_fread(buf.untagged() + 1,1,size,file); if(c == 0) - { - if(feof(file)) - ctx->push(false_object); - else - io_error(); - } + ctx->push(false_object); else { if(feof(file)) From 3bf5eeddf93362d332e7a18d3f21d3b7a070efa4 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 24 Feb 2010 00:51:02 -0800 Subject: [PATCH 240/713] tidy up load errors in ui.backend.x11 --- basis/ui/backend/x11/x11.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/ui/backend/x11/x11.factor b/basis/ui/backend/x11/x11.factor index ee6eb813b0..6a7a8d147f 100644 --- a/basis/ui/backend/x11/x11.factor +++ b/basis/ui/backend/x11/x11.factor @@ -329,10 +329,10 @@ M: x11-ui-backend beep ( -- ) M: x11-ui-backend system-alert From ebd2cce1bed8d3b23e9fcfd05ba6dab650302498 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 24 Feb 2010 03:32:02 -0600 Subject: [PATCH 241/713] Add some commented out unit tests to io.ports.tests that seem like they should be supported --- basis/io/ports/ports-tests.factor | 42 ++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/basis/io/ports/ports-tests.factor b/basis/io/ports/ports-tests.factor index e637999880..7d8c799017 100644 --- a/basis/io/ports/ports-tests.factor +++ b/basis/io/ports/ports-tests.factor @@ -1,6 +1,7 @@ USING: destructors io io.encodings.binary io.files io.directories io.files.temp io.ports kernel sequences math -specialized-arrays.instances.alien.c-types.int tools.test ; +specialized-arrays.instances.alien.c-types.int tools.test +specialized-arrays alien.c-types classes.struct alien ; IN: io.ports.tests ! Make sure that writing malloced storage to a file works, and @@ -20,4 +21,43 @@ IN: io.ports.tests ] with-file-reader ] unit-test +USE: multiline +/* +[ ] [ + BV{ 0 1 2 } "test.txt" temp-file binary set-file-contents +] unit-test + +[ t ] [ + "test.txt" temp-file binary file-contents + B{ 0 1 2 } = +] unit-test + +STRUCT: pt { x uint } { y uint } ; +SPECIALIZED-ARRAY: pt + +CONSTANT: pt-array-1 + pt-array{ S{ pt f 1 1 } S{ pt f 2 2 } S{ pt f 3 3 } } + +[ ] [ + pt-array-1 + "test.txt" temp-file binary set-file-contents +] unit-test + +[ t ] [ + "test.txt" temp-file binary file-contents + pt-array-1 >c-ptr sequence= +] unit-test + +[ ] [ + pt-array-1 rest-slice + "test.txt" temp-file binary set-file-contents +] unit-test + +[ t ] [ + "test.txt" temp-file binary file-contents + pt-array-1 rest-slice >c-ptr sequence= +] unit-test + +*/ + [ ] [ "test.txt" temp-file delete-file ] unit-test From 17b095a5243c0ec94acb336d06cec2890159c08c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 25 Feb 2010 04:50:31 +1300 Subject: [PATCH 242/713] Slices over specialized arrays can now be passed to C functions, written to binary output streams, and given to malloc-byte-array --- basis/alien/data/data-docs.factor | 11 +--- basis/alien/data/data.factor | 14 +++-- basis/base64/base64.factor | 4 +- basis/io/buffers/buffers-tests.factor | 5 +- basis/io/buffers/buffers.factor | 2 +- basis/io/encodings/utf32/utf32-tests.factor | 6 +-- basis/io/ports/ports-tests.factor | 54 +++---------------- basis/serialize/serialize-tests.factor | 14 ++--- .../specialized-arrays-tests.factor | 5 +- .../specialized-arrays.factor | 2 +- .../specialized-vectors.factor | 4 +- basis/ui/backend/windows/windows.factor | 2 +- .../directx/dinput/constants/constants.factor | 5 +- core/alien/alien-docs.factor | 14 +++-- core/alien/alien.factor | 30 +++++++---- core/io/files/files-tests.factor | 49 +++++++++++++++-- .../byte-array/byte-array-tests.factor | 1 + 17 files changed, 117 insertions(+), 105 deletions(-) diff --git a/basis/alien/data/data-docs.factor b/basis/alien/data/data-docs.factor index 6ab6d56bc7..4600ea6837 100644 --- a/basis/alien/data/data-docs.factor +++ b/basis/alien/data/data-docs.factor @@ -21,11 +21,6 @@ HELP: memory>byte-array { $values { "alien" c-ptr } { "len" "a non-negative integer" } { "byte-array" byte-array } } { $description "Reads " { $snippet "len" } " bytes starting from " { $snippet "base" } " and stores them in a new byte array." } ; -HELP: byte-array>memory -{ $values { "byte-array" byte-array } { "base" c-ptr } } -{ $description "Writes a byte array to memory starting from the " { $snippet "base" } " address." } -{ $warning "This word is unsafe. Improper use can corrupt memory." } ; - HELP: malloc-array { $values { "n" "a non-negative integer" } { "type" "a C type" } { "array" "a specialized array" } } { $description "Allocates an unmanaged memory block large enough to hold " { $snippet "n" } " values of a C type, then wraps the memory in a sequence object using " { $link } "." } @@ -75,9 +70,7 @@ $nl "You can unsafely copy a range of bytes from one memory location to another:" { $subsections memcpy } "You can copy a range of bytes from memory into a byte array:" -{ $subsections memory>byte-array } -"You can copy a byte array to memory unsafely:" -{ $subsections byte-array>memory } ; +{ $subsections memory>byte-array } ; ARTICLE: "c-pointers" "Passing pointers to C functions" "The following Factor objects may be passed to C function parameters with pointer types:" @@ -85,7 +78,7 @@ ARTICLE: "c-pointers" "Passing pointers to C functions" { "Instances of " { $link alien } "." } { "Instances of " { $link f } "; this is interpreted as a null pointer." } { "Instances of " { $link byte-array } "; the C function receives a pointer to the first element of the array." } - { "Any data type which defines a method on " { $link >c-ptr } " that returns an instance of one of the above. This includes " { $link "classes.struct" } " and " { $link "specialized-arrays" } "." } + { "Any data type which defines a method on " { $link >c-ptr } ". This includes " { $link "classes.struct" } " and " { $link "specialized-arrays" } "." } } "The class of primitive C pointer types:" { $subsections c-ptr } diff --git a/basis/alien/data/data.factor b/basis/alien/data/data.factor index 462bed8b76..2d572e9f13 100644 --- a/basis/alien/data/data.factor +++ b/basis/alien/data/data.factor @@ -49,7 +49,7 @@ M: word heap-size malloc ; inline : malloc-byte-array ( byte-array -- alien ) - dup byte-length [ nip malloc dup ] 2keep memcpy ; + binary-object [ nip malloc dup ] 2keep memcpy ; : memory>byte-array ( alien len -- byte-array ) [ nip (byte-array) dup ] 2keep memcpy ; @@ -63,14 +63,12 @@ M: memory-stream stream-read swap memory>byte-array ] [ [ + ] change-index drop ] 2bi ; -: byte-array>memory ( byte-array base -- ) - swap dup byte-length memcpy ; inline - M: byte-vector stream-write - [ binary-object ] dip - [ [ length + ] keep lengthen drop ] - [ '[ _ underlying>> ] 2dip memcpy ] - 3bi ; + [ dup byte-length tail-slice ] + [ [ [ byte-length ] bi@ + ] keep lengthen ] + [ drop byte-length ] + 2tri + [ >c-ptr swap >c-ptr ] dip memcpy ; M: value-type c-type-rep drop int-rep ; diff --git a/basis/base64/base64.factor b/basis/base64/base64.factor index 1a0648cef8..9a57740936 100644 --- a/basis/base64/base64.factor +++ b/basis/base64/base64.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: combinators io io.binary io.encodings.binary io.streams.byte-array kernel math namespaces -sequences strings io.crlf ; +sequences strings ; IN: base64 ERROR: malformed-base64 ; @@ -35,7 +35,7 @@ SYMBOL: column : write1-lines ( ch -- ) write1 column get [ - 1 + [ 76 = [ crlf ] when ] + 1 + [ 76 = [ B{ CHAR: \r CHAR: \n } write ] when ] [ 76 mod column set ] bi ] when* ; diff --git a/basis/io/buffers/buffers-tests.factor b/basis/io/buffers/buffers-tests.factor index 836b4d0cc8..07e783f267 100644 --- a/basis/io/buffers/buffers-tests.factor +++ b/basis/io/buffers/buffers-tests.factor @@ -4,8 +4,9 @@ kernel.private libc sequences tools.test namespaces byte-arrays strings accessors destructors ; : buffer-set ( string buffer -- ) - over >byte-array over ptr>> byte-array>memory - [ length ] dip buffer-reset ; + [ ptr>> swap >byte-array binary-object memcpy ] + [ [ length ] dip buffer-reset ] + 2bi ; : string>buffer ( string -- buffer ) dup length [ buffer-set ] keep ; diff --git a/basis/io/buffers/buffers.factor b/basis/io/buffers/buffers.factor index ce5ad2c9a0..562abad082 100644 --- a/basis/io/buffers/buffers.factor +++ b/basis/io/buffers/buffers.factor @@ -60,7 +60,7 @@ HINTS: buffer-read fixnum buffer ; HINTS: n>buffer fixnum buffer ; : >buffer ( byte-array buffer -- ) - [ buffer-end byte-array>memory ] + [ buffer-end swap binary-object memcpy ] [ [ byte-length ] dip n>buffer ] 2bi ; diff --git a/basis/io/encodings/utf32/utf32-tests.factor b/basis/io/encodings/utf32/utf32-tests.factor index 2a80e47c7b..adff0ecf4b 100644 --- a/basis/io/encodings/utf32/utf32-tests.factor +++ b/basis/io/encodings/utf32/utf32-tests.factor @@ -12,7 +12,7 @@ IN: io.encodings.utf32.tests [ { CHAR: replacement-character } ] [ B{ 0 } utf32be decode >array ] unit-test [ { } ] [ { } utf32be decode >array ] unit-test -[ { 0 0 0 CHAR: x 0 1 HEX: D1 HEX: 1E } ] [ { CHAR: x HEX: 1d11e } >string utf32be encode >array ] unit-test +[ B{ 0 0 0 CHAR: x 0 1 HEX: D1 HEX: 1E } ] [ { CHAR: x HEX: 1d11e } >string utf32be encode ] unit-test [ { CHAR: x } ] [ B{ CHAR: x 0 0 0 } utf32le decode >array ] unit-test [ { HEX: 1d11e } ] [ B{ HEX: 1e HEX: d1 1 0 } utf32le decode >array ] unit-test @@ -21,10 +21,10 @@ IN: io.encodings.utf32.tests [ { CHAR: replacement-character } ] [ B{ HEX: 1e } utf32le decode >array ] unit-test [ { } ] [ { } utf32le decode >array ] unit-test -[ { 120 0 0 0 HEX: 1e HEX: d1 1 0 } ] [ { CHAR: x HEX: 1d11e } >string utf32le encode >array ] unit-test +[ B{ 120 0 0 0 HEX: 1e HEX: d1 1 0 } ] [ { CHAR: x HEX: 1d11e } >string utf32le encode ] unit-test [ { CHAR: x } ] [ B{ HEX: ff HEX: fe 0 0 CHAR: x 0 0 0 } utf32 decode >array ] unit-test [ { CHAR: x } ] [ B{ 0 0 HEX: fe HEX: ff 0 0 0 CHAR: x } utf32 decode >array ] unit-test -[ { HEX: ff HEX: fe 0 0 120 0 0 0 HEX: 1e HEX: d1 1 0 } ] [ { CHAR: x HEX: 1d11e } >string utf32 encode >array ] unit-test +[ B{ HEX: ff HEX: fe 0 0 120 0 0 0 HEX: 1e HEX: d1 1 0 } ] [ { CHAR: x HEX: 1d11e } >string utf32 encode ] unit-test diff --git a/basis/io/ports/ports-tests.factor b/basis/io/ports/ports-tests.factor index 7d8c799017..c7af6909e1 100644 --- a/basis/io/ports/ports-tests.factor +++ b/basis/io/ports/ports-tests.factor @@ -1,7 +1,6 @@ -USING: destructors io io.encodings.binary io.files io.directories -io.files.temp io.ports kernel sequences math -specialized-arrays.instances.alien.c-types.int tools.test -specialized-arrays alien.c-types classes.struct alien ; +USING: destructors io io.directories io.encodings.binary +io.files io.files.temp kernel libc math sequences +specialized-arrays.instances.alien.c-types.int tools.test ; IN: io.ports.tests ! Make sure that writing malloced storage to a file works, and @@ -9,9 +8,11 @@ IN: io.ports.tests [ ] [ "test.txt" temp-file binary [ - 100,000 iota - 0 - 100,000 malloc-int-array &dispose [ copy ] keep write + [ + 100,000 iota + 0 + 100,000 malloc-int-array &free [ copy ] keep write + ] with-destructors ] with-file-writer ] unit-test @@ -21,43 +22,4 @@ IN: io.ports.tests ] with-file-reader ] unit-test -USE: multiline -/* -[ ] [ - BV{ 0 1 2 } "test.txt" temp-file binary set-file-contents -] unit-test - -[ t ] [ - "test.txt" temp-file binary file-contents - B{ 0 1 2 } = -] unit-test - -STRUCT: pt { x uint } { y uint } ; -SPECIALIZED-ARRAY: pt - -CONSTANT: pt-array-1 - pt-array{ S{ pt f 1 1 } S{ pt f 2 2 } S{ pt f 3 3 } } - -[ ] [ - pt-array-1 - "test.txt" temp-file binary set-file-contents -] unit-test - -[ t ] [ - "test.txt" temp-file binary file-contents - pt-array-1 >c-ptr sequence= -] unit-test - -[ ] [ - pt-array-1 rest-slice - "test.txt" temp-file binary set-file-contents -] unit-test - -[ t ] [ - "test.txt" temp-file binary file-contents - pt-array-1 rest-slice >c-ptr sequence= -] unit-test - -*/ - [ ] [ "test.txt" temp-file delete-file ] unit-test diff --git a/basis/serialize/serialize-tests.factor b/basis/serialize/serialize-tests.factor index 036356e137..9213a54004 100644 --- a/basis/serialize/serialize-tests.factor +++ b/basis/serialize/serialize-tests.factor @@ -4,7 +4,8 @@ USING: tools.test kernel serialize io io.streams.byte-array alien arrays byte-arrays bit-arrays specialized-arrays sequences math prettyprint parser classes math.constants -io.encodings.binary random assocs serialize.private alien.c-types ; +io.encodings.binary random assocs serialize.private alien.c-types +combinators.short-circuit ; SPECIALIZED-ARRAY: double IN: serialize.tests @@ -16,11 +17,12 @@ IN: serialize.tests [ t ] [ 100 [ drop - 40 [ test-serialize-cell ] all-integers? - 4 [ 40 * test-serialize-cell ] all-integers? - 4 [ 400 * test-serialize-cell ] all-integers? - 4 [ 4000 * test-serialize-cell ] all-integers? - and and and + { + [ 40 [ test-serialize-cell ] all-integers? ] + [ 4 [ 40 * test-serialize-cell ] all-integers? ] + [ 4 [ 400 * test-serialize-cell ] all-integers? ] + [ 4 [ 4000 * test-serialize-cell ] all-integers? ] + } 0&& ] all-integers? ] unit-test diff --git a/basis/specialized-arrays/specialized-arrays-tests.factor b/basis/specialized-arrays/specialized-arrays-tests.factor index c25f8ae3b1..645606edc5 100644 --- a/basis/specialized-arrays/specialized-arrays-tests.factor +++ b/basis/specialized-arrays/specialized-arrays-tests.factor @@ -1,12 +1,13 @@ IN: specialized-arrays.tests USING: tools.test alien.syntax specialized-arrays -specialized-arrays.private sequences alien.c-types accessors +specialized-arrays.private sequences alien accessors kernel arrays combinators compiler compiler.units classes.struct combinators.smart compiler.tree.debugger math libc destructors sequences.private multiline eval words vocabs namespaces assocs prettyprint alien.data math.vectors definitions compiler.test ; -FROM: alien.c-types => float ; +FROM: alien.c-types => int float bool char float ulonglong ushort uint +heap-size little-endian? ; SPECIALIZED-ARRAY: int SPECIALIZED-ARRAYS: bool ushort char uint float ulonglong ; diff --git a/basis/specialized-arrays/specialized-arrays.factor b/basis/specialized-arrays/specialized-arrays.factor index f7070c68e1..b052becfed 100644 --- a/basis/specialized-arrays/specialized-arrays.factor +++ b/basis/specialized-arrays/specialized-arrays.factor @@ -95,7 +95,7 @@ M: A resize ] [ drop ] 2bi ; inline -M: A byte-length length \ T heap-size * ; inline +M: A element-size drop \ T heap-size ; inline M: A direct-array-syntax drop \ A@ ; diff --git a/basis/specialized-vectors/specialized-vectors.factor b/basis/specialized-vectors/specialized-vectors.factor index c16fe2510d..0c0569ea9d 100644 --- a/basis/specialized-vectors/specialized-vectors.factor +++ b/basis/specialized-vectors/specialized-vectors.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008, 2009 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien alien.c-types alien.parser assocs compiler.units functors growable kernel lexer math namespaces @@ -26,7 +26,7 @@ V A vectors.functor:define-vector M: V contract 2drop ; inline -M: V byte-length length \ T heap-size * ; inline +M: V element-size drop \ T heap-size ; inline M: V pprint-delims drop \ V{ \ } ; diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index 5863d3f39d..0bf2e88468 100644 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -212,7 +212,7 @@ PRIVATE> dup win32-error=0/f dup GlobalLock dup win32-error=0/f - swapd byte-array>memory + rot binary-object memcpy dup GlobalUnlock win32-error=0/f CF_UNICODETEXT swap SetClipboardData win32-error=0/f ] with-clipboard ; diff --git a/basis/windows/directx/dinput/constants/constants.factor b/basis/windows/directx/dinput/constants/constants.factor index 26f9da00ec..ba4d750174 100644 --- a/basis/windows/directx/dinput/constants/constants.factor +++ b/basis/windows/directx/dinput/constants/constants.factor @@ -72,10 +72,7 @@ M: array array-base-type first ; call swap set-global ; inline : (malloc-guid-symbol) ( symbol guid -- ) - '[ - _ execute( -- value ) - [ byte-length malloc ] [ over byte-array>memory ] bi - ] initialize ; + '[ _ execute( -- value ) malloc-byte-array ] initialize ; : define-guid-constants ( -- ) { diff --git a/core/alien/alien-docs.factor b/core/alien/alien-docs.factor index 60c1cdaf69..99f3a2b0f4 100644 --- a/core/alien/alien-docs.factor +++ b/core/alien/alien-docs.factor @@ -1,18 +1,24 @@ USING: byte-arrays arrays help.syntax help.markup alien.syntax compiler definitions math libc eval debugger parser io io.backend system alien.accessors -alien.libraries alien.c-types quotations kernel ; +alien.libraries alien.c-types quotations kernel +sequences ; IN: alien HELP: >c-ptr -{ $values { "object" object } { "c-ptr" c-ptr } } +{ $values { "obj" object } { "c-ptr" c-ptr } } { $contract "Outputs a pointer to the binary data of this object." } ; HELP: byte-length -{ $values { "object" object } { "n" "a non-negative integer" } } +{ $values { "obj" object } { "n" "a non-negative integer" } } { $contract "Outputs the number of bytes of binary data that will be output by " { $link >c-ptr } "." } ; -{ >c-ptr byte-length } related-words +HELP: element-size +{ $values { "seq" sequence } { "n" "a non-negative integer" } } +{ $contract "Outputs the number of bytes used for each element of the sequence." } +{ $notes "If a sequence class implements " { $link element-size } " and " { $link >c-ptr } ", then instances of this sequence, as well as slices of this sequence, can be used as binary objects." } ; + +{ >c-ptr element-size byte-length } related-words HELP: alien { $class-description "The class of alien pointers. See " { $link "syntax-aliens" } " for syntax and " { $link "c-data" } " for general information." } ; diff --git a/core/alien/alien.factor b/core/alien/alien.factor index 42f48f97aa..3802147838 100644 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -1,30 +1,42 @@ ! Copyright (C) 2004, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs kernel math namespaces sequences system -kernel.private byte-arrays arrays init ; +kernel.private byte-arrays byte-vectors arrays init ; IN: alien PREDICATE: pinned-alien < alien underlying>> not ; UNION: pinned-c-ptr pinned-alien POSTPONE: f ; +GENERIC: element-size ( seq -- n ) flushable + +M: byte-array element-size drop 1 ; inline + +M: byte-vector element-size drop 1 ; inline + +M: slice element-size seq>> element-size ; inline + +M: f element-size drop 1 ; inline + +GENERIC: byte-length ( obj -- n ) flushable + +M: object byte-length [ length ] [ element-size ] bi * ; inline + GENERIC: >c-ptr ( obj -- c-ptr ) flushable M: c-ptr >c-ptr ; inline -GENERIC: byte-length ( seq -- n ) flushable - -M: byte-array byte-length length ; inline - -M: f byte-length drop 0 ; inline - -: binary-object ( obj -- c-ptr n ) - [ >c-ptr ] [ byte-length ] bi ; inline +M: slice >c-ptr + [ [ from>> ] [ element-size ] bi * ] [ seq>> >c-ptr ] bi + ; inline SLOT: underlying M: object >c-ptr underlying>> ; inline +: binary-object ( obj -- c-ptr n ) + [ >c-ptr ] [ byte-length ] bi ; inline + GENERIC: expired? ( c-ptr -- ? ) flushable M: alien expired? expired>> ; diff --git a/core/io/files/files-tests.factor b/core/io/files/files-tests.factor index cf58dbfe05..5db1822d9e 100644 --- a/core/io/files/files-tests.factor +++ b/core/io/files/files-tests.factor @@ -1,8 +1,9 @@ -USING: arrays debugger.threads destructors io io.directories -io.encodings.ascii io.encodings.binary io.encodings.string -io.encodings.8-bit.latin1 io.files io.files.private -io.files.temp io.files.unique kernel make math sequences system -threads tools.test generic.single specialized-arrays alien.c-types ; +USING: alien alien.c-types arrays classes.struct +debugger.threads destructors generic.single io io.directories +io.encodings.8-bit.latin1 io.encodings.ascii +io.encodings.binary io.encodings.string io.files +io.files.private io.files.temp io.files.unique kernel make math +sequences specialized-arrays system threads tools.test ; SPECIALIZED-ARRAY: int IN: io.files.tests @@ -80,6 +81,44 @@ IN: io.files.tests byte-array>int-array ] unit-test +[ ] [ + BV{ 0 1 2 } "test.txt" temp-file binary set-file-contents +] unit-test + +[ t ] [ + "test.txt" temp-file binary file-contents + B{ 0 1 2 } = +] unit-test + +STRUCT: pt { x uint } { y uint } ; +SPECIALIZED-ARRAY: pt + +CONSTANT: pt-array-1 + pt-array{ S{ pt f 1 1 } S{ pt f 2 2 } S{ pt f 3 3 } } + +[ ] [ + pt-array-1 + "test.txt" temp-file binary set-file-contents +] unit-test + +[ t ] [ + "test.txt" temp-file binary file-contents + pt-array-1 >c-ptr sequence= +] unit-test + +! Slices should support >c-ptr and byte-length + +[ ] [ + pt-array-1 rest-slice + "test.txt" temp-file binary set-file-contents +] unit-test + +[ t ] [ + "test.txt" temp-file binary file-contents + byte-array>pt-array + pt-array-1 rest-slice sequence= +] unit-test + ! Writing strings to binary streams should fail [ "test.txt" temp-file binary [ diff --git a/core/io/streams/byte-array/byte-array-tests.factor b/core/io/streams/byte-array/byte-array-tests.factor index dc95d454fa..46e015e576 100644 --- a/core/io/streams/byte-array/byte-array-tests.factor +++ b/core/io/streams/byte-array/byte-array-tests.factor @@ -6,6 +6,7 @@ IN: io.streams.byte-array.tests [ B{ } ] [ B{ } binary [ contents ] with-byte-reader ] unit-test [ B{ 1 2 3 } ] [ binary [ B{ 1 2 3 } write ] with-byte-writer ] unit-test +[ B{ 1 2 3 4 5 6 } ] [ binary [ B{ 1 2 3 } write B{ 4 5 6 } write ] with-byte-writer ] unit-test [ B{ 1 2 3 } ] [ { 1 2 3 } binary [ 3 read ] with-byte-reader ] unit-test [ B{ BIN: 11110101 BIN: 10111111 BIN: 10000000 BIN: 10111111 BIN: 11101111 BIN: 10000000 BIN: 10111111 BIN: 11011111 BIN: 10000000 CHAR: x } ] From d0c21a9182d11c6f3f18e30a925aff681729a605 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 25 Feb 2010 04:54:42 +1300 Subject: [PATCH 243/713] webapps.wiki: fix template --- extra/webapps/wiki/wiki-common.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/webapps/wiki/wiki-common.xml b/extra/webapps/wiki/wiki-common.xml index 6bdc449dc8..bd2b897c0e 100644 --- a/extra/webapps/wiki/wiki-common.xml +++ b/extra/webapps/wiki/wiki-common.xml @@ -15,7 +15,7 @@

- +

From e5aa02571f87e3f200724d916518fb636944dc63 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 25 Feb 2010 05:57:09 +1300 Subject: [PATCH 244/713] sequences: add suffix! to destructive sequence ops article --- core/sequences/sequences-docs.factor | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index dc26933af4..46b4dcd4ec 100644 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -1617,8 +1617,8 @@ ARTICLE: "sequences-destructive-discussion" "When to use destructive operations" } "The second reason is much weaker than the first one. In particular, many combinators (see " { $link map } ", " { $link produce } " and " { $link "namespaces-make" } ") as well as more advanced data structures (such as " { $vocab-link "persistent.vectors" } ") alleviate the need for explicit use of side effects." ; -ARTICLE: "sequences-destructive" "Destructive operations" -"Many operations have constructive and destructive variants:" +ARTICLE: "sequences-destructive" "Destructive sequence operations" +"Many operations have destructive variants that side effect an input sequence, instead of creating a new sequence:" { $table { "Constructive" "Destructive" } { { $link suffix } { $link suffix! } } @@ -1641,10 +1641,14 @@ ARTICLE: "sequences-destructive" "Destructive operations" delete-all filter! } +"Adding elements:" +{ $subsections + suffix! + append! +} "Other destructive words:" { $subsections reverse! - append! move exchange copy From 22edb2ea0d97adf46194a4c97d84d2d31946e22d Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Wed, 24 Feb 2010 13:34:24 -0600 Subject: [PATCH 245/713] Adding combine word to new-sets --- basis/new-sets/new-sets-tests.factor | 2 ++ basis/new-sets/new-sets.factor | 3 +++ 2 files changed, 5 insertions(+) diff --git a/basis/new-sets/new-sets-tests.factor b/basis/new-sets/new-sets-tests.factor index 12da3a7515..bd777618a6 100644 --- a/basis/new-sets/new-sets-tests.factor +++ b/basis/new-sets/new-sets-tests.factor @@ -38,3 +38,5 @@ IN: new-sets.tests [ { 1 2 3 } ] [ HS{ 1 2 3 } { } set-like natural-sort ] unit-test [ HS{ 1 2 3 } ] [ { 1 2 3 } fast-set ] unit-test + +[ { 1 2 3 } ] [ { { 1 } { 2 } { 1 3 } } combine ] unit-test diff --git a/basis/new-sets/new-sets.factor b/basis/new-sets/new-sets.factor index 5f42dc40af..435c245311 100644 --- a/basis/new-sets/new-sets.factor +++ b/basis/new-sets/new-sets.factor @@ -63,3 +63,6 @@ M: sequence members fast-set members ; USE: vocabs.loader "hash-sets" require + +: combine ( sets -- set ) + f [ union ] reduce ; From d853061f8fca8dd0507b96baba39d4d7360f5a7a Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 24 Feb 2010 17:00:17 -0800 Subject: [PATCH 246/713] move chipmunk to chipmunk.ffi --- extra/chipmunk/demo/demo.factor | 2 +- extra/chipmunk/{chipmunk.factor => ffi/ffi.factor} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename extra/chipmunk/{chipmunk.factor => ffi/ffi.factor} (99%) diff --git a/extra/chipmunk/demo/demo.factor b/extra/chipmunk/demo/demo.factor index 38a8689bec..b0aa7f18b4 100644 --- a/extra/chipmunk/demo/demo.factor +++ b/extra/chipmunk/demo/demo.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2010 Erik Charlebois ! See http:// factorcode.org/license.txt for BSD license. -USING: accessors chipmunk classes.struct game.worlds kernel locals +USING: accessors chipmunk.ffi classes.struct game.worlds kernel locals math method-chains opengl.gl random sequences specialized-arrays specialized-arrays.instances.alien.c-types.void* ui ui.gadgets.worlds ui.pixel-formats ; diff --git a/extra/chipmunk/chipmunk.factor b/extra/chipmunk/ffi/ffi.factor similarity index 99% rename from extra/chipmunk/chipmunk.factor rename to extra/chipmunk/ffi/ffi.factor index b24232147c..e2adf2dff7 100644 --- a/extra/chipmunk/chipmunk.factor +++ b/extra/chipmunk/ffi/ffi.factor @@ -4,7 +4,7 @@ USING: accessors alien.c-types alien.syntax classes.struct combinators combinators.short-circuit kernel math math.order sequences specialized-arrays.instances.alien.c-types.void* typed specialized-arrays locals system alien.libraries ; -IN: chipmunk +IN: chipmunk.ffi << "chipmunk" { { [ os windows? ] [ "chipmunk.dll" ] } From 7de21ca8beee1bc757eeaeb279560360d97a373c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 24 Feb 2010 18:46:02 -0800 Subject: [PATCH 247/713] fix up chipmunk.demo, add a MAIN: --- extra/chipmunk/demo/demo.factor | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/extra/chipmunk/demo/demo.factor b/extra/chipmunk/demo/demo.factor index b0aa7f18b4..c110349db5 100644 --- a/extra/chipmunk/demo/demo.factor +++ b/extra/chipmunk/demo/demo.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2010 Erik Charlebois ! See http:// factorcode.org/license.txt for BSD license. -USING: accessors chipmunk.ffi classes.struct game.worlds kernel locals -math method-chains opengl.gl random sequences specialized-arrays +USING: accessors alien chipmunk.ffi classes.struct game.worlds kernel +locals math method-chains opengl.gl random sequences specialized-arrays specialized-arrays.instances.alien.c-types.void* ui ui.gadgets.worlds ui.pixel-formats ; IN: chipmunk.demo @@ -53,7 +53,10 @@ CONSTANT: image-bitmap B{ cpBodyAlloc 1.0 NAN: 0 cpBodyInit x y cpv >>p :> body cpCircleShapeAlloc body 0.95 0 0 cpv cpCircleShapeInit - [ shape>> 0 >>e ] [ shape>> 0 >>u ] bi drop ; + dup shape>> + 0 >>e + 0 >>u + drop ; TUPLE: chipmunk-world < game-world space ; @@ -88,7 +91,7 @@ M:: chipmunk-world draw-world* ( world -- ) space arbiters>> [ num>> ] [ arr>> swap ] bi [ cpArbiter memory>struct - [ numContacts>> ] [ contacts>> swap ] bi [ + [ numContacts>> ] [ contacts>> >c-ptr swap ] bi [ p>> [ x>> ] [ y>> ] bi glVertex2f ] each ] each @@ -109,7 +112,7 @@ M:: chipmunk-world begin-game-world ( world -- ) x image-width 2 / - 0.05 0.0 1.0 uniform-random-float * + 2 * image-height 2 / y - 0.05 0.0 1.0 uniform-random-float * + 2 * make-ball :> shape - space shape body>> cpSpaceAddBody drop + space shape shape>> body>> cpSpaceAddBody drop space shape cpSpaceAddShape drop ] when ] each @@ -119,10 +122,12 @@ M:: chipmunk-world begin-game-world ( world -- ) body -1000 -10 cpv >>p drop body 400 0 cpv >>v drop - space cpCircleShapeAlloc body 8 0 0 cpv cpCircleShapeInit cpSpaceAddShape :> shape - shape - [ shape>> 0 >>e drop ] - [ shape>> 0 >>u drop ] bi ; + space cpCircleShapeAlloc [ body 8 0 0 cpv cpCircleShapeInit cpSpaceAddShape drop ] keep + :> shape + shape shape>> + 0 >>e + 0 >>u + drop ; M: chipmunk-world end-game-world space>> @@ -145,3 +150,4 @@ M: chipmunk-world end-game-world open-window ] with-ui ; +MAIN: chipmunk-demo From 433f0d1ea647fdbaa6e4badfe5f399eee2061215 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 24 Feb 2010 20:07:13 -0800 Subject: [PATCH 248/713] game.worlds: construct game-loop object before begin-game-world is called so begin-game-world can change it before the loop is started --- extra/game/worlds/worlds.factor | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/extra/game/worlds/worlds.factor b/extra/game/worlds/worlds.factor index dd9b2431c9..bf05eddc71 100644 --- a/extra/game/worlds/worlds.factor +++ b/extra/game/worlds/worlds.factor @@ -44,9 +44,8 @@ PRIVATE> M: game-world begin-world dup use-game-input?>> [ open-game-input ] when dup use-audio-engine?>> [ dup open-game-audio-engine >>audio-engine ] when - dup begin-game-world - dup [ tick-interval-micros>> ] [ ] bi [ >>game-loop ] keep start-loop - drop ; + dup [ tick-interval-micros>> ] [ ] bi + [ >>game-loop begin-game-world ] keep start-loop ; M: game-world end-world [ [ stop-loop ] when* f ] change-game-loop From 7826543d2e85f9304c00f8c02c4657b2ea9e9825 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 25 Feb 2010 20:54:41 +1300 Subject: [PATCH 249/713] sequences: add cartesian-each, cartesian-map, cartesian-product words to eliminate some duplication throughout the codebase --- basis/delegate/delegate.factor | 7 ++--- basis/images/processing/processing.factor | 2 +- basis/math/matrices/matrices-tests.factor | 3 --- basis/math/matrices/matrices.factor | 5 +--- basis/opengl/textures/textures.factor | 6 ++--- basis/ui/gadgets/grids/grids.factor | 11 ++++---- core/sequences/sequences-docs.factor | 33 +++++++++++++++++++++++ core/sequences/sequences-tests.factor | 3 +++ core/sequences/sequences.factor | 9 +++++++ extra/project-euler/004/004.factor | 2 +- extra/project-euler/027/027.factor | 2 +- extra/project-euler/029/029.factor | 2 +- extra/project-euler/032/032.factor | 12 ++++----- extra/project-euler/033/033.factor | 2 +- extra/project-euler/043/043.factor | 3 ++- extra/project-euler/056/056.factor | 2 +- extra/project-euler/081/081.factor | 4 +-- extra/project-euler/common/common.factor | 3 --- 18 files changed, 72 insertions(+), 39 deletions(-) diff --git a/basis/delegate/delegate.factor b/basis/delegate/delegate.factor index d033b7115b..662a2840a1 100644 --- a/basis/delegate/delegate.factor +++ b/basis/delegate/delegate.factor @@ -99,11 +99,8 @@ M: consultation forget* ! Protocols c @@ -126,9 +126,6 @@ IN: math.matrices : norm-gram-schmidt ( seq -- orthonormal ) gram-schmidt [ normalize ] map ; -: cross-zip ( seq1 seq2 -- seq1xseq2 ) - [ [ 2array ] with map ] curry map ; - : m^n ( m n -- n ) make-bits over first length identity-matrix [ [ dupd m. ] when [ dup m. ] dip ] reduce nip ; diff --git a/basis/opengl/textures/textures.factor b/basis/opengl/textures/textures.factor index e53383c98b..9284a151f5 100644 --- a/basis/opengl/textures/textures.factor +++ b/basis/opengl/textures/textures.factor @@ -1,9 +1,9 @@ -! Copyright (C) 2009 Slava Pestov. +! Copyright (C) 2009, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs cache colors.constants destructors kernel opengl opengl.gl opengl.capabilities combinators images images.tesselation grouping sequences math math.vectors -math.matrices generalizations fry arrays namespaces system +generalizations fry arrays namespaces system locals literals specialized-arrays ; FROM: alien.c-types => float ; SPECIALIZED-ARRAY: float @@ -354,7 +354,7 @@ TUPLE: multi-texture < disposable grid display-list loc ; : image-locs ( image-grid -- loc-grid ) [ first [ dim>> first ] map ] [ [ first dim>> second ] map ] bi [ 0 [ + ] accumulate nip ] bi@ - cross-zip flip ; + cartesian-product flip ; : ( image-grid loc -- grid ) [ dup image-locs ] dip diff --git a/basis/ui/gadgets/grids/grids.factor b/basis/ui/gadgets/grids/grids.factor index 2e964b48b6..d103ce401c 100644 --- a/basis/ui/gadgets/grids/grids.factor +++ b/basis/ui/gadgets/grids/grids.factor @@ -1,9 +1,8 @@ ! Copyright (C) 2006, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays kernel math math.order math.matrices namespaces -make sequences words io math.vectors ui.gadgets -ui.baseline-alignment columns accessors strings.tables -math.rectangles fry ; +USING: arrays kernel math math.order namespaces make sequences +words io math.vectors ui.gadgets ui.baseline-alignment columns +accessors strings.tables math.rectangles fry ; IN: ui.gadgets.grids TUPLE: grid < gadget @@ -90,7 +89,7 @@ M: grid pref-dim* grid-pref-dim ; : (compute-cell-locs) ( grid-layout -- locs ) [ accumulate-cell-xs nip ] [ accumulate-cell-ys nip ] - bi cross-zip flip ; + bi cartesian-product flip ; : adjust-for-baseline ( row-locs row-cells -- row-locs' ) align-baselines [ 0 swap 2array v+ ] 2map ; @@ -104,7 +103,7 @@ M: grid pref-dim* grid-pref-dim ; : cell-dims ( grid-layout -- dims ) dup fill?>> - [ [ column-widths>> ] [ row-heights>> ] bi cross-zip flip ] + [ [ column-widths>> ] [ row-heights>> ] bi cartesian-product flip ] [ grid>> [ [ pref-dim>> ] map ] map ] if ; diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 46b4dcd4ec..94e8e97998 100644 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -1364,6 +1364,25 @@ HELP: assert-sequence= } } ; +HELP: cartesian-each +{ $values { "seq1" sequence } { "seq1" sequence } { "quot" { $quotation "( elt1 elt2 -- )" } } } +{ $description "Applies the quotation to every possible pairing of elements from the two sequences." } ; + +HELP: cartesian-map +{ $values { "seq1" sequence } { "seq1" sequence } { "quot" { $quotation "( elt1 elt2 -- result )" } } { "newseq" "a new sequence of sequences" } } +{ $description "Applies the quotation to every possible pairing of elements from the two sequences, collecting results into a new sequence of sequences." } ; + +HELP: cartesian-product +{ $values { "seq1" sequence } { "seq1" sequence } { "newseq" "a new sequence of sequences of pairs" } } +{ $description "Outputs a sequence of all possible pairings of elements from the two sequences." } +{ $examples + { $example + "USING: prettyprint sequences ;" + "{ 1 2 } { 3 4 } cartesian-product ." + "{ { { 1 3 } { 1 4 } } { { 2 3 } { 2 4 } } }" + } +} ; + ARTICLE: "sequences-unsafe" "Unsafe sequence operations" "The " { $link nth-unsafe } " and " { $link set-nth-unsafe } " sequence protocol bypasses bounds checks for increased performance." $nl @@ -1691,6 +1710,19 @@ ARTICLE: "sequences-combinator-implementation" "Implementing sequence combinator 2selector } ; +ARTICLE: "sequences-cartesian" "Cartesian product operations" +"The cartesian product of two sequences is a sequence of all pairs where the first element of each pair is from the first sequence, and the second element of each pair is from the second sequence. The number of elements in the cartesian product is the product of the lengths of the two sequences." +$nl +"Combinators which pair every element of the first sequence with every element of the second:" +{ $subsections + cartesian-each + cartesian-map +} +"Computing the cartesian product of two sequences:" +{ $subsections + cartesian-product +} ; + ARTICLE: "sequences" "Sequence operations" "A " { $emphasis "sequence" } " is a finite, linearly-ordered collection of elements. Words for working with sequences are in the " { $vocab-link "sequences" } " vocabulary." $nl @@ -1718,6 +1750,7 @@ $nl "binary-search" "sets" "sequences-trimming" + "sequences-cartesian" "sequences.deep" } "Using sequences for looping:" diff --git a/core/sequences/sequences-tests.factor b/core/sequences/sequences-tests.factor index be1111b826..665e7a7ada 100644 --- a/core/sequences/sequences-tests.factor +++ b/core/sequences/sequences-tests.factor @@ -309,3 +309,6 @@ USE: make [ +gt+ ] [ { 0 0 0 0 } { 0 0 0 } <=> ] unit-test [ +eq+ ] [ { } { } <=> ] unit-test [ +eq+ ] [ { 1 2 3 } { 1 2 3 } <=> ] unit-test + +[ { { { 1 "a" } { 1 "b" } } { { 2 "a" } { 2 "b" } } } ] +[ { 1 2 } { "a" "b" } cartesian-product ] unit-test diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 2eafe2ceb8..9f59d98468 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -947,6 +947,15 @@ M: object sum 0 [ + ] binary-reduce ; inline : count ( seq quot -- n ) [ 1 0 ? ] compose map-sum ; inline +: cartesian-each ( seq1 seq2 quot -- ) + [ with each ] 2curry each ; inline + +: cartesian-map ( seq1 seq2 quot -- newseq ) + [ with map ] 2curry map ; inline + +: cartesian-product ( seq1 seq2 -- newseq ) + [ { } 2sequence ] cartesian-map ; + ! We hand-optimize flip to such a degree because type hints ! cannot express that an array is an array of arrays yet, and ! this word happens to be performance-critical since the compiler diff --git a/extra/project-euler/004/004.factor b/extra/project-euler/004/004.factor index fe09914d9f..1bb9ebbef5 100644 --- a/extra/project-euler/004/004.factor +++ b/extra/project-euler/004/004.factor @@ -29,7 +29,7 @@ IN: project-euler.004 PRIVATE> : euler004 ( -- answer ) - source-004 dup cartesian-product [ product ] map prune max-palindrome ; + source-004 dup [ * ] cartesian-map concat prune max-palindrome ; ! [ euler004 ] 100 ave-time ! 1164 ms ave run time - 39.35 SD (100 trials) diff --git a/extra/project-euler/027/027.factor b/extra/project-euler/027/027.factor index 0c697236aa..cd2620bc4f 100644 --- a/extra/project-euler/027/027.factor +++ b/extra/project-euler/027/027.factor @@ -47,7 +47,7 @@ IN: project-euler.027 : source-027 ( -- seq ) 1000 iota [ prime? ] filter [ dup [ neg ] map append ] keep - cartesian-product [ first2 < ] filter ; + cartesian-product concat [ first2 < ] filter ; : quadratic ( b a n -- m ) dup sq -rot * + + ; diff --git a/extra/project-euler/029/029.factor b/extra/project-euler/029/029.factor index 73773e1887..31be1a566b 100644 --- a/extra/project-euler/029/029.factor +++ b/extra/project-euler/029/029.factor @@ -29,7 +29,7 @@ IN: project-euler.029 ! -------- : euler029 ( -- answer ) - 2 100 [a,b] dup cartesian-product [ first2 ^ ] map prune length ; + 2 100 [a,b] dup [ ^ ] cartesian-map concat prune length ; ! [ euler029 ] 100 ave-time ! 704 ms ave run time - 28.07 SD (100 trials) diff --git a/extra/project-euler/032/032.factor b/extra/project-euler/032/032.factor index 8fb7a2bfaa..7def55b659 100644 --- a/extra/project-euler/032/032.factor +++ b/extra/project-euler/032/032.factor @@ -62,17 +62,17 @@ PRIVATE> string ] tri@ 3append string>number ; +: mmp ( x y -- n ) + 2dup * [ number>string ] tri@ 3append string>number ; PRIVATE> : euler032a ( -- answer ) - source-032a [ mmp ] map [ pandigital? ] filter products prune sum ; + 50 [1,b] 2000 [1,b] + [ mmp ] cartesian-map concat + [ pandigital? ] filter + products prune sum ; ! [ euler032a ] 10 ave-time ! 2624 ms ave run time - 131.91 SD (10 trials) diff --git a/extra/project-euler/033/033.factor b/extra/project-euler/033/033.factor index 780015ab77..77bae6d2f2 100644 --- a/extra/project-euler/033/033.factor +++ b/extra/project-euler/033/033.factor @@ -30,7 +30,7 @@ IN: project-euler.033 : interesting-pandigitals ( -- seq ) 17 candidates { 13 11 7 5 3 2 } [ - candidates swap cartesian-product [ overlap? ] filter clean + candidates swap cartesian-product concat + [ overlap? ] filter clean ] each [ add-missing-digit ] map ; PRIVATE> diff --git a/extra/project-euler/056/056.factor b/extra/project-euler/056/056.factor index 76c275e4dd..98e39ebd36 100644 --- a/extra/project-euler/056/056.factor +++ b/extra/project-euler/056/056.factor @@ -23,7 +23,7 @@ IN: project-euler.056 ! Through analysis, you only need to check when a and b > 90 : euler056 ( -- answer ) - 90 100 [a,b) dup cartesian-product + 90 100 [a,b) dup cartesian-product concat [ first2 ^ number>digits sum ] [ max ] map-reduce ; ! [ euler056 ] 100 ave-time diff --git a/extra/project-euler/081/081.factor b/extra/project-euler/081/081.factor index cc5e93d7a8..73936ba2ed 100644 --- a/extra/project-euler/081/081.factor +++ b/extra/project-euler/081/081.factor @@ -60,8 +60,8 @@ IN: project-euler.081 3dup minimal-path-sum-to '[ _ + ] change-matrix ; : (euler081) ( matrix -- n ) - dup first length iota dup cartesian-product - [ first2 pick update-minimal-path-sum ] each + dup first length iota dup + [ pick update-minimal-path-sum ] cartesian-each last last ; PRIVATE> diff --git a/extra/project-euler/common/common.factor b/extra/project-euler/common/common.factor index 48520ef565..895eba4deb 100644 --- a/extra/project-euler/common/common.factor +++ b/extra/project-euler/common/common.factor @@ -68,9 +68,6 @@ PRIVATE> : alpha-value ( str -- n ) >lower [ CHAR: a - 1 + ] map-sum ; -: cartesian-product ( seq1 seq2 -- seq1xseq2 ) - [ [ 2array ] with map ] curry map concat ; - : mediant ( a/c b/d -- (a+b)/(c+d) ) 2>fraction [ + ] 2bi@ / ; From 2ee4db39affc9232fbc0c77fd88b57bf216e5f09 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 25 Feb 2010 21:39:14 +1300 Subject: [PATCH 250/713] syndication: get it working with doublec's wacky atom feed --- basis/syndication/syndication.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basis/syndication/syndication.factor b/basis/syndication/syndication.factor index e30cd6826c..fe31a49265 100644 --- a/basis/syndication/syndication.factor +++ b/basis/syndication/syndication.factor @@ -70,7 +70,8 @@ TUPLE: entry title url description date ; tri ; : atom-entry-link ( tag -- url/f ) - "link" tags-named [ "rel" attr "alternate" = ] find nip + "link" tags-named + [ "rel" attr { f "alternate" } member? ] find nip dup [ "href" attr >url ] when ; : atom1.0-entry ( tag -- entry ) From 86b7ba95a8b7fee2086ce150ac8989cb12ab907f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 26 Feb 2010 00:44:48 +1300 Subject: [PATCH 251/713] sequences: fix help lint --- core/sequences/sequences-docs.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 94e8e97998..d40796a4f6 100644 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -1365,15 +1365,15 @@ HELP: assert-sequence= } ; HELP: cartesian-each -{ $values { "seq1" sequence } { "seq1" sequence } { "quot" { $quotation "( elt1 elt2 -- )" } } } +{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( elt1 elt2 -- )" } } } { $description "Applies the quotation to every possible pairing of elements from the two sequences." } ; HELP: cartesian-map -{ $values { "seq1" sequence } { "seq1" sequence } { "quot" { $quotation "( elt1 elt2 -- result )" } } { "newseq" "a new sequence of sequences" } } +{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( elt1 elt2 -- result )" } } { "newseq" "a new sequence of sequences" } } { $description "Applies the quotation to every possible pairing of elements from the two sequences, collecting results into a new sequence of sequences." } ; HELP: cartesian-product -{ $values { "seq1" sequence } { "seq1" sequence } { "newseq" "a new sequence of sequences of pairs" } } +{ $values { "seq1" sequence } { "seq2" sequence } { "newseq" "a new sequence of sequences of pairs" } } { $description "Outputs a sequence of all possible pairings of elements from the two sequences." } { $examples { $example From 7548e57b5bbccf1d4c5a74ac6b21ff34cf6be347 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Thu, 25 Feb 2010 08:15:53 -0800 Subject: [PATCH 252/713] Add perp and angle-between words for vectors. Fix bug in cross product and add unit tests. --- basis/math/matrices/matrices-tests.factor | 3 ++- basis/math/matrices/matrices.factor | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/basis/math/matrices/matrices-tests.factor b/basis/math/matrices/matrices-tests.factor index a22f6cc978..b827741209 100644 --- a/basis/math/matrices/matrices-tests.factor +++ b/basis/math/matrices/matrices-tests.factor @@ -99,9 +99,10 @@ USING: math.matrices math.vectors tools.test math ; m. ] unit-test -[ { 0 0 -1 } ] [ { 1 0 0 } { 0 1 0 } cross ] unit-test +[ { 0 0 1 } ] [ { 1 0 0 } { 0 1 0 } cross ] unit-test [ { 1 0 0 } ] [ { 0 1 0 } { 0 0 1 } cross ] unit-test [ { 0 1 0 } ] [ { 0 0 1 } { 1 0 0 } cross ] unit-test +[ { 0.0 -0.707 0.707 } ] [ { 1.0 0.0 0.0 } { 0.0 0.707 0.707 } cross ] unit-test [ { 1 0 0 } ] [ { 1 1 0 } { 1 0 0 } proj ] unit-test diff --git a/basis/math/matrices/matrices.factor b/basis/math/matrices/matrices.factor index 2a1a217c2e..216d2c31bb 100644 --- a/basis/math/matrices/matrices.factor +++ b/basis/math/matrices/matrices.factor @@ -111,12 +111,18 @@ IN: math.matrices : mnorm ( m -- n ) dup mmax abs m/n ; : cross ( vec1 vec2 -- vec3 ) - [ [ { 1 2 1 } vshuffle ] [ { 2 0 0 } vshuffle ] bi* v* ] - [ [ { 2 0 0 } vshuffle ] [ { 1 2 1 } vshuffle ] bi* v* ] 2bi v- ; inline + [ [ { 1 2 0 } vshuffle ] [ { 2 0 1 } vshuffle ] bi* v* ] + [ [ { 2 0 1 } vshuffle ] [ { 1 2 0 } vshuffle ] bi* v* ] 2bi v- ; inline : proj ( v u -- w ) [ [ v. ] [ norm-sq ] bi / ] keep n*v ; +: perp ( v u -- w ) + dupd proj v- ; + +: angle-between ( v u -- a ) + [ normalize ] bi@ v. acos ; + : (gram-schmidt) ( v seq -- newseq ) [ dupd proj v- ] each ; From f2999ce778eaeb7735e9bba0e1533cc0e1ab742b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 25 Feb 2010 11:52:21 -0800 Subject: [PATCH 253/713] classes.struct: raise an error in STRUCT: if there are duplicate slot names --- basis/classes/struct/struct-tests.factor | 18 +++++++++++++----- basis/classes/struct/struct.factor | 3 ++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/basis/classes/struct/struct-tests.factor b/basis/classes/struct/struct-tests.factor index c94ef48f4c..dafd31efde 100644 --- a/basis/classes/struct/struct-tests.factor +++ b/basis/classes/struct/struct-tests.factor @@ -1,10 +1,10 @@ ! (c)Joe Groff bsd license USING: accessors alien alien.c-types alien.data alien.syntax ascii -assocs byte-arrays classes.struct classes.tuple.private classes.tuple -combinators compiler.tree.debugger compiler.units destructors -io.encodings.utf8 io.pathnames io.streams.string kernel libc -literals math mirrors namespaces prettyprint -prettyprint.config see sequences specialized-arrays system +assocs byte-arrays classes.struct classes.tuple.parser +classes.tuple.private classes.tuple combinators compiler.tree.debugger +compiler.units destructors io.encodings.utf8 io.pathnames +io.streams.string kernel libc literals math mirrors namespaces +prettyprint prettyprint.config see sequences specialized-arrays system tools.test parser lexer eval layouts generic.single classes ; FROM: math => float ; QUALIFIED-WITH: alien.c-types c @@ -334,6 +334,14 @@ STRUCT: struct-that's-a-word { x int } ; "struct-class-test-1" parse-stream ] [ error>> error>> unexpected-eof? ] must-fail-with +[ + "USING: alien.c-types classes.struct ; IN: classes.struct.tests STRUCT: struct-test-duplicate-slots { x uint } { x uint } ;" eval( -- ) +] [ error>> duplicate-slot-names? ] must-fail-with + +[ + "USING: alien.c-types classes.struct ; IN: classes.struct.tests STRUCT: struct-test-duplicate-slots { x uint } { x float } ;" eval( -- ) +] [ error>> duplicate-slot-names? ] must-fail-with + ! S{ with non-struct type [ "USE: classes.struct IN: classes.struct.tests TUPLE: not-a-struct ; S{ not-a-struct }" diff --git a/basis/classes/struct/struct.factor b/basis/classes/struct/struct.factor index a3b198bd94..79dea73d8c 100644 --- a/basis/classes/struct/struct.factor +++ b/basis/classes/struct/struct.factor @@ -363,7 +363,8 @@ PRIVATE> } case ; : parse-struct-definition ( -- class slots ) - CREATE-CLASS 8 [ parse-struct-slots ] [ ] while >array ; + CREATE-CLASS 8 [ parse-struct-slots ] [ ] while >array + dup [ name>> ] map check-duplicate-slots ; PRIVATE> SYNTAX: STRUCT: From 31b77781aef97d08431a99829f62c6f393acc9b0 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 25 Feb 2010 14:36:12 -0600 Subject: [PATCH 254/713] Add more user32 bindings --- basis/windows/user32/user32.factor | 98 ++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 6 deletions(-) diff --git a/basis/windows/user32/user32.factor b/basis/windows/user32/user32.factor index 9908bb1f1b..b9d5cc95c4 100644 --- a/basis/windows/user32/user32.factor +++ b/basis/windows/user32/user32.factor @@ -927,6 +927,87 @@ STRUCT: RAWINPUTDEVICELIST { dwType DWORD } ; TYPEDEF: RAWINPUTDEVICELIST* PRAWINPUTDEVICELIST +CONSTANT: CCHFORMNAME 32 + +CONSTANT: CDS_UPDATEREGISTRY HEX: 00000001 +CONSTANT: CDS_TEST HEX: 00000002 +CONSTANT: CDS_FULLSCREEN HEX: 00000004 +CONSTANT: CDS_GLOBAL HEX: 00000008 +CONSTANT: CDS_SET_PRIMARY HEX: 00000010 +CONSTANT: CDS_RESET HEX: 40000000 +CONSTANT: CDS_SETRECT HEX: 20000000 +CONSTANT: CDS_NORESET HEX: 10000000 + +CONSTANT: DISP_CHANGE_SUCCESSFUL 0 +CONSTANT: DISP_CHANGE_RESTART 1 +CONSTANT: DISP_CHANGE_FAILED -1 +CONSTANT: DISP_CHANGE_BADMODE -2 +CONSTANT: DISP_CHANGE_NOTUPDATED -3 +CONSTANT: DISP_CHANGE_BADFLAGS -4 +CONSTANT: DISP_CHANGE_BADPARAM -5 + + + +STRUCT: DEVMODE + { dmDeviceName TCHAR[CCHDEVICENAME] } + { dmSpecVersion WORD } + { dmDriverVersion WORD } + { dmSize WORD } + { dmDriverExtra WORD } + { dmFields DWORD } + + { dmOrientation short } + { dmPaperSize short } + { dmPaperLength short } + { dmPaperWidth short } + { dmScale short } + { dmCopies short } + { dmDefaultSource short } + { dmPrintQuality short } + + { dmColor short } + { dmDuplex short } + { dmYResolution short } + { dmTTOption short } + { dmCollate short } + { dmFormName TCHAR[CCHFORMNAME] } + { dmLogPixels WORD } + { dmBitsPerPel DWORD } + { dmPelsWidth DWORD } + { dmPelsHeight DWORD } + { dmDisplayFlags DWORD } + { dmDisplayFrequency DWORD } + { dmiCMMethod DWORD } + { dmICMIntent DWORD } + + { dmMediaType DWORD } + { dmDitherType DWORD } + { dmReserved1 DWORD } + { dmReserved2 DWORD } + { dmPanningWidth DWORD } ; + +! union { DWORD dmDisplayFlags; DWORD dmNup; } ; + ! union { + ! struct { + ! short dmOrientation; + ! short dmPaperSize; + ! short dmPaperLength; + ! short dmPaperWidth; + ! short dmScale; + ! short dmCopies; + ! short dmDefaultSource; + ! short dmPrintQuality; + ! } ; + ! struct { + ! POINTL dmPosition; + ! DWORD dmDisplayOrientation; + ! DWORD dmDisplayFixedOutput; + ! } ; + ! } ; + +TYPEDEF: DEVMODE* PDEVMODE +TYPEDEF: DEVMODE* LPDEVMODE + LIBRARY: user32 FUNCTION: HKL ActivateKeyboardLayout ( HKL hkl, UINT Flags ) ; @@ -965,10 +1046,10 @@ FUNCTION: HDC BeginPaint ( HWND hwnd, LPPAINTSTRUCT lpPaint ) ; ! FUNCTION: CascadeChildWindows ! FUNCTION: CascadeWindows ! FUNCTION: ChangeClipboardChain -! FUNCTION: ChangeDisplaySettingsA -! FUNCTION: ChangeDisplaySettingsExA -! FUNCTION: ChangeDisplaySettingsExW -! FUNCTION: ChangeDisplaySettingsW +FUNCTION: LONG ChangeDisplaySettingsExW ( LPCTSTR lpszDeviceName, DEVMODE *lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam ) ; +FUNCTION: LONG ChangeDisplaySettingsW ( DEVMODE *lpDevMode, DWORD dwFlags ) ; +ALIAS: ChangeDisplaySettingsEx ChangeDisplaySettingsExW +ALIAS: ChangeDisplaySettings ChangeDisplaySettingsW ! FUNCTION: ChangeMenuA ! FUNCTION: ChangeMenuW ! FUNCTION: CharLowerA @@ -1173,7 +1254,8 @@ FUNCTION: UINT EnumClipboardFormats ( UINT format ) ; ! FUNCTION: EnumDisplaySettingsA ! FUNCTION: EnumDisplaySettingsExA ! FUNCTION: EnumDisplaySettingsExW -! FUNCTION: EnumDisplaySettingsW +FUNCTION: BOOL EnumDisplaySettingsW ( LPCTSTR lpszDeviceName, DWORD iModeNum, DEVMODE *lpDevMode ) ; +ALIAS: EnumDisplaySettings EnumDisplaySettingsW ! FUNCTION: EnumPropsA ! FUNCTION: EnumPropsExA ! FUNCTION: EnumPropsExW @@ -1236,7 +1318,7 @@ FUNCTION: DWORD GetClipboardSequenceNumber ( ) ; ! FUNCTION: GetCursorPos FUNCTION: HDC GetDC ( HWND hWnd ) ; FUNCTION: HDC GetDCEx ( HWND hWnd, HRGN hrgnClip, DWORD flags ) ; -! FUNCTION: GetDesktopWindow +FUNCTION: HWND GetDesktopWindow ( ) ; ! FUNCTION: GetDialogBaseUnits ! FUNCTION: GetDlgCtrlID ! FUNCTION: GetDlgItem @@ -1345,6 +1427,8 @@ FUNCTION: HWND GetWindow ( HWND hWnd, UINT uCmd ) ; ! FUNCTION: GetWindowLongW FUNCTION: LONG_PTR GetWindowLongW ( HANDLE hWnd, int index ) ; ALIAS: GetWindowLong GetWindowLongW + +FUNCTION: LONG_PTR GetWindowLongPtr ( HWND hWnd, int nIndex ) ; ! FUNCTION: GetWindowModuleFileName ! FUNCTION: GetWindowModuleFileNameA ! FUNCTION: GetWindowModuleFileNameW @@ -1692,6 +1776,8 @@ ALIAS: SetWindowLong SetWindowLongW ! FUNCTION: SetWindowPlacement FUNCTION: BOOL SetWindowPos ( HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags ) ; +FUNCTION: LONG_PTR SetWindowLongPtr ( HWND hWnd, int nIndex, LONG_PTR dwNewLong ) ; + : HWND_BOTTOM ( -- alien ) 1 ; : HWND_NOTOPMOST ( -- alien ) -2 ; CONSTANT: HWND_TOP f From 6655002629fdfcb2bcd610224769198f83c14d7b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 25 Feb 2010 12:55:31 -0800 Subject: [PATCH 255/713] remove repeated "pad" slots from x11.xlib structs --- basis/x11/xlib/xlib.factor | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/basis/x11/xlib/xlib.factor b/basis/x11/xlib/xlib.factor index de01d509dd..e86bb5e8c3 100644 --- a/basis/x11/xlib/xlib.factor +++ b/basis/x11/xlib/xlib.factor @@ -1010,14 +1010,7 @@ STRUCT: XKeymapEvent { send_event Bool } { display Display* } { window Window } -{ pad int } -{ pad int } -{ pad int } -{ pad int } -{ pad int } -{ pad int } -{ pad int } -{ pad int } ; +{ pad int[8] } ; UNION-STRUCT: XEvent { int int } From 1bb27b8a21382a5d375e1deb4325fceb63507038 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 25 Feb 2010 15:13:06 -0800 Subject: [PATCH 256/713] deploy chipmunk lib --- extra/chipmunk/ffi/ffi.factor | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/extra/chipmunk/ffi/ffi.factor b/extra/chipmunk/ffi/ffi.factor index e2adf2dff7..0142b57a77 100644 --- a/extra/chipmunk/ffi/ffi.factor +++ b/extra/chipmunk/ffi/ffi.factor @@ -2,15 +2,19 @@ ! See http:// factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.syntax classes.struct combinators combinators.short-circuit kernel math math.order sequences -specialized-arrays.instances.alien.c-types.void* typed -specialized-arrays locals system alien.libraries ; +typed specialized-arrays locals system alien.libraries ; +SPECIALIZED-ARRAY: void* IN: chipmunk.ffi -<< "chipmunk" { - { [ os windows? ] [ "chipmunk.dll" ] } - { [ os macosx? ] [ "libchipmunk.dylib" ] } - { [ os unix? ] [ "libchipmunk.so" ] } - } cond "cdecl" add-library >> +<< +"chipmunk" { + { [ os windows? ] [ "chipmunk.dll" ] } + { [ os macosx? ] [ "libchipmunk.dylib" ] } + { [ os unix? ] [ "libchipmunk.so" ] } +} cond "cdecl" add-library + +"chipmunk" deploy-library +>> LIBRARY: chipmunk ! chipmunk_types.h From 4358edcae79d7bbb425da8933a60b436a0a11254 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 25 Feb 2010 16:39:30 -0800 Subject: [PATCH 257/713] windows.com: typedef interface word to void* immediately so that self-referential pointers in the interface definition parse properly. fix a bug where pointer return values for interface methods couldn't parse --- basis/windows/com/com-tests.factor | 3 +++ basis/windows/com/syntax/syntax.factor | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/basis/windows/com/com-tests.factor b/basis/windows/com/com-tests.factor index f0b4eadb9f..fdc48adfbe 100644 --- a/basis/windows/com/com-tests.factor +++ b/basis/windows/com/com-tests.factor @@ -16,6 +16,9 @@ COM-INTERFACE: IUnrelated IUnknown {b06ac3f4-30e4-406b-a7cd-c29cead4552c} int xPlus ( int y ) int xMulAdd ( int mul, int add ) ; +COM-INTERFACE: ISelfReferential IUnknown {d4f45bf8-f720-4701-a09d-e8e341981121} + ISelfReferential* selfReference ( ) ; + { GUID: {216fb341-0eb2-44b1-8edb-60b76e353abc} } [ ISimple-iid ] unit-test { GUID: {9620ecec-8438-423b-bb14-86f835aa40dd} } [ IInherited-iid ] unit-test { GUID: {00000000-0000-0000-C000-000000000046} } [ IUnknown-iid ] unit-test diff --git a/basis/windows/com/syntax/syntax.factor b/basis/windows/com/syntax/syntax.factor index 7e93a6e9f8..5230d9497e 100644 --- a/basis/windows/com/syntax/syntax.factor +++ b/basis/windows/com/syntax/syntax.factor @@ -3,6 +3,7 @@ effects kernel windows.ole32 parser lexer splitting grouping sequences namespaces assocs quotations generalizations accessors words macros alien.syntax fry arrays layouts math classes.struct windows.kernel32 ; +FROM: alien.parser.private => return-type-name ; IN: windows.com.syntax > 1array ] if ] bi* + [ dup void? [ drop { } ] [ return-type-name 1array ] if ] bi* ; : (define-word-for-function) ( function interface n -- ) @@ -83,17 +84,16 @@ ERROR: no-com-interface interface ; : define-words-for-com-interface ( definition -- ) [ [ (iid-word) ] [ iid>> 1quotation ] bi (( -- iid )) define-declared ] - [ word>> void* swap typedef ] [ dup family-tree-functions [ (define-word-for-function) ] with each-index - ] - tri ; + ] bi ; PRIVATE> SYNTAX: COM-INTERFACE: CREATE-C-TYPE + void* over typedef scan-object find-com-interface-definition scan string>guid parse-com-functions From cebabdc32382998595492824753dbfa6555cce9c Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Thu, 25 Feb 2010 08:15:53 -0800 Subject: [PATCH 258/713] Add perp and angle-between words for vectors. Fix bug in cross product and add unit tests. --- basis/math/matrices/matrices-tests.factor | 3 ++- basis/math/matrices/matrices.factor | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/basis/math/matrices/matrices-tests.factor b/basis/math/matrices/matrices-tests.factor index a22f6cc978..b827741209 100644 --- a/basis/math/matrices/matrices-tests.factor +++ b/basis/math/matrices/matrices-tests.factor @@ -99,9 +99,10 @@ USING: math.matrices math.vectors tools.test math ; m. ] unit-test -[ { 0 0 -1 } ] [ { 1 0 0 } { 0 1 0 } cross ] unit-test +[ { 0 0 1 } ] [ { 1 0 0 } { 0 1 0 } cross ] unit-test [ { 1 0 0 } ] [ { 0 1 0 } { 0 0 1 } cross ] unit-test [ { 0 1 0 } ] [ { 0 0 1 } { 1 0 0 } cross ] unit-test +[ { 0.0 -0.707 0.707 } ] [ { 1.0 0.0 0.0 } { 0.0 0.707 0.707 } cross ] unit-test [ { 1 0 0 } ] [ { 1 1 0 } { 1 0 0 } proj ] unit-test diff --git a/basis/math/matrices/matrices.factor b/basis/math/matrices/matrices.factor index 2a1a217c2e..216d2c31bb 100644 --- a/basis/math/matrices/matrices.factor +++ b/basis/math/matrices/matrices.factor @@ -111,12 +111,18 @@ IN: math.matrices : mnorm ( m -- n ) dup mmax abs m/n ; : cross ( vec1 vec2 -- vec3 ) - [ [ { 1 2 1 } vshuffle ] [ { 2 0 0 } vshuffle ] bi* v* ] - [ [ { 2 0 0 } vshuffle ] [ { 1 2 1 } vshuffle ] bi* v* ] 2bi v- ; inline + [ [ { 1 2 0 } vshuffle ] [ { 2 0 1 } vshuffle ] bi* v* ] + [ [ { 2 0 1 } vshuffle ] [ { 1 2 0 } vshuffle ] bi* v* ] 2bi v- ; inline : proj ( v u -- w ) [ [ v. ] [ norm-sq ] bi / ] keep n*v ; +: perp ( v u -- w ) + dupd proj v- ; + +: angle-between ( v u -- a ) + [ normalize ] bi@ v. acos ; + : (gram-schmidt) ( v seq -- newseq ) [ dupd proj v- ] each ; From d898ee86b68ae36a896b65b7b3492f1318cdb25d Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 25 Feb 2010 17:05:03 -0800 Subject: [PATCH 259/713] grouping: add circular clumps (e.g. { 1 2 3 4 } 3 circular-clump => { { 1 2 3 } { 2 3 4 } { 3 4 1 } { 4 1 2 } } --- basis/grouping/grouping-docs.factor | 70 ++++++++++++++++++++++++---- basis/grouping/grouping-tests.factor | 9 ++++ basis/grouping/grouping.factor | 43 ++++++++++++++++- 3 files changed, 111 insertions(+), 11 deletions(-) diff --git a/basis/grouping/grouping-docs.factor b/basis/grouping/grouping-docs.factor index 2c2fee1d70..0c9db38f4b 100644 --- a/basis/grouping/grouping-docs.factor +++ b/basis/grouping/grouping-docs.factor @@ -8,22 +8,48 @@ ARTICLE: "grouping" "Groups and clumps" { $subsections groups } "Splitting a sequence into overlapping, fixed-length subsequences:" { $subsections clump } +"Splitting a sequence into overlapping, fixed-length subsequences, wrapping around the end of the sequence:" +{ $subsections circular-clump } "A virtual sequence for splitting a sequence into overlapping, fixed-length subsequences:" { $subsections clumps } +"A virtual sequence for splitting a sequence into overlapping, fixed-length subsequences:" +{ $subsections circular-clumps } "The difference can be summarized as the following:" { $list { "With groups, the subsequences form the original sequence when concatenated:" + { $unchecked-example + "USING: grouping ;" + "{ 1 2 3 4 } 2 group ." "{ { 1 2 } { 3 4 } }" + } { $unchecked-example "USING: grouping ;" "{ 1 2 3 4 } dup" "2 concat sequence= ." "t" } } { "With clumps, collecting the first element of each subsequence but the last one, together with the last subseqence, yields the original sequence:" + { $unchecked-example + "USING: grouping ;" + "{ 1 2 3 4 } 2 clump ." "{ { 1 2 } { 2 3 } { 3 4 } }" + } { $unchecked-example "USING: grouping ;" "{ 1 2 3 4 } dup" "2 unclip-last [ [ first ] map ] dip append sequence= ." "t" } } + { "With circular clumps, collecting the first element of each subsequence yields the original sequence. Collecting the " { $snippet "n" } "th element of each subsequence would rotate the original sequence " { $snippet "n" } " elements rightward:" + { $unchecked-example + "USING: grouping ;" + "{ 1 2 3 4 } 2 circular-clump ." "{ { 1 2 } { 2 3 } { 3 4 } { 4 1 } }" + } + { $unchecked-example + "USING: grouping ;" + "{ 1 2 3 4 } dup" "2 [ first ] map sequence= ." "t" + } + { $unchecked-example + "USING: grouping ;" + "{ 1 2 3 4 } dup" "2 [ second ] { } map-as ." "{ 2 3 4 1 }" + } + } } $nl "A combinator built using clumps:" @@ -79,18 +105,31 @@ HELP: } ; HELP: clumps -{ $class-description "Instances are virtual sequences whose elements are overlapping fixed-length subsequences o an underlying sequence. Clumps are mutable and resizable if the underlying sequence is mutable and resizable, respectively." +{ $class-description "Instances are virtual sequences whose elements are overlapping fixed-length subsequences of an underlying sequence. Clumps are mutable and resizable if the underlying sequence is mutable and resizable, respectively." $nl "New clumps are created by calling " { $link } " and " { $link } "." } ; +HELP: circular-clumps +{ $class-description "Instances are virtual sequences whose elements are overlapping fixed-length subsequences of an underlying sequence, beginning with every element in the original sequence and wrapping around its end. Circular clumps are mutable and resizable if the underlying sequence is mutable and resizable, respectively." +$nl +"New clumps are created by calling " { $link } " and " { $link } "." } ; + HELP: clump { $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "array" "a sequence of sequences" } } { $description "Splits the sequence into overlapping clumps of " { $snippet "n" } " elements and collects the clumps into a new array." } -{ $errors "Throws an error if " { $snippet "n" } " is smaller than the length of the sequence." } +{ $errors "Throws an error if " { $snippet "n" } " is larger than the length of the sequence." } { $examples { $example "USING: grouping prettyprint ;" "{ 3 1 3 3 7 } 2 clump ." "{ { 3 1 } { 1 3 } { 3 3 } { 3 7 } }" } } ; +HELP: circular-clump +{ $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "array" "a sequence of sequences" } } +{ $description "Splits the sequence into overlapping clumps of " { $snippet "n" } " elements, wrapping around the end of the sequence, and collects the clumps into a new array." } +{ $errors "Throws an error if " { $snippet "n" } " is larger than the length of the sequence." } +{ $examples + { $example "USING: grouping prettyprint ;" "{ 3 1 3 3 7 } 2 circular-clump ." "{ { 3 1 } { 1 3 } { 3 3 } { 3 7 } { 7 3 } }" } +} ; + HELP: { $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "clumps" clumps } } { $description "Outputs a virtual sequence whose elements are overlapping subsequences of " { $snippet "n" } " elements from the underlying sequence." } @@ -111,24 +150,35 @@ HELP: } } ; -HELP: +HELP: { $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "clumps" clumps } } -{ $description "Outputs a virtual sequence whose elements are overlapping slices of " { $snippet "n" } " elements from the underlying sequence." } +{ $description "Outputs a virtual sequence whose elements are overlapping subsequences of " { $snippet "n" } " elements from the underlying sequence, starting with each of its elements and wrapping around the end of the sequence." } { $examples { $example "USING: kernel sequences grouping prettyprint ;" - "{ 1 2 3 4 5 6 } 3 second ." - "T{ slice { from 1 } { to 4 } { seq { 1 2 3 4 5 6 } } }" + "{ 1 2 3 4 } 3 third ." + "{ 3 4 1 }" } } ; -{ clumps groups } related-words +HELP: +{ $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "clumps" clumps } } +{ $description "Outputs a virtual sequence whose elements are overlapping slices of " { $snippet "n" } " elements from the underlying sequence, starting with each of its elements and wrapping around the end of the sequence." } +{ $examples + { $example + "USING: arrays kernel sequences grouping prettyprint ;" + "{ 1 2 3 4 } 3 third >array ." + "{ 3 4 1 }" + } +} ; -{ clump group } related-words +{ clumps circular-clumps groups } related-words -{ } related-words +{ clump circular-clump group } related-words -{ } related-words +{ } related-words + +{ } related-words HELP: monotonic? { $values { "seq" sequence } { "quot" { $quotation "( elt elt -- ? )" } } { "?" "a boolean" } } diff --git a/basis/grouping/grouping-tests.factor b/basis/grouping/grouping-tests.factor index 60500558a7..9340b322e2 100644 --- a/basis/grouping/grouping-tests.factor +++ b/basis/grouping/grouping-tests.factor @@ -17,6 +17,15 @@ IN: grouping.tests [ 1 ] [ { 1 2 } 2 length ] unit-test [ 2 ] [ { 1 2 3 } 2 length ] unit-test +[ { } 2 length ] must-fail +[ { 1 } 2 length ] must-fail + +[ 2 ] [ { 1 2 } 2 length ] unit-test +[ 3 ] [ { 1 2 3 } 2 length ] unit-test + +[ { { 1 2 } { 2 1 } } ] [ { 1 2 } 2 circular-clump ] unit-test +[ { { 1 2 } { 2 3 } { 3 1 } } ] [ { 1 2 3 } 2 circular-clump ] unit-test + [ 1 ] [ V{ } 2 0 over set-length seq>> length ] unit-test [ 2 ] [ V{ } 2 1 over set-length seq>> length ] unit-test [ 3 ] [ V{ } 2 2 over set-length seq>> length ] unit-test diff --git a/basis/grouping/grouping.factor b/basis/grouping/grouping.factor index 4ee0d0c385..0dced6ad9d 100644 --- a/basis/grouping/grouping.factor +++ b/basis/grouping/grouping.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel math math.order strings arrays vectors sequences -sequences.private accessors fry ; +sequences.private accessors fry combinators.short-circuit ; IN: grouping = [ - ] [ drop ] if ; inline + +: check-circular-clumps ( seq n -- seq n ) + 2dup { [ nip 0 <= ] [ swap length > ] } 2|| + [ "Invalid clump size" throw ] when ; inline + PRIVATE> TUPLE: groups < chunking-seq ; @@ -106,3 +113,37 @@ INSTANCE: sliced-clumps abstract-clumps : all-equal? ( seq -- ? ) [ = ] monotonic? ; : all-eq? ( seq -- ? ) [ eq? ] monotonic? ; + +TUPLE: circular-slice < slice ; +M: circular-slice virtual@ + [ from>> + ] [ seq>> ] bi [ length slice-mod ] keep ; inline + +C: circular-slice + +TUPLE: sliced-circular-clumps < chunking-seq ; +INSTANCE: sliced-circular-clumps sequence + +M: sliced-circular-clumps length + seq>> length ; inline + +M: sliced-circular-clumps nth + [ n>> over + ] [ seq>> ] bi ; inline + +: ( seq n -- clumps ) + check-circular-clumps sliced-circular-clumps boa ; inline + +TUPLE: circular-clumps < chunking-seq ; +INSTANCE: circular-clumps sequence + +M: circular-clumps length + seq>> length ; inline + +M: circular-clumps nth + [ n>> over + ] [ seq>> ] bi [ ] [ like ] bi ; inline + +: ( seq n -- clumps ) + check-circular-clumps circular-clumps boa ; inline + +: circular-clump ( seq n -- array ) + { } like ; inline + From 889fb74b8fb7af2cb57733176e1eb10baa86f4d4 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Thu, 25 Feb 2010 18:50:05 -0800 Subject: [PATCH 260/713] Fix windows.directx compile errors --- basis/windows/directx/d2d1/d2d1.factor | 3 +++ basis/windows/directx/d3d10/d3d10.factor | 1 + .../windows/directx/d3d10effect/d3d10effect.factor | 2 +- basis/windows/directx/d3d10misc/d3d10misc.factor | 2 +- .../windows/directx/d3d10shader/d3d10shader.factor | 5 +++-- basis/windows/directx/d3d11/d3d11.factor | 3 +++ basis/windows/directx/d3d9/d3d9.factor | 13 +++++++++++++ .../windows/directx/d3dx10async/d3dx10async.factor | 5 +++-- .../windows/directx/d3dx11async/d3dx11async.factor | 6 +++--- basis/windows/directx/d3dx11tex/d3dx11tex.factor | 6 +++--- basis/windows/directx/dxgi/dxgi.factor | 7 ++++--- basis/windows/directx/xapofx/xapofx.factor | 4 ++-- basis/windows/directx/xaudio2/xaudio2.factor | 3 +++ 13 files changed, 43 insertions(+), 17 deletions(-) diff --git a/basis/windows/directx/d2d1/d2d1.factor b/basis/windows/directx/d2d1/d2d1.factor index cf9e5a3a98..4a8b44f63d 100644 --- a/basis/windows/directx/d2d1/d2d1.factor +++ b/basis/windows/directx/d2d1/d2d1.factor @@ -303,6 +303,9 @@ TYPEDEF: int D2D1_FACTORY_TYPE STRUCT: D2D1_FACTORY_OPTIONS { debugLevel D2D1_DEBUG_LEVEL } ; +C-TYPE: ID2D1Factory +C-TYPE: ID2D1BitmapRenderTarget + COM-INTERFACE: ID2D1Resource IUnknown {2cd90691-12e2-11dc-9fed-001143a055f9} void GetFactory ( ID2D1Factory** factory ) ; diff --git a/basis/windows/directx/d3d10/d3d10.factor b/basis/windows/directx/d3d10/d3d10.factor index 561aa47acd..4f23d41218 100644 --- a/basis/windows/directx/d3d10/d3d10.factor +++ b/basis/windows/directx/d3d10/d3d10.factor @@ -382,6 +382,7 @@ STRUCT: D3D10_BOX { bottom UINT } { back UINT } ; +C-TYPE: ID3D10Device COM-INTERFACE: ID3D10DeviceChild IUnknown {9B7E4C00-342C-4106-A19F-4F2704F689F0} void GetDevice ( ID3D10Device** ppDevice ) HRESULT GetPrivateData ( LPGUID guid, UINT* pDataSize, void* pData ) diff --git a/basis/windows/directx/d3d10effect/d3d10effect.factor b/basis/windows/directx/d3d10effect/d3d10effect.factor index 1d809b3862..873f8e26e8 100644 --- a/basis/windows/directx/d3d10effect/d3d10effect.factor +++ b/basis/windows/directx/d3d10effect/d3d10effect.factor @@ -1,5 +1,5 @@ USING: alien.c-types alien.syntax classes.struct windows.com -windows.com.syntax windows.directx.d3d10 +windows.com.syntax windows.directx.d3d10 windows.directx.d3d10misc windows.directx.d3d10shader windows.types ; IN: windows.directx.d3d10effect diff --git a/basis/windows/directx/d3d10misc/d3d10misc.factor b/basis/windows/directx/d3d10misc/d3d10misc.factor index b6f5f12bce..a5809009ea 100644 --- a/basis/windows/directx/d3d10misc/d3d10misc.factor +++ b/basis/windows/directx/d3d10misc/d3d10misc.factor @@ -1,5 +1,5 @@ USING: alien.c-types alien.syntax windows.com windows.com.syntax -windows.directx.dxgi windows.types alien.libraries ; +windows.directx.d3d10 windows.directx.dxgi windows.types ; IN: windows.directx.d3d10misc LIBRARY: d3d10 diff --git a/basis/windows/directx/d3d10shader/d3d10shader.factor b/basis/windows/directx/d3d10shader/d3d10shader.factor index 4507441fd0..787698e503 100644 --- a/basis/windows/directx/d3d10shader/d3d10shader.factor +++ b/basis/windows/directx/d3d10shader/d3d10shader.factor @@ -1,5 +1,6 @@ -USING: alien.syntax alien.c-types classes.struct windows.types windows.com -windows.com.syntax windows.directx.d3d10 ; +USING: alien.c-types alien.syntax classes.struct windows.com +windows.com.syntax windows.directx.d3d10 windows.directx.d3d10misc +windows.types ; IN: windows.directx.d3d10shader LIBRARY: d3d10 diff --git a/basis/windows/directx/d3d11/d3d11.factor b/basis/windows/directx/d3d11/d3d11.factor index 505ac4bc67..8382c11dc2 100644 --- a/basis/windows/directx/d3d11/d3d11.factor +++ b/basis/windows/directx/d3d11/d3d11.factor @@ -634,6 +634,9 @@ STRUCT: D3D11_BOX { bottom UINT } { back UINT } ; +C-TYPE: ID3D11Device +C-TYPE: ID3D11ClassLinkage + COM-INTERFACE: ID3D11DeviceChild IUnknown {1841e5c8-16b0-489b-bcc8-44cfb0d5deae} void GetDevice ( ID3D11Device** ppDevice ) HRESULT GetPrivateData ( REFGUID guid, UINT* pDataSize, void* pData ) diff --git a/basis/windows/directx/d3d9/d3d9.factor b/basis/windows/directx/d3d9/d3d9.factor index cedfefc103..d4e06ae8c9 100644 --- a/basis/windows/directx/d3d9/d3d9.factor +++ b/basis/windows/directx/d3d9/d3d9.factor @@ -23,6 +23,8 @@ FUNCTION: BOOL D3DPERF_QueryRepeatFrame ( ) ; FUNCTION: void D3DPERF_SetOptions ( DWORD dwOptions ) ; FUNCTION: DWORD D3DPERF_GetStatus ( ) ; +C-TYPE: IDirect3DDevice9 + COM-INTERFACE: IDirect3D9 IUnknown {81BDCBCA-64D4-426d-AE8D-AD0147F4275C} HRESULT RegisterSoftwareDevice ( void* pInitializeFunction ) UINT GetAdapterCount ( ) @@ -51,6 +53,17 @@ C-TYPE: IDirect3DVertexDeclaration9 C-TYPE: IDirect3DVertexShader9 C-TYPE: IDirect3DIndexBuffer9 C-TYPE: IDirect3DPixelShader9 +C-TYPE: IDirect3DSwapChain9 +C-TYPE: IDirect3DTexture9 +C-TYPE: IDirect3DVolumeTexture9 +C-TYPE: IDirect3DCubeTexture9 +C-TYPE: IDirect3DStateBlock9 +C-TYPE: IDirect3DQuery9 +C-TYPE: IDirect3DVolume9 +C-TYPE: IDirect3D9Ex +C-TYPE: IDirect3DDevice9Ex +C-TYPE: IDirect3DAuthenticatedChannel9 +C-TYPE: IDirect3DCryptoSession9 COM-INTERFACE: IDirect3DDevice9 IUnknown {D0223B96-BF7A-43fd-92BD-A43B0D82B9EB} HRESULT TestCooperativeLevel ( ) diff --git a/basis/windows/directx/d3dx10async/d3dx10async.factor b/basis/windows/directx/d3dx10async/d3dx10async.factor index e2165302f4..e7fbcf573e 100644 --- a/basis/windows/directx/d3dx10async/d3dx10async.factor +++ b/basis/windows/directx/d3dx10async/d3dx10async.factor @@ -1,5 +1,5 @@ -USING: alien.syntax windows.directx.d3d10 windows.directx.d3d10shader -windows.types ; +USING: alien.syntax windows.directx.d3d10 windows.directx.d3d10misc +windows.directx.d3d10shader windows.directx.d3dx10core windows.types ; IN: windows.directx.d3dx10async LIBRARY: d3dx10 @@ -8,6 +8,7 @@ C-TYPE: ID3DX10ThreadPump C-TYPE: ID3D10EffectPool C-TYPE: D3DX10_IMAGE_LOAD_INFO C-TYPE: D3DX10_IMAGE_INFO +C-TYPE: ID3D10Effect FUNCTION: HRESULT D3DX10CompileFromFileA ( LPCSTR pSrcFile, D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2, ID3DX10ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult ) ; diff --git a/basis/windows/directx/d3dx11async/d3dx11async.factor b/basis/windows/directx/d3dx11async/d3dx11async.factor index 369ffd6683..bea30ecb1a 100644 --- a/basis/windows/directx/d3dx11async/d3dx11async.factor +++ b/basis/windows/directx/d3dx11async/d3dx11async.factor @@ -1,6 +1,6 @@ -USING: alien.syntax alien.c-types classes.struct windows.types -windows.directx.d3d10shader windows.directx.d3dx11core -windows.directx.d3d11 windows.directx.d3dx11tex ; +USING: alien.syntax windows.directx.d3d10misc +windows.directx.d3d10shader windows.directx.d3d11 +windows.directx.d3dx11core windows.directx.d3dx11tex windows.types ; IN: windows.directx.d3dx11async LIBRARY: d3dx11 diff --git a/basis/windows/directx/d3dx11tex/d3dx11tex.factor b/basis/windows/directx/d3dx11tex/d3dx11tex.factor index d21fa0c72a..19425535e8 100644 --- a/basis/windows/directx/d3dx11tex/d3dx11tex.factor +++ b/basis/windows/directx/d3dx11tex/d3dx11tex.factor @@ -1,6 +1,6 @@ -USING: alien.syntax alien.c-types classes.struct windows.types -windows.directx.dxgiformat windows.directx.d3d11 -windows.directx.d3dx11core ; +USING: alien.c-types alien.syntax classes.struct +windows.directx.d3d10misc windows.directx.d3d11 +windows.directx.d3dx11core windows.directx.dxgiformat windows.types ; IN: windows.directx.d3dx11tex LIBRARY: d3dx11 diff --git a/basis/windows/directx/dxgi/dxgi.factor b/basis/windows/directx/dxgi/dxgi.factor index 6537de885f..5d2ae5b990 100644 --- a/basis/windows/directx/dxgi/dxgi.factor +++ b/basis/windows/directx/dxgi/dxgi.factor @@ -119,6 +119,7 @@ COM-INTERFACE: IDXGISurface1 IDXGISurface {4AE63092-6327-4c1b-80AE-BFE12EA32B86} HRESULT GetDC ( BOOL Discard, HDC* phdc ) HRESULT ReleaseDC ( RECT* pDirtyRect ) ; +C-TYPE: IDXGIOutput COM-INTERFACE: IDXGIAdapter IDXGIObject {2411e7e1-12ac-4ccf-bd14-9798e8534dc0} HRESULT EnumOutputs ( UINT Output, IDXGIOutput** ppOutput ) HRESULT GetDesc ( DXGI_ADAPTER_DESC* pDesc ) @@ -201,13 +202,13 @@ STRUCT: DXGI_DISPLAY_COLOR_SPACE { PrimaryCoordinates FLOAT[8][2] } { WhitePoints FLOAT[16][2] } ; +COM-INTERFACE: IDXGIAdapter1 IDXGIAdapter {29038f61-3839-4626-91fd-086879011a05} +HRESULT GetDesc1 ( DXGI_ADAPTER_DESC1* pDesc ) ; + COM-INTERFACE: IDXGIFactory1 IDXGIFactory {770aae78-f26f-4dba-a829-253c83d1b387} HRESULT EnumAdapters1 ( UINT Adapter, IDXGIAdapter1** ppAdapter ) BOOL IsCurrent ( ) ; -COM-INTERFACE: IDXGIAdapter1 IDXGIAdapter {29038f61-3839-4626-91fd-086879011a05} -HRESULT GetDesc1 ( DXGI_ADAPTER_DESC1* pDesc ) ; - COM-INTERFACE: IDXGIDevice1 IDXGIDevice {77db970f-6276-48ba-ba28-070143b4392c} HRESULT SetMaximumFrameLatency ( UINT MaxLatency ) HRESULT GetMaximumFrameLatency ( UINT* pMaxLatency ) ; diff --git a/basis/windows/directx/xapofx/xapofx.factor b/basis/windows/directx/xapofx/xapofx.factor index 1255880c4c..594ad9ecbe 100644 --- a/basis/windows/directx/xapofx/xapofx.factor +++ b/basis/windows/directx/xapofx/xapofx.factor @@ -1,5 +1,5 @@ -USING: alien.c-types alien.syntax classes.struct windows.ole32 -windows.types ; +USING: alien.c-types alien.syntax classes.struct windows.com +windows.ole32 windows.types ; IN: windows.directx.xapofx LIBRARY: xapofx diff --git a/basis/windows/directx/xaudio2/xaudio2.factor b/basis/windows/directx/xaudio2/xaudio2.factor index 67a9234367..303eaf26b1 100644 --- a/basis/windows/directx/xaudio2/xaudio2.factor +++ b/basis/windows/directx/xaudio2/xaudio2.factor @@ -203,6 +203,9 @@ CONSTANT: XAUDIO2_LOG_STREAMING HEX: 1000 C-TYPE: IXAudio2EngineCallback C-TYPE: IXAudio2VoiceCallback +C-TYPE: IXAudio2SourceVoice +C-TYPE: IXAudio2SubmixVoice +C-TYPE: IXAudio2MasteringVoice COM-INTERFACE: IXAudio2 IUnknown {8bcf1f58-9fe7-4583-8ac6-e2adc465c8bb} HRESULT GetDeviceCount ( UINT32* pCount ) From e43312d7803437558746ac422550c669cc29878b Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Fri, 26 Feb 2010 11:01:57 -0500 Subject: [PATCH 261/713] Moving new-sets and hash-sets to core --- basis/prettyprint/backend/backend.factor | 6 +++- core/bootstrap/syntax.factor | 1 + core/hash-sets/hash-sets-tests.factor | 33 +++++++++++++++++++ core/hash-sets/hash-sets.factor | 24 ++++++++++++++ .../new-sets/new-sets-tests.factor | 0 {basis => core}/new-sets/new-sets.factor | 2 +- core/syntax/syntax.factor | 3 +- 7 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 core/hash-sets/hash-sets-tests.factor create mode 100644 core/hash-sets/hash-sets.factor rename {basis => core}/new-sets/new-sets-tests.factor (100%) rename {basis => core}/new-sets/new-sets.factor (97%) diff --git a/basis/prettyprint/backend/backend.factor b/basis/prettyprint/backend/backend.factor index 11d97a5118..aead51a4e3 100644 --- a/basis/prettyprint/backend/backend.factor +++ b/basis/prettyprint/backend/backend.factor @@ -6,7 +6,8 @@ combinators continuations effects generic hashtables io io.pathnames io.styles kernel make math math.order math.parser namespaces prettyprint.config prettyprint.custom prettyprint.sections prettyprint.stylesheet quotations sbufs -sequences strings vectors words words.symbol ; +sequences strings vectors words words.symbol hash-sets ; +FROM: new-sets => members ; IN: prettyprint.backend M: effect pprint* effect>string "(" ")" surround text ; @@ -187,6 +188,7 @@ M: hashtable pprint-delims drop \ H{ \ } ; M: tuple pprint-delims drop \ T{ \ } ; M: wrapper pprint-delims drop \ W{ \ } ; M: callstack pprint-delims drop \ CS{ \ } ; +M: hash-set pprint-delims drop \ HS{ \ } ; M: object >pprint-sequence ; M: vector >pprint-sequence ; @@ -195,6 +197,7 @@ M: callable >pprint-sequence ; M: hashtable >pprint-sequence >alist ; M: wrapper >pprint-sequence wrapped>> 1array ; M: callstack >pprint-sequence callstack>array ; +M: hash-set >pprint-sequence members ; : class-slot-sequence ( class slots -- sequence ) [ 1array ] [ [ f 2array ] dip append ] if-empty ; @@ -226,6 +229,7 @@ M: byte-vector pprint* pprint-object ; M: hashtable pprint* pprint-object ; M: curry pprint* pprint-object ; M: compose pprint* pprint-object ; +M: hash-set pprint* pprint-object ; M: wrapper pprint* { diff --git a/core/bootstrap/syntax.factor b/core/bootstrap/syntax.factor index 1870f4ac1b..c13f9f9026 100644 --- a/core/bootstrap/syntax.factor +++ b/core/bootstrap/syntax.factor @@ -29,6 +29,7 @@ IN: bootstrap.syntax "HEX:" "HOOK:" "H{" + "HS{" "IN:" "INSTANCE:" "M:" diff --git a/core/hash-sets/hash-sets-tests.factor b/core/hash-sets/hash-sets-tests.factor new file mode 100644 index 0000000000..2eef2bd309 --- /dev/null +++ b/core/hash-sets/hash-sets-tests.factor @@ -0,0 +1,33 @@ +! Copyright (C) 2010 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: new-sets tools.test kernel sorting prettyprint hash-sets ; +IN: hash-sets.tests + +[ { 1 2 3 } ] [ HS{ 1 2 3 } members natural-sort ] unit-test + +[ "HS{ 1 2 3 4 }" ] [ HS{ 1 2 3 4 } unparse ] unit-test + +[ t ] [ 1 HS{ 0 1 2 } in? ] unit-test +[ f ] [ 3 HS{ 0 1 2 } in? ] unit-test +[ HS{ 1 2 3 } ] [ 3 HS{ 1 2 } clone [ adjoin ] keep ] unit-test +[ HS{ 1 2 } ] [ 2 HS{ 1 2 } clone [ adjoin ] keep ] unit-test +[ HS{ 1 2 3 } ] [ 4 HS{ 1 2 3 } clone [ delete ] keep ] unit-test +[ HS{ 1 2 } ] [ 3 HS{ 1 2 3 } clone [ delete ] keep ] unit-test +[ HS{ 1 2 } ] [ HS{ 1 2 } fast-set ] unit-test +[ { 1 2 } ] [ HS{ 1 2 } members natural-sort ] unit-test + +[ HS{ 1 2 3 4 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } union ] unit-test +[ HS{ 2 3 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } intersect ] unit-test +[ t ] [ HS{ 1 2 3 } HS{ 2 3 4 } intersects? ] unit-test +[ f ] [ HS{ 1 } HS{ 2 3 4 } intersects? ] unit-test +[ f ] [ HS{ 1 } HS{ 2 3 4 } subset? ] unit-test +[ f ] [ HS{ 1 2 3 } HS{ 2 3 4 } subset? ] unit-test +[ t ] [ HS{ 2 3 } HS{ 2 3 4 } subset? ] unit-test +[ t ] [ HS{ } HS{ 2 3 4 } subset? ] unit-test +[ HS{ 1 } ] [ HS{ 1 2 3 } HS{ 2 3 4 } diff ] unit-test +[ t ] [ HS{ 1 2 3 } HS{ 2 1 3 } set= ] unit-test +[ t ] [ HS{ 1 2 3 } HS{ 2 1 3 } = ] unit-test +[ f ] [ HS{ 2 3 } HS{ 2 1 3 } set= ] unit-test +[ f ] [ HS{ 1 2 3 } HS{ 2 3 } set= ] unit-test + +[ HS{ 1 2 } HS{ 1 2 3 } ] [ HS{ 1 2 } clone dup clone [ 3 swap adjoin ] keep ] unit-test diff --git a/core/hash-sets/hash-sets.factor b/core/hash-sets/hash-sets.factor new file mode 100644 index 0000000000..34af2f5c87 --- /dev/null +++ b/core/hash-sets/hash-sets.factor @@ -0,0 +1,24 @@ +! Copyright (C) 2010 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: accessors assocs hashtables kernel new-sets +sequences parser ; +QUALIFIED: sets +IN: hash-sets + +! In a better implementation, less memory would be used +TUPLE: hash-set { table hashtable read-only } ; + +: ( members -- hash-set ) + [ dup ] H{ } map>assoc hash-set boa ; + +INSTANCE: hash-set set +M: hash-set in? table>> key? ; inline +M: hash-set adjoin table>> dupd set-at ; inline +M: hash-set delete table>> delete-at ; inline +M: hash-set members table>> keys ; inline +M: hash-set set-like + drop dup hash-set? [ members ] unless ; +M: hash-set clone + table>> clone hash-set boa ; + +M: sequence fast-set ; diff --git a/basis/new-sets/new-sets-tests.factor b/core/new-sets/new-sets-tests.factor similarity index 100% rename from basis/new-sets/new-sets-tests.factor rename to core/new-sets/new-sets-tests.factor diff --git a/basis/new-sets/new-sets.factor b/core/new-sets/new-sets.factor similarity index 97% rename from basis/new-sets/new-sets.factor rename to core/new-sets/new-sets.factor index 435c245311..d0541d90df 100644 --- a/basis/new-sets/new-sets.factor +++ b/core/new-sets/new-sets.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2010 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs hashtables kernel -math sequences parser prettyprint.custom ; +math sequences ; FROM: sets => prune ; IN: new-sets ! The vocab is called new-sets for now, but only until it gets into core diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index 0b5b32e289..77ef643fe2 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -8,7 +8,7 @@ generic.standard generic.hook generic.math generic.parser classes io.pathnames vocabs vocabs.parser classes.parser classes.union classes.intersection classes.mixin classes.predicate classes.singleton classes.tuple.parser compiler.units -combinators effects.parser slots ; +combinators effects.parser slots hash-sets ; IN: bootstrap.syntax ! These words are defined as a top-level form, instead of with @@ -104,6 +104,7 @@ IN: bootstrap.syntax "H{" [ \ } [ >hashtable ] parse-literal ] define-core-syntax "T{" [ parse-tuple-literal suffix! ] define-core-syntax "W{" [ \ } [ first ] parse-literal ] define-core-syntax + "HS{" [ \ } [ ] parse-literal ] define-core-syntax "POSTPONE:" [ scan-word suffix! ] define-core-syntax "\\" [ scan-word suffix! ] define-core-syntax From b76c82048d52b3fb457df699fa8d16801be66cbf Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Fri, 26 Feb 2010 12:07:37 -0500 Subject: [PATCH 262/713] Making propagation and tuple.parser refer to new-sets; adding some missing features from sets into new-sets --- .../tree/propagation/propagation-tests.factor | 2 +- .../propagation/transforms/transforms.factor | 15 +++--- core/classes/tuple/parser/parser.factor | 2 +- core/hash-sets/hash-sets.factor | 3 ++ core/new-sets/new-sets-tests.factor | 9 ++++ core/new-sets/new-sets.factor | 54 +++++++++++++++---- 6 files changed, 65 insertions(+), 20 deletions(-) diff --git a/basis/compiler/tree/propagation/propagation-tests.factor b/basis/compiler/tree/propagation/propagation-tests.factor index 444a424766..8cc91538d6 100644 --- a/basis/compiler/tree/propagation/propagation-tests.factor +++ b/basis/compiler/tree/propagation/propagation-tests.factor @@ -8,7 +8,7 @@ layouts compiler.tree.propagation.info compiler.tree.def-use compiler.tree.debugger compiler.tree.checker slots.private words hashtables classes assocs locals specialized-arrays system sorting math.libm math.floats.private math.integers.private -math.intervals quotations effects alien alien.data sets ; +math.intervals quotations effects alien alien.data new-sets ; FROM: math => float ; SPECIALIZED-ARRAY: double SPECIALIZED-ARRAY: void* diff --git a/basis/compiler/tree/propagation/transforms/transforms.factor b/basis/compiler/tree/propagation/transforms/transforms.factor index 0077d0f123..d4e5e25ffe 100644 --- a/basis/compiler/tree/propagation/transforms/transforms.factor +++ b/basis/compiler/tree/propagation/transforms/transforms.factor @@ -3,12 +3,13 @@ USING: alien.c-types kernel sequences words fry generic accessors classes.tuple classes classes.algebra definitions stack-checker.dependencies quotations classes.tuple.private math -math.partial-dispatch math.private math.intervals sets.private +math.partial-dispatch math.private math.intervals new-sets.private math.floats.private math.integers.private layouts math.order vectors hashtables combinators effects generalizations assocs -sets combinators.short-circuit sequences.private locals growable +new-sets combinators.short-circuit sequences.private locals growable stack-checker namespaces compiler.tree.propagation.info ; FROM: math => float ; +FROM: new-sets => set ; IN: compiler.tree.propagation.transforms \ equal? [ @@ -207,7 +208,7 @@ ERROR: bad-partial-eval quot word ; [ drop f ] swap [ literalize [ t ] ] { } map>assoc linear-case-quot ] [ - unique [ key? ] curry + tester ] if ; \ member? [ @@ -272,14 +273,14 @@ CONSTANT: lookup-table-at-max 256 \ at* [ at-quot ] 1 define-partial-eval : diff-quot ( seq -- quot: ( seq' -- seq'' ) ) - tester '[ [ @ not ] filter ] ; + tester '[ [ [ @ not ] filter ] keep set-like ] ; -\ diff [ diff-quot ] 1 define-partial-eval +M\ set diff [ diff-quot ] 1 define-partial-eval : intersect-quot ( seq -- quot: ( seq' -- seq'' ) ) - tester '[ _ filter ] ; + tester '[ [ _ filter ] keep set-like ] ; -\ intersect [ intersect-quot ] 1 define-partial-eval +M\ set intersect [ intersect-quot ] 1 define-partial-eval : fixnum-bits ( -- n ) cell-bits tag-bits get - ; diff --git a/core/classes/tuple/parser/parser.factor b/core/classes/tuple/parser/parser.factor index 7482cce048..8527275667 100644 --- a/core/classes/tuple/parser/parser.factor +++ b/core/classes/tuple/parser/parser.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel sets namespaces make sequences parser +USING: accessors kernel new-sets namespaces make sequences parser lexer combinators words classes.parser classes.tuple arrays slots math assocs parser.notes classes classes.algebra ; IN: classes.tuple.parser diff --git a/core/hash-sets/hash-sets.factor b/core/hash-sets/hash-sets.factor index 34af2f5c87..3c0acd46c4 100644 --- a/core/hash-sets/hash-sets.factor +++ b/core/hash-sets/hash-sets.factor @@ -22,3 +22,6 @@ M: hash-set clone table>> clone hash-set boa ; M: sequence fast-set ; + +M: sequence duplicates + HS{ } clone [ [ in? ] [ adjoin ] 2bi ] curry filter ; diff --git a/core/new-sets/new-sets-tests.factor b/core/new-sets/new-sets-tests.factor index bd777618a6..18960f86db 100644 --- a/core/new-sets/new-sets-tests.factor +++ b/core/new-sets/new-sets-tests.factor @@ -40,3 +40,12 @@ IN: new-sets.tests [ HS{ 1 2 3 } ] [ { 1 2 3 } fast-set ] unit-test [ { 1 2 3 } ] [ { { 1 } { 2 } { 1 3 } } combine ] unit-test + +[ f ] [ { 0 1 1 2 3 5 } all-unique? ] unit-test +[ t ] [ { 0 1 2 3 4 5 } all-unique? ] unit-test + +[ { 1 2 3 } ] [ { 1 2 2 3 3 } { } set-like ] unit-test +[ { 3 2 1 } ] [ { 3 3 2 2 1 } { } set-like ] unit-test + +[ { 1 2 1 } ] [ { 1 2 3 2 1 2 1 } duplicates ] unit-test +[ f ] [ HS{ 1 2 3 1 2 1 } duplicates ] unit-test diff --git a/core/new-sets/new-sets.factor b/core/new-sets/new-sets.factor index d0541d90df..115e0d404a 100644 --- a/core/new-sets/new-sets.factor +++ b/core/new-sets/new-sets.factor @@ -1,11 +1,8 @@ ! Copyright (C) 2010 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs hashtables kernel +USING: accessors assocs hashtables kernel vectors math sequences ; -FROM: sets => prune ; IN: new-sets -! The vocab is called new-sets for now, but only until it gets into core -! All the code here is in the style that could be put in core ! Set protocol MIXIN: set @@ -21,6 +18,8 @@ GENERIC: intersects? ( set1 set2 -- ? ) GENERIC: diff ( set1 set2 -- set ) GENERIC: subset? ( set1 set2 -- ? ) GENERIC: set= ( set1 set2 -- ? ) +GENERIC: duplicates ( set -- sequence ) +GENERIC: all-unique? ( set -- ? ) ! Defaults for some methods. ! Override them for efficiency @@ -30,8 +29,11 @@ M: set union @@ -52,15 +54,45 @@ M: set set= M: set fast-set ; +M: set duplicates drop f ; + +M: set all-unique? drop t ; + + ] [ length ] tri + [ [ (prune) ] 2curry each ] keep ; + +PRIVATE> + ! Sequences are sets INSTANCE: sequence set -M: sequence in? member? ; inline -M: sequence adjoin [ delete ] [ push ] 2bi ; -M: sequence delete remove! drop ; inline -M: sequence set-like - [ dup sequence? [ prune ] [ members ] if ] dip like ; -M: sequence members fast-set members ; +M: sequence in? + member? ; inline + +M: sequence adjoin + [ delete ] [ push ] 2bi ; + +M: sequence delete + remove! drop ; inline + +M: sequence set-like + [ members ] dip like ; + +M: sequence members + [ prune ] keep like ; + +M: sequence all-unique? + dup prune sequence= ; + +! Some sequence methods are defined using hash-sets USE: vocabs.loader "hash-sets" require From 366f36d73fdb979211c5caac2cc370f9394f356f Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Fri, 26 Feb 2010 13:22:56 -0500 Subject: [PATCH 263/713] Finishing porting sets features to new-sets --- core/new-sets/new-sets-tests.factor | 4 +++- core/new-sets/new-sets.factor | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core/new-sets/new-sets-tests.factor b/core/new-sets/new-sets-tests.factor index 18960f86db..b644b9a809 100644 --- a/core/new-sets/new-sets-tests.factor +++ b/core/new-sets/new-sets-tests.factor @@ -47,5 +47,7 @@ IN: new-sets.tests [ { 1 2 3 } ] [ { 1 2 2 3 3 } { } set-like ] unit-test [ { 3 2 1 } ] [ { 3 3 2 2 1 } { } set-like ] unit-test -[ { 1 2 1 } ] [ { 1 2 3 2 1 2 1 } duplicates ] unit-test +[ { 2 1 2 1 } ] [ { 1 2 3 2 1 2 1 } duplicates ] unit-test [ f ] [ HS{ 1 2 3 1 2 1 } duplicates ] unit-test + +[ H{ { 3 HS{ 1 2 } } } ] [ H{ } clone 1 3 pick adjoin-at 2 3 pick adjoin-at ] unit-test diff --git a/core/new-sets/new-sets.factor b/core/new-sets/new-sets.factor index 115e0d404a..bc4e720c9c 100644 --- a/core/new-sets/new-sets.factor +++ b/core/new-sets/new-sets.factor @@ -61,12 +61,12 @@ M: set all-unique? drop t ; ] [ length ] tri + [ f fast-set ] [ length ] bi [ [ (prune) ] 2curry each ] keep ; PRIVATE> @@ -98,3 +98,9 @@ USE: vocabs.loader : combine ( sets -- set ) f [ union ] reduce ; + +: gather ( seq quot -- newseq ) + map concat members ; inline + +: adjoin-at ( value key assoc -- ) + [ [ f fast-set ] unless* [ adjoin ] keep ] change-at ; From 73a990a4b80b8440483c34a9a267a2b9299c6bb0 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Fri, 26 Feb 2010 13:24:26 -0500 Subject: [PATCH 264/713] Making it fast to create a new hashset --- basis/compiler/tree/propagation/transforms/transforms.factor | 1 + core/hash-sets/hash-sets.factor | 1 + 2 files changed, 2 insertions(+) diff --git a/basis/compiler/tree/propagation/transforms/transforms.factor b/basis/compiler/tree/propagation/transforms/transforms.factor index d4e5e25ffe..b6fda4d5b9 100644 --- a/basis/compiler/tree/propagation/transforms/transforms.factor +++ b/basis/compiler/tree/propagation/transforms/transforms.factor @@ -135,6 +135,7 @@ IN: compiler.tree.propagation.transforms in-d>> first value-info literal>> { { V{ } [ [ drop { } 0 vector boa ] ] } { H{ } [ [ drop 0 ] ] } + { HS{ } [ [ drop f fast-set ] ] } [ drop f ] } case ] "custom-inlining" set-word-prop diff --git a/core/hash-sets/hash-sets.factor b/core/hash-sets/hash-sets.factor index 3c0acd46c4..52b883195e 100644 --- a/core/hash-sets/hash-sets.factor +++ b/core/hash-sets/hash-sets.factor @@ -22,6 +22,7 @@ M: hash-set clone table>> clone hash-set boa ; M: sequence fast-set ; +M: f fast-set drop H{ } clone hash-set boa ; M: sequence duplicates HS{ } clone [ [ in? ] [ adjoin ] 2bi ] curry filter ; From a72e2cc96c233a7acf7fcd3c633e1ba666c94af9 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Fri, 26 Feb 2010 13:53:20 -0500 Subject: [PATCH 265/713] Finishing converting compiler.cfg.ssa.construction.tdmsc to new-sets --- .../cfg/ssa/construction/tdmsc/tdmsc.factor | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor b/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor index ae3a20e800..7601ccc9bb 100644 --- a/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor +++ b/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs bit-arrays bit-sets fry -hashtables hints kernel locals math namespaces sequences sets +hashtables hints kernel locals math namespaces sequences new-sets compiler.cfg compiler.cfg.dominance compiler.cfg.rpo ; -QUALIFIED: new-sets +FROM: namespaces => set ; IN: compiler.cfg.ssa.construction.tdmsc ! TDMSC-I algorithm from "A Practical and Fast Iterative Algorithm for @@ -34,8 +34,8 @@ SYMBOLS: visited merge-sets levels again? ; [ merge-sets get ] dip '[ _ - [ merge-sets get at new-sets:union ] - [ number>> over new-sets:adjoin ] + [ merge-sets get at union ] + [ number>> over adjoin ] bi ] change-at ; @@ -49,10 +49,10 @@ SYMBOLS: visited merge-sets levels again? ; [ [ predecessors>> ] keep ] dip '[ _ 2dup j-edge? _ [ 2drop ] if ] each ; inline -: visited? ( pair -- ? ) visited get key? ; +: visited? ( pair -- ? ) visited get in? ; : consistent? ( snode lnode -- ? ) - [ merge-sets get at ] bi@ new-sets:subset? ; + [ merge-sets get at ] bi@ subset? ; : (process-edge) ( from to -- ) f walk [ @@ -63,7 +63,7 @@ SYMBOLS: visited merge-sets levels again? ; : process-edge ( from to -- ) 2dup 2array dup visited? [ 3drop ] [ - visited get conjoin + visited get adjoin (process-edge) ] if ; @@ -71,7 +71,7 @@ SYMBOLS: visited merge-sets levels again? ; [ process-edge ] each-incoming-j-edge ; : compute-merge-set-step ( bfo -- ) - visited get clear-assoc + HS{ } clone visited set [ process-block ] each ; : compute-merge-set-loop ( cfg -- ) @@ -80,7 +80,7 @@ SYMBOLS: visited merge-sets levels again? ; loop ; : (merge-set) ( bbs -- flags rpo ) - merge-sets get '[ _ at ] [ new-sets:union ] map-reduce + merge-sets get '[ _ at ] [ union ] map-reduce cfg get reverse-post-order ; inline PRIVATE> @@ -88,14 +88,14 @@ PRIVATE> : compute-merge-sets ( cfg -- ) needs-dominance - H{ } clone visited set + HS{ } clone visited set [ compute-levels ] [ init-merge-sets ] [ compute-merge-set-loop ] tri ; : merge-set ( bbs -- bbs' ) - (merge-set) [ new-sets:members ] dip nths ; + (merge-set) [ members ] dip nths ; : merge-set-each ( bbs quot: ( bb -- ) -- ) [ merge-set ] dip each ; inline From 7074979745e2962d7af43057ab2b11c1732370de Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Fri, 26 Feb 2010 16:01:01 -0500 Subject: [PATCH 266/713] Moving new-sets to sets --- basis/bit-sets/bit-sets-tests.factor | 2 +- basis/bit-sets/bit-sets.factor | 2 +- .../cfg/alias-analysis/alias-analysis.factor | 1 + basis/compiler/cfg/dce/dce.factor | 2 +- basis/compiler/cfg/def-use/def-use.factor | 1 + basis/compiler/cfg/dominance/dominance.factor | 3 +- .../linear-scan/assignment/assignment.factor | 1 + .../cfg/linearization/order/order.factor | 2 +- basis/compiler/cfg/liveness/ssa/ssa.factor | 3 +- .../cfg/loop-detection/loop-detection.factor | 1 + .../preferred/preferred.factor | 1 + .../representations/representations.factor | 1 + basis/compiler/cfg/rpo/rpo.factor | 3 +- .../cfg/ssa/construction/construction.factor | 3 +- .../cfg/ssa/construction/tdmsc/tdmsc.factor | 2 +- .../cfg/ssa/destruction/destruction.factor | 1 + .../compiler/cfg/ssa/liveness/liveness.factor | 1 + basis/compiler/cfg/stacks/local/local.factor | 3 +- .../cfg/write-barrier/write-barrier.factor | 1 + basis/compiler/codegen/codegen.factor | 1 + basis/compiler/tree/checker/checker.factor | 1 + .../tree/dead-code/branches/branches.factor | 1 + .../tree/dead-code/liveness/liveness.factor | 1 + basis/compiler/tree/def-use/def-use.factor | 1 + .../tree/def-use/simplified/simplified.factor | 1 + .../allocations/allocations.factor | 1 + .../modular-arithmetic.factor | 1 + .../tree/propagation/propagation-tests.factor | 2 +- .../propagation/transforms/transforms.factor | 6 +- .../compiler/tree/recursive/recursive.factor | 1 + basis/help/markup/markup.factor | 1 + basis/inspector/inspector.factor | 1 + basis/peg/peg.factor | 1 + basis/prettyprint/backend/backend.factor | 2 +- basis/prettyprint/prettyprint.factor | 1 + basis/prettyprint/sections/sections.factor | 1 + basis/regexp/nfa/nfa.factor | 1 + basis/see/see.factor | 2 + basis/stack-checker/backend/backend.factor | 1 + .../dependencies/dependencies.factor | 1 + .../transforms/transforms.factor | 1 + basis/ui/gestures/gestures.factor | 1 + basis/ui/tools/listener/listener.factor | 1 + basis/unicode/data/data.factor | 1 + basis/vocabs/refresh/refresh.factor | 3 +- core/classes/algebra/algebra.factor | 1 + core/classes/classes.factor | 1 + core/classes/tuple/parser/parser.factor | 2 +- core/combinators/combinators.factor | 2 +- core/compiler/units/units.factor | 1 + core/destructors/destructors.factor | 1 + core/generic/generic.factor | 1 + core/hash-sets/hash-sets-tests.factor | 2 +- core/hash-sets/hash-sets.factor | 2 +- core/sets/sets-tests.factor | 51 +++++-- core/sets/sets.factor | 139 ++++++++++++------ 56 files changed, 195 insertions(+), 78 deletions(-) diff --git a/basis/bit-sets/bit-sets-tests.factor b/basis/bit-sets/bit-sets-tests.factor index 26010a3337..4e97e703d0 100644 --- a/basis/bit-sets/bit-sets-tests.factor +++ b/basis/bit-sets/bit-sets-tests.factor @@ -1,4 +1,4 @@ -USING: bit-sets tools.test new-sets kernel bit-arrays ; +USING: bit-sets tools.test sets kernel bit-arrays ; IN: bit-sets.tests [ T{ bit-set f ?{ t f t f t f } } ] [ diff --git a/basis/bit-sets/bit-sets.factor b/basis/bit-sets/bit-sets.factor index a3cac64295..9d3d09ec1b 100644 --- a/basis/bit-sets/bit-sets.factor +++ b/basis/bit-sets/bit-sets.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel accessors sequences byte-arrays bit-arrays math hints new-sets ; +USING: kernel accessors sequences byte-arrays bit-arrays math hints sets ; IN: bit-sets TUPLE: bit-set { table bit-array read-only } ; diff --git a/basis/compiler/cfg/alias-analysis/alias-analysis.factor b/basis/compiler/cfg/alias-analysis/alias-analysis.factor index 9fffa0eed2..810831f776 100644 --- a/basis/compiler/cfg/alias-analysis/alias-analysis.factor +++ b/basis/compiler/cfg/alias-analysis/alias-analysis.factor @@ -12,6 +12,7 @@ compiler.cfg.registers compiler.cfg.comparisons compiler.cfg.instructions compiler.cfg.representations.preferred ; +FROM: namespaces => set ; IN: compiler.cfg.alias-analysis ! We try to eliminate redundant slot operations using some simple heuristics. diff --git a/basis/compiler/cfg/dce/dce.factor b/basis/compiler/cfg/dce/dce.factor index c8010d9aa8..b4fcd018f4 100644 --- a/basis/compiler/cfg/dce/dce.factor +++ b/basis/compiler/cfg/dce/dce.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs kernel namespaces sequences compiler.cfg.instructions compiler.cfg.def-use -compiler.cfg.rpo compiler.cfg.predecessors hash-sets new-sets ; +compiler.cfg.rpo compiler.cfg.predecessors hash-sets sets ; FROM: namespaces => set ; IN: compiler.cfg.dce diff --git a/basis/compiler/cfg/def-use/def-use.factor b/basis/compiler/cfg/def-use/def-use.factor index 54cff2ccaa..3838a0d1b9 100644 --- a/basis/compiler/cfg/def-use/def-use.factor +++ b/basis/compiler/cfg/def-use/def-use.factor @@ -5,6 +5,7 @@ compiler.units fry generalizations generic kernel locals namespaces quotations sequences sets slots words compiler.cfg.instructions compiler.cfg.instructions.syntax compiler.cfg.rpo ; +FROM: namespaces => set ; IN: compiler.cfg.def-use GENERIC: defs-vreg ( insn -- vreg/f ) diff --git a/basis/compiler/cfg/dominance/dominance.factor b/basis/compiler/cfg/dominance/dominance.factor index d21e81526e..71dc12f6a1 100644 --- a/basis/compiler/cfg/dominance/dominance.factor +++ b/basis/compiler/cfg/dominance/dominance.factor @@ -3,6 +3,7 @@ USING: accessors assocs combinators sets math fry kernel math.order dlists deques vectors namespaces sequences sorting locals compiler.cfg.rpo compiler.cfg.predecessors ; +FROM: namespaces => set ; IN: compiler.cfg.dominance ! Reference: @@ -103,4 +104,4 @@ PRIVATE> [ accum push ] [ dom-children work-list push-all-front ] bi ] slurp-deque - accum ; \ No newline at end of file + accum ; diff --git a/basis/compiler/cfg/linear-scan/assignment/assignment.factor b/basis/compiler/cfg/linear-scan/assignment/assignment.factor index f69db1deea..6acb9169ec 100644 --- a/basis/compiler/cfg/linear-scan/assignment/assignment.factor +++ b/basis/compiler/cfg/linear-scan/assignment/assignment.factor @@ -13,6 +13,7 @@ compiler.cfg.linearization.order compiler.cfg.linear-scan.allocation compiler.cfg.linear-scan.allocation.state compiler.cfg.linear-scan.live-intervals ; +FROM: namespaces => set ; IN: compiler.cfg.linear-scan.assignment ! This contains both active and inactive intervals; any interval diff --git a/basis/compiler/cfg/linearization/order/order.factor b/basis/compiler/cfg/linearization/order/order.factor index f48816d1b9..166a0f0d50 100644 --- a/basis/compiler/cfg/linearization/order/order.factor +++ b/basis/compiler/cfg/linearization/order/order.factor @@ -4,7 +4,7 @@ USING: accessors assocs deques dlists kernel make sorting namespaces sequences combinators combinators.short-circuit fry math compiler.cfg.rpo compiler.cfg.utilities compiler.cfg.loop-detection compiler.cfg.predecessors -new-sets hash-sets ; +sets hash-sets ; FROM: namespaces => set ; IN: compiler.cfg.linearization.order diff --git a/basis/compiler/cfg/liveness/ssa/ssa.factor b/basis/compiler/cfg/liveness/ssa/ssa.factor index 81263c8e9a..5215c9c487 100644 --- a/basis/compiler/cfg/liveness/ssa/ssa.factor +++ b/basis/compiler/cfg/liveness/ssa/ssa.factor @@ -4,6 +4,7 @@ USING: kernel namespaces deques accessors sets sequences assocs fry hashtables dlists compiler.cfg.def-use compiler.cfg.instructions compiler.cfg.rpo compiler.cfg.liveness compiler.cfg.utilities compiler.cfg.predecessors ; +FROM: namespaces => set ; IN: compiler.cfg.liveness.ssa ! TODO: merge with compiler.cfg.liveness @@ -59,4 +60,4 @@ SYMBOL: work-list : live-in? ( vreg bb -- ? ) live-in key? ; -: live-out? ( vreg bb -- ? ) live-out key? ; \ No newline at end of file +: live-out? ( vreg bb -- ? ) live-out key? ; diff --git a/basis/compiler/cfg/loop-detection/loop-detection.factor b/basis/compiler/cfg/loop-detection/loop-detection.factor index 73b99ee132..2e2dab00f1 100644 --- a/basis/compiler/cfg/loop-detection/loop-detection.factor +++ b/basis/compiler/cfg/loop-detection/loop-detection.factor @@ -2,6 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs combinators deques dlists fry kernel namespaces sequences sets compiler.cfg compiler.cfg.predecessors ; +FROM: namespaces => set ; IN: compiler.cfg.loop-detection TUPLE: natural-loop header index ends blocks ; diff --git a/basis/compiler/cfg/representations/preferred/preferred.factor b/basis/compiler/cfg/representations/preferred/preferred.factor index 726521cfe1..3be96515de 100644 --- a/basis/compiler/cfg/representations/preferred/preferred.factor +++ b/basis/compiler/cfg/representations/preferred/preferred.factor @@ -5,6 +5,7 @@ words sets combinators generalizations cpu.architecture compiler.units compiler.cfg.utilities compiler.cfg compiler.cfg.rpo compiler.cfg.instructions compiler.cfg.def-use ; FROM: compiler.cfg.instructions.syntax => insn-def-slot insn-use-slots insn-temp-slots scalar-rep ; +FROM: namespaces => set ; IN: compiler.cfg.representations.preferred GENERIC: defs-vreg-rep ( insn -- rep/f ) diff --git a/basis/compiler/cfg/representations/representations.factor b/basis/compiler/cfg/representations/representations.factor index 005fe8c90b..eaea3b94c8 100644 --- a/basis/compiler/cfg/representations/representations.factor +++ b/basis/compiler/cfg/representations/representations.factor @@ -15,6 +15,7 @@ compiler.cfg.utilities compiler.cfg.loop-detection compiler.cfg.renaming.functor compiler.cfg.representations.preferred ; +FROM: namespaces => set ; IN: compiler.cfg.representations ! Virtual register representation selection. diff --git a/basis/compiler/cfg/rpo/rpo.factor b/basis/compiler/cfg/rpo/rpo.factor index b6322730ee..e99b9c6c1e 100644 --- a/basis/compiler/cfg/rpo/rpo.factor +++ b/basis/compiler/cfg/rpo/rpo.factor @@ -2,6 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel accessors namespaces make math sequences sets assocs fry compiler.cfg compiler.cfg.instructions ; +FROM: namespaces => set ; IN: compiler.cfg.rpo SYMBOL: visited @@ -42,4 +43,4 @@ SYMBOL: visited dupd '[ _ optimize-basic-block ] each-basic-block ; inline : needs-post-order ( cfg -- cfg' ) - dup post-order drop ; \ No newline at end of file + dup post-order drop ; diff --git a/basis/compiler/cfg/ssa/construction/construction.factor b/basis/compiler/cfg/ssa/construction/construction.factor index 7662b8ab01..7cd85e5fbe 100644 --- a/basis/compiler/cfg/ssa/construction/construction.factor +++ b/basis/compiler/cfg/ssa/construction/construction.factor @@ -12,6 +12,7 @@ compiler.cfg.instructions compiler.cfg.renaming compiler.cfg.renaming.functor compiler.cfg.ssa.construction.tdmsc ; +FROM: namespaces => set ; IN: compiler.cfg.ssa.construction ! The phi placement algorithm is implemented in @@ -135,4 +136,4 @@ PRIVATE> [ compute-defs compute-phi-nodes insert-phi-nodes ] [ rename ] [ ] - } cleave ; \ No newline at end of file + } cleave ; diff --git a/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor b/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor index 7601ccc9bb..4c2210c493 100644 --- a/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor +++ b/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs bit-arrays bit-sets fry -hashtables hints kernel locals math namespaces sequences new-sets +hashtables hints kernel locals math namespaces sequences sets compiler.cfg compiler.cfg.dominance compiler.cfg.rpo ; FROM: namespaces => set ; IN: compiler.cfg.ssa.construction.tdmsc diff --git a/basis/compiler/cfg/ssa/destruction/destruction.factor b/basis/compiler/cfg/ssa/destruction/destruction.factor index d93045da55..8b766c8114 100644 --- a/basis/compiler/cfg/ssa/destruction/destruction.factor +++ b/basis/compiler/cfg/ssa/destruction/destruction.factor @@ -15,6 +15,7 @@ compiler.cfg.ssa.interference compiler.cfg.ssa.interference.live-ranges compiler.cfg.utilities compiler.utilities ; +FROM: namespaces => set ; IN: compiler.cfg.ssa.destruction ! Maps vregs to leaders. diff --git a/basis/compiler/cfg/ssa/liveness/liveness.factor b/basis/compiler/cfg/ssa/liveness/liveness.factor index 7847de28fc..6e84b8b77d 100644 --- a/basis/compiler/cfg/ssa/liveness/liveness.factor +++ b/basis/compiler/cfg/ssa/liveness/liveness.factor @@ -6,6 +6,7 @@ compiler.cfg.rpo compiler.cfg.dominance compiler.cfg.def-use compiler.cfg.instructions ; +FROM: namespaces => set ; IN: compiler.cfg.ssa.liveness ! Liveness checking on SSA IR, as described in diff --git a/basis/compiler/cfg/stacks/local/local.factor b/basis/compiler/cfg/stacks/local/local.factor index 30a2c4c13f..95feb4c034 100644 --- a/basis/compiler/cfg/stacks/local/local.factor +++ b/basis/compiler/cfg/stacks/local/local.factor @@ -8,6 +8,7 @@ compiler.cfg.instructions compiler.cfg.registers compiler.cfg.stacks.height compiler.cfg.parallel-copy ; +FROM: namespaces => set ; IN: compiler.cfg.stacks.local ! Local stack analysis. We build three sets for every basic block @@ -106,4 +107,4 @@ M: rs-loc translate-local-loc n>> current-height get r>> - ; : peek-set ( bb -- assoc ) peek-sets get at ; : replace-set ( bb -- assoc ) replace-sets get at ; -: kill-set ( bb -- assoc ) kill-sets get at ; \ No newline at end of file +: kill-set ( bb -- assoc ) kill-sets get at ; diff --git a/basis/compiler/cfg/write-barrier/write-barrier.factor b/basis/compiler/cfg/write-barrier/write-barrier.factor index 523f7c6d1c..cecf5f7251 100644 --- a/basis/compiler/cfg/write-barrier/write-barrier.factor +++ b/basis/compiler/cfg/write-barrier/write-barrier.factor @@ -3,6 +3,7 @@ USING: accessors assocs combinators.short-circuit compiler.cfg.instructions compiler.cfg.rpo kernel namespaces sequences sets ; +FROM: namespaces => set ; IN: compiler.cfg.write-barrier SYMBOL: fresh-allocations diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index 963ed0ab28..3edfcc565b 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -16,6 +16,7 @@ compiler.cfg.registers compiler.cfg.builder compiler.codegen.fixup compiler.utilities ; +FROM: namespaces => set ; IN: compiler.codegen SYMBOL: insn-counts diff --git a/basis/compiler/tree/checker/checker.factor b/basis/compiler/tree/checker/checker.factor index b3f01c8c01..a3a19b8f4d 100644 --- a/basis/compiler/tree/checker/checker.factor +++ b/basis/compiler/tree/checker/checker.factor @@ -7,6 +7,7 @@ compiler.tree compiler.tree.def-use compiler.tree.recursive compiler.tree.combinators ; +FROM: namespaces => set ; IN: compiler.tree.checker ! Check some invariants; this can help catch compiler bugs. diff --git a/basis/compiler/tree/dead-code/branches/branches.factor b/basis/compiler/tree/dead-code/branches/branches.factor index d1fdf6359a..5b5249f8e4 100644 --- a/basis/compiler/tree/dead-code/branches/branches.factor +++ b/basis/compiler/tree/dead-code/branches/branches.factor @@ -4,6 +4,7 @@ USING: sequences namespaces kernel accessors assocs sets fry arrays combinators columns stack-checker.backend stack-checker.branches compiler.tree compiler.tree.combinators compiler.tree.dead-code.liveness compiler.tree.dead-code.simple ; +FROM: namespaces => set ; IN: compiler.tree.dead-code.branches M: #if mark-live-values* look-at-inputs ; diff --git a/basis/compiler/tree/dead-code/liveness/liveness.factor b/basis/compiler/tree/dead-code/liveness/liveness.factor index 9ece5d340b..7e437cbc4e 100644 --- a/basis/compiler/tree/dead-code/liveness/liveness.factor +++ b/basis/compiler/tree/dead-code/liveness/liveness.factor @@ -4,6 +4,7 @@ USING: fry accessors namespaces assocs deques search-deques dlists kernel sequences compiler.utilities words sets stack-checker.branches compiler.tree compiler.tree.def-use compiler.tree.combinators ; +FROM: namespaces => set ; IN: compiler.tree.dead-code.liveness SYMBOL: work-list diff --git a/basis/compiler/tree/def-use/def-use.factor b/basis/compiler/tree/def-use/def-use.factor index 872b6131c9..a1c316140d 100644 --- a/basis/compiler/tree/def-use/def-use.factor +++ b/basis/compiler/tree/def-use/def-use.factor @@ -6,6 +6,7 @@ stack-checker.state stack-checker.branches compiler.tree compiler.tree.combinators ; +FROM: namespaces => set ; IN: compiler.tree.def-use SYMBOL: def-use diff --git a/basis/compiler/tree/def-use/simplified/simplified.factor b/basis/compiler/tree/def-use/simplified/simplified.factor index c2fb74c97e..0061e8cffb 100644 --- a/basis/compiler/tree/def-use/simplified/simplified.factor +++ b/basis/compiler/tree/def-use/simplified/simplified.factor @@ -2,6 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: sequences kernel fry vectors accessors namespaces assocs sets stack-checker.branches compiler.tree compiler.tree.def-use ; +FROM: namespaces => set ; IN: compiler.tree.def-use.simplified ! Simplified def-use follows chains of copies. diff --git a/basis/compiler/tree/escape-analysis/allocations/allocations.factor b/basis/compiler/tree/escape-analysis/allocations/allocations.factor index 5291c5e81f..015b6ad626 100644 --- a/basis/compiler/tree/escape-analysis/allocations/allocations.factor +++ b/basis/compiler/tree/escape-analysis/allocations/allocations.factor @@ -2,6 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs namespaces sequences kernel math combinators sets disjoint-sets fry stack-checker.values ; +FROM: namespaces => set ; IN: compiler.tree.escape-analysis.allocations ! A map from values to classes. Only for #introduce outputs diff --git a/basis/compiler/tree/modular-arithmetic/modular-arithmetic.factor b/basis/compiler/tree/modular-arithmetic/modular-arithmetic.factor index ece2ed80f3..961ce1ecd7 100644 --- a/basis/compiler/tree/modular-arithmetic/modular-arithmetic.factor +++ b/basis/compiler/tree/modular-arithmetic/modular-arithmetic.factor @@ -9,6 +9,7 @@ compiler.tree.propagation.info compiler.tree.def-use compiler.tree.def-use.simplified compiler.tree.late-optimizations ; +FROM: namespaces => set ; IN: compiler.tree.modular-arithmetic ! This is a late-stage optimization. diff --git a/basis/compiler/tree/propagation/propagation-tests.factor b/basis/compiler/tree/propagation/propagation-tests.factor index 8cc91538d6..444a424766 100644 --- a/basis/compiler/tree/propagation/propagation-tests.factor +++ b/basis/compiler/tree/propagation/propagation-tests.factor @@ -8,7 +8,7 @@ layouts compiler.tree.propagation.info compiler.tree.def-use compiler.tree.debugger compiler.tree.checker slots.private words hashtables classes assocs locals specialized-arrays system sorting math.libm math.floats.private math.integers.private -math.intervals quotations effects alien alien.data new-sets ; +math.intervals quotations effects alien alien.data sets ; FROM: math => float ; SPECIALIZED-ARRAY: double SPECIALIZED-ARRAY: void* diff --git a/basis/compiler/tree/propagation/transforms/transforms.factor b/basis/compiler/tree/propagation/transforms/transforms.factor index b6fda4d5b9..4f0eea9cbb 100644 --- a/basis/compiler/tree/propagation/transforms/transforms.factor +++ b/basis/compiler/tree/propagation/transforms/transforms.factor @@ -3,13 +3,13 @@ USING: alien.c-types kernel sequences words fry generic accessors classes.tuple classes classes.algebra definitions stack-checker.dependencies quotations classes.tuple.private math -math.partial-dispatch math.private math.intervals new-sets.private +math.partial-dispatch math.private math.intervals sets.private math.floats.private math.integers.private layouts math.order vectors hashtables combinators effects generalizations assocs -new-sets combinators.short-circuit sequences.private locals growable +sets combinators.short-circuit sequences.private locals growable stack-checker namespaces compiler.tree.propagation.info ; FROM: math => float ; -FROM: new-sets => set ; +FROM: sets => set ; IN: compiler.tree.propagation.transforms \ equal? [ diff --git a/basis/compiler/tree/recursive/recursive.factor b/basis/compiler/tree/recursive/recursive.factor index bc6243e138..0771b978a7 100644 --- a/basis/compiler/tree/recursive/recursive.factor +++ b/basis/compiler/tree/recursive/recursive.factor @@ -2,6 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel assocs arrays namespaces accessors sequences deques fry search-deques dlists combinators.short-circuit make sets compiler.tree ; +FROM: namespaces => set ; IN: compiler.tree.recursive TUPLE: call-site tail? node label ; diff --git a/basis/help/markup/markup.factor b/basis/help/markup/markup.factor index f951f30b2f..dd43c84864 100644 --- a/basis/help/markup/markup.factor +++ b/basis/help/markup/markup.factor @@ -8,6 +8,7 @@ prettyprint.stylesheet quotations see sequences sets slots sorting splitting strings vectors vocabs vocabs.loader words words.symbol ; FROM: prettyprint.sections => with-pprint ; +FROM: namespaces => set ; IN: help.markup PREDICATE: simple-element < array diff --git a/basis/inspector/inspector.factor b/basis/inspector/inspector.factor index 2aa7cd218e..92d61ca7cf 100644 --- a/basis/inspector/inspector.factor +++ b/basis/inspector/inspector.factor @@ -5,6 +5,7 @@ namespaces prettyprint prettyprint.custom prettyprint.sections sequences strings io.styles vectors words quotations mirrors splitting math.parser classes vocabs sets sorting summary debugger continuations fry combinators ; +FROM: namespaces => set ; IN: inspector SYMBOL: +number-rows+ diff --git a/basis/peg/peg.factor b/basis/peg/peg.factor index a180713ccf..cc480c30b2 100644 --- a/basis/peg/peg.factor +++ b/basis/peg/peg.factor @@ -5,6 +5,7 @@ io vectors arrays math.parser math.order combinators classes sets unicode.categories compiler.units parser effects.parser words quotations memoize accessors locals splitting combinators.short-circuit generalizations ; +FROM: namespaces => set ; IN: peg TUPLE: parse-result remaining ast ; diff --git a/basis/prettyprint/backend/backend.factor b/basis/prettyprint/backend/backend.factor index aead51a4e3..7d0cb40576 100644 --- a/basis/prettyprint/backend/backend.factor +++ b/basis/prettyprint/backend/backend.factor @@ -7,7 +7,7 @@ io.pathnames io.styles kernel make math math.order math.parser namespaces prettyprint.config prettyprint.custom prettyprint.sections prettyprint.stylesheet quotations sbufs sequences strings vectors words words.symbol hash-sets ; -FROM: new-sets => members ; +FROM: sets => members ; IN: prettyprint.backend M: effect pprint* effect>string "(" ")" surround text ; diff --git a/basis/prettyprint/prettyprint.factor b/basis/prettyprint/prettyprint.factor index 23cf956a1d..249a6e0a57 100644 --- a/basis/prettyprint/prettyprint.factor +++ b/basis/prettyprint/prettyprint.factor @@ -5,6 +5,7 @@ io.streams.string io.styles kernel make math math.parser namespaces parser prettyprint.backend prettyprint.config prettyprint.custom prettyprint.sections quotations sequences sorting strings vocabs vocabs.prettyprint words sets generic ; +FROM: namespaces => set ; IN: prettyprint : with-use ( obj quot -- ) diff --git a/basis/prettyprint/sections/sections.factor b/basis/prettyprint/sections/sections.factor index 6f5f61f688..cd606667fd 100644 --- a/basis/prettyprint/sections/sections.factor +++ b/basis/prettyprint/sections/sections.factor @@ -4,6 +4,7 @@ USING: arrays generic hashtables io kernel math assocs namespaces make sequences strings io.styles vectors words prettyprint.config splitting classes continuations accessors sets vocabs.parser combinators vocabs ; +FROM: namespaces => set ; IN: prettyprint.sections ! State diff --git a/basis/regexp/nfa/nfa.factor b/basis/regexp/nfa/nfa.factor index 35edcf328a..cc430f2de1 100644 --- a/basis/regexp/nfa/nfa.factor +++ b/basis/regexp/nfa/nfa.factor @@ -5,6 +5,7 @@ sequences fry quotations math.order math.ranges vectors unicode.categories regexp.transition-tables words sets hashtables combinators.short-circuit unicode.data regexp.ast regexp.classes memoize ; +FROM: namespaces => set ; IN: regexp.nfa ! This uses unicode.data for ch>upper and ch>lower diff --git a/basis/see/see.factor b/basis/see/see.factor index 326e051219..bb6ae5cf2d 100644 --- a/basis/see/see.factor +++ b/basis/see/see.factor @@ -8,6 +8,8 @@ io.streams.string io.styles kernel make namespaces prettyprint prettyprint.backend prettyprint.config prettyprint.custom prettyprint.sections sequences sets sorting strings summary words words.symbol words.constant words.alias vocabs slots ; +FROM: namespaces => set ; +FROM: classes => members ; IN: see GENERIC: synopsis* ( defspec -- ) diff --git a/basis/stack-checker/backend/backend.factor b/basis/stack-checker/backend/backend.factor index 8de930a6cd..ddb1fd0021 100644 --- a/basis/stack-checker/backend/backend.factor +++ b/basis/stack-checker/backend/backend.factor @@ -6,6 +6,7 @@ continuations assocs combinators compiler.errors accessors math.order definitions sets hints macros stack-checker.state stack-checker.visitor stack-checker.errors stack-checker.values stack-checker.recursive-state stack-checker.dependencies summary ; +FROM: namespaces => set ; IN: stack-checker.backend : push-d ( obj -- ) meta-d push ; diff --git a/basis/stack-checker/dependencies/dependencies.factor b/basis/stack-checker/dependencies/dependencies.factor index e2f7c57593..dcfb3db6bf 100644 --- a/basis/stack-checker/dependencies/dependencies.factor +++ b/basis/stack-checker/dependencies/dependencies.factor @@ -5,6 +5,7 @@ generic kernel math namespaces sequences words sets combinators.short-circuit classes.tuple alien.c-types ; FROM: classes.tuple.private => tuple-layout ; FROM: assocs => change-at ; +FROM: namespaces => set ; IN: stack-checker.dependencies ! Words that the current quotation depends on diff --git a/basis/stack-checker/transforms/transforms.factor b/basis/stack-checker/transforms/transforms.factor index cf32792a2e..9f966bd8b8 100644 --- a/basis/stack-checker/transforms/transforms.factor +++ b/basis/stack-checker/transforms/transforms.factor @@ -9,6 +9,7 @@ sequences.private generalizations stack-checker.backend stack-checker.state stack-checker.visitor stack-checker.errors stack-checker.values stack-checker.recursive-state stack-checker.dependencies ; +FROM: namespaces => set ; IN: stack-checker.transforms : call-transformer ( stack quot -- newquot ) diff --git a/basis/ui/gestures/gestures.factor b/basis/ui/gestures/gestures.factor index f33b6ec6da..30c96335cc 100644 --- a/basis/ui/gestures/gestures.factor +++ b/basis/ui/gestures/gestures.factor @@ -5,6 +5,7 @@ namespaces make sequences words strings system hashtables math.parser math.vectors classes.tuple classes boxes calendar alarms combinators sets columns fry deques ui.gadgets ui.gadgets.private ascii combinators.short-circuit ; +FROM: namespaces => set ; IN: ui.gestures : get-gesture-handler ( gesture gadget -- quot ) diff --git a/basis/ui/tools/listener/listener.factor b/basis/ui/tools/listener/listener.factor index 2a948fddc0..53d3bec56e 100644 --- a/basis/ui/tools/listener/listener.factor +++ b/basis/ui/tools/listener/listener.factor @@ -16,6 +16,7 @@ ui.tools.listener.completion ui.tools.listener.popups ui.tools.listener.history ui.images ui.tools.error-list tools.errors.model ; FROM: source-files.errors => all-errors ; +FROM: namespaces => set ; IN: ui.tools.listener ! If waiting is t, we're waiting for user input, and invoking diff --git a/basis/unicode/data/data.factor b/basis/unicode/data/data.factor index 24dfba6be0..85b59de750 100644 --- a/basis/unicode/data/data.factor +++ b/basis/unicode/data/data.factor @@ -6,6 +6,7 @@ math.parser hash2 math.order byte-arrays namespaces compiler.units parser io.encodings.ascii values interval-maps ascii sets combinators locals math.ranges sorting make strings.parser io.encodings.utf8 memoize simple-flat-file ; +FROM: namespaces => set ; IN: unicode.data set ; IN: vocabs.refresh : source-modified? ( path -- ? ) @@ -88,4 +89,4 @@ SYMBOL: modified-docs : refresh ( prefix -- ) to-refresh do-refresh ; -: refresh-all ( -- ) "" refresh ; \ No newline at end of file +: refresh-all ( -- ) "" refresh ; diff --git a/core/classes/algebra/algebra.factor b/core/classes/algebra/algebra.factor index f9aaf3eaa5..96fa34314e 100644 --- a/core/classes/algebra/algebra.factor +++ b/core/classes/algebra/algebra.factor @@ -3,6 +3,7 @@ USING: kernel classes classes.private combinators accessors sequences arrays vectors assocs namespaces words sorting layouts math hashtables kernel.private sets math.order ; +FROM: classes => members ; IN: classes.algebra set ; IN: classes ERROR: bad-inheritance class superclass ; diff --git a/core/classes/tuple/parser/parser.factor b/core/classes/tuple/parser/parser.factor index 8527275667..7482cce048 100644 --- a/core/classes/tuple/parser/parser.factor +++ b/core/classes/tuple/parser/parser.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel new-sets namespaces make sequences parser +USING: accessors kernel sets namespaces make sequences parser lexer combinators words classes.parser classes.tuple arrays slots math assocs parser.notes classes classes.algebra ; IN: classes.tuple.parser diff --git a/core/combinators/combinators.factor b/core/combinators/combinators.factor index 7b9481825b..ce0d04c73c 100644 --- a/core/combinators/combinators.factor +++ b/core/combinators/combinators.factor @@ -147,7 +147,7 @@ ERROR: no-case object ; : contiguous-range? ( keys -- ? ) dup [ fixnum? ] all? [ dup all-unique? [ - [ prune length ] + [ length ] [ [ supremum ] [ infimum ] bi - ] bi - 1 = ] [ drop f ] if diff --git a/core/compiler/units/units.factor b/core/compiler/units/units.factor index b024ed2c65..ffbdbefbf2 100644 --- a/core/compiler/units/units.factor +++ b/core/compiler/units/units.factor @@ -4,6 +4,7 @@ USING: accessors arrays kernel continuations assocs namespaces sequences words vocabs definitions hashtables init sets math math.order classes classes.private classes.algebra classes.tuple classes.tuple.private generic source-files.errors kernel.private ; +FROM: namespaces => set ; IN: compiler.units SYMBOL: old-definitions diff --git a/core/destructors/destructors.factor b/core/destructors/destructors.factor index ac3751e32e..e6d78fa03e 100644 --- a/core/destructors/destructors.factor +++ b/core/destructors/destructors.factor @@ -2,6 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors continuations kernel namespaces make sequences vectors sets assocs init math ; +FROM: namespaces => set ; IN: destructors SYMBOL: disposables diff --git a/core/generic/generic.factor b/core/generic/generic.factor index 0c626ac1d6..a733ac90fa 100644 --- a/core/generic/generic.factor +++ b/core/generic/generic.factor @@ -4,6 +4,7 @@ USING: accessors words kernel sequences namespaces make assocs hashtables definitions kernel.private classes classes.private classes.algebra quotations arrays vocabs effects combinators sets ; +FROM: namespaces => set ; IN: generic ! Method combination protocol diff --git a/core/hash-sets/hash-sets-tests.factor b/core/hash-sets/hash-sets-tests.factor index 2eef2bd309..5b7ffafc8b 100644 --- a/core/hash-sets/hash-sets-tests.factor +++ b/core/hash-sets/hash-sets-tests.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2010 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. -USING: new-sets tools.test kernel sorting prettyprint hash-sets ; +USING: sets tools.test kernel sorting prettyprint hash-sets ; IN: hash-sets.tests [ { 1 2 3 } ] [ HS{ 1 2 3 } members natural-sort ] unit-test diff --git a/core/hash-sets/hash-sets.factor b/core/hash-sets/hash-sets.factor index 52b883195e..bdef9a6ff9 100644 --- a/core/hash-sets/hash-sets.factor +++ b/core/hash-sets/hash-sets.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2010 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs hashtables kernel new-sets +USING: accessors assocs hashtables kernel sets sequences parser ; QUALIFIED: sets IN: hash-sets diff --git a/core/sets/sets-tests.factor b/core/sets/sets-tests.factor index f9f8ba9e65..aa76a4f02e 100644 --- a/core/sets/sets-tests.factor +++ b/core/sets/sets-tests.factor @@ -1,26 +1,16 @@ -USING: kernel sets tools.test ; +! Copyright (C) 2010 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: sets tools.test kernel prettyprint hash-sets sorting ; IN: sets.tests -[ f ] [ { 0 1 1 2 3 5 } all-unique? ] unit-test -[ t ] [ { 0 1 2 3 4 5 } all-unique? ] unit-test - -[ V{ 1 2 3 } ] [ { 1 2 2 3 3 } prune ] unit-test -[ V{ 3 2 1 } ] [ { 3 3 2 2 1 } prune ] unit-test - [ { } ] [ { } { } intersect ] unit-test [ { 2 3 } ] [ { 1 2 3 } { 2 3 4 } intersect ] unit-test [ { } ] [ { } { } diff ] unit-test [ { 1 } ] [ { 1 2 3 } { 2 3 4 } diff ] unit-test -[ V{ } ] [ { } { } union ] unit-test -[ V{ 1 2 3 4 } ] [ { 1 2 3 } { 2 3 4 } union ] unit-test - -[ V{ 1 2 3 } ] -[ 3 V{ 1 2 } clone [ adjoin ] keep ] unit-test - -[ V{ 1 2 3 } ] -[ 3 V{ 1 3 2 } clone [ adjoin ] keep ] unit-test +[ { } ] [ { } { } union ] unit-test +[ { 1 2 3 4 } ] [ { 1 2 3 } { 2 3 4 } union ] unit-test [ t ] [ { 1 2 } { 1 3 } intersects? ] unit-test @@ -30,3 +20,34 @@ IN: sets.tests [ f ] [ { 1 } { } intersects? ] unit-test +[ t ] [ 4 { 2 4 5 } in? ] unit-test +[ f ] [ 1 { 2 4 5 } in? ] unit-test + +[ V{ 1 2 3 } ] [ 3 V{ 1 2 } clone [ adjoin ] keep ] unit-test +[ V{ 1 2 } ] [ 2 V{ 1 2 } clone [ adjoin ] keep ] unit-test +[ V{ 1 2 } ] [ 3 V{ 1 2 } clone [ delete ] keep ] unit-test +[ V{ 2 } ] [ 1 V{ 1 2 } clone [ delete ] keep ] unit-test + +[ t ] [ { 1 2 3 } { 2 1 3 } set= ] unit-test +[ f ] [ { 2 3 } { 1 2 3 } set= ] unit-test +[ f ] [ { 1 2 3 } { 2 3 } set= ] unit-test + +[ { 1 } ] [ { 1 } members ] unit-test + +[ { 1 2 3 } ] [ { 1 1 1 2 2 3 3 3 3 3 } dup set-like natural-sort ] unit-test +[ { 1 2 3 } ] [ HS{ 1 2 3 } { } set-like natural-sort ] unit-test + +[ HS{ 1 2 3 } ] [ { 1 2 3 } fast-set ] unit-test + +[ { 1 2 3 } ] [ { { 1 } { 2 } { 1 3 } } combine ] unit-test + +[ f ] [ { 0 1 1 2 3 5 } all-unique? ] unit-test +[ t ] [ { 0 1 2 3 4 5 } all-unique? ] unit-test + +[ { 1 2 3 } ] [ { 1 2 2 3 3 } { } set-like ] unit-test +[ { 3 2 1 } ] [ { 3 3 2 2 1 } { } set-like ] unit-test + +[ { 2 1 2 1 } ] [ { 1 2 3 2 1 2 1 } duplicates ] unit-test +[ f ] [ HS{ 1 2 3 1 2 1 } duplicates ] unit-test + +[ H{ { 3 HS{ 1 2 } } } ] [ H{ } clone 1 3 pick adjoin-at 2 3 pick adjoin-at ] unit-test diff --git a/core/sets/sets.factor b/core/sets/sets.factor index 38c1f73bb3..550b906b55 100644 --- a/core/sets/sets.factor +++ b/core/sets/sets.factor @@ -1,59 +1,112 @@ -! Copyright (C) 2008, 2009 Slava Pestov, Doug Coleman. +! Copyright (C) 2010 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. -USING: assocs hashtables kernel sequences vectors ; +USING: accessors assocs hashtables kernel vectors +math sequences ; IN: sets -: adjoin ( elt seq -- ) [ remove! drop ] [ push ] 2bi ; +! Set protocol +MIXIN: set +GENERIC: adjoin ( elt set -- ) +GENERIC: in? ( elt set -- ? ) +GENERIC: delete ( elt set -- ) +GENERIC: set-like ( set exemplar -- set' ) +GENERIC: fast-set ( set -- set' ) +GENERIC: members ( set -- sequence ) +GENERIC: union ( set1 set2 -- set ) +GENERIC: intersect ( set1 set2 -- set ) +GENERIC: intersects? ( set1 set2 -- ? ) +GENERIC: diff ( set1 set2 -- set ) +GENERIC: subset? ( set1 set2 -- ? ) +GENERIC: set= ( set1 set2 -- ? ) +GENERIC: duplicates ( set -- sequence ) +GENERIC: all-unique? ( set -- ? ) -: conjoin ( elt assoc -- ) dupd set-at ; +! Defaults for some methods. +! Override them for efficiency -: conjoin-at ( value key assoc -- ) - [ dupd ?set-at ] change-at ; - -: (prune) ( elt hash vec -- ) - 3dup drop key? [ 3drop ] [ - [ drop conjoin ] [ nip push ] 3bi - ] if ; inline - -: prune ( seq -- newseq ) - [ ] [ length ] [ length ] tri - [ [ (prune) ] 2curry each ] keep ; - -: duplicates ( seq -- newseq ) - H{ } clone [ [ key? ] [ conjoin ] 2bi ] curry filter ; - -: gather ( seq quot -- newseq ) - map concat prune ; inline - -: unique ( seq -- assoc ) - [ dup ] H{ } map>assoc ; - -: (all-unique?) ( elt hash -- ? ) - 2dup key? [ 2drop f ] [ conjoin t ] if ; - -: all-unique? ( seq -- ? ) - dup length [ (all-unique?) ] curry all? ; +M: set union + [ [ members ] bi@ append ] keep set-like ; -: intersect ( seq1 seq2 -- newseq ) - tester filter ; +M: set intersect + [ sequence/tester filter ] keep set-like ; -: intersects? ( seq1 seq2 -- ? ) - tester any? ; +M: set diff + [ sequence/tester [ not ] compose filter ] keep set-like ; -: diff ( seq1 seq2 -- newseq ) - tester [ not ] compose filter ; +M: set intersects? + sequence/tester any? ; -: union ( seq1 seq2 -- newseq ) - append prune ; +M: set subset? + sequence/tester all? ; + +M: set set= + 2dup subset? [ swap subset? ] [ 2drop f ] if ; -: subset? ( seq1 seq2 -- ? ) - tester all? ; +M: set fast-set ; -: set= ( seq1 seq2 -- ? ) - [ unique ] bi@ = ; +M: set duplicates drop f ; + +M: set all-unique? drop t ; + + ] bi + [ [ (pruned) ] 2curry each ] keep ; + +PRIVATE> + +! Sequences are sets +INSTANCE: sequence set + +M: sequence in? + member? ; inline + +M: sequence adjoin + [ delete ] [ push ] 2bi ; + +M: sequence delete + remove! drop ; inline + +M: sequence set-like + [ members ] dip like ; + +M: sequence members + [ pruned ] keep like ; + +M: sequence all-unique? + dup pruned sequence= ; + +: combine ( sets -- set ) + f [ union ] reduce ; + +: gather ( seq quot -- newseq ) + map concat members ; inline + +: adjoin-at ( value key assoc -- ) + [ [ f fast-set ] unless* [ adjoin ] keep ] change-at ; + +! Temporarily for compatibility + +ALIAS: prune members +: unique ( seq -- assoc ) + [ dup ] H{ } map>assoc ; +: conjoin ( elt assoc -- ) + dupd set-at ; +: conjoin-at ( value key assoc -- ) + [ dupd ?set-at ] change-at ; From dfd99199a376caa70ad519b96ff4e7e5b78ee074 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 26 Feb 2010 13:20:47 -0800 Subject: [PATCH 267/713] grouping: circular-slice shouldn't be a subclass of slice since that thwarts method inlining --- basis/grouping/grouping.factor | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/basis/grouping/grouping.factor b/basis/grouping/grouping.factor index 0dced6ad9d..304fd50fcc 100644 --- a/basis/grouping/grouping.factor +++ b/basis/grouping/grouping.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2005, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel math math.order strings arrays vectors sequences -sequences.private accessors fry combinators.short-circuit ; +sequences.private accessors fry combinators.short-circuit +combinators ; IN: grouping > ] [ from>> ] bi - ; inline +M: circular-slice virtual-exemplar seq>> ; inline M: circular-slice virtual@ [ from>> + ] [ seq>> ] bi [ length slice-mod ] keep ; inline From 6298203b4c81ebe4cd1f67a4d525587bfd6c85ad Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Fri, 26 Feb 2010 16:28:38 -0500 Subject: [PATCH 268/713] Making all of basis and extra unambiguous for sets/namespaces --- .../cfg/linear-scan/debugger/debugger.factor | 1 + basis/farkup/farkup.factor | 1 + basis/smtp/smtp.factor | 1 + basis/xml/elements/elements.factor | 1 + core/new-sets/new-sets-tests.factor | 53 --------- core/new-sets/new-sets.factor | 106 ------------------ extra/koszul/koszul.factor | 1 + extra/managed-server/chat/chat.factor | 1 + extra/managed-server/managed-server.factor | 1 + extra/multi-methods/multi-methods.factor | 1 + extra/project-euler/051/051.factor | 1 + 11 files changed, 9 insertions(+), 159 deletions(-) delete mode 100644 core/new-sets/new-sets-tests.factor delete mode 100644 core/new-sets/new-sets.factor diff --git a/basis/compiler/cfg/linear-scan/debugger/debugger.factor b/basis/compiler/cfg/linear-scan/debugger/debugger.factor index fa248dd4e8..d93ebcccf0 100644 --- a/basis/compiler/cfg/linear-scan/debugger/debugger.factor +++ b/basis/compiler/cfg/linear-scan/debugger/debugger.factor @@ -3,6 +3,7 @@ USING: accessors kernel sequences sets arrays math strings fry namespaces prettyprint compiler.cfg.linear-scan.live-intervals compiler.cfg.linear-scan.allocation compiler.cfg assocs ; +FROM: namespaces => set ; IN: compiler.cfg.linear-scan.debugger : check-linear-scan ( live-intervals machine-registers -- ) diff --git a/basis/farkup/farkup.factor b/basis/farkup/farkup.factor index 5795438570..fe9bc78ec6 100644 --- a/basis/farkup/farkup.factor +++ b/basis/farkup/farkup.factor @@ -4,6 +4,7 @@ USING: sequences kernel splitting lists fry accessors assocs math.order math combinators namespaces urls.encoding xml.syntax xmode.code2html xml.data arrays strings vectors xml.writer io.streams.string locals unicode.categories ; +FROM: namespaces => set ; IN: farkup SYMBOL: relative-link-prefix diff --git a/basis/smtp/smtp.factor b/basis/smtp/smtp.factor index 61ccd5c435..045c08df42 100644 --- a/basis/smtp/smtp.factor +++ b/basis/smtp/smtp.factor @@ -7,6 +7,7 @@ io.encodings.ascii io.timeouts io.sockets io.sockets.secure io.crlf kernel logging sequences combinators splitting assocs strings math.order math.parser random system calendar summary calendar.format accessors sets hashtables base64 debugger classes prettyprint words ; +FROM: namespaces => set ; IN: smtp SYMBOL: smtp-domain diff --git a/basis/xml/elements/elements.factor b/basis/xml/elements/elements.factor index b927947329..1e59c19909 100644 --- a/basis/xml/elements/elements.factor +++ b/basis/xml/elements/elements.factor @@ -4,6 +4,7 @@ USING: kernel namespaces xml.tokenize xml.state xml.name xml.data accessors arrays make xml.char-classes fry assocs sequences math xml.errors sets combinators io.encodings io.encodings.iana unicode.case xml.dtd strings xml.entities unicode.categories ; +FROM: namespaces => set ; IN: xml.elements : take-interpolated ( quot -- interpolated ) diff --git a/core/new-sets/new-sets-tests.factor b/core/new-sets/new-sets-tests.factor deleted file mode 100644 index b644b9a809..0000000000 --- a/core/new-sets/new-sets-tests.factor +++ /dev/null @@ -1,53 +0,0 @@ -! Copyright (C) 2010 Daniel Ehrenberg -! See http://factorcode.org/license.txt for BSD license. -USING: new-sets tools.test kernel prettyprint hash-sets sorting ; -IN: new-sets.tests - -[ { } ] [ { } { } intersect ] unit-test -[ { 2 3 } ] [ { 1 2 3 } { 2 3 4 } intersect ] unit-test - -[ { } ] [ { } { } diff ] unit-test -[ { 1 } ] [ { 1 2 3 } { 2 3 4 } diff ] unit-test - -[ { } ] [ { } { } union ] unit-test -[ { 1 2 3 4 } ] [ { 1 2 3 } { 2 3 4 } union ] unit-test - -[ t ] [ { 1 2 } { 1 3 } intersects? ] unit-test - -[ f ] [ { 4 2 } { 1 3 } intersects? ] unit-test - -[ f ] [ { } { 1 } intersects? ] unit-test - -[ f ] [ { 1 } { } intersects? ] unit-test - -[ t ] [ 4 { 2 4 5 } in? ] unit-test -[ f ] [ 1 { 2 4 5 } in? ] unit-test - -[ V{ 1 2 3 } ] [ 3 V{ 1 2 } clone [ adjoin ] keep ] unit-test -[ V{ 1 2 } ] [ 2 V{ 1 2 } clone [ adjoin ] keep ] unit-test -[ V{ 1 2 } ] [ 3 V{ 1 2 } clone [ delete ] keep ] unit-test -[ V{ 2 } ] [ 1 V{ 1 2 } clone [ delete ] keep ] unit-test - -[ t ] [ { 1 2 3 } { 2 1 3 } set= ] unit-test -[ f ] [ { 2 3 } { 1 2 3 } set= ] unit-test -[ f ] [ { 1 2 3 } { 2 3 } set= ] unit-test - -[ { 1 } ] [ { 1 } members ] unit-test - -[ { 1 2 3 } ] [ { 1 1 1 2 2 3 3 3 3 3 } dup set-like natural-sort ] unit-test -[ { 1 2 3 } ] [ HS{ 1 2 3 } { } set-like natural-sort ] unit-test - -[ HS{ 1 2 3 } ] [ { 1 2 3 } fast-set ] unit-test - -[ { 1 2 3 } ] [ { { 1 } { 2 } { 1 3 } } combine ] unit-test - -[ f ] [ { 0 1 1 2 3 5 } all-unique? ] unit-test -[ t ] [ { 0 1 2 3 4 5 } all-unique? ] unit-test - -[ { 1 2 3 } ] [ { 1 2 2 3 3 } { } set-like ] unit-test -[ { 3 2 1 } ] [ { 3 3 2 2 1 } { } set-like ] unit-test - -[ { 2 1 2 1 } ] [ { 1 2 3 2 1 2 1 } duplicates ] unit-test -[ f ] [ HS{ 1 2 3 1 2 1 } duplicates ] unit-test - -[ H{ { 3 HS{ 1 2 } } } ] [ H{ } clone 1 3 pick adjoin-at 2 3 pick adjoin-at ] unit-test diff --git a/core/new-sets/new-sets.factor b/core/new-sets/new-sets.factor deleted file mode 100644 index bc4e720c9c..0000000000 --- a/core/new-sets/new-sets.factor +++ /dev/null @@ -1,106 +0,0 @@ -! Copyright (C) 2010 Daniel Ehrenberg -! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs hashtables kernel vectors -math sequences ; -IN: new-sets - -! Set protocol -MIXIN: set -GENERIC: adjoin ( elt set -- ) -GENERIC: in? ( elt set -- ? ) -GENERIC: delete ( elt set -- ) -GENERIC: set-like ( set exemplar -- set' ) -GENERIC: fast-set ( set -- set' ) -GENERIC: members ( set -- sequence ) -GENERIC: union ( set1 set2 -- set ) -GENERIC: intersect ( set1 set2 -- set ) -GENERIC: intersects? ( set1 set2 -- ? ) -GENERIC: diff ( set1 set2 -- set ) -GENERIC: subset? ( set1 set2 -- ? ) -GENERIC: set= ( set1 set2 -- ? ) -GENERIC: duplicates ( set -- sequence ) -GENERIC: all-unique? ( set -- ? ) - -! Defaults for some methods. -! Override them for efficiency - -M: set union - [ [ members ] bi@ append ] keep set-like ; - - - -M: set intersect - [ sequence/tester filter ] keep set-like ; - -M: set diff - [ sequence/tester [ not ] compose filter ] keep set-like ; - -M: set intersects? - sequence/tester any? ; - -M: set subset? - sequence/tester all? ; - -M: set set= - 2dup subset? [ swap subset? ] [ 2drop f ] if ; - -M: set fast-set ; - -M: set duplicates drop f ; - -M: set all-unique? drop t ; - - ] bi - [ [ (prune) ] 2curry each ] keep ; - -PRIVATE> - -! Sequences are sets -INSTANCE: sequence set - -M: sequence in? - member? ; inline - -M: sequence adjoin - [ delete ] [ push ] 2bi ; - -M: sequence delete - remove! drop ; inline - -M: sequence set-like - [ members ] dip like ; - -M: sequence members - [ prune ] keep like ; - -M: sequence all-unique? - dup prune sequence= ; - -! Some sequence methods are defined using hash-sets -USE: vocabs.loader -"hash-sets" require - -: combine ( sets -- set ) - f [ union ] reduce ; - -: gather ( seq quot -- newseq ) - map concat members ; inline - -: adjoin-at ( value key assoc -- ) - [ [ f fast-set ] unless* [ adjoin ] keep ] change-at ; diff --git a/extra/koszul/koszul.factor b/extra/koszul/koszul.factor index c35ba6ac8c..81086e8064 100644 --- a/extra/koszul/koszul.factor +++ b/extra/koszul/koszul.factor @@ -4,6 +4,7 @@ USING: accessors arrays hashtables assocs io kernel locals math math.vectors math.matrices math.matrices.elimination namespaces parser prettyprint sequences words combinators math.parser splitting sorting shuffle sets math.order ; +FROM: namespaces => set ; IN: koszul ! Utilities diff --git a/extra/managed-server/chat/chat.factor b/extra/managed-server/chat/chat.factor index e75a2803e6..ecf36bcfbb 100644 --- a/extra/managed-server/chat/chat.factor +++ b/extra/managed-server/chat/chat.factor @@ -5,6 +5,7 @@ destructors fry io io.encodings.utf8 kernel managed-server namespaces parser sequences sorting splitting strings.parser unicode.case unicode.categories calendar calendar.format locals io.encodings.binary io.encodings.string prettyprint ; +FROM: namespaces => set ; IN: managed-server.chat TUPLE: chat-server < managed-server ; diff --git a/extra/managed-server/managed-server.factor b/extra/managed-server/managed-server.factor index 6f9bdf25f1..acb3c84825 100644 --- a/extra/managed-server/managed-server.factor +++ b/extra/managed-server/managed-server.factor @@ -5,6 +5,7 @@ io.encodings.binary io.servers.connection io.sockets io.streams.duplex fry kernel locals math math.ranges multiline namespaces prettyprint random sequences sets splitting threads tools.continuations ; +FROM: namespaces => set ; IN: managed-server TUPLE: managed-server < threaded-server clients ; diff --git a/extra/multi-methods/multi-methods.factor b/extra/multi-methods/multi-methods.factor index caf37dbadb..a65e459a7c 100644 --- a/extra/multi-methods/multi-methods.factor +++ b/extra/multi-methods/multi-methods.factor @@ -6,6 +6,7 @@ definitions prettyprint prettyprint.backend prettyprint.custom quotations generalizations debugger io compiler.units kernel.private effects accessors hashtables sorting shuffle math.order sets see effects.parser ; +FROM: namespaces => set ; IN: multi-methods ! PART I: Converting hook specializers diff --git a/extra/project-euler/051/051.factor b/extra/project-euler/051/051.factor index ff45e9e58a..f0bdd69901 100644 --- a/extra/project-euler/051/051.factor +++ b/extra/project-euler/051/051.factor @@ -29,6 +29,7 @@ USING: assocs kernel math math.combinatorics math.functions math.parser math.primes namespaces project-euler.common sequences sets strings grouping math.ranges arrays fry math.order ; +FROM: namespaces => set ; IN: project-euler.051 Date: Fri, 26 Feb 2010 17:17:40 -0500 Subject: [PATCH 269/713] Fixing ambiguity between sets and namespaces in many unit tests and furnace.auth --- .../cfg/linear-scan/linear-scan-tests.factor | 3 ++- .../cfg/ssa/construction/tdmsc/tdmsc-tests.factor | 3 ++- basis/furnace/auth/auth.factor | 1 + basis/help/crossref/crossref-tests.factor | 2 +- basis/regexp/classes/classes-tests.factor | 2 +- basis/suffix-arrays/suffix-arrays-tests.factor | 12 ++++++------ basis/tools/deploy/shaker/shaker.factor | 1 + basis/ui/gadgets/gadgets-tests.factor | 9 +++++---- core/alien/alien-tests.factor | 3 ++- core/generic/single/single-tests.factor | 1 + 10 files changed, 22 insertions(+), 15 deletions(-) diff --git a/basis/compiler/cfg/linear-scan/linear-scan-tests.factor b/basis/compiler/cfg/linear-scan/linear-scan-tests.factor index c144b5f07f..dcf2e743ec 100644 --- a/basis/compiler/cfg/linear-scan/linear-scan-tests.factor +++ b/basis/compiler/cfg/linear-scan/linear-scan-tests.factor @@ -1,4 +1,3 @@ -IN: compiler.cfg.linear-scan.tests USING: tools.test random sorting sequences sets hashtables assocs kernel fry arrays splitting namespaces math accessors vectors locals math.order grouping strings strings.private classes layouts @@ -21,6 +20,8 @@ compiler.cfg.linear-scan.allocation.state compiler.cfg.linear-scan.allocation.splitting compiler.cfg.linear-scan.allocation.spilling compiler.cfg.linear-scan.debugger ; +FROM: namespaces => set ; +IN: compiler.cfg.linear-scan.tests check-allocation? on check-numbering? on diff --git a/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc-tests.factor b/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc-tests.factor index 955d41814f..9b24c55078 100644 --- a/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc-tests.factor +++ b/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc-tests.factor @@ -2,6 +2,7 @@ USING: accessors arrays compiler.cfg compiler.cfg.debugger compiler.cfg.dominance compiler.cfg.predecessors compiler.cfg.ssa.construction.tdmsc kernel namespaces sequences tools.test vectors sets ; +FROM: namespaces => set ; IN: compiler.cfg.ssa.construction.tdmsc.tests : test-tdmsc ( -- ) @@ -70,4 +71,4 @@ V{ } 7 test-bb [ ] [ test-tdmsc ] unit-test [ V{ 2 } ] [ { 2 3 4 5 } [ get ] map merge-set [ number>> ] map ] unit-test -[ V{ } ] [ { 0 1 6 7 } [ get ] map merge-set ] unit-test \ No newline at end of file +[ V{ } ] [ { 0 1 6 7 } [ get ] map merge-set ] unit-test diff --git a/basis/furnace/auth/auth.factor b/basis/furnace/auth/auth.factor index 831ec7f8fc..e7f868759f 100644 --- a/basis/furnace/auth/auth.factor +++ b/basis/furnace/auth/auth.factor @@ -14,6 +14,7 @@ furnace.redirection furnace.boilerplate furnace.auth.providers furnace.auth.providers.db ; +FROM: namespaces => set ; IN: furnace.auth SYMBOL: logged-in-user diff --git a/basis/help/crossref/crossref-tests.factor b/basis/help/crossref/crossref-tests.factor index 6fb4c562cf..99f40622ea 100644 --- a/basis/help/crossref/crossref-tests.factor +++ b/basis/help/crossref/crossref-tests.factor @@ -62,4 +62,4 @@ ARTICLE: "crossref-test-1" "Crossref test 1" ARTICLE: "crossref-test-2" "Crossref test 2" { $markup-example { $subsection "crossref-test-1" } } ; -[ V{ } ] [ "crossref-test-2" >link article-children ] unit-test +[ { } ] [ "crossref-test-2" >link article-children ] unit-test diff --git a/basis/regexp/classes/classes-tests.factor b/basis/regexp/classes/classes-tests.factor index e2db86f6c1..4044a059a5 100644 --- a/basis/regexp/classes/classes-tests.factor +++ b/basis/regexp/classes/classes-tests.factor @@ -36,7 +36,7 @@ IN: regexp.classes.tests ! Making classes into nested conditionals -[ V{ 1 2 3 4 } ] [ T{ and-class f { 1 T{ not-class f 2 } T{ or-class f { 3 4 } } 2 } } class>questions ] unit-test +[ { 1 2 3 4 } ] [ T{ and-class f { 1 T{ not-class f 2 } T{ or-class f { 3 4 } } 2 } } class>questions ] unit-test [ { 3 } ] [ { { 3 t } } table>condition ] unit-test [ { T{ primitive-class } } ] [ { { 1 t } { 2 T{ primitive-class } } } table>questions ] unit-test [ { { 1 t } { 2 t } } ] [ { { 1 t } { 2 T{ primitive-class } } } T{ primitive-class } t assoc-answer ] unit-test diff --git a/basis/suffix-arrays/suffix-arrays-tests.factor b/basis/suffix-arrays/suffix-arrays-tests.factor index 5149804ce6..f9de4979ab 100644 --- a/basis/suffix-arrays/suffix-arrays-tests.factor +++ b/basis/suffix-arrays/suffix-arrays-tests.factor @@ -25,14 +25,14 @@ IN: suffix-arrays.tests [ { } ] [ SA{ } "something" swap query ] unit-test -[ V{ "unit-test" "(unit-test)" } ] +[ { "unit-test" "(unit-test)" } ] [ "suffix-array" get "unit-test" swap query ] unit-test [ t ] [ "suffix-array" get "something else" swap query empty? ] unit-test -[ V{ "rofl" } ] [ SA{ "rofl" } "r" swap query ] unit-test -[ V{ "rofl" } ] [ SA{ "rofl" } "o" swap query ] unit-test -[ V{ "rofl" } ] [ SA{ "rofl" } "f" swap query ] unit-test -[ V{ "rofl" } ] [ SA{ "rofl" } "l" swap query ] unit-test -[ V{ } ] [ SA{ "rofl" } "t" swap query ] unit-test +[ { "rofl" } ] [ SA{ "rofl" } "r" swap query ] unit-test +[ { "rofl" } ] [ SA{ "rofl" } "o" swap query ] unit-test +[ { "rofl" } ] [ SA{ "rofl" } "f" swap query ] unit-test +[ { "rofl" } ] [ SA{ "rofl" } "l" swap query ] unit-test +[ { } ] [ SA{ "rofl" } "t" swap query ] unit-test diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index 9a5f89fae0..73d4b919d5 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -20,6 +20,7 @@ QUALIFIED: source-files QUALIFIED: source-files.errors QUALIFIED: vocabs FROM: alien.libraries.private => >deployed-library-path ; +FROM: namespaces => set ; IN: tools.deploy.shaker ! This file is some hairy shit. diff --git a/basis/ui/gadgets/gadgets-tests.factor b/basis/ui/gadgets/gadgets-tests.factor index ea16abb9ba..e9d677537c 100644 --- a/basis/ui/gadgets/gadgets-tests.factor +++ b/basis/ui/gadgets/gadgets-tests.factor @@ -2,6 +2,7 @@ USING: accessors ui.gadgets ui.gadgets.packs ui.gadgets.worlds tools.test namespaces models kernel dlists deques math math.parser ui sequences hashtables assocs io arrays prettyprint io.streams.string math.rectangles ui.gadgets.private sets generic ; +FROM: namespaces => set ; IN: ui.gadgets.tests [ { 300 300 } ] @@ -126,16 +127,16 @@ M: mock-gadget ungraft* ] each-integer ; : status-flags ( -- seq ) - { "g" "1" "2" "3" } [ get graft-state>> ] map prune ; + { "g" "1" "2" "3" } [ get graft-state>> ] map members ; : notify-combo ( ? ? -- ) nl "===== Combo: " write 2dup 2array . nl \ graft-queue [ "g" set [ ] [ add-some-children ] unit-test - [ V{ { f f } } ] [ status-flags ] unit-test + [ { { f f } } ] [ status-flags ] unit-test [ ] [ "g" get graft ] unit-test - [ V{ { f t } } ] [ status-flags ] unit-test + [ { { f t } } ] [ status-flags ] unit-test dup [ [ ] [ notify-queued ] unit-test ] when [ ] [ "g" get clear-gadget ] unit-test [ [ t ] [ graft-queue [ front>> ] [ back>> ] bi eq? ] unit-test ] unless @@ -146,7 +147,7 @@ M: mock-gadget ungraft* [ { f t } ] [ "3" get graft-state>> ] unit-test [ ] [ graft-queue [ "x" print notify ] slurp-deque ] unit-test [ ] [ notify-queued ] unit-test - [ V{ { t t } } ] [ status-flags ] unit-test + [ { { t t } } ] [ status-flags ] unit-test ] with-variable ; { { f f } { f t } { t f } { t t } } [ notify-combo ] assoc-each diff --git a/core/alien/alien-tests.factor b/core/alien/alien-tests.factor index 7eaa5cc50b..3321dbe2ed 100644 --- a/core/alien/alien-tests.factor +++ b/core/alien/alien-tests.factor @@ -1,6 +1,7 @@ USING: accessors alien alien.accessors alien.syntax byte-arrays arrays kernel kernel.private namespaces tools.test sequences libc math system prettyprint layouts alien.libraries sets ; +FROM: namespaces => set ; IN: alien.tests [ t ] [ -1 alien-address 0 > ] unit-test @@ -83,4 +84,4 @@ f initialize-test set-global [ 7575 ] [ initialize-test [ 7575 ] initialize-alien ] unit-test -[ V{ BAD-ALIEN } ] [ { BAD-ALIEN BAD-ALIEN BAD-ALIEN } prune ] unit-test \ No newline at end of file +[ { BAD-ALIEN } ] [ { BAD-ALIEN BAD-ALIEN BAD-ALIEN } members ] unit-test diff --git a/core/generic/single/single-tests.factor b/core/generic/single/single-tests.factor index cee99a828e..6be03042cb 100644 --- a/core/generic/single/single-tests.factor +++ b/core/generic/single/single-tests.factor @@ -5,6 +5,7 @@ quotations stack-checker vectors growable hashtables sbufs prettyprint byte-vectors bit-vectors specialized-vectors definitions generic sets graphs assocs grouping see eval ; QUALIFIED-WITH: alien.c-types c +FROM: namespaces => set ; SPECIALIZED-VECTOR: c:double IN: generic.single.tests From 013760a90687c41f40d8aae84bddbcba519c50ac Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 26 Feb 2010 18:16:16 -0800 Subject: [PATCH 270/713] co-credit William Schlieper for game.input.linux --- basis/game/input/linux/authors.txt | 3 ++- basis/game/input/linux/linux.factor | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/basis/game/input/linux/authors.txt b/basis/game/input/linux/authors.txt index 67cf648cf5..d73be90188 100644 --- a/basis/game/input/linux/authors.txt +++ b/basis/game/input/linux/authors.txt @@ -1 +1,2 @@ -Erik Charlebois \ No newline at end of file +Erik Charlebois +William Schlieper diff --git a/basis/game/input/linux/linux.factor b/basis/game/input/linux/linux.factor index 07889c8298..a1b9c57def 100644 --- a/basis/game/input/linux/linux.factor +++ b/basis/game/input/linux/linux.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2010 Erik Charlebois. +! Copyright (C) 2010 Erik Charlebois, William Schlieper. ! See http://factorcode.org/license.txt for BSD license. USING: alien.c-types alien.syntax arrays kernel game.input namespaces classes bit-arrays sequences vectors x11 x11.xlib ; From 3d479927d79c4a06b06f946309bbe3d68fd37d68 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 26 Feb 2010 18:21:37 -0800 Subject: [PATCH 271/713] move XQueryKeymap binding to x11.xlib --- basis/game/input/linux/linux.factor | 75 ++++++++++++++--------------- basis/x11/xlib/xlib.factor | 5 ++ 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/basis/game/input/linux/linux.factor b/basis/game/input/linux/linux.factor index a1b9c57def..cd482ae604 100644 --- a/basis/game/input/linux/linux.factor +++ b/basis/game/input/linux/linux.factor @@ -42,49 +42,48 @@ M: linux-game-input-backend vibrate-controller 3drop ; CONSTANT: x>hid-bit-order { - -0 0 0 0 0 0 0 0 -0 41 30 31 32 33 34 35 -36 37 38 39 45 46 42 43 -20 26 8 21 23 28 24 12 -18 19 47 48 40 224 4 22 -7 9 10 11 13 14 15 51 -52 53 225 49 29 27 6 25 -5 17 16 54 55 56 229 85 -226 44 57 58 59 60 61 62 -63 64 65 66 67 83 71 95 -96 97 86 92 93 94 87 91 -90 89 98 99 0 0 0 68 -69 0 0 0 0 0 0 0 -88 228 84 70 0 0 74 82 -75 80 79 77 81 78 73 76 -127 129 128 102 103 0 72 0 -0 0 0 227 231 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 41 30 31 32 33 34 35 + 36 37 38 39 45 46 42 43 + 20 26 8 21 23 28 24 12 + 18 19 47 48 40 224 4 22 + 7 9 10 11 13 14 15 51 + 52 53 225 49 29 27 6 25 + 5 17 16 54 55 56 229 85 + 226 44 57 58 59 60 61 62 + 63 64 65 66 67 83 71 95 + 96 97 86 92 93 94 87 91 + 90 89 98 99 0 0 0 68 + 69 0 0 0 0 0 0 0 + 88 228 84 70 0 0 74 82 + 75 80 79 77 81 78 73 76 + 127 129 128 102 103 0 72 0 + 0 0 0 227 231 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 } : x-bits>hid-bits ( bit-array -- bit-array ) - 256 iota [ 2array ] { } 2map-as [ first ] filter [ second ] map - x>hid-bit-order [ nth ] curry map - 256 swap [ t swap pick set-nth ] each ; + 256 iota [ 2array ] { } 2map-as [ first ] filter [ second ] map + x>hid-bit-order [ nth ] curry map + 256 swap [ t swap pick set-nth ] each ; M: linux-game-input-backend read-keyboard - dpy get 256 [ XQueryKeymap drop ] keep - x-bits>hid-bits keyboard-state boa ; + dpy get 256 [ XQueryKeymap drop ] keep + x-bits>hid-bits keyboard-state boa ; M: linux-game-input-backend read-mouse 0 0 0 0 2 mouse-state boa ; diff --git a/basis/x11/xlib/xlib.factor b/basis/x11/xlib/xlib.factor index e86bb5e8c3..1c5ff2e3ef 100644 --- a/basis/x11/xlib/xlib.factor +++ b/basis/x11/xlib/xlib.factor @@ -1406,3 +1406,8 @@ X-FUNCTION: c-string setlocale ( int category, c-string name ) ; X-FUNCTION: Bool XSupportsLocale ( ) ; X-FUNCTION: c-string XSetLocaleModifiers ( c-string modifier_list ) ; + +! uncategorized xlib bindings + +X-FUNCTION: int XQueryKeymap ( Display* display, char[32] keys_return ) ; + From 09517a87e3eba441b9bc301a4672be6401b3b7a5 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 26 Feb 2010 18:30:51 -0800 Subject: [PATCH 272/713] rename game.input.linux to game.input.x11, make x>hid-bit-order a hook on system --- basis/game/input/input.factor | 2 +- basis/game/input/linux/linux.factor | 92 ------------------- basis/game/input/{linux => x11}/authors.txt | 0 basis/game/input/{linux => x11}/platforms.txt | 0 basis/game/input/{linux => x11}/summary.txt | 0 basis/game/input/{linux => x11}/tags.txt | 0 basis/game/input/x11/x11.factor | 92 +++++++++++++++++++ 7 files changed, 93 insertions(+), 93 deletions(-) delete mode 100644 basis/game/input/linux/linux.factor rename basis/game/input/{linux => x11}/authors.txt (100%) rename basis/game/input/{linux => x11}/platforms.txt (100%) rename basis/game/input/{linux => x11}/summary.txt (100%) rename basis/game/input/{linux => x11}/tags.txt (100%) create mode 100644 basis/game/input/x11/x11.factor diff --git a/basis/game/input/input.factor b/basis/game/input/input.factor index f27e1f36d1..9b514e77e0 100644 --- a/basis/game/input/input.factor +++ b/basis/game/input/input.factor @@ -108,6 +108,6 @@ SYMBOLS: pressed released ; { { [ os windows? ] [ "game.input.xinput" require ] } { [ os macosx? ] [ "game.input.iokit" require ] } - { [ os linux? ] [ "game.input.linux" require ] } + { [ os linux? ] [ "game.input.x11" require ] } [ ] } cond diff --git a/basis/game/input/linux/linux.factor b/basis/game/input/linux/linux.factor deleted file mode 100644 index cd482ae604..0000000000 --- a/basis/game/input/linux/linux.factor +++ /dev/null @@ -1,92 +0,0 @@ -! Copyright (C) 2010 Erik Charlebois, William Schlieper. -! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.syntax arrays kernel game.input namespaces -classes bit-arrays sequences vectors x11 x11.xlib ; -IN: game.input.linux - -LIBRARY: xlib -FUNCTION: int XQueryKeymap ( Display* display, char[32] keys_return ) ; - -SINGLETON: linux-game-input-backend - -linux-game-input-backend game-input-backend set-global - -M: linux-game-input-backend (open-game-input) - ; - -M: linux-game-input-backend (close-game-input) - ; - -M: linux-game-input-backend (reset-game-input) - ; - -M: linux-game-input-backend get-controllers - { } ; - -M: linux-game-input-backend product-string - drop "" ; - -M: linux-game-input-backend product-id - drop f ; - -M: linux-game-input-backend instance-id - drop f ; - -M: linux-game-input-backend read-controller - drop controller-state new ; - -M: linux-game-input-backend calibrate-controller - drop ; - -M: linux-game-input-backend vibrate-controller - 3drop ; - -CONSTANT: x>hid-bit-order { - 0 0 0 0 0 0 0 0 - 0 41 30 31 32 33 34 35 - 36 37 38 39 45 46 42 43 - 20 26 8 21 23 28 24 12 - 18 19 47 48 40 224 4 22 - 7 9 10 11 13 14 15 51 - 52 53 225 49 29 27 6 25 - 5 17 16 54 55 56 229 85 - 226 44 57 58 59 60 61 62 - 63 64 65 66 67 83 71 95 - 96 97 86 92 93 94 87 91 - 90 89 98 99 0 0 0 68 - 69 0 0 0 0 0 0 0 - 88 228 84 70 0 0 74 82 - 75 80 79 77 81 78 73 76 - 127 129 128 102 103 0 72 0 - 0 0 0 227 231 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 -} - -: x-bits>hid-bits ( bit-array -- bit-array ) - 256 iota [ 2array ] { } 2map-as [ first ] filter [ second ] map - x>hid-bit-order [ nth ] curry map - 256 swap [ t swap pick set-nth ] each ; - -M: linux-game-input-backend read-keyboard - dpy get 256 [ XQueryKeymap drop ] keep - x-bits>hid-bits keyboard-state boa ; - -M: linux-game-input-backend read-mouse - 0 0 0 0 2 mouse-state boa ; - -M: linux-game-input-backend reset-mouse - ; diff --git a/basis/game/input/linux/authors.txt b/basis/game/input/x11/authors.txt similarity index 100% rename from basis/game/input/linux/authors.txt rename to basis/game/input/x11/authors.txt diff --git a/basis/game/input/linux/platforms.txt b/basis/game/input/x11/platforms.txt similarity index 100% rename from basis/game/input/linux/platforms.txt rename to basis/game/input/x11/platforms.txt diff --git a/basis/game/input/linux/summary.txt b/basis/game/input/x11/summary.txt similarity index 100% rename from basis/game/input/linux/summary.txt rename to basis/game/input/x11/summary.txt diff --git a/basis/game/input/linux/tags.txt b/basis/game/input/x11/tags.txt similarity index 100% rename from basis/game/input/linux/tags.txt rename to basis/game/input/x11/tags.txt diff --git a/basis/game/input/x11/x11.factor b/basis/game/input/x11/x11.factor new file mode 100644 index 0000000000..4e6f610531 --- /dev/null +++ b/basis/game/input/x11/x11.factor @@ -0,0 +1,92 @@ +! Copyright (C) 2010 Erik Charlebois, William Schlieper. +! See http://factorcode.org/license.txt for BSD license. +USING: arrays kernel game.input namespaces +classes bit-arrays system sequences vectors x11 x11.xlib ; +IN: game.input.x11 + +SINGLETON: x11-game-input-backend + +x11-game-input-backend game-input-backend set-global + +M: x11-game-input-backend (open-game-input) + ; + +M: x11-game-input-backend (close-game-input) + ; + +M: x11-game-input-backend (reset-game-input) + ; + +M: x11-game-input-backend get-controllers + { } ; + +M: x11-game-input-backend product-string + drop "" ; + +M: x11-game-input-backend product-id + drop f ; + +M: x11-game-input-backend instance-id + drop f ; + +M: x11-game-input-backend read-controller + drop controller-state new ; + +M: x11-game-input-backend calibrate-controller + drop ; + +M: x11-game-input-backend vibrate-controller + 3drop ; + +HOOK: x>hid-bit-order os ( -- x ) + +M: linux x>hid-bit-order + { + 0 0 0 0 0 0 0 0 + 0 41 30 31 32 33 34 35 + 36 37 38 39 45 46 42 43 + 20 26 8 21 23 28 24 12 + 18 19 47 48 40 224 4 22 + 7 9 10 11 13 14 15 51 + 52 53 225 49 29 27 6 25 + 5 17 16 54 55 56 229 85 + 226 44 57 58 59 60 61 62 + 63 64 65 66 67 83 71 95 + 96 97 86 92 93 94 87 91 + 90 89 98 99 0 0 0 68 + 69 0 0 0 0 0 0 0 + 88 228 84 70 0 0 74 82 + 75 80 79 77 81 78 73 76 + 127 129 128 102 103 0 72 0 + 0 0 0 227 231 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + } ; inline + +: x-bits>hid-bits ( bit-array -- bit-array ) + 256 iota [ 2array ] { } 2map-as [ first ] filter [ second ] map + x>hid-bit-order [ nth ] curry map + 256 swap [ t swap pick set-nth ] each ; + +M: x11-game-input-backend read-keyboard + dpy get 256 [ XQueryKeymap drop ] keep + x-bits>hid-bits keyboard-state boa ; + +M: x11-game-input-backend read-mouse + 0 0 0 0 2 mouse-state boa ; + +M: x11-game-input-backend reset-mouse + ; From 7ad324837b786fd1ae320d48d7137024714f14c9 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Sat, 27 Feb 2010 00:27:40 -0500 Subject: [PATCH 273/713] Updated documentation for sets --- basis/bit-sets/bit-sets-docs.factor | 18 +++ basis/help/handbook/handbook.factor | 1 + core/hash-sets/hash-sets-docs.factor | 18 +++ core/sets/sets-docs.factor | 165 ++++++++++++++++----------- core/sets/sets.factor | 4 +- core/syntax/syntax-docs.factor | 13 ++- 6 files changed, 148 insertions(+), 71 deletions(-) create mode 100644 basis/bit-sets/bit-sets-docs.factor create mode 100644 core/hash-sets/hash-sets-docs.factor diff --git a/basis/bit-sets/bit-sets-docs.factor b/basis/bit-sets/bit-sets-docs.factor new file mode 100644 index 0000000000..a2792d3213 --- /dev/null +++ b/basis/bit-sets/bit-sets-docs.factor @@ -0,0 +1,18 @@ +USING: help.markup help.syntax sequences math ; +IN: bit-sets + +ARTICLE: "bit-sets" "Bit sets" +"The " { $vocab-link "bit-sets" } " vocabulary implements bit-array-backed sets. Bitsets are efficient for implementing relatively dense sets whose members are in a contiguous range of integers starting from 0. One bit is required for each integer in this range in the underlying representation." +"Bit sets are of the class" +{ $subsection bit-set } +"They can be instantiated with the word" +{ $subsection } ; + +ABOUT: "bit-sets" + +HELP: bit-set +{ $class-description "The class of bit-array-based sets. These implement the " { $link "sets" } "." } ; + +HELP: +{ $values { "capacity" integer } { "bit-set" bit-set } } +{ $description "Creates a new bit set with the given capacity. This set is initially empty and can contain as members integers between 0 and " { $snippet "capacity" } "-1." } ; diff --git a/basis/help/handbook/handbook.factor b/basis/help/handbook/handbook.factor index e3a7af6fc2..da5f2911f8 100644 --- a/basis/help/handbook/handbook.factor +++ b/basis/help/handbook/handbook.factor @@ -166,6 +166,7 @@ ARTICLE: "collections" "Collections" } { $heading "Other collections" } { $subsections + "sets" "lists" "disjoint-sets" "interval-maps" diff --git a/core/hash-sets/hash-sets-docs.factor b/core/hash-sets/hash-sets-docs.factor new file mode 100644 index 0000000000..e771442932 --- /dev/null +++ b/core/hash-sets/hash-sets-docs.factor @@ -0,0 +1,18 @@ +USING: help.markup help.syntax sequences ; +IN: hash-sets + +ARTICLE: "hash-sets" "Hash sets" +"The " { $vocab-link "hash-sets" } " vocabulary implements hashtable-backed sets. These are of the class:" +{ $subsection hash-set } +"They can be instantiated with the word" +{ $subsection } +"The syntax for hash sets is described in " { $link "syntax-hash-sets" } "." ; + +ABOUT: "hash-sets" + +HELP: hash-set +{ $class-description "The class of hashtable-based sets. These implement the " { $link "sets" } "." } ; + +HELP: +{ $values { "members" sequence } { "hash-set" hash-set } } +{ $description "Creates a new hash set with the given members." } ; diff --git a/core/sets/sets-docs.factor b/core/sets/sets-docs.factor index d9b1271152..ac296f949c 100644 --- a/core/sets/sets-docs.factor +++ b/core/sets/sets-docs.factor @@ -1,42 +1,71 @@ USING: assocs hashtables help.markup help.syntax kernel -quotations sequences ; +quotations sequences vectors ; IN: sets -ARTICLE: "sets" "Set-theoretic operations on sequences" -"Set-theoretic operations on sequences are defined on the " { $vocab-link "sets" } " vocabulary. All of these operations use hashtables internally to achieve linear running time." -$nl -"Remove duplicates:" -{ $subsections prune } -"Test for duplicates:" +ARTICLE: "sets" "Sets" +"A set is an unordered list of elements. Words for working with sets are in the " { $vocab-link "sets" } " vocabulary." +"All sets are instances of a mixin class:" { $subsections - all-unique? - duplicates + set + set? } -"Set operations on sequences:" +{ $subsections "set-operations" "set-implementations" } ; + +ABOUT: "sets" + +ARTICLE: "set-operations" "Operations on sets" +"To test if an object is a member of a set:" +{ $subsection member? } +"All sets can be represented as a sequence, without duplicates, of their members:" +{ $subsection members } +"Sets can have members added or removed destructively:" +{ $subsections + adjoin + delete +} +"Basic mathematical operations, which any type of set may override for efficiency:" { $subsections diff intersect union } -"Set-theoretic predicates:" +"Mathematical predicates on sets, which may be overridden for efficiency:" { $subsections intersects? subset? set= } -"A word used to implement the above:" -{ $subsections unique } -"Adding elements to sets:" +"An optional generic word for creating sets of the same class as a given set:" +{ $subsection set-like } +"An optional generic word for creating a set with a fast lookup operation, if the set itself has a slow lookup operation:" +{ $subsection fast-set } +"For set types that allow duplicates, like sequence sets, some additional words test for duplication:" { $subsections - adjoin -} -{ $see-also member? member-eq? any? all? "assocs-sets" } ; + all-unique? + duplicates +} ; -ABOUT: "sets" +ARTICLE: "set-implementations" "Set implementations" +"There are several implementations of sets in the Factor library. More can be added if they implement the words of the set protocol, the basic set operations." +{ $subsections + "sequence-sets" + "hash-sets" + "bit-sets" +} ; + +ARTICLE: "sequence-sets" "Sequences as sets" +"Any sequence can be used as a set. The members of this set are the elements of the sequence. Calling the word " { $link members } " on a sequence returns a copy of the sequence with only one listing of each member. Destructive operations " { $link adjoin } " and " { $link delete } " only work properly on growable sequences like " { $link vector } "s." +$nl +"Care must be taken in writing efficient code using sequence sets. Testing for membership with " { $link in? } ", as well as the destructive set operations, take time proportional to the size of the sequence. Another representation, like " { $link "hash-sets" } ", would take constant time for membership tests. But binary operations like " { $link union } "are asymptotically optimal, taking time proportional to the sum of the size of the inputs." +$nl +"As one particlar example, " { $link POSTPONE: f } " is a representation of the empty set, as it represents the empty sequence." ; + +HELP: set +{ $class-description "The class of all sets. Custom implementations of the set protocol should be declared as instances of this mixin for all set implementation to work correctly." } ; HELP: adjoin -{ $values { "elt" object } { "seq" "a resizable mutable sequence" } } -{ $description "Removes all elements equal to " { $snippet "elt" } ", and adds " { $snippet "elt" } " at the end of the sequence." } +{ $values { "elt" object } { "set" set } } +{ $description "Destructively adds " { $snippet "elt" } " to " { $snippet "set" } ". For sequences, this guarantees that this element is not duplicated, and that it is at the end of the sequence." $nl "Each mutable set type is expected to implement a method on this generic word." } { $examples { $example "USING: namespaces prettyprint sets ;" @@ -47,48 +76,36 @@ HELP: adjoin "V{ \"beans\" \"cheese\" \"nachos\" \"salsa\" }" } } -{ $side-effects "seq" } ; +{ $side-effects "set" } ; -HELP: conjoin -{ $values { "elt" object } { "assoc" assoc } } -{ $description "Stores a key/value pair, both equal to " { $snippet "elt" } ", into the assoc." } -{ $examples - { $example - "USING: kernel prettyprint sets ;" - "H{ } clone 1 over conjoin ." - "H{ { 1 1 } }" - } -} +HELP: delete +{ $values { "elt" object } { "set" set } } +{ $description "Destructively removes " { $snippet "elt" } " from " { $snippet "set" } ". If the element is not present, this does nothing." $nl "Each mutable set type is expected to implement a method on this generic word." } +{ $side-effects "set" } ; + +HELP: members +{ $values { "set" set } { "seq" sequence } } +{ $description "Creates a sequence with a single copy of each member of the set." $nl "Each set type is expected to implement a method on this generic word." } ; + +HELP: in? +{ $values { "elt" object } { "set" set } { "?" "a boolean" } } +{ $description "Tests whether the element is a member of the set." $nl "Each set type is expected to implement a method on this generic word as part of the set protocol." } ; + +HELP: adjoin-at +{ $values { "value" object } { "key" object } { "assoc" assoc } } +{ $description "Adds " { $snippet "value" } " to the set stored at " { $snippet "key" } " of " { $snippet "assoc" } "." } { $side-effects "assoc" } ; -HELP: conjoin-at -{ $values { "value" object } { "key" object } { "assoc" assoc } } -{ $description "Adds " { $snippet "value" } " to the set stored at " { $snippet "key" } " of " { $snippet "assoc" } "." } ; - -HELP: unique -{ $values { "seq" "a sequence" } { "assoc" assoc } } -{ $description "Outputs a new assoc where the keys and values are equal." } -{ $examples - { $example "USING: sets prettyprint ;" "{ 1 1 2 2 3 3 } unique ." "H{ { 1 1 } { 2 2 } { 3 3 } }" } -} ; - -HELP: prune -{ $values { "seq" "a sequence" } { "newseq" "a sequence" } } -{ $description "Outputs a new sequence with each distinct element of " { $snippet "seq" } " appearing only once. Elements are compared for equality using " { $link = } " and elements are ordered according to their position in " { $snippet "seq" } "." } -{ $examples - { $example "USING: sets prettyprint ;" "{ 1 1 t 3 t } prune ." "V{ 1 t 3 }" } -} ; - HELP: duplicates -{ $values { "seq" "a sequence" } { "newseq" "a sequence" } } -{ $description "Outputs a new sequence consisting of elements which occur more than once in " { $snippet "seq" } "." } +{ $values { "set" set } { "seq" sequence } } +{ $description "Outputs a sequence consisting of elements which occur more than once in " { $snippet "set" } "." } { $examples - { $example "USING: sets prettyprint ;" "{ 1 2 3 1 2 1 } duplicates ." "{ 1 2 1 }" } + { $example "USING: sets prettyprint ;" "{ 1 2 3 1 2 1 } duplicates ." "{ 2 1 2 1 }" } } ; HELP: all-unique? -{ $values { "seq" sequence } { "?" "a boolean" } } -{ $description "Tests whether a sequence contains any repeated elements." } +{ $values { "set" set } { "?" "a boolean" } } +{ $description "Tests whether a set contains any repeated elements." } { $example "USING: sets prettyprint ;" "{ 0 1 1 2 3 5 } all-unique? ." @@ -96,41 +113,44 @@ HELP: all-unique? } ; HELP: diff -{ $values { "seq1" sequence } { "seq2" sequence } { "newseq" sequence } } -{ $description "Outputs a sequence consisting of elements present in " { $snippet "seq1" } " but not " { $snippet "seq2" } ", comparing elements for equality." +{ $values { "set1" set } { "set2" set } { "set" set } } +{ $description "Outputs a set consisting of elements present in " { $snippet "set1" } " but not " { $snippet "set2" } ", comparing elements for equality." +"This word has a default definition which works for all sets, but set implementations may override the default for efficiency." } { $examples { $example "USING: sets prettyprint ;" "{ 1 2 3 } { 2 3 4 } diff ." "{ 1 }" } } ; HELP: intersect -{ $values { "seq1" sequence } { "seq2" sequence } { "newseq" sequence } } -{ $description "Outputs a sequence consisting of elements present in both " { $snippet "seq1" } " and " { $snippet "seq2" } "." } +{ $values { "set1" set } { "set2" set } { "set" set } } +{ $description "Outputs a set consisting of elements present in both " { $snippet "set1" } " and " { $snippet "set2" } "." +"This word has a default definition which works for all sets, but set implementations may override the default for efficiency." } { $examples { $example "USING: sets prettyprint ;" "{ 1 2 3 } { 2 3 4 } intersect ." "{ 2 3 }" } } ; HELP: union -{ $values { "seq1" sequence } { "seq2" sequence } { "newseq" sequence } } -{ $description "Outputs a sequence consisting of elements present in " { $snippet "seq1" } " and " { $snippet "seq2" } " which does not contain duplicate values." } +{ $values { "set1" set } { "set2" set } { "set" set } } +{ $description "Outputs a set consisting of elements present in either " { $snippet "set1" } " or " { $snippet "set2" } " which does not contain duplicate values." +"This word has a default definition which works for all sets, but set implementations may override the default for efficiency." } { $examples - { $example "USING: sets prettyprint ;" "{ 1 2 3 } { 2 3 4 } union ." "V{ 1 2 3 4 }" } + { $example "USING: sets prettyprint ;" "{ 1 2 3 } { 2 3 4 } union ." "{ 1 2 3 4 }" } } ; { diff intersect union } related-words HELP: intersects? -{ $values { "seq1" sequence } { "seq2" sequence } { "?" "a boolean" } } -{ $description "Tests if " { $snippet "seq1" } " and " { $snippet "seq2" } " have any elements in common." } -{ $notes "If one of the sequences is empty, the result is always " { $link f } "." } ; +{ $values { "set1" set } { "set2" set } { "?" "a boolean" } } +{ $description "Tests if " { $snippet "set1" } " and " { $snippet "set2" } " have any elements in common." } +{ $notes "If one of the sets is empty, the result is always " { $link f } "." } ; HELP: subset? -{ $values { "seq1" sequence } { "seq2" sequence } { "?" "a boolean" } } -{ $description "Tests if every element of " { $snippet "seq1" } " is contained in " { $snippet "seq2" } "." } -{ $notes "If " { $snippet "seq1" } " is empty, the result is always " { $link t } "." } ; +{ $values { "set1" set } { "set2" set } { "?" "a boolean" } } +{ $description "Tests if every element of " { $snippet "set1" } " is contained in " { $snippet "set2" } "." } +{ $notes "If " { $snippet "set1" } " is empty, the result is always " { $link t } "." } ; HELP: set= -{ $values { "seq1" sequence } { "seq2" sequence } { "?" "a boolean" } } -{ $description "Tests if both sequences contain the same elements, disregrading order and duplicates." } ; +{ $values { "set1" set } { "set2" set } { "?" "a boolean" } } +{ $description "Tests if both sets contain the same elements, disregrading order and duplicates." } ; HELP: gather { $values @@ -138,3 +158,10 @@ HELP: gather { "newseq" sequence } } { $description "Maps a quotation onto a sequence, concatenates the results of the mapping, and removes duplicates." } ; +HELP: set-like +{ $values { "set" set } { "exemplar" set } { "set'" set } } +{ $description "If the conversion is defined for the exemplar, converts the set into a set of the exemplar's class. This is not guaranteed to create a new set, for example if the input set and exemplar are of the same class." $nl +"Set implementations may optionally implement a method on this generic word. The default implementation returns its input set." } +{ $examples + { $example "USING: sets prettyprint ;" "{ 1 2 3 } HS{ } set-like ." "HS{ 1 2 3 }" } +} ; diff --git a/core/sets/sets.factor b/core/sets/sets.factor index 550b906b55..5e7c3b1617 100644 --- a/core/sets/sets.factor +++ b/core/sets/sets.factor @@ -18,12 +18,14 @@ GENERIC: intersects? ( set1 set2 -- ? ) GENERIC: diff ( set1 set2 -- set ) GENERIC: subset? ( set1 set2 -- ? ) GENERIC: set= ( set1 set2 -- ? ) -GENERIC: duplicates ( set -- sequence ) +GENERIC: duplicates ( set -- seq ) GENERIC: all-unique? ( set -- ? ) ! Defaults for some methods. ! Override them for efficiency +M: set set-like drop ; inline + M: set union [ [ members ] bi@ append ] keep set-like ; diff --git a/core/syntax/syntax-docs.factor b/core/syntax/syntax-docs.factor index 4a1af4c578..035ac1454b 100644 --- a/core/syntax/syntax-docs.factor +++ b/core/syntax/syntax-docs.factor @@ -189,6 +189,10 @@ ARTICLE: "syntax-hashtables" "Hashtable syntax" { $subsections POSTPONE: H{ } "Hashtables are documented in " { $link "hashtables" } "." ; +ARTICLE: "syntax-hash-sets" "Hash set syntax" +{ $subsections POSTPONE: HS{ } +"Hashtables are documented in " { $link "hash-sets" } "." ; + ARTICLE: "syntax-tuples" "Tuple syntax" { $subsections POSTPONE: T{ } "Tuples are documented in " { $link "tuples" } "." ; @@ -229,6 +233,7 @@ $nl "syntax-vectors" "syntax-sbufs" "syntax-hashtables" + "syntax-hash-sets" "syntax-tuples" "syntax-pathnames" "syntax-effects" @@ -330,7 +335,7 @@ HELP: } $nl "Parsing words can use this word as a generic end delimiter." } ; -{ POSTPONE: { POSTPONE: V{ POSTPONE: H{ POSTPONE: C{ POSTPONE: T{ POSTPONE: W{ POSTPONE: } } related-words +{ POSTPONE: { POSTPONE: V{ POSTPONE: H{ POSTPONE: HS{ POSTPONE: C{ POSTPONE: T{ POSTPONE: W{ POSTPONE: } } related-words HELP: { { $syntax "{ elements... }" } @@ -356,6 +361,12 @@ HELP: H{ { $description "Marks the beginning of a literal hashtable, given as a list of two-element arrays holding key/value pairs. Literal hashtables are terminated by " { $link POSTPONE: } } "." } { $examples { $code "H{ { \"tuna\" \"fish\" } { \"jalapeno\" \"vegetable\" } }" } } ; +HELP: HS{ +{ $syntax "HS{ members ... }" } +{ $values { "members" "a list of objects" } } +{ $description "Marks the beginning of a literal hash set, given as a list of its members. Literal hashtables are terminated by " { $link POSTPONE: } } "." } +{ $examples { $code "HS{ 3 \"foo\" }" } } ; + HELP: C{ { $syntax "C{ real-part imaginary-part }" } { $values { "real-part" "a real number" } { "imaginary-part" "a real number" } } From 9bf7f56283ce7adfe731367efbe94a0577b7d79c Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 25 Feb 2010 18:05:10 -0600 Subject: [PATCH 274/713] Add a new word http-data that is just http-get nip --- .../bootstrap/image/download/download.factor | 2 +- basis/http/client/client.factor | 3 +++ basis/http/http-tests.factor | 22 +++++++++---------- basis/syndication/syndication.factor | 2 +- extra/images/http/http.factor | 2 +- extra/webapps/fjsc/fjsc.factor | 2 +- extra/yahoo/yahoo.factor | 2 +- 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/basis/bootstrap/image/download/download.factor b/basis/bootstrap/image/download/download.factor index e2de621984..9ab7689eca 100644 --- a/basis/bootstrap/image/download/download.factor +++ b/basis/bootstrap/image/download/download.factor @@ -7,7 +7,7 @@ IN: bootstrap.image.download CONSTANT: url URL" http://factorcode.org/images/latest/" : download-checksums ( -- alist ) - url "checksums.txt" >url derive-url http-get nip + url "checksums.txt" >url derive-url http-data string-lines [ " " split1 ] { } map>assoc ; : need-new-image? ( image -- ? ) diff --git a/basis/http/client/client.factor b/basis/http/client/client.factor index 482a23aeaa..9e540f111f 100644 --- a/basis/http/client/client.factor +++ b/basis/http/client/client.factor @@ -157,6 +157,9 @@ ERROR: download-failed response ; : http-get ( url -- response data ) http-request ; +: http-data ( url -- data ) + http-get nip ; + : with-http-get ( url quot -- response ) [ ] dip with-http-request ; inline diff --git a/basis/http/http-tests.factor b/basis/http/http-tests.factor index 35d01c1014..62936af7ff 100644 --- a/basis/http/http-tests.factor +++ b/basis/http/http-tests.factor @@ -226,14 +226,14 @@ test-db [ [ t ] [ "vocab:http/test/foo.html" ascii file-contents - "http://localhost/nested/foo.html" add-port http-get nip = + "http://localhost/nested/foo.html" add-port http-data = ] unit-test -[ "http://localhost/redirect-loop" add-port http-get nip ] +[ "http://localhost/redirect-loop" add-port http-data ] [ too-many-redirects? ] must-fail-with [ "Goodbye" ] [ - "http://localhost/quit" add-port http-get nip + "http://localhost/quit" add-port http-data ] unit-test ! HTTP client redirect bug @@ -247,7 +247,7 @@ test-db [ ] unit-test [ "Goodbye" ] [ - "http://localhost/redirect" add-port http-get nip + "http://localhost/redirect" add-port http-data ] unit-test @@ -274,12 +274,12 @@ test-db [ : 404? ( response -- ? ) [ download-failed? ] [ response>> code>> 404 = ] bi and ; ! This should give a 404 not an infinite redirect loop -[ "http://localhost/d/blah" add-port http-get nip ] [ 404? ] must-fail-with +[ "http://localhost/d/blah" add-port http-data ] [ 404? ] must-fail-with ! This should give a 404 not an infinite redirect loop -[ "http://localhost/blah/" add-port http-get nip ] [ 404? ] must-fail-with +[ "http://localhost/blah/" add-port http-data ] [ 404? ] must-fail-with -[ "Goodbye" ] [ "http://localhost/quit" add-port http-get nip ] unit-test +[ "Goodbye" ] [ "http://localhost/quit" add-port http-data ] unit-test [ ] [ @@ -293,9 +293,9 @@ test-db [ test-httpd ] unit-test -[ "Hi" ] [ "http://localhost/" add-port http-get nip ] unit-test +[ "Hi" ] [ "http://localhost/" add-port http-data ] unit-test -[ "Goodbye" ] [ "http://localhost/quit" add-port http-get nip ] unit-test +[ "Goodbye" ] [ "http://localhost/quit" add-port http-data ] unit-test USING: html.components html.forms xml xml.traversal validators @@ -353,7 +353,7 @@ SYMBOL: a [ 4 ] [ a get-global ] unit-test -[ "Goodbye" ] [ "http://localhost/quit" add-port http-get nip ] unit-test +[ "Goodbye" ] [ "http://localhost/quit" add-port http-data ] unit-test ! Test cloning [ f ] [ <404> dup clone "b" "a" set-header drop "a" header ] unit-test @@ -371,7 +371,7 @@ SYMBOL: a ] unit-test [ t ] [ - "http://localhost/" add-port http-get nip + "http://localhost/" add-port http-data "vocab:http/test/foo.html" ascii file-contents = ] unit-test diff --git a/basis/syndication/syndication.factor b/basis/syndication/syndication.factor index fe31a49265..edfbebeeab 100644 --- a/basis/syndication/syndication.factor +++ b/basis/syndication/syndication.factor @@ -115,7 +115,7 @@ M: byte-array parse-feed [ bytes>xml xml>feed ] with-html-entities ; : download-feed ( url -- feed ) #! Retrieve an news syndication file, return as a feed tuple. - http-get nip parse-feed ; + http-data parse-feed ; ! Atom generation diff --git a/extra/images/http/http.factor b/extra/images/http/http.factor index 620ab6f73b..d3cff18afb 100644 --- a/extra/images/http/http.factor +++ b/extra/images/http/http.factor @@ -5,7 +5,7 @@ images.viewer ; IN: images.http : load-http-image ( path -- image ) - [ http-get nip ] [ image-class ] bi load-image* ; + [ http-data ] [ image-class ] bi load-image* ; : http-image. ( path -- ) load-http-image image. ; diff --git a/extra/webapps/fjsc/fjsc.factor b/extra/webapps/fjsc/fjsc.factor index 01d6935bee..4dec258083 100644 --- a/extra/webapps/fjsc/fjsc.factor +++ b/extra/webapps/fjsc/fjsc.factor @@ -35,7 +35,7 @@ TUPLE: fjsc < dispatcher ; : do-compile-url ( url -- response ) [ - absolute-url http-get nip 'expression' parse fjsc-compile write "();" write + absolute-url http-data 'expression' parse fjsc-compile write "();" write ] with-string-writer "application/javascript" ; diff --git a/extra/yahoo/yahoo.factor b/extra/yahoo/yahoo.factor index 5e0c08b430..2a8469c328 100644 --- a/extra/yahoo/yahoo.factor +++ b/extra/yahoo/yahoo.factor @@ -57,4 +57,4 @@ CONSTANT: factor-id "fRrVAKzV34GDyeRw6bUHDhEWHRedwfOC7e61wwXZLgGF80E67spxdQXuugB swap >>query ; : search-yahoo ( search -- seq ) - query http-get nip string>xml parse-yahoo ; + query http-data string>xml parse-yahoo ; From 18c0935b64c5745c47cb4fa17c40365a32313be8 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 25 Feb 2010 18:07:14 -0600 Subject: [PATCH 275/713] Docs for http-data --- basis/http/client/client-docs.factor | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/basis/http/client/client-docs.factor b/basis/http/client/client-docs.factor index 04077fc2f7..0d0887d10d 100644 --- a/basis/http/client/client-docs.factor +++ b/basis/http/client/client-docs.factor @@ -35,6 +35,11 @@ HELP: http-get { $description "Downloads the contents of a URL." } { $errors "Throws an error if the HTTP request fails." } ; +HELP: http-data +{ $values { "url" "a " { $link url } " or " { $link string } } { "data" sequence } } +{ $description "Downloads the contents of a URL. To view the HTTP response, use " { $link http-get } "." } +{ $errors "Throws an error if the HTTP request fails." } ; + HELP: http-post { $values { "post-data" object } { "url" "a " { $link url } " or " { $link string } } { "response" response } { "data" sequence } } { $description "Submits an HTTP POST request." } @@ -61,7 +66,7 @@ HELP: with-http-request ARTICLE: "http.client.get" "GET requests with the HTTP client" "Basic usage involves passing a " { $link url } " and getting a " { $link response } " and data back:" -{ $subsections http-get } +{ $subsections http-get http-data } "Utilities to retrieve a " { $link url } " and save the contents to a file:" { $subsections download From 5eff2e0e9aad9951eb479d27fb20abb29df76afc Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 25 Feb 2010 18:30:40 -0600 Subject: [PATCH 276/713] Add csv>string and string>csv --- basis/csv/csv-docs.factor | 18 ++++++++++++++++++ basis/csv/csv.factor | 22 ++++++++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/basis/csv/csv-docs.factor b/basis/csv/csv-docs.factor index 1f05ab639b..1796a029de 100644 --- a/basis/csv/csv-docs.factor +++ b/basis/csv/csv-docs.factor @@ -21,6 +21,20 @@ HELP: csv>file } { $description "Writes a comma-separated-value structure to a file." } ; +HELP: string>csv +{ $values + { "string" string } + { "csv" "csv" } +} +{ $description "Parses a string into a sequence of comma-separated-value fields." } ; + +HELP: csv>string +{ $values + { "rows" "a sequence of sequences of strings" } + { "string" string } +} +{ $description "Writes a comma-separated-value structure to a string." } ; + HELP: csv-row { $values { "stream" "an input stream" } { "row" "an array of fields" } } @@ -42,6 +56,10 @@ ARTICLE: "csv" "Comma-separated-values parsing and writing" { $subsections file>csv } "Writing a csv file:" { $subsections csv>file } +"Reading a string to csv:" +{ $subsections string>csv } +"Writing csv to a string:" +{ $subsections csv>string } "Changing the delimiter from a comma:" { $subsections with-delimiter } "Reading from a stream:" diff --git a/basis/csv/csv.factor b/basis/csv/csv.factor index 23416d6912..1aeb2e1d19 100644 --- a/basis/csv/csv.factor +++ b/basis/csv/csv.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2007, 2008 Phil Dawes ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences io namespaces make combinators -unicode.categories io.files combinators.short-circuit ; +unicode.categories io.files combinators.short-circuit +io.streams.string ; IN: csv SYMBOL: delimiter @@ -65,6 +66,9 @@ PRIVATE> [ [ (csv) ] { } make ] with-input-stream dup last { "" } = [ but-last ] when ; +: string>csv ( string -- csv ) + csv ; + : file>csv ( path encoding -- csv ) csv ; @@ -96,8 +100,18 @@ PRIVATE> : write-row ( row -- ) [ delimiter get write1 ] [ escape-if-required write ] interleave nl ; inline - -: write-csv ( rows stream -- ) - [ [ write-row ] each ] with-output-stream ; + + +: write-csv ( rows stream -- ) + [ (write-csv) ] with-output-stream ; + +: csv>string ( csv -- string ) + [ (write-csv) ] with-string-writer ; + : csv>file ( rows path encoding -- ) write-csv ; From 90597236e1341a56c44438804ecfb21045dbb87a Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 27 Feb 2010 05:01:14 -0600 Subject: [PATCH 277/713] Add a slots{ word for accessing multiple slots --- extra/slots/syntax/authors.txt | 1 + extra/slots/syntax/syntax-docs.factor | 20 ++++++++++++++++++++ extra/slots/syntax/syntax-tests.factor | 10 ++++++++++ extra/slots/syntax/syntax.factor | 10 ++++++++++ 4 files changed, 41 insertions(+) create mode 100755 extra/slots/syntax/authors.txt create mode 100755 extra/slots/syntax/syntax-docs.factor create mode 100755 extra/slots/syntax/syntax-tests.factor create mode 100755 extra/slots/syntax/syntax.factor diff --git a/extra/slots/syntax/authors.txt b/extra/slots/syntax/authors.txt new file mode 100755 index 0000000000..7c1b2f2279 --- /dev/null +++ b/extra/slots/syntax/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/extra/slots/syntax/syntax-docs.factor b/extra/slots/syntax/syntax-docs.factor new file mode 100755 index 0000000000..b79916f91b --- /dev/null +++ b/extra/slots/syntax/syntax-docs.factor @@ -0,0 +1,20 @@ +! Copyright (C) 2010 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: help.markup help.syntax ; +IN: slots.syntax + +HELP: slots{ +{ $description "Outputs an array of slot values from a tuple." } +{ $example "USING: prettyprint slots.syntax ;" + "IN: slots.syntax.example" + "TUPLE: rectangle width height ;" + "T{ rectangle { width 3 } { height 5 } } slots{ width height } ." + "{ 3 5 }" +} ; + +ARTICLE: "slots.syntax" "Slots syntax sugar" +"The " { $vocab-link "slots.syntax" } " vocabulary provides an alternative syntax for taking a sequence of slots from a tuple." $nl +"Syntax sugar for cleaving slots to an array:" +{ $subsections POSTPONE: slots{ } ; + +ABOUT: "slots.syntax" diff --git a/extra/slots/syntax/syntax-tests.factor b/extra/slots/syntax/syntax-tests.factor new file mode 100755 index 0000000000..689ccb48eb --- /dev/null +++ b/extra/slots/syntax/syntax-tests.factor @@ -0,0 +1,10 @@ +! Copyright (C) 2010 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: tools.test slots.syntax ; +IN: slots.syntax.tests + +TUPLE: slot-test a b c ; + +[ { 1 2 3 } ] [ T{ slot-test f 1 2 3 } slots{ a b c } ] unit-test +[ { 3 } ] [ T{ slot-test f 1 2 3 } slots{ c } ] unit-test +[ { } ] [ T{ slot-test f 1 2 3 } slots{ } ] unit-test \ No newline at end of file diff --git a/extra/slots/syntax/syntax.factor b/extra/slots/syntax/syntax.factor new file mode 100755 index 0000000000..2cce91c569 --- /dev/null +++ b/extra/slots/syntax/syntax.factor @@ -0,0 +1,10 @@ +! Copyright (C) 2010 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: combinators combinators.smart fry lexer quotations +sequences slots ; +IN: slots.syntax + +SYNTAX: slots{ + "}" parse-tokens + [ reader-word 1quotation ] map + '[ [ _ cleave ] output>array ] append! ; \ No newline at end of file From 93efc83938091c363074d6a6eb34a8c71f84ec5c Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 27 Feb 2010 07:53:21 -0600 Subject: [PATCH 278/713] more user32 bindings --- basis/windows/user32/user32.factor | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/basis/windows/user32/user32.factor b/basis/windows/user32/user32.factor index b9d5cc95c4..1c23c36071 100644 --- a/basis/windows/user32/user32.factor +++ b/basis/windows/user32/user32.factor @@ -580,8 +580,8 @@ CONSTANT: SWP_HIDEWINDOW 128 CONSTANT: SWP_NOCOPYBITS 256 CONSTANT: SWP_NOOWNERZORDER 512 CONSTANT: SWP_NOSENDCHANGING 1024 -CONSTANT: SWP_DRAWFRAME SWP_FRAMECHANGED -CONSTANT: SWP_NOREPOSITION SWP_NOOWNERZORDER +ALIAS: SWP_DRAWFRAME SWP_FRAMECHANGED +ALIAS: SWP_NOREPOSITION SWP_NOOWNERZORDER CONSTANT: SWP_DEFERERASE 8192 CONSTANT: SWP_ASYNCWINDOWPOS 16384 @@ -1250,7 +1250,7 @@ FUNCTION: UINT EnumClipboardFormats ( UINT format ) ; ! FUNCTION: EnumDesktopWindows ! FUNCTION: EnumDisplayDevicesA ! FUNCTION: EnumDisplayDevicesW -! FUNCTION: EnumDisplayMonitors +! FUNCTION: BOOL EnumDisplayMonitors ( HDC hdc, LPCRECT lprcClip, MONITORENUMPROC lpfnEnum, LPARAM dwData ) ; ! FUNCTION: EnumDisplaySettingsA ! FUNCTION: EnumDisplaySettingsExA ! FUNCTION: EnumDisplaySettingsExW @@ -1327,7 +1327,7 @@ FUNCTION: HWND GetDesktopWindow ( ) ; ! FUNCTION: GetDlgItemTextW FUNCTION: uint GetDoubleClickTime ( ) ; FUNCTION: HWND GetFocus ( ) ; -! FUNCTION: GetForegroundWindow +FUNCTION: HWND GetForegroundWindow ( ) ; ! FUNCTION: GetGuiResources ! FUNCTION: GetGUIThreadInfo ! FUNCTION: GetIconInfo @@ -1428,7 +1428,8 @@ FUNCTION: HWND GetWindow ( HWND hWnd, UINT uCmd ) ; FUNCTION: LONG_PTR GetWindowLongW ( HANDLE hWnd, int index ) ; ALIAS: GetWindowLong GetWindowLongW -FUNCTION: LONG_PTR GetWindowLongPtr ( HWND hWnd, int nIndex ) ; +FUNCTION: LONG_PTR GetWindowLongPtrW ( HWND hWnd, int nIndex ) ; +ALIAS: GetWindowLongPtr GetWindowLongPtrW ! FUNCTION: GetWindowModuleFileName ! FUNCTION: GetWindowModuleFileNameA ! FUNCTION: GetWindowModuleFileNameW @@ -1776,7 +1777,8 @@ ALIAS: SetWindowLong SetWindowLongW ! FUNCTION: SetWindowPlacement FUNCTION: BOOL SetWindowPos ( HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags ) ; -FUNCTION: LONG_PTR SetWindowLongPtr ( HWND hWnd, int nIndex, LONG_PTR dwNewLong ) ; +FUNCTION: LONG_PTR SetWindowLongPtrW ( HWND hWnd, int nIndex, LONG_PTR dwNewLong ) ; +ALIAS: SetWindowLongPtr SetWindowLongPtrW : HWND_BOTTOM ( -- alien ) 1 ; : HWND_NOTOPMOST ( -- alien ) -2 ; From bad7e4b68e3c84419c00d786fc021662b4c64257 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 27 Feb 2010 07:54:54 -0600 Subject: [PATCH 279/713] Add a slot for worlds to know if they are fullscreened, and another for restoring the window position after returning from fullscreen mode --- basis/ui/gadgets/worlds/worlds.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basis/ui/gadgets/worlds/worlds.factor b/basis/ui/gadgets/worlds/worlds.factor index 05466f4673..bcdccb23cd 100644 --- a/basis/ui/gadgets/worlds/worlds.factor +++ b/basis/ui/gadgets/worlds/worlds.factor @@ -33,7 +33,8 @@ CONSTANT: default-world-window-controls } TUPLE: world < track - active? focused? grab-input? + active? focused? grab-input? fullscreen? + saved-position layers title status status-owner text-handle handle images From cc892700c8dea87510011713d476c377f08573db Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 27 Feb 2010 08:25:25 -0600 Subject: [PATCH 280/713] add missing using --- basis/csv/csv-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/csv/csv-docs.factor b/basis/csv/csv-docs.factor index 1796a029de..075b00eea2 100644 --- a/basis/csv/csv-docs.factor +++ b/basis/csv/csv-docs.factor @@ -1,5 +1,5 @@ USING: help.syntax help.markup kernel prettyprint sequences -io.pathnames ; +io.pathnames strings ; IN: csv HELP: csv From 434605c0b59115098a743e29a78ef24d59a5ed1c Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Sat, 27 Feb 2010 13:14:03 -0500 Subject: [PATCH 281/713] Changing some uses of prune to use members --- basis/compiler/tree/def-use/def-use.factor | 3 ++- basis/help/lint/checks/checks.factor | 5 +++-- basis/help/markup/markup.factor | 2 +- basis/io/monitors/linux/linux.factor | 2 +- basis/locals/rewrite/closures/closures.factor | 4 ++-- basis/math/ranges/ranges-tests.factor | 2 +- basis/random/random-tests.factor | 6 +++--- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/basis/compiler/tree/def-use/def-use.factor b/basis/compiler/tree/def-use/def-use.factor index a1c316140d..4af54d0319 100644 --- a/basis/compiler/tree/def-use/def-use.factor +++ b/basis/compiler/tree/def-use/def-use.factor @@ -7,6 +7,7 @@ stack-checker.branches compiler.tree compiler.tree.combinators ; FROM: namespaces => set ; +FROM: sets => members ; IN: compiler.tree.def-use SYMBOL: def-use @@ -43,7 +44,7 @@ GENERIC: node-uses-values ( node -- values ) M: #introduce node-uses-values drop f ; M: #push node-uses-values drop f ; -M: #phi node-uses-values phi-in-d>> concat remove-bottom prune ; +M: #phi node-uses-values phi-in-d>> concat remove-bottom members ; M: #declare node-uses-values drop f ; M: #terminate node-uses-values [ in-d>> ] [ in-r>> ] bi append ; M: #shuffle node-uses-values [ in-d>> ] [ in-r>> ] bi append ; diff --git a/basis/help/lint/checks/checks.factor b/basis/help/lint/checks/checks.factor index 632cdb46e2..47e1714229 100644 --- a/basis/help/lint/checks/checks.factor +++ b/basis/help/lint/checks/checks.factor @@ -6,6 +6,7 @@ help help.markup help.topics io.streams.string kernel macros namespaces sequences sequences.deep sets sorting splitting strings unicode.categories values vocabs vocabs.loader words words.symbol summary debugger io ; +FROM: sets => members ; IN: help.lint.checks ERROR: simple-lint-error message ; @@ -39,7 +40,7 @@ SYMBOL: vocab-articles : effect-values ( word -- seq ) stack-effect [ in>> ] [ out>> ] bi append - [ dup pair? [ first ] when effect>string ] map prune ; + [ dup pair? [ first ] when effect>string ] map members ; : contains-funky-elements? ( element -- ? ) { @@ -80,7 +81,7 @@ SYMBOL: vocab-articles : check-see-also ( element -- ) \ $see-also swap elements [ - rest dup prune [ length ] bi@ assert= + rest all-unique? t assert= ] each ; : vocab-exists? ( name -- ? ) diff --git a/basis/help/markup/markup.factor b/basis/help/markup/markup.factor index dd43c84864..ce954eae98 100644 --- a/basis/help/markup/markup.factor +++ b/basis/help/markup/markup.factor @@ -442,7 +442,7 @@ M: array elements* : elements ( elt-type element -- seq ) [ elements* ] { } make ; : collect-elements ( element seq -- elements ) - swap '[ _ elements [ rest ] map concat ] map concat prune ; + swap '[ _ elements [ rest ] map concat ] gather ; : <$link> ( topic -- element ) 1array \ $link prefix ; diff --git a/basis/io/monitors/linux/linux.factor b/basis/io/monitors/linux/linux.factor index eacc920303..63484f467f 100644 --- a/basis/io/monitors/linux/linux.factor +++ b/basis/io/monitors/linux/linux.factor @@ -81,7 +81,7 @@ M: linux-monitor dispose* ( monitor -- ) IN_MOVED_FROM +rename-file-old+ ?flag IN_MOVED_TO +rename-file-new+ ?flag drop - ] { } make prune ; + ] { } make members ; : parse-event-name ( event -- name ) dup len>> zero? diff --git a/basis/locals/rewrite/closures/closures.factor b/basis/locals/rewrite/closures/closures.factor index d85155daad..b0f1426bec 100644 --- a/basis/locals/rewrite/closures/closures.factor +++ b/basis/locals/rewrite/closures/closures.factor @@ -18,7 +18,7 @@ GENERIC: rewrite-closures* ( obj -- ) GENERIC: defs-vars* ( seq form -- seq' ) -: defs-vars ( form -- vars ) { } [ defs-vars* ] reduce prune ; +: defs-vars ( form -- vars ) { } [ defs-vars* ] reduce members ; M: def defs-vars* local>> unquote suffix ; @@ -28,7 +28,7 @@ M: object defs-vars* drop ; GENERIC: uses-vars* ( seq form -- seq' ) -: uses-vars ( form -- vars ) { } [ uses-vars* ] reduce prune ; +: uses-vars ( form -- vars ) { } [ uses-vars* ] reduce members ; M: local-writer uses-vars* "local-reader" word-prop suffix ; diff --git a/basis/math/ranges/ranges-tests.factor b/basis/math/ranges/ranges-tests.factor index e314f72c6b..16cb379ba8 100644 --- a/basis/math/ranges/ranges-tests.factor +++ b/basis/math/ranges/ranges-tests.factor @@ -23,5 +23,5 @@ IN: math.ranges.tests [ { 0 1/3 2/3 1 } ] [ 1 0 -1/3 >array reverse ] unit-test [ 100 ] [ - 1 100 [a,b] [ 2^ [1,b] ] map prune length + 1 100 [a,b] [ 2^ [1,b] ] map members length ] unit-test diff --git a/basis/random/random-tests.factor b/basis/random/random-tests.factor index 9341b96b11..3fc4ff80eb 100644 --- a/basis/random/random-tests.factor +++ b/basis/random/random-tests.factor @@ -14,7 +14,7 @@ IN: random.tests [ t ] [ 10000 [ iota 0 [ drop 187 random + ] reduce ] keep / 2 * 187 10 ~ ] unit-test [ t ] [ 10000 [ iota 0 [ drop 400 random + ] reduce ] keep / 2 * 400 10 ~ ] unit-test -[ t ] [ 1000 [ 400 random ] replicate prune length 256 > ] unit-test +[ t ] [ 1000 [ 400 random ] replicate members length 256 > ] unit-test [ f ] [ 0 random ] unit-test @@ -28,8 +28,8 @@ IN: random.tests [ { 1 2 } 3 sample ] [ too-many-samples? ] must-fail-with -[ 3 ] [ { 1 2 3 4 } 3 sample prune length ] unit-test -[ 99 ] [ 100 iota 99 sample prune length ] unit-test +[ 3 ] [ { 1 2 3 4 } 3 sample members length ] unit-test +[ 99 ] [ 100 iota 99 sample members length ] unit-test [ ] [ [ 100 random-bytes ] with-system-random drop ] unit-test From 07dfcf2298df860755c443f3a494814a9ca143b0 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 27 Feb 2010 13:03:28 -0600 Subject: [PATCH 282/713] Beginning of a real fullscreen library --- extra/fullscreen/authors.txt | 1 + extra/fullscreen/fullscreen.factor | 142 +++++++++++++++++++++++++++++ extra/fullscreen/platforms.txt | 1 + 3 files changed, 144 insertions(+) create mode 100755 extra/fullscreen/authors.txt create mode 100755 extra/fullscreen/fullscreen.factor create mode 100644 extra/fullscreen/platforms.txt diff --git a/extra/fullscreen/authors.txt b/extra/fullscreen/authors.txt new file mode 100755 index 0000000000..7c1b2f2279 --- /dev/null +++ b/extra/fullscreen/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/extra/fullscreen/fullscreen.factor b/extra/fullscreen/fullscreen.factor new file mode 100755 index 0000000000..a233d6f4f5 --- /dev/null +++ b/extra/fullscreen/fullscreen.factor @@ -0,0 +1,142 @@ +! Copyright (C) 2010 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien.c-types arrays classes.struct fry kernel +literals locals make math math.bitwise multiline sequences +slots.syntax ui.backend.windows vocabs.loader windows.errors +windows.gdi32 windows.kernel32 windows.types windows.user32 +ui.gadgets.worlds ; +IN: fullscreen + +: hwnd>hmonitor ( HWND -- HMONITOR ) + MONITOR_DEFAULTTOPRIMARY MonitorFromWindow ; + +: desktop-hmonitor ( -- HMONITOR ) + GetDesktopWindow hwnd>hmonitor ; + +:: (monitor-info>devmodes) ( monitor-info n -- ) + DEVMODE + DEVMODE heap-size >>dmSize + { DM_BITSPERPEL DM_PELSWIDTH DM_PELSHEIGHT } flags >>dmFields + :> devmode + + monitor-info szDevice>> + n + devmode + EnumDisplaySettings 0 = [ + devmode , + monitor-info n 1 + (monitor-info>devmodes) + ] unless ; + +: monitor-info>devmodes ( monito-info -- devmodes ) + [ 0 (monitor-info>devmodes) ] { } make ; + +: hmonitor>monitor-info ( HMONITOR -- monitor-info ) + MONITORINFOEX + MONITORINFOEX heap-size >>cbSize + [ GetMonitorInfo win32-error=0/f ] keep ; + +: hwnd>monitor-info ( HWND -- monitor-info ) + hwnd>hmonitor hmonitor>monitor-info ; + +: hmonitor>devmodes ( HMONITOR -- devmodes ) + hmonitor>monitor-info monitor-info>devmodes ; + +: desktop-devmodes ( -- DEVMODEs ) + desktop-hmonitor hmonitor>devmodes ; + +: desktop-monitor-info ( -- monitor-info ) + desktop-hmonitor hmonitor>monitor-info ; + +: desktop-RECT ( -- RECT ) + GetDesktopWindow RECT [ GetWindowRect win32-error=0/f ] keep ; + +ERROR: display-change-error n ; + +: fullscreen-mode ( monitor-info devmode -- ) + [ szDevice>> ] dip f CDS_FULLSCREEN f + ChangeDisplaySettingsEx dup DISP_CHANGE_SUCCESSFUL = + [ drop ] [ display-change-error ] if ; + +: non-fullscreen-mode ( monitor-info devmode -- ) + [ szDevice>> ] dip f 0 f + ChangeDisplaySettingsEx dup DISP_CHANGE_SUCCESSFUL = + [ drop ] [ display-change-error ] if ; + +: get-style ( hwnd n -- style ) + GetWindowLongPtr [ win32-error=0/f ] keep ; + +: set-style ( hwnd n style -- ) + SetWindowLongPtr win32-error=0/f ; + +: change-style ( hwnd n quot -- ) + [ 2dup get-style ] dip call set-style ; inline + +: set-fullscreen-styles ( hwnd -- ) + [ GWL_STYLE [ WS_OVERLAPPEDWINDOW unmask ] change-style ] + [ GWL_EXSTYLE [ { WS_EX_APPWINDOW WS_EX_TOPMOST } flags bitor ] change-style ] bi ; + +: set-non-fullscreen-styles ( hwnd -- ) + [ GWL_STYLE [ WS_OVERLAPPEDWINDOW bitor ] change-style ] + [ GWL_EXSTYLE [ { WS_EX_APPWINDOW WS_EX_TOPMOST } flags unmask ] change-style ] bi ; + +ERROR: unsupported-resolution triple ; + +:: find-devmode ( triple hwnd -- devmode ) + hwnd hwnd>hmonitor hmonitor>devmodes + [ + slots{ dmPelsWidth dmPelsHeight dmBitsPerPel } + triple = + ] find nip [ triple unsupported-resolution ] unless* ; + +:: set-fullscreen-window-position ( hwnd triple -- ) + hwnd f + desktop-monitor-info rcMonitor>> slots{ left top } first2 + triple first2 + { + SWP_NOACTIVATE SWP_NOCOPYBITS SWP_NOOWNERZORDER + SWP_NOREPOSITION SWP_NOZORDER + } flags + SetWindowPos win32-error=0/f ; + +:: enable-fullscreen ( triple hwnd -- rect ) + hwnd hwnd>RECT :> rect + + desktop-monitor-info + triple GetDesktopWindow find-devmode + hwnd set-fullscreen-styles + fullscreen-mode + + hwnd triple set-fullscreen-window-position + rect ; + +:: set-window-position ( hwnd rect -- ) + hwnd f rect get-RECT-dimensions SWP_FRAMECHANGED + SetWindowPos win32-error=0/f ; + +:: disable-fullscreen ( rect triple hwnd -- ) + desktop-monitor-info + triple + GetDesktopWindow find-devmode non-fullscreen-mode + hwnd set-non-fullscreen-styles + hwnd rect set-window-position ; + +: enable-factor-fullscreen ( triple -- rect ) + GetForegroundWindow enable-fullscreen ; + +: disable-factor-fullscreen ( rect triple -- ) + GetForegroundWindow disable-fullscreen ; + +:: (set-fullscreen) ( world triple fullscreen? -- ) + world fullscreen?>> fullscreen? xor [ + triple + world handle>> hWnd>> + fullscreen? [ + enable-fullscreen world (>>saved-position) + ] [ + [ world saved-position>> ] 2dip disable-fullscreen + ] if + fullscreen? world (>>fullscreen?) + ] when ; + +: set-fullscreen ( gadget triple fullscreen? -- ) + [ find-world ] 2dip (set-fullscreen) ; diff --git a/extra/fullscreen/platforms.txt b/extra/fullscreen/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/extra/fullscreen/platforms.txt @@ -0,0 +1 @@ +windows From 004608e1f48171bc9697713663fc39a25751f2d8 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 27 Feb 2010 13:04:42 -0600 Subject: [PATCH 283/713] fix docs for csv --- basis/csv/csv-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/csv/csv-docs.factor b/basis/csv/csv-docs.factor index 075b00eea2..32c4cd53fb 100644 --- a/basis/csv/csv-docs.factor +++ b/basis/csv/csv-docs.factor @@ -30,7 +30,7 @@ HELP: string>csv HELP: csv>string { $values - { "rows" "a sequence of sequences of strings" } + { "csv" "csv" } { "string" string } } { $description "Writes a comma-separated-value structure to a string." } ; From da5743618016fc54e7c24957cb20d9c75ecfe45f Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Sat, 27 Feb 2010 14:52:24 -0500 Subject: [PATCH 284/713] Finishing eliminating prune as a synonym of members --- basis/regexp/classes/classes.factor | 9 +++++---- basis/regexp/parser/parser.factor | 2 +- basis/see/see.factor | 2 +- basis/simple-flat-file/simple-flat-file.factor | 2 +- basis/suffix-arrays/suffix-arrays.factor | 2 +- basis/tools/deploy/shaker/shaker.factor | 3 ++- basis/tools/profiler/profiler.factor | 3 ++- basis/ui/gestures/gestures.factor | 3 ++- basis/ui/ui.factor | 2 +- basis/unicode/data/data.factor | 2 +- basis/vocabs/metadata/metadata.factor | 2 +- basis/vocabs/refresh/monitor/monitor.factor | 2 +- basis/vocabs/refresh/refresh.factor | 2 +- basis/xmode/keyword-map/keyword-map.factor | 2 +- core/classes/algebra/algebra.factor | 6 ++++-- core/sets/sets.factor | 1 - extra/contributors/contributors.factor | 2 +- extra/fuel/xref/xref.factor | 4 ++-- extra/html/parser/analyzer/analyzer.factor | 2 +- extra/koszul/koszul.factor | 5 +---- extra/mason/test/test.factor | 4 ++-- extra/project-euler/004/004.factor | 2 +- extra/project-euler/029/029.factor | 2 +- extra/project-euler/032/032.factor | 4 ++-- extra/project-euler/059/059.factor | 2 +- extra/project-euler/079/079.factor | 6 +++--- extra/project-euler/203/203.factor | 2 +- extra/spider/spider.factor | 2 +- 28 files changed, 42 insertions(+), 40 deletions(-) diff --git a/basis/regexp/classes/classes.factor b/basis/regexp/classes/classes.factor index e3e2f0bcf3..fd4c7e7e4f 100644 --- a/basis/regexp/classes/classes.factor +++ b/basis/regexp/classes/classes.factor @@ -5,6 +5,7 @@ unicode.categories combinators.short-circuit sequences fry macros arrays assocs sets classes mirrors unicode.script unicode.data ; FROM: ascii => ascii? ; +FROM: sets => members ; IN: regexp.classes SINGLETONS: dot letter-class LETTER-class Letter-class digit-class @@ -157,7 +158,7 @@ DEFER: substitute TUPLE: class-partition integers not-integers simples not-simples and or other ; : partition-classes ( seq -- class-partition ) - prune + members [ integer? ] partition [ not-integer? ] partition [ simple-class? ] partition @@ -194,7 +195,7 @@ TUPLE: class-partition integers not-integers simples not-simples and or other ; [ t swap remove ] change-other dup contradiction? [ drop f ] - [ filter-not-integers class-partition>seq prune t and-class seq>instance ] if ; + [ filter-not-integers class-partition>seq members t and-class seq>instance ] if ; : ( seq -- class ) dup and-class flatten partition-classes @@ -225,7 +226,7 @@ TUPLE: class-partition integers not-integers simples not-simples and or other ; [ f swap remove ] change-other dup tautology? [ drop t ] - [ filter-integers class-partition>seq prune f or-class seq>instance ] if ; + [ filter-integers class-partition>seq members f or-class seq>instance ] if ; : ( seq -- class ) dup or-class flatten partition-classes @@ -329,7 +330,7 @@ M: object class>questions 1array ; : condition-states ( condition -- states ) dup condition? [ [ yes>> ] [ no>> ] bi - [ condition-states ] bi@ append prune + [ condition-states ] bi@ union ] [ 1array ] if ; : condition-at ( condition assoc -- new-condition ) diff --git a/basis/regexp/parser/parser.factor b/basis/regexp/parser/parser.factor index 70281aa798..0025b89d56 100644 --- a/basis/regexp/parser/parser.factor +++ b/basis/regexp/parser/parser.factor @@ -27,7 +27,7 @@ ERROR: bad-class name ; [ [ simple ] keep ] H{ } map>assoc ; MEMO: simple-script-table ( -- table ) - script-table interval-values prune simple-table ; + script-table interval-values members simple-table ; MEMO: simple-category-table ( -- table ) categories simple-table ; diff --git a/basis/see/see.factor b/basis/see/see.factor index bb6ae5cf2d..0d93757086 100644 --- a/basis/see/see.factor +++ b/basis/see/see.factor @@ -239,7 +239,7 @@ PRIVATE> dup class? [ dup seeing-implementors % ] when dup generic? [ dup seeing-methods % ] when drop - ] { } make prune ; + ] { } make members ; : see-methods ( word -- ) methods see-all nl ; diff --git a/basis/simple-flat-file/simple-flat-file.factor b/basis/simple-flat-file/simple-flat-file.factor index 88a64b7746..a2fa8c3c4c 100644 --- a/basis/simple-flat-file/simple-flat-file.factor +++ b/basis/simple-flat-file/simple-flat-file.factor @@ -47,7 +47,7 @@ SYMBOL: interned ] { } make ; : process-interval-file ( ranges -- table ) - dup values prune interned + dup values members interned [ expand-ranges ] with-variable ; : load-interval-file ( filename -- table ) diff --git a/basis/suffix-arrays/suffix-arrays.factor b/basis/suffix-arrays/suffix-arrays.factor index 134c144fda..8f728c1eda 100644 --- a/basis/suffix-arrays/suffix-arrays.factor +++ b/basis/suffix-arrays/suffix-arrays.factor @@ -35,5 +35,5 @@ SYNTAX: SA{ \ } [ >suffix-array ] parse-literal ; : query ( begin suffix-array -- matches ) 2dup find-index dup - [ -rot [ from-to ] keep [ seq>> ] map prune ] + [ -rot [ from-to ] keep [ seq>> ] map members ] [ 3drop { } ] if ; diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index 73d4b919d5..6fb6ab91ec 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -21,6 +21,7 @@ QUALIFIED: source-files.errors QUALIFIED: vocabs FROM: alien.libraries.private => >deployed-library-path ; FROM: namespaces => set ; +FROM: sets => members ; IN: tools.deploy.shaker ! This file is some hairy shit. @@ -507,7 +508,7 @@ SYMBOL: deploy-vocab : write-vocab-manifest ( vocab-manifest-out -- ) "Writing vocabulary manifest to " write dup print flush vocabs "VOCABS:" prefix - deploy-libraries get [ libraries get at path>> ] map prune "LIBRARIES:" prefix append + deploy-libraries get [ libraries get at path>> ] map members "LIBRARIES:" prefix append swap utf8 set-file-lines ; : prepare-deploy-libraries ( -- ) diff --git a/basis/tools/profiler/profiler.factor b/basis/tools/profiler/profiler.factor index b0ce5dfbe4..c79d8b443c 100644 --- a/basis/tools/profiler/profiler.factor +++ b/basis/tools/profiler/profiler.factor @@ -5,6 +5,7 @@ io io.styles namespaces assocs kernel.private strings combinators sorting math.parser vocabs definitions tools.profiler.private tools.crossref continuations generic compiler.units compiler.crossref sets classes fry ; +FROM: sets => members ; IN: tools.profiler : profile ( quot -- ) @@ -41,7 +42,7 @@ IN: tools.profiler [ smart-usage [ word? ] filter ] [ generic-call-sites-of keys ] [ effect-dependencies-of keys ] - tri 3append prune ; + tri 3append members ; : usage-counters ( word -- alist ) profiler-usage counters ; diff --git a/basis/ui/gestures/gestures.factor b/basis/ui/gestures/gestures.factor index 30c96335cc..6e8e73ab55 100644 --- a/basis/ui/gestures/gestures.factor +++ b/basis/ui/gestures/gestures.factor @@ -6,6 +6,7 @@ math.vectors classes.tuple classes boxes calendar alarms combinators sets columns fry deques ui.gadgets ui.gadgets.private ascii combinators.short-circuit ; FROM: namespaces => set ; +FROM: sets => members ; IN: ui.gestures : get-gesture-handler ( gesture gadget -- quot ) @@ -235,7 +236,7 @@ SYMBOL: drag-timer : modifier ( mod modifiers -- seq ) [ second swap bitand 0 > ] with filter - 0 prune [ f ] [ >array ] if-empty ; + 0 members [ f ] [ >array ] if-empty ; : drag-loc ( -- loc ) hand-loc get-global hand-click-loc get-global v- ; diff --git a/basis/ui/ui.factor b/basis/ui/ui.factor index 824ffb8351..bf32b329ce 100644 --- a/basis/ui/ui.factor +++ b/basis/ui/ui.factor @@ -138,7 +138,7 @@ M: world ungraft* layout-queue [ dup layout find-world [ , ] when* ] slurp-deque - ] { } make prune ; + ] { } make members ; : redraw-worlds ( seq -- ) [ dup update-hand draw-world ] each ; diff --git a/basis/unicode/data/data.factor b/basis/unicode/data/data.factor index 85b59de750..ff4e64df29 100644 --- a/basis/unicode/data/data.factor +++ b/basis/unicode/data/data.factor @@ -184,7 +184,7 @@ C: code-point ] assoc-map ; : properties>intervals ( properties -- assoc[str,interval] ) - dup values prune [ f ] H{ } map>assoc + dup values members [ f ] H{ } map>assoc [ [ push-at ] curry assoc-each ] keep [ ] assoc-map ; diff --git a/basis/vocabs/metadata/metadata.factor b/basis/vocabs/metadata/metadata.factor index 09ca012fcc..5048b0edd0 100644 --- a/basis/vocabs/metadata/metadata.factor +++ b/basis/vocabs/metadata/metadata.factor @@ -73,7 +73,7 @@ M: vocab-link summary vocab-summary ; dup vocab-tags-path set-vocab-file-contents ; : add-vocab-tags ( tags vocab -- ) - [ vocab-tags append prune ] keep set-vocab-tags ; + [ vocab-tags append members ] keep set-vocab-tags ; : remove-vocab-tags ( tags vocab -- ) [ vocab-tags swap diff ] keep set-vocab-tags ; diff --git a/basis/vocabs/refresh/monitor/monitor.factor b/basis/vocabs/refresh/monitor/monitor.factor index 1bf73862e6..6274921bdb 100644 --- a/basis/vocabs/refresh/monitor/monitor.factor +++ b/basis/vocabs/refresh/monitor/monitor.factor @@ -39,7 +39,7 @@ TR: convert-separators "/\\" ".." ; : monitor-thread ( -- ) [ [ - vocab-roots get prune [ add-monitor-for-path ] each + vocab-roots get [ add-monitor-for-path ] each H{ } clone changed-vocabs set-global vocabs [ changed-vocab ] each diff --git a/basis/vocabs/refresh/refresh.factor b/basis/vocabs/refresh/refresh.factor index 3dc67712de..3d9c91bbcd 100644 --- a/basis/vocabs/refresh/refresh.factor +++ b/basis/vocabs/refresh/refresh.factor @@ -82,7 +82,7 @@ SYMBOL: modified-docs [ [ vocab f >>docs-loaded? drop ] each ] bi* ] [ - append prune + union [ unchanged-vocabs ] [ require-all load-failures. ] bi ] 2bi ; diff --git a/basis/xmode/keyword-map/keyword-map.factor b/basis/xmode/keyword-map/keyword-map.factor index 877eda44aa..402dd974b1 100644 --- a/basis/xmode/keyword-map/keyword-map.factor +++ b/basis/xmode/keyword-map/keyword-map.factor @@ -32,7 +32,7 @@ M: keyword-map >alist assoc>> >alist ; : (keyword-map-no-word-sep) ( assoc -- str ) - keys concat [ alpha? not ] filter prune natural-sort ; + keys combine [ alpha? not ] filter natural-sort ; : keyword-map-no-word-sep* ( keyword-map -- str ) dup no-word-sep>> [ ] [ diff --git a/core/classes/algebra/algebra.factor b/core/classes/algebra/algebra.factor index 96fa34314e..ae217904b7 100644 --- a/core/classes/algebra/algebra.factor +++ b/core/classes/algebra/algebra.factor @@ -4,6 +4,7 @@ USING: kernel classes classes.private combinators accessors sequences arrays vectors assocs namespaces words sorting layouts math hashtables kernel.private sets math.order ; FROM: classes => members ; +RENAME: members sets => set-members IN: classes.algebra ( members -- class ) - [ null eq? not ] filter prune + [ null eq? not ] filter set-members dup length 1 = [ first ] [ anonymous-union boa ] if ; TUPLE: anonymous-intersection { participants read-only } ; : ( participants -- class ) - prune dup length 1 = [ first ] [ anonymous-intersection boa ] if ; + set-members dup length 1 = + [ first ] [ anonymous-intersection boa ] if ; TUPLE: anonymous-complement { class read-only } ; diff --git a/core/sets/sets.factor b/core/sets/sets.factor index 5e7c3b1617..5274c07d37 100644 --- a/core/sets/sets.factor +++ b/core/sets/sets.factor @@ -105,7 +105,6 @@ M: sequence all-unique? ! Temporarily for compatibility -ALIAS: prune members : unique ( seq -- assoc ) [ dup ] H{ } map>assoc ; : conjoin ( elt assoc -- ) diff --git a/extra/contributors/contributors.factor b/extra/contributors/contributors.factor index 97f4edc521..1ca62beef3 100644 --- a/extra/contributors/contributors.factor +++ b/extra/contributors/contributors.factor @@ -11,7 +11,7 @@ IN: contributors ] with-directory ; : patch-counts ( authors -- assoc ) - dup prune + dup members [ dup rot [ = ] with count ] with { } map>assoc ; diff --git a/extra/fuel/xref/xref.factor b/extra/fuel/xref/xref.factor index 39ba3bd2b3..649081ff03 100644 --- a/extra/fuel/xref/xref.factor +++ b/extra/fuel/xref/xref.factor @@ -29,7 +29,7 @@ IN: fuel.xref [ word? ] filter [ word>xref ] map ; : filter-prefix ( seq prefix -- seq ) - [ drop-prefix nip length 0 = ] curry filter prune ; + [ drop-prefix nip length 0 = ] curry filter members ; MEMO: (vocab-words) ( name -- seq ) >vocab-link words [ name>> ] map ; @@ -40,7 +40,7 @@ MEMO: (vocab-words) ( name -- seq ) append H{ } [ assoc-union ] reduce keys ; : vocabs-words ( names -- seq ) - prune [ (vocab-words) ] map concat ; + members [ (vocab-words) ] map concat ; PRIVATE> diff --git a/extra/html/parser/analyzer/analyzer.factor b/extra/html/parser/analyzer/analyzer.factor index 2d0b9514ff..760fd1e47b 100644 --- a/extra/html/parser/analyzer/analyzer.factor +++ b/extra/html/parser/analyzer/analyzer.factor @@ -145,7 +145,7 @@ TUPLE: link attributes clickable ; [ >url ] map ; : find-all-links ( vector -- vector' ) - [ find-hrefs ] [ find-frame-links ] bi append prune ; + [ find-hrefs ] [ find-frame-links ] bi union ; : find-forms ( vector -- vector' ) "form" over find-opening-tags-by-name diff --git a/extra/koszul/koszul.factor b/extra/koszul/koszul.factor index 81086e8064..58c90df6e9 100644 --- a/extra/koszul/koszul.factor +++ b/extra/koszul/koszul.factor @@ -79,11 +79,8 @@ SYMBOL: terms [ nth ] 2keep swap 1 + tail-slice (inversions) + ] curry each ; -: duplicates? ( seq -- ? ) - dup prune [ length ] bi@ > ; - : (wedge) ( n basis1 basis2 -- n basis ) - append dup duplicates? [ + append dup all-unique? not [ 2drop 0 { } ] [ dup permutation inversions -1^ rot * diff --git a/extra/mason/test/test.factor b/extra/mason/test/test.factor index bd703d3cb9..8593e47413 100644 --- a/extra/mason/test/test.factor +++ b/extra/mason/test/test.factor @@ -23,7 +23,7 @@ M: method word-vocabulary "method-generic" word-prop word-vocabulary ; :: do-step ( errors summary-file details-file -- ) errors [ error-type +linkage-error+ eq? not ] filter - [ file>> ] map prune natural-sort summary-file to-file + [ file>> ] map members natural-sort summary-file to-file errors details-file utf8 [ errors. ] with-file-writer ; : do-tests ( -- ) @@ -55,7 +55,7 @@ M: method word-vocabulary "method-generic" word-prop word-vocabulary ; "" to-refresh drop 2dup [ empty? not ] either? [ "Boot image is out of date. Changed vocabs:" print - append prune [ print ] each + members [ print ] each flush 1 exit ] [ 2drop ] if ; diff --git a/extra/project-euler/004/004.factor b/extra/project-euler/004/004.factor index 1bb9ebbef5..342e8d1a9e 100644 --- a/extra/project-euler/004/004.factor +++ b/extra/project-euler/004/004.factor @@ -29,7 +29,7 @@ IN: project-euler.004 PRIVATE> : euler004 ( -- answer ) - source-004 dup [ * ] cartesian-map concat prune max-palindrome ; + source-004 dup [ * ] cartesian-map combine max-palindrome ; ! [ euler004 ] 100 ave-time ! 1164 ms ave run time - 39.35 SD (100 trials) diff --git a/extra/project-euler/029/029.factor b/extra/project-euler/029/029.factor index 31be1a566b..944d345938 100644 --- a/extra/project-euler/029/029.factor +++ b/extra/project-euler/029/029.factor @@ -29,7 +29,7 @@ IN: project-euler.029 ! -------- : euler029 ( -- answer ) - 2 100 [a,b] dup [ ^ ] cartesian-map concat prune length ; + 2 100 [a,b] dup [ ^ ] cartesian-map concat members length ; ! [ euler029 ] 100 ave-time ! 704 ms ave run time - 28.07 SD (100 trials) diff --git a/extra/project-euler/032/032.factor b/extra/project-euler/032/032.factor index 7def55b659..de0cb72609 100644 --- a/extra/project-euler/032/032.factor +++ b/extra/project-euler/032/032.factor @@ -48,7 +48,7 @@ IN: project-euler.032 PRIVATE> : euler032 ( -- answer ) - source-032 [ valid? ] filter products prune sum ; + source-032 [ valid? ] filter products members sum ; ! [ euler032 ] 10 ave-time ! 16361 ms ave run time - 417.8 SD (10 trials) @@ -72,7 +72,7 @@ PRIVATE> 50 [1,b] 2000 [1,b] [ mmp ] cartesian-map concat [ pandigital? ] filter - products prune sum ; + products members sum ; ! [ euler032a ] 10 ave-time ! 2624 ms ave run time - 131.91 SD (10 trials) diff --git a/extra/project-euler/059/059.factor b/extra/project-euler/059/059.factor index 1fb5c7c8bb..306746b601 100644 --- a/extra/project-euler/059/059.factor +++ b/extra/project-euler/059/059.factor @@ -70,7 +70,7 @@ INSTANCE: rollover immutable-sequence over length swap [ bitxor ] 2map ; : frequency-analysis ( seq -- seq ) - dup prune [ + dup members [ [ 2dup [ = ] curry count 2array , ] each ] { } make nip ; inline diff --git a/extra/project-euler/079/079.factor b/extra/project-euler/079/079.factor index 3ad7406703..e0a616dc52 100644 --- a/extra/project-euler/079/079.factor +++ b/extra/project-euler/079/079.factor @@ -35,7 +35,7 @@ IN: project-euler.079 ] { } make ; : find-source ( seq -- elt ) - unzip diff prune + unzip diff [ "Topological sort failed" throw ] [ first ] if-empty ; : remove-source ( seq elt -- seq ) @@ -52,7 +52,7 @@ PRIVATE> : topological-sort ( seq -- seq ) [ [ (topological-sort) ] { } make ] keep - concat prune over diff append ; + combine over diff append ; : euler079 ( -- answer ) source-079 >edges topological-sort 10 digits>integer ; @@ -60,7 +60,7 @@ PRIVATE> ! [ euler079 ] 100 ave-time ! 1 ms ave run time - 0.46 SD (100 trials) -! TODO: prune and diff are relatively slow; topological sort could be +! TODO: set words on sequences are relatively slow; topological sort could be ! cleaned up and generalized much better, but it works for this problem SOLUTION: euler079 diff --git a/extra/project-euler/203/203.factor b/extra/project-euler/203/203.factor index 806098b865..2077fe328e 100644 --- a/extra/project-euler/203/203.factor +++ b/extra/project-euler/203/203.factor @@ -45,7 +45,7 @@ IN: project-euler.203 [ 0 prefix ] [ 0 suffix ] bi [ + ] 2map ; : generate ( n -- seq ) - 1 - { 1 } [ (generate) ] iterate concat prune ; + 1 - { 1 } [ (generate) ] iterate combine ; : squarefree ( n -- ? ) factors all-unique? ; diff --git a/extra/spider/spider.factor b/extra/spider/spider.factor index c8ea4734d2..2a0b2946e5 100644 --- a/extra/spider/spider.factor +++ b/extra/spider/spider.factor @@ -48,7 +48,7 @@ fetched-in parsed-html links processed-in fetched-at ; nonmatching>> push-links ; : filter-base-links ( spider spider-result -- base-links nonmatching-links ) - [ base>> host>> ] [ links>> prune ] bi* + [ base>> host>> ] [ links>> members ] bi* [ host>> = ] with partition ; : add-spidered ( spider spider-result -- ) From e7d2e732153306f5702a8edb6aeaf2590634984e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 28 Feb 2010 19:44:18 +1300 Subject: [PATCH 285/713] webapps.help: fix typo --- extra/webapps/help/search.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/webapps/help/search.xml b/extra/webapps/help/search.xml index bcaed59ea4..f6b364f089 100644 --- a/extra/webapps/help/search.xml +++ b/extra/webapps/help/search.xml @@ -23,7 +23,7 @@

This is the Factor documentation, generated offline from a - load-everything image. If you want, you can also browse the + load-all image. If you want, you can also browse the documentation from within the Factor UI.

You may search article titles below; for example, try searching for "HTTP".

From 163c26ad7242b440a9737f8d0087c1ec19ba4790 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 28 Feb 2010 13:01:03 -0800 Subject: [PATCH 286/713] lexer, parser: show initial parsing word line as part of lexer-errors --- core/lexer/lexer.factor | 50 ++++++++++++++++++++++++++++++++------- core/parser/parser.factor | 7 +++++- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/core/lexer/lexer.factor b/core/lexer/lexer.factor index b3bd3cacdb..3b0348aa10 100644 --- a/core/lexer/lexer.factor +++ b/core/lexer/lexer.factor @@ -5,7 +5,9 @@ io vectors arrays math.parser combinators continuations source-files.errors ; IN: lexer -TUPLE: lexer text line line-text line-length column ; +TUPLE: lexer text line line-text line-length column parsing-words ; + +TUPLE: lexer-parsing-word word line line-text column ; : next-line ( lexer -- ) dup [ line>> ] [ text>> ] bi ?nth >>line-text @@ -14,10 +16,23 @@ TUPLE: lexer text line line-text line-length column ; 0 >>column drop ; +: push-parsing-word ( word -- ) + lexer-parsing-word new + swap >>word + lexer get [ + [ line>> >>line ] + [ line-text>> >>line-text ] + [ column>> >>column ] tri + ] [ parsing-words>> push ] bi ; + +: pop-parsing-word ( -- ) + lexer get parsing-words>> pop drop ; + : new-lexer ( text class -- lexer ) new 0 >>line swap >>text + V{ } clone >>parsing-words dup next-line ; inline : ( text -- lexer ) @@ -92,27 +107,46 @@ PREDICATE: unexpected-eof < unexpected : parse-tokens ( end -- seq ) 100 swap (parse-tokens) >array ; -TUPLE: lexer-error line column line-text error ; +TUPLE: lexer-error line column line-text parsing-words error ; M: lexer-error error-file error>> error-file ; M: lexer-error error-line [ error>> error-line ] [ line>> ] bi or ; : ( msg -- error ) \ lexer-error new - lexer get - [ line>> >>line ] - [ column>> >>column ] - [ line-text>> >>line-text ] - tri + lexer get [ + [ line>> >>line ] + [ column>> >>column ] bi + ] [ + [ line-text>> >>line-text ] + [ parsing-words>> clone >>parsing-words ] bi + ] bi swap >>error ; -: lexer-dump ( error -- ) +: simple-lexer-dump ( error -- ) [ line>> number>string ": " append ] [ line-text>> dup string? [ drop "" ] unless ] [ column>> 0 or ] tri pick length + CHAR: \s [ write ] [ print ] [ write "^" print ] tri* ; +: (parsing-word-lexer-dump) ( error parsing-word -- ) + [ + line>> number>string + over line>> number>string length + CHAR: \s pad-head + ": " append write + ] [ line-text>> dup string? [ drop "" ] unless print ] bi + simple-lexer-dump ; + +: parsing-word-lexer-dump ( error parsing-word -- ) + 2dup [ line>> ] bi@ = + [ drop simple-lexer-dump ] + [ (parsing-word-lexer-dump) ] if ; + +: lexer-dump ( error -- ) + dup parsing-words>> [ simple-lexer-dump ] [ last parsing-word-lexer-dump ] if-empty ; + : with-lexer ( lexer quot -- newquot ) [ lexer set ] dip [ rethrow ] recover ; inline diff --git a/core/parser/parser.factor b/core/parser/parser.factor index e3e7d79c40..3257bd69a4 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -58,9 +58,14 @@ SYMBOL: auto-use? ERROR: staging-violation word ; +: (execute-parsing) ( accum word -- accum ) + dup push-parsing-word + execute( accum -- accum ) + pop-parsing-word ; inline + : execute-parsing ( accum word -- accum ) dup changed-definitions get key? [ staging-violation ] when - execute( accum -- accum ) ; + (execute-parsing) ; : scan-object ( -- object ) scan-word { From e3ddafbdecdd778e036bb7f0d99f80d2337e081c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 1 Mar 2010 12:22:18 +1300 Subject: [PATCH 287/713] core-foundation.run-loop: clean up and speed up some code to fix starvation issue exposed by game.loop (reported by Joe Groff) --- .../core-foundation/run-loop/run-loop.factor | 22 ++++++++----------- basis/core-foundation/time/time.factor | 12 +++++----- basis/core-foundation/timers/timers.factor | 4 ++-- extra/game/loop/loop.factor | 2 +- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/basis/core-foundation/run-loop/run-loop.factor b/basis/core-foundation/run-loop/run-loop.factor index 56b5a9c798..c1316eaa16 100644 --- a/basis/core-foundation/run-loop/run-loop.factor +++ b/basis/core-foundation/run-loop/run-loop.factor @@ -99,22 +99,18 @@ TUPLE: run-loop fds sources timers ; CFAbsoluteTime CFRunLoopTimerSetNextFireDate ; +: (reset-timer) ( timer timestamp -- ) + >CFAbsoluteTime CFRunLoopTimerSetNextFireDate ; -: nano-count>timestamp ( x -- timestamp ) - nano-count - nanoseconds now time+ ; - -: (reset-timer) ( timer counter -- ) - yield { - { [ dup 0 = ] [ now ((reset-timer)) ] } - { [ run-queue deque-empty? not ] [ 1 - (reset-timer) ] } - { [ sleep-queue heap-empty? ] [ 5 minutes hence ((reset-timer)) ] } - [ sleep-queue heap-peek nip nano-count>timestamp ((reset-timer)) ] - } cond ; +: nano-count>micros ( x -- n ) + nano-count - 1,000 /f system-micros + ; : reset-timer ( timer -- ) - 10 (reset-timer) ; + yield { + { [ run-queue deque-empty? not ] [ yield system-micros (reset-timer) ] } + { [ sleep-queue heap-empty? ] [ system-micros 1,000,000 + (reset-timer) ] } + [ sleep-queue heap-peek nip nano-count>micros (reset-timer) ] + } cond ; PRIVATE> diff --git a/basis/core-foundation/time/time.factor b/basis/core-foundation/time/time.factor index 8f09652462..59dd8098b4 100644 --- a/basis/core-foundation/time/time.factor +++ b/basis/core-foundation/time/time.factor @@ -1,6 +1,6 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: calendar alien.c-types alien.syntax ; +USING: calendar math alien.c-types alien.syntax memoize system ; IN: core-foundation.time TYPEDEF: double CFTimeInterval @@ -9,6 +9,8 @@ TYPEDEF: double CFAbsoluteTime : >CFTimeInterval ( duration -- interval ) duration>seconds ; inline -: >CFAbsoluteTime ( timestamp -- time ) - T{ timestamp { year 2001 } { month 1 } { day 1 } } time- - duration>seconds ; inline +MEMO: epoch ( -- micros ) + T{ timestamp { year 2001 } { month 1 } { day 1 } } timestamp>micros ; + +: >CFAbsoluteTime ( micros -- time ) + epoch - 1,000,000 /f ; inline diff --git a/basis/core-foundation/timers/timers.factor b/basis/core-foundation/timers/timers.factor index cf17cb41d9..343753385a 100644 --- a/basis/core-foundation/timers/timers.factor +++ b/basis/core-foundation/timers/timers.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: alien.c-types alien.syntax system math kernel calendar core-foundation core-foundation.time ; @@ -19,7 +19,7 @@ FUNCTION: CFRunLoopTimerRef CFRunLoopTimerCreate ( ) ; : ( callback -- timer ) - [ f now >CFAbsoluteTime 60 0 0 ] dip f CFRunLoopTimerCreate ; + [ f system-micros >CFAbsoluteTime 60 0 0 ] dip f CFRunLoopTimerCreate ; FUNCTION: void CFRunLoopTimerInvalidate ( CFRunLoopTimerRef timer diff --git a/extra/game/loop/loop.factor b/extra/game/loop/loop.factor index 9e46535b4e..00fe14c3cd 100644 --- a/extra/game/loop/loop.factor +++ b/extra/game/loop/loop.factor @@ -66,7 +66,7 @@ TUPLE: game-loop-error game-loop error ; : (run-loop) ( loop -- ) dup running?>> - [ [ MAX-FRAMES-TO-SKIP ?tick ] [ redraw ] [ 1 milliseconds sleep (run-loop) ] tri ] + [ [ MAX-FRAMES-TO-SKIP ?tick ] [ redraw ] [ yield (run-loop) ] tri ] [ drop ] if ; : run-loop ( loop -- ) From 078ca0fa5876275272e46a24e96770879388cb07 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 28 Feb 2010 16:15:58 -0800 Subject: [PATCH 288/713] alien.parser: refactor FUNCTION: parsing to read from the source incrementally. parse errors in FUNCTION: should now correspond to their location within the definition --- basis/alien/parser/parser.factor | 63 ++++++++++++++------------- basis/alien/syntax/syntax-docs.factor | 5 --- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index cf8c878589..f4331b3624 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -59,64 +59,65 @@ ERROR: *-in-c-type-name name ; [ ] } cleave ; -: normalize-c-arg ( type name -- type' name' ) - [ length ] - [ - [ CHAR: * = ] trim-head - [ length - CHAR: * append ] keep - ] bi - [ parse-c-type ] dip ; - > ; M: pointer return-type-name to>> return-type-name CHAR: * suffix ; + +: parse-pointers ( type name -- type' name' ) + "*" ?head + [ [ ] dip parse-pointers ] when ; + PRIVATE> -: parse-arglist ( parameters return -- types effect ) - [ - 2 group [ first2 normalize-c-arg 2array ] map - unzip [ "," ?tail drop ] map - ] - [ [ { } ] [ return-type-name 1array ] if-void ] - bi* ; +: scan-function-name ( -- return function ) + scan-c-type scan parse-pointers ; + +:: (scan-c-args) ( end-marker types names -- ) + scan :> type-str + type-str end-marker = [ + type-str { "(" ")" } member? [ + type-str parse-c-type :> type + scan :> name + type name parse-pointers :> ( type' name' ) + type' types push name' names push + ] unless + end-marker types names (scan-c-args) + ] unless ; + +: scan-c-args ( end-marker -- types names ) + V{ } clone V{ } clone [ (scan-c-args) ] 2keep [ >array ] bi@ ; : function-quot ( return library function types -- quot ) '[ _ _ _ _ alien-invoke ] ; -:: make-function ( return library function parameters -- word quot effect ) - return function normalize-c-arg :> ( return function ) - function create-in dup reset-generic - return library function - parameters return parse-arglist [ function-quot ] dip ; +: function-effect ( names return -- effect ) + [ { } ] [ return-type-name 1array ] if-void ; -: parse-arg-tokens ( -- tokens ) - ";" parse-tokens [ "()" subseq? not ] filter ; +:: make-function ( return function library types names -- word quot effect ) + function create-in dup reset-generic + return library function types function-quot + names return function-effect ; : (FUNCTION:) ( -- word quot effect ) - scan "c-library" get scan parse-arg-tokens make-function ; - -: define-function ( return library function parameters -- ) - make-function define-declared ; + scan-function-name "c-library" get ";" scan-c-args make-function ; : callback-quot ( return types abi -- quot ) '[ [ _ _ _ ] dip alien-callback ] ; -:: make-callback-type ( lib return type-name parameters -- word quot effect ) - return type-name normalize-c-arg :> ( return type-name ) +:: make-callback-type ( lib return type-name types names -- word quot effect ) type-name current-vocab create :> type-word type-word [ reset-generic ] [ reset-c-type ] bi void* type-word typedef - parameters return parse-arglist :> ( types callback-effect ) - type-word callback-effect "callback-effect" set-word-prop + type-word names return function-effect "callback-effect" set-word-prop type-word lib "callback-library" set-word-prop type-word return types lib library-abi callback-quot (( quot -- alien )) ; : (CALLBACK:) ( -- word quot effect ) "c-library" get - scan scan parse-arg-tokens make-callback-type ; + scan-function-name ";" scan-c-args make-callback-type ; PREDICATE: alien-function-word < word def>> { diff --git a/basis/alien/syntax/syntax-docs.factor b/basis/alien/syntax/syntax-docs.factor index 3d1c757035..58b43cec31 100644 --- a/basis/alien/syntax/syntax-docs.factor +++ b/basis/alien/syntax/syntax-docs.factor @@ -112,11 +112,6 @@ HELP: c-struct? { $values { "c-type" "a C type" } { "?" "a boolean" } } { $description "Tests if a C type is a structure defined by " { $link POSTPONE: STRUCT: } "." } ; -HELP: define-function -{ $values { "return" "a C return type" } { "library" "a logical library name" } { "function" "a C function name" } { "parameters" "a sequence of C parameter types" } } -{ $description "Defines a word named " { $snippet "function" } " in the current vocabulary (see " { $link "vocabularies" } "). The word calls " { $link alien-invoke } " with the specified parameters." } -{ $notes "This word is used to implement the " { $link POSTPONE: FUNCTION: } " parsing word." } ; - HELP: C-GLOBAL: { $syntax "C-GLOBAL: type name" } { $values { "type" "a C type" } { "name" "a C global variable name" } } From 9412fe82973d4fbf6f31fa9535cd0d8da306917d Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 28 Feb 2010 16:40:34 -0800 Subject: [PATCH 289/713] update GL-FUNCTION: to use new FUNCTION: factors --- basis/opengl/gl/extensions/extensions.factor | 27 +++++++++----------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/basis/opengl/gl/extensions/extensions.factor b/basis/opengl/gl/extensions/extensions.factor index 17813b8c82..530f3ada6c 100644 --- a/basis/opengl/gl/extensions/extensions.factor +++ b/basis/opengl/gl/extensions/extensions.factor @@ -11,11 +11,11 @@ ERROR: unknown-gl-platform ; [ unknown-gl-platform ] } cond use-vocab >> -SYMBOL: +gl-function-number-counter+ +SYMBOL: +gl-function-counter+ SYMBOL: +gl-function-pointers+ : reset-gl-function-number-counter ( -- ) - 0 +gl-function-number-counter+ set-global ; + 0 +gl-function-counter+ set-global ; : reset-gl-function-pointers ( -- ) 100 +gl-function-pointers+ set-global ; @@ -23,9 +23,9 @@ SYMBOL: +gl-function-pointers+ reset-gl-function-pointers reset-gl-function-number-counter -: gl-function-number ( -- n ) - +gl-function-number-counter+ get-global - dup 1 + +gl-function-number-counter+ set-global ; +: gl-function-counter ( -- n ) + +gl-function-counter+ get-global + dup 1 + +gl-function-counter+ set-global ; : gl-function-pointer ( names n -- funptr ) gl-function-context 2array dup +gl-function-pointers+ get-global at @@ -41,18 +41,15 @@ reset-gl-function-number-counter : indirect-quot ( function-ptr-quot return types abi -- quot ) '[ @ _ _ _ alien-indirect ] ; -:: define-indirect ( abi return function-ptr-quot function-name parameters -- ) +:: define-indirect ( abi return function-name function-ptr-quot types names -- ) function-name create-in dup reset-generic - function-ptr-quot return - parameters return parse-arglist [ abi indirect-quot ] dip + function-ptr-quot return types abi indirect-quot + names return function-effect define-declared ; SYNTAX: GL-FUNCTION: gl-function-calling-convention - scan-c-type - scan dup - scan drop "}" parse-tokens swap prefix - gl-function-number - [ gl-function-pointer ] 2curry swap - ";" parse-tokens [ "()" subseq? not ] filter - define-indirect ; + scan-function-name + "{" expect "}" parse-tokens over prefix + gl-function-counter '[ _ _ gl-function-pointer ] + ";" scan-c-args define-indirect ; From cd17a934ac1f33b45a218e0f4e036343462e9551 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 28 Feb 2010 19:29:53 -0800 Subject: [PATCH 290/713] cut commas off of FUNCTION: parameter names in stack effects again --- basis/alien/parser/parser.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index f4331b3624..c9ec2c3889 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -80,7 +80,7 @@ PRIVATE> type-str end-marker = [ type-str { "(" ")" } member? [ type-str parse-c-type :> type - scan :> name + scan "," ?tail drop :> name type name parse-pointers :> ( type' name' ) type' types push name' names push ] unless From bde65fe2d076ac57535b3f1961bf8e7dfd27c72e Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 28 Feb 2010 19:30:15 -0800 Subject: [PATCH 291/713] windows.com: update COM-INTERFACE: to parse incrementally --- basis/windows/com/syntax/syntax.factor | 45 ++++++++++-------------- basis/windows/com/wrapper/wrapper.factor | 6 +--- 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/basis/windows/com/syntax/syntax.factor b/basis/windows/com/syntax/syntax.factor index 5230d9497e..49c9272d9b 100644 --- a/basis/windows/com/syntax/syntax.factor +++ b/basis/windows/com/syntax/syntax.factor @@ -2,8 +2,8 @@ USING: alien alien.c-types alien.accessors alien.parser effects kernel windows.ole32 parser lexer splitting grouping sequences namespaces assocs quotations generalizations accessors words macros alien.syntax fry arrays layouts math -classes.struct windows.kernel32 ; -FROM: alien.parser.private => return-type-name ; +classes.struct windows.kernel32 locals ; +FROM: alien.parser.private => parse-pointers return-type-name ; IN: windows.com.syntax com-interface-definition -TUPLE: com-function-definition name return parameters ; +TUPLE: com-function-definition return name parameter-types parameter-names ; C: com-function-definition SYMBOL: +com-interface-definitions+ @@ -37,19 +37,20 @@ ERROR: no-com-interface interface ; : save-com-interface-definition ( definition -- ) dup word>> +com-interface-definitions+ get-global set-at ; -: (parse-com-function) ( tokens -- definition ) - [ second ] - [ first parse-c-type ] - [ - 3 tail [ CHAR: , swap remove ] map - 2 group [ first2 normalize-c-arg 2array ] map - { void* "this" } prefix - ] tri +: (parse-com-function) ( return name -- definition ) + ")" scan-c-args + [ pointer: void prefix ] [ "this" prefix ] bi* ; +:: (parse-com-functions) ( functions -- ) + scan dup ";" = [ drop ] [ + parse-c-type scan parse-pointers + (parse-com-function) functions push + functions (parse-com-functions) + ] if ; + : parse-com-functions ( -- functions ) - ";" parse-tokens { ")" } split harvest - [ (parse-com-function) ] map ; + V{ } clone [ (parse-com-functions) ] keep >array ; : (iid-word) ( definition -- word ) word>> name>> "-iid" append create-in ; @@ -66,20 +67,10 @@ ERROR: no-com-interface interface ; dup parent>> [ family-tree-functions ] [ { } ] if* swap functions>> append ; -: (invocation-quot) ( function return parameters -- quot ) - [ first ] map [ com-invoke ] 3curry ; - -: (stack-effect-from-return-and-parameters) ( return parameters -- stack-effect ) - swap - [ [ second ] map ] - [ dup void? [ drop { } ] [ return-type-name 1array ] if ] bi* - ; - -: (define-word-for-function) ( function interface n -- ) - -rot [ (function-word) swap ] 2keep drop - [ return>> ] [ parameters>> ] bi - [ (invocation-quot) ] 2keep - (stack-effect-from-return-and-parameters) +:: (define-word-for-function) ( function interface n -- ) + function interface (function-word) + n function [ return>> ] [ parameter-types>> ] bi '[ _ _ _ com-invoke ] + function [ parameter-names>> ] [ return>> ] bi function-effect define-declared ; : define-words-for-com-interface ( definition -- ) diff --git a/basis/windows/com/wrapper/wrapper.factor b/basis/windows/com/wrapper/wrapper.factor index 623a9c8db3..25861659dc 100644 --- a/basis/windows/com/wrapper/wrapper.factor +++ b/basis/windows/com/wrapper/wrapper.factor @@ -110,11 +110,7 @@ unless keep (next-vtbl-counter) '[ swap [ [ name>> _ _ (callback-word) ] - [ return>> ] [ - parameters>> - [ [ first ] map ] - [ length ] bi - ] tri + [ return>> ] [ parameter-types>> dup length ] tri ] [ first2 (finish-thunk) ] bi* From 1217dc9c6ed7a4c036b5fef0e66d64ba10364c3d Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Sun, 28 Feb 2010 22:42:10 -0500 Subject: [PATCH 292/713] Making alias analysis use sets --- basis/compiler/cfg/alias-analysis/alias-analysis.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/compiler/cfg/alias-analysis/alias-analysis.factor b/basis/compiler/cfg/alias-analysis/alias-analysis.factor index 810831f776..23e46f169b 100644 --- a/basis/compiler/cfg/alias-analysis/alias-analysis.factor +++ b/basis/compiler/cfg/alias-analysis/alias-analysis.factor @@ -298,14 +298,14 @@ SYMBOL: live-stores histories get values [ values [ [ store? ] filter [ insn#>> ] map ] map concat - ] map concat unique + ] map concat HS{ } set-like live-stores set ; GENERIC: eliminate-dead-stores* ( insn -- insn' ) : (eliminate-dead-stores) ( insn -- insn' ) dup insn-slot# [ - insn# get live-stores get key? [ + insn# get live-stores get in? [ drop f ] unless ] when ; From 1e5f202998efbd3af094a66d01d1077292fb06a3 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Sun, 28 Feb 2010 22:55:22 -0500 Subject: [PATCH 293/713] Maing vocabs.hierarchy use sets; modifying alias analysis's use of sets --- basis/compiler/cfg/alias-analysis/alias-analysis.factor | 2 +- basis/vocabs/hierarchy/hierarchy.factor | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/basis/compiler/cfg/alias-analysis/alias-analysis.factor b/basis/compiler/cfg/alias-analysis/alias-analysis.factor index 23e46f169b..24433ad594 100644 --- a/basis/compiler/cfg/alias-analysis/alias-analysis.factor +++ b/basis/compiler/cfg/alias-analysis/alias-analysis.factor @@ -298,7 +298,7 @@ SYMBOL: live-stores histories get values [ values [ [ store? ] filter [ insn#>> ] map ] map concat - ] map concat HS{ } set-like + ] map concat fast-set live-stores set ; GENERIC: eliminate-dead-stores* ( insn -- insn' ) diff --git a/basis/vocabs/hierarchy/hierarchy.factor b/basis/vocabs/hierarchy/hierarchy.factor index b840b5ab9d..986091a543 100644 --- a/basis/vocabs/hierarchy/hierarchy.factor +++ b/basis/vocabs/hierarchy/hierarchy.factor @@ -65,8 +65,8 @@ PRIVATE> #! Hack. [ vocab-prefix? ] partition [ - [ vocab-name ] map unique - '[ name>> _ key? not ] filter + [ vocab-name ] map fast-set + '[ name>> _ in? not ] filter convert-prefixes ] keep append ; From bb58cf4d161518d496f2c711e9572cb7140d1158 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 28 Feb 2010 20:14:16 -0800 Subject: [PATCH 294/713] classes.tuple.parser: throw bad-slot-name immediately when an invalid slot name in a tuple/struct literal is scanned --- core/classes/tuple/parser/parser.factor | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/core/classes/tuple/parser/parser.factor b/core/classes/tuple/parser/parser.factor index 7482cce048..5016bb38f6 100644 --- a/core/classes/tuple/parser/parser.factor +++ b/core/classes/tuple/parser/parser.factor @@ -68,23 +68,28 @@ ERROR: invalid-slot-name name ; ERROR: bad-literal-tuple ; -: parse-slot-value ( -- ) - scan scan-object 2array , scan { +ERROR: bad-slot-name class slot ; + +: check-slot-name ( class slots name -- name ) + 2dup swap slot-named* nip [ 2nip ] [ nip bad-slot-name ] if ; + +: parse-slot-value ( class slots -- ) + scan check-slot-name scan-object 2array , scan { { f [ \ } unexpected-eof ] } { "}" [ ] } [ bad-literal-tuple ] } case ; -: (parse-slot-values) ( -- ) - parse-slot-value +: (parse-slot-values) ( class slots -- ) + 2dup parse-slot-value scan { - { f [ \ } unexpected-eof ] } + { f [ 2drop \ } unexpected-eof ] } { "{" [ (parse-slot-values) ] } - { "}" [ ] } - [ bad-literal-tuple ] + { "}" [ 2drop ] } + [ 2nip bad-literal-tuple ] } case ; -: parse-slot-values ( -- values ) +: parse-slot-values ( class slots -- values ) [ (parse-slot-values) ] { } make ; GENERIC# boa>object 1 ( class slots -- tuple ) @@ -92,8 +97,6 @@ GENERIC# boa>object 1 ( class slots -- tuple ) M: tuple-class boa>object swap prefix >tuple ; -ERROR: bad-slot-name class slot ; - : check-slot-exists ( class initials slot-spec/f index/f name -- class initials slot-spec index ) over [ drop ] [ nip nip nip bad-slot-name ] if ; @@ -109,7 +112,7 @@ ERROR: bad-slot-name class slot ; scan { { f [ unexpected-eof ] } { "f" [ drop \ } parse-until boa>object ] } - { "{" [ parse-slot-values assoc>object ] } + { "{" [ 2dup parse-slot-values assoc>object ] } { "}" [ drop new ] } [ bad-literal-tuple ] } case ; From 9bf5c76771f82af8c301fe1cf6c70cd981a899d5 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 28 Feb 2010 22:06:47 -0800 Subject: [PATCH 295/713] lexer: add "each-token" and "map-tokens", which are equivalent to "parse-token _ each/map" but incremental. update a smattering of parsing words (such as USING:, SYMBOLS:, etc.) to use each-token/map-tokens --- basis/delegate/delegate.factor | 6 +++--- basis/locals/parser/parser.factor | 7 +++++-- basis/match/match.factor | 2 +- .../specialized-arrays/specialized-arrays.factor | 2 +- .../specialized-vectors.factor | 4 ++-- core/lexer/lexer.factor | 16 +++++++++------- core/syntax/syntax.factor | 8 +++----- extra/poker/poker.factor | 2 +- extra/slots/syntax/syntax.factor | 5 ++--- extra/vars/vars.factor | 2 +- 10 files changed, 28 insertions(+), 26 deletions(-) diff --git a/basis/delegate/delegate.factor b/basis/delegate/delegate.factor index 662a2840a1..dc3024b55f 100644 --- a/basis/delegate/delegate.factor +++ b/basis/delegate/delegate.factor @@ -157,6 +157,6 @@ M: protocol definer drop \ PROTOCOL: \ ; ; M: protocol group-words protocol-words ; SYNTAX: SLOT-PROTOCOL: - CREATE-WORD ";" parse-tokens - [ [ reader-word ] [ writer-word ] bi 2array ] map concat - define-protocol ; \ No newline at end of file + CREATE-WORD ";" + [ [ reader-word ] [ writer-word ] bi 2array ] + map-tokens concat define-protocol ; diff --git a/basis/locals/parser/parser.factor b/basis/locals/parser/parser.factor index c0184ee0ef..e742b4768a 100644 --- a/basis/locals/parser/parser.factor +++ b/basis/locals/parser/parser.factor @@ -21,6 +21,9 @@ SYMBOL: in-lambda? : make-locals ( seq -- words assoc ) [ [ make-local ] map ] H{ } make-assoc ; +: parse-local-defs ( -- words assoc ) + [ "|" [ make-local ] map-tokens ] H{ } make-assoc ; + : make-local-word ( name def -- word ) [ [ dup name>> set ] [ ] [ ] tri ] dip "local-word-def" set-word-prop ; @@ -42,12 +45,12 @@ SYMBOL: locals [ \ ] parse-until >quotation ] ((parse-lambda)) ; : parse-lambda ( -- lambda ) - "|" parse-tokens make-locals + parse-local-defs (parse-lambda) ?rewrite-closures ; : parse-multi-def ( locals -- multi-def ) - ")" parse-tokens swap [ [ make-local ] map ] bind ; + [ ")" [ make-local ] map-tokens ] bind ; : parse-def ( name/paren locals -- def ) over "(" = [ nip parse-multi-def ] [ [ make-local ] bind ] if ; diff --git a/basis/match/match.factor b/basis/match/match.factor index b6369249b3..9baadfe1f2 100644 --- a/basis/match/match.factor +++ b/basis/match/match.factor @@ -17,7 +17,7 @@ SYMBOL: _ [ define-match-var ] each ; SYNTAX: MATCH-VARS: ! vars ... - ";" parse-tokens define-match-vars ; + ";" [ define-match-var ] each-token ; : match-var? ( symbol -- bool ) dup word? [ "match-var" word-prop ] [ drop f ] if ; diff --git a/basis/specialized-arrays/specialized-arrays.factor b/basis/specialized-arrays/specialized-arrays.factor index b052becfed..11b050d5fc 100644 --- a/basis/specialized-arrays/specialized-arrays.factor +++ b/basis/specialized-arrays/specialized-arrays.factor @@ -168,7 +168,7 @@ M: c-type-word c-direct-array-constructor M: pointer c-direct-array-constructor drop void* c-direct-array-constructor ; SYNTAX: SPECIALIZED-ARRAYS: - ";" parse-tokens [ parse-c-type define-array-vocab use-vocab ] each ; + ";" [ parse-c-type define-array-vocab use-vocab ] each-token ; SYNTAX: SPECIALIZED-ARRAY: scan-c-type define-array-vocab use-vocab ; diff --git a/basis/specialized-vectors/specialized-vectors.factor b/basis/specialized-vectors/specialized-vectors.factor index 0c0569ea9d..3352c226d8 100644 --- a/basis/specialized-vectors/specialized-vectors.factor +++ b/basis/specialized-vectors/specialized-vectors.factor @@ -56,11 +56,11 @@ PRIVATE> generate-vocab ; SYNTAX: SPECIALIZED-VECTORS: - ";" parse-tokens [ + ";" [ parse-c-type [ define-array-vocab use-vocab ] [ define-vector-vocab use-vocab ] bi - ] each ; + ] each-token ; SYNTAX: SPECIALIZED-VECTOR: scan-c-type diff --git a/core/lexer/lexer.factor b/core/lexer/lexer.factor index b3bd3cacdb..7ad454c67c 100644 --- a/core/lexer/lexer.factor +++ b/core/lexer/lexer.factor @@ -82,15 +82,17 @@ PREDICATE: unexpected-eof < unexpected [ unexpected-eof ] if* ; -: (parse-tokens) ( accum end -- accum ) - scan 2dup = [ - 2drop - ] [ - [ pick push (parse-tokens) ] [ unexpected-eof ] if* - ] if ; +: (each-token) ( end quot -- pred quot ) + [ [ [ scan dup ] ] dip [ = not ] curry [ [ f ] if* ] curry compose ] dip ; inline + +: each-token ( end quot -- ) + (each-token) while drop ; inline + +: map-tokens ( end quot -- seq ) + (each-token) produce nip ; inline : parse-tokens ( end -- seq ) - 100 swap (parse-tokens) >array ; + [ ] map-tokens ; TUPLE: lexer-error line column line-text error ; diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index 0b5b32e289..6c35a3c5c6 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -51,7 +51,7 @@ IN: bootstrap.syntax "UNUSE:" [ scan unuse-vocab ] define-core-syntax - "USING:" [ ";" parse-tokens [ use-vocab ] each ] define-core-syntax + "USING:" [ ";" [ use-vocab ] each-token ] define-core-syntax "QUALIFIED:" [ scan dup add-qualified ] define-core-syntax @@ -124,13 +124,11 @@ IN: bootstrap.syntax ] define-core-syntax "SYMBOLS:" [ - ";" parse-tokens - [ create-in dup reset-generic define-symbol ] each + ";" [ create-in dup reset-generic define-symbol ] each-token ] define-core-syntax "SINGLETONS:" [ - ";" parse-tokens - [ create-class-in define-singleton-class ] each + ";" [ create-class-in define-singleton-class ] each-token ] define-core-syntax "DEFER:" [ diff --git a/extra/poker/poker.factor b/extra/poker/poker.factor index b33b8e5710..75af1b604a 100644 --- a/extra/poker/poker.factor +++ b/extra/poker/poker.factor @@ -263,4 +263,4 @@ ERROR: bad-suit-symbol ch ; string>value value>hand-name ; SYNTAX: HAND{ - "}" parse-tokens [ card> ] { } map-as suffix! ; + "}" [ card> ] map-tokens suffix! ; diff --git a/extra/slots/syntax/syntax.factor b/extra/slots/syntax/syntax.factor index 2cce91c569..95207a0de9 100755 --- a/extra/slots/syntax/syntax.factor +++ b/extra/slots/syntax/syntax.factor @@ -5,6 +5,5 @@ sequences slots ; IN: slots.syntax SYNTAX: slots{ - "}" parse-tokens - [ reader-word 1quotation ] map - '[ [ _ cleave ] output>array ] append! ; \ No newline at end of file + "}" [ reader-word 1quotation ] map-tokens + '[ [ _ cleave ] output>array ] append! ; diff --git a/extra/vars/vars.factor b/extra/vars/vars.factor index 21c9b303f3..990b0307d0 100644 --- a/extra/vars/vars.factor +++ b/extra/vars/vars.factor @@ -28,4 +28,4 @@ SYNTAX: VAR: ! var [ define-var ] each ; SYNTAX: VARS: ! vars ... - ";" parse-tokens define-vars ; + ";" [ define-var ] each-token ; From 6d81d1eaaa1ed1f6129a973a5565c4a9d96a8ff9 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 28 Feb 2010 23:11:43 -0800 Subject: [PATCH 296/713] windows.directx.d3d9: a method was missing argument names --- basis/windows/directx/d3d9/d3d9.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/windows/directx/d3d9/d3d9.factor b/basis/windows/directx/d3d9/d3d9.factor index d4e06ae8c9..a612f72ccd 100644 --- a/basis/windows/directx/d3d9/d3d9.factor +++ b/basis/windows/directx/d3d9/d3d9.factor @@ -109,7 +109,7 @@ COM-INTERFACE: IDirect3DDevice9 IUnknown {D0223B96-BF7A-43fd-92BD-A43B0D82B9EB} HRESULT Clear ( DWORD Count, D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil ) HRESULT SetTransform ( D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix ) HRESULT GetTransform ( D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix ) - HRESULT MultiplyTransform ( D3DTRANSFORMSTATETYPE, D3DMATRIX* ) + HRESULT MultiplyTransform ( D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix ) HRESULT SetViewport ( D3DVIEWPORT9* pViewport ) HRESULT GetViewport ( D3DVIEWPORT9* pViewport ) HRESULT SetMaterial ( D3DMATERIAL9* pMaterial ) From 51541bb35b42b33e5a6104762727b289d66122d7 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 1 Mar 2010 11:47:57 -0800 Subject: [PATCH 297/713] lexer, parser: update docs on "parse-tokens" and add docs for "each-token", "map-tokens" --- core/lexer/lexer-docs.factor | 13 ++++++++++++- core/parser/parser-docs.factor | 10 +++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/core/lexer/lexer-docs.factor b/core/lexer/lexer-docs.factor index 30888b76d8..b9af0dc65c 100644 --- a/core/lexer/lexer-docs.factor +++ b/core/lexer/lexer-docs.factor @@ -66,10 +66,21 @@ HELP: still-parsing? { $values { "lexer" lexer } { "?" "a boolean" } } { $description "Outputs " { $link f } " if end of input has been reached, " { $link t } " otherwise." } ; +HELP: each-token +{ $values { "end" string } { "quot" { $quotation "( token -- )" } } } +{ $description "Reads a sequence of tokens until the first occurrence of " { $snippet "end" } ". " { $snippet "quot" } " is called on each token as it is read." } +{ $examples "This word is used to implement " { $link POSTPONE: USING: } "." } +$parsing-note ; + +HELP: map-tokens +{ $values { "end" string } { "quot" { $quotation "( token -- object )" } } { "seq" "a new sequence of " { $snippet "object" } "s" } } +{ $description "Reads a sequence of tokens until the first occurrence of " { $snippet "end" } ". " { $snippet "quot" } " is called on each token as it is read, and the results are collected into a new output sequence." } +$parsing-note ; + HELP: parse-tokens { $values { "end" string } { "seq" "a new sequence of strings" } } { $description "Reads a sequence of tokens until the first occurrence of " { $snippet "end" } ". The tokens remain as strings and are not processed in any way." } -{ $examples "This word is used to implement " { $link POSTPONE: USING: } "." } +{ $notes "This word is equivalent to " { $link map-tokens } " with an empty quotation." } $parsing-note ; HELP: unexpected diff --git a/core/parser/parser-docs.factor b/core/parser/parser-docs.factor index b024d1d968..c04a0f568e 100644 --- a/core/parser/parser-docs.factor +++ b/core/parser/parser-docs.factor @@ -52,8 +52,12 @@ ARTICLE: "parsing-tokens" "Parsing raw tokens" $nl "One example is the " { $link POSTPONE: USING: } " parsing word." { $see POSTPONE: USING: } -"It reads a list of vocabularies terminated by " { $link POSTPONE: ; } ". However, the vocabulary names do not name words, except by coincidence; so " { $link parse-until } " cannot be used here. Instead, a lower-level word is called:" -{ $subsections parse-tokens } ; +"It reads a list of vocabularies terminated by " { $link POSTPONE: ; } ". However, the vocabulary names do not name words, except by coincidence; so " { $link parse-until } " cannot be used here. Instead, a set of lower-level combinators can be used:" +{ $subsections + each-token + map-tokens + parse-tokens +} ; ARTICLE: "parsing-words" "Parsing words" "The Factor parser follows a simple recursive-descent design. The parser reads successive tokens from the input; if the token identifies a number or an ordinary word, it is added to an accumulator vector. Otherwise if the token identifies a parsing word, the parsing word is executed immediately." @@ -164,7 +168,7 @@ HELP: parse-until { $examples "This word is used to implement " { $link POSTPONE: ARTICLE: } "." } $parsing-note ; -{ parse-tokens (parse-until) parse-until } related-words +{ parse-tokens each-token map-tokens (parse-until) parse-until } related-words HELP: (parse-lines) { $values { "lexer" lexer } { "quot" "a new " { $link quotation } } } From 2c5deba1d1f61c36cf373cbda4103453ebb79175 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 1 Mar 2010 11:50:16 -0800 Subject: [PATCH 298/713] parse-tokens had two $notes sections. oops! --- core/lexer/lexer-docs.factor | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/lexer/lexer-docs.factor b/core/lexer/lexer-docs.factor index b9af0dc65c..04985a4340 100644 --- a/core/lexer/lexer-docs.factor +++ b/core/lexer/lexer-docs.factor @@ -79,8 +79,7 @@ $parsing-note ; HELP: parse-tokens { $values { "end" string } { "seq" "a new sequence of strings" } } -{ $description "Reads a sequence of tokens until the first occurrence of " { $snippet "end" } ". The tokens remain as strings and are not processed in any way." } -{ $notes "This word is equivalent to " { $link map-tokens } " with an empty quotation." } +{ $description "Reads a sequence of tokens until the first occurrence of " { $snippet "end" } ". The tokens remain as strings and are not processed in any way. This word is equivalent to " { $link map-tokens } " with an empty quotation." } $parsing-note ; HELP: unexpected From ac979619e614e02f9063768ea6af6994069c488c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 1 Mar 2010 13:32:07 -0800 Subject: [PATCH 299/713] record the C++ compiler version in the VM, and expose it with a vm-compiler word --- core/alien/strings/strings.factor | 5 +++-- core/system/system.factor | 2 ++ vm/factor.cpp | 1 + vm/master.hpp | 13 +++++++++++++ vm/objects.hpp | 2 ++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/core/alien/strings/strings.factor b/core/alien/strings/strings.factor index 0ad4f6c85a..435ceb2a96 100644 --- a/core/alien/strings/strings.factor +++ b/core/alien/strings/strings.factor @@ -66,6 +66,7 @@ M: string string>symbol string>symbol* ; M: sequence string>symbol [ string>symbol* ] map ; [ - 8 special-object utf8 alien>string string>cpu \ cpu set-global - 9 special-object utf8 alien>string string>os \ os set-global + 8 special-object utf8 alien>string string>cpu \ cpu set-global + 9 special-object utf8 alien>string string>os \ os set-global + 67 special-object utf8 alien>string \ vm-compiler set-global ] "alien.strings" add-startup-hook diff --git a/core/system/system.factor b/core/system/system.factor index 715564c64d..765861c62f 100644 --- a/core/system/system.factor +++ b/core/system/system.factor @@ -24,6 +24,8 @@ UNION: unix bsd solaris linux haiku ; : os ( -- class ) \ os get-global ; foldable +: vm-compiler ( -- string ) \ vm-compiler get-global ; foldable + cpu ( str -- class ) diff --git a/vm/factor.cpp b/vm/factor.cpp index fb14336ae4..4433095173 100755 --- a/vm/factor.cpp +++ b/vm/factor.cpp @@ -136,6 +136,7 @@ void factor_vm::init_factor(vm_parameters *p) special_objects[OBJ_EXECUTABLE] = allot_alien(false_object,(cell)p->executable_path); special_objects[OBJ_ARGS] = false_object; special_objects[OBJ_EMBEDDED] = false_object; + special_objects[OBJ_VM_COMPILER] = allot_alien(false_object,(cell)FACTOR_COMPILER_VERSION); /* We can GC now */ gc_off = false; diff --git a/vm/master.hpp b/vm/master.hpp index 70736c1bd9..9ba4ebd64b 100755 --- a/vm/master.hpp +++ b/vm/master.hpp @@ -29,6 +29,19 @@ #include #include +/* Record compiler version */ +#if defined(__clang__) + #define FACTOR_COMPILER_VERSION "Clang (GCC " __VERSION__ ")" +#elif defined(__INTEL_COMPILER) + #define FACTOR_COMPILER_VERSION "Intel C Compiler " #__INTEL_COMPILER +#elif defined(__GNUC__) + #define FACTOR_COMPILER_VERSION "GCC " __VERSION__ +#elif defined(_MSC_FULL_VER) + #define FACTOR_COMPILER_VERSION "Microsoft Visual C++ " #_MSC_FULL_VER +#else + #define FACTOR_COMPILER_VERSION "unknown" +#endif + /* Detect target CPU type */ #if defined(__arm__) #define FACTOR_ARM diff --git a/vm/objects.hpp b/vm/objects.hpp index fdc5758a8d..2d777ac516 100644 --- a/vm/objects.hpp +++ b/vm/objects.hpp @@ -95,6 +95,8 @@ enum special_object { OBJ_THREADS = 64, OBJ_RUN_QUEUE = 65, OBJ_SLEEP_QUEUE = 66, + + OBJ_VM_COMPILER = 67, /* version string of the compiler we were built with */ }; /* save-image-and-exit discards special objects that are filled in on startup From 1c08fde381ed7767f087e22aeaec2577332da588 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 1 Mar 2010 17:56:17 -0800 Subject: [PATCH 300/713] yay C89 --- vm/master.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vm/master.hpp b/vm/master.hpp index 9ba4ebd64b..dca3d7473c 100755 --- a/vm/master.hpp +++ b/vm/master.hpp @@ -29,15 +29,17 @@ #include #include +#define FACTOR_STRINGIZE(x) #x + /* Record compiler version */ #if defined(__clang__) #define FACTOR_COMPILER_VERSION "Clang (GCC " __VERSION__ ")" #elif defined(__INTEL_COMPILER) - #define FACTOR_COMPILER_VERSION "Intel C Compiler " #__INTEL_COMPILER + #define FACTOR_COMPILER_VERSION "Intel C Compiler " FACTOR_STRINGIZE(__INTEL_COMPILER) #elif defined(__GNUC__) #define FACTOR_COMPILER_VERSION "GCC " __VERSION__ #elif defined(_MSC_FULL_VER) - #define FACTOR_COMPILER_VERSION "Microsoft Visual C++ " #_MSC_FULL_VER + #define FACTOR_COMPILER_VERSION "Microsoft Visual C++ " FACTOR_STRINGIZE(_MSC_FULL_VER) #else #define FACTOR_COMPILER_VERSION "unknown" #endif From 55e772c528b4123210c680d53e6366e21734c900 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 1 Mar 2010 22:31:36 -0600 Subject: [PATCH 301/713] Remove the http-data word --- .../bootstrap/image/download/download.factor | 2 +- basis/http/client/client-docs.factor | 7 +----- basis/http/client/client.factor | 3 --- basis/http/http-tests.factor | 22 +++++++++---------- basis/syndication/syndication.factor | 2 +- extra/images/http/http.factor | 2 +- extra/webapps/fjsc/fjsc.factor | 2 +- extra/yahoo/yahoo.factor | 2 +- 8 files changed, 17 insertions(+), 25 deletions(-) diff --git a/basis/bootstrap/image/download/download.factor b/basis/bootstrap/image/download/download.factor index 9ab7689eca..e2de621984 100644 --- a/basis/bootstrap/image/download/download.factor +++ b/basis/bootstrap/image/download/download.factor @@ -7,7 +7,7 @@ IN: bootstrap.image.download CONSTANT: url URL" http://factorcode.org/images/latest/" : download-checksums ( -- alist ) - url "checksums.txt" >url derive-url http-data + url "checksums.txt" >url derive-url http-get nip string-lines [ " " split1 ] { } map>assoc ; : need-new-image? ( image -- ? ) diff --git a/basis/http/client/client-docs.factor b/basis/http/client/client-docs.factor index 0d0887d10d..04077fc2f7 100644 --- a/basis/http/client/client-docs.factor +++ b/basis/http/client/client-docs.factor @@ -35,11 +35,6 @@ HELP: http-get { $description "Downloads the contents of a URL." } { $errors "Throws an error if the HTTP request fails." } ; -HELP: http-data -{ $values { "url" "a " { $link url } " or " { $link string } } { "data" sequence } } -{ $description "Downloads the contents of a URL. To view the HTTP response, use " { $link http-get } "." } -{ $errors "Throws an error if the HTTP request fails." } ; - HELP: http-post { $values { "post-data" object } { "url" "a " { $link url } " or " { $link string } } { "response" response } { "data" sequence } } { $description "Submits an HTTP POST request." } @@ -66,7 +61,7 @@ HELP: with-http-request ARTICLE: "http.client.get" "GET requests with the HTTP client" "Basic usage involves passing a " { $link url } " and getting a " { $link response } " and data back:" -{ $subsections http-get http-data } +{ $subsections http-get } "Utilities to retrieve a " { $link url } " and save the contents to a file:" { $subsections download diff --git a/basis/http/client/client.factor b/basis/http/client/client.factor index 9e540f111f..482a23aeaa 100644 --- a/basis/http/client/client.factor +++ b/basis/http/client/client.factor @@ -157,9 +157,6 @@ ERROR: download-failed response ; : http-get ( url -- response data ) http-request ; -: http-data ( url -- data ) - http-get nip ; - : with-http-get ( url quot -- response ) [ ] dip with-http-request ; inline diff --git a/basis/http/http-tests.factor b/basis/http/http-tests.factor index 62936af7ff..35d01c1014 100644 --- a/basis/http/http-tests.factor +++ b/basis/http/http-tests.factor @@ -226,14 +226,14 @@ test-db [ [ t ] [ "vocab:http/test/foo.html" ascii file-contents - "http://localhost/nested/foo.html" add-port http-data = + "http://localhost/nested/foo.html" add-port http-get nip = ] unit-test -[ "http://localhost/redirect-loop" add-port http-data ] +[ "http://localhost/redirect-loop" add-port http-get nip ] [ too-many-redirects? ] must-fail-with [ "Goodbye" ] [ - "http://localhost/quit" add-port http-data + "http://localhost/quit" add-port http-get nip ] unit-test ! HTTP client redirect bug @@ -247,7 +247,7 @@ test-db [ ] unit-test [ "Goodbye" ] [ - "http://localhost/redirect" add-port http-data + "http://localhost/redirect" add-port http-get nip ] unit-test @@ -274,12 +274,12 @@ test-db [ : 404? ( response -- ? ) [ download-failed? ] [ response>> code>> 404 = ] bi and ; ! This should give a 404 not an infinite redirect loop -[ "http://localhost/d/blah" add-port http-data ] [ 404? ] must-fail-with +[ "http://localhost/d/blah" add-port http-get nip ] [ 404? ] must-fail-with ! This should give a 404 not an infinite redirect loop -[ "http://localhost/blah/" add-port http-data ] [ 404? ] must-fail-with +[ "http://localhost/blah/" add-port http-get nip ] [ 404? ] must-fail-with -[ "Goodbye" ] [ "http://localhost/quit" add-port http-data ] unit-test +[ "Goodbye" ] [ "http://localhost/quit" add-port http-get nip ] unit-test [ ] [ @@ -293,9 +293,9 @@ test-db [ test-httpd ] unit-test -[ "Hi" ] [ "http://localhost/" add-port http-data ] unit-test +[ "Hi" ] [ "http://localhost/" add-port http-get nip ] unit-test -[ "Goodbye" ] [ "http://localhost/quit" add-port http-data ] unit-test +[ "Goodbye" ] [ "http://localhost/quit" add-port http-get nip ] unit-test USING: html.components html.forms xml xml.traversal validators @@ -353,7 +353,7 @@ SYMBOL: a [ 4 ] [ a get-global ] unit-test -[ "Goodbye" ] [ "http://localhost/quit" add-port http-data ] unit-test +[ "Goodbye" ] [ "http://localhost/quit" add-port http-get nip ] unit-test ! Test cloning [ f ] [ <404> dup clone "b" "a" set-header drop "a" header ] unit-test @@ -371,7 +371,7 @@ SYMBOL: a ] unit-test [ t ] [ - "http://localhost/" add-port http-data + "http://localhost/" add-port http-get nip "vocab:http/test/foo.html" ascii file-contents = ] unit-test diff --git a/basis/syndication/syndication.factor b/basis/syndication/syndication.factor index edfbebeeab..fe31a49265 100644 --- a/basis/syndication/syndication.factor +++ b/basis/syndication/syndication.factor @@ -115,7 +115,7 @@ M: byte-array parse-feed [ bytes>xml xml>feed ] with-html-entities ; : download-feed ( url -- feed ) #! Retrieve an news syndication file, return as a feed tuple. - http-data parse-feed ; + http-get nip parse-feed ; ! Atom generation diff --git a/extra/images/http/http.factor b/extra/images/http/http.factor index d3cff18afb..620ab6f73b 100644 --- a/extra/images/http/http.factor +++ b/extra/images/http/http.factor @@ -5,7 +5,7 @@ images.viewer ; IN: images.http : load-http-image ( path -- image ) - [ http-data ] [ image-class ] bi load-image* ; + [ http-get nip ] [ image-class ] bi load-image* ; : http-image. ( path -- ) load-http-image image. ; diff --git a/extra/webapps/fjsc/fjsc.factor b/extra/webapps/fjsc/fjsc.factor index 4dec258083..01d6935bee 100644 --- a/extra/webapps/fjsc/fjsc.factor +++ b/extra/webapps/fjsc/fjsc.factor @@ -35,7 +35,7 @@ TUPLE: fjsc < dispatcher ; : do-compile-url ( url -- response ) [ - absolute-url http-data 'expression' parse fjsc-compile write "();" write + absolute-url http-get nip 'expression' parse fjsc-compile write "();" write ] with-string-writer "application/javascript" ; diff --git a/extra/yahoo/yahoo.factor b/extra/yahoo/yahoo.factor index 2a8469c328..5e0c08b430 100644 --- a/extra/yahoo/yahoo.factor +++ b/extra/yahoo/yahoo.factor @@ -57,4 +57,4 @@ CONSTANT: factor-id "fRrVAKzV34GDyeRw6bUHDhEWHRedwfOC7e61wwXZLgGF80E67spxdQXuugB swap >>query ; : search-yahoo ( search -- seq ) - query http-data string>xml parse-yahoo ; + query http-get nip string>xml parse-yahoo ; From 4159cfcc7bce7c9fe073c5dbf22d9482f0f1a9df Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 1 Mar 2010 23:29:26 -0800 Subject: [PATCH 302/713] game.input.*: factor out callback implementations to separate words so they optimize --- basis/game/input/dinput/dinput.factor | 38 ++++++++++++---------- basis/game/input/iokit/iokit.factor | 47 ++++++++++++++------------- 2 files changed, 45 insertions(+), 40 deletions(-) diff --git a/basis/game/input/dinput/dinput.factor b/basis/game/input/dinput/dinput.factor index a95dbd06c3..7eae826aa5 100755 --- a/basis/game/input/dinput/dinput.factor +++ b/basis/game/input/dinput/dinput.factor @@ -92,21 +92,22 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ +dinput+ get swap device-guid IDirectInput8W::GetDeviceStatus S_OK = ; +: (find-device-axes-callback) ( lpddoi pvRef -- BOOL ) + +controller-devices+ get at + swap guidType>> { + { [ dup GUID_XAxis = ] [ drop 0.0 >>x ] } + { [ dup GUID_YAxis = ] [ drop 0.0 >>y ] } + { [ dup GUID_ZAxis = ] [ drop 0.0 >>z ] } + { [ dup GUID_RxAxis = ] [ drop 0.0 >>rx ] } + { [ dup GUID_RyAxis = ] [ drop 0.0 >>ry ] } + { [ dup GUID_RzAxis = ] [ drop 0.0 >>rz ] } + { [ dup GUID_Slider = ] [ drop 0.0 >>slider ] } + [ drop ] + } cond drop + DIENUM_CONTINUE ; + : find-device-axes-callback ( -- alien ) - [ ! ( lpddoi pvRef -- BOOL ) - +controller-devices+ get at - swap guidType>> { - { [ dup GUID_XAxis = ] [ drop 0.0 >>x ] } - { [ dup GUID_YAxis = ] [ drop 0.0 >>y ] } - { [ dup GUID_ZAxis = ] [ drop 0.0 >>z ] } - { [ dup GUID_RxAxis = ] [ drop 0.0 >>rx ] } - { [ dup GUID_RyAxis = ] [ drop 0.0 >>ry ] } - { [ dup GUID_RzAxis = ] [ drop 0.0 >>rz ] } - { [ dup GUID_Slider = ] [ drop 0.0 >>slider ] } - [ drop ] - } cond drop - DIENUM_CONTINUE - ] LPDIENUMDEVICEOBJECTSCALLBACKW ; + [ (find-device-axes-callback) ] LPDIENUMDEVICEOBJECTSCALLBACKW ; : find-device-axes ( device controller-state -- controller-state ) swap [ +controller-devices+ get set-at ] 2keep @@ -139,11 +140,12 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ [ device-guid +controller-guids+ get delete-at ] [ com-release ] tri ; +: (find-controller-callback) ( lpddi pvRef -- BOOL ) + drop guidInstance>> add-controller + DIENUM_CONTINUE ; + : find-controller-callback ( -- alien ) - [ ! ( lpddi pvRef -- BOOL ) - drop guidInstance>> add-controller - DIENUM_CONTINUE - ] LPDIENUMDEVICESCALLBACKW ; inline + [ (find-controller-callback) ] LPDIENUMDEVICESCALLBACKW ; : find-controllers ( -- ) +dinput+ get DI8DEVCLASS_GAMECTRL find-controller-callback diff --git a/basis/game/input/iokit/iokit.factor b/basis/game/input/iokit/iokit.factor index efc586e1ef..45ed67dc22 100644 --- a/basis/game/input/iokit/iokit.factor +++ b/basis/game/input/iokit/iokit.factor @@ -251,33 +251,36 @@ M: iokit-game-input-backend reset-mouse 2dup length > [ set-length ] [ 2drop ] if ; +:: (device-matched-callback) ( context result sender device -- ) + { + { [ device mouse-device? ] [ device ?add-mouse-buttons ] } + { [ device controller-device? ] [ + device + device +controller-states+ get set-at + ] } + [ ] + } cond ; + : device-matched-callback ( -- alien ) - [| context result sender device | - { - { [ device controller-device? ] [ - device - device +controller-states+ get set-at - ] } - { [ device mouse-device? ] [ device ?add-mouse-buttons ] } - [ ] - } cond - ] IOHIDDeviceCallback ; + [ (device-matched-callback) ] IOHIDDeviceCallback ; + +:: (device-removed-callback) ( context result sender device -- ) + device +controller-states+ get delete-at ; : device-removed-callback ( -- alien ) - [| context result sender device | - device +controller-states+ get delete-at - ] IOHIDDeviceCallback ; + [ (device-removed-callback) ] IOHIDDeviceCallback ; + +:: (device-input-callback) ( context result sender value -- ) + { + { [ sender mouse-device? ] [ +mouse-state+ get value record-mouse ] } + { [ sender controller-device? ] [ + sender +controller-states+ get at value record-controller + ] } + [ +keyboard-state+ get value record-keyboard ] + } cond ; : device-input-callback ( -- alien ) - [| context result sender value | - { - { [ sender controller-device? ] [ - sender +controller-states+ get at value record-controller - ] } - { [ sender mouse-device? ] [ +mouse-state+ get value record-mouse ] } - [ +keyboard-state+ get value record-keyboard ] - } cond - ] IOHIDValueCallback ; + [ (device-input-callback) ] IOHIDValueCallback ; : initialize-variables ( manager -- ) +hid-manager+ set-global From 55c606f274ebeed93884f2eeff65ee889c6152b0 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 2 Mar 2010 04:20:40 -0600 Subject: [PATCH 303/713] Remove year/month/day words because they're dumb and confusing --- basis/calendar/calendar.factor | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/basis/calendar/calendar.factor b/basis/calendar/calendar.factor index 1a64ceb646..cd87701aa9 100644 --- a/basis/calendar/calendar.factor +++ b/basis/calendar/calendar.factor @@ -170,18 +170,6 @@ M: timestamp easter ( timestamp -- timestamp ) : microseconds ( x -- duration ) 1000000 / seconds ; : nanoseconds ( x -- duration ) 1000000000 / seconds ; -GENERIC: year ( obj -- n ) -M: integer year ; -M: timestamp year year>> ; - -GENERIC: month ( obj -- n ) -M: integer month ; -M: timestamp month month>> ; - -GENERIC: day ( obj -- n ) -M: integer day ; -M: timestamp day day>> ; - GENERIC: leap-year? ( obj -- ? ) M: integer leap-year? ( year -- ? ) From b059ade5edad9b2a13c46475c988660336bfac7a Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 2 Mar 2010 04:31:17 -0600 Subject: [PATCH 304/713] Use TYPED: in a few places in calendar.format to avoid passing durations instead of timestamps --- basis/calendar/format/format.factor | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/basis/calendar/format/format.factor b/basis/calendar/format/format.factor index 96d76d0ce8..35e364e6aa 100644 --- a/basis/calendar/format/format.factor +++ b/basis/calendar/format/format.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008, 2010 Slava Pestov, Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: math math.order math.parser math.functions kernel -sequences io accessors arrays io.streams.string splitting -combinators calendar calendar.format.macros present ; +USING: accessors arrays calendar calendar.format.macros +combinators io io.streams.string kernel math math.functions +math.order math.parser present sequences typed ; IN: calendar.format : pad-00 ( n -- str ) number>string 2 CHAR: 0 pad-head ; @@ -272,16 +272,16 @@ ERROR: invalid-timestamp-format ; : (timestamp>ymd) ( timestamp -- ) { YYYY "-" MM "-" DD } formatted ; -: timestamp>ymd ( timestamp -- str ) +TYPED: timestamp>ymd ( timestamp: timestamp -- str ) [ (timestamp>ymd) ] with-string-writer ; : (timestamp>hms) ( timestamp -- ) { hh ":" mm ":" ss } formatted ; -: timestamp>hms ( timestamp -- str ) +TYPED: timestamp>hms ( timestamp: timestamp -- str ) [ (timestamp>hms) ] with-string-writer ; -: timestamp>ymdhms ( timestamp -- str ) +TYPED: timestamp>ymdhms ( timestamp: timestamp -- str ) [ >gmt { (timestamp>ymd) " " (timestamp>hms) } formatted From 3faa1a57d30e49429448f0bae99fb6acfe1e401c Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 2 Mar 2010 04:51:52 -0600 Subject: [PATCH 305/713] Add a parsing word to output slots to the stack instead of to an array --- extra/slots/syntax/syntax-docs.factor | 12 ++++++++++++ extra/slots/syntax/syntax-tests.factor | 6 +++++- extra/slots/syntax/syntax.factor | 4 ++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/extra/slots/syntax/syntax-docs.factor b/extra/slots/syntax/syntax-docs.factor index b79916f91b..84e6e89dac 100755 --- a/extra/slots/syntax/syntax-docs.factor +++ b/extra/slots/syntax/syntax-docs.factor @@ -3,6 +3,16 @@ USING: help.markup help.syntax ; IN: slots.syntax +HELP: slots[ +{ $description "Outputs several slot values to the stack." } +{ $example "USING: kernel prettyprint slots.syntax ;" + "IN: slots.syntax.example" + "TUPLE: rectangle width height ;" + "T{ rectangle { width 3 } { height 5 } } slots[ width height ] [ . ] bi@" + """3 +5""" +} ; + HELP: slots{ { $description "Outputs an array of slot values from a tuple." } { $example "USING: prettyprint slots.syntax ;" @@ -14,6 +24,8 @@ HELP: slots{ ARTICLE: "slots.syntax" "Slots syntax sugar" "The " { $vocab-link "slots.syntax" } " vocabulary provides an alternative syntax for taking a sequence of slots from a tuple." $nl +"Syntax sugar for cleaving slots to the stack:" +{ $subsections POSTPONE: slots[ } "Syntax sugar for cleaving slots to an array:" { $subsections POSTPONE: slots{ } ; diff --git a/extra/slots/syntax/syntax-tests.factor b/extra/slots/syntax/syntax-tests.factor index 689ccb48eb..e4dac6e4a4 100755 --- a/extra/slots/syntax/syntax-tests.factor +++ b/extra/slots/syntax/syntax-tests.factor @@ -5,6 +5,10 @@ IN: slots.syntax.tests TUPLE: slot-test a b c ; +[ 1 2 3 ] [ T{ slot-test f 1 2 3 } slots[ a b c ] ] unit-test +[ 3 ] [ T{ slot-test f 1 2 3 } slots[ c ] ] unit-test +[ ] [ T{ slot-test f 1 2 3 } slots[ ] ] unit-test + [ { 1 2 3 } ] [ T{ slot-test f 1 2 3 } slots{ a b c } ] unit-test [ { 3 } ] [ T{ slot-test f 1 2 3 } slots{ c } ] unit-test -[ { } ] [ T{ slot-test f 1 2 3 } slots{ } ] unit-test \ No newline at end of file +[ { } ] [ T{ slot-test f 1 2 3 } slots{ } ] unit-test diff --git a/extra/slots/syntax/syntax.factor b/extra/slots/syntax/syntax.factor index 95207a0de9..7bfe238fa8 100755 --- a/extra/slots/syntax/syntax.factor +++ b/extra/slots/syntax/syntax.factor @@ -4,6 +4,10 @@ USING: combinators combinators.smart fry lexer quotations sequences slots ; IN: slots.syntax +SYNTAX: slots[ + "]" [ reader-word 1quotation ] map-tokens + '[ _ cleave ] append! ; + SYNTAX: slots{ "}" [ reader-word 1quotation ] map-tokens '[ [ _ cleave ] output>array ] append! ; From 8ef279e020abb9ee38f87a90c141f16a17176c11 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 2 Mar 2010 11:38:35 -0600 Subject: [PATCH 306/713] Fix load error in calendar --- extra/calendar/holidays/us/us.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/calendar/holidays/us/us.factor b/extra/calendar/holidays/us/us.factor index a4fb19c597..538836952f 100644 --- a/extra/calendar/holidays/us/us.factor +++ b/extra/calendar/holidays/us/us.factor @@ -33,7 +33,7 @@ HOLIDAY-NAME: new-years-day us-federal "New Year's Day" HOLIDAY: martin-luther-king-day january 3 monday-of-month ; HOLIDAY-NAME: martin-luther-king-day us-federal "Martin Luther King Day" -HOLIDAY: inauguration-day year dup 4 neg rem + january 20 >>day ; +HOLIDAY: inauguration-day january 20 >>day [ dup 4 neg rem + ] change-year ; HOLIDAY-NAME: inauguration-day us "Inauguration Day" HOLIDAY: washingtons-birthday february 3 monday-of-month ; From 3ad5ca4636bbe717f9333d8c982d041eb86a0ad4 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Tue, 2 Mar 2010 18:05:37 -0500 Subject: [PATCH 307/713] Regexps use new sets rather than assocs for final states --- basis/regexp/compiler/compiler.factor | 4 ++-- basis/regexp/dfa/dfa.factor | 4 ++-- basis/regexp/minimize/minimize-tests.factor | 4 ++-- basis/regexp/minimize/minimize.factor | 2 +- basis/regexp/negation/negation-tests.factor | 4 ++-- basis/regexp/negation/negation.factor | 10 +++++----- basis/regexp/nfa/nfa.factor | 2 +- .../regexp/transition-tables/transition-tables.factor | 8 ++++---- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/basis/regexp/compiler/compiler.factor b/basis/regexp/compiler/compiler.factor index d8940bb829..0682cc4f56 100644 --- a/basis/regexp/compiler/compiler.factor +++ b/basis/regexp/compiler/compiler.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. USING: regexp.classes kernel sequences regexp.negation -quotations assocs fry math locals combinators +quotations assocs fry math locals combinators sets accessors words compiler.units kernel.private strings sequences.private arrays namespaces unicode.breaks regexp.transition-tables combinators.short-circuit ; @@ -106,7 +106,7 @@ C: box : word>quot ( word dfa -- quot ) [ transitions>> at ] - [ final-states>> key? ] 2bi + [ final-states>> in? ] 2bi transitions>quot ; : states>code ( words dfa -- ) diff --git a/basis/regexp/dfa/dfa.factor b/basis/regexp/dfa/dfa.factor index fa75232fd5..416781bdb3 100644 --- a/basis/regexp/dfa/dfa.factor +++ b/basis/regexp/dfa/dfa.factor @@ -69,10 +69,10 @@ IN: regexp.dfa : set-final-states ( nfa dfa -- ) [ - [ final-states>> keys ] + [ final-states>> members ] [ transitions>> keys ] bi* [ intersects? ] with filter - unique + fast-set ] keep (>>final-states) ; : initialize-dfa ( nfa -- dfa ) diff --git a/basis/regexp/minimize/minimize-tests.factor b/basis/regexp/minimize/minimize-tests.factor index 17a1d51b88..7f961f4d98 100644 --- a/basis/regexp/minimize/minimize-tests.factor +++ b/basis/regexp/minimize/minimize-tests.factor @@ -34,7 +34,7 @@ IN: regexp.minimize.tests { 3 H{ } } } } { start-state 0 } - { final-states H{ { 3 3 } } } + { final-states HS{ 3 } } } ] [ T{ transition-table @@ -48,7 +48,7 @@ IN: regexp.minimize.tests { 6 H{ } } } } { start-state 0 } - { final-states H{ { 3 3 } { 6 6 } } } + { final-states HS{ 3 6 } } } combine-states ] unit-test diff --git a/basis/regexp/minimize/minimize.factor b/basis/regexp/minimize/minimize.factor index a6eb4f00a2..832622e6e1 100644 --- a/basis/regexp/minimize/minimize.factor +++ b/basis/regexp/minimize/minimize.factor @@ -18,7 +18,7 @@ IN: regexp.minimize { [ drop <= ] [ transitions>> '[ _ at keys ] bi@ set= ] - [ final-states>> '[ _ key? ] bi@ = ] + [ final-states>> '[ _ in? ] bi@ = ] } 3&& ; :: initialize-partitions ( transition-table -- partitions ) diff --git a/basis/regexp/negation/negation-tests.factor b/basis/regexp/negation/negation-tests.factor index 41dfe7f493..f367e62ff5 100644 --- a/basis/regexp/negation/negation-tests.factor +++ b/basis/regexp/negation/negation-tests.factor @@ -12,7 +12,7 @@ IN: regexp.negation.tests { -1 H{ { t -1 } } } } } { start-state 0 } - { final-states H{ { 0 0 } { -1 -1 } } } + { final-states HS{ 0 -1 } } } ] [ ! R/ a/ @@ -22,6 +22,6 @@ IN: regexp.negation.tests { 1 H{ } } } } { start-state 0 } - { final-states H{ { 1 1 } } } + { final-states HS{ 1 } } } negate-table ] unit-test diff --git a/basis/regexp/negation/negation.factor b/basis/regexp/negation/negation.factor index 802e211536..5f627b645e 100644 --- a/basis/regexp/negation/negation.factor +++ b/basis/regexp/negation/negation.factor @@ -3,7 +3,7 @@ USING: regexp.nfa regexp.disambiguate kernel sequences assocs regexp.classes hashtables accessors fry vectors regexp.ast regexp.transition-tables regexp.minimize -regexp.dfa namespaces ; +regexp.dfa namespaces sets ; IN: regexp.negation CONSTANT: fail-state -1 @@ -21,7 +21,7 @@ CONSTANT: fail-state -1 fail-state-recurses ; : inverse-final-states ( transition-table -- final-states ) - [ transitions>> assoc>set ] [ final-states>> ] bi assoc-diff ; + [ transitions>> keys ] [ final-states>> ] bi diff fast-set ; : negate-table ( transition-table -- transition-table ) clone @@ -36,14 +36,14 @@ CONSTANT: fail-state -1 [ [ [ 1vector ] assoc-map ] assoc-map ] change-transitions ; : unify-final-state ( transition-table -- transition-table ) - dup [ final-states>> keys ] keep + dup [ final-states>> members ] keep '[ -2 epsilon _ set-transition ] each - H{ { -2 -2 } } >>final-states ; + HS{ -2 } clone >>final-states ; : adjoin-dfa ( transition-table -- start end ) unify-final-state renumber-states box-transitions [ start-state>> ] - [ final-states>> keys first ] + [ final-states>> members first ] [ nfa-table get [ transitions>> ] bi@ swap assoc-union! drop ] tri ; : ast>dfa ( parse-tree -- minimal-dfa ) diff --git a/basis/regexp/nfa/nfa.factor b/basis/regexp/nfa/nfa.factor index cc430f2de1..fb210c5ef2 100644 --- a/basis/regexp/nfa/nfa.factor +++ b/basis/regexp/nfa/nfa.factor @@ -163,6 +163,6 @@ M: with-options nfa-node ( node -- start end ) nfa-table set nfa-node nfa-table get - swap dup associate >>final-states + swap 1array fast-set >>final-states swap >>start-state ] with-scope ; diff --git a/basis/regexp/transition-tables/transition-tables.factor b/basis/regexp/transition-tables/transition-tables.factor index f452e3d24a..b548b883b2 100644 --- a/basis/regexp/transition-tables/transition-tables.factor +++ b/basis/regexp/transition-tables/transition-tables.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs fry hashtables kernel sequences -vectors locals regexp.classes ; +vectors locals regexp.classes sets ; IN: regexp.transition-tables TUPLE: transition-table transitions start-state final-states ; @@ -9,7 +9,7 @@ TUPLE: transition-table transitions start-state final-states ; : ( -- transition-table ) transition-table new H{ } clone >>transitions - H{ } clone >>final-states ; + HS{ } clone >>final-states ; :: (set-transition) ( from to obj hash -- ) from hash at @@ -27,8 +27,8 @@ TUPLE: transition-table transitions start-state final-states ; : add-transition ( from to obj transition-table -- ) transitions>> (add-transition) ; -: map-set ( assoc quot -- new-assoc ) - '[ drop @ dup ] assoc-map ; inline +: map-set ( set quot -- new-set ) + over [ [ members ] dip map ] dip set-like ; inline : number-transitions ( transitions numbering -- new-transitions ) dup '[ From 2e4ebc01829c754b5a31a4de65d261bb8a56a03a Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 2 Mar 2010 15:24:47 -0800 Subject: [PATCH 308/713] needlessly rice game.input backends further by using set/get-global everywhere --- basis/game/input/dinput/dinput.factor | 42 +++++++++++++-------------- basis/game/input/iokit/iokit.factor | 22 +++++++------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/basis/game/input/dinput/dinput.factor b/basis/game/input/dinput/dinput.factor index 7eae826aa5..f5b3520b12 100755 --- a/basis/game/input/dinput/dinput.factor +++ b/basis/game/input/dinput/dinput.factor @@ -30,15 +30,15 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ +dinput+ [ com-release f ] change-global ; : device-for-guid ( guid -- device ) - +dinput+ get swap f + +dinput+ get-global swap f [ f IDirectInput8W::CreateDevice ole32-error ] keep *void* ; : set-coop-level ( device -- ) - +device-change-window+ get DISCL_BACKGROUND DISCL_NONEXCLUSIVE bitor - IDirectInputDevice8W::SetCooperativeLevel ole32-error ; + +device-change-window+ get-global DISCL_BACKGROUND DISCL_NONEXCLUSIVE bitor + IDirectInputDevice8W::SetCooperativeLevel ole32-error ; inline : set-data-format ( device format-symbol -- ) - get IDirectInputDevice8W::SetDataFormat ole32-error ; + get-global IDirectInputDevice8W::SetDataFormat ole32-error ; inline : ( size -- DIPROPDWORD ) DIPROPDWORD [ @@ -93,7 +93,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ IDirectInput8W::GetDeviceStatus S_OK = ; : (find-device-axes-callback) ( lpddoi pvRef -- BOOL ) - +controller-devices+ get at + +controller-devices+ get-global at swap guidType>> { { [ dup GUID_XAxis = ] [ drop 0.0 >>x ] } { [ dup GUID_YAxis = ] [ drop 0.0 >>y ] } @@ -110,7 +110,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ [ (find-device-axes-callback) ] LPDIENUMDEVICEOBJECTSCALLBACKW ; : find-device-axes ( device controller-state -- controller-state ) - swap [ +controller-devices+ get set-at ] 2keep + swap [ +controller-devices+ get-global set-at ] 2keep find-device-axes-callback over DIDFT_AXIS IDirectInputDevice8W::EnumObjects ole32-error ; @@ -122,22 +122,22 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ find-device-axes ; : device-known? ( guid -- ? ) - +controller-guids+ get key? ; inline + +controller-guids+ get-global key? ; inline : (add-controller) ( guid -- ) device-for-guid { [ configure-controller ] [ controller-state-template ] - [ dup device-guid clone +controller-guids+ get set-at ] - [ +controller-devices+ get set-at ] + [ dup device-guid clone +controller-guids+ get-global set-at ] + [ +controller-devices+ get-global set-at ] } cleave ; : add-controller ( guid -- ) dup device-known? [ drop ] [ (add-controller) ] if ; : remove-controller ( device -- ) - [ +controller-devices+ get delete-at ] - [ device-guid +controller-guids+ get delete-at ] + [ +controller-devices+ get-global delete-at ] + [ device-guid +controller-guids+ get-global delete-at ] [ com-release ] tri ; : (find-controller-callback) ( lpddi pvRef -- BOOL ) @@ -148,7 +148,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ [ (find-controller-callback) ] LPDIENUMDEVICESCALLBACKW ; : find-controllers ( -- ) - +dinput+ get DI8DEVCLASS_GAMECTRL find-controller-callback + +dinput+ get-global DI8DEVCLASS_GAMECTRL find-controller-callback f DIEDFL_ATTACHEDONLY IDirectInput8W::EnumDevices ole32-error ; : set-up-controllers ( -- ) @@ -157,7 +157,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ find-controllers ; : find-and-remove-detached-devices ( -- ) - +controller-devices+ get keys + +controller-devices+ get-global keys [ device-attached? not ] filter [ remove-controller ] each ; @@ -253,7 +253,7 @@ M: dinput-game-input-backend (reset-game-input) ] bind ; M: dinput-game-input-backend get-controllers - +controller-devices+ get + +controller-devices+ get-global [ drop controller boa ] { } assoc>map ; M: dinput-game-input-backend product-string @@ -315,7 +315,7 @@ CONSTANT: pov-values } case ; : fill-mouse-state ( buffer count -- state ) - iota [ +mouse-state+ get ] 2dip swap [ nth (fill-mouse-state) ] curry each ; + iota [ +mouse-state+ get-global ] 2dip swap [ nth (fill-mouse-state) ] curry each ; : get-device-state ( device DIJOYSTATE2 -- ) [ dup IDirectInputDevice8W::Poll ole32-error ] dip @@ -327,25 +327,25 @@ CONSTANT: pov-values [ fill-controller-state ] [ drop f ] with-acquisition ; M: dinput-game-input-backend read-controller - handle>> dup +controller-devices+ get at + handle>> dup +controller-devices+ get-global at [ (read-controller) ] [ drop f ] if* ; M: dinput-game-input-backend calibrate-controller handle>> f 0 IDirectInputDevice8W::RunControlPanel ole32-error ; M: dinput-game-input-backend read-keyboard - +keyboard-device+ get - [ +keyboard-state+ get [ keys>> underlying>> get-device-state ] keep ] + +keyboard-device+ get-global + [ +keyboard-state+ get-global [ keys>> underlying>> get-device-state ] keep ] [ ] [ f ] with-acquisition ; M: dinput-game-input-backend read-mouse - +mouse-device+ get [ +mouse-buffer+ get MOUSE-BUFFER-SIZE read-device-buffer ] + +mouse-device+ get-global [ +mouse-buffer+ get-global MOUSE-BUFFER-SIZE read-device-buffer ] [ fill-mouse-state ] [ f ] with-acquisition ; M: dinput-game-input-backend reset-mouse - +mouse-device+ get [ f MOUSE-BUFFER-SIZE read-device-buffer ] + +mouse-device+ get-global [ f MOUSE-BUFFER-SIZE read-device-buffer ] [ 2drop ] [ ] with-acquisition - +mouse-state+ get + +mouse-state+ get-global 0 >>dx 0 >>dy 0 >>scroll-dx diff --git a/basis/game/input/iokit/iokit.factor b/basis/game/input/iokit/iokit.factor index 45ed67dc22..083be8e74f 100644 --- a/basis/game/input/iokit/iokit.factor +++ b/basis/game/input/iokit/iokit.factor @@ -203,10 +203,10 @@ HINTS: record-keyboard { bit-array alien } ; HINTS: record-mouse { mouse-state alien } ; M: iokit-game-input-backend read-mouse - +mouse-state+ get ; + +mouse-state+ get-global ; M: iokit-game-input-backend reset-mouse - +mouse-state+ get + +mouse-state+ get-global 0 >>dx 0 >>dy 0 >>scroll-dx @@ -247,7 +247,7 @@ M: iokit-game-input-backend reset-mouse } cleave controller-state boa ; : ?add-mouse-buttons ( device -- ) - button-count +mouse-state+ get buttons>> + button-count +mouse-state+ get-global buttons>> 2dup length > [ set-length ] [ 2drop ] if ; @@ -256,7 +256,7 @@ M: iokit-game-input-backend reset-mouse { [ device mouse-device? ] [ device ?add-mouse-buttons ] } { [ device controller-device? ] [ device - device +controller-states+ get set-at + device +controller-states+ get-global set-at ] } [ ] } cond ; @@ -265,18 +265,18 @@ M: iokit-game-input-backend reset-mouse [ (device-matched-callback) ] IOHIDDeviceCallback ; :: (device-removed-callback) ( context result sender device -- ) - device +controller-states+ get delete-at ; + device +controller-states+ get-global delete-at ; : device-removed-callback ( -- alien ) [ (device-removed-callback) ] IOHIDDeviceCallback ; :: (device-input-callback) ( context result sender value -- ) { - { [ sender mouse-device? ] [ +mouse-state+ get value record-mouse ] } + { [ sender mouse-device? ] [ +mouse-state+ get-global value record-mouse ] } { [ sender controller-device? ] [ - sender +controller-states+ get at value record-controller + sender +controller-states+ get-global at value record-controller ] } - [ +keyboard-state+ get value record-keyboard ] + [ +keyboard-state+ get-global value record-keyboard ] } cond ; : device-input-callback ( -- alien ) @@ -324,7 +324,7 @@ M: iokit-game-input-backend (close-game-input) ] when ; M: iokit-game-input-backend get-controllers ( -- sequence ) - +controller-states+ get keys [ controller boa ] map ; + +controller-states+ get-global keys [ controller boa ] map ; : ?join ( pre post sep -- string ) 2over start [ swap 2nip ] [ [ 2array ] dip join ] if ; @@ -341,10 +341,10 @@ M: iokit-game-input-backend instance-id ( controller -- integer ) handle>> kIOHIDLocationIDKey device-property ; M: iokit-game-input-backend read-controller ( controller -- controller-state ) - handle>> +controller-states+ get at clone ; + handle>> +controller-states+ get-global at clone ; M: iokit-game-input-backend read-keyboard ( -- keyboard-state ) - +keyboard-state+ get clone keyboard-state boa ; + +keyboard-state+ get-global clone keyboard-state boa ; M: iokit-game-input-backend calibrate-controller ( controller -- ) drop ; From 766896f01c15ec340e98b67bdb74104aac50dfe2 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Tue, 2 Mar 2010 19:11:35 -0500 Subject: [PATCH 309/713] Fixing bug in see caused by incorrect import --- basis/see/see.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basis/see/see.factor b/basis/see/see.factor index 0d93757086..38a8a48934 100644 --- a/basis/see/see.factor +++ b/basis/see/see.factor @@ -10,6 +10,7 @@ prettyprint.sections sequences sets sorting strings summary words words.symbol words.constant words.alias vocabs slots ; FROM: namespaces => set ; FROM: classes => members ; +RENAME: members sets => set-members IN: see GENERIC: synopsis* ( defspec -- ) @@ -239,7 +240,7 @@ PRIVATE> dup class? [ dup seeing-implementors % ] when dup generic? [ dup seeing-methods % ] when drop - ] { } make members ; + ] { } make set-members ; : see-methods ( word -- ) methods see-all nl ; From e3481a7ed7642ded5a26db75b9471e9a4328d304 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Tue, 2 Mar 2010 19:23:34 -0500 Subject: [PATCH 310/713] compiler.cfg.def-use uses sets --- basis/compiler/cfg/def-use/def-use.factor | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/basis/compiler/cfg/def-use/def-use.factor b/basis/compiler/cfg/def-use/def-use.factor index 3838a0d1b9..87758fafcd 100644 --- a/basis/compiler/cfg/def-use/def-use.factor +++ b/basis/compiler/cfg/def-use/def-use.factor @@ -6,6 +6,7 @@ namespaces quotations sequences sets slots words compiler.cfg.instructions compiler.cfg.instructions.syntax compiler.cfg.rpo ; FROM: namespaces => set ; +FROM: sets => members ; IN: compiler.cfg.def-use GENERIC: defs-vreg ( insn -- vreg/f ) @@ -95,9 +96,9 @@ SYMBOLS: defs insns uses ; cfg [| block | block instructions>> [ dup ##phi? - [ inputs>> [ use conjoin-at ] assoc-each ] - [ uses-vregs [ block swap use conjoin-at ] each ] + [ inputs>> [ use adjoin-at ] assoc-each ] + [ uses-vregs [ block swap use adjoin-at ] each ] if ] each ] each-basic-block - use [ keys ] assoc-map uses set ; + use [ members ] assoc-map uses set ; From 98da7ac16e81edc926e090fbdff0534f9b658bbb Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Tue, 2 Mar 2010 19:32:07 -0800 Subject: [PATCH 311/713] FUEL syntax updates --- misc/fuel/fuel-syntax.el | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index 67a8ee89e0..114355b3db 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -57,6 +57,7 @@ "LIBRARY:" "M:" "M::" "MACRO:" "MACRO::" "MAIN:" "MATH:" "MEMO:" "MEMO:" "METHOD:" "MIXIN:" + "NAN:" "OCT:" "POSTPONE:" "PREDICATE:" "PRIMITIVE:" "PRIVATE>" "PROVIDE:" "QUALIFIED-WITH:" "QUALIFIED:" @@ -64,7 +65,7 @@ "SINGLETON:" "SINGLETONS:" "SLOT:" "SPECIALIZED-ARRAY:" "SPECIALIZED-ARRAYS:" "STRING:" "STRUCT:" "SYMBOL:" "SYMBOLS:" "SYNTAX:" "TUPLE:" "t" "t?" "TYPEDEF:" "TYPED:" "TYPED::" "UNIFORM-TUPLE:" "UNION:" "UNION-STRUCT:" "USE:" "USING:" - "VARS:" "VERTEX-FORMAT:")) + "VARIANT:" "VERTEX-FORMAT:")) (defconst fuel-syntax--parsing-words-regex (regexp-opt fuel-syntax--parsing-words 'words)) @@ -91,7 +92,7 @@ "\\_<-?[0-9]+\\_>") (defconst fuel-syntax--raw-float-regex - "[0-9]*\\.[0-9]*\\([eE][+-]?[0-9]+\\)?") + "[0-9]*\\.[0-9]*\\([eEpP][+-]?[0-9]+\\)?") (defconst fuel-syntax--float-regex (format "\\_<-?%s\\_>" fuel-syntax--raw-float-regex)) @@ -121,7 +122,7 @@ '("IN:" "USE:" "FROM:" "EXCLUDE:" "QUALIFIED:" "QUALIFIED-WITH:"))) (defconst fuel-syntax--int-constant-def-regex - (fuel-syntax--second-word-regex '("ALIEN:" "CHAR:" "BIN:" "HEX:" "OCT:"))) + (fuel-syntax--second-word-regex '("ALIEN:" "CHAR:" "BIN:" "HEX:" "NAN:" "OCT:"))) (defconst fuel-syntax--type-definition-regex (fuel-syntax--second-word-regex @@ -163,18 +164,16 @@ "MEMO" "MEMO:" "METHOD" "SYNTAX" "PREDICATE" "PRIMITIVE" - "STRUCT" "TAG" "TUPLE" + "SINGLETONS" + "STRUCT" "SYMBOLS" "TAG" "TUPLE" "TYPED" "TYPED:" "UNIFORM-TUPLE" "UNION-STRUCT" "UNION" - "VERTEX-FORMAT")) + "VARIANT" "VERTEX-FORMAT")) (defconst fuel-syntax--no-indent-def-starts '("ARTICLE" "HELP" - "SINGLETONS" - "SPECIALIZED-ARRAYS" - "SYMBOLS" - "VARS")) + "SPECIALIZED-ARRAYS")) (defconst fuel-syntax--indent-def-start-regex (format "^\\(%s:\\)\\( \\|\n\\)" (regexp-opt fuel-syntax--indent-def-starts))) @@ -198,6 +197,7 @@ "IN:" "INSTANCE:" "LIBRARY:" "MAIN:" "MATH:" "MIXIN:" + "NAN:" "OCT:" "POSTPONE:" "PRIVATE>" "\\)" (1 "\\)" + ("\\_<\\(SYMBOLS\\|SPECIALIZED-ARRAYS\\|SINGLETONS\\|VARIANT\\): *?\\( \\|\n\\)\\([^;\n]\\|\\_>\\)" (2 "" (1 ">b")) ;; Let and lambda: From a7f1d4f231b7977f889a4adb249a3ac8bcebf037 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Wed, 3 Mar 2010 00:02:47 -0800 Subject: [PATCH 312/713] Initial checkin of OpenCL bindings --- extra/opencl/authors.txt | 1 + extra/opencl/ffi/authors.txt | 1 + extra/opencl/ffi/ffi-tests.factor | 74 ++++ extra/opencl/ffi/ffi.factor | 618 ++++++++++++++++++++++++++++++ extra/opencl/ffi/summary.txt | 1 + extra/opencl/ffi/tags.txt | 1 + extra/opencl/opencl-docs.factor | 246 ++++++++++++ extra/opencl/opencl-tests.factor | 44 +++ extra/opencl/opencl.factor | 572 +++++++++++++++++++++++++++ extra/opencl/summary.txt | 1 + extra/opencl/syntax/authors.txt | 1 + extra/opencl/syntax/syntax.factor | 8 + extra/opencl/tags.txt | 1 + 13 files changed, 1569 insertions(+) create mode 100644 extra/opencl/authors.txt create mode 100644 extra/opencl/ffi/authors.txt create mode 100644 extra/opencl/ffi/ffi-tests.factor create mode 100644 extra/opencl/ffi/ffi.factor create mode 100644 extra/opencl/ffi/summary.txt create mode 100644 extra/opencl/ffi/tags.txt create mode 100644 extra/opencl/opencl-docs.factor create mode 100644 extra/opencl/opencl-tests.factor create mode 100644 extra/opencl/opencl.factor create mode 100644 extra/opencl/summary.txt create mode 100644 extra/opencl/syntax/authors.txt create mode 100644 extra/opencl/syntax/syntax.factor create mode 100644 extra/opencl/tags.txt diff --git a/extra/opencl/authors.txt b/extra/opencl/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/extra/opencl/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/extra/opencl/ffi/authors.txt b/extra/opencl/ffi/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/extra/opencl/ffi/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/extra/opencl/ffi/ffi-tests.factor b/extra/opencl/ffi/ffi-tests.factor new file mode 100644 index 0000000000..44bb49ce4e --- /dev/null +++ b/extra/opencl/ffi/ffi-tests.factor @@ -0,0 +1,74 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: tools.test opencl.ffi multiline locals kernel io.encodings.ascii +io.encodings.string sequences libc alien.c-types destructors math specialized-arrays +math.order alien ; +FROM: alien.c-types => float ; +SPECIALIZED-ARRAY: float +IN: opencl.ffi.tests + +STRING: kernel-source +__kernel square( + __global float* input, + __global float* output, + const unsigned int count) +{ + int i = get_global_id(0); + if (i < count) + output[i] = input[i] * input[i]; +} +; + +ERROR: cl-error err ; +: cl-success ( err -- ) + dup CL_SUCCESS = [ drop ] [ cl-error ] if ; + +:: cl-string-array ( str -- alien ) + str ascii encode 0 suffix :> str-buffer + str-buffer length malloc &free :> str-alien + str-alien str-buffer dup length memcpy str-alien ; + +:: opencl-square ( in type -- out ) + f CL_DEVICE_TYPE_CPU 1 f [ f clGetDeviceIDs cl-success ] keep *void* :> device-id + f 1 device-id f f 0 [ clCreateContext ] keep *int cl-success :> context + context device-id 0 0 [ clCreateCommandQueue ] keep *int cl-success :> queue + + [ + context 1 kernel-source cl-string-array + f 0 [ clCreateProgramWithSource ] keep *int cl-success + [ 0 f f f f clBuildProgram cl-success ] + [ "square" cl-string-array 0 [ clCreateKernel ] keep *int cl-success ] + [ ] tri + ] with-destructors :> ( kernel program ) + + context CL_MEM_READ_ONLY in byte-length f + 0 [ clCreateBuffer ] keep *int cl-success :> input + + context CL_MEM_WRITE_ONLY in byte-length f + 0 [ clCreateBuffer ] keep *int cl-success :> output + + queue input CL_TRUE 0 in byte-length in 0 f f clEnqueueWriteBuffer cl-success + + kernel 0 cl_mem heap-size input clSetKernelArg cl-success + kernel 1 cl_mem heap-size output clSetKernelArg cl-success + kernel 2 uint heap-size in length clSetKernelArg cl-success + + queue kernel 1 f in length f + 0 f f clEnqueueNDRangeKernel cl-success + + queue clFinish cl-success + + queue output CL_TRUE 0 in byte-length in length + [ 0 f f clEnqueueReadBuffer cl-success ] keep + + input clReleaseMemObject cl-success + output clReleaseMemObject cl-success + program clReleaseProgram cl-success + kernel clReleaseKernel cl-success + queue clReleaseCommandQueue cl-success + context clReleaseContext cl-success ; + +[ float-array{ 1.0 4.0 9.0 16.0 100.0 } ] +[ float-array{ 1.0 2.0 3.0 4.0 10.0 } CL_DEVICE_TYPE_CPU opencl-square ] unit-test +[ float-array{ 1.0 4.0 9.0 16.0 100.0 } ] +[ float-array{ 1.0 2.0 3.0 4.0 10.0 } CL_DEVICE_TYPE_GPU opencl-square ] unit-test diff --git a/extra/opencl/ffi/ffi.factor b/extra/opencl/ffi/ffi.factor new file mode 100644 index 0000000000..36f1c13519 --- /dev/null +++ b/extra/opencl/ffi/ffi.factor @@ -0,0 +1,618 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: alien.c-types alien.libraries alien.syntax classes.struct +combinators system unix.types alien.accessors byte-arrays kernel ; +IN: opencl.ffi + +<< "opencl" { + { [ os windows? ] [ "OpenCL32.dll" ] } + { [ os macosx? ] [ "/System/Library/Frameworks/OpenCL.framework/OpenCL" ] } + { [ os unix? ] [ "libopencl.so" ] } + } cond "stdcall" add-library >> +LIBRARY: opencl + +! cl_platform.h +TYPEDEF: int8_t cl_char +TYPEDEF: uint8_t cl_uchar +TYPEDEF: int16_t cl_short +TYPEDEF: uint16_t cl_ushort +TYPEDEF: int32_t cl_int +TYPEDEF: uint32_t cl_uint +TYPEDEF: int64_t cl_long +TYPEDEF: uint64_t cl_ulong +TYPEDEF: uint16_t cl_half; +TYPEDEF: float cl_float; +TYPEDEF: double cl_double; + +CONSTANT: CL_CHAR_BIT 8 +CONSTANT: CL_SCHAR_MAX 127 +CONSTANT: CL_SCHAR_MIN -128 +CONSTANT: CL_CHAR_MAX 127 +CONSTANT: CL_CHAR_MIN -128 +CONSTANT: CL_UCHAR_MAX 255 +CONSTANT: CL_SHRT_MAX 32767 +CONSTANT: CL_SHRT_MIN -32768 +CONSTANT: CL_USHRT_MAX 65535 +CONSTANT: CL_INT_MAX 2147483647 +CONSTANT: CL_INT_MIN -2147483648 +CONSTANT: CL_UINT_MAX HEX: ffffffff +CONSTANT: CL_LONG_MAX HEX: 7FFFFFFFFFFFFFFF +CONSTANT: CL_LONG_MIN HEX: 8000000000000000 +CONSTANT: CL_ULONG_MAX HEX: FFFFFFFFFFFFFFFF + +CONSTANT: CL_FLT_DIG 6 +CONSTANT: CL_FLT_MANT_DIG 24 +CONSTANT: CL_FLT_MAX_10_EXP 38 +CONSTANT: CL_FLT_MAX_EXP 128 +CONSTANT: CL_FLT_MIN_10_EXP -37 +CONSTANT: CL_FLT_MIN_EXP -125 +CONSTANT: CL_FLT_RADIX 2 +CONSTANT: CL_FLT_MAX 340282346638528859811704183484516925440.0 +CONSTANT: CL_FLT_MIN 1.175494350822287507969e-38 +CONSTANT: CL_FLT_EPSILON HEX: 1.0p-23 + +CONSTANT: CL_DBL_DIG 15 +CONSTANT: CL_DBL_MANT_DIG 53 +CONSTANT: CL_DBL_MAX_10_EXP 308 +CONSTANT: CL_DBL_MAX_EXP 1024 +CONSTANT: CL_DBL_MIN_10_EXP -307 +CONSTANT: CL_DBL_MIN_EXP -1021 +CONSTANT: CL_DBL_RADIX 2 +CONSTANT: CL_DBL_MAX 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0 +CONSTANT: CL_DBL_MIN 2.225073858507201383090e-308 +CONSTANT: CL_DBL_EPSILON 2.220446049250313080847e-16 + +CONSTANT: CL_NAN NAN: 0 +CONSTANT: CL_HUGE_VALF 1.0e50 +CONSTANT: CL_HUGE_VAL 1.0e500 +CONSTANT: CL_MAXFLOAT 340282346638528859811704183484516925440.0 +CONSTANT: CL_INFINITY 1.0e50 + +TYPEDEF: uint cl_GLuint +TYPEDEF: int cl_GLint +TYPEDEF: uint cl_GLenum + +! cl.h +C-TYPE: _cl_platform_id +C-TYPE: _cl_device_id +C-TYPE: _cl_context +C-TYPE: _cl_command_queue +C-TYPE: _cl_mem +C-TYPE: _cl_program +C-TYPE: _cl_kernel +C-TYPE: _cl_event +C-TYPE: _cl_sampler + +TYPEDEF: _cl_platform_id* cl_platform_id +TYPEDEF: _cl_device_id* cl_device_id +TYPEDEF: _cl_context* cl_context +TYPEDEF: _cl_command_queue* cl_command_queue +TYPEDEF: _cl_mem* cl_mem +TYPEDEF: _cl_program* cl_program +TYPEDEF: _cl_kernel* cl_kernel +TYPEDEF: _cl_event* cl_event +TYPEDEF: _cl_sampler* cl_sampler + +TYPEDEF: cl_uint cl_bool +TYPEDEF: cl_ulong cl_bitfield +TYPEDEF: cl_bitfield cl_device_type +TYPEDEF: cl_uint cl_platform_info +TYPEDEF: cl_uint cl_device_info +TYPEDEF: cl_bitfield cl_device_address_info +TYPEDEF: cl_bitfield cl_device_fp_config +TYPEDEF: cl_uint cl_device_mem_cache_type +TYPEDEF: cl_uint cl_device_local_mem_type +TYPEDEF: cl_bitfield cl_device_exec_capabilities +TYPEDEF: cl_bitfield cl_command_queue_properties + +TYPEDEF: intptr_t cl_context_properties +TYPEDEF: cl_uint cl_context_info +TYPEDEF: cl_uint cl_command_queue_info +TYPEDEF: cl_uint cl_channel_order +TYPEDEF: cl_uint cl_channel_type +TYPEDEF: cl_bitfield cl_mem_flags +TYPEDEF: cl_uint cl_mem_object_type +TYPEDEF: cl_uint cl_mem_info +TYPEDEF: cl_uint cl_image_info +TYPEDEF: cl_uint cl_addressing_mode +TYPEDEF: cl_uint cl_filter_mode +TYPEDEF: cl_uint cl_sampler_info +TYPEDEF: cl_bitfield cl_map_flags +TYPEDEF: cl_uint cl_program_info +TYPEDEF: cl_uint cl_program_build_info +TYPEDEF: cl_int cl_build_status +TYPEDEF: cl_uint cl_kernel_info +TYPEDEF: cl_uint cl_kernel_work_group_info +TYPEDEF: cl_uint cl_event_info +TYPEDEF: cl_uint cl_command_type +TYPEDEF: cl_uint cl_profiling_info + +STRUCT: cl_image_format + { image_channel_order cl_channel_order } + { image_channel_data_type cl_channel_type } ; + +CONSTANT: CL_SUCCESS 0 +CONSTANT: CL_DEVICE_NOT_FOUND -1 +CONSTANT: CL_DEVICE_NOT_AVAILABLE -2 +CONSTANT: CL_COMPILER_NOT_AVAILABLE -3 +CONSTANT: CL_MEM_OBJECT_ALLOCATION_FAILURE -4 +CONSTANT: CL_OUT_OF_RESOURCES -5 +CONSTANT: CL_OUT_OF_HOST_MEMORY -6 +CONSTANT: CL_PROFILING_INFO_NOT_AVAILABLE -7 +CONSTANT: CL_MEM_COPY_OVERLAP -8 +CONSTANT: CL_IMAGE_FORMAT_MISMATCH -9 +CONSTANT: CL_IMAGE_FORMAT_NOT_SUPPORTED -10 +CONSTANT: CL_BUILD_PROGRAM_FAILURE -11 +CONSTANT: CL_MAP_FAILURE -12 + +CONSTANT: CL_INVALID_VALUE -30 +CONSTANT: CL_INVALID_DEVICE_TYPE -31 +CONSTANT: CL_INVALID_PLATFORM -32 +CONSTANT: CL_INVALID_DEVICE -33 +CONSTANT: CL_INVALID_CONTEXT -34 +CONSTANT: CL_INVALID_QUEUE_PROPERTIES -35 +CONSTANT: CL_INVALID_COMMAND_QUEUE -36 +CONSTANT: CL_INVALID_HOST_PTR -37 +CONSTANT: CL_INVALID_MEM_OBJECT -38 +CONSTANT: CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39 +CONSTANT: CL_INVALID_IMAGE_SIZE -40 +CONSTANT: CL_INVALID_SAMPLER -41 +CONSTANT: CL_INVALID_BINARY -42 +CONSTANT: CL_INVALID_BUILD_OPTIONS -43 +CONSTANT: CL_INVALID_PROGRAM -44 +CONSTANT: CL_INVALID_PROGRAM_EXECUTABLE -45 +CONSTANT: CL_INVALID_KERNEL_NAME -46 +CONSTANT: CL_INVALID_KERNEL_DEFINITION -47 +CONSTANT: CL_INVALID_KERNEL -48 +CONSTANT: CL_INVALID_ARG_INDEX -49 +CONSTANT: CL_INVALID_ARG_VALUE -50 +CONSTANT: CL_INVALID_ARG_SIZE -51 +CONSTANT: CL_INVALID_KERNEL_ARGS -52 +CONSTANT: CL_INVALID_WORK_DIMENSION -53 +CONSTANT: CL_INVALID_WORK_GROUP_SIZE -54 +CONSTANT: CL_INVALID_WORK_ITEM_SIZE -55 +CONSTANT: CL_INVALID_GLOBAL_OFFSET -56 +CONSTANT: CL_INVALID_EVENT_WAIT_LIST -57 +CONSTANT: CL_INVALID_EVENT -58 +CONSTANT: CL_INVALID_OPERATION -59 +CONSTANT: CL_INVALID_GL_OBJECT -60 +CONSTANT: CL_INVALID_BUFFER_SIZE -61 +CONSTANT: CL_INVALID_MIP_LEVEL -62 +CONSTANT: CL_INVALID_GLOBAL_WORK_SIZE -63 + +CONSTANT: CL_VERSION_1_0 1 + +CONSTANT: CL_FALSE 0 +CONSTANT: CL_TRUE 1 + +CONSTANT: CL_PLATFORM_PROFILE HEX: 0900 +CONSTANT: CL_PLATFORM_VERSION HEX: 0901 +CONSTANT: CL_PLATFORM_NAME HEX: 0902 +CONSTANT: CL_PLATFORM_VENDOR HEX: 0903 +CONSTANT: CL_PLATFORM_EXTENSIONS HEX: 0904 + +CONSTANT: CL_DEVICE_TYPE_DEFAULT 1 +CONSTANT: CL_DEVICE_TYPE_CPU 2 +CONSTANT: CL_DEVICE_TYPE_GPU 4 +CONSTANT: CL_DEVICE_TYPE_ACCELERATOR 8 +CONSTANT: CL_DEVICE_TYPE_ALL HEX: FFFFFFFF + +CONSTANT: CL_DEVICE_TYPE HEX: 1000 +CONSTANT: CL_DEVICE_VENDOR_ID HEX: 1001 +CONSTANT: CL_DEVICE_MAX_COMPUTE_UNITS HEX: 1002 +CONSTANT: CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS HEX: 1003 +CONSTANT: CL_DEVICE_MAX_WORK_GROUP_SIZE HEX: 1004 +CONSTANT: CL_DEVICE_MAX_WORK_ITEM_SIZES HEX: 1005 +CONSTANT: CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR HEX: 1006 +CONSTANT: CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT HEX: 1007 +CONSTANT: CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT HEX: 1008 +CONSTANT: CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG HEX: 1009 +CONSTANT: CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT HEX: 100A +CONSTANT: CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE HEX: 100B +CONSTANT: CL_DEVICE_MAX_CLOCK_FREQUENCY HEX: 100C +CONSTANT: CL_DEVICE_ADDRESS_BITS HEX: 100D +CONSTANT: CL_DEVICE_MAX_READ_IMAGE_ARGS HEX: 100E +CONSTANT: CL_DEVICE_MAX_WRITE_IMAGE_ARGS HEX: 100F +CONSTANT: CL_DEVICE_MAX_MEM_ALLOC_SIZE HEX: 1010 +CONSTANT: CL_DEVICE_IMAGE2D_MAX_WIDTH HEX: 1011 +CONSTANT: CL_DEVICE_IMAGE2D_MAX_HEIGHT HEX: 1012 +CONSTANT: CL_DEVICE_IMAGE3D_MAX_WIDTH HEX: 1013 +CONSTANT: CL_DEVICE_IMAGE3D_MAX_HEIGHT HEX: 1014 +CONSTANT: CL_DEVICE_IMAGE3D_MAX_DEPTH HEX: 1015 +CONSTANT: CL_DEVICE_IMAGE_SUPPORT HEX: 1016 +CONSTANT: CL_DEVICE_MAX_PARAMETER_SIZE HEX: 1017 +CONSTANT: CL_DEVICE_MAX_SAMPLERS HEX: 1018 +CONSTANT: CL_DEVICE_MEM_BASE_ADDR_ALIGN HEX: 1019 +CONSTANT: CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE HEX: 101A +CONSTANT: CL_DEVICE_SINGLE_FP_CONFIG HEX: 101B +CONSTANT: CL_DEVICE_GLOBAL_MEM_CACHE_TYPE HEX: 101C +CONSTANT: CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE HEX: 101D +CONSTANT: CL_DEVICE_GLOBAL_MEM_CACHE_SIZE HEX: 101E +CONSTANT: CL_DEVICE_GLOBAL_MEM_SIZE HEX: 101F +CONSTANT: CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE HEX: 1020 +CONSTANT: CL_DEVICE_MAX_CONSTANT_ARGS HEX: 1021 +CONSTANT: CL_DEVICE_LOCAL_MEM_TYPE HEX: 1022 +CONSTANT: CL_DEVICE_LOCAL_MEM_SIZE HEX: 1023 +CONSTANT: CL_DEVICE_ERROR_CORRECTION_SUPPORT HEX: 1024 +CONSTANT: CL_DEVICE_PROFILING_TIMER_RESOLUTION HEX: 1025 +CONSTANT: CL_DEVICE_ENDIAN_LITTLE HEX: 1026 +CONSTANT: CL_DEVICE_AVAILABLE HEX: 1027 +CONSTANT: CL_DEVICE_COMPILER_AVAILABLE HEX: 1028 +CONSTANT: CL_DEVICE_EXECUTION_CAPABILITIES HEX: 1029 +CONSTANT: CL_DEVICE_QUEUE_PROPERTIES HEX: 102A +CONSTANT: CL_DEVICE_NAME HEX: 102B +CONSTANT: CL_DEVICE_VENDOR HEX: 102C +CONSTANT: CL_DRIVER_VERSION HEX: 102D +CONSTANT: CL_DEVICE_PROFILE HEX: 102E +CONSTANT: CL_DEVICE_VERSION HEX: 102F +CONSTANT: CL_DEVICE_EXTENSIONS HEX: 1030 +CONSTANT: CL_DEVICE_PLATFORM HEX: 1031 + +CONSTANT: CL_FP_DENORM 1 +CONSTANT: CL_FP_INF_NAN 2 +CONSTANT: CL_FP_ROUND_TO_NEAREST 4 +CONSTANT: CL_FP_ROUND_TO_ZERO 8 +CONSTANT: CL_FP_ROUND_TO_INF 16 +CONSTANT: CL_FP_FMA 32 + +CONSTANT: CL_NONE 0 +CONSTANT: CL_READ_ONLY_CACHE 1 +CONSTANT: CL_READ_WRITE_CACHE 2 + +CONSTANT: CL_LOCAL 1 +CONSTANT: CL_GLOBAL 2 + +CONSTANT: CL_EXEC_KERNEL 1 +CONSTANT: CL_EXEC_NATIVE_KERNEL 2 + +CONSTANT: CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE 1 +CONSTANT: CL_QUEUE_PROFILING_ENABLE 2 + +CONSTANT: CL_CONTEXT_REFERENCE_COUNT HEX: 1080 +CONSTANT: CL_CONTEXT_DEVICES HEX: 1081 +CONSTANT: CL_CONTEXT_PROPERTIES HEX: 1082 + +CONSTANT: CL_CONTEXT_PLATFORM HEX: 1084 + +CONSTANT: CL_QUEUE_CONTEXT HEX: 1090 +CONSTANT: CL_QUEUE_DEVICE HEX: 1091 +CONSTANT: CL_QUEUE_REFERENCE_COUNT HEX: 1092 +CONSTANT: CL_QUEUE_PROPERTIES HEX: 1093 + +CONSTANT: CL_MEM_READ_WRITE 1 +CONSTANT: CL_MEM_WRITE_ONLY 2 +CONSTANT: CL_MEM_READ_ONLY 4 +CONSTANT: CL_MEM_USE_HOST_PTR 8 +CONSTANT: CL_MEM_ALLOC_HOST_PTR 16 +CONSTANT: CL_MEM_COPY_HOST_PTR 32 + +CONSTANT: CL_R HEX: 10B0 +CONSTANT: CL_A HEX: 10B1 +CONSTANT: CL_RG HEX: 10B2 +CONSTANT: CL_RA HEX: 10B3 +CONSTANT: CL_RGB HEX: 10B4 +CONSTANT: CL_RGBA HEX: 10B5 +CONSTANT: CL_BGRA HEX: 10B6 +CONSTANT: CL_ARGB HEX: 10B7 +CONSTANT: CL_INTENSITY HEX: 10B8 +CONSTANT: CL_LUMINANCE HEX: 10B9 + +CONSTANT: CL_SNORM_INT8 HEX: 10D0 +CONSTANT: CL_SNORM_INT16 HEX: 10D1 +CONSTANT: CL_UNORM_INT8 HEX: 10D2 +CONSTANT: CL_UNORM_INT16 HEX: 10D3 +CONSTANT: CL_UNORM_SHORT_565 HEX: 10D4 +CONSTANT: CL_UNORM_SHORT_555 HEX: 10D5 +CONSTANT: CL_UNORM_INT_101010 HEX: 10D6 +CONSTANT: CL_SIGNED_INT8 HEX: 10D7 +CONSTANT: CL_SIGNED_INT16 HEX: 10D8 +CONSTANT: CL_SIGNED_INT32 HEX: 10D9 +CONSTANT: CL_UNSIGNED_INT8 HEX: 10DA +CONSTANT: CL_UNSIGNED_INT16 HEX: 10DB +CONSTANT: CL_UNSIGNED_INT32 HEX: 10DC +CONSTANT: CL_HALF_FLOAT HEX: 10DD +CONSTANT: CL_FLOAT HEX: 10DE + +CONSTANT: CL_MEM_OBJECT_BUFFER HEX: 10F0 +CONSTANT: CL_MEM_OBJECT_IMAGE2D HEX: 10F1 +CONSTANT: CL_MEM_OBJECT_IMAGE3D HEX: 10F2 + +CONSTANT: CL_MEM_TYPE HEX: 1100 +CONSTANT: CL_MEM_FLAGS HEX: 1101 +CONSTANT: CL_MEM_SIZE HEX: 1102 +CONSTANT: CL_MEM_HOST_PTR HEX: 1103 +CONSTANT: CL_MEM_MAP_COUNT HEX: 1104 +CONSTANT: CL_MEM_REFERENCE_COUNT HEX: 1105 +CONSTANT: CL_MEM_CONTEXT HEX: 1106 + +CONSTANT: CL_IMAGE_FORMAT HEX: 1110 +CONSTANT: CL_IMAGE_ELEMENT_SIZE HEX: 1111 +CONSTANT: CL_IMAGE_ROW_PITCH HEX: 1112 +CONSTANT: CL_IMAGE_SLICE_PITCH HEX: 1113 +CONSTANT: CL_IMAGE_WIDTH HEX: 1114 +CONSTANT: CL_IMAGE_HEIGHT HEX: 1115 +CONSTANT: CL_IMAGE_DEPTH HEX: 1116 + +CONSTANT: CL_ADDRESS_NONE HEX: 1130 +CONSTANT: CL_ADDRESS_CLAMP_TO_EDGE HEX: 1131 +CONSTANT: CL_ADDRESS_CLAMP HEX: 1132 +CONSTANT: CL_ADDRESS_REPEAT HEX: 1133 + +CONSTANT: CL_FILTER_NEAREST HEX: 1140 +CONSTANT: CL_FILTER_LINEAR HEX: 1141 + +CONSTANT: CL_SAMPLER_REFERENCE_COUNT HEX: 1150 +CONSTANT: CL_SAMPLER_CONTEXT HEX: 1151 +CONSTANT: CL_SAMPLER_NORMALIZED_COORDS HEX: 1152 +CONSTANT: CL_SAMPLER_ADDRESSING_MODE HEX: 1153 +CONSTANT: CL_SAMPLER_FILTER_MODE HEX: 1154 + +CONSTANT: CL_MAP_READ 1 +CONSTANT: CL_MAP_WRITE 2 + +CONSTANT: CL_PROGRAM_REFERENCE_COUNT HEX: 1160 +CONSTANT: CL_PROGRAM_CONTEXT HEX: 1161 +CONSTANT: CL_PROGRAM_NUM_DEVICES HEX: 1162 +CONSTANT: CL_PROGRAM_DEVICES HEX: 1163 +CONSTANT: CL_PROGRAM_SOURCE HEX: 1164 +CONSTANT: CL_PROGRAM_BINARY_SIZES HEX: 1165 +CONSTANT: CL_PROGRAM_BINARIES HEX: 1166 + +CONSTANT: CL_PROGRAM_BUILD_STATUS HEX: 1181 +CONSTANT: CL_PROGRAM_BUILD_OPTIONS HEX: 1182 +CONSTANT: CL_PROGRAM_BUILD_LOG HEX: 1183 + +CONSTANT: CL_BUILD_SUCCESS 0 +CONSTANT: CL_BUILD_NONE -1 +CONSTANT: CL_BUILD_ERROR -2 +CONSTANT: CL_BUILD_IN_PROGRESS -3 + +CONSTANT: CL_KERNEL_FUNCTION_NAME HEX: 1190 +CONSTANT: CL_KERNEL_NUM_ARGS HEX: 1191 +CONSTANT: CL_KERNEL_REFERENCE_COUNT HEX: 1192 +CONSTANT: CL_KERNEL_CONTEXT HEX: 1193 +CONSTANT: CL_KERNEL_PROGRAM HEX: 1194 + +CONSTANT: CL_KERNEL_WORK_GROUP_SIZE HEX: 11B0 +CONSTANT: CL_KERNEL_COMPILE_WORK_GROUP_SIZE HEX: 11B1 +CONSTANT: CL_KERNEL_LOCAL_MEM_SIZE HEX: 11B2 + +CONSTANT: CL_EVENT_COMMAND_QUEUE HEX: 11D0 +CONSTANT: CL_EVENT_COMMAND_TYPE HEX: 11D1 +CONSTANT: CL_EVENT_REFERENCE_COUNT HEX: 11D2 +CONSTANT: CL_EVENT_COMMAND_EXECUTION_STATUS HEX: 11D3 + +CONSTANT: CL_COMMAND_NDRANGE_KERNEL HEX: 11F0 +CONSTANT: CL_COMMAND_TASK HEX: 11F1 +CONSTANT: CL_COMMAND_NATIVE_KERNEL HEX: 11F2 +CONSTANT: CL_COMMAND_READ_BUFFER HEX: 11F3 +CONSTANT: CL_COMMAND_WRITE_BUFFER HEX: 11F4 +CONSTANT: CL_COMMAND_COPY_BUFFER HEX: 11F5 +CONSTANT: CL_COMMAND_READ_IMAGE HEX: 11F6 +CONSTANT: CL_COMMAND_WRITE_IMAGE HEX: 11F7 +CONSTANT: CL_COMMAND_COPY_IMAGE HEX: 11F8 +CONSTANT: CL_COMMAND_COPY_IMAGE_TO_BUFFER HEX: 11F9 +CONSTANT: CL_COMMAND_COPY_BUFFER_TO_IMAGE HEX: 11FA +CONSTANT: CL_COMMAND_MAP_BUFFER HEX: 11FB +CONSTANT: CL_COMMAND_MAP_IMAGE HEX: 11FC +CONSTANT: CL_COMMAND_UNMAP_MEM_OBJECT HEX: 11FD +CONSTANT: CL_COMMAND_MARKER HEX: 11FE +CONSTANT: CL_COMMAND_ACQUIRE_GL_OBJECTS HEX: 11FF +CONSTANT: CL_COMMAND_RELEASE_GL_OBJECTS HEX: 1200 + +CONSTANT: CL_COMPLETE HEX: 0 +CONSTANT: CL_RUNNING HEX: 1 +CONSTANT: CL_SUBMITTED HEX: 2 +CONSTANT: CL_QUEUED HEX: 3 + +CONSTANT: CL_PROFILING_COMMAND_QUEUED HEX: 1280 +CONSTANT: CL_PROFILING_COMMAND_SUBMIT HEX: 1281 +CONSTANT: CL_PROFILING_COMMAND_START HEX: 1282 +CONSTANT: CL_PROFILING_COMMAND_END HEX: 1283 + +FUNCTION: cl_int clGetPlatformIDs ( cl_uint num_entries, cl_platform_id* platforms, cl_uint* num_platforms ) ; +FUNCTION: cl_int clGetPlatformInfo ( cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; +FUNCTION: cl_int clGetDeviceIDs ( cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id* devices, cl_uint* num_devices ) ; +FUNCTION: cl_int clGetDeviceInfo ( cl_device_id device, cl_device_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; +CALLBACK: void cl_create_context_cb ( char* a, void* b, size_t s, void* c ) ; +FUNCTION: cl_context clCreateContext ( cl_context_properties* properties, cl_uint num_devices, cl_device_id* devices, cl_create_context_cb pfn_notify, void* user_data, cl_int* errcode_ret ) ; +FUNCTION: cl_context clCreateContextFromType ( cl_context_properties* properties, cl_device_type device_type, cl_create_context_cb pfn_notify, void* user_data, cl_int* errcode_ret ) ; +FUNCTION: cl_int clRetainContext ( cl_context context ) ; +FUNCTION: cl_int clReleaseContext ( cl_context context ) ; +FUNCTION: cl_int clGetContextInfo ( cl_context context, cl_context_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; +FUNCTION: cl_command_queue clCreateCommandQueue ( cl_context context, cl_device_id device, cl_command_queue_properties properties, cl_int* errcode_ret ) ; +FUNCTION: cl_int clRetainCommandQueue ( cl_command_queue command_queue ) ; +FUNCTION: cl_int clReleaseCommandQueue ( cl_command_queue command_queue ) ; +FUNCTION: cl_int clGetCommandQueueInfo ( cl_command_queue command_queue, cl_command_queue_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; +FUNCTION: cl_int clSetCommandQueueProperty ( cl_command_queue command_queue, cl_command_queue_properties properties, cl_bool enable, cl_command_queue_properties* old_properties ) ; +FUNCTION: cl_mem clCreateBuffer ( cl_context context, cl_mem_flags flags, size_t size, void* host_ptr, cl_int* errcode_ret ) ; +FUNCTION: cl_mem clCreateImage2D ( cl_context context, cl_mem_flags flags, cl_image_format* image_format, size_t image_width, size_t image_height, size_t image_row_pitch, void* host_ptr, cl_int* errcode_ret ) ; +FUNCTION: cl_mem clCreateImage3D ( cl_context context, cl_mem_flags flags, cl_image_format* image_format, size_t image_width, size_t image_height, size_t image_depth, size_t image_row_pitch, size_t image_slice_pitch, void* host_ptr, cl_int* errcode_ret ) ; +FUNCTION: cl_int clRetainMemObject ( cl_mem memobj ) ; +FUNCTION: cl_int clReleaseMemObject ( cl_mem memobj ) ; +FUNCTION: cl_int clGetSupportedImageFormats ( cl_context context, cl_mem_flags flags, cl_mem_object_type image_type, cl_uint num_entries, cl_image_format* image_formats, cl_uint* num_image_formats ) ; +FUNCTION: cl_int clGetMemObjectInfo ( cl_mem memobj, cl_mem_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; +FUNCTION: cl_int clGetImageInfo ( cl_mem image, cl_image_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; +FUNCTION: cl_sampler clCreateSampler ( cl_context context, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, cl_int* errcode_ret ) ; +FUNCTION: cl_int clRetainSampler ( cl_sampler sampler ) ; +FUNCTION: cl_int clReleaseSampler ( cl_sampler sampler ) ; +FUNCTION: cl_int clGetSamplerInfo ( cl_sampler sampler, cl_sampler_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; +FUNCTION: cl_program clCreateProgramWithSource ( cl_context context, cl_uint count, char** strings, size_t* lengths, cl_int* errcode_ret ) ; +FUNCTION: cl_program clCreateProgramWithBinary ( cl_context context, cl_uint num_devices, cl_device_id* device_list, size_t* lengths, char** binaries, cl_int* binary_status, cl_int* errcode_ret ) ; +FUNCTION: cl_int clRetainProgram ( cl_program program ) ; +FUNCTION: cl_int clReleaseProgram ( cl_program program ) ; +CALLBACK: void cl_build_program_cb ( cl_program program, void* user_data ) ; +FUNCTION: cl_int clBuildProgram ( cl_program program, cl_uint num_devices, cl_device_id* device_list, char* options, cl_build_program_cb pfn_notify, void* user_data ) ; +FUNCTION: cl_int clUnloadCompiler ( ) ; +FUNCTION: cl_int clGetProgramInfo ( cl_program program, cl_program_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; +FUNCTION: cl_int clGetProgramBuildInfo ( cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; +FUNCTION: cl_kernel clCreateKernel ( cl_program program, char* kernel_name, cl_int* errcode_ret ) ; +FUNCTION: cl_int clCreateKernelsInProgram ( cl_program program, cl_uint num_kernels, cl_kernel* kernels, cl_uint* num_kernels_ret ) ; +FUNCTION: cl_int clRetainKernel ( cl_kernel kernel ) ; +FUNCTION: cl_int clReleaseKernel ( cl_kernel kernel ) ; +FUNCTION: cl_int clSetKernelArg ( cl_kernel kernel, cl_uint arg_index, size_t arg_size, void* arg_value ) ; +FUNCTION: cl_int clGetKernelInfo ( cl_kernel kernel, cl_kernel_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; +FUNCTION: cl_int clGetKernelWorkGroupInfo ( cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; +FUNCTION: cl_int clWaitForEvents ( cl_uint num_events, cl_event* event_list ) ; +FUNCTION: cl_int clGetEventInfo ( cl_event event, cl_event_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; +FUNCTION: cl_int clRetainEvent ( cl_event event ) ; +FUNCTION: cl_int clReleaseEvent ( cl_event event ) ; +FUNCTION: cl_int clGetEventProfilingInfo ( cl_event event, cl_profiling_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; +FUNCTION: cl_int clFlush ( cl_command_queue command_queue ) ; +FUNCTION: cl_int clFinish ( cl_command_queue command_queue ) ; +FUNCTION: cl_int clEnqueueReadBuffer ( cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t cb, void* ptr, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: cl_int clEnqueueWriteBuffer ( cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t cb, void* ptr, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: cl_int clEnqueueCopyBuffer ( cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t cb, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: cl_int clEnqueueReadImage ( cl_command_queue command_queue, cl_mem image, cl_bool blocking_read, size_t** origin, size_t** region, size_t row_pitch, size_t slice_pitch, void* ptr, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: cl_int clEnqueueWriteImage ( cl_command_queue command_queue, cl_mem image, cl_bool blocking_write, size_t** origin, size_t** region, size_t input_row_pitch, size_t input_slice_pitch, void* ptr, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: cl_int clEnqueueCopyImage ( cl_command_queue command_queue, cl_mem src_image, cl_mem dst_image, size_t** src_origin, size_t** dst_origin, size_t** region, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: cl_int clEnqueueCopyImageToBuffer ( cl_command_queue command_queue, cl_mem src_image, cl_mem dst_buffer, size_t** src_origin, size_t** region, size_t dst_offset, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: cl_int clEnqueueCopyBufferToImage ( cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_image, size_t src_offset, size_t** dst_origin, size_t** region, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: void* clEnqueueMapBuffer ( cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map, cl_map_flags map_flags, size_t offset, size_t cb, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event, cl_int* errcode_ret ) ; +FUNCTION: void* clEnqueueMapImage ( cl_command_queue command_queue, cl_mem image, cl_bool blocking_map, cl_map_flags map_flags, size_t** origin, size_t** region, size_t* image_row_pitch, size_t* image_slice_pitch, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event, cl_int* errcode_ret ) ; +FUNCTION: cl_int clEnqueueUnmapMemObject ( cl_command_queue command_queue, cl_mem memobj, void* mapped_ptr, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: cl_int clEnqueueNDRangeKernel ( cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, size_t* global_work_offset, size_t* global_work_size, size_t* local_work_size, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +CALLBACK: void cl_enqueue_task_cb ( void* args ) ; +FUNCTION: cl_int clEnqueueTask ( cl_command_queue command_queue, cl_kernel kernel, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: cl_int clEnqueueNativeKernel ( cl_command_queue command_queue, cl_enqueue_task_cb user_func, void* args, size_t cb_args, cl_uint num_mem_objects, cl_mem* mem_list, void** args_mem_loc, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: cl_int clEnqueueMarker ( cl_command_queue command_queue, cl_event* event ) ; +FUNCTION: cl_int clEnqueueWaitForEvents ( cl_command_queue command_queue, cl_uint num_events, cl_event* event_list ) ; +FUNCTION: cl_int clEnqueueBarrier ( cl_command_queue command_queue ) ; +FUNCTION: void* clGetExtensionFunctionAddress ( char* func_name ) ; + +! cl_ext.h +CONSTANT: CL_DEVICE_DOUBLE_FP_CONFIG HEX: 1032 +CONSTANT: CL_DEVICE_HALF_FP_CONFIG HEX: 1033 + +! cl_khr_icd.txt +CONSTANT: CL_PLATFORM_ICD_SUFFIX_KHR HEX: 0920 +CONSTANT: CL_PLATFORM_NOT_FOUND_KHR -1001 + +FUNCTION: cl_int clIcdGetPlatformIDsKHR ( cl_uint num_entries, cl_platform_id* platforms, cl_uint* num_platforms ) ; + +! cl_gl.h +TYPEDEF: cl_uint cl_gl_object_type +TYPEDEF: cl_uint cl_gl_texture_info +TYPEDEF: cl_uint cl_gl_platform_info + +CONSTANT: CL_GL_OBJECT_BUFFER HEX: 2000 +CONSTANT: CL_GL_OBJECT_TEXTURE2D HEX: 2001 +CONSTANT: CL_GL_OBJECT_TEXTURE3D HEX: 2002 +CONSTANT: CL_GL_OBJECT_RENDERBUFFER HEX: 2003 +CONSTANT: CL_GL_TEXTURE_TARGET HEX: 2004 +CONSTANT: CL_GL_MIPMAP_LEVEL HEX: 2005 + +FUNCTION: cl_mem clCreateFromGLBuffer ( cl_context context, cl_mem_flags flags, cl_GLuint bufobj, int* errcode_ret ) ; +FUNCTION: cl_mem clCreateFromGLTexture2D ( cl_context context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture, cl_int* errcode_ret ) ; +FUNCTION: cl_mem clCreateFromGLTexture3D ( cl_context context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture, cl_int* errcode_ret ) ; +FUNCTION: cl_mem clCreateFromGLRenderbuffer ( cl_context context, cl_mem_flags flags, cl_GLuint renderbuffer, cl_int* errcode_ret ) ; +FUNCTION: cl_int clGetGLObjectInfo ( cl_mem memobj, cl_gl_object_type* gl_object_type, cl_GLuint* gl_object_name ) ; +FUNCTION: cl_int clGetGLTextureInfo ( cl_mem memobj, cl_gl_texture_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; +FUNCTION: cl_int clEnqueueAcquireGLObjects ( cl_command_queue command_queue, cl_uint num_objects, cl_mem* mem_objects, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: cl_int clEnqueueReleaseGLObjects ( cl_command_queue command_queue, cl_uint num_objects, cl_mem* mem_objects, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; + +! cl_khr_gl_sharing.txt +TYPEDEF: cl_uint cl_gl_context_info + +CONSTANT: CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000 +CONSTANT: CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR HEX: 2006 +CONSTANT: CL_DEVICES_FOR_GL_CONTEXT_KHR HEX: 2007 +CONSTANT: CL_GL_CONTEXT_KHR HEX: 2008 +CONSTANT: CL_EGL_DISPLAY_KHR HEX: 2009 +CONSTANT: CL_GLX_DISPLAY_KHR HEX: 200A +CONSTANT: CL_WGL_HDC_KHR HEX: 200B +CONSTANT: CL_CGL_SHAREGROUP_KHR HEX: 200C + +FUNCTION: cl_int clGetGLContextInfoKHR ( cl_context_properties* properties, cl_gl_context_info param_name, size_t param_value_size, void* param_value, size_t* param_value_size_ret ) ; + +! cl_nv_d3d9_sharing.txt +CONSTANT: CL_D3D9_DEVICE_NV HEX: 4022 +CONSTANT: CL_D3D9_ADAPTER_NAME_NV HEX: 4023 +CONSTANT: CL_PREFERRED_DEVICES_FOR_D3D9_NV HEX: 4024 +CONSTANT: CL_ALL_DEVICES_FOR_D3D9_NV HEX: 4025 +CONSTANT: CL_CONTEXT_D3D9_DEVICE_NV HEX: 4026 +CONSTANT: CL_MEM_D3D9_RESOURCE_NV HEX: 4027 +CONSTANT: CL_IMAGE_D3D9_FACE_NV HEX: 4028 +CONSTANT: CL_IMAGE_D3D9_LEVEL_NV HEX: 4029 +CONSTANT: CL_COMMAND_ACQUIRE_D3D9_OBJECTS_NV HEX: 402A +CONSTANT: CL_COMMAND_RELEASE_D3D9_OBJECTS_NV HEX: 402B +CONSTANT: CL_INVALID_D3D9_DEVICE_NV -1010 +CONSTANT: CL_INVALID_D3D9_RESOURCE_NV -1011 +CONSTANT: CL_D3D9_RESOURCE_ALREADY_ACQUIRED_NV -1012 +CONSTANT: CL_D3D9_RESOURCE_NOT_ACQUIRED_NV -1013 + +TYPEDEF: void* cl_d3d9_device_source_nv +TYPEDEF: void* cl_d3d9_device_set_nv + +FUNCTION: cl_int clGetDeviceIDsFromD3D9NV ( cl_platform_id platform, cl_d3d9_device_source_nv d3d_device_source, void* d3d_object, cl_d3d9_device_set_nv d3d_device_set, cl_uint num_entries, cl_device_id* devices, cl_uint* num_devices ) ; +FUNCTION: cl_mem clCreateFromD3D9VertexBufferNV ( cl_context context, cl_mem_flags flags, void* id3dvb9_resource, cl_int* errcode_ret ) ; +FUNCTION: cl_mem clCreateFromD3D9IndexBufferNV ( cl_context context, cl_mem_flags flags, void* id3dib9_resource, cl_int* errcode_ret ) ; +FUNCTION: cl_mem clCreateFromD3D9SurfaceNV ( cl_context context, cl_mem_flags flags, void* id3dsurface9_resource, cl_int* errcode_ret ) ; +FUNCTION: cl_mem clCreateFromD3D9TextureNV ( cl_context context, cl_mem_flags flags, void* id3dtexture9_resource, uint miplevel, cl_int* errcode_ret ) ; +FUNCTION: cl_mem clCreateFromD3D9CubeTextureNV ( cl_context context, cl_mem_flags flags, void* id3dct9_resource, int facetype, uint miplevel, cl_int* errcode_ret ) ; +FUNCTION: cl_mem clCreateFromD3D9VolumeTextureNV ( cl_context context, cl_mem_flags flags, void* id3dvt9-resource, uint miplevel, cl_int* errcode_ret ) ; +FUNCTION: cl_int clEnqueueAcquireD3D9ObjectsNV ( cl_command_queue command_queue, cl_uint num_objects, cl_mem* mem_objects, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: cl_int clEnqueueReleaseD3D9ObjectsNV ( cl_command_queue command_queue, cl_uint num_objects, cl_mem* mem_objects, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; + +! cl_nv_d3d10_sharing.txt +CONSTANT: CL_D3D10_DEVICE_NV HEX: 4010 +CONSTANT: CL_D3D10_DXGI_ADAPTER_NV HEX: 4011 +CONSTANT: CL_PREFERRED_DEVICES_FOR_D3D10_NV HEX: 4012 +CONSTANT: CL_ALL_DEVICES_FOR_D3D10_NV HEX: 4013 +CONSTANT: CL_CONTEXT_D3D10_DEVICE_NV HEX: 4014 +CONSTANT: CL_MEM_D3D10_RESOURCE_NV HEX: 4015 +CONSTANT: CL_IMAGE_D3D10_SUBRESOURCE_NV HEX: 4016 +CONSTANT: CL_COMMAND_ACQUIRE_D3D10_OBJECTS_NV HEX: 4017 +CONSTANT: CL_COMMAND_RELEASE_D3D10_OBJECTS_NV HEX: 4018 +CONSTANT: CL_INVALID_D3D10_DEVICE_NV -1002 +CONSTANT: CL_INVALID_D3D10_RESOURCE_NV -1003 +CONSTANT: CL_D3D10_RESOURCE_ALREADY_ACQUIRED_NV -1004 +CONSTANT: CL_D3D10_RESOURCE_NOT_ACQUIRED_NV -1005 + +TYPEDEF: void* cl_d3d10_device_source_nv +TYPEDEF: void* cl_d3d10_device_set_nv + +FUNCTION: cl_int clGetDeviceIDsFromD3D10NV ( cl_platform_id platform, cl_d3d10_device_source_nv d3d_device_source, void* d3d_object, cl_d3d10_device_set_nv d3d_device_set, cl_uint num_entries, cl_device_id* devices, cl_uint* num_devices ) ; +FUNCTION: cl_mem clCreateFromD3D10BufferNV ( cl_context context, cl_mem_flags flags, void* id3d10buffer_resource, cl_int* errcode_ret ) ; +FUNCTION: cl_mem clCreateFromD3D10Texture2DNV ( cl_context context, cl_mem_flags flags, void* id3d10texture2d_resource, uint subresource, cl_int* errcode_ret ) ; +FUNCTION: cl_mem clCreateFromD3D10Texture3DNV ( cl_context context, cl_mem_flags flags, void* id3d10texture3d_resource, uint subresource, cl_int* errcode_ret ) ; +FUNCTION: cl_int clEnqueueAcquireD3D10ObjectsNV ( cl_command_queue command_queue, cl_uint num_objects, cl_mem* mem_objects, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: cl_int clEnqueueReleaseD3D10ObjectsNV ( cl_command_queue command_queue, cl_uint num_objects, cl_mem* mem_objects, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; + +! cl_nv_d3d11_sharing.txt +CONSTANT: CL_D3D11_DEVICE_NV HEX: 4019 +CONSTANT: CL_D3D11_DXGI_ADAPTER_NV HEX: 401A +CONSTANT: CL_PREFERRED_DEVICES_FOR_D3D11_NV HEX: 401B +CONSTANT: CL_ALL_DEVICES_FOR_D3D11_NV HEX: 401C +CONSTANT: CL_CONTEXT_D3D11_DEVICE_NV HEX: 401D +CONSTANT: CL_MEM_D3D11_RESOURCE_NV HEX: 401E +CONSTANT: CL_IMAGE_D3D11_SUBRESOURCE_NV HEX: 401F +CONSTANT: CL_COMMAND_ACQUIRE_D3D11_OBJECTS_NV HEX: 4020 +CONSTANT: CL_COMMAND_RELEASE_D3D11_OBJECTS_NV HEX: 4021 +CONSTANT: CL_INVALID_D3D11_DEVICE_NV -1006 +CONSTANT: CL_INVALID_D3D11_RESOURCE_NV -1007 +CONSTANT: CL_D3D11_RESOURCE_ALREADY_ACQUIRED_NV -1008 +CONSTANT: CL_D3D11_RESOURCE_NOT_ACQUIRED_NV -1009 + +TYPEDEF: void* cl_d3d11_device_source_nv +TYPEDEF: void* cl_d3d11_device_set_nv + +FUNCTION: cl_int clGetDeviceIDsFromD3D11NV ( cl_platform_id platform, cl_d3d11_device_source_nv d3d_device_source, void* d3d_object, cl_d3d11_device_set_nv d3d_device_set, cl_uint num_entries, cl_device_id* devices, cl_uint* num_devices ) ; +FUNCTION: cl_mem clCreateFromD3D11BufferNV ( cl_context context, cl_mem_flags flags, void* id3d11buffer_resource, cl_int* errcode_ret ) ; +FUNCTION: cl_mem clCreateFromD3D11Texture2DNV ( cl_context context, cl_mem_flags flags, void* id3d11texture2d_resource, uint subresource, cl_int* errcode_ret ) ; +FUNCTION: cl_mem clCreateFromD3D11Texture3DNV ( cl_context context, cl_mem_flags flags, void* id3dtexture3d_resource, uint subresource, cl_int* errcode_ret ) ; +FUNCTION: cl_int clEnqueueAcquireD3D11ObjectsNV ( cl_command_queue command_queue, cl_uint num_objects, cl_mem* mem_objects, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; +FUNCTION: cl_int clEnqueueReleaseD3D11ObjectsNV ( cl_command_queue command_queue, cl_uint num_objects, cl_mem* mem_objects, cl_uint num_events_in_wait_list, cl_event* event_wait_list, cl_event* event ) ; + +! Utility words needed for working with the API +: *size_t ( c-ptr -- value ) + size_t heap-size { + { 4 [ 0 alien-unsigned-4 ] } + { 8 [ 0 alien-unsigned-8 ] } + } case ; inline + +: ( value -- c-ptr ) + size_t heap-size [ (byte-array) ] keep { + { 4 [ [ 0 set-alien-unsigned-4 ] keep ] } + { 8 [ [ 0 set-alien-unsigned-8 ] keep ] } + } case ; inline diff --git a/extra/opencl/ffi/summary.txt b/extra/opencl/ffi/summary.txt new file mode 100644 index 0000000000..e699c14cda --- /dev/null +++ b/extra/opencl/ffi/summary.txt @@ -0,0 +1 @@ +Bindings to OpenCL diff --git a/extra/opencl/ffi/tags.txt b/extra/opencl/ffi/tags.txt new file mode 100644 index 0000000000..bb863cf9a0 --- /dev/null +++ b/extra/opencl/ffi/tags.txt @@ -0,0 +1 @@ +bindings diff --git a/extra/opencl/opencl-docs.factor b/extra/opencl/opencl-docs.factor new file mode 100644 index 0000000000..dc881e47c7 --- /dev/null +++ b/extra/opencl/opencl-docs.factor @@ -0,0 +1,246 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: help.markup help.syntax kernel quotations strings opencl.private +math byte-arrays alien ; +IN: opencl + +HELP: cl-addressing-mode +{ $values + { "sampler" cl-sampler } + { "addressing-mode" cl-addressing-mode } +} +{ $description "Returns the addressing mode of the given sampler." } ; + +HELP: cl-barrier +{ $description "Insert a synchronization barrier into the current command queue." } ; + +HELP: cl-barrier-events +{ $values + { "event/events" "a single event or sequence of events" } +} +{ $description "Insert a synchronization barrier for the specified events into the current command queue." } ; + +HELP: cl-buffer +{ $var-description "Tuple wrapper which will release the memory object handle when disposed." } ; + +HELP: cl-buffer-ptr +{ $var-description "A buffer and offset pair for specifying a starting point for a copy." } ; + +HELP: cl-buffer-range +{ $var-description "A buffer, offset and size triplet for specifying copy ranges." } ; + +HELP: cl-context +{ $var-description "Tuple wrapper which will release the context handle when disposed." } ; + +HELP: cl-current-context +{ $var-description "Symbol for the current cl-context tuple." } ; + +HELP: cl-current-device +{ $var-description "Symbol for the current cl-device tuple." } ; + +HELP: cl-current-queue +{ $var-description "Symbol for the current cl-queue tuple." } ; + +HELP: cl-device +{ $var-description "Tuple wrapper which will release the device handle when disposed." } ; + +HELP: cl-event +{ $var-description "Tuple wrapper which will release the event handle when disposed." } ; + +HELP: cl-event-status +{ $values + { "event" cl-event } + { "execution-status" cl-execution-status } +} +{ $description "Returns the current execution status of the operation represented by the event." } ; + +HELP: cl-event-type +{ $values + { "event" cl-event } + { "command-type" cl-execution-status } +} +{ $description "Returns the type of operation that created the event." } ; + +HELP: cl-filter-mode +{ $values + { "sampler" cl-sampler } + { "filter-mode" cl-filter-mode } +} +{ $description "Returns the filter mode of the sampler object." } ; + +HELP: cl-finish +{ $description "Flush the current command queue and wait till all operations are completed." } ; + +HELP: cl-flush +{ $description "Flush the current command queue to kick off pending operations." } ; + +HELP: cl-kernel +{ $var-description "Tuple wrapper which will release the kernel handle when disposed." } ; + +HELP: cl-kernel-arity +{ $values + { "kernel" cl-kernel } + { "arity" integer } +} +{ $description "Returns the number of inputs that this kernel function accepts." } ; + +HELP: cl-kernel-local-size +{ $values + { "kernel" cl-kernel } + { "size" integer } +} +{ $description "Returns the maximum size of a local work group for this kernel." } ; + +HELP: cl-kernel-name +{ $values + { "kernel" cl-kernel } + { "string" string } +} +{ $description "Returns the name of the kernel function." } ; + +HELP: cl-marker +{ $values + + { "event" cl-event } +} +{ $description "Inserts a marker into the current command queue." } ; + +HELP: cl-normalized-coords? +{ $values + { "sampler" cl-sampler } + { "?" boolean } +} +{ $description "Returns whether the sampler uses normalized coords or not." } ; + +HELP: cl-out-of-order-execution? +{ $values + { "command-queue" cl-queue } + { "?" boolean } +} +{ $description "Returns whether the given command queue allows out of order execution or not." } ; + +HELP: cl-platform +{ $var-description "Tuple summarizing the capabilities and devices of an OpenCL platform." } ; + +HELP: cl-platforms +{ $values + + { "platforms" "sequence of cl-platform"} +} +{ $description "Returns the platforms available for OpenCL computation on this hardware." } ; + +HELP: cl-profile-counters +{ $values + { "event" cl-event } + { "queued" integer } { "submitted" integer } { "started" integer } { "finished" integer } +} +{ $description "Returns the profiling counters for the operation represented by event." } ; + +HELP: cl-profiling? +{ $values + { "command-queue" cl-queue } + { "?" boolean } +} +{ $description "Returns true if the command queue allows profiling." } ; + +HELP: cl-program +{ $var-description "Tuple wrapper which will release the program handle when disposed." } ; + +HELP: cl-queue +{ $var-description "Tuple wrapper which will release the command queue handle when disposed." } ; + +HELP: cl-read-buffer +{ $values + { "buffer-range" cl-buffer-range } + { "byte-array" byte-array } +} +{ $description "Synchronously read a byte-array from the specified buffer location." } ; + +HELP: cl-sampler +{ $var-description "Tuple wrapper which will release the sampler handle when disposed." } ; + +HELP: cl-queue-copy-buffer +{ $values + { "src-buffer-ptr" cl-buffer-ptr } { "dst-buffer-ptr" cl-buffer-ptr } { "size" integer } { "dependent-events" "sequence of events" } + { "event" cl-event } +} +{ $description "Queue a copy operation from " { $snippet "src-buffer-ptr" } " to " { $snippet "dst-buffer-ptr" } ". Dependent events can be passed to order the operation relative to other operations." } ; + +HELP: cl-queue-kernel +{ $values + { "kernel" cl-kernel } { "args" "sequence of cl-buffer or byte-array" } { "sizes" "sequence of integers" } { "dependent-events" "sequence of events" } + { "event" cl-event } +} +{ $description "Queue a kernel for execution with the given arguments. The " { $snippet "sizes" } " argument specifies input array sizes for each dimension. Dependent events can be passed to order the operation relative to other operations." } ; + +HELP: cl-queue-read-buffer +{ $values + { "buffer-range" cl-buffer-range } { "alien" alien } { "dependent-events" "a sequence of events" } + { "event" cl-event } +} +{ $description "Queue a read operation from " { $snippet "buffer-range" } " to " { $snippet "alien" } ". Dependent events can be passed to order the operation relative to other operations." } ; + +HELP: cl-queue-write-buffer +{ $values + { "buffer-range" cl-buffer-range } { "alien" alien } { "dependent-events" "a sequence of events" } + { "event" cl-event } +} +{ $description "Queue a write operation from " { $snippet "alien" } " to " { $snippet "buffer-range" } ". Dependent events can be passed to order the operation relative to other operations." } ; + +HELP: cl-wait +{ $values + { "event/events" "a single event or sequence of events" } +} +{ $description "Synchronously wait for the events to complete." } ; + +HELP: cl-write-buffer +{ $values + { "buffer-range" cl-buffer-range } { "byte-array" byte-array } +} +{ $description "Synchronously write a byte-array to the specified buffer location." } ; + +HELP: +{ $values + { "options" string } { "strings" "sequence of source code strings" } + { "program" "compiled cl-program" } +} +{ $description "Compile the given source code and return a program object. A " { $link cl-error } " is thrown in the event of a compile error." } ; + +HELP: with-cl-state +{ $values + { "context/f" { $maybe cl-context } } { "device/f" { $maybe cl-device } } { "queue/f" { $maybe cl-queue } } { "quot" quotation } +} +{ $description "Run the specified quotation with the given context, device and command queue. False arguments are not bound." } ; + +ARTICLE: "opencl" "OpenCL" +"The " { $vocab-link "opencl" } " vocabulary provides high-level words for using OpenCL." +{ $subsections + cl-platforms + + with-cl-state +} +"Memory Objects:" +{ $subsections + + cl-queue-copy-buffer + cl-read-buffer + cl-queue-read-buffer + cl-write-buffer + cl-queue-write-buffer +} +"Programs and Kernels:" +{ $subsections + + +} + +"Running and Waiting for Completion:" +{ $subsections + cl-queue-kernel + cl-wait + cl-flush + cl-finish +} +; + +ABOUT: "opencl" diff --git a/extra/opencl/opencl-tests.factor b/extra/opencl/opencl-tests.factor new file mode 100644 index 0000000000..09bafa0264 --- /dev/null +++ b/extra/opencl/opencl-tests.factor @@ -0,0 +1,44 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: multiline locals io.encodings.ascii io.encodings.string sequences +math specialized-arrays alien.c-types math.order alien opencl tools.test +accessors arrays destructors kernel namespaces ; +FROM: alien.c-types => float ; +SPECIALIZED-ARRAY: float +IN: opencl.tests + +STRING: kernel-source +__kernel square( + __global float* input, + __global float* output, + const unsigned int count) +{ + int i = get_global_id(0); + if (i < count) + output[i] = input[i] * input[i]; +} +; + +:: opencl-square ( in -- out ) + [ + in byte-length :> num-bytes + in length :> num-floats + cl-platforms first devices>> first :> device + device 1array &dispose :> context + context device f f &dispose :> queue + + context device queue [ + "" kernel-source 1array &dispose "square" &dispose :> kernel + cl-read-access num-bytes in &dispose :> in-buffer + cl-write-access num-bytes f &dispose :> out-buffer + + kernel in-buffer out-buffer num-floats 3array + { num-floats } [ ] cl-queue-kernel &dispose drop + + cl-finish + out-buffer 0 num-bytes cl-read-buffer num-floats + ] with-cl-state + ] with-destructors ; + +[ float-array{ 1.0 4.0 9.0 16.0 100.0 } ] +[ float-array{ 1.0 2.0 3.0 4.0 10.0 } opencl-square ] unit-test diff --git a/extra/opencl/opencl.factor b/extra/opencl/opencl.factor new file mode 100644 index 0000000000..a32c5de3d1 --- /dev/null +++ b/extra/opencl/opencl.factor @@ -0,0 +1,572 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien alien.accessors alien.c-types arrays +byte-arrays combinators combinators.smart continuations destructors +fry io.encodings.ascii io.encodings.string kernel libc locals macros +math math.order multiline opencl.ffi prettyprint sequences +specialized-arrays typed variants namespaces ; +IN: opencl +SPECIALIZED-ARRAYS: void* char size_t ; + + _ '[ _ call cl-success ] keep + *size_t dup _ '[ f _ call cl-success ] keep + _ call ] ; + +MACRO: 2info ( info-quot lift-quot -- quot ) + [ dup ] dip '[ 3dup 0 f 0 _ '[ _ call cl-success ] keep + *size_t dup _ '[ f _ call cl-success ] keep + _ call ] ; + +: info-bool ( handle name quot -- ? ) + [ *uint CL_TRUE = ] info ; inline + +: info-ulong ( handle name quot -- ulong ) + [ *ulonglong ] info ; inline + +: info-int ( handle name quot -- int ) + [ *int ] info ; inline + +: info-uint ( handle name quot -- uint ) + [ *uint ] info ; inline + +: info-size_t ( handle name quot -- size_t ) + [ *size_t ] info ; inline + +: 2info-size_t ( handle1 handle2 name quot -- size_t ) + [ *size_t ] 2info ; inline + +: info-string ( handle name quot -- string ) + [ ascii decode 1 head* ] info ; inline + +: 2info-string ( handle name quot -- string ) + [ ascii decode 1 head* ] 2info ; inline + +: info-size_t-array ( handle name quot -- size_t-array ) + [ [ length size_t heap-size / ] keep swap ] info ; inline + +TUPLE: cl-handle < disposable handle ; +PRIVATE> + +VARIANT: cl-fp-feature + cl-denorm cl-inf-and-nan cl-round-to-nearest cl-round-to-zero cl-round-to-inf cl-fma ; + +VARIANT: cl-cache-type + cl-no-cache cl-read-only-cache cl-read-write-cache ; + +VARIANT: cl-buffer-access-mode + cl-read-access cl-write-access cl-read-write-access ; + +VARIANT: cl-image-channel-order + cl-channel-order-r cl-channel-order-a cl-channel-order-rg cl-channel-order-ra + cl-channel-order-rga cl-channel-order-rgba cl-channel-order-bgra cl-channel-order-argb + cl-channel-order-intensity cl-channel-order-luminance ; + +VARIANT: cl-image-channel-type + cl-channel-type-snorm-int8 cl-channel-type-snorm-int16 cl-channel-type-unorm-int8 + cl-channel-type-unorm-int16 cl-channel-type-unorm-short-565 + cl-channel-type-unorm-short-555 cl-channel-type-unorm-int-101010 + cl-channel-type-signed-int8 cl-channel-type-signed-int16 cl-channel-type-signed-int32 + cl-channel-type-unsigned-int8 cl-channel-type-unsigned-int16 + cl-channel-type-unsigned-int32 cl-channel-type-half-float cl-channel-type-float ; + +VARIANT: cl-addressing-mode + cl-repeat-addressing cl-clamp-to-edge-addressing cl-clamp-addressing cl-no-addressing ; + +VARIANT: cl-filter-mode + cl-filter-nearest cl-filter-linear ; + +VARIANT: cl-command-type + cl-ndrange-kernel-command cl-task-command cl-native-kernel-command cl-read-buffer-command + cl-write-buffer-command cl-copy-buffer-command cl-read-image-command cl-write-image-command + cl-copy-image-command cl-copy-buffer-to-image-command cl-copy-image-to-buffer-command + cl-map-buffer-command cl-map-image-command cl-unmap-mem-object-command + cl-marker-command cl-acquire-gl-objects-command cl-release-gl-objects-command ; + +VARIANT: cl-execution-status + cl-queued cl-submitted cl-running cl-complete cl-failure ; + +TUPLE: cl-platform + id profile version name vendor extensions devices ; + +TUPLE: cl-device + id type vendor-id max-compute-units max-work-item-dimensions + max-work-item-sizes max-work-group-size preferred-vector-width-char + preferred-vector-width-short preferred-vector-width-int + preferred-vector-width-long preferred-vector-width-float + preferred-vector-width-double max-clock-frequency address-bits + max-mem-alloc-size image-support max-read-image-args max-write-image-args + image2d-max-width image2d-max-height image3d-max-width image3d-max-height + image3d-max-depth max-samplers max-parameter-size mem-base-addr-align + min-data-type-align-size single-fp-config global-mem-cache-type + global-mem-cacheline-size global-mem-cache-size global-mem-size + max-constant-buffer-size max-constant-args local-mem? local-mem-size + error-correction-support profiling-timer-resolution endian-little + available compiler-available execute-kernels? execute-native-kernels? + out-of-order-exec-available? profiling-available? + name vendor driver-version profile version extensions ; + +TUPLE: cl-context < cl-handle ; +TUPLE: cl-queue < cl-handle ; +TUPLE: cl-buffer < cl-handle ; +TUPLE: cl-sampler < cl-handle ; +TUPLE: cl-program < cl-handle ; +TUPLE: cl-kernel < cl-handle ; +TUPLE: cl-event < cl-handle ; + +M: cl-context dispose* handle>> clReleaseContext cl-success ; +M: cl-queue dispose* handle>> clReleaseCommandQueue cl-success ; +M: cl-buffer dispose* handle>> clReleaseMemObject cl-success ; +M: cl-sampler dispose* handle>> clReleaseSampler cl-success ; +M: cl-program dispose* handle>> clReleaseProgram cl-success ; +M: cl-kernel dispose* handle>> clReleaseKernel cl-success ; +M: cl-event dispose* handle>> clReleaseEvent cl-success ; + +TUPLE: cl-buffer-ptr + { buffer cl-buffer read-only } + { offset integer read-only } ; +C: cl-buffer-ptr + +TUPLE: cl-buffer-range + { buffer cl-buffer read-only } + { offset integer read-only } + { size integer read-only } ; +C: cl-buffer-range + +SYMBOLS: cl-current-context cl-current-queue cl-current-device ; + +addressing-mode ( cl_addressing_mode -- addressing-mode ) + { + { CL_ADDRESS_REPEAT [ cl-repeat-addressing ] } + { CL_ADDRESS_CLAMP_TO_EDGE [ cl-clamp-to-edge-addressing ] } + { CL_ADDRESS_CLAMP [ cl-clamp-addressing ] } + { CL_ADDRESS_NONE [ cl-no-addressing ] } + } case ; + +: cl_filter_mode>filter-mode ( cl_filter_mode -- filter-mode ) + { + { CL_FILTER_LINEAR [ cl-filter-linear ] } + { CL_FILTER_NEAREST [ cl-filter-nearest ] } + } case ; + +: platform-info-string ( handle name -- string ) + [ clGetPlatformInfo ] info-string ; + +: platform-info ( id -- profile version name vendor extensions ) + { + [ CL_PLATFORM_PROFILE platform-info-string ] + [ CL_PLATFORM_VERSION platform-info-string ] + [ CL_PLATFORM_NAME platform-info-string ] + [ CL_PLATFORM_VENDOR platform-info-string ] + [ CL_PLATFORM_EXTENSIONS platform-info-string ] + } cleave ; + +: cl_device_fp_config>flags ( ulong -- sequence ) + [ { + [ CL_FP_DENORM bitand 0 = [ f ] [ cl-denorm ] if ] + [ CL_FP_INF_NAN bitand 0 = [ f ] [ cl-inf-and-nan ] if ] + [ CL_FP_ROUND_TO_NEAREST bitand 0 = [ f ] [ cl-round-to-nearest ] if ] + [ CL_FP_ROUND_TO_ZERO bitand 0 = [ f ] [ cl-round-to-zero ] if ] + [ CL_FP_ROUND_TO_INF bitand 0 = [ f ] [ cl-round-to-inf ] if ] + [ CL_FP_FMA bitand 0 = [ f ] [ cl-fma ] if ] + } cleave ] { } output>sequence sift ; + +: cl_device_mem_cache_type>cache-type ( uint -- cache-type ) + { + { CL_NONE [ cl-no-cache ] } + { CL_READ_ONLY_CACHE [ cl-read-only-cache ] } + { CL_READ_WRITE_CACHE [ cl-read-write-cache ] } + } case ; + +: device-info-bool ( handle name -- ? ) + [ clGetDeviceInfo ] info-bool ; + +: device-info-ulong ( handle name -- ulong ) + [ clGetDeviceInfo ] info-ulong ; + +: device-info-uint ( handle name -- uint ) + [ clGetDeviceInfo ] info-uint ; + +: device-info-string ( handle name -- string ) + [ clGetDeviceInfo ] info-string ; + +: device-info-size_t ( handle name -- size_t ) + [ clGetDeviceInfo ] info-size_t ; + +: device-info-size_t-array ( handle name -- size_t-array ) + [ clGetDeviceInfo ] info-size_t-array ; + +: device-info ( device-id -- device ) + dup { + [ CL_DEVICE_TYPE device-info-size_t ] + [ CL_DEVICE_VENDOR_ID device-info-uint ] + [ CL_DEVICE_MAX_COMPUTE_UNITS device-info-uint ] + [ CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS device-info-uint ] + [ CL_DEVICE_MAX_WORK_ITEM_SIZES device-info-size_t-array ] + [ CL_DEVICE_MAX_WORK_GROUP_SIZE device-info-size_t ] + [ CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR device-info-uint ] + [ CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT device-info-uint ] + [ CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT device-info-uint ] + [ CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG device-info-uint ] + [ CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT device-info-uint ] + [ CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE device-info-uint ] + [ CL_DEVICE_MAX_CLOCK_FREQUENCY device-info-uint ] + [ CL_DEVICE_ADDRESS_BITS device-info-uint ] + [ CL_DEVICE_MAX_MEM_ALLOC_SIZE device-info-ulong ] + [ CL_DEVICE_IMAGE_SUPPORT device-info-bool ] + [ CL_DEVICE_MAX_READ_IMAGE_ARGS device-info-uint ] + [ CL_DEVICE_MAX_WRITE_IMAGE_ARGS device-info-uint ] + [ CL_DEVICE_IMAGE2D_MAX_WIDTH device-info-size_t ] + [ CL_DEVICE_IMAGE2D_MAX_HEIGHT device-info-size_t ] + [ CL_DEVICE_IMAGE3D_MAX_WIDTH device-info-size_t ] + [ CL_DEVICE_IMAGE3D_MAX_HEIGHT device-info-size_t ] + [ CL_DEVICE_IMAGE3D_MAX_DEPTH device-info-size_t ] + [ CL_DEVICE_MAX_SAMPLERS device-info-uint ] + [ CL_DEVICE_MAX_PARAMETER_SIZE device-info-size_t ] + [ CL_DEVICE_MEM_BASE_ADDR_ALIGN device-info-uint ] + [ CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE device-info-uint ] + [ CL_DEVICE_SINGLE_FP_CONFIG device-info-ulong cl_device_fp_config>flags ] + [ CL_DEVICE_GLOBAL_MEM_CACHE_TYPE device-info-uint cl_device_mem_cache_type>cache-type ] + [ CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE device-info-uint ] + [ CL_DEVICE_GLOBAL_MEM_CACHE_SIZE device-info-ulong ] + [ CL_DEVICE_GLOBAL_MEM_SIZE device-info-ulong ] + [ CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE device-info-ulong ] + [ CL_DEVICE_MAX_CONSTANT_ARGS device-info-uint ] + [ CL_DEVICE_LOCAL_MEM_TYPE device-info-uint CL_LOCAL = ] + [ CL_DEVICE_LOCAL_MEM_SIZE device-info-ulong ] + [ CL_DEVICE_ERROR_CORRECTION_SUPPORT device-info-bool ] + [ CL_DEVICE_PROFILING_TIMER_RESOLUTION device-info-size_t ] + [ CL_DEVICE_ENDIAN_LITTLE device-info-bool ] + [ CL_DEVICE_AVAILABLE device-info-bool ] + [ CL_DEVICE_COMPILER_AVAILABLE device-info-bool ] + [ CL_DEVICE_EXECUTION_CAPABILITIES device-info-ulong CL_EXEC_KERNEL bitand 0 = not ] + [ CL_DEVICE_EXECUTION_CAPABILITIES device-info-ulong CL_EXEC_NATIVE_KERNEL bitand 0 = not ] + [ CL_DEVICE_QUEUE_PROPERTIES device-info-ulong CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE bitand 0 = not ] + [ CL_DEVICE_QUEUE_PROPERTIES device-info-ulong CL_QUEUE_PROFILING_ENABLE bitand 0 = not ] + [ CL_DEVICE_NAME device-info-string ] + [ CL_DEVICE_VENDOR device-info-string ] + [ CL_DRIVER_VERSION device-info-string ] + [ CL_DEVICE_PROFILE device-info-string ] + [ CL_DEVICE_VERSION device-info-string ] + [ CL_DEVICE_EXTENSIONS device-info-string ] + } cleave cl-device boa ; + +: platform-devices ( platform-id -- devices ) + CL_DEVICE_TYPE_ALL [ + 0 f 0 [ clGetDeviceIDs cl-success ] keep *uint + ] [ + rot dup [ f clGetDeviceIDs cl-success ] keep + ] 2bi ; + +: command-queue-info-ulong ( handle name -- ulong ) + [ clGetCommandQueueInfo ] info-ulong ; + +: sampler-info-bool ( handle name -- ? ) + [ clGetSamplerInfo ] info-bool ; + +: sampler-info-uint ( handle name -- uint ) + [ clGetSamplerInfo ] info-uint ; + +: program-build-info-string ( program-handle device-handle name -- string ) + [ clGetProgramBuildInfo ] 2info-string ; + +: program-build-log ( program-handle device-handle -- string ) + CL_PROGRAM_BUILD_LOG program-build-info-string ; + +: strings>char*-array ( strings -- char*-array ) + [ ascii encode dup length dup malloc [ cl-not-null ] + keep &free [ -rot memcpy ] keep ] void*-array{ } map-as ; + +: (program) ( cl-context sources -- program-handle ) + [ handle>> ] dip [ + [ length ] + [ strings>char*-array ] + [ [ length ] size_t-array{ } map-as ] tri + 0 [ clCreateProgramWithSource ] keep *int cl-success + ] with-destructors ; + +:: (build-program) ( program-handle device options -- program ) + program-handle 1 device 1array [ id>> ] void*-array{ } map-as + options ascii encode 0 suffix f f clBuildProgram :> rc + rc { + { CL_BUILD_PROGRAM_FAILURE [ + program-handle device id>> program-build-log program-handle + clReleaseProgram cl-success cl-error f ] } + { CL_SUCCESS [ cl-program new-disposable program-handle >>handle ] } + [ program-handle clReleaseProgram cl-success cl-success f ] + } case ; + +: kernel-info-string ( handle name -- string ) + [ clGetKernelInfo ] info-string ; + +: kernel-info-uint ( handle name -- uint ) + [ clGetKernelInfo ] info-uint ; + +: kernel-work-group-info-size_t ( handle1 handle2 name -- size_t ) + [ clGetKernelWorkGroupInfo ] 2info-size_t ; + +: event-info-uint ( handle name -- uint ) + [ clGetEventInfo ] info-uint ; + +: event-info-int ( handle name -- int ) + [ clGetEventInfo ] info-int ; + +: cl_command_type>command-type ( cl_command-type -- command-type ) + { + { CL_COMMAND_NDRANGE_KERNEL [ cl-ndrange-kernel-command ] } + { CL_COMMAND_TASK [ cl-task-command ] } + { CL_COMMAND_NATIVE_KERNEL [ cl-native-kernel-command ] } + { CL_COMMAND_READ_BUFFER [ cl-read-buffer-command ] } + { CL_COMMAND_WRITE_BUFFER [ cl-write-buffer-command ] } + { CL_COMMAND_COPY_BUFFER [ cl-copy-buffer-command ] } + { CL_COMMAND_READ_IMAGE [ cl-read-image-command ] } + { CL_COMMAND_WRITE_IMAGE [ cl-write-image-command ] } + { CL_COMMAND_COPY_IMAGE [ cl-copy-image-command ] } + { CL_COMMAND_COPY_BUFFER_TO_IMAGE [ cl-copy-buffer-to-image-command ] } + { CL_COMMAND_COPY_IMAGE_TO_BUFFER [ cl-copy-image-to-buffer-command ] } + { CL_COMMAND_MAP_BUFFER [ cl-map-buffer-command ] } + { CL_COMMAND_MAP_IMAGE [ cl-map-image-command ] } + { CL_COMMAND_UNMAP_MEM_OBJECT [ cl-unmap-mem-object-command ] } + { CL_COMMAND_MARKER [ cl-marker-command ] } + { CL_COMMAND_ACQUIRE_GL_OBJECTS [ cl-acquire-gl-objects-command ] } + { CL_COMMAND_RELEASE_GL_OBJECTS [ cl-release-gl-objects-command ] } + } case ; + +: cl_int>execution-status ( clint -- execution-status ) + { + { CL_QUEUED [ cl-queued ] } + { CL_SUBMITTED [ cl-submitted ] } + { CL_RUNNING [ cl-running ] } + { CL_COMPLETE [ cl-complete ] } + [ drop cl-failure ] + } case ; + +: profiling-info-ulong ( handle name -- ulong ) + [ clGetEventProfilingInfo ] info-ulong ; + + +: bind-kernel-arg-buffer ( kernel index buffer -- ) + [ handle>> ] [ cl_mem heap-size ] [ handle>> ] tri* + clSetKernelArg cl-success ; + +: bind-kernel-arg-data ( kernel index byte-array -- ) + [ handle>> ] 2dip + [ byte-length ] keep clSetKernelArg cl-success ; + +GENERIC: bind-kernel-arg ( kernel index data -- ) +M: cl-buffer bind-kernel-arg bind-kernel-arg-buffer ; +M: byte-array bind-kernel-arg bind-kernel-arg-data ; +PRIVATE> + +: with-cl-state ( context/f device/f queue/f quot -- ) + [ + [ + [ cl-current-queue set ] when* + [ cl-current-device set ] when* + [ cl-current-context set ] when* + ] 3curry H{ } make-assoc + ] dip bind ; inline + +: cl-platforms ( -- platforms ) + 0 f 0 [ clGetPlatformIDs cl-success ] keep *uint + dup [ f clGetPlatformIDs cl-success ] keep + [ + dup + [ platform-info ] + [ platform-devices [ device-info ] { } map-as ] bi + cl-platform boa + ] { } map-as ; + +: ( devices -- cl-context ) + [ f ] dip + [ length ] [ [ id>> ] void*-array{ } map-as ] bi + f f 0 [ clCreateContext ] keep *int cl-success + cl-context new-disposable swap >>handle ; + +: ( context device out-of-order? profiling? -- command-queue ) + [ [ handle>> ] [ id>> ] bi* ] 2dip + [ [ CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE ] [ 0 ] if ] + [ [ CL_QUEUE_PROFILING_ENABLE ] [ 0 ] if ] bi* bitor + 0 [ clCreateCommandQueue ] keep *int cl-success + cl-queue new-disposable swap >>handle ; + +: cl-out-of-order-execution? ( command-queue -- ? ) + CL_QUEUE_PROPERTIES command-queue-info-ulong + CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE bitand 0 = not ; + +: cl-profiling? ( command-queue -- ? ) + CL_QUEUE_PROPERTIES command-queue-info-ulong + CL_QUEUE_PROFILING_ENABLE bitand 0 = not ; + +: ( buffer-access-mode size initial-data -- buffer ) + [ (current-cl-context) ] 3dip + swap over [ + [ handle>> ] + [ buffer-access-constant ] + [ [ CL_MEM_COPY_HOST_PTR ] [ CL_MEM_ALLOC_HOST_PTR ] if ] tri* bitor + ] 2dip + 0 [ clCreateBuffer ] keep *int cl-success + cl-buffer new-disposable swap >>handle ; + +: cl-read-buffer ( buffer-range -- byte-array ) + [ (current-cl-queue) handle>> ] dip + [ buffer>> handle>> CL_TRUE ] + [ offset>> ] + [ size>> dup ] tri + [ 0 f f clEnqueueReadBuffer cl-success ] keep ; inline + +: cl-write-buffer ( buffer-range byte-array -- ) + [ + [ (current-cl-queue) handle>> ] dip + [ buffer>> handle>> CL_TRUE ] + [ offset>> ] + [ size>> ] tri + ] dip 0 f f clEnqueueWriteBuffer cl-success ; inline + +: cl-queue-copy-buffer ( src-buffer-ptr dst-buffer-ptr size dependent-events -- event ) + [ + (current-cl-queue) + [ handle>> ] + [ [ buffer>> handle>> ] [ offset>> ] bi ] + [ [ buffer>> handle>> ] [ offset>> ] bi ] + tri* swapd + ] 2dip [ length ] keep [ f ] [ [ handle>> ] void*-array{ } map-as ] if-empty + f [ clEnqueueCopyBuffer cl-success ] keep *void* cl-event + new-disposable swap >>handle ; + +: cl-queue-read-buffer ( buffer-range alien dependent-events -- event ) + [ + [ (current-cl-queue) handle>> ] dip + [ buffer>> handle>> CL_FALSE ] [ offset>> ] [ size>> ] tri + ] 2dip [ length ] keep [ f ] [ [ handle>> ] void*-array{ } map-as ] if-empty + f [ clEnqueueReadBuffer cl-success ] keep *void* cl-event + new-disposable swap >>handle ; + +: cl-queue-write-buffer ( buffer-range alien dependent-events -- event ) + [ + [ (current-cl-queue) handle>> ] dip + [ buffer>> handle>> CL_FALSE ] [ offset>> ] [ size>> ] tri + ] 2dip [ length ] keep [ f ] [ [ handle>> ] void*-array{ } map-as ] if-empty + f [ clEnqueueWriteBuffer cl-success ] keep *void* cl-event + new-disposable swap >>handle ; + +: ( normalized-coords? addressing-mode filter-mode -- sampler ) + [ (current-cl-context) ] 3dip + [ [ CL_TRUE ] [ CL_FALSE ] if ] + [ addressing-mode-constant ] + [ filter-mode-constant ] + tri* 0 [ clCreateSampler ] keep *int cl-success + cl-sampler new-disposable swap >>handle ; + +: cl-normalized-coords? ( sampler -- ? ) + handle>> CL_SAMPLER_NORMALIZED_COORDS sampler-info-bool ; + +: cl-addressing-mode ( sampler -- addressing-mode ) + handle>> CL_SAMPLER_ADDRESSING_MODE sampler-info-uint cl_addressing_mode>addressing-mode ; + +: cl-filter-mode ( sampler -- filter-mode ) + handle>> CL_SAMPLER_FILTER_MODE sampler-info-uint cl_filter_mode>filter-mode ; + +: ( options strings -- program ) + [ (current-cl-device) ] 2dip + [ (current-cl-context) ] dip + (program) -rot (build-program) ; + +: ( program kernel-name -- kernel ) + [ handle>> ] [ ascii encode 0 suffix ] bi* + 0 [ clCreateKernel ] keep *int cl-success + cl-kernel new-disposable swap >>handle ; + +: cl-kernel-name ( kernel -- string ) + handle>> CL_KERNEL_FUNCTION_NAME kernel-info-string ; + +: cl-kernel-arity ( kernel -- arity ) + handle>> CL_KERNEL_NUM_ARGS kernel-info-uint ; + +: cl-kernel-local-size ( kernel -- size ) + (current-cl-device) [ handle>> ] bi@ CL_KERNEL_WORK_GROUP_SIZE kernel-work-group-info-size_t ; + +:: cl-queue-kernel ( kernel args sizes dependent-events -- event ) + args [| arg idx | kernel idx arg bind-kernel-arg ] each-index + (current-cl-queue) handle>> + kernel handle>> + sizes [ length f ] [ [ ] size_t-array{ } map-as f ] bi + dependent-events [ length ] [ [ f ] [ [ handle>> ] void*-array{ } map-as ] if-empty ] bi + f [ clEnqueueNDRangeKernel cl-success ] keep *void* + cl-event new-disposable swap >>handle ; + +: cl-event-type ( event -- command-type ) + handle>> CL_EVENT_COMMAND_TYPE event-info-uint cl_command_type>command-type ; + +: cl-event-status ( event -- execution-status ) + handle>> CL_EVENT_COMMAND_EXECUTION_STATUS event-info-int cl_int>execution-status ; + +: cl-profile-counters ( event -- queued submitted started finished ) + handle>> { + [ CL_PROFILING_COMMAND_QUEUED profiling-info-ulong ] + [ CL_PROFILING_COMMAND_SUBMIT profiling-info-ulong ] + [ CL_PROFILING_COMMAND_START profiling-info-ulong ] + [ CL_PROFILING_COMMAND_END profiling-info-ulong ] + } cleave ; inline + +: cl-barrier-events ( event/events -- ) + [ (current-cl-queue) handle>> ] dip + dup sequence? [ 1array ] unless + [ handle>> ] void*-array{ } map-as [ length ] keep clEnqueueWaitForEvents cl-success ; inline + +: cl-marker ( -- event ) + (current-cl-queue) + f [ clEnqueueMarker cl-success ] keep *void* cl-event new-disposable + swap >>handle ; inline + +: cl-barrier ( -- ) + (current-cl-queue) clEnqueueBarrier cl-success ; inline + +: cl-flush ( -- ) + (current-cl-queue) handle>> clFlush cl-success ; inline + +: cl-wait ( event/events -- ) + dup sequence? [ 1array ] unless + [ handle>> ] void*-array{ } map-as [ length ] keep clWaitForEvents cl-success ; inline + +: cl-finish ( -- ) + (current-cl-queue) handle>> clFinish cl-success ; inline diff --git a/extra/opencl/summary.txt b/extra/opencl/summary.txt new file mode 100644 index 0000000000..ccb14a0dee --- /dev/null +++ b/extra/opencl/summary.txt @@ -0,0 +1 @@ +High-level vocabulary for using OpenCL diff --git a/extra/opencl/syntax/authors.txt b/extra/opencl/syntax/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/extra/opencl/syntax/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/extra/opencl/syntax/syntax.factor b/extra/opencl/syntax/syntax.factor new file mode 100644 index 0000000000..e9dbabd7fc --- /dev/null +++ b/extra/opencl/syntax/syntax.factor @@ -0,0 +1,8 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: classes.parser classes.singleton classes.union kernel lexer +sequences ; +IN: opencl.syntax + +SYNTAX: SINGLETONS-UNION: + CREATE-CLASS ";" parse-tokens [ create-class-in [ define-singleton-class ] keep ] map define-union-class ; diff --git a/extra/opencl/tags.txt b/extra/opencl/tags.txt new file mode 100644 index 0000000000..bb863cf9a0 --- /dev/null +++ b/extra/opencl/tags.txt @@ -0,0 +1 @@ +bindings From a0ac5a16c3579282dc0fac0a81cb0fef162a0aa7 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Wed, 3 Mar 2010 00:03:44 -0800 Subject: [PATCH 313/713] Update tags.txt files for Windows DDK --- basis/windows/ddk/hid/tags.txt | 2 +- basis/windows/ddk/setupapi/tags.txt | 2 +- basis/windows/ddk/winusb/tags.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/basis/windows/ddk/hid/tags.txt b/basis/windows/ddk/hid/tags.txt index fdce1614de..024277a9b2 100644 --- a/basis/windows/ddk/hid/tags.txt +++ b/basis/windows/ddk/hid/tags.txt @@ -1 +1 @@ -unportable bindings \ No newline at end of file +bindings diff --git a/basis/windows/ddk/setupapi/tags.txt b/basis/windows/ddk/setupapi/tags.txt index 25fe231655..024277a9b2 100644 --- a/basis/windows/ddk/setupapi/tags.txt +++ b/basis/windows/ddk/setupapi/tags.txt @@ -1 +1 @@ -unportable bindings +bindings diff --git a/basis/windows/ddk/winusb/tags.txt b/basis/windows/ddk/winusb/tags.txt index ee46b6bc1f..bb863cf9a0 100644 --- a/basis/windows/ddk/winusb/tags.txt +++ b/basis/windows/ddk/winusb/tags.txt @@ -1 +1 @@ -unportable bindings +bindings From 950f268bad9d9a0536442ddf52315bf956db9488 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Wed, 3 Mar 2010 02:06:58 -0800 Subject: [PATCH 314/713] Get OpenCL unit tests passing on Win7/NVidia. --- extra/opencl/ffi/ffi-tests.factor | 14 ++--- extra/opencl/ffi/ffi.factor | 26 ++++----- extra/opencl/opencl-tests.factor | 2 +- extra/opencl/opencl.factor | 95 +++++++++++++++++-------------- 4 files changed, 74 insertions(+), 63 deletions(-) diff --git a/extra/opencl/ffi/ffi-tests.factor b/extra/opencl/ffi/ffi-tests.factor index 44bb49ce4e..1ec96e4c76 100644 --- a/extra/opencl/ffi/ffi-tests.factor +++ b/extra/opencl/ffi/ffi-tests.factor @@ -4,11 +4,11 @@ USING: tools.test opencl.ffi multiline locals kernel io.encodings.ascii io.encodings.string sequences libc alien.c-types destructors math specialized-arrays math.order alien ; FROM: alien.c-types => float ; -SPECIALIZED-ARRAY: float +SPECIALIZED-ARRAYS: float void* ; IN: opencl.ffi.tests STRING: kernel-source -__kernel square( +__kernel void square( __global float* input, __global float* output, const unsigned int count) @@ -28,8 +28,10 @@ ERROR: cl-error err ; str-buffer length malloc &free :> str-alien str-alien str-buffer dup length memcpy str-alien ; -:: opencl-square ( in type -- out ) - f CL_DEVICE_TYPE_CPU 1 f [ f clGetDeviceIDs cl-success ] keep *void* :> device-id +:: opencl-square ( in -- out ) + 0 f 0 [ clGetPlatformIDs cl-success ] keep *uint + dup [ f clGetPlatformIDs cl-success ] keep first + CL_DEVICE_TYPE_DEFAULT 1 f [ f clGetDeviceIDs cl-success ] keep *void* :> device-id f 1 device-id f f 0 [ clCreateContext ] keep *int cl-success :> context context device-id 0 0 [ clCreateCommandQueue ] keep *int cl-success :> queue @@ -69,6 +71,4 @@ ERROR: cl-error err ; context clReleaseContext cl-success ; [ float-array{ 1.0 4.0 9.0 16.0 100.0 } ] -[ float-array{ 1.0 2.0 3.0 4.0 10.0 } CL_DEVICE_TYPE_CPU opencl-square ] unit-test -[ float-array{ 1.0 4.0 9.0 16.0 100.0 } ] -[ float-array{ 1.0 2.0 3.0 4.0 10.0 } CL_DEVICE_TYPE_GPU opencl-square ] unit-test +[ float-array{ 1.0 2.0 3.0 4.0 10.0 } opencl-square ] unit-test diff --git a/extra/opencl/ffi/ffi.factor b/extra/opencl/ffi/ffi.factor index 36f1c13519..b1fff5a008 100644 --- a/extra/opencl/ffi/ffi.factor +++ b/extra/opencl/ffi/ffi.factor @@ -1,28 +1,28 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. USING: alien.c-types alien.libraries alien.syntax classes.struct -combinators system unix.types alien.accessors byte-arrays kernel ; +combinators system alien.accessors byte-arrays kernel ; IN: opencl.ffi << "opencl" { - { [ os windows? ] [ "OpenCL32.dll" ] } + { [ os windows? ] [ "OpenCL.dll" ] } { [ os macosx? ] [ "/System/Library/Frameworks/OpenCL.framework/OpenCL" ] } { [ os unix? ] [ "libopencl.so" ] } } cond "stdcall" add-library >> LIBRARY: opencl ! cl_platform.h -TYPEDEF: int8_t cl_char -TYPEDEF: uint8_t cl_uchar -TYPEDEF: int16_t cl_short -TYPEDEF: uint16_t cl_ushort -TYPEDEF: int32_t cl_int -TYPEDEF: uint32_t cl_uint -TYPEDEF: int64_t cl_long -TYPEDEF: uint64_t cl_ulong -TYPEDEF: uint16_t cl_half; -TYPEDEF: float cl_float; -TYPEDEF: double cl_double; +TYPEDEF: char cl_char +TYPEDEF: uchar cl_uchar +TYPEDEF: short cl_short +TYPEDEF: ushort cl_ushort +TYPEDEF: int cl_int +TYPEDEF: uint cl_uint +TYPEDEF: longlong cl_long +TYPEDEF: ulonglong cl_ulong +TYPEDEF: ushort cl_half; +TYPEDEF: float cl_float; +TYPEDEF: double cl_double; CONSTANT: CL_CHAR_BIT 8 CONSTANT: CL_SCHAR_MAX 127 diff --git a/extra/opencl/opencl-tests.factor b/extra/opencl/opencl-tests.factor index 09bafa0264..6fd7bb581d 100644 --- a/extra/opencl/opencl-tests.factor +++ b/extra/opencl/opencl-tests.factor @@ -8,7 +8,7 @@ SPECIALIZED-ARRAY: float IN: opencl.tests STRING: kernel-source -__kernel square( +__kernel void square( __global float* input, __global float* output, const unsigned int count) diff --git a/extra/opencl/opencl.factor b/extra/opencl/opencl.factor index a32c5de3d1..ddcf16a3b2 100644 --- a/extra/opencl/opencl.factor +++ b/extra/opencl/opencl.factor @@ -12,10 +12,10 @@ SPECIALIZED-ARRAYS: void* char size_t ; ERROR: cl-error err ; : cl-success ( err -- ) - dup CL_SUCCESS = [ drop ] [ cl-error ] if ; + dup CL_SUCCESS = [ drop ] [ cl-error ] if ; inline : cl-not-null ( err -- ) - dup f = [ cl-error ] [ drop ] if ; + dup f = [ cl-error ] [ drop ] if ; inline MACRO: info ( info-quot lift-quot -- quot ) [ dup ] dip '[ 2dup 0 f 0 _ '[ _ call cl-success ] keep @@ -57,6 +57,17 @@ MACRO: 2info ( info-quot lift-quot -- quot ) TUPLE: cl-handle < disposable handle ; PRIVATE> +VARIANT: cl-device-type + cl-device-default cl-device-cpu cl-device-gpu cl-device-accelerator ; + +: size_t>cl-device-type ( size_t -- cl-device-type ) + { + { CL_DEVICE_TYPE_DEFAULT [ cl-device-default ] } + { CL_DEVICE_TYPE_CPU [ cl-device-cpu ] } + { CL_DEVICE_TYPE_GPU [ cl-device-gpu ] } + { CL_DEVICE_TYPE_ACCELERATOR [ cl-device-accelerator ] } + } case ; inline + VARIANT: cl-fp-feature cl-denorm cl-inf-and-nan cl-round-to-nearest cl-round-to-zero cl-round-to-inf cl-fma ; @@ -180,16 +191,16 @@ M: cl-filter-linear filter-mode-constant drop CL_FILTER_LINEAR ; { CL_ADDRESS_CLAMP_TO_EDGE [ cl-clamp-to-edge-addressing ] } { CL_ADDRESS_CLAMP [ cl-clamp-addressing ] } { CL_ADDRESS_NONE [ cl-no-addressing ] } - } case ; + } case ; inline : cl_filter_mode>filter-mode ( cl_filter_mode -- filter-mode ) { { CL_FILTER_LINEAR [ cl-filter-linear ] } { CL_FILTER_NEAREST [ cl-filter-nearest ] } - } case ; + } case ; inline : platform-info-string ( handle name -- string ) - [ clGetPlatformInfo ] info-string ; + [ clGetPlatformInfo ] info-string ; inline : platform-info ( id -- profile version name vendor extensions ) { @@ -215,29 +226,29 @@ M: cl-filter-linear filter-mode-constant drop CL_FILTER_LINEAR ; { CL_NONE [ cl-no-cache ] } { CL_READ_ONLY_CACHE [ cl-read-only-cache ] } { CL_READ_WRITE_CACHE [ cl-read-write-cache ] } - } case ; + } case ; inline : device-info-bool ( handle name -- ? ) - [ clGetDeviceInfo ] info-bool ; + [ clGetDeviceInfo ] info-bool ; inline : device-info-ulong ( handle name -- ulong ) - [ clGetDeviceInfo ] info-ulong ; + [ clGetDeviceInfo ] info-ulong ; inline : device-info-uint ( handle name -- uint ) - [ clGetDeviceInfo ] info-uint ; + [ clGetDeviceInfo ] info-uint ; inline : device-info-string ( handle name -- string ) - [ clGetDeviceInfo ] info-string ; + [ clGetDeviceInfo ] info-string ; inline : device-info-size_t ( handle name -- size_t ) - [ clGetDeviceInfo ] info-size_t ; + [ clGetDeviceInfo ] info-size_t ; inline : device-info-size_t-array ( handle name -- size_t-array ) - [ clGetDeviceInfo ] info-size_t-array ; + [ clGetDeviceInfo ] info-size_t-array ; inline : device-info ( device-id -- device ) dup { - [ CL_DEVICE_TYPE device-info-size_t ] + [ CL_DEVICE_TYPE device-info-size_t size_t>cl-device-type ] [ CL_DEVICE_VENDOR_ID device-info-uint ] [ CL_DEVICE_MAX_COMPUTE_UNITS device-info-uint ] [ CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS device-info-uint ] @@ -295,26 +306,26 @@ M: cl-filter-linear filter-mode-constant drop CL_FILTER_LINEAR ; 0 f 0 [ clGetDeviceIDs cl-success ] keep *uint ] [ rot dup [ f clGetDeviceIDs cl-success ] keep - ] 2bi ; + ] 2bi ; inline : command-queue-info-ulong ( handle name -- ulong ) - [ clGetCommandQueueInfo ] info-ulong ; + [ clGetCommandQueueInfo ] info-ulong ; inline : sampler-info-bool ( handle name -- ? ) - [ clGetSamplerInfo ] info-bool ; + [ clGetSamplerInfo ] info-bool ; inline : sampler-info-uint ( handle name -- uint ) - [ clGetSamplerInfo ] info-uint ; + [ clGetSamplerInfo ] info-uint ; inline : program-build-info-string ( program-handle device-handle name -- string ) - [ clGetProgramBuildInfo ] 2info-string ; + [ clGetProgramBuildInfo ] 2info-string ; inline : program-build-log ( program-handle device-handle -- string ) - CL_PROGRAM_BUILD_LOG program-build-info-string ; + CL_PROGRAM_BUILD_LOG program-build-info-string ; inline : strings>char*-array ( strings -- char*-array ) [ ascii encode dup length dup malloc [ cl-not-null ] - keep &free [ -rot memcpy ] keep ] void*-array{ } map-as ; + keep &free [ -rot memcpy ] keep ] void*-array{ } map-as ; inline : (program) ( cl-context sources -- program-handle ) [ handle>> ] dip [ @@ -326,8 +337,8 @@ M: cl-filter-linear filter-mode-constant drop CL_FILTER_LINEAR ; :: (build-program) ( program-handle device options -- program ) program-handle 1 device 1array [ id>> ] void*-array{ } map-as - options ascii encode 0 suffix f f clBuildProgram :> rc - rc { + options ascii encode 0 suffix f f clBuildProgram + { { CL_BUILD_PROGRAM_FAILURE [ program-handle device id>> program-build-log program-handle clReleaseProgram cl-success cl-error f ] } @@ -336,19 +347,19 @@ M: cl-filter-linear filter-mode-constant drop CL_FILTER_LINEAR ; } case ; : kernel-info-string ( handle name -- string ) - [ clGetKernelInfo ] info-string ; + [ clGetKernelInfo ] info-string ; inline : kernel-info-uint ( handle name -- uint ) - [ clGetKernelInfo ] info-uint ; + [ clGetKernelInfo ] info-uint ; inline : kernel-work-group-info-size_t ( handle1 handle2 name -- size_t ) - [ clGetKernelWorkGroupInfo ] 2info-size_t ; + [ clGetKernelWorkGroupInfo ] 2info-size_t ; inline : event-info-uint ( handle name -- uint ) - [ clGetEventInfo ] info-uint ; + [ clGetEventInfo ] info-uint ; inline : event-info-int ( handle name -- int ) - [ clGetEventInfo ] info-int ; + [ clGetEventInfo ] info-int ; inline : cl_command_type>command-type ( cl_command-type -- command-type ) { @@ -378,19 +389,19 @@ M: cl-filter-linear filter-mode-constant drop CL_FILTER_LINEAR ; { CL_RUNNING [ cl-running ] } { CL_COMPLETE [ cl-complete ] } [ drop cl-failure ] - } case ; + } case ; inline : profiling-info-ulong ( handle name -- ulong ) - [ clGetEventProfilingInfo ] info-ulong ; + [ clGetEventProfilingInfo ] info-ulong ; inline : bind-kernel-arg-buffer ( kernel index buffer -- ) [ handle>> ] [ cl_mem heap-size ] [ handle>> ] tri* - clSetKernelArg cl-success ; + clSetKernelArg cl-success ; inline : bind-kernel-arg-data ( kernel index byte-array -- ) [ handle>> ] 2dip - [ byte-length ] keep clSetKernelArg cl-success ; + [ byte-length ] keep clSetKernelArg cl-success ; inline GENERIC: bind-kernel-arg ( kernel index data -- ) M: cl-buffer bind-kernel-arg bind-kernel-arg-buffer ; @@ -431,11 +442,11 @@ PRIVATE> : cl-out-of-order-execution? ( command-queue -- ? ) CL_QUEUE_PROPERTIES command-queue-info-ulong - CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE bitand 0 = not ; + CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE bitand 0 = not ; inline : cl-profiling? ( command-queue -- ? ) CL_QUEUE_PROPERTIES command-queue-info-ulong - CL_QUEUE_PROFILING_ENABLE bitand 0 = not ; + CL_QUEUE_PROFILING_ENABLE bitand 0 = not ; inline : ( buffer-access-mode size initial-data -- buffer ) [ (current-cl-context) ] 3dip @@ -498,13 +509,13 @@ PRIVATE> cl-sampler new-disposable swap >>handle ; : cl-normalized-coords? ( sampler -- ? ) - handle>> CL_SAMPLER_NORMALIZED_COORDS sampler-info-bool ; + handle>> CL_SAMPLER_NORMALIZED_COORDS sampler-info-bool ; inline : cl-addressing-mode ( sampler -- addressing-mode ) - handle>> CL_SAMPLER_ADDRESSING_MODE sampler-info-uint cl_addressing_mode>addressing-mode ; + handle>> CL_SAMPLER_ADDRESSING_MODE sampler-info-uint cl_addressing_mode>addressing-mode ; inline : cl-filter-mode ( sampler -- filter-mode ) - handle>> CL_SAMPLER_FILTER_MODE sampler-info-uint cl_filter_mode>filter-mode ; + handle>> CL_SAMPLER_FILTER_MODE sampler-info-uint cl_filter_mode>filter-mode ; inline : ( options strings -- program ) [ (current-cl-device) ] 2dip @@ -514,16 +525,16 @@ PRIVATE> : ( program kernel-name -- kernel ) [ handle>> ] [ ascii encode 0 suffix ] bi* 0 [ clCreateKernel ] keep *int cl-success - cl-kernel new-disposable swap >>handle ; + cl-kernel new-disposable swap >>handle ; inline : cl-kernel-name ( kernel -- string ) - handle>> CL_KERNEL_FUNCTION_NAME kernel-info-string ; + handle>> CL_KERNEL_FUNCTION_NAME kernel-info-string ; inline : cl-kernel-arity ( kernel -- arity ) - handle>> CL_KERNEL_NUM_ARGS kernel-info-uint ; + handle>> CL_KERNEL_NUM_ARGS kernel-info-uint ; inline : cl-kernel-local-size ( kernel -- size ) - (current-cl-device) [ handle>> ] bi@ CL_KERNEL_WORK_GROUP_SIZE kernel-work-group-info-size_t ; + (current-cl-device) [ handle>> ] bi@ CL_KERNEL_WORK_GROUP_SIZE kernel-work-group-info-size_t ; inline :: cl-queue-kernel ( kernel args sizes dependent-events -- event ) args [| arg idx | kernel idx arg bind-kernel-arg ] each-index @@ -535,10 +546,10 @@ PRIVATE> cl-event new-disposable swap >>handle ; : cl-event-type ( event -- command-type ) - handle>> CL_EVENT_COMMAND_TYPE event-info-uint cl_command_type>command-type ; + handle>> CL_EVENT_COMMAND_TYPE event-info-uint cl_command_type>command-type ; inline : cl-event-status ( event -- execution-status ) - handle>> CL_EVENT_COMMAND_EXECUTION_STATUS event-info-int cl_int>execution-status ; + handle>> CL_EVENT_COMMAND_EXECUTION_STATUS event-info-int cl_int>execution-status ; inline : cl-profile-counters ( event -- queued submitted started finished ) handle>> { From 23de2811861c629d29dbbe2ecc7feac564659334 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 4 Mar 2010 19:30:08 -0800 Subject: [PATCH 315/713] initial implementation of row-polymorphism check --- basis/stack-checker/errors/errors.factor | 9 +- basis/stack-checker/inlining/inlining.factor | 4 +- .../row-polymorphism-tests.factor | 96 ++++++++++++++++ .../row-polymorphism/row-polymorphism.factor | 103 ++++++++++++++++++ 4 files changed, 210 insertions(+), 2 deletions(-) create mode 100644 basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor create mode 100644 basis/stack-checker/row-polymorphism/row-polymorphism.factor diff --git a/basis/stack-checker/errors/errors.factor b/basis/stack-checker/errors/errors.factor index ff06b2ac27..fbb8515a07 100644 --- a/basis/stack-checker/errors/errors.factor +++ b/basis/stack-checker/errors/errors.factor @@ -32,4 +32,11 @@ ERROR: inconsistent-recursive-call-error < inference-error word ; ERROR: transform-expansion-error < inference-error error continuation word ; -ERROR: bad-declaration-error < inference-error declaration ; \ No newline at end of file +ERROR: bad-declaration-error < inference-error declaration ; + +ERROR: invalid-quotation-input < inference-error branches quots ; + +ERROR: invalid-effect-variable < inference-error effect ; + +ERROR: effect-variable-can't-have-type < inference-error effect ; + diff --git a/basis/stack-checker/inlining/inlining.factor b/basis/stack-checker/inlining/inlining.factor index 4197aa00a2..b1d6b6d9ef 100644 --- a/basis/stack-checker/inlining/inlining.factor +++ b/basis/stack-checker/inlining/inlining.factor @@ -11,6 +11,7 @@ stack-checker.backend stack-checker.branches stack-checker.known-words stack-checker.dependencies +stack-checker.row-polymorphism stack-checker.recursive-state ; IN: stack-checker.inlining @@ -141,6 +142,7 @@ SYMBOL: enter-out : inline-word ( word -- ) commit-literals [ depends-on-definition ] + [ infer-polymorphic? get [ check-polymorphic-effect ] [ drop ] if ] [ dup inline-recursive-label [ call-recursive-inline-word @@ -150,7 +152,7 @@ SYMBOL: enter-out [ dup infer-inline-word-def ] if ] if* - ] bi ; + ] tri ; M: word apply-object dup inline? [ inline-word ] [ non-inline-word ] if ; diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor new file mode 100644 index 0000000000..39c9a2c13a --- /dev/null +++ b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor @@ -0,0 +1,96 @@ +! (c)2010 Joe Groff bsd license +USING: effects fry io kernel math namespaces sequences +system tools.test +stack-checker.backend +stack-checker.errors +stack-checker.row-polymorphism +stack-checker.values ; +IN: stack-checker.row-polymorphism.tests + +[ 3 f ] [ (( a b c -- d )) in-effect-variable ] unit-test +[ 0 f ] [ (( -- d )) in-effect-variable ] unit-test +[ 2 "a" ] [ (( ..a b c -- d )) in-effect-variable ] unit-test +[ (( a ..b c -- d )) in-effect-variable ] [ invalid-effect-variable? ] must-fail-with +[ (( ..a: integer b c -- d )) in-effect-variable ] [ effect-variable-can't-have-type? ] must-fail-with + +: checked-each ( ..a seq quot: ( ..a x -- ..a ) -- ..a ) + curry call ; inline + +: checked-map ( ..a seq quot: ( ..a x -- ..a y ) -- ..a seq' ) + curry call f ; inline + +: checked-map-index ( ..a seq quot: ( ..a x index -- ..a y ) -- ..a seq' ) + 0 swap 2curry call f ; inline + +: checked-if ( ..a x then: ( ..a -- ..b ) else: ( ..a -- ..b ) -- ..b ) + drop nip call ; inline + +: checked-if* ( ..a x then: ( ..a x -- ..b ) else: ( ..a -- ..b ) -- ..b ) + drop call ; inline + +: checked-with-variable ( ..a value key quot: ( ..a -- ..b ) -- ..b ) + 2nip call ; inline + +: infer-polymorphic-quot ( quot -- vars ) + t infer-polymorphic? [ + unclip-last [ + dup current-word set + init-inference + init-known-values + [ [ [ set-known ] [ push-d ] bi ] each ] + [ stack-effect ] bi* + infer-polymorphic-vars + ] with-scope + ] with-variable ; + +: test-poly-infer ( effect quot -- ) + [ '[ _ ] ] [ '[ _ infer-polymorphic-quot ] ] bi* unit-test ; inline + +: poly-infer-must-fail ( quot -- ) + '[ _ infer-polymorphic-quot ] [ invalid-quotation-input? ] must-fail-with ; inline + +H{ { "a" 0 } } [ [ write ] checked-each ] test-poly-infer +H{ { "a" 1 } } [ [ append ] checked-each ] test-poly-infer +H{ { "a" 0 } } [ [ ] checked-map ] test-poly-infer +H{ { "a" 0 } } [ [ reverse ] checked-map ] test-poly-infer +H{ { "a" 1 } } [ [ append dup ] checked-map ] test-poly-infer +H{ { "a" 1 } } [ [ swap nth suffix dup ] checked-map-index ] test-poly-infer + +H{ { "a" 3 } { "b" 1 } } [ [ 2drop ] [ 2nip ] checked-if ] test-poly-infer +H{ { "a" 2 } { "b" 3 } } [ [ dup ] [ over ] checked-if ] test-poly-infer +H{ { "a" 0 } { "b" 1 } } [ [ os ] [ cpu ] checked-if ] test-poly-infer +H{ { "a" 1 } { "b" 2 } } [ [ os ] [ 1 + cpu ] checked-if ] test-poly-infer + +H{ { "a" 0 } { "b" 0 } } [ [ write ] [ "(f)" write ] checked-if* ] test-poly-infer +H{ { "a" 0 } { "b" 1 } } [ [ ] [ f ] checked-if* ] test-poly-infer +H{ { "a" 1 } { "b" 1 } } [ [ nip ] [ drop f ] checked-if* ] test-poly-infer +H{ { "a" 1 } { "b" 1 } } [ [ nip ] [ ] checked-if* ] test-poly-infer +H{ { "a" 2 } { "b" 2 } } [ [ 3append f ] [ ] checked-if* ] test-poly-infer +H{ { "a" 0 } { "b" 0 } } [ [ drop ] [ ] checked-if* ] test-poly-infer + +H{ { "a" 1 } { "b" 0 } } [ [ write ] checked-with-variable ] test-poly-infer +H{ { "a" 0 } { "b" 1 } } [ [ os ] checked-with-variable ] test-poly-infer +H{ { "a" 1 } { "b" 1 } } [ [ dup + ] checked-with-variable ] test-poly-infer + +[ [ write write ] checked-each ] poly-infer-must-fail +[ [ ] checked-each ] poly-infer-must-fail +[ [ dup ] checked-map ] poly-infer-must-fail +[ [ drop ] checked-map ] poly-infer-must-fail +[ [ 1 + ] checked-map-index ] poly-infer-must-fail + +[ [ dup ] [ ] checked-if ] poly-infer-must-fail +[ [ 2dup ] [ over ] checked-if ] poly-infer-must-fail +[ [ drop ] [ ] checked-if ] poly-infer-must-fail + +[ [ ] [ ] checked-if* ] poly-infer-must-fail +[ [ dup ] [ ] checked-if* ] poly-infer-must-fail +[ [ drop ] [ drop ] checked-if* ] poly-infer-must-fail +[ [ ] [ drop ] checked-if* ] poly-infer-must-fail +[ [ ] [ 2dup ] checked-if* ] poly-infer-must-fail + +[ "derp" checked-each ] poly-infer-must-fail +[ checked-each ] poly-infer-must-fail +[ "derp" [ "derp" ] checked-if ] poly-infer-must-fail +[ [ "derp" ] "derp" checked-if ] poly-infer-must-fail +[ [ "derp" ] checked-if ] poly-infer-must-fail + diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor new file mode 100644 index 0000000000..bad125deac --- /dev/null +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -0,0 +1,103 @@ +! (c)2010 Joe Groff bsd license +USING: accessors arrays assocs combinators combinators.short-circuit +continuations effects fry kernel locals math namespaces +quotations sequences splitting stack-checker +stack-checker.backend +stack-checker.errors +stack-checker.known-words +stack-checker.values ; +IN: stack-checker.row-polymorphism + + + +: in-effect-variable ( effect -- count variable/f ) + dup in>> effect-variable ; +: out-effect-variable ( effect -- count variable/f ) + dup out>> effect-variable ; + += + [ effect-variables get at+ ] + [ 2drop ] if ; inline + +:: (check-input) ( declared actual -- ) + actual in>> length declared in-effect-variable [ check-variable ] keep :> ( in-diff in-var ) + actual out>> length declared out-effect-variable [ check-variable ] keep :> ( out-diff out-var ) + { [ in-var not ] [ out-var not ] [ in-diff out-diff = ] } 0|| + [ + in-var [ in-diff swap adjust-variable ] when* + out-var [ out-diff swap adjust-variable ] when* + ] [ + abandon-check + ] if ; + +GENERIC: infer-known ( known -- effect ) + +M: object infer-known + current-word get bad-macro-input ; +M: literal infer-known + value>> dup callable? [ infer ] [ current-word get bad-macro-input ] if ; +M: composed infer-known + [ quot1>> known infer-known ] [ quot2>> known infer-known ] bi compose-effects ; +M: curried infer-known + (( -- x )) swap quot>> known infer-known compose-effects ; + +: check-input ( in value -- ) + over quotation-effect? [ + [ second ] dip known infer-known (check-input) + ] [ 2drop ] if ; + +: normalize-variables ( variables -- variables' ) + dup values [ + infimum dup 0 < + [ '[ _ - ] assoc-map ] [ drop ] if + ] unless-empty ; + +PRIVATE> + +: infer-polymorphic-vars ( effect -- variables ) + H{ } clone + [ effect-variables [ in>> dup length ensure-d [ check-input ] 2each ] with-variable ] + keep normalize-variables ; + +: check-polymorphic-effect ( word -- ) + dup current-word [ stack-effect infer-polymorphic-vars drop ] with-variable ; + +SYMBOL: infer-polymorphic? + + From 31640ea9c6adda19ab1fc490774dcfc16f08244c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 4 Mar 2010 20:15:26 -0800 Subject: [PATCH 316/713] nested scopes were messing up stack checker state --- .../row-polymorphism/row-polymorphism.factor | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index bad125deac..8468f56eac 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -66,24 +66,27 @@ ERROR: abandon-check ; abandon-check ] if ; -GENERIC: infer-known ( known -- effect ) +GENERIC: (infer-known) ( known -- effect ) -M: object infer-known +M: object (infer-known) current-word get bad-macro-input ; -M: literal infer-known +M: literal (infer-known) value>> dup callable? [ infer ] [ current-word get bad-macro-input ] if ; -M: composed infer-known - [ quot1>> known infer-known ] [ quot2>> known infer-known ] bi compose-effects ; -M: curried infer-known - (( -- x )) swap quot>> known infer-known compose-effects ; +M: composed (infer-known) + [ quot1>> known (infer-known) ] [ quot2>> known (infer-known) ] bi compose-effects ; +M: curried (infer-known) + (( -- x )) swap quot>> known (infer-known) compose-effects ; + +: infer-known ( value -- effect ) + (infer-known) ; inline : check-input ( in value -- ) over quotation-effect? [ [ second ] dip known infer-known (check-input) ] [ 2drop ] if ; -: normalize-variables ( variables -- variables' ) - dup values [ +: normalize-variables ( -- variables' ) + effect-variables get dup values [ infimum dup 0 < [ '[ _ - ] assoc-map ] [ drop ] if ] unless-empty ; @@ -91,12 +94,14 @@ M: curried infer-known PRIVATE> : infer-polymorphic-vars ( effect -- variables ) - H{ } clone - [ effect-variables [ in>> dup length ensure-d [ check-input ] 2each ] with-variable ] - keep normalize-variables ; + H{ } clone effect-variables set + in>> dup length ensure-d [ check-input ] 2each + normalize-variables ; : check-polymorphic-effect ( word -- ) - dup current-word [ stack-effect infer-polymorphic-vars drop ] with-variable ; + current-word get [ + dup current-word set stack-effect infer-polymorphic-vars drop + ] dip current-word set ; SYMBOL: infer-polymorphic? From 053ba583fc3f9ead7518e065e6e7ca51c27b582f Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 4 Mar 2010 21:51:49 -0800 Subject: [PATCH 317/713] improve error reporting --- basis/stack-checker/errors/errors.factor | 2 +- .../errors/prettyprint/prettyprint.factor | 23 +++++++++-- .../row-polymorphism-tests.factor | 1 + .../row-polymorphism/row-polymorphism.factor | 41 +++++++++++++++---- 4 files changed, 54 insertions(+), 13 deletions(-) diff --git a/basis/stack-checker/errors/errors.factor b/basis/stack-checker/errors/errors.factor index fbb8515a07..e928c38c88 100644 --- a/basis/stack-checker/errors/errors.factor +++ b/basis/stack-checker/errors/errors.factor @@ -34,7 +34,7 @@ ERROR: transform-expansion-error < inference-error error continuation word ; ERROR: bad-declaration-error < inference-error declaration ; -ERROR: invalid-quotation-input < inference-error branches quots ; +ERROR: invalid-quotation-input < inference-error word branches quots ; ERROR: invalid-effect-variable < inference-error effect ; diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor index f762e0559b..3288f4108e 100644 --- a/basis/stack-checker/errors/prettyprint/prettyprint.factor +++ b/basis/stack-checker/errors/prettyprint/prettyprint.factor @@ -13,10 +13,13 @@ M: bad-macro-input summary M: unbalanced-branches-error summary drop "Unbalanced branches" ; +: quots-and-branches. ( quots branches -- ) + zip [ [ first pprint-short bl ] [ second effect>string print ] bi ] each ; + M: unbalanced-branches-error error. dup summary print - [ quots>> ] [ branches>> [ length [ "x" ] bi@ ] { } assoc>map ] bi zip - [ [ first pprint-short bl ] [ second effect>string print ] bi ] each ; + [ quots>> ] [ branches>> [ length [ "x" ] bi@ ] { } assoc>map ] bi + quots-and-branches. ; M: too-many->r summary drop "Quotation pushes elements on retain stack without popping them" ; @@ -60,4 +63,18 @@ M: transform-expansion-error error. tri ; M: do-not-compile summary - word>> name>> "Cannot compile call to " prepend ; \ No newline at end of file + word>> name>> "Cannot compile call to " prepend ; + +M: invalid-quotation-input summary + word>> name>> + "The input quotations to " " don't match their expected effects" surround ; + +M: invalid-quotation-input error. + dup summary print + P [ quots>> ] [ branches>> ] bi quots-and-branches. ; + +M: invalid-effect-variable summary + drop "Stack effect variables can only occur as the first input or output" ; +M: effect-variable-can't-have-type summary + drop "Stack effect variables cannot have a declared type" ; + diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor index 39c9a2c13a..d2fc6bfc22 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor @@ -4,6 +4,7 @@ system tools.test stack-checker.backend stack-checker.errors stack-checker.row-polymorphism +stack-checker.state stack-checker.values ; IN: stack-checker.row-polymorphism.tests diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index 8468f56eac..182533640a 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -9,7 +9,7 @@ stack-checker.values ; IN: stack-checker.row-polymorphism error-quot ( known -- quot ) + +M: object >error-quot drop (unknown) ; +M: literal >error-quot value>> ; +M: composed >error-quot + [ quot1>> known >error-quot ] [ quot2>> known >error-quot ] bi + \ compose [ ] 3sequence ; +M: curried >error-quot + [ obj>> known >error-quot ] [ quot>> known >error-quot ] bi + \ curry [ ] 3sequence ; + +: >error-branches-and-quots ( branch/values -- branches quots ) + [ [ second ] [ known >error-quot ] bi* ] assoc-map unzip ; + +: abandon-check ( -- * ) + current-word get + current-effect get in>> current-meta-d get zip + [ first quotation-effect? ] filter + >error-branches-and-quots + invalid-quotation-input ; :: check-variable ( actual-count declared-count variable -- difference ) actual-count declared-count - variable [ - variable effect-variables get at* nip - [ variable effect-variables get at - ] - [ variable effect-variables get set-at 0 ] if + variable current-effect-variables get at* nip + [ variable current-effect-variables get at - ] + [ variable current-effect-variables get set-at 0 ] if ] [ dup [ abandon-check ] unless-zero ] if ; : adjust-variable ( diff var -- ) over 0 >= - [ effect-variables get at+ ] + [ current-effect-variables get at+ ] [ 2drop ] if ; inline :: (check-input) ( declared actual -- ) @@ -86,7 +107,7 @@ M: curried (infer-known) ] [ 2drop ] if ; : normalize-variables ( -- variables' ) - effect-variables get dup values [ + current-effect-variables get dup values [ infimum dup 0 < [ '[ _ - ] assoc-map ] [ drop ] if ] unless-empty ; @@ -94,8 +115,10 @@ M: curried (infer-known) PRIVATE> : infer-polymorphic-vars ( effect -- variables ) - H{ } clone effect-variables set - in>> dup length ensure-d [ check-input ] 2each + H{ } clone current-effect-variables set + dup current-effect set + in>> dup length ensure-d dup current-meta-d set + [ check-input ] 2each normalize-variables ; : check-polymorphic-effect ( word -- ) From 1b1ccb71a4645881b6d545701cd4130306133b14 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 4 Mar 2010 22:43:01 -0800 Subject: [PATCH 318/713] make tests pass --- basis/stack-checker/errors/prettyprint/prettyprint.factor | 2 +- .../row-polymorphism/row-polymorphism-tests.factor | 6 ++++-- .../stack-checker/row-polymorphism/row-polymorphism.factor | 4 +--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor index 3288f4108e..9d36e9c56c 100644 --- a/basis/stack-checker/errors/prettyprint/prettyprint.factor +++ b/basis/stack-checker/errors/prettyprint/prettyprint.factor @@ -71,7 +71,7 @@ M: invalid-quotation-input summary M: invalid-quotation-input error. dup summary print - P [ quots>> ] [ branches>> ] bi quots-and-branches. ; + [ quots>> ] [ branches>> ] bi quots-and-branches. ; M: invalid-effect-variable summary drop "Stack effect variables can only occur as the first input or output" ; diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor index d2fc6bfc22..c00935b58b 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor @@ -49,6 +49,8 @@ IN: stack-checker.row-polymorphism.tests : poly-infer-must-fail ( quot -- ) '[ _ infer-polymorphic-quot ] [ invalid-quotation-input? ] must-fail-with ; inline +: poly-infer-must-fail-bad-macro-input ( quot -- ) + '[ _ infer-polymorphic-quot ] [ bad-macro-input? ] must-fail-with ; inline H{ { "a" 0 } } [ [ write ] checked-each ] test-poly-infer H{ { "a" 1 } } [ [ append ] checked-each ] test-poly-infer @@ -90,8 +92,8 @@ H{ { "a" 1 } { "b" 1 } } [ [ dup + ] checked-with-variable ] test-poly-infer [ [ ] [ 2dup ] checked-if* ] poly-infer-must-fail [ "derp" checked-each ] poly-infer-must-fail -[ checked-each ] poly-infer-must-fail +[ checked-each ] poly-infer-must-fail-bad-macro-input [ "derp" [ "derp" ] checked-if ] poly-infer-must-fail [ [ "derp" ] "derp" checked-if ] poly-infer-must-fail -[ [ "derp" ] checked-if ] poly-infer-must-fail +[ [ "derp" ] checked-if ] poly-infer-must-fail-bad-macro-input diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index 182533640a..caaf89fbac 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -92,7 +92,7 @@ GENERIC: (infer-known) ( known -- effect ) M: object (infer-known) current-word get bad-macro-input ; M: literal (infer-known) - value>> dup callable? [ infer ] [ current-word get bad-macro-input ] if ; + value>> dup callable? [ infer ] [ abandon-check ] if ; M: composed (infer-known) [ quot1>> known (infer-known) ] [ quot2>> known (infer-known) ] bi compose-effects ; M: curried (infer-known) @@ -127,5 +127,3 @@ PRIVATE> ] dip current-word set ; SYMBOL: infer-polymorphic? - - From 85f30987e22969df7227955f6faa3e4d940d4956 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 5 Mar 2010 00:21:10 -0800 Subject: [PATCH 319/713] spray some polymorphic stack effects on kernel, math, and sequences --- core/kernel/kernel.factor | 12 ++-- core/math/math.factor | 10 +-- core/sequences/sequences.factor | 110 ++++++++++++++++---------------- 3 files changed, 66 insertions(+), 66 deletions(-) diff --git a/core/kernel/kernel.factor b/core/kernel/kernel.factor index 69d082ed2f..ae8763e7f8 100644 --- a/core/kernel/kernel.factor +++ b/core/kernel/kernel.factor @@ -29,7 +29,7 @@ DEFER: if #! two literal quotations. rot [ drop ] [ nip ] if ; inline -: if ( ? true false -- ) ? call ; +: if ( ..a ? true: ( ..a -- ..b ) false: ( ..a -- ..b ) -- ..b ) ? call ; ! Single branch : unless ( ? false -- ) @@ -39,7 +39,7 @@ DEFER: if swap [ call ] [ drop ] if ; inline ! Anaphoric -: if* ( ? true false -- ) +: if* ( ..a ? true: ( ..a ? -- ..b ) false: ( ..a -- ..b ) -- ..b ) pick [ drop call ] [ 2nip call ] if ; inline : when* ( ? true -- ) @@ -49,7 +49,7 @@ DEFER: if over [ drop ] [ nip call ] if ; inline ! Default -: ?if ( default cond true false -- ) +: ?if ( ..a default cond true: ( ..a cond -- ..b ) false: ( ..a default -- ..b ) -- ..b ) pick [ drop [ drop ] 2dip call ] [ 2nip call ] if ; inline ! Dippers. @@ -171,16 +171,16 @@ UNION: boolean POSTPONE: t POSTPONE: f ; : most ( x y quot -- z ) 2keep ? ; inline ! Loops -: loop ( pred: ( -- ? ) -- ) +: loop ( ... pred: ( ... -- ... ? ) -- ... ) [ call ] keep [ loop ] curry when ; inline recursive : do ( pred body -- pred body ) dup 2dip ; inline -: while ( pred: ( -- ? ) body: ( -- ) -- ) +: while ( ... pred: ( ... -- ... ? ) body: ( ... -- ... ) -- ... ) swap do compose [ loop ] curry when ; inline -: until ( pred: ( -- ? ) body: ( -- ) -- ) +: until ( ... pred: ( ... -- ... ? ) body: ( ... -- ... ) -- ) [ [ not ] compose ] dip while ; inline ! Object protocol diff --git a/core/math/math.factor b/core/math/math.factor index c1a8ba32f7..eb3966397e 100644 --- a/core/math/math.factor +++ b/core/math/math.factor @@ -77,7 +77,7 @@ ERROR: log2-expects-positive x ; : even? ( n -- ? ) 1 bitand zero? ; : odd? ( n -- ? ) 1 bitand 1 number= ; -: if-zero ( n quot1 quot2 -- ) +: if-zero ( ..a n quot1: ( ..a -- ..b ) quot2: ( ..a n -- ..b ) -- ..b ) [ dup zero? ] [ [ drop ] prepose ] [ ] tri* if ; inline : when-zero ( n quot -- ) [ ] if-zero ; inline @@ -141,18 +141,18 @@ GENERIC: prev-float ( m -- n ) PRIVATE> -: (each-integer) ( i n quot: ( i -- ) -- ) +: (each-integer) ( ... i n quot: ( ... i -- ... ) -- ... ) [ iterate-step iterate-next (each-integer) ] [ 3drop ] if-iterate? ; inline recursive -: (find-integer) ( i n quot: ( i -- ? ) -- i ) +: (find-integer) ( ... i n quot: ( ... i -- ... ? ) -- ... i ) [ iterate-step [ [ ] ] 2dip [ iterate-next (find-integer) ] 2curry bi-curry if ] [ 3drop f ] if-iterate? ; inline recursive -: (all-integers?) ( i n quot: ( i -- ? ) -- ? ) +: (all-integers?) ( ... i n quot: ( ... i -- ... ? ) -- ... ? ) [ iterate-step [ iterate-next (all-integers?) ] 3curry @@ -171,7 +171,7 @@ PRIVATE> : all-integers? ( n quot -- ? ) iterate-prep (all-integers?) ; inline -: find-last-integer ( n quot: ( i -- ? ) -- i ) +: find-last-integer ( ... n quot: ( ... i -- ... ? ) -- ... i ) over 0 < [ 2drop f ] [ diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 9f59d98468..cb8d2abedf 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -29,7 +29,7 @@ M: sequence shorten 2dup length < [ set-length ] [ 2drop ] if ; inline : empty? ( seq -- ? ) length 0 = ; inline -: if-empty ( seq quot1 quot2 -- ) +: if-empty ( ..a seq quot1: ( ..a -- ..b ) quot2: ( ..a seq -- ..b ) -- ..b ) [ dup empty? ] [ [ drop ] prepose ] [ ] tri* if ; inline : when-empty ( seq quot -- ) [ ] if-empty ; inline @@ -408,82 +408,82 @@ PRIVATE> PRIVATE> -: each ( seq quot -- ) +: each ( ... seq quot: ( ... x -- ... ) -- ... ) (each) each-integer ; inline -: reduce ( seq identity quot -- result ) +: reduce ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... result ) swapd each ; inline : map-integers ( len quot exemplar -- newseq ) [ over ] dip [ [ collect ] keep ] new-like ; inline -: map-as ( seq quot exemplar -- newseq ) +: map-as ( ... seq quot: ( ... x -- ... newx ) exemplar -- ... newseq ) [ (each) ] dip map-integers ; inline -: map ( seq quot -- newseq ) +: map ( ... seq quot: ( ... x -- ... newx ) -- ... newseq ) over map-as ; inline -: replicate-as ( len quot exemplar -- newseq ) +: replicate-as ( ... len quot: ( ... -- ... newx ) exemplar -- ... newseq ) [ [ drop ] prepose ] dip map-integers ; inline -: replicate ( len quot -- newseq ) +: replicate ( ... len quot: ( ... -- ... newx ) -- ... newseq ) { } replicate-as ; inline -: map! ( seq quot -- seq ) +: map! ( ... seq quot: ( ... x -- ... x' ) -- ... seq ) over [ map-into ] keep ; inline -: accumulate-as ( seq identity quot exemplar -- final newseq ) +: accumulate-as ( ... seq identity quot: ( ... prev elt -- ... next ) exemplar -- ... final newseq ) [ (accumulate) ] dip map-as ; inline -: accumulate ( seq identity quot -- final newseq ) +: accumulate ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... final newseq ) { } accumulate-as ; inline -: accumulate! ( seq identity quot -- final seq ) +: accumulate! ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... final seq ) (accumulate) map! ; inline -: 2each ( seq1 seq2 quot -- ) +: 2each ( ... seq1 seq2 quot: ( ... x1 x2 -- ... ) -- ... ) (2each) each-integer ; inline -: 2reverse-each ( seq1 seq2 quot -- ) +: 2reverse-each ( ... seq1 seq2 quot: ( ... x1 x2 -- ... ) -- ... ) [ [ ] bi@ ] dip 2each ; inline -: 2reduce ( seq1 seq2 identity quot -- result ) +: 2reduce ( ... seq1 seq2 identity quot: ( ... prev elt1 elt2 -- ... next ) -- ... result ) [ -rot ] dip 2each ; inline -: 2map-as ( seq1 seq2 quot exemplar -- newseq ) +: 2map-as ( ... seq1 seq2 quot: ( ... x1 x2 -- ... newx ) exemplar -- ... newseq ) [ (2each) ] dip map-integers ; inline -: 2map ( seq1 seq2 quot -- newseq ) +: 2map ( ... seq1 seq2 quot: ( ... x1 x2 -- ... newx ) -- ... newseq ) pick 2map-as ; inline -: 2all? ( seq1 seq2 quot -- ? ) +: 2all? ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) -- ... ? ) (2each) all-integers? ; inline -: 3each ( seq1 seq2 seq3 quot -- ) +: 3each ( ... seq1 seq2 seq3 quot: ( ... x1 x2 x3 -- ... ) -- ... ) (3each) each-integer ; inline -: 3map-as ( seq1 seq2 seq3 quot exemplar -- newseq ) +: 3map-as ( ... seq1 seq2 seq3 quot: ( ... x1 x2 x3 -- ... newx ) exemplar -- ... newseq ) [ (3each) ] dip map-integers ; inline -: 3map ( seq1 seq2 seq3 quot -- newseq ) +: 3map ( ... seq1 seq2 seq3 quot: ( ... x1 x2 x3 -- ... newx ) -- ... newseq ) [ pick ] dip swap 3map-as ; inline -: find-from ( n seq quot -- i elt ) +: find-from ( ... n seq quot: ( ... elt -- ... ? ) -- ... i elt ) [ (find-integer) ] (find-from) ; inline -: find ( seq quot -- i elt ) +: find ( ... seq quot: ( ... elt -- ... ? ) -- ... i elt ) [ find-integer ] (find) ; inline -: find-last-from ( n seq quot -- i elt ) +: find-last-from ( ... n seq quot: ( ... elt -- ... ? ) -- ... i elt ) [ nip find-last-integer ] (find-from) ; inline -: find-last ( seq quot -- i elt ) +: find-last ( ... seq quot: ( ... elt -- ... ? ) -- ... i elt ) [ [ 1 - ] dip find-last-integer ] (find) ; inline -: all? ( seq quot -- ? ) +: all? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? ) (each) all-integers? ; inline -: push-if ( elt quot accum -- ) +: push-if ( ... elt quot: ( ... elt -- ... ? ) accum -- ... ) [ keep ] dip rot [ push ] [ 2drop ] if ; inline : selector-for ( quot exemplar -- selector accum ) @@ -492,19 +492,19 @@ PRIVATE> : selector ( quot -- selector accum ) V{ } selector-for ; inline -: filter-as ( seq quot exemplar -- subseq ) +: filter-as ( ... seq quot: ( ... elt -- ... ? ) exemplar -- ... subseq ) dup [ selector-for [ each ] dip ] curry dip like ; inline -: filter ( seq quot -- subseq ) +: filter ( ... seq quot: ( ... elt -- ... ? ) -- ... subseq ) over filter-as ; inline -: push-either ( elt quot accum1 accum2 -- ) +: push-either ( ... elt quot: ( ... elt -- ... ? ) accum1 accum2 -- ... ) [ keep swap ] 2dip ? push ; inline : 2selector ( quot -- selector accum1 accum2 ) V{ } clone V{ } clone [ [ push-either ] 3curry ] 2keep ; inline -: partition ( seq quot -- trueseq falseseq ) +: partition ( ... seq quot: ( ... elt -- ... ? ) -- ... trueseq falseseq ) over [ 2selector [ each ] 2dip ] dip [ like ] curry bi@ ; inline : collector-for ( quot exemplar -- quot' vec ) @@ -513,16 +513,16 @@ PRIVATE> : collector ( quot -- quot' vec ) V{ } collector-for ; inline -: produce-as ( pred quot exemplar -- seq ) +: produce-as ( ... pred: ( ... -- ... ? ) quot: ( ... -- ... obj ) exemplar -- ... seq ) dup [ collector-for [ while ] dip ] curry dip like ; inline -: produce ( pred quot -- seq ) +: produce ( ... pred: ( ... -- ... ? ) quot: ( ... -- ... obj ) -- ... seq ) { } produce-as ; inline -: follow ( obj quot -- seq ) +: follow ( ... obj quot: ( ... prev -- ... result/f ) -- ... seq ) [ dup ] swap [ keep ] curry produce nip ; inline -: each-index ( seq quot -- ) +: each-index ( ... seq quot: ( ... x i -- ... ) -- ... ) (each-index) each-integer ; inline : interleave ( seq between quot -- ) @@ -532,10 +532,10 @@ PRIVATE> 3bi ] if ; inline -: map-index ( seq quot -- newseq ) +: map-index ( ... seq quot: ( ... x i -- ... newx ) -- ... newseq ) [ dup length iota ] dip 2map ; inline -: reduce-index ( seq identity quot -- ) +: reduce-index ( ... seq identity quot: ( ... prev x i -- ... next ) -- ... result ) swapd each-index ; inline : index ( obj seq -- n ) @@ -564,7 +564,7 @@ PRIVATE> : nths ( indices seq -- seq' ) [ nth ] curry map ; -: any? ( seq quot -- ? ) +: any? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? ) find drop >boolean ; inline : member? ( elt seq -- ? ) @@ -626,7 +626,7 @@ M: slice equal? over slice? [ sequence= ] [ 2drop f ] if ; -: filter! ( seq quot -- seq ) +: filter! ( ... seq quot: ( ... elt -- ... ? ) -- ... seq ) swap [ [ 0 0 ] dip (filter!) ] keep ; inline : remove! ( elt seq -- seq ) @@ -771,7 +771,7 @@ PRIVATE> ] keep like ] if ; -: padding ( seq n elt quot -- newseq ) +: padding ( ... seq n elt quot: ( ... seq1 seq2 -- ... newseq ) -- ... newseq ) [ [ over length [-] dup 0 = [ drop ] ] dip [ ] curry @@ -810,7 +810,7 @@ PRIVATE> : halves ( seq -- first-slice second-slice ) dup midpoint@ cut-slice ; -: binary-reduce ( seq start quot: ( elt1 elt2 -- newelt ) -- value ) +: binary-reduce ( ... seq start quot: ( ... elt1 elt2 -- ... newelt ) -- ... value ) #! We can't use case here since combinators depends on #! sequences pick length dup 0 3 between? [ @@ -873,11 +873,11 @@ PRIVATE> : 2unclip-slice ( seq1 seq2 -- rest-slice1 rest-slice2 first1 first2 ) [ unclip-slice ] bi@ swapd ; inline -: map-reduce ( seq map-quot reduce-quot -- result ) +: map-reduce ( ..a seq map-quot: ( ..a x -- ..b elt ) reduce-quot: ( ..b prev elt -- ..a next ) -- ..a result ) [ [ unclip-slice ] dip [ call ] keep ] dip compose reduce ; inline -: 2map-reduce ( seq1 seq2 map-quot reduce-quot -- result ) +: 2map-reduce ( ..a seq1 seq2 map-quot: ( ..a x1 x2 -- ..b elt ) reduce-quot: ( ..b prev elt -- ..a next ) -- ..a result ) [ [ prepare-2map-reduce ] keep ] dip compose compose each-integer ; inline @@ -889,10 +889,10 @@ PRIVATE> PRIVATE> -: map-find ( seq quot -- result elt ) +: map-find ( ... seq quot: ( ... elt -- ... ? ) -- ... result elt ) [ find ] (map-find) ; inline -: map-find-last ( seq quot -- result elt ) +: map-find-last ( ... seq quot: ( ... elt -- ... ? ) -- ... result elt ) [ find-last ] (map-find) ; inline : unclip-last-slice ( seq -- butlast-slice last ) @@ -915,22 +915,22 @@ PRIVATE> PRIVATE> -: trim-head-slice ( seq quot -- slice ) +: trim-head-slice ( ... seq quot: ( ... elt -- ... ? ) -- ... slice ) (trim-head) tail-slice ; inline -: trim-head ( seq quot -- newseq ) +: trim-head ( ... seq quot: ( ... elt -- ... ? ) -- ... newseq ) (trim-head) tail ; inline -: trim-tail-slice ( seq quot -- slice ) +: trim-tail-slice ( ... seq quot: ( ... elt -- ... ? ) -- ... slice ) (trim-tail) head-slice ; inline -: trim-tail ( seq quot -- newseq ) +: trim-tail ( ... seq quot: ( ... elt -- ... ? ) -- ... newseq ) (trim-tail) head ; inline -: trim-slice ( seq quot -- slice ) +: trim-slice ( ... seq quot: ( ... elt -- ... ? ) -- ... slice ) [ trim-head-slice ] [ trim-tail-slice ] bi ; inline -: trim ( seq quot -- newseq ) +: trim ( ... seq quot: ( ... elt -- ... ? ) -- ... newseq ) [ trim-slice ] [ drop ] 2bi like ; inline GENERIC: sum ( seq -- n ) @@ -942,15 +942,15 @@ M: object sum 0 [ + ] binary-reduce ; inline : supremum ( seq -- n ) [ ] [ max ] map-reduce ; -: map-sum ( seq quot -- n ) +: map-sum ( ... seq quot: ( ... elt -- ... n ) -- ... n ) [ 0 ] 2dip [ dip + ] curry [ swap ] prepose each ; inline -: count ( seq quot -- n ) [ 1 0 ? ] compose map-sum ; inline +: count ( ... seq quot: ( ... elt -- ... ? ) -- ... n ) [ 1 0 ? ] compose map-sum ; inline -: cartesian-each ( seq1 seq2 quot -- ) +: cartesian-each ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ) -- ... ) [ with each ] 2curry each ; inline -: cartesian-map ( seq1 seq2 quot -- newseq ) +: cartesian-map ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) -- ... newseq ) [ with map ] 2curry map ; inline : cartesian-product ( seq1 seq2 -- newseq ) From a3033e885a030a8b277e7dbbffa2cb2f543ace6e Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 5 Mar 2010 13:30:10 -0800 Subject: [PATCH 320/713] make effect variables part of effect syntax, stored out of band in effect tuple --- .../call-effect/call-effect.factor | 2 +- .../row-polymorphism-tests.factor | 6 --- .../row-polymorphism/row-polymorphism.factor | 28 +---------- basis/stack-checker/state/state.factor | 2 +- core/effects/effects-tests.factor | 17 ++++++- core/effects/effects.factor | 34 +++++++++---- core/effects/parser/parser.factor | 49 ++++++++++++------- 7 files changed, 77 insertions(+), 61 deletions(-) diff --git a/basis/compiler/tree/propagation/call-effect/call-effect.factor b/basis/compiler/tree/propagation/call-effect/call-effect.factor index eba11de26c..4b029fccf2 100644 --- a/basis/compiler/tree/propagation/call-effect/call-effect.factor +++ b/basis/compiler/tree/propagation/call-effect/call-effect.factor @@ -48,7 +48,7 @@ M: +unknown+ curry-effect ; M: effect curry-effect [ in>> length ] [ out>> length ] [ terminated?>> ] tri pick 0 = [ [ 1 + ] dip ] [ [ 1 - ] 2dip ] if - [ [ "x" ] bi@ ] dip effect boa ; + [ [ "x" ] bi@ ] dip ; M: curry cached-effect quot>> cached-effect curry-effect ; diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor index c00935b58b..3c129e9e0c 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor @@ -8,12 +8,6 @@ stack-checker.state stack-checker.values ; IN: stack-checker.row-polymorphism.tests -[ 3 f ] [ (( a b c -- d )) in-effect-variable ] unit-test -[ 0 f ] [ (( -- d )) in-effect-variable ] unit-test -[ 2 "a" ] [ (( ..a b c -- d )) in-effect-variable ] unit-test -[ (( a ..b c -- d )) in-effect-variable ] [ invalid-effect-variable? ] must-fail-with -[ (( ..a: integer b c -- d )) in-effect-variable ] [ effect-variable-can't-have-type? ] must-fail-with - : checked-each ( ..a seq quot: ( ..a x -- ..a ) -- ..a ) curry call ; inline diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index caaf89fbac..a01d0caaf9 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -14,30 +14,6 @@ SYMBOLS: current-effect-variables current-effect current-meta-d ; : quotation-effect? ( in -- ? ) dup pair? [ second effect? ] [ drop f ] if ; -: (effect-variable) ( effect in -- effect variable/f ) - dup pair? - [ first ".." head? [ effect-variable-can't-have-type ] [ f ] if ] - [ ".." ?head [ drop f ] unless ] if ; - -: validate-effect-variables ( effect ins/outs -- ) - [ (effect-variable) ] any? [ invalid-effect-variable ] [ drop ] if ; - -: effect-variable ( effect ins/outs -- count variable/f ) - [ drop 0 f ] [ - unclip - [ [ validate-effect-variables ] [ length ] bi ] - [ (effect-variable) ] bi* - [ 1 + f ] unless* - ] if-empty ; -PRIVATE> - -: in-effect-variable ( effect -- count variable/f ) - dup in>> effect-variable ; -: out-effect-variable ( effect -- count variable/f ) - dup out>> effect-variable ; - -error-quot ( known -- quot ) @@ -77,8 +53,8 @@ M: curried >error-quot [ 2drop ] if ; inline :: (check-input) ( declared actual -- ) - actual in>> length declared in-effect-variable [ check-variable ] keep :> ( in-diff in-var ) - actual out>> length declared out-effect-variable [ check-variable ] keep :> ( out-diff out-var ) + actual in>> length declared in-var>> [ check-variable ] keep :> ( in-diff in-var ) + actual out>> length declared out-var>> [ check-variable ] keep :> ( out-diff out-var ) { [ in-var not ] [ out-var not ] [ in-diff out-diff = ] } 0|| [ in-var [ in-diff swap adjust-variable ] when* diff --git a/basis/stack-checker/state/state.factor b/basis/stack-checker/state/state.factor index f0b595ebe5..69eb590d48 100644 --- a/basis/stack-checker/state/state.factor +++ b/basis/stack-checker/state/state.factor @@ -40,7 +40,7 @@ SYMBOL: literals : current-effect ( -- effect ) input-count get "x" meta-d length "x" - terminated? get effect boa ; + terminated? get ; : init-inference ( -- ) terminated? off diff --git a/core/effects/effects-tests.factor b/core/effects/effects-tests.factor index ffc0c9780b..af4675d6f2 100644 --- a/core/effects/effects-tests.factor +++ b/core/effects/effects-tests.factor @@ -1,4 +1,4 @@ -USING: effects kernel tools.test prettyprint accessors +USING: effects effects.parser eval kernel tools.test prettyprint accessors quotations sequences ; IN: effects.tests @@ -27,3 +27,18 @@ IN: effects.tests [ { object object } ] [ (( a b -- )) effect-in-types ] unit-test [ { object sequence } ] [ (( a b: sequence -- )) effect-in-types ] unit-test + +[ f ] [ (( a b c -- d )) in-var>> ] unit-test +[ f ] [ (( -- d )) in-var>> ] unit-test +[ "a" ] [ (( ..a b c -- d )) in-var>> ] unit-test +[ { "b" "c" } ] [ (( ..a b c -- d )) in>> ] unit-test + +[ f ] [ (( ..a b c -- e )) out-var>> ] unit-test +[ "d" ] [ (( ..a b c -- ..d e )) out-var>> ] unit-test +[ { "e" } ] [ (( ..a b c -- ..d e )) out>> ] unit-test + +[ "(( a ..b c -- d ))" eval( -- effect ) ] +[ error>> invalid-effect-variable? ] must-fail-with + +[ "(( ..a: integer b c -- d ))" eval( -- effect ) ] +[ error>> effect-variable-can't-have-type? ] must-fail-with diff --git a/core/effects/effects.factor b/core/effects/effects.factor index fea50d2981..c049f16f4a 100644 --- a/core/effects/effects.factor +++ b/core/effects/effects.factor @@ -8,11 +8,21 @@ IN: effects TUPLE: effect { in array read-only } { out array read-only } -{ terminated? read-only } ; +{ terminated? read-only } +{ in-var read-only } +{ out-var read-only } ; + +: ?terminated ( out -- out terminated? ) + dup { "*" } = [ drop { } t ] [ f ] if ; : ( in out -- effect ) - dup { "*" } = [ drop { } t ] [ f ] if - effect boa ; + ?terminated f f effect boa ; + +: ( in out terminated? -- effect ) + f f effect boa ; inline + +: ( in-var in out-var out -- effect ) + swap [ rot ] dip [ ?terminated ] 2dip effect boa ; : effect-height ( effect -- n ) [ out>> length ] [ in>> length ] bi - ; inline @@ -42,13 +52,19 @@ M: pair effect>string first2 [ effect>string ] bi@ ": " glue ; : stack-picture ( seq -- string ) [ [ effect>string % CHAR: \s , ] each ] "" make ; +: var-picture ( var -- string ) + [ ".." " " surround ] + [ "" ] if* ; + M: effect effect>string ( effect -- string ) [ "( " % - [ in>> stack-picture % "-- " % ] - [ out>> stack-picture % ] - [ terminated?>> [ "* " % ] when ] - tri + dup in-var>> var-picture % + dup in>> stack-picture % "-- " % + dup out-var>> var-picture % + dup out>> stack-picture % + dup terminated?>> [ "* " % ] when + drop ")" % ] "" make ; @@ -87,7 +103,7 @@ M: effect clone shuffle-mapping swap nths ; : add-effect-input ( effect -- effect' ) - [ in>> "obj" suffix ] [ out>> ] [ terminated?>> ] tri effect boa ; + [ in>> "obj" suffix ] [ out>> ] [ terminated?>> ] tri ; : compose-effects ( effect1 effect2 -- effect' ) over terminated?>> [ @@ -97,5 +113,5 @@ M: effect clone [ [ out>> length ] [ [ in>> length ] [ out>> length ] bi ] bi* [ [-] ] dip + ] [ nip terminated?>> ] 2tri [ [ "x" ] bi@ ] dip - effect boa + ] if ; inline diff --git a/core/effects/parser/parser.factor b/core/effects/parser/parser.factor index 842d4f6447..e806f1befc 100644 --- a/core/effects/parser/parser.factor +++ b/core/effects/parser/parser.factor @@ -1,34 +1,49 @@ ! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: lexer sets sequences kernel splitting effects -combinators arrays vocabs.parser classes parser ; +combinators arrays make vocabs.parser classes parser ; IN: effects.parser DEFER: parse-effect ERROR: bad-effect ; +ERROR: invalid-effect-variable ; +ERROR: effect-variable-can't-have-type ; +ERROR: stack-effect-omits-dashes ; -: parse-effect-token ( end -- token/f ) - scan [ nip ] [ = ] 2bi [ drop f ] [ - dup { f "(" "((" } member? [ bad-effect ] [ - ":" ?tail [ - scan { - { [ dup "(" = ] [ drop ")" parse-effect ] } - { [ dup f = ] [ ")" unexpected-eof ] } - [ parse-word dup class? [ bad-effect ] unless ] - } cond 2array - ] when +SYMBOL: effect-var + +: parse-var ( first? var name -- var ) + nip + [ ":" ?tail [ effect-variable-can't-have-type ] when ] curry + [ invalid-effect-variable ] if ; + +: parse-effect-token ( first? var end -- var more? ) + scan [ nip ] [ = ] 2bi [ drop nip f ] [ + dup { f "(" "((" "--" } member? [ bad-effect ] [ + dup { ")" "))" } member? [ stack-effect-omits-dashes ] [ + ".." ?head [ parse-var t ] [ + [ drop ] 2dip + ":" ?tail [ + scan { + { [ dup "(" = ] [ drop ")" parse-effect ] } + { [ dup f = ] [ ")" unexpected-eof ] } + [ parse-word dup class? [ bad-effect ] unless ] + } cond 2array + ] when , t + ] if + ] if ] if ] if ; -: parse-effect-tokens ( end -- tokens ) - [ parse-effect-token dup ] curry [ ] produce nip ; - -ERROR: stack-effect-omits-dashes tokens ; +: parse-effect-tokens ( end -- var tokens ) + [ + [ t f ] dip [ parse-effect-token [ f ] 2dip ] curry [ ] while nip + ] { } make ; : parse-effect ( end -- effect ) - parse-effect-tokens { "--" } split1 dup - [ ] [ drop stack-effect-omits-dashes ] if ; + [ "--" parse-effect-tokens ] dip parse-effect-tokens + ; : complete-effect ( -- effect ) "(" expect ")" parse-effect ; From ff2a53e1b87ed78dca7f882b32ed3a6e1bf077db Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 5 Mar 2010 13:58:00 -0800 Subject: [PATCH 321/713] clean up now-inappropriate uses of "..." in generalizations stack effects --- .../generalizations-docs.factor | 6 +++--- basis/generalizations/generalizations.factor | 6 +++--- .../generalizations-docs.factor | 8 ++++---- .../generalizations/generalizations.factor | 20 +++++++++---------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/basis/generalizations/generalizations-docs.factor b/basis/generalizations/generalizations-docs.factor index 5b869f138e..d21b2b022c 100644 --- a/basis/generalizations/generalizations-docs.factor +++ b/basis/generalizations/generalizations-docs.factor @@ -252,17 +252,17 @@ HELP: spread* { $notes "This word can be used with " { $link apply-curry } " to generalize the " { $snippet "bi-curry@ bi*" } " or " { $snippet "tri-curry@ tri*" } " dataflow patterns." } ; HELP: apply-curry -{ $values { "...a" { $snippet "n" } " values on the datastack" } { "quot" quotation } { "n" integer } } +{ $values { "a..." { $snippet "n" } " values on the datastack" } { "quot" quotation } { "n" integer } } { $description "Curries each of the top " { $snippet "n" } " items of the datastack onto " { $snippet "quot" } ", leaving " { $snippet "n" } " quotations on the datastack. A generalization of " { $link bi-curry@ } " and " { $link tri-curry@ } "." } { $notes "This word can be used with " { $link cleave* } " and " { $link spread* } " to generalize dataflow patterns such as " { $snippet "bi-curry@ bi" } ", " { $snippet "tri-curry@ tri" } ", " { $snippet "bi-curry@ bi*" } ", and " { $snippet "tri-curry@ tri*" } "." } ; HELP: cleave-curry -{ $values { "a" object } { "...quot" { $snippet "n" } " quotations on the datastack" } { "n" integer } } +{ $values { "a" object } { "quot..." { $snippet "n" } " quotations on the datastack" } { "n" integer } } { $description "Curries " { $snippet "a" } " onto the " { $snippet "n" } " quotations on the top of the datastack. A generalization of " { $link bi-curry } " and " { $link tri-curry } "." } { $notes "This word can be used with " { $link cleave* } " and " { $link spread* } " to generalize dataflow patterns such as " { $snippet "bi-curry bi" } ", " { $snippet "tri-curry tri" } ", " { $snippet "bi-curry bi*" } ", and " { $snippet "tri-curry tri*" } "." } ; HELP: spread-curry -{ $values { "...a" { $snippet "n" } " objects on the datastack" } { "...quot" { $snippet "n" } " quotations on the datastack" } { "n" integer } } +{ $values { "a..." { $snippet "n" } " objects on the datastack" } { "quot..." { $snippet "n" } " quotations on the datastack" } { "n" integer } } { $description "Curries the " { $snippet "n" } " quotations on the top of the datastack with the " { $snippet "n" } " values just below them. A generalization of " { $link bi-curry* } " and " { $link tri-curry* } "." } { $notes "This word can be used with " { $link cleave* } " and " { $link spread* } " to generalize dataflow patterns such as " { $snippet "bi-curry* bi" } ", " { $snippet "tri-curry* tri" } ", " { $snippet "bi-curry* bi*" } ", and " { $snippet "tri-curry* tri*" } "." } ; diff --git a/basis/generalizations/generalizations.factor b/basis/generalizations/generalizations.factor index dd0665b534..ac5ff3dee0 100644 --- a/basis/generalizations/generalizations.factor +++ b/basis/generalizations/generalizations.factor @@ -125,13 +125,13 @@ MACRO: cleave* ( n -- ) : mnapply ( quot m n -- ) [ nip dupn ] [ nspread* ] 2bi ; inline -: apply-curry ( ...a quot n -- ) +: apply-curry ( a... quot n -- ) [ [curry] ] dip napply ; inline -: cleave-curry ( a ...quot n -- ) +: cleave-curry ( a quot... n -- ) [ [curry] ] swap [ napply ] [ cleave* ] bi ; inline -: spread-curry ( ...a ...quot n -- ) +: spread-curry ( a... quot... n -- ) [ [curry] ] swap [ napply ] [ spread* ] bi ; inline MACRO: mnswap ( m n -- ) diff --git a/basis/sequences/generalizations/generalizations-docs.factor b/basis/sequences/generalizations/generalizations-docs.factor index 7940427e69..30ad1ea628 100644 --- a/basis/sequences/generalizations/generalizations-docs.factor +++ b/basis/sequences/generalizations/generalizations-docs.factor @@ -4,15 +4,15 @@ math arrays combinators ; IN: sequences.generalizations HELP: neach -{ $values { "...seq" { $snippet "n" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( ...element -- )" } } { "n" integer } } +{ $values { "seq..." { $snippet "n" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( element... -- )" } } { "n" integer } } { $description "A generalization of " { $link each } ", " { $link 2each } ", and " { $link 3each } " that can iterate over any number of sequences in parallel." } ; HELP: nmap -{ $values { "...seq" { $snippet "n" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( ...element -- result )" } } { "n" integer } { "result" "a sequence of the same type as the first " { $snippet "seq" } } } +{ $values { "seq..." { $snippet "n" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( element... -- result )" } } { "n" integer } { "result" "a sequence of the same type as the first " { $snippet "seq" } } } { $description "A generalization of " { $link map } ", " { $link 2map } ", and " { $link 3map } " that can map over any number of sequences in parallel." } ; HELP: nmap-as -{ $values { "...seq" { $snippet "n" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( ...element -- result )" } } { "exemplar" sequence } { "n" integer } { "result" "a sequence of the same type as " { $snippet "exemplar" } } } +{ $values { "seq..." { $snippet "n" } " sequences on the datastack" } { "quot" "a quotation with stack effect " { $snippet "( element... -- result )" } } { "exemplar" sequence } { "n" integer } { "result" "a sequence of the same type as " { $snippet "exemplar" } } } { $description "A generalization of " { $link map-as } ", " { $link 2map-as } ", and " { $link 3map-as } " that can map over any number of sequences in parallel." } ; HELP: mnmap @@ -28,7 +28,7 @@ HELP: nproduce { $description "A generalization of " { $link produce } " that generates " { $snippet "n" } " arrays in parallel by calling " { $snippet "quot" } " repeatedly until " { $snippet "pred" } " outputs false." } ; HELP: nproduce-as -{ $values { "pred" { $quotation "( -- ? )" } } { "quot" { $quotation "( -- obj1 obj2 ... objn )" } } { "...exemplar" { $snippet "n" } " sequences on the datastack" } { "n" integer } { "seq..." { $snippet "n" } " sequences on the datastack of the same types as the " { $snippet "exemplar" } "s" } } +{ $values { "pred" { $quotation "( -- ? )" } } { "quot" { $quotation "( -- obj1 obj2 ... objn )" } } { "exemplar..." { $snippet "n" } " sequences on the datastack" } { "n" integer } { "seq..." { $snippet "n" } " sequences on the datastack of the same types as the " { $snippet "exemplar" } "s" } } { $description "A generalization of " { $link produce-as } " that generates " { $snippet "n" } " sequences in parallel by calling " { $snippet "quot" } " repeatedly until " { $snippet "pred" } " outputs false." } ; ARTICLE: "sequences.generalizations" "Generalized sequence iteration combinators" diff --git a/basis/sequences/generalizations/generalizations.factor b/basis/sequences/generalizations/generalizations.factor index f49dc8a4e7..60b1a8a011 100644 --- a/basis/sequences/generalizations/generalizations.factor +++ b/basis/sequences/generalizations/generalizations.factor @@ -8,31 +8,31 @@ MACRO: nmin-length ( n -- ) dup 1 - [ min ] n*quot '[ [ length ] _ napply @ ] ; -: nnth-unsafe ( n ...seq n -- ) +: nnth-unsafe ( n seq... n -- ) [ nth-unsafe ] swap [ apply-curry ] [ cleave* ] bi ; inline MACRO: nset-nth-unsafe ( n -- ) [ [ drop ] ] [ '[ [ set-nth-unsafe ] _ [ apply-curry ] [ cleave-curry ] [ spread* ] tri ] ] if-zero ; -: (neach) ( ...seq quot n -- len quot' ) +: (neach) ( seq... quot n -- len quot' ) dup dup dup '[ [ _ nmin-length ] _ nkeep [ _ nnth-unsafe ] _ ncurry ] dip compose ; inline -: neach ( ...seq quot n -- ) +: neach ( seq... quot n -- ) (neach) each-integer ; inline -: nmap-as ( ...seq quot exemplar n -- result ) +: nmap-as ( seq... quot exemplar n -- result ) '[ _ (neach) ] dip map-integers ; inline -: nmap ( ...seq quot n -- result ) +: nmap ( seq... quot n -- result ) dup '[ [ _ npick ] dip swap ] dip nmap-as ; inline MACRO: nnew-sequence ( n -- ) [ [ drop ] ] [ dup '[ [ new-sequence ] _ apply-curry _ cleave* ] ] if-zero ; -: nnew-like ( len ...exemplar quot n -- result... ) +: nnew-like ( len exemplar... quot n -- result... ) 5 dupn '[ _ nover [ [ _ nnew-sequence ] dip call ] @@ -45,10 +45,10 @@ MACRO: (ncollect) ( n -- ) 3 dupn 1 + '[ [ [ keep ] _ ndip _ nset-nth-unsafe ] _ ncurry ] ; -: ncollect ( len quot ...into n -- ) +: ncollect ( len quot into... n -- ) (ncollect) each-integer ; inline -: nmap-integers ( len quot ...exemplar n -- result... ) +: nmap-integers ( len quot exemplar... n -- result... ) 4 dupn '[ [ over ] _ ndip [ [ _ ncollect ] _ nkeep ] _ nnew-like ] call ; inline @@ -58,7 +58,7 @@ MACRO: (ncollect) ( n -- ) : mnmap ( m*seq quot m n -- result*n ) 2dup '[ [ _ npick ] dip swap _ dupn ] 2dip mnmap-as ; inline -: ncollector-for ( quot ...exemplar n -- quot' vec... ) +: ncollector-for ( quot exemplar... n -- quot' vec... ) 5 dupn '[ [ [ length ] keep new-resizable ] _ napply [ [ [ push ] _ apply-curry _ spread* ] _ ncurry compose ] _ nkeep @@ -67,7 +67,7 @@ MACRO: (ncollect) ( n -- ) : ncollector ( quot n -- quot' vec... ) [ V{ } swap dupn ] keep ncollector-for ; inline -: nproduce-as ( pred quot ...exemplar n -- seq... ) +: nproduce-as ( pred quot exemplar... n -- seq... ) 7 dupn '[ _ ndup [ _ ncollector-for [ while ] _ ndip ] From 4892bf1d47833dbf56767a7ca10df7cc563d82d2 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 5 Mar 2010 14:27:36 -0800 Subject: [PATCH 322/713] refactor stack-checker slightly to fix circular dependency --- basis/stack-checker/backend/backend.factor | 3 +++ basis/stack-checker/row-polymorphism/row-polymorphism.factor | 4 ++-- basis/stack-checker/stack-checker.factor | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/basis/stack-checker/backend/backend.factor b/basis/stack-checker/backend/backend.factor index 8de930a6cd..15fa9f588a 100644 --- a/basis/stack-checker/backend/backend.factor +++ b/basis/stack-checker/backend/backend.factor @@ -157,3 +157,6 @@ M: bad-call summary current-effect stack-visitor get ] with-scope ; inline + +: (infer) ( quot -- effect ) + [ infer-quot-here ] with-infer drop ; diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index a01d0caaf9..6557a26393 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -1,7 +1,7 @@ ! (c)2010 Joe Groff bsd license USING: accessors arrays assocs combinators combinators.short-circuit continuations effects fry kernel locals math namespaces -quotations sequences splitting stack-checker +quotations sequences splitting stack-checker.backend stack-checker.errors stack-checker.known-words @@ -68,7 +68,7 @@ GENERIC: (infer-known) ( known -- effect ) M: object (infer-known) current-word get bad-macro-input ; M: literal (infer-known) - value>> dup callable? [ infer ] [ abandon-check ] if ; + value>> dup callable? [ (infer) ] [ abandon-check ] if ; M: composed (infer-known) [ quot1>> known (infer-known) ] [ quot2>> known (infer-known) ] bi compose-effects ; M: curried (infer-known) diff --git a/basis/stack-checker/stack-checker.factor b/basis/stack-checker/stack-checker.factor index 12e8660900..beb5026a2b 100644 --- a/basis/stack-checker/stack-checker.factor +++ b/basis/stack-checker/stack-checker.factor @@ -11,7 +11,7 @@ IN: stack-checker GENERIC: infer ( quot -- effect ) M: callable infer ( quot -- effect ) - [ infer-quot-here ] with-infer drop ; + (infer) ; : infer. ( quot -- ) #! Safe to call from inference transforms. From af57d4dfa98882d92195083a0bcb0cac783d2f38 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 5 Mar 2010 14:27:58 -0800 Subject: [PATCH 323/713] fix ... in compiler.cfg.linearization --- basis/compiler/cfg/linearization/linearization.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/compiler/cfg/linearization/linearization.factor b/basis/compiler/cfg/linearization/linearization.factor index 34ae7f8cc6..a0360e9d9c 100644 --- a/basis/compiler/cfg/linearization/linearization.factor +++ b/basis/compiler/cfg/linearization/linearization.factor @@ -42,7 +42,7 @@ M: ##branch linearize-insn : successors ( bb -- first second ) successors>> first2 ; inline -:: conditional ( bb insn n conditional-quot negate-cc-quot -- bb successor label ... ) +:: conditional ( bb insn n conditional-quot negate-cc-quot -- bb successor label etc... ) bb insn conditional-quot [ drop dup successors>> second useless-branch? ] 2bi From c9162c5e312e2039133c73997d92af61697f7a62 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 5 Mar 2010 14:34:50 -0800 Subject: [PATCH 324/713] fix stack error in stack-checker.row-polymorphism --- .../stack-checker/row-polymorphism/row-polymorphism.factor | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index 6557a26393..1208d67336 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -53,8 +53,10 @@ M: curried >error-quot [ 2drop ] if ; inline :: (check-input) ( declared actual -- ) - actual in>> length declared in-var>> [ check-variable ] keep :> ( in-diff in-var ) - actual out>> length declared out-var>> [ check-variable ] keep :> ( out-diff out-var ) + actual declared [ in>> length ] bi@ declared in-var>> + [ check-variable ] keep :> ( in-diff in-var ) + actual declared [ out>> length ] bi@ declared out-var>> + [ check-variable ] keep :> ( out-diff out-var ) { [ in-var not ] [ out-var not ] [ in-diff out-diff = ] } 0|| [ in-var [ in-diff swap adjust-variable ] when* From 26e4bb818af4aca8ab30fba4d809225634d7e03c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 5 Mar 2010 15:12:03 -0800 Subject: [PATCH 325/713] reuse infer-call* for polymorphic inference, which handles curried quotations. tests can pass with real "each" etc. now --- .../row-polymorphism-tests.factor | 94 +++++++------------ .../row-polymorphism/row-polymorphism.factor | 31 +++--- 2 files changed, 48 insertions(+), 77 deletions(-) diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor index 3c129e9e0c..6401258100 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor @@ -8,24 +8,6 @@ stack-checker.state stack-checker.values ; IN: stack-checker.row-polymorphism.tests -: checked-each ( ..a seq quot: ( ..a x -- ..a ) -- ..a ) - curry call ; inline - -: checked-map ( ..a seq quot: ( ..a x -- ..a y ) -- ..a seq' ) - curry call f ; inline - -: checked-map-index ( ..a seq quot: ( ..a x index -- ..a y ) -- ..a seq' ) - 0 swap 2curry call f ; inline - -: checked-if ( ..a x then: ( ..a -- ..b ) else: ( ..a -- ..b ) -- ..b ) - drop nip call ; inline - -: checked-if* ( ..a x then: ( ..a x -- ..b ) else: ( ..a -- ..b ) -- ..b ) - drop call ; inline - -: checked-with-variable ( ..a value key quot: ( ..a -- ..b ) -- ..b ) - 2nip call ; inline - : infer-polymorphic-quot ( quot -- vars ) t infer-polymorphic? [ unclip-last [ @@ -43,51 +25,47 @@ IN: stack-checker.row-polymorphism.tests : poly-infer-must-fail ( quot -- ) '[ _ infer-polymorphic-quot ] [ invalid-quotation-input? ] must-fail-with ; inline -: poly-infer-must-fail-bad-macro-input ( quot -- ) - '[ _ infer-polymorphic-quot ] [ bad-macro-input? ] must-fail-with ; inline +: poly-infer-must-fail-unknown ( quot -- ) + '[ _ infer-polymorphic-quot ] [ unknown-macro-input? ] must-fail-with ; inline -H{ { "a" 0 } } [ [ write ] checked-each ] test-poly-infer -H{ { "a" 1 } } [ [ append ] checked-each ] test-poly-infer -H{ { "a" 0 } } [ [ ] checked-map ] test-poly-infer -H{ { "a" 0 } } [ [ reverse ] checked-map ] test-poly-infer -H{ { "a" 1 } } [ [ append dup ] checked-map ] test-poly-infer -H{ { "a" 1 } } [ [ swap nth suffix dup ] checked-map-index ] test-poly-infer +H{ { "." 0 } } [ [ write ] each ] test-poly-infer +H{ { "." 1 } } [ [ append ] each ] test-poly-infer +H{ { "." 0 } } [ [ ] map ] test-poly-infer +H{ { "." 0 } } [ [ reverse ] map ] test-poly-infer +H{ { "." 1 } } [ [ append dup ] map ] test-poly-infer +H{ { "." 1 } } [ [ swap nth suffix dup ] map-index ] test-poly-infer -H{ { "a" 3 } { "b" 1 } } [ [ 2drop ] [ 2nip ] checked-if ] test-poly-infer -H{ { "a" 2 } { "b" 3 } } [ [ dup ] [ over ] checked-if ] test-poly-infer -H{ { "a" 0 } { "b" 1 } } [ [ os ] [ cpu ] checked-if ] test-poly-infer -H{ { "a" 1 } { "b" 2 } } [ [ os ] [ 1 + cpu ] checked-if ] test-poly-infer +H{ { "a" 3 } { "b" 1 } } [ [ 2drop ] [ 2nip ] if ] test-poly-infer +H{ { "a" 2 } { "b" 3 } } [ [ dup ] [ over ] if ] test-poly-infer +H{ { "a" 0 } { "b" 1 } } [ [ os ] [ cpu ] if ] test-poly-infer +H{ { "a" 1 } { "b" 2 } } [ [ os ] [ 1 + cpu ] if ] test-poly-infer -H{ { "a" 0 } { "b" 0 } } [ [ write ] [ "(f)" write ] checked-if* ] test-poly-infer -H{ { "a" 0 } { "b" 1 } } [ [ ] [ f ] checked-if* ] test-poly-infer -H{ { "a" 1 } { "b" 1 } } [ [ nip ] [ drop f ] checked-if* ] test-poly-infer -H{ { "a" 1 } { "b" 1 } } [ [ nip ] [ ] checked-if* ] test-poly-infer -H{ { "a" 2 } { "b" 2 } } [ [ 3append f ] [ ] checked-if* ] test-poly-infer -H{ { "a" 0 } { "b" 0 } } [ [ drop ] [ ] checked-if* ] test-poly-infer +H{ { "a" 0 } { "b" 0 } } [ [ write ] [ "(f)" write ] if* ] test-poly-infer +H{ { "a" 0 } { "b" 1 } } [ [ ] [ f ] if* ] test-poly-infer +H{ { "a" 1 } { "b" 1 } } [ [ nip ] [ drop f ] if* ] test-poly-infer +H{ { "a" 1 } { "b" 1 } } [ [ nip ] [ ] if* ] test-poly-infer +H{ { "a" 2 } { "b" 2 } } [ [ 3append f ] [ ] if* ] test-poly-infer +H{ { "a" 0 } { "b" 0 } } [ [ drop ] [ ] if* ] test-poly-infer -H{ { "a" 1 } { "b" 0 } } [ [ write ] checked-with-variable ] test-poly-infer -H{ { "a" 0 } { "b" 1 } } [ [ os ] checked-with-variable ] test-poly-infer -H{ { "a" 1 } { "b" 1 } } [ [ dup + ] checked-with-variable ] test-poly-infer +[ [ write write ] each ] poly-infer-must-fail +[ [ ] each ] poly-infer-must-fail +[ [ dup ] map ] poly-infer-must-fail +[ [ drop ] map ] poly-infer-must-fail +[ [ 1 + ] map-index ] poly-infer-must-fail -[ [ write write ] checked-each ] poly-infer-must-fail -[ [ ] checked-each ] poly-infer-must-fail -[ [ dup ] checked-map ] poly-infer-must-fail -[ [ drop ] checked-map ] poly-infer-must-fail -[ [ 1 + ] checked-map-index ] poly-infer-must-fail +[ [ dup ] [ ] if ] poly-infer-must-fail +[ [ 2dup ] [ over ] if ] poly-infer-must-fail +[ [ drop ] [ ] if ] poly-infer-must-fail -[ [ dup ] [ ] checked-if ] poly-infer-must-fail -[ [ 2dup ] [ over ] checked-if ] poly-infer-must-fail -[ [ drop ] [ ] checked-if ] poly-infer-must-fail +[ [ ] [ ] if* ] poly-infer-must-fail +[ [ dup ] [ ] if* ] poly-infer-must-fail +[ [ drop ] [ drop ] if* ] poly-infer-must-fail +[ [ ] [ drop ] if* ] poly-infer-must-fail +[ [ ] [ 2dup ] if* ] poly-infer-must-fail -[ [ ] [ ] checked-if* ] poly-infer-must-fail -[ [ dup ] [ ] checked-if* ] poly-infer-must-fail -[ [ drop ] [ drop ] checked-if* ] poly-infer-must-fail -[ [ ] [ drop ] checked-if* ] poly-infer-must-fail -[ [ ] [ 2dup ] checked-if* ] poly-infer-must-fail - -[ "derp" checked-each ] poly-infer-must-fail -[ checked-each ] poly-infer-must-fail-bad-macro-input -[ "derp" [ "derp" ] checked-if ] poly-infer-must-fail -[ [ "derp" ] "derp" checked-if ] poly-infer-must-fail -[ [ "derp" ] checked-if ] poly-infer-must-fail-bad-macro-input +[ "derp" each ] poly-infer-must-fail +[ each ] poly-infer-must-fail-unknown +[ "derp" [ "derp" ] if ] poly-infer-must-fail +[ [ "derp" ] "derp" if ] poly-infer-must-fail +[ [ "derp" ] if ] poly-infer-must-fail-unknown diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index 1208d67336..b1acf50551 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -5,11 +5,13 @@ quotations sequences splitting stack-checker.backend stack-checker.errors stack-checker.known-words -stack-checker.values ; +stack-checker.state +stack-checker.values +stack-checker.visitor ; IN: stack-checker.row-polymorphism error-quot : abandon-check ( -- * ) current-word get - current-effect get in>> current-meta-d get zip + current-word-effect get in>> current-meta-d get zip [ first quotation-effect? ] filter >error-branches-and-quots invalid-quotation-input ; @@ -65,23 +67,12 @@ M: curried >error-quot abandon-check ] if ; -GENERIC: (infer-known) ( known -- effect ) - -M: object (infer-known) - current-word get bad-macro-input ; -M: literal (infer-known) - value>> dup callable? [ (infer) ] [ abandon-check ] if ; -M: composed (infer-known) - [ quot1>> known (infer-known) ] [ quot2>> known (infer-known) ] bi compose-effects ; -M: curried (infer-known) - (( -- x )) swap quot>> known (infer-known) compose-effects ; - -: infer-known ( value -- effect ) - (infer-known) ; inline +: infer-value ( value -- effect ) + dup known [ nest-visitor init-inference infer-call* current-effect ] with-scope ; inline : check-input ( in value -- ) over quotation-effect? [ - [ second ] dip known infer-known (check-input) + [ second ] dip infer-value (check-input) ] [ 2drop ] if ; : normalize-variables ( -- variables' ) @@ -94,14 +85,16 @@ PRIVATE> : infer-polymorphic-vars ( effect -- variables ) H{ } clone current-effect-variables set - dup current-effect set + dup current-word-effect set in>> dup length ensure-d dup current-meta-d set [ check-input ] 2each normalize-variables ; : check-polymorphic-effect ( word -- ) current-word get [ - dup current-word set stack-effect infer-polymorphic-vars drop + dup current-word set stack-effect + dup { [ in-var>> ] [ out-var>> ] } 1|| + [ infer-polymorphic-vars ] when drop ] dip current-word set ; SYMBOL: infer-polymorphic? From 15e6a7fa5e4069f0858e7306fcd6f9f16b52e93f Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 5 Mar 2010 21:50:40 -0800 Subject: [PATCH 326/713] move error summaries for effect parsing errors to debugger vocab --- basis/debugger/debugger.factor | 4 ++++ basis/stack-checker/errors/prettyprint/prettyprint.factor | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index b6497c52a9..69156208b8 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -328,6 +328,10 @@ M: lexer-error error-help M: bad-effect summary drop "Bad stack effect declaration" ; +M: invalid-effect-variable summary + drop "Stack effect variables can only occur as the first input or output" ; +M: effect-variable-can't-have-type summary + drop "Stack effect variables cannot have a declared type" ; M: bad-escape error. "Bad escape code: \\" write diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor index 9d36e9c56c..589bd0a056 100644 --- a/basis/stack-checker/errors/prettyprint/prettyprint.factor +++ b/basis/stack-checker/errors/prettyprint/prettyprint.factor @@ -73,8 +73,3 @@ M: invalid-quotation-input error. dup summary print [ quots>> ] [ branches>> ] bi quots-and-branches. ; -M: invalid-effect-variable summary - drop "Stack effect variables can only occur as the first input or output" ; -M: effect-variable-can't-have-type summary - drop "Stack effect variables cannot have a declared type" ; - From 48b433750b08f5b79f64ff9195e389c853fe2e27 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 5 Mar 2010 21:51:13 -0800 Subject: [PATCH 327/713] clean up polymorphic stack effects in fuel --- extra/fuel/fuel.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/fuel/fuel.factor b/extra/fuel/fuel.factor index 9d47bf8cc4..1c0dc9c480 100644 --- a/extra/fuel/fuel.factor +++ b/extra/fuel/fuel.factor @@ -55,14 +55,14 @@ SYMBOL: :uses-suggestions PRIVATE> -: fuel-use-suggested-vocabs ( suggestions quot -- ... ) +: fuel-use-suggested-vocabs ( ..a suggestions quot: ( ..a -- ..b ) -- ..b ) [ :uses-suggestions set ] dip [ try-suggested-restarts rethrow ] recover ; inline : fuel-run-file ( path -- ) [ fuel-set-use-hook run-file ] curry with-scope ; inline -: fuel-with-autouse ( ... quot: ( ... -- ... ) -- ... ) +: fuel-with-autouse ( ..a quot: ( ..a -- ..b ) -- ..b ) [ auto-use? on fuel-set-use-hook call ] curry with-scope ; inline : fuel-get-uses ( lines -- ) From 9571bf6d4bb4cec39bb6695967372d001e5a7001 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 5 Mar 2010 21:51:38 -0800 Subject: [PATCH 328/713] give terminating stack effects a pass in the polymorphic checker --- .../row-polymorphism-tests.factor | 5 ++-- .../row-polymorphism/row-polymorphism.factor | 29 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor index 6401258100..ec73ec3b21 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor @@ -47,6 +47,8 @@ H{ { "a" 1 } { "b" 1 } } [ [ nip ] [ ] if* ] test-poly-infer H{ { "a" 2 } { "b" 2 } } [ [ 3append f ] [ ] if* ] test-poly-infer H{ { "a" 0 } { "b" 0 } } [ [ drop ] [ ] if* ] test-poly-infer +H{ { "a" 0 } { "b" 1 } } [ [ 1 + ] [ "oops" throw ] if* ] test-poly-infer + [ [ write write ] each ] poly-infer-must-fail [ [ ] each ] poly-infer-must-fail [ [ dup ] map ] poly-infer-must-fail @@ -63,9 +65,6 @@ H{ { "a" 0 } { "b" 0 } } [ [ drop ] [ ] if* ] test-poly-infer [ [ ] [ drop ] if* ] poly-infer-must-fail [ [ ] [ 2dup ] if* ] poly-infer-must-fail -[ "derp" each ] poly-infer-must-fail [ each ] poly-infer-must-fail-unknown -[ "derp" [ "derp" ] if ] poly-infer-must-fail -[ [ "derp" ] "derp" if ] poly-infer-must-fail [ [ "derp" ] if ] poly-infer-must-fail-unknown diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index b1acf50551..85d151d478 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -55,17 +55,19 @@ M: curried >error-quot [ 2drop ] if ; inline :: (check-input) ( declared actual -- ) - actual declared [ in>> length ] bi@ declared in-var>> - [ check-variable ] keep :> ( in-diff in-var ) - actual declared [ out>> length ] bi@ declared out-var>> - [ check-variable ] keep :> ( out-diff out-var ) - { [ in-var not ] [ out-var not ] [ in-diff out-diff = ] } 0|| - [ - in-var [ in-diff swap adjust-variable ] when* - out-var [ out-diff swap adjust-variable ] when* - ] [ - abandon-check - ] if ; + actual terminated?>> [ + actual declared [ in>> length ] bi@ declared in-var>> + [ check-variable ] keep :> ( in-diff in-var ) + actual declared [ out>> length ] bi@ declared out-var>> + [ check-variable ] keep :> ( out-diff out-var ) + { [ in-var not ] [ out-var not ] [ in-diff out-diff = ] } 0|| + [ + in-var [ in-diff swap adjust-variable ] when* + out-var [ out-diff swap adjust-variable ] when* + ] [ + abandon-check + ] if + ] unless ; : infer-value ( value -- effect ) dup known [ nest-visitor init-inference infer-call* current-effect ] with-scope ; inline @@ -92,9 +94,10 @@ PRIVATE> : check-polymorphic-effect ( word -- ) current-word get [ - dup current-word set stack-effect - dup { [ in-var>> ] [ out-var>> ] } 1|| + dup current-word set + stack-effect dup { [ in-var>> ] [ out-var>> ] } 1|| [ infer-polymorphic-vars ] when drop ] dip current-word set ; SYMBOL: infer-polymorphic? +infer-polymorphic? [ t ] initialize From 3b9d6f64a4271f29b68cfef15f955822ed2a5173 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Fri, 5 Mar 2010 22:37:10 -0800 Subject: [PATCH 329/713] Get the OpenCL driver name right on Linux, confirm test passes --- extra/opencl/ffi/ffi.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/opencl/ffi/ffi.factor b/extra/opencl/ffi/ffi.factor index b1fff5a008..90f392a22e 100644 --- a/extra/opencl/ffi/ffi.factor +++ b/extra/opencl/ffi/ffi.factor @@ -7,7 +7,7 @@ IN: opencl.ffi << "opencl" { { [ os windows? ] [ "OpenCL.dll" ] } { [ os macosx? ] [ "/System/Library/Frameworks/OpenCL.framework/OpenCL" ] } - { [ os unix? ] [ "libopencl.so" ] } + { [ os unix? ] [ "libOpenCL.so" ] } } cond "stdcall" add-library >> LIBRARY: opencl From 17df15280e6c32fae6184cb5fdd1ce1fdbc8facc Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 5 Mar 2010 22:42:05 -0800 Subject: [PATCH 330/713] generalize stack effect of while, until, and produce --- core/kernel/kernel.factor | 4 ++-- core/sequences/sequences.factor | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/kernel/kernel.factor b/core/kernel/kernel.factor index ae8763e7f8..3a53eb91e2 100644 --- a/core/kernel/kernel.factor +++ b/core/kernel/kernel.factor @@ -177,10 +177,10 @@ UNION: boolean POSTPONE: t POSTPONE: f ; : do ( pred body -- pred body ) dup 2dip ; inline -: while ( ... pred: ( ... -- ... ? ) body: ( ... -- ... ) -- ... ) +: while ( ..a pred: ( ..a -- ..b ? ) body: ( ..b -- ..a ) -- ..b ) swap do compose [ loop ] curry when ; inline -: until ( ... pred: ( ... -- ... ? ) body: ( ... -- ... ) -- ) +: until ( ..a pred: ( ..a -- ..b ? ) body: ( ..b -- ..a ) -- ..b ) [ [ not ] compose ] dip while ; inline ! Object protocol diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index cb8d2abedf..314447febf 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -513,10 +513,10 @@ PRIVATE> : collector ( quot -- quot' vec ) V{ } collector-for ; inline -: produce-as ( ... pred: ( ... -- ... ? ) quot: ( ... -- ... obj ) exemplar -- ... seq ) +: produce-as ( ..a pred: ( ..a -- ..b ? ) quot: ( ..b -- ..a obj ) exemplar -- ..b seq ) dup [ collector-for [ while ] dip ] curry dip like ; inline -: produce ( ... pred: ( ... -- ... ? ) quot: ( ... -- ... obj ) -- ... seq ) +: produce ( ..a pred: ( ..a -- ..b ? ) quot: ( ..b -- ..a obj ) -- ..b seq ) { } produce-as ; inline : follow ( ... obj quot: ( ... prev -- ... result/f ) -- ... seq ) From eff65915b0cf86f4b5ef39ccbd7b9a0402415e11 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sat, 6 Mar 2010 08:48:39 +0100 Subject: [PATCH 331/713] A* algorithm implementation --- extra/astar/astar-docs.factor | 42 +++++++++++++ extra/astar/astar-tests.factor | 109 +++++++++++++++++++++++++++++++++ extra/astar/astar.factor | 72 ++++++++++++++++++++++ extra/astar/authors.txt | 1 + extra/astar/summary.txt | 1 + 5 files changed, 225 insertions(+) create mode 100644 extra/astar/astar-docs.factor create mode 100644 extra/astar/astar-tests.factor create mode 100644 extra/astar/astar.factor create mode 100644 extra/astar/authors.txt create mode 100644 extra/astar/summary.txt diff --git a/extra/astar/astar-docs.factor b/extra/astar/astar-docs.factor new file mode 100644 index 0000000000..b8da237ed6 --- /dev/null +++ b/extra/astar/astar-docs.factor @@ -0,0 +1,42 @@ +! Copyright (C) 2010 Samuel Tardieu. +! See http://factorcode.org/license.txt for BSD license. +USING: help.markup help.syntax ; +IN: astar + +{ find-path considered } related-words + +HELP: +{ $values + { "neighbours" "a quotation with stack effect ( node -- seq )" } + { "cost" "a quotation with stack effect ( from to -- cost )" } + { "heuristic" "a quotation with stack effect ( pos target -- cost )" } + { "astar" "a astar tuple" } +} +{ $description "Build an astar object from the given quotations. The " + { $snippet "neighbours" } " one builds the list of neighbours. The " + { $snippet "cost" } " and " { $snippet "heuristic" } " ones represent " + "respectively the cost for transitioning from a node to one of its neighbour, " + "and the underestimated cost for going from a node to the target." +} ; + +HELP: find-path +{ $values + { "start" "a node" } + { "target" "a node" } + { "astar" "a astar tuple" } + { "path/f" "an optimal path from " { $snippet "start" } " to " { $snippet "target" } + ", or f if no such path exists" } +} +{ $description "Find a path between " { $snippet "start" } " and " { $snippet "target" } + " using the A* algorithm. The " { $snippet "astar" } " tuple must have been previously " + " built using " { $link } "." +} ; + +HELP: considered +{ $values + { "astar" "a astar tuple" } + { "considered" "a sequence" } +} +{ $description "When called after a call to " { $link find-path } ", return a list of nodes " + "which have been examined during the A* exploration." +} ; diff --git a/extra/astar/astar-tests.factor b/extra/astar/astar-tests.factor new file mode 100644 index 0000000000..2567ad046d --- /dev/null +++ b/extra/astar/astar-tests.factor @@ -0,0 +1,109 @@ +! Copyright (C) 2010 Samuel Tardieu. +! See http://factorcode.org/license.txt for BSD license. +USING: arrays assocs astar combinators hashtables kernel literals math math.functions +math.vectors sequences sorting splitting strings tools.test ; +IN: astar.tests + +<< + +! Use a 10x9 maze (see below) to try to go from s to e, f or g. +! X means that a position is unreachable. +! The costs model is: +! - going up costs 5 points +! - going down costs 1 point +! - going left or right costs 2 points + +: reachable? ( pos -- ? ) + first2 [ 2 * 5 + ] [ 2 + ] bi* $[ +" 0 1 2 3 4 5 6 7 8 9 + + 0 X X X X X X X X X X + 1 X s f X X + 2 X X X X X X X X X + 3 X X X X X X X X X + 4 X X X X X X + 5 X X X X X + 6 X X X X X X e X + 7 X g X X + 8 X X X X X X X X X X" + "\n" split ] nth nth CHAR: X = not ; + +: neighbours ( pos -- neighbours ) + first2 + { [ 1 + 2array ] [ 1 - 2array ] [ [ 1 + ] dip 2array ] [ [ 1 - ] dip 2array ] } 2cleave + 4array + [ reachable? ] filter ; + +: cost ( from to -- cost ) + 2dup [ first ] bi@ = [ [ second ] bi@ > 1 5 ? ] [ 2drop 2 ] if ; + +: heuristic ( pos1 pos2 -- distance ) + v- [ sq ] map sum sqrt ; + +: test1 ( to -- path considered ) + { 1 1 } swap [ neighbours ] [ cost ] [ heuristic ] [ find-path ] [ considered ] bi ; +>> + +! Existing path from s to f +[ + { + { 1 1 } + { 2 1 } + { 3 1 } + { 4 1 } + { 4 2 } + { 4 3 } + { 4 4 } + { 4 5 } + { 4 6 } + { 4 7 } + { 5 7 } + { 6 7 } + { 7 7 } + { 8 7 } + { 8 6 } + } +] [ + { 8 6 } test1 drop +] unit-test + +! Check that only the right positions have been considered in the s to f path +[ 7 ] [ { 7 1 } test1 nip length ] unit-test + +! Non-existing path from s to g -- all positions must have been considered +[ f 26 ] [ { 1 7 } test1 length ] unit-test + +<< + +! Look for a path between A and C. The best path is A --> D --> C. C will be placed +! in the open set early because B will be examined first. This checks that the evaluation +! of C is correctly replaced in the open set. +! +! We use no heuristic here and always return 0. +! +! (5) +! B ---> C <-------- +! \ (2) +! ^ ^ | +! | | | +! (1) | | (2) | +! | | | +! +! A ---> D ---------> E ---> F +! (2) (1) (1) + +: n ( pos -- neighbours ) + $[ { "ABD" "BC" "C" "DCE" "ECF" } [ unclip swap 2array ] map >hashtable ] at ; + +: c ( from to -- cost ) + "" 2sequence H{ { "AB" 1 } { "AD" 2 } { "BC" 5 } { "DC" 2 } { "DE" 1 } { "EC" 2 } { "EF" 1 } } at ; + +: test2 ( fromto -- path considered ) + first2 [ n ] [ c ] [ 2drop 0 ] [ find-path ] [ considered natural-sort >string ] bi ; +>> + +! Check path from A to C -- all nodes but F must have been examined +[ "ADC" "ABCDE" ] [ "AC" test2 [ >string ] dip ] unit-test + +! No path from D to B -- all nodes reachable from D must have been examined +[ f "CDEF" ] [ "DB" test2 ] unit-test diff --git a/extra/astar/astar.factor b/extra/astar/astar.factor new file mode 100644 index 0000000000..6a5c431ae4 --- /dev/null +++ b/extra/astar/astar.factor @@ -0,0 +1,72 @@ +! Copyright (C) 2010 Samuel Tardieu. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors arrays assocs heaps kernel math math.order sequences sets shuffle ; +IN: astar + +! This implements the A* algorithm. See http://en.wikipedia.org/wiki/A* + +> at* [ over open-set>> heap-delete ] [ drop ] if + [ swapd open-set>> heap-push* ] [ in-open-set>> set-at ] 2bi ; + +: add-to-open-set ( node astar -- ) + [ g>> at ] 2keep + [ [ goal>> ] [ heuristic>> call( n1 n2 -- c ) ] bi + ] 2keep + (add-to-open-set) ; + +: ?add-to-open-set ( node astar -- ) + 2dup in-closed-set>> key? [ 2drop ] [ add-to-open-set ] if ; + +: move-to-closed-set ( node astar -- ) + [ in-closed-set>> conjoin ] [ in-open-set>> delete-at ] 2bi ; + +: get-first ( astar -- node ) + [ open-set>> heap-pop drop dup ] [ move-to-closed-set ] bi ; + +: set-g ( origin g node astar -- ) + [ [ origin>> set-at ] [ g>> set-at ] bi-curry bi-curry bi* ] [ ?add-to-open-set ] 2bi ; + +: cost-through ( origin node astar -- cost ) + [ cost>> call( n1 n2 -- c ) ] [ nip g>> at ] 3bi + ; + +: ?set-g ( origin node astar -- ) + [ cost-through ] 3keep [ swap ] 2dip + 3dup g>> at [ 1/0. ] unless* > [ 4drop ] [ set-g ] if ; + +: build-path ( target astar -- path ) + [ over ] [ over [ [ origin>> at ] keep ] dip ] produce 2nip reverse ; + +: handle ( node astar -- ) + dupd [ neighbours>> call( node -- neighbours ) ] keep [ ?set-g ] curry with each ; + +: (find-path) ( astar -- path/f ) + dup open-set>> heap-empty? [ + drop f + ] [ + [ get-first ] keep 2dup goal>> = [ build-path ] [ [ handle ] [ (find-path) ] bi ] if + ] if ; + +: (init) ( from to astar -- ) + swap >>goal + H{ } clone >>g + H{ } clone >>origin + H{ } clone >>in-open-set + H{ } clone >>in-closed-set + >>open-set + [ 0 ] 2dip [ (add-to-open-set) ] [ g>> set-at ] 3bi ; + +PRIVATE> + +: find-path ( start target astar -- path/f ) + [ (init) ] [ (find-path) ] bi ; + +: ( neighbours cost heuristic -- astar ) + astar new swap >>heuristic swap >>cost swap >>neighbours ; + +: considered ( astar -- considered ) + in-closed-set>> keys ; diff --git a/extra/astar/authors.txt b/extra/astar/authors.txt new file mode 100644 index 0000000000..f3b0233f74 --- /dev/null +++ b/extra/astar/authors.txt @@ -0,0 +1 @@ +Samuel Tardieu diff --git a/extra/astar/summary.txt b/extra/astar/summary.txt new file mode 100644 index 0000000000..ff3167a133 --- /dev/null +++ b/extra/astar/summary.txt @@ -0,0 +1 @@ +A* path-finding algorithm From 542096b5286e7fc40e038086c3933ce49208a3a6 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sat, 6 Mar 2010 14:14:54 +0100 Subject: [PATCH 332/713] Use distance from math.vectors --- extra/astar/astar-tests.factor | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/extra/astar/astar-tests.factor b/extra/astar/astar-tests.factor index 2567ad046d..6dd27cf372 100644 --- a/extra/astar/astar-tests.factor +++ b/extra/astar/astar-tests.factor @@ -37,11 +37,8 @@ IN: astar.tests : cost ( from to -- cost ) 2dup [ first ] bi@ = [ [ second ] bi@ > 1 5 ? ] [ 2drop 2 ] if ; -: heuristic ( pos1 pos2 -- distance ) - v- [ sq ] map sum sqrt ; - : test1 ( to -- path considered ) - { 1 1 } swap [ neighbours ] [ cost ] [ heuristic ] [ find-path ] [ considered ] bi ; + { 1 1 } swap [ neighbours ] [ cost ] [ distance ] [ find-path ] [ considered ] bi ; >> ! Existing path from s to f From 0e35c883aeb04ceed9c8b1bbde8183b08d6888bd Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sat, 6 Mar 2010 14:31:46 +0100 Subject: [PATCH 333/713] Remove useless USING: --- extra/astar/astar.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/astar/astar.factor b/extra/astar/astar.factor index 6a5c431ae4..1912b6af21 100644 --- a/extra/astar/astar.factor +++ b/extra/astar/astar.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2010 Samuel Tardieu. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays assocs heaps kernel math math.order sequences sets shuffle ; +USING: accessors assocs heaps kernel math sequences sets shuffle ; IN: astar ! This implements the A* algorithm. See http://en.wikipedia.org/wiki/A* From adcf50514c6334aca97c1830553c427411507256 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sat, 6 Mar 2010 14:37:35 +0100 Subject: [PATCH 334/713] Use a better heuristic --- extra/astar/astar-tests.factor | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extra/astar/astar-tests.factor b/extra/astar/astar-tests.factor index 6dd27cf372..11b2dfcaa2 100644 --- a/extra/astar/astar-tests.factor +++ b/extra/astar/astar-tests.factor @@ -34,11 +34,14 @@ IN: astar.tests 4array [ reachable? ] filter ; +: heuristic ( from to -- cost ) + v- [ abs ] [ + ] map-reduce ; + : cost ( from to -- cost ) 2dup [ first ] bi@ = [ [ second ] bi@ > 1 5 ? ] [ 2drop 2 ] if ; : test1 ( to -- path considered ) - { 1 1 } swap [ neighbours ] [ cost ] [ distance ] [ find-path ] [ considered ] bi ; + { 1 1 } swap [ neighbours ] [ cost ] [ heuristic ] [ find-path ] [ considered ] bi ; >> ! Existing path from s to f From 68dd644233bcc0391cc6dd58cf8e2882478fca89 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 6 Mar 2010 12:28:09 -0800 Subject: [PATCH 335/713] add unit test to show that polymorphic check breaks inference of inline recursive words --- .../row-polymorphism/row-polymorphism-tests.factor | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor index ec73ec3b21..a5572336c0 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor @@ -1,11 +1,13 @@ ! (c)2010 Joe Groff bsd license -USING: effects fry io kernel math namespaces sequences -system tools.test +USING: accessors effects fry io kernel make math namespaces sequences +splitting system tools.test +stack-checker stack-checker.backend stack-checker.errors stack-checker.row-polymorphism stack-checker.state stack-checker.values ; +FROM: splitting.private => split, ; IN: stack-checker.row-polymorphism.tests : infer-polymorphic-quot ( quot -- vars ) @@ -49,6 +51,14 @@ H{ { "a" 0 } { "b" 0 } } [ [ drop ] [ ] if* ] test-poly-infer H{ { "a" 0 } { "b" 1 } } [ [ 1 + ] [ "oops" throw ] if* ] test-poly-infer +H{ } [ [ [ member? ] curry split, ] { } make ] test-poly-infer + +[ (( x x -- x )) ] [ + t infer-polymorphic? [ + [ [ [ member? ] curry split, ] { } make ] infer + ] with-variable +] unit-test + [ [ write write ] each ] poly-infer-must-fail [ [ ] each ] poly-infer-must-fail [ [ dup ] map ] poly-infer-must-fail From 211cafed4a592994370daf145de85f552869f249 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 6 Mar 2010 14:01:26 -0800 Subject: [PATCH 336/713] tag opencl.* untested --- extra/opencl/ffi/tags.txt | 1 + extra/opencl/syntax/tags.txt | 1 + extra/opencl/tags.txt | 1 + 3 files changed, 3 insertions(+) create mode 100644 extra/opencl/syntax/tags.txt diff --git a/extra/opencl/ffi/tags.txt b/extra/opencl/ffi/tags.txt index bb863cf9a0..a9d28becd8 100644 --- a/extra/opencl/ffi/tags.txt +++ b/extra/opencl/ffi/tags.txt @@ -1 +1,2 @@ bindings +untested diff --git a/extra/opencl/syntax/tags.txt b/extra/opencl/syntax/tags.txt new file mode 100644 index 0000000000..5d77766703 --- /dev/null +++ b/extra/opencl/syntax/tags.txt @@ -0,0 +1 @@ +untested diff --git a/extra/opencl/tags.txt b/extra/opencl/tags.txt index bb863cf9a0..a9d28becd8 100644 --- a/extra/opencl/tags.txt +++ b/extra/opencl/tags.txt @@ -1 +1,2 @@ bindings +untested From 339cc8f04e88b6d5fd47607c2e06ba6727f76319 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 11:44:44 -0800 Subject: [PATCH 337/713] row polymorphism new approach: wrap polymorphic quotation inputs in a "declared-effect" value. M\ declared-effect infer-call* will then assert the effect of declared-effect values during the normal course of stack inference --- basis/stack-checker/branches/branches.factor | 11 +- basis/stack-checker/inlining/inlining.factor | 2 +- .../known-words/known-words.factor | 10 ++ .../row-polymorphism-tests.factor | 80 ------------- .../row-polymorphism/row-polymorphism.factor | 108 ++++-------------- .../stack-checker/stack-checker-tests.factor | 4 +- basis/stack-checker/values/values.factor | 35 +++++- 7 files changed, 77 insertions(+), 173 deletions(-) delete mode 100644 basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor diff --git a/basis/stack-checker/branches/branches.factor b/basis/stack-checker/branches/branches.factor index 99e5a70409..2862b03f20 100644 --- a/basis/stack-checker/branches/branches.factor +++ b/basis/stack-checker/branches/branches.factor @@ -91,6 +91,9 @@ M: literal infer-branch [ value>> quotation set ] [ infer-literal-quot ] bi ] H{ } make-assoc ; +M: declared-effect infer-branch + value>> infer-branch ; + M: callable infer-branch [ copy-inference @@ -107,12 +110,18 @@ M: callable infer-branch infer-branches [ first2 #if, ] dip compute-phi-function ; +GENERIC: curried/composed? ( known -- ? ) +M: object curried/composed? drop f ; +M: curried curried/composed? drop t ; +M: composed curried/composed? drop t ; +M: declared-effect curried/composed? value>> known curried/composed? ; + : infer-if ( -- ) 2 literals-available? [ (infer-if) ] [ drop 2 consume-d - dup [ known [ curried? ] [ composed? ] bi or ] any? [ + dup [ known curried/composed? ] any? [ output-d [ rot [ drop call ] [ nip call ] if ] infer-quot-here diff --git a/basis/stack-checker/inlining/inlining.factor b/basis/stack-checker/inlining/inlining.factor index b1d6b6d9ef..c83f609868 100644 --- a/basis/stack-checker/inlining/inlining.factor +++ b/basis/stack-checker/inlining/inlining.factor @@ -142,7 +142,7 @@ SYMBOL: enter-out : inline-word ( word -- ) commit-literals [ depends-on-definition ] - [ infer-polymorphic? get [ check-polymorphic-effect ] [ drop ] if ] + [ declare-input-effects ] [ dup inline-recursive-label [ call-recursive-inline-word diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index e93dca9072..03c45b9487 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -98,6 +98,16 @@ M: composed infer-call* 1 infer->r infer-call terminated? get [ 1 infer-r> infer-call ] unless ; +: Pdeclared-effect ( x -- x ) + dup + [ word>> P. ] + [ effect>> P. ] + [ value>> known known>callable P. ] tri ; + +M: declared-effect infer-call* + Pdeclared-effect + nip value>> (infer-call) ; + M: input-parameter infer-call* \ call unknown-macro-input ; M: object infer-call* \ call bad-macro-input ; diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor deleted file mode 100644 index a5572336c0..0000000000 --- a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor +++ /dev/null @@ -1,80 +0,0 @@ -! (c)2010 Joe Groff bsd license -USING: accessors effects fry io kernel make math namespaces sequences -splitting system tools.test -stack-checker -stack-checker.backend -stack-checker.errors -stack-checker.row-polymorphism -stack-checker.state -stack-checker.values ; -FROM: splitting.private => split, ; -IN: stack-checker.row-polymorphism.tests - -: infer-polymorphic-quot ( quot -- vars ) - t infer-polymorphic? [ - unclip-last [ - dup current-word set - init-inference - init-known-values - [ [ [ set-known ] [ push-d ] bi ] each ] - [ stack-effect ] bi* - infer-polymorphic-vars - ] with-scope - ] with-variable ; - -: test-poly-infer ( effect quot -- ) - [ '[ _ ] ] [ '[ _ infer-polymorphic-quot ] ] bi* unit-test ; inline - -: poly-infer-must-fail ( quot -- ) - '[ _ infer-polymorphic-quot ] [ invalid-quotation-input? ] must-fail-with ; inline -: poly-infer-must-fail-unknown ( quot -- ) - '[ _ infer-polymorphic-quot ] [ unknown-macro-input? ] must-fail-with ; inline - -H{ { "." 0 } } [ [ write ] each ] test-poly-infer -H{ { "." 1 } } [ [ append ] each ] test-poly-infer -H{ { "." 0 } } [ [ ] map ] test-poly-infer -H{ { "." 0 } } [ [ reverse ] map ] test-poly-infer -H{ { "." 1 } } [ [ append dup ] map ] test-poly-infer -H{ { "." 1 } } [ [ swap nth suffix dup ] map-index ] test-poly-infer - -H{ { "a" 3 } { "b" 1 } } [ [ 2drop ] [ 2nip ] if ] test-poly-infer -H{ { "a" 2 } { "b" 3 } } [ [ dup ] [ over ] if ] test-poly-infer -H{ { "a" 0 } { "b" 1 } } [ [ os ] [ cpu ] if ] test-poly-infer -H{ { "a" 1 } { "b" 2 } } [ [ os ] [ 1 + cpu ] if ] test-poly-infer - -H{ { "a" 0 } { "b" 0 } } [ [ write ] [ "(f)" write ] if* ] test-poly-infer -H{ { "a" 0 } { "b" 1 } } [ [ ] [ f ] if* ] test-poly-infer -H{ { "a" 1 } { "b" 1 } } [ [ nip ] [ drop f ] if* ] test-poly-infer -H{ { "a" 1 } { "b" 1 } } [ [ nip ] [ ] if* ] test-poly-infer -H{ { "a" 2 } { "b" 2 } } [ [ 3append f ] [ ] if* ] test-poly-infer -H{ { "a" 0 } { "b" 0 } } [ [ drop ] [ ] if* ] test-poly-infer - -H{ { "a" 0 } { "b" 1 } } [ [ 1 + ] [ "oops" throw ] if* ] test-poly-infer - -H{ } [ [ [ member? ] curry split, ] { } make ] test-poly-infer - -[ (( x x -- x )) ] [ - t infer-polymorphic? [ - [ [ [ member? ] curry split, ] { } make ] infer - ] with-variable -] unit-test - -[ [ write write ] each ] poly-infer-must-fail -[ [ ] each ] poly-infer-must-fail -[ [ dup ] map ] poly-infer-must-fail -[ [ drop ] map ] poly-infer-must-fail -[ [ 1 + ] map-index ] poly-infer-must-fail - -[ [ dup ] [ ] if ] poly-infer-must-fail -[ [ 2dup ] [ over ] if ] poly-infer-must-fail -[ [ drop ] [ ] if ] poly-infer-must-fail - -[ [ ] [ ] if* ] poly-infer-must-fail -[ [ dup ] [ ] if* ] poly-infer-must-fail -[ [ drop ] [ drop ] if* ] poly-infer-must-fail -[ [ ] [ drop ] if* ] poly-infer-must-fail -[ [ ] [ 2dup ] if* ] poly-infer-must-fail - -[ each ] poly-infer-must-fail-unknown -[ [ "derp" ] if ] poly-infer-must-fail-unknown - diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index 85d151d478..5f798b1760 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -10,94 +10,26 @@ stack-checker.values stack-checker.visitor ; IN: stack-checker.row-polymorphism - d-length + n d-length < [ + d-length 1 - n - :> n' + n' meta-d [| value | + value word effect variables :> known' + :> value' + known' value' set-known + value' + ] change-nth + ] [ word unknown-macro-input ] if ; -SYMBOL: (unknown) +:: declare-input-effects ( word -- ) + H{ } clone :> variables + word stack-effect in>> [| in n | + in ?quotation-effect [| effect | + word effect variables n declare-effect-d + ] when* + ] each-index ; -GENERIC: >error-quot ( known -- quot ) - -M: object >error-quot drop (unknown) ; -M: literal >error-quot value>> ; -M: composed >error-quot - [ quot1>> known >error-quot ] [ quot2>> known >error-quot ] bi - \ compose [ ] 3sequence ; -M: curried >error-quot - [ obj>> known >error-quot ] [ quot>> known >error-quot ] bi - \ curry [ ] 3sequence ; - -: >error-branches-and-quots ( branch/values -- branches quots ) - [ [ second ] [ known >error-quot ] bi* ] assoc-map unzip ; - -: abandon-check ( -- * ) - current-word get - current-word-effect get in>> current-meta-d get zip - [ first quotation-effect? ] filter - >error-branches-and-quots - invalid-quotation-input ; - -:: check-variable ( actual-count declared-count variable -- difference ) - actual-count declared-count - - variable [ - variable current-effect-variables get at* nip - [ variable current-effect-variables get at - ] - [ variable current-effect-variables get set-at 0 ] if - ] [ - dup [ abandon-check ] unless-zero - ] if ; - -: adjust-variable ( diff var -- ) - over 0 >= - [ current-effect-variables get at+ ] - [ 2drop ] if ; inline - -:: (check-input) ( declared actual -- ) - actual terminated?>> [ - actual declared [ in>> length ] bi@ declared in-var>> - [ check-variable ] keep :> ( in-diff in-var ) - actual declared [ out>> length ] bi@ declared out-var>> - [ check-variable ] keep :> ( out-diff out-var ) - { [ in-var not ] [ out-var not ] [ in-diff out-diff = ] } 0|| - [ - in-var [ in-diff swap adjust-variable ] when* - out-var [ out-diff swap adjust-variable ] when* - ] [ - abandon-check - ] if - ] unless ; - -: infer-value ( value -- effect ) - dup known [ nest-visitor init-inference infer-call* current-effect ] with-scope ; inline - -: check-input ( in value -- ) - over quotation-effect? [ - [ second ] dip infer-value (check-input) - ] [ 2drop ] if ; - -: normalize-variables ( -- variables' ) - current-effect-variables get dup values [ - infimum dup 0 < - [ '[ _ - ] assoc-map ] [ drop ] if - ] unless-empty ; - -PRIVATE> - -: infer-polymorphic-vars ( effect -- variables ) - H{ } clone current-effect-variables set - dup current-word-effect set - in>> dup length ensure-d dup current-meta-d set - [ check-input ] 2each - normalize-variables ; - -: check-polymorphic-effect ( word -- ) - current-word get [ - dup current-word set - stack-effect dup { [ in-var>> ] [ out-var>> ] } 1|| - [ infer-polymorphic-vars ] when drop - ] dip current-word set ; - -SYMBOL: infer-polymorphic? -infer-polymorphic? [ t ] initialize diff --git a/basis/stack-checker/stack-checker-tests.factor b/basis/stack-checker/stack-checker-tests.factor index 270e5695b3..cf0210821e 100644 --- a/basis/stack-checker/stack-checker-tests.factor +++ b/basis/stack-checker/stack-checker-tests.factor @@ -378,7 +378,9 @@ DEFER: eee' [ [ cond ] infer ] [ T{ unknown-macro-input f cond } = ] must-fail-with [ [ bi ] infer ] [ T{ unknown-macro-input f call } = ] must-fail-with -[ [ each ] infer ] [ T{ unknown-macro-input f call } = ] must-fail-with + +[ [ each ] infer ] [ T{ unknown-macro-input f each } = ] must-fail-with +[ [ if* ] infer ] [ T{ unknown-macro-input f if* } = ] must-fail-with [ [ [ "OOPS" throw ] dip ] [ drop ] if ] must-infer diff --git a/basis/stack-checker/values/values.factor b/basis/stack-checker/values/values.factor index 7e11ec3edb..53f9e307eb 100644 --- a/basis/stack-checker/values/values.factor +++ b/basis/stack-checker/values/values.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2008, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors namespaces kernel assocs sequences -stack-checker.recursive-state stack-checker.errors ; +stack-checker.recursive-state stack-checker.errors +quotations ; IN: stack-checker.values ! Values @@ -97,9 +98,39 @@ M: input-parameter (literal-value?) drop f ; M: input-parameter (literal) current-word get unknown-macro-input ; +! Argument corresponding to polymorphic declared input of inline combinator + +TUPLE: declared-effect value word effect variables ; + +C: declared-effect + +M: declared-effect (input-value?) value>> input-value? ; + +M: declared-effect (literal-value?) value>> literal-value? ; + +M: declared-effect (literal) value>> literal ; + ! Computed values M: f (input-value?) drop f ; M: f (literal-value?) drop f ; -M: f (literal) current-word get bad-macro-input ; \ No newline at end of file +M: f (literal) current-word get bad-macro-input ; + +SYMBOL: (_) +ERROR: (@) ; + +GENERIC: known>callable ( known -- quot ) + +: ?@ ( x -- y ) + dup callable? [ drop [ (@) ] ] unless ; + +M: object known>callable drop (_) ; +M: literal known>callable value>> ; +M: composed known>callable + [ quot1>> known known>callable ?@ ] [ quot2>> known known>callable ?@ ] bi + append ; +M: curried known>callable + [ quot>> known known>callable ] [ obj>> known known>callable ] bi + prefix ; + From 63ad397cc1b890b2353a62ca691a6762ab9d9bb7 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 11:55:47 -0800 Subject: [PATCH 338/713] tweak recursive call site checking to consider declared-effects equivalent to their wrapped values --- basis/stack-checker/inlining/inlining.factor | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/basis/stack-checker/inlining/inlining.factor b/basis/stack-checker/inlining/inlining.factor index c83f609868..fd49fa73f0 100644 --- a/basis/stack-checker/inlining/inlining.factor +++ b/basis/stack-checker/inlining/inlining.factor @@ -119,9 +119,15 @@ SYMBOL: enter-out : trimmed-enter-out ( label -- stack ) dup enter-out>> trim-stack ; +GENERIC: (undeclared-known) ( value -- known ) +M: object (undeclared-known) ; +M: declared-effect (undeclared-known) value>> known (undeclared-known) ; + +: undeclared-known ( value -- known ) known (undeclared-known) ; + : check-call-site-stack ( label -- ) [ ] [ call-site-stack ] [ trimmed-enter-out ] tri - [ dup known [ [ known ] bi@ = ] [ 2drop t ] if ] 2all? + [ dup undeclared-known [ [ undeclared-known ] bi@ = ] [ 2drop t ] if ] 2all? [ drop ] [ word>> inconsistent-recursive-call-error inference-error ] if ; : check-call ( label -- ) From bbbda64ee74dc4b763e538970909a29811ebfa26 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 16:45:33 -0800 Subject: [PATCH 339/713] add a with-effect-here combinator that determines the effect of a scoped subset of the stack checker --- .../backend/backend-tests.factor | 1 + basis/stack-checker/backend/backend.factor | 11 ++++++-- .../known-words/known-words.factor | 25 +++++++++++++------ .../row-polymorphism/row-polymorphism.factor | 24 +++++++++++++++++- basis/stack-checker/state/state.factor | 4 ++- basis/stack-checker/values/values.factor | 2 ++ 6 files changed, 55 insertions(+), 12 deletions(-) diff --git a/basis/stack-checker/backend/backend-tests.factor b/basis/stack-checker/backend/backend-tests.factor index b58998cb49..a714ddf5ab 100644 --- a/basis/stack-checker/backend/backend-tests.factor +++ b/basis/stack-checker/backend/backend-tests.factor @@ -8,6 +8,7 @@ IN: stack-checker.backend.tests V{ } clone \ literals set H{ } clone known-values set 0 input-count set + 0 inner-d-index set ] unit-test [ 0 ] [ 0 ensure-d length ] unit-test diff --git a/basis/stack-checker/backend/backend.factor b/basis/stack-checker/backend/backend.factor index 15fa9f588a..3476866e02 100644 --- a/basis/stack-checker/backend/backend.factor +++ b/basis/stack-checker/backend/backend.factor @@ -6,6 +6,7 @@ continuations assocs combinators compiler.errors accessors math.order definitions sets hints macros stack-checker.state stack-checker.visitor stack-checker.errors stack-checker.values stack-checker.recursive-state stack-checker.dependencies summary ; +FROM: sequences.private => from-end ; IN: stack-checker.backend : push-d ( obj -- ) meta-d push ; @@ -16,8 +17,13 @@ IN: stack-checker.backend [ #introduce, ] tri ; +: update-inner-d ( new -- ) + inner-d-index get min inner-d-index set ; + : pop-d ( -- obj ) - meta-d [ dup 1array introduce-values ] [ pop ] if-empty ; + meta-d + [ dup 1array introduce-values ] + [ pop meta-d length update-inner-d ] if-empty ; : peek-d ( -- obj ) pop-d dup push-d ; @@ -30,7 +36,8 @@ IN: stack-checker.backend [ nip >array ] [ length - make-values ] [ nip delete-all ] 2tri [ introduce-values ] [ meta-d push-all ] bi meta-d push-all - ] when swap tail* ; + ] when + swap from-end [ tail ] [ update-inner-d ] bi ; : shorten-by ( n seq -- ) [ length swap - ] keep shorten ; inline diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 03c45b9487..203c4c8cb9 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -22,7 +22,8 @@ stack-checker.backend stack-checker.branches stack-checker.transforms stack-checker.dependencies -stack-checker.recursive-state ; +stack-checker.recursive-state +stack-checker.row-polymorphism ; IN: stack-checker.known-words : infer-primitive ( word -- ) @@ -98,15 +99,23 @@ M: composed infer-call* 1 infer->r infer-call terminated? get [ 1 infer-r> infer-call ] unless ; -: Pdeclared-effect ( x -- x ) - dup - [ word>> P. ] - [ effect>> P. ] - [ value>> known known>callable P. ] tri ; +! : Pdeclared-effect ( x -- x ) +! "-->" P. +! dup +! [ word>> P. ] +! [ effect>> P. ] +! [ value>> known known>callable P. ] tri +! current-effect P. ; +! +! M: declared-effect infer-call* +! [ Pdeclared-effect +! nip value>> (infer-call) ] +! [ "<--" P. +! word>> P. +! current-effect P. ] bi ; M: declared-effect infer-call* - Pdeclared-effect - nip value>> (infer-call) ; + [ nip dup value>> (infer-call) ] with-effect-here check-declared-effect ; M: input-parameter infer-call* \ call unknown-macro-input ; M: object infer-call* \ call bad-macro-input ; diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index 5f798b1760..5148efba4d 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -1,6 +1,6 @@ ! (c)2010 Joe Groff bsd license USING: accessors arrays assocs combinators combinators.short-circuit -continuations effects fry kernel locals math namespaces +continuations effects fry kernel locals math math.order namespaces quotations sequences splitting stack-checker.backend stack-checker.errors @@ -33,3 +33,25 @@ IN: stack-checker.row-polymorphism ] when* ] each-index ; +:: with-effect-here ( quot -- effect ) + inner-d-index get :> old-inner-d-index + input-count get :> old-input-count + meta-d length :> old-meta-d-length + + old-meta-d-length inner-d-index set + quot call + + inner-d-index get :> new-inner-d-index + input-count get :> new-input-count + + old-meta-d-length new-inner-d-index - + new-input-count old-input-count - + :> in + + meta-d length new-inner-d-index - :> out + + new-inner-d-index old-inner-d-index min inner-d-index set + + in "x" out "x" terminated? get ; inline + +: check-declared-effect ( known effect -- ) + [ known>callable P. ] [ P. ] bi* ; diff --git a/basis/stack-checker/state/state.factor b/basis/stack-checker/state/state.factor index 69eb590d48..3ac6a4531f 100644 --- a/basis/stack-checker/state/state.factor +++ b/basis/stack-checker/state/state.factor @@ -11,6 +11,7 @@ SYMBOL: terminated? ! Number of inputs current word expects from the stack SYMBOL: input-count +SYMBOL: inner-d-index DEFER: commit-literals @@ -46,4 +47,5 @@ SYMBOL: literals terminated? off V{ } clone \ meta-d set V{ } clone literals set - 0 input-count set ; + 0 input-count set + 0 inner-d-index set ; diff --git a/basis/stack-checker/values/values.factor b/basis/stack-checker/values/values.factor index 53f9e307eb..1590cd886d 100644 --- a/basis/stack-checker/values/values.factor +++ b/basis/stack-checker/values/values.factor @@ -133,4 +133,6 @@ M: composed known>callable M: curried known>callable [ quot>> known known>callable ] [ obj>> known known>callable ] bi prefix ; +M: declared-effect known>callable + value>> known known>callable ; From b14d59030f8fa7288a96c1931639c54d66640a10 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 17:51:41 -0800 Subject: [PATCH 340/713] add stack variable unification to M\ declared-effect infer-call* --- basis/stack-checker/errors/errors.factor | 6 +--- .../errors/prettyprint/prettyprint.factor | 5 --- .../row-polymorphism/row-polymorphism.factor | 33 ++++++++++++++++++- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/basis/stack-checker/errors/errors.factor b/basis/stack-checker/errors/errors.factor index e928c38c88..6a463b5710 100644 --- a/basis/stack-checker/errors/errors.factor +++ b/basis/stack-checker/errors/errors.factor @@ -34,9 +34,5 @@ ERROR: transform-expansion-error < inference-error error continuation word ; ERROR: bad-declaration-error < inference-error declaration ; -ERROR: invalid-quotation-input < inference-error word branches quots ; - -ERROR: invalid-effect-variable < inference-error effect ; - -ERROR: effect-variable-can't-have-type < inference-error effect ; +ERROR: invalid-quotation-input < inference-error word quot variables expected actual ; diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor index 589bd0a056..5a910af767 100644 --- a/basis/stack-checker/errors/prettyprint/prettyprint.factor +++ b/basis/stack-checker/errors/prettyprint/prettyprint.factor @@ -68,8 +68,3 @@ M: do-not-compile summary M: invalid-quotation-input summary word>> name>> "The input quotations to " " don't match their expected effects" surround ; - -M: invalid-quotation-input error. - dup summary print - [ quots>> ] [ branches>> ] bi quots-and-branches. ; - diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index 5148efba4d..406ef7aaae 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -53,5 +53,36 @@ IN: stack-checker.row-polymorphism in "x" out "x" terminated? get ; inline +:: check-variable ( actual-count declared-count variable vars -- difference ) + actual-count declared-count - + variable [ + variable vars at* nip + [ variable vars at - ] + [ variable vars set-at 0 ] if + ] [ drop 0 ] if ; + +: adjust-variable ( diff var vars -- ) + pick 0 >= + [ at+ ] + [ 3drop ] if ; inline + +:: check-variables ( vars declared actual -- ? ) + actual terminated?>> [ t ] [ + actual declared [ in>> length ] bi@ declared in-var>> + [ vars check-variable ] keep :> ( in-diff in-var ) + actual declared [ out>> length ] bi@ declared out-var>> + [ vars check-variable ] keep :> ( out-diff out-var ) + { [ in-var not ] [ out-var not ] [ in-diff out-diff = ] } 0|| + dup [ + in-var [ in-diff swap vars adjust-variable ] when* + out-var [ out-diff swap vars adjust-variable ] when* + ] when + ] if ; + : check-declared-effect ( known effect -- ) - [ known>callable P. ] [ P. ] bi* ; + 2dup [ [ variables>> ] [ effect>> ] bi ] dip check-variables + [ 2drop ] [ + [ { [ word>> ] [ known>callable ] [ variables>> ] [ effect>> ] } cleave ] + dip invalid-quotation-input + ] if ; + From 6b9a79159d6143fef25d7f9bb56f7150dece49ed Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 18:07:42 -0800 Subject: [PATCH 341/713] tweak declared-effect to wrap the existing known instead of introducing a new value, so we don't confuse the compiler --- basis/stack-checker/branches/branches.factor | 4 ++-- basis/stack-checker/inlining/inlining.factor | 2 +- basis/stack-checker/known-words/known-words.factor | 2 +- .../row-polymorphism/row-polymorphism.factor | 10 ++++------ basis/stack-checker/values/values.factor | 10 +++++----- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/basis/stack-checker/branches/branches.factor b/basis/stack-checker/branches/branches.factor index 2862b03f20..bb85ec5b1e 100644 --- a/basis/stack-checker/branches/branches.factor +++ b/basis/stack-checker/branches/branches.factor @@ -92,7 +92,7 @@ M: literal infer-branch ] H{ } make-assoc ; M: declared-effect infer-branch - value>> infer-branch ; + known>> infer-branch ; M: callable infer-branch [ @@ -114,7 +114,7 @@ GENERIC: curried/composed? ( known -- ? ) M: object curried/composed? drop f ; M: curried curried/composed? drop t ; M: composed curried/composed? drop t ; -M: declared-effect curried/composed? value>> known curried/composed? ; +M: declared-effect curried/composed? known>> curried/composed? ; : infer-if ( -- ) 2 literals-available? [ diff --git a/basis/stack-checker/inlining/inlining.factor b/basis/stack-checker/inlining/inlining.factor index fd49fa73f0..697e668409 100644 --- a/basis/stack-checker/inlining/inlining.factor +++ b/basis/stack-checker/inlining/inlining.factor @@ -121,7 +121,7 @@ SYMBOL: enter-out GENERIC: (undeclared-known) ( value -- known ) M: object (undeclared-known) ; -M: declared-effect (undeclared-known) value>> known (undeclared-known) ; +M: declared-effect (undeclared-known) known>> (undeclared-known) ; : undeclared-known ( value -- known ) known (undeclared-known) ; diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 203c4c8cb9..c2c110e6a4 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -115,7 +115,7 @@ M: composed infer-call* ! current-effect P. ] bi ; M: declared-effect infer-call* - [ nip dup value>> (infer-call) ] with-effect-here check-declared-effect ; + [ [ known>> infer-call* ] keep ] with-effect-here check-declared-effect ; M: input-parameter infer-call* \ call unknown-macro-input ; M: object infer-call* \ call bad-macro-input ; diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index 406ef7aaae..2a5696e380 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -17,12 +17,10 @@ IN: stack-checker.row-polymorphism meta-d length :> d-length n d-length < [ d-length 1 - n - :> n' - n' meta-d [| value | - value word effect variables :> known' - :> value' - known' value' set-known - value' - ] change-nth + n' meta-d nth :> value + value known :> known + known word effect variables :> known' + known' value set-known ] [ word unknown-macro-input ] if ; :: declare-input-effects ( word -- ) diff --git a/basis/stack-checker/values/values.factor b/basis/stack-checker/values/values.factor index 1590cd886d..668bdd63a8 100644 --- a/basis/stack-checker/values/values.factor +++ b/basis/stack-checker/values/values.factor @@ -100,15 +100,15 @@ M: input-parameter (literal) current-word get unknown-macro-input ; ! Argument corresponding to polymorphic declared input of inline combinator -TUPLE: declared-effect value word effect variables ; +TUPLE: declared-effect known word effect variables ; C: declared-effect -M: declared-effect (input-value?) value>> input-value? ; +M: declared-effect (input-value?) known>> (input-value?) ; -M: declared-effect (literal-value?) value>> literal-value? ; +M: declared-effect (literal-value?) known>> (literal-value?) ; -M: declared-effect (literal) value>> literal ; +M: declared-effect (literal) known>> (literal) ; ! Computed values M: f (input-value?) drop f ; @@ -134,5 +134,5 @@ M: curried known>callable [ quot>> known known>callable ] [ obj>> known known>callable ] bi prefix ; M: declared-effect known>callable - value>> known known>callable ; + known>> known>callable ; From 83c81b288fe4ee955baf0c80249583ef2e17de67 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 18:07:59 -0800 Subject: [PATCH 342/713] polymorphize splitting private combinators --- core/splitting/splitting.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/splitting/splitting.factor b/core/splitting/splitting.factor index 7b805dffe5..7e5c301711 100644 --- a/core/splitting/splitting.factor +++ b/core/splitting/splitting.factor @@ -61,7 +61,7 @@ PRIVATE> [ drop [ swap [ tail ] unless-zero , ] 2curry ] 3tri if* ; inline recursive -: split, ( seq quot -- ) [ 0 ] 2dip (split) ; inline +: split, ( ... seq quot: ( ... elt -- ... ? ) -- ... ) [ 0 ] 2dip (split) ; inline PRIVATE> From 011a39457eb32294beb7405969dab30eeefd9e91 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 18:11:44 -0800 Subject: [PATCH 343/713] clear away some rebar --- .../stack-checker/known-words/known-words.factor | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index c2c110e6a4..2c08533ebb 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -99,21 +99,6 @@ M: composed infer-call* 1 infer->r infer-call terminated? get [ 1 infer-r> infer-call ] unless ; -! : Pdeclared-effect ( x -- x ) -! "-->" P. -! dup -! [ word>> P. ] -! [ effect>> P. ] -! [ value>> known known>callable P. ] tri -! current-effect P. ; -! -! M: declared-effect infer-call* -! [ Pdeclared-effect -! nip value>> (infer-call) ] -! [ "<--" P. -! word>> P. -! current-effect P. ] bi ; - M: declared-effect infer-call* [ [ known>> infer-call* ] keep ] with-effect-here check-declared-effect ; From ea4545e3660ad5106cc5b6b421e5481d10aed364 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 18:27:55 -0800 Subject: [PATCH 344/713] improve error message for invalid quotation inputs by referencing each declared-effect to its other references --- basis/stack-checker/errors/errors.factor | 2 +- .../errors/prettyprint/prettyprint.factor | 5 +++++ .../row-polymorphism/row-polymorphism.factor | 20 ++++++++++++------- basis/stack-checker/values/values.factor | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/basis/stack-checker/errors/errors.factor b/basis/stack-checker/errors/errors.factor index 6a463b5710..3ca9cab7d9 100644 --- a/basis/stack-checker/errors/errors.factor +++ b/basis/stack-checker/errors/errors.factor @@ -34,5 +34,5 @@ ERROR: transform-expansion-error < inference-error error continuation word ; ERROR: bad-declaration-error < inference-error declaration ; -ERROR: invalid-quotation-input < inference-error word quot variables expected actual ; +ERROR: invalid-quotation-input < inference-error word quots branches ; diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor index 5a910af767..589bd0a056 100644 --- a/basis/stack-checker/errors/prettyprint/prettyprint.factor +++ b/basis/stack-checker/errors/prettyprint/prettyprint.factor @@ -68,3 +68,8 @@ M: do-not-compile summary M: invalid-quotation-input summary word>> name>> "The input quotations to " " don't match their expected effects" surround ; + +M: invalid-quotation-input error. + dup summary print + [ quots>> ] [ branches>> ] bi quots-and-branches. ; + diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index 2a5696e380..cabb69d47c 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -13,21 +13,23 @@ IN: stack-checker.row-polymorphism : ?quotation-effect ( in -- effect/f ) dup pair? [ second dup effect? [ drop f ] unless ] [ drop f ] if ; -:: declare-effect-d ( word effect variables n -- ) +:: declare-effect-d ( word effect variables branches n -- ) meta-d length :> d-length n d-length < [ d-length 1 - n - :> n' n' meta-d nth :> value value known :> known - known word effect variables :> known' + known word effect variables branches :> known' known' value set-known + known' branches push ] [ word unknown-macro-input ] if ; :: declare-input-effects ( word -- ) H{ } clone :> variables + V{ } clone :> branches word stack-effect in>> [| in n | in ?quotation-effect [| effect | - word effect variables n declare-effect-d + word effect variables branches n declare-effect-d ] when* ] each-index ; @@ -77,10 +79,14 @@ IN: stack-checker.row-polymorphism ] when ] if ; +: invalid-quotation-input* ( known -- * ) + [ word>> ] [ + branches>> + [ [ known>callable ] { } map-as ] + [ [ effect>> ] { } map-as ] bi + ] bi invalid-quotation-input ; + : check-declared-effect ( known effect -- ) 2dup [ [ variables>> ] [ effect>> ] bi ] dip check-variables - [ 2drop ] [ - [ { [ word>> ] [ known>callable ] [ variables>> ] [ effect>> ] } cleave ] - dip invalid-quotation-input - ] if ; + [ 2drop ] [ drop invalid-quotation-input* ] if ; diff --git a/basis/stack-checker/values/values.factor b/basis/stack-checker/values/values.factor index 668bdd63a8..714634bdc3 100644 --- a/basis/stack-checker/values/values.factor +++ b/basis/stack-checker/values/values.factor @@ -100,7 +100,7 @@ M: input-parameter (literal) current-word get unknown-macro-input ; ! Argument corresponding to polymorphic declared input of inline combinator -TUPLE: declared-effect known word effect variables ; +TUPLE: declared-effect known word effect variables branches ; C: declared-effect From 1512ed12f3a6817d7f9174dc97e572eb423859f4 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 18:40:58 -0800 Subject: [PATCH 345/713] further improve error message for invalid quotation inputs using a table display with the actual quotation effects determined so far --- basis/stack-checker/errors/errors.factor | 2 +- basis/stack-checker/errors/prettyprint/prettyprint.factor | 3 ++- .../stack-checker/row-polymorphism/row-polymorphism.factor | 4 +++- basis/stack-checker/values/values.factor | 7 +++++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/basis/stack-checker/errors/errors.factor b/basis/stack-checker/errors/errors.factor index 3ca9cab7d9..cfc96e621e 100644 --- a/basis/stack-checker/errors/errors.factor +++ b/basis/stack-checker/errors/errors.factor @@ -34,5 +34,5 @@ ERROR: transform-expansion-error < inference-error error continuation word ; ERROR: bad-declaration-error < inference-error declaration ; -ERROR: invalid-quotation-input < inference-error word quots branches ; +ERROR: invalid-quotation-input < inference-error word quots declareds actuals ; diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor index 589bd0a056..d3330341e3 100644 --- a/basis/stack-checker/errors/prettyprint/prettyprint.factor +++ b/basis/stack-checker/errors/prettyprint/prettyprint.factor @@ -71,5 +71,6 @@ M: invalid-quotation-input summary M: invalid-quotation-input error. dup summary print - [ quots>> ] [ branches>> ] bi quots-and-branches. ; + [ quots>> ] [ declareds>> ] [ actuals>> ] tri 3array flip + { "Input" "Expected" "Got" } prefix simple-table. ; diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index cabb69d47c..4fb54506c5 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -83,10 +83,12 @@ IN: stack-checker.row-polymorphism [ word>> ] [ branches>> [ [ known>callable ] { } map-as ] - [ [ effect>> ] { } map-as ] bi + [ [ effect>> ] { } map-as ] + [ [ actual>> ] { } map-as ] tri ] bi invalid-quotation-input ; : check-declared-effect ( known effect -- ) + [ >>actual ] keep 2dup [ [ variables>> ] [ effect>> ] bi ] dip check-variables [ 2drop ] [ drop invalid-quotation-input* ] if ; diff --git a/basis/stack-checker/values/values.factor b/basis/stack-checker/values/values.factor index 714634bdc3..e2c1ec4707 100644 --- a/basis/stack-checker/values/values.factor +++ b/basis/stack-checker/values/values.factor @@ -100,9 +100,12 @@ M: input-parameter (literal) current-word get unknown-macro-input ; ! Argument corresponding to polymorphic declared input of inline combinator -TUPLE: declared-effect known word effect variables branches ; +TUPLE: declared-effect known word effect variables branches actual ; -C: declared-effect +C: (declared-effect) declared-effect + +: ( known word effect variables branches -- declared-effect ) + f (declared-effect) ; inline M: declared-effect (input-value?) known>> (input-value?) ; From 4cd6ad840d6917f6784b108923920d96c6ec6b15 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 19:13:41 -0800 Subject: [PATCH 346/713] add tests from old row-polymorphism implementation to stack-checker unit tests --- .../stack-checker/stack-checker-tests.factor | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/basis/stack-checker/stack-checker-tests.factor b/basis/stack-checker/stack-checker-tests.factor index cf0210821e..6e2d6c467b 100644 --- a/basis/stack-checker/stack-checker-tests.factor +++ b/basis/stack-checker/stack-checker-tests.factor @@ -381,6 +381,7 @@ DEFER: eee' [ [ each ] infer ] [ T{ unknown-macro-input f each } = ] must-fail-with [ [ if* ] infer ] [ T{ unknown-macro-input f if* } = ] must-fail-with +[ [ [ "derp" ] if* ] infer ] [ T{ unknown-macro-input f if* } = ] must-fail-with [ [ [ "OOPS" throw ] dip ] [ drop ] if ] must-infer @@ -404,3 +405,46 @@ DEFER: eee' [ "special" word-prop not ] filter [ "shuffle" word-prop not ] filter ] unit-test + +{ 1 0 } [ [ drop ] each ] must-infer-as +{ 2 1 } [ [ append ] each ] must-infer-as +{ 1 1 } [ [ ] map ] must-infer-as +{ 1 1 } [ [ reverse ] map ] must-infer-as +{ 2 2 } [ [ append dup ] map ] must-infer-as +{ 2 2 } [ [ swap nth suffix dup ] map-index ] must-infer-as + +{ 4 1 } [ [ 2drop ] [ 2nip ] if ] must-infer-as +{ 3 3 } [ [ dup ] [ over ] if ] must-infer-as +{ 1 1 } [ [ 1 ] [ 0 ] if ] must-infer-as +{ 2 2 } [ [ t ] [ 1 + f ] if ] must-infer-as + +{ 1 0 } [ [ write ] [ "(f)" write ] if* ] must-infer-as +{ 1 1 } [ [ ] [ f ] if* ] must-infer-as +{ 2 1 } [ [ nip ] [ drop f ] if* ] must-infer-as +{ 2 1 } [ [ nip ] [ ] if* ] must-infer-as +{ 3 2 } [ [ 3append f ] [ ] if* ] must-infer-as +{ 1 0 } [ [ drop ] [ ] if* ] must-infer-as + +{ 1 1 } [ [ 1 + ] [ "oops" throw ] if* ] must-infer-as + +! ensure that polymorphic checking works on recursive combinators +FROM: splitting.private => split, ; +{ 2 0 } [ [ member? ] curry split, ] must-infer-as + +[ [ [ write write ] each ] infer ] [ invalid-quotation-input? ] must-fail-with + +[ [ [ ] each ] infer ] [ invalid-quotation-input? ] must-fail-with +[ [ [ dup ] map ] infer ] [ invalid-quotation-input? ] must-fail-with +[ [ [ drop ] map ] infer ] [ invalid-quotation-input? ] must-fail-with +[ [ [ 1 + ] map-index ] infer ] [ invalid-quotation-input? ] must-fail-with + +[ [ [ dup ] [ ] if ] infer ] [ invalid-quotation-input? ] must-fail-with +[ [ [ 2dup ] [ over ] if ] infer ] [ invalid-quotation-input? ] must-fail-with +[ [ [ drop ] [ ] if ] infer ] [ invalid-quotation-input? ] must-fail-with + +[ [ [ ] [ ] if* ] infer ] [ invalid-quotation-input? ] must-fail-with +[ [ [ dup ] [ ] if* ] infer ] [ invalid-quotation-input? ] must-fail-with +[ [ [ drop ] [ drop ] if* ] infer ] [ invalid-quotation-input? ] must-fail-with +[ [ [ ] [ drop ] if* ] infer ] [ invalid-quotation-input? ] must-fail-with +[ [ [ ] [ 2dup ] if* ] infer ] [ invalid-quotation-input? ] must-fail-with + From f353b13bbc18f11b238348a35b623c50e33bd3c3 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 20:07:30 -0800 Subject: [PATCH 347/713] add unit test from quotation that fails to infer during bootstrap.compiler --- basis/stack-checker/stack-checker-tests.factor | 3 +++ 1 file changed, 3 insertions(+) diff --git a/basis/stack-checker/stack-checker-tests.factor b/basis/stack-checker/stack-checker-tests.factor index 6e2d6c467b..a2296ca84f 100644 --- a/basis/stack-checker/stack-checker-tests.factor +++ b/basis/stack-checker/stack-checker-tests.factor @@ -448,3 +448,6 @@ FROM: splitting.private => split, ; [ [ [ ] [ drop ] if* ] infer ] [ invalid-quotation-input? ] must-fail-with [ [ [ ] [ 2dup ] if* ] infer ] [ invalid-quotation-input? ] must-fail-with +! edge cases in polymorphic checking +{ 1 0 } [ [ 1 [ drop ] [ drop ] if ] each ] must-infer-as + From 66687d6b214106dfc7f496452fa6c433abc4b291 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 20:08:35 -0800 Subject: [PATCH 348/713] reuse @ and _ from fry in placeholders for invalid-quotation-input errors rather than making our own redundant placeholder symbols --- basis/stack-checker/values/values.factor | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/basis/stack-checker/values/values.factor b/basis/stack-checker/values/values.factor index e2c1ec4707..e701f297d7 100644 --- a/basis/stack-checker/values/values.factor +++ b/basis/stack-checker/values/values.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors namespaces kernel assocs sequences +USING: accessors namespaces fry kernel assocs sequences stack-checker.recursive-state stack-checker.errors quotations ; IN: stack-checker.values @@ -120,15 +120,12 @@ M: f (literal-value?) drop f ; M: f (literal) current-word get bad-macro-input ; -SYMBOL: (_) -ERROR: (@) ; - GENERIC: known>callable ( known -- quot ) : ?@ ( x -- y ) - dup callable? [ drop [ (@) ] ] unless ; + dup callable? [ drop [ @ ] ] unless ; -M: object known>callable drop (_) ; +M: object known>callable drop \ _ ; M: literal known>callable value>> ; M: composed known>callable [ quot1>> known known>callable ?@ ] [ quot2>> known known>callable ?@ ] bi From 66891135196edeebd21c8486e7640d8f597f0323 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 20:44:50 -0800 Subject: [PATCH 349/713] unify inner-d-index when unifying branches; close a few other leaks where meta-d could have been popped without updating inner-d-index --- basis/stack-checker/backend/backend.factor | 5 ++++- basis/stack-checker/branches/branches.factor | 7 +++++-- basis/stack-checker/transforms/transforms.factor | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/basis/stack-checker/backend/backend.factor b/basis/stack-checker/backend/backend.factor index 3476866e02..1de6ed0e6a 100644 --- a/basis/stack-checker/backend/backend.factor +++ b/basis/stack-checker/backend/backend.factor @@ -42,8 +42,11 @@ IN: stack-checker.backend : shorten-by ( n seq -- ) [ length swap - ] keep shorten ; inline +: shorten-d ( n -- ) + meta-d shorten-by meta-d length update-inner-d ; + : consume-d ( n -- seq ) - [ ensure-d ] [ meta-d shorten-by ] bi ; + [ ensure-d ] [ shorten-d ] bi ; : output-d ( values -- ) meta-d push-all ; diff --git a/basis/stack-checker/branches/branches.factor b/basis/stack-checker/branches/branches.factor index bb85ec5b1e..570b80f2fd 100644 --- a/basis/stack-checker/branches/branches.factor +++ b/basis/stack-checker/branches/branches.factor @@ -61,7 +61,9 @@ SYMBOL: quotations branch-variable ; : datastack-phi ( seq -- phi-in phi-out ) - [ input-count branch-variable ] [ \ meta-d active-variable ] bi + [ input-count branch-variable ] + [ inner-d-index branch-variable infimum inner-d-index set ] + [ \ meta-d active-variable ] tri unify-branches [ input-count set ] [ ] [ dup >vector \ meta-d set ] tri* ; @@ -80,7 +82,8 @@ SYMBOL: quotations : copy-inference ( -- ) \ meta-d [ clone ] change literals [ clone ] change - input-count [ ] change ; + input-count [ ] change + inner-d-index [ ] change ; GENERIC: infer-branch ( literal -- namespace ) diff --git a/basis/stack-checker/transforms/transforms.factor b/basis/stack-checker/transforms/transforms.factor index cf32792a2e..98e20e5330 100644 --- a/basis/stack-checker/transforms/transforms.factor +++ b/basis/stack-checker/transforms/transforms.factor @@ -18,7 +18,7 @@ IN: stack-checker.transforms :: ((apply-transform)) ( quot values stack rstate -- ) rstate recursive-state [ stack quot call-transformer ] with-variable - values [ length meta-d shorten-by ] [ #drop, ] bi + values [ length shorten-d ] [ #drop, ] bi rstate infer-quot ; : literal-values? ( values -- ? ) [ literal-value? ] all? ; From 9e6f84bc245bfa51063cc6079b99198ac5649280 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 21:37:24 -0800 Subject: [PATCH 350/713] declare effect on inputs to infer-if in non-literal case, so we get a better error than "unbalanced drop call/nip call" --- basis/stack-checker/backend/backend.factor | 26 ++++++++++++++++++- basis/stack-checker/branches/branches.factor | 12 +++++++-- .../row-polymorphism/row-polymorphism.factor | 23 ---------------- .../stack-checker/stack-checker-tests.factor | 2 +- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/basis/stack-checker/backend/backend.factor b/basis/stack-checker/backend/backend.factor index 1de6ed0e6a..7829f933aa 100644 --- a/basis/stack-checker/backend/backend.factor +++ b/basis/stack-checker/backend/backend.factor @@ -3,7 +3,7 @@ USING: fry arrays generic io io.streams.string kernel math namespaces parser sequences strings vectors words quotations effects classes continuations assocs combinators compiler.errors accessors math.order -definitions sets hints macros stack-checker.state +definitions locals sets hints macros stack-checker.state stack-checker.visitor stack-checker.errors stack-checker.values stack-checker.recursive-state stack-checker.dependencies summary ; FROM: sequences.private => from-end ; @@ -170,3 +170,27 @@ M: bad-call summary : (infer) ( quot -- effect ) [ infer-quot-here ] with-infer drop ; + +: ?quotation-effect ( in -- effect/f ) + dup pair? [ second dup effect? [ drop f ] unless ] [ drop f ] if ; + +:: declare-effect-d ( word effect variables branches n -- ) + meta-d length :> d-length + n d-length < [ + d-length 1 - n - :> n' + n' meta-d nth :> value + value known :> known + known word effect variables branches :> known' + known' value set-known + known' branches push + ] [ word unknown-macro-input ] if ; + +:: declare-input-effects ( word -- ) + H{ } clone :> variables + V{ } clone :> branches + word stack-effect in>> [| in n | + in ?quotation-effect [| effect | + word effect variables branches n declare-effect-d + ] when* + ] each-index ; + diff --git a/basis/stack-checker/branches/branches.factor b/basis/stack-checker/branches/branches.factor index 570b80f2fd..61730d06ec 100644 --- a/basis/stack-checker/branches/branches.factor +++ b/basis/stack-checker/branches/branches.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: fry vectors sequences assocs math math.order accessors kernel -combinators quotations namespaces grouping stack-checker.state +combinators quotations namespaces grouping locals stack-checker.state stack-checker.backend stack-checker.errors stack-checker.visitor stack-checker.values stack-checker.recursive-state ; IN: stack-checker.branches @@ -119,11 +119,19 @@ M: curried curried/composed? drop t ; M: composed curried/composed? drop t ; M: declared-effect curried/composed? known>> curried/composed? ; +:: declare-if-effects ( -- ) + H{ } clone :> variables + V{ } clone :> branches + \ if (( ..a -- ..b )) variables branches 0 declare-effect-d + \ if (( ..a -- ..b )) variables branches 1 declare-effect-d ; + : infer-if ( -- ) 2 literals-available? [ (infer-if) ] [ - drop 2 consume-d + drop 2 ensure-d + declare-if-effects + 2 shorten-d dup [ known curried/composed? ] any? [ output-d [ rot [ drop call ] [ nip call ] if ] diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index 4fb54506c5..debe014e33 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -10,29 +10,6 @@ stack-checker.values stack-checker.visitor ; IN: stack-checker.row-polymorphism -: ?quotation-effect ( in -- effect/f ) - dup pair? [ second dup effect? [ drop f ] unless ] [ drop f ] if ; - -:: declare-effect-d ( word effect variables branches n -- ) - meta-d length :> d-length - n d-length < [ - d-length 1 - n - :> n' - n' meta-d nth :> value - value known :> known - known word effect variables branches :> known' - known' value set-known - known' branches push - ] [ word unknown-macro-input ] if ; - -:: declare-input-effects ( word -- ) - H{ } clone :> variables - V{ } clone :> branches - word stack-effect in>> [| in n | - in ?quotation-effect [| effect | - word effect variables branches n declare-effect-d - ] when* - ] each-index ; - :: with-effect-here ( quot -- effect ) inner-d-index get :> old-inner-d-index input-count get :> old-input-count diff --git a/basis/stack-checker/stack-checker-tests.factor b/basis/stack-checker/stack-checker-tests.factor index a2296ca84f..b8dacdadcc 100644 --- a/basis/stack-checker/stack-checker-tests.factor +++ b/basis/stack-checker/stack-checker-tests.factor @@ -448,6 +448,6 @@ FROM: splitting.private => split, ; [ [ [ ] [ drop ] if* ] infer ] [ invalid-quotation-input? ] must-fail-with [ [ [ ] [ 2dup ] if* ] infer ] [ invalid-quotation-input? ] must-fail-with -! edge cases in polymorphic checking +! M\ declared-effect infer-call* didn't properly unify branches { 1 0 } [ [ 1 [ drop ] [ drop ] if ] each ] must-infer-as From e5c2344ce469b58082ef485faee664cdca24f0de Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 21:56:40 -0800 Subject: [PATCH 351/713] sequences: effects of push-if and push-either were too strict --- core/sequences/sequences.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 314447febf..3e0f102181 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -483,7 +483,7 @@ PRIVATE> : all? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? ) (each) all-integers? ; inline -: push-if ( ... elt quot: ( ... elt -- ... ? ) accum -- ... ) +: push-if ( ..a elt quot: ( ..a elt -- ..b ? ) accum -- ..b ) [ keep ] dip rot [ push ] [ 2drop ] if ; inline : selector-for ( quot exemplar -- selector accum ) @@ -498,7 +498,7 @@ PRIVATE> : filter ( ... seq quot: ( ... elt -- ... ? ) -- ... subseq ) over filter-as ; inline -: push-either ( ... elt quot: ( ... elt -- ... ? ) accum1 accum2 -- ... ) +: push-either ( ..a elt quot: ( ..a elt -- ..b ? ) accum1 accum2 -- ..b ) [ keep swap ] 2dip ? push ; inline : 2selector ( quot -- selector accum1 accum2 ) From 8159a191877ff24d0a1081abbeac76b25b46ef24 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 7 Mar 2010 22:23:24 -0800 Subject: [PATCH 352/713] combine unbalanced-branches-error and invalid-quotation-input into one error --- basis/stack-checker/branches/branches.factor | 10 +++++-- basis/stack-checker/errors/errors.factor | 4 +-- .../errors/prettyprint/prettyprint.factor | 15 ++-------- .../row-polymorphism/row-polymorphism.factor | 6 ++-- .../stack-checker/stack-checker-tests.factor | 28 ++++++++++--------- 5 files changed, 29 insertions(+), 34 deletions(-) diff --git a/basis/stack-checker/branches/branches.factor b/basis/stack-checker/branches/branches.factor index 61730d06ec..6f8d503c05 100644 --- a/basis/stack-checker/branches/branches.factor +++ b/basis/stack-checker/branches/branches.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: fry vectors sequences assocs math math.order accessors kernel +USING: arrays effects fry vectors sequences assocs math math.order accessors kernel combinators quotations namespaces grouping locals stack-checker.state stack-checker.backend stack-checker.errors stack-checker.visitor stack-checker.values stack-checker.recursive-state ; @@ -45,11 +45,17 @@ SYMBOLS: +bottom+ +top+ ; SYMBOL: quotations +: simple-unbalanced-branches-error ( branches quots -- * ) + [ \ if ] 2dip swap + [ length [ (( ..a -- ..b )) ] replicate ] + [ [ length [ "x" ] bi@ ] { } assoc>map ] bi + unbalanced-branches-error ; + : unify-branches ( ins stacks -- in phi-in phi-out ) zip [ 0 { } { } ] [ [ keys supremum ] [ ] [ balanced? ] tri [ dupd phi-inputs dup phi-outputs ] - [ quotations get unbalanced-branches-error ] + [ quotations get simple-unbalanced-branches-error ] if ] if-empty ; diff --git a/basis/stack-checker/errors/errors.factor b/basis/stack-checker/errors/errors.factor index cfc96e621e..58ce20035c 100644 --- a/basis/stack-checker/errors/errors.factor +++ b/basis/stack-checker/errors/errors.factor @@ -10,8 +10,6 @@ ERROR: bad-macro-input < inference-error macro ; ERROR: unknown-macro-input < inference-error macro ; -ERROR: unbalanced-branches-error < inference-error branches quots ; - ERROR: too-many->r < inference-error ; ERROR: too-many-r> < inference-error ; @@ -34,5 +32,5 @@ ERROR: transform-expansion-error < inference-error error continuation word ; ERROR: bad-declaration-error < inference-error declaration ; -ERROR: invalid-quotation-input < inference-error word quots declareds actuals ; +ERROR: unbalanced-branches-error < inference-error word quots declareds actuals ; diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor index d3330341e3..90d12c6235 100644 --- a/basis/stack-checker/errors/prettyprint/prettyprint.factor +++ b/basis/stack-checker/errors/prettyprint/prettyprint.factor @@ -10,17 +10,6 @@ M: unknown-macro-input summary M: bad-macro-input summary macro>> name>> "Cannot apply “" "” to a run-time computed value" surround ; -M: unbalanced-branches-error summary - drop "Unbalanced branches" ; - -: quots-and-branches. ( quots branches -- ) - zip [ [ first pprint-short bl ] [ second effect>string print ] bi ] each ; - -M: unbalanced-branches-error error. - dup summary print - [ quots>> ] [ branches>> [ length [ "x" ] bi@ ] { } assoc>map ] bi - quots-and-branches. ; - M: too-many->r summary drop "Quotation pushes elements on retain stack without popping them" ; @@ -65,11 +54,11 @@ M: transform-expansion-error error. M: do-not-compile summary word>> name>> "Cannot compile call to " prepend ; -M: invalid-quotation-input summary +M: unbalanced-branches-error summary word>> name>> "The input quotations to " " don't match their expected effects" surround ; -M: invalid-quotation-input error. +M: unbalanced-branches-error error. dup summary print [ quots>> ] [ declareds>> ] [ actuals>> ] tri 3array flip { "Input" "Expected" "Got" } prefix simple-table. ; diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index debe014e33..89bbbb79f0 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -56,16 +56,16 @@ IN: stack-checker.row-polymorphism ] when ] if ; -: invalid-quotation-input* ( known -- * ) +: complex-unbalanced-branches-error ( known -- * ) [ word>> ] [ branches>> [ [ known>callable ] { } map-as ] [ [ effect>> ] { } map-as ] [ [ actual>> ] { } map-as ] tri - ] bi invalid-quotation-input ; + ] bi unbalanced-branches-error ; : check-declared-effect ( known effect -- ) [ >>actual ] keep 2dup [ [ variables>> ] [ effect>> ] bi ] dip check-variables - [ 2drop ] [ drop invalid-quotation-input* ] if ; + [ 2drop ] [ drop complex-unbalanced-branches-error ] if ; diff --git a/basis/stack-checker/stack-checker-tests.factor b/basis/stack-checker/stack-checker-tests.factor index b8dacdadcc..8aa2c0c8a2 100644 --- a/basis/stack-checker/stack-checker-tests.factor +++ b/basis/stack-checker/stack-checker-tests.factor @@ -234,10 +234,12 @@ DEFER: blah4 ! Test some curry stuff { 1 1 } [ 3 [ ] curry 4 [ ] curry if ] must-infer-as +{ 3 1 } [ [ ] curry [ [ ] curry ] dip if ] must-infer-as { 2 1 } [ [ ] curry 4 [ ] curry if ] must-infer-as [ [ 3 [ ] curry 1 2 [ ] 2curry if ] infer ] [ unbalanced-branches-error? ] must-fail-with +[ [ [ ] curry [ [ ] 2curry ] dip if ] infer ] [ unbalanced-branches-error? ] must-fail-with { 1 3 } [ [ 2drop f ] assoc-find ] must-infer-as @@ -431,22 +433,22 @@ DEFER: eee' FROM: splitting.private => split, ; { 2 0 } [ [ member? ] curry split, ] must-infer-as -[ [ [ write write ] each ] infer ] [ invalid-quotation-input? ] must-fail-with +[ [ [ write write ] each ] infer ] [ unbalanced-branches-error? ] must-fail-with -[ [ [ ] each ] infer ] [ invalid-quotation-input? ] must-fail-with -[ [ [ dup ] map ] infer ] [ invalid-quotation-input? ] must-fail-with -[ [ [ drop ] map ] infer ] [ invalid-quotation-input? ] must-fail-with -[ [ [ 1 + ] map-index ] infer ] [ invalid-quotation-input? ] must-fail-with +[ [ [ ] each ] infer ] [ unbalanced-branches-error? ] must-fail-with +[ [ [ dup ] map ] infer ] [ unbalanced-branches-error? ] must-fail-with +[ [ [ drop ] map ] infer ] [ unbalanced-branches-error? ] must-fail-with +[ [ [ 1 + ] map-index ] infer ] [ unbalanced-branches-error? ] must-fail-with -[ [ [ dup ] [ ] if ] infer ] [ invalid-quotation-input? ] must-fail-with -[ [ [ 2dup ] [ over ] if ] infer ] [ invalid-quotation-input? ] must-fail-with -[ [ [ drop ] [ ] if ] infer ] [ invalid-quotation-input? ] must-fail-with +[ [ [ dup ] [ ] if ] infer ] [ unbalanced-branches-error? ] must-fail-with +[ [ [ 2dup ] [ over ] if ] infer ] [ unbalanced-branches-error? ] must-fail-with +[ [ [ drop ] [ ] if ] infer ] [ unbalanced-branches-error? ] must-fail-with -[ [ [ ] [ ] if* ] infer ] [ invalid-quotation-input? ] must-fail-with -[ [ [ dup ] [ ] if* ] infer ] [ invalid-quotation-input? ] must-fail-with -[ [ [ drop ] [ drop ] if* ] infer ] [ invalid-quotation-input? ] must-fail-with -[ [ [ ] [ drop ] if* ] infer ] [ invalid-quotation-input? ] must-fail-with -[ [ [ ] [ 2dup ] if* ] infer ] [ invalid-quotation-input? ] must-fail-with +[ [ [ ] [ ] if* ] infer ] [ unbalanced-branches-error? ] must-fail-with +[ [ [ dup ] [ ] if* ] infer ] [ unbalanced-branches-error? ] must-fail-with +[ [ [ drop ] [ drop ] if* ] infer ] [ unbalanced-branches-error? ] must-fail-with +[ [ [ ] [ drop ] if* ] infer ] [ unbalanced-branches-error? ] must-fail-with +[ [ [ ] [ 2dup ] if* ] infer ] [ unbalanced-branches-error? ] must-fail-with ! M\ declared-effect infer-call* didn't properly unify branches { 1 0 } [ [ 1 [ drop ] [ drop ] if ] each ] must-infer-as From 1669194d04a4b20f3ef09130489b29bb5c75a501 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 8 Mar 2010 03:39:29 -0600 Subject: [PATCH 353/713] Fix typedef typo in opencl --- extra/opencl/ffi/ffi.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extra/opencl/ffi/ffi.factor b/extra/opencl/ffi/ffi.factor index 90f392a22e..8f0400dd20 100644 --- a/extra/opencl/ffi/ffi.factor +++ b/extra/opencl/ffi/ffi.factor @@ -20,9 +20,9 @@ TYPEDEF: int cl_int TYPEDEF: uint cl_uint TYPEDEF: longlong cl_long TYPEDEF: ulonglong cl_ulong -TYPEDEF: ushort cl_half; -TYPEDEF: float cl_float; -TYPEDEF: double cl_double; +TYPEDEF: ushort cl_half +TYPEDEF: float cl_float +TYPEDEF: double cl_double CONSTANT: CL_CHAR_BIT 8 CONSTANT: CL_SCHAR_MAX 127 From bda1c97d21636d8510b800fc0e28f1c9f2b5e5c5 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sun, 7 Mar 2010 12:17:31 +0100 Subject: [PATCH 354/713] Project Euler : problem 265 --- extra/project-euler/265/265-tests.factor | 5 ++ extra/project-euler/265/265.factor | 63 ++++++++++++++++++++++++ extra/project-euler/project-euler.factor | 2 +- 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 extra/project-euler/265/265-tests.factor create mode 100644 extra/project-euler/265/265.factor diff --git a/extra/project-euler/265/265-tests.factor b/extra/project-euler/265/265-tests.factor new file mode 100644 index 0000000000..5e6a7f40c4 --- /dev/null +++ b/extra/project-euler/265/265-tests.factor @@ -0,0 +1,5 @@ +! Copyright (c) 2010 Samuel Tardieu. +! See http://factorcode.org/license.txt for BSD license. +USING: project-euler.265 tools.test ; + +[ 209110240768 ] [ euler265 ] unit-test diff --git a/extra/project-euler/265/265.factor b/extra/project-euler/265/265.factor new file mode 100644 index 0000000000..f9ae9393fc --- /dev/null +++ b/extra/project-euler/265/265.factor @@ -0,0 +1,63 @@ +! Copyright (c) 2010 Samuel Tardieu. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel math math.functions project-euler.common sequences sets ; +IN: project-euler.265 + +! http://projecteuler.net/index.php?section=problems&id=265 + +! 2^(N) binary digits can be placed in a circle so that all the N-digit +! clockwise subsequences are distinct. + +! For N=3, two such circular arrangements are possible, ignoring rotations. + +! For the first arrangement, the 3-digit subsequences, in clockwise order, are: +! 000, 001, 010, 101, 011, 111, 110 and 100. + +! Each circular arrangement can be encoded as a number by concatenating +! the binary digits starting with the subsequence of all zeros as the most +! significant bits and proceeding clockwise. The two arrangements for N=3 are +! thus represented as 23 and 29: +! 00010111 _(2) = 23 +! 00011101 _(2) = 29 + +! Calling S(N) the sum of the unique numeric representations, we can see that S(3) = 23 + 29 = 52. + +! Find S(5). + +CONSTANT: N 5 + +: decompose ( n -- seq ) + N iota [ drop [ 2/ ] [ 1 bitand ] bi ] map nip reverse ; + +: bits ( seq -- n ) + 0 [ [ 2 * ] [ + ] bi* ] reduce ; + +: complete ( seq -- seq' ) + unclip decompose append [ 1 bitand ] map ; + +: rotate-bits ( seq -- seq' ) + dup length iota [ cut prepend bits ] with map ; + +: ?register ( acc seq -- ) + complete rotate-bits + dup [ 2 N ^ mod ] map all-unique? [ infimum swap push ] [ 2drop ] if ; + +: add-bit ( seen bit -- seen' t/f ) + over last 2 * + 2 N ^ mod + 2dup swap member? [ drop f ] [ suffix t ] if ; + +: iterate ( acc left seen -- ) + over 0 = [ + nip ?register + ] [ + [ 1 - ] dip + { 0 1 } [ add-bit [ iterate ] [ 3drop ] if ] with with with each + ] if ; + +: euler265 ( -- answer ) + V{ } clone [ 2 N ^ N - { 0 } iterate ] [ sum ] bi ; + +! [ euler265 ] time +! Running time: 0.376389019 seconds + +SOLUTION: euler265 diff --git a/extra/project-euler/project-euler.factor b/extra/project-euler/project-euler.factor index 4131f41b1f..77017ce578 100644 --- a/extra/project-euler/project-euler.factor +++ b/extra/project-euler/project-euler.factor @@ -26,7 +26,7 @@ USING: definitions io io.files io.pathnames kernel math math.parser project-euler.134 project-euler.148 project-euler.150 project-euler.151 project-euler.164 project-euler.169 project-euler.173 project-euler.175 project-euler.186 project-euler.188 project-euler.190 project-euler.203 - project-euler.206 project-euler.215 project-euler.255 ; + project-euler.206 project-euler.215 project-euler.255 project-euler.265 ; IN: project-euler Date: Mon, 8 Mar 2010 20:26:36 +0100 Subject: [PATCH 355/713] Use a subclassed tuple with methods instead of quotations --- extra/astar/astar-docs.factor | 38 ++++++++++++++++++++++++++++++++-- extra/astar/astar.factor | 39 +++++++++++++++++++++-------------- 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/extra/astar/astar-docs.factor b/extra/astar/astar-docs.factor index b8da237ed6..b43f2aba1c 100644 --- a/extra/astar/astar-docs.factor +++ b/extra/astar/astar-docs.factor @@ -3,7 +3,40 @@ USING: help.markup help.syntax ; IN: astar -{ find-path considered } related-words +HELP: astar +{ $description "This tuple must be subclassed and its method " { $link cost } ", " + { $link heuristic } ", and " { $link neighbours } " must be implemented. " + "Alternatively, the " { $link } " word can be used to build a non-specialized version." } ; + +HELP: cost +{ $values + { "from" "a node" } + { "to" "a node" } + { "astar" "an instance of a subclassed " { $link astar } " tuple" } + { "n" "a number" } +} +{ $description "Return the cost to go from " { $snippet "from" } " to " { $snippet "to" } ". " + { $snippet "to" } " is necessarily a neighbour of " { $snippet "from" } "." +} ; + +HELP: heuristic +{ $values + { "from" "a node" } + { "to" "a node" } + { "astar" "an instance of a subclassed " { $link astar } " tuple" } + { "n" "a number" } +} +{ $description "Return the estimated (undervalued) cost to go from " { $snippet "from" } " to " { $snippet "to" } ". " + { $snippet "from" } " and " { $snippet "to" } " are not necessarily neighbours." +} ; + +HELP: neighbours +{ $values + { "node" "a node" } + { "astar" "an instance of a subclassed " { $link astar } " tuple" } + { "seq" "a sequence of nodes" } +} +{ $description "Return the list of nodes reachable from " { $snippet "node" } "." } ; HELP: { $values @@ -16,7 +49,8 @@ HELP: { $snippet "neighbours" } " one builds the list of neighbours. The " { $snippet "cost" } " and " { $snippet "heuristic" } " ones represent " "respectively the cost for transitioning from a node to one of its neighbour, " - "and the underestimated cost for going from a node to the target." + "and the underestimated cost for going from a node to the target. This solution " + "may not be as efficient as subclassing the " { $link astar } " tuple." } ; HELP: find-path diff --git a/extra/astar/astar.factor b/extra/astar/astar.factor index 1912b6af21..45f8aaa86e 100644 --- a/extra/astar/astar.factor +++ b/extra/astar/astar.factor @@ -5,44 +5,48 @@ IN: astar ! This implements the A* algorithm. See http://en.wikipedia.org/wiki/A* +TUPLE: astar g in-closed-set ; +GENERIC: cost ( from to astar -- n ) +GENERIC: heuristic ( from to astar -- n ) +GENERIC: neighbours ( node astar -- seq ) + > at* [ over open-set>> heap-delete ] [ drop ] if [ swapd open-set>> heap-push* ] [ in-open-set>> set-at ] 2bi ; : add-to-open-set ( node astar -- ) - [ g>> at ] 2keep - [ [ goal>> ] [ heuristic>> call( n1 n2 -- c ) ] bi + ] 2keep + [ astar>> g>> at ] 2keep + [ [ goal>> ] [ astar>> heuristic ] bi + ] 2keep (add-to-open-set) ; : ?add-to-open-set ( node astar -- ) - 2dup in-closed-set>> key? [ 2drop ] [ add-to-open-set ] if ; + 2dup astar>> in-closed-set>> key? [ 2drop ] [ add-to-open-set ] if ; : move-to-closed-set ( node astar -- ) - [ in-closed-set>> conjoin ] [ in-open-set>> delete-at ] 2bi ; + [ astar>> in-closed-set>> conjoin ] [ in-open-set>> delete-at ] 2bi ; : get-first ( astar -- node ) [ open-set>> heap-pop drop dup ] [ move-to-closed-set ] bi ; : set-g ( origin g node astar -- ) - [ [ origin>> set-at ] [ g>> set-at ] bi-curry bi-curry bi* ] [ ?add-to-open-set ] 2bi ; + [ [ origin>> set-at ] [ astar>> g>> set-at ] bi-curry bi-curry bi* ] [ ?add-to-open-set ] 2bi ; : cost-through ( origin node astar -- cost ) - [ cost>> call( n1 n2 -- c ) ] [ nip g>> at ] 3bi + ; + [ astar>> cost ] [ nip astar>> g>> at ] 3bi + ; : ?set-g ( origin node astar -- ) [ cost-through ] 3keep [ swap ] 2dip - 3dup g>> at [ 1/0. ] unless* > [ 4drop ] [ set-g ] if ; + 3dup astar>> g>> at [ 1/0. ] unless* > [ 4drop ] [ set-g ] if ; : build-path ( target astar -- path ) [ over ] [ over [ [ origin>> at ] keep ] dip ] produce 2nip reverse ; : handle ( node astar -- ) - dupd [ neighbours>> call( node -- neighbours ) ] keep [ ?set-g ] curry with each ; + dupd [ astar>> neighbours ] keep [ ?set-g ] curry with each ; : (find-path) ( astar -- path/f ) dup open-set>> heap-empty? [ @@ -53,20 +57,25 @@ TUPLE: astar neighbours heuristic cost : (init) ( from to astar -- ) swap >>goal - H{ } clone >>g + H{ } clone over astar>> (>>g) + H{ } clone over astar>> (>>in-closed-set) H{ } clone >>origin H{ } clone >>in-open-set - H{ } clone >>in-closed-set >>open-set - [ 0 ] 2dip [ (add-to-open-set) ] [ g>> set-at ] 3bi ; + [ 0 ] 2dip [ (add-to-open-set) ] [ astar>> g>> set-at ] 3bi ; + +TUPLE: astar-simple < astar cost heuristic neighbours ; +M: astar-simple cost cost>> call( n1 n2 -- c ) ; +M: astar-simple heuristic heuristic>> call( n1 n2 -- c ) ; +M: astar-simple neighbours neighbours>> call( n -- neighbours ) ; PRIVATE> : find-path ( start target astar -- path/f ) - [ (init) ] [ (find-path) ] bi ; + (astar) new [ (>>astar) ] keep [ (init) ] [ (find-path) ] bi ; : ( neighbours cost heuristic -- astar ) - astar new swap >>heuristic swap >>cost swap >>neighbours ; + astar-simple new swap >>heuristic swap >>cost swap >>neighbours ; : considered ( astar -- considered ) in-closed-set>> keys ; From 5597ee691f2894e8f92771fe150c3d88a3681613 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 8 Mar 2010 17:17:47 -0800 Subject: [PATCH 356/713] add documentation about stack effect variable syntax and the effect on the stack checker --- basis/stack-checker/stack-checker-docs.factor | 2 ++ core/effects/effects-docs.factor | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/basis/stack-checker/stack-checker-docs.factor b/basis/stack-checker/stack-checker-docs.factor index 5ba70ed181..4fa66f7f38 100644 --- a/basis/stack-checker/stack-checker-docs.factor +++ b/basis/stack-checker/stack-checker-docs.factor @@ -27,6 +27,8 @@ ARTICLE: "inference-combinators" "Combinator stack effects" { "If the word is declared " { $link POSTPONE: inline } ", the combinator may additionally be called on one of the word's input parameters or with quotations built from the word's input parameters, literal quotations, " { $link curry } ", and " { $link compose } ". When inline, a word is itself considered to be a combinator, and its callers must in turn satisfy these conditions." } } "If neither condition holds, the stack checker throws a " { $link unknown-macro-input } " or " { $link bad-macro-input } " error. To make the code compile, a runtime checking combinator such as " { $link POSTPONE: call( } " must be used instead. See " { $link "inference-escape" } " for details. An inline combinator can be called with an unknown quotation by " { $link curry } "ing the quotation onto a literal quotation that uses " { $link POSTPONE: call( } "." +{ $heading "Input stack effects" } +"Inline combinators will verify the stack effect of their input quotations if they are declared in the combinator's stack effect. See " { $link "effects-variables" } " for details." { $heading "Examples" } { $subheading "Calling a combinator" } "The following usage of " { $link map } " passes the stack checker, because the quotation is the result of " { $link curry } ":" diff --git a/core/effects/effects-docs.factor b/core/effects/effects-docs.factor index 134faea027..df9f6401a2 100644 --- a/core/effects/effects-docs.factor +++ b/core/effects/effects-docs.factor @@ -1,4 +1,4 @@ -USING: help.markup help.syntax math strings words kernel combinators ; +USING: help.markup help.syntax math strings words kernel combinators sequences ; IN: effects ARTICLE: "effects" "Stack effect declarations" @@ -6,11 +6,9 @@ ARTICLE: "effects" "Stack effect declarations" { $code "( input1 input2 ... -- output1 ... )" } "Stack elements in a stack effect are ordered so that the top of the stack is on the right side. Here is an example:" { $synopsis + } -"Parameters which are quotations can be declared by suffixing the parameter name with " { $snippet ":" } " and then writing a nested stack effect declaration:" +"Parameters which are quotations can be declared by suffixing the parameter name with " { $snippet ":" } " and then writing a nested stack effect declaration. If the number of inputs or outputs depends on the stack effects of quotation parameters, " { $link "effects-variables" } " can be used to declare this:" { $synopsis while } -"Only the number of inputs and outputs carries semantic meaning." -$nl -"Nested quotation declaration only has semantic meaning for " { $link POSTPONE: inline } " " { $link POSTPONE: recursive } " words. See " { $link "inference-recursive-combinators" } "." +"For words that are not " { $link POSTPONE: inline } ", only the number of inputs and outputs carries semantic meaning, and effect variables are ignored. However, nested quotation declarations are enforced for inline words. Nested quotation declarations are optional for non-recursive inline combinators and only provide better error messages. However, quotation inputs to " { $link POSTPONE: recursive } " combinators must have an effect declared. See " { $link "inference-recursive-combinators" } "." $nl "In concatenative code, input and output names are for documentation purposes only and certain conventions have been established to make them more descriptive. For code written with " { $link "locals" } ", stack values are bound to local variables named by the stack effect's input parameters." $nl @@ -29,9 +27,17 @@ $nl { { $snippet "loc" } "a screen location specified as a two-element array holding x and y co-ordinates" } { { $snippet "dim" } "a screen dimension specified as a two-element array holding width and height values" } { { $snippet "*" } "when this symbol appears by itself in the list of outputs, it means the word unconditionally throws an error" } + { { $snippet ".." } { "indicates " { $link "effects-variables" } ". only valid as the first input or first output" } } } { $see-also "inference" } ; +ARTICLE: "effects-variables" "Stack effect variables" +{ $link POSTPONE: inline } " combinators can have variable stack effects, depending on the effect of the quotation they call. For example, while " { $link each } " inputs elements of its sequence to its quotation, the quotation can also manipulate values on the stack below the element, as long as it leaves the same number of elements on the stack. This ability is used to implement " { $link reduce } " in terms of " { $snippet "each" } ". This variable stack effect is indicated by starting the list of inputs and outputs with a name starting with " { $snippet ".." } ":" +{ $synopsis each } +"In combinators with multiple quotation inputs, the number of inputs or outputs represented by a particular " { $snippet ".." } " name must match. For example, the predicate for a " { $link while } " loop can take an arbitrary number of inputs and leave an arbitrary number of outputs on the stack in addition to the predicate result; however, for the loop to leave the stack balanced, the body of the while loop must consume all of the predicate's outputs and leave a number of its own outputs equal to the initial number of stack values before the predicate was called. This is expressed with the following stack effect:" +{ $synopsis while } +"Stack effect variables can only occur as the first input or first output of a stack effect; names starting in " { $snippet ".." } " cause a syntax error if they occur elsewhere in the effect. For words that are not " { $link POSTPONE: inline } ", effect variables are currently ignored by the stack checker." ; + ABOUT: "effects" HELP: effect From cb656c6e6baefddff8b749eee62edb0b0bacf62a Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 8 Mar 2010 18:28:19 -0800 Subject: [PATCH 357/713] add polymorphic stack effects to continuations:recover, attempt-all --- core/continuations/continuations.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/continuations/continuations.factor b/core/continuations/continuations.factor index 332354e302..687f7153a1 100644 --- a/core/continuations/continuations.factor +++ b/core/continuations/continuations.factor @@ -119,7 +119,7 @@ SYMBOL: thread-error-hook ] when c> continue-with ; -: recover ( try recovery -- ) +: recover ( ..a try: ( ..a -- ..b ) recovery: ( ..a error -- ..b ) -- ..b ) [ [ swap >c call c> drop ] curry ] dip ifcc ; inline : ignore-errors ( quot -- ) @@ -130,7 +130,7 @@ SYMBOL: thread-error-hook ERROR: attempt-all-error ; -: attempt-all ( seq quot -- obj ) +: attempt-all ( ... seq quot: ( ... elt -- ... obj ) -- ... obj ) over empty? [ attempt-all-error ] [ From 10ca2ba6956f980b77d2e8a0f0f3539470ccf9a4 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 8 Mar 2010 18:55:46 -0800 Subject: [PATCH 358/713] add polymorphic effects for lexer:each-token, map-tokens --- core/lexer/lexer.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lexer/lexer.factor b/core/lexer/lexer.factor index e03cae74db..7f6324c251 100644 --- a/core/lexer/lexer.factor +++ b/core/lexer/lexer.factor @@ -100,10 +100,10 @@ PREDICATE: unexpected-eof < unexpected : (each-token) ( end quot -- pred quot ) [ [ [ scan dup ] ] dip [ = not ] curry [ [ f ] if* ] curry compose ] dip ; inline -: each-token ( end quot -- ) +: each-token ( ... end quot: ( ... token -- ... ) -- ... ) (each-token) while drop ; inline -: map-tokens ( end quot -- seq ) +: map-tokens ( ... end quot: ( ... token -- ... elt ) -- ... seq ) (each-token) produce nip ; inline : parse-tokens ( end -- seq ) From 21aa4632c844801d7dfc5b1b966a2eae667572d2 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 8 Mar 2010 19:32:25 -0800 Subject: [PATCH 359/713] refactor stack-checker.row-polymorphism a little --- .../row-polymorphism/row-polymorphism.factor | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index 89bbbb79f0..d8ba12a317 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -10,24 +10,24 @@ stack-checker.values stack-checker.visitor ; IN: stack-checker.row-polymorphism -:: with-effect-here ( quot -- effect ) +:: with-inner-d ( quot -- inner-d ) inner-d-index get :> old-inner-d-index + meta-d length inner-d-index set + quot call + inner-d-index get :> new-inner-d-index + old-inner-d-index new-inner-d-index min inner-d-index set + new-inner-d-index ; inline + +:: with-effect-here ( quot -- effect ) input-count get :> old-input-count meta-d length :> old-meta-d-length - old-meta-d-length inner-d-index set - quot call + quot with-inner-d :> inner-d - inner-d-index get :> new-inner-d-index input-count get :> new-input-count - - old-meta-d-length new-inner-d-index - + old-meta-d-length inner-d - new-input-count old-input-count - + :> in - - meta-d length new-inner-d-index - :> out - - new-inner-d-index old-inner-d-index min inner-d-index set - + meta-d length inner-d - :> out in "x" out "x" terminated? get ; inline :: check-variable ( actual-count declared-count variable vars -- difference ) From 3abf1f1ef72c7063620dc853a05d7ef4fbdf986b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 8 Mar 2010 19:44:01 -0800 Subject: [PATCH 360/713] stack-checker.row-polymorphism: modify check-variables to enforce non-polymorphic stack effects --- .../row-polymorphism/row-polymorphism.factor | 11 ++++++----- basis/stack-checker/stack-checker-tests.factor | 6 ++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index d8ba12a317..76879a3950 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -30,13 +30,14 @@ IN: stack-checker.row-polymorphism meta-d length inner-d - :> out in "x" out "x" terminated? get ; inline -:: check-variable ( actual-count declared-count variable vars -- difference ) +:: check-variable ( actual-count declared-count variable vars -- difference ? ) actual-count declared-count - variable [ variable vars at* nip [ variable vars at - ] [ variable vars set-at 0 ] if - ] [ drop 0 ] if ; + t + ] [ dup zero? ] if ; : adjust-variable ( diff var vars -- ) pick 0 >= @@ -46,10 +47,10 @@ IN: stack-checker.row-polymorphism :: check-variables ( vars declared actual -- ? ) actual terminated?>> [ t ] [ actual declared [ in>> length ] bi@ declared in-var>> - [ vars check-variable ] keep :> ( in-diff in-var ) + [ vars check-variable ] keep :> ( in-diff in-ok? in-var ) actual declared [ out>> length ] bi@ declared out-var>> - [ vars check-variable ] keep :> ( out-diff out-var ) - { [ in-var not ] [ out-var not ] [ in-diff out-diff = ] } 0|| + [ vars check-variable ] keep :> ( out-diff out-ok? out-var ) + { [ in-ok? ] [ out-ok? ] [ in-diff out-diff = ] } 0&& dup [ in-var [ in-diff swap vars adjust-variable ] when* out-var [ out-diff swap vars adjust-variable ] when* diff --git a/basis/stack-checker/stack-checker-tests.factor b/basis/stack-checker/stack-checker-tests.factor index 8aa2c0c8a2..e537a530d2 100644 --- a/basis/stack-checker/stack-checker-tests.factor +++ b/basis/stack-checker/stack-checker-tests.factor @@ -429,6 +429,12 @@ DEFER: eee' { 1 1 } [ [ 1 + ] [ "oops" throw ] if* ] must-infer-as +: strict-each ( seq quot: ( x -- ) -- ) + each ; inline + +{ 1 0 } [ [ drop ] strict-each ] must-infer-as +[ [ [ append ] strict-each ] infer ] [ unbalanced-branches-error? ] must-fail-with + ! ensure that polymorphic checking works on recursive combinators FROM: splitting.private => split, ; { 2 0 } [ [ member? ] curry split, ] must-infer-as From 191ac353fd62d886b5e0ad1e2100444e092a85d3 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 8 Mar 2010 23:38:10 -0800 Subject: [PATCH 361/713] generalize stack effects so we can bootstrap with the stricter stack effect checking --- basis/binary-search/binary-search.factor | 2 +- basis/circular/circular.factor | 4 ++-- basis/cocoa/enumeration/enumeration.factor | 6 +++--- basis/compiler/cfg/cfg.factor | 2 +- .../representations/preferred/preferred.factor | 8 ++++---- .../cfg/representations/representations.factor | 2 +- basis/compiler/cfg/rpo/rpo.factor | 4 ++-- .../cfg/ssa/construction/tdmsc/tdmsc.factor | 4 ++-- .../cfg/stacks/finalize/finalize.factor | 2 +- basis/compiler/cfg/tco/tco.factor | 4 ++-- basis/compiler/cfg/utilities/utilities.factor | 6 +++--- .../tree/combinators/combinators.factor | 8 ++++---- .../tree/escape-analysis/nodes/nodes.factor | 2 +- basis/compiler/tree/recursive/recursive.factor | 2 +- basis/compression/huffman/huffman.factor | 2 +- basis/concurrency/mailboxes/mailboxes.factor | 2 +- basis/dlists/dlists.factor | 18 +++++++++--------- basis/documents/documents.factor | 6 +++--- basis/lists/lists.factor | 10 +++++----- basis/math/rectangles/rectangles.factor | 2 +- basis/regexp/regexp.factor | 6 +++--- basis/sequences/deep/deep.factor | 16 ++++++++-------- basis/sequences/parser/parser.factor | 6 +++--- basis/sorting/insertion/insertion.factor | 2 +- basis/stack-checker/backend/backend.factor | 2 +- basis/tools/disassembler/udis/udis.factor | 2 +- core/assocs/assocs.factor | 2 +- core/combinators/combinators.factor | 2 +- core/generic/math/math.factor | 4 ++-- extra/gpu/buffers/buffers.factor | 8 ++++---- extra/math/matrices/simd/simd.factor | 4 ++-- 31 files changed, 75 insertions(+), 75 deletions(-) diff --git a/basis/binary-search/binary-search.factor b/basis/binary-search/binary-search.factor index 89a300202a..83bf9f13f4 100644 --- a/basis/binary-search/binary-search.factor +++ b/basis/binary-search/binary-search.factor @@ -21,7 +21,7 @@ DEFER: (search) : keep-searching ( seq quot -- slice ) [ dup midpoint@ ] dip call collapse-slice slice boa (search) ; inline -: (search) ( quot: ( elt -- <=> ) seq -- i elt ) +: (search) ( ... quot: ( ... elt -- ... <=> ) seq -- ... i elt ) dup length 1 <= [ finish ] [ diff --git a/basis/circular/circular.factor b/basis/circular/circular.factor index ccb70c617f..0e1fe47fbb 100644 --- a/basis/circular/circular.factor +++ b/basis/circular/circular.factor @@ -64,7 +64,7 @@ TUPLE: circular-iterator > ] [ circular>> ] bi nth ] dip call ] 2keep rot [ [ dup n>> >>last-start ] dip ] when over [ n>> ] [ [ last-start>> ] [ circular>> length ] bi + 1 - ] bi = [ @@ -75,5 +75,5 @@ TUPLE: circular-iterator PRIVATE> -: circular-while ( circular quot: ( obj -- ? ) -- ) +: circular-while ( ... circular quot: ( ... obj -- ... ? ) -- ... ) [ clone ] dip [ ] dip (circular-while) ; inline diff --git a/basis/cocoa/enumeration/enumeration.factor b/basis/cocoa/enumeration/enumeration.factor index c7bdf625d9..f4d1053f0a 100644 --- a/basis/cocoa/enumeration/enumeration.factor +++ b/basis/cocoa/enumeration/enumeration.factor @@ -15,7 +15,7 @@ CONSTANT: NS-EACH-BUFFER-SIZE 16 @ ] with-destructors ; inline -:: (NSFastEnumeration-each) ( object quot: ( elt -- ) state stackbuf count -- ) +:: (NSFastEnumeration-each) ( ... object quot: ( ... elt -- ) state stackbuf count -- ... ) object state stackbuf count -> countByEnumeratingWithState:objects:count: :> items-count items-count 0 = [ state itemsPtr>> [ items-count id ] [ stackbuf ] if* :> items @@ -23,10 +23,10 @@ CONSTANT: NS-EACH-BUFFER-SIZE 16 object quot state stackbuf count (NSFastEnumeration-each) ] unless ; inline recursive -: NSFastEnumeration-each ( object quot -- ) +: NSFastEnumeration-each ( ... object quot: ( ... elt -- ... ) -- ... ) [ (NSFastEnumeration-each) ] with-enumeration-buffers ; inline -: NSFastEnumeration-map ( object quot -- vector ) +: NSFastEnumeration-map ( ... object quot: ( ... elt -- ... newelt ) -- ... vector ) NS-EACH-BUFFER-SIZE [ '[ @ _ push ] NSFastEnumeration-each ] keep ; inline diff --git a/basis/compiler/cfg/cfg.factor b/basis/compiler/cfg/cfg.factor index 5d815e3b0f..79f3b0d1fb 100644 --- a/basis/compiler/cfg/cfg.factor +++ b/basis/compiler/cfg/cfg.factor @@ -39,7 +39,7 @@ predecessors-valid? dominance-valid? loops-valid? ; : predecessors-changed ( cfg -- cfg ) f >>predecessors-valid? ; -: with-cfg ( cfg quot: ( cfg -- ) -- ) +: with-cfg ( ..a cfg quot: ( ..a cfg -- ..b ) -- ..b ) [ dup cfg ] dip with-variable ; inline TUPLE: mr { instructions array } word label ; diff --git a/basis/compiler/cfg/representations/preferred/preferred.factor b/basis/compiler/cfg/representations/preferred/preferred.factor index 726521cfe1..9ba78dbf46 100644 --- a/basis/compiler/cfg/representations/preferred/preferred.factor +++ b/basis/compiler/cfg/representations/preferred/preferred.factor @@ -67,16 +67,16 @@ PRIVATE> tri ] with-compilation-unit -: each-def-rep ( insn vreg-quot: ( vreg rep -- ) -- ) +: each-def-rep ( ... insn vreg-quot: ( ... vreg rep -- ... ) -- ... ) [ [ defs-vreg ] [ defs-vreg-rep ] bi ] dip with when* ; inline -: each-use-rep ( insn vreg-quot: ( vreg rep -- ) -- ) +: each-use-rep ( ... insn vreg-quot: ( ... vreg rep -- ... ) -- ... ) [ [ uses-vregs ] [ uses-vreg-reps ] bi ] dip 2each ; inline -: each-temp-rep ( insn vreg-quot: ( vreg rep -- ) -- ) +: each-temp-rep ( ... insn vreg-quot: ( ... vreg rep -- ... ) -- ... ) [ [ temp-vregs ] [ temp-vreg-reps ] bi ] dip 2each ; inline -: with-vreg-reps ( cfg vreg-quot: ( vreg rep -- ) -- ) +: with-vreg-reps ( ..a cfg vreg-quot: ( ..a vreg rep -- ..b ) -- ..b ) '[ [ basic-block set ] [ [ diff --git a/basis/compiler/cfg/representations/representations.factor b/basis/compiler/cfg/representations/representations.factor index 005fe8c90b..b14390e980 100644 --- a/basis/compiler/cfg/representations/representations.factor +++ b/basis/compiler/cfg/representations/representations.factor @@ -187,7 +187,7 @@ SYMBOLS: renaming-set needs-renaming? ; : record-renaming ( from to -- ) 2array renaming-set get push needs-renaming? on ; -:: (compute-renaming-set) ( vreg required quot: ( vreg preferred required -- ) -- ) +:: (compute-renaming-set) ( ..a vreg required quot: ( ..a vreg preferred required -- ..b ) -- ..b ) vreg rep-of :> preferred preferred required eq? [ vreg no-renaming ] diff --git a/basis/compiler/cfg/rpo/rpo.factor b/basis/compiler/cfg/rpo/rpo.factor index b6322730ee..b569327c83 100644 --- a/basis/compiler/cfg/rpo/rpo.factor +++ b/basis/compiler/cfg/rpo/rpo.factor @@ -38,8 +38,8 @@ SYMBOL: visited [ drop basic-block set ] [ change-instructions drop ] 2bi ; inline -: local-optimization ( cfg quot: ( insns -- insns' ) -- cfg' ) +: local-optimization ( ... cfg quot: ( ... insns -- ... insns' ) -- ... cfg' ) dupd '[ _ optimize-basic-block ] each-basic-block ; inline : needs-post-order ( cfg -- cfg' ) - dup post-order drop ; \ No newline at end of file + dup post-order drop ; diff --git a/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor b/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor index 4b459e90fb..837b41e47f 100644 --- a/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor +++ b/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor @@ -47,7 +47,7 @@ SYMBOLS: visited merge-sets levels again? ; tmp dom-parent to tmp walk ] [ lnode ] if ; -: each-incoming-j-edge ( bb quot: ( from to -- ) -- ) +: each-incoming-j-edge ( ... bb quot: ( ... from to -- ... ) -- ... ) [ [ predecessors>> ] keep ] dip '[ _ 2dup j-edge? _ [ 2drop ] if ] each ; inline @@ -101,7 +101,7 @@ PRIVATE> [ compute-merge-set-loop ] tri ; -: merge-set-each ( bbs quot: ( bb -- ) -- ) +: merge-set-each ( ... bbs quot: ( ... bb -- ... ) -- ... ) [ (merge-set) ] dip '[ swap _ [ drop ] if ] 2each ; inline diff --git a/basis/compiler/cfg/stacks/finalize/finalize.factor b/basis/compiler/cfg/stacks/finalize/finalize.factor index f1f7880c90..ad3453704b 100644 --- a/basis/compiler/cfg/stacks/finalize/finalize.factor +++ b/basis/compiler/cfg/stacks/finalize/finalize.factor @@ -27,7 +27,7 @@ IN: compiler.cfg.stacks.finalize to dead-in to live-in to anticip-in assoc-diff assoc-diff assoc-diff ; -: each-insertion ( assoc bb quot: ( vreg loc -- ) -- ) +: each-insertion ( ... assoc bb quot: ( ... vreg loc -- ... ) -- ... ) '[ drop [ loc>vreg ] [ _ untranslate-loc ] bi @ ] assoc-each ; inline ERROR: bad-peek dst loc ; diff --git a/basis/compiler/cfg/tco/tco.factor b/basis/compiler/cfg/tco/tco.factor index 810b901013..bd8a7cf754 100644 --- a/basis/compiler/cfg/tco/tco.factor +++ b/basis/compiler/cfg/tco/tco.factor @@ -29,7 +29,7 @@ IN: compiler.cfg.tco : word-tail-call? ( bb -- ? ) instructions>> penultimate ##call? ; -: convert-tail-call ( bb quot: ( insn -- tail-insn ) -- ) +: convert-tail-call ( ..a bb quot: ( ..a insn -- ..a tail-insn ) -- ..b ) '[ instructions>> [ pop* ] [ pop ] [ ] tri @@ -65,4 +65,4 @@ IN: compiler.cfg.tco : optimize-tail-calls ( cfg -- cfg' ) dup [ optimize-tail-call ] each-basic-block - cfg-changed predecessors-changed ; \ No newline at end of file + cfg-changed predecessors-changed ; diff --git a/basis/compiler/cfg/utilities/utilities.factor b/basis/compiler/cfg/utilities/utilities.factor index 3710f4974b..bee2226ec4 100644 --- a/basis/compiler/cfg/utilities/utilities.factor +++ b/basis/compiler/cfg/utilities/utilities.factor @@ -65,14 +65,14 @@ SYMBOL: visited : cfg-has-phis? ( cfg -- ? ) post-order [ has-phis? ] any? ; -: if-has-phis ( bb quot: ( bb -- ) -- ) +: if-has-phis ( ..a bb quot: ( ..a bb -- ..b ) -- ..b ) [ dup has-phis? ] dip [ drop ] if ; inline -: each-phi ( bb quot: ( ##phi -- ) -- ) +: each-phi ( ... bb quot: ( ... ##phi -- ... ) -- ... ) [ instructions>> ] dip '[ dup ##phi? [ @ t ] [ drop f ] if ] all? drop ; inline -: each-non-phi ( bb quot: ( insn -- ) -- ) +: each-non-phi ( ... bb quot: ( ... insn -- ... ) -- ... ) [ instructions>> ] dip '[ dup ##phi? [ drop ] _ if ] each ; inline diff --git a/basis/compiler/tree/combinators/combinators.factor b/basis/compiler/tree/combinators/combinators.factor index 1fffa06336..69c48c5f94 100644 --- a/basis/compiler/tree/combinators/combinators.factor +++ b/basis/compiler/tree/combinators/combinators.factor @@ -5,7 +5,7 @@ arrays stack-checker.inlining namespaces compiler.tree math.order ; IN: compiler.tree.combinators -: each-node ( nodes quot: ( node -- ) -- ) +: each-node ( ... nodes quot: ( ... node -- ... ) -- ... ) dup dup '[ _ [ dup #branch? [ @@ -18,7 +18,7 @@ IN: compiler.tree.combinators ] bi ] each ; inline recursive -: map-nodes ( nodes quot: ( node -- node' ) -- nodes ) +: map-nodes ( ... nodes quot: ( ... node -- ... node' ) -- ... nodes ) dup dup '[ @ dup #branch? [ @@ -30,7 +30,7 @@ IN: compiler.tree.combinators ] if ] map-flat ; inline recursive -: contains-node? ( nodes quot: ( node -- ? ) -- ? ) +: contains-node? ( ... nodes quot: ( ... node -- ... ? ) -- ... ? ) dup dup '[ _ keep swap [ drop t ] [ dup #branch? [ @@ -49,7 +49,7 @@ IN: compiler.tree.combinators : sift-children ( seq flags -- seq' ) zip [ nip ] assoc-filter keys ; -: until-fixed-point ( #recursive quot: ( node -- ) -- ) +: until-fixed-point ( ... #recursive quot: ( ... node -- ... ) -- ... ) over label>> t >>fixed-point drop [ with-scope ] 2keep over label>> fixed-point>> [ 2drop ] [ until-fixed-point ] if ; diff --git a/basis/compiler/tree/escape-analysis/nodes/nodes.factor b/basis/compiler/tree/escape-analysis/nodes/nodes.factor index 3451750a34..4c9dc1ade7 100644 --- a/basis/compiler/tree/escape-analysis/nodes/nodes.factor +++ b/basis/compiler/tree/escape-analysis/nodes/nodes.factor @@ -10,7 +10,7 @@ GENERIC: escape-analysis* ( node -- ) SYMBOL: next-node -: each-with-next ( seq quot: ( elt -- ) -- ) +: each-with-next ( ... seq quot: ( ... elt -- ... ) -- ... ) dupd '[ 1 + _ ?nth next-node set @ ] each-index ; inline : (escape-analysis) ( node -- ) diff --git a/basis/compiler/tree/recursive/recursive.factor b/basis/compiler/tree/recursive/recursive.factor index bc6243e138..af76cda903 100644 --- a/basis/compiler/tree/recursive/recursive.factor +++ b/basis/compiler/tree/recursive/recursive.factor @@ -102,7 +102,7 @@ SYMBOL: changed? recursive-nesting get pop* ] each ; -: while-changing ( quot: ( -- ) -- ) +: while-changing ( ... quot: ( ... -- ... ) -- ... ) changed? off [ call ] [ changed? get [ while-changing ] [ drop ] if ] bi ; inline recursive diff --git a/basis/compression/huffman/huffman.factor b/basis/compression/huffman/huffman.factor index 9922048009..0c3db04993 100644 --- a/basis/compression/huffman/huffman.factor +++ b/basis/compression/huffman/huffman.factor @@ -30,7 +30,7 @@ TUPLE: huffman-code [ free-bits 2^ iota [ huffman-code code>> free-bits 2^ * + ] map ] [ huffman-code code>> free-bits neg 2^ /i 1array ] if ; -:: huffman-each ( tdesc quot: ( huffman-code -- ) -- ) +:: huffman-each ( ... tdesc quot: ( ... huffman-code -- ... ) -- ... ) :> code tdesc [ diff --git a/basis/concurrency/mailboxes/mailboxes.factor b/basis/concurrency/mailboxes/mailboxes.factor index 221a5a1fa3..e245f93bd5 100644 --- a/basis/concurrency/mailboxes/mailboxes.factor +++ b/basis/concurrency/mailboxes/mailboxes.factor @@ -23,7 +23,7 @@ TUPLE: mailbox threads data ; : wait-for-mailbox ( mailbox timeout -- ) [ threads>> ] dip "mailbox" wait ; -:: block-unless-pred ( mailbox timeout pred: ( message -- ? ) -- ) +:: block-unless-pred ( ... mailbox timeout pred: ( ... message -- ... ? ) -- ... ) mailbox data>> pred dlist-any? [ mailbox timeout wait-for-mailbox mailbox timeout pred block-unless-pred diff --git a/basis/dlists/dlists.factor b/basis/dlists/dlists.factor index 317ed81e3e..44140d3109 100644 --- a/basis/dlists/dlists.factor +++ b/basis/dlists/dlists.factor @@ -54,16 +54,16 @@ M: dlist-node node-value obj>> ; : set-front-to-back ( dlist -- ) dup front>> [ dup back>> >>front ] unless drop ; inline -: (dlist-find-node) ( dlist-node quot: ( node -- ? ) -- node/f ? ) +: (dlist-find-node) ( ... dlist-node quot: ( ... node -- ... ? ) -- ... node/f ? ) over [ [ call ] 2keep rot [ drop t ] [ [ next>> ] dip (dlist-find-node) ] if ] [ 2drop f f ] if ; inline recursive -: dlist-find-node ( dlist quot -- node/f ? ) +: dlist-find-node ( ... dlist quot: ( ... node -- ... ? ) -- ... node/f ? ) [ front>> ] dip (dlist-find-node) ; inline -: dlist-each-node ( dlist quot -- ) +: dlist-each-node ( ... dlist quot: ( ... node -- ... ) -- ... ) '[ @ f ] dlist-find-node 2drop ; inline : unlink-node ( dlist-node -- ) @@ -114,10 +114,10 @@ M: dlist pop-back* ( dlist -- ) ] keep normalize-front ; -: dlist-find ( dlist quot -- obj/f ? ) +: dlist-find ( ... dlist quot: ( ... value -- ... ? ) -- ... obj/f ? ) '[ obj>> @ ] dlist-find-node [ obj>> t ] [ drop f f ] if ; inline -: dlist-any? ( dlist quot -- ? ) +: dlist-any? ( ... dlist quot: ( ... value -- ... ? ) -- ... ? ) dlist-find nip ; inline M: dlist deque-member? ( value dlist -- ? ) @@ -130,7 +130,7 @@ M: dlist delete-node ( dlist-node dlist -- ) [ drop unlink-node ] } cond ; -: delete-node-if* ( dlist quot -- obj/f ? ) +: delete-node-if* ( ... dlist quot: ( ... value -- ... ? ) -- ... obj/f ? ) dupd dlist-find-node [ dup [ [ swap delete-node ] keep obj>> t @@ -141,7 +141,7 @@ M: dlist delete-node ( dlist-node dlist -- ) 2drop f f ] if ; inline -: delete-node-if ( dlist quot -- obj/f ) +: delete-node-if ( ... dlist quot: ( ... value -- ... ? ) -- ... obj/f ) '[ obj>> @ ] delete-node-if* drop ; inline M: dlist clear-deque ( dlist -- ) @@ -149,7 +149,7 @@ M: dlist clear-deque ( dlist -- ) f >>back drop ; -: dlist-each ( dlist quot -- ) +: dlist-each ( ... dlist quot: ( ... value -- ... ) -- ... ) '[ obj>> @ ] dlist-each-node ; inline : dlist>seq ( dlist -- seq ) @@ -157,7 +157,7 @@ M: dlist clear-deque ( dlist -- ) : 1dlist ( obj -- dlist ) [ push-front ] keep ; -: dlist-filter ( dlist quot -- dlist' ) +: dlist-filter ( ... dlist quot: ( ... value -- ... ? ) -- ... dlist' ) over [ '[ dup obj>> @ [ drop ] [ _ delete-node ] if ] dlist-each-node ] keep ; inline M: dlist clone diff --git a/basis/documents/documents.factor b/basis/documents/documents.factor index dcd1bf5820..e84a993eea 100644 --- a/basis/documents/documents.factor +++ b/basis/documents/documents.factor @@ -55,12 +55,12 @@ TUPLE: document < model locs undos redos inside-undo? ; to first line# = [ to second ] [ line# document doc-line length ] if ; -: each-line ( from to quot -- ) +: each-line ( ... from to quot: ( ... line -- ... ) -- ... ) 2over = [ 3drop ] [ [ [ first ] bi@ [a,b] ] dip each ] if ; inline -: map-lines ( from to quot -- results ) +: map-lines ( ... from to quot: ( ... line -- ... result ) -- ... results ) collector [ each-line ] dip ; inline : start/end-on-line ( from to line# document -- n1 n2 ) @@ -109,7 +109,7 @@ CONSTANT: doc-start { 0 0 } : entire-doc ( document -- start end document ) [ [ doc-start ] dip doc-end ] keep ; -: with-undo ( document quot: ( document -- ) -- ) +: with-undo ( ..a document quot: ( ..a document -- ..b ) -- ..b ) [ t >>inside-undo? ] dip keep f >>inside-undo? drop ; inline PRIVATE> diff --git a/basis/lists/lists.factor b/basis/lists/lists.factor index 29adcd47d6..bef9261468 100644 --- a/basis/lists/lists.factor +++ b/basis/lists/lists.factor @@ -55,16 +55,16 @@ M: object nil? drop f ; PRIVATE> -: leach ( list quot: ( elt -- ) -- ) +: leach ( ... list quot: ( ... elt -- ... ) -- ... ) over nil? [ 2drop ] [ (leach) leach ] if ; inline recursive -: lmap ( list quot: ( elt -- ) -- result ) +: lmap ( ... list quot: ( ... elt -- ... newelt ) -- ... result ) over nil? [ drop ] [ (leach) lmap cons ] if ; inline recursive -: foldl ( list identity quot: ( obj1 obj2 -- obj ) -- result ) +: foldl ( ... list identity quot: ( ... obj1 obj2 -- ... obj ) -- ... result ) swapd leach ; inline -:: foldr ( list identity quot: ( obj1 obj2 -- obj ) -- result ) +:: foldr ( ... list identity quot: ( ... obj1 obj2 -- ... obj ) -- ... result ) list nil? [ identity ] [ list cdr identity quot foldr list car quot call @@ -87,7 +87,7 @@ PRIVATE> : sequence>list ( sequence -- list ) nil [ swons ] reduce ; -: lmap>array ( list quot -- array ) +: lmap>array ( ... list quot: ( ... elt -- ... newelt ) -- ... array ) collector [ leach ] dip { } like ; inline : list>array ( list -- array ) diff --git a/basis/math/rectangles/rectangles.factor b/basis/math/rectangles/rectangles.factor index bfde391884..db3794cbb0 100644 --- a/basis/math/rectangles/rectangles.factor +++ b/basis/math/rectangles/rectangles.factor @@ -20,7 +20,7 @@ SYNTAX: RECT: scan-object scan-object suffix! ; : rect-center ( rect -- center ) rect-bounds 2 v/n v+ ; -: with-rect-extents ( rect1 rect2 loc-quot: ( loc1 loc2 -- ) ext-quot: ( ext1 ext2 -- ) -- ) +: with-rect-extents ( ..a+b rect1 rect2 loc-quot: ( ..a loc1 loc2 -- ..c ) ext-quot: ( ..b ext1 ext2 -- ..d ) -- ..c+d ) [ [ rect-extent ] bi@ ] 2dip bi-curry* bi* ; inline : ( loc ext -- rect ) over [v-] ; diff --git a/basis/regexp/regexp.factor b/basis/regexp/regexp.factor index 0b387acd2a..e5ac1df151 100644 --- a/basis/regexp/regexp.factor +++ b/basis/regexp/regexp.factor @@ -69,7 +69,7 @@ PRIVATE> dup next-match>> execute( i string regexp -- i start end ? ) ; inline -:: (each-match) ( i string regexp quot: ( start end string -- ) -- ) +:: (each-match) ( ... i string regexp quot: ( ... start end string -- ... ) -- ... ) i string regexp do-next-match [| i' start end | start end string quot call i' string regexp quot (each-match) @@ -80,10 +80,10 @@ PRIVATE> PRIVATE> -: each-match ( string regexp quot: ( start end string -- ) -- ) +: each-match ( ... string regexp quot: ( ... start end string -- ... ) -- ... ) [ prepare-match-iterator ] dip (each-match) ; inline -: map-matches ( string regexp quot: ( start end string -- obj ) -- seq ) +: map-matches ( ... string regexp quot: ( ... start end string -- ... obj ) -- ... seq ) collector [ each-match ] dip >array ; inline : all-matching-slices ( string regexp -- seq ) diff --git a/basis/sequences/deep/deep.factor b/basis/sequences/deep/deep.factor index c79d0b2002..6238962b6c 100644 --- a/basis/sequences/deep/deep.factor +++ b/basis/sequences/deep/deep.factor @@ -12,30 +12,30 @@ M: integer branch? drop f ; M: string branch? drop f ; M: object branch? drop f ; -: deep-each ( obj quot: ( elt -- ) -- ) +: deep-each ( ... obj quot: ( ... elt -- ... ) -- ... ) [ call ] 2keep over branch? [ '[ _ deep-each ] each ] [ 2drop ] if ; inline recursive -: deep-map ( obj quot: ( elt -- elt' ) -- newobj ) +: deep-map ( ... obj quot: ( ... elt -- ... elt' ) -- ... newobj ) [ call ] keep over branch? [ '[ _ deep-map ] map ] [ drop ] if ; inline recursive -: deep-filter ( obj quot: ( elt -- ? ) -- seq ) +: deep-filter ( ... obj quot: ( ... elt -- ... ? ) -- ... seq ) over [ selector [ deep-each ] dip ] dip dup branch? [ like ] [ drop ] if ; inline recursive -: (deep-find) ( obj quot: ( elt -- ? ) -- elt ? ) +: (deep-find) ( ... obj quot: ( ... elt -- ... ? ) -- ... elt ? ) [ call ] 2keep rot [ drop t ] [ over branch? [ [ f ] 2dip '[ nip _ (deep-find) ] find drop >boolean ] [ 2drop f f ] if ] if ; inline recursive -: deep-find ( obj quot -- elt ) (deep-find) drop ; inline +: deep-find ( ... obj quot: ( ... elt -- ... ? ) -- ... elt ) (deep-find) drop ; inline -: deep-any? ( obj quot -- ? ) (deep-find) nip ; inline +: deep-any? ( ... obj quot: ( ... elt -- ... ? ) -- ... ? ) (deep-find) nip ; inline -: deep-all? ( obj quot -- ? ) +: deep-all? ( ... obj quot: ( ... elt -- ... ? ) -- ... ? ) '[ @ not ] deep-any? not ; inline : deep-member? ( obj seq -- ? ) @@ -48,7 +48,7 @@ M: object branch? drop f ; _ swap dup branch? [ subseq? ] [ 2drop f ] if ] deep-find >boolean ; -: deep-map! ( obj quot: ( elt -- elt' ) -- obj ) +: deep-map! ( ... obj quot: ( ... elt -- ... elt' ) -- ... obj ) over branch? [ '[ _ [ call ] keep over [ deep-map! drop ] dip ] map! ] [ drop ] if ; inline recursive diff --git a/basis/sequences/parser/parser.factor b/basis/sequences/parser/parser.factor index 44fa75239c..322d4cf488 100644 --- a/basis/sequences/parser/parser.factor +++ b/basis/sequences/parser/parser.factor @@ -39,7 +39,7 @@ TUPLE: sequence-parser sequence n ; : get+increment ( sequence-parser -- char/f ) [ current ] [ advance drop ] bi ; inline -:: skip-until ( sequence-parser quot: ( obj -- ? ) -- ) +:: skip-until ( ... sequence-parser quot: ( ... obj -- ... ? ) -- ... ) sequence-parser current [ sequence-parser quot call [ sequence-parser advance quot skip-until ] unless @@ -47,7 +47,7 @@ TUPLE: sequence-parser sequence n ; : sequence-parse-end? ( sequence-parser -- ? ) current not ; -: take-until ( sequence-parser quot: ( obj -- ? ) -- sequence/f ) +: take-until ( ... sequence-parser quot: ( ... obj -- ... ? ) -- ... sequence/f ) over sequence-parse-end? [ 2drop f ] [ @@ -56,7 +56,7 @@ TUPLE: sequence-parser sequence n ; [ drop [ n>> ] [ sequence>> ] bi ] 2tri subseq f like ] if ; inline -: take-while ( sequence-parser quot: ( obj -- ? ) -- sequence/f ) +: take-while ( ... sequence-parser quot: ( ... obj -- ... ? ) -- ... sequence/f ) [ not ] compose take-until ; inline : ( from to seq -- slice/f ) diff --git a/basis/sorting/insertion/insertion.factor b/basis/sorting/insertion/insertion.factor index b7fefcad63..577d2f0b67 100644 --- a/basis/sorting/insertion/insertion.factor +++ b/basis/sorting/insertion/insertion.factor @@ -2,7 +2,7 @@ USING: locals sequences kernel math ; IN: sorting.insertion = [ n n 1 - seq exchange diff --git a/basis/stack-checker/backend/backend.factor b/basis/stack-checker/backend/backend.factor index 7829f933aa..1e7ae5a9f3 100644 --- a/basis/stack-checker/backend/backend.factor +++ b/basis/stack-checker/backend/backend.factor @@ -136,7 +136,7 @@ M: bad-call summary : infer-r> ( n -- ) consume-r dup copy-values [ nip output-d ] [ #r>, ] 2bi ; -: consume/produce ( effect quot: ( inputs outputs -- ) -- ) +: consume/produce ( ..a effect quot: ( ..a inputs outputs -- ..b ) -- ..b ) '[ [ in>> length consume-d ] [ out>> length produce-d ] bi @ ] [ terminated?>> [ terminate ] when ] bi ; inline diff --git a/basis/tools/disassembler/udis/udis.factor b/basis/tools/disassembler/udis/udis.factor index ae8827e093..5e46a34682 100644 --- a/basis/tools/disassembler/udis/udis.factor +++ b/basis/tools/disassembler/udis/udis.factor @@ -103,7 +103,7 @@ FUNCTION: c-string ud_lookup_mnemonic ( int c ) ; dup cell-bits ud_set_mode dup UD_SYN_INTEL ud_set_syntax ; -: with-ud ( quot: ( ud -- ) -- ) +: with-ud ( ..a quot: ( ..a ud -- ..b ) -- ..b ) [ [ [ ] dip call ] with-destructors ] with-code-blocks ; inline SINGLETON: udis-disassembler diff --git a/core/assocs/assocs.factor b/core/assocs/assocs.factor index e8ed1637e6..b0509b27cb 100644 --- a/core/assocs/assocs.factor +++ b/core/assocs/assocs.factor @@ -44,7 +44,7 @@ M: assoc assoc-like drop ; inline : substituter ( assoc -- quot ) [ ?at drop ] curry ; inline -: with-assoc ( assoc quot: ( value key assoc -- ) -- quot: ( key value -- ) ) +: with-assoc ( assoc quot: ( ..a value key assoc -- ..b ) -- quot: ( ..a key value -- ..b ) ) curry [ swap ] prepose ; inline PRIVATE> diff --git a/core/combinators/combinators.factor b/core/combinators/combinators.factor index 7b9481825b..d14564f7b2 100644 --- a/core/combinators/combinators.factor +++ b/core/combinators/combinators.factor @@ -193,5 +193,5 @@ M: hashtable hashcode* [ assoc-hashcode ] [ nip assoc-size ] if ] recursive-hashcode ; -: to-fixed-point ( object quot: ( object(n) -- object(n+1) ) -- object(n) ) +: to-fixed-point ( ... object quot: ( ... object(n) -- ... object(n+1) ) -- ... object(n) ) [ keep over = ] keep [ to-fixed-point ] curry unless ; inline recursive diff --git a/core/generic/math/math.factor b/core/generic/math/math.factor index 297684014b..277f40c34f 100644 --- a/core/generic/math/math.factor +++ b/core/generic/math/math.factor @@ -74,7 +74,7 @@ PRIVATE> SYMBOL: generic-word -: make-math-method-table ( classes quot: ( class -- quot ) -- alist ) +: make-math-method-table ( classes quot: ( ... class -- ... quot ) -- alist ) [ bootstrap-words ] dip [ [ drop ] [ call ] 2bi ] curry { } map>assoc ; inline @@ -93,7 +93,7 @@ SYMBOL: generic-word : tuple-dispatch ( picker alist -- alist' ) swap [ [ tuple-dispatch-entry ] curry dip ] curry assoc-map math-alist>quot ; -: math-dispatch-step ( picker quot: ( class -- quot ) -- quot ) +: math-dispatch-step ( picker quot: ( ... class -- ... quot ) -- quot ) [ [ { bignum float fixnum } ] dip make-math-method-table ] [ [ { ratio complex } ] dip make-math-method-table tuple-dispatch ] 2bi tuple swap 2array prefix tag-dispatch ; inline diff --git a/extra/gpu/buffers/buffers.factor b/extra/gpu/buffers/buffers.factor index bc6f089db9..1f764cdfec 100644 --- a/extra/gpu/buffers/buffers.factor +++ b/extra/gpu/buffers/buffers.factor @@ -132,7 +132,7 @@ TYPED:: copy-buffer ( to-buffer-ptr: buffer-ptr from-buffer-ptr: buffer-ptr size from-buffer-ptr offset>> to-buffer-ptr offset>> size glCopyBufferSubData ; -:: with-mapped-buffer ( buffer access quot: ( alien -- ) -- ) +:: with-mapped-buffer ( ..a buffer access quot: ( ..a alien -- ..b ) -- ..b ) buffer bind-buffer :> target target access gl-access glMapBuffer @@ -140,15 +140,15 @@ TYPED:: copy-buffer ( to-buffer-ptr: buffer-ptr from-buffer-ptr: buffer-ptr size target glUnmapBuffer drop ; inline -:: with-bound-buffer ( buffer target quot: ( -- ) -- ) +:: with-bound-buffer ( ..a buffer target quot: ( ..a -- ..b ) -- ..b ) target gl-target buffer glBindBuffer quot call ; inline -: with-buffer-ptr ( buffer-ptr target quot: ( c-ptr -- ) -- ) +: with-buffer-ptr ( ..a buffer-ptr target quot: ( ..a c-ptr -- ..b ) -- ..b ) [ [ offset>> ] [ buffer>> handle>> ] bi ] 2dip with-bound-buffer ; inline -: with-gpu-data-ptr ( gpu-data-ptr target quot: ( c-ptr -- ) -- ) +: with-gpu-data-ptr ( ..a gpu-data-ptr target quot: ( ..a c-ptr -- ..b ) -- ..b ) pick buffer-ptr? [ with-buffer-ptr ] [ [ gl-target 0 glBindBuffer ] dip call ] if ; inline diff --git a/extra/math/matrices/simd/simd.factor b/extra/math/matrices/simd/simd.factor index 01d831d6b0..26ad8bb4d7 100644 --- a/extra/math/matrices/simd/simd.factor +++ b/extra/math/matrices/simd/simd.factor @@ -28,7 +28,7 @@ M: matrix4 new-sequence 2drop matrix4 (struct) ; inline c1 c2 c3 c4 columns 4 set-firstn-unsafe c ; inline -: make-matrix4 ( quot: ( -- c1 c2 c3 c4 ) -- c ) +: make-matrix4 ( ..a quot: ( ..a -- ..b c1 c2 c3 c4 ) -- ..b c ) matrix4 (struct) swap dip set-columns ; inline :: 2map-columns ( a b quot -- c ) @@ -42,7 +42,7 @@ M: matrix4 new-sequence 2drop matrix4 (struct) ; inline a4 b4 quot call ] make-matrix4 ; inline -: map-columns ( a quot -- c ) +: map-columns ( ... a quot: ( ... col -- ... newcol ) -- ... c ) '[ columns _ 4 napply ] make-matrix4 ; inline PRIVATE> From bcbc7632c60680b014d9943f7ac7e3be91e058f6 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 8 Mar 2010 23:46:20 -0800 Subject: [PATCH 362/713] fix stack effects in compiler tests --- basis/compiler/tests/curry.factor | 2 +- basis/compiler/tests/optimizer.factor | 2 +- basis/compiler/tree/dead-code/dead-code-tests.factor | 2 +- basis/compiler/tree/normalization/normalization-tests.factor | 2 +- .../compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/basis/compiler/tests/curry.factor b/basis/compiler/tests/curry.factor index ddbd9ba646..4f38cd8290 100644 --- a/basis/compiler/tests/curry.factor +++ b/basis/compiler/tests/curry.factor @@ -32,7 +32,7 @@ IN: compiler.tests.curry compile-call ] unit-test -: foobar ( quot: ( -- ) -- ) +: foobar ( quot: ( ..a -- ..b ) -- ) [ call ] keep swap [ foobar ] [ drop ] if ; inline recursive [ ] [ [ [ f ] foobar ] compile-call ] unit-test diff --git a/basis/compiler/tests/optimizer.factor b/basis/compiler/tests/optimizer.factor index fe67cbbc37..2e305b2c39 100644 --- a/basis/compiler/tests/optimizer.factor +++ b/basis/compiler/tests/optimizer.factor @@ -198,7 +198,7 @@ USE: sorting USE: binary-search USE: binary-search.private -: old-binsearch ( elt quot: ( -- ) seq -- elt quot i ) +: old-binsearch ( elt quot: ( ..a -- ..b ) seq -- elt quot i ) dup length 1 <= [ from>> ] [ diff --git a/basis/compiler/tree/dead-code/dead-code-tests.factor b/basis/compiler/tree/dead-code/dead-code-tests.factor index d859096e1d..afdd8fed4e 100644 --- a/basis/compiler/tree/dead-code/dead-code-tests.factor +++ b/basis/compiler/tree/dead-code/dead-code-tests.factor @@ -168,7 +168,7 @@ IN: compiler.tree.dead-code.tests [ ] [ [ [ 0 -rot set-nth-unsafe ] curry (each-integer) ] optimize-quot drop ] unit-test -: call-recursive-dce-6 ( i quot: ( i -- ? ) -- i ) +: call-recursive-dce-6 ( i quot: ( ..a -- ..b ) -- i ) dup call [ drop ] [ call-recursive-dce-6 ] if ; inline recursive [ ] [ [ [ ] curry [ ] swap compose call-recursive-dce-6 ] optimize-quot drop ] unit-test diff --git a/basis/compiler/tree/normalization/normalization-tests.factor b/basis/compiler/tree/normalization/normalization-tests.factor index 19669c2239..2f250fcf08 100644 --- a/basis/compiler/tree/normalization/normalization-tests.factor +++ b/basis/compiler/tree/normalization/normalization-tests.factor @@ -14,7 +14,7 @@ IN: compiler.tree.normalization.tests [ 2 ] [ [ 3 [ drop ] [ 2drop 3 ] if ] build-tree count-introductions ] unit-test -: foo ( quot: ( -- ) -- ) call ; inline recursive +: foo ( ..a quot: ( ..a -- ..b ) -- ..b ) call ; inline recursive : recursive-inputs ( nodes -- n ) [ #recursive? ] find nip child>> first in-d>> length ; diff --git a/basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor b/basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor index d73368867d..e6d42f0289 100644 --- a/basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor +++ b/basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor @@ -38,10 +38,10 @@ TUPLE: empty-tuple ; } [ [ ] swap [ test-unboxing ] curry unit-test ] each ! A more complicated example -: impeach-node ( quot: ( node -- ) -- ) +: impeach-node ( quot: ( ..a -- ..b ) -- ) [ call ] keep impeach-node ; inline recursive -: bleach-node ( quot: ( node -- ) -- ) +: bleach-node ( quot: ( ..a -- ..b ) -- ) [ bleach-node ] curry [ ] compose impeach-node ; inline recursive [ ] [ [ [ ] bleach-node ] test-unboxing ] unit-test From e7968ceffc2a29d4248a52078716105b03734aef Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 9 Mar 2010 00:56:07 -0800 Subject: [PATCH 363/713] mop up compiler errors from macosx load-all --- basis/farkup/farkup.factor | 2 +- basis/furnace/auth/auth.factor | 1 + basis/furnace/scopes/scopes.factor | 1 + basis/io/directories/search/search.factor | 2 +- basis/math/matrices/elimination/elimination.factor | 2 +- basis/xml/syntax/syntax.factor | 2 +- basis/xml/tokenize/tokenize.factor | 4 ++-- core/io/io.factor | 2 +- extra/bank/bank.factor | 2 +- extra/benchmark/nbody-simd/nbody-simd.factor | 2 +- extra/benchmark/nbody/nbody.factor | 2 +- extra/bson/writer/writer.factor | 12 ++++++------ extra/irc/client/base/base.factor | 2 +- extra/project-euler/085/085.factor | 2 +- 14 files changed, 20 insertions(+), 18 deletions(-) diff --git a/basis/farkup/farkup.factor b/basis/farkup/farkup.factor index 5795438570..7707c2a2c7 100644 --- a/basis/farkup/farkup.factor +++ b/basis/farkup/farkup.factor @@ -70,7 +70,7 @@ DEFER: (parse-paragraph) { CHAR: % inline-code } } at ; -: or-simple-title ( url title/f quot: ( title -- title' ) -- url title' ) +: or-simple-title ( ... url title/f quot: ( ... title -- ... title' ) -- ... url title' ) [ "" like dup simple-link-title ] if* ; inline : parse-link ( string -- paragraph-list ) diff --git a/basis/furnace/auth/auth.factor b/basis/furnace/auth/auth.factor index 831ec7f8fc..29ab04fe1b 100644 --- a/basis/furnace/auth/auth.factor +++ b/basis/furnace/auth/auth.factor @@ -14,6 +14,7 @@ furnace.redirection furnace.boilerplate furnace.auth.providers furnace.auth.providers.db ; +FROM: assocs => change-at ; IN: furnace.auth SYMBOL: logged-in-user diff --git a/basis/furnace/scopes/scopes.factor b/basis/furnace/scopes/scopes.factor index daad0dcf91..4d005e8adc 100644 --- a/basis/furnace/scopes/scopes.factor +++ b/basis/furnace/scopes/scopes.factor @@ -2,6 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel accessors assocs destructors db.tuples db.types furnace.cache ; +FROM: assocs => change-at ; IN: furnace.scopes TUPLE: scope < server-state namespace changed? ; diff --git a/basis/io/directories/search/search.factor b/basis/io/directories/search/search.factor index 28d7f63d87..0b69064311 100644 --- a/basis/io/directories/search/search.factor +++ b/basis/io/directories/search/search.factor @@ -41,7 +41,7 @@ TUPLE: directory-iterator path bfs queue ; [ nip ] if ] if ; -:: iterate-directory-entries ( iter quot: ( obj -- obj ) -- directory-entry/f ) +:: iterate-directory-entries ( ... iter quot: ( ... obj -- ... obj ) -- ... directory-entry/f ) iter next-directory-entry [ quot call [ iter quot iterate-directory-entries ] unless* diff --git a/basis/math/matrices/elimination/elimination.factor b/basis/math/matrices/elimination/elimination.factor index c8d5bb7338..6dfcf9f0ca 100644 --- a/basis/math/matrices/elimination/elimination.factor +++ b/basis/math/matrices/elimination/elimination.factor @@ -11,7 +11,7 @@ SYMBOL: matrix : nth-row ( row# -- seq ) matrix get nth ; -: change-row ( row# quot: ( seq -- seq ) -- ) +: change-row ( ..a row# quot: ( ..a seq -- ..b seq ) -- ..b ) matrix get swap change-nth ; inline : exchange-rows ( row# row# -- ) matrix get exchange ; diff --git a/basis/xml/syntax/syntax.factor b/basis/xml/syntax/syntax.factor index 4b9900d3b0..c56dd23db7 100644 --- a/basis/xml/syntax/syntax.factor +++ b/basis/xml/syntax/syntax.factor @@ -44,7 +44,7 @@ SYNTAX: XML-NS: : each-attrs ( attrs quot -- ) [ values [ interpolated? ] filter ] dip each ; inline -: (each-interpolated) ( item quot: ( interpolated -- ) -- ) +: (each-interpolated) ( ... item quot: ( ... interpolated -- ... ) -- ... ) { { [ over interpolated? ] [ call ] } { [ over tag? ] [ [ attrs>> ] dip each-attrs ] } diff --git a/basis/xml/tokenize/tokenize.factor b/basis/xml/tokenize/tokenize.factor index ef8420d66c..8978c660f4 100644 --- a/basis/xml/tokenize/tokenize.factor +++ b/basis/xml/tokenize/tokenize.factor @@ -59,14 +59,14 @@ HINTS: next* { spot } ; ! with-input-stream implicitly creates a new scope which we use swap [ init-parser call ] with-input-stream ; inline -:: (skip-until) ( quot: ( -- ? ) spot -- ) +:: (skip-until) ( ... quot: ( ... -- ... ? ) spot -- ... ) spot char>> [ quot call [ spot next* quot spot (skip-until) ] unless ] when ; inline recursive -: skip-until ( quot: ( -- ? ) -- ) +: skip-until ( ... quot: ( ... -- ... ? ) -- ... ) spot get (skip-until) ; inline : take-until ( quot -- string ) diff --git a/core/io/io.factor b/core/io/io.factor index 519d6535b9..e3c6a8f26c 100644 --- a/core/io/io.factor +++ b/core/io/io.factor @@ -87,7 +87,7 @@ SYMBOL: error-stream : bl ( -- ) " " write ; -: each-morsel ( handler: ( data -- ) reader: ( -- data ) -- ) +: each-morsel ( ..a handler: ( ..a data -- ..b ) reader: ( ..b -- ..a data ) -- ..a ) [ dup ] compose swap while drop ; inline transaction : process-day ( account date -- ) 2dup accumulate-interest ?pay-interest ; -: each-day ( quot: ( -- ) start end -- ) +: each-day ( ... quot: ( ... day -- ... ) start end -- ... ) 2dup before? [ [ dup [ over [ swap call ] dip ] dip 1 days time+ ] dip each-day ] [ diff --git a/extra/benchmark/nbody-simd/nbody-simd.factor b/extra/benchmark/nbody-simd/nbody-simd.factor index 37fb1d0ce3..39c2169596 100644 --- a/extra/benchmark/nbody-simd/nbody-simd.factor +++ b/extra/benchmark/nbody-simd/nbody-simd.factor @@ -58,7 +58,7 @@ SPECIALIZED-ARRAY: body body-array{ } output>sequence dup init-bodies ; inline -:: each-pair ( bodies pair-quot: ( other-body body -- ) each-quot: ( body -- ) -- ) +:: each-pair ( ... bodies pair-quot: ( ... other-body body -- ... ) each-quot: ( ... body -- ... ) -- ) bodies [| body i | body each-quot call bodies i 1 + tail-slice [ diff --git a/extra/benchmark/nbody/nbody.factor b/extra/benchmark/nbody/nbody.factor index 256fa9ec28..79a5a131f9 100644 --- a/extra/benchmark/nbody/nbody.factor +++ b/extra/benchmark/nbody/nbody.factor @@ -58,7 +58,7 @@ TUPLE: nbody-system { bodies array read-only } ; [ ] output>array nbody-system boa dup bodies>> init-bodies ; inline -:: each-pair ( bodies pair-quot: ( other-body body -- ) each-quot: ( body -- ) -- ) +:: each-pair ( ... bodies pair-quot: ( ... other-body body -- ... ) each-quot: ( ... body -- ... ) -- ... ) bodies [| body i | body each-quot call bodies i 1 + tail-slice [ diff --git a/extra/bson/writer/writer.factor b/extra/bson/writer/writer.factor index a070579943..2ae8737c70 100644 --- a/extra/bson/writer/writer.factor +++ b/extra/bson/writer/writer.factor @@ -32,22 +32,22 @@ PRIVATE> : ensure-buffer ( -- ) (buffer) drop ; inline -: with-buffer ( quot: ( -- ) -- byte-vector ) +: with-buffer ( ..a quot: ( ..a -- ..b ) -- ..b byte-vector ) [ (buffer) [ reset-buffer ] keep dup ] dip with-output-stream* ; inline -: with-length ( quot: ( -- ) -- bytes-written start-index ) +: with-length ( ..a quot: ( ..a -- ..b ) -- ..b bytes-written start-index ) [ (buffer) [ length ] keep ] dip call length swap [ - ] keep ; inline -: (with-length-prefix) ( quot: ( -- ) length-quot: ( bytes-written -- length ) -- ) +: (with-length-prefix) ( ..a quot: ( ..a -- ..b ) length-quot: ( bytes-written -- length ) -- ..b ) [ [ B{ 0 0 0 0 } write ] prepose with-length ] dip swap [ call ] dip (buffer) copy ; inline -: with-length-prefix ( quot: ( -- ) -- ) +: with-length-prefix ( ..a quot: ( ..a -- ..b ) -- ..b ) [ INT32-SIZE >le ] (with-length-prefix) ; inline -: with-length-prefix-excl ( quot: ( -- ) -- ) +: with-length-prefix-excl ( ..a quot: ( ..a -- ..b ) -- ..b ) [ INT32-SIZE [ - ] keep >le ] (with-length-prefix) ; inline : mdb-special-value? ( value -- ? ) { [ timestamp? ] [ quotation? ] [ mdbregexp? ] - [ oid? ] [ byte-array? ] } 1|| ; inline \ No newline at end of file + [ oid? ] [ byte-array? ] } 1|| ; inline diff --git a/extra/irc/client/base/base.factor b/extra/irc/client/base/base.factor index 318a1ab1e3..8cc083d9dd 100644 --- a/extra/irc/client/base/base.factor +++ b/extra/irc/client/base/base.factor @@ -14,7 +14,7 @@ SYMBOL: current-irc-client : chats> ( -- seq ) irc> chats>> values ; : me? ( string -- ? ) irc> nick>> = ; -: with-irc ( irc-client quot: ( -- ) -- ) +: with-irc ( ..a irc-client quot: ( ..a -- ..b ) -- ..b ) \ current-irc-client swap with-variable ; inline UNION: to-target privmsg notice ; diff --git a/extra/project-euler/085/085.factor b/extra/project-euler/085/085.factor index 9c12367cdf..bc94811a76 100644 --- a/extra/project-euler/085/085.factor +++ b/extra/project-euler/085/085.factor @@ -29,7 +29,7 @@ IN: project-euler.085 : rectangles-count ( a b -- n ) 2dup [ 1 + ] bi@ * * * 4 /i ; inline -:: each-unique-product ( a b quot: ( i j -- ) -- ) +:: each-unique-product ( ... a b quot: ( ... i j -- ... ) -- ... ) a b [a,b] [| i | i b [a,b] [| j | i j quot call From 84aa47610f4f688dd076abf2906e049c1acea78e Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 9 Mar 2010 10:22:14 -0800 Subject: [PATCH 364/713] mop up errors from test-all --- basis/regexp/minimize/minimize.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basis/regexp/minimize/minimize.factor b/basis/regexp/minimize/minimize.factor index a6eb4f00a2..08f7b1da58 100644 --- a/basis/regexp/minimize/minimize.factor +++ b/basis/regexp/minimize/minimize.factor @@ -3,6 +3,7 @@ USING: kernel sequences regexp.transition-tables fry assocs accessors locals math sorting arrays sets hashtables regexp.dfa combinators.short-circuit regexp.classes ; +FROM: assocs => change-at ; IN: regexp.minimize : table>state-numbers ( table -- assoc ) @@ -51,7 +52,7 @@ IN: regexp.minimize >hashtable ; -:: (while-changes) ( obj quot: ( obj -- obj' ) comp: ( obj -- key ) old-key -- obj ) +:: (while-changes) ( ..a obj quot: ( ..a obj -- ..b obj' ) comp: ( ..b obj' -- ..a key ) old-key -- ..a obj ) obj quot call :> new-obj new-obj comp call :> new-key new-key old-key = From 8e227bc874e356f1e292ab18d1bad1d48966746a Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Tue, 9 Mar 2010 15:58:44 -0500 Subject: [PATCH 365/713] Propagation tracks length just like any other read-only slot --- .../tree/propagation/info/info.factor | 35 +++++++------------ .../propagation/recursive/recursive.factor | 3 +- .../tree/propagation/slots/slots.factor | 9 ++--- 3 files changed, 16 insertions(+), 31 deletions(-) diff --git a/basis/compiler/tree/propagation/info/info.factor b/basis/compiler/tree/propagation/info/info.factor index 7f5b9f6fcd..b154845c07 100644 --- a/basis/compiler/tree/propagation/info/info.factor +++ b/basis/compiler/tree/propagation/info/info.factor @@ -31,7 +31,6 @@ class interval literal literal? -length slots ; CONSTANT: null-info T{ value-info f null empty-interval } @@ -74,13 +73,20 @@ UNION: fixed-length array byte-array string ; ] unless ] unless ; +: length-slots ( length class -- slots ) + "slots" word-prop length 1 - f + swap prefix ; + : init-literal-info ( info -- info ) empty-interval >>interval dup literal>> literal-class >>class dup literal>> { { [ dup real? ] [ [a,a] >>interval ] } { [ dup tuple? ] [ tuple-slot-infos >>slots ] } - { [ dup fixed-length? ] [ length >>length ] } + { [ dup fixed-length? ] [ + [ length ] [ class ] bi + length-slots >>slots + ] } [ drop ] } cond ; inline @@ -158,11 +164,11 @@ UNION: fixed-length array byte-array string ; t >>literal? init-value-info ; foldable -: ( value -- info ) +: ( length class -- info ) - object >>class - swap value-info >>length - init-value-info ; foldable + over >>class + [ length-slots ] dip swap >>slots + init-value-info ; : ( slots class -- info ) @@ -185,13 +191,6 @@ DEFER: value-info-intersect DEFER: (value-info-intersect) -: intersect-lengths ( info1 info2 -- length ) - [ length>> ] bi@ { - { [ dup not ] [ drop ] } - { [ over not ] [ nip ] } - [ value-info-intersect ] - } cond ; - : intersect-slot ( info1 info2 -- info ) { { [ dup not ] [ nip ] } @@ -215,7 +214,6 @@ DEFER: (value-info-intersect) [ [ class>> ] bi@ class-and >>class ] [ [ interval>> ] bi@ interval-intersect >>interval ] [ intersect-literals [ >>literal ] [ >>literal? ] bi* ] - [ intersect-lengths >>length ] [ intersect-slots >>slots ] } 2cleave init-value-info ; @@ -236,13 +234,6 @@ DEFER: value-info-union DEFER: (value-info-union) -: union-lengths ( info1 info2 -- length ) - [ length>> ] bi@ { - { [ dup not ] [ nip ] } - { [ over not ] [ drop ] } - [ value-info-union ] - } cond ; - : union-slot ( info1 info2 -- info ) { { [ dup not ] [ nip ] } @@ -261,7 +252,6 @@ DEFER: (value-info-union) [ [ class>> ] bi@ class-or >>class ] [ [ interval>> ] bi@ interval-union >>interval ] [ union-literals [ >>literal ] [ >>literal? ] bi* ] - [ union-lengths >>length ] [ union-slots >>slots ] } 2cleave init-value-info ; @@ -293,7 +283,6 @@ DEFER: (value-info-union) { [ 2dup [ class>> ] bi@ class<= not ] [ f ] } { [ 2dup [ interval>> ] bi@ interval-subset? not ] [ f ] } { [ 2dup literals<= not ] [ f ] } - { [ 2dup [ length>> ] bi@ value-info<= not ] [ f ] } { [ 2dup [ slots>> ] bi@ [ value-info<= ] 2all? not ] [ f ] } [ t ] } cond 2nip diff --git a/basis/compiler/tree/propagation/recursive/recursive.factor b/basis/compiler/tree/propagation/recursive/recursive.factor index eb4158e756..d4ab697e21 100644 --- a/basis/compiler/tree/propagation/recursive/recursive.factor +++ b/basis/compiler/tree/propagation/recursive/recursive.factor @@ -45,8 +45,7 @@ IN: compiler.tree.propagation.recursive [ clone ] dip [ [ drop ] [ [ [ interval>> ] bi@ ] [ drop class>> ] 2bi generalize-counter-interval ] 2bi >>interval ] [ [ drop ] [ [ slots>> ] bi@ [ generalize-counter ] 2map ] 2bi >>slots ] - [ [ drop ] [ [ length>> ] bi@ generalize-counter ] 2bi >>length ] - tri + bi ] if ] if ; diff --git a/basis/compiler/tree/propagation/slots/slots.factor b/basis/compiler/tree/propagation/slots/slots.factor index 18d31985d6..6429928294 100644 --- a/basis/compiler/tree/propagation/slots/slots.factor +++ b/basis/compiler/tree/propagation/slots/slots.factor @@ -9,8 +9,6 @@ IN: compiler.tree.propagation.slots ! Propagation of immutable slots and array lengths -UNION: fixed-length-sequence array byte-array string ; - : sequence-constructor? ( word -- ? ) { (byte-array) } member-eq? ; @@ -23,9 +21,9 @@ UNION: fixed-length-sequence array byte-array string ; } at ; : propagate-sequence-constructor ( #call word -- infos ) - [ in-d>> first ] - [ constructor-output-class ] - bi* value-info-intersect 1array ; + [ in-d>> first value-info ] + [ constructor-output-class ] bi* + 1array ; : fold- ( values class -- info ) [ [ literal>> ] map ] dip prefix >tuple @@ -72,7 +70,6 @@ UNION: fixed-length-sequence array byte-array string ; : value-info-slot ( slot info -- info' ) { { [ over 0 = ] [ 2drop fixnum ] } - { [ 2dup length-accessor? ] [ nip length>> ] } { [ dup literal?>> ] [ literal>> literal-info-slot ] } [ [ 1 - ] [ slots>> ] bi* ?nth ] } cond [ object-info ] unless* ; From 8a52aec6da904f4ea9e5678bb340e19d8a8f06ff Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 9 Mar 2010 13:50:58 -0800 Subject: [PATCH 366/713] effects: docs for , , --- core/effects/effects-docs.factor | 67 +++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/core/effects/effects-docs.factor b/core/effects/effects-docs.factor index df9f6401a2..e97120d26b 100644 --- a/core/effects/effects-docs.factor +++ b/core/effects/effects-docs.factor @@ -1,4 +1,4 @@ -USING: help.markup help.syntax math strings words kernel combinators sequences ; +USING: arrays classes help.markup help.syntax math strings words kernel combinators sequences ; IN: effects ARTICLE: "effects" "Stack effect declarations" @@ -29,8 +29,73 @@ $nl { { $snippet "*" } "when this symbol appears by itself in the list of outputs, it means the word unconditionally throws an error" } { { $snippet ".." } { "indicates " { $link "effects-variables" } ". only valid as the first input or first output" } } } +"For reflection and metaprogramming, you can use " { $link "syntax-effects" } " to include literal stack effects in your code, or these constructor words to construct stack effect objects at runtime:" +{ $subsections + + + +} +$nl { $see-also "inference" } ; +HELP: +{ $values + { "in" "a sequence of strings or string–type pairs" } + { "out" "a sequence of strings or string–type pairs" } + { "effect" effect } +} +{ $description "Constructs an " { $link effect } " object. Each element of " { $snippet "in" } " and " { $snippet "out" } " must be either a string (which is equivalent to a " { $snippet "name" } " in literal stack effect syntax), or a " { $link pair } " where the first element is a string and the second is either a " { $link class } " or effect (which is equivalent to " { $snippet "name: class" } " or " { $snippet "name: ( nested -- effect )" } " in the literal syntax. If the " { $snippet "out" } " array consists of a single string element " { $snippet "\"*\"" } ", a terminating stack effect will be constructed." } +{ $notes "This word cannot construct effects with " { $link "effects-variables" } ". Use " { $link } " to construct variable stack effects." } +{ $examples +{ $example """USING: effects prettyprint ; +{ "a" "b" } { "c" } .""" """(( a b -- c ))""" } +{ $example """USING: arrays effects prettyprint ; +{ "a" { "b" array } } { "c" } .""" """(( a b: array -- c ))""" } +{ $example """USING: effects prettyprint ; +{ "a" { "b" (( x y -- z )) } } { "c" } .""" """(( a b: ( x y -- z ) -- c ))""" } +{ $example """USING: effects prettyprint ; +{ "a" { "b" (( x y -- z )) } } { "*" } .""" """(( a b: ( x y -- z ) -- * ))""" } +} ; + +HELP: +{ $values + { "in" "a sequence of strings or string–type pairs" } + { "out" "a sequence of strings or string–type pairs" } + { "terminated?" boolean } + { "effect" effect } +} +{ $description "Constructs an " { $link effect } " object like " { $link } ". If " { $snippet "terminated?" } " is true, the value of " { $snippet "out" } " is ignored, and a terminating stack effect is constructed." } +{ $notes "This word cannot construct effects with " { $link "effects-variables" } ". Use " { $link } " to construct variable stack effects." } +{ $examples +{ $example """USING: effects prettyprint ; +{ "a" { "b" (( x y -- z )) } } { "c" } f .""" """(( a b: ( x y -- z ) -- c ))""" } +{ $example """USING: effects prettyprint ; +{ "a" { "b" (( x y -- z )) } } { } t .""" """(( a b: ( x y -- z ) -- * ))""" } +} ; + +HELP: +{ $values + { "in-var" { $maybe string } } + { "in" "a sequence of strings or string–type pairs" } + { "out-var" { $maybe string } } + { "out" "a sequence of strings or string–type pairs" } + { "effect" effect } +} +{ $description "Constructs an " { $link effect } " object like " { $link } ". If " { $snippet "in-var" } " or " { $snippet "out-var" } " are not " { $link f } ", they are used as the names of the " { $link "effects-variables" } " for the inputs and outputs of the effect object." } +{ $examples +{ $example """USING: effects prettyprint ; +f { "a" "b" } f { "c" } .""" """(( a b -- c ))""" } +{ $example """USING: effects prettyprint ; +"x" { "a" "b" } "y" { "c" } .""" """(( ..x a b -- ..y c ))""" } +{ $example """USING: arrays effects prettyprint ; +"y" { "a" { "b" (( ..x -- ..y )) } } "x" { "c" } .""" """(( ..y a b: ( ..x -- ..y ) -- ..x c ))""" } +{ $example """USING: effects prettyprint ; +"." { "a" "b" } f { "*" } .""" """(( ... a b -- * ))""" } +} ; + + +{ } related-words + ARTICLE: "effects-variables" "Stack effect variables" { $link POSTPONE: inline } " combinators can have variable stack effects, depending on the effect of the quotation they call. For example, while " { $link each } " inputs elements of its sequence to its quotation, the quotation can also manipulate values on the stack below the element, as long as it leaves the same number of elements on the stack. This ability is used to implement " { $link reduce } " in terms of " { $snippet "each" } ". This variable stack effect is indicated by starting the list of inputs and outputs with a name starting with " { $snippet ".." } ":" { $synopsis each } From 34b29af2454ca07cceebf17ee970362ddd1c4639 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 9 Mar 2010 15:57:00 -0800 Subject: [PATCH 367/713] non-polymorphic input parameter check was too strict: wouldn't allow ( x -- ) for ( x x -- x ), for example --- .../row-polymorphism/row-polymorphism.factor | 2 +- basis/stack-checker/stack-checker-tests.factor | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index 76879a3950..29ee63bf33 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -37,7 +37,7 @@ IN: stack-checker.row-polymorphism [ variable vars at - ] [ variable vars set-at 0 ] if t - ] [ dup zero? ] if ; + ] [ dup 0 <= ] if ; : adjust-variable ( diff var vars -- ) pick 0 >= diff --git a/basis/stack-checker/stack-checker-tests.factor b/basis/stack-checker/stack-checker-tests.factor index e537a530d2..ce2c03264b 100644 --- a/basis/stack-checker/stack-checker-tests.factor +++ b/basis/stack-checker/stack-checker-tests.factor @@ -431,9 +431,18 @@ DEFER: eee' : strict-each ( seq quot: ( x -- ) -- ) each ; inline +: strict-map ( seq quot: ( x -- x' ) -- seq' ) + map ; inline +: strict-2map ( xs ys quot: ( x y -- z ) -- zs ) + 2map ; inline { 1 0 } [ [ drop ] strict-each ] must-infer-as +{ 1 1 } [ [ 1 + ] strict-map ] must-infer-as +{ 1 1 } [ [ ] strict-map ] must-infer-as +{ 2 1 } [ [ + ] strict-2map ] must-infer-as +{ 2 1 } [ [ drop ] strict-2map ] must-infer-as [ [ [ append ] strict-each ] infer ] [ unbalanced-branches-error? ] must-fail-with +[ [ [ 1 + ] strict-2map ] infer ] [ unbalanced-branches-error? ] must-fail-with ! ensure that polymorphic checking works on recursive combinators FROM: splitting.private => split, ; From 7744559a46393b467d595e812eaf92e7340d2453 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 10 Mar 2010 15:15:49 +1300 Subject: [PATCH 368/713] compiler.tree.propagation: clean up --- .../tree/propagation/info/info.factor | 21 ++++++++----------- .../tree/propagation/slots/slots.factor | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/basis/compiler/tree/propagation/info/info.factor b/basis/compiler/tree/propagation/info/info.factor index b154845c07..22ea1306d6 100644 --- a/basis/compiler/tree/propagation/info/info.factor +++ b/basis/compiler/tree/propagation/info/info.factor @@ -47,9 +47,7 @@ CONSTANT: object-info T{ value-info f object full-interval } { [ over interval-length 0 > ] [ 3drop f f ] } { [ pick bignum class<= ] [ 2nip >bignum t ] } { [ pick integer class<= ] [ 2nip >fixnum t ] } - { [ pick float class<= ] [ - 2nip dup zero? [ drop f f ] [ >float t ] if - ] } + { [ pick float class<= ] [ 2nip dup zero? [ drop f f ] [ >float t ] if ] } [ 3drop f f ] } cond ] if ; @@ -73,9 +71,11 @@ UNION: fixed-length array byte-array string ; ] unless ] unless ; -: length-slots ( length class -- slots ) - "slots" word-prop length 1 - f - swap prefix ; +: (slots-with-length) ( length class -- slots ) + "slots" word-prop length 1 - f swap prefix ; + +: slots-with-length ( seq -- slots ) + [ length ] [ class ] bi (slots-with-length) ; : init-literal-info ( info -- info ) empty-interval >>interval @@ -83,10 +83,7 @@ UNION: fixed-length array byte-array string ; dup literal>> { { [ dup real? ] [ [a,a] >>interval ] } { [ dup tuple? ] [ tuple-slot-infos >>slots ] } - { [ dup fixed-length? ] [ - [ length ] [ class ] bi - length-slots >>slots - ] } + { [ dup fixed-length? ] [ slots-with-length >>slots ] } [ drop ] } cond ; inline @@ -164,10 +161,10 @@ UNION: fixed-length array byte-array string ; t >>literal? init-value-info ; foldable -: ( length class -- info ) +: ( length class -- info ) over >>class - [ length-slots ] dip swap >>slots + [ (slots-with-length) ] dip swap >>slots init-value-info ; : ( slots class -- info ) diff --git a/basis/compiler/tree/propagation/slots/slots.factor b/basis/compiler/tree/propagation/slots/slots.factor index 6429928294..2602d6d59a 100644 --- a/basis/compiler/tree/propagation/slots/slots.factor +++ b/basis/compiler/tree/propagation/slots/slots.factor @@ -23,7 +23,7 @@ IN: compiler.tree.propagation.slots : propagate-sequence-constructor ( #call word -- infos ) [ in-d>> first value-info ] [ constructor-output-class ] bi* - 1array ; + 1array ; : fold- ( values class -- info ) [ [ literal>> ] map ] dip prefix >tuple From b9bced9a5ed4c9e60c7de80facd48e27c41509b4 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 9 Mar 2010 18:42:10 -0800 Subject: [PATCH 369/713] update docs for unbalanced-branches-error --- basis/stack-checker/errors/errors-docs.factor | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/basis/stack-checker/errors/errors-docs.factor b/basis/stack-checker/errors/errors-docs.factor index 9aa7ed0d14..4f1bb28c5e 100644 --- a/basis/stack-checker/errors/errors-docs.factor +++ b/basis/stack-checker/errors/errors-docs.factor @@ -63,15 +63,16 @@ HELP: bad-macro-input } ; HELP: unbalanced-branches-error -{ $values { "in" "a sequence of integers" } { "out" "a sequence of integers" } } -{ $description "Throws an " { $link unbalanced-branches-error } "." } -{ $error-description "Thrown when inference encounters an " { $link if } " or " { $link dispatch } " where the branches do not all exit with the same stack height. See " { $link "inference-branches" } " for details." } -{ $notes "If this error comes up when inferring the stack effect of a recursive word, check the word's stack effect declaration; it might be wrong." } +{ $error-description "Thrown when inference encounters an inline combinator whose input quotations do not match their declared effects, or when it encounters an " { $link if } " or " { $link dispatch } " whose branches do not all exit with the same stack height. See " { $link "inference-combinators" } " and " { $link "inference-branches" } " for details." } { $examples { $code - ": unbalanced-branches-example ( a b c -- )" + ": if-unbalanced-branches-example ( a b c -- )" " [ + ] [ dup ] if ;" } + { $code + ": each-unbalanced-branches-example ( x seq -- x' )" + " [ 3append ] each ;" + } } ; HELP: too-many->r From 4367b15c4a3825448ad53d6763de616ba1731655 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 9 Mar 2010 19:51:04 -0800 Subject: [PATCH 370/713] update help-lint to complain when $quotation effect doesn't match declared effect on corresponding input parameter of stack effect --- basis/help/lint/checks/checks.factor | 25 ++++++++++++++++++++++++- basis/help/lint/lint.factor | 18 ++++++++++-------- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/basis/help/lint/checks/checks.factor b/basis/help/lint/checks/checks.factor index 632cdb46e2..85fa50f2b9 100644 --- a/basis/help/lint/checks/checks.factor +++ b/basis/help/lint/checks/checks.factor @@ -36,11 +36,27 @@ SYMBOL: vocab-articles first rest [ first ] map ] unless ; +: extract-value-effects ( element -- seq ) + \ $values swap elements dup empty? [ + first rest [ + \ $quotation swap elements dup empty? [ drop f ] [ + first second + ] if + ] map + ] unless ; + : effect-values ( word -- seq ) stack-effect [ in>> ] [ out>> ] bi append [ dup pair? [ first ] when effect>string ] map prune ; +: effect-effects ( word -- seq ) + stack-effect in>> [ + dup pair? + [ second dup effect? [ effect>string ] [ drop f ] if ] + [ drop f ] if + ] map ; + : contains-funky-elements? ( element -- ? ) { $shuffle @@ -70,9 +86,16 @@ SYMBOL: vocab-articles [ effect-values ] [ extract-values ] bi* sequence= - ] + ] } 2|| [ "$values don't match stack effect" simple-lint-error ] unless ; +: check-value-effects ( word element -- ) + [ effect-effects ] + [ extract-value-effects ] + bi* [ 2dup and [ = ] [ 2drop t ] if ] 2all? + [ "$quotation documentation in $values don't match stack effect" simple-lint-error ] + unless ; + : check-nulls ( element -- ) \ $values swap elements null swap deep-member? diff --git a/basis/help/lint/lint.factor b/basis/help/lint/lint.factor index 47b8820f18..7112eb5da9 100644 --- a/basis/help/lint/lint.factor +++ b/basis/help/lint/lint.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2006, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: assocs continuations fry help help.lint.checks -help.topics io kernel namespaces parser sequences -source-files.errors vocabs.hierarchy vocabs words classes -locals tools.errors listener ; +USING: assocs combinators continuations fry help +help.lint.checks help.topics io kernel namespaces parser +sequences source-files.errors vocabs.hierarchy vocabs words +classes locals tools.errors listener ; FROM: help.lint.checks => all-vocabs ; FROM: vocabs => child-vocabs ; IN: help.lint @@ -49,10 +49,12 @@ PRIVATE> [ with-file-vocabs ] vocabs-quot set dup word-help [ [ >link ] keep '[ - _ dup word-help - [ check-values ] - [ check-class-description ] - [ nip [ check-nulls ] [ check-see-also ] [ check-markup ] tri ] 2tri + _ dup word-help { + [ check-values ] + [ check-value-effects ] + [ check-class-description ] + [ nip [ check-nulls ] [ check-see-also ] [ check-markup ] tri ] + } 2cleave ] check-something ] [ drop ] if ; From b9004a4fffd05eb45f5d1a5d2de91c7b2c68f554 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 9 Mar 2010 20:29:44 -0800 Subject: [PATCH 371/713] fix up sequences help-lint --- basis/sequences/deep/deep-docs.factor | 12 ++-- core/sequences/sequences-docs.factor | 90 +++++++++++++-------------- core/sequences/sequences.factor | 36 +++++------ 3 files changed, 69 insertions(+), 69 deletions(-) diff --git a/basis/sequences/deep/deep-docs.factor b/basis/sequences/deep/deep-docs.factor index 6f479e48b6..02d3b9e9ba 100644 --- a/basis/sequences/deep/deep-docs.factor +++ b/basis/sequences/deep/deep-docs.factor @@ -2,27 +2,27 @@ USING: help.syntax help.markup kernel sequences ; IN: sequences.deep HELP: deep-each -{ $values { "obj" object } { "quot" { $quotation "( elt -- )" } } } +{ $values { "obj" object } { "quot" { $quotation "( ... elt -- ... )" } } } { $description "Execute a quotation on each nested element of an object and its children, in preorder." } { $see-also each } ; HELP: deep-map -{ $values { "obj" object } { "quot" { $quotation "( elt -- newelt )" } } { "newobj" "the mapped object" } } +{ $values { "obj" object } { "quot" { $quotation "( ... elt -- ... elt' )" } } { "newobj" "the mapped object" } } { $description "Execute a quotation on each nested element of an object and its children, in preorder. That is, the result of the execution of the quotation on the outer is used to map the inner elements." } { $see-also map } ; HELP: deep-filter -{ $values { "obj" object } { "quot" { $quotation "( elt -- ? )" } } { "seq" "a sequence" } } +{ $values { "obj" object } { "quot" { $quotation "( ... elt -- ... ? )" } } { "seq" "a sequence" } } { $description "Creates a sequence of sub-nodes in the object which satisfy the given quotation, in preorder. This includes the object itself, if it passes the quotation." } { $see-also filter } ; HELP: deep-find -{ $values { "obj" object } { "quot" { $quotation "( elt -- ? )" } } { "elt" "an element" } } +{ $values { "obj" object } { "quot" { $quotation "( ... elt -- ... ? )" } } { "elt" "an element" } } { $description "Gets the first sub-node of the object, in preorder, which satisfies the quotation. If nothing satisifies it, it returns " { $link f } "." } { $see-also find } ; HELP: deep-any? -{ $values { "obj" object } { "quot" { $quotation "( elt -- ? )" } } { "?" "a boolean" } } +{ $values { "obj" object } { "quot" { $quotation "( ... elt -- ... ? )" } } { "?" "a boolean" } } { $description "Tests whether the given object or any subnode satisfies the given quotation." } { $see-also any? } ; @@ -31,7 +31,7 @@ HELP: flatten { $description "Creates a sequence of all of the leaf nodes (non-sequence nodes, but including strings and numbers) in the object." } ; HELP: deep-map! -{ $values { "obj" object } { "quot" { $quotation "( elt -- newelt )" } } } +{ $values { "obj" object } { "quot" { $quotation "( ... elt -- ... elt' )" } } } { $description "Modifies each sub-node of an object in place, in preorder, and returns that object." } { $see-also map! } ; diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index d40796a4f6..8d6ddf1be9 100644 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -253,15 +253,15 @@ HELP: set-array-nth { $warning "This word is in the " { $vocab-link "sequences.private" } " vocabulary because it is unsafe. It does not check types or array bounds, and improper use can corrupt memory. User code must use " { $link set-nth } " instead." } ; HELP: collect -{ $values { "n" "a non-negative integer" } { "quot" { $quotation "( n -- value )" } } { "into" "a sequence of length at least " { $snippet "n" } } } +{ $values { "n" "a non-negative integer" } { "quot" { $quotation "( ... n -- ... value )" } } { "into" "a sequence of length at least " { $snippet "n" } } } { $description "A primitive mapping operation that applies a quotation to all integers from 0 up to but not including " { $snippet "n" } ", and collects the results in a new array. User code should use " { $link map } " instead." } ; HELP: each -{ $values { "seq" sequence } { "quot" { $quotation "( elt -- )" } } } +{ $values { "seq" sequence } { "quot" { $quotation "( ... x -- ... )" } } } { $description "Applies the quotation to each element of the sequence in order." } ; HELP: reduce -{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( prev elt -- next )" } } { "result" "the final result" } } +{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( ... prev elt -- ... next )" } } { "result" "the final result" } } { $description "Combines successive elements of the sequence using a binary operation, and outputs the final result. On the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the sequence." } { $examples { $example "USING: math prettyprint sequences ;" "{ 1 5 3 } 0 [ + ] reduce ." "9" } @@ -269,7 +269,7 @@ HELP: reduce HELP: reduce-index { $values - { "seq" sequence } { "identity" object } { "quot" { $quotation "( prev elt index -- result )" } } } + { "seq" sequence } { "identity" object } { "quot" { $quotation "( ... prev elt index -- ... next )" } } { "result" object } } { $description "Combines successive elements of the sequence and their indices binary operations, and outputs the final result. On the first iteration, the three inputs to the quotation are " { $snippet "identity" } ", the first element of the sequence, and its index, 0. On successive iterations, the first input is the result of the previous iteration, the second input is the corresponding element of the sequence, and the third is its index." } { $examples { $example "USING: sequences prettyprint math ;" "{ 10 50 90 } 0 [ + + ] reduce-index ." @@ -277,7 +277,7 @@ HELP: reduce-index } } ; HELP: accumulate-as -{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( prev elt -- next )" } } { "exemplar" sequence } { "final" "the final result" } { "newseq" "a new sequence" } } +{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( ... prev elt -- ... next )" } } { "exemplar" sequence } { "final" "the final result" } { "newseq" "a new sequence" } } { $description "Combines successive elements of the sequence using a binary operation, and outputs a sequence of the same type as " { $snippet "exemplar" } " containing intermediate results, together with the final result." $nl "The first element of the new sequence is " { $snippet "identity" } ". Then, on the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the old sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the old sequence." @@ -285,7 +285,7 @@ $nl "When given the empty sequence, outputs an empty sequence together with the " { $snippet "identity" } "." } ; HELP: accumulate -{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( prev elt -- next )" } } { "final" "the final result" } { "newseq" "a new array" } } +{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( ... prev elt -- ... next )" } } { "final" "the final result" } { "newseq" "a new array" } } { $description "Combines successive elements of the sequence using a binary operation, and outputs an array of intermediate results, together with the final result." $nl "The first element of the new sequence is " { $snippet "identity" } ". Then, on the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the old sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the old sequence." @@ -296,7 +296,7 @@ $nl } ; HELP: accumulate! -{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( prev elt -- next )" } } { "final" "the final result" } } +{ $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( ... prev elt -- ... next )" } } { "final" "the final result" } } { $description "Combines successive elements of the sequence using a binary operation, and outputs the original sequence of intermediate results, together with the final result." $nl "The first element of the new sequence is " { $snippet "identity" } ". Then, on the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the old sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the old sequence." @@ -307,11 +307,11 @@ $nl } ; HELP: map -{ $values { "seq" sequence } { "quot" { $quotation "( old -- new )" } } { "newseq" "a new sequence" } } +{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... newelt )" } } { "newseq" "a new sequence" } } { $description "Applies the quotation to each element of the sequence in order. The new elements are collected into a sequence of the same class as the input sequence." } ; HELP: map-as -{ $values { "seq" sequence } { "quot" { $quotation "( old -- new )" } } { "exemplar" sequence } { "newseq" "a new sequence" } } +{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... newelt )" } } { "exemplar" sequence } { "newseq" "a new sequence" } } { $description "Applies the quotation to each element of the sequence in order. The new elements are collected into a sequence of the same class as " { $snippet "exemplar" } "." } { $examples "The following example converts a string into an array of one-element strings:" @@ -321,7 +321,7 @@ HELP: map-as HELP: each-index { $values - { "seq" sequence } { "quot" { $quotation "( elt index -- )" } } } + { "seq" sequence } { "quot" { $quotation "( ... elt index -- ... )" } } } { $description "Calls the quotation with the element of the sequence and its index on the stack, with the index on the top of the stack." } { $examples { $example "USING: arrays sequences prettyprint ;" "{ 10 20 30 } [ 2array . ] each-index" @@ -330,7 +330,7 @@ HELP: each-index HELP: map-index { $values - { "seq" sequence } { "quot" { $quotation "( elt index -- result )" } } { "newseq" sequence } } + { "seq" sequence } { "quot" { $quotation "( ... elt index -- ... newelt )" } } { "newseq" sequence } } { $description "Calls the quotation with the element of the sequence and its index on the stack, with the index on the top of the stack. Collects the outputs of the quotation and outputs them in a sequence of the same type as the input sequence." } { $examples { $example "USING: arrays sequences prettyprint ;" "{ 10 20 30 } [ 2array ] map-index ." @@ -338,13 +338,13 @@ HELP: map-index } } ; HELP: change-nth -{ $values { "i" "a non-negative integer" } { "seq" "a mutable sequence" } { "quot" { $quotation "( elt -- newelt )" } } } +{ $values { "i" "a non-negative integer" } { "seq" "a mutable sequence" } { "quot" { $quotation "( ... elt -- ... newelt )" } } } { $description "Applies the quotation to the " { $snippet "i" } "th element of the sequence, storing the result back into the sequence." } { $errors "Throws an error if the sequence is immutable, if the index is out of bounds, or the sequence cannot hold elements of the type output by " { $snippet "quot" } "." } { $side-effects "seq" } ; HELP: map! -{ $values { "seq" "a mutable sequence" } { "quot" { $quotation "( old -- new )" } } } +{ $values { "seq" "a mutable sequence" } { "quot" { $quotation "( ... elt -- ... newelt )" } } } { $description "Applies the quotation to each element yielding a new element, storing the new elements back in the original sequence. Returns the original sequence." } { $errors "Throws an error if the sequence is immutable, or the sequence cannot hold elements of the type output by " { $snippet "quot" } "." } { $side-effects "seq" } ; @@ -358,44 +358,44 @@ HELP: max-length { $description "Outputs the maximum of the lengths of the two sequences." } ; HELP: 2each -{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( elt1 elt2 -- )" } } } +{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( ... elt1 elt2 -- ... )" } } } { $description "Applies the quotation to pairs of elements from " { $snippet "seq1" } " and " { $snippet "seq2" } "." } ; HELP: 3each -{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "quot" { $quotation "( elt1 elt2 elt3 -- )" } } } +{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "quot" { $quotation "( ... elt1 elt2 elt3 -- ... )" } } } { $description "Applies the quotation to triples of elements from " { $snippet "seq1" } ", " { $snippet "seq2" } " and " { $snippet "seq3" } "." } ; HELP: 2reduce { $values { "seq1" sequence } { "seq2" sequence } { "identity" object } - { "quot" { $quotation "( prev elt1 elt2 -- next )" } } + { "quot" { $quotation "( ... prev elt1 elt2 -- ... next )" } } { "result" "the final result" } } { $description "Combines successive pairs of elements from the two sequences using a ternary operation. The first input value at each iteration except the first one is the result of the previous iteration. The first input value at the first iteration is " { $snippet "identity" } "." } ; HELP: 2map -{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( elt1 elt2 -- new )" } } { "newseq" "a new sequence" } } +{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( ... elt1 elt2 -- ... newelt )" } } { "newseq" "a new sequence" } } { $description "Applies the quotation to each pair of elements in turn, yielding new elements which are collected into a new sequence having the same class as " { $snippet "seq1" } "." } ; HELP: 3map -{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "quot" { $quotation "( elt1 elt2 elt3 -- new )" } } { "newseq" "a new sequence" } } +{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "quot" { $quotation "( ... elt1 elt2 elt3 -- ... newelt )" } } { "newseq" "a new sequence" } } { $description "Applies the quotation to each triple of elements in turn, yielding new elements which are collected into a new sequence having the same class as " { $snippet "seq1" } "." } ; HELP: 2map-as -{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( elt1 elt2 -- new )" } } { "exemplar" sequence } { "newseq" "a new sequence" } } +{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( ... elt1 elt2 -- ... newelt )" } } { "exemplar" sequence } { "newseq" "a new sequence" } } { $description "Applies the quotation to each pair of elements in turn, yielding new elements which are collected into a new sequence having the same class as " { $snippet "exemplar" } "." } ; HELP: 3map-as -{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "quot" { $quotation "( elt1 elt2 elt3 -- new )" } } { "exemplar" sequence } { "newseq" "a new sequence" } } +{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "quot" { $quotation "( ... elt1 elt2 elt3 -- ... newelt )" } } { "exemplar" sequence } { "newseq" "a new sequence" } } { $description "Applies the quotation to each triple of elements in turn, yielding new elements which are collected into a new sequence having the same class as " { $snippet "exemplar" } "." } ; HELP: 2all? -{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( elt1 elt2 -- ? )" } } { "?" "a boolean" } } +{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( ... elt1 elt2 -- ... ? )" } } { "?" "a boolean" } } { $description "Tests the predicate pairwise against elements of " { $snippet "seq1" } " and " { $snippet "seq2" } "." } ; HELP: find { $values { "seq" sequence } - { "quot" { $quotation "( elt -- ? )" } } + { "quot" { $quotation "( ... elt -- ... ? )" } } { "i" "the index of the first match, or " { $link f } } { "elt" "the first matching element, or " { $link f } } } { $description "A simpler variant of " { $link find-from } " where the starting index is 0." } ; @@ -403,51 +403,51 @@ HELP: find HELP: find-from { $values { "n" "a starting index" } { "seq" sequence } - { "quot" { $quotation "( elt -- ? )" } } + { "quot" { $quotation "( ... elt -- ... ? )" } } { "i" "the index of the first match, or " { $link f } } { "elt" "the first matching element, or " { $link f } } } { $description "Applies the quotation to each element of the sequence in turn, until it outputs a true value or the end of the sequence is reached. If the quotation yields a true value for some sequence element, the word outputs the element index and the element itself. Otherwise, the word outputs an index of f and " { $link f } " as the element." } ; HELP: find-last -{ $values { "seq" sequence } { "quot" { $quotation "( elt -- ? )" } } { "i" "the index of the first match, or f" } { "elt" "the first matching element, or " { $link f } } } +{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... ? )" } } { "i" "the index of the first match, or f" } { "elt" "the first matching element, or " { $link f } } } { $description "A simpler variant of " { $link find-last-from } " where the starting index is one less than the length of the sequence." } ; HELP: find-last-from -{ $values { "n" "a starting index" } { "seq" sequence } { "quot" { $quotation "( elt -- ? )" } } { "i" "the index of the first match, or f" } { "elt" "the first matching element, or " { $link f } } } +{ $values { "n" "a starting index" } { "seq" sequence } { "quot" { $quotation "( ... elt -- ... ? )" } } { "i" "the index of the first match, or f" } { "elt" "the first matching element, or " { $link f } } } { $description "Applies the quotation to each element of the sequence in reverse order, until it outputs a true value or the start of the sequence is reached. If the quotation yields a true value for some sequence element, the word outputs the element index and the element itself. Otherwise, the word outputs an index of f and " { $link f } " as the element." } ; HELP: map-find -{ $values { "seq" sequence } { "quot" { $quotation "( elt -- result/f )" } } { "result" "the first non-false result of the quotation" } { "elt" "the first matching element, or " { $link f } } } +{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... result/f )" } } { "result" "the first non-false result of the quotation" } { "elt" "the first matching element, or " { $link f } } } { $description "Applies the quotation to each element of the sequence, until the quotation outputs a true value. If the quotation ever yields a result which is not " { $link f } ", then the value is output, along with the element of the sequence which yielded this." } ; HELP: any? -{ $values { "seq" sequence } { "quot" { $quotation "( elt -- ? )" } } { "?" "a boolean" } } +{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... ? )" } } { "?" "a boolean" } } { $description "Tests if the sequence contains an element satisfying the predicate, by applying the predicate to each element in turn until a true value is found. If the sequence is empty or if the end of the sequence is reached, outputs " { $link f } "." } ; HELP: all? -{ $values { "seq" sequence } { "quot" { $quotation "( elt -- ? )" } } { "?" "a boolean" } } +{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... ? )" } } { "?" "a boolean" } } { $description "Tests if all elements in the sequence satisfy the predicate by checking each element in turn. Given an empty sequence, vacuously outputs " { $link t } "." } ; HELP: push-if -{ $values { "elt" object } { "quot" { $quotation "( elt -- ? )" } } { "accum" "a resizable mutable sequence" } } +{ $values { "elt" object } { "quot" { $quotation "( ..a elt -- ..b ? )" } } { "accum" "a resizable mutable sequence" } } { $description "Adds the element at the end of the sequence if the quotation yields a true value." } { $notes "This word is a factor of " { $link filter } "." } ; HELP: filter -{ $values { "seq" sequence } { "quot" { $quotation "( elt -- ? )" } } { "subseq" "a new sequence" } } +{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... ? )" } } { "subseq" "a new sequence" } } { $description "Applies the quotation to each element in turn, and outputs a new sequence containing the elements of the original sequence for which the quotation output a true value." } ; HELP: filter-as -{ $values { "seq" sequence } { "quot" { $quotation "( elt -- ? )" } } { "exemplar" sequence } { "subseq" "a new sequence" } } +{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... ? )" } } { "exemplar" sequence } { "subseq" "a new sequence" } } { $description "Applies the quotation to each element in turn, and outputs a new sequence of the same type as " { $snippet "exemplar" } " containing the elements of the original sequence for which the quotation output a true value." } ; HELP: filter! -{ $values { "seq" "a resizable mutable sequence" } { "quot" { $quotation "( elt -- ? )" } } } +{ $values { "seq" "a resizable mutable sequence" } { "quot" { $quotation "( ... elt -- ... ? )" } } } { $description "Applies the quotation to each element in turn, and removes elements for which the quotation outputs a false value." } { $side-effects "seq" } ; HELP: interleave -{ $values { "seq" sequence } { "between" "a quotation" } { "quot" { $quotation "( elt -- )" } } } +{ $values { "seq" sequence } { "between" "a quotation" } { "quot" { $quotation "( ... elt -- ... )" } } } { $description "Applies " { $snippet "quot" } " to each element in turn, also invoking " { $snippet "between" } " in-between each pair of elements." } { $example "USING: io sequences ;" "{ \"a\" \"b\" \"c\" } [ \"X\" write ] [ write ] interleave" "aXbXc" } ; @@ -622,7 +622,7 @@ HELP: reverse! { $side-effects "seq" } ; HELP: padding -{ $values { "seq" sequence } { "n" "a non-negative integer" } { "elt" object } { "quot" { $quotation "( seq1 seq2 -- newseq )" } } { "newseq" "a new sequence" } } +{ $values { "seq" sequence } { "n" "a non-negative integer" } { "elt" object } { "quot" { $quotation "( ... seq1 seq2 -- ... newseq )" } } { "newseq" "a new sequence" } } { $description "Outputs a new string sequence of " { $snippet "elt" } " repeated, that when appended to " { $snippet "seq" } ", yields a sequence of length " { $snippet "n" } ". If the length of " { $snippet "seq" } " is greater than " { $snippet "n" } ", this word outputs an empty sequence." } ; HELP: pad-head @@ -961,7 +961,7 @@ HELP: supremum { $errors "Throws an error if the sequence is empty." } ; HELP: produce -{ $values { "pred" { $quotation "( -- ? )" } } { "quot" { $quotation "( -- obj )" } } { "seq" "a sequence" } } +{ $values { "pred" { $quotation "( ..a -- ..b ? )" } } { "quot" { $quotation "( ..b -- ..a obj )" } } { "seq" "a sequence" } } { $description "Calls " { $snippet "pred" } " repeatedly. If the predicate yields " { $link f } ", stops, otherwise, calls " { $snippet "quot" } " to yield a value. Values are accumulated and returned in a sequence at the end." } { $examples "The following example divides a number by two until we reach zero, and accumulates intermediate results:" @@ -971,7 +971,7 @@ HELP: produce } ; HELP: produce-as -{ $values { "pred" { $quotation "( -- ? )" } } { "quot" { $quotation "( -- obj )" } } { "exemplar" sequence } { "seq" "a sequence" } } +{ $values { "pred" { $quotation "( ..a -- ..b ? )" } } { "quot" { $quotation "( ..b -- ..a obj )" } } { "exemplar" sequence } { "seq" "a sequence" } } { $description "Calls " { $snippet "pred" } " repeatedly. If the predicate yields " { $link f } ", stops, otherwise, calls " { $snippet "quot" } " to yield a value. Values are accumulated and returned in a sequence of type " { $snippet "exemplar" } " at the end." } { $examples "See " { $link produce } " for examples." } ; @@ -995,8 +995,8 @@ HELP: count HELP: selector { $values - { "quot" { $quotation "( elt -- ? )" } } - { "selector" { $quotation "( elt -- )" } } { "accum" vector } } + { "quot" { $quotation "( ... elt -- ... ? )" } } + { "selector" { $quotation "( ... elt -- ... )" } } { "accum" vector } } { $description "Creates a new vector to accumulate the values which return true for a predicate. Returns a new quotation which accepts an object to be tested and stored in the collector if the test yields true. The collector is left on the stack for convenience." } { $example "! Find all the even numbers:" "USING: prettyprint sequences math kernel ;" "10 iota [ even? ] selector [ each ] dip ." @@ -1140,7 +1140,7 @@ HELP: set-fourth HELP: replicate { $values - { "len" integer } { "quot" { $quotation "( -- elt )" } } + { "len" integer } { "quot" { $quotation "( ... -- ... newelt )" } } { "newseq" sequence } } { $description "Calls the quotation " { $snippet "len" } " times, collecting results into a new array." } { $examples @@ -1152,7 +1152,7 @@ HELP: replicate HELP: replicate-as { $values - { "len" integer } { "quot" { $quotation "( -- elt )" } } { "exemplar" sequence } + { "len" integer } { "quot" { $quotation "( ... -- ... newelt )" } } { "exemplar" sequence } { "newseq" sequence } } { $description "Calls the quotation " { $snippet "len" } " times, collecting results into a new sequence of the same type as the exemplar sequence." } { $examples @@ -1190,7 +1190,7 @@ HELP: virtual@ HELP: 2map-reduce { $values - { "seq1" sequence } { "seq2" sequence } { "map-quot" { $quotation "( elt1 elt2 -- intermediate )" } } { "reduce-quot" { $quotation "( prev intermediate -- result )" } } + { "seq1" sequence } { "seq2" sequence } { "map-quot" { $quotation "( ..a elt1 elt2 -- ..b intermediate )" } } { "reduce-quot" { $quotation "( ..b prev intermediate -- ..a next )" } } { "result" object } } { $description "Calls " { $snippet "map-quot" } " on each pair of elements from " { $snippet "seq1" } " and " { $snippet "seq2" } " and combines the results using " { $snippet "reduce-quot" } " in the same manner as " { $link reduce } ", except that there is no identity element, and the sequence must have a length of at least 1." } { $errors "Throws an error if the sequence is empty." } @@ -1236,7 +1236,7 @@ HELP: collector HELP: binary-reduce { $values - { "seq" sequence } { "start" integer } { "quot" { $quotation "( elt1 elt2 -- newelt )" } } + { "seq" sequence } { "start" integer } { "quot" { $quotation "( ... elt1 elt2 -- ... newelt )" } } { "value" object } } { $description "Like " { $link reduce } ", but splits the sequence in half recursively until each sequence is small enough, and calls the quotation on these smaller sequences. If the quotation computes values that depend on the size of their input, such as bignum arithmetic, then this algorithm can be more efficient than using " { $link reduce } "." } { $examples "Computing factorial:" @@ -1247,7 +1247,7 @@ HELP: binary-reduce HELP: follow { $values - { "obj" object } { "quot" { $quotation "( prev -- result/f )" } } + { "obj" object } { "quot" { $quotation "( ... prev -- ... result/f )" } } { "seq" sequence } } { $description "Outputs a sequence containing the input object and all of the objects generated by successively feeding the result of the quotation called on the input object to the quotation recursuively. Objects yielded by the quotation are added to the output sequence until the quotation yields " { $link f } ", at which point the recursion terminates." } { $examples "Get random numbers until zero is reached:" @@ -1365,11 +1365,11 @@ HELP: assert-sequence= } ; HELP: cartesian-each -{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( elt1 elt2 -- )" } } } +{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( ... elt1 elt2 -- ... )" } } } { $description "Applies the quotation to every possible pairing of elements from the two sequences." } ; HELP: cartesian-map -{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( elt1 elt2 -- result )" } } { "newseq" "a new sequence of sequences" } } +{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation "( ... elt1 elt2 -- ... newelt )" } } { "newseq" "a new sequence of sequences" } } { $description "Applies the quotation to every possible pairing of elements from the two sequences, collecting results into a new sequence of sequences." } ; HELP: cartesian-product diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 3e0f102181..02c5d0ac72 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -417,19 +417,19 @@ PRIVATE> : map-integers ( len quot exemplar -- newseq ) [ over ] dip [ [ collect ] keep ] new-like ; inline -: map-as ( ... seq quot: ( ... x -- ... newx ) exemplar -- ... newseq ) +: map-as ( ... seq quot: ( ... elt -- ... newelt ) exemplar -- ... newseq ) [ (each) ] dip map-integers ; inline -: map ( ... seq quot: ( ... x -- ... newx ) -- ... newseq ) +: map ( ... seq quot: ( ... elt -- ... newelt ) -- ... newseq ) over map-as ; inline -: replicate-as ( ... len quot: ( ... -- ... newx ) exemplar -- ... newseq ) +: replicate-as ( ... len quot: ( ... -- ... newelt ) exemplar -- ... newseq ) [ [ drop ] prepose ] dip map-integers ; inline -: replicate ( ... len quot: ( ... -- ... newx ) -- ... newseq ) +: replicate ( ... len quot: ( ... -- ... newelt ) -- ... newseq ) { } replicate-as ; inline -: map! ( ... seq quot: ( ... x -- ... x' ) -- ... seq ) +: map! ( ... seq quot: ( ... elt -- ... newelt ) -- ... seq ) over [ map-into ] keep ; inline : accumulate-as ( ... seq identity quot: ( ... prev elt -- ... next ) exemplar -- ... final newseq ) @@ -441,31 +441,31 @@ PRIVATE> : accumulate! ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... final seq ) (accumulate) map! ; inline -: 2each ( ... seq1 seq2 quot: ( ... x1 x2 -- ... ) -- ... ) +: 2each ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ) -- ... ) (2each) each-integer ; inline -: 2reverse-each ( ... seq1 seq2 quot: ( ... x1 x2 -- ... ) -- ... ) +: 2reverse-each ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ) -- ... ) [ [ ] bi@ ] dip 2each ; inline : 2reduce ( ... seq1 seq2 identity quot: ( ... prev elt1 elt2 -- ... next ) -- ... result ) [ -rot ] dip 2each ; inline -: 2map-as ( ... seq1 seq2 quot: ( ... x1 x2 -- ... newx ) exemplar -- ... newseq ) +: 2map-as ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) exemplar -- ... newseq ) [ (2each) ] dip map-integers ; inline -: 2map ( ... seq1 seq2 quot: ( ... x1 x2 -- ... newx ) -- ... newseq ) +: 2map ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) -- ... newseq ) pick 2map-as ; inline : 2all? ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) -- ... ? ) (2each) all-integers? ; inline -: 3each ( ... seq1 seq2 seq3 quot: ( ... x1 x2 x3 -- ... ) -- ... ) +: 3each ( ... seq1 seq2 seq3 quot: ( ... elt1 elt2 elt3 -- ... ) -- ... ) (3each) each-integer ; inline -: 3map-as ( ... seq1 seq2 seq3 quot: ( ... x1 x2 x3 -- ... newx ) exemplar -- ... newseq ) +: 3map-as ( ... seq1 seq2 seq3 quot: ( ... elt1 elt2 elt3 -- ... newelt ) exemplar -- ... newseq ) [ (3each) ] dip map-integers ; inline -: 3map ( ... seq1 seq2 seq3 quot: ( ... x1 x2 x3 -- ... newx ) -- ... newseq ) +: 3map ( ... seq1 seq2 seq3 quot: ( ... elt1 elt2 elt3 -- ... newelt ) -- ... newseq ) [ pick ] dip swap 3map-as ; inline : find-from ( ... n seq quot: ( ... elt -- ... ? ) -- ... i elt ) @@ -522,7 +522,7 @@ PRIVATE> : follow ( ... obj quot: ( ... prev -- ... result/f ) -- ... seq ) [ dup ] swap [ keep ] curry produce nip ; inline -: each-index ( ... seq quot: ( ... x i -- ... ) -- ... ) +: each-index ( ... seq quot: ( ... elt index -- ... ) -- ... ) (each-index) each-integer ; inline : interleave ( seq between quot -- ) @@ -532,10 +532,10 @@ PRIVATE> 3bi ] if ; inline -: map-index ( ... seq quot: ( ... x i -- ... newx ) -- ... newseq ) +: map-index ( ... seq quot: ( ... elt index -- ... newelt ) -- ... newseq ) [ dup length iota ] dip 2map ; inline -: reduce-index ( ... seq identity quot: ( ... prev x i -- ... next ) -- ... result ) +: reduce-index ( ... seq identity quot: ( ... prev elt index -- ... next ) -- ... result ) swapd each-index ; inline : index ( obj seq -- n ) @@ -877,7 +877,7 @@ PRIVATE> [ [ unclip-slice ] dip [ call ] keep ] dip compose reduce ; inline -: 2map-reduce ( ..a seq1 seq2 map-quot: ( ..a x1 x2 -- ..b elt ) reduce-quot: ( ..b prev elt -- ..a next ) -- ..a result ) +: 2map-reduce ( ..a seq1 seq2 map-quot: ( ..a elt1 elt2 -- ..b intermediate ) reduce-quot: ( ..b prev intermediate -- ..a next ) -- ..a result ) [ [ prepare-2map-reduce ] keep ] dip compose compose each-integer ; inline @@ -889,10 +889,10 @@ PRIVATE> PRIVATE> -: map-find ( ... seq quot: ( ... elt -- ... ? ) -- ... result elt ) +: map-find ( ... seq quot: ( ... elt -- ... result/f ) -- ... result elt ) [ find ] (map-find) ; inline -: map-find-last ( ... seq quot: ( ... elt -- ... ? ) -- ... result elt ) +: map-find-last ( ... seq quot: ( ... elt -- ... result/f ) -- ... result elt ) [ find-last ] (map-find) ; inline : unclip-last-slice ( seq -- butlast-slice last ) From 18f3df9d4a6611e19c030c8c4e81c54c6371609b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 9 Mar 2010 21:02:43 -0800 Subject: [PATCH 372/713] more help-lint --- .../mailboxes/mailboxes-docs.factor | 2 +- basis/documents/documents-docs.factor | 2 +- basis/lists/lists-docs.factor | 8 +++---- basis/lists/lists.factor | 4 ++-- core/alien/alien-docs.factor | 6 ++--- core/alien/alien.factor | 6 ++--- core/classes/tuple/tuple-docs.factor | 6 ++--- core/combinators/combinators-docs.factor | 2 +- core/continuations/continuations-docs.factor | 2 +- core/kernel/kernel-docs.factor | 22 +++++++++---------- core/kernel/kernel.factor | 2 +- core/lexer/lexer-docs.factor | 4 ++-- core/math/math-docs.factor | 8 +++---- extra/gpu/buffers/buffers-docs.factor | 2 +- 14 files changed, 38 insertions(+), 38 deletions(-) diff --git a/basis/concurrency/mailboxes/mailboxes-docs.factor b/basis/concurrency/mailboxes/mailboxes-docs.factor index 727efd45d0..461650738e 100644 --- a/basis/concurrency/mailboxes/mailboxes-docs.factor +++ b/basis/concurrency/mailboxes/mailboxes-docs.factor @@ -21,7 +21,7 @@ HELP: block-unless-pred { $values { "mailbox" mailbox } { "timeout" "a " { $link duration } " or " { $link f } } - { "pred" { $quotation "( obj -- ? )" } } + { "pred" { $quotation "( ... message -- ... ? )" } } } { $description "Block the thread if there are no items in the mailbox that return true when the predicate is called with the item on the stack." } ; diff --git a/basis/documents/documents-docs.factor b/basis/documents/documents-docs.factor index a4e02009df..203a6e3b09 100644 --- a/basis/documents/documents-docs.factor +++ b/basis/documents/documents-docs.factor @@ -42,7 +42,7 @@ HELP: doc-lines { $errors "Throws an error if " { $snippet "from" } " or " { $snippet "to" } " is out of bounds." } ; HELP: each-line -{ $values { "from" "a non-negative integer" } { "to" "a non-negative integer" } { "quot" { $quotation "( string -- )" } } } +{ $values { "from" "a non-negative integer" } { "to" "a non-negative integer" } { "quot" { $quotation "( ... line -- ... )" } } } { $description "Applies the quotation to each line in the range." } { $notes "The range is created by calling " { $link } "." } { $errors "Throws an error if " { $snippet "from" } " or " { $snippet "to" } " is out of bounds." } ; diff --git a/basis/lists/lists-docs.factor b/basis/lists/lists-docs.factor index 53fde94687..a3056b0332 100644 --- a/basis/lists/lists-docs.factor +++ b/basis/lists/lists-docs.factor @@ -127,19 +127,19 @@ HELP: unswons { leach foldl lmap>array } related-words HELP: leach -{ $values { "list" list } { "quot" { $quotation "( obj -- )" } } } +{ $values { "list" list } { "quot" { $quotation "( ... elt -- ... )" } } } { $description "Call the quotation for each item in the list." } ; HELP: foldl -{ $values { "list" list } { "identity" "an object" } { "quot" { $quotation "( prev elt -- next )" } } { "result" "the final result" } } +{ $values { "list" list } { "identity" "an object" } { "quot" { $quotation "( ... prev elt -- ... next )" } } { "result" "the final result" } } { $description "Combines successive elements of the list (in a left-assocative order) using a binary operation and outputs the final result." } ; HELP: foldr -{ $values { "list" list } { "identity" "an object" } { "quot" { $quotation "( prev elt -- next )" } } { "result" "the final result" } } +{ $values { "list" list } { "identity" "an object" } { "quot" { $quotation "( ... prev elt -- ... next )" } } { "result" "the final result" } } { $description "Combines successive elements of the list (in a right-assocative order) using a binary operation, and outputs the final result." } ; HELP: lmap -{ $values { "list" list } { "quot" { $quotation "( old -- new )" } } { "result" "the final result" } } +{ $values { "list" list } { "quot" { $quotation "( ... elt -- ... newelt )" } } { "result" "the final result" } } { $description "Applies the quotation to each element of the list in order, collecting the new elements into a new list." } ; HELP: lreverse diff --git a/basis/lists/lists.factor b/basis/lists/lists.factor index bef9261468..1e009df25c 100644 --- a/basis/lists/lists.factor +++ b/basis/lists/lists.factor @@ -61,10 +61,10 @@ PRIVATE> : lmap ( ... list quot: ( ... elt -- ... newelt ) -- ... result ) over nil? [ drop ] [ (leach) lmap cons ] if ; inline recursive -: foldl ( ... list identity quot: ( ... obj1 obj2 -- ... obj ) -- ... result ) +: foldl ( ... list identity quot: ( ... prev elt -- ... next ) -- ... result ) swapd leach ; inline -:: foldr ( ... list identity quot: ( ... obj1 obj2 -- ... obj ) -- ... result ) +:: foldr ( ... list identity quot: ( ... prev elt -- ... next ) -- ... result ) list nil? [ identity ] [ list cdr identity quot foldr list car quot call diff --git a/core/alien/alien-docs.factor b/core/alien/alien-docs.factor index 99f3a2b0f4..5f91d4c695 100644 --- a/core/alien/alien-docs.factor +++ b/core/alien/alien-docs.factor @@ -71,7 +71,7 @@ HELP: alien-invoke-error } ; HELP: alien-invoke -{ $values { "..." "zero or more objects passed to the C function" } { "return" "a C return type" } { "library" "a logical library name" } { "function" "a C function name" } { "parameters" "a sequence of C parameter types" } } +{ $values { "args..." "zero or more objects passed to the C function" } { "return" "a C return type" } { "library" "a logical library name" } { "function" "a C function name" } { "parameters" "a sequence of C parameter types" } { "return..." "the return value of the function, if not " { $link void } } } { $description "Calls a C library function with the given name. Input parameters are taken from the data stack, and the return value is pushed on the data stack after the function returns. A return type of " { $link void } " indicates that no value is to be expected." } { $notes "C type names are documented in " { $link "c-types-specs" } "." } { $errors "Throws an " { $link alien-invoke-error } " if the word calling " { $link alien-invoke } " was not compiled with the optimizing compiler." } ; @@ -85,7 +85,7 @@ HELP: alien-indirect-error } ; HELP: alien-indirect -{ $values { "..." "zero or more objects passed to the C function" } { "funcptr" "a C function pointer" } { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } } +{ $values { "args..." "zero or more objects passed to the C function" } { "funcptr" "a C function pointer" } { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } { "return..." "the return value of the function, if not " { $link void } } } { $description "Invokes a C function pointer passed on the data stack. Input parameters are taken from the data stack following the function pointer, and the return value is pushed on the data stack after the function returns. A return type of " { $link void } " indicates that no value is to be expected." } @@ -128,7 +128,7 @@ HELP: alien-assembly-error } ; HELP: alien-assembly -{ $values { "..." "zero or more objects passed to the C function" } { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } { "quot" quotation } } +{ $values { "args..." "zero or more objects passed to the C function" } { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } { "quot" quotation } { "return..." "the return value of the function, if not " { $link void } } } { $description "Invokes arbitrary machine code, generated at compile-time by the quotation. Input parameters are taken from the data stack, and the return value is pushed on the data stack after the function returns. A return type of " { $link void } " indicates that no value is to be expected." } diff --git a/core/alien/alien.factor b/core/alien/alien.factor index 3802147838..631fdcfc93 100644 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -70,17 +70,17 @@ ERROR: alien-callback-error ; ERROR: alien-indirect-error ; -: alien-indirect ( ... funcptr return parameters abi -- ... ) +: alien-indirect ( args... funcptr return parameters abi -- return... ) alien-indirect-error ; ERROR: alien-invoke-error library symbol ; -: alien-invoke ( ... return library function parameters -- ... ) +: alien-invoke ( args... return library function parameters -- return... ) 2over alien-invoke-error ; ERROR: alien-assembly-error code ; -: alien-assembly ( ... return parameters abi quot -- ... ) +: alien-assembly ( args... return parameters abi quot -- return... ) dup alien-assembly-error ; ! Callbacks are registered in a global hashtable. Note that they diff --git a/core/classes/tuple/tuple-docs.factor b/core/classes/tuple/tuple-docs.factor index 7f6078e321..b3bdcb4673 100644 --- a/core/classes/tuple/tuple-docs.factor +++ b/core/classes/tuple/tuple-docs.factor @@ -421,8 +421,8 @@ HELP: ( layout -- tuple ) { $values { "layout" "a tuple layout array" } { "tuple" tuple } } { $description "Low-level tuple constructor. User code should never call this directly, and instead use " { $link new } "." } ; -HELP: ( ... layout -- tuple ) -{ $values { "..." "values" } { "layout" "a tuple layout array" } { "tuple" tuple } } +HELP: ( slots... layout -- tuple ) +{ $values { "slots..." "values" } { "layout" "a tuple layout array" } { "tuple" tuple } } { $description "Low-level tuple constructor. User code should never call this directly, and instead use " { $link boa } "." } ; HELP: new @@ -439,7 +439,7 @@ HELP: new } ; HELP: boa -{ $values { "..." "slot values" } { "class" tuple-class } { "tuple" tuple } } +{ $values { "slots..." "slot values" } { "class" tuple-class } { "tuple" tuple } } { $description "Creates a new instance of " { $snippet "class" } " and fill in the slots from the stack, with the top-most stack element being stored in the right-most slot." } { $notes "The name " { $snippet "boa" } " is shorthand for “by order of arguments”, and “BOA constructor” is a pun on “boa constrictor”." } { $errors "Throws an error if the slot values do not match class declarations on slots (see" { $link "tuple-declarations" } ")." } ; diff --git a/core/combinators/combinators-docs.factor b/core/combinators/combinators-docs.factor index 31183a629e..5b1ce8e80c 100644 --- a/core/combinators/combinators-docs.factor +++ b/core/combinators/combinators-docs.factor @@ -295,7 +295,7 @@ HELP: spread { bi* tri* spread } related-words HELP: to-fixed-point -{ $values { "object" object } { "quot" { $quotation "( object(n) -- object(n+1) )" } } { "object(n)" object } } +{ $values { "object" object } { "quot" { $quotation "( ... object(n) -- ... object(n+1) )" } } { "object(n)" object } } { $description "Applies the quotation repeatedly with " { $snippet "object" } " as the initial input until the output of the quotation equals the input." } { $examples { $example diff --git a/core/continuations/continuations-docs.factor b/core/continuations/continuations-docs.factor index 766a78c483..3710680269 100644 --- a/core/continuations/continuations-docs.factor +++ b/core/continuations/continuations-docs.factor @@ -182,7 +182,7 @@ HELP: cleanup { $description "Calls the " { $snippet "try" } " quotation. If no error is thrown, calls " { $snippet "cleanup-always" } " without restoring the data stack. If an error is thrown, restores the data stack, calls " { $snippet "cleanup-always" } " followed by " { $snippet "cleanup-error" } ", and rethrows the error." } ; HELP: recover -{ $values { "try" quotation } { "recovery" { $quotation "( error -- )" } } } +{ $values { "try" { $quotation "( ..a -- ..b )" } } { "recovery" { $quotation "( ..a error -- ..b )" } } } { $description "Calls the " { $snippet "try" } " quotation. If an exception is thrown in the dynamic extent of the " { $snippet "try" } " quotation, restores the data stack and calls the " { $snippet "recovery" } " quotation to handle the error." } ; HELP: ignore-errors diff --git a/core/kernel/kernel-docs.factor b/core/kernel/kernel-docs.factor index 8b9650fc31..8512700852 100644 --- a/core/kernel/kernel-docs.factor +++ b/core/kernel/kernel-docs.factor @@ -169,7 +169,7 @@ HELP: xor { $notes "This word implements boolean exclusive or, so applying it to integers will not yield useful results (all integers have a true value). Bitwise exclusive or is the " { $link bitxor } " word." } ; HELP: both? -{ $values { "x" object } { "y" object } { "quot" { $quotation "( obj -- ? )" } } { "?" "a boolean" } } +{ $values { "x" object } { "y" object } { "quot" { $quotation "( ... obj -- ... ? )" } } { "?" "a boolean" } } { $description "Tests if the quotation yields a true value when applied to both " { $snippet "x" } " and " { $snippet "y" } "." } { $examples { $example "USING: kernel math prettyprint ;" "3 5 [ odd? ] both? ." "t" } @@ -177,7 +177,7 @@ HELP: both? } ; HELP: either? -{ $values { "x" object } { "y" object } { "quot" { $quotation "( obj -- ? )" } } { "?" "a boolean" } } +{ $values { "x" object } { "y" object } { "quot" { $quotation "( ... obj -- ... ? )" } } { "?" "a boolean" } } { $description "Tests if the quotation yields a true value when applied to either " { $snippet "x" } " or " { $snippet "y" } "." } { $examples { $example "USING: kernel math prettyprint ;" "3 6 [ odd? ] either? ." "t" } @@ -214,22 +214,22 @@ HELP: call-clear ( quot -- * ) { $notes "Used to implement " { $link "threads" } "." } ; HELP: keep -{ $values { "x" object } { "quot" { $quotation "( x -- ... )" } } } +{ $values { "x" object } { "quot" { $quotation "( ..a x -- ..b )" } } } { $description "Call a quotation with a value on the stack, restoring the value when the quotation returns." } { $examples { $example "USING: arrays kernel prettyprint ;" "2 \"greetings\" [ ] keep 2array ." "{ { \"greetings\" \"greetings\" } \"greetings\" }" } } ; HELP: 2keep -{ $values { "x" object } { "y" object } { "quot" { $quotation "( x y -- ... )" } } } +{ $values { "x" object } { "y" object } { "quot" { $quotation "( ..a x y -- ..b )" } } } { $description "Call a quotation with two values on the stack, restoring the values when the quotation returns." } ; HELP: 3keep -{ $values { "x" object } { "y" object } { "z" object } { "quot" { $quotation "( x y z -- ... )" } } } +{ $values { "x" object } { "y" object } { "z" object } { "quot" { $quotation "( ..a x y z -- ..b )" } } } { $description "Call a quotation with three values on the stack, restoring the values when the quotation returns." } ; HELP: bi -{ $values { "x" object } { "p" { $quotation "( x -- ... )" } } { "q" { $quotation "( x -- ... )" } } } +{ $values { "x" object } { "p" { $quotation "( ..a x -- ..b )" } } { "q" { $quotation "( ..c x -- ..d )" } } } { $description "Applies " { $snippet "p" } " to " { $snippet "x" } ", then applies " { $snippet "q" } " to " { $snippet "x" } "." } { $examples "If " { $snippet "[ p ]" } " and " { $snippet "[ q ]" } " have stack effect " { $snippet "( x -- )" } ", then the following two lines are equivalent:" @@ -595,7 +595,7 @@ $nl "The " { $snippet "cond" } " value is removed from the stack before the quotation is called." } ; HELP: if* -{ $values { "?" "a generalized boolean" } { "true" { $quotation "( cond -- ... )" } } { "false" quotation } } +{ $values { "?" "a generalized boolean" } { "true" { $quotation "( ..a ? -- ..b )" } } { "false" { $quotation "( ..a -- ..b )" } } } { $description "Alternative conditional form that preserves the " { $snippet "cond" } " value if it is true." $nl "If the condition is true, it is retained on the stack before the " { $snippet "true" } " quotation is called. Otherwise, the condition is removed from the stack and the " { $snippet "false" } " quotation is called." @@ -618,7 +618,7 @@ HELP: unless* { $code "X [ Y ] unless*" "X dup [ ] [ drop Y ] if" } } ; HELP: ?if -{ $values { "default" object } { "cond" "a generalized boolean" } { "true" { $quotation "( cond -- ... )" } } { "false" { $quotation "( default -- ... )" } } } +{ $values { "default" object } { "cond" "a generalized boolean" } { "true" { $quotation "( ..a cond -- ..b )" } } { "false" { $quotation "( ..a default -- ..b )" } } } { $description "If the condition is " { $link f } ", the " { $snippet "false" } " quotation is called with the " { $snippet "default" } " value on the stack. Otherwise, the " { $snippet "true" } " quotation is called with the condition on the stack." } { $notes "The following two lines are equivalent:" @@ -771,15 +771,15 @@ HELP: 4dip } ; HELP: while -{ $values { "pred" { $quotation "( -- ? )" } } { "body" "a quotation" } } +{ $values { "pred" { $quotation "( ..a -- ..b ? )" } } { "body" { $quotation "( ..b -- ..a )" } } } { $description "Calls " { $snippet "body" } " until " { $snippet "pred" } " returns " { $link f } "." } ; HELP: until -{ $values { "pred" { $quotation "( -- ? )" } } { "body" "a quotation" } } +{ $values { "pred" { $quotation "( ..a -- ..b ? )" } } { "body" { $quotation "( ..b -- ..a )" } } } { $description "Calls " { $snippet "body" } " until " { $snippet "pred" } " returns " { $link t } "." } ; HELP: do -{ $values { "pred" { $quotation "( -- ? )" } } { "body" "a quotation" } } +{ $values { "pred" { $quotation "( ..a -- ..b ? )" } } { "body" { $quotation "( ..b -- ..a )" } } } { $description "Executes one iteration of a " { $link while } " or " { $link until } " loop." } ; HELP: loop diff --git a/core/kernel/kernel.factor b/core/kernel/kernel.factor index 3a53eb91e2..e506b7fc27 100644 --- a/core/kernel/kernel.factor +++ b/core/kernel/kernel.factor @@ -226,7 +226,7 @@ M: callstack clone (clone) ; inline ! Tuple construction GENERIC: new ( class -- tuple ) -GENERIC: boa ( ... class -- tuple ) +GENERIC: boa ( slots... class -- tuple ) ! Error handling -- defined early so that other files can ! throw errors before continuations are loaded diff --git a/core/lexer/lexer-docs.factor b/core/lexer/lexer-docs.factor index 04985a4340..3dc534cdfd 100644 --- a/core/lexer/lexer-docs.factor +++ b/core/lexer/lexer-docs.factor @@ -67,13 +67,13 @@ HELP: still-parsing? { $description "Outputs " { $link f } " if end of input has been reached, " { $link t } " otherwise." } ; HELP: each-token -{ $values { "end" string } { "quot" { $quotation "( token -- )" } } } +{ $values { "end" string } { "quot" { $quotation "( ... token -- ... )" } } } { $description "Reads a sequence of tokens until the first occurrence of " { $snippet "end" } ". " { $snippet "quot" } " is called on each token as it is read." } { $examples "This word is used to implement " { $link POSTPONE: USING: } "." } $parsing-note ; HELP: map-tokens -{ $values { "end" string } { "quot" { $quotation "( token -- object )" } } { "seq" "a new sequence of " { $snippet "object" } "s" } } +{ $values { "end" string } { "quot" { $quotation "( ... token -- ... elt )" } } { "seq" "a new sequence of " { $snippet "object" } "s" } } { $description "Reads a sequence of tokens until the first occurrence of " { $snippet "end" } ". " { $snippet "quot" } " is called on each token as it is read, and the results are collected into a new output sequence." } $parsing-note ; diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor index 50a31434f4..1de443b0c5 100644 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -410,22 +410,22 @@ HELP: power-of-2? { $description "Tests if " { $snippet "n" } " is a power of 2." } ; HELP: each-integer -{ $values { "n" integer } { "quot" { $quotation "( i -- )" } } } +{ $values { "n" integer } { "quot" { $quotation "( ... i -- ... )" } } } { $description "Applies the quotation to each integer from 0 up to " { $snippet "n" } ", excluding " { $snippet "n" } "." } { $notes "This word is used to implement " { $link each } "." } ; HELP: all-integers? -{ $values { "n" integer } { "quot" { $quotation "( i -- ? )" } } { "?" "a boolean" } } +{ $values { "n" integer } { "quot" { $quotation "( ... i -- ... ? )" } } { "?" "a boolean" } } { $description "Applies the quotation to each integer from 0 up to " { $snippet "n" } ", excluding " { $snippet "n" } ". Iteration stops when the quotation outputs " { $link f } " or the end is reached. If the quotation yields a false value for some integer, this word outputs " { $link f } ". Otherwise, this word outputs " { $link t } "." } { $notes "This word is used to implement " { $link all? } "." } ; HELP: find-integer -{ $values { "n" integer } { "quot" { $quotation "( i -- ? )" } } { "i" "an integer or " { $link f } } } +{ $values { "n" integer } { "quot" { $quotation "( ... i -- ... ? )" } } { "i" "an integer or " { $link f } } } { $description "Applies the quotation to each integer from 0 up to " { $snippet "n" } ", excluding " { $snippet "n" } ". Iterationi stops when the quotation outputs a true value or the end is reached. If the quotation yields a true value for some integer, this word outputs that integer. Otherwise, this word outputs " { $link f } "." } { $notes "This word is used to implement " { $link find } "." } ; HELP: find-last-integer -{ $values { "n" integer } { "quot" { $quotation "( i -- ? )" } } { "i" "an integer or " { $link f } } } +{ $values { "n" integer } { "quot" { $quotation "( ... i -- ... ? )" } } { "i" "an integer or " { $link f } } } { $description "Applies the quotation to each integer from " { $snippet "n" } " down to 0, inclusive. Iteration stops when the quotation outputs a true value or 0 is reached. If the quotation yields a true value for some integer, the word outputs that integer. Otherwise, the word outputs " { $link f } "." } { $notes "This word is used to implement " { $link find-last } "." } ; diff --git a/extra/gpu/buffers/buffers-docs.factor b/extra/gpu/buffers/buffers-docs.factor index 9ca1093000..cb1031c7fa 100644 --- a/extra/gpu/buffers/buffers-docs.factor +++ b/extra/gpu/buffers/buffers-docs.factor @@ -203,7 +203,7 @@ HELP: vertex-buffer HELP: with-mapped-buffer { $values - { "buffer" buffer } { "access" buffer-access-mode } { "quot" { $quotation "( alien -- )" } } + { "buffer" buffer } { "access" buffer-access-mode } { "quot" { $quotation "( ..a alien -- ..b )" } } } { $description "Maps " { $snippet "buffer" } " into CPU address space with " { $snippet "access" } " for the dynamic extent of " { $snippet "quot" } ". " { $snippet "quot" } " is called with a pointer to the mapped memory on top of the stack." } ; From 6bf709429b1042aff2f8d5016f0dce1bbe69ced2 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 9 Mar 2010 22:38:41 -0800 Subject: [PATCH 373/713] fix effect of primitive --- core/bootstrap/primitives.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 43aeb6bd70..2772b68875 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -420,7 +420,7 @@ tuple { "(byte-array)" "byte-arrays" "primitive_uninitialized_byte_array" (( n -- byte-array )) } { "" "byte-arrays" "primitive_byte_array" (( n -- byte-array )) } { "resize-byte-array" "byte-arrays" "primitive_resize_byte_array" (( n byte-array -- newbyte-array )) } - { "" "classes.tuple.private" "primitive_tuple_boa" (( ... layout -- tuple )) } + { "" "classes.tuple.private" "primitive_tuple_boa" (( slots... layout -- tuple )) } { "" "classes.tuple.private" "primitive_tuple" (( layout -- tuple )) } { "modify-code-heap" "compiler.units" "primitive_modify_code_heap" (( alist update-existing? reset-pics? -- )) } { "lookup-method" "generic.single.private" "primitive_lookup_method" (( object methods -- method )) } From 1f593f6bbc719da65b2fc96125f2f0cf89b05803 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 11 Mar 2010 19:13:57 +1300 Subject: [PATCH 374/713] furnace.recaptcha: cleanups --- .../furnace/recaptcha/example/example.factor | 2 +- basis/furnace/recaptcha/recaptcha-docs.factor | 2 +- basis/furnace/recaptcha/recaptcha.factor | 28 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/basis/furnace/recaptcha/example/example.factor b/basis/furnace/recaptcha/example/example.factor index 264be678ae..d453edb10e 100644 --- a/basis/furnace/recaptcha/example/example.factor +++ b/basis/furnace/recaptcha/example/example.factor @@ -9,7 +9,7 @@ IN: furnace.recaptcha.example TUPLE: recaptcha-app < dispatcher recaptcha ; -: recaptcha-db ( -- obj ) "recaptcha-example" ; +: recaptcha-db ( -- obj ) "resource:recaptcha-example" ; : ( -- obj ) diff --git a/basis/furnace/recaptcha/recaptcha-docs.factor b/basis/furnace/recaptcha/recaptcha-docs.factor index 1349b5243d..0e901f8bb5 100644 --- a/basis/furnace/recaptcha/recaptcha-docs.factor +++ b/basis/furnace/recaptcha/recaptcha-docs.factor @@ -26,7 +26,7 @@ ARTICLE: "recaptcha-example" "Recaptcha example" { "Wrap the responder in a " { $link } } { "Wrap the responder in a " { $link } " if it is not already" } { "Ensure that there is a database connected, with the " { $link } " word" } - { "Start a conversation to move values between requests" } + { "Start a conversation with " { $link begin-conversation } " to move values between requests" } { "Add a handler calling " { $link validate-recaptcha } " in the " { $slot "submit" } " of the " { $link page-action } } { "Pass the conversation from your submit action using " { $link } } { "Put the chloe tag " { $snippet "" } " inside a form tag in the template for your " { $link page-action } } diff --git a/basis/furnace/recaptcha/recaptcha.factor b/basis/furnace/recaptcha/recaptcha.factor index 99b223b8e3..020b5e472e 100644 --- a/basis/furnace/recaptcha/recaptcha.factor +++ b/basis/furnace/recaptcha/recaptcha.factor @@ -23,23 +23,23 @@ M: recaptcha call-responder* : (render-recaptcha) ( private-key -- xml ) dup -[XML + [XML + - -XML] ; + + XML] ; : recaptcha-url ( secure? -- ? ) - [ "https://api.recaptcha.net/challenge" ] - [ "http://api.recaptcha.net/challenge" ] if + "https://api.recaptcha.net/challenge" "http://api.recaptcha.net/challenge" ? recaptcha-error cget [ "?error=" glue ] when* >url ; : render-recaptcha ( -- xml ) From 0d0f1a92a8d1a3dd6368b4a87f11da28778e5a1d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 11 Mar 2010 19:14:16 +1300 Subject: [PATCH 375/713] websites.concatenative: add a recaptcha to the pastebin --- extra/webapps/pastebin/new-paste.xml | 6 +----- extra/webapps/pastebin/paste.xml | 6 +----- extra/webapps/pastebin/pastebin.factor | 13 +++++++++---- extra/websites/concatenative/concatenative.factor | 11 +++++++++-- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/extra/webapps/pastebin/new-paste.xml b/extra/webapps/pastebin/new-paste.xml index 9866c8819a..b202a19a0a 100644 --- a/extra/webapps/pastebin/new-paste.xml +++ b/extra/webapps/pastebin/new-paste.xml @@ -11,11 +11,7 @@ Author: Mode: Body: - Captcha: - - - Leave the captcha blank. Spam-bots will fill it indiscriminantly, so their attempts to register will be blocked. - +

diff --git a/extra/webapps/pastebin/paste.xml b/extra/webapps/pastebin/paste.xml index 6e1cb53664..d88e66450c 100644 --- a/extra/webapps/pastebin/paste.xml +++ b/extra/webapps/pastebin/paste.xml @@ -47,11 +47,7 @@ Author: Mode: Body: - Captcha: - - - Leave the captcha blank. Spam-bots will fill it indiscriminantly, so their attempts to register will be blocked. - +

diff --git a/extra/webapps/pastebin/pastebin.factor b/extra/webapps/pastebin/pastebin.factor index 48e6ed030b..684f6f0784 100644 --- a/extra/webapps/pastebin/pastebin.factor +++ b/extra/webapps/pastebin/pastebin.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2007, 2008 Slava Pestov +! Copyright (C) 2007, 2010 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. USING: namespaces assocs sorting sequences kernel accessors hashtables db.types db.tuples db combinators @@ -17,7 +17,9 @@ furnace.redirection furnace.auth furnace.auth.login furnace.boilerplate -furnace.syndication ; +furnace.recaptcha +furnace.syndication +furnace.conversations ; IN: webapps.pastebin TUPLE: pastebin < dispatcher ; @@ -156,8 +158,11 @@ M: annotation entity-url { "author" [ v-one-line ] } { "mode" [ v-mode ] } { "contents" [ v-required ] } - { "captcha" [ v-captcha ] } - } validate-params ; + } validate-params + + begin-conversation + validate-recaptcha + recaptcha-valid? cget [ validation-failed ] unless ; : deposit-entity-slots ( tuple -- ) now >>date diff --git a/extra/websites/concatenative/concatenative.factor b/extra/websites/concatenative/concatenative.factor index 92a4942fe6..efa4c4b635 100644 --- a/extra/websites/concatenative/concatenative.factor +++ b/extra/websites/concatenative/concatenative.factor @@ -19,6 +19,7 @@ furnace.auth.features.registration furnace.auth.features.deactivate-user furnace.boilerplate furnace.redirection +furnace.recaptcha webapps.pastebin webapps.planet webapps.wiki @@ -54,6 +55,12 @@ TUPLE: factor-website < dispatcher ; allow-edit-profile allow-deactivation ; +: ( responder -- responder' ) + + "concatenative.org" >>domain + "6LeJWQgAAAAAAFlYV7SuBClE9uSpGtV_ZS-qVON7" >>public-key + "6LeJWQgAAAAAALh-XJgSSQ6xKygRgJ8-029Ip2Xv" >>private-key ; + : ( -- responder ) factor-website new-dispatcher URL" /wiki/view/Front Page" "" add-responder ; @@ -77,7 +84,7 @@ SYMBOL: dh-file "wiki" add-responder "user-admin" add-responder - "pastebin" add-responder + "pastebin" add-responder "planet" add-responder "mason" add-responder "/tmp/docs/" "docs" add-responder @@ -96,7 +103,7 @@ SYMBOL: dh-file "wiki" add-responder "user-admin" add-responder test-db "concatenative.org" add-responder - test-db "paste.factorcode.org" add-responder + test-db "paste.factorcode.org" add-responder test-db "planet.factorcode.org" add-responder test-db "builds.factorcode.org" add-responder home "docs" append-path "docs.factorcode.org" add-responder From fd767b7d31c8acbbe46f15bf5d64e80898184138 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 11 Mar 2010 21:02:39 +1300 Subject: [PATCH 376/713] furnace.recaptcha: make it easier to use --- .../furnace/recaptcha/example/example.factor | 14 +++---- basis/furnace/recaptcha/example/example.xml | 2 +- basis/furnace/recaptcha/recaptcha-docs.factor | 37 ++++++++++--------- basis/furnace/recaptcha/recaptcha.factor | 28 ++++++++------ extra/webapps/pastebin/pastebin.factor | 5 +-- 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/basis/furnace/recaptcha/example/example.factor b/basis/furnace/recaptcha/example/example.factor index d453edb10e..3650e2bcf9 100644 --- a/basis/furnace/recaptcha/example/example.factor +++ b/basis/furnace/recaptcha/example/example.factor @@ -13,19 +13,15 @@ TUPLE: recaptcha-app < dispatcher recaptcha ; : ( -- obj ) - [ - begin-conversation - validate-recaptcha - recaptcha-valid? cget - "?good" "?bad" ? >url - ] >>submit + [ validate-recaptcha ] >>validate + [ "?good" >url ] >>submit { recaptcha-app "example" } >>template ; : ( -- obj ) \ recaptcha-app new-dispatcher "" add-responder - "concatenative.org" >>domain - "6LeJWQgAAAAAAFlYV7SuBClE9uSpGtV_ZS-qVON7" >>public-key - "6LeJWQgAAAAAALh-XJgSSQ6xKygRgJ8-029Ip2Xv" >>private-key + "concatenative.org" >>domain + "6LeJWQgAAAAAAFlYV7SuBClE9uSpGtV_ZS-qVON7" >>public-key + "6LeJWQgAAAAAALh-XJgSSQ6xKygRgJ8-029Ip2Xv" >>private-key recaptcha-db ; diff --git a/basis/furnace/recaptcha/example/example.xml b/basis/furnace/recaptcha/example/example.xml index e59f441f7f..2553b332ef 100644 --- a/basis/furnace/recaptcha/example/example.xml +++ b/basis/furnace/recaptcha/example/example.xml @@ -1,4 +1,4 @@ -
+
diff --git a/basis/furnace/recaptcha/recaptcha-docs.factor b/basis/furnace/recaptcha/recaptcha-docs.factor index 0e901f8bb5..9e5d046a1d 100644 --- a/basis/furnace/recaptcha/recaptcha-docs.factor +++ b/basis/furnace/recaptcha/recaptcha-docs.factor @@ -7,43 +7,41 @@ IN: furnace.recaptcha HELP: { $values { "responder" "a responder" } - { "obj" object } + { "recaptcha" recaptcha } } -{ $description "A " { $link filter-responder } " wrapping another responder. Set the domain, public, and private keys using the key you get by registering with Recaptcha." } ; +{ $description "A " { $link filter-responder } " wrapping another responder. Set the domain, public, and private keys using the key you get by registering with recaptcha." } ; HELP: recaptcha-error -{ $var-description "Set to the error string returned by the Recaptcha server." } ; +{ $var-description "Set to the error string returned by the recaptcha server." } ; HELP: recaptcha-valid? -{ $var-description "Set to " { $link t } " if the user solved the last Recaptcha correctly." } ; +{ $var-description "Set to " { $link t } " if the user solved the last recaptcha correctly." } ; HELP: validate-recaptcha -{ $description "Validates a Recaptcha using the Recaptcha web service API." } ; +{ $description "Validates a recaptcha using the recaptcha web service API." } ; ARTICLE: "recaptcha-example" "Recaptcha example" -"There are several steps to using the Recaptcha library." +"There are several steps to using the recaptcha library." { $list { "Wrap the responder in a " { $link } } - { "Wrap the responder in a " { $link } " if it is not already" } - { "Ensure that there is a database connected, with the " { $link } " word" } - { "Start a conversation with " { $link begin-conversation } " to move values between requests" } - { "Add a handler calling " { $link validate-recaptcha } " in the " { $slot "submit" } " of the " { $link page-action } } - { "Pass the conversation from your submit action using " { $link } } - { "Put the chloe tag " { $snippet "" } " inside a form tag in the template for your " { $link page-action } } + { "Wrap the responder in an " { $link } " if it is not already, to enable conversations and database access" } + { "Call " { $link validate-recaptcha } " from the " { $slot "validate" } " slot of the " { $link action } } + { "Put the chloe tag " { $snippet "" } " inside a form tag in the template served by your " { $link action } } } $nl -"Run this example vocabulary:" +"There is an example web app using recaptcha support:" { $code - "USE: furnace.recaptcha.example" + "USING: furnace.recaptcha.example http.server ;" " main-responder set-global" + "8080 httpd" } ; -ARTICLE: "furnace.recaptcha" "Recaptcha" -"The " { $vocab-link "furnace.recaptcha" } " vocabulary implements support for the Recaptcha. Recaptcha is a web service that provides the user with a captcha, a test that is easy to solve by visual inspection, but hard to solve by writing a computer program. Use a captcha to protect forms from abusive users." $nl +ARTICLE: "furnace.recaptcha" "Recaptcha support for Furnace" +"The " { $vocab-link "furnace.recaptcha" } " vocabulary implements support for the recaptcha. Recaptcha is a web service that provides the user with a captcha, a test that is easy to solve by visual inspection, but hard to solve by writing a computer program. Use a captcha to protect forms from abusive users." $nl -"The recaptcha responder is a " { $link filter-responder } " that wraps another responder. Set the " { $slot "domain" } ", " { $slot "public-key" } ", and " { $slot "private-key" } " slots of this responder to your Recaptcha account information." $nl +"The recaptcha responder is a " { $link filter-responder } " that wraps another responder. Set the " { $slot "domain" } ", " { $slot "public-key" } ", and " { $slot "private-key" } " slots of this responder to your recaptcha account information." $nl -"Wrapping a responder with Recaptcha:" +"Wrapping a responder with recaptcha support:" { $subsections } "Validating recaptcha:" { $subsections validate-recaptcha } @@ -51,6 +49,9 @@ ARTICLE: "furnace.recaptcha" "Recaptcha" { $subsections recaptcha-valid? recaptcha-error +} +"An example:" +{ $subsections "recaptcha-example" } ; diff --git a/basis/furnace/recaptcha/recaptcha.factor b/basis/furnace/recaptcha/recaptcha.factor index 020b5e472e..d99af16a52 100644 --- a/basis/furnace/recaptcha/recaptcha.factor +++ b/basis/furnace/recaptcha/recaptcha.factor @@ -11,12 +11,12 @@ TUPLE: recaptcha < filter-responder domain public-key private-key ; SYMBOLS: recaptcha-valid? recaptcha-error ; -: ( responder -- obj ) +: ( responder -- recaptcha ) recaptcha new swap >>responder ; M: recaptcha call-responder* - dup \ recaptcha set + dup recaptcha set responder>> call-responder ; http-request nip parse-recaptcha-response ; -CHLOE: recaptcha - drop [ render-recaptcha ] [xml-code] ; - -PRIVATE> - -: validate-recaptcha ( -- ) +: validate-recaptcha-params ( -- ) { { "recaptcha_challenge_field" [ v-required ] } { "recaptcha_response_field" [ v-required ] } - } validate-params + } validate-params ; + +PRIVATE> + +CHLOE: recaptcha drop [ render-recaptcha ] [xml-code] ; + +: validate-recaptcha ( -- ) + begin-conversation + validate-recaptcha-params + "recaptcha_challenge_field" value "recaptcha_response_field" value - \ recaptcha get (validate-recaptcha) - [ recaptcha-valid? cset ] [ recaptcha-error cset ] bi* ; + recaptcha get + (validate-recaptcha) + recaptcha-error cset + [ validation-failed ] unless ; diff --git a/extra/webapps/pastebin/pastebin.factor b/extra/webapps/pastebin/pastebin.factor index 684f6f0784..fccf47d468 100644 --- a/extra/webapps/pastebin/pastebin.factor +++ b/extra/webapps/pastebin/pastebin.factor @@ -159,10 +159,7 @@ M: annotation entity-url { "mode" [ v-mode ] } { "contents" [ v-required ] } } validate-params - - begin-conversation - validate-recaptcha - recaptcha-valid? cget [ validation-failed ] unless ; + validate-recaptcha ; : deposit-entity-slots ( tuple -- ) now >>date From 3189c8d7a16feb61c8f8e3b8fdbb0bbbde506123 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 11 Mar 2010 21:13:22 +1300 Subject: [PATCH 377/713] furnace.recaptcha: remove unused variable --- basis/furnace/recaptcha/recaptcha.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/furnace/recaptcha/recaptcha.factor b/basis/furnace/recaptcha/recaptcha.factor index d99af16a52..38ba8e2b1f 100644 --- a/basis/furnace/recaptcha/recaptcha.factor +++ b/basis/furnace/recaptcha/recaptcha.factor @@ -9,7 +9,7 @@ IN: furnace.recaptcha TUPLE: recaptcha < filter-responder domain public-key private-key ; -SYMBOLS: recaptcha-valid? recaptcha-error ; +SYMBOL: recaptcha-error : ( responder -- recaptcha ) recaptcha new From 26ff757de498cc7795689109d776c75f1e371a6b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 11 Mar 2010 00:53:40 -0800 Subject: [PATCH 378/713] carve the tough, gamey steak of stack-checker.polymorphism into chewable morsels --- .../row-polymorphism/row-polymorphism.factor | 61 +++++++++---------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index 29ee63bf33..ef47dfe285 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -10,27 +10,21 @@ stack-checker.values stack-checker.visitor ; IN: stack-checker.row-polymorphism -:: with-inner-d ( quot -- inner-d ) - inner-d-index get :> old-inner-d-index - meta-d length inner-d-index set - quot call - inner-d-index get :> new-inner-d-index - old-inner-d-index new-inner-d-index min inner-d-index set - new-inner-d-index ; inline +: with-inner-d ( quot -- inner-d ) + inner-d-index get + [ meta-d length inner-d-index set call ] dip + inner-d-index get [ min inner-d-index set ] keep ; inline -:: with-effect-here ( quot -- effect ) - input-count get :> old-input-count - meta-d length :> old-meta-d-length +:: (effect-here) ( inner-d old-meta-d-length old-input-count -- effect ) + old-meta-d-length inner-d - input-count get old-input-count - + + meta-d length inner-d - + [ "x" ] bi@ terminated? get ; inline - quot with-inner-d :> inner-d - - input-count get :> new-input-count - old-meta-d-length inner-d - - new-input-count old-input-count - + :> in - meta-d length inner-d - :> out - in "x" out "x" terminated? get ; inline +: with-effect-here ( quot -- effect ) + meta-d length input-count get + [ with-inner-d ] 2dip (effect-here) ; inline -:: check-variable ( actual-count declared-count variable vars -- difference ? ) +:: (check-variable) ( actual-count declared-count variable vars -- difference ? ) actual-count declared-count - variable [ variable vars at* nip @@ -44,20 +38,25 @@ IN: stack-checker.row-polymorphism [ at+ ] [ 3drop ] if ; inline -:: check-variables ( vars declared actual -- ? ) - actual terminated?>> [ t ] [ - actual declared [ in>> length ] bi@ declared in-var>> - [ vars check-variable ] keep :> ( in-diff in-ok? in-var ) - actual declared [ out>> length ] bi@ declared out-var>> - [ vars check-variable ] keep :> ( out-diff out-ok? out-var ) - { [ in-ok? ] [ out-ok? ] [ in-diff out-diff = ] } 0&& - dup [ - in-var [ in-diff swap vars adjust-variable ] when* - out-var [ out-diff swap vars adjust-variable ] when* - ] when +:: check-variable ( vars declared actual slot var-slot -- diff ok? var ) + actual declared [ slot call length ] bi@ declared var-slot call + [ vars (check-variable) ] keep ; inline + +:: unify-variables ( in-diff in-ok? in-var out-diff out-ok? out-var vars -- ? ) + { [ in-ok? ] [ out-ok? ] [ in-diff out-diff = ] } 0&& + dup [ + in-var [ in-diff swap vars adjust-variable ] when* + out-var [ out-diff swap vars adjust-variable ] when* + ] when ; + +: check-variables ( vars declared actual -- ? ) + dup terminated?>> [ 3drop t ] [ + [ [ in>> ] [ in-var>> ] check-variable ] + [ [ out>> ] [ out-var>> ] check-variable ] + [ 2drop ] 3tri unify-variables ] if ; -: complex-unbalanced-branches-error ( known -- * ) +: combinator-unbalanced-branches-error ( known -- * ) [ word>> ] [ branches>> [ [ known>callable ] { } map-as ] @@ -68,5 +67,5 @@ IN: stack-checker.row-polymorphism : check-declared-effect ( known effect -- ) [ >>actual ] keep 2dup [ [ variables>> ] [ effect>> ] bi ] dip check-variables - [ 2drop ] [ drop complex-unbalanced-branches-error ] if ; + [ 2drop ] [ drop combinator-unbalanced-branches-error ] if ; From d001c1f3752be26e14593412dfeb59a0a628c27a Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 11 Mar 2010 01:03:40 -0800 Subject: [PATCH 379/713] carve up effects.parser too --- core/effects/parser/parser.factor | 41 ++++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/core/effects/parser/parser.factor b/core/effects/parser/parser.factor index e806f1befc..2748df4bc8 100644 --- a/core/effects/parser/parser.factor +++ b/core/effects/parser/parser.factor @@ -13,28 +13,35 @@ ERROR: stack-effect-omits-dashes ; SYMBOL: effect-var -: parse-var ( first? var name -- var ) + + : parse-effect-token ( first? var end -- var more? ) - scan [ nip ] [ = ] 2bi [ drop nip f ] [ - dup { f "(" "((" "--" } member? [ bad-effect ] [ - dup { ")" "))" } member? [ stack-effect-omits-dashes ] [ - ".." ?head [ parse-var t ] [ - [ drop ] 2dip - ":" ?tail [ - scan { - { [ dup "(" = ] [ drop ")" parse-effect ] } - { [ dup f = ] [ ")" unexpected-eof ] } - [ parse-word dup class? [ bad-effect ] unless ] - } cond 2array - ] when , t - ] if - ] if - ] if - ] if ; + scan { + { [ end-token? ] [ drop nip f ] } + { [ effect-opener? ] [ bad-effect ] } + { [ effect-closer? ] [ stack-effect-omits-dashes ] } + { [ effect-variable? ] [ parse-effect-var t ] } + [ [ drop ] 2dip parse-effect-value , t ] + } cond ; : parse-effect-tokens ( end -- var tokens ) [ From 8b1b7b20d57fa74e20a72de81fb67417b3f4779b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 11 Mar 2010 01:25:13 -0800 Subject: [PATCH 380/713] effect-variable -> row-variable --- core/effects/effects-tests.factor | 4 ++-- core/effects/parser/parser.factor | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/effects/effects-tests.factor b/core/effects/effects-tests.factor index af4675d6f2..4dd5502046 100644 --- a/core/effects/effects-tests.factor +++ b/core/effects/effects-tests.factor @@ -38,7 +38,7 @@ IN: effects.tests [ { "e" } ] [ (( ..a b c -- ..d e )) out>> ] unit-test [ "(( a ..b c -- d ))" eval( -- effect ) ] -[ error>> invalid-effect-variable? ] must-fail-with +[ error>> invalid-row-variable? ] must-fail-with [ "(( ..a: integer b c -- d ))" eval( -- effect ) ] -[ error>> effect-variable-can't-have-type? ] must-fail-with +[ error>> row-variable-can't-have-type? ] must-fail-with diff --git a/core/effects/parser/parser.factor b/core/effects/parser/parser.factor index 2748df4bc8..cd484ddd2e 100644 --- a/core/effects/parser/parser.factor +++ b/core/effects/parser/parser.factor @@ -7,8 +7,8 @@ IN: effects.parser DEFER: parse-effect ERROR: bad-effect ; -ERROR: invalid-effect-variable ; -ERROR: effect-variable-can't-have-type ; +ERROR: invalid-row-variable ; +ERROR: row-variable-can't-have-type ; ERROR: stack-effect-omits-dashes ; SYMBOL: effect-var @@ -17,12 +17,12 @@ SYMBOL: effect-var : end-token? ( end token -- token ? ) [ nip ] [ = ] 2bi ; inline : effect-opener? ( token -- token ? ) dup { f "(" "((" "--" } member? ; inline : effect-closer? ( token -- token ? ) dup { ")" "))" } member? ; inline -: effect-variable? ( token -- token' ? ) ".." ?head ; inline +: row-variable? ( token -- token' ? ) ".." ?head ; inline : parse-effect-var ( first? var name -- var ) nip - [ ":" ?tail [ effect-variable-can't-have-type ] when ] curry - [ invalid-effect-variable ] if ; + [ ":" ?tail [ row-variable-can't-have-type ] when ] curry + [ invalid-row-variable ] if ; : parse-effect-value ( token -- value ) ":" ?tail [ @@ -39,7 +39,7 @@ PRIVATE> { [ end-token? ] [ drop nip f ] } { [ effect-opener? ] [ bad-effect ] } { [ effect-closer? ] [ stack-effect-omits-dashes ] } - { [ effect-variable? ] [ parse-effect-var t ] } + { [ row-variable? ] [ parse-effect-var t ] } [ [ drop ] 2dip parse-effect-value , t ] } cond ; From c35dd7c2ef9029b3e4fdbb7ba10ed79bf5ec91d6 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 11 Mar 2010 01:37:33 -0800 Subject: [PATCH 381/713] make effect<= work with univariable stack effects, deny all bivariable stack effects --- core/effects/effects-tests.factor | 7 +++++++ core/effects/effects.factor | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/core/effects/effects-tests.factor b/core/effects/effects-tests.factor index 4dd5502046..0afc61047d 100644 --- a/core/effects/effects-tests.factor +++ b/core/effects/effects-tests.factor @@ -10,6 +10,13 @@ IN: effects.tests [ 2 ] [ (( a b -- c )) in>> length ] unit-test [ 1 ] [ (( a b -- c )) out>> length ] unit-test +[ t ] [ (( a b -- c )) (( ... a b -- ... c )) effect<= ] unit-test +[ t ] [ (( b -- )) (( ... a b -- ... c )) effect<= ] unit-test +[ f ] [ (( ... a b -- ... c )) (( a b -- c )) effect<= ] unit-test +[ f ] [ (( ... b -- ... )) (( a b -- c )) effect<= ] unit-test +[ f ] [ (( a b -- c )) (( ... a b -- c )) effect<= ] unit-test +[ f ] [ (( a b -- c )) (( ..x a b -- ..y c )) effect<= ] unit-test + [ "(( object -- object ))" ] [ { f } { f } unparse ] unit-test [ "(( a b -- c d ))" ] [ { "a" "b" } { "c" "d" } unparse ] unit-test [ "(( -- c d ))" ] [ { } { "c" "d" } unparse ] unit-test diff --git a/core/effects/effects.factor b/core/effects/effects.factor index c049f16f4a..216f50dd8e 100644 --- a/core/effects/effects.factor +++ b/core/effects/effects.factor @@ -27,10 +27,17 @@ TUPLE: effect : effect-height ( effect -- n ) [ out>> length ] [ in>> length ] bi - ; inline +: variable-effect? ( effect -- ? ) + [ in-var>> ] [ out-var>> ] bi or ; +: bivariable-effect? ( effect -- ? ) + [ in-var>> ] [ out-var>> ] bi = not ; + : effect<= ( effect1 effect2 -- ? ) { { [ over terminated?>> ] [ t ] } { [ dup terminated?>> ] [ f ] } + { [ 2dup [ bivariable-effect? ] either? ] [ f ] } + { [ 2dup [ variable-effect? ] [ variable-effect? not ] bi* and ] [ f ] } { [ 2dup [ in>> length ] bi@ > ] [ f ] } { [ 2dup [ effect-height ] bi@ = not ] [ f ] } [ t ] From 274a6ec5ce57bccac6b88d3d6ef058d1cd25c510 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 12 Mar 2010 01:23:28 +1300 Subject: [PATCH 382/713] furnace.recaptcha: fix load error --- basis/furnace/recaptcha/recaptcha-docs.factor | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/basis/furnace/recaptcha/recaptcha-docs.factor b/basis/furnace/recaptcha/recaptcha-docs.factor index 9e5d046a1d..3d23979962 100644 --- a/basis/furnace/recaptcha/recaptcha-docs.factor +++ b/basis/furnace/recaptcha/recaptcha-docs.factor @@ -14,9 +14,6 @@ HELP: HELP: recaptcha-error { $var-description "Set to the error string returned by the recaptcha server." } ; -HELP: recaptcha-valid? -{ $var-description "Set to " { $link t } " if the user solved the last recaptcha correctly." } ; - HELP: validate-recaptcha { $description "Validates a recaptcha using the recaptcha web service API." } ; @@ -45,14 +42,9 @@ ARTICLE: "furnace.recaptcha" "Recaptcha support for Furnace" { $subsections } "Validating recaptcha:" { $subsections validate-recaptcha } -"Symbols set after validation:" -{ $subsections - recaptcha-valid? - recaptcha-error -} +"Symbol set after validation:" +{ $subsections recaptcha-error } "An example:" -{ $subsections - "recaptcha-example" -} ; +{ $subsections "recaptcha-example" } ; ABOUT: "furnace.recaptcha" From 5bccc964986cb06c4fe46fe677fd354de5738bab Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 11 Mar 2010 11:22:28 -0800 Subject: [PATCH 383/713] typo in docs --- core/effects/effects-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/effects/effects-docs.factor b/core/effects/effects-docs.factor index e97120d26b..0d4da504fb 100644 --- a/core/effects/effects-docs.factor +++ b/core/effects/effects-docs.factor @@ -44,7 +44,7 @@ HELP: { "out" "a sequence of strings or string–type pairs" } { "effect" effect } } -{ $description "Constructs an " { $link effect } " object. Each element of " { $snippet "in" } " and " { $snippet "out" } " must be either a string (which is equivalent to a " { $snippet "name" } " in literal stack effect syntax), or a " { $link pair } " where the first element is a string and the second is either a " { $link class } " or effect (which is equivalent to " { $snippet "name: class" } " or " { $snippet "name: ( nested -- effect )" } " in the literal syntax. If the " { $snippet "out" } " array consists of a single string element " { $snippet "\"*\"" } ", a terminating stack effect will be constructed." } +{ $description "Constructs an " { $link effect } " object. Each element of " { $snippet "in" } " and " { $snippet "out" } " must be either a string, which is equivalent to a " { $snippet "name" } " in literal stack effect syntax), or a " { $link pair } " where the first element is a string and the second is either a " { $link class } " or effect, which is equivalent to " { $snippet "name: class" } " or " { $snippet "name: ( nested -- effect )" } " in the literal syntax. If the " { $snippet "out" } " array consists of a single string element " { $snippet "\"*\"" } ", a terminating stack effect will be constructed." } { $notes "This word cannot construct effects with " { $link "effects-variables" } ". Use " { $link } " to construct variable stack effects." } { $examples { $example """USING: effects prettyprint ; From 452f17c859ffc8a537c9d46e3817a7c64b55bd68 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 11 Mar 2010 11:22:43 -0800 Subject: [PATCH 384/713] update effect syntax error names in debugger --- basis/debugger/debugger.factor | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index 69156208b8..a48cc89225 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -328,10 +328,10 @@ M: lexer-error error-help M: bad-effect summary drop "Bad stack effect declaration" ; -M: invalid-effect-variable summary - drop "Stack effect variables can only occur as the first input or output" ; -M: effect-variable-can't-have-type summary - drop "Stack effect variables cannot have a declared type" ; +M: invalid-row-variable summary + drop "Stack effect row variables can only occur as the first input or output" ; +M: row-variable-can't-have-type summary + drop "Stack effect row variables cannot have a declared type" ; M: bad-escape error. "Bad escape code: \\" write From 64c064fb3e4fbb5a54cd30e6dacdf2c16679b005 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 11 Mar 2010 11:23:48 -0800 Subject: [PATCH 385/713] another typo in effects syntax --- core/effects/effects-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/effects/effects-docs.factor b/core/effects/effects-docs.factor index 0d4da504fb..f3f47e8d23 100644 --- a/core/effects/effects-docs.factor +++ b/core/effects/effects-docs.factor @@ -44,7 +44,7 @@ HELP: { "out" "a sequence of strings or string–type pairs" } { "effect" effect } } -{ $description "Constructs an " { $link effect } " object. Each element of " { $snippet "in" } " and " { $snippet "out" } " must be either a string, which is equivalent to a " { $snippet "name" } " in literal stack effect syntax), or a " { $link pair } " where the first element is a string and the second is either a " { $link class } " or effect, which is equivalent to " { $snippet "name: class" } " or " { $snippet "name: ( nested -- effect )" } " in the literal syntax. If the " { $snippet "out" } " array consists of a single string element " { $snippet "\"*\"" } ", a terminating stack effect will be constructed." } +{ $description "Constructs an " { $link effect } " object. Each element of " { $snippet "in" } " and " { $snippet "out" } " must be either a string, which is equivalent to a " { $snippet "name" } " in literal stack effect syntax, or a " { $link pair } " where the first element is a string and the second is either a " { $link class } " or effect, which is equivalent to " { $snippet "name: class" } " or " { $snippet "name: ( nested -- effect )" } " in the literal syntax. If the " { $snippet "out" } " array consists of a single string element " { $snippet "\"*\"" } ", a terminating stack effect will be constructed." } { $notes "This word cannot construct effects with " { $link "effects-variables" } ". Use " { $link } " to construct variable stack effects." } { $examples { $example """USING: effects prettyprint ; From 0d3015cd1ca5e7e7e1120b5fce604934c3d2f7a0 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 11 Mar 2010 11:57:12 -0800 Subject: [PATCH 386/713] fill out row variables docs --- core/effects/effects-docs.factor | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/core/effects/effects-docs.factor b/core/effects/effects-docs.factor index f3f47e8d23..fd77cfab31 100644 --- a/core/effects/effects-docs.factor +++ b/core/effects/effects-docs.factor @@ -6,8 +6,12 @@ ARTICLE: "effects" "Stack effect declarations" { $code "( input1 input2 ... -- output1 ... )" } "Stack elements in a stack effect are ordered so that the top of the stack is on the right side. Here is an example:" { $synopsis + } -"Parameters which are quotations can be declared by suffixing the parameter name with " { $snippet ":" } " and then writing a nested stack effect declaration. If the number of inputs or outputs depends on the stack effects of quotation parameters, " { $link "effects-variables" } " can be used to declare this:" +"Parameters which are quotations can be declared by suffixing the parameter name with " { $snippet ":" } " and then writing a nested stack effect declaration. If the number of inputs or outputs depends on the stack effects of quotation parameters, row variables can be declared:" +{ $subsection "effects-variables" } +"Some examples of row-polymorphic combinators:" { $synopsis while } +{ $synopsis if* } +{ $synopsis each } "For words that are not " { $link POSTPONE: inline } ", only the number of inputs and outputs carries semantic meaning, and effect variables are ignored. However, nested quotation declarations are enforced for inline words. Nested quotation declarations are optional for non-recursive inline combinators and only provide better error messages. However, quotation inputs to " { $link POSTPONE: recursive } " combinators must have an effect declared. See " { $link "inference-recursive-combinators" } "." $nl "In concatenative code, input and output names are for documentation purposes only and certain conventions have been established to make them more descriptive. For code written with " { $link "locals" } ", stack values are bound to local variables named by the stack effect's input parameters." @@ -27,7 +31,6 @@ $nl { { $snippet "loc" } "a screen location specified as a two-element array holding x and y co-ordinates" } { { $snippet "dim" } "a screen dimension specified as a two-element array holding width and height values" } { { $snippet "*" } "when this symbol appears by itself in the list of outputs, it means the word unconditionally throws an error" } - { { $snippet ".." } { "indicates " { $link "effects-variables" } ". only valid as the first input or first output" } } } "For reflection and metaprogramming, you can use " { $link "syntax-effects" } " to include literal stack effects in your code, or these constructor words to construct stack effect objects at runtime:" { $subsections @@ -35,7 +38,6 @@ $nl } -$nl { $see-also "inference" } ; HELP: @@ -96,11 +98,20 @@ f { "a" "b" } f { "c" } .""" """(( a b -- c ))""" } { } related-words -ARTICLE: "effects-variables" "Stack effect variables" -{ $link POSTPONE: inline } " combinators can have variable stack effects, depending on the effect of the quotation they call. For example, while " { $link each } " inputs elements of its sequence to its quotation, the quotation can also manipulate values on the stack below the element, as long as it leaves the same number of elements on the stack. This ability is used to implement " { $link reduce } " in terms of " { $snippet "each" } ". This variable stack effect is indicated by starting the list of inputs and outputs with a name starting with " { $snippet ".." } ":" +ARTICLE: "effects-variables" "Stack effect row variables" +"The stack of effect of many " { $link POSTPONE: inline } " combinators can have variable stack effects, depending on the effect of the quotation they call. For example, the quotation parameter to " { $link each } " receives an element from the input sequence each time it is called, but it can also manipulate values on the stack below the element as long as it leaves the same number of elements on the stack. (This is how " { $link reduce } " is implemented in terms of " { $snippet "each" } ".) The stack effect of an " { $snippet "each" } " expression thus depends on the stack effect of its input quotation:" +{ $example + """USING: io sequences stack-checker ; +[ [ write ] each ] infer.""" +"""( x -- )""" } +{ $example +"""USING: sequences stack-checker ; +[ [ append ] each ] infer.""" +"""( x x -- x )""" } +"This feature is referred to as row polymorphism. Row-polymorphic combinators are declared by including row variables in their stack effect, which are indicated by names starting with " { $snippet ".." } ":" { $synopsis each } -"In combinators with multiple quotation inputs, the number of inputs or outputs represented by a particular " { $snippet ".." } " name must match. For example, the predicate for a " { $link while } " loop can take an arbitrary number of inputs and leave an arbitrary number of outputs on the stack in addition to the predicate result; however, for the loop to leave the stack balanced, the body of the while loop must consume all of the predicate's outputs and leave a number of its own outputs equal to the initial number of stack values before the predicate was called. This is expressed with the following stack effect:" -{ $synopsis while } +"Using the same variable name in both the inputs and outputs (in the above case of " { $snippet "each" } ", " { $snippet "..." } ") indicates that the number of additional inputs and outputs must be the same. Using different variable names indicates that they can be independent. In combinators with multiple quotation inputs, the number of inputs or outputs represented by a particular " { $snippet ".." } " name must match among all of the quotations. For example, the branches of " { $link if* } " can take a different number of inputs from outputs, as long as they both have the same stack height. The true branch receives the test value as an added input. This is declared as follows:" +{ $synopsis if* } "Stack effect variables can only occur as the first input or first output of a stack effect; names starting in " { $snippet ".." } " cause a syntax error if they occur elsewhere in the effect. For words that are not " { $link POSTPONE: inline } ", effect variables are currently ignored by the stack checker." ; ABOUT: "effects" From 16ddd015d342a5caeee124b55608485e05f418c2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 12 Mar 2010 10:22:35 +1300 Subject: [PATCH 387/713] typed: forgetting a final class would throw an error while recompiling typed words depending on it --- basis/stack-checker/dependencies/dependencies.factor | 2 +- basis/typed/typed-tests.factor | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/basis/stack-checker/dependencies/dependencies.factor b/basis/stack-checker/dependencies/dependencies.factor index e2f7c57593..7110fa77ab 100644 --- a/basis/stack-checker/dependencies/dependencies.factor +++ b/basis/stack-checker/dependencies/dependencies.factor @@ -141,7 +141,7 @@ TUPLE: depends-on-final class ; [ \ depends-on-final add-conditional-dependency ] bi ; M: depends-on-final satisfied? - class>> final-class? ; + class>> { [ class? ] [ final-class? ] } 1&& ; : init-dependencies ( -- ) H{ } clone dependencies set diff --git a/basis/typed/typed-tests.factor b/basis/typed/typed-tests.factor index 28ec2b6e86..bca1136ee6 100644 --- a/basis/typed/typed-tests.factor +++ b/basis/typed/typed-tests.factor @@ -1,6 +1,6 @@ USING: accessors effects eval kernel layouts math namespaces quotations tools.test typed words words.symbol -compiler.tree.debugger prettyprint ; +compiler.tree.debugger prettyprint definitions compiler.units ; IN: typed.tests TYPED: f+ ( a: float b: float -- c: float ) @@ -149,3 +149,12 @@ SYMBOL: a-symbol a-symbol get ] with-variable ] unit-test + +! Forgetting an unboxed final class should work +TUPLE: forget-class { x read-only } ; final + +TYPED: forget-fail ( a: forget-class -- ) drop ; + +[ ] [ [ \ forget-class forget ] with-compilation-unit ] unit-test + +[ ] [ [ \ forget-fail forget ] with-compilation-unit ] unit-test From e3fd22268e1b798b0e9cdc20988960fa494e0cdb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 12 Mar 2010 11:05:09 +1300 Subject: [PATCH 388/713] mason.test: forget test definitions to free up code heap space and hopefully get builds to complete on PowerPC --- extra/mason/test/test.factor | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/extra/mason/test/test.factor b/extra/mason/test/test.factor index bd703d3cb9..2421a288ee 100644 --- a/extra/mason/test/test.factor +++ b/extra/mason/test/test.factor @@ -1,11 +1,12 @@ -! Copyright (C) 2008, 2009 Eduardo Cavazos, Slava Pestov. +! Copyright (C) 2008, 2010 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs benchmark bootstrap.stage2 compiler.errors -source-files.errors generic help.html help.lint io.directories -io.encodings.utf8 io.files kernel mason.common math namespaces -prettyprint sequences sets sorting tools.test tools.time -words system io tools.errors vocabs.hierarchy vocabs.errors -vocabs.refresh locals ; +USING: accessors assocs benchmark bootstrap.stage2 +compiler.errors source-files.errors generic help.html help.lint +io.directories io.encodings.utf8 io.files kernel mason.common +math namespaces prettyprint sequences sets sorting tools.test +tools.time words system io tools.errors vocabs vocabs.files +vocabs.hierarchy vocabs.errors vocabs.refresh locals +source-files compiler.units ; IN: mason.test : do-load ( -- ) @@ -32,6 +33,12 @@ M: method word-vocabulary "method-generic" word-prop word-vocabulary ; test-all-errors-file do-step ; +: cleanup-tests ( -- ) + ! Free up some code heap space + [ + vocabs [ vocab-tests [ forget-source ] each ] each + ] with-compilation-unit ; + : do-help-lint ( -- ) help-lint-all lint-failures get values help-lint-vocabs-file @@ -67,6 +74,7 @@ M: method word-vocabulary "method-generic" word-prop word-vocabulary ; [ do-load ] benchmark load-time-file to-file [ generate-help ] benchmark html-help-time-file to-file [ do-tests ] benchmark test-time-file to-file + cleanup-tests [ do-help-lint ] benchmark help-lint-time-file to-file [ do-benchmarks ] benchmark benchmark-time-file to-file do-compile-errors From dfbe1211f737bb4f48a88ba3f108abb629fbf580 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 11 Mar 2010 14:09:18 -0800 Subject: [PATCH 389/713] pre-chew the bite-sized morsels of stack-checker.row-polymorphism so they're easy for old people to digest --- .../row-polymorphism/row-polymorphism.factor | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index ef47dfe285..d91c766fea 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -24,45 +24,41 @@ IN: stack-checker.row-polymorphism meta-d length input-count get [ with-inner-d ] 2dip (effect-here) ; inline -:: (check-variable) ( actual-count declared-count variable vars -- difference ? ) - actual-count declared-count - - variable [ - variable vars at* nip - [ variable vars at - ] - [ variable vars set-at 0 ] if - t - ] [ dup 0 <= ] if ; +: (diff-variable) ( diff variable vars -- diff' ) + [ at* nip ] [ '[ _ _ at - ] ] [ '[ _ _ set-at 0 ] ] 2tri if ; + +: (check-variable) ( actual-count declared-count variable vars -- diff ? ) + [ - ] 2dip dupd '[ _ _ (diff-variable) t ] [ dup 0 <= ] if ; : adjust-variable ( diff var vars -- ) - pick 0 >= - [ at+ ] - [ 3drop ] if ; inline + pick 0 >= [ at+ ] [ 3drop ] if ; inline :: check-variable ( vars declared actual slot var-slot -- diff ok? var ) actual declared [ slot call length ] bi@ declared var-slot call [ vars (check-variable) ] keep ; inline :: unify-variables ( in-diff in-ok? in-var out-diff out-ok? out-var vars -- ? ) - { [ in-ok? ] [ out-ok? ] [ in-diff out-diff = ] } 0&& - dup [ + { [ in-ok? ] [ out-ok? ] [ in-diff out-diff = ] } 0&& dup [ in-var [ in-diff swap vars adjust-variable ] when* out-var [ out-diff swap vars adjust-variable ] when* ] when ; +: (check-variables) ( vars declared actual -- ? ) + [ [ in>> ] [ in-var>> ] check-variable ] + [ [ out>> ] [ out-var>> ] check-variable ] + [ 2drop ] 3tri unify-variables ; + : check-variables ( vars declared actual -- ? ) - dup terminated?>> [ 3drop t ] [ - [ [ in>> ] [ in-var>> ] check-variable ] - [ [ out>> ] [ out-var>> ] check-variable ] - [ 2drop ] 3tri unify-variables - ] if ; + dup terminated?>> [ 3drop t ] [ (check-variables) ] if ; + +: combinator-branches-effects ( branches -- quots declareds actuals ) + [ [ known>callable ] { } map-as ] + [ [ effect>> ] { } map-as ] + [ [ actual>> ] { } map-as ] tri ; : combinator-unbalanced-branches-error ( known -- * ) - [ word>> ] [ - branches>> - [ [ known>callable ] { } map-as ] - [ [ effect>> ] { } map-as ] - [ [ actual>> ] { } map-as ] tri - ] bi unbalanced-branches-error ; + [ word>> ] [ branches>> combinator-branches-effects ] bi + unbalanced-branches-error ; : check-declared-effect ( known effect -- ) [ >>actual ] keep From e8f857f3f6b7fd54c9abddcf1acc7a0ad00f6d1d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 12 Mar 2010 16:45:09 +1300 Subject: [PATCH 390/713] sequences.cords: remove blank lines --- basis/sequences/cords/cords.factor | 2 -- 1 file changed, 2 deletions(-) diff --git a/basis/sequences/cords/cords.factor b/basis/sequences/cords/cords.factor index 4a2d267a12..36f8db4ba8 100644 --- a/basis/sequences/cords/cords.factor +++ b/basis/sequences/cords/cords.factor @@ -108,5 +108,3 @@ M: cord v/n '[ _ v/n ] cord-map ; inline M: cord norm-sq [ norm-sq ] cord-both + ; inline M: cord distance v- norm ; inline - - From 9c3b94519d78838a7938095a6c31c8ef9b0406a7 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 12 Mar 2010 16:45:31 +1300 Subject: [PATCH 391/713] project-euler.206: reduce memory usage --- extra/project-euler/206/206.factor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extra/project-euler/206/206.factor b/extra/project-euler/206/206.factor index 06946d4db7..0563762370 100644 --- a/extra/project-euler/206/206.factor +++ b/extra/project-euler/206/206.factor @@ -1,7 +1,8 @@ ! Copyright (c) 2010 Aaron Schaefer. All rights reserved. ! The contents of this file are licensed under the Simplified BSD License ! A copy of the license is available at http://factorcode.org/license.txt -USING: grouping kernel math math.ranges project-euler.common sequences ; +USING: grouping kernel math math.ranges project-euler.common +sequences sequences.cords ; IN: project-euler.206 ! http://projecteuler.net/index.php?section=problems&id=206 @@ -33,7 +34,7 @@ CONSTANT: hi 1389026570 { 1 2 3 4 5 6 7 8 9 0 } = ; : candidates ( -- seq ) - lo lo 40 + [ hi 100 ] bi@ append ; + lo lo 40 + [ hi 100 ] bi@ cord-append ; PRIVATE> From 2785399c7bf6d8af8ee826137cc64e1203aa82bf Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 12 Mar 2010 04:36:43 -0600 Subject: [PATCH 392/713] Add ARTICLE: and ABOUT: sections to astar docs --- extra/astar/astar-docs.factor | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/extra/astar/astar-docs.factor b/extra/astar/astar-docs.factor index b43f2aba1c..d19166c1bf 100644 --- a/extra/astar/astar-docs.factor +++ b/extra/astar/astar-docs.factor @@ -74,3 +74,12 @@ HELP: considered { $description "When called after a call to " { $link find-path } ", return a list of nodes " "which have been examined during the A* exploration." } ; + +ARTICLE: "astar" "A* algorithm" +"The " { $vocab-link "astar" } " vocabulary implements a graph search algorithm for finding the least-cost path from one node to another." $nl +"Make an A* object:" +{ $subsections } +"Find a path between nodes:" +{ $subsections find-path } ; + +ABOUT: "astar" From f13a031f8facf5765decb7965b49645e5b287bf0 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 12 Mar 2010 19:59:21 -0800 Subject: [PATCH 393/713] windows.offscreen: generalize the declared effect of with-memory-dc --- basis/windows/offscreen/offscreen.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/windows/offscreen/offscreen.factor b/basis/windows/offscreen/offscreen.factor index e38477c98c..4b4847f964 100644 --- a/basis/windows/offscreen/offscreen.factor +++ b/basis/windows/offscreen/offscreen.factor @@ -46,7 +46,7 @@ IN: windows.offscreen ubyte-components >>component-type t >>upside-down? ; -: with-memory-dc ( quot: ( hDC -- ) -- ) +: with-memory-dc ( ..a quot: ( ..a hDC -- ..b ) -- ..b ) [ [ f CreateCompatibleDC &DeleteDC ] dip call ] with-destructors ; inline :: make-bitmap-image ( dim dc quot -- image ) From f8e2ddd53f162c76a21379c5307de278dc71b04c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 13 Mar 2010 11:32:34 +1300 Subject: [PATCH 394/713] prettyprint.config: short. should not print structs as pointers --- basis/prettyprint/config/config.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/prettyprint/config/config.factor b/basis/prettyprint/config/config.factor index a8848f9061..0b2c4b888b 100644 --- a/basis/prettyprint/config/config.factor +++ b/basis/prettyprint/config/config.factor @@ -28,7 +28,7 @@ string-limit? on 2 nesting-limit set string-limit? on boa-tuples? on - c-object-pointers? on + c-object-pointers? off call ] with-scope ; inline From 02a4082e1feb23879ce821d5774acd2c757182a7 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 13 Mar 2010 19:06:41 +1300 Subject: [PATCH 395/713] http.server: decouple charset header from encoding used to send the data, and serve text files as UTF-8 by default --- basis/furnace/syndication/syndication.factor | 4 +++- basis/http/client/client.factor | 10 +++++----- basis/http/http-tests.factor | 11 ++++++----- basis/http/http.factor | 15 ++++++++------- basis/http/server/responses/responses.factor | 4 ++-- basis/http/server/server-tests.factor | 18 ++++++++++++++---- basis/http/server/server.factor | 10 ++++++---- basis/http/server/static/static.factor | 13 +++++-------- 8 files changed, 49 insertions(+), 36 deletions(-) diff --git a/basis/furnace/syndication/syndication.factor b/basis/furnace/syndication/syndication.factor index 876aaf8c98..d5d6c1cec8 100644 --- a/basis/furnace/syndication/syndication.factor +++ b/basis/furnace/syndication/syndication.factor @@ -35,7 +35,9 @@ M: object >entry ] map ; : ( body -- response ) - feed>xml "application/atom+xml" ; + feed>xml "application/atom+xml" + "UTF-8" >>content-charset + utf8 >>content-encoding ; TUPLE: feed-action < action title url entries ; diff --git a/basis/http/client/client.factor b/basis/http/client/client.factor index 482a23aeaa..d69b1ed1f3 100644 --- a/basis/http/client/client.factor +++ b/basis/http/client/client.factor @@ -1,11 +1,11 @@ -! Copyright (C) 2005, 2009 Slava Pestov. +! Copyright (C) 2005, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: assocs kernel math math.parser namespaces make sequences strings splitting calendar continuations accessors vectors math.order hashtables byte-arrays destructors io io.sockets io.streams.string io.files io.timeouts io.pathnames io.encodings io.encodings.string io.encodings.ascii -io.encodings.utf8 io.encodings.binary io.crlf +io.encodings.utf8 io.encodings.binary io.encodings.iana io.crlf io.streams.duplex fry ascii urls urls.encoding present locals http http.parsers http.client.post-data ; IN: http.client @@ -56,8 +56,8 @@ ERROR: too-many-redirects ; dup "set-cookie" header parse-set-cookie >>cookies dup "content-type" header [ parse-content-type - [ >>content-type ] - [ >>content-charset ] bi* + [ >>content-type ] [ >>content-charset ] bi* + dup content-charset>> name>encoding >>content-encoding ] when* ; : read-response ( -- response ) @@ -149,7 +149,7 @@ ERROR: download-failed response ; : http-request ( request -- response data ) [ [ % ] with-http-request ] B{ } make - over content-charset>> decode check-response-with-body ; + over content-encoding>> decode check-response-with-body ; : ( url -- request ) "GET" ; diff --git a/basis/http/http-tests.factor b/basis/http/http-tests.factor index 35d01c1014..0c396ff4e9 100644 --- a/basis/http/http-tests.factor +++ b/basis/http/http-tests.factor @@ -6,13 +6,13 @@ continuations urls hashtables accessors namespaces xml.data io.encodings.8-bit.latin1 ; IN: http.tests -[ "text/plain" latin1 ] [ "text/plain" parse-content-type ] unit-test +[ "text/plain" "UTF-8" ] [ "text/plain" parse-content-type ] unit-test -[ "text/html" utf8 ] [ "text/html; charset=UTF-8" parse-content-type ] unit-test +[ "text/html" "ASCII" ] [ "text/html; charset=ASCII" parse-content-type ] unit-test -[ "text/html" utf8 ] [ "text/html; charset=\"utf-8\"" parse-content-type ] unit-test +[ "text/html" "utf-8" ] [ "text/html; charset=\"utf-8\"" parse-content-type ] unit-test -[ "application/octet-stream" binary ] [ "application/octet-stream" parse-content-type ] unit-test +[ "application/octet-stream" f ] [ "application/octet-stream" parse-content-type ] unit-test : lf>crlf ( string -- string' ) "\n" split "\r\n" join ; @@ -115,7 +115,8 @@ blah { header H{ { "content-type" "text/html; charset=UTF-8" } } } { cookies { } } { content-type "text/html" } - { content-charset utf8 } + { content-charset "UTF-8" } + { content-encoding utf8 } } ] [ read-response-test-1 lf>crlf diff --git a/basis/http/http.factor b/basis/http/http.factor index 6f898e949c..54866c745b 100644 --- a/basis/http/http.factor +++ b/basis/http/http.factor @@ -1,11 +1,11 @@ -! Copyright (C) 2003, 2008 Slava Pestov. +! Copyright (C) 2003, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel combinators math namespaces make assocs sequences splitting sorting sets strings vectors hashtables quotations arrays byte-arrays math.parser calendar -calendar.format present urls fry -io io.encodings io.encodings.iana io.encodings.binary -io.crlf ascii io.encodings.8-bit.latin1 http.parsers base64 ; +calendar.format present urls fry io io.encodings +io.encodings.iana io.encodings.binary io.encodings.utf8 io.crlf +ascii io.encodings.8-bit.latin1 http.parsers base64 ; IN: http CONSTANT: max-redirects 10 @@ -170,6 +170,7 @@ header cookies content-type content-charset +content-encoding body ; : ( -- response ) @@ -179,7 +180,7 @@ body ; "close" "connection" set-header now timestamp>http-string "date" set-header "Factor http.server" "server" set-header - latin1 >>content-charset + utf8 >>content-encoding V{ } clone >>cookies ; M: response clone @@ -221,5 +222,5 @@ TUPLE: post-data data params content-type content-encoding ; : parse-content-type ( content-type -- type encoding ) ";" split1 - parse-content-type-attributes "charset" swap at name>encoding - [ dup "text/" head? latin1 binary ? ] unless* ; + parse-content-type-attributes "charset" swap at + [ dup "text/" head? "UTF-8" and ] unless* ; diff --git a/basis/http/server/responses/responses.factor b/basis/http/server/responses/responses.factor index 3902b7f5e2..14527f5d68 100644 --- a/basis/http/server/responses/responses.factor +++ b/basis/http/server/responses/responses.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: math.parser http accessors kernel xml.syntax xml.writer io io.streams.string io.encodings.utf8 ; @@ -8,7 +8,7 @@ IN: http.server.responses 200 >>code "Document follows" >>message - utf8 >>content-charset + utf8 >>content-encoding swap >>content-type swap >>body ; diff --git a/basis/http/server/server-tests.factor b/basis/http/server/server-tests.factor index 3dc97098a4..00e8710c70 100644 --- a/basis/http/server/server-tests.factor +++ b/basis/http/server/server-tests.factor @@ -4,16 +4,26 @@ IN: http.server.tests [ t ] [ [ \ + first ] [ <500> ] recover response? ] unit-test -[ "text/plain; charset=UTF-8" ] [ +[ "text/plain; charset=ASCII" ] [ "text/plain" >>content-type - utf8 >>content-charset + "ASCII" >>content-charset unparse-content-type ] unit-test -[ "text/xml" ] [ +[ "text/xml; charset=UTF-8" ] [ "text/xml" >>content-type - binary >>content-charset + unparse-content-type +] unit-test + +[ "image/jpeg" ] [ + + "image/jpeg" >>content-type + unparse-content-type +] unit-test + +[ "application/octet-stream" ] [ + unparse-content-type ] unit-test \ No newline at end of file diff --git a/basis/http/server/server.factor b/basis/http/server/server.factor index 131fe3fe18..bfb724ca9a 100644 --- a/basis/http/server/server.factor +++ b/basis/http/server/server.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2003, 2009 Slava Pestov. +! Copyright (C) 2003, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel accessors sequences arrays namespaces splitting vocabs.loader destructors assocs debugger continuations @@ -101,8 +101,10 @@ GENERIC: write-full-response ( request response -- ) tri ; : unparse-content-type ( request -- content-type ) - [ content-type>> "application/octet-stream" or ] [ content-charset>> ] bi - dup binary eq? [ drop ] [ encoding>name "; charset=" glue ] if ; + [ content-type>> ] [ content-charset>> ] bi + over "text/" head? [ "UTF-8" or ] when + [ "application/octet-stream" or ] dip + [ "; charset=" glue ] when* ; : ensure-domain ( cookie -- cookie ) [ @@ -133,7 +135,7 @@ M: response write-response ( respose -- ) M: response write-full-response ( request response -- ) dup write-response swap method>> "HEAD" = [ - [ content-charset>> encode-output ] + [ content-encoding>> encode-output ] [ write-response-body ] bi ] unless drop ; diff --git a/basis/http/server/static/static.factor b/basis/http/server/static/static.factor index f80a3cc7cd..6b65cd5fe4 100644 --- a/basis/http/server/static/static.factor +++ b/basis/http/server/static/static.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2004, 2009 Slava Pestov. +! Copyright (C) 2004, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: calendar kernel math math.order math.parser namespaces parser sequences strings assocs hashtables debugger mime.types @@ -16,11 +16,8 @@ TUPLE: file-responder root hook special allow-listings ; dup [ rfc822>timestamp ] when ; : modified-since? ( filename -- ? ) - request get modified-since dup [ - [ file-info modified>> ] dip after? - ] [ - 2drop t - ] if ; + request get modified-since dup + [ [ file-info modified>> ] dip after? ] [ 2drop t ] if ; : ( root hook -- responder ) file-responder new @@ -30,8 +27,8 @@ TUPLE: file-responder root hook special allow-listings ; : (serve-static) ( path mime-type -- response ) [ - [ binary &dispose ] dip - binary >>content-charset + [ binary &dispose ] dip + binary >>content-encoding ] [ drop file-info [ size>> ] [ modified>> ] bi ] 2bi [ "content-length" set-header ] From b28f7c97f41fc370135961ec15ab2e4fa55db374 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 12 Mar 2010 23:07:36 -0800 Subject: [PATCH 396/713] add descriptive summary for no-c-type error --- basis/debugger/debugger.factor | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index a48cc89225..3b75c1e7a0 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -1,12 +1,12 @@ ! Copyright (C) 2004, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: slots arrays definitions generic hashtables summary io kernel -math namespaces make prettyprint prettyprint.config sequences assocs -sequences.private strings io.styles io.pathnames vectors words system -splitting math.parser classes.mixin classes.tuple continuations -continuations.private combinators generic.math classes.builtin classes -compiler.units generic.standard generic.single vocabs init -kernel.private io.encodings accessors math.order destructors +USING: slots alien.c-types arrays definitions generic hashtables +summary io kernel math namespaces make prettyprint prettyprint.config +sequences assocs sequences.private strings io.styles io.pathnames +vectors words system splitting math.parser classes.mixin classes.tuple +continuations continuations.private combinators generic.math +classes.builtin classes compiler.units generic.standard generic.single +vocabs init kernel.private io.encodings accessors math.order destructors source-files parser classes.tuple.parser effects.parser lexer generic.parser strings.parser vocabs.loader vocabs.parser source-files.errors ; @@ -347,6 +347,8 @@ M: wrong-values summary drop "Quotation's stack effect does not match call site" M: stack-effect-omits-dashes summary drop "Stack effect must contain “--”" ; +M: no-c-type summary name>> unparse "“" "” is not a C type" surround ; + { { [ os windows? ] [ "debugger.windows" require ] } { [ os unix? ] [ "debugger.unix" require ] } From efe5e224830aeaf1dbfde78f4d30892d3a3fb996 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 13 Mar 2010 21:13:34 +1300 Subject: [PATCH 397/713] furnace.syndication: fix load error --- basis/furnace/syndication/syndication.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/furnace/syndication/syndication.factor b/basis/furnace/syndication/syndication.factor index d5d6c1cec8..b71abf6d86 100644 --- a/basis/furnace/syndication/syndication.factor +++ b/basis/furnace/syndication/syndication.factor @@ -1,8 +1,8 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel sequences fry combinators syndication http.server.responses http.server.redirection furnace.actions -furnace.utilities ; +furnace.utilities io.encodings.utf8 ; IN: furnace.syndication GENERIC: feed-entry-title ( object -- string ) From 937b05f1debcfb47947131eb02f068ae7b092c39 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 13 Mar 2010 22:09:56 +1300 Subject: [PATCH 398/713] http: clean up and fix some content encoding logic --- basis/http/client/client.factor | 9 +++++++-- basis/http/http.factor | 4 ++-- basis/http/server/server.factor | 3 ++- basis/mime/types/types.factor | 9 +++++++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/basis/http/client/client.factor b/basis/http/client/client.factor index d69b1ed1f3..2ce0ec9dfc 100644 --- a/basis/http/client/client.factor +++ b/basis/http/client/client.factor @@ -7,7 +7,7 @@ io io.sockets io.streams.string io.files io.timeouts io.pathnames io.encodings io.encodings.string io.encodings.ascii io.encodings.utf8 io.encodings.binary io.encodings.iana io.crlf io.streams.duplex fry ascii urls urls.encoding present locals -http http.parsers http.client.post-data ; +http http.parsers http.client.post-data mime.types ; IN: http.client ERROR: too-many-redirects ; @@ -51,13 +51,18 @@ ERROR: too-many-redirects ; read-crlf parse-response-line first3 [ >>version ] [ >>code ] [ >>message ] tri* ; +: detect-encoding ( response -- encoding ) + [ content-charset>> name>encoding ] + [ content-type>> mime-type-encoding ] bi + or ; + : read-response-header ( response -- response ) read-header >>header dup "set-cookie" header parse-set-cookie >>cookies dup "content-type" header [ parse-content-type [ >>content-type ] [ >>content-charset ] bi* - dup content-charset>> name>encoding >>content-encoding + dup detect-encoding >>content-encoding ] when* ; : read-response ( -- response ) diff --git a/basis/http/http.factor b/basis/http/http.factor index 54866c745b..46b67b5321 100644 --- a/basis/http/http.factor +++ b/basis/http/http.factor @@ -5,7 +5,7 @@ sequences splitting sorting sets strings vectors hashtables quotations arrays byte-arrays math.parser calendar calendar.format present urls fry io io.encodings io.encodings.iana io.encodings.binary io.encodings.utf8 io.crlf -ascii io.encodings.8-bit.latin1 http.parsers base64 ; +ascii io.encodings.8-bit.latin1 http.parsers base64 mime.types ; IN: http CONSTANT: max-redirects 10 @@ -223,4 +223,4 @@ TUPLE: post-data data params content-type content-encoding ; : parse-content-type ( content-type -- type encoding ) ";" split1 parse-content-type-attributes "charset" swap at - [ dup "text/" head? "UTF-8" and ] unless* ; + [ dup mime-type-encoding encoding>name ] unless* ; diff --git a/basis/http/server/server.factor b/basis/http/server/server.factor index bfb724ca9a..acdd71d10d 100644 --- a/basis/http/server/server.factor +++ b/basis/http/server/server.factor @@ -26,6 +26,7 @@ http.server.remapping html.templates html.streams html +mime.types xml.writer ; FROM: mime.multipart => parse-multipart ; IN: http.server @@ -102,7 +103,7 @@ GENERIC: write-full-response ( request response -- ) : unparse-content-type ( request -- content-type ) [ content-type>> ] [ content-charset>> ] bi - over "text/" head? [ "UTF-8" or ] when + over mime-type-encoding encoding>name or [ "application/octet-stream" or ] dip [ "; charset=" glue ] when* ; diff --git a/basis/mime/types/types.factor b/basis/mime/types/types.factor index 5693aa9162..90b856ef23 100644 --- a/basis/mime/types/types.factor +++ b/basis/mime/types/types.factor @@ -1,6 +1,7 @@ -! Copyright (C) 2004, 2008 Slava Pestov. +! Copyright (C) 2004, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io.pathnames io.files io.encodings.ascii assocs sequences +USING: io.pathnames io.files io.encodings.ascii +io.encodings.binary io.encodings.utf8 assocs sequences splitting kernel namespaces fry memoize ; IN: mime.types @@ -23,3 +24,7 @@ MEMO: mime-types ( -- assoc ) : mime-type ( filename -- mime-type ) file-extension mime-types at "application/octet-stream" or ; + +: mime-type-encoding ( mime-type -- encoding ) + "text/" head? utf8 binary ? ; + From 4c9ae8398c7f130f3cb7d692fdaa3d4fe232ff64 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 14 Mar 2010 17:04:36 +1300 Subject: [PATCH 399/713] io.servers.connection: fix bogus logging --- basis/io/servers/connection/connection.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/io/servers/connection/connection.factor b/basis/io/servers/connection/connection.factor index fdd42352da..4dfdc13bc9 100644 --- a/basis/io/servers/connection/connection.factor +++ b/basis/io/servers/connection/connection.factor @@ -79,7 +79,7 @@ M: threaded-server handle-client* handler>> call( -- ) ; [ timeout>> timeouts ] [ handle-client* ] bi ] with-stream ; -\ handle-client ERROR add-error-logging +\ handle-client NOTICE add-error-logging : thread-name ( server-name addrspec -- string ) unparse-short " connection from " glue ; From e30d18aefc85b1ab3f16a7203682c2b0e5d18870 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 15 Mar 2010 19:25:20 +1300 Subject: [PATCH 400/713] http: update docs --- basis/http/http-docs.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basis/http/http-docs.factor b/basis/http/http-docs.factor index 2de2323394..a9695c667a 100644 --- a/basis/http/http-docs.factor +++ b/basis/http/http-docs.factor @@ -35,7 +35,8 @@ $nl { { $slot "header" } { "An assoc of HTTP header values. See " { $link "http.headers" } } } { { $slot "cookies" } { "A sequence of HTTP cookies. See " { $link "http.cookies" } } } { { $slot "content-type" } { "an HTTP content type" } } - { { $slot "content-charset" } { "an encoding descriptor. See " { $link "io.encodings" } } } + { { $slot "content-charset" } { "an encoding name" } } + { { $slot "content-encoding" } { "an encoding descriptor. See " { $link "io.encodings" } } } { { $slot "body" } { "an HTTP response body" } } } } ; From f0a9912ae9b4b905071a053a20d05f29f3f53308 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 15 Mar 2010 19:25:57 +1300 Subject: [PATCH 401/713] core-foundation.run-loop: remove unnecessary yields. This fixes a thread starvation issue with game.input --- basis/core-foundation/run-loop/run-loop.factor | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/basis/core-foundation/run-loop/run-loop.factor b/basis/core-foundation/run-loop/run-loop.factor index c1316eaa16..14d701ba17 100644 --- a/basis/core-foundation/run-loop/run-loop.factor +++ b/basis/core-foundation/run-loop/run-loop.factor @@ -106,11 +106,11 @@ TUPLE: run-loop fds sources timers ; nano-count - 1,000 /f system-micros + ; : reset-timer ( timer -- ) - yield { - { [ run-queue deque-empty? not ] [ yield system-micros (reset-timer) ] } - { [ sleep-queue heap-empty? ] [ system-micros 1,000,000 + (reset-timer) ] } - [ sleep-queue heap-peek nip nano-count>micros (reset-timer) ] - } cond ; + { + { [ run-queue deque-empty? not ] [ system-micros ] } + { [ sleep-queue heap-empty? not ] [ sleep-queue heap-peek nip nano-count>micros ] } + [ system-micros 1,000,000 + ] + } cond (reset-timer) ; PRIVATE> From 08f29d9fcd98a003d2d9fb6dca459e46dbcc1e3a Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 15 Mar 2010 12:57:09 -0700 Subject: [PATCH 402/713] ui.backend.cocoa.views: change drawRect: method so it does "draw-world" directly instead of relayout-1 yield --- basis/ui/backend/cocoa/views/views.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/ui/backend/cocoa/views/views.factor b/basis/ui/backend/cocoa/views/views.factor index 88e5f243ad..19c451d909 100644 --- a/basis/ui/backend/cocoa/views/views.factor +++ b/basis/ui/backend/cocoa/views/views.factor @@ -149,7 +149,7 @@ CLASS: { ! Rendering { "drawRect:" void { id SEL NSRect } - [ 2drop window relayout-1 yield ] + [ 2drop window draw-world ] } ! Events From acb04ad3ed898ad1f2b0edec340c6dcbee0e1525 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 15 Mar 2010 12:57:38 -0700 Subject: [PATCH 403/713] debugger: give a descriptive error for *-in-c-type-name --- basis/debugger/debugger.factor | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index 3b75c1e7a0..b7ecc5acec 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -1,15 +1,15 @@ ! Copyright (C) 2004, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: slots alien.c-types arrays definitions generic hashtables -summary io kernel math namespaces make prettyprint prettyprint.config -sequences assocs sequences.private strings io.styles io.pathnames -vectors words system splitting math.parser classes.mixin classes.tuple -continuations continuations.private combinators generic.math -classes.builtin classes compiler.units generic.standard generic.single -vocabs init kernel.private io.encodings accessors math.order destructors -source-files parser classes.tuple.parser effects.parser lexer -generic.parser strings.parser vocabs.loader vocabs.parser -source-files.errors ; +USING: slots alien.c-types alien.parser arrays definitions generic +hashtables summary io kernel math namespaces make prettyprint +prettyprint.config sequences assocs sequences.private strings +io.styles io.pathnames vectors words system splitting math.parser +classes.mixin classes.tuple continuations continuations.private +combinators generic.math classes.builtin classes compiler.units +generic.standard generic.single vocabs init kernel.private +io.encodings accessors math.order destructors source-files parser +classes.tuple.parser effects.parser lexer generic.parser strings.parser +vocabs.loader vocabs.parser source-files.errors ; IN: debugger GENERIC: error-help ( error -- topic ) @@ -349,6 +349,9 @@ M: stack-effect-omits-dashes summary drop "Stack effect must contain “--”" ; M: no-c-type summary name>> unparse "“" "” is not a C type" surround ; +M: *-in-c-type-name summary + name>> "Cannot define a C type “" "” that ends with an asterisk (*)" surround ; + { { [ os windows? ] [ "debugger.windows" require ] } { [ os unix? ] [ "debugger.unix" require ] } From 22e8d485a55ec70f44716b245d339ba29adf8ff9 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 15 Mar 2010 14:11:48 -0700 Subject: [PATCH 404/713] game.worlds: use draw-world in response to game-loop draw* events rather than relayout-1 yield --- extra/game/worlds/worlds.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/game/worlds/worlds.factor b/extra/game/worlds/worlds.factor index bf05eddc71..508a26da9b 100644 --- a/extra/game/worlds/worlds.factor +++ b/extra/game/worlds/worlds.factor @@ -28,7 +28,7 @@ M: game-world tick* [ audio-engine>> [ update-audio ] when* ] bi ; M: game-world draw* - swap >>tick-slice relayout-1 yield ; + swap >>tick-slice draw-world ; Date: Tue, 16 Mar 2010 14:00:15 +1300 Subject: [PATCH 405/713] tools.memory, tools.dispatch: change collect-gc-events and collect-dispatch-stats combinators to output values instead of setting variables --- basis/tools/dispatch/dispatch.factor | 7 +++---- basis/tools/memory/memory.factor | 8 ++++---- basis/tools/time/time-docs.factor | 8 ++++---- basis/tools/time/time.factor | 8 +++++--- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/basis/tools/dispatch/dispatch.factor b/basis/tools/dispatch/dispatch.factor index 7d30dac36b..7ee89a50fb 100644 --- a/basis/tools/dispatch/dispatch.factor +++ b/basis/tools/dispatch/dispatch.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2009 Slava Pestov. +! Copyright (C) 2009, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel namespaces prettyprint classes.struct vm tools.dispatch.private ; @@ -17,8 +17,7 @@ SYMBOL: last-dispatch-stats { "Tuple check count" [ pic-tuple-count>> ] } } object-table. ; -: collect-dispatch-stats ( quot -- ) +: collect-dispatch-stats ( quot -- dispatch-stats ) reset-dispatch-stats call - dispatch-stats dispatch-statistics memory>struct - last-dispatch-stats set ; inline + dispatch-stats dispatch-statistics memory>struct ; inline diff --git a/basis/tools/memory/memory.factor b/basis/tools/memory/memory.factor index 0c55612466..1c999d979a 100644 --- a/basis/tools/memory/memory.factor +++ b/basis/tools/memory/memory.factor @@ -90,12 +90,10 @@ PRIVATE> ] each 2drop ] tabular-output nl ; -SYMBOL: gc-events - -: collect-gc-events ( quot -- ) +: collect-gc-events ( quot -- gc-events ) enable-gc-events [ ] [ disable-gc-events drop ] cleanup - disable-gc-events [ gc-event memory>struct ] map gc-events set ; inline + disable-gc-events [ gc-event memory>struct ] map ; inline +SYMBOL: gc-events + : gc-event. ( event -- ) { { "Event type:" [ op>> gc-op-string ] } diff --git a/basis/tools/time/time-docs.factor b/basis/tools/time/time-docs.factor index d28202f844..ce9a621a2f 100644 --- a/basis/tools/time/time-docs.factor +++ b/basis/tools/time/time-docs.factor @@ -27,11 +27,11 @@ HELP: time { benchmark system-micros time } related-words HELP: collect-gc-events -{ $values { "quot" quotation } } -{ $description "Calls the quotation, storing an array of " { $link gc-event } " instances in the " { $link gc-events } " variable." } +{ $values { "quot" quotation } { "gc-events" "a sequence of " { $link gc-event } " instances" } } +{ $description "Calls the quotation and outputs a sequence of " { $link gc-event } " instances." } { $notes "The " { $link time } " combinator automatically calls this combinator." } ; HELP: collect-dispatch-stats -{ $values { "quot" quotation } } -{ $description "Calls the quotation, collecting method dispatch statistics and storing them in the " { $link last-dispatch-stats } " variable. " } +{ $values { "quot" quotation } { "dispatch-stats" dispatch-stats } } +{ $description "Calls the quotation and outputs a " { $link dispatch-stats } " instance." } { $notes "The " { $link time } " combinator automatically calls this combinator." } ; diff --git a/basis/tools/time/time.factor b/basis/tools/time/time.factor index 0bd97f563d..8355f1f20c 100644 --- a/basis/tools/time/time.factor +++ b/basis/tools/time/time.factor @@ -1,6 +1,6 @@ -! Copyright (C) 2003, 2009 Slava Pestov. +! Copyright (C) 2003, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: system kernel math io prettyprint tools.memory +USING: system kernel math namespaces io prettyprint tools.memory tools.dispatch ; IN: tools.time @@ -18,5 +18,7 @@ IN: tools.time "gc-summary. - Print aggregate garbage collection statistics" print ; : time ( quot -- ) - [ [ benchmark ] collect-dispatch-stats ] collect-gc-events + [ + [ benchmark ] collect-dispatch-stats last-dispatch-stats set + ] collect-gc-events gc-events set time. nl time-banner. ; inline From 9b6b58b240aa01ac5e73b0bd71695755f083e0fe Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 16 Mar 2010 16:44:36 +1300 Subject: [PATCH 406/713] tools.time: fix load error in docs --- basis/tools/dispatch/dispatch.factor | 2 +- basis/tools/time/time-docs.factor | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/basis/tools/dispatch/dispatch.factor b/basis/tools/dispatch/dispatch.factor index 7ee89a50fb..72830b29b4 100644 --- a/basis/tools/dispatch/dispatch.factor +++ b/basis/tools/dispatch/dispatch.factor @@ -17,7 +17,7 @@ SYMBOL: last-dispatch-stats { "Tuple check count" [ pic-tuple-count>> ] } } object-table. ; -: collect-dispatch-stats ( quot -- dispatch-stats ) +: collect-dispatch-stats ( quot -- dispatch-statistics ) reset-dispatch-stats call dispatch-stats dispatch-statistics memory>struct ; inline diff --git a/basis/tools/time/time-docs.factor b/basis/tools/time/time-docs.factor index ce9a621a2f..cbcd38c801 100644 --- a/basis/tools/time/time-docs.factor +++ b/basis/tools/time/time-docs.factor @@ -32,6 +32,6 @@ HELP: collect-gc-events { $notes "The " { $link time } " combinator automatically calls this combinator." } ; HELP: collect-dispatch-stats -{ $values { "quot" quotation } { "dispatch-stats" dispatch-stats } } -{ $description "Calls the quotation and outputs a " { $link dispatch-stats } " instance." } +{ $values { "quot" quotation } { "dispatch-statistics" dispatch-statistics } } +{ $description "Calls the quotation and outputs a " { $link dispatch-statistics } " instance." } { $notes "The " { $link time } " combinator automatically calls this combinator." } ; From 604ccb0a3ab397a81437ca7a3d9c0095a51eef4b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 16 Mar 2010 18:35:44 +1300 Subject: [PATCH 407/713] tools.memory: fix unit test --- basis/tools/memory/memory-tests.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/tools/memory/memory-tests.factor b/basis/tools/memory/memory-tests.factor index 4711f472a3..1ea5854939 100644 --- a/basis/tools/memory/memory-tests.factor +++ b/basis/tools/memory/memory-tests.factor @@ -1,9 +1,9 @@ -USING: tools.test tools.memory memory ; +USING: tools.test tools.memory memory arrays ; IN: tools.memory.tests [ ] [ room. ] unit-test [ ] [ heap-stats. ] unit-test -[ ] [ [ gc gc ] collect-gc-events ] unit-test +[ t ] [ [ gc gc ] collect-gc-events array? ] unit-test [ ] [ gc-events. ] unit-test [ ] [ gc-stats. ] unit-test [ ] [ gc-summary. ] unit-test From 9bfb2a33802fc6762f17808c4bbc9aeb34404015 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Mar 2010 00:05:42 -0700 Subject: [PATCH 408/713] revert game.worlds calling draw-world directly, was causing mouse starvation again --- extra/game/worlds/worlds.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/game/worlds/worlds.factor b/extra/game/worlds/worlds.factor index 508a26da9b..bf05eddc71 100644 --- a/extra/game/worlds/worlds.factor +++ b/extra/game/worlds/worlds.factor @@ -28,7 +28,7 @@ M: game-world tick* [ audio-engine>> [ update-audio ] when* ] bi ; M: game-world draw* - swap >>tick-slice draw-world ; + swap >>tick-slice relayout-1 yield ; Date: Tue, 16 Mar 2010 09:28:51 +0100 Subject: [PATCH 409/713] Also test the derivation variant of astar --- extra/astar/astar-tests.factor | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/extra/astar/astar-tests.factor b/extra/astar/astar-tests.factor index 11b2dfcaa2..6e2e2f4f1b 100644 --- a/extra/astar/astar-tests.factor +++ b/extra/astar/astar-tests.factor @@ -4,8 +4,6 @@ USING: arrays assocs astar combinators hashtables kernel literals math math.func math.vectors sequences sorting splitting strings tools.test ; IN: astar.tests -<< - ! Use a 10x9 maze (see below) to try to go from s to e, f or g. ! X means that a position is unreachable. ! The costs model is: @@ -13,6 +11,10 @@ IN: astar.tests ! - going down costs 1 point ! - going left or right costs 2 points +<< + +TUPLE: maze < astar ; + : reachable? ( pos -- ? ) first2 [ 2 * 5 + ] [ 2 + ] bi* $[ " 0 1 2 3 4 5 6 7 8 9 @@ -28,20 +30,21 @@ IN: astar.tests 8 X X X X X X X X X X" "\n" split ] nth nth CHAR: X = not ; -: neighbours ( pos -- neighbours ) - first2 - { [ 1 + 2array ] [ 1 - 2array ] [ [ 1 + ] dip 2array ] [ [ 1 - ] dip 2array ] } 2cleave - 4array - [ reachable? ] filter ; +M: maze neighbours + drop + first2 + { [ 1 + 2array ] [ 1 - 2array ] [ [ 1 + ] dip 2array ] [ [ 1 - ] dip 2array ] } 2cleave + 4array + [ reachable? ] filter ; -: heuristic ( from to -- cost ) - v- [ abs ] [ + ] map-reduce ; +M: maze heuristic + drop v- [ abs ] [ + ] map-reduce ; -: cost ( from to -- cost ) - 2dup [ first ] bi@ = [ [ second ] bi@ > 1 5 ? ] [ 2drop 2 ] if ; +M: maze cost + drop 2dup [ first ] bi@ = [ [ second ] bi@ > 1 5 ? ] [ 2drop 2 ] if ; : test1 ( to -- path considered ) - { 1 1 } swap [ neighbours ] [ cost ] [ heuristic ] [ find-path ] [ considered ] bi ; + { 1 1 } swap maze new [ find-path ] [ considered ] bi ; >> ! Existing path from s to f @@ -73,8 +76,6 @@ IN: astar.tests ! Non-existing path from s to g -- all positions must have been considered [ f 26 ] [ { 1 7 } test1 length ] unit-test -<< - ! Look for a path between A and C. The best path is A --> D --> C. C will be placed ! in the open set early because B will be examined first. This checks that the evaluation ! of C is correctly replaced in the open set. @@ -92,6 +93,10 @@ IN: astar.tests ! A ---> D ---------> E ---> F ! (2) (1) (1) +<< + +! In this version, we will use the quotations-aware version through . + : n ( pos -- neighbours ) $[ { "ABD" "BC" "C" "DCE" "ECF" } [ unclip swap 2array ] map >hashtable ] at ; From 1da6ea957aa00bfd11ff2343b287be72ba3cf50e Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Tue, 16 Mar 2010 20:17:26 -0400 Subject: [PATCH 410/713] Fixing bugs with sets, including adding new within and without words --- basis/validators/validators.factor | 2 +- core/hash-sets/hash-sets.factor | 2 +- core/sets/sets-docs.factor | 27 ++++++++++++++++++++------- core/sets/sets-tests.factor | 10 ++++++++++ core/sets/sets.factor | 13 +++++++++++-- extra/project-euler/035/035.factor | 4 ++-- 6 files changed, 45 insertions(+), 13 deletions(-) diff --git a/basis/validators/validators.factor b/basis/validators/validators.factor index f2c5691452..cf45e7b13f 100644 --- a/basis/validators/validators.factor +++ b/basis/validators/validators.factor @@ -97,7 +97,7 @@ IN: validators sum 10 mod 0 = ; : v-credit-card ( str -- n ) - "- " diff + "- " without dup CHAR: 0 CHAR: 9 [a,b] diff empty? [ 13 v-min-length 16 v-max-length diff --git a/core/hash-sets/hash-sets.factor b/core/hash-sets/hash-sets.factor index bdef9a6ff9..248b4af4c6 100644 --- a/core/hash-sets/hash-sets.factor +++ b/core/hash-sets/hash-sets.factor @@ -25,4 +25,4 @@ M: sequence fast-set ; M: f fast-set drop H{ } clone hash-set boa ; M: sequence duplicates - HS{ } clone [ [ in? ] [ adjoin ] 2bi ] curry filter ; + f fast-set [ [ in? ] [ adjoin ] 2bi ] curry filter ; diff --git a/core/sets/sets-docs.factor b/core/sets/sets-docs.factor index ac296f949c..5cb0096d0b 100644 --- a/core/sets/sets-docs.factor +++ b/core/sets/sets-docs.factor @@ -3,7 +3,7 @@ quotations sequences vectors ; IN: sets ARTICLE: "sets" "Sets" -"A set is an unordered list of elements. Words for working with sets are in the " { $vocab-link "sets" } " vocabulary." +"A set is an unordered list of elements. Words for working with sets are in the " { $vocab-link "sets" } " vocabulary." $nl "All sets are instances of a mixin class:" { $subsections set @@ -43,6 +43,11 @@ ARTICLE: "set-operations" "Operations on sets" { $subsections all-unique? duplicates +} +"Utilities for sets and sequences:" +{ $subsections + within + without } ; ARTICLE: "set-implementations" "Set implementations" @@ -68,11 +73,11 @@ HELP: adjoin { $description "Destructively adds " { $snippet "elt" } " to " { $snippet "set" } ". For sequences, this guarantees that this element is not duplicated, and that it is at the end of the sequence." $nl "Each mutable set type is expected to implement a method on this generic word." } { $examples { $example - "USING: namespaces prettyprint sets ;" - "V{ \"beans\" \"salsa\" \"cheese\" } \"v\" set" - "\"nachos\" \"v\" get adjoin" - "\"salsa\" \"v\" get adjoin" - "\"v\" get ." + "USING: prettyprint sets kernel ;" + "V{ \"beans\" \"salsa\" \"cheese\" } clone" + "\"nachos\" over adjoin" + "\"salsa\" over adjoin" + "." "V{ \"beans\" \"cheese\" \"nachos\" \"salsa\" }" } } @@ -100,7 +105,7 @@ HELP: duplicates { $values { "set" set } { "seq" sequence } } { $description "Outputs a sequence consisting of elements which occur more than once in " { $snippet "set" } "." } { $examples - { $example "USING: sets prettyprint ;" "{ 1 2 3 1 2 1 } duplicates ." "{ 2 1 2 1 }" } + { $example "USING: sets prettyprint ;" "{ 1 2 3 1 2 1 } duplicates ." "{ 1 2 1 }" } } ; HELP: all-unique? @@ -165,3 +170,11 @@ HELP: set-like { $examples { $example "USING: sets prettyprint ;" "{ 1 2 3 } HS{ } set-like ." "HS{ 1 2 3 }" } } ; + +HELP: within +{ $values { "seq" sequence } { "set" set } { "subseq" sequence } } +{ $description "Returns the subsequence of the given sequence consisting of members of the set. This may contain duplicates, if the sequence has duplicates." } ; + +HELP: without +{ $values { "seq" sequence } { "set" set } { "subseq" sequence } } +{ $description "Returns the subsequence of the given sequence consisting of things that are not members of the set. This may contain duplicates, if the sequence has duplicates." } ; diff --git a/core/sets/sets-tests.factor b/core/sets/sets-tests.factor index aa76a4f02e..e4bc762512 100644 --- a/core/sets/sets-tests.factor +++ b/core/sets/sets-tests.factor @@ -5,9 +5,19 @@ IN: sets.tests [ { } ] [ { } { } intersect ] unit-test [ { 2 3 } ] [ { 1 2 3 } { 2 3 4 } intersect ] unit-test +[ { 2 3 } ] [ { 1 2 2 3 } { 2 3 3 4 } intersect ] unit-test [ { } ] [ { } { } diff ] unit-test [ { 1 } ] [ { 1 2 3 } { 2 3 4 } diff ] unit-test +[ { 1 } ] [ { 1 1 2 3 } { 2 3 4 4 } diff ] unit-test + +[ { } ] [ { } { } within ] unit-test +[ { 2 3 } ] [ { 1 2 3 } { 2 3 4 } within ] unit-test +[ { 2 2 3 } ] [ { 1 2 2 3 } { 2 3 3 4 } within ] unit-test + +[ { } ] [ { } { } without ] unit-test +[ { 1 } ] [ { 1 2 3 } { 2 3 4 } without ] unit-test +[ { 1 1 } ] [ { 1 1 2 3 3 } { 2 3 4 4 } without ] unit-test [ { } ] [ { } { } union ] unit-test [ { 1 2 3 4 } ] [ { 1 2 3 } { 2 3 4 } union ] unit-test diff --git a/core/sets/sets.factor b/core/sets/sets.factor index 5274c07d37..3f441f9239 100644 --- a/core/sets/sets.factor +++ b/core/sets/sets.factor @@ -2,6 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs hashtables kernel vectors math sequences ; +FROM: assocs => change-at ; IN: sets ! Set protocol @@ -11,7 +12,7 @@ GENERIC: in? ( elt set -- ? ) GENERIC: delete ( elt set -- ) GENERIC: set-like ( set exemplar -- set' ) GENERIC: fast-set ( set -- set' ) -GENERIC: members ( set -- sequence ) +GENERIC: members ( set -- seq ) GENERIC: union ( set1 set2 -- set ) GENERIC: intersect ( set1 set2 -- set ) GENERIC: intersects? ( set1 set2 -- ? ) @@ -95,7 +96,9 @@ M: sequence all-unique? dup pruned sequence= ; : combine ( sets -- set ) - f [ union ] reduce ; + [ f ] + [ [ [ members ] map concat ] [ first ] bi set-like ] + if-empty ; : gather ( seq quot -- newseq ) map concat members ; inline @@ -103,6 +106,12 @@ M: sequence all-unique? : adjoin-at ( value key assoc -- ) [ [ f fast-set ] unless* [ adjoin ] keep ] change-at ; +: within ( seq set -- subseq ) + fast-set [ in? ] curry filter ; + +: without ( seq set -- subseq ) + fast-set [ in? not ] curry filter ; + ! Temporarily for compatibility : unique ( seq -- assoc ) diff --git a/extra/project-euler/035/035.factor b/extra/project-euler/035/035.factor index 7d98de62b1..ee4af81720 100644 --- a/extra/project-euler/035/035.factor +++ b/extra/project-euler/035/035.factor @@ -1,7 +1,7 @@ ! Copyright (c) 2008 Aaron Schaefer. ! See http://factorcode.org/license.txt for BSD license. USING: kernel math math.combinatorics math.parser math.primes - project-euler.common sequences sets ; + project-euler.common sequences ; IN: project-euler.035 ! http://projecteuler.net/index.php?section=problems&id=35 @@ -28,7 +28,7 @@ IN: project-euler.035 : possible? ( seq -- ? ) dup length 1 > [ - dup { 0 2 4 5 6 8 } diff = + [ even? ] any? not ] [ drop t ] if ; From fce55c7bb3dfc9c23c2743fdb85e8525ed69dea2 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Mar 2010 17:23:39 -0700 Subject: [PATCH 411/713] opengl 3.2; EXT_geometry_shader4 => ARB_geometry_shader4 --- basis/opengl/gl/gl.factor | 122 +++++++++++++++++++++++++++++------- basis/opengl/gl3/gl3.factor | 81 ++++++++++++++++++++++++ 2 files changed, 181 insertions(+), 22 deletions(-) diff --git a/basis/opengl/gl/gl.factor b/basis/opengl/gl/gl.factor index 58039558d7..599721fb5e 100644 --- a/basis/opengl/gl/gl.factor +++ b/basis/opengl/gl/gl.factor @@ -22,6 +22,9 @@ TYPEDEF: float GLfloat TYPEDEF: float GLclampf TYPEDEF: double GLdouble TYPEDEF: double GLclampd +TYPEDEF: longlong GLint64 +TYPEDEF: ulonglong GLuint64 +TYPEDEF: void* GLsync C-TYPE: GLvoid TYPEDEF: c-string[ascii] GLstring @@ -2167,31 +2170,106 @@ GL-FUNCTION: void glUniformBlockBinding { } ( GLuint buffer, GLuint uniformBlock GL-FUNCTION: void glCopyBufferSubData { glCopyBufferSubDataEXT } ( GLenum readtarget, GLenum writetarget, GLintptr readoffset, GLintptr writeoffset, GLsizeiptr size ) ; -! GL_EXT_geometry_shader4 +! OpenGL 3.2 + +CONSTANT: GL_CONTEXT_CORE_PROFILE_BIT HEX: 00000001 +CONSTANT: GL_CONTEXT_COMPATIBILITY_PROFILE_BIT HEX: 00000002 +CONSTANT: GL_LINES_ADJACENCY HEX: 000A +CONSTANT: GL_LINE_STRIP_ADJACENCY HEX: 000B +CONSTANT: GL_TRIANGLES_ADJACENCY HEX: 000C +CONSTANT: GL_TRIANGLE_STRIP_ADJACENCY HEX: 000D +CONSTANT: GL_PROGRAM_POINT_SIZE HEX: 8642 +CONSTANT: GL_GEOMETRY_VERTICES_OUT HEX: 8916 +CONSTANT: GL_GEOMETRY_INPUT_TYPE HEX: 8917 +CONSTANT: GL_GEOMETRY_OUTPUT_TYPE HEX: 8918 +CONSTANT: GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS HEX: 8C29 +CONSTANT: GL_FRAMEBUFFER_ATTACHMENT_LAYERED HEX: 8DA7 +CONSTANT: GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS HEX: 8DA8 +CONSTANT: GL_GEOMETRY_SHADER HEX: 8DD9 +CONSTANT: GL_MAX_GEOMETRY_UNIFORM_COMPONENTS HEX: 8DDF +CONSTANT: GL_MAX_GEOMETRY_OUTPUT_VERTICES HEX: 8DE0 +CONSTANT: GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS HEX: 8DE1 +CONSTANT: GL_MAX_VERTEX_OUTPUT_COMPONENTS HEX: 9122 +CONSTANT: GL_MAX_GEOMETRY_INPUT_COMPONENTS HEX: 9123 +CONSTANT: GL_MAX_GEOMETRY_OUTPUT_COMPONENTS HEX: 9124 +CONSTANT: GL_MAX_FRAGMENT_INPUT_COMPONENTS HEX: 9125 +CONSTANT: GL_CONTEXT_PROFILE_MASK HEX: 9126 +CONSTANT: GL_MAX_SERVER_WAIT_TIMEOUT HEX: 9111 +CONSTANT: GL_OBJECT_TYPE HEX: 9112 +CONSTANT: GL_SYNC_CONDITION HEX: 9113 +CONSTANT: GL_SYNC_STATUS HEX: 9114 +CONSTANT: GL_SYNC_FLAGS HEX: 9115 +CONSTANT: GL_SYNC_FENCE HEX: 9116 +CONSTANT: GL_SYNC_GPU_COMMANDS_COMPLETE HEX: 9117 +CONSTANT: GL_UNSIGNALED HEX: 9118 +CONSTANT: GL_SIGNALED HEX: 9119 +CONSTANT: GL_ALREADY_SIGNALED HEX: 911A +CONSTANT: GL_TIMEOUT_EXPIRED HEX: 911B +CONSTANT: GL_CONDITION_SATISFIED HEX: 911C +CONSTANT: GL_WAIT_FAILED HEX: 911D +CONSTANT: GL_SYNC_FLUSH_COMMANDS_BIT HEX: 00000001 +CONSTANT: GL_TIMEOUT_IGNORED HEX: FFFF,FFFF,FFFF,FFFF +CONSTANT: GL_SAMPLE_POSITION HEX: 8E50 +CONSTANT: GL_SAMPLE_MASK HEX: 8E51 +CONSTANT: GL_SAMPLE_MASK_VALUE HEX: 8E52 +CONSTANT: GL_MAX_SAMPLE_MASK_WORDS HEX: 8E59 +CONSTANT: GL_TEXTURE_2D_MULTISAMPLE HEX: 9100 +CONSTANT: GL_PROXY_TEXTURE_2D_MULTISAMPLE HEX: 9101 +CONSTANT: GL_TEXTURE_2D_MULTISAMPLE_ARRAY HEX: 9102 +CONSTANT: GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY HEX: 9103 +CONSTANT: GL_TEXTURE_BINDING_2D_MULTISAMPLE HEX: 9104 +CONSTANT: GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY HEX: 9105 +CONSTANT: GL_TEXTURE_SAMPLES HEX: 9106 +CONSTANT: GL_TEXTURE_FIXED_SAMPLE_LOCATIONS HEX: 9107 +CONSTANT: GL_SAMPLER_2D_MULTISAMPLE HEX: 9108 +CONSTANT: GL_INT_SAMPLER_2D_MULTISAMPLE HEX: 9109 +CONSTANT: GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE HEX: 910A +CONSTANT: GL_SAMPLER_2D_MULTISAMPLE_ARRAY HEX: 910B +CONSTANT: GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY HEX: 910C +CONSTANT: GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY HEX: 910D +CONSTANT: GL_MAX_COLOR_TEXTURE_SAMPLES HEX: 910E +CONSTANT: GL_MAX_DEPTH_TEXTURE_SAMPLES HEX: 910F +CONSTANT: GL_MAX_INTEGER_SAMPLES HEX: 9110 +CONSTANT: GL_DEPTH_CLAMP HEX: 864F +CONSTANT: GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION HEX: 8E4C +CONSTANT: GL_FIRST_VERTEX_CONVENTION HEX: 8E4D +CONSTANT: GL_LAST_VERTEX_CONVENTION HEX: 8E4E +CONSTANT: GL_PROVOKING_VERTEX HEX: 8E4F +CONSTANT: GL_TEXTURE_CUBE_MAP_SEAMLESS HEX: 884F + +GL-FUNCTION: void glFramebufferTexture { glFramebufferTextureARB glFramebufferTextureEXT } + ( GLenum target, GLenum attachment, GLuint texture, GLint level ) ; +GL-FUNCTION: void glGetBufferParameteri64v { } + ( GLenum target, GLenum pname, GLint64* params ) ; +GL-FUNCTION: void glGetInteger64i_v { } + ( GLenum target, GLuint index, GLint64* data ) ; +GL-FUNCTION: void glProvokingVertex { } ( GLenum mode ) ; + +GL-FUNCTION: GLsync glFenceSync { } ( GLenum condition, GLbitfield flags ) ; +GL-FUNCTION: GLboolean glIsSync { } ( GLsync sync ) ; +GL-FUNCTION: void glDeleteSync { } ( GLsync sync ) ; +GL-FUNCTION: GLenum glClientWaitSync { } ( GLsync sync, GLbitfield flags, GLuint64 timeout ) ; +GL-FUNCTION: void glWaitSync { } ( GLsync sync, GLbitfield flags, GLuint64 timeout ) ; +GL-FUNCTION: void glGetInteger64v { } ( GLenum pname, GLint64* params ) ; +GL-FUNCTION: void glGetSynciv { } ( GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values ) ; +GL-FUNCTION: void glTexImage2DMultisample { } ( GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations ) ; +GL-FUNCTION: void glTexImage3DMultisample { } ( GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations ) ; +GL-FUNCTION: void glGetMultisamplefv { } ( GLenum pname, GLuint index, GLfloat* val ) ; +GL-FUNCTION: void glSampleMaski { } ( GLuint index, GLbitfield mask ) ; -GL-FUNCTION: void glProgramParameteriEXT { } ( GLuint program, GLenum pname, GLint value ) ; -GL-FUNCTION: void glFramebufferTextureEXT { } ( GLenum target, GLenum attachment, - GLuint texture, GLint level ) ; +! GL_ARB_geometry_shader4 -CONSTANT: GL_GEOMETRY_SHADER_EXT HEX: 8DD9 -CONSTANT: GL_GEOMETRY_VERTICES_OUT_EXT HEX: 8DDA -CONSTANT: GL_GEOMETRY_INPUT_TYPE_EXT HEX: 8DDB -CONSTANT: GL_GEOMETRY_OUTPUT_TYPE_EXT HEX: 8DDC -CONSTANT: GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT HEX: 8C29 -CONSTANT: GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT HEX: 8DDD -CONSTANT: GL_MAX_VERTEX_VARYING_COMPONENTS_EXT HEX: 8DDE -CONSTANT: GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT HEX: 8DDF -CONSTANT: GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT HEX: 8DE0 -CONSTANT: GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT HEX: 8DE1 -CONSTANT: GL_LINES_ADJACENCY_EXT HEX: A -CONSTANT: GL_LINE_STRIP_ADJACENCY_EXT HEX: B -CONSTANT: GL_TRIANGLES_ADJACENCY_EXT HEX: C -CONSTANT: GL_TRIANGLE_STRIP_ADJACENCY_EXT HEX: D -CONSTANT: GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT HEX: 8DA8 -CONSTANT: GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT HEX: 8DA9 -CONSTANT: GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT HEX: 8DA7 -CONSTANT: GL_PROGRAM_POINT_SIZE_EXT HEX: 8642 +GL-FUNCTION: void glProgramParameteriARB { glProgramParameteriEXT } + ( GLuint program, GLenum pname, GLint value ) ; +GL-FUNCTION: void glFramebufferTextureLayerARB { glFramebufferTextureLayerEXT } + ( GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer ) ; +GL-FUNCTION: void glFramebufferTextureFaceARB { glFramebufferTextureFaceEXT } + ( GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face ) ; + +CONSTANT: GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB HEX: 8DDD +CONSTANT: GL_MAX_VERTEX_VARYING_COMPONENTS_ARB HEX: 8DDE +CONSTANT: GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB HEX: 8DA9 ! GL_EXT_framebuffer_object diff --git a/basis/opengl/gl3/gl3.factor b/basis/opengl/gl3/gl3.factor index 2c10e639e5..616049257d 100644 --- a/basis/opengl/gl3/gl3.factor +++ b/basis/opengl/gl3/gl3.factor @@ -727,6 +727,71 @@ ALIAS: GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER gl:GL_UNIFORM_BLOCK_REFERENC ALIAS: GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER gl:GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER ALIAS: GL_INVALID_INDEX gl:GL_INVALID_INDEX +ALIAS: GL_CONTEXT_CORE_PROFILE_BIT gl:GL_CONTEXT_CORE_PROFILE_BIT +ALIAS: GL_CONTEXT_COMPATIBILITY_PROFILE_BIT gl:GL_CONTEXT_COMPATIBILITY_PROFILE_BIT +ALIAS: GL_LINES_ADJACENCY gl:GL_LINES_ADJACENCY +ALIAS: GL_LINE_STRIP_ADJACENCY gl:GL_LINE_STRIP_ADJACENCY +ALIAS: GL_TRIANGLES_ADJACENCY gl:GL_TRIANGLES_ADJACENCY +ALIAS: GL_TRIANGLE_STRIP_ADJACENCY gl:GL_TRIANGLE_STRIP_ADJACENCY +ALIAS: GL_PROGRAM_POINT_SIZE gl:GL_PROGRAM_POINT_SIZE +ALIAS: GL_GEOMETRY_VERTICES_OUT gl:GL_GEOMETRY_VERTICES_OUT +ALIAS: GL_GEOMETRY_INPUT_TYPE gl:GL_GEOMETRY_INPUT_TYPE +ALIAS: GL_GEOMETRY_OUTPUT_TYPE gl:GL_GEOMETRY_OUTPUT_TYPE +ALIAS: GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS gl:GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS +ALIAS: GL_FRAMEBUFFER_ATTACHMENT_LAYERED gl:GL_FRAMEBUFFER_ATTACHMENT_LAYERED +ALIAS: GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS gl:GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS +ALIAS: GL_GEOMETRY_SHADER gl:GL_GEOMETRY_SHADER +ALIAS: GL_MAX_GEOMETRY_UNIFORM_COMPONENTS gl:GL_MAX_GEOMETRY_UNIFORM_COMPONENTS +ALIAS: GL_MAX_GEOMETRY_OUTPUT_VERTICES gl:GL_MAX_GEOMETRY_OUTPUT_VERTICES +ALIAS: GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS gl:GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS +ALIAS: GL_MAX_VERTEX_OUTPUT_COMPONENTS gl:GL_MAX_VERTEX_OUTPUT_COMPONENTS +ALIAS: GL_MAX_GEOMETRY_INPUT_COMPONENTS gl:GL_MAX_GEOMETRY_INPUT_COMPONENTS +ALIAS: GL_MAX_GEOMETRY_OUTPUT_COMPONENTS gl:GL_MAX_GEOMETRY_OUTPUT_COMPONENTS +ALIAS: GL_MAX_FRAGMENT_INPUT_COMPONENTS gl:GL_MAX_FRAGMENT_INPUT_COMPONENTS +ALIAS: GL_CONTEXT_PROFILE_MASK gl:GL_CONTEXT_PROFILE_MASK +ALIAS: GL_MAX_SERVER_WAIT_TIMEOUT gl:GL_MAX_SERVER_WAIT_TIMEOUT +ALIAS: GL_OBJECT_TYPE gl:GL_OBJECT_TYPE +ALIAS: GL_SYNC_CONDITION gl:GL_SYNC_CONDITION +ALIAS: GL_SYNC_STATUS gl:GL_SYNC_STATUS +ALIAS: GL_SYNC_FLAGS gl:GL_SYNC_FLAGS +ALIAS: GL_SYNC_FENCE gl:GL_SYNC_FENCE +ALIAS: GL_SYNC_GPU_COMMANDS_COMPLETE gl:GL_SYNC_GPU_COMMANDS_COMPLETE +ALIAS: GL_UNSIGNALED gl:GL_UNSIGNALED +ALIAS: GL_SIGNALED gl:GL_SIGNALED +ALIAS: GL_ALREADY_SIGNALED gl:GL_ALREADY_SIGNALED +ALIAS: GL_TIMEOUT_EXPIRED gl:GL_TIMEOUT_EXPIRED +ALIAS: GL_CONDITION_SATISFIED gl:GL_CONDITION_SATISFIED +ALIAS: GL_WAIT_FAILED gl:GL_WAIT_FAILED +ALIAS: GL_SYNC_FLUSH_COMMANDS_BIT gl:GL_SYNC_FLUSH_COMMANDS_BIT +ALIAS: GL_TIMEOUT_IGNORED gl:GL_TIMEOUT_IGNORED +ALIAS: GL_SAMPLE_POSITION gl:GL_SAMPLE_POSITION +ALIAS: GL_SAMPLE_MASK gl:GL_SAMPLE_MASK +ALIAS: GL_SAMPLE_MASK_VALUE gl:GL_SAMPLE_MASK_VALUE +ALIAS: GL_MAX_SAMPLE_MASK_WORDS gl:GL_MAX_SAMPLE_MASK_WORDS +ALIAS: GL_TEXTURE_2D_MULTISAMPLE gl:GL_TEXTURE_2D_MULTISAMPLE +ALIAS: GL_PROXY_TEXTURE_2D_MULTISAMPLE gl:GL_PROXY_TEXTURE_2D_MULTISAMPLE +ALIAS: GL_TEXTURE_2D_MULTISAMPLE_ARRAY gl:GL_TEXTURE_2D_MULTISAMPLE_ARRAY +ALIAS: GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY gl:GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY +ALIAS: GL_TEXTURE_BINDING_2D_MULTISAMPLE gl:GL_TEXTURE_BINDING_2D_MULTISAMPLE +ALIAS: GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY gl:GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY +ALIAS: GL_TEXTURE_SAMPLES gl:GL_TEXTURE_SAMPLES +ALIAS: GL_TEXTURE_FIXED_SAMPLE_LOCATIONS gl:GL_TEXTURE_FIXED_SAMPLE_LOCATIONS +ALIAS: GL_SAMPLER_2D_MULTISAMPLE gl:GL_SAMPLER_2D_MULTISAMPLE +ALIAS: GL_INT_SAMPLER_2D_MULTISAMPLE gl:GL_INT_SAMPLER_2D_MULTISAMPLE +ALIAS: GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE gl:GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE +ALIAS: GL_SAMPLER_2D_MULTISAMPLE_ARRAY gl:GL_SAMPLER_2D_MULTISAMPLE_ARRAY +ALIAS: GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY gl:GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY +ALIAS: GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY gl:GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY +ALIAS: GL_MAX_COLOR_TEXTURE_SAMPLES gl:GL_MAX_COLOR_TEXTURE_SAMPLES +ALIAS: GL_MAX_DEPTH_TEXTURE_SAMPLES gl:GL_MAX_DEPTH_TEXTURE_SAMPLES +ALIAS: GL_MAX_INTEGER_SAMPLES gl:GL_MAX_INTEGER_SAMPLES +ALIAS: GL_DEPTH_CLAMP gl:GL_DEPTH_CLAMP +ALIAS: GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION gl:GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION +ALIAS: GL_FIRST_VERTEX_CONVENTION gl:GL_FIRST_VERTEX_CONVENTION +ALIAS: GL_LAST_VERTEX_CONVENTION gl:GL_LAST_VERTEX_CONVENTION +ALIAS: GL_PROVOKING_VERTEX gl:GL_PROVOKING_VERTEX +ALIAS: GL_TEXTURE_CUBE_MAP_SEAMLESS gl:GL_TEXTURE_CUBE_MAP_SEAMLESS + ALIAS: glCullFace gl:glCullFace ALIAS: glFrontFace gl:glFrontFace ALIAS: glHint gl:glHint @@ -1005,3 +1070,19 @@ ALIAS: glGetActiveUniformBlockiv gl:glGetActiveUniformBlockiv ALIAS: glGetActiveUniformBlockName gl:glGetActiveUniformBlockName ALIAS: glUniformBlockBinding gl:glUniformBlockBinding ALIAS: glCopyBufferSubData gl:glCopyBufferSubData +ALIAS: glFramebufferTexture gl:glFramebufferTexture +ALIAS: glGetBufferParameteri64v gl:glGetBufferParameteri64v +ALIAS: glGetInteger64i_v gl:glGetInteger64i_v +ALIAS: glProvokingVertex gl:glProvokingVertex +ALIAS: glFenceSync gl:glFenceSync +ALIAS: glIsSync gl:glIsSync +ALIAS: glDeleteSync gl:glDeleteSync +ALIAS: glClientWaitSync gl:glClientWaitSync +ALIAS: glWaitSync gl:glWaitSync +ALIAS: glGetInteger64v gl:glGetInteger64v +ALIAS: glGetSynciv gl:glGetSynciv +ALIAS: glTexImage2DMultisample gl:glTexImage2DMultisample +ALIAS: glTexImage3DMultisample gl:glTexImage3DMultisample +ALIAS: glGetMultisamplefv gl:glGetMultisamplefv +ALIAS: glSampleMaski gl:glSampleMaski + From 7fcc03b8b6df595b49acb2d954f5aa3b63bc3ee8 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Tue, 16 Mar 2010 21:30:17 -0400 Subject: [PATCH 412/713] Fixing spacing in the sets docs --- core/sets/sets-docs.factor | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/sets/sets-docs.factor b/core/sets/sets-docs.factor index 5cb0096d0b..75df4069dc 100644 --- a/core/sets/sets-docs.factor +++ b/core/sets/sets-docs.factor @@ -15,9 +15,9 @@ ABOUT: "sets" ARTICLE: "set-operations" "Operations on sets" "To test if an object is a member of a set:" -{ $subsection member? } +{ $subsections member? } "All sets can be represented as a sequence, without duplicates, of their members:" -{ $subsection members } +{ $subsections members } "Sets can have members added or removed destructively:" { $subsections adjoin @@ -36,9 +36,9 @@ ARTICLE: "set-operations" "Operations on sets" set= } "An optional generic word for creating sets of the same class as a given set:" -{ $subsection set-like } +{ $subsections set-like } "An optional generic word for creating a set with a fast lookup operation, if the set itself has a slow lookup operation:" -{ $subsection fast-set } +{ $subsections fast-set } "For set types that allow duplicates, like sequence sets, some additional words test for duplication:" { $subsections all-unique? From 632c1996363515107dfe1356e314ded1df967cb0 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 16 Mar 2010 18:35:46 -0700 Subject: [PATCH 413/713] opengl 3.3, 4.0 --- basis/opengl/gl/gl.factor | 226 +++++++++++++++++++++++++++++++++++- basis/opengl/gl3/gl3.factor | 168 ++++++++++++++++++++++++++- 2 files changed, 391 insertions(+), 3 deletions(-) diff --git a/basis/opengl/gl/gl.factor b/basis/opengl/gl/gl.factor index 599721fb5e..a6413fee4a 100644 --- a/basis/opengl/gl/gl.factor +++ b/basis/opengl/gl/gl.factor @@ -903,7 +903,7 @@ FUNCTION: void glEdgeFlagPointer ( GLsizei stride, GLvoid* ptr ) ; ! [09:39] (slava) NULL ! [09:39] (slava) then keep that object -! [09:39] (slava) when you want to get the value stored there, *void* +! [09:39] (slava) when you want to get the value stored there,* void* ! [09:39] (slava) which returns an alien FUNCTION: void glGetPointerv ( GLenum pname, GLvoid** params ) ; @@ -2258,6 +2258,227 @@ GL-FUNCTION: void glGetMultisamplefv { } ( GLenum pname, GLuint index, GLfloat* GL-FUNCTION: void glSampleMaski { } ( GLuint index, GLbitfield mask ) ; +! OpenGL 3.3 + +CONSTANT: GL_SRC1_COLOR HEX: 88F9 +CONSTANT: GL_ONE_MINUS_SRC1_COLOR HEX: 88FA +CONSTANT: GL_ONE_MINUS_SRC1_ALPHA HEX: 88FB +CONSTANT: GL_MAX_DUAL_SOURCE_DRAW_BUFFERS HEX: 88FC + +CONSTANT: GL_ANY_SAMPLES_PASSED HEX: 8C2F + +CONSTANT: GL_SAMPLER_BINDING HEX: 8919 + +CONSTANT: GL_RGB10_A2UI HEX: 906F + +CONSTANT: GL_TEXTURE_SWIZZLE_R HEX: 8E42 +CONSTANT: GL_TEXTURE_SWIZZLE_G HEX: 8E43 +CONSTANT: GL_TEXTURE_SWIZZLE_B HEX: 8E44 +CONSTANT: GL_TEXTURE_SWIZZLE_A HEX: 8E45 +CONSTANT: GL_TEXTURE_SWIZZLE_RGBA HEX: 8E46 + +CONSTANT: GL_TIME_ELAPSED HEX: 88BF +CONSTANT: GL_TIMESTAMP HEX: 8E28 + +CONSTANT: GL_INT_2_10_10_10_REV HEX: 8D9F + +GL-FUNCTION: void glBindFragDataLocationIndexed { } ( GLuint program, GLuint colorNumber, GLuint index, GLstring name ) ; +GL-FUNCTION: GLint glGetFragDataIndex { } ( GLuint program, GLstring name ) ; + +GL-FUNCTION: void glGenSamplers { } ( GLsizei count, GLuint* samplers ) ; +GL-FUNCTION: void glDeleteSamplers { } ( GLsizei count, GLuint* samplers ) ; +GL-FUNCTION: GLboolean glIsSampler { } ( GLuint sampler ) ; +GL-FUNCTION: void glBindSampler { } ( GLenum unit, GLuint sampler ) ; +GL-FUNCTION: void glSamplerParameteri { } ( GLuint sampler, GLenum pname, GLint param ) ; +GL-FUNCTION: void glSamplerParameteriv { } ( GLuint sampler, GLenum pname, GLint* param ) ; +GL-FUNCTION: void glSamplerParameterf { } ( GLuint sampler, GLenum pname, GLfloat param ) ; +GL-FUNCTION: void glSamplerParameterfv { } ( GLuint sampler, GLenum pname, GLfloat* param ) ; +GL-FUNCTION: void glSamplerParameterIiv { } ( GLuint sampler, GLenum pname, GLint* param ) ; +GL-FUNCTION: void glSamplerParameterIuiv { } ( GLuint sampler, GLenum pname, GLuint* param ) ; +GL-FUNCTION: void glGetSamplerParameteriv { } ( GLuint sampler, GLenum pname, GLint* params ) ; +GL-FUNCTION: void glGetSamplerParameterIiv { } ( GLuint sampler, GLenum pname, GLint* params ) ; +GL-FUNCTION: void glGetSamplerParameterfv { } ( GLuint sampler, GLenum pname, GLfloat* params ) ; +GL-FUNCTION: void glGetSamplerParameterIfv { } ( GLuint sampler, GLenum pname, GLfloat* params ) ; + +GL-FUNCTION: void glQueryCounter { } ( GLuint id, GLenum target ) ; +GL-FUNCTION: void glGetQueryObjecti64v { } ( GLuint id, GLenum pname, GLint64* params ) ; +GL-FUNCTION: void glGetQueryObjectui64v { } ( GLuint id, GLenum pname, GLuint64* params ) ; + +GL-FUNCTION: void glVertexP2ui { } ( GLenum type, GLuint value ) ; +GL-FUNCTION: void glVertexP2uiv { } ( GLenum type, GLuint* value ) ; +GL-FUNCTION: void glVertexP3ui { } ( GLenum type, GLuint value ) ; +GL-FUNCTION: void glVertexP3uiv { } ( GLenum type, GLuint* value ) ; +GL-FUNCTION: void glVertexP4ui { } ( GLenum type, GLuint value ) ; +GL-FUNCTION: void glVertexP4uiv { } ( GLenum type, GLuint* value ) ; +GL-FUNCTION: void glTexCoordP1ui { } ( GLenum type, GLuint coords ) ; +GL-FUNCTION: void glTexCoordP1uiv { } ( GLenum type, GLuint* coords ) ; +GL-FUNCTION: void glTexCoordP2ui { } ( GLenum type, GLuint coords ) ; +GL-FUNCTION: void glTexCoordP2uiv { } ( GLenum type, GLuint* coords ) ; +GL-FUNCTION: void glTexCoordP3ui { } ( GLenum type, GLuint coords ) ; +GL-FUNCTION: void glTexCoordP3uiv { } ( GLenum type, GLuint* coords ) ; +GL-FUNCTION: void glTexCoordP4ui { } ( GLenum type, GLuint coords ) ; +GL-FUNCTION: void glTexCoordP4uiv { } ( GLenum type, GLuint* coords ) ; +GL-FUNCTION: void glMultiTexCoordP1ui { } ( GLenum texture, GLenum type, GLuint coords ) ; +GL-FUNCTION: void glMultiTexCoordP1uiv { } ( GLenum texture, GLenum type, GLuint* coords ) ; +GL-FUNCTION: void glMultiTexCoordP2ui { } ( GLenum texture, GLenum type, GLuint coords ) ; +GL-FUNCTION: void glMultiTexCoordP2uiv { } ( GLenum texture, GLenum type, GLuint* coords ) ; +GL-FUNCTION: void glMultiTexCoordP3ui { } ( GLenum texture, GLenum type, GLuint coords ) ; +GL-FUNCTION: void glMultiTexCoordP3uiv { } ( GLenum texture, GLenum type, GLuint* coords ) ; +GL-FUNCTION: void glMultiTexCoordP4ui { } ( GLenum texture, GLenum type, GLuint coords ) ; +GL-FUNCTION: void glMultiTexCoordP4uiv { } ( GLenum texture, GLenum type, GLuint* coords ) ; +GL-FUNCTION: void glNormalP3ui { } ( GLenum type, GLuint coords ) ; +GL-FUNCTION: void glNormalP3uiv { } ( GLenum type, GLuint* coords ) ; +GL-FUNCTION: void glColorP3ui { } ( GLenum type, GLuint color ) ; +GL-FUNCTION: void glColorP3uiv { } ( GLenum type, GLuint* color ) ; +GL-FUNCTION: void glColorP4ui { } ( GLenum type, GLuint color ) ; +GL-FUNCTION: void glColorP4uiv { } ( GLenum type, GLuint* color ) ; +GL-FUNCTION: void glSecondaryColorP3ui { } ( GLenum type, GLuint color ) ; +GL-FUNCTION: void glSecondaryColorP3uiv { } ( GLenum type, GLuint* color ) ; +GL-FUNCTION: void glVertexAttribP1ui { } ( GLuint index, GLenum type, GLboolean normalized, GLuint value ) ; +GL-FUNCTION: void glVertexAttribP1uiv { } ( GLuint index, GLenum type, GLboolean normalized, GLuint* value ) ; +GL-FUNCTION: void glVertexAttribP2ui { } ( GLuint index, GLenum type, GLboolean normalized, GLuint value ) ; +GL-FUNCTION: void glVertexAttribP2uiv { } ( GLuint index, GLenum type, GLboolean normalized, GLuint* value ) ; +GL-FUNCTION: void glVertexAttribP3ui { } ( GLuint index, GLenum type, GLboolean normalized, GLuint value ) ; +GL-FUNCTION: void glVertexAttribP3uiv { } ( GLuint index, GLenum type, GLboolean normalized, GLuint* value ) ; +GL-FUNCTION: void glVertexAttribP4ui { } ( GLuint index, GLenum type, GLboolean normalized, GLuint value ) ; +GL-FUNCTION: void glVertexAttribP4uiv { } ( GLuint index, GLenum type, GLboolean normalized, GLuint* value ) ; + + +! OpenGL 4.0 + +CONSTANT: GL_DRAW_INDIRECT_BUFFER HEX: 8F3F +CONSTANT: GL_DRAW_INDIRECT_BUFFER_BINDING HEX: 8F43 + +CONSTANT: GL_GEOMETRY_SHADER_INVOCATIONS HEX: 887F +CONSTANT: GL_MAX_GEOMETRY_SHADER_INVOCATIONS HEX: 8E5A +CONSTANT: GL_MIN_FRAGMENT_INTERPOLATION_OFFSET HEX: 8E5B +CONSTANT: GL_MAX_FRAGMENT_INTERPOLATION_OFFSET HEX: 8E5C +CONSTANT: GL_FRAGMENT_INTERPOLATION_OFFSET_BITS HEX: 8E5D +CONSTANT: GL_MAX_VERTEX_STREAMS HEX: 8E71 + +CONSTANT: GL_DOUBLE_VEC2 HEX: 8FFC +CONSTANT: GL_DOUBLE_VEC3 HEX: 8FFD +CONSTANT: GL_DOUBLE_VEC4 HEX: 8FFE +CONSTANT: GL_DOUBLE_MAT2 HEX: 8F46 +CONSTANT: GL_DOUBLE_MAT3 HEX: 8F47 +CONSTANT: GL_DOUBLE_MAT4 HEX: 8F48 +CONSTANT: GL_DOUBLE_MAT2x3 HEX: 8F49 +CONSTANT: GL_DOUBLE_MAT2x4 HEX: 8F4A +CONSTANT: GL_DOUBLE_MAT3x2 HEX: 8F4B +CONSTANT: GL_DOUBLE_MAT3x4 HEX: 8F4C +CONSTANT: GL_DOUBLE_MAT4x2 HEX: 8F4D +CONSTANT: GL_DOUBLE_MAT4x3 HEX: 8F4E + +CONSTANT: GL_ACTIVE_SUBROUTINES HEX: 8DE5 +CONSTANT: GL_ACTIVE_SUBROUTINE_UNIFORMS HEX: 8DE6 +CONSTANT: GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS HEX: 8E47 +CONSTANT: GL_ACTIVE_SUBROUTINE_MAX_LENGTH HEX: 8E48 +CONSTANT: GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH HEX: 8E49 +CONSTANT: GL_MAX_SUBROUTINES HEX: 8DE7 +CONSTANT: GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS HEX: 8DE8 +CONSTANT: GL_NUM_COMPATIBLE_SUBROUTINES HEX: 8E4A +CONSTANT: GL_COMPATIBLE_SUBROUTINES HEX: 8E4B + +CONSTANT: GL_PATCHES HEX: 000E +CONSTANT: GL_PATCH_VERTICES HEX: 8E72 +CONSTANT: GL_PATCH_DEFAULT_INNER_LEVEL HEX: 8E73 +CONSTANT: GL_PATCH_DEFAULT_OUTER_LEVEL HEX: 8E74 +CONSTANT: GL_TESS_CONTROL_OUTPUT_VERTICES HEX: 8E75 +CONSTANT: GL_TESS_GEN_MODE HEX: 8E76 +CONSTANT: GL_TESS_GEN_SPACING HEX: 8E77 +CONSTANT: GL_TESS_GEN_VERTEX_ORDER HEX: 8E78 +CONSTANT: GL_TESS_GEN_POINT_MODE HEX: 8E79 +CONSTANT: GL_ISOLINES HEX: 8E7A +CONSTANT: GL_FRACTIONAL_ODD HEX: 8E7B +CONSTANT: GL_FRACTIONAL_EVEN HEX: 8E7C +CONSTANT: GL_MAX_PATCH_VERTICES HEX: 8E7D +CONSTANT: GL_MAX_TESS_GEN_LEVEL HEX: 8E7E +CONSTANT: GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS HEX: 8E7F +CONSTANT: GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS HEX: 8E80 +CONSTANT: GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS HEX: 8E81 +CONSTANT: GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS HEX: 8E82 +CONSTANT: GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS HEX: 8E83 +CONSTANT: GL_MAX_TESS_PATCH_COMPONENTS HEX: 8E84 +CONSTANT: GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS HEX: 8E85 +CONSTANT: GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS HEX: 8E86 +CONSTANT: GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS HEX: 8E89 +CONSTANT: GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS HEX: 8E8A +CONSTANT: GL_MAX_TESS_CONTROL_INPUT_COMPONENTS HEX: 886C +CONSTANT: GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS HEX: 886D +CONSTANT: GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS HEX: 8E1E +CONSTANT: GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS HEX: 8E1F +CONSTANT: GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER HEX: 84F0 +CONSTANT: GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER HEX: 84F1 +CONSTANT: GL_TESS_EVALUATION_SHADER HEX: 8E87 +CONSTANT: GL_TESS_CONTROL_SHADER HEX: 8E88 +CONSTANT: GL_TRANSFORM_FEEDBACK HEX: 8E22 +CONSTANT: GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED HEX: 8E23 +CONSTANT: GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE HEX: 8E24 +CONSTANT: GL_TRANSFORM_FEEDBACK_BINDING HEX: 8E25 +CONSTANT: GL_MAX_TRANSFORM_FEEDBACK_BUFFERS HEX: 8E70 + +GL-FUNCTION: void glUniform1d { } ( GLint location, GLdouble x ) ; +GL-FUNCTION: void glUniform2d { } ( GLint location, GLdouble x, GLdouble y ) ; +GL-FUNCTION: void glUniform3d { } ( GLint location, GLdouble x, GLdouble y, GLdouble z ) ; +GL-FUNCTION: void glUniform4d { } ( GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w ) ; +GL-FUNCTION: void glUniform1dv { } ( GLint location, GLsizei count, GLdouble* value ) ; +GL-FUNCTION: void glUniform2dv { } ( GLint location, GLsizei count, GLdouble* value ) ; +GL-FUNCTION: void glUniform3dv { } ( GLint location, GLsizei count, GLdouble* value ) ; +GL-FUNCTION: void glUniform4dv { } ( GLint location, GLsizei count, GLdouble* value ) ; +GL-FUNCTION: void glUniformMatrix2dv { } ( GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glUniformMatrix3dv { } ( GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glUniformMatrix4dv { } ( GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glUniformMatrix2x3dv { } ( GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glUniformMatrix2x4dv { } ( GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glUniformMatrix3x2dv { } ( GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glUniformMatrix3x4dv { } ( GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glUniformMatrix4x2dv { } ( GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glUniformMatrix4x3dv { } ( GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glGetUniformdv { } ( GLuint program, GLint location, GLdouble* params ) ; +GL-FUNCTION: void glProgramUniform1dEXT { } ( GLuint program, GLint location, GLdouble x ) ; +GL-FUNCTION: void glProgramUniform2dEXT { } ( GLuint program, GLint location, GLdouble x, GLdouble y ) ; +GL-FUNCTION: void glProgramUniform3dEXT { } ( GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z ) ; +GL-FUNCTION: void glProgramUniform4dEXT { } ( GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w ) ; +GL-FUNCTION: void glProgramUniform1dvEXT { } ( GLuint program, GLint location, GLsizei count, GLdouble* value ) ; +GL-FUNCTION: void glProgramUniform2dvEXT { } ( GLuint program, GLint location, GLsizei count, GLdouble* value ) ; +GL-FUNCTION: void glProgramUniform3dvEXT { } ( GLuint program, GLint location, GLsizei count, GLdouble* value ) ; +GL-FUNCTION: void glProgramUniform4dvEXT { } ( GLuint program, GLint location, GLsizei count, GLdouble* value ) ; +GL-FUNCTION: void glProgramUniformMatrix2dvEXT { } ( GLuint program, GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glProgramUniformMatrix3dvEXT { } ( GLuint program, GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glProgramUniformMatrix4dvEXT { } ( GLuint program, GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glProgramUniformMatrix2x3dvEXT { } ( GLuint program, GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glProgramUniformMatrix2x4dvEXT { } ( GLuint program, GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glProgramUniformMatrix3x2dvEXT { } ( GLuint program, GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glProgramUniformMatrix3x4dvEXT { } ( GLuint program, GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glProgramUniformMatrix4x2dvEXT { } ( GLuint program, GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; +GL-FUNCTION: void glProgramUniformMatrix4x3dvEXT { } ( GLuint program, GLint location, GLsizei count, GLboolean transpose, GLdouble* value ) ; + +GL-FUNCTION: GLint glGetSubroutineUniformLocation { } ( GLuint program, GLenum shadertype, GLstring name ) ; +GL-FUNCTION: GLuint glGetSubroutineIndex { } ( GLuint program, GLenum shadertype, GLstring name ) ; +GL-FUNCTION: void glGetActiveSubroutineUniformiv { } ( GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint* values ) ; +GL-FUNCTION: void glGetActiveSubroutineUniformName { } ( GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei* length, GLstring name ) ; +GL-FUNCTION: void glGetActiveSubroutineName { } ( GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei* length, GLstring name ) ; +GL-FUNCTION: void glUniformSubroutinesuiv { } ( GLenum shadertype, GLsizei count, GLuint* indices ) ; +GL-FUNCTION: void glGetUniformSubroutineuiv { } ( GLenum shadertype, GLint location, GLuint* params ) ; +GL-FUNCTION: void glGetProgramStageiv { } ( GLuint program, GLenum shadertype, GLenum pname, GLint* values ) ; + +GL-FUNCTION: void glPatchParameteri { } ( GLenum pname, GLint value ) ; +GL-FUNCTION: void glPatchParameterfv { } ( GLenum pname, GLfloat* values ) ; + +GL-FUNCTION: void glBindTransformFeedback { } ( GLenum target, GLuint id ) ; +GL-FUNCTION: void glDeleteTransformFeedbacks { } ( GLsizei n, GLuint* ids ) ; +GL-FUNCTION: void glGenTransformFeedbacks { } ( GLsizei n, GLuint* ids ) ; +GL-FUNCTION: GLboolean glIsTransformFeedback { } ( GLuint id ) ; +GL-FUNCTION: void glPauseTransformFeedback { } ( ) ; +GL-FUNCTION: void glResumeTransformFeedback { } ( ) ; +GL-FUNCTION: void glDrawTransformFeedback { } ( GLenum mode, GLuint id ) ; + +GL-FUNCTION: void glDrawTransformFeedbackStream { } ( GLenum mode, GLuint id, GLuint stream ) ; +GL-FUNCTION: void glBeginQueryIndexed { } ( GLenum target, GLuint index, GLuint id ) ; +GL-FUNCTION: void glEndQueryIndexed { } ( GLenum target, GLuint index ) ; +GL-FUNCTION: void glGetQueryIndexediv { } ( GLenum target, GLuint index, GLenum pname, GLint* params ) ; + + ! GL_ARB_geometry_shader4 GL-FUNCTION: void glProgramParameteriARB { glProgramParameteriEXT } @@ -2290,6 +2511,7 @@ CONSTANT: GL_LUMINANCE_ALPHA16F_ARB HEX: 881F CONSTANT: GL_TEXTURE_LUMINANCE_TYPE_ARB HEX: 8C14 CONSTANT: GL_TEXTURE_INTENSITY_TYPE_ARB HEX: 8C15 + ! GL_EXT_texture_integer CONSTANT: GL_ALPHA32UI_EXT HEX: 8D72 @@ -2329,6 +2551,7 @@ CONSTANT: GL_LUMINANCE_ALPHA_INTEGER_EXT HEX: 8D9D GL-FUNCTION: void glClearColorIiEXT { } ( GLint r, GLint g, GLint b, GLint a ) ; GL-FUNCTION: void glClearColorIuiEXT { } ( GLuint r, GLuint g, GLuint b, GLuint a ) ; + ! GL_EXT_texture_compression_s3tc, GL_EXT_texture_compression_dxt1 CONSTANT: GL_COMPRESSED_RGB_S3TC_DXT1_EXT HEX: 83F0 @@ -2336,6 +2559,7 @@ CONSTANT: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT HEX: 83F1 CONSTANT: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT HEX: 83F2 CONSTANT: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT HEX: 83F3 + ! GL_EXT_texture_compression_latc CONSTANT: GL_COMPRESSED_LUMINANCE_LATC1_EXT HEX: 8C70 diff --git a/basis/opengl/gl3/gl3.factor b/basis/opengl/gl3/gl3.factor index 616049257d..0faacacf15 100644 --- a/basis/opengl/gl3/gl3.factor +++ b/basis/opengl/gl3/gl3.factor @@ -17,6 +17,7 @@ ALIAS: GL_LINE_STRIP gl:GL_LINE_STRIP ALIAS: GL_TRIANGLES gl:GL_TRIANGLES ALIAS: GL_TRIANGLE_STRIP gl:GL_TRIANGLE_STRIP ALIAS: GL_TRIANGLE_FAN gl:GL_TRIANGLE_FAN +ALIAS: GL_QUADS gl:GL_QUADS ALIAS: GL_NEVER gl:GL_NEVER ALIAS: GL_LESS gl:GL_LESS ALIAS: GL_EQUAL gl:GL_EQUAL @@ -354,6 +355,7 @@ ALIAS: GL_DYNAMIC_DRAW gl:GL_DYNAMIC_DRAW ALIAS: GL_DYNAMIC_READ gl:GL_DYNAMIC_READ ALIAS: GL_DYNAMIC_COPY gl:GL_DYNAMIC_COPY ALIAS: GL_SAMPLES_PASSED gl:GL_SAMPLES_PASSED +ALIAS: GL_SRC1_ALPHA gl:GL_SRC1_ALPHA ALIAS: GL_BLEND_EQUATION_RGB gl:GL_BLEND_EQUATION_RGB ALIAS: GL_VERTEX_ATTRIB_ARRAY_ENABLED gl:GL_VERTEX_ATTRIB_ARRAY_ENABLED ALIAS: GL_VERTEX_ATTRIB_ARRAY_SIZE gl:GL_VERTEX_ATTRIB_ARRAY_SIZE @@ -726,7 +728,6 @@ ALIAS: GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES gl:GL_UNIFORM_BLOCK_ACTIVE_UNIFOR ALIAS: GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER gl:GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER ALIAS: GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER gl:GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER ALIAS: GL_INVALID_INDEX gl:GL_INVALID_INDEX - ALIAS: GL_CONTEXT_CORE_PROFILE_BIT gl:GL_CONTEXT_CORE_PROFILE_BIT ALIAS: GL_CONTEXT_COMPATIBILITY_PROFILE_BIT gl:GL_CONTEXT_COMPATIBILITY_PROFILE_BIT ALIAS: GL_LINES_ADJACENCY gl:GL_LINES_ADJACENCY @@ -791,6 +792,87 @@ ALIAS: GL_FIRST_VERTEX_CONVENTION gl:GL_FIRST_VERTEX_CONVENTION ALIAS: GL_LAST_VERTEX_CONVENTION gl:GL_LAST_VERTEX_CONVENTION ALIAS: GL_PROVOKING_VERTEX gl:GL_PROVOKING_VERTEX ALIAS: GL_TEXTURE_CUBE_MAP_SEAMLESS gl:GL_TEXTURE_CUBE_MAP_SEAMLESS +ALIAS: GL_SRC1_COLOR gl:GL_SRC1_COLOR +ALIAS: GL_ONE_MINUS_SRC1_COLOR gl:GL_ONE_MINUS_SRC1_COLOR +ALIAS: GL_ONE_MINUS_SRC1_ALPHA gl:GL_ONE_MINUS_SRC1_ALPHA +ALIAS: GL_MAX_DUAL_SOURCE_DRAW_BUFFERS gl:GL_MAX_DUAL_SOURCE_DRAW_BUFFERS +ALIAS: GL_ANY_SAMPLES_PASSED gl:GL_ANY_SAMPLES_PASSED +ALIAS: GL_SAMPLER_BINDING gl:GL_SAMPLER_BINDING +ALIAS: GL_RGB10_A2UI gl:GL_RGB10_A2UI +ALIAS: GL_TEXTURE_SWIZZLE_R gl:GL_TEXTURE_SWIZZLE_R +ALIAS: GL_TEXTURE_SWIZZLE_G gl:GL_TEXTURE_SWIZZLE_G +ALIAS: GL_TEXTURE_SWIZZLE_B gl:GL_TEXTURE_SWIZZLE_B +ALIAS: GL_TEXTURE_SWIZZLE_A gl:GL_TEXTURE_SWIZZLE_A +ALIAS: GL_TEXTURE_SWIZZLE_RGBA gl:GL_TEXTURE_SWIZZLE_RGBA +ALIAS: GL_TIME_ELAPSED gl:GL_TIME_ELAPSED +ALIAS: GL_TIMESTAMP gl:GL_TIMESTAMP +ALIAS: GL_INT_2_10_10_10_REV gl:GL_INT_2_10_10_10_REV +ALIAS: GL_DRAW_INDIRECT_BUFFER gl:GL_DRAW_INDIRECT_BUFFER +ALIAS: GL_DRAW_INDIRECT_BUFFER_BINDING gl:GL_DRAW_INDIRECT_BUFFER_BINDING +ALIAS: GL_GEOMETRY_SHADER_INVOCATIONS gl:GL_GEOMETRY_SHADER_INVOCATIONS +ALIAS: GL_MAX_GEOMETRY_SHADER_INVOCATIONS gl:GL_MAX_GEOMETRY_SHADER_INVOCATIONS +ALIAS: GL_MIN_FRAGMENT_INTERPOLATION_OFFSET gl:GL_MIN_FRAGMENT_INTERPOLATION_OFFSET +ALIAS: GL_MAX_FRAGMENT_INTERPOLATION_OFFSET gl:GL_MAX_FRAGMENT_INTERPOLATION_OFFSET +ALIAS: GL_FRAGMENT_INTERPOLATION_OFFSET_BITS gl:GL_FRAGMENT_INTERPOLATION_OFFSET_BITS +ALIAS: GL_MAX_VERTEX_STREAMS gl:GL_MAX_VERTEX_STREAMS +ALIAS: GL_DOUBLE_VEC2 gl:GL_DOUBLE_VEC2 +ALIAS: GL_DOUBLE_VEC3 gl:GL_DOUBLE_VEC3 +ALIAS: GL_DOUBLE_VEC4 gl:GL_DOUBLE_VEC4 +ALIAS: GL_DOUBLE_MAT2 gl:GL_DOUBLE_MAT2 +ALIAS: GL_DOUBLE_MAT3 gl:GL_DOUBLE_MAT3 +ALIAS: GL_DOUBLE_MAT4 gl:GL_DOUBLE_MAT4 +ALIAS: GL_DOUBLE_MAT2x3 gl:GL_DOUBLE_MAT2x3 +ALIAS: GL_DOUBLE_MAT2x4 gl:GL_DOUBLE_MAT2x4 +ALIAS: GL_DOUBLE_MAT3x2 gl:GL_DOUBLE_MAT3x2 +ALIAS: GL_DOUBLE_MAT3x4 gl:GL_DOUBLE_MAT3x4 +ALIAS: GL_DOUBLE_MAT4x2 gl:GL_DOUBLE_MAT4x2 +ALIAS: GL_DOUBLE_MAT4x3 gl:GL_DOUBLE_MAT4x3 +ALIAS: GL_ACTIVE_SUBROUTINES gl:GL_ACTIVE_SUBROUTINES +ALIAS: GL_ACTIVE_SUBROUTINE_UNIFORMS gl:GL_ACTIVE_SUBROUTINE_UNIFORMS +ALIAS: GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS gl:GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS +ALIAS: GL_ACTIVE_SUBROUTINE_MAX_LENGTH gl:GL_ACTIVE_SUBROUTINE_MAX_LENGTH +ALIAS: GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH gl:GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH +ALIAS: GL_MAX_SUBROUTINES gl:GL_MAX_SUBROUTINES +ALIAS: GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS gl:GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS +ALIAS: GL_NUM_COMPATIBLE_SUBROUTINES gl:GL_NUM_COMPATIBLE_SUBROUTINES +ALIAS: GL_COMPATIBLE_SUBROUTINES gl:GL_COMPATIBLE_SUBROUTINES +ALIAS: GL_PATCHES gl:GL_PATCHES +ALIAS: GL_PATCH_VERTICES gl:GL_PATCH_VERTICES +ALIAS: GL_PATCH_DEFAULT_INNER_LEVEL gl:GL_PATCH_DEFAULT_INNER_LEVEL +ALIAS: GL_PATCH_DEFAULT_OUTER_LEVEL gl:GL_PATCH_DEFAULT_OUTER_LEVEL +ALIAS: GL_TESS_CONTROL_OUTPUT_VERTICES gl:GL_TESS_CONTROL_OUTPUT_VERTICES +ALIAS: GL_TESS_GEN_MODE gl:GL_TESS_GEN_MODE +ALIAS: GL_TESS_GEN_SPACING gl:GL_TESS_GEN_SPACING +ALIAS: GL_TESS_GEN_VERTEX_ORDER gl:GL_TESS_GEN_VERTEX_ORDER +ALIAS: GL_TESS_GEN_POINT_MODE gl:GL_TESS_GEN_POINT_MODE +ALIAS: GL_ISOLINES gl:GL_ISOLINES +ALIAS: GL_FRACTIONAL_ODD gl:GL_FRACTIONAL_ODD +ALIAS: GL_FRACTIONAL_EVEN gl:GL_FRACTIONAL_EVEN +ALIAS: GL_MAX_PATCH_VERTICES gl:GL_MAX_PATCH_VERTICES +ALIAS: GL_MAX_TESS_GEN_LEVEL gl:GL_MAX_TESS_GEN_LEVEL +ALIAS: GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS gl:GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS +ALIAS: GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS gl:GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS +ALIAS: GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS gl:GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS +ALIAS: GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS gl:GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS +ALIAS: GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS gl:GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS +ALIAS: GL_MAX_TESS_PATCH_COMPONENTS gl:GL_MAX_TESS_PATCH_COMPONENTS +ALIAS: GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS gl:GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS +ALIAS: GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS gl:GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS +ALIAS: GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS gl:GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS +ALIAS: GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS gl:GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS +ALIAS: GL_MAX_TESS_CONTROL_INPUT_COMPONENTS gl:GL_MAX_TESS_CONTROL_INPUT_COMPONENTS +ALIAS: GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS gl:GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS +ALIAS: GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS gl:GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS +ALIAS: GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS gl:GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS +ALIAS: GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER gl:GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER +ALIAS: GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER gl:GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER +ALIAS: GL_TESS_EVALUATION_SHADER gl:GL_TESS_EVALUATION_SHADER +ALIAS: GL_TESS_CONTROL_SHADER gl:GL_TESS_CONTROL_SHADER +ALIAS: GL_TRANSFORM_FEEDBACK gl:GL_TRANSFORM_FEEDBACK +ALIAS: GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED gl:GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED +ALIAS: GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE gl:GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE +ALIAS: GL_TRANSFORM_FEEDBACK_BINDING gl:GL_TRANSFORM_FEEDBACK_BINDING +ALIAS: GL_MAX_TRANSFORM_FEEDBACK_BUFFERS gl:GL_MAX_TRANSFORM_FEEDBACK_BUFFERS ALIAS: glCullFace gl:glCullFace ALIAS: glFrontFace gl:glFrontFace @@ -1085,4 +1167,86 @@ ALIAS: glTexImage2DMultisample gl:glTexImage2DMultisample ALIAS: glTexImage3DMultisample gl:glTexImage3DMultisample ALIAS: glGetMultisamplefv gl:glGetMultisamplefv ALIAS: glSampleMaski gl:glSampleMaski - +ALIAS: glBindFragDataLocationIndexed gl:glBindFragDataLocationIndexed +ALIAS: glGetFragDataIndex gl:glGetFragDataIndex +ALIAS: glGenSamplers gl:glGenSamplers +ALIAS: glDeleteSamplers gl:glDeleteSamplers +ALIAS: glIsSampler gl:glIsSampler +ALIAS: glBindSampler gl:glBindSampler +ALIAS: glSamplerParameteri gl:glSamplerParameteri +ALIAS: glSamplerParameteriv gl:glSamplerParameteriv +ALIAS: glSamplerParameterf gl:glSamplerParameterf +ALIAS: glSamplerParameterfv gl:glSamplerParameterfv +ALIAS: glSamplerParameterIiv gl:glSamplerParameterIiv +ALIAS: glSamplerParameterIuiv gl:glSamplerParameterIuiv +ALIAS: glGetSamplerParameteriv gl:glGetSamplerParameteriv +ALIAS: glGetSamplerParameterIiv gl:glGetSamplerParameterIiv +ALIAS: glGetSamplerParameterfv gl:glGetSamplerParameterfv +ALIAS: glGetSamplerParameterIfv gl:glGetSamplerParameterIfv +ALIAS: glQueryCounter gl:glQueryCounter +ALIAS: glGetQueryObjecti64v gl:glGetQueryObjecti64v +ALIAS: glGetQueryObjectui64v gl:glGetQueryObjectui64v +ALIAS: glVertexAttribP1ui gl:glVertexAttribP1ui +ALIAS: glVertexAttribP1uiv gl:glVertexAttribP1uiv +ALIAS: glVertexAttribP2ui gl:glVertexAttribP2ui +ALIAS: glVertexAttribP2uiv gl:glVertexAttribP2uiv +ALIAS: glVertexAttribP3ui gl:glVertexAttribP3ui +ALIAS: glVertexAttribP3uiv gl:glVertexAttribP3uiv +ALIAS: glVertexAttribP4ui gl:glVertexAttribP4ui +ALIAS: glVertexAttribP4uiv gl:glVertexAttribP4uiv +ALIAS: glUniform1d gl:glUniform1d +ALIAS: glUniform2d gl:glUniform2d +ALIAS: glUniform3d gl:glUniform3d +ALIAS: glUniform4d gl:glUniform4d +ALIAS: glUniform1dv gl:glUniform1dv +ALIAS: glUniform2dv gl:glUniform2dv +ALIAS: glUniform3dv gl:glUniform3dv +ALIAS: glUniform4dv gl:glUniform4dv +ALIAS: glUniformMatrix2dv gl:glUniformMatrix2dv +ALIAS: glUniformMatrix3dv gl:glUniformMatrix3dv +ALIAS: glUniformMatrix4dv gl:glUniformMatrix4dv +ALIAS: glUniformMatrix2x3dv gl:glUniformMatrix2x3dv +ALIAS: glUniformMatrix2x4dv gl:glUniformMatrix2x4dv +ALIAS: glUniformMatrix3x2dv gl:glUniformMatrix3x2dv +ALIAS: glUniformMatrix3x4dv gl:glUniformMatrix3x4dv +ALIAS: glUniformMatrix4x2dv gl:glUniformMatrix4x2dv +ALIAS: glUniformMatrix4x3dv gl:glUniformMatrix4x3dv +ALIAS: glGetUniformdv gl:glGetUniformdv +ALIAS: glProgramUniform1dEXT gl:glProgramUniform1dEXT +ALIAS: glProgramUniform2dEXT gl:glProgramUniform2dEXT +ALIAS: glProgramUniform3dEXT gl:glProgramUniform3dEXT +ALIAS: glProgramUniform4dEXT gl:glProgramUniform4dEXT +ALIAS: glProgramUniform1dvEXT gl:glProgramUniform1dvEXT +ALIAS: glProgramUniform2dvEXT gl:glProgramUniform2dvEXT +ALIAS: glProgramUniform3dvEXT gl:glProgramUniform3dvEXT +ALIAS: glProgramUniform4dvEXT gl:glProgramUniform4dvEXT +ALIAS: glProgramUniformMatrix2dvEXT gl:glProgramUniformMatrix2dvEXT +ALIAS: glProgramUniformMatrix3dvEXT gl:glProgramUniformMatrix3dvEXT +ALIAS: glProgramUniformMatrix4dvEXT gl:glProgramUniformMatrix4dvEXT +ALIAS: glProgramUniformMatrix2x3dvEXT gl:glProgramUniformMatrix2x3dvEXT +ALIAS: glProgramUniformMatrix2x4dvEXT gl:glProgramUniformMatrix2x4dvEXT +ALIAS: glProgramUniformMatrix3x2dvEXT gl:glProgramUniformMatrix3x2dvEXT +ALIAS: glProgramUniformMatrix3x4dvEXT gl:glProgramUniformMatrix3x4dvEXT +ALIAS: glProgramUniformMatrix4x2dvEXT gl:glProgramUniformMatrix4x2dvEXT +ALIAS: glProgramUniformMatrix4x3dvEXT gl:glProgramUniformMatrix4x3dvEXT +ALIAS: glGetSubroutineUniformLocation gl:glGetSubroutineUniformLocation +ALIAS: glGetSubroutineIndex gl:glGetSubroutineIndex +ALIAS: glGetActiveSubroutineUniformiv gl:glGetActiveSubroutineUniformiv +ALIAS: glGetActiveSubroutineUniformName gl:glGetActiveSubroutineUniformName +ALIAS: glGetActiveSubroutineName gl:glGetActiveSubroutineName +ALIAS: glUniformSubroutinesuiv gl:glUniformSubroutinesuiv +ALIAS: glGetUniformSubroutineuiv gl:glGetUniformSubroutineuiv +ALIAS: glGetProgramStageiv gl:glGetProgramStageiv +ALIAS: glPatchParameteri gl:glPatchParameteri +ALIAS: glPatchParameterfv gl:glPatchParameterfv +ALIAS: glBindTransformFeedback gl:glBindTransformFeedback +ALIAS: glDeleteTransformFeedbacks gl:glDeleteTransformFeedbacks +ALIAS: glGenTransformFeedbacks gl:glGenTransformFeedbacks +ALIAS: glIsTransformFeedback gl:glIsTransformFeedback +ALIAS: glPauseTransformFeedback gl:glPauseTransformFeedback +ALIAS: glResumeTransformFeedback gl:glResumeTransformFeedback +ALIAS: glDrawTransformFeedback gl:glDrawTransformFeedback +ALIAS: glDrawTransformFeedbackStream gl:glDrawTransformFeedbackStream +ALIAS: glBeginQueryIndexed gl:glBeginQueryIndexed +ALIAS: glEndQueryIndexed gl:glEndQueryIndexed +ALIAS: glGetQueryIndexediv gl:glGetQueryIndexediv From cd10fed0af8892d00e0b34642b67e27b6b6c09cd Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Tue, 16 Mar 2010 23:59:35 -0400 Subject: [PATCH 414/713] Fixing bit sets help --- basis/bit-sets/bit-sets-docs.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/bit-sets/bit-sets-docs.factor b/basis/bit-sets/bit-sets-docs.factor index a2792d3213..bb4dc75cac 100644 --- a/basis/bit-sets/bit-sets-docs.factor +++ b/basis/bit-sets/bit-sets-docs.factor @@ -2,7 +2,7 @@ USING: help.markup help.syntax sequences math ; IN: bit-sets ARTICLE: "bit-sets" "Bit sets" -"The " { $vocab-link "bit-sets" } " vocabulary implements bit-array-backed sets. Bitsets are efficient for implementing relatively dense sets whose members are in a contiguous range of integers starting from 0. One bit is required for each integer in this range in the underlying representation." +"The " { $vocab-link "bit-sets" } " vocabulary implements bit-array-backed sets. Bitsets are efficient for implementing relatively dense sets whose members are in a contiguous range of integers starting from 0. One bit is required for each integer in this range in the underlying representation." $nl "Bit sets are of the class" { $subsection bit-set } "They can be instantiated with the word" @@ -11,7 +11,7 @@ ARTICLE: "bit-sets" "Bit sets" ABOUT: "bit-sets" HELP: bit-set -{ $class-description "The class of bit-array-based sets. These implement the " { $link "sets" } "." } ; +{ $class-description "The class of bit-array-based " { $link "sets" } "." } ; HELP: { $values { "capacity" integer } { "bit-set" bit-set } } From 39df2c373fbf8acf5bc779a27280c2813b0c44c9 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Wed, 17 Mar 2010 00:22:48 -0400 Subject: [PATCH 415/713] Fixing vocab ambiguities in linux and windows-specific vocabs --- basis/io/monitors/linux/linux.factor | 1 + basis/ui/backend/windows/windows.factor | 1 + 2 files changed, 2 insertions(+) diff --git a/basis/io/monitors/linux/linux.factor b/basis/io/monitors/linux/linux.factor index 63484f467f..31442b7f0b 100644 --- a/basis/io/monitors/linux/linux.factor +++ b/basis/io/monitors/linux/linux.factor @@ -6,6 +6,7 @@ io.backend.unix io.encodings.utf8 unix.linux.inotify assocs namespaces make threads continuations init math math.bitwise sets alien alien.strings alien.c-types vocabs.loader accessors system hashtables destructors unix classes.struct ; +FROM: namespaces => set ; IN: io.monitors.linux SYMBOL: watches diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index 0bf2e88468..8a4ae9853f 100644 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -14,6 +14,7 @@ math.order calendar ascii sets io.encodings.utf16n windows.errors literals ui.pixel-formats ui.pixel-formats.private memoize classes colors specialized-arrays classes.struct alien.data ; +FROM: namespaces => set ; SPECIALIZED-ARRAY: POINT IN: ui.backend.windows From 01e5aadcd055b18c06d0bd6ec7b44d3b85402ecc Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 17 Mar 2010 17:39:12 +1300 Subject: [PATCH 416/713] unix.types.freebsd: fix time_t typedef --- basis/unix/types/freebsd/freebsd.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/unix/types/freebsd/freebsd.factor b/basis/unix/types/freebsd/freebsd.factor index 215e344231..4973df989d 100644 --- a/basis/unix/types/freebsd/freebsd.factor +++ b/basis/unix/types/freebsd/freebsd.factor @@ -21,6 +21,6 @@ TYPEDEF: __uint32_t blksize_t TYPEDEF: __uint32_t fflags_t TYPEDEF: long ssize_t TYPEDEF: int pid_t -TYPEDEF: int time_t +TYPEDEF: long time_t -ALIAS: +ALIAS: From cdee2439d8163c663346894b28d68b976b1b7207 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 17 Mar 2010 19:13:25 +1300 Subject: [PATCH 417/713] grouping: minor cleanup --- basis/grouping/authors.txt | 1 + basis/grouping/grouping.factor | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/basis/grouping/authors.txt b/basis/grouping/authors.txt index 1901f27a24..580f882c8d 100644 --- a/basis/grouping/authors.txt +++ b/basis/grouping/authors.txt @@ -1 +1,2 @@ Slava Pestov +Joe Groff diff --git a/basis/grouping/grouping.factor b/basis/grouping/grouping.factor index 304fd50fcc..1a7e267c90 100644 --- a/basis/grouping/grouping.factor +++ b/basis/grouping/grouping.factor @@ -1,8 +1,7 @@ -! Copyright (C) 2005, 2010 Slava Pestov. +! Copyright (C) 2005, 2010 Slava Pestov, Joe Groff. ! See http://factorcode.org/license.txt for BSD license. USING: kernel math math.order strings arrays vectors sequences -sequences.private accessors fry combinators.short-circuit -combinators ; +sequences.private accessors fry combinators ; IN: grouping = [ - ] [ drop ] if ; inline : check-circular-clumps ( seq n -- seq n ) - 2dup { [ nip 0 <= ] [ swap length > ] } 2|| - [ "Invalid clump size" throw ] when ; inline + 2dup 1 - swap bounds-check 2drop ; inline PRIVATE> @@ -115,15 +113,18 @@ INSTANCE: sliced-clumps abstract-clumps : all-eq? ( seq -- ? ) [ eq? ] monotonic? ; -TUPLE: circular-slice - { from read-only } - { to read-only } - { seq read-only } ; +TUPLE: circular-slice { from read-only } { to read-only } { seq read-only } ; + INSTANCE: circular-slice virtual-sequence + M: circular-slice equal? over slice? [ sequence= ] [ 2drop f ] if ; + M: circular-slice hashcode* [ sequence-hashcode ] recursive-hashcode ; + M: circular-slice length [ to>> ] [ from>> ] bi - ; inline + M: circular-slice virtual-exemplar seq>> ; inline + M: circular-slice virtual@ [ from>> + ] [ seq>> ] bi [ length slice-mod ] keep ; inline @@ -155,4 +156,3 @@ M: circular-clumps nth : circular-clump ( seq n -- array ) { } like ; inline - From 6ff0393e2f7a4d701b9d7fdcad7335b7e6dcc6e4 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 17 Mar 2010 19:19:43 +1300 Subject: [PATCH 418/713] debugger: Untangle some dodgy dependencies that were loading locals before prettyprint, resulting in locals.prettyprint not being loaded --- basis/alien/debugger/authors.txt | 1 + basis/alien/debugger/debugger.factor | 9 +++++++++ basis/alien/parser/authors.txt | 3 +++ basis/alien/parser/parser.factor | 12 ++++++------ basis/bootstrap/compiler/compiler.factor | 1 + basis/debugger/debugger.factor | 21 +++++++++------------ 6 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 basis/alien/debugger/authors.txt create mode 100644 basis/alien/debugger/debugger.factor create mode 100644 basis/alien/parser/authors.txt diff --git a/basis/alien/debugger/authors.txt b/basis/alien/debugger/authors.txt new file mode 100644 index 0000000000..f13c9c1e77 --- /dev/null +++ b/basis/alien/debugger/authors.txt @@ -0,0 +1 @@ +Joe Groff diff --git a/basis/alien/debugger/debugger.factor b/basis/alien/debugger/debugger.factor new file mode 100644 index 0000000000..4ac3174bb7 --- /dev/null +++ b/basis/alien/debugger/debugger.factor @@ -0,0 +1,9 @@ +! Copyright (C) 2010 Joe Groff. +! See http://factorcode.org/license.txt for BSD license. +USING: ; +IN: alien.debugger + +M: no-c-type summary name>> unparse "“" "” is not a C type" surround ; + +M: *-in-c-type-name summary + name>> "Cannot define a C type “" "” that ends with an asterisk (*)" surround ; diff --git a/basis/alien/parser/authors.txt b/basis/alien/parser/authors.txt new file mode 100644 index 0000000000..c299e0ac31 --- /dev/null +++ b/basis/alien/parser/authors.txt @@ -0,0 +1,3 @@ +Slava Pestov +Doug Coleman +Joe Groff diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index c9ec2c3889..4c5f5dbd6a 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -1,10 +1,10 @@ -! Copyright (C) 2008, 2010 Slava Pestov, Doug Coleman. +! Copyright (C) 2008, 2010 Slava Pestov, Doug Coleman, Joe Groff. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien alien.c-types alien.parser -alien.libraries arrays assocs classes combinators -combinators.short-circuit compiler.units effects grouping -kernel parser sequences splitting words fry locals lexer -namespaces summary math vocabs.parser ; +USING: accessors alien alien.c-types alien.libraries arrays +assocs classes combinators combinators.short-circuit +compiler.units effects grouping kernel parser sequences +splitting words fry locals lexer namespaces summary math +vocabs.parser ; IN: alien.parser : parse-c-type-name ( name -- word ) diff --git a/basis/bootstrap/compiler/compiler.factor b/basis/bootstrap/compiler/compiler.factor index edb0bdf2ae..0bdb2494f8 100644 --- a/basis/bootstrap/compiler/compiler.factor +++ b/basis/bootstrap/compiler/compiler.factor @@ -23,6 +23,7 @@ IN: bootstrap.compiler "prettyprint" vocab [ "stack-checker.errors.prettyprint" require "alien.prettyprint" require + "alien.debugger" require ] when "cpu." cpu name>> append require diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index b7ecc5acec..c34a50190f 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -1,15 +1,15 @@ ! Copyright (C) 2004, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: slots alien.c-types alien.parser arrays definitions generic -hashtables summary io kernel math namespaces make prettyprint -prettyprint.config sequences assocs sequences.private strings -io.styles io.pathnames vectors words system splitting math.parser +USING: slots arrays definitions generic hashtables summary io +kernel math namespaces make prettyprint prettyprint.config +sequences assocs sequences.private strings io.styles +io.pathnames vectors words system splitting math.parser classes.mixin classes.tuple continuations continuations.private combinators generic.math classes.builtin classes compiler.units generic.standard generic.single vocabs init kernel.private -io.encodings accessors math.order destructors source-files parser -classes.tuple.parser effects.parser lexer generic.parser strings.parser -vocabs.loader vocabs.parser source-files.errors ; +io.encodings accessors math.order destructors source-files +parser classes.tuple.parser effects.parser lexer generic.parser +strings.parser vocabs.loader vocabs.parser source-files.errors ; IN: debugger GENERIC: error-help ( error -- topic ) @@ -328,8 +328,10 @@ M: lexer-error error-help M: bad-effect summary drop "Bad stack effect declaration" ; + M: invalid-row-variable summary drop "Stack effect row variables can only occur as the first input or output" ; + M: row-variable-can't-have-type summary drop "Stack effect row variables cannot have a declared type" ; @@ -347,11 +349,6 @@ M: wrong-values summary drop "Quotation's stack effect does not match call site" M: stack-effect-omits-dashes summary drop "Stack effect must contain “--”" ; -M: no-c-type summary name>> unparse "“" "” is not a C type" surround ; - -M: *-in-c-type-name summary - name>> "Cannot define a C type “" "” that ends with an asterisk (*)" surround ; - { { [ os windows? ] [ "debugger.windows" require ] } { [ os unix? ] [ "debugger.unix" require ] } From fb06bbcae72af1b23f0ac634286cd74b84a850a9 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 17 Mar 2010 19:20:28 +1300 Subject: [PATCH 419/713] stack-checker.errors.prettyprint: give it some smart quotes lovin' --- .../errors/prettyprint/prettyprint.factor | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor index 90d12c6235..3d4480a4aa 100644 --- a/basis/stack-checker/errors/prettyprint/prettyprint.factor +++ b/basis/stack-checker/errors/prettyprint/prettyprint.factor @@ -27,23 +27,23 @@ M: recursive-quotation-error summary M: undeclared-recursion-error summary word>> name>> - "The inline recursive word " " must be declared recursive" surround ; + "The inline recursive word “" "” must be declared recursive" surround ; M: diverging-recursion-error summary word>> name>> - "The recursive word " " digs arbitrarily deep into the stack" surround ; + "The recursive word “" "” digs arbitrarily deep into the stack" surround ; M: unbalanced-recursion-error summary word>> name>> - "The recursive word " " leaves with the stack having the wrong height" surround ; + "The recursive word “" "” leaves with the stack having the wrong height" surround ; M: inconsistent-recursive-call-error summary word>> name>> - "The recursive word " - " calls itself with a different set of quotation parameters than were input" surround ; + "The recursive word “" + "” calls itself with a different set of quotation parameters than were input" surround ; M: transform-expansion-error summary - word>> name>> "Macro expansion of " " threw an error" surround ; + word>> name>> "Macro expansion of “" "” threw an error" surround ; M: transform-expansion-error error. [ summary print ] @@ -52,14 +52,13 @@ M: transform-expansion-error error. tri ; M: do-not-compile summary - word>> name>> "Cannot compile call to " prepend ; + word>> name>> "Cannot compile call to “" "”" surround ; M: unbalanced-branches-error summary word>> name>> - "The input quotations to " " don't match their expected effects" surround ; + "The input quotations to “" "” don't match their expected effects" surround ; M: unbalanced-branches-error error. dup summary print [ quots>> ] [ declareds>> ] [ actuals>> ] tri 3array flip { "Input" "Expected" "Got" } prefix simple-table. ; - From 75d0f51b305d4df0d03475267616927741e5c861 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 17 Mar 2010 19:35:12 +1300 Subject: [PATCH 420/713] alien.debugger: fix USING: form --- basis/alien/debugger/debugger.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basis/alien/debugger/debugger.factor b/basis/alien/debugger/debugger.factor index 4ac3174bb7..a04697155e 100644 --- a/basis/alien/debugger/debugger.factor +++ b/basis/alien/debugger/debugger.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2010 Joe Groff. ! See http://factorcode.org/license.txt for BSD license. -USING: ; +USING: alien.c-types alien.parser summary sequences accessors +prettyprint ; IN: alien.debugger M: no-c-type summary name>> unparse "“" "” is not a C type" surround ; From 248730d39f9859ab0888528d4f49328648641923 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Wed, 17 Mar 2010 20:12:10 -0400 Subject: [PATCH 421/713] Cleaning up compiler.cfg.ssa.construction --- basis/compiler/cfg/ssa/construction/construction.factor | 2 +- basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/basis/compiler/cfg/ssa/construction/construction.factor b/basis/compiler/cfg/ssa/construction/construction.factor index 7cd85e5fbe..03c85c1f5e 100644 --- a/basis/compiler/cfg/ssa/construction/construction.factor +++ b/basis/compiler/cfg/ssa/construction/construction.factor @@ -57,7 +57,7 @@ SYMBOL: inserting-phi-nodes ] [ 2drop ] if ; : compute-phi-nodes-for ( vreg bbs -- ) - keys [ insert-phi-node-later ] with merge-set-each ; + keys merge-set [ insert-phi-node-later ] with each ; : compute-phi-nodes ( -- ) H{ } clone inserting-phi-nodes set diff --git a/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor b/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor index 51eb3c8a98..4cdc290c41 100644 --- a/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor +++ b/basis/compiler/cfg/ssa/construction/tdmsc/tdmsc.factor @@ -88,7 +88,6 @@ PRIVATE> : compute-merge-sets ( cfg -- ) needs-dominance - HS{ } clone visited set [ compute-levels ] [ init-merge-sets ] [ compute-merge-set-loop ] @@ -96,6 +95,3 @@ PRIVATE> : merge-set ( bbs -- bbs' ) (merge-set) [ members ] dip nths ; - -: merge-set-each ( bbs quot: ( bb -- ) -- ) - [ merge-set ] dip each ; inline From 67912db5f1041a254b1a299a7366b8f3dba03b93 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Wed, 17 Mar 2010 20:12:25 -0400 Subject: [PATCH 422/713] Making faster --- core/hash-sets/hash-sets.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/hash-sets/hash-sets.factor b/core/hash-sets/hash-sets.factor index 248b4af4c6..b4bf9a1aef 100644 --- a/core/hash-sets/hash-sets.factor +++ b/core/hash-sets/hash-sets.factor @@ -9,7 +9,7 @@ IN: hash-sets TUPLE: hash-set { table hashtable read-only } ; : ( members -- hash-set ) - [ dup ] H{ } map>assoc hash-set boa ; + H{ } clone [ [ dupd set-at ] curry each ] keep hash-set boa ; INSTANCE: hash-set set M: hash-set in? table>> key? ; inline From fab9a925c3346a1bbefc0051ded565a9b51c9efc Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Wed, 17 Mar 2010 21:38:06 -0400 Subject: [PATCH 423/713] Reducing bit-sets performance regression somewhat --- basis/bit-sets/bit-sets.factor | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/basis/bit-sets/bit-sets.factor b/basis/bit-sets/bit-sets.factor index 9d3d09ec1b..aa74c2b9fb 100644 --- a/basis/bit-sets/bit-sets.factor +++ b/basis/bit-sets/bit-sets.factor @@ -30,6 +30,11 @@ M: bit-set delete ! of the same length. > ] [ @@ -62,13 +67,20 @@ M: bit-set subset? M: bit-set members [ table>> length iota ] keep [ in? ] curry filter ; -M: bit-set set-like +> ] bi@ length = ] [ f ] if + over bit-set? [ 2dup [ table>> length ] bi@ = ] [ f ] if [ drop ] [ [ members ] dip table>> length [ [ adjoin ] curry each ] keep ] if ; +PRIVATE> + +M: bit-set set-like + bit-set-like check-bit-set ; inline + M: bit-set clone table>> clone bit-set boa ; From 043578ca1de11634502ba77cc9038535a000ca8c Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Thu, 18 Mar 2010 00:00:32 -0400 Subject: [PATCH 424/713] require-if loads vocabs conditionally, now or later --- core/vocabs/loader/loader-tests.factor | 18 ++++++++++++++++++ core/vocabs/loader/loader.factor | 16 +++++++++++++++- core/vocabs/loader/test/m/m.factor | 4 ++++ core/vocabs/loader/test/n/n.factor | 1 + core/vocabs/loader/test/o/o.factor | 1 + core/vocabs/vocabs.factor | 9 ++++++--- 6 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 core/vocabs/loader/test/m/m.factor create mode 100644 core/vocabs/loader/test/n/n.factor create mode 100644 core/vocabs/loader/test/o/o.factor diff --git a/core/vocabs/loader/loader-tests.factor b/core/vocabs/loader/loader-tests.factor index 09f28541e0..89afb50af7 100644 --- a/core/vocabs/loader/loader-tests.factor +++ b/core/vocabs/loader/loader-tests.factor @@ -170,3 +170,21 @@ forget-junk ] with-compilation-unit [ ] [ [ "vocabs.loader.test.j" require ] [ drop :1 ] recover ] unit-test + +[ ] [ "vocabs.loader.test.m" require ] unit-test +[ f ] [ "vocabs.loader.test.n" vocab ] unit-test +[ ] [ "vocabs.loader.test.o" require ] unit-test +[ t ] [ "vocabs.loader.test.n" vocab >boolean ] unit-test + +[ + "mno" [ "vocabs.loader.test." swap suffix forget-vocab ] each +] with-compilation-unit + +[ ] [ "vocabs.loader.test.o" require ] unit-test +[ f ] [ "vocabs.loader.test.n" vocab ] unit-test +[ ] [ "vocabs.loader.test.m" require ] unit-test +[ t ] [ "vocabs.loader.test.n" vocab >boolean ] unit-test + +[ + "mno" [ "vocabs.loader.test." swap suffix forget-vocab ] each +] with-compilation-unit diff --git a/core/vocabs/loader/loader.factor b/core/vocabs/loader/loader.factor index c8cf77b795..2acefe4cef 100644 --- a/core/vocabs/loader/loader.factor +++ b/core/vocabs/loader/loader.factor @@ -62,8 +62,15 @@ SYMBOL: check-vocab-hook check-vocab-hook [ [ drop ] ] initialize +DEFER: require + >source-loaded? ] dip [ % ] [ call( -- ) ] if-bootstrapping - +done+ >>source-loaded? drop + +done+ >>source-loaded? + vocab-name load-conditional-requires ] [ ] [ f >>source-loaded? ] cleanup ; : load-docs ( vocab -- ) @@ -88,6 +96,12 @@ PRIVATE> : require ( vocab -- ) load-vocab drop ; +: require-if ( if then -- ) + over vocab + [ nip require ] + [ swap conditional-requires get [ swap suffix ] change-at ] + if ; + : reload ( name -- ) dup vocab [ [ load-source ] [ load-docs ] bi ] diff --git a/core/vocabs/loader/test/m/m.factor b/core/vocabs/loader/test/m/m.factor new file mode 100644 index 0000000000..e5106d86b7 --- /dev/null +++ b/core/vocabs/loader/test/m/m.factor @@ -0,0 +1,4 @@ +USE: vocabs.loader +IN: vocabs.loader.test.m + +"vocabs.loader.test.o" "vocabs.loader.test.n" require-if diff --git a/core/vocabs/loader/test/n/n.factor b/core/vocabs/loader/test/n/n.factor new file mode 100644 index 0000000000..b3cedb3006 --- /dev/null +++ b/core/vocabs/loader/test/n/n.factor @@ -0,0 +1 @@ +IN: vocabs.loader.test.n diff --git a/core/vocabs/loader/test/o/o.factor b/core/vocabs/loader/test/o/o.factor new file mode 100644 index 0000000000..cc8051ab38 --- /dev/null +++ b/core/vocabs/loader/test/o/o.factor @@ -0,0 +1 @@ +IN: vocabs.loader.test.o diff --git a/core/vocabs/vocabs.factor b/core/vocabs/vocabs.factor index 239b88a2e8..e48d6c3031 100644 --- a/core/vocabs/vocabs.factor +++ b/core/vocabs/vocabs.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2009 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs strings kernel sorting namespaces -sequences definitions ; +sequences definitions sets ; IN: vocabs SYMBOL: dictionary @@ -83,6 +83,9 @@ ERROR: bad-vocab-name name ; : check-vocab-name ( name -- name ) dup string? [ bad-vocab-name ] unless ; +SYMBOL: conditional-requires +conditional-requires [ H{ } clone ] initialize + : create-vocab ( name -- vocab ) check-vocab-name dictionary get [ ] cache @@ -118,8 +121,8 @@ M: vocab-spec >vocab-link ; M: string >vocab-link dup vocab [ ] [ ] ?if ; : forget-vocab ( vocab -- ) - dup words forget-all - vocab-name dictionary get delete-at + [ words forget-all ] + [ vocab-name dictionary get delete-at ] bi notify-vocab-observers ; M: vocab-spec forget* forget-vocab ; From 9e602d213f95f42914094db099d6e102d6d4092b Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Thu, 18 Mar 2010 00:24:41 -0400 Subject: [PATCH 425/713] Renaming require-if to require-when --- core/vocabs/loader/loader.factor | 2 +- core/vocabs/loader/test/m/m.factor | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/vocabs/loader/loader.factor b/core/vocabs/loader/loader.factor index 2acefe4cef..59fe06e6fd 100644 --- a/core/vocabs/loader/loader.factor +++ b/core/vocabs/loader/loader.factor @@ -96,7 +96,7 @@ PRIVATE> : require ( vocab -- ) load-vocab drop ; -: require-if ( if then -- ) +: require-when ( if then -- ) over vocab [ nip require ] [ swap conditional-requires get [ swap suffix ] change-at ] diff --git a/core/vocabs/loader/test/m/m.factor b/core/vocabs/loader/test/m/m.factor index e5106d86b7..d6d3bd8a7a 100644 --- a/core/vocabs/loader/test/m/m.factor +++ b/core/vocabs/loader/test/m/m.factor @@ -1,4 +1,4 @@ USE: vocabs.loader IN: vocabs.loader.test.m -"vocabs.loader.test.o" "vocabs.loader.test.n" require-if +"vocabs.loader.test.o" "vocabs.loader.test.n" require-when From aa4a9f8288d3191e2770590a4a1ae771e42b37b4 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Mar 2010 17:25:56 +1300 Subject: [PATCH 426/713] mason.test: fix outdated boot image check --- extra/mason/test/test.factor | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/extra/mason/test/test.factor b/extra/mason/test/test.factor index fba3ed58c4..e99f76c8c4 100644 --- a/extra/mason/test/test.factor +++ b/extra/mason/test/test.factor @@ -58,19 +58,21 @@ M: method word-vocabulary "method-generic" word-prop word-vocabulary ; compiler-error-messages-file do-step ; -: check-boot-image ( -- ) - "" to-refresh drop 2dup [ empty? not ] either? - [ - "Boot image is out of date. Changed vocabs:" print - members [ print ] each - flush - 1 exit - ] [ 2drop ] if ; +: outdated-core-vocabs ( -- modified-sources modified-docs any? ) + "" to-refresh drop 2dup [ empty? not ] either? ; + +: outdated-boot-image. ( modified-sources modified-docs -- ) + "Boot image is out of date. Changed vocabs:" print + union [ print ] each + flush ; + +: check-boot-image ( -- ? ) + outdated-core-vocabs [ outdated-boot-image. t ] [ 2drop f ] if ; : do-all ( -- ) ".." [ bootstrap-time get boot-time-file to-file - check-boot-image + check-boot-image [ 1 exit ] when [ do-load ] benchmark load-time-file to-file [ generate-help ] benchmark html-help-time-file to-file [ do-tests ] benchmark test-time-file to-file From eb060443dbfcf1dd3fc523cbdf1e306021464dbd Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Thu, 18 Mar 2010 01:13:37 -0400 Subject: [PATCH 427/713] Updating code to use require-when rather than vocab [ require ] when --- basis/bootstrap/compiler/compiler.factor | 10 +++++----- basis/bootstrap/threads/threads.factor | 8 +++----- basis/classes/struct/struct.factor | 2 +- basis/http/client/client.factor | 2 +- basis/locals/locals.factor | 6 ++---- basis/math/rectangles/rectangles.factor | 4 ++-- basis/peg/peg.factor | 4 +--- basis/regexp/regexp.factor | 4 +--- basis/specialized-arrays/specialized-arrays.factor | 8 ++------ basis/typed/typed.factor | 2 +- basis/ui/gadgets/gadgets.factor | 4 ++-- basis/unix/unix.factor | 4 +--- basis/urls/urls.factor | 6 ++---- basis/windows/com/syntax/syntax.factor | 6 ++---- extra/game/loop/loop.factor | 2 +- extra/gpu/shaders/shaders.factor | 2 +- 16 files changed, 28 insertions(+), 46 deletions(-) diff --git a/basis/bootstrap/compiler/compiler.factor b/basis/bootstrap/compiler/compiler.factor index 0bdb2494f8..393e4eab27 100644 --- a/basis/bootstrap/compiler/compiler.factor +++ b/basis/bootstrap/compiler/compiler.factor @@ -20,11 +20,11 @@ IN: bootstrap.compiler "alien.remote-control" require ] unless -"prettyprint" vocab [ - "stack-checker.errors.prettyprint" require - "alien.prettyprint" require - "alien.debugger" require -] when +{ + "stack-checker.errors.prettyprint" + "alien.prettyprint" + "alien.debugger" +} [ "prettyprint" swap require-when ] each "cpu." cpu name>> append require diff --git a/basis/bootstrap/threads/threads.factor b/basis/bootstrap/threads/threads.factor index 24cbba6af8..3a8fe98cf4 100644 --- a/basis/bootstrap/threads/threads.factor +++ b/basis/bootstrap/threads/threads.factor @@ -1,11 +1,9 @@ ! Copyright (C) 2008, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: vocabs vocabs.loader kernel io.thread threads +USING: vocabs.loader kernel io.thread threads compiler.utilities namespaces ; IN: bootstrap.threads -"debugger" vocab [ - "debugger.threads" require -] when +"debugger" "debugger.threads" require-when -[ yield ] yield-hook set-global \ No newline at end of file +[ yield ] yield-hook set-global diff --git a/basis/classes/struct/struct.factor b/basis/classes/struct/struct.factor index 79dea73d8c..ffde233748 100644 --- a/basis/classes/struct/struct.factor +++ b/basis/classes/struct/struct.factor @@ -404,4 +404,4 @@ FUNCTOR-SYNTAX: STRUCT: USING: vocabs vocabs.loader ; -"prettyprint" vocab [ "classes.struct.prettyprint" require ] when +"prettyprint" "classes.struct.prettyprint" require-when diff --git a/basis/http/client/client.factor b/basis/http/client/client.factor index 2ce0ec9dfc..1221ee39f3 100644 --- a/basis/http/client/client.factor +++ b/basis/http/client/client.factor @@ -196,4 +196,4 @@ ERROR: download-failed response ; USING: vocabs vocabs.loader ; -"debugger" vocab [ "http.client.debugger" require ] when +"debugger" "http.client.debugger" require-when diff --git a/basis/locals/locals.factor b/basis/locals/locals.factor index 8e940bfdd8..7d67881c47 100644 --- a/basis/locals/locals.factor +++ b/basis/locals/locals.factor @@ -26,7 +26,5 @@ SYNTAX: MEMO:: (::) define-memoized ; "locals.fry" } [ require ] each -"prettyprint" vocab [ - "locals.definitions" require - "locals.prettyprint" require -] when +"prettyprint" "locals.definitions" require-when +"prettyprint" "locals.prettyprint" require-when diff --git a/basis/math/rectangles/rectangles.factor b/basis/math/rectangles/rectangles.factor index db3794cbb0..78ac5457bc 100644 --- a/basis/math/rectangles/rectangles.factor +++ b/basis/math/rectangles/rectangles.factor @@ -62,6 +62,6 @@ M: rect contains-point? [ [ dim>> ] dip (>>dim) ] 2bi ; inline -USING: vocabs vocabs.loader ; +USE: vocabs.loader -"prettyprint" vocab [ "math.rectangles.prettyprint" require ] when +"prettyprint" "math.rectangles.prettyprint" require-when diff --git a/basis/peg/peg.factor b/basis/peg/peg.factor index cc480c30b2..ca7d28bb97 100644 --- a/basis/peg/peg.factor +++ b/basis/peg/peg.factor @@ -630,6 +630,4 @@ SYNTAX: PEG: USING: vocabs vocabs.loader ; -"debugger" vocab [ - "peg.debugger" require -] when +"debugger" "peg.debugger" require-when diff --git a/basis/regexp/regexp.factor b/basis/regexp/regexp.factor index e5ac1df151..eea0a26ea5 100644 --- a/basis/regexp/regexp.factor +++ b/basis/regexp/regexp.factor @@ -218,6 +218,4 @@ SYNTAX: R| CHAR: | parsing-regexp ; USING: vocabs vocabs.loader ; -"prettyprint" vocab [ - "regexp.prettyprint" require -] when +"prettyprint" "regexp.prettyprint" require-when diff --git a/basis/specialized-arrays/specialized-arrays.factor b/basis/specialized-arrays/specialized-arrays.factor index 11b050d5fc..c82ebd78c8 100644 --- a/basis/specialized-arrays/specialized-arrays.factor +++ b/basis/specialized-arrays/specialized-arrays.factor @@ -173,10 +173,6 @@ SYNTAX: SPECIALIZED-ARRAYS: SYNTAX: SPECIALIZED-ARRAY: scan-c-type define-array-vocab use-vocab ; -"prettyprint" vocab [ - "specialized-arrays.prettyprint" require -] when +"prettyprint" "specialized-arrays.prettyprint" require-when -"mirrors" vocab [ - "specialized-arrays.mirrors" require -] when +"mirrors" "specialized-arrays.mirrors" require-when diff --git a/basis/typed/typed.factor b/basis/typed/typed.factor index 6ab4e0334d..df46303b79 100644 --- a/basis/typed/typed.factor +++ b/basis/typed/typed.factor @@ -166,4 +166,4 @@ SYNTAX: TYPED:: USING: vocabs vocabs.loader ; -"prettyprint" vocab [ "typed.prettyprint" require ] when +"prettyprint" "typed.prettyprint" require-when diff --git a/basis/ui/gadgets/gadgets.factor b/basis/ui/gadgets/gadgets.factor index 7e47bf627b..dca340cd3b 100644 --- a/basis/ui/gadgets/gadgets.factor +++ b/basis/ui/gadgets/gadgets.factor @@ -393,6 +393,6 @@ M: f request-focus-on 2drop ; : focus-path ( gadget -- seq ) [ focus>> ] follow ; -USING: vocabs vocabs.loader ; +USE: vocabs.loader -"prettyprint" vocab [ "ui.gadgets.prettyprint" require ] when +"prettyprint" "ui.gadgets.prettyprint" require-when diff --git a/basis/unix/unix.factor b/basis/unix/unix.factor index 4e77a41713..e747e48433 100644 --- a/basis/unix/unix.factor +++ b/basis/unix/unix.factor @@ -74,8 +74,6 @@ M: unix open-file [ open ] unix-system-call ; << -"debugger" vocab [ - "unix.debugger" require -] when +"debugger" "unix.debugger" require-when >> diff --git a/basis/urls/urls.factor b/basis/urls/urls.factor index bf4a9bb76c..cd470a451a 100644 --- a/basis/urls/urls.factor +++ b/basis/urls/urls.factor @@ -183,8 +183,6 @@ PRIVATE> ! Literal syntax SYNTAX: URL" lexer get skip-blank parse-string >url suffix! ; -USING: vocabs vocabs.loader ; +USE: vocabs.loader -"prettyprint" vocab [ - "urls.prettyprint" require -] when +"prettyprint" "urls.prettyprint" require-when diff --git a/basis/windows/com/syntax/syntax.factor b/basis/windows/com/syntax/syntax.factor index 49c9272d9b..78a3c0e6d2 100644 --- a/basis/windows/com/syntax/syntax.factor +++ b/basis/windows/com/syntax/syntax.factor @@ -94,8 +94,6 @@ SYNTAX: COM-INTERFACE: SYNTAX: GUID: scan string>guid suffix! ; -USING: vocabs vocabs.loader ; +USE: vocabs.loader -"prettyprint" vocab [ - "windows.com.prettyprint" require -] when +"prettyprint" "windows.com.prettyprint" require-when diff --git a/extra/game/loop/loop.factor b/extra/game/loop/loop.factor index 00fe14c3cd..ffe5acd879 100644 --- a/extra/game/loop/loop.factor +++ b/extra/game/loop/loop.factor @@ -114,4 +114,4 @@ M: game-loop dispose USING: vocabs vocabs.loader ; -"prettyprint" vocab [ "game.loop.prettyprint" require ] when +"prettyprint" "game.loop.prettyprint" require-when diff --git a/extra/gpu/shaders/shaders.factor b/extra/gpu/shaders/shaders.factor index 025acba896..7c03e00851 100755 --- a/extra/gpu/shaders/shaders.factor +++ b/extra/gpu/shaders/shaders.factor @@ -575,4 +575,4 @@ M: program-instance dispose [ world>> ] [ program>> instances>> ] [ ] tri ?delete-at reset-memos ; -"prettyprint" vocab [ "gpu.shaders.prettyprint" require ] when +"prettyprint" "gpu.shaders.prettyprint" require-when From 4af88ff9ffb449cad5017f9e4a30148c54a9f7d8 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Thu, 18 Mar 2010 01:39:30 -0400 Subject: [PATCH 428/713] Making more vocabs use require-when --- basis/bootstrap/handbook/handbook.factor | 2 +- basis/bootstrap/ui/tools/tools.factor | 4 +--- basis/math/vectors/simd/simd.factor | 4 +--- basis/mirrors/mirrors.factor | 4 ---- basis/x11/x11.factor | 2 +- 5 files changed, 4 insertions(+), 12 deletions(-) diff --git a/basis/bootstrap/handbook/handbook.factor b/basis/bootstrap/handbook/handbook.factor index 51aa9eefaf..11f7349b79 100644 --- a/basis/bootstrap/handbook/handbook.factor +++ b/basis/bootstrap/handbook/handbook.factor @@ -1,4 +1,4 @@ USING: vocabs.loader vocabs kernel ; IN: bootstrap.handbook -"bootstrap.help" vocab [ "help.handbook" require ] when +"bootstrap.help" "help.handbook" require-when diff --git a/basis/bootstrap/ui/tools/tools.factor b/basis/bootstrap/ui/tools/tools.factor index 5cf05aef91..7db69ce9c1 100644 --- a/basis/bootstrap/ui/tools/tools.factor +++ b/basis/bootstrap/ui/tools/tools.factor @@ -4,9 +4,7 @@ USING: kernel vocabs vocabs.loader sequences system ; [ "bootstrap." prepend vocab ] all? [ "ui.tools" require - "ui.backend.cocoa" vocab [ - "ui.backend.cocoa.tools" require - ] when + "ui.backend.cocoa" "ui.backend.cocoa.tools" require-when "ui.tools.walker" require ] when diff --git a/basis/math/vectors/simd/simd.factor b/basis/math/vectors/simd/simd.factor index 8d804247d3..65d6e113bf 100644 --- a/basis/math/vectors/simd/simd.factor +++ b/basis/math/vectors/simd/simd.factor @@ -339,6 +339,4 @@ M: short-8 v*hs+ M: int-4 v*hs+ int-4-rep [ (simd-v*hs+) ] [ call-next-method ] vv->v-op longlong-2-cast ; inline -"mirrors" vocab [ - "math.vectors.simd.mirrors" require -] when +"mirrors" "math.vectors.simd.mirrors" require-when diff --git a/basis/mirrors/mirrors.factor b/basis/mirrors/mirrors.factor index 65978f0b46..f12d34e170 100644 --- a/basis/mirrors/mirrors.factor +++ b/basis/mirrors/mirrors.factor @@ -59,7 +59,3 @@ M: hashtable make-mirror ; M: integer make-mirror drop f ; M: enumerated-sequence make-mirror ; M: object make-mirror ; - -"specialized-arrays" vocab [ - "specialized-arrays.mirrors" require -] when diff --git a/basis/x11/x11.factor b/basis/x11/x11.factor index 09328c6f6e..e91c6a6909 100644 --- a/basis/x11/x11.factor +++ b/basis/x11/x11.factor @@ -33,4 +33,4 @@ SYMBOL: root : with-x ( display-string quot -- ) [ init-x ] dip [ close-x ] [ ] cleanup ; inline -"io.backend.unix" vocab [ "x11.io.unix" require ] when \ No newline at end of file +"io.backend.unix" "x11.io.unix" require-when From b4bf7b1d9b5967536eb7421a5b0ff8ceca4531c1 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Thu, 18 Mar 2010 02:07:47 -0400 Subject: [PATCH 429/713] Making xml literal inverse behavior only load if inverse is loaded --- basis/xml/syntax/inverse/inverse.factor | 75 +++++++++++++++++++++++++ basis/xml/syntax/syntax.factor | 74 +----------------------- 2 files changed, 78 insertions(+), 71 deletions(-) create mode 100644 basis/xml/syntax/inverse/inverse.factor diff --git a/basis/xml/syntax/inverse/inverse.factor b/basis/xml/syntax/inverse/inverse.factor new file mode 100644 index 0000000000..002f60aa23 --- /dev/null +++ b/basis/xml/syntax/inverse/inverse.factor @@ -0,0 +1,75 @@ +! Copyright (C) 2005, 2009 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: accessors arrays assocs combinators +combinators.short-circuit fry generalizations inverse kernel +namespaces sequences sorting strings unicode.categories +xml.data xml.syntax xml.syntax.private ; +IN: xml.syntax.inverse + +: remove-blanks ( seq -- newseq ) + [ { [ string? not ] [ [ blank? ] all? not ] } 1|| ] filter ; + +GENERIC: >xml ( xml -- tag ) +M: xml >xml body>> ; +M: tag >xml ; +M: xml-chunk >xml + remove-blanks + [ length 1 =/fail ] + [ first dup tag? [ fail ] unless ] bi ; +M: object >xml fail ; + +: 1chunk ( object -- xml-chunk ) + 1array ; + +GENERIC: >xml-chunk ( xml -- chunk ) +M: xml >xml-chunk body>> 1chunk ; +M: xml-chunk >xml-chunk ; +M: object >xml-chunk 1chunk ; + +GENERIC: [undo-xml] ( xml -- quot ) + +M: xml [undo-xml] + body>> [undo-xml] '[ >xml @ ] ; + +M: xml-chunk [undo-xml] + seq>> [undo-xml] '[ >xml-chunk @ ] ; + +: undo-attrs ( attrs -- quot: ( attrs -- ) ) + [ + [ main>> ] dip dup interpolated? + [ var>> '[ _ attr _ set ] ] + [ '[ _ attr _ =/fail ] ] if + ] { } assoc>map '[ _ cleave ] ; + +M: tag [undo-xml] ( tag -- quot: ( tag -- ) ) + { + [ name>> main>> '[ name>> main>> _ =/fail ] ] + [ attrs>> undo-attrs ] + [ children>> [undo-xml] '[ children>> @ ] ] + } cleave '[ _ _ _ tri ] ; + +: firstn-strong ( seq n -- ... ) + [ swap length =/fail ] + [ firstn ] 2bi ; inline + +M: sequence [undo-xml] ( sequence -- quot: ( seq -- ) ) + remove-blanks [ length ] [ [ [undo-xml] ] { } map-as ] bi + '[ remove-blanks _ firstn-strong _ spread ] ; + +M: string [undo-xml] ( string -- quot: ( string -- ) ) + '[ _ =/fail ] ; + +M: xml-data [undo-xml] ( datum -- quot: ( datum -- ) ) + '[ _ =/fail ] ; + +M: interpolated [undo-xml] + var>> '[ _ set ] ; + +: >enum ( assoc -- enum ) + ! Assumes keys are 0..n + >alist sort-keys values ; + +: undo-xml ( xml -- quot ) + [undo-xml] '[ H{ } clone [ _ bind ] keep >enum ] ; + +\ interpolate-xml 1 [ undo-xml ] define-pop-inverse diff --git a/basis/xml/syntax/syntax.factor b/basis/xml/syntax/syntax.factor index c56dd23db7..a58526faa3 100644 --- a/basis/xml/syntax/syntax.factor +++ b/basis/xml/syntax/syntax.factor @@ -4,7 +4,7 @@ USING: words assocs kernel accessors parser vocabs.parser effects.parser sequences summary lexer splitting combinators locals memoize sequences.deep xml.data xml.state xml namespaces present arrays generalizations strings make math macros multiline -inverse combinators.short-circuit sorting fry unicode.categories +combinators.short-circuit sorting fry unicode.categories effects ; IN: xml.syntax @@ -175,74 +175,6 @@ SYNTAX: chunk ] parse-def ; -xml ( xml -- tag ) -M: xml >xml body>> ; -M: tag >xml ; -M: xml-chunk >xml - remove-blanks - [ length 1 =/fail ] - [ first dup tag? [ fail ] unless ] bi ; -M: object >xml fail ; - -: 1chunk ( object -- xml-chunk ) - 1array ; - -GENERIC: >xml-chunk ( xml -- chunk ) -M: xml >xml-chunk body>> 1chunk ; -M: xml-chunk >xml-chunk ; -M: object >xml-chunk 1chunk ; - -GENERIC: [undo-xml] ( xml -- quot ) - -M: xml [undo-xml] - body>> [undo-xml] '[ >xml @ ] ; - -M: xml-chunk [undo-xml] - seq>> [undo-xml] '[ >xml-chunk @ ] ; - -: undo-attrs ( attrs -- quot: ( attrs -- ) ) - [ - [ main>> ] dip dup interpolated? - [ var>> '[ _ attr _ set ] ] - [ '[ _ attr _ =/fail ] ] if - ] { } assoc>map '[ _ cleave ] ; - -M: tag [undo-xml] ( tag -- quot: ( tag -- ) ) - { - [ name>> main>> '[ name>> main>> _ =/fail ] ] - [ attrs>> undo-attrs ] - [ children>> [undo-xml] '[ children>> @ ] ] - } cleave '[ _ _ _ tri ] ; - -: firstn-strong ( seq n -- ... ) - [ swap length =/fail ] - [ firstn ] 2bi ; inline - -M: sequence [undo-xml] ( sequence -- quot: ( seq -- ) ) - remove-blanks [ length ] [ [ [undo-xml] ] { } map-as ] bi - '[ remove-blanks _ firstn-strong _ spread ] ; - -M: string [undo-xml] ( string -- quot: ( string -- ) ) - '[ _ =/fail ] ; - -M: xml-data [undo-xml] ( datum -- quot: ( datum -- ) ) - '[ _ =/fail ] ; - -M: interpolated [undo-xml] - var>> '[ _ set ] ; - -: >enum ( assoc -- enum ) - ! Assumes keys are 0..n - >alist sort-keys values ; - -: undo-xml ( xml -- quot ) - [undo-xml] '[ H{ } clone [ _ bind ] keep >enum ] ; - -\ interpolate-xml 1 [ undo-xml ] define-pop-inverse - -PRIVATE> +"inverse" "xml.syntax.inverse" require-when From 6aee6b3adcf575040fde1099c1cc88286e1351e2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 18 Mar 2010 22:06:00 +1300 Subject: [PATCH 430/713] Add context-specific special object table, generalizing catchstack_save and current_callback_save fields of context struct --- basis/compiler/codegen/codegen.factor | 39 +++++------------- basis/compiler/tests/alien.factor | 21 +++------- basis/stack-checker/alien/alien.factor | 7 ++-- .../known-words/known-words.factor | 5 +++ .../row-polymorphism/row-polymorphism.factor | 1 - core/alien/alien.factor | 28 ++++++++++++- core/bootstrap/primitives.factor | 2 + core/bootstrap/stage1.factor | 2 +- core/continuations/continuations.factor | 27 ++++++------- core/namespaces/namespaces.factor | 6 +-- vm/contexts.cpp | 40 ++++++++++++++----- vm/contexts.hpp | 27 +++++++------ vm/objects.cpp | 8 ++-- vm/objects.hpp | 6 +-- vm/primitives.cpp | 2 + vm/primitives.hpp | 2 + vm/slot_visitor.hpp | 25 ++++++------ vm/vm.hpp | 5 ++- 18 files changed, 139 insertions(+), 114 deletions(-) diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index 3edfcc565b..73cfd6b86e 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -1,11 +1,12 @@ ! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: namespaces make math math.order math.parser sequences accessors -kernel kernel.private layouts assocs words summary arrays -combinators classes.algebra alien alien.c-types -alien.strings alien.arrays alien.complex alien.libraries sets libc -continuations.private fry cpu.architecture classes classes.struct locals -source-files.errors slots parser generic.parser strings +USING: namespaces make math math.order math.parser sequences +accessors kernel layouts assocs words summary arrays combinators +classes.algebra alien alien.private alien.c-types alien.strings +alien.arrays alien.complex alien.libraries sets libc +continuations.private fry cpu.architecture classes +classes.struct locals source-files.errors slots parser +generic.parser strings quotations compiler.errors compiler.alien compiler.constants @@ -461,22 +462,6 @@ M: ##alien-indirect generate-insn box-parameters ] with-param-regs ; -TUPLE: callback-context ; - -: current-callback ( -- id ) 2 special-object ; - -: wait-to-return ( token -- ) - dup current-callback eq? [ - drop - ] [ - yield-hook get call( -- ) wait-to-return - ] if ; - -: do-callback ( quot token -- ) - init-catchstack - [ 2 set-special-object call ] keep - wait-to-return ; inline - : callback-return-quot ( ctype -- quot ) return>> { { [ dup void? ] [ drop [ ] ] } @@ -488,12 +473,10 @@ TUPLE: callback-context ; parameters>> [ c-type c-type-boxer-quot ] map spread>quot ; : wrap-callback-quot ( params -- quot ) - [ - [ callback-prep-quot ] - [ quot>> ] - [ callback-return-quot ] tri 3append , - [ callback-context new do-callback ] % - ] [ ] make ; + [ callback-prep-quot ] [ quot>> ] [ callback-return-quot ] tri 3append + yield-hook get + '[ _ _ do-callback ] + >quotation ; M: ##alien-callback generate-insn params>> diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index acb5555bc3..ad8dac3ef9 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -330,26 +330,15 @@ FUNCTION: ulonglong ffi_test_38 ( ulonglong x, ulonglong y ) ; : callback-3 ( -- callback ) void { } "cdecl" [ 5 "x" set ] alien-callback ; -[ t ] [ - namestack* - 3 "x" set callback-3 callback_test_1 - namestack* eq? -] unit-test - -[ 5 ] [ +[ t 3 5 ] [ [ - 3 "x" set callback-3 callback_test_1 "x" get + namestack* + 3 "x" set callback-3 callback_test_1 + namestack* eq? + "x" get "x" get-global ] with-scope ] unit-test -: callback-4 ( -- callback ) - void { } "cdecl" [ "Hello world" write ] alien-callback - gc ; - -[ "Hello world" ] [ - [ callback-4 callback_test_1 ] with-string-writer -] unit-test - : callback-5 ( -- callback ) void { } "cdecl" [ gc ] alien-callback ; diff --git a/basis/stack-checker/alien/alien.factor b/basis/stack-checker/alien/alien.factor index 81d8a93240..9039c5d3f0 100644 --- a/basis/stack-checker/alien/alien.factor +++ b/basis/stack-checker/alien/alien.factor @@ -1,9 +1,10 @@ ! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences accessors combinators math namespaces -init sets words assocs alien.libraries alien alien.c-types -cpu.architecture fry stack-checker.backend stack-checker.errors -stack-checker.visitor stack-checker.dependencies ; +init sets words assocs alien.libraries alien alien.private +alien.c-types cpu.architecture fry stack-checker.backend +stack-checker.errors stack-checker.visitor +stack-checker.dependencies ; IN: stack-checker.alien TUPLE: alien-node-params return parameters abi in-d out-d ; diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 2c08533ebb..d0cbb05919 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -509,6 +509,11 @@ M: bad-executable summary \ set-special-object { object fixnum } { } define-primitive +\ context-object { fixnum } { object } define-primitive +\ context-object make-flushable + +\ set-context-object { object fixnum } { } define-primitive + \ (exists?) { string } { object } define-primitive \ minor-gc { } { } define-primitive diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index d91c766fea..1b8bd8faed 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -4,7 +4,6 @@ continuations effects fry kernel locals math math.order namespaces quotations sequences splitting stack-checker.backend stack-checker.errors -stack-checker.known-words stack-checker.state stack-checker.values stack-checker.visitor ; diff --git a/core/alien/alien.factor b/core/alien/alien.factor index 631fdcfc93..191886393a 100644 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2004, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs kernel math namespaces sequences system -kernel.private byte-arrays byte-vectors arrays init ; +kernel.private byte-arrays byte-vectors arrays init +continuations.private ; IN: alien PREDICATE: pinned-alien < alien underlying>> not ; @@ -83,6 +84,8 @@ ERROR: alien-assembly-error code ; : alien-assembly ( args... return parameters abi quot -- return... ) dup alien-assembly-error ; + context-id + +: context-id ( -- id ) 2 context-object ; + +: set-context-id ( id -- ) 2 set-context-object ; + +: wait-to-return ( yield-quot id -- ) + dup context-id eq? + [ 2drop ] [ over call( -- ) wait-to-return ] if ; + +! Used by compiler.codegen to wrap callback bodies +: do-callback ( callback-quot yield-quot -- ) + init-namespaces + init-catchstack + + [ set-context-id drop call ] [ wait-to-return drop ] 3bi ; inline + +! A utility for defining global variables that are recompiled in +! every session TUPLE: expiry-check object alien ; : recompute-value? ( check -- ? ) diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 2772b68875..19a179a6b1 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -447,8 +447,10 @@ tuple { "call-clear" "kernel.private" "primitive_call_clear" (( quot -- * )) } { "check-datastack" "kernel.private" "primitive_check_datastack" (( array in# out# -- ? )) } { "compute-identity-hashcode" "kernel.private" "primitive_compute_identity_hashcode" (( obj -- )) } + { "context-object" "kernel.private" "primitive_context_object" (( n -- obj )) } { "innermost-frame-executing" "kernel.private" "primitive_innermost_stack_frame_executing" (( callstack -- obj )) } { "innermost-frame-scan" "kernel.private" "primitive_innermost_stack_frame_scan" (( callstack -- n )) } + { "set-context-object" "kernel.private" "primitive_set_context_object" (( obj n -- )) } { "set-datastack" "kernel.private" "primitive_set_datastack" (( ds -- )) } { "set-innermost-frame-quot" "kernel.private" "primitive_set_innermost_stack_frame_quot" (( n callstack -- )) } { "set-retainstack" "kernel.private" "primitive_set_retainstack" (( rs -- )) } diff --git a/core/bootstrap/stage1.factor b/core/bootstrap/stage1.factor index 78658206de..41218fff6d 100644 --- a/core/bootstrap/stage1.factor +++ b/core/bootstrap/stage1.factor @@ -40,7 +40,7 @@ load-help? off run-file ] [ "Cannot find " write write "." print - "Please move " write image write " to the same directory as the Factor sources," print + "Please move " write image write " into the same directory as the Factor sources," print "and try again." print 1 (exit) ] if diff --git a/core/continuations/continuations.factor b/core/continuations/continuations.factor index 687f7153a1..cfceb1f715 100644 --- a/core/continuations/continuations.factor +++ b/core/continuations/continuations.factor @@ -13,7 +13,7 @@ SYMBOL: restarts c ( continuation -- ) catchstack* push ; @@ -23,13 +23,14 @@ SYMBOL: restarts : dummy-1 ( -- obj ) f ; : dummy-2 ( obj -- obj ) dup drop ; -: init-catchstack ( -- ) V{ } clone 1 set-special-object ; - -PRIVATE> - : catchstack ( -- catchstack ) catchstack* clone ; inline -: set-catchstack ( catchstack -- ) >vector 1 set-special-object ; inline +: set-catchstack ( catchstack -- ) + >vector 1 set-context-object ; inline + +: init-catchstack ( -- ) f set-catchstack ; + +PRIVATE> TUPLE: continuation data call retain name catch ; @@ -39,14 +40,12 @@ C: continuation datastack callstack retainstack namestack catchstack ; +continuation< ( continuation -- data call retain name catch ) - { - [ data>> ] - [ call>> ] - [ retain>> ] - [ name>> ] - [ catch>> ] - } cleave ; + { [ data>> ] [ call>> ] [ retain>> ] [ name>> ] [ catch>> ] } cleave ; + +PRIVATE> : ifcc ( capture restore -- ) [ dummy-1 continuation ] 2dip [ dummy-2 ] prepose ?if ; inline @@ -172,7 +171,7 @@ M: condition compute-restarts n ( namespace -- ) namestack* push ; : ndrop ( -- ) namestack* pop* ; @@ -14,7 +14,7 @@ PRIVATE> : namespace ( -- namespace ) namestack* last ; inline : namestack ( -- namestack ) namestack* clone ; -: set-namestack ( namestack -- ) >vector 0 set-special-object ; +: set-namestack ( namestack -- ) >vector 0 set-context-object ; : global ( -- g ) 21 special-object { hashtable } declare ; inline : init-namespaces ( -- ) global 1array set-namestack ; : get ( variable -- value ) namestack* assoc-stack ; inline diff --git a/vm/contexts.cpp b/vm/contexts.cpp index 394d14e55d..1079c572d2 100644 --- a/vm/contexts.cpp +++ b/vm/contexts.cpp @@ -10,12 +10,26 @@ context::context(cell ds_size, cell rs_size) : retainstack(0), datastack_region(new segment(ds_size,false)), retainstack_region(new segment(rs_size,false)), - catchstack_save(0), - current_callback_save(0), next(NULL) { reset_datastack(); reset_retainstack(); + reset_context_objects(); +} + +void context::reset_datastack() +{ + datastack = datastack_region->start - sizeof(cell); +} + +void context::reset_retainstack() +{ + retainstack = retainstack_region->start - sizeof(cell); +} + +void context::reset_context_objects() +{ + memset_cell(context_objects,false_object,context_object_count * sizeof(cell)); } context *factor_vm::alloc_context() @@ -47,12 +61,9 @@ void factor_vm::nest_stacks() new_ctx->callstack_bottom = (stack_frame *)-1; new_ctx->callstack_top = (stack_frame *)-1; - /* save per-callback special_objects */ - new_ctx->current_callback_save = special_objects[OBJ_CURRENT_CALLBACK]; - new_ctx->catchstack_save = special_objects[OBJ_CATCHSTACK]; - new_ctx->reset_datastack(); new_ctx->reset_retainstack(); + new_ctx->reset_context_objects(); new_ctx->next = ctx; ctx = new_ctx; @@ -66,10 +77,6 @@ void nest_stacks(factor_vm *parent) /* called when leaving a compiled callback */ void factor_vm::unnest_stacks() { - /* restore per-callback special_objects */ - special_objects[OBJ_CURRENT_CALLBACK] = ctx->current_callback_save; - special_objects[OBJ_CATCHSTACK] = ctx->catchstack_save; - context *old_ctx = ctx; ctx = old_ctx->next; dealloc_context(old_ctx); @@ -89,6 +96,19 @@ void factor_vm::init_stacks(cell ds_size_, cell rs_size_) unused_contexts = NULL; } +void factor_vm::primitive_context_object() +{ + fixnum n = untag_fixnum(ctx->peek()); + ctx->replace(ctx->context_objects[n]); +} + +void factor_vm::primitive_set_context_object() +{ + fixnum n = untag_fixnum(ctx->pop()); + cell value = ctx->pop(); + ctx->context_objects[n] = value; +} + bool factor_vm::stack_to_array(cell bottom, cell top) { fixnum depth = (fixnum)(top - bottom + sizeof(cell)); diff --git a/vm/contexts.hpp b/vm/contexts.hpp index 9ba9bb313c..e555bd4a92 100644 --- a/vm/contexts.hpp +++ b/vm/contexts.hpp @@ -1,6 +1,14 @@ namespace factor { +static const cell context_object_count = 10; + +enum context_object { + OBJ_NAMESTACK, + OBJ_CATCHSTACK, + OBJ_CONTEXT_ID, +}; + /* Assembly code makes assumptions about the layout of this struct */ struct context { /* C stack pointer on entry */ @@ -19,13 +27,16 @@ struct context { /* memory region holding current retain stack */ segment *retainstack_region; - /* saved special_objects slots on entry to callback */ - cell catchstack_save; - cell current_callback_save; + /* context-specific special objects, accessed by context-object and + set-context-object primitives */ + cell context_objects[context_object_count]; context *next; context(cell ds_size, cell rs_size); + void reset_datastack(); + void reset_retainstack(); + void reset_context_objects(); cell peek() { @@ -50,16 +61,6 @@ struct context { replace(tagged); } - void reset_datastack() - { - datastack = datastack_region->start - sizeof(cell); - } - - void reset_retainstack() - { - retainstack = retainstack_region->start - sizeof(cell); - } - static const cell stack_reserved = (64 * sizeof(cell)); void fix_stacks() diff --git a/vm/objects.cpp b/vm/objects.cpp index f1201c4de7..6b007f5d42 100644 --- a/vm/objects.cpp +++ b/vm/objects.cpp @@ -5,15 +5,15 @@ namespace factor void factor_vm::primitive_special_object() { - fixnum e = untag_fixnum(ctx->peek()); - ctx->replace(special_objects[e]); + fixnum n = untag_fixnum(ctx->peek()); + ctx->replace(special_objects[n]); } void factor_vm::primitive_set_special_object() { - fixnum e = untag_fixnum(ctx->pop()); + fixnum n = untag_fixnum(ctx->pop()); cell value = ctx->pop(); - special_objects[e] = value; + special_objects[n] = value; } void factor_vm::primitive_identity_hashcode() diff --git a/vm/objects.hpp b/vm/objects.hpp index 2d777ac516..772863d3f1 100644 --- a/vm/objects.hpp +++ b/vm/objects.hpp @@ -4,11 +4,7 @@ namespace factor static const cell special_object_count = 70; enum special_object { - OBJ_NAMESTACK, /* used by library only */ - OBJ_CATCHSTACK, /* used by library only, per-callback */ - - OBJ_CURRENT_CALLBACK = 2, /* used by library only, per-callback */ - OBJ_WALKER_HOOK, /* non-local exit hook, used by library only */ + OBJ_WALKER_HOOK = 3, /* non-local exit hook, used by library only */ OBJ_CALLCC_1, /* used to pass the value in callcc1 */ ERROR_HANDLER_QUOT = 5, /* quotation called when VM throws an error */ diff --git a/vm/primitives.cpp b/vm/primitives.cpp index be9d5c6ff6..aa1e10f5a5 100644 --- a/vm/primitives.cpp +++ b/vm/primitives.cpp @@ -47,6 +47,7 @@ PRIMITIVE(code_blocks) PRIMITIVE(code_room) PRIMITIVE(compact_gc) PRIMITIVE(compute_identity_hashcode) +PRIMITIVE(context_object) PRIMITIVE(data_room) PRIMITIVE(datastack) PRIMITIVE(die) @@ -111,6 +112,7 @@ PRIMITIVE(resize_string) PRIMITIVE(retainstack) PRIMITIVE(save_image) PRIMITIVE(save_image_and_exit) +PRIMITIVE(set_context_object) PRIMITIVE(set_datastack) PRIMITIVE(set_innermost_stack_frame_quot) PRIMITIVE(set_retainstack) diff --git a/vm/primitives.hpp b/vm/primitives.hpp index 520df423a1..a36050323f 100644 --- a/vm/primitives.hpp +++ b/vm/primitives.hpp @@ -43,6 +43,7 @@ DECLARE_PRIMITIVE(code_blocks) DECLARE_PRIMITIVE(code_room) DECLARE_PRIMITIVE(compact_gc) DECLARE_PRIMITIVE(compute_identity_hashcode) +DECLARE_PRIMITIVE(context_object) DECLARE_PRIMITIVE(data_room) DECLARE_PRIMITIVE(datastack) DECLARE_PRIMITIVE(die) @@ -107,6 +108,7 @@ DECLARE_PRIMITIVE(resize_string) DECLARE_PRIMITIVE(retainstack) DECLARE_PRIMITIVE(save_image) DECLARE_PRIMITIVE(save_image_and_exit) +DECLARE_PRIMITIVE(set_context_object) DECLARE_PRIMITIVE(set_datastack) DECLARE_PRIMITIVE(set_innermost_stack_frame_quot) DECLARE_PRIMITIVE(set_retainstack) diff --git a/vm/slot_visitor.hpp b/vm/slot_visitor.hpp index 0ab9cc171d..e8ff7e30d2 100644 --- a/vm/slot_visitor.hpp +++ b/vm/slot_visitor.hpp @@ -26,6 +26,7 @@ template struct slot_visitor { cell visit_pointer(cell pointer); void visit_handle(cell *handle); + void visit_object_array(cell *start, cell *end); void visit_slots(object *ptr, cell payload_start); void visit_slots(object *ptr); void visit_stack_elements(segment *region, cell *top); @@ -55,6 +56,12 @@ void slot_visitor::visit_handle(cell *handle) *handle = visit_pointer(*handle); } +template +void slot_visitor::visit_object_array(cell *start, cell *end) +{ + while(start < end) visit_handle(start++); +} + template void slot_visitor::visit_slots(object *ptr, cell payload_start) { @@ -64,7 +71,7 @@ void slot_visitor::visit_slots(object *ptr, cell payload_start) if(slot != end) { slot++; - for(; slot < end; slot++) visit_handle(slot); + visit_object_array(slot,end); } } @@ -77,8 +84,7 @@ void slot_visitor::visit_slots(object *ptr) template void slot_visitor::visit_stack_elements(segment *region, cell *top) { - for(cell *ptr = (cell *)region->start; ptr <= top; ptr++) - visit_handle(ptr); + visit_object_array((cell *)region->start,top + 1); } template @@ -88,11 +94,7 @@ void slot_visitor::visit_data_roots() std::vector::const_iterator end = parent->data_roots.end(); for(; iter < end; iter++) - { - data_root_range r = *iter; - for(cell index = 0; index < r.len; index++) - visit_handle(r.start + index); - } + visit_object_array(iter->start,iter->start + iter->len); } template @@ -162,8 +164,7 @@ void slot_visitor::visit_roots() visit_callback_roots(); visit_literal_table_roots(); - for(cell i = 0; i < special_object_count; i++) - visit_handle(&parent->special_objects[i]); + visit_object_array(parent->special_objects,parent->special_objects + special_object_count); } template @@ -175,9 +176,7 @@ void slot_visitor::visit_contexts() { visit_stack_elements(ctx->datastack_region,(cell *)ctx->datastack); visit_stack_elements(ctx->retainstack_region,(cell *)ctx->retainstack); - - visit_handle(&ctx->catchstack_save); - visit_handle(&ctx->current_callback_save); + visit_object_array(ctx->context_objects,ctx->context_objects + context_object_count); ctx = ctx->next; } diff --git a/vm/vm.hpp b/vm/vm.hpp index 714794aa32..f20145b43f 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -18,7 +18,8 @@ struct factor_vm cell cards_offset; cell decks_offset; - /* TAGGED user environment data; see getenv/setenv prims */ + /* Various special objects, accessed by special-object and + set-special-object primitives */ cell special_objects[special_object_count]; /* Data stack and retain stack sizes */ @@ -100,6 +101,8 @@ struct factor_vm void nest_stacks(); void unnest_stacks(); void init_stacks(cell ds_size_, cell rs_size_); + void primitive_context_object(); + void primitive_set_context_object(); bool stack_to_array(cell bottom, cell top); cell array_to_stack(array *array, cell bottom); void primitive_datastack(); From bcba3ab5ec0b576fd1f892f12c33a0060f0421dc Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Fri, 19 Mar 2010 06:34:25 -0400 Subject: [PATCH 431/713] Untested tags for vocabs.loader.test.[mno] --- core/vocabs/loader/test/m/tags.txt | 1 + core/vocabs/loader/test/n/tags.txt | 1 + core/vocabs/loader/test/o/tags.txt | 1 + 3 files changed, 3 insertions(+) create mode 100644 core/vocabs/loader/test/m/tags.txt create mode 100644 core/vocabs/loader/test/n/tags.txt create mode 100644 core/vocabs/loader/test/o/tags.txt diff --git a/core/vocabs/loader/test/m/tags.txt b/core/vocabs/loader/test/m/tags.txt new file mode 100644 index 0000000000..5d77766703 --- /dev/null +++ b/core/vocabs/loader/test/m/tags.txt @@ -0,0 +1 @@ +untested diff --git a/core/vocabs/loader/test/n/tags.txt b/core/vocabs/loader/test/n/tags.txt new file mode 100644 index 0000000000..5d77766703 --- /dev/null +++ b/core/vocabs/loader/test/n/tags.txt @@ -0,0 +1 @@ +untested diff --git a/core/vocabs/loader/test/o/tags.txt b/core/vocabs/loader/test/o/tags.txt new file mode 100644 index 0000000000..5d77766703 --- /dev/null +++ b/core/vocabs/loader/test/o/tags.txt @@ -0,0 +1 @@ +untested From 7dd44bfccf4bc2e1eba0935cf0d4c952eb2a7cea Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Fri, 19 Mar 2010 06:45:55 -0400 Subject: [PATCH 432/713] Docs for require-when --- core/vocabs/loader/loader-docs.factor | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/vocabs/loader/loader-docs.factor b/core/vocabs/loader/loader-docs.factor index 08ab729b6d..d5a6be5335 100755 --- a/core/vocabs/loader/loader-docs.factor +++ b/core/vocabs/loader/loader-docs.factor @@ -50,7 +50,9 @@ $nl { $subsections "vocabs.metadata" "vocabs.icons" } "Vocabularies can also be loaded at run time, without altering the vocabulary search path. This is done by calling a word which loads a vocabulary if it is not in the image, doing nothing if it is:" { $subsections require } -"The above word will only ever load a vocabulary once in a given session. There is another word which unconditionally loads vocabulary from disk, regardless of whether or not is has already been loaded:" +"The above word will only ever load a vocabulary once in a given session. Sometimes, two vocabularies require special code to interact. The following word is used to load one vocabulary when another is present:" +{ $subsections require-when } +"There is another word which unconditionally loads vocabulary from disk, regardless of whether or not is has already been loaded:" { $subsections reload } "For interactive development in the listener, calling " { $link reload } " directly is usually not necessary, since a better facility exists for " { $link "vocabs.refresh" } "." $nl @@ -111,6 +113,12 @@ HELP: require { $description "Loads a vocabulary if it has not already been loaded." } { $notes "To unconditionally reload a vocabulary, use " { $link reload } ". To reload changed source files only, use the words in " { $link "vocabs.refresh" } "." } ; +HELP: require-when +{ $values { "if" "a vocabulary specifier" } { "then" "a vocabulary specifier" } } +{ $description "Loads the " { $snippet "then" } " vocabulary if it is not loaded and the " { $snippet "if" } " vocabulary is. If the " { $snippet "if" } " vocabulary is not loaded now, but it is later, then the " { $snippet "then" } " vocabulary will be loaded along with it at that time." } +{ $notes "This is used to express a joint dependency of vocabularies. If vocabularies " { $snippet "a" } " and " { $snippet "b" } " use code in vocabulary " { $snippet "c" } " to interact, then the following line can be placed in " { $snippet "a" } " in order express the dependency." +{ $code "\"b\" \"c\" require-when" } } ; + HELP: run { $values { "vocab" "a vocabulary specifier" } } { $description "Runs a vocabulary's main entry point. The main entry point is set with the " { $link POSTPONE: MAIN: } " parsing word." } ; From 930b0d931b688c47e9ed2cffe9a50cd9cca011dd Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Fri, 19 Mar 2010 14:05:14 -0400 Subject: [PATCH 433/713] Using a higher-order C macro to clean up duplication in declaring/defining VM primitives --- vm/alien.cpp | 14 +-- vm/primitives.cpp | 127 +------------------ vm/primitives.hpp | 304 +++++++++++++++++++++++----------------------- 3 files changed, 152 insertions(+), 293 deletions(-) diff --git a/vm/alien.cpp b/vm/alien.cpp index 38078b6679..44365859e2 100755 --- a/vm/alien.cpp +++ b/vm/alien.cpp @@ -113,19 +113,7 @@ void *factor_vm::alien_pointer() *ptr = value; \ } -DEFINE_ALIEN_ACCESSOR(signed_cell,fixnum,from_signed_cell,to_fixnum) -DEFINE_ALIEN_ACCESSOR(unsigned_cell,cell,from_unsigned_cell,to_cell) -DEFINE_ALIEN_ACCESSOR(signed_8,s64,from_signed_8,to_signed_8) -DEFINE_ALIEN_ACCESSOR(unsigned_8,u64,from_unsigned_8,to_unsigned_8) -DEFINE_ALIEN_ACCESSOR(signed_4,s32,from_signed_4,to_fixnum) -DEFINE_ALIEN_ACCESSOR(unsigned_4,u32,from_unsigned_4,to_cell) -DEFINE_ALIEN_ACCESSOR(signed_2,s16,from_signed_2,to_fixnum) -DEFINE_ALIEN_ACCESSOR(unsigned_2,u16,from_unsigned_2,to_cell) -DEFINE_ALIEN_ACCESSOR(signed_1,s8,from_signed_1,to_fixnum) -DEFINE_ALIEN_ACCESSOR(unsigned_1,u8,from_unsigned_1,to_cell) -DEFINE_ALIEN_ACCESSOR(float,float,from_float,to_float) -DEFINE_ALIEN_ACCESSOR(double,double,from_double,to_double) -DEFINE_ALIEN_ACCESSOR(cell,void *,allot_alien,pinned_alien_offset) +EACH_ALIEN_PRIMITIVE(DEFINE_ALIEN_ACCESSOR) /* open a native library and push a handle */ void factor_vm::primitive_dlopen() diff --git a/vm/primitives.cpp b/vm/primitives.cpp index aa1e10f5a5..104b180341 100644 --- a/vm/primitives.cpp +++ b/vm/primitives.cpp @@ -8,131 +8,6 @@ namespace factor parent->primitive_##name(); \ } -PRIMITIVE(alien_address) -PRIMITIVE(all_instances) -PRIMITIVE(array) -PRIMITIVE(array_to_quotation) -PRIMITIVE(become) -PRIMITIVE(bignum_add) -PRIMITIVE(bignum_and) -PRIMITIVE(bignum_bitp) -PRIMITIVE(bignum_divint) -PRIMITIVE(bignum_divmod) -PRIMITIVE(bignum_eq) -PRIMITIVE(bignum_greater) -PRIMITIVE(bignum_greatereq) -PRIMITIVE(bignum_less) -PRIMITIVE(bignum_lesseq) -PRIMITIVE(bignum_log2) -PRIMITIVE(bignum_mod) -PRIMITIVE(bignum_multiply) -PRIMITIVE(bignum_not) -PRIMITIVE(bignum_or) -PRIMITIVE(bignum_shift) -PRIMITIVE(bignum_subtract) -PRIMITIVE(bignum_to_fixnum) -PRIMITIVE(bignum_to_float) -PRIMITIVE(bignum_xor) -PRIMITIVE(bits_double) -PRIMITIVE(bits_float) -PRIMITIVE(byte_array) -PRIMITIVE(byte_array_to_bignum) -PRIMITIVE(call_clear) -PRIMITIVE(callback) -PRIMITIVE(callstack) -PRIMITIVE(callstack_to_array) -PRIMITIVE(check_datastack) -PRIMITIVE(clone) -PRIMITIVE(code_blocks) -PRIMITIVE(code_room) -PRIMITIVE(compact_gc) -PRIMITIVE(compute_identity_hashcode) -PRIMITIVE(context_object) -PRIMITIVE(data_room) -PRIMITIVE(datastack) -PRIMITIVE(die) -PRIMITIVE(disable_gc_events) -PRIMITIVE(dispatch_stats) -PRIMITIVE(displaced_alien) -PRIMITIVE(dlclose) -PRIMITIVE(dll_validp) -PRIMITIVE(dlopen) -PRIMITIVE(dlsym) -PRIMITIVE(double_bits) -PRIMITIVE(enable_gc_events) -PRIMITIVE(existsp) -PRIMITIVE(exit) -PRIMITIVE(fclose) -PRIMITIVE(fflush) -PRIMITIVE(fgetc) -PRIMITIVE(fixnum_divint) -PRIMITIVE(fixnum_divmod) -PRIMITIVE(fixnum_shift) -PRIMITIVE(fixnum_to_bignum) -PRIMITIVE(fixnum_to_float) -PRIMITIVE(float_add) -PRIMITIVE(float_bits) -PRIMITIVE(float_divfloat) -PRIMITIVE(float_eq) -PRIMITIVE(float_greater) -PRIMITIVE(float_greatereq) -PRIMITIVE(float_less) -PRIMITIVE(float_lesseq) -PRIMITIVE(float_mod) -PRIMITIVE(float_multiply) -PRIMITIVE(float_subtract) -PRIMITIVE(float_to_bignum) -PRIMITIVE(float_to_fixnum) -PRIMITIVE(float_to_str) -PRIMITIVE(fopen) -PRIMITIVE(fputc) -PRIMITIVE(fread) -PRIMITIVE(fseek) -PRIMITIVE(ftell) -PRIMITIVE(full_gc) -PRIMITIVE(fwrite) -PRIMITIVE(identity_hashcode) -PRIMITIVE(innermost_stack_frame_executing) -PRIMITIVE(innermost_stack_frame_scan) -PRIMITIVE(jit_compile) -PRIMITIVE(load_locals) -PRIMITIVE(lookup_method) -PRIMITIVE(mega_cache_miss) -PRIMITIVE(minor_gc) -PRIMITIVE(modify_code_heap) -PRIMITIVE(nano_count) -PRIMITIVE(optimized_p) -PRIMITIVE(profiling) -PRIMITIVE(quot_compiled_p) -PRIMITIVE(quotation_code) -PRIMITIVE(reset_dispatch_stats) -PRIMITIVE(resize_array) -PRIMITIVE(resize_byte_array) -PRIMITIVE(resize_string) -PRIMITIVE(retainstack) -PRIMITIVE(save_image) -PRIMITIVE(save_image_and_exit) -PRIMITIVE(set_context_object) -PRIMITIVE(set_datastack) -PRIMITIVE(set_innermost_stack_frame_quot) -PRIMITIVE(set_retainstack) -PRIMITIVE(set_slot) -PRIMITIVE(set_special_object) -PRIMITIVE(set_string_nth_fast) -PRIMITIVE(set_string_nth_slow) -PRIMITIVE(size) -PRIMITIVE(sleep) -PRIMITIVE(special_object) -PRIMITIVE(string) -PRIMITIVE(string_nth) -PRIMITIVE(strip_stack_traces) -PRIMITIVE(system_micros) -PRIMITIVE(tuple) -PRIMITIVE(tuple_boa) -PRIMITIVE(unimplemented) -PRIMITIVE(uninitialized_byte_array) -PRIMITIVE(word) -PRIMITIVE(word_code) -PRIMITIVE(wrapper) +EACH_PRIMITIVE(PRIMITIVE) } diff --git a/vm/primitives.hpp b/vm/primitives.hpp index a36050323f..df36ed84b2 100644 --- a/vm/primitives.hpp +++ b/vm/primitives.hpp @@ -1,163 +1,159 @@ namespace factor { -#define DECLARE_PRIMITIVE(name) VM_C_API void primitive_##name(factor_vm *parent); - /* Generated with PRIMITIVE in primitives.cpp */ -DECLARE_PRIMITIVE(alien_address) -DECLARE_PRIMITIVE(all_instances) -DECLARE_PRIMITIVE(array) -DECLARE_PRIMITIVE(array_to_quotation) -DECLARE_PRIMITIVE(become) -DECLARE_PRIMITIVE(bignum_add) -DECLARE_PRIMITIVE(bignum_and) -DECLARE_PRIMITIVE(bignum_bitp) -DECLARE_PRIMITIVE(bignum_divint) -DECLARE_PRIMITIVE(bignum_divmod) -DECLARE_PRIMITIVE(bignum_eq) -DECLARE_PRIMITIVE(bignum_greater) -DECLARE_PRIMITIVE(bignum_greatereq) -DECLARE_PRIMITIVE(bignum_less) -DECLARE_PRIMITIVE(bignum_lesseq) -DECLARE_PRIMITIVE(bignum_log2) -DECLARE_PRIMITIVE(bignum_mod) -DECLARE_PRIMITIVE(bignum_multiply) -DECLARE_PRIMITIVE(bignum_not) -DECLARE_PRIMITIVE(bignum_or) -DECLARE_PRIMITIVE(bignum_shift) -DECLARE_PRIMITIVE(bignum_subtract) -DECLARE_PRIMITIVE(bignum_to_fixnum) -DECLARE_PRIMITIVE(bignum_to_float) -DECLARE_PRIMITIVE(bignum_xor) -DECLARE_PRIMITIVE(bits_double) -DECLARE_PRIMITIVE(bits_float) -DECLARE_PRIMITIVE(byte_array) -DECLARE_PRIMITIVE(byte_array_to_bignum) -DECLARE_PRIMITIVE(call_clear) -DECLARE_PRIMITIVE(callback) -DECLARE_PRIMITIVE(callstack) -DECLARE_PRIMITIVE(callstack_to_array) -DECLARE_PRIMITIVE(check_datastack) -DECLARE_PRIMITIVE(clone) -DECLARE_PRIMITIVE(code_blocks) -DECLARE_PRIMITIVE(code_room) -DECLARE_PRIMITIVE(compact_gc) -DECLARE_PRIMITIVE(compute_identity_hashcode) -DECLARE_PRIMITIVE(context_object) -DECLARE_PRIMITIVE(data_room) -DECLARE_PRIMITIVE(datastack) -DECLARE_PRIMITIVE(die) -DECLARE_PRIMITIVE(disable_gc_events) -DECLARE_PRIMITIVE(dispatch_stats) -DECLARE_PRIMITIVE(displaced_alien) -DECLARE_PRIMITIVE(dlclose) -DECLARE_PRIMITIVE(dll_validp) -DECLARE_PRIMITIVE(dlopen) -DECLARE_PRIMITIVE(dlsym) -DECLARE_PRIMITIVE(double_bits) -DECLARE_PRIMITIVE(enable_gc_events) -DECLARE_PRIMITIVE(existsp) -DECLARE_PRIMITIVE(exit) -DECLARE_PRIMITIVE(fclose) -DECLARE_PRIMITIVE(fflush) -DECLARE_PRIMITIVE(fgetc) -DECLARE_PRIMITIVE(fixnum_divint) -DECLARE_PRIMITIVE(fixnum_divmod) -DECLARE_PRIMITIVE(fixnum_shift) -DECLARE_PRIMITIVE(fixnum_to_bignum) -DECLARE_PRIMITIVE(fixnum_to_float) -DECLARE_PRIMITIVE(float_add) -DECLARE_PRIMITIVE(float_bits) -DECLARE_PRIMITIVE(float_divfloat) -DECLARE_PRIMITIVE(float_eq) -DECLARE_PRIMITIVE(float_greater) -DECLARE_PRIMITIVE(float_greatereq) -DECLARE_PRIMITIVE(float_less) -DECLARE_PRIMITIVE(float_lesseq) -DECLARE_PRIMITIVE(float_mod) -DECLARE_PRIMITIVE(float_multiply) -DECLARE_PRIMITIVE(float_subtract) -DECLARE_PRIMITIVE(float_to_bignum) -DECLARE_PRIMITIVE(float_to_fixnum) -DECLARE_PRIMITIVE(float_to_str) -DECLARE_PRIMITIVE(fopen) -DECLARE_PRIMITIVE(fputc) -DECLARE_PRIMITIVE(fread) -DECLARE_PRIMITIVE(fseek) -DECLARE_PRIMITIVE(ftell) -DECLARE_PRIMITIVE(full_gc) -DECLARE_PRIMITIVE(fwrite) -DECLARE_PRIMITIVE(identity_hashcode) -DECLARE_PRIMITIVE(innermost_stack_frame_executing) -DECLARE_PRIMITIVE(innermost_stack_frame_scan) -DECLARE_PRIMITIVE(jit_compile) -DECLARE_PRIMITIVE(load_locals) -DECLARE_PRIMITIVE(lookup_method) -DECLARE_PRIMITIVE(mega_cache_miss) -DECLARE_PRIMITIVE(minor_gc) -DECLARE_PRIMITIVE(modify_code_heap) -DECLARE_PRIMITIVE(nano_count) -DECLARE_PRIMITIVE(optimized_p) -DECLARE_PRIMITIVE(profiling) -DECLARE_PRIMITIVE(quot_compiled_p) -DECLARE_PRIMITIVE(quotation_code) -DECLARE_PRIMITIVE(reset_dispatch_stats) -DECLARE_PRIMITIVE(resize_array) -DECLARE_PRIMITIVE(resize_byte_array) -DECLARE_PRIMITIVE(resize_string) -DECLARE_PRIMITIVE(retainstack) -DECLARE_PRIMITIVE(save_image) -DECLARE_PRIMITIVE(save_image_and_exit) -DECLARE_PRIMITIVE(set_context_object) -DECLARE_PRIMITIVE(set_datastack) -DECLARE_PRIMITIVE(set_innermost_stack_frame_quot) -DECLARE_PRIMITIVE(set_retainstack) -DECLARE_PRIMITIVE(set_slot) -DECLARE_PRIMITIVE(set_special_object) -DECLARE_PRIMITIVE(set_string_nth_fast) -DECLARE_PRIMITIVE(set_string_nth_slow) -DECLARE_PRIMITIVE(size) -DECLARE_PRIMITIVE(sleep) -DECLARE_PRIMITIVE(special_object) -DECLARE_PRIMITIVE(string) -DECLARE_PRIMITIVE(string_nth) -DECLARE_PRIMITIVE(strip_stack_traces) -DECLARE_PRIMITIVE(system_micros) -DECLARE_PRIMITIVE(tuple) -DECLARE_PRIMITIVE(tuple_boa) -DECLARE_PRIMITIVE(unimplemented) -DECLARE_PRIMITIVE(uninitialized_byte_array) -DECLARE_PRIMITIVE(word) -DECLARE_PRIMITIVE(word_code) -DECLARE_PRIMITIVE(wrapper) +#define EACH_PRIMITIVE(_) \ + _(alien_address) \ + _(all_instances) \ + _(array) \ + _(array_to_quotation) \ + _(become) \ + _(bignum_add) \ + _(bignum_and) \ + _(bignum_bitp) \ + _(bignum_divint) \ + _(bignum_divmod) \ + _(bignum_eq) \ + _(bignum_greater) \ + _(bignum_greatereq) \ + _(bignum_less) \ + _(bignum_lesseq) \ + _(bignum_log2) \ + _(bignum_mod) \ + _(bignum_multiply) \ + _(bignum_not) \ + _(bignum_or) \ + _(bignum_shift) \ + _(bignum_subtract) \ + _(bignum_to_fixnum) \ + _(bignum_to_float) \ + _(bignum_xor) \ + _(bits_double) \ + _(bits_float) \ + _(byte_array) \ + _(byte_array_to_bignum) \ + _(call_clear) \ + _(callback) \ + _(callstack) \ + _(callstack_to_array) \ + _(check_datastack) \ + _(clone) \ + _(code_blocks) \ + _(code_room) \ + _(compact_gc) \ + _(compute_identity_hashcode) \ + _(context_object) \ + _(data_room) \ + _(datastack) \ + _(die) \ + _(disable_gc_events) \ + _(dispatch_stats) \ + _(displaced_alien) \ + _(dlclose) \ + _(dll_validp) \ + _(dlopen) \ + _(dlsym) \ + _(double_bits) \ + _(enable_gc_events) \ + _(existsp) \ + _(exit) \ + _(fclose) \ + _(fflush) \ + _(fgetc) \ + _(fixnum_divint) \ + _(fixnum_divmod) \ + _(fixnum_shift) \ + _(fixnum_to_bignum) \ + _(fixnum_to_float) \ + _(float_add) \ + _(float_bits) \ + _(float_divfloat) \ + _(float_eq) \ + _(float_greater) \ + _(float_greatereq) \ + _(float_less) \ + _(float_lesseq) \ + _(float_mod) \ + _(float_multiply) \ + _(float_subtract) \ + _(float_to_bignum) \ + _(float_to_fixnum) \ + _(float_to_str) \ + _(fopen) \ + _(fputc) \ + _(fread) \ + _(fseek) \ + _(ftell) \ + _(full_gc) \ + _(fwrite) \ + _(identity_hashcode) \ + _(innermost_stack_frame_executing) \ + _(innermost_stack_frame_scan) \ + _(jit_compile) \ + _(load_locals) \ + _(lookup_method) \ + _(mega_cache_miss) \ + _(minor_gc) \ + _(modify_code_heap) \ + _(nano_count) \ + _(optimized_p) \ + _(profiling) \ + _(quot_compiled_p) \ + _(quotation_code) \ + _(reset_dispatch_stats) \ + _(resize_array) \ + _(resize_byte_array) \ + _(resize_string) \ + _(retainstack) \ + _(save_image) \ + _(save_image_and_exit) \ + _(set_context_object) \ + _(set_datastack) \ + _(set_innermost_stack_frame_quot) \ + _(set_retainstack) \ + _(set_slot) \ + _(set_special_object) \ + _(set_string_nth_fast) \ + _(set_string_nth_slow) \ + _(size) \ + _(sleep) \ + _(special_object) \ + _(string) \ + _(string_nth) \ + _(strip_stack_traces) \ + _(system_micros) \ + _(tuple) \ + _(tuple_boa) \ + _(unimplemented) \ + _(uninitialized_byte_array) \ + _(word) \ + _(word_code) \ + _(wrapper) /* These are generated with macros in alien.cpp, and not with PRIMIIVE in primitives.cpp */ -DECLARE_PRIMITIVE(alien_signed_cell) -DECLARE_PRIMITIVE(set_alien_signed_cell) -DECLARE_PRIMITIVE(alien_unsigned_cell) -DECLARE_PRIMITIVE(set_alien_unsigned_cell) -DECLARE_PRIMITIVE(alien_signed_8) -DECLARE_PRIMITIVE(set_alien_signed_8) -DECLARE_PRIMITIVE(alien_unsigned_8) -DECLARE_PRIMITIVE(set_alien_unsigned_8) -DECLARE_PRIMITIVE(alien_signed_4) -DECLARE_PRIMITIVE(set_alien_signed_4) -DECLARE_PRIMITIVE(alien_unsigned_4) -DECLARE_PRIMITIVE(set_alien_unsigned_4) -DECLARE_PRIMITIVE(alien_signed_2) -DECLARE_PRIMITIVE(set_alien_signed_2) -DECLARE_PRIMITIVE(alien_unsigned_2) -DECLARE_PRIMITIVE(set_alien_unsigned_2) -DECLARE_PRIMITIVE(alien_signed_1) -DECLARE_PRIMITIVE(set_alien_signed_1) -DECLARE_PRIMITIVE(alien_unsigned_1) -DECLARE_PRIMITIVE(set_alien_unsigned_1) -DECLARE_PRIMITIVE(alien_float) -DECLARE_PRIMITIVE(set_alien_float) -DECLARE_PRIMITIVE(alien_double) -DECLARE_PRIMITIVE(set_alien_double) -DECLARE_PRIMITIVE(alien_cell) -DECLARE_PRIMITIVE(set_alien_cell) +#define EACH_ALIEN_PRIMITIVE(_) \ + _(signed_cell,fixnum,from_signed_cell,to_fixnum) \ + _(unsigned_cell,cell,from_unsigned_cell,to_cell) \ + _(signed_8,s64,from_signed_8,to_signed_8) \ + _(unsigned_8,u64,from_unsigned_8,to_unsigned_8) \ + _(signed_4,s32,from_signed_4,to_fixnum) \ + _(unsigned_4,u32,from_unsigned_4,to_cell) \ + _(signed_2,s16,from_signed_2,to_fixnum) \ + _(unsigned_2,u16,from_unsigned_2,to_cell) \ + _(signed_1,s8,from_signed_1,to_fixnum) \ + _(unsigned_1,u8,from_unsigned_1,to_cell) \ + _(float,float,from_float,to_float) \ + _(double,double,from_double,to_double) \ + _(cell,void *,allot_alien,pinned_alien_offset) + +#define DECLARE_PRIMITIVE(name) VM_C_API void primitive_##name(factor_vm *parent); + +#define DECLARE_ALIEN_PRIMITIVE(name, type, from, to) \ + DECLARE_PRIMITIVE(alien_##name) \ + DECLARE_PRIMITIVE(set_alien_##name) + +EACH_PRIMITIVE(DECLARE_PRIMITIVE) +EACH_ALIEN_PRIMITIVE(DECLARE_ALIEN_PRIMITIVE) } From ee4913702f6cecee5afc9e659264fd68404af5ea Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 20 Mar 2010 02:16:50 -0700 Subject: [PATCH 434/713] compiler.cfg.intrinsics.simd.backend: use less grotesque metaprogramming to determine simd instruction sequences --- .../intrinsics/simd/backend/backend.factor | 184 ++++++------------ 1 file changed, 63 insertions(+), 121 deletions(-) diff --git a/basis/compiler/cfg/intrinsics/simd/backend/backend.factor b/basis/compiler/cfg/intrinsics/simd/backend/backend.factor index e8b9e3c5de..7689266204 100644 --- a/basis/compiler/cfg/intrinsics/simd/backend/backend.factor +++ b/basis/compiler/cfg/intrinsics/simd/backend/backend.factor @@ -3,145 +3,87 @@ USING: accessors arrays assocs classes combinators combinators.short-circuit compiler.cfg.builder.blocks compiler.cfg.registers compiler.cfg.stacks compiler.cfg.stacks.local compiler.tree.propagation.info +compiler.cfg.instructions cpu.architecture effects fry generalizations -kernel locals macros math namespaces quotations sequences +kernel locals macros make math namespaces quotations sequences splitting stack-checker words ; IN: compiler.cfg.intrinsics.simd.backend ! Selection of implementation based on available CPU instructions -: can-has? ( quot -- ? ) - [ t \ can-has? ] dip '[ @ drop \ can-has? get ] with-variable ; inline +GENERIC: insn-available? ( ## -- reps ) -: can-has-rep? ( rep reps -- ) - member? \ can-has? [ and ] change ; inline +M: object insn-available? drop t ; -GENERIC: create-can-has ( word -- word' ) +M: ##zero-vector insn-available? rep>> %zero-vector-reps member? ; +M: ##fill-vector insn-available? rep>> %fill-vector-reps member? ; +M: ##gather-vector-2 insn-available? rep>> %gather-vector-2-reps member? ; +M: ##gather-vector-4 insn-available? rep>> %gather-vector-4-reps member? ; +M: ##alien-vector insn-available? rep>> %alien-vector-reps member? ; +M: ##shuffle-vector insn-available? rep>> %shuffle-vector-reps member? ; +M: ##shuffle-vector-imm insn-available? rep>> %shuffle-vector-imm-reps member? ; +M: ##merge-vector-head insn-available? rep>> %merge-vector-reps member? ; +M: ##merge-vector-tail insn-available? rep>> %merge-vector-reps member? ; +M: ##signed-pack-vector insn-available? rep>> %signed-pack-vector-reps member? ; +M: ##unsigned-pack-vector insn-available? rep>> %unsigned-pack-vector-reps member? ; +M: ##unpack-vector-head insn-available? rep>> %unpack-vector-head-reps member? ; +M: ##unpack-vector-tail insn-available? rep>> %unpack-vector-tail-reps member? ; +M: ##tail>head-vector insn-available? rep>> %unpack-vector-head-reps member? ; +M: ##integer>float-vector insn-available? rep>> %integer>float-vector-reps member? ; +M: ##float>integer-vector insn-available? rep>> %float>integer-vector-reps member? ; +M: ##compare-vector insn-available? [ rep>> ] [ cc>> ] bi %compare-vector-reps member? ; +M: ##test-vector insn-available? rep>> %test-vector-reps member? ; +M: ##add-vector insn-available? rep>> %add-vector-reps member? ; +M: ##saturated-add-vector insn-available? rep>> %saturated-add-vector-reps member? ; +M: ##add-sub-vector insn-available? rep>> %add-sub-vector-reps member? ; +M: ##sub-vector insn-available? rep>> %sub-vector-reps member? ; +M: ##saturated-sub-vector insn-available? rep>> %saturated-sub-vector-reps member? ; +M: ##mul-vector insn-available? rep>> %mul-vector-reps member? ; +M: ##mul-high-vector insn-available? rep>> %mul-high-vector-reps member? ; +M: ##mul-horizontal-add-vector insn-available? rep>> %mul-horizontal-add-vector-reps member? ; +M: ##saturated-mul-vector insn-available? rep>> %saturated-mul-vector-reps member? ; +M: ##div-vector insn-available? rep>> %div-vector-reps member? ; +M: ##min-vector insn-available? rep>> %min-vector-reps member? ; +M: ##max-vector insn-available? rep>> %max-vector-reps member? ; +M: ##avg-vector insn-available? rep>> %avg-vector-reps member? ; +M: ##dot-vector insn-available? rep>> %dot-vector-reps member? ; +M: ##sad-vector insn-available? rep>> %sad-vector-reps member? ; +M: ##sqrt-vector insn-available? rep>> %sqrt-vector-reps member? ; +M: ##horizontal-add-vector insn-available? rep>> %horizontal-add-vector-reps member? ; +M: ##horizontal-sub-vector insn-available? rep>> %horizontal-sub-vector-reps member? ; +M: ##abs-vector insn-available? rep>> %abs-vector-reps member? ; +M: ##and-vector insn-available? rep>> %and-vector-reps member? ; +M: ##andn-vector insn-available? rep>> %andn-vector-reps member? ; +M: ##or-vector insn-available? rep>> %or-vector-reps member? ; +M: ##xor-vector insn-available? rep>> %xor-vector-reps member? ; +M: ##not-vector insn-available? rep>> %not-vector-reps member? ; +M: ##shl-vector insn-available? rep>> %shl-vector-reps member? ; +M: ##shr-vector insn-available? rep>> %shr-vector-reps member? ; +M: ##shl-vector-imm insn-available? rep>> %shl-vector-imm-reps member? ; +M: ##shr-vector-imm insn-available? rep>> %shr-vector-imm-reps member? ; +M: ##horizontal-shl-vector-imm insn-available? rep>> %horizontal-shl-vector-imm-reps member? ; +M: ##horizontal-shr-vector-imm insn-available? rep>> %horizontal-shr-vector-imm-reps member? ; -PREDICATE: hat-word < word - { - [ name>> { [ "^" head? ] [ "##" head? ] } 1|| ] - [ vocabulary>> { "compiler.cfg.intrinsics.simd" "compiler.cfg.hats" } member? ] - } 1&& ; +GENERIC# >vector-op-cond 2 ( quot #pick #dup -- quotpair ) +M:: callable >vector-op-cond ( quot #pick #dup -- quotpair ) + #dup quot '[ _ ndup [ @ drop ] { } make [ insn-available? ] all? ] quot 2array ; -PREDICATE: vector-op-word < hat-word - name>> "-vector" swap subseq? ; - -: reps-word ( word -- word' ) - name>> "^^" ?head drop "##" ?head drop - "%" "-reps" surround "cpu.architecture" lookup ; - -SYMBOL: blub - -:: can-has-^^-quot ( word def effect -- quot ) - effect in>> { "rep" } split1 [ length ] bi@ 1 + - word reps-word 1quotation - effect out>> length blub >quotation - '[ [ _ ndrop ] _ ndip @ can-has-rep? @ ] ; - -:: can-has-^-quot ( word def effect -- quot ) - def create-can-has first ; - -: map-concat-like ( seq quot -- seq' ) - '[ _ map ] [ concat-as ] bi ; inline - -M: object create-can-has 1quotation ; - -M: array create-can-has - [ create-can-has ] map-concat-like 1quotation ; -M: callable create-can-has - [ create-can-has ] map-concat-like 1quotation ; - -: (can-has-word) ( word -- word' ) - name>> "can-has-" prepend "compiler.cfg.intrinsics.simd.backend" lookup ; - -: (can-has-quot) ( word -- quot ) - [ ] [ def>> ] [ stack-effect ] tri { - { [ pick name>> "^^" head? ] [ can-has-^^-quot ] } - { [ pick name>> "##" head? ] [ can-has-^^-quot ] } - { [ pick name>> "^" head? ] [ can-has-^-quot ] } - } cond ; - -: (can-has-nop-quot) ( word -- quot ) - stack-effect in>> length '[ _ ndrop blub ] ; - -DEFER: can-has-words - -M: word create-can-has - can-has-words ?at drop 1quotation ; - -M: hat-word create-can-has - (can-has-nop-quot) ; - -M: vector-op-word create-can-has - dup (can-has-word) [ 1quotation ] [ (can-has-quot) ] ?if ; - -GENERIC# >can-has-cond 2 ( quot #pick #dup -- quotpair ) -M:: callable >can-has-cond ( quot #pick #dup -- quotpair ) - #dup quot create-can-has '[ _ ndup @ can-has? ] quot 2array ; - -M:: pair >can-has-cond ( pair #pick #dup -- quotpair ) +M:: pair >vector-op-cond ( pair #pick #dup -- quotpair ) pair first2 :> ( class quot ) - #pick class #dup quot create-can-has - '[ _ npick _ instance? [ _ ndup @ can-has? ] dip and ] + #pick class #dup quot + '[ _ npick _ instance? [ _ ndup [ @ drop ] { } make [ insn-available? ] all? ] [ f ] if ] quot 2array ; MACRO: v-vector-op ( trials -- ) - [ 1 2 >can-has-cond ] map '[ _ cond ] ; + [ 1 2 >vector-op-cond ] map '[ _ cond ] ; MACRO: vl-vector-op ( trials -- ) - [ 1 3 >can-has-cond ] map '[ _ cond ] ; + [ 1 3 >vector-op-cond ] map '[ _ cond ] ; MACRO: vv-vector-op ( trials -- ) - [ 1 3 >can-has-cond ] map '[ _ cond ] ; + [ 1 3 >vector-op-cond ] map '[ _ cond ] ; MACRO: vv-cc-vector-op ( trials -- ) - [ 2 4 >can-has-cond ] map '[ _ cond ] ; + [ 2 4 >vector-op-cond ] map '[ _ cond ] ; MACRO: vvvv-vector-op ( trials -- ) - [ 1 5 >can-has-cond ] map '[ _ cond ] ; - -! Special-case conditional instructions - -: can-has-^(compare-vector) ( src1 src2 rep cc -- dst ) - [ 2drop ] 2dip %compare-vector-reps member? - \ can-has? [ and ] change - blub ; - -: can-has-^^test-vector ( src rep vcc -- dst ) - [ drop ] 2dip drop %test-vector-reps member? - \ can-has? [ and ] change - blub ; - -MACRO: can-has-case ( cases -- ) - dup first second inputs 1 + - '[ _ ndrop f ] suffix '[ _ case ] ; - -GENERIC# >can-has-trial 1 ( obj #pick -- quot ) - -M: callable >can-has-trial - drop '[ _ can-has? ] ; -M: pair >can-has-trial - swap first2 dup inputs - '[ _ npick _ instance? [ _ can-has? ] [ _ ndrop blub ] if ] ; - -MACRO: can-has-vector-op ( trials #pick #dup -- ) - [ '[ _ >can-has-trial ] map ] dip '[ _ _ n|| \ can-has? [ and ] change blub ] ; - -: can-has-v-vector-op ( trials -- ? ) - 1 2 can-has-vector-op ; inline -: can-has-vv-vector-op ( trials -- ? ) - 1 3 can-has-vector-op ; inline -: can-has-vv-cc-vector-op ( trials -- ? ) - 2 4 can-has-vector-op ; inline -: can-has-vvvv-vector-op ( trials -- ? ) - 1 5 can-has-vector-op ; inline - -CONSTANT: can-has-words - H{ - { case can-has-case } - { v-vector-op can-has-v-vector-op } - { vl-vector-op can-has-vv-vector-op } - { vv-vector-op can-has-vv-vector-op } - { vv-cc-vector-op can-has-vv-cc-vector-op } - { vvvv-vector-op can-has-vvvv-vector-op } - } + [ 1 5 >vector-op-cond ] map '[ _ cond ] ; ! Intrinsic code emission From f82a368602bc4312bf35f4e9c7eb1c7061d52831 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 20 Mar 2010 02:51:49 -0700 Subject: [PATCH 435/713] compiler.cfg.intrinsics.simd.backend: eliminate duplicated work done on successful insn sequence --- .../intrinsics/simd/backend/backend.factor | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/basis/compiler/cfg/intrinsics/simd/backend/backend.factor b/basis/compiler/cfg/intrinsics/simd/backend/backend.factor index 7689266204..d090bc1a7c 100644 --- a/basis/compiler/cfg/intrinsics/simd/backend/backend.factor +++ b/basis/compiler/cfg/intrinsics/simd/backend/backend.factor @@ -66,24 +66,27 @@ M: ##horizontal-shr-vector-imm insn-available? rep>> %horizontal-shr-vector-imm- GENERIC# >vector-op-cond 2 ( quot #pick #dup -- quotpair ) M:: callable >vector-op-cond ( quot #pick #dup -- quotpair ) - #dup quot '[ _ ndup [ @ drop ] { } make [ insn-available? ] all? ] quot 2array ; + #dup quot '[ 2drop _ ndup [ @ ] { } make dup [ insn-available? ] all? ] + #dup '[ % _ nnip ] + 2array ; M:: pair >vector-op-cond ( pair #pick #dup -- quotpair ) pair first2 :> ( class quot ) #pick class #dup quot - '[ _ npick _ instance? [ _ ndup [ @ drop ] { } make [ insn-available? ] all? ] [ f ] if ] - quot 2array ; + '[ 2drop _ npick _ instance? [ _ ndup [ @ ] { } make dup [ insn-available? ] all? ] [ f f f ] if ] + #dup '[ % _ nnip ] + 2array ; MACRO: v-vector-op ( trials -- ) - [ 1 2 >vector-op-cond ] map '[ _ cond ] ; + [ 1 2 >vector-op-cond ] map '[ f f _ cond ] ; MACRO: vl-vector-op ( trials -- ) - [ 1 3 >vector-op-cond ] map '[ _ cond ] ; + [ 1 3 >vector-op-cond ] map '[ f f _ cond ] ; MACRO: vv-vector-op ( trials -- ) - [ 1 3 >vector-op-cond ] map '[ _ cond ] ; + [ 1 3 >vector-op-cond ] map '[ f f _ cond ] ; MACRO: vv-cc-vector-op ( trials -- ) - [ 2 4 >vector-op-cond ] map '[ _ cond ] ; + [ 2 4 >vector-op-cond ] map '[ f f _ cond ] ; MACRO: vvvv-vector-op ( trials -- ) - [ 1 5 >vector-op-cond ] map '[ _ cond ] ; + [ 1 5 >vector-op-cond ] map '[ f f _ cond ] ; ! Intrinsic code emission From 1d4d6f4ce8ba0a7af1643acd7ff11185f9553378 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 20 Mar 2010 10:57:04 -0700 Subject: [PATCH 436/713] factor code duplication in compiler.cfg.intrinsics.simd.backend --- .../compiler/cfg/intrinsics/simd/backend/backend.factor | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/basis/compiler/cfg/intrinsics/simd/backend/backend.factor b/basis/compiler/cfg/intrinsics/simd/backend/backend.factor index d090bc1a7c..2c2d1f1d3a 100644 --- a/basis/compiler/cfg/intrinsics/simd/backend/backend.factor +++ b/basis/compiler/cfg/intrinsics/simd/backend/backend.factor @@ -64,16 +64,19 @@ M: ##shr-vector-imm insn-available? rep>> %shr-vector-imm-reps member? ; M: ##horizontal-shl-vector-imm insn-available? rep>> %horizontal-shl-vector-imm-reps member? ; M: ##horizontal-shr-vector-imm insn-available? rep>> %horizontal-shr-vector-imm-reps member? ; +: [vector-op-checked] ( #dup quot -- quot ) + '[ _ ndup [ @ ] { } make dup [ insn-available? ] all? ] ; + GENERIC# >vector-op-cond 2 ( quot #pick #dup -- quotpair ) M:: callable >vector-op-cond ( quot #pick #dup -- quotpair ) - #dup quot '[ 2drop _ ndup [ @ ] { } make dup [ insn-available? ] all? ] + #dup quot [vector-op-checked] '[ 2drop @ ] #dup '[ % _ nnip ] 2array ; M:: pair >vector-op-cond ( pair #pick #dup -- quotpair ) pair first2 :> ( class quot ) - #pick class #dup quot - '[ 2drop _ npick _ instance? [ _ ndup [ @ ] { } make dup [ insn-available? ] all? ] [ f f f ] if ] + #pick class #dup quot [vector-op-checked] + '[ 2drop _ npick _ instance? _ [ f f f ] if ] #dup '[ % _ nnip ] 2array ; From 91c353ef60aaaea249d7cb4c95e1dec8088472f3 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 22 Mar 2010 16:55:35 -0700 Subject: [PATCH 437/713] tools.deploy: make deploy-console? and deploy-ui? independent config variables, so windows apps can be deployed without a console or the ui --- basis/tools/deploy/config/config.factor | 2 ++ basis/tools/deploy/windows/windows.factor | 2 +- basis/ui/tools/deploy/deploy.factor | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/basis/tools/deploy/config/config.factor b/basis/tools/deploy/config/config.factor index 89d1fe3821..aa3701dc85 100644 --- a/basis/tools/deploy/config/config.factor +++ b/basis/tools/deploy/config/config.factor @@ -7,6 +7,7 @@ IN: tools.deploy.config SYMBOL: deploy-name SYMBOL: deploy-ui? +SYMBOL: deploy-console? SYMBOL: deploy-math? SYMBOL: deploy-unicode? SYMBOL: deploy-threads? @@ -52,6 +53,7 @@ SYMBOL: deploy-image : default-config ( vocab -- assoc ) vocab-name deploy-name associate H{ { deploy-ui? f } + { deploy-console? t } { deploy-io 2 } { deploy-reflection 1 } { deploy-threads? t } diff --git a/basis/tools/deploy/windows/windows.factor b/basis/tools/deploy/windows/windows.factor index f52154ccd0..5945d9915c 100755 --- a/basis/tools/deploy/windows/windows.factor +++ b/basis/tools/deploy/windows/windows.factor @@ -21,7 +21,7 @@ CONSTANT: app-icon-resource-id "APPICON" : create-exe-dir ( vocab bundle-name -- vm ) dup copy-dll - deploy-ui? get ".exe" ".com" ? copy-vm ; + deploy-console? get ".exe" ".com" ? copy-vm ; : open-in-explorer ( dir -- ) [ f "open" ] dip absolute-path normalize-separators diff --git a/basis/ui/tools/deploy/deploy.factor b/basis/ui/tools/deploy/deploy.factor index cf6f1c066d..3a5f31bee3 100644 --- a/basis/ui/tools/deploy/deploy.factor +++ b/basis/ui/tools/deploy/deploy.factor @@ -14,6 +14,10 @@ TUPLE: deploy-gadget < pack vocab settings ; deploy-name get "Executable name:" label-on-left add-gadget ; +: deploy-console ( parent -- parent ) + deploy-console? get + "Deploy as Windows console application" add-gadget ; + : deploy-ui ( parent -- parent ) deploy-ui? get "Include user interface framework" add-gadget ; @@ -45,6 +49,7 @@ TUPLE: deploy-gadget < pack vocab settings ; bundle-name deploy-ui + deploy-console io-settings reflection-settings advanced-settings From 88e88207ffa978bc9f9b18536c0255268cddc6e9 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Tue, 23 Mar 2010 00:30:49 -0400 Subject: [PATCH 438/713] Fixing bug in regexp \P --- basis/regexp/parser/parser.factor | 2 +- basis/regexp/regexp-tests.factor | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/basis/regexp/parser/parser.factor b/basis/regexp/parser/parser.factor index 0025b89d56..a038351cb0 100644 --- a/basis/regexp/parser/parser.factor +++ b/basis/regexp/parser/parser.factor @@ -133,7 +133,7 @@ CharacterInBracket = !("}") Character QuotedCharacter = !("\\E") . Escape = "p{" CharacterInBracket*:s "}" => [[ s name>class ]] - | "P{" CharacterInBracket*:s "}" => [[ s name>class ]] + | "P{" CharacterInBracket*:s "}" => [[ s name>class ]] | "Q" QuotedCharacter*:s "\\E" => [[ s ]] | "u" Character:a Character:b Character:c Character:d => [[ { a b c d } hex> ensure-number ]] diff --git a/basis/regexp/regexp-tests.factor b/basis/regexp/regexp-tests.factor index 1f72fa04ba..2488f568da 100644 --- a/basis/regexp/regexp-tests.factor +++ b/basis/regexp/regexp-tests.factor @@ -530,3 +530,8 @@ IN: regexp-tests [ f ] [ "π" R/ [\p{script=latin}--\p{lower}]/ matches? ] unit-test [ t ] [ "A" R/ [\p{script=latin}--\p{lower}]/ matches? ] unit-test [ f ] [ "3" R/ [\p{script=latin}--\p{lower}]/ matches? ] unit-test + +[ t ] [ " " R/ \P{alpha}/ matches? ] unit-test +[ f ] [ "" R/ \P{alpha}/ matches? ] unit-test +[ f ] [ "a " R/ \P{alpha}/ matches? ] unit-test +[ f ] [ "a" R/ \P{alpha}/ matches? ] unit-test From f6561f3c03036670cabfd92a827e9ba1faab903c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 22 Mar 2010 22:32:00 -0700 Subject: [PATCH 439/713] delegate: add BROADCAST: syntax, delegate generic with no outputs to an array of multiple delegates --- basis/delegate/delegate-docs.factor | 16 ++++++++++---- basis/delegate/delegate-tests.factor | 17 ++++++++++++++- basis/delegate/delegate.factor | 31 +++++++++++++++++++++++----- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/basis/delegate/delegate-docs.factor b/basis/delegate/delegate-docs.factor index d4867714d3..451016cc6c 100644 --- a/basis/delegate/delegate-docs.factor +++ b/basis/delegate/delegate-docs.factor @@ -18,9 +18,16 @@ HELP: define-consult { $notes "Usually, " { $link POSTPONE: CONSULT: } " should be used instead. This is only for runtime use." } ; HELP: CONSULT: -{ $syntax "CONSULT: group class getter... ;" } -{ $values { "group" "a protocol, generic word or tuple class" } { "class" "a class" } { "getter" "code to get where the method should be forwarded" } } -{ $description "Defines a class to consult, using the given code, on the generic words contained in the group. This means that, when one of the words in the group is called on an object of this class, the quotation will be called, and then the generic word called again. If the getter is empty, this will cause an infinite loop. Consultation overwrites the existing methods, but others can be defined afterwards." } ; +{ $syntax """CONSULT: group class + code ;""" } +{ $values { "group" "a protocol, generic word or tuple class" } { "class" "a class" } { "code" "code to get the object to which the method should be forwarded" } } +{ $description "Declares that objects of " { $snippet "class" } " will delegate the generic words contained in " { $snippet "group" } " to the object returned by executing " { $snippet "code" } " with the original object as an input." { $snippet "CONSULT:" } " will overwrite any existing methods on " { $snippet "class" } " for the members of " { $snippet "group" } ", but new methods can be added after the " { $snippet "CONSULT:" } " to override the delegation." } ; + +HELP: BROADCAST: +{ $syntax """BROADCAST: group class + code ;""" } +{ $values { "group" "a protocol, generic word or tuple class" } { "class" "a class" } { "code" "code to get the object to which the method should be forwarded" } } +{ $description "Declares that objects of " { $snippet "class" } " will delegate the generic words contained in " { $snippet "group" } " to every object in the sequence returned by executing " { $snippet "code" } " with the original object as an input." { $snippet "BROADCAST:" } " will overwrite any existing methods on " { $snippet "class" } " for the members of " { $snippet "group" } ", but new methods can be added after the " { $snippet "BROADCAST:" } " to override the delegation. Every generic word in " { $snippet "group" } " must return no outputs; otherwise, a " { $link broadcast-words-must-have-no-outputs } " error will be raised." } ; HELP: SLOT-PROTOCOL: { $syntax "SLOT-PROTOCOL: protocol-name slots... ;" } @@ -28,7 +35,7 @@ HELP: SLOT-PROTOCOL: { define-protocol POSTPONE: PROTOCOL: } related-words -{ define-consult POSTPONE: CONSULT: } related-words +{ define-consult POSTPONE: BROADCAST: POSTPONE: CONSULT: } related-words HELP: group-words { $values { "group" "a group" } { "words" "an array of words" } } @@ -52,6 +59,7 @@ $nl { $subsections POSTPONE: SLOT-PROTOCOL: } "Defining consultation:" { $subsections + POSTPONE: BROADCAST: POSTPONE: CONSULT: define-consult } diff --git a/basis/delegate/delegate-tests.factor b/basis/delegate/delegate-tests.factor index 17f81708c5..4a280ef584 100644 --- a/basis/delegate/delegate-tests.factor +++ b/basis/delegate/delegate-tests.factor @@ -1,7 +1,7 @@ USING: delegate kernel arrays tools.test words math definitions compiler.units parser generic prettyprint io.streams.string accessors eval multiline generic.single delegate.protocols -delegate.private assocs see ; +delegate.private assocs see make ; IN: delegate.tests TUPLE: hello this that ; @@ -197,3 +197,18 @@ DEFER: seq-delegate sequence-protocol \ protocol-consult word-prop key? ] unit-test + +GENERIC: broadcastable ( x -- ) +GENERIC: nonbroadcastable ( x -- y ) + +TUPLE: broadcaster targets ; + +BROADCAST: broadcastable broadcaster targets>> ; + +M: integer broadcastable 1 + , ; + +[ "USING: accessors delegate ; IN: delegate.tests BROADCAST: nonbroadcastable broadcaster targets>> ;" eval( -- ) ] +[ error>> broadcast-words-must-have-no-outputs? ] must-fail-with + +[ { 2 3 4 } ] +[ { 1 2 3 } broadcaster boa [ broadcastable ] { } make ] unit-test diff --git a/basis/delegate/delegate.factor b/basis/delegate/delegate.factor index dc3024b55f..5c8703116d 100644 --- a/basis/delegate/delegate.factor +++ b/basis/delegate/delegate.factor @@ -1,12 +1,14 @@ ! Copyright (C) 2007, 2008 Daniel Ehrenberg -! Portions copyright (C) 2009 Slava Pestov +! Portions copyright (C) 2009, 2010 Slava Pestov, Joe Groff ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays assocs classes.tuple definitions generic +USING: accessors arrays assocs classes.tuple definitions effects generic generic.standard hashtables kernel lexer math parser generic.parser sequences sets slots words words.symbol fry compiler.units ; IN: delegate +ERROR: broadcast-words-must-have-no-outputs group ; + > empty? ] all? + [ broadcast-words-must-have-no-outputs ] unless ; + ! Consultation TUPLE: consultation group class quot loc ; +TUPLE: broadcast < consultation ; : ( group class quot -- consultation ) f consultation boa ; +: ( group class quot -- consultation ) + [ check-broadcast-group ] 2dip f broadcast boa ; : create-consult-method ( word consultation -- method ) [ class>> swap first create-method dup fake-definition ] keep @@ -44,13 +53,21 @@ PREDICATE: consult-method < method "consultation" word-prop ; M: consult-method reset-word [ call-next-method ] [ f "consultation" set-word-prop ] bi ; -: consult-method-quot ( quot word -- object ) +GENERIC# (consult-method-quot) 2 ( consultation quot word -- object ) + +M: consultation (consult-method-quot) + '[ _ call _ execute ] nip ; +M: broadcast (consult-method-quot) + '[ _ call [ _ execute ] each ] nip ; + +: consult-method-quot ( consultation word -- object ) + [ dup quot>> ] dip [ second [ [ dip ] curry ] times ] [ first ] bi - '[ _ call _ execute ] ; + (consult-method-quot) ; : consult-method ( word consultation -- ) [ create-consult-method ] - [ quot>> swap consult-method-quot ] 2bi + [ swap consult-method-quot ] 2bi define ; : change-word-prop ( word prop quot -- ) @@ -89,6 +106,10 @@ SYNTAX: CONSULT: scan-word scan-word parse-definition [ save-location ] [ define-consult ] bi ; +SYNTAX: BROADCAST: + scan-word scan-word parse-definition + [ save-location ] [ define-consult ] bi ; + M: consultation where loc>> ; M: consultation set-where (>>loc) ; From bc174332d1c410ab1c2c104eb29e04d558e9539b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 23 Mar 2010 01:55:50 -0400 Subject: [PATCH 440/713] irc.gitbot: don't stop the alarm if running git throws an error --- extra/irc/gitbot/gitbot.factor | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/extra/irc/gitbot/gitbot.factor b/extra/irc/gitbot/gitbot.factor index 0963765482..ccb96239ff 100644 --- a/extra/irc/gitbot/gitbot.factor +++ b/extra/irc/gitbot/gitbot.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: fry irc.client irc.client.chats kernel namespaces sequences threads io.launcher io splitting @@ -46,8 +46,10 @@ M: object handle-message drop ; '[ _ speak ] interleave ; : check-for-updates ( chat -- ) - [ git-id git-pull-cmd short-running-process git-id ] dip - report-updates ; + '[ + git-id git-pull-cmd short-running-process git-id + _ report-updates + ] try ; : bot ( -- ) start-bot From 3ffee52cadcf50dd919cd91d46897388939c193e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 23 Mar 2010 02:05:24 -0400 Subject: [PATCH 441/713] irc.gitbot: fix USING: --- extra/irc/gitbot/gitbot.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/irc/gitbot/gitbot.factor b/extra/irc/gitbot/gitbot.factor index ccb96239ff..2627e8d081 100644 --- a/extra/irc/gitbot/gitbot.factor +++ b/extra/irc/gitbot/gitbot.factor @@ -3,7 +3,7 @@ USING: fry irc.client irc.client.chats kernel namespaces sequences threads io.launcher io splitting make mason.common mason.updates calendar math alarms -io.encodings.8-bit.latin1 ; +io.encodings.8-bit.latin1 debugger ; IN: irc.gitbot : bot-profile ( -- obj ) From 76e1dc5c77413413d8ed1a9c2dd08ef4115bc7d3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 23 Mar 2010 02:22:28 -0400 Subject: [PATCH 442/713] irc.gitbot: new nickname --- extra/irc/gitbot/gitbot.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/irc/gitbot/gitbot.factor b/extra/irc/gitbot/gitbot.factor index 2627e8d081..950b34a8d7 100644 --- a/extra/irc/gitbot/gitbot.factor +++ b/extra/irc/gitbot/gitbot.factor @@ -7,7 +7,7 @@ io.encodings.8-bit.latin1 debugger ; IN: irc.gitbot : bot-profile ( -- obj ) - "irc.freenode.org" 6667 "jackass" f ; + "irc.freenode.org" 6667 "stackoid" f ; : bot-channel ( -- seq ) "#concatenative" ; From ffafafd951ada6137e3bd66ad7b0286fb2755cc7 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 23 Mar 2010 04:04:08 -0400 Subject: [PATCH 443/713] vm/mach_signal.c: work around Mac OS X 10.6 API change (or bug?) --- vm/mach_signal.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/vm/mach_signal.cpp b/vm/mach_signal.cpp index 3fa7dcbf07..5a96bdaf3f 100644 --- a/vm/mach_signal.cpp +++ b/vm/mach_signal.cpp @@ -82,11 +82,14 @@ static void call_fault_handler( MACH_THREAD_STATE_TYPE *thread_state, MACH_FLOAT_STATE_TYPE *float_state) { + /* Look up the VM instance involved */ THREADHANDLE thread_id = pthread_from_mach_thread_np(thread); assert(thread_id); std::map::const_iterator vm = thread_vms.find(thread_id); + + /* Handle the exception */ if (vm != thread_vms.end()) - vm->second->call_fault_handler(exception,code,exc_state,thread_state,float_state); + vm->second->call_fault_handler(exception,code,exc_state,thread_state,float_state); } /* Handle an exception by invoking the user's fault handler and/or forwarding @@ -100,15 +103,14 @@ catch_exception_raise (mach_port_t exception_port, exception_data_t code, mach_msg_type_number_t code_count) { - MACH_EXC_STATE_TYPE exc_state; - MACH_THREAD_STATE_TYPE thread_state; - MACH_FLOAT_STATE_TYPE float_state; - mach_msg_type_number_t exc_state_count, thread_state_count, float_state_count; + /* 10.6 likes to report exceptions from child processes too. Ignore those */ + if(task != mach_task_self()) return KERN_SUCCESS; /* Get fault information and the faulting thread's register contents.. See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/thread_get_state.html. */ - exc_state_count = MACH_EXC_STATE_COUNT; + MACH_EXC_STATE_TYPE exc_state; + mach_msg_type_number_t exc_state_count = MACH_EXC_STATE_COUNT; if (thread_get_state (thread, MACH_EXC_STATE_FLAVOR, (natural_t *)&exc_state, &exc_state_count) != KERN_SUCCESS) @@ -118,7 +120,8 @@ catch_exception_raise (mach_port_t exception_port, return KERN_FAILURE; } - thread_state_count = MACH_THREAD_STATE_COUNT; + MACH_THREAD_STATE_TYPE thread_state; + mach_msg_type_number_t thread_state_count = MACH_THREAD_STATE_COUNT; if (thread_get_state (thread, MACH_THREAD_STATE_FLAVOR, (natural_t *)&thread_state, &thread_state_count) != KERN_SUCCESS) @@ -128,7 +131,8 @@ catch_exception_raise (mach_port_t exception_port, return KERN_FAILURE; } - float_state_count = MACH_FLOAT_STATE_COUNT; + MACH_FLOAT_STATE_TYPE float_state; + mach_msg_type_number_t float_state_count = MACH_FLOAT_STATE_COUNT; if (thread_get_state (thread, MACH_FLOAT_STATE_FLAVOR, (natural_t *)&float_state, &float_state_count) != KERN_SUCCESS) From 14d1da94bb5f04211190667852a964405b83b0f1 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Wed, 17 Mar 2010 10:50:45 +0100 Subject: [PATCH 444/713] Use sets --- extra/astar/astar.factor | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extra/astar/astar.factor b/extra/astar/astar.factor index 45f8aaa86e..85b3108217 100644 --- a/extra/astar/astar.factor +++ b/extra/astar/astar.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2010 Samuel Tardieu. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs heaps kernel math sequences sets shuffle ; +USING: accessors assocs hash-sets heaps kernel math sequences sets shuffle ; IN: astar ! This implements the A* algorithm. See http://en.wikipedia.org/wiki/A* @@ -24,10 +24,10 @@ TUPLE: (astar) astar goal origin in-open-set open-set ; (add-to-open-set) ; : ?add-to-open-set ( node astar -- ) - 2dup astar>> in-closed-set>> key? [ 2drop ] [ add-to-open-set ] if ; + 2dup astar>> in-closed-set>> in? [ 2drop ] [ add-to-open-set ] if ; : move-to-closed-set ( node astar -- ) - [ astar>> in-closed-set>> conjoin ] [ in-open-set>> delete-at ] 2bi ; + [ astar>> in-closed-set>> adjoin ] [ in-open-set>> delete-at ] 2bi ; : get-first ( astar -- node ) [ open-set>> heap-pop drop dup ] [ move-to-closed-set ] bi ; @@ -58,7 +58,7 @@ TUPLE: (astar) astar goal origin in-open-set open-set ; : (init) ( from to astar -- ) swap >>goal H{ } clone over astar>> (>>g) - H{ } clone over astar>> (>>in-closed-set) + { } over astar>> (>>in-closed-set) H{ } clone >>origin H{ } clone >>in-open-set >>open-set @@ -78,4 +78,4 @@ PRIVATE> astar-simple new swap >>heuristic swap >>cost swap >>neighbours ; : considered ( astar -- considered ) - in-closed-set>> keys ; + in-closed-set>> members ; From 1e4e66d6a2b1154ebbab62bbeaf7b64dd91025fd Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 23 Mar 2010 04:17:39 -0400 Subject: [PATCH 445/713] vm: another fix --- vm/mach_signal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/mach_signal.cpp b/vm/mach_signal.cpp index 5a96bdaf3f..6295381b1c 100644 --- a/vm/mach_signal.cpp +++ b/vm/mach_signal.cpp @@ -104,7 +104,7 @@ catch_exception_raise (mach_port_t exception_port, mach_msg_type_number_t code_count) { /* 10.6 likes to report exceptions from child processes too. Ignore those */ - if(task != mach_task_self()) return KERN_SUCCESS; + if(task != mach_task_self()) return KERN_FAILURE; /* Get fault information and the faulting thread's register contents.. From f62d414bd15c8d128ce9414e28046e91069ca1c2 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Tue, 23 Mar 2010 09:30:48 +0100 Subject: [PATCH 446/713] Add some documentation precisions for astar --- extra/astar/astar-docs.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/astar/astar-docs.factor b/extra/astar/astar-docs.factor index d19166c1bf..7c474bdb57 100644 --- a/extra/astar/astar-docs.factor +++ b/extra/astar/astar-docs.factor @@ -62,8 +62,7 @@ HELP: find-path ", or f if no such path exists" } } { $description "Find a path between " { $snippet "start" } " and " { $snippet "target" } - " using the A* algorithm. The " { $snippet "astar" } " tuple must have been previously " - " built using " { $link } "." + " using the A* algorithm." } ; HELP: considered @@ -77,6 +76,7 @@ HELP: considered ARTICLE: "astar" "A* algorithm" "The " { $vocab-link "astar" } " vocabulary implements a graph search algorithm for finding the least-cost path from one node to another." $nl +"The " { $link astar } " tuple may be derived from and its " { $link cost } ", " { $link heuristic } ", and " { $link neighbours } " methods overwritten, or the " { $link } " word can be used to build such an object from quotations." $nl "Make an A* object:" { $subsections } "Find a path between nodes:" From 522f28d5a584415d3583e456a0e877b3afbcfa3c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 23 Mar 2010 05:07:44 -0400 Subject: [PATCH 447/713] webapps.planet: wrap feed updating within a with-logging form so that errors fetch-feed don't break everything. Previously if there was an error fetching a feed, the update task would just stop --- extra/webapps/planet/planet.factor | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extra/webapps/planet/planet.factor b/extra/webapps/planet/planet.factor index eb51acbe1a..a003c8b618 100644 --- a/extra/webapps/planet/planet.factor +++ b/extra/webapps/planet/planet.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel accessors sequences sorting math math.order calendar alarms logging concurrency.combinators namespaces @@ -194,4 +194,7 @@ posting "POSTINGS" { planet "planet-common" } >>template ; : start-update-task ( db -- ) - '[ _ [ update-cached-postings ] with-db ] 10 minutes every drop ; + '[ + "webapps.planet" + [ _ [ update-cached-postings ] with-db ] with-logging + ] 10 minutes every drop ; From 63bb6c4e4268731d93e5325d47b5dd4446abcad7 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Mar 2010 02:11:57 -0700 Subject: [PATCH 448/713] gpu: add geometry shader support --- extra/gpu/demos/raytrace/deploy.factor | 1 + extra/gpu/render/render.factor | 8 +++ extra/gpu/shaders/shaders.factor | 75 +++++++++++++++++++++++--- 3 files changed, 76 insertions(+), 8 deletions(-) diff --git a/extra/gpu/demos/raytrace/deploy.factor b/extra/gpu/demos/raytrace/deploy.factor index b01a64ccbc..2fec4f861f 100644 --- a/extra/gpu/demos/raytrace/deploy.factor +++ b/extra/gpu/demos/raytrace/deploy.factor @@ -3,6 +3,7 @@ H{ { deploy-name "Raytrace" } { deploy-ui? t } { deploy-c-types? f } + { deploy-console? f } { deploy-unicode? f } { "stop-after-last-window?" t } { deploy-io 2 } diff --git a/extra/gpu/render/render.factor b/extra/gpu/render/render.factor index 2b7d75a3ae..6e66832a2f 100755 --- a/extra/gpu/render/render.factor +++ b/extra/gpu/render/render.factor @@ -104,9 +104,13 @@ VARIANT: primitive-mode points-mode lines-mode line-strip-mode + lines-with-adjacency-mode + line-strip-with-adjacency-mode line-loop-mode triangles-mode triangle-strip-mode + triangles-with-adjacency-mode + triangle-strip-with-adjacency-mode triangle-fan-mode ; TUPLE: uniform-tuple ; @@ -131,6 +135,10 @@ ERROR: invalid-uniform-type uniform ; { triangles-mode [ GL_TRIANGLES ] } { triangle-strip-mode [ GL_TRIANGLE_STRIP ] } { triangle-fan-mode [ GL_TRIANGLE_FAN ] } + { lines-with-adjacency-mode [ GL_LINES_ADJACENCY ] } + { line-strip-with-adjacency-mode [ GL_LINE_STRIP_ADJACENCY ] } + { triangles-with-adjacency-mode [ GL_TRIANGLES_ADJACENCY ] } + { triangle-strip-with-adjacency-mode [ GL_TRIANGLE_STRIP_ADJACENCY ] } } case ; inline GENERIC: render-vertex-indexes ( primitive-mode vertex-indexes -- ) diff --git a/extra/gpu/shaders/shaders.factor b/extra/gpu/shaders/shaders.factor index 025acba896..8609a914bf 100755 --- a/extra/gpu/shaders/shaders.factor +++ b/extra/gpu/shaders/shaders.factor @@ -15,7 +15,18 @@ SPECIALIZED-ARRAY: void* IN: gpu.shaders VARIANT: shader-kind - vertex-shader fragment-shader ; + vertex-shader fragment-shader geometry-shader ; + +VARIANT: geometry-shader-input + points-input + lines-input + lines-with-adjacency-input + triangles-input + triangles-with-adjacency-input ; +VARIANT: geometry-shader-output + points-output + line-strips-output + triangle-strips-output ; UNION: ?string string POSTPONE: f ; @@ -47,6 +58,7 @@ TUPLE: program { shaders array read-only } { vertex-formats array read-only } { feedback-format ?vertex-format read-only } + { geometry-shader-parameters array read-only } { instances hashtable read-only } ; TUPLE: shader-instance < gpu-object @@ -197,6 +209,31 @@ TR: hyphens>underscores "-" "_" ; vertex-attributes [ [verify-feedback-attribute] ] map-index :> verify-cleave { drop verify-cleave cleave } >quotation ; +: gl-geometry-shader-input ( input -- input ) + { + { points-input [ GL_POINTS ] } + { lines-input [ GL_LINES ] } + { lines-with-adjacency-input [ GL_LINES_ADJACENCY ] } + { triangles-input [ GL_TRIANGLES ] } + { triangles-with-adjacency-input [ GL_TRIANGLES_ADJACENCY ] } + } case ; inline + +: gl-geometry-shader-output ( output -- output ) + { + { points-output [ GL_POINTS ] } + { line-strips-output [ GL_LINE_STRIP ] } + { triangle-strips-output [ GL_TRIANGLE_STRIP ] } + } case ; inline + +TUPLE: geometry-shader-vertices-out + { count integer read-only } ; + +UNION: geometry-shader-parameter + geometry-shader-input + geometry-shader-output + geometry-shader-vertices-out ; + + GENERIC: bind-vertex-format ( program-instance buffer-ptr format -- ) GENERIC: link-feedback-format ( program-handle format -- ) @@ -208,6 +245,18 @@ M: f link-feedback-format [ vertex-format-attributes [ name>> ] map sift ] map concat swap '[ [ _ ] 2dip swap glBindAttribLocation ] each-index ; +GENERIC: link-geometry-shader-parameter ( program-handle parameter -- ) + +M: geometry-shader-input link-geometry-shader-parameter + [ GL_GEOMETRY_INPUT_TYPE ] dip gl-geometry-shader-input glProgramParameteriARB ; +M: geometry-shader-output link-geometry-shader-parameter + [ GL_GEOMETRY_OUTPUT_TYPE ] dip gl-geometry-shader-output glProgramParameteriARB ; +M: geometry-shader-vertices-out link-geometry-shader-parameter + [ GL_GEOMETRY_VERTICES_OUT ] dip count>> glProgramParameteriARB ; + +: link-geometry-shader-parameters ( program-handle parameters -- ) + [ link-geometry-shader-parameter ] with each ; + GENERIC: (verify-feedback-format) ( program-instance format -- ) M: f (verify-feedback-format) @@ -293,7 +342,8 @@ padding-no [ 0 ] initialize { { vertex-shader [ GL_VERTEX_SHADER ] } { fragment-shader [ GL_FRAGMENT_SHADER ] } - } case ; + { geometry-shader [ GL_GEOMETRY_SHADER ] } + } case ; inline PRIVATE> @@ -433,8 +483,12 @@ DEFER: : (link-program) ( program shader-instances -- program-instance ) '[ _ [ handle>> ] map ] [ - [ vertex-formats>> ] [ feedback-format>> ] bi - '[ [ _ link-vertex-formats ] [ _ link-feedback-format ] bi ] + [ vertex-formats>> ] [ feedback-format>> ] [ geometry-shader-parameters>> ] tri + '[ + [ _ link-vertex-formats ] + [ _ link-feedback-format ] + [ _ link-geometry-shader-parameters ] tri + ] ] bi (gl-program) dup gl-program-ok? [ [ swap world get \ program-instance boa |dispose dup verify-feedback-format ] @@ -485,15 +539,20 @@ TUPLE: feedback-format : ?shader ( object -- shader/f ) dup word? [ def>> first dup shader? [ drop f ] unless ] [ drop f ] if ; -: shaders-and-formats ( words -- shaders vertex-formats feedback-format ) - [ [ ?shader ] map sift ] - [ [ vertex-format-attributes ] filter ] - [ [ feedback-format? ] filter validate-feedback-format ] tri ; +: shaders-and-formats ( words -- shaders vertex-formats feedback-format geom-parameters ) + { + [ [ ?shader ] map sift ] + [ [ vertex-format-attributes ] filter ] + [ [ feedback-format? ] filter validate-feedback-format ] + [ [ geometry-shader-parameter? ] filter ] + } cleave ; PRIVATE> SYNTAX: feedback-format: scan-object feedback-format boa suffix! ; +SYNTAX: geometry-shader-vertices-out: + scan-object geometry-shader-vertices-out boa suffix! ; TYPED:: refresh-program ( program: program -- ) program shaders>> [ refresh-shader-source ] each From 8e003bf239ddb15fd7ea52e5a17451aaf778c4b1 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Tue, 23 Mar 2010 09:52:51 +0100 Subject: [PATCH 449/713] Rename astar into path-finding --- extra/{astar => path-finding}/authors.txt | 0 .../path-finding-docs.factor} | 4 ++-- .../path-finding-tests.factor} | 6 +++--- .../astar.factor => path-finding/path-finding.factor} | 2 +- extra/{astar => path-finding}/summary.txt | 0 5 files changed, 6 insertions(+), 6 deletions(-) rename extra/{astar => path-finding}/authors.txt (100%) rename extra/{astar/astar-docs.factor => path-finding/path-finding-docs.factor} (94%) rename extra/{astar/astar-tests.factor => path-finding/path-finding-tests.factor} (94%) rename extra/{astar/astar.factor => path-finding/path-finding.factor} (99%) rename extra/{astar => path-finding}/summary.txt (100%) diff --git a/extra/astar/authors.txt b/extra/path-finding/authors.txt similarity index 100% rename from extra/astar/authors.txt rename to extra/path-finding/authors.txt diff --git a/extra/astar/astar-docs.factor b/extra/path-finding/path-finding-docs.factor similarity index 94% rename from extra/astar/astar-docs.factor rename to extra/path-finding/path-finding-docs.factor index 7c474bdb57..dd66e4f76a 100644 --- a/extra/astar/astar-docs.factor +++ b/extra/path-finding/path-finding-docs.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2010 Samuel Tardieu. ! See http://factorcode.org/license.txt for BSD license. USING: help.markup help.syntax ; -IN: astar +IN: path-finding HELP: astar { $description "This tuple must be subclassed and its method " { $link cost } ", " @@ -75,7 +75,7 @@ HELP: considered } ; ARTICLE: "astar" "A* algorithm" -"The " { $vocab-link "astar" } " vocabulary implements a graph search algorithm for finding the least-cost path from one node to another." $nl +"The " { $vocab-link "path-finding" } " vocabulary implements a graph search algorithm for finding the least-cost path from one node to another." $nl "The " { $link astar } " tuple may be derived from and its " { $link cost } ", " { $link heuristic } ", and " { $link neighbours } " methods overwritten, or the " { $link } " word can be used to build such an object from quotations." $nl "Make an A* object:" { $subsections } diff --git a/extra/astar/astar-tests.factor b/extra/path-finding/path-finding-tests.factor similarity index 94% rename from extra/astar/astar-tests.factor rename to extra/path-finding/path-finding-tests.factor index 6e2e2f4f1b..16614bb165 100644 --- a/extra/astar/astar-tests.factor +++ b/extra/path-finding/path-finding-tests.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2010 Samuel Tardieu. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays assocs astar combinators hashtables kernel literals math math.functions -math.vectors sequences sorting splitting strings tools.test ; -IN: astar.tests +USING: arrays assocs combinators hashtables kernel literals math math.functions +math.vectors path-finding sequences sorting splitting strings tools.test ; +IN: path-finding.tests ! Use a 10x9 maze (see below) to try to go from s to e, f or g. ! X means that a position is unreachable. diff --git a/extra/astar/astar.factor b/extra/path-finding/path-finding.factor similarity index 99% rename from extra/astar/astar.factor rename to extra/path-finding/path-finding.factor index 85b3108217..74e12e1e38 100644 --- a/extra/astar/astar.factor +++ b/extra/path-finding/path-finding.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2010 Samuel Tardieu. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs hash-sets heaps kernel math sequences sets shuffle ; -IN: astar +IN: path-finding ! This implements the A* algorithm. See http://en.wikipedia.org/wiki/A* diff --git a/extra/astar/summary.txt b/extra/path-finding/summary.txt similarity index 100% rename from extra/astar/summary.txt rename to extra/path-finding/summary.txt From b742df468b54ceeb26b94fd20944fbf643680717 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Tue, 23 Mar 2010 10:24:01 +0100 Subject: [PATCH 450/713] Add BFS search algorithm --- extra/path-finding/path-finding-docs.factor | 22 +++++++++++++++----- extra/path-finding/path-finding-tests.factor | 12 +++++++++-- extra/path-finding/path-finding.factor | 8 +++++++ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/extra/path-finding/path-finding-docs.factor b/extra/path-finding/path-finding-docs.factor index dd66e4f76a..46f1048ba7 100644 --- a/extra/path-finding/path-finding-docs.factor +++ b/extra/path-finding/path-finding-docs.factor @@ -3,6 +3,8 @@ USING: help.markup help.syntax ; IN: path-finding +{ } related-words + HELP: astar { $description "This tuple must be subclassed and its method " { $link cost } ", " { $link heuristic } ", and " { $link neighbours } " must be implemented. " @@ -53,6 +55,16 @@ HELP: "may not be as efficient as subclassing the " { $link astar } " tuple." } ; +HELP: +{ $values + { "neighbours" "an assoc" } + { "astar" "a astar tuple" } +} +{ $description "Build an astar object from the " { $snippet "neighbours" } " assoc. " + "When used with " { $link find-path } ", this astar tuple will use the breadth-first search (BFS) " + "path finding algorithm which is a particular case of the general A* algorithm." +} ; + HELP: find-path { $values { "start" "a node" } @@ -74,12 +86,12 @@ HELP: considered "which have been examined during the A* exploration." } ; -ARTICLE: "astar" "A* algorithm" -"The " { $vocab-link "path-finding" } " vocabulary implements a graph search algorithm for finding the least-cost path from one node to another." $nl -"The " { $link astar } " tuple may be derived from and its " { $link cost } ", " { $link heuristic } ", and " { $link neighbours } " methods overwritten, or the " { $link } " word can be used to build such an object from quotations." $nl +ARTICLE: "path-finding" "Path finding using the A* algorithm" +"The " { $vocab-link "path-finding" } " vocabulary implements a graph search algorithm for finding the least-cost path from one node to another using the A* algorithm." $nl +"The " { $link astar } " tuple may be derived from and its " { $link cost } ", " { $link heuristic } ", and " { $link neighbours } " methods overwritten, or the " { $link } " or " { $link } " words can be used to build a new tuple." $nl "Make an A* object:" -{ $subsections } +{ $subsections } "Find a path between nodes:" { $subsections find-path } ; -ABOUT: "astar" +ABOUT: "path-finding" diff --git a/extra/path-finding/path-finding-tests.factor b/extra/path-finding/path-finding-tests.factor index 16614bb165..11a047cb89 100644 --- a/extra/path-finding/path-finding-tests.factor +++ b/extra/path-finding/path-finding-tests.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2010 Samuel Tardieu. ! See http://factorcode.org/license.txt for BSD license. USING: arrays assocs combinators hashtables kernel literals math math.functions -math.vectors path-finding sequences sorting splitting strings tools.test ; +math.vectors memoize path-finding sequences sorting splitting strings tools.test ; IN: path-finding.tests ! Use a 10x9 maze (see below) to try to go from s to e, f or g. @@ -97,8 +97,10 @@ M: maze cost ! In this version, we will use the quotations-aware version through . +MEMO: routes ( -- hash ) $[ { "ABD" "BC" "C" "DCE" "ECF" } [ unclip swap 2array ] map >hashtable ] ; + : n ( pos -- neighbours ) - $[ { "ABD" "BC" "C" "DCE" "ECF" } [ unclip swap 2array ] map >hashtable ] at ; + routes at ; : c ( from to -- cost ) "" 2sequence H{ { "AB" 1 } { "AD" 2 } { "BC" 5 } { "DC" 2 } { "DE" 1 } { "EC" 2 } { "EF" 1 } } at ; @@ -112,3 +114,9 @@ M: maze cost ! No path from D to B -- all nodes reachable from D must have been examined [ f "CDEF" ] [ "DB" test2 ] unit-test + +! Find a path using BFS. There are no path from F to A, and the path from D to +! C does not include any other node. + +[ f ] [ "FA" first2 routes find-path ] unit-test +[ "DC" ] [ "DC" first2 routes find-path >string ] unit-test diff --git a/extra/path-finding/path-finding.factor b/extra/path-finding/path-finding.factor index 74e12e1e38..3188013940 100644 --- a/extra/path-finding/path-finding.factor +++ b/extra/path-finding/path-finding.factor @@ -69,6 +69,11 @@ M: astar-simple cost cost>> call( n1 n2 -- c ) ; M: astar-simple heuristic heuristic>> call( n1 n2 -- c ) ; M: astar-simple neighbours neighbours>> call( n -- neighbours ) ; +TUPLE: bfs < astar neighbours ; +M: bfs cost 3drop 1 ; +M: bfs heuristic 3drop 0 ; +M: bfs neighbours neighbours>> at ; + PRIVATE> : find-path ( start target astar -- path/f ) @@ -79,3 +84,6 @@ PRIVATE> : considered ( astar -- considered ) in-closed-set>> members ; + +: ( neighbours -- astar ) + [ bfs new ] dip >>neighbours ; From 305ea844dece4d19313eadd99f04c44e3dfadcf6 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Mar 2010 15:32:16 -0700 Subject: [PATCH 451/713] tools.deploy.windows: got the "com" and "exe" backwards for deploy-console? flag --- basis/tools/deploy/windows/windows.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/tools/deploy/windows/windows.factor b/basis/tools/deploy/windows/windows.factor index 5945d9915c..f592ff2d69 100755 --- a/basis/tools/deploy/windows/windows.factor +++ b/basis/tools/deploy/windows/windows.factor @@ -21,7 +21,7 @@ CONSTANT: app-icon-resource-id "APPICON" : create-exe-dir ( vocab bundle-name -- vm ) dup copy-dll - deploy-console? get ".exe" ".com" ? copy-vm ; + deploy-console? get ".com" ".exe" ? copy-vm ; : open-in-explorer ( dir -- ) [ f "open" ] dip absolute-path normalize-separators From ab148a85e0bc30ec6f111f032cbe1cc7b3e2069c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 23 Mar 2010 17:54:47 -0700 Subject: [PATCH 452/713] proof of concept new "cursors" framework --- extra/cursors/authors.txt | 2 +- extra/cursors/cursors-tests.factor | 84 ++++-- extra/cursors/cursors.factor | 457 ++++++++++++++++++++++------- 3 files changed, 403 insertions(+), 140 deletions(-) diff --git a/extra/cursors/authors.txt b/extra/cursors/authors.txt index b4bd0e7b35..f13c9c1e77 100644 --- a/extra/cursors/authors.txt +++ b/extra/cursors/authors.txt @@ -1 +1 @@ -Doug Coleman \ No newline at end of file +Joe Groff diff --git a/extra/cursors/cursors-tests.factor b/extra/cursors/cursors-tests.factor index 8821d4570c..158769ff14 100644 --- a/extra/cursors/cursors-tests.factor +++ b/extra/cursors/cursors-tests.factor @@ -1,44 +1,68 @@ -! Copyright (C) 2009 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: cursors math tools.test make ; +! (c)2010 Joe Groff bsd license +USING: accessors cursors make math sequences sorting tools.test ; +FROM: cursors => each map assoc-each assoc>map ; IN: cursors.tests -[ 2 t ] [ { 2 3 } [ even? ] find ] unit-test -[ 3 t ] [ { 2 3 } [ odd? ] find ] unit-test -[ f f ] [ { 2 4 } [ odd? ] find ] unit-test +[ { 1 2 3 4 } ] [ + [ T{ linear-cursor f 1 1 } T{ linear-cursor f 5 1 } [ value>> , ] -each ] + { } make +] unit-test -[ { 2 3 } ] [ { 1 2 } [ 1 + ] map ] unit-test -[ { 2 3 } ] [ { 1 2 } [ [ 1 + , ] each ] { 2 3 } make ] unit-test +[ { 1 3 } ] [ + [ T{ linear-cursor f 1 2 } T{ linear-cursor f 5 2 } [ value>> , ] -each ] + { } make +] unit-test -[ t ] [ { } [ odd? ] all? ] unit-test -[ t ] [ { 1 3 5 } [ odd? ] all? ] unit-test -[ f ] [ { 1 3 5 6 } [ odd? ] all? ] unit-test +[ B{ 1 2 3 4 5 } ] [ [ { 1 2 3 4 5 } [ , ] each ] B{ } make ] unit-test +[ B{ } ] [ [ { } [ , ] each ] B{ } make ] unit-test +[ { 2 4 6 8 10 } ] [ { 1 2 3 4 5 } [ 2 * ] map ] unit-test -[ t ] [ { } [ odd? ] all? ] unit-test -[ t ] [ { 1 3 5 } [ odd? ] any? ] unit-test -[ f ] [ { 2 4 6 } [ odd? ] any? ] unit-test +[ { "roses: lutefisk" "tulips: lox" } ] +[ + [ + { { "roses" "lutefisk" } { "tulips" "lox" } } + [ ": " glue , ] assoc-each + ] { } make +] unit-test -[ { 1 3 5 } ] [ { 1 2 3 4 5 6 } [ odd? ] filter ] unit-test +[ { "roses: lutefisk" "tulips: lox" } ] +[ + { { "roses" "lutefisk" } { "tulips" "lox" } } + [ ": " glue ] { } assoc>map +] unit-test -[ { } ] -[ { 1 2 } { } [ + ] 2map ] unit-test +[ { "roses: lutefisk" "tulips: lox" } ] +[ + [ + H{ { "roses" "lutefisk" } { "tulips" "lox" } } + [ ": " glue , ] assoc-each + ] { } make natural-sort +] unit-test -[ { 11 } ] -[ { 1 2 } { 10 } [ + ] 2map ] unit-test +[ { "roses: lutefisk" "tulips: lox" } ] +[ + H{ { "roses" "lutefisk" } { "tulips" "lox" } } + [ ": " glue ] { } assoc>map natural-sort +] unit-test -[ { 11 22 } ] -[ { 1 2 } { 10 20 } [ + ] 2map ] unit-test +: compile-test-each ( xs -- ) + [ , ] each ; -[ { } ] -[ { 1 2 } { } { } [ + + ] 3map ] unit-test +: compile-test-map ( xs -- ys ) + [ 2 * ] map ; -[ { 111 } ] -[ { 1 2 } { 10 } { 100 200 } [ + + ] 3map ] unit-test +: compile-test-assoc-each ( xs -- ) + [ ": " glue , ] assoc-each ; -[ { 111 222 } ] -[ { 1 2 } { 10 20 } { 100 200 } [ + + ] 3map ] unit-test +: compile-test-assoc>map ( xs -- ys ) + [ ": " glue ] { } assoc>map ; -: test-3map ( -- seq ) - { 1 2 } { 10 20 } { 100 200 } [ + + ] 3map ; +[ B{ 1 2 3 4 5 } ] [ [ { 1 2 3 4 5 } compile-test-each ] B{ } make ] unit-test +[ { 2 4 6 8 10 } ] [ { 1 2 3 4 5 } compile-test-map ] unit-test + +[ { "roses: lutefisk" "tulips: lox" } ] +[ [ { { "roses" "lutefisk" } { "tulips" "lox" } } compile-test-assoc-each ] { } make ] unit-test + +[ { "roses: lutefisk" "tulips: lox" } ] +[ { { "roses" "lutefisk" } { "tulips" "lox" } } compile-test-assoc>map ] unit-test -[ { 111 222 } ] [ test-3map ] unit-test diff --git a/extra/cursors/cursors.factor b/extra/cursors/cursors.factor index 77defb081d..b93a7bb645 100644 --- a/extra/cursors/cursors.factor +++ b/extra/cursors/cursors.factor @@ -1,153 +1,392 @@ -! Copyright (C) 2009 Slava Pestov, Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays generalizations kernel math sequences -sequences.private fry ; +! (c)2010 Joe Groff bsd license +USING: accessors assocs combinators.short-circuit fry hashtables +kernel locals math math.functions sequences sequences.private ; +FROM: hashtables.private => tombstone? ; IN: cursors -GENERIC: cursor-done? ( cursor -- ? ) -GENERIC: cursor-get-unsafe ( cursor -- obj ) -GENERIC: cursor-advance ( cursor -- ) +! +! basic cursor protocol +! + +MIXIN: cursor + +GENERIC: cursor-compatible? ( cursor cursor -- ? ) GENERIC: cursor-valid? ( cursor -- ? ) -GENERIC: cursor-write ( obj cursor -- ) +GENERIC: cursor= ( cursor cursor -- ? ) +GENERIC: cursor<= ( cursor cursor -- ? ) +GENERIC: cursor>= ( cursor cursor -- ? ) +GENERIC: cursor-distance-hint ( cursor cursor -- n ) -ERROR: cursor-ended cursor ; +M: cursor cursor<= cursor= ; inline +M: cursor cursor>= cursor= ; inline +M: cursor cursor-distance-hint 2drop 0 ; inline -: cursor-get ( cursor -- obj ) - dup cursor-done? - [ cursor-ended ] [ cursor-get-unsafe ] if ; inline +! +! cursor iteration +! -: find-done? ( cursor quot -- ? ) - over cursor-done? - [ 2drop t ] [ [ cursor-get-unsafe ] dip call ] if ; inline +MIXIN: forward-cursor +INSTANCE: forward-cursor cursor -: cursor-until ( cursor quot -- ) - [ find-done? not ] - [ drop cursor-advance ] bi-curry bi-curry while ; inline - -: cursor-each ( cursor quot -- ) - [ f ] compose cursor-until ; inline +GENERIC: inc-cursor ( cursor -- cursor' ) -: cursor-find ( cursor quot -- obj ? ) - [ cursor-until ] [ drop ] 2bi - dup cursor-done? [ drop f f ] [ cursor-get t ] if ; inline +MIXIN: bidirectional-cursor +INSTANCE: bidirectional-cursor forward-cursor -: cursor-any? ( cursor quot -- ? ) - cursor-find nip ; inline +GENERIC: dec-cursor ( cursor -- cursor' ) -: cursor-all? ( cursor quot -- ? ) - [ not ] compose cursor-any? not ; inline +MIXIN: random-access-cursor +INSTANCE: random-access-cursor bidirectional-cursor -: cursor-map-quot ( quot to -- quot' ) - [ [ call ] dip cursor-write ] 2curry ; inline +GENERIC# cursor+ 1 ( cursor n -- cursor' ) +GENERIC# cursor- 1 ( cursor n -- cursor' ) +GENERIC: cursor-distance ( cursor cursor -- n ) +GENERIC: cursor< ( cursor cursor -- ? ) +GENERIC: cursor> ( cursor cursor -- ? ) -: cursor-map ( from to quot -- ) - swap cursor-map-quot cursor-each ; inline +M: random-access-cursor inc-cursor 1 cursor+ ; inline +M: random-access-cursor dec-cursor -1 cursor+ ; inline +M: random-access-cursor cursor- neg cursor+ ; inline +M: random-access-cursor cursor<= { [ cursor= ] [ cursor< ] } 2|| ; inline +M: random-access-cursor cursor>= { [ cursor= ] [ cursor> ] } 2|| ; inline +M: random-access-cursor cursor-distance-hint cursor-distance ; inline -: cursor-write-if ( obj quot to -- ) - [ over [ call ] dip ] dip - [ cursor-write ] 2curry when ; inline +! +! input cursors +! -: cursor-filter-quot ( quot to -- quot' ) - [ cursor-write-if ] 2curry ; inline +ERROR: invalid-cursor cursor ; -: cursor-filter ( from to quot -- ) - swap cursor-filter-quot cursor-each ; inline +MIXIN: input-cursor -TUPLE: from-sequence { seq sequence } { n integer } ; +GENERIC: cursor-value ( cursor -- value ) + +M: input-cursor cursor-value-unsafe cursor-value ; inline +M: input-cursor cursor-value + dup cursor-valid? [ cursor-value-unsafe ] [ invalid-cursor ] if ; inline -: >from-sequence< ( from-sequence -- n seq ) - [ n>> ] [ seq>> ] bi ; inline +! +! output cursors +! -M: from-sequence cursor-done? ( cursor -- ? ) - >from-sequence< length >= ; +MIXIN: output-cursor -M: from-sequence cursor-valid? - >from-sequence< bounds-check? not ; +GENERIC: set-cursor-value ( value cursor -- ) + +M: output-cursor set-cursor-value-unsafe set-cursor-value ; inline +M: output-cursor set-cursor-value + dup cursor-valid? [ set-cursor-value-unsafe ] [ invalid-cursor ] if ; inline -M: from-sequence cursor-get-unsafe - >from-sequence< nth-unsafe ; +! +! basic iterator +! -M: from-sequence cursor-advance - [ 1 + ] change-n drop ; +: -each ( ... begin end quot: ( ... cursor -- ... ) -- ... ) + [ '[ dup _ cursor>= ] ] + [ '[ _ keep inc-cursor ] ] bi* until drop ; inline -: >input ( seq -- cursor ) - 0 from-sequence boa ; inline +! +! numeric cursors +! -: iterate ( seq quot iterator -- ) - [ >input ] 2dip call ; inline +TUPLE: numeric-cursor + { value read-only } ; -: each ( seq quot -- ) [ cursor-each ] iterate ; inline -: find ( seq quot -- ? ) [ cursor-find ] iterate ; inline -: any? ( seq quot -- ? ) [ cursor-any? ] iterate ; inline -: all? ( seq quot -- ? ) [ cursor-all? ] iterate ; inline +M: numeric-cursor cursor-valid? drop t ; inline -TUPLE: to-sequence { seq sequence } { exemplar sequence } ; +M: numeric-cursor cursor= [ value>> ] bi@ = ; inline -M: to-sequence cursor-write - seq>> push ; +M: numeric-cursor cursor<= [ value>> ] bi@ <= ; inline +M: numeric-cursor cursor< [ value>> ] bi@ < ; inline +M: numeric-cursor cursor> [ value>> ] bi@ > ; inline +M: numeric-cursor cursor>= [ value>> ] bi@ >= ; inline -: freeze ( cursor -- seq ) - [ seq>> ] [ exemplar>> ] bi like ; inline +INSTANCE: numeric-cursor input-cursor -: >output ( seq -- cursor ) - [ [ length ] keep new-resizable ] keep - to-sequence boa ; inline +M: numeric-cursor cursor-value value>> ; inline -: transform ( seq quot transformer -- newseq ) - [ [ >input ] [ >output ] bi ] 2dip - [ call ] - [ 2drop freeze ] 3bi ; inline +! +! linear cursor +! -: map ( seq quot -- ) [ cursor-map ] transform ; inline -: filter ( seq quot -- newseq ) [ cursor-filter ] transform ; inline +TUPLE: linear-cursor < numeric-cursor + { delta read-only } ; +C: linear-cursor -: find-done2? ( cursor cursor quot -- ? ) - 2over [ cursor-done? ] either? - [ 3drop t ] [ [ [ cursor-get-unsafe ] bi@ ] dip call ] if ; inline +INSTANCE: linear-cursor random-access-cursor -: cursor-until2 ( cursor cursor quot -- ) - [ find-done2? not ] - [ drop [ cursor-advance ] bi@ ] bi-curry bi-curry bi-curry while ; inline +M: linear-cursor cursor-compatible? + [ linear-cursor? ] both? ; inline -: cursor-each2 ( cursor cursor quot -- ) - [ f ] compose cursor-until2 ; inline +M: linear-cursor inc-cursor + [ value>> ] [ delta>> ] bi [ + ] keep ; inline +M: linear-cursor dec-cursor + [ value>> ] [ delta>> ] bi [ - ] keep ; inline +M: linear-cursor cursor+ + [ [ value>> ] [ delta>> ] bi ] dip [ * + ] keep ; inline +M: linear-cursor cursor- + [ [ value>> ] [ delta>> ] bi ] dip [ * - ] keep ; inline -: cursor-map2 ( from to quot -- ) - swap cursor-map-quot cursor-each2 ; inline +GENERIC: up/i ( distance delta -- distance' ) +M: integer up/i [ 1 - + ] keep /i ; inline +M: real up/i / ceiling >integer ; inline -: iterate2 ( seq1 seq2 quot iterator -- ) - [ [ >input ] bi@ ] 2dip call ; inline +M: linear-cursor cursor-distance + [ [ value>> ] bi@ - ] [ nip delta>> ] 2bi up/i ; inline -: transform2 ( seq1 seq2 quot transformer -- newseq ) - [ over >output [ [ >input ] [ >input ] bi* ] dip ] 2dip - [ call ] - [ 2drop nip freeze ] 4 nbi ; inline +! +! quadratic cursor +! -: 2each ( seq1 seq2 quot -- ) [ cursor-each2 ] iterate2 ; inline -: 2map ( seq1 seq2 quot -- ) [ cursor-map2 ] transform2 ; inline +TUPLE: quadratic-cursor < numeric-cursor + { delta read-only } + { delta2 read-only } ; -: find-done3? ( cursor1 cursor2 cursor3 quot -- ? ) - [ 3 ndrop t ] swap '[ [ cursor-get-unsafe ] tri@ @ ] - [ 3 ndup 3 narray [ cursor-done? ] any? ] 2dip if ; inline +C: quadratic-cursor -: cursor-until3 ( cursor cursor quot -- ) - [ find-done3? not ] - [ drop [ cursor-advance ] tri@ ] - bi-curry bi-curry bi-curry bi-curry while ; inline +INSTANCE: quadratic-cursor bidirectional-cursor -: cursor-each3 ( cursor cursor quot -- ) - [ f ] compose cursor-until3 ; inline +M: quadratic-cursor cursor-compatible? + [ linear-cursor? ] both? ; inline -: cursor-map3 ( from to quot -- ) - swap cursor-map-quot cursor-each3 ; inline +M: quadratic-cursor inc-cursor + [ value>> ] [ delta>> [ + ] keep ] [ delta2>> [ + ] keep ] tri ; inline -: iterate3 ( seq1 seq2 seq3 quot iterator -- ) - [ [ >input ] tri@ ] 2dip call ; inline +M: quadratic-cursor dec-cursor + [ value>> ] [ delta>> ] [ delta2>> ] tri [ - [ - ] keep ] keep ; inline -: transform3 ( seq1 seq2 seq3 quot transformer -- newseq ) - [ pick >output [ [ >input ] [ >input ] [ >input ] tri* ] dip ] 2dip - [ call ] - [ 2drop 2nip freeze ] 5 nbi ; inline +! +! collections +! -: 3each ( seq1 seq2 seq3 quot -- ) [ cursor-each3 ] iterate3 ; inline -: 3map ( seq1 seq2 seq3 quot -- ) [ cursor-map3 ] transform3 ; inline +MIXIN: collection + +GENERIC: begin-cursor ( collection -- cursor ) +GENERIC: end-cursor ( collection -- cursor ) + +: all- ( collection quot -- begin end quot ) + [ [ begin-cursor ] [ end-cursor ] bi ] dip ; inline + +! +! containers +! + +MIXIN: container +INSTANCE: container collection + +: -container- ( quot -- quot' ) + '[ cursor-value-unsafe @ ] ; inline + +: container- ( container quot -- begin end quot' ) + all- -container- ; inline + +: each ( ... container quot: ( ... x -- ... ) -- ... ) container- -each ; inline + +! +! sequence cursor +! + +TUPLE: sequence-cursor + { seq read-only } + { n fixnum read-only } ; +C: sequence-cursor + +INSTANCE: sequence container + +M: sequence begin-cursor 0 ; inline +M: sequence end-cursor dup length ; inline + +INSTANCE: sequence-cursor random-access-cursor + +M: sequence-cursor cursor-compatible? + { + [ [ sequence-cursor? ] both? ] + [ [ seq>> ] bi@ eq? ] + } 2&& ; inline + +M: sequence-cursor cursor-valid? + [ n>> ] [ seq>> ] bi bounds-check? ; inline + +M: sequence-cursor cursor= [ n>> ] bi@ = ; inline +M: sequence-cursor cursor<= [ n>> ] bi@ <= ; inline +M: sequence-cursor cursor>= [ n>> ] bi@ >= ; inline +M: sequence-cursor cursor< [ n>> ] bi@ < ; inline +M: sequence-cursor cursor> [ n>> ] bi@ > ; inline +M: sequence-cursor inc-cursor [ seq>> ] [ n>> ] bi 1 + ; inline +M: sequence-cursor dec-cursor [ seq>> ] [ n>> ] bi 1 - ; inline +M: sequence-cursor cursor+ [ [ seq>> ] [ n>> ] bi ] dip + ; inline +M: sequence-cursor cursor- [ [ seq>> ] [ n>> ] bi ] dip - ; inline +M: sequence-cursor cursor-distance ( cursor cursor -- n ) + [ n>> ] bi@ - ; inline + +INSTANCE: sequence-cursor input-cursor + +M: sequence-cursor cursor-value-unsafe [ n>> ] [ seq>> ] bi nth-unsafe ; inline +M: sequence-cursor cursor-value [ n>> ] [ seq>> ] bi nth ; inline + +INSTANCE: sequence-cursor output-cursor + +M: sequence-cursor set-cursor-value-unsafe [ n>> ] [ seq>> ] bi set-nth-unsafe ; inline +M: sequence-cursor set-cursor-value [ n>> ] [ seq>> ] bi set-nth ; inline + +! +! pipe cursor +! + +TUPLE: pipe-cursor + { from read-only } + { to read-only } ; +C: pipe-cursor + +INSTANCE: pipe-cursor forward-cursor + +M: pipe-cursor cursor-compatible? [ from>> ] bi@ cursor-compatible? ; inline +M: pipe-cursor cursor-valid? [ from>> ] [ to>> ] bi [ cursor-valid? ] both? ; inline +M: pipe-cursor cursor= [ from>> ] bi@ cursor= ; inline +M: pipe-cursor inc-cursor [ from>> inc-cursor ] [ to>> inc-cursor ] bi ; inline + +INSTANCE: pipe-cursor output-cursor + +M: pipe-cursor set-cursor-value-unsafe to>> set-cursor-value-unsafe ; inline +M: pipe-cursor set-cursor-value to>> set-cursor-value ; inline + +: -pipe- ( begin end quot to -- begin' end' quot' ) + swap [ '[ _ ] bi@ ] dip '[ from>> @ ] ; inline + +! +! pusher cursor +! + +TUPLE: pusher-cursor + { growable read-only } ; +C: pusher-cursor + +INSTANCE: pusher-cursor forward-cursor + +! XXX define a protocol for stream cursors that don't actually move +M: pusher-cursor cursor-compatible? 2drop f ; inline +M: pusher-cursor cursor-valid? drop t ; inline +M: pusher-cursor cursor= 2drop f ; inline +M: pusher-cursor inc-cursor ; inline + +INSTANCE: pusher-cursor output-cursor + +M: pusher-cursor set-cursor-value growable>> push ; inline + +! +! Create cursors into new sequences +! + +: new-growable-cursor ( begin end exemplar -- cursor result ) + [ swap cursor-distance-hint ] dip new-resizable [ ] keep ; inline + +GENERIC# new-sequence-cursor 1 ( begin end exemplar -- cursor result ) + +M: random-access-cursor new-sequence-cursor + [ swap cursor-distance ] dip new-sequence [ begin-cursor ] keep ; inline +M: forward-cursor new-sequence-cursor + new-growable-cursor ; inline + +: -into-sequence- ( begin end quot exemplar -- begin' end' quot' result ) + swap [ [ 2dup ] dip new-sequence-cursor ] dip swap [ swap -pipe- ] dip ; inline + +: -into-growable- ( begin end quot exemplar -- begin' end' quot' result ) + swap [ [ 2dup ] dip new-growable-cursor ] dip swap [ swap -pipe- ] dip ; inline + +! +! map +! + +: -map- ( quot -- quot' ) + '[ _ keep set-cursor-value-unsafe ] ; inline + +: -map ( ... begin end quot: ( ... cursor -- ... value ) -- ... ) + -map- -each ; inline + +! XXX generalize exemplar +: -map-as ( ... begin end quot: ( ... cursor -- ... value ) exemplar -- ... newseq ) + [ -into-sequence- [ -map ] dip ] keep like ; inline + +: map! ( ... container quot: ( ... x -- ... newx ) -- ... container ) + [ container- -map ] keep ; inline +: map-as ( ... container quot: ( ... x -- ... newx ) exemplar -- ... newseq ) + [ container- ] dip -map-as ; inline +: map ( ... container quot: ( ... x -- ... newx ) -- ... newcontainer ) + over map-as ; inline + +! +! assoc cursors +! + +MIXIN: assoc-cursor + +GENERIC: cursor-key-value ( cursor -- key value ) + +: -assoc- ( quot -- quot' ) + '[ cursor-key-value @ ] ; inline + +: assoc- ( assoc quot -- begin end quot' ) + all- -assoc- ; inline + +: assoc-each ( ... assoc quot: ( ... k v -- ... ) -- ... ) + assoc- -each ; inline +: assoc>map ( ... assoc quot: ( ... k v -- ... newx ) exemplar -- ... newcontainer ) + [ assoc- ] dip -map-as ; inline + +INSTANCE: input-cursor assoc-cursor + +M: input-cursor cursor-key-value + cursor-value first2 ; inline + +! +! hashtable cursor +! + +TUPLE: hashtable-cursor + { hashtable hashtable read-only } + { n fixnum read-only } ; + hashtable-cursor +PRIVATE> + +INSTANCE: hashtable-cursor forward-cursor + +M: hashtable-cursor cursor-compatible? + { + [ [ hashtable-cursor? ] both? ] + [ [ hashtable>> ] bi@ eq? ] + } 2&& ; inline + +M: hashtable-cursor cursor-valid? ( cursor -- ? ) + [ n>> ] [ hashtable>> array>> ] bi bounds-check? ; inline + +M: hashtable-cursor cursor= ( cursor cursor -- ? ) + [ n>> ] bi@ = ; inline +M: hashtable-cursor cursor-distance-hint ( cursor cursor -- n ) + nip hashtable>> assoc-size ; inline + + + +M: hashtable-cursor inc-cursor ( cursor -- cursor' ) + [ hashtable>> dup array>> ] [ n>> 2 + ] bi + (inc-hashtable-cursor) ; inline + +INSTANCE: hashtable-cursor assoc-cursor + +M: hashtable-cursor cursor-key-value + [ n>> ] [ hashtable>> array>> ] bi + [ nth-unsafe ] [ [ 1 + ] dip nth-unsafe ] 2bi ; inline + +INSTANCE: hashtable collection + +M: hashtable begin-cursor + dup array>> 0 (inc-hashtable-cursor) ; inline +M: hashtable end-cursor + dup array>> length ; inline From cd3bffee345a515712f8b2e9dd6726547f8f6340 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 24 Mar 2010 13:04:14 -0700 Subject: [PATCH 453/713] cursors: set up some "stream cursor" mixin and change pusher-cursor to use them --- extra/cursors/cursors.factor | 60 ++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/extra/cursors/cursors.factor b/extra/cursors/cursors.factor index b93a7bb645..a706f043ce 100644 --- a/extra/cursors/cursors.factor +++ b/extra/cursors/cursors.factor @@ -1,6 +1,7 @@ ! (c)2010 Joe Groff bsd license -USING: accessors assocs combinators.short-circuit fry hashtables -kernel locals math math.functions sequences sequences.private ; +USING: accessors arrays assocs combinators.short-circuit fry +hashtables kernel locals math math.functions sequences ; +FROM: sequences.private => nth-unsafe set-nth-unsafe ; FROM: hashtables.private => tombstone? ; IN: cursors @@ -81,6 +82,40 @@ M: output-cursor set-cursor-value-unsafe set-cursor-value ; inline M: output-cursor set-cursor-value dup cursor-valid? [ set-cursor-value-unsafe ] [ invalid-cursor ] if ; inline +! +! stream cursors +! + +MIXIN: stream-cursor +INSTANCE: stream-cursor forward-cursor + +M: stream-cursor cursor-compatible? 2drop f ; inline +M: stream-cursor cursor-valid? drop t ; inline +M: stream-cursor cursor= 2drop f ; inline + +MIXIN: infinite-stream-cursor +INSTANCE: infinite-stream-cursor stream-cursor + +M: infinite-stream-cursor inc-cursor ; inline + +MIXIN: finite-stream-cursor +INSTANCE: finite-stream-cursor stream-cursor + +SINGLETON: end-of-stream + +GENERIC: cursor-stream-ended? ( cursor -- ? ) + +M: finite-stream-cursor inc-cursor + dup cursor-stream-ended? [ drop end-of-stream ] when ; inline + +INSTANCE: end-of-stream finite-stream-cursor + +M: end-of-stream cursor-compatible? drop finite-stream-cursor? ; inline +M: end-of-stream cursor-valid? drop f ; inline +M: end-of-stream cursor= eq? ; inline +M: end-of-stream inc-cursor ; inline +M: end-of-stream cursor-stream-ended? drop t ; inline + ! ! basic iterator ! @@ -168,8 +203,11 @@ MIXIN: collection GENERIC: begin-cursor ( collection -- cursor ) GENERIC: end-cursor ( collection -- cursor ) +: all ( collection -- begin end ) + [ begin-cursor ] [ end-cursor ] bi ; inline + : all- ( collection quot -- begin end quot ) - [ [ begin-cursor ] [ end-cursor ] bi ] dip ; inline + [ all ] dip ; inline ! ! containers @@ -265,14 +303,7 @@ TUPLE: pusher-cursor { growable read-only } ; C: pusher-cursor -INSTANCE: pusher-cursor forward-cursor - -! XXX define a protocol for stream cursors that don't actually move -M: pusher-cursor cursor-compatible? 2drop f ; inline -M: pusher-cursor cursor-valid? drop t ; inline -M: pusher-cursor cursor= 2drop f ; inline -M: pusher-cursor inc-cursor ; inline - +INSTANCE: pusher-cursor infinite-stream-cursor INSTANCE: pusher-cursor output-cursor M: pusher-cursor set-cursor-value growable>> push ; inline @@ -384,7 +415,12 @@ M: hashtable-cursor cursor-key-value [ n>> ] [ hashtable>> array>> ] bi [ nth-unsafe ] [ [ 1 + ] dip nth-unsafe ] 2bi ; inline -INSTANCE: hashtable collection +INSTANCE: hashtable-cursor input-cursor + +M: hashtable-cursor cursor-value + cursor-key-value 2array ; inline + +INSTANCE: hashtable container M: hashtable begin-cursor dup array>> 0 (inc-hashtable-cursor) ; inline From 7fe4a2b01fee1f184808280777784e4d1f1614e0 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 24 Mar 2010 14:35:51 -0700 Subject: [PATCH 454/713] cursors: finite-stream-cursors can act as containers over [self, end-of-stream) --- extra/cursors/cursors.factor | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/extra/cursors/cursors.factor b/extra/cursors/cursors.factor index a706f043ce..03855bc536 100644 --- a/extra/cursors/cursors.factor +++ b/extra/cursors/cursors.factor @@ -116,6 +116,11 @@ M: end-of-stream cursor= eq? ; inline M: end-of-stream inc-cursor ; inline M: end-of-stream cursor-stream-ended? drop t ; inline +INSTANCE: finite-stream-cursor container + +M: finite-stream-cursor begin-cursor ; inline +M: finite-stream-cursor end-cursor drop end-of-stream ; inline + ! ! basic iterator ! @@ -426,3 +431,58 @@ M: hashtable begin-cursor dup array>> 0 (inc-hashtable-cursor) ; inline M: hashtable end-cursor dup array>> length ; inline + +! +! zip cursor +! + +TUPLE: zip-cursor + { keys read-only } + { values read-only } ; +C: zip-cursor + +INSTANCE: zip-cursor forward-cursor + +M: zip-cursor cursor-compatible? ( cursor cursor -- ? ) + { + [ [ zip-cursor? ] both? ] + [ [ keys>> ] bi@ cursor-compatible? ] + [ [ values>> ] bi@ cursor-compatible? ] + } 2&& ; inline + +M: zip-cursor cursor-valid? ( cursor -- ? ) + [ keys>> ] [ values>> ] bi [ cursor-valid? ] both? ; inline +M: zip-cursor cursor= ( cursor cursor -- ? ) + { + [ [ keys>> ] bi@ cursor= ] + [ [ values>> ] bi@ cursor= ] + } 2|| ; inline + +M: zip-cursor cursor-distance-hint ( cursor cursor -- n ) + [ [ keys>> ] bi@ cursor-distance-hint ] + [ [ values>> ] bi@ cursor-distance-hint ] 2bi max ; inline + +M: zip-cursor inc-cursor ( cursor -- cursor' ) + [ keys>> inc-cursor ] [ values>> inc-cursor ] bi ; inline + +INSTANCE: zip-cursor assoc-cursor + +M: zip-cursor cursor-key-value + [ keys>> cursor-value ] [ values>> cursor-value ] bi ; inline + +: zip-cursors ( a-begin a-end b-begin b-end -- begin end ) + [ ] bi-curry@ bi* ; inline + +: 2all ( a b -- begin end ) + [ all ] bi@ zip-cursors ; inline + +: 2all- ( a b quot -- begin end quot ) + [ 2all ] dip ; inline + +ALIAS: -2container- assoc ; inline + +: 2container- ( a b quot -- begin end quot' ) + 2all- -2container- ; inline + + + From 98d81e71d79bcf37cc000a232949d9bbff5fdc86 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 24 Mar 2010 14:37:01 -0700 Subject: [PATCH 455/713] cursors: fix load errors w/o auto-use --- extra/cursors/cursors.factor | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/extra/cursors/cursors.factor b/extra/cursors/cursors.factor index 03855bc536..84b3d0ef78 100644 --- a/extra/cursors/cursors.factor +++ b/extra/cursors/cursors.factor @@ -1,6 +1,6 @@ ! (c)2010 Joe Groff bsd license USING: accessors arrays assocs combinators.short-circuit fry -hashtables kernel locals math math.functions sequences ; +hashtables kernel locals math math.functions math.order sequences ; FROM: sequences.private => nth-unsafe set-nth-unsafe ; FROM: hashtables.private => tombstone? ; IN: cursors @@ -116,11 +116,6 @@ M: end-of-stream cursor= eq? ; inline M: end-of-stream inc-cursor ; inline M: end-of-stream cursor-stream-ended? drop t ; inline -INSTANCE: finite-stream-cursor container - -M: finite-stream-cursor begin-cursor ; inline -M: finite-stream-cursor end-cursor drop end-of-stream ; inline - ! ! basic iterator ! @@ -229,6 +224,11 @@ INSTANCE: container collection : each ( ... container quot: ( ... x -- ... ) -- ... ) container- -each ; inline +INSTANCE: finite-stream-cursor container + +M: finite-stream-cursor begin-cursor ; inline +M: finite-stream-cursor end-cursor drop end-of-stream ; inline + ! ! sequence cursor ! @@ -479,7 +479,7 @@ M: zip-cursor cursor-key-value : 2all- ( a b quot -- begin end quot ) [ 2all ] dip ; inline -ALIAS: -2container- assoc ; inline +ALIAS: -2container- -assoc- : 2container- ( a b quot -- begin end quot' ) 2all- -2container- ; inline From 56c89c0510a16a9f52688aef4bbc2e3b7ca70e05 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 24 Mar 2010 15:26:50 -0700 Subject: [PATCH 456/713] cursors: 2each, 2map-as, 2map, using zip-cursors --- extra/cursors/cursors.factor | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extra/cursors/cursors.factor b/extra/cursors/cursors.factor index 84b3d0ef78..1d02311c2f 100644 --- a/extra/cursors/cursors.factor +++ b/extra/cursors/cursors.factor @@ -484,5 +484,11 @@ ALIAS: -2container- -assoc- : 2container- ( a b quot -- begin end quot' ) 2all- -2container- ; inline +: 2each ( ... a b quot: ( ... x y -- ... ) -- ... ) + 2container- -each ; inline +: 2map-as ( ... a b quot: ( ... x y -- ... z ) exemplar -- ... c ) + [ 2container- ] dip -map-as ; inline +: 2map ( ... a b quot: ( ... x y -- ... z ) -- ... c ) + pick 2map-as ; inline From c17eb80b90fe97ae4b5a8471918e3645a92488e8 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 24 Mar 2010 16:41:52 -0700 Subject: [PATCH 457/713] cursors: generalized -ncontainer- --- extra/cursors/cursors.factor | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/extra/cursors/cursors.factor b/extra/cursors/cursors.factor index 1d02311c2f..94e83398bd 100644 --- a/extra/cursors/cursors.factor +++ b/extra/cursors/cursors.factor @@ -1,6 +1,7 @@ ! (c)2010 Joe Groff bsd license USING: accessors arrays assocs combinators.short-circuit fry -hashtables kernel locals math math.functions math.order sequences ; +hashtables kernel locals macros math math.functions math.order +generalizations sequences ; FROM: sequences.private => nth-unsafe set-nth-unsafe ; FROM: hashtables.private => tombstone? ; IN: cursors @@ -376,7 +377,7 @@ GENERIC: cursor-key-value ( cursor -- key value ) INSTANCE: input-cursor assoc-cursor M: input-cursor cursor-key-value - cursor-value first2 ; inline + cursor-value-unsafe first2 ; inline ! ! hashtable cursor @@ -422,7 +423,7 @@ M: hashtable-cursor cursor-key-value INSTANCE: hashtable-cursor input-cursor -M: hashtable-cursor cursor-value +M: hashtable-cursor cursor-value-unsafe cursor-key-value 2array ; inline INSTANCE: hashtable container @@ -468,7 +469,7 @@ M: zip-cursor inc-cursor ( cursor -- cursor' ) INSTANCE: zip-cursor assoc-cursor M: zip-cursor cursor-key-value - [ keys>> cursor-value ] [ values>> cursor-value ] bi ; inline + [ keys>> cursor-value-unsafe ] [ values>> cursor-value-unsafe ] bi ; inline : zip-cursors ( a-begin a-end b-begin b-end -- begin end ) [ ] bi-curry@ bi* ; inline @@ -492,3 +493,27 @@ ALIAS: -2container- -assoc- : 2map ( ... a b quot: ( ... x y -- ... z ) -- ... c ) pick 2map-as ; inline + +! +! generalized zips +! + +: -unzip- ( quot -- quot' ) + '[ [ keys>> cursor-value-unsafe ] [ values>> ] bi @ ] ; inline + +MACRO: nzip-cursors ( n -- ) 1 - [ zip-cursors ] n*quot ; + +: nall ( seqs... n -- begin end ) [ [ all ] swap napply ] [ nzip-cursors ] bi ; inline + +: nall- ( seqs... quot n -- begin end quot ) swap [ nall ] dip ; inline + +MACRO: -ncontainer- ( n -- ) + 1 - [ -unzip- ] n*quot [ -container- ] prepend ; + +: ncontainer- ( seqs... quot n -- begin end quot ) [ nall- ] [ -ncontainer- ] bi ; inline + +: neach ( seqs... quot n -- ) ncontainer- -each ; inline +: nmap-as ( seqs... quot exemplar n -- newseq ) + swap [ ncontainer- ] dip -map-as ; inline +: nmap ( seqs... quot n -- newseq ) + dup [ npick ] curry [ dip swap ] curry dip nmap-as ; inline From c70090bb8378538a94e844571e3499b2531bd095 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 24 Mar 2010 17:02:10 -0700 Subject: [PATCH 458/713] cursors: -with- filter (e.g. foo H{ ... } [ ... ] assoc- -with- -each) --- extra/cursors/cursors.factor | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/extra/cursors/cursors.factor b/extra/cursors/cursors.factor index 94e83398bd..750540844a 100644 --- a/extra/cursors/cursors.factor +++ b/extra/cursors/cursors.factor @@ -517,3 +517,17 @@ MACRO: -ncontainer- ( n -- ) swap [ ncontainer- ] dip -map-as ; inline : nmap ( seqs... quot n -- newseq ) dup [ npick ] curry [ dip swap ] curry dip nmap-as ; inline + +! +! utilities +! + +: -with- ( invariant begin end quot -- begin end quot' ) + [ rot ] dip '[ [ _ ] dip @ ] ; inline + +: -2with- ( invariant invariant begin end quot -- begin end quot' ) + -with- -with- ; inline + +MACRO: -nwith- ( n -- ) + [ -with- ] n*quot ; + From e0358219ad96c2880836ac8d8caa21557048f838 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 24 Mar 2010 18:05:41 -0700 Subject: [PATCH 459/713] cursors: some refactoring: - rename -container- to -in- - rename current -map- to -out- - rename "pipe-cursor" to "map-cursor" - have -map- and -map take the "to" cursor --- extra/cursors/cursors.factor | 89 +++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/extra/cursors/cursors.factor b/extra/cursors/cursors.factor index 750540844a..a82f0e28a0 100644 --- a/extra/cursors/cursors.factor +++ b/extra/cursors/cursors.factor @@ -118,13 +118,22 @@ M: end-of-stream inc-cursor ; inline M: end-of-stream cursor-stream-ended? drop t ; inline ! -! basic iterator +! basic iterators ! : -each ( ... begin end quot: ( ... cursor -- ... ) -- ... ) [ '[ dup _ cursor>= ] ] [ '[ _ keep inc-cursor ] ] bi* until drop ; inline +: -in- ( quot -- quot' ) + '[ cursor-value-unsafe @ ] ; inline + +: -out- ( quot -- quot' ) + '[ _ keep set-cursor-value-unsafe ] ; inline + +: -out ( ... begin end quot: ( ... cursor -- ... value ) -- ... ) + -out- -each ; inline + ! ! numeric cursors ! @@ -217,13 +226,10 @@ GENERIC: end-cursor ( collection -- cursor ) MIXIN: container INSTANCE: container collection -: -container- ( quot -- quot' ) - '[ cursor-value-unsafe @ ] ; inline +: in- ( container quot -- begin end quot' ) + all- -in- ; inline -: container- ( container quot -- begin end quot' ) - all- -container- ; inline - -: each ( ... container quot: ( ... x -- ... ) -- ... ) container- -each ; inline +: each ( ... container quot: ( ... x -- ... ) -- ... ) in- -each ; inline INSTANCE: finite-stream-cursor container @@ -278,28 +284,31 @@ M: sequence-cursor set-cursor-value-unsafe [ n>> ] [ seq>> ] bi set-nth-unsafe ; M: sequence-cursor set-cursor-value [ n>> ] [ seq>> ] bi set-nth ; inline ! -! pipe cursor +! map cursor ! -TUPLE: pipe-cursor +TUPLE: map-cursor { from read-only } { to read-only } ; -C: pipe-cursor +C: map-cursor -INSTANCE: pipe-cursor forward-cursor +INSTANCE: map-cursor forward-cursor -M: pipe-cursor cursor-compatible? [ from>> ] bi@ cursor-compatible? ; inline -M: pipe-cursor cursor-valid? [ from>> ] [ to>> ] bi [ cursor-valid? ] both? ; inline -M: pipe-cursor cursor= [ from>> ] bi@ cursor= ; inline -M: pipe-cursor inc-cursor [ from>> inc-cursor ] [ to>> inc-cursor ] bi ; inline +M: map-cursor cursor-compatible? [ from>> ] bi@ cursor-compatible? ; inline +M: map-cursor cursor-valid? [ from>> ] [ to>> ] bi [ cursor-valid? ] both? ; inline +M: map-cursor cursor= [ from>> ] bi@ cursor= ; inline +M: map-cursor inc-cursor [ from>> inc-cursor ] [ to>> inc-cursor ] bi ; inline -INSTANCE: pipe-cursor output-cursor +INSTANCE: map-cursor output-cursor -M: pipe-cursor set-cursor-value-unsafe to>> set-cursor-value-unsafe ; inline -M: pipe-cursor set-cursor-value to>> set-cursor-value ; inline +M: map-cursor set-cursor-value-unsafe to>> set-cursor-value-unsafe ; inline +M: map-cursor set-cursor-value to>> set-cursor-value ; inline -: -pipe- ( begin end quot to -- begin' end' quot' ) - swap [ '[ _ ] bi@ ] dip '[ from>> @ ] ; inline +: -map- ( begin end quot to -- begin' end' quot' ) + swap [ '[ _ ] bi@ ] dip '[ from>> @ ] ; inline + +: -map ( begin end quot to -- begin' end' quot' ) + -map- -out ; inline ! ! pusher cursor @@ -328,30 +337,24 @@ M: random-access-cursor new-sequence-cursor M: forward-cursor new-sequence-cursor new-growable-cursor ; inline -: -into-sequence- ( begin end quot exemplar -- begin' end' quot' result ) - swap [ [ 2dup ] dip new-sequence-cursor ] dip swap [ swap -pipe- ] dip ; inline +: -into-sequence- ( begin end quot exemplar -- begin' end' quot' cursor result ) + [ 2over ] dip new-sequence-cursor ; inline -: -into-growable- ( begin end quot exemplar -- begin' end' quot' result ) - swap [ [ 2dup ] dip new-growable-cursor ] dip swap [ swap -pipe- ] dip ; inline +: -into-growable- ( begin end quot exemplar -- begin' end' quot' cursor result ) + [ 2over ] dip new-sequence-cursor ; inline ! -! map +! map combinators ! -: -map- ( quot -- quot' ) - '[ _ keep set-cursor-value-unsafe ] ; inline - -: -map ( ... begin end quot: ( ... cursor -- ... value ) -- ... ) - -map- -each ; inline - ! XXX generalize exemplar : -map-as ( ... begin end quot: ( ... cursor -- ... value ) exemplar -- ... newseq ) [ -into-sequence- [ -map ] dip ] keep like ; inline : map! ( ... container quot: ( ... x -- ... newx ) -- ... container ) - [ container- -map ] keep ; inline + [ in- -out ] keep ; inline : map-as ( ... container quot: ( ... x -- ... newx ) exemplar -- ... newseq ) - [ container- ] dip -map-as ; inline + [ in- ] dip -map-as ; inline : map ( ... container quot: ( ... x -- ... newx ) -- ... newcontainer ) over map-as ; inline @@ -480,16 +483,16 @@ M: zip-cursor cursor-key-value : 2all- ( a b quot -- begin end quot ) [ 2all ] dip ; inline -ALIAS: -2container- -assoc- +ALIAS: -2in- -assoc- -: 2container- ( a b quot -- begin end quot' ) - 2all- -2container- ; inline +: 2in- ( a b quot -- begin end quot' ) + 2all- -2in- ; inline : 2each ( ... a b quot: ( ... x y -- ... ) -- ... ) - 2container- -each ; inline + 2in- -each ; inline : 2map-as ( ... a b quot: ( ... x y -- ... z ) exemplar -- ... c ) - [ 2container- ] dip -map-as ; inline + [ 2in- ] dip -map-as ; inline : 2map ( ... a b quot: ( ... x y -- ... z ) -- ... c ) pick 2map-as ; inline @@ -507,14 +510,14 @@ MACRO: nzip-cursors ( n -- ) 1 - [ zip-cursors ] n*quot ; : nall- ( seqs... quot n -- begin end quot ) swap [ nall ] dip ; inline -MACRO: -ncontainer- ( n -- ) - 1 - [ -unzip- ] n*quot [ -container- ] prepend ; +MACRO: -nin- ( n -- ) + 1 - [ -unzip- ] n*quot [ -in- ] prepend ; -: ncontainer- ( seqs... quot n -- begin end quot ) [ nall- ] [ -ncontainer- ] bi ; inline +: nin- ( seqs... quot n -- begin end quot ) [ nall- ] [ -nin- ] bi ; inline -: neach ( seqs... quot n -- ) ncontainer- -each ; inline +: neach ( seqs... quot n -- ) nin- -each ; inline : nmap-as ( seqs... quot exemplar n -- newseq ) - swap [ ncontainer- ] dip -map-as ; inline + swap [ nin- ] dip -map-as ; inline : nmap ( seqs... quot n -- newseq ) dup [ npick ] curry [ dip swap ] curry dip nmap-as ; inline From 96d2b44f3e806f27f1a2e06a2eeb8413200aca00 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 24 Mar 2010 18:16:22 -0700 Subject: [PATCH 460/713] cursors: push the -out- part from -map into -map- --- extra/cursors/cursors.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/cursors/cursors.factor b/extra/cursors/cursors.factor index a82f0e28a0..5a3e7475c6 100644 --- a/extra/cursors/cursors.factor +++ b/extra/cursors/cursors.factor @@ -305,10 +305,10 @@ M: map-cursor set-cursor-value-unsafe to>> set-cursor-value-unsafe ; inline M: map-cursor set-cursor-value to>> set-cursor-value ; inline : -map- ( begin end quot to -- begin' end' quot' ) - swap [ '[ _ ] bi@ ] dip '[ from>> @ ] ; inline + swap [ '[ _ ] bi@ ] dip '[ from>> @ ] -out- ; inline : -map ( begin end quot to -- begin' end' quot' ) - -map- -out ; inline + -map- -each ; inline ! ! pusher cursor From e0435f6261d04d38563f288b8ca7e801bd3610df Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 24 Mar 2010 19:02:27 -0700 Subject: [PATCH 461/713] cursors: typo in -into-growable- --- extra/cursors/cursors.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/cursors/cursors.factor b/extra/cursors/cursors.factor index 5a3e7475c6..030e9ab72f 100644 --- a/extra/cursors/cursors.factor +++ b/extra/cursors/cursors.factor @@ -341,7 +341,7 @@ M: forward-cursor new-sequence-cursor [ 2over ] dip new-sequence-cursor ; inline : -into-growable- ( begin end quot exemplar -- begin' end' quot' cursor result ) - [ 2over ] dip new-sequence-cursor ; inline + [ 2over ] dip new-growable-cursor ; inline ! ! map combinators From 63c7513e2d7db2113d3145dbba388a526b6a3625 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 25 Mar 2010 09:21:49 -0400 Subject: [PATCH 462/713] websites.concatenative: fix stylesheet --- extra/websites/concatenative/page.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/websites/concatenative/page.css b/extra/websites/concatenative/page.css index 8115627742..dc0c57b7d5 100644 --- a/extra/websites/concatenative/page.css +++ b/extra/websites/concatenative/page.css @@ -9,7 +9,7 @@ body, button { border: none; } -a, .link { +a:link, a:visited, .link { color: #222; border-bottom:1px dotted #666; text-decoration:none; From a566d8cc6b2daa14289c6fce71b02b95354f118c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 26 Mar 2010 03:42:07 -0400 Subject: [PATCH 463/713] lexer: each-token and map-tokens did not handle EOF properly --- core/lexer/lexer.factor | 15 +- core/parser/parser-tests.factor | 514 ++++++++++++++++---------------- core/syntax/syntax.factor | 4 +- 3 files changed, 268 insertions(+), 265 deletions(-) diff --git a/core/lexer/lexer.factor b/core/lexer/lexer.factor index 7f6324c251..f9554fa9bb 100644 --- a/core/lexer/lexer.factor +++ b/core/lexer/lexer.factor @@ -86,8 +86,7 @@ M: lexer skip-word ( lexer -- ) : scan ( -- str/f ) lexer get parse-token ; -PREDICATE: unexpected-eof < unexpected - got>> not ; +PREDICATE: unexpected-eof < unexpected got>> not ; : unexpected-eof ( word -- * ) f unexpected ; @@ -97,14 +96,15 @@ PREDICATE: unexpected-eof < unexpected [ unexpected-eof ] if* ; -: (each-token) ( end quot -- pred quot ) - [ [ [ scan dup ] ] dip [ = not ] curry [ [ f ] if* ] curry compose ] dip ; inline - : each-token ( ... end quot: ( ... token -- ... ) -- ... ) - (each-token) while drop ; inline + [ scan ] 2dip { + { [ 2over = ] [ 3drop ] } + { [ pick not ] [ drop unexpected-eof ] } + [ [ nip call ] [ each-token ] 2bi ] + } cond ; inline recursive : map-tokens ( ... end quot: ( ... token -- ... elt ) -- ... seq ) - (each-token) produce nip ; inline + collector [ each-token ] dip ; inline : parse-tokens ( end -- seq ) [ ] map-tokens ; @@ -112,6 +112,7 @@ PREDICATE: unexpected-eof < unexpected TUPLE: lexer-error line column line-text parsing-words error ; M: lexer-error error-file error>> error-file ; + M: lexer-error error-line [ error>> error-line ] [ line>> ] bi or ; : ( msg -- error ) diff --git a/core/parser/parser-tests.factor b/core/parser/parser-tests.factor index 266a65b957..ac2310d3f9 100644 --- a/core/parser/parser-tests.factor +++ b/core/parser/parser-tests.factor @@ -7,332 +7,334 @@ vocabs.parser words.symbol multiline source-files.errors tools.crossref grouping ; IN: parser.tests +[ 1 [ 2 [ 3 ] 4 ] 5 ] +[ "1\n[\n2\n[\n3\n]\n4\n]\n5" eval( -- a b c ) ] +unit-test + +[ t t f f ] +[ "t t f f" eval( -- ? ? ? ? ) ] +unit-test + +[ "hello world" ] +[ "\"hello world\"" eval( -- string ) ] +unit-test + +[ "\n\r\t\\" ] +[ "\"\\n\\r\\t\\\\\"" eval( -- string ) ] +unit-test + +[ "hello world" ] [ - [ 1 [ 2 [ 3 ] 4 ] 5 ] - [ "1\n[\n2\n[\n3\n]\n4\n]\n5" eval( -- a b c ) ] - unit-test + "IN: parser.tests : hello ( -- str ) \"hello world\" ;" + eval( -- ) "USE: parser.tests hello" eval( -- string ) +] unit-test - [ t t f f ] - [ "t t f f" eval( -- ? ? ? ? ) ] - unit-test +[ ] +[ "! This is a comment, people." eval( -- ) ] +unit-test - [ "hello world" ] - [ "\"hello world\"" eval( -- string ) ] - unit-test +! Test escapes - [ "\n\r\t\\" ] - [ "\"\\n\\r\\t\\\\\"" eval( -- string ) ] - unit-test +[ " " ] +[ "\"\\u000020\"" eval( -- string ) ] +unit-test - [ "hello world" ] - [ - "IN: parser.tests : hello ( -- str ) \"hello world\" ;" - eval( -- ) "USE: parser.tests hello" eval( -- string ) - ] unit-test +[ "'" ] +[ "\"\\u000027\"" eval( -- string ) ] +unit-test - [ ] - [ "! This is a comment, people." eval( -- ) ] - unit-test +! Test EOL comments in multiline strings. +[ "Hello" ] [ "#! This calls until-eol.\n\"Hello\"" eval( -- string ) ] unit-test - ! Test escapes +[ word ] [ \ f class ] unit-test - [ " " ] - [ "\"\\u000020\"" eval( -- string ) ] - unit-test +! Test stack effect parsing - [ "'" ] - [ "\"\\u000027\"" eval( -- string ) ] - unit-test +: effect-parsing-test ( a b -- c ) + ; - ! Test EOL comments in multiline strings. - [ "Hello" ] [ "#! This calls until-eol.\n\"Hello\"" eval( -- string ) ] unit-test +[ t ] [ + "effect-parsing-test" "parser.tests" lookup + \ effect-parsing-test eq? +] unit-test - [ word ] [ \ f class ] unit-test +[ T{ effect f { "a" "b" } { "c" } f } ] +[ \ effect-parsing-test "declared-effect" word-prop ] unit-test - ! Test stack effect parsing +: baz ( a b -- * ) 2array throw ; - : effect-parsing-test ( a b -- c ) + ; +[ t ] +[ \ baz "declared-effect" word-prop terminated?>> ] +unit-test - [ t ] [ - "effect-parsing-test" "parser.tests" lookup - \ effect-parsing-test eq? - ] unit-test +[ ] [ "IN: parser.tests USE: math : effect-parsing-test ( a b -- d ) - ;" eval( -- ) ] unit-test - [ T{ effect f { "a" "b" } { "c" } f } ] - [ \ effect-parsing-test "declared-effect" word-prop ] unit-test +[ t ] [ + "effect-parsing-test" "parser.tests" lookup + \ effect-parsing-test eq? +] unit-test - : baz ( a b -- * ) 2array throw ; +[ T{ effect f { "a" "b" } { "d" } f } ] +[ \ effect-parsing-test "declared-effect" word-prop ] unit-test - [ t ] - [ \ baz "declared-effect" word-prop terminated?>> ] - unit-test +[ "IN: parser.tests : missing-- ( a b ) ;" eval( -- ) ] must-fail - [ ] [ "IN: parser.tests USE: math : effect-parsing-test ( a b -- d ) - ;" eval( -- ) ] unit-test +! Funny bug +[ 2 ] [ "IN: parser.tests : \0. ( -- x ) 2 ; \0." eval( -- n ) ] unit-test - [ t ] [ - "effect-parsing-test" "parser.tests" lookup - \ effect-parsing-test eq? - ] unit-test +! These should throw errors +[ "HEX: zzz" eval( -- obj ) ] must-fail +[ "OCT: 999" eval( -- obj ) ] must-fail +[ "BIN: --0" eval( -- obj ) ] must-fail - [ T{ effect f { "a" "b" } { "d" } f } ] - [ \ effect-parsing-test "declared-effect" word-prop ] unit-test +DEFER: foo - ! Funny bug - [ 2 ] [ "IN: parser.tests : \0. ( -- x ) 2 ; \0." eval( -- n ) ] unit-test +"IN: parser.tests USING: math prettyprint ; SYNTAX: foo 2 2 + . ;" eval( -- ) - [ "IN: parser.tests : missing-- ( a b ) ;" eval( -- ) ] must-fail +[ ] [ "USE: parser.tests foo" eval( -- ) ] unit-test - ! These should throw errors - [ "HEX: zzz" eval( -- obj ) ] must-fail - [ "OCT: 999" eval( -- obj ) ] must-fail - [ "BIN: --0" eval( -- obj ) ] must-fail +"IN: parser.tests USING: math prettyprint ; : foo ( -- ) 2 2 + . ;" eval( -- ) - DEFER: foo +[ t ] [ + "USE: parser.tests \\ foo" eval( -- word ) + "foo" "parser.tests" lookup eq? +] unit-test - "IN: parser.tests USING: math prettyprint ; SYNTAX: foo 2 2 + . ;" eval( -- ) +! parse-tokens should do the right thing on EOF +[ "USING: kernel" eval( -- ) ] +[ error>> T{ unexpected { want ";" } } = ] must-fail-with - [ ] [ "USE: parser.tests foo" eval( -- ) ] unit-test +! Test smudging - "IN: parser.tests USING: math prettyprint ; : foo ( -- ) 2 2 + . ;" eval( -- ) +[ 1 ] [ + "IN: parser.tests : smudge-me ( -- ) ;" "foo" + parse-stream drop - [ t ] [ - "USE: parser.tests \\ foo" eval( -- word ) - "foo" "parser.tests" lookup eq? - ] unit-test + "foo" source-file definitions>> first assoc-size +] unit-test - ! Test smudging +[ t ] [ "smudge-me" "parser.tests" lookup >boolean ] unit-test - [ 1 ] [ - "IN: parser.tests : smudge-me ( -- ) ;" "foo" - parse-stream drop +[ ] [ + "IN: parser.tests : smudge-me-more ( -- ) ;" "foo" + parse-stream drop +] unit-test - "foo" source-file definitions>> first assoc-size - ] unit-test +[ t ] [ "smudge-me-more" "parser.tests" lookup >boolean ] unit-test +[ f ] [ "smudge-me" "parser.tests" lookup >boolean ] unit-test - [ t ] [ "smudge-me" "parser.tests" lookup >boolean ] unit-test +[ 3 ] [ + "IN: parser.tests USING: math strings ; GENERIC: smudge-me ( a -- b ) M: integer smudge-me ; M: string smudge-me ;" "foo" + parse-stream drop - [ ] [ - "IN: parser.tests : smudge-me-more ( -- ) ;" "foo" - parse-stream drop - ] unit-test + "foo" source-file definitions>> first assoc-size +] unit-test - [ t ] [ "smudge-me-more" "parser.tests" lookup >boolean ] unit-test - [ f ] [ "smudge-me" "parser.tests" lookup >boolean ] unit-test +[ 1 ] [ + "IN: parser.tests USING: arrays ; M: array smudge-me ;" "bar" + parse-stream drop - [ 3 ] [ - "IN: parser.tests USING: math strings ; GENERIC: smudge-me ( a -- b ) M: integer smudge-me ; M: string smudge-me ;" "foo" - parse-stream drop + "bar" source-file definitions>> first assoc-size +] unit-test - "foo" source-file definitions>> first assoc-size - ] unit-test +[ 2 ] [ + "IN: parser.tests USING: math strings ; GENERIC: smudge-me ( a -- b ) M: integer smudge-me ;" "foo" + parse-stream drop - [ 1 ] [ - "IN: parser.tests USING: arrays ; M: array smudge-me ;" "bar" - parse-stream drop + "foo" source-file definitions>> first assoc-size +] unit-test - "bar" source-file definitions>> first assoc-size - ] unit-test +[ t ] [ + array "smudge-me" "parser.tests" lookup order member-eq? +] unit-test - [ 2 ] [ - "IN: parser.tests USING: math strings ; GENERIC: smudge-me ( a -- b ) M: integer smudge-me ;" "foo" - parse-stream drop +[ t ] [ + integer "smudge-me" "parser.tests" lookup order member-eq? +] unit-test - "foo" source-file definitions>> first assoc-size - ] unit-test - - [ t ] [ - array "smudge-me" "parser.tests" lookup order member-eq? - ] unit-test - - [ t ] [ - integer "smudge-me" "parser.tests" lookup order member-eq? - ] unit-test - - [ f ] [ - string "smudge-me" "parser.tests" lookup order member-eq? - ] unit-test +[ f ] [ + string "smudge-me" "parser.tests" lookup order member-eq? +] unit-test - [ ] [ - "IN: parser.tests USE: math 2 2 +" "a" - parse-stream drop - ] unit-test - - [ t ] [ - "a" \ + usage member? - ] unit-test +[ ] [ + "IN: parser.tests USE: math 2 2 +" "a" + parse-stream drop +] unit-test - [ ] [ - "IN: parser.tests USE: math 2 2 -" "a" - parse-stream drop - ] unit-test - - [ f ] [ - "a" \ + usage member? - ] unit-test - - [ ] [ - "a" source-files get delete-at - 2 [ - "IN: parser.tests DEFER: x : y ( -- ) x ; : x ( -- ) y ;" - "a" parse-stream drop - ] times - ] unit-test - +[ t ] [ + "a" \ + usage member? +] unit-test + +[ ] [ + "IN: parser.tests USE: math 2 2 -" "a" + parse-stream drop +] unit-test + +[ f ] [ + "a" \ + usage member? +] unit-test + +[ ] [ "a" source-files get delete-at - - [ - "IN: parser.tests : x ( -- ) ; : y ( -- * ) 3 throw ; this is an error" - "a" parse-stream - ] [ source-file-error? ] must-fail-with - - [ t ] [ - "y" "parser.tests" lookup >boolean - ] unit-test - - [ f ] [ - "IN: parser.tests : x ( -- ) ;" + 2 [ + "IN: parser.tests DEFER: x : y ( -- ) x ; : x ( -- ) y ;" "a" parse-stream drop - - "y" "parser.tests" lookup - ] unit-test + ] times +] unit-test - ! Test new forward definition logic - [ ] [ - "IN: axx : axx ( -- ) ;" - "axx" parse-stream drop - ] unit-test +"a" source-files get delete-at - [ ] [ - "USE: axx IN: bxx : bxx ( -- ) ; : cxx ( -- ) axx bxx ;" - "bxx" parse-stream drop - ] unit-test +[ + "IN: parser.tests : x ( -- ) ; : y ( -- * ) 3 throw ; this is an error" + "a" parse-stream +] [ source-file-error? ] must-fail-with - ! So we move the bxx word to axx... - [ ] [ - "IN: axx : axx ( -- ) ; : bxx ( -- ) ;" - "axx" parse-stream drop - ] unit-test +[ t ] [ + "y" "parser.tests" lookup >boolean +] unit-test - [ t ] [ "bxx" "axx" lookup >boolean ] unit-test - - ! And reload the file that uses it... - [ ] [ - "USE: axx IN: bxx ( -- ) : cxx ( -- ) axx bxx ;" - "bxx" parse-stream drop - ] unit-test +[ f ] [ + "IN: parser.tests : x ( -- ) ;" + "a" parse-stream drop - ! And hope not to get a forward-error! + "y" "parser.tests" lookup +] unit-test - ! Turning a generic into a non-generic could cause all - ! kinds of funnyness - [ ] [ - "IN: ayy USE: kernel GENERIC: ayy ( a -- b ) M: object ayy ;" - "ayy" parse-stream drop - ] unit-test +! Test new forward definition logic +[ ] [ + "IN: axx : axx ( -- ) ;" + "axx" parse-stream drop +] unit-test - [ ] [ - "IN: ayy USE: kernel : ayy ( -- ) ;" - "ayy" parse-stream drop - ] unit-test +[ ] [ + "USE: axx IN: bxx : bxx ( -- ) ; : cxx ( -- ) axx bxx ;" + "bxx" parse-stream drop +] unit-test - [ ] [ - "IN: azz TUPLE: my-class ; GENERIC: a-generic ( a -- b )" - "azz" parse-stream drop - ] unit-test +! So we move the bxx word to axx... +[ ] [ + "IN: axx : axx ( -- ) ; : bxx ( -- ) ;" + "axx" parse-stream drop +] unit-test - [ ] [ - "USE: azz M: my-class a-generic ;" - "azz-2" parse-stream drop - ] unit-test +[ t ] [ "bxx" "axx" lookup >boolean ] unit-test - [ ] [ - "IN: azz GENERIC: a-generic ( a -- b )" - "azz" parse-stream drop - ] unit-test +! And reload the file that uses it... +[ ] [ + "USE: axx IN: bxx ( -- ) : cxx ( -- ) axx bxx ;" + "bxx" parse-stream drop +] unit-test - [ ] [ - "USE: azz USE: math M: integer a-generic ;" - "azz-2" parse-stream drop - ] unit-test +! And hope not to get a forward-error! - [ ] [ - "IN: parser.tests : ( -- ) ; : bogus ( -- error ) ;" - "bogus-error" parse-stream drop - ] unit-test +! Turning a generic into a non-generic could cause all +! kinds of funnyness +[ ] [ + "IN: ayy USE: kernel GENERIC: ayy ( a -- b ) M: object ayy ;" + "ayy" parse-stream drop +] unit-test - [ ] [ - "IN: parser.tests TUPLE: bogus-error ; C: bogus-error : bogus ( -- error ) ;" - "bogus-error" parse-stream drop - ] unit-test +[ ] [ + "IN: ayy USE: kernel : ayy ( -- ) ;" + "ayy" parse-stream drop +] unit-test - ! Problems with class predicates -vs- ordinary words - [ ] [ - "IN: parser.tests TUPLE: killer ;" - "removing-the-predicate" parse-stream drop - ] unit-test +[ ] [ + "IN: azz TUPLE: my-class ; GENERIC: a-generic ( a -- b )" + "azz" parse-stream drop +] unit-test - [ ] [ - "IN: parser.tests GENERIC: killer? ( a -- b )" - "removing-the-predicate" parse-stream drop - ] unit-test - - [ t ] [ - "killer?" "parser.tests" lookup >boolean - ] unit-test +[ ] [ + "USE: azz M: my-class a-generic ;" + "azz-2" parse-stream drop +] unit-test - [ - "IN: parser.tests TUPLE: another-pred-test ; GENERIC: another-pred-test? ( a -- b )" - "removing-the-predicate" parse-stream - ] [ error>> error>> error>> redefine-error? ] must-fail-with +[ ] [ + "IN: azz GENERIC: a-generic ( a -- b )" + "azz" parse-stream drop +] unit-test - [ - "IN: parser.tests TUPLE: class-redef-test ; TUPLE: class-redef-test ;" - "redefining-a-class-1" parse-stream - ] [ error>> error>> error>> redefine-error? ] must-fail-with +[ ] [ + "USE: azz USE: math M: integer a-generic ;" + "azz-2" parse-stream drop +] unit-test - [ ] [ - "IN: parser.tests TUPLE: class-redef-test ; SYMBOL: class-redef-test" - "redefining-a-class-2" parse-stream drop - ] unit-test +[ ] [ + "IN: parser.tests : ( -- ) ; : bogus ( -- error ) ;" + "bogus-error" parse-stream drop +] unit-test - [ - "IN: parser.tests TUPLE: class-redef-test ; SYMBOL: class-redef-test : class-redef-test ( -- ) ;" - "redefining-a-class-3" parse-stream drop - ] [ error>> error>> error>> redefine-error? ] must-fail-with +[ ] [ + "IN: parser.tests TUPLE: bogus-error ; C: bogus-error : bogus ( -- error ) ;" + "bogus-error" parse-stream drop +] unit-test - [ ] [ - "IN: parser.tests TUPLE: class-fwd-test ;" - "redefining-a-class-3" parse-stream drop - ] unit-test +! Problems with class predicates -vs- ordinary words +[ ] [ + "IN: parser.tests TUPLE: killer ;" + "removing-the-predicate" parse-stream drop +] unit-test - [ - "IN: parser.tests \\ class-fwd-test" - "redefining-a-class-3" parse-stream drop - ] [ error>> error>> error>> no-word-error? ] must-fail-with +[ ] [ + "IN: parser.tests GENERIC: killer? ( a -- b )" + "removing-the-predicate" parse-stream drop +] unit-test - [ ] [ - "IN: parser.tests TUPLE: class-fwd-test ; SYMBOL: class-fwd-test" - "redefining-a-class-3" parse-stream drop - ] unit-test +[ t ] [ + "killer?" "parser.tests" lookup >boolean +] unit-test - [ - "IN: parser.tests \\ class-fwd-test" - "redefining-a-class-3" parse-stream drop - ] [ error>> error>> error>> no-word-error? ] must-fail-with +[ + "IN: parser.tests TUPLE: another-pred-test ; GENERIC: another-pred-test? ( a -- b )" + "removing-the-predicate" parse-stream +] [ error>> error>> error>> redefine-error? ] must-fail-with - [ - "IN: parser.tests : foo ( -- ) ; TUPLE: foo ;" - "redefining-a-class-4" parse-stream drop - ] [ error>> error>> error>> redefine-error? ] must-fail-with +[ + "IN: parser.tests TUPLE: class-redef-test ; TUPLE: class-redef-test ;" + "redefining-a-class-1" parse-stream +] [ error>> error>> error>> redefine-error? ] must-fail-with - [ ] [ - "IN: parser.tests : foo ( x y -- z ) 1 2 ; : bar ( a -- b ) ;" eval( -- ) - ] unit-test +[ ] [ + "IN: parser.tests TUPLE: class-redef-test ; SYMBOL: class-redef-test" + "redefining-a-class-2" parse-stream drop +] unit-test - [ - "IN: parser.tests : foo ( x y -- z) 1 2 ; : bar ( a -- b ) ;" eval( -- ) - ] must-fail -] with-file-vocabs +[ + "IN: parser.tests TUPLE: class-redef-test ; SYMBOL: class-redef-test : class-redef-test ( -- ) ;" + "redefining-a-class-3" parse-stream drop +] [ error>> error>> error>> redefine-error? ] must-fail-with + +[ ] [ + "IN: parser.tests TUPLE: class-fwd-test ;" + "redefining-a-class-3" parse-stream drop +] unit-test + +[ + "IN: parser.tests \\ class-fwd-test" + "redefining-a-class-3" parse-stream drop +] [ error>> error>> error>> no-word-error? ] must-fail-with + +[ ] [ + "IN: parser.tests TUPLE: class-fwd-test ; SYMBOL: class-fwd-test" + "redefining-a-class-3" parse-stream drop +] unit-test + +[ + "IN: parser.tests \\ class-fwd-test" + "redefining-a-class-3" parse-stream drop +] [ error>> error>> error>> no-word-error? ] must-fail-with + +[ + "IN: parser.tests : foo ( -- ) ; TUPLE: foo ;" + "redefining-a-class-4" parse-stream drop +] [ error>> error>> error>> redefine-error? ] must-fail-with + +[ ] [ + "IN: parser.tests : foo ( x y -- z ) 1 2 ; : bar ( a -- b ) ;" eval( -- ) +] unit-test + +[ + "IN: parser.tests : foo ( x y -- z) 1 2 ; : bar ( a -- b ) ;" eval( -- ) +] must-fail [ ] [ "IN: parser.tests USE: kernel PREDICATE: foo < object ( x -- y ) ;" eval( -- ) diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index 84a753fb1b..bd70b0be62 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2004, 2009 Slava Pestov. +! Copyright (C) 2004, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien arrays byte-arrays byte-vectors definitions generic hashtables kernel math namespaces parser lexer sequences strings @@ -125,7 +125,7 @@ IN: bootstrap.syntax ] define-core-syntax "SYMBOLS:" [ - ";" [ create-in dup reset-generic define-symbol ] each-token + ";" [ create-in [ reset-generic ] [ define-symbol ] bi ] each-token ] define-core-syntax "SINGLETONS:" [ From dde21c3cc40cfd6b29296e5b10020c2c76b0c22f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 26 Mar 2010 16:31:48 -0400 Subject: [PATCH 464/713] lexer: fix output type of map-tokens --- core/lexer/lexer.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lexer/lexer.factor b/core/lexer/lexer.factor index f9554fa9bb..7939a49d7a 100644 --- a/core/lexer/lexer.factor +++ b/core/lexer/lexer.factor @@ -104,7 +104,7 @@ PREDICATE: unexpected-eof < unexpected got>> not ; } cond ; inline recursive : map-tokens ( ... end quot: ( ... token -- ... elt ) -- ... seq ) - collector [ each-token ] dip ; inline + collector [ each-token ] dip { } like ; inline : parse-tokens ( end -- seq ) [ ] map-tokens ; From 560c119cd2482ce3f96644be564294ed5afd1f22 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 26 Mar 2010 22:44:43 -0400 Subject: [PATCH 465/713] vm: actually use context callstacks when running code --- basis/bootstrap/image/image.factor | 4 +- basis/command-line/command-line-docs.factor | 4 +- basis/compiler/alien/alien.factor | 6 +- basis/compiler/codegen/codegen.factor | 5 +- basis/compiler/constants/constants.factor | 2 + basis/compiler/tests/alien.factor | 17 +- basis/cpu/architecture/architecture.factor | 8 +- basis/cpu/ppc/bootstrap.factor | 10 +- basis/cpu/ppc/ppc.factor | 10 +- basis/cpu/x86/32/32.factor | 22 +- basis/cpu/x86/32/bootstrap.factor | 46 ++- basis/cpu/x86/64/64.factor | 34 +- basis/cpu/x86/64/bootstrap.factor | 56 ++-- basis/cpu/x86/bootstrap.factor | 54 ++-- basis/cpu/x86/x86.factor | 3 - .../known-words/known-words.factor | 39 ++- basis/vm/vm.factor | 8 +- core/alien/alien.factor | 23 +- core/bootstrap/primitives.factor | 5 + vm/callbacks.cpp | 3 +- vm/callstack.cpp | 2 +- vm/callstack.hpp | 2 +- vm/code_block_visitor.hpp | 2 +- vm/contexts.cpp | 155 +++++++--- vm/contexts.hpp | 36 ++- vm/cpu-ppc.hpp | 2 + vm/cpu-x86.hpp | 2 + vm/data_heap.cpp | 2 +- vm/debug.cpp | 8 +- vm/errors.cpp | 8 +- vm/factor.cpp | 21 +- vm/image.hpp | 2 +- vm/primitives.hpp | 290 +++++++++--------- vm/slot_visitor.hpp | 14 +- vm/vm.cpp | 6 + vm/vm.hpp | 52 ++-- 36 files changed, 557 insertions(+), 406 deletions(-) diff --git a/basis/bootstrap/image/image.factor b/basis/bootstrap/image/image.factor index 3552f0bd92..141a77d2b2 100644 --- a/basis/bootstrap/image/image.factor +++ b/basis/bootstrap/image/image.factor @@ -129,8 +129,8 @@ SYMBOL: jit-literals : jit-vm ( offset rc -- ) [ jit-parameter ] dip rt-vm jit-rel ; -: jit-dlsym ( name library rc -- ) - rt-dlsym jit-rel [ string>symbol jit-parameter ] bi@ ; +: jit-dlsym ( name rc -- ) + rt-dlsym jit-rel string>symbol jit-parameter f jit-parameter ; :: jit-conditional ( test-quot false-quot -- ) [ 0 test-quot call ] B{ } make length :> len diff --git a/basis/command-line/command-line-docs.factor b/basis/command-line/command-line-docs.factor index 9a69614766..b17f8250dd 100644 --- a/basis/command-line/command-line-docs.factor +++ b/basis/command-line/command-line-docs.factor @@ -43,14 +43,16 @@ ARTICLE: "runtime-cli-args" "Command line switches for the VM" { { $snippet "-i=" { $emphasis "image" } } { "Specifies the image file to use; see " { $link "images" } } } { { $snippet "-datastack=" { $emphasis "n" } } "Data stack size, kilobytes" } { { $snippet "-retainstack=" { $emphasis "n" } } "Retain stack size, kilobytes" } + { { $snippet "-callstack=" { $emphasis "n" } } "Call stack size, kilobytes" } { { $snippet "-young=" { $emphasis "n" } } { "Size of youngest generation (0), megabytes" } } { { $snippet "-aging=" { $emphasis "n" } } "Size of aging generation (1), megabytes" } { { $snippet "-tenured=" { $emphasis "n" } } "Size of oldest generation (2), megabytes" } { { $snippet "-codeheap=" { $emphasis "n" } } "Code heap size, megabytes" } + { { $snippet "-callbacks=" { $emphasis "n" } } "Callback heap size, megabytes" } { { $snippet "-pic=" { $emphasis "n" } } "Maximum inline cache size. Setting of 0 disables inline caching, > 1 enables polymorphic inline caching" } { { $snippet "-securegc" } "If specified, unused portions of the data heap will be zeroed out after every garbage collection" } } -"If an " { $snippet "-i=" } " switch is not present, the default image file is used, which is usually a file named " { $snippet "factor.image" } " in the same directory as the runtime executable (on Windows and Mac OS X) or the current directory (on Unix)." ; +"If an " { $snippet "-i=" } " switch is not present, the default image file is used, which is usually a file named " { $snippet "factor.image" } " in the same directory as the Factor executable." ; ARTICLE: "bootstrap-cli-args" "Command line switches for bootstrap" "A number of command line switches can be passed to a bootstrap image to modify the behavior of the resulting image:" diff --git a/basis/compiler/alien/alien.factor b/basis/compiler/alien/alien.factor index 6a63b719df..7426d7e940 100644 --- a/basis/compiler/alien/alien.factor +++ b/basis/compiler/alien/alien.factor @@ -1,17 +1,17 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel namespaces make math sequences layouts alien.c-types cpu.architecture ; IN: compiler.alien -: large-struct? ( ctype -- ? ) +: large-struct? ( type -- ? ) dup c-struct? [ return-struct-in-registers? not ] [ drop f ] if ; : alien-parameters ( params -- seq ) dup parameters>> swap return>> large-struct? [ void* prefix ] when ; -: alien-return ( params -- ctype ) +: alien-return ( params -- type ) return>> dup large-struct? [ drop void ] when ; : c-type-stack-align ( type -- align ) diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index 73cfd6b86e..430bd9550d 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -458,7 +458,7 @@ M: ##alien-indirect generate-insn ! Generate code for boxing input parameters in a callback. [ dup \ %save-param-reg move-parameters - %nest-stacks + %begin-callback box-parameters ] with-param-regs ; @@ -482,5 +482,4 @@ M: ##alien-callback generate-insn params>> [ registers>objects ] [ wrap-callback-quot %alien-callback ] - [ alien-return [ %unnest-stacks ] [ %callback-value ] if-void ] - tri ; + [ alien-return [ %end-callback ] [ %end-callback-value ] if-void ] tri ; diff --git a/basis/compiler/constants/constants.factor b/basis/compiler/constants/constants.factor index 73e77cca4d..9769b72801 100644 --- a/basis/compiler/constants/constants.factor +++ b/basis/compiler/constants/constants.factor @@ -28,10 +28,12 @@ CONSTANT: deck-bits 18 : callstack-length-offset ( -- n ) 1 \ callstack type-number slot-offset ; inline : callstack-top-offset ( -- n ) 2 \ callstack type-number slot-offset ; inline : vm-context-offset ( -- n ) 0 bootstrap-cells ; inline +: vm-spare-context-offset ( -- n ) 1 bootstrap-cells ; inline : context-callstack-top-offset ( -- n ) 0 bootstrap-cells ; inline : context-callstack-bottom-offset ( -- n ) 1 bootstrap-cells ; inline : context-datastack-offset ( -- n ) 2 bootstrap-cells ; inline : context-retainstack-offset ( -- n ) 3 bootstrap-cells ; inline +: context-callstack-save-offset ( -- n ) 4 bootstrap-cells ; inline ! Relocation classes CONSTANT: rc-absolute-cell 0 diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index ad8dac3ef9..692dbee4c5 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -4,7 +4,7 @@ compiler continuations effects io io.backend io.pathnames io.streams.string kernel math memory namespaces namespaces.private parser quotations sequences specialized-arrays stack-checker stack-checker.errors -system threads tools.test words alien.complex ; +system threads tools.test words alien.complex concurrency.promises ; FROM: alien.c-types => float short ; SPECIALIZED-ARRAY: float SPECIALIZED-ARRAY: char @@ -579,6 +579,21 @@ FUNCTION: short ffi_test_48 ( bool-field-test x ) ; ] unless +! Test interaction between threads and callbacks +: thread-callback-1 ( -- callback ) + int { } "cdecl" [ yield 100 ] alien-callback ; + +: thread-callback-2 ( -- callback ) + int { } "cdecl" [ yield 200 ] alien-callback ; + +: thread-callback-invoker ( callback -- n ) + int { } "cdecl" alien-indirect ; + + "p" set +[ thread-callback-1 thread-callback-invoker "p" get fulfill ] in-thread +[ 200 ] [ thread-callback-2 thread-callback-invoker ] unit-test +[ 100 ] [ "p" get ?promise ] unit-test + ! Regression: calling an undefined function would raise a protection fault FUNCTION: void this_does_not_exist ( ) ; diff --git a/basis/cpu/architecture/architecture.factor b/basis/cpu/architecture/architecture.factor index 4d99b5a0ed..b617746a06 100644 --- a/basis/cpu/architecture/architecture.factor +++ b/basis/cpu/architecture/architecture.factor @@ -582,13 +582,13 @@ HOOK: %prepare-alien-indirect cpu ( -- ) HOOK: %alien-indirect cpu ( -- ) +HOOK: %begin-callback cpu ( -- ) + HOOK: %alien-callback cpu ( quot -- ) -HOOK: %callback-value cpu ( ctype -- ) +HOOK: %end-callback cpu ( -- ) -HOOK: %nest-stacks cpu ( -- ) - -HOOK: %unnest-stacks cpu ( -- ) +HOOK: %end-callback-value cpu ( c-type -- ) HOOK: callback-return-rewind cpu ( params -- n ) diff --git a/basis/cpu/ppc/bootstrap.factor b/basis/cpu/ppc/bootstrap.factor index b2ae9c4e73..58c0a4ef7b 100644 --- a/basis/cpu/ppc/bootstrap.factor +++ b/basis/cpu/ppc/bootstrap.factor @@ -267,7 +267,7 @@ CONSTANT: ctx-reg 16 jit-save-context 3 6 MR 4 vm-reg MR - 0 5 LOAD32 "inline_cache_miss" f rc-absolute-ppc-2/2 jit-dlsym + 0 5 LOAD32 "inline_cache_miss" rc-absolute-ppc-2/2 jit-dlsym 5 MTLR BLRL jit-restore-context ; @@ -392,7 +392,7 @@ CONSTANT: ctx-reg 16 1 3 MR ! Call memcpy; arguments are now in the correct registers 1 1 -64 STWU - 0 2 LOAD32 "factor_memcpy" f rc-absolute-ppc-2/2 jit-dlsym + 0 2 LOAD32 "factor_memcpy" rc-absolute-ppc-2/2 jit-dlsym 2 MTLR BLRL 1 1 0 LWZ @@ -405,7 +405,7 @@ CONSTANT: ctx-reg 16 [ jit-save-context 4 vm-reg MR - 0 2 LOAD32 "lazy_jit_compile" f rc-absolute-ppc-2/2 jit-dlsym + 0 2 LOAD32 "lazy_jit_compile" rc-absolute-ppc-2/2 jit-dlsym 2 MTLR BLRL 5 3 quot-entry-point-offset LWZ @@ -665,7 +665,7 @@ CONSTANT: ctx-reg 16 [ BNO ] [ 5 vm-reg MR - 0 6 LOAD32 func f rc-absolute-ppc-2/2 jit-dlsym + 0 6 LOAD32 func rc-absolute-ppc-2/2 jit-dlsym 6 MTLR BLRL ] @@ -689,7 +689,7 @@ CONSTANT: ctx-reg 16 [ 4 4 tag-bits get SRAWI 5 vm-reg MR - 0 6 LOAD32 "overflow_fixnum_multiply" f rc-absolute-ppc-2/2 jit-dlsym + 0 6 LOAD32 "overflow_fixnum_multiply" rc-absolute-ppc-2/2 jit-dlsym 6 MTLR BLRL ] diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor index 6d84aad8d5..36beb86792 100644 --- a/basis/cpu/ppc/ppc.factor +++ b/basis/cpu/ppc/ppc.factor @@ -716,7 +716,7 @@ M: ppc %callback-value ( ctype -- ) 3 1 0 local@ STW 3 %load-vm-addr ! Restore data/call/retain stacks - "unnest_stacks" f %alien-invoke + "unnest_context" f %alien-invoke ! Restore top of data stack 3 1 0 local@ LWZ ! Unbox former top of data stack to return registers @@ -757,13 +757,13 @@ M: ppc %box-small-struct ( c-type -- ) 4 3 4 LWZ 3 3 0 LWZ ; -M: ppc %nest-stacks ( -- ) +M: ppc %nest-context ( -- ) 3 %load-vm-addr - "nest_stacks" f %alien-invoke ; + "nest_context" f %alien-invoke ; -M: ppc %unnest-stacks ( -- ) +M: ppc %unnest-context ( -- ) 3 %load-vm-addr - "unnest_stacks" f %alien-invoke ; + "unnest_context" f %alien-invoke ; M: ppc %unbox-small-struct ( size -- ) heap-size cell align cell /i { diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index b8b621ee11..09f1ecb32b 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -228,14 +228,6 @@ M:: x86.32 %unbox-large-struct ( n c-type -- ) 0 stack@ EAX MOV "to_value_struct" f %alien-invoke ; -M: x86.32 %nest-stacks ( -- ) - 0 save-vm-ptr - "nest_stacks" f %alien-invoke ; - -M: x86.32 %unnest-stacks ( -- ) - 0 save-vm-ptr - "unnest_stacks" f %alien-invoke ; - M: x86.32 %prepare-alien-indirect ( -- ) EAX ds-reg [] MOV ds-reg 4 SUB @@ -247,18 +239,24 @@ M: x86.32 %prepare-alien-indirect ( -- ) M: x86.32 %alien-indirect ( -- ) EBP CALL ; +M: x86.32 %begin-callback ( -- ) + 0 save-vm-ptr + "begin_callback" f %alien-invoke ; + M: x86.32 %alien-callback ( quot -- ) EAX EDX %restore-context EAX swap %load-reference EAX quot-entry-point-offset [+] CALL EAX EDX %save-context ; -M: x86.32 %callback-value ( ctype -- ) +M: x86.32 %end-callback ( -- ) + 0 save-vm-ptr + "end_callback" f %alien-invoke ; + +M: x86.32 %end-callback-value ( ctype -- ) %pop-context-stack 4 stack@ EAX MOV - 0 save-vm-ptr - ! Restore data/call/retain stacks - "unnest_stacks" f %alien-invoke + %end-callback ! Place former top of data stack back in EAX EAX 4 stack@ MOV ! Unbox EAX diff --git a/basis/cpu/x86/32/bootstrap.factor b/basis/cpu/x86/32/bootstrap.factor index cf2d09501c..c7457d2732 100644 --- a/basis/cpu/x86/32/bootstrap.factor +++ b/basis/cpu/x86/32/bootstrap.factor @@ -16,17 +16,20 @@ IN: bootstrap.x86 : temp1 ( -- reg ) EDX ; : temp2 ( -- reg ) ECX ; : temp3 ( -- reg ) EBX ; -: safe-reg ( -- reg ) EAX ; : stack-reg ( -- reg ) ESP ; : frame-reg ( -- reg ) EBP ; : vm-reg ( -- reg ) ECX ; : ctx-reg ( -- reg ) EBP ; : nv-regs ( -- seq ) { ESI EDI EBX } ; +: nv-reg ( -- reg ) nv-regs first ; : ds-reg ( -- reg ) ESI ; : rs-reg ( -- reg ) EDI ; : fixnum>slot@ ( -- ) temp0 2 SAR ; : rex-length ( -- n ) 0 ; +: jit-call ( name -- ) + 0 CALL rc-relative jit-dlsym ; + [ ! save stack frame size stack-frame-size PUSH @@ -49,7 +52,7 @@ IN: bootstrap.x86 ctx-reg vm-reg vm-context-offset [+] MOV ; : jit-save-context ( -- ) - EDX RSP -4 [+] LEA + EDX ESP -4 [+] LEA ctx-reg context-callstack-top-offset [+] EDX MOV ctx-reg context-datastack-offset [+] ds-reg MOV ctx-reg context-retainstack-offset [+] rs-reg MOV ; @@ -70,18 +73,37 @@ IN: bootstrap.x86 ] jit-primitive jit-define [ - ! Load quotation + jit-load-vm + ESP [] vm-reg MOV + "begin_callback" jit-call + + ! load quotation - EBP is ctx-reg so it will get clobbered + ! later on EAX EBP 8 [+] MOV - ! save ctx->callstack_bottom, load ds, rs registers + jit-load-vm jit-load-context jit-restore-context - EDX stack-reg stack-frame-size 4 - [+] LEA - ctx-reg context-callstack-bottom-offset [+] EDX MOV + + ! save C callstack pointer + ctx-reg context-callstack-save-offset [+] ESP MOV + + ! load Factor callstack pointer + ESP ctx-reg context-callstack-bottom-offset [+] MOV + ESP 4 ADD + ! call the quotation EAX quot-entry-point-offset [+] CALL - ! save ds, rs registers + + jit-load-vm + jit-load-context jit-save-context + + ! load C callstack pointer + ESP ctx-reg context-callstack-save-offset [+] MOV + + ESP [] vm-reg MOV + "end_callback" jit-call ] \ c-to-factor define-sub-primitive [ @@ -137,7 +159,7 @@ IN: bootstrap.x86 EDX PUSH EBP PUSH EAX PUSH - 0 CALL "factor_memcpy" f rc-relative jit-dlsym + "factor_memcpy" jit-call ESP 12 ADD ! Return with new callstack 0 RET @@ -153,7 +175,7 @@ IN: bootstrap.x86 ESP 4 [+] vm-reg MOV ! Call VM - 0 CALL "lazy_jit_compile" f rc-relative jit-dlsym + "lazy_jit_compile" jit-call ] [ EAX quot-entry-point-offset [+] CALL ] [ EAX quot-entry-point-offset [+] JMP ] @@ -171,7 +193,7 @@ IN: bootstrap.x86 jit-save-context ESP 4 [+] vm-reg MOV ESP [] EBX MOV - 0 CALL "inline_cache_miss" f rc-relative jit-dlsym + "inline_cache_miss" jit-call jit-restore-context ; [ jit-load-return-address jit-inline-cache-miss ] @@ -200,7 +222,7 @@ IN: bootstrap.x86 ESP [] EAX MOV ESP 4 [+] EDX MOV ESP 8 [+] vm-reg MOV - [ 0 CALL ] dip f rc-relative jit-dlsym + jit-call ] jit-conditional ; @@ -225,7 +247,7 @@ IN: bootstrap.x86 ESP [] EBX MOV ESP 4 [+] EBP MOV ESP 8 [+] vm-reg MOV - 0 CALL "overflow_fixnum_multiply" f rc-relative jit-dlsym + "overflow_fixnum_multiply" jit-call ] jit-conditional ] \ fixnum* define-sub-primitive diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index 856127aedf..04f64f96b6 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -38,6 +38,7 @@ M: x86.64 machine-registers } ; : vm-reg ( -- reg ) R13 ; inline +: nv-reg ( -- reg ) RBX ; inline M: x86.64 %mov-vm-ptr ( reg -- ) vm-reg MOV ; @@ -215,23 +216,19 @@ M: x86.64 %alien-invoke rc-absolute-cell rel-dlsym R11 CALL ; -M: x86.64 %nest-stacks ( -- ) - param-reg-0 %mov-vm-ptr - "nest_stacks" f %alien-invoke ; - -M: x86.64 %unnest-stacks ( -- ) - param-reg-0 %mov-vm-ptr - "unnest_stacks" f %alien-invoke ; - M: x86.64 %prepare-alien-indirect ( -- ) param-reg-0 ds-reg [] MOV ds-reg 8 SUB param-reg-1 %mov-vm-ptr "pinned_alien_offset" f %alien-invoke - RBP RAX MOV ; + nv-reg RAX MOV ; M: x86.64 %alien-indirect ( -- ) - RBP CALL ; + nv-reg CALL ; + +M: x86.64 %begin-callback ( -- ) + param-reg-0 %mov-vm-ptr + "begin_callback" f %alien-invoke ; M: x86.64 %alien-callback ( quot -- ) param-reg-0 param-reg-1 %restore-context @@ -239,16 +236,15 @@ M: x86.64 %alien-callback ( quot -- ) param-reg-0 quot-entry-point-offset [+] CALL param-reg-0 param-reg-1 %save-context ; -M: x86.64 %callback-value ( ctype -- ) - %pop-context-stack - RSP 8 SUB - param-reg-0 PUSH +M: x86.64 %end-callback ( -- ) param-reg-0 %mov-vm-ptr - ! Restore data/call/retain stacks - "unnest_stacks" f %alien-invoke - ! Put former top of data stack in param-reg-0 - param-reg-0 POP - RSP 8 ADD + "end_callback" f %alien-invoke ; + +M: x86.64 %end-callback-value ( ctype -- ) + %pop-context-stack + nv-reg param-reg-0 MOV + %end-callback + param-reg-0 nv-reg MOV ! Unbox former top of data stack to return registers unbox-return ; diff --git a/basis/cpu/x86/64/bootstrap.factor b/basis/cpu/x86/64/bootstrap.factor index bc560580fa..2da9f7564e 100644 --- a/basis/cpu/x86/64/bootstrap.factor +++ b/basis/cpu/x86/64/bootstrap.factor @@ -16,7 +16,7 @@ IN: bootstrap.x86 : temp2 ( -- reg ) RDX ; : temp3 ( -- reg ) RBX ; : return-reg ( -- reg ) RAX ; -: safe-reg ( -- reg ) RAX ; +: nv-reg ( -- reg ) nv-regs first ; : stack-reg ( -- reg ) RSP ; : frame-reg ( -- reg ) RBP ; : ctx-reg ( -- reg ) R12 ; @@ -26,13 +26,17 @@ IN: bootstrap.x86 : fixnum>slot@ ( -- ) temp0 1 SAR ; : rex-length ( -- n ) 1 ; +: jit-call ( name -- ) + RAX 0 MOV rc-absolute-cell jit-dlsym + RAX CALL ; + [ ! load entry point - safe-reg 0 MOV rc-absolute-cell rt-this jit-rel + RAX 0 MOV rc-absolute-cell rt-this jit-rel ! save stack frame size stack-frame-size PUSH ! push entry point - safe-reg PUSH + RAX PUSH ! alignment RSP stack-frame-size 3 bootstrap-cells - SUB ] jit-prolog jit-define @@ -47,8 +51,8 @@ IN: bootstrap.x86 : jit-save-context ( -- ) jit-load-context - safe-reg RSP -8 [+] LEA - ctx-reg context-callstack-top-offset [+] safe-reg MOV + RAX RSP -8 [+] LEA + ctx-reg context-callstack-top-offset [+] RAX MOV ctx-reg context-datastack-offset [+] ds-reg MOV ctx-reg context-retainstack-offset [+] rs-reg MOV ; @@ -67,13 +71,31 @@ IN: bootstrap.x86 ] jit-primitive jit-define [ + nv-reg arg1 MOV + + arg1 vm-reg MOV + "begin_callback" jit-call + jit-restore-context - ! save ctx->callstack_bottom - safe-reg stack-reg stack-frame-size 8 - [+] LEA - ctx-reg context-callstack-bottom-offset [+] safe-reg MOV + + ! save C callstack pointer + ctx-reg context-callstack-save-offset [+] stack-reg MOV + + ! load Factor callstack pointer + stack-reg ctx-reg context-callstack-bottom-offset [+] MOV + stack-reg 8 ADD + ! call the quotation + arg1 nv-reg MOV arg1 quot-entry-point-offset [+] CALL + jit-save-context + + ! load C callstack pointer + stack-reg ctx-reg context-callstack-save-offset [+] MOV + + arg1 vm-reg MOV + "end_callback" jit-call ] \ c-to-factor define-sub-primitive [ @@ -124,8 +146,7 @@ IN: bootstrap.x86 ! Call memcpy; arguments are now in the correct registers ! Create register shadow area for Win64 RSP 32 SUB - safe-reg 0 MOV "factor_memcpy" f rc-absolute-cell jit-dlsym - safe-reg CALL + "factor_memcpy" jit-call ! Tear down register shadow area RSP 32 ADD ! Return with new callstack @@ -135,8 +156,7 @@ IN: bootstrap.x86 [ jit-save-context arg2 vm-reg MOV - safe-reg 0 MOV "lazy_jit_compile" f rc-absolute-cell jit-dlsym - safe-reg CALL + "lazy_jit_compile" jit-call ] [ return-reg quot-entry-point-offset [+] CALL ] [ return-reg quot-entry-point-offset [+] JMP ] @@ -152,8 +172,7 @@ IN: bootstrap.x86 jit-save-context arg1 RBX MOV arg2 vm-reg MOV - RAX 0 MOV "inline_cache_miss" f rc-absolute-cell jit-dlsym - RAX CALL + "inline_cache_miss" jit-call jit-restore-context ; [ jit-load-return-address jit-inline-cache-miss ] @@ -176,11 +195,7 @@ IN: bootstrap.x86 [ [ arg3 arg2 ] dip call ] dip ds-reg [] arg3 MOV [ JNO ] - [ - arg3 vm-reg MOV - RAX 0 MOV f rc-absolute-cell jit-dlsym - RAX CALL - ] + [ arg3 vm-reg MOV jit-call ] jit-conditional ; inline [ [ ADD ] "overflow_fixnum_add" jit-overflow ] \ fixnum+ define-sub-primitive @@ -202,8 +217,7 @@ IN: bootstrap.x86 arg1 tag-bits get SAR arg2 RBX MOV arg3 vm-reg MOV - RAX 0 MOV "overflow_fixnum_multiply" f rc-absolute-cell jit-dlsym - RAX CALL + "overflow_fixnum_multiply" jit-call ] jit-conditional ] \ fixnum* define-sub-primitive diff --git a/basis/cpu/x86/bootstrap.factor b/basis/cpu/x86/bootstrap.factor index 8f1a4d7f49..1c4a6b7796 100644 --- a/basis/cpu/x86/bootstrap.factor +++ b/basis/cpu/x86/bootstrap.factor @@ -13,35 +13,45 @@ big-endian off ! Optimizing compiler's side of callback accesses ! arguments that are on the stack via the frame pointer. ! On x86-64, some arguments are passed in registers, and - ! so the only register that is safe for use here is safe-reg. + ! so the only register that is safe for use here is nv-reg. frame-reg PUSH frame-reg stack-reg MOV ! Save all non-volatile registers nv-regs [ PUSH ] each - ! Save old stack pointer and align - safe-reg stack-reg MOV - stack-reg bootstrap-cell SUB - stack-reg -16 AND - stack-reg [] safe-reg MOV + ! Load VM into vm-reg + vm-reg 0 MOV rc-absolute-cell rt-vm jit-rel - ! Register shadow area - only required on Win64, but doesn't - ! hurt on other platforms - stack-reg 32 SUB + ! Save old context + nv-reg vm-reg vm-context-offset [+] MOV + nv-reg PUSH + + ! Switch over to the spare context + nv-reg vm-reg vm-spare-context-offset [+] MOV + vm-reg vm-context-offset [+] nv-reg MOV + + ! Save C callstack pointer + nv-reg context-callstack-save-offset [+] stack-reg MOV + + ! Load Factor callstack pointer + stack-reg nv-reg context-callstack-bottom-offset [+] MOV + stack-reg bootstrap-cell ADD + + ! Call into Factor code + nv-reg 0 MOV rc-absolute-cell rt-entry-point jit-rel + nv-reg CALL ! Load VM into vm-reg vm-reg 0 MOV rc-absolute-cell rt-vm jit-rel - ! Call into Factor code - safe-reg 0 MOV rc-absolute-cell rt-entry-point jit-rel - safe-reg CALL + ! Load C callstack pointer + nv-reg vm-reg vm-context-offset [+] MOV + stack-reg nv-reg context-callstack-save-offset [+] MOV - ! Tear down register shadow area - stack-reg 32 ADD - - ! Undo stack alignment - stack-reg stack-reg [] MOV + ! Load old context + nv-reg POP + vm-reg vm-context-offset [+] nv-reg MOV ! Restore non-volatile registers nv-regs [ POP ] each @@ -56,15 +66,15 @@ big-endian off [ ! Load word - safe-reg 0 MOV rc-absolute-cell rt-literal jit-rel + temp0 0 MOV rc-absolute-cell rt-literal jit-rel ! Bump profiling counter - safe-reg profile-count-offset [+] 1 tag-fixnum ADD + temp0 profile-count-offset [+] 1 tag-fixnum ADD ! Load word->code - safe-reg safe-reg word-code-offset [+] MOV + temp0 temp0 word-code-offset [+] MOV ! Compute word entry point - safe-reg compiled-header-size ADD + temp0 compiled-header-size ADD ! Jump to entry point - safe-reg JMP + temp0 JMP ] jit-profiling jit-define [ diff --git a/basis/cpu/x86/x86.factor b/basis/cpu/x86/x86.factor index e54e307f79..dbb112bf4b 100644 --- a/basis/cpu/x86/x86.factor +++ b/basis/cpu/x86/x86.factor @@ -1403,10 +1403,7 @@ M: x86 %loop-entry 16 code-alignment [ NOP ] times ; M:: x86 %restore-context ( temp1 temp2 -- ) #! Load Factor stack pointers on entry from C to Factor. - #! Also save callstack bottom! temp1 "ctx" %vm-field - temp2 stack-reg stack-frame get total-size>> cell - [+] LEA - temp1 "callstack-bottom" context-field-offset [+] temp2 MOV ds-reg temp1 "datastack" context-field-offset [+] MOV rs-reg temp1 "retainstack" context-field-offset [+] MOV ; diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index d0cbb05919..289afcf28c 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -1,19 +1,20 @@ ! Copyright (C) 2004, 2010 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: fry accessors alien alien.accessors arrays byte-arrays -classes continuations.private effects generic hashtables -hashtables.private io io.backend io.files io.files.private -io.streams.c kernel kernel.private math math.private -math.parser.private memory memory.private namespaces -namespaces.private parser quotations quotations.private sbufs -sbufs.private sequences sequences.private slots.private strings -strings.private system threads.private classes.tuple -classes.tuple.private vectors vectors.private words -words.private definitions assocs summary compiler.units -system.private combinators combinators.short-circuit locals -locals.backend locals.types combinators.private -stack-checker.values generic.single generic.single.private -alien.libraries tools.dispatch.private tools.profiler.private +USING: fry accessors alien alien.accessors alien.private arrays +byte-arrays classes continuations.private effects generic +hashtables hashtables.private io io.backend io.files +io.files.private io.streams.c kernel kernel.private math +math.private math.parser.private memory memory.private +namespaces namespaces.private parser quotations +quotations.private sbufs sbufs.private sequences +sequences.private slots.private strings strings.private system +threads.private classes.tuple classes.tuple.private vectors +vectors.private words words.private definitions assocs summary +compiler.units system.private combinators +combinators.short-circuit locals locals.backend locals.types +combinators.private stack-checker.values generic.single +generic.single.private alien.libraries tools.dispatch.private +tools.profiler.private stack-checker.alien stack-checker.state stack-checker.errors @@ -504,6 +505,16 @@ M: bad-executable summary \ word-code { word } { integer integer } define-primitive \ word-code make-flushable +\ current-callback { } { fixnum } define-primitive +\ current-callback make-flushable + +\ current-context { } { c-ptr } define-primitive +\ current-context make-flushable + +\ delete-context { c-ptr } { } define-primitive + +\ start-context { quotation } { } define-primitive + \ special-object { fixnum } { object } define-primitive \ special-object make-flushable diff --git a/basis/vm/vm.factor b/basis/vm/vm.factor index cc4a291a8b..b0f2c945f7 100644 --- a/basis/vm/vm.factor +++ b/basis/vm/vm.factor @@ -10,12 +10,11 @@ STRUCT: context { callstack-bottom void* } { datastack cell } { retainstack cell } -{ magic-frame void* } +{ callstack-save cell } +{ context-objects cell[10] } { datastack-region void* } { retainstack-region void* } -{ catchstack-save cell } -{ current-callback-save cell } -{ next context* } ; +{ callstack-region void* } ; : context-field-offset ( field -- offset ) context offset-of ; inline @@ -27,6 +26,7 @@ STRUCT: zone STRUCT: vm { ctx context* } +{ spare-ctx context* } { nursery zone } { cards-offset cell } { decks-offset cell } diff --git a/core/alien/alien.factor b/core/alien/alien.factor index 191886393a..a44d703fbc 100644 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -94,26 +94,21 @@ SYMBOL: callbacks [ H{ } clone callbacks set-global ] "alien" add-startup-hook -! Every context object in the VM is identified from the Factor -! side by a unique identifier -TUPLE: context-id < identity-tuple ; - -C: context-id - -: context-id ( -- id ) 2 context-object ; - -: set-context-id ( id -- ) 2 set-context-object ; - -: wait-to-return ( yield-quot id -- ) - dup context-id eq? +! Every callback invocation has a unique identifier in the VM. +! We make sure that the current callback is the right one before +! returning from it, to avoid a bad interaction between threads +! and callbacks. See basis/compiler/tests/alien.factor for a +! test case. +: wait-to-return ( yield-quot callback-id -- ) + dup current-callback eq? [ 2drop ] [ over call( -- ) wait-to-return ] if ; ! Used by compiler.codegen to wrap callback bodies : do-callback ( callback-quot yield-quot -- ) init-namespaces init-catchstack - - [ set-context-id drop call ] [ wait-to-return drop ] 3bi ; inline + current-callback + [ 2drop call ] [ wait-to-return drop ] 3bi ; inline ! A utility for defining global variables that are recompiled in ! every session diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 19a179a6b1..9bf7be31a2 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -63,6 +63,7 @@ call( -- ) "alien" "alien.accessors" "alien.libraries" + "alien.private" "arrays" "byte-arrays" "classes.private" @@ -415,6 +416,7 @@ tuple { "(dlsym)" "alien.libraries" "primitive_dlsym" (( name dll -- alien )) } { "dlclose" "alien.libraries" "primitive_dlclose" (( dll -- )) } { "dll-valid?" "alien.libraries" "primitive_dll_validp" (( dll -- ? )) } + { "current-callback" "alien.private" "primitive_current_callback" (( -- n )) } { "" "arrays" "primitive_array" (( n elt -- array )) } { "resize-array" "arrays" "primitive_resize_array" (( n array -- newarray )) } { "(byte-array)" "byte-arrays" "primitive_uninitialized_byte_array" (( n -- byte-array )) } @@ -532,6 +534,9 @@ tuple { "nano-count" "system" "primitive_nano_count" (( -- ns )) } { "system-micros" "system" "primitive_system_micros" (( -- us )) } { "(sleep)" "threads.private" "primitive_sleep" (( nanos -- )) } + { "current-context" "threads.private" "primitive_current_context" (( -- c-ptr )) } + { "delete-context" "threads.private" "primitive_delete_context" (( c-ptr -- )) } + { "start-context" "threads.private" "primitive_start_context" (( quot -- )) } { "dispatch-stats" "tools.dispatch.private" "primitive_dispatch_stats" (( -- stats )) } { "reset-dispatch-stats" "tools.dispatch.private" "primitive_reset_dispatch_stats" (( -- )) } { "profiling" "tools.profiler.private" "primitive_profiling" (( ? -- )) } diff --git a/vm/callbacks.cpp b/vm/callbacks.cpp index 416c1395d4..6c8165f5c4 100644 --- a/vm/callbacks.cpp +++ b/vm/callbacks.cpp @@ -64,11 +64,12 @@ code_block *callback_heap::add(cell owner, cell return_rewind) /* Store VM pointer */ store_callback_operand(stub,0,(cell)parent); + store_callback_operand(stub,2,(cell)parent); /* On x86, the RET instruction takes an argument which depends on the callback's calling convention */ #if defined(FACTOR_X86) || defined(FACTOR_AMD64) - store_callback_operand(stub,2,return_rewind); + store_callback_operand(stub,3,return_rewind); #endif update(stub); diff --git a/vm/callstack.cpp b/vm/callstack.cpp index 195b212d8b..8389ff8d90 100755 --- a/vm/callstack.cpp +++ b/vm/callstack.cpp @@ -13,7 +13,7 @@ void factor_vm::check_frame(stack_frame *frame) callstack *factor_vm::allot_callstack(cell size) { - callstack *stack = allot(callstack_size(size)); + callstack *stack = allot(callstack_object_size(size)); stack->length = tag_fixnum(size); return stack; } diff --git a/vm/callstack.hpp b/vm/callstack.hpp index 9f8867447c..9f0693eb76 100755 --- a/vm/callstack.hpp +++ b/vm/callstack.hpp @@ -1,7 +1,7 @@ namespace factor { -inline static cell callstack_size(cell size) +inline static cell callstack_object_size(cell size) { return sizeof(callstack) + size; } diff --git a/vm/code_block_visitor.hpp b/vm/code_block_visitor.hpp index ac5d140783..deaa41e4b8 100644 --- a/vm/code_block_visitor.hpp +++ b/vm/code_block_visitor.hpp @@ -114,7 +114,7 @@ template void code_block_visitor::visit_context_code_blocks() { call_frame_code_block_visitor call_frame_visitor(parent,visitor); - parent->iterate_active_frames(call_frame_visitor); + parent->iterate_active_callstacks(call_frame_visitor); } template diff --git a/vm/contexts.cpp b/vm/contexts.cpp index 1079c572d2..b5ca348d14 100644 --- a/vm/contexts.cpp +++ b/vm/contexts.cpp @@ -3,28 +3,32 @@ namespace factor { -context::context(cell ds_size, cell rs_size) : +context::context(cell datastack_size, cell retainstack_size, cell callstack_size) : callstack_top(NULL), callstack_bottom(NULL), datastack(0), retainstack(0), - datastack_region(new segment(ds_size,false)), - retainstack_region(new segment(rs_size,false)), - next(NULL) + callstack_save(0), + datastack_seg(new segment(datastack_size,false)), + retainstack_seg(new segment(retainstack_size,false)), + callstack_seg(new segment(callstack_size,false)) { - reset_datastack(); - reset_retainstack(); - reset_context_objects(); + reset(); } void context::reset_datastack() { - datastack = datastack_region->start - sizeof(cell); + datastack = datastack_seg->start - sizeof(cell); } void context::reset_retainstack() { - retainstack = retainstack_region->start - sizeof(cell); + retainstack = retainstack_seg->start - sizeof(cell); +} + +void context::reset_callstack() +{ + callstack_top = callstack_bottom = CALLSTACK_BOTTOM(this); } void context::reset_context_objects() @@ -32,68 +36,99 @@ void context::reset_context_objects() memset_cell(context_objects,false_object,context_object_count * sizeof(cell)); } -context *factor_vm::alloc_context() +void context::reset() +{ + reset_datastack(); + reset_retainstack(); + reset_callstack(); + reset_context_objects(); +} + +context::~context() +{ + delete datastack_seg; + delete retainstack_seg; + delete callstack_seg; +} + +/* called on startup */ +void factor_vm::init_contexts(cell datastack_size_, cell retainstack_size_, cell callstack_size_) +{ + datastack_size = datastack_size_; + retainstack_size = retainstack_size_; + callstack_size = callstack_size_; + + ctx = NULL; + spare_ctx = new_context(); +} + +void factor_vm::delete_contexts() +{ + assert(!ctx); + std::vector::const_iterator iter = unused_contexts.begin(); + std::vector::const_iterator end = unused_contexts.end(); + while(iter != end) + { + delete *iter; + iter++; + } +} + +context *factor_vm::new_context() { context *new_context; - if(unused_contexts) + if(unused_contexts.empty()) { - new_context = unused_contexts; - unused_contexts = unused_contexts->next; + new_context = new context(datastack_size, + retainstack_size, + callstack_size); } else - new_context = new context(ds_size,rs_size); + { + new_context = unused_contexts.back(); + unused_contexts.pop_back(); + } + + new_context->reset(); + + active_contexts.insert(new_context); return new_context; } -void factor_vm::dealloc_context(context *old_context) +void factor_vm::delete_context(context *old_context) { - old_context->next = unused_contexts; - unused_contexts = old_context; + unused_contexts.push_back(old_context); + active_contexts.erase(old_context); } -/* called on entry into a compiled callback */ -void factor_vm::nest_stacks() +void factor_vm::begin_callback() { - context *new_ctx = alloc_context(); - - new_ctx->callstack_bottom = (stack_frame *)-1; - new_ctx->callstack_top = (stack_frame *)-1; - - new_ctx->reset_datastack(); - new_ctx->reset_retainstack(); - new_ctx->reset_context_objects(); - - new_ctx->next = ctx; - ctx = new_ctx; + ctx->reset(); + spare_ctx = new_context(); + callback_ids.push_back(callback_id++); } -void nest_stacks(factor_vm *parent) +void begin_callback(factor_vm *parent) { - return parent->nest_stacks(); + parent->begin_callback(); } -/* called when leaving a compiled callback */ -void factor_vm::unnest_stacks() +void factor_vm::end_callback() { - context *old_ctx = ctx; - ctx = old_ctx->next; - dealloc_context(old_ctx); + callback_ids.pop_back(); + delete_context(ctx); } -void unnest_stacks(factor_vm *parent) +void end_callback(factor_vm *parent) { - return parent->unnest_stacks(); + parent->end_callback(); } -/* called on startup */ -void factor_vm::init_stacks(cell ds_size_, cell rs_size_) +void factor_vm::primitive_current_callback() { - ds_size = ds_size_; - rs_size = rs_size_; - ctx = NULL; - unused_contexts = NULL; + ctx->push(tag_fixnum(callback_ids.back())); } void factor_vm::primitive_context_object() @@ -126,13 +161,13 @@ bool factor_vm::stack_to_array(cell bottom, cell top) void factor_vm::primitive_datastack() { - if(!stack_to_array(ctx->datastack_region->start,ctx->datastack)) + if(!stack_to_array(ctx->datastack_seg->start,ctx->datastack)) general_error(ERROR_DS_UNDERFLOW,false_object,false_object,NULL); } void factor_vm::primitive_retainstack() { - if(!stack_to_array(ctx->retainstack_region->start,ctx->retainstack)) + if(!stack_to_array(ctx->retainstack_seg->start,ctx->retainstack)) general_error(ERROR_RS_UNDERFLOW,false_object,false_object,NULL); } @@ -146,12 +181,12 @@ cell factor_vm::array_to_stack(array *array, cell bottom) void factor_vm::primitive_set_datastack() { - ctx->datastack = array_to_stack(untag_check(ctx->pop()),ctx->datastack_region->start); + ctx->datastack = array_to_stack(untag_check(ctx->pop()),ctx->datastack_seg->start); } void factor_vm::primitive_set_retainstack() { - ctx->retainstack = array_to_stack(untag_check(ctx->pop()),ctx->retainstack_region->start); + ctx->retainstack = array_to_stack(untag_check(ctx->pop()),ctx->retainstack_seg->start); } /* Used to implement call( */ @@ -162,12 +197,12 @@ void factor_vm::primitive_check_datastack() fixnum height = out - in; array *saved_datastack = untag_check(ctx->pop()); fixnum saved_height = array_capacity(saved_datastack); - fixnum current_height = (ctx->datastack - ctx->datastack_region->start + sizeof(cell)) / sizeof(cell); + fixnum current_height = (ctx->datastack - ctx->datastack_seg->start + sizeof(cell)) / sizeof(cell); if(current_height - height != saved_height) ctx->push(false_object); else { - cell *ds_bot = (cell *)ctx->datastack_region->start; + cell *ds_bot = (cell *)ctx->datastack_seg->start; for(fixnum i = 0; i < saved_height - in; i++) { if(ds_bot[i] != array_nth(saved_datastack,i)) @@ -190,4 +225,22 @@ void factor_vm::primitive_load_locals() ctx->retainstack += sizeof(cell) * count; } +void factor_vm::primitive_current_context() +{ + ctx->push(allot_alien(ctx)); +} + +void factor_vm::primitive_start_context() +{ + cell quot = ctx->pop(); + ctx = new_context(); + unwind_native_frames(quot,ctx->callstack_bottom); +} + +void factor_vm::primitive_delete_context() +{ + context *old_context = (context *)pinned_alien_offset(ctx->pop()); + delete_context(old_context); +} + } diff --git a/vm/contexts.hpp b/vm/contexts.hpp index e555bd4a92..e746e53ffa 100644 --- a/vm/contexts.hpp +++ b/vm/contexts.hpp @@ -6,12 +6,13 @@ static const cell context_object_count = 10; enum context_object { OBJ_NAMESTACK, OBJ_CATCHSTACK, - OBJ_CONTEXT_ID, }; -/* Assembly code makes assumptions about the layout of this struct */ struct context { - /* C stack pointer on entry */ + + // First 4 fields accessed directly by compiler. See basis/vm/vm.factor + + /* Factor callstack pointers */ stack_frame *callstack_top; stack_frame *callstack_bottom; @@ -21,22 +22,25 @@ struct context { /* current retain stack top pointer */ cell retainstack; - /* memory region holding current datastack */ - segment *datastack_region; - - /* memory region holding current retain stack */ - segment *retainstack_region; + /* C callstack pointer */ + cell callstack_save; /* context-specific special objects, accessed by context-object and set-context-object primitives */ cell context_objects[context_object_count]; - context *next; + segment *datastack_seg; + segment *retainstack_seg; + segment *callstack_seg; + + context(cell datastack_size, cell retainstack_size, cell callstack_size); + ~context(); - context(cell ds_size, cell rs_size); void reset_datastack(); void reset_retainstack(); + void reset_callstack(); void reset_context_objects(); + void reset(); cell peek() { @@ -65,17 +69,17 @@ struct context { void fix_stacks() { - if(datastack + sizeof(cell) < datastack_region->start - || datastack + stack_reserved >= datastack_region->end) + if(datastack + sizeof(cell) < datastack_seg->start + || datastack + stack_reserved >= datastack_seg->end) reset_datastack(); - if(retainstack + sizeof(cell) < retainstack_region->start - || retainstack + stack_reserved >= retainstack_region->end) + if(retainstack + sizeof(cell) < retainstack_seg->start + || retainstack + stack_reserved >= retainstack_seg->end) reset_retainstack(); } }; -VM_C_API void nest_stacks(factor_vm *vm); -VM_C_API void unnest_stacks(factor_vm *vm); +VM_C_API void begin_callback(factor_vm *vm); +VM_C_API void end_callback(factor_vm *vm); } diff --git a/vm/cpu-ppc.hpp b/vm/cpu-ppc.hpp index d09fc173ea..6e76164308 100644 --- a/vm/cpu-ppc.hpp +++ b/vm/cpu-ppc.hpp @@ -3,6 +3,8 @@ namespace factor #define FACTOR_CPU_STRING "ppc" +#define CALLSTACK_BOTTOM(ctx) (stack_frame *)ctx->callstack_seg->end + /* In the instruction sequence: LOAD32 r3,... diff --git a/vm/cpu-x86.hpp b/vm/cpu-x86.hpp index ac8ac51ade..bfdcd8afb2 100644 --- a/vm/cpu-x86.hpp +++ b/vm/cpu-x86.hpp @@ -5,6 +5,8 @@ namespace factor #define FRAME_RETURN_ADDRESS(frame,vm) *(void **)(vm->frame_successor(frame) + 1) +#define CALLSTACK_BOTTOM(ctx) (stack_frame *)(ctx->callstack_seg->end - sizeof(cell)) + inline static void flush_icache(cell start, cell len) {} /* In the instruction sequence: diff --git a/vm/data_heap.cpp b/vm/data_heap.cpp index 22ef39e868..9b28215bb8 100755 --- a/vm/data_heap.cpp +++ b/vm/data_heap.cpp @@ -159,7 +159,7 @@ cell object::size() const case WRAPPER_TYPE: return align(sizeof(wrapper),data_alignment); case CALLSTACK_TYPE: - return align(callstack_size(untag_fixnum(((callstack *)this)->length)),data_alignment); + return align(callstack_object_size(untag_fixnum(((callstack *)this)->length)),data_alignment); default: critical_error("Invalid header",(cell)this); return 0; /* can't happen */ diff --git a/vm/debug.cpp b/vm/debug.cpp index e82394951a..85335d49ae 100755 --- a/vm/debug.cpp +++ b/vm/debug.cpp @@ -145,13 +145,13 @@ void factor_vm::print_objects(cell *start, cell *end) void factor_vm::print_datastack() { std::cout << "==== DATA STACK:\n"; - print_objects((cell *)ctx->datastack_region->start,(cell *)ctx->datastack); + print_objects((cell *)ctx->datastack_seg->start,(cell *)ctx->datastack); } void factor_vm::print_retainstack() { std::cout << "==== RETAIN STACK:\n"; - print_objects((cell *)ctx->retainstack_region->start,(cell *)ctx->retainstack); + print_objects((cell *)ctx->retainstack_seg->start,(cell *)ctx->retainstack); } struct stack_frame_printer { @@ -421,9 +421,9 @@ void factor_vm::factorbug() else if(strcmp(cmd,"t") == 0) full_output = !full_output; else if(strcmp(cmd,"s") == 0) - dump_memory(ctx->datastack_region->start,ctx->datastack); + dump_memory(ctx->datastack_seg->start,ctx->datastack); else if(strcmp(cmd,"r") == 0) - dump_memory(ctx->retainstack_region->start,ctx->retainstack); + dump_memory(ctx->retainstack_seg->start,ctx->retainstack); else if(strcmp(cmd,".s") == 0) print_datastack(); else if(strcmp(cmd,".r") == 0) diff --git a/vm/errors.cpp b/vm/errors.cpp index ae560012aa..8efcb3346f 100755 --- a/vm/errors.cpp +++ b/vm/errors.cpp @@ -99,13 +99,13 @@ bool factor_vm::in_page(cell fault, cell area, cell area_size, int offset) void factor_vm::memory_protection_error(cell addr, stack_frame *native_stack) { - if(in_page(addr, ctx->datastack_region->start, 0, -1)) + if(in_page(addr, ctx->datastack_seg->start, 0, -1)) general_error(ERROR_DS_UNDERFLOW,false_object,false_object,native_stack); - else if(in_page(addr, ctx->datastack_region->start, ds_size, 0)) + else if(in_page(addr, ctx->datastack_seg->start, datastack_size, 0)) general_error(ERROR_DS_OVERFLOW,false_object,false_object,native_stack); - else if(in_page(addr, ctx->retainstack_region->start, 0, -1)) + else if(in_page(addr, ctx->retainstack_seg->start, 0, -1)) general_error(ERROR_RS_UNDERFLOW,false_object,false_object,native_stack); - else if(in_page(addr, ctx->retainstack_region->start, rs_size, 0)) + else if(in_page(addr, ctx->retainstack_seg->start, retainstack_size, 0)) general_error(ERROR_RS_OVERFLOW,false_object,false_object,native_stack); else if(in_page(addr, nursery.end, 0, 0)) critical_error("allot_object() missed GC check",0); diff --git a/vm/factor.cpp b/vm/factor.cpp index 4433095173..c38e38a5d0 100755 --- a/vm/factor.cpp +++ b/vm/factor.cpp @@ -14,8 +14,9 @@ void factor_vm::default_parameters(vm_parameters *p) { p->image_path = NULL; - p->ds_size = 32 * sizeof(cell); - p->rs_size = 32 * sizeof(cell); + p->datastack_size = 32 * sizeof(cell); + p->retainstack_size = 32 * sizeof(cell); + p->callstack_size = 128 * sizeof(cell); p->code_size = 8 * sizeof(cell); p->young_size = sizeof(cell) / 4; @@ -59,8 +60,9 @@ void factor_vm::init_parameters_from_args(vm_parameters *p, int argc, vm_char ** { vm_char *arg = argv[i]; if(STRCMP(arg,STRING_LITERAL("--")) == 0) break; - else if(factor_arg(arg,STRING_LITERAL("-datastack=%d"),&p->ds_size)); - else if(factor_arg(arg,STRING_LITERAL("-retainstack=%d"),&p->rs_size)); + else if(factor_arg(arg,STRING_LITERAL("-datastack=%d"),&p->datastack_size)); + else if(factor_arg(arg,STRING_LITERAL("-retainstack=%d"),&p->retainstack_size)); + else if(factor_arg(arg,STRING_LITERAL("-callstack=%d"),&p->callstack_size)); else if(factor_arg(arg,STRING_LITERAL("-young=%d"),&p->young_size)); else if(factor_arg(arg,STRING_LITERAL("-aging=%d"),&p->aging_size)); else if(factor_arg(arg,STRING_LITERAL("-tenured=%d"),&p->tenured_size)); @@ -91,8 +93,9 @@ void factor_vm::prepare_boot_image() void factor_vm::init_factor(vm_parameters *p) { /* Kilobytes */ - p->ds_size = align_page(p->ds_size << 10); - p->rs_size = align_page(p->rs_size << 10); + p->datastack_size = align_page(p->datastack_size << 10); + p->retainstack_size = align_page(p->retainstack_size << 10); + p->callstack_size = align_page(p->retainstack_size << 10); p->callback_size = align_page(p->callback_size << 10); /* Megabytes */ @@ -117,7 +120,7 @@ void factor_vm::init_factor(vm_parameters *p) srand((unsigned int)system_micros()); init_ffi(); - init_stacks(p->ds_size,p->rs_size); + init_contexts(p->datastack_size,p->retainstack_size,p->callstack_size); init_callbacks(p->callback_size); load_image(p); init_c_io(); @@ -161,16 +164,12 @@ void factor_vm::start_factor(vm_parameters *p) { if(p->fep) factorbug(); - nest_stacks(); c_to_factor_toplevel(special_objects[OBJ_STARTUP_QUOT]); - unnest_stacks(); } void factor_vm::stop_factor() { - nest_stacks(); c_to_factor_toplevel(special_objects[OBJ_SHUTDOWN_QUOT]); - unnest_stacks(); } char *factor_vm::factor_eval_string(char *string) diff --git a/vm/image.hpp b/vm/image.hpp index 101482b1da..40ffa28d11 100755 --- a/vm/image.hpp +++ b/vm/image.hpp @@ -30,7 +30,7 @@ struct image_header { struct vm_parameters { const vm_char *image_path; const vm_char *executable_path; - cell ds_size, rs_size; + cell datastack_size, retainstack_size, callstack_size; cell young_size, aging_size, tenured_size; cell code_size; bool fep; diff --git a/vm/primitives.hpp b/vm/primitives.hpp index df36ed84b2..cbbadd2596 100644 --- a/vm/primitives.hpp +++ b/vm/primitives.hpp @@ -2,157 +2,159 @@ namespace factor { /* Generated with PRIMITIVE in primitives.cpp */ -#define EACH_PRIMITIVE(_) \ - _(alien_address) \ - _(all_instances) \ - _(array) \ - _(array_to_quotation) \ - _(become) \ - _(bignum_add) \ - _(bignum_and) \ - _(bignum_bitp) \ - _(bignum_divint) \ - _(bignum_divmod) \ - _(bignum_eq) \ - _(bignum_greater) \ - _(bignum_greatereq) \ - _(bignum_less) \ - _(bignum_lesseq) \ - _(bignum_log2) \ - _(bignum_mod) \ - _(bignum_multiply) \ - _(bignum_not) \ - _(bignum_or) \ - _(bignum_shift) \ - _(bignum_subtract) \ - _(bignum_to_fixnum) \ - _(bignum_to_float) \ - _(bignum_xor) \ - _(bits_double) \ - _(bits_float) \ - _(byte_array) \ - _(byte_array_to_bignum) \ - _(call_clear) \ - _(callback) \ - _(callstack) \ - _(callstack_to_array) \ - _(check_datastack) \ - _(clone) \ - _(code_blocks) \ - _(code_room) \ - _(compact_gc) \ - _(compute_identity_hashcode) \ - _(context_object) \ - _(data_room) \ - _(datastack) \ - _(die) \ - _(disable_gc_events) \ - _(dispatch_stats) \ - _(displaced_alien) \ - _(dlclose) \ - _(dll_validp) \ - _(dlopen) \ - _(dlsym) \ - _(double_bits) \ - _(enable_gc_events) \ - _(existsp) \ - _(exit) \ - _(fclose) \ - _(fflush) \ - _(fgetc) \ - _(fixnum_divint) \ - _(fixnum_divmod) \ - _(fixnum_shift) \ - _(fixnum_to_bignum) \ - _(fixnum_to_float) \ - _(float_add) \ - _(float_bits) \ - _(float_divfloat) \ - _(float_eq) \ - _(float_greater) \ - _(float_greatereq) \ - _(float_less) \ - _(float_lesseq) \ - _(float_mod) \ - _(float_multiply) \ - _(float_subtract) \ - _(float_to_bignum) \ - _(float_to_fixnum) \ - _(float_to_str) \ - _(fopen) \ - _(fputc) \ - _(fread) \ - _(fseek) \ - _(ftell) \ - _(full_gc) \ - _(fwrite) \ - _(identity_hashcode) \ - _(innermost_stack_frame_executing) \ - _(innermost_stack_frame_scan) \ - _(jit_compile) \ - _(load_locals) \ - _(lookup_method) \ - _(mega_cache_miss) \ - _(minor_gc) \ - _(modify_code_heap) \ - _(nano_count) \ - _(optimized_p) \ - _(profiling) \ - _(quot_compiled_p) \ - _(quotation_code) \ - _(reset_dispatch_stats) \ - _(resize_array) \ - _(resize_byte_array) \ - _(resize_string) \ - _(retainstack) \ - _(save_image) \ - _(save_image_and_exit) \ - _(set_context_object) \ - _(set_datastack) \ - _(set_innermost_stack_frame_quot) \ - _(set_retainstack) \ - _(set_slot) \ - _(set_special_object) \ - _(set_string_nth_fast) \ - _(set_string_nth_slow) \ - _(size) \ - _(sleep) \ - _(special_object) \ - _(string) \ - _(string_nth) \ - _(strip_stack_traces) \ - _(system_micros) \ - _(tuple) \ - _(tuple_boa) \ - _(unimplemented) \ - _(uninitialized_byte_array) \ - _(word) \ - _(word_code) \ - _(wrapper) -/* These are generated with macros in alien.cpp, and not with PRIMIIVE in -primitives.cpp */ +#define EACH_PRIMITIVE(_) \ + _(alien_address) \ + _(all_instances) \ + _(array) \ + _(array_to_quotation) \ + _(become) \ + _(bignum_add) \ + _(bignum_and) \ + _(bignum_bitp) \ + _(bignum_divint) \ + _(bignum_divmod) \ + _(bignum_eq) \ + _(bignum_greater) \ + _(bignum_greatereq) \ + _(bignum_less) \ + _(bignum_lesseq) \ + _(bignum_log2) \ + _(bignum_mod) \ + _(bignum_multiply) \ + _(bignum_not) \ + _(bignum_or) \ + _(bignum_shift) \ + _(bignum_subtract) \ + _(bignum_to_fixnum) \ + _(bignum_to_float) \ + _(bignum_xor) \ + _(bits_double) \ + _(bits_float) \ + _(byte_array) \ + _(byte_array_to_bignum) \ + _(call_clear) \ + _(callback) \ + _(callstack) \ + _(callstack_to_array) \ + _(check_datastack) \ + _(clone) \ + _(code_blocks) \ + _(code_room) \ + _(compact_gc) \ + _(compute_identity_hashcode) \ + _(context_object) \ + _(current_callback) \ + _(current_context) \ + _(data_room) \ + _(datastack) \ + _(delete_context) \ + _(die) \ + _(disable_gc_events) \ + _(dispatch_stats) \ + _(displaced_alien) \ + _(dlclose) \ + _(dll_validp) \ + _(dlopen) \ + _(dlsym) \ + _(double_bits) \ + _(enable_gc_events) \ + _(existsp) \ + _(exit) \ + _(fclose) \ + _(fflush) \ + _(fgetc) \ + _(fixnum_divint) \ + _(fixnum_divmod) \ + _(fixnum_shift) \ + _(fixnum_to_bignum) \ + _(fixnum_to_float) \ + _(float_add) \ + _(float_bits) \ + _(float_divfloat) \ + _(float_eq) \ + _(float_greater) \ + _(float_greatereq) \ + _(float_less) \ + _(float_lesseq) \ + _(float_mod) \ + _(float_multiply) \ + _(float_subtract) \ + _(float_to_bignum) \ + _(float_to_fixnum) \ + _(float_to_str) \ + _(fopen) \ + _(fputc) \ + _(fread) \ + _(fseek) \ + _(ftell) \ + _(full_gc) \ + _(fwrite) \ + _(identity_hashcode) \ + _(innermost_stack_frame_executing) \ + _(innermost_stack_frame_scan) \ + _(jit_compile) \ + _(load_locals) \ + _(lookup_method) \ + _(mega_cache_miss) \ + _(minor_gc) \ + _(modify_code_heap) \ + _(nano_count) \ + _(optimized_p) \ + _(profiling) \ + _(quot_compiled_p) \ + _(quotation_code) \ + _(reset_dispatch_stats) \ + _(resize_array) \ + _(resize_byte_array) \ + _(resize_string) \ + _(retainstack) \ + _(save_image) \ + _(save_image_and_exit) \ + _(set_context_object) \ + _(set_datastack) \ + _(set_innermost_stack_frame_quot) \ + _(set_retainstack) \ + _(set_slot) \ + _(set_special_object) \ + _(set_string_nth_fast) \ + _(set_string_nth_slow) \ + _(size) \ + _(sleep) \ + _(special_object) \ + _(start_context) \ + _(string) \ + _(string_nth) \ + _(strip_stack_traces) \ + _(system_micros) \ + _(tuple) \ + _(tuple_boa) \ + _(unimplemented) \ + _(uninitialized_byte_array) \ + _(word) \ + _(word_code) \ + _(wrapper) #define EACH_ALIEN_PRIMITIVE(_) \ - _(signed_cell,fixnum,from_signed_cell,to_fixnum) \ - _(unsigned_cell,cell,from_unsigned_cell,to_cell) \ - _(signed_8,s64,from_signed_8,to_signed_8) \ - _(unsigned_8,u64,from_unsigned_8,to_unsigned_8) \ - _(signed_4,s32,from_signed_4,to_fixnum) \ - _(unsigned_4,u32,from_unsigned_4,to_cell) \ - _(signed_2,s16,from_signed_2,to_fixnum) \ - _(unsigned_2,u16,from_unsigned_2,to_cell) \ - _(signed_1,s8,from_signed_1,to_fixnum) \ - _(unsigned_1,u8,from_unsigned_1,to_cell) \ - _(float,float,from_float,to_float) \ - _(double,double,from_double,to_double) \ - _(cell,void *,allot_alien,pinned_alien_offset) + _(signed_cell,fixnum,from_signed_cell,to_fixnum) \ + _(unsigned_cell,cell,from_unsigned_cell,to_cell) \ + _(signed_8,s64,from_signed_8,to_signed_8) \ + _(unsigned_8,u64,from_unsigned_8,to_unsigned_8) \ + _(signed_4,s32,from_signed_4,to_fixnum) \ + _(unsigned_4,u32,from_unsigned_4,to_cell) \ + _(signed_2,s16,from_signed_2,to_fixnum) \ + _(unsigned_2,u16,from_unsigned_2,to_cell) \ + _(signed_1,s8,from_signed_1,to_fixnum) \ + _(unsigned_1,u8,from_unsigned_1,to_cell) \ + _(float,float,from_float,to_float) \ + _(double,double,from_double,to_double) \ + _(cell,void *,allot_alien,pinned_alien_offset) #define DECLARE_PRIMITIVE(name) VM_C_API void primitive_##name(factor_vm *parent); #define DECLARE_ALIEN_PRIMITIVE(name, type, from, to) \ - DECLARE_PRIMITIVE(alien_##name) \ - DECLARE_PRIMITIVE(set_alien_##name) + DECLARE_PRIMITIVE(alien_##name) \ + DECLARE_PRIMITIVE(set_alien_##name) EACH_PRIMITIVE(DECLARE_PRIMITIVE) EACH_ALIEN_PRIMITIVE(DECLARE_ALIEN_PRIMITIVE) diff --git a/vm/slot_visitor.hpp b/vm/slot_visitor.hpp index e8ff7e30d2..d4dd44bed1 100644 --- a/vm/slot_visitor.hpp +++ b/vm/slot_visitor.hpp @@ -170,15 +170,17 @@ void slot_visitor::visit_roots() template void slot_visitor::visit_contexts() { - context *ctx = parent->ctx; - - while(ctx) + std::set::const_iterator begin = parent->active_contexts.begin(); + std::set::const_iterator end = parent->active_contexts.end(); + while(begin != end) { - visit_stack_elements(ctx->datastack_region,(cell *)ctx->datastack); - visit_stack_elements(ctx->retainstack_region,(cell *)ctx->retainstack); + context *ctx = *begin; + + visit_stack_elements(ctx->datastack_seg,(cell *)ctx->datastack); + visit_stack_elements(ctx->retainstack_seg,(cell *)ctx->retainstack); visit_object_array(ctx->context_objects,ctx->context_objects + context_object_count); - ctx = ctx->next; + begin++; } } diff --git a/vm/vm.cpp b/vm/vm.cpp index be43371087..87bf47f290 100755 --- a/vm/vm.cpp +++ b/vm/vm.cpp @@ -5,6 +5,7 @@ namespace factor factor_vm::factor_vm() : nursery(0,0), + callback_id(0), c_to_factor_func(NULL), profiling_p(false), gc_off(false), @@ -17,4 +18,9 @@ factor_vm::factor_vm() : primitive_reset_dispatch_stats(); } +factor_vm::~factor_vm() +{ + delete_contexts(); +} + } diff --git a/vm/vm.hpp b/vm/vm.hpp index f20145b43f..f2f2d9a769 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -6,11 +6,14 @@ struct code_root; struct factor_vm { - // First five fields accessed directly by assembler. See vm.factor + // First 5 fields accessed directly by compiler. See basis/vm/vm.factor - /* Current stacks */ + /* Current context */ context *ctx; - + + /* Spare context -- for callbacks */ + context *spare_ctx; + /* New objects are allocated here */ nursery_space nursery; @@ -23,10 +26,19 @@ struct factor_vm cell special_objects[special_object_count]; /* Data stack and retain stack sizes */ - cell ds_size, rs_size; + cell datastack_size, retainstack_size, callstack_size; - /* Pooling unused contexts to make callbacks cheaper */ - context *unused_contexts; + /* Stack of callback IDs */ + std::vector callback_ids; + + /* Next callback ID */ + int callback_id; + + /* Pooling unused contexts to make context allocation cheaper */ + std::vector unused_contexts; + + /* Active contexts, for tracing by the GC */ + std::set active_contexts; /* Canonical truth value. In Factor, 't' */ cell true_object; @@ -96,11 +108,13 @@ struct factor_vm u64 last_nano_count; // contexts - context *alloc_context(); - void dealloc_context(context *old_context); - void nest_stacks(); - void unnest_stacks(); - void init_stacks(cell ds_size_, cell rs_size_); + context *new_context(); + void delete_context(context *old_context); + void init_contexts(cell datastack_size_, cell retainstack_size_, cell callstack_size_); + void delete_contexts(); + void begin_callback(); + void end_callback(); + void primitive_current_callback(); void primitive_context_object(); void primitive_set_context_object(); bool stack_to_array(cell bottom, cell top); @@ -111,16 +125,15 @@ struct factor_vm void primitive_set_retainstack(); void primitive_check_datastack(); void primitive_load_locals(); + void primitive_current_context(); + void primitive_start_context(); + void primitive_delete_context(); - template void iterate_active_frames(Iterator &iter) + template void iterate_active_callstacks(Iterator &iter) { - context *ctx = this->ctx; - - while(ctx) - { - iterate_callstack(ctx,iter); - ctx = ctx->next; - } + std::set::const_iterator begin = active_contexts.begin(); + std::set::const_iterator end = active_contexts.end(); + while(begin != end) iterate_callstack(*begin++,iter); } // run @@ -694,6 +707,7 @@ struct factor_vm #endif factor_vm(); + ~factor_vm(); }; From e6a15c0b336df2c522a92bc00531ea29cf6b4a82 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 26 Mar 2010 22:44:56 -0400 Subject: [PATCH 466/713] compiler.tree.propagation: don't constant-fold boa constructors of identity-tuple subclasses --- .../tree/propagation/propagation-tests.factor | 6 ++++++ .../tree/propagation/slots/slots.factor | 17 +++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/basis/compiler/tree/propagation/propagation-tests.factor b/basis/compiler/tree/propagation/propagation-tests.factor index 444a424766..ad8a75ecdd 100644 --- a/basis/compiler/tree/propagation/propagation-tests.factor +++ b/basis/compiler/tree/propagation/propagation-tests.factor @@ -467,6 +467,12 @@ TUPLE: fold-boa-test-tuple { x read-only } { y read-only } { z read-only } ; [ [ 1 2 3 fold-boa-test-tuple boa ] final-literals ] unit-test +TUPLE: don't-fold-boa-test-tuple < identity-tuple ; + +[ V{ f } ] +[ [ don't-fold-boa-test-tuple boa ] final-literals ] +unit-test + TUPLE: immutable-prop-test-tuple { x sequence read-only } ; [ V{ T{ immutable-prop-test-tuple f "hey" } } ] [ diff --git a/basis/compiler/tree/propagation/slots/slots.factor b/basis/compiler/tree/propagation/slots/slots.factor index 2602d6d59a..14546f0237 100644 --- a/basis/compiler/tree/propagation/slots/slots.factor +++ b/basis/compiler/tree/propagation/slots/slots.factor @@ -34,17 +34,18 @@ IN: compiler.tree.propagation.slots [ read-only>> [ value-info ] [ drop f ] if ] 2map f prefix ; -: (propagate-tuple-constructor) ( values class -- info ) - [ read-only-slots ] keep - over rest-slice [ dup [ literal?>> ] when ] all? [ - [ rest-slice ] dip fold- - ] [ - - ] if ; +: fold-? ( values class -- ? ) + [ rest-slice [ dup [ literal?>> ] when ] all? ] + [ identity-tuple class<= not ] + bi* and ; + +: (propagate-) ( values class -- info ) + [ read-only-slots ] keep 2dup fold-? + [ [ rest-slice ] dip fold- ] [ ] if ; : propagate- ( #call -- infos ) in-d>> unclip-last - value-info literal>> first (propagate-tuple-constructor) 1array ; + value-info literal>> first (propagate-) 1array ; : read-only-slot? ( n class -- ? ) all-slots [ offset>> = ] with find nip From dbebe044c9a01d0efd66cd6fcad6966b821621da Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 26 Mar 2010 20:08:29 -0700 Subject: [PATCH 467/713] cursors: -find iterator --- extra/cursors/cursors-tests.factor | 4 ++++ extra/cursors/cursors.factor | 3 +++ 2 files changed, 7 insertions(+) diff --git a/extra/cursors/cursors-tests.factor b/extra/cursors/cursors-tests.factor index 158769ff14..d71999ab87 100644 --- a/extra/cursors/cursors-tests.factor +++ b/extra/cursors/cursors-tests.factor @@ -8,6 +8,10 @@ IN: cursors.tests { } make ] unit-test +[ T{ linear-cursor f 3 1 } ] [ + T{ linear-cursor f 1 1 } T{ linear-cursor f 5 1 } [ value>> 3 mod zero? ] -find +] unit-test + [ { 1 3 } ] [ [ T{ linear-cursor f 1 2 } T{ linear-cursor f 5 2 } [ value>> , ] -each ] { } make diff --git a/extra/cursors/cursors.factor b/extra/cursors/cursors.factor index 030e9ab72f..d7fe5fb893 100644 --- a/extra/cursors/cursors.factor +++ b/extra/cursors/cursors.factor @@ -125,6 +125,9 @@ M: end-of-stream cursor-stream-ended? drop t ; inline [ '[ dup _ cursor>= ] ] [ '[ _ keep inc-cursor ] ] bi* until drop ; inline +: -find ( ... begin end quot: ( ... cursor -- ... ? ) -- ... cursor ) + '[ dup _ cursor>= [ t ] [ dup @ ] if ] [ inc-cursor ] until ; inline + : -in- ( quot -- quot' ) '[ cursor-value-unsafe @ ] ; inline From d98e752199b687b4c62e920242454c5391b4fb1b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 26 Mar 2010 23:11:05 -0400 Subject: [PATCH 468/713] compiler: add intrinsic for context-object primitive --- .../cfg/instructions/instructions.factor | 4 ++++ .../compiler/cfg/intrinsics/intrinsics.factor | 1 + .../compiler/cfg/intrinsics/misc/misc.factor | 20 +++++++++++++++---- basis/compiler/codegen/codegen.factor | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/basis/compiler/cfg/instructions/instructions.factor b/basis/compiler/cfg/instructions/instructions.factor index 68a8b8ce59..678ce76860 100644 --- a/basis/compiler/cfg/instructions/instructions.factor +++ b/basis/compiler/cfg/instructions/instructions.factor @@ -664,6 +664,10 @@ INSN: ##vm-field-ptr def: dst/int-rep literal: field-name ; +INSN: ##vm-field +def: dst/int-rep +literal: field-name ; + ! FFI INSN: ##alien-invoke literal: params stack-frame ; diff --git a/basis/compiler/cfg/intrinsics/intrinsics.factor b/basis/compiler/cfg/intrinsics/intrinsics.factor index d753a4c1b4..4ebc818b83 100644 --- a/basis/compiler/cfg/intrinsics/intrinsics.factor +++ b/basis/compiler/cfg/intrinsics/intrinsics.factor @@ -30,6 +30,7 @@ IN: compiler.cfg.intrinsics { { kernel.private:tag [ drop emit-tag ] } + { kernel.private:context-object [ emit-context-object ] } { kernel.private:special-object [ emit-special-object ] } { kernel.private:(identity-hashcode) [ drop emit-identity-hashcode ] } { math.private:both-fixnums? [ drop emit-both-fixnums? ] } diff --git a/basis/compiler/cfg/intrinsics/misc/misc.factor b/basis/compiler/cfg/intrinsics/misc/misc.factor index fed5492220..9731d2f6f5 100644 --- a/basis/compiler/cfg/intrinsics/misc/misc.factor +++ b/basis/compiler/cfg/intrinsics/misc/misc.factor @@ -3,17 +3,29 @@ USING: namespaces layouts sequences kernel math accessors compiler.tree.propagation.info compiler.cfg.stacks compiler.cfg.hats compiler.cfg.instructions +compiler.cfg.builder.blocks compiler.cfg.utilities ; +FROM: vm => context-field-offset ; IN: compiler.cfg.intrinsics.misc : emit-tag ( -- ) ds-pop tag-mask get ^^and-imm ^^tag-fixnum ds-push ; : emit-special-object ( node -- ) - "special-objects" ^^vm-field-ptr - swap node-input-infos first literal>> - [ ds-drop 0 ^^slot-imm ] [ ds-pop ^^offset>slot ^^slot ] if* - ds-push ; + dup node-input-infos first literal>> [ + "special-objects" ^^vm-field-ptr + ds-drop swap 0 ^^slot-imm + ds-push + ] [ emit-primitive ] ?if ; + +: context-object-offset ( -- n ) + "context-objects" context-field-offset cell /i ; + +: emit-context-object ( node -- ) + dup node-input-infos first literal>> [ + "ctx" ^^vm-field + ds-drop swap context-object-offset + 0 ^^slot-imm ds-push + ] [ emit-primitive ] ?if ; : emit-identity-hashcode ( -- ) ds-pop tag-mask get bitnot ^^load-immediate ^^and 0 0 ^^slot-imm diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index 430bd9550d..d82ced8a1d 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -211,6 +211,7 @@ CODEGEN: ##compare-float-ordered %compare-float-ordered CODEGEN: ##compare-float-unordered %compare-float-unordered CODEGEN: ##save-context %save-context CODEGEN: ##vm-field-ptr %vm-field-ptr +CODEGEN: ##vm-field %vm-field CODEGEN: _fixnum-add %fixnum-add CODEGEN: _fixnum-sub %fixnum-sub From 1717b8d0f7f928aff230fb160e7f339ed38a38c1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 27 Mar 2010 02:55:49 -0400 Subject: [PATCH 469/713] Implement start-context and set-context primitives --- basis/cpu/x86/32/bootstrap.factor | 64 ++++++++++++++++--- basis/cpu/x86/64/bootstrap.factor | 60 +++++++++++++++-- basis/cpu/x86/bootstrap.factor | 3 +- .../known-words/known-words.factor | 4 +- basis/threads/threads.factor | 10 +++ core/bootstrap/primitives.factor | 5 +- vm/contexts.cpp | 14 ++-- vm/contexts.hpp | 5 +- vm/primitives.hpp | 3 +- vm/vm.hpp | 3 +- 10 files changed, 141 insertions(+), 30 deletions(-) diff --git a/basis/cpu/x86/32/bootstrap.factor b/basis/cpu/x86/32/bootstrap.factor index c7457d2732..6fab8769d5 100644 --- a/basis/cpu/x86/32/bootstrap.factor +++ b/basis/cpu/x86/32/bootstrap.factor @@ -3,7 +3,7 @@ USING: bootstrap.image.private kernel kernel.private namespaces system cpu.x86.assembler cpu.x86.assembler.operands layouts vocabs parser compiler.constants sequences math math.private -generic.single.private ; +generic.single.private threads.private ; IN: bootstrap.x86 4 \ cell set @@ -21,7 +21,7 @@ IN: bootstrap.x86 : vm-reg ( -- reg ) ECX ; : ctx-reg ( -- reg ) EBP ; : nv-regs ( -- seq ) { ESI EDI EBX } ; -: nv-reg ( -- reg ) nv-regs first ; +: nv-reg ( -- reg ) EBX ; : ds-reg ( -- reg ) ESI ; : rs-reg ( -- reg ) EDI ; : fixnum>slot@ ( -- ) temp0 2 SAR ; @@ -52,6 +52,7 @@ IN: bootstrap.x86 ctx-reg vm-reg vm-context-offset [+] MOV ; : jit-save-context ( -- ) + jit-load-context EDX ESP -4 [+] LEA ctx-reg context-callstack-top-offset [+] EDX MOV ctx-reg context-datastack-offset [+] ds-reg MOV @@ -63,7 +64,6 @@ IN: bootstrap.x86 [ jit-load-vm - jit-load-context jit-save-context ! call the primitive ESP [] vm-reg MOV @@ -96,7 +96,6 @@ IN: bootstrap.x86 EAX quot-entry-point-offset [+] CALL jit-load-vm - jit-load-context jit-save-context ! load C callstack pointer @@ -167,7 +166,6 @@ IN: bootstrap.x86 [ jit-load-vm - jit-load-context jit-save-context ! Store arguments @@ -189,7 +187,6 @@ IN: bootstrap.x86 ! frame, and the stack. The frame setup takes this into account. : jit-inline-cache-miss ( -- ) jit-load-vm - jit-load-context jit-save-context ESP 4 [+] vm-reg MOV ESP [] EBX MOV @@ -210,7 +207,6 @@ IN: bootstrap.x86 : jit-overflow ( insn func -- ) ds-reg 4 SUB jit-load-vm - jit-load-context jit-save-context EAX ds-reg [] MOV EDX ds-reg 4 [+] MOV @@ -233,7 +229,6 @@ IN: bootstrap.x86 [ ds-reg 4 SUB jit-load-vm - jit-load-context jit-save-context EBX ds-reg [] MOV EAX EBX MOV @@ -252,5 +247,58 @@ IN: bootstrap.x86 jit-conditional ] \ fixnum* define-sub-primitive +! Threads +: jit-set-context ( reg -- ) + ! Save ds, rs registers + jit-load-vm + jit-save-context + + ! Make the new context the current one + ctx-reg swap MOV + vm-reg vm-context-offset [+] ctx-reg MOV + + ! Load new stack pointer + ESP ctx-reg context-callstack-top-offset [+] MOV + + ! Load new ds, rs registers + jit-restore-context ; + +[ + ! Create the new context in return-reg + jit-load-vm + ESP [] vm-reg MOV + "new_context" jit-call + + ! Save pointer to quotation and parameter, pop them off the + ! datastack + EBX ds-reg MOV + ds-reg 8 SUB + + ! Make the new context the active context + EAX jit-set-context + + ! Push parameter + EAX EBX -4 [+] MOV + ds-reg 4 ADD + ds-reg [] EAX MOV + + ! Jump to initial quotation + EAX EBX [] MOV + EAX quot-entry-point-offset [+] JMP +] \ (start-context) define-sub-primitive + +[ + ! Load context from datastack + EAX ds-reg [] MOV + EAX EAX alien-offset [+] MOV + ds-reg 4 SUB + + ! Make it the active context + EAX jit-set-context + + ! Twiddle stack for return + ESP 4 ADD +] \ (set-context) define-sub-primitive + << "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >> call diff --git a/basis/cpu/x86/64/bootstrap.factor b/basis/cpu/x86/64/bootstrap.factor index 2da9f7564e..e8fa026a49 100644 --- a/basis/cpu/x86/64/bootstrap.factor +++ b/basis/cpu/x86/64/bootstrap.factor @@ -3,7 +3,7 @@ USING: bootstrap.image.private kernel kernel.private namespaces system layouts vocabs parser compiler.constants math math.private cpu.x86.assembler cpu.x86.assembler.operands -sequences generic.single.private ; +sequences generic.single.private threads.private ; IN: bootstrap.x86 8 \ cell set @@ -16,7 +16,7 @@ IN: bootstrap.x86 : temp2 ( -- reg ) RDX ; : temp3 ( -- reg ) RBX ; : return-reg ( -- reg ) RAX ; -: nv-reg ( -- reg ) nv-regs first ; +: nv-reg ( -- reg ) RBX ; : stack-reg ( -- reg ) RSP ; : frame-reg ( -- reg ) RBP ; : ctx-reg ( -- reg ) R12 ; @@ -51,8 +51,8 @@ IN: bootstrap.x86 : jit-save-context ( -- ) jit-load-context - RAX RSP -8 [+] LEA - ctx-reg context-callstack-top-offset [+] RAX MOV + R11 RSP -8 [+] LEA + ctx-reg context-callstack-top-offset [+] R11 MOV ctx-reg context-datastack-offset [+] ds-reg MOV ctx-reg context-retainstack-offset [+] rs-reg MOV ; @@ -222,5 +222,57 @@ IN: bootstrap.x86 jit-conditional ] \ fixnum* define-sub-primitive +! Threads +: jit-set-context ( reg -- ) + ! Save ds, rs registers + jit-save-context + + ! Make the new context the current one + ctx-reg swap MOV + vm-reg vm-context-offset [+] ctx-reg MOV + + ! Load new stack pointer + RSP ctx-reg context-callstack-top-offset [+] MOV + + ! Load new ds, rs registers + jit-restore-context ; + +[ + ! Create the new context in return-reg + arg1 vm-reg MOV + "new_context" jit-call + + ! Load quotation from datastack + arg1 ds-reg [] MOV + + ! Load parameter from datastack + arg2 ds-reg -8 [+] MOV + + ds-reg 16 SUB + + ! Make the new context the active context + return-reg jit-set-context + + ! Push parameter + ds-reg 8 ADD + ds-reg [] arg2 MOV + + ! Jump to initial quotation + arg1 quot-entry-point-offset [+] JMP +] \ (start-context) define-sub-primitive + +[ + ! Load context from datastack + temp0 ds-reg [] MOV + temp0 temp0 alien-offset [+] MOV + ds-reg 8 SUB + + ! Make it the active context + temp0 jit-set-context + + ! Twiddle stack for return + RSP 8 ADD +] \ (set-context) define-sub-primitive + << "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >> call diff --git a/basis/cpu/x86/bootstrap.factor b/basis/cpu/x86/bootstrap.factor index 1c4a6b7796..d75d80faf2 100644 --- a/basis/cpu/x86/bootstrap.factor +++ b/basis/cpu/x86/bootstrap.factor @@ -42,7 +42,8 @@ big-endian off nv-reg 0 MOV rc-absolute-cell rt-entry-point jit-rel nv-reg CALL - ! Load VM into vm-reg + ! Load VM into vm-reg; only needed on x86-32, but doesn't + ! hurt on x86-64 vm-reg 0 MOV rc-absolute-cell rt-vm jit-rel ! Load C callstack pointer diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 289afcf28c..656c159a9b 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -513,7 +513,9 @@ M: bad-executable summary \ delete-context { c-ptr } { } define-primitive -\ start-context { quotation } { } define-primitive +\ (start-context) { object quotation } { } define-primitive + +\ (set-context) { alien } { } define-primitive \ special-object { fixnum } { object } define-primitive \ special-object make-flushable diff --git a/basis/threads/threads.factor b/basis/threads/threads.factor index 952652d801..9282dda46f 100644 --- a/basis/threads/threads.factor +++ b/basis/threads/threads.factor @@ -7,6 +7,16 @@ dlists assocs system combinators combinators.private init boxes accessors math.order deques strings quotations fry ; IN: threads + + SYMBOL: initial-thread TUPLE: thread diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 9bf7be31a2..9971c00e1d 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -369,6 +369,8 @@ tuple { "fixnum<=" "math.private" (( x y -- z )) } { "fixnum>" "math.private" (( x y -- ? )) } { "fixnum>=" "math.private" (( x y -- ? )) } + { "(set-context)" "threads.private" (( context -- )) } + { "(start-context)" "threads.private" (( obj quot -- )) } } [ first3 make-sub-primitive ] each ! Primitive words @@ -534,9 +536,8 @@ tuple { "nano-count" "system" "primitive_nano_count" (( -- ns )) } { "system-micros" "system" "primitive_system_micros" (( -- us )) } { "(sleep)" "threads.private" "primitive_sleep" (( nanos -- )) } - { "current-context" "threads.private" "primitive_current_context" (( -- c-ptr )) } + { "context" "threads.private" "primitive_context" (( -- c-ptr )) } { "delete-context" "threads.private" "primitive_delete_context" (( c-ptr -- )) } - { "start-context" "threads.private" "primitive_start_context" (( quot -- )) } { "dispatch-stats" "tools.dispatch.private" "primitive_dispatch_stats" (( -- stats )) } { "reset-dispatch-stats" "tools.dispatch.private" "primitive_reset_dispatch_stats" (( -- )) } { "profiling" "tools.profiler.private" "primitive_profiling" (( ? -- )) } diff --git a/vm/contexts.cpp b/vm/contexts.cpp index b5ca348d14..f21d9c948d 100644 --- a/vm/contexts.cpp +++ b/vm/contexts.cpp @@ -97,6 +97,11 @@ context *factor_vm::new_context() return new_context; } +context *new_context(factor_vm *parent) +{ + return parent->new_context(); +} + void factor_vm::delete_context(context *old_context) { unused_contexts.push_back(old_context); @@ -225,18 +230,11 @@ void factor_vm::primitive_load_locals() ctx->retainstack += sizeof(cell) * count; } -void factor_vm::primitive_current_context() +void factor_vm::primitive_context() { ctx->push(allot_alien(ctx)); } -void factor_vm::primitive_start_context() -{ - cell quot = ctx->pop(); - ctx = new_context(); - unwind_native_frames(quot,ctx->callstack_bottom); -} - void factor_vm::primitive_delete_context() { context *old_context = (context *)pinned_alien_offset(ctx->pop()); diff --git a/vm/contexts.hpp b/vm/contexts.hpp index e746e53ffa..3adabd9e5d 100644 --- a/vm/contexts.hpp +++ b/vm/contexts.hpp @@ -79,7 +79,8 @@ struct context { } }; -VM_C_API void begin_callback(factor_vm *vm); -VM_C_API void end_callback(factor_vm *vm); +VM_C_API context *new_context(factor_vm *parent); +VM_C_API void begin_callback(factor_vm *parent); +VM_C_API void end_callback(factor_vm *parent); } diff --git a/vm/primitives.hpp b/vm/primitives.hpp index cbbadd2596..4d72cf1abb 100644 --- a/vm/primitives.hpp +++ b/vm/primitives.hpp @@ -43,9 +43,9 @@ namespace factor _(code_room) \ _(compact_gc) \ _(compute_identity_hashcode) \ + _(context) \ _(context_object) \ _(current_callback) \ - _(current_context) \ _(data_room) \ _(datastack) \ _(delete_context) \ @@ -122,7 +122,6 @@ namespace factor _(size) \ _(sleep) \ _(special_object) \ - _(start_context) \ _(string) \ _(string_nth) \ _(strip_stack_traces) \ diff --git a/vm/vm.hpp b/vm/vm.hpp index f2f2d9a769..defe4f24eb 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -125,8 +125,7 @@ struct factor_vm void primitive_set_retainstack(); void primitive_check_datastack(); void primitive_load_locals(); - void primitive_current_context(); - void primitive_start_context(); + void primitive_context(); void primitive_delete_context(); template void iterate_active_callstacks(Iterator &iter) From e6b9e54454ff244222d012523e844b4e180bdce3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 27 Mar 2010 03:35:01 -0400 Subject: [PATCH 470/713] stack-checker.known-words: fix load error --- basis/stack-checker/known-words/known-words.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 656c159a9b..a625eedb3a 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -508,8 +508,8 @@ M: bad-executable summary \ current-callback { } { fixnum } define-primitive \ current-callback make-flushable -\ current-context { } { c-ptr } define-primitive -\ current-context make-flushable +\ context { } { c-ptr } define-primitive +\ context make-flushable \ delete-context { c-ptr } { } define-primitive From fa08afdde8608bcad93406caba0dc3f7ec7de787 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 27 Mar 2010 03:35:10 -0400 Subject: [PATCH 471/713] vm: fix ridiculous default callstack size --- vm/factor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/factor.cpp b/vm/factor.cpp index c38e38a5d0..c33db440a0 100755 --- a/vm/factor.cpp +++ b/vm/factor.cpp @@ -95,7 +95,7 @@ void factor_vm::init_factor(vm_parameters *p) /* Kilobytes */ p->datastack_size = align_page(p->datastack_size << 10); p->retainstack_size = align_page(p->retainstack_size << 10); - p->callstack_size = align_page(p->retainstack_size << 10); + p->callstack_size = align_page(p->callstack_size << 10); p->callback_size = align_page(p->callback_size << 10); /* Megabytes */ From 69bb81dab864277caf4971782a0f144d8ca33c5b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 27 Mar 2010 03:44:40 -0400 Subject: [PATCH 472/713] vm: clean up TLS usage --- vm/code_blocks.cpp | 2 +- vm/errors.cpp | 10 +++++----- vm/os-linux-arm.cpp | 2 +- vm/os-unix.cpp | 16 ++++++++-------- vm/os-unix.hpp | 2 +- vm/os-windows-nt.cpp | 6 +++--- vm/os-windows-nt.hpp | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/vm/code_blocks.cpp b/vm/code_blocks.cpp index e002b26afc..4741a68c54 100755 --- a/vm/code_blocks.cpp +++ b/vm/code_blocks.cpp @@ -149,7 +149,7 @@ void factor_vm::undefined_symbol() void undefined_symbol() { - return tls_vm()->undefined_symbol(); + return current_vm()->undefined_symbol(); } /* Look up an external library symbol referenced by a compiled code block */ diff --git a/vm/errors.cpp b/vm/errors.cpp index 8efcb3346f..37a9452744 100755 --- a/vm/errors.cpp +++ b/vm/errors.cpp @@ -17,13 +17,13 @@ void critical_error(const char *msg, cell tagged) std::cout << "critical_error: " << msg; std::cout << ": " << std::hex << tagged << std::dec; std::cout << std::endl; - tls_vm()->factorbug(); + current_vm()->factorbug(); } void out_of_memory() { std::cout << "Out of memory\n\n"; - tls_vm()->dump_generations(); + current_vm()->dump_generations(); exit(1); } @@ -146,7 +146,7 @@ void factor_vm::memory_signal_handler_impl() void memory_signal_handler_impl() { - tls_vm()->memory_signal_handler_impl(); + current_vm()->memory_signal_handler_impl(); } void factor_vm::misc_signal_handler_impl() @@ -156,7 +156,7 @@ void factor_vm::misc_signal_handler_impl() void misc_signal_handler_impl() { - tls_vm()->misc_signal_handler_impl(); + current_vm()->misc_signal_handler_impl(); } void factor_vm::fp_signal_handler_impl() @@ -166,7 +166,7 @@ void factor_vm::fp_signal_handler_impl() void fp_signal_handler_impl() { - tls_vm()->fp_signal_handler_impl(); + current_vm()->fp_signal_handler_impl(); } } diff --git a/vm/os-linux-arm.cpp b/vm/os-linux-arm.cpp index 07eda12186..8e131b9011 100644 --- a/vm/os-linux-arm.cpp +++ b/vm/os-linux-arm.cpp @@ -25,7 +25,7 @@ void flush_icache(cell start, cell len) : "r0","r1","r2"); if(result < 0) - tls_vm()critical_error("flush_icache() failed",result); + critical_error("flush_icache() failed",result); } } diff --git a/vm/os-unix.cpp b/vm/os-unix.cpp index 15f8132a63..f63b509cb5 100644 --- a/vm/os-unix.cpp +++ b/vm/os-unix.cpp @@ -17,23 +17,23 @@ THREADHANDLE start_thread(void *(*start_routine)(void *),void *args) return thread; } -pthread_key_t tlsKey = 0; +pthread_key_t current_vm_tls_key = 0; void init_platform_globals() { - if (pthread_key_create(&tlsKey, NULL) != 0) + if (pthread_key_create(¤t_vm_tls_key, NULL) != 0) fatal_error("pthread_key_create() failed",0); } void register_vm_with_thread(factor_vm *vm) { - pthread_setspecific(tlsKey,vm); + pthread_setspecific(current_vm_tls_key,vm); } -factor_vm *tls_vm() +factor_vm *current_vm() { - factor_vm *vm = (factor_vm*)pthread_getspecific(tlsKey); + factor_vm *vm = (factor_vm*)pthread_getspecific(current_vm_tls_key); assert(vm != NULL); return vm; } @@ -156,21 +156,21 @@ void factor_vm::dispatch_signal(void *uap, void (handler)()) void memory_signal_handler(int signal, siginfo_t *siginfo, void *uap) { - factor_vm *vm = tls_vm(); + factor_vm *vm = current_vm(); vm->signal_fault_addr = (cell)siginfo->si_addr; vm->dispatch_signal(uap,factor::memory_signal_handler_impl); } void misc_signal_handler(int signal, siginfo_t *siginfo, void *uap) { - factor_vm *vm = tls_vm(); + factor_vm *vm = current_vm(); vm->signal_number = signal; vm->dispatch_signal(uap,factor::misc_signal_handler_impl); } void fpe_signal_handler(int signal, siginfo_t *siginfo, void *uap) { - factor_vm *vm = tls_vm(); + factor_vm *vm = current_vm(); vm->signal_number = signal; vm->signal_fpu_status = fpu_status(uap_fpu_status(uap)); uap_clear_fpu_status(uap); diff --git a/vm/os-unix.hpp b/vm/os-unix.hpp index 29378bb523..de60bbe15f 100644 --- a/vm/os-unix.hpp +++ b/vm/os-unix.hpp @@ -50,7 +50,7 @@ void sleep_nanos(u64 nsec); void init_platform_globals(); void register_vm_with_thread(factor_vm *vm); -factor_vm *tls_vm(); +factor_vm *current_vm(); void open_console(); void move_file(const vm_char *path1, const vm_char *path2); diff --git a/vm/os-windows-nt.cpp b/vm/os-windows-nt.cpp index 07d428fb49..d33a935f7f 100755 --- a/vm/os-windows-nt.cpp +++ b/vm/os-windows-nt.cpp @@ -22,9 +22,9 @@ void register_vm_with_thread(factor_vm *vm) fatal_error("TlsSetValue failed",0); } -factor_vm *tls_vm() +factor_vm *current_vm() { - factor_vm *vm = (factor_vm*)TlsGetValue(dwTlsIndex); + factor_vm *vm = (factor_vm *)TlsGetValue(dwTlsIndex); assert(vm != NULL); return vm; } @@ -122,7 +122,7 @@ LONG factor_vm::exception_handler(PEXCEPTION_POINTERS pe) FACTOR_STDCALL(LONG) exception_handler(PEXCEPTION_POINTERS pe) { - return tls_vm()->exception_handler(pe); + return current_vm()->exception_handler(pe); } void factor_vm::c_to_factor_toplevel(cell quot) diff --git a/vm/os-windows-nt.hpp b/vm/os-windows-nt.hpp index 8ad34ed147..d425a2c281 100755 --- a/vm/os-windows-nt.hpp +++ b/vm/os-windows-nt.hpp @@ -47,6 +47,6 @@ inline static THREADHANDLE thread_id() { return GetCurrentThread(); } void init_platform_globals(); void register_vm_with_thread(factor_vm *vm); -factor_vm *tls_vm(); +factor_vm *current_vm(); } From 88d07939467580a25b6f9bf161559e8bb4cf774d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 27 Mar 2010 06:25:47 -0400 Subject: [PATCH 473/713] spelling: John Benediktsson's port of Peter Norvig's spelling corrector --- extra/spelling/authors.txt | 1 + extra/spelling/spelling-tests.factor | 14 ++ extra/spelling/spelling.factor | 78 +++++++++ extra/spelling/summary.txt | 1 + extra/spelling/tags.txt | 1 + extra/spelling/test.txt | 246 +++++++++++++++++++++++++++ 6 files changed, 341 insertions(+) create mode 100644 extra/spelling/authors.txt create mode 100644 extra/spelling/spelling-tests.factor create mode 100644 extra/spelling/spelling.factor create mode 100644 extra/spelling/summary.txt create mode 100644 extra/spelling/tags.txt create mode 100644 extra/spelling/test.txt diff --git a/extra/spelling/authors.txt b/extra/spelling/authors.txt new file mode 100644 index 0000000000..e091bb8164 --- /dev/null +++ b/extra/spelling/authors.txt @@ -0,0 +1 @@ +John Benediktsson diff --git a/extra/spelling/spelling-tests.factor b/extra/spelling/spelling-tests.factor new file mode 100644 index 0000000000..f32363854b --- /dev/null +++ b/extra/spelling/spelling-tests.factor @@ -0,0 +1,14 @@ +USING: spelling tools.test memoize ; +IN: spelling.tests + +MEMO: test-dictionary ( -- assoc ) + "vocab:spelling/test.txt" load-dictionary ; + +: test-correct ( word -- word/f ) + test-dictionary (correct) ; + +[ "government" ] [ "goverment" test-correct ] unit-test +[ "government" ] [ "govxernment" test-correct ] unit-test +[ "government" ] [ "govermnent" test-correct ] unit-test +[ "government" ] [ "govxermnent" test-correct ] unit-test +[ "government" ] [ "govyrmnent" test-correct ] unit-test diff --git a/extra/spelling/spelling.factor b/extra/spelling/spelling.factor new file mode 100644 index 0000000000..b8a90bd2da --- /dev/null +++ b/extra/spelling/spelling.factor @@ -0,0 +1,78 @@ +USING: arrays ascii assocs combinators combinators.smart fry +http.client io.encodings.ascii io.files io.files.temp kernel +locals math math.statistics memoize sequences sorting splitting +strings urls ; +IN: spelling + +! http://norvig.com/spell-correct.html + +CONSTANT: ALPHABET "abcdefghijklmnopqrstuvwxyz" + +: splits ( word -- sequence ) + dup length iota [ cut 2array ] with map ; + +: deletes ( sequence -- sequence' ) + [ second length 0 > ] filter [ first2 rest append ] map ; + +: transposes ( sequence -- sequence' ) + [ second length 1 > ] filter [ + [ + { + [ first ] + [ second second 1string ] + [ second first 1string ] + [ second 2 tail ] + } cleave + ] "" append-outputs-as + ] map ; + +: replaces ( sequence -- sequence' ) + [ second length 0 > ] filter [ + [ ALPHABET ] dip first2 + '[ 1string _ _ rest surround ] { } map-as + ] map concat ; + +: inserts ( sequence -- sequence' ) + [ + ALPHABET + [ [ first2 ] dip 1string glue ] with { } map-as + ] map concat ; + +: edits1 ( word -- edits ) + [ + splits { + [ deletes ] + [ transposes ] + [ replaces ] + [ inserts ] + } cleave + ] append-outputs ; + +: edits2 ( word -- edits ) + edits1 [ edits1 ] map concat ; + +: filter-known ( words dictionary -- words' ) + '[ _ key? ] filter ; + +:: corrections ( word dictionary -- words ) + word 1array dictionary filter-known + [ word edits1 dictionary filter-known ] when-empty + [ word edits2 dictionary filter-known ] when-empty + [ dictionary at 1 or ] sort-with ; + +: words ( string -- words ) + >lower [ letter? not ] split-when harvest ; + +: load-dictionary ( file -- assoc ) + ascii file-contents words histogram ; + +MEMO: default-dictionary ( -- counts ) + "big.txt" temp-file dup exists? + [ URL" http://norvig.com/big.txt" over download-to ] unless + load-dictionary ; + +: (correct) ( word dictionary -- word/f ) + corrections [ f ] [ first ] if-empty ; + +: correct ( word -- word/f ) + default-dictionary (correct) ; diff --git a/extra/spelling/summary.txt b/extra/spelling/summary.txt new file mode 100644 index 0000000000..7fa90685bc --- /dev/null +++ b/extra/spelling/summary.txt @@ -0,0 +1 @@ +Peter Norvig's spelling corrector diff --git a/extra/spelling/tags.txt b/extra/spelling/tags.txt new file mode 100644 index 0000000000..1e107f52e4 --- /dev/null +++ b/extra/spelling/tags.txt @@ -0,0 +1 @@ +examples diff --git a/extra/spelling/test.txt b/extra/spelling/test.txt new file mode 100644 index 0000000000..5b9de09b8f --- /dev/null +++ b/extra/spelling/test.txt @@ -0,0 +1,246 @@ +AMERICAN FOREIGN RELATIONS (1865-98) + +=French Intrigues in Mexico Blocked.=--Between the war for the union and +the war with Spain, the Department of State had many an occasion to +present the rights of America among the powers of the world. Only a +little while after the civil conflict came to a close, it was called +upon to deal with a dangerous situation created in Mexico by the +ambitions of Napoleon III. During the administration of Buchanan, Mexico +had fallen into disorder through the strife of the Liberal and the +Clerical parties; the President asked for authority to use American +troops to bring to a peaceful haven "a wreck upon the ocean, drifting +about as she is impelled by different factions." Our own domestic crisis +then intervened. + +Observing the United States heavily involved in its own problems, the +great powers, England, France, and Spain, decided in the autumn of 1861 +to take a hand themselves in restoring order in Mexico. They entered +into an agreement to enforce the claims of their citizens against Mexico +and to protect their subjects residing in that republic. They invited +the United States to join them, and, on meeting a polite refusal, they +prepared for a combined military and naval demonstration on their own +account. In the midst of this action England and Spain, discovering the +sinister purposes of Napoleon, withdrew their troops and left the field +to him. + +The French Emperor, it was well known, looked with jealousy upon the +growth of the United States and dreamed of establishing in the Western +hemisphere an imperial power to offset the American republic. +Intervention to collect debts was only a cloak for his deeper designs. +Throwing off that guise in due time, he made the Archduke Maximilian, a +brother of the ruler of Austria, emperor in Mexico, and surrounded his +throne by French soldiers, in spite of all protests. + +This insolent attack upon the Mexican republic, deeply resented in the +United States, was allowed to drift in its course until 1865. At that +juncture General Sheridan was dispatched to the Mexican border with a +large armed force; General Grant urged the use of the American army to +expel the French from this continent. The Secretary of State, Seward, +counseled negotiation first, and, applying the Monroe Doctrine, was able +to prevail upon Napoleon III to withdraw his troops. Without the support +of French arms, the sham empire in Mexico collapsed like a house of +cards and the unhappy Maximilian, the victim of French ambition and +intrigue, met his death at the hands of a Mexican firing squad. + +=Alaska Purchased.=--The Mexican affair had not been brought to a close +before the Department of State was busy with negotiations which resulted +in the purchase of Alaska from Russia. The treaty of cession, signed on +March 30, 1867, added to the United States a domain of nearly six +hundred thousand square miles, a territory larger than Texas and nearly +three-fourths the size of the Louisiana purchase. Though it was a +distant colony separated from our continental domain by a thousand miles +of water, no question of "imperialism" or "colonization foreign to +American doctrines" seems to have been raised at the time. The treaty +was ratified promptly by the Senate. The purchase price, $7,200,000, was +voted by the House of Representatives after the display of some +resentment against a system that compelled it to appropriate money to +fulfill an obligation which it had no part in making. Seward, who +formulated the treaty, rejoiced, as he afterwards said, that he had kept +Alaska out of the hands of England. + +=American Interest in the Caribbean.=--Having achieved this diplomatic +triumph, Seward turned to the increase of American power in another +direction. He negotiated, with Denmark, a treaty providing for the +purchase of the islands of St. John and St. Thomas in the West Indies, +strategic points in the Caribbean for sea power. This project, long +afterward brought to fruition by other men, was defeated on this +occasion by the refusal of the Senate to ratify the treaty. Evidently it +was not yet prepared to exercise colonial dominion over other races. + +Undaunted by the misadventure in Caribbean policies, President Grant +warmly advocated the acquisition of Santo Domingo. This little republic +had long been in a state of general disorder. In 1869 a treaty of +annexation was concluded with its president. The document Grant +transmitted to the Senate with his cordial approval, only to have it +rejected. Not at all changed in his opinion by the outcome of his +effort, he continued to urge the subject of annexation. Even in his last +message to Congress he referred to it, saying that time had only proved +the wisdom of his early course. The addition of Santo Domingo to the +American sphere of protection was the work of a later generation. The +State Department, temporarily checked, had to bide its time. + +=The _Alabama_ Claims Arbitrated.=--Indeed, it had in hand a far more +serious matter, a vexing issue that grew out of Civil War diplomacy. The +British government, as already pointed out in other connections, had +permitted Confederate cruisers, including the famous _Alabama_, built in +British ports, to escape and prey upon the commerce of the Northern +states. This action, denounced at the time by our government as a grave +breach of neutrality as well as a grievous injury to American citizens, +led first to remonstrances and finally to repeated claims for damages +done to American ships and goods. For a long time Great Britain was +firm. Her foreign secretary denied all obligations in the premises, +adding somewhat curtly that "he wished to say once for all that Her +Majesty's government disclaimed any responsibility for the losses and +hoped that they had made their position perfectly clear." Still +President Grant was not persuaded that the door of diplomacy, though +closed, was barred. Hamilton Fish, his Secretary of State, renewed the +demand. Finally he secured from the British government in 1871 the +treaty of Washington providing for the arbitration not merely of the +_Alabama_ and other claims but also all points of serious controversy +between the two countries. + +The tribunal of arbitration thus authorized sat at Geneva in +Switzerland, and after a long and careful review of the arguments on +both sides awarded to the United States the lump sum of $15,500,000 to +be distributed among the American claimants. The damages thus allowed +were large, unquestionably larger than strict justice required and it is +not surprising that the decision excited much adverse comment in +England. Nevertheless, the prompt payment by the British government +swept away at once a great cloud of ill-feeling in America. Moreover, +the spectacle of two powerful nations choosing the way of peaceful +arbitration to settle an angry dispute seemed a happy, if illusory, omen +of a modern method for avoiding the arbitrament of war. + +=Samoa.=--If the Senate had its doubts at first about the wisdom of +acquiring strategic points for naval power in distant seas, the same +could not be said of the State Department or naval officers. In 1872 +Commander Meade, of the United States navy, alive to the importance of +coaling stations even in mid-ocean, made a commercial agreement with the +chief of Tutuila, one of the Samoan Islands, far below the equator, in +the southern Pacific, nearer to Australia than to California. This +agreement, providing among other things for our use of the harbor of +Pago Pago as a naval base, was six years later changed into a formal +treaty ratified by the Senate. + +Such enterprise could not escape the vigilant eyes of England and +Germany, both mindful of the course of the sea power in history. The +German emperor, seizing as a pretext a quarrel between his consul in the +islands and a native king, laid claim to an interest in the Samoan +group. England, aware of the dangers arising from German outposts in the +southern seas so near to Australia, was not content to stand aside. So +it happened that all three countries sent battleships to the Samoan +waters, threatening a crisis that was fortunately averted by friendly +settlement. If, as is alleged, Germany entertained a notion of +challenging American sea power then and there, the presence of British +ships must have dispelled that dream. + +The result of the affair was a tripartite agreement by which the three +powers in 1889 undertook a protectorate over the islands. But joint +control proved unsatisfactory. There was constant friction between the +Germans and the English. The spheres of authority being vague and open +to dispute, the plan had to be abandoned at the end of ten years. +England withdrew altogether, leaving to Germany all the islands except +Tutuila, which was ceded outright to the United States. Thus one of the +finest harbors in the Pacific, to the intense delight of the American +navy, passed permanently under American dominion. Another triumph in +diplomacy was set down to the credit of the State Department. + +=Cleveland and the Venezuela Affair.=--In the relations with South +America, as well as in those with the distant Pacific, the diplomacy of +the government at Washington was put to the test. For some time it had +been watching a dispute between England and Venezuela over the western +boundary of British Guiana and, on an appeal from Venezuela, it had +taken a lively interest in the contest. In 1895 President Cleveland saw +that Great Britain would yield none of her claims. After hearing the +arguments of Venezuela, his Secretary of State, Richard T. Olney, in a +note none too conciliatory, asked the British government whether it was +willing to arbitrate the points in controversy. This inquiry he +accompanied by a warning to the effect that the United States could not +permit any European power to contest its mastery in this hemisphere. +"The United States," said the Secretary, "is practically sovereign on +this continent and its fiat is law upon the subjects to which it +confines its interposition.... Its infinite resources, combined with its +isolated position, render it master of the situation and practically +invulnerable against any or all other powers." + +The reply evoked from the British government by this strong statement +was firm and clear. The Monroe Doctrine, it said, even if not so widely +stretched by interpretation, was not binding in international law; the +dispute with Venezuela was a matter of interest merely to the parties +involved; and arbitration of the question was impossible. This response +called forth President Cleveland's startling message of 1895. He asked +Congress to create a commission authorized to ascertain by researches +the true boundary between Venezuela and British Guiana. He added that it +would be the duty of this country "to resist by every means in its +power, as a willful aggression upon its rights and interests, the +appropriation by Great Britain of any lands or the exercise of +governmental jurisdiction over any territory which, after investigation, +we have determined of right belongs to Venezuela." The serious character +of this statement he thoroughly understood. He declared that he was +conscious of his responsibilities, intimating that war, much as it was +to be deplored, was not comparable to "a supine submission to wrong and +injustice and the consequent loss of national self-respect and honor." + +[Illustration: GROVER CLEVELAND] + +The note of defiance which ran through this message, greeted by shrill +cries of enthusiasm in many circles, was viewed in other quarters as a +portent of war. Responsible newspapers in both countries spoke of an +armed settlement of the dispute as inevitable. Congress created the +commission and appropriated money for the investigation; a body of +learned men was appointed to determine the merits of the conflicting +boundary claims. The British government, deaf to the clamor of the +bellicose section of the London press, deplored the incident, +courteously replied in the affirmative to a request for assistance in +the search for evidence, and finally agreed to the proposition that the +issue be submitted to arbitration. The outcome of this somewhat perilous +dispute contributed not a little to Cleveland's reputation as "a +sterling representative of the true American spirit." This was not +diminished when the tribunal of arbitration found that Great Britain was +on the whole right in her territorial claims against Venezuela. + +=The Annexation of Hawaii.=--While engaged in the dangerous Venezuela +controversy, President Cleveland was compelled by a strange turn in +events to consider the annexation of the Hawaiian Islands in the +mid-Pacific. For more than half a century American missionaries had been +active in converting the natives to the Christian faith and enterprising +American business men had been developing the fertile sugar plantations. +Both the Department of State and the Navy Department were fully +conscious of the strategic relation of the islands to the growth of sea +power and watched with anxiety any developments likely to bring them +under some other Dominion. + +The country at large was indifferent, however, until 1893, when a +revolution, headed by Americans, broke out, ending in the overthrow of +the native government, the abolition of the primitive monarchy, and the +retirement of Queen Liliuokalani to private life. This crisis, a +repetition of the Texas affair in a small theater, was immediately +followed by a demand from the new Hawaiian government for annexation to +the United States. President Harrison looked with favor on the proposal, +negotiated the treaty of annexation, and laid it before the Senate for +approval. There it still rested when his term of office was brought to a +close. + +Harrison's successor, Cleveland, it was well known, had doubts about the +propriety of American action in Hawaii. For the purpose of making an +inquiry into the matter, he sent a special commissioner to the islands. +On the basis of the report of his agent, Cleveland came to the +conclusion that "the revolution in the island kingdom had been +accomplished by the improper use of the armed forces of the United +States and that the wrong should be righted by a restoration of the +queen to her throne." Such being his matured conviction, though the +facts upon which he rested it were warmly controverted, he could do +nothing but withdraw the treaty from the Senate and close the incident. + +To the Republicans this sharp and cavalier disposal of their plans, +carried out in a way that impugned the motives of a Republican +President, was nothing less than "a betrayal of American interests." In +their platform of 1896 they made clear their position: "Our foreign +policy should be at all times firm, vigorous, and dignified and all our +interests in the Western hemisphere carefully watched and guarded. The +Hawaiian Islands should be controlled by the United States and no +foreign power should be permitted to interfere with them." There was no +mistaking this view of the issue. As the vote in the election gave +popular sanction to Republican policies, Congress by a joint resolution, +passed on July 6, 1898, annexed the islands to the United States and +later conferred upon them the ordinary territorial form of government. From 11ddbc03a4d56763d8eec123ddce61083db1a661 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 27 Mar 2010 07:33:28 -0400 Subject: [PATCH 474/713] vm: signal handling cleanup --- vm/alien.cpp | 2 +- vm/callstack.cpp | 12 +++++-- vm/code_blocks.cpp | 2 +- vm/contexts.cpp | 15 ++++++-- vm/contexts.hpp | 16 ++------- vm/errors.cpp | 76 +++++++++++++++++------------------------ vm/errors.hpp | 8 ++--- vm/io.cpp | 2 +- vm/mach_signal.cpp | 14 ++------ vm/math.cpp | 2 +- vm/os-genunix.hpp | 5 --- vm/os-macosx-ppc.hpp | 5 --- vm/os-macosx-x86.32.hpp | 5 --- vm/os-macosx-x86.64.hpp | 5 --- vm/os-unix.cpp | 15 ++------ vm/os-windows-nt.cpp | 2 ++ vm/os-windows.cpp | 2 +- vm/segments.hpp | 10 ++++++ vm/vm.hpp | 16 ++++----- 19 files changed, 90 insertions(+), 124 deletions(-) diff --git a/vm/alien.cpp b/vm/alien.cpp index 44365859e2..da70fa134e 100755 --- a/vm/alien.cpp +++ b/vm/alien.cpp @@ -13,7 +13,7 @@ char *factor_vm::pinned_alien_offset(cell obj) { alien *ptr = untag(obj); if(to_boolean(ptr->expired)) - general_error(ERROR_EXPIRED,obj,false_object,NULL); + general_error(ERROR_EXPIRED,obj,false_object); if(to_boolean(ptr->base)) type_error(ALIEN_TYPE,obj); else diff --git a/vm/callstack.cpp b/vm/callstack.cpp index 8389ff8d90..7268d6ab91 100755 --- a/vm/callstack.cpp +++ b/vm/callstack.cpp @@ -18,11 +18,17 @@ callstack *factor_vm::allot_callstack(cell size) return stack; } -stack_frame *factor_vm::fix_callstack_top(stack_frame *top, stack_frame *bottom) +/* If 'stack' points into the middle of the frame, find the nearest valid stack +pointer where we can resume execution and hope to capture the call trace without +crashing. Also, make sure we have at least 'stack_reserved' bytes available so +that we don't run out of callstack space while handling the error. */ +stack_frame *factor_vm::fix_callstack_top(stack_frame *stack) { - stack_frame *frame = bottom - 1; + stack_frame *frame = ctx->callstack_bottom - 1; - while(frame >= top) + while(frame >= stack + && frame >= ctx->callstack_top + && (cell)frame >= ctx->callstack_seg->start + stack_reserved) frame = frame_successor(frame); return frame + 1; diff --git a/vm/code_blocks.cpp b/vm/code_blocks.cpp index 4741a68c54..894e49846d 100755 --- a/vm/code_blocks.cpp +++ b/vm/code_blocks.cpp @@ -144,7 +144,7 @@ void factor_vm::update_word_references(code_block *compiled, bool reset_inline_c image load */ void factor_vm::undefined_symbol() { - general_error(ERROR_UNDEFINED_SYMBOL,false_object,false_object,NULL); + general_error(ERROR_UNDEFINED_SYMBOL,false_object,false_object); } void undefined_symbol() diff --git a/vm/contexts.cpp b/vm/contexts.cpp index f21d9c948d..8734ff8486 100644 --- a/vm/contexts.cpp +++ b/vm/contexts.cpp @@ -44,6 +44,17 @@ void context::reset() reset_context_objects(); } +void context::fix_stacks() +{ + if(datastack + sizeof(cell) < datastack_seg->start + || datastack + stack_reserved >= datastack_seg->end) + reset_datastack(); + + if(retainstack + sizeof(cell) < retainstack_seg->start + || retainstack + stack_reserved >= retainstack_seg->end) + reset_retainstack(); +} + context::~context() { delete datastack_seg; @@ -167,13 +178,13 @@ bool factor_vm::stack_to_array(cell bottom, cell top) void factor_vm::primitive_datastack() { if(!stack_to_array(ctx->datastack_seg->start,ctx->datastack)) - general_error(ERROR_DS_UNDERFLOW,false_object,false_object,NULL); + general_error(ERROR_DATASTACK_UNDERFLOW,false_object,false_object); } void factor_vm::primitive_retainstack() { if(!stack_to_array(ctx->retainstack_seg->start,ctx->retainstack)) - general_error(ERROR_RS_UNDERFLOW,false_object,false_object,NULL); + general_error(ERROR_RETAINSTACK_UNDERFLOW,false_object,false_object); } /* returns pointer to top of stack */ diff --git a/vm/contexts.hpp b/vm/contexts.hpp index 3adabd9e5d..441b5916c8 100644 --- a/vm/contexts.hpp +++ b/vm/contexts.hpp @@ -8,6 +8,8 @@ enum context_object { OBJ_CATCHSTACK, }; +static const cell stack_reserved = 1024; + struct context { // First 4 fields accessed directly by compiler. See basis/vm/vm.factor @@ -41,6 +43,7 @@ struct context { void reset_callstack(); void reset_context_objects(); void reset(); + void fix_stacks(); cell peek() { @@ -64,19 +67,6 @@ struct context { datastack += sizeof(cell); replace(tagged); } - - static const cell stack_reserved = (64 * sizeof(cell)); - - void fix_stacks() - { - if(datastack + sizeof(cell) < datastack_seg->start - || datastack + stack_reserved >= datastack_seg->end) - reset_datastack(); - - if(retainstack + sizeof(cell) < retainstack_seg->start - || retainstack + stack_reserved >= retainstack_seg->end) - reset_retainstack(); - } }; VM_C_API context *new_context(factor_vm *parent); diff --git a/vm/errors.cpp b/vm/errors.cpp index 37a9452744..d0c72989a3 100755 --- a/vm/errors.cpp +++ b/vm/errors.cpp @@ -27,8 +27,10 @@ void out_of_memory() exit(1); } -void factor_vm::throw_error(cell error, stack_frame *callstack_top) +void factor_vm::throw_error(cell error, stack_frame *stack) { + assert(stack); + /* If the error handler is set, we rewind any C stack frames and pass the error to user-space. */ if(!current_gc && to_boolean(special_objects[ERROR_HANDLER_QUOT])) @@ -41,22 +43,13 @@ void factor_vm::throw_error(cell error, stack_frame *callstack_top) bignum_roots.clear(); code_roots.clear(); - /* If we had an underflow or overflow, stack pointers might be - out of bounds */ + /* If we had an underflow or overflow, data or retain stack + pointers might be out of bounds */ ctx->fix_stacks(); ctx->push(error); - /* Errors thrown from C code pass NULL for this parameter. - Errors thrown from Factor code, or signal handlers, pass the - actual stack pointer at the time, since the saved pointer is - not necessarily up to date at that point. */ - if(callstack_top) - callstack_top = fix_callstack_top(callstack_top,ctx->callstack_bottom); - else - callstack_top = ctx->callstack_top; - - unwind_native_frames(special_objects[ERROR_HANDLER_QUOT],callstack_top); + unwind_native_frames(special_objects[ERROR_HANDLER_QUOT],stack); } /* Error was thrown in early startup before error handler is set, just crash. */ @@ -70,62 +63,55 @@ void factor_vm::throw_error(cell error, stack_frame *callstack_top) } } -void factor_vm::general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *callstack_top) +void factor_vm::general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *stack) { throw_error(allot_array_4(special_objects[OBJ_ERROR], - tag_fixnum(error),arg1,arg2),callstack_top); + tag_fixnum(error),arg1,arg2),stack); +} + +void factor_vm::general_error(vm_error_type error, cell arg1, cell arg2) +{ + throw_error(allot_array_4(special_objects[OBJ_ERROR], + tag_fixnum(error),arg1,arg2),ctx->callstack_top); } void factor_vm::type_error(cell type, cell tagged) { - general_error(ERROR_TYPE,tag_fixnum(type),tagged,NULL); + general_error(ERROR_TYPE,tag_fixnum(type),tagged); } void factor_vm::not_implemented_error() { - general_error(ERROR_NOT_IMPLEMENTED,false_object,false_object,NULL); + general_error(ERROR_NOT_IMPLEMENTED,false_object,false_object); } -/* Test if 'fault' is in the guard page at the top or bottom (depending on -offset being 0 or -1) of area+area_size */ -bool factor_vm::in_page(cell fault, cell area, cell area_size, int offset) +void factor_vm::memory_protection_error(cell addr, stack_frame *stack) { - int pagesize = getpagesize(); - area += area_size; - area += offset * pagesize; - - return fault >= area && fault <= area + pagesize; -} - -void factor_vm::memory_protection_error(cell addr, stack_frame *native_stack) -{ - if(in_page(addr, ctx->datastack_seg->start, 0, -1)) - general_error(ERROR_DS_UNDERFLOW,false_object,false_object,native_stack); - else if(in_page(addr, ctx->datastack_seg->start, datastack_size, 0)) - general_error(ERROR_DS_OVERFLOW,false_object,false_object,native_stack); - else if(in_page(addr, ctx->retainstack_seg->start, 0, -1)) - general_error(ERROR_RS_UNDERFLOW,false_object,false_object,native_stack); - else if(in_page(addr, ctx->retainstack_seg->start, retainstack_size, 0)) - general_error(ERROR_RS_OVERFLOW,false_object,false_object,native_stack); - else if(in_page(addr, nursery.end, 0, 0)) - critical_error("allot_object() missed GC check",0); + if(ctx->datastack_seg->underflow_p(addr)) + general_error(ERROR_DATASTACK_UNDERFLOW,false_object,false_object,stack); + else if(ctx->datastack_seg->overflow_p(addr)) + general_error(ERROR_DATASTACK_OVERFLOW,false_object,false_object,stack); + else if(ctx->retainstack_seg->underflow_p(addr)) + general_error(ERROR_RETAINSTACK_UNDERFLOW,false_object,false_object,stack); + else if(ctx->retainstack_seg->overflow_p(addr)) + general_error(ERROR_RETAINSTACK_OVERFLOW,false_object,false_object,stack); else - general_error(ERROR_MEMORY,allot_cell(addr),false_object,native_stack); + general_error(ERROR_MEMORY,allot_cell(addr),false_object,stack); } -void factor_vm::signal_error(cell signal, stack_frame *native_stack) +void factor_vm::signal_error(cell signal, stack_frame *stack) { - general_error(ERROR_SIGNAL,allot_cell(signal),false_object,native_stack); + general_error(ERROR_SIGNAL,allot_cell(signal),false_object,stack); } void factor_vm::divide_by_zero_error() { - general_error(ERROR_DIVIDE_BY_ZERO,false_object,false_object,NULL); + general_error(ERROR_DIVIDE_BY_ZERO,false_object,false_object); } -void factor_vm::fp_trap_error(unsigned int fpu_status, stack_frame *signal_callstack_top) +void factor_vm::fp_trap_error(unsigned int fpu_status, stack_frame *stack) { - general_error(ERROR_FP_TRAP,tag_fixnum(fpu_status),false_object,signal_callstack_top); + general_error(ERROR_FP_TRAP,tag_fixnum(fpu_status),false_object,stack); } void factor_vm::primitive_call_clear() diff --git a/vm/errors.hpp b/vm/errors.hpp index 4b237e03a0..0ce5957aef 100755 --- a/vm/errors.hpp +++ b/vm/errors.hpp @@ -14,10 +14,10 @@ enum vm_error_type ERROR_C_STRING, ERROR_FFI, ERROR_UNDEFINED_SYMBOL, - ERROR_DS_UNDERFLOW, - ERROR_DS_OVERFLOW, - ERROR_RS_UNDERFLOW, - ERROR_RS_OVERFLOW, + ERROR_DATASTACK_UNDERFLOW, + ERROR_DATASTACK_OVERFLOW, + ERROR_RETAINSTACK_UNDERFLOW, + ERROR_RETAINSTACK_OVERFLOW, ERROR_MEMORY, ERROR_FP_TRAP, }; diff --git a/vm/io.cpp b/vm/io.cpp index fdd872457e..8ce7ff5256 100755 --- a/vm/io.cpp +++ b/vm/io.cpp @@ -28,7 +28,7 @@ void factor_vm::io_error() return; #endif - general_error(ERROR_IO,tag_fixnum(errno),false_object,NULL); + general_error(ERROR_IO,tag_fixnum(errno),false_object); } FILE *factor_vm::safe_fopen(char *filename, char *mode) diff --git a/vm/mach_signal.cpp b/vm/mach_signal.cpp index 6295381b1c..af14c3a49a 100644 --- a/vm/mach_signal.cpp +++ b/vm/mach_signal.cpp @@ -35,19 +35,9 @@ void factor_vm::call_fault_handler( MACH_THREAD_STATE_TYPE *thread_state, MACH_FLOAT_STATE_TYPE *float_state) { - /* There is a race condition here, but in practice an exception - delivered during stack frame setup/teardown or while transitioning - from Factor to C is a sign of things seriously gone wrong, not just - a divide by zero or stack underflow in the listener */ + MACH_STACK_POINTER(thread_state) = (cell)fix_callstack_top((stack_frame *)MACH_STACK_POINTER(thread_state)); - /* Are we in compiled Factor code? Then use the current stack pointer */ - if(in_code_heap_p(MACH_PROGRAM_COUNTER(thread_state))) - signal_callstack_top = (stack_frame *)MACH_STACK_POINTER(thread_state); - /* Are we in C? Then use the saved callstack top */ - else - signal_callstack_top = NULL; - - MACH_STACK_POINTER(thread_state) = align_stack_pointer(MACH_STACK_POINTER(thread_state)); + signal_callstack_top = (stack_frame *)MACH_STACK_POINTER(thread_state); /* Now we point the program counter at the right handler function. */ if(exception == EXC_BAD_ACCESS) diff --git a/vm/math.cpp b/vm/math.cpp index bb5d9c13c4..a462232344 100755 --- a/vm/math.cpp +++ b/vm/math.cpp @@ -246,7 +246,7 @@ cell factor_vm::unbox_array_size_slow() } } - general_error(ERROR_ARRAY_SIZE,ctx->pop(),tag_fixnum(array_size_max),NULL); + general_error(ERROR_ARRAY_SIZE,ctx->pop(),tag_fixnum(array_size_max)); return 0; /* can't happen */ } diff --git a/vm/os-genunix.hpp b/vm/os-genunix.hpp index ff5d29ecd7..1972a728e6 100644 --- a/vm/os-genunix.hpp +++ b/vm/os-genunix.hpp @@ -10,9 +10,4 @@ void early_init(); const char *vm_executable_path(); const char *default_image_path(); -template Type align_stack_pointer(Type sp) -{ - return sp; -} - } diff --git a/vm/os-macosx-ppc.hpp b/vm/os-macosx-ppc.hpp index 30fd4b2081..90da9a26f3 100644 --- a/vm/os-macosx-ppc.hpp +++ b/vm/os-macosx-ppc.hpp @@ -62,11 +62,6 @@ inline static unsigned int uap_fpu_status(void *uap) return mach_fpu_status(UAP_FS(uap)); } -template Type align_stack_pointer(Type sp) -{ - return sp; -} - inline static void mach_clear_fpu_status(ppc_float_state_t *float_state) { FPSCR(float_state) &= 0x0007f8ff; diff --git a/vm/os-macosx-x86.32.hpp b/vm/os-macosx-x86.32.hpp index a6fe8e2703..3d754ae9e4 100644 --- a/vm/os-macosx-x86.32.hpp +++ b/vm/os-macosx-x86.32.hpp @@ -64,11 +64,6 @@ inline static unsigned int uap_fpu_status(void *uap) return mach_fpu_status(UAP_FS(uap)); } -template Type align_stack_pointer(Type sp) -{ - return (Type)((((cell)sp + 4) & ~15) - 4); -} - inline static void mach_clear_fpu_status(i386_float_state_t *float_state) { MXCSR(float_state) &= 0xffffffc0; diff --git a/vm/os-macosx-x86.64.hpp b/vm/os-macosx-x86.64.hpp index cb1980ddbf..7cef436327 100644 --- a/vm/os-macosx-x86.64.hpp +++ b/vm/os-macosx-x86.64.hpp @@ -62,11 +62,6 @@ inline static unsigned int uap_fpu_status(void *uap) return mach_fpu_status(UAP_FS(uap)); } -template Type align_stack_pointer(Type sp) -{ - return (Type)((((cell)sp + 8) & ~15) - 8); -} - inline static void mach_clear_fpu_status(x86_float_state64_t *float_state) { MXCSR(float_state) &= 0xffffffc0; diff --git a/vm/os-unix.cpp b/vm/os-unix.cpp index f63b509cb5..94d2a31839 100644 --- a/vm/os-unix.cpp +++ b/vm/os-unix.cpp @@ -85,7 +85,7 @@ void *factor_vm::ffi_dlsym(dll *dll, symbol_char *symbol) void factor_vm::ffi_dlclose(dll *dll) { if(dlclose(dll->handle)) - general_error(ERROR_FFI,false_object,false_object,NULL); + general_error(ERROR_FFI,false_object,false_object); dll->handle = NULL; } @@ -103,7 +103,7 @@ void factor_vm::move_file(const vm_char *path1, const vm_char *path2) ret = rename((path1),(path2)); } while(ret < 0 && errno == EINTR); if(ret < 0) - general_error(ERROR_IO,tag_fixnum(errno),false_object,NULL); + general_error(ERROR_IO,tag_fixnum(errno),false_object); } segment::segment(cell size_, bool executable_p) @@ -141,16 +141,7 @@ segment::~segment() void factor_vm::dispatch_signal(void *uap, void (handler)()) { - if(in_code_heap_p(UAP_PROGRAM_COUNTER(uap))) - { - stack_frame *ptr = (stack_frame *)UAP_STACK_POINTER(uap); - assert(ptr); - signal_callstack_top = ptr; - } - else - signal_callstack_top = NULL; - - UAP_STACK_POINTER(uap) = align_stack_pointer(UAP_STACK_POINTER(uap)); + UAP_STACK_POINTER(uap) = fix_callstack_top((stack_frame *)UAP_STACK_POINTER(uap)); UAP_PROGRAM_COUNTER(uap) = (cell)handler; } diff --git a/vm/os-windows-nt.cpp b/vm/os-windows-nt.cpp index d33a935f7f..e063fe3db3 100755 --- a/vm/os-windows-nt.cpp +++ b/vm/os-windows-nt.cpp @@ -74,6 +74,8 @@ LONG factor_vm::exception_handler(PEXCEPTION_POINTERS pe) PEXCEPTION_RECORD e = (PEXCEPTION_RECORD)pe->ExceptionRecord; CONTEXT *c = (CONTEXT*)pe->ContextRecord; + c->ESP = (cell)fix_callstack_top((stack_frame *)c->ESP); + if(in_code_heap_p(c->EIP)) signal_callstack_top = (stack_frame *)c->ESP; else diff --git a/vm/os-windows.cpp b/vm/os-windows.cpp index 08f5932172..d69966567a 100755 --- a/vm/os-windows.cpp +++ b/vm/os-windows.cpp @@ -140,7 +140,7 @@ long getpagesize() void factor_vm::move_file(const vm_char *path1, const vm_char *path2) { if(MoveFileEx((path1),(path2),MOVEFILE_REPLACE_EXISTING) == false) - general_error(ERROR_IO,tag_fixnum(GetLastError()),false_object,NULL); + general_error(ERROR_IO,tag_fixnum(GetLastError()),false_object); } } diff --git a/vm/segments.hpp b/vm/segments.hpp index 5cedada578..7f86c35485 100644 --- a/vm/segments.hpp +++ b/vm/segments.hpp @@ -15,6 +15,16 @@ struct segment { explicit segment(cell size, bool executable_p); ~segment(); + + bool underflow_p(cell addr) + { + return (addr >= start - getpagesize() && addr < start); + } + + bool overflow_p(cell addr) + { + return (addr >= end && addr < end + getpagesize()); + } }; } diff --git a/vm/vm.hpp b/vm/vm.hpp index defe4f24eb..7a0b0fcd33 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -160,20 +160,20 @@ struct factor_vm void primitive_profiling(); // errors - void throw_error(cell error, stack_frame *callstack_top); + void throw_error(cell error, stack_frame *stack); + void general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *stack); + void general_error(vm_error_type error, cell arg1, cell arg2); + void type_error(cell type, cell tagged); void not_implemented_error(); - bool in_page(cell fault, cell area, cell area_size, int offset); - void memory_protection_error(cell addr, stack_frame *native_stack); - void signal_error(cell signal, stack_frame *native_stack); + void memory_protection_error(cell addr, stack_frame *stack); + void signal_error(cell signal, stack_frame *stack); void divide_by_zero_error(); - void fp_trap_error(unsigned int fpu_status, stack_frame *signal_callstack_top); + void fp_trap_error(unsigned int fpu_status, stack_frame *stack); void primitive_call_clear(); void primitive_unimplemented(); void memory_signal_handler_impl(); void misc_signal_handler_impl(); void fp_signal_handler_impl(); - void type_error(cell type, cell tagged); - void general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *native_stack); // bignum int bignum_equal_p(bignum * x, bignum * y); @@ -582,7 +582,7 @@ struct factor_vm template void iterate_callstack_object(callstack *stack_, Iterator &iterator); void check_frame(stack_frame *frame); callstack *allot_callstack(cell size); - stack_frame *fix_callstack_top(stack_frame *top, stack_frame *bottom); + stack_frame *fix_callstack_top(stack_frame *top); stack_frame *second_from_top_stack_frame(); void primitive_callstack(); code_block *frame_code(stack_frame *frame); From b5f7e91bdcc43e8ff51f91b236a2ee89ad8379dc Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 27 Mar 2010 07:45:11 -0400 Subject: [PATCH 475/713] vm: report callstack overflow --- basis/debugger/debugger.factor | 8 ++++++-- core/kernel/kernel-tests.factor | 4 ++++ vm/errors.cpp | 6 ++++++ vm/errors.hpp | 2 ++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index c34a50190f..d10fd4f73a 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -120,6 +120,8 @@ HOOK: signal-error. os ( obj -- ) : datastack-overflow. ( obj -- ) "Data" stack-overflow. ; : retainstack-underflow. ( obj -- ) "Retain" stack-underflow. ; : retainstack-overflow. ( obj -- ) "Retain" stack-overflow. ; +: callstack-underflow. ( obj -- ) "Call" stack-underflow. ; +: callstack-overflow. ( obj -- ) "Call" stack-overflow. ; : memory-error. ( error -- ) "Memory protection fault at address " write third .h ; @@ -153,8 +155,10 @@ PREDICATE: vm-error < array { 11 [ datastack-overflow. ] } { 12 [ retainstack-underflow. ] } { 13 [ retainstack-overflow. ] } - { 14 [ memory-error. ] } - { 15 [ fp-trap-error. ] } + { 13 [ callstack-underflow. ] } + { 14 [ callstack-overflow. ] } + { 15 [ memory-error. ] } + { 16 [ fp-trap-error. ] } } ; inline M: vm-error summary drop "VM error" ; diff --git a/core/kernel/kernel-tests.factor b/core/kernel/kernel-tests.factor index ca8aa8286b..bf16d9439f 100644 --- a/core/kernel/kernel-tests.factor +++ b/core/kernel/kernel-tests.factor @@ -46,6 +46,10 @@ IN: kernel.tests [ ] [ :c ] unit-test +: overflow-c ( -- ) overflow-c overflow-c ; + +[ overflow-c ] [ { "kernel-error" 14 f f } = ] must-fail-with + [ -7 ] must-fail [ 3 ] [ t 3 and ] unit-test diff --git a/vm/errors.cpp b/vm/errors.cpp index d0c72989a3..21dff5a475 100755 --- a/vm/errors.cpp +++ b/vm/errors.cpp @@ -87,6 +87,8 @@ void factor_vm::not_implemented_error() void factor_vm::memory_protection_error(cell addr, stack_frame *stack) { + /* Retain and call stack underflows are not supposed to happen */ + if(ctx->datastack_seg->underflow_p(addr)) general_error(ERROR_DATASTACK_UNDERFLOW,false_object,false_object,stack); else if(ctx->datastack_seg->overflow_p(addr)) @@ -95,6 +97,10 @@ void factor_vm::memory_protection_error(cell addr, stack_frame *stack) general_error(ERROR_RETAINSTACK_UNDERFLOW,false_object,false_object,stack); else if(ctx->retainstack_seg->overflow_p(addr)) general_error(ERROR_RETAINSTACK_OVERFLOW,false_object,false_object,stack); + else if(ctx->callstack_seg->underflow_p(addr)) + general_error(ERROR_CALLSTACK_UNDERFLOW,false_object,false_object,stack); + else if(ctx->callstack_seg->overflow_p(addr)) + general_error(ERROR_CALLSTACK_OVERFLOW,false_object,false_object,stack); else general_error(ERROR_MEMORY,allot_cell(addr),false_object,stack); } diff --git a/vm/errors.hpp b/vm/errors.hpp index 0ce5957aef..34a23bd46d 100755 --- a/vm/errors.hpp +++ b/vm/errors.hpp @@ -18,6 +18,8 @@ enum vm_error_type ERROR_DATASTACK_OVERFLOW, ERROR_RETAINSTACK_UNDERFLOW, ERROR_RETAINSTACK_OVERFLOW, + ERROR_CALLSTACK_UNDERFLOW, + ERROR_CALLSTACK_OVERFLOW, ERROR_MEMORY, ERROR_FP_TRAP, }; From b6dfdcb9095e3087e7aa657377f82d0a5a2b5218 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 27 Mar 2010 08:13:57 -0400 Subject: [PATCH 476/713] set-context and start-context primitives can now pass parameters around --- basis/cpu/x86/32/bootstrap.factor | 16 ++++++++++------ basis/cpu/x86/64/bootstrap.factor | 18 ++++++++++-------- .../known-words/known-words.factor | 4 ++-- core/bootstrap/primitives.factor | 4 ++-- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/basis/cpu/x86/32/bootstrap.factor b/basis/cpu/x86/32/bootstrap.factor index 6fab8769d5..dde800760e 100644 --- a/basis/cpu/x86/32/bootstrap.factor +++ b/basis/cpu/x86/32/bootstrap.factor @@ -269,12 +269,11 @@ IN: bootstrap.x86 ESP [] vm-reg MOV "new_context" jit-call - ! Save pointer to quotation and parameter, pop them off the - ! datastack + ! Save pointer to quotation and parameter EBX ds-reg MOV ds-reg 8 SUB - ! Make the new context the active context + ! Make the new context active EAX jit-set-context ! Push parameter @@ -288,16 +287,21 @@ IN: bootstrap.x86 ] \ (start-context) define-sub-primitive [ - ! Load context from datastack + ! Load context and parameter from datastack EAX ds-reg [] MOV EAX EAX alien-offset [+] MOV - ds-reg 4 SUB + EBX ds-reg -4 [+] MOV + ds-reg 8 SUB - ! Make it the active context + ! Make the new context active EAX jit-set-context ! Twiddle stack for return ESP 4 ADD + + ! Store parameter to datastack + ds-reg 4 ADD + ds-reg [] EBX MOV ] \ (set-context) define-sub-primitive << "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >> diff --git a/basis/cpu/x86/64/bootstrap.factor b/basis/cpu/x86/64/bootstrap.factor index e8fa026a49..9eb59e2c86 100644 --- a/basis/cpu/x86/64/bootstrap.factor +++ b/basis/cpu/x86/64/bootstrap.factor @@ -242,15 +242,12 @@ IN: bootstrap.x86 arg1 vm-reg MOV "new_context" jit-call - ! Load quotation from datastack + ! Load quotation and parameter from datastack arg1 ds-reg [] MOV - - ! Load parameter from datastack arg2 ds-reg -8 [+] MOV - ds-reg 16 SUB - ! Make the new context the active context + ! Make the new context active return-reg jit-set-context ! Push parameter @@ -262,16 +259,21 @@ IN: bootstrap.x86 ] \ (start-context) define-sub-primitive [ - ! Load context from datastack + ! Load context and parameter from datastack temp0 ds-reg [] MOV temp0 temp0 alien-offset [+] MOV - ds-reg 8 SUB + temp1 ds-reg -8 [+] MOV + ds-reg 16 SUB - ! Make it the active context + ! Make the new context active temp0 jit-set-context ! Twiddle stack for return RSP 8 ADD + + ! Store parameter to datastack + ds-reg 8 ADD + ds-reg [] temp1 MOV ] \ (set-context) define-sub-primitive << "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >> diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index a625eedb3a..a95456cdc6 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -513,9 +513,9 @@ M: bad-executable summary \ delete-context { c-ptr } { } define-primitive -\ (start-context) { object quotation } { } define-primitive +\ (start-context) { object quotation } { object } define-primitive -\ (set-context) { alien } { } define-primitive +\ (set-context) { object alien } { object } define-primitive \ special-object { fixnum } { object } define-primitive \ special-object make-flushable diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 9971c00e1d..38e1a380ee 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -369,8 +369,8 @@ tuple { "fixnum<=" "math.private" (( x y -- z )) } { "fixnum>" "math.private" (( x y -- ? )) } { "fixnum>=" "math.private" (( x y -- ? )) } - { "(set-context)" "threads.private" (( context -- )) } - { "(start-context)" "threads.private" (( obj quot -- )) } + { "(set-context)" "threads.private" (( obj context -- obj' )) } + { "(start-context)" "threads.private" (( obj quot -- obj' )) } } [ first3 make-sub-primitive ] each ! Primitive words From 19aef06741d3998bf4fe83807b097031a45ebb40 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 27 Mar 2010 09:44:20 -0400 Subject: [PATCH 477/713] vm: fix compilation on various Unices --- vm/os-freebsd.hpp | 2 ++ vm/os-linux.hpp | 2 ++ vm/os-macosx.hpp | 2 ++ vm/os-netbsd.hpp | 7 ++----- vm/os-openbsd.hpp | 1 + vm/os-unix.cpp | 2 +- vm/platform.hpp | 3 ++- 7 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 vm/os-openbsd.hpp diff --git a/vm/os-freebsd.hpp b/vm/os-freebsd.hpp index 7797a7199b..177a920d87 100644 --- a/vm/os-freebsd.hpp +++ b/vm/os-freebsd.hpp @@ -6,3 +6,5 @@ extern "C" int getosreldate(); #ifndef KERN_PROC_PATHNAME #define KERN_PROC_PATHNAME 12 #endif + +#define UAP_STACK_POINTER_TYPE __register_t diff --git a/vm/os-linux.hpp b/vm/os-linux.hpp index de13896b9a..6c490de260 100644 --- a/vm/os-linux.hpp +++ b/vm/os-linux.hpp @@ -7,4 +7,6 @@ VM_C_API int inotify_init(); VM_C_API int inotify_add_watch(int fd, const char *name, u32 mask); VM_C_API int inotify_rm_watch(int fd, u32 wd); +#define UAP_STACK_POINTER_TYPE greg_t + } diff --git a/vm/os-macosx.hpp b/vm/os-macosx.hpp index 0d230f48e3..93f6574367 100644 --- a/vm/os-macosx.hpp +++ b/vm/os-macosx.hpp @@ -15,4 +15,6 @@ void c_to_factor_toplevel(cell quot); #define UAP_STACK_POINTER(ucontext) (((ucontext_t *)ucontext)->uc_stack.ss_sp) +#define UAP_STACK_POINTER_TYPE void* + } diff --git a/vm/os-netbsd.hpp b/vm/os-netbsd.hpp index d45b2ac163..e79d1bf375 100644 --- a/vm/os-netbsd.hpp +++ b/vm/os-netbsd.hpp @@ -1,8 +1,5 @@ #include -namespace factor -{ +#define UAP_PROGRAM_COUNTER(uap) _UC_MACHINE_PC((ucontext_t *)uap) -#define UAP_PROGRAM_COUNTER(uap) _UC_MACHINE_PC((ucontext_t *)uap) - -} +#define UAP_STACK_POINTER_TYPE __greg_t diff --git a/vm/os-openbsd.hpp b/vm/os-openbsd.hpp new file mode 100644 index 0000000000..6a81a26be2 --- /dev/null +++ b/vm/os-openbsd.hpp @@ -0,0 +1 @@ +#define UAP_STACK_POINTER_TYPE __greg_t diff --git a/vm/os-unix.cpp b/vm/os-unix.cpp index 94d2a31839..01740a1712 100644 --- a/vm/os-unix.cpp +++ b/vm/os-unix.cpp @@ -141,7 +141,7 @@ segment::~segment() void factor_vm::dispatch_signal(void *uap, void (handler)()) { - UAP_STACK_POINTER(uap) = fix_callstack_top((stack_frame *)UAP_STACK_POINTER(uap)); + UAP_STACK_POINTER(uap) = (UAP_STACK_POINTER_TYPE)fix_callstack_top((stack_frame *)UAP_STACK_POINTER(uap)); UAP_PROGRAM_COUNTER(uap) = (cell)handler; } diff --git a/vm/platform.hpp b/vm/platform.hpp index 2a38c91171..a71aae1e89 100755 --- a/vm/platform.hpp +++ b/vm/platform.hpp @@ -48,6 +48,7 @@ #endif #elif defined(__OpenBSD__) #define FACTOR_OS_STRING "openbsd" + #include "os-openbsd.hpp" #if defined(FACTOR_X86) #include "os-openbsd-x86.32.hpp" @@ -58,6 +59,7 @@ #endif #elif defined(__NetBSD__) #define FACTOR_OS_STRING "netbsd" + #include "os-netbsd.hpp" #if defined(FACTOR_X86) #include "os-netbsd-x86.32.hpp" @@ -67,7 +69,6 @@ #error "Unsupported NetBSD flavor" #endif - #include "os-netbsd.hpp" #elif defined(linux) #define FACTOR_OS_STRING "linux" #include "os-linux.hpp" From 532c2aa5ad5a4c73c9583a536061ddb53c123189 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sat, 27 Mar 2010 14:21:28 -0700 Subject: [PATCH 478/713] FFI structs for manipulating ELF objects. --- extra/elf/authors.txt | 1 + extra/elf/elf.factor | 458 ++++++++++++++++++++++++++++++++++++++++++ extra/elf/summary.txt | 1 + 3 files changed, 460 insertions(+) create mode 100644 extra/elf/authors.txt create mode 100644 extra/elf/elf.factor create mode 100644 extra/elf/summary.txt diff --git a/extra/elf/authors.txt b/extra/elf/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/extra/elf/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/extra/elf/elf.factor b/extra/elf/elf.factor new file mode 100644 index 0000000000..2ad82bc23c --- /dev/null +++ b/extra/elf/elf.factor @@ -0,0 +1,458 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: alien.c-types alien.syntax classes.struct ; +IN: elf + +CONSTANT: EI_NIDENT 16 +CONSTANT: EI_MAG0 0 +CONSTANT: EI_MAG1 1 +CONSTANT: EI_MAG2 2 +CONSTANT: EI_MAG3 3 +CONSTANT: EI_CLASS 4 +CONSTANT: EI_DATA 5 +CONSTANT: EI_VERSION 6 +CONSTANT: EI_OSABI 7 +CONSTANT: EI_ABIVERSION 8 +CONSTANT: EI_PAD 9 + +CONSTANT: ELFMAG0 HEX: 7f +CONSTANT: ELFMAG1 HEX: 45 +CONSTANT: ELFMAG2 HEX: 4c +CONSTANT: ELFMAG3 HEX: 46 + +CONSTANT: ELFCLASS32 1 +CONSTANT: ELFCLASS64 2 + +CONSTANT: ELFDATA2LSB 1 +CONSTANT: ELFDATA2MSB 2 + +CONSTANT: ELFOSABI_SYSV 0 +CONSTANT: ELFOSABI_HPUX 1 +CONSTANT: ELFOSABI_NETBSD 2 +CONSTANT: ELFOSABI_LINUX 3 +CONSTANT: ELFOSABI_SOLARIS 6 +CONSTANT: ELFOSABI_AIX 7 +CONSTANT: ELFOSABI_IRIX 8 +CONSTANT: ELFOSABI_FREEBSD 9 +CONSTANT: ELFOSABI_TRU64 10 +CONSTANT: ELFOSABI_MODESTO 11 +CONSTANT: ELFOSABI_OPENBSD 12 +CONSTANT: ELFOSABI_OPENVMS 13 +CONSTANT: ELFOSABI_NSK 14 +CONSTANT: ELFOSABI_AROS 15 +CONSTANT: ELFOSABI_ARM_AEABI 64 +CONSTANT: ELFOSABI_ARM 97 +CONSTANT: ELFOSABI_STANDALONE 255 + +CONSTANT: ET_NONE 0 +CONSTANT: ET_REL 1 +CONSTANT: ET_EXEC 2 +CONSTANT: ET_DYN 3 +CONSTANT: ET_CORE 4 +CONSTANT: ET_LOOS HEX: FE00 +CONSTANT: ET_HIOS HEX: FEFF +CONSTANT: ET_LOPROC HEX: FF00 +CONSTANT: ET_HIPROC HEX: FFFF + +CONSTANT: EM_NONE 0 +CONSTANT: EM_M32 1 +CONSTANT: EM_SPARC 2 +CONSTANT: EM_386 3 +CONSTANT: EM_68K 4 +CONSTANT: EM_88K 5 +CONSTANT: EM_486 6 +CONSTANT: EM_860 7 +CONSTANT: EM_MIPS 8 +CONSTANT: EM_S370 9 +CONSTANT: EM_MIPS_RS3_LE 10 +CONSTANT: EM_SPARC64 11 +CONSTANT: EM_PARISC 15 +CONSTANT: EM_VPP500 17 +CONSTANT: EM_SPARC32PLUS 18 +CONSTANT: EM_960 19 +CONSTANT: EM_PPC 20 +CONSTANT: EM_PPC64 21 +CONSTANT: EM_S390 22 +CONSTANT: EM_SPU 23 +CONSTANT: EM_V800 36 +CONSTANT: EM_FR20 37 +CONSTANT: EM_RH32 38 +CONSTANT: EM_RCE 39 +CONSTANT: EM_ARM 40 +CONSTANT: EM_ALPHA 41 +CONSTANT: EM_SH 42 +CONSTANT: EM_SPARCV9 43 +CONSTANT: EM_TRICORE 44 +CONSTANT: EM_ARC 45 +CONSTANT: EM_H8_300 46 +CONSTANT: EM_H8_300H 47 +CONSTANT: EM_H8S 48 +CONSTANT: EM_H8_500 49 +CONSTANT: EM_IA_64 50 +CONSTANT: EM_MIPS_X 51 +CONSTANT: EM_COLDFIRE 52 +CONSTANT: EM_68HC12 53 +CONSTANT: EM_MMA 54 +CONSTANT: EM_PCP 55 +CONSTANT: EM_NCPU 56 +CONSTANT: EM_NDR1 57 +CONSTANT: EM_STARCORE 58 +CONSTANT: EM_ME16 59 +CONSTANT: EM_ST100 60 +CONSTANT: EM_TINYJ 61 +CONSTANT: EM_X86_64 62 +CONSTANT: EM_PDSP 63 +CONSTANT: EM_FX66 66 +CONSTANT: EM_ST9PLUS 67 +CONSTANT: EM_ST7 68 +CONSTANT: EM_68HC16 69 +CONSTANT: EM_68HC11 70 +CONSTANT: EM_68HC08 71 +CONSTANT: EM_68HC05 72 +CONSTANT: EM_SVX 73 +CONSTANT: EM_ST19 74 +CONSTANT: EM_VAX 75 +CONSTANT: EM_CRIS 76 +CONSTANT: EM_JAVELIN 77 +CONSTANT: EM_FIREPATH 78 +CONSTANT: EM_ZSP 79 +CONSTANT: EM_MMIX 80 +CONSTANT: EM_HUANY 81 +CONSTANT: EM_PRISM 82 +CONSTANT: EM_AVR 83 +CONSTANT: EM_FR30 84 +CONSTANT: EM_D10V 85 +CONSTANT: EM_D30V 86 +CONSTANT: EM_V850 87 +CONSTANT: EM_M32R 88 +CONSTANT: EM_MN10300 89 +CONSTANT: EM_MN10200 90 +CONSTANT: EM_PJ 91 +CONSTANT: EM_OPENRISC 92 +CONSTANT: EM_ARC_A5 93 +CONSTANT: EM_XTENSA 94 +CONSTANT: EM_VIDEOCORE 95 +CONSTANT: EM_TMM_GPP 96 +CONSTANT: EM_NS32K 97 +CONSTANT: EM_TPC 98 +CONSTANT: EM_SNP1K 99 +CONSTANT: EM_ST200 100 +CONSTANT: EM_IP2K 101 +CONSTANT: EM_MAX 102 +CONSTANT: EM_CR 103 +CONSTANT: EM_F2MC16 104 +CONSTANT: EM_MSP430 105 +CONSTANT: EM_BLACKFIN 106 +CONSTANT: EM_SE_C33 107 +CONSTANT: EM_SEP 108 +CONSTANT: EM_ARCA 109 +CONSTANT: EM_UNICORE 110 + +CONSTANT: EV_NONE 0 +CONSTANT: EV_CURRENT 1 + +CONSTANT: EF_ARM_EABIMASK HEX: ff000000 +CONSTANT: EF_ARM_BE8 HEX: 00800000 + +CONSTANT: SHN_UNDEF HEX: 0000 +CONSTANT: SHN_LOPROC HEX: FF00 +CONSTANT: SHN_HIPROC HEX: FF1F +CONSTANT: SHN_LOOS HEX: FF20 +CONSTANT: SHN_HIOS HEX: FF3F +CONSTANT: SHN_ABS HEX: FFF1 +CONSTANT: SHN_COMMON HEX: FFF2 + +CONSTANT: SHT_NULL 0 +CONSTANT: SHT_PROGBITS 1 +CONSTANT: SHT_SYMTAB 2 +CONSTANT: SHT_STRTAB 3 +CONSTANT: SHT_RELA 4 +CONSTANT: SHT_HASH 5 +CONSTANT: SHT_DYNAMIC 6 +CONSTANT: SHT_NOTE 7 +CONSTANT: SHT_NOBITS 8 +CONSTANT: SHT_REL 9 +CONSTANT: SHT_SHLIB 10 +CONSTANT: SHT_DYNSYM 11 +CONSTANT: SHT_LOOS HEX: 60000000 +CONSTANT: SHT_GNU_LIBLIST HEX: 6ffffff7 +CONSTANT: SHT_CHECKSUM HEX: 6ffffff8 +CONSTANT: SHT_LOSUNW HEX: 6ffffffa +CONSTANT: SHT_SUNW_move HEX: 6ffffffa +CONSTANT: SHT_SUNW_COMDAT HEX: 6ffffffb +CONSTANT: SHT_SUNW_syminfo HEX: 6ffffffc +CONSTANT: SHT_GNU_verdef HEX: 6ffffffd +CONSTANT: SHT_GNU_verneed HEX: 6ffffffe +CONSTANT: SHT_GNU_versym HEX: 6fffffff +CONSTANT: SHT_HISUNW HEX: 6fffffff +CONSTANT: SHT_HIOS HEX: 6fffffff +CONSTANT: SHT_LOPROC HEX: 70000000 +CONSTANT: SHT_ARM_EXIDX HEX: 70000001 +CONSTANT: SHT_ARM_PREEMPTMAP HEX: 70000002 +CONSTANT: SHT_ARM_ATTRIBUTES HEX: 70000003 +CONSTANT: SHT_ARM_DEBUGOVERLAY HEX: 70000004 +CONSTANT: SHT_ARM_OVERLAYSECTION HEX: 70000005 +CONSTANT: SHT_HIPROC HEX: 7fffffff +CONSTANT: SHT_LOUSER HEX: 80000000 +CONSTANT: SHT_HIUSER HEX: 8fffffff + +CONSTANT: SHF_WRITE 1 +CONSTANT: SHF_ALLOC 2 +CONSTANT: SHF_EXECINSTR 4 +CONSTANT: SHF_MERGE 16 +CONSTANT: SHF_STRINGS 32 +CONSTANT: SHF_INFO_LINK 64 +CONSTANT: SHF_LINK_ORDER 128 +CONSTANT: SHF_OS_NONCONFORMING 256 +CONSTANT: SHF_GROUP 512 +CONSTANT: SHF_TLS 1024 +CONSTANT: SHF_MASKOS HEX: 0f000000 +CONSTANT: SHF_MASKPROC HEX: f0000000 + +CONSTANT: STB_LOCAL 0 +CONSTANT: STB_GLOBAL 1 +CONSTANT: STB_WEAK 2 +CONSTANT: STB_LOOS 10 +CONSTANT: STB_HIOS 12 +CONSTANT: STB_LOPROC 13 +CONSTANT: STB_HIPROC 15 + +CONSTANT: STT_NOTYPE 0 +CONSTANT: STT_OBJECT 1 +CONSTANT: STT_FUNC 2 +CONSTANT: STT_SECTION 3 +CONSTANT: STT_FILE 4 +CONSTANT: STT_COMMON 5 +CONSTANT: STT_TLS 6 +CONSTANT: STT_LOOS 10 +CONSTANT: STT_HIOS 12 +CONSTANT: STT_LOPROC 13 +CONSTANT: STT_HIPROC 15 + +CONSTANT: STN_UNDEF 0 + +CONSTANT: STV_DEFAULT 0 +CONSTANT: STV_INTERNAL 1 +CONSTANT: STV_HIDDEN 2 +CONSTANT: STV_PROTECTED 3 + +CONSTANT: PT_NULL 0 +CONSTANT: PT_LOAD 1 +CONSTANT: PT_DYNAMIC 2 +CONSTANT: PT_INTERP 3 +CONSTANT: PT_NOTE 4 +CONSTANT: PT_SHLIB 5 +CONSTANT: PT_PHDR 6 +CONSTANT: PT_TLS 7 +CONSTANT: PT_LOOS HEX: 60000000 +CONSTANT: PT_HIOS HEX: 6fffffff +CONSTANT: PT_LOPROC HEX: 70000000 +CONSTANT: PT_ARM_ARCHEXT HEX: 70000000 +CONSTANT: PT_ARM_EXIDX HEX: 70000001 +CONSTANT: PT_ARM_UNWIND HEX: 70000001 +CONSTANT: PT_HIPROC HEX: 7fffffff + +CONSTANT: PT_ARM_ARCHEXT_FMTMSK HEX: ff000000 +CONSTANT: PT_ARM_ARCHEXT_PROFMSK HEX: 00ff0000 +CONSTANT: PT_ARM_ARCHEXT_ARCHMSK HEX: 000000ff +CONSTANT: PT_ARM_ARCHEXT_FMT_OS HEX: 00000000 +CONSTANT: PT_ARM_ARCHEXT_FMT_ABI HEX: 01000000 +CONSTANT: PT_ARM_ARCHEXT_PROF_NONE HEX: 00000000 +CONSTANT: PT_ARM_ARCHEXT_PROF_ARM HEX: 00410000 +CONSTANT: PT_ARM_ARCHEXT_PROF_RT HEX: 00520000 +CONSTANT: PT_ARM_ARCHEXT_PROF_MC HEX: 004d0000 +CONSTANT: PT_ARM_ARCHEXT_PROF_CLASSIC HEX: 00530000 + +CONSTANT: PT_ARM_ARCHEXT_ARCH_UNKN HEX: 00 +CONSTANT: PT_ARM_ARCHEXT_ARCH_ARCHv4 HEX: 01 +CONSTANT: PT_ARM_ARCHEXT_ARCH_ARCHv4T HEX: 02 +CONSTANT: PT_ARM_ARCHEXT_ARCH_ARCHv5T HEX: 03 +CONSTANT: PT_ARM_ARCHEXT_ARCH_ARCHv5TE HEX: 04 +CONSTANT: PT_ARM_ARCHEXT_ARCH_ARCHv5TEJ HEX: 05 +CONSTANT: PT_ARM_ARCHEXT_ARCH_ARCHv6 HEX: 06 +CONSTANT: PT_ARM_ARCHEXT_ARCH_ARCHv6KZ HEX: 07 +CONSTANT: PT_ARM_ARCHEXT_ARCH_ARCHv6T2 HEX: 08 +CONSTANT: PT_ARM_ARCHEXT_ARCH_ARCHv6K HEX: 09 +CONSTANT: PT_ARM_ARCHEXT_ARCH_ARCHv7 HEX: 0A +CONSTANT: PT_ARM_ARCHEXT_ARCH_ARCHv6M HEX: 0B +CONSTANT: PT_ARM_ARCHEXT_ARCH_ARCHv6SM HEX: 0C +CONSTANT: PT_ARM_ARCHEXT_ARCH_ARCHv7EM HEX: 0D + +CONSTANT: PF_X 1 +CONSTANT: PF_W 2 +CONSTANT: PF_R 4 +CONSTANT: PF_MASKOS HEX: 00ff0000 +CONSTANT: PF_MASKPROC HEX: ff000000 + +CONSTANT: DT_NULL 0 +CONSTANT: DT_NEEDED 1 +CONSTANT: DT_PLTRELSZ 2 +CONSTANT: DT_PLTGOT 3 +CONSTANT: DT_HASH 4 +CONSTANT: DT_STRTAB 5 +CONSTANT: DT_SYMTAB 6 +CONSTANT: DT_RELA 7 +CONSTANT: DT_RELASZ 8 +CONSTANT: DT_RELAENT 9 +CONSTANT: DT_STRSZ 10 +CONSTANT: DT_SYMENT 11 +CONSTANT: DT_INIT 12 +CONSTANT: DT_FINI 13 +CONSTANT: DT_SONAME 14 +CONSTANT: DT_RPATH 15 +CONSTANT: DT_SYMBOLIC 16 +CONSTANT: DT_REL 17 +CONSTANT: DT_RELSZ 18 +CONSTANT: DT_RELENT 19 +CONSTANT: DT_PLTREL 20 +CONSTANT: DT_DEBUG 21 +CONSTANT: DT_TEXTREL 22 +CONSTANT: DT_JMPREL 23 +CONSTANT: DT_BIND_NOW 24 +CONSTANT: DT_INIT_ARRAY 25 +CONSTANT: DT_FINI_ARRAY 26 +CONSTANT: DT_INIT_ARRAYSZ 27 +CONSTANT: DT_FINI_ARRAYSZ 28 +CONSTANT: DT_RUNPATH 29 +CONSTANT: DT_FLAGS 30 +CONSTANT: DT_ENCODING 32 +CONSTANT: DT_PREINIT_ARRAY 32 +CONSTANT: DT_PREINIT_ARRAYSZ 33 +CONSTANT: DT_LOOS HEX: 60000000 +CONSTANT: DT_HIOS HEX: 6fffffff +CONSTANT: DT_LOPROC HEX: 70000000 +CONSTANT: DT_ARM_RESERVED1 HEX: 70000000 +CONSTANT: DT_ARM_SYMTABSZ HEX: 70000001 +CONSTANT: DT_ARM_PREEMPTYMAP HEX: 70000002 +CONSTANT: DT_ARM_RESERVED2 HEX: 70000003 +CONSTANT: DT_HIPROC HEX: 7fffffff + +TYPEDEF: ushort Elf32_Half +TYPEDEF: uint Elf32_Word +TYPEDEF: int Elf32_Sword +TYPEDEF: uint Elf32_Off +TYPEDEF: uint Elf32_Addr +TYPEDEF: ushort Elf64_Half +TYPEDEF: uint Elf64_Word +TYPEDEF: ulonglong Elf64_Xword +TYPEDEF: longlong Elf64_Sxword +TYPEDEF: ulonglong Elf64_Off +TYPEDEF: ulonglong Elf64_Addr + +STRUCT: Elf32_Ehdr + { e_ident uchar[16] } + { e_type Elf32_Half } + { e_machine Elf32_Half } + { e_version Elf32_Word } + { e_entry Elf32_Addr } + { e_phoff Elf32_Off } + { e_shoff Elf32_Off } + { e_flags Elf32_Word } + { e_ehsize Elf32_Half } + { e_phentsize Elf32_Half } + { e_phnum Elf32_Half } + { e_shentsize Elf32_Half } + { e_shnum Elf32_Half } + { e_shstrndx Elf32_Half } ; + +STRUCT: Elf64_Ehdr + { e_ident uchar[16] } + { e_type Elf64_Half } + { e_machine Elf64_Half } + { e_version Elf64_Word } + { e_entry Elf64_Addr } + { e_phoff Elf64_Off } + { e_shoff Elf64_Off } + { e_flags Elf64_Word } + { e_ehsize Elf64_Half } + { e_phentsize Elf64_Half } + { e_phnum Elf64_Half } + { e_shentsize Elf64_Half } + { e_shnum Elf64_Half } + { e_shstrndx Elf64_Half } ; + +STRUCT: Elf32_Shdr + { sh_name Elf32_Word } + { sh_type Elf32_Word } + { sh_flags Elf32_Word } + { sh_addr Elf32_Addr } + { sh_offset Elf32_Off } + { sh_size Elf32_Word } + { sh_link Elf32_Word } + { sh_info Elf32_Word } + { sh_addralign Elf32_Word } + { sh_entsize Elf32_Word } ; + +STRUCT: Elf64_Shdr + { sh_name Elf64_Word } + { sh_type Elf64_Word } + { sh_flags Elf64_Xword } + { sh_addr Elf64_Addr } + { sh_offset Elf64_Off } + { sh_size Elf64_Xword } + { sh_link Elf64_Word } + { sh_info Elf64_Word } + { sh_addralign Elf64_Xword } + { sh_entsize Elf64_Xword } ; + +STRUCT: Elf32_Sym + { st_name Elf32_Word } + { st_value Elf32_Addr } + { st_size Elf32_Word } + { st_info uchar } + { st_other uchar } + { st_shndx Elf32_Half } ; + +STRUCT: Elf64_Sym + { st_name Elf64_Word } + { st_info uchar } + { st_other uchar } + { st_shndx Elf64_Half } + { st_value Elf64_Addr } + { st_size Elf64_Xword } ; + +STRUCT: Elf32_Rel + { r_offset Elf32_Addr } + { r_info Elf32_Word } ; + +STRUCT: Elf32_Rela + { r_offset Elf32_Addr } + { r_info Elf32_Word } + { r_addend Elf32_Sword } ; + +STRUCT: Elf64_Rel + { r_offset Elf64_Addr } + { r_info Elf64_Xword } ; + +STRUCT: Elf64_Rela + { r_offset Elf64_Addr } + { r_info Elf64_Xword } + { r_addend Elf64_Sxword } ; + +STRUCT: Elf32_Phdr + { p_type Elf32_Word } + { p_offset Elf32_Off } + { p_vaddr Elf32_Addr } + { p_paddr Elf32_Addr } + { p_filesz Elf32_Word } + { p_memsz Elf32_Word } + { p_flags Elf32_Word } + { p_align Elf32_Word } ; + +STRUCT: Elf64_Phdr + { p_type Elf64_Word } + { p_flags Elf64_Word } + { p_offset Elf64_Off } + { p_vaddr Elf64_Addr } + { p_paddr Elf64_Addr } + { p_filesz Elf64_Xword } + { p_memsz Elf64_Xword } + { p_align Elf64_Xword } ; + +STRUCT: Elf32_Dyn + { d_tag Elf32_Sword } + { d_val Elf32_Word } ; + +STRUCT: Elf64_Dyn + { d_tag Elf64_Sxword } + { d_val Elf64_Xword } ; diff --git a/extra/elf/summary.txt b/extra/elf/summary.txt new file mode 100644 index 0000000000..5cb6b843c3 --- /dev/null +++ b/extra/elf/summary.txt @@ -0,0 +1 @@ +Constants and structs related to the ELF object format. From fcec127d2d93c9413e3f6a5317550ebc0d06663f Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sat, 27 Mar 2010 14:31:24 -0700 Subject: [PATCH 479/713] Debug rendering vocabulary --- extra/game/debug/authors.txt | 1 + extra/game/debug/debug.factor | 212 ++++++++++++++++++++++++++++ extra/game/debug/summary.txt | 1 + extra/game/debug/tags.txt | 1 + extra/game/debug/tests/tests.factor | 68 +++++++++ 5 files changed, 283 insertions(+) create mode 100644 extra/game/debug/authors.txt create mode 100644 extra/game/debug/debug.factor create mode 100644 extra/game/debug/summary.txt create mode 100644 extra/game/debug/tags.txt create mode 100644 extra/game/debug/tests/tests.factor diff --git a/extra/game/debug/authors.txt b/extra/game/debug/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/extra/game/debug/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/extra/game/debug/debug.factor b/extra/game/debug/debug.factor new file mode 100644 index 0000000000..a4f4895812 --- /dev/null +++ b/extra/game/debug/debug.factor @@ -0,0 +1,212 @@ +! Copyright (C) 2010 Erik Charlebois +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien.c-types arrays circular colors colors.constants +columns destructors fonts gpu.buffers gpu.render gpu.shaders gpu.state +gpu.textures images kernel literals locals make math math.constants +math.functions math.vectors sequences specialized-arrays typed ui.text fry ; +FROM: alien.c-types => float ; +SPECIALIZED-ARRAYS: float uint ; +IN: game.debug + +image ( string color -- image ) + debug-text-font clone swap >>foreground swap string>image drop ; + +:: image>texture ( image -- texture ) + image [ component-order>> ] [ component-type>> ] bi + debug-text-texture-parameters &dispose + [ 0 image allocate-texture-image ] keep ; + +:: screen-quad ( image pt dim -- float-array ) + pt dim v/ 2.0 v*n 1.0 v-n + dup image dim>> dim v/ 2.0 v*n v+ + [ first2 ] bi@ :> ( x0 y0 x1 y1 ) + image upside-down?>> + [ { x0 y0 0 0 x1 y0 1 0 x1 y1 1 1 x0 y1 0 1 } ] + [ { x0 y0 0 1 x1 y0 1 1 x1 y1 1 0 x0 y1 0 0 } ] + if >float-array ; + +: debug-text-uniform-variables ( string color -- image uniforms ) + text>image dup image>texture + float-array{ 0.0 0.0 0.0 } + debug-text-uniforms boa swap ; + +: debug-text-vertex-array ( image pt dim -- vertex-array ) + screen-quad stream-upload draw-usage vertex-buffer byte-array>buffer &dispose + debug-text-program &dispose ; + +: debug-text-index-buffer ( -- index-buffer ) + uint-array{ 0 1 2 2 3 0 } stream-upload draw-usage index-buffer + byte-array>buffer &dispose 0 6 uint-indexes ; + +: debug-text-render ( uniforms vertex-array index-buffer -- ) + [ + { + { "primitive-mode" [ 3drop triangles-mode ] } + { "uniforms" [ 2drop ] } + { "vertex-array" [ drop nip ] } + { "indexes" [ 2nip ] } + } 3 render + ] with-destructors ; + +: debug-shapes-vertex-array ( sequence -- vertex-array ) + stream-upload draw-usage vertex-buffer byte-array>buffer &dispose + debug-shapes-program &dispose &dispose ; + +: draw-debug-primitives ( mode primitives mvp-matrix -- ) + f origin-upper-left 1.0 set-gpu-state + { + { "primitive-mode" [ 2drop ] } + { "uniforms" [ 2nip debug-shapes-uniforms boa ] } + { "vertex-array" [ drop nip debug-shapes-vertex-array ] } + { "indexes" [ drop nip length 0 swap ] } + } 3 render ; + +CONSTANT: box-vertices + { { { 1 1 1 } { 1 1 -1 } } + { { 1 1 1 } { 1 -1 1 } } + { { 1 1 1 } { -1 1 1 } } + { { -1 -1 -1 } { -1 -1 1 } } + { { -1 -1 -1 } { -1 1 -1 } } + { { -1 -1 -1 } { 1 -1 -1 } } + { { -1 -1 1 } { -1 1 1 } } + { { -1 -1 1 } { 1 -1 1 } } + { { -1 1 -1 } { -1 1 1 } } + { { -1 1 -1 } { 1 1 -1 } } + { { 1 -1 -1 } { 1 -1 1 } } + { { 1 -1 -1 } { 1 1 -1 } } } + +CONSTANT: cylinder-vertices + $[ 12 iota [ 2pi 12 / * [ cos ] [ drop 0.0 ] [ sin ] tri 3array ] map ] + +:: scale-cylinder-vertices ( radius half-height verts -- bot-verts top-verts ) + verts + [ [ radius v*n { 0 half-height 0 } v- ] map ] + [ [ radius v*n { 0 half-height 0 } v+ ] map ] bi ; +PRIVATE> + +: debug-point ( pt color -- ) + [ first3 [ , ] tri@ ] + [ [ red>> , ] [ green>> , ] [ blue>> , ] tri ] + bi* ; inline + +: debug-line ( from to color -- ) + dup swapd [ debug-point ] 2bi@ ; inline + +: debug-axes ( pt mat -- ) + [ 0 normalize over v+ COLOR: red debug-line ] + [ 1 normalize over v+ COLOR: green debug-line ] + [ 2 normalize over v+ COLOR: blue debug-line ] + 2tri ; inline + +:: debug-box ( pt half-widths color -- ) + box-vertices [ + first2 [ half-widths v* pt v+ ] bi@ color debug-line + ] each ; inline + +:: debug-circle ( points color -- ) + points dup [ 1 swap change-circular-start ] keep + [ color debug-line ] 2each ; inline + +:: debug-cylinder ( pt half-height radius color -- ) + radius half-height cylinder-vertices scale-cylinder-vertices + [ [ color debug-circle ] bi@ ] + [ color '[ _ debug-line ] 2each ] 2bi ; inline + +TYPED: draw-debug-lines ( lines: float-array mvp-matrix -- ) + [ lines-mode -rot draw-debug-primitives ] with-destructors ; inline + +TYPED: draw-debug-points ( points: float-array mvp-matrix -- ) + [ points-mode -rot draw-debug-primitives ] with-destructors ; inline + +TYPED: draw-text ( string color: rgba pt dim -- ) + [ + [ debug-text-uniform-variables ] 2dip + debug-text-vertex-array + debug-text-index-buffer + debug-text-render + ] with-destructors ; inline diff --git a/extra/game/debug/summary.txt b/extra/game/debug/summary.txt new file mode 100644 index 0000000000..1f772ef24b --- /dev/null +++ b/extra/game/debug/summary.txt @@ -0,0 +1 @@ +Simple shape rendering for visual debugging. diff --git a/extra/game/debug/tags.txt b/extra/game/debug/tags.txt new file mode 100644 index 0000000000..84d4140a70 --- /dev/null +++ b/extra/game/debug/tags.txt @@ -0,0 +1 @@ +games diff --git a/extra/game/debug/tests/tests.factor b/extra/game/debug/tests/tests.factor new file mode 100644 index 0000000000..049aa2b492 --- /dev/null +++ b/extra/game/debug/tests/tests.factor @@ -0,0 +1,68 @@ +! Copyright (C) 2010 Erik Charlebois +! See http://factorcode.org/license.txt for BSD license. +USING: accessors colors.constants game.loop game.worlds gpu +gpu.framebuffers gpu.util.wasd game.debug kernel literals locals +make math math.constants math.matrices math.parser sequences +alien.c-types specialized-arrays ui.gadgets.worlds ui.pixel-formats ; +FROM: alien.c-types => float ; +SPECIALIZED-ARRAY: float +IN: game.debug.tests + +:: clear-screen ( color -- ) + system-framebuffer { + { default-attachment color } + } clear-framebuffer ; + +: deg>rad ( d -- r ) + 180 / pi * ; + +:: draw-debug-tests ( world -- ) + world [ wasd-p-matrix ] [ wasd-mv-matrix ] bi m. :> mvp-matrix + { 0 0 0 } clear-screen + + [ + { 0 0 0 } { 1 0 0 } COLOR: red debug-line + { 0 0 0 } { 0 1 0 } COLOR: green debug-line + { 0 0 0 } { 0 0 1 } COLOR: blue debug-line + { -1.2 0 0 } { 0 1 0 } 0 deg>rad rotation-matrix3 debug-axes + { 3 5 -2 } { 3 2 1 } COLOR: white debug-box + { 0 9 0 } 8 2 COLOR: blue debug-cylinder + ] float-array{ } make + mvp-matrix draw-debug-lines + + [ + { 0 4.0 0 } COLOR: red debug-point + { 0 4.1 0 } COLOR: green debug-point + { 0 4.2 0 } COLOR: blue debug-point + ] float-array{ } make + mvp-matrix draw-debug-points + + "Frame: " world frame-number>> number>string append + COLOR: purple { 5 5 } world dim>> draw-text + world [ 1 + ] change-frame-number drop ; + +TUPLE: tests-world < wasd-world frame-number ; +M: tests-world draw-world* draw-debug-tests ; +M: tests-world wasd-movement-speed drop 1/16. ; +M: tests-world wasd-near-plane drop 1/32. ; +M: tests-world wasd-far-plane drop 1024.0 ; +M: tests-world begin-game-world + init-gpu + 0 >>frame-number + { 0.0 0.0 2.0 } 0 0 set-wasd-view drop ; + +GAME: run-tests { + { world-class tests-world } + { title "game.debug.tests" } + { pixel-format-attributes { + windowed + double-buffered + T{ depth-bits { value 24 } } + } } + { grab-input? t } + { use-game-input? t } + { pref-dim { 1024 768 } } + { tick-interval-micros $[ 60 fps ] } + } ; + +MAIN: run-tests From 031ea6c39cc26217c68448bc205dcd8d9eaf8731 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 28 Mar 2010 08:29:10 -0400 Subject: [PATCH 480/713] vm: fix factor_vm::dispatch_signal() --- vm/os-unix.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vm/os-unix.cpp b/vm/os-unix.cpp index 01740a1712..8aa100aa01 100644 --- a/vm/os-unix.cpp +++ b/vm/os-unix.cpp @@ -67,7 +67,7 @@ void sleep_nanos(u64 nsec) void factor_vm::init_ffi() { - /* NULL_DLL is "libfactor.dylib" for OS X and NULL for generic unix */ + /* NULL_DLL is "libfactor.dylib" for OS X and NULL for generic Unix */ null_dll = dlopen(NULL_DLL,RTLD_LAZY); } @@ -143,6 +143,8 @@ void factor_vm::dispatch_signal(void *uap, void (handler)()) { UAP_STACK_POINTER(uap) = (UAP_STACK_POINTER_TYPE)fix_callstack_top((stack_frame *)UAP_STACK_POINTER(uap)); UAP_PROGRAM_COUNTER(uap) = (cell)handler; + + signal_callstack_top = (stack_frame *)UAP_STACK_POINTER(uap); } void memory_signal_handler(int signal, siginfo_t *siginfo, void *uap) From f1e19aabdbf96fcfc8b84abf2e6b3bd7f9649533 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 27 Mar 2010 12:03:06 -0400 Subject: [PATCH 481/713] threads: simplify 'suspend' combinator --- basis/alarms/alarms-tests.factor | 5 +-- basis/channels/channels.factor | 10 ++--- .../concurrency/conditions/conditions.factor | 9 ++-- .../concurrency/exchangers/exchangers.factor | 5 ++- basis/deques/deques.factor | 10 ++--- basis/io/backend/unix/unix.factor | 11 +++-- basis/io/backend/windows/nt/nt.factor | 4 +- basis/io/launcher/launcher.factor | 8 +--- basis/threads/threads-docs.factor | 6 +-- basis/threads/threads-tests.factor | 6 +-- basis/threads/threads.factor | 44 ++++++++++--------- .../tools/continuations/continuations.factor | 14 +++--- 12 files changed, 64 insertions(+), 68 deletions(-) diff --git a/basis/alarms/alarms-tests.factor b/basis/alarms/alarms-tests.factor index 2379e3e80d..8f7868324d 100644 --- a/basis/alarms/alarms-tests.factor +++ b/basis/alarms/alarms-tests.factor @@ -11,7 +11,6 @@ IN: alarms.tests ] unit-test [ ] [ - [ - [ resume ] curry instant later drop - ] "test" suspend drop + self [ resume ] curry instant later drop + "test" suspend drop ] unit-test diff --git a/basis/channels/channels.factor b/basis/channels/channels.factor index 0eb7881f95..870085f77a 100644 --- a/basis/channels/channels.factor +++ b/basis/channels/channels.factor @@ -17,7 +17,7 @@ GENERIC: from ( channel -- value ) > push ] curry + [ self ] dip senders>> push "channel send" suspend drop ; : (to) ( value receivers -- ) @@ -36,7 +36,7 @@ M: channel to ( value channel -- ) [ dup wait to ] [ nip (to) ] if-empty ; M: channel from ( channel -- value ) - [ - notify senders>> - [ (from) ] unless-empty - ] curry "channel receive" suspend ; + [ self ] dip + notify senders>> + [ (from) ] unless-empty + "channel receive" suspend ; diff --git a/basis/concurrency/conditions/conditions.factor b/basis/concurrency/conditions/conditions.factor index ad00bbdfa9..4a1c7d3370 100644 --- a/basis/concurrency/conditions/conditions.factor +++ b/basis/concurrency/conditions/conditions.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: deques threads kernel arrays sequences alarms fry ; IN: concurrency.conditions @@ -22,10 +22,13 @@ IN: concurrency.conditions ERROR: wait-timeout ; +: queue ( queue -- ) + [ self ] dip push-front ; + : wait ( queue timeout status -- ) over [ - [ queue-timeout [ drop ] ] dip suspend + [ queue-timeout ] dip suspend [ wait-timeout ] [ cancel-alarm ] if ] [ - [ drop '[ _ push-front ] ] dip suspend drop + [ drop queue ] dip suspend drop ] if ; diff --git a/basis/concurrency/exchangers/exchangers.factor b/basis/concurrency/exchangers/exchangers.factor index 97b3c14fe4..7cfe016085 100644 --- a/basis/concurrency/exchangers/exchangers.factor +++ b/basis/concurrency/exchangers/exchangers.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel threads boxes accessors fry ; IN: concurrency.exchangers @@ -17,5 +17,6 @@ TUPLE: exchanger thread object ; [ thread>> box> resume-with ] dip ] [ [ object>> >box ] keep - '[ _ thread>> >box ] "exchange" suspend + [ self ] dip thread>> >box + "exchange" suspend ] if ; diff --git a/basis/deques/deques.factor b/basis/deques/deques.factor index 1e1be404a7..7483c0f56b 100644 --- a/basis/deques/deques.factor +++ b/basis/deques/deques.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008, 2009 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences math fry ; IN: deques @@ -16,22 +16,22 @@ GENERIC: node-value ( node -- value ) GENERIC: deque-empty? ( deque -- ? ) : push-front ( obj deque -- ) - push-front* drop ; + push-front* drop ; inline : push-all-front ( seq deque -- ) [ push-front ] curry each ; : push-back ( obj deque -- ) - push-back* drop ; + push-back* drop ; inline : push-all-back ( seq deque -- ) [ push-back ] curry each ; : pop-front ( deque -- obj ) - [ peek-front ] [ pop-front* ] bi ; + [ peek-front ] [ pop-front* ] bi ; inline : pop-back ( deque -- obj ) - [ peek-back ] [ pop-back* ] bi ; + [ peek-back ] [ pop-back* ] bi ; inline : slurp-deque ( deque quot -- ) [ drop '[ _ deque-empty? not ] ] diff --git a/basis/io/backend/unix/unix.factor b/basis/io/backend/unix/unix.factor index 39f0a5fec3..0e84f1b65e 100644 --- a/basis/io/backend/unix/unix.factor +++ b/basis/io/backend/unix/unix.factor @@ -67,12 +67,11 @@ M: io-timeout summary drop "I/O operation timed out" ; : wait-for-fd ( handle event -- ) dup +retry+ eq? [ 2drop ] [ - '[ - swap handle-fd mx get-global _ { - { +input+ [ add-input-callback ] } - { +output+ [ add-output-callback ] } - } case - ] "I/O" suspend nip [ io-timeout ] when + [ [ self ] dip handle-fd mx get-global ] dip { + { +input+ [ add-input-callback ] } + { +output+ [ add-output-callback ] } + } case + "I/O" suspend [ io-timeout ] when ] if ; : wait-for-port ( port event -- ) diff --git a/basis/io/backend/windows/nt/nt.factor b/basis/io/backend/windows/nt/nt.factor index de29f33ee6..5cbe7b3ad9 100644 --- a/basis/io/backend/windows/nt/nt.factor +++ b/basis/io/backend/windows/nt/nt.factor @@ -40,8 +40,8 @@ M: winnt add-completion ( win32-handle -- ) : twiddle-thumbs ( overlapped port -- bytes-transferred ) [ drop - [ >c-ptr pending-overlapped get-global set-at ] curry "I/O" suspend - { + [ self ] dip >c-ptr pending-overlapped get-global set-at + "I/O" suspend { { [ dup integer? ] [ ] } { [ dup array? ] [ first dup eof? diff --git a/basis/io/launcher/launcher.factor b/basis/io/launcher/launcher.factor index 3999a026c0..dfbbd33d2e 100755 --- a/basis/io/launcher/launcher.factor +++ b/basis/io/launcher/launcher.factor @@ -129,12 +129,8 @@ M: process-was-killed error. : (wait-for-process) ( process -- status ) dup handle>> - [ - dup [ processes get at push ] curry - "process" suspend drop - ] when - dup killed>> - [ process-was-killed ] [ status>> ] if ; + [ self over processes get at push "process" suspend drop ] when + dup killed>> [ process-was-killed ] [ status>> ] if ; : wait-for-process ( process -- status ) [ (wait-for-process) ] with-timeout ; diff --git a/basis/threads/threads-docs.factor b/basis/threads/threads-docs.factor index 995fc867e7..335fbb3902 100644 --- a/basis/threads/threads-docs.factor +++ b/basis/threads/threads-docs.factor @@ -142,10 +142,8 @@ HELP: interrupt { $description "Interrupts a sleeping thread." } ; HELP: suspend -{ $values { "quot" { $quotation "( thread -- )" } } { "state" string } { "obj" object } } -{ $description "Suspends the current thread and passes it to the quotation." -$nl -"After the quotation returns, control yields to the next runnable thread and the current thread does not execute again until it is resumed, and so the quotation must arrange for another thread to later resume the suspended thread with a call to " { $link resume } " or " { $link resume-with } "." +{ $values { "state" string } { "obj" object } } +{ $description "Suspends the current thread. Control yields to the next runnable thread and the current thread does not execute again until it is resumed, and so the caller of this word must arrange for another thread to later resume the suspended thread with a call to " { $link resume } " or " { $link resume-with } "." $nl "The status string is for debugging purposes; see " { $link "tools.threads" } "." } ; diff --git a/basis/threads/threads-tests.factor b/basis/threads/threads-tests.factor index 4568b7c491..6e573ccd88 100644 --- a/basis/threads/threads-tests.factor +++ b/basis/threads/threads-tests.factor @@ -13,9 +13,7 @@ yield [ ] [ 0.3 sleep ] unit-test [ "hey" sleep ] must-fail -[ 3 ] [ - [ 3 swap resume-with ] "Test suspend" suspend -] unit-test +[ 3 ] [ 3 self resume-with "Test suspend" suspend ] unit-test [ f ] [ f get-global ] unit-test @@ -29,8 +27,6 @@ yield ] parallel-map ] unit-test -[ [ 3 throw ] "A" suspend ] [ 3 = ] must-fail-with - :: spawn-namespace-test ( -- ? ) :> p gensym :> g [ diff --git a/basis/threads/threads.factor b/basis/threads/threads.factor index 9282dda46f..09869924f4 100644 --- a/basis/threads/threads.factor +++ b/basis/threads/threads.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2004, 2009 Slava Pestov. +! Copyright (C) 2004, 2010 Slava Pestov. ! Copyright (C) 2005 Mackenzie Straight. ! See http://factorcode.org/license.txt for BSD license. USING: arrays hashtables heaps kernel kernel.private math @@ -12,8 +12,8 @@ IN: threads ! (set-context) and (start-context) are sub-primitives, but ! we don't want them inlined into callers since their behavior ! depends on what frames are on the callstack -: start-context ( obj quot: ( obj -- * ) -- ) (start-context) ; -: set-context ( context -- ) (set-context) ; +: set-context ( obj context -- obj' ) (set-context) ; +: start-context ( obj quot: ( obj -- * ) -- obj' ) (start-context) ; PRIVATE> @@ -24,14 +24,15 @@ TUPLE: thread { quot callable initial: [ ] } { exit-handler callable initial: [ ] } { id integer } -continuation +{ continuation box } state runnable mailbox -variables +{ variables hashtable } sleep-entry ; -: self ( -- thread ) 63 special-object ; inline +: self ( -- thread ) + 63 special-object { thread } declare ; inline ! Thread-local storage : tnamespace ( -- assoc ) @@ -46,9 +47,11 @@ sleep-entry ; : tchange ( key quot -- ) tnamespace swap change-at ; inline -: threads ( -- assoc ) 64 special-object ; +: threads ( -- assoc ) + 64 special-object { hashtable } declare ; inline -: thread ( id -- thread ) threads at ; +: thread ( id -- thread ) + threads at ; : thread-registered? ( thread -- ? ) id>> threads key? ; @@ -85,9 +88,11 @@ PRIVATE> : ( quot name -- thread ) \ thread new-thread ; -: run-queue ( -- dlist ) 65 special-object ; +: run-queue ( -- dlist ) + 65 special-object { dlist } declare ; inline -: sleep-queue ( -- heap ) 66 special-object ; +: sleep-queue ( -- heap ) + 66 special-object { dlist } declare ; inline : resume ( thread -- ) f >>state @@ -175,25 +180,22 @@ DEFER: next PRIVATE> -: stop ( -- ) +: stop ( -- * ) self [ exit-handler>> call( -- ) ] [ unregister-thread ] bi next ; -: suspend ( quot state -- obj ) - [ - [ [ self swap call ] dip self (>>state) ] dip - self continuation>> >box - next - ] callcc1 2nip ; inline +: suspend ( state -- obj ) + self (>>state) + [ self continuation>> >box next ] callcc1 ; inline -: yield ( -- ) [ resume ] f suspend drop ; +: yield ( -- ) self resume f suspend drop ; GENERIC: sleep-until ( n/f -- ) M: integer sleep-until - '[ _ schedule-sleep ] "sleep" suspend drop ; + [ self ] dip schedule-sleep "sleep" suspend drop ; M: f sleep-until - drop [ drop ] "interrupt" suspend drop ; + drop "interrupt" suspend drop ; GENERIC: sleep ( dt -- ) @@ -218,7 +220,7 @@ M: real sleep : in-thread ( quot -- ) [ datastack ] dip - '[ _ set-datastack _ call ] + '[ _ set-datastack @ ] "Thread" spawn drop ; GENERIC: error-in-thread ( error thread -- ) diff --git a/basis/tools/continuations/continuations.factor b/basis/tools/continuations/continuations.factor index 15fdb9f9b5..6f748cdb31 100644 --- a/basis/tools/continuations/continuations.factor +++ b/basis/tools/continuations/continuations.factor @@ -1,10 +1,11 @@ -! Copyright (C) 2009 Slava Pestov. +! Copyright (C) 2009, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: threads kernel namespaces continuations combinators -sequences math namespaces.private continuations.private -concurrency.messaging quotations kernel.private words -sequences.private assocs models models.arrow arrays accessors -generic generic.single definitions make sbufs tools.crossref fry ; +USING: threads threads.private kernel namespaces continuations +combinators sequences math namespaces.private +continuations.private concurrency.messaging quotations +kernel.private words sequences.private assocs models +models.arrow arrays accessors generic generic.single definitions +make sbufs tools.crossref fry ; IN: tools.continuations >n ndrop >c c> continue continue-with stop suspend (spawn) + set-context start-context } [ don't-step-into ] each \ break [ break ] "step-into" set-word-prop From e859a3209628b44b8e3382e5c1ac9894c1917505 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 28 Mar 2010 07:30:58 -0400 Subject: [PATCH 482/713] cpu.x86.bootstrap: fix jit-profiling regression --- basis/cpu/x86/bootstrap.factor | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/basis/cpu/x86/bootstrap.factor b/basis/cpu/x86/bootstrap.factor index d75d80faf2..961f0c9977 100644 --- a/basis/cpu/x86/bootstrap.factor +++ b/basis/cpu/x86/bootstrap.factor @@ -67,15 +67,15 @@ big-endian off [ ! Load word - temp0 0 MOV rc-absolute-cell rt-literal jit-rel + nv-reg 0 MOV rc-absolute-cell rt-literal jit-rel ! Bump profiling counter - temp0 profile-count-offset [+] 1 tag-fixnum ADD + nv-reg profile-count-offset [+] 1 tag-fixnum ADD ! Load word->code - temp0 temp0 word-code-offset [+] MOV + nv-reg nv-reg word-code-offset [+] MOV ! Compute word entry point - temp0 compiled-header-size ADD + nv-reg compiled-header-size ADD ! Jump to entry point - temp0 JMP + nv-reg JMP ] jit-profiling jit-define [ From 9ffe0a69d158dca004e33f6859421bb609f01ac5 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 28 Mar 2010 11:37:28 -0400 Subject: [PATCH 483/713] vm: use sigaltstack to handle callstack overflow properly --- vm/os-genunix.cpp | 2 +- vm/os-genunix.hpp | 2 -- vm/os-macosx.hpp | 3 --- vm/os-macosx.mm | 8 +++----- vm/os-unix.cpp | 23 ++++++++++++++++------- vm/os-unix.hpp | 1 - vm/os-windows.cpp | 2 ++ vm/os-windows.hpp | 1 - vm/vm.cpp | 8 +++++++- vm/vm.hpp | 45 +++++++++++++++++++++++++-------------------- 10 files changed, 54 insertions(+), 41 deletions(-) diff --git a/vm/os-genunix.cpp b/vm/os-genunix.cpp index 301b68fb52..c7449e867b 100644 --- a/vm/os-genunix.cpp +++ b/vm/os-genunix.cpp @@ -9,7 +9,7 @@ void factor_vm::c_to_factor_toplevel(cell quot) c_to_factor(quot); } -void init_signals() +void factor_vm::init_signals() { unix_init_signals(); } diff --git a/vm/os-genunix.hpp b/vm/os-genunix.hpp index 1972a728e6..c6123eca56 100644 --- a/vm/os-genunix.hpp +++ b/vm/os-genunix.hpp @@ -4,8 +4,6 @@ namespace factor #define VM_C_API extern "C" #define NULL_DLL NULL -void c_to_factor_toplevel(cell quot); -void init_signals(); void early_init(); const char *vm_executable_path(); const char *default_image_path(); diff --git a/vm/os-macosx.hpp b/vm/os-macosx.hpp index 93f6574367..8428f56998 100644 --- a/vm/os-macosx.hpp +++ b/vm/os-macosx.hpp @@ -5,14 +5,11 @@ namespace factor #define FACTOR_OS_STRING "macosx" #define NULL_DLL "libfactor.dylib" -void init_signals(); void early_init(); const char *vm_executable_path(); const char *default_image_path(); -void c_to_factor_toplevel(cell quot); - #define UAP_STACK_POINTER(ucontext) (((ucontext_t *)ucontext)->uc_stack.ss_sp) #define UAP_STACK_POINTER_TYPE void* diff --git a/vm/os-macosx.mm b/vm/os-macosx.mm index 92694a4599..4a6a3cb2b4 100644 --- a/vm/os-macosx.mm +++ b/vm/os-macosx.mm @@ -70,7 +70,7 @@ const char *default_image_path(void) return [returnVal UTF8String]; } -void init_signals(void) +void factor_vm::init_signals(void) { unix_init_signals(); mach_initialize(); @@ -87,11 +87,9 @@ Protocol *objc_getProtocol(char *name) u64 nano_count() { - u64 t; + u64 t = mach_absolute_time(); mach_timebase_info_data_t info; - kern_return_t ret; - t = mach_absolute_time(); - ret = mach_timebase_info(&info); + kern_return_t ret = mach_timebase_info(&info); if(ret != 0) fatal_error("mach_timebase_info failed",ret); return t * (info.numer/info.denom); diff --git a/vm/os-unix.cpp b/vm/os-unix.cpp index 8aa100aa01..7e88cedb0e 100644 --- a/vm/os-unix.cpp +++ b/vm/os-unix.cpp @@ -13,7 +13,7 @@ THREADHANDLE start_thread(void *(*start_routine)(void *),void *args) fatal_error("pthread_attr_setdetachstate() failed",0); if (pthread_create (&thread, &attr, start_routine, args) != 0) fatal_error("pthread_create() failed",0); - pthread_attr_destroy (&attr); + pthread_attr_destroy(&attr); return thread; } @@ -21,9 +21,8 @@ pthread_key_t current_vm_tls_key = 0; void init_platform_globals() { - if (pthread_key_create(¤t_vm_tls_key, NULL) != 0) + if(pthread_key_create(¤t_vm_tls_key, NULL) != 0) fatal_error("pthread_key_create() failed",0); - } void register_vm_with_thread(factor_vm *vm) @@ -187,8 +186,18 @@ static void sigaction_safe(int signum, const struct sigaction *act, struct sigac fatal_error("sigaction failed", 0); } -void unix_init_signals() +void factor_vm::unix_init_signals() { + signal_callstack_seg = new segment(callstack_size,false); + + stack_t signal_callstack; + signal_callstack.ss_sp = (void *)signal_callstack_seg->start; + signal_callstack.ss_size = signal_callstack_seg->size; + signal_callstack.ss_flags = 0; + + if(sigaltstack(&signal_callstack,(stack_t *)NULL) < 0) + fatal_error("sigaltstack() failed",0); + struct sigaction memory_sigaction; struct sigaction misc_sigaction; struct sigaction fpe_sigaction; @@ -197,7 +206,7 @@ void unix_init_signals() memset(&memory_sigaction,0,sizeof(struct sigaction)); sigemptyset(&memory_sigaction.sa_mask); memory_sigaction.sa_sigaction = memory_signal_handler; - memory_sigaction.sa_flags = SA_SIGINFO; + memory_sigaction.sa_flags = SA_SIGINFO | SA_ONSTACK; sigaction_safe(SIGBUS,&memory_sigaction,NULL); sigaction_safe(SIGSEGV,&memory_sigaction,NULL); @@ -205,14 +214,14 @@ void unix_init_signals() memset(&fpe_sigaction,0,sizeof(struct sigaction)); sigemptyset(&fpe_sigaction.sa_mask); fpe_sigaction.sa_sigaction = fpe_signal_handler; - fpe_sigaction.sa_flags = SA_SIGINFO; + fpe_sigaction.sa_flags = SA_SIGINFO | SA_ONSTACK; sigaction_safe(SIGFPE,&fpe_sigaction,NULL); memset(&misc_sigaction,0,sizeof(struct sigaction)); sigemptyset(&misc_sigaction.sa_mask); misc_sigaction.sa_sigaction = misc_signal_handler; - misc_sigaction.sa_flags = SA_SIGINFO; + misc_sigaction.sa_flags = SA_SIGINFO | SA_ONSTACK; sigaction_safe(SIGQUIT,&misc_sigaction,NULL); sigaction_safe(SIGILL,&misc_sigaction,NULL); diff --git a/vm/os-unix.hpp b/vm/os-unix.hpp index de60bbe15f..df6e0b4b3e 100644 --- a/vm/os-unix.hpp +++ b/vm/os-unix.hpp @@ -39,7 +39,6 @@ typedef pthread_t THREADHANDLE; THREADHANDLE start_thread(void *(*start_routine)(void *),void *args); inline static THREADHANDLE thread_id() { return pthread_self(); } -void unix_init_signals(); void signal_handler(int signal, siginfo_t* siginfo, void* uap); void dump_stack_signal(int signal, siginfo_t* siginfo, void* uap); diff --git a/vm/os-windows.cpp b/vm/os-windows.cpp index d69966567a..1ff1b174b5 100755 --- a/vm/os-windows.cpp +++ b/vm/os-windows.cpp @@ -143,4 +143,6 @@ void factor_vm::move_file(const vm_char *path1, const vm_char *path2) general_error(ERROR_IO,tag_fixnum(GetLastError()),false_object); } +void factor_vm::init_signals() {} + } diff --git a/vm/os-windows.hpp b/vm/os-windows.hpp index 92a3c73a99..020a506038 100755 --- a/vm/os-windows.hpp +++ b/vm/os-windows.hpp @@ -43,7 +43,6 @@ typedef wchar_t vm_char; /* Difference between Jan 1 00:00:00 1601 and Jan 1 00:00:00 1970 */ #define EPOCH_OFFSET 0x019db1ded53e8000LL -inline static void init_signals() {} inline static void early_init() {} u64 system_micros(); diff --git a/vm/vm.cpp b/vm/vm.cpp index 87bf47f290..e9ade19cc6 100755 --- a/vm/vm.cpp +++ b/vm/vm.cpp @@ -13,7 +13,8 @@ factor_vm::factor_vm() : gc_events(NULL), fep_disabled(false), full_output(false), - last_nano_count(0) + last_nano_count(0), + signal_callstack_seg(NULL) { primitive_reset_dispatch_stats(); } @@ -21,6 +22,11 @@ factor_vm::factor_vm() : factor_vm::~factor_vm() { delete_contexts(); + if(signal_callstack_seg) + { + delete signal_callstack_seg; + signal_callstack_seg = NULL; + } } } diff --git a/vm/vm.hpp b/vm/vm.hpp index 7a0b0fcd33..4402b64f41 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -107,6 +107,9 @@ struct factor_vm decrease */ u64 last_nano_count; + /* Stack for signal handlers, only used on Unix */ + segment *signal_callstack_seg; + // contexts context *new_context(); void delete_context(context *old_context); @@ -339,7 +342,7 @@ struct factor_vm template bool reallot_array_in_place_p(Array *array, cell capacity); template Array *reallot_array(Array *array_, cell capacity); - //debug + // debug void print_chars(string* str); void print_word(word* word, cell nesting); void print_factor_string(string* str); @@ -362,7 +365,7 @@ struct factor_vm void factorbug(); void primitive_die(); - //arrays + // arrays inline void set_array_nth(array *array, cell slot, cell value); array *allot_array(cell capacity, cell fill_); void primitive_array(); @@ -372,7 +375,7 @@ struct factor_vm void primitive_resize_array(); cell std_vector_to_array(std::vector &elements); - //strings + // strings cell string_nth(const string *str, cell index); void set_string_nth_fast(string *str, cell index, cell ch); void set_string_nth_slow(string *str_, cell index, cell ch); @@ -388,13 +391,13 @@ struct factor_vm void primitive_set_string_nth_fast(); void primitive_set_string_nth_slow(); - //booleans + // booleans cell tag_boolean(cell untagged) { return (untagged ? true_object : false_object); } - //byte arrays + // byte arrays byte_array *allot_byte_array(cell size); void primitive_byte_array(); void primitive_uninitialized_byte_array(); @@ -402,11 +405,11 @@ struct factor_vm template byte_array *byte_array_from_value(Type *value); - //tuples + // tuples void primitive_tuple(); void primitive_tuple_boa(); - //words + // words word *allot_word(cell name_, cell vocab_, cell hashcode_); void primitive_word(); void primitive_word_code(); @@ -417,7 +420,7 @@ struct factor_vm cell find_all_words(); void compile_all_words(); - //math + // math void primitive_bignum_to_fixnum(); void primitive_float_to_fixnum(); void primitive_fixnum_divint(); @@ -503,7 +506,7 @@ struct factor_vm // tagged template Type *untag_check(cell value); - //io + // io void init_c_io(); void io_error(); FILE* safe_fopen(char *filename, char *mode); @@ -526,7 +529,7 @@ struct factor_vm void primitive_fflush(); void primitive_fclose(); - //code_block + // code_block cell compute_entry_point_address(cell obj); cell compute_entry_point_pic_address(word *w, cell tagged_quot); cell compute_entry_point_pic_address(cell w_); @@ -563,11 +566,11 @@ struct factor_vm cell code_blocks(); void primitive_code_blocks(); - //callbacks + // callbacks void init_callbacks(cell size); void primitive_callback(); - //image + // image void init_objects(image_header *h); void load_data_heap(FILE *file, image_header *h, vm_parameters *p); void load_code_heap(FILE *file, image_header *h, vm_parameters *p); @@ -578,7 +581,7 @@ struct factor_vm void fixup_code(cell data_offset, cell code_offset); void load_image(vm_parameters *p); - //callstack + // callstack template void iterate_callstack_object(callstack *stack_, Iterator &iterator); void check_frame(stack_frame *frame); callstack *allot_callstack(cell size); @@ -598,7 +601,7 @@ struct factor_vm void primitive_set_innermost_stack_frame_quot(); template void iterate_callstack(context *ctx, Iterator &iterator); - //alien + // alien char *pinned_alien_offset(cell obj); cell allot_alien(cell delegate_, cell displacement); cell allot_alien(void *address); @@ -615,7 +618,7 @@ struct factor_vm cell from_small_struct(cell x, cell y, cell size); cell from_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size); - //quotations + // quotations void primitive_jit_compile(); code_block *lazy_jit_compile_block(); void primitive_array_to_quotation(); @@ -630,7 +633,7 @@ struct factor_vm cell find_all_quotations(); void initialize_all_quotations(); - //dispatch + // dispatch cell search_lookup_alist(cell table, cell klass); cell search_lookup_hash(cell table, cell klass, cell hashcode); cell nth_superclass(tuple_layout *layout, fixnum echelon); @@ -645,7 +648,7 @@ struct factor_vm void primitive_reset_dispatch_stats(); void primitive_dispatch_stats(); - //inline cache + // inline cache void init_inline_caching(int max_size); void deallocate_inline_cache(cell return_address); cell determine_inline_cache_type(array *cache_entries); @@ -657,11 +660,11 @@ struct factor_vm void update_pic_transitions(cell pic_size); void *inline_cache_miss(cell return_address); - //entry points + // entry points void c_to_factor(cell quot); void unwind_native_frames(cell quot, stack_frame *to); - //factor + // factor void default_parameters(vm_parameters *p); bool factor_arg(const vm_char *str, const vm_char *arg, cell *value); void init_parameters_from_args(vm_parameters *p, int argc, vm_char **argv); @@ -685,6 +688,7 @@ struct factor_vm void *ffi_dlsym(dll *dll, symbol_char *symbol); void ffi_dlclose(dll *dll); void c_to_factor_toplevel(cell quot); + void init_signals(); // os-windows #if defined(WINDOWS) @@ -697,8 +701,10 @@ struct factor_vm void open_console(); LONG exception_handler(PEXCEPTION_POINTERS pe); #endif + #else // UNIX void dispatch_signal(void *uap, void (handler)()); + void unix_init_signals(); #endif #ifdef __APPLE__ @@ -707,7 +713,6 @@ struct factor_vm factor_vm(); ~factor_vm(); - }; extern std::map thread_vms; From 51c7e1e1e64b123acebc4a70c8b8537d6acdf13d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 28 Mar 2010 12:33:41 -0400 Subject: [PATCH 484/713] threads: fix thread-local variables --- basis/threads/threads-tests.factor | 16 ++++++++++++++++ basis/threads/threads.factor | 7 ++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/basis/threads/threads-tests.factor b/basis/threads/threads-tests.factor index 6e573ccd88..742ecaa1f7 100644 --- a/basis/threads/threads-tests.factor +++ b/basis/threads/threads-tests.factor @@ -40,3 +40,19 @@ yield [ "a" [ 1 1 + ] spawn 100 sleep ] must-fail [ ] [ 0.1 seconds sleep ] unit-test + +! Test thread-local variables + "p" set + +5 "x" tset + +[ 5 ] [ "x" tget ] unit-test + +[ ] [ "x" [ 1 + ] tchange ] unit-test + +[ 6 ] [ "x" tget ] unit-test + +! Are they truly thread-local? +[ "x" tget "p" get fulfill ] in-thread + +[ f ] [ "p" get ?promise ] unit-test diff --git a/basis/threads/threads.factor b/basis/threads/threads.factor index 09869924f4..89a90f87fd 100644 --- a/basis/threads/threads.factor +++ b/basis/threads/threads.factor @@ -36,10 +36,10 @@ sleep-entry ; ! Thread-local storage : tnamespace ( -- assoc ) - self variables>> [ H{ } clone dup self (>>variables) ] unless* ; + self variables>> ; inline : tget ( key -- value ) - self variables>> at ; + tnamespace at ; : tset ( value key -- ) tnamespace set-at ; @@ -83,7 +83,8 @@ PRIVATE> swap >>name swap >>quot \ thread counter >>id - >>continuation ; inline + >>continuation + H{ } clone >>variables ; inline : ( quot name -- thread ) \ thread new-thread ; From 84c01e1ab3b94c96af10606500ace00ebef499f7 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 28 Mar 2010 12:52:16 -0400 Subject: [PATCH 485/713] vm: fix compilation on FreeBSD --- vm/os-unix.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vm/os-unix.cpp b/vm/os-unix.cpp index 7e88cedb0e..78a487d9b6 100644 --- a/vm/os-unix.cpp +++ b/vm/os-unix.cpp @@ -98,9 +98,12 @@ void factor_vm::primitive_existsp() void factor_vm::move_file(const vm_char *path1, const vm_char *path2) { int ret = 0; - do { + do + { ret = rename((path1),(path2)); - } while(ret < 0 && errno == EINTR); + } + while(ret < 0 && errno == EINTR); + if(ret < 0) general_error(ERROR_IO,tag_fixnum(errno),false_object); } @@ -191,7 +194,7 @@ void factor_vm::unix_init_signals() signal_callstack_seg = new segment(callstack_size,false); stack_t signal_callstack; - signal_callstack.ss_sp = (void *)signal_callstack_seg->start; + signal_callstack.ss_sp = (char *)signal_callstack_seg->start; signal_callstack.ss_size = signal_callstack_seg->size; signal_callstack.ss_flags = 0; From bddbcd24cd67c3a2276e1ea4e3443a95c25dd21d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 28 Mar 2010 12:53:01 -0400 Subject: [PATCH 486/713] vm: fix OpenBSD compilation --- vm/os-openbsd.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/os-openbsd.hpp b/vm/os-openbsd.hpp index 6a81a26be2..b3b47c08b3 100644 --- a/vm/os-openbsd.hpp +++ b/vm/os-openbsd.hpp @@ -1 +1 @@ -#define UAP_STACK_POINTER_TYPE __greg_t +#define UAP_STACK_POINTER_TYPE __register_t From 46ec4ff093f176d51af7dbb0723a2ae5ef28a6ba Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 28 Mar 2010 17:57:47 -0500 Subject: [PATCH 487/713] vm: fix SEH on Windows --- vm/os-windows-nt.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/vm/os-windows-nt.cpp b/vm/os-windows-nt.cpp index e063fe3db3..54ee78f977 100755 --- a/vm/os-windows-nt.cpp +++ b/vm/os-windows-nt.cpp @@ -75,11 +75,7 @@ LONG factor_vm::exception_handler(PEXCEPTION_POINTERS pe) CONTEXT *c = (CONTEXT*)pe->ContextRecord; c->ESP = (cell)fix_callstack_top((stack_frame *)c->ESP); - - if(in_code_heap_p(c->EIP)) - signal_callstack_top = (stack_frame *)c->ESP; - else - signal_callstack_top = NULL; + signal_callstack_top = (stack_frame *)c->ESP; switch (e->ExceptionCode) { From 43ac59a9f44978e4f6913793af3d6bbded34b508 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 28 Mar 2010 17:58:05 -0500 Subject: [PATCH 488/713] kernel: don't test callstack overflow on OpenBSD or Windows --- core/kernel/kernel-tests.factor | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/kernel/kernel-tests.factor b/core/kernel/kernel-tests.factor index bf16d9439f..152e1bac14 100644 --- a/core/kernel/kernel-tests.factor +++ b/core/kernel/kernel-tests.factor @@ -1,7 +1,8 @@ USING: arrays byte-arrays kernel kernel.private math memory namespaces sequences tools.test math.private quotations continuations prettyprint io.streams.string debugger assocs -sequences.private accessors locals.backend grouping words ; +sequences.private accessors locals.backend grouping words +system ; IN: kernel.tests [ 0 ] [ f size ] unit-test @@ -48,7 +49,9 @@ IN: kernel.tests : overflow-c ( -- ) overflow-c overflow-c ; -[ overflow-c ] [ { "kernel-error" 14 f f } = ] must-fail-with +os [ windows? ] [ openbsd? ] bi or [ + [ overflow-c ] [ { "kernel-error" 14 f f } = ] must-fail-with +] unless [ -7 ] must-fail From b40382f412e36cb5b94eddd2b6f0c774d481652d Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 28 Mar 2010 18:26:39 -0500 Subject: [PATCH 489/713] vm: don't use sigaltstack() on OpenBSD because OpenBSD sucks --- vm/os-unix.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vm/os-unix.cpp b/vm/os-unix.cpp index 78a487d9b6..a724007b1a 100644 --- a/vm/os-unix.cpp +++ b/vm/os-unix.cpp @@ -191,6 +191,10 @@ static void sigaction_safe(int signum, const struct sigaction *act, struct sigac void factor_vm::unix_init_signals() { + /* OpenBSD doesn't support sigaltstack() if we link against + libpthread. See http://redmine.ruby-lang.org/issues/show/1239 */ + +#ifndef __OpenBSD__ signal_callstack_seg = new segment(callstack_size,false); stack_t signal_callstack; @@ -200,6 +204,7 @@ void factor_vm::unix_init_signals() if(sigaltstack(&signal_callstack,(stack_t *)NULL) < 0) fatal_error("sigaltstack() failed",0); +#endif struct sigaction memory_sigaction; struct sigaction misc_sigaction; From 676d4e4c832e1e6860dfcef079b1bdba0e61e6e7 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 28 Mar 2010 18:31:11 -0700 Subject: [PATCH 490/713] someone screwed up the kernel-error codes in debugger --- basis/debugger/debugger.factor | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index d10fd4f73a..8f448ff237 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -155,10 +155,10 @@ PREDICATE: vm-error < array { 11 [ datastack-overflow. ] } { 12 [ retainstack-underflow. ] } { 13 [ retainstack-overflow. ] } - { 13 [ callstack-underflow. ] } - { 14 [ callstack-overflow. ] } - { 15 [ memory-error. ] } - { 16 [ fp-trap-error. ] } + { 14 [ callstack-underflow. ] } + { 15 [ callstack-overflow. ] } + { 16 [ memory-error. ] } + { 17 [ fp-trap-error. ] } } ; inline M: vm-error summary drop "VM error" ; From f60bdb4cb1536c279b5a98dead8459be27f97c48 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 28 Mar 2010 19:26:24 -0700 Subject: [PATCH 491/713] remove old, unused 'vars' vocab --- extra/vars/authors.txt | 1 - extra/vars/summary.txt | 1 - extra/vars/tags.txt | 1 - extra/vars/vars.factor | 31 ------------------------------- 4 files changed, 34 deletions(-) delete mode 100644 extra/vars/authors.txt delete mode 100644 extra/vars/summary.txt delete mode 100644 extra/vars/tags.txt delete mode 100644 extra/vars/vars.factor diff --git a/extra/vars/authors.txt b/extra/vars/authors.txt deleted file mode 100644 index 6cfd5da273..0000000000 --- a/extra/vars/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/extra/vars/summary.txt b/extra/vars/summary.txt deleted file mode 100644 index 9f5f717b99..0000000000 --- a/extra/vars/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Shorthand notation for variables diff --git a/extra/vars/tags.txt b/extra/vars/tags.txt deleted file mode 100644 index f4274299b1..0000000000 --- a/extra/vars/tags.txt +++ /dev/null @@ -1 +0,0 @@ -extensions diff --git a/extra/vars/vars.factor b/extra/vars/vars.factor deleted file mode 100644 index 990b0307d0..0000000000 --- a/extra/vars/vars.factor +++ /dev/null @@ -1,31 +0,0 @@ -! Copyright (C) 2005, 2006 Eduardo Cavazos - -! Thanks to Mackenzie Straight for the idea - -USING: accessors kernel parser lexer words words.symbol -namespaces sequences quotations ; - -IN: vars - -: define-var-getter ( word -- ) - [ name>> ">" append create-in ] [ [ get ] curry ] bi - (( -- value )) define-declared ; - -: define-var-setter ( word -- ) - [ name>> ">" prepend create-in ] [ [ set ] curry ] bi - (( value -- )) define-declared ; - -: define-var ( str -- ) - create-in - [ define-symbol ] - [ define-var-getter ] - [ define-var-setter ] tri ; - -SYNTAX: VAR: ! var - scan define-var ; - -: define-vars ( seq -- ) - [ define-var ] each ; - -SYNTAX: VARS: ! vars ... - ";" [ define-var ] each-token ; From 5f31860f18f8ac9e8054ff00e6083f2a6b5506b6 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 28 Mar 2010 19:27:34 -0700 Subject: [PATCH 492/713] "variables" vocab with uniform-access global, dynamic, and local vars --- extra/variables/variables.factor | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 extra/variables/variables.factor diff --git a/extra/variables/variables.factor b/extra/variables/variables.factor new file mode 100644 index 0000000000..5b7186e155 --- /dev/null +++ b/extra/variables/variables.factor @@ -0,0 +1,60 @@ +! (c)2010 Joe Groff bsd license +USING: accessors definitions fry kernel locals.types namespaces parser +see sequences words ; +FROM: help.markup.private => link-effect? ; +IN: variables + +PREDICATE: variable < word + "variable-setter" word-prop ; + +GENERIC: variable-setter ( word -- word' ) + +M: variable variable-setter "variable-setter" word-prop ; +M: local-reader variable-setter "local-writer" word-prop ; + +SYNTAX: set: + scan-object variable-setter suffix! ; + +: [variable-getter] ( variable -- quot ) + '[ _ get ] ; +: [variable-setter] ( variable -- quot ) + '[ _ set ] ; + +: (define-variable) ( word getter setter -- ) + [ (( -- value )) define-inline ] + [ + [ + [ name>> "set: " prepend ] + [ over "variable-setter" set-word-prop ] bi + ] dip (( value -- )) define-inline + ] bi-curry* bi ; + +: define-variable ( word -- ) + dup [ [variable-getter] ] [ [variable-setter] ] bi (define-variable) ; + +SYNTAX: VAR: + CREATE-WORD define-variable ; + +M: variable definer drop \ VAR: f ; +M: variable definition drop f ; +M: variable link-effect? drop f ; +M: variable print-stack-effect? drop f ; + +TUPLE: global-box value ; + +PREDICATE: global-variable < variable + "variable-setter" word-prop def>> first global-box? ; + +: [global-getter] ( box -- quot ) + '[ _ value>> ] ; +: [global-setter] ( box -- quot ) + '[ _ (>>value) ] ; + +: define-global ( word -- ) + global-box new [ [global-getter] ] [ [global-setter] ] bi (define-variable) ; + +SYNTAX: GLOBAL: + CREATE-WORD define-global ; + +M: global-variable definer drop \ GLOBAL: f ; + From 0a9d1b03a16b5284a5439034cadde48b2aef2ed4 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 28 Mar 2010 21:25:49 -0700 Subject: [PATCH 493/713] variables: typed vars, globals --- extra/variables/variables.factor | 44 +++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/extra/variables/variables.factor b/extra/variables/variables.factor index 5b7186e155..705e1f1945 100644 --- a/extra/variables/variables.factor +++ b/extra/variables/variables.factor @@ -1,6 +1,8 @@ ! (c)2010 Joe Groff bsd license -USING: accessors definitions fry kernel locals.types namespaces parser -see sequences words ; +USING: accessors arrays combinators definitions fry kernel +locals.types namespaces parser quotations see sequences slots +words ; +FROM: kernel.private => declare ; FROM: help.markup.private => link-effect? ; IN: variables @@ -40,10 +42,32 @@ M: variable definition drop f ; M: variable link-effect? drop f ; M: variable print-stack-effect? drop f ; +PREDICATE: typed-variable < variable + "variable-type" word-prop ; + +: [typed-getter] ( quot type -- quot ) + 1array '[ @ _ declare ] ; +: [typed-setter] ( quot type -- quot ) + instance-check-quot prepose ; + +: define-typed-variable ( word type -- ) + dupd { + [ [ [variable-getter] ] dip [typed-getter] ] + [ [ [variable-setter] ] dip [typed-setter] ] + [ "variable-type" set-word-prop ] + [ initial-value swap set-global ] + } 2cleave (define-variable) ; + +SYNTAX: TYPED-VAR: + CREATE-WORD scan-object define-typed-variable ; + +M: typed-variable definer drop \ TYPED-VAR: f ; +M: typed-variable definition "variable-type" word-prop 1quotation ; + TUPLE: global-box value ; PREDICATE: global-variable < variable - "variable-setter" word-prop def>> first global-box? ; + def>> first global-box? ; : [global-getter] ( box -- quot ) '[ _ value>> ] ; @@ -58,3 +82,17 @@ SYNTAX: GLOBAL: M: global-variable definer drop \ GLOBAL: f ; +INTERSECTION: typed-global-variable + global-variable typed-variable ; + +: define-typed-global ( word type -- ) + 2dup "variable-type" set-word-prop + dup initial-value global-box boa swap + [ [ [global-getter] ] dip [typed-getter] ] + [ [ [global-setter] ] dip [typed-setter] ] 2bi (define-variable) ; + +SYNTAX: TYPED-GLOBAL: + CREATE-WORD scan-object define-typed-global ; + +M: typed-global-variable definer drop \ TYPED-GLOBAL: f ; + From 8ab0d12e8defc2b1c80db0e2481b2ca2acf71f17 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 29 Mar 2010 01:53:20 -0400 Subject: [PATCH 494/713] vm: callstack errors were flipped --- core/kernel/kernel-tests.factor | 5 ++++- vm/errors.cpp | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/kernel/kernel-tests.factor b/core/kernel/kernel-tests.factor index 152e1bac14..7d5f7b538b 100644 --- a/core/kernel/kernel-tests.factor +++ b/core/kernel/kernel-tests.factor @@ -49,8 +49,11 @@ IN: kernel.tests : overflow-c ( -- ) overflow-c overflow-c ; +! The VM cannot recover from callstack overflow on Windows or +! OpenBSD, because no facility exists to run memory protection +! fault handlers on an alternate callstack. os [ windows? ] [ openbsd? ] bi or [ - [ overflow-c ] [ { "kernel-error" 14 f f } = ] must-fail-with + [ overflow-c ] [ { "kernel-error" 15 f f } = ] must-fail-with ] unless [ -7 ] must-fail diff --git a/vm/errors.cpp b/vm/errors.cpp index 21dff5a475..f6ceee9966 100755 --- a/vm/errors.cpp +++ b/vm/errors.cpp @@ -98,9 +98,9 @@ void factor_vm::memory_protection_error(cell addr, stack_frame *stack) else if(ctx->retainstack_seg->overflow_p(addr)) general_error(ERROR_RETAINSTACK_OVERFLOW,false_object,false_object,stack); else if(ctx->callstack_seg->underflow_p(addr)) - general_error(ERROR_CALLSTACK_UNDERFLOW,false_object,false_object,stack); - else if(ctx->callstack_seg->overflow_p(addr)) general_error(ERROR_CALLSTACK_OVERFLOW,false_object,false_object,stack); + else if(ctx->callstack_seg->overflow_p(addr)) + general_error(ERROR_CALLSTACK_UNDERFLOW,false_object,false_object,stack); else general_error(ERROR_MEMORY,allot_cell(addr),false_object,stack); } From 43b2e02534f4e4d28e2ccc34dba1a7a4c5324b8a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 29 Mar 2010 02:23:21 -0400 Subject: [PATCH 495/713] vm: split up TLS code and add a dummy implementation for a dummy OS known as NetBSD --- GNUmakefile | 1 + Nmakefile | 2 ++ vm/Config.freebsd | 2 +- vm/Config.linux | 2 +- vm/Config.macosx | 2 +- vm/Config.netbsd | 2 +- vm/Config.openbsd | 2 +- vm/Config.windows.nt | 2 +- vm/factor.cpp | 27 +-------------------------- vm/factor.hpp | 2 +- vm/master.hpp | 1 + vm/mvm-none.cpp | 28 ++++++++++++++++++++++++++++ vm/mvm-unix.cpp | 26 ++++++++++++++++++++++++++ vm/mvm-windows-nt.cpp | 27 +++++++++++++++++++++++++++ vm/mvm.cpp | 29 +++++++++++++++++++++++++++++ vm/mvm.hpp | 12 ++++++++++++ vm/os-unix.cpp | 20 -------------------- vm/os-unix.hpp | 5 ----- vm/os-windows-nt.cpp | 21 --------------------- vm/os-windows-nt.hpp | 4 ---- vm/vm.hpp | 2 -- 21 files changed, 134 insertions(+), 85 deletions(-) create mode 100644 vm/mvm-none.cpp create mode 100644 vm/mvm-unix.cpp create mode 100644 vm/mvm-windows-nt.cpp create mode 100644 vm/mvm.cpp create mode 100644 vm/mvm.hpp diff --git a/GNUmakefile b/GNUmakefile index eac1c696df..12ca388f87 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -52,6 +52,7 @@ ifdef CONFIG vm/io.o \ vm/jit.o \ vm/math.o \ + vm/mvm.o \ vm/nursery_collector.o \ vm/object_start_map.o \ vm/objects.o \ diff --git a/Nmakefile b/Nmakefile index 7349deae23..a73a59d0f5 100755 --- a/Nmakefile +++ b/Nmakefile @@ -38,6 +38,8 @@ DLL_OBJS = vm\os-windows-nt.obj \ vm\io.obj \ vm\jit.obj \ vm\math.obj \ + vm\mvm.obj \ + vm\mvm-windows-nt.obj \ vm\nursery_collector.obj \ vm\object_start_map.obj \ vm\objects.obj \ diff --git a/vm/Config.freebsd b/vm/Config.freebsd index a0dbe228e5..4dc56cfaed 100644 --- a/vm/Config.freebsd +++ b/vm/Config.freebsd @@ -1,4 +1,4 @@ include vm/Config.unix -PLAF_DLL_OBJS += vm/os-genunix.o vm/os-freebsd.o +PLAF_DLL_OBJS += vm/os-genunix.o vm/os-freebsd.o vm/mvm-unix.o CFLAGS += -export-dynamic LIBS = -L/usr/local/lib/ -lm -lrt $(X11_UI_LIBS) diff --git a/vm/Config.linux b/vm/Config.linux index 4a859b1216..00ff73522a 100644 --- a/vm/Config.linux +++ b/vm/Config.linux @@ -1,4 +1,4 @@ include vm/Config.unix -PLAF_DLL_OBJS += vm/os-genunix.o vm/os-linux.o +PLAF_DLL_OBJS += vm/os-genunix.o vm/os-linux.o vm/mvm-unix.o CFLAGS += -export-dynamic LIBS = -ldl -lm -lrt -lpthread $(X11_UI_LIBS) diff --git a/vm/Config.macosx b/vm/Config.macosx index 89fe239668..5b9de7f5cf 100644 --- a/vm/Config.macosx +++ b/vm/Config.macosx @@ -1,7 +1,7 @@ include vm/Config.unix CFLAGS += -fPIC -PLAF_DLL_OBJS += vm/os-macosx.o vm/mach_signal.o +PLAF_DLL_OBJS += vm/os-macosx.o vm/mach_signal.o vm/mvm-unix.o DLL_EXTENSION = .dylib SHARED_DLL_EXTENSION = .dylib diff --git a/vm/Config.netbsd b/vm/Config.netbsd index 72a4056c90..2838f9d4c5 100644 --- a/vm/Config.netbsd +++ b/vm/Config.netbsd @@ -1,5 +1,5 @@ include vm/Config.unix -PLAF_DLL_OBJS += vm/os-genunix.o vm/os-netbsd.o +PLAF_DLL_OBJS += vm/os-genunix.o vm/os-netbsd.o vm/mvm-none.o CFLAGS += -export-dynamic LIBPATH = -L/usr/X11R7/lib -Wl,-rpath,/usr/X11R7/lib -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib LIBS = -lm -lrt -lssl -lcrypto $(X11_UI_LIBS) diff --git a/vm/Config.openbsd b/vm/Config.openbsd index c7d2672e6b..6983223b74 100644 --- a/vm/Config.openbsd +++ b/vm/Config.openbsd @@ -1,5 +1,5 @@ include vm/Config.unix -PLAF_DLL_OBJS += vm/os-genunix.o vm/os-openbsd.o +PLAF_DLL_OBJS += vm/os-genunix.o vm/os-openbsd.o vm/mvm-unix.o CC = egcc CPP = eg++ CFLAGS += -export-dynamic -fno-inline-functions diff --git a/vm/Config.windows.nt b/vm/Config.windows.nt index ffaa899fe1..322649dc06 100644 --- a/vm/Config.windows.nt +++ b/vm/Config.windows.nt @@ -1,7 +1,7 @@ LIBS = -lm EXE_SUFFIX= DLL_SUFFIX= -PLAF_DLL_OBJS += vm/os-windows-nt.o +PLAF_DLL_OBJS += vm/os-windows-nt.o vm/mvm-windows-nt.o PLAF_EXE_OBJS += vm/resources.o PLAF_EXE_OBJS += vm/main-windows-nt.o CFLAGS += -mwindows diff --git a/vm/factor.cpp b/vm/factor.cpp index c33db440a0..e726ebf6da 100755 --- a/vm/factor.cpp +++ b/vm/factor.cpp @@ -3,11 +3,9 @@ namespace factor { -std::map thread_vms; - void init_globals() { - init_platform_globals(); + init_mvm(); } void factor_vm::default_parameters(vm_parameters *p) @@ -205,11 +203,6 @@ void factor_vm::start_standalone_factor(int argc, vm_char **argv) start_factor(&p); } -struct startargs { - int argc; - vm_char **argv; -}; - factor_vm *new_factor_vm() { factor_vm *newvm = new factor_vm(); @@ -219,28 +212,10 @@ factor_vm *new_factor_vm() return newvm; } -// arg must be new'ed because we're going to delete it! -void *start_standalone_factor_thread(void *arg) -{ - factor_vm *newvm = new_factor_vm(); - startargs *args = (startargs*) arg; - int argc = args->argc; vm_char **argv = args->argv; - delete args; - newvm->start_standalone_factor(argc, argv); - return 0; -} - VM_C_API void start_standalone_factor(int argc, vm_char **argv) { factor_vm *newvm = new_factor_vm(); return newvm->start_standalone_factor(argc,argv); } -VM_C_API THREADHANDLE start_standalone_factor_in_new_thread(int argc, vm_char **argv) -{ - startargs *args = new startargs; - args->argc = argc; args->argv = argv; - return start_thread(start_standalone_factor_thread,args); -} - } diff --git a/vm/factor.hpp b/vm/factor.hpp index cec59bcc5c..f2dd6af0bf 100755 --- a/vm/factor.hpp +++ b/vm/factor.hpp @@ -2,7 +2,7 @@ namespace factor { VM_C_API void init_globals(); +factor_vm *new_factor_vm(); VM_C_API void start_standalone_factor(int argc, vm_char **argv); -VM_C_API THREADHANDLE start_standalone_factor_in_new_thread(int argc, vm_char **argv); } diff --git a/vm/master.hpp b/vm/master.hpp index dca3d7473c..9879fa607a 100755 --- a/vm/master.hpp +++ b/vm/master.hpp @@ -132,6 +132,7 @@ namespace factor #include "jit.hpp" #include "quotations.hpp" #include "inline_cache.hpp" +#include "mvm.hpp" #include "factor.hpp" #include "utilities.hpp" diff --git a/vm/mvm-none.cpp b/vm/mvm-none.cpp new file mode 100644 index 0000000000..ab1b53a4b5 --- /dev/null +++ b/vm/mvm-none.cpp @@ -0,0 +1,28 @@ +#include "master.hpp" + +/* Multi-VM threading is not supported on NetBSD due to +http://gnats.netbsd.org/25563 */ + +namespace factor +{ + +factor_vm *global_vm; + +void init_mvm() +{ + global_vm = NULL; +} + +void register_vm_with_thread(factor_vm *vm) +{ + assert(!global_vm); + global_vm = vm; +} + +factor_vm *current_vm() +{ + assert(global_vm != NULL); + return global_vm; +} + +} diff --git a/vm/mvm-unix.cpp b/vm/mvm-unix.cpp new file mode 100644 index 0000000000..110e73f8af --- /dev/null +++ b/vm/mvm-unix.cpp @@ -0,0 +1,26 @@ +#include "master.hpp" + +namespace factor +{ + +pthread_key_t current_vm_tls_key = 0; + +void init_mvm() +{ + if(pthread_key_create(¤t_vm_tls_key, NULL) != 0) + fatal_error("pthread_key_create() failed",0); +} + +void register_vm_with_thread(factor_vm *vm) +{ + pthread_setspecific(current_vm_tls_key,vm); +} + +factor_vm *current_vm() +{ + factor_vm *vm = (factor_vm*)pthread_getspecific(current_vm_tls_key); + assert(vm != NULL); + return vm; +} + +} diff --git a/vm/mvm-windows-nt.cpp b/vm/mvm-windows-nt.cpp new file mode 100644 index 0000000000..7cb6b826a8 --- /dev/null +++ b/vm/mvm-windows-nt.cpp @@ -0,0 +1,27 @@ +#include "master.hpp" + +namespace factor +{ + +DWORD current_vm_tls_key; + +void init_mvm() +{ + if ((current_vm_tls_key = TlsAlloc()) == TLS_OUT_OF_INDEXES) + fatal_error("TlsAlloc() failed",0); +} + +void register_vm_with_thread(factor_vm *vm) +{ + if (!TlsSetValue(current_vm_tls_key, vm)) + fatal_error("TlsSetValue() failed",0); +} + +factor_vm *current_vm() +{ + factor_vm *vm = (factor_vm *)TlsGetValue(current_vm_tls_key); + assert(vm != NULL); + return vm; +} + +} diff --git a/vm/mvm.cpp b/vm/mvm.cpp new file mode 100644 index 0000000000..dda2d66255 --- /dev/null +++ b/vm/mvm.cpp @@ -0,0 +1,29 @@ +#include "master.cpp" + +namespace factor +{ + +struct startargs { + int argc; + vm_char **argv; +}; + +// arg must be new'ed because we're going to delete it! +void *start_standalone_factor_thread(void *arg) +{ + factor_vm *newvm = new_factor_vm(); + startargs *args = (startargs*) arg; + int argc = args->argc; vm_char **argv = args->argv; + delete args; + newvm->start_standalone_factor(argc, argv); + return 0; +} + +VM_C_API THREADHANDLE start_standalone_factor_in_new_thread(int argc, vm_char **argv) +{ + startargs *args = new startargs; + args->argc = argc; args->argv = argv; + return start_thread(start_standalone_factor_thread,args); +} + +} diff --git a/vm/mvm.hpp b/vm/mvm.hpp new file mode 100644 index 0000000000..52430b7c01 --- /dev/null +++ b/vm/mvm.hpp @@ -0,0 +1,12 @@ +namespace factor +{ + +void init_mvm(); +void register_vm_with_thread(factor_vm *vm); +factor_vm *current_vm(); + +VM_C_API THREADHANDLE start_standalone_factor_in_new_thread(int argc, vm_char **argv); + +extern std::map thread_vms; + +} diff --git a/vm/os-unix.cpp b/vm/os-unix.cpp index a724007b1a..a8898eccab 100644 --- a/vm/os-unix.cpp +++ b/vm/os-unix.cpp @@ -17,26 +17,6 @@ THREADHANDLE start_thread(void *(*start_routine)(void *),void *args) return thread; } -pthread_key_t current_vm_tls_key = 0; - -void init_platform_globals() -{ - if(pthread_key_create(¤t_vm_tls_key, NULL) != 0) - fatal_error("pthread_key_create() failed",0); -} - -void register_vm_with_thread(factor_vm *vm) -{ - pthread_setspecific(current_vm_tls_key,vm); -} - -factor_vm *current_vm() -{ - factor_vm *vm = (factor_vm*)pthread_getspecific(current_vm_tls_key); - assert(vm != NULL); - return vm; -} - static void *null_dll; u64 system_micros() diff --git a/vm/os-unix.hpp b/vm/os-unix.hpp index df6e0b4b3e..3673c4e121 100644 --- a/vm/os-unix.hpp +++ b/vm/os-unix.hpp @@ -45,11 +45,6 @@ void dump_stack_signal(int signal, siginfo_t* siginfo, void* uap); u64 system_micros(); u64 nano_count(); void sleep_nanos(u64 nsec); - -void init_platform_globals(); - -void register_vm_with_thread(factor_vm *vm); -factor_vm *current_vm(); void open_console(); void move_file(const vm_char *path1, const vm_char *path2); diff --git a/vm/os-windows-nt.cpp b/vm/os-windows-nt.cpp index 54ee78f977..2d5881252a 100755 --- a/vm/os-windows-nt.cpp +++ b/vm/os-windows-nt.cpp @@ -8,27 +8,6 @@ THREADHANDLE start_thread(void *(*start_routine)(void *), void *args) return (void *)CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, args, 0, 0); } -DWORD dwTlsIndex; - -void init_platform_globals() -{ - if ((dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES) - fatal_error("TlsAlloc failed - out of indexes",0); -} - -void register_vm_with_thread(factor_vm *vm) -{ - if (! TlsSetValue(dwTlsIndex, vm)) - fatal_error("TlsSetValue failed",0); -} - -factor_vm *current_vm() -{ - factor_vm *vm = (factor_vm *)TlsGetValue(dwTlsIndex); - assert(vm != NULL); - return vm; -} - u64 system_micros() { FILETIME t; diff --git a/vm/os-windows-nt.hpp b/vm/os-windows-nt.hpp index d425a2c281..c5e721c56d 100755 --- a/vm/os-windows-nt.hpp +++ b/vm/os-windows-nt.hpp @@ -45,8 +45,4 @@ typedef HANDLE THREADHANDLE; THREADHANDLE start_thread(void *(*start_routine)(void *),void *args); inline static THREADHANDLE thread_id() { return GetCurrentThread(); } -void init_platform_globals(); -void register_vm_with_thread(factor_vm *vm); -factor_vm *current_vm(); - } diff --git a/vm/vm.hpp b/vm/vm.hpp index 4402b64f41..d304543879 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -715,6 +715,4 @@ struct factor_vm ~factor_vm(); }; -extern std::map thread_vms; - } From 946b7415e055fc802310f734d8c876dc2e881874 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 29 Mar 2010 02:27:45 -0400 Subject: [PATCH 496/713] vm: fix typos --- vm/mvm-unix.cpp | 2 +- vm/mvm-windows-nt.cpp | 4 ++-- vm/mvm.cpp | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/vm/mvm-unix.cpp b/vm/mvm-unix.cpp index 110e73f8af..adba52b122 100644 --- a/vm/mvm-unix.cpp +++ b/vm/mvm-unix.cpp @@ -3,7 +3,7 @@ namespace factor { -pthread_key_t current_vm_tls_key = 0; +pthread_key_t current_vm_tls_key; void init_mvm() { diff --git a/vm/mvm-windows-nt.cpp b/vm/mvm-windows-nt.cpp index 7cb6b826a8..92c20672aa 100644 --- a/vm/mvm-windows-nt.cpp +++ b/vm/mvm-windows-nt.cpp @@ -7,13 +7,13 @@ DWORD current_vm_tls_key; void init_mvm() { - if ((current_vm_tls_key = TlsAlloc()) == TLS_OUT_OF_INDEXES) + if((current_vm_tls_key = TlsAlloc()) == TLS_OUT_OF_INDEXES) fatal_error("TlsAlloc() failed",0); } void register_vm_with_thread(factor_vm *vm) { - if (!TlsSetValue(current_vm_tls_key, vm)) + if(!TlsSetValue(current_vm_tls_key, vm)) fatal_error("TlsSetValue() failed",0); } diff --git a/vm/mvm.cpp b/vm/mvm.cpp index dda2d66255..df5d85ef30 100644 --- a/vm/mvm.cpp +++ b/vm/mvm.cpp @@ -1,8 +1,10 @@ -#include "master.cpp" +#include "master.hpp" namespace factor { +std::map thread_vms; + struct startargs { int argc; vm_char **argv; From 99771eb689c28a0afe306131145fe693c2357c9c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 29 Mar 2010 13:14:26 -0400 Subject: [PATCH 497/713] bootstrap.compiler: fix joint dependencies declared here --- basis/bootstrap/compiler/compiler.factor | 7 ++----- basis/stack-checker/errors/errors.factor | 4 +++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/basis/bootstrap/compiler/compiler.factor b/basis/bootstrap/compiler/compiler.factor index 393e4eab27..0237ed99ee 100644 --- a/basis/bootstrap/compiler/compiler.factor +++ b/basis/bootstrap/compiler/compiler.factor @@ -20,11 +20,8 @@ IN: bootstrap.compiler "alien.remote-control" require ] unless -{ - "stack-checker.errors.prettyprint" - "alien.prettyprint" - "alien.debugger" -} [ "prettyprint" swap require-when ] each +"prettyprint" "alien.prettyprint" require-when +"debugger" "alien.debugger" require-when "cpu." cpu name>> append require diff --git a/basis/stack-checker/errors/errors.factor b/basis/stack-checker/errors/errors.factor index 58ce20035c..5eca37ffbe 100644 --- a/basis/stack-checker/errors/errors.factor +++ b/basis/stack-checker/errors/errors.factor @@ -1,5 +1,6 @@ -! Copyright (C) 2006, 2009 Slava Pestov. +! Copyright (C) 2006, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. +USING: vocabs.loader ; IN: stack-checker.errors TUPLE: inference-error ; @@ -34,3 +35,4 @@ ERROR: bad-declaration-error < inference-error declaration ; ERROR: unbalanced-branches-error < inference-error word quots declareds actuals ; +"debugger" "stack-checker.errors.prettyprint" require-when From d130f242480ac8913bf137d25015251e17313e50 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 29 Mar 2010 15:08:15 -0400 Subject: [PATCH 498/713] ui.gadgets.buttons: fix incorrect parameter order in --- basis/ui/gadgets/buttons/buttons.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/ui/gadgets/buttons/buttons.factor b/basis/ui/gadgets/buttons/buttons.factor index d0d25a0630..4a68b47f15 100644 --- a/basis/ui/gadgets/buttons/buttons.factor +++ b/basis/ui/gadgets/buttons/buttons.factor @@ -220,8 +220,8 @@ TUPLE: radio-control < button value ; M: radio-control model-changed 2dup [ value>> ] bi@ = >>selected? relayout-1 drop ; -:: ( parent model assoc quot: ( value model label -- gadget ) -- parent ) - assoc model [ parent swap quot call add-gadget ] assoc-each ; inline +:: ( model assoc parent quot: ( value model label -- gadget ) -- parent ) + parent assoc [ model swap quot call add-gadget ] assoc-each ; inline PRIVATE> From c7142e428110f29d6d02daae40397af35104c051 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 29 Mar 2010 20:40:17 -0400 Subject: [PATCH 499/713] threads: use context-switching primitives --- basis/boxes/boxes.factor | 8 +- .../known-words/known-words.factor | 637 +++++------------- basis/threads/threads-docs.factor | 14 +- basis/threads/threads.factor | 153 +++-- basis/tools/threads/threads.factor | 6 +- basis/ui/tools/listener/listener.factor | 4 +- basis/ui/tools/operations/operations.factor | 5 +- core/bootstrap/primitives.factor | 21 +- core/kernel/kernel-docs.factor | 29 +- vm/callstack.cpp | 19 +- vm/contexts.cpp | 67 +- vm/errors.cpp | 5 - vm/objects.hpp | 5 +- vm/primitives.hpp | 5 +- vm/vm.hpp | 16 +- 15 files changed, 406 insertions(+), 588 deletions(-) diff --git a/basis/boxes/boxes.factor b/basis/boxes/boxes.factor index 39f8eb44cc..811c5addb0 100644 --- a/basis/boxes/boxes.factor +++ b/basis/boxes/boxes.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel accessors ; IN: boxes @@ -15,9 +15,11 @@ ERROR: box-full box ; ERROR: box-empty box ; +: check-box ( box -- box ) + dup occupied>> [ box-empty ] unless ; inline + : box> ( box -- value ) - dup occupied>> - [ [ f ] change-value f >>occupied drop ] [ box-empty ] if ; + check-box [ f ] change-value f >>occupied drop ; : ?box ( box -- value/f ? ) dup occupied>> [ box> t ] [ drop f f ] if ; diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index a95456cdc6..b0a751b172 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -247,7 +247,6 @@ M: bad-executable summary unwind-native-frames lazy-jit-compile c-to-factor - call-clear } [ dup '[ _ do-not-compile ] "special" set-word-prop ] each : infer-special ( word -- ) @@ -299,466 +298,184 @@ M: bad-executable summary 3tri ; ! Stack effects for all primitives -\ fixnum< { fixnum fixnum } { object } define-primitive -\ fixnum< make-foldable - -\ fixnum<= { fixnum fixnum } { object } define-primitive -\ fixnum<= make-foldable - -\ fixnum> { fixnum fixnum } { object } define-primitive -\ fixnum> make-foldable - -\ fixnum>= { fixnum fixnum } { object } define-primitive -\ fixnum>= make-foldable - -\ eq? { object object } { object } define-primitive -\ eq? make-foldable - -\ bignum>fixnum { bignum } { fixnum } define-primitive -\ bignum>fixnum make-foldable - -\ float>fixnum { float } { fixnum } define-primitive -\ bignum>fixnum make-foldable - -\ fixnum>bignum { fixnum } { bignum } define-primitive -\ fixnum>bignum make-foldable - -\ float>bignum { float } { bignum } define-primitive -\ float>bignum make-foldable - -\ fixnum>float { fixnum } { float } define-primitive -\ fixnum>float make-foldable - -\ bignum>float { bignum } { float } define-primitive -\ bignum>float make-foldable - -\ (float>string) { float } { byte-array } define-primitive -\ (float>string) make-foldable - -\ float>bits { real } { integer } define-primitive -\ float>bits make-foldable - -\ double>bits { real } { integer } define-primitive -\ double>bits make-foldable - -\ bits>float { integer } { float } define-primitive -\ bits>float make-foldable - -\ bits>double { integer } { float } define-primitive -\ bits>double make-foldable - -\ both-fixnums? { object object } { object } define-primitive - -\ fixnum+ { fixnum fixnum } { integer } define-primitive -\ fixnum+ make-foldable - -\ fixnum+fast { fixnum fixnum } { fixnum } define-primitive -\ fixnum+fast make-foldable - -\ fixnum- { fixnum fixnum } { integer } define-primitive -\ fixnum- make-foldable - -\ fixnum-fast { fixnum fixnum } { fixnum } define-primitive -\ fixnum-fast make-foldable - -\ fixnum* { fixnum fixnum } { integer } define-primitive -\ fixnum* make-foldable - -\ fixnum*fast { fixnum fixnum } { fixnum } define-primitive -\ fixnum*fast make-foldable - -\ 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 - -\ fixnum-bitor { fixnum fixnum } { fixnum } define-primitive -\ fixnum-bitor make-foldable - -\ fixnum-bitxor { fixnum fixnum } { fixnum } define-primitive -\ fixnum-bitxor make-foldable - -\ fixnum-bitnot { fixnum } { fixnum } define-primitive -\ fixnum-bitnot make-foldable - -\ fixnum-shift { fixnum fixnum } { integer } define-primitive -\ fixnum-shift make-foldable - -\ fixnum-shift-fast { fixnum fixnum } { fixnum } define-primitive -\ fixnum-shift-fast make-foldable - -\ bignum= { bignum bignum } { object } define-primitive -\ bignum= make-foldable - -\ bignum+ { bignum bignum } { bignum } define-primitive -\ bignum+ make-foldable - -\ bignum- { bignum bignum } { bignum } define-primitive -\ bignum- make-foldable - -\ bignum* { bignum bignum } { bignum } define-primitive -\ bignum* make-foldable - -\ bignum/i { bignum bignum } { bignum } define-primitive -\ bignum/i make-foldable - -\ bignum-mod { bignum bignum } { bignum } define-primitive -\ bignum-mod make-foldable - -\ bignum/mod { bignum bignum } { bignum bignum } define-primitive -\ bignum/mod make-foldable - -\ bignum-bitand { bignum bignum } { bignum } define-primitive -\ bignum-bitand make-foldable - -\ bignum-bitor { bignum bignum } { bignum } define-primitive -\ bignum-bitor make-foldable - -\ bignum-bitxor { bignum bignum } { bignum } define-primitive -\ bignum-bitxor make-foldable - -\ bignum-bitnot { bignum } { bignum } define-primitive -\ bignum-bitnot make-foldable - -\ bignum-shift { bignum fixnum } { bignum } define-primitive -\ bignum-shift make-foldable - -\ bignum< { bignum bignum } { object } define-primitive -\ bignum< make-foldable - -\ bignum<= { bignum bignum } { object } define-primitive -\ bignum<= make-foldable - -\ bignum> { bignum bignum } { object } define-primitive -\ bignum> make-foldable - -\ bignum>= { bignum bignum } { object } define-primitive -\ bignum>= make-foldable - -\ bignum-bit? { bignum integer } { object } define-primitive -\ bignum-bit? make-foldable - -\ bignum-log2 { bignum } { bignum } define-primitive -\ bignum-log2 make-foldable - -\ byte-array>bignum { byte-array } { bignum } define-primitive -\ byte-array>bignum make-foldable - -\ float= { float float } { object } define-primitive -\ float= make-foldable - -\ float+ { float float } { float } define-primitive -\ float+ make-foldable - -\ float- { float float } { float } define-primitive -\ float- make-foldable - -\ float* { float float } { float } define-primitive -\ float* make-foldable - -\ float/f { float float } { float } define-primitive -\ float/f make-foldable - -\ float-mod { float float } { float } define-primitive -\ float-mod make-foldable - -\ float< { float float } { object } define-primitive -\ float< make-foldable - -\ float<= { float float } { object } define-primitive -\ float<= make-foldable - -\ float> { float float } { object } define-primitive -\ float> make-foldable - -\ float>= { float float } { object } define-primitive -\ float>= make-foldable - -\ float-u< { float float } { object } define-primitive -\ float-u< make-foldable - -\ float-u<= { float float } { object } define-primitive -\ float-u<= make-foldable - -\ float-u> { float float } { object } define-primitive -\ float-u> make-foldable - -\ float-u>= { float float } { object } define-primitive -\ float-u>= make-foldable - -\ (word) { object object object } { word } define-primitive -\ (word) make-flushable - -\ word-code { word } { integer integer } define-primitive -\ word-code make-flushable - -\ current-callback { } { fixnum } define-primitive -\ current-callback make-flushable - -\ context { } { c-ptr } define-primitive -\ context make-flushable - -\ delete-context { c-ptr } { } define-primitive - -\ (start-context) { object quotation } { object } define-primitive - -\ (set-context) { object alien } { object } define-primitive - -\ special-object { fixnum } { object } define-primitive -\ special-object make-flushable - -\ set-special-object { object fixnum } { } define-primitive - -\ context-object { fixnum } { object } define-primitive -\ context-object make-flushable - -\ set-context-object { object fixnum } { } define-primitive - -\ (exists?) { string } { object } define-primitive - -\ minor-gc { } { } define-primitive - -\ gc { } { } define-primitive - -\ compact-gc { } { } define-primitive - -\ (save-image) { byte-array byte-array } { } define-primitive - -\ (save-image-and-exit) { byte-array byte-array } { } define-primitive - -\ data-room { } { byte-array } define-primitive -\ data-room make-flushable - -\ (code-blocks) { } { array } define-primitive -\ (code-blocks) make-flushable - -\ code-room { } { byte-array } define-primitive -\ code-room make-flushable - -\ system-micros { } { integer } define-primitive -\ system-micros make-flushable - -\ nano-count { } { integer } define-primitive -\ nano-count make-flushable - -\ tag { object } { fixnum } define-primitive -\ tag make-foldable - +\ (byte-array) { integer } { byte-array } define-primitive \ (byte-array) make-flushable +\ (clone) { object } { object } define-primitive \ (clone) make-flushable +\ (code-blocks) { } { array } define-primitive \ (code-blocks) make-flushable \ (dlopen) { byte-array } { dll } define-primitive - \ (dlsym) { byte-array object } { c-ptr } define-primitive - -\ dlclose { dll } { } define-primitive - -\ { integer } { byte-array } define-primitive -\ make-flushable - -\ (byte-array) { integer } { byte-array } define-primitive -\ (byte-array) make-flushable - -\ { integer c-ptr } { c-ptr } define-primitive -\ make-flushable - -\ alien-signed-cell { c-ptr integer } { integer } define-primitive -\ alien-signed-cell make-flushable - -\ set-alien-signed-cell { integer c-ptr integer } { } define-primitive - -\ alien-unsigned-cell { c-ptr integer } { integer } define-primitive -\ alien-unsigned-cell make-flushable - -\ set-alien-unsigned-cell { integer c-ptr integer } { } define-primitive - -\ alien-signed-8 { c-ptr integer } { integer } define-primitive -\ alien-signed-8 make-flushable - -\ set-alien-signed-8 { integer c-ptr integer } { } define-primitive - -\ alien-unsigned-8 { c-ptr integer } { integer } define-primitive -\ alien-unsigned-8 make-flushable - -\ set-alien-unsigned-8 { integer c-ptr integer } { } define-primitive - -\ alien-signed-4 { c-ptr integer } { integer } define-primitive -\ alien-signed-4 make-flushable - -\ set-alien-signed-4 { integer c-ptr integer } { } define-primitive - -\ alien-unsigned-4 { c-ptr integer } { integer } define-primitive -\ alien-unsigned-4 make-flushable - -\ set-alien-unsigned-4 { integer c-ptr integer } { } define-primitive - -\ alien-signed-2 { c-ptr integer } { fixnum } define-primitive -\ alien-signed-2 make-flushable - -\ set-alien-signed-2 { integer c-ptr integer } { } define-primitive - -\ alien-unsigned-2 { c-ptr integer } { fixnum } define-primitive -\ alien-unsigned-2 make-flushable - -\ set-alien-unsigned-2 { integer c-ptr integer } { } define-primitive - -\ alien-signed-1 { c-ptr integer } { fixnum } define-primitive -\ alien-signed-1 make-flushable - -\ set-alien-signed-1 { integer c-ptr integer } { } define-primitive - -\ alien-unsigned-1 { c-ptr integer } { fixnum } define-primitive -\ alien-unsigned-1 make-flushable - -\ set-alien-unsigned-1 { integer c-ptr integer } { } define-primitive - -\ alien-float { c-ptr integer } { float } define-primitive -\ alien-float make-flushable - -\ set-alien-float { float c-ptr integer } { } define-primitive - -\ alien-double { c-ptr integer } { float } define-primitive -\ alien-double make-flushable - -\ set-alien-double { float c-ptr integer } { } define-primitive - -\ alien-cell { c-ptr integer } { pinned-c-ptr } define-primitive -\ alien-cell make-flushable - -\ set-alien-cell { c-ptr c-ptr integer } { } define-primitive - -\ alien-address { alien } { integer } define-primitive -\ alien-address make-flushable - -\ slot { object fixnum } { object } define-primitive -\ slot make-flushable - -\ set-slot { object object fixnum } { } define-primitive - -\ string-nth { fixnum string } { fixnum } define-primitive -\ string-nth make-flushable - -\ set-string-nth-slow { fixnum fixnum string } { } define-primitive -\ set-string-nth-fast { fixnum fixnum string } { } define-primitive - -\ resize-array { integer array } { array } define-primitive -\ resize-array make-flushable - -\ resize-byte-array { integer byte-array } { byte-array } define-primitive -\ resize-byte-array make-flushable - -\ resize-string { integer string } { string } define-primitive -\ resize-string make-flushable - -\ { integer object } { array } define-primitive -\ make-flushable - -\ all-instances { } { array } define-primitive - -\ size { object } { fixnum } define-primitive -\ size make-flushable - -\ die { } { } define-primitive - -\ (fopen) { byte-array byte-array } { alien } define-primitive - -\ fgetc { alien } { object } define-primitive - -\ fwrite { c-ptr integer alien } { } define-primitive - -\ fputc { object alien } { } define-primitive - -\ fread { integer alien } { object } define-primitive - -\ fflush { alien } { } define-primitive - -\ fseek { integer integer alien } { } define-primitive - -\ ftell { alien } { integer } define-primitive - -\ fclose { alien } { } define-primitive - -\ { object } { wrapper } define-primitive -\ make-foldable - -\ (clone) { object } { object } define-primitive -\ (clone) make-flushable - -\ { integer integer } { string } define-primitive -\ make-flushable - -\ array>quotation { array } { quotation } define-primitive -\ array>quotation make-flushable - -\ quotation-code { quotation } { integer integer } define-primitive -\ quotation-code make-flushable - -\ { tuple-layout } { tuple } define-primitive -\ make-flushable - -\ datastack { } { array } define-primitive -\ datastack make-flushable - -\ check-datastack { array integer integer } { object } define-primitive -\ check-datastack make-flushable - -\ retainstack { } { array } define-primitive -\ retainstack make-flushable - -\ callstack { } { callstack } define-primitive -\ callstack make-flushable - -\ callstack>array { callstack } { array } define-primitive -\ callstack>array make-flushable - -\ (sleep) { integer } { } define-primitive - -\ become { array array } { } define-primitive - -\ innermost-frame-executing { callstack } { object } define-primitive - -\ innermost-frame-scan { callstack } { fixnum } define-primitive - -\ set-innermost-frame-quot { quotation callstack } { } define-primitive - -\ dll-valid? { object } { object } define-primitive - -\ modify-code-heap { array object object } { } define-primitive - -\ unimplemented { } { } define-primitive - -\ jit-compile { quotation } { } define-primitive - -\ lookup-method { object array } { word } define-primitive - -\ reset-dispatch-stats { } { } define-primitive -\ dispatch-stats { } { byte-array } define-primitive - -\ optimized? { word } { object } define-primitive - -\ strip-stack-traces { } { } define-primitive - -\ { integer word } { alien } define-primitive - -\ enable-gc-events { } { } define-primitive -\ disable-gc-events { } { object } define-primitive - -\ profiling { object } { } define-primitive - -\ (identity-hashcode) { object } { fixnum } define-primitive - -\ compute-identity-hashcode { object } { } define-primitive - +\ (exists?) { string } { object } define-primitive \ (exit) { integer } { } define-primitive - +\ (float>string) { float } { byte-array } define-primitive \ (float>string) make-foldable +\ (fopen) { byte-array byte-array } { alien } define-primitive +\ (identity-hashcode) { object } { fixnum } define-primitive +\ (save-image) { byte-array byte-array } { } define-primitive +\ (save-image-and-exit) { byte-array byte-array } { } define-primitive +\ (set-context) { object alien } { object } define-primitive +\ (sleep) { integer } { } define-primitive +\ (start-context) { object quotation } { object } define-primitive +\ (word) { object object object } { word } define-primitive \ (word) make-flushable +\ { integer object } { array } define-primitive \ make-flushable +\ { integer } { byte-array } define-primitive \ make-flushable +\ { integer word } { alien } define-primitive +\ { integer c-ptr } { c-ptr } define-primitive \ make-flushable +\ { integer integer } { string } define-primitive \ make-flushable +\ { tuple-layout } { tuple } define-primitive \ make-flushable +\ { object } { wrapper } define-primitive \ make-foldable +\ alien-address { alien } { integer } define-primitive \ alien-address make-flushable +\ alien-cell { c-ptr integer } { pinned-c-ptr } define-primitive \ alien-cell make-flushable +\ alien-double { c-ptr integer } { float } define-primitive \ alien-double make-flushable +\ alien-float { c-ptr integer } { float } define-primitive \ alien-float make-flushable +\ alien-signed-1 { c-ptr integer } { fixnum } define-primitive \ alien-signed-1 make-flushable +\ alien-signed-2 { c-ptr integer } { fixnum } define-primitive \ alien-signed-2 make-flushable +\ alien-signed-4 { c-ptr integer } { integer } define-primitive \ alien-signed-4 make-flushable +\ alien-signed-8 { c-ptr integer } { integer } define-primitive \ alien-signed-8 make-flushable +\ alien-signed-cell { c-ptr integer } { integer } define-primitive \ alien-signed-cell make-flushable +\ alien-unsigned-1 { c-ptr integer } { fixnum } define-primitive \ alien-unsigned-1 make-flushable +\ alien-unsigned-2 { c-ptr integer } { fixnum } define-primitive \ alien-unsigned-2 make-flushable +\ alien-unsigned-4 { c-ptr integer } { integer } define-primitive \ alien-unsigned-4 make-flushable +\ alien-unsigned-8 { c-ptr integer } { integer } define-primitive \ alien-unsigned-8 make-flushable +\ alien-unsigned-cell { c-ptr integer } { integer } define-primitive \ alien-unsigned-cell make-flushable +\ all-instances { } { array } define-primitive +\ array>quotation { array } { quotation } define-primitive \ array>quotation make-foldable +\ become { array array } { } define-primitive +\ bignum* { bignum bignum } { bignum } define-primitive \ bignum* make-foldable +\ bignum+ { bignum bignum } { bignum } define-primitive \ bignum+ make-foldable +\ bignum- { bignum bignum } { bignum } define-primitive \ bignum- make-foldable +\ bignum-bit? { bignum integer } { object } define-primitive \ bignum-bit? make-foldable +\ bignum-bitand { bignum bignum } { bignum } define-primitive \ bignum-bitand make-foldable +\ bignum-bitnot { bignum } { bignum } define-primitive \ bignum-bitnot make-foldable +\ bignum-bitor { bignum bignum } { bignum } define-primitive \ bignum-bitor make-foldable +\ bignum-bitxor { bignum bignum } { bignum } define-primitive \ bignum-bitxor make-foldable +\ bignum-log2 { bignum } { bignum } define-primitive \ bignum-log2 make-foldable +\ bignum-mod { bignum bignum } { bignum } define-primitive \ bignum-mod make-foldable +\ bignum-shift { bignum fixnum } { bignum } define-primitive \ bignum-shift make-foldable +\ bignum/i { bignum bignum } { bignum } define-primitive \ bignum/i make-foldable +\ bignum/mod { bignum bignum } { bignum bignum } define-primitive \ bignum/mod make-foldable +\ bignum< { bignum bignum } { object } define-primitive \ bignum< make-foldable +\ bignum<= { bignum bignum } { object } define-primitive \ bignum<= make-foldable +\ bignum= { bignum bignum } { object } define-primitive \ bignum= make-foldable +\ bignum> { bignum bignum } { object } define-primitive \ bignum> make-foldable +\ bignum>= { bignum bignum } { object } define-primitive \ bignum>= make-foldable +\ bignum>fixnum { bignum } { fixnum } define-primitive \ bignum>fixnum make-foldable +\ bignum>float { bignum } { float } define-primitive \ bignum>float make-foldable +\ bits>double { integer } { float } define-primitive \ bits>double make-foldable +\ bits>float { integer } { float } define-primitive \ bits>float make-foldable +\ both-fixnums? { object object } { object } define-primitive +\ byte-array>bignum { byte-array } { bignum } define-primitive \ byte-array>bignum make-foldable +\ callstack { } { callstack } define-primitive \ callstack make-flushable +\ callstack-for { c-ptr } { callstack } define-primitive \ callstack make-flushable +\ callstack>array { callstack } { array } define-primitive \ callstack>array make-flushable +\ check-datastack { array integer integer } { object } define-primitive \ check-datastack make-flushable +\ code-room { } { byte-array } define-primitive \ code-room make-flushable +\ compact-gc { } { } define-primitive +\ compute-identity-hashcode { object } { } define-primitive +\ context { } { c-ptr } define-primitive \ context make-flushable +\ context-object { fixnum } { object } define-primitive \ context-object make-flushable +\ context-object-for { fixnum c-ptr } { object } define-primitive \ context-object-for make-flushable +\ current-callback { } { fixnum } define-primitive \ current-callback make-flushable +\ data-room { } { byte-array } define-primitive \ data-room make-flushable +\ datastack { } { array } define-primitive \ datastack make-flushable +\ datastack-for { c-ptr } { array } define-primitive \ datastack-for make-flushable +\ delete-context { c-ptr } { } define-primitive +\ die { } { } define-primitive +\ disable-gc-events { } { object } define-primitive +\ dispatch-stats { } { byte-array } define-primitive +\ dlclose { dll } { } define-primitive +\ dll-valid? { object } { object } define-primitive +\ double>bits { real } { integer } define-primitive \ double>bits make-foldable +\ enable-gc-events { } { } define-primitive +\ eq? { object object } { object } define-primitive \ eq? make-foldable +\ fclose { alien } { } define-primitive +\ fflush { alien } { } define-primitive +\ fgetc { alien } { object } define-primitive +\ fixnum* { fixnum fixnum } { integer } define-primitive \ fixnum* make-foldable +\ fixnum*fast { fixnum fixnum } { fixnum } define-primitive \ fixnum*fast make-foldable +\ fixnum+ { fixnum fixnum } { integer } define-primitive \ fixnum+ make-foldable +\ fixnum+fast { fixnum fixnum } { fixnum } define-primitive \ fixnum+fast make-foldable +\ fixnum- { fixnum fixnum } { integer } define-primitive \ fixnum- make-foldable +\ fixnum-bitand { fixnum fixnum } { fixnum } define-primitive \ fixnum-bitand make-foldable +\ fixnum-bitnot { fixnum } { fixnum } define-primitive \ fixnum-bitnot make-foldable +\ fixnum-bitor { fixnum fixnum } { fixnum } define-primitive \ fixnum-bitor make-foldable +\ fixnum-bitxor { fixnum fixnum } { fixnum } define-primitive \ fixnum-bitxor make-foldable +\ fixnum-fast { fixnum fixnum } { fixnum } define-primitive \ fixnum-fast make-foldable +\ fixnum-mod { fixnum fixnum } { fixnum } define-primitive \ fixnum-mod make-foldable +\ fixnum-shift { fixnum fixnum } { integer } define-primitive \ fixnum-shift make-foldable +\ fixnum-shift-fast { fixnum fixnum } { fixnum } define-primitive \ fixnum-shift-fast make-foldable +\ 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 } { integer fixnum } define-primitive \ fixnum/mod make-foldable +\ fixnum/mod-fast { fixnum fixnum } { fixnum fixnum } define-primitive \ fixnum/mod-fast make-foldable +\ fixnum< { fixnum fixnum } { object } define-primitive \ fixnum< make-foldable +\ fixnum<= { fixnum fixnum } { object } define-primitive \ fixnum<= make-foldable +\ fixnum> { fixnum fixnum } { object } define-primitive \ fixnum> make-foldable +\ fixnum>= { fixnum fixnum } { object } define-primitive \ fixnum>= make-foldable +\ fixnum>bignum { fixnum } { bignum } define-primitive \ fixnum>bignum make-foldable +\ fixnum>float { fixnum } { float } define-primitive \ fixnum>float make-foldable +\ float* { float float } { float } define-primitive \ float* make-foldable +\ float+ { float float } { float } define-primitive \ float+ make-foldable +\ float- { float float } { float } define-primitive \ float- make-foldable +\ float-mod { float float } { float } define-primitive \ float-mod make-foldable +\ float-u< { float float } { object } define-primitive \ float-u< make-foldable +\ float-u<= { float float } { object } define-primitive \ float-u<= make-foldable +\ float-u> { float float } { object } define-primitive \ float-u> make-foldable +\ float-u>= { float float } { object } define-primitive \ float-u>= make-foldable +\ float/f { float float } { float } define-primitive \ float/f make-foldable +\ float< { float float } { object } define-primitive \ float< make-foldable +\ float<= { float float } { object } define-primitive \ float<= make-foldable +\ float= { float float } { object } define-primitive \ float= make-foldable +\ float> { float float } { object } define-primitive \ float> make-foldable +\ float>= { float float } { object } define-primitive \ float>= make-foldable +\ float>bignum { float } { bignum } define-primitive \ float>bignum make-foldable +\ float>bits { real } { integer } define-primitive \ float>bits make-foldable +\ float>fixnum { float } { fixnum } define-primitive \ bignum>fixnum make-foldable +\ fputc { object alien } { } define-primitive +\ fread { integer alien } { object } define-primitive +\ fseek { integer integer alien } { } define-primitive +\ ftell { alien } { integer } define-primitive +\ fwrite { c-ptr integer alien } { } define-primitive +\ gc { } { } define-primitive +\ innermost-frame-executing { callstack } { object } define-primitive +\ innermost-frame-scan { callstack } { fixnum } define-primitive +\ jit-compile { quotation } { } define-primitive +\ lookup-method { object array } { word } define-primitive +\ minor-gc { } { } define-primitive +\ modify-code-heap { array object object } { } define-primitive +\ nano-count { } { integer } define-primitive \ nano-count make-flushable +\ optimized? { word } { object } define-primitive +\ profiling { object } { } define-primitive \ quot-compiled? { quotation } { object } define-primitive +\ quotation-code { quotation } { integer integer } define-primitive \ quotation-code make-flushable +\ reset-dispatch-stats { } { } define-primitive +\ resize-array { integer array } { array } define-primitive \ resize-array make-flushable +\ resize-byte-array { integer byte-array } { byte-array } define-primitive \ resize-byte-array make-flushable +\ resize-string { integer string } { string } define-primitive \ resize-string make-flushable +\ retainstack { } { array } define-primitive \ retainstack make-flushable +\ retainstack-for { c-ptr } { array } define-primitive \ retainstack-for make-flushable +\ set-alien-cell { c-ptr c-ptr integer } { } define-primitive +\ set-alien-double { float c-ptr integer } { } define-primitive +\ set-alien-float { float c-ptr integer } { } define-primitive +\ set-alien-signed-1 { integer c-ptr integer } { } define-primitive +\ set-alien-signed-2 { integer c-ptr integer } { } define-primitive +\ set-alien-signed-4 { integer c-ptr integer } { } define-primitive +\ set-alien-signed-8 { integer c-ptr integer } { } define-primitive +\ set-alien-signed-cell { integer c-ptr integer } { } define-primitive +\ set-alien-unsigned-1 { integer c-ptr integer } { } define-primitive +\ set-alien-unsigned-2 { integer c-ptr integer } { } define-primitive +\ set-alien-unsigned-4 { integer c-ptr integer } { } define-primitive +\ set-alien-unsigned-8 { integer c-ptr integer } { } define-primitive +\ set-alien-unsigned-cell { integer c-ptr integer } { } define-primitive +\ set-context-object { object fixnum } { } define-primitive +\ set-innermost-frame-quot { quotation callstack } { } define-primitive +\ set-slot { object object fixnum } { } define-primitive +\ set-special-object { object fixnum } { } define-primitive +\ set-string-nth-fast { fixnum fixnum string } { } define-primitive +\ set-string-nth-slow { fixnum fixnum string } { } define-primitive +\ size { object } { fixnum } define-primitive \ size make-flushable +\ slot { object fixnum } { object } define-primitive \ slot make-flushable +\ special-object { fixnum } { object } define-primitive \ special-object make-flushable +\ string-nth { fixnum string } { fixnum } define-primitive \ string-nth make-flushable +\ strip-stack-traces { } { } define-primitive +\ system-micros { } { integer } define-primitive \ system-micros make-flushable +\ tag { object } { fixnum } define-primitive \ tag make-foldable +\ unimplemented { } { } define-primitive +\ word-code { word } { integer integer } define-primitive \ word-code make-flushable diff --git a/basis/threads/threads-docs.factor b/basis/threads/threads-docs.factor index 335fbb3902..3e63a81d9a 100644 --- a/basis/threads/threads-docs.factor +++ b/basis/threads/threads-docs.factor @@ -1,6 +1,6 @@ USING: help.markup help.syntax kernel kernel.private io -threads.private continuations init quotations strings -assocs heaps boxes namespaces deques dlists system ; +threads.private init quotations strings assocs heaps boxes +namespaces deques dlists system ; IN: threads ARTICLE: "threads-start/stop" "Starting and stopping threads" @@ -48,7 +48,7 @@ ARTICLE: "thread-state" "Thread-local state and variables" $nl "Global hashtable of all threads, keyed by " { $snippet "id" } ":" { $subsections threads } -"Threads have an identity independent of continuations. If a continuation is refied in one thread and then resumed in another thread, the code running in that continuation will observe a change in the value output by " { $link self } "." ; +"Threads have an identity independent of continuations. If a continuation is reified in one thread and then reflected in another thread, the code running in that continuation will observe a change in the value output by " { $link self } "." ; ARTICLE: "thread-impl" "Thread implementation" "Thread implementation:" @@ -57,10 +57,8 @@ ARTICLE: "thread-impl" "Thread implementation" sleep-queue } ; -ARTICLE: "threads" "Lightweight co-operative threads" -"Factor supports lightweight co-operative threads implemented on top of " { $link "continuations" } ". A thread will yield while waiting for input/output operations to complete, or when a yield has been explicitly requested." -$nl -"Factor threads are very lightweight. Each thread can take as little as 900 bytes of memory. This library has been tested running hundreds of thousands of simple threads." +ARTICLE: "threads" "Co-operative threads" +"Factor supports co-operative threads. A thread will yield while waiting for input/output operations to complete, or when a yield has been explicitly requested." $nl "Words for working with threads are in the " { $vocab-link "threads" } " vocabulary." { $subsections @@ -78,7 +76,7 @@ HELP: thread { { $snippet "id" } " - a unique identifier assigned to each thread." } { { $snippet "name" } " - the name passed to " { $link spawn } "." } { { $snippet "quot" } " - the initial quotation passed to " { $link spawn } "." } - { { $snippet "continuation" } " - a " { $link box } "; if the thread is ready to run, the box holds the continuation, otherwise it is empty." } + { { $snippet "status" } " - a " { $link string } " indicating what the thread is waiting for, or " { $link f } ". This slot is intended to be used for debugging purposes." } } } ; diff --git a/basis/threads/threads.factor b/basis/threads/threads.factor index 89a90f87fd..bd30ef4b90 100644 --- a/basis/threads/threads.factor +++ b/basis/threads/threads.factor @@ -3,8 +3,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays hashtables heaps kernel kernel.private math namespaces sequences vectors continuations continuations.private -dlists assocs system combinators combinators.private init boxes -accessors math.order deques strings quotations fry ; +dlists assocs system combinators init boxes accessors math.order +deques strings quotations fry ; IN: threads ; + PRIVATE> SYMBOL: initial-thread @@ -24,7 +40,7 @@ TUPLE: thread { quot callable initial: [ ] } { exit-handler callable initial: [ ] } { id integer } -{ continuation box } +{ context box } state runnable mailbox @@ -34,6 +50,9 @@ sleep-entry ; : self ( -- thread ) 63 special-object { thread } declare ; inline +: thread-continuation ( thread -- continuation ) + context>> check-box value>> continuation-for ; + ! Thread-local storage : tnamespace ( -- assoc ) self variables>> ; inline @@ -45,14 +64,11 @@ sleep-entry ; tnamespace set-at ; : tchange ( key quot -- ) - tnamespace swap change-at ; inline + [ tnamespace ] dip change-at ; inline : threads ( -- assoc ) 64 special-object { hashtable } declare ; inline -: thread ( id -- thread ) - threads at ; - : thread-registered? ( thread -- ? ) id>> threads key? ; @@ -78,23 +94,23 @@ ERROR: not-running thread ; PRIVATE> -: new-thread ( quot name class -- thread ) - new - swap >>name - swap >>quot - \ thread counter >>id - >>continuation - H{ } clone >>variables ; inline - -: ( quot name -- thread ) - \ thread new-thread ; - : run-queue ( -- dlist ) 65 special-object { dlist } declare ; inline : sleep-queue ( -- heap ) 66 special-object { dlist } declare ; inline +: new-thread ( quot name class -- thread ) + new + swap >>name + swap >>quot + \ thread counter >>id + H{ } clone >>variables + >>context ; inline + +: ( quot name -- thread ) + \ thread new-thread ; + : resume ( thread -- ) f >>state check-registered run-queue push-front ; @@ -114,6 +130,13 @@ PRIVATE> [ sleep-queue heap-peek nip nano-count [-] ] } cond ; +: interrupt ( thread -- ) + dup state>> [ + dup sleep-entry>> [ sleep-queue heap-delete ] when* + f >>sleep-entry + dup resume + ] when drop ; + DEFER: stop > [ call stop ] call-clear - ] (( namestack thread -- * )) call-effect-unsafe ; + init-catchstack + self quot>> call + stop + ] start-context ; DEFER: next -: no-runnable-threads ( -- * ) +: no-runnable-threads ( -- obj ) ! We should never be in a state where the only threads ! are sleeping; the I/O wait thread is always runnable. ! However, if it dies, we handle this case @@ -162,31 +183,36 @@ DEFER: next [ (sleep) ] } cond next ; -: (next) ( arg thread -- * ) +: (next) ( obj thread -- obj' ) f >>state dup set-self - dup runnable>> [ - continuation>> box> continue-with - ] [ - t >>runnable start - ] if ; + dup runnable>> + [ context>> box> set-context ] [ t >>runnable drop start ] if ; -: next ( -- * ) +: next ( -- obj ) expire-sleep-loop - run-queue dup deque-empty? [ - drop no-runnable-threads - ] [ - pop-back dup array? [ first2 ] [ f swap ] if (next) - ] if ; + run-queue dup deque-empty? + [ drop no-runnable-threads ] + [ pop-back dup array? [ first2 ] [ [ f ] dip ] if (next) ] if ; + +: recycler-thread ( -- thread ) 68 special-object ; + +: recycler-queue ( -- vector ) 69 special-object ; + +: delete-context-later ( context -- ) + recycler-queue push recycler-thread interrupt ; PRIVATE> : stop ( -- * ) - self [ exit-handler>> call( -- ) ] [ unregister-thread ] bi next ; + self [ exit-handler>> call( -- ) ] [ unregister-thread ] bi + context delete-context-later next + die 1 exit ; : suspend ( state -- obj ) - self (>>state) - [ self continuation>> >box next ] callcc1 ; inline + [ self ] dip >>state + [ context ] dip context>> >box + next ; : yield ( -- ) self resume f suspend drop ; @@ -196,22 +222,15 @@ M: integer sleep-until [ self ] dip schedule-sleep "sleep" suspend drop ; M: f sleep-until - drop "interrupt" suspend drop ; + drop "standby" suspend drop ; GENERIC: sleep ( dt -- ) M: real sleep >integer nano-count + sleep-until ; -: interrupt ( thread -- ) - dup state>> [ - dup sleep-entry>> [ sleep-queue heap-delete ] when* - f >>sleep-entry - dup resume - ] when drop ; - : (spawn) ( thread -- ) - [ register-thread ] [ namestack swap resume-with ] bi ; + [ register-thread ] [ [ namestack ] dip resume-with ] bi ; : spawn ( quot name -- thread ) [ (spawn) ] keep ; @@ -228,17 +247,35 @@ GENERIC: error-in-thread ( error thread -- ) 65 set-special-object - 66 set-special-object - initial-thread global - [ drop [ ] "Initial" ] cache - >>continuation + 66 set-special-object ; + +: init-initial-thread ( -- ) + [ ] "Initial" t >>runnable - f >>state - dup register-thread - set-self ; + [ initial-thread set-global ] + [ register-thread ] + [ set-self ] + tri ; + +! The recycler thread deletes contexts belonging to stopped +! threads + +: recycler-loop ( -- ) + recycler-queue [ [ delete-context ] each ] [ delete-all ] bi + f sleep-until + recycler-loop ; + +: init-recycler ( -- ) + [ recycler-loop ] "Context recycler" spawn 68 set-special-object + V{ } clone 69 set-special-object ; + +: init-threads ( -- ) + init-thread-state + init-initial-thread + init-recycler ; PRIVATE> diff --git a/basis/tools/threads/threads.factor b/basis/tools/threads/threads.factor index ea85fb1129..1bb0918b82 100644 --- a/basis/tools/threads/threads.factor +++ b/basis/tools/threads/threads.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: threads kernel prettyprint prettyprint.config io io.styles sequences assocs namespaces sorting boxes @@ -7,7 +7,9 @@ IN: tools.threads : thread. ( thread -- ) dup id>> pprint-cell - dup name>> over [ write-object ] with-cell + dup name>> [ + over write-object + ] with-cell dup state>> [ [ dup self eq? "running" "yield" ? ] unless* write diff --git a/basis/ui/tools/listener/listener.factor b/basis/ui/tools/listener/listener.factor index 53d3bec56e..ffd0c4cd0e 100644 --- a/basis/ui/tools/listener/listener.factor +++ b/basis/ui/tools/listener/listener.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2005, 2009 Slava Pestov. +! Copyright (C) 2005, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs calendar combinators locals source-files.errors colors.constants combinators.short-circuit @@ -30,7 +30,7 @@ output history flag mailbox thread waiting token-model word-model popup ; drop ; : interactor-continuation ( interactor -- continuation ) - thread>> continuation>> value>> ; + thread>> thread-continuation ; : interactor-busy? ( interactor -- ? ) #! We're busy if there's no thread to resume. diff --git a/basis/ui/tools/operations/operations.factor b/basis/ui/tools/operations/operations.factor index 3019de4e21..9d8e50c615 100644 --- a/basis/ui/tools/operations/operations.factor +++ b/basis/ui/tools/operations/operations.factor @@ -62,10 +62,7 @@ IN: ui.tools.operations ! Thread : com-thread-traceback-window ( thread -- ) - continuation>> dup occupied>> - [ value>> traceback-window ] - [ drop beep ] - if ; + thread-continuation traceback-window ; [ thread? ] \ com-thread-traceback-window H{ { +primary+ t } diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 38e1a380ee..87350f290a 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -343,7 +343,7 @@ tuple { "(execute)" "kernel.private" (( word -- )) } { "(call)" "kernel.private" (( quot -- )) } { "unwind-native-frames" "kernel.private" (( -- )) } - { "set-callstack" "kernel.private" (( cs -- * )) } + { "set-callstack" "kernel.private" (( callstack -- * )) } { "lazy-jit-compile" "kernel.private" (( -- )) } { "c-to-factor" "kernel.private" (( -- )) } { "slot" "slots.private" (( obj m -- value )) } @@ -441,23 +441,22 @@ tuple { "fwrite" "io.streams.c" "primitive_fwrite" (( data length alien -- )) } { "(clone)" "kernel" "primitive_clone" (( obj -- newobj )) } { "" "kernel" "primitive_wrapper" (( obj -- wrapper )) } - { "callstack" "kernel" "primitive_callstack" (( -- cs )) } + { "callstack" "kernel" "primitive_callstack" (( -- callstack )) } { "callstack>array" "kernel" "primitive_callstack_to_array" (( callstack -- array )) } - { "datastack" "kernel" "primitive_datastack" (( -- ds )) } + { "datastack" "kernel" "primitive_datastack" (( -- array )) } { "die" "kernel" "primitive_die" (( -- )) } - { "retainstack" "kernel" "primitive_retainstack" (( -- rs )) } + { "retainstack" "kernel" "primitive_retainstack" (( -- array )) } { "(identity-hashcode)" "kernel.private" "primitive_identity_hashcode" (( obj -- code )) } { "become" "kernel.private" "primitive_become" (( old new -- )) } - { "call-clear" "kernel.private" "primitive_call_clear" (( quot -- * )) } { "check-datastack" "kernel.private" "primitive_check_datastack" (( array in# out# -- ? )) } { "compute-identity-hashcode" "kernel.private" "primitive_compute_identity_hashcode" (( obj -- )) } { "context-object" "kernel.private" "primitive_context_object" (( n -- obj )) } { "innermost-frame-executing" "kernel.private" "primitive_innermost_stack_frame_executing" (( callstack -- obj )) } { "innermost-frame-scan" "kernel.private" "primitive_innermost_stack_frame_scan" (( callstack -- n )) } { "set-context-object" "kernel.private" "primitive_set_context_object" (( obj n -- )) } - { "set-datastack" "kernel.private" "primitive_set_datastack" (( ds -- )) } + { "set-datastack" "kernel.private" "primitive_set_datastack" (( array -- )) } { "set-innermost-frame-quot" "kernel.private" "primitive_set_innermost_stack_frame_quot" (( n callstack -- )) } - { "set-retainstack" "kernel.private" "primitive_set_retainstack" (( rs -- )) } + { "set-retainstack" "kernel.private" "primitive_set_retainstack" (( array -- )) } { "set-special-object" "kernel.private" "primitive_set_special_object" (( obj n -- )) } { "special-object" "kernel.private" "primitive_special_object" (( n -- obj )) } { "strip-stack-traces" "kernel.private" "primitive_strip_stack_traces" (( -- )) } @@ -536,8 +535,12 @@ tuple { "nano-count" "system" "primitive_nano_count" (( -- ns )) } { "system-micros" "system" "primitive_system_micros" (( -- us )) } { "(sleep)" "threads.private" "primitive_sleep" (( nanos -- )) } - { "context" "threads.private" "primitive_context" (( -- c-ptr )) } - { "delete-context" "threads.private" "primitive_delete_context" (( c-ptr -- )) } + { "callstack-for" "threads.private" "primitive_callstack_for" (( context -- array )) } + { "context" "threads.private" "primitive_context" (( -- context )) } + { "context-object-for" "threads.private" "primitive_context_object_for" (( n context -- obj )) } + { "datastack-for" "threads.private" "primitive_datastack_for" (( context -- array )) } + { "retainstack-for" "threads.private" "primitive_retainstack_for" (( context -- array )) } + { "delete-context" "threads.private" "primitive_delete_context" (( context -- )) } { "dispatch-stats" "tools.dispatch.private" "primitive_dispatch_stats" (( -- stats )) } { "reset-dispatch-stats" "tools.dispatch.private" "primitive_reset_dispatch_stats" (( -- )) } { "profiling" "tools.profiler.private" "primitive_profiling" (( ? -- )) } diff --git a/core/kernel/kernel-docs.factor b/core/kernel/kernel-docs.factor index 8512700852..064978f99b 100644 --- a/core/kernel/kernel-docs.factor +++ b/core/kernel/kernel-docs.factor @@ -26,28 +26,28 @@ HELP: -rot ( x y z -- z x y ) $complex-shuffle ; HELP: dupd ( x y -- x x y ) $complex-shuffle ; HELP: swapd ( x y z -- y x z ) $complex-shuffle ; -HELP: datastack ( -- ds ) -{ $values { "ds" array } } +HELP: datastack ( -- array ) +{ $values { "array" array } } { $description "Outputs an array containing a copy of the data stack contents right before the call to this word, with the top of the stack at the end of the array." } ; -HELP: set-datastack ( ds -- ) -{ $values { "ds" array } } +HELP: set-datastack ( array -- ) +{ $values { "array" array } } { $description "Replaces the data stack contents with a copy of an array. The end of the array becomes the top of the stack." } ; -HELP: retainstack ( -- rs ) -{ $values { "rs" array } } +HELP: retainstack ( -- array ) +{ $values { "array" array } } { $description "Outputs an array containing a copy of the retain stack contents right before the call to this word, with the top of the stack at the end of the array." } ; -HELP: set-retainstack ( rs -- ) -{ $values { "rs" array } } +HELP: set-retainstack ( array -- ) +{ $values { "array" array } } { $description "Replaces the retain stack contents with a copy of an array. The end of the array becomes the top of the stack." } ; -HELP: callstack ( -- cs ) -{ $values { "cs" callstack } } +HELP: callstack ( -- callstack ) +{ $values { "callstack" callstack } } { $description "Outputs a copy of the call stack contents, with the top of the stack at the end of the vector. The stack frame of the caller word is " { $emphasis "not" } " included." } ; -HELP: set-callstack ( cs -- * ) -{ $values { "cs" callstack } } +HELP: set-callstack ( callstack -- * ) +{ $values { "callstack" callstack } } { $description "Replaces the call stack contents. Control flow is transferred immediately to the innermost frame of the new call stack." } ; HELP: clear @@ -208,11 +208,6 @@ HELP: call { call POSTPONE: call( } related-words -HELP: call-clear ( quot -- * ) -{ $values { "quot" callable } } -{ $description "Calls a quotation with an empty call stack. If the quotation returns, Factor will exit.." } -{ $notes "Used to implement " { $link "threads" } "." } ; - HELP: keep { $values { "x" object } { "quot" { $quotation "( ..a x -- ..b )" } } } { $description "Call a quotation with a value on the stack, restoring the value when the quotation returns." } diff --git a/vm/callstack.cpp b/vm/callstack.cpp index 7268d6ab91..ad7528ab84 100755 --- a/vm/callstack.cpp +++ b/vm/callstack.cpp @@ -42,7 +42,7 @@ This means that if 'callstack' is called in tail position, we will have popped a necessary frame... however this word is only called by continuation implementation, and user code shouldn't be calling it at all, so we leave it as it is for now. */ -stack_frame *factor_vm::second_from_top_stack_frame() +stack_frame *factor_vm::second_from_top_stack_frame(context *ctx) { stack_frame *frame = ctx->callstack_bottom - 1; while(frame >= ctx->callstack_top @@ -54,16 +54,27 @@ stack_frame *factor_vm::second_from_top_stack_frame() return frame + 1; } -void factor_vm::primitive_callstack() +cell factor_vm::capture_callstack(context *ctx) { - stack_frame *top = second_from_top_stack_frame(); + stack_frame *top = second_from_top_stack_frame(ctx); stack_frame *bottom = ctx->callstack_bottom; fixnum size = std::max((fixnum)0,(fixnum)bottom - (fixnum)top); callstack *stack = allot_callstack(size); memcpy(stack->top(),top,size); - ctx->push(tag(stack)); + return tag(stack); +} + +void factor_vm::primitive_callstack() +{ + ctx->push(capture_callstack(ctx)); +} + +void factor_vm::primitive_callstack_for() +{ + context *other_ctx = (context *)pinned_alien_offset(ctx->pop()); + ctx->push(capture_callstack(other_ctx)); } code_block *factor_vm::frame_code(stack_frame *frame) diff --git a/vm/contexts.cpp b/vm/contexts.cpp index 8734ff8486..20dac9f4e5 100644 --- a/vm/contexts.cpp +++ b/vm/contexts.cpp @@ -160,31 +160,68 @@ void factor_vm::primitive_set_context_object() ctx->context_objects[n] = value; } -bool factor_vm::stack_to_array(cell bottom, cell top) +void factor_vm::primitive_context_object_for() +{ + context *other_ctx = (context *)pinned_alien_offset(ctx->pop()); + fixnum n = untag_fixnum(ctx->pop()); + ctx->push(other_ctx->context_objects[n]); +} + +cell factor_vm::stack_to_array(cell bottom, cell top) { fixnum depth = (fixnum)(top - bottom + sizeof(cell)); if(depth < 0) - return false; + return false_object; else { array *a = allot_uninitialized_array(depth / sizeof(cell)); memcpy(a + 1,(void*)bottom,depth); - ctx->push(tag(a)); - return true; + return tag(a); } } +cell factor_vm::datastack_to_array(context *ctx) +{ + cell array = stack_to_array(ctx->datastack_seg->start,ctx->datastack); + if(array == false_object) + general_error(ERROR_DATASTACK_UNDERFLOW,false_object,false_object); + else + return array; +} + void factor_vm::primitive_datastack() { - if(!stack_to_array(ctx->datastack_seg->start,ctx->datastack)) - general_error(ERROR_DATASTACK_UNDERFLOW,false_object,false_object); + ctx->push(datastack_to_array(ctx)); +} + +void factor_vm::primitive_datastack_for() +{ + context *other_ctx = (context *)pinned_alien_offset(ctx->pop()); + ctx->push(datastack_to_array(other_ctx)); +} + +cell factor_vm::retainstack_to_array(context *ctx) +{ + cell array = stack_to_array(ctx->retainstack_seg->start,ctx->retainstack); + if(array == false_object) + { + general_error(ERROR_RETAINSTACK_UNDERFLOW,false_object,false_object); + return false_object; + } + else + return array; } void factor_vm::primitive_retainstack() { - if(!stack_to_array(ctx->retainstack_seg->start,ctx->retainstack)) - general_error(ERROR_RETAINSTACK_UNDERFLOW,false_object,false_object); + ctx->push(retainstack_to_array(ctx)); +} + +void factor_vm::primitive_retainstack_for() +{ + context *other_ctx = (context *)pinned_alien_offset(ctx->pop()); + ctx->push(retainstack_to_array(other_ctx)); } /* returns pointer to top of stack */ @@ -195,14 +232,24 @@ cell factor_vm::array_to_stack(array *array, cell bottom) return bottom + depth - sizeof(cell); } +void factor_vm::set_datastack(context *ctx, array *array) +{ + ctx->datastack = array_to_stack(array,ctx->datastack_seg->start); +} + void factor_vm::primitive_set_datastack() { - ctx->datastack = array_to_stack(untag_check(ctx->pop()),ctx->datastack_seg->start); + set_datastack(ctx,untag_check(ctx->pop())); +} + +void factor_vm::set_retainstack(context *ctx, array *array) +{ + ctx->retainstack = array_to_stack(array,ctx->retainstack_seg->start); } void factor_vm::primitive_set_retainstack() { - ctx->retainstack = array_to_stack(untag_check(ctx->pop()),ctx->retainstack_seg->start); + set_retainstack(ctx,untag_check(ctx->pop())); } /* Used to implement call( */ diff --git a/vm/errors.cpp b/vm/errors.cpp index f6ceee9966..1867965108 100755 --- a/vm/errors.cpp +++ b/vm/errors.cpp @@ -120,11 +120,6 @@ void factor_vm::fp_trap_error(unsigned int fpu_status, stack_frame *stack) general_error(ERROR_FP_TRAP,tag_fixnum(fpu_status),false_object,stack); } -void factor_vm::primitive_call_clear() -{ - unwind_native_frames(ctx->pop(),ctx->callstack_bottom); -} - /* For testing purposes */ void factor_vm::primitive_unimplemented() { diff --git a/vm/objects.hpp b/vm/objects.hpp index 772863d3f1..4c5dd64632 100644 --- a/vm/objects.hpp +++ b/vm/objects.hpp @@ -92,7 +92,10 @@ enum special_object { OBJ_RUN_QUEUE = 65, OBJ_SLEEP_QUEUE = 66, - OBJ_VM_COMPILER = 67, /* version string of the compiler we were built with */ + OBJ_VM_COMPILER = 67, /* version string of the compiler we were built with */ + + OBJ_RECYCLE_THREAD = 68, + OBJ_RECYCLE_QUEUE = 69, }; /* save-image-and-exit discards special objects that are filled in on startup diff --git a/vm/primitives.hpp b/vm/primitives.hpp index 4d72cf1abb..cb5626c894 100644 --- a/vm/primitives.hpp +++ b/vm/primitives.hpp @@ -33,9 +33,9 @@ namespace factor _(bits_float) \ _(byte_array) \ _(byte_array_to_bignum) \ - _(call_clear) \ _(callback) \ _(callstack) \ + _(callstack_for) \ _(callstack_to_array) \ _(check_datastack) \ _(clone) \ @@ -45,9 +45,11 @@ namespace factor _(compute_identity_hashcode) \ _(context) \ _(context_object) \ + _(context_object_for) \ _(current_callback) \ _(data_room) \ _(datastack) \ + _(datastack_for) \ _(delete_context) \ _(die) \ _(disable_gc_events) \ @@ -109,6 +111,7 @@ namespace factor _(resize_byte_array) \ _(resize_string) \ _(retainstack) \ + _(retainstack_for) \ _(save_image) \ _(save_image_and_exit) \ _(set_context_object) \ diff --git a/vm/vm.hpp b/vm/vm.hpp index d304543879..973d5f0dda 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -119,12 +119,19 @@ struct factor_vm void end_callback(); void primitive_current_callback(); void primitive_context_object(); + void primitive_context_object_for(); void primitive_set_context_object(); - bool stack_to_array(cell bottom, cell top); - cell array_to_stack(array *array, cell bottom); + cell stack_to_array(cell bottom, cell top); + cell datastack_to_array(context *ctx); void primitive_datastack(); + void primitive_datastack_for(); + cell retainstack_to_array(context *ctx); void primitive_retainstack(); + void primitive_retainstack_for(); + cell array_to_stack(array *array, cell bottom); + void set_datastack(context *ctx, array *array); void primitive_set_datastack(); + void set_retainstack(context *ctx, array *array); void primitive_set_retainstack(); void primitive_check_datastack(); void primitive_load_locals(); @@ -172,7 +179,6 @@ struct factor_vm void signal_error(cell signal, stack_frame *stack); void divide_by_zero_error(); void fp_trap_error(unsigned int fpu_status, stack_frame *stack); - void primitive_call_clear(); void primitive_unimplemented(); void memory_signal_handler_impl(); void misc_signal_handler_impl(); @@ -586,8 +592,10 @@ struct factor_vm void check_frame(stack_frame *frame); callstack *allot_callstack(cell size); stack_frame *fix_callstack_top(stack_frame *top); - stack_frame *second_from_top_stack_frame(); + stack_frame *second_from_top_stack_frame(context *ctx); + cell capture_callstack(context *ctx); void primitive_callstack(); + void primitive_callstack_for(); code_block *frame_code(stack_frame *frame); code_block_type frame_type(stack_frame *frame); cell frame_executing(stack_frame *frame); From c36d85ab47965da60129010182fcc92209eb4e2a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 30 Mar 2010 01:10:39 -0400 Subject: [PATCH 500/713] sets, hash-sets, bit-sets: fix some typos in the documentation --- basis/bit-sets/bit-sets-docs.factor | 4 ++-- core/hash-sets/hash-sets-docs.factor | 4 ++-- core/sets/sets-docs.factor | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/basis/bit-sets/bit-sets-docs.factor b/basis/bit-sets/bit-sets-docs.factor index bb4dc75cac..706ffb5cf1 100644 --- a/basis/bit-sets/bit-sets-docs.factor +++ b/basis/bit-sets/bit-sets-docs.factor @@ -3,9 +3,9 @@ IN: bit-sets ARTICLE: "bit-sets" "Bit sets" "The " { $vocab-link "bit-sets" } " vocabulary implements bit-array-backed sets. Bitsets are efficient for implementing relatively dense sets whose members are in a contiguous range of integers starting from 0. One bit is required for each integer in this range in the underlying representation." $nl -"Bit sets are of the class" +"Bit sets form a class:" { $subsection bit-set } -"They can be instantiated with the word" +"Constructing new bit sets:" { $subsection } ; ABOUT: "bit-sets" diff --git a/core/hash-sets/hash-sets-docs.factor b/core/hash-sets/hash-sets-docs.factor index e771442932..d59ebeca10 100644 --- a/core/hash-sets/hash-sets-docs.factor +++ b/core/hash-sets/hash-sets-docs.factor @@ -2,9 +2,9 @@ USING: help.markup help.syntax sequences ; IN: hash-sets ARTICLE: "hash-sets" "Hash sets" -"The " { $vocab-link "hash-sets" } " vocabulary implements hashtable-backed sets. These are of the class:" +"The " { $vocab-link "hash-sets" } " vocabulary implements hashtable-backed sets. Hash sets form a class:" { $subsection hash-set } -"They can be instantiated with the word" +"Constructing new hash sets:" { $subsection } "The syntax for hash sets is described in " { $link "syntax-hash-sets" } "." ; diff --git a/core/sets/sets-docs.factor b/core/sets/sets-docs.factor index 75df4069dc..5bde8a1feb 100644 --- a/core/sets/sets-docs.factor +++ b/core/sets/sets-docs.factor @@ -61,9 +61,9 @@ ARTICLE: "set-implementations" "Set implementations" ARTICLE: "sequence-sets" "Sequences as sets" "Any sequence can be used as a set. The members of this set are the elements of the sequence. Calling the word " { $link members } " on a sequence returns a copy of the sequence with only one listing of each member. Destructive operations " { $link adjoin } " and " { $link delete } " only work properly on growable sequences like " { $link vector } "s." $nl -"Care must be taken in writing efficient code using sequence sets. Testing for membership with " { $link in? } ", as well as the destructive set operations, take time proportional to the size of the sequence. Another representation, like " { $link "hash-sets" } ", would take constant time for membership tests. But binary operations like " { $link union } "are asymptotically optimal, taking time proportional to the sum of the size of the inputs." +"Care must be taken in writing efficient code using sequence sets. Testing for membership with " { $link in? } ", as well as the destructive set operations, take time proportional to the size of the sequence. Another representation, like " { $link "hash-sets" } ", would take constant time for membership tests. But binary operations like " { $link union } " are asymptotically optimal, taking time proportional to the sum of the size of the inputs." $nl -"As one particlar example, " { $link POSTPONE: f } " is a representation of the empty set, as it represents the empty sequence." ; +"As one particular example, " { $link POSTPONE: f } " is a representation of the empty set, since it is an empty sequence." ; HELP: set { $class-description "The class of all sets. Custom implementations of the set protocol should be declared as instances of this mixin for all set implementation to work correctly." } ; From 000c21fc665a0fa096297d637e419516965f8373 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 30 Mar 2010 01:17:39 -0400 Subject: [PATCH 501/713] concurrency.distributed: fix for removal of 'thread' word --- basis/concurrency/distributed/distributed.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/concurrency/distributed/distributed.factor b/basis/concurrency/distributed/distributed.factor index 0015b10cef..229cea8548 100644 --- a/basis/concurrency/distributed/distributed.factor +++ b/basis/concurrency/distributed/distributed.factor @@ -20,7 +20,7 @@ PRIVATE> registered-remote-threads delete-at ; : get-remote-thread ( name -- thread ) - dup registered-remote-threads at [ ] [ thread ] ?if ; + dup registered-remote-threads at [ ] [ threads at ] ?if ; SYMBOL: local-node From 26c4aec91a192aa73f9b5f56b50ca1645a9ccccb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 30 Mar 2010 15:35:36 -0400 Subject: [PATCH 502/713] validators: fix v-default (reported by Niklas Waern) --- basis/validators/validators-tests.factor | 19 +++++++++++-------- basis/validators/validators.factor | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/basis/validators/validators-tests.factor b/basis/validators/validators-tests.factor index acdcdda5d2..6b5936977f 100644 --- a/basis/validators/validators-tests.factor +++ b/basis/validators/validators-tests.factor @@ -2,17 +2,12 @@ IN: validators.tests USING: kernel sequences tools.test validators accessors namespaces assocs ; -[ "" v-one-line ] must-fail -[ "hello world" ] [ "hello world" v-one-line ] unit-test -[ "hello\nworld" v-one-line ] must-fail - -[ "" v-one-word ] must-fail -[ "hello" ] [ "hello" v-one-word ] unit-test -[ "hello world" v-one-word ] must-fail - [ t ] [ "on" v-checkbox ] unit-test [ f ] [ "off" v-checkbox ] unit-test +[ "default test" ] [ "" "default test" v-default ] unit-test +[ "blah" ] [ "blah" "default test" v-default ] unit-test + [ "foo" v-number ] must-fail [ 123 ] [ "123" v-number ] unit-test [ 123 ] [ "123" v-integer ] unit-test @@ -42,6 +37,14 @@ namespaces assocs ; [ "http:/www.factorcode.org" v-url ] [ "invalid URL" = ] must-fail-with +[ "" v-one-line ] must-fail +[ "hello world" ] [ "hello world" v-one-line ] unit-test +[ "hello\nworld" v-one-line ] must-fail + +[ "" v-one-word ] must-fail +[ "hello" ] [ "hello" v-one-word ] unit-test +[ "hello world" v-one-word ] must-fail + [ 4561261212345467 ] [ "4561261212345467" v-credit-card ] unit-test [ 4561261212345467 ] [ "4561-2612-1234-5467" v-credit-card ] unit-test diff --git a/basis/validators/validators.factor b/basis/validators/validators.factor index cf45e7b13f..45287a60c6 100644 --- a/basis/validators/validators.factor +++ b/basis/validators/validators.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2006, 2008 Slava Pestov +! Copyright (C) 2006, 2010 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. USING: kernel continuations sequences math namespaces make sets math.parser math.ranges assocs regexp unicode.categories arrays @@ -9,7 +9,7 @@ IN: validators >lower "on" = ; : v-default ( str def -- str/def ) - [ nip empty? ] 2keep ? ; + [ drop empty? not ] 2keep ? ; : v-required ( str -- str ) dup empty? [ "required" throw ] when ; From 2b68f56c89667a62c0b49487ee6f54efc6be38ab Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 30 Mar 2010 17:31:41 -0400 Subject: [PATCH 503/713] Document (free), move it out of libc.private and mention it in the "c-strings" help article (reported by Blei) --- basis/alien/data/data-docs.factor | 6 ++++-- basis/cocoa/messages/messages.factor | 3 +-- basis/libc/libc-docs.factor | 4 ++++ basis/libc/libc.factor | 6 +++--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/basis/alien/data/data-docs.factor b/basis/alien/data/data-docs.factor index 4600ea6837..d36a4d5fd2 100644 --- a/basis/alien/data/data-docs.factor +++ b/basis/alien/data/data-docs.factor @@ -60,6 +60,8 @@ $nl } "You must always free pointers returned by any of the above words when the block of memory is no longer in use:" { $subsections free } +"The above words record memory allocations, to help catch double frees and track down memory leaks with " { $link "tools.destructors" } ". To free memory allocated by a C library, another word can be used:" +{ $subsections (free) } "Utilities for automatically freeing memory in conjunction with " { $link with-destructors } ":" { $subsections &free @@ -148,9 +150,9 @@ $nl } "The first allocates " { $link byte-array } "s, and the latter allocates manually-managed memory which is not moved by the garbage collector and has to be explicitly freed by calling " { $link free } ". See " { $link "byte-arrays-gc" } " for a discussion of the two approaches." $nl -"The C type " { $link char } { $snippet "*" } " represents a generic pointer to " { $snippet "char" } "; arguments with this type will expect and return " { $link alien } "s, and won't perform any implicit string conversion." +"The C type " { $snippet "char*" } " represents a generic pointer to " { $snippet "char" } "; arguments with this type will expect and return " { $link alien } "s, and won't perform any implicit string conversion." $nl "A word to read strings from arbitrary addresses:" { $subsections alien>string } -"For example, if a C function returns a " { $link c-string } " but stipulates that the caller must deallocate the memory afterward, you must define the function as returning " { $snippet "char*" } " and call one of the above words before passing the pointer to " { $link free } "." ; +"For example, if a C function returns a " { $link c-string } " but stipulates that the caller must deallocate the memory afterward, you must define the function as returning " { $snippet "char*" } " and call " { $link (free) } " yourself." ; diff --git a/basis/cocoa/messages/messages.factor b/basis/cocoa/messages/messages.factor index a744087037..c422d85423 100644 --- a/basis/cocoa/messages/messages.factor +++ b/basis/cocoa/messages/messages.factor @@ -5,8 +5,7 @@ classes.struct continuations combinators compiler compiler.alien core-graphics.types stack-checker kernel math namespaces make quotations sequences strings words cocoa.runtime cocoa.types io macros memoize io.encodings.utf8 effects layouts libc -libc.private lexer init core-foundation fry generalizations -specialized-arrays ; +lexer init core-foundation fry generalizations specialized-arrays ; QUALIFIED-WITH: alien.c-types c IN: cocoa.messages diff --git a/basis/libc/libc-docs.factor b/basis/libc/libc-docs.factor index b89f4174bf..74e96b08d3 100644 --- a/basis/libc/libc-docs.factor +++ b/basis/libc/libc-docs.factor @@ -32,6 +32,10 @@ HELP: free { $values { "alien" c-ptr } } { $description "Deallocates a block of memory allocated by " { $link malloc } ", " { $link calloc } " or " { $link realloc } "." } ; +HELP: (free) +{ $values { "alien" c-ptr } } +{ $description "Deallocates a block of memory allocated by an external C library." } ; + HELP: &free { $values { "alien" c-ptr } } { $description "Marks the block of memory for unconditional deallocation at the end of the current " { $link with-destructors } " scope." } ; diff --git a/basis/libc/libc.factor b/basis/libc/libc.factor index 5f6a808b2e..4a887e695f 100644 --- a/basis/libc/libc.factor +++ b/basis/libc/libc.factor @@ -1,5 +1,5 @@ ! Copyright (C) 2004, 2005 Mackenzie Straight -! Copyright (C) 2007, 2009 Slava Pestov +! Copyright (C) 2007, 2010 Slava Pestov ! Copyright (C) 2007, 2008 Doug Coleman ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types assocs continuations alien.destructors kernel @@ -18,8 +18,6 @@ IN: libc : preserve-errno ( quot -- ) errno [ call ] dip set-errno ; inline - Date: Tue, 30 Mar 2010 17:33:08 -0400 Subject: [PATCH 504/713] models.product: fix example (reported by Muzzleflash) --- basis/models/product/product-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/models/product/product-docs.factor b/basis/models/product/product-docs.factor index b4288891e0..29b26159a7 100644 --- a/basis/models/product/product-docs.factor +++ b/basis/models/product/product-docs.factor @@ -13,7 +13,7 @@ $nl "ui.gadgets.labels ui.gadgets.packs ui.gadgets.panes" "ui.gadgets.sliders ;" "" - ": ( -- model ) 0 10 0 100 ;" + ": ( -- model ) 0 10 0 100 1 ;" ": ( model -- slider ) horizontal ;" "" " 2array" From fb2ecab614c0cd604864962b924991998eab7667 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 30 Mar 2010 21:47:48 -0400 Subject: [PATCH 505/713] threads: delete old contexts immediately instead of handing them off to a 'context recycler' thread --- basis/cpu/x86/32/bootstrap.factor | 81 ++++++++++------ basis/cpu/x86/64/bootstrap.factor | 90 +++++++++++------- basis/stack-checker/backend/backend.factor | 7 -- .../known-words/known-words.factor | 95 ++++++++----------- basis/threads/threads.factor | 84 ++++++---------- basis/tools/deploy/shaker/shaker.factor | 1 - core/bootstrap/primitives.factor | 7 +- core/system/system.factor | 4 +- vm/contexts.cpp | 14 +-- vm/contexts.hpp | 1 + vm/objects.hpp | 3 - vm/primitives.hpp | 1 - vm/vm.hpp | 1 - 13 files changed, 195 insertions(+), 194 deletions(-) diff --git a/basis/cpu/x86/32/bootstrap.factor b/basis/cpu/x86/32/bootstrap.factor index dde800760e..5b3bff1fc6 100644 --- a/basis/cpu/x86/32/bootstrap.factor +++ b/basis/cpu/x86/32/bootstrap.factor @@ -72,6 +72,12 @@ IN: bootstrap.x86 jit-restore-context ] jit-primitive jit-define +: jit-jump-quot ( -- ) + EAX quot-entry-point-offset [+] JMP ; + +: jit-call-quot ( -- ) + EAX quot-entry-point-offset [+] CALL ; + [ jit-load-vm ESP [] vm-reg MOV @@ -92,8 +98,7 @@ IN: bootstrap.x86 ESP ctx-reg context-callstack-bottom-offset [+] MOV ESP 4 ADD - ! call the quotation - EAX quot-entry-point-offset [+] CALL + jit-call-quot jit-load-vm jit-save-context @@ -109,8 +114,8 @@ IN: bootstrap.x86 EAX ds-reg [] MOV ds-reg bootstrap-cell SUB ] -[ EAX quot-entry-point-offset [+] CALL ] -[ EAX quot-entry-point-offset [+] JMP ] +[ jit-call-quot ] +[ jit-jump-quot ] \ (call) define-combinator-primitive [ @@ -133,8 +138,7 @@ IN: bootstrap.x86 jit-load-context jit-restore-context - ! Call quotation - EAX quot-entry-point-offset [+] JMP + jit-jump-quot ] \ unwind-native-frames define-sub-primitive [ @@ -175,8 +179,8 @@ IN: bootstrap.x86 ! Call VM "lazy_jit_compile" jit-call ] -[ EAX quot-entry-point-offset [+] CALL ] -[ EAX quot-entry-point-offset [+] JMP ] +[ jit-call-quot ] +[ jit-jump-quot ] \ lazy-jit-compile define-combinator-primitive ! Inline cache miss entry points @@ -247,8 +251,8 @@ IN: bootstrap.x86 jit-conditional ] \ fixnum* define-sub-primitive -! Threads -: jit-set-context ( reg -- ) +! Contexts +: jit-switch-context ( reg -- ) ! Save ds, rs registers jit-load-vm jit-save-context @@ -263,7 +267,26 @@ IN: bootstrap.x86 ! Load new ds, rs registers jit-restore-context ; -[ +: jit-set-context ( -- ) + ! Load context and parameter from datastack + EAX ds-reg [] MOV + EAX EAX alien-offset [+] MOV + EBX ds-reg -4 [+] MOV + ds-reg 8 SUB + + ! Make the new context active + EAX jit-switch-context + + ! Twiddle stack for return + ESP 4 ADD + + ! Store parameter to datastack + ds-reg 4 ADD + ds-reg [] EBX MOV ; + +[ jit-set-context ] \ (set-context) define-sub-primitive + +: jit-start-context ( -- ) ! Create the new context in return-reg jit-load-vm ESP [] vm-reg MOV @@ -274,7 +297,7 @@ IN: bootstrap.x86 ds-reg 8 SUB ! Make the new context active - EAX jit-set-context + EAX jit-switch-context ! Push parameter EAX EBX -4 [+] MOV @@ -283,26 +306,26 @@ IN: bootstrap.x86 ! Jump to initial quotation EAX EBX [] MOV - EAX quot-entry-point-offset [+] JMP -] \ (start-context) define-sub-primitive + jit-jump-quot ; + +[ jit-start-context ] \ (start-context) define-sub-primitive + +: jit-delete-current-context ( -- ) + jit-load-vm + jit-load-context + ESP [] vm-reg MOV + ESP 4 [+] ctx-reg MOV + "delete_context" jit-call ; [ - ! Load context and parameter from datastack - EAX ds-reg [] MOV - EAX EAX alien-offset [+] MOV - EBX ds-reg -4 [+] MOV - ds-reg 8 SUB + jit-delete-current-context + jit-set-context +] \ (set-context-and-delete) define-sub-primitive - ! Make the new context active - EAX jit-set-context - - ! Twiddle stack for return - ESP 4 ADD - - ! Store parameter to datastack - ds-reg 4 ADD - ds-reg [] EBX MOV -] \ (set-context) define-sub-primitive +[ + jit-delete-current-context + jit-start-context +] \ (start-context-and-delete) define-sub-primitive << "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >> call diff --git a/basis/cpu/x86/64/bootstrap.factor b/basis/cpu/x86/64/bootstrap.factor index 9eb59e2c86..b068c60352 100644 --- a/basis/cpu/x86/64/bootstrap.factor +++ b/basis/cpu/x86/64/bootstrap.factor @@ -70,6 +70,10 @@ IN: bootstrap.x86 jit-restore-context ] jit-primitive jit-define +: jit-jump-quot ( -- ) arg1 quot-entry-point-offset [+] JMP ; + +: jit-call-quot ( -- ) arg1 quot-entry-point-offset [+] CALL ; + [ nv-reg arg1 MOV @@ -87,7 +91,7 @@ IN: bootstrap.x86 ! call the quotation arg1 nv-reg MOV - arg1 quot-entry-point-offset [+] CALL + jit-call-quot jit-save-context @@ -102,8 +106,8 @@ IN: bootstrap.x86 arg1 ds-reg [] MOV ds-reg bootstrap-cell SUB ] -[ arg1 quot-entry-point-offset [+] CALL ] -[ arg1 quot-entry-point-offset [+] JMP ] +[ jit-call-quot ] +[ jit-jump-quot ] \ (call) define-combinator-primitive [ @@ -124,7 +128,7 @@ IN: bootstrap.x86 jit-restore-context ! Call quotation - arg1 quot-entry-point-offset [+] JMP + jit-jump-quot ] \ unwind-native-frames define-sub-primitive [ @@ -157,9 +161,10 @@ IN: bootstrap.x86 jit-save-context arg2 vm-reg MOV "lazy_jit_compile" jit-call + arg1 return-reg MOV ] [ return-reg quot-entry-point-offset [+] CALL ] -[ return-reg quot-entry-point-offset [+] JMP ] +[ jit-jump-quot ] \ lazy-jit-compile define-combinator-primitive ! Inline cache miss entry points @@ -222,8 +227,8 @@ IN: bootstrap.x86 jit-conditional ] \ fixnum* define-sub-primitive -! Threads -: jit-set-context ( reg -- ) +! Contexts +: jit-switch-context ( reg -- ) ! Save ds, rs registers jit-save-context @@ -237,44 +242,59 @@ IN: bootstrap.x86 ! Load new ds, rs registers jit-restore-context ; -[ +: jit-pop-context-and-param ( -- ) + arg1 ds-reg [] MOV + arg1 arg1 alien-offset [+] MOV + arg2 ds-reg -8 [+] MOV + ds-reg 16 SUB ; + +: jit-push-param ( -- ) + ds-reg 8 ADD + ds-reg [] arg2 MOV ; + +: jit-set-context ( -- ) + jit-pop-context-and-param + arg1 jit-switch-context + RSP 8 ADD + jit-push-param ; + +[ jit-set-context ] \ (set-context) define-sub-primitive + +: jit-pop-quot-and-param ( -- ) + arg1 ds-reg [] MOV + arg2 ds-reg -8 [+] MOV + ds-reg 16 SUB ; + +: jit-start-context ( -- ) ! Create the new context in return-reg arg1 vm-reg MOV "new_context" jit-call - ! Load quotation and parameter from datastack - arg1 ds-reg [] MOV - arg2 ds-reg -8 [+] MOV - ds-reg 16 SUB + jit-pop-quot-and-param - ! Make the new context active - return-reg jit-set-context + return-reg jit-switch-context - ! Push parameter - ds-reg 8 ADD - ds-reg [] arg2 MOV + jit-push-param - ! Jump to initial quotation - arg1 quot-entry-point-offset [+] JMP -] \ (start-context) define-sub-primitive + jit-jump-quot ; + +[ jit-start-context ] \ (start-context) define-sub-primitive + +: jit-delete-current-context ( -- ) + jit-load-context + arg1 vm-reg MOV + arg2 ctx-reg MOV + "delete_context" jit-call ; [ - ! Load context and parameter from datastack - temp0 ds-reg [] MOV - temp0 temp0 alien-offset [+] MOV - temp1 ds-reg -8 [+] MOV - ds-reg 16 SUB + jit-delete-current-context + jit-set-context +] \ (set-context-and-delete) define-sub-primitive - ! Make the new context active - temp0 jit-set-context - - ! Twiddle stack for return - RSP 8 ADD - - ! Store parameter to datastack - ds-reg 8 ADD - ds-reg [] temp1 MOV -] \ (set-context) define-sub-primitive +[ + jit-delete-current-context + jit-start-context +] \ (start-context-and-delete) define-sub-primitive << "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >> call diff --git a/basis/stack-checker/backend/backend.factor b/basis/stack-checker/backend/backend.factor index 51b5f0cdaf..7a18133eff 100644 --- a/basis/stack-checker/backend/backend.factor +++ b/basis/stack-checker/backend/backend.factor @@ -151,13 +151,6 @@ M: bad-call summary : required-stack-effect ( word -- effect ) dup stack-effect [ ] [ missing-effect ] ?if ; -: infer-word ( word -- ) - { - { [ dup macro? ] [ do-not-compile ] } - { [ dup "no-compile" word-prop ] [ do-not-compile ] } - [ dup required-stack-effect apply-word/effect ] - } cond ; - : with-infer ( quot -- effect visitor ) [ init-inference diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index b0a751b172..f6c7cf5859 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -14,7 +14,7 @@ compiler.units system.private combinators combinators.short-circuit locals locals.backend locals.types combinators.private stack-checker.values generic.single generic.single.private alien.libraries tools.dispatch.private -tools.profiler.private +tools.profiler.private macros stack-checker.alien stack-checker.state stack-checker.errors @@ -27,11 +27,41 @@ stack-checker.recursive-state stack-checker.row-polymorphism ; IN: stack-checker.known-words -: infer-primitive ( word -- ) - dup - [ "input-classes" word-prop ] - [ "default-output-classes" word-prop ] bi - apply-word/effect ; +: infer-special ( word -- ) + [ current-word set ] [ "special" word-prop call( -- ) ] bi ; + +: infer-shuffle ( shuffle -- ) + [ in>> length consume-d ] keep ! inputs shuffle + [ drop ] [ shuffle dup copy-values dup output-d ] 2bi ! inputs outputs copies + [ nip f f ] [ swap zip ] 2bi ! in-d out-d in-r out-r mapping + #shuffle, ; + +: infer-shuffle-word ( word -- ) + "shuffle" word-prop infer-shuffle ; + +: infer-local-reader ( word -- ) + (( -- value )) apply-word/effect ; + +: infer-local-writer ( word -- ) + (( value -- )) apply-word/effect ; + +: infer-local-word ( word -- ) + "local-word-def" word-prop infer-quot-here ; + +: non-inline-word ( word -- ) + dup depends-on-effect + { + { [ dup "shuffle" word-prop ] [ infer-shuffle-word ] } + { [ dup "special" word-prop ] [ infer-special ] } + { [ dup "transform-quot" word-prop ] [ apply-transform ] } + { [ dup macro? ] [ apply-macro ] } + { [ dup local? ] [ infer-local-reader ] } + { [ dup local-reader? ] [ infer-local-reader ] } + { [ dup local-writer? ] [ infer-local-writer ] } + { [ dup local-word? ] [ infer-local-word ] } + { [ dup "no-compile" word-prop ] [ do-not-compile ] } + [ dup required-stack-effect apply-word/effect ] + } cond ; { { drop (( x -- )) } @@ -51,15 +81,6 @@ IN: stack-checker.known-words { swap (( x y -- y x )) } } [ "shuffle" set-word-prop ] assoc-each -: infer-shuffle ( shuffle -- ) - [ in>> length consume-d ] keep ! inputs shuffle - [ drop ] [ shuffle dup copy-values dup output-d ] 2bi ! inputs outputs copies - [ nip f f ] [ swap zip ] 2bi ! in-d out-d in-r out-r mapping - #shuffle, ; - -: infer-shuffle-word ( word -- ) - "shuffle" word-prop infer-shuffle ; - : check-declaration ( declaration -- declaration ) dup { [ array? ] [ [ class? ] all? ] } 1&& [ bad-declaration-error ] unless ; @@ -180,11 +201,6 @@ M: bad-executable summary \ call-effect-unsafe [ infer-call-effect-unsafe ] "special" set-word-prop -: infer-exit ( -- ) - \ exit (( n -- * )) apply-word/effect ; - -\ exit [ infer-exit ] "special" set-word-prop - : infer-load-locals ( -- ) pop-literal nip consume-d dup copy-values dup output-r @@ -249,22 +265,10 @@ M: bad-executable summary c-to-factor } [ dup '[ _ do-not-compile ] "special" set-word-prop ] each -: infer-special ( word -- ) - [ current-word set ] [ "special" word-prop call( -- ) ] bi ; - -: infer-local-reader ( word -- ) - (( -- value )) apply-word/effect ; - -: infer-local-writer ( word -- ) - (( value -- )) apply-word/effect ; - -: infer-local-word ( word -- ) - "local-word-def" word-prop infer-quot-here ; - { declare call (call) dip 2dip 3dip curry compose execute (execute) call-effect-unsafe execute-effect-unsafe if - dispatch exit load-local load-locals get-local + dispatch load-local load-locals get-local drop-locals do-primitive alien-invoke alien-indirect alien-callback } [ t "no-compile" set-word-prop ] each @@ -276,26 +280,10 @@ M: bad-executable summary ! More words not to compile \ clear t "no-compile" set-word-prop -: non-inline-word ( word -- ) - dup depends-on-effect - { - { [ dup "shuffle" word-prop ] [ infer-shuffle-word ] } - { [ dup "special" word-prop ] [ infer-special ] } - { [ dup "primitive" word-prop ] [ infer-primitive ] } - { [ dup "transform-quot" word-prop ] [ apply-transform ] } - { [ dup "macro" word-prop ] [ apply-macro ] } - { [ dup local? ] [ infer-local-reader ] } - { [ dup local-reader? ] [ infer-local-reader ] } - { [ dup local-writer? ] [ infer-local-writer ] } - { [ dup local-word? ] [ infer-local-word ] } - [ infer-word ] - } cond ; - : define-primitive ( word inputs outputs -- ) - [ 2drop t "primitive" set-word-prop ] - [ drop "input-classes" set-word-prop ] - [ nip "default-output-classes" set-word-prop ] - 3tri ; + [ "input-classes" set-word-prop ] + [ "default-output-classes" set-word-prop ] + bi-curry* bi ; ! Stack effects for all primitives \ (byte-array) { integer } { byte-array } define-primitive \ (byte-array) make-flushable @@ -311,8 +299,10 @@ M: bad-executable summary \ (save-image) { byte-array byte-array } { } define-primitive \ (save-image-and-exit) { byte-array byte-array } { } define-primitive \ (set-context) { object alien } { object } define-primitive +\ (set-context-and-delete) { object alien } { } define-primitive \ (sleep) { integer } { } define-primitive \ (start-context) { object quotation } { object } define-primitive +\ (start-context-and-delete) { object quotation } { } define-primitive \ (word) { object object object } { word } define-primitive \ (word) make-flushable \ { integer object } { array } define-primitive \ make-flushable \ { integer } { byte-array } define-primitive \ make-flushable @@ -376,7 +366,6 @@ M: bad-executable summary \ data-room { } { byte-array } define-primitive \ data-room make-flushable \ datastack { } { array } define-primitive \ datastack make-flushable \ datastack-for { c-ptr } { array } define-primitive \ datastack-for make-flushable -\ delete-context { c-ptr } { } define-primitive \ die { } { } define-primitive \ disable-gc-events { } { object } define-primitive \ dispatch-stats { } { byte-array } define-primitive diff --git a/basis/threads/threads.factor b/basis/threads/threads.factor index bd30ef4b90..117e941aa7 100644 --- a/basis/threads/threads.factor +++ b/basis/threads/threads.factor @@ -9,13 +9,21 @@ IN: threads > call stop - ] start-context ; + ] -DEFER: next - -: no-runnable-threads ( -- obj ) - ! We should never be in a state where the only threads - ! are sleeping; the I/O wait thread is always runnable. - ! However, if it dies, we handle this case - ! semi-gracefully. - ! - ! And if sleep-time outputs f, there are no sleeping - ! threads either... so WTF. - sleep-time { - { [ dup not ] [ drop die ] } - { [ dup 0 = ] [ drop ] } - [ (sleep) ] - } cond next ; +: no-runnable-threads ( -- ) die ; : (next) ( obj thread -- obj' ) - f >>state - dup set-self dup runnable>> - [ context>> box> set-context ] [ t >>runnable drop start ] if ; + [ context>> box> set-context ] + [ t >>runnable drop [start] start-context ] if ; -: next ( -- obj ) +: (stop) ( obj thread -- * ) + dup runnable>> + [ context>> box> set-context-and-delete ] + [ t >>runnable drop [start] start-context-and-delete ] if ; + +: next ( -- obj thread ) expire-sleep-loop - run-queue dup deque-empty? - [ drop no-runnable-threads ] - [ pop-back dup array? [ first2 ] [ [ f ] dip ] if (next) ] if ; - -: recycler-thread ( -- thread ) 68 special-object ; - -: recycler-queue ( -- vector ) 69 special-object ; - -: delete-context-later ( context -- ) - recycler-queue push recycler-thread interrupt ; + run-queue pop-back + dup array? [ first2 ] [ [ f ] dip ] if + f >>state + dup set-self ; PRIVATE> : stop ( -- * ) self [ exit-handler>> call( -- ) ] [ unregister-thread ] bi - context delete-context-later next - die 1 exit ; + next (stop) ; : suspend ( state -- obj ) [ self ] dip >>state [ context ] dip context>> >box - next ; + next (next) ; : yield ( -- ) self resume f suspend drop ; @@ -260,22 +251,9 @@ GENERIC: error-in-thread ( error thread -- ) [ set-self ] tri ; -! The recycler thread deletes contexts belonging to stopped -! threads - -: recycler-loop ( -- ) - recycler-queue [ [ delete-context ] each ] [ delete-all ] bi - f sleep-until - recycler-loop ; - -: init-recycler ( -- ) - [ recycler-loop ] "Context recycler" spawn 68 set-special-object - V{ } clone 69 set-special-object ; - : init-threads ( -- ) init-thread-state - init-initial-thread - init-recycler ; + init-initial-thread ; PRIVATE> diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index 6fb6ab91ec..e7eea1179a 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -175,7 +175,6 @@ IN: tools.deploy.shaker "predicate" "predicate-definition" "predicating" - "primitive" "reader" "reading" "recursive" diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 87350f290a..52ee1e14b4 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -370,7 +370,9 @@ tuple { "fixnum>" "math.private" (( x y -- ? )) } { "fixnum>=" "math.private" (( x y -- ? )) } { "(set-context)" "threads.private" (( obj context -- obj' )) } + { "(set-context-and-delete)" "threads.private" (( obj context -- * )) } { "(start-context)" "threads.private" (( obj quot -- obj' )) } + { "(start-context-and-delete)" "threads.private" (( obj quot -- * )) } } [ first3 make-sub-primitive ] each ! Primitive words @@ -531,7 +533,7 @@ tuple { "set-string-nth-fast" "strings.private" "primitive_set_string_nth_fast" (( ch n string -- )) } { "set-string-nth-slow" "strings.private" "primitive_set_string_nth_slow" (( ch n string -- )) } { "string-nth" "strings.private" "primitive_string_nth" (( n string -- ch )) } - { "(exit)" "system" "primitive_exit" (( n -- )) } + { "(exit)" "system" "primitive_exit" (( n -- * )) } { "nano-count" "system" "primitive_nano_count" (( -- ns )) } { "system-micros" "system" "primitive_system_micros" (( -- us )) } { "(sleep)" "threads.private" "primitive_sleep" (( nanos -- )) } @@ -540,13 +542,12 @@ tuple { "context-object-for" "threads.private" "primitive_context_object_for" (( n context -- obj )) } { "datastack-for" "threads.private" "primitive_datastack_for" (( context -- array )) } { "retainstack-for" "threads.private" "primitive_retainstack_for" (( context -- array )) } - { "delete-context" "threads.private" "primitive_delete_context" (( context -- )) } { "dispatch-stats" "tools.dispatch.private" "primitive_dispatch_stats" (( -- stats )) } { "reset-dispatch-stats" "tools.dispatch.private" "primitive_reset_dispatch_stats" (( -- )) } { "profiling" "tools.profiler.private" "primitive_profiling" (( ? -- )) } { "optimized?" "words" "primitive_optimized_p" (( word -- ? )) } { "word-code" "words" "primitive_word_code" (( word -- start end )) } - { "(word)" "words.private" "primitive_word" (( name vocab -- word )) } + { "(word)" "words.private" "primitive_word" (( name vocab hashcode -- word )) } } [ first4 make-primitive ] each ! Bump build number diff --git a/core/system/system.factor b/core/system/system.factor index 765861c62f..ecd5047fba 100644 --- a/core/system/system.factor +++ b/core/system/system.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2007, 2009 Slava Pestov. +! Copyright (C) 2007, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel kernel.private sequences math namespaces init splitting assocs system.private layouts words ; @@ -57,4 +57,4 @@ PRIVATE> : embedded? ( -- ? ) 15 special-object ; -: exit ( n -- ) do-shutdown-hooks (exit) ; +: exit ( n -- * ) do-shutdown-hooks (exit) ; diff --git a/vm/contexts.cpp b/vm/contexts.cpp index 20dac9f4e5..9364f2e362 100644 --- a/vm/contexts.cpp +++ b/vm/contexts.cpp @@ -119,6 +119,11 @@ void factor_vm::delete_context(context *old_context) active_contexts.erase(old_context); } +VM_C_API void delete_context(factor_vm *parent, context *old_context) +{ + parent->delete_context(old_context); +} + void factor_vm::begin_callback() { ctx->reset(); @@ -185,7 +190,10 @@ cell factor_vm::datastack_to_array(context *ctx) { cell array = stack_to_array(ctx->datastack_seg->start,ctx->datastack); if(array == false_object) + { general_error(ERROR_DATASTACK_UNDERFLOW,false_object,false_object); + return false_object; + } else return array; } @@ -293,10 +301,4 @@ void factor_vm::primitive_context() ctx->push(allot_alien(ctx)); } -void factor_vm::primitive_delete_context() -{ - context *old_context = (context *)pinned_alien_offset(ctx->pop()); - delete_context(old_context); -} - } diff --git a/vm/contexts.hpp b/vm/contexts.hpp index 441b5916c8..f3aba0e5a6 100644 --- a/vm/contexts.hpp +++ b/vm/contexts.hpp @@ -70,6 +70,7 @@ struct context { }; VM_C_API context *new_context(factor_vm *parent); +VM_C_API void delete_context(factor_vm *parent, context *old_context); VM_C_API void begin_callback(factor_vm *parent); VM_C_API void end_callback(factor_vm *parent); diff --git a/vm/objects.hpp b/vm/objects.hpp index 4c5dd64632..778df8642e 100644 --- a/vm/objects.hpp +++ b/vm/objects.hpp @@ -93,9 +93,6 @@ enum special_object { OBJ_SLEEP_QUEUE = 66, OBJ_VM_COMPILER = 67, /* version string of the compiler we were built with */ - - OBJ_RECYCLE_THREAD = 68, - OBJ_RECYCLE_QUEUE = 69, }; /* save-image-and-exit discards special objects that are filled in on startup diff --git a/vm/primitives.hpp b/vm/primitives.hpp index cb5626c894..7e95a3bad5 100644 --- a/vm/primitives.hpp +++ b/vm/primitives.hpp @@ -50,7 +50,6 @@ namespace factor _(data_room) \ _(datastack) \ _(datastack_for) \ - _(delete_context) \ _(die) \ _(disable_gc_events) \ _(dispatch_stats) \ diff --git a/vm/vm.hpp b/vm/vm.hpp index 973d5f0dda..ad74a8e090 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -136,7 +136,6 @@ struct factor_vm void primitive_check_datastack(); void primitive_load_locals(); void primitive_context(); - void primitive_delete_context(); template void iterate_active_callstacks(Iterator &iter) { From 1b271f820261fce0e0fb6e4f6c59e95c59a83ef8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 30 Mar 2010 21:56:51 -0400 Subject: [PATCH 506/713] locals: remove some dead code --- basis/locals/errors/errors.factor | 5 ----- basis/locals/parser/parser.factor | 4 ---- basis/locals/rewrite/point-free/point-free.factor | 2 -- basis/locals/rewrite/sugar/sugar.factor | 3 --- basis/locals/types/types.factor | 9 ++------- basis/stack-checker/known-words/known-words.factor | 4 ---- 6 files changed, 2 insertions(+), 25 deletions(-) diff --git a/basis/locals/errors/errors.factor b/basis/locals/errors/errors.factor index 468671361f..d8a53b3c4e 100644 --- a/basis/locals/errors/errors.factor +++ b/basis/locals/errors/errors.factor @@ -19,11 +19,6 @@ ERROR: local-writer-in-literal-error ; M: local-writer-in-literal-error summary drop "Local writer words not permitted inside literals" ; -ERROR: local-word-in-literal-error ; - -M: local-word-in-literal-error summary - drop "Local words not permitted inside literals" ; - ERROR: :>-outside-lambda-error ; M: :>-outside-lambda-error summary diff --git a/basis/locals/parser/parser.factor b/basis/locals/parser/parser.factor index e742b4768a..01be7bcd20 100644 --- a/basis/locals/parser/parser.factor +++ b/basis/locals/parser/parser.factor @@ -24,10 +24,6 @@ SYMBOL: in-lambda? : parse-local-defs ( -- words assoc ) [ "|" [ make-local ] map-tokens ] H{ } make-assoc ; -: make-local-word ( name def -- word ) - [ [ dup name>> set ] [ ] [ ] tri ] dip - "local-word-def" set-word-prop ; - SINGLETON: lambda-parser SYMBOL: locals diff --git a/basis/locals/rewrite/point-free/point-free.factor b/basis/locals/rewrite/point-free/point-free.factor index 4e91e3d87b..0b010a5591 100644 --- a/basis/locals/rewrite/point-free/point-free.factor +++ b/basis/locals/rewrite/point-free/point-free.factor @@ -21,8 +21,6 @@ M: local localize dupd read-local-quot ; M: quote localize dupd local>> read-local-quot ; -M: local-word localize dupd read-local-quot [ call ] append ; - M: local-reader localize dupd read-local-quot [ local-value ] append ; M: local-writer localize diff --git a/basis/locals/rewrite/sugar/sugar.factor b/basis/locals/rewrite/sugar/sugar.factor index a8a12d2614..9dfc733fff 100644 --- a/basis/locals/rewrite/sugar/sugar.factor +++ b/basis/locals/rewrite/sugar/sugar.factor @@ -82,9 +82,6 @@ M: local-reader rewrite-element , ; M: local-writer rewrite-element local-writer-in-literal-error ; -M: local-word rewrite-element - local-word-in-literal-error ; - M: word rewrite-element , ; : rewrite-wrapper ( wrapper -- ) diff --git a/basis/locals/types/types.factor b/basis/locals/types/types.factor index 424ef68243..a930765b7c 100644 --- a/basis/locals/types/types.factor +++ b/basis/locals/types/types.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2007, 2009 Slava Pestov, Eduardo Cavazos. +! Copyright (C) 2007, 2010 Slava Pestov, Eduardo Cavazos. ! See http://factorcode.org/license.txt for BSD license. USING: accessors combinators kernel sequences words quotations ; @@ -35,11 +35,6 @@ PREDICATE: local < word "local?" word-prop ; M: local literalize ; -PREDICATE: local-word < word "local-word?" word-prop ; - -: ( name -- word ) - f dup t "local-word?" set-word-prop ; - PREDICATE: local-reader < word "local-reader?" word-prop ; : ( name -- word ) @@ -58,5 +53,5 @@ PREDICATE: local-writer < word "local-writer?" word-prop ; [ nip ] } 2cleave ; -UNION: lexical local local-reader local-writer local-word ; +UNION: lexical local local-reader local-writer ; UNION: special lexical quote def ; diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index f6c7cf5859..01f3ff77c0 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -45,9 +45,6 @@ IN: stack-checker.known-words : infer-local-writer ( word -- ) (( value -- )) apply-word/effect ; -: infer-local-word ( word -- ) - "local-word-def" word-prop infer-quot-here ; - : non-inline-word ( word -- ) dup depends-on-effect { @@ -58,7 +55,6 @@ IN: stack-checker.known-words { [ dup local? ] [ infer-local-reader ] } { [ dup local-reader? ] [ infer-local-reader ] } { [ dup local-writer? ] [ infer-local-writer ] } - { [ dup local-word? ] [ infer-local-word ] } { [ dup "no-compile" word-prop ] [ do-not-compile ] } [ dup required-stack-effect apply-word/effect ] } cond ; From 587664efbfc5b90004765c0b61f766fdc241eae1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 31 Mar 2010 10:27:24 -0400 Subject: [PATCH 507/713] tools.deploy.shaker: don't strip out io-thread, since new thread implementation requires at least one thread to be runnable at any time --- basis/tools/deploy/shaker/shaker.factor | 7 ------- 1 file changed, 7 deletions(-) diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index e7eea1179a..21f28d6ae2 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -42,12 +42,8 @@ IN: tools.deploy.shaker deploy-threads? get [ "threads" startup-hooks get delete-at ] unless - native-io? [ - "io.thread" startup-hooks get delete-at - ] unless strip-io? [ "io.backend" startup-hooks get delete-at - "io.thread" startup-hooks get delete-at ] when strip-dictionary? [ { @@ -402,9 +398,6 @@ IN: tools.deploy.shaker [ c-io-backend forget "io.streams.c" forget-vocab - "io-thread-running?" "io.thread" lookup [ - global delete-at - ] when* ] with-compilation-unit ] when ; From ce42aea6a4594e5ee74e7674d74ef26f5eb0ed56 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 31 Mar 2010 13:29:44 -0400 Subject: [PATCH 508/713] tools.deploy.shaker: make sure an io-multiplex method remains even if C streams are stripped out --- basis/tools/deploy/shaker/shaker.factor | 10 ++++++---- basis/tools/deploy/shaker/strip-c-io.factor | 10 ++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 basis/tools/deploy/shaker/strip-c-io.factor diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index 21f28d6ae2..a2a2dbbc86 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -392,13 +392,15 @@ IN: tools.deploy.shaker ] [ drop ] if ; : strip-c-io ( -- ) + ! On all platforms, if deploy-io is 1, we strip out C streams. + ! On Unix, if deploy-io is 3, we strip out C streams as well. + ! On Windows, even if deploy-io is 3, C streams are still used + ! for the console, so don't strip it there. strip-io? deploy-io get 3 = os windows? not and or [ - [ - c-io-backend forget - "io.streams.c" forget-vocab - ] with-compilation-unit + "Stripping C I/O" show + "vocab:tools/deploy/shaker/strip-c-io.factor" run-file ] when ; : compress ( pred post-process string -- ) diff --git a/basis/tools/deploy/shaker/strip-c-io.factor b/basis/tools/deploy/shaker/strip-c-io.factor new file mode 100644 index 0000000000..44c63c509c --- /dev/null +++ b/basis/tools/deploy/shaker/strip-c-io.factor @@ -0,0 +1,10 @@ +USING: compiler.units definitions io.backend io.streams.c kernel +math threads.private vocabs ; + +[ + c-io-backend forget + "io.streams.c" forget-vocab +] with-compilation-unit + +M: object io-multiplex + dup 0 = [ drop ] [ 60 60 * 1000 * 1000 * or (sleep) ] if ; From 8f0487f1c3de9729cff98d181693efe3d3130dee Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 31 Mar 2010 15:19:00 -0400 Subject: [PATCH 509/713] cpu.x86: remove useless crap from c-to-factor sub-primitive --- basis/cpu/x86/32/bootstrap.factor | 10 ---------- basis/cpu/x86/64/bootstrap.factor | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/basis/cpu/x86/32/bootstrap.factor b/basis/cpu/x86/32/bootstrap.factor index 5b3bff1fc6..15a7dc1c29 100644 --- a/basis/cpu/x86/32/bootstrap.factor +++ b/basis/cpu/x86/32/bootstrap.factor @@ -91,21 +91,11 @@ IN: bootstrap.x86 jit-load-context jit-restore-context - ! save C callstack pointer - ctx-reg context-callstack-save-offset [+] ESP MOV - - ! load Factor callstack pointer - ESP ctx-reg context-callstack-bottom-offset [+] MOV - ESP 4 ADD - jit-call-quot jit-load-vm jit-save-context - ! load C callstack pointer - ESP ctx-reg context-callstack-save-offset [+] MOV - ESP [] vm-reg MOV "end_callback" jit-call ] \ c-to-factor define-sub-primitive diff --git a/basis/cpu/x86/64/bootstrap.factor b/basis/cpu/x86/64/bootstrap.factor index b068c60352..2f03823d45 100644 --- a/basis/cpu/x86/64/bootstrap.factor +++ b/basis/cpu/x86/64/bootstrap.factor @@ -82,22 +82,12 @@ IN: bootstrap.x86 jit-restore-context - ! save C callstack pointer - ctx-reg context-callstack-save-offset [+] stack-reg MOV - - ! load Factor callstack pointer - stack-reg ctx-reg context-callstack-bottom-offset [+] MOV - stack-reg 8 ADD - ! call the quotation arg1 nv-reg MOV jit-call-quot jit-save-context - ! load C callstack pointer - stack-reg ctx-reg context-callstack-save-offset [+] MOV - arg1 vm-reg MOV "end_callback" jit-call ] \ c-to-factor define-sub-primitive From 4b1361833e73d556bab6a86418adbcb36aecd332 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 31 Mar 2010 15:19:14 -0400 Subject: [PATCH 510/713] cpu.ppc: updating non-optimizing compiler backend for green threads (untested) --- basis/cpu/ppc/bootstrap.factor | 169 +++++++++++++++++++++++++++------ vm/cpu-ppc.hpp | 2 +- 2 files changed, 140 insertions(+), 31 deletions(-) diff --git a/basis/cpu/ppc/bootstrap.factor b/basis/cpu/ppc/bootstrap.factor index 58c0a4ef7b..53edcd427d 100644 --- a/basis/cpu/ppc/bootstrap.factor +++ b/basis/cpu/ppc/bootstrap.factor @@ -3,7 +3,8 @@ USING: bootstrap.image.private kernel kernel.private namespaces system cpu.ppc.assembler compiler.units compiler.constants math math.private math.ranges layouts words vocabs slots.private -locals locals.backend generic.single.private fry sequences ; +locals locals.backend generic.single.private fry sequences +threads.private ; FROM: cpu.ppc.assembler => B ; IN: bootstrap.ppc @@ -14,6 +15,22 @@ CONSTANT: ds-reg 13 CONSTANT: rs-reg 14 CONSTANT: vm-reg 15 CONSTANT: ctx-reg 16 +CONSTANT: nv-reg 17 + +: jit-call ( string -- ) + 0 2 LOAD32 rc-absolute-ppc-2/2 jit-dlsym + 2 MTLR + BLRL ; + +: jit-call-quot ( -- ) + 4 3 quot-entry-point-offset LWZ + 4 MTLR + BLRL ; + +: jit-jump-quot ( -- ) + 4 3 quot-entry-point-offset LWZ + 4 MTCTR + BCTR ; : factor-area-size ( -- n ) 16 ; @@ -52,27 +69,59 @@ CONSTANT: ctx-reg 16 saved-int-regs-size + saved-fp-regs-size + saved-vec-regs-size + + 4 + 16 align ; +: old-context-save-offset ( -- n ) + 432 save-at ; + [ + ! Create stack frame 0 MFLR 1 1 callback-frame-size neg STWU 0 1 callback-frame-size lr-save + STW + ! Save all non-volatile registers nv-int-regs [ 4 * save-int ] each-index nv-fp-regs [ 8 * 80 + save-fp ] each-index nv-vec-regs [ 16 * 224 + save-vec ] each-index + ! Load VM into vm-reg 0 vm-reg LOAD32 rc-absolute-ppc-2/2 rt-vm jit-rel + ! Save old context + 2 vm-reg vm-context-offset LWZ + 2 1 old-context-save-offset STW + + ! Switch over to the spare context + 2 vm-reg vm-spare-context-offset LWZ + 2 vm-reg vm-context-offset STW + + ! Save C callstack pointer + 2 context-callstack-save-offset 1 STW + + ! Load Factor callstack pointer + 1 2 context-callstack-bottom-offset LWZ + + ! Call into Factor code 0 2 LOAD32 rc-absolute-ppc-2/2 rt-entry-point jit-rel 2 MTLR BLRL + ! Load C callstack pointer + 2 vm-reg vm-context-offset LWZ + 1 2 context-callstack-save-offset LWZ + + ! Load old context + 2 1 old-context-save-offset LWZ + 2 vm-reg vm-context-offset STW + + ! Restore non-volatile registers nv-vec-regs [ 16 * 224 + restore-vec ] each-index nv-fp-regs [ 8 * 80 + restore-fp ] each-index nv-int-regs [ 4 * restore-int ] each-index + ! Tear down stack frame and return 0 1 callback-frame-size lr-save + LWZ 1 1 0 LWZ 0 MTLR @@ -267,9 +316,7 @@ CONSTANT: ctx-reg 16 jit-save-context 3 6 MR 4 vm-reg MR - 0 5 LOAD32 "inline_cache_miss" rc-absolute-ppc-2/2 jit-dlsym - 5 MTLR - BLRL + "inline_cache_miss" jit-call jit-restore-context ; [ jit-load-return-address jit-inline-cache-miss ] @@ -321,10 +368,9 @@ CONSTANT: ctx-reg 16 [ 3 ds-reg 0 LWZ ds-reg dup 4 SUBI - 5 3 quot-entry-point-offset LWZ ] -[ 5 MTLR BLRL ] -[ 5 MTCTR BCTR ] \ (call) define-combinator-primitive +[ jit-call-quot ] +[ jit-jump-quot ] \ (call) define-combinator-primitive [ 3 ds-reg 0 LWZ @@ -343,14 +389,20 @@ CONSTANT: ctx-reg 16 ! Special primitives [ + nv-reg 3 MR + + 3 vm-reg MR + "begin_callback" jit-call + jit-restore-context - ! Save ctx->callstack_bottom - 1 ctx-reg context-callstack-bottom-offset STW + ! Call quotation - 5 3 quot-entry-point-offset LWZ - 5 MTLR - BLRL + jit-call-quot + jit-save-context + + 3 vm-reg MR + "end_callback" jit-call ] \ c-to-factor define-sub-primitive [ @@ -369,9 +421,7 @@ CONSTANT: ctx-reg 16 0 MTLR ! Call quotation - 4 3 quot-entry-point-offset LWZ - 4 MTCTR - BCTR + jit-call-quot ] \ unwind-native-frames define-sub-primitive [ @@ -392,9 +442,7 @@ CONSTANT: ctx-reg 16 1 3 MR ! Call memcpy; arguments are now in the correct registers 1 1 -64 STWU - 0 2 LOAD32 "factor_memcpy" rc-absolute-ppc-2/2 jit-dlsym - 2 MTLR - BLRL + "factor_memcpy" jit-call 1 1 0 LWZ ! Return with new callstack 0 1 lr-save LWZ @@ -405,13 +453,10 @@ CONSTANT: ctx-reg 16 [ jit-save-context 4 vm-reg MR - 0 2 LOAD32 "lazy_jit_compile" rc-absolute-ppc-2/2 jit-dlsym - 2 MTLR - BLRL - 5 3 quot-entry-point-offset LWZ + "lazy_jit_compile" jit-call ] -[ 5 MTLR BLRL ] -[ 5 MTCTR BCTR ] +[ jit-call-quot ] +[ jit-jump-quot ] \ lazy-jit-compile define-combinator-primitive ! Objects @@ -665,9 +710,7 @@ CONSTANT: ctx-reg 16 [ BNO ] [ 5 vm-reg MR - 0 6 LOAD32 func rc-absolute-ppc-2/2 jit-dlsym - 6 MTLR - BLRL + func jit-call ] jit-conditional* ; @@ -689,11 +732,77 @@ CONSTANT: ctx-reg 16 [ 4 4 tag-bits get SRAWI 5 vm-reg MR - 0 6 LOAD32 "overflow_fixnum_multiply" rc-absolute-ppc-2/2 jit-dlsym - 6 MTLR - BLRL + "overflow_fixnum_multiply" jit-call ] jit-conditional* ] \ fixnum* define-sub-primitive +! Contexts +: jit-switch-context ( reg -- ) + ! Save ds, rs registers + jit-save-context + + ! Make the new context the current one + ctx-reg swap MR + ctx-reg vm-reg vm-context-offset STW + + ! Load new stack pointer + 1 ctx-reg context-callstack-top-offset LWZ + + ! Load new ds, rs registers + jit-restore-context ; + +: jit-pop-context-and-param ( -- ) + 3 ds-reg 0 LWZ + 3 3 alien-offset LWZ + 4 ds-reg -8 LWZ + ds-reg ds-reg 16 SUBI ; + +: jit-push-param ( -- ) + ds-reg ds-reg 8 ADDI + 4 ds-reg 0 STW ; + +: jit-set-context ( -- ) + jit-pop-context-and-param + 4 jit-switch-context + jit-push-param ; + +[ jit-set-context ] \ (set-context) define-sub-primitive + +: jit-pop-quot-and-param ( -- ) + 3 ds-reg 0 LWZ + 4 ds-reg -8 LWZ + ds-reg ds-reg 16 SUBI ; + +: jit-start-context ( -- ) + ! Create the new context in return-reg + 3 vm-reg MR + "new_context" jit-call + + jit-pop-quot-and-param + + 3 jit-switch-context + + jit-push-param + + jit-jump-quot ; + +[ jit-start-context ] \ (start-context) define-sub-primitive + +: jit-delete-current-context ( -- ) + jit-load-context + 3 vm-reg MR + 4 ctx-reg MR + "delete_context" jit-call ; + +[ + jit-delete-current-context + jit-set-context +] \ (set-context-and-delete) define-sub-primitive + +[ + jit-delete-current-context + jit-start-context +] \ (start-context-and-delete) define-sub-primitive + [ "bootstrap.ppc" forget-vocab ] with-compilation-unit diff --git a/vm/cpu-ppc.hpp b/vm/cpu-ppc.hpp index 6e76164308..e6244e366e 100644 --- a/vm/cpu-ppc.hpp +++ b/vm/cpu-ppc.hpp @@ -3,7 +3,7 @@ namespace factor #define FACTOR_CPU_STRING "ppc" -#define CALLSTACK_BOTTOM(ctx) (stack_frame *)ctx->callstack_seg->end +#define CALLSTACK_BOTTOM(ctx) (stack_frame *)(ctx->callstack_seg->end - 32) /* In the instruction sequence: From be514688633cf232a68065d62d146ad9a865caae Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 31 Mar 2010 07:23:19 -0500 Subject: [PATCH 511/713] Report the Win32 error code along with the error message --- basis/windows/errors/errors.factor | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) mode change 100644 => 100755 basis/windows/errors/errors.factor diff --git a/basis/windows/errors/errors.factor b/basis/windows/errors/errors.factor old mode 100644 new mode 100755 index c5dedb090a..67757d05d2 --- a/basis/windows/errors/errors.factor +++ b/basis/windows/errors/errors.factor @@ -719,8 +719,10 @@ ERROR: error-message-failed id ; : win32-error-string ( -- str ) GetLastError n>win32-error-string ; +ERROR: windows-error n string ; + : (win32-error) ( n -- ) - [ win32-error-string throw ] unless-zero ; + [ dup win32-error-string windows-error ] unless-zero ; : win32-error ( -- ) GetLastError (win32-error) ; From c49f45f051c1ae53f2c9d927bfa3c028b5e8c6c8 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 31 Mar 2010 07:24:00 -0500 Subject: [PATCH 512/713] Make literals work with aliases, add flags{ parsing word to clean boilerplate with $[ --- basis/literals/literals.factor | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/basis/literals/literals.factor b/basis/literals/literals.factor index 001c56525f..3e541a80ce 100644 --- a/basis/literals/literals.factor +++ b/basis/literals/literals.factor @@ -1,6 +1,6 @@ ! (c) Joe Groff, see license for details -USING: accessors continuations kernel parser words quotations -vectors sequences fry ; +USING: accessors combinators continuations fry kernel lexer +math parser quotations sequences vectors words words.alias ; IN: literals > call so that CONSTANT:s defined in the same file can ! be called +: expand-alias ( obj -- obj' ) + dup alias? [ def>> first expand-alias ] when ; + : expand-literal ( seq obj -- seq' ) - '[ _ dup word? [ def>> call ] when ] with-datastack ; + '[ + _ expand-alias dup word? [ def>> call ] when + ] with-datastack ; : expand-literals ( seq -- seq' ) [ [ { } ] dip expand-literal ] map concat ; @@ -19,3 +24,7 @@ PRIVATE> SYNTAX: $ scan-word expand-literal >vector ; SYNTAX: $[ parse-quotation with-datastack >vector ; SYNTAX: ${ \ } [ expand-literals ] parse-literal ; +SYNTAX: flags{ + "}" [ parse-word ] map-tokens + expand-literals + 0 [ bitor ] reduce suffix! ; From e7487bfe988c97bbc5ea75f4403f0701f6c1bbdb Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 31 Mar 2010 07:25:07 -0500 Subject: [PATCH 513/713] More constants and functions in windows.advapi32 --- basis/windows/advapi32/advapi32.factor | 346 ++++++++++++++++++++++--- 1 file changed, 310 insertions(+), 36 deletions(-) mode change 100644 => 100755 basis/windows/advapi32/advapi32.factor diff --git a/basis/windows/advapi32/advapi32.factor b/basis/windows/advapi32/advapi32.factor old mode 100644 new mode 100755 index d5fe33b745..72769971e6 --- a/basis/windows/advapi32/advapi32.factor +++ b/basis/windows/advapi32/advapi32.factor @@ -1,28 +1,9 @@ -USING: alien.c-types alien.syntax kernel math windows.types -windows.kernel32 math.bitwise classes.struct ; +USING: alien.c-types alien.syntax classes.struct kernel +literals math math.bitwise windows.kernel32 windows.types ; IN: windows.advapi32 LIBRARY: advapi32 -CONSTANT: PROV_RSA_FULL 1 -CONSTANT: PROV_RSA_SIG 2 -CONSTANT: PROV_DSS 3 -CONSTANT: PROV_FORTEZZA 4 -CONSTANT: PROV_MS_EXCHANGE 5 -CONSTANT: PROV_SSL 6 -CONSTANT: PROV_RSA_SCHANNEL 12 -CONSTANT: PROV_DSS_DH 13 -CONSTANT: PROV_EC_ECDSA_SIG 14 -CONSTANT: PROV_EC_ECNRA_SIG 15 -CONSTANT: PROV_EC_ECDSA_FULL 16 -CONSTANT: PROV_EC_ECNRA_FULL 17 -CONSTANT: PROV_DH_SCHANNEL 18 -CONSTANT: PROV_SPYRUS_LYNKS 20 -CONSTANT: PROV_RNG 21 -CONSTANT: PROV_INTEL_SEC 22 -CONSTANT: PROV_REPLACE_OWF 23 -CONSTANT: PROV_RSA_AES 24 - CONSTANT: MS_DEF_DH_SCHANNEL_PROV "Microsoft DH Schannel Cryptographic Provider" CONSTANT: MS_DEF_DSS_DH_PROV @@ -56,12 +37,6 @@ CONSTANT: MS_SCARD_PROV CONSTANT: MS_STRONG_PROV "Microsoft Strong Cryptographic Provider" -CONSTANT: CRYPT_VERIFYCONTEXT HEX: F0000000 -CONSTANT: CRYPT_NEWKEYSET HEX: 8 -CONSTANT: CRYPT_DELETEKEYSET HEX: 10 -CONSTANT: CRYPT_MACHINE_KEYSET HEX: 20 -CONSTANT: CRYPT_SILENT HEX: 40 - STRUCT: ACL { AclRevision BYTE } { Sbz1 BYTE } @@ -361,18 +336,18 @@ CONSTANT: TOKEN_IMPERSONATE HEX: 0004 CONSTANT: TOKEN_QUERY HEX: 0008 CONSTANT: TOKEN_QUERY_SOURCE HEX: 0010 CONSTANT: TOKEN_ADJUST_DEFAULT HEX: 0080 -: TOKEN_READ ( -- n ) { STANDARD_RIGHTS_READ TOKEN_QUERY } flags ; +CONSTANT: TOKEN_READ flags{ STANDARD_RIGHTS_READ TOKEN_QUERY } -: TOKEN_WRITE ( -- n ) - { +CONSTANT: TOKEN_WRITE + flags{ STANDARD_RIGHTS_WRITE TOKEN_ADJUST_PRIVILEGES TOKEN_ADJUST_GROUPS TOKEN_ADJUST_DEFAULT - } flags ; foldable + } -: TOKEN_ALL_ACCESS ( -- n ) - { +CONSTANT: TOKEN_ALL_ACCESS + flags{ STANDARD_RIGHTS_REQUIRED TOKEN_ASSIGN_PRIMARY TOKEN_DUPLICATE @@ -383,7 +358,7 @@ CONSTANT: TOKEN_ADJUST_DEFAULT HEX: 0080 TOKEN_ADJUST_GROUPS TOKEN_ADJUST_SESSIONID TOKEN_ADJUST_DEFAULT - } flags ; foldable + } CONSTANT: HKEY_CLASSES_ROOT HEX: 80000000 CONSTANT: HKEY_CURRENT_USER HEX: 80000001 @@ -426,6 +401,305 @@ CONSTANT: REG_QWORD_LITTLE_ENDIAN 11 CONSTANT: REG_CREATED_NEW_KEY 1 CONSTANT: REG_OPENED_EXISTING_KEY 2 + + +CONSTANT: ALG_CLASS_ANY 0 +CONSTANT: ALG_CLASS_SIGNATURE 8192 +CONSTANT: ALG_CLASS_MSG_ENCRYPT 16384 +CONSTANT: ALG_CLASS_DATA_ENCRYPT 24576 +CONSTANT: ALG_CLASS_HASH 32768 +CONSTANT: ALG_CLASS_KEY_EXCHANGE 40960 +CONSTANT: ALG_CLASS_ALL 57344 +CONSTANT: ALG_TYPE_ANY 0 +CONSTANT: ALG_TYPE_DSS 512 +CONSTANT: ALG_TYPE_RSA 1024 +CONSTANT: ALG_TYPE_BLOCK 1536 +CONSTANT: ALG_TYPE_STREAM 2048 +CONSTANT: ALG_TYPE_DH 2560 +CONSTANT: ALG_TYPE_SECURECHANNEL 3072 +CONSTANT: ALG_SID_ANY 0 +CONSTANT: ALG_SID_RSA_ANY 0 +CONSTANT: ALG_SID_RSA_PKCS 1 +CONSTANT: ALG_SID_RSA_MSATWORK 2 +CONSTANT: ALG_SID_RSA_ENTRUST 3 +CONSTANT: ALG_SID_RSA_PGP 4 +CONSTANT: ALG_SID_DSS_ANY 0 +CONSTANT: ALG_SID_DSS_PKCS 1 +CONSTANT: ALG_SID_DSS_DMS 2 +CONSTANT: ALG_SID_DES 1 +CONSTANT: ALG_SID_3DES 3 +CONSTANT: ALG_SID_DESX 4 +CONSTANT: ALG_SID_IDEA 5 +CONSTANT: ALG_SID_CAST 6 +CONSTANT: ALG_SID_SAFERSK64 7 +CONSTANT: ALG_SID_SAFERSK128 8 +CONSTANT: ALG_SID_3DES_112 9 +CONSTANT: ALG_SID_SKIPJACK 10 +CONSTANT: ALG_SID_TEK 11 +CONSTANT: ALG_SID_CYLINK_MEK 12 +CONSTANT: ALG_SID_RC5 13 +CONSTANT: ALG_SID_RC2 2 +CONSTANT: ALG_SID_RC4 1 +CONSTANT: ALG_SID_SEAL 2 +CONSTANT: ALG_SID_MD2 1 +CONSTANT: ALG_SID_MD4 2 +CONSTANT: ALG_SID_MD5 3 +CONSTANT: ALG_SID_SHA 4 +CONSTANT: ALG_SID_MAC 5 +CONSTANT: ALG_SID_RIPEMD 6 +CONSTANT: ALG_SID_RIPEMD160 7 +CONSTANT: ALG_SID_SSL3SHAMD5 8 +CONSTANT: ALG_SID_HMAC 9 +CONSTANT: ALG_SID_TLS1PRF 10 +CONSTANT: ALG_SID_EXAMPLE 80 + +CONSTANT: CALG_MD2 flags{ ALG_CLASS_HASH ALG_TYPE_ANY ALG_SID_MD2 } +CONSTANT: CALG_MD4 flags{ ALG_CLASS_HASH ALG_TYPE_ANY ALG_SID_MD4 } +CONSTANT: CALG_MD5 flags{ ALG_CLASS_HASH ALG_TYPE_ANY ALG_SID_MD5 } +CONSTANT: CALG_SHA flags{ ALG_CLASS_HASH ALG_TYPE_ANY ALG_SID_SHA } +CONSTANT: CALG_MAC flags{ ALG_CLASS_HASH ALG_TYPE_ANY ALG_SID_MAC } +CONSTANT: CALG_3DES flags{ ALG_CLASS_DATA_ENCRYPT ALG_TYPE_BLOCK 3 } +CONSTANT: CALG_CYLINK_MEK flags{ ALG_CLASS_DATA_ENCRYPT ALG_TYPE_BLOCK 12 } +CONSTANT: CALG_SKIPJACK flags{ ALG_CLASS_DATA_ENCRYPT ALG_TYPE_BLOCK 10 } +CONSTANT: CALG_KEA_KEYX flags{ ALG_CLASS_KEY_EXCHANGE ALG_TYPE_STREAM ALG_TYPE_DSS 4 } +CONSTANT: CALG_RSA_SIGN flags{ ALG_CLASS_SIGNATURE ALG_TYPE_RSA ALG_SID_RSA_ANY } +CONSTANT: CALG_DSS_SIGN flags{ ALG_CLASS_SIGNATURE ALG_TYPE_DSS ALG_SID_DSS_ANY } +CONSTANT: CALG_RSA_KEYX flags{ ALG_CLASS_KEY_EXCHANGE ALG_TYPE_RSA ALG_SID_RSA_ANY } +CONSTANT: CALG_DES flags{ ALG_CLASS_DATA_ENCRYPT ALG_TYPE_BLOCK ALG_SID_DES } +CONSTANT: CALG_RC2 flags{ ALG_CLASS_DATA_ENCRYPT ALG_TYPE_BLOCK ALG_SID_RC2 } +CONSTANT: CALG_RC4 flags{ ALG_CLASS_DATA_ENCRYPT ALG_TYPE_STREAM ALG_SID_RC4 } +CONSTANT: CALG_SEAL flags{ ALG_CLASS_DATA_ENCRYPT ALG_TYPE_STREAM ALG_SID_SEAL } +CONSTANT: CALG_DH_EPHEM flags{ ALG_CLASS_KEY_EXCHANGE ALG_TYPE_STREAM ALG_TYPE_DSS ALG_SID_DSS_DMS } +CONSTANT: CALG_DESX flags{ ALG_CLASS_DATA_ENCRYPT ALG_TYPE_BLOCK ALG_SID_DESX } +! CONSTANT: CALG_TLS1PRF flags{ ALG_CLASS_DHASH ALG_TYPE_ANY ALG_SID_TLS1PRF } + +CONSTANT: CRYPT_VERIFYCONTEXT HEX: F0000000 +CONSTANT: CRYPT_NEWKEYSET 8 +CONSTANT: CRYPT_DELETEKEYSET 16 +CONSTANT: CRYPT_MACHINE_KEYSET 32 +CONSTANT: CRYPT_SILENT 64 +CONSTANT: CRYPT_EXPORTABLE 1 +CONSTANT: CRYPT_USER_PROTECTED 2 +CONSTANT: CRYPT_CREATE_SALT 4 +CONSTANT: CRYPT_UPDATE_KEY 8 +CONSTANT: AT_KEYEXCHANGE 1 +CONSTANT: AT_SIGNATURE 2 +CONSTANT: CRYPT_USERDATA 1 +CONSTANT: KP_IV 1 +CONSTANT: KP_SALT 2 +CONSTANT: KP_PADDING 3 +CONSTANT: KP_MODE 4 +CONSTANT: KP_MODE_BITS 5 +CONSTANT: KP_PERMISSIONS 6 +CONSTANT: KP_ALGID 7 +CONSTANT: KP_BLOCKLEN 8 +CONSTANT: PKCS5_PADDING 1 +CONSTANT: CRYPT_MODE_CBC 1 +CONSTANT: CRYPT_MODE_ECB 2 +CONSTANT: CRYPT_MODE_OFB 3 +CONSTANT: CRYPT_MODE_CFB 4 +CONSTANT: CRYPT_MODE_CTS 5 +CONSTANT: CRYPT_MODE_CBCI 6 +CONSTANT: CRYPT_MODE_CFBP 7 +CONSTANT: CRYPT_MODE_OFBP 8 +CONSTANT: CRYPT_MODE_CBCOFM 9 +CONSTANT: CRYPT_MODE_CBCOFMI 10 +CONSTANT: CRYPT_ENCRYPT 1 +CONSTANT: CRYPT_DECRYPT 2 +CONSTANT: CRYPT_EXPORT 4 +CONSTANT: CRYPT_READ 8 +CONSTANT: CRYPT_WRITE 16 +CONSTANT: CRYPT_MAC 32 +CONSTANT: HP_ALGID 1 +CONSTANT: HP_HASHVAL 2 +CONSTANT: HP_HASHSIZE 4 +CONSTANT: PP_ENUMALGS 1 +CONSTANT: PP_ENUMCONTAINERS 2 +CONSTANT: PP_IMPTYPE 3 +CONSTANT: PP_NAME 4 +CONSTANT: PP_VERSION 5 +CONSTANT: PP_CONTAINER 6 +CONSTANT: PP_ENUMMANDROOTS 25 +CONSTANT: PP_ENUMELECTROOTS 26 +CONSTANT: PP_KEYSET_TYPE 27 +CONSTANT: PP_ADMIN_PIN 31 +CONSTANT: PP_KEYEXCHANGE_PIN 32 +CONSTANT: PP_SIGNATURE_PIN 33 +CONSTANT: PP_SIG_KEYSIZE_INC 34 +CONSTANT: PP_KEYX_KEYSIZE_INC 35 +CONSTANT: PP_UNIQUE_CONTAINER 36 +CONSTANT: PP_SGC_INFO 37 +CONSTANT: PP_USE_HARDWARE_RNG 38 +CONSTANT: PP_KEYSPEC 39 +CONSTANT: PP_ENUMEX_SIGNING_PROT 40 +CONSTANT: CRYPT_FIRST 1 +CONSTANT: CRYPT_NEXT 2 +CONSTANT: CRYPT_IMPL_HARDWARE 1 +CONSTANT: CRYPT_IMPL_SOFTWARE 2 +CONSTANT: CRYPT_IMPL_MIXED 3 +CONSTANT: CRYPT_IMPL_UNKNOWN 4 +CONSTANT: PROV_RSA_FULL 1 +CONSTANT: PROV_RSA_SIG 2 +CONSTANT: PROV_DSS 3 +CONSTANT: PROV_FORTEZZA 4 +CONSTANT: PROV_MS_MAIL 5 +CONSTANT: PROV_SSL 6 +CONSTANT: PROV_STT_MER 7 +CONSTANT: PROV_STT_ACQ 8 +CONSTANT: PROV_STT_BRND 9 +CONSTANT: PROV_STT_ROOT 10 +CONSTANT: PROV_STT_ISS 11 +CONSTANT: PROV_RSA_SCHANNEL 12 +CONSTANT: PROV_DSS_DH 13 +CONSTANT: PROV_EC_ECDSA_SIG 14 +CONSTANT: PROV_EC_ECNRA_SIG 15 +CONSTANT: PROV_EC_ECDSA_FULL 16 +CONSTANT: PROV_EC_ECNRA_FULL 17 +CONSTANT: PROV_DH_SCHANNEL 18 +CONSTANT: PROV_SPYRUS_LYNKS 20 +CONSTANT: PROV_RNG 21 +CONSTANT: PROV_INTEL_SEC 22 +CONSTANT: PROV_REPLACE_OWF 23 +CONSTANT: PROV_RSA_AES 24 +CONSTANT: MAXUIDLEN 64 +CONSTANT: CUR_BLOB_VERSION 2 +CONSTANT: X509_ASN_ENCODING 1 +CONSTANT: PKCS_7_ASN_ENCODING 65536 +CONSTANT: CERT_V1 0 +CONSTANT: CERT_V2 1 +CONSTANT: CERT_V3 2 +CONSTANT: CERT_E_CHAINING -2146762486 +CONSTANT: CERT_E_CN_NO_MATCH -2146762481 +CONSTANT: CERT_E_EXPIRED -2146762495 +CONSTANT: CERT_E_PURPOSE -2146762490 +CONSTANT: CERT_E_REVOCATION_FAILURE -2146762482 +CONSTANT: CERT_E_REVOKED -2146762484 +CONSTANT: CERT_E_ROLE -2146762493 +CONSTANT: CERT_E_UNTRUSTEDROOT -2146762487 +CONSTANT: CERT_E_UNTRUSTEDTESTROOT -2146762483 +CONSTANT: CERT_E_VALIDITYPERIODNESTING -2146762494 +CONSTANT: CERT_E_WRONG_USAGE -2146762480 +CONSTANT: CERT_E_PATHLENCONST -2146762492 +CONSTANT: CERT_E_CRITICAL -2146762491 +CONSTANT: CERT_E_ISSUERCHAINING -2146762489 +CONSTANT: CERT_E_MALFORMED -2146762488 +CONSTANT: CRYPT_E_REVOCATION_OFFLINE -2146885613 +CONSTANT: CRYPT_E_REVOKED -2146885616 +CONSTANT: TRUST_E_BASIC_CONSTRAINTS -2146869223 +CONSTANT: TRUST_E_CERT_SIGNATURE -2146869244 +CONSTANT: TRUST_E_FAIL -2146762485 +CONSTANT: CERT_TRUST_NO_ERROR 0 +CONSTANT: CERT_TRUST_IS_NOT_TIME_VALID 1 +CONSTANT: CERT_TRUST_IS_NOT_TIME_NESTED 2 +CONSTANT: CERT_TRUST_IS_REVOKED 4 +CONSTANT: CERT_TRUST_IS_NOT_SIGNATURE_VALID 8 +CONSTANT: CERT_TRUST_IS_NOT_VALID_FOR_USAGE 16 +CONSTANT: CERT_TRUST_IS_UNTRUSTED_ROOT 32 +CONSTANT: CERT_TRUST_REVOCATION_STATUS_UNKNOWN 64 +CONSTANT: CERT_TRUST_IS_CYCLIC 128 +CONSTANT: CERT_TRUST_IS_PARTIAL_CHAIN 65536 +CONSTANT: CERT_TRUST_CTL_IS_NOT_TIME_VALID 131072 +CONSTANT: CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID 262144 +CONSTANT: CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE 524288 +CONSTANT: CERT_TRUST_HAS_EXACT_MATCH_ISSUER 1 +CONSTANT: CERT_TRUST_HAS_KEY_MATCH_ISSUER 2 +CONSTANT: CERT_TRUST_HAS_NAME_MATCH_ISSUER 4 +CONSTANT: CERT_TRUST_IS_SELF_SIGNED 8 +CONSTANT: CERT_TRUST_IS_COMPLEX_CHAIN 65536 +CONSTANT: CERT_CHAIN_POLICY_BASE 1 +CONSTANT: CERT_CHAIN_POLICY_AUTHENTICODE 2 +CONSTANT: CERT_CHAIN_POLICY_AUTHENTICODE_TS 3 +CONSTANT: CERT_CHAIN_POLICY_SSL 4 +CONSTANT: CERT_CHAIN_POLICY_BASIC_CONSTRAINTS 5 +CONSTANT: CERT_CHAIN_POLICY_NT_AUTH 6 +CONSTANT: USAGE_MATCH_TYPE_AND 0 +CONSTANT: USAGE_MATCH_TYPE_OR 1 +CONSTANT: CERT_SIMPLE_NAME_STR 1 +CONSTANT: CERT_OID_NAME_STR 2 +CONSTANT: CERT_X500_NAME_STR 3 +CONSTANT: CERT_NAME_STR_SEMICOLON_FLAG 1073741824 +CONSTANT: CERT_NAME_STR_CRLF_FLAG 134217728 +CONSTANT: CERT_NAME_STR_NO_PLUS_FLAG 536870912 +CONSTANT: CERT_NAME_STR_NO_QUOTING_FLAG 268435456 +CONSTANT: CERT_NAME_STR_REVERSE_FLAG 33554432 +CONSTANT: CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG 131072 +CONSTANT: CERT_FIND_ANY 0 +CONSTANT: CERT_FIND_CERT_ID 1048576 +CONSTANT: CERT_FIND_CTL_USAGE 655360 +CONSTANT: CERT_FIND_ENHKEY_USAGE 655360 +CONSTANT: CERT_FIND_EXISTING 851968 +CONSTANT: CERT_FIND_HASH 65536 +CONSTANT: CERT_FIND_ISSUER_ATTR 196612 +CONSTANT: CERT_FIND_ISSUER_NAME 131076 +CONSTANT: CERT_FIND_ISSUER_OF 786432 +CONSTANT: CERT_FIND_KEY_IDENTIFIER 983040 +CONSTANT: CERT_FIND_KEY_SPEC 589824 +CONSTANT: CERT_FIND_MD5_HASH 262144 +CONSTANT: CERT_FIND_PROPERTY 327680 +CONSTANT: CERT_FIND_PUBLIC_KEY 393216 +CONSTANT: CERT_FIND_SHA1_HASH 65536 +CONSTANT: CERT_FIND_SIGNATURE_HASH 917504 +CONSTANT: CERT_FIND_SUBJECT_ATTR 196615 +CONSTANT: CERT_FIND_SUBJECT_CERT 720896 +CONSTANT: CERT_FIND_SUBJECT_NAME 131079 +CONSTANT: CERT_FIND_SUBJECT_STR_A 458759 +CONSTANT: CERT_FIND_SUBJECT_STR_W 524295 +CONSTANT: CERT_FIND_ISSUER_STR_A 458756 +CONSTANT: CERT_FIND_ISSUER_STR_W 524292 +CONSTANT: CERT_FIND_OR_ENHKEY_USAGE_FLAG 16 +CONSTANT: CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG 1 +CONSTANT: CERT_FIND_NO_ENHKEY_USAGE_FLAG 8 +CONSTANT: CERT_FIND_VALID_ENHKEY_USAGE_FLAG 32 +CONSTANT: CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG 2 +CONSTANT: CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG 2 +CONSTANT: CERT_UNICODE_IS_RDN_ATTRS_FLAG 1 +CONSTANT: CERT_CHAIN_FIND_BY_ISSUER 1 +CONSTANT: CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG 1 +CONSTANT: CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG 2 +CONSTANT: CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG 32768 +CONSTANT: CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG 4 +CONSTANT: CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG 8 +CONSTANT: CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG 16384 +CONSTANT: CERT_STORE_PROV_SYSTEM 10 +CONSTANT: CERT_SYSTEM_STORE_LOCAL_MACHINE 131072 +CONSTANT: szOID_PKIX_KP_SERVER_AUTH "4235600" +CONSTANT: szOID_SERVER_GATED_CRYPTO "4235658" +CONSTANT: szOID_SGC_NETSCAPE "2.16.840.1.113730.4.1" +CONSTANT: szOID_PKIX_KP_CLIENT_AUTH "1.3.6.1.5.5.7.3.2" + +CONSTANT: CRYPT_NOHASHOID HEX: 00000001 +CONSTANT: CRYPT_NO_SALT HEX: 10 +CONSTANT: CRYPT_PREGEN HEX: 40 +CONSTANT: CRYPT_RECIPIENT HEX: 10 +CONSTANT: CRYPT_INITIATOR HEX: 40 +CONSTANT: CRYPT_ONLINE HEX: 80 +CONSTANT: CRYPT_SF HEX: 100 +CONSTANT: CRYPT_CREATE_IV HEX: 200 +CONSTANT: CRYPT_KEK HEX: 400 +CONSTANT: CRYPT_DATA_KEY HEX: 800 +CONSTANT: CRYPT_VOLATILE HEX: 1000 +CONSTANT: CRYPT_SGCKEY HEX: 2000 + +CONSTANT: KEYSTATEBLOB HEX: C +CONSTANT: OPAQUEKEYBLOB HEX: 9 +CONSTANT: PLAINTEXTKEYBLOB HEX: 8 +CONSTANT: PRIVATEKEYBLOB HEX: 7 +CONSTANT: PUBLICKEYBLOB HEX: 6 +CONSTANT: PUBLICKEYBLOBEX HEX: A +CONSTANT: SIMPLEBLOB HEX: 1 +CONSTANT: SYMMETRICWRAPKEYBLOB HEX: B + +TYPEDEF: uint ALG_ID + +STRUCT: PUBLICKEYSTRUC + { bType BYTE } + { bVersion BYTE } + { reserved WORD } + { aiKeyAlg ALG_ID } ; + +TYPEDEF: PUBLICKEYSTRUC BLOBHEADER +TYPEDEF: LONG HCRYPTHASH +TYPEDEF: LONG HCRYPTKEY TYPEDEF: DWORD REGSAM ! : I_ScGetCurrentGroupStateW ; @@ -590,7 +864,7 @@ FUNCTION: BOOL CryptAcquireContextW ( HCRYPTPROV* phProv, ALIAS: CryptAcquireContext CryptAcquireContextW ! : CryptContextAddRef ; -! : CryptCreateHash ; +FUNCTION: BOOL CryptCreateHash ( HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *pHash ) ; ! : CryptDecrypt ; ! : CryptDeriveKey ; ! : CryptDestroyHash ; @@ -613,7 +887,7 @@ FUNCTION: BOOL CryptGenRandom ( HCRYPTPROV hProv, DWORD dwLen, BYTE* pbBuffer ) ! : CryptGetUserKey ; ! : CryptHashData ; ! : CryptHashSessionKey ; -! : CryptImportKey ; +FUNCTION: BOOL CryptImportKey ( HCRYPTPROV hProv, BYTE *pbData, DWORD dwDataLen, HCRYPTKEY hPubKey, DWORD dwFlags, HCRYPTKEY *phKey ) ; FUNCTION: BOOL CryptReleaseContext ( HCRYPTPROV hProv, DWORD dwFlags ) ; ! : CryptSetHashParam ; ! : CryptSetKeyParam ; From 077e5dea2ad4fb860fa2c01eff7566bc9f3cec5e Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 20 Mar 2010 18:38:23 -0500 Subject: [PATCH 514/713] Always do a leap year check when adding timestamps --- basis/calendar/calendar-tests.factor | 10 ++++++++++ basis/calendar/calendar.factor | 14 +++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/basis/calendar/calendar-tests.factor b/basis/calendar/calendar-tests.factor index 2490b87c37..3f52b4d2e7 100644 --- a/basis/calendar/calendar-tests.factor +++ b/basis/calendar/calendar-tests.factor @@ -176,3 +176,13 @@ IN: calendar.tests [ t ] [ 1356998399 unix-time>timestamp 2013 1 seconds time- = ] unit-test [ t ] [ 1500000000 random [ unix-time>timestamp timestamp>unix-time ] keep = ] unit-test + +[ t ] [ + 2009 1 29 1 months time+ + 2009 3 1 = +] unit-test + +[ t ] [ + 2008 1 29 1 months time+ + 2008 2 29 = +] unit-test diff --git a/basis/calendar/calendar.factor b/basis/calendar/calendar.factor index cd87701aa9..8758b8198b 100644 --- a/basis/calendar/calendar.factor +++ b/basis/calendar/calendar.factor @@ -99,12 +99,12 @@ CONSTANT: day-abbreviations3 : day-abbreviation3 ( n -- string ) day-abbreviations3 nth ; inline -: average-month ( -- ratio ) 30+5/12 ; inline -: months-per-year ( -- integer ) 12 ; inline -: days-per-year ( -- ratio ) 3652425/10000 ; inline -: hours-per-year ( -- ratio ) 876582/100 ; inline -: minutes-per-year ( -- ratio ) 5259492/10 ; inline -: seconds-per-year ( -- integer ) 31556952 ; inline +CONSTANT: average-month 30+5/12 +CONSTANT: months-per-year 12 +CONSTANT: days-per-year 3652425/10000 +CONSTANT: hours-per-year 876582/100 +CONSTANT: minutes-per-year 5259492/10 +CONSTANT: seconds-per-year 31556952 :: julian-day-number ( year month day -- n ) #! Returns a composite date number @@ -200,7 +200,7 @@ GENERIC: +second ( timestamp x -- timestamp ) [ 3 >>month 1 >>day ] when ; M: integer +year ( timestamp n -- timestamp ) - [ [ + ] curry change-year adjust-leap-year ] unless-zero ; + [ + ] curry change-year adjust-leap-year ; M: real +year ( timestamp n -- timestamp ) [ float>whole-part swapd days-per-year * +day swap +year ] unless-zero ; From b39e3f47007535b31f305c9e956ac746a4e7b552 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 24 Mar 2010 03:04:48 -0500 Subject: [PATCH 515/713] Link a word in math docs --- basis/math/bitwise/bitwise-docs.factor | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/basis/math/bitwise/bitwise-docs.factor b/basis/math/bitwise/bitwise-docs.factor index bbc72d99e4..ee94479b46 100644 --- a/basis/math/bitwise/bitwise-docs.factor +++ b/basis/math/bitwise/bitwise-docs.factor @@ -375,6 +375,10 @@ $nl bit? bit-clear? } +"Toggling a bit:" +{ $subsections + toggle-bit +} "Operations with bitmasks:" { $subsections mask From dc52f177f529ca31277db3cd812a3a8708db3525 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 24 Mar 2010 17:52:28 -0500 Subject: [PATCH 516/713] Add utiltity words for io.files.unique --- basis/io/files/unique/unique-docs.factor | 20 +++++++++++++++----- basis/io/files/unique/unique.factor | 15 +++++++++++---- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/basis/io/files/unique/unique-docs.factor b/basis/io/files/unique/unique-docs.factor index a2051bd10a..7e8d166b32 100644 --- a/basis/io/files/unique/unique-docs.factor +++ b/basis/io/files/unique/unique-docs.factor @@ -54,12 +54,19 @@ HELP: with-unique-directory } { $description "Creates a directory with " { $link unique-directory } " and calls the quotation with the pathname on the stack using the " { $link with-temporary-directory } " combinator. The quotation can access the " { $link current-temporary-directory } " symbol for the name of the temporary directory. Subsequent unique files will be created in this unique directory until the combinator returns." } ; -HELP: move-file-unique +HELP: copy-file-unique { $values - { "path" "a pathname string" } { "directory" "a directory" } + { "path" "a pathname string" } { "prefix" string } { "suffix" string } { "path'" "a pathname string" } } -{ $description "Moves " { $snippet "path" } " to " { $snippet "directory" } " by creating a unique file in this directory. Returns the new path." } ; +{ $description "Copies " { $snippet "path" } " to a new unique file in the directory stored in " { $link current-temporary-directory } ". Returns the new path." } ; + +HELP: move-file-unique +{ $values + { "path" "a pathname string" } { "prefix" string } { "suffix" string } + { "path'" "a pathname string" } +} +{ $description "Moves " { $snippet "path" } " to a new unique file in the directory stored in " { $link current-temporary-directory } ". Returns the new path." } ; HELP: current-temporary-directory { $values @@ -98,7 +105,10 @@ ARTICLE: "io.files.unique" "Unique files" } "Default temporary directory:" { $subsections default-temporary-directory } -"Moving files into a directory safely:" -{ $subsections move-file-unique } ; +"Copying and moving files to a new unique file:" +{ $subsections + copy-file-unique + move-file-unique +} ; ABOUT: "io.files.unique" diff --git a/basis/io/files/unique/unique.factor b/basis/io/files/unique/unique.factor index 07f7b25140..5bf89b9520 100644 --- a/basis/io/files/unique/unique.factor +++ b/basis/io/files/unique/unique.factor @@ -70,10 +70,17 @@ PRIVATE> : unique-file ( prefix -- path ) "" make-unique-file ; -: move-file-unique ( path directory -- path' ) - [ - "" unique-file [ move-file ] keep - ] with-temporary-directory ; +: move-file-unique ( path prefix suffix -- path' ) + make-unique-file [ move-file ] keep ; + +: copy-file-unique ( path prefix suffix -- path' ) + make-unique-file [ copy-file ] keep ; + +: temporary-file ( -- path ) "" unique-file ; + +: with-working-directory ( path quot -- ) + over make-directories + dupd '[ _ _ with-temporary-directory ] with-directory ; inline { { [ os unix? ] [ "io.files.unique.unix" ] } From 0569f08ea272b5ada1d648abc252382eaf2ad012 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 31 Mar 2010 17:37:22 -0500 Subject: [PATCH 517/713] Fix calendar docs --- basis/calendar/calendar-docs.factor | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/basis/calendar/calendar-docs.factor b/basis/calendar/calendar-docs.factor index 6ce8b1d5fd..a5a31ebd65 100644 --- a/basis/calendar/calendar-docs.factor +++ b/basis/calendar/calendar-docs.factor @@ -76,27 +76,27 @@ HELP: day-abbreviation3 } related-words HELP: average-month -{ $values { "ratio" ratio } } +{ $values { "value" ratio } } { $description "The length of an average month averaged over 400 years. Used internally for adding an arbitrary real number of months to a timestamp." } ; HELP: months-per-year -{ $values { "integer" integer } } +{ $values { "value" integer } } { $description "Returns the number of months in a year." } ; HELP: days-per-year -{ $values { "ratio" ratio } } +{ $values { "value" ratio } } { $description "Returns the number of days in a year averaged over 400 years. Used internally for adding an arbitrary real number of days to a timestamp." } ; HELP: hours-per-year -{ $values { "ratio" ratio } } +{ $values { "value" ratio } } { $description "Returns the number of hours in a year averaged over 400 years. Used internally for adding an arbitrary real number of hours to a timestamp." } ; HELP: minutes-per-year -{ $values { "ratio" ratio } } +{ $values { "value" ratio } } { $description "Returns the number of minutes in a year averaged over 400 years. Used internally for adding an arbitrary real number of minutes to a timestamp." } ; HELP: seconds-per-year -{ $values { "integer" integer } } +{ $values { "value" integer } } { $description "Returns the number of seconds in a year averaged over 400 years. Used internally for adding an arbitrary real number of seconds to a timestamp." } ; HELP: julian-day-number From ef53e6ecd576641b71f71409889b64ab84585e02 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 31 Mar 2010 17:06:50 -0400 Subject: [PATCH 518/713] cpu.x86.64: eliminate useless instruction from primitive call sequence for a marginal to non-existent gain --- basis/cpu/x86/32/bootstrap.factor | 3 ++- basis/cpu/x86/64/bootstrap.factor | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/basis/cpu/x86/32/bootstrap.factor b/basis/cpu/x86/32/bootstrap.factor index 15a7dc1c29..a428a66ace 100644 --- a/basis/cpu/x86/32/bootstrap.factor +++ b/basis/cpu/x86/32/bootstrap.factor @@ -63,12 +63,13 @@ IN: bootstrap.x86 rs-reg ctx-reg context-retainstack-offset [+] MOV ; [ + ! ctx-reg is preserved across the call because it is non-volatile + ! in the C ABI jit-load-vm jit-save-context ! call the primitive ESP [] vm-reg MOV 0 CALL rc-relative rt-dlsym jit-rel - ! restore ds, rs registers jit-restore-context ] jit-primitive jit-define diff --git a/basis/cpu/x86/64/bootstrap.factor b/basis/cpu/x86/64/bootstrap.factor index 2f03823d45..4cd2d8104b 100644 --- a/basis/cpu/x86/64/bootstrap.factor +++ b/basis/cpu/x86/64/bootstrap.factor @@ -57,11 +57,12 @@ IN: bootstrap.x86 ctx-reg context-retainstack-offset [+] rs-reg MOV ; : jit-restore-context ( -- ) - jit-load-context ds-reg ctx-reg context-datastack-offset [+] MOV rs-reg ctx-reg context-retainstack-offset [+] MOV ; [ + ! ctx-reg is preserved across the call because it is non-volatile + ! in the C ABI jit-save-context ! call the primitive arg1 vm-reg MOV @@ -80,6 +81,7 @@ IN: bootstrap.x86 arg1 vm-reg MOV "begin_callback" jit-call + jit-load-context jit-restore-context ! call the quotation @@ -115,6 +117,7 @@ IN: bootstrap.x86 vm-reg 0 MOV 0 rc-absolute-cell jit-vm ! Load ds and rs registers + jit-load-context jit-restore-context ! Call quotation @@ -168,6 +171,7 @@ IN: bootstrap.x86 arg1 RBX MOV arg2 vm-reg MOV "inline_cache_miss" jit-call + jit-load-context jit-restore-context ; [ jit-load-return-address jit-inline-cache-miss ] From 7d24459bb8a21bf4920386d93df1cf83a8ef3ae0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 31 Mar 2010 20:47:13 -0400 Subject: [PATCH 519/713] cpu.x86.assembler: add segment override prefixes --- basis/cpu/x86/assembler/assembler-tests.factor | 2 ++ basis/cpu/x86/assembler/assembler.factor | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/basis/cpu/x86/assembler/assembler-tests.factor b/basis/cpu/x86/assembler/assembler-tests.factor index 531110da7b..0a6ae5a484 100644 --- a/basis/cpu/x86/assembler/assembler-tests.factor +++ b/basis/cpu/x86/assembler/assembler-tests.factor @@ -164,3 +164,5 @@ IN: cpu.x86.assembler.tests [ { 15 183 195 } ] [ [ EAX BX MOVZX ] { } make ] unit-test +[ { 100 199 5 0 0 0 0 123 0 0 0 } ] [ [ 0 [] FS 123 MOV ] { } make ] unit-test + diff --git a/basis/cpu/x86/assembler/assembler.factor b/basis/cpu/x86/assembler/assembler.factor index b075b121a5..32eeaaad1d 100644 --- a/basis/cpu/x86/assembler/assembler.factor +++ b/basis/cpu/x86/assembler/assembler.factor @@ -188,6 +188,13 @@ M: register displacement, drop ; PRIVATE> +! Segment override prefixes +: CS ( -- ) HEX: 2e , ; +: ES ( -- ) HEX: 26 , ; +: SS ( -- ) HEX: 36 , ; +: FS ( -- ) HEX: 64 , ; +: GS ( -- ) HEX: 65 , ; + ! Moving stuff GENERIC: PUSH ( op -- ) M: register PUSH f HEX: 50 short-operand ; From 565e3383abf5a62232847828fbe8ad4127d5bade Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 31 Mar 2010 19:17:06 -0700 Subject: [PATCH 520/713] add singletons for stdcall, cdecl, mingw abis --- core/alien/alien.factor | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/alien/alien.factor b/core/alien/alien.factor index a44d703fbc..7a539d4dd5 100644 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -5,6 +5,10 @@ kernel.private byte-arrays byte-vectors arrays init continuations.private ; IN: alien +SINGLETONS: stdcall cdecl mingw ; + +UNION: abi stdcall cdecl mingw ; + PREDICATE: pinned-alien < alien underlying>> not ; UNION: pinned-c-ptr pinned-alien POSTPONE: f ; From 65c32597614224e6857832565cab037ee33fee36 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 31 Mar 2010 19:20:35 -0700 Subject: [PATCH 521/713] "cdecl" -> cdecl --- basis/alien/fortran/fortran.factor | 14 ++--- basis/alien/libraries/libraries-docs.factor | 4 +- basis/alien/libraries/libraries.factor | 2 +- .../remote-control/remote-control.factor | 6 +- basis/cairo/ffi/ffi.factor | 10 ++-- basis/cocoa/subclassing/subclassing.factor | 2 +- .../compiler/cfg/builder/builder-tests.factor | 4 +- basis/compiler/tests/alien.factor | 56 +++++++++---------- basis/compiler/tests/redefine24.factor | 4 +- basis/compression/zlib/ffi/ffi.factor | 2 +- .../core-foundation/run-loop/run-loop.factor | 2 +- basis/cpu/x86/32/32-tests.factor | 2 +- basis/cpu/x86/64/64-tests.factor | 4 +- basis/cpu/x86/features/features.factor | 6 +- basis/db/postgresql/ffi/ffi.factor | 2 +- basis/db/sqlite/ffi/ffi.factor | 2 +- basis/glib/glib.factor | 8 +-- .../multiplexers/run-loop/run-loop.factor | 2 +- .../io/sockets/secure/openssl/openssl.factor | 2 +- basis/math/floats/env/x86/32/32.factor | 8 +-- basis/math/floats/env/x86/64/64.factor | 8 +-- basis/opengl/gl/macosx/macosx.factor | 2 +- basis/opengl/gl/unix/unix.factor | 2 +- basis/openssl/libcrypto/libcrypto.factor | 6 +- basis/openssl/libssl/libssl.factor | 6 +- basis/pango/cairo/cairo.factor | 4 +- basis/pango/pango.factor | 4 +- basis/tools/deploy/test/9/9.factor | 4 +- basis/tools/disassembler/udis/udis.factor | 2 +- basis/tools/profiler/profiler-tests.factor | 4 +- basis/unix/ffi/ffi.factor | 2 +- basis/windows/nt/nt.factor | 4 +- extra/benchmark/fib6/fib6.factor | 4 +- extra/chipmunk/ffi/ffi.factor | 2 +- extra/curses/ffi/ffi.factor | 2 +- extra/cursors/cursors-tests.factor | 6 +- extra/freetype/freetype.factor | 4 +- extra/libusb/libusb.factor | 2 +- extra/llvm/core/core.factor | 2 +- extra/llvm/invoker/invoker.factor | 2 +- extra/ogg/ogg.factor | 2 +- extra/ogg/theora/theora.factor | 4 +- extra/ogg/vorbis/vorbis.factor | 2 +- extra/openal/alut/alut.factor | 2 +- extra/openal/openal.factor | 2 +- extra/opengl/glu/glu.factor | 2 +- extra/tokyo/alien/tcrdb/tcrdb.factor | 2 +- extra/tokyo/alien/tcutil/tcutil.factor | 2 +- unmaintained/alien/inline/inline.factor | 2 +- unmaintained/cryptlib/libcl/libcl.factor | 4 +- unmaintained/db/mysql/ffi/ffi.factor | 4 +- unmaintained/jni/jni-internals.factor | 24 ++++---- unmaintained/ldap/libldap/libldap.factor | 4 +- unmaintained/lint/lint.factor | 2 +- unmaintained/oracle/liboci/liboci.factor | 4 +- unmaintained/pdf/libhpdf/libhpdf.factor | 4 +- 56 files changed, 142 insertions(+), 138 deletions(-) diff --git a/basis/alien/fortran/fortran.factor b/basis/alien/fortran/fortran.factor index 9255c66c9f..8c74aa102a 100644 --- a/basis/alien/fortran/fortran.factor +++ b/basis/alien/fortran/fortran.factor @@ -13,8 +13,8 @@ SINGLETONS: f2c-abi g95-abi gfortran-abi intel-unix-abi intel-windows-abi ; << : add-f2c-libraries ( -- ) - "I77" "libI77.so" "cdecl" add-library - "F77" "libF77.so" "cdecl" add-library ; + "I77" "libI77.so" cdecl add-library + "F77" "libF77.so" cdecl add-library ; os netbsd? [ add-f2c-libraries ] when >> @@ -42,11 +42,11 @@ library-fortran-abis [ H{ } clone ] initialize [ "__" append ] [ "_" append ] if ; HOOK: fortran-c-abi fortran-abi ( -- abi ) -M: f2c-abi fortran-c-abi "cdecl" ; -M: g95-abi fortran-c-abi "cdecl" ; -M: gfortran-abi fortran-c-abi "cdecl" ; -M: intel-unix-abi fortran-c-abi "cdecl" ; -M: intel-windows-abi fortran-c-abi "cdecl" ; +M: f2c-abi fortran-c-abi cdecl ; +M: g95-abi fortran-c-abi cdecl ; +M: gfortran-abi fortran-c-abi cdecl ; +M: intel-unix-abi fortran-c-abi cdecl ; +M: intel-windows-abi fortran-c-abi cdecl ; HOOK: real-functions-return-double? fortran-abi ( -- ? ) M: f2c-abi real-functions-return-double? t ; diff --git a/basis/alien/libraries/libraries-docs.factor b/basis/alien/libraries/libraries-docs.factor index 59142733b9..be1a7c7ad6 100644 --- a/basis/alien/libraries/libraries-docs.factor +++ b/basis/alien/libraries/libraries-docs.factor @@ -6,7 +6,7 @@ IN: alien.libraries HELP: { $values - { "path" "a pathname string" } { "abi" "the ABI used by the library, either " { $snippet "cdecl" } " or " { $snippet "stdcall" } } + { "path" "a pathname string" } { "abi" "the ABI used by the library, either " { $snippet cdecl } " or " { $snippet "stdcall" } } { "library" library } } { $description "Opens a C library using the path and ABI parameters and outputs a library tuple." } { $notes "User code should use " { $link add-library } " so that the opened library is added to a global hashtable, " { $link libraries } "." } ; @@ -19,7 +19,7 @@ HELP: library { $description "Looks up a library by its logical name. The library object is a hashtable with the following keys:" { $list { { $snippet "name" } " - the full path of the C library binary" } - { { $snippet "abi" } " - the ABI used by the library, either " { $snippet "cdecl" } " or " { $snippet "stdcall" } } + { { $snippet "abi" } " - the ABI used by the library, either " { $snippet cdecl } " or " { $snippet "stdcall" } } { { $snippet "dll" } " - an instance of the " { $link dll } " class; only set if the library is loaded" } } } ; diff --git a/basis/alien/libraries/libraries.factor b/basis/alien/libraries/libraries.factor index 47e34fe5ff..5a042fd436 100644 --- a/basis/alien/libraries/libraries.factor +++ b/basis/alien/libraries/libraries.factor @@ -36,7 +36,7 @@ M: library dispose dll>> [ dispose ] when* ; [ swap libraries get set-at ] 3bi ; : library-abi ( library -- abi ) - library [ abi>> ] [ "cdecl" ] if* ; + library [ abi>> ] [ cdecl ] if* ; SYMBOL: deploy-libraries diff --git a/basis/alien/remote-control/remote-control.factor b/basis/alien/remote-control/remote-control.factor index c305d720f0..5090280945 100644 --- a/basis/alien/remote-control/remote-control.factor +++ b/basis/alien/remote-control/remote-control.factor @@ -6,14 +6,14 @@ eval ; IN: alien.remote-control : eval-callback ( -- callback ) - void* { c-string } "cdecl" + void* { c-string } cdecl [ eval>string utf8 malloc-string ] alien-callback ; : yield-callback ( -- callback ) - void { } "cdecl" [ yield ] alien-callback ; + void { } cdecl [ yield ] alien-callback ; : sleep-callback ( -- callback ) - void { long } "cdecl" [ sleep ] alien-callback ; + void { long } cdecl [ sleep ] alien-callback ; : ?callback ( word -- alien ) dup optimized? [ execute ] [ drop f ] if ; inline diff --git a/basis/cairo/ffi/ffi.factor b/basis/cairo/ffi/ffi.factor index c4700d2dad..2ff688c456 100644 --- a/basis/cairo/ffi/ffi.factor +++ b/basis/cairo/ffi/ffi.factor @@ -10,8 +10,8 @@ alien.libraries classes.struct ; IN: cairo.ffi << { - { [ os winnt? ] [ "cairo" "libcairo-2.dll" "cdecl" add-library ] } - { [ os macosx? ] [ "cairo" "/opt/local/lib/libcairo.dylib" "cdecl" add-library ] } + { [ os winnt? ] [ "cairo" "libcairo-2.dll" cdecl add-library ] } + { [ os macosx? ] [ "cairo" "/opt/local/lib/libcairo.dylib" cdecl add-library ] } { [ os unix? ] [ ] } } cond >> @@ -38,7 +38,7 @@ TYPEDEF: void* cairo_pattern_t TYPEDEF: void* cairo_destroy_func_t : cairo-destroy-func ( quot -- callback ) - [ void { pointer: void } "cdecl" ] dip alien-callback ; inline + [ void { pointer: void } cdecl ] dip alien-callback ; inline ! See cairo.h for details STRUCT: cairo_user_data_key_t @@ -79,11 +79,11 @@ CONSTANT: CAIRO_CONTENT_COLOR_ALPHA HEX: 3000 TYPEDEF: void* cairo_write_func_t : cairo-write-func ( quot -- callback ) - [ cairo_status_t { pointer: void c-string int } "cdecl" ] dip alien-callback ; inline + [ cairo_status_t { pointer: void c-string int } cdecl ] dip alien-callback ; inline TYPEDEF: void* cairo_read_func_t : cairo-read-func ( quot -- callback ) - [ cairo_status_t { pointer: void c-string int } "cdecl" ] dip alien-callback ; inline + [ cairo_status_t { pointer: void c-string int } cdecl ] dip alien-callback ; inline ! Functions for manipulating state objects FUNCTION: cairo_t* diff --git a/basis/cocoa/subclassing/subclassing.factor b/basis/cocoa/subclassing/subclassing.factor index e4db56221f..1accb1e8dc 100644 --- a/basis/cocoa/subclassing/subclassing.factor +++ b/basis/cocoa/subclassing/subclassing.factor @@ -40,7 +40,7 @@ IN: cocoa.subclassing : prepare-method ( ret types quot -- type imp ) [ [ encode-types ] 2keep ] dip - '[ _ _ "cdecl" _ alien-callback ] + '[ _ _ cdecl _ alien-callback ] (( -- callback )) define-temp ; : prepare-methods ( methods -- methods ) diff --git a/basis/compiler/cfg/builder/builder-tests.factor b/basis/compiler/cfg/builder/builder-tests.factor index 7f1b6aa6f2..b2c05edf73 100644 --- a/basis/compiler/cfg/builder/builder-tests.factor +++ b/basis/compiler/cfg/builder/builder-tests.factor @@ -68,8 +68,8 @@ IN: compiler.cfg.builder.tests [ [ dup ] loop ] [ [ 2 ] [ 3 throw ] if 4 ] [ int f "malloc" { int } alien-invoke ] - [ int { int } "cdecl" alien-indirect ] - [ int { int } "cdecl" [ ] alien-callback ] + [ int { int } cdecl alien-indirect ] + [ int { int } cdecl [ ] alien-callback ] [ swap - + * ] [ swap slot ] [ blahblah ] diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 692dbee4c5..a813c530f7 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -19,7 +19,7 @@ IN: compiler.tests.alien { [ os unix? ] [ "libfactor-ffi-test.so" ] } } cond append-path ; -"f-cdecl" libfactor-ffi-tests-path "cdecl" add-library +"f-cdecl" libfactor-ffi-tests-path cdecl add-library "f-stdcall" libfactor-ffi-tests-path "stdcall" add-library >> @@ -90,7 +90,7 @@ FUNCTION: TINY ffi_test_17 int x ; [ [ alien-indirect ] infer ] [ inference-error? ] must-fail-with : indirect-test-1 ( ptr -- result ) - int { } "cdecl" alien-indirect ; + int { } cdecl alien-indirect ; { 1 1 } [ indirect-test-1 ] must-infer-as @@ -99,7 +99,7 @@ FUNCTION: TINY ffi_test_17 int x ; [ 3 ] [ &: ffi_test_1 indirect-test-1 ] unit-test : indirect-test-1' ( ptr -- ) - int { } "cdecl" alien-indirect drop ; + int { } cdecl alien-indirect drop ; { 1 0 } [ indirect-test-1' ] must-infer-as @@ -108,7 +108,7 @@ FUNCTION: TINY ffi_test_17 int x ; [ -1 indirect-test-1 ] must-fail : indirect-test-2 ( x y ptr -- result ) - int { int int } "cdecl" alien-indirect gc ; + int { int int } cdecl alien-indirect gc ; { 3 1 } [ indirect-test-2 ] must-infer-as @@ -314,21 +314,21 @@ FUNCTION: ulonglong ffi_test_38 ( ulonglong x, ulonglong y ) ; ! Test callbacks -: callback-1 ( -- callback ) void { } "cdecl" [ ] alien-callback ; +: callback-1 ( -- callback ) void { } cdecl [ ] alien-callback ; [ 0 1 ] [ [ callback-1 ] infer [ in>> length ] [ out>> length ] bi ] unit-test [ t ] [ callback-1 alien? ] unit-test -: callback_test_1 ( ptr -- ) void { } "cdecl" alien-indirect ; +: callback_test_1 ( ptr -- ) void { } cdecl alien-indirect ; [ ] [ callback-1 callback_test_1 ] unit-test -: callback-2 ( -- callback ) void { } "cdecl" [ [ 5 throw ] ignore-errors ] alien-callback ; +: callback-2 ( -- callback ) void { } cdecl [ [ 5 throw ] ignore-errors ] alien-callback ; [ ] [ callback-2 callback_test_1 ] unit-test -: callback-3 ( -- callback ) void { } "cdecl" [ 5 "x" set ] alien-callback ; +: callback-3 ( -- callback ) void { } cdecl [ 5 "x" set ] alien-callback ; [ t 3 5 ] [ [ @@ -340,38 +340,38 @@ FUNCTION: ulonglong ffi_test_38 ( ulonglong x, ulonglong y ) ; ] unit-test : callback-5 ( -- callback ) - void { } "cdecl" [ gc ] alien-callback ; + void { } cdecl [ gc ] alien-callback ; [ "testing" ] [ "testing" callback-5 callback_test_1 ] unit-test : callback-5b ( -- callback ) - void { } "cdecl" [ compact-gc ] alien-callback ; + void { } cdecl [ compact-gc ] alien-callback ; [ "testing" ] [ "testing" callback-5b callback_test_1 ] unit-test : callback-6 ( -- callback ) - void { } "cdecl" [ [ continue ] callcc0 ] alien-callback ; + void { } cdecl [ [ continue ] callcc0 ] alien-callback ; [ 1 2 3 ] [ callback-6 callback_test_1 1 2 3 ] unit-test : callback-7 ( -- callback ) - void { } "cdecl" [ 1000000 sleep ] alien-callback ; + void { } cdecl [ 1000000 sleep ] alien-callback ; [ 1 2 3 ] [ callback-7 callback_test_1 1 2 3 ] unit-test [ f ] [ namespace global eq? ] unit-test : callback-8 ( -- callback ) - void { } "cdecl" [ [ ] in-thread yield ] alien-callback ; + void { } cdecl [ [ ] in-thread yield ] alien-callback ; [ ] [ callback-8 callback_test_1 ] unit-test : callback-9 ( -- callback ) - int { int int int } "cdecl" [ + int { int int int } cdecl [ + + 1 + ] alien-callback ; @@ -429,13 +429,13 @@ STRUCT: double-rect } cleave ; : double-rect-callback ( -- alien ) - void { void* void* double-rect } "cdecl" + void { void* void* double-rect } cdecl [ "example" set-global 2drop ] alien-callback ; : double-rect-test ( arg -- arg' ) f f rot double-rect-callback - void { void* void* double-rect } "cdecl" alien-indirect + void { void* void* double-rect } cdecl alien-indirect "example" get-global ; [ 1.0 2.0 3.0 4.0 ] @@ -452,7 +452,7 @@ FUNCTION: test_struct_14 ffi_test_40 ( double x1, double x2 ) ; ] unit-test : callback-10 ( -- callback ) - test_struct_14 { double double } "cdecl" + test_struct_14 { double double } cdecl [ test_struct_14 swap >>x2 @@ -460,7 +460,7 @@ FUNCTION: test_struct_14 ffi_test_40 ( double x1, double x2 ) ; ] alien-callback ; : callback-10-test ( x1 x2 callback -- result ) - test_struct_14 { double double } "cdecl" alien-indirect ; + test_struct_14 { double double } cdecl alien-indirect ; [ 1.0 2.0 ] [ 1.0 2.0 callback-10 callback-10-test @@ -475,7 +475,7 @@ FUNCTION: test-struct-12 ffi_test_41 ( int a, double x ) ; ] unit-test : callback-11 ( -- callback ) - test-struct-12 { int double } "cdecl" + test-struct-12 { int double } cdecl [ test-struct-12 swap >>x @@ -483,7 +483,7 @@ FUNCTION: test-struct-12 ffi_test_41 ( int a, double x ) ; ] alien-callback ; : callback-11-test ( x1 x2 callback -- result ) - test-struct-12 { int double } "cdecl" alien-indirect ; + test-struct-12 { int double } cdecl alien-indirect ; [ 1 2.0 ] [ 1 2.0 callback-11 callback-11-test @@ -499,7 +499,7 @@ FUNCTION: test_struct_15 ffi_test_42 ( float x, float y ) ; [ 1.0 2.0 ] [ 1.0 2.0 ffi_test_42 [ x>> ] [ y>> ] bi ] unit-test : callback-12 ( -- callback ) - test_struct_15 { float float } "cdecl" + test_struct_15 { float float } cdecl [ test_struct_15 swap >>y @@ -507,7 +507,7 @@ FUNCTION: test_struct_15 ffi_test_42 ( float x, float y ) ; ] alien-callback ; : callback-12-test ( x1 x2 callback -- result ) - test_struct_15 { float float } "cdecl" alien-indirect ; + test_struct_15 { float float } cdecl alien-indirect ; [ 1.0 2.0 ] [ 1.0 2.0 callback-12 callback-12-test [ x>> ] [ y>> ] bi @@ -522,7 +522,7 @@ FUNCTION: test_struct_16 ffi_test_43 ( float x, int a ) ; [ 1.0 2 ] [ 1.0 2 ffi_test_43 [ x>> ] [ a>> ] bi ] unit-test : callback-13 ( -- callback ) - test_struct_16 { float int } "cdecl" + test_struct_16 { float int } cdecl [ test_struct_16 swap >>a @@ -530,7 +530,7 @@ FUNCTION: test_struct_16 ffi_test_43 ( float x, int a ) ; ] alien-callback ; : callback-13-test ( x1 x2 callback -- result ) - test_struct_16 { float int } "cdecl" alien-indirect ; + test_struct_16 { float int } cdecl alien-indirect ; [ 1.0 2 ] [ 1.0 2 callback-13 callback-13-test @@ -581,13 +581,13 @@ FUNCTION: short ffi_test_48 ( bool-field-test x ) ; ! Test interaction between threads and callbacks : thread-callback-1 ( -- callback ) - int { } "cdecl" [ yield 100 ] alien-callback ; + int { } cdecl [ yield 100 ] alien-callback ; : thread-callback-2 ( -- callback ) - int { } "cdecl" [ yield 200 ] alien-callback ; + int { } cdecl [ yield 200 ] alien-callback ; : thread-callback-invoker ( callback -- n ) - int { } "cdecl" alien-indirect ; + int { } cdecl alien-indirect ; "p" set [ thread-callback-1 thread-callback-invoker "p" get fulfill ] in-thread @@ -600,6 +600,6 @@ FUNCTION: void this_does_not_exist ( ) ; [ this_does_not_exist ] [ { "kernel-error" 9 f f } = ] must-fail-with ! More alien-assembly tests are in cpu.* vocabs -: assembly-test-1 ( -- ) void { } "cdecl" [ ] alien-assembly ; +: assembly-test-1 ( -- ) void { } cdecl [ ] alien-assembly ; [ ] [ assembly-test-1 ] unit-test diff --git a/basis/compiler/tests/redefine24.factor b/basis/compiler/tests/redefine24.factor index 391102102e..90c4e9943d 100644 --- a/basis/compiler/tests/redefine24.factor +++ b/basis/compiler/tests/redefine24.factor @@ -7,12 +7,12 @@ TYPEDEF: alien.c-types:int type-1 TYPEDEF: alien.c-types:int type-3 : callback ( -- ptr ) - type-3 { type-1 type-1 } "cdecl" [ + >integer ] alien-callback ; + type-3 { type-1 type-1 } cdecl [ + >integer ] alien-callback ; TYPEDEF: alien.c-types:float type-2 : indirect ( x y ptr -- z ) - type-3 { type-2 type-2 } "cdecl" alien-indirect ; + type-3 { type-2 type-2 } cdecl alien-indirect ; [ ] [ "USING: alien.c-types alien.syntax ; diff --git a/basis/compression/zlib/ffi/ffi.factor b/basis/compression/zlib/ffi/ffi.factor index 553b55cf6e..aede6d5621 100644 --- a/basis/compression/zlib/ffi/ffi.factor +++ b/basis/compression/zlib/ffi/ffi.factor @@ -8,7 +8,7 @@ IN: compression.zlib.ffi { [ os winnt? ] [ "zlib1.dll" ] } { [ os macosx? ] [ "libz.dylib" ] } { [ os unix? ] [ "libz.so" ] } -} cond "cdecl" add-library >> +} cond cdecl add-library >> LIBRARY: zlib diff --git a/basis/core-foundation/run-loop/run-loop.factor b/basis/core-foundation/run-loop/run-loop.factor index 14d701ba17..793efefbe8 100644 --- a/basis/core-foundation/run-loop/run-loop.factor +++ b/basis/core-foundation/run-loop/run-loop.factor @@ -120,7 +120,7 @@ PRIVATE> [ fds>> [ enable-all-callbacks ] each ] bi ; : timer-callback ( -- callback ) - void { CFRunLoopTimerRef void* } "cdecl" + void { CFRunLoopTimerRef void* } cdecl [ 2drop reset-run-loop yield ] alien-callback ; : init-thread-timer ( -- ) diff --git a/basis/cpu/x86/32/32-tests.factor b/basis/cpu/x86/32/32-tests.factor index bc07e3a25b..375374806f 100644 --- a/basis/cpu/x86/32/32-tests.factor +++ b/basis/cpu/x86/32/32-tests.factor @@ -2,6 +2,6 @@ IN: cpu.x86.32.tests USING: alien alien.c-types tools.test cpu.x86.assembler cpu.x86.assembler.operands ; -: assembly-test-1 ( -- x ) int { } "cdecl" [ EAX 3 MOV ] alien-assembly ; +: assembly-test-1 ( -- x ) int { } cdecl [ EAX 3 MOV ] alien-assembly ; [ 3 ] [ assembly-test-1 ] unit-test diff --git a/basis/cpu/x86/64/64-tests.factor b/basis/cpu/x86/64/64-tests.factor index 6d171af7ea..2d2c89441c 100644 --- a/basis/cpu/x86/64/64-tests.factor +++ b/basis/cpu/x86/64/64-tests.factor @@ -2,12 +2,12 @@ USING: alien alien.c-types cpu.architecture cpu.x86.64 cpu.x86.assembler cpu.x86.assembler.operands tools.test ; IN: cpu.x86.64.tests -: assembly-test-1 ( -- x ) int { } "cdecl" [ RAX 3 MOV ] alien-assembly ; +: assembly-test-1 ( -- x ) int { } cdecl [ RAX 3 MOV ] alien-assembly ; [ 3 ] [ assembly-test-1 ] unit-test : assembly-test-2 ( a b -- x ) - int { int int } "cdecl" [ + int { int int } cdecl [ param-reg-0 param-reg-1 ADD int-regs return-reg param-reg-0 MOV ] alien-assembly ; diff --git a/basis/cpu/x86/features/features.factor b/basis/cpu/x86/features/features.factor index 30b2ce3b57..7913489178 100644 --- a/basis/cpu/x86/features/features.factor +++ b/basis/cpu/x86/features/features.factor @@ -9,7 +9,7 @@ IN: cpu.x86.features > +} cond cdecl add-library >> ! ConnSatusType CONSTANT: CONNECTION_OK HEX: 0 diff --git a/basis/db/sqlite/ffi/ffi.factor b/basis/db/sqlite/ffi/ffi.factor index f93b961799..d9da317c89 100644 --- a/basis/db/sqlite/ffi/ffi.factor +++ b/basis/db/sqlite/ffi/ffi.factor @@ -10,7 +10,7 @@ IN: db.sqlite.ffi { [ os winnt? ] [ "sqlite3.dll" ] } { [ os macosx? ] [ "/usr/lib/libsqlite3.dylib" ] } { [ os unix? ] [ "libsqlite3.so" ] } - } cond "cdecl" add-library >> + } cond cdecl add-library >> ! Return values from sqlite functions CONSTANT: SQLITE_OK 0 ! Successful result diff --git a/basis/glib/glib.factor b/basis/glib/glib.factor index 157a426e19..7447f24151 100644 --- a/basis/glib/glib.factor +++ b/basis/glib/glib.factor @@ -8,14 +8,14 @@ IN: glib << { - { [ os winnt? ] [ "glib" "libglib-2.0-0.dll" "cdecl" add-library ] } - { [ os macosx? ] [ "glib" "/opt/local/lib/libglib-2.0.0.dylib" "cdecl" add-library ] } + { [ os winnt? ] [ "glib" "libglib-2.0-0.dll" cdecl add-library ] } + { [ os macosx? ] [ "glib" "/opt/local/lib/libglib-2.0.0.dylib" cdecl add-library ] } { [ os unix? ] [ ] } } cond { - { [ os winnt? ] [ "gobject" "libgobject-2.0-0.dll" "cdecl" add-library ] } - { [ os macosx? ] [ "gobject" "/opt/local/lib/libgobject-2.0.0.dylib" "cdecl" add-library ] } + { [ os winnt? ] [ "gobject" "libgobject-2.0-0.dll" cdecl add-library ] } + { [ os macosx? ] [ "gobject" "/opt/local/lib/libgobject-2.0.0.dylib" cdecl add-library ] } { [ os unix? ] [ ] } } cond diff --git a/basis/io/backend/unix/multiplexers/run-loop/run-loop.factor b/basis/io/backend/unix/multiplexers/run-loop/run-loop.factor index 05328b48dc..ea31292c06 100644 --- a/basis/io/backend/unix/multiplexers/run-loop/run-loop.factor +++ b/basis/io/backend/unix/multiplexers/run-loop/run-loop.factor @@ -11,7 +11,7 @@ TUPLE: run-loop-mx kqueue-mx ; : file-descriptor-callback ( -- callback ) void { CFFileDescriptorRef CFOptionFlags void* } - "cdecl" [ + cdecl [ 3drop 0 mx get kqueue-mx>> wait-for-events reset-run-loop diff --git a/basis/io/sockets/secure/openssl/openssl.factor b/basis/io/sockets/secure/openssl/openssl.factor index b3cf28a497..ca7ba0cd49 100644 --- a/basis/io/sockets/secure/openssl/openssl.factor +++ b/basis/io/sockets/secure/openssl/openssl.factor @@ -31,7 +31,7 @@ TUPLE: openssl-context < secure-context aliens sessions ; ] [ drop ] if ; : password-callback ( -- alien ) - int { void* int bool void* } "cdecl" + int { void* int bool void* } cdecl [| buf size rwflag password! | password [ B{ 0 } password! ] unless diff --git a/basis/math/floats/env/x86/32/32.factor b/basis/math/floats/env/x86/32/32.factor index ea3bee424f..7d45f01337 100644 --- a/basis/math/floats/env/x86/32/32.factor +++ b/basis/math/floats/env/x86/32/32.factor @@ -3,26 +3,26 @@ cpu.x86.assembler.operands math.floats.env.x86 system ; IN: math.floats.env.x86.32 M: x86.32 get-sse-env - void { void* } "cdecl" [ + void { void* } cdecl [ EAX ESP [] MOV EAX [] STMXCSR ] alien-assembly ; M: x86.32 set-sse-env - void { void* } "cdecl" [ + void { void* } cdecl [ EAX ESP [] MOV EAX [] LDMXCSR ] alien-assembly ; M: x86.32 get-x87-env - void { void* } "cdecl" [ + void { void* } cdecl [ EAX ESP [] MOV EAX [] FNSTSW EAX 2 [+] FNSTCW ] alien-assembly ; M: x86.32 set-x87-env - void { void* } "cdecl" [ + void { void* } cdecl [ EAX ESP [] MOV FNCLEX EAX 2 [+] FLDCW diff --git a/basis/math/floats/env/x86/64/64.factor b/basis/math/floats/env/x86/64/64.factor index b6f8ee151f..c20eed1cab 100644 --- a/basis/math/floats/env/x86/64/64.factor +++ b/basis/math/floats/env/x86/64/64.factor @@ -3,23 +3,23 @@ cpu.x86.assembler.operands math.floats.env.x86 sequences system ; IN: math.floats.env.x86.64 M: x86.64 get-sse-env - void { void* } "cdecl" [ + void { void* } cdecl [ int-regs param-regs first [] STMXCSR ] alien-assembly ; M: x86.64 set-sse-env - void { void* } "cdecl" [ + void { void* } cdecl [ int-regs param-regs first [] LDMXCSR ] alien-assembly ; M: x86.64 get-x87-env - void { void* } "cdecl" [ + void { void* } cdecl [ int-regs param-regs first [] FNSTSW int-regs param-regs first 2 [+] FNSTCW ] alien-assembly ; M: x86.64 set-x87-env - void { void* } "cdecl" [ + void { void* } cdecl [ FNCLEX int-regs param-regs first 2 [+] FLDCW ] alien-assembly ; diff --git a/basis/opengl/gl/macosx/macosx.factor b/basis/opengl/gl/macosx/macosx.factor index 9e095a62e6..aeaa5da4eb 100644 --- a/basis/opengl/gl/macosx/macosx.factor +++ b/basis/opengl/gl/macosx/macosx.factor @@ -3,4 +3,4 @@ IN: opengl.gl.macosx : gl-function-context ( -- context ) 0 ; inline : gl-function-address ( name -- address ) f dlsym ; inline -: gl-function-calling-convention ( -- str ) "cdecl" ; inline +: gl-function-calling-convention ( -- str ) cdecl ; inline diff --git a/basis/opengl/gl/unix/unix.factor b/basis/opengl/gl/unix/unix.factor index 3352b18350..a9d3b42b53 100644 --- a/basis/opengl/gl/unix/unix.factor +++ b/basis/opengl/gl/unix/unix.factor @@ -3,4 +3,4 @@ IN: opengl.gl.unix : gl-function-context ( -- context ) glXGetCurrentContext ; inline : gl-function-address ( name -- address ) glXGetProcAddressARB ; inline -: gl-function-calling-convention ( -- str ) "cdecl" ; inline +: gl-function-calling-convention ( -- str ) cdecl ; inline diff --git a/basis/openssl/libcrypto/libcrypto.factor b/basis/openssl/libcrypto/libcrypto.factor index f9983d7813..fb39a8e51b 100644 --- a/basis/openssl/libcrypto/libcrypto.factor +++ b/basis/openssl/libcrypto/libcrypto.factor @@ -14,9 +14,9 @@ IN: openssl.libcrypto { { [ os openbsd? ] [ ] } ! VM is linked with it { [ os netbsd? ] [ ] } - { [ os winnt? ] [ "libcrypto" "libeay32.dll" "cdecl" add-library ] } - { [ os macosx? ] [ "libcrypto" "libcrypto.dylib" "cdecl" add-library ] } - { [ os unix? ] [ "libcrypto" "libcrypto.so" "cdecl" add-library ] } + { [ os winnt? ] [ "libcrypto" "libeay32.dll" cdecl add-library ] } + { [ os macosx? ] [ "libcrypto" "libcrypto.dylib" cdecl add-library ] } + { [ os unix? ] [ "libcrypto" "libcrypto.so" cdecl add-library ] } } cond >> diff --git a/basis/openssl/libssl/libssl.factor b/basis/openssl/libssl/libssl.factor index bfd59cde25..341b35eb15 100644 --- a/basis/openssl/libssl/libssl.factor +++ b/basis/openssl/libssl/libssl.factor @@ -10,9 +10,9 @@ IN: openssl.libssl << { { [ os openbsd? ] [ ] } ! VM is linked with it { [ os netbsd? ] [ ] } - { [ os winnt? ] [ "libssl" "ssleay32.dll" "cdecl" add-library ] } - { [ os macosx? ] [ "libssl" "libssl.dylib" "cdecl" add-library ] } - { [ os unix? ] [ "libssl" "libssl.so" "cdecl" add-library ] } + { [ os winnt? ] [ "libssl" "ssleay32.dll" cdecl add-library ] } + { [ os macosx? ] [ "libssl" "libssl.dylib" cdecl add-library ] } + { [ os unix? ] [ "libssl" "libssl.so" cdecl add-library ] } } cond >> CONSTANT: X509_FILETYPE_PEM 1 diff --git a/basis/pango/cairo/cairo.factor b/basis/pango/cairo/cairo.factor index d6baaffe2e..85d4cef424 100644 --- a/basis/pango/cairo/cairo.factor +++ b/basis/pango/cairo/cairo.factor @@ -12,8 +12,8 @@ classes.struct cairo cairo.ffi ; IN: pango.cairo << { - { [ os winnt? ] [ "pangocairo" "libpangocairo-1.0-0.dll" "cdecl" add-library ] } - { [ os macosx? ] [ "pangocairo" "/opt/local/lib/libpangocairo-1.0.0.dylib" "cdecl" add-library ] } + { [ os winnt? ] [ "pangocairo" "libpangocairo-1.0-0.dll" cdecl add-library ] } + { [ os macosx? ] [ "pangocairo" "/opt/local/lib/libpangocairo-1.0.0.dylib" cdecl add-library ] } { [ os unix? ] [ ] } } cond >> diff --git a/basis/pango/pango.factor b/basis/pango/pango.factor index 6dc48e39fe..3a249c664c 100644 --- a/basis/pango/pango.factor +++ b/basis/pango/pango.factor @@ -11,8 +11,8 @@ IN: pango ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! << { - { [ os winnt? ] [ "pango" "libpango-1.0-0.dll" "cdecl" add-library ] } - { [ os macosx? ] [ "pango" "/opt/local/lib/libpango-1.0.0.dylib" "cdecl" add-library ] } + { [ os winnt? ] [ "pango" "libpango-1.0-0.dll" cdecl add-library ] } + { [ os macosx? ] [ "pango" "/opt/local/lib/libpango-1.0.0.dylib" cdecl add-library ] } { [ os unix? ] [ ] } } cond >> diff --git a/basis/tools/deploy/test/9/9.factor b/basis/tools/deploy/test/9/9.factor index 642ee48e67..73dade6657 100644 --- a/basis/tools/deploy/test/9/9.factor +++ b/basis/tools/deploy/test/9/9.factor @@ -2,9 +2,9 @@ USING: alien alien.c-types kernel math ; IN: tools.deploy.test.9 : callback-test ( -- callback ) - int { int } "cdecl" [ 1 + ] alien-callback ; + int { int } cdecl [ 1 + ] alien-callback ; : indirect-test ( -- ) - 10 callback-test int { int } "cdecl" alien-indirect 11 assert= ; + 10 callback-test int { int } cdecl alien-indirect 11 assert= ; MAIN: indirect-test diff --git a/basis/tools/disassembler/udis/udis.factor b/basis/tools/disassembler/udis/udis.factor index 5e46a34682..e998a5cfdb 100644 --- a/basis/tools/disassembler/udis/udis.factor +++ b/basis/tools/disassembler/udis/udis.factor @@ -12,7 +12,7 @@ IN: tools.disassembler.udis { [ os macosx? ] [ "libudis86.0.dylib" ] } { [ os unix? ] [ "libudis86.so.0" ] } { [ os winnt? ] [ "libudis86.dll" ] } -} cond "cdecl" add-library +} cond cdecl add-library >> LIBRARY: libudis86 diff --git a/basis/tools/profiler/profiler-tests.factor b/basis/tools/profiler/profiler-tests.factor index 5c31cdaeb4..b02b800463 100644 --- a/basis/tools/profiler/profiler-tests.factor +++ b/basis/tools/profiler/profiler-tests.factor @@ -21,9 +21,9 @@ IN: tools.profiler.tests [ ] [ \ + usage-profile. ] unit-test -: callback-test ( -- callback ) void { } "cdecl" [ ] alien-callback ; +: callback-test ( -- callback ) void { } cdecl [ ] alien-callback ; -: indirect-test ( callback -- ) void { } "cdecl" alien-indirect ; +: indirect-test ( callback -- ) void { } cdecl alien-indirect ; : foobar ( -- ) ; diff --git a/basis/unix/ffi/ffi.factor b/basis/unix/ffi/ffi.factor index 555bab32e4..1809ee4b68 100644 --- a/basis/unix/ffi/ffi.factor +++ b/basis/unix/ffi/ffi.factor @@ -156,4 +156,4 @@ FUNCTION: int unlink ( c-string path ) ; FUNCTION: int utimes ( c-string path, timeval[2] times ) ; FUNCTION: ssize_t write ( int fd, void* buf, size_t nbytes ) ; -"librt" "librt.so" "cdecl" add-library +"librt" "librt.so" cdecl add-library diff --git a/basis/windows/nt/nt.factor b/basis/windows/nt/nt.factor index 8e831e153e..2de60e524d 100644 --- a/basis/windows/nt/nt.factor +++ b/basis/windows/nt/nt.factor @@ -8,8 +8,8 @@ USING: alien sequences alien.libraries ; { "winsock" "ws2_32.dll" "stdcall" } { "mswsock" "mswsock.dll" "stdcall" } { "shell32" "shell32.dll" "stdcall" } - { "libc" "msvcrt.dll" "cdecl" } - { "libm" "msvcrt.dll" "cdecl" } + { "libc" "msvcrt.dll" cdecl } + { "libm" "msvcrt.dll" cdecl } { "gl" "opengl32.dll" "stdcall" } { "glu" "glu32.dll" "stdcall" } { "ole32" "ole32.dll" "stdcall" } diff --git a/extra/benchmark/fib6/fib6.factor b/extra/benchmark/fib6/fib6.factor index 561110d941..1ae1c6a34d 100644 --- a/extra/benchmark/fib6/fib6.factor +++ b/extra/benchmark/fib6/fib6.factor @@ -2,12 +2,12 @@ USING: math kernel alien alien.c-types ; IN: benchmark.fib6 : fib ( x -- y ) - int { int } "cdecl" [ + int { int } cdecl [ dup 1 <= [ drop 1 ] [ 1 - dup fib swap 1 - fib + ] if ] alien-callback - int { int } "cdecl" alien-indirect ; + int { int } cdecl alien-indirect ; : fib-main ( -- ) 32 fib drop ; diff --git a/extra/chipmunk/ffi/ffi.factor b/extra/chipmunk/ffi/ffi.factor index 0142b57a77..b00f64339f 100644 --- a/extra/chipmunk/ffi/ffi.factor +++ b/extra/chipmunk/ffi/ffi.factor @@ -11,7 +11,7 @@ IN: chipmunk.ffi { [ os windows? ] [ "chipmunk.dll" ] } { [ os macosx? ] [ "libchipmunk.dylib" ] } { [ os unix? ] [ "libchipmunk.so" ] } -} cond "cdecl" add-library +} cond cdecl add-library "chipmunk" deploy-library >> diff --git a/extra/curses/ffi/ffi.factor b/extra/curses/ffi/ffi.factor index 222885b72c..2b52d0ec56 100644 --- a/extra/curses/ffi/ffi.factor +++ b/extra/curses/ffi/ffi.factor @@ -8,7 +8,7 @@ IN: curses.ffi { [ os winnt? ] [ "libcurses.dll" ] } { [ os macosx? ] [ "libcurses.dylib" ] } { [ os unix? ] [ "libcurses.so" ] } -} cond "cdecl" add-library >> +} cond cdecl add-library >> C-TYPE: WINDOW C-TYPE: SCREEN diff --git a/extra/cursors/cursors-tests.factor b/extra/cursors/cursors-tests.factor index d71999ab87..770fd01ffd 100644 --- a/extra/cursors/cursors-tests.factor +++ b/extra/cursors/cursors-tests.factor @@ -1,5 +1,5 @@ ! (c)2010 Joe Groff bsd license -USING: accessors cursors make math sequences sorting tools.test ; +USING: accessors cursors kernel make math sequences sorting tools.test ; FROM: cursors => each map assoc-each assoc>map ; IN: cursors.tests @@ -12,6 +12,10 @@ IN: cursors.tests T{ linear-cursor f 1 1 } T{ linear-cursor f 5 1 } [ value>> 3 mod zero? ] -find ] unit-test +[ T{ linear-cursor f 5 1 } ] [ + T{ linear-cursor f 1 1 } T{ linear-cursor f 5 1 } [ value>> 6 = ] -find +] unit-test + [ { 1 3 } ] [ [ T{ linear-cursor f 1 2 } T{ linear-cursor f 5 2 } [ value>> , ] -each ] { } make diff --git a/extra/freetype/freetype.factor b/extra/freetype/freetype.factor index d131d2eb35..cd215ea463 100644 --- a/extra/freetype/freetype.factor +++ b/extra/freetype/freetype.factor @@ -5,8 +5,8 @@ alien.libraries classes.struct ; IN: freetype << "freetype" { - { [ os macosx? ] [ "/usr/X11R6/lib/libfreetype.6.dylib" "cdecl" add-library ] } - { [ os windows? ] [ "freetype6.dll" "cdecl" add-library ] } + { [ os macosx? ] [ "/usr/X11R6/lib/libfreetype.6.dylib" cdecl add-library ] } + { [ os windows? ] [ "freetype6.dll" cdecl add-library ] } { [ t ] [ drop ] } } cond >> diff --git a/extra/libusb/libusb.factor b/extra/libusb/libusb.factor index d521015d6f..5cae45ff95 100644 --- a/extra/libusb/libusb.factor +++ b/extra/libusb/libusb.factor @@ -11,7 +11,7 @@ IN: libusb { [ os windows? ] [ "libusb-1.0.dll" ] } { [ os macosx? ] [ "libusb-1.0.dylib" ] } { [ os unix? ] [ "libusb-1.0.so" ] } - } cond "cdecl" add-library >> + } cond cdecl add-library >> LIBRARY: libusb : libusb_cpu_to_le16 ( x -- y ) diff --git a/extra/llvm/core/core.factor b/extra/llvm/core/core.factor index f0a3cafe33..f3bf1cbaf0 100644 --- a/extra/llvm/core/core.factor +++ b/extra/llvm/core/core.factor @@ -12,7 +12,7 @@ IN: llvm.core { [ os macosx? ] [ "/usr/local/lib/lib" ".dylib" surround ] } { [ os windows? ] [ ".dll" append ] } { [ os unix? ] [ "lib" ".so" surround ] } - } cond "cdecl" add-library ; + } cond cdecl add-library ; "LLVMSystem" add-llvm-library "LLVMSupport" add-llvm-library diff --git a/extra/llvm/invoker/invoker.factor b/extra/llvm/invoker/invoker.factor index 87f39944d9..cc3480fe49 100644 --- a/extra/llvm/invoker/invoker.factor +++ b/extra/llvm/invoker/invoker.factor @@ -41,7 +41,7 @@ TUPLE: function name alien return params ; dup name>> function-pointer , dup return>> c-type , dup params>> [ second c-type ] map , - "cdecl" , \ alien-indirect , + cdecl , \ alien-indirect , ] [ ] make swap function-effect [ define-declared ] with-compilation-unit ; : install-module ( name -- ) diff --git a/extra/ogg/ogg.factor b/extra/ogg/ogg.factor index d7abece8bc..51e4621476 100644 --- a/extra/ogg/ogg.factor +++ b/extra/ogg/ogg.factor @@ -18,7 +18,7 @@ IN: ogg { [ os winnt? ] [ "ogg.dll" ] } { [ os macosx? ] [ "libogg.0.dylib" ] } { [ os unix? ] [ "libogg.so" ] } -} cond "cdecl" add-library +} cond cdecl add-library "ogg" deploy-library >> diff --git a/extra/ogg/theora/theora.factor b/extra/ogg/theora/theora.factor index eb79613496..82f4a7db51 100644 --- a/extra/ogg/theora/theora.factor +++ b/extra/ogg/theora/theora.factor @@ -19,13 +19,13 @@ IN: ogg.theora { [ os winnt? ] [ "theoradec.dll" ] } { [ os macosx? ] [ "libtheoradec.0.dylib" ] } { [ os unix? ] [ "libtheoradec.so" ] } -} cond "cdecl" add-library +} cond cdecl add-library "theoraenc" { { [ os winnt? ] [ "theoraenc.dll" ] } { [ os macosx? ] [ "libtheoraenc.0.dylib" ] } { [ os unix? ] [ "libtheoraenc.so" ] } -} cond "cdecl" add-library +} cond cdecl add-library >> CONSTANT: TH-EFAULT -1 diff --git a/extra/ogg/vorbis/vorbis.factor b/extra/ogg/vorbis/vorbis.factor index ad43750e27..3cefbeebec 100644 --- a/extra/ogg/vorbis/vorbis.factor +++ b/extra/ogg/vorbis/vorbis.factor @@ -19,7 +19,7 @@ IN: ogg.vorbis { [ os winnt? ] [ "vorbis.dll" ] } { [ os macosx? ] [ "libvorbis.0.dylib" ] } { [ os unix? ] [ "libvorbis.so" ] } -} cond "cdecl" add-library +} cond cdecl add-library "vorbis" deploy-library >> diff --git a/extra/openal/alut/alut.factor b/extra/openal/alut/alut.factor index 0bf8511647..07b2e4c2b6 100755 --- a/extra/openal/alut/alut.factor +++ b/extra/openal/alut/alut.factor @@ -14,7 +14,7 @@ IN: openal.alut "/System/Library/Frameworks/OpenAL.framework/OpenAL" ] } { [ os unix? ] [ "libalut.so" ] } - } cond "cdecl" add-library >> + } cond cdecl add-library >> << os macosx? [ "alut" deploy-library ] unless >> diff --git a/extra/openal/openal.factor b/extra/openal/openal.factor index bbe61f9dc3..853b33b386 100755 --- a/extra/openal/openal.factor +++ b/extra/openal/openal.factor @@ -14,7 +14,7 @@ IN: openal "/System/Library/Frameworks/OpenAL.framework/OpenAL" ] } { [ os unix? ] [ "libopenal.so" ] } - } cond "cdecl" add-library >> + } cond cdecl add-library >> << os macosx? [ "openal" deploy-library ] unless >> diff --git a/extra/opengl/glu/glu.factor b/extra/opengl/glu/glu.factor index 86936fdd65..856740d229 100644 --- a/extra/opengl/glu/glu.factor +++ b/extra/opengl/glu/glu.factor @@ -9,7 +9,7 @@ IN: opengl.glu os { { [ dup macosx? ] [ drop ] } { [ dup windows? ] [ drop ] } - { [ dup unix? ] [ drop "glu" "libGLU.so.1" "cdecl" add-library ] } + { [ dup unix? ] [ drop "glu" "libGLU.so.1" cdecl add-library ] } } cond >> diff --git a/extra/tokyo/alien/tcrdb/tcrdb.factor b/extra/tokyo/alien/tcrdb/tcrdb.factor index da4a750444..07c5eabeea 100644 --- a/extra/tokyo/alien/tcrdb/tcrdb.factor +++ b/extra/tokyo/alien/tcrdb/tcrdb.factor @@ -9,7 +9,7 @@ IN: tokyo.alien.tcrdb { [ os macosx? ] [ "/opt/local/lib/libtokyotyrant.dylib" ] } { [ os unix? ] [ "libtokyotyrant.so" ] } { [ os windows? ] [ "tokyotyrant.dll" ] } -} cond "cdecl" add-library >> +} cond cdecl add-library >> LIBRARY: tokyotyrant diff --git a/extra/tokyo/alien/tcutil/tcutil.factor b/extra/tokyo/alien/tcutil/tcutil.factor index afb78dba22..ee92348bb4 100644 --- a/extra/tokyo/alien/tcutil/tcutil.factor +++ b/extra/tokyo/alien/tcutil/tcutil.factor @@ -8,7 +8,7 @@ IN: tokyo.alien.tcutil { [ os macosx? ] [ "/opt/local/lib/libtokyocabinet.dylib" ] } { [ os unix? ] [ "libtokyocabinet.so" ] } { [ os windows? ] [ "tokyocabinet.dll" ] } -} cond "cdecl" add-library >> +} cond cdecl add-library >> LIBRARY: tokyocabinet diff --git a/unmaintained/alien/inline/inline.factor b/unmaintained/alien/inline/inline.factor index ee69d954ea..6428bead75 100644 --- a/unmaintained/alien/inline/inline.factor +++ b/unmaintained/alien/inline/inline.factor @@ -76,7 +76,7 @@ PRIVATE> : compile-c-library ( -- ) compile-library? [ compile-library ] when - c-library get dup library-path "cdecl" add-library ; + c-library get dup library-path cdecl add-library ; : define-c-function ( function types effect body -- ) [ diff --git a/unmaintained/cryptlib/libcl/libcl.factor b/unmaintained/cryptlib/libcl/libcl.factor index 38e6817f6c..f38ee856a1 100644 --- a/unmaintained/cryptlib/libcl/libcl.factor +++ b/unmaintained/cryptlib/libcl/libcl.factor @@ -14,8 +14,8 @@ IN: cryptlib.libcl << "libcl" { { [ win32? ] [ "cl32.dll" "stdcall" ] } - { [ macosx? ] [ "libcl.dylib" "cdecl" ] } - { [ unix? ] [ "libcl.so" "cdecl" ] } + { [ macosx? ] [ "libcl.dylib" cdecl ] } + { [ unix? ] [ "libcl.so" cdecl ] } } cond add-library >> ! =============================================== diff --git a/unmaintained/db/mysql/ffi/ffi.factor b/unmaintained/db/mysql/ffi/ffi.factor index c047393c99..1f50035a81 100644 --- a/unmaintained/db/mysql/ffi/ffi.factor +++ b/unmaintained/db/mysql/ffi/ffi.factor @@ -7,8 +7,8 @@ IN: db.mysql.ffi << "mysql" { { [ os winnt? ] [ "libmySQL.dll" "stdcall" ] } - { [ os macosx? ] [ "libmysqlclient.14.dylib" "cdecl" ] } - { [ os unix? ] [ "libmysqlclient.so.14" "cdecl" ] } + { [ os macosx? ] [ "libmysqlclient.14.dylib" cdecl ] } + { [ os unix? ] [ "libmysqlclient.so.14" cdecl ] } } cond add-library >> LIBRARY: mysql diff --git a/unmaintained/jni/jni-internals.factor b/unmaintained/jni/jni-internals.factor index 49bc57b108..d809d899de 100644 --- a/unmaintained/jni/jni-internals.factor +++ b/unmaintained/jni/jni-internals.factor @@ -296,61 +296,61 @@ FUNCTION: jint JNI_CreateJavaVM ( void** pvm, void** penv, void* args ) ; ] when ; : (destroy-java-vm) - "int" { "void*" } "cdecl" alien-indirect ; + "int" { "void*" } cdecl alien-indirect ; : (attach-current-thread) - "int" { "void*" "void*" "void*" } "cdecl" alien-indirect ; + "int" { "void*" "void*" "void*" } cdecl alien-indirect ; : (detach-current-thread) - "int" { "void*" } "cdecl" alien-indirect ; + "int" { "void*" } cdecl alien-indirect ; : (get-env) - "int" { "void*" "void*" "int" } "cdecl" alien-indirect ; + "int" { "void*" "void*" "int" } cdecl alien-indirect ; : (attach-current-thread-as-daemon) - "int" { "void*" "void*" "void*" } "cdecl" alien-indirect ; + "int" { "void*" "void*" "void*" } cdecl alien-indirect ; : destroy-java-vm ( javavm -- int ) dup JavaVM-functions JNIInvokeInterface-DestroyJavaVM (destroy-java-vm) ; : (get-version) - "jint" { "JNIEnv*" } "cdecl" alien-indirect ; + "jint" { "JNIEnv*" } cdecl alien-indirect ; : get-version ( jnienv -- int ) dup JNIEnv-functions JNINativeInterface-GetVersion (get-version) ; : (find-class) - "void*" { "JNINativeInterface*" "char*" } "cdecl" alien-indirect ; + "void*" { "JNINativeInterface*" "char*" } cdecl alien-indirect ; : find-class ( name jnienv -- int ) dup swapd JNIEnv-functions JNINativeInterface-FindClass (find-class) ; : (get-static-field-id) - "void*" { "JNINativeInterface*" "void*" "char*" "char*" } "cdecl" alien-indirect ; + "void*" { "JNINativeInterface*" "void*" "char*" "char*" } cdecl alien-indirect ; : get-static-field-id ( class name sig jnienv -- int ) dup >r >r 3array r> swap first3 r> JNIEnv-functions JNINativeInterface-GetStaticFieldID (get-static-field-id) ; : (get-static-object-field) - "void*" { "JNINativeInterface*" "void*" "void*" } "cdecl" alien-indirect ; + "void*" { "JNINativeInterface*" "void*" "void*" } cdecl alien-indirect ; : get-static-object-field ( class id jnienv -- int ) dup >r >r 2array r> swap first2 r> JNIEnv-functions JNINativeInterface-GetStaticObjectField (get-static-object-field) ; : (get-method-id) - "void*" { "JNINativeInterface*" "void*" "char*" "char*" } "cdecl" alien-indirect ; + "void*" { "JNINativeInterface*" "void*" "char*" "char*" } cdecl alien-indirect ; : get-method-id ( class name sig jnienv -- int ) dup >r >r 3array r> swap first3 r> JNIEnv-functions JNINativeInterface-GetMethodID (get-method-id) ; : (new-string) - "void*" { "JNINativeInterface*" "char*" "int" } "cdecl" alien-indirect ; + "void*" { "JNINativeInterface*" "char*" "int" } cdecl alien-indirect ; : new-string ( str jnienv -- str ) dup >r >r dup length 2array r> swap first2 r> JNIEnv-functions JNINativeInterface-NewString (new-string) ; : (call1) - "void" { "JNINativeInterface*" "void*" "void*" "int" } "cdecl" alien-indirect ; + "void" { "JNINativeInterface*" "void*" "void*" "int" } cdecl alien-indirect ; : call1 ( obj method-id jstr jnienv -- ) dup >r >r 3array r> swap first3 r> JNIEnv-functions JNINativeInterface-CallObjectMethod (call1) ; diff --git a/unmaintained/ldap/libldap/libldap.factor b/unmaintained/ldap/libldap/libldap.factor index 6db6884071..83d31ed968 100644 --- a/unmaintained/ldap/libldap/libldap.factor +++ b/unmaintained/ldap/libldap/libldap.factor @@ -11,8 +11,8 @@ IN: ldap.libldap << "libldap" { { [ win32? ] [ "libldap.dll" "stdcall" ] } - { [ macosx? ] [ "libldap.dylib" "cdecl" ] } - { [ unix? ] [ "libldap.so" "cdecl" ] } + { [ macosx? ] [ "libldap.dylib" cdecl ] } + { [ unix? ] [ "libldap.so" cdecl ] } } cond add-library >> : LDAP_VERSION1 1 ; inline diff --git a/unmaintained/lint/lint.factor b/unmaintained/lint/lint.factor index 9877c70062..093a110fba 100644 --- a/unmaintained/lint/lint.factor +++ b/unmaintained/lint/lint.factor @@ -52,7 +52,7 @@ SYMBOL: def-hash-keys [ t ] [ f ] [ { } ] [ drop f ] - [ "cdecl" ] + [ cdecl ] [ first ] [ second ] [ third ] [ fourth ] [ ">" write ] [ "/>" write ] } ; diff --git a/unmaintained/oracle/liboci/liboci.factor b/unmaintained/oracle/liboci/liboci.factor index aa04aef39f..71473ea7c8 100644 --- a/unmaintained/oracle/liboci/liboci.factor +++ b/unmaintained/oracle/liboci/liboci.factor @@ -13,8 +13,8 @@ IN: oracle.liboci "oci" { { [ os winnt? ] [ "oci.dll" "stdcall" ] } - { [ os macosx? ] [ "$DYLD_LIBRARY_PATH/libclntsh.dylib" "cdecl" ] } - { [ os unix? ] [ "$DYLD_LIBRARY_PATH/libclntsh.so.10.1" "cdecl" ] } + { [ os macosx? ] [ "$DYLD_LIBRARY_PATH/libclntsh.dylib" cdecl ] } + { [ os unix? ] [ "$DYLD_LIBRARY_PATH/libclntsh.so.10.1" cdecl ] } } cond add-library ! =============================================== diff --git a/unmaintained/pdf/libhpdf/libhpdf.factor b/unmaintained/pdf/libhpdf/libhpdf.factor index a40b7cddee..a3d5dd574f 100644 --- a/unmaintained/pdf/libhpdf/libhpdf.factor +++ b/unmaintained/pdf/libhpdf/libhpdf.factor @@ -11,8 +11,8 @@ IN: pdf.libhpdf << "libhpdf" { { [ win32? ] [ "libhpdf.dll" "stdcall" ] } - { [ macosx? ] [ "libhpdf.dylib" "cdecl" ] } - { [ unix? ] [ "$LD_LIBRARY_PATH/libhpdf.so" "cdecl" ] } + { [ macosx? ] [ "libhpdf.dylib" cdecl ] } + { [ unix? ] [ "$LD_LIBRARY_PATH/libhpdf.so" cdecl ] } } cond add-library >> ! compression mode From a6ee4232bb3752f4c289fd98ac1bc49127c4d40b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 31 Mar 2010 19:28:11 -0700 Subject: [PATCH 522/713] "mingw" -> mingw --- basis/cpu/x86/32/32.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 09f1ecb32b..38e60cddf9 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -297,7 +297,7 @@ M:: x86.32 %binary-float-function ( dst src1 src2 func -- ) : funny-large-struct-return? ( params -- ? ) #! MINGW ABI incompatibility disaster [ return>> large-struct? ] - [ abi>> "mingw" = os windows? not or ] + [ abi>> mingw = os windows? not or ] bi and ; M: x86.32 %cleanup ( params -- ) From f3dd625de6c50baefff1977c692f634fb2f0dfa8 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 31 Mar 2010 19:29:04 -0700 Subject: [PATCH 523/713] "stdcall" -> stdcall --- basis/alien/libraries/libraries-docs.factor | 4 +- basis/compiler/codegen/codegen.factor | 2 +- basis/compiler/tests/alien.factor | 6 +-- basis/cpu/x86/32/32.factor | 2 +- basis/io/sockets/windows/nt/nt.factor | 2 +- basis/opengl/gl/windows/windows.factor | 2 +- basis/ui/backend/windows/windows.factor | 2 +- basis/windows/ce/ce.factor | 22 ++++---- basis/windows/com/syntax/syntax.factor | 2 +- basis/windows/com/wrapper/wrapper.factor | 2 +- basis/windows/ddk/hid/hid.factor | 2 +- basis/windows/ddk/setupapi/setupapi.factor | 2 +- basis/windows/ddk/winusb/winusb.factor | 2 +- basis/windows/dwmapi/dwmapi.factor | 2 +- basis/windows/nt/nt.factor | 60 ++++++++++----------- extra/opencl/ffi/ffi.factor | 2 +- unmaintained/cryptlib/libcl/libcl.factor | 2 +- unmaintained/db/mysql/ffi/ffi.factor | 2 +- unmaintained/ldap/libldap/libldap.factor | 2 +- unmaintained/odbc/odbc.factor | 2 +- unmaintained/oracle/liboci/liboci.factor | 2 +- unmaintained/pdf/libhpdf/libhpdf.factor | 2 +- 22 files changed, 64 insertions(+), 64 deletions(-) diff --git a/basis/alien/libraries/libraries-docs.factor b/basis/alien/libraries/libraries-docs.factor index be1a7c7ad6..7ee953581a 100644 --- a/basis/alien/libraries/libraries-docs.factor +++ b/basis/alien/libraries/libraries-docs.factor @@ -6,7 +6,7 @@ IN: alien.libraries HELP: { $values - { "path" "a pathname string" } { "abi" "the ABI used by the library, either " { $snippet cdecl } " or " { $snippet "stdcall" } } + { "path" "a pathname string" } { "abi" "the ABI used by the library, either " { $snippet cdecl } " or " { $snippet stdcall } } { "library" library } } { $description "Opens a C library using the path and ABI parameters and outputs a library tuple." } { $notes "User code should use " { $link add-library } " so that the opened library is added to a global hashtable, " { $link libraries } "." } ; @@ -19,7 +19,7 @@ HELP: library { $description "Looks up a library by its logical name. The library object is a hashtable with the following keys:" { $list { { $snippet "name" } " - the full path of the C library binary" } - { { $snippet "abi" } " - the ABI used by the library, either " { $snippet cdecl } " or " { $snippet "stdcall" } } + { { $snippet "abi" } " - the ABI used by the library, either " { $snippet cdecl } " or " { $snippet stdcall } } { { $snippet "dll" } " - an instance of the " { $link dll } " class; only set if the library is loaded" } } } ; diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index d82ced8a1d..d8f0823d44 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -412,7 +412,7 @@ M: array dlsym-valid? '[ _ dlsym ] any? ; 3array ; : alien-invoke-dlsym ( params -- symbols dll ) - [ dup abi>> "stdcall" = [ stdcall-mangle ] [ function>> ] if ] + [ dup abi>> stdcall = [ stdcall-mangle ] [ function>> ] if ] [ library>> load-library ] bi 2dup check-dlsym ; diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index a813c530f7..71efe8a929 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -21,7 +21,7 @@ IN: compiler.tests.alien "f-cdecl" libfactor-ffi-tests-path cdecl add-library -"f-stdcall" libfactor-ffi-tests-path "stdcall" add-library +"f-stdcall" libfactor-ffi-tests-path stdcall add-library >> LIBRARY: f-cdecl @@ -117,11 +117,11 @@ FUNCTION: TINY ffi_test_17 int x ; unit-test : indirect-test-3 ( a b c d ptr -- result ) - int { int int int int } "stdcall" alien-indirect + int { int int int int } stdcall alien-indirect gc ; [ f ] [ "f-stdcall" load-library f = ] unit-test -[ "stdcall" ] [ "f-stdcall" library abi>> ] unit-test +[ stdcall ] [ "f-stdcall" library abi>> ] unit-test : ffi_test_18 ( w x y z -- int ) int "f-stdcall" "ffi_test_18" { int int int int } diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 38e60cddf9..c96d961d65 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -292,7 +292,7 @@ M:: x86.32 %binary-float-function ( dst src1 src2 func -- ) dst float-function-return ; : stdcall? ( params -- ? ) - abi>> "stdcall" = ; + abi>> stdcall = ; : funny-large-struct-return? ( params -- ? ) #! MINGW ABI incompatibility disaster diff --git a/basis/io/sockets/windows/nt/nt.factor b/basis/io/sockets/windows/nt/nt.factor index 8eb2df5b46..7a961518a0 100644 --- a/basis/io/sockets/windows/nt/nt.factor +++ b/basis/io/sockets/windows/nt/nt.factor @@ -57,7 +57,7 @@ TUPLE: ConnectEx-args port } cleave int { SOCKET void* int PVOID DWORD LPDWORD void* } - "stdcall" alien-indirect drop + stdcall alien-indirect drop winsock-error-string [ throw ] when* ; inline M: object establish-connection ( client-out remote -- ) diff --git a/basis/opengl/gl/windows/windows.factor b/basis/opengl/gl/windows/windows.factor index 8bceb865e2..2ac9894b9a 100644 --- a/basis/opengl/gl/windows/windows.factor +++ b/basis/opengl/gl/windows/windows.factor @@ -8,4 +8,4 @@ FUNCTION: void* wglGetProcAddress ( c-string name ) ; : gl-function-context ( -- context ) wglGetCurrentContext ; inline : gl-function-address ( name -- address ) wglGetProcAddress ; inline -: gl-function-calling-convention ( -- str ) "stdcall" ; inline +: gl-function-calling-convention ( -- str ) stdcall ; inline diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index 8a4ae9853f..626faf4274 100644 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -609,7 +609,7 @@ SYMBOL: trace-messages? ! return 0 if you handle the message, else just let DefWindowProc return its val : ui-wndproc ( -- object ) - uint { void* uint long long } "stdcall" [ + uint { void* uint long long } stdcall [ pick trace-messages? get-global [ dup windows-message-name name>> print flush ] when wm-handlers get-global at* [ call ] [ drop DefWindowProc ] if diff --git a/basis/windows/ce/ce.factor b/basis/windows/ce/ce.factor index ff6a9ad4fc..614a535ea0 100644 --- a/basis/windows/ce/ce.factor +++ b/basis/windows/ce/ce.factor @@ -1,14 +1,14 @@ USING: alien sequences alien.libraries ; { - { "advapi32" "\\windows\\coredll.dll" "stdcall" } - { "gdi32" "\\windows\\coredll.dll" "stdcall" } - { "user32" "\\windows\\coredll.dll" "stdcall" } - { "kernel32" "\\windows\\coredll.dll" "stdcall" } - { "winsock" "\\windows\\ws2.dll" "stdcall" } - { "mswsock" "\\windows\\ws2.dll" "stdcall" } - { "libc" "\\windows\\coredll.dll" "stdcall" } - { "libm" "\\windows\\coredll.dll" "stdcall" } - ! { "gl" "libGLES_CM.dll" "stdcall" } - ! { "glu" "libGLES_CM.dll" "stdcall" } - { "ole32" "ole32.dll" "stdcall" } + { "advapi32" "\\windows\\coredll.dll" stdcall } + { "gdi32" "\\windows\\coredll.dll" stdcall } + { "user32" "\\windows\\coredll.dll" stdcall } + { "kernel32" "\\windows\\coredll.dll" stdcall } + { "winsock" "\\windows\\ws2.dll" stdcall } + { "mswsock" "\\windows\\ws2.dll" stdcall } + { "libc" "\\windows\\coredll.dll" stdcall } + { "libm" "\\windows\\coredll.dll" stdcall } + ! { "gl" "libGLES_CM.dll" stdcall } + ! { "glu" "libGLES_CM.dll" stdcall } + { "ole32" "ole32.dll" stdcall } } [ first3 add-library ] each diff --git a/basis/windows/com/syntax/syntax.factor b/basis/windows/com/syntax/syntax.factor index 78a3c0e6d2..9d74ac49f8 100644 --- a/basis/windows/com/syntax/syntax.factor +++ b/basis/windows/com/syntax/syntax.factor @@ -12,7 +12,7 @@ MACRO: com-invoke ( n return parameters -- ) [ 2nip length ] 3keep '[ _ npick *void* _ cell * alien-cell _ _ - "stdcall" alien-indirect + stdcall alien-indirect ] ; TUPLE: com-interface-definition word parent iid functions ; diff --git a/basis/windows/com/wrapper/wrapper.factor b/basis/windows/com/wrapper/wrapper.factor index 25861659dc..6f92c8b860 100644 --- a/basis/windows/com/wrapper/wrapper.factor +++ b/basis/windows/com/wrapper/wrapper.factor @@ -114,7 +114,7 @@ unless ] [ first2 (finish-thunk) ] bi* - "stdcall" swap compile-alien-callback + stdcall swap compile-alien-callback ] 2map ; : (make-callbacks) ( implementations -- sequence ) diff --git a/basis/windows/ddk/hid/hid.factor b/basis/windows/ddk/hid/hid.factor index 9c8a55ee7c..25c2642e34 100644 --- a/basis/windows/ddk/hid/hid.factor +++ b/basis/windows/ddk/hid/hid.factor @@ -4,7 +4,7 @@ USING: alien.c-types alien.libraries alien.syntax classes.struct kernel math windows.types windows.ole32 ; IN: windows.ddk.hid -<< "hid" "hid.dll" "stdcall" add-library >> +<< "hid" "hid.dll" stdcall add-library >> LIBRARY: hid TYPEDEF: LONG NTSTATUS diff --git a/basis/windows/ddk/setupapi/setupapi.factor b/basis/windows/ddk/setupapi/setupapi.factor index 06d32725f7..45ecebee74 100644 --- a/basis/windows/ddk/setupapi/setupapi.factor +++ b/basis/windows/ddk/setupapi/setupapi.factor @@ -4,7 +4,7 @@ USING: literals windows.kernel32 math alien.syntax windows.types classes.struct alien.c-types windows.errors windows.ole32 windows.advapi32 alien.libraries ; IN: windows.ddk.setupapi -<< "setupapi" "setupapi.dll" "stdcall" add-library >> +<< "setupapi" "setupapi.dll" stdcall add-library >> LIBRARY: setupapi TYPEDEF: DWORDLONG SP_LOG_TOKEN diff --git a/basis/windows/ddk/winusb/winusb.factor b/basis/windows/ddk/winusb/winusb.factor index 3b98e7e8ca..12ce137901 100644 --- a/basis/windows/ddk/winusb/winusb.factor +++ b/basis/windows/ddk/winusb/winusb.factor @@ -4,7 +4,7 @@ USING: alien.c-types alien.syntax classes.struct windows.kernel32 windows.types alien.libraries ; IN: windows.ddk.winusb -<< "winusb" "winusb.dll" "stdcall" add-library >> +<< "winusb" "winusb.dll" stdcall add-library >> LIBRARY: winusb TYPEDEF: PVOID WINUSB_INTERFACE_HANDLE diff --git a/basis/windows/dwmapi/dwmapi.factor b/basis/windows/dwmapi/dwmapi.factor index 998846ebc2..8f68643e0a 100644 --- a/basis/windows/dwmapi/dwmapi.factor +++ b/basis/windows/dwmapi/dwmapi.factor @@ -21,7 +21,7 @@ STRUCT: DWM_BLURBEHIND : full-window-margins ( -- MARGINS ) -1 -1 -1 -1 ; inline -<< "dwmapi" "dwmapi.dll" "stdcall" add-library >> +<< "dwmapi" "dwmapi.dll" stdcall add-library >> LIBRARY: dwmapi diff --git a/basis/windows/nt/nt.factor b/basis/windows/nt/nt.factor index 2de60e524d..4b119ba5fa 100644 --- a/basis/windows/nt/nt.factor +++ b/basis/windows/nt/nt.factor @@ -1,35 +1,35 @@ USING: alien sequences alien.libraries ; { - { "advapi32" "advapi32.dll" "stdcall" } - { "dinput" "dinput8.dll" "stdcall" } - { "gdi32" "gdi32.dll" "stdcall" } - { "user32" "user32.dll" "stdcall" } - { "kernel32" "kernel32.dll" "stdcall" } - { "winsock" "ws2_32.dll" "stdcall" } - { "mswsock" "mswsock.dll" "stdcall" } - { "shell32" "shell32.dll" "stdcall" } + { "advapi32" "advapi32.dll" stdcall } + { "dinput" "dinput8.dll" stdcall } + { "gdi32" "gdi32.dll" stdcall } + { "user32" "user32.dll" stdcall } + { "kernel32" "kernel32.dll" stdcall } + { "winsock" "ws2_32.dll" stdcall } + { "mswsock" "mswsock.dll" stdcall } + { "shell32" "shell32.dll" stdcall } { "libc" "msvcrt.dll" cdecl } { "libm" "msvcrt.dll" cdecl } - { "gl" "opengl32.dll" "stdcall" } - { "glu" "glu32.dll" "stdcall" } - { "ole32" "ole32.dll" "stdcall" } - { "usp10" "usp10.dll" "stdcall" } - { "psapi" "psapi.dll" "stdcall" } - { "xinput" "xinput1_3.dll" "stdcall" } - { "dxgi" "dxgi.dll" "stdcall" } - { "d2d1" "d2d1.dll" "stdcall" } - { "d3d9" "d3d9.dll" "stdcall" } - { "d3d10" "d3d10.dll" "stdcall" } - { "d3d10_1" "d3d10_1.dll" "stdcall" } - { "d3d11" "d3d11.dll" "stdcall" } - { "d3dcompiler" "d3dcompiler_42.dll" "stdcall" } - { "d3dcsx" "d3dcsx_42.dll" "stdcall" } - { "d3dx9" "d3dx9_42.dll" "stdcall" } - { "d3dx10" "d3dx10_42.dll" "stdcall" } - { "d3dx11" "d3dx11_42.dll" "stdcall" } - { "dwrite" "dwrite.dll" "stdcall" } - { "x3daudio" "x3daudio1_6.dll" "stdcall" } - { "xactengine" "xactengine3_5.dll" "stdcall" } - { "xapofx" "xapofx1_3.dll" "stdcall" } - { "xaudio2" "xaudio2_5.dll" "stdcall" } + { "gl" "opengl32.dll" stdcall } + { "glu" "glu32.dll" stdcall } + { "ole32" "ole32.dll" stdcall } + { "usp10" "usp10.dll" stdcall } + { "psapi" "psapi.dll" stdcall } + { "xinput" "xinput1_3.dll" stdcall } + { "dxgi" "dxgi.dll" stdcall } + { "d2d1" "d2d1.dll" stdcall } + { "d3d9" "d3d9.dll" stdcall } + { "d3d10" "d3d10.dll" stdcall } + { "d3d10_1" "d3d10_1.dll" stdcall } + { "d3d11" "d3d11.dll" stdcall } + { "d3dcompiler" "d3dcompiler_42.dll" stdcall } + { "d3dcsx" "d3dcsx_42.dll" stdcall } + { "d3dx9" "d3dx9_42.dll" stdcall } + { "d3dx10" "d3dx10_42.dll" stdcall } + { "d3dx11" "d3dx11_42.dll" stdcall } + { "dwrite" "dwrite.dll" stdcall } + { "x3daudio" "x3daudio1_6.dll" stdcall } + { "xactengine" "xactengine3_5.dll" stdcall } + { "xapofx" "xapofx1_3.dll" stdcall } + { "xaudio2" "xaudio2_5.dll" stdcall } } [ first3 add-library ] each diff --git a/extra/opencl/ffi/ffi.factor b/extra/opencl/ffi/ffi.factor index 8f0400dd20..9ee2135cb6 100644 --- a/extra/opencl/ffi/ffi.factor +++ b/extra/opencl/ffi/ffi.factor @@ -8,7 +8,7 @@ IN: opencl.ffi { [ os windows? ] [ "OpenCL.dll" ] } { [ os macosx? ] [ "/System/Library/Frameworks/OpenCL.framework/OpenCL" ] } { [ os unix? ] [ "libOpenCL.so" ] } - } cond "stdcall" add-library >> + } cond stdcall add-library >> LIBRARY: opencl ! cl_platform.h diff --git a/unmaintained/cryptlib/libcl/libcl.factor b/unmaintained/cryptlib/libcl/libcl.factor index f38ee856a1..8895d0b3a6 100644 --- a/unmaintained/cryptlib/libcl/libcl.factor +++ b/unmaintained/cryptlib/libcl/libcl.factor @@ -13,7 +13,7 @@ USING: alien kernel system combinators alien.syntax ; IN: cryptlib.libcl << "libcl" { - { [ win32? ] [ "cl32.dll" "stdcall" ] } + { [ win32? ] [ "cl32.dll" stdcall ] } { [ macosx? ] [ "libcl.dylib" cdecl ] } { [ unix? ] [ "libcl.so" cdecl ] } } cond add-library >> diff --git a/unmaintained/db/mysql/ffi/ffi.factor b/unmaintained/db/mysql/ffi/ffi.factor index 1f50035a81..98fd0b38cb 100644 --- a/unmaintained/db/mysql/ffi/ffi.factor +++ b/unmaintained/db/mysql/ffi/ffi.factor @@ -6,7 +6,7 @@ USING: alien alien.syntax combinators kernel system ; IN: db.mysql.ffi << "mysql" { - { [ os winnt? ] [ "libmySQL.dll" "stdcall" ] } + { [ os winnt? ] [ "libmySQL.dll" stdcall ] } { [ os macosx? ] [ "libmysqlclient.14.dylib" cdecl ] } { [ os unix? ] [ "libmysqlclient.so.14" cdecl ] } } cond add-library >> diff --git a/unmaintained/ldap/libldap/libldap.factor b/unmaintained/ldap/libldap/libldap.factor index 83d31ed968..9b7dd36a69 100644 --- a/unmaintained/ldap/libldap/libldap.factor +++ b/unmaintained/ldap/libldap/libldap.factor @@ -10,7 +10,7 @@ USING: alien alien.syntax combinators kernel system ; IN: ldap.libldap << "libldap" { - { [ win32? ] [ "libldap.dll" "stdcall" ] } + { [ win32? ] [ "libldap.dll" stdcall ] } { [ macosx? ] [ "libldap.dylib" cdecl ] } { [ unix? ] [ "libldap.so" cdecl ] } } cond add-library >> diff --git a/unmaintained/odbc/odbc.factor b/unmaintained/odbc/odbc.factor index 06d47b8937..6dcddb5bd5 100644 --- a/unmaintained/odbc/odbc.factor +++ b/unmaintained/odbc/odbc.factor @@ -5,7 +5,7 @@ combinators alien.c-types strings sequences namespaces make words math threads io.encodings.ascii ; IN: odbc -<< "odbc" "odbc32.dll" "stdcall" add-library >> +<< "odbc" "odbc32.dll" stdcall add-library >> LIBRARY: odbc diff --git a/unmaintained/oracle/liboci/liboci.factor b/unmaintained/oracle/liboci/liboci.factor index 71473ea7c8..4e8ebfc860 100644 --- a/unmaintained/oracle/liboci/liboci.factor +++ b/unmaintained/oracle/liboci/liboci.factor @@ -12,7 +12,7 @@ USING: alien alien.syntax combinators kernel system ; IN: oracle.liboci "oci" { - { [ os winnt? ] [ "oci.dll" "stdcall" ] } + { [ os winnt? ] [ "oci.dll" stdcall ] } { [ os macosx? ] [ "$DYLD_LIBRARY_PATH/libclntsh.dylib" cdecl ] } { [ os unix? ] [ "$DYLD_LIBRARY_PATH/libclntsh.so.10.1" cdecl ] } } cond add-library diff --git a/unmaintained/pdf/libhpdf/libhpdf.factor b/unmaintained/pdf/libhpdf/libhpdf.factor index a3d5dd574f..c365f6944f 100644 --- a/unmaintained/pdf/libhpdf/libhpdf.factor +++ b/unmaintained/pdf/libhpdf/libhpdf.factor @@ -10,7 +10,7 @@ USING: alien alien.syntax combinators system ; IN: pdf.libhpdf << "libhpdf" { - { [ win32? ] [ "libhpdf.dll" "stdcall" ] } + { [ win32? ] [ "libhpdf.dll" stdcall ] } { [ macosx? ] [ "libhpdf.dylib" cdecl ] } { [ unix? ] [ "$LD_LIBRARY_PATH/libhpdf.so" cdecl ] } } cond add-library >> From 98d1e7d00663d84024e8d31244c28542571ad59d Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 31 Mar 2010 19:57:04 -0700 Subject: [PATCH 524/713] update alien.libraries docs to link cdecl/stdcall symbols --- basis/alien/libraries/libraries-docs.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/alien/libraries/libraries-docs.factor b/basis/alien/libraries/libraries-docs.factor index 7ee953581a..d2e510e0e9 100644 --- a/basis/alien/libraries/libraries-docs.factor +++ b/basis/alien/libraries/libraries-docs.factor @@ -6,7 +6,7 @@ IN: alien.libraries HELP: { $values - { "path" "a pathname string" } { "abi" "the ABI used by the library, either " { $snippet cdecl } " or " { $snippet stdcall } } + { "path" "a pathname string" } { "abi" "the ABI used by the library, either " { $link cdecl } " or " { $link stdcall } } { "library" library } } { $description "Opens a C library using the path and ABI parameters and outputs a library tuple." } { $notes "User code should use " { $link add-library } " so that the opened library is added to a global hashtable, " { $link libraries } "." } ; @@ -19,7 +19,7 @@ HELP: library { $description "Looks up a library by its logical name. The library object is a hashtable with the following keys:" { $list { { $snippet "name" } " - the full path of the C library binary" } - { { $snippet "abi" } " - the ABI used by the library, either " { $snippet cdecl } " or " { $snippet stdcall } } + { { $snippet "abi" } " - the ABI used by the library, either " { $link cdecl } " or " { $link stdcall } } { { $snippet "dll" } " - an instance of the " { $link dll } " class; only set if the library is loaded" } } } ; From 6805dc6401490baaef6d83ab7889f3d51a1f3b37 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 31 Mar 2010 19:57:29 -0700 Subject: [PATCH 525/713] =?UTF-8?q?remove=20redundant=20=C2=ABstdcall=3F?= =?UTF-8?q?=C2=BB=20word=20from=20cpu.x86.32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- basis/cpu/x86/32/32.factor | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index c96d961d65..d296b730d2 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -291,9 +291,6 @@ M:: x86.32 %binary-float-function ( dst src1 src2 func -- ) func "libm" load-library %alien-invoke dst float-function-return ; -: stdcall? ( params -- ? ) - abi>> stdcall = ; - : funny-large-struct-return? ( params -- ? ) #! MINGW ABI incompatibility disaster [ return>> large-struct? ] @@ -307,7 +304,7 @@ M: x86.32 %cleanup ( params -- ) #! b) If we just called a function returning a struct, we #! have to fix ESP. { - { [ dup stdcall? ] [ drop ESP stack-frame get params>> SUB ] } + { [ dup abi>> stdcall? ] [ drop ESP stack-frame get params>> SUB ] } { [ dup funny-large-struct-return? ] [ drop EAX PUSH ] } [ drop ] } cond ; From 9d3326658c8f661c70f39a0fb236d4da6b2a62f9 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 31 Mar 2010 20:30:04 -0700 Subject: [PATCH 526/713] alien: add singletons for thiscall and fastcall --- core/alien/alien.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/alien/alien.factor b/core/alien/alien.factor index 7a539d4dd5..4dab6f8452 100644 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -5,9 +5,9 @@ kernel.private byte-arrays byte-vectors arrays init continuations.private ; IN: alien -SINGLETONS: stdcall cdecl mingw ; +SINGLETONS: stdcall thiscall fastcall cdecl mingw ; -UNION: abi stdcall cdecl mingw ; +UNION: abi stdcall thiscall fastcall cdecl mingw ; PREDICATE: pinned-alien < alien underlying>> not ; From 1e1425a6e18fb03340ace8432b4cb64e49c0f782 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 1 Apr 2010 00:21:41 -0400 Subject: [PATCH 527/713] cpu.ppc: non-optimizing compiler backend fixes --- basis/cpu/ppc/bootstrap.factor | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/basis/cpu/ppc/bootstrap.factor b/basis/cpu/ppc/bootstrap.factor index 53edcd427d..83be0150d8 100644 --- a/basis/cpu/ppc/bootstrap.factor +++ b/basis/cpu/ppc/bootstrap.factor @@ -98,7 +98,7 @@ CONSTANT: nv-reg 17 2 vm-reg vm-context-offset STW ! Save C callstack pointer - 2 context-callstack-save-offset 1 STW + 1 2 context-callstack-save-offset STW ! Load Factor callstack pointer 1 2 context-callstack-bottom-offset LWZ @@ -108,6 +108,9 @@ CONSTANT: nv-reg 17 2 MTLR BLRL + ! Load VM again, pointlessly + 0 vm-reg LOAD32 rc-absolute-ppc-2/2 rt-vm jit-rel + ! Load C callstack pointer 2 vm-reg vm-context-offset LWZ 1 2 context-callstack-save-offset LWZ @@ -141,7 +144,6 @@ CONSTANT: nv-reg 17 rs-reg ctx-reg context-retainstack-offset STW ; : jit-restore-context ( -- ) - jit-load-context ds-reg ctx-reg context-datastack-offset LWZ rs-reg ctx-reg context-retainstack-offset LWZ ; @@ -317,6 +319,7 @@ CONSTANT: nv-reg 17 3 6 MR 4 vm-reg MR "inline_cache_miss" jit-call + jit-load-context jit-restore-context ; [ jit-load-return-address jit-inline-cache-miss ] @@ -394,9 +397,11 @@ CONSTANT: nv-reg 17 3 vm-reg MR "begin_callback" jit-call + jit-load-context jit-restore-context ! Call quotation + 3 nv-reg MR jit-call-quot jit-save-context @@ -414,6 +419,7 @@ CONSTANT: nv-reg 17 0 vm-reg LOAD32 0 rc-absolute-ppc-2/2 jit-vm ! Load ds and rs registers + jit-load-context jit-restore-context ! We have changed the stack; load return address again @@ -755,33 +761,34 @@ CONSTANT: nv-reg 17 : jit-pop-context-and-param ( -- ) 3 ds-reg 0 LWZ 3 3 alien-offset LWZ - 4 ds-reg -8 LWZ - ds-reg ds-reg 16 SUBI ; + 4 ds-reg -4 LWZ + ds-reg ds-reg 8 SUBI ; : jit-push-param ( -- ) - ds-reg ds-reg 8 ADDI + ds-reg ds-reg 4 ADDI 4 ds-reg 0 STW ; : jit-set-context ( -- ) jit-pop-context-and-param - 4 jit-switch-context + 3 jit-switch-context jit-push-param ; [ jit-set-context ] \ (set-context) define-sub-primitive : jit-pop-quot-and-param ( -- ) 3 ds-reg 0 LWZ - 4 ds-reg -8 LWZ - ds-reg ds-reg 16 SUBI ; + 4 ds-reg -4 LWZ + ds-reg ds-reg 8 SUBI ; : jit-start-context ( -- ) ! Create the new context in return-reg 3 vm-reg MR "new_context" jit-call + 6 3 MR jit-pop-quot-and-param - 3 jit-switch-context + 6 jit-switch-context jit-push-param From 1f9fbd22eb6d54bb8fc953def8a34f2ae01772a2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 1 Apr 2010 00:22:10 -0400 Subject: [PATCH 528/713] cpu.ppc: updating optimizing compiler backend for recent changes (untested) --- basis/cpu/ppc/ppc.factor | 45 ++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor index 36beb86792..dbc313052f 100644 --- a/basis/cpu/ppc/ppc.factor +++ b/basis/cpu/ppc/ppc.factor @@ -678,8 +678,6 @@ M: ppc %box-large-struct ( n c-type -- ) M:: ppc %restore-context ( temp1 temp2 -- ) temp1 "ctx" %vm-field - temp2 1 stack-frame get total-size>> ADDI - temp2 temp1 "callstack-bottom" context-field-offset STW ds-reg temp1 "datastack" context-field-offset LWZ rs-reg temp1 "retainstack" context-field-offset LWZ ; @@ -692,14 +690,6 @@ M:: ppc %save-context ( temp1 temp2 -- ) M: ppc %alien-invoke ( symbol dll -- ) [ 11 ] 2dip %alien-global 11 MTLR BLRL ; -M: ppc %alien-callback ( quot -- ) - 3 4 %restore-context - 3 swap %load-reference - 4 3 quot-entry-point-offset LWZ - 4 MTLR - BLRL - 3 4 %save-context ; - M: ppc %prepare-alien-indirect ( -- ) 3 ds-reg 0 LWZ ds-reg ds-reg 4 SUBI @@ -710,18 +700,6 @@ M: ppc %prepare-alien-indirect ( -- ) M: ppc %alien-indirect ( -- ) 16 MTLR BLRL ; -M: ppc %callback-value ( ctype -- ) - ! Save top of data stack - 3 ds-reg 0 LWZ - 3 1 0 local@ STW - 3 %load-vm-addr - ! Restore data/call/retain stacks - "unnest_context" f %alien-invoke - ! Restore top of data stack - 3 1 0 local@ LWZ - ! Unbox former top of data stack to return registers - unbox-return ; - M: ppc immediate-arithmetic? ( n -- ? ) -32768 32767 between? ; M: ppc immediate-bitwise? ( n -- ? ) 0 65535 between? ; @@ -757,14 +735,31 @@ M: ppc %box-small-struct ( c-type -- ) 4 3 4 LWZ 3 3 0 LWZ ; -M: ppc %nest-context ( -- ) +M: ppc %begin-callback ( -- ) 3 %load-vm-addr - "nest_context" f %alien-invoke ; + "begin_callback" f %alien-invoke ; -M: ppc %unnest-context ( -- ) +M: ppc %alien-callback ( quot -- ) + 3 4 %restore-context + 3 swap %load-reference + 4 3 quot-entry-point-offset LWZ + 4 MTLR + BLRL + 3 4 %save-context ; + +M: ppc %end-callback ( -- ) 3 %load-vm-addr "unnest_context" f %alien-invoke ; +M: ppc %end-callback-value ( ctype -- ) + ! Save top of data stack + 12 ds-reg 0 LWZ + %end-callback + ! Restore top of data stack + 3 12 MR + ! Unbox former top of data stack to return registers + unbox-return ; + M: ppc %unbox-small-struct ( size -- ) heap-size cell align cell /i { { 1 [ %unbox-struct-1 ] } From 116c8850acbe65036672216b103da09d538c2d49 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Thu, 1 Apr 2010 00:44:32 -0700 Subject: [PATCH 529/713] PPM image loading and saving --- basis/images/ppm/authors.txt | 1 + basis/images/ppm/ppm-tests.factor | 7 + basis/images/ppm/ppm.factor | 59 + basis/images/ppm/summary.txt | 1 + extra/images/testing/ppm/ascii.fig | Bin 0 -> 57660 bytes extra/images/testing/ppm/ascii.ppm | 57604 ++++++++++++++++++++++++++ extra/images/testing/ppm/binary.fig | Bin 0 -> 57660 bytes extra/images/testing/ppm/binary.ppm | Bin 0 -> 57654 bytes 8 files changed, 57672 insertions(+) create mode 100644 basis/images/ppm/authors.txt create mode 100644 basis/images/ppm/ppm-tests.factor create mode 100644 basis/images/ppm/ppm.factor create mode 100644 basis/images/ppm/summary.txt create mode 100644 extra/images/testing/ppm/ascii.fig create mode 100644 extra/images/testing/ppm/ascii.ppm create mode 100644 extra/images/testing/ppm/binary.fig create mode 100644 extra/images/testing/ppm/binary.ppm diff --git a/basis/images/ppm/authors.txt b/basis/images/ppm/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/basis/images/ppm/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/basis/images/ppm/ppm-tests.factor b/basis/images/ppm/ppm-tests.factor new file mode 100644 index 0000000000..208af76dd2 --- /dev/null +++ b/basis/images/ppm/ppm-tests.factor @@ -0,0 +1,7 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: images.testing ; +IN: images.ppm.tests + +"vocab:images/testing/ppm/binary.ppm" decode-test +"vocab:images/testing/ppm/ascii.ppm" decode-test diff --git a/basis/images/ppm/ppm.factor b/basis/images/ppm/ppm.factor new file mode 100644 index 0000000000..d50d51797d --- /dev/null +++ b/basis/images/ppm/ppm.factor @@ -0,0 +1,59 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors ascii combinators images images.loader io +io.encodings.ascii io.encodings.string kernel locals make math +math.parser prettyprint sequences ; +IN: images.ppm + +SINGLETON: ppm-image +"ppm" ppm-image register-image-class + +: read-token ( -- token ) + [ read1 dup blank? + [ t ] + [ dup CHAR: # = + [ "\n" read-until 2drop t ] + [ f ] if + ] if + ] [ drop ] while + " \n\r\t" read-until drop swap + prefix ascii decode ; + +: read-number ( -- number ) + read-token string>number ; + +:: read-numbers ( n lim -- ) + n lim = [ + read-number , + n 1 + lim read-numbers + ] unless ; + +:: read-ppm ( -- image ) + read-token :> type + read-number :> width + read-number :> height + read-number :> max + width height 3 * * :> npixels + type { + { "P3" [ [ 0 npixels read-numbers ] B{ } make ] } + { "P6" [ npixels read ] } + } case :> data + + image new + RGB >>component-order + { width height } >>dim + f >>upside-down? + data >>bitmap + ubyte-components >>component-type ; + +M: ppm-image stream>image + drop [ read-ppm ] with-input-stream ; + +M: ppm-image image>stream + drop { + [ drop "P6\n" ascii encode write ] + [ dim>> first number>string " " append ascii encode write ] + [ dim>> second number>string "\n" append ascii encode write ] + [ drop "255\n" ascii encode write ] + [ bitmap>> write ] + } cleave ; diff --git a/basis/images/ppm/summary.txt b/basis/images/ppm/summary.txt new file mode 100644 index 0000000000..f527e2a6de --- /dev/null +++ b/basis/images/ppm/summary.txt @@ -0,0 +1 @@ +Image loading for PPM image files. diff --git a/extra/images/testing/ppm/ascii.fig b/extra/images/testing/ppm/ascii.fig new file mode 100644 index 0000000000000000000000000000000000000000..68a1fa1ac10fd7c8dcdddb7407527bd327f83baf GIT binary patch literal 57660 zcmeHNTZo-k6`sTkSRcGSwWTPuPfA4cAX*9~MTl4nHOAP7f{hZyhh$PFCHUCZ`k*g9 zl|E@7DpZhC>{}}$DEeR~*XEu{(4f>b_X{)0470m-_Bre9voC9}f9-!CPLlO=m|6c? z>-*N)-#2q|&Y5i9J@?Abwr~CEwz*%rZ(Cp4`qIudukT#iJ@@jajZe(JxO?t5FZ}rD zySAvpcr!*flr%;*Je#|2<>$QUz22RX`O`1yli5po;?Qw_M{qx=?EGR4Bl) zmFSs@Gw2c-1qkE%EoJ6wx}gI7I>=#bco?OQ6yP{AnVx91LSn|uZ{U=Wb&lWOB{S{I&J#yFQrA z{5G-dlLX>%k}edJ2+susLk?2RcXc+`UmQd?Owy*BS?&~s5k!erfB?D@4Nq2cX36r& z5&UG0>=VPf;}pHfHRROD_51l8mdML|Bv8bxVrgO?)eLf{@MZ5BCw1VEB!P62aH_8o zy#Q8=n)5r0R5cB54UQc|51s`Bq8Urr%n$l9vB*RBV88f%3B3 zt~{NN>6$sF^w>je$WfJm_fjhE;2L0-%+N}d;EX+b$E3^EOr0~%mrrBgDv z;G|4bdTh%rSrj%0>@i>5!8O1{nL(8(*-3l!jzg7OvZ!qi*jK)|05-tHN~dIS*-1I3 zK#wD5HWO{RB~iUxkOTIT&karHVWP~SN|gAdgdKh<;P*@XI3U5>q>_FTJNpWJa(?Wl zS2`tw*BqQk1IqHnak&N-xhekX^`_2i^u<~i;_PmZk;F4lZvKs-3dkxtDVLg+zGSx{pT z6HEMfOw10zF&*^(`h@f$|r2mN$8IyVlMXh0rdN~xtO5sRO->+PII9dO(cS@ zoIUpEln?TPi2+0MRzRDC^yP1ooK6z9Vu@yGT20CxBxMT(B*|MDbBwC-H)iXUK@*9f z6Jd|dNzLP=Y+}q4XJpJVO6G6OBghc8Vo5;T3nUginUT#(QUysFbByBn8>4#3pov7# z%OC+spmy$7zzmQao1d34$0+qT*2LGDh+`l#LvUh=NmXp)_zOKn9zg@~Yl|fTZ9N1< zrUUUHn$}gtO*7xE{?eyzQAI1`pv5>Qr~1njiqjT53mFcu zU61SpkYL7An>3aA3AfGVI0r~;~hDxeCe0;+&2 zpbDr0s(>n>3aA3AfGVI0r~;~hDxeCe0;+&2pbDr0s=ytsz@8aXe7FPV+VJ>S|6)#T zH2Xeh=09!@e$kxyk-7GFEZV>^jHS9H1EAh=6v(;e=N*rq@ncuL^p@GPHu0n4@8D2= z24a3P0P3wkfu!1whbTeA;jdVyPCjK8kC@eEvwY56{DV3ExPuP9CK>q2F)qCkDUej# zF%czbnE!ryK8=oZSC&#$-Mx;PeZO7z$>c=<- zUO&UXzk5GDGb-Qz`n&%NqhgYQpBxe0QPET#Fu9DAlPD$iUjESf z3$Ls3+Ox)H%qk{qz)z0B?wp&XZpq{X&P2>5O0d|`ubXqPn#H4Lb;+#WG&lB`6W_9K zzW?RX*6_Ow8Te<~x0s(C5%HqMtoi0psvnGC3?Z{7%eurTDAc=ElFwe`d|$ zuiD=Nkm$gJX5sth+TX@jz4c$4-2eIEbMoyXKRL$5ySXuMtvqnQeM)f`e71J*A)CDZ zk3j~0z@QBpZk{!#pRpzQ>aI$-BXNoi7>D1I$zf5ycTfQSQgaZ%!0|D1aJVqnI=llIDGYx>HSf!){uK_%R$(zuBN ztLE@J`=W0CWA>>MUu(fEcr^(AUV7WUty@~KADhE1JjSj{_!yVoG*RHf?+3=gna2v1h%{=W02l=SU-$S110RG6u1dIIqC!*wRX`O`1yli5Kow90Q~_0>UV)DQ DnAHDz literal 0 HcmV?d00001 diff --git a/extra/images/testing/ppm/ascii.ppm b/extra/images/testing/ppm/ascii.ppm new file mode 100644 index 0000000000..326b70ecc0 --- /dev/null +++ b/extra/images/testing/ppm/ascii.ppm @@ -0,0 +1,57604 @@ +P3 +# CREATOR: GIMP PNM Filter Version 1.1 +160 120 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +243 +50 +50 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +50 +86 +243 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +0 +255 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +242 +190 +255 +218 +71 +255 +207 +17 +255 +205 +4 +255 +210 +31 +255 +223 +95 +255 +243 +196 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +239 +174 +255 +204 +2 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +213 +43 +255 +204 +0 +255 +219 +77 +255 +247 +214 +255 +254 +251 +255 +251 +234 +255 +238 +169 +255 +217 +63 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +205 +5 +255 +204 +0 +255 +252 +238 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +210 +32 +255 +204 +0 +255 +230 +132 +255 +251 +237 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +236 +158 +255 +204 +0 +255 +204 +0 +255 +204 +1 +255 +211 +36 +255 +221 +87 +255 +237 +164 +255 +254 +250 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +242 +190 +255 +219 +77 +255 +206 +11 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +214 +48 +255 +251 +233 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +254 +252 +255 +247 +213 +255 +234 +152 +255 +211 +35 +255 +204 +0 +255 +222 +92 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +248 +220 +255 +204 +0 +255 +208 +19 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +251 +235 +255 +204 +0 +255 +205 +5 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +1 +255 +204 +0 +255 +255 +254 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +1 +255 +204 +0 +255 +255 +254 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +1 +255 +204 +0 +255 +255 +254 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +215 +54 +255 +234 +150 +255 +247 +215 +255 +254 +248 +255 +254 +249 +255 +245 +204 +255 +218 +68 +255 +204 +0 +255 +212 +42 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +208 +19 +255 +204 +0 +255 +242 +190 +255 +255 +254 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +208 +19 +255 +204 +0 +255 +242 +190 +255 +255 +254 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +208 +19 +255 +204 +0 +255 +242 +190 +255 +255 +254 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +247 +217 +255 +204 +2 +255 +206 +10 +255 +251 +236 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +252 +239 +255 +206 +11 +255 +204 +2 +255 +247 +216 +255 +255 +255 +255 +241 +186 +255 +219 +75 +255 +207 +15 +255 +206 +9 +255 +215 +57 +255 +242 +188 +255 +255 +255 +255 +255 +255 +255 +247 +217 +255 +204 +2 +255 +206 +10 +255 +251 +236 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +252 +239 +255 +206 +11 +255 +204 +2 +255 +247 +216 +255 +255 +255 +255 +241 +186 +255 +219 +75 +255 +207 +15 +255 +206 +9 +255 +215 +57 +255 +242 +188 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +2 +255 +238 +172 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +221 +84 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +221 +84 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +221 +84 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +221 +85 +255 +204 +0 +255 +230 +132 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +232 +138 +255 +204 +0 +255 +220 +80 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +205 +5 +255 +245 +204 +255 +255 +255 +255 +255 +255 +255 +221 +85 +255 +204 +0 +255 +230 +132 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +232 +138 +255 +204 +0 +255 +220 +80 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +205 +5 +255 +245 +204 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +245 +203 +255 +226 +111 +255 +213 +46 +255 +206 +9 +255 +205 +5 +255 +209 +27 +255 +221 +83 +255 +243 +195 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +250 +229 +255 +221 +83 +255 +208 +18 +255 +204 +1 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +250 +229 +255 +221 +83 +255 +208 +18 +255 +204 +1 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +250 +229 +255 +221 +83 +255 +208 +18 +255 +204 +1 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +245 +205 +255 +204 +0 +255 +209 +25 +255 +254 +249 +255 +255 +255 +255 +255 +255 +255 +254 +251 +255 +210 +29 +255 +204 +0 +255 +244 +198 +255 +255 +255 +255 +255 +255 +255 +221 +84 +255 +245 +205 +255 +254 +249 +255 +249 +227 +255 +222 +88 +255 +204 +0 +255 +222 +88 +255 +255 +255 +255 +255 +255 +255 +245 +205 +255 +204 +0 +255 +209 +25 +255 +254 +249 +255 +255 +255 +255 +255 +255 +255 +254 +251 +255 +210 +29 +255 +204 +0 +255 +244 +198 +255 +255 +255 +255 +255 +255 +255 +221 +84 +255 +245 +205 +255 +254 +249 +255 +249 +227 +255 +222 +88 +255 +204 +0 +255 +222 +88 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +218 +71 +255 +204 +0 +255 +236 +159 +255 +255 +255 +255 +255 +255 +255 +238 +168 +255 +204 +0 +255 +216 +60 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +252 +239 +255 +204 +0 +255 +210 +29 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +218 +71 +255 +204 +0 +255 +236 +159 +255 +255 +255 +255 +255 +255 +255 +238 +168 +255 +204 +0 +255 +216 +60 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +252 +239 +255 +204 +0 +255 +210 +29 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +206 +10 +255 +206 +11 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +206 +10 +255 +206 +11 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +242 +192 +255 +204 +0 +255 +213 +46 +255 +255 +255 +255 +255 +255 +255 +215 +56 +255 +204 +0 +255 +240 +178 +255 +255 +255 +255 +255 +255 +255 +254 +252 +255 +232 +139 +255 +214 +48 +255 +206 +10 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +205 +6 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +242 +192 +255 +204 +0 +255 +213 +46 +255 +255 +255 +255 +255 +255 +255 +215 +56 +255 +204 +0 +255 +240 +178 +255 +255 +255 +255 +255 +255 +255 +254 +252 +255 +232 +139 +255 +214 +48 +255 +206 +10 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +205 +6 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +209 +26 +255 +209 +27 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +209 +26 +255 +209 +27 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +216 +58 +255 +204 +0 +255 +241 +187 +255 +244 +199 +255 +204 +0 +255 +212 +42 +255 +255 +254 +255 +255 +255 +255 +255 +255 +255 +227 +113 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +216 +58 +255 +204 +0 +255 +241 +187 +255 +244 +199 +255 +204 +0 +255 +212 +42 +255 +255 +254 +255 +255 +255 +255 +255 +255 +255 +227 +113 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +213 +43 +255 +213 +43 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +213 +43 +255 +213 +43 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +240 +179 +255 +204 +0 +255 +218 +72 +255 +221 +86 +255 +204 +0 +255 +236 +158 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +208 +18 +255 +204 +0 +255 +238 +168 +255 +252 +240 +255 +255 +254 +255 +252 +241 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +240 +179 +255 +204 +0 +255 +218 +72 +255 +221 +86 +255 +204 +0 +255 +236 +158 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +208 +18 +255 +204 +0 +255 +238 +168 +255 +252 +240 +255 +255 +254 +255 +252 +241 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +254 +255 +213 +45 +255 +204 +1 +255 +205 +3 +255 +209 +27 +255 +254 +249 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +206 +9 +255 +204 +0 +255 +239 +176 +255 +254 +248 +255 +248 +221 +255 +221 +87 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +254 +255 +213 +45 +255 +204 +1 +255 +205 +3 +255 +209 +27 +255 +254 +249 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +206 +9 +255 +204 +0 +255 +239 +176 +255 +254 +248 +255 +248 +221 +255 +221 +87 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +237 +165 +255 +204 +0 +255 +204 +0 +255 +232 +138 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +220 +81 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +219 +76 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +237 +165 +255 +204 +0 +255 +204 +0 +255 +232 +138 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +220 +81 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +219 +76 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +248 +218 +255 +204 +0 +255 +207 +15 +255 +252 +241 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +251 +235 +255 +220 +82 +255 +206 +10 +255 +207 +16 +255 +223 +96 +255 +252 +240 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +248 +218 +255 +204 +0 +255 +207 +15 +255 +252 +241 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +251 +235 +255 +220 +82 +255 +206 +10 +255 +207 +16 +255 +223 +96 +255 +252 +240 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +236 +158 +255 +204 +0 +255 +227 +116 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +236 +158 +255 +204 +0 +255 +227 +116 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +252 +238 +255 +218 +71 +255 +204 +0 +255 +247 +213 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +252 +238 +255 +218 +71 +255 +204 +0 +255 +247 +213 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +219 +74 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +204 +0 +255 +204 +0 +255 +219 +74 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +205 +4 +255 +217 +65 +255 +250 +229 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +204 +0 +255 +205 +4 +255 +217 +65 +255 +250 +229 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 +255 diff --git a/extra/images/testing/ppm/binary.fig b/extra/images/testing/ppm/binary.fig new file mode 100644 index 0000000000000000000000000000000000000000..68a1fa1ac10fd7c8dcdddb7407527bd327f83baf GIT binary patch literal 57660 zcmeHNTZo-k6`sTkSRcGSwWTPuPfA4cAX*9~MTl4nHOAP7f{hZyhh$PFCHUCZ`k*g9 zl|E@7DpZhC>{}}$DEeR~*XEu{(4f>b_X{)0470m-_Bre9voC9}f9-!CPLlO=m|6c? z>-*N)-#2q|&Y5i9J@?Abwr~CEwz*%rZ(Cp4`qIudukT#iJ@@jajZe(JxO?t5FZ}rD zySAvpcr!*flr%;*Je#|2<>$QUz22RX`O`1yli5po;?Qw_M{qx=?EGR4Bl) zmFSs@Gw2c-1qkE%EoJ6wx}gI7I>=#bco?OQ6yP{AnVx91LSn|uZ{U=Wb&lWOB{S{I&J#yFQrA z{5G-dlLX>%k}edJ2+susLk?2RcXc+`UmQd?Owy*BS?&~s5k!erfB?D@4Nq2cX36r& z5&UG0>=VPf;}pHfHRROD_51l8mdML|Bv8bxVrgO?)eLf{@MZ5BCw1VEB!P62aH_8o zy#Q8=n)5r0R5cB54UQc|51s`Bq8Urr%n$l9vB*RBV88f%3B3 zt~{NN>6$sF^w>je$WfJm_fjhE;2L0-%+N}d;EX+b$E3^EOr0~%mrrBgDv z;G|4bdTh%rSrj%0>@i>5!8O1{nL(8(*-3l!jzg7OvZ!qi*jK)|05-tHN~dIS*-1I3 zK#wD5HWO{RB~iUxkOTIT&karHVWP~SN|gAdgdKh<;P*@XI3U5>q>_FTJNpWJa(?Wl zS2`tw*BqQk1IqHnak&N-xhekX^`_2i^u<~i;_PmZk;F4lZvKs-3dkxtDVLg+zGSx{pT z6HEMfOw10zF&*^(`h@f$|r2mN$8IyVlMXh0rdN~xtO5sRO->+PII9dO(cS@ zoIUpEln?TPi2+0MRzRDC^yP1ooK6z9Vu@yGT20CxBxMT(B*|MDbBwC-H)iXUK@*9f z6Jd|dNzLP=Y+}q4XJpJVO6G6OBghc8Vo5;T3nUginUT#(QUysFbByBn8>4#3pov7# z%OC+spmy$7zzmQao1d34$0+qT*2LGDh+`l#LvUh=NmXp)_zOKn9zg@~Yl|fTZ9N1< zrUUUHn$}gtO*7xE{?eyzQAI1`pv5>Qr~1njiqjT53mFcu zU61SpkYL7An>3aA3AfGVI0r~;~hDxeCe0;+&2 zpbDr0s(>n>3aA3AfGVI0r~;~hDxeCe0;+&2pbDr0s=ytsz@8aXe7FPV+VJ>S|6)#T zH2Xeh=09!@e$kxyk-7GFEZV>^jHS9H1EAh=6v(;e=N*rq@ncuL^p@GPHu0n4@8D2= z24a3P0P3wkfu!1whbTeA;jdVyPCjK8kC@eEvwY56{DV3ExPuP9CK>q2F)qCkDUej# zF%czbnE!ryK8=oZSC&#$-Mx;PeZO7z$>c=<- zUO&UXzk5GDGb-Qz`n&%NqhgYQpBxe0QPET#Fu9DAlPD$iUjESf z3$Ls3+Ox)H%qk{qz)z0B?wp&XZpq{X&P2>5O0d|`ubXqPn#H4Lb;+#WG&lB`6W_9K zzW?RX*6_Ow8Te<~x0s(C5%HqMtoi0psvnGC3?Z{7%eurTDAc=ElFwe`d|$ zuiD=Nkm$gJX5sth+TX@jz4c$4-2eIEbMoyXKRL$5ySXuMtvqnQeM)f`e71J*A)CDZ zk3j~0z@QBpZk{!#pRpzQ>aI$-BXNoi7>D1I$zf5ycTfQSQgaZ%!0|D1aJVqnI=llIDGYx>HSf!){uK_%R$(zuBN ztLE@J`=W0CWA>>MUu(fEcr^(AUV7WUty@~KADhE1JjSj{_!yVoG*RHf?+3=gna2v1h%{=W02l=SU-$S110RG6u1dIIqC!*wRX`O`1yli5Kow90Q~_0>UV)DQ DnAHDz literal 0 HcmV?d00001 diff --git a/extra/images/testing/ppm/binary.ppm b/extra/images/testing/ppm/binary.ppm new file mode 100644 index 0000000000000000000000000000000000000000..b774663b8de639d934596981fec69ce1709592b4 GIT binary patch literal 57654 zcmeHNON(6B5gsW{Ad^KLXJs4X0c8~vAq_}4CSZggO5(^?6h+R$U~jY#7@OGo30Wok zkd?iOApv7dvP(h;#5jv+^o-sb86sk2S?>oUYlbz)UB%T zt2*B|)9UWg_RX{F=APN{+?Jg$?RaW#>yNf=pWFW8wz=o`yuNq$TXVa1zxDQ>H{Y1s zxPIg8#?2e%HqLLDo!_)+*65`Qr~;~hDxeCe0;)h41?G3%;5@oeYVTAiz_FF+nTj*$ z5*Y;u0rxYE?IqT<( zB=VmmVAF zm5LV7a89*2g4qDGn2r!_xG>QZln}xXdbE#2MJ!g-mcVu@6$cd?U|gWQ?6xaUr(?Qi zjwwC%5F2t-CE&f3iaWRlm?bl`5+yiekKQqnz(7uSFWm{{qQ3@$h+)07_D za!VG4%>jGN7k6+CFi~buB}#VE9=+pG<(4dJn*;WhFD`%$FtO4p8C-T!jw#UN$eGPV zTW(2IFBjy1z2tL4lX;jZGpG_JJ}F^`UkdpB522y z=NOda=K%elBnc#o3g>{bd~sZ^0mjMPsYl69>QKG~L`;t$fLO{g|VRZRfn zI8HI!I8@lfKWW^F`qM!S^fNTpRsDWHuF-swSlAf_CjxggqCrsd>6m$rJJ6G3tAvX+pBNAi&T*tuGlvj*kW&`a7{tU9KOPga zNjAurlw$|>bDEhw$SDpuHU;Dyh~E>y@m41LWKg)I3pjQlgwxFIK~8bt8__7v?KT;w z1XJRLId&k5)6DEa&YGZ+tw@{OO`v>hNN!b*9X^)R&*||w#W5PuD9A0=+N@6exg}j* z-~|U#?4h?}RvX#sXo(#<>EEuI*wB@VF1Ut(hl!%w0#4a&JAdhY+F8bDrZ;p|+5)V` zR9F%RF{dEY$lu~7d>2}D7T3cDjyu@w2OJ>XpetvO{W;}> zykKI$kh~SpCLw+KnmBoYW$7aI%UvABIrceV{=mT zI4PSL^TZh$bBvPt8}kS3{f#y8btd8%$jlI&SYlEY+c^G0PmxE^K>XTbNkCfN98}5!6o+FtpacHGgnq^*0ctwf?R7gX5^bfgr8*Z_OVZNBs>1X{~>2 z{@^(3Zy-of|DeC?ZIK@ux^mL}MT=>;tV+DB!jg=+5>?c{HGl8^!oq~bmB-1!(ZpPk z1Gdh8Dg6b}k`}iUGiNL2+l{7~zpVb!r*2V2E90QWI3}n1%M^;!7CQ?W4zOL1`rA(1 zDPblouH2Ad#!}@7g>w`@wf%qtq1c$7t;({on{4c zp8EM|-d}g474Ut`#WaIfr&)oVr+$8#_t)Ku3iwtg<06ALOtS(>PyOUHFR#0C6!6^) zVh&t;reA@;R(Cu7YwL!pfGVI0r~;~hDxeCe0;+&2pbDr0s(>n>3aA3AfGVI0r~;~h zDxeCe0;+&2pbDr0s(>n>3aA3AfGVI0r~<0MJ*~jL8B=_?1LoTB_}Bk#PHi;@zGW63 zFoz#EpS)^re1t_CIEJxQmt+9cTaE%b*ZjQW@iTtxs#iWR`_?9YRQw$r%FjT|PX<7} z6)2EY+wl-3XgK}$Uy7kNW;-fC znCM&M$8N&KcZLqGF-N{*7GE}(es5OqjEzr{^OIv-dLvRGskUSCJ@sRp1FxUq-{1Y; z7#clej%_f@pJ9EFAKl-Lk`t530I0VD1qfk@l0Rs5#Vj2)7k+1sth0umePvWkGVqfl zqI)WusskpMadHx+q~5pBSbq7@P0W&f;MzBmS0xpMbK!dkO*!sf62#hiY@9QdZ$|8;Zx`{w%J z2F;al9GTQDnM6ptfSBt_@mIG@oVS^^=JNZaWfyl^fAQf8{N#v;9WDOcj)Qk?{&oJ> zHhE_IAcy<70G@E*htpk^a7W^32aLmS$>gxu@H;WrmEx~%n_K@j|9#UOU2lI2K%zsB zn#G@)8~+?z_0Ion^58?m=j6LZesYY9cXMmOT6ySU`;_7?_-yU)V>Ws7<3R>~z@QBp zzBp&j{=$~vtGg=Uj>IW8U>tr+CWl4+-a!HQlLv@-@!bLB@*nK&i65jH;Hev`@B@HX zB^-F*9|(BQ7+lF@(4)5;1+M?YS_V%n?mGUYy}kOU!7aR-JO3N|J{<&yyn8HsZA4rN z2ckod*k`lgN+yFIy=5wJ;wfv~wZEF1|FVI7$v1orf9{tfThU(#{HqcUe|dpNa3zyL zkKQsBxcX;n;;A2+#a%Xlk5cinF9v1|JZZ07wWhCJ8`zBv5LCi_Dvg^cuxgHe&%UTz z_=Ait*@aD+B&ir(ccebAX zNy=YiYT$_ Date: Thu, 1 Apr 2010 02:22:42 -0700 Subject: [PATCH 530/713] add fastcall functions to ffi tests --- basis/compiler/tests/alien.factor | 22 ++++++++++++++++++++++ vm/ffi_test.c | 24 ++++++++++++++++++++++++ vm/ffi_test.h | 12 ++++++++++++ 3 files changed, 58 insertions(+) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 71efe8a929..08ff47ee5a 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -22,6 +22,8 @@ IN: compiler.tests.alien "f-cdecl" libfactor-ffi-tests-path cdecl add-library "f-stdcall" libfactor-ffi-tests-path stdcall add-library + +"f-fastcall" libfactor-ffi-tests-path fastcall add-library >> LIBRARY: f-cdecl @@ -603,3 +605,23 @@ FUNCTION: void this_does_not_exist ( ) ; : assembly-test-1 ( -- ) void { } cdecl [ ] alien-assembly ; [ ] [ assembly-test-1 ] unit-test + +LIBRARY: f-fastcall + +FUNCTION: int ffi_test_49 ( int x ) ; +FUNCTION: int ffi_test_50 ( int x, int y ) ; +FUNCTION: int ffi_test_51 ( int x, int y, int z ) ; +FUNCTION: int ffi_test_52 ( int x, float y, int z ) ; +FUNCTION: int ffi_test_53 ( int x, float y, int z, int w ) ; +FUNCTION: int ffi_test_54 ( test-struct-11 x, int y ) ; +FUNCTION: int ffi_test_55 ( int x, int y, int z ) ; +FUNCTION: int ffi_test_56 ( int x, int y, int z ) ; + +[ 4 ] [ 3 ffi_test_49 ] unit-test +[ 8 ] [ 3 4 ffi_test_50 ] unit-test +[ 13 ] [ 3 4 5 ffi_test_51 ] unit-test +[ 13 ] [ 3 4.0 5 ffi_test_52 ] unit-test +[ 19 ] [ 3 4.0 5 6 ffi_test_53 ] unit-test +[ 13 ] [ 3 4 test-struct-11 5 ffi_test_54 ] unit-test +[ 19 ] [ 3 4 test-struct-11 5 6 ffi_test_55 ] unit-test +[ 26 ] [ 3 4 test-struct-11 5 6 7 ffi_test_56 ] unit-test diff --git a/vm/ffi_test.c b/vm/ffi_test.c index 11f7498f30..6ad9a26b27 100755 --- a/vm/ffi_test.c +++ b/vm/ffi_test.c @@ -329,3 +329,27 @@ short ffi_test_48(struct bool_field_test x) } #endif + +FACTOR_FASTCALL(int) ffi_test_49(int x) { return x + 1; } +FACTOR_FASTCALL(int) ffi_test_50(int x, int y) { return x + y + 1; } +FACTOR_FASTCALL(int) ffi_test_51(int x, int y, int z) { return x + y + z + 1; } +FACTOR_FASTCALL(int) ffi_test_52(int x, float y, int z) { return x + y + z + 1; } +FACTOR_FASTCALL(int) ffi_test_53(int x, float y, int z, int w) +{ + return x + y + z + w + 1; +} + +FACTOR_FASTCALL(int) ffi_test_54(test_struct_11 x, int y) +{ + return x.x + x.y + y + 1; +} + +FACTOR_FASTCALL(int) ffi_test_55(test_struct_11 x, int y, int z) +{ + return x.x + x.y + y + z + 1; +} + +FACTOR_FASTCALL(int) ffi_test_56(test_struct_11 x, int y, int z, int w) +{ + return x.x + x.y + y + z + w + 1; +} diff --git a/vm/ffi_test.h b/vm/ffi_test.h index c61c95d6df..0ee593a26e 100755 --- a/vm/ffi_test.h +++ b/vm/ffi_test.h @@ -1,9 +1,12 @@ #if defined(_MSC_VER) #define FACTOR_STDCALL(return_type) return_type __stdcall + #define FACTOR_FASTCALL(return_type) return_type __fastcall #elif defined(i386) || defined(__i386) || defined(__i386__) #define FACTOR_STDCALL(return_type) __attribute__((stdcall)) return_type + #define FACTOR_FASTCALL(return_type) __attribute__((fastcall)) return_type #else #define FACTOR_STDCALL(return_type) return_type + #define FACTOR_FASTCALL(return_type) return_type #endif #if defined(__APPLE__) @@ -119,3 +122,12 @@ struct bool_field_test { FACTOR_EXPORT short ffi_test_48(struct bool_field_test x); #endif + +FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_49(int x); +FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_50(int x, int y); +FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_51(int x, int y, int z); +FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_52(int x, float y, int z); +FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_53(int x, float y, int z, int w); +FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_54(test_struct_11 x, int y); +FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_55(test_struct_11 x, int y, int z); +FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_56(test_struct_11 x, int y, int z, int w); From 4fd61f0b5c64ecd39181991035ec5061af8fcab4 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 02:53:40 -0700 Subject: [PATCH 531/713] cpu.architecture: alter param-regs to take abi as an (ignored for now) argument --- basis/compiler/codegen/codegen.factor | 16 ++++++++-------- basis/cpu/architecture/architecture.factor | 8 ++++---- basis/cpu/ppc/linux/linux.factor | 2 +- basis/cpu/ppc/macosx/macosx.factor | 2 +- basis/cpu/ppc/ppc.factor | 6 +++--- basis/cpu/x86/32/32.factor | 11 +++++++---- basis/cpu/x86/64/64.factor | 14 +++++++------- basis/cpu/x86/64/unix/unix.factor | 4 ++-- basis/cpu/x86/64/winnt/winnt.factor | 4 ++-- basis/math/floats/env/x86/64/64.factor | 10 +++++----- 10 files changed, 40 insertions(+), 37 deletions(-) diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index d8f0823d44..12e263a3f4 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -300,12 +300,12 @@ M: float-rep next-fastcall-param M: double-rep next-fastcall-param float-regs inc [ ?dummy-stack-params ] [ ?dummy-int-params ] bi ; -GENERIC: reg-class-full? ( reg-class -- ? ) +GENERIC# reg-class-full? 1 ( reg-class abi -- ? ) -M: stack-params reg-class-full? drop t ; +M: stack-params reg-class-full? 2drop t ; M: reg-class reg-class-full? - [ get ] [ param-regs length ] bi >= ; + [ get ] swap '[ _ param-regs length ] bi >= ; : alloc-stack-param ( rep -- n reg-class rep ) stack-params get @@ -315,10 +315,10 @@ M: reg-class reg-class-full? : alloc-fastcall-param ( rep -- n reg-class rep ) [ [ reg-class-of get ] [ reg-class-of ] [ next-fastcall-param ] tri ] keep ; -: alloc-parameter ( parameter -- reg rep ) - c-type-rep dup reg-class-of reg-class-full? +:: alloc-parameter ( parameter abi -- reg rep ) + parameter c-type-rep dup reg-class-of abi reg-class-full? [ alloc-stack-param ] [ alloc-fastcall-param ] if - [ param-reg ] dip ; + [ abi param-reg ] dip ; : (flatten-int-type) ( type -- seq ) stack-size cell align cell /i void* c-type ; @@ -355,8 +355,8 @@ M: c-type-name flatten-value-type c-type flatten-value-type ; #! Moves values from C stack to registers (if word is #! %load-param-reg) and registers to C stack (if word is #! %save-param-reg). - [ alien-parameters flatten-value-types ] - [ '[ alloc-parameter _ execute ] ] + [ [ alien-parameters flatten-value-types ] [ abi>> ] bi ] + [ '[ _ alloc-parameter _ execute ] ] bi* each-parameter ; inline : reverse-each-parameter ( parameters quot -- ) diff --git a/basis/cpu/architecture/architecture.factor b/basis/cpu/architecture/architecture.factor index b617746a06..9a50b0a2e2 100644 --- a/basis/cpu/architecture/architecture.factor +++ b/basis/cpu/architecture/architecture.factor @@ -484,15 +484,15 @@ HOOK: %loop-entry cpu ( -- ) GENERIC: return-reg ( reg-class -- reg ) ! Sequence of registers used for parameter passing in class -GENERIC: param-regs ( reg-class -- regs ) +GENERIC# param-regs 1 ( reg-class abi -- regs ) -M: stack-params param-regs drop f ; +M: stack-params param-regs 2drop f ; -GENERIC: param-reg ( n reg-class -- reg ) +GENERIC# param-reg 1 ( n reg-class abi -- reg ) M: reg-class param-reg param-regs nth ; -M: stack-params param-reg drop ; +M: stack-params param-reg 2drop ; ! Is this integer small enough to be an immediate operand for ! %add-imm, %sub-imm, and %mul-imm? diff --git a/basis/cpu/ppc/linux/linux.factor b/basis/cpu/ppc/linux/linux.factor index 5cfa1391c4..0a1e8477e8 100644 --- a/basis/cpu/ppc/linux/linux.factor +++ b/basis/cpu/ppc/linux/linux.factor @@ -13,7 +13,7 @@ M: linux reserved-area-size 2 cells ; M: linux lr-save 1 cells ; -M: float-regs param-regs drop { 1 2 3 4 5 6 7 8 } ; +M: float-regs param-regs 2drop { 1 2 3 4 5 6 7 8 } ; M: ppc value-struct? drop f ; diff --git a/basis/cpu/ppc/macosx/macosx.factor b/basis/cpu/ppc/macosx/macosx.factor index 152a3aa720..49e9768cf6 100644 --- a/basis/cpu/ppc/macosx/macosx.factor +++ b/basis/cpu/ppc/macosx/macosx.factor @@ -8,7 +8,7 @@ M: macosx reserved-area-size 6 cells ; M: macosx lr-save 2 cells ; -M: float-regs param-regs drop { 1 2 3 4 5 6 7 8 9 10 11 12 13 } ; +M: float-regs param-regs 2drop { 1 2 3 4 5 6 7 8 9 10 11 12 13 } ; M: ppc value-struct? drop t ; diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor index 36beb86792..e721713154 100644 --- a/basis/cpu/ppc/ppc.factor +++ b/basis/cpu/ppc/ppc.factor @@ -237,7 +237,7 @@ M: spill-slot float-function-param* [ 1 ] dip n>> spill@ LFD ; M: integer float-function-param* FMR ; : float-function-param ( i src -- ) - [ float-regs param-regs nth ] dip float-function-param* ; + [ float-regs cdecl param-regs nth ] dip float-function-param* ; : float-function-return ( reg -- ) float-regs return-reg double-rep %copy ; @@ -587,7 +587,7 @@ M: ppc %reload ( dst rep src -- ) M: ppc %loop-entry ; M: int-regs return-reg drop 3 ; -M: int-regs param-regs drop { 3 4 5 6 7 8 9 10 } ; +M: int-regs param-regs 2drop { 3 4 5 6 7 8 9 10 } ; M: float-regs return-reg drop 1 ; M:: ppc %save-param-reg ( stack reg rep -- ) @@ -647,7 +647,7 @@ M:: ppc %box ( n rep func -- ) ! If the source is a stack location, load it into freg #0. ! If the source is f, then we assume the value is already in ! freg #0. - n [ 0 rep reg-class-of param-reg rep %load-param-reg ] when* + n [ 0 rep reg-class-of cdecl param-reg rep %load-param-reg ] when* rep double-rep? 5 4 ? %load-vm-addr func f %alien-invoke ; diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index d296b730d2..df5bdd2bb4 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -85,8 +85,8 @@ M: x86.32 return-struct-in-registers? ( c-type -- ? ) ! On x86, parameters are never passed in registers. M: int-regs return-reg drop EAX ; -M: int-regs param-regs drop { } ; -M: float-regs param-regs drop { } ; +M: int-regs param-regs 2drop { } ; +M: float-regs param-regs 2drop { } ; GENERIC: load-return-reg ( src rep -- ) GENERIC: store-return-reg ( dst rep -- ) @@ -297,14 +297,17 @@ M:: x86.32 %binary-float-function ( dst src1 src2 func -- ) [ abi>> mingw = os windows? not or ] bi and ; +: callee-cleanup? ( abi -- ? ) + { stdcall fastcall thiscall } member? ; + M: x86.32 %cleanup ( params -- ) - #! a) If we just called an stdcall function in Windows, it + #! a) If we just called a stdcall function in Windows, it #! cleaned up the stack frame for us. But we don't want that #! so we 'undo' the cleanup since we do that in %epilogue. #! b) If we just called a function returning a struct, we #! have to fix ESP. { - { [ dup abi>> stdcall? ] [ drop ESP stack-frame get params>> SUB ] } + { [ dup abi>> callee-cleanup? ] [ drop ESP stack-frame get params>> SUB ] } { [ dup funny-large-struct-return? ] [ drop EAX PUSH ] } [ drop ] } cond ; diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index 04f64f96b6..6e33219a66 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -11,10 +11,10 @@ cpu.architecture vm ; FROM: layouts => cell cells ; IN: cpu.x86.64 -: param-reg-0 ( -- reg ) 0 int-regs param-reg ; inline -: param-reg-1 ( -- reg ) 1 int-regs param-reg ; inline -: param-reg-2 ( -- reg ) 2 int-regs param-reg ; inline -: param-reg-3 ( -- reg ) 3 int-regs param-reg ; inline +: param-reg-0 ( -- reg ) 0 int-regs cdecl param-reg ; inline +: param-reg-1 ( -- reg ) 1 int-regs cdecl param-reg ; inline +: param-reg-2 ( -- reg ) 2 int-regs cdecl param-reg ; inline +: param-reg-3 ( -- reg ) 3 int-regs cdecl param-reg ; inline M: x86.64 pic-tail-reg RBX ; @@ -154,7 +154,7 @@ M:: x86.64 %unbox-large-struct ( n c-type -- ) "to_value_struct" f %alien-invoke ; : load-return-value ( rep -- ) - [ [ 0 ] dip reg-class-of param-reg ] + [ [ 0 ] dip reg-class-of cdecl param-reg ] [ reg-class-of return-reg ] [ ] tri %copy ; @@ -162,7 +162,7 @@ M:: x86.64 %unbox-large-struct ( n c-type -- ) M:: x86.64 %box ( n rep func -- ) n [ n - 0 rep reg-class-of param-reg + 0 rep reg-class-of cdecl param-reg rep %load-param-reg ] [ rep load-return-value @@ -249,7 +249,7 @@ M: x86.64 %end-callback-value ( ctype -- ) unbox-return ; : float-function-param ( i src -- ) - [ float-regs param-regs nth ] dip double-rep %copy ; + [ float-regs cdecl param-regs nth ] dip double-rep %copy ; : float-function-return ( reg -- ) float-regs return-reg double-rep %copy ; diff --git a/basis/cpu/x86/64/unix/unix.factor b/basis/cpu/x86/64/unix/unix.factor index 2fb32ce733..01e02d274d 100644 --- a/basis/cpu/x86/64/unix/unix.factor +++ b/basis/cpu/x86/64/unix/unix.factor @@ -7,10 +7,10 @@ compiler.cfg.registers ; IN: cpu.x86.64.unix M: int-regs param-regs - drop { RDI RSI RDX RCX R8 R9 } ; + 2drop { RDI RSI RDX RCX R8 R9 } ; M: float-regs param-regs - drop { XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 } ; + 2drop { XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 } ; M: x86.64 reserved-stack-space 0 ; diff --git a/basis/cpu/x86/64/winnt/winnt.factor b/basis/cpu/x86/64/winnt/winnt.factor index c75bb5a1b9..5d8ecc5cfb 100644 --- a/basis/cpu/x86/64/winnt/winnt.factor +++ b/basis/cpu/x86/64/winnt/winnt.factor @@ -5,9 +5,9 @@ compiler.cfg.registers cpu.architecture cpu.x86.assembler cpu.x86 cpu.x86.assembler.operands ; IN: cpu.x86.64.winnt -M: int-regs param-regs drop { RCX RDX R8 R9 } ; +M: int-regs param-regs 2drop { RCX RDX R8 R9 } ; -M: float-regs param-regs drop { XMM0 XMM1 XMM2 XMM3 } ; +M: float-regs param-regs 2drop { XMM0 XMM1 XMM2 XMM3 } ; M: x86.64 reserved-stack-space 4 cells ; diff --git a/basis/math/floats/env/x86/64/64.factor b/basis/math/floats/env/x86/64/64.factor index c20eed1cab..93cb11104f 100644 --- a/basis/math/floats/env/x86/64/64.factor +++ b/basis/math/floats/env/x86/64/64.factor @@ -4,22 +4,22 @@ IN: math.floats.env.x86.64 M: x86.64 get-sse-env void { void* } cdecl [ - int-regs param-regs first [] STMXCSR + int-regs cdecl param-regs first [] STMXCSR ] alien-assembly ; M: x86.64 set-sse-env void { void* } cdecl [ - int-regs param-regs first [] LDMXCSR + int-regs cdecl param-regs first [] LDMXCSR ] alien-assembly ; M: x86.64 get-x87-env void { void* } cdecl [ - int-regs param-regs first [] FNSTSW - int-regs param-regs first 2 [+] FNSTCW + int-regs cdecl param-regs first [] FNSTSW + int-regs cdecl param-regs first 2 [+] FNSTCW ] alien-assembly ; M: x86.64 set-x87-env void { void* } cdecl [ FNCLEX - int-regs param-regs first 2 [+] FLDCW + int-regs cdecl param-regs first 2 [+] FLDCW ] alien-assembly ; From a191937c47c0d3ad7cc58008ffc5567f8e008f97 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 03:02:36 -0700 Subject: [PATCH 532/713] typos in ffi tests --- basis/compiler/tests/alien.factor | 10 +++++----- vm/ffi_test.c | 6 +++--- vm/ffi_test.h | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 08ff47ee5a..2bde4234b4 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -614,14 +614,14 @@ FUNCTION: int ffi_test_51 ( int x, int y, int z ) ; FUNCTION: int ffi_test_52 ( int x, float y, int z ) ; FUNCTION: int ffi_test_53 ( int x, float y, int z, int w ) ; FUNCTION: int ffi_test_54 ( test-struct-11 x, int y ) ; -FUNCTION: int ffi_test_55 ( int x, int y, int z ) ; -FUNCTION: int ffi_test_56 ( int x, int y, int z ) ; +FUNCTION: int ffi_test_55 ( test-struct-11 x, int y, int z ) ; +FUNCTION: int ffi_test_56 ( test-struct-11 x, int y, int z, int w ) ; [ 4 ] [ 3 ffi_test_49 ] unit-test [ 8 ] [ 3 4 ffi_test_50 ] unit-test [ 13 ] [ 3 4 5 ffi_test_51 ] unit-test [ 13 ] [ 3 4.0 5 ffi_test_52 ] unit-test [ 19 ] [ 3 4.0 5 6 ffi_test_53 ] unit-test -[ 13 ] [ 3 4 test-struct-11 5 ffi_test_54 ] unit-test -[ 19 ] [ 3 4 test-struct-11 5 6 ffi_test_55 ] unit-test -[ 26 ] [ 3 4 test-struct-11 5 6 7 ffi_test_56 ] unit-test +[ 13 ] [ 3 4 test-struct-11 5 ffi_test_54 ] unit-test +[ 19 ] [ 3 4 test-struct-11 5 6 ffi_test_55 ] unit-test +[ 26 ] [ 3 4 test-struct-11 5 6 7 ffi_test_56 ] unit-test diff --git a/vm/ffi_test.c b/vm/ffi_test.c index 6ad9a26b27..d45a08cf8b 100755 --- a/vm/ffi_test.c +++ b/vm/ffi_test.c @@ -339,17 +339,17 @@ FACTOR_FASTCALL(int) ffi_test_53(int x, float y, int z, int w) return x + y + z + w + 1; } -FACTOR_FASTCALL(int) ffi_test_54(test_struct_11 x, int y) +FACTOR_FASTCALL(int) ffi_test_54(struct test_struct_11 x, int y) { return x.x + x.y + y + 1; } -FACTOR_FASTCALL(int) ffi_test_55(test_struct_11 x, int y, int z) +FACTOR_FASTCALL(int) ffi_test_55(struct test_struct_11 x, int y, int z) { return x.x + x.y + y + z + 1; } -FACTOR_FASTCALL(int) ffi_test_56(test_struct_11 x, int y, int z, int w) +FACTOR_FASTCALL(int) ffi_test_56(struct test_struct_11 x, int y, int z, int w) { return x.x + x.y + y + z + w + 1; } diff --git a/vm/ffi_test.h b/vm/ffi_test.h index 0ee593a26e..6fe35fdb42 100755 --- a/vm/ffi_test.h +++ b/vm/ffi_test.h @@ -128,6 +128,6 @@ FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_50(int x, int y); FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_51(int x, int y, int z); FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_52(int x, float y, int z); FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_53(int x, float y, int z, int w); -FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_54(test_struct_11 x, int y); -FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_55(test_struct_11 x, int y, int z); -FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_56(test_struct_11 x, int y, int z, int w); +FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_54(struct test_struct_11 x, int y); +FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_55(struct test_struct_11 x, int y, int z); +FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_56(struct test_struct_11 x, int y, int z, int w); From 615c64443b8a06fe3104955d86d910988eeccf5f Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 03:35:37 -0700 Subject: [PATCH 533/713] update M\ int-regs param-regs for x86-32 to give input regs for thiscall/fastcall --- basis/cpu/x86/32/32.factor | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index df5bdd2bb4..c707294e42 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: locals alien.c-types alien.libraries alien.syntax arrays -kernel fry math namespaces sequences system layouts io +USING: locals alien alien.c-types alien.libraries alien.syntax +arrays kernel fry math namespaces sequences system layouts io vocabs.loader accessors init combinators command-line make compiler compiler.units compiler.constants compiler.alien compiler.codegen compiler.codegen.fixup @@ -83,11 +83,18 @@ M: x86.32 return-struct-in-registers? ( c-type -- ? ) : struct-return@ ( n -- operand ) [ next-stack@ ] [ stack-frame get params>> local@ ] if* ; -! On x86, parameters are never passed in registers. +! On x86, parameters are usually never passed in registers, except with Microsoft's +! "thiscall" and "fastcall" abis M: int-regs return-reg drop EAX ; -M: int-regs param-regs 2drop { } ; M: float-regs param-regs 2drop { } ; +M: int-regs param-regs + nip { + { thiscall [ { ECX } ] } + { fastcall [ { ECX EDX } ] } + [ drop { } ] + } case ; + GENERIC: load-return-reg ( src rep -- ) GENERIC: store-return-reg ( dst rep -- ) From 026499e64fd6718418310dfdbff41e3350efb900 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 1 Apr 2010 14:43:27 -0500 Subject: [PATCH 534/713] Use flags{ instead of flags all over the place --- .../file-descriptors/file-descriptors.factor | 5 +-- basis/core-graphics/core-graphics.factor | 5 ++- .../unix/multiplexers/kqueue/kqueue.factor | 6 ++-- .../windows/nt/privileges/privileges.factor | 4 +-- basis/io/backend/windows/windows.factor | 8 ++--- basis/io/directories/unix/unix.factor | 5 ++- basis/io/files/unique/unix/unix.factor | 5 ++- basis/io/files/unix/unix-tests.factor | 6 ++-- basis/io/files/unix/unix.factor | 12 +++---- basis/io/files/windows/windows.factor | 9 ++--- basis/io/mmap/unix/unix.factor | 10 +++--- basis/io/mmap/windows/windows.factor | 8 ++--- basis/io/monitors/linux/linux.factor | 6 ++-- basis/io/monitors/windows/nt/nt.factor | 4 +-- basis/io/pipes/windows/nt/nt.factor | 4 +-- basis/literals/literals-docs.factor | 15 ++++++++- basis/literals/literals-tests.factor | 15 ++++++++- basis/literals/literals.factor | 7 ++-- basis/math/bitwise/bitwise-docs.factor | 13 -------- basis/math/bitwise/bitwise-tests.factor | 13 +------- basis/math/bitwise/bitwise.factor | 4 --- basis/openssl/libssl/libssl.factor | 9 +++-- basis/random/windows/windows.factor | 2 +- basis/ui/backend/windows/windows.factor | 7 ++-- basis/unix/linux/inotify/inotify.factor | 19 ++++++----- basis/unix/statfs/macosx/macosx.factor | 11 +++---- .../directx/d3d9types/d3d9types.factor | 33 ++++++++++--------- basis/windows/errors/errors.factor | 6 ++-- basis/windows/gdi32/gdi32.factor | 4 +-- basis/windows/user32/user32.factor | 17 +++++----- basis/windows/winsock/winsock.factor | 5 ++- basis/x11/windows/windows.factor | 10 +++--- basis/x11/xlib/xlib.factor | 7 ++-- extra/fullscreen/fullscreen.factor | 10 +++--- extra/io/serial/unix/bsd/bsd.factor | 5 +-- extra/io/serial/unix/unix-tests.factor | 11 ++++--- extra/io/serial/unix/unix.factor | 5 +-- extra/model-viewer/model-viewer.factor | 6 ++-- extra/webkit-demo/webkit-demo.factor | 8 ++--- 39 files changed, 168 insertions(+), 171 deletions(-) diff --git a/basis/core-foundation/file-descriptors/file-descriptors.factor b/basis/core-foundation/file-descriptors/file-descriptors.factor index ec5581d463..4ec362f0fc 100644 --- a/basis/core-foundation/file-descriptors/file-descriptors.factor +++ b/basis/core-foundation/file-descriptors/file-descriptors.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.syntax kernel math.bitwise core-foundation ; +USING: alien.c-types alien.syntax kernel math.bitwise core-foundation +literals ; IN: core-foundation.file-descriptors TYPEDEF: void* CFFileDescriptorRef @@ -25,7 +26,7 @@ FUNCTION: void CFFileDescriptorEnableCallBacks ( ) ; : enable-all-callbacks ( fd -- ) - { kCFFileDescriptorReadCallBack kCFFileDescriptorWriteCallBack } flags + flags{ kCFFileDescriptorReadCallBack kCFFileDescriptorWriteCallBack } CFFileDescriptorEnableCallBacks ; : ( fd callback -- handle ) diff --git a/basis/core-graphics/core-graphics.factor b/basis/core-graphics/core-graphics.factor index f3f759115c..82b8191621 100644 --- a/basis/core-graphics/core-graphics.factor +++ b/basis/core-graphics/core-graphics.factor @@ -3,7 +3,7 @@ USING: alien alien.c-types alien.destructors alien.syntax accessors destructors fry kernel math math.bitwise sequences libc colors images images.memory core-graphics.types core-foundation.utilities -opengl.gl ; +opengl.gl literals ; IN: core-graphics ! CGImageAlphaInfo @@ -121,8 +121,7 @@ FUNCTION: uint GetCurrentButtonState ( ) ; > close-file ; M: kqueue-mx add-input-callback ( thread fd mx -- ) [ call-next-method ] [ - [ EVFILT_READ { EV_ADD EV_ONESHOT } flags make-kevent ] dip + [ EVFILT_READ flags{ EV_ADD EV_ONESHOT } make-kevent ] dip register-kevent ] 2bi ; M: kqueue-mx add-output-callback ( thread fd mx -- ) [ call-next-method ] [ - [ EVFILT_WRITE { EV_ADD EV_ONESHOT } flags make-kevent ] dip + [ EVFILT_WRITE flags{ EV_ADD EV_ONESHOT } make-kevent ] dip register-kevent ] 2bi ; diff --git a/basis/io/backend/windows/nt/privileges/privileges.factor b/basis/io/backend/windows/nt/privileges/privileges.factor index 6022e91efd..53a67bbeab 100644 --- a/basis/io/backend/windows/nt/privileges/privileges.factor +++ b/basis/io/backend/windows/nt/privileges/privileges.factor @@ -2,7 +2,7 @@ USING: alien alien.c-types alien.data alien.syntax arrays continuations destructors generic io.mmap io.ports io.backend.windows io.files.windows kernel libc locals math math.bitwise namespaces quotations sequences windows windows.advapi32 windows.kernel32 windows.types io.backend system accessors -io.backend.windows.privileges classes.struct windows.errors ; +io.backend.windows.privileges classes.struct windows.errors literals ; IN: io.backend.windows.nt.privileges TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES @@ -11,7 +11,7 @@ TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES ! http://msdn.microsoft.com/msdnmag/issues/05/03/TokenPrivileges/ : (open-process-token) ( handle -- handle ) - { TOKEN_ADJUST_PRIVILEGES TOKEN_QUERY } flags PHANDLE + flags{ TOKEN_ADJUST_PRIVILEGES TOKEN_QUERY } PHANDLE [ OpenProcessToken win32-error=0/f ] keep *void* ; : open-process-token ( -- handle ) diff --git a/basis/io/backend/windows/windows.factor b/basis/io/backend/windows/windows.factor index 6ec2ec4dc5..0e0a803679 100644 --- a/basis/io/backend/windows/windows.factor +++ b/basis/io/backend/windows/windows.factor @@ -5,7 +5,7 @@ io.buffers io.files io.ports io.binary io.timeouts system strings kernel math namespaces sequences windows.errors windows.kernel32 windows.shell32 windows.types splitting continuations math.bitwise accessors init sets assocs -classes.struct classes ; +classes.struct classes literals ; IN: io.backend.windows TUPLE: win32-handle < disposable handle ; @@ -43,12 +43,12 @@ HOOK: add-completion io-backend ( port -- ) |dispose dup add-completion ; -: share-mode ( -- n ) - { +CONSTANT: share-mode + flags{ FILE_SHARE_READ FILE_SHARE_WRITE FILE_SHARE_DELETE - } flags ; foldable + } : default-security-attributes ( -- obj ) SECURITY_ATTRIBUTES diff --git a/basis/io/directories/unix/unix.factor b/basis/io/directories/unix/unix.factor index 77d7f2d1b2..0cc8aaa0e4 100644 --- a/basis/io/directories/unix/unix.factor +++ b/basis/io/directories/unix/unix.factor @@ -4,11 +4,10 @@ USING: accessors alien.c-types alien.strings combinators continuations destructors fry io io.backend io.backend.unix io.directories io.encodings.binary io.encodings.utf8 io.files io.pathnames io.files.types kernel math.bitwise sequences system -unix unix.stat vocabs.loader classes.struct unix.ffi ; +unix unix.stat vocabs.loader classes.struct unix.ffi literals ; IN: io.directories.unix -: touch-mode ( -- n ) - { O_WRONLY O_APPEND O_CREAT O_EXCL } flags ; foldable +CONSTANT: touch-mode flags{ O_WRONLY O_APPEND O_CREAT O_EXCL } M: unix touch-file ( path -- ) normalize-path diff --git a/basis/io/files/unique/unix/unix.factor b/basis/io/files/unique/unix/unix.factor index ec72d9128b..cd60e3d4b8 100644 --- a/basis/io/files/unique/unix/unix.factor +++ b/basis/io/files/unique/unix/unix.factor @@ -1,11 +1,10 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: kernel io.ports io.backend.unix math.bitwise -unix system io.files.unique unix.ffi ; +unix system io.files.unique unix.ffi literals ; IN: io.files.unique.unix -: open-unique-flags ( -- flags ) - { O_RDWR O_CREAT O_EXCL } flags ; +CONSTANT: open-unique-flags flags{ O_RDWR O_CREAT O_EXCL } M: unix (touch-unique-file) ( path -- ) open-unique-flags file-mode open-file close-file ; diff --git a/basis/io/files/unix/unix-tests.factor b/basis/io/files/unix/unix-tests.factor index 93e499a576..06f7473aed 100644 --- a/basis/io/files/unix/unix-tests.factor +++ b/basis/io/files/unix/unix-tests.factor @@ -2,7 +2,7 @@ USING: tools.test io.files io.files.temp io.pathnames io.directories io.files.info io.files.info.unix continuations kernel io.files.unix math.bitwise calendar accessors math.functions math unix.users unix.groups arrays sequences -grouping io.pathnames.private ; +grouping io.pathnames.private literals ; IN: io.files.unix.tests [ "/usr/libexec/" ] [ "/usr/libexec/awk/" parent-directory ] unit-test @@ -45,7 +45,7 @@ IN: io.files.unix.tests prepare-test-file [ t ] -[ test-file { USER-ALL GROUP-ALL OTHER-ALL } flags set-file-permissions perms OCT: 777 = ] unit-test +[ test-file flags{ USER-ALL GROUP-ALL OTHER-ALL } set-file-permissions perms OCT: 777 = ] unit-test [ t ] [ test-file user-read? ] unit-test [ t ] [ test-file user-write? ] unit-test @@ -85,7 +85,7 @@ prepare-test-file [ f ] [ test-file file-info other-read? ] unit-test [ t ] -[ test-file { USER-ALL GROUP-ALL OTHER-EXECUTE } flags set-file-permissions perms OCT: 771 = ] unit-test +[ test-file flags{ USER-ALL GROUP-ALL OTHER-EXECUTE } set-file-permissions perms OCT: 771 = ] unit-test prepare-test-file diff --git a/basis/io/files/unix/unix.factor b/basis/io/files/unix/unix.factor index bf0a21f997..e695345125 100644 --- a/basis/io/files/unix/unix.factor +++ b/basis/io/files/unix/unix.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: unix byte-arrays kernel io.backend.unix math.bitwise io.ports io.files io.files.private io.pathnames environment -destructors system unix.ffi ; +destructors system unix.ffi literals ; IN: io.files.unix M: unix cwd ( -- path ) @@ -12,15 +12,14 @@ M: unix cwd ( -- path ) M: unix cd ( path -- ) [ chdir ] unix-system-call drop ; -: read-flags ( -- n ) O_RDONLY ; inline +CONSTANT: read-flags flags{ O_RDONLY } -: open-read ( path -- fd ) O_RDONLY file-mode open-file ; +: open-read ( path -- fd ) read-flags file-mode open-file ; M: unix (file-reader) ( path -- stream ) open-read init-fd ; -: write-flags ( -- n ) - { O_WRONLY O_CREAT O_TRUNC } flags ; inline +CONSTANT: write-flags flags{ O_WRONLY O_CREAT O_TRUNC } : open-write ( path -- fd ) write-flags file-mode open-file ; @@ -28,8 +27,7 @@ M: unix (file-reader) ( path -- stream ) M: unix (file-writer) ( path -- stream ) open-write init-fd ; -: append-flags ( -- n ) - { O_WRONLY O_APPEND O_CREAT } flags ; inline +CONSTANT: append-flags flags{ O_WRONLY O_APPEND O_CREAT } : open-append ( path -- fd ) [ diff --git a/basis/io/files/windows/windows.factor b/basis/io/files/windows/windows.factor index c4c848cb64..4fc2057a74 100644 --- a/basis/io/files/windows/windows.factor +++ b/basis/io/files/windows/windows.factor @@ -6,7 +6,8 @@ io.backend.windows kernel math splitting fry alien.strings windows windows.kernel32 windows.time windows.types calendar combinators math.functions sequences namespaces make words system destructors accessors math.bitwise continuations -windows.errors arrays byte-arrays generalizations alien.data ; +windows.errors arrays byte-arrays generalizations alien.data +literals ; IN: io.files.windows : open-file ( path access-mode create-mode flags -- handle ) @@ -16,7 +17,7 @@ IN: io.files.windows ] with-destructors ; : open-r/w ( path -- win32-file ) - { GENERIC_READ GENERIC_WRITE } flags + flags{ GENERIC_READ GENERIC_WRITE } OPEN_EXISTING 0 open-file ; : open-read ( path -- win32-file ) @@ -29,7 +30,7 @@ IN: io.files.windows GENERIC_WRITE OPEN_ALWAYS 0 open-file ; : open-existing ( path -- win32-file ) - { GENERIC_READ GENERIC_WRITE } flags + flags{ GENERIC_READ GENERIC_WRITE } share-mode f OPEN_EXISTING @@ -38,7 +39,7 @@ IN: io.files.windows : maybe-create-file ( path -- win32-file ? ) #! return true if file was just created - { GENERIC_READ GENERIC_WRITE } flags + flags{ GENERIC_READ GENERIC_WRITE } share-mode f OPEN_ALWAYS diff --git a/basis/io/mmap/unix/unix.factor b/basis/io/mmap/unix/unix.factor index f426201b06..84378efeb8 100644 --- a/basis/io/mmap/unix/unix.factor +++ b/basis/io/mmap/unix/unix.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors destructors io.backend.unix io.mmap +USING: accessors destructors io.backend.unix io.mmap literals io.mmap.private kernel locals math.bitwise system unix unix.ffi ; IN: io.mmap.unix @@ -12,13 +12,13 @@ IN: io.mmap.unix ] with-destructors ; M: unix (mapped-file-r/w) - { PROT_READ PROT_WRITE } flags - { MAP_FILE MAP_SHARED } flags + flags{ PROT_READ PROT_WRITE } + flags{ MAP_FILE MAP_SHARED } O_RDWR mmap-open ; M: unix (mapped-file-reader) - { PROT_READ } flags - { MAP_FILE MAP_SHARED } flags + flags{ PROT_READ } + flags{ MAP_FILE MAP_SHARED } O_RDONLY mmap-open ; M: unix close-mapped-file ( mmap -- ) diff --git a/basis/io/mmap/windows/windows.factor b/basis/io/mmap/windows/windows.factor index e3e3116b59..b1191082b3 100644 --- a/basis/io/mmap/windows/windows.factor +++ b/basis/io/mmap/windows/windows.factor @@ -2,7 +2,7 @@ USING: alien alien.c-types arrays destructors generic io.mmap io.ports io.backend.windows io.files.windows io.backend.windows.privileges io.mmap.private kernel libc math math.bitwise namespaces quotations sequences windows windows.advapi32 windows.kernel32 io.backend system -accessors locals windows.errors ; +accessors locals windows.errors literals ; IN: io.mmap.windows : create-file-mapping ( hFile lpAttributes flProtect dwMaximumSizeHigh dwMaximumSizeLow lpName -- HANDLE ) @@ -29,9 +29,9 @@ C: win32-mapped-file M: windows (mapped-file-r/w) [ - { GENERIC_WRITE GENERIC_READ } flags + flags{ GENERIC_WRITE GENERIC_READ } OPEN_ALWAYS - { PAGE_READWRITE SEC_COMMIT } flags + flags{ PAGE_READWRITE SEC_COMMIT } FILE_MAP_ALL_ACCESS mmap-open -rot ] with-destructors ; @@ -40,7 +40,7 @@ M: windows (mapped-file-reader) [ GENERIC_READ OPEN_ALWAYS - { PAGE_READONLY SEC_COMMIT } flags + flags{ PAGE_READONLY SEC_COMMIT } FILE_MAP_READ mmap-open -rot ] with-destructors ; diff --git a/basis/io/monitors/linux/linux.factor b/basis/io/monitors/linux/linux.factor index 31442b7f0b..9b2440aec8 100644 --- a/basis/io/monitors/linux/linux.factor +++ b/basis/io/monitors/linux/linux.factor @@ -5,7 +5,7 @@ io.files io.pathnames io.buffers io.ports io.timeouts io.backend.unix io.encodings.utf8 unix.linux.inotify assocs namespaces make threads continuations init math math.bitwise sets alien alien.strings alien.c-types vocabs.loader accessors -system hashtables destructors unix classes.struct ; +system hashtables destructors unix classes.struct literals ; FROM: namespaces => set ; IN: io.monitors.linux @@ -65,13 +65,13 @@ M: linux-monitor dispose* ( monitor -- ) tri ; : ignore-flags? ( mask -- ? ) - { + flags{ IN_DELETE_SELF IN_MOVE_SELF IN_UNMOUNT IN_Q_OVERFLOW IN_IGNORED - } flags bitand 0 > ; + } bitand 0 > ; : parse-action ( mask -- changed ) [ diff --git a/basis/io/monitors/windows/nt/nt.factor b/basis/io/monitors/windows/nt/nt.factor index 4d061cbb1a..e6a055a9d6 100644 --- a/basis/io/monitors/windows/nt/nt.factor +++ b/basis/io/monitors/windows/nt/nt.factor @@ -5,7 +5,7 @@ locals kernel math assocs namespaces make continuations sequences hashtables sorting arrays combinators math.bitwise strings system accessors threads splitting io.backend io.backend.windows io.backend.windows.nt io.files.windows.nt io.monitors io.ports -io.buffers io.files io.timeouts io.encodings.string +io.buffers io.files io.timeouts io.encodings.string literals io.encodings.utf16n io windows.errors windows.kernel32 windows.types io.pathnames classes.struct ; IN: io.monitors.windows.nt @@ -16,7 +16,7 @@ IN: io.monitors.windows.nt share-mode f OPEN_EXISTING - { FILE_FLAG_BACKUP_SEMANTICS FILE_FLAG_OVERLAPPED } flags + flags{ FILE_FLAG_BACKUP_SEMANTICS FILE_FLAG_OVERLAPPED } f CreateFile opened-file ; diff --git a/basis/io/pipes/windows/nt/nt.factor b/basis/io/pipes/windows/nt/nt.factor index 7fce8b4de2..f87a98ab91 100644 --- a/basis/io/pipes/windows/nt/nt.factor +++ b/basis/io/pipes/windows/nt/nt.factor @@ -10,7 +10,7 @@ IN: io.pipes.windows.nt ! http://twistedmatrix.com/trac/browser/trunk/twisted/internet/iocpreactor/process.py : create-named-pipe ( name -- handle ) - { PIPE_ACCESS_INBOUND FILE_FLAG_OVERLAPPED } flags + flags{ PIPE_ACCESS_INBOUND FILE_FLAG_OVERLAPPED } PIPE_TYPE_BYTE 1 4096 @@ -21,7 +21,7 @@ IN: io.pipes.windows.nt : open-other-end ( name -- handle ) GENERIC_WRITE - { FILE_SHARE_READ FILE_SHARE_WRITE } flags + flags{ FILE_SHARE_READ FILE_SHARE_WRITE } default-security-attributes OPEN_EXISTING FILE_FLAG_OVERLAPPED diff --git a/basis/literals/literals-docs.factor b/basis/literals/literals-docs.factor index a464d75b22..6fcf8a5e07 100644 --- a/basis/literals/literals-docs.factor +++ b/basis/literals/literals-docs.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Joe Groff. ! See http://factorcode.org/license.txt for BSD license. -USING: help.markup help.syntax kernel multiline ; +USING: help.markup help.syntax kernel multiline sequences ; IN: literals HELP: $ @@ -62,6 +62,19 @@ ${ five six 7 } . { POSTPONE: $ POSTPONE: $[ POSTPONE: ${ } related-words +HELP: flags{ +{ $values { "values" sequence } } +{ $description "Constructs a constant flag value from a sequence of integers or words that output integers. The resulting constant is computed at parse-time, which makes this word as efficient as using a literal integer." } +{ $examples + { $example "USING: literals kernel prettyprint ;" + "IN: scratchpad" + "CONSTANT: x HEX: 1" + "flags{ HEX: 20 x BIN: 100 } .h" + "25" + } +} ; + + ARTICLE: "literals" "Interpolating code results into literal values" "The " { $vocab-link "literals" } " vocabulary contains words to run code at parse time and insert the results into more complex literal values." { $example """ diff --git a/basis/literals/literals-tests.factor b/basis/literals/literals-tests.factor index d7256a64b1..4357198db6 100644 --- a/basis/literals/literals-tests.factor +++ b/basis/literals/literals-tests.factor @@ -1,4 +1,4 @@ -USING: kernel literals math tools.test ; +USING: accessors kernel literals math tools.test ; IN: literals.tests << @@ -27,3 +27,16 @@ CONSTANT: constant-a 3 : sixty-nine ( -- a b ) 6 9 ; [ { 6 9 } ] [ ${ sixty-nine } ] unit-test + +CONSTANT: a 1 +CONSTANT: b 2 +ALIAS: c b +ALIAS: d c + +CONSTANT: foo flags{ a b d } + +[ 3 ] [ foo ] unit-test +[ 3 ] [ flags{ a b d } ] unit-test +\ foo def>> must-infer + +[ 1 ] [ flags{ 1 } ] unit-test diff --git a/basis/literals/literals.factor b/basis/literals/literals.factor index 3e541a80ce..42a7ab9668 100644 --- a/basis/literals/literals.factor +++ b/basis/literals/literals.factor @@ -25,6 +25,7 @@ SYNTAX: $ scan-word expand-literal >vector ; SYNTAX: $[ parse-quotation with-datastack >vector ; SYNTAX: ${ \ } [ expand-literals ] parse-literal ; SYNTAX: flags{ - "}" [ parse-word ] map-tokens - expand-literals - 0 [ bitor ] reduce suffix! ; + \ } [ + expand-literals + 0 [ bitor ] reduce + ] parse-literal ; diff --git a/basis/math/bitwise/bitwise-docs.factor b/basis/math/bitwise/bitwise-docs.factor index ee94479b46..4024953070 100644 --- a/basis/math/bitwise/bitwise-docs.factor +++ b/basis/math/bitwise/bitwise-docs.factor @@ -135,18 +135,6 @@ HELP: clear-bit } } ; -HELP: flags -{ $values { "values" sequence } } -{ $description "Constructs a constant flag value from a sequence of integers or words that output integers. The resulting constant is computed at compile-time, which makes this word as efficient as using a literal integer." } -{ $examples - { $example "USING: math.bitwise kernel prettyprint ;" - "IN: scratchpad" - "CONSTANT: x HEX: 1" - "{ HEX: 20 x BIN: 100 } flags .h" - "25" - } -} ; - HELP: symbols>flags { $values { "symbols" sequence } { "assoc" assoc } { "flag-bits" integer } } { $description "Constructs an integer value by mapping the values in the " { $snippet "symbols" } " sequence to integer values using " { $snippet "assoc" } " and " { $link bitor } "ing the values together." } @@ -408,7 +396,6 @@ $nl } "Bitfields:" { $subsections - flags "math-bitfields" } ; diff --git a/basis/math/bitwise/bitwise-tests.factor b/basis/math/bitwise/bitwise-tests.factor index a5919d3ec3..93d2d9e882 100644 --- a/basis/math/bitwise/bitwise-tests.factor +++ b/basis/math/bitwise/bitwise-tests.factor @@ -1,6 +1,6 @@ USING: accessors math math.bitwise tools.test kernel words specialized-arrays alien.c-types math.vectors.simd -sequences destructors libc ; +sequences destructors libc literals ; SPECIALIZED-ARRAY: int IN: math.bitwise.tests @@ -23,17 +23,6 @@ IN: math.bitwise.tests : test-1+ ( x -- y ) 1 + ; [ 512 ] [ 1 { { test-1+ 8 } } bitfield ] unit-test -CONSTANT: a 1 -CONSTANT: b 2 - -: foo ( -- flags ) { a b } flags ; - -[ 3 ] [ foo ] unit-test -[ 3 ] [ { a b } flags ] unit-test -\ foo def>> must-infer - -[ 1 ] [ { 1 } flags ] unit-test - [ 8 ] [ 0 3 toggle-bit ] unit-test [ 0 ] [ 8 3 toggle-bit ] unit-test diff --git a/basis/math/bitwise/bitwise.factor b/basis/math/bitwise/bitwise.factor index 15db425137..cd38c8513c 100644 --- a/basis/math/bitwise/bitwise.factor +++ b/basis/math/bitwise/bitwise.factor @@ -44,10 +44,6 @@ IN: math.bitwise : W- ( x y -- z ) - 64 bits ; inline : W* ( x y -- z ) * 64 bits ; inline -! flags -MACRO: flags ( values -- ) - [ 0 ] [ [ ?execute bitor ] curry compose ] reduce ; - : symbols>flags ( symbols assoc -- flag-bits ) [ at ] curry map 0 [ bitor ] reduce ; diff --git a/basis/openssl/libssl/libssl.factor b/basis/openssl/libssl/libssl.factor index bfd59cde25..96d235d271 100644 --- a/basis/openssl/libssl/libssl.factor +++ b/basis/openssl/libssl/libssl.factor @@ -3,7 +3,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.syntax combinators kernel system namespaces assocs parser lexer sequences words -quotations math.bitwise alien.libraries ; +quotations math.bitwise alien.libraries literals ; IN: openssl.libssl @@ -258,15 +258,14 @@ CONSTANT: SSL_SESS_CACHE_OFF HEX: 0000 CONSTANT: SSL_SESS_CACHE_CLIENT HEX: 0001 CONSTANT: SSL_SESS_CACHE_SERVER HEX: 0002 -: SSL_SESS_CACHE_BOTH ( -- n ) - { SSL_SESS_CACHE_CLIENT SSL_SESS_CACHE_SERVER } flags ; inline +CONSTANT: SSL_SESS_CACHE_BOTH flags{ SSL_SESS_CACHE_CLIENT SSL_SESS_CACHE_SERVER } CONSTANT: SSL_SESS_CACHE_NO_AUTO_CLEAR HEX: 0080 CONSTANT: SSL_SESS_CACHE_NO_INTERNAL_LOOKUP HEX: 0100 CONSTANT: SSL_SESS_CACHE_NO_INTERNAL_STORE HEX: 0200 -: SSL_SESS_CACHE_NO_INTERNAL ( -- n ) - { SSL_SESS_CACHE_NO_INTERNAL_LOOKUP SSL_SESS_CACHE_NO_INTERNAL_STORE } flags ; inline +CONSTANT: SSL_SESS_CACHE_NO_INTERNAL + flags{ SSL_SESS_CACHE_NO_INTERNAL_LOOKUP SSL_SESS_CACHE_NO_INTERNAL_STORE } ! =============================================== ! x509_vfy.h diff --git a/basis/random/windows/windows.factor b/basis/random/windows/windows.factor index 30b169bfed..72b908a32f 100644 --- a/basis/random/windows/windows.factor +++ b/basis/random/windows/windows.factor @@ -36,7 +36,7 @@ CONSTANT: factor-crypto-container "FactorCryptoContainer" ] if ; : create-crypto-context ( provider type -- handle ) - { CRYPT_MACHINE_KEYSET CRYPT_NEWKEYSET } flags + flags{ CRYPT_MACHINE_KEYSET CRYPT_NEWKEYSET } (acquire-crypto-context) win32-error=0/f *void* ; ERROR: acquire-crypto-context-failed provider type ; diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index 8a4ae9853f..c0829e5c8d 100644 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -628,7 +628,7 @@ M: windows-ui-backend do-events WNDCLASSEX f GetModuleHandle class-name-ptr pick GetClassInfoEx 0 = [ WNDCLASSEX heap-size >>cbSize - { CS_HREDRAW CS_VREDRAW CS_OWNDC } flags >>style + flags{ CS_HREDRAW CS_VREDRAW CS_OWNDC } >>style ui-wndproc >>lpfnWndProc 0 >>cbClsExtra 0 >>cbWndExtra @@ -811,8 +811,7 @@ M: windows-ui-backend (ungrab-input) ( handle -- ) f ClipCursor drop 1 ShowCursor drop ; -: fullscreen-flags ( -- n ) - { WS_CAPTION WS_BORDER WS_THICKFRAME } flags ; inline +CONSTANT: fullscreen-flags { WS_CAPTION WS_BORDER WS_THICKFRAME } : enter-fullscreen ( world -- ) handle>> hWnd>> @@ -838,7 +837,7 @@ M: windows-ui-backend (ungrab-input) ( handle -- ) [ f over hwnd>RECT get-RECT-dimensions - { SWP_NOMOVE SWP_NOSIZE SWP_NOZORDER SWP_FRAMECHANGED } flags + flags{ SWP_NOMOVE SWP_NOSIZE SWP_NOZORDER SWP_FRAMECHANGED } SetWindowPos win32-error=0/f ] [ SW_RESTORE ShowWindow win32-error=0/f ] diff --git a/basis/unix/linux/inotify/inotify.factor b/basis/unix/linux/inotify/inotify.factor index c296cc8166..947191e7dd 100644 --- a/basis/unix/linux/inotify/inotify.factor +++ b/basis/unix/linux/inotify/inotify.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.syntax math math.bitwise classes.struct ; +USING: alien.c-types alien.syntax math math.bitwise classes.struct +literals ; IN: unix.linux.inotify STRUCT: inotify-event @@ -27,8 +28,8 @@ CONSTANT: IN_UNMOUNT HEX: 2000 ! Backing fs was unmounted CONSTANT: IN_Q_OVERFLOW HEX: 4000 ! Event queued overflowed CONSTANT: IN_IGNORED HEX: 8000 ! File was ignored -: IN_CLOSE ( -- n ) { IN_CLOSE_WRITE IN_CLOSE_NOWRITE } flags ; foldable ! close -: IN_MOVE ( -- n ) { IN_MOVED_FROM IN_MOVED_TO } flags ; foldable ! moves +CONSTANT: IN_CLOSE flags{ IN_CLOSE_WRITE IN_CLOSE_NOWRITE } +CONSTANT: IN_MOVE flags{ IN_MOVED_FROM IN_MOVED_TO } CONSTANT: IN_ONLYDIR HEX: 1000000 ! only watch the path if it is a directory CONSTANT: IN_DONT_FOLLOW HEX: 2000000 ! don't follow a sym link @@ -36,20 +37,20 @@ CONSTANT: IN_MASK_ADD HEX: 20000000 ! add to the mask of an already existing w CONSTANT: IN_ISDIR HEX: 40000000 ! event occurred against dir CONSTANT: IN_ONESHOT HEX: 80000000 ! only send event once -: IN_CHANGE_EVENTS ( -- n ) - { +CONSTANT: IN_CHANGE_EVENTS + flags{ IN_MODIFY IN_ATTRIB IN_MOVED_FROM IN_MOVED_TO IN_DELETE IN_CREATE IN_DELETE_SELF IN_MOVE_SELF - } flags ; foldable + } -: IN_ALL_EVENTS ( -- n ) - { +CONSTANT: IN_ALL_EVENTS + flags{ IN_ACCESS IN_MODIFY IN_ATTRIB IN_CLOSE_WRITE IN_CLOSE_NOWRITE IN_OPEN IN_MOVED_FROM IN_MOVED_TO IN_DELETE IN_CREATE IN_DELETE_SELF IN_MOVE_SELF - } flags ; foldable + } FUNCTION: int inotify_init ( ) ; FUNCTION: int inotify_add_watch ( int fd, c-string name, uint mask ) ; diff --git a/basis/unix/statfs/macosx/macosx.factor b/basis/unix/statfs/macosx/macosx.factor index 75b231da96..b5ae2c2223 100644 --- a/basis/unix/statfs/macosx/macosx.factor +++ b/basis/unix/statfs/macosx/macosx.factor @@ -3,7 +3,7 @@ USING: alien.c-types io.encodings.utf8 io.encodings.string kernel sequences unix.stat accessors unix combinators math grouping system alien.strings math.bitwise alien.syntax -unix.types classes.struct unix.ffi ; +unix.types classes.struct unix.ffi literals ; IN: unix.statfs.macosx CONSTANT: MNT_RDONLY HEX: 00000001 @@ -29,8 +29,8 @@ CONSTANT: MNT_MULTILABEL HEX: 04000000 CONSTANT: MNT_NOATIME HEX: 10000000 ALIAS: MNT_UNKNOWNPERMISSIONS MNT_IGNORE_OWNERSHIP -: MNT_VISFLAGMASK ( -- n ) - { +CONSTANT: MNT_VISFLAGMASK + flags{ MNT_RDONLY MNT_SYNCHRONOUS MNT_NOEXEC MNT_NOSUID MNT_NODEV MNT_UNION MNT_ASYNC MNT_EXPORTED MNT_QUARANTINE @@ -38,14 +38,13 @@ ALIAS: MNT_UNKNOWNPERMISSIONS MNT_IGNORE_OWNERSHIP MNT_ROOTFS MNT_DOVOLFS MNT_DONTBROWSE MNT_IGNORE_OWNERSHIP MNT_AUTOMOUNTED MNT_JOURNALED MNT_NOUSERXATTR MNT_DEFWRITE MNT_MULTILABEL MNT_NOATIME - } flags ; inline + } CONSTANT: MNT_UPDATE HEX: 00010000 CONSTANT: MNT_RELOAD HEX: 00040000 CONSTANT: MNT_FORCE HEX: 00080000 -: MNT_CMDFLAGS ( -- n ) - { MNT_UPDATE MNT_RELOAD MNT_FORCE } flags ; inline +CONSTANT: MNT_CMDFLAGS flags{ MNT_UPDATE MNT_RELOAD MNT_FORCE } CONSTANT: VFS_GENERIC 0 CONSTANT: VFS_NUMMNTOPS 1 diff --git a/basis/windows/directx/d3d9types/d3d9types.factor b/basis/windows/directx/d3d9types/d3d9types.factor index dc02849553..618d3c79e5 100644 --- a/basis/windows/directx/d3d9types/d3d9types.factor +++ b/basis/windows/directx/d3d9types/d3d9types.factor @@ -1,5 +1,5 @@ USING: alien.syntax windows.types classes.struct math alien.c-types -math.bitwise kernel locals windows.kernel32 ; +math.bitwise kernel locals windows.kernel32 literals ; IN: windows.directx.d3d9types TYPEDEF: DWORD D3DCOLOR @@ -54,19 +54,21 @@ CONSTANT: D3DCS_PLANE3 HEX: 00000200 CONSTANT: D3DCS_PLANE4 HEX: 00000400 CONSTANT: D3DCS_PLANE5 HEX: 00000800 -: D3DCS_ALL ( -- n ) - { D3DCS_LEFT - D3DCS_RIGHT - D3DCS_TOP - D3DCS_BOTTOM - D3DCS_FRONT - D3DCS_BACK - D3DCS_PLANE0 - D3DCS_PLANE1 - D3DCS_PLANE2 - D3DCS_PLANE3 - D3DCS_PLANE4 - D3DCS_PLANE5 } flags ; inline +CONSTANT: D3DCS_ALL + flags{ + D3DCS_LEFT + D3DCS_RIGHT + D3DCS_TOP + D3DCS_BOTTOM + D3DCS_FRONT + D3DCS_BACK + D3DCS_PLANE0 + D3DCS_PLANE1 + D3DCS_PLANE2 + D3DCS_PLANE3 + D3DCS_PLANE4 + D3DCS_PLANE5 + } STRUCT: D3DCLIPSTATUS9 { ClipUnion DWORD } @@ -777,8 +779,7 @@ CONSTANT: D3DVS_SWIZZLE_MASK HEX: 00FF0000 : D3DVS_W_Z ( -- n ) 2 D3DVS_SWIZZLE_SHIFT 6 + shift ; inline : D3DVS_W_W ( -- n ) 3 D3DVS_SWIZZLE_SHIFT 6 + shift ; inline -: D3DVS_NOSWIZZLE ( -- n ) - { D3DVS_X_X D3DVS_Y_Y D3DVS_Z_Z D3DVS_W_W } flags ; inline +CONSTANT: D3DVS_NOSWIZZLE flags{ D3DVS_X_X D3DVS_Y_Y D3DVS_Z_Z D3DVS_W_W } CONSTANT: D3DSP_SWIZZLE_SHIFT 16 CONSTANT: D3DSP_SWIZZLE_MASK HEX: 00FF0000 diff --git a/basis/windows/errors/errors.factor b/basis/windows/errors/errors.factor index 67757d05d2..a22b6ec007 100755 --- a/basis/windows/errors/errors.factor +++ b/basis/windows/errors/errors.factor @@ -1,7 +1,7 @@ USING: alien.data kernel locals math math.bitwise windows.kernel32 sequences byte-arrays unicode.categories io.encodings.string io.encodings.utf16n alien.strings -arrays literals windows.types specialized-arrays ; +arrays literals windows.types specialized-arrays literals ; SPECIALIZED-ARRAY: TCHAR IN: windows.errors @@ -705,10 +705,10 @@ CONSTANT: FORMAT_MESSAGE_MAX_WIDTH_MASK HEX: 000000FF ERROR: error-message-failed id ; :: n>win32-error-string ( id -- string ) - { + flags{ FORMAT_MESSAGE_FROM_SYSTEM FORMAT_MESSAGE_ARGUMENT_ARRAY - } flags + } f id LANG_NEUTRAL SUBLANG_DEFAULT make-lang-id diff --git a/basis/windows/gdi32/gdi32.factor b/basis/windows/gdi32/gdi32.factor index 43307cb6ba..93784ea370 100644 --- a/basis/windows/gdi32/gdi32.factor +++ b/basis/windows/gdi32/gdi32.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005, 2006 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.syntax alien.destructors -kernel windows.types math.bitwise ; +kernel windows.types math.bitwise literals ; IN: windows.gdi32 CONSTANT: BI_RGB 0 @@ -818,7 +818,7 @@ CONSTANT: TA_RIGHT 2 CONSTANT: TA_RTLREADING 256 CONSTANT: TA_NOUPDATECP 0 CONSTANT: TA_UPDATECP 1 -: TA_MASK ( -- n ) { TA_BASELINE TA_CENTER TA_UPDATECP TA_RTLREADING } flags ; foldable +CONSTANT: TA_MASK flags{ TA_BASELINE TA_CENTER TA_UPDATECP TA_RTLREADING } CONSTANT: VTA_BASELINE 24 CONSTANT: VTA_CENTER 6 ALIAS: VTA_LEFT TA_BOTTOM diff --git a/basis/windows/user32/user32.factor b/basis/windows/user32/user32.factor index 1c23c36071..54d31bb12b 100644 --- a/basis/windows/user32/user32.factor +++ b/basis/windows/user32/user32.factor @@ -33,18 +33,17 @@ CONSTANT: WS_MINIMIZEBOX HEX: 00020000 CONSTANT: WS_MAXIMIZEBOX HEX: 00010000 ! Common window styles -: WS_OVERLAPPEDWINDOW ( -- n ) - { +CONSTANT: WS_OVERLAPPEDWINDOW + flags{ WS_OVERLAPPED WS_CAPTION WS_SYSMENU WS_THICKFRAME WS_MINIMIZEBOX WS_MAXIMIZEBOX - } flags ; foldable + } -: WS_POPUPWINDOW ( -- n ) - { WS_POPUP WS_BORDER WS_SYSMENU } flags ; foldable +CONSTANT: WS_POPUPWINDOW flags{ WS_POPUP WS_BORDER WS_SYSMENU } ALIAS: WS_CHILDWINDOW WS_CHILD @@ -76,11 +75,11 @@ CONSTANT: WS_EX_CONTROLPARENT HEX: 00010000 CONSTANT: WS_EX_STATICEDGE HEX: 00020000 CONSTANT: WS_EX_APPWINDOW HEX: 00040000 -: WS_EX_OVERLAPPEDWINDOW ( -- n ) - WS_EX_WINDOWEDGE WS_EX_CLIENTEDGE bitor ; foldable +CONSTANT: WS_EX_OVERLAPPEDWINDOW + flags{ WS_EX_WINDOWEDGE WS_EX_CLIENTEDGE } -: WS_EX_PALETTEWINDOW ( -- n ) - { WS_EX_WINDOWEDGE WS_EX_TOOLWINDOW WS_EX_TOPMOST } flags ; foldable +CONSTANT: WS_EX_PALETTEWINDOW + flags{ WS_EX_WINDOWEDGE WS_EX_TOOLWINDOW WS_EX_TOPMOST } CONSTANT: CS_VREDRAW HEX: 0001 CONSTANT: CS_HREDRAW HEX: 0002 diff --git a/basis/windows/winsock/winsock.factor b/basis/windows/winsock/winsock.factor index b58cbcacbd..49a3d6e9fa 100644 --- a/basis/windows/winsock/winsock.factor +++ b/basis/windows/winsock/winsock.factor @@ -3,7 +3,7 @@ USING: alien alien.c-types alien.strings alien.syntax arrays byte-arrays kernel literals math sequences windows.types windows.kernel32 windows.errors math.bitwise io.encodings.utf16n -classes.struct windows.com.syntax init ; +classes.struct windows.com.syntax init literals ; FROM: alien.c-types => short ; IN: windows.winsock @@ -73,8 +73,7 @@ CONSTANT: AI_PASSIVE 1 CONSTANT: AI_CANONNAME 2 CONSTANT: AI_NUMERICHOST 4 -: AI_MASK ( -- n ) - { AI_PASSIVE AI_CANONNAME AI_NUMERICHOST } flags ; inline +CONSTANT: AI_MASK flags{ AI_PASSIVE AI_CANONNAME AI_NUMERICHOST } CONSTANT: NI_NUMERICHOST 1 CONSTANT: NI_NUMERICSERV 2 diff --git a/basis/x11/windows/windows.factor b/basis/x11/windows/windows.factor index ad0a8b11a6..7b7ae8b106 100644 --- a/basis/x11/windows/windows.factor +++ b/basis/x11/windows/windows.factor @@ -5,15 +5,15 @@ namespaces sequences x11 x11.xlib x11.constants x11.glx arrays fry classes.struct ; IN: x11.windows -: create-window-mask ( -- n ) - { CWBackPixel CWBorderPixel CWColormap CWEventMask } flags ; +CONSTANT: create-window-mask + flags{ CWBackPixel CWBorderPixel CWColormap CWEventMask } : create-colormap ( visinfo -- colormap ) [ dpy get root get ] dip visual>> AllocNone XCreateColormap ; -: event-mask ( -- n ) - { +CONSTANT: event-mask + flags{ ExposureMask StructureNotifyMask KeyPressMask @@ -25,7 +25,7 @@ IN: x11.windows EnterWindowMask LeaveWindowMask PropertyChangeMask - } flags ; + } : window-attributes ( visinfo -- attributes ) XSetWindowAttributes diff --git a/basis/x11/xlib/xlib.factor b/basis/x11/xlib/xlib.factor index 1c5ff2e3ef..ac9e5591dc 100644 --- a/basis/x11/xlib/xlib.factor +++ b/basis/x11/xlib/xlib.factor @@ -12,7 +12,8 @@ ! and note the section. USING: accessors kernel arrays alien alien.c-types alien.data alien.strings alien.syntax classes.struct math math.bitwise words -sequences namespaces continuations io io.encodings.ascii x11.syntax ; +sequences namespaces continuations io io.encodings.ascii x11.syntax +literals ; FROM: alien.c-types => short ; IN: x11.xlib @@ -1134,8 +1135,8 @@ X-FUNCTION: Status XWithdrawWindow ( : PAspect ( -- n ) 7 2^ ; inline : PBaseSize ( -- n ) 8 2^ ; inline : PWinGravity ( -- n ) 9 2^ ; inline -: PAllHints ( -- n ) - { PPosition PSize PMinSize PMaxSize PResizeInc PAspect } flags ; foldable +CONSTANT: PAllHints + flags{ PPosition PSize PMinSize PMaxSize PResizeInc PAspect } STRUCT: XSizeHints { flags long } diff --git a/extra/fullscreen/fullscreen.factor b/extra/fullscreen/fullscreen.factor index a233d6f4f5..458ef3d51e 100755 --- a/extra/fullscreen/fullscreen.factor +++ b/extra/fullscreen/fullscreen.factor @@ -16,7 +16,7 @@ IN: fullscreen :: (monitor-info>devmodes) ( monitor-info n -- ) DEVMODE DEVMODE heap-size >>dmSize - { DM_BITSPERPEL DM_PELSWIDTH DM_PELSHEIGHT } flags >>dmFields + flags{ DM_BITSPERPEL DM_PELSWIDTH DM_PELSHEIGHT } >>dmFields :> devmode monitor-info szDevice>> @@ -73,11 +73,11 @@ ERROR: display-change-error n ; : set-fullscreen-styles ( hwnd -- ) [ GWL_STYLE [ WS_OVERLAPPEDWINDOW unmask ] change-style ] - [ GWL_EXSTYLE [ { WS_EX_APPWINDOW WS_EX_TOPMOST } flags bitor ] change-style ] bi ; + [ GWL_EXSTYLE [ flags{ WS_EX_APPWINDOW WS_EX_TOPMOST } bitor ] change-style ] bi ; : set-non-fullscreen-styles ( hwnd -- ) [ GWL_STYLE [ WS_OVERLAPPEDWINDOW bitor ] change-style ] - [ GWL_EXSTYLE [ { WS_EX_APPWINDOW WS_EX_TOPMOST } flags unmask ] change-style ] bi ; + [ GWL_EXSTYLE [ flags{ WS_EX_APPWINDOW WS_EX_TOPMOST } unmask ] change-style ] bi ; ERROR: unsupported-resolution triple ; @@ -92,10 +92,10 @@ ERROR: unsupported-resolution triple ; hwnd f desktop-monitor-info rcMonitor>> slots{ left top } first2 triple first2 - { + flags{ SWP_NOACTIVATE SWP_NOCOPYBITS SWP_NOOWNERZORDER SWP_NOREPOSITION SWP_NOZORDER - } flags + } SetWindowPos win32-error=0/f ; :: enable-fullscreen ( triple hwnd -- rect ) diff --git a/extra/io/serial/unix/bsd/bsd.factor b/extra/io/serial/unix/bsd/bsd.factor index dbb013aca0..14d4f515ae 100644 --- a/extra/io/serial/unix/bsd/bsd.factor +++ b/extra/io/serial/unix/bsd/bsd.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax kernel math.bitwise sequences system io.serial ; +USING: alien.syntax kernel math.bitwise sequences system io.serial +literals ; IN: io.serial.unix M: bsd lookup-baud ( m -- n ) @@ -60,7 +61,7 @@ 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: CRTSCTS flags{ CCTS_OFLOW CRTS_IFLOW } CONSTANT: CDTR_IFLOW HEX: 00040000 CONSTANT: CDSR_OFLOW HEX: 00080000 CONSTANT: CCAR_OFLOW HEX: 00100000 diff --git a/extra/io/serial/unix/unix-tests.factor b/extra/io/serial/unix/unix-tests.factor index f4c0c6b45a..422844ab82 100644 --- a/extra/io/serial/unix/unix-tests.factor +++ b/extra/io/serial/unix/unix-tests.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel math.bitwise io.serial io.serial.unix ; +USING: accessors kernel math.bitwise io.serial io.serial.unix +literals ; IN: io.serial.unix : serial-obj ( -- obj ) @@ -10,10 +11,10 @@ IN: io.serial.unix ! "/dev/ttyd0" >>path ! freebsd ! "/dev/ttyU0" >>path ! openbsd 19200 >>baud - { IGNPAR ICRNL } flags >>iflag - { } flags >>oflag - { CS8 CLOCAL CREAD } flags >>cflag - { ICANON } flags >>lflag ; + flags{ IGNPAR ICRNL } >>iflag + flags{ } >>oflag + flags{ CS8 CLOCAL CREAD } >>cflag + flags{ ICANON } >>lflag ; : serial-test ( -- serial ) serial-obj diff --git a/extra/io/serial/unix/unix.factor b/extra/io/serial/unix/unix.factor index 6c0de55ec8..fc613da423 100644 --- a/extra/io/serial/unix/unix.factor +++ b/extra/io/serial/unix/unix.factor @@ -3,7 +3,8 @@ USING: accessors alien.c-types alien.syntax alien.data classes.struct combinators io.ports io.streams.duplex system kernel math math.bitwise vocabs.loader io.serial -io.serial.unix.termios io.backend.unix unix unix.ffi ; +io.serial.unix.termios io.backend.unix unix unix.ffi +literals ; IN: io.serial.unix << { @@ -33,7 +34,7 @@ FUNCTION: int cfsetspeed ( termios* t, speed_t s ) ; M: unix open-serial ( serial -- serial' ) dup - path>> { O_RDWR O_NOCTTY O_NDELAY } flags file-mode open-file + path>> flags{ O_RDWR O_NOCTTY O_NDELAY } file-mode open-file fd>duplex-stream >>stream ; : serial-fd ( serial -- fd ) diff --git a/extra/model-viewer/model-viewer.factor b/extra/model-viewer/model-viewer.factor index 061ce07d1e..f1b184f220 100644 --- a/extra/model-viewer/model-viewer.factor +++ b/extra/model-viewer/model-viewer.factor @@ -11,7 +11,7 @@ ui.gadgets.worlds ui.pixel-formats specialized-arrays specialized-vectors literals fry sequences.deep destructors math.bitwise opengl.gl game.models game.models.obj game.models.loader game.models.collada -prettyprint images.tga ; +prettyprint images.tga literals ; FROM: alien.c-types => float ; SPECIALIZED-ARRAY: float SPECIALIZED-VECTOR: uint @@ -164,9 +164,9 @@ TUPLE: vbo 0 0 0 0 glClearColor 1 glClearDepth HEX: ffffffff glClearStencil - { GL_COLOR_BUFFER_BIT + flags{ GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT - GL_STENCIL_BUFFER_BIT } flags glClear ; + GL_STENCIL_BUFFER_BIT } glClear ; : draw-model ( world -- ) clear-screen diff --git a/extra/webkit-demo/webkit-demo.factor b/extra/webkit-demo/webkit-demo.factor index e6178a55c3..eb24d035dc 100644 --- a/extra/webkit-demo/webkit-demo.factor +++ b/extra/webkit-demo/webkit-demo.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: cocoa cocoa.application cocoa.types cocoa.classes cocoa.windows -core-graphics.types kernel math.bitwise ; +core-graphics.types kernel math.bitwise literals ; IN: webkit-demo FRAMEWORK: /System/Library/Frameworks/WebKit.framework @@ -13,13 +13,13 @@ IMPORT: WebView WebView -> alloc rect f f -> initWithFrame:frameName:groupName: ; -: window-style ( -- n ) - { +CONSTANT: window-style ( -- n ) + flags{ NSClosableWindowMask NSMiniaturizableWindowMask NSResizableWindowMask NSTitledWindowMask - } flags ; + } : ( -- id ) rect window-style ; From 8a46a201fcc12ed2c465f6c179c5ac973a796c26 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 1 Apr 2010 15:37:57 -0500 Subject: [PATCH 535/713] Fix bootstrap --- basis/core-graphics/core-graphics.factor | 19 ++++++++++--------- basis/x11/windows/windows.factor | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/basis/core-graphics/core-graphics.factor b/basis/core-graphics/core-graphics.factor index 82b8191621..1b7693da14 100644 --- a/basis/core-graphics/core-graphics.factor +++ b/basis/core-graphics/core-graphics.factor @@ -16,15 +16,15 @@ kCGImageAlphaFirst kCGImageAlphaNoneSkipLast kCGImageAlphaNoneSkipFirst ; -: kCGBitmapAlphaInfoMask ( -- n ) HEX: 1f ; inline -: kCGBitmapFloatComponents ( -- n ) 1 8 shift ; inline +CONSTANT: kCGBitmapAlphaInfoMask HEX: 1f +CONSTANT: kCGBitmapFloatComponents 256 -: kCGBitmapByteOrderMask ( -- n ) HEX: 7000 ; inline -: kCGBitmapByteOrderDefault ( -- n ) 0 12 shift ; inline -: kCGBitmapByteOrder16Little ( -- n ) 1 12 shift ; inline -: kCGBitmapByteOrder32Little ( -- n ) 2 12 shift ; inline -: kCGBitmapByteOrder16Big ( -- n ) 3 12 shift ; inline -: kCGBitmapByteOrder32Big ( -- n ) 4 12 shift ; inline +CONSTANT: kCGBitmapByteOrderMask HEX: 7000 +CONSTANT: kCGBitmapByteOrderDefault 0 +CONSTANT: kCGBitmapByteOrder16Little 4096 +CONSTANT: kCGBitmapByteOrder32Little 8192 +CONSTANT: kCGBitmapByteOrder16Big 12288 +CONSTANT: kCGBitmapByteOrder32Big 16384 : kCGBitmapByteOrder16Host ( -- n ) little-endian? @@ -121,7 +121,8 @@ FUNCTION: uint GetCurrentButtonState ( ) ; Date: Thu, 1 Apr 2010 14:15:34 -0700 Subject: [PATCH 536/713] check gc after fastcall ffi tests like stdcall tests --- basis/compiler/tests/alien.factor | 37 ++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 2bde4234b4..7aab8c8920 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -606,17 +606,34 @@ FUNCTION: void this_does_not_exist ( ) ; [ ] [ assembly-test-1 ] unit-test -LIBRARY: f-fastcall - -FUNCTION: int ffi_test_49 ( int x ) ; -FUNCTION: int ffi_test_50 ( int x, int y ) ; -FUNCTION: int ffi_test_51 ( int x, int y, int z ) ; -FUNCTION: int ffi_test_52 ( int x, float y, int z ) ; -FUNCTION: int ffi_test_53 ( int x, float y, int z, int w ) ; -FUNCTION: int ffi_test_54 ( test-struct-11 x, int y ) ; -FUNCTION: int ffi_test_55 ( test-struct-11 x, int y, int z ) ; -FUNCTION: int ffi_test_56 ( test-struct-11 x, int y, int z, int w ) ; +[ f ] [ "f-fastcall" load-library f = ] unit-test +[ fastcall ] [ "f-fastcall" library abi>> ] unit-test +: ffi_test_49 ( x -- int ) + int "f-fastcall" "ffi_test_49" { int } + alien-invoke gc ; +: ffi_test_50 ( x y -- int ) + int "f-fastcall" "ffi_test_50" { int int } + alien-invoke gc ; +: ffi_test_51 ( x y z -- int ) + int "f-fastcall" "ffi_test_51" { int int int } + alien-invoke gc ; +: ffi_test_52 ( x y z -- int ) + int "f-fastcall" "ffi_test_52" { int float int } + alien-invoke gc ; +: ffi_test_53 ( x y z w -- int ) + int "f-fastcall" "ffi_test_53" { int int int int } + alien-invoke gc ; +: ffi_test_54 ( x y -- int ) + int "f-fastcall" "ffi_test_54" { test-struct-11 int } + alien-invoke gc ; +: ffi_test_55 ( x y z -- int ) + int "f-fastcall" "ffi_test_55" { test-struct-11 int int } + alien-invoke gc ; +: ffi_test_56 ( x y z w -- int ) + int "f-fastcall" "ffi_test_56" { test-struct-11 int int int } + alien-invoke gc ; + [ 4 ] [ 3 ffi_test_49 ] unit-test [ 8 ] [ 3 4 ffi_test_50 ] unit-test [ 13 ] [ 3 4 5 ffi_test_51 ] unit-test From 6d8c30ad98dc2bd93b0c56231a57a0abbf546296 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 14:25:02 -0700 Subject: [PATCH 537/713] statically link factor executable to VM so dylib is only needed for embedding --- GNUmakefile | 14 ++++---------- vm/os-macosx.hpp | 2 +- vm/os-unix.cpp | 1 - 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 12ca388f87..9f93deedf2 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -169,22 +169,16 @@ macosx.app: factor mkdir -p $(BUNDLE)/Contents/Frameworks mv $(EXECUTABLE) $(BUNDLE)/Contents/MacOS/factor ln -s Factor.app/Contents/MacOS/factor ./factor - cp $(ENGINE) $(BUNDLE)/Contents/Frameworks/$(ENGINE) - - install_name_tool \ - -change libfactor.dylib \ - @executable_path/../Frameworks/libfactor.dylib \ - Factor.app/Contents/MacOS/factor $(ENGINE): $(DLL_OBJS) $(TOOLCHAIN_PREFIX)$(LINKER) $(ENGINE) $(DLL_OBJS) -factor: $(EXE_OBJS) $(ENGINE) - $(TOOLCHAIN_PREFIX)$(CPP) $(LIBS) $(LIBPATH) -L. $(LINK_WITH_ENGINE) \ +factor: $(EXE_OBJS) $(DLL_OBJS) + $(TOOLCHAIN_PREFIX)$(CPP) $(LIBS) $(LIBPATH) -L. $(DLL_OBJS) \ $(CFLAGS) -o $(EXECUTABLE) $(EXE_OBJS) -factor-console: $(EXE_OBJS) $(ENGINE) - $(TOOLCHAIN_PREFIX)$(CPP) $(LIBS) $(LIBPATH) -L. $(LINK_WITH_ENGINE) \ +factor-console: $(EXE_OBJS) $(DLL_OBJS) + $(TOOLCHAIN_PREFIX)$(CPP) $(LIBS) $(LIBPATH) -L. $(DLL_OBJS) \ $(CFLAGS) $(CFLAGS_CONSOLE) -o $(CONSOLE_EXECUTABLE) $(EXE_OBJS) factor-ffi-test: $(FFI_TEST_LIBRARY) diff --git a/vm/os-macosx.hpp b/vm/os-macosx.hpp index 8428f56998..4d4499461d 100644 --- a/vm/os-macosx.hpp +++ b/vm/os-macosx.hpp @@ -3,7 +3,7 @@ namespace factor #define VM_C_API extern "C" __attribute__((visibility("default"))) #define FACTOR_OS_STRING "macosx" -#define NULL_DLL "libfactor.dylib" +#define NULL_DLL NULL void early_init(); diff --git a/vm/os-unix.cpp b/vm/os-unix.cpp index a8898eccab..60ac00fb39 100644 --- a/vm/os-unix.cpp +++ b/vm/os-unix.cpp @@ -46,7 +46,6 @@ void sleep_nanos(u64 nsec) void factor_vm::init_ffi() { - /* NULL_DLL is "libfactor.dylib" for OS X and NULL for generic Unix */ null_dll = dlopen(NULL_DLL,RTLD_LAZY); } From 6fdba565a146bb6ad3ca46ce817d8dcf473e9068 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 14:26:56 -0700 Subject: [PATCH 538/713] update deploy backends not to include dll in deployed apps --- basis/tools/deploy/macosx/macosx.factor | 11 +++-------- basis/tools/deploy/windows/windows.factor | 4 ---- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/basis/tools/deploy/macosx/macosx.factor b/basis/tools/deploy/macosx/macosx.factor index c02642ba1d..4718e3792f 100644 --- a/basis/tools/deploy/macosx/macosx.factor +++ b/basis/tools/deploy/macosx/macosx.factor @@ -34,9 +34,6 @@ IN: tools.deploy.macosx "Contents/Info.plist" append-path write-plist ; -: copy-dll ( bundle-name -- ) - "Frameworks/libfactor.dylib" copy-bundle-dir ; - : copy-nib ( bundle-name -- ) deploy-ui? get [ "Resources/English.lproj/MiniFactor.nib" copy-bundle-dir @@ -50,11 +47,9 @@ IN: tools.deploy.macosx : create-app-dir ( vocab bundle-name -- vm ) { [ - nip { - [ copy-dll ] - [ copy-nib ] - [ "Contents/Resources" append-path make-directories ] - } cleave + nip + [ copy-nib ] + [ "Contents/Resources" append-path make-directories ] bi ] [ copy-icns ] [ create-app-plist ] diff --git a/basis/tools/deploy/windows/windows.factor b/basis/tools/deploy/windows/windows.factor index f592ff2d69..7981859573 100755 --- a/basis/tools/deploy/windows/windows.factor +++ b/basis/tools/deploy/windows/windows.factor @@ -11,16 +11,12 @@ IN: tools.deploy.windows CONSTANT: app-icon-resource-id "APPICON" -: copy-dll ( bundle-name -- ) - "resource:factor.dll" swap copy-file-into ; - :: copy-vm ( executable bundle-name extension -- vm ) vm "." split1-last drop extension append bundle-name executable ".exe" append append-path [ copy-file ] keep ; : create-exe-dir ( vocab bundle-name -- vm ) - dup copy-dll deploy-console? get ".com" ".exe" ? copy-vm ; : open-in-explorer ( dir -- ) From 6bc8beb070620f8283bd30368767de14effc3aa0 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 14:44:18 -0700 Subject: [PATCH 539/713] tools.deploy.macosx: make sure Contents/Frameworks dir still gets created for apps that deploy third-party libraries --- basis/tools/deploy/macosx/macosx.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basis/tools/deploy/macosx/macosx.factor b/basis/tools/deploy/macosx/macosx.factor index 4718e3792f..446f453709 100644 --- a/basis/tools/deploy/macosx/macosx.factor +++ b/basis/tools/deploy/macosx/macosx.factor @@ -49,7 +49,8 @@ IN: tools.deploy.macosx [ nip [ copy-nib ] - [ "Contents/Resources" append-path make-directories ] bi + [ "Contents/Resources" append-path make-directories ] + [ "Contents/Frameworks" append-path make-directories ] tri ] [ copy-icns ] [ create-app-plist ] From bbe6b729bf243884474c38cb68639ac07d72b6ed Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 15:11:52 -0700 Subject: [PATCH 540/713] =?UTF-8?q?tools.deploy:=20add=20a=20=C2=ABdeploy-?= =?UTF-8?q?image-only=C2=BB=20word=20that=20only=20builds=20the=20image=20?= =?UTF-8?q?file=20to=20a=20specified=20location?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- basis/tools/deploy/deploy-docs.factor | 9 ++++++++- basis/tools/deploy/deploy.factor | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/basis/tools/deploy/deploy-docs.factor b/basis/tools/deploy/deploy-docs.factor index 976fc25357..169fdd501a 100755 --- a/basis/tools/deploy/deploy-docs.factor +++ b/basis/tools/deploy/deploy-docs.factor @@ -18,6 +18,7 @@ $nl ARTICLE: "tools.deploy.usage" "Deploy tool usage" "Once the necessary deployment flags have been set, the application can be deployed:" { $subsections deploy } +{ $subsections deploy-image-only } "For example, you can deploy the " { $vocab-link "hello-ui" } " demo which comes with Factor. Note that this demo already has a deployment configuration, so nothing needs to be configured:" { $code "\"hello-ui\" deploy" } { $list @@ -61,4 +62,10 @@ ABOUT: "tools.deploy" HELP: deploy { $values { "vocab" "a vocabulary specifier" } } -{ $description "Deploys " { $snippet "vocab" } ", saving the deployed image as " { $snippet { $emphasis "vocab" } ".image" } "." } ; +{ $description "Deploys " { $snippet "vocab" } " into a packaged application. This will create a directory containing the Factor VM, a deployed image set up to run the " { $link POSTPONE: MAIN: } " entry point of " { $snippet "vocab" } " at startup, and any " { $link "deploy-resources" } " and shared libraries the application depends on." } ; + +HELP: deploy-image-only +{ $values { "vocab" "a vocabulary specifier" } { "image" "a pathname" } } +{ $description "Deploys " { $snippet "vocab" } ", saving the deployed image to the location specified by " { $snippet "image" } ". This only builds the Factor image for the vocabulary; to create a complete packaged application, use " { $link deploy } "." } ; + +{ deploy deploy-image-only } related-words diff --git a/basis/tools/deploy/deploy.factor b/basis/tools/deploy/deploy.factor index e57cc1f04b..9430802803 100644 --- a/basis/tools/deploy/deploy.factor +++ b/basis/tools/deploy/deploy.factor @@ -1,13 +1,16 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: tools.deploy.backend system vocabs.loader kernel -combinators ; +combinators tools.deploy.config.editor ; IN: tools.deploy : deploy ( vocab -- ) deploy* ; +: deploy-image-only ( vocab image -- ) + [ vm ] 2dip swap dup deploy-config make-deploy-image drop ; + { { [ os macosx? ] [ "tools.deploy.macosx" ] } { [ os winnt? ] [ "tools.deploy.windows" ] } { [ os unix? ] [ "tools.deploy.unix" ] } -} cond require \ No newline at end of file +} cond require From 7a5a6c779e08687115a5a43e30721a0d19e2d454 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 15:23:29 -0700 Subject: [PATCH 541/713] =?UTF-8?q?add=20note=20to=20deploy=20docs=20that?= =?UTF-8?q?=20=C2=ABdeploy=C2=BB=20creates=20a=20bundle=20directory=20with?= =?UTF-8?q?=20all=20the=20parts,=20and=20=C2=ABdeploy-image-only=C2=BB=20d?= =?UTF-8?q?eploys=20only=20the=20image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- basis/tools/deploy/deploy-docs.factor | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/basis/tools/deploy/deploy-docs.factor b/basis/tools/deploy/deploy-docs.factor index 169fdd501a..27c5bbccf1 100755 --- a/basis/tools/deploy/deploy-docs.factor +++ b/basis/tools/deploy/deploy-docs.factor @@ -17,8 +17,7 @@ $nl ARTICLE: "tools.deploy.usage" "Deploy tool usage" "Once the necessary deployment flags have been set, the application can be deployed:" -{ $subsections deploy } -{ $subsections deploy-image-only } +{ $subsections deploy deploy-image-only } "For example, you can deploy the " { $vocab-link "hello-ui" } " demo which comes with Factor. Note that this demo already has a deployment configuration, so nothing needs to be configured:" { $code "\"hello-ui\" deploy" } { $list @@ -62,7 +61,7 @@ ABOUT: "tools.deploy" HELP: deploy { $values { "vocab" "a vocabulary specifier" } } -{ $description "Deploys " { $snippet "vocab" } " into a packaged application. This will create a directory containing the Factor VM, a deployed image set up to run the " { $link POSTPONE: MAIN: } " entry point of " { $snippet "vocab" } " at startup, and any " { $link "deploy-resources" } " and shared libraries the application depends on." } ; +{ $description "Deploys " { $snippet "vocab" } " into a packaged application. This will create a directory containing the Factor VM, a deployed image set up to run the " { $link POSTPONE: MAIN: } " entry point of " { $snippet "vocab" } " at startup, and any " { $link "deploy-resources" } " and shared libraries the application depends on. On Mac OS X, the deployment directory will be a standard " { $snippet ".app" } " bundle executable from Finder. To only generate the Factor image, use " { $link deploy-image-only } "." } ; HELP: deploy-image-only { $values { "vocab" "a vocabulary specifier" } { "image" "a pathname" } } From 51fd5e34e8fb74fddf99336abc5945c452f98125 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 1 Apr 2010 18:48:25 -0500 Subject: [PATCH 542/713] Fix bootstrap on windows --- basis/io/pipes/windows/nt/nt.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/io/pipes/windows/nt/nt.factor b/basis/io/pipes/windows/nt/nt.factor index f87a98ab91..d58e5e3d5f 100644 --- a/basis/io/pipes/windows/nt/nt.factor +++ b/basis/io/pipes/windows/nt/nt.factor @@ -3,7 +3,7 @@ USING: alien alien.c-types arrays destructors io io.backend.windows libc windows.types math.bitwise windows.kernel32 windows namespaces make kernel sequences windows.errors assocs math.parser system -random combinators accessors io.pipes io.ports ; +random combinators accessors io.pipes io.ports literals ; IN: io.pipes.windows.nt ! This code is based on From 1b4b1a180c67e4ca4d4cd5007b1796082e7282a6 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 1 Apr 2010 20:05:32 -0400 Subject: [PATCH 543/713] Some minor pointless optimizations --- basis/boxes/boxes.factor | 6 +-- .../concurrency/conditions/conditions.factor | 8 ++-- basis/concurrency/mailboxes/mailboxes.factor | 21 +++++---- basis/concurrency/messaging/messaging.factor | 20 +++++---- basis/dlists/dlists.factor | 2 +- basis/heaps/heaps.factor | 2 +- basis/threads/threads.factor | 44 +++++++------------ 7 files changed, 47 insertions(+), 56 deletions(-) diff --git a/basis/boxes/boxes.factor b/basis/boxes/boxes.factor index 811c5addb0..a159e1402b 100644 --- a/basis/boxes/boxes.factor +++ b/basis/boxes/boxes.factor @@ -11,7 +11,7 @@ ERROR: box-full box ; : >box ( value box -- ) dup occupied>> - [ box-full ] [ t >>occupied (>>value) ] if ; + [ box-full ] [ t >>occupied (>>value) ] if ; inline ERROR: box-empty box ; @@ -19,10 +19,10 @@ ERROR: box-empty box ; dup occupied>> [ box-empty ] unless ; inline : box> ( box -- value ) - check-box [ f ] change-value f >>occupied drop ; + check-box [ f ] change-value f >>occupied drop ; inline : ?box ( box -- value/f ? ) - dup occupied>> [ box> t ] [ drop f f ] if ; + dup occupied>> [ box> t ] [ drop f f ] if ; inline : if-box? ( box quot -- ) [ ?box ] dip [ drop ] if ; inline diff --git a/basis/concurrency/conditions/conditions.factor b/basis/concurrency/conditions/conditions.factor index 4a1c7d3370..2fb75226eb 100644 --- a/basis/concurrency/conditions/conditions.factor +++ b/basis/concurrency/conditions/conditions.factor @@ -4,10 +4,10 @@ USING: deques threads kernel arrays sequences alarms fry ; IN: concurrency.conditions : notify-1 ( deque -- ) - dup deque-empty? [ drop ] [ pop-back resume-now ] if ; + dup deque-empty? [ drop ] [ pop-back resume-now ] if ; inline : notify-all ( deque -- ) - [ resume-now ] slurp-deque ; + [ resume-now ] slurp-deque ; inline : queue-timeout ( queue timeout -- alarm ) #! Add an alarm which removes the current thread from the @@ -23,7 +23,7 @@ IN: concurrency.conditions ERROR: wait-timeout ; : queue ( queue -- ) - [ self ] dip push-front ; + [ self ] dip push-front ; inline : wait ( queue timeout status -- ) over [ @@ -31,4 +31,4 @@ ERROR: wait-timeout ; [ wait-timeout ] [ cancel-alarm ] if ] [ [ drop queue ] dip suspend drop - ] if ; + ] if ; inline diff --git a/basis/concurrency/mailboxes/mailboxes.factor b/basis/concurrency/mailboxes/mailboxes.factor index e245f93bd5..163873575c 100644 --- a/basis/concurrency/mailboxes/mailboxes.factor +++ b/basis/concurrency/mailboxes/mailboxes.factor @@ -6,22 +6,24 @@ concurrency.conditions accessors debugger debugger.threads locals fry ; IN: concurrency.mailboxes -TUPLE: mailbox threads data ; +TUPLE: mailbox { threads dlist } { data dlist } ; : ( -- mailbox ) mailbox new >>threads - >>data ; + >>data ; inline : mailbox-empty? ( mailbox -- bool ) - data>> deque-empty? ; + data>> deque-empty? ; inline -: mailbox-put ( obj mailbox -- ) +GENERIC: mailbox-put ( obj mailbox -- ) + +M: mailbox mailbox-put [ data>> push-front ] [ threads>> notify-all ] bi yield ; : wait-for-mailbox ( mailbox timeout -- ) - [ threads>> ] dip "mailbox" wait ; + [ threads>> ] dip "mailbox" wait ; inline :: block-unless-pred ( ... mailbox timeout pred: ( ... message -- ... ? ) -- ... ) mailbox data>> pred dlist-any? [ @@ -34,16 +36,17 @@ TUPLE: mailbox threads data ; 2dup wait-for-mailbox block-if-empty ] [ drop - ] if ; + ] if ; inline recursive : mailbox-peek ( mailbox -- obj ) data>> peek-back ; -: mailbox-get-timeout ( mailbox timeout -- obj ) - block-if-empty data>> pop-back ; +GENERIC# mailbox-get-timeout 1 ( mailbox timeout -- obj ) + +M: mailbox mailbox-get-timeout block-if-empty data>> pop-back ; : mailbox-get ( mailbox -- obj ) - f mailbox-get-timeout ; + f mailbox-get-timeout ; inline : mailbox-get-all-timeout ( mailbox timeout -- array ) block-if-empty diff --git a/basis/concurrency/messaging/messaging.factor b/basis/concurrency/messaging/messaging.factor index 37965309e8..3f55b0969b 100644 --- a/basis/concurrency/messaging/messaging.factor +++ b/basis/concurrency/messaging/messaging.factor @@ -1,20 +1,22 @@ -! Copyright (C) 2005, 2008 Chris Double, Slava Pestov. +! Copyright (C) 2005, 2010 Chris Double, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel threads concurrency.mailboxes continuations -namespaces assocs accessors summary fry ; +USING: kernel kernel.private threads concurrency.mailboxes +continuations namespaces assocs accessors summary fry ; IN: concurrency.messaging GENERIC: send ( message thread -- ) -: mailbox-of ( thread -- mailbox ) - dup mailbox>> [ ] [ - [ >>mailbox drop ] keep - ] ?if ; +GENERIC: mailbox-of ( thread -- mailbox ) + +M: thread mailbox-of + dup mailbox>> + [ { mailbox } declare ] + [ [ >>mailbox drop ] keep ] ?if ; inline M: thread send ( message thread -- ) - check-registered mailbox-of mailbox-put ; + mailbox-of mailbox-put ; -: my-mailbox ( -- mailbox ) self mailbox-of ; +: my-mailbox ( -- mailbox ) self mailbox-of ; inline : receive ( -- message ) my-mailbox mailbox-get ?linked ; diff --git a/basis/dlists/dlists.factor b/basis/dlists/dlists.factor index 44140d3109..53e134fad9 100644 --- a/basis/dlists/dlists.factor +++ b/basis/dlists/dlists.factor @@ -29,7 +29,7 @@ TUPLE: dlist : ( -- search-deque ) 20 ; -M: dlist deque-empty? front>> not ; +M: dlist deque-empty? front>> not ; inline M: dlist-node node-value obj>> ; diff --git a/basis/heaps/heaps.factor b/basis/heaps/heaps.factor index 677daca69d..28d18cb53a 100644 --- a/basis/heaps/heaps.factor +++ b/basis/heaps/heaps.factor @@ -35,7 +35,7 @@ TUPLE: max-heap < heap ; : ( -- max-heap ) max-heap ; M: heap heap-empty? ( heap -- ? ) - data>> empty? ; + data>> empty? ; inline M: heap heap-size ( heap -- n ) data>> length ; diff --git a/basis/threads/threads.factor b/basis/threads/threads.factor index 117e941aa7..404c8112fb 100644 --- a/basis/threads/threads.factor +++ b/basis/threads/threads.factor @@ -80,23 +80,13 @@ sleep-entry ; : thread-registered? ( thread -- ? ) id>> threads key? ; -ERROR: already-stopped thread ; - -: check-unregistered ( thread -- thread ) - dup thread-registered? [ already-stopped ] when ; - -ERROR: not-running thread ; - -: check-registered ( thread -- thread ) - dup thread-registered? [ not-running ] unless ; - > threads set-at ; + dup id>> threads set-at ; : unregister-thread ( thread -- ) - check-registered id>> threads delete-at ; + id>> threads delete-at ; : set-self ( thread -- ) 63 set-special-object ; inline @@ -106,7 +96,7 @@ PRIVATE> 65 special-object { dlist } declare ; inline : sleep-queue ( -- heap ) - 66 special-object { dlist } declare ; inline + 66 special-object { min-heap } declare ; inline : new-thread ( quot name class -- thread ) new @@ -120,16 +110,13 @@ PRIVATE> \ thread new-thread ; : resume ( thread -- ) - f >>state - check-registered run-queue push-front ; + f >>state run-queue push-front ; : resume-now ( thread -- ) - f >>state - check-registered run-queue push-back ; + f >>state run-queue push-back ; : resume-with ( obj thread -- ) - f >>state - check-registered 2array run-queue push-front ; + f >>state 2array run-queue push-front ; : sleep-time ( -- nanos/f ) { @@ -150,22 +137,19 @@ DEFER: stop >sleep-entry drop ; + dupd sleep-queue heap-push* >>sleep-entry drop ; -: expire-sleep? ( heap -- ? ) - dup heap-empty? +: expire-sleep? ( -- ? ) + sleep-queue dup heap-empty? [ drop f ] [ heap-peek nip nano-count <= ] if ; : expire-sleep ( thread -- ) f >>sleep-entry resume ; : expire-sleep-loop ( -- ) - sleep-queue - [ dup expire-sleep? ] - [ dup heap-pop drop expire-sleep ] - while - drop ; + [ expire-sleep? ] + [ sleep-queue heap-pop drop expire-sleep ] + while ; CONSTANT: [start] [ @@ -177,7 +161,9 @@ CONSTANT: [start] : no-runnable-threads ( -- ) die ; -: (next) ( obj thread -- obj' ) +GENERIC: (next) ( obj thread -- obj' ) + +M: thread (next) dup runnable>> [ context>> box> set-context ] [ t >>runnable drop [start] start-context ] if ; From eceabbc57e7ecd1ad6a406db4e65ed538185f169 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 1 Apr 2010 20:06:18 -0400 Subject: [PATCH 544/713] compiler: new set-special-object intrinsic; more efficient special-object intrinsic --- .../cfg/alias-analysis/alias-analysis.factor | 8 +++--- .../cfg/instructions/instructions.factor | 14 +++++------ .../compiler/cfg/intrinsics/intrinsics.factor | 1 + .../compiler/cfg/intrinsics/misc/misc.factor | 25 +++++++++++++------ basis/compiler/codegen/codegen.factor | 2 +- basis/compiler/tests/alien.factor | 11 +++++--- basis/cpu/architecture/architecture.factor | 6 +++-- basis/cpu/ppc/ppc.factor | 16 +++++------- basis/cpu/x86/32/32.factor | 9 ++++--- basis/cpu/x86/64/64.factor | 13 ++++++---- basis/cpu/x86/x86.factor | 15 +++++++---- 11 files changed, 72 insertions(+), 48 deletions(-) diff --git a/basis/compiler/cfg/alias-analysis/alias-analysis.factor b/basis/compiler/cfg/alias-analysis/alias-analysis.factor index 24433ad594..44326c179f 100644 --- a/basis/compiler/cfg/alias-analysis/alias-analysis.factor +++ b/basis/compiler/cfg/alias-analysis/alias-analysis.factor @@ -202,14 +202,16 @@ M: ##slot-imm insn-slot# slot>> ; M: ##set-slot insn-slot# slot>> constant ; M: ##set-slot-imm insn-slot# slot>> ; M: ##alien-global insn-slot# [ library>> ] [ symbol>> ] bi 2array ; -M: ##vm-field-ptr insn-slot# field-name>> ; +M: ##vm-field insn-slot# offset>> ; +M: ##set-vm-field insn-slot# offset>> ; M: ##slot insn-object obj>> resolve ; M: ##slot-imm insn-object obj>> resolve ; M: ##set-slot insn-object obj>> resolve ; M: ##set-slot-imm insn-object obj>> resolve ; M: ##alien-global insn-object drop \ ##alien-global ; -M: ##vm-field-ptr insn-object drop \ ##vm-field-ptr ; +M: ##vm-field insn-object drop \ ##vm-field ; +M: ##set-vm-field insn-object drop \ ##vm-field ; : init-alias-analysis ( insns -- insns' ) H{ } clone histories set @@ -222,7 +224,7 @@ M: ##vm-field-ptr insn-object drop \ ##vm-field-ptr ; 0 ac-counter set next-ac heap-ac set - \ ##vm-field-ptr set-new-ac + \ ##vm-field set-new-ac \ ##alien-global set-new-ac dup local-live-in [ set-heap-ac ] each ; diff --git a/basis/compiler/cfg/instructions/instructions.factor b/basis/compiler/cfg/instructions/instructions.factor index 678ce76860..c015cb640b 100644 --- a/basis/compiler/cfg/instructions/instructions.factor +++ b/basis/compiler/cfg/instructions/instructions.factor @@ -660,13 +660,13 @@ INSN: ##alien-global def: dst/int-rep literal: symbol library ; -INSN: ##vm-field-ptr -def: dst/int-rep -literal: field-name ; - INSN: ##vm-field def: dst/int-rep -literal: field-name ; +literal: offset ; + +INSN: ##set-vm-field +use: src/int-rep +literal: offset ; ! FFI INSN: ##alien-invoke @@ -835,8 +835,8 @@ UNION: ##allocation ##box-displaced-alien ; ! For alias analysis -UNION: ##read ##slot ##slot-imm ##vm-field-ptr ##alien-global ; -UNION: ##write ##set-slot ##set-slot-imm ; +UNION: ##read ##slot ##slot-imm ##vm-field ##alien-global ; +UNION: ##write ##set-slot ##set-slot-imm ##set-vm-field ; ! Instructions that kill all live vregs but cannot trigger GC UNION: partial-sync-insn diff --git a/basis/compiler/cfg/intrinsics/intrinsics.factor b/basis/compiler/cfg/intrinsics/intrinsics.factor index 4ebc818b83..2b2ae7d160 100644 --- a/basis/compiler/cfg/intrinsics/intrinsics.factor +++ b/basis/compiler/cfg/intrinsics/intrinsics.factor @@ -32,6 +32,7 @@ IN: compiler.cfg.intrinsics { kernel.private:tag [ drop emit-tag ] } { kernel.private:context-object [ emit-context-object ] } { kernel.private:special-object [ emit-special-object ] } + { kernel.private:set-special-object [ emit-set-special-object ] } { kernel.private:(identity-hashcode) [ drop emit-identity-hashcode ] } { math.private:both-fixnums? [ drop emit-both-fixnums? ] } { math.private:fixnum+ [ drop emit-fixnum+ ] } diff --git a/basis/compiler/cfg/intrinsics/misc/misc.factor b/basis/compiler/cfg/intrinsics/misc/misc.factor index 9731d2f6f5..da77bcaa09 100644 --- a/basis/compiler/cfg/intrinsics/misc/misc.factor +++ b/basis/compiler/cfg/intrinsics/misc/misc.factor @@ -1,30 +1,39 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: namespaces layouts sequences kernel math accessors compiler.tree.propagation.info compiler.cfg.stacks compiler.cfg.hats compiler.cfg.instructions compiler.cfg.builder.blocks compiler.cfg.utilities ; -FROM: vm => context-field-offset ; +FROM: vm => context-field-offset vm-field-offset ; IN: compiler.cfg.intrinsics.misc : emit-tag ( -- ) ds-pop tag-mask get ^^and-imm ^^tag-fixnum ds-push ; +: special-object-offset ( n -- offset ) + cells "special-objects" vm-field-offset + ; + : emit-special-object ( node -- ) dup node-input-infos first literal>> [ - "special-objects" ^^vm-field-ptr - ds-drop swap 0 ^^slot-imm + ds-drop + special-object-offset ^^vm-field ds-push ] [ emit-primitive ] ?if ; -: context-object-offset ( -- n ) - "context-objects" context-field-offset cell /i ; +: emit-set-special-object ( node -- ) + dup node-input-infos second literal>> [ + ds-drop + [ ds-pop ] dip special-object-offset ##set-vm-field + ] [ emit-primitive ] ?if ; + +: context-object-offset ( n -- n ) + cells "context-objects" context-field-offset + ; : emit-context-object ( node -- ) dup node-input-infos first literal>> [ - "ctx" ^^vm-field - ds-drop swap context-object-offset + 0 ^^slot-imm ds-push + "ctx" vm-field-offset ^^vm-field + ds-drop swap context-object-offset cell /i 0 ^^slot-imm ds-push ] [ emit-primitive ] ?if ; : emit-identity-hashcode ( -- ) diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index d82ced8a1d..4208fec0a7 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -210,8 +210,8 @@ CODEGEN: ##compare-imm %compare-imm CODEGEN: ##compare-float-ordered %compare-float-ordered CODEGEN: ##compare-float-unordered %compare-float-unordered CODEGEN: ##save-context %save-context -CODEGEN: ##vm-field-ptr %vm-field-ptr CODEGEN: ##vm-field %vm-field +CODEGEN: ##set-vm-field %set-vm-field CODEGEN: _fixnum-add %fixnum-add CODEGEN: _fixnum-sub %fixnum-sub diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 692dbee4c5..ceac1b094c 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -432,14 +432,17 @@ STRUCT: double-rect void { void* void* double-rect } "cdecl" [ "example" set-global 2drop ] alien-callback ; -: double-rect-test ( arg -- arg' ) - f f rot - double-rect-callback +: double-rect-test ( arg callback -- arg' ) + [ f f ] 2dip void { void* void* double-rect } "cdecl" alien-indirect "example" get-global ; [ 1.0 2.0 3.0 4.0 ] -[ 1.0 2.0 3.0 4.0 double-rect-test >double-rect< ] unit-test +[ + 1.0 2.0 3.0 4.0 + double-rect-callback double-rect-test + >double-rect< +] unit-test STRUCT: test_struct_14 { x1 double } diff --git a/basis/cpu/architecture/architecture.factor b/basis/cpu/architecture/architecture.factor index b617746a06..ad1a4be2eb 100644 --- a/basis/cpu/architecture/architecture.factor +++ b/basis/cpu/architecture/architecture.factor @@ -447,8 +447,10 @@ HOOK: %set-alien-double cpu ( ptr offset value -- ) HOOK: %set-alien-vector cpu ( ptr offset value rep -- ) HOOK: %alien-global cpu ( dst symbol library -- ) -HOOK: %vm-field cpu ( dst fieldname -- ) -HOOK: %vm-field-ptr cpu ( dst fieldname -- ) +HOOK: %vm-field cpu ( dst offset -- ) +HOOK: %set-vm-field cpu ( src offset -- ) + +: %context ( dst -- ) 0 %vm-field ; HOOK: %allot cpu ( dst size class temp -- ) HOOK: %write-barrier cpu ( src slot temp1 temp2 -- ) diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor index dbc313052f..3fd0552a99 100644 --- a/basis/cpu/ppc/ppc.factor +++ b/basis/cpu/ppc/ppc.factor @@ -58,11 +58,7 @@ CONSTANT: vm-reg 15 : %load-vm-addr ( reg -- ) vm-reg MR ; -M: ppc %vm-field ( dst field -- ) - [ vm-reg ] dip vm-field-offset LWZ ; - -M: ppc %vm-field-ptr ( dst field -- ) - [ vm-reg ] dip vm-field-offset ADDI ; +M: ppc %vm-field ( dst field -- ) [ vm-reg ] dip LWZ ; GENERIC: loc-reg ( loc -- reg ) @@ -385,7 +381,7 @@ M: ppc %set-alien-float -rot STFS ; M: ppc %set-alien-double -rot STFD ; : load-zone-ptr ( reg -- ) - "nursery" %vm-field-ptr ; + vm-reg "nursery" vm-field-offset ADDI ; : load-allot-ptr ( nursery-ptr allot-ptr -- ) [ drop load-zone-ptr ] [ swap 0 LWZ ] 2bi ; @@ -604,14 +600,14 @@ M: ppc %push-stack ( -- ) int-regs return-reg ds-reg 0 STW ; M: ppc %push-context-stack ( -- ) - 11 "ctx" %vm-field + 11 %context 12 11 "datastack" context-field-offset LWZ 12 12 4 ADDI 12 11 "datastack" context-field-offset STW int-regs return-reg 12 0 STW ; M: ppc %pop-context-stack ( -- ) - 11 "ctx" %vm-field + 11 %context 12 11 "datastack" context-field-offset LWZ int-regs return-reg 12 0 LWZ 12 12 4 SUBI @@ -677,12 +673,12 @@ M: ppc %box-large-struct ( n c-type -- ) "from_value_struct" f %alien-invoke ; M:: ppc %restore-context ( temp1 temp2 -- ) - temp1 "ctx" %vm-field + temp1 %context ds-reg temp1 "datastack" context-field-offset LWZ rs-reg temp1 "retainstack" context-field-offset LWZ ; M:: ppc %save-context ( temp1 temp2 -- ) - temp1 "ctx" %vm-field + temp1 %context 1 temp1 "callstack-top" context-field-offset STW ds-reg temp1 "datastack" context-field-offset STW rs-reg temp1 "retainstack" context-field-offset STW ; diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 09f1ecb32b..8b97eb9351 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -28,10 +28,13 @@ M: x86.32 %mov-vm-ptr ( reg -- ) 0 MOV 0 rc-absolute-cell rel-vm ; M: x86.32 %vm-field ( dst field -- ) - [ 0 [] MOV ] dip vm-field-offset rc-absolute-cell rel-vm ; + [ 0 [] MOV ] dip rc-absolute-cell rel-vm ; + +M: x86.32 %set-vm-field ( dst field -- ) + [ 0 [] swap MOV ] dip rc-absolute-cell rel-vm ; M: x86.32 %vm-field-ptr ( dst field -- ) - [ 0 MOV ] dip vm-field-offset rc-absolute-cell rel-vm ; + [ 0 MOV ] dip rc-absolute-cell rel-vm ; : local@ ( n -- op ) stack-frame get extra-stack-space dup 16 assert= + stack@ ; @@ -166,7 +169,7 @@ M: x86.32 %pop-stack ( n -- ) EAX swap ds-reg reg-stack MOV ; M: x86.32 %pop-context-stack ( -- ) - temp-reg "ctx" %vm-field + temp-reg %context EAX temp-reg "datastack" context-field-offset [+] MOV EAX EAX [] MOV temp-reg "datastack" context-field-offset [+] bootstrap-cell SUB ; diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index 04f64f96b6..bea5d4da1f 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -43,11 +43,14 @@ M: x86.64 machine-registers M: x86.64 %mov-vm-ptr ( reg -- ) vm-reg MOV ; -M: x86.64 %vm-field ( dst field -- ) - [ vm-reg ] dip vm-field-offset [+] MOV ; +M: x86.64 %vm-field ( dst offset -- ) + [ vm-reg ] dip [+] MOV ; -M: x86.64 %vm-field-ptr ( dst field -- ) - [ vm-reg ] dip vm-field-offset [+] LEA ; +M: x86.64 %set-vm-field ( src offset -- ) + [ vm-reg ] dip [+] swap MOV ; + +M: x86.64 %vm-field-ptr ( dst offset -- ) + [ vm-reg ] dip [+] LEA ; : param@ ( n -- op ) reserved-stack-space + stack@ ; @@ -111,7 +114,7 @@ M: x86.64 %pop-stack ( n -- ) param-reg-0 swap ds-reg reg-stack MOV ; M: x86.64 %pop-context-stack ( -- ) - temp-reg "ctx" %vm-field + temp-reg %context param-reg-0 temp-reg "datastack" context-field-offset [+] MOV param-reg-0 param-reg-0 [] MOV temp-reg "datastack" context-field-offset [+] bootstrap-cell SUB ; diff --git a/basis/cpu/x86/x86.factor b/basis/cpu/x86/x86.factor index dbb112bf4b..acd2e1358d 100644 --- a/basis/cpu/x86/x86.factor +++ b/basis/cpu/x86/x86.factor @@ -423,8 +423,13 @@ M: x86 %sar int-rep two-operand [ SAR ] emit-shift ; HOOK: %mov-vm-ptr cpu ( reg -- ) +HOOK: %vm-field-ptr cpu ( reg offset -- ) + +: load-zone-offset ( nursery-ptr -- ) + "nursery" vm-field-offset %vm-field-ptr ; + : load-allot-ptr ( nursery-ptr allot-ptr -- ) - [ drop "nursery" %vm-field-ptr ] [ swap [] MOV ] 2bi ; + [ drop load-zone-offset ] [ swap [] MOV ] 2bi ; : inc-allot-ptr ( nursery-ptr n -- ) [ [] ] dip data-alignment get align ADD ; @@ -456,7 +461,7 @@ M: x86 %write-barrier ( src slot temp1 temp2 -- ) (%write-barrier) ; M: x86 %write-barrier-imm ( src slot temp1 temp2 -- ) (%write-barrier) ; M:: x86 %check-nursery ( label size temp1 temp2 -- ) - temp1 "nursery" %vm-field-ptr + temp1 load-zone-offset ! Load 'here' into temp2 temp2 temp1 [] MOV temp2 size ADD @@ -477,7 +482,7 @@ M: x86 %push-stack ( -- ) ds-reg [] int-regs return-reg MOV ; M: x86 %push-context-stack ( -- ) - temp-reg "ctx" %vm-field + temp-reg %context temp-reg "datastack" context-field-offset [+] bootstrap-cell ADD temp-reg temp-reg "datastack" context-field-offset [+] MOV temp-reg [] int-regs return-reg MOV ; @@ -1403,7 +1408,7 @@ M: x86 %loop-entry 16 code-alignment [ NOP ] times ; M:: x86 %restore-context ( temp1 temp2 -- ) #! Load Factor stack pointers on entry from C to Factor. - temp1 "ctx" %vm-field + temp1 %context ds-reg temp1 "datastack" context-field-offset [+] MOV rs-reg temp1 "retainstack" context-field-offset [+] MOV ; @@ -1411,7 +1416,7 @@ M:: x86 %save-context ( temp1 temp2 -- ) #! Save Factor stack pointers in case the C code calls a #! callback which does a GC, which must reliably trace #! all roots. - temp1 "ctx" %vm-field + temp1 %context temp2 stack-reg cell neg [+] LEA temp1 "callstack-top" context-field-offset [+] temp2 MOV temp1 "datastack" context-field-offset [+] ds-reg MOV From 666081f155072d523559d23e0324d16d517b94ae Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 17:36:09 -0700 Subject: [PATCH 545/713] update %load-param-reg, %save-param-reg, and %cleanup to take register args into account --- basis/cpu/x86/32/32.factor | 26 +++++++++++++++++++------- basis/cpu/x86/64/64.factor | 2 -- basis/cpu/x86/x86.factor | 2 ++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index c707294e42..44e3f040f6 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -66,7 +66,7 @@ M:: x86.32 %dispatch ( src temp -- ) M: x86.32 pic-tail-reg EBX ; -M: x86.32 reserved-stack-space 4 cells ; +M: x86.32 reserved-stack-space 0 ; M: x86.32 %alien-invoke 0 CALL rc-relative rel-dlsym ; @@ -115,12 +115,17 @@ M: x86.32 %prologue ( n -- ) M: x86.32 %prepare-jump pic-tail-reg 0 MOV xt-tail-pic-offset rc-absolute-cell rel-here ; -M: x86.32 %load-param-reg - stack-params assert= - [ [ EAX ] dip local@ MOV ] dip - stack@ EAX MOV ; +M: stack-params copy-register* + drop + { + { [ dup integer? ] [ EAX swap next-stack@ MOV EAX MOV ] } + { [ over integer? ] [ EAX swap MOV param@ EAX MOV ] } + } cond ; -M: x86.32 %save-param-reg 3drop ; +M: x86.32 %save-param-reg + dup stack-params? [ 3drop ] [ [ param@ ] 2dip %copy ] if ; + +M: x86.32 %load-param-reg [ swap local@ ] dip %copy ; : (%box) ( n rep -- ) #! If n is f, push the return register onto the stack; we @@ -307,6 +312,13 @@ M:: x86.32 %binary-float-function ( dst src1 src2 func -- ) : callee-cleanup? ( abi -- ? ) { stdcall fastcall thiscall } member? ; +: stack-arg-size ( params -- n ) + dup abi>> '[ + alien-parameters flatten-value-types + [ _ alloc-parameter 2drop ] each + stack-params get + ] with-param-regs ; + M: x86.32 %cleanup ( params -- ) #! a) If we just called a stdcall function in Windows, it #! cleaned up the stack frame for us. But we don't want that @@ -314,7 +326,7 @@ M: x86.32 %cleanup ( params -- ) #! b) If we just called a function returning a struct, we #! have to fix ESP. { - { [ dup abi>> callee-cleanup? ] [ drop ESP stack-frame get params>> SUB ] } + { [ dup abi>> callee-cleanup? ] [ stack-arg-size ESP swap SUB ] } { [ dup funny-large-struct-return? ] [ drop EAX PUSH ] } [ drop ] } cond ; diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index 6e33219a66..ab75dbf00b 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -49,8 +49,6 @@ M: x86.64 %vm-field ( dst field -- ) M: x86.64 %vm-field-ptr ( dst field -- ) [ vm-reg ] dip vm-field-offset [+] LEA ; -: param@ ( n -- op ) reserved-stack-space + stack@ ; - M: x86.64 %prologue ( n -- ) temp-reg -7 [] LEA dup PUSH diff --git a/basis/cpu/x86/x86.factor b/basis/cpu/x86/x86.factor index dbb112bf4b..a071485de0 100644 --- a/basis/cpu/x86/x86.factor +++ b/basis/cpu/x86/x86.factor @@ -41,6 +41,8 @@ HOOK: extra-stack-space cpu ( stack-frame -- n ) : gc-root@ ( n -- op ) gc-root-offset special@ ; +: param@ ( n -- op ) reserved-stack-space + stack@ ; + : decr-stack-reg ( n -- ) dup 0 = [ drop ] [ stack-reg swap SUB ] if ; From 9c1a9158beec68576dad344521738f9c2696912c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 18:25:56 -0700 Subject: [PATCH 546/713] retire mixed int/float fastcall tests because who cares --- basis/compiler/tests/alien.factor | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 7aab8c8920..2b10c8bd38 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -618,27 +618,7 @@ FUNCTION: void this_does_not_exist ( ) ; : ffi_test_51 ( x y z -- int ) int "f-fastcall" "ffi_test_51" { int int int } alien-invoke gc ; -: ffi_test_52 ( x y z -- int ) - int "f-fastcall" "ffi_test_52" { int float int } - alien-invoke gc ; -: ffi_test_53 ( x y z w -- int ) - int "f-fastcall" "ffi_test_53" { int int int int } - alien-invoke gc ; -: ffi_test_54 ( x y -- int ) - int "f-fastcall" "ffi_test_54" { test-struct-11 int } - alien-invoke gc ; -: ffi_test_55 ( x y z -- int ) - int "f-fastcall" "ffi_test_55" { test-struct-11 int int } - alien-invoke gc ; -: ffi_test_56 ( x y z w -- int ) - int "f-fastcall" "ffi_test_56" { test-struct-11 int int int } - alien-invoke gc ; [ 4 ] [ 3 ffi_test_49 ] unit-test [ 8 ] [ 3 4 ffi_test_50 ] unit-test [ 13 ] [ 3 4 5 ffi_test_51 ] unit-test -[ 13 ] [ 3 4.0 5 ffi_test_52 ] unit-test -[ 19 ] [ 3 4.0 5 6 ffi_test_53 ] unit-test -[ 13 ] [ 3 4 test-struct-11 5 ffi_test_54 ] unit-test -[ 19 ] [ 3 4 test-struct-11 5 6 ffi_test_55 ] unit-test -[ 26 ] [ 3 4 test-struct-11 5 6 7 ffi_test_56 ] unit-test From 553b9fcd933d83bf4ab05b4e5c79205f65374eb2 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 18:34:15 -0700 Subject: [PATCH 547/713] make "fastcall" symbol private since it doesn't really work in all cases --- basis/compiler/tests/alien.factor | 1 + basis/cpu/x86/32/32.factor | 1 + core/alien/alien.factor | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 2b10c8bd38..07457c8f4e 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -6,6 +6,7 @@ namespaces.private parser quotations sequences specialized-arrays stack-checker stack-checker.errors system threads tools.test words alien.complex concurrency.promises ; FROM: alien.c-types => float short ; +FROM: alien.private => fastcall ; SPECIALIZED-ARRAY: float SPECIALIZED-ARRAY: char IN: compiler.tests.alien diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 44e3f040f6..e346f8ab8c 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -10,6 +10,7 @@ compiler.cfg.intrinsics compiler.cfg.stack-frame cpu.x86.assembler cpu.x86.assembler.operands cpu.x86 cpu.architecture vm ; FROM: layouts => cell ; +FROM: alien.private => fastcall ; IN: cpu.x86.32 M: x86.32 machine-registers diff --git a/core/alien/alien.factor b/core/alien/alien.factor index 4dab6f8452..194e4201d2 100644 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -5,7 +5,11 @@ kernel.private byte-arrays byte-vectors arrays init continuations.private ; IN: alien -SINGLETONS: stdcall thiscall fastcall cdecl mingw ; +SINGLETONS: stdcall thiscall cdecl mingw ; + + UNION: abi stdcall thiscall fastcall cdecl mingw ; From 88da92543c7f2d9ffde33f5144f8c45bb2400c43 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 18:48:12 -0700 Subject: [PATCH 548/713] add a test that multiple stdcalls or fastcalls in the same word behave correctly --- basis/compiler/tests/alien.factor | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 07457c8f4e..7b35b8772c 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -1,10 +1,11 @@ USING: accessors alien alien.c-types alien.libraries alien.syntax arrays classes.struct combinators -compiler continuations effects io io.backend io.pathnames -io.streams.string kernel math memory namespaces -namespaces.private parser quotations sequences -specialized-arrays stack-checker stack-checker.errors -system threads tools.test words alien.complex concurrency.promises ; +compiler continuations effects generalizations io +io.backend io.pathnames io.streams.string kernel +math memory namespaces namespaces.private parser +quotations sequences specialized-arrays stack-checker +stack-checker.errors system threads tools.test words +alien.complex concurrency.promises ; FROM: alien.c-types => float short ; FROM: alien.private => fastcall ; SPECIALIZED-ARRAY: float @@ -140,6 +141,14 @@ unit-test 11 6 -7 ffi_test_19 [ x>> ] [ y>> ] [ z>> ] tri ] unit-test +: multi_ffi_test_18 ( w x y z w' x' y' z' -- int int ) + [ int "f-stdcall" "ffi_test_18" { int int int int } alien-invoke ] + 4 ndip + int "f-stdcall" "ffi_test_18" { int int int int } alien-invoke + gc ; + +[ 25 85 ] [ 2 3 4 5 6 7 8 9 multi_ffi_test_18 ] unit-test + FUNCTION: double ffi_test_6 float x float y ; [ 6.0 ] [ 3.0 2.0 ffi_test_6 ] unit-test [ "a" "b" ffi_test_6 ] must-fail @@ -619,7 +628,12 @@ FUNCTION: void this_does_not_exist ( ) ; : ffi_test_51 ( x y z -- int ) int "f-fastcall" "ffi_test_51" { int int int } alien-invoke gc ; +: multi_ffi_test_51 ( x y z x' y' z' -- int int ) + [ int "f-fastcall" "ffi_test_51" { int int int } alien-invoke ] + 3dip + int "f-fastcall" "ffi_test_51" { int int int } alien-invoke gc ; [ 4 ] [ 3 ffi_test_49 ] unit-test [ 8 ] [ 3 4 ffi_test_50 ] unit-test [ 13 ] [ 3 4 5 ffi_test_51 ] unit-test +[ 13 22 ] [ 3 4 5 6 7 8 multi_ffi_test_51 ] unit-test From c12424f8346cd62f7ae46e848476ed855794cff6 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 19:25:24 -0700 Subject: [PATCH 549/713] update alien docs to mention abi symbols --- core/alien/alien-docs.factor | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/core/alien/alien-docs.factor b/core/alien/alien-docs.factor index 5f91d4c695..34ff33bff9 100644 --- a/core/alien/alien-docs.factor +++ b/core/alien/alien-docs.factor @@ -3,8 +3,24 @@ alien.syntax compiler definitions math libc eval debugger parser io io.backend system alien.accessors alien.libraries alien.c-types quotations kernel sequences ; +FROM: alien.private => fastcall ; IN: alien +HELP: cdecl +{ $description "This symbol is passed as the " { $snippet "abi" } " argument to " { $link alien-indirect } ", " { $link alien-callback } ", " { $link alien-assembly } ", and " { $link add-library } " to indicate that the standard C calling convention should be used, where the caller cleans up the stack frame after calling the function. This symbol only has meaning on 32-bit x86 platforms." } ; + +HELP: stdcall +{ $description "This symbol is passed as the " { $snippet "abi" } " argument to " { $link alien-indirect } ", " { $link alien-callback } ", " { $link alien-assembly } ", and " { $link add-library } " to indicate that the Windows API calling convention should be used, where the called function cleans up its own stack frame before returning to the caller. This symbol only has meaning on 32-bit x86 platforms." } ; + +HELP: fastcall +{ $warning "In the current implementation this ABI only works for functions that take only integer and pointer arguments." } +{ $description "This symbol is passed as the " { $snippet "abi" } " argument to " { $link alien-indirect } ", " { $link alien-callback } ", " { $link alien-assembly } ", and " { $link add-library } " to indicate that the \"fast call\" calling convention should be used, where the first two integer or pointer arguments are passed in registers and the function cleans up its own stack frame before returning to the caller. This symbol only has meaning on 32-bit x86 platforms." } ; + +HELP: thiscall +{ $description "This symbol is passed as the " { $snippet "abi" } " argument to " { $link alien-indirect } ", " { $link alien-callback } ", " { $link alien-assembly } ", and " { $link add-library } " to indicate that Microsoft Visual C++ calling convention should be used, where the first argument (which must be a \"this\" pointer) is passed in a register and the function cleans up its own stack frame before returning to the caller. This symbol only has meaning on 32-bit x86 platforms." } ; + +{ cdecl stdcall fastcall thiscall } related-words + HELP: >c-ptr { $values { "obj" object } { "c-ptr" c-ptr } } { $contract "Outputs a pointer to the binary data of this object." } ; @@ -85,7 +101,7 @@ HELP: alien-indirect-error } ; HELP: alien-indirect -{ $values { "args..." "zero or more objects passed to the C function" } { "funcptr" "a C function pointer" } { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } { "return..." "the return value of the function, if not " { $link void } } } +{ $values { "args..." "zero or more objects passed to the C function" } { "funcptr" "a C function pointer" } { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $link cdecl } " or " { $link stdcall } } { "return..." "the return value of the function, if not " { $link void } } } { $description "Invokes a C function pointer passed on the data stack. Input parameters are taken from the data stack following the function pointer, and the return value is pushed on the data stack after the function returns. A return type of " { $link void } " indicates that no value is to be expected." } @@ -101,7 +117,7 @@ HELP: alien-callback-error } ; HELP: alien-callback -{ $values { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } { "quot" quotation } { "alien" alien } } +{ $values { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $link cdecl } " or " { $link stdcall } } { "quot" quotation } { "alien" alien } } { $description "Defines a callback from C to Factor which accepts the given set of parameters from the C caller, pushes them on the data stack, calls the quotation, and passes a return value back to the C caller. A return type of " { $snippet "void" } " indicates that no value is to be returned." $nl @@ -128,7 +144,7 @@ HELP: alien-assembly-error } ; HELP: alien-assembly -{ $values { "args..." "zero or more objects passed to the C function" } { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } { "quot" quotation } { "return..." "the return value of the function, if not " { $link void } } } +{ $values { "args..." "zero or more objects passed to the C function" } { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $link cdecl } " or " { $link stdcall } } { "quot" quotation } { "return..." "the return value of the function, if not " { $link void } } } { $description "Invokes arbitrary machine code, generated at compile-time by the quotation. Input parameters are taken from the data stack, and the return value is pushed on the data stack after the function returns. A return type of " { $link void } " indicates that no value is to be expected." } From 2cab0bb86cc8cc6a48ca4dca1f2f0c141448e7f3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 1 Apr 2010 22:39:46 -0400 Subject: [PATCH 550/713] cpu.ppc: stick old stack pointer in a register for use by callbacks --- basis/cpu/ppc/bootstrap.factor | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/basis/cpu/ppc/bootstrap.factor b/basis/cpu/ppc/bootstrap.factor index 83be0150d8..f7a1917d0e 100644 --- a/basis/cpu/ppc/bootstrap.factor +++ b/basis/cpu/ppc/bootstrap.factor @@ -76,9 +76,12 @@ CONSTANT: nv-reg 17 432 save-at ; [ + ! Save old stack pointer + 11 1 MR + ! Create stack frame 0 MFLR - 1 1 callback-frame-size neg STWU + 1 1 callback-frame-size SUBI 0 1 callback-frame-size lr-save + STW ! Save all non-volatile registers @@ -86,6 +89,10 @@ CONSTANT: nv-reg 17 nv-fp-regs [ 8 * 80 + save-fp ] each-index nv-vec-regs [ 16 * 224 + save-vec ] each-index + ! Stick old stack pointer in a non-volatile register so that + ! callbacks can access their arguments + nv-reg 11 MR + ! Load VM into vm-reg 0 vm-reg LOAD32 rc-absolute-ppc-2/2 rt-vm jit-rel @@ -126,7 +133,7 @@ CONSTANT: nv-reg 17 ! Tear down stack frame and return 0 1 callback-frame-size lr-save + LWZ - 1 1 0 LWZ + 1 1 callback-frame-size ADDI 0 MTLR BLR ] callback-stub jit-define From 044171e6b9296245cc8741fc0c4e9513eec0b328 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 1 Apr 2010 21:41:13 -0500 Subject: [PATCH 551/713] cpu.ppc: fix optimizing compiler backend --- basis/cpu/ppc/ppc.factor | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor index 3fd0552a99..cf8a832386 100644 --- a/basis/cpu/ppc/ppc.factor +++ b/basis/cpu/ppc/ppc.factor @@ -60,6 +60,8 @@ CONSTANT: vm-reg 15 M: ppc %vm-field ( dst field -- ) [ vm-reg ] dip LWZ ; +M: ppc %set-vm-field ( src field -- ) [ vm-reg ] dip STW ; + GENERIC: loc-reg ( loc -- reg ) M: ds-loc loc-reg drop ds-reg ; @@ -563,8 +565,7 @@ M:: ppc %compare-float-unordered-branch ( label src1 src2 cc -- ) } case ; : next-param@ ( n -- reg x ) - 2 1 stack-frame get total-size>> LWZ - [ 2 ] dip param@ ; + [ 17 ] dip param@ ; : store-to-frame ( src n rep -- ) { @@ -745,14 +746,14 @@ M: ppc %alien-callback ( quot -- ) M: ppc %end-callback ( -- ) 3 %load-vm-addr - "unnest_context" f %alien-invoke ; + "end_callback" f %alien-invoke ; M: ppc %end-callback-value ( ctype -- ) ! Save top of data stack - 12 ds-reg 0 LWZ + 16 ds-reg 0 LWZ %end-callback ! Restore top of data stack - 3 12 MR + 3 16 MR ! Unbox former top of data stack to return registers unbox-return ; From 0c0935dfc182e6289da084cd6b78c2bafaa670e6 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 1 Apr 2010 22:24:46 -0500 Subject: [PATCH 552/713] Fix typo in webkit demo --- extra/webkit-demo/webkit-demo.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/webkit-demo/webkit-demo.factor b/extra/webkit-demo/webkit-demo.factor index eb24d035dc..8f89b1b4ae 100644 --- a/extra/webkit-demo/webkit-demo.factor +++ b/extra/webkit-demo/webkit-demo.factor @@ -13,7 +13,7 @@ IMPORT: WebView WebView -> alloc rect f f -> initWithFrame:frameName:groupName: ; -CONSTANT: window-style ( -- n ) +CONSTANT: window-style flags{ NSClosableWindowMask NSMiniaturizableWindowMask From 88fbcba0676ca4370aa6422f14051012dc46889b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 20:56:43 -0700 Subject: [PATCH 553/713] flatten non-integral types to (stack-value) on x86.32 --- basis/compiler/alien/alien.factor | 2 +- basis/compiler/codegen/codegen.factor | 11 ++++++++++- basis/cpu/architecture/architecture.factor | 3 +++ basis/cpu/ppc/ppc.factor | 2 ++ basis/cpu/x86/32/32.factor | 12 +++++++++--- basis/cpu/x86/64/64.factor | 2 ++ basis/cpu/x86/64/unix/unix.factor | 8 +------- 7 files changed, 28 insertions(+), 12 deletions(-) diff --git a/basis/compiler/alien/alien.factor b/basis/compiler/alien/alien.factor index 7426d7e940..63df85be05 100644 --- a/basis/compiler/alien/alien.factor +++ b/basis/compiler/alien/alien.factor @@ -9,7 +9,7 @@ IN: compiler.alien : alien-parameters ( params -- seq ) dup parameters>> - swap return>> large-struct? [ void* prefix ] when ; + swap return>> large-struct? [ struct-return-pointer-type prefix ] when ; : alien-return ( params -- type ) return>> dup large-struct? [ drop void ] when ; diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index 12e263a3f4..4ffe062090 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -320,8 +320,17 @@ M: reg-class reg-class-full? [ alloc-stack-param ] [ alloc-fastcall-param ] if [ abi param-reg ] dip ; +SYMBOL: (stack-value) +<< void* c-type clone \ (stack-value) define-primitive-type +stack-params \ (stack-value) c-type (>>rep) >> + +: ((flatten-type)) ( type to-type -- seq ) + [ stack-size cell align cell /i ] dip c-type ; inline + : (flatten-int-type) ( type -- seq ) - stack-size cell align cell /i void* c-type ; + void* ((flatten-type)) ; +: (flatten-stack-type) ( type -- seq ) + (stack-value) ((flatten-type)) ; GENERIC: flatten-value-type ( type -- types ) diff --git a/basis/cpu/architecture/architecture.factor b/basis/cpu/architecture/architecture.factor index 9a50b0a2e2..6f3865497b 100644 --- a/basis/cpu/architecture/architecture.factor +++ b/basis/cpu/architecture/architecture.factor @@ -502,6 +502,9 @@ HOOK: immediate-arithmetic? cpu ( n -- ? ) ! %and-imm, %or-imm, and %xor-imm? HOOK: immediate-bitwise? cpu ( n -- ? ) +! What c-type describes the implicit struct return pointer for large structs? +HOOK: struct-return-pointer-type cpu ( -- c-type ) + ! Is this structure small enough to be returned in registers? HOOK: return-struct-in-registers? cpu ( c-type -- ? ) diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor index f81d8705bf..dd9252129a 100644 --- a/basis/cpu/ppc/ppc.factor +++ b/basis/cpu/ppc/ppc.factor @@ -704,6 +704,8 @@ M: ppc immediate-arithmetic? ( n -- ? ) -32768 32767 between? ; M: ppc immediate-bitwise? ( n -- ? ) 0 65535 between? ; +M: ppc struct-return-pointer-type void* ; + M: ppc return-struct-in-registers? ( c-type -- ? ) c-type return-in-registers?>> ; diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index e346f8ab8c..71439373c0 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -2,8 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: locals alien alien.c-types alien.libraries alien.syntax arrays kernel fry math namespaces sequences system layouts io -vocabs.loader accessors init combinators command-line make -compiler compiler.units compiler.constants compiler.alien +vocabs.loader accessors init classes.struct combinators command-line +make compiler compiler.units compiler.constants compiler.alien compiler.codegen compiler.codegen.fixup compiler.cfg.instructions compiler.cfg.builder compiler.cfg.intrinsics compiler.cfg.stack-frame @@ -357,6 +357,12 @@ M: x86.32 callback-return-rewind ( params -- n ) } cond ; ! Dreadful -M: object flatten-value-type (flatten-int-type) ; +M: object flatten-value-type (flatten-stack-type) ; +M: struct-c-type flatten-value-type (flatten-stack-type) ; +M: long-long-type flatten-value-type (flatten-stack-type) ; +M: c-type flatten-value-type + dup rep>> int-rep? [ (flatten-int-type) ] [ (flatten-stack-type) ] if ; + +M: x86.64 struct-return-pointer-type (stack-value) ; check-sse diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index ab75dbf00b..87578dd8db 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -275,6 +275,8 @@ M:: x86.64 %call-gc ( gc-root-count temp -- ) ! Call GC "inline_gc" f %alien-invoke ; +M: x86.64 struct-return-pointer-type void* ; + ! The result of reading 4 bytes from memory is a fixnum on ! x86-64. enable-alien-4-intrinsics diff --git a/basis/cpu/x86/64/unix/unix.factor b/basis/cpu/x86/64/unix/unix.factor index 01e02d274d..a1868a3bc8 100644 --- a/basis/cpu/x86/64/unix/unix.factor +++ b/basis/cpu/x86/64/unix/unix.factor @@ -14,11 +14,6 @@ M: float-regs param-regs M: x86.64 reserved-stack-space 0 ; -SYMBOL: (stack-value) -! The ABI for passing structs by value is pretty great -<< void* c-type clone \ (stack-value) define-primitive-type -stack-params \ (stack-value) c-type (>>rep) >> - : struct-types&offset ( struct-type -- pairs ) fields>> [ [ type>> ] [ offset>> ] bi 2array @@ -36,8 +31,7 @@ stack-params \ (stack-value) c-type (>>rep) >> ] map ; : flatten-large-struct ( c-type -- seq ) - heap-size cell align - cell /i \ (stack-value) c-type ; + (flatten-stack-type) ; : flatten-struct ( c-type -- seq ) dup heap-size 16 > [ From 0faa3bcf4a24dd8da0cff04d76bfbdb6be31378a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 1 Apr 2010 22:12:45 -0400 Subject: [PATCH 554/713] vm: pre-allocate context alien --- basis/cpu/x86/32/32.factor | 1 + basis/cpu/x86/32/bootstrap.factor | 6 ++--- basis/cpu/x86/64/64.factor | 1 + basis/cpu/x86/64/bootstrap.factor | 5 ++-- .../known-words/known-words.factor | 1 - basis/threads/threads.factor | 11 +++++--- core/bootstrap/primitives.factor | 1 - vm/contexts.cpp | 26 ++++++++++++------- vm/contexts.hpp | 3 ++- vm/primitives.hpp | 1 - vm/vm.hpp | 4 +-- 11 files changed, 34 insertions(+), 26 deletions(-) diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 8b97eb9351..97f0cfb668 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -244,6 +244,7 @@ M: x86.32 %alien-indirect ( -- ) M: x86.32 %begin-callback ( -- ) 0 save-vm-ptr + ESP 4 [+] 0 MOV "begin_callback" f %alien-invoke ; M: x86.32 %alien-callback ( quot -- ) diff --git a/basis/cpu/x86/32/bootstrap.factor b/basis/cpu/x86/32/bootstrap.factor index a428a66ace..293d99fe93 100644 --- a/basis/cpu/x86/32/bootstrap.factor +++ b/basis/cpu/x86/32/bootstrap.factor @@ -82,11 +82,9 @@ IN: bootstrap.x86 [ jit-load-vm ESP [] vm-reg MOV - "begin_callback" jit-call - - ! load quotation - EBP is ctx-reg so it will get clobbered - ! later on EAX EBP 8 [+] MOV + ESP 4 [+] EAX MOV + "begin_callback" jit-call jit-load-vm jit-load-context diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index bea5d4da1f..7e1c5c1f48 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -231,6 +231,7 @@ M: x86.64 %alien-indirect ( -- ) M: x86.64 %begin-callback ( -- ) param-reg-0 %mov-vm-ptr + param-reg-1 0 MOV "begin_callback" f %alien-invoke ; M: x86.64 %alien-callback ( quot -- ) diff --git a/basis/cpu/x86/64/bootstrap.factor b/basis/cpu/x86/64/bootstrap.factor index 4cd2d8104b..6c0d50f1b7 100644 --- a/basis/cpu/x86/64/bootstrap.factor +++ b/basis/cpu/x86/64/bootstrap.factor @@ -76,8 +76,7 @@ IN: bootstrap.x86 : jit-call-quot ( -- ) arg1 quot-entry-point-offset [+] CALL ; [ - nv-reg arg1 MOV - + arg2 arg1 MOV arg1 vm-reg MOV "begin_callback" jit-call @@ -85,7 +84,7 @@ IN: bootstrap.x86 jit-restore-context ! call the quotation - arg1 nv-reg MOV + arg1 return-reg MOV jit-call-quot jit-save-context diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 01f3ff77c0..15895184df 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -355,7 +355,6 @@ M: bad-executable summary \ code-room { } { byte-array } define-primitive \ code-room make-flushable \ compact-gc { } { } define-primitive \ compute-identity-hashcode { object } { } define-primitive -\ context { } { c-ptr } define-primitive \ context make-flushable \ context-object { fixnum } { object } define-primitive \ context-object make-flushable \ context-object-for { fixnum c-ptr } { object } define-primitive \ context-object-for make-flushable \ current-callback { } { fixnum } define-primitive \ current-callback make-flushable diff --git a/basis/threads/threads.factor b/basis/threads/threads.factor index 404c8112fb..330b4abd6c 100644 --- a/basis/threads/threads.factor +++ b/basis/threads/threads.factor @@ -11,17 +11,20 @@ IN: threads ! Wrap sub-primitives; we don't want them inlined into callers ! since their behavior depends on what frames are on the callstack +: context ( -- context ) + 2 context-object ; inline + : set-context ( obj context -- obj' ) - (set-context) ; + (set-context) ; inline : start-context ( obj quot: ( obj -- * ) -- obj' ) - (start-context) ; + (start-context) ; inline : set-context-and-delete ( obj context -- * ) - (set-context-and-delete) ; + (set-context-and-delete) ; inline : start-context-and-delete ( obj quot: ( obj -- * ) -- * ) - (start-context-and-delete) ; + (start-context-and-delete) ; inline ! Context introspection : namestack-for ( context -- namestack ) diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 52ee1e14b4..8a412b8a14 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -538,7 +538,6 @@ tuple { "system-micros" "system" "primitive_system_micros" (( -- us )) } { "(sleep)" "threads.private" "primitive_sleep" (( nanos -- )) } { "callstack-for" "threads.private" "primitive_callstack_for" (( context -- array )) } - { "context" "threads.private" "primitive_context" (( -- context )) } { "context-object-for" "threads.private" "primitive_context_object_for" (( n context -- obj )) } { "datastack-for" "threads.private" "primitive_datastack_for" (( context -- array )) } { "retainstack-for" "threads.private" "primitive_retainstack_for" (( context -- array )) } diff --git a/vm/contexts.cpp b/vm/contexts.cpp index 9364f2e362..25fe0e5280 100644 --- a/vm/contexts.cpp +++ b/vm/contexts.cpp @@ -108,9 +108,16 @@ context *factor_vm::new_context() return new_context; } +void factor_vm::init_context(context *ctx) +{ + ctx->context_objects[OBJ_CONTEXT] = allot_alien(ctx); +} + context *new_context(factor_vm *parent) { - return parent->new_context(); + context *new_context = parent->new_context(); + parent->init_context(new_context); + return new_context; } void factor_vm::delete_context(context *old_context) @@ -124,16 +131,22 @@ VM_C_API void delete_context(factor_vm *parent, context *old_context) parent->delete_context(old_context); } -void factor_vm::begin_callback() +cell factor_vm::begin_callback(cell quot_) { + data_root quot(quot_,this); + ctx->reset(); spare_ctx = new_context(); callback_ids.push_back(callback_id++); + + init_context(ctx); + + return quot.value(); } -void begin_callback(factor_vm *parent) +cell begin_callback(factor_vm *parent, cell quot) { - parent->begin_callback(); + return parent->begin_callback(quot); } void factor_vm::end_callback() @@ -296,9 +309,4 @@ void factor_vm::primitive_load_locals() ctx->retainstack += sizeof(cell) * count; } -void factor_vm::primitive_context() -{ - ctx->push(allot_alien(ctx)); -} - } diff --git a/vm/contexts.hpp b/vm/contexts.hpp index f3aba0e5a6..85338ca91d 100644 --- a/vm/contexts.hpp +++ b/vm/contexts.hpp @@ -6,6 +6,7 @@ static const cell context_object_count = 10; enum context_object { OBJ_NAMESTACK, OBJ_CATCHSTACK, + OBJ_CONTEXT, }; static const cell stack_reserved = 1024; @@ -71,7 +72,7 @@ struct context { VM_C_API context *new_context(factor_vm *parent); VM_C_API void delete_context(factor_vm *parent, context *old_context); -VM_C_API void begin_callback(factor_vm *parent); +VM_C_API cell begin_callback(factor_vm *parent, cell quot); VM_C_API void end_callback(factor_vm *parent); } diff --git a/vm/primitives.hpp b/vm/primitives.hpp index 7e95a3bad5..ff0947912c 100644 --- a/vm/primitives.hpp +++ b/vm/primitives.hpp @@ -43,7 +43,6 @@ namespace factor _(code_room) \ _(compact_gc) \ _(compute_identity_hashcode) \ - _(context) \ _(context_object) \ _(context_object_for) \ _(current_callback) \ diff --git a/vm/vm.hpp b/vm/vm.hpp index ad74a8e090..cf2f0ca433 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -112,10 +112,11 @@ struct factor_vm // contexts context *new_context(); + void init_context(context *ctx); void delete_context(context *old_context); void init_contexts(cell datastack_size_, cell retainstack_size_, cell callstack_size_); void delete_contexts(); - void begin_callback(); + cell begin_callback(cell quot); void end_callback(); void primitive_current_callback(); void primitive_context_object(); @@ -135,7 +136,6 @@ struct factor_vm void primitive_set_retainstack(); void primitive_check_datastack(); void primitive_load_locals(); - void primitive_context(); template void iterate_active_callstacks(Iterator &iter) { From d9d12ab8fb5af2fedfeb99b08b4536cbd0ffe480 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 2 Apr 2010 00:03:26 -0400 Subject: [PATCH 555/713] vm: don't try loading Factor VM DLL anymore --- vm/os-genunix.hpp | 1 - vm/os-macosx.hpp | 1 - vm/os-unix.cpp | 2 +- vm/os-windows-nt.hpp | 4 ++-- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/vm/os-genunix.hpp b/vm/os-genunix.hpp index c6123eca56..a40e891a6e 100644 --- a/vm/os-genunix.hpp +++ b/vm/os-genunix.hpp @@ -2,7 +2,6 @@ namespace factor { #define VM_C_API extern "C" -#define NULL_DLL NULL void early_init(); const char *vm_executable_path(); diff --git a/vm/os-macosx.hpp b/vm/os-macosx.hpp index 4d4499461d..27eba77215 100644 --- a/vm/os-macosx.hpp +++ b/vm/os-macosx.hpp @@ -3,7 +3,6 @@ namespace factor #define VM_C_API extern "C" __attribute__((visibility("default"))) #define FACTOR_OS_STRING "macosx" -#define NULL_DLL NULL void early_init(); diff --git a/vm/os-unix.cpp b/vm/os-unix.cpp index 60ac00fb39..034dfcbf5f 100644 --- a/vm/os-unix.cpp +++ b/vm/os-unix.cpp @@ -46,7 +46,7 @@ void sleep_nanos(u64 nsec) void factor_vm::init_ffi() { - null_dll = dlopen(NULL_DLL,RTLD_LAZY); + null_dll = dlopen(NULL,RTLD_LAZY); } void factor_vm::ffi_dlopen(dll *dll) diff --git a/vm/os-windows-nt.hpp b/vm/os-windows-nt.hpp index c5e721c56d..869205b67e 100755 --- a/vm/os-windows-nt.hpp +++ b/vm/os-windows-nt.hpp @@ -20,7 +20,7 @@ typedef char symbol_char; #define FACTOR_OS_STRING "winnt" -#define FACTOR_DLL L"factor.dll" +#define FACTOR_DLL NULL #ifdef _MSC_VER #define FACTOR_STDCALL(return_type) return_type __stdcall @@ -28,7 +28,7 @@ typedef char symbol_char; #define FACTOR_STDCALL(return_type) __attribute__((stdcall)) return_type #endif -FACTOR_STDCALL(LONG) exception_handler(PEXCEPTION_POINTERS pe); +VM_C_API exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch) // SSE traps raise these exception codes, which are defined in internal NT headers // but not winbase.h From fa9b6e086b94be5f1670cd1fa226f4ff67a3c147 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 2 Apr 2010 00:22:16 -0400 Subject: [PATCH 556/713] vm: oops --- vm/os-windows-nt.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/os-windows-nt.hpp b/vm/os-windows-nt.hpp index 869205b67e..f274d7813f 100755 --- a/vm/os-windows-nt.hpp +++ b/vm/os-windows-nt.hpp @@ -28,7 +28,7 @@ typedef char symbol_char; #define FACTOR_STDCALL(return_type) __attribute__((stdcall)) return_type #endif -VM_C_API exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch) +FACTOR_STDCALL(LONG) exception_handler(PEXCEPTION_POINTERS pe); // SSE traps raise these exception codes, which are defined in internal NT headers // but not winbase.h From 279ff3a7d311b00dd85d1701f32bd91f52b2353e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 2 Apr 2010 00:36:45 -0400 Subject: [PATCH 557/713] vm: smaller default callstack size on OpenBSD --- vm/factor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vm/factor.cpp b/vm/factor.cpp index e726ebf6da..983e12bdcd 100755 --- a/vm/factor.cpp +++ b/vm/factor.cpp @@ -14,7 +14,12 @@ void factor_vm::default_parameters(vm_parameters *p) p->datastack_size = 32 * sizeof(cell); p->retainstack_size = 32 * sizeof(cell); + +#ifdef __OpenBSD__ + p->callstack_size = 32 * sizeof(cell); +#else p->callstack_size = 128 * sizeof(cell); +#endif p->code_size = 8 * sizeof(cell); p->young_size = sizeof(cell) / 4; From fa49520cbf019f7e02b0879f0bdfd73308cbfacd Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 21:59:02 -0700 Subject: [PATCH 558/713] update nmakefile to statically link VM to exe just like GNUmakefile --- Nmakefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Nmakefile b/Nmakefile index a73a59d0f5..0d815b6161 100755 --- a/Nmakefile +++ b/Nmakefile @@ -6,7 +6,7 @@ LINK_FLAGS = /nologo shell32.lib CL_FLAGS = /nologo /O2 /W3 !ENDIF -EXE_OBJS = factor.dll.lib vm\main-windows-nt.obj vm\factor.res +EXE_OBJS = vm\main-windows-nt.obj vm\factor.res DLL_OBJS = vm\os-windows-nt.obj \ vm\os-windows.obj \ @@ -63,7 +63,7 @@ DLL_OBJS = vm\os-windows-nt.obj \ .rs.res: rc $< -all: factor.com factor.exe libfactor-ffi-test.dll +all: factor.com factor.exe factor.dll.lib libfactor-ffi-test.dll libfactor-ffi-test.dll: vm/ffi_test.obj link $(LINK_FLAGS) /out:libfactor-ffi-test.dll /dll vm/ffi_test.obj @@ -71,11 +71,11 @@ libfactor-ffi-test.dll: vm/ffi_test.obj factor.dll.lib: $(DLL_OBJS) link $(LINK_FLAGS) /implib:factor.dll.lib /out:factor.dll /dll $(DLL_OBJS) -factor.com: $(EXE_OBJS) - link $(LINK_FLAGS) /out:factor.com /SUBSYSTEM:console $(EXE_OBJS) +factor.com: $(EXE_OBJS) $(DLL_OBJS) + link $(LINK_FLAGS) /out:factor.com /SUBSYSTEM:console $(EXE_OBJS) $(DLL_OBJS) -factor.exe: $(EXE_OBJS) - link $(LINK_FLAGS) /out:factor.exe /SUBSYSTEM:windows $(EXE_OBJS) +factor.exe: $(EXE_OBJS) $(DLL_OBJS) + link $(LINK_FLAGS) /out:factor.exe /SUBSYSTEM:windows $(EXE_OBJS) $(DLL_OBJS) clean: del vm\*.obj From 2c3fde412ab29a21be2b71c47a33a466aaa05b57 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 22:01:10 -0700 Subject: [PATCH 559/713] cpu.x86.32: add load-return-regs methods for stack-params so callbacks can box the struct return pointer --- basis/cpu/x86/32/32.factor | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 71439373c0..02f9380e01 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -99,6 +99,9 @@ M: int-regs param-regs GENERIC: load-return-reg ( src rep -- ) GENERIC: store-return-reg ( dst rep -- ) +M: stack-params load-return-reg drop EAX swap MOV ; +M: stack-params store-return-reg drop EAX MOV ; + M: int-rep load-return-reg drop EAX swap MOV ; M: int-rep store-return-reg drop EAX MOV ; @@ -363,6 +366,6 @@ M: long-long-type flatten-value-type (flatten-stack-type) ; M: c-type flatten-value-type dup rep>> int-rep? [ (flatten-int-type) ] [ (flatten-stack-type) ] if ; -M: x86.64 struct-return-pointer-type (stack-value) ; +M: x86.32 struct-return-pointer-type (stack-value) ; check-sse From fd0569e553243eb7a9f2c8e2b622ed5d0fcdee4c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 22:47:16 -0700 Subject: [PATCH 560/713] compiler.tests.alien: add back fastcall float and struct tests --- basis/compiler/tests/alien.factor | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 7b35b8772c..63d32d71ac 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -637,3 +637,25 @@ FUNCTION: void this_does_not_exist ( ) ; [ 8 ] [ 3 4 ffi_test_50 ] unit-test [ 13 ] [ 3 4 5 ffi_test_51 ] unit-test [ 13 22 ] [ 3 4 5 6 7 8 multi_ffi_test_51 ] unit-test + +: ffi_test_52 ( x y z -- int ) + int "f-fastcall" "ffi_test_52" { int float int } + alien-invoke gc ; +: ffi_test_53 ( x y z w -- int ) + int "f-fastcall" "ffi_test_53" { int float int int } + alien-invoke gc ; +: ffi_test_54 ( x y -- int ) + int "f-fastcall" "ffi_test_54" { test-struct-11 int } + alien-invoke gc ; +: ffi_test_55 ( x y z -- int ) + int "f-fastcall" "ffi_test_55" { test-struct-11 int int } + alien-invoke gc ; +: ffi_test_56 ( x y z w -- int ) + int "f-fastcall" "ffi_test_56" { test-struct-11 int int int } + alien-invoke gc ; + +[ 13 ] [ 3 4.0 5 ffi_test_52 ] unit-test +[ 19 ] [ 3 4.0 5 6 ffi_test_53 ] unit-test +[ 13 ] [ 3 4 test-struct-11 5 ffi_test_54 ] unit-test +[ 19 ] [ 3 4 test-struct-11 5 6 ffi_test_55 ] unit-test +[ 26 ] [ 3 4 test-struct-11 5 6 7 ffi_test_56 ] unit-test From 69abcd4b9b5ac3901b654b140a597669c8e425ad Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 23:43:55 -0700 Subject: [PATCH 561/713] test indirect fastcalls --- basis/compiler/tests/alien.factor | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 63d32d71ac..d4dd1f6eb8 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -659,3 +659,11 @@ FUNCTION: void this_does_not_exist ( ) ; [ 13 ] [ 3 4 test-struct-11 5 ffi_test_54 ] unit-test [ 19 ] [ 3 4 test-struct-11 5 6 ffi_test_55 ] unit-test [ 26 ] [ 3 4 test-struct-11 5 6 7 ffi_test_56 ] unit-test + +: fastcall-ii-indirect ( x y ptr -- result ) + int { int int } fastcall alien-indirect ; +: fastcall-ifi-indirect ( x y z ptr -- result ) + int { int float int } fastcall alien-indirect ; + +[ 8 ] [ 3 4 &: ffi_test_50 fastcall-ii-indirect ] unit-test +[ 13 ] [ 3 4.0 5 &: ffi_test_52 fastcall-ifi-indirect ] unit-test From 5dcfb383a630f33bc11098777714fba97e41f361 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 23:52:56 -0700 Subject: [PATCH 562/713] add tests for struct returns from fastcall --- basis/compiler/tests/alien.factor | 9 +++++++++ vm/ffi_test.c | 12 ++++++++++++ vm/ffi_test.h | 2 ++ 3 files changed, 23 insertions(+) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index d4dd1f6eb8..fdbcf6948e 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -653,12 +653,20 @@ FUNCTION: void this_does_not_exist ( ) ; : ffi_test_56 ( x y z w -- int ) int "f-fastcall" "ffi_test_56" { test-struct-11 int int int } alien-invoke gc ; +: ffi_test_57 ( x y -- test-struct-11 ) + test-struct-11 "f-fastcall" "ffi_test_57" { int int } + alien-invoke gc ; +: ffi_test_58 ( x y z -- test-struct-11 ) + test-struct-11 "f-fastcall" "ffi_test_58" { int int int } + alien-invoke gc ; [ 13 ] [ 3 4.0 5 ffi_test_52 ] unit-test [ 19 ] [ 3 4.0 5 6 ffi_test_53 ] unit-test [ 13 ] [ 3 4 test-struct-11 5 ffi_test_54 ] unit-test [ 19 ] [ 3 4 test-struct-11 5 6 ffi_test_55 ] unit-test [ 26 ] [ 3 4 test-struct-11 5 6 7 ffi_test_56 ] unit-test +[ S{ test-struct-11 f 7 -1 } ] [ 3 4 ffi_test_57 ] unit-test +[ S{ test-struct-11 f 7 -3 } ] [ 3 4 7 ffi_test_58 ] unit-test : fastcall-ii-indirect ( x y ptr -- result ) int { int int } fastcall alien-indirect ; @@ -667,3 +675,4 @@ FUNCTION: void this_does_not_exist ( ) ; [ 8 ] [ 3 4 &: ffi_test_50 fastcall-ii-indirect ] unit-test [ 13 ] [ 3 4.0 5 &: ffi_test_52 fastcall-ifi-indirect ] unit-test + diff --git a/vm/ffi_test.c b/vm/ffi_test.c index d45a08cf8b..993ca18fa3 100755 --- a/vm/ffi_test.c +++ b/vm/ffi_test.c @@ -353,3 +353,15 @@ FACTOR_FASTCALL(int) ffi_test_56(struct test_struct_11 x, int y, int z, int w) { return x.x + x.y + y + z + w + 1; } + +FACTOR_FASTCALL(struct test_struct_11) ffi_test_57(int x, int y) +{ + struct test_struct_11 r = { x + y, x - y }; + return r; +} + +FACTOR_FASTCALL(struct test_struct_11) ffi_test_58(int x, int y, int z) +{ + struct test_struct_11 r = { x + y, y - z }; + return r; +} diff --git a/vm/ffi_test.h b/vm/ffi_test.h index 6fe35fdb42..08b8f95c39 100755 --- a/vm/ffi_test.h +++ b/vm/ffi_test.h @@ -131,3 +131,5 @@ FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_53(int x, float y, int z, int w); FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_54(struct test_struct_11 x, int y); FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_55(struct test_struct_11 x, int y, int z); FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_56(struct test_struct_11 x, int y, int z, int w); +FACTOR_EXPORT FACTOR_FASTCALL(struct test_struct_11) ffi_test_57(int x, int y); +FACTOR_EXPORT FACTOR_FASTCALL(struct test_struct_11) ffi_test_58(int x, int y, int z); From 43d73dcd4d6f0967d91f6c1c4134cb8ab6acfbf0 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 1 Apr 2010 23:54:08 -0700 Subject: [PATCH 563/713] remove fastcall struct param tests because GCC appears to behave differently from VC++ here and again, who cares --- basis/compiler/tests/alien.factor | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index fdbcf6948e..757576525a 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -644,15 +644,6 @@ FUNCTION: void this_does_not_exist ( ) ; : ffi_test_53 ( x y z w -- int ) int "f-fastcall" "ffi_test_53" { int float int int } alien-invoke gc ; -: ffi_test_54 ( x y -- int ) - int "f-fastcall" "ffi_test_54" { test-struct-11 int } - alien-invoke gc ; -: ffi_test_55 ( x y z -- int ) - int "f-fastcall" "ffi_test_55" { test-struct-11 int int } - alien-invoke gc ; -: ffi_test_56 ( x y z w -- int ) - int "f-fastcall" "ffi_test_56" { test-struct-11 int int int } - alien-invoke gc ; : ffi_test_57 ( x y -- test-struct-11 ) test-struct-11 "f-fastcall" "ffi_test_57" { int int } alien-invoke gc ; @@ -662,9 +653,6 @@ FUNCTION: void this_does_not_exist ( ) ; [ 13 ] [ 3 4.0 5 ffi_test_52 ] unit-test [ 19 ] [ 3 4.0 5 6 ffi_test_53 ] unit-test -[ 13 ] [ 3 4 test-struct-11 5 ffi_test_54 ] unit-test -[ 19 ] [ 3 4 test-struct-11 5 6 ffi_test_55 ] unit-test -[ 26 ] [ 3 4 test-struct-11 5 6 7 ffi_test_56 ] unit-test [ S{ test-struct-11 f 7 -1 } ] [ 3 4 ffi_test_57 ] unit-test [ S{ test-struct-11 f 7 -3 } ] [ 3 4 7 ffi_test_58 ] unit-test From 47f3ace5ac197b5963e2c8ce28d5d343f870e6a5 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 2 Apr 2010 00:00:34 -0700 Subject: [PATCH 564/713] test fastcall indirect struct return --- basis/compiler/tests/alien.factor | 3 +++ 1 file changed, 3 insertions(+) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 757576525a..667fd43285 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -660,7 +660,10 @@ FUNCTION: void this_does_not_exist ( ) ; int { int int } fastcall alien-indirect ; : fastcall-ifi-indirect ( x y z ptr -- result ) int { int float int } fastcall alien-indirect ; +: fastcall-struct-return-indirect ( x y ptr -- result ) + test-struct-11 { int int } fastcall alien-indirect ; [ 8 ] [ 3 4 &: ffi_test_50 fastcall-ii-indirect ] unit-test [ 13 ] [ 3 4.0 5 &: ffi_test_52 fastcall-ifi-indirect ] unit-test +[ S{ test-struct-11 f 7 -1 } ] [ 3 4 &: ffi_test_57 fastcall-struct-return-indirect ] unit-test From 1c5f718e802331842417343347aaf8e23ec3542d Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 2 Apr 2010 00:23:39 -0700 Subject: [PATCH 565/713] add tests for fastcall callbacks --- basis/compiler/tests/alien.factor | 46 +++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 667fd43285..c54ce443d6 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -658,12 +658,52 @@ FUNCTION: void this_does_not_exist ( ) ; : fastcall-ii-indirect ( x y ptr -- result ) int { int int } fastcall alien-indirect ; +: fastcall-iii-indirect ( x y z ptr -- result ) + int { int int int } fastcall alien-indirect ; : fastcall-ifi-indirect ( x y z ptr -- result ) int { int float int } fastcall alien-indirect ; -: fastcall-struct-return-indirect ( x y ptr -- result ) +: fastcall-ifii-indirect ( x y z w ptr -- result ) + int { int float int int } fastcall alien-indirect ; +: fastcall-struct-return-ii-indirect ( x y ptr -- result ) test-struct-11 { int int } fastcall alien-indirect ; +: fastcall-struct-return-iii-indirect ( x y z ptr -- result ) + test-struct-11 { int int int } fastcall alien-indirect ; [ 8 ] [ 3 4 &: ffi_test_50 fastcall-ii-indirect ] unit-test -[ 13 ] [ 3 4.0 5 &: ffi_test_52 fastcall-ifi-indirect ] unit-test -[ S{ test-struct-11 f 7 -1 } ] [ 3 4 &: ffi_test_57 fastcall-struct-return-indirect ] unit-test +[ 13 ] [ 3 4 5 &: ffi_test_51 fastcall-iii-indirect ] unit-test +[ 13 ] [ 3 4.0 5 &: ffi_test_52 fastcall-ifi-indirect ] unit-test +[ 19 ] [ 3 4.0 5 6 &: ffi_test_53 fastcall-ifii-indirect ] unit-test +[ S{ test-struct-11 f 7 -1 } ] +[ 3 4 &: ffi_test_57 fastcall-struct-return-ii-indirect ] unit-test + +[ S{ test-struct-11 f 7 -3 } ] +[ 3 4 7 &: ffi_test_58 fastcall-struct-return-iii-indirect ] unit-test + +: fastcall-ii-callback ( -- ptr ) + int { int int } fastcall [ + 1 + ] alien-callback ; +: fastcall-iii-callback ( -- ptr ) + int { int int int } fastcall [ + + 1 + ] alien-callback ; +: fastcall-ifi-callback ( -- ptr ) + int { int float int } fastcall + [ [ >integer ] dip + + 1 + ] alien-callback ; +: fastcall-ifii-callback ( -- ptr ) + int { int float int int } fastcall + [ [ >integer ] 2dip + + + 1 + ] alien-callback ; +: fastcall-struct-return-ii-callback ( -- ptr ) + test-struct-11 { int int } fastcall + [ [ + ] [ - ] 2bi test-struct-11 ] alien-callback ; +: fastcall-struct-return-iii-callback ( -- ptr ) + test-struct-11 { int int int } fastcall + [ [ drop + ] [ - nip ] 3bi test-struct-11 ] alien-callback ; + +[ 8 ] [ 3 4 fastcall-ii-callback fastcall-ii-indirect ] unit-test +[ 13 ] [ 3 4 5 fastcall-iii-callback fastcall-iii-indirect ] unit-test +[ 13 ] [ 3 4.0 5 fastcall-ifi-callback fastcall-ifi-indirect ] unit-test +[ 19 ] [ 3 4.0 5 6 fastcall-ifii-callback fastcall-ifii-indirect ] unit-test + +[ S{ test-struct-11 f 7 -1 } ] +[ 3 4 fastcall-struct-return-ii-callback fastcall-struct-return-ii-indirect ] unit-test + +[ S{ test-struct-11 f 7 -3 } ] +[ 3 4 7 fastcall-struct-return-iii-callback fastcall-struct-return-iii-indirect ] unit-test From 2d22a8eb49c5010c3bab9507d1c0dd99cdc9a198 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 2 Apr 2010 00:30:27 -0700 Subject: [PATCH 566/713] tools.disassembler: allow aliens to be used in address pairs --- basis/tools/disassembler/disassembler.factor | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/basis/tools/disassembler/disassembler.factor b/basis/tools/disassembler/disassembler.factor index c0b3c9a586..c8df2f1094 100644 --- a/basis/tools/disassembler/disassembler.factor +++ b/basis/tools/disassembler/disassembler.factor @@ -15,6 +15,11 @@ HOOK: disassemble* disassembler-backend ( from to -- lines ) TR: tabs>spaces "\t" "\s" ; +GENERIC: (>address) ( object -- n ) + +M: integer (>address) ; +M: alien (>address) alien-address ; + PRIVATE> M: byte-array disassemble @@ -24,7 +29,7 @@ M: byte-array disassemble 2array disassemble ] with-destructors ; -M: pair disassemble first2 disassemble* [ tabs>spaces print ] each ; +M: pair disassemble first2 [ (>address) ] bi@ disassemble* [ tabs>spaces print ] each ; M: word disassemble word-code 2array disassemble ; From 77e63550a776838780f2fa7f5f0cf166f9b35307 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Fri, 2 Apr 2010 00:47:37 -0700 Subject: [PATCH 567/713] Add syntax highlighting for BEFORE: and AFTER: --- misc/fuel/fuel-font-lock.el | 4 ++++ misc/fuel/fuel-syntax.el | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/misc/fuel/fuel-font-lock.el b/misc/fuel/fuel-font-lock.el index 983e1bcb98..8d3990fcd8 100644 --- a/misc/fuel/fuel-font-lock.el +++ b/misc/fuel/fuel-font-lock.el @@ -126,6 +126,10 @@ (,fuel-syntax--type-definition-regex 2 'factor-font-lock-type-name) (,fuel-syntax--method-definition-regex (1 'factor-font-lock-type-name) (2 'factor-font-lock-word)) + (,fuel-syntax--before-definition-regex (1 'factor-font-lock-type-name) + (2 'factor-font-lock-word)) + (,fuel-syntax--after-definition-regex (1 'factor-font-lock-type-name) + (2 'factor-font-lock-word)) (,fuel-syntax--tuple-decl-regex 2 'factor-font-lock-type-name) (,fuel-syntax--constructor-regex . 'factor-font-lock-constructor) (,fuel-syntax--setter-regex . 'factor-font-lock-setter-word) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index 114355b3db..d13a670df4 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -44,8 +44,8 @@ (defconst fuel-syntax--parsing-words '(":" "::" ";" "&:" "<<" ">" - "ABOUT:" "ALIAS:" "ALIEN:" "ARTICLE:" - "B" "BIN:" + "ABOUT:" "AFTER:" "ALIAS:" "ALIEN:" "ARTICLE:" + "B" "BEFORE:" "BIN:" "C:" "CALLBACK:" "C-ENUM:" "C-STRUCT:" "C-TYPE:" "C-UNION:" "CHAR:" "COM-INTERFACE:" "CONSTANT:" "call-next-method" "DEFER:" "EBNF:" ";EBNF" "ERROR:" "EXCLUDE:" @@ -88,6 +88,12 @@ (defconst fuel-syntax--method-definition-regex "^M::? +\\([^ ]+\\) +\\([^ ]+\\)") +(defconst fuel-syntax--before-definition-regex + "^BEFORE: +\\([^ ]+\\) +\\([^ ]+\\)") + +(defconst fuel-syntax--after-definition-regex + "^AFTER: +\\([^ ]+\\) +\\([^ ]+\\)") + (defconst fuel-syntax--integer-regex "\\_<-?[0-9]+\\_>") @@ -157,6 +163,7 @@ "\\_ Date: Fri, 2 Apr 2010 14:09:58 -0400 Subject: [PATCH 568/713] vm: larger default callstack on PowerPC --- vm/factor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/factor.cpp b/vm/factor.cpp index 983e12bdcd..89da7a2db7 100755 --- a/vm/factor.cpp +++ b/vm/factor.cpp @@ -15,8 +15,8 @@ void factor_vm::default_parameters(vm_parameters *p) p->datastack_size = 32 * sizeof(cell); p->retainstack_size = 32 * sizeof(cell); -#ifdef __OpenBSD__ - p->callstack_size = 32 * sizeof(cell); +#ifdef FACTOR_PPC + p->callstack_size = 256 * sizeof(cell); #else p->callstack_size = 128 * sizeof(cell); #endif From b740a1fe5d34c872f58e9dac2491d3b7715adcdd Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 2 Apr 2010 14:10:55 -0400 Subject: [PATCH 569/713] vm: use C++ exceptions instead of longjmp(), to make Windows crash more --- vm/collector.hpp | 5 +-- vm/gc.cpp | 84 ++++++++++++++++++++++++++---------------------- vm/gc.hpp | 1 - vm/master.hpp | 1 - 4 files changed, 49 insertions(+), 42 deletions(-) diff --git a/vm/collector.hpp b/vm/collector.hpp index ece4926c28..0b8b473e8b 100644 --- a/vm/collector.hpp +++ b/vm/collector.hpp @@ -1,6 +1,8 @@ namespace factor { +struct must_start_gc_again {}; + template struct data_workhorse { factor_vm *parent; TargetGeneration *target; @@ -27,8 +29,7 @@ template struct data_workhorse { { cell size = untagged->size(); object *newpointer = target->allot(size); - /* XXX not exception-safe */ - if(!newpointer) longjmp(parent->current_gc->gc_unwind,1); + if(!newpointer) throw must_start_gc_again(); memcpy(newpointer,untagged,size); untagged->forward_to(newpointer); diff --git a/vm/gc.cpp b/vm/gc.cpp index a57f338c44..e01a05aa5b 100755 --- a/vm/gc.cpp +++ b/vm/gc.cpp @@ -135,49 +135,57 @@ void factor_vm::gc(gc_op op, cell requested_bytes, bool trace_contexts_p) /* Keep trying to GC higher and higher generations until we don't run out of space */ - if(setjmp(current_gc->gc_unwind)) + for(;;) { - /* We come back here if a generation is full */ - start_gc_again(); - } - - current_gc->event->op = current_gc->op; - - switch(current_gc->op) - { - case collect_nursery_op: - collect_nursery(); - break; - case collect_aging_op: - collect_aging(); - if(data->high_fragmentation_p()) + try { - current_gc->op = collect_full_op; - current_gc->event->op = collect_full_op; - collect_full(trace_contexts_p); + current_gc->event->op = current_gc->op; + + switch(current_gc->op) + { + case collect_nursery_op: + collect_nursery(); + break; + case collect_aging_op: + collect_aging(); + if(data->high_fragmentation_p()) + { + current_gc->op = collect_full_op; + current_gc->event->op = collect_full_op; + collect_full(trace_contexts_p); + } + break; + case collect_to_tenured_op: + collect_to_tenured(); + if(data->high_fragmentation_p()) + { + current_gc->op = collect_full_op; + current_gc->event->op = collect_full_op; + collect_full(trace_contexts_p); + } + break; + case collect_full_op: + collect_full(trace_contexts_p); + break; + case collect_compact_op: + collect_compact(trace_contexts_p); + break; + case collect_growing_heap_op: + collect_growing_heap(requested_bytes,trace_contexts_p); + break; + default: + critical_error("Bad GC op",current_gc->op); + break; + } + + break; } - break; - case collect_to_tenured_op: - collect_to_tenured(); - if(data->high_fragmentation_p()) + catch(const must_start_gc_again e) { - current_gc->op = collect_full_op; - current_gc->event->op = collect_full_op; - collect_full(trace_contexts_p); + /* We come back here if a generation is full */ + start_gc_again(); + continue; } - break; - case collect_full_op: - collect_full(trace_contexts_p); - break; - case collect_compact_op: - collect_compact(trace_contexts_p); - break; - case collect_growing_heap_op: - collect_growing_heap(requested_bytes,trace_contexts_p); - break; - default: - critical_error("Bad GC op",current_gc->op); - break; } end_gc(); diff --git a/vm/gc.hpp b/vm/gc.hpp index 5224dec3e2..5129ced909 100755 --- a/vm/gc.hpp +++ b/vm/gc.hpp @@ -45,7 +45,6 @@ struct gc_event { struct gc_state { gc_op op; u64 start_time; - jmp_buf gc_unwind; gc_event *event; explicit gc_state(gc_op op_, factor_vm *parent); diff --git a/vm/master.hpp b/vm/master.hpp index 9879fa607a..a111a86b69 100755 --- a/vm/master.hpp +++ b/vm/master.hpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include From 68073831f9585fb31d99645866c19b4668cf3106 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 2 Apr 2010 14:14:25 -0400 Subject: [PATCH 570/713] mason.common: increase timeout because Windows is damn slow --- extra/mason/common/common.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/mason/common/common.factor b/extra/mason/common/common.factor index 912cd48c79..db68a558e0 100644 --- a/extra/mason/common/common.factor +++ b/extra/mason/common/common.factor @@ -17,8 +17,8 @@ SYMBOL: current-git-id : short-running-process ( command -- ) #! Give network operations and shell commands at most - #! 15 minutes to complete, to catch hangs. - >process 15 minutes >>timeout try-output-process ; + #! 30 minutes to complete, to catch hangs. + >process 30 minutes >>timeout try-output-process ; HOOK: really-delete-tree os ( path -- ) From de4343eaf7e14260b288632764f4108261eabd2c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 2 Apr 2010 15:42:29 -0400 Subject: [PATCH 571/713] vm: re-organize context structure --- basis/vm/vm.factor | 4 ++-- vm/contexts.hpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/basis/vm/vm.factor b/basis/vm/vm.factor index b0f2c945f7..b4c5734810 100644 --- a/basis/vm/vm.factor +++ b/basis/vm/vm.factor @@ -11,10 +11,10 @@ STRUCT: context { datastack cell } { retainstack cell } { callstack-save cell } -{ context-objects cell[10] } { datastack-region void* } { retainstack-region void* } -{ callstack-region void* } ; +{ callstack-region void* } +{ context-objects cell[10] } ; : context-field-offset ( field -- offset ) context offset-of ; inline diff --git a/vm/contexts.hpp b/vm/contexts.hpp index 85338ca91d..582fab173f 100644 --- a/vm/contexts.hpp +++ b/vm/contexts.hpp @@ -28,14 +28,14 @@ struct context { /* C callstack pointer */ cell callstack_save; - /* context-specific special objects, accessed by context-object and - set-context-object primitives */ - cell context_objects[context_object_count]; - segment *datastack_seg; segment *retainstack_seg; segment *callstack_seg; + /* context-specific special objects, accessed by context-object and + set-context-object primitives */ + cell context_objects[context_object_count]; + context(cell datastack_size, cell retainstack_size, cell callstack_size); ~context(); From f86c9439e9bf29fb9d3109a2acd7b835d5f9e3b8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 2 Apr 2010 15:58:47 -0400 Subject: [PATCH 572/713] windows.errors: redundant USING: list entry --- basis/windows/errors/errors.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/windows/errors/errors.factor b/basis/windows/errors/errors.factor index a22b6ec007..a3dbaf40ff 100755 --- a/basis/windows/errors/errors.factor +++ b/basis/windows/errors/errors.factor @@ -1,7 +1,7 @@ USING: alien.data kernel locals math math.bitwise windows.kernel32 sequences byte-arrays unicode.categories io.encodings.string io.encodings.utf16n alien.strings -arrays literals windows.types specialized-arrays literals ; +arrays literals windows.types specialized-arrays ; SPECIALIZED-ARRAY: TCHAR IN: windows.errors From 2240520e2db6e2d26800e9e7645241c09316f8d6 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 2 Apr 2010 23:16:53 -0700 Subject: [PATCH 573/713] update some more doc examples using old abi strings --- basis/alien/libraries/libraries-docs.factor | 6 +++--- core/alien/alien-docs.factor | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/basis/alien/libraries/libraries-docs.factor b/basis/alien/libraries/libraries-docs.factor index d2e510e0e9..8676ac8c58 100644 --- a/basis/alien/libraries/libraries-docs.factor +++ b/basis/alien/libraries/libraries-docs.factor @@ -43,7 +43,7 @@ HELP: load-library { $description "Loads a library by logical name and outputs a handle which may be passed to " { $link dlsym } " or " { $link dlclose } ". If the library is already loaded, returns the existing handle." } ; HELP: add-library -{ $values { "name" string } { "path" string } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } } +{ $values { "name" string } { "path" string } { "abi" "one of " { $link cdecl } " or " { $link stdcall } } } { $description "Defines a new logical library named " { $snippet "name" } " located in the file system at " { $snippet "path" } " and the specified ABI. The logical library name can then be used by a " { $link POSTPONE: LIBRARY: } " form to specify the logical library for subsequent " { $link POSTPONE: FUNCTION: } " definitions." } { $notes "Because the entire source file is parsed before top-level forms are executed, " { $link add-library } " must be placed within a " { $snippet "<< ... >>" } " parse-time evaluation block." $nl @@ -53,8 +53,8 @@ $nl { $examples "Here is a typical usage of " { $link add-library } ":" { $code "<< \"freetype\" {" - " { [ os macosx? ] [ \"libfreetype.6.dylib\" \"cdecl\" add-library ] }" - " { [ os windows? ] [ \"freetype6.dll\" \"cdecl\" add-library ] }" + " { [ os macosx? ] [ \"libfreetype.6.dylib\" cdecl add-library ] }" + " { [ os windows? ] [ \"freetype6.dll\" cdecl add-library ] }" " [ drop ]" "} cond >>" } diff --git a/core/alien/alien-docs.factor b/core/alien/alien-docs.factor index 34ff33bff9..6c64b2fac3 100644 --- a/core/alien/alien-docs.factor +++ b/core/alien/alien-docs.factor @@ -130,7 +130,7 @@ HELP: alien-callback "A simple example, showing a C function which returns the difference of two given integers:" { $code ": difference-callback ( -- alien )" - " int { int int } \"cdecl\" [ - ] alien-callback ;" + " int { int int } cdecl [ - ] alien-callback ;" } } { $errors "Throws an " { $link alien-callback-error } " if the word calling " { $link alien-callback } " is not compiled." } ; From 39f066726c21a69f71dfdd90b8b8c558e7f7656a Mon Sep 17 00:00:00 2001 From: William Schlieper Date: Sat, 3 Apr 2010 08:48:15 -0400 Subject: [PATCH 574/713] Added mouse support to game.input on Linux --- basis/game/input/x11/x11.factor | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/basis/game/input/x11/x11.factor b/basis/game/input/x11/x11.factor index 4e6f610531..1e103ad0fa 100644 --- a/basis/game/input/x11/x11.factor +++ b/basis/game/input/x11/x11.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2010 Erik Charlebois, William Schlieper. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays kernel game.input namespaces +USING: accessors alien.c-types arrays kernel game.input namespaces math classes bit-arrays system sequences vectors x11 x11.xlib ; IN: game.input.x11 @@ -84,9 +84,24 @@ M: linux x>hid-bit-order M: x11-game-input-backend read-keyboard dpy get 256 [ XQueryKeymap drop ] keep x-bits>hid-bits keyboard-state boa ; + +: query-pointer ( -- x y buttons ) + dpy get dup XDefaultRootWindow + 0 0 0 0 0 0 0 + [ XQueryPointer drop ] 3keep + [ *int ] tri@ ; + +SYMBOL: mouse-reset? M: x11-game-input-backend read-mouse - 0 0 0 0 2 mouse-state boa ; + mouse-reset? get [ reset-mouse ] unless + query-pointer + mouse-state new + swap 256 /i >>buttons + swap 400 - >>dy + swap 400 - >>dx + 0 >>scroll-dy 0 >>scroll-dx ; M: x11-game-input-backend reset-mouse - ; + dpy get dup XDefaultRootWindow dup + 0 0 0 0 400 400 XWarpPointer drop t mouse-reset? set-global ; From be024c228c15b2cceb64314e2637ca1a4d0b2230 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 3 Apr 2010 19:10:21 -0400 Subject: [PATCH 575/713] continuations: faster with-datastack --- core/continuations/continuations-docs.factor | 2 +- core/continuations/continuations.factor | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core/continuations/continuations-docs.factor b/core/continuations/continuations-docs.factor index 3710680269..8775e599a6 100644 --- a/core/continuations/continuations-docs.factor +++ b/core/continuations/continuations-docs.factor @@ -235,7 +235,7 @@ HELP: save-error $low-level-note ; HELP: with-datastack -{ $values { "stack" sequence } { "quot" quotation } { "newstack" sequence } } +{ $values { "stack" sequence } { "quot" quotation } { "new-stack" sequence } } { $description "Executes the quotation with the given data stack contents, and outputs the new data stack after the word returns. The input sequence is not modified; a new sequence is produced. Does not affect the data stack in surrounding code, other than consuming the two inputs and pushing the output." } { $examples { $example "USING: continuations math prettyprint ;" "{ 3 7 } [ + ] with-datastack ." "{ 10 }" } diff --git a/core/continuations/continuations.factor b/core/continuations/continuations.factor index cfceb1f715..196a12d0d2 100644 --- a/core/continuations/continuations.factor +++ b/core/continuations/continuations.factor @@ -1,10 +1,17 @@ -! Copyright (C) 2003, 2009 Slava Pestov. +! Copyright (C) 2003, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays vectors kernel kernel.private sequences namespaces make math splitting sorting quotations assocs combinators combinators.private accessors words ; IN: continuations +: with-datastack ( stack quot -- new-stack ) + [ + [ [ datastack ] dip swap [ { } like set-datastack ] dip ] dip + swap [ call datastack ] dip + swap [ set-datastack ] dip + ] (( stack quot -- new-stack )) call-effect-unsafe ; + SYMBOL: error SYMBOL: error-continuation SYMBOL: error-thread @@ -90,14 +97,6 @@ SYMBOL: return-continuation : return ( -- * ) return-continuation get continue ; -: with-datastack ( stack quot -- newstack ) - [ - [ - [ [ { } like set-datastack ] dip call datastack ] dip - continue-with - ] (( stack quot continuation -- * )) call-effect-unsafe - ] callcc1 2nip ; - GENERIC: compute-restarts ( error -- seq ) Date: Sat, 3 Apr 2010 20:24:33 -0400 Subject: [PATCH 576/713] Get green threads working on Windows - store stack base and limit in TIB - set up a frame-based structured exception handler in each context's callstack - boot.x86.32.image has now been replaced by boot.winnt-x86.32.image and boot.unix-x86.32.image --- Nmakefile | 2 +- basis/bootstrap/image/image.factor | 9 ++-- basis/compiler/constants/constants.factor | 5 +++ basis/cpu/x86/32/bootstrap.factor | 25 ++++++++--- basis/cpu/x86/32/unix/bootstrap.factor | 14 ++++++ basis/cpu/x86/32/winnt/bootstrap.factor | 54 +++++++++++++++++++++++ basis/cpu/x86/64/bootstrap.factor | 5 +++ basis/cpu/x86/bootstrap.factor | 8 +++- basis/threads/threads-tests.factor | 3 ++ core/bootstrap/primitives.factor | 3 +- vm/callbacks.cpp | 20 +++++++-- vm/code_blocks.cpp | 5 +++ vm/cpu-x86.hpp | 2 +- vm/instruction_operands.hpp | 5 +++ vm/os-windows-nt.cpp | 25 +++-------- vm/os-windows-nt.hpp | 8 +--- vm/vm.hpp | 2 +- 17 files changed, 151 insertions(+), 44 deletions(-) create mode 100644 basis/cpu/x86/32/unix/bootstrap.factor create mode 100644 basis/cpu/x86/32/winnt/bootstrap.factor mode change 100644 => 100755 vm/callbacks.cpp mode change 100644 => 100755 vm/cpu-x86.hpp diff --git a/Nmakefile b/Nmakefile index 0d815b6161..9df7a6a1ee 100755 --- a/Nmakefile +++ b/Nmakefile @@ -2,7 +2,7 @@ LINK_FLAGS = /nologo /DEBUG shell32.lib CL_FLAGS = /nologo /Zi /O2 /W3 /DFACTOR_DEBUG !ELSE -LINK_FLAGS = /nologo shell32.lib +LINK_FLAGS = /nologo /safeseh:no shell32.lib CL_FLAGS = /nologo /O2 /W3 !ENDIF diff --git a/basis/bootstrap/image/image.factor b/basis/bootstrap/image/image.factor index 141a77d2b2..62240f73ce 100644 --- a/basis/bootstrap/image/image.factor +++ b/basis/bootstrap/image/image.factor @@ -15,10 +15,11 @@ generalizations ; IN: bootstrap.image : arch ( os cpu -- arch ) + [ dup "winnt" = "winnt" "unix" ? ] dip { - { "ppc" [ "-ppc" append ] } - { "x86.64" [ "winnt" = "winnt" "unix" ? "-x86.64" append ] } - [ nip ] + { "ppc" [ drop "-ppc" append ] } + { "x86.32" [ nip "-x86.32" append ] } + { "x86.64" [ nip "-x86.64" append ] } } case ; : my-arch ( -- arch ) @@ -32,7 +33,7 @@ IN: bootstrap.image : images ( -- seq ) { - "x86.32" + "winnt-x86.32" "unix-x86.32" "winnt-x86.64" "unix-x86.64" "linux-ppc" "macosx-ppc" } ; diff --git a/basis/compiler/constants/constants.factor b/basis/compiler/constants/constants.factor index 9769b72801..ac0fcff0ff 100644 --- a/basis/compiler/constants/constants.factor +++ b/basis/compiler/constants/constants.factor @@ -34,6 +34,10 @@ CONSTANT: deck-bits 18 : context-datastack-offset ( -- n ) 2 bootstrap-cells ; inline : context-retainstack-offset ( -- n ) 3 bootstrap-cells ; inline : context-callstack-save-offset ( -- n ) 4 bootstrap-cells ; inline +: context-callstack-seg-offset ( -- n ) 7 bootstrap-cells ; inline +: segment-start-offset ( -- n ) 0 bootstrap-cells ; inline +: segment-size-offset ( -- n ) 1 bootstrap-cells ; inline +: segment-end-offset ( -- n ) 2 bootstrap-cells ; inline ! Relocation classes CONSTANT: rc-absolute-cell 0 @@ -61,6 +65,7 @@ CONSTANT: rt-megamorphic-cache-hits 8 CONSTANT: rt-vm 9 CONSTANT: rt-cards-offset 10 CONSTANT: rt-decks-offset 11 +CONSTANT: rt-exception-handler 12 : rc-absolute? ( n -- ? ) ${ rc-absolute-ppc-2/2 rc-absolute-cell rc-absolute } member? ; diff --git a/basis/cpu/x86/32/bootstrap.factor b/basis/cpu/x86/32/bootstrap.factor index 293d99fe93..9b1a1de23d 100644 --- a/basis/cpu/x86/32/bootstrap.factor +++ b/basis/cpu/x86/32/bootstrap.factor @@ -108,6 +108,14 @@ IN: bootstrap.x86 \ (call) define-combinator-primitive [ + ! Load ds and rs registers + jit-load-vm + jit-load-context + jit-restore-context + + ! Windows-specific setup + ctx-reg jit-update-seh + ! Clear x87 stack, but preserve rounding mode and exception flags ESP 2 SUB ESP [] FNSTCW @@ -122,11 +130,6 @@ IN: bootstrap.x86 ! Unwind stack frames ESP EDX MOV - ! Load ds and rs registers - jit-load-vm - jit-load-context - jit-restore-context - jit-jump-quot ] \ unwind-native-frames define-sub-primitive @@ -253,6 +256,9 @@ IN: bootstrap.x86 ! Load new stack pointer ESP ctx-reg context-callstack-top-offset [+] MOV + ! Windows-specific setup + ctx-reg jit-update-tib + ! Load new ds, rs registers jit-restore-context ; @@ -266,6 +272,9 @@ IN: bootstrap.x86 ! Make the new context active EAX jit-switch-context + ! Windows-specific setup + ctx-reg jit-update-seh + ! Twiddle stack for return ESP 4 ADD @@ -293,6 +302,12 @@ IN: bootstrap.x86 ds-reg 4 ADD ds-reg [] EAX MOV + ! Windows-specific setup + jit-install-seh + + ! Push a fake return address + 0 PUSH + ! Jump to initial quotation EAX EBX [] MOV jit-jump-quot ; diff --git a/basis/cpu/x86/32/unix/bootstrap.factor b/basis/cpu/x86/32/unix/bootstrap.factor new file mode 100644 index 0000000000..1e3bee4961 --- /dev/null +++ b/basis/cpu/x86/32/unix/bootstrap.factor @@ -0,0 +1,14 @@ +! Copyright (C) 2010 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: cpu.x86.assembler cpu.x86.assembler.operands kernel +layouts parser sequences ; +IN: bootstrap.x86 + +: jit-save-tib ( -- ) ; +: jit-restore-tib ( -- ) ; +: jit-update-tib ( ctx-reg -- ) drop ; +: jit-install-seh ( -- ) ESP bootstrap-cell ADD ; +: jit-update-seh ( ctx-reg -- ) drop ; + +<< "vocab:cpu/x86/32/bootstrap.factor" parse-file suffix! >> +call diff --git a/basis/cpu/x86/32/winnt/bootstrap.factor b/basis/cpu/x86/32/winnt/bootstrap.factor new file mode 100644 index 0000000000..b8ee1dacaf --- /dev/null +++ b/basis/cpu/x86/32/winnt/bootstrap.factor @@ -0,0 +1,54 @@ +! Copyright (C) 2010 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: bootstrap.image.private compiler.constants +cpu.x86.assembler cpu.x86.assembler.operands kernel layouts +locals parser sequences ; +IN: bootstrap.x86 + +: tib-exception-list-offset ( -- n ) 0 bootstrap-cells ; +: tib-stack-base-offset ( -- n ) 1 bootstrap-cells ; +: tib-stack-limit-offset ( -- n ) 2 bootstrap-cells ; + +: jit-save-tib ( -- ) + tib-exception-list-offset [] FS PUSH + tib-stack-base-offset [] FS PUSH + tib-stack-limit-offset [] FS PUSH ; + +: jit-restore-tib ( -- ) + tib-stack-limit-offset [] FS POP + tib-stack-base-offset [] FS POP + tib-exception-list-offset [] FS POP ; + +:: jit-update-tib ( ctx-reg -- ) + ! There's a redundant load here because we're not allowed + ! to clobber ctx-reg. Clobbers EAX. + ! Save callstack base in TIB + EAX ctx-reg context-callstack-seg-offset [+] MOV + EAX EAX segment-end-offset [+] MOV + tib-stack-base-offset [] EAX FS MOV + ! Save callstack limit in TIB + EAX ctx-reg context-callstack-seg-offset [+] MOV + EAX EAX segment-start-offset [+] MOV + tib-stack-limit-offset [] EAX FS MOV ; + +: jit-install-seh ( -- ) + ! Create a new exception record and store it in the TIB. + ! Align stack + ESP 3 bootstrap-cells ADD + ! Exception handler address filled in by callback.cpp + 0 PUSH rc-absolute-cell rt-exception-handler jit-rel + ! No next handler + 0 PUSH + ! This is the new exception handler + tib-exception-list-offset [] ESP FS MOV ; + +:: jit-update-seh ( ctx-reg -- ) + ! Load exception record structure that jit-install-seh + ! created from the bottom of the callstack. Clobbers EAX. + EAX ctx-reg context-callstack-bottom-offset [+] MOV + EAX bootstrap-cell ADD + ! Store exception record in TIB. + tib-exception-list-offset [] EAX FS MOV ; + +<< "vocab:cpu/x86/32/bootstrap.factor" parse-file suffix! >> +call diff --git a/basis/cpu/x86/64/bootstrap.factor b/basis/cpu/x86/64/bootstrap.factor index 6c0d50f1b7..c7f9901d33 100644 --- a/basis/cpu/x86/64/bootstrap.factor +++ b/basis/cpu/x86/64/bootstrap.factor @@ -26,6 +26,11 @@ IN: bootstrap.x86 : fixnum>slot@ ( -- ) temp0 1 SAR ; : rex-length ( -- n ) 1 ; +: jit-save-tib ( -- ) ; +: jit-restore-tib ( -- ) ; +: jit-update-tib ( ctx-reg -- ) drop ; +: jit-install-seh ( -- ) ESP bootstrap-cell ADD ; + : jit-call ( name -- ) RAX 0 MOV rc-absolute-cell jit-dlsym RAX CALL ; diff --git a/basis/cpu/x86/bootstrap.factor b/basis/cpu/x86/bootstrap.factor index 961f0c9977..80b56f9f91 100644 --- a/basis/cpu/x86/bootstrap.factor +++ b/basis/cpu/x86/bootstrap.factor @@ -20,6 +20,8 @@ big-endian off ! Save all non-volatile registers nv-regs [ PUSH ] each + jit-save-tib + ! Load VM into vm-reg vm-reg 0 MOV rc-absolute-cell rt-vm jit-rel @@ -36,7 +38,9 @@ big-endian off ! Load Factor callstack pointer stack-reg nv-reg context-callstack-bottom-offset [+] MOV - stack-reg bootstrap-cell ADD + + nv-reg jit-update-tib + jit-install-seh ! Call into Factor code nv-reg 0 MOV rc-absolute-cell rt-entry-point jit-rel @@ -55,6 +59,8 @@ big-endian off vm-reg vm-context-offset [+] nv-reg MOV ! Restore non-volatile registers + jit-restore-tib + nv-regs [ POP ] each frame-reg POP diff --git a/basis/threads/threads-tests.factor b/basis/threads/threads-tests.factor index 742ecaa1f7..01578d4e64 100644 --- a/basis/threads/threads-tests.factor +++ b/basis/threads/threads-tests.factor @@ -56,3 +56,6 @@ yield [ "x" tget "p" get fulfill ] in-thread [ f ] [ "p" get ?promise ] unit-test + +! Test system traps inside threads +[ ] [ [ dup ] in-thread yield ] unit-test diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 8a412b8a14..87963848bf 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -18,7 +18,8 @@ H{ } clone sub-primitives set "vocab:bootstrap/syntax.factor" parse-file architecture get { - { "x86.32" "x86/32" } + { "winnt-x86.32" "x86/32/winnt" } + { "unix-x86.32" "x86/32/unix" } { "winnt-x86.64" "x86/64/winnt" } { "unix-x86.64" "x86/64/unix" } { "linux-ppc" "ppc/linux" } diff --git a/vm/callbacks.cpp b/vm/callbacks.cpp old mode 100644 new mode 100755 index 6c8165f5c4..fbf36c7cea --- a/vm/callbacks.cpp +++ b/vm/callbacks.cpp @@ -38,7 +38,12 @@ void callback_heap::store_callback_operand(code_block *stub, cell index, cell va void callback_heap::update(code_block *stub) { - store_callback_operand(stub,1,(cell)callback_entry_point(stub)); +#ifdef WIN32 + cell index = 2; +#else + cell index = 1; +#endif + store_callback_operand(stub,index,(cell)callback_entry_point(stub)); stub->flush_icache(); } @@ -64,12 +69,21 @@ code_block *callback_heap::add(cell owner, cell return_rewind) /* Store VM pointer */ store_callback_operand(stub,0,(cell)parent); - store_callback_operand(stub,2,(cell)parent); + +#ifdef WIN32 + store_callback_operand(stub,1,(cell)&exception_handler); + cell index = 1; +#else + cell index = 0; +#endif + + /* Store VM pointer */ + store_callback_operand(stub,index + 2,(cell)parent); /* On x86, the RET instruction takes an argument which depends on the callback's calling convention */ #if defined(FACTOR_X86) || defined(FACTOR_AMD64) - store_callback_operand(stub,3,return_rewind); + store_callback_operand(stub,index + 3,return_rewind); #endif update(stub); diff --git a/vm/code_blocks.cpp b/vm/code_blocks.cpp index 894e49846d..64b218f377 100755 --- a/vm/code_blocks.cpp +++ b/vm/code_blocks.cpp @@ -225,6 +225,11 @@ void factor_vm::store_external_address(instruction_operand op) case RT_DECKS_OFFSET: op.store_value(decks_offset); break; +#ifdef WINDOWS + case RT_EXCEPTION_HANDLER: + op.store_value(&factor::exception_handler); + break; +#endif default: critical_error("Bad rel type",op.rel_type()); break; diff --git a/vm/cpu-x86.hpp b/vm/cpu-x86.hpp old mode 100644 new mode 100755 index bfdcd8afb2..89d7fb792a --- a/vm/cpu-x86.hpp +++ b/vm/cpu-x86.hpp @@ -5,7 +5,7 @@ namespace factor #define FRAME_RETURN_ADDRESS(frame,vm) *(void **)(vm->frame_successor(frame) + 1) -#define CALLSTACK_BOTTOM(ctx) (stack_frame *)(ctx->callstack_seg->end - sizeof(cell)) +#define CALLSTACK_BOTTOM(ctx) (stack_frame *)(ctx->callstack_seg->end - sizeof(cell) * 5) inline static void flush_icache(cell start, cell len) {} diff --git a/vm/instruction_operands.hpp b/vm/instruction_operands.hpp index dc8aa9d841..66ffddc24e 100644 --- a/vm/instruction_operands.hpp +++ b/vm/instruction_operands.hpp @@ -26,6 +26,10 @@ enum relocation_type { RT_CARDS_OFFSET, /* value of vm->decks_offset */ RT_DECKS_OFFSET, + /* address of exception_handler -- this exists as a separate relocation + type since its used in a situation where relocation arguments cannot + be passed in, and so RT_DLSYM is inappropriate (Windows only) */ + RT_EXCEPTION_HANDLER, }; enum relocation_class { @@ -105,6 +109,7 @@ struct relocation_entry { case RT_MEGAMORPHIC_CACHE_HITS: case RT_CARDS_OFFSET: case RT_DECKS_OFFSET: + case RT_EXCEPTION_HANDLER: return 0; default: critical_error("Bad rel type",rel_type()); diff --git a/vm/os-windows-nt.cpp b/vm/os-windows-nt.cpp index 2d5881252a..4f90d7f641 100755 --- a/vm/os-windows-nt.cpp +++ b/vm/os-windows-nt.cpp @@ -48,11 +48,8 @@ void sleep_nanos(u64 nsec) Sleep((DWORD)(nsec/1000000)); } -LONG factor_vm::exception_handler(PEXCEPTION_POINTERS pe) +LONG factor_vm::exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch) { - PEXCEPTION_RECORD e = (PEXCEPTION_RECORD)pe->ExceptionRecord; - CONTEXT *c = (CONTEXT*)pe->ContextRecord; - c->ESP = (cell)fix_callstack_top((stack_frame *)c->ESP); signal_callstack_top = (stack_frame *)c->ESP; @@ -81,35 +78,23 @@ LONG factor_vm::exception_handler(PEXCEPTION_POINTERS pe) MXCSR(c) &= 0xffffffc0; c->EIP = (cell)factor::fp_signal_handler_impl; break; - case 0x40010006: - /* If the Widcomm bluetooth stack is installed, the BTTray.exe - process injects code into running programs. For some reason this - results in random SEH exceptions with this (undocumented) - exception code being raised. The workaround seems to be ignoring - this altogether, since that is what happens if SEH is not - enabled. Don't really have any idea what this exception means. */ - break; default: signal_number = e->ExceptionCode; c->EIP = (cell)factor::misc_signal_handler_impl; break; } - return EXCEPTION_CONTINUE_EXECUTION; + + return ExceptionContinueExecution; } -FACTOR_STDCALL(LONG) exception_handler(PEXCEPTION_POINTERS pe) +LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch) { - return current_vm()->exception_handler(pe); + return current_vm()->exception_handler(e,frame,c,dispatch); } void factor_vm::c_to_factor_toplevel(cell quot) { - if(!AddVectoredExceptionHandler(0, (PVECTORED_EXCEPTION_HANDLER)factor::exception_handler)) - fatal_error("AddVectoredExceptionHandler failed", 0); - c_to_factor(quot); - - RemoveVectoredExceptionHandler((void *)factor::exception_handler); } void factor_vm::open_console() diff --git a/vm/os-windows-nt.hpp b/vm/os-windows-nt.hpp index f274d7813f..d84ac97298 100755 --- a/vm/os-windows-nt.hpp +++ b/vm/os-windows-nt.hpp @@ -22,13 +22,7 @@ typedef char symbol_char; #define FACTOR_DLL NULL -#ifdef _MSC_VER - #define FACTOR_STDCALL(return_type) return_type __stdcall -#else - #define FACTOR_STDCALL(return_type) __attribute__((stdcall)) return_type -#endif - -FACTOR_STDCALL(LONG) exception_handler(PEXCEPTION_POINTERS pe); +LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch); // SSE traps raise these exception codes, which are defined in internal NT headers // but not winbase.h diff --git a/vm/vm.hpp b/vm/vm.hpp index cf2f0ca433..36ec3260d6 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -706,7 +706,7 @@ struct factor_vm #if defined(WINNT) void open_console(); - LONG exception_handler(PEXCEPTION_POINTERS pe); + LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch); #endif #else // UNIX From b16d91576cc94dc52edf1ad90d29cc7af8d5132e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 3 Apr 2010 21:11:04 -0400 Subject: [PATCH 577/713] cpu.x86.64: fix typo that caused bootstrap crash --- basis/cpu/x86/64/bootstrap.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/cpu/x86/64/bootstrap.factor b/basis/cpu/x86/64/bootstrap.factor index c7f9901d33..a82c8c17e2 100644 --- a/basis/cpu/x86/64/bootstrap.factor +++ b/basis/cpu/x86/64/bootstrap.factor @@ -29,7 +29,7 @@ IN: bootstrap.x86 : jit-save-tib ( -- ) ; : jit-restore-tib ( -- ) ; : jit-update-tib ( ctx-reg -- ) drop ; -: jit-install-seh ( -- ) ESP bootstrap-cell ADD ; +: jit-install-seh ( -- ) stack-reg bootstrap-cell ADD ; : jit-call ( name -- ) RAX 0 MOV rc-absolute-cell jit-dlsym From 925d2c7e58653998e88aa0036bb619ce336455ec Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sun, 4 Apr 2010 03:23:04 -0700 Subject: [PATCH 578/713] PGM image loading and saving --- basis/images/pgm/authors.txt | 1 + basis/images/pgm/pgm-tests.factor | 7 + basis/images/pgm/pgm.factor | 63 + basis/images/pgm/summary.txt | 1 + extra/images/testing/pgm/radial.ascii.fig | Bin 0 -> 16443 bytes extra/images/testing/pgm/radial.ascii.pgm | 16388 +++++++++++++++++++ extra/images/testing/pgm/radial.binary.fig | Bin 0 -> 16443 bytes extra/images/testing/pgm/radial.binary.pgm | Bin 0 -> 16438 bytes 8 files changed, 16460 insertions(+) create mode 100644 basis/images/pgm/authors.txt create mode 100644 basis/images/pgm/pgm-tests.factor create mode 100644 basis/images/pgm/pgm.factor create mode 100644 basis/images/pgm/summary.txt create mode 100644 extra/images/testing/pgm/radial.ascii.fig create mode 100644 extra/images/testing/pgm/radial.ascii.pgm create mode 100644 extra/images/testing/pgm/radial.binary.fig create mode 100644 extra/images/testing/pgm/radial.binary.pgm diff --git a/basis/images/pgm/authors.txt b/basis/images/pgm/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/basis/images/pgm/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/basis/images/pgm/pgm-tests.factor b/basis/images/pgm/pgm-tests.factor new file mode 100644 index 0000000000..7bfade4717 --- /dev/null +++ b/basis/images/pgm/pgm-tests.factor @@ -0,0 +1,7 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: images.testing ; +IN: images.pgm.tests + +"vocab:images/testing/pgm/radial.binary.pgm" decode-test +"vocab:images/testing/pgm/radial.ascii.pgm" decode-test diff --git a/basis/images/pgm/pgm.factor b/basis/images/pgm/pgm.factor new file mode 100644 index 0000000000..e673565fc9 --- /dev/null +++ b/basis/images/pgm/pgm.factor @@ -0,0 +1,63 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien.c-types ascii combinators images images.loader +io io.encodings.ascii io.encodings.string kernel locals make math +math.parser sequences specialized-arrays ; +SPECIALIZED-ARRAY: ushort +IN: images.pgm + +SINGLETON: pgm-image +"pgm" pgm-image register-image-class + +: read-token ( -- token ) + [ read1 dup blank? + [ t ] + [ dup CHAR: # = + [ "\n" read-until 2drop t ] + [ f ] if + ] if + ] [ drop ] while + " \n\r\t" read-until drop swap + prefix ascii decode ; + +: read-number ( -- number ) + read-token string>number ; + +:: read-numbers ( n lim -- ) + n lim = [ + read-number , + n 1 + lim read-numbers + ] unless ; + +ERROR: INSPECT a ; +:: read-pgm ( -- image ) + read-token :> type + read-number :> width + read-number :> height + read-number :> max + width height * :> npixels + max 256 >= :> wide + + type { + { "P2" [ [ 0 npixels read-numbers ] wide [ ushort-array{ } ] [ B{ } ] if make ] } + { "P5" [ wide [ 2 ] [ 1 ] if npixels * read ] } + } case :> data + + image new + L >>component-order + { width height } >>dim + f >>upside-down? + data >>bitmap + wide [ ushort-components ] [ ubyte-components ] if >>component-type ; + +M: pgm-image stream>image + drop [ read-pgm ] with-input-stream ; + +M: pgm-image image>stream + drop { + [ drop "P5\n" ascii encode write ] + [ dim>> first number>string " " append ascii encode write ] + [ dim>> second number>string "\n" append ascii encode write ] + [ component-type>> ubyte-components = [ "255\n" ] [ "65535\n" ] if ascii encode write ] + [ bitmap>> write ] + } cleave ; diff --git a/basis/images/pgm/summary.txt b/basis/images/pgm/summary.txt new file mode 100644 index 0000000000..f558b7cbb5 --- /dev/null +++ b/basis/images/pgm/summary.txt @@ -0,0 +1 @@ +Image loading for PGM image files. diff --git a/extra/images/testing/pgm/radial.ascii.fig b/extra/images/testing/pgm/radial.ascii.fig new file mode 100644 index 0000000000000000000000000000000000000000..6e52311b94202145e080cf8f4dc7794d43490754 GIT binary patch literal 16443 zcmZ9T2UM45md0muW@ocgQpR*m>?KBHH1-l3Dk?U>E+~p(Lr@Ux6$BA07Bpg4?AS%@ z*n6zlH5wB&F~*p(nVCJizvsT+AIW@C(K&O@ZO?t)``-87;P{xtevx4jy<;Z1A7P1M z6QciP9KYgY#s@@=kB^x#wCC{H-W7XAMMg&r>OCknCTjekhA%bv!yjJyNRTCs$HjUz54YVHf+?mv0sy>&6@f9 z`!{c4U&|IP`K7-$Z{FPBzgg2JO`0@r)Tm*D`k&RSTc>udnl-9d{j~BYA6NXS{D)=B zlqylY==+7=d-v@(3;q4ISN{6vm;dy~mwe*?{>Gbczf<`AqQy#-ERFb&B)y7BM|i#Z z4H`8gU(Eu~evAr%tV!)ulltH2Cnt zGNntFDE7hog-wB1odRb4E3ZlXyM?j7M5)qc%Y9Vg<4TpQd|It~&Dyo=*8QwLmizg= zklngf>(*`BwrTs~YtyDRA6lRUDl~1{#A$#N(4d-WP(dz00bKCz+i&?iAm<~#&|7c6 zhxNrVzAVO9!u3e6RU5}QK)SOWyRo?qg4?xg7Z?~6807l``OpS6oC@gB#IG@N_^cj2 zP!OtoQi&jxD^seZV({)eZ@pn5_^+4$+lhbY-NGLfmG2dKjIUa)M$OuF>Y44%?Iv8J z0|SGDf`fzGcWB>%&;8M!{~;(SupLU^hXC_J6F)zvLG4;Ks#UE*5Gs@}SJo6L^4{B? z0%rXiSYPCWqQy%|e8q~N;Ce~N^9>pi^=5?JEN_dM!R^~4vSY_iojU7RXMT0!>)27c zv=8S0(XK6SaB;u~4H|$01wlBJ0)U|C2Swg{=S}l~tbfA+zeFj|_c9*P%k_=1-J}!n zc0oZ1M|9`TT{?H^(zR>XZuzjo=2CQ_n(u-ssQXyKyJpnknNwQHIS1jDkWOBF9B z1@OSDue|cACtlW4FxW z@>Nh6n)^2e2Mx(axj->MfpS8jQ{eU2UVYtXeM!=;LPZC>+6H=(okS04h3SFB+YHBO zliZ_6k1%~bd-eP*^Yoh_~3|{Bq?hh;s0~ zBHyr)pGhaxgRv~C}K+B2&o_^bRi1h zpluuIz+&Jj;PMa<8WFu`tXI~>9^k`xWS#jQ<3XKlm-Jq}!ezIKj*J{MXi$`W(e~${ zK~iKu|9<`O0+H}E5E4-UHUNg?LA|=Ql?EaL17VTE?-dd0mIe8h6#LqBywJA{Xx$dq zcW|~7^zhyh5q_&9_u;Igo4All2n&LXfygL8 z3djSsYgYTzAW)_x!7u;O$DdTGRvqzjK70?`2jTm!_+G~M?Kc412M;0O7;du1j2Sa_ z?6~}IET6O(ITA<2#o+|=0WRo`3qnJHp+L~uJYYOfgR=l4EL&RD4y;>M;?4Tz0j)qD zxF_ih^|)T1kCEw4xI~X1KYqeQ@0&1T0{LU$PCqlc!Fb zHhubx88h9-&l%IvLn@>YiA2+YAPkF(1%^@p6nYqF*Cqf3{73>tfSUX;=gmt`pFe;8f(7#z z@FP7v9X(KD7Lk}HBqU8rm;ee!jt~lA0x%#CC<%x_OCW#)pusAYtE%8p>fwEYFY!Hk z3i**(ABXtSiaf^S`ROxedcu+X`ND+@Gx%@e!q53oBOMje($Ih?Oiq>p7K6Ch!O?>( z3&KbODL@j6hI9~oO1VkulX^xxV6Q9KQ|#sZIFcUm6HWZoX`XbGosqF<(W1qCOBOHY zZy6cr;At>RQAkOil&BaGf;jTf(vU2)2pA1<5($EsUsnZ>rCxA;@cRpT5C$E1w{+=JX@L$4<`V~^KoE$*3k8Nm!No2KI*SD?2`PzdRafqL z-fs)-D)`DgL%unGLPBB^z?(K>R@$7o>GP3}aLHc2f^Vh16)To6U$%6~lEsS%#e5V< zlMAK@hRy>+;Q>=1th>hoDu?8NnwW3kYoSwz%n$8B=81HLe4LMXLO*r-%vrPN%$vVJ zrY~8F?3Jrlt;$@TxtcFCGjkP6NC#=KAblP{1O-!4l!z7rfzZRC%K>wM5Fp}L^aI*J z`<=UT;)a7gPMp{{6F<=>UdGFI6TT9`Yu2t=yKddOwd?q~W_9MORj9Dcd_WLf3??T_ z0i|K=kSH)n1bT27cL){>84cGq^PBo}=3{=BZc4p=cwgd2$a(=^z?1QxXJGsCl?a#Q z_3Jly-}?2au|_(q#0QHq76OCWX*2PF6c|5t)JT|6G|*QxBo+#6+sc=NochW=XTA^n zgJZ$o=rN>yl8JY|UxaiVzj_VAH*DOPm9@#ftgNh!8#k;+h1HoWS1w<=gdohHH-}7| zn(9CZ6A}SfAOZ)F1D1p4fVy=={LL|6sgL>ceq{6z1%J#q6F+r2p*PG#M|f7& z=FOY8Y}snxmMxn%Z_3)R0WY9|V31)joFxxTN`#0;!9zoognhydf)u2l161@Bh(5$8 z?8kEAnfDEPX>;ev_e+=I`ZY3rlSFUZzJ2=+ecQKh+qQMfmQARze(jpfRVzRNshB<| zO$rzhjaCFW37|no0%Ac@fMbZ{BljVG(`HIZdYuA}{ zgzwn7b7%H0ec9PNckbAM3Y)VCgMzS}L~tRPJ{2MYgT4s#i!cX(0C7MQF6IsWuhu2_}1X6^b7S(~?P+qOfZb9VFX*}Xf54;^-FM}tip z*RNZn7{~+j=D-7~%EEEtK?))u*t-`9pduFw>pmd!11Ne7{6v4?AS1rf9Jq$PSs?#& zArJBE)^FS-$M4L}$=SVU&)$9e_V44{y9X_B13mx;D6o1JC=>?Z0Wc^Cj25BdGRq}n-W+#33p1phb?>}(ReFqNg zM~B@xyLN6zgRBiGpb%tyo(>ng2#g;yinG|!FbGg7_Aq zAjbgbprs%r?B|j{Fc|bfeU!UIKc481hk2$4NF5*!RNY}Gk8uy^!~BsJ{nV*oKYhVM3;w$G&idULpL+=D z$4{O-b?Wq)GpA3VK6UcMiDSo(9Lhbg-xL4?>({M@2P^_WaLQz87zDt=4uJ}Q4gn~j zS#wH$m;5gI$bF0cWKw@N*v}yNtJl5|FXNGp?6c?GcNQ&99zTBcNbbS?d-vdhtx%B{ z0UR)EnrL|Z*wKyz`x5{vF;RdjQIU_hmxH$t?pN}e`HH^G2m34WK8d#t=kMKr@X(QC zCr+M1_!nPX(0Bg)`7h3$J$?G*30!~z3c;358-+nw01`-(13P3EC2-4=gpo82~DCDAq6b}$^dr=we;7GuU&hQkK}Xm#Kw#H6O&-xSu!8+ zWjgO?=Q!&z{@fQAE?&BPB`@#l)x5mCE0-@_#0O_ic?#rYZwCV800_t+2SGpz2QeHZ z3W)RtzyW|O7vWdUukc3?k^9Gq`Nh1>e6YW1%l4f)Am6OV_zRaVBm4UG>o=}nzjp0v z-jz!iQQ)*faA2Pxpd1hjEm|lJAO($tT>!+v4gjrMG;?PUg^vq=Y@E0c>J|FtlKV?# z{>IH)ckJ4|Z-1_wf9Blzi|WPt(&*_Zr-?#2Dm^T0E7qj?cTLx>*kH?*JQ3( zN(#6XBml|)jiuMTHU*9!J$!Kgo?Y1@0ZRcP&`3BD4upbKhU8NqT`|r+)t%kLRCY#D zc#wUb`(b{Vch%~3p80tH_=z)Tu|DtGja#?x-o1DK-u?UczWnko8eGe}LI}u1b3nE^ z01hAk^XI0`m}UXs5Kg@c!0!Se4i*It;WFegKyV;;Q7S(l z`%rkr3>Eni{?uu+W^?W@7Wy}A+PWR^AILp&{N$N)7cR;AJ73=a>cKbPJbd)<;WudT zB??@4W5bHxC52#bNDC_^0s2DS}oiG0-_s{4Vz&R)qE z`9gj=dXNwG=Il9;dl>gy^l#n0_u!jH-#&Tz!w=7%{qXb&3Ve0%&aLZLLBJUyaR1(% zo!dEu)?}J|j{))%KxHsTpw%G8{wn<>e@Lu5e8fJ!>|X=0LURs9XN9uXRxY3E5cL+hIXR_pa#pA5BtAJe;q!Ozig%8zeVJC@UX&vp5(iE zhv{OfQ3`0dx9fBfOe%fd0)PN0`6S>TCtpXPod7QgFov7B`QK{L7To-F`g8Gf{x|!R zo&PiNKk;{m&w;~EenIyGR_#Q!MvpTCp```jb`PoDnx)33k%M*N>YmH+SGy?Gr9CjQvJ zcMml{zWljd##IB3v-soxeEVCqkpJ!YGyhxuar|Jvi$C~VpC$b7v%?Sk=Upp^|6hdv z?+yRAZ(hrTfgwP}-w|;B35@?IsR9xH+$BgAPyzh+lK%%=@u~cie5wzf{wln8?l$^A zbw>Gr!|3nvlc&#qwEX`80(x-&%iA}uUAFu`dg#DjY9J0EN}zu`04@JK{5$z=s6Gw< z#y=eYj{ms!ro(?LR;l>X@w1=W2mZTw`Kkc;mGR%xXV0EJ{ocoaz+e1(oEpf-fAG)Z z&wUk;<$vrDN^oBV$Q8t^zA1mWd5eFo`b(KQ-SNNi@8)egIDT^tfEIw;cR79>|37j3 zfB){C8`tdsqy`iGcW&EE4XpFWlP~@sHA0OT@n3!cB>5e=eEF*H;Unq#Bzfl#)u+mj zO;&x006G8UfSY#yJ$h{C-y_aH4q%~A?kD_IVAR0W;K1MHs{lg2cLh-&DF6JUgz>HN3z*9uTIgLMPp4$k>&ou~Zr*Xj?i{?gUctG>PZN7biJKr6rQQGp;^^^X&; z`p4LR|DK#3+qO`E+8s=HK%+l(A#?+=0-W~{>W`NGl>b4#`cDKLPyM9>cp3$OmEXF0 za`D9h6hL+aT)bix&>iZ(`}e2;zr4fQtNPECKhFKezB>MYSO3`s!1W-Me#m$A?~4Q2 z3V;L(5HA3_{MiYZV+G)GSAOSRrTV7+y=(RF&6}$JRR5lI^{;pOz6ig%Fu>2s4?BKE z|JH)=)&D9021G?$?}N6Z0N|a#nN%P`V9q{DkYj?NtN(A@wDSMf&6^nStN)Lw{LNAQ z?<+sWzP|9|e%-(w{5k~DgW~?--G8k0=1xFe|HMG90Qatcy8j%s3y8b_T*>1KqR+ek z==yO|S5Qknt3ECJD8F_3!hT#p=|sC8l=H1+vk-lsNlQ*UC6)x(FGy-l>F}gr!LskDQbeb@}JX>4v4`I_^b7+6To9YV<1() z|9=0a2BQe^uHSb1zQ7e!_g`+ox_zEKed@UH0uK1??9u&K?w>|0+{=F0zrg9+(!YrV zpx6B>(0*|lzzs|sto#4g7x#a<54!)KKkqdFO!`Sryr>WHcKKN1T2S8MZ})!-zwX~u zKivQQ)O*hFf4J7KSAuf|Nt>5$-6#4Vih$REfCnKWdM{_K19JB48MR>O0df1M@S*>~ z^Xk~pRU#dr2$3*0tPY$uo8$Xh}vJO!E^@@2U_!wQ;5c+LO>QA zIeMHP2>l6w=jxp$}=|={~Gjw#eQ7g+6Y-kdLqZpeDT60R;e70vH4M8Zgv= zIs?2EPzypW5Mj{uzi9i>fl~Vm(I;qt73hC~JqkZ{UtIsoU4DJ&*DHjIZ!i0sSohgG zf?WU4?jQyFe+#Syqa4WZ|3L(~hpqod7tZzna!LEWt_6zo75rsh|IhWnt^eoMzSLgo z|0(@EhsBO^zi5U z->I$xo8N$T{ckjID(s^JPWyYWn$J0|15f{(Hwf2$<`ISlJnwKkg^nI!y%)WJ^b8Hr zJFwcXO&an1q5u?ZfO8A56rc-38$dZQUkbSX|Hdqsh{p%@|7pT|4*)zuU^~Xs|99d^ zJ$0Yedb8G(jvjje;p#2)>FjOJJA6GJ-i?ANLfrF@>wv=n)`C_ctRA#Nu!0`E-hS*2 zV8@Q^o!MxSt&dk2y?<=lNaxwTe`GA2?-OsWKMG&HKymbX=u`Wh_mBMNFLAJY0njy= z9m}Y^U)=kbdx3P7mr4&k!rRo34nbW5%>jCS<>BAGKmh?YLJb2jv0`Aak4^>e0dSMO z{}FgzAXi|#_x?9)I@lxlw0+F`)V+PfRrosd-21+YEpMf78aifHUmrdjNF^ z@Sfm&5YQtS9+;Unn@2$Uaf=B8Z=m-6yOxhP$F=tMigawZ_g_yu(8u}o-9`LryD9hd z^kFj)GM_1!>hAqpZ%`fyy6FRhz$gtL*b6Yv?dwzDWuX_2=$>Vb0CLpTe0FC|>c!E^~^a`g|tR6vy0r&ntkN1B!e8BVn zas~ia+5mvP|1Z<~e+DnV=}cj05XGP;-W{O{2#0-pe6<-EJw0g%Nb?UGzR@F~_X6+U zfTN@UC$TU!@!MYC zJK42^NjycL0T2y9Xz;WJyH@t1HR!G-}H$ML1_MCu?>JMw)qcDp)i6n zcaEe_OO<#p_GZ1_-bMWKK4mv`pN6m)fYJPmn?CY#5Ej&3Ob>y)#fXQ-QVb9SUITp^ zFa#nu;0TSsNHl{ugdNY%BJ$>YXvd&8Y$)?Dkq}?+o`!ul|H2fUCNY_SV)zUP@CpnI z69IdQ2xHi_zi0>#C=J~V3QQmkH2%H*SspTR>;0rHSB z98F-M!L(`K{FgTXhGd()lH=X%6XJh2|AqA$Ky#B9ZUoT4SG7td-~3zsf1iKT7>v!o zF^T~QZ1yiv(|0z4#{3(8m^qV~FTNQwBzr2T)8v(0&&Y!&j~w!u17#GKL0B63X%LQP(p4<>=c6b8|l{&Sxu0Ga=rg5Mc^v+29B zq}>ROf!g?;CUMnoM?A-##JkkD`9G~3Fo9VY65du9D}%;L1heAqh~e&+KyA-Qjg)Y8dVwp`$&W5 zmGfud^cXA}>evMu;5}LjxDiN7GO;0ZuM7e*cq$$E7ywP4%uh3%8B|74u^s6Q-VKR{ z^S$v)6R(*An*%5KHvh>4u7;nPKK4c+nSW*c*2drz0-Jvw5c&K0S9D%*q>lmE z1ZGba^>G@(^-bVv_>-p=^4?hw?Nf9425_|s!Tc+;=lKx;gKh{?9`WSH1iBAP2R3~^gb{2FLF0vy z8URO)F`EA7WAs{+&zeE^=D&T$vlY{YT@Z$kVSP`$h)=`6`FAH?*t6kh z#Ipv&@&^ilLECe} z1F;?4u?ON-AP}$lf36!k^f+`K_Lx2|QOsMv_=qWJM)28pYak+|9D<62s0hskXu!@3 zTPF$wUO)#%@rP;wLcg&Z(a6>k2B_=b7wO?WIc{zCzC&!yWCg~p zpWp%8yVCxLEnu|J&K1MJow^7G1c40jae?@9qSzt{kA3TXd@6%2pY0NU983uI_8AQiL=;PzjT zg(vu4tiMRM_Fp2{0(!B5!`MBXYvMI^t+8(#d@o;aepZvV-M!193e$WoEDGq?XFD6j|QTY%CQlv{v8wh0Gy#yEm~pn%7ehxVVC z`p;j!5%h~{|EUnWe=J~W_piJIA*+Ad1!&x)X>(TZgaR_b`9RBOVeFo<{?!LKX!}b` zVA=sgbU2pd_)xck){&fdn?DwM_EFvbmtt?3#|j>6n6DSY1MEJscUsOn-l*&;@>Q! z)l+T2p@8jxY4y{sA8PHCbz59utB+c`)E*j8zzwE__W#(7;>D-T|1fD-~) z!Q@!b=4t0Hd|ed}q;~c8KWzz>6;yM)Y$x!zUdBVY+W*udwCzE^*#ETkTUIc^Krzy= zEbF)0eAeo*+kym#L_tUdifjW0Y5lcB2ZW&pzxb{FSM8okHh%ZEPql|^(hKar+WKh$ z>tFe+TR)ZpN<-VdrXFznznn+5|EnlS1CXHIW33$r+ZL`A;p6X;9K`A^vbA(++qX^F zH*>Dn2D15H$RqDry?k5FX9fE|3o1~wxS>!Ws9aUc-}&3uXkaR^|4by%K_7YqNi2dT zndM_-%kM2%Mc4kbcEIbheazyi?LX)5ptJYr#J}wAf0Kstzz0$Q5ZL}V8)>$IjSm{K z`L4xxynq{Q30tnv9=60{G-jJ@vz%>5q-*=y+y6%T#}#b#w?uIk(AoP${NMia=a>KV zk`(xhHo%PuwF=5g7JI;2g?*ucmcVWQT{^H0-O{)Cj!^g6{yR(f?7utVvRwsTIa;~^ literal 0 HcmV?d00001 diff --git a/extra/images/testing/pgm/radial.ascii.pgm b/extra/images/testing/pgm/radial.ascii.pgm new file mode 100644 index 0000000000..1a7a6a832d --- /dev/null +++ b/extra/images/testing/pgm/radial.ascii.pgm @@ -0,0 +1,16388 @@ +P2 +# CREATOR: GIMP PNM Filter Version 1.1 +128 128 +255 +0 +2 +4 +6 +8 +10 +12 +13 +16 +17 +19 +21 +22 +24 +26 +28 +30 +32 +33 +35 +36 +38 +40 +41 +42 +44 +45 +46 +48 +49 +51 +52 +54 +55 +56 +57 +58 +59 +60 +61 +63 +63 +65 +65 +66 +67 +67 +68 +69 +70 +71 +71 +72 +72 +72 +73 +74 +74 +74 +74 +74 +74 +75 +74 +75 +75 +74 +75 +74 +74 +74 +74 +73 +73 +73 +72 +72 +71 +70 +69 +69 +69 +67 +66 +66 +65 +64 +63 +62 +61 +60 +59 +58 +57 +56 +55 +54 +52 +51 +49 +48 +46 +45 +43 +42 +41 +39 +38 +36 +34 +33 +31 +29 +27 +26 +25 +23 +21 +19 +18 +16 +14 +12 +10 +8 +6 +4 +2 +2 +4 +6 +8 +10 +12 +13 +16 +18 +20 +21 +23 +24 +27 +29 +31 +32 +34 +35 +37 +38 +40 +41 +43 +45 +46 +48 +49 +50 +52 +54 +55 +56 +57 +59 +60 +61 +61 +63 +64 +66 +66 +67 +68 +69 +69 +70 +71 +72 +73 +73 +74 +74 +75 +76 +76 +76 +77 +76 +77 +77 +78 +77 +77 +77 +77 +77 +77 +78 +77 +77 +77 +76 +76 +75 +75 +74 +74 +74 +73 +72 +71 +71 +70 +68 +68 +67 +67 +65 +64 +63 +62 +60 +59 +59 +57 +56 +54 +54 +52 +51 +49 +47 +46 +45 +43 +41 +41 +38 +37 +35 +34 +32 +30 +29 +27 +25 +23 +21 +19 +18 +15 +14 +12 +10 +8 +6 +4 +4 +6 +8 +10 +12 +14 +16 +18 +20 +21 +23 +25 +27 +28 +30 +32 +34 +36 +37 +39 +40 +43 +44 +46 +47 +49 +50 +51 +53 +54 +56 +58 +58 +60 +60 +62 +63 +65 +66 +67 +68 +68 +70 +71 +72 +73 +73 +74 +74 +75 +76 +76 +78 +77 +78 +78 +79 +80 +79 +80 +80 +80 +80 +80 +80 +80 +80 +80 +80 +80 +79 +79 +78 +78 +78 +78 +77 +77 +76 +75 +75 +74 +73 +72 +71 +70 +70 +69 +67 +67 +65 +64 +63 +62 +61 +60 +59 +57 +56 +54 +53 +52 +51 +49 +47 +46 +44 +42 +41 +39 +38 +35 +34 +32 +31 +29 +27 +25 +23 +22 +19 +18 +16 +14 +12 +10 +8 +6 +6 +8 +10 +12 +14 +16 +18 +19 +22 +23 +26 +27 +29 +31 +33 +35 +37 +38 +39 +41 +43 +45 +47 +48 +49 +51 +53 +54 +56 +57 +58 +60 +61 +63 +64 +65 +66 +67 +69 +69 +70 +71 +72 +73 +74 +75 +76 +77 +77 +78 +79 +79 +80 +80 +81 +81 +81 +82 +82 +83 +82 +83 +83 +83 +83 +83 +83 +83 +83 +83 +82 +82 +82 +82 +80 +80 +80 +79 +79 +78 +77 +76 +75 +75 +74 +73 +73 +72 +71 +69 +68 +67 +66 +65 +64 +62 +61 +59 +59 +57 +55 +54 +52 +51 +50 +48 +47 +45 +43 +42 +40 +38 +36 +35 +33 +31 +29 +27 +25 +24 +22 +20 +18 +16 +14 +12 +10 +7 +8 +9 +12 +14 +16 +18 +19 +22 +24 +25 +27 +30 +31 +34 +35 +37 +38 +41 +42 +44 +45 +47 +49 +50 +52 +53 +55 +56 +58 +59 +61 +62 +63 +65 +66 +67 +69 +70 +71 +72 +73 +73 +75 +76 +77 +77 +78 +80 +80 +81 +81 +82 +82 +84 +83 +84 +84 +84 +85 +86 +85 +86 +86 +86 +86 +85 +86 +86 +86 +86 +85 +85 +84 +84 +84 +83 +83 +82 +81 +80 +80 +80 +78 +78 +77 +76 +75 +74 +73 +72 +71 +69 +68 +68 +66 +65 +64 +62 +61 +59 +58 +57 +55 +53 +52 +50 +49 +47 +46 +44 +42 +40 +39 +36 +35 +33 +31 +29 +28 +26 +23 +22 +20 +18 +16 +14 +12 +10 +10 +12 +14 +16 +18 +20 +22 +23 +26 +28 +30 +31 +33 +36 +37 +38 +41 +42 +45 +45 +48 +50 +51 +53 +55 +56 +58 +59 +60 +62 +63 +64 +66 +68 +69 +69 +71 +73 +74 +74 +76 +77 +77 +78 +79 +80 +82 +82 +82 +84 +85 +85 +85 +86 +86 +87 +87 +88 +88 +89 +88 +88 +89 +88 +89 +89 +88 +89 +88 +88 +88 +88 +87 +87 +86 +86 +86 +85 +85 +84 +82 +82 +82 +81 +80 +79 +78 +77 +75 +74 +73 +72 +71 +70 +68 +67 +66 +64 +64 +62 +60 +59 +57 +56 +54 +53 +51 +49 +48 +46 +44 +42 +40 +39 +37 +35 +34 +31 +30 +28 +26 +24 +21 +20 +18 +16 +14 +12 +12 +14 +16 +18 +20 +22 +24 +26 +28 +30 +32 +34 +36 +38 +39 +41 +43 +45 +47 +48 +50 +52 +53 +55 +57 +58 +59 +61 +63 +64 +65 +67 +69 +70 +71 +73 +74 +74 +76 +77 +78 +79 +80 +81 +83 +83 +84 +85 +85 +86 +87 +87 +89 +89 +90 +89 +90 +90 +91 +91 +91 +92 +92 +92 +92 +92 +91 +92 +92 +91 +91 +91 +90 +89 +89 +89 +88 +87 +87 +86 +86 +85 +84 +83 +82 +81 +80 +79 +78 +77 +76 +75 +74 +72 +71 +69 +68 +67 +66 +64 +63 +61 +59 +58 +56 +55 +53 +52 +50 +49 +46 +45 +43 +41 +39 +37 +36 +33 +32 +30 +28 +26 +24 +22 +20 +18 +15 +14 +14 +15 +18 +20 +22 +24 +26 +28 +30 +31 +33 +36 +37 +40 +42 +43 +45 +47 +48 +50 +52 +54 +56 +57 +59 +61 +62 +64 +65 +67 +68 +70 +71 +72 +74 +75 +76 +77 +78 +80 +81 +82 +83 +84 +85 +86 +87 +87 +88 +89 +89 +90 +90 +91 +92 +92 +93 +93 +94 +94 +94 +95 +94 +94 +94 +94 +94 +94 +94 +94 +94 +94 +93 +92 +92 +92 +90 +91 +90 +89 +88 +87 +86 +86 +85 +84 +83 +82 +81 +80 +78 +77 +76 +75 +73 +72 +70 +69 +68 +67 +65 +63 +62 +61 +59 +57 +56 +54 +52 +50 +49 +47 +45 +43 +41 +40 +38 +35 +34 +32 +30 +28 +26 +24 +22 +20 +17 +16 +15 +17 +20 +22 +24 +26 +28 +30 +32 +34 +35 +38 +40 +41 +44 +45 +48 +49 +51 +53 +54 +56 +58 +60 +62 +63 +65 +66 +68 +69 +70 +72 +73 +74 +76 +77 +79 +80 +81 +82 +84 +84 +85 +87 +87 +89 +89 +90 +91 +91 +92 +93 +94 +94 +94 +95 +96 +96 +96 +97 +97 +97 +97 +97 +98 +98 +98 +97 +97 +96 +96 +96 +95 +95 +95 +95 +94 +93 +92 +92 +91 +90 +89 +88 +88 +87 +86 +84 +83 +82 +81 +80 +79 +77 +76 +74 +73 +72 +71 +69 +68 +66 +64 +63 +61 +59 +58 +57 +54 +53 +51 +49 +48 +45 +43 +42 +39 +37 +35 +34 +31 +30 +28 +26 +24 +21 +20 +18 +17 +20 +22 +23 +26 +28 +30 +31 +34 +36 +38 +40 +42 +44 +46 +48 +49 +51 +53 +55 +57 +59 +60 +62 +63 +65 +66 +68 +70 +72 +73 +74 +76 +78 +78 +79 +81 +83 +83 +84 +86 +87 +89 +89 +90 +91 +92 +92 +94 +95 +95 +96 +96 +97 +98 +98 +99 +98 +99 +100 +100 +99 +100 +100 +100 +100 +100 +100 +100 +99 +99 +98 +99 +98 +98 +97 +96 +96 +95 +95 +93 +93 +92 +91 +90 +89 +89 +87 +86 +85 +84 +83 +81 +79 +78 +77 +75 +74 +73 +71 +70 +69 +67 +65 +64 +62 +60 +59 +57 +55 +53 +51 +49 +47 +46 +44 +41 +40 +38 +36 +34 +32 +30 +27 +26 +24 +21 +19 +19 +21 +24 +26 +28 +30 +32 +34 +35 +38 +40 +41 +44 +45 +48 +50 +52 +54 +56 +56 +59 +61 +62 +64 +66 +67 +69 +71 +73 +74 +76 +77 +78 +79 +81 +83 +84 +85 +86 +87 +89 +90 +91 +92 +93 +93 +95 +96 +97 +97 +97 +98 +99 +100 +100 +100 +101 +101 +102 +103 +102 +102 +103 +103 +102 +103 +102 +102 +103 +102 +102 +102 +101 +100 +100 +99 +99 +98 +98 +98 +97 +96 +95 +94 +92 +91 +91 +89 +89 +88 +87 +85 +84 +83 +81 +79 +78 +77 +75 +74 +73 +71 +69 +68 +66 +64 +62 +61 +59 +57 +55 +54 +51 +49 +48 +46 +43 +42 +40 +38 +36 +33 +32 +29 +27 +26 +23 +21 +21 +23 +25 +27 +30 +32 +33 +35 +38 +40 +42 +44 +45 +48 +50 +52 +53 +55 +57 +59 +61 +63 +64 +67 +68 +69 +71 +73 +75 +76 +77 +79 +81 +82 +83 +85 +87 +88 +89 +90 +91 +92 +93 +95 +95 +96 +97 +98 +99 +99 +101 +101 +102 +102 +103 +104 +104 +105 +105 +105 +105 +105 +106 +106 +106 +106 +106 +106 +105 +105 +105 +104 +104 +103 +103 +103 +102 +101 +101 +100 +99 +98 +97 +96 +96 +95 +93 +93 +91 +90 +88 +87 +86 +85 +83 +82 +81 +79 +77 +76 +74 +73 +71 +69 +68 +66 +65 +63 +61 +59 +57 +56 +54 +51 +50 +48 +46 +43 +42 +40 +38 +35 +34 +32 +30 +27 +25 +23 +22 +25 +27 +29 +32 +34 +35 +38 +40 +42 +44 +45 +48 +50 +52 +53 +56 +57 +60 +61 +64 +65 +67 +69 +70 +72 +74 +76 +77 +79 +80 +81 +83 +84 +86 +87 +88 +90 +91 +92 +94 +95 +96 +97 +98 +99 +100 +101 +102 +102 +103 +104 +105 +105 +106 +106 +107 +108 +108 +108 +108 +108 +108 +108 +109 +109 +108 +108 +108 +108 +107 +107 +106 +106 +106 +105 +104 +104 +103 +103 +102 +101 +100 +99 +98 +97 +96 +95 +94 +92 +91 +90 +89 +87 +86 +84 +83 +82 +80 +79 +76 +75 +74 +71 +70 +69 +67 +65 +63 +61 +59 +57 +56 +54 +51 +49 +48 +46 +44 +42 +40 +38 +35 +34 +31 +29 +27 +25 +24 +26 +29 +31 +33 +35 +37 +39 +42 +44 +46 +48 +49 +51 +54 +56 +57 +60 +61 +63 +65 +67 +69 +71 +73 +74 +76 +77 +79 +81 +82 +84 +85 +87 +89 +90 +91 +92 +94 +95 +96 +97 +99 +99 +100 +102 +103 +104 +104 +106 +106 +107 +108 +108 +109 +109 +110 +110 +110 +111 +111 +111 +111 +111 +111 +112 +111 +111 +111 +111 +111 +110 +110 +109 +109 +108 +108 +107 +106 +105 +105 +103 +102 +101 +100 +99 +99 +97 +96 +95 +94 +92 +91 +90 +88 +87 +86 +84 +82 +80 +79 +77 +75 +74 +72 +71 +69 +67 +65 +63 +61 +60 +58 +56 +54 +52 +50 +48 +46 +44 +42 +39 +37 +35 +34 +31 +28 +27 +26 +28 +31 +33 +35 +37 +39 +41 +44 +45 +47 +50 +52 +54 +56 +58 +59 +62 +64 +66 +67 +69 +71 +73 +75 +76 +78 +80 +82 +83 +85 +86 +88 +90 +91 +92 +94 +95 +97 +97 +98 +100 +101 +103 +103 +104 +105 +106 +107 +108 +109 +109 +110 +111 +111 +112 +112 +113 +113 +114 +114 +114 +114 +114 +115 +114 +114 +114 +113 +113 +113 +113 +112 +111 +111 +110 +110 +109 +108 +108 +107 +106 +106 +104 +103 +102 +102 +99 +99 +97 +97 +95 +94 +92 +91 +89 +87 +87 +84 +83 +81 +80 +78 +77 +75 +73 +71 +69 +67 +66 +63 +62 +60 +58 +56 +54 +51 +50 +48 +46 +44 +42 +39 +37 +35 +33 +31 +28 +28 +31 +32 +35 +36 +39 +41 +43 +46 +47 +49 +52 +54 +56 +57 +60 +62 +63 +65 +68 +69 +71 +73 +75 +77 +79 +80 +82 +84 +85 +87 +88 +90 +91 +93 +95 +96 +97 +99 +100 +101 +102 +104 +105 +106 +107 +108 +109 +109 +111 +111 +113 +113 +113 +114 +114 +115 +116 +116 +116 +117 +117 +117 +117 +117 +117 +117 +117 +117 +117 +116 +115 +115 +115 +115 +113 +113 +112 +111 +111 +110 +109 +108 +107 +106 +104 +103 +102 +102 +100 +98 +97 +96 +95 +93 +92 +90 +89 +87 +85 +84 +82 +80 +79 +77 +75 +73 +72 +69 +67 +66 +64 +61 +60 +57 +56 +53 +52 +49 +48 +46 +43 +41 +38 +37 +35 +33 +30 +30 +31 +34 +36 +39 +40 +42 +45 +47 +49 +52 +54 +56 +57 +60 +62 +64 +65 +68 +69 +71 +74 +76 +77 +79 +81 +83 +84 +86 +87 +89 +90 +93 +94 +96 +97 +99 +100 +101 +103 +104 +106 +106 +108 +109 +110 +111 +112 +112 +114 +114 +115 +115 +117 +117 +117 +117 +119 +118 +119 +119 +119 +120 +119 +120 +119 +120 +120 +119 +119 +119 +119 +118 +118 +117 +116 +116 +115 +114 +114 +113 +111 +111 +110 +109 +108 +106 +105 +104 +103 +101 +100 +99 +97 +96 +94 +92 +91 +89 +87 +86 +84 +83 +80 +79 +77 +76 +73 +71 +70 +67 +65 +64 +62 +59 +57 +55 +54 +51 +49 +47 +45 +43 +41 +38 +37 +34 +31 +32 +34 +35 +38 +40 +43 +45 +46 +49 +52 +53 +55 +57 +59 +62 +64 +66 +68 +70 +72 +73 +75 +77 +79 +81 +83 +85 +86 +88 +90 +91 +93 +95 +97 +98 +99 +101 +102 +103 +105 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +117 +119 +119 +120 +121 +120 +121 +121 +122 +122 +122 +122 +123 +123 +122 +123 +122 +122 +122 +121 +121 +120 +121 +120 +119 +118 +117 +117 +116 +115 +114 +113 +112 +111 +110 +108 +107 +106 +105 +104 +102 +100 +99 +98 +96 +95 +93 +91 +90 +88 +86 +84 +83 +81 +79 +77 +75 +74 +71 +70 +68 +66 +63 +62 +59 +57 +55 +53 +51 +49 +47 +45 +42 +40 +38 +36 +33 +33 +35 +37 +40 +42 +44 +47 +49 +51 +53 +56 +57 +59 +61 +63 +66 +68 +70 +72 +74 +76 +78 +80 +82 +83 +86 +87 +88 +90 +93 +94 +95 +97 +99 +101 +102 +103 +105 +106 +107 +108 +110 +111 +113 +113 +115 +116 +116 +118 +118 +120 +120 +121 +121 +122 +123 +124 +124 +125 +124 +125 +126 +126 +125 +125 +125 +125 +126 +125 +125 +124 +124 +124 +123 +122 +122 +121 +121 +119 +118 +117 +116 +116 +115 +113 +112 +111 +110 +109 +107 +106 +105 +103 +102 +100 +98 +97 +96 +93 +92 +90 +89 +87 +85 +83 +81 +79 +78 +76 +74 +71 +70 +68 +65 +64 +62 +59 +58 +56 +53 +51 +48 +46 +44 +42 +39 +38 +35 +35 +36 +39 +42 +43 +46 +48 +50 +53 +54 +57 +59 +61 +64 +65 +68 +69 +72 +74 +75 +78 +80 +81 +83 +86 +87 +89 +91 +93 +94 +96 +98 +99 +101 +102 +104 +105 +107 +109 +110 +111 +113 +114 +116 +116 +117 +119 +120 +121 +121 +122 +123 +124 +124 +126 +126 +126 +127 +127 +128 +128 +128 +128 +128 +128 +128 +128 +128 +128 +127 +127 +127 +127 +126 +125 +125 +124 +123 +123 +121 +121 +120 +118 +118 +116 +115 +114 +112 +111 +110 +108 +107 +105 +104 +102 +101 +99 +98 +96 +94 +93 +91 +89 +87 +85 +84 +82 +80 +78 +75 +74 +71 +70 +68 +65 +63 +61 +59 +57 +55 +52 +50 +49 +46 +44 +41 +39 +37 +37 +39 +40 +43 +46 +48 +49 +52 +54 +57 +59 +61 +63 +66 +68 +70 +72 +73 +76 +77 +80 +82 +84 +86 +88 +90 +92 +94 +95 +97 +98 +100 +101 +103 +105 +107 +108 +110 +111 +112 +113 +115 +116 +118 +118 +120 +121 +122 +123 +124 +124 +126 +127 +127 +128 +128 +129 +129 +129 +130 +131 +131 +131 +131 +131 +131 +131 +131 +130 +130 +130 +129 +129 +129 +128 +127 +126 +126 +125 +124 +123 +122 +121 +120 +119 +118 +116 +115 +114 +113 +111 +110 +108 +107 +104 +103 +102 +100 +98 +96 +95 +93 +91 +90 +87 +85 +84 +82 +79 +78 +75 +74 +72 +69 +67 +65 +63 +60 +59 +56 +55 +52 +49 +47 +46 +43 +41 +38 +37 +40 +42 +44 +47 +49 +52 +54 +56 +58 +61 +62 +65 +67 +69 +72 +73 +75 +77 +80 +82 +83 +86 +88 +89 +92 +93 +95 +97 +99 +101 +102 +104 +106 +108 +108 +110 +112 +114 +115 +116 +118 +119 +120 +121 +122 +124 +125 +126 +127 +128 +128 +130 +130 +130 +131 +132 +132 +133 +133 +133 +133 +134 +134 +134 +134 +133 +134 +133 +133 +132 +133 +132 +131 +131 +130 +129 +128 +127 +126 +126 +125 +124 +123 +121 +120 +119 +118 +117 +115 +114 +112 +111 +109 +107 +105 +104 +103 +101 +99 +97 +95 +94 +91 +90 +87 +86 +83 +82 +80 +78 +76 +73 +71 +69 +67 +65 +62 +61 +59 +56 +53 +52 +49 +47 +45 +43 +40 +39 +41 +44 +46 +48 +51 +54 +56 +58 +60 +63 +64 +66 +69 +71 +73 +76 +78 +80 +81 +84 +86 +88 +89 +92 +93 +95 +97 +100 +100 +103 +104 +106 +108 +110 +112 +113 +114 +116 +118 +119 +120 +122 +123 +124 +126 +126 +128 +128 +129 +130 +131 +132 +133 +134 +134 +134 +135 +136 +136 +136 +137 +137 +137 +137 +137 +137 +136 +136 +136 +136 +135 +134 +134 +133 +133 +131 +132 +130 +130 +128 +127 +126 +125 +124 +123 +121 +121 +118 +117 +116 +114 +112 +111 +110 +108 +107 +105 +102 +101 +100 +98 +95 +94 +91 +90 +88 +86 +83 +82 +79 +78 +76 +73 +71 +69 +67 +65 +62 +60 +58 +55 +54 +51 +49 +47 +44 +42 +41 +44 +46 +47 +50 +53 +55 +57 +60 +61 +64 +66 +68 +71 +72 +75 +77 +79 +82 +84 +85 +88 +90 +91 +93 +95 +98 +99 +101 +103 +105 +107 +108 +110 +112 +113 +115 +117 +118 +120 +121 +122 +124 +126 +126 +128 +129 +130 +131 +132 +133 +134 +135 +135 +136 +137 +138 +138 +139 +138 +139 +139 +140 +139 +139 +140 +139 +139 +139 +139 +138 +137 +138 +136 +136 +135 +135 +134 +133 +132 +131 +130 +129 +128 +127 +126 +124 +122 +121 +119 +119 +117 +115 +113 +112 +111 +109 +107 +105 +103 +101 +99 +98 +96 +94 +92 +90 +87 +86 +84 +82 +79 +78 +75 +73 +71 +68 +66 +64 +61 +60 +58 +55 +53 +50 +48 +46 +43 +42 +44 +47 +50 +52 +54 +56 +58 +61 +64 +66 +68 +70 +72 +74 +77 +79 +81 +83 +85 +87 +90 +92 +93 +95 +98 +99 +101 +103 +105 +107 +109 +111 +112 +115 +116 +117 +119 +120 +123 +123 +125 +126 +128 +129 +130 +132 +132 +134 +135 +136 +137 +137 +138 +139 +140 +140 +141 +141 +141 +141 +142 +143 +142 +143 +142 +142 +142 +142 +142 +141 +141 +141 +140 +139 +138 +137 +137 +135 +134 +134 +132 +132 +130 +129 +128 +126 +125 +124 +122 +121 +119 +118 +115 +115 +112 +110 +109 +107 +106 +104 +101 +100 +98 +96 +93 +92 +90 +88 +85 +83 +81 +79 +77 +74 +72 +70 +67 +66 +63 +61 +59 +56 +54 +52 +49 +47 +45 +44 +46 +49 +51 +54 +56 +58 +61 +62 +65 +67 +70 +72 +74 +76 +78 +81 +83 +85 +87 +89 +92 +93 +96 +98 +100 +102 +104 +106 +107 +110 +111 +113 +115 +117 +118 +120 +121 +123 +125 +126 +127 +129 +130 +132 +132 +134 +136 +136 +137 +139 +139 +140 +141 +142 +142 +143 +143 +144 +144 +145 +145 +145 +145 +145 +145 +145 +144 +145 +145 +144 +143 +143 +142 +142 +141 +140 +139 +138 +138 +136 +135 +134 +133 +132 +130 +129 +128 +126 +124 +123 +121 +120 +118 +116 +114 +113 +111 +109 +107 +106 +104 +102 +100 +98 +95 +94 +91 +90 +87 +86 +83 +81 +79 +76 +74 +72 +70 +68 +65 +63 +61 +58 +55 +54 +51 +48 +46 +45 +48 +50 +52 +55 +58 +60 +62 +64 +67 +69 +71 +74 +76 +78 +80 +83 +84 +86 +90 +91 +93 +95 +97 +99 +101 +103 +105 +108 +109 +111 +113 +115 +117 +118 +120 +122 +124 +126 +127 +128 +130 +132 +132 +134 +136 +136 +138 +139 +140 +141 +141 +143 +144 +144 +145 +146 +146 +147 +147 +148 +148 +148 +148 +148 +148 +147 +148 +147 +147 +146 +147 +145 +145 +144 +143 +143 +142 +141 +140 +138 +138 +137 +135 +135 +133 +131 +130 +128 +127 +125 +124 +122 +120 +119 +117 +115 +114 +111 +109 +108 +106 +103 +102 +99 +97 +95 +93 +92 +89 +87 +85 +83 +81 +78 +76 +74 +71 +69 +66 +65 +62 +60 +57 +55 +52 +50 +48 +47 +50 +52 +54 +57 +58 +61 +64 +66 +68 +71 +72 +75 +77 +80 +82 +85 +86 +89 +91 +93 +95 +98 +100 +102 +104 +105 +108 +110 +111 +114 +115 +117 +119 +121 +122 +125 +126 +127 +129 +131 +133 +134 +136 +137 +138 +140 +140 +142 +143 +144 +144 +145 +146 +147 +148 +148 +149 +150 +150 +150 +151 +150 +151 +151 +151 +150 +150 +151 +149 +149 +149 +148 +148 +147 +146 +145 +145 +144 +142 +141 +140 +139 +138 +137 +135 +133 +132 +131 +129 +127 +126 +125 +123 +121 +119 +117 +116 +113 +111 +109 +107 +105 +104 +101 +99 +98 +95 +94 +91 +89 +87 +84 +82 +79 +78 +75 +73 +71 +68 +65 +64 +61 +59 +56 +54 +52 +49 +48 +50 +53 +56 +58 +60 +62 +65 +67 +69 +72 +75 +77 +79 +81 +83 +86 +88 +90 +93 +95 +97 +99 +102 +104 +105 +108 +110 +111 +113 +116 +117 +119 +121 +123 +124 +127 +128 +129 +131 +133 +134 +136 +137 +139 +140 +142 +143 +144 +146 +146 +147 +148 +149 +150 +151 +151 +152 +152 +153 +153 +153 +154 +154 +153 +154 +153 +153 +153 +152 +152 +152 +151 +151 +150 +149 +149 +148 +146 +145 +144 +143 +142 +140 +139 +138 +137 +135 +134 +132 +130 +128 +126 +125 +123 +122 +119 +117 +115 +113 +111 +110 +108 +106 +104 +101 +99 +97 +95 +93 +90 +88 +86 +83 +81 +79 +76 +75 +72 +70 +67 +65 +62 +60 +58 +56 +53 +50 +49 +52 +55 +57 +59 +61 +64 +66 +69 +71 +74 +76 +78 +81 +83 +85 +88 +90 +93 +95 +96 +98 +101 +103 +105 +107 +109 +111 +114 +115 +118 +119 +121 +123 +125 +127 +129 +130 +132 +134 +136 +137 +139 +140 +141 +143 +144 +145 +147 +148 +149 +150 +151 +151 +152 +153 +154 +154 +155 +156 +156 +156 +157 +156 +157 +156 +156 +156 +155 +155 +155 +155 +154 +153 +153 +152 +151 +150 +149 +147 +147 +145 +144 +143 +141 +140 +138 +137 +136 +134 +132 +130 +128 +127 +125 +124 +122 +120 +118 +116 +113 +112 +110 +107 +105 +103 +101 +99 +97 +94 +92 +90 +88 +86 +83 +81 +78 +76 +73 +72 +69 +67 +65 +62 +59 +57 +55 +51 +51 +53 +55 +58 +60 +63 +66 +68 +71 +73 +75 +77 +80 +82 +85 +87 +89 +91 +93 +96 +98 +101 +103 +105 +108 +110 +111 +114 +115 +118 +120 +122 +123 +125 +127 +129 +131 +132 +134 +136 +137 +139 +141 +142 +144 +145 +147 +148 +149 +150 +151 +153 +154 +154 +155 +156 +157 +157 +158 +158 +158 +159 +159 +159 +159 +160 +159 +159 +158 +158 +158 +157 +157 +155 +155 +155 +153 +152 +151 +150 +149 +147 +147 +146 +144 +142 +141 +140 +138 +136 +134 +133 +131 +129 +127 +126 +123 +121 +119 +118 +115 +113 +112 +109 +107 +105 +103 +101 +98 +96 +94 +91 +89 +87 +84 +82 +80 +78 +76 +73 +71 +68 +66 +63 +61 +58 +55 +54 +52 +55 +57 +60 +63 +65 +67 +69 +72 +74 +77 +79 +81 +84 +86 +89 +91 +93 +95 +98 +100 +102 +104 +106 +109 +111 +113 +115 +118 +120 +122 +123 +126 +128 +130 +131 +133 +135 +136 +138 +140 +142 +143 +144 +146 +148 +149 +150 +151 +152 +154 +155 +156 +157 +158 +159 +159 +160 +161 +161 +162 +162 +162 +162 +162 +162 +162 +162 +161 +161 +161 +160 +159 +159 +158 +157 +157 +155 +154 +153 +151 +151 +150 +148 +146 +145 +143 +142 +140 +138 +137 +135 +133 +131 +129 +127 +126 +123 +121 +119 +118 +115 +114 +111 +108 +107 +104 +102 +100 +98 +95 +94 +91 +89 +86 +84 +82 +79 +77 +74 +72 +70 +67 +64 +62 +60 +57 +54 +54 +56 +58 +61 +64 +66 +69 +71 +74 +76 +78 +80 +83 +86 +88 +90 +93 +95 +97 +100 +102 +104 +106 +109 +111 +113 +115 +117 +119 +121 +123 +125 +127 +130 +132 +133 +135 +137 +138 +140 +142 +144 +146 +147 +149 +150 +152 +153 +154 +155 +156 +158 +159 +159 +161 +161 +162 +162 +163 +164 +164 +164 +164 +165 +165 +165 +165 +165 +164 +164 +163 +163 +162 +161 +160 +160 +159 +158 +156 +155 +155 +153 +151 +150 +148 +147 +146 +144 +142 +141 +139 +137 +135 +133 +132 +129 +127 +126 +123 +121 +119 +117 +115 +112 +110 +108 +107 +104 +102 +100 +97 +95 +92 +90 +88 +85 +83 +81 +79 +75 +73 +71 +69 +66 +63 +61 +58 +56 +55 +57 +60 +62 +65 +67 +69 +72 +74 +77 +80 +82 +84 +87 +89 +92 +94 +96 +99 +101 +103 +106 +108 +110 +112 +115 +117 +119 +121 +123 +125 +127 +130 +132 +133 +136 +137 +139 +141 +143 +145 +146 +148 +149 +151 +153 +154 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +166 +166 +167 +168 +167 +168 +168 +168 +168 +167 +167 +167 +166 +165 +165 +164 +163 +163 +162 +161 +159 +158 +156 +155 +154 +152 +151 +149 +148 +146 +144 +143 +141 +139 +138 +135 +133 +131 +130 +127 +126 +123 +121 +119 +117 +115 +113 +111 +108 +106 +104 +101 +99 +97 +95 +91 +89 +87 +84 +82 +79 +77 +74 +72 +70 +67 +65 +62 +59 +57 +56 +58 +60 +63 +66 +68 +71 +73 +76 +79 +81 +84 +86 +89 +91 +94 +96 +98 +100 +103 +105 +107 +110 +112 +114 +116 +118 +121 +123 +125 +127 +130 +131 +133 +136 +137 +139 +141 +143 +145 +146 +149 +150 +152 +153 +155 +156 +158 +159 +161 +162 +163 +164 +165 +165 +167 +168 +168 +169 +170 +169 +170 +171 +171 +171 +170 +171 +170 +169 +170 +169 +168 +167 +166 +166 +165 +164 +163 +162 +160 +159 +158 +156 +155 +153 +151 +151 +148 +146 +145 +143 +142 +140 +137 +136 +133 +131 +130 +127 +125 +123 +121 +119 +116 +114 +111 +110 +107 +105 +102 +100 +98 +96 +93 +91 +89 +86 +84 +81 +79 +76 +74 +71 +68 +66 +64 +61 +58 +57 +60 +62 +65 +67 +70 +72 +75 +78 +80 +82 +84 +87 +90 +92 +95 +97 +99 +102 +105 +106 +109 +111 +114 +116 +118 +121 +122 +125 +127 +130 +132 +134 +136 +137 +139 +142 +144 +145 +147 +149 +151 +153 +154 +155 +157 +159 +160 +161 +163 +165 +165 +167 +168 +169 +170 +171 +171 +172 +172 +173 +173 +173 +173 +173 +173 +173 +173 +172 +172 +171 +171 +170 +169 +169 +168 +167 +166 +165 +163 +162 +161 +158 +157 +156 +154 +153 +151 +148 +147 +145 +143 +141 +139 +137 +136 +133 +131 +129 +127 +124 +123 +120 +118 +116 +113 +111 +109 +107 +104 +102 +99 +97 +95 +92 +89 +87 +85 +82 +80 +77 +75 +72 +70 +67 +65 +62 +60 +58 +61 +63 +66 +69 +71 +74 +76 +79 +81 +84 +86 +89 +91 +93 +96 +98 +101 +103 +105 +108 +110 +113 +116 +118 +120 +122 +125 +126 +129 +131 +133 +135 +137 +139 +142 +144 +145 +148 +149 +151 +153 +154 +156 +158 +160 +161 +163 +164 +165 +166 +168 +169 +171 +171 +172 +173 +174 +174 +175 +175 +176 +176 +176 +176 +176 +176 +175 +175 +175 +174 +174 +173 +172 +171 +170 +169 +168 +167 +165 +165 +163 +161 +160 +158 +156 +155 +153 +151 +149 +147 +145 +144 +141 +140 +137 +135 +133 +131 +129 +127 +124 +122 +120 +117 +115 +113 +110 +108 +106 +103 +100 +98 +96 +94 +91 +89 +86 +83 +81 +78 +76 +74 +71 +68 +66 +64 +60 +59 +62 +65 +67 +70 +73 +75 +78 +80 +83 +85 +88 +90 +92 +95 +97 +100 +103 +105 +107 +109 +112 +114 +117 +119 +121 +123 +126 +128 +131 +133 +135 +137 +139 +141 +143 +146 +148 +149 +152 +153 +155 +156 +158 +160 +162 +164 +165 +167 +168 +169 +170 +172 +173 +174 +175 +175 +177 +177 +177 +178 +178 +179 +179 +179 +179 +179 +179 +178 +178 +177 +177 +176 +175 +173 +173 +171 +171 +170 +168 +167 +165 +163 +162 +161 +159 +157 +155 +153 +151 +150 +148 +146 +143 +141 +139 +137 +134 +133 +130 +128 +126 +124 +122 +119 +117 +114 +112 +109 +107 +105 +102 +100 +97 +95 +92 +90 +88 +84 +83 +80 +77 +75 +72 +70 +67 +65 +62 +61 +63 +66 +68 +71 +73 +76 +79 +81 +84 +86 +89 +91 +94 +96 +99 +102 +104 +106 +109 +111 +113 +116 +119 +120 +123 +125 +127 +130 +132 +134 +137 +139 +141 +143 +145 +147 +150 +151 +154 +155 +157 +159 +161 +162 +165 +165 +167 +169 +171 +172 +173 +174 +176 +177 +178 +178 +179 +180 +181 +181 +181 +182 +182 +182 +182 +182 +181 +181 +180 +180 +179 +178 +178 +176 +176 +175 +173 +172 +170 +169 +167 +166 +164 +162 +160 +159 +157 +155 +154 +152 +149 +147 +146 +143 +141 +139 +136 +134 +132 +130 +128 +125 +123 +120 +118 +116 +114 +111 +109 +106 +104 +101 +98 +96 +94 +91 +89 +87 +83 +81 +79 +76 +73 +71 +69 +65 +63 +61 +64 +66 +69 +72 +74 +77 +80 +82 +85 +88 +90 +93 +95 +98 +100 +102 +105 +107 +110 +112 +115 +117 +120 +122 +124 +127 +129 +131 +134 +136 +139 +141 +143 +145 +147 +150 +151 +154 +155 +158 +159 +161 +163 +164 +167 +168 +170 +171 +173 +174 +176 +177 +178 +179 +180 +181 +182 +183 +183 +183 +184 +185 +185 +185 +185 +185 +184 +184 +183 +183 +182 +182 +180 +179 +178 +177 +175 +174 +173 +172 +169 +168 +167 +165 +163 +161 +159 +158 +155 +153 +151 +149 +147 +145 +143 +141 +138 +136 +134 +131 +130 +127 +124 +122 +120 +117 +115 +113 +110 +108 +105 +103 +100 +97 +95 +92 +90 +87 +85 +82 +79 +77 +74 +72 +69 +66 +64 +63 +65 +68 +70 +73 +75 +78 +81 +83 +86 +88 +91 +94 +97 +99 +101 +104 +106 +109 +111 +114 +116 +118 +121 +124 +126 +128 +131 +133 +136 +138 +140 +142 +145 +147 +149 +151 +154 +156 +157 +159 +161 +164 +166 +167 +169 +170 +172 +173 +175 +177 +178 +180 +180 +182 +183 +184 +185 +185 +186 +187 +187 +187 +187 +188 +187 +187 +186 +186 +186 +186 +184 +184 +183 +182 +181 +179 +178 +177 +176 +174 +172 +171 +169 +167 +165 +163 +162 +159 +157 +155 +154 +151 +149 +146 +144 +142 +140 +138 +135 +133 +131 +128 +126 +123 +121 +119 +116 +114 +112 +109 +107 +104 +101 +99 +96 +94 +91 +88 +86 +84 +81 +78 +76 +73 +70 +67 +65 +64 +66 +69 +72 +74 +76 +79 +82 +84 +87 +90 +92 +95 +97 +100 +103 +105 +108 +110 +113 +115 +118 +120 +122 +125 +128 +130 +132 +135 +137 +139 +142 +144 +146 +149 +151 +153 +155 +158 +160 +161 +163 +166 +167 +169 +171 +172 +174 +176 +178 +179 +180 +181 +183 +184 +186 +186 +187 +188 +188 +189 +190 +190 +191 +190 +190 +190 +190 +189 +188 +188 +187 +187 +185 +184 +184 +182 +180 +179 +177 +176 +175 +172 +171 +169 +168 +166 +163 +161 +160 +157 +155 +153 +151 +148 +146 +144 +141 +140 +137 +134 +133 +130 +128 +125 +122 +120 +118 +115 +112 +110 +108 +105 +103 +100 +97 +95 +92 +90 +88 +84 +82 +79 +77 +74 +71 +68 +66 +64 +67 +70 +73 +75 +77 +80 +83 +86 +88 +91 +93 +96 +99 +101 +104 +106 +109 +112 +114 +116 +119 +122 +124 +126 +129 +131 +134 +137 +138 +141 +144 +145 +148 +150 +152 +155 +157 +159 +161 +163 +166 +168 +170 +171 +173 +175 +177 +179 +180 +181 +183 +184 +186 +187 +188 +189 +189 +191 +191 +192 +193 +193 +193 +193 +193 +193 +193 +192 +192 +191 +190 +189 +188 +187 +186 +185 +183 +181 +180 +179 +177 +175 +173 +171 +169 +168 +165 +163 +161 +159 +157 +155 +152 +150 +148 +146 +143 +141 +138 +136 +134 +131 +129 +126 +124 +121 +119 +117 +114 +111 +108 +107 +104 +102 +98 +96 +94 +90 +88 +85 +83 +80 +77 +75 +72 +70 +67 +65 +68 +71 +73 +76 +79 +81 +84 +86 +89 +91 +94 +97 +100 +102 +105 +108 +110 +112 +115 +118 +120 +123 +125 +128 +130 +133 +135 +138 +140 +142 +145 +147 +150 +152 +154 +157 +158 +161 +163 +165 +167 +169 +171 +174 +175 +178 +179 +181 +182 +184 +185 +187 +188 +189 +190 +192 +193 +193 +194 +194 +195 +195 +195 +196 +196 +196 +196 +195 +194 +193 +193 +191 +190 +189 +188 +187 +185 +184 +182 +180 +179 +177 +175 +173 +171 +169 +167 +165 +163 +160 +159 +156 +154 +152 +149 +147 +144 +143 +140 +138 +135 +132 +130 +127 +125 +123 +120 +117 +115 +113 +110 +108 +104 +102 +100 +97 +94 +92 +89 +86 +83 +81 +78 +75 +73 +71 +68 +66 +69 +71 +74 +76 +79 +82 +84 +88 +90 +93 +96 +98 +100 +104 +106 +108 +111 +114 +116 +119 +121 +124 +126 +129 +132 +134 +136 +139 +141 +144 +146 +149 +151 +153 +156 +158 +160 +163 +165 +167 +169 +171 +173 +175 +177 +179 +181 +183 +185 +186 +188 +189 +191 +192 +193 +194 +195 +196 +197 +197 +198 +198 +199 +199 +199 +198 +198 +198 +197 +196 +196 +195 +193 +192 +190 +190 +188 +186 +185 +183 +181 +180 +177 +175 +173 +171 +170 +167 +165 +163 +160 +158 +155 +154 +151 +149 +146 +144 +141 +139 +136 +134 +131 +129 +127 +124 +122 +119 +116 +114 +111 +109 +105 +103 +101 +98 +96 +93 +90 +88 +85 +82 +80 +77 +74 +72 +68 +67 +70 +73 +75 +77 +81 +83 +86 +88 +91 +93 +97 +99 +101 +104 +107 +110 +112 +115 +117 +120 +123 +126 +128 +131 +133 +135 +138 +140 +143 +145 +148 +150 +152 +155 +158 +160 +162 +164 +166 +169 +171 +173 +175 +178 +180 +182 +183 +185 +187 +188 +190 +192 +193 +194 +196 +197 +198 +199 +199 +201 +200 +201 +201 +201 +201 +202 +201 +200 +199 +199 +198 +197 +196 +194 +193 +192 +190 +189 +187 +185 +183 +181 +180 +178 +175 +173 +171 +169 +166 +165 +162 +160 +157 +155 +153 +150 +148 +145 +143 +140 +138 +136 +132 +131 +127 +125 +123 +120 +118 +115 +113 +110 +107 +104 +101 +99 +97 +94 +91 +88 +86 +83 +81 +78 +75 +72 +70 +67 +71 +74 +76 +78 +82 +84 +87 +89 +92 +95 +97 +100 +103 +105 +108 +110 +113 +116 +119 +121 +123 +126 +129 +131 +134 +137 +140 +141 +145 +147 +149 +152 +154 +156 +159 +161 +163 +166 +168 +171 +172 +175 +177 +179 +181 +183 +185 +187 +189 +191 +192 +194 +195 +197 +198 +199 +200 +202 +202 +203 +203 +204 +205 +205 +204 +204 +204 +203 +202 +201 +201 +199 +199 +197 +195 +194 +192 +191 +189 +187 +185 +183 +181 +179 +177 +175 +172 +171 +168 +166 +164 +162 +159 +156 +154 +152 +149 +146 +144 +141 +139 +137 +133 +131 +129 +126 +124 +121 +118 +116 +113 +110 +108 +105 +103 +100 +97 +94 +92 +89 +86 +84 +81 +79 +76 +73 +71 +69 +71 +73 +77 +79 +82 +85 +88 +90 +93 +95 +98 +101 +104 +106 +109 +111 +114 +117 +120 +122 +125 +128 +130 +133 +135 +137 +141 +143 +145 +148 +151 +153 +155 +157 +161 +163 +165 +168 +170 +172 +175 +177 +179 +181 +183 +185 +187 +189 +191 +193 +194 +196 +197 +199 +200 +202 +203 +204 +205 +206 +207 +207 +207 +207 +207 +207 +207 +206 +205 +205 +204 +202 +200 +200 +198 +197 +194 +193 +191 +189 +188 +185 +183 +181 +179 +176 +175 +173 +170 +167 +165 +163 +160 +158 +155 +153 +150 +148 +146 +142 +140 +137 +135 +133 +129 +127 +125 +122 +119 +117 +114 +112 +109 +106 +103 +101 +98 +95 +93 +90 +87 +85 +82 +79 +76 +74 +71 +69 +72 +74 +77 +80 +83 +85 +88 +90 +94 +96 +99 +102 +104 +107 +110 +113 +115 +118 +120 +123 +126 +129 +131 +134 +136 +139 +141 +144 +147 +149 +152 +154 +157 +159 +161 +165 +166 +169 +171 +174 +176 +178 +180 +183 +185 +187 +189 +191 +193 +195 +197 +199 +201 +202 +203 +205 +206 +207 +208 +208 +210 +210 +210 +210 +210 +209 +209 +209 +208 +207 +206 +204 +204 +202 +201 +199 +197 +195 +193 +191 +189 +187 +185 +183 +181 +178 +176 +174 +171 +169 +167 +165 +162 +159 +157 +154 +151 +149 +147 +144 +141 +139 +137 +134 +131 +129 +126 +123 +120 +118 +115 +112 +109 +107 +105 +102 +99 +96 +94 +91 +88 +86 +83 +80 +78 +74 +72 +70 +73 +76 +78 +81 +84 +86 +88 +92 +95 +98 +100 +103 +106 +108 +111 +114 +116 +118 +121 +124 +126 +129 +132 +134 +137 +140 +142 +145 +148 +150 +153 +155 +158 +160 +163 +165 +168 +171 +173 +175 +178 +180 +182 +185 +187 +189 +191 +194 +195 +197 +199 +201 +203 +204 +206 +207 +209 +209 +211 +212 +212 +212 +213 +212 +213 +213 +212 +212 +211 +210 +209 +207 +206 +204 +202 +201 +199 +198 +195 +193 +191 +189 +187 +184 +182 +180 +177 +175 +173 +170 +168 +166 +163 +160 +158 +155 +152 +151 +148 +145 +142 +140 +138 +134 +132 +129 +127 +124 +121 +119 +116 +113 +110 +108 +105 +102 +100 +97 +94 +91 +89 +86 +83 +81 +78 +75 +72 +71 +73 +76 +78 +81 +85 +87 +90 +92 +95 +98 +100 +103 +106 +109 +112 +114 +116 +119 +123 +125 +127 +130 +133 +135 +139 +141 +143 +146 +149 +152 +154 +157 +160 +162 +164 +167 +170 +172 +175 +177 +179 +181 +184 +186 +189 +191 +193 +195 +197 +199 +202 +203 +205 +207 +208 +210 +211 +212 +213 +214 +215 +215 +216 +216 +215 +215 +215 +214 +213 +212 +211 +209 +208 +207 +205 +203 +201 +199 +198 +195 +193 +191 +189 +186 +184 +181 +179 +177 +175 +171 +170 +167 +164 +162 +159 +157 +154 +152 +149 +146 +144 +141 +138 +136 +133 +131 +128 +125 +122 +119 +117 +114 +111 +109 +106 +103 +101 +98 +95 +93 +90 +87 +84 +81 +79 +76 +73 +71 +74 +77 +79 +82 +85 +88 +91 +93 +95 +98 +101 +104 +106 +109 +112 +114 +118 +120 +123 +126 +128 +131 +134 +136 +139 +142 +145 +147 +149 +153 +155 +158 +160 +163 +165 +169 +171 +173 +176 +178 +181 +183 +186 +188 +190 +192 +195 +197 +199 +201 +203 +206 +207 +209 +210 +212 +213 +215 +216 +216 +218 +218 +218 +219 +218 +218 +217 +217 +216 +215 +214 +212 +211 +208 +207 +205 +204 +201 +199 +197 +195 +192 +190 +188 +185 +183 +181 +178 +175 +173 +171 +168 +165 +163 +161 +158 +156 +152 +149 +147 +144 +141 +139 +136 +133 +131 +128 +126 +123 +120 +118 +115 +112 +109 +107 +104 +101 +99 +96 +93 +90 +87 +85 +82 +79 +77 +74 +71 +74 +77 +80 +82 +85 +88 +91 +94 +96 +99 +102 +104 +107 +110 +113 +116 +118 +122 +124 +126 +129 +132 +135 +137 +141 +143 +145 +148 +150 +153 +156 +158 +161 +164 +167 +170 +172 +174 +177 +179 +182 +185 +187 +190 +191 +194 +197 +199 +201 +203 +205 +207 +209 +211 +213 +214 +216 +217 +218 +220 +221 +220 +221 +221 +221 +221 +220 +219 +218 +217 +216 +215 +212 +211 +209 +207 +205 +203 +201 +198 +197 +194 +192 +190 +187 +185 +182 +179 +177 +174 +172 +169 +167 +164 +161 +159 +156 +154 +150 +148 +145 +143 +140 +138 +134 +132 +129 +126 +124 +121 +118 +115 +112 +110 +108 +105 +102 +100 +96 +94 +91 +88 +86 +82 +80 +77 +74 +72 +75 +77 +80 +83 +86 +89 +92 +95 +97 +100 +102 +105 +108 +111 +113 +117 +119 +122 +124 +128 +130 +133 +135 +139 +140 +144 +146 +149 +152 +154 +157 +160 +162 +165 +168 +171 +173 +175 +178 +181 +183 +186 +188 +190 +193 +195 +198 +201 +203 +205 +207 +209 +211 +213 +214 +217 +219 +220 +221 +222 +223 +223 +223 +224 +224 +223 +223 +222 +221 +219 +218 +217 +215 +213 +211 +209 +207 +205 +203 +200 +198 +196 +193 +191 +188 +185 +184 +180 +178 +175 +173 +170 +167 +165 +163 +160 +157 +154 +151 +149 +146 +143 +141 +138 +136 +133 +130 +127 +125 +122 +119 +116 +113 +110 +108 +106 +102 +100 +97 +94 +92 +89 +86 +83 +81 +77 +75 +73 +75 +78 +81 +84 +87 +89 +92 +95 +97 +101 +103 +106 +108 +111 +114 +117 +119 +122 +125 +128 +131 +134 +136 +139 +142 +145 +147 +150 +152 +155 +158 +161 +163 +166 +168 +171 +174 +177 +179 +182 +185 +187 +190 +192 +195 +197 +200 +201 +205 +206 +209 +211 +213 +215 +217 +219 +221 +222 +224 +224 +226 +227 +226 +227 +227 +226 +225 +225 +224 +222 +221 +219 +217 +215 +214 +211 +208 +207 +204 +202 +200 +197 +194 +192 +190 +187 +184 +182 +179 +177 +174 +172 +168 +166 +164 +161 +158 +156 +153 +150 +147 +144 +142 +139 +136 +133 +131 +128 +125 +122 +120 +117 +114 +112 +109 +106 +103 +100 +97 +95 +92 +89 +87 +83 +80 +78 +75 +73 +76 +78 +81 +84 +87 +89 +92 +95 +98 +101 +104 +106 +109 +112 +115 +117 +120 +123 +126 +128 +132 +134 +137 +140 +142 +145 +148 +150 +154 +156 +158 +161 +164 +167 +170 +172 +175 +177 +180 +183 +185 +188 +191 +193 +196 +198 +201 +203 +205 +208 +210 +213 +215 +218 +219 +221 +223 +225 +226 +227 +229 +229 +230 +229 +229 +229 +228 +227 +226 +224 +223 +221 +219 +217 +215 +213 +210 +208 +206 +203 +201 +199 +196 +193 +191 +188 +185 +183 +180 +178 +175 +172 +169 +167 +164 +161 +159 +156 +154 +150 +148 +145 +143 +140 +136 +134 +131 +129 +125 +123 +120 +118 +114 +112 +110 +107 +103 +101 +98 +95 +93 +90 +87 +84 +82 +78 +76 +74 +76 +79 +81 +85 +88 +90 +93 +95 +98 +101 +104 +107 +109 +112 +115 +117 +121 +123 +126 +129 +132 +135 +137 +140 +142 +146 +148 +151 +154 +156 +159 +162 +164 +167 +170 +173 +176 +179 +181 +184 +186 +189 +192 +194 +197 +200 +202 +205 +207 +210 +212 +215 +217 +219 +221 +223 +225 +227 +228 +229 +231 +231 +232 +233 +232 +232 +231 +229 +228 +227 +225 +223 +221 +219 +216 +214 +212 +209 +207 +204 +202 +200 +197 +194 +192 +189 +187 +184 +181 +178 +176 +173 +170 +168 +164 +163 +160 +157 +154 +151 +148 +146 +143 +140 +137 +134 +131 +129 +126 +124 +120 +117 +115 +113 +110 +106 +104 +102 +98 +95 +93 +90 +87 +84 +81 +78 +76 +74 +76 +80 +83 +85 +88 +90 +94 +96 +99 +101 +104 +107 +110 +113 +116 +118 +122 +124 +127 +129 +132 +135 +138 +140 +144 +146 +149 +151 +155 +157 +160 +163 +166 +168 +171 +174 +176 +179 +181 +185 +187 +190 +192 +195 +198 +200 +203 +206 +208 +210 +214 +216 +218 +221 +223 +225 +227 +229 +231 +232 +233 +235 +235 +235 +235 +234 +234 +232 +231 +229 +228 +225 +223 +221 +219 +216 +214 +211 +209 +206 +203 +201 +198 +196 +193 +190 +187 +184 +182 +179 +177 +174 +171 +168 +166 +163 +160 +157 +154 +151 +149 +146 +143 +141 +138 +135 +132 +129 +127 +124 +121 +118 +115 +113 +110 +107 +104 +102 +98 +96 +93 +91 +88 +85 +82 +79 +76 +73 +76 +80 +82 +85 +88 +91 +94 +96 +100 +102 +105 +107 +110 +113 +115 +119 +122 +125 +127 +130 +133 +136 +138 +141 +144 +147 +149 +152 +155 +158 +161 +164 +166 +169 +172 +174 +177 +179 +182 +185 +188 +191 +193 +197 +199 +202 +204 +207 +210 +212 +215 +217 +220 +222 +225 +227 +229 +232 +233 +235 +236 +237 +238 +238 +238 +238 +236 +235 +233 +231 +229 +226 +224 +222 +219 +218 +215 +212 +210 +207 +205 +202 +199 +196 +193 +191 +188 +186 +183 +179 +177 +175 +171 +169 +166 +163 +161 +158 +155 +152 +150 +146 +144 +141 +138 +135 +132 +130 +127 +125 +121 +119 +116 +113 +111 +107 +105 +102 +99 +96 +94 +91 +88 +86 +82 +80 +76 +75 +76 +80 +82 +86 +88 +91 +93 +97 +99 +102 +105 +108 +111 +113 +116 +119 +121 +124 +127 +130 +133 +136 +139 +141 +144 +147 +150 +153 +155 +159 +161 +163 +166 +169 +172 +174 +178 +180 +183 +186 +188 +192 +194 +196 +200 +202 +205 +208 +210 +213 +215 +218 +221 +224 +226 +229 +231 +233 +235 +237 +239 +240 +240 +241 +241 +240 +239 +237 +235 +233 +231 +228 +226 +223 +221 +218 +216 +213 +210 +208 +205 +202 +200 +197 +194 +191 +189 +186 +183 +181 +177 +175 +172 +169 +167 +163 +161 +158 +155 +152 +149 +147 +144 +141 +139 +136 +133 +130 +127 +125 +122 +119 +116 +113 +110 +108 +105 +102 +100 +97 +94 +91 +88 +85 +83 +80 +77 +75 +77 +80 +83 +85 +88 +91 +94 +97 +99 +102 +105 +108 +111 +114 +116 +120 +122 +125 +128 +130 +133 +136 +139 +142 +145 +148 +150 +153 +156 +158 +161 +164 +167 +169 +173 +176 +178 +180 +184 +186 +189 +192 +195 +197 +200 +203 +206 +209 +212 +214 +217 +220 +222 +225 +227 +230 +232 +234 +237 +240 +241 +243 +243 +244 +243 +242 +241 +239 +237 +235 +232 +230 +227 +224 +222 +219 +216 +214 +211 +208 +206 +203 +200 +197 +194 +192 +190 +186 +183 +181 +178 +175 +173 +170 +166 +164 +161 +158 +156 +153 +150 +147 +145 +141 +139 +136 +134 +131 +128 +125 +122 +119 +117 +114 +111 +108 +105 +102 +99 +97 +94 +91 +88 +85 +83 +80 +77 +74 +77 +80 +83 +86 +88 +92 +94 +97 +100 +102 +105 +108 +111 +113 +117 +119 +123 +125 +128 +131 +133 +137 +139 +141 +145 +148 +151 +153 +156 +159 +161 +164 +168 +170 +173 +176 +178 +181 +184 +187 +189 +193 +196 +198 +200 +204 +206 +209 +212 +214 +218 +220 +223 +226 +229 +231 +234 +236 +239 +241 +243 +245 +246 +247 +246 +245 +243 +241 +239 +236 +234 +231 +228 +226 +223 +220 +217 +214 +212 +209 +206 +204 +201 +198 +196 +193 +190 +187 +184 +181 +179 +176 +173 +170 +168 +164 +162 +159 +156 +153 +151 +148 +145 +142 +139 +137 +133 +130 +128 +125 +122 +119 +117 +114 +111 +108 +105 +103 +100 +97 +94 +92 +88 +86 +83 +80 +77 +75 +77 +80 +83 +86 +88 +92 +94 +97 +100 +103 +106 +109 +111 +114 +117 +119 +122 +125 +128 +131 +134 +136 +140 +142 +145 +148 +151 +153 +156 +159 +162 +165 +167 +170 +173 +176 +178 +182 +185 +187 +190 +193 +196 +199 +202 +204 +207 +209 +213 +215 +218 +220 +223 +227 +229 +232 +235 +238 +240 +242 +245 +247 +249 +250 +249 +247 +245 +242 +240 +237 +234 +232 +229 +226 +224 +221 +218 +216 +213 +210 +206 +204 +201 +198 +196 +193 +190 +187 +185 +182 +178 +175 +173 +170 +168 +164 +162 +159 +156 +153 +150 +148 +145 +142 +139 +136 +133 +131 +128 +126 +122 +120 +117 +114 +111 +109 +106 +103 +100 +97 +94 +91 +89 +85 +83 +80 +77 +75 +77 +80 +83 +86 +89 +91 +94 +97 +100 +102 +106 +109 +112 +115 +117 +120 +123 +125 +128 +131 +134 +137 +139 +142 +145 +147 +151 +154 +156 +159 +162 +164 +167 +171 +174 +176 +179 +181 +185 +187 +190 +193 +196 +198 +202 +204 +207 +210 +213 +216 +218 +221 +224 +227 +230 +232 +235 +238 +241 +243 +246 +248 +251 +252 +251 +249 +246 +244 +241 +238 +235 +232 +229 +226 +224 +221 +219 +216 +213 +209 +207 +204 +202 +199 +195 +193 +190 +187 +185 +182 +179 +176 +173 +171 +168 +165 +162 +159 +156 +154 +151 +148 +146 +142 +139 +137 +134 +131 +129 +125 +123 +120 +117 +114 +112 +109 +105 +102 +100 +98 +95 +92 +89 +86 +84 +80 +77 +75 +77 +81 +83 +86 +88 +92 +94 +98 +100 +103 +105 +108 +111 +114 +117 +120 +123 +126 +128 +131 +134 +136 +139 +143 +145 +148 +151 +154 +157 +159 +163 +164 +168 +170 +174 +176 +179 +181 +185 +187 +190 +193 +196 +199 +201 +204 +207 +210 +213 +215 +219 +221 +224 +226 +230 +233 +235 +238 +241 +244 +247 +250 +252 +255 +252 +250 +246 +244 +241 +238 +236 +233 +230 +227 +224 +222 +218 +216 +213 +210 +207 +204 +202 +199 +196 +193 +190 +188 +185 +182 +179 +176 +173 +171 +167 +164 +162 +159 +156 +154 +150 +148 +145 +142 +139 +136 +133 +131 +128 +125 +122 +120 +117 +115 +111 +108 +106 +103 +100 +97 +94 +92 +89 +86 +83 +81 +78 +74 +78 +80 +83 +86 +88 +92 +95 +97 +100 +103 +106 +109 +111 +114 +117 +119 +123 +125 +128 +131 +134 +136 +140 +142 +145 +148 +151 +153 +157 +159 +162 +165 +168 +170 +173 +177 +179 +182 +185 +187 +190 +192 +196 +199 +201 +204 +207 +210 +213 +216 +218 +221 +224 +227 +230 +232 +235 +238 +241 +243 +246 +249 +251 +253 +251 +249 +246 +243 +241 +238 +235 +233 +230 +227 +224 +221 +218 +216 +213 +210 +207 +204 +201 +198 +196 +192 +191 +187 +184 +182 +179 +176 +173 +170 +168 +165 +162 +159 +156 +153 +151 +148 +145 +142 +140 +137 +133 +131 +129 +125 +122 +120 +117 +114 +111 +108 +106 +103 +100 +98 +95 +92 +89 +86 +83 +80 +78 +74 +78 +80 +83 +86 +89 +91 +94 +97 +100 +103 +105 +109 +111 +114 +116 +120 +123 +126 +128 +131 +134 +136 +139 +142 +145 +148 +150 +153 +156 +159 +162 +165 +167 +170 +173 +176 +179 +182 +184 +188 +190 +193 +196 +198 +201 +204 +207 +209 +212 +215 +218 +221 +223 +226 +229 +232 +235 +237 +239 +242 +244 +247 +249 +249 +249 +247 +245 +243 +239 +238 +235 +232 +229 +227 +224 +220 +218 +215 +213 +210 +206 +204 +201 +199 +196 +193 +189 +188 +184 +181 +179 +176 +173 +170 +168 +165 +162 +159 +156 +153 +150 +147 +145 +143 +139 +137 +133 +131 +128 +126 +122 +120 +117 +114 +112 +109 +105 +103 +100 +97 +94 +92 +89 +86 +83 +81 +77 +74 +77 +81 +83 +86 +89 +92 +95 +97 +100 +103 +105 +108 +111 +114 +116 +120 +122 +125 +128 +131 +134 +136 +140 +142 +145 +147 +151 +154 +156 +159 +162 +165 +167 +170 +172 +175 +178 +181 +184 +187 +190 +193 +195 +198 +201 +203 +206 +209 +212 +215 +217 +220 +223 +226 +229 +231 +234 +236 +239 +241 +243 +245 +246 +246 +246 +245 +243 +241 +238 +236 +234 +231 +228 +226 +222 +220 +217 +215 +212 +209 +207 +203 +201 +198 +195 +193 +190 +187 +184 +181 +178 +176 +173 +170 +167 +164 +161 +159 +156 +154 +150 +148 +145 +142 +139 +136 +134 +131 +128 +125 +122 +120 +117 +114 +111 +108 +105 +103 +100 +97 +95 +91 +89 +86 +83 +80 +77 +75 +77 +80 +83 +86 +88 +92 +94 +97 +99 +103 +106 +109 +111 +113 +117 +120 +122 +125 +128 +131 +133 +137 +139 +142 +145 +147 +151 +153 +155 +158 +161 +164 +167 +170 +173 +175 +178 +180 +183 +187 +189 +192 +194 +197 +200 +203 +205 +209 +212 +214 +217 +219 +222 +225 +227 +229 +232 +234 +237 +239 +241 +242 +243 +244 +243 +242 +241 +240 +237 +235 +233 +229 +227 +225 +222 +219 +217 +213 +211 +208 +206 +203 +200 +198 +195 +192 +189 +186 +184 +181 +178 +175 +172 +170 +167 +164 +161 +158 +156 +153 +150 +147 +144 +142 +139 +136 +133 +131 +128 +125 +122 +119 +117 +114 +111 +108 +106 +103 +100 +97 +94 +91 +89 +86 +83 +80 +77 +75 +77 +79 +83 +85 +88 +91 +94 +97 +100 +102 +105 +108 +111 +114 +116 +119 +122 +124 +127 +130 +133 +136 +139 +141 +145 +147 +150 +152 +155 +159 +161 +164 +166 +170 +172 +175 +177 +181 +184 +186 +189 +191 +195 +197 +199 +202 +205 +208 +211 +213 +216 +219 +221 +224 +226 +228 +231 +233 +235 +237 +239 +239 +241 +241 +241 +239 +238 +237 +235 +233 +231 +228 +226 +223 +221 +219 +216 +213 +210 +207 +205 +202 +200 +197 +195 +192 +189 +186 +183 +181 +177 +175 +172 +169 +166 +164 +161 +159 +155 +152 +149 +147 +144 +141 +139 +136 +133 +130 +128 +125 +122 +119 +116 +114 +110 +108 +105 +102 +100 +97 +94 +91 +89 +86 +83 +80 +77 +74 +77 +79 +82 +85 +88 +90 +93 +96 +99 +102 +105 +107 +110 +113 +116 +119 +121 +125 +127 +130 +133 +135 +138 +141 +143 +147 +149 +152 +155 +158 +161 +163 +166 +169 +172 +174 +177 +180 +182 +185 +188 +191 +194 +196 +199 +201 +204 +207 +209 +212 +215 +217 +220 +222 +224 +227 +229 +231 +233 +235 +236 +237 +238 +238 +237 +238 +236 +235 +233 +231 +229 +227 +224 +223 +219 +218 +214 +212 +209 +207 +204 +201 +199 +197 +193 +190 +188 +185 +183 +180 +177 +174 +171 +169 +166 +163 +160 +157 +155 +152 +149 +147 +144 +141 +139 +135 +132 +130 +127 +124 +122 +118 +116 +113 +111 +108 +105 +102 +99 +96 +94 +91 +88 +86 +82 +80 +77 +74 +77 +79 +82 +85 +87 +90 +93 +96 +99 +102 +104 +107 +110 +113 +115 +118 +121 +123 +127 +130 +132 +135 +138 +141 +144 +147 +149 +152 +155 +157 +160 +162 +166 +168 +171 +174 +176 +179 +182 +185 +187 +190 +193 +196 +198 +200 +203 +206 +208 +211 +213 +216 +219 +220 +223 +225 +227 +229 +231 +233 +234 +235 +235 +235 +235 +234 +233 +232 +231 +229 +227 +225 +223 +220 +218 +215 +213 +211 +208 +206 +203 +201 +198 +195 +192 +190 +187 +184 +182 +180 +176 +174 +171 +168 +165 +162 +160 +157 +155 +152 +149 +146 +143 +141 +138 +135 +132 +130 +126 +124 +121 +118 +116 +113 +110 +107 +104 +102 +99 +96 +93 +91 +88 +85 +82 +79 +76 +73 +77 +79 +81 +85 +88 +90 +93 +96 +98 +101 +104 +106 +109 +112 +115 +118 +120 +124 +126 +129 +132 +134 +137 +140 +143 +146 +149 +151 +154 +157 +159 +162 +165 +167 +170 +173 +176 +178 +181 +184 +187 +189 +191 +194 +197 +200 +202 +204 +207 +210 +212 +214 +217 +218 +221 +223 +225 +227 +228 +229 +231 +232 +233 +233 +233 +232 +230 +230 +229 +227 +225 +223 +221 +219 +217 +215 +212 +209 +208 +205 +202 +200 +197 +195 +191 +189 +186 +184 +181 +179 +175 +173 +170 +167 +165 +162 +159 +157 +153 +151 +148 +146 +143 +140 +137 +135 +132 +129 +127 +124 +120 +118 +115 +112 +109 +106 +104 +101 +99 +95 +93 +90 +87 +84 +82 +79 +76 +73 +76 +79 +81 +84 +86 +89 +93 +95 +98 +101 +104 +106 +109 +112 +114 +117 +121 +123 +126 +129 +131 +134 +136 +139 +142 +145 +147 +151 +153 +156 +158 +162 +164 +167 +170 +172 +175 +177 +180 +183 +185 +188 +191 +193 +196 +199 +201 +203 +205 +208 +210 +213 +215 +217 +219 +221 +222 +224 +226 +227 +228 +229 +230 +230 +229 +229 +228 +227 +226 +225 +223 +221 +219 +217 +215 +213 +210 +208 +206 +204 +201 +198 +196 +193 +191 +188 +186 +182 +180 +178 +174 +172 +169 +166 +164 +162 +159 +156 +153 +150 +148 +145 +142 +139 +137 +134 +131 +128 +126 +123 +121 +118 +115 +112 +109 +106 +103 +101 +98 +95 +92 +90 +87 +84 +81 +78 +75 +72 +76 +78 +81 +83 +87 +89 +92 +95 +97 +101 +103 +106 +109 +112 +115 +117 +119 +123 +126 +128 +130 +133 +136 +139 +142 +144 +147 +149 +153 +155 +158 +160 +163 +166 +169 +171 +173 +177 +179 +181 +184 +187 +189 +192 +194 +197 +199 +202 +204 +207 +209 +211 +214 +215 +217 +219 +221 +223 +223 +224 +226 +227 +227 +226 +226 +227 +226 +225 +223 +223 +221 +218 +217 +215 +214 +211 +209 +207 +204 +202 +200 +197 +195 +192 +190 +187 +184 +182 +179 +176 +173 +171 +168 +166 +163 +161 +158 +156 +153 +150 +147 +144 +142 +139 +136 +133 +131 +128 +125 +122 +119 +117 +114 +111 +109 +105 +103 +100 +97 +95 +92 +89 +86 +83 +80 +78 +75 +72 +75 +77 +80 +83 +86 +89 +91 +94 +97 +99 +102 +105 +108 +111 +114 +116 +119 +121 +124 +127 +130 +132 +136 +138 +141 +143 +146 +149 +151 +154 +157 +159 +163 +165 +168 +170 +173 +176 +178 +181 +184 +186 +188 +191 +193 +196 +198 +200 +203 +205 +207 +209 +211 +213 +215 +216 +218 +220 +221 +222 +223 +223 +224 +224 +224 +223 +223 +222 +220 +220 +219 +217 +215 +213 +211 +209 +207 +205 +202 +200 +198 +196 +193 +191 +188 +186 +183 +181 +178 +175 +173 +170 +168 +165 +162 +160 +157 +155 +152 +149 +146 +143 +140 +138 +135 +133 +130 +127 +124 +121 +119 +116 +113 +111 +108 +105 +102 +99 +97 +95 +92 +89 +86 +83 +80 +77 +75 +72 +74 +77 +80 +82 +85 +88 +91 +94 +97 +99 +102 +105 +107 +111 +112 +116 +119 +122 +124 +126 +130 +132 +134 +137 +140 +143 +146 +148 +151 +153 +156 +159 +161 +164 +167 +169 +172 +174 +176 +179 +182 +185 +186 +190 +192 +194 +196 +199 +200 +203 +206 +208 +209 +211 +213 +214 +216 +217 +219 +220 +220 +221 +221 +221 +221 +221 +220 +220 +218 +217 +215 +215 +212 +211 +209 +207 +205 +203 +201 +199 +197 +194 +192 +190 +186 +185 +182 +179 +177 +175 +172 +169 +167 +164 +161 +159 +156 +153 +151 +148 +145 +143 +140 +137 +135 +132 +129 +127 +124 +121 +118 +115 +113 +110 +107 +104 +102 +99 +96 +93 +91 +88 +86 +83 +79 +77 +74 +71 +74 +77 +79 +82 +85 +88 +91 +93 +95 +99 +102 +104 +106 +109 +112 +115 +117 +120 +123 +125 +129 +132 +134 +137 +139 +142 +145 +147 +150 +152 +155 +158 +161 +163 +165 +168 +171 +173 +175 +178 +180 +183 +186 +188 +190 +193 +194 +197 +199 +201 +203 +206 +207 +209 +210 +212 +213 +214 +215 +216 +217 +218 +218 +218 +218 +218 +217 +217 +216 +215 +214 +212 +211 +209 +207 +205 +203 +202 +199 +197 +195 +193 +190 +188 +185 +183 +180 +178 +176 +173 +170 +168 +166 +163 +160 +157 +155 +153 +150 +147 +145 +142 +139 +136 +134 +131 +128 +126 +123 +120 +117 +115 +112 +109 +107 +104 +101 +99 +96 +93 +90 +88 +85 +82 +80 +76 +74 +71 +73 +76 +79 +82 +84 +87 +90 +92 +95 +98 +100 +104 +106 +109 +112 +114 +116 +120 +122 +125 +128 +130 +133 +136 +138 +141 +143 +147 +149 +151 +154 +156 +159 +162 +165 +167 +169 +172 +174 +177 +179 +181 +184 +186 +188 +191 +193 +195 +197 +199 +201 +203 +205 +207 +208 +209 +211 +212 +214 +214 +214 +215 +216 +216 +215 +215 +215 +214 +213 +212 +211 +210 +208 +207 +205 +203 +201 +199 +198 +195 +193 +190 +188 +186 +184 +182 +180 +177 +174 +171 +169 +167 +164 +162 +159 +157 +154 +151 +149 +146 +144 +141 +139 +135 +133 +131 +128 +125 +122 +120 +117 +114 +112 +108 +106 +103 +101 +98 +96 +92 +90 +87 +84 +81 +79 +76 +73 +70 +72 +75 +78 +81 +83 +86 +89 +91 +94 +97 +100 +102 +105 +108 +110 +113 +116 +119 +121 +124 +127 +129 +132 +134 +137 +140 +142 +145 +148 +150 +153 +155 +158 +160 +163 +165 +168 +171 +173 +176 +178 +180 +182 +185 +187 +189 +191 +193 +195 +197 +199 +201 +203 +205 +206 +207 +208 +210 +210 +211 +212 +212 +213 +212 +213 +212 +212 +212 +211 +209 +208 +207 +206 +204 +203 +200 +199 +197 +195 +193 +191 +189 +187 +185 +182 +180 +178 +176 +173 +170 +168 +165 +163 +160 +158 +155 +153 +151 +148 +145 +142 +139 +138 +135 +132 +130 +126 +124 +121 +118 +116 +114 +111 +108 +106 +103 +100 +97 +94 +92 +89 +86 +83 +81 +78 +75 +72 +69 +72 +75 +77 +80 +83 +86 +88 +91 +93 +96 +99 +101 +104 +107 +110 +112 +115 +117 +120 +123 +126 +128 +131 +133 +136 +139 +142 +144 +147 +149 +152 +154 +157 +159 +161 +164 +166 +169 +171 +174 +176 +179 +180 +183 +185 +187 +189 +191 +193 +195 +197 +199 +200 +202 +203 +205 +206 +207 +208 +209 +209 +210 +210 +210 +210 +210 +209 +209 +208 +207 +206 +204 +203 +202 +200 +199 +197 +195 +193 +191 +189 +188 +185 +183 +180 +178 +176 +173 +172 +169 +167 +164 +161 +160 +156 +154 +152 +149 +147 +144 +142 +139 +136 +133 +131 +128 +125 +123 +120 +118 +115 +112 +110 +107 +104 +102 +99 +97 +94 +91 +89 +85 +83 +80 +78 +74 +72 +68 +71 +74 +76 +79 +82 +85 +88 +90 +93 +95 +98 +101 +104 +107 +109 +112 +114 +117 +119 +122 +125 +127 +130 +133 +136 +138 +140 +142 +146 +147 +151 +152 +156 +158 +160 +163 +165 +168 +170 +172 +174 +177 +179 +181 +183 +185 +187 +189 +191 +193 +195 +196 +198 +200 +200 +202 +204 +204 +205 +205 +206 +206 +207 +207 +207 +207 +206 +206 +205 +204 +203 +202 +201 +199 +198 +197 +195 +193 +191 +190 +187 +185 +183 +181 +179 +177 +175 +173 +169 +168 +166 +163 +160 +158 +156 +153 +150 +148 +146 +143 +140 +138 +135 +133 +130 +128 +125 +122 +119 +117 +114 +112 +109 +106 +104 +101 +99 +95 +93 +91 +87 +85 +82 +79 +77 +73 +71 +68 +70 +73 +76 +79 +81 +84 +87 +89 +92 +95 +97 +100 +103 +105 +108 +111 +113 +116 +118 +121 +124 +126 +129 +131 +134 +137 +139 +141 +144 +147 +149 +151 +154 +157 +159 +161 +163 +166 +168 +170 +172 +175 +177 +180 +181 +183 +185 +187 +189 +191 +192 +194 +196 +197 +198 +200 +201 +202 +203 +203 +203 +204 +204 +204 +205 +204 +204 +203 +202 +202 +201 +200 +198 +197 +195 +194 +193 +191 +189 +187 +185 +184 +181 +179 +177 +175 +173 +170 +168 +166 +164 +162 +158 +157 +154 +152 +149 +146 +144 +142 +139 +136 +134 +132 +129 +126 +123 +121 +118 +116 +113 +110 +108 +105 +102 +100 +97 +95 +92 +89 +87 +84 +81 +78 +76 +73 +70 +67 +70 +72 +75 +77 +81 +83 +86 +89 +91 +94 +97 +99 +102 +104 +107 +110 +113 +115 +118 +120 +123 +125 +128 +131 +132 +135 +138 +141 +142 +145 +147 +150 +152 +155 +158 +160 +162 +164 +167 +168 +171 +173 +175 +177 +179 +181 +184 +185 +187 +188 +190 +192 +193 +195 +196 +196 +198 +199 +200 +200 +201 +201 +201 +202 +202 +201 +201 +201 +200 +199 +198 +197 +196 +194 +193 +192 +190 +189 +187 +185 +183 +182 +180 +177 +176 +173 +171 +169 +167 +165 +162 +160 +157 +155 +153 +150 +148 +146 +143 +141 +138 +136 +133 +131 +128 +126 +123 +120 +117 +115 +112 +110 +107 +105 +102 +99 +97 +94 +91 +89 +86 +83 +80 +77 +75 +72 +69 +66 +69 +72 +74 +77 +79 +82 +85 +87 +90 +93 +96 +98 +100 +104 +106 +108 +111 +113 +116 +119 +121 +124 +126 +129 +132 +134 +136 +139 +141 +144 +146 +149 +151 +154 +155 +158 +160 +163 +165 +167 +169 +172 +174 +175 +177 +179 +181 +183 +185 +186 +188 +189 +190 +192 +194 +194 +196 +196 +197 +197 +198 +198 +198 +199 +199 +198 +198 +198 +197 +196 +196 +194 +194 +192 +190 +189 +187 +186 +185 +183 +181 +180 +177 +175 +173 +172 +169 +167 +164 +162 +160 +158 +155 +154 +151 +149 +146 +143 +141 +139 +136 +134 +132 +129 +127 +124 +122 +119 +117 +114 +111 +109 +106 +103 +100 +98 +95 +92 +90 +88 +85 +82 +79 +77 +74 +71 +68 +65 +68 +71 +73 +76 +78 +82 +84 +86 +90 +92 +94 +97 +99 +102 +105 +107 +110 +113 +115 +117 +120 +122 +126 +128 +130 +132 +136 +137 +140 +143 +145 +147 +149 +152 +154 +156 +159 +161 +163 +166 +168 +169 +172 +174 +175 +177 +179 +180 +182 +184 +186 +187 +188 +190 +190 +191 +193 +193 +194 +195 +196 +195 +196 +196 +195 +196 +195 +194 +194 +194 +193 +192 +191 +189 +188 +186 +186 +184 +182 +181 +179 +177 +175 +173 +171 +170 +167 +165 +163 +161 +159 +157 +154 +152 +150 +147 +144 +143 +140 +137 +135 +133 +130 +128 +125 +123 +120 +117 +115 +112 +110 +108 +105 +103 +99 +97 +94 +91 +89 +87 +84 +81 +78 +76 +73 +71 +68 +64 +67 +70 +72 +75 +77 +81 +83 +85 +88 +91 +93 +96 +99 +101 +104 +107 +109 +112 +114 +117 +119 +121 +124 +126 +129 +132 +133 +136 +138 +141 +143 +145 +148 +150 +152 +155 +157 +159 +161 +163 +165 +167 +169 +171 +173 +175 +177 +179 +180 +182 +183 +185 +186 +187 +188 +189 +190 +191 +191 +192 +193 +193 +193 +193 +193 +192 +192 +192 +192 +191 +190 +189 +188 +187 +186 +184 +183 +181 +180 +178 +176 +175 +173 +172 +170 +167 +166 +163 +161 +159 +157 +154 +153 +151 +148 +146 +143 +141 +139 +136 +133 +132 +128 +127 +124 +121 +119 +116 +114 +112 +109 +106 +103 +101 +98 +96 +94 +91 +88 +86 +83 +80 +77 +75 +72 +70 +67 +63 +66 +69 +71 +74 +76 +79 +82 +85 +87 +90 +92 +95 +98 +100 +102 +105 +107 +110 +113 +115 +118 +120 +122 +125 +128 +130 +132 +135 +137 +140 +141 +144 +146 +149 +151 +153 +155 +157 +159 +161 +163 +166 +168 +170 +171 +172 +174 +176 +178 +179 +180 +182 +183 +185 +185 +186 +187 +188 +189 +190 +190 +189 +190 +190 +190 +190 +189 +189 +189 +188 +187 +186 +186 +184 +183 +182 +181 +179 +178 +176 +175 +172 +170 +169 +167 +165 +163 +161 +159 +157 +155 +153 +151 +149 +146 +144 +142 +139 +137 +135 +132 +130 +128 +125 +122 +121 +118 +115 +112 +110 +107 +105 +102 +100 +98 +94 +93 +89 +87 +84 +82 +80 +77 +74 +72 +69 +66 +62 +65 +67 +71 +73 +76 +78 +80 +83 +86 +88 +91 +93 +96 +99 +101 +104 +106 +109 +111 +114 +117 +118 +121 +124 +126 +129 +130 +133 +135 +137 +140 +142 +144 +147 +149 +151 +153 +155 +157 +159 +161 +164 +166 +167 +169 +170 +172 +174 +175 +176 +178 +180 +181 +182 +183 +184 +185 +185 +186 +186 +186 +187 +187 +187 +188 +187 +187 +186 +186 +185 +185 +184 +183 +181 +180 +180 +178 +176 +176 +174 +172 +170 +169 +167 +165 +163 +161 +160 +158 +156 +154 +152 +149 +147 +145 +142 +140 +138 +136 +133 +131 +128 +126 +124 +121 +119 +116 +114 +111 +109 +106 +104 +102 +98 +96 +94 +91 +89 +86 +84 +81 +78 +75 +73 +70 +68 +65 +61 +64 +67 +69 +72 +75 +77 +80 +83 +85 +88 +90 +92 +95 +97 +100 +103 +105 +108 +110 +112 +115 +118 +120 +122 +125 +127 +129 +132 +134 +136 +139 +140 +142 +145 +147 +149 +151 +153 +156 +157 +159 +161 +163 +164 +166 +168 +170 +172 +173 +174 +175 +176 +178 +179 +180 +181 +182 +182 +184 +183 +184 +184 +185 +185 +184 +184 +184 +184 +184 +182 +182 +182 +180 +179 +178 +177 +176 +174 +173 +171 +170 +168 +167 +165 +163 +161 +159 +157 +156 +153 +152 +149 +147 +145 +142 +140 +138 +136 +134 +132 +129 +127 +124 +122 +120 +117 +115 +113 +110 +108 +105 +103 +100 +98 +95 +92 +90 +88 +85 +82 +80 +77 +75 +72 +69 +66 +64 +61 +63 +66 +69 +71 +74 +76 +79 +81 +83 +86 +89 +91 +93 +96 +99 +101 +104 +106 +108 +111 +114 +116 +119 +121 +123 +125 +128 +130 +132 +135 +137 +139 +141 +144 +145 +147 +149 +151 +153 +156 +157 +159 +161 +163 +164 +166 +168 +169 +171 +171 +173 +175 +175 +177 +178 +179 +179 +179 +181 +181 +181 +181 +182 +182 +182 +181 +181 +181 +180 +180 +179 +179 +177 +177 +175 +174 +173 +171 +170 +169 +167 +165 +165 +163 +161 +159 +157 +155 +154 +151 +150 +147 +145 +143 +141 +139 +137 +134 +132 +130 +127 +125 +123 +121 +118 +116 +114 +111 +108 +106 +104 +101 +99 +96 +93 +91 +89 +87 +84 +81 +79 +76 +73 +71 +69 +65 +63 +59 +62 +65 +67 +70 +73 +74 +77 +80 +82 +85 +87 +90 +93 +95 +98 +99 +103 +105 +107 +110 +112 +114 +117 +119 +121 +123 +125 +128 +130 +132 +135 +137 +139 +141 +143 +146 +148 +149 +151 +154 +155 +157 +158 +160 +162 +163 +165 +166 +168 +169 +171 +172 +173 +174 +175 +175 +176 +177 +178 +178 +179 +179 +179 +179 +179 +179 +178 +178 +178 +177 +177 +176 +175 +174 +173 +171 +170 +169 +168 +166 +165 +164 +162 +161 +159 +157 +155 +153 +152 +149 +147 +145 +143 +141 +139 +137 +135 +133 +131 +128 +126 +124 +122 +119 +117 +114 +112 +110 +107 +105 +102 +100 +98 +95 +93 +90 +87 +84 +82 +80 +78 +75 +72 +70 +67 +65 +62 +59 +61 +63 +66 +68 +71 +73 +76 +79 +81 +83 +86 +88 +91 +93 +96 +99 +101 +103 +106 +108 +110 +113 +116 +117 +120 +122 +124 +127 +129 +131 +133 +135 +137 +139 +141 +143 +146 +147 +149 +151 +153 +155 +156 +158 +160 +161 +163 +164 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +175 +176 +175 +176 +176 +176 +176 +176 +176 +176 +175 +174 +174 +173 +172 +172 +170 +169 +168 +167 +166 +164 +163 +161 +159 +158 +156 +155 +153 +151 +149 +147 +146 +143 +142 +139 +137 +136 +133 +131 +129 +126 +124 +122 +120 +117 +115 +113 +111 +108 +105 +104 +100 +99 +96 +94 +91 +89 +87 +84 +81 +79 +76 +74 +71 +68 +66 +64 +61 +57 +60 +62 +65 +67 +70 +73 +75 +78 +80 +82 +85 +87 +89 +92 +94 +97 +99 +102 +104 +107 +109 +111 +113 +116 +118 +121 +123 +124 +127 +129 +131 +133 +135 +138 +140 +141 +144 +146 +147 +149 +151 +153 +154 +156 +157 +159 +161 +162 +163 +164 +165 +166 +168 +169 +170 +170 +171 +171 +172 +172 +172 +173 +173 +173 +173 +173 +173 +172 +172 +171 +171 +170 +169 +169 +167 +166 +165 +165 +163 +162 +161 +159 +157 +156 +154 +152 +151 +149 +147 +145 +143 +141 +139 +137 +136 +133 +131 +129 +127 +124 +122 +121 +118 +116 +114 +111 +108 +106 +104 +101 +100 +97 +94 +92 +90 +88 +84 +82 +80 +77 +74 +72 +70 +67 +64 +62 +60 +56 +59 +61 +63 +66 +69 +71 +74 +76 +79 +81 +83 +86 +89 +91 +93 +96 +98 +100 +102 +105 +107 +110 +112 +114 +116 +119 +121 +123 +125 +128 +130 +131 +133 +136 +138 +139 +141 +143 +145 +147 +148 +150 +151 +154 +154 +156 +158 +159 +160 +162 +163 +164 +165 +166 +167 +168 +168 +169 +170 +170 +170 +170 +170 +171 +171 +170 +170 +170 +169 +169 +168 +167 +167 +166 +165 +164 +163 +161 +160 +159 +158 +156 +155 +154 +152 +151 +149 +147 +145 +143 +142 +140 +138 +135 +133 +131 +129 +127 +125 +123 +121 +118 +116 +114 +112 +110 +107 +105 +102 +100 +98 +96 +93 +90 +88 +86 +83 +81 +79 +76 +74 +71 +68 +66 +63 +61 +59 +54 +57 +60 +62 +65 +67 +69 +73 +75 +77 +80 +82 +84 +86 +90 +92 +94 +97 +98 +101 +103 +105 +108 +110 +112 +114 +117 +119 +121 +124 +125 +127 +129 +131 +134 +136 +137 +139 +142 +142 +144 +146 +148 +150 +151 +153 +154 +156 +157 +158 +159 +161 +162 +162 +163 +164 +165 +165 +166 +167 +167 +167 +168 +168 +168 +168 +168 +167 +167 +166 +166 +166 +165 +164 +163 +162 +161 +160 +159 +158 +157 +155 +154 +152 +152 +150 +148 +146 +144 +143 +141 +139 +137 +135 +134 +132 +130 +127 +125 +123 +121 +119 +116 +115 +113 +110 +108 +106 +103 +101 +99 +97 +94 +92 +89 +87 +84 +82 +80 +77 +74 +72 +69 +67 +65 +62 +59 +57 +53 +56 +59 +61 +64 +66 +68 +70 +73 +75 +78 +80 +83 +85 +88 +90 +92 +95 +97 +99 +102 +104 +107 +108 +110 +113 +115 +117 +119 +122 +124 +125 +127 +130 +132 +133 +135 +137 +139 +140 +142 +144 +146 +147 +149 +151 +152 +153 +154 +156 +157 +158 +159 +159 +160 +162 +162 +163 +163 +163 +164 +164 +165 +164 +165 +165 +165 +165 +164 +164 +163 +163 +162 +162 +160 +160 +159 +158 +157 +156 +155 +153 +152 +150 +149 +147 +145 +144 +142 +141 +139 +137 +135 +133 +131 +130 +128 +125 +123 +122 +119 +118 +115 +113 +111 +108 +106 +104 +101 +99 +97 +95 +92 +90 +88 +85 +83 +81 +78 +76 +73 +71 +68 +66 +63 +61 +59 +56 +52 +55 +57 +60 +62 +64 +67 +69 +72 +74 +76 +79 +81 +84 +86 +89 +91 +94 +96 +97 +100 +103 +105 +107 +109 +111 +113 +115 +117 +119 +121 +124 +126 +127 +129 +131 +133 +134 +136 +139 +140 +142 +143 +144 +147 +148 +149 +151 +151 +153 +154 +155 +156 +157 +158 +159 +159 +160 +161 +161 +161 +162 +162 +162 +162 +162 +161 +161 +161 +161 +161 +160 +159 +159 +158 +157 +156 +155 +154 +153 +152 +150 +150 +148 +147 +145 +144 +141 +140 +138 +136 +135 +134 +132 +129 +127 +125 +124 +121 +120 +117 +115 +113 +111 +109 +107 +104 +102 +100 +98 +96 +93 +91 +88 +87 +84 +82 +79 +76 +74 +71 +70 +67 +64 +62 +60 +57 +55 +51 +54 +56 +58 +61 +63 +66 +68 +70 +73 +75 +78 +80 +82 +84 +87 +89 +91 +94 +96 +99 +100 +102 +104 +107 +110 +111 +113 +116 +117 +120 +122 +123 +125 +128 +129 +131 +133 +134 +136 +137 +139 +140 +143 +144 +145 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +157 +158 +158 +159 +158 +159 +159 +159 +159 +159 +159 +158 +158 +158 +157 +156 +156 +155 +155 +153 +153 +152 +150 +149 +148 +147 +145 +144 +142 +140 +140 +138 +136 +135 +133 +131 +129 +127 +125 +123 +121 +119 +118 +115 +113 +111 +109 +107 +104 +102 +101 +98 +96 +94 +92 +89 +87 +84 +83 +80 +77 +76 +73 +70 +68 +66 +64 +61 +58 +56 +53 +49 +52 +55 +57 +60 +62 +64 +67 +69 +71 +73 +76 +79 +81 +83 +86 +88 +90 +92 +95 +96 +98 +101 +104 +105 +108 +110 +112 +113 +115 +118 +119 +121 +123 +125 +127 +128 +131 +132 +133 +135 +137 +138 +140 +142 +143 +144 +145 +147 +148 +149 +150 +151 +151 +152 +154 +153 +154 +155 +156 +155 +156 +157 +157 +156 +156 +156 +156 +156 +155 +155 +154 +154 +153 +152 +152 +150 +150 +149 +147 +146 +146 +144 +143 +142 +141 +139 +137 +135 +134 +132 +130 +129 +127 +125 +123 +121 +120 +117 +116 +113 +112 +109 +108 +105 +103 +101 +98 +97 +94 +92 +90 +88 +86 +83 +81 +78 +76 +73 +71 +69 +67 +64 +62 +59 +57 +54 +51 +48 +50 +53 +55 +58 +61 +63 +65 +68 +70 +72 +75 +77 +79 +81 +84 +85 +88 +91 +93 +95 +97 +100 +101 +103 +106 +107 +110 +112 +114 +116 +117 +120 +121 +123 +124 +127 +128 +130 +131 +133 +135 +136 +137 +139 +141 +142 +143 +144 +145 +146 +147 +148 +149 +149 +150 +151 +152 +152 +153 +153 +153 +154 +153 +153 +153 +153 +153 +153 +153 +152 +152 +151 +150 +150 +149 +149 +148 +146 +145 +144 +143 +141 +140 +139 +138 +136 +135 +133 +131 +130 +129 +127 +125 +123 +121 +119 +118 +115 +114 +112 +109 +108 +105 +104 +101 +99 +97 +95 +93 +91 +88 +86 +84 +81 +79 +77 +74 +73 +70 +68 +66 +63 +60 +58 +56 +53 +51 +47 +50 +51 +54 +56 +58 +61 +63 +65 +69 +71 +73 +75 +78 +80 +82 +84 +86 +89 +91 +93 +95 +97 +100 +102 +103 +105 +108 +109 +112 +114 +115 +117 +119 +120 +122 +124 +126 +128 +129 +130 +132 +134 +135 +136 +138 +139 +140 +141 +143 +143 +144 +145 +146 +147 +148 +148 +148 +150 +150 +150 +150 +151 +151 +151 +151 +150 +150 +151 +149 +150 +149 +148 +148 +147 +147 +146 +145 +144 +143 +141 +140 +139 +138 +137 +135 +133 +132 +130 +130 +127 +126 +124 +122 +121 +119 +117 +115 +114 +112 +109 +108 +105 +104 +101 +99 +97 +95 +93 +90 +89 +87 +84 +82 +79 +78 +75 +73 +71 +68 +66 +64 +61 +59 +56 +54 +52 +49 +45 +48 +50 +53 +55 +57 +60 +62 +64 +67 +69 +71 +73 +76 +79 +80 +82 +85 +87 +89 +91 +94 +95 +97 +100 +102 +104 +106 +107 +109 +111 +113 +115 +117 +119 +120 +122 +124 +125 +127 +129 +130 +131 +133 +134 +136 +137 +138 +139 +140 +141 +142 +142 +144 +144 +145 +146 +146 +147 +147 +147 +148 +148 +148 +148 +148 +148 +148 +147 +147 +147 +146 +145 +145 +144 +144 +143 +142 +141 +140 +139 +138 +137 +135 +134 +133 +132 +130 +128 +127 +125 +124 +122 +120 +119 +117 +115 +114 +111 +109 +108 +105 +104 +101 +100 +98 +95 +94 +92 +89 +87 +85 +82 +80 +78 +76 +73 +71 +69 +67 +64 +62 +60 +57 +55 +52 +50 +47 +44 +46 +49 +51 +54 +56 +58 +61 +63 +65 +67 +70 +72 +74 +76 +78 +81 +83 +85 +87 +89 +92 +93 +96 +98 +99 +101 +103 +106 +107 +110 +111 +113 +115 +116 +118 +120 +121 +123 +125 +126 +128 +129 +130 +131 +133 +134 +135 +136 +137 +138 +139 +140 +141 +141 +142 +143 +143 +143 +144 +145 +145 +145 +146 +145 +145 +145 +145 +145 +144 +144 +144 +143 +142 +141 +141 +140 +140 +138 +138 +137 +135 +134 +133 +131 +130 +129 +128 +126 +124 +123 +121 +119 +118 +117 +115 +113 +111 +109 +107 +105 +104 +102 +99 +97 +96 +93 +91 +90 +87 +85 +83 +81 +78 +77 +74 +72 +70 +67 +65 +63 +61 +58 +56 +54 +51 +48 +47 +43 +45 +47 +49 +52 +54 +56 +59 +61 +64 +66 +68 +70 +73 +74 +77 +79 +82 +84 +85 +88 +90 +92 +94 +96 +97 +100 +102 +103 +105 +107 +109 +111 +113 +114 +116 +117 +119 +121 +123 +124 +125 +126 +127 +129 +130 +131 +133 +134 +134 +135 +137 +138 +138 +138 +140 +140 +141 +141 +142 +142 +142 +142 +142 +142 +142 +143 +142 +142 +142 +141 +141 +141 +139 +139 +138 +137 +137 +135 +135 +134 +133 +132 +130 +129 +127 +127 +125 +124 +122 +120 +119 +118 +116 +114 +113 +111 +109 +107 +105 +104 +102 +100 +98 +96 +93 +91 +90 +87 +85 +84 +81 +79 +77 +74 +72 +70 +68 +66 +63 +61 +59 +56 +54 +52 +49 +47 +45 +41 +44 +45 +48 +50 +52 +55 +57 +59 +61 +64 +66 +68 +71 +72 +75 +78 +79 +82 +84 +86 +88 +90 +91 +93 +96 +98 +99 +102 +103 +105 +106 +108 +111 +112 +113 +115 +117 +119 +120 +121 +123 +124 +126 +127 +127 +129 +130 +131 +132 +133 +134 +135 +135 +136 +136 +137 +137 +139 +138 +139 +139 +139 +139 +139 +139 +139 +140 +139 +139 +139 +138 +137 +137 +136 +135 +135 +134 +133 +132 +131 +130 +129 +128 +127 +125 +124 +123 +121 +120 +118 +116 +115 +113 +111 +110 +108 +107 +105 +103 +102 +99 +97 +95 +93 +91 +90 +87 +86 +83 +81 +80 +77 +75 +73 +70 +68 +66 +64 +62 +60 +58 +55 +52 +51 +48 +46 +43 +39 +42 +44 +46 +49 +50 +53 +56 +58 +60 +62 +65 +67 +69 +71 +74 +76 +78 +79 +81 +84 +86 +87 +90 +91 +94 +96 +97 +99 +101 +103 +105 +106 +108 +109 +111 +112 +115 +116 +117 +118 +120 +122 +122 +124 +125 +127 +128 +129 +129 +130 +132 +132 +133 +133 +134 +135 +135 +136 +136 +136 +136 +136 +137 +137 +137 +136 +137 +136 +136 +136 +135 +135 +134 +133 +132 +132 +131 +131 +129 +128 +127 +127 +125 +124 +123 +121 +120 +119 +117 +116 +114 +112 +112 +110 +107 +107 +105 +103 +101 +99 +98 +96 +93 +91 +90 +87 +86 +84 +82 +79 +77 +75 +73 +71 +69 +67 +64 +62 +60 +58 +55 +54 +51 +49 +46 +44 +41 +38 +40 +43 +45 +47 +49 +51 +54 +56 +58 +61 +62 +65 +67 +69 +72 +73 +76 +77 +80 +81 +83 +85 +88 +90 +92 +94 +96 +97 +99 +101 +102 +104 +106 +107 +109 +110 +112 +114 +115 +116 +118 +119 +120 +121 +122 +124 +125 +126 +127 +127 +128 +129 +130 +131 +131 +132 +132 +132 +133 +133 +134 +134 +134 +134 +134 +134 +133 +134 +133 +132 +133 +131 +132 +131 +130 +129 +128 +128 +126 +126 +125 +124 +122 +121 +120 +119 +118 +116 +115 +114 +112 +111 +109 +107 +106 +104 +102 +101 +98 +97 +95 +93 +91 +90 +87 +86 +84 +82 +80 +78 +75 +73 +72 +69 +67 +65 +63 +60 +59 +56 +53 +51 +49 +47 +45 +43 +40 +36 +39 +41 +44 +45 +48 +50 +52 +55 +57 +59 +61 +63 +65 +67 +69 +71 +74 +76 +78 +80 +81 +84 +86 +87 +89 +91 +93 +95 +97 +99 +100 +101 +103 +105 +106 +109 +109 +111 +113 +114 +115 +117 +117 +119 +120 +121 +122 +123 +124 +125 +126 +126 +127 +128 +128 +129 +130 +130 +130 +130 +131 +131 +131 +131 +131 +131 +131 +131 +130 +130 +129 +129 +128 +128 +127 +126 +126 +125 +124 +124 +122 +121 +120 +119 +117 +116 +116 +113 +113 +111 +109 +108 +107 +105 +103 +102 +100 +99 +97 +94 +93 +91 +89 +88 +85 +83 +81 +80 +78 +76 +73 +72 +70 +67 +65 +63 +61 +59 +56 +54 +52 +50 +48 +46 +43 +41 +38 +34 +37 +39 +41 +44 +46 +48 +50 +53 +55 +57 +59 +61 +63 +66 +68 +70 +71 +73 +76 +77 +79 +82 +84 +85 +87 +89 +91 +93 +94 +96 +98 +100 +101 +103 +104 +106 +107 +108 +110 +112 +112 +114 +115 +116 +118 +119 +119 +121 +121 +122 +123 +124 +125 +125 +126 +127 +127 +127 +127 +128 +128 +128 +128 +129 +128 +128 +128 +128 +128 +127 +127 +126 +126 +125 +124 +124 +123 +122 +122 +120 +120 +118 +118 +116 +115 +114 +113 +111 +110 +108 +107 +106 +104 +103 +101 +100 +97 +96 +94 +92 +91 +89 +87 +86 +84 +82 +80 +78 +76 +73 +72 +70 +68 +66 +63 +61 +59 +56 +55 +53 +51 +48 +46 +44 +41 +40 +37 +33 +35 +37 +39 +42 +44 +46 +49 +51 +53 +55 +57 +59 +62 +63 +66 +67 +69 +71 +74 +76 +78 +80 +81 +84 +86 +87 +89 +90 +92 +94 +95 +97 +98 +100 +102 +104 +104 +106 +108 +109 +110 +111 +112 +114 +114 +116 +116 +118 +118 +120 +121 +121 +122 +123 +123 +123 +124 +124 +125 +125 +125 +126 +126 +125 +126 +125 +125 +125 +125 +125 +124 +123 +123 +123 +122 +121 +120 +120 +119 +118 +117 +116 +115 +113 +112 +111 +110 +109 +108 +107 +105 +103 +102 +100 +99 +97 +95 +94 +93 +90 +88 +87 +85 +83 +82 +80 +77 +76 +73 +72 +70 +68 +66 +63 +61 +59 +58 +56 +53 +51 +49 +47 +44 +42 +40 +37 +36 +31 +33 +36 +38 +41 +42 +45 +47 +49 +51 +53 +55 +57 +60 +61 +64 +65 +68 +70 +71 +74 +76 +77 +80 +81 +83 +85 +87 +89 +90 +92 +93 +95 +96 +98 +99 +101 +103 +104 +105 +107 +108 +108 +110 +111 +112 +113 +114 +115 +116 +117 +118 +118 +119 +120 +120 +121 +121 +122 +122 +122 +123 +122 +123 +122 +122 +123 +122 +123 +122 +122 +121 +120 +120 +120 +119 +119 +118 +117 +116 +115 +114 +113 +112 +111 +110 +109 +108 +106 +105 +104 +102 +101 +99 +98 +97 +95 +93 +92 +90 +88 +86 +84 +83 +81 +79 +77 +76 +73 +72 +70 +68 +66 +64 +62 +60 +58 +56 +53 +52 +49 +47 +44 +42 +40 +38 +36 +34 +29 +32 +34 +36 +38 +41 +43 +45 +47 +50 +52 +54 +56 +58 +60 +62 +64 +66 +68 +70 +71 +74 +75 +77 +79 +81 +83 +85 +86 +88 +89 +91 +92 +94 +95 +97 +99 +100 +101 +102 +104 +105 +106 +107 +108 +110 +111 +111 +113 +113 +114 +115 +116 +117 +117 +118 +118 +118 +119 +119 +119 +120 +120 +120 +120 +120 +120 +119 +120 +119 +119 +118 +118 +117 +117 +116 +116 +115 +114 +113 +113 +111 +110 +109 +108 +108 +107 +105 +104 +102 +101 +99 +98 +97 +95 +94 +92 +91 +89 +87 +86 +84 +83 +80 +79 +77 +76 +74 +72 +69 +68 +66 +64 +61 +60 +57 +55 +53 +51 +49 +47 +45 +43 +41 +39 +37 +34 +32 +28 +31 +33 +35 +37 +39 +41 +43 +46 +47 +50 +51 +53 +56 +58 +60 +61 +64 +65 +67 +70 +72 +73 +75 +77 +79 +80 +82 +83 +85 +87 +89 +90 +92 +93 +95 +96 +97 +99 +100 +102 +102 +103 +105 +106 +106 +108 +109 +110 +111 +111 +112 +113 +113 +114 +115 +115 +116 +116 +117 +116 +117 +117 +117 +116 +117 +117 +117 +117 +116 +115 +116 +115 +114 +114 +113 +113 +112 +111 +111 +110 +109 +108 +107 +106 +104 +104 +102 +101 +100 +98 +98 +96 +94 +93 +92 +90 +89 +87 +86 +84 +82 +81 +78 +77 +75 +73 +72 +69 +68 +66 +63 +61 +60 +57 +56 +54 +51 +50 +48 +46 +43 +41 +39 +37 +35 +32 +30 +27 +29 +31 +33 +35 +37 +39 +41 +43 +45 +48 +50 +52 +54 +56 +58 +59 +62 +64 +65 +68 +69 +71 +73 +74 +77 +78 +80 +81 +83 +84 +86 +88 +90 +90 +92 +94 +95 +96 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +110 +111 +112 +112 +112 +113 +113 +113 +113 +114 +114 +114 +114 +114 +114 +114 +113 +113 +114 +113 +112 +112 +111 +110 +110 +110 +109 +108 +107 +106 +105 +104 +104 +102 +101 +100 +99 +98 +96 +95 +93 +92 +91 +89 +87 +86 +85 +83 +81 +80 +78 +76 +74 +72 +71 +69 +68 +66 +63 +62 +60 +57 +56 +53 +52 +50 +47 +46 +44 +41 +39 +37 +35 +33 +31 +28 +25 +27 +29 +31 +33 +36 +37 +40 +41 +43 +46 +48 +50 +52 +54 +56 +58 +60 +61 +63 +65 +68 +69 +71 +72 +74 +75 +78 +79 +81 +82 +84 +85 +87 +88 +90 +91 +92 +93 +95 +96 +98 +98 +100 +101 +101 +102 +104 +105 +106 +106 +107 +108 +108 +109 +110 +110 +110 +110 +111 +111 +111 +111 +111 +112 +111 +111 +111 +111 +111 +110 +110 +109 +109 +109 +108 +107 +106 +106 +105 +105 +103 +103 +101 +101 +100 +98 +97 +96 +95 +94 +92 +91 +90 +89 +87 +85 +84 +82 +81 +79 +77 +76 +74 +72 +71 +69 +67 +66 +63 +61 +60 +58 +55 +53 +52 +49 +47 +45 +43 +42 +39 +38 +35 +34 +31 +29 +27 +22 +25 +27 +29 +31 +34 +35 +37 +40 +42 +44 +46 +48 +50 +52 +54 +56 +58 +59 +61 +63 +64 +66 +68 +71 +72 +74 +75 +77 +79 +80 +81 +83 +84 +85 +87 +89 +90 +91 +92 +93 +95 +96 +97 +98 +99 +100 +101 +102 +102 +103 +104 +105 +105 +105 +106 +107 +108 +107 +108 +108 +108 +109 +108 +108 +108 +108 +109 +108 +108 +108 +107 +107 +107 +105 +105 +105 +104 +103 +102 +102 +101 +100 +99 +98 +97 +96 +95 +93 +92 +91 +90 +88 +87 +86 +84 +83 +82 +80 +78 +77 +75 +74 +72 +70 +69 +66 +65 +63 +61 +60 +57 +56 +54 +51 +49 +48 +46 +43 +41 +40 +38 +35 +33 +31 +29 +27 +25 +21 +23 +25 +27 +29 +32 +33 +36 +38 +40 +42 +44 +46 +48 +50 +52 +54 +55 +57 +59 +61 +63 +64 +66 +68 +70 +71 +73 +74 +76 +77 +80 +81 +82 +84 +85 +86 +87 +89 +90 +92 +92 +93 +94 +95 +96 +97 +98 +99 +99 +100 +102 +102 +103 +103 +104 +104 +104 +105 +105 +105 +105 +105 +106 +106 +105 +105 +105 +106 +105 +105 +105 +104 +104 +103 +102 +102 +101 +101 +100 +99 +98 +97 +97 +95 +94 +94 +93 +91 +89 +88 +88 +86 +84 +83 +82 +80 +79 +77 +76 +75 +72 +71 +69 +68 +66 +65 +62 +61 +59 +58 +56 +54 +51 +50 +48 +46 +44 +42 +40 +38 +36 +34 +31 +30 +27 +25 +23 +19 +22 +24 +26 +27 +30 +32 +34 +36 +38 +39 +42 +43 +46 +47 +50 +51 +53 +55 +57 +58 +60 +63 +64 +66 +67 +69 +70 +73 +74 +75 +76 +78 +80 +81 +83 +83 +85 +86 +87 +89 +90 +91 +92 +93 +94 +95 +95 +96 +97 +98 +98 +99 +100 +100 +101 +102 +101 +102 +103 +103 +103 +102 +103 +103 +102 +102 +103 +102 +103 +102 +102 +101 +101 +100 +100 +100 +99 +98 +98 +97 +96 +94 +93 +93 +92 +91 +90 +89 +87 +87 +85 +83 +83 +81 +80 +78 +77 +75 +74 +72 +71 +69 +68 +65 +64 +63 +61 +59 +57 +55 +54 +51 +50 +47 +46 +44 +42 +40 +38 +36 +34 +32 +30 +28 +25 +24 +22 +17 +19 +21 +23 +25 +28 +30 +31 +34 +36 +37 +40 +42 +43 +46 +47 +50 +51 +53 +54 +57 +58 +60 +62 +64 +65 +67 +68 +70 +72 +73 +74 +76 +77 +79 +80 +81 +83 +83 +85 +86 +87 +88 +89 +91 +91 +92 +92 +93 +95 +95 +96 +96 +97 +98 +98 +99 +99 +99 +99 +100 +100 +100 +100 +100 +100 +100 +100 +100 +99 +99 +98 +99 +98 +97 +97 +97 +96 +95 +94 +94 +92 +92 +91 +90 +89 +89 +87 +86 +84 +84 +82 +81 +80 +79 +77 +75 +74 +73 +71 +70 +68 +67 +65 +63 +62 +60 +59 +56 +55 +53 +51 +49 +47 +46 +44 +42 +40 +38 +36 +34 +32 +29 +28 +25 +24 +21 +19 +16 +18 +19 +22 +24 +26 +28 +30 +31 +34 +36 +38 +40 +42 +44 +45 +47 +49 +50 +52 +54 +56 +57 +59 +61 +62 +65 +66 +67 +69 +71 +72 +73 +75 +76 +78 +79 +80 +81 +83 +83 +85 +86 +86 +87 +88 +89 +90 +91 +91 +92 +93 +94 +95 +95 +95 +95 +96 +96 +97 +97 +97 +97 +97 +97 +97 +98 +97 +97 +97 +96 +96 +96 +95 +95 +94 +94 +93 +92 +92 +91 +90 +89 +88 +87 +86 +86 +84 +83 +82 +81 +80 +78 +77 +76 +75 +73 +72 +71 +69 +68 +66 +64 +63 +61 +59 +58 +56 +54 +53 +50 +49 +47 +45 +44 +42 +40 +38 +35 +33 +32 +29 +28 +26 +24 +22 +19 +17 +13 +16 +18 +19 +22 +24 +26 +28 +30 +31 +34 +36 +38 +40 +42 +43 +45 +47 +48 +50 +52 +54 +55 +57 +59 +60 +62 +63 +65 +67 +68 +69 +71 +72 +74 +75 +76 +77 +79 +80 +81 +82 +82 +84 +85 +86 +87 +88 +88 +89 +89 +91 +91 +92 +92 +93 +93 +94 +93 +94 +94 +94 +94 +94 +95 +95 +95 +95 +94 +94 +94 +93 +93 +93 +92 +92 +91 +90 +89 +89 +88 +88 +87 +85 +84 +84 +82 +82 +80 +79 +79 +78 +76 +75 +73 +72 +70 +69 +68 +66 +65 +63 +62 +61 +59 +58 +56 +54 +52 +50 +48 +47 +45 +44 +41 +39 +37 +35 +34 +31 +30 +28 +26 +24 +22 +20 +18 +16 +12 +14 +16 +18 +20 +22 +24 +26 +28 +30 +32 +33 +36 +38 +39 +41 +43 +45 +46 +48 +50 +52 +54 +55 +57 +58 +59 +61 +63 +64 +65 +67 +68 +69 +71 +72 +74 +75 +76 +77 +78 +79 +80 +82 +82 +83 +84 +84 +86 +87 +87 +88 +88 +89 +89 +90 +90 +90 +90 +91 +91 +91 +92 +92 +92 +92 +91 +91 +92 +91 +91 +91 +90 +89 +89 +88 +88 +87 +87 +86 +85 +85 +84 +84 +82 +81 +80 +79 +78 +77 +76 +75 +74 +72 +71 +70 +68 +67 +66 +64 +63 +61 +60 +58 +56 +55 +53 +52 +50 +48 +46 +45 +43 +41 +39 +38 +36 +34 +32 +30 +28 +26 +24 +22 +20 +18 +15 +14 +9 +12 +14 +16 +18 +20 +22 +24 +25 +28 +30 +32 +34 +35 +37 +39 +41 +42 +44 +46 +48 +49 +50 +53 +54 +56 +58 +59 +60 +62 +63 +65 +66 +67 +69 +70 +71 +72 +73 +74 +75 +76 +78 +78 +80 +81 +81 +82 +83 +83 +85 +85 +86 +86 +86 +86 +88 +88 +87 +88 +89 +89 +88 +89 +89 +89 +88 +89 +88 +88 +88 +88 +88 +87 +87 +86 +85 +85 +84 +84 +83 +82 +81 +81 +80 +79 +78 +77 +76 +75 +73 +72 +71 +70 +68 +67 +66 +64 +63 +62 +60 +59 +57 +56 +54 +53 +51 +49 +48 +46 +45 +43 +41 +39 +37 +35 +34 +31 +30 +28 +26 +24 +22 +20 +18 +16 +14 +12 +8 +10 +12 +14 +16 +18 +20 +22 +24 +25 +27 +29 +32 +33 +35 +37 +38 +40 +41 +44 +45 +48 +49 +50 +52 +53 +55 +56 +57 +60 +61 +62 +63 +65 +66 +67 +68 +69 +71 +72 +73 +74 +75 +76 +76 +78 +79 +79 +80 +80 +81 +82 +83 +83 +83 +84 +85 +85 +85 +86 +86 +86 +86 +86 +86 +86 +86 +86 +85 +85 +85 +85 +84 +84 +83 +83 +82 +82 +81 +81 +80 +79 +79 +78 +77 +75 +75 +74 +73 +72 +71 +69 +69 +67 +66 +65 +63 +62 +61 +59 +58 +57 +55 +54 +52 +50 +48 +47 +45 +44 +42 +40 +38 +36 +35 +33 +31 +30 +27 +26 +23 +22 +20 +18 +16 +14 +12 +10 +5 +8 +10 +12 +14 +16 +18 +20 +22 +24 +25 +27 +29 +31 +33 +34 +36 +38 +40 +42 +43 +45 +47 +48 +49 +52 +52 +54 +55 +56 +58 +60 +60 +62 +63 +65 +66 +67 +68 +69 +71 +72 +72 +73 +74 +75 +76 +77 +77 +78 +78 +79 +80 +80 +81 +82 +82 +82 +82 +82 +83 +83 +83 +83 +84 +83 +83 +82 +83 +82 +82 +82 +81 +81 +80 +81 +80 +80 +79 +78 +77 +77 +76 +75 +74 +74 +72 +72 +71 +69 +68 +67 +66 +64 +63 +62 +60 +60 +58 +57 +55 +54 +53 +51 +50 +48 +47 +45 +43 +41 +39 +38 +36 +34 +33 +31 +29 +27 +25 +23 +22 +20 +18 +16 +14 +12 +10 +8 +4 +6 +8 +10 +12 +14 +16 +17 +19 +21 +24 +25 +27 +29 +30 +33 +34 +36 +38 +39 +41 +43 +44 +46 +47 +49 +50 +52 +53 +55 +56 +57 +58 +60 +61 +62 +63 +65 +65 +67 +67 +68 +70 +71 +71 +72 +73 +74 +75 +75 +76 +76 +77 +77 +78 +79 +79 +79 +79 +80 +80 +80 +81 +81 +81 +80 +81 +80 +80 +80 +79 +79 +79 +79 +78 +78 +77 +77 +76 +75 +75 +74 +73 +72 +71 +71 +70 +69 +68 +67 +66 +65 +64 +62 +61 +60 +59 +57 +56 +54 +53 +52 +50 +48 +47 +46 +44 +43 +41 +39 +37 +36 +34 +33 +30 +29 +27 +26 +23 +21 +20 +18 +16 +13 +11 +10 +8 +6 +2 +4 +6 +8 +10 +11 +14 +16 +18 +19 +21 +23 +25 +27 +29 +30 +32 +33 +35 +37 +39 +40 +42 +43 +45 +46 +48 +49 +51 +52 +53 +55 +56 +57 +58 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +69 +70 +71 +71 +72 +73 +74 +74 +74 +76 +75 +77 +77 +77 +77 +77 +78 +77 +77 +78 +77 +77 +77 +77 +77 +77 +77 +77 +76 +75 +75 +74 +74 +73 +73 +72 +71 +71 +70 +69 +68 +67 +66 +65 +64 +63 +62 +60 +60 +59 +57 +56 +54 +54 +52 +50 +49 +48 +46 +44 +43 +42 +40 +38 +37 +35 +33 +32 +30 +28 +27 +25 +23 +22 +20 +18 +16 +14 +11 +10 +8 +6 +4 diff --git a/extra/images/testing/pgm/radial.binary.fig b/extra/images/testing/pgm/radial.binary.fig new file mode 100644 index 0000000000000000000000000000000000000000..6e52311b94202145e080cf8f4dc7794d43490754 GIT binary patch literal 16443 zcmZ9T2UM45md0muW@ocgQpR*m>?KBHH1-l3Dk?U>E+~p(Lr@Ux6$BA07Bpg4?AS%@ z*n6zlH5wB&F~*p(nVCJizvsT+AIW@C(K&O@ZO?t)``-87;P{xtevx4jy<;Z1A7P1M z6QciP9KYgY#s@@=kB^x#wCC{H-W7XAMMg&r>OCknCTjekhA%bv!yjJyNRTCs$HjUz54YVHf+?mv0sy>&6@f9 z`!{c4U&|IP`K7-$Z{FPBzgg2JO`0@r)Tm*D`k&RSTc>udnl-9d{j~BYA6NXS{D)=B zlqylY==+7=d-v@(3;q4ISN{6vm;dy~mwe*?{>Gbczf<`AqQy#-ERFb&B)y7BM|i#Z z4H`8gU(Eu~evAr%tV!)ulltH2Cnt zGNntFDE7hog-wB1odRb4E3ZlXyM?j7M5)qc%Y9Vg<4TpQd|It~&Dyo=*8QwLmizg= zklngf>(*`BwrTs~YtyDRA6lRUDl~1{#A$#N(4d-WP(dz00bKCz+i&?iAm<~#&|7c6 zhxNrVzAVO9!u3e6RU5}QK)SOWyRo?qg4?xg7Z?~6807l``OpS6oC@gB#IG@N_^cj2 zP!OtoQi&jxD^seZV({)eZ@pn5_^+4$+lhbY-NGLfmG2dKjIUa)M$OuF>Y44%?Iv8J z0|SGDf`fzGcWB>%&;8M!{~;(SupLU^hXC_J6F)zvLG4;Ks#UE*5Gs@}SJo6L^4{B? z0%rXiSYPCWqQy%|e8q~N;Ce~N^9>pi^=5?JEN_dM!R^~4vSY_iojU7RXMT0!>)27c zv=8S0(XK6SaB;u~4H|$01wlBJ0)U|C2Swg{=S}l~tbfA+zeFj|_c9*P%k_=1-J}!n zc0oZ1M|9`TT{?H^(zR>XZuzjo=2CQ_n(u-ssQXyKyJpnknNwQHIS1jDkWOBF9B z1@OSDue|cACtlW4FxW z@>Nh6n)^2e2Mx(axj->MfpS8jQ{eU2UVYtXeM!=;LPZC>+6H=(okS04h3SFB+YHBO zliZ_6k1%~bd-eP*^Yoh_~3|{Bq?hh;s0~ zBHyr)pGhaxgRv~C}K+B2&o_^bRi1h zpluuIz+&Jj;PMa<8WFu`tXI~>9^k`xWS#jQ<3XKlm-Jq}!ezIKj*J{MXi$`W(e~${ zK~iKu|9<`O0+H}E5E4-UHUNg?LA|=Ql?EaL17VTE?-dd0mIe8h6#LqBywJA{Xx$dq zcW|~7^zhyh5q_&9_u;Igo4All2n&LXfygL8 z3djSsYgYTzAW)_x!7u;O$DdTGRvqzjK70?`2jTm!_+G~M?Kc412M;0O7;du1j2Sa_ z?6~}IET6O(ITA<2#o+|=0WRo`3qnJHp+L~uJYYOfgR=l4EL&RD4y;>M;?4Tz0j)qD zxF_ih^|)T1kCEw4xI~X1KYqeQ@0&1T0{LU$PCqlc!Fb zHhubx88h9-&l%IvLn@>YiA2+YAPkF(1%^@p6nYqF*Cqf3{73>tfSUX;=gmt`pFe;8f(7#z z@FP7v9X(KD7Lk}HBqU8rm;ee!jt~lA0x%#CC<%x_OCW#)pusAYtE%8p>fwEYFY!Hk z3i**(ABXtSiaf^S`ROxedcu+X`ND+@Gx%@e!q53oBOMje($Ih?Oiq>p7K6Ch!O?>( z3&KbODL@j6hI9~oO1VkulX^xxV6Q9KQ|#sZIFcUm6HWZoX`XbGosqF<(W1qCOBOHY zZy6cr;At>RQAkOil&BaGf;jTf(vU2)2pA1<5($EsUsnZ>rCxA;@cRpT5C$E1w{+=JX@L$4<`V~^KoE$*3k8Nm!No2KI*SD?2`PzdRafqL z-fs)-D)`DgL%unGLPBB^z?(K>R@$7o>GP3}aLHc2f^Vh16)To6U$%6~lEsS%#e5V< zlMAK@hRy>+;Q>=1th>hoDu?8NnwW3kYoSwz%n$8B=81HLe4LMXLO*r-%vrPN%$vVJ zrY~8F?3Jrlt;$@TxtcFCGjkP6NC#=KAblP{1O-!4l!z7rfzZRC%K>wM5Fp}L^aI*J z`<=UT;)a7gPMp{{6F<=>UdGFI6TT9`Yu2t=yKddOwd?q~W_9MORj9Dcd_WLf3??T_ z0i|K=kSH)n1bT27cL){>84cGq^PBo}=3{=BZc4p=cwgd2$a(=^z?1QxXJGsCl?a#Q z_3Jly-}?2au|_(q#0QHq76OCWX*2PF6c|5t)JT|6G|*QxBo+#6+sc=NochW=XTA^n zgJZ$o=rN>yl8JY|UxaiVzj_VAH*DOPm9@#ftgNh!8#k;+h1HoWS1w<=gdohHH-}7| zn(9CZ6A}SfAOZ)F1D1p4fVy=={LL|6sgL>ceq{6z1%J#q6F+r2p*PG#M|f7& z=FOY8Y}snxmMxn%Z_3)R0WY9|V31)joFxxTN`#0;!9zoognhydf)u2l161@Bh(5$8 z?8kEAnfDEPX>;ev_e+=I`ZY3rlSFUZzJ2=+ecQKh+qQMfmQARze(jpfRVzRNshB<| zO$rzhjaCFW37|no0%Ac@fMbZ{BljVG(`HIZdYuA}{ zgzwn7b7%H0ec9PNckbAM3Y)VCgMzS}L~tRPJ{2MYgT4s#i!cX(0C7MQF6IsWuhu2_}1X6^b7S(~?P+qOfZb9VFX*}Xf54;^-FM}tip z*RNZn7{~+j=D-7~%EEEtK?))u*t-`9pduFw>pmd!11Ne7{6v4?AS1rf9Jq$PSs?#& zArJBE)^FS-$M4L}$=SVU&)$9e_V44{y9X_B13mx;D6o1JC=>?Z0Wc^Cj25BdGRq}n-W+#33p1phb?>}(ReFqNg zM~B@xyLN6zgRBiGpb%tyo(>ng2#g;yinG|!FbGg7_Aq zAjbgbprs%r?B|j{Fc|bfeU!UIKc481hk2$4NF5*!RNY}Gk8uy^!~BsJ{nV*oKYhVM3;w$G&idULpL+=D z$4{O-b?Wq)GpA3VK6UcMiDSo(9Lhbg-xL4?>({M@2P^_WaLQz87zDt=4uJ}Q4gn~j zS#wH$m;5gI$bF0cWKw@N*v}yNtJl5|FXNGp?6c?GcNQ&99zTBcNbbS?d-vdhtx%B{ z0UR)EnrL|Z*wKyz`x5{vF;RdjQIU_hmxH$t?pN}e`HH^G2m34WK8d#t=kMKr@X(QC zCr+M1_!nPX(0Bg)`7h3$J$?G*30!~z3c;358-+nw01`-(13P3EC2-4=gpo82~DCDAq6b}$^dr=we;7GuU&hQkK}Xm#Kw#H6O&-xSu!8+ zWjgO?=Q!&z{@fQAE?&BPB`@#l)x5mCE0-@_#0O_ic?#rYZwCV800_t+2SGpz2QeHZ z3W)RtzyW|O7vWdUukc3?k^9Gq`Nh1>e6YW1%l4f)Am6OV_zRaVBm4UG>o=}nzjp0v z-jz!iQQ)*faA2Pxpd1hjEm|lJAO($tT>!+v4gjrMG;?PUg^vq=Y@E0c>J|FtlKV?# z{>IH)ckJ4|Z-1_wf9Blzi|WPt(&*_Zr-?#2Dm^T0E7qj?cTLx>*kH?*JQ3( zN(#6XBml|)jiuMTHU*9!J$!Kgo?Y1@0ZRcP&`3BD4upbKhU8NqT`|r+)t%kLRCY#D zc#wUb`(b{Vch%~3p80tH_=z)Tu|DtGja#?x-o1DK-u?UczWnko8eGe}LI}u1b3nE^ z01hAk^XI0`m}UXs5Kg@c!0!Se4i*It;WFegKyV;;Q7S(l z`%rkr3>Eni{?uu+W^?W@7Wy}A+PWR^AILp&{N$N)7cR;AJ73=a>cKbPJbd)<;WudT zB??@4W5bHxC52#bNDC_^0s2DS}oiG0-_s{4Vz&R)qE z`9gj=dXNwG=Il9;dl>gy^l#n0_u!jH-#&Tz!w=7%{qXb&3Ve0%&aLZLLBJUyaR1(% zo!dEu)?}J|j{))%KxHsTpw%G8{wn<>e@Lu5e8fJ!>|X=0LURs9XN9uXRxY3E5cL+hIXR_pa#pA5BtAJe;q!Ozig%8zeVJC@UX&vp5(iE zhv{OfQ3`0dx9fBfOe%fd0)PN0`6S>TCtpXPod7QgFov7B`QK{L7To-F`g8Gf{x|!R zo&PiNKk;{m&w;~EenIyGR_#Q!MvpTCp```jb`PoDnx)33k%M*N>YmH+SGy?Gr9CjQvJ zcMml{zWljd##IB3v-soxeEVCqkpJ!YGyhxuar|Jvi$C~VpC$b7v%?Sk=Upp^|6hdv z?+yRAZ(hrTfgwP}-w|;B35@?IsR9xH+$BgAPyzh+lK%%=@u~cie5wzf{wln8?l$^A zbw>Gr!|3nvlc&#qwEX`80(x-&%iA}uUAFu`dg#DjY9J0EN}zu`04@JK{5$z=s6Gw< z#y=eYj{ms!ro(?LR;l>X@w1=W2mZTw`Kkc;mGR%xXV0EJ{ocoaz+e1(oEpf-fAG)Z z&wUk;<$vrDN^oBV$Q8t^zA1mWd5eFo`b(KQ-SNNi@8)egIDT^tfEIw;cR79>|37j3 zfB){C8`tdsqy`iGcW&EE4XpFWlP~@sHA0OT@n3!cB>5e=eEF*H;Unq#Bzfl#)u+mj zO;&x006G8UfSY#yJ$h{C-y_aH4q%~A?kD_IVAR0W;K1MHs{lg2cLh-&DF6JUgz>HN3z*9uTIgLMPp4$k>&ou~Zr*Xj?i{?gUctG>PZN7biJKr6rQQGp;^^^X&; z`p4LR|DK#3+qO`E+8s=HK%+l(A#?+=0-W~{>W`NGl>b4#`cDKLPyM9>cp3$OmEXF0 za`D9h6hL+aT)bix&>iZ(`}e2;zr4fQtNPECKhFKezB>MYSO3`s!1W-Me#m$A?~4Q2 z3V;L(5HA3_{MiYZV+G)GSAOSRrTV7+y=(RF&6}$JRR5lI^{;pOz6ig%Fu>2s4?BKE z|JH)=)&D9021G?$?}N6Z0N|a#nN%P`V9q{DkYj?NtN(A@wDSMf&6^nStN)Lw{LNAQ z?<+sWzP|9|e%-(w{5k~DgW~?--G8k0=1xFe|HMG90Qatcy8j%s3y8b_T*>1KqR+ek z==yO|S5Qknt3ECJD8F_3!hT#p=|sC8l=H1+vk-lsNlQ*UC6)x(FGy-l>F}gr!LskDQbeb@}JX>4v4`I_^b7+6To9YV<1() z|9=0a2BQe^uHSb1zQ7e!_g`+ox_zEKed@UH0uK1??9u&K?w>|0+{=F0zrg9+(!YrV zpx6B>(0*|lzzs|sto#4g7x#a<54!)KKkqdFO!`Sryr>WHcKKN1T2S8MZ})!-zwX~u zKivQQ)O*hFf4J7KSAuf|Nt>5$-6#4Vih$REfCnKWdM{_K19JB48MR>O0df1M@S*>~ z^Xk~pRU#dr2$3*0tPY$uo8$Xh}vJO!E^@@2U_!wQ;5c+LO>QA zIeMHP2>l6w=jxp$}=|={~Gjw#eQ7g+6Y-kdLqZpeDT60R;e70vH4M8Zgv= zIs?2EPzypW5Mj{uzi9i>fl~Vm(I;qt73hC~JqkZ{UtIsoU4DJ&*DHjIZ!i0sSohgG zf?WU4?jQyFe+#Syqa4WZ|3L(~hpqod7tZzna!LEWt_6zo75rsh|IhWnt^eoMzSLgo z|0(@EhsBO^zi5U z->I$xo8N$T{ckjID(s^JPWyYWn$J0|15f{(Hwf2$<`ISlJnwKkg^nI!y%)WJ^b8Hr zJFwcXO&an1q5u?ZfO8A56rc-38$dZQUkbSX|Hdqsh{p%@|7pT|4*)zuU^~Xs|99d^ zJ$0Yedb8G(jvjje;p#2)>FjOJJA6GJ-i?ANLfrF@>wv=n)`C_ctRA#Nu!0`E-hS*2 zV8@Q^o!MxSt&dk2y?<=lNaxwTe`GA2?-OsWKMG&HKymbX=u`Wh_mBMNFLAJY0njy= z9m}Y^U)=kbdx3P7mr4&k!rRo34nbW5%>jCS<>BAGKmh?YLJb2jv0`Aak4^>e0dSMO z{}FgzAXi|#_x?9)I@lxlw0+F`)V+PfRrosd-21+YEpMf78aifHUmrdjNF^ z@Sfm&5YQtS9+;Unn@2$Uaf=B8Z=m-6yOxhP$F=tMigawZ_g_yu(8u}o-9`LryD9hd z^kFj)GM_1!>hAqpZ%`fyy6FRhz$gtL*b6Yv?dwzDWuX_2=$>Vb0CLpTe0FC|>c!E^~^a`g|tR6vy0r&ntkN1B!e8BVn zas~ia+5mvP|1Z<~e+DnV=}cj05XGP;-W{O{2#0-pe6<-EJw0g%Nb?UGzR@F~_X6+U zfTN@UC$TU!@!MYC zJK42^NjycL0T2y9Xz;WJyH@t1HR!G-}H$ML1_MCu?>JMw)qcDp)i6n zcaEe_OO<#p_GZ1_-bMWKK4mv`pN6m)fYJPmn?CY#5Ej&3Ob>y)#fXQ-QVb9SUITp^ zFa#nu;0TSsNHl{ugdNY%BJ$>YXvd&8Y$)?Dkq}?+o`!ul|H2fUCNY_SV)zUP@CpnI z69IdQ2xHi_zi0>#C=J~V3QQmkH2%H*SspTR>;0rHSB z98F-M!L(`K{FgTXhGd()lH=X%6XJh2|AqA$Ky#B9ZUoT4SG7td-~3zsf1iKT7>v!o zF^T~QZ1yiv(|0z4#{3(8m^qV~FTNQwBzr2T)8v(0&&Y!&j~w!u17#GKL0B63X%LQP(p4<>=c6b8|l{&Sxu0Ga=rg5Mc^v+29B zq}>ROf!g?;CUMnoM?A-##JkkD`9G~3Fo9VY65du9D}%;L1heAqh~e&+KyA-Qjg)Y8dVwp`$&W5 zmGfud^cXA}>evMu;5}LjxDiN7GO;0ZuM7e*cq$$E7ywP4%uh3%8B|74u^s6Q-VKR{ z^S$v)6R(*An*%5KHvh>4u7;nPKK4c+nSW*c*2drz0-Jvw5c&K0S9D%*q>lmE z1ZGba^>G@(^-bVv_>-p=^4?hw?Nf9425_|s!Tc+;=lKx;gKh{?9`WSH1iBAP2R3~^gb{2FLF0vy z8URO)F`EA7WAs{+&zeE^=D&T$vlY{YT@Z$kVSP`$h)=`6`FAH?*t6kh z#Ipv&@&^ilLECe} z1F;?4u?ON-AP}$lf36!k^f+`K_Lx2|QOsMv_=qWJM)28pYak+|9D<62s0hskXu!@3 zTPF$wUO)#%@rP;wLcg&Z(a6>k2B_=b7wO?WIc{zCzC&!yWCg~p zpWp%8yVCxLEnu|J&K1MJow^7G1c40jae?@9qSzt{kA3TXd@6%2pY0NU983uI_8AQiL=;PzjT zg(vu4tiMRM_Fp2{0(!B5!`MBXYvMI^t+8(#d@o;aepZvV-M!193e$WoEDGq?XFD6j|QTY%CQlv{v8wh0Gy#yEm~pn%7ehxVVC z`p;j!5%h~{|EUnWe=J~W_piJIA*+Ad1!&x)X>(TZgaR_b`9RBOVeFo<{?!LKX!}b` zVA=sgbU2pd_)xck){&fdn?DwM_EFvbmtt?3#|j>6n6DSY1MEJscUsOn-l*&;@>Q! z)l+T2p@8jxY4y{sA8PHCbz59utB+c`)E*j8zzwE__W#(7;>D-T|1fD-~) z!Q@!b=4t0Hd|ed}q;~c8KWzz>6;yM)Y$x!zUdBVY+W*udwCzE^*#ETkTUIc^Krzy= zEbF)0eAeo*+kym#L_tUdifjW0Y5lcB2ZW&pzxb{FSM8okHh%ZEPql|^(hKar+WKh$ z>tFe+TR)ZpN<-VdrXFznznn+5|EnlS1CXHIW33$r+ZL`A;p6X;9K`A^vbA(++qX^F zH*>Dn2D15H$RqDry?k5FX9fE|3o1~wxS>!Ws9aUc-}&3uXkaR^|4by%K_7YqNi2dT zndM_-%kM2%Mc4kbcEIbheazyi?LX)5ptJYr#J}wAf0Kstzz0$Q5ZL}V8)>$IjSm{K z`L4xxynq{Q30tnv9=60{G-jJ@vz%>5q-*=y+y6%T#}#b#w?uIk(AoP${NMia=a>KV zk`(xhHo%PuwF=5g7JI;2g?*ucmcVWQT{^H0-O{)Cj!^g6{yR(f?7utVvRwsTIa;~^ literal 0 HcmV?d00001 diff --git a/extra/images/testing/pgm/radial.binary.pgm b/extra/images/testing/pgm/radial.binary.pgm new file mode 100644 index 0000000000000000000000000000000000000000..598ee59e2d01f0216f3df07a56713eb23c5d9661 GIT binary patch literal 16438 zcmZ9T2UM45md5wYnVrpMW|GO6uCccmOEgy0*iccifno(4iVX`Q*egg8D;6|jSM0qY ziUoU*ielGjOw_~}Q#UiSXZQEq_xmH6FN!*6&bjTm&wJnd-rKImtEGxJ32NG?L)##~ z;>}yMZdbfro7Tmf4Hz8VH>!9@->4A-h7KuSwQ|*0t5&OBoZqijt5M_C|MK0OxKYCfpVqHe*RM|PS~aVGQuX7?l|HKQ zVY#xUOO`11LE-n`d*`h}fB)NSe|hzlKmG9!KJkBl^R0K@E&M^T;w4L!LHtLOUd^N< zyncg*jT<8y;Q=iW-6}9JuytVT)@@qbr#}J%(F8RDnm2Fe@86_}RH#?CZk^gSr9l-m z`0&HBWlEJSUi5>)roih?0ki(Kze)Uig|WV5=`!WYe^jw@m8#V~sZq1GpI^OtpEkg9 zfB%=V+q7=erfs{n?OuLu+qU6D3zR^GX3d&94R8V))G!Sy$^|HZ3*LL@ZJ!6^e8d-e z`fo7*C|ef#!7LBT=6zAuOmZBWChfDTRln-GUj z>*E6jq1wk)2txU?rAsLW@4fr>n-+rqdgZ^J_;=qcT(p>cugGJ3^%}Km`_-*)wmY|* zaET5I>JZ$aLx+wb9YgrskBeQ-Hy&6HNSfPA5Q=rKE z?|2HB^>1Q*k)p*)l$Q8Pl|IJxl8)yaHYV!L3AtI`4l_G+?1;!tojP~!qF-J3)tRqT zC+X6$1OJcq?QnyO13qZj5F987!l4uZ1jULLdH>zF%mcFiO$Ypvr9I!vct9`LH^Fw3 zPQcp-2O}KOUAlDb(zR>1Zr!@;<0pUZ+67IdM8^(tg9W0ci$cQ&_3Qf8HWvtn<;s*U zQCte(f!AMq?R8JQtS?_dp$GQ0>)?8%3v`Nln|AGk5H7P3-W8Fdphkv1mv}1`}T|I*DoT% ze)j9vuP@r514{G=0}ld20S)8=#h_MAq0sWML~*F_owr0g;#^q|@P#}953+0Cg21;W z?i~rbq+>a<`yjbrMF0K+^bNF+zx3}Pfi8XfhW9ZygobwON)$Q*#kLB9V$cW}0s@%8 z6c7ePMDG>;0M5-9U%O7d`Ud*|7kGKTGt$FMc(}=y+(Cog7a6HP2Mt0IQvydw1v#NB zQ2+<++Cm2w15W{$hk($C=zU|oaxV4&AI2l=%=Z`%>SVj5_vsTZyG?Xt)Y$xd9eIp|J55R6@4;?ye*zn;|`bO}3I3H@DgH#yUA7G$CFZrNLr%vFIbGQ{T zXwsN72?Z1aQ=mk#B1MW7FI5`K=fF|g3-}g#l1|1WUZCrP<2~U+hawHR(b3T(^S|g3 zd`^i-RFDSYib802f&eMX1uX(lpke)bb!ykBE)eQCEKwBFFI}#D1t{N%Zz%B!J+K$* zL&HpZ1b!ck;lqX@dW7W0#>B?Pj?#al_)Ba|%*g0yoG~0fL=FZE5rm;vPjdk%K!Ly( z&6_C?T^5Ll%9bgq^S*3(PW!5ce4MYWZzb{O`_LXho>Uuv-;q8XyAd5bYV@elqsQ=# z9Xn<$e~jkeqhe!5jzk4QF+@n{-w!0>0x|&w$OEC!pAdLFP)Vm@34%}NRe^TIxeX+~ zrG;Lw4-M^z0+BH5g2$U^F@GE>&`QvIeY9e0FhwowgV0_;V-^=*^0|sIH@F)U~;U;^+ zgb5QTPRjo#@=1%aV{t@G3{Ef~;DWxmAS@IZ3IuJ;1I7cjI13=ca%EKQz`E5X-mGsC z*c#-4dy>vjkL%_65i;Egm*~lpCr_E`eN(1P;h&Qx;tt%PKqw4~0zeFRF^~dnQ2-D& zYEZ9k?ON4gVnM*Xugt6eDS5BhlXoGVyTEtyegA=j2M-xW*kiDL3@%4D@}|bc#q&+$ zi=P%B9~U1tb?OwK3I+xFAaam!*oRE)*0oazRMZ9#q5xE^Bmjfu$^6P6e}edW)EdwZ zv2Ty{CO$kI*dra+Bb}H}n1JEPmfVEI#Ka`~_)B5}dc;qSn=%D2;Dphm0fH9<_^7uO z=!^njz$sAAPe(x&YC=lQYLGsx+t|N(0LUlpE$a!rV2}6_BjtHXcfu1A5|fgXrzcOJ zo?^eIPft!tMu&uHxWT+IZp`S|*pUJvF2DnTpgSJ05VUB{VFVG@s$nNVMaO#*5A-eZ zI(5bQPJHChVPstFsIg703V=1%!m=g zlnDLtKu^-3b4RkEb<2Qe5Frt$sR&f8Tvgsz@GbMm`%XB&XYX)AKM2^H@kpO&((ySa z&zL!L)~wmH=eUnQXU{?psgO)0;!OjBFe)Y*7)k+9=wYCJ+dvfXCkYe*ZYG?$wJ3KQ za^@)UVLeeU(2E!_IMRv7^%Ez__QXUipD{zC=gv({oo8R_ywudWsZNI(Dapx62?_C2 z!2vE9MGT^bLWdFk0AXl%(lEHaXrO81MxWNJLlS;0@7MA31;1TT#}M+qhpZn!+C_~R z89RE6jGr1mji9Hb%rxPMp1)whf`tnfE?meT^XJc>H!pQAI+zoZ62QS^fH-z^?8s<& zU_gH`fCsvC@o35Y-|Ab~jtKd=U;eCQH z@jZJB`H@&3gZS}^JjUbsS+nPO!jb&hk|j&h`ESXR&-hRy4HZ&T(SRroYrOWu1 zFI&dn($mqw(_pTmkeoOzUNIm9G3248Az5e!0$K_CV%6^I%N7rP|rA{MYDq$I9W zQ@Q7Pza6xz;4AYC`R4p7aq$TNZ|3Z|sq+`4EkZiNC41FszBT$*uU@rk<%;FYmn|g} zi%=j{E|@MDIuDG52TXxpJv~U zAJ`V!@6wGEHyrG7;zY-o_^CeeGG4Zu@HGftzhV7`jT<*^*vOyj*JZ3-iwY~v2L!>z zASqD_C=H{dhJryN(38VBq=Q(jiuPPsV?ij_s?~ zAY76+ZQAU8n>L}wdg-tRA1qB@0u1J*&cOpxVDiLqV_`zkK!4GYSSYAnYhMm>>MQr0 z`9ACqj|O|=Cy@3DCf@meDbjKLy7dU(yk*PQt=sI|x^?T8Et@x?!n%w#YgVmTP7oF? zoKGgsNO2&935ftK5P<{80n0&iK)t#m{uY?8)W>{zKXO=82dL;N z5PgVG*pKGKGw&PpQWq?g?^mqE_3LH&Hi_P~d-v`=`gZT$wQJ{&9otZ0(}wjKYgdB; zQZa3QsuVCH8m|a&5o;uLymkAIUAy*3bk=^p1N--9@u9<> z-Dt3F%chO%6$5!-;e2=?MOipWJV-$V1pD>@0aWB-VciF0ejr7UfuHCP9%95do&(pg zHy7l8CgdT0;q_l8}I=*K!J5@L7^}J4}d{IVEmX- zF=8Rl0iBHmm4ZTFYf&G>Z|0Nwv7GpLKPh>}>^bumq$&2R*2?!=w>##=^z)*U-{@5$VU^n=LG$vJxT=rO*dIY*9|2K&qfQh*RFU$#UToIQ&O z#EFGm4sr}|4q6IA!u~G#gF1jdsE=}&=*JTM$uQ6K8MEd6B}IH+ZSzq#Mg z7b^5Q@VnGcPMKxiUrOGuU61p3fIE!G_MBtK5qxJ$y~@)-AkKFl9$(NCEH_R|(GvEXmqiU%2SL3utlX)TtB4bB-L!K7a>y zLPcH#aKPM|qT$IC$2$@nNC2qBL;pipE-;0&p*Gc@6x49pI^Li?%bKvxBvwdf*sqo2!pTyB#B7|=?&I9|xCitlK|S*pDD^Sl1z+Ov{mIj3&t159>C%e^aa2HfGZc_SIw{R4~vrfCyDvRyv}^Ezir3vy;&gNtjGAvxmS^W^XAQ4H*em! zaXs%^?iCa`rw|-ICz2*k*+b#u!XF(Y?t^-Tz6Ip| z3YouU`_4W4_8&ZyBj=yLcvU$~tC#sEgXU3Bt8enW?kgnPw((^KFcbH9tenSbQy37_~Iw{G9L zd+*-8`}gnNyL$%>@~)Z!r%oI@a_GRmOp$=4fDmXT91jOVK`KM?DUhxhXP@fM9=%j{ z4yEuQ`#kr<{4np@bsIhN@&2jP=PzJ=-i=##?%u!u;NgRZ4B}pGK4b7$}ke3mBC-~UHCcq3BM2hi#_*m-A?WuICSKg%>VrI z)x4Xx?%ez0!NW(7zIycN(U%V&+`lIUu3rB90vI$0?8O1U3xGIS6d1*2$YX#GLEJ^D z{9Ne)`9@NCi2MkD%FMa*IQN$c{hPP#+zt2-=NvzE=KRIWxw8J=7Z1OD^!3+|pFDp2 zH5z<@0@ttQUh*7}y+0EUAO%;iT225s1v!O9fp!LQA2$Y44bU>s$37x|>P{6taU6X* zdOk~EZth1u=sSG$#Hq6vKEHhJ`b~*{gz#_po<5ZZPJt_zZ~zE6xZeT*37dQaK!P!V zI|BNt4(AAhfdf@~0e`E!hL0fpWPc(jKjcUFIe8rVasTm?XU>`Vx9=hz>EAy4j_=!V zo_zi2!Tr0pZsz4)zIgtO1t4p$C}2H>2o$tH3}A<_7-%SEsAIsOc7d&sui8U(Kk(Pt zEBPW{$WKQP@}b_W1BY{t;eLz$o%;_Sef{K{XV1U?{>6*$pFcx^FCW~ybMra~I4=Yq z%Ff!mn^S0ghROFBAU^?A26F^j4PxxC(ogcEqTS&m_VH!^ddO#&!Vmh-UbvKd?S{<% z>haTO-@o|r$De-u;ROmj{^}tPxK0XOIBOYzd}W|70p?f{;4$D}?Dxsn=>z+R<)=TT z&(wIzZk>G`y{p#&za6_X_h*CtQ|BcA=Iwi!|Mc7EFMj;_mtTMR`NtQ}zkMnP+`a(< zFP!rLz$qvIatKog&Y8&>tSZooFcpDe-6;X6!Sdz9{x8#ChmYj1TqF4J5cwTBrtn`P z`EK7M`rmx_{SQC?`rAK#`}OA^zJK=gF$k~#_~h@~Bm13v7|;>G1QCEv06T$v{@1+| z`(b~jzvzcc*PK)@{Wy9J{@5@0T?PI3asM~pz4-B$|M};?{`uQ4KfUK>+RujtQr`l$Bc>|cfd^W~pBE%|x3 zfZtb7kpI)K|M=Jc{p%l+|Lqe2Kme3{67YbNuOrY-fR_X~f}6Pc-)hj7-28OhadRQyHODT zzX<=|8UF9yzL5t5Lx76EBjEfK82?XG1tR>pOOPs{0{HJE{|~p~Q~4+PR3AG1Re0~+ zZ}flmyz>8+(cjZ&&tLpt`Tsox^yuLicW>ReYWaWS=;3T?APyi(pnp36E&n|HJNa#? zJ`MlIKOFy#|G4(1!GEjQs`%3JbBNjp{=0JZx&Zj4@!#_oFJ3(V&c}biU;KND8py|g z@XxZ(d=-%8e{>WjxUT}_3gT7Ylt0|O#lKelCC`}U_}}<<`>s74zc~g#3&7p`96yf# zpE>@2c>mt5n|1(Fg9-k7cWtKz*7@Vf7ypkNqehJQFTVhi{7ziHeAV~pv2=YByz__Z zQ{~4ttG+~loPTn_Z9D&-Jhk)h3FjXNu+S&>6MiZ%YG7(`;BWF(03qMIf~XIafBw<& z*ZEJ=Q{^Yszuo4V$N%r@Kf3_99)!{l`L6zb zc>r4h5Jv&x1wfZSI{~w-06gW&@4V|&-_*bNt^U1zTh*WH-!rcM^-kZH;a3+1_*wa3 z$FJz$S`fbaUj@LRp~I~ALEBLP@J`?iDi9$s>mVh_NkP!n|F>>i`G4p3ZH)KT|0h-c zW~u)7m7ii?U-)sqZr~1nA;I*ZxPN%}A8Wn26HwPbF_0_3z3ZRuKS%5W;_g4!^0sr#Y(pH~4H1K1I~Mh*}H z6al+{asT7?dF>i1`0js~^Y4FjK}bF&zq|jb3pQiAnqaQ{=k%ikV(|QA1AaSubpMt6XVMDyvLE&@aQe0i zXzBpyb-xOO;I;K9;){ly~^s{olf` z`#04O_kVx&p7Z-3uJ!Ac;9Nmc7p7VFiT;No;58uNL5PUn%LVIzT)1#vEf{)0-2N$i z=znniR}+v<^kJ~Tg<7+>t3Ga140f3bN#sIzs z3^kz6051j9f=~-Y7tUmyDQ3ZdfL%l@X; zefEwZ*Z;FSNP+&}Vr#)D2lD%W5JAo{>;KV(bN#;@(mva@Kyki;ztZdfxgNOn|Ge6l z+DrXEWxszT^*?FAg)nbm6hsG#A_NYOON4_8bl{ueO)qXSco%@^n)Bm*qs0E|`ulM+%Lr}Ls*MSrSU;zt( zdXQ+4ebCqcJ;Z(Ux6r4vw*~L;^?7(V3Ze*c&p)mM4hL8ZT7|HB&TXZQY*zGRV4ytV!)eDwmw(d(g4?RVZk@}IxN!R`e> z*I;_U-U|dz00kA`?Q1iSPkMRc{YMW#{N(*-=XSlm@CKHlCop^cP}Q%_r#0WneNnHq z-t+|Nd;f9oUv>yn1u}KP`xmc|_W0?ZKMX=_)Uk9(shgsUIDJx(1p9^!m!fzk7iK0&0XB24G^vz+NAn3f=?Y zHhcdg@Vr2-#(3}jZ|*FxNAPL;nD?oB`-iLWb>_PVQ1||+2S8GQ=U+I09HbG#^DF1z zRK0?b1X93Wq3r3G_fLBO^JZ>P!TBJdM=(4vCv_f=fb`>*5d_{q?frKHA8(Eu?Clll*lzE?o_L^-^Xa>b_|)}z)PI~{gDGc}g>|S5>@}ZN*<-Sco)W886{VDJSs|e^7POVryf(irf{eL0v|8Dqz z=l@j<0IabA0DJ#msrUbMUVhV(f^!T{ZH%|9^vu~5(8zWE0n!N>H2H~+xfKhhaL(93f&lR$L*#*Z7V%(usH zdwuV0*A6D}6nzFjGytK&H-jK`fI8t!Kxp(xNdOJ_hF^TsCpHA3`Hy8b0J6;HKQx8H z2+D%_l0Gv<;=S0L^?G|3@yq*^-PC;=!eRhM^Dl1t$jd=kPd z^l88lh}?i9H2xyd4B`-WJU^GnoA03=gWjl-%)dlJe0_Tx_TBsoQ*fHZWCDueGaSGx zFf2?2>?xub!>$8GLwG=G=w?u00%@T6AI+iI{13xF`k4PgxSRjc7?zB8;<27nkIc9E zAA9)a+?V+cH2?ESm1-^mjd%#NAqdg19s_8HP>q8Dh{#6Im^{<;6@y<=VctCEpEUkt z^G~>4Q&=|pqv<0?z!?0{3>pJiFU2zq>zjYV`!<2b{FkQh1VOQ&u~0WAA8q^$9&!qh zhm7H90t*dh&h+NLya6yI+w7Gb?`EG6|GW7wtk(dVo4jx%fCj$m)vEaB-x~b;{F}yL zZ2pZ=3_xJBfAN~Wvk^4r-|)knIm~?V&7LjUGeDgtujG109yEF6kk1?_qqq#h+W46p zebMX<(XYb7fhK=F63}H# z-%TX##%K)G#_u$VtA0D;Irb#prM}JoY2||#TADR7R z`f{Q)VEB^xM}`omGyiBGLy(ePVE$1Pn4@AC#MKNcW4IbUvkB1locfk}44>7i&iLO) z8a%I>KLe-7V9`*guFwGQ(Ne&TKvI&44Vimo5Rk!B>A=STXkrq7n&Hf#GJ=ZjNN4aa zY8agFjbEC0%^cVqIKj91PbP3R{LJ*RHv-B0E918|2B#3%{Oh2|-_O6I1CzILro}XU z48X=Qd#b2U(g?0^0$0PIJhhPb&U$E{n#(tUt5pc*Uzt76j{q2SLy+=-r6F_YxFAv} zVCY*DxB`M^a3?c_TVMc~@n1LpYtlzXM-PW`&G$@!hcWY{*-y>AspxRSpPD}Xuxv@q z-fRBZ_8#D2vd};%1vHJ-ml<45!NLVh;l|qhGc(s3dDi?ha`_m4#&FGGk8<GLQ?ur&mY z7shG;95p6r`kRl@YfV0D2Hl(g_8HGsOjmY67(RyeJ@Fzw4gZ!eQ<}9O?L27!9U9UE zcrz3*3`hYDLjpraz!`(~=HFu&Mt0-xHvDcs5X~6AgxmZ(Bd2coo6vLD3bFZjCtldI z;b+9N2E+0P3V=b|et-uRf|fc8f*HW?qScFD`P&C9KCpYB5&RgGU<}_rb^tW~PtXyL z<0A)SJGf&H#H~OeUi1H4H+1N6=sN5%eO|J-w|?;vQ_zgyv+veWL`XRV6$euhnhVf? zofo!F6b8J24vgZD)B=QlV>P0YttAXlH?Tj_!+Uew+U$KuhoJUaz>s)0Kzuteh%dzo zj9Wj!1Gaai{SRBfXsMkmhJibG6$%If8yMdH2b(9uwEy94fJiV-XX0K9AdLN+bXz^p z{s&7q0)9)|gK9v@f%B_XvDtf8@rt}B1=##z1H>ty{TEg+0$2lRYx^&dp}~Mu&@O=6 ze?b*VMJfzHRWmLOHj9qy3*^C2a}9Q-FdP5J&-H zfD04^(|}D3-~P`4Qc@d0gxdWW1ktgD#NJ6?xBsIxEVl>N4&TH1j68eJx8)O-&}*z|!tt1qVV_|FjFxq-nDjtlkL)WPzd&c@#Kj5J4 zFD-#-2Mp2SSdQbv+zMJJa^7wJSm@bDb^Bk6y=5LNc&uT*Q3wyP`^esDc~1f6!O6o$ zEdTko?@R-dQG0)=U^?_+AIkUH{u`TVtX+k5_x9g95O}Tqu>94`Rsgkh;r8F0_zw{O zRw1pPY6A`hYzIuMpKkq7Yp1N+;sRTJ)Y7H)(0~GNFfFwI$7U42Z2=Ikn{dJ|&ui;R z8;J6~TY;>}xObIGvc44CZ$;REEcC`-f3JYI{|E@Q38gJKaOgG=4G64!IyZ!dX$>*V zRN;?MoNk7*eAp4wi95R%NN4{M;JMIi+`f{QURXUVD)DT97TEs;gxbCJQ0S*Tc&PzS z2x0}3V?mpzUApphQ#_E`&D;O9B~(^W&GE9Gz~g!u59MnAQ;X2H2mNyY)7EcU!2|=v zNyBoi-)i$&tH*8&5*!i*ArUCD4H&HT*N_l|p$5PBt^HT+o=P@;_qI>9hiuXd?7!Oj zX#wkB`-@vYmI6vc+r6e9aQnZUN4Ec~C`bd4pxtAw9e1!TTq(lG-z7Pi)mvn1>C(1u zo3d}_T(1pe^SzKq-m`l7j-1a5_J0;spjZh*p+Hczx|YB5x3AH_RAB#^NT7p0^az$% z1WPi@$H##}FY$l;f7W(T`~Uy| literal 0 HcmV?d00001 From 52736dd94ff4ddf3196d8a57c1a73809b210cbb3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 4 Apr 2010 12:20:56 -0400 Subject: [PATCH 579/713] mason.child: fix unit test for boot image renaming --- extra/mason/child/child-tests.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/mason/child/child-tests.factor b/extra/mason/child/child-tests.factor index 6fedac87bd..f8046ac8e5 100644 --- a/extra/mason/child/child-tests.factor +++ b/extra/mason/child/child-tests.factor @@ -33,7 +33,7 @@ USING: mason.child mason.config tools.test namespaces io kernel sequences ; ] with-scope ] unit-test -[ { "./factor.com" "-i=boot.x86.32.image" "-no-user-init" } ] [ +[ { "./factor.com" "-i=boot.winnt-x86.32.image" "-no-user-init" } ] [ [ "winnt" target-os set "x86.32" target-cpu set From d70cf197f268e9863538a20603f93eb1adbb13a4 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 4 Apr 2010 13:53:17 -0500 Subject: [PATCH 580/713] vm: fix compile error --- vm/code_blocks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/code_blocks.cpp b/vm/code_blocks.cpp index 64b218f377..de103cda12 100755 --- a/vm/code_blocks.cpp +++ b/vm/code_blocks.cpp @@ -227,7 +227,7 @@ void factor_vm::store_external_address(instruction_operand op) break; #ifdef WINDOWS case RT_EXCEPTION_HANDLER: - op.store_value(&factor::exception_handler); + op.store_value((cell)&factor::exception_handler); break; #endif default: From 6e40b77a9fb33b96fce62757100006aee427cba3 Mon Sep 17 00:00:00 2001 From: Sheepson Apprentice Date: Sun, 4 Apr 2010 14:30:29 -0500 Subject: [PATCH 581/713] When curl fails with a 404 error, don't write this error to disk --- build-support/factor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-support/factor.sh b/build-support/factor.sh index 3a5fb4e253..38bdc8183c 100755 --- a/build-support/factor.sh +++ b/build-support/factor.sh @@ -68,7 +68,7 @@ set_downloader() { if [[ $? -ne 0 ]] ; then DOWNLOADER=wget else - DOWNLOADER="curl -O" + DOWNLOADER="curl -f -O" fi } From cd05b1007dda4b68b625ab9d345c435d492e18e4 Mon Sep 17 00:00:00 2001 From: Sheepson Apprentice Date: Sun, 4 Apr 2010 14:39:59 -0500 Subject: [PATCH 582/713] Support unix-x86.32 and winnt-x86.32 boot images in factor.sh --- build-support/factor.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build-support/factor.sh b/build-support/factor.sh index 38bdc8183c..68d138c3ef 100755 --- a/build-support/factor.sh +++ b/build-support/factor.sh @@ -291,9 +291,15 @@ set_build_info() { elif [[ $OS == winnt && $ARCH == x86 && $WORD == 64 ]] ; then MAKE_IMAGE_TARGET=winnt-x86.64 MAKE_TARGET=winnt-x86-64 + elif [[ $OS == winnt && $ARCH == x86 && $WORD == 32 ]] ; then + MAKE_IMAGE_TARGET=winnt-x86.32 + MAKE_TARGET=winnt-x86-32 elif [[ $ARCH == x86 && $WORD == 64 ]] ; then MAKE_IMAGE_TARGET=unix-x86.64 MAKE_TARGET=$OS-x86-64 + elif [[ $ARCH == x86 && $WORD == 32 ]] ; then + MAKE_IMAGE_TARGET=unix-x86.32 + MAKE_TARGET=$OS-x86-32 else MAKE_IMAGE_TARGET=$ARCH.$WORD MAKE_TARGET=$OS-$ARCH-$WORD From ce16c4ec2cfa309f71b4db91fc014e6f7ce7bbdf Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 4 Apr 2010 17:46:36 -0400 Subject: [PATCH 583/713] vm: fix callback heap code on 64-bit Windows --- vm/callbacks.cpp | 60 ++++++++++++++++++++++++++++++++++-------------- vm/callbacks.hpp | 4 ++++ 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/vm/callbacks.cpp b/vm/callbacks.cpp index fbf36c7cea..38479a3cb4 100755 --- a/vm/callbacks.cpp +++ b/vm/callbacks.cpp @@ -19,7 +19,25 @@ void factor_vm::init_callbacks(cell size) callbacks = new callback_heap(size,this); } -void callback_heap::store_callback_operand(code_block *stub, cell index, cell value) +bool callback_heap::setup_seh_p() +{ +#if defined(WINDOWS) && defined(FACTOR_X86) + return true; +#else + return false; +#endif +} + +bool callback_heap::return_takes_param_p() +{ +#if defined(FACTOR_X86) || defined(FACTOR_AMD64) + return true; +#else + return false; +#endif +} + +instruction_operand callback_heap::callback_operand(code_block *stub, cell index) { tagged code_template(parent->special_objects[CALLBACK_STUB]); @@ -33,17 +51,23 @@ void callback_heap::store_callback_operand(code_block *stub, cell index, cell va offset); instruction_operand op(rel,stub,0); - op.store_value(value); + + return op; +} + +void callback_heap::store_callback_operand(code_block *stub, cell index) +{ + parent->store_external_address(callback_operand(stub,index)); +} + +void callback_heap::store_callback_operand(code_block *stub, cell index, cell value) +{ + callback_operand(stub,index).store_value(value); } void callback_heap::update(code_block *stub) { -#ifdef WIN32 - cell index = 2; -#else - cell index = 1; -#endif - store_callback_operand(stub,index,(cell)callback_entry_point(stub)); + store_callback_operand(stub,setup_seh_p() ? 2 : 1,(cell)callback_entry_point(stub)); stub->flush_icache(); } @@ -70,21 +94,23 @@ code_block *callback_heap::add(cell owner, cell return_rewind) /* Store VM pointer */ store_callback_operand(stub,0,(cell)parent); -#ifdef WIN32 - store_callback_operand(stub,1,(cell)&exception_handler); - cell index = 1; -#else - cell index = 0; -#endif + cell index; + + if(setup_seh_p()) + { + store_callback_operand(stub,1); + index = 1; + } + else + index = 0; /* Store VM pointer */ store_callback_operand(stub,index + 2,(cell)parent); /* On x86, the RET instruction takes an argument which depends on the callback's calling convention */ -#if defined(FACTOR_X86) || defined(FACTOR_AMD64) - store_callback_operand(stub,index + 3,return_rewind); -#endif + if(return_takes_param_p()) + store_callback_operand(stub,index + 3,return_rewind); update(stub); diff --git a/vm/callbacks.hpp b/vm/callbacks.hpp index 607984ad23..a0ab3d6bf9 100644 --- a/vm/callbacks.hpp +++ b/vm/callbacks.hpp @@ -38,6 +38,10 @@ struct callback_heap { return w->entry_point; } + bool setup_seh_p(); + bool return_takes_param_p(); + instruction_operand callback_operand(code_block *stub, cell index); + void store_callback_operand(code_block *stub, cell index); void store_callback_operand(code_block *stub, cell index, cell value); void update(code_block *stub); From c0af678c5bc13c8f096609223ae81a8c8a4afa90 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 4 Apr 2010 19:42:57 -0400 Subject: [PATCH 584/713] cpu.x86.assembler: add support for absolute addressing on x86-64; [RIP+] now behaves like [] did, and [] now does absolute addressing just like in 32-bit mode --- basis/cpu/x86/64/64.factor | 4 ++-- basis/cpu/x86/64/bootstrap.factor | 2 +- basis/cpu/x86/assembler/assembler-tests.factor | 10 ++++++++-- basis/cpu/x86/assembler/assembler.factor | 16 ++++++++++------ basis/cpu/x86/assembler/operands/operands.factor | 14 ++++++++------ 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index 7e1c5c1f48..4dfb250348 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -55,13 +55,13 @@ M: x86.64 %vm-field-ptr ( dst offset -- ) : param@ ( n -- op ) reserved-stack-space + stack@ ; M: x86.64 %prologue ( n -- ) - temp-reg -7 [] LEA + temp-reg -7 [RIP+] LEA dup PUSH temp-reg PUSH stack-reg swap 3 cells - SUB ; M: x86.64 %prepare-jump - pic-tail-reg xt-tail-pic-offset [] LEA ; + pic-tail-reg xt-tail-pic-offset [RIP+] LEA ; : load-cards-offset ( dst -- ) 0 MOV rc-absolute-cell rel-cards-offset ; diff --git a/basis/cpu/x86/64/bootstrap.factor b/basis/cpu/x86/64/bootstrap.factor index a82c8c17e2..69734df225 100644 --- a/basis/cpu/x86/64/bootstrap.factor +++ b/basis/cpu/x86/64/bootstrap.factor @@ -47,7 +47,7 @@ IN: bootstrap.x86 ] jit-prolog jit-define [ - temp3 5 [] LEA + temp3 5 [RIP+] LEA 0 JMP rc-relative rt-entry-point-pic-tail jit-rel ] jit-word-jump jit-define diff --git a/basis/cpu/x86/assembler/assembler-tests.factor b/basis/cpu/x86/assembler/assembler-tests.factor index 0a6ae5a484..8ed789f392 100644 --- a/basis/cpu/x86/assembler/assembler-tests.factor +++ b/basis/cpu/x86/assembler/assembler-tests.factor @@ -1,5 +1,5 @@ USING: cpu.x86.assembler cpu.x86.assembler.operands -kernel tools.test namespaces make ; +kernel tools.test namespaces make layouts ; IN: cpu.x86.assembler.tests [ { HEX: 40 HEX: 8a HEX: 2a } ] [ [ BPL RDX [] MOV ] { } make ] unit-test @@ -164,5 +164,11 @@ IN: cpu.x86.assembler.tests [ { 15 183 195 } ] [ [ EAX BX MOVZX ] { } make ] unit-test -[ { 100 199 5 0 0 0 0 123 0 0 0 } ] [ [ 0 [] FS 123 MOV ] { } make ] unit-test +bootstrap-cell 4 = [ + [ { 100 199 5 0 0 0 0 123 0 0 0 } ] [ [ 0 [] FS 123 MOV ] { } make ] unit-test +] when +bootstrap-cell 8 = [ + [ { 72 137 13 123 0 0 0 } ] [ [ 123 [RIP+] RCX MOV ] { } make ] unit-test + [ { 101 72 137 12 37 123 0 0 0 } ] [ [ 123 [] GS RCX MOV ] { } make ] unit-test +] when diff --git a/basis/cpu/x86/assembler/assembler.factor b/basis/cpu/x86/assembler/assembler.factor index 32eeaaad1d..b91083dad1 100644 --- a/basis/cpu/x86/assembler/assembler.factor +++ b/basis/cpu/x86/assembler/assembler.factor @@ -1,9 +1,9 @@ -! Copyright (C) 2005, 2009 Slava Pestov, Joe Groff. +! Copyright (C) 2005, 2010 Slava Pestov, Joe Groff. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays io.binary kernel combinators kernel.private math -math.bitwise locals namespaces make sequences words system -layouts math.order accessors cpu.x86.assembler.operands -cpu.x86.assembler.operands.private ; +USING: arrays io.binary kernel combinators +combinators.short-circuit math math.bitwise locals namespaces +make sequences words system layouts math.order accessors +cpu.x86.assembler.operands cpu.x86.assembler.operands.private ; QUALIFIED: sequences IN: cpu.x86.assembler @@ -22,7 +22,11 @@ IN: cpu.x86.assembler GENERIC: sib-present? ( op -- ? ) M: indirect sib-present? - [ base>> { ESP RSP R12 } member? ] [ index>> ] [ scale>> ] tri or or ; + { + [ base>> { ESP RSP R12 } member? ] + [ index>> ] + [ scale>> ] + } 1|| ; M: register sib-present? drop f ; diff --git a/basis/cpu/x86/assembler/operands/operands.factor b/basis/cpu/x86/assembler/operands/operands.factor index bd9a3f6cdd..e8d98cde17 100644 --- a/basis/cpu/x86/assembler/operands/operands.factor +++ b/basis/cpu/x86/assembler/operands/operands.factor @@ -1,13 +1,9 @@ -! Copyright (C) 2008, 2009 Slava Pestov, Joe Groff. +! Copyright (C) 2008, 2010 Slava Pestov, Joe Groff. ! See http://factorcode.org/license.txt for BSD license. USING: kernel words math accessors sequences namespaces assocs layouts cpu.x86.assembler.syntax ; IN: cpu.x86.assembler.operands -! In 32-bit mode, { 1234 } is absolute indirect addressing. -! In 64-bit mode, { 1234 } is RIP-relative. -! Beware! - REGISTERS: 8 AL CL DL BL SPL BPL SIL DIL R8B R9B R10B R11B R12B R13B R14B R15B ; ALIAS: AH SPL @@ -90,7 +86,13 @@ M: object operand-64? drop f ; PRIVATE> : [] ( reg/displacement -- indirect ) - dup integer? [ [ f f f ] dip ] [ f f f ] if ; + dup integer? + [ [ f f bootstrap-cell 8 = 0 f ? ] dip ] + [ f f f ] + if ; + +: [RIP+] ( displacement -- indirect ) + [ f f f ] dip ; : [+] ( reg displacement -- indirect ) dup integer? From 964f45fc777207a5bce9df2bb06482d07af1f546 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sun, 4 Apr 2010 18:57:58 -0700 Subject: [PATCH 585/713] Techniques work --- extra/fluids/authors.txt | 1 + extra/fluids/colors.ppm | Bin 0 -> 81 bytes extra/fluids/fluids.factor | 164 + extra/fluids/particle2.pgm | 16388 +++++++++++++++++++++++++++ extra/gpu/effects/blur/authors.txt | 1 + extra/gpu/effects/blur/blur.factor | 81 + extra/gpu/effects/blur/summary.txt | 1 + extra/gpu/effects/quad/authors.txt | 1 + extra/gpu/effects/quad/quad.factor | 4 + extra/gpu/effects/quad/summary.txt | 1 + extra/gpu/effects/step/authors.txt | 1 + extra/gpu/effects/step/step.factor | 23 + extra/gpu/effects/step/summary.txt | 1 + extra/gpu/util/util.factor | 69 +- 14 files changed, 16732 insertions(+), 4 deletions(-) create mode 100644 extra/fluids/authors.txt create mode 100644 extra/fluids/colors.ppm create mode 100644 extra/fluids/fluids.factor create mode 100644 extra/fluids/particle2.pgm create mode 100644 extra/gpu/effects/blur/authors.txt create mode 100644 extra/gpu/effects/blur/blur.factor create mode 100644 extra/gpu/effects/blur/summary.txt create mode 100644 extra/gpu/effects/quad/authors.txt create mode 100644 extra/gpu/effects/quad/quad.factor create mode 100644 extra/gpu/effects/quad/summary.txt create mode 100644 extra/gpu/effects/step/authors.txt create mode 100644 extra/gpu/effects/step/step.factor create mode 100644 extra/gpu/effects/step/summary.txt diff --git a/extra/fluids/authors.txt b/extra/fluids/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/extra/fluids/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/extra/fluids/colors.ppm b/extra/fluids/colors.ppm new file mode 100644 index 0000000000000000000000000000000000000000..c12c455f4c1d7fcd2f991538bcb556b62dd52f2b GIT binary patch literal 81 zcmWGA<5E^|4svx2@ei_6aQE~LPzdnzRdCD9DM>9-2um$0&dkqKFw`^TGBi*y85n?QAu0j@SUnTh literal 0 HcmV?d00001 diff --git a/extra/fluids/fluids.factor b/extra/fluids/fluids.factor new file mode 100644 index 0000000000..a0d75fd6e3 --- /dev/null +++ b/extra/fluids/fluids.factor @@ -0,0 +1,164 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors arrays classes.struct destructors game.loop +game.worlds gpu gpu.buffers gpu.framebuffers gpu.render gpu.shaders +gpu.state gpu.textures gpu.util images images.loader kernel literals +locals make math math.rectangles math.vectors namespaces opengl.gl +sequences specialized-arrays ui.gadgets.worlds images.ppm +ui.gestures ui.pixel-formats images.pgm gpu.effects.blur ; +FROM: alien.c-types => float ; +SPECIALIZED-ARRAY: float +IN: fluids + +STRUCT: float2_t + { x float } + { y float } ; + +: f2+ ( lhs rhs -- res ) + [ [ x>> ] bi@ + ] + [ [ y>> ] bi@ + ] + 2bi float2_t ; inline + +: f2- ( lhs rhs -- res ) + [ [ x>> ] bi@ - ] + [ [ y>> ] bi@ - ] + 2bi float2_t ; inline + +: f2*n ( lhs rhs -- res ) + [ [ x>> ] dip * ] + [ [ y>> ] dip * ] + 2bi float2_t ; inline + +STRUCT: particle_t + { p float2_t } + { p' float2_t } + { m float } ; +SPECIALIZED-ARRAY: particle_t + +CONSTANT: gravity S{ float2_t f 0.0 -0.1 } + +:: verlet-integrate-particle ( p dt -- p' ) + p p>> 2.0 f2*n :> v1 + p p'>> :> v2 + gravity dt dt * 1.0 p m>> 2.0 * / * f2*n :> v3 + v1 v2 f2- v3 f2+ + p p m>> particle_t ; inline + +CONSTANT: initial-particles +particle_t-array{ + S{ particle_t f S{ float2_t f 0.5 0.6 } S{ float2_t f 0.499 0.599 } 1.0 } + S{ particle_t f S{ float2_t f 0.5 0.6 } S{ float2_t f 0.501 0.599 } 3.0 } + + S{ particle_t f S{ float2_t f 0.5 0.5 } S{ float2_t f 0.5 0.5 } 2.0 } + S{ particle_t f S{ float2_t f 0.5 0.6 } S{ float2_t f 0.5 0.599 } 1.0 } + S{ particle_t f S{ float2_t f 0.6 0.5 } S{ float2_t f 0.6 0.5 } 3.0 } + S{ particle_t f S{ float2_t f 0.7 0.5 } S{ float2_t f 0.7 0.5 } 1.0 } + S{ particle_t f S{ float2_t f 0.1 0.5 } S{ float2_t f 0.1 0.5 } 5.0 } + S{ particle_t f S{ float2_t f 0.2 0.5 } S{ float2_t f 0.2 0.5 } 1.0 } + S{ particle_t f S{ float2_t f 0.3 0.3 } S{ float2_t f 0.3 0.3 } 4.0 } + S{ particle_t f S{ float2_t f 0.5 0.15 } S{ float2_t f 0.5 0.15 } 1.0 } + S{ particle_t f S{ float2_t f 0.5 0.1 } S{ float2_t f 0.5 0.1 } 9.0 } +} + +: integrate-particles! ( particles dt -- particles ) + [ verlet-integrate-particle ] curry map! ; + +TUPLE: fluids-world < game-world + particles texture framebuffer color-texture ramp { paused boolean initial: f } ; + +: make-texture ( pathname -- texture ) + load-image + [ + [ component-order>> ] + [ component-type>> ] bi + T{ texture-parameters + { wrap clamp-texcoord-to-edge } + { min-filter filter-nearest } + { mag-filter filter-nearest } + { min-mipmap-filter f } } + + ] + [ + 0 swap [ allocate-texture-image ] 3keep 2drop + ] bi ; + +SYMBOL: fluid + +: integrate ( world -- ) + particles>> $[ 60 fps 1000000 /f ] integrate-particles! drop ; + +: pause ( -- ) + fluid get [ not ] change-paused drop ; + +: step ( -- ) + fluid get paused>> [ fluid get integrate ] when ; + +M: fluids-world begin-game-world + dup fluid set + init-gpu + initial-particles clone >>particles + "C:/Users/erikc/Pictures/particle2.pgm" make-texture >>texture + "C:/Users/erikc/Pictures/colors.ppm" make-texture >>ramp + + RGB float-components T{ texture-parameters + { wrap clamp-texcoord-to-edge } + { min-filter filter-linear } + { min-mipmap-filter f } + } >>color-texture + + dup color-texture>> 0 1array f f { 320 240 } >>framebuffer + drop ; + +M: fluids-world end-game-world + framebuffer>> dispose ; + +M: fluids-world tick-game-world + dup paused>> [ drop ] [ integrate ] if ; + +M:: fluids-world draw-world* ( world -- ) + world framebuffer>> { { default-attachment { 0 0 0 } } } clear-framebuffer + system-framebuffer { { default-attachment { 0 0 0 } } } clear-framebuffer + + f eq-add func-one func-one dup set-gpu-state + f origin-upper-left 1.0 set-gpu-state + world particles>> [ + [ p>> [ x>> , ] [ y>> , ] bi ] each + ] curry float-array{ } make :> verts + + { 0 0 } { 320 240 } set-gpu-state + GL_POINT_SPRITE glEnable + world verts { + { "primitive-mode" [ 2drop points-mode ] } + { "uniforms" [ drop texture>> 50.0 window-point-uniforms boa ] } + { "vertex-array" [ nip stream-upload draw-usage vertex-buffer byte-array>buffer &dispose window-point-program &dispose &dispose ] } + { "indexes" [ nip length 2 / 0 swap ] } + { "framebuffer" [ drop framebuffer>> ] } + } 2 render + + world color-texture>> gaussian-blur + { 0 0 } { 640 480 } set-gpu-state + world ramp>> { + { "primitive-mode" [ 2drop triangle-strip-mode ] } + { "uniforms" [ step-uniforms boa ] } + { "vertex-array" [ 2drop step-program ] } + { "indexes" [ 2drop T{ index-range f 0 4 } ] } + } 2 render + ; + +GAME: fluids { + { world-class fluids-world } + { title "Fluids Test" } + { pixel-format-attributes { + windowed double-buffered T{ depth-bits { value 24 } } } } + { pref-dim { 640 480 } } + { tick-interval-micros $[ 60 fps ] } +} ; + +MAIN: fluids + +fluids-world H{ + { T{ button-down } [ [ + hand-loc get { 640 480 } v/ 2 v*n 1 v-n { 1 -1 } v* first2 float2_t + dup 2.0 particle_t suffix + ] change-particles drop ] } +} set-gestures diff --git a/extra/fluids/particle2.pgm b/extra/fluids/particle2.pgm new file mode 100644 index 0000000000..99bf7a4057 --- /dev/null +++ b/extra/fluids/particle2.pgm @@ -0,0 +1,16388 @@ +P2 +# CREATOR: GIMP PNM Filter Version 1.1 +128 128 +255 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +1 +2 +2 +3 +3 +3 +4 +4 +4 +4 +4 +4 +4 +4 +3 +4 +3 +3 +3 +2 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +3 +3 +3 +4 +5 +6 +6 +7 +7 +7 +7 +8 +8 +8 +8 +8 +8 +8 +8 +7 +7 +6 +6 +5 +5 +4 +4 +2 +2 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +2 +4 +4 +5 +6 +7 +7 +8 +8 +10 +10 +10 +11 +12 +12 +12 +12 +12 +12 +12 +12 +12 +11 +11 +11 +11 +10 +10 +9 +8 +7 +7 +6 +5 +5 +3 +2 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +3 +5 +6 +7 +7 +9 +10 +10 +11 +12 +13 +13 +14 +14 +15 +15 +15 +15 +16 +16 +16 +15 +15 +16 +15 +15 +15 +15 +14 +13 +13 +12 +12 +11 +10 +9 +7 +6 +6 +5 +4 +3 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +1 +3 +4 +6 +7 +9 +9 +10 +12 +13 +13 +15 +15 +16 +17 +17 +18 +18 +19 +19 +19 +20 +20 +20 +20 +20 +20 +20 +19 +19 +19 +19 +18 +17 +17 +16 +15 +14 +13 +13 +12 +10 +9 +8 +7 +6 +5 +3 +2 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +2 +4 +6 +7 +9 +9 +11 +12 +14 +15 +15 +16 +17 +19 +19 +19 +20 +21 +21 +23 +23 +23 +23 +23 +24 +24 +24 +24 +24 +24 +24 +22 +23 +23 +21 +21 +20 +19 +19 +19 +18 +16 +16 +15 +13 +12 +11 +10 +8 +6 +5 +4 +2 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +3 +4 +6 +8 +9 +11 +12 +13 +14 +16 +17 +18 +19 +20 +21 +22 +23 +23 +25 +25 +26 +26 +26 +27 +27 +27 +27 +28 +27 +28 +28 +27 +27 +27 +26 +26 +26 +25 +25 +24 +23 +22 +21 +21 +19 +18 +17 +16 +15 +13 +12 +10 +9 +8 +5 +4 +3 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +2 +5 +6 +8 +9 +11 +13 +14 +16 +17 +19 +19 +20 +21 +23 +24 +25 +26 +27 +28 +28 +28 +29 +30 +30 +31 +31 +31 +32 +31 +32 +31 +32 +31 +32 +31 +31 +30 +29 +29 +28 +27 +27 +26 +25 +24 +23 +22 +20 +19 +18 +16 +15 +14 +13 +11 +9 +8 +6 +5 +2 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +4 +7 +8 +10 +12 +13 +15 +16 +18 +19 +20 +22 +23 +25 +26 +27 +28 +29 +30 +30 +32 +32 +33 +33 +34 +34 +35 +35 +35 +35 +35 +36 +35 +35 +35 +35 +34 +35 +34 +33 +33 +32 +32 +30 +30 +28 +28 +27 +26 +25 +23 +22 +21 +19 +18 +17 +15 +13 +11 +10 +8 +6 +5 +2 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +3 +6 +7 +10 +12 +13 +15 +17 +18 +20 +21 +22 +24 +26 +27 +28 +30 +31 +31 +32 +33 +34 +35 +36 +37 +37 +37 +38 +38 +39 +39 +40 +39 +39 +39 +39 +40 +39 +39 +38 +38 +37 +36 +36 +36 +34 +33 +33 +32 +30 +30 +29 +26 +26 +25 +23 +22 +20 +19 +17 +15 +14 +11 +9 +8 +5 +3 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +5 +7 +9 +11 +13 +15 +16 +19 +20 +22 +23 +25 +27 +28 +30 +30 +32 +33 +34 +35 +37 +37 +39 +40 +39 +40 +41 +42 +42 +43 +43 +43 +43 +44 +43 +44 +43 +43 +43 +42 +43 +41 +41 +40 +40 +39 +38 +38 +37 +35 +34 +34 +32 +30 +30 +28 +27 +25 +24 +22 +21 +19 +17 +15 +13 +11 +9 +7 +5 +3 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +4 +6 +8 +11 +13 +15 +16 +18 +21 +22 +23 +25 +27 +28 +30 +32 +33 +35 +35 +37 +38 +39 +40 +41 +42 +43 +44 +45 +45 +45 +46 +47 +47 +47 +47 +47 +48 +47 +47 +47 +47 +47 +46 +45 +45 +45 +43 +43 +42 +41 +41 +40 +38 +37 +36 +34 +33 +32 +30 +28 +27 +26 +24 +22 +20 +18 +16 +15 +12 +10 +9 +6 +4 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +5 +8 +10 +11 +14 +16 +17 +19 +22 +24 +25 +27 +29 +31 +32 +34 +36 +36 +38 +39 +40 +42 +42 +44 +45 +45 +47 +48 +48 +49 +49 +50 +51 +50 +51 +51 +52 +51 +51 +51 +51 +51 +50 +50 +50 +49 +48 +47 +47 +46 +44 +44 +43 +42 +41 +40 +38 +37 +35 +33 +32 +31 +28 +27 +25 +24 +22 +20 +18 +15 +13 +11 +10 +8 +5 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +4 +6 +8 +11 +12 +15 +17 +19 +21 +23 +25 +27 +29 +31 +32 +34 +35 +38 +39 +40 +42 +43 +44 +45 +47 +48 +49 +49 +51 +52 +52 +52 +53 +54 +54 +54 +55 +55 +55 +55 +55 +55 +55 +54 +54 +53 +54 +53 +52 +52 +50 +50 +49 +47 +46 +45 +44 +43 +42 +41 +39 +37 +36 +34 +32 +31 +29 +27 +25 +23 +21 +19 +17 +15 +13 +10 +8 +5 +3 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +4 +7 +8 +11 +13 +16 +18 +21 +22 +25 +27 +28 +30 +32 +34 +35 +37 +39 +41 +42 +44 +45 +47 +48 +50 +50 +51 +53 +54 +55 +55 +55 +56 +57 +58 +58 +58 +59 +58 +59 +59 +59 +59 +58 +58 +58 +57 +57 +57 +56 +55 +54 +53 +52 +52 +50 +49 +48 +47 +46 +44 +42 +41 +40 +37 +36 +34 +32 +31 +29 +26 +24 +22 +20 +18 +16 +13 +11 +9 +6 +4 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +4 +7 +9 +12 +14 +17 +19 +21 +23 +26 +28 +30 +32 +34 +36 +37 +39 +41 +43 +44 +46 +48 +49 +51 +52 +53 +55 +55 +56 +57 +58 +59 +59 +60 +61 +62 +62 +62 +63 +63 +63 +63 +63 +63 +62 +62 +62 +62 +61 +60 +60 +59 +58 +57 +56 +55 +54 +53 +52 +51 +49 +47 +46 +44 +43 +41 +40 +37 +36 +34 +32 +30 +28 +25 +23 +21 +19 +17 +15 +12 +10 +7 +5 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +5 +8 +10 +13 +15 +17 +20 +22 +24 +27 +29 +31 +33 +35 +37 +39 +41 +43 +45 +46 +48 +50 +51 +53 +54 +56 +57 +58 +60 +60 +61 +62 +63 +63 +64 +65 +66 +66 +66 +67 +67 +67 +66 +67 +67 +67 +66 +66 +65 +65 +64 +64 +63 +62 +61 +61 +59 +58 +57 +55 +54 +53 +51 +50 +49 +46 +44 +43 +41 +39 +37 +35 +33 +31 +29 +27 +24 +22 +20 +17 +15 +12 +10 +7 +5 +3 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +5 +8 +10 +13 +16 +19 +21 +23 +26 +28 +30 +32 +34 +37 +38 +41 +43 +45 +47 +48 +50 +52 +53 +55 +57 +58 +59 +60 +61 +63 +64 +65 +65 +67 +68 +68 +69 +69 +70 +70 +70 +70 +70 +71 +71 +71 +70 +71 +70 +69 +68 +68 +67 +66 +66 +65 +64 +63 +62 +60 +59 +58 +56 +55 +53 +52 +50 +49 +46 +44 +43 +40 +38 +37 +34 +32 +30 +28 +26 +23 +21 +18 +16 +13 +11 +8 +6 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +5 +8 +11 +14 +16 +18 +21 +24 +26 +29 +31 +33 +36 +37 +40 +42 +44 +46 +48 +50 +51 +54 +55 +56 +58 +60 +61 +63 +64 +65 +67 +67 +69 +70 +71 +71 +72 +73 +73 +74 +74 +74 +74 +75 +75 +75 +75 +75 +74 +74 +73 +73 +72 +71 +70 +70 +69 +68 +66 +65 +64 +63 +62 +60 +59 +56 +55 +53 +51 +50 +48 +46 +44 +41 +39 +37 +35 +33 +31 +28 +26 +24 +21 +19 +16 +14 +11 +9 +6 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +5 +9 +11 +13 +16 +19 +22 +24 +26 +30 +32 +34 +36 +39 +41 +43 +46 +48 +50 +51 +53 +55 +57 +58 +60 +62 +63 +65 +66 +68 +70 +70 +72 +73 +73 +75 +75 +76 +76 +77 +78 +78 +79 +78 +78 +79 +79 +78 +78 +78 +78 +77 +76 +75 +75 +75 +73 +73 +72 +70 +69 +68 +66 +65 +64 +62 +60 +59 +57 +56 +53 +51 +50 +48 +45 +44 +40 +39 +36 +34 +32 +29 +27 +24 +21 +19 +16 +14 +11 +9 +6 +3 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +6 +8 +11 +14 +16 +19 +22 +24 +27 +30 +32 +35 +37 +40 +42 +44 +46 +48 +50 +53 +55 +57 +58 +61 +62 +64 +65 +67 +69 +70 +72 +73 +74 +75 +77 +78 +78 +79 +80 +80 +81 +81 +82 +82 +82 +83 +83 +83 +83 +82 +82 +81 +81 +81 +80 +79 +78 +78 +77 +75 +74 +73 +72 +71 +68 +67 +66 +64 +62 +61 +59 +57 +55 +52 +50 +49 +46 +44 +42 +39 +37 +35 +32 +30 +28 +24 +22 +19 +17 +14 +11 +9 +6 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +6 +9 +11 +14 +17 +19 +22 +25 +28 +31 +33 +35 +38 +41 +43 +45 +48 +50 +52 +54 +56 +58 +61 +62 +64 +65 +67 +69 +71 +72 +74 +75 +77 +78 +79 +80 +81 +82 +83 +84 +84 +85 +85 +86 +87 +87 +86 +86 +86 +86 +86 +86 +85 +85 +84 +84 +82 +82 +81 +80 +79 +78 +76 +75 +74 +73 +71 +69 +68 +66 +64 +62 +60 +58 +56 +54 +52 +50 +48 +45 +43 +40 +38 +35 +33 +30 +27 +25 +22 +20 +16 +13 +11 +8 +6 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +5 +8 +11 +14 +17 +19 +22 +25 +28 +31 +33 +35 +38 +41 +43 +45 +48 +51 +52 +54 +57 +59 +62 +64 +65 +68 +69 +71 +73 +75 +76 +78 +79 +80 +82 +83 +84 +85 +86 +87 +87 +89 +89 +89 +90 +90 +90 +90 +90 +90 +91 +90 +90 +89 +89 +88 +88 +87 +85 +85 +84 +82 +81 +81 +79 +77 +76 +75 +73 +71 +69 +68 +66 +63 +61 +59 +57 +55 +52 +50 +48 +45 +43 +40 +38 +36 +33 +31 +28 +25 +22 +19 +16 +14 +11 +8 +5 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +5 +8 +10 +13 +16 +20 +22 +25 +27 +31 +33 +36 +38 +41 +43 +46 +49 +51 +54 +56 +58 +60 +62 +64 +67 +69 +71 +73 +75 +77 +78 +80 +81 +83 +84 +85 +87 +88 +88 +89 +91 +91 +92 +93 +93 +94 +94 +94 +94 +94 +95 +94 +94 +94 +93 +93 +92 +91 +90 +90 +89 +87 +87 +86 +84 +83 +81 +80 +78 +77 +75 +73 +70 +69 +67 +65 +62 +60 +58 +56 +54 +51 +48 +46 +43 +42 +38 +36 +33 +31 +28 +25 +22 +19 +16 +13 +11 +8 +5 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +4 +7 +10 +13 +17 +19 +22 +25 +28 +30 +33 +36 +39 +41 +44 +47 +50 +52 +54 +56 +59 +61 +64 +66 +68 +70 +72 +74 +76 +77 +80 +82 +83 +85 +87 +87 +89 +90 +92 +92 +93 +94 +96 +96 +97 +97 +97 +98 +98 +98 +98 +98 +98 +98 +98 +97 +97 +95 +95 +94 +93 +92 +92 +90 +89 +88 +86 +84 +83 +81 +79 +78 +76 +74 +72 +70 +68 +66 +64 +61 +59 +57 +54 +52 +50 +46 +44 +41 +39 +36 +33 +30 +27 +25 +22 +19 +16 +13 +10 +7 +4 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +6 +10 +13 +16 +19 +21 +24 +27 +30 +33 +36 +39 +41 +45 +47 +50 +53 +55 +57 +59 +62 +64 +67 +69 +72 +74 +76 +77 +79 +81 +84 +85 +86 +89 +90 +91 +92 +94 +95 +96 +97 +98 +99 +100 +100 +101 +101 +101 +102 +102 +102 +102 +102 +102 +101 +101 +100 +100 +99 +99 +98 +96 +95 +94 +93 +91 +90 +88 +87 +85 +83 +82 +79 +78 +75 +74 +71 +69 +66 +65 +63 +60 +57 +54 +52 +50 +47 +44 +42 +39 +36 +33 +30 +27 +24 +22 +19 +15 +12 +9 +6 +4 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +6 +9 +12 +16 +18 +21 +24 +27 +30 +34 +36 +39 +41 +44 +48 +49 +53 +55 +57 +61 +63 +66 +68 +70 +73 +75 +77 +79 +81 +82 +85 +87 +89 +90 +92 +93 +95 +97 +98 +99 +100 +101 +102 +103 +104 +104 +105 +105 +106 +106 +106 +106 +106 +106 +105 +106 +104 +104 +104 +102 +102 +101 +100 +99 +97 +96 +95 +93 +91 +91 +88 +87 +85 +83 +81 +79 +77 +75 +72 +71 +67 +65 +63 +60 +58 +55 +53 +50 +47 +44 +41 +39 +36 +33 +30 +27 +25 +21 +18 +15 +12 +9 +5 +3 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +5 +8 +11 +14 +18 +21 +24 +26 +30 +33 +35 +38 +42 +44 +47 +50 +53 +55 +58 +61 +63 +66 +68 +71 +73 +75 +77 +80 +82 +84 +87 +88 +90 +92 +94 +95 +97 +99 +100 +101 +103 +103 +105 +106 +107 +108 +108 +109 +109 +109 +110 +110 +110 +110 +110 +110 +109 +109 +108 +107 +106 +106 +105 +104 +102 +101 +100 +99 +97 +95 +94 +91 +90 +88 +86 +85 +82 +80 +77 +75 +73 +70 +69 +66 +63 +60 +58 +55 +53 +50 +47 +44 +41 +39 +36 +33 +30 +27 +24 +20 +18 +14 +12 +8 +5 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +4 +7 +11 +14 +17 +20 +23 +26 +29 +33 +35 +38 +41 +44 +47 +50 +53 +55 +58 +61 +64 +66 +69 +71 +73 +77 +78 +81 +83 +86 +87 +90 +92 +93 +96 +97 +99 +100 +102 +103 +105 +107 +107 +108 +110 +110 +111 +112 +113 +113 +113 +114 +113 +113 +114 +113 +114 +113 +113 +112 +112 +110 +110 +108 +108 +106 +105 +104 +102 +100 +99 +97 +96 +94 +92 +90 +88 +85 +84 +81 +79 +76 +74 +71 +69 +66 +63 +61 +59 +55 +53 +50 +47 +44 +41 +39 +35 +32 +29 +26 +23 +20 +17 +13 +10 +7 +4 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +6 +10 +13 +16 +19 +23 +26 +28 +32 +35 +38 +41 +44 +47 +50 +53 +56 +58 +61 +64 +67 +69 +72 +74 +77 +80 +82 +85 +86 +89 +91 +93 +95 +97 +99 +101 +103 +104 +106 +108 +108 +110 +111 +112 +114 +114 +115 +116 +117 +117 +117 +118 +118 +117 +118 +118 +117 +117 +116 +116 +115 +115 +113 +113 +111 +110 +108 +107 +106 +104 +102 +101 +99 +97 +95 +93 +91 +89 +86 +85 +82 +79 +76 +74 +72 +69 +66 +64 +61 +58 +56 +52 +49 +47 +44 +41 +38 +35 +31 +28 +26 +22 +19 +16 +12 +9 +6 +3 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +5 +8 +12 +15 +19 +21 +25 +28 +30 +34 +37 +40 +43 +47 +49 +52 +56 +58 +61 +63 +67 +70 +72 +75 +78 +80 +83 +85 +87 +90 +92 +94 +96 +99 +100 +102 +104 +106 +108 +109 +111 +112 +114 +115 +116 +117 +118 +119 +120 +120 +121 +121 +121 +121 +121 +122 +121 +122 +120 +120 +120 +119 +118 +118 +116 +115 +113 +112 +111 +109 +108 +106 +104 +102 +101 +98 +97 +94 +92 +90 +87 +85 +82 +80 +78 +75 +72 +70 +66 +64 +61 +58 +55 +52 +50 +46 +44 +40 +37 +34 +31 +27 +25 +21 +18 +15 +12 +9 +5 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +7 +11 +13 +17 +20 +23 +27 +30 +34 +37 +39 +43 +46 +48 +52 +55 +58 +61 +63 +66 +69 +72 +75 +77 +80 +83 +85 +88 +91 +93 +95 +97 +99 +102 +104 +106 +107 +110 +111 +113 +115 +116 +117 +119 +120 +121 +122 +123 +123 +124 +124 +125 +125 +125 +126 +125 +125 +125 +125 +124 +124 +122 +122 +120 +120 +118 +117 +116 +115 +112 +111 +109 +108 +105 +104 +102 +99 +97 +95 +93 +90 +88 +86 +83 +80 +77 +75 +72 +70 +66 +64 +61 +58 +54 +52 +48 +46 +43 +39 +36 +33 +30 +26 +23 +21 +17 +13 +10 +7 +3 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +6 +9 +12 +16 +19 +22 +25 +29 +32 +35 +39 +42 +45 +48 +51 +54 +57 +60 +63 +66 +70 +72 +75 +78 +81 +83 +86 +89 +90 +94 +96 +98 +101 +103 +105 +107 +109 +111 +113 +115 +116 +118 +119 +121 +122 +124 +125 +126 +127 +127 +128 +128 +129 +129 +129 +130 +129 +129 +129 +129 +128 +127 +126 +126 +124 +123 +122 +122 +119 +118 +116 +114 +113 +112 +109 +107 +105 +103 +101 +98 +96 +93 +91 +88 +86 +83 +81 +78 +75 +72 +69 +66 +63 +60 +57 +54 +51 +48 +45 +41 +38 +36 +32 +29 +26 +23 +19 +16 +13 +9 +5 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +4 +8 +11 +14 +18 +21 +24 +28 +31 +34 +38 +41 +44 +47 +51 +53 +57 +60 +62 +66 +68 +72 +75 +78 +80 +83 +86 +89 +92 +93 +97 +99 +102 +104 +106 +109 +111 +112 +115 +116 +118 +120 +122 +124 +125 +126 +128 +128 +129 +131 +131 +132 +133 +133 +133 +134 +134 +133 +134 +133 +132 +132 +132 +130 +129 +129 +127 +126 +125 +123 +122 +120 +119 +116 +115 +112 +110 +108 +106 +104 +102 +99 +97 +94 +91 +89 +86 +83 +80 +78 +75 +72 +69 +66 +63 +60 +57 +53 +50 +47 +44 +41 +38 +34 +32 +28 +25 +21 +18 +15 +11 +7 +4 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +6 +9 +13 +16 +20 +23 +27 +30 +33 +37 +40 +43 +46 +50 +53 +56 +59 +62 +65 +68 +72 +74 +77 +81 +83 +86 +89 +92 +94 +97 +100 +102 +105 +106 +109 +112 +114 +115 +118 +120 +122 +124 +125 +127 +129 +130 +131 +133 +134 +134 +135 +136 +136 +137 +137 +138 +137 +137 +137 +137 +137 +136 +135 +135 +133 +132 +131 +130 +128 +127 +125 +124 +122 +120 +118 +116 +114 +111 +109 +107 +105 +102 +100 +97 +95 +92 +89 +86 +83 +80 +77 +74 +71 +68 +66 +62 +59 +56 +53 +49 +46 +43 +39 +37 +33 +30 +27 +23 +20 +17 +13 +10 +6 +3 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +5 +8 +12 +15 +19 +22 +25 +29 +32 +35 +38 +42 +46 +48 +51 +55 +58 +61 +64 +68 +71 +74 +77 +80 +83 +86 +88 +91 +94 +97 +99 +103 +105 +108 +110 +113 +115 +117 +119 +121 +123 +125 +127 +129 +130 +132 +133 +135 +136 +137 +138 +139 +140 +140 +140 +141 +141 +141 +141 +141 +140 +140 +140 +138 +138 +137 +136 +135 +133 +132 +130 +128 +127 +125 +123 +121 +119 +117 +115 +113 +110 +108 +105 +103 +100 +97 +94 +92 +88 +86 +83 +80 +77 +74 +71 +68 +65 +62 +58 +55 +52 +48 +45 +42 +39 +36 +31 +29 +26 +22 +19 +15 +11 +8 +4 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +6 +10 +14 +17 +20 +24 +27 +30 +34 +37 +41 +44 +47 +51 +53 +57 +61 +64 +67 +70 +73 +76 +80 +82 +85 +88 +91 +94 +97 +100 +102 +105 +108 +110 +113 +116 +118 +121 +122 +125 +126 +128 +131 +133 +134 +135 +137 +139 +139 +141 +142 +143 +144 +144 +145 +145 +146 +146 +145 +145 +144 +145 +143 +142 +142 +141 +140 +139 +137 +135 +134 +132 +131 +128 +127 +125 +123 +120 +118 +116 +113 +110 +107 +105 +103 +100 +97 +95 +91 +89 +85 +82 +79 +76 +73 +70 +67 +63 +61 +57 +54 +50 +48 +44 +41 +37 +34 +30 +27 +24 +20 +17 +13 +10 +6 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +5 +8 +11 +15 +19 +21 +25 +29 +32 +36 +39 +43 +46 +50 +53 +56 +60 +63 +66 +69 +72 +76 +78 +82 +85 +87 +91 +94 +97 +100 +103 +106 +108 +111 +114 +116 +119 +121 +124 +126 +128 +130 +132 +134 +136 +138 +140 +141 +143 +143 +144 +145 +146 +147 +148 +148 +149 +149 +149 +149 +149 +148 +148 +148 +146 +146 +145 +144 +142 +141 +139 +138 +136 +134 +132 +130 +128 +126 +123 +121 +119 +116 +114 +111 +109 +105 +102 +99 +97 +94 +91 +88 +85 +81 +79 +76 +72 +69 +66 +63 +60 +56 +53 +49 +46 +43 +39 +36 +32 +29 +26 +22 +19 +15 +11 +8 +4 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +6 +9 +13 +17 +20 +23 +27 +31 +34 +38 +41 +45 +48 +51 +55 +58 +61 +64 +68 +72 +74 +77 +81 +85 +87 +91 +93 +96 +99 +103 +106 +108 +111 +114 +116 +119 +121 +124 +126 +128 +131 +133 +136 +137 +139 +141 +143 +144 +146 +147 +148 +150 +151 +151 +152 +153 +153 +153 +153 +153 +152 +153 +152 +151 +151 +150 +149 +147 +146 +145 +143 +141 +140 +137 +136 +134 +131 +129 +126 +124 +121 +119 +116 +113 +110 +108 +105 +103 +99 +97 +93 +91 +88 +84 +81 +78 +74 +72 +68 +65 +61 +58 +55 +52 +48 +45 +41 +37 +34 +31 +27 +23 +20 +17 +13 +9 +6 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +4 +8 +11 +15 +18 +22 +25 +29 +33 +36 +39 +42 +46 +49 +53 +57 +60 +64 +66 +70 +74 +77 +80 +84 +86 +90 +93 +96 +99 +102 +105 +108 +111 +113 +116 +119 +122 +125 +127 +130 +132 +134 +136 +139 +141 +143 +145 +147 +148 +150 +151 +153 +153 +155 +155 +156 +156 +157 +157 +157 +157 +157 +156 +156 +155 +154 +153 +153 +151 +150 +148 +146 +144 +142 +140 +139 +136 +134 +131 +129 +127 +124 +122 +119 +117 +114 +111 +108 +105 +102 +99 +96 +93 +89 +86 +84 +80 +76 +73 +70 +67 +63 +60 +56 +54 +50 +46 +43 +39 +36 +32 +29 +25 +22 +18 +14 +11 +7 +4 +0 +0 +0 +0 +0 +0 +0 +0 +2 +5 +9 +12 +16 +20 +24 +26 +31 +34 +38 +42 +45 +48 +52 +55 +59 +62 +65 +69 +72 +75 +79 +83 +86 +89 +92 +95 +98 +102 +104 +107 +111 +113 +116 +119 +122 +124 +128 +130 +133 +135 +137 +139 +142 +144 +146 +148 +150 +151 +153 +154 +156 +157 +158 +159 +160 +161 +161 +160 +161 +161 +161 +160 +160 +159 +158 +157 +156 +155 +154 +152 +150 +148 +147 +144 +142 +140 +137 +135 +133 +130 +128 +124 +122 +119 +116 +113 +111 +107 +104 +101 +98 +95 +92 +89 +85 +82 +79 +75 +72 +68 +65 +62 +58 +55 +52 +48 +45 +41 +38 +35 +30 +27 +23 +19 +16 +13 +9 +5 +2 +0 +0 +0 +0 +0 +0 +0 +4 +7 +11 +14 +18 +22 +25 +28 +32 +36 +39 +43 +46 +50 +54 +57 +60 +64 +67 +71 +74 +77 +81 +84 +87 +91 +94 +98 +100 +104 +107 +110 +113 +116 +119 +122 +124 +127 +130 +133 +135 +139 +140 +143 +145 +147 +149 +152 +153 +155 +157 +158 +159 +161 +162 +163 +164 +164 +164 +164 +165 +165 +164 +165 +164 +162 +162 +161 +159 +158 +156 +155 +153 +152 +150 +147 +145 +142 +141 +138 +136 +133 +130 +127 +124 +122 +119 +116 +113 +110 +107 +104 +101 +97 +94 +91 +88 +84 +81 +77 +74 +71 +67 +64 +61 +57 +54 +50 +47 +43 +39 +36 +33 +28 +25 +22 +18 +14 +11 +6 +3 +0 +0 +0 +0 +0 +0 +1 +5 +9 +12 +16 +19 +23 +26 +30 +33 +38 +41 +44 +48 +51 +55 +58 +62 +66 +69 +73 +76 +80 +83 +86 +90 +93 +96 +99 +103 +106 +109 +112 +115 +118 +122 +125 +127 +130 +133 +136 +138 +141 +144 +146 +149 +150 +152 +154 +157 +158 +160 +162 +163 +165 +166 +166 +167 +168 +168 +169 +169 +168 +169 +168 +167 +167 +166 +165 +164 +162 +160 +158 +157 +155 +153 +150 +149 +146 +144 +141 +139 +136 +133 +130 +127 +124 +121 +118 +116 +113 +109 +106 +102 +99 +96 +93 +89 +86 +83 +80 +77 +73 +69 +66 +62 +59 +55 +51 +48 +44 +41 +37 +34 +31 +26 +23 +19 +16 +12 +8 +5 +1 +0 +0 +0 +0 +0 +2 +6 +10 +13 +17 +21 +24 +28 +31 +35 +39 +43 +46 +50 +53 +57 +61 +63 +68 +71 +74 +78 +81 +85 +88 +92 +95 +99 +102 +105 +108 +112 +115 +118 +121 +124 +127 +130 +132 +136 +138 +142 +144 +146 +149 +151 +154 +157 +159 +160 +162 +164 +165 +167 +168 +169 +170 +171 +172 +172 +172 +172 +173 +173 +172 +172 +171 +169 +168 +167 +165 +164 +162 +160 +158 +156 +154 +152 +149 +147 +144 +142 +139 +136 +133 +131 +127 +124 +121 +118 +114 +112 +108 +105 +101 +98 +95 +92 +88 +85 +81 +78 +74 +71 +68 +64 +60 +57 +54 +49 +46 +43 +38 +35 +31 +28 +25 +21 +17 +13 +9 +6 +3 +0 +0 +0 +0 +0 +3 +7 +11 +14 +18 +22 +26 +29 +33 +37 +40 +44 +48 +51 +55 +58 +62 +66 +69 +73 +76 +80 +83 +86 +90 +94 +97 +100 +104 +107 +110 +114 +117 +120 +123 +127 +130 +133 +136 +139 +142 +144 +147 +150 +152 +155 +157 +159 +161 +163 +166 +168 +169 +171 +172 +173 +174 +175 +176 +176 +177 +177 +177 +176 +176 +175 +174 +174 +172 +170 +169 +167 +166 +164 +161 +159 +157 +154 +152 +149 +147 +144 +141 +138 +135 +133 +130 +127 +123 +120 +117 +114 +110 +107 +104 +101 +97 +93 +90 +87 +83 +80 +77 +73 +69 +66 +62 +58 +55 +51 +48 +44 +40 +37 +33 +30 +26 +22 +18 +15 +11 +7 +4 +0 +0 +0 +0 +1 +5 +8 +12 +16 +20 +23 +27 +30 +34 +38 +42 +45 +49 +53 +57 +60 +63 +67 +71 +75 +78 +81 +85 +89 +92 +95 +99 +102 +106 +109 +113 +116 +119 +122 +126 +128 +132 +135 +138 +141 +144 +147 +149 +153 +155 +157 +160 +163 +165 +167 +169 +171 +173 +174 +175 +177 +178 +178 +179 +181 +180 +180 +180 +180 +179 +178 +178 +177 +175 +174 +172 +171 +169 +167 +165 +163 +160 +158 +155 +152 +150 +147 +144 +141 +138 +135 +132 +129 +126 +122 +119 +116 +112 +109 +106 +102 +99 +96 +92 +88 +85 +82 +78 +74 +71 +68 +63 +60 +56 +52 +49 +45 +42 +38 +34 +30 +27 +24 +19 +16 +12 +9 +4 +1 +0 +0 +0 +2 +6 +10 +13 +17 +21 +24 +28 +32 +35 +40 +43 +47 +51 +54 +58 +62 +65 +68 +72 +76 +79 +83 +87 +90 +93 +97 +101 +104 +108 +111 +114 +118 +121 +125 +128 +131 +134 +137 +141 +144 +147 +150 +153 +155 +158 +161 +163 +166 +168 +170 +172 +174 +177 +178 +179 +181 +182 +182 +184 +184 +184 +185 +185 +184 +184 +182 +182 +181 +179 +177 +176 +174 +172 +170 +168 +166 +163 +160 +158 +155 +152 +149 +147 +144 +140 +137 +134 +131 +128 +125 +121 +118 +115 +111 +108 +104 +101 +98 +94 +90 +87 +84 +80 +76 +72 +69 +65 +62 +58 +54 +50 +47 +43 +40 +36 +32 +29 +24 +21 +17 +13 +10 +6 +2 +0 +0 +0 +3 +7 +10 +15 +18 +22 +25 +30 +33 +37 +40 +45 +48 +52 +56 +59 +63 +67 +71 +74 +78 +81 +84 +88 +92 +95 +99 +102 +106 +109 +113 +117 +120 +124 +126 +130 +134 +137 +140 +143 +146 +150 +153 +155 +158 +161 +164 +166 +169 +171 +173 +176 +178 +179 +181 +183 +184 +186 +187 +187 +187 +188 +189 +189 +188 +187 +187 +186 +184 +183 +181 +180 +178 +175 +174 +171 +169 +166 +163 +160 +158 +155 +153 +149 +146 +143 +140 +137 +133 +130 +126 +123 +120 +116 +113 +110 +106 +103 +99 +95 +92 +88 +84 +82 +78 +73 +70 +66 +63 +59 +55 +52 +48 +45 +40 +37 +33 +29 +25 +22 +18 +14 +11 +7 +3 +0 +0 +0 +4 +8 +12 +15 +19 +23 +26 +31 +35 +38 +42 +46 +50 +53 +57 +61 +64 +67 +71 +75 +79 +83 +87 +90 +93 +97 +100 +104 +107 +112 +115 +119 +122 +125 +129 +132 +136 +139 +142 +145 +148 +152 +155 +158 +161 +164 +166 +169 +171 +174 +176 +179 +181 +183 +185 +186 +188 +190 +190 +191 +192 +192 +192 +193 +192 +191 +190 +189 +188 +187 +185 +183 +181 +179 +177 +174 +172 +169 +166 +164 +161 +158 +154 +151 +149 +145 +142 +138 +136 +132 +129 +125 +122 +118 +114 +111 +108 +105 +100 +97 +94 +89 +86 +82 +79 +76 +71 +68 +64 +60 +56 +53 +49 +46 +42 +39 +34 +31 +27 +23 +19 +16 +11 +8 +4 +1 +0 +1 +5 +9 +13 +16 +20 +24 +28 +32 +35 +39 +43 +47 +50 +55 +58 +61 +65 +69 +73 +77 +80 +84 +87 +91 +94 +99 +102 +106 +110 +113 +116 +120 +123 +127 +130 +134 +137 +140 +145 +148 +151 +154 +157 +160 +163 +166 +169 +172 +175 +177 +180 +182 +185 +186 +189 +190 +192 +193 +194 +195 +196 +196 +196 +196 +195 +195 +194 +193 +191 +190 +188 +187 +184 +182 +180 +177 +174 +171 +169 +166 +163 +160 +157 +153 +151 +148 +144 +140 +137 +134 +130 +127 +124 +121 +116 +113 +110 +105 +102 +98 +95 +91 +87 +84 +80 +77 +73 +69 +65 +62 +58 +54 +50 +46 +43 +39 +36 +32 +27 +24 +21 +17 +12 +9 +5 +2 +0 +2 +6 +9 +14 +17 +21 +25 +29 +32 +36 +40 +44 +48 +51 +55 +59 +63 +66 +70 +74 +78 +82 +85 +89 +92 +96 +100 +103 +108 +111 +114 +118 +121 +125 +128 +132 +136 +140 +143 +146 +149 +153 +156 +160 +162 +166 +169 +171 +174 +177 +180 +183 +185 +188 +189 +192 +194 +195 +197 +198 +199 +199 +200 +200 +200 +200 +199 +198 +197 +195 +194 +191 +190 +188 +185 +182 +180 +177 +175 +172 +169 +166 +163 +159 +156 +153 +150 +146 +143 +140 +136 +132 +129 +126 +121 +118 +115 +111 +107 +103 +100 +97 +93 +89 +85 +81 +78 +74 +71 +66 +63 +60 +55 +51 +47 +44 +40 +36 +32 +29 +25 +21 +17 +14 +10 +6 +2 +0 +3 +7 +11 +15 +18 +22 +26 +29 +33 +37 +41 +45 +49 +53 +56 +60 +63 +68 +72 +75 +79 +83 +87 +90 +94 +97 +101 +105 +109 +113 +116 +119 +124 +127 +131 +134 +137 +141 +145 +148 +152 +155 +158 +162 +165 +168 +171 +175 +177 +180 +183 +185 +188 +191 +193 +195 +197 +199 +200 +201 +203 +203 +204 +204 +204 +203 +202 +202 +200 +199 +197 +195 +193 +190 +188 +186 +183 +180 +177 +174 +171 +168 +165 +162 +158 +155 +151 +148 +144 +142 +138 +134 +131 +127 +123 +119 +116 +113 +109 +105 +102 +98 +94 +90 +86 +83 +79 +76 +71 +68 +64 +60 +56 +53 +49 +45 +41 +38 +34 +30 +26 +22 +18 +14 +10 +7 +3 +0 +4 +7 +11 +16 +19 +23 +26 +31 +35 +38 +42 +46 +49 +53 +57 +61 +65 +69 +72 +77 +80 +84 +87 +92 +96 +99 +102 +106 +110 +113 +117 +122 +124 +128 +132 +135 +139 +143 +146 +150 +153 +157 +160 +163 +167 +170 +173 +177 +180 +183 +186 +188 +191 +194 +196 +199 +200 +203 +204 +206 +207 +207 +208 +208 +208 +208 +206 +206 +204 +203 +201 +198 +196 +194 +191 +189 +186 +183 +180 +177 +174 +170 +167 +164 +160 +157 +153 +150 +146 +143 +140 +135 +132 +128 +125 +121 +117 +113 +110 +106 +103 +99 +95 +92 +88 +84 +80 +76 +72 +69 +64 +62 +57 +53 +50 +46 +42 +38 +35 +30 +27 +23 +19 +15 +11 +8 +3 +1 +4 +8 +12 +16 +20 +23 +28 +31 +36 +39 +43 +47 +51 +54 +59 +62 +66 +70 +74 +78 +81 +85 +89 +93 +96 +100 +104 +108 +111 +115 +119 +122 +126 +130 +134 +137 +140 +144 +148 +152 +155 +159 +162 +165 +169 +173 +176 +179 +183 +185 +189 +191 +194 +197 +199 +201 +204 +206 +208 +209 +211 +211 +212 +212 +212 +212 +210 +209 +208 +206 +204 +201 +199 +197 +194 +191 +188 +185 +182 +179 +175 +173 +169 +166 +162 +159 +155 +151 +148 +144 +140 +137 +134 +130 +126 +122 +119 +115 +112 +107 +104 +100 +96 +92 +89 +85 +81 +77 +73 +70 +66 +62 +58 +54 +50 +47 +43 +39 +36 +32 +28 +24 +20 +16 +12 +8 +5 +2 +6 +9 +13 +16 +21 +25 +28 +32 +36 +40 +44 +47 +51 +55 +59 +63 +66 +71 +74 +78 +82 +86 +89 +93 +97 +101 +104 +108 +113 +116 +120 +124 +128 +131 +135 +139 +142 +145 +149 +153 +156 +160 +164 +168 +171 +174 +178 +181 +184 +187 +191 +194 +196 +200 +202 +205 +208 +210 +211 +213 +214 +215 +216 +216 +215 +215 +214 +213 +211 +209 +207 +205 +202 +199 +197 +194 +191 +187 +185 +181 +178 +174 +170 +168 +164 +160 +157 +154 +149 +145 +142 +139 +135 +131 +128 +124 +120 +116 +112 +108 +104 +101 +98 +94 +90 +86 +82 +78 +74 +70 +67 +63 +59 +55 +51 +47 +43 +40 +36 +32 +28 +24 +21 +17 +13 +9 +5 +1 +5 +10 +13 +17 +21 +25 +29 +33 +37 +40 +45 +48 +52 +56 +60 +63 +67 +71 +75 +79 +83 +87 +90 +94 +98 +102 +106 +109 +113 +117 +121 +124 +128 +132 +136 +139 +143 +147 +151 +155 +158 +162 +165 +169 +172 +176 +179 +183 +187 +190 +193 +196 +199 +202 +205 +208 +210 +213 +215 +216 +218 +219 +219 +220 +219 +219 +218 +217 +215 +213 +211 +207 +205 +202 +200 +197 +193 +190 +187 +183 +179 +176 +172 +169 +165 +162 +158 +155 +151 +148 +143 +140 +136 +132 +128 +124 +121 +117 +113 +110 +106 +102 +98 +94 +90 +87 +83 +79 +76 +72 +67 +64 +60 +56 +52 +48 +45 +40 +37 +32 +29 +25 +21 +17 +13 +10 +6 +3 +7 +10 +14 +18 +21 +26 +30 +33 +37 +41 +45 +49 +52 +56 +61 +64 +68 +72 +76 +80 +84 +87 +92 +95 +99 +103 +107 +110 +114 +118 +121 +125 +130 +133 +137 +141 +145 +148 +152 +155 +160 +163 +167 +171 +174 +178 +181 +185 +189 +192 +195 +198 +202 +205 +208 +211 +214 +216 +218 +220 +222 +222 +224 +223 +224 +223 +221 +220 +218 +216 +213 +211 +208 +205 +202 +199 +195 +192 +188 +185 +181 +178 +174 +171 +167 +164 +159 +156 +152 +149 +145 +141 +138 +133 +129 +126 +122 +118 +114 +110 +107 +103 +99 +96 +91 +87 +84 +80 +75 +72 +69 +64 +61 +57 +53 +49 +45 +41 +37 +34 +30 +26 +22 +18 +13 +10 +6 +2 +7 +10 +14 +18 +22 +26 +30 +34 +38 +41 +46 +49 +54 +57 +61 +65 +68 +73 +76 +81 +84 +88 +92 +96 +100 +103 +107 +111 +115 +119 +123 +127 +130 +134 +138 +142 +146 +150 +153 +157 +161 +164 +168 +172 +175 +180 +183 +186 +190 +193 +197 +200 +204 +208 +211 +214 +217 +219 +222 +223 +225 +226 +227 +228 +227 +227 +225 +223 +222 +219 +216 +214 +211 +207 +204 +200 +197 +194 +190 +187 +183 +179 +175 +172 +168 +164 +161 +157 +153 +150 +145 +142 +138 +134 +130 +126 +123 +118 +115 +111 +107 +103 +100 +96 +92 +88 +85 +80 +76 +73 +69 +65 +61 +57 +53 +49 +45 +41 +37 +34 +29 +27 +22 +18 +15 +10 +7 +3 +7 +11 +15 +19 +22 +27 +30 +34 +38 +42 +46 +50 +53 +58 +62 +66 +70 +73 +77 +81 +85 +89 +93 +97 +101 +104 +109 +112 +116 +119 +123 +128 +132 +135 +139 +143 +146 +151 +154 +158 +161 +165 +169 +173 +177 +181 +185 +188 +191 +196 +199 +203 +206 +209 +212 +215 +219 +222 +224 +226 +229 +231 +231 +231 +231 +230 +229 +226 +224 +221 +219 +216 +212 +209 +206 +203 +199 +195 +191 +188 +184 +180 +177 +174 +170 +166 +162 +158 +155 +151 +146 +142 +139 +135 +131 +127 +123 +119 +116 +112 +109 +104 +100 +96 +92 +89 +85 +81 +78 +73 +70 +66 +62 +57 +54 +50 +46 +42 +39 +34 +31 +27 +23 +19 +15 +11 +7 +3 +7 +11 +15 +19 +23 +27 +31 +34 +39 +43 +46 +51 +54 +58 +62 +66 +70 +73 +78 +82 +86 +90 +93 +97 +101 +105 +109 +113 +116 +120 +124 +128 +132 +136 +139 +143 +147 +152 +155 +159 +163 +167 +170 +175 +178 +182 +185 +189 +193 +197 +200 +205 +207 +211 +215 +218 +221 +225 +227 +229 +232 +234 +235 +235 +235 +234 +232 +230 +227 +225 +221 +218 +215 +211 +207 +204 +200 +197 +193 +189 +185 +181 +178 +175 +170 +166 +163 +159 +155 +152 +147 +144 +140 +135 +132 +128 +124 +120 +116 +112 +108 +105 +101 +97 +93 +89 +85 +82 +78 +74 +69 +66 +62 +58 +54 +51 +46 +42 +39 +35 +31 +27 +23 +19 +15 +11 +7 +4 +7 +12 +16 +19 +24 +28 +31 +35 +39 +43 +46 +51 +55 +59 +63 +66 +70 +74 +78 +82 +86 +90 +93 +97 +102 +105 +110 +113 +117 +121 +125 +129 +133 +136 +140 +144 +148 +152 +156 +159 +163 +168 +171 +175 +179 +183 +187 +191 +194 +198 +202 +205 +209 +213 +216 +220 +224 +227 +230 +233 +235 +237 +239 +239 +239 +237 +235 +232 +230 +226 +224 +220 +217 +213 +209 +205 +201 +198 +194 +190 +186 +183 +179 +175 +171 +167 +164 +160 +156 +152 +148 +144 +141 +137 +132 +129 +125 +121 +117 +113 +109 +105 +101 +98 +94 +90 +85 +82 +78 +74 +70 +66 +62 +59 +55 +51 +47 +43 +39 +35 +31 +28 +23 +19 +15 +12 +7 +4 +8 +12 +15 +19 +23 +27 +31 +36 +39 +43 +47 +51 +55 +59 +63 +67 +70 +75 +78 +82 +86 +90 +94 +97 +102 +106 +110 +113 +117 +122 +125 +129 +133 +137 +141 +144 +148 +152 +156 +160 +164 +168 +171 +175 +180 +183 +188 +191 +195 +199 +203 +207 +210 +214 +218 +222 +225 +229 +232 +235 +238 +241 +242 +243 +242 +241 +238 +235 +232 +228 +225 +222 +218 +214 +210 +206 +203 +199 +195 +192 +187 +183 +180 +176 +172 +168 +164 +160 +156 +152 +148 +145 +141 +137 +133 +129 +126 +122 +117 +113 +109 +105 +102 +98 +93 +90 +86 +82 +79 +75 +70 +67 +63 +59 +55 +51 +47 +43 +39 +35 +31 +28 +23 +20 +16 +12 +8 +4 +8 +12 +16 +20 +24 +28 +32 +36 +39 +44 +47 +51 +55 +59 +63 +67 +70 +74 +79 +83 +87 +91 +94 +98 +102 +106 +110 +114 +117 +122 +125 +129 +133 +138 +141 +145 +149 +153 +156 +161 +165 +168 +172 +176 +180 +184 +188 +191 +195 +199 +203 +207 +212 +215 +219 +222 +226 +230 +234 +237 +241 +244 +246 +247 +246 +244 +240 +237 +234 +230 +227 +222 +219 +215 +212 +208 +204 +200 +196 +192 +188 +184 +181 +176 +173 +168 +165 +160 +157 +153 +149 +145 +141 +137 +133 +129 +125 +121 +117 +114 +110 +106 +102 +98 +94 +90 +86 +83 +78 +74 +71 +67 +63 +59 +55 +51 +47 +43 +40 +35 +31 +28 +24 +19 +15 +12 +8 +4 +8 +12 +16 +20 +23 +28 +31 +36 +39 +44 +47 +51 +55 +59 +63 +67 +71 +75 +79 +83 +86 +91 +95 +98 +102 +106 +110 +114 +118 +121 +126 +130 +134 +137 +141 +145 +149 +153 +157 +160 +165 +169 +173 +177 +180 +185 +188 +193 +196 +200 +204 +207 +211 +215 +219 +223 +227 +232 +235 +239 +243 +246 +249 +252 +250 +247 +243 +239 +235 +231 +227 +223 +220 +215 +212 +208 +204 +200 +196 +192 +188 +185 +181 +177 +172 +169 +165 +161 +157 +153 +149 +145 +141 +137 +134 +129 +126 +121 +118 +114 +110 +106 +102 +98 +94 +91 +86 +83 +79 +74 +71 +67 +63 +59 +55 +52 +47 +43 +39 +36 +31 +28 +24 +20 +16 +12 +8 +4 +8 +12 +16 +20 +24 +27 +31 +36 +40 +43 +47 +51 +55 +59 +62 +67 +70 +75 +78 +83 +87 +90 +95 +98 +102 +106 +110 +114 +118 +122 +126 +130 +133 +138 +141 +145 +149 +153 +157 +161 +165 +169 +173 +176 +181 +184 +189 +193 +196 +200 +204 +208 +212 +216 +220 +224 +227 +231 +235 +239 +243 +247 +251 +255 +251 +247 +243 +240 +236 +232 +227 +224 +219 +216 +212 +208 +204 +200 +196 +192 +189 +184 +180 +177 +173 +169 +165 +161 +157 +153 +149 +145 +142 +138 +134 +130 +126 +122 +117 +114 +110 +106 +102 +98 +95 +90 +86 +83 +78 +75 +71 +67 +63 +59 +55 +51 +47 +43 +39 +36 +32 +27 +24 +20 +16 +12 +8 +4 +8 +12 +16 +20 +24 +28 +32 +36 +39 +43 +47 +51 +55 +59 +63 +66 +70 +75 +78 +83 +86 +90 +94 +99 +102 +106 +110 +114 +118 +122 +126 +130 +133 +137 +142 +145 +149 +153 +157 +161 +164 +168 +173 +176 +180 +184 +188 +192 +196 +200 +203 +208 +211 +216 +220 +223 +227 +231 +235 +239 +243 +246 +249 +251 +249 +246 +243 +238 +235 +231 +228 +224 +219 +215 +212 +208 +204 +200 +196 +192 +188 +184 +181 +177 +172 +168 +165 +161 +157 +153 +149 +145 +141 +138 +133 +129 +126 +122 +118 +114 +110 +106 +102 +98 +94 +91 +86 +82 +79 +75 +70 +66 +63 +59 +55 +51 +47 +43 +39 +36 +32 +28 +24 +20 +16 +12 +9 +4 +8 +12 +15 +20 +23 +28 +32 +35 +39 +43 +47 +51 +55 +59 +63 +67 +70 +75 +79 +82 +86 +90 +94 +98 +102 +105 +110 +114 +118 +121 +125 +130 +133 +138 +141 +145 +149 +153 +156 +161 +165 +168 +172 +177 +180 +184 +188 +192 +196 +199 +203 +207 +211 +215 +219 +222 +227 +230 +234 +237 +241 +244 +246 +247 +246 +244 +241 +237 +234 +231 +226 +222 +218 +215 +211 +207 +204 +200 +195 +192 +188 +184 +181 +176 +173 +168 +165 +161 +157 +153 +149 +145 +141 +138 +133 +130 +125 +122 +117 +114 +109 +106 +102 +98 +94 +90 +86 +83 +79 +74 +71 +67 +62 +59 +55 +51 +47 +43 +39 +35 +31 +28 +24 +19 +16 +12 +8 +4 +8 +12 +16 +19 +23 +27 +31 +35 +39 +43 +47 +50 +55 +59 +63 +67 +70 +74 +79 +82 +86 +90 +94 +98 +102 +105 +110 +113 +118 +121 +125 +129 +133 +137 +141 +145 +149 +152 +156 +160 +164 +168 +172 +176 +180 +184 +188 +191 +195 +199 +202 +207 +211 +214 +217 +221 +225 +229 +232 +236 +239 +241 +242 +244 +242 +241 +238 +235 +232 +229 +226 +222 +218 +214 +210 +206 +202 +199 +195 +191 +188 +183 +180 +176 +171 +168 +164 +160 +157 +152 +148 +145 +141 +137 +133 +129 +125 +121 +118 +114 +109 +106 +102 +98 +94 +90 +86 +82 +79 +75 +70 +66 +62 +59 +55 +51 +47 +43 +39 +35 +31 +28 +23 +20 +16 +12 +8 +4 +8 +12 +16 +20 +24 +27 +31 +35 +39 +43 +47 +50 +54 +59 +62 +66 +70 +74 +78 +82 +85 +90 +93 +98 +101 +105 +109 +113 +117 +121 +124 +128 +133 +136 +140 +144 +148 +152 +155 +160 +163 +167 +171 +176 +179 +183 +187 +190 +194 +198 +201 +206 +209 +213 +216 +220 +223 +227 +230 +233 +236 +237 +238 +239 +238 +237 +236 +233 +230 +227 +223 +220 +216 +212 +209 +205 +202 +198 +194 +190 +186 +182 +179 +175 +171 +167 +164 +160 +156 +152 +148 +144 +140 +136 +132 +129 +125 +121 +117 +113 +109 +105 +101 +98 +93 +89 +86 +82 +78 +74 +70 +66 +62 +59 +54 +51 +47 +43 +39 +35 +31 +27 +23 +20 +15 +12 +7 +4 +8 +11 +15 +19 +23 +27 +31 +34 +39 +43 +47 +50 +54 +58 +62 +66 +70 +73 +77 +82 +85 +89 +93 +97 +101 +105 +109 +113 +116 +120 +124 +128 +132 +136 +139 +143 +148 +151 +155 +158 +163 +167 +170 +174 +178 +182 +185 +190 +193 +197 +201 +204 +207 +211 +214 +218 +222 +224 +227 +229 +232 +234 +235 +236 +235 +234 +232 +230 +228 +224 +221 +218 +215 +211 +207 +204 +200 +197 +193 +189 +186 +182 +178 +174 +171 +166 +162 +159 +155 +151 +148 +143 +140 +135 +132 +128 +124 +120 +117 +113 +109 +104 +101 +97 +93 +89 +86 +81 +78 +73 +69 +66 +62 +58 +55 +51 +46 +42 +39 +35 +31 +27 +23 +19 +15 +12 +7 +3 +7 +11 +14 +19 +23 +26 +30 +34 +38 +42 +46 +50 +53 +58 +61 +66 +69 +74 +77 +81 +84 +89 +93 +97 +101 +104 +108 +112 +116 +119 +124 +128 +131 +135 +139 +142 +146 +151 +154 +158 +162 +165 +170 +174 +177 +181 +185 +188 +192 +196 +199 +202 +206 +209 +213 +216 +219 +222 +224 +227 +228 +230 +232 +232 +231 +231 +229 +227 +225 +222 +219 +216 +213 +209 +205 +202 +199 +196 +192 +188 +185 +180 +176 +173 +169 +166 +162 +158 +154 +151 +146 +143 +139 +135 +131 +127 +124 +120 +116 +112 +108 +105 +100 +96 +92 +89 +85 +81 +77 +73 +69 +65 +61 +58 +54 +50 +46 +42 +38 +34 +30 +26 +23 +19 +14 +10 +6 +2 +6 +11 +15 +18 +22 +26 +30 +34 +37 +42 +46 +50 +53 +57 +61 +65 +69 +73 +76 +80 +84 +88 +92 +96 +100 +103 +107 +112 +115 +119 +122 +126 +131 +134 +138 +142 +146 +149 +153 +157 +161 +164 +169 +172 +176 +179 +183 +186 +190 +194 +197 +200 +204 +208 +210 +214 +216 +219 +222 +224 +225 +227 +227 +228 +227 +226 +225 +224 +221 +219 +217 +214 +210 +207 +204 +201 +197 +194 +190 +186 +183 +180 +176 +172 +169 +164 +160 +157 +153 +150 +146 +142 +138 +134 +131 +126 +123 +119 +115 +111 +107 +103 +99 +96 +92 +88 +84 +80 +76 +73 +69 +65 +61 +57 +54 +49 +45 +42 +37 +34 +30 +26 +23 +18 +14 +11 +7 +2 +6 +10 +14 +18 +22 +26 +29 +33 +38 +41 +45 +49 +53 +56 +60 +64 +68 +72 +76 +79 +84 +87 +91 +95 +99 +103 +106 +111 +114 +119 +122 +126 +129 +133 +137 +141 +145 +149 +152 +155 +160 +163 +167 +170 +175 +178 +182 +185 +188 +191 +196 +198 +201 +205 +208 +210 +213 +216 +218 +220 +222 +222 +223 +224 +224 +222 +222 +220 +218 +215 +213 +210 +208 +205 +201 +198 +195 +192 +188 +185 +181 +178 +174 +171 +167 +163 +160 +156 +152 +149 +145 +141 +137 +134 +130 +126 +122 +118 +115 +110 +106 +103 +99 +95 +91 +88 +84 +80 +76 +72 +68 +64 +60 +57 +53 +48 +45 +41 +38 +33 +29 +25 +22 +17 +14 +10 +6 +2 +5 +9 +13 +18 +22 +25 +29 +33 +36 +41 +44 +49 +52 +56 +60 +64 +67 +72 +75 +79 +83 +87 +91 +94 +98 +102 +106 +109 +114 +117 +121 +125 +129 +132 +136 +140 +144 +147 +151 +155 +158 +162 +165 +169 +173 +177 +179 +183 +187 +190 +193 +196 +199 +202 +205 +207 +210 +213 +215 +216 +218 +218 +220 +220 +220 +218 +218 +216 +214 +213 +210 +208 +205 +202 +199 +197 +193 +190 +187 +183 +180 +176 +172 +169 +165 +162 +159 +154 +151 +147 +144 +140 +136 +133 +129 +125 +121 +117 +114 +109 +106 +102 +98 +94 +91 +87 +83 +79 +76 +71 +67 +63 +60 +56 +52 +48 +44 +40 +36 +32 +29 +25 +21 +17 +13 +9 +5 +1 +5 +8 +13 +17 +21 +25 +28 +32 +36 +39 +44 +48 +51 +55 +59 +63 +67 +70 +74 +78 +82 +86 +90 +94 +97 +102 +105 +108 +112 +116 +120 +124 +127 +131 +135 +139 +142 +146 +149 +153 +157 +161 +164 +167 +171 +175 +177 +181 +184 +188 +191 +194 +197 +200 +202 +205 +207 +209 +211 +213 +214 +215 +215 +216 +216 +215 +214 +212 +211 +209 +207 +205 +202 +200 +197 +194 +191 +188 +184 +181 +177 +174 +171 +167 +164 +161 +156 +153 +150 +146 +142 +138 +134 +131 +128 +123 +120 +116 +112 +108 +105 +101 +98 +94 +89 +86 +82 +78 +75 +70 +67 +63 +59 +55 +51 +48 +44 +39 +36 +32 +28 +24 +20 +17 +12 +9 +5 +1 +5 +9 +12 +16 +20 +24 +27 +31 +35 +39 +43 +47 +50 +54 +58 +62 +65 +70 +74 +77 +81 +85 +88 +92 +96 +100 +104 +107 +112 +115 +118 +122 +126 +130 +133 +137 +140 +144 +148 +151 +155 +159 +162 +166 +169 +173 +175 +179 +183 +185 +188 +191 +194 +197 +199 +201 +204 +206 +208 +209 +210 +211 +212 +212 +212 +211 +210 +209 +207 +206 +204 +201 +199 +197 +194 +191 +189 +186 +182 +179 +176 +172 +169 +165 +162 +158 +155 +151 +148 +145 +140 +138 +133 +130 +126 +123 +119 +115 +111 +107 +103 +100 +96 +93 +89 +85 +81 +77 +74 +69 +65 +62 +58 +54 +51 +47 +42 +39 +35 +32 +27 +24 +20 +16 +13 +8 +4 +0 +3 +8 +12 +16 +19 +23 +27 +31 +35 +38 +42 +45 +49 +54 +57 +61 +65 +69 +72 +76 +80 +84 +88 +91 +96 +99 +103 +106 +110 +114 +118 +121 +125 +128 +132 +135 +140 +143 +146 +150 +153 +157 +160 +163 +167 +170 +174 +177 +179 +183 +186 +188 +191 +194 +197 +198 +201 +202 +204 +206 +207 +207 +208 +208 +208 +207 +207 +205 +204 +203 +200 +199 +196 +194 +191 +188 +185 +183 +180 +176 +174 +170 +167 +163 +160 +156 +154 +149 +147 +143 +139 +135 +132 +129 +125 +121 +117 +113 +110 +106 +102 +99 +96 +91 +87 +84 +80 +76 +73 +68 +65 +61 +57 +54 +49 +46 +42 +39 +34 +31 +26 +23 +19 +15 +12 +7 +4 +0 +3 +6 +11 +15 +18 +23 +26 +30 +34 +37 +41 +44 +49 +52 +57 +61 +64 +68 +71 +75 +79 +83 +86 +90 +94 +98 +101 +105 +108 +113 +116 +120 +123 +127 +130 +134 +137 +141 +145 +148 +152 +155 +158 +162 +165 +168 +171 +174 +177 +180 +183 +186 +189 +191 +193 +195 +197 +199 +201 +202 +203 +203 +204 +204 +204 +203 +203 +202 +201 +199 +197 +195 +193 +191 +188 +186 +183 +180 +177 +174 +171 +168 +164 +162 +158 +155 +151 +148 +144 +141 +137 +134 +130 +127 +123 +120 +116 +112 +108 +105 +101 +98 +94 +90 +87 +83 +79 +75 +71 +68 +64 +60 +57 +53 +49 +45 +42 +38 +33 +29 +26 +22 +18 +15 +11 +7 +3 +0 +2 +5 +10 +14 +17 +21 +25 +29 +33 +36 +40 +44 +48 +52 +55 +59 +63 +67 +70 +74 +78 +81 +85 +89 +93 +96 +100 +104 +108 +111 +114 +118 +122 +125 +129 +132 +135 +140 +143 +146 +149 +153 +156 +160 +162 +166 +168 +172 +174 +177 +180 +182 +186 +188 +190 +191 +194 +195 +196 +198 +199 +200 +200 +201 +200 +200 +199 +198 +197 +195 +194 +191 +189 +187 +185 +183 +180 +177 +174 +171 +168 +166 +162 +160 +156 +153 +149 +147 +143 +139 +135 +132 +129 +125 +122 +119 +114 +111 +108 +103 +100 +96 +93 +89 +85 +81 +78 +74 +70 +67 +63 +59 +55 +52 +48 +44 +40 +37 +33 +28 +25 +22 +18 +14 +10 +6 +2 +0 +1 +5 +9 +13 +17 +21 +24 +28 +32 +35 +39 +42 +47 +51 +54 +58 +61 +65 +69 +72 +77 +80 +84 +88 +91 +95 +99 +102 +106 +109 +113 +117 +120 +123 +127 +130 +134 +138 +141 +144 +148 +150 +154 +157 +160 +163 +166 +169 +172 +174 +177 +179 +182 +185 +186 +188 +190 +192 +193 +195 +195 +196 +196 +197 +196 +196 +195 +194 +193 +191 +190 +188 +186 +184 +182 +180 +177 +174 +171 +169 +166 +163 +160 +157 +154 +150 +148 +144 +141 +137 +134 +130 +127 +124 +120 +116 +113 +109 +106 +102 +98 +94 +91 +87 +84 +81 +76 +73 +69 +65 +61 +58 +54 +50 +47 +43 +39 +35 +31 +28 +24 +20 +17 +13 +9 +5 +1 +0 +0 +4 +8 +11 +16 +19 +23 +26 +30 +34 +39 +42 +45 +49 +53 +57 +60 +64 +68 +72 +75 +79 +83 +86 +89 +93 +97 +101 +104 +107 +111 +115 +118 +122 +125 +129 +132 +136 +139 +142 +145 +148 +151 +155 +157 +161 +164 +166 +169 +171 +174 +176 +179 +181 +183 +185 +186 +188 +189 +191 +191 +192 +192 +193 +192 +192 +191 +190 +190 +188 +187 +184 +183 +181 +179 +177 +174 +172 +169 +166 +163 +161 +158 +155 +152 +148 +145 +142 +139 +135 +132 +129 +125 +122 +118 +115 +111 +108 +104 +100 +97 +93 +89 +86 +83 +79 +75 +71 +68 +64 +61 +57 +53 +49 +46 +42 +38 +35 +31 +27 +23 +19 +15 +11 +8 +4 +0 +0 +0 +3 +7 +10 +14 +18 +22 +25 +29 +33 +37 +40 +44 +48 +52 +55 +60 +63 +66 +71 +74 +77 +81 +85 +88 +92 +95 +99 +102 +106 +110 +113 +117 +120 +123 +127 +130 +134 +137 +140 +143 +146 +149 +152 +155 +158 +161 +163 +166 +169 +171 +173 +176 +178 +179 +182 +183 +184 +186 +187 +187 +188 +188 +188 +188 +188 +187 +186 +186 +184 +183 +181 +179 +178 +175 +173 +171 +169 +166 +164 +161 +158 +155 +153 +150 +146 +143 +139 +136 +134 +130 +126 +124 +120 +116 +113 +109 +106 +102 +99 +96 +91 +89 +85 +81 +78 +74 +70 +66 +63 +59 +56 +52 +48 +44 +41 +37 +33 +30 +26 +22 +18 +15 +11 +7 +3 +0 +0 +0 +2 +6 +10 +13 +17 +21 +24 +29 +32 +36 +39 +43 +47 +50 +54 +58 +61 +65 +69 +73 +76 +80 +83 +86 +90 +94 +97 +101 +105 +107 +111 +114 +118 +121 +124 +128 +131 +134 +138 +140 +144 +147 +150 +153 +155 +158 +160 +163 +166 +168 +170 +172 +174 +176 +177 +179 +180 +181 +183 +184 +184 +184 +184 +184 +184 +184 +183 +181 +181 +179 +177 +176 +174 +172 +170 +168 +166 +163 +160 +158 +155 +153 +149 +146 +143 +141 +138 +135 +131 +128 +124 +121 +118 +115 +111 +108 +105 +100 +97 +94 +90 +86 +84 +80 +75 +73 +69 +65 +61 +57 +54 +51 +47 +43 +40 +35 +32 +28 +24 +20 +17 +13 +10 +6 +2 +0 +0 +0 +1 +5 +8 +12 +16 +19 +23 +27 +31 +35 +38 +41 +46 +49 +53 +56 +60 +64 +67 +71 +75 +78 +81 +85 +89 +92 +96 +99 +102 +105 +109 +112 +116 +119 +122 +126 +128 +132 +135 +138 +141 +144 +147 +150 +153 +155 +157 +160 +162 +164 +167 +169 +171 +173 +175 +176 +177 +178 +179 +179 +180 +180 +180 +181 +180 +179 +179 +178 +177 +175 +174 +172 +171 +169 +167 +164 +162 +160 +158 +155 +152 +149 +146 +144 +141 +138 +135 +132 +129 +125 +123 +119 +116 +112 +109 +106 +102 +99 +95 +92 +88 +85 +82 +78 +74 +71 +67 +63 +60 +56 +53 +49 +46 +42 +38 +35 +31 +27 +23 +20 +16 +12 +8 +5 +1 +0 +0 +0 +0 +3 +7 +11 +15 +18 +22 +26 +29 +33 +37 +41 +44 +47 +51 +55 +59 +62 +66 +70 +72 +76 +80 +83 +87 +90 +93 +97 +101 +103 +107 +111 +113 +117 +121 +124 +126 +130 +133 +136 +138 +141 +144 +147 +149 +152 +155 +157 +159 +162 +163 +165 +167 +169 +171 +172 +173 +174 +175 +176 +176 +176 +177 +177 +176 +176 +175 +174 +173 +172 +170 +169 +167 +165 +163 +162 +159 +157 +155 +152 +149 +147 +144 +141 +138 +136 +133 +129 +127 +123 +120 +117 +114 +110 +107 +104 +101 +97 +94 +91 +87 +83 +80 +76 +72 +69 +65 +62 +59 +55 +51 +48 +44 +40 +37 +33 +29 +26 +22 +18 +15 +11 +8 +3 +0 +0 +0 +0 +0 +3 +5 +10 +14 +17 +20 +24 +28 +32 +35 +39 +42 +46 +50 +54 +57 +60 +64 +67 +71 +74 +78 +82 +84 +88 +91 +95 +99 +102 +105 +108 +112 +114 +117 +121 +124 +128 +130 +133 +136 +139 +141 +144 +147 +149 +151 +154 +156 +158 +160 +163 +164 +165 +167 +169 +169 +170 +171 +172 +173 +173 +173 +173 +172 +172 +171 +170 +170 +169 +167 +166 +164 +162 +160 +158 +156 +154 +151 +149 +146 +144 +142 +139 +136 +133 +130 +127 +124 +121 +118 +114 +111 +108 +105 +102 +99 +95 +92 +89 +84 +81 +78 +75 +71 +68 +64 +61 +57 +53 +50 +46 +42 +39 +35 +32 +28 +24 +20 +17 +14 +9 +6 +2 +0 +0 +0 +0 +0 +1 +4 +8 +12 +16 +19 +23 +26 +30 +34 +37 +41 +45 +48 +52 +56 +58 +62 +66 +69 +73 +76 +80 +83 +87 +90 +93 +97 +100 +103 +106 +110 +112 +116 +118 +121 +124 +127 +131 +133 +136 +138 +141 +144 +146 +148 +151 +153 +155 +157 +159 +161 +161 +163 +165 +165 +167 +167 +168 +169 +169 +168 +168 +168 +168 +167 +166 +166 +165 +163 +162 +160 +159 +157 +155 +153 +151 +148 +146 +144 +141 +139 +136 +133 +131 +127 +125 +122 +118 +115 +113 +109 +106 +103 +100 +96 +93 +90 +86 +83 +80 +76 +72 +69 +66 +63 +59 +55 +52 +48 +45 +41 +38 +33 +30 +27 +23 +20 +16 +12 +9 +4 +0 +0 +0 +0 +0 +0 +0 +3 +6 +11 +14 +17 +21 +25 +29 +32 +36 +39 +43 +47 +50 +53 +57 +61 +63 +67 +71 +74 +77 +81 +84 +88 +91 +94 +97 +101 +103 +107 +110 +113 +116 +119 +122 +125 +128 +130 +133 +135 +138 +141 +143 +145 +148 +149 +152 +154 +155 +157 +158 +159 +161 +162 +162 +163 +164 +165 +165 +165 +165 +164 +164 +164 +163 +162 +160 +159 +158 +157 +156 +153 +152 +149 +147 +146 +143 +140 +138 +136 +133 +130 +127 +125 +122 +119 +116 +113 +109 +107 +103 +100 +97 +94 +90 +88 +84 +81 +77 +74 +71 +67 +64 +60 +57 +53 +50 +47 +43 +39 +36 +32 +28 +25 +22 +18 +15 +11 +7 +3 +0 +0 +0 +0 +0 +0 +0 +2 +6 +10 +13 +16 +20 +24 +27 +30 +34 +37 +42 +44 +48 +52 +55 +59 +62 +65 +68 +73 +76 +79 +82 +86 +89 +92 +95 +99 +101 +104 +108 +111 +114 +116 +119 +122 +125 +128 +130 +132 +135 +137 +139 +142 +144 +146 +148 +150 +151 +153 +155 +156 +157 +158 +159 +160 +160 +161 +161 +161 +161 +161 +161 +160 +159 +158 +157 +156 +154 +153 +152 +149 +148 +146 +144 +142 +140 +137 +135 +133 +130 +127 +125 +122 +120 +116 +114 +110 +107 +105 +102 +98 +95 +92 +89 +86 +82 +79 +76 +72 +68 +66 +62 +58 +55 +51 +48 +45 +42 +38 +34 +31 +27 +24 +20 +17 +13 +9 +6 +2 +0 +0 +0 +0 +0 +0 +0 +0 +4 +8 +11 +15 +19 +21 +26 +28 +32 +36 +40 +43 +47 +50 +54 +56 +60 +64 +67 +70 +74 +77 +80 +83 +87 +90 +93 +95 +99 +102 +105 +108 +111 +114 +117 +119 +122 +125 +127 +130 +132 +134 +136 +139 +141 +143 +145 +146 +148 +150 +151 +153 +153 +154 +156 +155 +156 +157 +157 +157 +157 +157 +156 +156 +155 +154 +153 +152 +151 +149 +148 +146 +145 +143 +140 +139 +137 +134 +131 +129 +127 +125 +122 +120 +116 +114 +111 +108 +105 +102 +99 +96 +93 +90 +87 +84 +80 +77 +74 +70 +67 +63 +60 +57 +53 +50 +46 +43 +40 +36 +33 +29 +25 +21 +18 +14 +11 +8 +4 +1 +0 +0 +0 +0 +0 +0 +0 +0 +3 +6 +10 +13 +16 +20 +24 +27 +31 +34 +37 +41 +45 +48 +52 +54 +58 +61 +65 +68 +71 +74 +77 +81 +84 +87 +90 +94 +96 +100 +102 +105 +108 +111 +113 +116 +119 +122 +124 +127 +129 +131 +133 +135 +137 +139 +141 +143 +144 +146 +147 +148 +149 +150 +151 +152 +152 +153 +153 +153 +153 +153 +152 +152 +151 +150 +149 +148 +147 +146 +144 +143 +141 +140 +138 +136 +133 +131 +129 +127 +124 +121 +119 +117 +114 +111 +108 +105 +103 +99 +96 +94 +91 +88 +84 +81 +78 +74 +71 +68 +64 +61 +58 +55 +51 +48 +45 +41 +38 +34 +30 +27 +24 +20 +17 +13 +10 +6 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +4 +8 +11 +15 +19 +21 +25 +29 +32 +36 +39 +43 +46 +50 +53 +56 +59 +63 +66 +69 +72 +75 +78 +82 +85 +88 +91 +94 +97 +100 +103 +105 +108 +111 +113 +116 +118 +121 +124 +126 +128 +130 +132 +134 +135 +138 +139 +141 +142 +144 +145 +146 +147 +147 +148 +149 +149 +149 +149 +149 +149 +149 +148 +147 +147 +146 +144 +143 +143 +140 +139 +138 +136 +134 +132 +130 +128 +126 +124 +121 +119 +116 +113 +111 +108 +106 +102 +100 +97 +94 +91 +88 +85 +82 +78 +76 +72 +69 +66 +62 +59 +56 +52 +49 +46 +43 +39 +36 +32 +29 +25 +22 +18 +15 +11 +8 +4 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +6 +10 +13 +17 +20 +24 +27 +31 +34 +37 +41 +44 +47 +51 +54 +58 +60 +63 +66 +70 +73 +76 +79 +82 +85 +88 +92 +94 +97 +100 +103 +105 +108 +110 +113 +116 +118 +121 +122 +125 +126 +129 +130 +132 +134 +136 +137 +138 +140 +141 +142 +143 +144 +144 +145 +145 +145 +145 +145 +145 +145 +144 +144 +143 +142 +141 +140 +138 +137 +135 +134 +132 +130 +128 +127 +124 +122 +121 +118 +116 +113 +111 +108 +105 +102 +100 +97 +94 +91 +88 +85 +82 +79 +76 +73 +70 +67 +63 +60 +57 +54 +50 +48 +44 +40 +37 +34 +30 +27 +24 +20 +16 +14 +10 +6 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +4 +8 +11 +15 +18 +22 +25 +28 +32 +35 +39 +41 +45 +48 +51 +55 +58 +61 +65 +68 +70 +74 +77 +80 +83 +86 +88 +92 +95 +97 +99 +102 +105 +107 +110 +112 +115 +117 +119 +121 +123 +125 +128 +128 +131 +132 +134 +135 +136 +137 +138 +139 +139 +140 +140 +141 +141 +141 +141 +141 +141 +141 +140 +139 +138 +137 +136 +135 +133 +132 +131 +129 +127 +125 +123 +121 +119 +116 +115 +112 +110 +108 +104 +103 +100 +97 +94 +91 +89 +86 +83 +79 +76 +74 +71 +68 +64 +61 +58 +55 +52 +48 +45 +42 +39 +35 +32 +29 +25 +22 +19 +15 +12 +7 +4 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +6 +10 +13 +17 +20 +23 +26 +30 +33 +37 +39 +43 +46 +50 +53 +56 +59 +62 +65 +69 +71 +75 +77 +80 +83 +86 +89 +92 +94 +97 +100 +102 +104 +107 +109 +112 +114 +116 +118 +120 +122 +123 +125 +127 +128 +130 +131 +132 +133 +135 +135 +136 +137 +136 +137 +137 +138 +138 +137 +137 +136 +136 +135 +134 +133 +133 +131 +130 +128 +126 +125 +124 +122 +120 +118 +115 +114 +112 +109 +107 +105 +102 +100 +97 +94 +91 +89 +86 +83 +81 +78 +74 +72 +68 +66 +62 +59 +56 +53 +49 +47 +43 +40 +36 +33 +30 +27 +23 +20 +16 +13 +10 +6 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +4 +8 +11 +14 +18 +21 +24 +27 +31 +35 +37 +41 +44 +47 +50 +53 +57 +59 +63 +66 +69 +72 +74 +78 +80 +83 +86 +88 +91 +94 +97 +99 +101 +104 +106 +108 +110 +112 +115 +116 +118 +120 +121 +123 +124 +126 +127 +128 +130 +130 +132 +132 +132 +133 +134 +134 +134 +134 +133 +133 +132 +132 +131 +130 +130 +129 +127 +126 +125 +123 +122 +120 +118 +116 +115 +113 +111 +109 +106 +103 +101 +99 +97 +94 +91 +89 +86 +83 +80 +77 +75 +72 +69 +66 +63 +60 +56 +54 +50 +47 +44 +41 +38 +34 +31 +28 +24 +22 +18 +14 +11 +7 +4 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +5 +9 +12 +16 +19 +22 +25 +29 +32 +36 +39 +42 +45 +48 +51 +54 +58 +60 +63 +66 +69 +72 +74 +78 +81 +83 +85 +89 +91 +93 +96 +98 +100 +103 +105 +107 +109 +112 +113 +115 +116 +118 +120 +121 +122 +123 +125 +126 +127 +127 +128 +129 +129 +130 +129 +130 +130 +129 +129 +128 +128 +127 +126 +126 +125 +123 +122 +121 +119 +118 +116 +115 +113 +111 +109 +108 +105 +103 +101 +98 +96 +94 +90 +88 +86 +83 +81 +77 +75 +72 +69 +66 +64 +60 +57 +54 +51 +48 +45 +42 +38 +36 +32 +29 +25 +22 +19 +16 +12 +9 +5 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +4 +7 +10 +14 +17 +20 +24 +27 +30 +33 +36 +39 +42 +45 +49 +51 +54 +58 +61 +64 +67 +69 +72 +75 +77 +80 +82 +85 +88 +90 +93 +95 +98 +100 +102 +103 +105 +108 +109 +111 +113 +115 +116 +118 +119 +120 +121 +122 +123 +124 +125 +124 +125 +125 +125 +126 +126 +125 +125 +125 +124 +124 +123 +122 +121 +119 +119 +118 +116 +114 +113 +111 +110 +107 +106 +104 +101 +100 +97 +95 +92 +90 +88 +85 +83 +80 +78 +75 +72 +69 +67 +64 +60 +58 +55 +52 +49 +45 +43 +39 +36 +33 +30 +26 +24 +20 +17 +13 +10 +7 +4 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +5 +8 +12 +15 +18 +21 +24 +27 +31 +34 +37 +40 +43 +47 +49 +52 +55 +58 +61 +64 +66 +69 +72 +75 +77 +80 +82 +84 +87 +90 +92 +94 +96 +99 +100 +103 +104 +106 +107 +109 +111 +113 +113 +115 +116 +117 +118 +119 +119 +120 +120 +121 +122 +122 +122 +122 +122 +122 +121 +121 +120 +119 +118 +117 +116 +115 +114 +113 +111 +110 +108 +106 +104 +103 +101 +98 +96 +94 +92 +90 +88 +85 +82 +80 +77 +74 +72 +69 +66 +64 +61 +58 +55 +52 +49 +46 +43 +40 +37 +34 +31 +28 +25 +22 +18 +15 +12 +9 +5 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +6 +9 +13 +16 +19 +22 +26 +28 +31 +34 +38 +40 +43 +47 +49 +53 +55 +58 +61 +64 +67 +69 +72 +74 +77 +79 +82 +84 +86 +88 +91 +93 +95 +97 +98 +101 +103 +104 +106 +107 +108 +110 +111 +112 +113 +114 +115 +116 +116 +117 +117 +118 +117 +118 +118 +118 +118 +117 +117 +116 +115 +115 +113 +112 +112 +110 +109 +108 +106 +104 +102 +101 +99 +97 +95 +93 +91 +89 +86 +85 +82 +80 +77 +74 +72 +69 +67 +63 +61 +58 +56 +53 +50 +47 +44 +41 +38 +34 +32 +28 +25 +22 +19 +16 +13 +10 +6 +3 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +4 +7 +10 +13 +17 +20 +23 +26 +29 +32 +36 +38 +41 +44 +47 +49 +53 +56 +58 +61 +63 +66 +69 +71 +74 +76 +78 +81 +84 +86 +88 +89 +91 +93 +96 +97 +99 +100 +102 +104 +105 +106 +108 +108 +110 +111 +111 +112 +112 +113 +113 +114 +114 +114 +114 +114 +113 +113 +112 +112 +111 +110 +110 +108 +108 +107 +105 +103 +102 +101 +99 +97 +96 +93 +92 +90 +88 +85 +83 +81 +79 +76 +74 +71 +69 +66 +64 +61 +59 +55 +53 +50 +47 +44 +41 +39 +35 +32 +30 +27 +23 +20 +16 +13 +10 +8 +4 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +5 +8 +12 +15 +18 +20 +24 +27 +30 +33 +36 +39 +41 +44 +47 +50 +53 +55 +58 +60 +63 +66 +69 +70 +73 +76 +78 +80 +82 +84 +86 +88 +90 +92 +93 +95 +97 +98 +99 +101 +102 +104 +105 +106 +106 +107 +108 +109 +109 +110 +109 +110 +110 +110 +110 +109 +109 +109 +108 +108 +107 +106 +104 +104 +103 +102 +100 +99 +97 +96 +93 +92 +90 +88 +86 +85 +83 +80 +78 +75 +73 +71 +68 +65 +64 +61 +59 +55 +53 +50 +47 +44 +41 +39 +36 +33 +29 +27 +24 +21 +17 +14 +12 +8 +4 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +6 +8 +12 +15 +18 +22 +25 +27 +30 +33 +36 +39 +42 +45 +47 +50 +53 +55 +58 +60 +63 +65 +68 +70 +72 +75 +77 +78 +81 +83 +85 +87 +89 +90 +92 +93 +95 +96 +97 +99 +100 +101 +102 +102 +103 +104 +105 +105 +105 +106 +106 +106 +106 +106 +105 +105 +104 +104 +104 +103 +102 +101 +100 +99 +98 +96 +95 +94 +92 +91 +88 +87 +85 +83 +81 +79 +76 +74 +73 +70 +67 +66 +63 +60 +58 +55 +53 +49 +47 +44 +42 +39 +36 +33 +30 +27 +24 +21 +18 +15 +12 +9 +6 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +3 +6 +10 +12 +16 +18 +22 +25 +27 +31 +33 +36 +39 +41 +44 +47 +49 +52 +55 +57 +60 +62 +64 +67 +69 +71 +73 +76 +77 +79 +81 +83 +85 +87 +88 +90 +92 +93 +94 +95 +96 +98 +99 +99 +100 +100 +101 +101 +102 +102 +102 +102 +102 +102 +102 +102 +100 +100 +100 +99 +98 +97 +96 +95 +94 +92 +92 +90 +88 +87 +85 +84 +82 +79 +78 +76 +73 +71 +69 +67 +64 +62 +59 +58 +55 +52 +50 +47 +45 +42 +39 +36 +33 +31 +27 +24 +22 +18 +16 +13 +9 +7 +3 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +4 +8 +10 +13 +16 +19 +22 +25 +27 +30 +34 +36 +39 +41 +44 +47 +49 +52 +55 +57 +59 +61 +64 +66 +68 +70 +73 +74 +76 +78 +79 +81 +83 +84 +87 +88 +89 +90 +92 +93 +93 +94 +95 +96 +96 +97 +98 +98 +98 +99 +98 +99 +98 +98 +97 +97 +97 +95 +95 +94 +94 +92 +92 +90 +89 +87 +86 +85 +83 +81 +80 +78 +76 +74 +72 +71 +68 +66 +64 +61 +59 +57 +54 +52 +49 +47 +45 +41 +39 +36 +33 +30 +27 +24 +22 +19 +16 +13 +11 +7 +4 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +4 +7 +11 +14 +16 +19 +23 +25 +28 +31 +34 +35 +38 +41 +44 +46 +48 +51 +53 +56 +58 +60 +62 +64 +67 +69 +70 +73 +75 +76 +78 +79 +81 +82 +84 +86 +87 +87 +89 +90 +91 +91 +92 +93 +93 +93 +94 +95 +94 +94 +94 +94 +94 +94 +93 +92 +92 +91 +90 +89 +88 +87 +87 +86 +84 +83 +81 +79 +78 +76 +74 +73 +71 +68 +67 +65 +63 +61 +58 +56 +54 +51 +49 +46 +43 +41 +38 +36 +33 +30 +27 +25 +22 +19 +17 +14 +11 +8 +5 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +5 +8 +11 +13 +17 +20 +22 +25 +27 +30 +33 +36 +38 +40 +43 +45 +48 +50 +53 +55 +57 +59 +61 +63 +66 +67 +69 +71 +73 +74 +76 +77 +79 +81 +82 +83 +84 +84 +86 +86 +88 +88 +88 +89 +90 +90 +90 +91 +90 +91 +91 +90 +90 +89 +89 +88 +87 +87 +86 +85 +84 +83 +82 +80 +79 +78 +76 +75 +73 +71 +69 +68 +66 +63 +61 +59 +57 +55 +52 +50 +48 +46 +43 +40 +38 +35 +33 +30 +27 +25 +22 +20 +16 +13 +11 +8 +5 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +5 +9 +11 +13 +16 +20 +22 +25 +28 +30 +33 +36 +38 +40 +42 +44 +48 +50 +51 +54 +56 +58 +60 +62 +64 +66 +68 +69 +70 +72 +74 +75 +77 +78 +79 +80 +81 +82 +83 +84 +85 +85 +86 +86 +86 +86 +86 +86 +86 +86 +86 +86 +86 +84 +85 +83 +83 +82 +81 +80 +79 +78 +77 +76 +73 +72 +71 +69 +68 +65 +64 +62 +60 +58 +56 +54 +51 +49 +47 +45 +42 +40 +37 +35 +33 +30 +27 +25 +22 +20 +17 +14 +11 +8 +5 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +6 +9 +11 +14 +16 +19 +22 +25 +27 +30 +32 +34 +37 +39 +42 +44 +46 +49 +50 +52 +55 +57 +59 +60 +62 +64 +65 +68 +68 +70 +72 +72 +74 +75 +76 +77 +78 +79 +79 +80 +81 +81 +82 +82 +82 +83 +83 +83 +82 +83 +82 +81 +81 +80 +80 +79 +78 +77 +76 +76 +74 +72 +71 +70 +68 +67 +66 +64 +62 +61 +58 +56 +55 +53 +50 +48 +46 +45 +42 +39 +37 +35 +32 +29 +27 +25 +22 +20 +16 +14 +11 +9 +6 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +6 +8 +11 +13 +17 +20 +21 +25 +27 +29 +32 +34 +36 +39 +41 +43 +45 +48 +49 +51 +53 +55 +57 +58 +60 +62 +63 +65 +67 +68 +70 +70 +71 +72 +73 +75 +76 +75 +77 +77 +77 +78 +78 +79 +78 +78 +78 +78 +78 +78 +78 +77 +77 +76 +75 +75 +74 +73 +72 +70 +69 +67 +67 +65 +64 +62 +61 +59 +57 +56 +53 +51 +49 +47 +46 +43 +41 +39 +36 +34 +31 +29 +27 +24 +22 +19 +17 +14 +11 +8 +5 +3 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +5 +8 +11 +13 +16 +18 +21 +24 +26 +29 +30 +33 +36 +37 +40 +42 +44 +46 +48 +50 +51 +53 +55 +56 +58 +60 +61 +62 +64 +66 +66 +67 +69 +70 +70 +71 +72 +73 +74 +73 +74 +75 +75 +74 +75 +74 +75 +74 +74 +74 +73 +73 +72 +72 +70 +70 +68 +67 +67 +65 +64 +62 +61 +60 +58 +57 +55 +54 +52 +50 +48 +46 +44 +42 +40 +37 +35 +33 +31 +29 +27 +24 +22 +19 +16 +14 +11 +8 +6 +3 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +6 +8 +11 +13 +16 +18 +21 +23 +25 +28 +30 +32 +34 +36 +39 +40 +43 +44 +46 +48 +50 +52 +53 +55 +56 +58 +59 +60 +62 +63 +64 +65 +66 +67 +67 +68 +68 +70 +70 +70 +70 +71 +70 +71 +70 +71 +70 +70 +70 +69 +68 +69 +67 +66 +66 +64 +64 +62 +62 +60 +59 +58 +57 +55 +53 +52 +50 +48 +46 +45 +43 +40 +38 +36 +35 +32 +29 +28 +25 +23 +20 +18 +16 +13 +11 +8 +5 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +5 +8 +10 +13 +15 +18 +20 +22 +25 +27 +29 +31 +33 +35 +37 +39 +41 +42 +45 +47 +48 +49 +51 +53 +54 +55 +56 +58 +59 +60 +61 +62 +63 +63 +64 +65 +65 +66 +67 +66 +67 +67 +67 +67 +67 +67 +66 +66 +66 +64 +65 +64 +63 +62 +61 +60 +59 +58 +57 +56 +54 +53 +51 +50 +48 +46 +45 +43 +41 +40 +37 +35 +33 +31 +29 +26 +24 +22 +20 +18 +15 +13 +10 +7 +5 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +5 +7 +9 +12 +14 +17 +19 +22 +24 +26 +28 +30 +31 +34 +35 +37 +39 +41 +43 +45 +46 +48 +49 +50 +52 +53 +54 +56 +56 +57 +59 +59 +60 +61 +61 +61 +62 +63 +62 +63 +63 +63 +63 +62 +63 +62 +62 +61 +61 +61 +59 +59 +58 +57 +56 +55 +54 +53 +52 +50 +49 +47 +46 +44 +43 +41 +40 +37 +36 +34 +32 +30 +28 +25 +24 +21 +19 +17 +14 +12 +10 +7 +4 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +4 +6 +9 +12 +14 +16 +18 +21 +22 +24 +27 +28 +30 +32 +35 +36 +37 +40 +41 +43 +44 +45 +47 +48 +49 +50 +52 +52 +54 +55 +55 +56 +56 +58 +57 +58 +59 +58 +58 +59 +59 +59 +59 +59 +59 +58 +58 +57 +57 +56 +55 +55 +53 +53 +52 +51 +49 +48 +47 +45 +44 +42 +41 +39 +37 +36 +34 +32 +31 +29 +27 +25 +22 +20 +18 +16 +14 +11 +8 +6 +4 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +3 +6 +9 +11 +12 +15 +17 +19 +21 +23 +25 +27 +28 +31 +33 +34 +36 +37 +39 +40 +42 +43 +44 +46 +46 +48 +49 +50 +51 +52 +52 +53 +54 +54 +54 +54 +55 +55 +55 +55 +56 +55 +54 +54 +54 +54 +53 +52 +52 +52 +50 +49 +49 +48 +47 +46 +44 +43 +42 +40 +39 +37 +36 +34 +33 +30 +29 +27 +25 +23 +21 +19 +16 +15 +12 +11 +8 +6 +4 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +5 +7 +9 +12 +14 +16 +18 +20 +22 +24 +26 +27 +29 +31 +33 +33 +35 +37 +38 +40 +40 +41 +42 +44 +45 +46 +46 +48 +48 +49 +50 +49 +51 +50 +51 +51 +52 +51 +51 +51 +51 +50 +50 +50 +49 +48 +49 +47 +47 +46 +45 +44 +43 +42 +41 +39 +38 +37 +35 +34 +32 +30 +28 +27 +25 +23 +21 +19 +17 +15 +14 +12 +10 +7 +5 +3 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +4 +6 +8 +10 +13 +15 +17 +18 +21 +22 +23 +25 +27 +29 +30 +32 +33 +35 +35 +37 +38 +39 +40 +41 +42 +43 +44 +44 +45 +46 +46 +46 +47 +47 +47 +48 +47 +47 +47 +47 +47 +47 +46 +46 +45 +44 +43 +43 +42 +41 +40 +39 +38 +37 +35 +34 +33 +32 +30 +29 +27 +26 +24 +22 +20 +19 +17 +15 +13 +11 +8 +6 +4 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +3 +5 +7 +9 +11 +13 +15 +17 +18 +20 +22 +23 +25 +27 +28 +29 +30 +32 +33 +34 +36 +36 +37 +38 +39 +40 +40 +41 +42 +42 +42 +43 +43 +44 +43 +43 +44 +43 +43 +43 +42 +42 +41 +41 +41 +40 +39 +38 +37 +37 +35 +34 +33 +32 +31 +29 +28 +26 +25 +23 +22 +20 +19 +16 +15 +12 +11 +9 +7 +5 +3 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +4 +5 +7 +9 +12 +13 +15 +16 +19 +20 +21 +23 +24 +25 +27 +29 +29 +31 +32 +33 +33 +34 +35 +35 +37 +37 +38 +39 +38 +38 +39 +39 +39 +40 +40 +39 +39 +39 +38 +38 +38 +37 +37 +36 +35 +34 +34 +33 +31 +31 +30 +28 +26 +26 +25 +23 +21 +20 +18 +17 +14 +13 +11 +10 +7 +6 +4 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +2 +4 +6 +8 +9 +11 +13 +15 +17 +17 +19 +20 +22 +23 +24 +26 +27 +28 +29 +30 +31 +32 +32 +33 +34 +34 +34 +35 +35 +35 +35 +36 +35 +36 +35 +35 +35 +35 +34 +34 +33 +32 +32 +31 +31 +29 +29 +28 +27 +26 +25 +24 +22 +21 +19 +18 +16 +15 +13 +12 +10 +7 +6 +4 +3 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +3 +5 +6 +8 +9 +11 +13 +14 +16 +17 +18 +20 +20 +21 +23 +24 +25 +26 +26 +28 +28 +29 +29 +30 +31 +31 +31 +32 +31 +31 +31 +31 +32 +31 +31 +30 +30 +30 +29 +28 +29 +28 +27 +26 +25 +24 +23 +21 +21 +20 +18 +17 +15 +14 +13 +11 +10 +8 +6 +4 +2 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +4 +6 +7 +9 +10 +12 +13 +15 +15 +17 +18 +19 +20 +21 +22 +23 +24 +24 +25 +26 +26 +26 +27 +27 +27 +28 +28 +28 +28 +28 +27 +27 +27 +27 +26 +26 +25 +25 +24 +23 +22 +21 +20 +20 +18 +17 +15 +15 +13 +12 +11 +9 +8 +6 +5 +2 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +3 +4 +5 +7 +8 +10 +10 +12 +14 +15 +16 +16 +18 +19 +19 +19 +20 +21 +22 +22 +23 +23 +23 +24 +23 +24 +24 +24 +24 +23 +24 +23 +23 +22 +22 +21 +20 +20 +19 +19 +18 +16 +15 +14 +13 +12 +11 +10 +9 +7 +6 +4 +3 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +3 +4 +6 +7 +9 +10 +11 +11 +12 +13 +14 +15 +16 +17 +17 +18 +18 +18 +19 +20 +20 +20 +20 +20 +19 +19 +19 +19 +19 +19 +18 +18 +17 +17 +16 +15 +14 +14 +13 +11 +11 +9 +8 +8 +6 +4 +4 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +3 +4 +4 +6 +6 +8 +9 +9 +11 +11 +12 +13 +14 +14 +14 +15 +15 +15 +16 +16 +16 +16 +16 +16 +15 +15 +15 +15 +14 +14 +13 +13 +12 +11 +11 +9 +9 +8 +7 +5 +4 +4 +2 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +9 +9 +10 +10 +11 +11 +11 +12 +11 +12 +12 +12 +12 +12 +11 +11 +11 +11 +10 +9 +9 +8 +7 +7 +6 +6 +4 +3 +2 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +2 +3 +4 +5 +5 +6 +6 +7 +7 +7 +7 +8 +8 +8 +8 +8 +8 +8 +7 +8 +7 +6 +6 +6 +5 +5 +4 +3 +2 +1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/extra/gpu/effects/blur/authors.txt b/extra/gpu/effects/blur/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/extra/gpu/effects/blur/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/extra/gpu/effects/blur/blur.factor b/extra/gpu/effects/blur/blur.factor new file mode 100644 index 0000000000..0a25654976 --- /dev/null +++ b/extra/gpu/effects/blur/blur.factor @@ -0,0 +1,81 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: destructors fry gpu.render gpu.shaders gpu.state gpu.textures +gpu.util images kernel locals math math.rectangles sequences ; +IN: gpu.effects.blur + +GLSL-SHADER: blur-fragment-shader fragment-shader +uniform sampler2D texture; +uniform bool horizontal; +uniform float blurSize; +varying vec2 texcoord; +void main() +{ + vec4 col = 0.16 * texture2D(texture, texcoord); + if (horizontal) + { + const vec2 blurX1 = vec2(blurSize, 0.0); + const vec2 blurX2 = vec2(blurSize * 2.0, 0.0); + const vec2 blurX3 = vec2(blurSize * 3.0, 0.0); + const vec2 blurX4 = vec2(blurSize * 4.0, 0.0); + col += 0.15 * ( texture2D(texture, texcoord - blurX1) + + texture2D(texture, texcoord + blurX1)); + col += 0.12 * ( texture2D(texture, texcoord - blurX2) + + texture2D(texture, texcoord + blurX2)); + col += 0.09 * ( texture2D(texture, texcoord - blurX3) + + texture2D(texture, texcoord + blurX3)); + col += 0.05 * ( texture2D(texture, texcoord - blurX4) + + texture2D(texture, texcoord + blurX4)); + } + else + { + const vec2 blurY1 = vec2(0.0, blurSize); + const vec2 blurY2 = vec2(0.0, blurSize * 2.0); + const vec2 blurY3 = vec2(0.0, blurSize * 3.0); + const vec2 blurY4 = vec2(0.0, blurSize * 4.0); + col += 0.15 * ( texture2D(texture, texcoord - blurY1) + + texture2D(texture, texcoord + blurY1)); + col += 0.12 * ( texture2D(texture, texcoord - blurY2) + + texture2D(texture, texcoord + blurY2)); + col += 0.09 * ( texture2D(texture, texcoord - blurY3) + + texture2D(texture, texcoord + blurY3)); + col += 0.05 * ( texture2D(texture, texcoord - blurY4) + + texture2D(texture, texcoord + blurY4)); + } + gl_FragColor = col ; +} +; + +UNIFORM-TUPLE: blur-uniforms + { "texture" texture-uniform f } + { "horizontal" bool-uniform f } + { "blurSize" float-uniform f } ; + +GLSL-PROGRAM: blur-program window-vertex-shader blur-fragment-shader window-vertex-format ; + +:: (blur) ( texture horizontal? framebuffer dim -- ) + { 0 0 } dim set-gpu-state + texture horizontal? 1.0 dim horizontal? [ first ] [ second ] if / blur-uniforms boa framebuffer { + { "primitive-mode" [ 2drop triangle-strip-mode ] } + { "uniforms" [ drop ] } + { "vertex-array" [ 2drop blur-program &dispose ] } + { "indexes" [ 2drop T{ index-range f 0 4 } ] } + { "framebuffer" [ nip ] } + } 2 render ; + +:: blur ( texture horizontal? -- texture ) + texture 0 texture-dim :> dim + dim L ubyte-components <2d-render-texture> :> ( target-framebuffer target-texture ) + texture horizontal? target-framebuffer dim (blur) + target-framebuffer dispose + target-texture ; + +: horizontal-blur ( texture -- texture ) t blur ; inline + +: vertical-blur ( texture -- texture ) f blur ; inline + +: discompose ( quot1 quot2 -- compose ) + '[ @ &dispose @ ] with-destructors ; inline + +: gaussian-blur ( texture -- texture ) + [ horizontal-blur ] [ vertical-blur ] discompose ; diff --git a/extra/gpu/effects/blur/summary.txt b/extra/gpu/effects/blur/summary.txt new file mode 100644 index 0000000000..a9c5314a2e --- /dev/null +++ b/extra/gpu/effects/blur/summary.txt @@ -0,0 +1 @@ +Blur effects for textures. diff --git a/extra/gpu/effects/quad/authors.txt b/extra/gpu/effects/quad/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/extra/gpu/effects/quad/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/extra/gpu/effects/quad/quad.factor b/extra/gpu/effects/quad/quad.factor new file mode 100644 index 0000000000..5a770ba838 --- /dev/null +++ b/extra/gpu/effects/quad/quad.factor @@ -0,0 +1,4 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: ; +IN: gpu.effects.quad diff --git a/extra/gpu/effects/quad/summary.txt b/extra/gpu/effects/quad/summary.txt new file mode 100644 index 0000000000..8952404931 --- /dev/null +++ b/extra/gpu/effects/quad/summary.txt @@ -0,0 +1 @@ +Render a screen-aligned quad. diff --git a/extra/gpu/effects/step/authors.txt b/extra/gpu/effects/step/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/extra/gpu/effects/step/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/extra/gpu/effects/step/step.factor b/extra/gpu/effects/step/step.factor new file mode 100644 index 0000000000..eff2a47e23 --- /dev/null +++ b/extra/gpu/effects/step/step.factor @@ -0,0 +1,23 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: ; +IN: gpu.effects.step + +GLSL-SHADER: step-fragment-shader fragment-shader +const vec4 luminance = vec4(0.3, 0.59, 0.11, 0.0); +uniform sampler2D texture; +uniform sampler2D ramp; +varying vec2 texcoord; +void main() +{ + vec4 col = texture2D(texture, texcoord); + float l = dot(col, luminance); + gl_FragColor = texture2D(ramp, vec2(l, 0.0)); +} +; + +UNIFORM-TUPLE: step-uniforms + { "texture" texture-uniform f } + { "ramp" texture-uniform f } ; + +GLSL-PROGRAM: step-program window-vertex-shader step-fragment-shader window-vertex-format ; diff --git a/extra/gpu/effects/step/summary.txt b/extra/gpu/effects/step/summary.txt new file mode 100644 index 0000000000..61028dd28a --- /dev/null +++ b/extra/gpu/effects/step/summary.txt @@ -0,0 +1 @@ +Render a quad with a step texture. diff --git a/extra/gpu/util/util.factor b/extra/gpu/util/util.factor index d33fcf8c09..ffca3a5478 100644 --- a/extra/gpu/util/util.factor +++ b/extra/gpu/util/util.factor @@ -1,6 +1,6 @@ ! (c)2009 Joe Groff bsd license -USING: gpu.buffers gpu.render gpu.shaders gpu.textures images kernel -specialized-arrays ; +USING: arrays gpu.buffers gpu.framebuffers gpu.render gpu.shaders +gpu.textures images kernel locals specialized-arrays ; FROM: alien.c-types => float ; SPECIALIZED-ARRAY: float IN: gpu.util @@ -44,10 +44,58 @@ CONSTANT: environment-cube-map-mv-matrices { 0.0 0.0 0.0 1.0 } } } } + +GLSL-SHADER: window-vertex-shader vertex-shader +attribute vec2 vertex; +varying vec2 texcoord; +void main() +{ + texcoord = vertex * vec2(0.5) + vec2(0.5); + gl_Position = vec4(vertex, 0.0, 1.0); +} +; -VERTEX-FORMAT: window-vertex +GLSL-SHADER: window-fragment-shader fragment-shader +uniform sampler2D texture; +varying vec2 texcoord; +void main() +{ + gl_FragColor = texture2D(texture, texcoord); +} +; + +VERTEX-FORMAT: window-vertex-format { "vertex" float-components 2 f } ; +UNIFORM-TUPLE: window-uniforms + { "texture" texture-uniform f } ; + +GLSL-PROGRAM: window-program window-vertex-shader window-fragment-shader window-vertex-format ; + +GLSL-SHADER: window-point-vertex-shader vertex-shader +uniform float point_size; +attribute vec2 vertex; +void main() +{ + gl_Position = vec4(vertex, 0.0, 1.0); + gl_PointSize = point_size; +} +; + +GLSL-SHADER: window-point-fragment-shader fragment-shader +uniform sampler2D texture; +void main() +{ + gl_FragColor = texture2D(texture, gl_PointCoord); +} +; + +UNIFORM-TUPLE: window-point-uniforms + { "texture" texture-uniform f } + { "point_size" float-uniform f } ; + +GLSL-PROGRAM: window-point-program window-point-vertex-shader window-point-fragment-shader window-vertex-format ; + CONSTANT: window-vertexes float-array{ -1.0 -1.0 @@ -62,4 +110,17 @@ CONSTANT: window-vertexes byte-array>buffer ; inline : ( program-instance -- vertex-array ) - [ ] dip window-vertex ; inline + [ ] dip window-vertex-format ; inline + +:: <2d-render-texture> ( dim order type -- renderbuffer texture ) + order type T{ texture-parameters { wrap clamp-texcoord-to-edge } + { min-filter filter-linear } { min-mipmap-filter f } } + [ 0 1array f f dim ] keep ; + +: draw-texture ( texture -- ) + { + { "primitive-mode" [ drop triangle-strip-mode ] } + { "uniforms" [ window-uniforms boa ] } + { "vertex-array" [ drop window-program ] } + { "indexes" [ drop T{ index-range f 0 4 } ] } + } render ; From 6081abea041db9bc2fb7651321568784c8079b70 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sun, 4 Apr 2010 20:52:09 -0700 Subject: [PATCH 586/713] Fix step effect --- extra/fluids/fluids.factor | 3 ++- extra/gpu/effects/step/step.factor | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/extra/fluids/fluids.factor b/extra/fluids/fluids.factor index a0d75fd6e3..d241a82ede 100644 --- a/extra/fluids/fluids.factor +++ b/extra/fluids/fluids.factor @@ -5,7 +5,8 @@ game.worlds gpu gpu.buffers gpu.framebuffers gpu.render gpu.shaders gpu.state gpu.textures gpu.util images images.loader kernel literals locals make math math.rectangles math.vectors namespaces opengl.gl sequences specialized-arrays ui.gadgets.worlds images.ppm -ui.gestures ui.pixel-formats images.pgm gpu.effects.blur ; +ui.gestures ui.pixel-formats images.pgm gpu.effects.blur +gpu.effects.step ; FROM: alien.c-types => float ; SPECIALIZED-ARRAY: float IN: fluids diff --git a/extra/gpu/effects/step/step.factor b/extra/gpu/effects/step/step.factor index eff2a47e23..f50c0c3cc1 100644 --- a/extra/gpu/effects/step/step.factor +++ b/extra/gpu/effects/step/step.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. -USING: ; +USING: gpu.render gpu.shaders gpu.util ; IN: gpu.effects.step GLSL-SHADER: step-fragment-shader fragment-shader From a91d7a0e7bdf270bfe80cb15cb7b857a2f14660d Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 5 Apr 2010 01:38:39 -0700 Subject: [PATCH 587/713] Get fluids working on Mac --- extra/fluids/fluids.factor | 14 +++++++------- extra/gpu/effects/blur/blur.factor | 27 ++++++++++++++------------- extra/gpu/util/util.factor | 18 +++++++++++++----- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/extra/fluids/fluids.factor b/extra/fluids/fluids.factor index d241a82ede..1b4f1524de 100644 --- a/extra/fluids/fluids.factor +++ b/extra/fluids/fluids.factor @@ -98,14 +98,14 @@ M: fluids-world begin-game-world dup fluid set init-gpu initial-particles clone >>particles - "C:/Users/erikc/Pictures/particle2.pgm" make-texture >>texture - "C:/Users/erikc/Pictures/colors.ppm" make-texture >>ramp + "resource:extra/fluids/particle2.pgm" make-texture >>texture + "resource:extra/fluids/colors.ppm" make-texture >>ramp RGB float-components T{ texture-parameters - { wrap clamp-texcoord-to-edge } - { min-filter filter-linear } - { min-mipmap-filter f } - } >>color-texture + { wrap clamp-texcoord-to-edge } + { min-filter filter-linear } + { min-mipmap-filter f } } + >>color-texture dup color-texture>> 0 1array f f { 320 240 } >>framebuffer drop ; @@ -135,7 +135,7 @@ M:: fluids-world draw-world* ( world -- ) { "indexes" [ nip length 2 / 0 swap ] } { "framebuffer" [ drop framebuffer>> ] } } 2 render - + world color-texture>> gaussian-blur { 0 0 } { 640 480 } set-gpu-state world ramp>> { diff --git a/extra/gpu/effects/blur/blur.factor b/extra/gpu/effects/blur/blur.factor index 0a25654976..ed72b28374 100644 --- a/extra/gpu/effects/blur/blur.factor +++ b/extra/gpu/effects/blur/blur.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. -USING: destructors fry gpu.render gpu.shaders gpu.state gpu.textures -gpu.util images kernel locals math math.rectangles sequences ; +USING: arrays destructors fry gpu.framebuffers gpu.render gpu.shaders +gpu.state gpu.textures gpu.util images kernel locals math +math.rectangles sequences ; IN: gpu.effects.blur GLSL-SHADER: blur-fragment-shader fragment-shader @@ -14,10 +15,10 @@ void main() vec4 col = 0.16 * texture2D(texture, texcoord); if (horizontal) { - const vec2 blurX1 = vec2(blurSize, 0.0); - const vec2 blurX2 = vec2(blurSize * 2.0, 0.0); - const vec2 blurX3 = vec2(blurSize * 3.0, 0.0); - const vec2 blurX4 = vec2(blurSize * 4.0, 0.0); + vec2 blurX1 = vec2(blurSize, 0.0); + vec2 blurX2 = vec2(blurSize * 2.0, 0.0); + vec2 blurX3 = vec2(blurSize * 3.0, 0.0); + vec2 blurX4 = vec2(blurSize * 4.0, 0.0); col += 0.15 * ( texture2D(texture, texcoord - blurX1) + texture2D(texture, texcoord + blurX1)); col += 0.12 * ( texture2D(texture, texcoord - blurX2) @@ -29,10 +30,10 @@ void main() } else { - const vec2 blurY1 = vec2(0.0, blurSize); - const vec2 blurY2 = vec2(0.0, blurSize * 2.0); - const vec2 blurY3 = vec2(0.0, blurSize * 3.0); - const vec2 blurY4 = vec2(0.0, blurSize * 4.0); + vec2 blurY1 = vec2(0.0, blurSize); + vec2 blurY2 = vec2(0.0, blurSize * 2.0); + vec2 blurY3 = vec2(0.0, blurSize * 3.0); + vec2 blurY4 = vec2(0.0, blurSize * 4.0); col += 0.15 * ( texture2D(texture, texcoord - blurY1) + texture2D(texture, texcoord + blurY1)); col += 0.12 * ( texture2D(texture, texcoord - blurY2) @@ -42,7 +43,7 @@ void main() col += 0.05 * ( texture2D(texture, texcoord - blurY4) + texture2D(texture, texcoord + blurY4)); } - gl_FragColor = col ; + gl_FragColor = col; } ; @@ -52,7 +53,7 @@ UNIFORM-TUPLE: blur-uniforms { "blurSize" float-uniform f } ; GLSL-PROGRAM: blur-program window-vertex-shader blur-fragment-shader window-vertex-format ; - + :: (blur) ( texture horizontal? framebuffer dim -- ) { 0 0 } dim set-gpu-state texture horizontal? 1.0 dim horizontal? [ first ] [ second ] if / blur-uniforms boa framebuffer { @@ -65,7 +66,7 @@ GLSL-PROGRAM: blur-program window-vertex-shader blur-fragment-shader window-vert :: blur ( texture horizontal? -- texture ) texture 0 texture-dim :> dim - dim L ubyte-components <2d-render-texture> :> ( target-framebuffer target-texture ) + dim RGB float-components <2d-render-texture> :> ( target-framebuffer target-texture ) texture horizontal? target-framebuffer dim (blur) target-framebuffer dispose target-texture ; diff --git a/extra/gpu/util/util.factor b/extra/gpu/util/util.factor index ffca3a5478..29fe5f1314 100644 --- a/extra/gpu/util/util.factor +++ b/extra/gpu/util/util.factor @@ -1,6 +1,7 @@ ! (c)2009 Joe Groff bsd license -USING: arrays gpu.buffers gpu.framebuffers gpu.render gpu.shaders -gpu.textures images kernel locals specialized-arrays ; +USING: accessors arrays gpu.buffers gpu.framebuffers gpu.render +gpu.shaders gpu.textures images kernel locals opengl.framebuffers +specialized-arrays ; FROM: alien.c-types => float ; SPECIALIZED-ARRAY: float IN: gpu.util @@ -83,6 +84,7 @@ void main() ; GLSL-SHADER: window-point-fragment-shader fragment-shader +#version 120 uniform sampler2D texture; void main() { @@ -113,9 +115,15 @@ CONSTANT: window-vertexes [ ] dip window-vertex-format ; inline :: <2d-render-texture> ( dim order type -- renderbuffer texture ) - order type T{ texture-parameters { wrap clamp-texcoord-to-edge } - { min-filter filter-linear } { min-mipmap-filter f } } - [ 0 1array f f dim ] keep ; + order type + T{ texture-parameters + { wrap clamp-texcoord-to-edge } + { min-filter filter-linear } + { min-mipmap-filter f } } + [ + 0 1array f f dim + dup { { default-attachment { 0 0 0 } } } clear-framebuffer + ] keep ; : draw-texture ( texture -- ) { From 9b44451682caa17361b68b25be2a85135bb79652 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 5 Apr 2010 14:49:32 -0500 Subject: [PATCH 588/713] Safe SEH is better than abstinence --- Nmakefile | 8 +++++++- vm/os-windows-nt.cpp | 2 +- vm/os-windows-nt.hpp | 2 +- vm/safeseh.asm | 5 +++++ 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100755 vm/safeseh.asm diff --git a/Nmakefile b/Nmakefile index 9df7a6a1ee..dc28e1884c 100755 --- a/Nmakefile +++ b/Nmakefile @@ -2,10 +2,12 @@ LINK_FLAGS = /nologo /DEBUG shell32.lib CL_FLAGS = /nologo /Zi /O2 /W3 /DFACTOR_DEBUG !ELSE -LINK_FLAGS = /nologo /safeseh:no shell32.lib +LINK_FLAGS = /nologo /safeseh shell32.lib CL_FLAGS = /nologo /O2 /W3 !ENDIF +ML_FLAGS = /nologo /safeseh + EXE_OBJS = vm\main-windows-nt.obj vm\factor.res DLL_OBJS = vm\os-windows-nt.obj \ @@ -47,6 +49,7 @@ DLL_OBJS = vm\os-windows-nt.obj \ vm\profiler.obj \ vm\quotations.obj \ vm\run.obj \ + vm\safeseh.obj \ vm\strings.obj \ vm\to_tenured_collector.obj \ vm\tuples.obj \ @@ -60,6 +63,9 @@ DLL_OBJS = vm\os-windows-nt.obj \ .c.obj: cl $(CL_FLAGS) /Fo$@ /c $< +.asm.obj: + ml $(ML_FLAGS) /Fo$@ /c $< + .rs.res: rc $< diff --git a/vm/os-windows-nt.cpp b/vm/os-windows-nt.cpp index 4f90d7f641..711b2a8445 100755 --- a/vm/os-windows-nt.cpp +++ b/vm/os-windows-nt.cpp @@ -87,7 +87,7 @@ LONG factor_vm::exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, return ExceptionContinueExecution; } -LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch) +extern "C" LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch) { return current_vm()->exception_handler(e,frame,c,dispatch); } diff --git a/vm/os-windows-nt.hpp b/vm/os-windows-nt.hpp index d84ac97298..2ba75ccf54 100755 --- a/vm/os-windows-nt.hpp +++ b/vm/os-windows-nt.hpp @@ -22,7 +22,7 @@ typedef char symbol_char; #define FACTOR_DLL NULL -LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch); +extern "C" LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch); // SSE traps raise these exception codes, which are defined in internal NT headers // but not winbase.h diff --git a/vm/safeseh.asm b/vm/safeseh.asm new file mode 100755 index 0000000000..fb706c1331 --- /dev/null +++ b/vm/safeseh.asm @@ -0,0 +1,5 @@ +.386 +.model flat +exception_handler proto +.safeseh exception_handler +end From ff0e084f94f4a58a433756bca7b696f4ce4e3bdf Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 5 Apr 2010 15:48:09 -0500 Subject: [PATCH 589/713] vm: dllexport exception_handler for great justice --- vm/os-windows-nt.cpp | 2 +- vm/os-windows-nt.hpp | 2 +- vm/platform.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vm/os-windows-nt.cpp b/vm/os-windows-nt.cpp index 711b2a8445..b7f86233a1 100755 --- a/vm/os-windows-nt.cpp +++ b/vm/os-windows-nt.cpp @@ -87,7 +87,7 @@ LONG factor_vm::exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, return ExceptionContinueExecution; } -extern "C" LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch) +VM_C_API LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch) { return current_vm()->exception_handler(e,frame,c,dispatch); } diff --git a/vm/os-windows-nt.hpp b/vm/os-windows-nt.hpp index 2ba75ccf54..60990c0986 100755 --- a/vm/os-windows-nt.hpp +++ b/vm/os-windows-nt.hpp @@ -22,7 +22,7 @@ typedef char symbol_char; #define FACTOR_DLL NULL -extern "C" LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch); +VM_C_API LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch); // SSE traps raise these exception codes, which are defined in internal NT headers // but not winbase.h diff --git a/vm/platform.hpp b/vm/platform.hpp index a71aae1e89..e5a07a05d4 100755 --- a/vm/platform.hpp +++ b/vm/platform.hpp @@ -3,8 +3,8 @@ #include "os-windows-ce.hpp" #include "os-windows.hpp" #elif defined(WINNT) - #include "os-windows-nt.hpp" #include "os-windows.hpp" + #include "os-windows-nt.hpp" #if defined(FACTOR_AMD64) #include "os-windows-nt.64.hpp" From 9ec94f242d95de50048cb91169647dd58c7008e7 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 5 Apr 2010 03:07:03 -0500 Subject: [PATCH 590/713] Dont use literals twice --- basis/windows/winsock/winsock.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/windows/winsock/winsock.factor b/basis/windows/winsock/winsock.factor index 49a3d6e9fa..4dd7d7385c 100644 --- a/basis/windows/winsock/winsock.factor +++ b/basis/windows/winsock/winsock.factor @@ -3,7 +3,7 @@ USING: alien alien.c-types alien.strings alien.syntax arrays byte-arrays kernel literals math sequences windows.types windows.kernel32 windows.errors math.bitwise io.encodings.utf16n -classes.struct windows.com.syntax init literals ; +classes.struct windows.com.syntax init ; FROM: alien.c-types => short ; IN: windows.winsock From eac2849833289dd4e4604ab5ccf13885e265a2c9 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 5 Apr 2010 17:57:18 -0500 Subject: [PATCH 591/713] Temporary fix for directx bindings until I revert flags{ patch or parsing words get redone --- .../directx/d3d9types/d3d9types.factor | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/basis/windows/directx/d3d9types/d3d9types.factor b/basis/windows/directx/d3d9types/d3d9types.factor index 618d3c79e5..a9485a8fcf 100644 --- a/basis/windows/directx/d3d9types/d3d9types.factor +++ b/basis/windows/directx/d3d9types/d3d9types.factor @@ -759,25 +759,25 @@ CONSTANT: D3DSHADER_ADDRMODE_FORCE_DWORD HEX: 7fffffff CONSTANT: D3DVS_SWIZZLE_SHIFT 16 CONSTANT: D3DVS_SWIZZLE_MASK HEX: 00FF0000 -: D3DVS_X_X ( -- n ) 0 D3DVS_SWIZZLE_SHIFT shift ; inline -: D3DVS_X_Y ( -- n ) 1 D3DVS_SWIZZLE_SHIFT shift ; inline -: D3DVS_X_Z ( -- n ) 2 D3DVS_SWIZZLE_SHIFT shift ; inline -: D3DVS_X_W ( -- n ) 3 D3DVS_SWIZZLE_SHIFT shift ; inline +CONSTANT: D3DVS_X_X $[ 0 16 shift ] +CONSTANT: D3DVS_X_Y $[ 1 16 shift ] +CONSTANT: D3DVS_X_Z $[ 2 16 shift ] +CONSTANT: D3DVS_X_W $[ 3 16 shift ] -: D3DVS_Y_X ( -- n ) 0 D3DVS_SWIZZLE_SHIFT 2 + shift ; inline -: D3DVS_Y_Y ( -- n ) 1 D3DVS_SWIZZLE_SHIFT 2 + shift ; inline -: D3DVS_Y_Z ( -- n ) 2 D3DVS_SWIZZLE_SHIFT 2 + shift ; inline -: D3DVS_Y_W ( -- n ) 3 D3DVS_SWIZZLE_SHIFT 2 + shift ; inline +CONSTANT: D3DVS_Y_X $[ 0 16 2 + shift ] +CONSTANT: D3DVS_Y_Y $[ 1 16 2 + shift ] +CONSTANT: D3DVS_Y_Z $[ 2 16 2 + shift ] +CONSTANT: D3DVS_Y_W $[ 3 16 2 + shift ] -: D3DVS_Z_X ( -- n ) 0 D3DVS_SWIZZLE_SHIFT 4 + shift ; inline -: D3DVS_Z_Y ( -- n ) 1 D3DVS_SWIZZLE_SHIFT 4 + shift ; inline -: D3DVS_Z_Z ( -- n ) 2 D3DVS_SWIZZLE_SHIFT 4 + shift ; inline -: D3DVS_Z_W ( -- n ) 3 D3DVS_SWIZZLE_SHIFT 4 + shift ; inline +CONSTANT: D3DVS_Z_X $[ 0 16 4 + shift ] +CONSTANT: D3DVS_Z_Y $[ 1 16 4 + shift ] +CONSTANT: D3DVS_Z_Z $[ 2 16 4 + shift ] +CONSTANT: D3DVS_Z_W $[ 3 16 4 + shift ] -: D3DVS_W_X ( -- n ) 0 D3DVS_SWIZZLE_SHIFT 6 + shift ; inline -: D3DVS_W_Y ( -- n ) 1 D3DVS_SWIZZLE_SHIFT 6 + shift ; inline -: D3DVS_W_Z ( -- n ) 2 D3DVS_SWIZZLE_SHIFT 6 + shift ; inline -: D3DVS_W_W ( -- n ) 3 D3DVS_SWIZZLE_SHIFT 6 + shift ; inline +CONSTANT: D3DVS_W_X $[ 0 16 6 + shift ] +CONSTANT: D3DVS_W_Y $[ 1 16 6 + shift ] +CONSTANT: D3DVS_W_Z $[ 2 16 6 + shift ] +CONSTANT: D3DVS_W_W $[ 3 16 6 + shift ] CONSTANT: D3DVS_NOSWIZZLE flags{ D3DVS_X_X D3DVS_Y_Y D3DVS_Z_Z D3DVS_W_W } @@ -787,20 +787,20 @@ CONSTANT: D3DSP_SRCMOD_SHIFT 24 CONSTANT: D3DSP_SRCMOD_MASK HEX: 0F000000 TYPEDEF: int D3DSHADER_PARAM_SRCMOD_TYPE -: D3DSPSM_NONE ( -- n ) 0 D3DSP_SRCMOD_SHIFT shift ; inline -: D3DSPSM_NEG ( -- n ) 1 D3DSP_SRCMOD_SHIFT shift ; inline -: D3DSPSM_BIAS ( -- n ) 2 D3DSP_SRCMOD_SHIFT shift ; inline -: D3DSPSM_BIASNEG ( -- n ) 3 D3DSP_SRCMOD_SHIFT shift ; inline -: D3DSPSM_SIGN ( -- n ) 4 D3DSP_SRCMOD_SHIFT shift ; inline -: D3DSPSM_SIGNNEG ( -- n ) 5 D3DSP_SRCMOD_SHIFT shift ; inline -: D3DSPSM_COMP ( -- n ) 6 D3DSP_SRCMOD_SHIFT shift ; inline -: D3DSPSM_X2 ( -- n ) 7 D3DSP_SRCMOD_SHIFT shift ; inline -: D3DSPSM_X2NEG ( -- n ) 8 D3DSP_SRCMOD_SHIFT shift ; inline -: D3DSPSM_DZ ( -- n ) 9 D3DSP_SRCMOD_SHIFT shift ; inline -: D3DSPSM_DW ( -- n ) 10 D3DSP_SRCMOD_SHIFT shift ; inline -: D3DSPSM_ABS ( -- n ) 11 D3DSP_SRCMOD_SHIFT shift ; inline -: D3DSPSM_ABSNEG ( -- n ) 12 D3DSP_SRCMOD_SHIFT shift ; inline -: D3DSPSM_NOT ( -- n ) 13 D3DSP_SRCMOD_SHIFT shift ; inline +CONSTANT: D3DSPSM_NONE $[ 0 24 shift ] +CONSTANT: D3DSPSM_NEG $[ 1 24 shift ] +CONSTANT: D3DSPSM_BIAS $[ 2 24 shift ] +CONSTANT: D3DSPSM_BIASNEG $[ 3 24 shift ] +CONSTANT: D3DSPSM_SIGN $[ 4 24 shift ] +CONSTANT: D3DSPSM_SIGNNEG $[ 5 24 shift ] +CONSTANT: D3DSPSM_COMP $[ 6 24 shift ] +CONSTANT: D3DSPSM_X2 $[ 7 24 shift ] +CONSTANT: D3DSPSM_X2NEG $[ 8 24 shift ] +CONSTANT: D3DSPSM_DZ $[ 9 24 shift ] +CONSTANT: D3DSPSM_DW $[ 10 24 shift ] +CONSTANT: D3DSPSM_ABS $[ 11 24 shift ] +CONSTANT: D3DSPSM_ABSNEG $[ 12 24 shift ] +CONSTANT: D3DSPSM_NOT $[ 13 24 shift ] CONSTANT: D3DSPSM_FORCE_DWORD HEX: 7fffffff : D3DPS_VERSION ( major minor -- n ) From d6fb134d5f8108a0d53d771e28cf3c446d3b1d3a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 5 Apr 2010 17:19:43 -0400 Subject: [PATCH 592/713] kernel: add examples for if, when, unless and if* --- core/kernel/kernel-docs.factor | 64 +++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/core/kernel/kernel-docs.factor b/core/kernel/kernel-docs.factor index 064978f99b..f977a0487b 100644 --- a/core/kernel/kernel-docs.factor +++ b/core/kernel/kernel-docs.factor @@ -575,19 +575,51 @@ HELP: if { $values { "?" "a generalized boolean" } { "true" quotation } { "false" quotation } } { $description "If " { $snippet "cond" } " is " { $link f } ", calls the " { $snippet "false" } " quotation. Otherwise calls the " { $snippet "true" } " quotation." $nl -"The " { $snippet "cond" } " value is removed from the stack before either quotation is called." } ; +"The " { $snippet "cond" } " value is removed from the stack before either quotation is called." } +{ $examples + { $example + "USING: io kernel math ;" + "10 3 < [ \"Math is broken\" print ] [ \"Math is good\" print ] if" + "Math is good" + } +} ; HELP: when { $values { "?" "a generalized boolean" } { "true" quotation } } { $description "If " { $snippet "cond" } " is not " { $link f } ", calls the " { $snippet "true" } " quotation." $nl -"The " { $snippet "cond" } " value is removed from the stack before the quotation is called." } ; +"The " { $snippet "cond" } " value is removed from the stack before the quotation is called." } +{ $examples + { $example + "USING: kernel math prettyprint ;" + "-5 dup 0 < [ 3 + ] when ." + "-2" + } +} ; HELP: unless { $values { "?" "a generalized boolean" } { "false" quotation } } { $description "If " { $snippet "cond" } " is " { $link f } ", calls the " { $snippet "false" } " quotation." $nl -"The " { $snippet "cond" } " value is removed from the stack before the quotation is called." } ; +"The " { $snippet "cond" } " value is removed from the stack before the quotation is called." } +{ $examples + { $example + "USING: kernel math prettyprint sequences ;" + "IN: scratchpad" + "" + "CONSTANT: american-cities {" + " \"San Francisco\"" + " \"Los Angeles\"" + " \"New York\"" + "}" + "" + ": add-tax ( price city -- price' )" + " american-cities member? [ 1.1 * ] unless ;" + "" + "123 \"Ottawa\" add-tax ." + "135.3" + } +} ; HELP: if* { $values { "?" "a generalized boolean" } { "true" { $quotation "( ..a ? -- ..b )" } } { "false" { $quotation "( ..a -- ..b )" } } } @@ -596,7 +628,31 @@ $nl "If the condition is true, it is retained on the stack before the " { $snippet "true" } " quotation is called. Otherwise, the condition is removed from the stack and the " { $snippet "false" } " quotation is called." $nl "The following two lines are equivalent:" -{ $code "X [ Y ] [ Z ] if*" "X dup [ Y ] [ drop Z ] if" } } ; +{ $code "X [ Y ] [ Z ] if*" "X dup [ Y ] [ drop Z ] if" } } +{ $examples + "Notice how in this example, the same value is tested by the conditional, and then used in the true branch; the false branch does not need to drop the value because of how " { $link if* } " works:" + { $example + "USING: assocs io kernel math.parser ;" + "IN: scratchpad" + "" + ": curry-price ( meat -- price ) + { + { \"Beef\" 10 } + { \"Chicken\" 12 } + { \"Lamb\" 13 } + } at ; + +: order-curry ( meat -- ) + curry-price [ + \"Your order will be \" write + number>string write + \" dollars.\" write + ] [ \"Invalid order.\" print ] if* ;" + "" + "\"Deer\" order-curry" + "Invalid order." + } +} ; HELP: when* { $values { "?" "a generalized boolean" } { "true" { $quotation "( cond -- ... )" } } } From 430a05dcea92d6a0148a1437246ebff69a8f1333 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 5 Apr 2010 19:06:51 -0400 Subject: [PATCH 593/713] Store stack bounds in TIB on win64 to make C++ exceptions work --- Nmakefile | 2 +- basis/cpu/x86/32/bootstrap.factor | 3 -- basis/cpu/x86/32/unix/bootstrap.factor | 14 +++----- basis/cpu/x86/32/winnt/bootstrap.factor | 46 ++++++++----------------- basis/cpu/x86/64/bootstrap.factor | 12 ++----- basis/cpu/x86/64/unix/bootstrap.factor | 5 +-- basis/cpu/x86/64/winnt/bootstrap.factor | 13 +++++-- basis/cpu/x86/unix/bootstrap.factor | 13 +++++++ basis/cpu/x86/winnt/bootstrap.factor | 32 +++++++++++++++++ 9 files changed, 81 insertions(+), 59 deletions(-) create mode 100644 basis/cpu/x86/unix/bootstrap.factor create mode 100644 basis/cpu/x86/winnt/bootstrap.factor diff --git a/Nmakefile b/Nmakefile index dc28e1884c..02d2b5f1ed 100755 --- a/Nmakefile +++ b/Nmakefile @@ -1,5 +1,5 @@ !IF DEFINED(DEBUG) -LINK_FLAGS = /nologo /DEBUG shell32.lib +LINK_FLAGS = /nologo /safeseh /DEBUG shell32.lib CL_FLAGS = /nologo /Zi /O2 /W3 /DFACTOR_DEBUG !ELSE LINK_FLAGS = /nologo /safeseh shell32.lib diff --git a/basis/cpu/x86/32/bootstrap.factor b/basis/cpu/x86/32/bootstrap.factor index 9b1a1de23d..b2cd241df1 100644 --- a/basis/cpu/x86/32/bootstrap.factor +++ b/basis/cpu/x86/32/bootstrap.factor @@ -330,6 +330,3 @@ IN: bootstrap.x86 jit-delete-current-context jit-start-context ] \ (start-context-and-delete) define-sub-primitive - -<< "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >> -call diff --git a/basis/cpu/x86/32/unix/bootstrap.factor b/basis/cpu/x86/32/unix/bootstrap.factor index 1e3bee4961..56d18511e4 100644 --- a/basis/cpu/x86/32/unix/bootstrap.factor +++ b/basis/cpu/x86/32/unix/bootstrap.factor @@ -1,14 +1,8 @@ ! Copyright (C) 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: cpu.x86.assembler cpu.x86.assembler.operands kernel -layouts parser sequences ; +USING: kernel parser sequences ; IN: bootstrap.x86 -: jit-save-tib ( -- ) ; -: jit-restore-tib ( -- ) ; -: jit-update-tib ( ctx-reg -- ) drop ; -: jit-install-seh ( -- ) ESP bootstrap-cell ADD ; -: jit-update-seh ( ctx-reg -- ) drop ; - -<< "vocab:cpu/x86/32/bootstrap.factor" parse-file suffix! >> -call +<< "vocab:cpu/x86/unix/bootstrap.factor" parse-file suffix! >> call +<< "vocab:cpu/x86/32/bootstrap.factor" parse-file suffix! >> call +<< "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >> call diff --git a/basis/cpu/x86/32/winnt/bootstrap.factor b/basis/cpu/x86/32/winnt/bootstrap.factor index b8ee1dacaf..5628632e6c 100644 --- a/basis/cpu/x86/32/winnt/bootstrap.factor +++ b/basis/cpu/x86/32/winnt/bootstrap.factor @@ -5,50 +5,32 @@ cpu.x86.assembler cpu.x86.assembler.operands kernel layouts locals parser sequences ; IN: bootstrap.x86 -: tib-exception-list-offset ( -- n ) 0 bootstrap-cells ; -: tib-stack-base-offset ( -- n ) 1 bootstrap-cells ; -: tib-stack-limit-offset ( -- n ) 2 bootstrap-cells ; +: tib-segment ( -- ) FS ; +: tib-temp ( -- reg ) EAX ; -: jit-save-tib ( -- ) - tib-exception-list-offset [] FS PUSH - tib-stack-base-offset [] FS PUSH - tib-stack-limit-offset [] FS PUSH ; - -: jit-restore-tib ( -- ) - tib-stack-limit-offset [] FS POP - tib-stack-base-offset [] FS POP - tib-exception-list-offset [] FS POP ; - -:: jit-update-tib ( ctx-reg -- ) - ! There's a redundant load here because we're not allowed - ! to clobber ctx-reg. Clobbers EAX. - ! Save callstack base in TIB - EAX ctx-reg context-callstack-seg-offset [+] MOV - EAX EAX segment-end-offset [+] MOV - tib-stack-base-offset [] EAX FS MOV - ! Save callstack limit in TIB - EAX ctx-reg context-callstack-seg-offset [+] MOV - EAX EAX segment-start-offset [+] MOV - tib-stack-limit-offset [] EAX FS MOV ; +<< "vocab:cpu/x86/winnt/bootstrap.factor" parse-file suffix! >> call : jit-install-seh ( -- ) ! Create a new exception record and store it in the TIB. + ! Clobbers tib-temp. ! Align stack ESP 3 bootstrap-cells ADD ! Exception handler address filled in by callback.cpp - 0 PUSH rc-absolute-cell rt-exception-handler jit-rel + tib-temp 0 MOV rc-absolute-cell rt-exception-handler jit-rel + tib-temp PUSH ! No next handler 0 PUSH ! This is the new exception handler - tib-exception-list-offset [] ESP FS MOV ; + tib-exception-list-offset [] ESP tib-segment MOV ; :: jit-update-seh ( ctx-reg -- ) ! Load exception record structure that jit-install-seh - ! created from the bottom of the callstack. Clobbers EAX. - EAX ctx-reg context-callstack-bottom-offset [+] MOV - EAX bootstrap-cell ADD + ! created from the bottom of the callstack. + ! Clobbers tib-temp. + tib-temp ctx-reg context-callstack-bottom-offset [+] MOV + tib-temp bootstrap-cell ADD ! Store exception record in TIB. - tib-exception-list-offset [] EAX FS MOV ; + tib-exception-list-offset [] tib-temp tib-segment MOV ; -<< "vocab:cpu/x86/32/bootstrap.factor" parse-file suffix! >> -call +<< "vocab:cpu/x86/32/bootstrap.factor" parse-file suffix! >> call +<< "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >> call diff --git a/basis/cpu/x86/64/bootstrap.factor b/basis/cpu/x86/64/bootstrap.factor index 69734df225..68c3d8b702 100644 --- a/basis/cpu/x86/64/bootstrap.factor +++ b/basis/cpu/x86/64/bootstrap.factor @@ -26,11 +26,6 @@ IN: bootstrap.x86 : fixnum>slot@ ( -- ) temp0 1 SAR ; : rex-length ( -- n ) 1 ; -: jit-save-tib ( -- ) ; -: jit-restore-tib ( -- ) ; -: jit-update-tib ( ctx-reg -- ) drop ; -: jit-install-seh ( -- ) stack-reg bootstrap-cell ADD ; - : jit-call ( name -- ) RAX 0 MOV rc-absolute-cell jit-dlsym RAX CALL ; @@ -238,7 +233,9 @@ IN: bootstrap.x86 RSP ctx-reg context-callstack-top-offset [+] MOV ! Load new ds, rs registers - jit-restore-context ; + jit-restore-context + + ctx-reg jit-update-tib ; : jit-pop-context-and-param ( -- ) arg1 ds-reg [] MOV @@ -293,6 +290,3 @@ IN: bootstrap.x86 jit-delete-current-context jit-start-context ] \ (start-context-and-delete) define-sub-primitive - -<< "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >> -call diff --git a/basis/cpu/x86/64/unix/bootstrap.factor b/basis/cpu/x86/64/unix/bootstrap.factor index d19b5306a0..cffb12902c 100644 --- a/basis/cpu/x86/64/unix/bootstrap.factor +++ b/basis/cpu/x86/64/unix/bootstrap.factor @@ -12,5 +12,6 @@ IN: bootstrap.x86 : arg3 ( -- reg ) RDX ; : arg4 ( -- reg ) RCX ; -<< "vocab:cpu/x86/64/bootstrap.factor" parse-file suffix! >> -call +<< "vocab:cpu/x86/unix/bootstrap.factor" parse-file suffix! >> call +<< "vocab:cpu/x86/64/bootstrap.factor" parse-file suffix! >> call +<< "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >> call diff --git a/basis/cpu/x86/64/winnt/bootstrap.factor b/basis/cpu/x86/64/winnt/bootstrap.factor index 113a13918f..f816980e57 100644 --- a/basis/cpu/x86/64/winnt/bootstrap.factor +++ b/basis/cpu/x86/64/winnt/bootstrap.factor @@ -5,6 +5,8 @@ vocabs sequences cpu.x86.assembler parser cpu.x86.assembler.operands ; IN: bootstrap.x86 +DEFER: stack-reg + : stack-frame-size ( -- n ) 8 bootstrap-cells ; : nv-regs ( -- seq ) { RBX RSI RDI R12 R13 R14 R15 } ; : arg1 ( -- reg ) RCX ; @@ -12,5 +14,12 @@ IN: bootstrap.x86 : arg3 ( -- reg ) R8 ; : arg4 ( -- reg ) R9 ; -<< "vocab:cpu/x86/64/bootstrap.factor" parse-file suffix! >> -call +: tib-segment ( -- ) GS ; +: tib-temp ( -- reg ) R11 ; + +: jit-install-seh ( -- ) stack-reg bootstrap-cell ADD ; +: jit-update-seh ( ctx-reg -- ) drop ; + +<< "vocab:cpu/x86/winnt/bootstrap.factor" parse-file suffix! >> call +<< "vocab:cpu/x86/64/bootstrap.factor" parse-file suffix! >> call +<< "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >> call diff --git a/basis/cpu/x86/unix/bootstrap.factor b/basis/cpu/x86/unix/bootstrap.factor new file mode 100644 index 0000000000..20dd738ac6 --- /dev/null +++ b/basis/cpu/x86/unix/bootstrap.factor @@ -0,0 +1,13 @@ +! Copyright (C) 2010 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: cpu.x86.assembler cpu.x86.assembler.operands kernel +layouts ; +IN: bootstrap.x86 + +DEFER: stack-reg + +: jit-save-tib ( -- ) ; +: jit-restore-tib ( -- ) ; +: jit-update-tib ( ctx-reg -- ) drop ; +: jit-install-seh ( -- ) stack-reg bootstrap-cell ADD ; +: jit-update-seh ( ctx-reg -- ) drop ; diff --git a/basis/cpu/x86/winnt/bootstrap.factor b/basis/cpu/x86/winnt/bootstrap.factor new file mode 100644 index 0000000000..b81c1eb604 --- /dev/null +++ b/basis/cpu/x86/winnt/bootstrap.factor @@ -0,0 +1,32 @@ +! Copyright (C) 2010 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: bootstrap.image.private compiler.constants +cpu.x86.assembler cpu.x86.assembler.operands kernel layouts +locals parser sequences ; +IN: bootstrap.x86 + +: tib-exception-list-offset ( -- n ) 0 bootstrap-cells ; +: tib-stack-base-offset ( -- n ) 1 bootstrap-cells ; +: tib-stack-limit-offset ( -- n ) 2 bootstrap-cells ; + +: jit-save-tib ( -- ) + tib-exception-list-offset [] tib-segment PUSH + tib-stack-base-offset [] tib-segment PUSH + tib-stack-limit-offset [] tib-segment PUSH ; + +: jit-restore-tib ( -- ) + tib-stack-limit-offset [] tib-segment POP + tib-stack-base-offset [] tib-segment POP + tib-exception-list-offset [] tib-segment POP ; + +:: jit-update-tib ( ctx-reg -- ) + ! There's a redundant load here because we're not allowed + ! to clobber ctx-reg. Clobbers tib-temp. + ! Save callstack base in TIB + tib-temp ctx-reg context-callstack-seg-offset [+] MOV + tib-temp tib-temp segment-end-offset [+] MOV + tib-stack-base-offset [] tib-temp tib-segment MOV + ! Save callstack limit in TIB + tib-temp ctx-reg context-callstack-seg-offset [+] MOV + tib-temp tib-temp segment-start-offset [+] MOV + tib-stack-limit-offset [] tib-temp tib-segment MOV ; From 2a2d9eb0a223b91cbdeb2633cdc2301934211aa2 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Tue, 6 Apr 2010 02:44:57 -0700 Subject: [PATCH 594/713] Mach-O FFI constants and data structures. --- extra/macho/authors.txt | 1 + extra/macho/macho.factor | 810 +++++++++++++++++++++++++++++++++++++++ extra/macho/summary.txt | 1 + 3 files changed, 812 insertions(+) create mode 100644 extra/macho/authors.txt create mode 100644 extra/macho/macho.factor create mode 100644 extra/macho/summary.txt diff --git a/extra/macho/authors.txt b/extra/macho/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/extra/macho/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/extra/macho/macho.factor b/extra/macho/macho.factor new file mode 100644 index 0000000000..fbccab35a4 --- /dev/null +++ b/extra/macho/macho.factor @@ -0,0 +1,810 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http:// factorcode.org/license.txt for BSD license. +USING: alien.c-types alien.syntax classes.struct kernel literals math +unix.types ; +IN: macho + +TYPEDEF: int integer_t +TYPEDEF: int vm_prot_t +TYPEDEF: integer_t cpu_type_t +TYPEDEF: integer_t cpu_subtype_t +TYPEDEF: integer_t cpu_threadtype_t + +CONSTANT: VM_PROT_NONE HEX: 00 +CONSTANT: VM_PROT_READ HEX: 01 +CONSTANT: VM_PROT_WRITE HEX: 02 +CONSTANT: VM_PROT_EXECUTE HEX: 04 +CONSTANT: VM_PROT_DEFAULT HEX: 03 +CONSTANT: VM_PROT_ALL HEX: 07 +CONSTANT: VM_PROT_NO_CHANGE HEX: 08 +CONSTANT: VM_PROT_COPY HEX: 10 +CONSTANT: VM_PROT_WANTS_COPY HEX: 10 + +! loader.h +STRUCT: mach_header + { magic uint32_t } + { cputype cpu_type_t } + { cpusubtype cpu_subtype_t } + { filetype uint32_t } + { ncmds uint32_t } + { sizeofcmds uint32_t } + { flags uint32_t } ; + +CONSTANT: MH_MAGIC HEX: feedface +CONSTANT: MH_CIGAM HEX: cefaedfe + +STRUCT: mach_header_64 + { magic uint32_t } + { cputype cpu_type_t } + { cpusubtype cpu_subtype_t } + { filetype uint32_t } + { ncmds uint32_t } + { sizeofcmds uint32_t } + { flags uint32_t } + { reserved uint32_t } ; + +CONSTANT: MH_MAGIC_64 HEX: feedfacf +CONSTANT: MH_CIGAM_64 HEX: cffaedfe + +CONSTANT: MH_OBJECT HEX: 1 +CONSTANT: MH_EXECUTE HEX: 2 +CONSTANT: MH_FVMLIB HEX: 3 +CONSTANT: MH_CORE HEX: 4 +CONSTANT: MH_PRELOAD HEX: 5 +CONSTANT: MH_DYLIB HEX: 6 +CONSTANT: MH_DYLINKER HEX: 7 +CONSTANT: MH_BUNDLE HEX: 8 +CONSTANT: MH_DYLIB_STUB HEX: 9 +CONSTANT: MH_DSYM HEX: a +CONSTANT: MH_KEXT_BUNDLE HEX: b + +CONSTANT: MH_NOUNDEFS HEX: 1 +CONSTANT: MH_INCRLINK HEX: 2 +CONSTANT: MH_DYLDLINK HEX: 4 +CONSTANT: MH_BINDATLOAD HEX: 8 +CONSTANT: MH_PREBOUND HEX: 10 +CONSTANT: MH_SPLIT_SEGS HEX: 20 +CONSTANT: MH_LAZY_INIT HEX: 40 +CONSTANT: MH_TWOLEVEL HEX: 80 +CONSTANT: MH_FORCE_FLAT HEX: 100 +CONSTANT: MH_NOMULTIDEFS HEX: 200 +CONSTANT: MH_NOFIXPREBINDING HEX: 400 +CONSTANT: MH_PREBINDABLE HEX: 800 +CONSTANT: MH_ALLMODSBOUND HEX: 1000 +CONSTANT: MH_SUBSECTIONS_VIA_SYMBOLS HEX: 2000 +CONSTANT: MH_CANONICAL HEX: 4000 +CONSTANT: MH_WEAK_DEFINES HEX: 8000 +CONSTANT: MH_BINDS_TO_WEAK HEX: 10000 +CONSTANT: MH_ALLOW_STACK_EXECUTION HEX: 20000 +CONSTANT: MH_DEAD_STRIPPABLE_DYLIB HEX: 400000 +CONSTANT: MH_ROOT_SAFE HEX: 40000 +CONSTANT: MH_SETUID_SAFE HEX: 80000 +CONSTANT: MH_NO_REEXPORTED_DYLIBS HEX: 100000 +CONSTANT: MH_PIE HEX: 200000 + +STRUCT: load_command + { cmd uint32_t } + { cmdsize uint32_t } ; + +CONSTANT: LC_REQ_DYLD HEX: 80000000 + +CONSTANT: LC_SEGMENT HEX: 1 +CONSTANT: LC_SYMTAB HEX: 2 +CONSTANT: LC_SYMSEG HEX: 3 +CONSTANT: LC_THREAD HEX: 4 +CONSTANT: LC_UNIXTHREAD HEX: 5 +CONSTANT: LC_LOADFVMLIB HEX: 6 +CONSTANT: LC_IDFVMLIB HEX: 7 +CONSTANT: LC_IDENT HEX: 8 +CONSTANT: LC_FVMFILE HEX: 9 +CONSTANT: LC_PREPAGE HEX: a +CONSTANT: LC_DYSYMTAB HEX: b +CONSTANT: LC_LOAD_DYLIB HEX: c +CONSTANT: LC_ID_DYLIB HEX: d +CONSTANT: LC_LOAD_DYLINKER HEX: e +CONSTANT: LC_ID_DYLINKER HEX: f +CONSTANT: LC_PREBOUND_DYLIB HEX: 10 +CONSTANT: LC_ROUTINES HEX: 11 +CONSTANT: LC_SUB_FRAMEWORK HEX: 12 +CONSTANT: LC_SUB_UMBRELLA HEX: 13 +CONSTANT: LC_SUB_CLIENT HEX: 14 +CONSTANT: LC_SUB_LIBRARY HEX: 15 +CONSTANT: LC_TWOLEVEL_HINTS HEX: 16 +CONSTANT: LC_PREBIND_CKSUM HEX: 17 +CONSTANT: LC_LOAD_WEAK_DYLIB HEX: 80000018 +CONSTANT: LC_SEGMENT_64 HEX: 19 +CONSTANT: LC_ROUTINES_64 HEX: 1a +CONSTANT: LC_UUID HEX: 1b +CONSTANT: LC_RPATH HEX: 8000001c +CONSTANT: LC_CODE_SIGNATURE HEX: 1d +CONSTANT: LC_SEGMENT_SPLIT_INFO HEX: 1e +CONSTANT: LC_REEXPORT_DYLIB HEX: 8000001f +CONSTANT: LC_LAZY_LOAD_DYLIB HEX: 20 +CONSTANT: LC_ENCRYPTION_INFO HEX: 21 +CONSTANT: LC_DYLD_INFO HEX: 22 +CONSTANT: LC_DYLD_INFO_ONLY HEX: 80000022 + +UNION-STRUCT: lc_str + { offset uint32_t } + { ptr char* } ; + +STRUCT: segment_command + { cmd uint32_t } + { cmdsize uint32_t } + { segname char[16] } + { vmaddr uint32_t } + { vmsize uint32_t } + { fileoff uint32_t } + { filesize uint32_t } + { maxprot vm_prot_t } + { initprot vm_prot_t } + { nsects uint32_t } + { flags uint32_t } ; + +STRUCT: segment_command_64 + { cmd uint32_t } + { cmdsize uint32_t } + { segname char[16] } + { vmaddr uint64_t } + { vmsize uint64_t } + { fileoff uint64_t } + { filesize uint64_t } + { maxprot vm_prot_t } + { initprot vm_prot_t } + { nsects uint32_t } + { flags uint32_t } ; + +CONSTANT: SG_HIGHVM HEX: 1 +CONSTANT: SG_FVMLIB HEX: 2 +CONSTANT: SG_NORELOC HEX: 4 +CONSTANT: SG_PROTECTED_VERSION_1 HEX: 8 + +STRUCT: section + { sectname char[16] } + { segname char[16] } + { addr uint32_t } + { size uint32_t } + { offset uint32_t } + { align uint32_t } + { reloff uint32_t } + { nreloc uint32_t } + { flags uint32_t } + { reserved1 uint32_t } + { reserved2 uint32_t } ; + +STRUCT: section_64 + { sectname char[16] } + { segname char[16] } + { addr uint64_t } + { size uint64_t } + { offset uint32_t } + { align uint32_t } + { reloff uint32_t } + { nreloc uint32_t } + { flags uint32_t } + { reserved1 uint32_t } + { reserved2 uint32_t } + { reserved3 uint32_t } ; + +CONSTANT: SECTION_TYPE HEX: 000000ff +CONSTANT: SECTION_ATTRIBUTES HEX: ffffff00 + +CONSTANT: S_REGULAR HEX: 0 +CONSTANT: S_ZEROFILL HEX: 1 +CONSTANT: S_CSTRING_LITERALS HEX: 2 +CONSTANT: S_4BYTE_LITERALS HEX: 3 +CONSTANT: S_8BYTE_LITERALS HEX: 4 +CONSTANT: S_LITERAL_POINTERS HEX: 5 +CONSTANT: S_NON_LAZY_SYMBOL_POINTERS HEX: 6 +CONSTANT: S_LAZY_SYMBOL_POINTERS HEX: 7 +CONSTANT: S_SYMBOL_STUBS HEX: 8 +CONSTANT: S_MOD_INIT_FUNC_POINTERS HEX: 9 +CONSTANT: S_MOD_TERM_FUNC_POINTERS HEX: a +CONSTANT: S_COALESCED HEX: b +CONSTANT: S_GB_ZEROFILL HEX: c +CONSTANT: S_INTERPOSING HEX: d +CONSTANT: S_16BYTE_LITERALS HEX: e +CONSTANT: S_DTRACE_DOF HEX: f +CONSTANT: S_LAZY_DYLIB_SYMBOL_POINTERS HEX: 10 + +CONSTANT: SECTION_ATTRIBUTES_USR HEX: ff000000 +CONSTANT: S_ATTR_PURE_INSTRUCTIONS HEX: 80000000 +CONSTANT: S_ATTR_NO_TOC HEX: 40000000 +CONSTANT: S_ATTR_STRIP_STATIC_SYMS HEX: 20000000 +CONSTANT: S_ATTR_NO_DEAD_STRIP HEX: 10000000 +CONSTANT: S_ATTR_LIVE_SUPPORT HEX: 08000000 +CONSTANT: S_ATTR_SELF_MODIFYING_CODE HEX: 04000000 +CONSTANT: S_ATTR_DEBUG HEX: 02000000 +CONSTANT: SECTION_ATTRIBUTES_SYS HEX: 00ffff00 +CONSTANT: S_ATTR_SOME_INSTRUCTIONS HEX: 00000400 +CONSTANT: S_ATTR_EXT_RELOC HEX: 00000200 +CONSTANT: S_ATTR_LOC_RELOC HEX: 00000100 + +CONSTANT: SEG_PAGEZERO "__PAGEZERO" +CONSTANT: SEG_TEXT "__TEXT" +CONSTANT: SECT_TEXT "__text" +CONSTANT: SECT_FVMLIB_INIT0 "__fvmlib_init0" +CONSTANT: SECT_FVMLIB_INIT1 "__fvmlib_init1" +CONSTANT: SEG_DATA "__DATA" +CONSTANT: SECT_DATA "__data" +CONSTANT: SECT_BSS "__bss" +CONSTANT: SECT_COMMON "__common" +CONSTANT: SEG_OBJC "__OBJC" +CONSTANT: SECT_OBJC_SYMBOLS "__symbol_table" +CONSTANT: SECT_OBJC_MODULES "__module_info" +CONSTANT: SECT_OBJC_STRINGS "__selector_strs" +CONSTANT: SECT_OBJC_REFS "__selector_refs" +CONSTANT: SEG_ICON "__ICON" +CONSTANT: SECT_ICON_HEADER "__header" +CONSTANT: SECT_ICON_TIFF "__tiff" +CONSTANT: SEG_LINKEDIT "__LINKEDIT" +CONSTANT: SEG_UNIXSTACK "__UNIXSTACK" +CONSTANT: SEG_IMPORT "__IMPORT" + +STRUCT: fvmlib + { name lc_str } + { minor_version uint32_t } + { header_addr uint32_t } ; + +STRUCT: fvmlib_command + { cmd uint32_t } + { cmdsize uint32_t } + { fvmlib fvmlib } ; + +STRUCT: dylib + { name lc_str } + { timestamp uint32_t } + { current_version uint32_t } + { compatibility_version uint32_t } ; + +STRUCT: dylib_command + { cmd uint32_t } + { cmdsize uint32_t } + { dylib dylib } ; + +STRUCT: sub_framework_command + { cmd uint32_t } + { cmdsize uint32_t } + { umbrella lc_str } ; + +STRUCT: sub_client_command + { cmd uint32_t } + { cmdsize uint32_t } + { client lc_str } ; + +STRUCT: sub_umbrella_command + { cmd uint32_t } + { cmdsize uint32_t } + { sub_umbrella lc_str } ; + +STRUCT: sub_library_command + { cmd uint32_t } + { cmdsize uint32_t } + { sub_library lc_str } ; + +STRUCT: prebound_dylib_command + { cmd uint32_t } + { cmdsize uint32_t } + { name lc_str } + { nmodules uint32_t } + { linked_modules lc_str } ; + +STRUCT: dylinker_command + { cmd uint32_t } + { cmdsize uint32_t } + { name lc_str } ; + +STRUCT: thread_command + { cmd uint32_t } + { cmdsize uint32_t } ; + +STRUCT: routines_command + { cmd uint32_t } + { cmdsize uint32_t } + { init_address uint32_t } + { init_module uint32_t } + { reserved1 uint32_t } + { reserved2 uint32_t } + { reserved3 uint32_t } + { reserved4 uint32_t } + { reserved5 uint32_t } + { reserved6 uint32_t } ; + +STRUCT: routines_command_64 + { cmd uint32_t } + { cmdsize uint32_t } + { init_address uint64_t } + { init_module uint64_t } + { reserved1 uint64_t } + { reserved2 uint64_t } + { reserved3 uint64_t } + { reserved4 uint64_t } + { reserved5 uint64_t } + { reserved6 uint64_t } ; + +STRUCT: symtab_command + { cmd uint32_t } + { cmdsize uint32_t } + { symoff uint32_t } + { nsyms uint32_t } + { stroff uint32_t } + { strsize uint32_t } ; + +STRUCT: dysymtab_command + { cmd uint32_t } + { cmdsize uint32_t } + { ilocalsym uint32_t } + { nlocalsym uint32_t } + { iextdefsym uint32_t } + { nextdefsym uint32_t } + { iundefsym uint32_t } + { nundefsym uint32_t } + { tocoff uint32_t } + { ntoc uint32_t } + { modtaboff uint32_t } + { nmodtab uint32_t } + { extrefsymoff uint32_t } + { nextrefsyms uint32_t } + { indirectsymoff uint32_t } + { nindirectsyms uint32_t } + { extreloff uint32_t } + { nextrel uint32_t } + { locreloff uint32_t } + { nlocrel uint32_t } ; + +CONSTANT: INDIRECT_SYMBOL_LOCAL HEX: 80000000 +CONSTANT: INDIRECT_SYMBOL_ABS HEX: 40000000 + +STRUCT: dylib_table_of_contents + { symbol_index uint32_t } + { module_index uint32_t } ; + +STRUCT: dylib_module + { module_name uint32_t } + { iextdefsym uint32_t } + { nextdefsym uint32_t } + { irefsym uint32_t } + { nrefsym uint32_t } + { ilocalsym uint32_t } + { nlocalsym uint32_t } + { iextrel uint32_t } + { nextrel uint32_t } + { iinit_iterm uint32_t } + { ninit_nterm uint32_t } + { objc_module_info_addr uint32_t } + { objc_module_info_size uint32_t } ; + +STRUCT: dylib_module_64 + { module_name uint32_t } + { iextdefsym uint32_t } + { nextdefsym uint32_t } + { irefsym uint32_t } + { nrefsym uint32_t } + { ilocalsym uint32_t } + { nlocalsym uint32_t } + { iextrel uint32_t } + { nextrel uint32_t } + { iinit_iterm uint32_t } + { ninit_nterm uint32_t } + { objc_module_info_size uint32_t } + { objc_module_info_addr uint64_t } ; + +STRUCT: dylib_reference + { isym_flags uint32_t } ; + +STRUCT: twolevel_hints_command + { cmd uint32_t } + { cmdsize uint32_t } + { offset uint32_t } + { nhints uint32_t } ; + +STRUCT: twolevel_hint + { isub_image_itoc uint32_t } ; + +STRUCT: prebind_cksum_command + { cmd uint32_t } + { cmdsize uint32_t } + { cksum uint32_t } ; + +STRUCT: uuid_command + { cmd uint32_t } + { cmdsize uint32_t } + { uuid uint8_t[16] } ; + +STRUCT: rpath_command + { cmd uint32_t } + { cmdsize uint32_t } + { path lc_str } ; + +STRUCT: linkedit_data_command + { cmd uint32_t } + { cmdsize uint32_t } + { dataoff uint32_t } + { datasize uint32_t } ; + +STRUCT: encryption_info_command + { cmd uint32_t } + { cmdsize uint32_t } + { cryptoff uint32_t } + { cryptsize uint32_t } + { cryptid uint32_t } ; + +STRUCT: dyld_info_command + { cmd uint32_t } + { cmdsize uint32_t } + { rebase_off uint32_t } + { rebase_size uint32_t } + { bind_off uint32_t } + { bind_size uint32_t } + { weak_bind_off uint32_t } + { weak_bind_size uint32_t } + { lazy_bind_off uint32_t } + { lazy_bind_size uint32_t } + { export_off uint32_t } + { export_size uint32_t } ; + +CONSTANT: REBASE_TYPE_POINTER 1 +CONSTANT: REBASE_TYPE_TEXT_ABSOLUTE32 2 +CONSTANT: REBASE_TYPE_TEXT_PCREL32 3 + +CONSTANT: REBASE_OPCODE_MASK HEX: F0 +CONSTANT: REBASE_IMMEDIATE_MASK HEX: 0F +CONSTANT: REBASE_OPCODE_DONE HEX: 00 +CONSTANT: REBASE_OPCODE_SET_TYPE_IMM HEX: 10 +CONSTANT: REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB HEX: 20 +CONSTANT: REBASE_OPCODE_ADD_ADDR_ULEB HEX: 30 +CONSTANT: REBASE_OPCODE_ADD_ADDR_IMM_SCALED HEX: 40 +CONSTANT: REBASE_OPCODE_DO_REBASE_IMM_TIMES HEX: 50 +CONSTANT: REBASE_OPCODE_DO_REBASE_ULEB_TIMES HEX: 60 +CONSTANT: REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB HEX: 70 +CONSTANT: REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB HEX: 80 + +CONSTANT: BIND_TYPE_POINTER 1 +CONSTANT: BIND_TYPE_TEXT_ABSOLUTE32 2 +CONSTANT: BIND_TYPE_TEXT_PCREL32 3 + +CONSTANT: BIND_SPECIAL_DYLIB_SELF 0 +CONSTANT: BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE -1 +CONSTANT: BIND_SPECIAL_DYLIB_FLAT_LOOKUP -2 + +CONSTANT: BIND_SYMBOL_FLAGS_WEAK_IMPORT HEX: 1 +CONSTANT: BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION HEX: 8 + +CONSTANT: BIND_OPCODE_MASK HEX: F0 +CONSTANT: BIND_IMMEDIATE_MASK HEX: 0F +CONSTANT: BIND_OPCODE_DONE HEX: 00 +CONSTANT: BIND_OPCODE_SET_DYLIB_ORDINAL_IMM HEX: 10 +CONSTANT: BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB HEX: 20 +CONSTANT: BIND_OPCODE_SET_DYLIB_SPECIAL_IMM HEX: 30 +CONSTANT: BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM HEX: 40 +CONSTANT: BIND_OPCODE_SET_TYPE_IMM HEX: 50 +CONSTANT: BIND_OPCODE_SET_ADDEND_SLEB HEX: 60 +CONSTANT: BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB HEX: 70 +CONSTANT: BIND_OPCODE_ADD_ADDR_ULEB HEX: 80 +CONSTANT: BIND_OPCODE_DO_BIND HEX: 90 +CONSTANT: BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB HEX: A0 +CONSTANT: BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED HEX: B0 +CONSTANT: BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB HEX: C0 + +CONSTANT: EXPORT_SYMBOL_FLAGS_KIND_MASK HEX: 03 +CONSTANT: EXPORT_SYMBOL_FLAGS_KIND_REGULAR HEX: 00 +CONSTANT: EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL HEX: 01 +CONSTANT: EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION HEX: 04 +CONSTANT: EXPORT_SYMBOL_FLAGS_INDIRECT_DEFINITION HEX: 08 +CONSTANT: EXPORT_SYMBOL_FLAGS_HAS_SPECIALIZATIONS HEX: 10 + +STRUCT: symseg_command + { cmd uint32_t } + { cmdsize uint32_t } + { offset uint32_t } + { size uint32_t } ; + +STRUCT: ident_command + { cmd uint32_t } + { cmdsize uint32_t } ; + +STRUCT: fvmfile_command + { cmd uint32_t } + { cmdsize uint32_t } + { name lc_str } + { header_addr uint32_t } ; + +! machine.h +CONSTANT: CPU_STATE_MAX 4 +CONSTANT: CPU_STATE_USER 0 +CONSTANT: CPU_STATE_SYSTEM 1 +CONSTANT: CPU_STATE_IDLE 2 +CONSTANT: CPU_STATE_NICE 3 + +CONSTANT: CPU_ARCH_MASK HEX: ff000000 +CONSTANT: CPU_ARCH_ABI64 HEX: 01000000 + +CONSTANT: CPU_TYPE_ANY -1 +CONSTANT: CPU_TYPE_VAX 1 +CONSTANT: CPU_TYPE_MC680x0 6 +CONSTANT: CPU_TYPE_X86 7 +CONSTANT: CPU_TYPE_I386 $ CPU_TYPE_X86 +CONSTANT: CPU_TYPE_X86_64 $[ CPU_TYPE_X86 CPU_ARCH_ABI64 bitor ] +CONSTANT: CPU_TYPE_MC98000 10 +CONSTANT: CPU_TYPE_HPPA 11 +CONSTANT: CPU_TYPE_ARM 12 +CONSTANT: CPU_TYPE_MC88000 13 +CONSTANT: CPU_TYPE_SPARC 14 +CONSTANT: CPU_TYPE_I860 15 +CONSTANT: CPU_TYPE_POWERPC 18 +CONSTANT: CPU_TYPE_POWERPC64 $[ $ CPU_TYPE_POWERPC CPU_ARCH_ABI64 bitor ] + +CONSTANT: CPU_SUBTYPE_MASK HEX: ff000000 +CONSTANT: CPU_SUBTYPE_LIB64 HEX: 80000000 + +CONSTANT: CPU_SUBTYPE_MULTIPLE -1 +CONSTANT: CPU_SUBTYPE_LITTLE_ENDIAN 0 +CONSTANT: CPU_SUBTYPE_BIG_ENDIAN 1 + +CONSTANT: CPU_THREADTYPE_NONE 0 + +CONSTANT: CPU_SUBTYPE_VAX_ALL 0 +CONSTANT: CPU_SUBTYPE_VAX780 1 +CONSTANT: CPU_SUBTYPE_VAX785 2 +CONSTANT: CPU_SUBTYPE_VAX750 3 +CONSTANT: CPU_SUBTYPE_VAX730 4 +CONSTANT: CPU_SUBTYPE_UVAXI 5 +CONSTANT: CPU_SUBTYPE_UVAXII 6 +CONSTANT: CPU_SUBTYPE_VAX8200 7 +CONSTANT: CPU_SUBTYPE_VAX8500 8 +CONSTANT: CPU_SUBTYPE_VAX8600 9 +CONSTANT: CPU_SUBTYPE_VAX8650 10 +CONSTANT: CPU_SUBTYPE_VAX8800 11 +CONSTANT: CPU_SUBTYPE_UVAXIII 12 + +CONSTANT: CPU_SUBTYPE_MC680x0_ALL 1 +CONSTANT: CPU_SUBTYPE_MC68030 1 +CONSTANT: CPU_SUBTYPE_MC68040 2 +CONSTANT: CPU_SUBTYPE_MC68030_ONLY 3 + +: CPU_SUBTYPE_INTEL ( f m -- subtype ) 4 shift + ; inline + +CONSTANT: CPU_SUBTYPE_I386_ALL 3 +CONSTANT: CPU_SUBTYPE_386 3 +CONSTANT: CPU_SUBTYPE_486 4 +CONSTANT: CPU_SUBTYPE_486SX 132 +CONSTANT: CPU_SUBTYPE_586 5 +CONSTANT: CPU_SUBTYPE_PENT 5 +CONSTANT: CPU_SUBTYPE_PENTPRO 22 +CONSTANT: CPU_SUBTYPE_PENTII_M3 54 +CONSTANT: CPU_SUBTYPE_PENTII_M5 86 +CONSTANT: CPU_SUBTYPE_CELERON 103 +CONSTANT: CPU_SUBTYPE_CELERON_MOBILE 119 +CONSTANT: CPU_SUBTYPE_PENTIUM_3 8 +CONSTANT: CPU_SUBTYPE_PENTIUM_3_M 24 +CONSTANT: CPU_SUBTYPE_PENTIUM_3_XEON 40 +CONSTANT: CPU_SUBTYPE_PENTIUM_M 9 +CONSTANT: CPU_SUBTYPE_PENTIUM_4 10 +CONSTANT: CPU_SUBTYPE_PENTIUM_4_M 26 +CONSTANT: CPU_SUBTYPE_ITANIUM 11 +CONSTANT: CPU_SUBTYPE_ITANIUM_2 27 +CONSTANT: CPU_SUBTYPE_XEON 12 +CONSTANT: CPU_SUBTYPE_XEON_MP 28 + +: CPU_SUBTYPE_INTEL_FAMILY ( x -- family ) 15 bitand ; inline + +CONSTANT: CPU_SUBTYPE_INTEL_FAMILY_MAX 15 + +: CPU_SUBTYPE_INTEL_MODEL ( x -- model ) -4 shift ; inline + +CONSTANT: CPU_SUBTYPE_INTEL_MODEL_ALL 0 +CONSTANT: CPU_SUBTYPE_X86_ALL 3 +CONSTANT: CPU_SUBTYPE_X86_64_ALL 3 +CONSTANT: CPU_SUBTYPE_X86_ARCH1 4 +CONSTANT: CPU_THREADTYPE_INTEL_HTT 1 + +CONSTANT: CPU_SUBTYPE_MIPS_ALL 0 +CONSTANT: CPU_SUBTYPE_MIPS_R2300 1 +CONSTANT: CPU_SUBTYPE_MIPS_R2600 2 +CONSTANT: CPU_SUBTYPE_MIPS_R2800 3 +CONSTANT: CPU_SUBTYPE_MIPS_R2000a 4 +CONSTANT: CPU_SUBTYPE_MIPS_R2000 5 +CONSTANT: CPU_SUBTYPE_MIPS_R3000a 6 +CONSTANT: CPU_SUBTYPE_MIPS_R3000 7 + +CONSTANT: CPU_SUBTYPE_MC98000_ALL 0 +CONSTANT: CPU_SUBTYPE_MC98601 1 + +CONSTANT: CPU_SUBTYPE_HPPA_ALL 0 +CONSTANT: CPU_SUBTYPE_HPPA_7100 0 +CONSTANT: CPU_SUBTYPE_HPPA_7100LC 1 + +CONSTANT: CPU_SUBTYPE_MC88000_ALL 0 +CONSTANT: CPU_SUBTYPE_MC88100 1 +CONSTANT: CPU_SUBTYPE_MC88110 2 + +CONSTANT: CPU_SUBTYPE_SPARC_ALL 0 + +CONSTANT: CPU_SUBTYPE_I860_ALL 0 +CONSTANT: CPU_SUBTYPE_I860_860 1 + +CONSTANT: CPU_SUBTYPE_POWERPC_ALL 0 +CONSTANT: CPU_SUBTYPE_POWERPC_601 1 +CONSTANT: CPU_SUBTYPE_POWERPC_602 2 +CONSTANT: CPU_SUBTYPE_POWERPC_603 3 +CONSTANT: CPU_SUBTYPE_POWERPC_603e 4 +CONSTANT: CPU_SUBTYPE_POWERPC_603ev 5 +CONSTANT: CPU_SUBTYPE_POWERPC_604 6 +CONSTANT: CPU_SUBTYPE_POWERPC_604e 7 +CONSTANT: CPU_SUBTYPE_POWERPC_620 8 +CONSTANT: CPU_SUBTYPE_POWERPC_750 9 +CONSTANT: CPU_SUBTYPE_POWERPC_7400 10 +CONSTANT: CPU_SUBTYPE_POWERPC_7450 11 +CONSTANT: CPU_SUBTYPE_POWERPC_970 100 + +CONSTANT: CPU_SUBTYPE_ARM_ALL 0 +CONSTANT: CPU_SUBTYPE_ARM_V4T 5 +CONSTANT: CPU_SUBTYPE_ARM_V6 6 +CONSTANT: CPU_SUBTYPE_ARM_V5TEJ 7 +CONSTANT: CPU_SUBTYPE_ARM_XSCALE 8 +CONSTANT: CPU_SUBTYPE_ARM_V7 9 + +CONSTANT: CPUFAMILY_UNKNOWN 0 +CONSTANT: CPUFAMILY_POWERPC_G3 HEX: cee41549 +CONSTANT: CPUFAMILY_POWERPC_G4 HEX: 77c184ae +CONSTANT: CPUFAMILY_POWERPC_G5 HEX: ed76d8aa +CONSTANT: CPUFAMILY_INTEL_6_13 HEX: aa33392b +CONSTANT: CPUFAMILY_INTEL_6_14 HEX: 73d67300 +CONSTANT: CPUFAMILY_INTEL_6_15 HEX: 426f69ef +CONSTANT: CPUFAMILY_INTEL_6_23 HEX: 78ea4fbc +CONSTANT: CPUFAMILY_INTEL_6_26 HEX: 6b5a4cd2 +CONSTANT: CPUFAMILY_ARM_9 HEX: e73283ae +CONSTANT: CPUFAMILY_ARM_11 HEX: 8ff620d8 +CONSTANT: CPUFAMILY_ARM_XSCALE HEX: 53b005f5 +CONSTANT: CPUFAMILY_ARM_13 HEX: 0cc90e64 + +CONSTANT: CPUFAMILY_INTEL_YONAH $ CPUFAMILY_INTEL_6_14 +CONSTANT: CPUFAMILY_INTEL_MEROM $ CPUFAMILY_INTEL_6_15 +CONSTANT: CPUFAMILY_INTEL_PENRYN $ CPUFAMILY_INTEL_6_23 +CONSTANT: CPUFAMILY_INTEL_NEHALEM $ CPUFAMILY_INTEL_6_26 + +CONSTANT: CPUFAMILY_INTEL_CORE $ CPUFAMILY_INTEL_6_14 +CONSTANT: CPUFAMILY_INTEL_CORE2 $ CPUFAMILY_INTEL_6_15 + +! fat.h +CONSTANT: FAT_MAGIC HEX: cafebabe +CONSTANT: FAT_CIGAM HEX: bebafeca + +STRUCT: fat_header + { magic uint32_t } + { nfat_arch uint32_t } ; + +STRUCT: fat_arch + { cputype cpu_type_t } + { cpusubtype cpu_subtype_t } + { offset uint32_t } + { size uint32_t } + { align uint32_t } ; + +! nlist.h +STRUCT: nlist + { n_strx int32_t } + { n_type uint8_t } + { n_sect uint8_t } + { n_desc int16_t } + { n_value uint32_t } ; + +STRUCT: nlist_64 + { n_strx uint32_t } + { n_type uint8_t } + { n_sect uint8_t } + { n_desc uint16_t } + { n_value uint64_t } ; + +CONSTANT: N_STAB HEX: e0 +CONSTANT: N_PEXT HEX: 10 +CONSTANT: N_TYPE HEX: 0e +CONSTANT: N_EXT HEX: 01 + +CONSTANT: N_UNDF HEX: 0 +CONSTANT: N_ABS HEX: 2 +CONSTANT: N_SECT HEX: e +CONSTANT: N_PBUD HEX: c +CONSTANT: N_INDR HEX: a + +CONSTANT: NO_SECT 0 +CONSTANT: MAX_SECT 255 + +: GET_COMM_ALIGN ( n_desc -- align ) + -8 shift HEX: 0f bitand ; inline + +: SET_COMM_ALIGN ( n_desc align -- n_desc ) + [ HEX: f0ff bitand ] + [ HEX: 000f bitand 8 shift ] bi* bitor ; inline + +CONSTANT: REFERENCE_TYPE 7 +CONSTANT: REFERENCE_FLAG_UNDEFINED_NON_LAZY 0 +CONSTANT: REFERENCE_FLAG_UNDEFINED_LAZY 1 +CONSTANT: REFERENCE_FLAG_DEFINED 2 +CONSTANT: REFERENCE_FLAG_PRIVATE_DEFINED 3 +CONSTANT: REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY 4 +CONSTANT: REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY 5 + +CONSTANT: REFERENCED_DYNAMICALLY HEX: 0010 + +: GET_LIBRARY_ORDINAL ( n_desc -- ordinal ) + -8 shift HEX: ff bitand ; inline + +: SET_LIBRARY_ORDINAL ( n_desc ordinal -- n_desc ) + [ HEX: 00ff bitand ] + [ HEX: 00ff bitand 8 shift ] bi* bitor ; inline + +CONSTANT: SELF_LIBRARY_ORDINAL HEX: 0 +CONSTANT: MAX_LIBRARY_ORDINAL HEX: fd +CONSTANT: DYNAMIC_LOOKUP_ORDINAL HEX: fe +CONSTANT: EXECUTABLE_ORDINAL HEX: ff + +CONSTANT: N_NO_DEAD_STRIP HEX: 0020 +CONSTANT: N_DESC_DISCARDED HEX: 0020 +CONSTANT: N_WEAK_REF HEX: 0040 +CONSTANT: N_WEAK_DEF HEX: 0080 +CONSTANT: N_REF_TO_WEAK HEX: 0080 +CONSTANT: N_ARM_THUMB_DEF HEX: 0008 + +! ranlib.h +CONSTANT: SYMDEF "__.SYMDEF" +CONSTANT: SYMDEF_SORTED "__.SYMDEF SORTED" + +STRUCT: ranlib + { ran_strx uint32_t } + { ran_off uint32_t } ; + +! reloc.h +STRUCT: relocation_info + { r_address int32_t } + { r_symbolnum_pcrel_length_extern_type uint32_t } ; + +CONSTANT: R_ABS 0 +CONSTANT: R_SCATTERED HEX: 80000000 + +STRUCT: scattered_relocation_info_big_endian + { r_scattered_pcrel_length_type_address uint32_t } + { r_value int32_t } ; + +STRUCT: scattered_relocation_info_little_endian + { r_address_type_length_pcrel_scattered uint32_t } + { r_value int32_t } ; + +TYPEDEF: int reloc_type_generic +C-ENUM: + GENERIC_RELOC_VANILLA + GENERIC_RELOC_PAIR + GENERIC_RELOC_SECTDIFF + GENERIC_RELOC_PB_LA_PTR + GENERIC_RELOC_LOCAL_SECTDIFF ; + +TYPEDEF: int reloc_type_x86_64 +C-ENUM: + X86_64_RELOC_UNSIGNED + X86_64_RELOC_SIGNED + X86_64_RELOC_BRANCH + X86_64_RELOC_GOT_LOAD + X86_64_RELOC_GOT + X86_64_RELOC_SUBTRACTOR + X86_64_RELOC_SIGNED_1 + X86_64_RELOC_SIGNED_2 + X86_64_RELOC_SIGNED_4 ; + +TYPEDEF: int reloc_type_ppc +C-ENUM: + PPC_RELOC_VANILLA + PPC_RELOC_PAIR + PPC_RELOC_BR14 + PPC_RELOC_BR24 + PPC_RELOC_HI16 + PPC_RELOC_LO16 + PPC_RELOC_HA16 + PPC_RELOC_LO14 + PPC_RELOC_SECTDIFF + PPC_RELOC_PB_LA_PTR + PPC_RELOC_HI16_SECTDIFF + PPC_RELOC_LO16_SECTDIFF + PPC_RELOC_HA16_SECTDIFF + PPC_RELOC_JBSR + PPC_RELOC_LO14_SECTDIFF + PPC_RELOC_LOCAL_SECTDIFF ; diff --git a/extra/macho/summary.txt b/extra/macho/summary.txt new file mode 100644 index 0000000000..aaef27545c --- /dev/null +++ b/extra/macho/summary.txt @@ -0,0 +1 @@ +Constants and structs related to the Mach object format. From 4b78fe690beebbe39eae353f57231ae4a8dfb139 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Tue, 6 Apr 2010 02:46:23 -0700 Subject: [PATCH 595/713] Extend C-ENUM: to allow specifying the constant vvalues like in C. Add C-TYPED-ENUM: to automatically typedef a type. --- basis/alien/data/data-docs.factor | 2 +- basis/alien/syntax/syntax-docs.factor | 17 ++++++++++++++--- basis/alien/syntax/syntax.factor | 16 +++++++++++++--- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/basis/alien/data/data-docs.factor b/basis/alien/data/data-docs.factor index d36a4d5fd2..e34b1ba4fa 100644 --- a/basis/alien/data/data-docs.factor +++ b/basis/alien/data/data-docs.factor @@ -105,7 +105,7 @@ $nl "Important guidelines for passing data in byte arrays:" { $subsections "byte-arrays-gc" } "C-style enumerated types are supported:" -{ $subsections POSTPONE: C-ENUM: } +{ $subsections POSTPONE: C-ENUM: POSTPONE: C-TYPED-ENUM: } "C types can be aliased for convenience and consistency with native library documentation:" { $subsections POSTPONE: TYPEDEF: } "A utility for defining " { $link "destructors" } " for deallocating memory:" diff --git a/basis/alien/syntax/syntax-docs.factor b/basis/alien/syntax/syntax-docs.factor index 58b43cec31..2a8e1b2714 100644 --- a/basis/alien/syntax/syntax-docs.factor +++ b/basis/alien/syntax/syntax-docs.factor @@ -60,13 +60,24 @@ HELP: TYPEDEF: HELP: C-ENUM: { $syntax "C-ENUM: words... ;" } { $values { "words" "a sequence of word names" } } -{ $description "Creates a sequence of word definitions in the current vocabulary. Each word pushes an integer according to its index in the enumeration definition. The first word pushes 0." } +{ $description "Creates a sequence of word definitions in the current vocabulary. Each word pushes an integer according to the rules of C enums." } { $notes "This word emulates a C-style " { $snippet "enum" } " in Factor. While this feature can be used for any purpose, using integer constants is discouraged unless it is for interfacing with C libraries. Factor code should use " { $link "words.symbol" } " or " { $link "singletons" } " instead." } { $examples "Here is an example enumeration definition:" - { $code "C-ENUM: red green blue ;" } + { $code "C-ENUM: red { green 3 } blue ;" } "It is equivalent to the following series of definitions:" - { $code "CONSTANT: red 0" "CONSTANT: green 1" "CONSTANT: blue 2" } + { $code "CONSTANT: red 0" "CONSTANT: green 3" "CONSTANT: blue 4" } +} ; + +HELP: C-TYPED-ENUM: +{ $syntax "C-TYPED-ENUM: foo_t FOO BAR { BAZ 4 } BOL ;" } +{ $description "Typedefs the first word as an int and creates a sequence of word definitions in the current vocabulary. Each word pushes an integer according to the rules of C enums." } +{ $notes "This word emulates a C-style " { $snippet "enum" } " in Factor. While this feature can be used for any purpose, using integer constants is discouraged unless it is for interfacing with C libraries. Factor code should use " { $link "words.symbol" } " or " { $link "singletons" } " instead." } +{ $examples + "Here is an example enumeration definition:" + { $code "C-TYPED-ENUM: color_t red { green 3 } blue ;" } + "It is equivalent to the following series of definitions:" + { $code "TYPEDEF: int color_t" "CONSTANT: red 0" "CONSTANT: green 3" "CONSTANT: blue 4" } } ; HELP: C-TYPE: diff --git a/basis/alien/syntax/syntax.factor b/basis/alien/syntax/syntax.factor index 9eb8ca6287..f7cff225c5 100644 --- a/basis/alien/syntax/syntax.factor +++ b/basis/alien/syntax/syntax.factor @@ -24,9 +24,19 @@ SYNTAX: CALLBACK: SYNTAX: TYPEDEF: scan-c-type CREATE-C-TYPE dup save-location typedef ; -SYNTAX: C-ENUM: - ";" parse-tokens - [ [ create-in ] dip define-constant ] each-index ; +: define-enum-members ( counter -- ) + scan dup ";" = not [ + dup "{" = + [ 2drop scan create-in scan-word [ define-constant ] keep "}" expect ] + [ create-in swap [ define-constant ] keep ] + if 1 + define-enum-members + ] [ 2drop ] if ; + +SYNTAX: C-ENUM: 0 define-enum-members ; + +SYNTAX: C-TYPED-ENUM: + int CREATE-C-TYPE dup save-location typedef + 0 define-enum-members ; SYNTAX: C-TYPE: void CREATE-C-TYPE typedef ; From 26a55bbb16e9c8a74526a8f47f4a33c4cc3c763a Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Tue, 6 Apr 2010 12:58:37 -0700 Subject: [PATCH 596/713] Syntax highlighting for TYPED:: --- misc/fuel/fuel-syntax.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index d13a670df4..026a7738e0 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -118,7 +118,7 @@ (format "\\_<\\(%s\\)?: +\\_<\\(\\w+\\)\\_>" (regexp-opt '(":" "GENERIC" "DEFER" "HOOK" "MAIN" "MATH" "POSTPONE" - "SYMBOL" "SYNTAX" "TYPED" "RENAME")))) + "SYMBOL" "SYNTAX" "TYPED" "TYPED:" "RENAME")))) (defconst fuel-syntax--alias-definition-regex "^ALIAS: +\\(\\_<.+?\\_>\\) +\\(\\_<.+?\\_>\\)") From 669956032766a3dd3a3b6418d63e8bf1dff261db Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Tue, 6 Apr 2010 12:59:46 -0700 Subject: [PATCH 597/713] Helper words for ELF parsing --- extra/elf/elf.factor | 47 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/extra/elf/elf.factor b/extra/elf/elf.factor index 2ad82bc23c..539939856d 100644 --- a/extra/elf/elf.factor +++ b/extra/elf/elf.factor @@ -1,6 +1,8 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.syntax classes.struct ; +USING: accessors alien alien.c-types alien.strings alien.syntax arrays +classes.struct io.encodings.ascii kernel locals sequences +specialized-arrays strings typed ; IN: elf CONSTANT: EI_NIDENT 16 @@ -456,3 +458,46 @@ STRUCT: Elf32_Dyn STRUCT: Elf64_Dyn { d_tag Elf64_Sxword } { d_val Elf64_Xword } ; + +SPECIALIZED-ARRAYS: Elf32_Shdr Elf64_Shdr uchar ; +UNION: Elf32/64_Ehdr Elf32_Ehdr Elf64_Ehdr ; +UNION: Elf32/64_Shdr Elf32_Shdr Elf64_Shdr ; +UNION: Elf32/64_Shdr-array Elf32_Shdr-array Elf64_Shdr-array ; + +TYPED: 64-bit? ( elf: Elf32/64_Ehdr -- ? ) + e_ident>> EI_CLASS swap nth ELFCLASS64 = ; + +TYPED: elf-header ( c-ptr -- elf: Elf32/64_Ehdr ) + [ Elf64_Ehdr memory>struct 64-bit? ] keep swap + [ Elf64_Ehdr memory>struct ] + [ Elf32_Ehdr memory>struct ] if ; + +TYPED:: elf-section-headers ( elf: Elf32/64_Ehdr -- headers: Elf32/64_Shdr-array ) + elf [ e_shoff>> ] [ e_shnum>> ] bi :> ( off num ) + off elf >c-ptr num + elf 64-bit? + [ ] + [ ] if ; + +TYPED:: elf-section-data ( elf: Elf32/64_Ehdr header: Elf32/64_Shdr -- uchar-array/f ) + header [ sh_offset>> elf >c-ptr ] [ sh_size>> ] bi ; + +TYPED:: elf-section-data-by-name ( elf: Elf32/64_Ehdr name: string -- header/f uchar-array/f ) + elf elf-section-headers :> sections + elf e_shstrndx>> :> ndx + elf ndx sections nth elf-section-data >c-ptr :> section-names + + sections 1 tail [ + sh_name>> section-names ascii alien>string name = + ] find nip + + [ dup elf swap elf-section-data ] + [ f f ] if* ; + +TYPED:: elf-section-names ( elf: Elf32/64_Ehdr -- names ) + elf elf-section-headers :> sections + elf ".shstrtab" elf-section-data-by-name nip >c-ptr :> section-names + sections 1 tail [ + sh_name>> section-names + ascii alien>string + ] { } map-as ; From e6b4e54e2c07465784ef933fe2656f8f50eac2d8 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Tue, 6 Apr 2010 13:12:10 -0700 Subject: [PATCH 598/713] More work on fluids --- extra/fluids/fluids.factor | 59 +++++++++--------------------- extra/gpu/effects/step/step.factor | 19 +++++++++- extra/gpu/util/util.factor | 34 ++++++++++++++--- 3 files changed, 65 insertions(+), 47 deletions(-) diff --git a/extra/fluids/fluids.factor b/extra/fluids/fluids.factor index 1b4f1524de..1fff38b079 100644 --- a/extra/fluids/fluids.factor +++ b/extra/fluids/fluids.factor @@ -1,12 +1,12 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays classes.struct destructors game.loop -game.worlds gpu gpu.buffers gpu.framebuffers gpu.render gpu.shaders -gpu.state gpu.textures gpu.util images images.loader kernel literals -locals make math math.rectangles math.vectors namespaces opengl.gl -sequences specialized-arrays ui.gadgets.worlds images.ppm -ui.gestures ui.pixel-formats images.pgm gpu.effects.blur -gpu.effects.step ; +game.worlds gpu gpu.buffers gpu.effects.blur gpu.framebuffers +gpu.render gpu.shaders gpu.state gpu.textures gpu.util images +images.loader kernel literals locals make math math.rectangles +math.vectors namespaces opengl.gl sequences specialized-arrays +ui.gadgets.worlds ui.gestures ui.pixel-formats gpu.effects.step +images.pgm images.ppm ; FROM: alien.c-types => float ; SPECIALIZED-ARRAY: float IN: fluids @@ -65,7 +65,7 @@ particle_t-array{ [ verlet-integrate-particle ] curry map! ; TUPLE: fluids-world < game-world - particles texture framebuffer color-texture ramp { paused boolean initial: f } ; + particles texture ramp { paused boolean initial: f } ; : make-texture ( pathname -- texture ) load-image @@ -100,50 +100,27 @@ M: fluids-world begin-game-world initial-particles clone >>particles "resource:extra/fluids/particle2.pgm" make-texture >>texture "resource:extra/fluids/colors.ppm" make-texture >>ramp - - RGB float-components T{ texture-parameters - { wrap clamp-texcoord-to-edge } - { min-filter filter-linear } - { min-mipmap-filter f } } - >>color-texture - - dup color-texture>> 0 1array f f { 320 240 } >>framebuffer drop ; M: fluids-world end-game-world - framebuffer>> dispose ; + drop ; M: fluids-world tick-game-world dup paused>> [ drop ] [ integrate ] if ; M:: fluids-world draw-world* ( world -- ) - world framebuffer>> { { default-attachment { 0 0 0 } } } clear-framebuffer - system-framebuffer { { default-attachment { 0 0 0 } } } clear-framebuffer - - f eq-add func-one func-one dup set-gpu-state - f origin-upper-left 1.0 set-gpu-state world particles>> [ [ p>> [ x>> , ] [ y>> , ] bi ] each ] curry float-array{ } make :> verts - { 0 0 } { 320 240 } set-gpu-state - GL_POINT_SPRITE glEnable - world verts { - { "primitive-mode" [ 2drop points-mode ] } - { "uniforms" [ drop texture>> 50.0 window-point-uniforms boa ] } - { "vertex-array" [ nip stream-upload draw-usage vertex-buffer byte-array>buffer &dispose window-point-program &dispose &dispose ] } - { "indexes" [ nip length 2 / 0 swap ] } - { "framebuffer" [ drop framebuffer>> ] } - } 2 render - - world color-texture>> gaussian-blur - { 0 0 } { 640 480 } set-gpu-state - world ramp>> { - { "primitive-mode" [ 2drop triangle-strip-mode ] } - { "uniforms" [ step-uniforms boa ] } - { "vertex-array" [ 2drop step-program ] } - { "indexes" [ 2drop T{ index-range f 0 4 } ] } - } 2 render + [ + verts world texture>> 50.0 { 320 240 } blended-point-sprite-batch &dispose + + blend-state new set-gpu-state + + gaussian-blur &dispose world ramp>> { 1024 768 } step-texture &dispose + { 1024 768 } draw-texture + ] with-destructors ; GAME: fluids { @@ -151,7 +128,7 @@ GAME: fluids { { title "Fluids Test" } { pixel-format-attributes { windowed double-buffered T{ depth-bits { value 24 } } } } - { pref-dim { 640 480 } } + { pref-dim { 1024 768 } } { tick-interval-micros $[ 60 fps ] } } ; @@ -159,7 +136,7 @@ MAIN: fluids fluids-world H{ { T{ button-down } [ [ - hand-loc get { 640 480 } v/ 2 v*n 1 v-n { 1 -1 } v* first2 float2_t + hand-loc get { 1024 768 } v/ 2 v*n 1 v-n { 1 -1 } v* first2 float2_t dup 2.0 particle_t suffix ] change-particles drop ] } } set-gestures diff --git a/extra/gpu/effects/step/step.factor b/extra/gpu/effects/step/step.factor index f50c0c3cc1..bd3b013b4a 100644 --- a/extra/gpu/effects/step/step.factor +++ b/extra/gpu/effects/step/step.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. -USING: gpu.render gpu.shaders gpu.util ; +USING: destructors gpu.render gpu.shaders gpu.state gpu.textures +gpu.util images kernel locals math.rectangles ; IN: gpu.effects.step GLSL-SHADER: step-fragment-shader fragment-shader @@ -21,3 +22,19 @@ UNIFORM-TUPLE: step-uniforms { "ramp" texture-uniform f } ; GLSL-PROGRAM: step-program window-vertex-shader step-fragment-shader window-vertex-format ; + +: (step-texture) ( texture ramp texture dim -- ) + { 0 0 } swap set-gpu-state + [ step-uniforms boa ] dip { + { "primitive-mode" [ 2drop triangle-strip-mode ] } + { "uniforms" [ drop ] } + { "vertex-array" [ 2drop step-program ] } + { "indexes" [ 2drop T{ index-range f 0 4 } ] } + { "framebuffer" [ nip ] } + } 2 render ; + +:: step-texture ( texture ramp dim -- texture ) + dim RGB float-components <2d-render-texture> :> ( target-framebuffer target-texture ) + texture ramp target-framebuffer dim (step-texture) + target-framebuffer dispose + target-texture ; diff --git a/extra/gpu/util/util.factor b/extra/gpu/util/util.factor index 29fe5f1314..2678f0452c 100644 --- a/extra/gpu/util/util.factor +++ b/extra/gpu/util/util.factor @@ -1,7 +1,7 @@ ! (c)2009 Joe Groff bsd license -USING: accessors arrays gpu.buffers gpu.framebuffers gpu.render -gpu.shaders gpu.textures images kernel locals opengl.framebuffers -specialized-arrays ; +USING: arrays destructors gpu.buffers gpu.framebuffers gpu.render +gpu.shaders gpu.state gpu.textures images kernel locals math +math.rectangles opengl.gl sequences specialized-arrays ; FROM: alien.c-types => float ; SPECIALIZED-ARRAY: float IN: gpu.util @@ -125,10 +125,34 @@ CONSTANT: window-vertexes dup { { default-attachment { 0 0 0 } } } clear-framebuffer ] keep ; -: draw-texture ( texture -- ) +: draw-texture ( texture dim -- ) + { 0 0 } swap set-gpu-state { { "primitive-mode" [ drop triangle-strip-mode ] } { "uniforms" [ window-uniforms boa ] } - { "vertex-array" [ drop window-program ] } + { "vertex-array" [ drop window-program &dispose ] } { "indexes" [ drop T{ index-range f 0 4 } ] } } render ; + +:: ( verts program-instance -- vertex-array ) + verts stream-upload draw-usage vertex-buffer byte-array>buffer &dispose + program-instance &dispose ; + +: (blended-point-sprite-batch) ( verts framebuffer texture point-size dim -- ) + f eq-add func-one func-one dup set-gpu-state + f origin-upper-left 1.0 set-gpu-state + GL_POINT_SPRITE glEnable + { 0 0 } swap set-gpu-state + window-point-uniforms boa { + { "primitive-mode" [ 3drop points-mode ] } + { "uniforms" [ 2nip ] } + { "vertex-array" [ 2drop window-point-program ] } + { "indexes" [ 2drop length 2 / 0 swap ] } + { "framebuffer" [ drop nip ] } + } 3 render ; + +:: blended-point-sprite-batch ( verts texture point-size dim -- texture ) + dim RGB float-components <2d-render-texture> :> ( target-framebuffer target-texture ) + verts target-framebuffer texture point-size dim (blended-point-sprite-batch) + target-framebuffer dispose + target-texture ; From c3f8f5067e49756b64c44b2241963db5b88dc482 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 6 Apr 2010 13:34:26 -0700 Subject: [PATCH 599/713] catch merge conflicts in source and report them as such --- basis/debugger/debugger.factor | 3 +++ core/bootstrap/syntax.factor | 6 ++++++ core/parser/parser.factor | 2 ++ core/syntax/syntax.factor | 8 ++++++++ 4 files changed, 19 insertions(+) diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index 8f448ff237..468b5dcf2b 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -306,6 +306,9 @@ M: bad-inheritance summary M: not-in-a-method-error summary drop "call-next-method can only be called in a method definition" ; +M: version-control-merge-conflict summary + drop "Version control merge conflict in source code" ; + GENERIC: expected>string ( obj -- str ) M: f expected>string drop "end of input" ; diff --git a/core/bootstrap/syntax.factor b/core/bootstrap/syntax.factor index c13f9f9026..9395447aa6 100644 --- a/core/bootstrap/syntax.factor +++ b/core/bootstrap/syntax.factor @@ -89,6 +89,12 @@ IN: bootstrap.syntax "read-only" "call(" "execute(" + "<<<<<<" + "======" + ">>>>>>" + "<<<<<<<" + "=======" + ">>>>>>>" } [ "syntax" create drop ] each "t" "syntax" lookup define-symbol diff --git a/core/parser/parser.factor b/core/parser/parser.factor index 3257bd69a4..be43979b31 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -207,3 +207,5 @@ print-use-hook [ [ ] ] initialize : ?run-file ( path -- ) dup exists? [ run-file ] [ drop ] if ; + +ERROR: version-control-merge-conflict ; diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index bd70b0be62..de719c7272 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -257,4 +257,12 @@ IN: bootstrap.syntax "call(" [ \ call-effect parse-call( ] define-core-syntax "execute(" [ \ execute-effect parse-call( ] define-core-syntax + + "<<<<<<<" [ version-control-merge-conflict ] define-core-syntax + "=======" [ version-control-merge-conflict ] define-core-syntax + ">>>>>>>" [ version-control-merge-conflict ] define-core-syntax + + "<<<<<<" [ version-control-merge-conflict ] define-core-syntax + "======" [ version-control-merge-conflict ] define-core-syntax + ">>>>>>" [ version-control-merge-conflict ] define-core-syntax ] with-compilation-unit From e0196da1c8a3dd0af3a71d39ba720b83e8f8e251 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 6 Apr 2010 16:42:30 -0400 Subject: [PATCH 600/713] combinators: call( now throws an error if a quotation that was declared as never returning actually returns --- core/combinators/combinators-tests.factor | 18 ++++++++++++++++++ core/combinators/combinators.factor | 9 +++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/core/combinators/combinators-tests.factor b/core/combinators/combinators-tests.factor index b239b1eac9..1e7a61daaa 100644 --- a/core/combinators/combinators-tests.factor +++ b/core/combinators/combinators-tests.factor @@ -35,6 +35,24 @@ IN: combinators.tests [ 7 ] [ 1 3 [ 2 * ] [ + ] compose compile-call(-test-1 ] unit-test [ 4 ] [ 1 3 [ { + } [ ] like call ] compile-call(-test-1 ] unit-test +[ [ ] call( -- * ) ] must-fail + +: compile-call(-test-2 ( -- ) [ ] call( -- * ) ; + +[ compile-call(-test-2 ] [ wrong-values? ] must-fail-with + +: compile-call(-test-3 ( quot -- ) call( -- * ) ; + +[ [ ] compile-call(-test-3 ] [ wrong-values? ] must-fail-with + +: compile-execute(-test-3 ( a -- ) \ . execute( value -- * ) ; + +[ 10 compile-execute(-test-3 ] [ wrong-values? ] must-fail-with + +: compile-execute(-test-4 ( a word -- ) execute( value -- * ) ; + +[ 10 \ . compile-execute(-test-4 ] [ wrong-values? ] must-fail-with + ! Compiled : cond-test-1 ( obj -- str ) { diff --git a/core/combinators/combinators.factor b/core/combinators/combinators.factor index 7ef2ed5f9f..7ef8ef68ea 100644 --- a/core/combinators/combinators.factor +++ b/core/combinators/combinators.factor @@ -30,11 +30,12 @@ SLOT: out : call-effect ( quot effect -- ) ! Don't use fancy combinators here, since this word always ! runs unoptimized - [ datastack ] 2dip 2dup [ - [ dip ] dip - dup in>> length swap out>> length - check-datastack + [ [ datastack ] dip dip ] dip + dup terminated?>> [ 2drop f ] [ + dup in>> length swap out>> length + check-datastack + ] if ] 2dip rot [ 2drop ] [ wrong-values ] if ; From 0d00160f4c03ec3c89d400487f4c8bd5479e28c5 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 6 Apr 2010 16:48:30 -0400 Subject: [PATCH 601/713] combinators: fix load error --- core/combinators/combinators.factor | 1 + 1 file changed, 1 insertion(+) diff --git a/core/combinators/combinators.factor b/core/combinators/combinators.factor index 7ef8ef68ea..bbfee30b3d 100644 --- a/core/combinators/combinators.factor +++ b/core/combinators/combinators.factor @@ -26,6 +26,7 @@ ERROR: wrong-values quot call-site ; ! We can't USE: effects here so we forward reference slots instead SLOT: in SLOT: out +SLOT: terminated? : call-effect ( quot effect -- ) ! Don't use fancy combinators here, since this word always From fe085c96d6af4f026caf9854b51b50baf3b1076c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 6 Apr 2010 13:56:35 -0700 Subject: [PATCH 602/713] =?UTF-8?q?debugger:=20``=20''=20->=20=E2=80=9C=20?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- basis/debugger/debugger.factor | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index 468b5dcf2b..8856871f11 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -270,20 +270,20 @@ M: no-current-vocab summary M: no-word-error summary name>> - "No word named ``" - "'' found in current vocabulary search path" surround ; + "No word named “" + "” found in current vocabulary search path" surround ; M: no-word-error error. summary print ; M: no-word-in-vocab summary [ vocab>> ] [ word>> ] bi - [ "No word named ``" % % "'' found in ``" % % "'' vocabulary" % ] "" make ; + [ "No word named “" % % "” found in “" % % "” vocabulary" % ] "" make ; M: no-word-in-vocab error. summary print ; M: ambiguous-use-error summary words>> first name>> - "More than one vocabulary defines a word named ``" "''" surround ; + "More than one vocabulary defines a word named “" "”" surround ; M: ambiguous-use-error error. summary print ; From c931870cd741d3d85f4f9010e43b6782080b8fa8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 6 Apr 2010 16:30:41 -0500 Subject: [PATCH 603/713] vm: fix compile error under Cygwin --- vm/os-windows-nt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/os-windows-nt.cpp b/vm/os-windows-nt.cpp index b7f86233a1..0d43cdecc2 100755 --- a/vm/os-windows-nt.cpp +++ b/vm/os-windows-nt.cpp @@ -84,7 +84,7 @@ LONG factor_vm::exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, break; } - return ExceptionContinueExecution; + return 0; } VM_C_API LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch) From aa7bf38e3864fe2069d4a496e20851b9034953de Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 6 Apr 2010 15:20:56 -0700 Subject: [PATCH 604/713] cursors: unify input-cursor and assoc-cursor, give all cursors a "key" concept --- extra/cursors/cursors-tests.factor | 24 ++++++---------- extra/cursors/cursors.factor | 46 ++++++++++++------------------ 2 files changed, 27 insertions(+), 43 deletions(-) diff --git a/extra/cursors/cursors-tests.factor b/extra/cursors/cursors-tests.factor index d71999ab87..44eb6bc16c 100644 --- a/extra/cursors/cursors-tests.factor +++ b/extra/cursors/cursors-tests.factor @@ -21,20 +21,6 @@ IN: cursors.tests [ B{ } ] [ [ { } [ , ] each ] B{ } make ] unit-test [ { 2 4 6 8 10 } ] [ { 1 2 3 4 5 } [ 2 * ] map ] unit-test -[ { "roses: lutefisk" "tulips: lox" } ] -[ - [ - { { "roses" "lutefisk" } { "tulips" "lox" } } - [ ": " glue , ] assoc-each - ] { } make -] unit-test - -[ { "roses: lutefisk" "tulips: lox" } ] -[ - { { "roses" "lutefisk" } { "tulips" "lox" } } - [ ": " glue ] { } assoc>map -] unit-test - [ { "roses: lutefisk" "tulips: lox" } ] [ [ @@ -65,8 +51,14 @@ IN: cursors.tests [ { 2 4 6 8 10 } ] [ { 1 2 3 4 5 } compile-test-map ] unit-test [ { "roses: lutefisk" "tulips: lox" } ] -[ [ { { "roses" "lutefisk" } { "tulips" "lox" } } compile-test-assoc-each ] { } make ] unit-test +[ + [ H{ { "roses" "lutefisk" } { "tulips" "lox" } } compile-test-assoc-each ] + { } make natural-sort +] unit-test [ { "roses: lutefisk" "tulips: lox" } ] -[ { { "roses" "lutefisk" } { "tulips" "lox" } } compile-test-assoc>map ] unit-test +[ + H{ { "roses" "lutefisk" } { "tulips" "lox" } } compile-test-assoc>map + natural-sort +] unit-test diff --git a/extra/cursors/cursors.factor b/extra/cursors/cursors.factor index d7fe5fb893..776a5523c4 100644 --- a/extra/cursors/cursors.factor +++ b/extra/cursors/cursors.factor @@ -61,13 +61,19 @@ ERROR: invalid-cursor cursor ; MIXIN: input-cursor -GENERIC: cursor-value ( cursor -- value ) +GENERIC: cursor-key-value ( cursor -- key value ) -M: input-cursor cursor-value-unsafe cursor-value ; inline -M: input-cursor cursor-value - dup cursor-valid? [ cursor-value-unsafe ] [ invalid-cursor ] if ; inline +M: input-cursor cursor-key-value-unsafe cursor-key-value ; inline +M: input-cursor cursor-key-value + dup cursor-valid? [ cursor-key-value-unsafe ] [ invalid-cursor ] if ; inline + +: cursor-key ( cursor -- key ) cursor-key-value drop ; +: cursor-value ( cursor -- key ) cursor-key-value nip ; + +: cursor-key-unsafe ( cursor -- key ) cursor-key-value-unsafe drop ; +: cursor-value-unsafe ( cursor -- key ) cursor-key-value-unsafe nip ; ! ! output cursors @@ -155,7 +161,7 @@ M: numeric-cursor cursor>= [ value>> ] bi@ >= ; inline INSTANCE: numeric-cursor input-cursor -M: numeric-cursor cursor-value value>> ; inline +M: numeric-cursor cursor-key-value value>> dup ; inline ! ! linear cursor @@ -278,8 +284,8 @@ M: sequence-cursor cursor-distance ( cursor cursor -- n ) INSTANCE: sequence-cursor input-cursor -M: sequence-cursor cursor-value-unsafe [ n>> ] [ seq>> ] bi nth-unsafe ; inline -M: sequence-cursor cursor-value [ n>> ] [ seq>> ] bi nth ; inline +M: sequence-cursor cursor-key-value-unsafe [ n>> dup ] [ seq>> ] bi nth-unsafe ; inline +M: sequence-cursor cursor-key-value [ n>> dup ] [ seq>> ] bi nth ; inline INSTANCE: sequence-cursor output-cursor @@ -362,13 +368,9 @@ M: forward-cursor new-sequence-cursor over map-as ; inline ! -! assoc cursors +! assoc combinators ! -MIXIN: assoc-cursor - -GENERIC: cursor-key-value ( cursor -- key value ) - : -assoc- ( quot -- quot' ) '[ cursor-key-value @ ] ; inline @@ -380,11 +382,6 @@ GENERIC: cursor-key-value ( cursor -- key value ) : assoc>map ( ... assoc quot: ( ... k v -- ... newx ) exemplar -- ... newcontainer ) [ assoc- ] dip -map-as ; inline -INSTANCE: input-cursor assoc-cursor - -M: input-cursor cursor-key-value - cursor-value-unsafe first2 ; inline - ! ! hashtable cursor ! @@ -421,16 +418,11 @@ M: hashtable-cursor inc-cursor ( cursor -- cursor' ) [ hashtable>> dup array>> ] [ n>> 2 + ] bi (inc-hashtable-cursor) ; inline -INSTANCE: hashtable-cursor assoc-cursor - -M: hashtable-cursor cursor-key-value - [ n>> ] [ hashtable>> array>> ] bi - [ nth-unsafe ] [ [ 1 + ] dip nth-unsafe ] 2bi ; inline - INSTANCE: hashtable-cursor input-cursor -M: hashtable-cursor cursor-value-unsafe - cursor-key-value 2array ; inline +M: hashtable-cursor cursor-key-value-unsafe + [ n>> ] [ hashtable>> array>> ] bi + [ nth-unsafe ] [ [ 1 + ] dip nth-unsafe ] 2bi ; inline INSTANCE: hashtable container @@ -472,7 +464,7 @@ M: zip-cursor cursor-distance-hint ( cursor cursor -- n ) M: zip-cursor inc-cursor ( cursor -- cursor' ) [ keys>> inc-cursor ] [ values>> inc-cursor ] bi ; inline -INSTANCE: zip-cursor assoc-cursor +INSTANCE: zip-cursor input-cursor M: zip-cursor cursor-key-value [ keys>> cursor-value-unsafe ] [ values>> cursor-value-unsafe ] bi ; inline From 181c45209f0640986effb890f444affff1cbe0e0 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 7 Apr 2010 15:33:19 -0700 Subject: [PATCH 605/713] gpu.shaders: use "counter" instead of reinventing it --- extra/gpu/shaders/shaders.factor | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/extra/gpu/shaders/shaders.factor b/extra/gpu/shaders/shaders.factor index 69f6ba2253..974f2f8070 100755 --- a/extra/gpu/shaders/shaders.factor +++ b/extra/gpu/shaders/shaders.factor @@ -301,13 +301,11 @@ M: f (verify-feedback-format) dup 1 = [ drop ] [ 2array ] if ; SYMBOL: padding-no -padding-no [ 0 ] initialize : padding-name ( -- name ) "padding-" - padding-no get number>string append - "(" ")" surround - padding-no inc ; + padding-no counter number>string append + "(" ")" surround ; : vertex-attribute>struct-slot ( vertex-attribute -- struct-slot-spec ) [ name>> [ padding-name ] unless* ] From 85f3c69c70b28912c6b8f2b62ecc82bbefdff98b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 7 Apr 2010 20:40:13 -0400 Subject: [PATCH 606/713] io.monitors.recursive: don't bomb if a dsubordinate monitor is disposed of --- basis/io/monitors/recursive/recursive.factor | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/basis/io/monitors/recursive/recursive.factor b/basis/io/monitors/recursive/recursive.factor index b573e2fa2b..70daed9018 100644 --- a/basis/io/monitors/recursive/recursive.factor +++ b/basis/io/monitors/recursive/recursive.factor @@ -1,9 +1,10 @@ -! Copyright (C) 2008, 2009 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors sequences assocs arrays continuations destructors combinators kernel threads concurrency.messaging concurrency.mailboxes concurrency.promises io.files io.files.info -io.directories io.pathnames io.monitors debugger fry ; +io.directories io.pathnames io.monitors io.monitors.private +debugger fry ; IN: io.monitors.recursive ! Simulate recursive monitors on platforms that don't have them @@ -71,12 +72,14 @@ M: recursive-monitor dispose* ] with with each ; : pump-loop ( -- ) - receive dup +stop+ eq? [ - drop stop-pump - ] [ - [ '[ _ update-hierarchy ] ignore-errors ] [ pump-step ] bi - pump-loop - ] if ; + receive { + { [ dup +stop+ eq? ] [ drop stop-pump ] } + { [ dup monitor-disposed eq? ] [ drop ] } + [ + [ '[ _ update-hierarchy ] ignore-errors ] [ pump-step ] bi + pump-loop + ] + } cond ; : monitor-ready ( error/t -- ) monitor tget ready>> fulfill ; From b330595c3b1c25c1fde61d5ffbdd9a12bd5d0d0d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 8 Apr 2010 10:22:59 -0700 Subject: [PATCH 607/713] ui.gadgets.grids: clarify docs --- basis/ui/gadgets/grids/grids-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/ui/gadgets/grids/grids-docs.factor b/basis/ui/gadgets/grids/grids-docs.factor index 10b3bb7259..1632072ca2 100644 --- a/basis/ui/gadgets/grids/grids-docs.factor +++ b/basis/ui/gadgets/grids/grids-docs.factor @@ -2,7 +2,7 @@ USING: ui.gadgets help.markup help.syntax arrays ; IN: ui.gadgets.grids ARTICLE: "ui-grid-layout" "Grid layouts" -"Grid gadgets layout their children in a rectangular grid." +"Grid gadgets layout their children in a rectangular grid. The grid is represented as a sequence of sequences of gadgets. Every child sequence is a row of gadgets. Every row must have an equal number of gadgets in it." { $subsections grid } "Creating grids from a fixed set of gadgets:" { $subsections } From e5e51c40a1917e5676062b37c4a9e63b6caf63d8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 8 Apr 2010 10:32:14 -0700 Subject: [PATCH 608/713] vm: implement frame-based SEH for 64-bit Windows --- Nmakefile | 1 + vm/Config.windows.nt.x86.32 | 1 + vm/Config.windows.nt.x86.64 | 1 + vm/code_heap.cpp | 10 ++++- vm/code_heap.hpp | 9 ++++ vm/image.cpp | 4 +- vm/os-windows-nt-x86.32.cpp | 12 ++++++ vm/os-windows-nt-x86.64.cpp | 85 +++++++++++++++++++++++++++++++++++++ vm/os-windows-nt.cpp | 5 --- 9 files changed, 119 insertions(+), 9 deletions(-) create mode 100644 vm/os-windows-nt-x86.32.cpp create mode 100644 vm/os-windows-nt-x86.64.cpp diff --git a/Nmakefile b/Nmakefile index 02d2b5f1ed..b85197a776 100755 --- a/Nmakefile +++ b/Nmakefile @@ -11,6 +11,7 @@ ML_FLAGS = /nologo /safeseh EXE_OBJS = vm\main-windows-nt.obj vm\factor.res DLL_OBJS = vm\os-windows-nt.obj \ + vm\os-windows-nt-x86.32.obj \ vm\os-windows.obj \ vm\aging_collector.obj \ vm\alien.obj \ diff --git a/vm/Config.windows.nt.x86.32 b/vm/Config.windows.nt.x86.32 index d27629fe83..73bf064ce5 100644 --- a/vm/Config.windows.nt.x86.32 +++ b/vm/Config.windows.nt.x86.32 @@ -1,3 +1,4 @@ +PLAF_DLL_OBJS += vm/os-windows-nt-x86.32.o DLL_PATH=http://factorcode.org/dlls WINDRES=windres include vm/Config.windows.nt diff --git a/vm/Config.windows.nt.x86.64 b/vm/Config.windows.nt.x86.64 index ddb61480e5..495a3ccac9 100644 --- a/vm/Config.windows.nt.x86.64 +++ b/vm/Config.windows.nt.x86.64 @@ -1,3 +1,4 @@ +PLAF_DLL_OBJS += vm/os-windows-nt-x86.64.o DLL_PATH=http://factorcode.org/dlls/64 CC=$(WIN64_PATH)-gcc.exe WINDRES=$(WIN64_PATH)-windres.exe diff --git a/vm/code_heap.cpp b/vm/code_heap.cpp index 40fe00b0e9..96d9541665 100755 --- a/vm/code_heap.cpp +++ b/vm/code_heap.cpp @@ -7,8 +7,14 @@ code_heap::code_heap(cell size) { if(size > ((u64)1 << (sizeof(cell) * 8 - 6))) fatal_error("Heap too large",size); seg = new segment(align_page(size),true); - if(!seg) fatal_error("Out of memory in heap allocator",size); - allocator = new free_list_allocator(size,seg->start); + if(!seg) fatal_error("Out of memory in code_heap constructor",size); + + cell start = seg->start + seh_area_size; + + allocator = new free_list_allocator(seg->end - start,start); + + /* See os-windows-nt-x86.64.cpp for seh_area usage */ + seh_area = (char *)seg->start; } code_heap::~code_heap() diff --git a/vm/code_heap.hpp b/vm/code_heap.hpp index 78ffa6c76a..20ce03c835 100755 --- a/vm/code_heap.hpp +++ b/vm/code_heap.hpp @@ -1,10 +1,19 @@ namespace factor { +#if defined(WINDOWS) && defined(FACTOR_64) + const cell seh_area_size = 1024; +#else + const cell seh_area_size = 0; +#endif + struct code_heap { /* The actual memory area */ segment *seg; + /* Memory area reserved for SEH. Only used on Windows */ + char *seh_area; + /* Memory allocator */ free_list_allocator *allocator; diff --git a/vm/image.cpp b/vm/image.cpp index c74351c191..ccce96a952 100755 --- a/vm/image.cpp +++ b/vm/image.cpp @@ -258,7 +258,7 @@ void factor_vm::load_image(vm_parameters *p) init_objects(&h); cell data_offset = data->tenured->start - h.data_relocation_base; - cell code_offset = code->seg->start - h.code_relocation_base; + cell code_offset = code->allocator->start - h.code_relocation_base; fixup_data(data_offset,code_offset); fixup_code(data_offset,code_offset); @@ -285,7 +285,7 @@ bool factor_vm::save_image(const vm_char *saving_filename, const vm_char *filena h.version = image_version; h.data_relocation_base = data->tenured->start; h.data_size = data->tenured->occupied_space(); - h.code_relocation_base = code->seg->start; + h.code_relocation_base = code->allocator->start; h.code_size = code->allocator->occupied_space(); h.true_object = true_object; diff --git a/vm/os-windows-nt-x86.32.cpp b/vm/os-windows-nt-x86.32.cpp new file mode 100644 index 0000000000..61cf9f6c4e --- /dev/null +++ b/vm/os-windows-nt-x86.32.cpp @@ -0,0 +1,12 @@ +#include "master.hpp" + +namespace factor +{ + +void factor_vm::c_to_factor_toplevel(cell quot) +{ + /* 32-bit Windows SEH is set up in basis/cpu/x86/32/winnt/bootstrap.factor */ + c_to_factor(quot); +} + +} diff --git a/vm/os-windows-nt-x86.64.cpp b/vm/os-windows-nt-x86.64.cpp new file mode 100644 index 0000000000..876d0c5771 --- /dev/null +++ b/vm/os-windows-nt-x86.64.cpp @@ -0,0 +1,85 @@ +#include "master.hpp" + +namespace factor { + +typedef unsigned char UBYTE; + +const UBYTE UNW_FLAG_EHANDLER = 0x1; + +struct UNWIND_INFO { + UBYTE Version:3; + UBYTE Flags:5; + UBYTE SizeOfProlog; + UBYTE CountOfCodes; + UBYTE FrameRegister:4; + UBYTE FrameOffset:4; + ULONG ExceptionHandler; + ULONG ExceptionData[1]; +}; + +struct seh_data { + UNWIND_INFO unwind_info; + RUNTIME_FUNCTION func; + UBYTE handler[32]; +}; + +void factor_vm::c_to_factor_toplevel(cell quot) +{ + /* The annoying thing about Win64 SEH is that the offsets in + * function tables are 32-bit integers, and the exception handler + * itself must reside between the start and end pointers, so + * we stick everything at the beginning of the code heap and + * generate a small trampoline that jumps to the real + * exception handler. */ + + seh_data *seh_area = (seh_data *)code->seh_area; + cell base = code->seg->start; + + /* Should look at generating this with the Factor assembler */ + + /* mov rax,0 */ + seh_area->handler[0] = 0x48; + seh_area->handler[1] = 0xb8; + seh_area->handler[2] = 0x0; + seh_area->handler[3] = 0x0; + seh_area->handler[4] = 0x0; + seh_area->handler[5] = 0x0; + seh_area->handler[6] = 0x0; + seh_area->handler[7] = 0x0; + seh_area->handler[8] = 0x0; + seh_area->handler[9] = 0x0; + + /* jmp rax */ + seh_area->handler[10] = 0x48; + seh_area->handler[11] = 0xff; + seh_area->handler[12] = 0xe0; + + /* Store address of exception handler in the operand of the 'mov' */ + cell handler = (cell)&factor::exception_handler; + memcpy(&seh_area->handler[2],&handler,sizeof(cell)); + + UNWIND_INFO *unwind_info = &seh_area->unwind_info; + unwind_info->Version = 1; + unwind_info->Flags = UNW_FLAG_EHANDLER; + unwind_info->SizeOfProlog = 0; + unwind_info->CountOfCodes = 0; + unwind_info->FrameRegister = 0; + unwind_info->FrameOffset = 0; + unwind_info->ExceptionHandler = (DWORD)((cell)&seh_area->handler[0] - base); + unwind_info->ExceptionData[0] = 0; + + RUNTIME_FUNCTION *func = &seh_area->func; + func->BeginAddress = 0; + func->EndAddress = (DWORD)(code->seg->end - base); + func->UnwindData = (DWORD)((cell)&seh_area->unwind_info - base); + + if(!RtlAddFunctionTable(func,1,base)) + fatal_error("RtlAddFunctionTable() failed",0); + + c_to_factor(quot); + + if(!RtlDeleteFunctionTable(func)) + fatal_error("RtlDeleteFunctionTable() failed",0); +} + +} diff --git a/vm/os-windows-nt.cpp b/vm/os-windows-nt.cpp index 0d43cdecc2..4fea294a12 100755 --- a/vm/os-windows-nt.cpp +++ b/vm/os-windows-nt.cpp @@ -92,11 +92,6 @@ VM_C_API LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, vo return current_vm()->exception_handler(e,frame,c,dispatch); } -void factor_vm::c_to_factor_toplevel(cell quot) -{ - c_to_factor(quot); -} - void factor_vm::open_console() { } From 1019278474c767d93e3c1bdbb8b308f05b518973 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 8 Apr 2010 18:00:00 -0500 Subject: [PATCH 609/713] Nmakefile: support both 32-bit and 64-bit builds again --- Nmakefile | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/Nmakefile b/Nmakefile index b85197a776..c8dd98917d 100755 --- a/Nmakefile +++ b/Nmakefile @@ -1,18 +1,27 @@ -!IF DEFINED(DEBUG) -LINK_FLAGS = /nologo /safeseh /DEBUG shell32.lib -CL_FLAGS = /nologo /Zi /O2 /W3 /DFACTOR_DEBUG -!ELSE -LINK_FLAGS = /nologo /safeseh shell32.lib +!IF DEFINED(PLATFORM) + +LINK_FLAGS = /nologo shell32.lib CL_FLAGS = /nologo /O2 /W3 + +!IF DEFINED(DEBUG) +LINK_FLAGS = $(LINK_FLAGS) /DEBUG +CL_FLAGS = $(CL_FLAGS) /Zi /DFACTOR_DEBUG !ENDIF -ML_FLAGS = /nologo /safeseh +!IF "$(PLATFORM)" == "x86-32" +LINK_FLAGS = $(LINK_FLAGS) /safeseh +PLAF_DLL_OBJS = vm\os-windows-nt-x86.32.obj vm\safeseh.obj +!ELSEIF "$(PLATFORM)" == "x86-64" +PLAF_DLL_OBJS = vm\os-windows-nt-x86.64.obj +!ENDIF + +ML_FLAGS = /nologo EXE_OBJS = vm\main-windows-nt.obj vm\factor.res -DLL_OBJS = vm\os-windows-nt.obj \ - vm\os-windows-nt-x86.32.obj \ +DLL_OBJS = $(PLAF_DLL_OBJS) \ vm\os-windows.obj \ + vm\os-windows-nt.obj \ vm\aging_collector.obj \ vm\alien.obj \ vm\arrays.obj \ @@ -50,7 +59,6 @@ DLL_OBJS = vm\os-windows-nt.obj \ vm\profiler.obj \ vm\quotations.obj \ vm\run.obj \ - vm\safeseh.obj \ vm\strings.obj \ vm\to_tenured_collector.obj \ vm\tuples.obj \ @@ -70,8 +78,6 @@ DLL_OBJS = vm\os-windows-nt.obj \ .rs.res: rc $< -all: factor.com factor.exe factor.dll.lib libfactor-ffi-test.dll - libfactor-ffi-test.dll: vm/ffi_test.obj link $(LINK_FLAGS) /out:libfactor-ffi-test.dll /dll vm/ffi_test.obj @@ -84,6 +90,22 @@ factor.com: $(EXE_OBJS) $(DLL_OBJS) factor.exe: $(EXE_OBJS) $(DLL_OBJS) link $(LINK_FLAGS) /out:factor.exe /SUBSYSTEM:windows $(EXE_OBJS) $(DLL_OBJS) +all: factor.com factor.exe factor.dll.lib libfactor-ffi-test.dll + +!ENDIF + +default: + @echo Usage: nmake /f Nmakefile platform + @echo Where platform is one of: + @echo x86-32 + @echo x86-64 + +x86-32: + nmake PLATFORM=x86-32 /f Nmakefile all + +x86-64: + nmake PLATFORM=x86-64 /f Nmakefile all + clean: del vm\*.obj del factor.lib @@ -92,6 +114,6 @@ clean: del factor.dll del factor.dll.lib -.PHONY: all clean +.PHONY: all default x86-32 x86-64 clean .SUFFIXES: .rs From ea81faffca3a8d68ad78eea4d4d0ee3f6e70c254 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 8 Apr 2010 18:06:22 -0500 Subject: [PATCH 610/713] Nmakefile: fix 32-bit build --- Nmakefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Nmakefile b/Nmakefile index c8dd98917d..1edc14199d 100755 --- a/Nmakefile +++ b/Nmakefile @@ -15,7 +15,7 @@ PLAF_DLL_OBJS = vm\os-windows-nt-x86.32.obj vm\safeseh.obj PLAF_DLL_OBJS = vm\os-windows-nt-x86.64.obj !ENDIF -ML_FLAGS = /nologo +ML_FLAGS = /nologo /safeseh EXE_OBJS = vm\main-windows-nt.obj vm\factor.res @@ -99,6 +99,7 @@ default: @echo Where platform is one of: @echo x86-32 @echo x86-64 + @exit 1 x86-32: nmake PLATFORM=x86-32 /f Nmakefile all From 618915a084a186ac21fb5864d95ee25e37fc082c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 8 Apr 2010 16:40:51 -0700 Subject: [PATCH 611/713] mason.child: update for Nmakefile change --- extra/mason/child/child-tests.factor | 2 +- extra/mason/child/child.factor | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/extra/mason/child/child-tests.factor b/extra/mason/child/child-tests.factor index f8046ac8e5..1018a1ec40 100644 --- a/extra/mason/child/child-tests.factor +++ b/extra/mason/child/child-tests.factor @@ -1,7 +1,7 @@ IN: mason.child.tests USING: mason.child mason.config tools.test namespaces io kernel sequences ; -[ { "nmake" "/f" "nmakefile" } ] [ +[ { "nmake" "/f" "nmakefile" "x86-32" } ] [ [ "winnt" target-os set "x86.32" target-cpu set diff --git a/extra/mason/child/child.factor b/extra/mason/child/child.factor index 017e4401d8..d9821f8fcc 100644 --- a/extra/mason/child/child.factor +++ b/extra/mason/child/child.factor @@ -4,13 +4,20 @@ USING: accessors arrays calendar combinators.short-circuit fry continuations debugger io.directories io.files io.launcher io.pathnames io.encodings.ascii kernel make mason.common mason.config mason.platform mason.report mason.notify namespaces sequences -quotations macros system combinators ; +quotations macros system combinators splitting ; IN: mason.child +: nmake-cmd ( -- args ) + { "nmake" "/f" "nmakefile" } + target-cpu get "." split "-" join suffix ; + +: gnu-make-cmd ( -- args ) + gnu-make platform 2array ; + : make-cmd ( -- args ) { - { [ target-os get "winnt" = ] [ { "nmake" "/f" "nmakefile" } ] } - [ gnu-make platform 2array ] + { [ target-os get "winnt" = ] [ nmake-cmd ] } + [ gnu-make-cmd ] } cond ; : make-vm ( -- ) From b86abfb70c35f2909a4d9c0c377e2e256d03984b Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Fri, 9 Apr 2010 23:45:21 -0700 Subject: [PATCH 612/713] Helper words for elf --- extra/elf/elf.factor | 131 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 120 insertions(+), 11 deletions(-) diff --git a/extra/elf/elf.factor b/extra/elf/elf.factor index 539939856d..bf4de754d1 100644 --- a/extra/elf/elf.factor +++ b/extra/elf/elf.factor @@ -1,10 +1,11 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien alien.c-types alien.strings alien.syntax arrays -classes.struct io.encodings.ascii kernel locals sequences -specialized-arrays strings typed ; +classes.struct io.encodings.ascii kernel locals math math.intervals +sequences specialized-arrays strings typed ; IN: elf +! FFI data CONSTANT: EI_NIDENT 16 CONSTANT: EI_MAG0 0 CONSTANT: EI_MAG1 1 @@ -459,10 +460,15 @@ STRUCT: Elf64_Dyn { d_tag Elf64_Sxword } { d_val Elf64_Xword } ; -SPECIALIZED-ARRAYS: Elf32_Shdr Elf64_Shdr uchar ; +! Low-level interface +SPECIALIZED-ARRAYS: Elf32_Shdr Elf64_Shdr Elf32_Sym Elf64_Sym Elf32_Phdr Elf64_Phdr uchar ; UNION: Elf32/64_Ehdr Elf32_Ehdr Elf64_Ehdr ; UNION: Elf32/64_Shdr Elf32_Shdr Elf64_Shdr ; UNION: Elf32/64_Shdr-array Elf32_Shdr-array Elf64_Shdr-array ; +UNION: Elf32/64_Sym Elf32_Sym Elf64_Sym ; +UNION: Elf32/64_Sym-array Elf32_Sym-array Elf64_Sym-array ; +UNION: Elf32/64_Phdr Elf32_Phdr Elf64_Phdr ; +UNION: Elf32/64_Phdr-array Elf32_Phdr-array Elf64_Phdr-array ; TYPED: 64-bit? ( elf: Elf32/64_Ehdr -- ? ) e_ident>> EI_CLASS swap nth ELFCLASS64 = ; @@ -479,25 +485,128 @@ TYPED:: elf-section-headers ( elf: Elf32/64_Ehdr -- headers: Elf32/64_Shdr-array [ ] [ ] if ; +TYPED:: elf-program-headers ( elf: Elf32/64_Ehdr -- headers: Elf32/64_Phdr-array ) + elf [ e_phoff>> ] [ e_phnum>> ] bi :> ( off num ) + off elf >c-ptr num + elf 64-bit? + [ ] + [ ] if ; + +TYPED: elf-loadable-segments ( headers: Elf32/64_Phdr-array -- headers: Elf32/64_Phdr-array ) + [ p_type>> PT_LOAD = ] filter ; + +TYPED:: elf-segment-sections ( segment: Elf32/64_Phdr sections: Elf32/64_Shdr-array -- sections ) + segment [ p_offset>> dup ] [ p_filesz>> + ] bi [a,b) :> segment-interval + sections [ dup [ sh_offset>> dup ] [ sh_size>> + ] bi [a,b) 2array ] { } map-as :> section-intervals + section-intervals [ second segment-interval interval-intersect empty-interval = not ] + filter [ first ] map ; + +TYPED:: virtual-address-segment ( elf: Elf32/64_Ehdr address -- program-header/f ) + elf elf-program-headers elf-loadable-segments [ + [ p_vaddr>> dup ] [ p_memsz>> + ] bi [a,b) + address swap interval-contains? + ] filter [ f ] [ first ] if-empty ; + +TYPED:: virtual-address-section ( elf: Elf32/64_Ehdr address -- section-header/f ) + elf address virtual-address-segment :> segment + segment elf elf-section-headers elf-segment-sections :> sections + address segment p_vaddr>> - segment p_offset>> + :> faddress + sections [ + [ sh_offset>> dup ] [ sh_size>> + ] bi [a,b) + faddress swap interval-contains? + ] filter [ f ] [ first ] if-empty ; + +TYPED:: elf-segment-data ( elf: Elf32/64_Ehdr header: Elf32/64_Phdr -- uchar-array/f ) + header [ p_offset>> elf >c-ptr ] [ p_filesz>> ] bi ; + TYPED:: elf-section-data ( elf: Elf32/64_Ehdr header: Elf32/64_Shdr -- uchar-array/f ) header [ sh_offset>> elf >c-ptr ] [ sh_size>> ] bi ; +TYPED:: elf-section-data-by-index ( elf: Elf32/64_Ehdr index -- header/f uchar-array/f ) + elf elf-section-headers :> sections + index sections nth :> header + elf header elf-section-data :> data + header data ; + +TYPED:: elf-section-name ( elf: Elf32/64_Ehdr header: Elf32/64_Shdr -- name: string ) + elf elf e_shstrndx>> elf-section-data-by-index nip >c-ptr :> section-names + header sh_name>> section-names ascii alien>string ; + TYPED:: elf-section-data-by-name ( elf: Elf32/64_Ehdr name: string -- header/f uchar-array/f ) elf elf-section-headers :> sections elf e_shstrndx>> :> ndx elf ndx sections nth elf-section-data >c-ptr :> section-names - sections 1 tail [ sh_name>> section-names ascii alien>string name = ] find nip - [ dup elf swap elf-section-data ] [ f f ] if* ; -TYPED:: elf-section-names ( elf: Elf32/64_Ehdr -- names ) - elf elf-section-headers :> sections - elf ".shstrtab" elf-section-data-by-name nip >c-ptr :> section-names - sections 1 tail [ - sh_name>> section-names - ascii alien>string +TYPED:: elf-sections ( elf: Elf32/64_Ehdr -- sections ) + elf elf-section-headers :> sections + elf elf e_shstrndx>> elf-section-data-by-index nip >c-ptr :> section-names + sections [ + [ sh_name>> section-names + ascii alien>string ] keep 2array ] { } map-as ; + +TYPED:: elf-symbols ( elf: Elf32/64_Ehdr section-data: uchar-array -- symbols ) + elf ".strtab" elf-section-data-by-name nip >c-ptr :> strings + section-data [ >c-ptr ] [ length ] bi + elf 64-bit? + [ Elf64_Sym heap-size / ] + [ Elf32_Sym heap-size / ] if + [ [ st_name>> strings ascii alien>string ] keep 2array ] { } map-as ; + +! High level interface +TUPLE: elf elf-header ; +TUPLE: section name elf-header section-header data ; +TUPLE: segment elf-header program-header data ; +TUPLE: symbol name elf-header sym data ; + +GENERIC: sections ( obj -- sections ) + +: ( c-ptr -- elf ) + elf-header elf boa ; + +M:: elf sections ( elf -- sections ) + elf elf-header>> elf-sections + [ + first2 :> ( name header ) + elf elf-header>> header elf-section-data :> data + name elf elf-header>> header data section boa + ] { } map-as ; + +:: segments ( elf -- segments ) + elf elf-header>> elf-program-headers + [| header | + elf elf-header>> header elf-segment-data :> data + elf elf-header>> header data segment boa + ] { } map-as ; + +M:: segment sections ( segment -- sections ) + segment program-header>> + segment elf-header>> elf-section-headers + elf-segment-sections + + [| header | + segment elf-header>> header elf-section-name :> name + segment elf-header>> header elf-section-data :> data + name segment elf-header>> header data section boa + ] { } map-as ; + +:: symbols ( section -- symbols ) + section elf-header>> + section data>> + elf-symbols + [ + first2 :> ( name sym ) + name section elf-header>> sym f symbol boa + ] { } map-as ; + +:: symbol-data ( symbol -- data ) + symbol [ elf-header>> ] [ sym>> st_value>> ] bi virtual-address-segment :> segment + symbol sym>> st_value>> segment p_vaddr>> - segment p_offset>> + :> faddress + faddress symbol elf-header>> >c-ptr + symbol sym>> st_size>> ; + From edc489f4c1d4027bce84c658332ec565fdd7289a Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Fri, 9 Apr 2010 23:48:22 -0700 Subject: [PATCH 613/713] Change C-ENUM: to always take a type. Use f for anonymous enums. Update all uses. --- basis/alien/data/data-docs.factor | 2 +- basis/alien/parser/parser.factor | 21 ++- basis/alien/syntax/syntax-docs.factor | 17 +-- basis/alien/syntax/syntax.factor | 18 +-- basis/cairo/ffi/ffi.factor | 39 ++---- basis/core-graphics/core-graphics.factor | 3 +- basis/pango/fonts/fonts.factor | 3 +- basis/windows/advapi32/advapi32.factor | 3 +- basis/windows/ddk/winusb/winusb.factor | 3 +- .../directx/d3d11shader/d3d11shader.factor | 10 +- .../directx/d3d9types/d3d9types.factor | 3 +- basis/windows/directx/d3dcsx/d3dcsx.factor | 3 +- .../directx/d3dx9shader/d3dx9shader.factor | 6 +- basis/windows/directx/dcommon/dcommon.factor | 8 +- basis/windows/directx/dwrite/dwrite.factor | 126 ++++++++---------- .../windows/directx/dxgitype/dxgitype.factor | 30 ++--- basis/windows/directx/xapo/xapo.factor | 7 +- basis/windows/kernel32/kernel32.factor | 4 +- basis/windows/usp10/usp10.factor | 33 ++--- basis/x11/constants/constants.factor | 2 +- extra/chipmunk/ffi/ffi.factor | 6 +- extra/freetype/freetype.factor | 4 +- extra/libusb/libusb.factor | 3 +- extra/llvm/core/core.factor | 72 +++++----- extra/macho/macho.factor | 9 +- extra/tokyo/alien/tcadb/tcadb.factor | 2 +- extra/tokyo/alien/tcbdb/tcbdb.factor | 2 +- extra/tokyo/alien/tcrdb/tcrdb.factor | 2 +- extra/tokyo/alien/tctdb/tctdb.factor | 6 +- extra/tokyo/alien/tcutil/tcutil.factor | 2 +- unmaintained/cryptlib/libcl/libcl.factor | 2 +- unmaintained/pdf/libhpdf/libhpdf.factor | 2 +- 32 files changed, 200 insertions(+), 253 deletions(-) diff --git a/basis/alien/data/data-docs.factor b/basis/alien/data/data-docs.factor index e34b1ba4fa..d36a4d5fd2 100644 --- a/basis/alien/data/data-docs.factor +++ b/basis/alien/data/data-docs.factor @@ -105,7 +105,7 @@ $nl "Important guidelines for passing data in byte arrays:" { $subsections "byte-arrays-gc" } "C-style enumerated types are supported:" -{ $subsections POSTPONE: C-ENUM: POSTPONE: C-TYPED-ENUM: } +{ $subsections POSTPONE: C-ENUM: } "C types can be aliased for convenience and consistency with native library documentation:" { $subsections POSTPONE: TYPEDEF: } "A utility for defining " { $link "destructors" } " for deallocating memory:" diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index 4c5f5dbd6a..0891caa04a 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -4,7 +4,7 @@ USING: accessors alien alien.c-types alien.libraries arrays assocs classes combinators combinators.short-circuit compiler.units effects grouping kernel parser sequences splitting words fry locals lexer namespaces summary math -vocabs.parser ; +vocabs.parser words.constant ; IN: alien.parser : parse-c-type-name ( name -- word ) @@ -51,14 +51,17 @@ ERROR: *-in-c-type-name name ; dup "*" tail? [ *-in-c-type-name ] when ; -: CREATE-C-TYPE ( -- word ) - scan validate-c-type-name current-vocab create { +: (CREATE-C-TYPE) ( word -- word ) + validate-c-type-name current-vocab create { [ fake-definition ] [ set-word ] [ reset-c-type ] [ ] } cleave ; +: CREATE-C-TYPE ( -- word ) + scan (CREATE-C-TYPE) ; + > return-type-name CHAR: * suffix ; PRIVATE> +: define-enum-member ( word-string value -- next-value ) + [ create-in ] dip [ define-constant ] keep 1 + ; + +: parse-enum-member ( word-string value -- next-value ) + over "{" = + [ 2drop scan scan-object define-enum-member "}" expect ] + [ define-enum-member ] if ; + +: parse-enum-members ( counter -- ) + scan dup ";" = not + [ swap parse-enum-member parse-enum-members ] [ 2drop ] if ; + : scan-function-name ( -- return function ) scan-c-type scan parse-pointers ; diff --git a/basis/alien/syntax/syntax-docs.factor b/basis/alien/syntax/syntax-docs.factor index 2a8e1b2714..df20926480 100644 --- a/basis/alien/syntax/syntax-docs.factor +++ b/basis/alien/syntax/syntax-docs.factor @@ -58,28 +58,17 @@ HELP: TYPEDEF: { $notes "This word differs from " { $link typedef } " in that it runs at parse time, to ensure correct ordering of operations when loading source files. Words defined in source files are compiled before top-level forms are run, so if a source file defines C binding words and uses " { $link typedef } ", the type alias won't be available at compile time." } ; HELP: C-ENUM: -{ $syntax "C-ENUM: words... ;" } -{ $values { "words" "a sequence of word names" } } +{ $syntax "C-ENUM: type/f words... ;" } +{ $values { "type" "a name to typedef to int or f" } { "words" "a sequence of word names" } } { $description "Creates a sequence of word definitions in the current vocabulary. Each word pushes an integer according to the rules of C enums." } { $notes "This word emulates a C-style " { $snippet "enum" } " in Factor. While this feature can be used for any purpose, using integer constants is discouraged unless it is for interfacing with C libraries. Factor code should use " { $link "words.symbol" } " or " { $link "singletons" } " instead." } { $examples "Here is an example enumeration definition:" - { $code "C-ENUM: red { green 3 } blue ;" } + { $code "C-ENUM: color_t red { green 3 } blue ;" } "It is equivalent to the following series of definitions:" { $code "CONSTANT: red 0" "CONSTANT: green 3" "CONSTANT: blue 4" } } ; -HELP: C-TYPED-ENUM: -{ $syntax "C-TYPED-ENUM: foo_t FOO BAR { BAZ 4 } BOL ;" } -{ $description "Typedefs the first word as an int and creates a sequence of word definitions in the current vocabulary. Each word pushes an integer according to the rules of C enums." } -{ $notes "This word emulates a C-style " { $snippet "enum" } " in Factor. While this feature can be used for any purpose, using integer constants is discouraged unless it is for interfacing with C libraries. Factor code should use " { $link "words.symbol" } " or " { $link "singletons" } " instead." } -{ $examples - "Here is an example enumeration definition:" - { $code "C-TYPED-ENUM: color_t red { green 3 } blue ;" } - "It is equivalent to the following series of definitions:" - { $code "TYPEDEF: int color_t" "CONSTANT: red 0" "CONSTANT: green 3" "CONSTANT: blue 4" } -} ; - HELP: C-TYPE: { $syntax "C-TYPE: type" } { $values { "type" "a new C type" } } diff --git a/basis/alien/syntax/syntax.factor b/basis/alien/syntax/syntax.factor index f7cff225c5..00148a82d4 100644 --- a/basis/alien/syntax/syntax.factor +++ b/basis/alien/syntax/syntax.factor @@ -24,19 +24,11 @@ SYNTAX: CALLBACK: SYNTAX: TYPEDEF: scan-c-type CREATE-C-TYPE dup save-location typedef ; -: define-enum-members ( counter -- ) - scan dup ";" = not [ - dup "{" = - [ 2drop scan create-in scan-word [ define-constant ] keep "}" expect ] - [ create-in swap [ define-constant ] keep ] - if 1 + define-enum-members - ] [ 2drop ] if ; - -SYNTAX: C-ENUM: 0 define-enum-members ; - -SYNTAX: C-TYPED-ENUM: - int CREATE-C-TYPE dup save-location typedef - 0 define-enum-members ; +SYNTAX: C-ENUM: + scan dup "f" = + [ drop ] + [ (CREATE-C-TYPE) dup save-location int swap typedef ] if + 0 parse-enum-members ; SYNTAX: C-TYPE: void CREATE-C-TYPE typedef ; diff --git a/basis/cairo/ffi/ffi.factor b/basis/cairo/ffi/ffi.factor index c4700d2dad..42b281c33c 100644 --- a/basis/cairo/ffi/ffi.factor +++ b/basis/cairo/ffi/ffi.factor @@ -44,8 +44,7 @@ TYPEDEF: void* cairo_destroy_func_t STRUCT: cairo_user_data_key_t { unused int } ; -TYPEDEF: int cairo_status_t -C-ENUM: +C-ENUM: cairo_status_t CAIRO_STATUS_SUCCESS CAIRO_STATUS_NO_MEMORY CAIRO_STATUS_INVALID_RESTORE @@ -125,8 +124,7 @@ FUNCTION: void cairo_pop_group_to_source ( cairo_t* cr ) ; ! Modify state -TYPEDEF: int cairo_operator_t -C-ENUM: +C-ENUM: cairo_operator_t CAIRO_OPERATOR_CLEAR CAIRO_OPERATOR_SOURCE @@ -163,8 +161,7 @@ cairo_set_source_surface ( cairo_t* cr, cairo_surface_t* surface, double x, doub FUNCTION: void cairo_set_tolerance ( cairo_t* cr, double tolerance ) ; -TYPEDEF: int cairo_antialias_t -C-ENUM: +C-ENUM: cairo_antialias_t CAIRO_ANTIALIAS_DEFAULT CAIRO_ANTIALIAS_NONE CAIRO_ANTIALIAS_GRAY @@ -173,8 +170,7 @@ C-ENUM: FUNCTION: void cairo_set_antialias ( cairo_t* cr, cairo_antialias_t antialias ) ; -TYPEDEF: int cairo_fill_rule_t -C-ENUM: +C-ENUM: cairo_fill_rule_t CAIRO_FILL_RULE_WINDING CAIRO_FILL_RULE_EVEN_ODD ; @@ -184,8 +180,7 @@ cairo_set_fill_rule ( cairo_t* cr, cairo_fill_rule_t fill_rule ) ; FUNCTION: void cairo_set_line_width ( cairo_t* cr, double width ) ; -TYPEDEF: int cairo_line_cap_t -C-ENUM: +C-ENUM: cairo_line_cap_t CAIRO_LINE_CAP_BUTT CAIRO_LINE_CAP_ROUND CAIRO_LINE_CAP_SQUARE ; @@ -193,8 +188,7 @@ C-ENUM: FUNCTION: void cairo_set_line_cap ( cairo_t* cr, cairo_line_cap_t line_cap ) ; -TYPEDEF: int cairo_line_join_t -C-ENUM: +C-ENUM: cairo_line_join_t CAIRO_LINE_JOIN_MITER CAIRO_LINE_JOIN_ROUND CAIRO_LINE_JOIN_BEVEL ; @@ -379,35 +373,30 @@ STRUCT: cairo_font_extents_t { max_x_advance double } { max_y_advance double } ; -TYPEDEF: int cairo_font_slant_t -C-ENUM: +C-ENUM: cairo_font_slant_t CAIRO_FONT_SLANT_NORMAL CAIRO_FONT_SLANT_ITALIC CAIRO_FONT_SLANT_OBLIQUE ; -TYPEDEF: int cairo_font_weight_t -C-ENUM: +C-ENUM: cairo_font_weight_t CAIRO_FONT_WEIGHT_NORMAL CAIRO_FONT_WEIGHT_BOLD ; -TYPEDEF: int cairo_subpixel_order_t -C-ENUM: +C-ENUM: cairo_subpixel_order_t CAIRO_SUBPIXEL_ORDER_DEFAULT CAIRO_SUBPIXEL_ORDER_RGB CAIRO_SUBPIXEL_ORDER_BGR CAIRO_SUBPIXEL_ORDER_VRGB CAIRO_SUBPIXEL_ORDER_VBGR ; -TYPEDEF: int cairo_hint_style_t -C-ENUM: +C-ENUM: cairo_hint_Style_t CAIRO_HINT_STYLE_DEFAULT CAIRO_HINT_STYLE_NONE CAIRO_HINT_STYLE_SLIGHT CAIRO_HINT_STYLE_MEDIUM CAIRO_HINT_STYLE_FULL ; -TYPEDEF: int cairo_hint_metrics_t -C-ENUM: +C-ENUM: cairo_hint_metrics_t CAIRO_HINT_METRICS_DEFAULT CAIRO_HINT_METRICS_OFF CAIRO_HINT_METRICS_ON ; @@ -527,8 +516,7 @@ cairo_font_face_get_reference_count ( cairo_font_face_t* font_face ) ; FUNCTION: cairo_status_t cairo_font_face_status ( cairo_font_face_t* font_face ) ; -TYPEDEF: int cairo_font_type_t -C-ENUM: +C-ENUM: cairo_font_type_t CAIRO_FONT_TYPE_TOY CAIRO_FONT_TYPE_FT CAIRO_FONT_TYPE_WIN32 @@ -640,8 +628,7 @@ cairo_get_target ( cairo_t* cr ) ; FUNCTION: cairo_surface_t* cairo_get_group_target ( cairo_t* cr ) ; -TYPEDEF: int cairo_path_data_type_t -C-ENUM: +C-ENUM: cairo_path_data_type_t CAIRO_PATH_MOVE_TO CAIRO_PATH_LINE_TO CAIRO_PATH_CURVE_TO diff --git a/basis/core-graphics/core-graphics.factor b/basis/core-graphics/core-graphics.factor index 1b7693da14..92925f5d64 100644 --- a/basis/core-graphics/core-graphics.factor +++ b/basis/core-graphics/core-graphics.factor @@ -6,8 +6,7 @@ images images.memory core-graphics.types core-foundation.utilities opengl.gl literals ; IN: core-graphics -! CGImageAlphaInfo -C-ENUM: +C-ENUM: CGImageAlphaInfo kCGImageAlphaNone kCGImageAlphaPremultipliedLast kCGImageAlphaPremultipliedFirst diff --git a/basis/pango/fonts/fonts.factor b/basis/pango/fonts/fonts.factor index c2a7ef128d..7ea4e0a0c2 100644 --- a/basis/pango/fonts/fonts.factor +++ b/basis/pango/fonts/fonts.factor @@ -8,8 +8,7 @@ IN: pango.fonts LIBRARY: pango -TYPEDEF: int PangoStyle -C-ENUM: +C-ENUM: PangoStyle PANGO_STYLE_NORMAL PANGO_STYLE_OBLIQUE PANGO_STYLE_ITALIC ; diff --git a/basis/windows/advapi32/advapi32.factor b/basis/windows/advapi32/advapi32.factor index 72769971e6..1e6a1c0b0b 100755 --- a/basis/windows/advapi32/advapi32.factor +++ b/basis/windows/advapi32/advapi32.factor @@ -146,8 +146,7 @@ CONSTANT: TokenSessionReference 14 CONSTANT: TokenSandBoxInert 15 ! } TOKEN_INFORMATION_CLASS; -TYPEDEF: DWORD ACCESS_MODE -C-ENUM: +C-ENUM: ACCESS_MODE NOT_USED_ACCESS GRANT_ACCESS SET_ACCESS diff --git a/basis/windows/ddk/winusb/winusb.factor b/basis/windows/ddk/winusb/winusb.factor index 3b98e7e8ca..5e43b7f884 100644 --- a/basis/windows/ddk/winusb/winusb.factor +++ b/basis/windows/ddk/winusb/winusb.factor @@ -22,12 +22,11 @@ STRUCT: USB_INTERFACE_DESCRIPTOR { iInterface UCHAR } ; TYPEDEF: USB_INTERFACE_DESCRIPTOR* PUSB_INTERFACE_DESCRIPTOR -C-ENUM: +C-ENUM: USBD_PIPE_TYPE UsbdPipeTypeControl UsbdPipeTypeIsochronous UsbdPipeTypeBulk UsbdPipeTypeInterrupt ; -TYPEDEF: int USBD_PIPE_TYPE STRUCT: WINUSB_PIPE_INFORMATION { PipeType USBD_PIPE_TYPE } diff --git a/basis/windows/directx/d3d11shader/d3d11shader.factor b/basis/windows/directx/d3d11shader/d3d11shader.factor index 02ab9bb177..08146300f2 100644 --- a/basis/windows/directx/d3d11shader/d3d11shader.factor +++ b/basis/windows/directx/d3d11shader/d3d11shader.factor @@ -24,11 +24,11 @@ CONSTANT: D3D11_RETURN_TYPE_DOUBLE 7 CONSTANT: D3D11_RETURN_TYPE_CONTINUED 8 TYPEDEF: int D3D11_RESOURCE_RETURN_TYPE -C-ENUM: D3D11_CT_CBUFFER - D3D11_CT_TBUFFER - D3D11_CT_INTERFACE_POINTERS - D3D11_CT_RESOURCE_BIND_INFO ; -TYPEDEF: int D3D11_CBUFFER_TYPE +C-ENUM: D3D11_CBUFFER_TYPE + D3D11_CT_CBUFFER + D3D11_CT_TBUFFER + D3D11_CT_INTERFACE_POINTERS + D3D11_CT_RESOURCE_BIND_INFO ; TYPEDEF: D3D11_CBUFFER_TYPE* LPD3D11_CBUFFER_TYPE STRUCT: D3D11_SIGNATURE_PARAMETER_DESC diff --git a/basis/windows/directx/d3d9types/d3d9types.factor b/basis/windows/directx/d3d9types/d3d9types.factor index 618d3c79e5..ad2d4a8279 100644 --- a/basis/windows/directx/d3d9types/d3d9types.factor +++ b/basis/windows/directx/d3d9types/d3d9types.factor @@ -502,8 +502,7 @@ CONSTANT: MAXD3DDECLUSAGE 13 CONSTANT: MAXD3DDECLUSAGEINDEX 15 CONSTANT: MAXD3DDECLLENGTH 64 -TYPEDEF: int D3DDECLMETHOD -C-ENUM: +C-ENUM: D3DDECLMETHOD D3DDECLMETHOD_DEFAULT D3DDECLMETHOD_PARTIALU D3DDECLMETHOD_PARTIALV diff --git a/basis/windows/directx/d3dcsx/d3dcsx.factor b/basis/windows/directx/d3dcsx/d3dcsx.factor index c2d3af8cf3..c6d0105fdc 100644 --- a/basis/windows/directx/d3dcsx/d3dcsx.factor +++ b/basis/windows/directx/d3dcsx/d3dcsx.factor @@ -48,10 +48,9 @@ COM-INTERFACE: ID3DX11FFT IUnknown {b3f7a938-4c93-4310-a675-b30d6de50553} HRESULT ForwardTransform ( ID3D11UnorderedAccessView* pInputBuffer, ID3D11UnorderedAccessView** ppOutputBuffer ) HRESULT InverseTransform ( ID3D11UnorderedAccessView* pInputBuffer, ID3D11UnorderedAccessView** ppOutputBuffer ) ; -C-ENUM: +C-ENUM: D3DX11_FFT_DATA_TYPE D3DX11_FFT_DATA_TYPE_REAL D3DX11_FFT_DATA_TYPE_COMPLEX ; -TYPEDEF: int D3DX11_FFT_DATA_TYPE CONSTANT: D3DX11_FFT_DIM_MASK_1D 1 CONSTANT: D3DX11_FFT_DIM_MASK_2D 3 diff --git a/basis/windows/directx/d3dx9shader/d3dx9shader.factor b/basis/windows/directx/d3dx9shader/d3dx9shader.factor index 12ba902fc5..4490acc7c9 100644 --- a/basis/windows/directx/d3dx9shader/d3dx9shader.factor +++ b/basis/windows/directx/d3dx9shader/d3dx9shader.factor @@ -41,22 +41,20 @@ STRUCT: D3DXSEMANTIC { UsageIndex UINT } ; TYPEDEF: D3DXSEMANTIC* LPD3DXSEMANTIC -C-ENUM: +C-ENUM: D3DXREGISTER_SET D3DXRS_BOOL D3DXRS_INT4 D3DXRS_FLOAT4 D3DXRS_SAMPLER ; -TYPEDEF: int D3DXREGISTER_SET TYPEDEF: D3DXREGISTER_SET* LPD3DXREGISTER_SET -C-ENUM: +C-ENUM: D3DXPARAMETER_CLASS D3DXPC_SCALAR D3DXPC_VECTOR D3DXPC_MATRIX_ROWS D3DXPC_MATRIX_COLUMNS D3DXPC_OBJECT D3DXPC_STRUCT ; -TYPEDEF: int D3DXPARAMETER_CLASS TYPEDEF: D3DXPARAMETER_CLASS* LPD3DXPARAMETER_CLASS C-ENUM: diff --git a/basis/windows/directx/dcommon/dcommon.factor b/basis/windows/directx/dcommon/dcommon.factor index 3b80bd4509..32d69f924c 100644 --- a/basis/windows/directx/dcommon/dcommon.factor +++ b/basis/windows/directx/dcommon/dcommon.factor @@ -1,7 +1,7 @@ USING: alien.c-types alien.syntax ; IN: windows.directx.dcommon -C-ENUM: DWRITE_MEASURING_MODE_NATURAL - DWRITE_MEASURING_MODE_GDI_CLASSIC - DWRITE_MEASURING_MODE_GDI_NATURAL ; -TYPEDEF: int DWRITE_MEASURING_MODE +C-ENUM: DWRITE_MEASURING_MODE + DWRITE_MEASURING_MODE_NATURAL + DWRITE_MEASURING_MODE_GDI_CLASSIC + DWRITE_MEASURING_MODE_GDI_NATURAL ; diff --git a/basis/windows/directx/dwrite/dwrite.factor b/basis/windows/directx/dwrite/dwrite.factor index 3e4167ebad..3d635a0dc4 100644 --- a/basis/windows/directx/dwrite/dwrite.factor +++ b/basis/windows/directx/dwrite/dwrite.factor @@ -5,7 +5,7 @@ IN: windows.directx.dwrite LIBRARY: dwrite -C-ENUM: +C-ENUM: DWRITE_FONT_FILE_TYPE DWRITE_FONT_FILE_TYPE_UNKNOWN DWRITE_FONT_FILE_TYPE_CFF DWRITE_FONT_FILE_TYPE_TRUETYPE @@ -14,9 +14,8 @@ C-ENUM: DWRITE_FONT_FILE_TYPE_TYPE1_PFB DWRITE_FONT_FILE_TYPE_VECTOR DWRITE_FONT_FILE_TYPE_BITMAP ; -TYPEDEF: int DWRITE_FONT_FILE_TYPE -C-ENUM: +C-ENUM: DWRITE_FONT_FACE_TYPE DWRITE_FONT_FACE_TYPE_CFF DWRITE_FONT_FACE_TYPE_TRUETYPE DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION @@ -24,51 +23,49 @@ C-ENUM: DWRITE_FONT_FACE_TYPE_VECTOR DWRITE_FONT_FACE_TYPE_BITMAP DWRITE_FONT_FACE_TYPE_UNKNOWN ; -TYPEDEF: int DWRITE_FONT_FACE_TYPE -CONSTANT: DWRITE_FONT_SIMULATIONS_NONE 0 -CONSTANT: DWRITE_FONT_SIMULATIONS_BOLD 1 -CONSTANT: DWRITE_FONT_SIMULATIONS_OBLIQUE 2 -TYPEDEF: int DWRITE_FONT_SIMULATIONS +C-ENUM: DWRITE_FONT_SIMULATIONS + DWRITE_FONT_SIMULATIONS_NONE + DWRITE_FONT_SIMULATIONS_BOLD + DWRITE_FONT_SIMULATIONS_OBLIQUE ; -CONSTANT: DWRITE_FONT_WEIGHT_THIN 100 -CONSTANT: DWRITE_FONT_WEIGHT_EXTRA_LIGHT 200 -CONSTANT: DWRITE_FONT_WEIGHT_ULTRA_LIGHT 200 -CONSTANT: DWRITE_FONT_WEIGHT_LIGHT 300 -CONSTANT: DWRITE_FONT_WEIGHT_NORMAL 400 -CONSTANT: DWRITE_FONT_WEIGHT_REGULAR 400 -CONSTANT: DWRITE_FONT_WEIGHT_MEDIUM 500 -CONSTANT: DWRITE_FONT_WEIGHT_DEMI_BOLD 600 -CONSTANT: DWRITE_FONT_WEIGHT_SEMI_BOLD 600 -CONSTANT: DWRITE_FONT_WEIGHT_BOLD 700 -CONSTANT: DWRITE_FONT_WEIGHT_EXTRA_BOLD 800 -CONSTANT: DWRITE_FONT_WEIGHT_ULTRA_BOLD 800 -CONSTANT: DWRITE_FONT_WEIGHT_BLACK 900 -CONSTANT: DWRITE_FONT_WEIGHT_HEAVY 900 -CONSTANT: DWRITE_FONT_WEIGHT_EXTRA_BLACK 950 -CONSTANT: DWRITE_FONT_WEIGHT_ULTRA_BLACK 950 -TYPEDEF: int DWRITE_FONT_WEIGHT +C-ENUM: DWRITE_FONT_WEIGHT + { DWRITE_FONT_WEIGHT_THIN 100 } + { DWRITE_FONT_WEIGHT_EXTRA_LIGHT 200 } + { DWRITE_FONT_WEIGHT_ULTRA_LIGHT 200 } + { DWRITE_FONT_WEIGHT_LIGHT 300 } + { DWRITE_FONT_WEIGHT_NORMAL 400 } + { DWRITE_FONT_WEIGHT_REGULAR 400 } + { DWRITE_FONT_WEIGHT_MEDIUM 500 } + { DWRITE_FONT_WEIGHT_DEMI_BOLD 600 } + { DWRITE_FONT_WEIGHT_SEMI_BOLD 600 } + { DWRITE_FONT_WEIGHT_BOLD 700 } + { DWRITE_FONT_WEIGHT_EXTRA_BOLD 800 } + { DWRITE_FONT_WEIGHT_ULTRA_BOLD 800 } + { DWRITE_FONT_WEIGHT_BLACK 900 } + { DWRITE_FONT_WEIGHT_HEAVY 900 } + { DWRITE_FONT_WEIGHT_EXTRA_BLACK 950 } + { DWRITE_FONT_WEIGHT_ULTRA_BLACK 950 } ; -CONSTANT: DWRITE_FONT_STRETCH_UNDEFINED 0 -CONSTANT: DWRITE_FONT_STRETCH_ULTRA_CONDENSED 1 -CONSTANT: DWRITE_FONT_STRETCH_EXTRA_CONDENSED 2 -CONSTANT: DWRITE_FONT_STRETCH_CONDENSED 3 -CONSTANT: DWRITE_FONT_STRETCH_SEMI_CONDENSED 4 -CONSTANT: DWRITE_FONT_STRETCH_NORMAL 5 -CONSTANT: DWRITE_FONT_STRETCH_MEDIUM 5 -CONSTANT: DWRITE_FONT_STRETCH_SEMI_EXPANDED 6 -CONSTANT: DWRITE_FONT_STRETCH_EXPANDED 7 -CONSTANT: DWRITE_FONT_STRETCH_EXTRA_EXPANDED 8 -CONSTANT: DWRITE_FONT_STRETCH_ULTRA_EXPANDED 9 -TYPEDEF: int DWRITE_FONT_STRETCH +C-ENUM: DWRITE_FONT_STRETCH + { DWRITE_FONT_STRETCH_UNDEFINED 0 } + { DWRITE_FONT_STRETCH_ULTRA_CONDENSED 1 } + { DWRITE_FONT_STRETCH_EXTRA_CONDENSED 2 } + { DWRITE_FONT_STRETCH_CONDENSED 3 } + { DWRITE_FONT_STRETCH_SEMI_CONDENSED 4 } + { DWRITE_FONT_STRETCH_NORMAL 5 } + { DWRITE_FONT_STRETCH_MEDIUM 5 } + { DWRITE_FONT_STRETCH_SEMI_EXPANDED 6 } + { DWRITE_FONT_STRETCH_EXPANDED 7 } + { DWRITE_FONT_STRETCH_EXTRA_EXPANDED 8 } + { DWRITE_FONT_STRETCH_ULTRA_EXPANDED 9 } ; -C-ENUM: +C-ENUM: DWRITE_FONT_STYLE DWRITE_FONT_STYLE_NORMAL DWRITE_FONT_STYLE_OBLIQUE DWRITE_FONT_STYLE_ITALIC ; -TYPEDEF: int DWRITE_FONT_STYLE -C-ENUM: +C-ENUM: DWRITE_INFORMATIONAL_STRING_ID DWRITE_INFORMATIONAL_STRING_NONE DWRITE_INFORMATIONAL_STRING_COPYRIGHT_NOTICE DWRITE_INFORMATIONAL_STRING_VERSION_STRINGS @@ -85,7 +82,6 @@ C-ENUM: DWRITE_INFORMATIONAL_STRING_PREFERRED_FAMILY_NAMES DWRITE_INFORMATIONAL_STRING_PREFERRED_SUBFAMILY_NAMES DWRITE_INFORMATIONAL_STRING_SAMPLE_TEXT ; -TYPEDEF: int DWRITE_INFORMATIONAL_STRING_ID STRUCT: DWRITE_FONT_METRICS { designUnitsPerEm USHORT } @@ -112,10 +108,9 @@ STRUCT: DWRITE_GLYPH_OFFSET { advanceOffset FLOAT } { ascenderOffset FLOAT } ; -C-ENUM: +C-ENUM: DWRITE_FACTORY_TYPE DWRITE_FACTORY_TYPE_SHARED DWRITE_FACTORY_TYPE_ISOLATED ; -TYPEDEF: int DWRITE_FACTORY_TYPE C-TYPE: IDWriteFontFileStream @@ -138,14 +133,12 @@ COM-INTERFACE: IDWriteFontFile IUnknown {739d886a-cef5-47dc-8769-1a8b41bebbb0} HRESULT GetLoader ( IDWriteFontFileLoader** fontFileLoader ) HRESULT Analyze ( BOOL* isSupportedFontType, DWRITE_FONT_FILE_TYPE* fontFileType, DWRITE_FONT_FACE_TYPE* fontFaceType, UINT32* numberOfFaces ) ; -TYPEDEF: int DWRITE_PIXEL_GEOMETRY -C-ENUM: +C-ENUM: DWRITE_PIXEL_GEOMETRY DWRITE_PIXEL_GEOMETRY_FLAT DWRITE_PIXEL_GEOMETRY_RGB DWRITE_PIXEL_GEOMETRY_BGR ; -TYPEDEF: int DWRITE_RENDERING_MODE -C-ENUM: +C-ENUM: DWRITE_RENDERING_MODE DWRITE_RENDERING_MODE_DEFAULT DWRITE_RENDERING_MODE_ALIASED DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC @@ -240,39 +233,32 @@ COM-INTERFACE: IDWriteFont IUnknown {acd16696-8c14-4f5d-877e-fe3fc1d32737} HRESULT HasCharacter ( UINT32 unicodeValue, BOOL* exists ) HRESULT CreateFontFace ( IDWriteFontFace** fontFace ) ; -TYPEDEF: int DWRITE_READING_DIRECTION -C-ENUM: +C-ENUM: DWRITE_READING_DRECTION DWRITE_READING_DIRECTION_LEFT_TO_RIGHT DWRITE_READING_DIRECTION_RIGHT_TO_LEFT ; -TYPEDEF: int DWRITE_FLOW_DIRECTION -C-ENUM: +C-ENUM: DWRITE_FLOW_DIRECTION DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM ; -TYPEDEF: int DWRITE_TEXT_ALIGNMENT -C-ENUM: +C-ENUM: DWRITE_TEXT_ALIGNMENT DWRITE_TEXT_ALIGNMENT_LEADING DWRITE_TEXT_ALIGNMENT_TRAILING DWRITE_TEXT_ALIGNMENT_CENTER ; -TYPEDEF: int DWRITE_PARAGRAPH_ALIGNMENT -C-ENUM: +C-ENUM: DWRITE_PARAGRAPH_ALIGNMENT DWRITE_PARAGRAPH_ALIGNMENT_NEAR DWRITE_PARAGRAPH_ALIGNMENT_FAR DWRITE_PARAGRAPH_ALIGNMENT_CENTER ; -TYPEDEF: int DWRITE_WORD_WRAPPING -C-ENUM: +C-ENUM: DWRITE_WORD_WRAPPING DWRITE_WORD_WRAPPING_WRAP DWRITE_WORD_WRAPPING_NO_WRAP ; -TYPEDEF: int DWRITE_LINE_SPACING_METHOD -C-ENUM: +C-ENUM: DWRITE_LINE_SPACING_METHOD DWRITE_LINE_SPACING_METHOD_DEFAULT DWRITE_LINE_SPACING_METHOD_UNIFORM ; -TYPEDEF: int DWRITE_TRIMMING_GRANULARITY -C-ENUM: +C-ENUM: DWRITE_TRIMMING_GRANULARITY DWRITE_TRIMMING_GRANULARITY_NONE DWRITE_TRIMMING_GRANULARITY_CHARACTER DWRITE_TRIMMING_GRANULARITY_WORD ; @@ -410,31 +396,29 @@ COM-INTERFACE: IDWriteTypography IUnknown {55f1112b-1dc2-4b3c-9541-f46894ed85b6} UINT32 GetFontFeatureCount ( ) HRESULT GetFontFeature ( UINT32 fontFeatureIndex, DWRITE_FONT_FEATURE* fontFeature ) ; -CONSTANT: DWRITE_SCRIPT_SHAPES_DEFAULT 0 -CONSTANT: DWRITE_SCRIPT_SHAPES_NO_VISUAL 1 -TYPEDEF: int DWRITE_SCRIPT_SHAPES +C-ENUM: DWRITE_SCRIPT_SHAPES + DWRITE_SCRIPT_SHAPES_DEFAULT + DWRITE_SCRIPT_SHAPES_NO_VISUAL ; STRUCT: DWRITE_SCRIPT_ANALYSIS { script USHORT } { shapes DWRITE_SCRIPT_SHAPES } ; -C-ENUM: +C-ENUM: DWRITE_BREAK_CONDITION DWRITE_BREAK_CONDITION_NEUTRAL DWRITE_BREAK_CONDITION_CAN_BREAK DWRITE_BREAK_CONDITION_MAY_NOT_BREAK DWRITE_BREAK_CONDITION_MUST_BREAK ; -TYPEDEF: int DWRITE_BREAK_CONDITION STRUCT: DWRITE_LINE_BREAKPOINT { data BYTE } ; -C-ENUM: +C-ENUM: DWRITE_NUMBER_SUBSTITUTION_METHOD DWRITE_NUMBER_SUBSTITUTION_METHOD_FROM_CULTURE DWRITE_NUMBER_SUBSTITUTION_METHOD_CONTEXTUAL DWRITE_NUMBER_SUBSTITUTION_METHOD_NONE DWRITE_NUMBER_SUBSTITUTION_METHOD_NATIONAL DWRITE_NUMBER_SUBSTITUTION_METHOD_TRADITIONAL ; -TYPEDEF: int DWRITE_NUMBER_SUBSTITUTION_METHOD COM-INTERFACE: IDWriteNumberSubstitution IUnknown {14885CC9-BAB0-4f90-B6ED-5C366A2CD03D} ; @@ -628,9 +612,9 @@ COM-INTERFACE: IDWriteGdiInterop IUnknown {1edd9491-9853-4299-898f-6432983b6f3a} HRESULT CreateFontFaceFromHdc ( HDC hdc, IDWriteFontFace** fontFace ) HRESULT CreateBitmapRenderTarget ( HDC hdc, UINT32 width, UINT32 height, IDWriteBitmapRenderTarget** renderTarget ) ; -C-ENUM: DWRITE_TEXTURE_ALIASED_1x1 - DWRITE_TEXTURE_CLEARTYPE_3x1 ; -TYPEDEF: int DWRITE_TEXTURE_TYPE +C-ENUM: DWRITE_TEXTURE_TYPE + DWRITE_TEXTURE_ALIASED_1x1 + DWRITE_TEXTURE_CLEARTYPE_3x1 ; CONSTANT: DWRITE_ALPHA_MAX 255 diff --git a/basis/windows/directx/dxgitype/dxgitype.factor b/basis/windows/directx/dxgitype/dxgitype.factor index 0b318f7af1..bdab49e652 100644 --- a/basis/windows/directx/dxgitype/dxgitype.factor +++ b/basis/windows/directx/dxgitype/dxgitype.factor @@ -47,23 +47,23 @@ STRUCT: DXGI_RATIONAL { Numerator UINT } { Denominator UINT } ; -C-ENUM: DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED - DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE - DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST - DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST ; -TYPEDEF: int DXGI_MODE_SCANLINE_ORDER +C-ENUM: DXGI_MODE_SCANLINE_ORDER + DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED + DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE + DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST + DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST ; -C-ENUM: DXGI_MODE_SCALING_UNSPECIFIED - DXGI_MODE_SCALING_CENTERED - DXGI_MODE_SCALING_STRETCHED ; -TYPEDEF: int DXGI_MODE_SCALING +C-ENUM: DXGI_MODE_SCALING + DXGI_MODE_SCALING_UNSPECIFIED + DXGI_MODE_SCALING_CENTERED + DXGI_MODE_SCALING_STRETCHED ; -C-ENUM: DXGI_MODE_ROTATION_UNSPECIFIED - DXGI_MODE_ROTATION_IDENTITY - DXGI_MODE_ROTATION_ROTATE90 - DXGI_MODE_ROTATION_ROTATE180 - DXGI_MODE_ROTATION_ROTATE270 ; -TYPEDEF: int DXGI_MODE_ROTATION +C-ENUM: DXGI_MODE_ROTATION + DXGI_MODE_ROTATION_UNSPECIFIED + DXGI_MODE_ROTATION_IDENTITY + DXGI_MODE_ROTATION_ROTATE90 + DXGI_MODE_ROTATION_ROTATE180 + DXGI_MODE_ROTATION_ROTATE270 ; STRUCT: DXGI_MODE_DESC { Width UINT } diff --git a/basis/windows/directx/xapo/xapo.factor b/basis/windows/directx/xapo/xapo.factor index 5878af80e0..f071ea08d5 100644 --- a/basis/windows/directx/xapo/xapo.factor +++ b/basis/windows/directx/xapo/xapo.factor @@ -39,10 +39,9 @@ STRUCT: XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS { pFormat WAVEFORMATEX* } { MaxFrameCount UINT32 } ; -C-ENUM: - XAPO_BUFFER_SILENT - XAPO_BUFFER_VALID ; -TYPEDEF: int XAPO_BUFFER_FLAGS +C-ENUM: XAPO_BUFFER_FLAGS + XAPO_BUFFER_SILENT + XAPO_BUFFER_VALID ; STRUCT: XAPO_PROCESS_BUFFER_PARAMETERS { pBuffer void* } diff --git a/basis/windows/kernel32/kernel32.factor b/basis/windows/kernel32/kernel32.factor index c2622cbf48..a7c460f525 100644 --- a/basis/windows/kernel32/kernel32.factor +++ b/basis/windows/kernel32/kernel32.factor @@ -199,7 +199,7 @@ CONSTANT: THREAD_PRIORITY_LOWEST -2 CONSTANT: THREAD_PRIORITY_NORMAL 0 CONSTANT: THREAD_PRIORITY_TIME_CRITICAL 15 -C-ENUM: +C-ENUM: COMPUTER_NAME_FORMAT ComputerNameNetBIOS ComputerNameDnsHostname ComputerNameDnsDomain @@ -210,8 +210,6 @@ C-ENUM: ComputerNamePhysicalDnsFullyQualified ComputerNameMax ; -TYPEDEF: uint COMPUTER_NAME_FORMAT - STRUCT: OVERLAPPED { internal UINT_PTR } { internal-high UINT_PTR } diff --git a/basis/windows/usp10/usp10.factor b/basis/windows/usp10/usp10.factor index 1c33aaf940..21b4f77434 100644 --- a/basis/windows/usp10/usp10.factor +++ b/basis/windows/usp10/usp10.factor @@ -37,22 +37,23 @@ FUNCTION: HRESULT ScriptLayout ( int* piLogicalToVisual ) ; -C-ENUM: SCRIPT_JUSTIFY_NONE -SCRIPT_JUSTIFY_ARABIC_BLANK -SCRIPT_JUSTIFY_CHARACTER -SCRIPT_JUSTIFY_RESERVED1 -SCRIPT_JUSTIFY_BLANK -SCRIPT_JUSTIFY_RESERVED2 -SCRIPT_JUSTIFY_RESERVED3 -SCRIPT_JUSTIFY_ARABIC_NORMAL -SCRIPT_JUSTIFY_ARABIC_KASHIDA -SCRIPT_JUSTIFY_ALEF -SCRIPT_JUSTIFY_HA -SCRIPT_JUSTIFY_RA -SCRIPT_JUSTIFY_BA -SCRIPT_JUSTIFY_BARA -SCRIPT_JUSTIFY_SEEN -SCRIPT_JUSTIFFY_RESERVED4 ; +C-ENUM: f + SCRIPT_JUSTIFY_NONE + SCRIPT_JUSTIFY_ARABIC_BLANK + SCRIPT_JUSTIFY_CHARACTER + SCRIPT_JUSTIFY_RESERVED1 + SCRIPT_JUSTIFY_BLANK + SCRIPT_JUSTIFY_RESERVED2 + SCRIPT_JUSTIFY_RESERVED3 + SCRIPT_JUSTIFY_ARABIC_NORMAL + SCRIPT_JUSTIFY_ARABIC_KASHIDA + SCRIPT_JUSTIFY_ALEF + SCRIPT_JUSTIFY_HA + SCRIPT_JUSTIFY_RA + SCRIPT_JUSTIFY_BA + SCRIPT_JUSTIFY_BARA + SCRIPT_JUSTIFY_SEEN + SCRIPT_JUSTIFFY_RESERVED4 ; STRUCT: SCRIPT_VISATTR { flags WORD } ; diff --git a/basis/x11/constants/constants.factor b/basis/x11/constants/constants.factor index 763cddaaf1..64c7e2f8dd 100644 --- a/basis/x11/constants/constants.factor +++ b/basis/x11/constants/constants.factor @@ -406,4 +406,4 @@ CONSTANT: MSBFirst 1 ! * EXTENDED WINDOW MANAGER HINTS ! ***************************************************************** -C-ENUM: _NET_WM_STATE_REMOVE _NET_WM_STATE_ADD _NET_WM_STATE_TOGGLE ; +C-ENUM: f _NET_WM_STATE_REMOVE _NET_WM_STATE_ADD _NET_WM_STATE_TOGGLE ; diff --git a/extra/chipmunk/ffi/ffi.factor b/extra/chipmunk/ffi/ffi.factor index 0142b57a77..7e46baf551 100644 --- a/extra/chipmunk/ffi/ffi.factor +++ b/extra/chipmunk/ffi/ffi.factor @@ -348,12 +348,11 @@ STRUCT: cpSegmentQueryInfo { t cpFloat } { n cpVect } ; -C-ENUM: +C-ENUM: cpShapeType CP_CIRCLE_SHAPE CP_SEGMENT_SHAPE CP_POLY_SHAPE CP_NUM_SHAPES ; -TYPEDEF: int cpShapeType CALLBACK: cpBB cacheData_cb ( cpShape* shape, cpVect p, cpVect rot ) ; CALLBACK: void destroy_cb ( cpShape* shape ) ; @@ -482,11 +481,10 @@ STRUCT: cpContact FUNCTION: cpContact* cpContactInit ( cpContact* con, cpVect p, cpVect n, cpFloat dist, cpHashValue hash ) ; -C-ENUM: +C-ENUM: cpArbiterState cpArbiterStateNormal cpArbiterStateFirstColl cpArbiterStateIgnore ; -TYPEDEF: int cpArbiterState STRUCT: cpArbiter { numContacts int } diff --git a/extra/freetype/freetype.factor b/extra/freetype/freetype.factor index d131d2eb35..588f1670c2 100644 --- a/extra/freetype/freetype.factor +++ b/extra/freetype/freetype.factor @@ -176,14 +176,14 @@ FUNCTION: FT_Error FT_Set_Char_Size ( face* face, FT_F26Dot6 char_width, FT_F26D FUNCTION: FT_Error FT_Load_Char ( face* face, FT_ULong charcode, FT_Int32 load_flags ) ; -C-ENUM: +C-ENUM: f FT_RENDER_MODE_NORMAL FT_RENDER_MODE_LIGHT FT_RENDER_MODE_MONO FT_RENDER_MODE_LCD FT_RENDER_MODE_LCD_V ; -C-ENUM: +C-ENUM: f FT_PIXEL_MODE_NONE FT_PIXEL_MODE_MONO FT_PIXEL_MODE_GRAY diff --git a/extra/libusb/libusb.factor b/extra/libusb/libusb.factor index d521015d6f..e2ef40d81e 100644 --- a/extra/libusb/libusb.factor +++ b/extra/libusb/libusb.factor @@ -191,7 +191,7 @@ CONSTANT: LIBUSB_ERROR_NOT_SUPPORTED -12 CONSTANT: LIBUSB_ERROR_OTHER -99 TYPEDEF: int libusb_error -C-ENUM: +C-ENUM: libusb_transfer_status LIBUSB_TRANSFER_COMPLETED LIBUSB_TRANSFER_ERROR LIBUSB_TRANSFER_TIMED_OUT @@ -199,7 +199,6 @@ C-ENUM: LIBUSB_TRANSFER_STALL LIBUSB_TRANSFER_NO_DEVICE LIBUSB_TRANSFER_OVERFLOW ; -TYPEDEF: int libusb_transfer_status CONSTANT: LIBUSB_TRANSFER_SHORT_NOT_OK 1 CONSTANT: LIBUSB_TRANSFER_FREE_BUFFER 2 diff --git a/extra/llvm/core/core.factor b/extra/llvm/core/core.factor index f0a3cafe33..b15a7150bf 100644 --- a/extra/llvm/core/core.factor +++ b/extra/llvm/core/core.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Matthew Willis. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.libraries alien.syntax system sequences combinators kernel ; +USING: alien.libraries alien.syntax system sequences combinators kernel alien.c-types ; IN: llvm.core @@ -28,20 +28,20 @@ LIBRARY: LLVMCore TYPEDEF: uint unsigned TYPEDEF: unsigned enum -CONSTANT: LLVMZExtAttribute BIN: 1 -CONSTANT: LLVMSExtAttribute BIN: 10 -CONSTANT: LLVMNoReturnAttribute BIN: 100 -CONSTANT: LLVMInRegAttribute BIN: 1000 -CONSTANT: LLVMStructRetAttribute BIN: 10000 -CONSTANT: LLVMNoUnwindAttribute BIN: 100000 -CONSTANT: LLVMNoAliasAttribute BIN: 1000000 -CONSTANT: LLVMByValAttribute BIN: 10000000 -CONSTANT: LLVMNestAttribute BIN: 100000000 -CONSTANT: LLVMReadNoneAttribute BIN: 1000000000 -CONSTANT: LLVMReadOnlyAttribute BIN: 10000000000 -TYPEDEF: enum LLVMAttribute; +C-ENUM: LLVMAttribute + { LLVMZExtAttribute BIN: 1 } + { LLVMSExtAttribute BIN: 10 } + { LLVMNoReturnAttribute BIN: 100 } + { LLVMInRegAttribute BIN: 1000 } + { LLVMStructRetAttribute BIN: 10000 } + { LLVMNoUnwindAttribute BIN: 100000 } + { LLVMNoAliasAttribute BIN: 1000000 } + { LLVMByValAttribute BIN: 10000000 } + { LLVMNestAttribute BIN: 100000000 } + { LLVMReadNoneAttribute BIN: 1000000000 } + { LLVMReadOnlyAttribute BIN: 10000000000 } ; -C-ENUM: +C-ENUM: LLVMTypeKind LLVMVoidTypeKind LLVMFloatTypeKind LLVMDoubleTypeKind @@ -57,9 +57,8 @@ C-ENUM: LLVMPointerTypeKind LLVMOpaqueTypeKind LLVMVectorTypeKind ; -TYPEDEF: enum LLVMTypeKind -C-ENUM: +C-ENUM: LLVMLinkage LLVMExternalLinkage LLVMLinkOnceLinkage LLVMWeakLinkage @@ -69,34 +68,32 @@ C-ENUM: LLVMDLLExportLinkage LLVMExternalWeakLinkage LLVMGhostLinkage ; -TYPEDEF: enum LLVMLinkage -C-ENUM: +C-ENUM: LLVMVisibility LLVMDefaultVisibility LLVMHiddenVisibility LLVMProtectedVisibility ; -TYPEDEF: enum LLVMVisibility -CONSTANT: LLVMCCallConv 0 -CONSTANT: LLVMFastCallConv 8 -CONSTANT: LLVMColdCallConv 9 -CONSTANT: LLVMX86StdcallCallConv 64 -CONSTANT: LLVMX86FastcallCallConv 65 -TYPEDEF: enum LLVMCallConv +C-ENUM: LLVMCallConv + { LLVMCCallConv 0 } + { LLVMFastCallConv 8 } + { LLVMColdCallConv 9 } + { LLVMX86StdcallCallConv 64 } + { LLVMX86FastcallCallConv 65 } ; -CONSTANT: LLVMIntEQ 32 -CONSTANT: LLVMIntNE 33 -CONSTANT: LLVMIntUGT 34 -CONSTANT: LLVMIntUGE 35 -CONSTANT: LLVMIntULT 36 -CONSTANT: LLVMIntULE 37 -CONSTANT: LLVMIntSGT 38 -CONSTANT: LLVMIntSGE 39 -CONSTANT: LLVMIntSLT 40 -CONSTANT: LLVMIntSLE 41 -TYPEDEF: enum LLVMIntPredicate +C-ENUM: LLVMIntPredicate + { LLVMIntEQ 32 } + { LLVMIntNE 33 } + { LLVMIntUGT 34 } + { LLVMIntUGE 35 } + { LLVMIntULT 36 } + { LLVMIntULE 37 } + { LLVMIntSGT 38 } + { LLVMIntSGE 39 } + { LLVMIntSLT 40 } + { LLVMIntSLE 41 } ; -C-ENUM: +C-ENUM: LLVMRealPredicate LLVMRealPredicateFalse LLVMRealOEQ LLVMRealOGT @@ -113,7 +110,6 @@ C-ENUM: LLVMRealULE LLVMRealUNE LLVMRealPredicateTrue ; -TYPEDEF: enum LLVMRealPredicate ! Opaque Types diff --git a/extra/macho/macho.factor b/extra/macho/macho.factor index fbccab35a4..ea71583072 100644 --- a/extra/macho/macho.factor +++ b/extra/macho/macho.factor @@ -770,16 +770,14 @@ STRUCT: scattered_relocation_info_little_endian { r_address_type_length_pcrel_scattered uint32_t } { r_value int32_t } ; -TYPEDEF: int reloc_type_generic -C-ENUM: +C-ENUM: reloc_type_generic GENERIC_RELOC_VANILLA GENERIC_RELOC_PAIR GENERIC_RELOC_SECTDIFF GENERIC_RELOC_PB_LA_PTR GENERIC_RELOC_LOCAL_SECTDIFF ; -TYPEDEF: int reloc_type_x86_64 -C-ENUM: +C-ENUM: reloc_type_x86_64 X86_64_RELOC_UNSIGNED X86_64_RELOC_SIGNED X86_64_RELOC_BRANCH @@ -790,8 +788,7 @@ C-ENUM: X86_64_RELOC_SIGNED_2 X86_64_RELOC_SIGNED_4 ; -TYPEDEF: int reloc_type_ppc -C-ENUM: +C-ENUM: reloc_type_ppc PPC_RELOC_VANILLA PPC_RELOC_PAIR PPC_RELOC_BR14 diff --git a/extra/tokyo/alien/tcadb/tcadb.factor b/extra/tokyo/alien/tcadb/tcadb.factor index 7e3a2d47c2..6107111be2 100644 --- a/extra/tokyo/alien/tcadb/tcadb.factor +++ b/extra/tokyo/alien/tcadb/tcadb.factor @@ -9,7 +9,7 @@ LIBRARY: tokyocabinet TYPEDEF: void* TCADB -C-ENUM: +C-ENUM: f ADBOVOID ADBOMDB ADBONDB diff --git a/extra/tokyo/alien/tcbdb/tcbdb.factor b/extra/tokyo/alien/tcbdb/tcbdb.factor index 6454e6b2fa..04913eba73 100644 --- a/extra/tokyo/alien/tcbdb/tcbdb.factor +++ b/extra/tokyo/alien/tcbdb/tcbdb.factor @@ -27,7 +27,7 @@ CONSTANT: BDBOTSYNC 64 TYPEDEF: void* BDBCUR -C-ENUM: +C-ENUM: f BDBCPCURRENT BDBCPBEFORE BDBCPAFTER ; diff --git a/extra/tokyo/alien/tcrdb/tcrdb.factor b/extra/tokyo/alien/tcrdb/tcrdb.factor index da4a750444..32938264ae 100644 --- a/extra/tokyo/alien/tcrdb/tcrdb.factor +++ b/extra/tokyo/alien/tcrdb/tcrdb.factor @@ -25,7 +25,7 @@ C-TYPE: TCRDB ! { timeout double } ! { opts int } ; -C-ENUM: +C-ENUM: f TTESUCCESS TTEINVALID TTENOHOST diff --git a/extra/tokyo/alien/tctdb/tctdb.factor b/extra/tokyo/alien/tctdb/tctdb.factor index 82100e23c8..e5a278e1b9 100644 --- a/extra/tokyo/alien/tctdb/tctdb.factor +++ b/extra/tokyo/alien/tctdb/tctdb.factor @@ -27,7 +27,7 @@ CONSTANT: TDBONOLCK 16 CONSTANT: TDBOLCKNB 32 CONSTANT: TDBOTSYNC 64 -C-ENUM: +C-ENUM: f TDBITLEXICAL TDBITDECIMAL ; @@ -38,7 +38,7 @@ CONSTANT: TDBITKEEP 16777216 C-TYPE: TDBCOND C-TYPE: TDBQRY -C-ENUM: +C-ENUM: f TDBQCSTREQ TDBQCSTRINC TDBQCSTRBW @@ -58,7 +58,7 @@ C-ENUM: CONSTANT: TDBQCNEGATE 16777216 CONSTANT: TDBQCNOIDX 33554432 -C-ENUM: +C-ENUM: f TDBQOSTRASC TDBQOSTRDESC TDBQONUMASC diff --git a/extra/tokyo/alien/tcutil/tcutil.factor b/extra/tokyo/alien/tcutil/tcutil.factor index afb78dba22..14ddbe99d1 100644 --- a/extra/tokyo/alien/tcutil/tcutil.factor +++ b/extra/tokyo/alien/tcutil/tcutil.factor @@ -12,7 +12,7 @@ IN: tokyo.alien.tcutil LIBRARY: tokyocabinet -C-ENUM: +C-ENUM: f TCDBTHASH TCDBTBTREE TCDBTFIXED diff --git a/unmaintained/cryptlib/libcl/libcl.factor b/unmaintained/cryptlib/libcl/libcl.factor index 38e6817f6c..946364efc1 100644 --- a/unmaintained/cryptlib/libcl/libcl.factor +++ b/unmaintained/cryptlib/libcl/libcl.factor @@ -878,7 +878,7 @@ TYPEDEF: int CRYPT_KEYID_TYPE ! Internal keyset options ! (As _NONE but open for exclusive access, _CRYPT_DEFINED ! Last possible key option type, _CRYPT_DEFINED Last external keyset option) -C-ENUM: +C-ENUM: f CRYPT_KEYOPT_NONE CRYPT_KEYOPT_READONLY CRYPT_KEYOPT_CREATE diff --git a/unmaintained/pdf/libhpdf/libhpdf.factor b/unmaintained/pdf/libhpdf/libhpdf.factor index a40b7cddee..c980ab0baf 100644 --- a/unmaintained/pdf/libhpdf/libhpdf.factor +++ b/unmaintained/pdf/libhpdf/libhpdf.factor @@ -24,7 +24,7 @@ IN: pdf.libhpdf : HPDF_COMP_MASK HEX: FF ; inline ! page mode -C-ENUM: +C-ENUM: f HPDF_PAGE_MODE_USE_NONE HPDF_PAGE_MODE_USE_OUTLINE HPDF_PAGE_MODE_USE_THUMBS From faf0418a125f2c99c0705e07c48e3a6935071684 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sat, 10 Apr 2010 00:02:44 -0700 Subject: [PATCH 614/713] Remove empty quad vocabulary --- extra/gpu/effects/quad/authors.txt | 1 - extra/gpu/effects/quad/quad.factor | 4 ---- extra/gpu/effects/quad/summary.txt | 1 - 3 files changed, 6 deletions(-) delete mode 100644 extra/gpu/effects/quad/authors.txt delete mode 100644 extra/gpu/effects/quad/quad.factor delete mode 100644 extra/gpu/effects/quad/summary.txt diff --git a/extra/gpu/effects/quad/authors.txt b/extra/gpu/effects/quad/authors.txt deleted file mode 100644 index 6f03a12101..0000000000 --- a/extra/gpu/effects/quad/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Erik Charlebois diff --git a/extra/gpu/effects/quad/quad.factor b/extra/gpu/effects/quad/quad.factor deleted file mode 100644 index 5a770ba838..0000000000 --- a/extra/gpu/effects/quad/quad.factor +++ /dev/null @@ -1,4 +0,0 @@ -! Copyright (C) 2010 Erik Charlebois. -! See http://factorcode.org/license.txt for BSD license. -USING: ; -IN: gpu.effects.quad diff --git a/extra/gpu/effects/quad/summary.txt b/extra/gpu/effects/quad/summary.txt deleted file mode 100644 index 8952404931..0000000000 --- a/extra/gpu/effects/quad/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Render a screen-aligned quad. From f828f9fdaad5b0855952f6a0451d789cb2ba3453 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 9 Apr 2010 21:13:48 -0700 Subject: [PATCH 615/713] Fiddle with register assignments in non-optimizing x86-32 backend --- basis/cpu/x86/32/32.factor | 2 +- basis/cpu/x86/32/bootstrap.factor | 53 ++++++++++++++++--------------- basis/cpu/x86/64/bootstrap.factor | 7 ++-- basis/cpu/x86/bootstrap.factor | 33 +++++++++---------- 4 files changed, 50 insertions(+), 45 deletions(-) diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 97f0cfb668..10b49f5e97 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -67,7 +67,7 @@ M:: x86.32 %dispatch ( src temp -- ) [ align-code ] bi ; -M: x86.32 pic-tail-reg EBX ; +M: x86.32 pic-tail-reg EDX ; M: x86.32 reserved-stack-space 4 cells ; diff --git a/basis/cpu/x86/32/bootstrap.factor b/basis/cpu/x86/32/bootstrap.factor index b2cd241df1..4eb8335b67 100644 --- a/basis/cpu/x86/32/bootstrap.factor +++ b/basis/cpu/x86/32/bootstrap.factor @@ -13,15 +13,16 @@ IN: bootstrap.x86 : div-arg ( -- reg ) EAX ; : mod-arg ( -- reg ) EDX ; : temp0 ( -- reg ) EAX ; -: temp1 ( -- reg ) EDX ; -: temp2 ( -- reg ) ECX ; -: temp3 ( -- reg ) EBX ; +: temp1 ( -- reg ) ECX ; +: temp2 ( -- reg ) EBX ; +: temp3 ( -- reg ) EDX ; +: pic-tail-reg ( -- reg ) EDX ; : stack-reg ( -- reg ) ESP ; : frame-reg ( -- reg ) EBP ; -: vm-reg ( -- reg ) ECX ; +: vm-reg ( -- reg ) EBX ; : ctx-reg ( -- reg ) EBP ; : nv-regs ( -- seq ) { ESI EDI EBX } ; -: nv-reg ( -- reg ) EBX ; +: nv-reg ( -- reg ) ESI ; : ds-reg ( -- reg ) ESI ; : rs-reg ( -- reg ) EDI ; : fixnum>slot@ ( -- ) temp0 2 SAR ; @@ -40,7 +41,7 @@ IN: bootstrap.x86 ] jit-prolog jit-define [ - temp3 0 MOV rc-absolute-cell rt-here jit-rel + pic-tail-reg 0 MOV rc-absolute-cell rt-here jit-rel 0 JMP rc-relative rt-entry-point-pic-tail jit-rel ] jit-word-jump jit-define @@ -53,8 +54,8 @@ IN: bootstrap.x86 : jit-save-context ( -- ) jit-load-context - EDX ESP -4 [+] LEA - ctx-reg context-callstack-top-offset [+] EDX MOV + ECX ESP -4 [+] LEA + ctx-reg context-callstack-top-offset [+] ECX MOV ctx-reg context-datastack-offset [+] ds-reg MOV ctx-reg context-retainstack-offset [+] rs-reg MOV ; @@ -135,25 +136,25 @@ IN: bootstrap.x86 [ ! Load callstack object - EBX ds-reg [] MOV + temp3 ds-reg [] MOV ds-reg bootstrap-cell SUB ! Get ctx->callstack_bottom jit-load-vm jit-load-context - EAX ctx-reg context-callstack-bottom-offset [+] MOV + temp0 ctx-reg context-callstack-bottom-offset [+] MOV ! Get top of callstack object -- 'src' for memcpy - EBP EBX callstack-top-offset [+] LEA + temp1 temp3 callstack-top-offset [+] LEA ! Get callstack length, in bytes --- 'len' for memcpy - EDX EBX callstack-length-offset [+] MOV - EDX tag-bits get SHR + temp2 temp3 callstack-length-offset [+] MOV + temp2 tag-bits get SHR ! Compute new stack pointer -- 'dst' for memcpy - EAX EDX SUB + temp0 temp2 SUB ! Install new stack pointer - ESP EAX MOV + ESP temp0 MOV ! Call memcpy - EDX PUSH - EBP PUSH - EAX PUSH + temp2 PUSH + temp1 PUSH + temp0 PUSH "factor_memcpy" jit-call ESP 12 ADD ! Return with new callstack @@ -177,7 +178,7 @@ IN: bootstrap.x86 ! Inline cache miss entry points : jit-load-return-address ( -- ) - EBX ESP stack-frame-size bootstrap-cell - [+] MOV ; + pic-tail-reg ESP stack-frame-size bootstrap-cell - [+] MOV ; ! These are always in tail position with an existing stack ! frame, and the stack. The frame setup takes this into account. @@ -185,7 +186,7 @@ IN: bootstrap.x86 jit-load-vm jit-save-context ESP 4 [+] vm-reg MOV - ESP [] EBX MOV + ESP [] pic-tail-reg MOV "inline_cache_miss" jit-call jit-restore-context ; @@ -213,6 +214,7 @@ IN: bootstrap.x86 [ ESP [] EAX MOV ESP 4 [+] EDX MOV + jit-load-vm ESP 8 [+] vm-reg MOV jit-call ] @@ -237,6 +239,7 @@ IN: bootstrap.x86 EBX tag-bits get SAR ESP [] EBX MOV ESP 4 [+] EBP MOV + jit-load-vm ESP 8 [+] vm-reg MOV "overflow_fixnum_multiply" jit-call ] @@ -266,7 +269,7 @@ IN: bootstrap.x86 ! Load context and parameter from datastack EAX ds-reg [] MOV EAX EAX alien-offset [+] MOV - EBX ds-reg -4 [+] MOV + EDX ds-reg -4 [+] MOV ds-reg 8 SUB ! Make the new context active @@ -280,7 +283,7 @@ IN: bootstrap.x86 ! Store parameter to datastack ds-reg 4 ADD - ds-reg [] EBX MOV ; + ds-reg [] EDX MOV ; [ jit-set-context ] \ (set-context) define-sub-primitive @@ -291,14 +294,14 @@ IN: bootstrap.x86 "new_context" jit-call ! Save pointer to quotation and parameter - EBX ds-reg MOV + EDX ds-reg MOV ds-reg 8 SUB ! Make the new context active EAX jit-switch-context ! Push parameter - EAX EBX -4 [+] MOV + EAX EDX -4 [+] MOV ds-reg 4 ADD ds-reg [] EAX MOV @@ -309,7 +312,7 @@ IN: bootstrap.x86 0 PUSH ! Jump to initial quotation - EAX EBX [] MOV + EAX EDX [] MOV jit-jump-quot ; [ jit-start-context ] \ (start-context) define-sub-primitive diff --git a/basis/cpu/x86/64/bootstrap.factor b/basis/cpu/x86/64/bootstrap.factor index 68c3d8b702..39046bce6a 100644 --- a/basis/cpu/x86/64/bootstrap.factor +++ b/basis/cpu/x86/64/bootstrap.factor @@ -11,10 +11,11 @@ IN: bootstrap.x86 : shift-arg ( -- reg ) RCX ; : div-arg ( -- reg ) RAX ; : mod-arg ( -- reg ) RDX ; -: temp0 ( -- reg ) RDI ; -: temp1 ( -- reg ) RSI ; +: temp0 ( -- reg ) RAX ; +: temp1 ( -- reg ) RCX ; : temp2 ( -- reg ) RDX ; : temp3 ( -- reg ) RBX ; +: pic-tail-reg ( -- reg ) RBX ; : return-reg ( -- reg ) RAX ; : nv-reg ( -- reg ) RBX ; : stack-reg ( -- reg ) RSP ; @@ -42,7 +43,7 @@ IN: bootstrap.x86 ] jit-prolog jit-define [ - temp3 5 [RIP+] LEA + pic-tail-reg 5 [RIP+] LEA 0 JMP rc-relative rt-entry-point-pic-tail jit-rel ] jit-word-jump jit-define diff --git a/basis/cpu/x86/bootstrap.factor b/basis/cpu/x86/bootstrap.factor index 80b56f9f91..b1866e110a 100644 --- a/basis/cpu/x86/bootstrap.factor +++ b/basis/cpu/x86/bootstrap.factor @@ -12,8 +12,9 @@ big-endian off [ ! Optimizing compiler's side of callback accesses ! arguments that are on the stack via the frame pointer. - ! On x86-64, some arguments are passed in registers, and - ! so the only register that is safe for use here is nv-reg. + ! On x86-32 fastcall, and x86-64, some arguments are passed + ! in registers, and so the only registers that are safe for + ! use here are frame-reg, nv-reg and vm-reg. frame-reg PUSH frame-reg stack-reg MOV @@ -73,15 +74,15 @@ big-endian off [ ! Load word - nv-reg 0 MOV rc-absolute-cell rt-literal jit-rel + temp0 0 MOV rc-absolute-cell rt-literal jit-rel ! Bump profiling counter - nv-reg profile-count-offset [+] 1 tag-fixnum ADD + temp0 profile-count-offset [+] 1 tag-fixnum ADD ! Load word->code - nv-reg nv-reg word-code-offset [+] MOV + temp0 temp0 word-code-offset [+] MOV ! Compute word entry point - nv-reg compiled-header-size ADD + temp0 compiled-header-size ADD ! Jump to entry point - nv-reg JMP + temp0 JMP ] jit-profiling jit-define [ @@ -200,7 +201,7 @@ big-endian off ! ! ! Polymorphic inline caches -! The PIC stubs are not permitted to touch temp3. +! The PIC stubs are not permitted to touch pic-tail-reg. ! Load a value from a stack position [ @@ -477,23 +478,23 @@ big-endian off ! load value temp3 ds-reg [] MOV ! make a copy - temp1 temp3 MOV - ! compute positive shift value in temp1 - temp1 CL SHL + temp2 temp3 MOV + ! compute positive shift value in temp2 + temp2 CL SHL shift-arg NEG ! compute negative shift value in temp3 temp3 CL SAR temp3 tag-mask get bitnot AND shift-arg 0 CMP - ! if shift count was negative, move temp0 to temp1 - temp1 temp3 CMOVGE + ! if shift count was negative, move temp0 to temp2 + temp2 temp3 CMOVGE ! push to stack - ds-reg [] temp1 MOV + ds-reg [] temp2 MOV ] \ fixnum-shift-fast define-sub-primitive : jit-fixnum-/mod ( -- ) ! load second parameter - temp3 ds-reg [] MOV + temp1 ds-reg [] MOV ! load first parameter div-arg ds-reg bootstrap-cell neg [+] MOV ! make a copy @@ -501,7 +502,7 @@ big-endian off ! sign-extend mod-arg bootstrap-cell-bits 1 - SAR ! divide - temp3 IDIV ; + temp1 IDIV ; [ jit-fixnum-/mod From 5768ae0af4db3311539c463e5d467639cfd7db4d Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sat, 10 Apr 2010 00:12:59 -0700 Subject: [PATCH 616/713] Forget to save some files for enum change --- basis/cairo/ffi/ffi.factor | 15 +++++---------- basis/cocoa/application/application.factor | 2 +- basis/unicode/breaks/breaks.factor | 4 ++-- basis/vm/vm.factor | 2 +- basis/windows/advapi32/advapi32.factor | 12 ++++-------- basis/windows/ddk/hid/hid.factor | 6 ++---- basis/windows/ddk/setupapi/setupapi.factor | 3 +-- .../directx/d3dx9shader/d3dx9shader.factor | 6 ++---- basis/windows/directx/xaudio2/xaudio2.factor | 3 +-- 9 files changed, 19 insertions(+), 34 deletions(-) diff --git a/basis/cairo/ffi/ffi.factor b/basis/cairo/ffi/ffi.factor index 42b281c33c..01e89aaf3c 100644 --- a/basis/cairo/ffi/ffi.factor +++ b/basis/cairo/ffi/ffi.factor @@ -694,8 +694,7 @@ cairo_surface_get_reference_count ( cairo_surface_t* surface ) ; FUNCTION: cairo_status_t cairo_surface_status ( cairo_surface_t* surface ) ; -TYPEDEF: int cairo_surface_type_t -C-ENUM: +C-ENUM: cairo_surface_type_t CAIRO_SURFACE_TYPE_IMAGE CAIRO_SURFACE_TYPE_PDF CAIRO_SURFACE_TYPE_PS @@ -758,8 +757,7 @@ cairo_surface_show_page ( cairo_surface_t* surface ) ; ! Image-surface functions -TYPEDEF: int cairo_format_t -C-ENUM: +C-ENUM: cairo_format_t CAIRO_FORMAT_ARGB32 CAIRO_FORMAT_RGB24 CAIRO_FORMAT_A8 @@ -831,8 +829,7 @@ cairo_pattern_get_user_data ( cairo_pattern_t* pattern, cairo_user_data_key_t* k FUNCTION: cairo_status_t cairo_pattern_set_user_data ( cairo_pattern_t* pattern, cairo_user_data_key_t* key, void* user_data, cairo_destroy_func_t destroy ) ; -TYPEDEF: int cairo_pattern_type_t -C-ENUM: +C-ENUM: cairo_pattern_type_t CAIRO_PATTERN_TYPE_SOLID CAIRO_PATTERN_TYPE_SURFACE CAIRO_PATTERN_TYPE_LINEAR @@ -853,8 +850,7 @@ cairo_pattern_set_matrix ( cairo_pattern_t* pattern, cairo_matrix_t* matrix ) ; FUNCTION: void cairo_pattern_get_matrix ( cairo_pattern_t* pattern, cairo_matrix_t* matrix ) ; -TYPEDEF: int cairo_extend_t -C-ENUM: +C-ENUM: cairo_extend_t CAIRO_EXTEND_NONE CAIRO_EXTEND_REPEAT CAIRO_EXTEND_REFLECT @@ -866,8 +862,7 @@ cairo_pattern_set_extend ( cairo_pattern_t* pattern, cairo_extend_t extend ) ; FUNCTION: cairo_extend_t cairo_pattern_get_extend ( cairo_pattern_t* pattern ) ; -TYPEDEF: int cairo_filter_t -C-ENUM: +C-ENUM: cairo_filter_t CAIRO_FILTER_FAST CAIRO_FILTER_GOOD CAIRO_FILTER_BEST diff --git a/basis/cocoa/application/application.factor b/basis/cocoa/application/application.factor index df56ce5c4c..6768e1471d 100644 --- a/basis/cocoa/application/application.factor +++ b/basis/cocoa/application/application.factor @@ -8,7 +8,7 @@ IN: cocoa.application : ( str -- alien ) -> autorelease ; -C-ENUM: +C-ENUM: f NSApplicationDelegateReplySuccess NSApplicationDelegateReplyCancel NSApplicationDelegateReplyFailure ; diff --git a/basis/unicode/breaks/breaks.factor b/basis/unicode/breaks/breaks.factor index 46651bd7de..2ab8b27cc7 100644 --- a/basis/unicode/breaks/breaks.factor +++ b/basis/unicode/breaks/breaks.factor @@ -12,7 +12,7 @@ IN: unicode.breaks Date: Sat, 10 Apr 2010 00:41:20 -0700 Subject: [PATCH 617/713] compiler.tests.alien: fix typo --- basis/compiler/tests/alien.factor | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 5793482a27..a3df053ca2 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -444,9 +444,8 @@ STRUCT: double-rect void { void* void* double-rect } cdecl [ "example" set-global 2drop ] alien-callback ; -: double-rect-test ( arg -- arg' ) +: double-rect-test ( arg callback -- arg' ) [ f f ] 2dip - double-rect-callback void { void* void* double-rect } cdecl alien-indirect "example" get-global ; From 2812830b443411b18bf030d7b10adc71a0fedf23 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sat, 10 Apr 2010 01:26:26 -0700 Subject: [PATCH 618/713] Typo in cairo ffi for C-ENUM change. --- basis/cairo/ffi/ffi.factor | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/basis/cairo/ffi/ffi.factor b/basis/cairo/ffi/ffi.factor index 01e89aaf3c..c357f856de 100644 --- a/basis/cairo/ffi/ffi.factor +++ b/basis/cairo/ffi/ffi.factor @@ -1,6 +1,8 @@ ! Copyright (c) 2007 Sampo Vuori ! Copyright (c) 2008 Matthew Willis ! + + ! Adapted from cairo.h, version 1.5.14 ! License: http://factorcode.org/license.txt @@ -389,7 +391,7 @@ C-ENUM: cairo_subpixel_order_t CAIRO_SUBPIXEL_ORDER_VRGB CAIRO_SUBPIXEL_ORDER_VBGR ; -C-ENUM: cairo_hint_Style_t +C-ENUM: cairo_hint_style_t CAIRO_HINT_STYLE_DEFAULT CAIRO_HINT_STYLE_NONE CAIRO_HINT_STYLE_SLIGHT From ed40eb42395e8cd460f494a19cfb19b1b2b43b4f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 10 Apr 2010 16:54:17 -0700 Subject: [PATCH 619/713] cpu.x86.32: cleanups and fixes to make fastcall and thiscall callbacks work --- basis/cpu/architecture/architecture.factor | 4 +-- basis/cpu/x86/32/32.factor | 36 ++++++++-------------- basis/cpu/x86/bootstrap.factor | 7 +++-- basis/stack-checker/alien/alien.factor | 3 +- 4 files changed, 20 insertions(+), 30 deletions(-) diff --git a/basis/cpu/architecture/architecture.factor b/basis/cpu/architecture/architecture.factor index 7abf1673d4..1aaf1bf2ea 100644 --- a/basis/cpu/architecture/architecture.factor +++ b/basis/cpu/architecture/architecture.factor @@ -595,6 +595,6 @@ HOOK: %end-callback cpu ( -- ) HOOK: %end-callback-value cpu ( c-type -- ) -HOOK: callback-return-rewind cpu ( params -- n ) +HOOK: stack-cleanup cpu ( params -- n ) -M: object callback-return-rewind drop 0 ; +M: object stack-cleanup drop 0 ; diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 37177abbcd..f08a03d8be 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -129,8 +129,7 @@ M: stack-params copy-register* { [ over integer? ] [ EAX swap MOV param@ EAX MOV ] } } cond ; -M: x86.32 %save-param-reg - dup stack-params? [ 3drop ] [ [ param@ ] 2dip %copy ] if ; +M: x86.32 %save-param-reg [ local@ ] 2dip %copy ; M: x86.32 %load-param-reg [ swap local@ ] dip %copy ; @@ -139,7 +138,7 @@ M: x86.32 %load-param-reg [ swap local@ ] dip %copy ; #! are boxing a return value of a C function. If n is an #! integer, push [ESP+n] on the stack; we are boxing a #! parameter being passed to a callback from C. - over [ [ next-stack@ ] dip load-return-reg ] [ 2drop ] if ; + over [ [ local@ ] dip load-return-reg ] [ 2drop ] if ; M:: x86.32 %box ( n rep func -- ) n rep (%box) @@ -327,18 +326,20 @@ M:: x86.32 %binary-float-function ( dst src1 src2 func -- ) stack-params get ] with-param-regs ; -M: x86.32 %cleanup ( params -- ) - #! a) If we just called a stdcall function in Windows, it - #! cleaned up the stack frame for us. But we don't want that - #! so we 'undo' the cleanup since we do that in %epilogue. - #! b) If we just called a function returning a struct, we - #! have to fix ESP. +M: x86.32 stack-cleanup ( params -- n ) + #! a) Functions which are stdcall/fastcall/thiscall have to + #! clean up the caller's stack frame. + #! b) Functions returning large structs on MINGW have to + #! fix ESP. { - { [ dup abi>> callee-cleanup? ] [ stack-arg-size ESP swap SUB ] } - { [ dup funny-large-struct-return? ] [ drop EAX PUSH ] } - [ drop ] + { [ dup abi>> callee-cleanup? ] [ stack-arg-size ] } + { [ dup funny-large-struct-return? ] [ drop 4 ] } + [ drop 0 ] } cond ; +M: x86.32 %cleanup ( params -- ) + stack-cleanup [ ESP swap SUB ] unless-zero ; + M:: x86.32 %call-gc ( gc-root-count temp -- ) temp gc-root-base special@ LEA 8 save-vm-ptr @@ -352,17 +353,6 @@ M: x86.32 dummy-int-params? f ; M: x86.32 dummy-fp-params? f ; -M: x86.32 callback-return-rewind ( params -- n ) - #! a) If the callback is stdcall, we have to clean up the - #! caller's stack frame. - #! b) If the callback is returning a large struct, we have - #! to fix ESP. - { - { [ dup stdcall? ] [ [ params>> ] [ return>> ] bi + ] } - { [ dup funny-large-struct-return? ] [ drop 4 ] } - [ drop 0 ] - } cond ; - ! Dreadful M: object flatten-value-type (flatten-stack-type) ; M: struct-c-type flatten-value-type (flatten-stack-type) ; diff --git a/basis/cpu/x86/bootstrap.factor b/basis/cpu/x86/bootstrap.factor index b1866e110a..7accc4b1cb 100644 --- a/basis/cpu/x86/bootstrap.factor +++ b/basis/cpu/x86/bootstrap.factor @@ -66,9 +66,10 @@ big-endian off frame-reg POP - ! Callbacks which return structs, or use stdcall, need a - ! parameter here. See the comment in callback-return-rewind - ! in cpu.x86.32 + ! Callbacks which return structs, or use stdcall/fastcall/thiscall, + ! need a parameter here. + + ! See the comment for M\ x86.32 stack-cleanup in cpu.x86.32 HEX: ffff RET rc-absolute-2 rt-untagged jit-rel ] callback-stub jit-define diff --git a/basis/stack-checker/alien/alien.factor b/basis/stack-checker/alien/alien.factor index 9039c5d3f0..1c6b37b7df 100644 --- a/basis/stack-checker/alien/alien.factor +++ b/basis/stack-checker/alien/alien.factor @@ -107,8 +107,7 @@ TUPLE: alien-callback-params < alien-node-params quot xt ; [ callbacks get ] dip '[ _ ] cache ; : callback-bottom ( params -- ) - [ xt>> ] [ callback-return-rewind ] bi - '[ _ _ callback-xt ] infer-quot-here ; + [ xt>> ] [ stack-cleanup ] bi '[ _ _ callback-xt ] infer-quot-here ; : infer-alien-callback ( -- ) alien-callback-params new From 0202c35d2af1aea3fd9525e7f2b0c6166c21e160 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 10 Apr 2010 16:56:00 -0700 Subject: [PATCH 620/713] alien: now that fastcall works better it doesn't need to be private --- basis/cpu/x86/32/32.factor | 1 - core/alien/alien.factor | 12 ++++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index f08a03d8be..0127d55997 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -10,7 +10,6 @@ compiler.cfg.intrinsics compiler.cfg.stack-frame cpu.x86.assembler cpu.x86.assembler.operands cpu.x86 cpu.architecture vm ; FROM: layouts => cell ; -FROM: alien.private => fastcall ; IN: cpu.x86.32 M: x86.32 machine-registers diff --git a/core/alien/alien.factor b/core/alien/alien.factor index 194e4201d2..27e326a557 100644 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -5,14 +5,6 @@ kernel.private byte-arrays byte-vectors arrays init continuations.private ; IN: alien -SINGLETONS: stdcall thiscall cdecl mingw ; - - - -UNION: abi stdcall thiscall fastcall cdecl mingw ; - PREDICATE: pinned-alien < alien underlying>> not ; UNION: pinned-c-ptr pinned-alien POSTPONE: f ; @@ -72,6 +64,10 @@ M: alien equal? M: pinned-alien hashcode* nip dup expired>> [ drop 1234 ] [ alien-address ] if ; +SINGLETONS: stdcall thiscall fastcall cdecl mingw ; + +UNION: abi stdcall thiscall fastcall cdecl mingw ; + ERROR: alien-callback-error ; : alien-callback ( return parameters abi quot -- alien ) From f6d8c0ad22dc1e640c339dec90ce20cb263207e8 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sat, 10 Apr 2010 17:07:05 -0700 Subject: [PATCH 621/713] Convert image to binary form and remove debug code. --- basis/images/pgm/pgm.factor | 1 - extra/fluids/particle2.pgm | Bin 50100 -> 16438 bytes 2 files changed, 1 deletion(-) diff --git a/basis/images/pgm/pgm.factor b/basis/images/pgm/pgm.factor index e673565fc9..52e594ddff 100644 --- a/basis/images/pgm/pgm.factor +++ b/basis/images/pgm/pgm.factor @@ -29,7 +29,6 @@ SINGLETON: pgm-image n 1 + lim read-numbers ] unless ; -ERROR: INSPECT a ; :: read-pgm ( -- image ) read-token :> type read-number :> width diff --git a/extra/fluids/particle2.pgm b/extra/fluids/particle2.pgm index 99bf7a40573ba50791bd0c595632f522ca5a1fa1..a45dc41082a45292dcb6c4ed9c56c665468aad3f 100644 GIT binary patch literal 16438 zcmcJW2UONqw)P{aC{`?pNE5N4qExY=f*^vTUvY%G1kN+ zChDj$CZ^q(axidlX(+DSMyY&)(1O6zW{VCn_nrb(fAw zO?}$7>(I%kQ$h!yn2cd#(=&a#rDu-G7&*cxFd)!5Feu!IFXy1pQ0LeF$SG39!NJkd zv8e4h7UdTQhd=UvdiDRNhzJ)eUfhXO!gidTiWe_dtY}dOha#{3KYWG%qKHFLNQ|C-0Y!oZz_+n;>3N9|?4HJ?>@jqD#$X&!smFCjrT|~HY zSU?J>;T25lrT=OXhhm~G;<|Sgx2o>Y^ziiZ^7i)jvHkJ(^7MocckxgO zDWHi`B@x1ZE(6D+P9;!!x$@lHwTfs%*~h1Pbzk2aI)3`*Tf?_{bsrxuFNEP<6)_-% za%GGf{xc379E&@Nx=RJb?gnu#?Ni;ihF{H^HEY$XUAsLa|O=fB$-%`uwR^&%a*Xx^?P^iyFSZ z5<|7BZU{j#DCtz}kD5Ud%uduRU~yHU?o+)+jheMYx?cST4H^VA)M;eC2k<*=zy*Tv zMGEM_&9xGSfF%|$`iDf|SgeF|DOsJXTh(fw-afv5eh~Nfhjzn8jRFIMf`fvCLxOdJ zf`S5JB%pqMcz}f()qT8;3@TMHW>DNJvO%SXfwN z>x6}chJ}WNz(m7<24bN$Lh$kStX8#(QGzp8@QM+!2xecZj6`oFkJf9~<>n0=1qB6% zif(w5rcIkRYub#%4^5gh32$t8Kn?-*5rV~mr39>?c+pp4z@ey9$j(9E z^#dAl@lZp$S+nLXA|fJMn!^tfEt)rP*3{x57%9}RXK~==VTqu$v(u~SK&r>-D!IBL z`s%uSy#@h|baSrV9MUaYwrU+285tE7WxgU?w{F#{Wkib>@PHVCg961tZR`LgV23W4 z;VbxoAz$8p`I@z$j^Md^lcwAo(ygP~w26+6(P`VZZA{yk=r(PlA|qSF17Zko92#Oc zz!LFB5BDmSE0ix&szmYMX@!u-?kiMwbLaAYHS72z`Jmvi#^Fs3@u;Y1sK&Ny7srX$ ziHmF3F1Bq9T-aEEgW#Y>0rf2rc(}V&u2`O6^!pfaEJn;JkJq_N^N8L^p1U`XXxTcl zO-u}=(s^*(1DGC-w}!&2|8s(zM7X$ z4cp}<`4$naT66Q*c5(5d+^JJyVp394XHHU5Vq#(^_~;NHhaAvEtB4lOnlv^_@W%?! zftzbZm)|7;$KoYRVfe09Jup0J9>s@++o-pV74eRp5|cW2>C&}px9;7$nbWmvmo9Jt z5A9*0EqZ7b(Y$GRSO_AhSEp8u>R#2Vx>ouM9#3@vq$w^3G+-S0dKzg~B|^M=j~+c!QhKGP_SWgcS88f6ae+9xbWWt`k8c+f9o5>1Ah=OL zJ^xyE2JnJ^#Q;&yxs18JS9L6}enZK=S&LR!U2I(Y4qUw}7f`WKPVu{gJ{SQ*n3`34PxFg#=* z6)ox=6Ont*ibNk$Q!lR75E$F+@)Y~8ZC z7-(4E-!Om?mMcvtep%kf_Daj|t9i-q>Ng66e2bP`9?^G9OzNtur}h!;^nrs056;LK zVot`8!Gi}69GE_!f4{zcQd3gI0d^1{+cpXYnl=uF0hore9)kbAw!1^8$Nva2y=!HA2xKzkc`2Gg+9HJLAS0+os1Pk z7G}V$QiZamUt$6%AJeZ?#obemXCvP#62t3|kl49fckbR7>H`O53>`Xb#E6ljMvoqy zslR+1HEP6&VZ+3NgwVTJa*wWE5<9k+4)6n;1Zwzrx>u>>@-h>!luyF*v608?jq15P zicdlE{nG~x9x`kgv@FZsss$~Md zt_B>PN|izS*j~-rg!~Yr`{-Cy-??iKb9tx_9Win=#3xM5nlyQGcJ`DhQ>OAYB|Cc( zOpG5lc8oYc3lafV&>17J7zhg?4#){ehSI>V1mGasC+vFq)Tr&>piyvGljbcWb$e9b zGr4!)v~=`7T-3);$eNTrW$LtPIXTm(PoKfp^qgr^r)E!{G-<;4v6-Vs4Ii2@C_Sxj zY6=V_A^~gwHwuCkq=^%d!3Zg#f4|-sL1(GJFkrl}mamV8 zG*If7Q3%&3?jrr_C_f-5G`v|v>o&1*9d!F%z55Lqm@#BHdND{mYpp0Q7MvoacA#3s!sORR*&Yx2-ciy~t^L6+vD1e8& zTyZctYr?oOqel$O7&HJYG&TSOts}6(Mh%FA-k$hCxl$zxg<*UT*H_@HX-OZ?i)q&$ z#}j#O5Bag^OS2Z^UfkMR)Sy#U2>Enm(BYkWyI<|cRAy?!F4H-5v zbL@ny?5R03a%bfi%$vV(;iAP$mM&YiTxZ#`Ww5bm!Th-e`LmG0R74;hWEdOh(Um}C zOu*8BOz@Wi!1#^t$@s8+BYi0!@~M6Mzd(LwUjCf9^A|3H_KKA&SFP4rwR+Xcl`EDn zU9x!L{CRWoXU&{GH5&$u3i|iM3%VpG#KpF0ttfyGC`UaST&{&E%2K3UH{AQ0Pc z6&Zu_yL3y2Ji;G2dhCQrQ>N+iP+u(Kt5>gGyKdcjoptNhu35c$<%(rX7A=@JR}4(c zo-|=x=Ez}4pl@o=Ze2PV4KxoA3sMm9@vQ1vp)4+7&w~!d@cl||?pz<&4{40;6L>nx z^!ua@96Z#J&(4{VhvFA3S|aLe)~(;Lant6_{N221)5ZTJ)w|4ca6-yT{m|u{eH$xJT5e`l#44?s=FshYI zu%V(L#TWvxyI>JrzhV{AE}=)-kBE%M_B$Kt55n)qjF<59@(boKTC#k_sx|93Y}&GQ z`;HwuckSA}d)Mw=J9qAYhfN#SuU)-j`I1HR=NbmG@Pgq(EDaC^+C>ut8V4H}@Kz8c z4_jHlfvU$vp|6H9eo78pKOwPek6wMGe8^{U``r8jWWRjnn)MquZP~Vc=dRs*Uf;{v zw{P#>*Wtl%ux`z&<>&wgW=_k_8lO38ScWu!44}J9hl|@e?PGA3t{N=;1>Lk-@GVh5=MCZ_cclIa9L6j~O`( zALyOj9UqL1#sy@7b#Os9rC}2T9i5!z{K`ByUwAXFkM_G5?Q{Kc6SJqzm^EkK!X<|M zwjEslAk^PHe)80*Q>V|IIeqHX$>VPxJ@UqZ{jcvf46I(hWZ}Fyc{8R?o`??&8Pp#O z=#rGsE+(>NGsPejU<&~%1B$Bdsp9TU%}MBOLga6Y@9X+#f7BQP&-7fBzj)ayZZGot z4?_LK$|+N#hlTNJKrmkp^Ue z3c~)i6$2}lH%SQZBlEgZ_0_J|Fo@9GI-1did>`%O`Z7MQzjzszziI1^-FpulI&$p9 z$unoqU$}VbEzYG&7cZPUd-~MzV@D2I5?H@_19{I1*3KUVR4)vS~jzAL%b&y>8PM-Tu&#H&2{CbN=F`%Wq$~ za+P!C?aP-g!odj`IDiDUZd|u|1sXsAQ)K}|Nrb6AjSErEN?Z%CpH*em!e*Nl|%a<;k zJ$>>`NnqFZEgRM%fCUA!W=@+-6eJO1f!#VkQvijSuRO4<>Og|8f}c@8-iP>OCH`I{ z9>hOxQZ~LfSH_3*ckbB-`ID#5U3}}x)f+e8y>;t7&b#m4ym9UAw=SMLV;I=8bK9o% zMgX&Oae;BqEKnZMDxyhfP=LRc1E@kADg5O99^Pbrysue=#Ej9=Q{ zw(Ir%ZyY^-irZhk{?2@#sG;xL?7yIa-YmEB%HD{w!PHfr~e>AKe2B{o@IS#U)Miz=KQ6%A%FYMz55Rz zJ$n4f<4-<*c>mroxc;8UeFXt~S+h#0~7=!^#wmh&eIe;=Ky0x9YXEjm~4uJbr zbfxe$(T~(0(~i2&sDJpVu@fd+*1vMihRs;tp`*CoTUTzp`~HV_A3S>e*%x1NzWm~| z#~(kq_u>2R-neq<-09=^;GP|F!6h;PdEltwHUm@$j-Uv!M?l^ohJKZ5-oE61B_HTx ze#$-ae$3CPAM3~Y4!m*f#2K#t&aK;b?|=O1lP|vh=IPU?-+cY$lTSasf7b}$!Wk5B zU=J~9?JBYm9%u|OBV7>)1EdIP8Ws%w8j8TsFX}|?W2-%k`78Q~{=f{pKWobLy!?51 z-@1)ki9J}~xr=E3{g3WFeEj6g|9bk}4?q0y-P5nX{Os|=zkKxmJJ;U6c=jX;zyLO_ zTeWP_{5j+R3~)GANbh9P=l;e4pzi_w(oR{p!KlSF3gBXD5FP=X~1}ORi z(^8X3LGgA6H1rh!O!y)D_|>-DKPn~;_oMKHe&#rGUtYm{dH?3^yY?PDa@?XX?SJ;= zH{bpEx1az1^WXmayKlaH^60_c58u0a^{w-#j~_j_Z`XE0APxY1?w>hgh!ugULF@s5 z`@3;}i@pheHu_4w-BPH#p+7!L(NFZ(Z<6^PIdS^JTUT$Q{s*5t`TFS(KmGiV|NsB~ z{?iXnzk2e?Lp%KwM-LGJZ~)Ptr4(e*Pay+X^g~nxL;v~xk-v%`Du2nJ>|>)(^tJB4 zUgm%B=MN6@$*mLKmF?S z$1lkL(B56P``ZJM$(xqnC5UmEsrg}>+eKV;}*f5`vQ zlV|$>@w;!n`s|VAfJ8t`|Cam<@@7oo{uH5B21fqR?O!FR(SJq!->QB@Kkga*(S%>w z|KjDw{_Xa6{T9*hW94|_W!yvkj?%nLhbZr|1bLAbNSoo z+tP1R*W}bR#UG^~%m3FZ{G04^@$GBx%KtyX|G)k2`yaml?%V(R67wSfzH?pvPYSmC zze*sx|ML#D`G1(?ulQ5R_&@R2ihm7*toYY~>Z@@4TSodL{_Q9J5&o~?00e-?CjNb^ z`1kqa=kf34F%pnf0W7rQAO6oX5c-J;dW7)?c^3alEB=<%+s_vNTSP|dN&+JMUB80+pEz<*6$nM}l7))@R{XUW zAmksO02DyvzbX|~02VjpAB`8Q`lk9N|62J^#rM>i%74ZIO!_~0_M-CN2Y1B4r%%X# zpM6UD`OBRTZr!{_{-Xq=0I(`BRe)0`Pf!KgpZupbfbw5hU;}^U-zvO;op}9Nk3Tve zDnFI~J5qg<|A&msgucxHWdJ4tkpSPmrt-t&|4$x2e)Qx&QFt!~6H|-4S^TFx5Z0{`M^!*Q_M{aP;2zf1z) z?Qa~=mVkJAlYpnG{<9RYlj{2@DF6*zf9KZws{d2~-uckfe^ei2|D#mkJGX7t3qaz} z;R$9Q;d%ij*wRm<`d0YS1H?2R=)740K(9|aKYII9|ML2>A|M%fCH3!)-TO$vlpyx{ z_XE|xw?BCQmaYChgY%i|>jAKM9?{39{sFXssDIEDFkG9`+>=1Bc*0+3$c zD!^#GVSp*>dzlDG1!NwdrvBfL22}rFe*4;WTm66Q);l+ET)jg5fBFQ{-@j)k+F!GL zDb{a!KiSVJ|Jt{s3#Jx?9)Os?-2XL4Ie;9nrVN1RXB(3NiNNU@!|cz$=kFgqzfPVp z@1JYet@qE3>lFW&E}XN!f3{igACjMX5H|6v{Eas)5Xw(~%#ZSu^2hNthhnroRe?>QcyZ}a@SW`F;k;R$S>UpuyJTDRJM{Yeve z01vXnZ!7<0el@KYl-_@O|El|=zPs8Fwg*@bJkY!V%=?$-$Fdc+_b)2o{d=1C?7wyRX=LNVt#u6n+KqmFMWU0do&MF>jgv! zZUkW7|0~y$gPvfa!l6GyRX#I;T#m|8e+@1N-QI(0-r` zN9fI`_P1Rh>od=9^*`kOb)Pk$)c>&ce@yRLDF_8v-9Np+hpPWW5|~v$5K;q%7KHjg z2M--SLJP(^Zyqhw|55ve1{7~U)BjQXBbgp-ycK-)`m3SWr@jAU`d^j@@&r-{w)el( z`_&`lS^o_^`eIr6%OsRcb-1|24%tJ#aoX0Li^3_&pQ9 zlE2k}e4ztjYEa%FgaC>_k}!`jRRNS?`KAG<{vW+hII#MEGyv8A+o%5D_N`ksu7|wZ zZ$#eb{lDJCUaS3O8lY-F8Sg70@nZn;K&t~p4z#s@6OxEQxBx+zETHByt#3MjE7z<; z2lPL8tN*!=L;G_N)OYCe>u5dE1-Ca~trj>PXj(krI5`S5H2i~+GObx&rm=2u1 z|7%)c1i?{EK1c&r|99C+bg*&r=B?Ye@1zI2dlzTtjvd^66PKs)Wc7b%PNVlV2H%tK zQ~B!pw(c9bPctC3AI3>gA`@MkX|FY$))>!>- z8sOVGG{Hrj7W`^tPv6P(zo)4GJzTA)-pTgub3znOvAf}h2JJb)IQra%5B2GRm; z*Pb#|Em+e7)%bzg%k%#KTGRhm_n%{kuYtOmK&b!E?I(`q-LKXgLoj-OvCP2K{Z;qX z+f0D$;)e&#KPpyc@~c-!P?%hREND#7n83))aWBq4%mjiF1WY`ef2>*w^~DRBLTUbC z$lK;0>b-VQ=S9~Kp!rJaQJK=`g$bA$Ju3;5gs=d`08QVRKrs2#^vjxnOq)JaBM@u; zvwX$MRki`pD#ky{mM&Su{0G@<{K5=Qwny1zrVscYq0d}jt+!tfz$^hgpMTMYVgf@O z(v07j{=oo7Xy#wD3mCp>{I%2?e=z`CD&pMTHvfV=!e1w$~>r|%`-r|>kDN1+kCNdjOW=!01kNX@|7 zYWQxO{|+9?{8!UwCa^g(m_5&i2MvIk0O#k=o|Tu!{CBFE|BlJj2;AHr@@Dua>4yfY z?`QeGt@Zz00CEBPaH<2P0fK-rfjGbi)&w{m=m8>tgRIHfQ(<97Zf-79Xa?ZSzh};v zVVi#ohA@(_0}8^Le}e!Z@-%1mCkTWuiC?p?=fgi651`I$^M7WLn*YlLz}+za?+W&! zZyH8`2sHl}_`uBnHT{S1^c>Cq8NO#R{}*)(pZPy=hua(S6#bh2`)mF$9F%Fizi@f| z2=vGrL2C%w0Nj&>{t)z~YmemAK50UpfW9yY1hJ4k#o!+VfXD`XkTt=e4@Qmv1Cl;~ z**h2%Yx+;mlhJEn15N(C+)d*B)%7U@G=eu8u;D*61(p{Y?2U#00DU411T2965CCM7 zIayiYKLB533W73Zu(`a*gTb)@P#{m_Vf1Sv?{8gSS%6M-MOSx0AP9qik1Pqqb?BJX z1tSphNcb1PH(+nTpa6go{KWuZz`uaOvCt>a@GpiullP|K&%qB!UtQl{2;cl_z+b}u z_y9et4+BELfd7eW&p4_Zm@^CiGdROQa7K;-0F)7zgh6NfddDCe@g>=)*A>O=(8^1-`WF0jA|9pOwgl-!hKXH>$-x2E$Q@f zEHq(Q06a;+Am9uG7XGgtRsaW}&;)`L4}kE}()#l!4J07=KN0WQ9m#`01b7AL1=$0? z3vAfHLcamO1A_TWr%81cLe!@SB|rVerU=mJQ&Bz)yui#1EtdgF+Pcv|G0x zfG~l7rof58e?q%!m(EEBf{N(d2=^ukEU>FW0MuUspX`L~pI|XS|H6O=Mpz5%v7pCB z1d(k(-#*8`0)Ksex^xAGEBtGR_8@ShF?$RAiR}IB0K+!;*MEO|F+mtACHyZo-~$v5 z@N-}gX4niRv~Ghdzyi?Yj(~7&_}?TbCw4NlrS=#L|0@(Wm&fwJ|ANE^e*3%dzhc0s zpmNn}o)-SO0l0URVDQgT;Ge->$G4B~(7^&g3;vwYK>%pL$G~2rxI3Z;{|pWu5W1hQ z!JrF%T;gTOOS|x`Ph$fX{u>?G@!z2a{~ggP5=$^V#DRp4kJBH6|Bj8}=7xB4f#9Y2 z`bPE^d0~HlJM0!FuHTFVU;sBT5b!#}{tN#e4*oqt(EBI=@CN-3_8s6ku;$h_;*B);rStZRsdK8`8UYl!b~6m@c$L$1~&XZ(NJ0t2wtlP!vDjC!2g^`NDF)4 z!t5Xj|1aunAPE0&Rv^j&IsA8){~`+xEZ%7U0T4VZKW6(v8wgk;D+u9DwEoZnF3bW1 zA8a19U=PFEf6x}l3;Pdltbmkd{ovJ>U|2ta0dxQk9wo4FREG@=2_YyXg#C~3@TM#y zumNI@7C^!qHx3OA31}*)?dv2 z3wtM=P&Q(M0?qPCJ^wnQUfs*ue_;hk4ZU2kyGqZsu7TAK)4i<9I0vJTi{ui59hPEN@?df4{ zph@)F|9W-V+c|J3Dn}@z4K!{3Rr6#MsyaJpETPq6-Av1GT7j#@=2=ZYcF(GNd$aEX z^~#khxUd80?DWcpXD4laYV%Uthvi&cv;?OWJWnrg_WyjX{Xak30w6N?@%GjdB0GrM z|1(RFQ2!4uZ{vWiSKIz$g-S*W?(VEV!iCl!t#4jlUY;HnZ7qVbe5kui@qb+OFUY~H zzG@8-TQvKhZY*KCYyXo)Otb%44Vjz$&q^Y$71Tdx`_j$?8_%p^IFN8=jI6h zRl{8&TEG1Z926~%DU>ukl-2$->(3ms{;d6HXtR8*J@7w8?Z0NDh=W$oo!~)R*zjTP gfb$a~H~Zg+{r`%%jUB^7;r(|fHm=PA{2!qGzewm#bN~PV literal 50100 zcmdVj&5kTbk{#gveToLO7g(2MH>sTlVoSBym1jvmoEx<%W! z@6Hh`{QPitk9p*04;P@o^ZmaL-D4+ed{4KIe!=n`I+>w59(B})%s6g-W;sQq0by&zx(of?A=`G+y{%> z6|Mjkdy2FDE!$FEDDE@hKnpk&xgv7~M1Kd3u7^nSdI&D<(?`I5#tCj~b%-$InAT5& zR>IQXnpqta`Y8rfjK~cpYSeCi9$TU6s{Nzn_vPy!&+(@(U-ys~UHjXMwr|fq2nO&O zZQy&iwwhW|tC1y^fB!cV#fdvX=sMh3`|sv}c@JUD#p_>< zh621}frO$l7ra_s?QH|v+xTWY^KZe@5}cB{-UAasv8<&=Rg1bJwHN`#p{Q{%0*7dG zJ^pzA+7ABqkv=|fzguGwJhu04c%;JR#Zmty!6W%Z^c!g7i4XGv8Y7^~*j7wxjj32c z2{?Z`$4_6rcL4V1FF)u!7tdeY$0Hu>aYeE)qO6XLuVPpeBwOvT#@D3q`&WjqGo(aF zun&{?tgSs6+G0kh+E)#yXdQ&$^uybiACzDYR=kIj%ys{^u^n`Fc&Y#|oWL-?!(2tN z?p#Nn5EwHogkys#LIUBddcS82;Tavjyh2CRjrs&$=!zR59dH}tdPl7Ih}=E?_~nN` z-H)H{U)|Mb`!A{o(u`ljtVs@%kEqBVxdIqj;zmNwo9tmwLGbqk?K*aBuYnGNn>`s{ zy|wUhy@q?5)XNsTni|6@5I_NwgGK)Q<;U;7{P=eMx{!way&gKuk^YM>1PoYXHU1dr z15M0{6`(}$lSLNFTSz4RUjfLg4dRdl+ya8lsILgp;R@f{U9l^01q)sd6j@L8unu}X zdaK?1?NbZu+UW(*gweIlqDf$mLRuk`DO{cVI~GFd-?;<~jFWWh%9Cy%eq0QJ*5Jnq z>%p+{6cefa4S=<$7+C>XxD*#66is@tP8a^}vA1;V;SrC6_k!xXrPfT>Kwt5E_3}rg zjEnz%^)!i^P8g$kuEt2BD~ipwMX_c`vT@$vSJNwg3*Mmh$M3%U@$JhWzn(+le>(P- z3qAE`kA)nxPq^Zc47Jl5sTNdU5mi?5_gC|rplQh8$-An{@X{5Ybrr5?{=ti_U^+H+0D}sgW>z6-$KZp3ThtlPx@Cxi-CI~>`QKh%W zHpka5KlS+j%TIf>r5*f5&f;wxqZt#%W5o#(jSps@pqq#bU2F?V*MOj$+9!zh0e)4j~0sMv9 zfMd`xfXQZ(QwCKW>z}VE3h^aGJZu;;qR^kY1WUwyz}wnD6)m{4-6wbjtHQep zY-2(V_kt}QV^36W94N3gR;WU$r~;E4euv#TCF}3bnWFup^W5(<9?xMM11|Vue@!BvW1PIH#fE@4wYAi;Aos%-(<%}78be?;se?AW}8IQ-9 z(>!IswBSen2J(q5fxm$T6;x?dDfXg@s)M4cj$+?R`HH>xVKPgP2lmqCZ^HhT{}y*M z)XEJ9?k*>;R?ai8xL;!PBYZIN3CWMZQR4>2G3y`{v~wOL6VI|mnKS(!XT0#E^W2~Q zdG@fB@eUg|Ch7?51%eOTU?HN!Q*dWazn%m3Pef9i)M&pcX+GjOF+JQ(2dhchQfYau z>Nbei?u&mT_|_bBU|dX$Wzh}VjoM7FVda2-Og%saxCihHGHK?;Fmk5O$|vz&uCHyz zoM#?nEs-JRO32kMScP~Y84w#2Y=$9Gr#WDQ5hj`dKJ*4As$#Rw02=7bPo0?6Zwme9 z$Rl~sh0)4_1TNmy3s7}sVXNw`P#Wl&eG9$~@eFQ*PAE9G55BS4hs_WC2l_yp6Lb+M zI_;@{tZlwuuhS=ebLP36hr*0Yy_>IO{+I&!8mailgsCLw;~ejND0Rg4O~|czga(0m zqZ7P<)jfNB7@fl8X zl({$NaG^zt;>GJGOlt#{f|QCBRVQ6J*>!3wB$#!-3MXAbna)h04JST+MY@nv$@wTX z=@sYL)a-%<;KPJ$0v|-U<_8X4KI$3egJ#ce0gDOS@JU2kcL+`~<=~d~!$GhQ&hF0% zHx=5ORq^{7)4P7p_34*qb3S-lmpc5ocjLyhkF;`gmxeFyLa|LGue?kZwTpwtri=&= z%?2*&(2g<*T)*royfHfhgd}fwS$K)8(RhUtuBkRfNf%Wr3#P(FMAxf}Y`$oP#MlfR zTO`n?XOhK6$2YEg#GWI?;o{&Q+&wd=KD_shYC^I8^F|9UAA4aO6E4L0e>;MC!q(GN$6Wp z8PT|+SJ%7EBY2U`%L_VN!ajvAqT_|Dn)^{cMQ7MdtT>!#TOSFI!8f>F`AB`i=b2L#4*z)C6kUD@jr;7*uCno(uTA0#s6fs3Qx&vKylfZ_>`aF0;D$H0kh( zxR3d%@*38<7-^=_bu*0`3_PV1BhNkbytuH^fIaO<^9gamf+2~F{$z^6x-EW0t%`fMxZjc}}G%H(7o z)dXg?M!ryV_n|9CvD26ZJjQ;BI5{F%Y8!4yGyH^`@D^^u1#Fq*o8rBvXKDY&QhT27 zxu5Iw%`-XkJVj@`jO+gRXZVUNkxBd5OZd`v{mS=%G^;DmUAW>?4SZA0Ju2*OEXoGZ zg>hSmpc{n!quh1fIz@f&EYvXan4?fE=?JvVe_oI_hoAoIjbV$+#Flxdsl(D$iid|$deGv0;bN9FgR zYpcF)CrAsTAb4dfQIKanMZxu~u8=ONDm$4UIo2ug5UK#_>!NPg)TtESGL)pa)!l5= zB=&83G6sT#?sul3w7DsoMnjs9L%DZy($osRuQOd)iW59DbeM5Z_(%LzHgmz7^{OpLG9Q20w^#Nb*`~cDaN}jpTxo~ zF4nuOdCZYGV1_CGu0MLrb+!|Ts8>rqq0`grS-VQ=!gcGtU9}R8fLn(fED9KIirFak z5n04Zq#3dha7|1Tq1+$y*JoWRLjx#lqn$vJ-JUMcd$h zcydoxeY5a;lj84Zbjo?!^||r*5r5E_2<(|HQo>ziHP?DwbRom&<9fK$FG*&XX5EHr zq}<}M)kxRQJnrm1ne36<8YVHZTN}ZPYuz1=)0mEACq&}8B}jKMSi!G!wo65Cu-$l# zHqj8eQz=J^7z#uO1!yd5?yZ-_`tv=k1#$hyTOMAtOobV9$Qy4GeoxN{Nj*lUwd3=l+cn9p+jXnG zdmiW@MM6So!pW}B5-7F1+j2ypROt8BhCtbJ%yMy3j%NIw%e&Bc<+<`##;_!7w*sa znJ4pkej=#vx4ehXiJZ~Fz38z^0@quoxPFbA-4JPwa`n7jvq78Zbt{DD*}XW+>kXOi z?>@*U;c|A|RSGhuTrGH|FtOaweK!sjwJjuN;a2@nnJsq1-`3DHo%J(qhq+jX zu{#U9=wZC*HOm>-6FbeDXg0A^pGTD`G}ZfdT>w#$a5uBMD40?O{NmDM$t{aTYLgl3 zvWT0g8B3$)W8oIhf?xmk`g|GF}84m!%qj|;?^?TvaGsB^K zvp;h<)E>Q}-(&{Yr*4@AxprG!S&VP)1DjO>5A3>beq13#FkQZ$4KBc+=*hd8#(hzD zwu_Bp(&2AQObfZbo;MQOx^drHWmg3v=LgP5@LduZbV4-{x43jYVUt2h{*&$imo@N& zDAx&D<9N^H`99=@6d(@)u{vY1pf`5i(>T7 z81&RE+J`=UZjm$69r}zv^ac9R7wX&}di2R&PF5|>ujIL&ZO{GmJ9J*D)OMrM_nR|@ zy2wh-T@gkX?a^oIX!2}5W9(ZtH1Fl5ff7^@Q_Ls@x0snw3WS7Gg{U-!f@>;7kYSBP z>5~f2;vw=+8oVwZj3OGh05y7lGGIRL{}e_aD+j~RdXJ{Z3FG*?)^q<>znJwUgoZ)w zS!+-33zB3W2fQ#ij^z8YcUTi~Ak~xA3hO=7W`A~0h!4|;&5WZh;dsJw=JEaJknW9K zAr>39E z)Afx({U`B3Z~QM(ANImh7)w&f+mDXbekQpx;5Wz!w&R;DTr)uSZVA1nxpl3SPb*PTy5CMlY?KNbOW zbeml>&6ropcKc=56T+!EuHkf7f~u{EMun+oh@WEmR?oQqQjCJ*=7`{%O%~EkCJcq1 zORcf>i|cX1Kn|LrFwS@A3vFmMe^1V*V0%9kVnciS9Xdm0#?5$#N;*u~hRoDDWJ*E2 z8B+U%R_))+j^v;E#`uGW=XQy&zG3{5(uUR9R%5!=mga-B2nxgYMsXIwVV!}o6Q3B;zI0{iy*$ zq#3i%Kc#7mI^eiJ*~k4UOO3V8sPB}bo|_mL5}rv6L5I8$8^?4e(46ZO0HbR99YWv9 zjB(U4Gmq<8hyrb;}^a`N*&Z2`}qdy!1`{3gK;M8)pM9!X@S&|{eJw$f9 z)Pmz_$w+HTMSkK8b*XdCQa=WtTkmfp)JR+7%u?TiDTBAh=`T~d&>+uahm95q8kbYVItOdt5E9=U$i-&U$h|wZ_+k zqWRQ!n2oyWf7r~JSJ%uuSev>h^G7D~?tTD0bq{K@6=AF7i+#a=EZ|X5T9bu^haw0x{Vg zH}qrD?3nD1O&l@e9V)59Ii^&bZH$%-a zs;HTWdT2~ci35hhP=^-Ue6@!AD#Gw7nFx_jDc2bZG3wc3e6L_V@laE%GV-@%jH%**L}HGudRAoy-I&iTRO3h z7cQAAdik-=tz2=*G7R;^Wj6xE29jJVo>)lajofrfrk_M{xYV|b5Bi<(nlLq6m%%A` z8E3+4?9TOs*Wk+($0rjCUB{OuImYi?kI%(i!y|6!@fDu$XTGOBoTguVG-G&v#&P}P zo93NGN#wxmgxSbSe=wIm5*@SnT{#^tqoy>9BNCE{9y0E% zHiHwnXZwgACuh#K58iG$lYP#{oqoe5S)=E0X`JEGGv?VscDZaJE4X=mr3}G}LKeiI ztVo`?jH_p4JRUBSBTa6-9x(J(m1=R^UP)N$3x=Da7l&n$;44y509=zrmxiKXTH-j_b2|ko>-f)j5Fi8 zp4|g|rv@U+ma~zEtg|q|QRE%D!zDY7KDSa(qGT-Y?&xc(0oqxHUS~|;-kGRw}F%}l7N_zvzH5x(GS9pJi(E#Ya7n(~B2(L^ zT+(~}QopHXKjcy|SuXh{cd=}^a%q7njPB3hNS?qG7yQ&OTl;jkXMY9I7(1)i_ZTZ% z_a^|~;4*%BxWq@6TrYkZF6nryVdIzDrgp^dynDKGNsXyrwS|Mtm5HI@=x~X1wOjuG zBj$7b6K~_2o=rR+E@3i$scq_6_EOCUDJ)-T1_Coa#fPhzYTNb&@mZ*s{mH^x43xi7SuFLBx0N4|vjON@bp5p`{c~SWnwmz zelf;|OEPVY{fJ9#!zF#zFT*8VcDsO{a1+*2bkr}e`Ep)xDGc9VaIIgG^6r;%;?_Q~ zZ)%oH0l90E5A!81#n@}@L%!h>M^pR6?!qN~Qu|Dd{md`vvwrEBU^Ht>wmg2RZC*m^ zcdLEyurc=GU%x6}hVSr>zlpK22hUIK6E5AqtxL%Ni}~^wxQzZ&1BOd>5H6?oxpBFE zd5y8wm#saH>zQN%#WsO~kg3Uw+2rlV5(DON5#Fh0FLQRX*g>UI8wj z-g4n`f_(N0;+N!{^%9O|uK;i3mvrUrpRX_JI9$Rh>$O>51}o$2`jWu&1}b?heuFDm z+}D@%nmC*I;#yLv|Ao8QX+GnRY0rKA(mw_q-Lp=e_!@iRpNTUs>&w^~xn?gTT#|S8 z@xmpUZ|h5KySeU}@yl@Onc%Z)lKvdIdj(ySw2r;5FA;Ffm-WjiLr&8g{j4v|kU%oG zp7wpjSbq7s?_&>dxKt7Rx%)o&y}ckgToP`#)nS)?pRCoV{vrNw$>?_9C%%NIS(msT zexeIsn>dP>;V+-=PkVUGGwIJZK8>$%&%9Ij;3_{5xoxj&%Zr`tb;xP&Z!bOb>AugE z%f#C2z7H<@gOL8HXZL*+pWoj1374uSW@6^U<#liU`hz-qcnT|nH<))nR<^x!8QE~e zOy2ink6)TaYzP@X7;|dM_)X&MlW)crZ+ylNoo9^$P zET5WsHu2H*@NwlcTqTC)jBfd){^Zr;kKs}KJa3$>dB}QuPh$R&<8Vp7S&u|sZD(zn z_ddg=`%}Y4Ut`UB1n$9OaM5P2^TQC!0YT0dH#|RlO=6+16!pr>5`+I;sSKJ1<&sjM z5$EfnlHE!tBvGW~aaGj(4^)sj@6*o9%T%(a?yn@}O;XMqFXP2FW&&-8$!}IaSifb= zAg1lMyH4iW$qTDQok$xGa-C}B?97fu`W~~KGubfAI`teI`?4XP6|@WJ>x@Rp&m)Ussl%A13KHJ3f7R2|TNjE0b6e2KySiFE9Jc z<^E8MMoci4N}Qn%Gnh1vIgd}eUm`g(BF7pCDXTw-sp~s#Nut?WG1jg8(S8fF0Y7ea$n<^OGekL4(wuY1OFOm44M8#` z>mkwnQ?`<8QZv9m+=3<3$f^INNnSCbHL$v#G)d2t?a}*I^0+@GkNeUDn|UlNufHca zTLd5nJopvHp<;g+QX<)l8CgSq6yjtjL5)(w^L3lR!@~6S70E6~uCKc;+vn!XFHSa&l#-?%%o2or`}#S~2)$3ksxgwzK1`7K z2ani>Ic^+gPI64S>UvUkWOKc~7}?1*zUX>_YIJlxdb<8bdOSZP=n|yAW9B8|sYT!Q zKk4ZbM1I7hB?xU8UwI^<$8Ga))yGzkCi*kw<sk&P@PUu2H#+EcOF*}Ye*^n3}a#$!hNHblukFC&ER zTb09KuqXz~jjeL_rE`BkKtDs7m5^OXhDFj4K5`F>y8!9Wv^GJO#a22`??w8)61p+$ zsi|EjRP*uvj=(kZ`1sw3zNr$%uwCzu?p#lBeJ~kB2iY(gHGNR^52^7Xxbc&NnfNbQ0rJ zg|oG)Y)1p0hDC5if)JM_q!5$H3ZP&m=1h9rGH3s@5WSw>It#1PyNQb^K7Z(`s$Cn0x`zat@=-B4U?`1NvI5yQ6WgXH>;5_V$NYh`_!5VwF#d&JBMyH%1*QX3dw#Y@t@k31iq95u%s}1wSRZ=!gyz0vF8cugd=jmMz$I+a9Nqyv#kBFnvQpNpy8KJV7fE+M%x8`>qLnEF_Em|*H@V~#h*BF!>Z z>3Y&5on{qDuPN)BcL+=pJMeajlpO2->ZujQ%whClhq+lPz)eIa?- zEPqrsr$WvD*o{G;O+b3x<0((xta$z3CF;s?7aY>#>z)oxGw8Uy@nbqSPc+*WtB?&E zTjYer2n2;?(f47|bHk$V<1rT|H^#a*?@JD=`OKMi$mbm9%riwOglAO<60`4uf%0Mgv|Jv*L-6<`o)-*JkRWk z!u616yxE+h?^L6n`ON*cl)>NiKdgi6zIVJX5c@M_+b~kWM|rUSb5jH`H*q$M;_vB= z^6rpt7~P#X=Cm)BVYEe!>v2N*#2BYMjc%^9F|`|Vu^sIx?Y2aPO)uHkb^QK1MJ=3w5B1qIJaT}Dcig)VIJz5GiS%+#b6U0zle z#^T6NyKj~;tx2!dj0NXoabc_}OIdNo&A@T|38SuuLG7ctse{Ca3=(z{Vq}Bx6!lk6 zjK>&nSTs&Na=bEZo-?dQ@5jA)HDTQGw!@k}<8hfU^JG5Htk?Oz%(;JK&bnHw#(=IPOm;J24(>SxP*0#|UMicSE!{IV~ z=G1S_^F8;|&p7L889U>-H(qYM*+0v?+9JpB=KI(eoM!DFxs5Ztxwp#(*He6hI{Hsh zuDpX!f2uJ{hj<+fZI13To_F-^(^K8~vU*TnE_30Ikmib7an88tQvurlKA?+wPHQ<> z*Xu%pF^B?cs(THZQPDE4XY3n&+HdrM@ald;U(CsKQ?KhkE*Sc>T`3$Ii9d<)P#Jp8 znYNt9o4^|jK9r&0#nrUUy!zkV%@~{Lj2-#2y1fO<=;^tsRHDCNv@X|I1Oirf(RR^y ziWOPoQLONsZopjQCGIcbvLSQIPI3|XsqE}B-ewFxoqcXmgaahMUSB^wyB(cojbp$m zT#P+o1pe!Kbe_Z)4D`FXp6^?Qxn+&S}1 zo{!FCy}4QD3um6qKGC|GF-K1KC&3wSs_5vZ?^KuWZJ5mUS>rvD9GI@|wnYke>n=8+ z&+CX3Df}q=4umup-roObsG97~_6u`qvC?AmwOHwjfvI?6U5@{&T-W6uyW26lh)%ts z&h=17{arXvcij$@OP#*6s~G6?pU4^4(`S}j+LyvWpVKqzilOD4anEz6&y}i-L%y>F zzeUDS7CE4HjgISP#*ZGG+4LRCjCYphjgab+zCPk=v(d@(fk!ANWBRYClulgyyMH0`>;gqz*?dzW_1=^7<3tGg%xj9nd2 z`bJtv3OFH+@)LxBJBcoq?)eXib8i!$K1*VVyq=6??xoL#qzQtV=Ma^7GGAoTzT1^h z+1f*&i4s?`+}i^15vbv$!S^bCj3=ecL>^j~MnIOLdw6`tIGiGtdetH|m5L_*IFn!YbrDC!Ek z<>CgzE%m$EtnPU7t){U4HsbDE7^>U*x(H<@?Bgi1K|5vU^#})Go@lwr>vl8Vhc1<~f;zFeNvw29VxQ0jo)@~nGf5%P1iC;N$O4_V z@v}g#eS9Fa1#0(~zEJqldHSS(o(t_6-*}sxGEe5y9+TPPUEBDRwlS}m*`di?pVQQ2 z1(v7yCoah>*Hze)PtlezpZgREcT1TByCHd9mg&**o*zq)d|H{)YU3$)DLDG_T<#JS zLBF9e;lpIJMl(^?Xp_RIKg&^V165$uwsdK~QZ}9t?=jZW7YaT)^;yp`-;9&-z&_(= zZetBSnP2;cJHSo7j2>&(3EE2)Q|Poiq1xrhj}U&*#i|nJ@FYKl8c2b%XXHM_c6F z>fAUlK6D7Ol6h=FL1k;cM!W7pO`XoDh(rnk(D8kBMXqnT(LF^Gj4P=DRgDdMmf5W- z8upZdv*LQrQr+ihC0K8=)iErMHvwiy0?HJGKw6K|wnW9U2|Rfr0A9)R%ve9*<}-i? z{Og&voTtx&kRj!G%poT8=r`4Oh>0AC*c_z)<5zd{yJiK$?k_Djt?!s9Zscv5NG^a8 zdv1t>9pJWXfNXaxOl;2B!T8VJXP&=7Jnug}Lq`6$?_PE}+!tuPR;X*uchXWeGx%uv z;rF~qW}*y!ltJoMa!m0DkEtbKzK*1AFbOvLjWdO#;1>MgHHIFZ9$ZaiBJIIEpXYk+ zWt^PpA1-ocoWqClr*PBfLr%1hoROCj0yia?T35ArvL|6CI*( zB1PH&JgX{gSAr%r=|9EaA&Hf3Bnr^yyn=t)(l_Tb8JX`8606O;Au6&30AoFNVNaSN zJPb<;i$e-$>Be52Wj7o)*}w`ZTe&rssj4qaSQ94S9P~f`v@U+UEuq>|OzURES=uUU zElA!g1k7BE?;pNpbQ8B<4VqzAom8u+;@&QUC9bz&u6?Xr+(`d z83*8-O0HzYI1U++>*^s_J}A`S#eg?>QGM4utoBsW$t|)$w-jJ`EvA31pM=DBm8`v?9!8~8I`&X@xg$43th+CxJV2)7{U7GR9@m5J^YlnI#x5O8_QByzwq zVM23-Z2(_iTzu{xxpP972QQ_W7%hD!bm8N?n2L`OgD|b4XT_7~CD0niqNgty4auFdZneQVgJlMN3b%zr&73sg1{8Nz3ZeWrM4Cbm${0Hx zJZ+?1QPke0d2`DBA3>gVU#nMkLYqdNlLC^Ji@F&G^_$@nd9kktV4w#c%0|C}vj;>A zY7Mx!n#JH7JIqLoLQ4`zH-eCGBM7fm__wB!NukTQ7Tv~h#tdENFzCuDsWg8(ya727 zr&O4LREWhYb(8(67CY9}n_s;L=+bRd?2};^Wy^#~v=5Xw!o$MR2qVckzy#|aMcm(~ z!(H7R`pXwEZD=U6_}iqo$Zl+Aw;~?L-5RBrkmKz(c- z02lGBf#_&q5H;V$cWRGEET;29427vfVrmO?u?ATY2VW6f90$sG11*|{I)ODi`2giJ z4X-fWAh1<(jdfF4VP!xv&6B-CfY1CHb;AMk{uyYcwrg0BIXQ@FyRNxrH?_?~hM-G{ zmetUuU(q!jbm`hm$ACo%0CU&|<61J1iu9Ot4EyzHA3%D<0ZxM$%0$#Rg=4LhFm?Z~ z{?ve!cJ|kU6Eb6y z3#2K`1xudtgeBj_Dm@pG6v15M#P%AO%@k6l`6) zpfXr?UEKU#@41;@J;Ri%e(*IHpI{G5~f9fxmpA?pz;>NFw#OwNJdKFhE-2dggRGK zZCOC&T5Am!8g)^BYh}F{v>&)_I~E)TuqnJ=Z8{ioh?Yo=lubS;UKlrCZXH?=-;hb8 z-@Hcs9J<##L@Jm_gePyPeG;sZw0PF(oBwN~%~XYyom>r-BZAaXbA@dW`0TMJw|9$M zA2c}h7QnT`R+@6=V%S1{Ya=q(8s&r8R+&KQ`9E_l`U=>$S_psj^yZ|7&pP`xf^HCH zB=mK#nI?ZGx{x-e4j_$i`CEj0(Z4Ktjt6M^_IJ%J4Tw!H$<+q^ojv&qV6NlY4|8luU*Fz@zA$RJB3UP&xEW;& z=Hdwo2TTg=(?zi=T&&q~1#NAvxHa~f9d5Ne5uDthyLhkKmKuM~R^2lozx_K!4urgb z3?L*LwmEepBv#2jejOBnUVEe>APHWpr21f)zrE1;KpV5_(YyZY??8gbjpHz&!5z)K zFk9G2(prX>a9DC8JX!d!Z**6TiS_Vfj9yK!8K!ZO6>ex;LoA8~vf3|}MYO>5Z(FW7 zdC)OvWi{e3GKvbA>DXDbM3Zg3^bzNR*}sgn-LZ@FW<9>xVV3PR5W?=s0&5TS91tH4 zU4to_dwu=NJLh;{^orD^gP8gn7_crjb^_aaJoH418as_G)E88@IO837?A@bY63}nd^yn*yZ4acNs za1QOPaE^!B(YEl>ydW-=;3y*fTWGH6bg1>b8WUJ1W+mGHZFu145OScKjS<{YOIz6Z z>9}gZ8~kb;`*#t2zi7`s2=zMJ`dUq>{s!8=S}pcD4!?A#IK>+q#~R75P*JXc(RHn@ zHrKyx@85P7njJNlKoY-7fuO?soAj-3fs_PU-%G$ssL#KL57w%RR{v6ZkG<={I~4x{ pLwu*+qvO8<3;7J3cVLnO15W>Wd35;~$f|JyYfM0}`77xC{{hlv{JsDH From 145e6428baf9e91f71890a3047e76ddb26f6ca5c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 10 Apr 2010 17:24:44 -0700 Subject: [PATCH 622/713] Fixing load errors --- basis/compiler/tests/alien.factor | 1 - basis/opengl/gl/unix/unix.factor | 2 +- basis/opengl/gl/windows/windows.factor | 2 +- core/alien/alien-docs.factor | 1 - extra/chipmunk/ffi/ffi.factor | 7 ++++--- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index a3df053ca2..8735d7cae4 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -7,7 +7,6 @@ quotations sequences specialized-arrays stack-checker stack-checker.errors system threads tools.test words alien.complex concurrency.promises ; FROM: alien.c-types => float short ; -FROM: alien.private => fastcall ; SPECIALIZED-ARRAY: float SPECIALIZED-ARRAY: char IN: compiler.tests.alien diff --git a/basis/opengl/gl/unix/unix.factor b/basis/opengl/gl/unix/unix.factor index a9d3b42b53..c0a0218ed2 100644 --- a/basis/opengl/gl/unix/unix.factor +++ b/basis/opengl/gl/unix/unix.factor @@ -1,4 +1,4 @@ -USING: kernel x11.glx ; +USING: alien kernel x11.glx ; IN: opengl.gl.unix : gl-function-context ( -- context ) glXGetCurrentContext ; inline diff --git a/basis/opengl/gl/windows/windows.factor b/basis/opengl/gl/windows/windows.factor index 2ac9894b9a..eda1e3178e 100644 --- a/basis/opengl/gl/windows/windows.factor +++ b/basis/opengl/gl/windows/windows.factor @@ -1,4 +1,4 @@ -USING: alien.c-types alien.syntax kernel windows.types ; +USING: alien alien.c-types alien.syntax kernel windows.types ; IN: opengl.gl.windows LIBRARY: gl diff --git a/core/alien/alien-docs.factor b/core/alien/alien-docs.factor index 6c64b2fac3..96eb9002be 100644 --- a/core/alien/alien-docs.factor +++ b/core/alien/alien-docs.factor @@ -3,7 +3,6 @@ alien.syntax compiler definitions math libc eval debugger parser io io.backend system alien.accessors alien.libraries alien.c-types quotations kernel sequences ; -FROM: alien.private => fastcall ; IN: alien HELP: cdecl diff --git a/extra/chipmunk/ffi/ffi.factor b/extra/chipmunk/ffi/ffi.factor index b00f64339f..c1cfabe20c 100644 --- a/extra/chipmunk/ffi/ffi.factor +++ b/extra/chipmunk/ffi/ffi.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2010 Erik Charlebois ! See http:// factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types alien.syntax classes.struct combinators -combinators.short-circuit kernel math math.order sequences -typed specialized-arrays locals system alien.libraries ; +USING: accessors alien alien.c-types alien.libraries +alien.syntax classes.struct combinators combinators.short-circuit +kernel math math.order sequences typed specialized-arrays locals +system ; SPECIALIZED-ARRAY: void* IN: chipmunk.ffi From 4fb2acb65e102fc57bd7b30d1fe1213f8eb7876c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 10 Apr 2010 17:26:56 -0700 Subject: [PATCH 623/713] vm: try a smaller call stack size on OpenBSD again, now that x86-32 stack frames are smaller --- vm/factor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vm/factor.cpp b/vm/factor.cpp index 89da7a2db7..60508e8a27 100755 --- a/vm/factor.cpp +++ b/vm/factor.cpp @@ -15,7 +15,9 @@ void factor_vm::default_parameters(vm_parameters *p) p->datastack_size = 32 * sizeof(cell); p->retainstack_size = 32 * sizeof(cell); -#ifdef FACTOR_PPC +#if defined(__OpenBSD__) && defined(FACTOR_X86) + p->callstack_size = 64 * sizeof(cell); +#elif defined(FACTOR_PPC) p->callstack_size = 256 * sizeof(cell); #else p->callstack_size = 128 * sizeof(cell); From e117300bb4df561851e790f689bde0ab08db69ac Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sat, 10 Apr 2010 22:38:17 -0700 Subject: [PATCH 624/713] Fix build breaks --- extra/gpu/demos/bunny/bunny.factor | 4 ++-- extra/gpu/demos/raytrace/raytrace.factor | 2 +- extra/macho/macho.factor | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/extra/gpu/demos/bunny/bunny.factor b/extra/gpu/demos/bunny/bunny.factor index bee94d302a..ae5757efcd 100644 --- a/extra/gpu/demos/bunny/bunny.factor +++ b/extra/gpu/demos/bunny/bunny.factor @@ -34,12 +34,12 @@ GLSL-SHADER-FILE: window-vertex-shader vertex-shader "window.v.glsl" GLSL-SHADER-FILE: sobel-fragment-shader fragment-shader "sobel.f.glsl" GLSL-PROGRAM: sobel-program window-vertex-shader sobel-fragment-shader - window-vertex ; + window-vertex-format ; GLSL-SHADER-FILE: loading-fragment-shader fragment-shader "loading.f.glsl" GLSL-PROGRAM: loading-program window-vertex-shader loading-fragment-shader - window-vertex ; + window-vertex-format ; TUPLE: bunny-state vertexes diff --git a/extra/gpu/demos/raytrace/raytrace.factor b/extra/gpu/demos/raytrace/raytrace.factor index 2ad6c82d7c..bdd1b51deb 100644 --- a/extra/gpu/demos/raytrace/raytrace.factor +++ b/extra/gpu/demos/raytrace/raytrace.factor @@ -10,7 +10,7 @@ GLSL-SHADER-FILE: raytrace-vertex-shader vertex-shader "raytrace.v.glsl" GLSL-SHADER-FILE: raytrace-fragment-shader fragment-shader "raytrace.f.glsl" GLSL-PROGRAM: raytrace-program raytrace-vertex-shader raytrace-fragment-shader - window-vertex ; + window-vertex-format ; UNIFORM-TUPLE: sphere-uniforms { "center" vec3-uniform f } diff --git a/extra/macho/macho.factor b/extra/macho/macho.factor index ea71583072..d371b3ac72 100644 --- a/extra/macho/macho.factor +++ b/extra/macho/macho.factor @@ -1,7 +1,6 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http:// factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.syntax classes.struct kernel literals math -unix.types ; +USING: alien.c-types alien.syntax classes.struct kernel literals math unix.types ; IN: macho TYPEDEF: int integer_t @@ -524,7 +523,7 @@ CONSTANT: CPU_TYPE_VAX 1 CONSTANT: CPU_TYPE_MC680x0 6 CONSTANT: CPU_TYPE_X86 7 CONSTANT: CPU_TYPE_I386 $ CPU_TYPE_X86 -CONSTANT: CPU_TYPE_X86_64 $[ CPU_TYPE_X86 CPU_ARCH_ABI64 bitor ] +CONSTANT: CPU_TYPE_X86_64 $[ $ CPU_TYPE_X86 $ CPU_ARCH_ABI64 bitor ] CONSTANT: CPU_TYPE_MC98000 10 CONSTANT: CPU_TYPE_HPPA 11 CONSTANT: CPU_TYPE_ARM 12 @@ -532,7 +531,7 @@ CONSTANT: CPU_TYPE_MC88000 13 CONSTANT: CPU_TYPE_SPARC 14 CONSTANT: CPU_TYPE_I860 15 CONSTANT: CPU_TYPE_POWERPC 18 -CONSTANT: CPU_TYPE_POWERPC64 $[ $ CPU_TYPE_POWERPC CPU_ARCH_ABI64 bitor ] +CONSTANT: CPU_TYPE_POWERPC64 $[ $ CPU_TYPE_POWERPC $ CPU_ARCH_ABI64 bitor ] CONSTANT: CPU_SUBTYPE_MASK HEX: ff000000 CONSTANT: CPU_SUBTYPE_LIB64 HEX: 80000000 From b34331431ef70476e43e039c54591db7bd22e911 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sun, 11 Apr 2010 01:46:00 -0700 Subject: [PATCH 625/713] Use vector operations instead of bespoke ones. Use different verlet integration for ease of use. --- extra/fluids/fluids.factor | 82 ++++++++++++++------------------------ 1 file changed, 30 insertions(+), 52 deletions(-) diff --git a/extra/fluids/fluids.factor b/extra/fluids/fluids.factor index 1fff38b079..f383534658 100644 --- a/extra/fluids/fluids.factor +++ b/extra/fluids/fluids.factor @@ -11,54 +11,34 @@ FROM: alien.c-types => float ; SPECIALIZED-ARRAY: float IN: fluids -STRUCT: float2_t - { x float } - { y float } ; - -: f2+ ( lhs rhs -- res ) - [ [ x>> ] bi@ + ] - [ [ y>> ] bi@ + ] - 2bi float2_t ; inline - -: f2- ( lhs rhs -- res ) - [ [ x>> ] bi@ - ] - [ [ y>> ] bi@ - ] - 2bi float2_t ; inline - -: f2*n ( lhs rhs -- res ) - [ [ x>> ] dip * ] - [ [ y>> ] dip * ] - 2bi float2_t ; inline - STRUCT: particle_t - { p float2_t } - { p' float2_t } - { m float } ; + { p float[2] } + { v float[2] } + { m float } ; SPECIALIZED-ARRAY: particle_t -CONSTANT: gravity S{ float2_t f 0.0 -0.1 } +CONSTANT: gravity { 0.0 -0.1 } -:: verlet-integrate-particle ( p dt -- p' ) - p p>> 2.0 f2*n :> v1 - p p'>> :> v2 - gravity dt dt * 1.0 p m>> 2.0 * / * f2*n :> v3 - v1 v2 f2- v3 f2+ - p p m>> particle_t ; inline +:: verlet-integrate-particle ( particle dt -- particle' ) + particle [ p>> ] [ v>> ] bi dt v*n v+ + gravity dt dt * particle m>> 2 * / v*n v+ :> p' + p' particle p>> v- dt v/n :> v' + p' v' particle m>> particle_t ; inline CONSTANT: initial-particles particle_t-array{ - S{ particle_t f S{ float2_t f 0.5 0.6 } S{ float2_t f 0.499 0.599 } 1.0 } - S{ particle_t f S{ float2_t f 0.5 0.6 } S{ float2_t f 0.501 0.599 } 3.0 } + S{ particle_t f float-array{ 0.5 0.6 } float-array{ 0 0.1 } 1.0 } + S{ particle_t f float-array{ 0.5 0.6 } float-array{ 0.1 0 } 3.0 } - S{ particle_t f S{ float2_t f 0.5 0.5 } S{ float2_t f 0.5 0.5 } 2.0 } - S{ particle_t f S{ float2_t f 0.5 0.6 } S{ float2_t f 0.5 0.599 } 1.0 } - S{ particle_t f S{ float2_t f 0.6 0.5 } S{ float2_t f 0.6 0.5 } 3.0 } - S{ particle_t f S{ float2_t f 0.7 0.5 } S{ float2_t f 0.7 0.5 } 1.0 } - S{ particle_t f S{ float2_t f 0.1 0.5 } S{ float2_t f 0.1 0.5 } 5.0 } - S{ particle_t f S{ float2_t f 0.2 0.5 } S{ float2_t f 0.2 0.5 } 1.0 } - S{ particle_t f S{ float2_t f 0.3 0.3 } S{ float2_t f 0.3 0.3 } 4.0 } - S{ particle_t f S{ float2_t f 0.5 0.15 } S{ float2_t f 0.5 0.15 } 1.0 } - S{ particle_t f S{ float2_t f 0.5 0.1 } S{ float2_t f 0.5 0.1 } 9.0 } + S{ particle_t f float-array{ 0.5 0.5 } float-array{ 0.1 0.1 } 2.0 } + S{ particle_t f float-array{ 0.5 0.6 } float-array{ -0.1 0 } 1.0 } + S{ particle_t f float-array{ 0.6 0.5 } float-array{ 0 -0.1 } 3.0 } + S{ particle_t f float-array{ 0.7 0.5 } float-array{ 0.1 0.1 } 1.0 } + S{ particle_t f float-array{ 0.1 0.5 } float-array{ -0.1 -0.1 } 5.0 } + S{ particle_t f float-array{ 0.2 0.5 } float-array{ 0 0 } 1.0 } + S{ particle_t f float-array{ 0.3 0.3 } float-array{ 0 0 } 4.0 } + S{ particle_t f float-array{ 0.5 0.15 } float-array{ 0 0 } 1.0 } + S{ particle_t f float-array{ 0.5 0.1 } float-array{ 0 0 } 9.0 } } : integrate-particles! ( particles dt -- particles ) @@ -110,18 +90,17 @@ M: fluids-world tick-game-world M:: fluids-world draw-world* ( world -- ) world particles>> [ - [ p>> [ x>> , ] [ y>> , ] bi ] each + [ p>> [ first , ] [ second , ] bi ] each ] curry float-array{ } make :> verts [ - verts world texture>> 50.0 { 320 240 } blended-point-sprite-batch &dispose - + verts world texture>> 30.0 world dim>> { 4 4 } v/ + blended-point-sprite-batch &dispose blend-state new set-gpu-state - - gaussian-blur &dispose world ramp>> { 1024 768 } step-texture &dispose - { 1024 768 } draw-texture - ] with-destructors - ; + gaussian-blur &dispose + world ramp>> world dim>> step-texture &dispose + world dim>> draw-texture + ] with-destructors ; GAME: fluids { { world-class fluids-world } @@ -132,11 +111,10 @@ GAME: fluids { { tick-interval-micros $[ 60 fps ] } } ; -MAIN: fluids - fluids-world H{ { T{ button-down } [ [ - hand-loc get { 1024 768 } v/ 2 v*n 1 v-n { 1 -1 } v* first2 float2_t - dup 2.0 particle_t suffix + hand-loc get >float-array + world get dim>> >float-array v/ 2 v*n 1 v-n { 1 -1 } v* + float-array{ 0 0.2 } 2.0 particle_t suffix ] change-particles drop ] } } set-gestures From a52103decd65299e3d4e516bbd495cbe390c1d50 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sun, 11 Apr 2010 02:57:37 -0700 Subject: [PATCH 626/713] Use the new C-ENUM for libusb --- extra/libusb/libusb.factor | 157 +++++++++++++++++++------------------ 1 file changed, 79 insertions(+), 78 deletions(-) diff --git a/extra/libusb/libusb.factor b/extra/libusb/libusb.factor index 10306c4816..b276a923b0 100644 --- a/extra/libusb/libusb.factor +++ b/extra/libusb/libusb.factor @@ -19,28 +19,28 @@ LIBRARY: libusb ALIAS: libusb_le16_to_cpu libusb_cpu_to_le16 -CONSTANT: LIBUSB_CLASS_PER_INTERFACE 0 -CONSTANT: LIBUSB_CLASS_AUDIO 1 -CONSTANT: LIBUSB_CLASS_COMM 2 -CONSTANT: LIBUSB_CLASS_HID 3 -CONSTANT: LIBUSB_CLASS_PRINTER 7 -CONSTANT: LIBUSB_CLASS_PTP 6 -CONSTANT: LIBUSB_CLASS_MASS_STORAGE 8 -CONSTANT: LIBUSB_CLASS_HUB 9 -CONSTANT: LIBUSB_CLASS_DATA 10 -CONSTANT: LIBUSB_CLASS_VENDOR_SPEC HEX: ff -TYPEDEF: int libusb_class_code +C-ENUM: libusb_class_code + { LIBUSB_CLASS_PER_INTERFACE 0 } + { LIBUSB_CLASS_AUDIO 1 } + { LIBUSB_CLASS_COMM 2 } + { LIBUSB_CLASS_HID 3 } + { LIBUSB_CLASS_PRINTER 7 } + { LIBUSB_CLASS_PTP 6 } + { LIBUSB_CLASS_MASS_STORAGE 8 } + { LIBUSB_CLASS_HUB 9 } + { LIBUSB_CLASS_DATA 10 } + { LIBUSB_CLASS_VENDOR_SPEC HEX: ff } ; -CONSTANT: LIBUSB_DT_DEVICE HEX: 01 -CONSTANT: LIBUSB_DT_CONFIG HEX: 02 -CONSTANT: LIBUSB_DT_STRING HEX: 03 -CONSTANT: LIBUSB_DT_INTERFACE HEX: 04 -CONSTANT: LIBUSB_DT_ENDPOINT HEX: 05 -CONSTANT: LIBUSB_DT_HID HEX: 21 -CONSTANT: LIBUSB_DT_REPORT HEX: 22 -CONSTANT: LIBUSB_DT_PHYSICAL HEX: 23 -CONSTANT: LIBUSB_DT_HUB HEX: 29 -TYPEDEF: int libusb_descriptor_type +C-ENUM: libusb_descriptor_type + { LIBUSB_DT_DEVICE HEX: 01 } + { LIBUSB_DT_CONFIG HEX: 02 } + { LIBUSB_DT_STRING HEX: 03 } + { LIBUSB_DT_INTERFACE HEX: 04 } + { LIBUSB_DT_ENDPOINT HEX: 05 } + { LIBUSB_DT_HID HEX: 21 } + { LIBUSB_DT_REPORT HEX: 22 } + { LIBUSB_DT_PHYSICAL HEX: 23 } + { LIBUSB_DT_HUB HEX: 29 } ; CONSTANT: LIBUSB_DT_DEVICE_SIZE 18 CONSTANT: LIBUSB_DT_CONFIG_SIZE 9 @@ -52,56 +52,57 @@ CONSTANT: LIBUSB_DT_HUB_NONVAR_SIZE 7 CONSTANT: LIBUSB_ENDPOINT_ADDRESS_MASK HEX: 0f CONSTANT: LIBUSB_ENDPOINT_DIR_MASK HEX: 80 -CONSTANT: LIBUSB_ENDPOINT_IN HEX: 80 -CONSTANT: LIBUSB_ENDPOINT_OUT HEX: 00 -TYPEDEF: int libusb_endpoint_direction +C-ENUM: libusb_endpoint_direction + { LIBUSB_ENDPOINT_IN HEX: 80 } + { LIBUSB_ENDPOINT_OUT HEX: 00 } ; CONSTANT: LIBUSB_TRANSFER_TYPE_MASK HEX: 03 -CONSTANT: LIBUSB_TRANSFER_TYPE_CONTROL 0 -CONSTANT: LIBUSB_TRANSFER_TYPE_ISOCHRONOUS 1 -CONSTANT: LIBUSB_TRANSFER_TYPE_BULK 2 -CONSTANT: LIBUSB_TRANSFER_TYPE_INTERRUPT 3 -TYPEDEF: int libusb_transfer_type +C-ENUM: libusb_transfer_type + { LIBUSB_TRANSFER_TYPE_CONTROL 0 } + { LIBUSB_TRANSFER_TYPE_ISOCHRONOUS 1 } + { LIBUSB_TRANSFER_TYPE_BULK 2 } + { LIBUSB_TRANSFER_TYPE_INTERRUPT 3 } ; -CONSTANT: LIBUSB_REQUEST_GET_STATUS HEX: 00 -CONSTANT: LIBUSB_REQUEST_CLEAR_FEATURE HEX: 01 -CONSTANT: LIBUSB_REQUEST_SET_FEATURE HEX: 03 -CONSTANT: LIBUSB_REQUEST_SET_ADDRESS HEX: 05 -CONSTANT: LIBUSB_REQUEST_GET_DESCRIPTOR HEX: 06 -CONSTANT: LIBUSB_REQUEST_SET_DESCRIPTOR HEX: 07 -CONSTANT: LIBUSB_REQUEST_GET_CONFIGURATION HEX: 08 -CONSTANT: LIBUSB_REQUEST_SET_CONFIGURATION HEX: 09 -CONSTANT: LIBUSB_REQUEST_GET_INTERFACE HEX: 0A -CONSTANT: LIBUSB_REQUEST_SET_INTERFACE HEX: 0B -CONSTANT: LIBUSB_REQUEST_SYNCH_FRAME HEX: 0C -TYPEDEF: int libusb_standard_request +C-ENUM: libusb_standard_request + { LIBUSB_REQUEST_GET_STATUS HEX: 00 } + { LIBUSB_REQUEST_CLEAR_FEATURE HEX: 01 } + { LIBUSB_REQUEST_SET_FEATURE HEX: 03 } + { LIBUSB_REQUEST_SET_ADDRESS HEX: 05 } + { LIBUSB_REQUEST_GET_DESCRIPTOR HEX: 06 } + { LIBUSB_REQUEST_SET_DESCRIPTOR HEX: 07 } + { LIBUSB_REQUEST_GET_CONFIGURATION HEX: 08 } + { LIBUSB_REQUEST_SET_CONFIGURATION HEX: 09 } + { LIBUSB_REQUEST_GET_INTERFACE HEX: 0A } + { LIBUSB_REQUEST_SET_INTERFACE HEX: 0B } + { LIBUSB_REQUEST_SYNCH_FRAME HEX: 0C } ; -CONSTANT: LIBUSB_REQUEST_TYPE_STANDARD HEX: 00 -CONSTANT: LIBUSB_REQUEST_TYPE_CLASS HEX: 20 -CONSTANT: LIBUSB_REQUEST_TYPE_VENDOR HEX: 40 -CONSTANT: LIBUSB_REQUEST_TYPE_RESERVED HEX: 60 +C-ENUM: libusb_request_type + { LIBUSB_REQUEST_TYPE_STANDARD HEX: 00 } + { LIBUSB_REQUEST_TYPE_CLASS HEX: 20 } + { LIBUSB_REQUEST_TYPE_VENDOR HEX: 40 } + { LIBUSB_REQUEST_TYPE_RESERVED HEX: 60 } ; -CONSTANT: LIBUSB_RECIPIENT_DEVICE HEX: 00 -CONSTANT: LIBUSB_RECIPIENT_INTERFACE HEX: 01 -CONSTANT: LIBUSB_RECIPIENT_ENDPOINT HEX: 02 -CONSTANT: LIBUSB_RECIPIENT_OTHER HEX: 03 -TYPEDEF: int libusb_request_recipient +C-ENUM: libusb_request_recipient + { LIBUSB_RECIPIENT_DEVICE HEX: 00 } + { LIBUSB_RECIPIENT_INTERFACE HEX: 01 } + { LIBUSB_RECIPIENT_ENDPOINT HEX: 02 } + { LIBUSB_RECIPIENT_OTHER HEX: 03 } ; CONSTANT: LIBUSB_ISO_SYNC_TYPE_MASK HEX: 0C -CONSTANT: LIBUSB_ISO_SYNC_TYPE_NONE 0 -CONSTANT: LIBUSB_ISO_SYNC_TYPE_ASYNC 1 -CONSTANT: LIBUSB_ISO_SYNC_TYPE_ADAPTIVE 2 -CONSTANT: LIBUSB_ISO_SYNC_TYPE_SYNC 3 -TYPEDEF: int libusb_iso_sync_type +C-ENUM: libusb_iso_sync_type + { LIBUSB_ISO_SYNC_TYPE_NONE 0 } + { LIBUSB_ISO_SYNC_TYPE_ASYNC 1 } + { LIBUSB_ISO_SYNC_TYPE_ADAPTIVE 2 } + { LIBUSB_ISO_SYNC_TYPE_SYNC 3 } ; CONSTANT: LIBUSB_ISO_USAGE_TYPE_MASK HEX: 30 -CONSTANT: LIBUSB_ISO_USAGE_TYPE_DATA 0 -CONSTANT: LIBUSB_ISO_USAGE_TYPE_FEEDBACK 1 -CONSTANT: LIBUSB_ISO_USAGE_TYPE_IMPLICIT 2 -TYPEDEF: int libusb_iso_usage_type +C-ENUM: libusb_iso_usage_type + { LIBUSB_ISO_USAGE_TYPE_DATA 0 } + { LIBUSB_ISO_USAGE_TYPE_FEEDBACK 1 } + { LIBUSB_ISO_USAGE_TYPE_IMPLICIT 2 } ; STRUCT: libusb_device_descriptor { bLength uint8_t } @@ -175,21 +176,21 @@ C-TYPE: libusb_context C-TYPE: libusb_device C-TYPE: libusb_device_handle -CONSTANT: LIBUSB_SUCCESS 0 -CONSTANT: LIBUSB_ERROR_IO -1 -CONSTANT: LIBUSB_ERROR_INVALID_PARAM -2 -CONSTANT: LIBUSB_ERROR_ACCESS -3 -CONSTANT: LIBUSB_ERROR_NO_DEVICE -4 -CONSTANT: LIBUSB_ERROR_NOT_FOUND -5 -CONSTANT: LIBUSB_ERROR_BUSY -6 -CONSTANT: LIBUSB_ERROR_TIMEOUT -7 -CONSTANT: LIBUSB_ERROR_OVERFLOW -8 -CONSTANT: LIBUSB_ERROR_PIPE -9 -CONSTANT: LIBUSB_ERROR_INTERRUPTED -10 -CONSTANT: LIBUSB_ERROR_NO_MEM -11 -CONSTANT: LIBUSB_ERROR_NOT_SUPPORTED -12 -CONSTANT: LIBUSB_ERROR_OTHER -99 -TYPEDEF: int libusb_error +C-ENUM: libusb_error + { LIBUSB_SUCCESS 0 } + { LIBUSB_ERROR_IO -1 } + { LIBUSB_ERROR_INVALID_PARAM -2 } + { LIBUSB_ERROR_ACCESS -3 } + { LIBUSB_ERROR_NO_DEVICE -4 } + { LIBUSB_ERROR_NOT_FOUND -5 } + { LIBUSB_ERROR_BUSY -6 } + { LIBUSB_ERROR_TIMEOUT -7 } + { LIBUSB_ERROR_OVERFLOW -8 } + { LIBUSB_ERROR_PIPE -9 } + { LIBUSB_ERROR_INTERRUPTED -10 } + { LIBUSB_ERROR_NO_MEM -11 } + { LIBUSB_ERROR_NOT_SUPPORTED -12 } + { LIBUSB_ERROR_OTHER -99 } ; C-ENUM: libusb_transfer_status LIBUSB_TRANSFER_COMPLETED @@ -200,10 +201,10 @@ C-ENUM: libusb_transfer_status LIBUSB_TRANSFER_NO_DEVICE LIBUSB_TRANSFER_OVERFLOW ; -CONSTANT: LIBUSB_TRANSFER_SHORT_NOT_OK 1 -CONSTANT: LIBUSB_TRANSFER_FREE_BUFFER 2 -CONSTANT: LIBUSB_TRANSFER_FREE_TRANSFER 4 -TYPEDEF: int libusb_transfer_flags +C-ENUM: libusb_transfer_flags + { LIBUSB_TRANSFER_SHORT_NOT_OK 1 } + { LIBUSB_TRANSFER_FREE_BUFFER 2 } + { LIBUSB_TRANSFER_FREE_TRANSFER 4 } ; STRUCT: libusb_iso_packet_descriptor { length uint } From ad0f697b145a4746928cf89b93fa30d43465a880 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 11 Apr 2010 11:49:14 -0700 Subject: [PATCH 627/713] macho: fix load errors --- extra/macho/macho.factor | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/extra/macho/macho.factor b/extra/macho/macho.factor index ea71583072..47d78569f8 100644 --- a/extra/macho/macho.factor +++ b/extra/macho/macho.factor @@ -523,8 +523,8 @@ CONSTANT: CPU_TYPE_ANY -1 CONSTANT: CPU_TYPE_VAX 1 CONSTANT: CPU_TYPE_MC680x0 6 CONSTANT: CPU_TYPE_X86 7 -CONSTANT: CPU_TYPE_I386 $ CPU_TYPE_X86 -CONSTANT: CPU_TYPE_X86_64 $[ CPU_TYPE_X86 CPU_ARCH_ABI64 bitor ] +ALIAS: CPU_TYPE_I386 CPU_TYPE_X86 +CONSTANT: CPU_TYPE_X86_64 flags{ CPU_TYPE_X86 CPU_ARCH_ABI64 } CONSTANT: CPU_TYPE_MC98000 10 CONSTANT: CPU_TYPE_HPPA 11 CONSTANT: CPU_TYPE_ARM 12 @@ -532,7 +532,7 @@ CONSTANT: CPU_TYPE_MC88000 13 CONSTANT: CPU_TYPE_SPARC 14 CONSTANT: CPU_TYPE_I860 15 CONSTANT: CPU_TYPE_POWERPC 18 -CONSTANT: CPU_TYPE_POWERPC64 $[ $ CPU_TYPE_POWERPC CPU_ARCH_ABI64 bitor ] +CONSTANT: CPU_TYPE_POWERPC64 flags{ CPU_TYPE_POWERPC CPU_ARCH_ABI64 } CONSTANT: CPU_SUBTYPE_MASK HEX: ff000000 CONSTANT: CPU_SUBTYPE_LIB64 HEX: 80000000 @@ -658,13 +658,13 @@ CONSTANT: CPUFAMILY_ARM_11 HEX: 8ff620d8 CONSTANT: CPUFAMILY_ARM_XSCALE HEX: 53b005f5 CONSTANT: CPUFAMILY_ARM_13 HEX: 0cc90e64 -CONSTANT: CPUFAMILY_INTEL_YONAH $ CPUFAMILY_INTEL_6_14 -CONSTANT: CPUFAMILY_INTEL_MEROM $ CPUFAMILY_INTEL_6_15 -CONSTANT: CPUFAMILY_INTEL_PENRYN $ CPUFAMILY_INTEL_6_23 -CONSTANT: CPUFAMILY_INTEL_NEHALEM $ CPUFAMILY_INTEL_6_26 +ALIAS: CPUFAMILY_INTEL_YONAH CPUFAMILY_INTEL_6_14 +ALIAS: CPUFAMILY_INTEL_MEROM CPUFAMILY_INTEL_6_15 +ALIAS: CPUFAMILY_INTEL_PENRYN CPUFAMILY_INTEL_6_23 +ALIAS: CPUFAMILY_INTEL_NEHALEM CPUFAMILY_INTEL_6_26 -CONSTANT: CPUFAMILY_INTEL_CORE $ CPUFAMILY_INTEL_6_14 -CONSTANT: CPUFAMILY_INTEL_CORE2 $ CPUFAMILY_INTEL_6_15 +ALIAS: CPUFAMILY_INTEL_CORE CPUFAMILY_INTEL_6_14 +ALIAS: CPUFAMILY_INTEL_CORE2 CPUFAMILY_INTEL_6_15 ! fat.h CONSTANT: FAT_MAGIC HEX: cafebabe From 328068b4809ca8723484e3363e369ea5c523dffb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 11 Apr 2010 15:00:54 -0500 Subject: [PATCH 628/713] windows: fix load errors --- basis/windows/ddk/hid/hid.factor | 4 ++-- basis/windows/ddk/setupapi/setupapi.factor | 5 +++-- basis/windows/ddk/winusb/winusb.factor | 4 ++-- basis/windows/directx/dwrite/dwrite.factor | 2 +- basis/windows/dwmapi/dwmapi.factor | 5 +++-- 5 files changed, 11 insertions(+), 9 deletions(-) mode change 100644 => 100755 basis/windows/ddk/hid/hid.factor mode change 100644 => 100755 basis/windows/ddk/setupapi/setupapi.factor mode change 100644 => 100755 basis/windows/ddk/winusb/winusb.factor mode change 100644 => 100755 basis/windows/directx/dwrite/dwrite.factor mode change 100644 => 100755 basis/windows/dwmapi/dwmapi.factor diff --git a/basis/windows/ddk/hid/hid.factor b/basis/windows/ddk/hid/hid.factor old mode 100644 new mode 100755 index d832a9d405..0e1e8e208c --- a/basis/windows/ddk/hid/hid.factor +++ b/basis/windows/ddk/hid/hid.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.libraries alien.syntax classes.struct -kernel math windows.types windows.ole32 ; +USING: alien alien.c-types alien.libraries alien.syntax +classes.struct kernel math windows.types windows.ole32 ; IN: windows.ddk.hid << "hid" "hid.dll" stdcall add-library >> diff --git a/basis/windows/ddk/setupapi/setupapi.factor b/basis/windows/ddk/setupapi/setupapi.factor old mode 100644 new mode 100755 index e4658b6e75..578a44a6d8 --- a/basis/windows/ddk/setupapi/setupapi.factor +++ b/basis/windows/ddk/setupapi/setupapi.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. -USING: literals windows.kernel32 math alien.syntax windows.types classes.struct -alien.c-types windows.errors windows.ole32 windows.advapi32 alien.libraries ; +USING: literals windows.kernel32 math alien.syntax windows.types +classes.struct alien alien.c-types windows.errors windows.ole32 +windows.advapi32 alien.libraries ; IN: windows.ddk.setupapi << "setupapi" "setupapi.dll" stdcall add-library >> diff --git a/basis/windows/ddk/winusb/winusb.factor b/basis/windows/ddk/winusb/winusb.factor old mode 100644 new mode 100755 index d40c994b19..328e16f5c9 --- a/basis/windows/ddk/winusb/winusb.factor +++ b/basis/windows/ddk/winusb/winusb.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.syntax classes.struct windows.kernel32 -windows.types alien.libraries ; +USING: alien alien.c-types alien.syntax classes.struct +windows.kernel32 windows.types alien.libraries ; IN: windows.ddk.winusb << "winusb" "winusb.dll" stdcall add-library >> diff --git a/basis/windows/directx/dwrite/dwrite.factor b/basis/windows/directx/dwrite/dwrite.factor old mode 100644 new mode 100755 index 3d635a0dc4..91dd422667 --- a/basis/windows/directx/dwrite/dwrite.factor +++ b/basis/windows/directx/dwrite/dwrite.factor @@ -233,7 +233,7 @@ COM-INTERFACE: IDWriteFont IUnknown {acd16696-8c14-4f5d-877e-fe3fc1d32737} HRESULT HasCharacter ( UINT32 unicodeValue, BOOL* exists ) HRESULT CreateFontFace ( IDWriteFontFace** fontFace ) ; -C-ENUM: DWRITE_READING_DRECTION +C-ENUM: DWRITE_READING_DIRECTION DWRITE_READING_DIRECTION_LEFT_TO_RIGHT DWRITE_READING_DIRECTION_RIGHT_TO_LEFT ; diff --git a/basis/windows/dwmapi/dwmapi.factor b/basis/windows/dwmapi/dwmapi.factor old mode 100644 new mode 100755 index 8f68643e0a..60fa5b4d83 --- a/basis/windows/dwmapi/dwmapi.factor +++ b/basis/windows/dwmapi/dwmapi.factor @@ -1,6 +1,7 @@ ! (c)2009 Joe Groff bsd license -USING: alien.c-types alien.data alien.libraries alien.syntax -classes.struct kernel math system-info.windows windows.types ; +USING: alien alien.c-types alien.data alien.libraries +alien.syntax classes.struct kernel math system-info.windows +windows.types ; IN: windows.dwmapi STRUCT: MARGINS From 18814768920fa8123c75526017f9ce88fe659df2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 11 Apr 2010 15:03:38 -0500 Subject: [PATCH 629/713] ui.backend.windows: fix icon name --- basis/ui/backend/windows/windows.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 basis/ui/backend/windows/windows.factor diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor old mode 100644 new mode 100755 index e0be2e7c99..4e271a8280 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -633,7 +633,7 @@ M: windows-ui-backend do-events 0 >>cbClsExtra 0 >>cbWndExtra f GetModuleHandle >>hInstance - f GetModuleHandle "fraptor" utf16n string>alien LoadIcon >>hIcon + f GetModuleHandle "APPICON" utf16n string>alien LoadIcon >>hIcon f IDC_ARROW LoadCursor >>hCursor class-name-ptr >>lpszClassName From a417b0e70dfc96dc6a20823df174c759c06f66fa Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 11 Apr 2010 20:26:11 -0700 Subject: [PATCH 630/713] vm: speed up nano-count primitive on Mac OS X --- vm/os-genunix.cpp | 3 +-- vm/os-macosx.mm | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/vm/os-genunix.cpp b/vm/os-genunix.cpp index c7449e867b..fb5ecf9f50 100644 --- a/vm/os-genunix.cpp +++ b/vm/os-genunix.cpp @@ -38,8 +38,7 @@ const char *default_image_path() u64 nano_count() { struct timespec t; - int ret; - ret = clock_gettime(CLOCK_MONOTONIC,&t); + int ret = clock_gettime(CLOCK_MONOTONIC,&t); if(ret != 0) fatal_error("clock_gettime failed", 0); return (u64)t.tv_sec * 1000000000 + t.tv_nsec; diff --git a/vm/os-macosx.mm b/vm/os-macosx.mm index 4a6a3cb2b4..05a9aef5c8 100644 --- a/vm/os-macosx.mm +++ b/vm/os-macosx.mm @@ -87,12 +87,19 @@ Protocol *objc_getProtocol(char *name) u64 nano_count() { - u64 t = mach_absolute_time(); - mach_timebase_info_data_t info; - kern_return_t ret = mach_timebase_info(&info); - if(ret != 0) - fatal_error("mach_timebase_info failed",ret); - return t * (info.numer/info.denom); + u64 time = mach_absolute_time(); + + static u64 scaling_factor = 0; + if(!scaling_factor) + { + mach_timebase_info_data_t info; + kern_return_t ret = mach_timebase_info(&info); + if(ret != 0) + fatal_error("mach_timebase_info failed",ret); + scaling_factor = info.numer/info.denom; + } + + return time * scaling_factor; } } From eaccd0b56ae2426eeea9a07f0df18a1f8b5cea12 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 11 Apr 2010 22:27:49 -0500 Subject: [PATCH 631/713] vm: speed up nano-count primitive on Windows --- vm/os-windows-nt.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/vm/os-windows-nt.cpp b/vm/os-windows-nt.cpp index 4fea294a12..97cd2146af 100755 --- a/vm/os-windows-nt.cpp +++ b/vm/os-windows-nt.cpp @@ -18,17 +18,24 @@ u64 system_micros() u64 nano_count() { - LARGE_INTEGER count; - LARGE_INTEGER frequency; + static double scale_factor; + static u32 hi = 0; static u32 lo = 0; - BOOL ret; - ret = QueryPerformanceCounter(&count); + + LARGE_INTEGER count; + BOOL ret = QueryPerformanceCounter(&count); if(ret == 0) fatal_error("QueryPerformanceCounter", 0); - ret = QueryPerformanceFrequency(&frequency); - if(ret == 0) - fatal_error("QueryPerformanceFrequency", 0); + + if(scale_factor == 0.0) + { + LARGE_INTEGER frequency; + BOOL ret = QueryPerformanceFrequency(&frequency); + if(ret == 0) + fatal_error("QueryPerformanceFrequency", 0); + scale_factor = (1000000000.0 / frequency.QuadPart); + } #ifdef FACTOR_64 hi = count.HighPart; @@ -40,7 +47,7 @@ u64 nano_count() #endif lo = count.LowPart; - return (u64)((((u64)hi << 32) | (u64)lo)*(1000000000.0/frequency.QuadPart)); + return (u64)((((u64)hi << 32) | (u64)lo) * scale_factor); } void sleep_nanos(u64 nsec) From 5478913e195bb0a0569c9c74c3eafc9838e4b547 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sun, 11 Apr 2010 23:51:50 -0700 Subject: [PATCH 632/713] Remove unix.types dependency from macho --- extra/macho/macho.factor | 442 +++++++++++++++++++-------------------- 1 file changed, 221 insertions(+), 221 deletions(-) diff --git a/extra/macho/macho.factor b/extra/macho/macho.factor index 57424cd243..e3765260bb 100644 --- a/extra/macho/macho.factor +++ b/extra/macho/macho.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http:// factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.syntax classes.struct kernel literals math unix.types ; +USING: alien.c-types alien.syntax classes.struct kernel literals math ; IN: macho TYPEDEF: int integer_t @@ -21,26 +21,26 @@ CONSTANT: VM_PROT_WANTS_COPY HEX: 10 ! loader.h STRUCT: mach_header - { magic uint32_t } + { magic uint } { cputype cpu_type_t } { cpusubtype cpu_subtype_t } - { filetype uint32_t } - { ncmds uint32_t } - { sizeofcmds uint32_t } - { flags uint32_t } ; + { filetype uint } + { ncmds uint } + { sizeofcmds uint } + { flags uint } ; CONSTANT: MH_MAGIC HEX: feedface CONSTANT: MH_CIGAM HEX: cefaedfe STRUCT: mach_header_64 - { magic uint32_t } + { magic uint } { cputype cpu_type_t } { cpusubtype cpu_subtype_t } - { filetype uint32_t } - { ncmds uint32_t } - { sizeofcmds uint32_t } - { flags uint32_t } - { reserved uint32_t } ; + { filetype uint } + { ncmds uint } + { sizeofcmds uint } + { flags uint } + { reserved uint } ; CONSTANT: MH_MAGIC_64 HEX: feedfacf CONSTANT: MH_CIGAM_64 HEX: cffaedfe @@ -82,8 +82,8 @@ CONSTANT: MH_NO_REEXPORTED_DYLIBS HEX: 100000 CONSTANT: MH_PIE HEX: 200000 STRUCT: load_command - { cmd uint32_t } - { cmdsize uint32_t } ; + { cmd uint } + { cmdsize uint } ; CONSTANT: LC_REQ_DYLD HEX: 80000000 @@ -124,35 +124,35 @@ CONSTANT: LC_DYLD_INFO HEX: 22 CONSTANT: LC_DYLD_INFO_ONLY HEX: 80000022 UNION-STRUCT: lc_str - { offset uint32_t } + { offset uint } { ptr char* } ; STRUCT: segment_command - { cmd uint32_t } - { cmdsize uint32_t } + { cmd uint } + { cmdsize uint } { segname char[16] } - { vmaddr uint32_t } - { vmsize uint32_t } - { fileoff uint32_t } - { filesize uint32_t } + { vmaddr uint } + { vmsize uint } + { fileoff uint } + { filesize uint } { maxprot vm_prot_t } { initprot vm_prot_t } - { nsects uint32_t } - { flags uint32_t } ; + { nsects uint } + { flags uint } ; STRUCT: segment_command_64 - { cmd uint32_t } - { cmdsize uint32_t } - { segname char[16] } - { vmaddr uint64_t } - { vmsize uint64_t } - { fileoff uint64_t } - { filesize uint64_t } - { maxprot vm_prot_t } - { initprot vm_prot_t } - { nsects uint32_t } - { flags uint32_t } ; - + { cmd uint } + { cmdsize uint } + { segname char[16] } + { vmaddr ulonglong } + { vmsize ulonglong } + { fileoff ulonglong } + { filesize ulonglong } + { maxprot vm_prot_t } + { initprot vm_prot_t } + { nsects uint } + { flags uint } ; + CONSTANT: SG_HIGHVM HEX: 1 CONSTANT: SG_FVMLIB HEX: 2 CONSTANT: SG_NORELOC HEX: 4 @@ -161,29 +161,29 @@ CONSTANT: SG_PROTECTED_VERSION_1 HEX: 8 STRUCT: section { sectname char[16] } { segname char[16] } - { addr uint32_t } - { size uint32_t } - { offset uint32_t } - { align uint32_t } - { reloff uint32_t } - { nreloc uint32_t } - { flags uint32_t } - { reserved1 uint32_t } - { reserved2 uint32_t } ; + { addr uint } + { size uint } + { offset uint } + { align uint } + { reloff uint } + { nreloc uint } + { flags uint } + { reserved1 uint } + { reserved2 uint } ; STRUCT: section_64 - { sectname char[16] } - { segname char[16] } - { addr uint64_t } - { size uint64_t } - { offset uint32_t } - { align uint32_t } - { reloff uint32_t } - { nreloc uint32_t } - { flags uint32_t } - { reserved1 uint32_t } - { reserved2 uint32_t } - { reserved3 uint32_t } ; + { sectname char[16] } + { segname char[16] } + { addr ulonglong } + { size ulonglong } + { offset uint } + { align uint } + { reloff uint } + { nreloc uint } + { flags uint } + { reserved1 uint } + { reserved2 uint } + { reserved3 uint } ; CONSTANT: SECTION_TYPE HEX: 000000ff CONSTANT: SECTION_ATTRIBUTES HEX: ffffff00 @@ -242,205 +242,205 @@ CONSTANT: SEG_IMPORT "__IMPORT" STRUCT: fvmlib { name lc_str } - { minor_version uint32_t } - { header_addr uint32_t } ; + { minor_version uint } + { header_addr uint } ; STRUCT: fvmlib_command - { cmd uint32_t } - { cmdsize uint32_t } + { cmd uint } + { cmdsize uint } { fvmlib fvmlib } ; STRUCT: dylib { name lc_str } - { timestamp uint32_t } - { current_version uint32_t } - { compatibility_version uint32_t } ; + { timestamp uint } + { current_version uint } + { compatibility_version uint } ; STRUCT: dylib_command - { cmd uint32_t } - { cmdsize uint32_t } + { cmd uint } + { cmdsize uint } { dylib dylib } ; STRUCT: sub_framework_command - { cmd uint32_t } - { cmdsize uint32_t } + { cmd uint } + { cmdsize uint } { umbrella lc_str } ; STRUCT: sub_client_command - { cmd uint32_t } - { cmdsize uint32_t } + { cmd uint } + { cmdsize uint } { client lc_str } ; STRUCT: sub_umbrella_command - { cmd uint32_t } - { cmdsize uint32_t } + { cmd uint } + { cmdsize uint } { sub_umbrella lc_str } ; STRUCT: sub_library_command - { cmd uint32_t } - { cmdsize uint32_t } + { cmd uint } + { cmdsize uint } { sub_library lc_str } ; STRUCT: prebound_dylib_command - { cmd uint32_t } - { cmdsize uint32_t } + { cmd uint } + { cmdsize uint } { name lc_str } - { nmodules uint32_t } + { nmodules uint } { linked_modules lc_str } ; STRUCT: dylinker_command - { cmd uint32_t } - { cmdsize uint32_t } + { cmd uint } + { cmdsize uint } { name lc_str } ; STRUCT: thread_command - { cmd uint32_t } - { cmdsize uint32_t } ; + { cmd uint } + { cmdsize uint } ; STRUCT: routines_command - { cmd uint32_t } - { cmdsize uint32_t } - { init_address uint32_t } - { init_module uint32_t } - { reserved1 uint32_t } - { reserved2 uint32_t } - { reserved3 uint32_t } - { reserved4 uint32_t } - { reserved5 uint32_t } - { reserved6 uint32_t } ; + { cmd uint } + { cmdsize uint } + { init_address uint } + { init_module uint } + { reserved1 uint } + { reserved2 uint } + { reserved3 uint } + { reserved4 uint } + { reserved5 uint } + { reserved6 uint } ; STRUCT: routines_command_64 - { cmd uint32_t } - { cmdsize uint32_t } - { init_address uint64_t } - { init_module uint64_t } - { reserved1 uint64_t } - { reserved2 uint64_t } - { reserved3 uint64_t } - { reserved4 uint64_t } - { reserved5 uint64_t } - { reserved6 uint64_t } ; + { cmd uint } + { cmdsize uint } + { init_address ulonglong } + { init_module ulonglong } + { reserved1 ulonglong } + { reserved2 ulonglong } + { reserved3 ulonglong } + { reserved4 ulonglong } + { reserved5 ulonglong } + { reserved6 ulonglong } ; STRUCT: symtab_command - { cmd uint32_t } - { cmdsize uint32_t } - { symoff uint32_t } - { nsyms uint32_t } - { stroff uint32_t } - { strsize uint32_t } ; + { cmd uint } + { cmdsize uint } + { symoff uint } + { nsyms uint } + { stroff uint } + { strsize uint } ; STRUCT: dysymtab_command - { cmd uint32_t } - { cmdsize uint32_t } - { ilocalsym uint32_t } - { nlocalsym uint32_t } - { iextdefsym uint32_t } - { nextdefsym uint32_t } - { iundefsym uint32_t } - { nundefsym uint32_t } - { tocoff uint32_t } - { ntoc uint32_t } - { modtaboff uint32_t } - { nmodtab uint32_t } - { extrefsymoff uint32_t } - { nextrefsyms uint32_t } - { indirectsymoff uint32_t } - { nindirectsyms uint32_t } - { extreloff uint32_t } - { nextrel uint32_t } - { locreloff uint32_t } - { nlocrel uint32_t } ; + { cmd uint } + { cmdsize uint } + { ilocalsym uint } + { nlocalsym uint } + { iextdefsym uint } + { nextdefsym uint } + { iundefsym uint } + { nundefsym uint } + { tocoff uint } + { ntoc uint } + { modtaboff uint } + { nmodtab uint } + { extrefsymoff uint } + { nextrefsyms uint } + { indirectsymoff uint } + { nindirectsyms uint } + { extreloff uint } + { nextrel uint } + { locreloff uint } + { nlocrel uint } ; CONSTANT: INDIRECT_SYMBOL_LOCAL HEX: 80000000 CONSTANT: INDIRECT_SYMBOL_ABS HEX: 40000000 STRUCT: dylib_table_of_contents - { symbol_index uint32_t } - { module_index uint32_t } ; + { symbol_index uint } + { module_index uint } ; STRUCT: dylib_module - { module_name uint32_t } - { iextdefsym uint32_t } - { nextdefsym uint32_t } - { irefsym uint32_t } - { nrefsym uint32_t } - { ilocalsym uint32_t } - { nlocalsym uint32_t } - { iextrel uint32_t } - { nextrel uint32_t } - { iinit_iterm uint32_t } - { ninit_nterm uint32_t } - { objc_module_info_addr uint32_t } - { objc_module_info_size uint32_t } ; + { module_name uint } + { iextdefsym uint } + { nextdefsym uint } + { irefsym uint } + { nrefsym uint } + { ilocalsym uint } + { nlocalsym uint } + { iextrel uint } + { nextrel uint } + { iinit_iterm uint } + { ninit_nterm uint } + { objc_module_info_addr uint } + { objc_module_info_size uint } ; STRUCT: dylib_module_64 - { module_name uint32_t } - { iextdefsym uint32_t } - { nextdefsym uint32_t } - { irefsym uint32_t } - { nrefsym uint32_t } - { ilocalsym uint32_t } - { nlocalsym uint32_t } - { iextrel uint32_t } - { nextrel uint32_t } - { iinit_iterm uint32_t } - { ninit_nterm uint32_t } - { objc_module_info_size uint32_t } - { objc_module_info_addr uint64_t } ; + { module_name uint } + { iextdefsym uint } + { nextdefsym uint } + { irefsym uint } + { nrefsym uint } + { ilocalsym uint } + { nlocalsym uint } + { iextrel uint } + { nextrel uint } + { iinit_iterm uint } + { ninit_nterm uint } + { objc_module_info_size uint } + { objc_module_info_addr ulonglong } ; STRUCT: dylib_reference - { isym_flags uint32_t } ; + { isym_flags uint } ; STRUCT: twolevel_hints_command - { cmd uint32_t } - { cmdsize uint32_t } - { offset uint32_t } - { nhints uint32_t } ; + { cmd uint } + { cmdsize uint } + { offset uint } + { nhints uint } ; STRUCT: twolevel_hint - { isub_image_itoc uint32_t } ; + { isub_image_itoc uint } ; STRUCT: prebind_cksum_command - { cmd uint32_t } - { cmdsize uint32_t } - { cksum uint32_t } ; + { cmd uint } + { cmdsize uint } + { cksum uint } ; STRUCT: uuid_command - { cmd uint32_t } - { cmdsize uint32_t } - { uuid uint8_t[16] } ; + { cmd uint } + { cmdsize uint } + { uuid uchar[16] } ; STRUCT: rpath_command - { cmd uint32_t } - { cmdsize uint32_t } + { cmd uint } + { cmdsize uint } { path lc_str } ; STRUCT: linkedit_data_command - { cmd uint32_t } - { cmdsize uint32_t } - { dataoff uint32_t } - { datasize uint32_t } ; + { cmd uint } + { cmdsize uint } + { dataoff uint } + { datasize uint } ; STRUCT: encryption_info_command - { cmd uint32_t } - { cmdsize uint32_t } - { cryptoff uint32_t } - { cryptsize uint32_t } - { cryptid uint32_t } ; + { cmd uint } + { cmdsize uint } + { cryptoff uint } + { cryptsize uint } + { cryptid uint } ; STRUCT: dyld_info_command - { cmd uint32_t } - { cmdsize uint32_t } - { rebase_off uint32_t } - { rebase_size uint32_t } - { bind_off uint32_t } - { bind_size uint32_t } - { weak_bind_off uint32_t } - { weak_bind_size uint32_t } - { lazy_bind_off uint32_t } - { lazy_bind_size uint32_t } - { export_off uint32_t } - { export_size uint32_t } ; + { cmd uint } + { cmdsize uint } + { rebase_off uint } + { rebase_size uint } + { bind_off uint } + { bind_size uint } + { weak_bind_off uint } + { weak_bind_size uint } + { lazy_bind_off uint } + { lazy_bind_size uint } + { export_off uint } + { export_size uint } ; CONSTANT: REBASE_TYPE_POINTER 1 CONSTANT: REBASE_TYPE_TEXT_ABSOLUTE32 2 @@ -493,20 +493,20 @@ CONSTANT: EXPORT_SYMBOL_FLAGS_INDIRECT_DEFINITION HEX: 08 CONSTANT: EXPORT_SYMBOL_FLAGS_HAS_SPECIALIZATIONS HEX: 10 STRUCT: symseg_command - { cmd uint32_t } - { cmdsize uint32_t } - { offset uint32_t } - { size uint32_t } ; + { cmd uint } + { cmdsize uint } + { offset uint } + { size uint } ; STRUCT: ident_command - { cmd uint32_t } - { cmdsize uint32_t } ; + { cmd uint } + { cmdsize uint } ; STRUCT: fvmfile_command - { cmd uint32_t } - { cmdsize uint32_t } + { cmd uint } + { cmdsize uint } { name lc_str } - { header_addr uint32_t } ; + { header_addr uint } ; ! machine.h CONSTANT: CPU_STATE_MAX 4 @@ -670,30 +670,30 @@ CONSTANT: FAT_MAGIC HEX: cafebabe CONSTANT: FAT_CIGAM HEX: bebafeca STRUCT: fat_header - { magic uint32_t } - { nfat_arch uint32_t } ; + { magic uint } + { nfat_arch uint } ; STRUCT: fat_arch { cputype cpu_type_t } { cpusubtype cpu_subtype_t } - { offset uint32_t } - { size uint32_t } - { align uint32_t } ; + { offset uint } + { size uint } + { align uint } ; ! nlist.h STRUCT: nlist - { n_strx int32_t } - { n_type uint8_t } - { n_sect uint8_t } - { n_desc int16_t } - { n_value uint32_t } ; + { n_strx int } + { n_type uchar } + { n_sect uchar } + { n_desc short } + { n_value uint } ; STRUCT: nlist_64 - { n_strx uint32_t } - { n_type uint8_t } - { n_sect uint8_t } - { n_desc uint16_t } - { n_value uint64_t } ; + { n_strx uint } + { n_type uchar } + { n_sect uchar } + { n_desc ushort } + { n_value ulonglong } ; CONSTANT: N_STAB HEX: e0 CONSTANT: N_PEXT HEX: 10 @@ -750,24 +750,24 @@ CONSTANT: SYMDEF "__.SYMDEF" CONSTANT: SYMDEF_SORTED "__.SYMDEF SORTED" STRUCT: ranlib - { ran_strx uint32_t } - { ran_off uint32_t } ; + { ran_strx uint } + { ran_off uint } ; ! reloc.h STRUCT: relocation_info - { r_address int32_t } - { r_symbolnum_pcrel_length_extern_type uint32_t } ; + { r_address int } + { r_symbolnum_pcrel_length_extern_type uint } ; CONSTANT: R_ABS 0 CONSTANT: R_SCATTERED HEX: 80000000 STRUCT: scattered_relocation_info_big_endian - { r_scattered_pcrel_length_type_address uint32_t } - { r_value int32_t } ; + { r_scattered_pcrel_length_type_address uint } + { r_value int } ; STRUCT: scattered_relocation_info_little_endian - { r_address_type_length_pcrel_scattered uint32_t } - { r_value int32_t } ; + { r_address_type_length_pcrel_scattered uint } + { r_value int } ; C-ENUM: reloc_type_generic GENERIC_RELOC_VANILLA From 3d4dadffe2728c8de93cc1c0af4e4e9246434246 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 12 Apr 2010 00:49:16 -0700 Subject: [PATCH 633/713] Image encoding/decoding of PBM format --- basis/images/pbm/authors.txt | 1 + basis/images/pbm/pbm-tests.factor | 7 + basis/images/pbm/pbm.factor | 85 ++++++ basis/images/pbm/summary.txt | 1 + extra/images/testing/pbm/test.ascii.fig | Bin 0 -> 25659 bytes extra/images/testing/pbm/test.ascii.pbm | 369 +++++++++++++++++++++++ extra/images/testing/pbm/test.binary.fig | Bin 0 -> 25659 bytes extra/images/testing/pbm/test.binary.pbm | Bin 0 -> 3250 bytes 8 files changed, 463 insertions(+) create mode 100644 basis/images/pbm/authors.txt create mode 100644 basis/images/pbm/pbm-tests.factor create mode 100644 basis/images/pbm/pbm.factor create mode 100644 basis/images/pbm/summary.txt create mode 100644 extra/images/testing/pbm/test.ascii.fig create mode 100644 extra/images/testing/pbm/test.ascii.pbm create mode 100644 extra/images/testing/pbm/test.binary.fig create mode 100644 extra/images/testing/pbm/test.binary.pbm diff --git a/basis/images/pbm/authors.txt b/basis/images/pbm/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/basis/images/pbm/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/basis/images/pbm/pbm-tests.factor b/basis/images/pbm/pbm-tests.factor new file mode 100644 index 0000000000..73558cc144 --- /dev/null +++ b/basis/images/pbm/pbm-tests.factor @@ -0,0 +1,7 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: images.testing ; +IN: images.pbm.tests + +"vocab:images/testing/pbm/test.binary.pbm" decode-test +"vocab:images/testing/pbm/test.ascii.pbm" decode-test diff --git a/basis/images/pbm/pbm.factor b/basis/images/pbm/pbm.factor new file mode 100644 index 0000000000..ba27c545cf --- /dev/null +++ b/basis/images/pbm/pbm.factor @@ -0,0 +1,85 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien.c-types arrays ascii bit-arrays byte-arrays +combinators continuations grouping images images.loader io +io.encodings.ascii io.encodings.string kernel locals make math +math.functions math.parser sequences specialized-arrays ; +SPECIALIZED-ARRAY: ushort +IN: images.pbm + +SINGLETON: pbm-image +"pbm" pbm-image register-image-class + +number ; + +: read-ascii-bits ( -- ) + read1 { + { CHAR: 1 [ 0 , read-ascii-bits ] } + { CHAR: 0 [ 255 , read-ascii-bits ] } + { f [ ] } + [ drop read-ascii-bits ] + } case ; + +:: read-binary-bits ( width height -- ) + width 8 align 8 / height * read + width 8 align 8 / [| row | + width iota [| n | + n 8 / floor row nth + n 8 mod 7 swap - bit? + [ 0 ] [ 255 ] if , + ] each + ] each ; + +:: write-binary-bits ( bitmap width -- ) + bitmap width [ + width 8 align 255 pad-tail + 8 [ + [ 255 = [ f ] [ t ] if ] { } map-as + >bit-array reverse bit-array>integer + 1array >byte-array write + ] each + ] each ; + +:: read-pbm ( -- image ) + read-token :> type + read-number :> width + read-number :> height + width height * :> npixels + width 8 mod :> leftover + + type { + { "P1" [ [ [ read-ascii-bits ] ignore-errors ] B{ } make ] } + { "P4" [ [ width height read-binary-bits ] B{ } make ] } + } case :> data + + image new + L >>component-order + { width height } >>dim + f >>upside-down? + data >>bitmap + ubyte-components >>component-type ; +PRIVATE> + +M: pbm-image stream>image + drop [ read-pbm ] with-input-stream ; + +M: pbm-image image>stream + drop { + [ drop "P4\n" ascii encode write ] + [ dim>> first number>string " " append ascii encode write ] + [ dim>> second number>string "\n" append ascii encode write ] + [ [ bitmap>> ] [ dim>> first ] bi write-binary-bits ] + } cleave ; diff --git a/basis/images/pbm/summary.txt b/basis/images/pbm/summary.txt new file mode 100644 index 0000000000..4f484f91a8 --- /dev/null +++ b/basis/images/pbm/summary.txt @@ -0,0 +1 @@ +Image loading for PBM image files. diff --git a/extra/images/testing/pbm/test.ascii.fig b/extra/images/testing/pbm/test.ascii.fig new file mode 100644 index 0000000000000000000000000000000000000000..aee805ec6985a325ad215ee428ef13f16dc889c4 GIT binary patch literal 25659 zcmeHO%WmaF5DokfAHkj_KM){7EG8K#gCdqe8rFOQe;T@NclW7hm+jlOK{p`XQ*|D7 zu9Hk=M)2d?>(}2tJ^uRi`q%vO`1SG6&)@u${(XCW|Ka8R?e*{9fBNIg(|13=eER(I z{Pg_g_2vEf`)_}FC?6kJ`zXcA>&5z&TJ`nn{T?n=us*g5E>-X2qxLG`-fz_tD37ha zu5uqBUWzTB=mQR}Jn=9$OJ9lUpG$sRw%8?~*1gpI3EZE+{R#YUpFsUdFTfRkfQeFU zaq_2ywb8~i8)|*T?!1DcioQ6lpk7C8@BQ>AARd&l(B0#=Mjf#p-$cD2dRPn9J$`A` z5&Q8~)C;1AwNTyTmsm$!b4j5dvT!T7B5KIOt>BVF>WEOcf=i01Aq%&H zOAe_cLfr~3DWZlf+zKu^q>c!6E4ZYH3N3Qvnm^LG6T&_dMc*&am}U}G2UW_KRh_^Zj%&RcZvgfzg#-Dh ze&hrhN(t{33_=E+c(y`pEii;(%L03JzWlc(MB2a_%?m{VYZ6-L1jiCr#+5ql^N{@R$Od_Mn>V6-x9+ZwnTN?Mv?1Aveh8lG;~g(ydza;->tE@%UB5|E7TJrH27}G z;%36#E9mHog}`@97B?A-K(RoFAiE3S%~_l$+|8#y2Lo~@!HbN_Bc*Ygv0~vXG;yv! zcie==VZ#0Rq(E25Ktvrk(h`#-Ye1W&vG*M}(j42Ngh3l2LPO7uJjJ2-Btloz({w#I z@&vaCAEC)ts%+1WJYqFWTW&J7pq?Fhz%8JMz!dn!T%`5v$X6^pT-;K3f7^?A|9oqL|?G(w>1f3o6 z?;NyK7^(5S9r|}-^%Q2Rg3c2CyRdNwGYyHmM*ntfo*&EYZ%1WL0Ak5Gg>nw|yM=n)GfrHe?Q$sV2m?rL1B&x3G<9ul5 z$AyUt>MWFWQFR4SIyx2i@+xeMFQd@$MG@9lE{M)GAOXdLbiw31NAaXpk+xS|*Wb2; zaJ_CQWER-)xn%8}{>-6T;KT$~5nFOknwjEu zBfAv{W{x}tTw5jNS}24#<{{+UCc1T;)I}~F zaF3M9d$O1YP@e#4AEn<3o$w^>Cnl7hgGD7=oKuNh#X15LiJq>03Rkvwkg8x(pT xxbvqtjT6^aFKFI8tqvguNF@7h1EdwWEeKpwknz{)AdA7$s=da1N2yA$e*tvWh=KqB literal 0 HcmV?d00001 diff --git a/extra/images/testing/pbm/test.ascii.pbm b/extra/images/testing/pbm/test.ascii.pbm new file mode 100644 index 0000000000..2cf2555793 --- /dev/null +++ b/extra/images/testing/pbm/test.ascii.pbm @@ -0,0 +1,369 @@ +P1 +# CREATOR: GIMP PNM Filter Version 1.1 +160 160 +1111111100000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000111111111111111100000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000011111111111111111000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000111111111111111111 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0111111111111111111000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000111111111111111110000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000001111111111111111100000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000011111111 +1111111110000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000111111101111110000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000001011111001010000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000101000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000001111 +1111111111111111111111010000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000011111111111111111111111111111111000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000001111111111111111111111111111111111100 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000111111111111111111 +1111111111111111111000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0111111111111111111111111111111111111111000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000001111111111111111111111111111111111111110000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000011111111111111111111111111111 +1111111111000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000001111111111 +1111111111111111111111111111110000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000111111111111111111111111111111111111111100000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000011111111111111111111111111111111111111111 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000111111111111111111111 +1111111111111111111100000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000001 +1111111111111111111111111111111111111111000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000111111111111000000000000000001111111111110000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000001111111111110000000000000000011 +1111111111000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000011111111111 +1000000000000000001111111111110000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000001111111111110000000000000000011111111111100000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000011111111111100000000000000000111111111111 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000111111111111000000000 +0000000011111111111100000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000001 +1111111111100000000000000000111111111111000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000111111111111000000000000000001111111111110000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000001111111111110000000000000000011 +1111111111000000000000000000000000000000000000000000000000000000000000 +0000000000011110100000000000000000000000000000000000000000011111111111 +1000000000000000001111111111110000000000000000000000000000000000000000 +0000000000000000000000000000111111111110000000000000000000000000000000 +0000000001111111111110000000000000000011111111111100000000000000000000 +0000000000000000000000000000000000000000000000111111111111110000000000 +0000000000000000000000000000011111111111100000000000000000111111111111 +0000000000000000000000000000000000000000000000000000000000000001111111 +1111111111100000000000000000000000000000000000000111111111111000000000 +0000000111111111111100000000000000000000000000000000000000000000000000 +0000000000111111111111111111111100000000000000000000000000000000000001 +1111111111100000000000000001111111111110000000000000000000000000000000 +0000000000000000000000000000011111111111111111111111000000000000000000 +0000000000000000001111111111111000000000000000011111111111100000000000 +0000000000000000000000000000000000000000000000011111111111111111111111 +1110000000000000000000000000000000000001111111111100000000000000000111 +1111111110000000000000000000000000000000000000000000000000000000001111 +1111111111111111111111100000000000000000000000000000000000111111111111 +0000000000000000011111111111100000000000000000000000000000000000000000 +0000000000000011111111111111111111111111111000000000000000000000000000 +0000000011111111111100000000000000000111111111110000000000000000000000 +0000000000000000000000000000000011111111111111111111111111111110000000 +0000000000000000000000000000111111111111000000000000000011111111111100 +0000000000000000000000000000000000000000000000000001111111111111111111 +1111111111111000000000000000000000000000000000001111111111110000000000 +0000001111111111110000000000000000000000000000000000000000000000000000 +1111111111111111111111111111111110000000000000000000000000000000000011 +1111111111000000000000000011111111111100000000000000000000000000000000 +0000000000000000000111111111111111111111111111111111110000000000000000 +0000000000000000001111111111110000000000000000111111111111000000000000 +0000000000000000000000000000000000000001111111111111111111111011111111 +1111000000000000000000000000000000000111111111111100000000000000001111 +1111111100000000000000000000000000000000000000000000000000011111111111 +1111110000001111111111110000000000000000000000000000000011111111111110 +0000000000000000111111111111000000000000000000000000000000000000000000 +0000000011111111111111111000000011111111111110000000000000000000000000 +0000011111111111111000000000000000001111111111110000000000000000000000 +0000000000000000000000000000111111111111111000000000011111111111000000 +0000000000000000000000000111111111111110000000000000000011111111111100 +0000000000000000000000000000000000000000000000001111111111111100000000 +0001111111111110000000000000000000000000000011111111111111000000000000 +0000001111111111110000000000000000000000000000000000000000000000000011 +1111111111000000000000011111111111100000000000000000000000000011111111 +1111111100000000000000000011111111111100000000000000000000000000000000 +0000000000000000001111111111100000000000000111111111111000000000000000 +0000000000001111111111111110000000000000000000111111111111000000000000 +0000000000000000000000000000000000000111111111111000000000000001111111 +1111100000000000000000000000000111111111111111000000000000000000001111 +1111111100000000000000000000000000000000000000000000000001111111111110 +0000000000000111111111111000000000000000000000000011111111111111110000 +0000000000000000111111111111000000000000000000000000000000000000000000 +0000000111111111111000000000000001111111111110000000000000000000000001 +1111111111111110000000000000000000001111111111110000000000000000000000 +0000000000000000000000000001111111111110000000000000011111111111110000 +0000000000000000000111111111111111000000000000000000000011111111111100 +0000000000000000000000000000000000000000000000011111111111100000000000 +0000111111111111000000000000000000000111111111111111100000000000000000 +0000001111111111110000000000000000000000000000000000000000000000000111 +1111111110000000000000001111111111110000000000000000000011111111111111 +1100000000000000000000000011111111111100000000000000000000000000000000 +0000000000000000011111111111100000000000000011111111111110000000000000 +0000011111111111111110000000000000000000000000111111111111000000000000 +0000000000000000000000000000000000000111111111111000000000000000011111 +1111111000000000000000000111111111111111100000000000000000000000001111 +1111111100000000000000000000000000000000000000000000000001111111111110 +0000000000000001111111111110000000000000000111111111111111100000000000 +0000000000000000111111111110000000000000000000000000000000000000000000 +0000000111111111111000000000000000011111111111100000000000000001111111 +1111111110000000000000000000000000011111111111110000000000000000000000 +0000000000000000000000000001111111111110000000000000000111111111111000 +0000000000001111111111111111000000000000000000000000000111111111111000 +0000000000000000000000000000000000000000000000011111111111100000000000 +0000011111111111110000000000000111111111111111100000000000000000000000 +0000011111111111100000000000000000000000000000000000000000000000000111 +1111111110000000000000000011111111111100000000000011111111111111110000 +0000000000000000000000000111111111111000000000000000000000000000000000 +0000000000000000011111111111100000000000000000111111111111000000000001 +1111111111111100000000000000000000000000000001111111111110000000000000 +0000000000000000000000000000000000000111111111111000000000000000001111 +1111111110000000001111111111111111000000000000000000000000000000011111 +1111111000000000000000000000000000000000000000000000000001111111111110 +0000000000000000011111111111100000000111111111111111100000000000000000 +0000000000000001111111111110000000000000000000000000000000000000000000 +0000000111111111111000000000000000000111111111111000000111111111111111 +1100000000000000000000000000000000011111111111100000000000000000000000 +0000000000000000000000000001111111111110000000000000000001111111111110 +0000011111111111111110000000000000000000000000000000000111111111111000 +0000000000000000000000000000000000000000000000011111111111100000000000 +0000000111111111111000011111111111111111000000000000000000000000000000 +0000011111111111100000000000000000000000000000000000000000000000000111 +1111111110000000000000000000111111111111001111111111111111110000000000 +0000000000000000000000000111111111111000000000000000000000000000000000 +0000000000000000011111111111100000000000000000001111111111110111111111 +1111111100000000000000000000000000000000000001111111111110000000000000 +0000000000000000000000000000000000000111111111111000000000000000000011 +1111111111111111111111111111000000000000000000000000000000000000011111 +1111111000000000000000000000000000000000000000000000000001111111111110 +0000000000000000001111111111111111111111111111000000000000000000000000 +0000000000000001111111111110000000000000000000000000000000000000000000 +0000000111111111111000000000000000000001111111111111111111111111100000 +0000000000000000000000000000000000011111111111100000000000000000000000 +0000000000000000000000000001111111111110000000000000000000011111111111 +1111111111111100000000000000000000000000000000000000001111111111110000 +0000000000000000000000000000000000000000000000011111111111100000000000 +0000000001111111111111111111111110000000000000000000000000000000000000 +0000111111111111000000000000000000000000000000000000000000000000000111 +1111111110000000000000000000011111111111111111111111000000000000000000 +0000000000000000000000001111111111110000000000000000000000000000000000 +0000000000000000011111111111100000000000000000000111111111111111111111 +0000000000000000000000000000000000000000000011111111111100000000000000 +0000000000000000000000000000000000000111111111111000000000000000000001 +1111111111111111111000000000000000000000000000000000000000000000111111 +1111110000000000000000000000000000000000000000000000000001111111111110 +0000000000000000000111111111111111111100000000000000000000000000000000 +0000000000000011111111111100000000000000000000000000000000000000000000 +0000000111111111111000000000000000000000111111111111111110000000000000 +0000000000000000000000000000000000111111111111000000000000000000000000 +0000000000000000000000000001111111111110000000000000000000001111111111 +1111111000000000000000000000000000000000000000000000001111111111110000 +0000000000000000000000000000000000000000000000011111111111100000000000 +0000000000111111111111111000000000000000000000000000000000000000000000 +0000111111111111000000000000000000000000000000000000000000000000000111 +1111111110000000000000000000001111111111111000000000000000000000000000 +0000000000000000000000001111111111110000000000000000000000000000000000 +0000000000000000011111111111100000000000000000000001111111111110000000 +0000000000000000000000000000000000000000000011111111111100000000000000 +0000000000000000000000000000000000000111111111111000000000000000000000 +0011111111110000000000000000000000000000000000000000000000000000111111 +1111110000000000000000000000000000000000000000000000000001111111111110 +0000000000000000000000011111110000001011111111111110100000000000000000 +0000000000000011111111111100000000000000000000000000000000000000000000 +0000000111111111111000000000000000000000000000101010111111111111111111 +1111111111000000000000000000000000111111111111000000000000000000000000 +0000000000000000000000000001111111111110000000000000000000000000001111 +1111111111111111111111111111111100000000000000000000001111111111110000 +0000000000000000000000000000000000000000000000011111111111100000000000 +0000000101111111111111111111111111111111111111111111100000000000000000 +0000111111111111000000000000000000000000000000000000000000000000000111 +1111111110000000000000101111111111111111111111111111111111111111111111 +1110000000000000000000001111111111110000000000000000000000000000000000 +0000000000000000011111111111100000101111111111111111111111111111111111 +1111111111111111111111110000000000000000000011111111111100000000000000 +0000000000000000000000000000000000000111111111111000111111111111111111 +1111111111111111111111111111111111111111111100000000000000000000111111 +1111110000000000000000000000000000000000000000000000000001111111111110 +0011111111111111111111111111111111111111111111111111111111111111000000 +0000000000000011111111111100000000000000000000000000000000000000000000 +0000000111111111111111111111111111111111111111111111111111111111111111 +1111111111111100000000000000000000111111111111000000000000000000000000 +0000000000000000000000000001111111111111111111111111111111111111111111 +1111111111111111111111111111111110000000000000000000011111111111110000 +0000000000000000000000000000000000000000000000011111111111111111111111 +1111111111111111111111111111111111111111111111111111100000000000000000 +0001111111111110000000000000000000000000000000000000000000000000000111 +1111111111111111111111111111111111111111111111111111111111111111111111 +1100000000000000000000011111111111100000000000000000000000000000000000 +0000000000000000011111111111111111111111111111111111111111111111111111 +1111111111111111111100000000000000000000000111111111111000000000000000 +0000000000000000000000000000000000000111111111111111111111111111111111 +1111111111111111111111111111111111111000000000000000000000000011111111 +1111100000000000000000000000000000000000000000000000000001111111111111 +1111111111111111111111111111111111111111111111111111110000000000000000 +0000000000011111111111110000000000000000000000000000000000000000000000 +0000000111111111111111111111111111110100000000111111111111111111111111 +1100000000000000000000000000000111111111111100000000000000000000000000 +0000000000000000000000000001111111111111111111111111010000000000011111 +1111111111111111111000000000000000000000000000000111111111111111000000 +0000000000000000000000000000000000000000000000111111111111111111111000 +0000000000000111111111111111111111111000000000000000000000000000000001 +1111111111111000000000000000000000000000000000000000000000000000001111 +1111111111111110000000000000000111111111111111111111111000000000000000 +0000000000000000011111111111111110000000000000000000000000000000000000 +0000000000000000111111111111111100000000000000000111111111111111111111 +1111000000000000000000000000000000011111111111111111000000000000000000 +0000000000000000000000000000000000001111111111111110000000000000000011 +1111111111111111111110000000000000000000000000000000001111111111111111 +1000000000000000000000000000000000000000000000000000000001111111111110 +0000000000000000001111111111111111111101000000000000000000000000000000 +0001111111111111111110000000000000000000000000000000000000000000000000 +0000000111111111110000000000000000000111111111111111111110000000000000 +0000000000000000000001111111111111111111000000000000000000000000000000 +0000000000000000000000000000111111111000000000000000000011111111111111 +1111110000000000000000000000000000000000011111111111111111100000000000 +0000000000000000000000000000000000000000000000000111111100000000000000 +0000001111111111111111100000000000000000000000000000000000011111111111 +1111111100000000000000000000000000000000000000000000000000000000000000 +0010100000000000000000000011111111111111110000000000000000000000000000 +0000000011111111111111111110000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000111111111111111000000000 +0000000000000000000000000011111111111111111110000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000001111 +1111111110000000000000000000000000000000000000111111111111111111100000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000111111111111000000000000000000000000000000000000011111 +1111111111110000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000001111111111110000000000000000000000 +0000000000000011111111111111111000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000011111111111100 +0000000000000000000000000000000001111111111111111100000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000001111111111110000000000000000000000000000000000111111111111111111 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000001111111111100000000000000000000000000000000 +1111111111111111110000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000011111111111100000000000 +0000000000000000000111111111111111111000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000111 +1111111110000000000000000000000000000111111111111111111100000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000011111111111110000000000000000000000000011111111111111 +1111000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000011111111111100000000000000000000 +0000111111111111111111110000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000111111111111 +1000000000000000000000011111111111111111110000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000011111111111110000000000000000000011111111111111111111000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000011111111111110000000000000000000111111111 +1111111111100000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000111111111111100000000 +0000000001111111111111111111100000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +1111111111110000000000000000111111111111111111110000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000011111111111110000000000000011111111111111111110000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000011111111111100000000000001111 +1111111111111110000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000111111111 +1111000000000001111111111111111110000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000011111111111110000000000111111111111111111000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000011111111111110000000011111111111111111 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000111111111111110000 +0011111111111111111100000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0001111111111111000011111111111111111100000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000001111111111111100111111111111111110000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000011111111111111111111111111 +1111100000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000011111 +1111111111111111111111110000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000001111111111111111111111111111100000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000001111111111111111111111111110000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000011111111111111 +1111111111110000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +0000000111111111111111111111110000000000000000000000000000000000000000 +0000000000000000000000000101000000101000000000000000000000000000000000 +0000000000000000000000000000111111111111111111111000000000000000000000 +0000000000000000000000000000000000000000000011111100111111000000000000 +0000000000000000000000000000000000000000000000000111111111111111111110 +0000000000000000000000000000000000000000000000000000000000000001111111 +1111111110000000000000000000000000000000000000000000000000000000000000 +1111111111111111100000000000000000000000000000000000000000000000000000 +0000000000001111111111111111110000000000000000000000000000000000000000 +0000000000000000000001111111111111111000000000000000000000000000000000 +0000000000000000000000000000000011111111111111111100000000000000000000 +0000000000000000000000000000000000000000011111111111111000000000000000 +0000000000000000000000000000000000000000000000000001111111111111111111 +1000000000000000000000000000000000000000000000000000000000000001111111 +1111000000000000000000000000000000000000000000000000000000000000000000 +0111111111111111111100000000000000000000000000000000000000000000000000 +0000000000000001111101000000000000000000000000000000000000000000000000 +0000000000000000000000111111111111111111000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000011111111 \ No newline at end of file diff --git a/extra/images/testing/pbm/test.binary.fig b/extra/images/testing/pbm/test.binary.fig new file mode 100644 index 0000000000000000000000000000000000000000..aee805ec6985a325ad215ee428ef13f16dc889c4 GIT binary patch literal 25659 zcmeHO%WmaF5DokfAHkj_KM){7EG8K#gCdqe8rFOQe;T@NclW7hm+jlOK{p`XQ*|D7 zu9Hk=M)2d?>(}2tJ^uRi`q%vO`1SG6&)@u${(XCW|Ka8R?e*{9fBNIg(|13=eER(I z{Pg_g_2vEf`)_}FC?6kJ`zXcA>&5z&TJ`nn{T?n=us*g5E>-X2qxLG`-fz_tD37ha zu5uqBUWzTB=mQR}Jn=9$OJ9lUpG$sRw%8?~*1gpI3EZE+{R#YUpFsUdFTfRkfQeFU zaq_2ywb8~i8)|*T?!1DcioQ6lpk7C8@BQ>AARd&l(B0#=Mjf#p-$cD2dRPn9J$`A` z5&Q8~)C;1AwNTyTmsm$!b4j5dvT!T7B5KIOt>BVF>WEOcf=i01Aq%&H zOAe_cLfr~3DWZlf+zKu^q>c!6E4ZYH3N3Qvnm^LG6T&_dMc*&am}U}G2UW_KRh_^Zj%&RcZvgfzg#-Dh ze&hrhN(t{33_=E+c(y`pEii;(%L03JzWlc(MB2a_%?m{VYZ6-L1jiCr#+5ql^N{@R$Od_Mn>V6-x9+ZwnTN?Mv?1Aveh8lG;~g(ydza;->tE@%UB5|E7TJrH27}G z;%36#E9mHog}`@97B?A-K(RoFAiE3S%~_l$+|8#y2Lo~@!HbN_Bc*Ygv0~vXG;yv! zcie==VZ#0Rq(E25Ktvrk(h`#-Ye1W&vG*M}(j42Ngh3l2LPO7uJjJ2-Btloz({w#I z@&vaCAEC)ts%+1WJYqFWTW&J7pq?Fhz%8JMz!dn!T%`5v$X6^pT-;K3f7^?A|9oqL|?G(w>1f3o6 z?;NyK7^(5S9r|}-^%Q2Rg3c2CyRdNwGYyHmM*ntfo*&EYZ%1WL0Ak5Gg>nw|yM=n)GfrHe?Q$sV2m?rL1B&x3G<9ul5 z$AyUt>MWFWQFR4SIyx2i@+xeMFQd@$MG@9lE{M)GAOXdLbiw31NAaXpk+xS|*Wb2; zaJ_CQWER-)xn%8}{>-6T;KT$~5nFOknwjEu zBfAv{W{x}tTw5jNS}24#<{{+UCc1T;)I}~F zaF3M9d$O1YP@e#4AEn<3o$w^>Cnl7hgGD7=oKuNh#X15LiJq>03Rkvwkg8x(pT xxbvqtjT6^aFKFI8tqvguNF@7h1EdwWEeKpwknz{)AdA7$s=da1N2yA$e*tvWh=KqB literal 0 HcmV?d00001 diff --git a/extra/images/testing/pbm/test.binary.pbm b/extra/images/testing/pbm/test.binary.pbm new file mode 100644 index 0000000000000000000000000000000000000000..3a49dd760304edab6e9a9bc0e3cfefb76e6929cd GIT binary patch literal 3250 zcmdUxzit#U5XODlVx>#5O=`Rn4Wd9qLKHL(LVzd&QG{qyr9eU;1!}yH!lUe?Y)MCo z6jxkgzHj_zZSP7%RAA|J_RpWkV=_b<*~K7ar2>{xKn$t8A=wn|0k??Jafod%cBH=MR?baEbmi zVw}6KU3O>{Lxi0hOW2T2C2Ps9{*HAkYuA`w(cPKdDpmWZ|5C{Y0 zhgPshTnqL~O3~(Q-wDGBqpowij!(s=U{gz7$;OsCMr>Y-6N7a*yNzs0IvtqCx#HT$ z%nIXsR_I2hEF8)hyBh|gVvR#m3O2zXBs618*BaAIW5WZX!9VJRwILsY(PbDIDD%22 zxQAiJcva*nDA|VYmAaj{Trj&6_bR5P8gqMgC+<}`E8gZhvv*5&<6o*mhuY$qDkf!~ zGwm4BQU@lFmoG3SR}XBWu43Z~BdT;#6j& zmKe^qU<00=O2;hW*-2}UjW3RjUE{{^%J>TbrNQCx-q8}D9ccy~yki{s3xN(VAN*mh zXHRPDbnp z^mJ~1P%(Op-N#uLeooW2G9zb#E1Ase@bKr%(q1ReNy3&+=)x5x%*IH0spKI=z%zr` zV2ja@0z(Y52naM_x`+VB>&(Y`w#Yj6vCi2rCnI3oLAWx^BJ}VEx7D^}RRnm3Db+ Date: Mon, 12 Apr 2010 01:15:49 -0700 Subject: [PATCH 634/713] Fix indentation in read-token --- basis/images/pbm/pbm.factor | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/basis/images/pbm/pbm.factor b/basis/images/pbm/pbm.factor index ba27c545cf..7db7ccedc6 100644 --- a/basis/images/pbm/pbm.factor +++ b/basis/images/pbm/pbm.factor @@ -1,10 +1,9 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types arrays ascii bit-arrays byte-arrays -combinators continuations grouping images images.loader io -io.encodings.ascii io.encodings.string kernel locals make math -math.functions math.parser sequences specialized-arrays ; -SPECIALIZED-ARRAY: ushort +USING: accessors arrays ascii bit-arrays byte-arrays combinators +continuations grouping images images.loader io io.encodings.ascii +io.encodings.string kernel locals make math math.functions math.parser +sequences ; IN: images.pbm SINGLETON: pbm-image @@ -12,12 +11,14 @@ SINGLETON: pbm-image height width height * :> npixels width 8 mod :> leftover - + type { { "P1" [ [ [ read-ascii-bits ] ignore-errors ] B{ } make ] } { "P4" [ [ width height read-binary-bits ] B{ } make ] } } case :> data - + image new L >>component-order { width height } >>dim From ef365bfa53c09a1cdb65c76d79b1d96a92d57bcd Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 12 Apr 2010 01:18:58 -0700 Subject: [PATCH 635/713] Remove unused locals. --- basis/images/pbm/pbm.factor | 2 -- 1 file changed, 2 deletions(-) diff --git a/basis/images/pbm/pbm.factor b/basis/images/pbm/pbm.factor index 7db7ccedc6..9b8c7c11f9 100644 --- a/basis/images/pbm/pbm.factor +++ b/basis/images/pbm/pbm.factor @@ -58,8 +58,6 @@ SINGLETON: pbm-image read-token :> type read-number :> width read-number :> height - width height * :> npixels - width 8 mod :> leftover type { { "P1" [ [ [ read-ascii-bits ] ignore-errors ] B{ } make ] } From 1434a305c876680e05d5c6045ac3686a65a51235 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Apr 2010 14:22:41 -0700 Subject: [PATCH 636/713] vm: add a new rc-absolute-1 relocation class to allow storing values in 8-bit operands, and optimized code sequences for inline caches using this --- basis/compiler/constants/constants.factor | 61 +++++++++++++---------- basis/cpu/ppc/bootstrap.factor | 24 +++++---- basis/cpu/x86/32/bootstrap.factor | 4 ++ basis/cpu/x86/64/bootstrap.factor | 5 ++ basis/cpu/x86/bootstrap.factor | 52 +++++++++---------- vm/dispatch.cpp | 4 +- vm/inline_cache.cpp | 3 +- vm/instruction_operands.cpp | 5 ++ vm/instruction_operands.hpp | 12 +++-- vm/jit.cpp | 6 --- vm/jit.hpp | 2 - 11 files changed, 97 insertions(+), 81 deletions(-) diff --git a/basis/compiler/constants/constants.factor b/basis/compiler/constants/constants.factor index ac0fcff0ff..2fec5ca190 100644 --- a/basis/compiler/constants/constants.factor +++ b/basis/compiler/constants/constants.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: math kernel layouts system strings words quotations byte-arrays -alien arrays literals sequences ; +alien alien.syntax arrays literals sequences ; IN: compiler.constants ! These constants must match vm/memory.h @@ -40,32 +40,41 @@ CONSTANT: deck-bits 18 : segment-end-offset ( -- n ) 2 bootstrap-cells ; inline ! Relocation classes -CONSTANT: rc-absolute-cell 0 -CONSTANT: rc-absolute 1 -CONSTANT: rc-relative 2 -CONSTANT: rc-absolute-ppc-2/2 3 -CONSTANT: rc-absolute-ppc-2 4 -CONSTANT: rc-relative-ppc-2 5 -CONSTANT: rc-relative-ppc-3 6 -CONSTANT: rc-relative-arm-3 7 -CONSTANT: rc-indirect-arm 8 -CONSTANT: rc-indirect-arm-pc 9 -CONSTANT: rc-absolute-2 10 +C-ENUM: f + rc-absolute-cell + rc-absolute + rc-relative + rc-absolute-ppc-2/2 + rc-absolute-ppc-2 + rc-relative-ppc-2 + rc-relative-ppc-3 + rc-relative-arm-3 + rc-indirect-arm + rc-indirect-arm-pc + rc-absolute-2 + rc-absolute-1 ; ! Relocation types -CONSTANT: rt-dlsym 0 -CONSTANT: rt-entry-point 1 -CONSTANT: rt-entry-point-pic 2 -CONSTANT: rt-entry-point-pic-tail 3 -CONSTANT: rt-here 4 -CONSTANT: rt-this 5 -CONSTANT: rt-literal 6 -CONSTANT: rt-untagged 7 -CONSTANT: rt-megamorphic-cache-hits 8 -CONSTANT: rt-vm 9 -CONSTANT: rt-cards-offset 10 -CONSTANT: rt-decks-offset 11 -CONSTANT: rt-exception-handler 12 +C-ENUM: f + rt-dlsym + rt-entry-point + rt-entry-point-pic + rt-entry-point-pic-tail + rt-here + rt-this + rt-literal + rt-untagged + rt-megamorphic-cache-hits + rt-vm + rt-cards-offset + rt-decks-offset + rt-exception-handler ; : rc-absolute? ( n -- ? ) - ${ rc-absolute-ppc-2/2 rc-absolute-cell rc-absolute } member? ; + ${ + rc-absolute-ppc-2/2 + rc-absolute-cell + rc-absolute + rc-absolute-2 + rc-absolute-1 + } member? ; diff --git a/basis/cpu/ppc/bootstrap.factor b/basis/cpu/ppc/bootstrap.factor index f7a1917d0e..4df7a487d4 100644 --- a/basis/cpu/ppc/bootstrap.factor +++ b/basis/cpu/ppc/bootstrap.factor @@ -286,25 +286,19 @@ CONSTANT: nv-reg 17 4 ds-reg 0 LWZ rc-absolute-ppc-2 rt-untagged jit-rel ] pic-load jit-define -! Tag -: load-tag ( -- ) - 4 4 tag-mask get ANDI - 4 4 tag-bits get SLWI ; +[ 4 4 tag-mask get ANDI ] pic-tag jit-define -[ load-tag ] pic-tag jit-define - -! Tuple [ 3 4 MR - load-tag - 0 4 tuple type-number tag-fixnum CMPI + 4 4 tag-mask get ANDI + 0 4 tuple type-number CMPI [ BNE ] - [ 4 3 tuple type-number neg 4 + LWZ ] + [ 4 3 tuple-class-offset LWZ ] jit-conditional* ] pic-tuple jit-define [ - 0 4 0 CMPI rc-absolute-ppc-2 rt-literal jit-rel + 0 4 0 CMPI rc-absolute-ppc-2 rt-untagged jit-rel ] pic-check-tag jit-define [ @@ -342,6 +336,14 @@ CONSTANT: nv-reg 17 ! ! ! Megamorphic caches [ + ! class = ... + 3 4 MR + 4 4 tag-mask get ANDI + 4 4 tag-bits get SLWI + 0 4 tuple type-number tag-fixnum CMPI + [ BNE ] + [ 4 3 tuple-class-offset LWZ ] + jit-conditional* ! cache = ... 0 3 LOAD32 rc-absolute-ppc-2/2 rt-literal jit-rel ! key = hashcode(class) diff --git a/basis/cpu/x86/32/bootstrap.factor b/basis/cpu/x86/32/bootstrap.factor index 4eb8335b67..a52a3390ac 100644 --- a/basis/cpu/x86/32/bootstrap.factor +++ b/basis/cpu/x86/32/bootstrap.factor @@ -176,6 +176,10 @@ IN: bootstrap.x86 [ jit-jump-quot ] \ lazy-jit-compile define-combinator-primitive +[ + temp1 HEX: ffffffff CMP rc-absolute-cell rt-literal jit-rel +] pic-check-tuple jit-define + ! Inline cache miss entry points : jit-load-return-address ( -- ) pic-tail-reg ESP stack-frame-size bootstrap-cell - [+] MOV ; diff --git a/basis/cpu/x86/64/bootstrap.factor b/basis/cpu/x86/64/bootstrap.factor index 39046bce6a..393d1c9b8b 100644 --- a/basis/cpu/x86/64/bootstrap.factor +++ b/basis/cpu/x86/64/bootstrap.factor @@ -160,6 +160,11 @@ IN: bootstrap.x86 [ jit-jump-quot ] \ lazy-jit-compile define-combinator-primitive +[ + temp2 HEX: ffffffff MOV rc-absolute-cell rt-literal jit-rel + temp1 temp2 CMP +] pic-check-tuple jit-define + ! Inline cache miss entry points : jit-load-return-address ( -- ) RBX RSP stack-frame-size bootstrap-cell - [+] MOV ; diff --git a/basis/cpu/x86/bootstrap.factor b/basis/cpu/x86/bootstrap.factor index 7accc4b1cb..969c02c910 100644 --- a/basis/cpu/x86/bootstrap.factor +++ b/basis/cpu/x86/bootstrap.factor @@ -206,43 +206,37 @@ big-endian off ! Load a value from a stack position [ - temp1 ds-reg HEX: ffffffff [+] MOV rc-absolute rt-untagged jit-rel + temp1 ds-reg HEX: 7f [+] MOV rc-absolute-1 rt-untagged jit-rel ] pic-load jit-define -! Tag -: load-tag ( -- ) - temp1 tag-mask get AND - temp1 tag-bits get SHL ; +[ temp1 tag-mask get AND ] pic-tag jit-define -[ load-tag ] pic-tag jit-define - -! The 'make' trick lets us compute the jump distance for the -! conditional branches there - -! Tuple [ temp0 temp1 MOV - load-tag - temp1 tuple type-number tag-fixnum CMP + temp1 tag-mask get AND + temp1 tuple type-number CMP [ JNE ] - [ temp1 temp0 tuple type-number neg bootstrap-cell + [+] MOV ] + [ temp1 temp0 tuple-class-offset [+] MOV ] jit-conditional ] pic-tuple jit-define [ - temp1 HEX: ffffffff CMP rc-absolute rt-literal jit-rel + temp1 HEX: 7f CMP rc-absolute-1 rt-untagged jit-rel ] pic-check-tag jit-define -[ - temp2 HEX: ffffffff MOV rc-absolute-cell rt-literal jit-rel - temp1 temp2 CMP -] pic-check-tuple jit-define - [ 0 JE rc-relative rt-entry-point jit-rel ] pic-hit jit-define ! ! ! Megamorphic caches [ + ! class = ... + temp0 temp1 MOV + temp1 tag-mask get AND + temp1 tag-bits get SHL + temp1 tuple type-number tag-fixnum CMP + [ JNE ] + [ temp1 temp0 tuple-class-offset [+] MOV ] + jit-conditional ! cache = ... temp0 0 MOV rc-absolute-cell rt-literal jit-rel ! key = hashcode(class) @@ -256,14 +250,16 @@ big-endian off temp0 temp2 ADD ! if(get(cache) == class) temp0 [] temp1 CMP - bootstrap-cell 4 = 14 22 ? JNE ! Yuck! - ! megamorphic_cache_hits++ - temp1 0 MOV rc-absolute-cell rt-megamorphic-cache-hits jit-rel - temp1 [] 1 ADD - ! goto get(cache + bootstrap-cell) - temp0 temp0 bootstrap-cell [+] MOV - temp0 word-entry-point-offset [+] JMP - ! fall-through on miss + [ JNE ] + [ + ! megamorphic_cache_hits++ + temp1 0 MOV rc-absolute-cell rt-megamorphic-cache-hits jit-rel + temp1 [] 1 ADD + ! goto get(cache + bootstrap-cell) + temp0 temp0 bootstrap-cell [+] MOV + temp0 word-entry-point-offset [+] JMP + ! fall-through on miss + ] jit-conditional ] mega-lookup jit-define ! ! ! Sub-primitives diff --git a/vm/dispatch.cpp b/vm/dispatch.cpp index b0f9159da7..480da1fd03 100755 --- a/vm/dispatch.cpp +++ b/vm/dispatch.cpp @@ -148,8 +148,8 @@ void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index, cell cac data_root methods(methods_,parent); data_root cache(cache_,parent); - /* Generate machine code to determine the object's class. */ - emit_class_lookup(index,PIC_TUPLE); + /* Load the object from the datastack. */ + emit_with_literal(parent->special_objects[PIC_LOAD],tag_fixnum(-index * sizeof(cell))); /* Do a cache lookup. */ emit_with_literal(parent->special_objects[MEGA_LOOKUP],cache.value()); diff --git a/vm/inline_cache.cpp b/vm/inline_cache.cpp index c8a1b22879..b7cd7630ac 100755 --- a/vm/inline_cache.cpp +++ b/vm/inline_cache.cpp @@ -89,7 +89,8 @@ void inline_cache_jit::compile_inline_cache(fixnum index, parent->update_pic_count(inline_cache_type); /* Generate machine code to determine the object's class. */ - emit_class_lookup(index,inline_cache_type); + emit_with_literal(parent->special_objects[PIC_LOAD],tag_fixnum(-index * sizeof(cell))); + emit(parent->special_objects[inline_cache_type]); /* Generate machine code to check, in turn, if the class is one of the cached entries. */ cell i; diff --git a/vm/instruction_operands.cpp b/vm/instruction_operands.cpp index 59dbf1ef8e..b11db279a5 100644 --- a/vm/instruction_operands.cpp +++ b/vm/instruction_operands.cpp @@ -49,6 +49,8 @@ fixnum instruction_operand::load_value(cell relative_to) return load_value_masked(rel_indirect_arm_mask,20,0) + relative_to + sizeof(cell); case RC_ABSOLUTE_2: return *(u16 *)(pointer - sizeof(u16)); + case RC_ABSOLUTE_1: + return *(u8 *)(pointer - sizeof(u8)); default: critical_error("Bad rel class",rel.rel_class()); return 0; @@ -124,6 +126,9 @@ void instruction_operand::store_value(fixnum absolute_value) case RC_ABSOLUTE_2: *(u16 *)(pointer - sizeof(u16)) = (u16)absolute_value; break; + case RC_ABSOLUTE_1: + *(u8 *)(pointer - sizeof(u8)) = (u8)absolute_value; + break; default: critical_error("Bad rel class",rel.rel_class()); break; diff --git a/vm/instruction_operands.hpp b/vm/instruction_operands.hpp index 66ffddc24e..5dda411c8b 100644 --- a/vm/instruction_operands.hpp +++ b/vm/instruction_operands.hpp @@ -33,11 +33,11 @@ enum relocation_type { }; enum relocation_class { - /* absolute address in a 64-bit location */ + /* absolute address in a pointer-width location */ RC_ABSOLUTE_CELL, - /* absolute address in a 32-bit location */ + /* absolute address in a 4 byte location */ RC_ABSOLUTE, - /* relative address in a 32-bit location */ + /* relative address in a 4 byte location */ RC_RELATIVE, /* absolute address in a PowerPC LIS/ORI sequence */ RC_ABSOLUTE_PPC_2_2, @@ -53,8 +53,10 @@ enum relocation_class { RC_INDIRECT_ARM, /* pointer to address in an ARM LDR/STR instruction offset by 8 bytes */ RC_INDIRECT_ARM_PC, - /* absolute address in a 16-bit location */ - RC_ABSOLUTE_2 + /* absolute address in a 2 byte location */ + RC_ABSOLUTE_2, + /* absolute address in a 1 byte location */ + RC_ABSOLUTE_1, }; static const cell rel_absolute_ppc_2_mask = 0xffff; diff --git a/vm/jit.cpp b/vm/jit.cpp index 8d2f5abb9a..3324cfb366 100644 --- a/vm/jit.cpp +++ b/vm/jit.cpp @@ -103,12 +103,6 @@ bool jit::emit_subprimitive(cell word_, bool tail_call_p, bool stack_frame_p) return false; } -void jit::emit_class_lookup(fixnum index, cell type) -{ - emit_with_literal(parent->special_objects[PIC_LOAD],tag_fixnum(-index * sizeof(cell))); - emit(parent->special_objects[type]); -} - /* Facility to convert compiled code offsets to quotation offsets. Call jit_compute_offset() with the compiled code offset, then emit code, and at the end jit->position is the quotation position. */ diff --git a/vm/jit.hpp b/vm/jit.hpp index a9716cab79..963115d6ab 100644 --- a/vm/jit.hpp +++ b/vm/jit.hpp @@ -47,8 +47,6 @@ struct jit { bool emit_subprimitive(cell word_, bool tail_call_p, bool stack_frame_p); - void emit_class_lookup(fixnum index, cell type); - fixnum get_position() { if(computing_offset_p) From a7ee58dc83c119d02bcf6d44a919e03af28c7cb3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Apr 2010 14:45:43 -0700 Subject: [PATCH 637/713] mason.test: forget test vocabs right after each test, instead of at the end --- basis/tools/test/test.factor | 13 +++++++++++-- extra/mason/test/test.factor | 19 ++++++------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/basis/tools/test/test.factor b/basis/tools/test/test.factor index 8dda4fe16c..f3f53e43b7 100644 --- a/basis/tools/test/test.factor +++ b/basis/tools/test/test.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2003, 2009 Slava Pestov. +! Copyright (C) 2003, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs combinators compiler.units continuations debugger effects fry generalizations io io.files @@ -118,12 +118,21 @@ PRIVATE> '[ _ run-file ] [ file-failure ] recover ] with-variable ; +SYMBOL: forget-tests? + > [ - vocab-tests [ run-test-file ] each + vocab-tests + [ [ run-test-file ] each ] + [ forget-tests ] + bi ] [ drop ] if ] [ drop ] if ; diff --git a/extra/mason/test/test.factor b/extra/mason/test/test.factor index e99f76c8c4..8e248e861b 100644 --- a/extra/mason/test/test.factor +++ b/extra/mason/test/test.factor @@ -1,12 +1,11 @@ ! Copyright (C) 2008, 2010 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs benchmark bootstrap.stage2 -compiler.errors source-files.errors generic help.html help.lint -io.directories io.encodings.utf8 io.files kernel mason.common -math namespaces prettyprint sequences sets sorting tools.test -tools.time words system io tools.errors vocabs vocabs.files -vocabs.hierarchy vocabs.errors vocabs.refresh locals -source-files compiler.units ; +compiler.errors generic help.html help.lint io io.directories +io.encodings.utf8 io.files kernel locals mason.common +namespaces sequences sets sorting source-files.errors system +tools.errors tools.test tools.time vocabs.errors +vocabs.hierarchy vocabs.refresh words ; IN: mason.test : do-load ( -- ) @@ -28,17 +27,12 @@ M: method word-vocabulary "method-generic" word-prop word-vocabulary ; errors details-file utf8 [ errors. ] with-file-writer ; : do-tests ( -- ) + forget-tests? on test-all test-failures get test-all-vocabs-file test-all-errors-file do-step ; -: cleanup-tests ( -- ) - ! Free up some code heap space - [ - vocabs [ vocab-tests [ forget-source ] each ] each - ] with-compilation-unit ; - : do-help-lint ( -- ) help-lint-all lint-failures get values help-lint-vocabs-file @@ -76,7 +70,6 @@ M: method word-vocabulary "method-generic" word-prop word-vocabulary ; [ do-load ] benchmark load-time-file to-file [ generate-help ] benchmark html-help-time-file to-file [ do-tests ] benchmark test-time-file to-file - cleanup-tests [ do-help-lint ] benchmark help-lint-time-file to-file [ do-benchmarks ] benchmark benchmark-time-file to-file do-compile-errors From 27124968805ceb14a27d8adbff42f6019e8b3145 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Apr 2010 18:44:02 -0400 Subject: [PATCH 638/713] cpu.x86.32: fastcall struct returns are different on Linux than everywhere else for some unknown reason --- basis/cpu/x86/32/32.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 0127d55997..40c6bd40db 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -359,6 +359,7 @@ M: long-long-type flatten-value-type (flatten-stack-type) ; M: c-type flatten-value-type dup rep>> int-rep? [ (flatten-int-type) ] [ (flatten-stack-type) ] if ; -M: x86.32 struct-return-pointer-type (stack-value) ; +M: x86.32 struct-return-pointer-type + os linux? void* (stack-value) ? ; check-sse From becb7c78b7cd99ccc82950950e8ad58da5cb2a07 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Apr 2010 18:09:26 -0500 Subject: [PATCH 639/713] Move non-parsing words out of alien.syntax, and use a symbol instead of a string variable to store the current library in alien.parser --- basis/alien/fortran/fortran.factor | 6 +++--- basis/alien/libraries/libraries.factor | 5 +++++ basis/alien/parser/parser.factor | 13 +++++++++++-- basis/alien/syntax/syntax.factor | 26 +++++++------------------- 4 files changed, 26 insertions(+), 24 deletions(-) mode change 100644 => 100755 basis/alien/fortran/fortran.factor mode change 100644 => 100755 basis/alien/libraries/libraries.factor mode change 100644 => 100755 basis/alien/parser/parser.factor mode change 100644 => 100755 basis/alien/syntax/syntax.factor diff --git a/basis/alien/fortran/fortran.factor b/basis/alien/fortran/fortran.factor old mode 100644 new mode 100755 index 8c74aa102a..9f44dec80a --- a/basis/alien/fortran/fortran.factor +++ b/basis/alien/fortran/fortran.factor @@ -434,15 +434,15 @@ MACRO: fortran-invoke ( return library function parameters -- ) [ \ fortran-invoke 5 [ ] nsequence ] dip define-declared ; SYNTAX: SUBROUTINE: - f "c-library" get scan ";" parse-tokens + f current-library get scan ";" parse-tokens [ "()" subseq? not ] filter define-fortran-function ; SYNTAX: FUNCTION: - scan "c-library" get scan ";" parse-tokens + scan current-library get scan ";" parse-tokens [ "()" subseq? not ] filter define-fortran-function ; SYNTAX: LIBRARY: scan - [ "c-library" set ] + [ current-library set ] [ set-fortran-abi ] bi ; diff --git a/basis/alien/libraries/libraries.factor b/basis/alien/libraries/libraries.factor old mode 100644 new mode 100755 index 5a042fd436..86249436aa --- a/basis/alien/libraries/libraries.factor +++ b/basis/alien/libraries/libraries.factor @@ -38,6 +38,11 @@ M: library dispose dll>> [ dispose ] when* ; : library-abi ( library -- abi ) library [ abi>> ] [ cdecl ] if* ; +ERROR: no-such-symbol name library ; + +: address-of ( name library -- value ) + 2dup load-library dlsym [ 2nip ] [ no-such-symbol ] if* ; + SYMBOL: deploy-libraries deploy-libraries [ V{ } clone ] initialize diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor old mode 100644 new mode 100755 index 0891caa04a..7b677c3581 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -7,6 +7,8 @@ splitting words fry locals lexer namespaces summary math vocabs.parser words.constant ; IN: alien.parser +SYMBOL: current-library + : parse-c-type-name ( name -- word ) dup search [ ] [ no-word ] ?if ; @@ -117,7 +119,7 @@ PRIVATE> names return function-effect ; : (FUNCTION:) ( -- word quot effect ) - scan-function-name "c-library" get ";" scan-c-args make-function ; + scan-function-name current-library get ";" scan-c-args make-function ; : callback-quot ( return types abi -- quot ) '[ [ _ _ _ ] dip alien-callback ] ; @@ -131,7 +133,7 @@ PRIVATE> type-word return types lib library-abi callback-quot (( quot -- alien )) ; : (CALLBACK:) ( -- word quot effect ) - "c-library" get + current-library get scan-function-name ";" scan-c-args make-callback-type ; PREDICATE: alien-function-word < word @@ -142,3 +144,10 @@ PREDICATE: alien-function-word < word PREDICATE: alien-callback-type-word < typedef-word "callback-effect" word-prop ; + +: global-quot ( type word -- quot ) + name>> current-library get '[ _ _ address-of 0 ] + swap c-type-getter-boxer append ; + +: define-global ( type word -- ) + [ nip ] [ global-quot ] 2bi (( -- value )) define-declared ; diff --git a/basis/alien/syntax/syntax.factor b/basis/alien/syntax/syntax.factor old mode 100644 new mode 100755 index 00148a82d4..bc7e590cff --- a/basis/alien/syntax/syntax.factor +++ b/basis/alien/syntax/syntax.factor @@ -1,10 +1,10 @@ ! Copyright (C) 2005, 2010 Slava Pestov, Alex Chapman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays alien alien.c-types -alien.arrays alien.strings kernel math namespaces parser -sequences words quotations math.parser splitting grouping -effects assocs combinators lexer strings.parser alien.parser -fry vocabs.parser words.constant alien.libraries ; +USING: accessors arrays alien alien.c-types alien.arrays +alien.strings kernel math namespaces parser sequences words +quotations math.parser splitting grouping effects assocs +combinators lexer strings.parser alien.parser fry vocabs.parser +words.constant alien.libraries ; IN: alien.syntax SYNTAX: DLL" lexer get skip-blank parse-string dlopen suffix! ; @@ -13,7 +13,7 @@ SYNTAX: ALIEN: 16 scan-base suffix! ; SYNTAX: BAD-ALIEN suffix! ; -SYNTAX: LIBRARY: scan "c-library" set ; +SYNTAX: LIBRARY: scan current-library set ; SYNTAX: FUNCTION: (FUNCTION:) define-declared ; @@ -33,20 +33,8 @@ SYNTAX: C-ENUM: SYNTAX: C-TYPE: void CREATE-C-TYPE typedef ; -ERROR: no-such-symbol name library ; - -: address-of ( name library -- value ) - 2dup load-library dlsym [ 2nip ] [ no-such-symbol ] if* ; - SYNTAX: &: - scan "c-library" get '[ _ _ address-of ] append! ; - -: global-quot ( type word -- quot ) - name>> "c-library" get '[ _ _ address-of 0 ] - swap c-type-getter-boxer append ; - -: define-global ( type word -- ) - [ nip ] [ global-quot ] 2bi (( -- value )) define-declared ; + scan current-library get '[ _ _ address-of ] append! ; SYNTAX: C-GLOBAL: scan-c-type CREATE-WORD define-global ; From 67e24b1d2aecd885ec785f1f1e5f887931c00c27 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Apr 2010 18:10:25 -0500 Subject: [PATCH 640/713] compiler.codegen: need to do name decoration with fastcall as well --- basis/compiler/codegen/codegen.factor | 14 ++++++++++---- basis/cpu/x86/32/32.factor | 3 --- core/alien/alien.factor | 3 +++ 3 files changed, 13 insertions(+), 7 deletions(-) mode change 100644 => 100755 core/alien/alien.factor diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index ffccf9f118..b16f471d11 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -18,6 +18,7 @@ compiler.cfg.builder compiler.codegen.fixup compiler.utilities ; FROM: namespaces => set ; +FROM: compiler.errors => no-such-symbol ; IN: compiler.codegen SYMBOL: insn-counts @@ -415,13 +416,18 @@ M: array dlsym-valid? '[ _ dlsym ] any? ; dll-path compiling-word get no-such-library drop ] if ; -: stdcall-mangle ( params -- symbols ) +: decorated-symbol ( params -- symbols ) [ function>> ] [ parameters>> parameter-offsets drop number>string ] bi - [ drop ] [ "@" glue ] [ "@" glue "_" prepend ] 2tri - 3array ; + { + [ drop ] + [ "@" glue ] + [ "@" glue "_" prepend ] + [ "@" glue "@" prepend ] + } 2cleave + 4array ; : alien-invoke-dlsym ( params -- symbols dll ) - [ dup abi>> stdcall = [ stdcall-mangle ] [ function>> ] if ] + [ dup abi>> callee-cleanup? [ decorated-symbol ] [ function>> ] if ] [ library>> load-library ] bi 2dup check-dlsym ; diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 40c6bd40db..05c627fb99 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -315,9 +315,6 @@ M:: x86.32 %binary-float-function ( dst src1 src2 func -- ) [ abi>> mingw = os windows? not or ] bi and ; -: callee-cleanup? ( abi -- ? ) - { stdcall fastcall thiscall } member? ; - : stack-arg-size ( params -- n ) dup abi>> '[ alien-parameters flatten-value-types diff --git a/core/alien/alien.factor b/core/alien/alien.factor old mode 100644 new mode 100755 index 27e326a557..d67e0a12b9 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -68,6 +68,9 @@ SINGLETONS: stdcall thiscall fastcall cdecl mingw ; UNION: abi stdcall thiscall fastcall cdecl mingw ; +: callee-cleanup? ( abi -- ? ) + { stdcall fastcall thiscall } member? ; + ERROR: alien-callback-error ; : alien-callback ( return parameters abi quot -- alien ) From 0d3861bb5d4deb7cbc656d40c34af0cf3bda013e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Apr 2010 18:12:55 -0500 Subject: [PATCH 641/713] vm: fix compiler warnings raised by CL --- vm/ffi_test.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/vm/ffi_test.c b/vm/ffi_test.c index 993ca18fa3..7d9abe2f87 100755 --- a/vm/ffi_test.c +++ b/vm/ffi_test.c @@ -56,7 +56,7 @@ int ffi_test_9(int a, int b, int c, int d, int e, int f, int g) int ffi_test_10(int a, int b, double c, int d, float e, int f, int g, int h) { - return a - b - c - d - e - f - g - h; + return (int)(a - b - c - d - e - f - g - h); } int ffi_test_11(int a, struct foo b, int c) @@ -66,7 +66,7 @@ int ffi_test_11(int a, struct foo b, int c) int ffi_test_12(int a, int b, struct rect c, int d, int e, int f) { - return a + b + c.x + c.y + c.w + c.h + d + e + f; + return (int)(a + b + c.x + c.y + c.w + c.h + d + e + f); } int ffi_test_13(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k) @@ -128,7 +128,7 @@ long long ffi_test_21(long x, long y) long ffi_test_22(long x, long long y, long long z) { - return x + y / z; + return (long)(x + y / z); } float ffi_test_23(float x[3], float y[3]) @@ -262,7 +262,7 @@ unsigned long long ffi_test_38(unsigned long long x, unsigned long long y) int ffi_test_39(long a, long b, struct test_struct_13 s) { assert(a == b); - return s.x1 + s.x2 + s.x3 + s.x4 + s.x5 + s.x6; + return (int)(s.x1 + s.x2 + s.x3 + s.x4 + s.x5 + s.x6); } struct test_struct_14 ffi_test_40(double x1, double x2) @@ -330,13 +330,29 @@ short ffi_test_48(struct bool_field_test x) #endif -FACTOR_FASTCALL(int) ffi_test_49(int x) { return x + 1; } -FACTOR_FASTCALL(int) ffi_test_50(int x, int y) { return x + y + 1; } -FACTOR_FASTCALL(int) ffi_test_51(int x, int y, int z) { return x + y + z + 1; } -FACTOR_FASTCALL(int) ffi_test_52(int x, float y, int z) { return x + y + z + 1; } +FACTOR_FASTCALL(int) ffi_test_49(int x) +{ + return x + 1; +} + +FACTOR_FASTCALL(int) ffi_test_50(int x, int y) +{ + return x + y + 1; +} + +FACTOR_FASTCALL(int) ffi_test_51(int x, int y, int z) +{ + return x + y + z + 1; +} + +FACTOR_FASTCALL(int) ffi_test_52(int x, float y, int z) +{ + return (int)(x + y + z + 1); +} + FACTOR_FASTCALL(int) ffi_test_53(int x, float y, int z, int w) { - return x + y + z + w + 1; + return (int)(x + y + z + w + 1); } FACTOR_FASTCALL(int) ffi_test_54(struct test_struct_11 x, int y) From 918b202b9a3e69d12b3f1afac3df97a2db425e65 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Apr 2010 18:14:18 -0500 Subject: [PATCH 642/713] compiler.tests.alien: get it passing when VM is compiled with MINGW by disabling certain tests and using the MINGW ABI for others, and fix fastcall alien-indirect tests for name decoration --- basis/compiler/tests/alien.factor | 68 +++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 8735d7cae4..279c6ef39f 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -20,7 +20,9 @@ IN: compiler.tests.alien { [ os unix? ] [ "libfactor-ffi-test.so" ] } } cond append-path ; -"f-cdecl" libfactor-ffi-tests-path cdecl add-library +: mingw? ( -- ? ) os windows? vm-compiler "GCC" head? and ; + +"f-cdecl" libfactor-ffi-tests-path mingw? mingw cdecl ? add-library "f-stdcall" libfactor-ffi-tests-path stdcall add-library @@ -653,55 +655,103 @@ FUNCTION: void this_does_not_exist ( ) ; test-struct-11 "f-fastcall" "ffi_test_58" { int int int } alien-invoke gc ; -[ 13 ] [ 3 4.0 5 ffi_test_52 ] unit-test -[ 19 ] [ 3 4.0 5 6 ffi_test_53 ] unit-test +! GCC bugs +mingw? [ + [ 13 ] [ 3 4.0 5 ffi_test_52 ] unit-test + + [ 19 ] [ 3 4.0 5 6 ffi_test_53 ] unit-test +] unless + [ S{ test-struct-11 f 7 -1 } ] [ 3 4 ffi_test_57 ] unit-test + [ S{ test-struct-11 f 7 -3 } ] [ 3 4 7 ffi_test_58 ] unit-test : fastcall-ii-indirect ( x y ptr -- result ) int { int int } fastcall alien-indirect ; + : fastcall-iii-indirect ( x y z ptr -- result ) int { int int int } fastcall alien-indirect ; + : fastcall-ifi-indirect ( x y z ptr -- result ) int { int float int } fastcall alien-indirect ; + : fastcall-ifii-indirect ( x y z w ptr -- result ) int { int float int int } fastcall alien-indirect ; + : fastcall-struct-return-ii-indirect ( x y ptr -- result ) test-struct-11 { int int } fastcall alien-indirect ; + : fastcall-struct-return-iii-indirect ( x y z ptr -- result ) test-struct-11 { int int int } fastcall alien-indirect ; -[ 8 ] [ 3 4 &: ffi_test_50 fastcall-ii-indirect ] unit-test -[ 13 ] [ 3 4 5 &: ffi_test_51 fastcall-iii-indirect ] unit-test -[ 13 ] [ 3 4.0 5 &: ffi_test_52 fastcall-ifi-indirect ] unit-test -[ 19 ] [ 3 4.0 5 6 &: ffi_test_53 fastcall-ifii-indirect ] unit-test +[ 8 ] [ + 3 4 + os windows? [ &: @ffi_test_50@8 ] [ &: ffi_test_50 ] if + fastcall-ii-indirect +] unit-test + +[ 13 ] [ + 3 4 5 + os windows? [ &: @ffi_test_51@12 ] [ &: ffi_test_51 ] if + fastcall-iii-indirect +] unit-test + +mingw? [ + [ 13 ] [ + 3 4.0 5 + os windows? [ &: @ffi_test_52@12 ] [ &: ffi_test_52 ] if + fastcall-ifi-indirect + ] unit-test + + [ 19 ] [ + 3 4.0 5 6 + os windows? [ &: @ffi_test_53@16 ] [ &: ffi_test_53 ] if + fastcall-ifii-indirect + ] unit-test +] unless [ S{ test-struct-11 f 7 -1 } ] -[ 3 4 &: ffi_test_57 fastcall-struct-return-ii-indirect ] unit-test +[ + 3 4 + os windows? [ &: @ffi_test_57@8 ] [ &: ffi_test_57 ] if + fastcall-struct-return-ii-indirect +] unit-test [ S{ test-struct-11 f 7 -3 } ] -[ 3 4 7 &: ffi_test_58 fastcall-struct-return-iii-indirect ] unit-test +[ + 3 4 7 + os windows? [ &: @ffi_test_58@12 ] [ &: ffi_test_58 ] if + fastcall-struct-return-iii-indirect +] unit-test : fastcall-ii-callback ( -- ptr ) int { int int } fastcall [ + 1 + ] alien-callback ; + : fastcall-iii-callback ( -- ptr ) int { int int int } fastcall [ + + 1 + ] alien-callback ; + : fastcall-ifi-callback ( -- ptr ) int { int float int } fastcall [ [ >integer ] dip + + 1 + ] alien-callback ; + : fastcall-ifii-callback ( -- ptr ) int { int float int int } fastcall [ [ >integer ] 2dip + + + 1 + ] alien-callback ; + : fastcall-struct-return-ii-callback ( -- ptr ) test-struct-11 { int int } fastcall [ [ + ] [ - ] 2bi test-struct-11 ] alien-callback ; + : fastcall-struct-return-iii-callback ( -- ptr ) test-struct-11 { int int int } fastcall [ [ drop + ] [ - nip ] 3bi test-struct-11 ] alien-callback ; [ 8 ] [ 3 4 fastcall-ii-callback fastcall-ii-indirect ] unit-test + [ 13 ] [ 3 4 5 fastcall-iii-callback fastcall-iii-indirect ] unit-test + [ 13 ] [ 3 4.0 5 fastcall-ifi-callback fastcall-ifi-indirect ] unit-test + [ 19 ] [ 3 4.0 5 6 fastcall-ifii-callback fastcall-ifii-indirect ] unit-test [ S{ test-struct-11 f 7 -1 } ] From 0d5729b639afc0c89d801cede78a4dda63652134 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 12 Apr 2010 17:25:36 -0700 Subject: [PATCH 643/713] opencl.ffi: library isn't stdcall except on windows --- extra/opencl/ffi/ffi.factor | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extra/opencl/ffi/ffi.factor b/extra/opencl/ffi/ffi.factor index 9ee2135cb6..d3398f5c24 100644 --- a/extra/opencl/ffi/ffi.factor +++ b/extra/opencl/ffi/ffi.factor @@ -5,10 +5,10 @@ combinators system alien.accessors byte-arrays kernel ; IN: opencl.ffi << "opencl" { - { [ os windows? ] [ "OpenCL.dll" ] } - { [ os macosx? ] [ "/System/Library/Frameworks/OpenCL.framework/OpenCL" ] } - { [ os unix? ] [ "libOpenCL.so" ] } - } cond stdcall add-library >> + { [ os windows? ] [ "OpenCL.dll" stdcall ] } + { [ os macosx? ] [ "/System/Library/Frameworks/OpenCL.framework/OpenCL" cdecl ] } + { [ os unix? ] [ "libOpenCL.so" cdecl ] } + } cond add-library >> LIBRARY: opencl ! cl_platform.h From de50d0bfda2afa0512a1ebcca356bb9bd731e91c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 12 Apr 2010 17:37:06 -0700 Subject: [PATCH 644/713] cuda.ffi binding --- extra/cuda/ffi/ffi.factor | 439 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 439 insertions(+) create mode 100644 extra/cuda/ffi/ffi.factor diff --git a/extra/cuda/ffi/ffi.factor b/extra/cuda/ffi/ffi.factor new file mode 100644 index 0000000000..3b59eb83e5 --- /dev/null +++ b/extra/cuda/ffi/ffi.factor @@ -0,0 +1,439 @@ +! (c)2010 Joe Groff bsd license +USING: alien alien.c-types alien.libraries alien.syntax +classes.struct combinators system ; +IN: cuda.ffi + +<< +"cuda" { + { [ os windows? ] [ "nvcuda.dll" stdcall ] } + { [ os macosx? ] [ "/usr/local/cuda/lib/libcuda.dylib" cdecl ] } + { [ os unix? ] [ "libcuda.so" cdecl ] } +} cond add-library +>> + +TYPEDEF: uint CUdeviceptr +TYPEDEF: int CUdevice +TYPEDEF: void* CUcontext +TYPEDEF: void* CUmodule +TYPEDEF: void* CUfunction +TYPEDEF: void* CUarray +TYPEDEF: void* CUtexref +TYPEDEF: void* CUevent +TYPEDEF: void* CUstream +TYPEDEF: void* CUgraphicsResource + +STRUCT: CUuuid + { bytes char[16] } ; + +C-ENUM: CUctx_flags + { CU_CTX_SCHED_AUTO 0 } + { CU_CTX_SCHED_SPIN 1 } + { CU_CTX_SCHED_YIELD 2 } + { CU_CTX_SCHED_MASK 3 } + { CU_CTX_BLOCKING_SYNC 4 } + { CU_CTX_MAP_HOST 8 } + { CU_CTX_LMEM_RESIZE_TO_MAX 16 } + { CU_CTX_FLAGS_MASK HEX: 1f } ; + +C-ENUM: CUevent_flags + { CU_EVENT_DEFAULT 0 } + { CU_EVENT_BLOCKING_SYNC 1 } ; + +C-ENUM: CUarray_format + { CU_AD_FORMAT_UNSIGNED_INT8 HEX: 01 } + { CU_AD_FORMAT_UNSIGNED_INT16 HEX: 02 } + { CU_AD_FORMAT_UNSIGNED_INT32 HEX: 03 } + { CU_AD_FORMAT_SIGNED_INT8 HEX: 08 } + { CU_AD_FORMAT_SIGNED_INT16 HEX: 09 } + { CU_AD_FORMAT_SIGNED_INT32 HEX: 0a } + { CU_AD_FORMAT_HALF HEX: 10 } + { CU_AD_FORMAT_FLOAT HEX: 20 } ; + +C-ENUM: CUaddress_mode + { CU_TR_ADDRESS_MODE_WRAP 0 } + { CU_TR_ADDRESS_MODE_CLAMP 1 } + { CU_TR_ADDRESS_MODE_MIRROR 2 } ; + +C-ENUM: CUfilter_mode + { CU_TR_FILTER_MODE_POINT 0 } + { CU_TR_FILTER_MODE_LINEAR 1 } ; + +C-ENUM: CUdevice_attribute + { CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK 1 } + { CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X 2 } + { CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y 3 } + { CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z 4 } + { CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X 5 } + { CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y 6 } + { CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z 7 } + { CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK 8 } + { CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK 8 } + { CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY 9 } + { CU_DEVICE_ATTRIBUTE_WARP_SIZE 10 } + { CU_DEVICE_ATTRIBUTE_MAX_PITCH 11 } + { CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK 12 } + { CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK 12 } + { CU_DEVICE_ATTRIBUTE_CLOCK_RATE 13 } + { CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT 14 } + + { CU_DEVICE_ATTRIBUTE_GPU_OVERLAP 15 } + { CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT 16 } + { CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT 17 } + { CU_DEVICE_ATTRIBUTE_INTEGRATED 18 } + { CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY 19 } + { CU_DEVICE_ATTRIBUTE_COMPUTE_MODE 20 } + { CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH 21 } + { CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH 22 } + { CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT 23 } + { CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH 24 } + { CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT 25 } + { CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH 26 } + { CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_WIDTH 27 } + { CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_HEIGHT 28 } + { CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES 29 } + { CU_DEVICE_ATTRIBUTE_SURFACE_ALIGNMENT 30 } + { CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS 31 } + { CU_DEVICE_ATTRIBUTE_ECC_ENABLED 32 } ; + +STRUCT: CUdevprop + { maxThreadsPerBlock int } + { maxThreadsDim int[3] } + { maxGridSize int[3] } + { sharedMemPerBlock int } + { totalConstantMemory int } + { SIMDWidth int } + { memPitch int } + { regsPerBlock int } + { clockRate int } + { textureAlign int } ; + +C-ENUM: CUfunction_attribute + { CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK 0 } + { CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES 1 } + { CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES 2 } + { CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES 3 } + { CU_FUNC_ATTRIBUTE_NUM_REGS 4 } + { CU_FUNC_ATTRIBUTE_PTX_VERSION 5 } + { CU_FUNC_ATTRIBUTE_BINARY_VERSION 6 } + CU_FUNC_ATTRIBUTE_MAX ; + +C-ENUM: CUfunc_cache + { CU_FUNC_CACHE_PREFER_NONE HEX: 00 } + { CU_FUNC_CACHE_PREFER_SHARED HEX: 01 } + { CU_FUNC_CACHE_PREFER_L1 HEX: 02 } ; + +C-ENUM: CUmemorytype + { CU_MEMORYTYPE_HOST HEX: 01 } + { CU_MEMORYTYPE_DEVICE HEX: 02 } + { CU_MEMORYTYPE_ARRAY HEX: 03 } ; + +C-ENUM: CUcomputemode + { CU_COMPUTEMODE_DEFAULT 0 } + { CU_COMPUTEMODE_EXCLUSIVE 1 } + { CU_COMPUTEMODE_PROHIBITED 2 } ; + +C-ENUM: CUjit_option + { CU_JIT_MAX_REGISTERS 0 } + CU_JIT_THREADS_PER_BLOCK + CU_JIT_WALL_TIME + CU_JIT_INFO_LOG_BUFFER + CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES + CU_JIT_ERROR_LOG_BUFFER + CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES + CU_JIT_OPTIMIZATION_LEVEL + CU_JIT_TARGET_FROM_CUCONTEXT + CU_JIT_TARGET + CU_JIT_FALLBACK_STRATEGY ; + +C-ENUM: CUjit_target + { CU_TARGET_COMPUTE_10 0 } + CU_TARGET_COMPUTE_11 + CU_TARGET_COMPUTE_12 + CU_TARGET_COMPUTE_13 + CU_TARGET_COMPUTE_20 ; + +C-ENUM: CUjit_fallback + { CU_PREFER_PTX 0 } + CU_PREFER_BINARY ; + +C-ENUM: CUgraphicsRegisterFlags + { CU_GRAPHICS_REGISTER_FLAGS_NONE 0 } ; + +C-ENUM: CUgraphicsMapResourceFlags + { CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE HEX: 00 } + { CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY HEX: 01 } + { CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD HEX: 02 } ; + +C-ENUM: CUarray_cubemap_face + { CU_CUBEMAP_FACE_POSITIVE_X HEX: 00 } + { CU_CUBEMAP_FACE_NEGATIVE_X HEX: 01 } + { CU_CUBEMAP_FACE_POSITIVE_Y HEX: 02 } + { CU_CUBEMAP_FACE_NEGATIVE_Y HEX: 03 } + { CU_CUBEMAP_FACE_POSITIVE_Z HEX: 04 } + { CU_CUBEMAP_FACE_NEGATIVE_Z HEX: 05 } ; + +C-ENUM: CUresult + { CUDA_SUCCESS 0 } + { CUDA_ERROR_INVALID_VALUE 1 } + { CUDA_ERROR_OUT_OF_MEMORY 2 } + { CUDA_ERROR_NOT_INITIALIZED 3 } + { CUDA_ERROR_DEINITIALIZED 4 } + + { CUDA_ERROR_NO_DEVICE 100 } + { CUDA_ERROR_INVALID_DEVICE 101 } + + { CUDA_ERROR_INVALID_IMAGE 200 } + { CUDA_ERROR_INVALID_CONTEXT 201 } + { CUDA_ERROR_CONTEXT_ALREADY_CURRENT 202 } + { CUDA_ERROR_MAP_FAILED 205 } + { CUDA_ERROR_UNMAP_FAILED 206 } + { CUDA_ERROR_ARRAY_IS_MAPPED 207 } + { CUDA_ERROR_ALREADY_MAPPED 208 } + { CUDA_ERROR_NO_BINARY_FOR_GPU 209 } + { CUDA_ERROR_ALREADY_ACQUIRED 210 } + { CUDA_ERROR_NOT_MAPPED 211 } + { CUDA_ERROR_NOT_MAPPED_AS_ARRAY 212 } + { CUDA_ERROR_NOT_MAPPED_AS_POINTER 213 } + { CUDA_ERROR_ECC_UNCORRECTABLE 214 } + + { CUDA_ERROR_INVALID_SOURCE 300 } + { CUDA_ERROR_FILE_NOT_FOUND 301 } + + { CUDA_ERROR_INVALID_HANDLE 400 } + + { CUDA_ERROR_NOT_FOUND 500 } + + { CUDA_ERROR_NOT_READY 600 } + + { CUDA_ERROR_LAUNCH_FAILED 700 } + { CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES 701 } + { CUDA_ERROR_LAUNCH_TIMEOUT 702 } + { CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING 703 } + + { CUDA_ERROR_POINTER_IS_64BIT 800 } + { CUDA_ERROR_SIZE_IS_64BIT 801 } + + { CUDA_ERROR_UNKNOWN 999 } ; + +CONSTANT: CU_MEMHOSTALLOC_PORTABLE HEX: 01 +CONSTANT: CU_MEMHOSTALLOC_DEVICEMAP HEX: 02 +CONSTANT: CU_MEMHOSTALLOC_WRITECOMBINED HEX: 04 + +STRUCT: CUDA_MEMCPY2D + { srcXInBytes uint } + { srcY uint } + { srcMemoryType CUmemorytype } + { srcHost void* } + { srcDevice CUdeviceptr } + { srcArray CUarray } + { srcPitch uint } + { dstXInBytes uint } + { dstY uint } + { dstMemoryType CUmemorytype } + { dstHost void* } + { dstDevice CUdeviceptr } + { dstArray CUarray } + { dstPitch uint } + { WidthInBytes uint } + { Height uint } ; + +STRUCT: CUDA_MEMCPY3D + { srcXInBytes uint } + { srcY uint } + { srcZ uint } + { srcLOD uint } + { srcMemoryType CUmemorytype } + { srcHost void* } + { srcDevice CUdeviceptr } + { srcArray CUarray } + { reserved0 void* } + { srcPitch uint } + { srcHeight uint } + { dstXInBytes uint } + { dstY uint } + { dstZ uint } + { dstLOD uint } + { dstMemoryType CUmemorytype } + { dstHost void* } + { dstDevice CUdeviceptr } + { dstArray CUarray } + { reserved1 void* } + { dstPitch uint } + { dstHeight uint } + { WidthInBytes uint } + { Height uint } + { Depth uint } ; + +STRUCT: CUDA_ARRAY_DESCRIPTOR + { Width uint } + { Height uint } + { Format CUarray_format } + { NumChannels uint } ; + +STRUCT: CUDA_ARRAY3D_DESCRIPTOR + { Width uint } + { Height uint } + { Depth uint } + { Format CUarray_format } + { NumChannels uint } + { Flags uint } ; + +CONSTANT: CUDA_ARRAY3D_2DARRAY HEX: 01 +CONSTANT: CU_TRSA_OVERRIDE_FORMAT HEX: 01 +CONSTANT: CU_TRSF_READ_AS_INTEGER HEX: 01 +CONSTANT: CU_TRSF_NORMALIZED_COORDINATES HEX: 02 +CONSTANT: CU_PARAM_TR_DEFAULT -1 + +FUNCTION: CUresult cuInit ( uint Flags ) ; + +FUNCTION: CUresult cuDriverGetVersion ( int* driverVersion ) ; + +FUNCTION: CUresult cuDeviceGet ( CUdevice* device, int ordinal ) ; +FUNCTION: CUresult cuDeviceGetCount ( int* count ) ; +FUNCTION: CUresult cuDeviceGetName ( char* name, int len, CUdevice dev ) ; +FUNCTION: CUresult cuDeviceComputeCapability ( int* major, int* minor, CUdevice dev ) ; +FUNCTION: CUresult cuDeviceTotalMem ( uint* bytes, CUdevice dev ) ; +FUNCTION: CUresult cuDeviceGetProperties ( CUdevprop* prop, CUdevice dev ) ; +FUNCTION: CUresult cuDeviceGetAttribute ( int* pi, CUdevice_attribute attrib, CUdevice dev ) ; + +FUNCTION: CUresult cuCtxCreate ( CUcontext* pctx, uint flags, CUdevice dev ) ; +FUNCTION: CUresult cuCtxDestroy ( CUcontext ctx ) ; +FUNCTION: CUresult cuCtxAttach ( CUcontext* pctx, uint flags ) ; +FUNCTION: CUresult cuCtxDetach ( CUcontext ctx ) ; +FUNCTION: CUresult cuCtxPushCurrent ( CUcontext ctx ) ; +FUNCTION: CUresult cuCtxPopCurrent ( CUcontext* pctx ) ; +FUNCTION: CUresult cuCtxGetDevice ( CUdevice* device ) ; +FUNCTION: CUresult cuCtxSynchronize ( ) ; + +FUNCTION: CUresult cuModuleLoad ( CUmodule* module, char* fname ) ; +FUNCTION: CUresult cuModuleLoadData ( CUmodule* module, void* image ) ; +FUNCTION: CUresult cuModuleLoadDataEx ( CUmodule* module, void* image, uint numOptions, CUjit_option* options, void** optionValues ) ; +FUNCTION: CUresult cuModuleLoadFatBinary ( CUmodule* module, void* fatCubin ) ; +FUNCTION: CUresult cuModuleUnload ( CUmodule hmod ) ; +FUNCTION: CUresult cuModuleGetFunction ( CUfunction* hfunc, CUmodule hmod, char* name ) ; +FUNCTION: CUresult cuModuleGetGlobal ( CUdeviceptr* dptr, uint* bytes, CUmodule hmod, char* name ) ; +FUNCTION: CUresult cuModuleGetTexRef ( CUtexref* pTexRef, CUmodule hmod, char* name ) ; + +FUNCTION: CUresult cuMemGetInfo ( uint* free, uint* total ) ; + +FUNCTION: CUresult cuMemAlloc ( CUdeviceptr* dptr, uint bytesize ) ; +FUNCTION: CUresult cuMemAllocPitch ( CUdeviceptr* dptr, + uint* pPitch, + uint WidthInBytes, + uint Height, + uint ElementSizeBytes + ) ; +FUNCTION: CUresult cuMemFree ( CUdeviceptr dptr ) ; +FUNCTION: CUresult cuMemGetAddressRange ( CUdeviceptr* pbase, uint* psize, CUdeviceptr dptr ) ; + +FUNCTION: CUresult cuMemAllocHost ( void** pp, uint bytesize ) ; +FUNCTION: CUresult cuMemFreeHost ( void* p ) ; + +FUNCTION: CUresult cuMemHostAlloc ( void** pp, size_t bytesize, uint Flags ) ; + +FUNCTION: CUresult cuMemHostGetDevicePointer ( CUdeviceptr* pdptr, void* p, uint Flags ) ; +FUNCTION: CUresult cuMemHostGetFlags ( uint* pFlags, void* p ) ; + +FUNCTION: CUresult cuMemcpyHtoD ( CUdeviceptr dstDevice, void* srcHost, uint ByteCount ) ; +FUNCTION: CUresult cuMemcpyDtoH ( void* dstHost, CUdeviceptr srcDevice, uint ByteCount ) ; + +FUNCTION: CUresult cuMemcpyDtoD ( CUdeviceptr dstDevice, CUdeviceptr srcDevice, uint ByteCount ) ; + +FUNCTION: CUresult cuMemcpyDtoA ( CUarray dstArray, uint dstIndex, CUdeviceptr srcDevice, uint ByteCount ) ; +FUNCTION: CUresult cuMemcpyAtoD ( CUdeviceptr dstDevice, CUarray hSrc, uint SrcIndex, uint ByteCount ) ; + +FUNCTION: CUresult cuMemcpyHtoA ( CUarray dstArray, uint dstIndex, void* pSrc, uint ByteCount ) ; +FUNCTION: CUresult cuMemcpyAtoH ( void* dstHost, CUarray srcArray, uint srcIndex, uint ByteCount ) ; + +FUNCTION: CUresult cuMemcpyAtoA ( CUarray dstArray, uint dstIndex, CUarray srcArray, uint srcIndex, uint ByteCount ) ; + +FUNCTION: CUresult cuMemcpy2D ( CUDA_MEMCPY2D* pCopy ) ; +FUNCTION: CUresult cuMemcpy2DUnaligned ( CUDA_MEMCPY2D* pCopy ) ; + +FUNCTION: CUresult cuMemcpy3D ( CUDA_MEMCPY3D* pCopy ) ; + +FUNCTION: CUresult cuMemcpyHtoDAsync ( CUdeviceptr dstDevice, + void* srcHost, uint ByteCount, CUstream hStream ) ; +FUNCTION: CUresult cuMemcpyDtoHAsync ( void* dstHost, + CUdeviceptr srcDevice, uint ByteCount, CUstream hStream ) ; + +FUNCTION: CUresult cuMemcpyDtoDAsync ( CUdeviceptr dstDevice, + CUdeviceptr srcDevice, uint ByteCount, CUstream hStream ) ; + +FUNCTION: CUresult cuMemcpyHtoAAsync ( CUarray dstArray, uint dstIndex, + void* pSrc, uint ByteCount, CUstream hStream ) ; +FUNCTION: CUresult cuMemcpyAtoHAsync ( void* dstHost, CUarray srcArray, uint srcIndex, + uint ByteCount, CUstream hStream ) ; + +FUNCTION: CUresult cuMemcpy2DAsync ( CUDA_MEMCPY2D* pCopy, CUstream hStream ) ; +FUNCTION: CUresult cuMemcpy3DAsync ( CUDA_MEMCPY3D* pCopy, CUstream hStream ) ; + +FUNCTION: CUresult cuMemsetD8 ( CUdeviceptr dstDevice, uchar uc, uint N ) ; +FUNCTION: CUresult cuMemsetD16 ( CUdeviceptr dstDevice, ushort us, uint N ) ; +FUNCTION: CUresult cuMemsetD32 ( CUdeviceptr dstDevice, uint ui, uint N ) ; + +FUNCTION: CUresult cuMemsetD2D8 ( CUdeviceptr dstDevice, uint dstPitch, uchar uc, uint Width, uint Height ) ; +FUNCTION: CUresult cuMemsetD2D16 ( CUdeviceptr dstDevice, uint dstPitch, ushort us, uint Width, uint Height ) ; +FUNCTION: CUresult cuMemsetD2D32 ( CUdeviceptr dstDevice, uint dstPitch, uint ui, uint Width, uint Height ) ; + +FUNCTION: CUresult cuFuncSetBlockShape ( CUfunction hfunc, int x, int y, int z ) ; +FUNCTION: CUresult cuFuncSetSharedSize ( CUfunction hfunc, uint bytes ) ; +FUNCTION: CUresult cuFuncGetAttribute ( int* pi, CUfunction_attribute attrib, CUfunction hfunc ) ; +FUNCTION: CUresult cuFuncSetCacheConfig ( CUfunction hfunc, CUfunc_cache config ) ; + +FUNCTION: CUresult cuArrayCreate ( CUarray* pHandle, CUDA_ARRAY_DESCRIPTOR* pAllocateArray ) ; +FUNCTION: CUresult cuArrayGetDescriptor ( CUDA_ARRAY_DESCRIPTOR* pArrayDescriptor, CUarray hArray ) ; +FUNCTION: CUresult cuArrayDestroy ( CUarray hArray ) ; + +FUNCTION: CUresult cuArray3DCreate ( CUarray* pHandle, CUDA_ARRAY3D_DESCRIPTOR* pAllocateArray ) ; +FUNCTION: CUresult cuArray3DGetDescriptor ( CUDA_ARRAY3D_DESCRIPTOR* pArrayDescriptor, CUarray hArray ) ; + +FUNCTION: CUresult cuTexRefCreate ( CUtexref* pTexRef ) ; +FUNCTION: CUresult cuTexRefDestroy ( CUtexref hTexRef ) ; + +FUNCTION: CUresult cuTexRefSetArray ( CUtexref hTexRef, CUarray hArray, uint Flags ) ; +FUNCTION: CUresult cuTexRefSetAddress ( uint* ByteOffset, CUtexref hTexRef, CUdeviceptr dptr, uint bytes ) ; +FUNCTION: CUresult cuTexRefSetAddress2D ( CUtexref hTexRef, CUDA_ARRAY_DESCRIPTOR* desc, CUdeviceptr dptr, uint Pitch ) ; +FUNCTION: CUresult cuTexRefSetFormat ( CUtexref hTexRef, CUarray_format fmt, int NumPackedComponents ) ; +FUNCTION: CUresult cuTexRefSetAddressMode ( CUtexref hTexRef, int dim, CUaddress_mode am ) ; +FUNCTION: CUresult cuTexRefSetFilterMode ( CUtexref hTexRef, CUfilter_mode fm ) ; +FUNCTION: CUresult cuTexRefSetFlags ( CUtexref hTexRef, uint Flags ) ; + +FUNCTION: CUresult cuTexRefGetAddress ( CUdeviceptr* pdptr, CUtexref hTexRef ) ; +FUNCTION: CUresult cuTexRefGetArray ( CUarray* phArray, CUtexref hTexRef ) ; +FUNCTION: CUresult cuTexRefGetAddressMode ( CUaddress_mode* pam, CUtexref hTexRef, int dim ) ; +FUNCTION: CUresult cuTexRefGetFilterMode ( CUfilter_mode* pfm, CUtexref hTexRef ) ; +FUNCTION: CUresult cuTexRefGetFormat ( CUarray_format* pFormat, int* pNumChannels, CUtexref hTexRef ) ; +FUNCTION: CUresult cuTexRefGetFlags ( uint* pFlags, CUtexref hTexRef ) ; + +FUNCTION: CUresult cuParamSetSize ( CUfunction hfunc, uint numbytes ) ; +FUNCTION: CUresult cuParamSeti ( CUfunction hfunc, int offset, uint value ) ; +FUNCTION: CUresult cuParamSetf ( CUfunction hfunc, int offset, float value ) ; +FUNCTION: CUresult cuParamSetv ( CUfunction hfunc, int offset, void* ptr, uint numbytes ) ; +FUNCTION: CUresult cuParamSetTexRef ( CUfunction hfunc, int texunit, CUtexref hTexRef ) ; + +FUNCTION: CUresult cuLaunch ( CUfunction f ) ; +FUNCTION: CUresult cuLaunchGrid ( CUfunction f, int grid_width, int grid_height ) ; +FUNCTION: CUresult cuLaunchGridAsync ( CUfunction f, int grid_width, int grid_height, CUstream hStream ) ; + +FUNCTION: CUresult cuEventCreate ( CUevent* phEvent, uint Flags ) ; +FUNCTION: CUresult cuEventRecord ( CUevent hEvent, CUstream hStream ) ; +FUNCTION: CUresult cuEventQuery ( CUevent hEvent ) ; +FUNCTION: CUresult cuEventSynchronize ( CUevent hEvent ) ; +FUNCTION: CUresult cuEventDestroy ( CUevent hEvent ) ; +FUNCTION: CUresult cuEventElapsedTime ( float* pMilliseconds, CUevent hStart, CUevent hEnd ) ; + +FUNCTION: CUresult cuStreamCreate ( CUstream* phStream, uint Flags ) ; +FUNCTION: CUresult cuStreamQuery ( CUstream hStream ) ; +FUNCTION: CUresult cuStreamSynchronize ( CUstream hStream ) ; +FUNCTION: CUresult cuStreamDestroy ( CUstream hStream ) ; + +FUNCTION: CUresult cuGraphicsUnregisterResource ( CUgraphicsResource resource ) ; +FUNCTION: CUresult cuGraphicsSubResourceGetMappedArray ( CUarray* pArray, CUgraphicsResource resource, uint arrayIndex, uint mipLevel ) ; +FUNCTION: CUresult cuGraphicsResourceGetMappedPointer ( CUdeviceptr* pDevPtr, uint* pSize, CUgraphicsResource resource ) ; +FUNCTION: CUresult cuGraphicsResourceSetMapFlags ( CUgraphicsResource resource, uint flags ) ; +FUNCTION: CUresult cuGraphicsMapResources ( uint count, CUgraphicsResource* resources, CUstream hStream ) ; +FUNCTION: CUresult cuGraphicsUnmapResources ( uint count, CUgraphicsResource* resources, CUstream hStream ) ; + +FUNCTION: CUresult cuGetExportTable ( void** ppExportTable, CUuuid* pExportTableId ) ; + From a46c624123a5ece55c247d0176d9bc58fffbcdd8 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 12 Apr 2010 17:45:30 -0700 Subject: [PATCH 645/713] missed LIBRARY: cuda in cuda.ffi --- extra/cuda/ffi/ffi.factor | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extra/cuda/ffi/ffi.factor b/extra/cuda/ffi/ffi.factor index 3b59eb83e5..ce6f8cb8b8 100644 --- a/extra/cuda/ffi/ffi.factor +++ b/extra/cuda/ffi/ffi.factor @@ -11,6 +11,8 @@ IN: cuda.ffi } cond add-library >> +LIBRARY: cuda + TYPEDEF: uint CUdeviceptr TYPEDEF: int CUdevice TYPEDEF: void* CUcontext From 99a3b3c9f61a13ad3b514b883836a5f8b53063d2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Apr 2010 18:17:21 -0700 Subject: [PATCH 646/713] furnace: documentation improvements --- basis/furnace/actions/actions-docs.factor | 2 +- basis/html/components/components-docs.factor | 2 +- basis/html/components/components.factor | 9 ++++++++- basis/html/templates/chloe/chloe-docs.factor | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/basis/furnace/actions/actions-docs.factor b/basis/furnace/actions/actions-docs.factor index a49d6d54b3..862bdead72 100644 --- a/basis/furnace/actions/actions-docs.factor +++ b/basis/furnace/actions/actions-docs.factor @@ -31,7 +31,7 @@ HELP: new-action { $description "Constructs a subclass of " { $link action } "." } ; HELP: page-action -{ $class-description "The class of Chloe page actions. These are actions whose " { $slot "display" } " slot is pre-set to serve the Chloe template stored in the " { $slot "page" } " slot." } ; +{ $class-description "The class of Chloe page actions. These are actions whose " { $slot "display" } " slot is pre-set to serve the Chloe template stored in the " { $slot "template" } " slot. The " { $slot "template" } " slot contains a pair with shape " { $snippet "{ responder name }" } "." } ; HELP: validate-integer-id { $description "A utility word which validates an integer parameter named " { $snippet "id" } "." } diff --git a/basis/html/components/components-docs.factor b/basis/html/components/components-docs.factor index c35237b403..3b4f1d6ae3 100644 --- a/basis/html/components/components-docs.factor +++ b/basis/html/components/components-docs.factor @@ -29,7 +29,7 @@ HELP: textarea { $class-description "Text area components display a multi-line editor for a string value. The " { $slot "rows" } " and " { $slot "cols" } " properties determine the size of the text area." } ; HELP: link -{ $description "Link components render a link to an object stored at a value, with the link title and URL determined by the " { $link link-title } " and " { $link link-href } " generic words. The optional " { $slot "target" } " slot is a target frame to open the link in." } ; +{ $description "Link components render a value responding to the " { $link link-title } " and " { $link link-href } " generic words. The optional " { $slot "target" } " slot is a target frame to open the link in." } ; HELP: link-title { $values { "obj" object } { "string" string } } diff --git a/basis/html/components/components.factor b/basis/html/components/components.factor index 9dddb85619..5a2a55bfd0 100644 --- a/basis/html/components/components.factor +++ b/basis/html/components/components.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008, 2009 Slava Pestov, Daniel Ehrenberg +! Copyright (C) 2008, 2010 Slava Pestov, Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel namespaces io math.parser assocs classes classes.tuple words arrays sequences splitting mirrors @@ -117,6 +117,13 @@ M: string link-href ; M: url link-title ; M: url link-href ; +TUPLE: simple-link title href ; + +C: simple-link + +M: simple-link link-title title>> ; +M: simple-link link-href href>> ; + TUPLE: link target ; M: link render* diff --git a/basis/html/templates/chloe/chloe-docs.factor b/basis/html/templates/chloe/chloe-docs.factor index 41653cb85a..a3032aba96 100644 --- a/basis/html/templates/chloe/chloe-docs.factor +++ b/basis/html/templates/chloe/chloe-docs.factor @@ -60,7 +60,7 @@ HELP: compile-with-scope { $description "Calls the quotation and wraps any output it compiles in a " { $link with-scope } " form." } ; ARTICLE: "html.templates.chloe.tags.component" "Component Chloe tags" -"The following Chloe tags correspond exactly to " { $link "html.components" } ". Singleton component tags do not allow any attributes. Attributes of tuple component tags are mapped to tuple slot values of the component instance." +"The following Chloe tags correspond exactly to " { $link "html.components" } ". The " { $snippet "name" } " attribute should be the name of a form value (see " { $link "html.forms.values" } "). Singleton component tags do not allow any other attributes. Tuple component tags map all other attributes to tuple slot values of the component instance." { $table { "Tag" "Component class" } { { $snippet "t:checkbox" } { $link checkbox } } From 3c11991843ef547fb2044bd38fa5b4950277db1b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Apr 2010 18:29:47 -0700 Subject: [PATCH 647/713] classes.struct, specialized-arrays: fix unit tests to work when forget-tests? is on --- basis/classes/struct/struct-tests.factor | 12 +++++-- .../specialized-arrays-tests.factor | 34 ++++++++++++++----- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/basis/classes/struct/struct-tests.factor b/basis/classes/struct/struct-tests.factor index dafd31efde..13088e1469 100644 --- a/basis/classes/struct/struct-tests.factor +++ b/basis/classes/struct/struct-tests.factor @@ -4,9 +4,11 @@ assocs byte-arrays classes.struct classes.tuple.parser classes.tuple.private classes.tuple combinators compiler.tree.debugger compiler.units destructors io.encodings.utf8 io.pathnames io.streams.string kernel libc literals math mirrors namespaces -prettyprint prettyprint.config see sequences specialized-arrays system -tools.test parser lexer eval layouts generic.single classes ; +prettyprint prettyprint.config see sequences specialized-arrays +system tools.test parser lexer eval layouts generic.single classes +vocabs ; FROM: math => float ; +FROM: specialized-arrays.private => specialized-array-vocab ; QUALIFIED-WITH: alien.c-types c SPECIALIZED-ARRAY: char SPECIALIZED-ARRAY: int @@ -303,6 +305,12 @@ SPECIALIZED-ARRAY: struct-test-optimization { x>> } inlined? ] unit-test +[ ] [ + [ + struct-test-optimization specialized-array-vocab forget-vocab + ] with-compilation-unit +] unit-test + ! Test cloning structs STRUCT: clone-test-struct { x int } { y char[3] } ; diff --git a/basis/specialized-arrays/specialized-arrays-tests.factor b/basis/specialized-arrays/specialized-arrays-tests.factor index 645606edc5..2dee88df88 100644 --- a/basis/specialized-arrays/specialized-arrays-tests.factor +++ b/basis/specialized-arrays/specialized-arrays-tests.factor @@ -1,13 +1,13 @@ -IN: specialized-arrays.tests -USING: tools.test alien.syntax specialized-arrays -specialized-arrays.private sequences alien accessors -kernel arrays combinators compiler compiler.units classes.struct -combinators.smart compiler.tree.debugger math libc destructors -sequences.private multiline eval words vocabs namespaces -assocs prettyprint alien.data math.vectors definitions -compiler.test ; +USING: tools.test alien.syntax specialized-arrays sequences +alien accessors kernel arrays combinators compiler +compiler.units classes.struct combinators.smart +compiler.tree.debugger math libc destructors sequences.private +multiline eval words vocabs namespaces assocs prettyprint +alien.data math.vectors definitions compiler.test ; +FROM: specialized-arrays.private => specialized-array-vocab ; FROM: alien.c-types => int float bool char float ulonglong ushort uint heap-size little-endian? ; +IN: specialized-arrays.tests SPECIALIZED-ARRAY: int SPECIALIZED-ARRAYS: bool ushort char uint float ulonglong ; @@ -101,6 +101,12 @@ SPECIALIZED-ARRAY: test-struct } second ] unit-test +[ ] [ + [ + test-struct specialized-array-vocab forget-vocab + ] with-compilation-unit +] unit-test + ! Regression STRUCT: fixed-string { text char[64] } ; @@ -115,6 +121,12 @@ SPECIALIZED-ARRAY: fixed-string ALIEN: 123 100 byte-length ] unit-test +[ ] [ + [ + fixed-string specialized-array-vocab forget-vocab + ] with-compilation-unit +] unit-test + ! Test prettyprinting [ "int-array{ 1 2 3 }" ] [ int-array{ 1 2 3 } unparse ] unit-test [ "int-array@ f 100" ] [ f 100 unparse ] unit-test @@ -172,3 +184,9 @@ SPECIALIZED-ARRAY: struct-resize-test [ 80 ] [ 10 byte-length ] unit-test [ { 10 20 30 } ] [ { 10 20 30 } struct-resize-test-usage ] unit-test + +[ ] [ + [ + struct-resize-test specialized-array-vocab forget-vocab + ] with-compilation-unit +] unit-test From 03ec284c2e9601dd9856c6eb580b5f23235535e1 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 12 Apr 2010 19:10:20 -0700 Subject: [PATCH 648/713] nm for ELF files --- extra/elf/elf.factor | 8 +++++--- extra/elf/nm/authors.txt | 1 + extra/elf/nm/nm-docs.factor | 22 ++++++++++++++++++++++ extra/elf/nm/nm.factor | 25 +++++++++++++++++++++++++ extra/elf/nm/summary.txt | 1 + 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 extra/elf/nm/authors.txt create mode 100644 extra/elf/nm/nm-docs.factor create mode 100644 extra/elf/nm/nm.factor create mode 100644 extra/elf/nm/summary.txt diff --git a/extra/elf/elf.factor b/extra/elf/elf.factor index bf4de754d1..b2fe7db8a4 100644 --- a/extra/elf/elf.factor +++ b/extra/elf/elf.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien alien.c-types alien.strings alien.syntax arrays -classes.struct io.encodings.ascii kernel locals math math.intervals -sequences specialized-arrays strings typed ; +classes.struct fry io.encodings.ascii kernel locals math +math.intervals sequences specialized-arrays strings typed ; IN: elf ! FFI data @@ -609,4 +609,6 @@ M:: segment sections ( segment -- sections ) symbol sym>> st_value>> segment p_vaddr>> - segment p_offset>> + :> faddress faddress symbol elf-header>> >c-ptr symbol sym>> st_size>> ; - + +: find-section ( sections name -- section/f ) + '[ name>> _ = ] find nip ; diff --git a/extra/elf/nm/authors.txt b/extra/elf/nm/authors.txt new file mode 100644 index 0000000000..6f03a12101 --- /dev/null +++ b/extra/elf/nm/authors.txt @@ -0,0 +1 @@ +Erik Charlebois diff --git a/extra/elf/nm/nm-docs.factor b/extra/elf/nm/nm-docs.factor new file mode 100644 index 0000000000..f07af890c8 --- /dev/null +++ b/extra/elf/nm/nm-docs.factor @@ -0,0 +1,22 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: elf help.markup help.syntax ; +IN: elf.nm + +HELP: nm +{ $values + { "path" "a pathname string" } +} +{ $description "Prints information about the symbols in the ELF object at the given path." } ; + +HELP: print-symbol +{ $values + { "sections" "sequence of section" } { "symbol" symbol } +} +{ $description "Prints the value, section and name of the given symbol." } ; + +ARTICLE: "elf.nm" "ELF nm" +{ $description "Utility to print the values, sections and names of the symbols in a given ELF file. In an ELF executable or shared library, the symbol values are typically their virtual addresses. In a relocatable ELF object, they are section-relative offsets." } +; + +ABOUT: "elf.nm" diff --git a/extra/elf/nm/nm.factor b/extra/elf/nm/nm.factor new file mode 100644 index 0000000000..f9df61249d --- /dev/null +++ b/extra/elf/nm/nm.factor @@ -0,0 +1,25 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors combinators elf formatting io.mmap kernel sequences ; +IN: elf.nm + +: print-symbol ( sections symbol -- ) + [ sym>> st_value>> "%016d " printf ] + [ + sym>> st_shndx>> + { + { SHN_UNDEF [ drop "undefined" ] } + { SHN_ABS [ drop "absolute" ] } + { SHN_COMMON [ drop "common" ] } + [ swap nth name>> ] + } case "%-16s " printf + ] + [ name>> "%s\n" printf ] tri ; + +: nm ( path -- ) + [ + address>> sections + dup ".symtab" find-section + symbols [ name>> empty? not ] filter + [ print-symbol ] with each + ] with-mapped-file ; diff --git a/extra/elf/nm/summary.txt b/extra/elf/nm/summary.txt new file mode 100644 index 0000000000..7d378d3c38 --- /dev/null +++ b/extra/elf/nm/summary.txt @@ -0,0 +1 @@ +UNIX nm-like utility. From 904a2057282cb31af9511173cfa8f1f03d939e6a Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 12 Apr 2010 21:23:26 -0700 Subject: [PATCH 649/713] Test cases for ELF --- extra/elf/elf-tests.factor | 180 +++++++++++++++++++++++++++++++++++ extra/elf/elf.factor | 16 +++- extra/elf/nm/nm-docs.factor | 2 +- extra/elf/nm/nm-tests.factor | 51 ++++++++++ extra/elf/nm/nm.factor | 5 +- 5 files changed, 248 insertions(+), 6 deletions(-) create mode 100644 extra/elf/elf-tests.factor create mode 100644 extra/elf/nm/nm-tests.factor diff --git a/extra/elf/elf-tests.factor b/extra/elf/elf-tests.factor new file mode 100644 index 0000000000..c0ade1bcd1 --- /dev/null +++ b/extra/elf/elf-tests.factor @@ -0,0 +1,180 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors byte-arrays elf kernel sequences tools.test ; +IN: elf.tests + +{ + { + "" + ".interp" + ".note.ABI-tag" + ".note.gnu.build-id" + ".hash" + ".gnu.hash" + ".dynsym" + ".dynstr" + ".gnu.version" + ".gnu.version_r" + ".rela.dyn" + ".rela.plt" + ".init" + ".plt" + ".text" + ".fini" + ".rodata" + ".eh_frame_hdr" + ".eh_frame" + ".ctors" + ".dtors" + ".jcr" + ".dynamic" + ".got" + ".got.plt" + ".data" + ".bss" + ".comment" + ".debug_aranges" + ".debug_pubnames" + ".debug_info" + ".debug_abbrev" + ".debug_line" + ".debug_str" + ".shstrtab" + ".symtab" + ".strtab" + } +} +[ + "resource:extra/elf/a.out" [ + sections [ name>> ] map + ] with-mapped-elf +] +unit-test + +{ + { + ".interp" + ".note.ABI-tag" + ".note.gnu.build-id" + ".hash" + ".gnu.hash" + ".dynsym" + ".dynstr" + ".gnu.version" + ".gnu.version_r" + ".rela.dyn" + ".rela.plt" + ".init" + ".plt" + ".text" + ".fini" + ".rodata" + ".eh_frame_hdr" + ".eh_frame" + } +} +[ + "resource:extra/elf/a.out" [ + segments [ program-header>> p_type>> PT_LOAD = ] find nip + sections [ name>> ] map + ] with-mapped-elf +] +unit-test + +{ + { + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "init.c" + "call_gmon_start" + "crtstuff.c" + "__CTOR_LIST__" + "__DTOR_LIST__" + "__JCR_LIST__" + "__do_global_dtors_aux" + "completed.7342" + "dtor_idx.7344" + "frame_dummy" + "crtstuff.c" + "__CTOR_END__" + "__FRAME_END__" + "__JCR_END__" + "__do_global_ctors_aux" + "test.c" + "_GLOBAL_OFFSET_TABLE_" + "__init_array_end" + "__init_array_start" + "_DYNAMIC" + "data_start" + "printf@@GLIBC_2.2.5" + "__libc_csu_fini" + "_start" + "__gmon_start__" + "_Jv_RegisterClasses" + "_fini" + "__libc_start_main@@GLIBC_2.2.5" + "_IO_stdin_used" + "__data_start" + "__dso_handle" + "__DTOR_END__" + "__libc_csu_init" + "__bss_start" + "_end" + "_edata" + "main" + "_init" + } +} +[ + "resource:extra/elf/a.out" [ + sections ".symtab" find-section symbols + [ name>> ] map + ] with-mapped-elf +] +unit-test + +{ + B{ + 85 72 137 229 184 44 6 64 0 72 137 199 184 0 0 0 0 232 222 + 254 255 255 201 195 + } +} +[ + "resource:extra/elf/a.out" [ + sections ".symtab" "main" find-section-symbol + symbol-data >byte-array + ] with-mapped-elf +] +unit-test diff --git a/extra/elf/elf.factor b/extra/elf/elf.factor index b2fe7db8a4..19bb3bfbf9 100644 --- a/extra/elf/elf.factor +++ b/extra/elf/elf.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien alien.c-types alien.strings alien.syntax arrays -classes.struct fry io.encodings.ascii kernel locals math +classes.struct fry io.encodings.ascii io.mmap kernel locals math math.intervals sequences specialized-arrays strings typed ; IN: elf @@ -611,4 +611,16 @@ M:: segment sections ( segment -- sections ) symbol sym>> st_size>> ; : find-section ( sections name -- section/f ) - '[ name>> _ = ] find nip ; + '[ name>> _ = ] find nip ; inline + +: find-symbol ( symbols name -- symbol/f ) + '[ name>> _ = ] find nip ; inline + +: find-section-symbol ( sections section symbol -- symbol/f ) + [ find-section ] dip over [ + [ symbols ] dip find-symbol ] [ 2drop f ] if ; + +: with-mapped-elf ( path quot -- ) + '[ + address>> @ + ] with-mapped-file ; inline diff --git a/extra/elf/nm/nm-docs.factor b/extra/elf/nm/nm-docs.factor index f07af890c8..a7b7ad426e 100644 --- a/extra/elf/nm/nm-docs.factor +++ b/extra/elf/nm/nm-docs.factor @@ -16,7 +16,7 @@ HELP: print-symbol { $description "Prints the value, section and name of the given symbol." } ; ARTICLE: "elf.nm" "ELF nm" -{ $description "Utility to print the values, sections and names of the symbols in a given ELF file. In an ELF executable or shared library, the symbol values are typically their virtual addresses. In a relocatable ELF object, they are section-relative offsets." } +"The " { $vocab-link "elf.nm" } " vocab prints the values, sections and names of the symbols in a given ELF file. In an ELF executable or shared library, the symbol values are typically their virtual addresses. In a relocatable ELF object, they are section-relative offsets." ; ABOUT: "elf.nm" diff --git a/extra/elf/nm/nm-tests.factor b/extra/elf/nm/nm-tests.factor new file mode 100644 index 0000000000..e420976d9e --- /dev/null +++ b/extra/elf/nm/nm-tests.factor @@ -0,0 +1,51 @@ +! Copyright (C) 2010 Erik Charlebois. +! See http://factorcode.org/license.txt for BSD license. +USING: elf.nm io io.streams.string kernel multiline strings tools.test +literals ; +IN: elf.nm.tests + +STRING: validation-output +0000000000000000 absolute init.c +0000000004195436 .text call_gmon_start +0000000000000000 absolute crtstuff.c +0000000006295064 .ctors __CTOR_LIST__ +0000000006295080 .dtors __DTOR_LIST__ +0000000006295096 .jcr __JCR_LIST__ +0000000004195472 .text __do_global_dtors_aux +0000000006295584 .bss completed.7342 +0000000006295592 .bss dtor_idx.7344 +0000000004195584 .text frame_dummy +0000000000000000 absolute crtstuff.c +0000000006295072 .ctors __CTOR_END__ +0000000004196056 .eh_frame __FRAME_END__ +0000000006295096 .jcr __JCR_END__ +0000000004195808 .text __do_global_ctors_aux +0000000000000000 absolute test.c +0000000006295528 .got.plt _GLOBAL_OFFSET_TABLE_ +0000000006295060 .ctors __init_array_end +0000000006295060 .ctors __init_array_start +0000000006295104 .dynamic _DYNAMIC +0000000006295568 .data data_start +0000000000000000 undefined printf@@GLIBC_2.2.5 +0000000004195648 .text __libc_csu_fini +0000000004195392 .text _start +0000000000000000 undefined __gmon_start__ +0000000000000000 undefined _Jv_RegisterClasses +0000000004195864 .fini _fini +0000000000000000 undefined __libc_start_main@@GLIBC_2.2.5 +0000000004195880 .rodata _IO_stdin_used +0000000006295568 .data __data_start +0000000006295576 .data __dso_handle +0000000006295088 .dtors __DTOR_END__ +0000000004195664 .text __libc_csu_init +0000000006295584 absolute __bss_start +0000000006295600 absolute _end +0000000006295584 absolute _edata +0000000004195620 .text main +0000000004195312 .init _init + +; + +{ $ validation-output } +[ dup [ "resource:extra/elf/a.out" nm ] with-output-stream >string ] +unit-test diff --git a/extra/elf/nm/nm.factor b/extra/elf/nm/nm.factor index f9df61249d..87c9abf00b 100644 --- a/extra/elf/nm/nm.factor +++ b/extra/elf/nm/nm.factor @@ -18,8 +18,7 @@ IN: elf.nm : nm ( path -- ) [ - address>> sections - dup ".symtab" find-section + sections dup ".symtab" find-section symbols [ name>> empty? not ] filter [ print-symbol ] with each - ] with-mapped-file ; + ] with-mapped-elf ; From f31929ca5b5aa0076eeb9aa18b791d17bd36229f Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Mon, 12 Apr 2010 21:38:01 -0700 Subject: [PATCH 650/713] a.elf for elf tests --- extra/elf/a.elf | Bin 0 -> 9849 bytes extra/elf/elf-tests.factor | 8 ++++---- extra/elf/nm/nm-tests.factor | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) create mode 100755 extra/elf/a.elf diff --git a/extra/elf/a.elf b/extra/elf/a.elf new file mode 100755 index 0000000000000000000000000000000000000000..0f10a2fb3132b888ea405b8221886079dfa431a5 GIT binary patch literal 9849 zcmeHNU2Ggz6}~gGcGfttH@0b=rX?G?MlRH2J9Sg{FCE8DvM$@CO<e((&56wzpmH zy1TQ%sVdc#+tS6P_<@Irf`|k{edrTNs8B>*LL2%5MMw}qK_+U1+q96XGz6-4`Ockt zc4xEmW1595OZykRan1h5SHi= zpA_{#>Tp@Igs7WidP$jP8dP!yXaHBg?gIU~B{NK~c45JkYe zop{c%ZGo_iQxtZJnOrL4OrV?~RX!b0WyHSN@a{o-hq=SNksMJAb+kbf6f?Rg6|PD( z5PpNpisj}}nWH{dL&_})x%dWfRCi864^Hvp6rF!NxRM9AqC6z`c2!g&gryr1s`=38~|E#FL9RUjs`8lzQJ8F8=ENXz^@x{*4QFj|`t)vg#}m zJ^j+%lAMl!th@+?zb!73@908Z3WlOjEIE4VHR*cMn+`{d=MItJ-0gFa6NS&d(1S+~ zY7djzW9K`Gd+7rsI)7e^-h3t>nP}cNB+!T@En2KQ453on%Tj2eZXc=Kd?t7HmAV^{ z)yUnES5Hk$Oqk8v9+&k$9G${Fi;M4(HIKb$F&#M*D<&e#(c@j;4~9kTc*k=@fUm@gPUJ$Y_(0&CGPG`ek%;wUG?H@y+w5`Uih@5;rS0H*D z@&R=9eV}ci4pCf`w1*E0Z8oHB-MAsRh*3oEb-KO-y>=29XbKHJsc+(U80nF{lPLF& z_Xw~NTql4RLB%~^se7{CZnE~yZ}_VIv~fH@;N^5V0+%CjIRcj>a5(~(BkM!3nICx9A^YB<9;}pVuW}n&H z)mM;Q|8*`e))u*$MJiUWN7n5FHSGd@=z* z$Zd);D&x#XAK=EB-T7nrL~AKIQ>{XsIH(4! zTTF(0W2x+9d@7!E{gM>d#mpa@cH(2g%sV-kPH_%m$=r-EGg&8T4(uN8a^jPUo6HnU zIl{V931Jd970*uzGjS{fdoFcyZpqPPE}zO~su&w(xnw#{3Mw~~c7#c_5~h=!#eD({ z%Cd>L6BlN3%AUx@r<3+n0=mozbKJ@1@^I*q2gXqdoAK$?I2>kS1~*gMcI}MiAw8a* zo=zeNW+FLOn6%@$cxEz5RwO%97=wWdpUO;Rxhy_5mP;OG4#z}E&Le8FXa5Jct*}AE zjo<72x&^Lsu1I@KZ<0gP1JD?x$C33%bPHVN+%7D+%8lnQMtYI)>N~n6iyUPzBDu=V zuOCH`d?_fA6S^gHCw%&Nj%DKchwTgjy@)x5>%XL1KxjUdqW*pCd&p{&2G zTi}FPR=}v_+%{6|*gwyAp94m7EbH^UZ4rpX^R&ykeZ_gA_v4~DlJ$9BoKyPjkL%BJ zOdo_k&AH6;y!({W52KtC^^v#!62$FcTog;z=Xw5FrO)kT|6Cu&ANT1m85R)4U+MEY zgY;=F17}bmI^SbGR&p$+D;(lkI&Op5S!GI-;f=ZD6vpnnbdhKgIeST+KO7ILB z_axS1=f{Oa} zf8f&}t+%A)sPg}a(qqE?$NUm9)PB`np6?2-gg;(>{nI{uI=Q6OsRFm2{x2Zw^-sr^ zl=_vv-=ClVHDsx&Tz_6C^7oFDs{iTvp~U)Juh)Tj{qs5XaZ`dmN(+2Zzxm45g?)PEnk)czh^-o*NQy&&=` zoMrlv2lI-~DF1%D3NDLofHmEl{p;4y|M6y5(OyUY zrZx1pst5n6b@T_7zCTXiUPm8lGEp_T?-eA;XJ`eCw4ViCc2)eSnBQGWM3N<1)*>yb z_Xxd*cH-i3%ku~AA8YxaQ!lQ6tm7Z*YbFD=?boeUl|;Pftv98r5X>26T0Pv zWZuBaWl6VW-g`6fMp@P^FC_B@W?{>yg$Ko4O}s(yeC{=7;1q!8>1w>Oyl=0@H!B8gCXnzg6QQ!Shx%zPbF}wi<5{JkM0)t>yWn8gIjVFzSV5-oR-G zzwf<;hPVRXt82+$S^kb#E#EHqy<3fM5&S-_#;+3mo~*`cHNH9-itRc3ofrr3r?IA8H1PgJBACz+@7Dtlk-!0v&VePHk2LwiQ-k%8T@ zJyd6ECC*NA@nd!}lc)ydshO~cKEHq9uHivJXD{yWBI*|s%kus)qW&kr!K5uueUzy0 zHx&EMqxQk%WGatisljwSpT`l6lK20Q;xk`;x@y~=>VU~-?WuSskxp_ya7^S+E>tOb WEM?m`JK~zj1}Ei_lKlV075NvT7Pr*^ literal 0 HcmV?d00001 diff --git a/extra/elf/elf-tests.factor b/extra/elf/elf-tests.factor index c0ade1bcd1..d68885e6b7 100644 --- a/extra/elf/elf-tests.factor +++ b/extra/elf/elf-tests.factor @@ -45,7 +45,7 @@ IN: elf.tests } } [ - "resource:extra/elf/a.out" [ + "resource:extra/elf/a.elf" [ sections [ name>> ] map ] with-mapped-elf ] @@ -74,7 +74,7 @@ unit-test } } [ - "resource:extra/elf/a.out" [ + "resource:extra/elf/a.elf" [ segments [ program-header>> p_type>> PT_LOAD = ] find nip sections [ name>> ] map ] with-mapped-elf @@ -158,7 +158,7 @@ unit-test } } [ - "resource:extra/elf/a.out" [ + "resource:extra/elf/a.elf" [ sections ".symtab" find-section symbols [ name>> ] map ] with-mapped-elf @@ -172,7 +172,7 @@ unit-test } } [ - "resource:extra/elf/a.out" [ + "resource:extra/elf/a.elf" [ sections ".symtab" "main" find-section-symbol symbol-data >byte-array ] with-mapped-elf diff --git a/extra/elf/nm/nm-tests.factor b/extra/elf/nm/nm-tests.factor index e420976d9e..2ecb499081 100644 --- a/extra/elf/nm/nm-tests.factor +++ b/extra/elf/nm/nm-tests.factor @@ -47,5 +47,5 @@ STRING: validation-output ; { $ validation-output } -[ dup [ "resource:extra/elf/a.out" nm ] with-output-stream >string ] +[ dup [ "resource:extra/elf/a.elf" nm ] with-output-stream >string ] unit-test From b5e99faf4fe33a1df0e15b31a230b1240fc337e3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Apr 2010 22:54:30 -0700 Subject: [PATCH 651/713] bit.ly: URL shortening web service --- extra/bit/ly/authors.txt | 1 + extra/bit/ly/ly.factor | 23 +++++++++++++++++++++++ extra/bit/ly/summary.txt | 1 + extra/bit/ly/tags.txt | 1 + 4 files changed, 26 insertions(+) create mode 100644 extra/bit/ly/authors.txt create mode 100644 extra/bit/ly/ly.factor create mode 100644 extra/bit/ly/summary.txt create mode 100644 extra/bit/ly/tags.txt diff --git a/extra/bit/ly/authors.txt b/extra/bit/ly/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/extra/bit/ly/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/extra/bit/ly/ly.factor b/extra/bit/ly/ly.factor new file mode 100644 index 0000000000..32d40786f7 --- /dev/null +++ b/extra/bit/ly/ly.factor @@ -0,0 +1,23 @@ +! Copyright (C) 2010 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: assocs http.client json.reader kernel namespaces urls ; +IN: bit.ly + +SYMBOLS: login api-key ; + +url + login get "login" set-query-param + api-key get "apiKey" set-query-param + "json" "format" set-query-param + swap "longUrl" set-query-param ; + +: parse-response ( response data -- short-url ) + nip json> "data" swap at "url" swap at ; + +PRIVATE> + +: shorten-url ( long-url -- short-url ) + make-request http-get parse-response ; diff --git a/extra/bit/ly/summary.txt b/extra/bit/ly/summary.txt new file mode 100644 index 0000000000..29020a649b --- /dev/null +++ b/extra/bit/ly/summary.txt @@ -0,0 +1 @@ +Wrapper for bit.ly URL shortening web service diff --git a/extra/bit/ly/tags.txt b/extra/bit/ly/tags.txt new file mode 100644 index 0000000000..0a8d552b33 --- /dev/null +++ b/extra/bit/ly/tags.txt @@ -0,0 +1 @@ +web services From ea3af2aef6ef885f8359a414a7e1f92e20184ea4 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Apr 2010 22:54:35 -0700 Subject: [PATCH 652/713] twitter: add meta-data --- extra/twitter/summary.txt | 1 + extra/twitter/tags.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 extra/twitter/summary.txt create mode 100644 extra/twitter/tags.txt diff --git a/extra/twitter/summary.txt b/extra/twitter/summary.txt new file mode 100644 index 0000000000..ee9d6c703e --- /dev/null +++ b/extra/twitter/summary.txt @@ -0,0 +1 @@ +Wrapper for Twitter web service diff --git a/extra/twitter/tags.txt b/extra/twitter/tags.txt new file mode 100644 index 0000000000..0a8d552b33 --- /dev/null +++ b/extra/twitter/tags.txt @@ -0,0 +1 @@ +web services From 88f627a402cd7ee4e222aed746002e28a1f3217d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 01:24:04 -0500 Subject: [PATCH 653/713] compiler.tests.alien: fix tests on Win64 --- basis/compiler/tests/alien.factor | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 279c6ef39f..7bbc0a904f 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -684,28 +684,30 @@ mingw? [ : fastcall-struct-return-iii-indirect ( x y z ptr -- result ) test-struct-11 { int int int } fastcall alien-indirect ; +: win32? ( -- ? ) os windows? cpu x86.32? and ; + [ 8 ] [ 3 4 - os windows? [ &: @ffi_test_50@8 ] [ &: ffi_test_50 ] if + win32? [ &: @ffi_test_50@8 ] [ &: ffi_test_50 ] if fastcall-ii-indirect ] unit-test [ 13 ] [ 3 4 5 - os windows? [ &: @ffi_test_51@12 ] [ &: ffi_test_51 ] if + win32? [ &: @ffi_test_51@12 ] [ &: ffi_test_51 ] if fastcall-iii-indirect ] unit-test mingw? [ [ 13 ] [ 3 4.0 5 - os windows? [ &: @ffi_test_52@12 ] [ &: ffi_test_52 ] if + win32? [ &: @ffi_test_52@12 ] [ &: ffi_test_52 ] if fastcall-ifi-indirect ] unit-test [ 19 ] [ 3 4.0 5 6 - os windows? [ &: @ffi_test_53@16 ] [ &: ffi_test_53 ] if + win32? [ &: @ffi_test_53@16 ] [ &: ffi_test_53 ] if fastcall-ifii-indirect ] unit-test ] unless @@ -713,14 +715,14 @@ mingw? [ [ S{ test-struct-11 f 7 -1 } ] [ 3 4 - os windows? [ &: @ffi_test_57@8 ] [ &: ffi_test_57 ] if + win32? [ &: @ffi_test_57@8 ] [ &: ffi_test_57 ] if fastcall-struct-return-ii-indirect ] unit-test [ S{ test-struct-11 f 7 -3 } ] [ 3 4 7 - os windows? [ &: @ffi_test_58@12 ] [ &: ffi_test_58 ] if + win32? [ &: @ffi_test_58@12 ] [ &: ffi_test_58 ] if fastcall-struct-return-iii-indirect ] unit-test From c09f1567cb664641318d77850de53de363b4401a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 00:54:36 -0700 Subject: [PATCH 654/713] bit.ly: check response for errors --- extra/bit/ly/ly.factor | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/extra/bit/ly/ly.factor b/extra/bit/ly/ly.factor index 32d40786f7..1dcdf97dff 100644 --- a/extra/bit/ly/ly.factor +++ b/extra/bit/ly/ly.factor @@ -14,8 +14,16 @@ SYMBOLS: login api-key ; "json" "format" set-query-param swap "longUrl" set-query-param ; +ERROR: bad-response json status ; + +: check-response ( json -- json ) + dup "status_code" swap at 200 = [ + dup "status_txt" swap at + bad-response + ] unless ; + : parse-response ( response data -- short-url ) - nip json> "data" swap at "url" swap at ; + nip json> check-response "data" swap at "url" swap at ; PRIVATE> From 4f162128405f04095298bfa49aec938803cccfec Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 00:56:48 -0700 Subject: [PATCH 655/713] compiler.tests.redefine23: test wasn't testing anything --- basis/compiler/tests/redefine23.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basis/compiler/tests/redefine23.factor b/basis/compiler/tests/redefine23.factor index e6061937b6..dafdc2d1af 100644 --- a/basis/compiler/tests/redefine23.factor +++ b/basis/compiler/tests/redefine23.factor @@ -1,6 +1,7 @@ IN: compiler.tests.redefine23 USING: classes.struct specialized-arrays alien.c-types sequences compiler.units vocabs tools.test ; +FROM: specialized-arrays.private => specialized-array-vocab ; STRUCT: my-struct { x int } ; SPECIALIZED-ARRAY: my-struct @@ -8,6 +9,6 @@ SPECIALIZED-ARRAY: my-struct [ ] [ [ - "specialized-arrays.instances.compiler.tests.redefine23" forget-vocab + my-struct specialized-array-vocab forget-vocab ] with-compilation-unit ] unit-test From 3e6c16ce36729a7ac2944abd926d5d6ec7511fc6 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 01:43:10 -0700 Subject: [PATCH 656/713] bit.ly: some old-school newfx --- extra/bit/ly/ly.factor | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/extra/bit/ly/ly.factor b/extra/bit/ly/ly.factor index 1dcdf97dff..0220fba264 100644 --- a/extra/bit/ly/ly.factor +++ b/extra/bit/ly/ly.factor @@ -7,6 +7,8 @@ SYMBOLS: login api-key ; url login get "login" set-query-param @@ -17,13 +19,13 @@ SYMBOLS: login api-key ; ERROR: bad-response json status ; : check-response ( json -- json ) - dup "status_code" swap at 200 = [ - dup "status_txt" swap at + dup "status_code" of 200 = [ + dup "status_txt" of bad-response ] unless ; : parse-response ( response data -- short-url ) - nip json> check-response "data" swap at "url" swap at ; + nip json> check-response "data" of "url" of ; PRIVATE> From 956ffa8946a93c1b6faf602c506601d5c7603455 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 01:52:57 -0700 Subject: [PATCH 657/713] furnace.recaptcha: add new tag --- basis/furnace/recaptcha/tags.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/basis/furnace/recaptcha/tags.txt b/basis/furnace/recaptcha/tags.txt index c0772185a0..2b49742460 100644 --- a/basis/furnace/recaptcha/tags.txt +++ b/basis/furnace/recaptcha/tags.txt @@ -1 +1,2 @@ web +web services From 89560ee4d98358bee88dfeb60533590d6f2ee35e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 11 Apr 2010 18:42:12 -0700 Subject: [PATCH 658/713] mason: big overhaul - add heartbeats for eventual notification of when build machines go down - mason.version: replaces mason.release, builds source package automatically, and tweets when new versions released - webapps.mason: new downloads action includes automatically-generated source download and release announcement links --- extra/mason/email/email-tests.factor | 2 +- extra/mason/email/email.factor | 37 +++++---- extra/mason/mason.factor | 5 +- extra/mason/notify/notify.factor | 5 +- extra/mason/server/notify/notify.factor | 4 + extra/mason/server/release/authors.txt | 1 - extra/mason/server/release/release.factor | 82 ------------------- extra/mason/server/server.factor | 5 +- extra/mason/source/authors.txt | 1 - extra/mason/source/source.factor | 49 ----------- extra/mason/version/authors.txt | 1 + extra/mason/version/binary/authors.txt | 1 + extra/mason/version/binary/binary.factor | 20 +++++ extra/mason/version/common/authors.txt | 1 + extra/mason/version/common/common.factor | 12 +++ extra/mason/version/data/authors.txt | 1 + extra/mason/version/data/data.factor | 54 ++++++++++++ extra/mason/version/files/authors.txt | 1 + extra/mason/version/files/files.factor | 39 +++++++++ extra/mason/version/source/authors.txt | 1 + extra/mason/version/source/source.factor | 51 ++++++++++++ extra/mason/version/version.factor | 52 ++++++++++++ extra/webapps/mason/download-package.xml | 1 + extra/webapps/mason/downloads.xml | 22 +++++ extra/webapps/mason/downloads/authors.txt | 1 + .../webapps/mason/downloads/downloads.factor | 25 ++++++ extra/webapps/mason/grids/grids.factor | 5 +- extra/webapps/mason/make-release.xml | 8 +- .../mason/make-release/make-release.factor | 5 +- extra/webapps/mason/mason.factor | 12 ++- extra/webapps/mason/package/package.factor | 10 ++- extra/webapps/mason/release/release.factor | 3 +- extra/webapps/mason/utils/utils.factor | 5 +- 33 files changed, 347 insertions(+), 175 deletions(-) delete mode 100644 extra/mason/server/release/authors.txt delete mode 100644 extra/mason/server/release/release.factor delete mode 100644 extra/mason/source/authors.txt delete mode 100644 extra/mason/source/source.factor create mode 100644 extra/mason/version/authors.txt create mode 100644 extra/mason/version/binary/authors.txt create mode 100644 extra/mason/version/binary/binary.factor create mode 100644 extra/mason/version/common/authors.txt create mode 100644 extra/mason/version/common/common.factor create mode 100644 extra/mason/version/data/authors.txt create mode 100644 extra/mason/version/data/data.factor create mode 100644 extra/mason/version/files/authors.txt create mode 100644 extra/mason/version/files/files.factor create mode 100644 extra/mason/version/source/authors.txt create mode 100644 extra/mason/version/source/source.factor create mode 100644 extra/mason/version/version.factor create mode 100644 extra/webapps/mason/downloads.xml create mode 100644 extra/webapps/mason/downloads/authors.txt create mode 100644 extra/webapps/mason/downloads/downloads.factor diff --git a/extra/mason/email/email-tests.factor b/extra/mason/email/email-tests.factor index 5f48ff0d4f..77f651feb9 100644 --- a/extra/mason/email/email-tests.factor +++ b/extra/mason/email/email-tests.factor @@ -6,6 +6,6 @@ USING: mason.email mason.common mason.config namespaces tools.test ; "linux" target-os set "x86.64" target-cpu set "12345" current-git-id set - status-error subject prefix-subject + status-error report-subject ] with-scope ] unit-test diff --git a/extra/mason/email/email.factor b/extra/mason/email/email.factor index 302df599b4..1389a2e27c 100644 --- a/extra/mason/email/email.factor +++ b/extra/mason/email/email.factor @@ -1,35 +1,42 @@ -! Copyright (C) 2008, 2009 Eduardo Cavazos, Slava Pestov. +! Copyright (C) 2008, 2010 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel namespaces accessors combinators make smtp debugger prettyprint sequences io io.streams.string io.encodings.utf8 io.files io.sockets mason.common mason.platform mason.config ; IN: mason.email -: prefix-subject ( str -- str' ) - [ "mason on " % platform % ": " % % ] "" make ; - -: email-status ( body content-type subject -- ) +: mason-email ( body content-type subject -- ) builder-from get >>from builder-recipients get >>to - swap prefix-subject >>subject + swap >>subject swap >>content-type swap >>body send-email ; -: subject ( status -- str ) - [ current-git-id get 7 short head " -- " ] dip { - { status-clean [ "clean" ] } - { status-dirty [ "dirty" ] } - { status-error [ "error" ] } - } case 3append ; +: subject-prefix ( -- string ) + "mason on " platform ": " 3append ; + +: report-subject ( status -- string ) + [ + subject-prefix % + current-git-id get 7 short head % + " -- " % + { + { status-clean [ "clean" ] } + { status-dirty [ "dirty" ] } + { status-error [ "error" ] } + } case % + ] "" make ; : email-report ( report status -- ) - [ "text/html" ] dip subject email-status ; + [ "text/html" ] dip report-subject mason-email ; : email-error ( error callstack -- ) [ "Fatal error on " write host-name print nl [ error. ] [ callstack. ] bi* - ] with-string-writer "text/plain" "fatal error" - email-status ; + ] with-string-writer + "text/plain" + subject-prefix "fatal error" append + mason-email ; diff --git a/extra/mason/mason.factor b/extra/mason/mason.factor index 42f3737e11..9732c03dfa 100755 --- a/extra/mason/mason.factor +++ b/extra/mason/mason.factor @@ -1,8 +1,8 @@ -! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. +! Copyright (C) 2008, 2010 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors calendar continuations debugger io io.directories io.files kernel mason.common -mason.email mason.updates namespaces threads ; +mason.email mason.updates mason.notify namespaces threads ; FROM: mason.build => build ; IN: mason @@ -15,6 +15,7 @@ IN: mason error. flush ; : build-loop ( -- ) + notify-heartbeat ?prepare-build-machine [ [ diff --git a/extra/mason/notify/notify.factor b/extra/mason/notify/notify.factor index 122c8a47cd..d7319c0f20 100644 --- a/extra/mason/notify/notify.factor +++ b/extra/mason/notify/notify.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2009 Slava Pestov. +! Copyright (C) 2009, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays accessors io io.sockets io.encodings.utf8 io.files io.launcher kernel make mason.config mason.common mason.email @@ -22,6 +22,9 @@ IN: mason.notify ] retry ] [ 2drop ] if ; +: notify-heartbeat ( -- ) + f { "heartbeat" } status-notify ; + : notify-begin-build ( git-id -- ) [ "Starting build of GIT ID " write print flush ] [ f swap "git-id" swap 2array status-notify ] diff --git a/extra/mason/server/notify/notify.factor b/extra/mason/server/notify/notify.factor index 2c04a43016..3303749c4f 100644 --- a/extra/mason/server/notify/notify.factor +++ b/extra/mason/server/notify/notify.factor @@ -25,6 +25,9 @@ SYMBOLS: host-name target-os target-cpu message message-arg ; target-cpu get >>cpu dup select-tuple [ ] [ dup insert-tuple ] ?if ; +: heartbeat ( -- ) + now >>heartbeat-timestamp ; + : git-id ( builder id -- ) >>current-git-id +starting+ >>status drop ; @@ -51,6 +54,7 @@ SYMBOLS: host-name target-os target-cpu message message-arg ; : update-builder ( builder -- ) message get { + { "heartbeat" [ heartbeat ] } { "git-id" [ message-arg get git-id ] } { "make-vm" [ make-vm ] } { "boot" [ boot ] } diff --git a/extra/mason/server/release/authors.txt b/extra/mason/server/release/authors.txt deleted file mode 100644 index d4f5d6b3ae..0000000000 --- a/extra/mason/server/release/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Slava Pestov \ No newline at end of file diff --git a/extra/mason/server/release/release.factor b/extra/mason/server/release/release.factor deleted file mode 100644 index 04ca2955a7..0000000000 --- a/extra/mason/server/release/release.factor +++ /dev/null @@ -1,82 +0,0 @@ -! Copyright (C) 2010 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors calendar db db.tuples db.types grouping io -io.encodings.ascii io.launcher kernel locals make -mason.release.archive mason.config mason.platform mason.server -namespaces sequences ; -IN: mason.server.release - -: platform ( builder -- string ) - [ os>> ] [ cpu>> ] bi (platform) ; - -: package-name ( builder -- string ) - [ platform ] [ last-release>> ] bi "/" glue ; - -: release-name ( version builder -- string ) - [ - "releases/" % - over % "/" % - [ "factor-" % platform % "-" % % ] - [ os>> extension % ] - bi - ] "" make ; - -: release-command ( version builder -- command ) - [ - "cp " % - [ nip package-name % " " % ] [ release-name % ] 2bi - ] "" make ; - -TUPLE: release -host-name os cpu -last-release release-git-id ; - -release "RELEASES" { - { "host-name" "HOST_NAME" TEXT +user-assigned-id+ } - { "os" "OS" TEXT +user-assigned-id+ } - { "cpu" "CPU" TEXT +user-assigned-id+ } - { "last-release" "LAST_RELEASE" TEXT } - { "release-git-id" "RELEASE_GIT_ID" TEXT } -} define-persistent - -:: ( version builder -- release ) - release new - builder host-name>> >>host-name - builder os>> >>os - builder cpu>> >>cpu - builder release-git-id>> >>release-git-id - version builder release-name >>last-release ; - -: execute-on-server ( string -- ) - [ "ssh" , upload-host get , "-l" , upload-username get , ] { } make - - swap >>command - 5 minutes >>timeout - ascii [ write ] with-process-writer ; - -: release-script ( version builders -- string ) - [ upload-directory get "cd " "\n" surround ] 2dip - [ release-command ] with map "\n" join - append ; - -: create-releases ( version builders -- ) - release-script execute-on-server ; - -: update-releases ( version builders -- ) - [ - release new delete-tuples - [ insert-tuple ] with each - ] with-transaction ; - -: check-releases ( builders -- ) - [ release-git-id>> ] map all-equal? - [ "Not all builders are up to date" throw ] unless ; - -: do-release ( version -- ) - [ - builder new select-tuples - [ nip check-releases ] - [ create-releases ] - [ update-releases ] - 2tri - ] with-mason-db ; diff --git a/extra/mason/server/server.factor b/extra/mason/server/server.factor index d0fe29b917..26be4df57c 100644 --- a/extra/mason/server/server.factor +++ b/extra/mason/server/server.factor @@ -17,7 +17,8 @@ clean-git-id clean-timestamp last-release release-git-id last-git-id last-timestamp last-report current-git-id current-timestamp -status ; +status +heartbeat-timestamp ; builder "BUILDERS" { { "host-name" "HOST_NAME" TEXT +user-assigned-id+ } @@ -38,6 +39,8 @@ builder "BUILDERS" { ! Can't name it CURRENT_TIMESTAMP because of bug in db library { "current-timestamp" "CURR_TIMESTAMP" TIMESTAMP } { "status" "STATUS" TEXT } + + { "heartbeat-timestamp" "HEARTBEAT_TIMESTAMP" TIMESTAMP } } define-persistent : mason-db ( -- db ) "resource:mason.db" ; diff --git a/extra/mason/source/authors.txt b/extra/mason/source/authors.txt deleted file mode 100644 index d4f5d6b3ae..0000000000 --- a/extra/mason/source/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Slava Pestov \ No newline at end of file diff --git a/extra/mason/source/source.factor b/extra/mason/source/source.factor deleted file mode 100644 index 72c63660e3..0000000000 --- a/extra/mason/source/source.factor +++ /dev/null @@ -1,49 +0,0 @@ -! Copyright (C) 2010 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: bootstrap.image bootstrap.image.download io io.directories -io.directories.hierarchy io.files.unique io.launcher -io.pathnames kernel sequences namespaces mason.common mason.config ; -IN: mason.source - -: clone-factor ( -- ) - { "git" "clone" } home "factor" append-path suffix try-process ; - -: save-git-id ( -- ) - git-id "git-id" to-file ; - -: delete-git-tree ( -- ) - ".git" delete-tree ; - -: download-images ( -- ) - images [ download-image ] each ; - -: prepare-source ( -- ) - "factor" [ save-git-id delete-git-tree download-images ] with-directory ; - -: package-name ( version -- string ) - "factor-src-" ".zip" surround ; - -: make-tarball ( version -- path ) - [ { "zip" "-qr9" } ] dip package-name - [ suffix "factor" suffix try-process ] keep ; - -: make-package ( version -- path ) - unique-directory - [ - clone-factor prepare-source make-tarball - "Package created: " write absolute-path dup print - ] with-directory ; - -: remote-location ( version -- dest ) - [ upload-directory get "/releases/" ] dip 3append ; - -: remote-archive-name ( version -- dest ) - [ remote-location ] [ package-name ] bi "/" glue ; - -: upload-package ( package version -- ) - [ upload-username get upload-host get ] dip - remote-archive-name - upload-safely ; - -: release-source-package ( version -- ) - [ make-package ] [ upload-package ] bi ; diff --git a/extra/mason/version/authors.txt b/extra/mason/version/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/extra/mason/version/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/extra/mason/version/binary/authors.txt b/extra/mason/version/binary/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/extra/mason/version/binary/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/extra/mason/version/binary/binary.factor b/extra/mason/version/binary/binary.factor new file mode 100644 index 0000000000..5273b644ee --- /dev/null +++ b/extra/mason/version/binary/binary.factor @@ -0,0 +1,20 @@ +! Copyright (C) 2010 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: io kernel make mason.version.common mason.version.files +sequences ; +IN: mason.version.binary + +: binary-release-command ( version builder -- command ) + [ + "cp " % + [ nip binary-package-name % " " % ] + [ remote-binary-release-name % ] + 2bi + ] "" make ; + +: binary-release-script ( version builders -- string ) + [ binary-release-command ] with map "\n" join ; + +: do-binary-release ( version builders -- ) + "Copying binary releases to release directory..." print flush + binary-release-script execute-on-server ; diff --git a/extra/mason/version/common/authors.txt b/extra/mason/version/common/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/extra/mason/version/common/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/extra/mason/version/common/common.factor b/extra/mason/version/common/common.factor new file mode 100644 index 0000000000..65d01c3f71 --- /dev/null +++ b/extra/mason/version/common/common.factor @@ -0,0 +1,12 @@ +! Copyright (C) 2010 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors calendar io io.encodings.ascii io.launcher +kernel make mason.config namespaces ; +IN: mason.version.common + +: execute-on-server ( string -- ) + [ "ssh" , upload-host get , "-l" , upload-username get , ] { } make + + swap >>command + 5 minutes >>timeout + ascii [ write ] with-process-writer ; diff --git a/extra/mason/version/data/authors.txt b/extra/mason/version/data/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/extra/mason/version/data/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/extra/mason/version/data/data.factor b/extra/mason/version/data/data.factor new file mode 100644 index 0000000000..eb735c918c --- /dev/null +++ b/extra/mason/version/data/data.factor @@ -0,0 +1,54 @@ +! Copyright (C) 2010 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors calendar db db.tuples db.types kernel locals +mason.version.files sequences ; +IN: mason.version.data + +TUPLE: release +host-name os cpu +last-release release-git-id ; + +release "RELEASES" { + { "host-name" "HOST_NAME" TEXT +user-assigned-id+ } + { "os" "OS" TEXT +user-assigned-id+ } + { "cpu" "CPU" TEXT +user-assigned-id+ } + { "last-release" "LAST_RELEASE" TEXT } + { "release-git-id" "RELEASE_GIT_ID" TEXT } +} define-persistent + +:: ( version builder -- release ) + release new + builder host-name>> >>host-name + builder os>> >>os + builder cpu>> >>cpu + builder release-git-id>> >>release-git-id + version builder binary-release-name >>last-release ; + +: update-binary-releases ( version builders -- ) + [ + release new delete-tuples + [ insert-tuple ] with each + ] with-transaction ; + +TUPLE: version +id version git-id timestamp source-path announcement-url ; + +version "VERSIONS" { + { "id" "ID" INTEGER +db-assigned-id+ } + { "version" "VERSION" TEXT } + { "git-id" "GIT_ID" TEXT } + { "timestamp" "TIMESTAMP" TIMESTAMP } + { "source-path" "SOURCE_PATH" TEXT } + { "announcement-url" "ANNOUNCEMENT_URL" TEXT } +} define-persistent + +: update-version ( version git-id announcement-url -- ) + version new + swap >>announcement-url + swap >>git-id + swap [ >>version ] [ source-release-name >>source-path ] bi + now >>timestamp + insert-tuple ; + +: latest-version ( -- version ) + version new select-tuples last ; diff --git a/extra/mason/version/files/authors.txt b/extra/mason/version/files/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/extra/mason/version/files/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/extra/mason/version/files/files.factor b/extra/mason/version/files/files.factor new file mode 100644 index 0000000000..1335885c3d --- /dev/null +++ b/extra/mason/version/files/files.factor @@ -0,0 +1,39 @@ +! Copyright (C) 2010 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors fry kernel make mason.config mason.platform +mason.release.archive namespaces sequences ; +IN: mason.version.files + +: release-directory ( string version -- string ) + [ "releases/" % % "/" % % ] "" make ; + +: remote-directory ( string -- string' ) + [ upload-directory get ] dip "/" glue ; + +: remote ( string version -- string ) + remote-directory swap "/" glue ; + +: platform ( builder -- string ) + [ os>> ] [ cpu>> ] bi (platform) ; + +: binary-package-name ( builder -- string ) + [ [ platform % "/" % ] [ last-release>> % ] bi ] "" make + remote-directory ; + +: binary-release-name ( version builder -- string ) + [ + [ + [ "factor-" % platform % "-" % % ] + [ os>> extension % ] + bi + ] "" make + ] [ drop ] 2bi release-directory ; + +: remote-binary-release-name ( version builder -- string ) + [ binary-release-name ] [ drop ] 2bi remote ; + +: source-release-name ( version -- string ) + [ "factor-src-" ".zip" surround ] keep release-directory ; + +: remote-source-release-name ( version -- string ) + [ source-release-name ] keep remote ; diff --git a/extra/mason/version/source/authors.txt b/extra/mason/version/source/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/extra/mason/version/source/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/extra/mason/version/source/source.factor b/extra/mason/version/source/source.factor new file mode 100644 index 0000000000..cc41ee3e6b --- /dev/null +++ b/extra/mason/version/source/source.factor @@ -0,0 +1,51 @@ +! Copyright (C) 2010 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: bootstrap.image bootstrap.image.download io +io.directories io.directories.hierarchy io.files.unique +io.launcher io.pathnames kernel mason.common mason.config +mason.version.files namespaces sequences ; +IN: mason.version.source + +: clone-factor ( -- ) + { "git" "clone" "git://factorcode.org/git/factor.git" } try-process ; + +: git-reset ( git-id -- ) + { "git" "reset" "--hard" } swap suffix try-process ; + +: save-git-id ( git-id -- ) + "git-id" to-file ; + +: delete-git-tree ( -- ) + ".git" delete-tree + ".gitignore" delete-file ; + +: download-images ( -- ) + images [ download-image ] each ; + +: prepare-source ( git-id -- ) + "factor" [ + [ git-reset ] [ save-git-id ] bi + delete-git-tree + download-images + ] with-directory ; + +: (make-source-release) ( version -- path ) + [ { "zip" "-qr9" } ] dip source-release-name file-name + [ suffix "factor" suffix try-process ] keep ; + +: make-source-release ( version git-id -- path ) + "Creating source release..." print flush + unique-directory + [ + clone-factor prepare-source (make-source-release) + "Package created: " write absolute-path dup print + ] with-directory ; + +: upload-source-release ( package version -- ) + "Uploading source release..." print flush + [ upload-username get upload-host get ] dip + remote-source-release-name + upload-safely ; + +: do-source-release ( version git-id -- ) + [ make-source-release ] [ drop upload-source-release ] 2bi ; diff --git a/extra/mason/version/version.factor b/extra/mason/version/version.factor new file mode 100644 index 0000000000..a2093124f7 --- /dev/null +++ b/extra/mason/version/version.factor @@ -0,0 +1,52 @@ +! Copyright (C) 2010 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors bit.ly combinators db.tuples debugger fry +grouping io io.streams.string kernel locals make mason.email +mason.server mason.twitter mason.version.binary +mason.version.common mason.version.data mason.version.files +mason.version.source sequences threads ; +IN: mason.version + +: check-releases ( builders -- ) + [ release-git-id>> ] map all-equal? + [ "Some builders are out of date" throw ] unless ; + +: make-release-directory ( version -- ) + "Creating release directory..." print flush + [ "mkdir -p " % "" release-directory % "\n" % ] "" make + execute-on-server ; + +: tweet-release ( version announcement-url -- ) + [ + "Factor " % + [ % " released -- " % ] [ shorten-url % ] bi* + ] "" make mason-tweet ; + +:: (do-release) ( version announcement-url -- ) + [ + builder new select-tuples :> builders + builders first release-git-id>> :> git-id + + builders check-releases + version make-release-directory + version builders do-binary-release + version builders update-binary-releases + version git-id do-source-release + version git-id announcement-url update-version + version announcement-url tweet-release + + "Done." print flush + ] with-mason-db ; + +: send-release-email ( string version -- ) + [ "text/plain" ] dip "Release output: " prepend mason-email ; + +:: do-release ( version announcement-url -- ) + [ + [ + [ + version announcement-url (do-release) + ] try + ] with-string-writer + version send-release-email + ] "Mason release" spawn drop ; diff --git a/extra/webapps/mason/download-package.xml b/extra/webapps/mason/download-package.xml index 7e50f958cd..cff9dbe789 100644 --- a/extra/webapps/mason/download-package.xml +++ b/extra/webapps/mason/download-package.xml @@ -28,6 +28,7 @@ + diff --git a/extra/webapps/mason/downloads.xml b/extra/webapps/mason/downloads.xml new file mode 100644 index 0000000000..82d6572579 --- /dev/null +++ b/extra/webapps/mason/downloads.xml @@ -0,0 +1,22 @@ + + + + + + +

Stable release:

+ +
Host name:
Last heartbeat:
Current status:
Last build:
Last clean build:
+ +
+ +

Source code:

+ +

Development release

+ + + +
+ + diff --git a/extra/webapps/mason/downloads/authors.txt b/extra/webapps/mason/downloads/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/extra/webapps/mason/downloads/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/extra/webapps/mason/downloads/downloads.factor b/extra/webapps/mason/downloads/downloads.factor new file mode 100644 index 0000000000..7ff9e64f6b --- /dev/null +++ b/extra/webapps/mason/downloads/downloads.factor @@ -0,0 +1,25 @@ +! Copyright (C) 2010 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors furnace.actions html.components html.forms +kernel mason.server mason.version.data webapps.mason.grids +webapps.mason.utils ; +IN: webapps.mason.downloads + +: stable-release ( version -- link ) + [ version>> ] [ announcement-url>> ] bi ; + +: source-release ( version -- link ) + [ version>> ] [ source-path>> download-url ] bi ; + +: ( -- action ) + + [ + [ + package-grid "package-grid" set-value + release-grid "release-grid" set-value + + latest-version + [ stable-release "stable-release" set-value ] + [ source-release "source-release" set-value ] bi + ] with-mason-db + ] >>init ; diff --git a/extra/webapps/mason/grids/grids.factor b/extra/webapps/mason/grids/grids.factor index 86d9ba38b3..d9d12ef745 100644 --- a/extra/webapps/mason/grids/grids.factor +++ b/extra/webapps/mason/grids/grids.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs db.tuples furnace.actions furnace.utilities http.server.responses kernel locals -mason.server mason.server.release sequences splitting urls +mason.server mason.version.data sequences splitting urls webapps.mason.utils xml.syntax xml.writer ; IN: webapps.mason.grids @@ -19,7 +19,6 @@ CONSTANT: oses { "macosx" "Mac OS X" } { "linux" "Linux" } { "freebsd" "FreeBSD" } - { "netbsd" "NetBSD" } { "openbsd" "OpenBSD" } } @@ -36,7 +35,7 @@ CONSTANT: cpus :: render-grid-row ( cpu quot -- xml ) cpu second oses keys [| os | cpu os quot render-grid-cell ] map [XML <-><-> XML] ; - + :: render-grid ( quot -- xml ) render-grid-header cpus [ quot render-grid-row ] map diff --git a/extra/webapps/mason/make-release.xml b/extra/webapps/mason/make-release.xml index f12ba014f2..7143d819ab 100644 --- a/extra/webapps/mason/make-release.xml +++ b/extra/webapps/mason/make-release.xml @@ -11,8 +11,12 @@ - Version: - + + + +
Version:
Announcement URL:
+ +

diff --git a/extra/webapps/mason/make-release/make-release.factor b/extra/webapps/mason/make-release/make-release.factor index 4cc3873d91..c90aaad297 100644 --- a/extra/webapps/mason/make-release/make-release.factor +++ b/extra/webapps/mason/make-release/make-release.factor @@ -1,8 +1,7 @@ ! Copyright (C) 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors furnace.actions html.forms -http.server.responses mason.server mason.server.release -validators ; +http.server.responses mason.server mason.version validators ; IN: webapps.mason.make-release : ( -- action ) @@ -10,7 +9,7 @@ IN: webapps.mason.make-release [ { { "version" [ v-one-line ] } } validate-params ] >>validate [ [ - "version" value do-release + "version" value "announcement-url" value do-release "OK" "text/html" ] with-mason-db ] >>submit ; diff --git a/extra/webapps/mason/mason.factor b/extra/webapps/mason/mason.factor index e134778fc7..ecb1348532 100644 --- a/extra/webapps/mason/mason.factor +++ b/extra/webapps/mason/mason.factor @@ -3,7 +3,8 @@ USING: accessors furnace.auth furnace.db http.server.dispatchers mason.server webapps.mason.grids webapps.mason.make-release webapps.mason.package -webapps.mason.release webapps.mason.report ; +webapps.mason.release webapps.mason.report +webapps.mason.downloads ; IN: webapps.mason TUPLE: mason-app < dispatcher ; @@ -21,19 +22,16 @@ can-make-releases? define-capability { mason-app "download-package" } >>template "package" add-responder - - "packages" add-responder - { mason-app "download-release" } >>template "release" add-responder - - "releases" add-responder + + { mason-app "downloads" } >>template + "downloads" add-responder { mason-app "make-release" } >>template - "make releases" >>description { can-make-releases? } >>capabilities diff --git a/extra/webapps/mason/package/package.factor b/extra/webapps/mason/package/package.factor index d1ed03cbf4..5c36a7f23a 100644 --- a/extra/webapps/mason/package/package.factor +++ b/extra/webapps/mason/package/package.factor @@ -2,8 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays combinators furnace.actions html.forms kernel mason.platform mason.report mason.server present -sequences webapps.mason webapps.mason.report -webapps.mason.utils xml.syntax ; +sequences webapps.mason webapps.mason.report webapps.mason.utils +xml.syntax ; +FROM: mason.version.files => platform ; IN: webapps.mason.package : building ( builder string -- xml ) @@ -31,7 +32,7 @@ IN: webapps.mason.package over [ [ git-link ] [ present ] bi* " (built on " ")" surround 2array ] [ 2drop f ] if ; : packages-url ( builder -- url ) - [ os>> ] [ cpu>> ] bi (platform) "http://downloads.factorcode.org/" prepend ; + platform download-url ; : package-link ( builder -- xml ) [ packages-url ] [ last-release>> ] bi [ "/" glue ] keep link ; @@ -40,7 +41,7 @@ IN: webapps.mason.package packages-url dup link ; : clean-image-url ( builder -- url ) - [ os>> ] [ cpu>> ] bi (platform) "http://factorcode.org/images/clean/" prepend ; + platform "http://factorcode.org/images/clean/" prepend ; : clean-image-link ( builder -- link ) clean-image-url dup link ; @@ -65,6 +66,7 @@ IN: webapps.mason.package [ current-status "status" set-value ] [ last-build-status "last-build" set-value ] [ clean-build-status "last-clean-build" set-value ] + [ heartbeat-timestamp>> "heartbeat-timestamp" set-value ] [ packages-link "binaries" set-value ] [ clean-image-link "clean-images" set-value ] [ report-link "last-report" set-value ] diff --git a/extra/webapps/mason/release/release.factor b/extra/webapps/mason/release/release.factor index a7c0f71154..98fa42b68c 100644 --- a/extra/webapps/mason/release/release.factor +++ b/extra/webapps/mason/release/release.factor @@ -6,8 +6,7 @@ webapps.mason.utils io.pathnames ; IN: webapps.mason.release : release-link ( builder -- xml ) - [ "http://downloads.factorcode.org/" ] dip - last-release>> [ "/" glue ] [ file-name ] bi link ; + last-release>> [ download-url ] [ file-name ] bi link ; : ( -- action ) diff --git a/extra/webapps/mason/utils/utils.factor b/extra/webapps/mason/utils/utils.factor index 8197cce820..ad56737bc1 100644 --- a/extra/webapps/mason/utils/utils.factor +++ b/extra/webapps/mason/utils/utils.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs db.tuples furnace.actions -html.forms kernel mason.server mason.server.release sequences +html.forms kernel mason.server mason.version.data sequences validators xml.syntax ; IN: webapps.mason.utils @@ -38,3 +38,6 @@ IN: webapps.mason.utils ] [ drop f ] if ] bi 2array sift [ [XML
  • <->
  • XML] ] map [XML
      <->
    XML] ; + +: download-url ( string -- string' ) + "http://downloads.factorcode.org/" prepend ; From 81c1e9fcb49df30e1c260b7c09a511f0c15caf06 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 13 Apr 2010 02:30:31 -0700 Subject: [PATCH 659/713] Playing around with a higher-level CUDA api. Also, changed some char* to c-string in cuda.ffi --- extra/cuda/authors.txt | 1 + extra/cuda/cuda-tests.factor | 7 ++++ extra/cuda/cuda.factor | 77 ++++++++++++++++++++++++++++++++++++ extra/cuda/ffi/ffi.factor | 4 +- 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 extra/cuda/authors.txt create mode 100644 extra/cuda/cuda-tests.factor create mode 100644 extra/cuda/cuda.factor diff --git a/extra/cuda/authors.txt b/extra/cuda/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/extra/cuda/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/extra/cuda/cuda-tests.factor b/extra/cuda/cuda-tests.factor new file mode 100644 index 0000000000..28fe222dff --- /dev/null +++ b/extra/cuda/cuda-tests.factor @@ -0,0 +1,7 @@ +! Copyright (C) 2010 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: cuda kernel tools.test ; +IN: cuda.tests + +! [ ] [ [ 0 0 [ drop ] with-cuda-context ] with-cuda ] unit-test +! [ ] [ 100 cuda-malloc cuda-free ] unit-test diff --git a/extra/cuda/cuda.factor b/extra/cuda/cuda.factor new file mode 100644 index 0000000000..887740d542 --- /dev/null +++ b/extra/cuda/cuda.factor @@ -0,0 +1,77 @@ +! Copyright (C) 2010 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: alien.c-types alien.data assocs classes.struct +combinators continuations cuda.ffi fry io.backend kernel +sequences ; +IN: cuda + +ERROR: throw-cuda-error n ; + +: cuda-error ( n -- ) + { + { CUDA_SUCCESS [ ] } + [ throw-cuda-error ] + } case ; + +: cuda-version ( -- n ) + int [ cuDriverGetVersion cuda-error ] keep *int ; + +: init-cuda ( -- ) + 0 cuInit cuda-error ; + +: with-cuda ( quot -- ) + init-cuda [ ] [ ] cleanup ; inline + + [ cuDeviceGetCount cuda-error ] keep *int ; + +: n>cuda-device ( n -- device ) + [ CUdevice ] dip [ cuDeviceGet cuda-error ] 2keep drop *int ; + +: enumerate-cuda-devices ( -- devices ) + #cuda-devices iota [ n>cuda-device ] map ; + +: cuda-device>properties ( device -- properties ) + [ CUdevprop ] dip + [ cuDeviceGetProperties cuda-error ] 2keep drop + CUdevprop memory>struct ; + +: cuda-device-properties ( -- properties ) + enumerate-cuda-devices [ cuda-device>properties ] map ; + +PRIVATE> + +: cuda-devices ( -- assoc ) + enumerate-cuda-devices [ dup cuda-device>properties ] { } map>assoc ; + +: with-cuda-context ( flags device quot -- ) + [ + [ CUcontext ] 2dip + [ cuCtxCreate cuda-error ] 3keep 2drop *void* + ] dip + [ '[ _ @ ] ] + [ drop '[ _ cuCtxDestroy cuda-error ] ] 2bi + [ ] cleanup ; inline + +: with-cuda-module ( path quot -- ) + [ + normalize-path + [ CUmodule ] dip + [ cuModuleLoad cuda-error ] 2keep drop *void* + ] dip + [ '[ _ @ ] ] + [ drop '[ _ cuModuleUnload cuda-error ] ] 2bi + [ ] cleanup ; inline + +: get-cuda-function ( module string -- function ) + [ CUfunction ] 2dip + [ cuModuleGetFunction cuda-error ] 3keep 2drop *void* ; + +: cuda-malloc ( n -- ptr ) + [ CUdeviceptr ] dip + [ cuMemAlloc cuda-error ] 2keep drop *int ; + +: cuda-free ( ptr -- ) + cuMemFree cuda-error ; diff --git a/extra/cuda/ffi/ffi.factor b/extra/cuda/ffi/ffi.factor index ce6f8cb8b8..3d41f1e4c5 100644 --- a/extra/cuda/ffi/ffi.factor +++ b/extra/cuda/ffi/ffi.factor @@ -307,12 +307,12 @@ FUNCTION: CUresult cuCtxPopCurrent ( CUcontext* pctx ) ; FUNCTION: CUresult cuCtxGetDevice ( CUdevice* device ) ; FUNCTION: CUresult cuCtxSynchronize ( ) ; -FUNCTION: CUresult cuModuleLoad ( CUmodule* module, char* fname ) ; +FUNCTION: CUresult cuModuleLoad ( CUmodule* module, c-string fname ) ; FUNCTION: CUresult cuModuleLoadData ( CUmodule* module, void* image ) ; FUNCTION: CUresult cuModuleLoadDataEx ( CUmodule* module, void* image, uint numOptions, CUjit_option* options, void** optionValues ) ; FUNCTION: CUresult cuModuleLoadFatBinary ( CUmodule* module, void* fatCubin ) ; FUNCTION: CUresult cuModuleUnload ( CUmodule hmod ) ; -FUNCTION: CUresult cuModuleGetFunction ( CUfunction* hfunc, CUmodule hmod, char* name ) ; +FUNCTION: CUresult cuModuleGetFunction ( CUfunction* hfunc, CUmodule hmod, c-string name ) ; FUNCTION: CUresult cuModuleGetGlobal ( CUdeviceptr* dptr, uint* bytes, CUmodule hmod, char* name ) ; FUNCTION: CUresult cuModuleGetTexRef ( CUtexref* pTexRef, CUmodule hmod, char* name ) ; From 3e91a7f280c4f22889e2dddee6778cc9f56f6b85 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 04:43:29 -0700 Subject: [PATCH 660/713] sets: fix performance regression in all-unique? word --- core/hash-sets/hash-sets.factor | 17 +++++++++++++---- core/sets/sets.factor | 3 --- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/core/hash-sets/hash-sets.factor b/core/hash-sets/hash-sets.factor index b4bf9a1aef..3ca2cce93c 100644 --- a/core/hash-sets/hash-sets.factor +++ b/core/hash-sets/hash-sets.factor @@ -16,13 +16,22 @@ M: hash-set in? table>> key? ; inline M: hash-set adjoin table>> dupd set-at ; inline M: hash-set delete table>> delete-at ; inline M: hash-set members table>> keys ; inline -M: hash-set set-like - drop dup hash-set? [ members ] unless ; -M: hash-set clone - table>> clone hash-set boa ; +M: hash-set set-like drop dup hash-set? [ members ] unless ; +M: hash-set clone table>> clone hash-set boa ; M: sequence fast-set ; M: f fast-set drop H{ } clone hash-set boa ; M: sequence duplicates f fast-set [ [ in? ] [ adjoin ] 2bi ] curry filter ; + + + +M: sequence all-unique? + dup length hash-set boa + [ (all-unique?) ] curry all? ; diff --git a/core/sets/sets.factor b/core/sets/sets.factor index 3f441f9239..d279f036d4 100644 --- a/core/sets/sets.factor +++ b/core/sets/sets.factor @@ -92,9 +92,6 @@ M: sequence set-like M: sequence members [ pruned ] keep like ; -M: sequence all-unique? - dup pruned sequence= ; - : combine ( sets -- set ) [ f ] [ [ [ members ] map concat ] [ first ] bi set-like ] From 572b71238ffdfff34d00ad2123520478250fb515 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 05:24:49 -0700 Subject: [PATCH 661/713] stack-checker: calling 'dispatch' with unbalanced branches generated an error message that erroneously talked about 'if' --- basis/stack-checker/branches/branches.factor | 26 ++++++++++--------- .../row-polymorphism/row-polymorphism.factor | 3 +-- .../stack-checker/stack-checker-tests.factor | 5 ++++ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/basis/stack-checker/branches/branches.factor b/basis/stack-checker/branches/branches.factor index 6f8d503c05..77e983eefb 100644 --- a/basis/stack-checker/branches/branches.factor +++ b/basis/stack-checker/branches/branches.factor @@ -1,9 +1,10 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov, Joe Groff. ! See http://factorcode.org/license.txt for BSD license. USING: arrays effects fry vectors sequences assocs math math.order accessors kernel combinators quotations namespaces grouping locals stack-checker.state stack-checker.backend stack-checker.errors stack-checker.visitor stack-checker.values stack-checker.recursive-state ; +FROM: sequences.private => dispatch ; IN: stack-checker.branches : balanced? ( pairs -- ? ) @@ -43,10 +44,9 @@ SYMBOLS: +bottom+ +top+ ; : phi-outputs ( phi-in -- stack ) flip [ unify-values ] map ; -SYMBOL: quotations +SYMBOLS: combinator quotations ; -: simple-unbalanced-branches-error ( branches quots -- * ) - [ \ if ] 2dip swap +: simple-unbalanced-branches-error ( word quots branches -- * ) [ length [ (( ..a -- ..b )) ] replicate ] [ [ length [ "x" ] bi@ ] { } assoc>map ] bi unbalanced-branches-error ; @@ -54,9 +54,10 @@ SYMBOL: quotations : unify-branches ( ins stacks -- in phi-in phi-out ) zip [ 0 { } { } ] [ [ keys supremum ] [ ] [ balanced? ] tri - [ dupd phi-inputs dup phi-outputs ] - [ quotations get simple-unbalanced-branches-error ] - if + [ dupd phi-inputs dup phi-outputs ] [ + [ combinator get quotations get ] dip + simple-unbalanced-branches-error + ] if ] if-empty ; : branch-variable ( seq symbol -- seq ) @@ -125,13 +126,13 @@ M: curried curried/composed? drop t ; M: composed curried/composed? drop t ; M: declared-effect curried/composed? known>> curried/composed? ; -:: declare-if-effects ( -- ) - H{ } clone :> variables - V{ } clone :> branches - \ if (( ..a -- ..b )) variables branches 0 declare-effect-d - \ if (( ..a -- ..b )) variables branches 1 declare-effect-d ; +: declare-if-effects ( -- ) + H{ } clone V{ } clone + [ [ \ if (( ..a -- ..b )) ] 2dip 0 declare-effect-d ] + [ [ \ if (( ..a -- ..b )) ] 2dip 1 declare-effect-d ] 2bi ; : infer-if ( -- ) + \ if combinator set 2 literals-available? [ (infer-if) ] [ @@ -148,5 +149,6 @@ M: declared-effect curried/composed? known>> curried/composed? ; ] if ; : infer-dispatch ( -- ) + \ dispatch combinator set pop-literal nip infer-branches [ #dispatch, ] dip compute-phi-function ; diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index 1b8bd8faed..ad4f92ced4 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -24,7 +24,7 @@ IN: stack-checker.row-polymorphism [ with-inner-d ] 2dip (effect-here) ; inline : (diff-variable) ( diff variable vars -- diff' ) - [ at* nip ] [ '[ _ _ at - ] ] [ '[ _ _ set-at 0 ] ] 2tri if ; + [ key? ] [ '[ _ _ at - ] ] [ '[ _ _ set-at 0 ] ] 2tri if ; : (check-variable) ( actual-count declared-count variable vars -- diff ? ) [ - ] 2dip dupd '[ _ _ (diff-variable) t ] [ dup 0 <= ] if ; @@ -63,4 +63,3 @@ IN: stack-checker.row-polymorphism [ >>actual ] keep 2dup [ [ variables>> ] [ effect>> ] bi ] dip check-variables [ 2drop ] [ drop combinator-unbalanced-branches-error ] if ; - diff --git a/basis/stack-checker/stack-checker-tests.factor b/basis/stack-checker/stack-checker-tests.factor index ce2c03264b..351cf5cde0 100644 --- a/basis/stack-checker/stack-checker-tests.factor +++ b/basis/stack-checker/stack-checker-tests.factor @@ -252,6 +252,11 @@ DEFER: blah4 ! A typo { 1 0 } [ { [ ] } dispatch ] must-infer-as +! Make sure the error is correct +[ + [ { [ drop ] [ dup ] } dispatch ] infer +] [ word>> \ dispatch eq? ] must-fail-with + DEFER: inline-recursive-2 : inline-recursive-1 ( -- ) inline-recursive-2 ; : inline-recursive-2 ( -- ) inline-recursive-1 ; From a47db60a745c7570964f95f12a0e10df2273ef8c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 05:25:13 -0700 Subject: [PATCH 662/713] mason.server.notify: fix heartbeat logic --- extra/mason/server/notify/notify.factor | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/extra/mason/server/notify/notify.factor b/extra/mason/server/notify/notify.factor index 3303749c4f..bfa1027d92 100644 --- a/extra/mason/server/notify/notify.factor +++ b/extra/mason/server/notify/notify.factor @@ -25,11 +25,9 @@ SYMBOLS: host-name target-os target-cpu message message-arg ; target-cpu get >>cpu dup select-tuple [ ] [ dup insert-tuple ] ?if ; -: heartbeat ( -- ) - now >>heartbeat-timestamp ; +: heartbeat ( builder -- ) now >>heartbeat-timestamp drop ; -: git-id ( builder id -- ) - >>current-git-id +starting+ >>status drop ; +: git-id ( builder id -- ) >>current-git-id +starting+ >>status drop ; : make-vm ( builder -- ) +make-vm+ >>status drop ; From a3e6de5e6a7422f780426f73808c2eac6ec2f7d1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 06:14:53 -0700 Subject: [PATCH 663/713] io.files: fix unit test for forget-tests? flag --- core/io/files/files-tests.factor | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/io/files/files-tests.factor b/core/io/files/files-tests.factor index 5db1822d9e..a308b9f0c3 100644 --- a/core/io/files/files-tests.factor +++ b/core/io/files/files-tests.factor @@ -3,7 +3,9 @@ debugger.threads destructors generic.single io io.directories io.encodings.8-bit.latin1 io.encodings.ascii io.encodings.binary io.encodings.string io.files io.files.private io.files.temp io.files.unique kernel make math -sequences specialized-arrays system threads tools.test ; +sequences specialized-arrays system threads tools.test vocabs +compiler.units ; +FROM: specialized-arrays.private => specialized-array-vocab ; SPECIALIZED-ARRAY: int IN: io.files.tests @@ -119,6 +121,12 @@ CONSTANT: pt-array-1 pt-array-1 rest-slice sequence= ] unit-test +[ ] [ + [ + pt specialized-array-vocab forget-vocab + ] with-compilation-unit +] unit-test + ! Writing strings to binary streams should fail [ "test.txt" temp-file binary [ From f652ee2b02b0a364901954e0272bc4fd84ed71f6 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 06:15:08 -0700 Subject: [PATCH 664/713] classes.struct.vectored: fix unit test for forget-tests? flag --- extra/classes/struct/vectored/vectored-tests.factor | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/extra/classes/struct/vectored/vectored-tests.factor b/extra/classes/struct/vectored/vectored-tests.factor index 1b3aa86eff..4d083faa5d 100644 --- a/extra/classes/struct/vectored/vectored-tests.factor +++ b/extra/classes/struct/vectored/vectored-tests.factor @@ -1,6 +1,7 @@ ! (c)2009 Joe Groff bsd license USING: accessors alien.c-types classes.struct classes.struct.vectored -kernel sequences specialized-arrays tools.test ; +kernel sequences specialized-arrays tools.test vocabs compiler.units ; +FROM: specialized-arrays.private => specialized-array-vocab ; SPECIALIZED-ARRAYS: int ushort float ; IN: classes.struct.vectored.tests @@ -71,3 +72,9 @@ VECTORED-STRUCT: foo { w ushort-array{ 15 25 35 45 } } } third vectored-element> ] unit-test + +[ ] [ + [ + foo specialized-array-vocab forget-vocab + ] with-compilation-unit +] unit-test From 74075511c21f6ccc6f9e5959e8ce4ef1861902e9 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 06:16:45 -0700 Subject: [PATCH 665/713] ui.tools.error-list: smaller default size --- basis/ui/tools/error-list/error-list.factor | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/basis/ui/tools/error-list/error-list.factor b/basis/ui/tools/error-list/error-list.factor index 34a5221307..eaa947b2d6 100644 --- a/basis/ui/tools/error-list/error-list.factor +++ b/basis/ui/tools/error-list/error-list.factor @@ -66,8 +66,8 @@ M: source-file-renderer filled-column drop 1 ; [ invoke-primary-operation ] >>action COLOR: dark-gray >>column-line-color 6 >>gap - 5 >>min-rows - 5 >>max-rows + 4 >>min-rows + 4 >>max-rows 60 >>min-cols 60 >>max-cols t >>selection-required? @@ -115,8 +115,8 @@ M: error-renderer column-alignment drop { 0 1 0 0 } ; [ invoke-primary-operation ] >>action COLOR: dark-gray >>column-line-color 6 >>gap - 5 >>min-rows - 5 >>max-rows + 4 >>min-rows + 4 >>max-rows 60 >>min-cols 60 >>max-cols t >>selection-required? From 017f772c4844d58d6d19d85f3eba8c49b2b66a53 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Tue, 13 Apr 2010 17:58:45 -0700 Subject: [PATCH 666/713] Macho version of nm and testcase for it. --- extra/elf/nm/nm-tests.factor | 62 ++++++++-------- extra/elf/nm/nm.factor | 4 +- extra/macho/a.macho | Bin 0 -> 8792 bytes extra/macho/macho-tests.factor | 26 +++++++ extra/macho/macho.factor | 128 ++++++++++++++++++++++++++++++++- 5 files changed, 186 insertions(+), 34 deletions(-) create mode 100755 extra/macho/a.macho create mode 100644 extra/macho/macho-tests.factor diff --git a/extra/elf/nm/nm-tests.factor b/extra/elf/nm/nm-tests.factor index 2ecb499081..9e529ae43d 100644 --- a/extra/elf/nm/nm-tests.factor +++ b/extra/elf/nm/nm-tests.factor @@ -6,46 +6,46 @@ IN: elf.nm.tests STRING: validation-output 0000000000000000 absolute init.c -0000000004195436 .text call_gmon_start +000000000040046c .text call_gmon_start 0000000000000000 absolute crtstuff.c -0000000006295064 .ctors __CTOR_LIST__ -0000000006295080 .dtors __DTOR_LIST__ -0000000006295096 .jcr __JCR_LIST__ -0000000004195472 .text __do_global_dtors_aux -0000000006295584 .bss completed.7342 -0000000006295592 .bss dtor_idx.7344 -0000000004195584 .text frame_dummy +0000000000600e18 .ctors __CTOR_LIST__ +0000000000600e28 .dtors __DTOR_LIST__ +0000000000600e38 .jcr __JCR_LIST__ +0000000000400490 .text __do_global_dtors_aux +0000000000601020 .bss completed.7342 +0000000000601028 .bss dtor_idx.7344 +0000000000400500 .text frame_dummy 0000000000000000 absolute crtstuff.c -0000000006295072 .ctors __CTOR_END__ -0000000004196056 .eh_frame __FRAME_END__ -0000000006295096 .jcr __JCR_END__ -0000000004195808 .text __do_global_ctors_aux +0000000000600e20 .ctors __CTOR_END__ +00000000004006d8 .eh_frame __FRAME_END__ +0000000000600e38 .jcr __JCR_END__ +00000000004005e0 .text __do_global_ctors_aux 0000000000000000 absolute test.c -0000000006295528 .got.plt _GLOBAL_OFFSET_TABLE_ -0000000006295060 .ctors __init_array_end -0000000006295060 .ctors __init_array_start -0000000006295104 .dynamic _DYNAMIC -0000000006295568 .data data_start +0000000000600fe8 .got.plt _GLOBAL_OFFSET_TABLE_ +0000000000600e14 .ctors __init_array_end +0000000000600e14 .ctors __init_array_start +0000000000600e40 .dynamic _DYNAMIC +0000000000601010 .data data_start 0000000000000000 undefined printf@@GLIBC_2.2.5 -0000000004195648 .text __libc_csu_fini -0000000004195392 .text _start +0000000000400540 .text __libc_csu_fini +0000000000400440 .text _start 0000000000000000 undefined __gmon_start__ 0000000000000000 undefined _Jv_RegisterClasses -0000000004195864 .fini _fini +0000000000400618 .fini _fini 0000000000000000 undefined __libc_start_main@@GLIBC_2.2.5 -0000000004195880 .rodata _IO_stdin_used -0000000006295568 .data __data_start -0000000006295576 .data __dso_handle -0000000006295088 .dtors __DTOR_END__ -0000000004195664 .text __libc_csu_init -0000000006295584 absolute __bss_start -0000000006295600 absolute _end -0000000006295584 absolute _edata -0000000004195620 .text main -0000000004195312 .init _init +0000000000400628 .rodata _IO_stdin_used +0000000000601010 .data __data_start +0000000000601018 .data __dso_handle +0000000000600e30 .dtors __DTOR_END__ +0000000000400550 .text __libc_csu_init +0000000000601020 absolute __bss_start +0000000000601030 absolute _end +0000000000601020 absolute _edata +0000000000400524 .text main +00000000004003f0 .init _init ; { $ validation-output } -[ dup [ "resource:extra/elf/a.elf" nm ] with-output-stream >string ] +[ dup [ "resource:extra/elf/a.elf" elf-nm ] with-output-stream >string ] unit-test diff --git a/extra/elf/nm/nm.factor b/extra/elf/nm/nm.factor index 87c9abf00b..52e1c66902 100644 --- a/extra/elf/nm/nm.factor +++ b/extra/elf/nm/nm.factor @@ -4,7 +4,7 @@ USING: accessors combinators elf formatting io.mmap kernel sequences ; IN: elf.nm : print-symbol ( sections symbol -- ) - [ sym>> st_value>> "%016d " printf ] + [ sym>> st_value>> "%016x " printf ] [ sym>> st_shndx>> { @@ -16,7 +16,7 @@ IN: elf.nm ] [ name>> "%s\n" printf ] tri ; -: nm ( path -- ) +: elf-nm ( path -- ) [ sections dup ".symtab" find-section symbols [ name>> empty? not ] filter diff --git a/extra/macho/a.macho b/extra/macho/a.macho new file mode 100755 index 0000000000000000000000000000000000000000..bc233d70958e9d5652303936e0c97bd425b1f405 GIT binary patch literal 8792 zcmeHN-)me&6h1dun^co@+Xs!<=vG=9Y)L9YsbFCv4cX9A*Cv%9%D6vnvMV>c%iX)_ zMkoe?Vvs<<7r_@F{S$oXgH`YcKBy0U5ue0Lf(S)KVjqm(ckj&Z-Q706D89@gGiT1s zoHH}u%)Oa=&VFoDh3Q4KJZ3bEZ>$Z1e1dBoaobE!I>uOO#)>>s0 zl&Y^T=c}Ho2aWvGz4nraB74MzWaLN^8PxXL^P?eEa=n`Cqf__%j%s_ywE@Z<)HA#xgmNNou&b<;TT+XD zZrP0*y65+iwwKjxgghW?Z&U9?WJ@V%JF?@YeuE^bAM^}^2O;3v*wwFfsTEEOj^*3!D6zr^HokntxA$eQ3Z!#(*HGSBoU$3)%-$2pNK5{Z47IMzWVv*#%G z(1*}xziz^7Asm;_^<<;&PkQD2WO3Ci>W+_ra~@uDXLjc6&%YdcZ*KC<;qM>j9(;_% zF`q*EzsbDs{%IcJdmWv)CSoTCiON8G?O1<3C>Bngnm9WF9Ljli(*F;@jh-XdAvqm- zbF1~hU7mP8u18%<76FTZMZh9p5wHkY1paLVUYE?q?aca5cQWr@AIxkvk{fr|KXq>Y z*q?EJ%WQo2OCqy=b1<|1tTg^$X?qY8*!W_bSKHsOQg!qEd6apblWkrkzxqt}PV_l~ zJc0bu=Gbl2PR;F|xCOpdLMA&u@9piCc%9n$fhE`Ts;O&L-zz@IW~j+g%~P5m2M_OD z;7Q!ONzdu@C%%VBlzAT?LOvQ=5!oFPhu@o^!?a0q-pF1NrmLj!|b98yjr zah!3?iS!67NnD7GB;W2!(EPCZPG!@6bXtG6oz;B5z8t}PU(~QZ%1zDJG~Z9(wpj!$ z0u}*_fJML}U=gqgSOhEr76FTZMZhBP-y(20t(017HWk9v^=c*Om4j8aaz dup [ "resource:extra/macho/a.macho" macho-nm ] with-output-stream >string ] +unit-test diff --git a/extra/macho/macho.factor b/extra/macho/macho.factor index e3765260bb..b18ea57ce5 100644 --- a/extra/macho/macho.factor +++ b/extra/macho/macho.factor @@ -1,8 +1,13 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http:// factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.syntax classes.struct kernel literals math ; +USING: accessors alien alien.c-types alien.strings alien.syntax +classes classes.struct combinators io.encodings.ascii +io.encodings.string kernel literals make math sequences +specialized-arrays typed fry io.mmap formatting locals ; +FROM: alien.c-types => short ; IN: macho +! FFI data TYPEDEF: int integer_t TYPEDEF: int vm_prot_t TYPEDEF: integer_t cpu_type_t @@ -804,3 +809,124 @@ C-ENUM: reloc_type_ppc PPC_RELOC_JBSR PPC_RELOC_LO14_SECTDIFF PPC_RELOC_LOCAL_SECTDIFF ; + +! Low-level interface +SPECIALIZED-ARRAYS: section section_64 nlist nlist_64 ; +UNION: mach_header_32/64 mach_header mach_header_64 ; +UNION: segment_command_32/64 segment_command segment_command_64 ; +UNION: load-command segment_command segment_command_64 + dylib_command sub_framework_command + sub_client_command sub_umbrella_command sub_library_command + prebound_dylib_command dylinker_command thread_command + routines_command routines_command_64 symtab_command + dysymtab_command twolevel_hints_command uuid_command ; +UNION: section_32/64 section section_64 ; +UNION: section_32/64-array section-array section_64-array ; +UNION: nlist_32/64 nlist nlist_64 ; +UNION: nlist_32/64-array nlist-array nlist_64-array ; + +TYPED: 64-bit? ( macho: mach_header_32/64 -- ? ) + magic>> { + { MH_MAGIC_64 [ t ] } + { MH_CIGAM_64 [ t ] } + [ drop f ] + } case ; + +TYPED: macho-header ( c-ptr -- macho: mach_header_32/64 ) + dup mach_header_64 memory>struct 64-bit? + [ mach_header_64 memory>struct ] + [ mach_header memory>struct ] if ; + +: cmd>load-command ( cmd -- load-command ) + { + { LC_UUID [ uuid_command ] } + { LC_SEGMENT [ segment_command ] } + { LC_SEGMENT_64 [ segment_command_64 ] } + { LC_SYMTAB [ symtab_command ] } + { LC_DYSYMTAB [ dysymtab_command ] } + { LC_THREAD [ thread_command ] } + { LC_UNIXTHREAD [ thread_command ] } + { LC_LOAD_DYLIB [ dylib_command ] } + { LC_ID_DYLIB [ dylib_command ] } + { LC_PREBOUND_DYLIB [ prebound_dylib_command ] } + { LC_LOAD_DYLINKER [ dylinker_command ] } + { LC_ID_DYLINKER [ dylinker_command ] } + { LC_ROUTINES [ routines_command ] } + { LC_ROUTINES_64 [ routines_command_64 ] } + { LC_TWOLEVEL_HINTS [ twolevel_hints_command ] } + { LC_SUB_FRAMEWORK [ sub_framework_command ] } + { LC_SUB_UMBRELLA [ sub_umbrella_command ] } + { LC_SUB_LIBRARY [ sub_library_command ] } + { LC_SUB_CLIENT [ sub_client_command ] } + { LC_DYLD_INFO [ dyld_info_command ] } + { LC_DYLD_INFO_ONLY [ dyld_info_command ] } + } case ; + +: read-command ( cmd -- next-cmd ) + dup load_command memory>struct + [ cmd>> cmd>load-command memory>struct , ] + [ cmdsize>> swap ] 2bi ; + +TYPED: load-commands ( macho: mach_header_32/64 -- load-commands ) + [ + [ class heap-size ] + [ >c-ptr ] + [ ncmds>> ] tri iota [ + drop read-command + ] each drop + ] { } make ; + +: segment-commands ( load-commands -- segment-commands ) + [ segment_command_32/64? ] filter ; inline + +: symtab-commands ( load-commands -- segment-commands ) + [ symtab_command? ] filter ; inline + +: read-array-string ( uchar-array -- string ) + ascii decode [ 0 = not ] filter ; + +: segment-sections ( segment-command -- sections ) + { + [ class heap-size ] + [ >c-ptr ] + [ nsects>> ] + [ segment_command_64? ] + } cleave + [ ] + [ ] if ; + +: sections-array ( segment-commands -- sections-array ) + [ + dup first segment_command_64? + [ section_64 ] [ section ] if , + segment-commands [ segment-sections [ , ] each ] each + ] { } make ; + +: symbols ( mach-header symtab-command -- symbols string-table ) + [ symoff>> swap >c-ptr ] + [ nsyms>> swap 64-bit? + [ ] + [ ] if ] + [ stroff>> swap >c-ptr ] 2tri ; + +: symbol-name ( symbol string-table -- name ) + [ n_strx>> ] dip ascii alien>string ; + +: with-mapped-macho ( path quot -- ) + '[ + address>> macho-header @ + ] with-mapped-file ; inline + +: macho-nm ( path -- ) + [| macho | + macho load-commands segment-commands sections-array :> sections + + macho load-commands symtab-commands [| symtab | + macho symtab symbols [ + [ drop n_value>> "%016x " printf ] + [ drop n_sect>> sections nth sectname>> + read-array-string "%-16s" printf ] + [ symbol-name "%s\n" printf ] 2tri + ] curry each + ] each + ] with-mapped-macho ; From da6bcbedfc50a941b070fcd58af9e95e1c1b6598 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 18:43:01 -0700 Subject: [PATCH 667/713] Replace 'untested' tag with 'not loaded' and 'not tested' tags --- basis/bootstrap/compiler/timing/tags.txt | 2 +- basis/cpu/ppc/linux/tags.txt | 2 +- basis/cpu/ppc/macosx/tags.txt | 2 +- basis/cpu/ppc/tags.txt | 2 +- basis/cpu/x86/32/tags.txt | 2 +- basis/cpu/x86/64/tags.txt | 2 +- basis/cpu/x86/64/unix/tags.txt | 2 +- basis/cpu/x86/64/winnt/tags.txt | 2 +- basis/cpu/x86/features/tags.txt | 2 +- basis/cpu/x86/tags.txt | 2 +- basis/editors/editpadlite/tags.txt | 2 +- basis/editors/editpadpro/tags.txt | 2 +- basis/editors/editplus/tags.txt | 2 +- basis/editors/emacs/tags.txt | 2 +- basis/editors/emacs/windows/tags.txt | 2 +- basis/editors/emeditor/tags.txt | 2 +- basis/editors/etexteditor/tags.txt | 2 +- basis/editors/gedit/tags.txt | 2 +- basis/editors/gvim/tags.txt | 2 +- basis/editors/gvim/unix/tags.txt | 2 +- basis/editors/gvim/windows/tags.txt | 2 +- basis/editors/jedit/tags.txt | 2 +- basis/editors/macvim/tags.txt | 2 +- basis/editors/notepad/tags.txt | 2 +- basis/editors/notepad2/tags.txt | 2 +- basis/editors/notepadpp/tags.txt | 2 +- basis/editors/scite/tags.txt | 2 +- basis/editors/ted-notepad/tags.txt | 2 +- basis/editors/textedit/tags.txt | 2 +- basis/editors/textmate/tags.txt | 2 +- basis/editors/textpad/tags.txt | 2 +- basis/editors/textwrangler/tags.txt | 2 +- basis/editors/ultraedit/tags.txt | 2 +- basis/editors/vim/generate-syntax/tags.txt | 1 - basis/editors/vim/tags.txt | 2 +- basis/editors/wordpad/tags.txt | 2 +- basis/math/floats/env/ppc/tags.txt | 2 +- basis/math/floats/env/x86/32/tags.txt | 2 +- basis/math/floats/env/x86/64/tags.txt | 2 +- basis/math/floats/env/x86/tags.txt | 2 +- basis/tools/disassembler/gdb/tags.txt | 2 +- basis/tools/disassembler/udis/tags.txt | 2 +- basis/ui/backend/x11/tags.txt | 2 +- basis/unix/stat/linux/32/tags.txt | 2 +- basis/unix/stat/linux/64/tags.txt | 2 +- basis/unix/stat/netbsd/32/tags.txt | 2 +- basis/unix/stat/netbsd/64/tags.txt | 2 +- basis/unix/types/netbsd/32/tags.txt | 2 +- basis/unix/types/netbsd/64/tags.txt | 2 +- core/vocabs/loader/test/a/tags.txt | 2 +- core/vocabs/loader/test/b/tags.txt | 2 +- core/vocabs/loader/test/c/tags.txt | 2 +- core/vocabs/loader/test/d/tags.txt | 2 +- core/vocabs/loader/test/e/tags.txt | 2 +- core/vocabs/loader/test/f/tags.txt | 2 +- core/vocabs/loader/test/g/tags.txt | 2 +- core/vocabs/loader/test/h/tags.txt | 2 +- core/vocabs/loader/test/i/tags.txt | 2 +- core/vocabs/loader/test/j/tags.txt | 2 +- core/vocabs/loader/test/k/tags.txt | 2 +- core/vocabs/loader/test/l/tags.txt | 2 +- core/vocabs/loader/test/m/tags.txt | 2 +- core/vocabs/loader/test/n/tags.txt | 2 +- core/vocabs/loader/test/o/tags.txt | 2 +- extra/couchdb/tags.txt | 2 +- extra/ecdsa/tags.txt | 2 +- extra/llvm/core/tags.txt | 2 +- extra/llvm/engine/tags.txt | 2 +- extra/llvm/invoker/tags.txt | 2 +- extra/llvm/jit/tags.txt | 2 +- extra/llvm/reader/tags.txt | 2 +- extra/llvm/tags.txt | 2 +- extra/llvm/types/tags.txt | 2 +- extra/llvm/wrappers/tags.txt | 2 +- extra/opencl/ffi/tags.txt | 2 +- extra/opencl/syntax/tags.txt | 2 +- extra/opencl/tags.txt | 2 +- 77 files changed, 76 insertions(+), 77 deletions(-) delete mode 100644 basis/editors/vim/generate-syntax/tags.txt diff --git a/basis/bootstrap/compiler/timing/tags.txt b/basis/bootstrap/compiler/timing/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/bootstrap/compiler/timing/tags.txt +++ b/basis/bootstrap/compiler/timing/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/cpu/ppc/linux/tags.txt b/basis/cpu/ppc/linux/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/cpu/ppc/linux/tags.txt +++ b/basis/cpu/ppc/linux/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/cpu/ppc/macosx/tags.txt b/basis/cpu/ppc/macosx/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/cpu/ppc/macosx/tags.txt +++ b/basis/cpu/ppc/macosx/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/cpu/ppc/tags.txt b/basis/cpu/ppc/tags.txt index 6c8f59c757..f5bb856b53 100644 --- a/basis/cpu/ppc/tags.txt +++ b/basis/cpu/ppc/tags.txt @@ -1,2 +1,2 @@ compiler -untested +not loaded diff --git a/basis/cpu/x86/32/tags.txt b/basis/cpu/x86/32/tags.txt index 50dfc5156e..44629a5876 100644 --- a/basis/cpu/x86/32/tags.txt +++ b/basis/cpu/x86/32/tags.txt @@ -1,2 +1,2 @@ -untested +not loaded compiler diff --git a/basis/cpu/x86/64/tags.txt b/basis/cpu/x86/64/tags.txt index 50dfc5156e..44629a5876 100644 --- a/basis/cpu/x86/64/tags.txt +++ b/basis/cpu/x86/64/tags.txt @@ -1,2 +1,2 @@ -untested +not loaded compiler diff --git a/basis/cpu/x86/64/unix/tags.txt b/basis/cpu/x86/64/unix/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/cpu/x86/64/unix/tags.txt +++ b/basis/cpu/x86/64/unix/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/cpu/x86/64/winnt/tags.txt b/basis/cpu/x86/64/winnt/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/cpu/x86/64/winnt/tags.txt +++ b/basis/cpu/x86/64/winnt/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/cpu/x86/features/tags.txt b/basis/cpu/x86/features/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/cpu/x86/features/tags.txt +++ b/basis/cpu/x86/features/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/cpu/x86/tags.txt b/basis/cpu/x86/tags.txt index 50dfc5156e..44629a5876 100644 --- a/basis/cpu/x86/tags.txt +++ b/basis/cpu/x86/tags.txt @@ -1,2 +1,2 @@ -untested +not loaded compiler diff --git a/basis/editors/editpadlite/tags.txt b/basis/editors/editpadlite/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/editpadlite/tags.txt +++ b/basis/editors/editpadlite/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/editpadpro/tags.txt b/basis/editors/editpadpro/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/editpadpro/tags.txt +++ b/basis/editors/editpadpro/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/editplus/tags.txt b/basis/editors/editplus/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/editplus/tags.txt +++ b/basis/editors/editplus/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/emacs/tags.txt b/basis/editors/emacs/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/emacs/tags.txt +++ b/basis/editors/emacs/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/emacs/windows/tags.txt b/basis/editors/emacs/windows/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/emacs/windows/tags.txt +++ b/basis/editors/emacs/windows/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/emeditor/tags.txt b/basis/editors/emeditor/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/emeditor/tags.txt +++ b/basis/editors/emeditor/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/etexteditor/tags.txt b/basis/editors/etexteditor/tags.txt index 5d77766703..ebb74b4d5f 100755 --- a/basis/editors/etexteditor/tags.txt +++ b/basis/editors/etexteditor/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/gedit/tags.txt b/basis/editors/gedit/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/gedit/tags.txt +++ b/basis/editors/gedit/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/gvim/tags.txt b/basis/editors/gvim/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/gvim/tags.txt +++ b/basis/editors/gvim/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/gvim/unix/tags.txt b/basis/editors/gvim/unix/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/gvim/unix/tags.txt +++ b/basis/editors/gvim/unix/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/gvim/windows/tags.txt b/basis/editors/gvim/windows/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/gvim/windows/tags.txt +++ b/basis/editors/gvim/windows/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/jedit/tags.txt b/basis/editors/jedit/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/jedit/tags.txt +++ b/basis/editors/jedit/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/macvim/tags.txt b/basis/editors/macvim/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/macvim/tags.txt +++ b/basis/editors/macvim/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/notepad/tags.txt b/basis/editors/notepad/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/notepad/tags.txt +++ b/basis/editors/notepad/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/notepad2/tags.txt b/basis/editors/notepad2/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/notepad2/tags.txt +++ b/basis/editors/notepad2/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/notepadpp/tags.txt b/basis/editors/notepadpp/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/notepadpp/tags.txt +++ b/basis/editors/notepadpp/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/scite/tags.txt b/basis/editors/scite/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/scite/tags.txt +++ b/basis/editors/scite/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/ted-notepad/tags.txt b/basis/editors/ted-notepad/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/ted-notepad/tags.txt +++ b/basis/editors/ted-notepad/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/textedit/tags.txt b/basis/editors/textedit/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/textedit/tags.txt +++ b/basis/editors/textedit/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/textmate/tags.txt b/basis/editors/textmate/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/textmate/tags.txt +++ b/basis/editors/textmate/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/textpad/tags.txt b/basis/editors/textpad/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/textpad/tags.txt +++ b/basis/editors/textpad/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/textwrangler/tags.txt b/basis/editors/textwrangler/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/textwrangler/tags.txt +++ b/basis/editors/textwrangler/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/ultraedit/tags.txt b/basis/editors/ultraedit/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/ultraedit/tags.txt +++ b/basis/editors/ultraedit/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/vim/generate-syntax/tags.txt b/basis/editors/vim/generate-syntax/tags.txt deleted file mode 100644 index 5d77766703..0000000000 --- a/basis/editors/vim/generate-syntax/tags.txt +++ /dev/null @@ -1 +0,0 @@ -untested diff --git a/basis/editors/vim/tags.txt b/basis/editors/vim/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/vim/tags.txt +++ b/basis/editors/vim/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/editors/wordpad/tags.txt b/basis/editors/wordpad/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/editors/wordpad/tags.txt +++ b/basis/editors/wordpad/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/math/floats/env/ppc/tags.txt b/basis/math/floats/env/ppc/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/math/floats/env/ppc/tags.txt +++ b/basis/math/floats/env/ppc/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/math/floats/env/x86/32/tags.txt b/basis/math/floats/env/x86/32/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/math/floats/env/x86/32/tags.txt +++ b/basis/math/floats/env/x86/32/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/math/floats/env/x86/64/tags.txt b/basis/math/floats/env/x86/64/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/math/floats/env/x86/64/tags.txt +++ b/basis/math/floats/env/x86/64/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/math/floats/env/x86/tags.txt b/basis/math/floats/env/x86/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/math/floats/env/x86/tags.txt +++ b/basis/math/floats/env/x86/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/tools/disassembler/gdb/tags.txt b/basis/tools/disassembler/gdb/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/tools/disassembler/gdb/tags.txt +++ b/basis/tools/disassembler/gdb/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/tools/disassembler/udis/tags.txt b/basis/tools/disassembler/udis/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/tools/disassembler/udis/tags.txt +++ b/basis/tools/disassembler/udis/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/ui/backend/x11/tags.txt b/basis/ui/backend/x11/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/ui/backend/x11/tags.txt +++ b/basis/ui/backend/x11/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/unix/stat/linux/32/tags.txt b/basis/unix/stat/linux/32/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/unix/stat/linux/32/tags.txt +++ b/basis/unix/stat/linux/32/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/unix/stat/linux/64/tags.txt b/basis/unix/stat/linux/64/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/unix/stat/linux/64/tags.txt +++ b/basis/unix/stat/linux/64/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/unix/stat/netbsd/32/tags.txt b/basis/unix/stat/netbsd/32/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/unix/stat/netbsd/32/tags.txt +++ b/basis/unix/stat/netbsd/32/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/unix/stat/netbsd/64/tags.txt b/basis/unix/stat/netbsd/64/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/unix/stat/netbsd/64/tags.txt +++ b/basis/unix/stat/netbsd/64/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/unix/types/netbsd/32/tags.txt b/basis/unix/types/netbsd/32/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/unix/types/netbsd/32/tags.txt +++ b/basis/unix/types/netbsd/32/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/basis/unix/types/netbsd/64/tags.txt b/basis/unix/types/netbsd/64/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/basis/unix/types/netbsd/64/tags.txt +++ b/basis/unix/types/netbsd/64/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/a/tags.txt b/core/vocabs/loader/test/a/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/a/tags.txt +++ b/core/vocabs/loader/test/a/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/b/tags.txt b/core/vocabs/loader/test/b/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/b/tags.txt +++ b/core/vocabs/loader/test/b/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/c/tags.txt b/core/vocabs/loader/test/c/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/c/tags.txt +++ b/core/vocabs/loader/test/c/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/d/tags.txt b/core/vocabs/loader/test/d/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/d/tags.txt +++ b/core/vocabs/loader/test/d/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/e/tags.txt b/core/vocabs/loader/test/e/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/e/tags.txt +++ b/core/vocabs/loader/test/e/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/f/tags.txt b/core/vocabs/loader/test/f/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/f/tags.txt +++ b/core/vocabs/loader/test/f/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/g/tags.txt b/core/vocabs/loader/test/g/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/g/tags.txt +++ b/core/vocabs/loader/test/g/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/h/tags.txt b/core/vocabs/loader/test/h/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/h/tags.txt +++ b/core/vocabs/loader/test/h/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/i/tags.txt b/core/vocabs/loader/test/i/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/i/tags.txt +++ b/core/vocabs/loader/test/i/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/j/tags.txt b/core/vocabs/loader/test/j/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/j/tags.txt +++ b/core/vocabs/loader/test/j/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/k/tags.txt b/core/vocabs/loader/test/k/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/k/tags.txt +++ b/core/vocabs/loader/test/k/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/l/tags.txt b/core/vocabs/loader/test/l/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/l/tags.txt +++ b/core/vocabs/loader/test/l/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/m/tags.txt b/core/vocabs/loader/test/m/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/m/tags.txt +++ b/core/vocabs/loader/test/m/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/n/tags.txt b/core/vocabs/loader/test/n/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/n/tags.txt +++ b/core/vocabs/loader/test/n/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/core/vocabs/loader/test/o/tags.txt b/core/vocabs/loader/test/o/tags.txt index 5d77766703..ebb74b4d5f 100644 --- a/core/vocabs/loader/test/o/tags.txt +++ b/core/vocabs/loader/test/o/tags.txt @@ -1 +1 @@ -untested +not loaded diff --git a/extra/couchdb/tags.txt b/extra/couchdb/tags.txt index 5d77766703..700f0dc9a5 100644 --- a/extra/couchdb/tags.txt +++ b/extra/couchdb/tags.txt @@ -1 +1 @@ -untested +not tested diff --git a/extra/ecdsa/tags.txt b/extra/ecdsa/tags.txt index 5d77766703..700f0dc9a5 100644 --- a/extra/ecdsa/tags.txt +++ b/extra/ecdsa/tags.txt @@ -1 +1 @@ -untested +not tested diff --git a/extra/llvm/core/tags.txt b/extra/llvm/core/tags.txt index 5d77766703..700f0dc9a5 100644 --- a/extra/llvm/core/tags.txt +++ b/extra/llvm/core/tags.txt @@ -1 +1 @@ -untested +not tested diff --git a/extra/llvm/engine/tags.txt b/extra/llvm/engine/tags.txt index 5d77766703..700f0dc9a5 100644 --- a/extra/llvm/engine/tags.txt +++ b/extra/llvm/engine/tags.txt @@ -1 +1 @@ -untested +not tested diff --git a/extra/llvm/invoker/tags.txt b/extra/llvm/invoker/tags.txt index 5d77766703..700f0dc9a5 100644 --- a/extra/llvm/invoker/tags.txt +++ b/extra/llvm/invoker/tags.txt @@ -1 +1 @@ -untested +not tested diff --git a/extra/llvm/jit/tags.txt b/extra/llvm/jit/tags.txt index 5d77766703..700f0dc9a5 100644 --- a/extra/llvm/jit/tags.txt +++ b/extra/llvm/jit/tags.txt @@ -1 +1 @@ -untested +not tested diff --git a/extra/llvm/reader/tags.txt b/extra/llvm/reader/tags.txt index 5d77766703..700f0dc9a5 100644 --- a/extra/llvm/reader/tags.txt +++ b/extra/llvm/reader/tags.txt @@ -1 +1 @@ -untested +not tested diff --git a/extra/llvm/tags.txt b/extra/llvm/tags.txt index a9d28becd8..ba3ee02ae4 100644 --- a/extra/llvm/tags.txt +++ b/extra/llvm/tags.txt @@ -1,2 +1,2 @@ bindings -untested +not tested diff --git a/extra/llvm/types/tags.txt b/extra/llvm/types/tags.txt index 5d77766703..700f0dc9a5 100644 --- a/extra/llvm/types/tags.txt +++ b/extra/llvm/types/tags.txt @@ -1 +1 @@ -untested +not tested diff --git a/extra/llvm/wrappers/tags.txt b/extra/llvm/wrappers/tags.txt index 5d77766703..700f0dc9a5 100644 --- a/extra/llvm/wrappers/tags.txt +++ b/extra/llvm/wrappers/tags.txt @@ -1 +1 @@ -untested +not tested diff --git a/extra/opencl/ffi/tags.txt b/extra/opencl/ffi/tags.txt index a9d28becd8..ba3ee02ae4 100644 --- a/extra/opencl/ffi/tags.txt +++ b/extra/opencl/ffi/tags.txt @@ -1,2 +1,2 @@ bindings -untested +not tested diff --git a/extra/opencl/syntax/tags.txt b/extra/opencl/syntax/tags.txt index 5d77766703..700f0dc9a5 100644 --- a/extra/opencl/syntax/tags.txt +++ b/extra/opencl/syntax/tags.txt @@ -1 +1 @@ -untested +not tested diff --git a/extra/opencl/tags.txt b/extra/opencl/tags.txt index a9d28becd8..ba3ee02ae4 100644 --- a/extra/opencl/tags.txt +++ b/extra/opencl/tags.txt @@ -1,2 +1,2 @@ bindings -untested +not tested From 7524007110757a4b3cf241501f672ca3782a18d0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 18:43:33 -0700 Subject: [PATCH 668/713] load-all now skips vocabs tagged 'not loaded', and test-all skips vocabs tagged 'not tested' --- basis/tools/test/test.factor | 20 +++++++++++--------- basis/vocabs/hierarchy/hierarchy.factor | 5 +---- basis/vocabs/metadata/metadata.factor | 13 +++++++++++-- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/basis/tools/test/test.factor b/basis/tools/test/test.factor index f3f53e43b7..95f1ad8e2c 100644 --- a/basis/tools/test/test.factor +++ b/basis/tools/test/test.factor @@ -2,11 +2,12 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs combinators compiler.units continuations debugger effects fry generalizations io io.files -io.styles kernel lexer locals macros math.parser namespaces parser -vocabs.parser prettyprint quotations sequences source-files splitting -stack-checker summary unicode.case vectors vocabs vocabs.loader -vocabs.files words tools.errors source-files.errors io.streams.string -make compiler.errors ; +io.styles kernel lexer locals macros math.parser namespaces +parser vocabs.parser prettyprint quotations sequences +source-files splitting stack-checker summary unicode.case +vectors vocabs vocabs.loader vocabs.files vocabs.metadata words +tools.errors source-files.errors io.streams.string make +compiler.errors ; IN: tools.test TUPLE: test-failure < source-file-error continuation ; @@ -126,7 +127,7 @@ SYMBOL: forget-tests? forget-tests? get [ [ [ forget-source ] each ] with-compilation-unit ] [ drop ] if ; -: run-vocab-tests ( vocab -- ) +: test-vocab ( vocab -- ) vocab dup [ dup source-loaded?>> [ vocab-tests @@ -136,6 +137,8 @@ SYMBOL: forget-tests? ] [ drop ] if ] [ drop ] if ; +: test-vocabs ( vocabs -- ) [ test-vocab ] each ; + PRIVATE> TEST: unit-test @@ -154,7 +157,6 @@ M: test-failure error. ( error -- ) : :test-failures ( -- ) test-failures get errors. ; -: test ( prefix -- ) - child-vocabs [ run-vocab-tests ] each ; +: test ( prefix -- ) child-vocabs test-vocabs ; -: test-all ( -- ) "" test ; +: test-all ( -- ) vocabs filter-don't-test test-vocabs ; diff --git a/basis/vocabs/hierarchy/hierarchy.factor b/basis/vocabs/hierarchy/hierarchy.factor index 986091a543..609d485f0c 100644 --- a/basis/vocabs/hierarchy/hierarchy.factor +++ b/basis/vocabs/hierarchy/hierarchy.factor @@ -97,9 +97,6 @@ MEMO: all-vocabs-recursive ( -- assoc ) : (load) ( prefix -- failures ) [ child-vocabs-recursive no-roots no-prefixes ] [ dup find-vocab-root [ >vocab-link prefix ] [ drop ] if ] bi - filter-unportable + filter-don't-load require-all ; : load ( prefix -- ) diff --git a/basis/vocabs/metadata/metadata.factor b/basis/vocabs/metadata/metadata.factor index 5048b0edd0..bb14581f0d 100644 --- a/basis/vocabs/metadata/metadata.factor +++ b/basis/vocabs/metadata/metadata.factor @@ -103,12 +103,21 @@ ERROR: bad-platform name ; : supported-platform? ( platforms -- ? ) [ t ] [ [ os swap class<= ] any? ] if-empty ; -: unportable? ( vocab -- ? ) +: don't-load? ( vocab -- ? ) { - [ vocab-tags "untested" swap member? ] + [ vocab-tags "not loaded" swap member? ] [ vocab-platforms supported-platform? not ] } 1|| ; +: filter-don't-load ( vocabs -- vocabs' ) + [ vocab-name don't-load? not ] filter ; + +: don't-test? ( vocab -- ? ) + vocab-tags "not tested" swap member? ; + +: filter-don't-test ( vocabs -- vocabs' ) + [ don't-test? not ] filter ; + TUPLE: unsupported-platform vocab requires ; : unsupported-platform ( vocab requires -- ) From f6908f513fd2db17ad81a54b4a14194895e780ea Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 18:43:48 -0700 Subject: [PATCH 669/713] llvm: fix load errors --- extra/llvm/core/core.factor | 2 +- extra/llvm/engine/engine.factor | 2 +- extra/llvm/invoker/invoker.factor | 2 +- extra/llvm/jit/jit.factor | 23 +++++++++++------------ extra/llvm/types/types.factor | 2 +- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/extra/llvm/core/core.factor b/extra/llvm/core/core.factor index 0ab43c6ab6..5778a00ffb 100644 --- a/extra/llvm/core/core.factor +++ b/extra/llvm/core/core.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Matthew Willis. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.libraries alien.syntax system sequences combinators kernel alien.c-types ; +USING: alien alien.libraries alien.syntax system sequences combinators kernel alien.c-types ; IN: llvm.core diff --git a/extra/llvm/engine/engine.factor b/extra/llvm/engine/engine.factor index 95e425c425..bb39f86f73 100644 --- a/extra/llvm/engine/engine.factor +++ b/extra/llvm/engine/engine.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Matthew Willis. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.libraries alien.syntax llvm.core ; +USING: alien.c-types alien.libraries alien.syntax llvm.core ; IN: llvm.engine << diff --git a/extra/llvm/invoker/invoker.factor b/extra/llvm/invoker/invoker.factor index cc3480fe49..27fdeeb618 100644 --- a/extra/llvm/invoker/invoker.factor +++ b/extra/llvm/invoker/invoker.factor @@ -45,7 +45,7 @@ TUPLE: function name alien return params ; ] [ ] make swap function-effect [ define-declared ] with-compilation-unit ; : install-module ( name -- ) - thejit get mps>> at [ + current-jit mps>> at [ module>> functions [ install-function ] each ] [ "no such module" throw ] if* ; diff --git a/extra/llvm/jit/jit.factor b/extra/llvm/jit/jit.factor index f58851fe6f..fc755fd00f 100644 --- a/extra/llvm/jit/jit.factor +++ b/extra/llvm/jit/jit.factor @@ -5,8 +5,6 @@ kernel llvm.core llvm.engine llvm.wrappers namespaces ; IN: llvm.jit -SYMBOL: thejit - TUPLE: jit ee mps ; : empty-engine ( -- engine ) @@ -15,8 +13,11 @@ TUPLE: jit ee mps ; : ( -- jit ) jit new empty-engine >>ee H{ } clone >>mps ; +: current-jit ( -- jit ) + \ current-jit global [ drop ] cache ; + : (remove-functions) ( function -- ) - thejit get ee>> value>> over LLVMFreeMachineCodeForFunction + current-jit ee>> value>> over LLVMFreeMachineCodeForFunction LLVMGetNextFunction dup ALIEN: 0 = [ drop ] [ (remove-functions) ] if ; : remove-functions ( module -- ) @@ -24,26 +25,24 @@ TUPLE: jit ee mps ; LLVMGetFirstFunction dup ALIEN: 0 = [ drop ] [ (remove-functions) ] if ; : remove-provider ( provider -- ) - thejit get ee>> value>> swap value>> f f + current-jit ee>> value>> swap value>> f f [ LLVMRemoveModuleProvider drop ] 2keep *void* [ llvm-throw ] when* *void* module new swap >>value [ value>> remove-functions ] with-disposal ; : remove-module ( name -- ) - dup thejit get mps>> at [ + dup current-jit mps>> at [ remove-provider - thejit get mps>> delete-at + current-jit mps>> delete-at ] [ drop ] if* ; : add-module ( module name -- ) [ ] dip [ remove-module ] keep - thejit get ee>> value>> pick + current-jit ee>> value>> pick [ [ value>> LLVMAddModuleProvider ] [ t >>disposed drop ] bi ] with-disposal - thejit get mps>> set-at ; + current-jit mps>> set-at ; : function-pointer ( name -- alien ) - thejit get ee>> value>> dup + current-jit ee>> value>> dup rot f [ LLVMFindFunction drop ] keep - *void* LLVMGetPointerToGlobal ; - -thejit [ ] initialize \ No newline at end of file + *void* LLVMGetPointerToGlobal ; \ No newline at end of file diff --git a/extra/llvm/types/types.factor b/extra/llvm/types/types.factor index e93cf7a44b..c312e7a173 100644 --- a/extra/llvm/types/types.factor +++ b/extra/llvm/types/types.factor @@ -229,7 +229,7 @@ NoFunctionParams = "(" WhiteSpace ")" => [[ drop { } ]] VarArgs = WhiteSpace "..." WhiteSpace => [[ drop ... ]] ParamListContinued = "," (Type | VarArgs):t => [[ t ]] ParamList = "(" Type:t (ParamListContinued*):ts ")" => [[ ts t prefix ]] -Function = T:t WhiteSpace ( ParamList | NoFunctionParams ):ts => [[ ... ts member? dup [ ... ts delete ] when t ts >array rot ]] +Function = T:t WhiteSpace ( ParamList | NoFunctionParams ):ts => [[ ... ts member? dup [ ... ts remove! drop ] when t ts >array rot ]] PackedStructure = "<" WhiteSpace "{" Type:ty (StructureTypesList)*:ts "}" WhiteSpace ">" => [[ ts ty prefix >array t ]] UpReference = "\\" Number:n => [[ n ]] Name = '%' ([a-zA-Z][a-zA-Z0-9]*):id => [[ id flatten >string ]] From 3f36a2dd2dbe58e324386710dfb82696a7ee73cb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 18:43:56 -0700 Subject: [PATCH 670/713] opencl.ffi: fix load error --- extra/opencl/ffi/ffi.factor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extra/opencl/ffi/ffi.factor b/extra/opencl/ffi/ffi.factor index d3398f5c24..c3a053d6ae 100644 --- a/extra/opencl/ffi/ffi.factor +++ b/extra/opencl/ffi/ffi.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.libraries alien.syntax classes.struct -combinators system alien.accessors byte-arrays kernel ; +USING: alien alien.c-types alien.libraries alien.syntax +classes.struct combinators system alien.accessors byte-arrays +kernel ; IN: opencl.ffi << "opencl" { From e1ee2c82ea5b92d75848d8a4ffd293b612b6bad0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 18:44:10 -0700 Subject: [PATCH 671/713] cuda: 'not tested' tag --- extra/cuda/ffi/tags.txt | 1 + extra/cuda/tags.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 extra/cuda/ffi/tags.txt create mode 100644 extra/cuda/tags.txt diff --git a/extra/cuda/ffi/tags.txt b/extra/cuda/ffi/tags.txt new file mode 100644 index 0000000000..700f0dc9a5 --- /dev/null +++ b/extra/cuda/ffi/tags.txt @@ -0,0 +1 @@ +not tested diff --git a/extra/cuda/tags.txt b/extra/cuda/tags.txt new file mode 100644 index 0000000000..700f0dc9a5 --- /dev/null +++ b/extra/cuda/tags.txt @@ -0,0 +1 @@ +not tested From 288090d99346e28b4b64976a2c0a917abdfcad65 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 21:21:28 -0700 Subject: [PATCH 672/713] math.parser: expose a format-float primitive for use by formatting vocabulary --- basis/stack-checker/known-words/known-words.factor | 2 +- core/bootstrap/primitives.factor | 2 +- core/math/parser/parser.factor | 13 +++++++------ vm/math.cpp | 8 +++++--- vm/primitives.hpp | 2 +- vm/vm.hpp | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 15895184df..1fa9a94677 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -289,7 +289,7 @@ M: bad-executable summary \ (dlsym) { byte-array object } { c-ptr } define-primitive \ (exists?) { string } { object } define-primitive \ (exit) { integer } { } define-primitive -\ (float>string) { float } { byte-array } define-primitive \ (float>string) make-foldable +\ (format-float) { float byte-array } { byte-array } define-primitive \ (format-float) make-foldable \ (fopen) { byte-array byte-array } { alien } define-primitive \ (identity-hashcode) { object } { fixnum } define-primitive \ (save-image) { byte-array byte-array } { } define-primitive diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 87963848bf..c466b0c1f8 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -470,7 +470,7 @@ tuple { "byte-array>bignum" "math" "primitive_byte_array_to_bignum" (( x -- y )) } { "double>bits" "math" "primitive_double_bits" (( x -- n )) } { "float>bits" "math" "primitive_float_bits" (( x -- n )) } - { "(float>string)" "math.parser.private" "primitive_float_to_str" (( n -- str )) } + { "(format-float)" "math.parser.private" "primitive_format_float" (( n format -- byte-array )) } { "bignum*" "math.private" "primitive_bignum_multiply" (( x y -- z )) } { "bignum+" "math.private" "primitive_bignum_add" (( x y -- z )) } { "bignum-" "math.private" "primitive_bignum_subtract" (( x y -- z )) } diff --git a/core/math/parser/parser.factor b/core/math/parser/parser.factor index 5bb024db9d..14fd6a2983 100644 --- a/core/math/parser/parser.factor +++ b/core/math/parser/parser.factor @@ -1,6 +1,7 @@ ! (c)2009 Joe Groff bsd license -USING: accessors combinators kernel kernel.private math -namespaces sequences sequences.private splitting strings make ; +USING: accessors byte-arrays combinators kernel kernel.private +math namespaces sequences sequences.private splitting strings +make ; IN: math.parser : digit> ( ch -- n ) @@ -356,15 +357,15 @@ M: ratio >base mantissa-expt [ float>hex-value ] [ float>hex-expt ] bi* ] bi 3append ; -: float>decimal ( n -- str ) - (float>string) - [ 0 = ] trim-tail >string +: format-float ( n format -- string ) + 0 suffix >byte-array (format-float) + dup [ 0 = ] find drop head >string fix-float ; : float>base ( n base -- str ) { { 16 [ float>hex ] } - [ drop float>decimal ] + [ drop "%.16g" format-float ] } case ; inline PRIVATE> diff --git a/vm/math.cpp b/vm/math.cpp index a462232344..e64db2690e 100755 --- a/vm/math.cpp +++ b/vm/math.cpp @@ -260,10 +260,12 @@ void factor_vm::primitive_bignum_to_float() ctx->replace(allot_float(bignum_to_float(ctx->peek()))); } -void factor_vm::primitive_float_to_str() +void factor_vm::primitive_format_float() { - byte_array *array = allot_byte_array(33); - SNPRINTF((char *)(array + 1),32,"%.16g",untag_float_check(ctx->pop())); + byte_array *array = allot_byte_array(100); + char *format = alien_offset(ctx->pop()); + double value = untag_float_check(ctx->pop()); + SNPRINTF(array->data(),99,format,value); ctx->push(tag(array)); } diff --git a/vm/primitives.hpp b/vm/primitives.hpp index ff0947912c..e98cf508b6 100644 --- a/vm/primitives.hpp +++ b/vm/primitives.hpp @@ -82,8 +82,8 @@ namespace factor _(float_subtract) \ _(float_to_bignum) \ _(float_to_fixnum) \ - _(float_to_str) \ _(fopen) \ + _(format_float) \ _(fputc) \ _(fread) \ _(fseek) \ diff --git a/vm/vm.hpp b/vm/vm.hpp index 36ec3260d6..dd1d48cf03 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -464,7 +464,7 @@ struct factor_vm cell unbox_array_size_slow(); void primitive_fixnum_to_float(); void primitive_bignum_to_float(); - void primitive_float_to_str(); + void primitive_format_float(); void primitive_float_eq(); void primitive_float_add(); void primitive_float_subtract(); From 8f4210436b489b626848d525a97e2ebcf988ffa8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 21:24:35 -0700 Subject: [PATCH 673/713] formatting: use the new format-float word to fix a failing test case --- basis/formatting/formatting-tests.factor | 1 + basis/formatting/formatting.factor | 46 +++++++++--------------- 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/basis/formatting/formatting-tests.factor b/basis/formatting/formatting-tests.factor index 5710ceb985..35b1dfff4a 100644 --- a/basis/formatting/formatting-tests.factor +++ b/basis/formatting/formatting-tests.factor @@ -16,6 +16,7 @@ IN: formatting.tests [ t ] [ "+0010" 10 "%+05d" sprintf = ] unit-test [ t ] [ "123.456000" 123.456 "%f" sprintf = ] unit-test [ t ] [ "2.44" 2.436 "%.2f" sprintf = ] unit-test +[ t ] [ "8.950" 8.950179003580072 "%.3f" sprintf = ] unit-test [ t ] [ "123.10" 123.1 "%01.2f" sprintf = ] unit-test [ t ] [ "1.2346" 1.23456789 "%.4f" sprintf = ] unit-test [ t ] [ " 1.23" 1.23456789 "%6.2f" sprintf = ] unit-test diff --git a/basis/formatting/formatting.factor b/basis/formatting/formatting.factor index ec3c9f1d8e..5abcb12916 100644 --- a/basis/formatting/formatting.factor +++ b/basis/formatting/formatting.factor @@ -3,7 +3,9 @@ USING: accessors arrays assocs calendar combinators fry kernel generalizations io io.streams.string macros math math.functions math.parser peg.ebnf quotations sequences splitting strings -unicode.categories unicode.case vectors combinators.smart ; +unicode.categories unicode.case vectors combinators.smart +present ; +FROM: math.parser.private => format-float ; IN: formatting digits ( string -- digits ) [ 0 ] [ string>number ] if-empty ; -: pad-digits ( string digits -- string' ) - [ "." split1 ] dip [ CHAR: 0 pad-tail ] [ head-slice ] bi "." glue ; +: format-simple ( x digits string -- string ) + [ [ >float ] [ number>string ] bi* "%." ] dip + surround format-float ; -: max-digits ( n digits -- n' ) - 10^ [ * round ] keep / ; inline +: format-scientific ( x digits -- string ) "e" format-simple ; -: >exp ( x -- exp base ) - [ - abs 0 swap - [ dup [ 10.0 >= ] [ 1.0 < ] bi or ] - [ dup 10.0 >= - [ 10.0 / [ 1 + ] dip ] - [ 10.0 * [ 1 - ] dip ] if - ] while - ] keep 0 < [ neg ] when ; +: format-decimal ( x digits -- string ) "f" format-simple ; -: exp>string ( exp base digits -- string ) - [ max-digits ] keep -rot - [ - [ 0 < "-" "+" ? ] - [ abs number>string 2 CHAR: 0 pad-head ] bi - "e" -rot 3append - ] - [ number>string ] bi* - rot pad-digits prepend ; +ERROR: unknown-printf-directive ; EBNF: parse-printf @@ -73,15 +59,15 @@ digits = (digits_)? => [[ 6 or ]] fmt-% = "%" => [[ [ "%" ] ]] fmt-c = "c" => [[ [ 1string ] ]] fmt-C = "C" => [[ [ 1string >upper ] ]] -fmt-s = "s" => [[ [ dup number? [ number>string ] when ] ]] -fmt-S = "S" => [[ [ dup number? [ number>string ] when >upper ] ]] -fmt-d = "d" => [[ [ >fixnum number>string ] ]] -fmt-e = digits "e" => [[ first '[ >exp _ exp>string ] ]] -fmt-E = digits "E" => [[ first '[ >exp _ exp>string >upper ] ]] -fmt-f = digits "f" => [[ first dup '[ >float _ max-digits number>string _ pad-digits ] ]] +fmt-s = "s" => [[ [ present ] ]] +fmt-S = "S" => [[ [ present >upper ] ]] +fmt-d = "d" => [[ [ >integer number>string ] ]] +fmt-e = digits "e" => [[ first '[ _ format-scientific ] ]] +fmt-E = digits "E" => [[ first '[ _ format-scientific >upper ] ]] +fmt-f = digits "f" => [[ first '[ _ format-decimal ] ]] fmt-x = "x" => [[ [ >hex ] ]] fmt-X = "X" => [[ [ >hex >upper ] ]] -unknown = (.)* => [[ "Unknown directive" throw ]] +unknown = (.)* => [[ unknown-printf-directive ]] strings_ = fmt-c|fmt-C|fmt-s|fmt-S strings = pad width strings_ => [[ reverse compose-all ]] From 216a05e68a4d9df1135837fd7306bf9285e3fa2b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 21:24:42 -0700 Subject: [PATCH 674/713] vm: small cleanup --- vm/callstack.cpp | 2 +- vm/io.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/callstack.cpp b/vm/callstack.cpp index ad7528ab84..eae976219f 100755 --- a/vm/callstack.cpp +++ b/vm/callstack.cpp @@ -122,7 +122,7 @@ cell factor_vm::frame_scan(stack_frame *frame) if(obj.type_p(QUOTATION_TYPE)) { char *return_addr = (char *)FRAME_RETURN_ADDRESS(frame,this); - char *quot_entry_point = (char *)(frame_code(frame) + 1); + char *quot_entry_point = (char *)frame_code(frame)->entry_point(); return tag_fixnum(quot_code_offset_to_scan( obj.value(),(cell)(return_addr - quot_entry_point))); diff --git a/vm/io.cpp b/vm/io.cpp index 8ce7ff5256..94e6e64d1d 100755 --- a/vm/io.cpp +++ b/vm/io.cpp @@ -216,7 +216,7 @@ void factor_vm::primitive_fread() if(feof(file)) { byte_array *new_buf = allot_byte_array(c); - memcpy(new_buf + 1, buf.untagged() + 1,c); + memcpy(new_buf->data(), buf->data(),c); buf = new_buf; } From bb0c4d94e05663e44af8e1da5abb1822bcb24a60 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Wed, 14 Apr 2010 00:08:10 -0700 Subject: [PATCH 675/713] Replace info and 2info macros with simple inline words. --- extra/opencl/opencl.factor | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/extra/opencl/opencl.factor b/extra/opencl/opencl.factor index ddcf16a3b2..91a264e85c 100644 --- a/extra/opencl/opencl.factor +++ b/extra/opencl/opencl.factor @@ -1,10 +1,9 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien alien.accessors alien.c-types arrays -byte-arrays combinators combinators.smart continuations destructors -fry io.encodings.ascii io.encodings.string kernel libc locals macros -math math.order multiline opencl.ffi prettyprint sequences -specialized-arrays typed variants namespaces ; +USING: accessors alien alien.c-types arrays byte-arrays combinators +combinators.smart destructors io.encodings.ascii io.encodings.string +kernel libc locals math namespaces opencl.ffi sequences shuffle +specialized-arrays variants ; IN: opencl SPECIALIZED-ARRAYS: void* char size_t ; @@ -16,17 +15,25 @@ ERROR: cl-error err ; : cl-not-null ( err -- ) dup f = [ cl-error ] [ drop ] if ; inline + +: info-data-size ( handle name info-quot -- size_t ) + [ 0 f 0 ] dip [ call cl-success ] 2keep drop *size_t ; inline -MACRO: info ( info-quot lift-quot -- quot ) - [ dup ] dip '[ 2dup 0 f 0 _ '[ _ call cl-success ] keep - *size_t dup _ '[ f _ call cl-success ] keep - _ call ] ; - -MACRO: 2info ( info-quot lift-quot -- quot ) - [ dup ] dip '[ 3dup 0 f 0 _ '[ _ call cl-success ] keep - *size_t dup _ '[ f _ call cl-success ] keep - _ call ] ; - +: info-data-bytes ( handle name info-quot size -- bytes ) + swap [ dup f ] dip [ call cl-success ] 3keep 2drop ; inline + +: info ( handle name info-quot lift-quot -- value ) + [ 3dup info-data-size info-data-bytes ] dip call ; inline + +: 2info-data-size ( handle1 handle2 name info-quot -- size_t ) + [ 0 f 0 ] dip [ call cl-success ] 2keep drop *size_t ; inline + +: 2info-data-bytes ( handle1 handle2 name info-quot size -- bytes ) + swap [ dup f ] dip [ call cl-success ] 3keep 2drop ; inline + +: 2info ( handle1 handle2 name info_quot lift_quot -- value ) + [ 4dup 2info-data-size 2info-data-bytes ] dip call ; inline + : info-bool ( handle name quot -- ? ) [ *uint CL_TRUE = ] info ; inline From b4a0fd8b17e1c8530067a33a7b24d389e8536bc2 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Wed, 14 Apr 2010 01:28:21 -0700 Subject: [PATCH 676/713] Remove some inline flags for info words to avoid out of memory on 32-bit archs. --- extra/opencl/opencl.factor | 44 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/extra/opencl/opencl.factor b/extra/opencl/opencl.factor index 91a264e85c..17f0143ae1 100644 --- a/extra/opencl/opencl.factor +++ b/extra/opencl/opencl.factor @@ -163,6 +163,7 @@ C: cl-buffer-range SYMBOLS: cl-current-context cl-current-queue cl-current-device ; char*-array ( strings -- char*-array ) [ ascii encode dup length dup malloc [ cl-not-null ] - keep &free [ -rot memcpy ] keep ] void*-array{ } map-as ; inline + keep &free [ -rot memcpy ] keep ] void*-array{ } map-as ; : (program) ( cl-context sources -- program-handle ) [ handle>> ] dip [ @@ -354,19 +355,19 @@ M: cl-filter-linear filter-mode-constant drop CL_FILTER_LINEAR ; } case ; : kernel-info-string ( handle name -- string ) - [ clGetKernelInfo ] info-string ; inline + [ clGetKernelInfo ] info-string ; : kernel-info-uint ( handle name -- uint ) - [ clGetKernelInfo ] info-uint ; inline + [ clGetKernelInfo ] info-uint ; : kernel-work-group-info-size_t ( handle1 handle2 name -- size_t ) - [ clGetKernelWorkGroupInfo ] 2info-size_t ; inline + [ clGetKernelWorkGroupInfo ] 2info-size_t ; : event-info-uint ( handle name -- uint ) - [ clGetEventInfo ] info-uint ; inline + [ clGetEventInfo ] info-uint ; : event-info-int ( handle name -- int ) - [ clGetEventInfo ] info-int ; inline + [ clGetEventInfo ] info-int ; : cl_command_type>command-type ( cl_command-type -- command-type ) { @@ -399,8 +400,7 @@ M: cl-filter-linear filter-mode-constant drop CL_FILTER_LINEAR ; } case ; inline : profiling-info-ulong ( handle name -- ulong ) - [ clGetEventProfilingInfo ] info-ulong ; inline - + [ clGetEventProfilingInfo ] info-ulong ; : bind-kernel-arg-buffer ( kernel index buffer -- ) [ handle>> ] [ cl_mem heap-size ] [ handle>> ] tri* @@ -535,10 +535,10 @@ PRIVATE> cl-kernel new-disposable swap >>handle ; inline : cl-kernel-name ( kernel -- string ) - handle>> CL_KERNEL_FUNCTION_NAME kernel-info-string ; inline + handle>> CL_KERNEL_FUNCTION_NAME kernel-info-string ; : cl-kernel-arity ( kernel -- arity ) - handle>> CL_KERNEL_NUM_ARGS kernel-info-uint ; inline + handle>> CL_KERNEL_NUM_ARGS kernel-info-uint ; : cl-kernel-local-size ( kernel -- size ) (current-cl-device) [ handle>> ] bi@ CL_KERNEL_WORK_GROUP_SIZE kernel-work-group-info-size_t ; inline From 5615671560811f8a287364bc89545c16ef9c1d54 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 14 Apr 2010 02:32:54 -0700 Subject: [PATCH 677/713] benchmark.knucleotide: some cleanups --- .../benchmark/knucleotide/knucleotide.factor | 57 +++++++------------ 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/extra/benchmark/knucleotide/knucleotide.factor b/extra/benchmark/knucleotide/knucleotide.factor index 70fa1bb061..f03e26675e 100644 --- a/extra/benchmark/knucleotide/knucleotide.factor +++ b/extra/benchmark/knucleotide/knucleotide.factor @@ -1,16 +1,9 @@ -USING: kernel locals io io.files splitting strings io.encodings.ascii - hashtables sequences assocs math namespaces prettyprint - math.parser combinators arrays sorting unicode.case ; - +USING: ascii kernel io io.files splitting strings +io.encodings.ascii hashtables sequences assocs math +math.statistics namespaces prettyprint math.parser combinators +arrays sorting formatting grouping fry ; IN: benchmark.knucleotide -: float>string ( float places -- string ) - swap >float number>string - "." split1 rot - over length over < - [ CHAR: 0 pad-tail ] - [ head ] if "." glue ; - : discard-lines ( -- ) readln [ ">THREE" head? [ discard-lines ] unless ] when* ; @@ -20,37 +13,25 @@ IN: benchmark.knucleotide ">" read-until drop CHAR: \n swap remove >upper ; -: tally ( x exemplar -- b ) - clone [ [ inc-at ] curry each ] keep ; - -: small-groups ( x n -- b ) - swap - [ length swap - 1 + iota ] 2keep - [ [ over + ] dip subseq ] 2curry map ; - : handle-table ( inputs n -- ) - small-groups - [ length ] keep - H{ } tally >alist - sort-values reverse - [ - dup first write bl - second 100 * over / 3 float>string print - ] each - drop ; + clump + [ histogram >alist sort-values reverse ] [ length ] bi + '[ + [ first write bl ] + [ second 100 * _ /f "%.3f" printf nl ] bi + ] each ; -:: handle-n ( inputs x -- ) - inputs x length small-groups :> groups - groups H{ } tally :> b - x b at [ 0 ] unless* - number>string 8 CHAR: \s pad-tail write ; +: handle-n ( input x -- ) + [ nip ] [ length clump histogram ] 2bi at 0 or "%d\t" printf ; : process-input ( input -- ) - dup 1 handle-table nl - dup 2 handle-table nl - { "GGT" "GGTA" "GGTATT" "GGTATTTTAATT" "GGTATTTTAATTTATAGT" } - [ [ dupd handle-n ] keep print ] each - drop ; + [ 1 handle-table nl ] + [ 2 handle-table nl ] + [ + { "GGT" "GGTA" "GGTATT" "GGTATTTTAATT" "GGTATTTTAATTTATAGT" } + [ [ handle-n ] keep print ] with each + ] + tri ; : knucleotide ( -- ) "resource:extra/benchmark/knucleotide/knucleotide-input.txt" From e5c1a82643876f0b210d80a8b9b28b04db009075 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 12:06:45 -0700 Subject: [PATCH 678/713] alien.syntax: FUNCTION-ALIAS: syntax to define a C function binding with a different Factor name --- basis/alien/parser/parser.factor | 14 ++++++++++---- basis/alien/syntax/syntax.factor | 6 +++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index 7b677c3581..27c3024056 100755 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -113,13 +113,19 @@ PRIVATE> : function-effect ( names return -- effect ) [ { } ] [ return-type-name 1array ] if-void ; -:: make-function ( return function library types names -- word quot effect ) - function create-in dup reset-generic +: create-function ( name -- word ) + create-in dup reset-generic ; + +:: (make-function) ( return function library types names -- quot effect ) return library function types function-quot names return function-effect ; -: (FUNCTION:) ( -- word quot effect ) - scan-function-name current-library get ";" scan-c-args make-function ; +:: make-function ( return function library types names -- word quot effect ) + function create-function + return function library types names (make-function) ; + +: (FUNCTION:) ( -- return function library types names ) + scan-function-name current-library get ";" scan-c-args ; : callback-quot ( return types abi -- quot ) '[ [ _ _ _ ] dip alien-callback ] ; diff --git a/basis/alien/syntax/syntax.factor b/basis/alien/syntax/syntax.factor index bc7e590cff..41aed99446 100755 --- a/basis/alien/syntax/syntax.factor +++ b/basis/alien/syntax/syntax.factor @@ -16,7 +16,11 @@ SYNTAX: BAD-ALIEN suffix! ; SYNTAX: LIBRARY: scan current-library set ; SYNTAX: FUNCTION: - (FUNCTION:) define-declared ; + (FUNCTION:) make-function define-declared ; + +SYNTAX: FUNCTION-ALIAS: + scan create-function + (FUNCTION:) (make-function) define-declared ; SYNTAX: CALLBACK: (CALLBACK:) define-inline ; From efbc3033da31acaf054fd2aee3e889b618c19368 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 12:25:22 -0700 Subject: [PATCH 679/713] math.libm: use FUNCTION-ALIAS: --- basis/math/libm/libm-docs.factor | 26 +++++------ basis/math/libm/libm.factor | 80 ++++++++++++++++---------------- 2 files changed, 54 insertions(+), 52 deletions(-) diff --git a/basis/math/libm/libm-docs.factor b/basis/math/libm/libm-docs.factor index 9de6e7d127..7dc6313b86 100644 --- a/basis/math/libm/libm-docs.factor +++ b/basis/math/libm/libm-docs.factor @@ -36,53 +36,53 @@ ARTICLE: "math.libm" "C standard library math functions" ABOUT: "math.libm" HELP: facos -{ $values { "x" real } { "y" real } } +{ $values { "x" real } { "double" real } } { $description "Calls the inverse trigonometric cosine function from the C standard library. User code should call " { $link acos } " instead." } ; HELP: fasin -{ $values { "x" real } { "y" real } } +{ $values { "x" real } { "double" real } } { $description "Calls the inverse trigonometric sine function from the C standard library. User code should call " { $link asin } " instead." } ; HELP: fatan -{ $values { "x" real } { "y" real } } +{ $values { "x" real } { "double" real } } { $description "Calls the inverse trigonometric tangent function from the C standard library. User code should call " { $link atan } " instead." } ; HELP: fatan2 -{ $values { "x" real } { "y" real } { "z" real } } +{ $values { "x" real } { "y" real } { "double" real } } { $description "Calls the two-parameter inverse trigonometric tangent function from the C standard library. User code should call " { $link arg } " instead." } ; HELP: fcos -{ $values { "x" real } { "y" real } } +{ $values { "x" real } { "double" real } } { $description "Calls the trigonometric cosine function from the C standard library. User code should call " { $link cos } " instead." } ; HELP: fsin -{ $values { "x" real } { "y" real } } +{ $values { "x" real } { "double" real } } { $description "Calls the trigonometric sine function from the C standard library. User code should call " { $link sin } " instead." } ; HELP: fcosh -{ $values { "x" real } { "y" real } } +{ $values { "x" real } { "double" real } } { $description "Calls the hyperbolic cosine function from the C standard library. User code should call " { $link cosh } " instead." } ; HELP: fsinh -{ $values { "x" real } { "y" real } } +{ $values { "x" real } { "double" real } } { $description "Calls the hyperbolic sine function from the C standard library. User code should call " { $link sinh } " instead." } ; HELP: fexp -{ $values { "x" real } { "y" real } } +{ $values { "x" real } { "double" real } } { $description "Calls the exponential function (" { $snippet "y=e^x" } " from the C standard library. User code should call " { $link exp } " instead." } ; HELP: flog -{ $values { "x" real } { "y" real } } +{ $values { "x" real } { "double" real } } { $description "Calls the natural logarithm function from the C standard library. User code should call " { $link log } " instead." } ; HELP: flog10 -{ $values { "x" real } { "y" real } } +{ $values { "x" real } { "double" real } } { $description "Calls the base 10 logarithm function from the C standard library. User code should call " { $link log10 } " instead." } ; HELP: fpow -{ $values { "x" real } { "y" real } { "z" real } } +{ $values { "x" real } { "y" real } { "double" real } } { $description "Calls the power function (" { $snippet "z=x^y" } ") from the C standard library. User code should call " { $link ^ } " instead." } ; HELP: fsqrt -{ $values { "x" real } { "y" real } } +{ $values { "x" real } { "double" real } } { $description "Calls the square root function from the C standard library. User code should call " { $link sqrt } " instead." } ; diff --git a/basis/math/libm/libm.factor b/basis/math/libm/libm.factor index 0288894081..c87a2819ca 100644 --- a/basis/math/libm/libm.factor +++ b/basis/math/libm/libm.factor @@ -1,62 +1,64 @@ ! Copyright (C) 2006 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien alien.c-types ; +USING: alien alien.c-types alien.syntax ; IN: math.libm -: facos ( x -- y ) - double "libm" "acos" { double } alien-invoke ; +LIBRARY: libm -: fasin ( x -- y ) - double "libm" "asin" { double } alien-invoke ; +FUNCTION-ALIAS: facos + double acos ( double x ) ; -: fatan ( x -- y ) - double "libm" "atan" { double } alien-invoke ; +FUNCTION-ALIAS: fasin + double asin ( double x ) ; -: fatan2 ( x y -- z ) - double "libm" "atan2" { double double } alien-invoke ; +FUNCTION-ALIAS: fatan + double atan ( double x ) ; -: fcos ( x -- y ) - double "libm" "cos" { double } alien-invoke ; +FUNCTION-ALIAS: fatan2 + double atan2 ( double x, double y ) ; -: fsin ( x -- y ) - double "libm" "sin" { double } alien-invoke ; +FUNCTION-ALIAS: fcos + double cos ( double x ) ; -: ftan ( x -- y ) - double "libm" "tan" { double } alien-invoke ; +FUNCTION-ALIAS: fsin + double sin ( double x ) ; -: fcosh ( x -- y ) - double "libm" "cosh" { double } alien-invoke ; +FUNCTION-ALIAS: ftan + double tan ( double x ) ; -: fsinh ( x -- y ) - double "libm" "sinh" { double } alien-invoke ; +FUNCTION-ALIAS: fcosh + double cosh ( double x ) ; -: ftanh ( x -- y ) - double "libm" "tanh" { double } alien-invoke ; +FUNCTION-ALIAS: fsinh + double sinh ( double x ) ; -: fexp ( x -- y ) - double "libm" "exp" { double } alien-invoke ; +FUNCTION-ALIAS: ftanh + double tanh ( double x ) ; -: flog ( x -- y ) - double "libm" "log" { double } alien-invoke ; +FUNCTION-ALIAS: fexp + double exp ( double x ) ; -: flog10 ( x -- y ) - double "libm" "log10" { double } alien-invoke ; +FUNCTION-ALIAS: flog + double log ( double x ) ; -: fpow ( x y -- z ) - double "libm" "pow" { double double } alien-invoke ; +FUNCTION-ALIAS: flog10 + double log10 ( double x ) ; -: fsqrt ( x -- y ) - double "libm" "sqrt" { double } alien-invoke ; +FUNCTION-ALIAS: fpow + double pow ( double x, double y ) ; + +FUNCTION-ALIAS: fsqrt + double sqrt ( double x ) ; ! Windows doesn't have these... -: flog1+ ( x -- y ) - double "libm" "log1p" { double } alien-invoke ; +FUNCTION-ALIAS: flog1+ + double log1p ( double x ) ; -: facosh ( x -- y ) - double "libm" "acosh" { double } alien-invoke ; +FUNCTION-ALIAS: facosh + double acosh ( double x ) ; -: fasinh ( x -- y ) - double "libm" "asinh" { double } alien-invoke ; +FUNCTION-ALIAS: fasinh + double asinh ( double x ) ; -: fatanh ( x -- y ) - double "libm" "atanh" { double } alien-invoke ; +FUNCTION-ALIAS: fatanh + double atanh ( double x ) ; From d20bff5615c110c82a39306dd7e72d85a81e9f77 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 12:40:10 -0700 Subject: [PATCH 680/713] prettyprint FUNCTION-ALIAS: definitions --- basis/alien/parser/parser.factor | 5 +++- basis/alien/prettyprint/prettyprint.factor | 32 ++++++++++++++++------ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index 27c3024056..1db4ca5cd8 100755 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -142,12 +142,15 @@ PRIVATE> current-library get scan-function-name ";" scan-c-args make-callback-type ; -PREDICATE: alien-function-word < word +PREDICATE: alien-function-alias-word < word def>> { [ length 5 = ] [ last \ alien-invoke eq? ] } 1&& ; +PREDICATE: alien-function-word < alien-function-alias-word + [ def>> third ] [ name>> ] bi = ; + PREDICATE: alien-callback-type-word < typedef-word "callback-effect" word-prop ; diff --git a/basis/alien/prettyprint/prettyprint.factor b/basis/alien/prettyprint/prettyprint.factor index 52e9978a5f..c47dafbfce 100644 --- a/basis/alien/prettyprint/prettyprint.factor +++ b/basis/alien/prettyprint/prettyprint.factor @@ -61,22 +61,36 @@ M: typedef-word synopsis* : pprint-library ( library -- ) [ \ LIBRARY: [ text ] pprint-prefix ] when* ; +: pprint-function ( word quot -- ) + [ def>> first pprint-c-type ] + swap + [ + > fourth ] [ stack-effect in>> ] bi + pprint-function-args + ")" text block> + ] tri ; inline + +M: alien-function-alias-word definer + drop \ FUNCTION-ALIAS: \ ; ; +M: alien-function-alias-word definition drop f ; +M: alien-function-alias-word synopsis* + { + [ seeing-word ] + [ def>> second pprint-library ] + [ definer. ] + [ pprint-word ] + [ [ def>> third text ] pprint-function ] + } cleave ; + M: alien-function-word definer drop \ FUNCTION: \ ; ; -M: alien-function-word definition drop f ; M: alien-function-word synopsis* { [ seeing-word ] [ def>> second pprint-library ] [ definer. ] - [ def>> first pprint-c-type ] - [ pprint-word ] - [ - > fourth ] [ stack-effect in>> ] bi - pprint-function-args - ")" text block> - ] + [ [ pprint-word ] pprint-function ] } cleave ; M: alien-callback-type-word definer From f10ea3cbeaf95d6ab880745473c7b5d8480115e7 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 13:08:45 -0700 Subject: [PATCH 681/713] libc: add DESTRUCTOR: for (free) --- basis/libc/libc.factor | 1 + 1 file changed, 1 insertion(+) diff --git a/basis/libc/libc.factor b/basis/libc/libc.factor index 4a887e695f..27d7555d67 100644 --- a/basis/libc/libc.factor +++ b/basis/libc/libc.factor @@ -99,3 +99,4 @@ PRIVATE> size_t "libc" "strlen" { c-string } alien-invoke ; DESTRUCTOR: free +DESTRUCTOR: (free) From dcf68af105827fd44d456fb4ff3c95381f751bcd Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 13:16:04 -0700 Subject: [PATCH 682/713] new vocab alien.cxx.demangle.libstdcxx: name demangling for gnu abi --- .../cxx/demangle/libstdcxx/libstdcxx.factor | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 extra/alien/cxx/demangle/libstdcxx/libstdcxx.factor diff --git a/extra/alien/cxx/demangle/libstdcxx/libstdcxx.factor b/extra/alien/cxx/demangle/libstdcxx/libstdcxx.factor new file mode 100644 index 0000000000..55a25be09d --- /dev/null +++ b/extra/alien/cxx/demangle/libstdcxx/libstdcxx.factor @@ -0,0 +1,39 @@ +! (c)2010 Joe Groff bsd license +USING: alien alien.c-types alien.libraries alien.strings +alien.syntax combinators destructors io.encodings.ascii kernel +libc locals sequences system ; +IN: alien.cxx.demangle.libstdcxx + +<< +"libstdc++" { + { [ os macosx? ] [ "/usr/lib/libstdc++.6.0.9.dylib" ] } + { [ os unix? ] [ "/usr/lib/libstdc++.so" ] } +} cond cdecl add-library +>> + +LIBRARY: libstdc++ + +FUNCTION: char* __cxa_demangle ( char* mangled_name, char* output_buffer, size_t* length, int* status ) ; + +ERROR: demangle-memory-allocation-failure ; +ERROR: invalid-mangled-name name ; +ERROR: invalid-demangle-args name ; + +: demangle-error ( name status -- ) + { + { 0 [ drop ] } + { -1 [ drop demangle-memory-allocation-failure ] } + { -2 [ invalid-mangled-name ] } + { -3 [ invalid-demangle-args ] } + } case ; + +: mangled-name? ( name -- ? ) + "_Z" head? ; + +:: demangle ( mangled-name -- c++-name ) + 0 :> length + 0 :> status [ + mangled-name ascii string>alien f length status __cxa_demangle &(free) :> demangled-buf + mangled-name status *int demangle-error + demangled-buf ascii alien>string + ] with-destructors ; From 94c0382b9991823a97cdedd71dad757b4aa9f035 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 13:38:41 -0700 Subject: [PATCH 683/713] macho: use with-mapped-file-reader in with-mapped-macho --- extra/macho/macho.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/macho/macho.factor b/extra/macho/macho.factor index b18ea57ce5..66e76825aa 100644 --- a/extra/macho/macho.factor +++ b/extra/macho/macho.factor @@ -915,7 +915,7 @@ TYPED: load-commands ( macho: mach_header_32/64 -- load-commands ) : with-mapped-macho ( path quot -- ) '[ address>> macho-header @ - ] with-mapped-file ; inline + ] with-mapped-file-reader ; inline : macho-nm ( path -- ) [| macho | From 3544568fe87f13c17bf233f03c0fdf05832cc119 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 14:37:21 -0700 Subject: [PATCH 684/713] macho: add utility for getting exported symbols from a dylib --- extra/macho/macho.factor | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/extra/macho/macho.factor b/extra/macho/macho.factor index 66e76825aa..79cb59c148 100644 --- a/extra/macho/macho.factor +++ b/extra/macho/macho.factor @@ -1,9 +1,10 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http:// factorcode.org/license.txt for BSD license. USING: accessors alien alien.c-types alien.strings alien.syntax -classes classes.struct combinators io.encodings.ascii -io.encodings.string kernel literals make math sequences -specialized-arrays typed fry io.mmap formatting locals ; +classes classes.struct combinators combinators.short-circuit +io.encodings.ascii io.encodings.string kernel literals make +math sequences specialized-arrays typed fry io.mmap formatting +locals splitting ; FROM: alien.c-types => short ; IN: macho @@ -912,6 +913,9 @@ TYPED: load-commands ( macho: mach_header_32/64 -- load-commands ) : symbol-name ( symbol string-table -- name ) [ n_strx>> ] dip ascii alien>string ; +: c-symbol-name ( symbol string-table -- name ) + symbol-name "_" ?head drop ; + : with-mapped-macho ( path quot -- ) '[ address>> macho-header @ @@ -930,3 +934,18 @@ TYPED: load-commands ( macho: mach_header_32/64 -- load-commands ) ] curry each ] each ] with-mapped-macho ; + +: dylib-export? ( symtab-entry -- ? ) + n_type>> { + [ N_EXT bitand zero? not ] + [ N_TYPE bitand N_UNDF = not ] + } 1&& ; + +: dylib-exports ( path -- symbol-names ) + [| macho | + macho load-commands symtab-commands [| symtab | + macho symtab symbols + [ [ dylib-export? ] filter ] + [ [ c-symbol-name ] curry { } map-as ] bi* + ] { } map-as concat + ] with-mapped-macho ; From b4867f4a1cd6cafd03fe1ae74bbcb807fcf27f42 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 15:08:32 -0700 Subject: [PATCH 685/713] assocs: add effect declarations to assoc combinators --- core/assocs/assocs-docs.factor | 28 ++++++++++++++-------------- core/assocs/assocs.factor | 30 +++++++++++++++--------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/core/assocs/assocs-docs.factor b/core/assocs/assocs-docs.factor index 8f93c5a9d1..2439f03aac 100644 --- a/core/assocs/assocs-docs.factor +++ b/core/assocs/assocs-docs.factor @@ -202,7 +202,7 @@ HELP: new-assoc { $contract "Creates a new assoc of the same size as " { $snippet "exemplar" } " which can hold " { $snippet "capacity" } " entries before growing." } ; HELP: assoc-find -{ $values { "assoc" assoc } { "quot" { $quotation "( key value -- ? )" } } { "key" "the successful key, or f" } { "value" "the successful value, or f" } { "?" "a boolean" } } +{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... ? )" } } { "key" "the successful key, or f" } { "value" "the successful value, or f" } { "?" "a boolean" } } { $description "Applies a predicate quotation to each entry in the assoc. Returns the key and value that the quotation succeeds on, or " { $link f } " for both if the quotation fails. It also returns a boolean describing whether there was anything found; this can be used to distinguish between a key and a value equal to " { $link f } ", or nothing being found." } ; HELP: clear-assoc @@ -242,7 +242,7 @@ HELP: ?at { $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 -- )" } } } +{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... )" } } } { $description "Applies a quotation to each entry in the assoc." } { $examples { $example @@ -254,7 +254,7 @@ HELP: assoc-each } ; HELP: assoc-map -{ $values { "assoc" assoc } { "quot" { $quotation "( key value -- newkey newvalue )" } } { "newassoc" "a new assoc" } } +{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... newkey newvalue )" } } { "newassoc" "a new assoc" } } { $description "Applies the quotation to each entry in the input assoc and collects the results in a new assoc of the same type as the input." } { $examples { $unchecked-example @@ -269,15 +269,15 @@ HELP: assoc-map { assoc-map assoc-map-as } related-words HELP: assoc-filter -{ $values { "assoc" assoc } { "quot" { $quotation "( key value -- ? )" } } { "subassoc" "a new assoc" } } +{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... ? )" } } { "subassoc" "a new assoc" } } { $description "Outputs an assoc of the same type as " { $snippet "assoc" } " consisting of all entries for which the predicate quotation yields true." } ; HELP: assoc-filter-as -{ $values { "assoc" assoc } { "quot" { $quotation "( key value -- ? )" } } { "exemplar" assoc } { "subassoc" "a new assoc" } } +{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... ? )" } } { "exemplar" assoc } { "subassoc" "a new assoc" } } { $description "Outputs an assoc of the same type as " { $snippet "exemplar" } " consisting of all entries for which the predicate quotation yields true." } ; HELP: assoc-filter! -{ $values { "assoc" assoc } { "quot" { $quotation "( key value -- ? )" } } } +{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... ? )" } } } { $description "Removes all entries for which the predicate quotation yields true." } { $side-effects "assoc" } ; @@ -291,11 +291,11 @@ HELP: assoc-partition { $description "Calls a predicate quotation on each key of the input assoc. If the test yields true, the key/value pair is added to " { $snippet "true-assoc" } "; if false, it's added to " { $snippet "false-assoc" } "." } ; HELP: assoc-any? -{ $values { "assoc" assoc } { "quot" { $quotation "( key value -- ? )" } } { "?" "a boolean" } } +{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... ? )" } } { "?" "a boolean" } } { $description "Tests if the assoc contains an entry satisfying a predicate by applying the quotation to each entry in turn. Iteration stops if an entry is found for which the quotation outputs a true value." } ; HELP: assoc-all? -{ $values { "assoc" assoc } { "quot" { $quotation "( key value -- ? )" } } { "?" "a boolean" } } +{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... ? )" } } { "?" "a boolean" } } { $description "Tests if all entries in the assoc satisfy a predicate by applying the quotation to each entry in turn. a predicate quotation to entry in the assoc. Iteration stops if an entry is found for which the quotation outputs " { $link f } ". If the assoc is empty, always outputs " { $link t } "." } ; HELP: assoc-subset? @@ -378,25 +378,25 @@ HELP: substitute { $description "Creates a new sequence where elements of " { $snippet "seq" } " which appear as keys in " { $snippet "assoc" } " are replaced by the corresponding values, and all other elements are unchanged." } ; HELP: cache -{ $values { "key" "a key" } { "assoc" assoc } { "quot" { $quotation "( key -- value )" } } { "value" "a previously-retained or freshly-computed value" } } +{ $values { "key" "a key" } { "assoc" assoc } { "quot" { $quotation "( ... key -- ... value )" } } { "value" "a previously-retained or freshly-computed value" } } { $description "If the key is present in the assoc, outputs the associated value, otherwise calls the quotation to produce a value and stores the key/value pair into the assoc. Returns a value either looked up or newly stored in the assoc." } { $side-effects "assoc" } ; HELP: 2cache -{ $values { "key1" "a key" } { "key2" "a key" } { "assoc" assoc } { "quot" { $quotation "( key1 key2 -- value )" } } { "value" "a previously-retained or freshly-computed value" } } +{ $values { "key1" "a key" } { "key2" "a key" } { "assoc" assoc } { "quot" { $quotation "( ... key1 key2 -- ... value )" } } { "value" "a previously-retained or freshly-computed value" } } { $description "If a single key composed of the input keys is present in the assoc, outputs the associated value, otherwise calls the quotation to produce a value and stores the keys/value pair into the assoc. Returns the value stored in the assoc. Returns a value either looked up or newly stored in the assoc." } { $side-effects "assoc" } ; HELP: map>assoc -{ $values { "seq" "a sequence" } { "quot" { $quotation "( elt -- key value )" } } { "exemplar" assoc } { "assoc" "a new assoc" } } +{ $values { "seq" "a sequence" } { "quot" { $quotation "( ... elt -- ... key value )" } } { "exemplar" assoc } { "assoc" "a new assoc" } } { $description "Applies the quotation to each element of the sequence, and collects the keys and values into a new assoc having the same type as " { $snippet "exemplar" } "." } ; HELP: assoc>map -{ $values { "assoc" assoc } { "quot" { $quotation "( key value -- elt )" } } { "exemplar" "a sequence" } { "seq" "a new sequence" } } +{ $values { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... elt )" } } { "exemplar" "a sequence" } { "seq" "a new sequence" } } { $description "Applies the quotation to each entry of the assoc and collects the results into a new sequence of the same type as the exemplar." } ; HELP: change-at -{ $values { "key" object } { "assoc" assoc } { "quot" { $quotation "( value -- newvalue )" } } } +{ $values { "key" object } { "assoc" assoc } { "quot" { $quotation "( ..a value -- ..b newvalue )" } } } { $description "Applies the quotation to the value associated with " { $snippet "key" } ", storing the new value back in the assoc." } { $side-effects "assoc" } ; @@ -432,7 +432,7 @@ HELP: assoc-combine HELP: assoc-map-as { $values - { "assoc" assoc } { "quot" { $quotation "( key value -- newkey newvalue )" } } { "exemplar" assoc } + { "assoc" assoc } { "quot" { $quotation "( ... key value -- ... newkey newvalue )" } } { "exemplar" assoc } { "newassoc" assoc } } { $description "Applies the quotation to each entry in the input assoc and collects the results in a new assoc of the stame type as the exemplar." } { $examples { $example "USING: prettyprint assocs hashtables math ;" " H{ { 1 2 } { 3 4 } } [ sq ] { } assoc-map-as ." "{ { 1 4 } { 3 16 } }" } } ; diff --git a/core/assocs/assocs.factor b/core/assocs/assocs.factor index b0509b27cb..58a2a29eb1 100644 --- a/core/assocs/assocs.factor +++ b/core/assocs/assocs.factor @@ -49,43 +49,43 @@ M: assoc assoc-like drop ; inline PRIVATE> -: assoc-find ( assoc quot -- key value ? ) +: assoc-find ( ... assoc quot: ( ... key value -- ... ? ) -- ... key value ? ) (assoc-each) find swap [ first2 t ] [ drop f f f ] if ; inline : key? ( key assoc -- ? ) at* nip ; inline -: assoc-each ( assoc quot -- ) +: assoc-each ( ... assoc quot: ( ... key value -- ... ) -- ... ) (assoc-each) each ; inline -: assoc>map ( assoc quot exemplar -- seq ) +: assoc>map ( ... assoc quot: ( ... key value -- ... elt ) exemplar -- ... seq ) [ collector-for [ assoc-each ] dip ] [ like ] bi ; inline -: assoc-map-as ( assoc quot exemplar -- newassoc ) +: assoc-map-as ( ... assoc quot: ( ... key value -- ... newkey newvalue ) exemplar -- ... newassoc ) [ [ 2array ] compose V{ } assoc>map ] dip assoc-like ; inline -: assoc-map ( assoc quot -- newassoc ) +: assoc-map ( ... assoc quot: ( ... key value -- ... newkey newvalue ) -- ... newassoc ) over assoc-map-as ; inline -: assoc-filter-as ( assoc quot exemplar -- subassoc ) +: assoc-filter-as ( ... assoc quot: ( ... key value -- ... ? ) exemplar -- ... subassoc ) [ (assoc-each) filter ] dip assoc-like ; inline -: assoc-filter ( assoc quot -- subassoc ) +: assoc-filter ( ... assoc quot: ( ... key value -- ... ? ) -- ... subassoc ) over assoc-filter-as ; inline -: assoc-filter! ( assoc quot -- assoc ) +: assoc-filter! ( ... assoc quot: ( ... key value -- ... ? ) -- ... assoc ) [ over [ [ [ drop ] 2bi ] dip [ delete-at ] 2curry unless ] 2curry assoc-each ] [ drop ] 2bi ; inline -: assoc-partition ( assoc quot -- true-assoc false-assoc ) +: assoc-partition ( ... assoc quot: ( ... key value -- ... ? ) -- ... true-assoc false-assoc ) [ (assoc-each) partition ] [ drop ] 2bi [ assoc-like ] curry bi@ ; inline -: assoc-any? ( assoc quot -- ? ) +: assoc-any? ( ... assoc quot: ( ... key value -- ... ? ) -- ... ? ) assoc-find 2nip ; inline -: assoc-all? ( assoc quot -- ? ) +: assoc-all? ( ... assoc quot: ( ... key value -- ... ? ) -- ... ? ) [ not ] compose assoc-any? not ; inline : at ( key assoc -- value/f ) @@ -150,23 +150,23 @@ M: assoc assoc-clone-like ( assoc exemplar -- newassoc ) : substitute ( seq assoc -- newseq ) substituter map ; -: cache ( key assoc quot -- value ) +: cache ( ... key assoc quot: ( ... key -- ... value ) -- ... value ) [ [ at* ] 2keep ] dip [ [ nip call dup ] [ drop ] 3bi set-at ] 3curry [ drop ] prepose unless ; inline -: 2cache ( key1 key2 assoc quot -- value ) +: 2cache ( ... key1 key2 assoc quot: ( ... key1 key2 -- ... value ) -- ... value ) [ 2array ] 2dip [ first2 ] prepose cache ; inline -: change-at ( key assoc quot -- ) +: change-at ( ..a key assoc quot: ( ..a value -- ..b newvalue ) -- ..b ) [ [ at ] dip call ] [ drop ] 3bi set-at ; inline : at+ ( n key assoc -- ) [ 0 or + ] change-at ; inline : inc-at ( key assoc -- ) [ 1 ] 2dip at+ ; inline -: map>assoc ( seq quot exemplar -- assoc ) +: map>assoc ( ... seq quot: ( ... elt -- ... key value ) exemplar -- ... assoc ) [ [ 2array ] compose { } map-as ] dip assoc-like ; inline : extract-keys ( seq assoc -- subassoc ) From 4f91d1fede363922af1361b01ec57b3f14e2c5ca Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 15:11:59 -0700 Subject: [PATCH 686/713] alien.cxx.demangle.libstdcxx: better to use libstdc++ linked into VM --- extra/alien/cxx/demangle/libstdcxx/libstdcxx.factor | 9 --------- 1 file changed, 9 deletions(-) diff --git a/extra/alien/cxx/demangle/libstdcxx/libstdcxx.factor b/extra/alien/cxx/demangle/libstdcxx/libstdcxx.factor index 55a25be09d..403015bad5 100644 --- a/extra/alien/cxx/demangle/libstdcxx/libstdcxx.factor +++ b/extra/alien/cxx/demangle/libstdcxx/libstdcxx.factor @@ -4,15 +4,6 @@ alien.syntax combinators destructors io.encodings.ascii kernel libc locals sequences system ; IN: alien.cxx.demangle.libstdcxx -<< -"libstdc++" { - { [ os macosx? ] [ "/usr/lib/libstdc++.6.0.9.dylib" ] } - { [ os unix? ] [ "/usr/lib/libstdc++.so" ] } -} cond cdecl add-library ->> - -LIBRARY: libstdc++ - FUNCTION: char* __cxa_demangle ( char* mangled_name, char* output_buffer, size_t* length, int* status ) ; ERROR: demangle-memory-allocation-failure ; From 4f2fd501e4b77fc638deeb04f3d53cfcc26322c9 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 15:41:40 -0700 Subject: [PATCH 687/713] source file for testing c++ stuff --- extra/alien/cxx/tests/test.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 extra/alien/cxx/tests/test.cpp diff --git a/extra/alien/cxx/tests/test.cpp b/extra/alien/cxx/tests/test.cpp new file mode 100644 index 0000000000..d4a69958b9 --- /dev/null +++ b/extra/alien/cxx/tests/test.cpp @@ -0,0 +1,31 @@ +namespace Namespace { + int namespaced(int x, int y) { return x + y; } +} + +double toplevel(double x, double y) { return x + y; } +double toplevel(double x, double y, double z) { return x + y + z; } + +class Class +{ + unsigned x; + + Class(); + Class(unsigned _x); + + unsigned member(unsigned y); + unsigned member(unsigned y) const; + + unsigned static_member(unsigned x, unsigned y); +}; + +Class::Class() : x(42) { } +Class::Class(unsigned _x) : x(_x) { } +unsigned Class::member(unsigned y) { return x += y; } +unsigned Class::member(unsigned y) const { return x + y; } +unsigned Class::static_member(unsigned x, unsigned y) { return Class(x).member(y); } + +template +T templated(T x, T y) { return x + y; } + +template int templated(int x, int y); +template double templated(double x, double y); From b7307c2dd6bc6ac164459ed7a0629a3c88fed4f4 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 15:51:32 -0700 Subject: [PATCH 688/713] foundation for abi-generic demangling --- extra/alien/cxx/cxx.factor | 12 ++++++++++++ extra/alien/cxx/demangle/demangle.factor | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 extra/alien/cxx/cxx.factor create mode 100644 extra/alien/cxx/demangle/demangle.factor diff --git a/extra/alien/cxx/cxx.factor b/extra/alien/cxx/cxx.factor new file mode 100644 index 0000000000..7194c5d960 --- /dev/null +++ b/extra/alien/cxx/cxx.factor @@ -0,0 +1,12 @@ +! (c)2010 Joe Groff bsd license +USING: alien kernel ; +IN: alien.cxx + +SINGLETONS: g++ visual-c++ ; +UNION: c++-abi + g++ visual-c++ ; + +GENERIC: c++>c-abi ( c++-abi -- c-abi ) + +M: g++ c++>c-abi drop cdecl ; +M: visual-c++ c++>c-abi drop thiscall ; diff --git a/extra/alien/cxx/demangle/demangle.factor b/extra/alien/cxx/demangle/demangle.factor new file mode 100644 index 0000000000..08cf8343af --- /dev/null +++ b/extra/alien/cxx/demangle/demangle.factor @@ -0,0 +1,12 @@ +! (c)2010 Joe Groff bsd license +USING: alien.cxx kernel ; +QUALIFIED-WITH: alien.cxx.demangle.libstdcxx libstdcxx +IN: alien.cxx.demangle + +GENERIC: c++-symbol? ( mangled-name abi -- ? ) +GENERIC: demangle ( mangled-name abi -- c++-name ) + +M: g++ c++-symbol? + drop libstdcxx:mangled-name? ; +M: g++ demangle + drop libstdcxx:demangle ; From 0f028feb22078c15d684ae4bc5c5e199201cf050 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 15:52:46 -0700 Subject: [PATCH 689/713] get symbols out of a dylib and map the C++ ones to their demangled names --- extra/alien/cxx/scaffold/scaffold.factor | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 extra/alien/cxx/scaffold/scaffold.factor diff --git a/extra/alien/cxx/scaffold/scaffold.factor b/extra/alien/cxx/scaffold/scaffold.factor new file mode 100644 index 0000000000..603d5d065f --- /dev/null +++ b/extra/alien/cxx/scaffold/scaffold.factor @@ -0,0 +1,15 @@ +! (c)2010 Joe Groff bsd license +USING: alien.cxx.demangle assocs combinators fry io.pathnames +kernel macho sequences ; +IN: alien.cxx.scaffold + +: library-symbols ( file -- symbols ) + dup file-extension { + { "dylib" [ dylib-exports ] } + { f [ dylib-exports ] } + } case ; + +: c++-library-symbols ( file abi -- symbols ) + [ library-symbols ] dip + [ '[ _ c++-symbol? ] filter ] + [ '[ dup _ demangle ] H{ } map>assoc ] bi ; From 5b470d8da90401db7c4ebec5d07f44faf1506fc3 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 16:00:11 -0700 Subject: [PATCH 690/713] system-info.linux: use FUNCTION-ALIAS: --- basis/system-info/linux/linux.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/system-info/linux/linux.factor b/basis/system-info/linux/linux.factor index 1a565705fb..9c6f9fbff3 100644 --- a/basis/system-info/linux/linux.factor +++ b/basis/system-info/linux/linux.factor @@ -6,8 +6,8 @@ specialized-arrays ; SPECIALIZED-ARRAY: char IN: system-info.linux -: (uname) ( buf -- int ) - int f "uname" { c-string } alien-invoke ; +FUNCTION-ALIAS: (uname) + int uname ( c-string buf ) ; : uname ( -- seq ) 65536 [ (uname) io-error ] keep From 54015782f3972ea3478959d9169b27e66a223e7c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 16:14:33 -0700 Subject: [PATCH 691/713] document FUNCTION-ALIAS: --- basis/alien/syntax/syntax-docs.factor | 20 ++++++++++++++++---- core/alien/alien-docs.factor | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/basis/alien/syntax/syntax-docs.factor b/basis/alien/syntax/syntax-docs.factor index df20926480..b71d0bd533 100644 --- a/basis/alien/syntax/syntax-docs.factor +++ b/basis/alien/syntax/syntax-docs.factor @@ -26,9 +26,9 @@ HELP: LIBRARY: { $notes "Logical library names are defined with the " { $link add-library } " word." } ; HELP: FUNCTION: -{ $syntax "FUNCTION: return name ( parameters )" } +{ $syntax "FUNCTION: return name ( parameters ) ;" } { $values { "return" "a C return type" } { "name" "a C function name" } { "parameters" "a comma-separated sequence of type/name pairs; " { $snippet "type1 arg1, type2 arg2, ..." } } } -{ $description "Defines a new word " { $snippet "name" } " which calls a C library function with the same name, in the logical library given by the most recent " { $link POSTPONE: LIBRARY: } " declaration." +{ $description "Defines a new word " { $snippet "name" } " which calls the C library function with the same " { $snippet "name" } " in the logical library given by the most recent " { $link POSTPONE: LIBRARY: } " declaration." $nl "The new word must be compiled before being executed." } { $examples @@ -45,11 +45,23 @@ $nl "The answer to the question is 42." } } "Using the " { $link c-string } " type instead of " { $snippet "char*" } " causes the FFI to automatically convert Factor strings to C strings. See " { $link "c-strings" } " for more information on using strings with the FFI." -{ $notes "Note that the parentheses and commas are only syntax sugar and can be omitted; they serve no purpose other than to make the declaration slightly easier to read:" +{ $notes "Note that the parentheses and commas are only syntax sugar and can be omitted; they serve no purpose other than to make the declaration easier to read. The following definitions are equivalent:" { $code "FUNCTION: void glHint ( GLenum target, GLenum mode ) ;" "FUNCTION: void glHint GLenum target GLenum mode ;" -} } ; +} +"To make a Factor word with a name different from the C function, use " { $link POSTPONE: FUNCTION-ALIAS: } "." } ; + +HELP: FUNCTION-ALIAS: +{ $syntax "FUNCTION-ALIAS: factor-name + return c_name ( parameters ) ;" } +{ $values { "factor-name" "a Factor word name" } { "return" "a C return type" } { "name" "a C function name" } { "parameters" "a comma-separated sequence of type/name pairs; " { $snippet "type1 arg1, type2 arg2, ..." } } } +{ $description "Defines a new word " { $snippet "factor-name" } " which calls the C library function named " { $snippet "c_name" } " in the logical library given by the most recent " { $link POSTPONE: LIBRARY: } " declaration." +$nl +"The new word must be compiled before being executed." } +{ $notes "Note that the parentheses and commas are only syntax sugar and can be omitted. They serve no purpose other than to make the declaration easier to read." } ; + +{ POSTPONE: FUNCTION: POSTPONE: FUNCTION-ALIAS: } related-words HELP: TYPEDEF: { $syntax "TYPEDEF: old new" } diff --git a/core/alien/alien-docs.factor b/core/alien/alien-docs.factor index 96eb9002be..178e8a6f71 100644 --- a/core/alien/alien-docs.factor +++ b/core/alien/alien-docs.factor @@ -213,6 +213,7 @@ ARTICLE: "alien-invoke" "Calling C from Factor" { $subsections POSTPONE: LIBRARY: POSTPONE: FUNCTION: + POSTPONE: FUNCTION-ALIAS: } "The above parsing words create word definitions which call a lower-level word; you can use it directly, too:" { $subsections alien-invoke } From bd4e920995e972e7496a59115c6bf25a822a8510 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 14 Apr 2010 17:19:26 -0700 Subject: [PATCH 692/713] compiler.tree.propagation: fix scalability issue with constraints --- .../compiler/tree/propagation/branches/branches.factor | 10 ++++++---- .../tree/propagation/constraints/constraints.factor | 7 +++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/basis/compiler/tree/propagation/branches/branches.factor b/basis/compiler/tree/propagation/branches/branches.factor index 28f34cb425..ef9e4e8f0b 100644 --- a/basis/compiler/tree/propagation/branches/branches.factor +++ b/basis/compiler/tree/propagation/branches/branches.factor @@ -1,8 +1,8 @@ -! Copyright (C) 2008, 2009 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: fry kernel sequences assocs accessors namespaces +USING: fry kernel sequences assocs accessors math.intervals arrays classes.algebra combinators columns -stack-checker.branches locals math +stack-checker.branches locals math namespaces compiler.utilities compiler.tree compiler.tree.combinators @@ -10,6 +10,8 @@ compiler.tree.propagation.info compiler.tree.propagation.nodes compiler.tree.propagation.simple compiler.tree.propagation.constraints ; +FROM: sets => union ; +FROM: assocs => change-at ; IN: compiler.tree.propagation.branches ! For conditionals, an assoc of child node # --> constraint @@ -90,7 +92,7 @@ M: #phi propagate-before ( #phi -- ) bi ; :: update-constraints ( new old -- ) - new [| key value | key old [ value append ] change-at ] assoc-each ; + new [| key value | key old [ value union ] change-at ] assoc-each ; : include-child-constraints ( i -- ) infer-children-data get nth constraints swap at last diff --git a/basis/compiler/tree/propagation/constraints/constraints.factor b/basis/compiler/tree/propagation/constraints/constraints.factor index 617352d699..f9988ba220 100644 --- a/basis/compiler/tree/propagation/constraints/constraints.factor +++ b/basis/compiler/tree/propagation/constraints/constraints.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays assocs math math.intervals kernel accessors sequences namespaces classes classes.algebra @@ -87,8 +87,11 @@ TUPLE: implication p q ; C: --> implication +: maybe-add ( elt seq -- seq' ) + 2dup member? [ nip ] [ swap suffix ] if ; + : assume-implication ( q p -- ) - [ constraints get [ assoc-stack swap suffix ] 2keep last set-at ] + [ constraints get [ assoc-stack maybe-add ] 2keep last set-at ] [ satisfied? [ assume ] [ drop ] if ] 2bi ; M: implication assume* From c392ff27188d89e72025840396836111296e6ee9 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 14 Apr 2010 21:09:16 -0500 Subject: [PATCH 693/713] Working on a CUDA api. Add a hello world program. --- extra/cuda/cuda.factor | 303 +++++++++++++++++++++++++++++++++++----- extra/cuda/ffi/tags.txt | 1 + extra/cuda/hello.cu | 65 +++++++++ extra/cuda/hello.ptx | 71 ++++++++++ 4 files changed, 404 insertions(+), 36 deletions(-) create mode 100644 extra/cuda/hello.cu create mode 100644 extra/cuda/hello.ptx diff --git a/extra/cuda/cuda.factor b/extra/cuda/cuda.factor index 887740d542..6b343fb1cc 100644 --- a/extra/cuda/cuda.factor +++ b/extra/cuda/cuda.factor @@ -1,17 +1,24 @@ ! Copyright (C) 2010 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.data assocs classes.struct -combinators continuations cuda.ffi fry io.backend kernel -sequences ; +USING: accessors alien alien.c-types alien.data alien.parser +alien.strings arrays assocs byte-arrays classes.struct +combinators continuations cuda.ffi destructors fry io +io.backend io.encodings.string io.encodings.utf8 kernel lexer +locals math math.parser namespaces opengl.gl.extensions +prettyprint quotations sequences ; IN: cuda +SYMBOL: cuda-device +SYMBOL: cuda-context +SYMBOL: cuda-module +SYMBOL: cuda-function +SYMBOL: cuda-launcher +SYMBOL: cuda-memory-hashtable + ERROR: throw-cuda-error n ; : cuda-error ( n -- ) - { - { CUDA_SUCCESS [ ] } - [ throw-cuda-error ] - } case ; + dup CUDA_SUCCESS = [ drop ] [ throw-cuda-error ] if ; : cuda-version ( -- n ) int [ cuDriverGetVersion cuda-error ] keep *int ; @@ -19,32 +26,10 @@ ERROR: throw-cuda-error n ; : init-cuda ( -- ) 0 cuInit cuda-error ; -: with-cuda ( quot -- ) - init-cuda [ ] [ ] cleanup ; inline - - [ cuDeviceGetCount cuda-error ] keep *int ; - -: n>cuda-device ( n -- device ) - [ CUdevice ] dip [ cuDeviceGet cuda-error ] 2keep drop *int ; - -: enumerate-cuda-devices ( -- devices ) - #cuda-devices iota [ n>cuda-device ] map ; - -: cuda-device>properties ( device -- properties ) - [ CUdevprop ] dip - [ cuDeviceGetProperties cuda-error ] 2keep drop - CUdevprop memory>struct ; - -: cuda-device-properties ( -- properties ) - enumerate-cuda-devices [ cuda-device>properties ] map ; - -PRIVATE> - -: cuda-devices ( -- assoc ) - enumerate-cuda-devices [ dup cuda-device>properties ] { } map>assoc ; +TUPLE: launcher +{ device integer initial: 0 } +{ device-flags initial: 0 } +path block-shape shared-size grid ; : with-cuda-context ( flags device quot -- ) [ @@ -65,13 +50,259 @@ PRIVATE> [ drop '[ _ cuModuleUnload cuda-error ] ] 2bi [ ] cleanup ; inline -: get-cuda-function ( module string -- function ) +: with-cuda-program ( flags device path quot -- ) + [ dup cuda-device set ] 2dip + '[ + cuda-context set + _ [ + cuda-module set + _ call + ] with-cuda-module + ] with-cuda-context ; inline + +: with-cuda ( launcher quot -- ) + [ + init-cuda + H{ } clone cuda-memory-hashtable + ] 2dip '[ + _ + [ cuda-launcher set ] + [ [ device>> ] [ device-flags>> ] [ path>> ] tri ] bi + _ with-cuda-program + ] with-variable ; inline + + [ cuDeviceGetCount cuda-error ] keep *int ; + +: n>cuda-device ( n -- device ) + [ CUdevice ] dip [ cuDeviceGet cuda-error ] 2keep drop *int ; + +: enumerate-cuda-devices ( -- devices ) + #cuda-devices iota [ n>cuda-device ] map ; + +: cuda-device-properties ( device -- properties ) + [ CUdevprop ] dip + [ cuDeviceGetProperties cuda-error ] 2keep drop + CUdevprop memory>struct ; + +PRIVATE> + +: cuda-devices ( -- assoc ) + enumerate-cuda-devices [ dup cuda-device-properties ] { } map>assoc ; + +: cuda-device-name ( n -- string ) + [ 256 [ ] keep ] dip + [ cuDeviceGetName cuda-error ] + [ 2drop utf8 alien>string ] 3bi ; + +: cuda-device-capability ( n -- pair ) + [ int int ] dip + [ cuDeviceComputeCapability cuda-error ] + [ drop [ *int ] bi@ ] 3bi 2array ; + +: cuda-device-memory ( n -- bytes ) + [ uint ] dip + [ cuDeviceTotalMem cuda-error ] + [ drop *uint ] 2bi ; + +: get-cuda-function* ( module string -- function ) [ CUfunction ] 2dip [ cuModuleGetFunction cuda-error ] 3keep 2drop *void* ; +: get-cuda-function ( string -- function ) + [ cuda-module get ] dip get-cuda-function* ; + +: with-cuda-function ( string quot -- ) + [ + get-cuda-function cuda-function set + ] dip call ; inline + +: launch-function* ( function -- ) cuLaunch cuda-error ; + +: launch-function ( -- ) cuda-function get cuLaunch cuda-error ; + +: launch-function-grid* ( function width height -- ) + cuLaunchGrid cuda-error ; + +: launch-function-grid ( width height -- ) + [ cuda-function get ] 2dip + cuLaunchGrid cuda-error ; + +TUPLE: cuda-memory < disposable ptr length ; + +: ( ptr length -- obj ) + cuda-memory new-disposable + swap >>length + swap >>ptr ; + +: add-cuda-memory ( obj -- obj ) + dup dup ptr>> cuda-memory-hashtable get set-at ; + +: delete-cuda-memory ( obj -- ) + cuda-memory-hashtable delete-at ; + +ERROR: invalid-cuda-memory ptr ; + +: cuda-memory-length ( cuda-memory -- n ) + ptr>> cuda-memory-hashtable get ?at [ + length>> + ] [ + invalid-cuda-memory + ] if ; + +M: cuda-memory byte-length length>> ; + : cuda-malloc ( n -- ptr ) [ CUdeviceptr ] dip - [ cuMemAlloc cuda-error ] 2keep drop *int ; + [ cuMemAlloc cuda-error ] 2keep + [ *int ] dip add-cuda-memory ; -: cuda-free ( ptr -- ) +: cuda-free* ( ptr -- ) cuMemFree cuda-error ; + +M: cuda-memory dispose ( ptr -- ) + ptr>> cuda-free* ; + +: host>device ( dest-ptr src-ptr -- ) + [ ptr>> ] dip dup length cuMemcpyHtoD cuda-error ; + +:: device>host ( ptr -- seq ) + ptr byte-length + [ ptr [ ptr>> ] [ byte-length ] bi cuMemcpyDtoH cuda-error ] keep ; + +: memcpy-device>device ( dest-ptr src-ptr count -- ) + cuMemcpyDtoD cuda-error ; + +: memcpy-device>array ( dest-array dest-index src-ptr count -- ) + cuMemcpyDtoA cuda-error ; + +: memcpy-array>device ( dest-ptr src-array src-index count -- ) + cuMemcpyAtoD cuda-error ; + +: memcpy-array>host ( dest-ptr src-array src-index count -- ) + cuMemcpyAtoH cuda-error ; + +: memcpy-host>array ( dest-array dest-index src-ptr count -- ) + cuMemcpyHtoA cuda-error ; + +: memcpy-array>array ( dest-array dest-index src-array src-ptr count -- ) + cuMemcpyAtoA cuda-error ; + +: cuda-int* ( function offset value -- ) + cuParamSeti cuda-error ; + +: cuda-int ( offset value -- ) + [ cuda-function get ] 2dip cuda-int* ; + +: cuda-float* ( function offset value -- ) + cuParamSetf cuda-error ; + +: cuda-float ( offset value -- ) + [ cuda-function get ] 2dip cuda-float* ; + +: cuda-vector* ( function offset ptr n -- ) + cuParamSetv cuda-error ; + +: cuda-vector ( offset ptr n -- ) + [ cuda-function get ] 3dip cuda-vector* ; + +: param-size* ( function n -- ) + cuParamSetSize cuda-error ; + +: param-size ( n -- ) + [ cuda-function get ] dip param-size* ; + +: malloc-device-string ( string -- n ) + utf8 encode + [ length cuda-malloc ] keep + [ host>device ] [ drop ] 2bi ; + +ERROR: bad-cuda-parameter parameter ; + +:: set-parameters ( seq -- ) + cuda-function get :> function + 0 :> offset! + seq [ + [ offset ] dip + { + { [ dup cuda-memory? ] [ ptr>> cuda-int ] } + { [ dup float? ] [ cuda-float ] } + { [ dup integer? ] [ cuda-int ] } + [ bad-cuda-parameter ] + } cond + offset 4 + offset! + ] each + offset param-size ; + +: cuda-device-attribute ( attribute dev -- n ) + [ int ] 2dip + [ cuDeviceGetAttribute cuda-error ] + [ 2drop *int ] 3bi ; + +: function-block-shape* ( function x y z -- ) + cuFuncSetBlockShape cuda-error ; + +: function-block-shape ( x y z -- ) + [ cuda-function get ] 3dip + cuFuncSetBlockShape cuda-error ; + +: function-shared-size* ( function n -- ) + cuFuncSetSharedSize cuda-error ; + +: function-shared-size ( n -- ) + [ cuda-function get ] dip + cuFuncSetSharedSize cuda-error ; + +: launch ( -- ) + cuda-launcher get { + [ block-shape>> first3 function-block-shape ] + [ shared-size>> function-shared-size ] + [ + grid>> [ + launch-function + ] [ + first2 launch-function-grid + ] if-empty + ] + } cleave ; + +: cuda-device. ( n -- ) + { + [ "Device: " write number>string print ] + [ "Name: " write cuda-device-name print ] + [ "Memory: " write cuda-device-memory number>string print ] + [ + "Capability: " write + cuda-device-capability [ number>string ] map " " join print + ] + [ "Properties: " write cuda-device-properties . ] + [ + "CU_DEVICE_ATTRIBUTE_GPU_OVERLAP: " write + CU_DEVICE_ATTRIBUTE_GPU_OVERLAP swap + cuda-device-attribute number>string print + ] + } cleave ; + +: cuda. ( -- ) + "CUDA Version: " write cuda-version number>string print nl + #cuda-devices iota [ nl ] [ cuda-device. ] interleave ; + + +: test-cuda0 ( -- ) + T{ launcher + { path "vocab:cuda/hello.ptx" } + { block-shape { 6 6 6 } } + { shared-size 2 } + { grid { 2 6 } } + } [ + "helloWorld" [ + "Hello World!" [ - ] map-index + malloc-device-string &dispose + + [ 1array set-parameters ] + [ drop launch ] + [ device>host utf8 alien>string . ] tri + ] with-cuda-function + ] with-cuda ; diff --git a/extra/cuda/ffi/tags.txt b/extra/cuda/ffi/tags.txt index 700f0dc9a5..f74dbeec64 100644 --- a/extra/cuda/ffi/tags.txt +++ b/extra/cuda/ffi/tags.txt @@ -1 +1,2 @@ not tested +bindings diff --git a/extra/cuda/hello.cu b/extra/cuda/hello.cu new file mode 100644 index 0000000000..1f3cd677f9 --- /dev/null +++ b/extra/cuda/hello.cu @@ -0,0 +1,65 @@ +/* + World using CUDA +** +** The string "Hello World!" is mangled then restored using a common CUDA idiom +** +** Byron Galbraith +** 2009-02-18 +*/ +#include +#include + +// Prototypes +extern "C" __global__ void helloWorld(char*); + +// Host function +int +main(int argc, char** argv) +{ + int i; + + // desired output + char str[] = "Hello World!"; + + // mangle contents of output + // the null character is left intact for simplicity + for(i = 0; i < 12; i++) + str[i] -= i; + + // allocate memory on the device + char *d_str; + size_t size = sizeof(str); + cudaMalloc((void**)&d_str, size); + + // copy the string to the device + cudaMemcpy(d_str, str, size, cudaMemcpyHostToDevice); + + // set the grid and block sizes + dim3 dimGrid(2); // one block per word + dim3 dimBlock(6); // one thread per character + + // invoke the kernel + helloWorld<<< dimGrid, dimBlock >>>(d_str); + + // retrieve the results from the device + cudaMemcpy(str, d_str, size, cudaMemcpyDeviceToHost); + + // free up the allocated memory on the device + cudaFree(d_str); + + // everyone's favorite part + printf("%s\n", str); + + return 0; +} + +// Device kernel +__global__ void +helloWorld(char* str) +{ + // determine where in the thread grid we are + int idx = blockIdx.x * blockDim.x + threadIdx.x; + + // unmangle output + str[idx] += idx; +} diff --git a/extra/cuda/hello.ptx b/extra/cuda/hello.ptx new file mode 100644 index 0000000000..049bb5e9a5 --- /dev/null +++ b/extra/cuda/hello.ptx @@ -0,0 +1,71 @@ + .version 1.4 + .target sm_10, map_f64_to_f32 + // compiled with /usr/local/cuda/bin/../open64/lib//be + // nvopencc 3.0 built on 2010-03-11 + + //----------------------------------------------------------- + // Compiling /tmp/tmpxft_00000eab_00000000-7_hello.cpp3.i (/var/folders/KD/KDnx4D80Eh0fsORqNrFWBE+++TI/-Tmp-/ccBI#.AYqbdQ) + //----------------------------------------------------------- + + //----------------------------------------------------------- + // Options: + //----------------------------------------------------------- + // Target:ptx, ISA:sm_10, Endian:little, Pointer Size:32 + // -O3 (Optimization level) + // -g0 (Debug level) + // -m2 (Report advisories) + //----------------------------------------------------------- + + .file 1 "" + .file 2 "/tmp/tmpxft_00000eab_00000000-6_hello.cudafe2.gpu" + .file 3 "/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/stddef.h" + .file 4 "/usr/local/cuda/bin/../include/crt/device_runtime.h" + .file 5 "/usr/local/cuda/bin/../include/host_defines.h" + .file 6 "/usr/local/cuda/bin/../include/builtin_types.h" + .file 7 "/usr/local/cuda/bin/../include/device_types.h" + .file 8 "/usr/local/cuda/bin/../include/driver_types.h" + .file 9 "/usr/local/cuda/bin/../include/texture_types.h" + .file 10 "/usr/local/cuda/bin/../include/vector_types.h" + .file 11 "/usr/local/cuda/bin/../include/device_launch_parameters.h" + .file 12 "/usr/local/cuda/bin/../include/crt/storage_class.h" + .file 13 "/usr/include/i386/_types.h" + .file 14 "/usr/include/time.h" + .file 15 "/usr/local/cuda/bin/../include/texture_fetch_functions.h" + .file 16 "/usr/local/cuda/bin/../include/common_functions.h" + .file 17 "/usr/local/cuda/bin/../include/crt/func_macro.h" + .file 18 "/usr/local/cuda/bin/../include/math_functions.h" + .file 19 "/usr/local/cuda/bin/../include/device_functions.h" + .file 20 "/usr/local/cuda/bin/../include/math_constants.h" + .file 21 "/usr/local/cuda/bin/../include/sm_11_atomic_functions.h" + .file 22 "/usr/local/cuda/bin/../include/sm_12_atomic_functions.h" + .file 23 "/usr/local/cuda/bin/../include/sm_13_double_functions.h" + .file 24 "/usr/local/cuda/bin/../include/common_types.h" + .file 25 "/usr/local/cuda/bin/../include/sm_20_atomic_functions.h" + .file 26 "/usr/local/cuda/bin/../include/sm_20_intrinsics.h" + .file 27 "/usr/local/cuda/bin/../include/math_functions_dbl_ptx1.h" + .file 28 "hello.cu" + + + .entry helloWorld ( + .param .u32 __cudaparm_helloWorld_str) + { + .reg .u16 %rh<4>; + .reg .u32 %r<9>; + .loc 28 58 0 +$LBB1_helloWorld: + .loc 28 64 0 + mov.u16 %rh1, %ctaid.x; + mov.u16 %rh2, %ntid.x; + mul.wide.u16 %r1, %rh1, %rh2; + cvt.u32.u16 %r2, %tid.x; + add.u32 %r3, %r2, %r1; + ld.param.u32 %r4, [__cudaparm_helloWorld_str]; + add.u32 %r5, %r4, %r3; + ld.global.s8 %r6, [%r5+0]; + add.s32 %r7, %r6, %r3; + st.global.s8 [%r5+0], %r7; + .loc 28 65 0 + exit; +$LDWend_helloWorld: + } // helloWorld + From c595c4a151f3859543dbf0ad7e3a88aebcf1230b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 21:34:32 -0700 Subject: [PATCH 694/713] x11.syntax: update X-FUNCTION: for FUNCTION: refactoring --- basis/x11/syntax/syntax.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/x11/syntax/syntax.factor b/basis/x11/syntax/syntax.factor index db2adab5dc..5e368f79cb 100644 --- a/basis/x11/syntax/syntax.factor +++ b/basis/x11/syntax/syntax.factor @@ -4,6 +4,6 @@ USING: alien.syntax alien.parser words x11.io sequences kernel ; IN: x11.syntax SYNTAX: X-FUNCTION: - (FUNCTION:) + (FUNCTION:) make-function [ \ awaken-event-loop suffix ] dip - define-declared ; \ No newline at end of file + define-declared ; From 37784cd35630119fb818f8e5fc0023ea28fc962f Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 21:40:29 -0700 Subject: [PATCH 695/713] rearrange stuff in alien.arrays and alien.data to eliminate libc dependency from alien.arrays, and by extension, alien.syntax --- basis/alien/arrays/arrays.factor | 11 +++-------- basis/alien/data/data.factor | 8 +++++++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/basis/alien/arrays/arrays.factor b/basis/alien/arrays/arrays.factor index ce6eb85245..e112a38d25 100644 --- a/basis/alien/arrays/arrays.factor +++ b/basis/alien/arrays/arrays.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien alien.strings alien.c-types alien.data alien.accessors +USING: alien alien.strings alien.c-types alien.accessors arrays words sequences math kernel namespaces fry cpu.architecture -io.encodings.binary io.encodings.utf8 accessors ; +io.encodings.binary io.encodings.utf8 accessors compiler.units ; IN: alien.arrays INSTANCE: array value-type @@ -34,11 +34,6 @@ M: array box-return drop void* box-return ; M: array stack-size drop void* stack-size ; -M: array c-type-boxer-quot - unclip [ array-length ] dip [ ] 2curry ; - -M: array c-type-unboxer-quot drop [ >c-ptr ] ; - PREDICATE: string-type < pair first2 [ c-string = ] [ word? ] bi* and ; @@ -100,5 +95,5 @@ M: string-type c-type-getter M: string-type c-type-setter drop [ set-alien-cell ] ; -{ c-string utf8 } c-string typedef +[ { c-string utf8 } c-string typedef ] with-compilation-unit diff --git a/basis/alien/data/data.factor b/basis/alien/data/data.factor index 2d572e9f13..a0450d5122 100644 --- a/basis/alien/data/data.factor +++ b/basis/alien/data/data.factor @@ -1,5 +1,5 @@ ! (c)2009, 2010 Slava Pestov, Joe Groff bsd license -USING: accessors alien alien.c-types alien.strings arrays +USING: accessors alien alien.c-types alien.arrays alien.strings arrays byte-arrays cpu.architecture fry io io.encodings.binary io.files io.streams.memory kernel libc math sequences words byte-vectors ; @@ -78,3 +78,9 @@ M: value-type c-type-getter M: value-type c-type-setter ( type -- quot ) [ c-type-getter ] [ c-type-unboxer-quot ] [ heap-size ] tri '[ @ swap @ _ memcpy ] ; + +M: array c-type-boxer-quot + unclip [ array-length ] dip [ ] 2curry ; + +M: array c-type-unboxer-quot drop [ >c-ptr ] ; + From 1c99d0cae017fbda0d424f71309e3d53329599fb Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 21:50:30 -0700 Subject: [PATCH 696/713] update libc to use FUNCTION: and FUNCTION-ALIAS: --- basis/libc/libc.factor | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/basis/libc/libc.factor b/basis/libc/libc.factor index 27d7555d67..5495ec2705 100644 --- a/basis/libc/libc.factor +++ b/basis/libc/libc.factor @@ -2,15 +2,18 @@ ! Copyright (C) 2007, 2010 Slava Pestov ! Copyright (C) 2007, 2008 Doug Coleman ! See http://factorcode.org/license.txt for BSD license. -USING: alien alien.c-types assocs continuations alien.destructors kernel -namespaces accessors sets summary destructors destructors.private ; +USING: alien alien.c-types alien.syntax assocs continuations +alien.destructors kernel namespaces accessors sets summary +destructors destructors.private ; IN: libc -: errno ( -- int ) - int "factor" "err_no" { } alien-invoke ; +LIBRARY: factor -: set-errno ( int -- ) - void "factor" "set_err_no" { int } alien-invoke ; +FUNCTION-ALIAS: errno + int err_no ( ) ; + +FUNCTION-ALIAS: set-errno + void set_err_no ( int err-no ) ; : clear-errno ( -- ) 0 set-errno ; @@ -18,17 +21,19 @@ IN: libc : preserve-errno ( quot -- ) errno [ call ] dip set-errno ; inline -: (malloc) ( size -- alien ) - void* "libc" "malloc" { ulong } alien-invoke ; +LIBRARY: libc -: (calloc) ( count size -- alien ) - void* "libc" "calloc" { ulong ulong } alien-invoke ; +FUNCTION-ALIAS: (malloc) + void* malloc ( ulong size ) ; -: (free) ( alien -- ) - void "libc" "free" { void* } alien-invoke ; +FUNCTION-ALIAS: (calloc) + void* calloc ( ulong count, ulong size ) ; -: (realloc) ( alien size -- newalien ) - void* "libc" "realloc" { void* ulong } alien-invoke ; +FUNCTION-ALIAS: (free) + void free ( void* alien ) ; + +FUNCTION-ALIAS: (realloc) + void* realloc ( void* alien, ulong size ) ; : free ( alien -- ) >c-ptr [ delete-malloc ] [ (free) ] bi ; -: memcpy ( dst src size -- ) - void "libc" "memcpy" { void* void* ulong } alien-invoke ; +FUNCTION: void memcpy ( void* dst, void* src, ulong size ) ; -: memcmp ( a b size -- cmp ) - int "libc" "memcmp" { void* void* ulong } alien-invoke ; +FUNCTION: int memcmp ( void* a, void* b, ulong size ) ; : memory= ( a b size -- ? ) memcmp 0 = ; -: strlen ( alien -- len ) - size_t "libc" "strlen" { c-string } alien-invoke ; +FUNCTION: size_t strlen ( c-string alien ) ; DESTRUCTOR: free DESTRUCTOR: (free) From f40b313be5724d687431d164646d2d8585ab5a5a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 14 Apr 2010 19:00:37 -0700 Subject: [PATCH 697/713] sequences: 'accumulate' now outputs a sequence of the same type as its input --- core/sequences/sequences-docs.factor | 2 +- core/sequences/sequences-tests.factor | 3 +++ core/sequences/sequences.factor | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 8d6ddf1be9..f7f774ad86 100644 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -286,7 +286,7 @@ $nl HELP: accumulate { $values { "seq" sequence } { "identity" object } { "quot" { $quotation "( ... prev elt -- ... next )" } } { "final" "the final result" } { "newseq" "a new array" } } -{ $description "Combines successive elements of the sequence using a binary operation, and outputs an array of intermediate results, together with the final result." +{ $description "Combines successive elements of the sequence using a binary operation, and outputs a sequence of intermediate results, together with the final result." $nl "The first element of the new sequence is " { $snippet "identity" } ". Then, on the first iteration, the two inputs to the quotation are " { $snippet "identity" } ", and the first element of the old sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the corresponding element of the old sequence." $nl diff --git a/core/sequences/sequences-tests.factor b/core/sequences/sequences-tests.factor index 665e7a7ada..175ab252e1 100644 --- a/core/sequences/sequences-tests.factor +++ b/core/sequences/sequences-tests.factor @@ -24,6 +24,9 @@ IN: sequences.tests [ 5040 { 1 1 2 6 24 120 720 } ] [ { 1 2 3 4 5 6 7 } 1 [ * ] accumulate ] unit-test +[ 64 B{ 1 2 4 16 } ] +[ B{ 2 2 4 4 } 1 [ * ] accumulate ] unit-test + [ 5040 { 1 1 2 6 24 120 720 } ] [ { 1 2 3 4 5 6 7 } 1 [ * ] accumulate! ] unit-test diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 02c5d0ac72..d9c234e717 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -436,7 +436,7 @@ PRIVATE> [ (accumulate) ] dip map-as ; inline : accumulate ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... final newseq ) - { } accumulate-as ; inline + pick accumulate-as ; inline : accumulate! ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... final seq ) (accumulate) map! ; inline From b87171ff0000bb2183ba62a89ebf9ee37ec646a0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 14 Apr 2010 21:49:41 -0700 Subject: [PATCH 698/713] benchmark.fasta: make it about 2x faster --- extra/benchmark/fasta/fasta.factor | 39 ++++++++++++++---------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/extra/benchmark/fasta/fasta.factor b/extra/benchmark/fasta/fasta.factor index bd7ccafb9f..226287974f 100644 --- a/extra/benchmark/fasta/fasta.factor +++ b/extra/benchmark/fasta/fasta.factor @@ -1,8 +1,9 @@ ! Based on http://shootout.alioth.debian.org/gp4/benchmark.php?test=fasta&lang=java&id=2 -USING: alien.c-types math kernel io io.files locals multiline -assocs sequences sequences.private benchmark.reverse-complement -hints io.encodings.ascii byte-arrays specialized-arrays ; -SPECIALIZED-ARRAY: double +USING: assocs benchmark.reverse-complement byte-arrays fry io +io.encodings.ascii io.files locals kernel math sequences +sequences.private specialized-arrays strings typed ; +QUALIFIED-WITH: alien.c-types c +SPECIALIZED-ARRAY: c:double IN: benchmark.fasta CONSTANT: IM 139968 @@ -11,10 +12,8 @@ CONSTANT: IC 29573 CONSTANT: initial-seed 42 CONSTANT: line-length 60 -: random ( seed -- n seed ) - >float IA * IC + IM mod [ IM /f ] keep ; inline - -HINTS: random fixnum ; +: random ( seed -- seed n ) + >float IA * IC + IM mod dup IM /f ; inline CONSTANT: ALU "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA" @@ -46,34 +45,32 @@ CONSTANT: homo-sapiens { CHAR: t 0.3015094502008 } } -: make-cumulative ( freq -- chars floats ) +TYPED: make-cumulative ( freq -- chars: byte-array floats: double-array ) [ keys >byte-array ] - [ values >double-array ] bi unclip [ + ] accumulate swap suffix ; + [ values >double-array unclip [ + ] accumulate swap suffix ] bi ; :: select-random ( seed chars floats -- seed elt ) - floats seed random -rot - [ >= ] curry find drop - chars nth-unsafe ; inline + seed random floats [ <= ] with find drop chars nth-unsafe ; inline -: make-random-fasta ( seed len chars floats -- seed ) - [ iota ] 2dip [ [ drop ] 2dip select-random ] 2curry "" map-as print ; inline +TYPED: make-random-fasta ( seed: fixnum len: fixnum chars: byte-array floats: double-array -- seed: fixnum ) + '[ _ _ select-random ] "" replicate-as print ; : write-description ( desc id -- ) - ">" write write bl print ; inline + ">" write write bl print ; :: split-lines ( n quot -- ) n line-length /mod [ [ line-length quot call ] times ] dip quot unless-zero ; inline -: write-random-fasta ( seed n chars floats desc id -- seed ) +TYPED: write-random-fasta ( seed: fixnum n: fixnum chars: byte-array floats: double-array desc id -- seed: fixnum ) write-description - [ make-random-fasta ] 2curry split-lines ; inline + '[ _ _ make-random-fasta ] split-lines ; -:: make-repeat-fasta ( k len alu -- k' ) +TYPED:: make-repeat-fasta ( k: fixnum len: fixnum alu: string -- k': fixnum ) alu length :> kn len iota [ k + kn mod alu nth-unsafe ] "" map-as print - k len + ; inline + k len + ; : write-repeat-fasta ( n alu desc id -- ) write-description @@ -81,7 +78,7 @@ CONSTANT: homo-sapiens :> alu 0 :> k! [| len | k len alu make-repeat-fasta k! ] split-lines - ] ; inline + ] ; : fasta ( n out -- ) homo-sapiens make-cumulative From 008ec8f40f71973dd7297262100070e5a1b4ca2b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 14 Apr 2010 21:50:00 -0700 Subject: [PATCH 699/713] benchmark.knucleotide: small performance improvement from using virtual sequences --- extra/benchmark/knucleotide/knucleotide.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/benchmark/knucleotide/knucleotide.factor b/extra/benchmark/knucleotide/knucleotide.factor index f03e26675e..4e4ec72271 100644 --- a/extra/benchmark/knucleotide/knucleotide.factor +++ b/extra/benchmark/knucleotide/knucleotide.factor @@ -14,7 +14,7 @@ IN: benchmark.knucleotide CHAR: \n swap remove >upper ; : handle-table ( inputs n -- ) - clump + [ histogram >alist sort-values reverse ] [ length ] bi '[ [ first write bl ] @@ -22,7 +22,7 @@ IN: benchmark.knucleotide ] each ; : handle-n ( input x -- ) - [ nip ] [ length clump histogram ] 2bi at 0 or "%d\t" printf ; + [ nip ] [ length histogram ] 2bi at 0 or "%d\t" printf ; : process-input ( input -- ) [ 1 handle-table nl ] From 829b7c89041c4f79fb42846e6941eb7c21726399 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 14 Apr 2010 21:50:17 -0700 Subject: [PATCH 700/713] benchmark.spectral-norm: use unsafe sequence ops again, use TYPED: instead of HINTS: --- extra/benchmark/spectral-norm/spectral-norm.factor | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/extra/benchmark/spectral-norm/spectral-norm.factor b/extra/benchmark/spectral-norm/spectral-norm.factor index 386ffb0ae1..93fb8cb562 100644 --- a/extra/benchmark/spectral-norm/spectral-norm.factor +++ b/extra/benchmark/spectral-norm/spectral-norm.factor @@ -1,8 +1,8 @@ ! Factor port of ! http://shootout.alioth.debian.org/gp4/benchmark.php?test=spectralnorm&lang=all USING: alien.c-types specialized-arrays kernel math -math.functions math.vectors sequences prettyprint words hints -locals ; +math.functions math.vectors sequences sequences.private +prettyprint words typed locals ; SPECIALIZED-ARRAY: double IN: benchmark.spectral-norm @@ -19,13 +19,13 @@ IN: benchmark.spectral-norm + 1 + recip ; inline : (eval-A-times-u) ( u i j -- x ) - [ swap nth ] [ eval-A ] bi-curry bi* * ; inline + [ swap nth-unsafe ] [ eval-A ] bi-curry bi* * ; inline : eval-A-times-u ( n u -- seq ) [ (eval-A-times-u) ] inner-loop ; inline : (eval-At-times-u) ( u i j -- x ) - [ swap nth ] [ swap eval-A ] bi-curry bi* * ; inline + [ swap nth-unsafe ] [ swap eval-A ] bi-curry bi* * ; inline : eval-At-times-u ( u n -- seq ) [ (eval-At-times-u) ] inner-loop ; inline @@ -43,11 +43,9 @@ IN: benchmark.spectral-norm [ n eval-AtA-times-u ] keep ] times ; inline -: spectral-norm ( n -- norm ) +TYPED: spectral-norm ( n: fixnum -- norm ) u/v [ v. ] [ norm-sq ] bi /f sqrt ; -HINTS: spectral-norm fixnum ; - : spectral-norm-main ( -- ) 2000 spectral-norm . ; From 06d91b239f0e450c59f2ea870838285cf536e6a5 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 14 Apr 2010 21:50:23 -0700 Subject: [PATCH 701/713] elf.nm: fix load error --- extra/elf/nm/nm-docs.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extra/elf/nm/nm-docs.factor b/extra/elf/nm/nm-docs.factor index a7b7ad426e..31ca3debf4 100644 --- a/extra/elf/nm/nm-docs.factor +++ b/extra/elf/nm/nm-docs.factor @@ -3,7 +3,7 @@ USING: elf help.markup help.syntax ; IN: elf.nm -HELP: nm +HELP: elf-nm { $values { "path" "a pathname string" } } @@ -17,6 +17,7 @@ HELP: print-symbol ARTICLE: "elf.nm" "ELF nm" "The " { $vocab-link "elf.nm" } " vocab prints the values, sections and names of the symbols in a given ELF file. In an ELF executable or shared library, the symbol values are typically their virtual addresses. In a relocatable ELF object, they are section-relative offsets." +{ $subsections elf-nm } ; ABOUT: "elf.nm" From 343856307e98cece7a8a4289d0185fb0345be8b8 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 21:58:52 -0700 Subject: [PATCH 702/713] db.sqlite.ffi: use FUNCTION-ALIAS: --- basis/db/sqlite/ffi/ffi.factor | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/basis/db/sqlite/ffi/ffi.factor b/basis/db/sqlite/ffi/ffi.factor index d9da317c89..c06581e1a2 100644 --- a/basis/db/sqlite/ffi/ffi.factor +++ b/basis/db/sqlite/ffi/ffi.factor @@ -119,9 +119,8 @@ FUNCTION: int sqlite3_bind_double ( sqlite3_stmt* pStmt, int index, double x ) ; FUNCTION: int sqlite3_bind_int ( sqlite3_stmt* pStmt, int index, int n ) ; FUNCTION: int sqlite3_bind_int64 ( sqlite3_stmt* pStmt, int index, sqlite3_int64 n ) ; ! Bind the same function as above, but for unsigned 64bit integers -: sqlite3-bind-uint64 ( pStmt index in64 -- int ) - int "sqlite" "sqlite3_bind_int64" - { pointer: sqlite3_stmt int sqlite3_uint64 } alien-invoke ; +FUNCTION-ALIAS: sqlite3-bind-uint64 ( pStmt index in64 -- int ) + int sqlite3_bind_int64 ( sqlite3_stmt* pStmt, int index, sqlite3_uint64 in64 ) ; FUNCTION: int sqlite3_bind_null ( sqlite3_stmt* pStmt, int n ) ; FUNCTION: int sqlite3_bind_text ( sqlite3_stmt* pStmt, int index, c-string text, int len, int destructor ) ; FUNCTION: int sqlite3_bind_parameter_index ( sqlite3_stmt* pStmt, c-string name ) ; @@ -133,9 +132,8 @@ FUNCTION: c-string sqlite3_column_decltype ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: int sqlite3_column_int ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: sqlite3_int64 sqlite3_column_int64 ( sqlite3_stmt* pStmt, int col ) ; ! Bind the same function as above, but for unsigned 64bit integers -: sqlite3-column-uint64 ( pStmt col -- uint64 ) - sqlite3_uint64 "sqlite" "sqlite3_column_int64" - { pointer: sqlite3_stmt int } alien-invoke ; +FUNCTION-ALIAS: sqlite3-column-uint64 ( pStmt col -- uint64 ) + sqlite3_uint64 sqlite3_column_int64 ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: double sqlite3_column_double ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: c-string sqlite3_column_name ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: c-string sqlite3_column_text ( sqlite3_stmt* pStmt, int col ) ; From ba2fa96eebd7b65590ad53c2f28863c55aa569a7 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 14 Apr 2010 22:04:04 -0700 Subject: [PATCH 703/713] unix: don't hack _exit to have a terminating effect; just use FUNCTION: --- basis/io/launcher/unix/unix.factor | 13 +++++++------ basis/unix/unix.factor | 4 +--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/basis/io/launcher/unix/unix.factor b/basis/io/launcher/unix/unix.factor index aaaccd4719..87af808df2 100644 --- a/basis/io/launcher/unix/unix.factor +++ b/basis/io/launcher/unix/unix.factor @@ -68,12 +68,13 @@ IN: io.launcher.unix ] when ; : spawn-process ( process -- * ) - [ setup-priority ] [ 250 _exit ] recover - [ setup-redirection ] [ 251 _exit ] recover - [ current-directory get absolute-path cd ] [ 252 _exit ] recover - [ setup-environment ] [ 253 _exit ] recover - [ get-arguments exec-args-with-path ] [ 254 _exit ] recover - 255 _exit ; + [ setup-priority ] [ 2drop 250 _exit ] recover + [ setup-redirection ] [ 2drop 251 _exit ] recover + [ current-directory get absolute-path cd ] [ 2drop 252 _exit ] recover + [ setup-environment ] [ 2drop 253 _exit ] recover + [ get-arguments exec-args-with-path ] [ 2drop 254 _exit ] recover + 255 _exit + f throw ; M: unix current-process-handle ( -- handle ) getpid ; diff --git a/basis/unix/unix.factor b/basis/unix/unix.factor index e747e48433..dbbfbcce6e 100644 --- a/basis/unix/unix.factor +++ b/basis/unix/unix.factor @@ -50,9 +50,7 @@ HOOK: open-file os ( path flags mode -- fd ) : close-file ( fd -- ) [ close ] unix-system-call drop ; -: _exit ( status -- * ) - #! We throw to give this a terminating stack effect. - int f "_exit" { int } alien-invoke "Exit failed" throw ; +FUNCTION: int _exit ( int status ) ; M: unix open-file [ open ] unix-system-call ; From 6556311115326993c853dc40cadef8845c542dfb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 14 Apr 2010 22:08:47 -0700 Subject: [PATCH 704/713] mason: fix --- extra/mason/mason.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/mason/mason.factor b/extra/mason/mason.factor index 9732c03dfa..3afa56290b 100755 --- a/extra/mason/mason.factor +++ b/extra/mason/mason.factor @@ -15,9 +15,9 @@ IN: mason error. flush ; : build-loop ( -- ) - notify-heartbeat ?prepare-build-machine [ + notify-heartbeat [ builds/factor set-current-directory new-code-available? [ build ] when From aaacd2a34942ec870ee0b2d220722d8722a31f2d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 14 Apr 2010 22:45:30 -0700 Subject: [PATCH 705/713] unix.process: use if-zero instead of re-inventing it --- basis/unix/process/process.factor | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/basis/unix/process/process.factor b/basis/unix/process/process.factor index 4b33c37d07..1e9129af58 100644 --- a/basis/unix/process/process.factor +++ b/basis/unix/process/process.factor @@ -36,8 +36,7 @@ FUNCTION: int execve ( c-string path, c-string* argv, c-string* envp ) ; [ [ first ] [ ] bi ] dip exec-with-env ; : with-fork ( child parent -- ) - [ [ fork-process dup zero? ] dip '[ drop @ ] ] dip - if ; inline + [ fork-process ] 2dip if-zero ; inline CONSTANT: SIGKILL 9 CONSTANT: SIGTERM 15 From d8c26b7d876a29bf3a0cb697a60e9a38e93ab6e5 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Thu, 15 Apr 2010 01:20:57 -0700 Subject: [PATCH 706/713] Fat binary loading --- extra/macho/a2.macho | Bin 0 -> 12888 bytes extra/macho/macho-tests.factor | 10 ++++++++-- extra/macho/macho.factor | 31 ++++++++++++++++++++++++++----- 3 files changed, 34 insertions(+), 7 deletions(-) create mode 100755 extra/macho/a2.macho diff --git a/extra/macho/a2.macho b/extra/macho/a2.macho new file mode 100755 index 0000000000000000000000000000000000000000..ed9a3a9a278bdaf8c3236ad2b96012df6d46c7dc GIT binary patch literal 12888 zcmeHN-)me&6h1dun^co@+Xs!<=vG=9Y)L9YsbFCv4cX9A*Cs7NlyNtElU=#lUGCmZ zH$rhCC_g-C-8+-Ln{CqCQA{E3J-jz~{aq+28j@yQuveMpup0u}*_fJML}U=gqgSOhEr76FTZ zMZh9p5%?bF#1@EzQj zXlED$C^bDkGu_@j)Ti4aPFlv?@YXg+qsAGP! zwZJcx=XIx@>rHEW{kolUoZ8lo2Bqrd%cXKbmCAFKP;Q@JR@_+4g7oB8#F_}P8=)lXIxgw%k5@wP|wdyi*j7woMSVbQdPe)58TvZ&aZW@H?8dr zYX!=D4(>%t6>>qY)w&bEqPCaPT`0%*p`{s>TF?Et$@6E&&rF(U76#h(0WxVuFP7^J z+rwIT67gO+q01pl;r$YmPeI0?%phxk(+v0IJIFlKpB@r<4;<%2vPdNMVd7YOk<6Z> z*g+papZ#_cUJK#4e6C09HGkAA?JBat+iwQwV*J2?AXZ35#UhDvy=XR0B-agxdO>) z)0v@&b<%;hW9%M7rG|WFtj4FIUo-2o1p!)NpfD#UJ$2|-1Gh=NXfpQ-Zc&> z$B{VBFy=&hgq0*NLP4Q_qLOo@79+inEOQ)>!aMzys7za`nJs? zU=gqgSOhEr76FTZMZh9p5wHkY1S|p;fqxf){b{Ate50WduC7(eIj dup [ "resource:extra/macho/a.macho" macho-nm ] with-output-stream >string ] unit-test + +{ t } [ + "resource:extra/macho/a2.macho" [ + >c-ptr fat-binary-members first data>> >c-ptr macho-header 64-bit? + ] with-mapped-macho +] unit-test diff --git a/extra/macho/macho.factor b/extra/macho/macho.factor index 79cb59c148..70dc594e07 100644 --- a/extra/macho/macho.factor +++ b/extra/macho/macho.factor @@ -4,7 +4,7 @@ USING: accessors alien alien.c-types alien.strings alien.syntax classes classes.struct combinators combinators.short-circuit io.encodings.ascii io.encodings.string kernel literals make math sequences specialized-arrays typed fry io.mmap formatting -locals splitting ; +locals splitting io.binary arrays ; FROM: alien.c-types => short ; IN: macho @@ -812,7 +812,7 @@ C-ENUM: reloc_type_ppc PPC_RELOC_LOCAL_SECTDIFF ; ! Low-level interface -SPECIALIZED-ARRAYS: section section_64 nlist nlist_64 ; +SPECIALIZED-ARRAYS: section section_64 nlist nlist_64 fat_arch uchar ; UNION: mach_header_32/64 mach_header mach_header_64 ; UNION: segment_command_32/64 segment_command segment_command_64 ; UNION: load-command segment_command segment_command_64 @@ -826,6 +826,26 @@ UNION: section_32/64-array section-array section_64-array ; UNION: nlist_32/64 nlist nlist_64 ; UNION: nlist_32/64-array nlist-array nlist_64-array ; +TUPLE: fat-binary-member cpu-type cpu-subtype data ; +ERROR: not-fat-binary ; + +TYPED: fat-binary-members ( >c-ptr -- fat-binary-members ) + fat_header memory>struct dup magic>> { + { FAT_MAGIC [ ] } + { FAT_CIGAM [ ] } + [ 2drop not-fat-binary ] + } case dup + [ >c-ptr fat_header heap-size swap ] + [ nfat_arch>> 4 >be le> ] bi + [ + { + [ nip cputype>> 4 >be le> ] + [ nip cpusubtype>> 4 >be le> ] + [ offset>> 4 >be le> swap >c-ptr ] + [ nip size>> 4 >be le> ] + } 2cleave fat-binary-member boa + ] with { } map-as ; + TYPED: 64-bit? ( macho: mach_header_32/64 -- ? ) magic>> { { MH_MAGIC_64 [ t ] } @@ -924,12 +944,13 @@ TYPED: load-commands ( macho: mach_header_32/64 -- load-commands ) : macho-nm ( path -- ) [| macho | macho load-commands segment-commands sections-array :> sections - macho load-commands symtab-commands [| symtab | macho symtab symbols [ [ drop n_value>> "%016x " printf ] - [ drop n_sect>> sections nth sectname>> - read-array-string "%-16s" printf ] + [ + drop n_sect>> sections nth sectname>> + read-array-string "%-16s" printf + ] [ symbol-name "%s\n" printf ] 2tri ] curry each ] each From 5f71d2bb18feccc76022b3a623a0f816108bc3e8 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 15 Apr 2010 11:27:33 -0700 Subject: [PATCH 707/713] db.sqlite.ffi: remove leftover stack effects from converted FUNCTION-ALIAS:es --- basis/db/sqlite/ffi/ffi.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/db/sqlite/ffi/ffi.factor b/basis/db/sqlite/ffi/ffi.factor index c06581e1a2..b5f9020ce9 100644 --- a/basis/db/sqlite/ffi/ffi.factor +++ b/basis/db/sqlite/ffi/ffi.factor @@ -119,7 +119,7 @@ FUNCTION: int sqlite3_bind_double ( sqlite3_stmt* pStmt, int index, double x ) ; FUNCTION: int sqlite3_bind_int ( sqlite3_stmt* pStmt, int index, int n ) ; FUNCTION: int sqlite3_bind_int64 ( sqlite3_stmt* pStmt, int index, sqlite3_int64 n ) ; ! Bind the same function as above, but for unsigned 64bit integers -FUNCTION-ALIAS: sqlite3-bind-uint64 ( pStmt index in64 -- int ) +FUNCTION-ALIAS: sqlite3-bind-uint64 int sqlite3_bind_int64 ( sqlite3_stmt* pStmt, int index, sqlite3_uint64 in64 ) ; FUNCTION: int sqlite3_bind_null ( sqlite3_stmt* pStmt, int n ) ; FUNCTION: int sqlite3_bind_text ( sqlite3_stmt* pStmt, int index, c-string text, int len, int destructor ) ; @@ -132,7 +132,7 @@ FUNCTION: c-string sqlite3_column_decltype ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: int sqlite3_column_int ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: sqlite3_int64 sqlite3_column_int64 ( sqlite3_stmt* pStmt, int col ) ; ! Bind the same function as above, but for unsigned 64bit integers -FUNCTION-ALIAS: sqlite3-column-uint64 ( pStmt col -- uint64 ) +FUNCTION-ALIAS: sqlite3-column-uint64 sqlite3_uint64 sqlite3_column_int64 ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: double sqlite3_column_double ( sqlite3_stmt* pStmt, int col ) ; FUNCTION: c-string sqlite3_column_name ( sqlite3_stmt* pStmt, int col ) ; From f26bf45b4a45e7342bd5225287b0afff5d7ad133 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 15 Apr 2010 13:48:13 -0500 Subject: [PATCH 708/713] formatting: fix unit tests on Windows; libc's float formatting produces different output there --- basis/formatting/formatting-tests.factor | 148 +++++++++++------------ 1 file changed, 74 insertions(+), 74 deletions(-) mode change 100644 => 100755 basis/formatting/formatting-tests.factor diff --git a/basis/formatting/formatting-tests.factor b/basis/formatting/formatting-tests.factor old mode 100644 new mode 100755 index 35b1dfff4a..740babf866 --- a/basis/formatting/formatting-tests.factor +++ b/basis/formatting/formatting-tests.factor @@ -1,83 +1,85 @@ ! Copyright (C) 2008 John Benediktsson ! See http://factorcode.org/license.txt for BSD license -USING: calendar kernel formatting tools.test ; +USING: calendar kernel formatting tools.test system ; IN: formatting.tests [ "%s" printf ] must-infer [ "%s" sprintf ] must-infer -[ t ] [ "" "" sprintf = ] unit-test -[ t ] [ "asdf" "asdf" sprintf = ] unit-test -[ t ] [ "10" 10 "%d" sprintf = ] unit-test -[ t ] [ "+10" 10 "%+d" sprintf = ] unit-test -[ t ] [ "-10" -10 "%d" sprintf = ] unit-test -[ t ] [ " -10" -10 "%5d" sprintf = ] unit-test -[ t ] [ "-0010" -10 "%05d" sprintf = ] unit-test -[ t ] [ "+0010" 10 "%+05d" sprintf = ] unit-test -[ t ] [ "123.456000" 123.456 "%f" sprintf = ] unit-test -[ t ] [ "2.44" 2.436 "%.2f" sprintf = ] unit-test -[ t ] [ "8.950" 8.950179003580072 "%.3f" sprintf = ] unit-test -[ t ] [ "123.10" 123.1 "%01.2f" sprintf = ] unit-test -[ t ] [ "1.2346" 1.23456789 "%.4f" sprintf = ] unit-test -[ t ] [ " 1.23" 1.23456789 "%6.2f" sprintf = ] unit-test -[ t ] [ "1.234000e+08" 123400000 "%e" sprintf = ] unit-test -[ t ] [ "-1.234000e+08" -123400000 "%e" sprintf = ] unit-test -[ t ] [ "1.234567e+08" 123456700 "%e" sprintf = ] unit-test -[ t ] [ "3.625e+08" 362525200 "%.3e" sprintf = ] unit-test -[ t ] [ "2.500000e-03" 0.0025 "%e" sprintf = ] unit-test -[ t ] [ "2.500000E-03" 0.0025 "%E" sprintf = ] unit-test -[ t ] [ " 1.0E+01" 10 "%10.1E" sprintf = ] unit-test -[ t ] [ " -1.0E+01" -10 "%10.1E" sprintf = ] unit-test -[ t ] [ " -1.0E+01" -10 "%+10.1E" sprintf = ] unit-test -[ t ] [ " +1.0E+01" 10 "%+10.1E" sprintf = ] unit-test -[ t ] [ "-001.0E+01" -10 "%+010.1E" sprintf = ] unit-test -[ t ] [ "+001.0E+01" 10 "%+010.1E" sprintf = ] unit-test -[ t ] [ "ff" HEX: ff "%x" sprintf = ] unit-test -[ t ] [ "FF" HEX: ff "%X" sprintf = ] unit-test -[ t ] [ "0f" HEX: f "%02x" sprintf = ] unit-test -[ t ] [ "0F" HEX: f "%02X" sprintf = ] unit-test -[ t ] [ "2008-09-10" - 2008 9 10 "%04d-%02d-%02d" sprintf = ] unit-test -[ t ] [ "Hello, World!" - "Hello, World!" "%s" sprintf = ] unit-test -[ t ] [ "printf test" - "printf test" sprintf = ] unit-test -[ t ] [ "char a = 'a'" - CHAR: a "char %c = 'a'" sprintf = ] unit-test -[ t ] [ "00" HEX: 0 "%02x" sprintf = ] unit-test -[ t ] [ "ff" HEX: ff "%02x" sprintf = ] unit-test -[ t ] [ "0 message(s)" - 0 "message" "%d %s(s)" sprintf = ] unit-test -[ t ] [ "0 message(s) with %" - 0 "message" "%d %s(s) with %%" sprintf = ] unit-test -[ t ] [ "justif: \"left \"" - "left" "justif: \"%-10s\"" sprintf = ] unit-test -[ t ] [ "justif: \" right\"" - "right" "justif: \"%10s\"" sprintf = ] unit-test -[ t ] [ " 3: 0003 zero padded" - 3 " 3: %04d zero padded" sprintf = ] unit-test -[ t ] [ " 3: 3 left justif" - 3 " 3: %-4d left justif" sprintf = ] unit-test -[ t ] [ " 3: 3 right justif" - 3 " 3: %4d right justif" sprintf = ] unit-test -[ t ] [ " -3: -003 zero padded" - -3 " -3: %04d zero padded" sprintf = ] unit-test -[ t ] [ " -3: -3 left justif" - -3 " -3: %-4d left justif" sprintf = ] unit-test -[ t ] [ " -3: -3 right justif" - -3 " -3: %4d right justif" sprintf = ] unit-test -[ t ] [ "There are 10 monkeys in the kitchen" - 10 "kitchen" "There are %d monkeys in the %s" sprintf = ] unit-test -[ f ] [ "%d" 10 "%d" sprintf = ] unit-test -[ t ] [ "[monkey]" "monkey" "[%s]" sprintf = ] unit-test -[ t ] [ "[ monkey]" "monkey" "[%10s]" sprintf = ] unit-test -[ t ] [ "[monkey ]" "monkey" "[%-10s]" sprintf = ] unit-test -[ t ] [ "[0000monkey]" "monkey" "[%010s]" sprintf = ] unit-test -[ t ] [ "[####monkey]" "monkey" "[%'#10s]" sprintf = ] unit-test -[ t ] [ "[many monke]" "many monkeys" "[%10.10s]" sprintf = ] unit-test +[ "" ] [ "" sprintf ] unit-test +[ "asdf" ] [ "asdf" sprintf ] unit-test +[ "10" ] [ 10 "%d" sprintf ] unit-test +[ "+10" ] [ 10 "%+d" sprintf ] unit-test +[ "-10" ] [ -10 "%d" sprintf ] unit-test +[ " -10" ] [ -10 "%5d" sprintf ] unit-test +[ "-0010" ] [ -10 "%05d" sprintf ] unit-test +[ "+0010" ] [ 10 "%+05d" sprintf ] unit-test +[ "123.456000" ] [ 123.456 "%f" sprintf ] unit-test +[ "2.44" ] [ 2.436 "%.2f" sprintf ] unit-test +[ "8.950" ] [ 8.950179003580072 "%.3f" sprintf ] unit-test +[ "123.10" ] [ 123.1 "%01.2f" sprintf ] unit-test +[ "1.2346" ] [ 1.23456789 "%.4f" sprintf ] unit-test +[ " 1.23" ] [ 1.23456789 "%6.2f" sprintf ] unit-test -[ t ] [ "{ 1, 2, 3 }" { 1 2 3 } "%[%s, %]" sprintf = ] unit-test -[ t ] [ "{ 1:2, 3:4 }" H{ { 1 2 } { 3 4 } } "%[%s: %s %]" sprintf = ] unit-test +os windows? [ + [ "1.234000e+008" ] [ 123400000 "%e" sprintf ] unit-test + [ "-1.234000e+008" ] [ -123400000 "%e" sprintf ] unit-test + [ "1.234567e+008" ] [ 123456700 "%e" sprintf ] unit-test + [ "3.625e+008" ] [ 362525200 "%.3e" sprintf ] unit-test + [ "2.500000e-003" ] [ 0.0025 "%e" sprintf ] unit-test + [ "2.500000E-003" ] [ 0.0025 "%E" sprintf ] unit-test + [ " 1.0E+001" ] [ 10 "%11.1E" sprintf ] unit-test + [ " -1.0E+001" ] [ -10 "%11.1E" sprintf ] unit-test + [ " -1.0E+001" ] [ -10 "%+11.1E" sprintf ] unit-test + [ " +1.0E+001" ] [ 10 "%+11.1E" sprintf ] unit-test + [ "-001.0E+001" ] [ -10 "%+011.1E" sprintf ] unit-test + [ "+001.0E+001" ] [ 10 "%+011.1E" sprintf ] unit-test +] [ + [ "1.234000e+08" ] [ 123400000 "%e" sprintf ] unit-test + [ "-1.234000e+08" ] [ -123400000 "%e" sprintf ] unit-test + [ "1.234567e+08" ] [ 123456700 "%e" sprintf ] unit-test + [ "3.625e+08" ] [ 362525200 "%.3e" sprintf ] unit-test + [ "2.500000e-03" ] [ 0.0025 "%e" sprintf ] unit-test + [ "2.500000E-03" ] [ 0.0025 "%E" sprintf ] unit-test + [ " 1.0E+01" ] [ 10 "%10.1E" sprintf ] unit-test + [ " -1.0E+01" ] [ -10 "%10.1E" sprintf ] unit-test + [ " -1.0E+01" ] [ -10 "%+10.1E" sprintf ] unit-test + [ " +1.0E+01" ] [ 10 "%+10.1E" sprintf ] unit-test + [ "-001.0E+01" ] [ -10 "%+010.1E" sprintf ] unit-test + [ "+001.0E+01" ] [ 10 "%+010.1E" sprintf ] unit-test +] if + +[ "ff" ] [ HEX: ff "%x" sprintf ] unit-test +[ "FF" ] [ HEX: ff "%X" sprintf ] unit-test +[ "0f" ] [ HEX: f "%02x" sprintf ] unit-test +[ "0F" ] [ HEX: f "%02X" sprintf ] unit-test +[ "2008-09-10" ] [ 2008 9 10 "%04d-%02d-%02d" sprintf ] unit-test +[ "Hello, World!" ] [ "Hello, World!" "%s" sprintf ] unit-test +[ "printf test" ] [ "printf test" sprintf ] unit-test +[ "char a = 'a'" ] [ CHAR: a "char %c = 'a'" sprintf ] unit-test +[ "00" ] [ HEX: 0 "%02x" sprintf ] unit-test +[ "ff" ] [ HEX: ff "%02x" sprintf ] unit-test +[ "0 message(s)" ] [ 0 "message" "%d %s(s)" sprintf ] unit-test +[ "0 message(s) with %" ] [ 0 "message" "%d %s(s) with %%" sprintf ] unit-test +[ "justif: \"left \"" ] [ "left" "justif: \"%-10s\"" sprintf ] unit-test +[ "justif: \" right\"" ] [ "right" "justif: \"%10s\"" sprintf ] unit-test +[ " 3: 0003 zero padded" ] [ 3 " 3: %04d zero padded" sprintf ] unit-test +[ " 3: 3 left justif" ] [ 3 " 3: %-4d left justif" sprintf ] unit-test +[ " 3: 3 right justif" ] [ 3 " 3: %4d right justif" sprintf ] unit-test +[ " -3: -003 zero padded" ] [ -3 " -3: %04d zero padded" sprintf ] unit-test +[ " -3: -3 left justif" ] [ -3 " -3: %-4d left justif" sprintf ] unit-test +[ " -3: -3 right justif" ] [ -3 " -3: %4d right justif" sprintf ] unit-test +[ "There are 10 monkeys in the kitchen" ] [ 10 "kitchen" "There are %d monkeys in the %s" sprintf ] unit-test +[ "10" ] [ 10 "%d" sprintf ] unit-test +[ "[monkey]" ] [ "monkey" "[%s]" sprintf ] unit-test +[ "[ monkey]" ] [ "monkey" "[%10s]" sprintf ] unit-test +[ "[monkey ]" ] [ "monkey" "[%-10s]" sprintf ] unit-test +[ "[0000monkey]" ] [ "monkey" "[%010s]" sprintf ] unit-test +[ "[####monkey]" ] [ "monkey" "[%'#10s]" sprintf ] unit-test +[ "[many monke]" ] [ "many monkeys" "[%10.10s]" sprintf ] unit-test + +[ "{ 1, 2, 3 }" ] [ { 1 2 3 } "%[%s, %]" sprintf ] unit-test +[ "{ 1:2, 3:4 }" ] [ H{ { 1 2 } { 3 4 } } "%[%s: %s %]" sprintf ] unit-test [ "%H:%M:%S" strftime ] must-infer @@ -96,5 +98,3 @@ IN: formatting.tests [ t ] [ "October" testtime "%B" strftime = ] unit-test [ t ] [ "Thu Oct 09 12:03:15 2008" testtime "%c" strftime = ] unit-test [ t ] [ "PM" testtime "%p" strftime = ] unit-test - - From feb62f3e883ffc32cbe6ea1bd842a8bd191c3010 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 15 Apr 2010 13:48:14 -0700 Subject: [PATCH 709/713] missing USING: for system-info.linux --- basis/system-info/linux/linux.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/system-info/linux/linux.factor b/basis/system-info/linux/linux.factor index 9c6f9fbff3..2eb395b8d1 100644 --- a/basis/system-info/linux/linux.factor +++ b/basis/system-info/linux/linux.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: unix alien alien.c-types kernel math sequences strings io.backend.unix splitting io.encodings.utf8 io.encodings.string -specialized-arrays ; +specialized-arrays alien.syntax ; SPECIALIZED-ARRAY: char IN: system-info.linux From 2ace3c59560bca2f546bbfbdf1fb9123b8e96729 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 15 Apr 2010 16:06:44 -0500 Subject: [PATCH 710/713] formatting: remove platform-specific example --- basis/formatting/formatting-docs.factor | 4 ---- 1 file changed, 4 deletions(-) mode change 100644 => 100755 basis/formatting/formatting-docs.factor diff --git a/basis/formatting/formatting-docs.factor b/basis/formatting/formatting-docs.factor old mode 100644 new mode 100755 index 9625c40577..100c88c4eb --- a/basis/formatting/formatting-docs.factor +++ b/basis/formatting/formatting-docs.factor @@ -62,10 +62,6 @@ HELP: printf "USING: formatting ;" "1.23456789 \"%.3f\" printf" "1.235" } - { $example - "USING: formatting ;" - "1234567890 \"%.5e\" printf" - "1.23457e+09" } { $example "USING: formatting ;" "12 \"%'#4d\" printf" From 8f56108702e7294e695a8babf5902eccf4f37bb7 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 15 Apr 2010 14:46:13 -0700 Subject: [PATCH 711/713] cuda.ffi: add CUDA versions of double, longlong, ulonglong that always 8-byte align, and a >cuda-param-type function we can use to make structs that match kernel param space layout --- extra/cuda/ffi/ffi.factor | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/extra/cuda/ffi/ffi.factor b/extra/cuda/ffi/ffi.factor index 3d41f1e4c5..b7efeff9fb 100644 --- a/extra/cuda/ffi/ffi.factor +++ b/extra/cuda/ffi/ffi.factor @@ -1,6 +1,6 @@ ! (c)2010 Joe Groff bsd license -USING: alien alien.c-types alien.libraries alien.syntax -classes.struct combinators system ; +USING: accessors alien alien.c-types alien.libraries alien.syntax +classes.struct combinators kernel system ; IN: cuda.ffi << @@ -24,6 +24,28 @@ TYPEDEF: void* CUevent TYPEDEF: void* CUstream TYPEDEF: void* CUgraphicsResource +! versions of double and longlong that always 8-byte align + +SYMBOLS: CUdouble CUlonglong CUulonglong ; + +: >cuda-param-type ( c-type -- c-type' ) + { + { CUdeviceptr [ void* ] } + { double [ CUdouble ] } + { longlong [ CUlonglong ] } + { ulonglong [ CUulonglong ] } + [ ] + } case ; + +<< +: always-8-byte-align ( c-type -- c-type ) + 8 >>align 8 >>align-first ; + +longlong c-type clone always-8-byte-align \ CUlonglong typedef +ulonglong c-type clone always-8-byte-align \ CUulonglong typedef +double c-type clone always-8-byte-align \ CUdouble typedef +>> + STRUCT: CUuuid { bytes char[16] } ; From 34771c8e10d102d27e9c863ff618bc397c9d0598 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 15 Apr 2010 17:19:20 -0500 Subject: [PATCH 712/713] benchmark.fasta: tweak it a bit --- extra/benchmark/fasta/fasta.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extra/benchmark/fasta/fasta.factor b/extra/benchmark/fasta/fasta.factor index 226287974f..8c06716ddb 100644 --- a/extra/benchmark/fasta/fasta.factor +++ b/extra/benchmark/fasta/fasta.factor @@ -13,7 +13,7 @@ CONSTANT: initial-seed 42 CONSTANT: line-length 60 : random ( seed -- seed n ) - >float IA * IC + IM mod dup IM /f ; inline + IA * IC + IM mod dup IM /f ; inline CONSTANT: ALU "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA" @@ -52,7 +52,7 @@ TYPED: make-cumulative ( freq -- chars: byte-array floats: double-array ) :: select-random ( seed chars floats -- seed elt ) seed random floats [ <= ] with find drop chars nth-unsafe ; inline -TYPED: make-random-fasta ( seed: fixnum len: fixnum chars: byte-array floats: double-array -- seed: fixnum ) +TYPED: make-random-fasta ( seed: float len: fixnum chars: byte-array floats: double-array -- seed: float ) '[ _ _ select-random ] "" replicate-as print ; : write-description ( desc id -- ) @@ -63,7 +63,7 @@ TYPED: make-random-fasta ( seed: fixnum len: fixnum chars: byte-array floats: do [ [ line-length quot call ] times ] dip quot unless-zero ; inline -TYPED: write-random-fasta ( seed: fixnum n: fixnum chars: byte-array floats: double-array desc id -- seed: fixnum ) +TYPED: write-random-fasta ( seed: float n: fixnum chars: byte-array floats: double-array desc id -- seed: float ) write-description '[ _ _ make-random-fasta ] split-lines ; From ccda46921f446e74c56adac03013925f115cf224 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Thu, 15 Apr 2010 16:31:37 -0700 Subject: [PATCH 713/713] Don't run mach-o and elf tests on ppc until endian issue sorted out --- extra/elf/elf-tests.factor | 4 +++- extra/elf/nm/nm-tests.factor | 12 +++++++----- extra/macho/macho-tests.factor | 22 ++++++++++++---------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/extra/elf/elf-tests.factor b/extra/elf/elf-tests.factor index d68885e6b7..4d1bb5be06 100644 --- a/extra/elf/elf-tests.factor +++ b/extra/elf/elf-tests.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors byte-arrays elf kernel sequences tools.test ; +USING: accessors byte-arrays elf kernel sequences system tools.test ; IN: elf.tests +cpu ppc? [ { { "" @@ -178,3 +179,4 @@ unit-test ] with-mapped-elf ] unit-test +] unless diff --git a/extra/elf/nm/nm-tests.factor b/extra/elf/nm/nm-tests.factor index 9e529ae43d..90d9634750 100644 --- a/extra/elf/nm/nm-tests.factor +++ b/extra/elf/nm/nm-tests.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. -USING: elf.nm io io.streams.string kernel multiline strings tools.test -literals ; +USING: elf.nm io io.streams.string kernel literals multiline strings +system tools.test ; IN: elf.nm.tests STRING: validation-output @@ -46,6 +46,8 @@ STRING: validation-output ; -{ $ validation-output } -[ dup [ "resource:extra/elf/a.elf" elf-nm ] with-output-stream >string ] -unit-test +cpu ppc? [ + { $ validation-output } + [ dup [ "resource:extra/elf/a.elf" elf-nm ] with-output-stream >string ] + unit-test +] unless diff --git a/extra/macho/macho-tests.factor b/extra/macho/macho-tests.factor index d52eb778f6..561a98cd70 100644 --- a/extra/macho/macho-tests.factor +++ b/extra/macho/macho-tests.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien io io.streams.string kernel literals macho -multiline sequences strings tools.test ; +multiline sequences strings system tools.test ; IN: macho.tests STRING: validation-output @@ -21,12 +21,14 @@ STRING: validation-output ; -{ $ validation-output } -[ dup [ "resource:extra/macho/a.macho" macho-nm ] with-output-stream >string ] -unit-test - -{ t } [ - "resource:extra/macho/a2.macho" [ - >c-ptr fat-binary-members first data>> >c-ptr macho-header 64-bit? - ] with-mapped-macho -] unit-test +cpu ppc? [ + { $ validation-output } + [ dup [ "resource:extra/macho/a.macho" macho-nm ] with-output-stream >string ] + unit-test + + { t } [ + "resource:extra/macho/a2.macho" [ + >c-ptr fat-binary-members first data>> >c-ptr macho-header 64-bit? + ] with-mapped-macho + ] unit-test +] unless