From b3080178c6d07718c24f1a03c85c5d8f48d67023 Mon Sep 17 00:00:00 2001 From: Philipp Winkler Date: Mon, 23 Mar 2009 12:39:03 -0700 Subject: [PATCH 01/36] Add a missing step to the tutorial. --- basis/help/tutorial/tutorial.factor | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/basis/help/tutorial/tutorial.factor b/basis/help/tutorial/tutorial.factor index 7ec155881b..26812947c0 100644 --- a/basis/help/tutorial/tutorial.factor +++ b/basis/help/tutorial/tutorial.factor @@ -62,7 +62,9 @@ ARTICLE: "first-program-test" "Testing your first program" "" ": palindrome? ( str -- ? ) dup reverse = ;" } -"We will now test our new word in the listener. First, push a string on the stack:" +"We will now test our new word in the listener. First we have add the palindrome vocabulary to the listener's vocabulary search path:" +{ $code "USE: palindrome"} +"Next, push a string on the stack:" { $code "\"hello\"" } "Note that the stack display in the listener now shows this string. Having supplied the input, we call our word:" { $code "palindrome?" } @@ -132,6 +134,8 @@ $nl $nl "We modify " { $snippet "palindrome?" } " to first apply " { $snippet "normalize" } " to its input:" { $code ": palindrome? ( str -- ? ) normalize dup reverse = ;" } +"Factor compiles the file from the top down. So, be sure to place the definition for " { $snippet "normalize" } " above the definition for " { $snippet "palindrome?" } "." +$nl "Now if you press " { $command tool "common" refresh-all } ", the source file should reload without any errors. You can run unit tests again, and this time, they will all pass:" { $code "\"palindrome\" test" } ; From f061b0531167f949eaeb887332e2662616f9aac0 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 23 Mar 2009 20:32:57 -0500 Subject: [PATCH 02/36] make ecdsa unportable for now --- extra/ecdsa/tags.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 extra/ecdsa/tags.txt diff --git a/extra/ecdsa/tags.txt b/extra/ecdsa/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/extra/ecdsa/tags.txt @@ -0,0 +1 @@ +unportable From 688452fa3d78b1ce6406f7aedcfb3403b5a3b815 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 23 Mar 2009 20:36:44 -0500 Subject: [PATCH 03/36] make multimethods tests pass --- extra/multi-methods/tests/definitions.factor | 2 +- extra/multi-methods/tests/syntax.factor | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extra/multi-methods/tests/definitions.factor b/extra/multi-methods/tests/definitions.factor index 64363af428..240c9f86d7 100644 --- a/extra/multi-methods/tests/definitions.factor +++ b/extra/multi-methods/tests/definitions.factor @@ -26,7 +26,7 @@ DEFER: fake DEFER: testing - [ ] [ \ testing define-generic ] unit-test + [ ] [ \ testing (( -- )) define-generic ] unit-test [ t ] [ \ testing generic? ] unit-test ] with-compilation-unit diff --git a/extra/multi-methods/tests/syntax.factor b/extra/multi-methods/tests/syntax.factor index 9d9c80b214..cc073099d8 100644 --- a/extra/multi-methods/tests/syntax.factor +++ b/extra/multi-methods/tests/syntax.factor @@ -3,7 +3,7 @@ USING: multi-methods tools.test math sequences namespaces system kernel strings definitions prettyprint debugger arrays hashtables continuations classes assocs accessors see ; -GENERIC: first-test +GENERIC: first-test ( -- ) [ t ] [ \ first-test generic? ] unit-test @@ -13,7 +13,7 @@ SINGLETON: paper INSTANCE: paper thing SINGLETON: scissors INSTANCE: scissors thing SINGLETON: rock INSTANCE: rock thing -GENERIC: beats? +GENERIC: beats? ( obj1 obj2 -- ? ) METHOD: beats? { paper scissors } t ; METHOD: beats? { scissors rock } t ; @@ -34,7 +34,7 @@ METHOD: beats? { thing thing } f ; SYMBOL: some-var -GENERIC: hook-test +GENERIC: hook-test ( -- obj ) METHOD: hook-test { array { some-var array } } reverse ; METHOD: hook-test { { some-var array } } class ; @@ -57,7 +57,7 @@ TUPLE: busted-1 ; TUPLE: busted-2 ; INSTANCE: busted-2 busted TUPLE: busted-3 ; -GENERIC: busted-sort +GENERIC: busted-sort ( obj1 obj2 -- obj1 obj2 ) METHOD: busted-sort { busted-1 busted-2 } ; METHOD: busted-sort { busted-2 busted-3 } ; From 7a4a7474e86ca80a5cb1eea60b527f0296e9b28c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 23 Mar 2009 22:33:05 -0500 Subject: [PATCH 04/36] Fix site-watcher tests --- extra/site-watcher/site-watcher-tests.factor | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/extra/site-watcher/site-watcher-tests.factor b/extra/site-watcher/site-watcher-tests.factor index dde5e65e7e..62233587d9 100644 --- a/extra/site-watcher/site-watcher-tests.factor +++ b/extra/site-watcher/site-watcher-tests.factor @@ -2,11 +2,14 @@ ! See http://factorcode.org/license.txt for BSD license. USING: db.tuples locals site-watcher site-watcher.db site-watcher.private kernel db io.directories io.files.temp -continuations db.sqlite site-watcher.db.private ; +continuations site-watcher.db.private db.sqlite +sequences tools.test ; IN: site-watcher.tests +[ "site-watcher.db" temp-file delete-file ] ignore-errors + :: fake-sites ( -- seq ) - [ + "site-watcher.db" temp-file [ account ensure-table site ensure-table watching-site ensure-table @@ -17,5 +20,6 @@ IN: site-watcher.tests "erg@factorcode.org" "http://asdfasdfasdfasdfqwerqqq.com" watch-site f select-tuples - ] with-sqlite-db ; + ] with-db ; +[ f ] [ fake-sites empty? ] unit-test \ No newline at end of file From 862223fa79f68cd883e3d776613c853f79034cc3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 23 Mar 2009 22:36:51 -0500 Subject: [PATCH 05/36] Fix bunny deployment --- basis/tools/deploy/shaker/shaker.factor | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index a729e40e2a..55433299ad 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -204,7 +204,8 @@ IN: tools.deploy.shaker ] when ; : strip-vocab-globals ( except names -- words ) - [ child-vocabs [ words ] map concat ] map concat swap diff ; + [ child-vocabs [ words ] map concat ] map concat + swap [ first2 lookup ] map sift diff ; : stripped-globals ( -- seq ) [ @@ -245,7 +246,8 @@ IN: tools.deploy.shaker strip-dictionary? [ "libraries" "alien" lookup , - { } { "cpu" "compiler" } strip-vocab-globals % + { { "yield-hook" "compiler.utilities" } } + { "cpu" "compiler" } strip-vocab-globals % { gensym From 53369cf5ff497cec81b1208e1d639ba648a04678 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 23 Mar 2009 23:15:53 -0500 Subject: [PATCH 06/36] Round mouse co-ordinates --- basis/cocoa/views/views.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/cocoa/views/views.factor b/basis/cocoa/views/views.factor index 0b8346db4b..3c60a6a7c1 100644 --- a/basis/cocoa/views/views.factor +++ b/basis/cocoa/views/views.factor @@ -89,4 +89,4 @@ PRIVATE> -> locationInWindow f -> convertPoint:fromView: [ CGPoint-x ] [ CGPoint-y ] bi ] [ drop -> frame CGRect-h ] 2bi - swap - 2array ; + swap - [ >integer ] bi@ 2array ; From c6837fbe3ed1b7f98d1d4905da88ed91efee82df Mon Sep 17 00:00:00 2001 From: sheeple Date: Tue, 24 Mar 2009 01:07:38 -0500 Subject: [PATCH 07/36] Update cpu-ppc.S for quotation layout change --- vm/cpu-ppc.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/cpu-ppc.S b/vm/cpu-ppc.S index 30b61b5c0c..8b3141218b 100755 --- a/vm/cpu-ppc.S +++ b/vm/cpu-ppc.S @@ -45,7 +45,7 @@ multiply_overflow: /* Note that the XT is passed to the quotation in r11 */ #define CALL_OR_JUMP_QUOT \ - lwz r11,9(r3) /* load quotation-xt slot */ XX \ + lwz r11,17(r3) /* load quotation-xt slot */ XX \ #define CALL_QUOT \ CALL_OR_JUMP_QUOT XX \ From 5d3c2c874a91c24b96f3d862a41371ebd45cca47 Mon Sep 17 00:00:00 2001 From: "U-SLAVA-DFB8FF805\\Slava" Date: Tue, 24 Mar 2009 03:58:11 -0500 Subject: [PATCH 08/36] Get game-input to load on Windows --- basis/ui/backend/windows/windows.factor | 2 +- basis/windows/dinput/constants/constants.factor | 2 +- basis/windows/dinput/dinput.factor | 6 +++--- extra/game-input/dinput/dinput.factor | 4 ++-- extra/game-input/game-input.factor | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index 54d9ed456a..80dd313e85 100755 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -354,7 +354,7 @@ H{ } clone wm-handlers set-global : add-wm-handler ( quot wm -- ) dup array? - [ [ execute add-wm-handler ] with each ] + [ [ execute( -- wm ) add-wm-handler ] with each ] [ wm-handlers get-global set-at ] if ; [ handle-wm-close 0 ] WM_CLOSE add-wm-handler diff --git a/basis/windows/dinput/constants/constants.factor b/basis/windows/dinput/constants/constants.factor index 314fb167e3..cd1033d418 100755 --- a/basis/windows/dinput/constants/constants.factor +++ b/basis/windows/dinput/constants/constants.factor @@ -832,7 +832,7 @@ SYMBOLS: define-keyboard-format-constant define-hid-keyboard-format-constant ; -: define-constants +: define-constants ( -- ) define-guid-constants define-format-constants ; diff --git a/basis/windows/dinput/dinput.factor b/basis/windows/dinput/dinput.factor index 1cd22beb75..dc544858b6 100755 --- a/basis/windows/dinput/dinput.factor +++ b/basis/windows/dinput/dinput.factor @@ -27,15 +27,15 @@ TYPEDEF: void* LPDIENUMEFFECTSCALLBACKW [ "BOOL" { "LPCDIEFFECTINFOW" "LPVOID" } "stdcall" ] dip alien-callback ; inline TYPEDEF: void* LPDIENUMCREATEDEFFECTOBJECTSCALLBACK -: LPDIENUMCREATEDEFFECTOBJECTSCALLBACK +: LPDIENUMCREATEDEFFECTOBJECTSCALLBACK ( quot -- callback ) [ "BOOL" { "LPDIRECTINPUTEFFECT" "LPVOID" } "stdcall" ] dip alien-callback ; inline TYPEDEF: void* LPDIENUMEFFECTSINFILECALLBACK -: LPDIENUMEFFECTSINFILECALLBACK +: LPDIENUMEFFECTSINFILECALLBACK ( quot -- callback ) [ "BOOL" { "LPCDIFILEEFFECT" "LPVOID" } "stdcall" ] dip alien-callback ; inline TYPEDEF: void* LPDIENUMDEVICEOBJECTSCALLBACKW -: LPDIENUMDEVICEOBJECTSCALLBACKW +: LPDIENUMDEVICEOBJECTSCALLBACKW ( quot -- callback ) [ "BOOL" { "LPCDIDEVICEOBJECTINSTANCEW" "LPVOID" } "stdcall" ] dip alien-callback ; inline diff --git a/extra/game-input/dinput/dinput.factor b/extra/game-input/dinput/dinput.factor index c6004a8221..a2beaf6d9b 100755 --- a/extra/game-input/dinput/dinput.factor +++ b/extra/game-input/dinput/dinput.factor @@ -2,10 +2,10 @@ USING: windows.dinput windows.dinput.constants parser alien.c-types windows.ole32 namespaces assocs kernel arrays vectors windows.kernel32 windows.com windows.dinput shuffle windows.user32 windows.messages sequences combinators locals -math.rectangles ui.windows accessors math windows alien +math.rectangles accessors math windows alien alien.strings io.encodings.utf16 io.encodings.utf16n continuations byte-arrays game-input.dinput.keys-array -game-input ; +game-input ui.backend.windows ; IN: game-input.dinput SINGLETON: dinput-game-input-backend diff --git a/extra/game-input/game-input.factor b/extra/game-input/game-input.factor index 46e3ba9e8d..6efe31861a 100755 --- a/extra/game-input/game-input.factor +++ b/extra/game-input/game-input.factor @@ -35,7 +35,7 @@ PRIVATE> ] when ; : with-game-input ( quot -- ) - open-game-input [ close-game-input ] [ ] cleanup ; + open-game-input [ close-game-input ] [ ] cleanup ; inline TUPLE: controller handle ; TUPLE: controller-state x y z rx ry rz slider pov buttons ; From 637d06a4f85066c70142a0c9d52552601b1bdc65 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 24 Mar 2009 04:11:08 -0500 Subject: [PATCH 09/36] Add silly 'tip of the day' feature, and 'recently visited' list to UI browser home page --- basis/bootstrap/help/help.factor | 2 +- basis/bootstrap/tools/tools.factor | 1 - .../apropos/apropos-docs.factor | 6 ++- basis/help/apropos/apropos-tests.factor | 4 ++ basis/{tools => help}/apropos/apropos.factor | 8 +++- basis/help/handbook/handbook.factor | 14 +++---- basis/help/help-docs.factor | 1 + basis/help/home/authors.txt | 1 + basis/help/home/home-docs.factor | 19 +++++++++ basis/help/home/home.factor | 40 +++++++++++++++++++ basis/help/html/html.factor | 2 +- basis/help/tips/authors.txt | 1 + basis/help/tips/tips-docs.factor | 27 +++++++++++++ basis/help/tips/tips.factor | 38 ++++++++++++++++++ .../browser => help/vocabs}/authors.txt | 0 .../browser => help/vocabs}/summary.txt | 0 .../vocabs/browser => help/vocabs}/tags.txt | 0 .../vocabs/vocabs-docs.factor} | 2 +- basis/help/vocabs/vocabs-tests.factor | 5 +++ .../vocabs/vocabs.factor} | 17 ++++---- basis/tools/apropos/apropos-tests.factor | 4 -- .../tools/vocabs/browser/browser-tests.factor | 5 --- basis/ui/gadgets/editors/editors-docs.factor | 6 ++- basis/ui/tools/browser/browser.factor | 19 ++++----- basis/ui/tools/deploy/deploy-docs.factor | 4 +- .../listener/completion/completion.factor | 2 +- basis/ui/tools/listener/listener-docs.factor | 22 +++++++++- basis/ui/tools/listener/listener.factor | 22 +++++----- .../tools/operations/operations-docs.factor | 8 ++++ basis/ui/tools/operations/operations.factor | 4 +- basis/ui/tools/profiler/profiler-docs.factor | 11 +++++ basis/ui/tools/profiler/profiler.factor | 2 + basis/ui/tools/tools-docs.factor | 5 ++- core/parser/parser.factor | 2 +- core/strings/strings-docs.factor | 2 +- extra/demos/demos.factor | 2 +- extra/fuel/help/help.factor | 2 +- extra/galois-talk/galois-talk.factor | 2 +- .../google-tech-talk/google-tech-talk.factor | 2 +- extra/otug-talk/otug-talk.factor | 2 +- extra/vpri-talk/vpri-talk.factor | 2 +- 41 files changed, 245 insertions(+), 73 deletions(-) rename basis/{tools => help}/apropos/apropos-docs.factor (60%) create mode 100644 basis/help/apropos/apropos-tests.factor rename basis/{tools => help}/apropos/apropos.factor (94%) create mode 100644 basis/help/home/authors.txt create mode 100644 basis/help/home/home-docs.factor create mode 100644 basis/help/home/home.factor create mode 100644 basis/help/tips/authors.txt create mode 100644 basis/help/tips/tips-docs.factor create mode 100644 basis/help/tips/tips.factor rename basis/{tools/vocabs/browser => help/vocabs}/authors.txt (100%) rename basis/{tools/vocabs/browser => help/vocabs}/summary.txt (100%) rename basis/{tools/vocabs/browser => help/vocabs}/tags.txt (100%) rename basis/{tools/vocabs/browser/browser-docs.factor => help/vocabs/vocabs-docs.factor} (94%) create mode 100644 basis/help/vocabs/vocabs-tests.factor rename basis/{tools/vocabs/browser/browser.factor => help/vocabs/vocabs.factor} (96%) delete mode 100644 basis/tools/apropos/apropos-tests.factor delete mode 100644 basis/tools/vocabs/browser/browser-tests.factor create mode 100644 basis/ui/tools/operations/operations-docs.factor create mode 100644 basis/ui/tools/profiler/profiler-docs.factor diff --git a/basis/bootstrap/help/help.factor b/basis/bootstrap/help/help.factor index c3e74f7863..553b91a6ae 100644 --- a/basis/bootstrap/help/help.factor +++ b/basis/bootstrap/help/help.factor @@ -5,7 +5,7 @@ IN: bootstrap.help : load-help ( -- ) "help.lint" require - "tools.vocabs.browser" require + "help.vocabs" require "alien.syntax" require "compiler" require diff --git a/basis/bootstrap/tools/tools.factor b/basis/bootstrap/tools/tools.factor index c6ec7f0b99..b0afe4a1d9 100644 --- a/basis/bootstrap/tools/tools.factor +++ b/basis/bootstrap/tools/tools.factor @@ -14,7 +14,6 @@ IN: bootstrap.tools "tools.time" "tools.threads" "tools.vocabs" - "tools.vocabs.browser" "tools.vocabs.monitor" "editors" } [ require ] each diff --git a/basis/tools/apropos/apropos-docs.factor b/basis/help/apropos/apropos-docs.factor similarity index 60% rename from basis/tools/apropos/apropos-docs.factor rename to basis/help/apropos/apropos-docs.factor index b50b51b84f..4d774a75cb 100644 --- a/basis/tools/apropos/apropos-docs.factor +++ b/basis/help/apropos/apropos-docs.factor @@ -1,6 +1,8 @@ -IN: tools.apropos -USING: help.markup help.syntax strings ; +IN: help.apropos +USING: help.markup help.syntax strings help.tips ; HELP: apropos { $values { "str" string } } { $description "Lists all words, vocabularies and help articles whose name contains a subsequence equal to " { $snippet "str" } ". Results are ranked using a simple distance algorithm." } ; + +TIP: "Use " { $link apropos } " to search for words, vocabularies and help articles." ; \ No newline at end of file diff --git a/basis/help/apropos/apropos-tests.factor b/basis/help/apropos/apropos-tests.factor new file mode 100644 index 0000000000..3dbda475de --- /dev/null +++ b/basis/help/apropos/apropos-tests.factor @@ -0,0 +1,4 @@ +IN: help.apropos.tests +USING: help.apropos tools.test ; + +[ ] [ "swp" apropos ] unit-test diff --git a/basis/tools/apropos/apropos.factor b/basis/help/apropos/apropos.factor similarity index 94% rename from basis/tools/apropos/apropos.factor rename to basis/help/apropos/apropos.factor index c7126c10d0..b241db4c0e 100644 --- a/basis/tools/apropos/apropos.factor +++ b/basis/help/apropos/apropos.factor @@ -2,9 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs fry help.markup help.topics io kernel make math math.parser namespaces sequences sorting -summary tools.completion tools.vocabs tools.vocabs.browser +summary tools.completion tools.vocabs help.vocabs vocabs words unicode.case help ; -IN: tools.apropos +IN: help.apropos : $completions ( seq -- ) dup [ word? ] all? [ words-table ] [ @@ -67,5 +67,9 @@ M: apropos article-name article-title ; M: apropos article-content search>> 1array \ $apropos prefix ; +M: apropos >link ; + +INSTANCE: apropos topic + : apropos ( str -- ) print-topic ; diff --git a/basis/help/handbook/handbook.factor b/basis/help/handbook/handbook.factor index e048b66b7c..ed2a14a2f2 100644 --- a/basis/help/handbook/handbook.factor +++ b/basis/help/handbook/handbook.factor @@ -4,7 +4,7 @@ prettyprint.backend prettyprint.custom kernel.private io generic math system strings sbufs vectors byte-arrays quotations io.streams.byte-array classes.builtin parser lexer classes.predicate classes.union classes.intersection -classes.singleton classes.tuple tools.vocabs.browser math.parser +classes.singleton classes.tuple help.vocabs math.parser accessors ; IN: help.handbook @@ -278,11 +278,7 @@ ARTICLE: "handbook-library-reference" "Library reference" "This index only includes articles from loaded vocabularies. To explore more vocabularies, see " { $link "vocab-index" } "." { $index [ "handbook" orphan-articles remove ] } ; -ARTICLE: "handbook" "Factor documentation" -"Welcome to Factor." -$nl -"Explore the code base:" -{ $subsection "vocab-index" } +ARTICLE: "handbook" "Factor handbook" "Learn the language:" { $subsection "cookbook" } { $subsection "first-program" } @@ -290,11 +286,13 @@ $nl { $subsection "handbook-environment-reference" } { $subsection "ui" } { $subsection "handbook-library-reference" } -"The below indices only include articles from loaded vocabularies. To explore more vocabularies, see " { $link "vocab-index" } "." +"Explore loaded libraries:" { $subsection "article-index" } { $subsection "primitive-index" } { $subsection "error-index" } { $subsection "type-index" } -{ $subsection "class-index" } ; +{ $subsection "class-index" } +"Explore the code base:" +{ $subsection "vocab-index" } ; ABOUT: "handbook" diff --git a/basis/help/help-docs.factor b/basis/help/help-docs.factor index 733199fc60..547ee871aa 100644 --- a/basis/help/help-docs.factor +++ b/basis/help/help-docs.factor @@ -127,6 +127,7 @@ ARTICLE: "help" "Help system" { $subsection "browsing-help" } { $subsection "writing-help" } { $subsection "help.lint" } +{ $subsection "tips-of-the-day" } { $subsection "help-impl" } ; IN: help diff --git a/basis/help/home/authors.txt b/basis/help/home/authors.txt new file mode 100644 index 0000000000..d4f5d6b3ae --- /dev/null +++ b/basis/help/home/authors.txt @@ -0,0 +1 @@ +Slava Pestov \ No newline at end of file diff --git a/basis/help/home/home-docs.factor b/basis/help/home/home-docs.factor new file mode 100644 index 0000000000..d4d8a6206d --- /dev/null +++ b/basis/help/home/home-docs.factor @@ -0,0 +1,19 @@ +IN: help.home +USING: help.markup help.syntax ; + +ARTICLE: "help.home" "Factor documentation" +{ $heading "Starting points" } +{ $list + { $link "ui-listener" } + { $link "handbook" } + { $link "vocab-index" } +} +{ $heading "Recently visited" } +{ $table + { "Words" "Articles" "Vocabs" } + { { $recent recent-words } { $recent recent-articles } { $recent recent-vocabs } } +} print-element +{ $heading "Recent searches" } +{ $recent-searches } ; + +ABOUT: "help.home" \ No newline at end of file diff --git a/basis/help/home/home.factor b/basis/help/home/home.factor new file mode 100644 index 0000000000..b1b938cb45 --- /dev/null +++ b/basis/help/home/home.factor @@ -0,0 +1,40 @@ +! Copyright (C) 2009 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: arrays compiler.units fry hashtables help.topics io +kernel math namespaces sequences sets help.vocabs +help.apropos vocabs help.markup ; +IN: help.home + +SYMBOLS: recent-words recent-articles recent-vocabs recent-searches ; + +CONSTANT: recent-count 10 + +{ recent-words recent-articles recent-vocabs recent-searches } +[ [ V{ } clone ] initialize ] each + +GENERIC: add-recent-where ( obj -- obj symbol ) + +M: link add-recent-where recent-articles ; +M: word-link add-recent-where recent-words ; +M: vocab-spec add-recent-where recent-vocabs ; +M: apropos add-recent-where recent-searches ; +M: object add-recent-where f ; + +: $recent ( element -- ) + first get [ nl ] [ 1array $pretty-link ] interleave ; + +: $recent-searches ( element -- ) + drop recent-searches get [ nl ] [ ($link) ] interleave ; + +: redisplay-recent-page ( -- ) + "help.home" >link dup associate + notify-definition-observers ; + +: expire ( seq -- ) + [ length recent-count - [ 0 > ] keep ] keep + '[ 0 _ _ delete-slice ] when ; + +: add-recent ( obj -- ) + add-recent-where dup + [ get [ adjoin ] [ expire ] bi ] [ 2drop ] if + redisplay-recent-page ; \ No newline at end of file diff --git a/basis/help/html/html.factor b/basis/help/html/html.factor index cbeb8b362e..66d864b2a0 100644 --- a/basis/help/html/html.factor +++ b/basis/help/html/html.factor @@ -3,7 +3,7 @@ USING: io.encodings.utf8 io.encodings.ascii io.encodings.binary io.files io.files.temp io.directories html.streams help kernel assocs sequences make words accessors arrays help.topics vocabs -tools.vocabs tools.vocabs.browser namespaces prettyprint io +tools.vocabs help.vocabs namespaces prettyprint io vocabs.loader serialize fry memoize unicode.case math.order sorting debugger html xml.syntax xml.writer ; IN: help.html diff --git a/basis/help/tips/authors.txt b/basis/help/tips/authors.txt new file mode 100644 index 0000000000..d4f5d6b3ae --- /dev/null +++ b/basis/help/tips/authors.txt @@ -0,0 +1 @@ +Slava Pestov \ No newline at end of file diff --git a/basis/help/tips/tips-docs.factor b/basis/help/tips/tips-docs.factor new file mode 100644 index 0000000000..7148b25a37 --- /dev/null +++ b/basis/help/tips/tips-docs.factor @@ -0,0 +1,27 @@ +IN: help.tips +USING: help.markup help.syntax debugger ; + +TIP: "To look at the most recent error, run " { $link :error } ". To look at the most recent error's callstack, run " { $link :c } "." ; + +TIP: "Learn to use " { $link "dataflow-combinators" } "." ; + +TIP: "Learn to use " { $link "editor" } " to be able to jump to the source code for word definitions from the listener." ; + +TIP: "Check out " { $url "http://concatenative.org/wiki/view/Factor/FAQ" } " to get answers to frequently-asked questions." ; + +TIP: "Drop by the " { $snippet "#concatenative" } " IRC channel on " { $snippet "irc.freenode.net" } " some time." ; + +TIP: "You can write documentation for your own code using the " { $link "help" } "." ; + +TIP: "You can write graphical applications using the " { $link "ui" } "." ; + +ARTICLE: "all-tips-of-the-day" "All tips of the day" +{ $tips-of-the-day } ; + +ARTICLE: "tips-of-the-day" "Tips of the day" +"The " { $vocab-link "help.tips" } " vocabulary provides a facility for displaying tips of the day in the " { $link "ui-listener" } ". Tips are defined with a parsing word:" +{ $subsection POSTPONE: TIP: } +"All tips defined so far:" +{ $subsection "all-tips-of-the-day" } ; + +ABOUT: "tips-of-the-day" \ No newline at end of file diff --git a/basis/help/tips/tips.factor b/basis/help/tips/tips.factor new file mode 100644 index 0000000000..8d173ce533 --- /dev/null +++ b/basis/help/tips/tips.factor @@ -0,0 +1,38 @@ +! Copyright (C) 2009 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: parser arrays namespaces sequences random help.markup kernel io +io.styles colors.constants ; +IN: help.tips + +SYMBOL: tips + +tips [ V{ } clone ] initialize + +SYNTAX: TIP: parse-definition >array tips get push ; + +: a-tip ( -- tip ) tips get random ; + +SYMBOL: tip-of-the-day-style + +H{ + { page-color COLOR: lavender } + { border-width 5 } + { wrap-margin 500 } +} tip-of-the-day-style set-global + +: $tip-of-the-day ( element -- ) + drop + [ + tip-of-the-day-style get + [ + last-element off + "Tip of the day" $heading a-tip print-element nl + "— " print-element "all-tips-of-the-day" ($link) + ] + with-nesting + ] ($heading) ; + +: tip-of-the-day. ( -- ) { $tip-of-the-day } print-content nl ; + +: $tips-of-the-day ( element -- ) + drop tips get [ nl nl ] [ print-element ] interleave ; \ No newline at end of file diff --git a/basis/tools/vocabs/browser/authors.txt b/basis/help/vocabs/authors.txt similarity index 100% rename from basis/tools/vocabs/browser/authors.txt rename to basis/help/vocabs/authors.txt diff --git a/basis/tools/vocabs/browser/summary.txt b/basis/help/vocabs/summary.txt similarity index 100% rename from basis/tools/vocabs/browser/summary.txt rename to basis/help/vocabs/summary.txt diff --git a/basis/tools/vocabs/browser/tags.txt b/basis/help/vocabs/tags.txt similarity index 100% rename from basis/tools/vocabs/browser/tags.txt rename to basis/help/vocabs/tags.txt diff --git a/basis/tools/vocabs/browser/browser-docs.factor b/basis/help/vocabs/vocabs-docs.factor similarity index 94% rename from basis/tools/vocabs/browser/browser-docs.factor rename to basis/help/vocabs/vocabs-docs.factor index 723c4ac483..5f1a97205e 100644 --- a/basis/tools/vocabs/browser/browser-docs.factor +++ b/basis/help/vocabs/vocabs-docs.factor @@ -1,5 +1,5 @@ USING: help.markup help.syntax io strings ; -IN: tools.vocabs.browser +IN: help.vocabs ARTICLE: "vocab-tags" "Vocabulary tags" { $all-tags } ; diff --git a/basis/help/vocabs/vocabs-tests.factor b/basis/help/vocabs/vocabs-tests.factor new file mode 100644 index 0000000000..f03e0b3337 --- /dev/null +++ b/basis/help/vocabs/vocabs-tests.factor @@ -0,0 +1,5 @@ +IN: help.vocabs.tests +USING: help.vocabs tools.test help.markup help vocabs ; + +[ ] [ { $vocab "scratchpad" } print-content ] unit-test +[ ] [ "classes" vocab print-topic ] unit-test \ No newline at end of file diff --git a/basis/tools/vocabs/browser/browser.factor b/basis/help/vocabs/vocabs.factor similarity index 96% rename from basis/tools/vocabs/browser/browser.factor rename to basis/help/vocabs/vocabs.factor index c9ade7aae2..13bb0cdf3e 100644 --- a/basis/tools/vocabs/browser/browser.factor +++ b/basis/help/vocabs/vocabs.factor @@ -6,17 +6,16 @@ classes.singleton classes.tuple classes.union combinators definitions effects fry generic help help.markup help.stylesheet help.topics io io.files io.pathnames io.styles kernel macros make namespaces prettyprint sequences sets sorting summary -tools.vocabs vocabs vocabs.loader words words.symbol -combinators.smart definitions.icons ; -IN: tools.vocabs.browser +tools.vocabs vocabs vocabs.loader words words.symbol definitions.icons ; +IN: help.vocabs + +: $pretty-link ( element -- ) + [ first definition-icon 1array $image " " print-element ] + [ $definition-link ] + bi ; : <$pretty-link> ( definition -- element ) - [ - [ definition-icon 1array \ $image prefix ] - [ drop " " ] - [ 1array \ $definition-link prefix ] - tri - ] output>array ; + 1array \ $pretty-link prefix ; : vocab-row ( vocab -- row ) [ <$pretty-link> ] [ vocab-summary ] bi 2array ; diff --git a/basis/tools/apropos/apropos-tests.factor b/basis/tools/apropos/apropos-tests.factor deleted file mode 100644 index 96ce9d3186..0000000000 --- a/basis/tools/apropos/apropos-tests.factor +++ /dev/null @@ -1,4 +0,0 @@ -IN: tools.apropos.tests -USING: tools.apropos tools.test ; - -[ ] [ "swp" apropos ] unit-test diff --git a/basis/tools/vocabs/browser/browser-tests.factor b/basis/tools/vocabs/browser/browser-tests.factor deleted file mode 100644 index 385d1b2d46..0000000000 --- a/basis/tools/vocabs/browser/browser-tests.factor +++ /dev/null @@ -1,5 +0,0 @@ -IN: tools.vocabs.browser.tests -USING: tools.vocabs.browser tools.test help.markup help vocabs ; - -[ ] [ { $vocab "scratchpad" } print-content ] unit-test -[ ] [ "classes" vocab print-topic ] unit-test \ No newline at end of file diff --git a/basis/ui/gadgets/editors/editors-docs.factor b/basis/ui/gadgets/editors/editors-docs.factor index 244e36d640..0ad37cb10f 100644 --- a/basis/ui/gadgets/editors/editors-docs.factor +++ b/basis/ui/gadgets/editors/editors-docs.factor @@ -1,6 +1,6 @@ USING: documents help.markup help.syntax ui.gadgets ui.gadgets.scrollers models strings ui.commands -ui.text colors fonts ; +ui.text colors fonts help.tips ; IN: ui.gadgets.editors HELP: editor @@ -109,4 +109,8 @@ ARTICLE: "ui.gadgets.editors" "Editor gadgets" "Editors edit " { $emphasis "documents" } ":" { $subsection "documents" } ; +TIP: "Editor gadgets support undo and redo; press " { $command editor "editing" com-undo } " and " { $command editor "editing" com-redo } "." ; + +TIP: "Learn the keyboard shortcuts used in " { $link "ui.gadgets.editors" } "." ; + ABOUT: "ui.gadgets.editors" diff --git a/basis/ui/tools/browser/browser.factor b/basis/ui/tools/browser/browser.factor index 078ece6546..e1dcba9910 100644 --- a/basis/ui/tools/browser/browser.factor +++ b/basis/ui/tools/browser/browser.factor @@ -1,10 +1,11 @@ ! Copyright (C) 2006, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: debugger help help.topics help.crossref kernel models compiler.units -assocs words vocabs accessors fry combinators.short-circuit -sequences models models.history tools.apropos combinators -ui.commands ui.gadgets ui.gadgets.panes ui.gadgets.scrollers -ui.gadgets.tracks ui.gestures ui.gadgets.buttons ui.gadgets.packs +USING: debugger help help.topics help.crossref help.home kernel +models compiler.units assocs words vocabs accessors fry +combinators.short-circuit namespaces sequences models +models.history help.apropos combinators ui.commands ui.gadgets +ui.gadgets.panes ui.gadgets.scrollers ui.gadgets.tracks +ui.gestures ui.gadgets.buttons ui.gadgets.packs ui.gadgets.editors ui.gadgets.labels ui.gadgets.status-bar ui.gadgets.glass ui.gadgets.borders ui.tools.common ui.tools.browser.popups ui ; @@ -15,8 +16,8 @@ TUPLE: browser-gadget < tool pane scroller search-field popup ; { 650 400 } browser-gadget set-tool-dim : show-help ( link browser-gadget -- ) - model>> dup add-history - [ >link ] dip set-model ; + [ >link ] [ model>> ] bi* + [ [ add-recent ] [ add-history ] bi* ] [ set-model ] 2bi ; : ( browser-gadget -- gadget ) model>> [ '[ _ print-topic ] try ] ; @@ -96,7 +97,7 @@ M: browser-gadget focusable-child* search-field>> ; : com-forward ( browser -- ) model>> go-forward ; -: com-documentation ( browser -- ) "handbook" swap show-help ; +: com-documentation ( browser -- ) "help.home" swap show-help ; : browser-help ( -- ) "ui-browser" com-browse ; @@ -113,7 +114,7 @@ browser-gadget "toolbar" f { over [ show-help ] [ 2drop ] if ; : navigate ( browser quot -- ) - '[ control-value @ ] keep ?show-help ; + '[ control-value @ ] keep ?show-help ; inline : com-up ( browser -- ) [ article-parent ] navigate ; diff --git a/basis/ui/tools/deploy/deploy-docs.factor b/basis/ui/tools/deploy/deploy-docs.factor index e625d26c60..b0a2fb6cf9 100644 --- a/basis/ui/tools/deploy/deploy-docs.factor +++ b/basis/ui/tools/deploy/deploy-docs.factor @@ -1,4 +1,4 @@ -USING: help.markup help.syntax ; +USING: help.markup help.syntax help.tips ; IN: ui.tools.deploy HELP: deploy-tool @@ -14,4 +14,6 @@ $nl "Alternatively, right-click on a vocabulary presentation in the UI and choose " { $strong "Deploy tool" } " from the resulting popup menu." { $see-also "tools.deploy" } ; +TIP: "Generate stand-alone applications from vocabularies with the " { $link "ui.tools.deploy" } "." ; + ABOUT: "ui.tools.deploy" diff --git a/basis/ui/tools/listener/completion/completion.factor b/basis/ui/tools/listener/completion/completion.factor index 0f357cb0af..022a2daabf 100644 --- a/basis/ui/tools/listener/completion/completion.factor +++ b/basis/ui/tools/listener/completion/completion.factor @@ -3,7 +3,7 @@ USING: accessors arrays assocs calendar colors colors.constants documents documents.elements fry kernel words sets splitting math math.vectors models.delay models.arrow combinators.short-circuit -parser present sequences tools.completion tools.vocabs.browser generic +parser present sequences tools.completion help.vocabs generic generic.standard.engines.tuple fonts definitions.icons ui.images ui.commands ui.operations ui.gadgets ui.gadgets.editors ui.gadgets.glass ui.gadgets.scrollers ui.gadgets.tables diff --git a/basis/ui/tools/listener/listener-docs.factor b/basis/ui/tools/listener/listener-docs.factor index caff45e40e..afe890b9c5 100644 --- a/basis/ui/tools/listener/listener-docs.factor +++ b/basis/ui/tools/listener/listener-docs.factor @@ -1,5 +1,7 @@ USING: help.markup help.syntax ui.commands ui.operations -ui.gadgets.editors ui.gadgets.panes listener io words ; +ui.gadgets.editors ui.gadgets.panes listener io words +ui.tools.listener.completion ui.tools.common help.tips +tools.vocabs vocabs ; IN: ui.tools.listener HELP: interactor @@ -21,11 +23,27 @@ ARTICLE: "ui-listener" "UI listener" { $operations \ word } { $heading "Vocabulary commands" } "These words operate on the vocabulary at the cursor." -{ $operations \ word } +{ $operations T{ vocab-link f "kernel" } } { $command-map interactor "quotation" } { $heading "Editing commands" } "The text editing commands are standard; see " { $link "gadgets-editors-commands" } "." { $heading "Implementation" } "Listeners are instances of " { $link listener-gadget } ". The listener consists of an output area (instance of " { $link pane } ") and an input area (instance of " { $link interactor } "). Clickable presentations can also be printed to the listener; see " { $link "ui-presentations" } "." ; +TIP: "You can read documentation by pressing F1." ; + +TIP: "The listener tool remembers previous lines of input. Press " { $command interactor "completion" recall-previous } " and " { $command interactor "completion" recall-next } " to cycle through them." ; + +TIP: "When you mouse over certain objects, a block border will appear. Left-clicking on such an object will perform the default operation. Right-clicking will show a menu with all operations." ; + +TIP: "The status bar displays stack effects of recognized words as they are being typed in." ; + +TIP: "Press " { $command interactor "completion" code-completion-popup } " to complete word, vocabulary and Unicode character names. The latter two features become available if the cursor is after a " { $link POSTPONE: USE: } ", " { $link POSTPONE: USING: } " or " { $link POSTPONE: CHAR: } "." ; + +TIP: "If a word's vocabulary is loaded, but not in the search path, you can use restarts to add the vocabulary to the search path. Auto-use mode (" { $command listener-gadget "toolbar" com-auto-use } ") invokes restarts automatically if there is only one restart." ; + +TIP: "Scroll the listener from the keyboard by pressing " { $command listener-gadget "scrolling" com-page-up } " and " { $command listener-gadget "scrolling" com-page-down } "." ; + +TIP: "Press " { $command tool "common" refresh-all } " or run " { $link refresh-all } " to reload changed source files from disk. " ; + ABOUT: "ui-listener" \ No newline at end of file diff --git a/basis/ui/tools/listener/listener.factor b/basis/ui/tools/listener/listener.factor index 5efcd01eec..91448dfe10 100644 --- a/basis/ui/tools/listener/listener.factor +++ b/basis/ui/tools/listener/listener.factor @@ -2,12 +2,13 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs calendar combinators locals colors.constants combinators.short-circuit compiler.units -concurrency.flags concurrency.mailboxes continuations destructors -documents documents.elements fry hashtables help help.markup io -io.styles kernel lexer listener math models models.delay models.arrow -namespaces parser prettyprint quotations sequences strings threads -tools.vocabs vocabs vocabs.loader vocabs.parser words debugger ui ui.commands -ui.pens.solid ui.gadgets ui.gadgets.glass ui.gadgets.buttons ui.gadgets.editors +help.tips concurrency.flags concurrency.mailboxes continuations +destructors documents documents.elements fry hashtables help +help.markup io io.styles kernel lexer listener math models +models.delay models.arrow namespaces parser prettyprint quotations +sequences strings threads tools.vocabs vocabs vocabs.loader +vocabs.parser words debugger ui ui.commands ui.pens.solid ui.gadgets +ui.gadgets.glass ui.gadgets.buttons ui.gadgets.editors ui.gadgets.labeled ui.gadgets.panes ui.gadgets.scrollers ui.gadgets.status-bar ui.gadgets.tracks ui.gadgets.borders ui.gestures ui.operations ui.tools.browser ui.tools.common ui.tools.debugger @@ -354,16 +355,11 @@ interactor "completion" f { { T{ key-down f { C+ } "r" } history-completion-popup } } define-command-map -: welcome. ( -- ) - "If this is your first time with Factor, please read the " print - "handbook" ($link) ". To see a list of keyboard shortcuts," print - "press F1." print nl ; - : listener-thread ( listener -- ) dup listener-streams [ [ com-browse ] help-hook set '[ [ _ input>> ] 2dip debugger-popup ] error-hook set - welcome. + tip-of-the-day. nl listener ] with-streams* ; @@ -385,7 +381,7 @@ interactor "completion" f { [ wait-for-listener ] } cleave ; -: listener-help ( -- ) "ui-listener" com-browse ; +: listener-help ( -- ) "help.home" com-browse ; \ listener-help H{ { +nullary+ t } } define-command diff --git a/basis/ui/tools/operations/operations-docs.factor b/basis/ui/tools/operations/operations-docs.factor new file mode 100644 index 0000000000..455e4f5ccc --- /dev/null +++ b/basis/ui/tools/operations/operations-docs.factor @@ -0,0 +1,8 @@ +USING: help.tips help.markup help.syntax ui.operations +tools.walker tools.time tools.profiler ui.tools.operations ; + +TIP: "Press " { $operation com-stack-effect } " to print the stack effect of the code in the input field without executing it (" { $link "inference" } ")." ; + +TIP: "Press " { $operation walk } " to single-step through the code in the input field (" { $link "ui-walker" } ")." ; + +TIP: "Press " { $operation time } " to time execution of the code in the input field (" { $link "timing" } ")." ; diff --git a/basis/ui/tools/operations/operations.factor b/basis/ui/tools/operations/operations.factor index 6d6cda1dba..28781e24bb 100644 --- a/basis/ui/tools/operations/operations.factor +++ b/basis/ui/tools/operations/operations.factor @@ -9,7 +9,7 @@ compiler.units accessors vocabs.parser macros.expander ui ui.tools.browser ui.tools.listener ui.tools.listener.completion ui.tools.profiler ui.tools.inspector ui.tools.traceback ui.commands ui.gadgets.editors ui.gestures ui.operations -ui.tools.deploy models ; +ui.tools.deploy models help.tips ; IN: ui.tools.operations ! Objects @@ -157,8 +157,6 @@ M: word com-stack-effect 1quotation com-stack-effect ; { +listener+ t } } define-operation -: com-profile ( quot -- ) profile profiler-window ; - [ quotation? ] \ com-profile H{ { +keyboard+ T{ key-down f { C+ } "o" } } { +listener+ t } diff --git a/basis/ui/tools/profiler/profiler-docs.factor b/basis/ui/tools/profiler/profiler-docs.factor new file mode 100644 index 0000000000..a54a29c6a1 --- /dev/null +++ b/basis/ui/tools/profiler/profiler-docs.factor @@ -0,0 +1,11 @@ +IN: ui.tools.profiler +USING: help.markup help.syntax ui.operations help.tips ; + +ARTICLE: "ui.tools.profiler" "UI profiler tool" +"The " { $vocab-link "ui.tools.profiler" } " vocabulary implements a graphical tool for viewing profiling results (see " { $link "tools.profiler" } ")." +$nl +"To use the profiler, enter a piece of code in the listener's input area and press " { $operation com-profile } "." ; + +TIP: "Press " { $operation com-profile } " to run the code in the input field with profiling enabled (" { $link "ui.tools.profiler" } ")." ; + +ABOUT: "ui.tools.profiler" \ No newline at end of file diff --git a/basis/ui/tools/profiler/profiler.factor b/basis/ui/tools/profiler/profiler.factor index bbd9237c87..6bca4b40c4 100644 --- a/basis/ui/tools/profiler/profiler.factor +++ b/basis/ui/tools/profiler/profiler.factor @@ -208,4 +208,6 @@ profiler-gadget "toolbar" f { : profiler-window ( -- ) "Profiling results" open-status-window ; +: com-profile ( quot -- ) profile profiler-window ; + MAIN: profiler-window \ No newline at end of file diff --git a/basis/ui/tools/tools-docs.factor b/basis/ui/tools/tools-docs.factor index d3078cc178..c591775429 100644 --- a/basis/ui/tools/tools-docs.factor +++ b/basis/ui/tools/tools-docs.factor @@ -1,7 +1,8 @@ USING: editors help.markup help.syntax summary inspector io io.styles listener parser prettyprint tools.profiler tools.walker ui.commands ui.gadgets.panes ui.gadgets.presentations ui.operations -ui.tools.operations ui.tools.profiler ui.tools.common vocabs see ; +ui.tools.operations ui.tools.profiler ui.tools.common vocabs see +help.tips ; IN: ui.tools ARTICLE: "starting-ui-tools" "Starting the UI tools" @@ -67,4 +68,6 @@ $nl "Platform-specific features:" { $subsection "ui-cocoa" } ; +TIP: "All UI developer tools support a common set of " { $link "ui-shortcuts" } ". Each individual tool has its own shortcuts as well; the F1 key is context-sensitive." ; + ABOUT: "ui-tools" diff --git a/core/parser/parser.factor b/core/parser/parser.factor index 871f7c5321..b71f6ed3be 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -166,6 +166,7 @@ SYMBOL: interactive-vocabs "definitions" "editors" "help" + "help.apropos" "help.lint" "inspector" "io" @@ -186,7 +187,6 @@ SYMBOL: interactive-vocabs "strings" "syntax" "tools.annotations" - "tools.apropos" "tools.crossref" "tools.disassembler" "tools.memory" diff --git a/core/strings/strings-docs.factor b/core/strings/strings-docs.factor index 2aa8ef421c..22e8bfcb62 100644 --- a/core/strings/strings-docs.factor +++ b/core/strings/strings-docs.factor @@ -1,6 +1,6 @@ USING: arrays byte-arrays help.markup help.syntax kernel kernel.private strings.private sequences vectors -sbufs math tools.vocabs.browser ; +sbufs math help.vocabs ; IN: strings ARTICLE: "strings" "Strings" diff --git a/extra/demos/demos.factor b/extra/demos/demos.factor index fd7aafb601..8c55945105 100644 --- a/extra/demos/demos.factor +++ b/extra/demos/demos.factor @@ -1,6 +1,6 @@ USING: kernel fry sequences - vocabs.loader tools.vocabs.browser + vocabs.loader help.vocabs ui ui.gadgets ui.gadgets.buttons ui.gadgets.packs ui.gadgets.scrollers ui.tools.listener accessors ; diff --git a/extra/fuel/help/help.factor b/extra/fuel/help/help.factor index 6368e542a7..30d6845a9b 100644 --- a/extra/fuel/help/help.factor +++ b/extra/fuel/help/help.factor @@ -3,7 +3,7 @@ USING: accessors arrays assocs combinators help help.crossref help.markup help.topics io io.streams.string kernel make namespaces -parser prettyprint sequences summary tools.vocabs tools.vocabs.browser +parser prettyprint sequences summary tools.vocabs help.vocabs vocabs vocabs.loader words see ; IN: fuel.help diff --git a/extra/galois-talk/galois-talk.factor b/extra/galois-talk/galois-talk.factor index ccba90fb6f..be713542ed 100644 --- a/extra/galois-talk/galois-talk.factor +++ b/extra/galois-talk/galois-talk.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: slides help.markup math arrays hashtables namespaces sequences kernel sequences parser memoize io.encodings.binary -locals kernel.private tools.vocabs.browser assocs quotations +locals kernel.private help.vocabs assocs quotations urls peg.ebnf tools.vocabs tools.annotations tools.crossref help.topics math.functions compiler.tree.optimizer compiler.cfg.optimizer fry ; diff --git a/extra/google-tech-talk/google-tech-talk.factor b/extra/google-tech-talk/google-tech-talk.factor index 4d4e3b0507..ab8e72fc76 100644 --- a/extra/google-tech-talk/google-tech-talk.factor +++ b/extra/google-tech-talk/google-tech-talk.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: slides help.markup math arrays hashtables namespaces sequences kernel sequences parser memoize io.encodings.binary -locals kernel.private tools.vocabs.browser assocs quotations +locals kernel.private help.vocabs assocs quotations urls peg.ebnf tools.vocabs tools.annotations tools.crossref help.topics math.functions compiler.tree.optimizer compiler.cfg.optimizer fry ; diff --git a/extra/otug-talk/otug-talk.factor b/extra/otug-talk/otug-talk.factor index 2ce307ce20..b7256246fe 100644 --- a/extra/otug-talk/otug-talk.factor +++ b/extra/otug-talk/otug-talk.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: slides help.markup math arrays hashtables namespaces sequences kernel sequences parser memoize io.encodings.binary locals -kernel.private tools.vocabs.browser assocs quotations tools.vocabs +kernel.private help.vocabs assocs quotations tools.vocabs tools.annotations tools.crossref help.topics math.functions compiler.tree.optimizer compiler.cfg.optimizer fry ui.gadgets.panes tetris tetris.game combinators generalizations multiline diff --git a/extra/vpri-talk/vpri-talk.factor b/extra/vpri-talk/vpri-talk.factor index 5d7620101f..1e5c9602b9 100644 --- a/extra/vpri-talk/vpri-talk.factor +++ b/extra/vpri-talk/vpri-talk.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: slides help.markup math arrays hashtables namespaces sequences kernel sequences parser memoize io.encodings.binary -locals kernel.private tools.vocabs.browser assocs quotations +locals kernel.private help.vocabs assocs quotations urls peg.ebnf tools.vocabs tools.annotations tools.crossref help.topics math.functions compiler.tree.optimizer compiler.cfg.optimizer fry ; From 577522fe0f4e71a708dce3d9d71f793f9ad3940e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 24 Mar 2009 08:56:59 -0500 Subject: [PATCH 10/36] Fix ui.tools.profiler help lint --- basis/ui/tools/profiler/profiler-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/ui/tools/profiler/profiler-docs.factor b/basis/ui/tools/profiler/profiler-docs.factor index a54a29c6a1..e2a0ef5f4e 100644 --- a/basis/ui/tools/profiler/profiler-docs.factor +++ b/basis/ui/tools/profiler/profiler-docs.factor @@ -2,7 +2,7 @@ IN: ui.tools.profiler USING: help.markup help.syntax ui.operations help.tips ; ARTICLE: "ui.tools.profiler" "UI profiler tool" -"The " { $vocab-link "ui.tools.profiler" } " vocabulary implements a graphical tool for viewing profiling results (see " { $link "tools.profiler" } ")." +"The " { $vocab-link "ui.tools.profiler" } " vocabulary implements a graphical tool for viewing profiling results (see " { $link "profiling" } ")." $nl "To use the profiler, enter a piece of code in the listener's input area and press " { $operation com-profile } "." ; From 7741d2ca2329c3db8888ca726802110efe1bdf79 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 24 Mar 2009 09:11:45 -0500 Subject: [PATCH 11/36] - definitions.icons now has a reference article - move about to help.vocabs; it now opens the vocab browser instead - help.vocabs is in default use list - add runnable-vocab predicate class --- basis/definitions/icons/icons-docs.factor | 12 +++++++ basis/definitions/icons/icons.factor | 38 ++++++++++++++--------- basis/help/crossref/crossref-docs.factor | 5 +-- basis/help/help-docs.factor | 11 ------- basis/help/help.factor | 9 ------ basis/help/home/home-docs.factor | 12 ++++--- basis/help/home/home.factor | 2 +- basis/help/markup/markup.factor | 3 ++ basis/help/tips/tips-docs.factor | 5 ++- basis/help/vocabs/vocabs-docs.factor | 23 +++++++++++++- basis/help/vocabs/vocabs.factor | 3 ++ basis/ui/tools/browser/browser.factor | 6 ++-- basis/ui/tools/tools-docs.factor | 4 +++ core/parser/parser.factor | 1 + core/vocabs/loader/loader-docs.factor | 1 + core/vocabs/vocabs-docs.factor | 3 ++ core/vocabs/vocabs.factor | 5 ++- 17 files changed, 94 insertions(+), 49 deletions(-) create mode 100644 basis/definitions/icons/icons-docs.factor diff --git a/basis/definitions/icons/icons-docs.factor b/basis/definitions/icons/icons-docs.factor new file mode 100644 index 0000000000..8bca46bc3a --- /dev/null +++ b/basis/definitions/icons/icons-docs.factor @@ -0,0 +1,12 @@ +IN: definitions.icons +USING: help.markup help.syntax ; + +ARTICLE: "definitions.icons" "Definition icons" +"The " { $vocab-link "definitions.icons" } " vocabulary associates common definition types with icons." +{ $definition-icons } +"Looking up the icon associated with a definition:" +{ $subsection definition-icon } +"Defining new icons:" +{ $subsection POSTPONE: ICON: } ; + +ABOUT: "definitions.icons" \ No newline at end of file diff --git a/basis/definitions/icons/icons.factor b/basis/definitions/icons/icons.factor index 7c5fbed9f4..7562658ea4 100644 --- a/basis/definitions/icons/icons.factor +++ b/basis/definitions/icons/icons.factor @@ -2,22 +2,29 @@ ! See http://factorcode.org/license.txt for BSD license. USING: assocs classes.predicate fry generic io.pathnames kernel macros sequences vocabs words words.symbol words.constant -lexer parser help.topics ; +lexer parser help.topics help.markup namespaces sorting ; IN: definitions.icons GENERIC: definition-icon ( definition -- path ) -> @@ -29,12 +36,15 @@ ICON: primitive primitive-word ICON: symbol symbol-word ICON: constant constant-word ICON: word normal-word -ICON: vocab-link unopen-vocab ICON: word-link word-help-article ICON: link help-article +ICON: runnable-vocab runnable-vocab +ICON: vocab open-vocab +ICON: vocab-link unopen-vocab -PRIVATE> - -M: vocab definition-icon - vocab-main "runnable-vocab" "open-vocab" ? definition-icon-path ; - \ No newline at end of file +: $definition-icons ( element -- ) + drop + icons get >alist sort-keys + [ [ <$link> ] [ definition-icon-path <$image> ] bi* swap ] assoc-map + { "" "Definition class" } prefix + $table ; \ No newline at end of file diff --git a/basis/help/crossref/crossref-docs.factor b/basis/help/crossref/crossref-docs.factor index 6ec35b23ce..ae227fde89 100644 --- a/basis/help/crossref/crossref-docs.factor +++ b/basis/help/crossref/crossref-docs.factor @@ -11,10 +11,7 @@ HELP: article-parent HELP: help-path { $values { "topic" "an article name or a word" } { "seq" "a new sequence" } } -{ $description "Outputs a sequence of all help articles which contain " { $snippet "topic" } " as a subsection, traversing all the way up to the root." } -{ $examples - { $example "USING: help.crossref prettyprint ;" "\"sequences\" help-path ." "{ \"collections\" \"handbook-language-reference\" \"handbook\" }" } -} ; +{ $description "Outputs a sequence of all help articles which contain " { $snippet "topic" } " as a subsection, traversing all the way up to the root." } ; HELP: xref-article { $values { "topic" "an article name or a word" } } diff --git a/basis/help/help-docs.factor b/basis/help/help-docs.factor index 547ee871aa..be521eb93a 100644 --- a/basis/help/help-docs.factor +++ b/basis/help/help-docs.factor @@ -69,12 +69,6 @@ ARTICLE: "element-types" "Element types" IN: help.markup ABOUT: "element-types" -ARTICLE: "browsing-help" "Browsing documentation" -"The easiest way to browse the help is from the help browser tool in the UI, however you can also display help topics in the listener. Help topics are identified by article name strings, or words. You can request a specific help topic:" -{ $subsection help } -"You can also display the main help article for a vocabulary:" -{ $subsection about } ; - ARTICLE: "writing-help" "Writing documentation" "By convention, documentation is written in files whose names end with " { $snippet "-docs.factor" } ". Vocabulary documentation should be placed in the same directory as the vocabulary source code; see " { $link "vocabs.loader" } "." $nl @@ -148,11 +142,6 @@ HELP: help { $description "Displays a help topic." } ; -HELP: about -{ $values { "vocab" "a vocabulary specifier" } } -{ $description - "Displays the main help article for the vocabulary. The main help article is set with the " { $link POSTPONE: ABOUT: } " parsing word." -} ; HELP: :help { $description "Displays documentation for the most recent error." } ; diff --git a/basis/help/help.factor b/basis/help/help.factor index 6fa4473d97..d20e06b6c6 100644 --- a/basis/help/help.factor +++ b/basis/help/help.factor @@ -127,15 +127,6 @@ help-hook [ [ print-topic ] ] initialize : help ( topic -- ) help-hook get call( topic -- ) ; -: about ( vocab -- ) - dup require - dup vocab [ ] [ no-vocab ] ?if - dup vocab-help [ help ] [ - "The " write vocab-name write - " vocabulary does not define a main help article." print - "To define one, refer to \\ ABOUT: help" print - ] ?if ; - : ($index) ( articles -- ) sort-articles [ \ $subsection swap 2array ] map print-element ; diff --git a/basis/help/home/home-docs.factor b/basis/help/home/home-docs.factor index d4d8a6206d..6608a6e9c0 100644 --- a/basis/help/home/home-docs.factor +++ b/basis/help/home/home-docs.factor @@ -2,18 +2,22 @@ IN: help.home USING: help.markup help.syntax ; ARTICLE: "help.home" "Factor documentation" -{ $heading "Starting points" } +"If this is your first time with Factor, you can start by writing " { $link "first-program" } "." +{ $heading "Reference" } { $list - { $link "ui-listener" } { $link "handbook" } { $link "vocab-index" } + { $link "ui-tools" } + { $link "handbook-library-reference" } } { $heading "Recently visited" } { $table { "Words" "Articles" "Vocabs" } { { $recent recent-words } { $recent recent-articles } { $recent recent-vocabs } } -} print-element +} +"The browser, completion popups and other tools use a common set of " { $link "definitions.icons" } "." { $heading "Recent searches" } -{ $recent-searches } ; +{ $recent-searches } +"Use the search field in the top-right of the " { $link "ui-browser" } " window to search for words, vocabularies and help articles." ; ABOUT: "help.home" \ No newline at end of file diff --git a/basis/help/home/home.factor b/basis/help/home/home.factor index b1b938cb45..f32c0db30d 100644 --- a/basis/help/home/home.factor +++ b/basis/help/home/home.factor @@ -24,7 +24,7 @@ M: object add-recent-where f ; first get [ nl ] [ 1array $pretty-link ] interleave ; : $recent-searches ( element -- ) - drop recent-searches get [ nl ] [ ($link) ] interleave ; + drop recent-searches get [ <$link> ] map $list ; : redisplay-recent-page ( -- ) "help.home" >link dup associate diff --git a/basis/help/markup/markup.factor b/basis/help/markup/markup.factor index a80d386638..8b5edf38c1 100644 --- a/basis/help/markup/markup.factor +++ b/basis/help/markup/markup.factor @@ -140,6 +140,9 @@ ALIAS: $slot $snippet : $image ( element -- ) [ [ "" ] dip first image associate format ] ($span) ; +: <$image> ( path -- element ) + 1array \ $image prefix ; + ! Some links : write-link ( string object -- ) link-style get [ write-object ] with-style ; diff --git a/basis/help/tips/tips-docs.factor b/basis/help/tips/tips-docs.factor index 7148b25a37..8d732c5568 100644 --- a/basis/help/tips/tips-docs.factor +++ b/basis/help/tips/tips-docs.factor @@ -1,5 +1,6 @@ IN: help.tips -USING: help.markup help.syntax debugger ; +USING: help.markup help.syntax debugger prettyprint see help help.vocabs +help.apropos tools.time stack-checker editors ; TIP: "To look at the most recent error, run " { $link :error } ". To look at the most recent error's callstack, run " { $link :c } "." ; @@ -15,6 +16,8 @@ TIP: "You can write documentation for your own code using the " { $link "help" } TIP: "You can write graphical applications using the " { $link "ui" } "." ; +TIP: "Power tools: " { $links see edit help about apropos time infer. } ; + ARTICLE: "all-tips-of-the-day" "All tips of the day" { $tips-of-the-day } ; diff --git a/basis/help/vocabs/vocabs-docs.factor b/basis/help/vocabs/vocabs-docs.factor index 5f1a97205e..cbedce2f52 100644 --- a/basis/help/vocabs/vocabs-docs.factor +++ b/basis/help/vocabs/vocabs-docs.factor @@ -1,4 +1,4 @@ -USING: help.markup help.syntax io strings ; +USING: help help.topics help.markup help.syntax io strings ; IN: help.vocabs ARTICLE: "vocab-tags" "Vocabulary tags" @@ -15,3 +15,24 @@ ARTICLE: "vocab-index" "Vocabulary index" HELP: words. { $values { "vocab" "a vocabulary name" } } { $description "Printings a listing of all the words in a vocabulary, categorized by type." } ; + +HELP: about +{ $values { "vocab" "a vocabulary specifier" } } +{ $description + "Displays the main help article for the vocabulary. The main help article is set with the " { $link POSTPONE: ABOUT: } " parsing word." +} ; + +ARTICLE: "browsing-help" "Browsing documentation" +"Help topics are instances of a mixin:" +{ $subsection topic } +"Most commonly, topics are article name strings, or words. You can display a specific help topic:" +{ $subsection help } +"You can also display the help for a vocabulary:" +{ $subsection about } +"To list a vocabulary's words only:" +{ $subsection words. } +{ $examples + { $code "\"evaluator\" help" } + { $code "\\ + help" } + { $code "\"io.files\" about" } +} ; \ No newline at end of file diff --git a/basis/help/vocabs/vocabs.factor b/basis/help/vocabs/vocabs.factor index 13bb0cdf3e..a8c93feee4 100644 --- a/basis/help/vocabs/vocabs.factor +++ b/basis/help/vocabs/vocabs.factor @@ -9,6 +9,9 @@ make namespaces prettyprint sequences sets sorting summary tools.vocabs vocabs vocabs.loader words words.symbol definitions.icons ; IN: help.vocabs +: about ( vocab -- ) + [ require ] [ vocab help ] bi ; + : $pretty-link ( element -- ) [ first definition-icon 1array $image " " print-element ] [ $definition-link ] diff --git a/basis/ui/tools/browser/browser.factor b/basis/ui/tools/browser/browser.factor index e1dcba9910..553ba0f6b9 100644 --- a/basis/ui/tools/browser/browser.factor +++ b/basis/ui/tools/browser/browser.factor @@ -78,7 +78,7 @@ M: browser-gadget focusable-child* search-field>> ; "Browser" open-status-window ; : browser-window ( -- ) - "handbook" (browser-window) ; + "help.home" (browser-window) ; \ browser-window H{ { +nullary+ t } } define-command @@ -97,7 +97,7 @@ M: browser-gadget focusable-child* search-field>> ; : com-forward ( browser -- ) model>> go-forward ; -: com-documentation ( browser -- ) "help.home" swap show-help ; +: com-home ( browser -- ) "help.home" swap show-help ; : browser-help ( -- ) "ui-browser" com-browse ; @@ -106,7 +106,7 @@ M: browser-gadget focusable-child* search-field>> ; browser-gadget "toolbar" f { { T{ key-down f { A+ } "LEFT" } com-back } { T{ key-down f { A+ } "RIGHT" } com-forward } - { f com-documentation } + { T{ key-down f { A+ } "H" } com-home } { T{ key-down f f "F1" } browser-help } } define-command-map diff --git a/basis/ui/tools/tools-docs.factor b/basis/ui/tools/tools-docs.factor index c591775429..93f45591a5 100644 --- a/basis/ui/tools/tools-docs.factor +++ b/basis/ui/tools/tools-docs.factor @@ -57,8 +57,12 @@ ARTICLE: "ui-tools" "UI developer tools" "The " { $vocab-link "ui.tools" } " vocabulary hierarchy implements a collection of simple developer tools." $nl "To take full advantage of the UI tools, you should be using a supported text editor. See " { $link "editor" } "." +$nl +"Common functionality:" { $subsection "ui-shortcuts" } { $subsection "ui-presentations" } +{ $subsection "definitions.icons" } +"Tools:" { $subsection "ui-listener" } { $subsection "ui-browser" } { $subsection "ui-inspector" } diff --git a/core/parser/parser.factor b/core/parser/parser.factor index b71f6ed3be..6d613a8b24 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -168,6 +168,7 @@ SYMBOL: interactive-vocabs "help" "help.apropos" "help.lint" + "help.vocabs" "inspector" "io" "io.files" diff --git a/core/vocabs/loader/loader-docs.factor b/core/vocabs/loader/loader-docs.factor index 527da053fb..e0d6fd4493 100644 --- a/core/vocabs/loader/loader-docs.factor +++ b/core/vocabs/loader/loader-docs.factor @@ -56,6 +56,7 @@ $nl "Application vocabularies can define a main entry point, giving the user a convenient way to run the application:" { $subsection POSTPONE: MAIN: } { $subsection run } +{ $subsection runnable-vocab } { $see-also "vocabularies" "parser-files" "source-files" } ; ABOUT: "vocabs.loader" diff --git a/core/vocabs/vocabs-docs.factor b/core/vocabs/vocabs-docs.factor index 2929b50081..2c87d9736a 100644 --- a/core/vocabs/vocabs-docs.factor +++ b/core/vocabs/vocabs-docs.factor @@ -96,3 +96,6 @@ $nl HELP: >vocab-link { $values { "name" string } { "vocab" "a vocabulary specifier" } } { $description "If the vocabulary is loaded, outputs the corresponding " { $link vocab } " instance, otherwise creates a new " { $link vocab-link } "." } ; + +HELP: runnable-vocab +{ $class-description "The class of vocabularies with a " { $slot "main" } " word." } ; \ No newline at end of file diff --git a/core/vocabs/vocabs.factor b/core/vocabs/vocabs.factor index b9f38dfef3..edac418285 100644 --- a/core/vocabs/vocabs.factor +++ b/core/vocabs/vocabs.factor @@ -105,4 +105,7 @@ M: vocab-spec forget* forget-vocab ; SYMBOL: load-vocab-hook ! ( name -- vocab ) -: load-vocab ( name -- vocab ) load-vocab-hook get call( name -- vocab ) ; \ No newline at end of file +: load-vocab ( name -- vocab ) load-vocab-hook get call( name -- vocab ) ; + +PREDICATE: runnable-vocab < vocab + vocab-main >boolean ; \ No newline at end of file From 9b8dd01c0ba14ceba939042365eea09822aeecfe Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 25 Mar 2009 10:11:58 -0500 Subject: [PATCH 12/36] Fix bitrot in compiler.tree.debugger --- basis/compiler/tree/debugger/debugger-tests.factor | 5 ++++- basis/compiler/tree/debugger/debugger.factor | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/basis/compiler/tree/debugger/debugger-tests.factor b/basis/compiler/tree/debugger/debugger-tests.factor index eb0bbd5ce6..4d1c5c824d 100644 --- a/basis/compiler/tree/debugger/debugger-tests.factor +++ b/basis/compiler/tree/debugger/debugger-tests.factor @@ -1,5 +1,8 @@ IN: compiler.tree.debugger.tests -USING: compiler.tree.debugger tools.test ; +USING: compiler.tree.debugger tools.test sorting sequences io ; \ optimized. must-infer \ optimizer-report. must-infer + +[ [ <=> ] sort ] optimized. +[ [ print ] each ] optimizer-report. \ No newline at end of file diff --git a/basis/compiler/tree/debugger/debugger.factor b/basis/compiler/tree/debugger/debugger.factor index 188dcdb935..430424291e 100644 --- a/basis/compiler/tree/debugger/debugger.factor +++ b/basis/compiler/tree/debugger/debugger.factor @@ -160,7 +160,7 @@ SYMBOL: node-count { [ dup generic? ] [ generics-called ] } { [ dup method-body? ] [ methods-called ] } [ words-called ] - } cond inc-at + } cond get inc-at ] [ drop ] if ] each-node node-count set From be9d8ffd0220624ac03ad1627c0c33ae4f968c77 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 25 Mar 2009 10:12:10 -0500 Subject: [PATCH 13/36] A+b now focuses the search field --- basis/ui/tools/browser/browser.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/ui/tools/browser/browser.factor b/basis/ui/tools/browser/browser.factor index 553ba0f6b9..e242b743f8 100644 --- a/basis/ui/tools/browser/browser.factor +++ b/basis/ui/tools/browser/browser.factor @@ -89,7 +89,7 @@ M: browser-gadget focusable-child* search-field>> ; : show-browser ( -- ) [ browser-gadget? ] find-window - [ raise-window ] [ browser-window ] if* ; + [ [ raise-window ] [ request-focus ] bi ] [ browser-window ] if* ; \ show-browser H{ { +nullary+ t } } define-command From 80860f62b22d9354da864c5c86e7252fd95bdefd Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 25 Mar 2009 10:19:27 -0500 Subject: [PATCH 14/36] remove dead freetype code from Makefile --- Makefile | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 5461ea5de9..234b8a2c88 100644 --- a/Makefile +++ b/Makefile @@ -98,17 +98,13 @@ netbsd-x86-32: netbsd-x86-64: $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.netbsd.x86.64 -macosx-freetype: - ln -sf libfreetype.6.dylib \ - Factor.app/Contents/Frameworks/libfreetype.dylib - -macosx-ppc: macosx-freetype +macosx-ppc: $(MAKE) $(EXECUTABLE) macosx.app CONFIG=vm/Config.macosx.ppc -macosx-x86-32: macosx-freetype +macosx-x86-32: $(MAKE) $(EXECUTABLE) macosx.app CONFIG=vm/Config.macosx.x86.32 -macosx-x86-64: macosx-freetype +macosx-x86-64: $(MAKE) $(EXECUTABLE) macosx.app CONFIG=vm/Config.macosx.x86.64 linux-x86-32: From 28b10a709464eb5c3f0183ff29c166904c4a322e Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 25 Mar 2009 10:19:52 -0500 Subject: [PATCH 15/36] remove loading freetype library on CE --- basis/windows/ce/ce.factor | 1 - 1 file changed, 1 deletion(-) diff --git a/basis/windows/ce/ce.factor b/basis/windows/ce/ce.factor index 948612b2b2..18c48a0139 100644 --- a/basis/windows/ce/ce.factor +++ b/basis/windows/ce/ce.factor @@ -10,6 +10,5 @@ USING: alien sequences ; { "libm" "\\windows\\coredll.dll" "stdcall" } ! { "gl" "libGLES_CM.dll" "stdcall" } ! { "glu" "libGLES_CM.dll" "stdcall" } - ! { "freetype" "libfreetype-6.dll" "stdcall" } { "ole32" "ole32.dll" "stdcall" } } [ first3 add-library ] each From 70bc39b3fd1495748e9bb54dfa7078858539a9c6 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 25 Mar 2009 11:10:25 -0500 Subject: [PATCH 16/36] Fix hello-unicode for deployment --- extra/hello-unicode/deploy.factor | 15 +++++++++++++++ extra/hello-unicode/hello-unicode.factor | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 extra/hello-unicode/deploy.factor diff --git a/extra/hello-unicode/deploy.factor b/extra/hello-unicode/deploy.factor new file mode 100644 index 0000000000..f2f1c9fb18 --- /dev/null +++ b/extra/hello-unicode/deploy.factor @@ -0,0 +1,15 @@ +USING: tools.deploy.config ; +H{ + { deploy-word-defs? f } + { deploy-reflection 1 } + { deploy-word-props? f } + { deploy-compiler? t } + { deploy-threads? t } + { deploy-unicode? f } + { "stop-after-last-window?" t } + { deploy-name "hello-unicode" } + { deploy-math? t } + { deploy-ui? t } + { deploy-io 2 } + { deploy-c-types? f } +} diff --git a/extra/hello-unicode/hello-unicode.factor b/extra/hello-unicode/hello-unicode.factor index ef492958e7..4374db2003 100644 --- a/extra/hello-unicode/hello-unicode.factor +++ b/extra/hello-unicode/hello-unicode.factor @@ -15,6 +15,6 @@ IN: hello-unicode ] with-style ] make-pane { 10 10 } ; -: hello-unicode ( -- ) "გამარჯობა" open-window ; +: hello-unicode ( -- ) [ "გამარჯობა" open-window ] with-ui ; MAIN: hello-unicode \ No newline at end of file From c36ae80c2824d3387101717cf4c0ba5736eb36c1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 25 Mar 2009 11:12:10 -0500 Subject: [PATCH 17/36] Better error message if user forgets with-ui --- basis/ui/gadgets/gadgets.factor | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/basis/ui/gadgets/gadgets.factor b/basis/ui/gadgets/gadgets.factor index e38f56c7f1..a4bedf1ef7 100644 --- a/basis/ui/gadgets/gadgets.factor +++ b/basis/ui/gadgets/gadgets.factor @@ -135,7 +135,9 @@ SYMBOL: ui-notify-flag : forget-pref-dim ( gadget -- ) f >>pref-dim drop ; -: layout-queue ( -- queue ) \ layout-queue get ; +: ui-state ( symbol -- value ) get [ "UI not running" throw ] unless* ; + +: layout-queue ( -- queue ) \ layout-queue ui-state ; : layout-later ( gadget -- ) #! When unit testing gadgets without the UI running, the @@ -214,7 +216,7 @@ M: gadget ungraft* drop ; > graft-queue delete-node ] From f41ee97addfa4341df3df40fdfc12a1dd70b8f62 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 25 Mar 2009 11:20:21 -0500 Subject: [PATCH 18/36] add sms, twitter fields to account. create sitewatcher account when user registers --- extra/site-watcher/db/db.factor | 9 ++++++--- extra/site-watcher/site-watcher-tests.factor | 4 ++-- extra/webapps/site-watcher/site-watcher.factor | 10 ++++++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/extra/site-watcher/db/db.factor b/extra/site-watcher/db/db.factor index a1a85f825f..148e5b96f9 100644 --- a/extra/site-watcher/db/db.factor +++ b/extra/site-watcher/db/db.factor @@ -5,15 +5,18 @@ io.directories io.files.temp kernel io.streams.string calendar debugger combinators.smart sequences ; IN: site-watcher.db -TUPLE: account account-id account-name email ; +TUPLE: account account-id account-name email twitter sms ; -: ( account-name -- account ) +: ( account-name email -- account ) account new + swap >>email swap >>account-name ; account "ACCOUNT" { { "account-name" "ACCOUNT_NAME" VARCHAR +user-assigned-id+ } { "email" "EMAIL" VARCHAR } + { "twitter" "TWITTER" VARCHAR } + { "sms" "SMS" VARCHAR } } define-persistent TUPLE: site site-id url up? changed? last-up error last-error ; @@ -72,7 +75,7 @@ TUPLE: reporting-site email url up? changed? last-up? error last-error ; : insert-site ( url -- site ) dup select-tuple [ ] [ dup t >>up? insert-tuple ] ?if ; -: insert-account ( account-name -- ) insert-tuple ; +: insert-account ( account-name email -- ) insert-tuple ; : find-sites ( -- seq ) f select-tuples ; diff --git a/extra/site-watcher/site-watcher-tests.factor b/extra/site-watcher/site-watcher-tests.factor index 62233587d9..b067504e2e 100644 --- a/extra/site-watcher/site-watcher-tests.factor +++ b/extra/site-watcher/site-watcher-tests.factor @@ -14,7 +14,7 @@ IN: site-watcher.tests site ensure-table watching-site ensure-table - "erg@factorcode.org" insert-account + "erg" "erg@factorcode.org" insert-account "http://asdfasdfasdfasdfqwerqqq.com" insert-site drop "http://fark.com" insert-site drop @@ -22,4 +22,4 @@ IN: site-watcher.tests f select-tuples ] with-db ; -[ f ] [ fake-sites empty? ] unit-test \ No newline at end of file +[ f ] [ fake-sites empty? ] unit-test diff --git a/extra/webapps/site-watcher/site-watcher.factor b/extra/webapps/site-watcher/site-watcher.factor index e220cff1d4..f173edb814 100644 --- a/extra/webapps/site-watcher/site-watcher.factor +++ b/extra/webapps/site-watcher/site-watcher.factor @@ -71,7 +71,7 @@ CONSTANT: site-list-url URL" $site-watcher-app/" : ( -- action ) [ - username select-tuple from-object + username f select-tuple from-object ] >>init { site-watcher-app "update-notify" } >>template [ @@ -82,8 +82,10 @@ CONSTANT: site-list-url URL" $site-watcher-app/" } validate-params ] >>validate [ - username select-tuple + username f select-tuple "email" value >>email + "twitter" value >>twitter + "sms" value >>sms update-tuple site-list-url ] >>submit @@ -122,6 +124,10 @@ CONSTANT: site-list-url URL" $site-watcher-app/" site-watcher-db main-responder set-global +M: site-watcher-app init-user-profile + drop + "username" value "email" value insert-tuple ; + : init-db ( -- ) site-watcher-db [ { site account watching-site } [ ensure-table ] each From 4b275c2861c0bbe43bd5c8e1b990ab523dec78fb Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 25 Mar 2009 13:05:34 -0500 Subject: [PATCH 19/36] make add-library normalize-path, use libfactor-ffi-tests for testing ffi --- basis/compiler/tests/alien.factor | 23 +++++++++++++++++++---- core/alien/alien.factor | 5 +++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index f3c2deb2d8..2aed251676 100644 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -6,6 +6,21 @@ continuations effects namespaces.private io io.streams.string memory system threads tools.test math accessors combinators specialized-arrays.float ; +<< +: libfactor-ffi-tests-path ( -- string ) + { + { [ os winnt? ] [ "resource:libfactor-ffi-test.dll" ] } + { [ os macosx? ] [ "resource:libfactor-ffi-test.dylib" ] } + { [ os unix? ] [ "resource:libfactor-ffi-test.so" ] } + } cond ; + +"f-cdecl" libfactor-ffi-tests-path "cdecl" add-library + +"f-stdcall" libfactor-ffi-tests-path "stdcall" add-library +>> + +LIBRARY: f-cdecl + FUNCTION: void ffi_test_0 ; [ ] [ ffi_test_0 ] unit-test @@ -107,9 +122,9 @@ unit-test "int" { "int" "int" "int" "int" } "stdcall" alien-indirect gc ; -<< "f-stdcall" f "stdcall" add-library >> +LIBRARY: f-stdcall -[ f ] [ "f-stdcall" load-library ] unit-test +[ f ] [ "f-stdcall" load-library f = ] unit-test [ "stdcall" ] [ "f-stdcall" library abi>> ] unit-test : ffi_test_18 ( w x y z -- int ) @@ -149,7 +164,7 @@ FUNCTION: void ffi_test_20 double x1, double x2, double x3, : ffi_test_31 ( a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a -- result y ) "int" - f "ffi_test_31" + "f-stdcall" "ffi_test_31" { "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" } alien-invoke gc 3 ; @@ -157,7 +172,7 @@ FUNCTION: void ffi_test_20 double x1, double x2, double x3, : ffi_test_31_point_5 ( a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a -- result ) "float" - f "ffi_test_31_point_5" + "f-stdcall" "ffi_test_31_point_5" { "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" } alien-invoke ; diff --git a/core/alien/alien.factor b/core/alien/alien.factor index 83665778f1..8e48ac770c 100644 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2004, 2009 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 arrays init io.backend ; IN: alien ! Some predicate classes used by the compiler for optimization @@ -64,6 +64,7 @@ TUPLE: library path abi dll ; library dup [ dll>> ] when ; : add-library ( name path abi -- ) + [ dup [ normalize-path ] when ] dip swap libraries get set-at ; ERROR: alien-callback-error ; @@ -99,4 +100,4 @@ PRIVATE> : initialize-alien ( symbol quot -- ) swap dup get-global dup recompute-value? [ drop [ call dup 31337 expiry-check boa ] dip set-global ] - [ 2nip object>> ] if ; inline \ No newline at end of file + [ 2nip object>> ] if ; inline From 97283b9857da3aff4e3e827f88ef2b1f6a6c8836 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 25 Mar 2009 13:06:20 -0500 Subject: [PATCH 20/36] compile an ffi test library, reduce factor runtime by 6kb! --- Makefile | 43 ++++++++++++++++++++++++------------------- vm/Config.macosx | 2 ++ vm/Config.unix | 1 + vm/Config.windows | 1 + 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 234b8a2c88..0c426ca5bc 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ LD = ld EXECUTABLE = factor CONSOLE_EXECUTABLE = factor-console +TEST_LIBRARY = factor-ffi-test VERSION = 0.92 IMAGE = factor.image @@ -35,7 +36,6 @@ DLL_OBJS = $(PLAF_DLL_OBJS) \ vm/debug.o \ vm/errors.o \ vm/factor.o \ - vm/ffi_test.o \ vm/image.o \ vm/io.o \ vm/math.o \ @@ -48,6 +48,8 @@ DLL_OBJS = $(PLAF_DLL_OBJS) \ EXE_OBJS = $(PLAF_EXE_OBJS) +TEST_OBJS = vm/ffi_test.o + default: $(MAKE) `./build-support/factor.sh make-target` @@ -81,60 +83,60 @@ help: @echo "X11=1 force link with X11 libraries instead of Cocoa (only on Mac OS X)" openbsd-x86-32: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.openbsd.x86.32 + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.openbsd.x86.32 openbsd-x86-64: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.openbsd.x86.64 + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.openbsd.x86.64 freebsd-x86-32: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.freebsd.x86.32 + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.freebsd.x86.32 freebsd-x86-64: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.freebsd.x86.64 + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.freebsd.x86.64 netbsd-x86-32: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.netbsd.x86.32 + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.netbsd.x86.32 netbsd-x86-64: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.netbsd.x86.64 + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.netbsd.x86.64 macosx-ppc: - $(MAKE) $(EXECUTABLE) macosx.app CONFIG=vm/Config.macosx.ppc + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) macosx.app CONFIG=vm/Config.macosx.ppc macosx-x86-32: - $(MAKE) $(EXECUTABLE) macosx.app CONFIG=vm/Config.macosx.x86.32 + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) macosx.app CONFIG=vm/Config.macosx.x86.32 macosx-x86-64: - $(MAKE) $(EXECUTABLE) macosx.app CONFIG=vm/Config.macosx.x86.64 + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) macosx.app CONFIG=vm/Config.macosx.x86.64 linux-x86-32: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.linux.x86.32 + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.linux.x86.32 linux-x86-64: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.linux.x86.64 + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.linux.x86.64 linux-ppc: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.linux.ppc + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.linux.ppc linux-arm: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.linux.arm + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.linux.arm solaris-x86-32: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.solaris.x86.32 + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.solaris.x86.32 solaris-x86-64: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.solaris.x86.64 + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.solaris.x86.64 winnt-x86-32: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.windows.nt.x86.32 + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.windows.nt.x86.32 $(MAKE) $(CONSOLE_EXECUTABLE) CONFIG=vm/Config.windows.nt.x86.32 winnt-x86-64: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.windows.nt.x86.64 + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.windows.nt.x86.64 $(MAKE) $(CONSOLE_EXECUTABLE) CONFIG=vm/Config.windows.nt.x86.64 wince-arm: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.windows.ce.arm + $(MAKE) $(EXECUTABLE) $(TEST_LIBRARY) CONFIG=vm/Config.windows.ce.arm macosx.app: factor mkdir -p $(BUNDLE)/Contents/MacOS @@ -157,6 +159,9 @@ factor-console: $(DLL_OBJS) $(EXE_OBJS) $(CC) $(LIBS) $(LIBPATH) -L. $(LINK_WITH_ENGINE) \ $(CFLAGS) $(CFLAGS_CONSOLE) -o factor$(EXE_SUFFIX)$(CONSOLE_EXTENSION) $(EXE_OBJS) +factor-ffi-test: $(TEST_OBJS) + $(CC) $(LIBPATH) $(CFLAGS) $(SHARED_FLAG) -o libfactor-ffi-test$(DLL_EXTENSION) $(TEST_OBJS) + clean: rm -f vm/*.o rm -f factor*.dll libfactor.{a,so,dylib} diff --git a/vm/Config.macosx b/vm/Config.macosx index 42334a0524..6655d548b7 100644 --- a/vm/Config.macosx +++ b/vm/Config.macosx @@ -5,6 +5,8 @@ PLAF_DLL_OBJS += vm/os-macosx.o vm/mach_signal.o DLL_EXTENSION = .dylib +SHARED_FLAG = -dynamiclib + ifdef X11 LIBS = -lm -framework Cocoa -L/opt/local/lib $(X11_UI_LIBS) -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib else diff --git a/vm/Config.unix b/vm/Config.unix index e8cb877249..8f2f140247 100644 --- a/vm/Config.unix +++ b/vm/Config.unix @@ -6,6 +6,7 @@ EXE_SUFFIX = DLL_PREFIX = lib DLL_EXTENSION = .a # DLL_EXTENSION = .so +SHARED_FLAG = -shared PLAF_DLL_OBJS = vm/os-unix.o PLAF_EXE_OBJS += vm/main-unix.o diff --git a/vm/Config.windows b/vm/Config.windows index 45d2f0cb98..75452a9bb4 100644 --- a/vm/Config.windows +++ b/vm/Config.windows @@ -1,6 +1,7 @@ CFLAGS += -DWINDOWS -mno-cygwin LIBS = -lm PLAF_DLL_OBJS += vm/os-windows.o +SHARED_FLAG = -shared EXE_EXTENSION=.exe CONSOLE_EXTENSION=.com DLL_EXTENSION=.dll From f4948ec9701cdda02a28e5ad6620db96666026ba Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 25 Mar 2009 22:52:52 -0500 Subject: [PATCH 21/36] Merge tools.test.ui into ui.gadgets.debug --- basis/tools/test/ui/authors.txt | 1 - basis/tools/test/ui/ui.factor | 16 ---------------- basis/ui/gadgets/debug/debug.factor | 16 +++++++++++++++- basis/ui/gadgets/editors/editors-tests.factor | 2 +- basis/ui/gadgets/panes/panes-tests.factor | 2 +- .../ui/gadgets/scrollers/scrollers-tests.factor | 2 +- basis/ui/tools/browser/browser-tests.factor | 2 +- basis/ui/tools/listener/listener-tests.factor | 2 +- 8 files changed, 20 insertions(+), 23 deletions(-) delete mode 100755 basis/tools/test/ui/authors.txt delete mode 100644 basis/tools/test/ui/ui.factor diff --git a/basis/tools/test/ui/authors.txt b/basis/tools/test/ui/authors.txt deleted file mode 100755 index 1901f27a24..0000000000 --- a/basis/tools/test/ui/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Slava Pestov diff --git a/basis/tools/test/ui/ui.factor b/basis/tools/test/ui/ui.factor deleted file mode 100644 index c37e7799cb..0000000000 --- a/basis/tools/test/ui/ui.factor +++ /dev/null @@ -1,16 +0,0 @@ -USING: dlists ui.gadgets ui.gadgets.private -kernel ui namespaces io.streams.string io ; -IN: tools.test.ui - -! We can't print to output-stream here because that might be a pane -! stream, and our graft-queue rebinding here would be captured -! by code adding children to the pane... -: with-grafted-gadget ( gadget quot -- ) - [ - \ graft-queue [ - over - graft notify-queued - dip - ungraft notify-queued - ] with-variable - ] with-string-writer print ; diff --git a/basis/ui/gadgets/debug/debug.factor b/basis/ui/gadgets/debug/debug.factor index 076c772f97..f8d496c1fc 100644 --- a/basis/ui/gadgets/debug/debug.factor +++ b/basis/ui/gadgets/debug/debug.factor @@ -2,9 +2,23 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays colors.constants combinators kernel opengl sequences ui ui.baseline-alignment ui.gadgets -ui.gadgets.buttons ui.gadgets.labels ui.pens ui.render ui.text ; +ui.gadgets.buttons ui.gadgets.labels ui.pens ui.render ui.text +ui.gadgets.private dlists namespaces io.streams.string io ; IN: ui.gadgets.debug +! We can't print to output-stream here because that might be a pane +! stream, and our graft-queue rebinding here would be captured +! by code adding children to the pane... +: with-grafted-gadget ( gadget quot -- ) + [ + \ graft-queue set + \ layout-queue set + over + graft notify-queued + dip + ungraft notify-queued + ] with-string-writer print ; inline + TUPLE: baseline-gadget < gadget baseline cap-height ; M: baseline-gadget baseline baseline>> ; diff --git a/basis/ui/gadgets/editors/editors-tests.factor b/basis/ui/gadgets/editors/editors-tests.factor index f8dc5b91c9..bd610ba53b 100644 --- a/basis/ui/gadgets/editors/editors-tests.factor +++ b/basis/ui/gadgets/editors/editors-tests.factor @@ -1,6 +1,6 @@ USING: accessors ui.gadgets.editors tools.test kernel io io.streams.plain definitions namespaces ui.gadgets -ui.gadgets.grids prettyprint documents ui.gestures tools.test.ui +ui.gadgets.grids prettyprint documents ui.gestures ui.gadgets.debug models documents.elements ui.gadgets.scrollers ui.gadgets.line-support sequences ; IN: ui.gadgets.editors.tests diff --git a/basis/ui/gadgets/panes/panes-tests.factor b/basis/ui/gadgets/panes/panes-tests.factor index 0c47af0214..0529437a76 100644 --- a/basis/ui/gadgets/panes/panes-tests.factor +++ b/basis/ui/gadgets/panes/panes-tests.factor @@ -1,7 +1,7 @@ USING: alien ui.gadgets.panes ui.gadgets namespaces kernel sequences io io.styles io.streams.string tools.test prettyprint definitions help help.syntax help.markup -help.stylesheet splitting tools.test.ui models math summary +help.stylesheet splitting ui.gadgets.debug models math summary inspector accessors help.topics see ; IN: ui.gadgets.panes.tests diff --git a/basis/ui/gadgets/scrollers/scrollers-tests.factor b/basis/ui/gadgets/scrollers/scrollers-tests.factor index 4e61c9b1ed..d4cdc95daf 100644 --- a/basis/ui/gadgets/scrollers/scrollers-tests.factor +++ b/basis/ui/gadgets/scrollers/scrollers-tests.factor @@ -1,7 +1,7 @@ USING: ui.gadgets ui.gadgets.scrollers namespaces tools.test kernel models models.product models.range ui.gadgets.viewports ui.gadgets.labels ui.gadgets.grids ui.gadgets.sliders math -math.vectors arrays sequences tools.test.ui math.rectangles +math.vectors arrays sequences ui.gadgets.debug math.rectangles accessors ui.gadgets.buttons ui.gadgets.packs ui.gadgets.scrollers.private ; IN: ui.gadgets.scrollers.tests diff --git a/basis/ui/tools/browser/browser-tests.factor b/basis/ui/tools/browser/browser-tests.factor index 7477edbe6a..3757f392c4 100644 --- a/basis/ui/tools/browser/browser-tests.factor +++ b/basis/ui/tools/browser/browser-tests.factor @@ -1,5 +1,5 @@ IN: ui.tools.browser.tests -USING: tools.test tools.test.ui ui.tools.browser math ; +USING: tools.test ui.gadgets.debug ui.tools.browser math ; \ must-infer [ ] [ \ + [ ] with-grafted-gadget ] unit-test diff --git a/basis/ui/tools/listener/listener-tests.factor b/basis/ui/tools/listener/listener-tests.factor index 63df55b71a..986e1270eb 100644 --- a/basis/ui/tools/listener/listener-tests.factor +++ b/basis/ui/tools/listener/listener-tests.factor @@ -1,7 +1,7 @@ USING: continuations documents ui.tools.listener hashtables kernel namespaces parser sequences tools.test ui.commands ui.gadgets ui.gadgets.editors -ui.gadgets.panes vocabs words tools.test.ui slots.private +ui.gadgets.panes vocabs words ui.gadgets.debug slots.private threads arrays generic threads accessors listener math calendar concurrency.promises io ui.tools.common ; IN: ui.tools.listener.tests From ff07c8f35203a3bc0c6677c18c943996f426b0f1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 25 Mar 2009 22:53:03 -0500 Subject: [PATCH 22/36] Fix compiler.tree.debugger tests --- basis/compiler/tree/debugger/debugger-tests.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/compiler/tree/debugger/debugger-tests.factor b/basis/compiler/tree/debugger/debugger-tests.factor index 4d1c5c824d..9b4a6da12a 100644 --- a/basis/compiler/tree/debugger/debugger-tests.factor +++ b/basis/compiler/tree/debugger/debugger-tests.factor @@ -1,5 +1,5 @@ IN: compiler.tree.debugger.tests -USING: compiler.tree.debugger tools.test sorting sequences io ; +USING: compiler.tree.debugger tools.test sorting sequences io math.order ; \ optimized. must-infer \ optimizer-report. must-infer From 6984c143e9a8ddea73fc67aa4afd4ac561bba84a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 25 Mar 2009 22:54:31 -0500 Subject: [PATCH 23/36] Fix hang when running ui tests --- basis/ui/gadgets/gadgets.factor | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/basis/ui/gadgets/gadgets.factor b/basis/ui/gadgets/gadgets.factor index a4bedf1ef7..adcfdfb00d 100644 --- a/basis/ui/gadgets/gadgets.factor +++ b/basis/ui/gadgets/gadgets.factor @@ -135,9 +135,7 @@ SYMBOL: ui-notify-flag : forget-pref-dim ( gadget -- ) f >>pref-dim drop ; -: ui-state ( symbol -- value ) get [ "UI not running" throw ] unless* ; - -: layout-queue ( -- queue ) \ layout-queue ui-state ; +: layout-queue ( -- queue ) \ layout-queue get ; : layout-later ( gadget -- ) #! When unit testing gadgets without the UI running, the @@ -216,7 +214,8 @@ M: gadget ungraft* drop ; > graft-queue delete-node ] From a2147ccb27269cfe7d81b85f12da0388df827691 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 25 Mar 2009 22:54:53 -0500 Subject: [PATCH 24/36] Slides from talk at PyCon VM summit, Chicago 2009 --- extra/chicago-talk/authors.txt | 1 + extra/chicago-talk/chicago-talk.factor | 65 ++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 extra/chicago-talk/authors.txt create mode 100644 extra/chicago-talk/chicago-talk.factor diff --git a/extra/chicago-talk/authors.txt b/extra/chicago-talk/authors.txt new file mode 100644 index 0000000000..d4f5d6b3ae --- /dev/null +++ b/extra/chicago-talk/authors.txt @@ -0,0 +1 @@ +Slava Pestov \ No newline at end of file diff --git a/extra/chicago-talk/chicago-talk.factor b/extra/chicago-talk/chicago-talk.factor new file mode 100644 index 0000000000..9d42ff13f2 --- /dev/null +++ b/extra/chicago-talk/chicago-talk.factor @@ -0,0 +1,65 @@ +! Copyright (C) 2009 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: slides help.markup ; +IN: chicago-talk + +CONSTANT: chicago-slides +{ +{ $slide "factor" + +{ $url "http://factorcode.org" } + +} +{ $slide "goals" + +"high level language" +"expressive and extensible" +"reasonable performance" +"interactive development with arbitrary redefinition" +"standalone app deployment (strip out compiler and REPL)" + +} +{ $slide "challenges" + +"higher-order functions" +"dynamic typing" +"memory allocation" +"float boxing/unboxing" +"integer overflow checks" +"user-defined abstractions" + +} +{ $slide "implementation" + +"VM: 12 kloc of C, library: >100 kloc of Factor" +"generational copying garbage collection, card marking write barrier" +"full continuations, tail calls" +"simple non-optimizing “bootstrap” compiler" +"optimizing compiler" + +} +{ $slide "optimizing compiler" + +"about 12,000 lines of Factor code" +"targets x86-32, x86-64, PowerPC" +"factor code ⇒ high-level SSA ⇒ low-level SSA ⇒ machine code" + +} +{ $slide "high-level optimizer" + +"macro expansion, defunctionalization" +"type and interval inference, sparse conditional constant propagation, method inlining" +"escape analysis and tuple unboxing" + +} +{ $slide "low-level optimizer" + +"alias analysis, value numbering, write barrier elimination" +"linear scan register allocation" + +} +} + +: chicago-talk ( -- ) chicago-slides slides-window ; + +MAIN: chicago-talk \ No newline at end of file From 3c1b716bf99a5c5432d8b3e0b04ba3d0af192be2 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 25 Mar 2009 23:00:02 -0500 Subject: [PATCH 25/36] move a lot of words to alien.libraries --- basis/alien/libraries/authors.txt | 1 + basis/alien/libraries/libraries-docs.factor | 60 +++++++++++++++++++++ basis/alien/libraries/libraries.factor | 22 ++++++++ 3 files changed, 83 insertions(+) create mode 100644 basis/alien/libraries/authors.txt create mode 100644 basis/alien/libraries/libraries-docs.factor create mode 100644 basis/alien/libraries/libraries.factor diff --git a/basis/alien/libraries/authors.txt b/basis/alien/libraries/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/basis/alien/libraries/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/basis/alien/libraries/libraries-docs.factor b/basis/alien/libraries/libraries-docs.factor new file mode 100644 index 0000000000..3b9c56c8fb --- /dev/null +++ b/basis/alien/libraries/libraries-docs.factor @@ -0,0 +1,60 @@ +! Copyright (C) 2009 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien alien.syntax assocs help.markup +help.syntax io.backend kernel namespaces ; +IN: alien.libraries + +HELP: +{ $values + { "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 } "." } ; + +HELP: libraries +{ $description "A global hashtable that keeps a list of open libraries. Use the " { $link add-library } " word to construct a library and add it with a single call." } ; + +HELP: library +{ $values { "name" "a string" } { "library" "a hashtable" } } +{ $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 "dll" } " - an instance of the " { $link dll } " class; only set if the library is loaded" } + } +} ; + +HELP: dlopen ( path -- dll ) +{ $values { "path" "a pathname string" } { "dll" "a DLL handle" } } +{ $description "Opens a native library and outputs a handle which may be passed to " { $link dlsym } " or " { $link dlclose } "." } +{ $errors "Throws an error if the library could not be found, or if loading fails for some other reason." } +{ $notes "This is the low-level facility used to implement " { $link load-library } ". Use the latter instead." } ; + +HELP: dlsym ( name dll -- alien ) +{ $values { "name" "a C symbol name" } { "dll" "a DLL handle" } { "alien" "an alien pointer" } } +{ $description "Looks up a symbol in a native library. If " { $snippet "dll" } " is " { $link f } " looks for the symbol in the runtime executable." } +{ $errors "Throws an error if the symbol could not be found." } ; + +HELP: dlclose ( dll -- ) +{ $values { "dll" "a DLL handle" } } +{ $description "Closes a DLL handle created by " { $link dlopen } ". This word might not be implemented on all platforms." } ; + +HELP: load-library +{ $values { "name" "a string" } { "dll" "a DLL handle" } } +{ $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" "a string" } { "path" "a string" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } } +{ $description "Defines a new logical library named " { $snippet "name" } " located in the file system at " { $snippet "path" } "and the specified ABI." } +{ $notes "Because the entire source file is parsed before top-level forms are executed, " { $link add-library } " cannot be used in the same file as " { $link POSTPONE: FUNCTION: } " definitions from that library. The " { $link add-library } " call will happen too late, after compilation, and the alien calls will not work." +$nl +"Instead, " { $link add-library } " calls must either be placed in different source files from those that use that library, or alternatively, " { $link "syntax-immediate" } " can be used to load the library before compilation." } +{ $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 ] }" + " [ drop ]" + "} cond >>" +} +"Note the parse time evaluation with " { $link POSTPONE: << } "." } ; diff --git a/basis/alien/libraries/libraries.factor b/basis/alien/libraries/libraries.factor new file mode 100644 index 0000000000..adb9eeb1bb --- /dev/null +++ b/basis/alien/libraries/libraries.factor @@ -0,0 +1,22 @@ +! Copyright (C) 2009 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien assocs io.backend kernel namespaces ; +IN: alien.libraries + +SYMBOL: libraries + +libraries [ H{ } clone ] initialize + +TUPLE: library path abi dll ; + +: library ( name -- library ) libraries get at ; + +: ( path abi -- library ) + over dup [ dlopen ] when \ library boa ; + +: load-library ( name -- dll ) + library dup [ dll>> ] when ; + +: add-library ( name path abi -- ) + [ dup [ normalize-path ] when ] dip + swap libraries get set-at ; From 8b7fcce399a5fff507f2868fbe094e0b2ed681fa Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 25 Mar 2009 23:00:19 -0500 Subject: [PATCH 26/36] update code for usages of add-library --- basis/alien/syntax/syntax.factor | 2 +- basis/cairo/ffi/ffi.factor | 3 +- basis/compiler/codegen/codegen.factor | 2 +- basis/compression/zlib/ffi/ffi.factor | 2 +- basis/core-text/utilities/utilities.factor | 3 +- basis/db/postgresql/ffi/ffi.factor | 2 +- basis/db/sqlite/ffi/ffi.factor | 2 +- basis/debugger/debugger-docs.factor | 3 +- basis/glib/glib.factor | 3 +- basis/opengl/gl/macosx/macosx.factor | 2 +- basis/openssl/libcrypto/libcrypto.factor | 3 +- basis/openssl/libssl/libssl.factor | 3 +- basis/pango/pango.factor | 4 +- basis/stack-checker/alien/alien.factor | 2 +- .../known-words/known-words.factor | 1 + basis/tools/disassembler/udis/udis.factor | 2 +- basis/ui/tools/profiler/profiler.factor | 2 +- basis/windows/ce/ce.factor | 2 +- basis/windows/dinput/dinput.factor | 6 -- basis/windows/nt/nt.factor | 3 +- core/alien/alien-docs.factor | 82 ++++--------------- core/alien/alien-tests.factor | 6 +- core/alien/alien.factor | 20 +---- core/bootstrap/primitives.factor | 7 +- extra/curses/ffi/ffi.factor | 3 +- extra/freetype/freetype.factor | 3 +- 26 files changed, 53 insertions(+), 120 deletions(-) diff --git a/basis/alien/syntax/syntax.factor b/basis/alien/syntax/syntax.factor index 5406970364..6a1bf7f635 100644 --- a/basis/alien/syntax/syntax.factor +++ b/basis/alien/syntax/syntax.factor @@ -4,7 +4,7 @@ USING: accessors arrays alien alien.c-types alien.structs 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 ; +fry vocabs.parser words.constant alien.libraries ; IN: alien.syntax SYNTAX: DLL" lexer get skip-blank parse-string dlopen parsed ; diff --git a/basis/cairo/ffi/ffi.factor b/basis/cairo/ffi/ffi.factor index e7c0a17660..2930843ad7 100644 --- a/basis/cairo/ffi/ffi.factor +++ b/basis/cairo/ffi/ffi.factor @@ -5,7 +5,8 @@ ! License: http://factorcode.org/license.txt USING: system combinators alien alien.syntax alien.c-types -alien.destructors kernel accessors sequences arrays ui.gadgets ; +alien.destructors kernel accessors sequences arrays ui.gadgets +alien.libraries ; IN: cairo.ffi << { diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index 4ddd0c0300..7df80c6b6e 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -3,7 +3,7 @@ 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.structs -alien.strings alien.arrays alien.complex sets libc +alien.strings alien.arrays alien.complex sets libc alien.libraries continuations.private fry cpu.architecture compiler.errors compiler.alien diff --git a/basis/compression/zlib/ffi/ffi.factor b/basis/compression/zlib/ffi/ffi.factor index d369c22e4c..a472f9a2fe 100755 --- a/basis/compression/zlib/ffi/ffi.factor +++ b/basis/compression/zlib/ffi/ffi.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien alien.syntax combinators system ; +USING: alien alien.syntax combinators system alien.libraries ; IN: compression.zlib.ffi << "zlib" { diff --git a/basis/core-text/utilities/utilities.factor b/basis/core-text/utilities/utilities.factor index 7de601c433..d3b1352750 100644 --- a/basis/core-text/utilities/utilities.factor +++ b/basis/core-text/utilities/utilities.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: words parser alien alien.c-types kernel fry accessors ; +USING: words parser alien alien.c-types kernel fry accessors +alien.libraries ; IN: core-text.utilities SYNTAX: C-GLOBAL: diff --git a/basis/db/postgresql/ffi/ffi.factor b/basis/db/postgresql/ffi/ffi.factor index fc407b06bd..93f93c9a13 100644 --- a/basis/db/postgresql/ffi/ffi.factor +++ b/basis/db/postgresql/ffi/ffi.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. ! tested on debian linux with postgresql 8.1 -USING: alien alien.syntax combinators system ; +USING: alien alien.syntax combinators system alien.libraries ; IN: db.postgresql.ffi << "postgresql" { diff --git a/basis/db/sqlite/ffi/ffi.factor b/basis/db/sqlite/ffi/ffi.factor index 341995634e..61394391a0 100644 --- a/basis/db/sqlite/ffi/ffi.factor +++ b/basis/db/sqlite/ffi/ffi.factor @@ -3,7 +3,7 @@ ! An interface to the sqlite database. Tested against sqlite v3.1.3. ! Not all functions have been wrapped. USING: alien compiler kernel math namespaces sequences strings alien.syntax - system combinators alien.c-types ; +system combinators alien.c-types alien.libraries ; IN: db.sqlite.ffi << "sqlite" { diff --git a/basis/debugger/debugger-docs.factor b/basis/debugger/debugger-docs.factor index 30c9fd37ab..ff5869efab 100644 --- a/basis/debugger/debugger-docs.factor +++ b/basis/debugger/debugger-docs.factor @@ -1,6 +1,7 @@ USING: alien arrays generic generic.math help.markup help.syntax kernel math memory strings sbufs vectors io io.files classes -help generic.standard continuations io.files.private listener ; +help generic.standard continuations io.files.private listener +alien.libraries ; IN: debugger ARTICLE: "debugger" "The debugger" diff --git a/basis/glib/glib.factor b/basis/glib/glib.factor index 1805f4bff9..ca481cb900 100755 --- a/basis/glib/glib.factor +++ b/basis/glib/glib.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2008 Matthew Willis. ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license -USING: alien alien.syntax alien.destructors combinators system ; +USING: alien alien.syntax alien.destructors combinators system +alien.libraries ; IN: glib << diff --git a/basis/opengl/gl/macosx/macosx.factor b/basis/opengl/gl/macosx/macosx.factor index eb8dda5e33..9e095a62e6 100644 --- a/basis/opengl/gl/macosx/macosx.factor +++ b/basis/opengl/gl/macosx/macosx.factor @@ -1,4 +1,4 @@ -USING: kernel alien ; +USING: kernel alien alien.libraries ; IN: opengl.gl.macosx : gl-function-context ( -- context ) 0 ; inline diff --git a/basis/openssl/libcrypto/libcrypto.factor b/basis/openssl/libcrypto/libcrypto.factor index 1a25b4d019..b9e00b6c8d 100644 --- a/basis/openssl/libcrypto/libcrypto.factor +++ b/basis/openssl/libcrypto/libcrypto.factor @@ -5,7 +5,8 @@ ! ! export LD_LIBRARY_PATH=/opt/local/lib -USING: alien alien.syntax combinators kernel system ; +USING: alien alien.syntax combinators kernel system +alien.libraries ; IN: openssl.libcrypto diff --git a/basis/openssl/libssl/libssl.factor b/basis/openssl/libssl/libssl.factor index 8ed15a4e5e..21f712fdc8 100644 --- a/basis/openssl/libssl/libssl.factor +++ b/basis/openssl/libssl/libssl.factor @@ -2,7 +2,8 @@ ! Portions copyright (C) 2008 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.syntax combinators kernel system namespaces -assocs parser lexer sequences words quotations math.bitwise ; +assocs parser lexer sequences words quotations math.bitwise +alien.libraries ; IN: openssl.libssl diff --git a/basis/pango/pango.factor b/basis/pango/pango.factor index 540d1cb9f7..ec5afa3c3d 100644 --- a/basis/pango/pango.factor +++ b/basis/pango/pango.factor @@ -2,7 +2,7 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license USING: arrays system alien.destructors alien.c-types alien.syntax alien -combinators math.rectangles kernel math ; +combinators math.rectangles kernel math alien.libraries ; IN: pango ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -34,4 +34,4 @@ C-STRUCT: PangoRectangle : PangoRectangle>rect ( PangoRectangle -- rect ) [ [ PangoRectangle-x pango>float ] [ PangoRectangle-y pango>float ] bi 2array ] [ [ PangoRectangle-width pango>float ] [ PangoRectangle-height pango>float ] bi 2array ] bi - ; \ No newline at end of file + ; diff --git a/basis/stack-checker/alien/alien.factor b/basis/stack-checker/alien/alien.factor index f52632040d..0b135319ff 100644 --- a/basis/stack-checker/alien/alien.factor +++ b/basis/stack-checker/alien/alien.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences accessors combinators math namespaces -init sets words +init sets words alien.libraries alien alien.c-types stack-checker.backend stack-checker.errors stack-checker.visitor ; IN: stack-checker.alien diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index a7f348d36b..a38bb42c7e 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -12,6 +12,7 @@ classes.tuple.private vectors vectors.private words definitions words.private assocs summary compiler.units system.private combinators locals locals.backend locals.types words.private quotations.private combinators.private stack-checker.values +alien.libraries stack-checker.alien stack-checker.state stack-checker.errors diff --git a/basis/tools/disassembler/udis/udis.factor b/basis/tools/disassembler/udis/udis.factor index 304595f41c..51e399c1c3 100755 --- a/basis/tools/disassembler/udis/udis.factor +++ b/basis/tools/disassembler/udis/udis.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: tools.disassembler namespaces combinators alien alien.syntax alien.c-types lexer parser kernel -sequences layouts math math.order +sequences layouts math math.order alien.libraries math.parser system make fry arrays ; IN: tools.disassembler.udis diff --git a/basis/ui/tools/profiler/profiler.factor b/basis/ui/tools/profiler/profiler.factor index 6bca4b40c4..1c2318a35e 100644 --- a/basis/ui/tools/profiler/profiler.factor +++ b/basis/ui/tools/profiler/profiler.factor @@ -210,4 +210,4 @@ profiler-gadget "toolbar" f { : com-profile ( quot -- ) profile profiler-window ; -MAIN: profiler-window \ No newline at end of file +MAIN: profiler-window diff --git a/basis/windows/ce/ce.factor b/basis/windows/ce/ce.factor index 18c48a0139..ff6a9ad4fc 100644 --- a/basis/windows/ce/ce.factor +++ b/basis/windows/ce/ce.factor @@ -1,4 +1,4 @@ -USING: alien sequences ; +USING: alien sequences alien.libraries ; { { "advapi32" "\\windows\\coredll.dll" "stdcall" } { "gdi32" "\\windows\\coredll.dll" "stdcall" } diff --git a/basis/windows/dinput/dinput.factor b/basis/windows/dinput/dinput.factor index dc544858b6..20a54dff98 100755 --- a/basis/windows/dinput/dinput.factor +++ b/basis/windows/dinput/dinput.factor @@ -2,12 +2,6 @@ USING: windows.kernel32 windows.ole32 windows.com windows.com.syntax alien alien.c-types alien.syntax kernel system namespaces math ; IN: windows.dinput -<< - os windows? - [ "dinput" "dinput8.dll" "stdcall" add-library ] - when ->> - LIBRARY: dinput TYPEDEF: void* LPDIENUMDEVICESCALLBACKW diff --git a/basis/windows/nt/nt.factor b/basis/windows/nt/nt.factor index 24d0032c5b..e05a409e67 100644 --- a/basis/windows/nt/nt.factor +++ b/basis/windows/nt/nt.factor @@ -1,6 +1,7 @@ -USING: alien sequences ; +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" } diff --git a/core/alien/alien-docs.factor b/core/alien/alien-docs.factor index edac8c09cc..398d04e4dd 100644 --- a/core/alien/alien-docs.factor +++ b/core/alien/alien-docs.factor @@ -1,7 +1,7 @@ USING: byte-arrays arrays help.syntax help.markup -alien.syntax compiler definitions math libc -debugger parser io io.backend system -alien.accessors eval ; +alien.syntax compiler definitions math libc eval +debugger parser io io.backend system alien.accessors +alien.libraries ; IN: alien HELP: alien @@ -22,16 +22,6 @@ HELP: { $values { "alien" c-ptr } } { $description "Constructs an invalid alien pointer that has expired." } ; -HELP: -{ $values - { "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 } "." } ; - -HELP: libraries -{ $description "A global hashtable that keeps a list of open libraries. Use the " { $link add-library } " word to construct a library and add it with a single call." } ; - HELP: ( displacement c-ptr -- alien ) { $values { "displacement" "an integer" } { "c-ptr" c-ptr } { "alien" "a new alien" } } { $description "Creates a new alien address object, wrapping a raw memory address. The alien points to a location in memory which is offset by " { $snippet "displacement" } " from the address of " { $snippet "c-ptr" } "." } @@ -54,61 +44,6 @@ HELP: 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*" } "." } ; -HELP: library -{ $values { "name" "a string" } { "library" "a hashtable" } } -{ $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 "dll" } " - an instance of the " { $link dll } " class; only set if the library is loaded" } - } -} ; - -HELP: dlopen ( path -- dll ) -{ $values { "path" "a pathname string" } { "dll" "a DLL handle" } } -{ $description "Opens a native library and outputs a handle which may be passed to " { $link dlsym } " or " { $link dlclose } "." } -{ $errors "Throws an error if the library could not be found, or if loading fails for some other reason." } -{ $notes "This is the low-level facility used to implement " { $link load-library } ". Use the latter instead." } ; - -HELP: dlsym ( name dll -- alien ) -{ $values { "name" "a C symbol name" } { "dll" "a DLL handle" } { "alien" "an alien pointer" } } -{ $description "Looks up a symbol in a native library. If " { $snippet "dll" } " is " { $link f } " looks for the symbol in the runtime executable." } -{ $errors "Throws an error if the symbol could not be found." } ; - -HELP: dlclose ( dll -- ) -{ $values { "dll" "a DLL handle" } } -{ $description "Closes a DLL handle created by " { $link dlopen } ". This word might not be implemented on all platforms." } ; - -HELP: load-library -{ $values { "name" "a string" } { "dll" "a DLL handle" } } -{ $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" "a string" } { "path" "a string" } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } } -{ $description "Defines a new logical library named " { $snippet "name" } " located in the file system at " { $snippet "path" } "and the specified ABI." } -{ $notes "Because the entire source file is parsed before top-level forms are executed, " { $link add-library } " cannot be used in the same file as " { $link POSTPONE: FUNCTION: } " definitions from that library. The " { $link add-library } " call will happen too late, after compilation, and the alien calls will not work." -$nl -"Instead, " { $link add-library } " calls must either be placed in different source files from those that use that library, or alternatively, " { $link "syntax-immediate" } " can be used to load the library before compilation." } -{ $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 ] }" - " [ drop ]" - "} cond >>" -} -"Note the parse time evaluation with " { $link POSTPONE: << } "." } ; - -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:" - { $list - { "This can happen when experimenting with " { $link alien-invoke } " in this listener. To fix the problem, place the " { $link alien-invoke } " call in a word; word definitions are automatically compiled with the optimizing compiler." } - { "The return type or parameter list references an unknown C type." } - { "The symbol or library could not be found." } - { "One of the four inputs to " { $link alien-invoke } " is not a literal value. To call functions which are not known at compile-time, use " { $link alien-indirect } "." } - } -} ; - 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" } } { $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 " { $snippet "\"void\"" } " indicates that no value is to be expected." } @@ -226,6 +161,16 @@ ARTICLE: "alien-invoke" "Calling C from Factor" { $subsection alien-indirect } "There are some details concerning the conversion of Factor objects to C values, and vice versa. See " { $link "c-data" } "." ; +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:" + { $list + { "This can happen when experimenting with " { $link alien-invoke } " in this listener. To fix the problem, place the " { $link alien-invoke } " call in a word; word definitions are automatically compiled with the optimizing compiler." } + { "The return type or parameter list references an unknown C type." } + { "The symbol or library could not be found." } + { "One of the four inputs to " { $link alien-invoke } " is not a literal value. To call functions which are not known at compile-time, use " { $link alien-indirect } "." } + } +} ; + ARTICLE: "alien-callback-gc" "Callbacks and code GC" "A callback consits of two parts; the callback word, which pushes the address of the callback on the stack when executed, and the callback body itself. If the callback word is redefined, removed from the dictionary using " { $link forget } ", or recompiled, the callback body will not be reclaimed by the garbage collector, since potentially C code may be holding a reference to the callback body." $nl @@ -321,6 +266,7 @@ $nl { $warning "C does not perform runtime type checking, automatic memory management or array bounds checks. Incorrect usage of C library functions can lead to crashes, data corruption, and security exploits." } { $subsection "loading-libs" } { $subsection "aliens" } +{ $subsection "alien.libraries" } { $subsection "alien-invoke" } { $subsection "alien-callback" } { $subsection "c-data" } diff --git a/core/alien/alien-tests.factor b/core/alien/alien-tests.factor index e4063b733c..57dc298c00 100644 --- a/core/alien/alien-tests.factor +++ b/core/alien/alien-tests.factor @@ -1,7 +1,7 @@ -IN: alien.tests USING: accessors alien alien.accessors alien.syntax byte-arrays arrays kernel kernel.private namespaces tools.test sequences libc math -system prettyprint layouts ; +system prettyprint layouts alien.libraries ; +IN: alien.tests [ t ] [ -1 alien-address 0 > ] unit-test @@ -85,4 +85,4 @@ f initialize-test set-global [ ] [ initialize-test get BAD-ALIEN >>alien drop ] unit-test -[ 7575 ] [ initialize-test [ 7575 ] initialize-alien ] unit-test \ No newline at end of file +[ 7575 ] [ initialize-test [ 7575 ] initialize-alien ] unit-test diff --git a/core/alien/alien.factor b/core/alien/alien.factor index 8e48ac770c..ea0cb9208e 100644 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2004, 2009 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 io.backend ; +kernel.private byte-arrays arrays init ; IN: alien ! Some predicate classes used by the compiler for optimization @@ -49,24 +49,6 @@ M: alien equal? 2drop f ] if ; -SYMBOL: libraries - -libraries [ H{ } clone ] initialize - -TUPLE: library path abi dll ; - -: library ( name -- library ) libraries get at ; - -: ( path abi -- library ) - over dup [ dlopen ] when \ library boa ; - -: load-library ( name -- dll ) - library dup [ dll>> ] when ; - -: add-library ( name path abi -- ) - [ dup [ normalize-path ] when ] dip - swap libraries get set-at ; - ERROR: alien-callback-error ; : alien-callback ( return parameters abi quot -- alien ) diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index ed64571582..e3803f2150 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -62,6 +62,7 @@ bootstrapping? on { "alien" "alien.accessors" + "alien.libraries" "arrays" "byte-arrays" "classes.private" @@ -458,9 +459,9 @@ tuple { "code-room" "memory" (( -- code-free code-total )) } { "micros" "system" (( -- us )) } { "modify-code-heap" "compiler.units" (( alist -- )) } - { "dlopen" "alien" (( path -- dll )) } - { "dlsym" "alien" (( name dll -- alien )) } - { "dlclose" "alien" (( dll -- )) } + { "dlopen" "alien.libraries" (( path -- dll )) } + { "dlsym" "alien.libraries" (( name dll -- alien )) } + { "dlclose" "alien.libraries" (( dll -- )) } { "" "byte-arrays" (( n -- byte-array )) } { "(byte-array)" "byte-arrays" (( n -- byte-array )) } { "" "alien" (( displacement c-ptr -- alien )) } diff --git a/extra/curses/ffi/ffi.factor b/extra/curses/ffi/ffi.factor index b1c481a576..3ff9404bff 100644 --- a/extra/curses/ffi/ffi.factor +++ b/extra/curses/ffi/ffi.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien alien.syntax combinators kernel system ; +USING: accessors alien alien.syntax combinators kernel system +alien.libraries ; IN: curses.ffi << "curses" { diff --git a/extra/freetype/freetype.factor b/extra/freetype/freetype.factor index 06c875b2fa..c45475cefa 100644 --- a/extra/freetype/freetype.factor +++ b/extra/freetype/freetype.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2005, 2007 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien alien.syntax kernel system combinators ; +USING: alien alien.syntax kernel system combinators +alien.libraries ; IN: freetype << "freetype" { From 77fccb27825a751ac49f54fe6ac6cd31cbc95a71 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Mar 2009 10:38:00 -0500 Subject: [PATCH 27/36] build with -fPIC on linux64 --- vm/Config.linux.x86.64 | 1 + 1 file changed, 1 insertion(+) diff --git a/vm/Config.linux.x86.64 b/vm/Config.linux.x86.64 index bfd1222496..7771ebdbbd 100644 --- a/vm/Config.linux.x86.64 +++ b/vm/Config.linux.x86.64 @@ -1,3 +1,4 @@ include vm/Config.linux include vm/Config.x86.64 LIBPATH = -L/usr/X11R6/lib64 -L/usr/X11R6/lib +CFLAGS = -fPIC From 4e33df153df2c64927dd2404fe2c1812502b8df9 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Mar 2009 10:43:54 -0500 Subject: [PATCH 28/36] add using --- basis/pango/cairo/cairo.factor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/basis/pango/cairo/cairo.factor b/basis/pango/cairo/cairo.factor index 7683b78890..45b7a9cb31 100644 --- a/basis/pango/cairo/cairo.factor +++ b/basis/pango/cairo/cairo.factor @@ -3,7 +3,8 @@ ! See http://factorcode.org/license.txt for BSD license. ! ! pangocairo bindings, from pango/pangocairo.h -USING: alien alien.syntax combinators system cairo.ffi ; +USING: alien alien.syntax combinators system cairo.ffi +alien.libraries ; IN: pango.cairo << { @@ -85,4 +86,4 @@ FUNCTION: void pango_cairo_layout_path ( cairo_t* cr, PangoLayout* layout ) ; FUNCTION: void -pango_cairo_error_underline_path ( cairo_t* cr, double x, double y, double width, double height ) ; \ No newline at end of file +pango_cairo_error_underline_path ( cairo_t* cr, double x, double y, double width, double height ) ; From b771758ff7d32676c18c6b7e2e041fb24f4526a4 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Mar 2009 10:45:52 -0500 Subject: [PATCH 29/36] fix load errors, help lint --- basis/alien/fortran/fortran.factor | 2 +- basis/compiler/tests/alien.factor | 2 +- basis/math/blas/ffi/ffi.factor | 3 ++- core/alien/alien-docs.factor | 1 - 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/basis/alien/fortran/fortran.factor b/basis/alien/fortran/fortran.factor index 83d56bf9e2..71efa1aa24 100644 --- a/basis/alien/fortran/fortran.factor +++ b/basis/alien/fortran/fortran.factor @@ -5,7 +5,7 @@ byte-arrays combinators combinators.short-circuit fry generalizations kernel lexer macros math math.parser namespaces parser sequences splitting stack-checker vectors vocabs.parser words locals io.encodings.ascii io.encodings.string shuffle effects math.ranges -math.order sorting strings system ; +math.order sorting strings system alien.libraries ; IN: alien.fortran SINGLETONS: f2c-abi gfortran-abi intel-unix-abi intel-windows-abi ; diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 2aed251676..aa9346f788 100644 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -4,7 +4,7 @@ namespaces namespaces tools.test sequences stack-checker stack-checker.errors words arrays parser quotations continuations effects namespaces.private io io.streams.string memory system threads tools.test math accessors combinators -specialized-arrays.float ; +specialized-arrays.float alien.libraries ; << : libfactor-ffi-tests-path ( -- string ) diff --git a/basis/math/blas/ffi/ffi.factor b/basis/math/blas/ffi/ffi.factor index 1749103ce4..5466ad2161 100644 --- a/basis/math/blas/ffi/ffi.factor +++ b/basis/math/blas/ffi/ffi.factor @@ -1,4 +1,5 @@ -USING: alien alien.fortran kernel system combinators ; +USING: alien alien.fortran kernel system combinators +alien.libraries ; IN: math.blas.ffi << diff --git a/core/alien/alien-docs.factor b/core/alien/alien-docs.factor index 398d04e4dd..6bd1d2f53a 100644 --- a/core/alien/alien-docs.factor +++ b/core/alien/alien-docs.factor @@ -266,7 +266,6 @@ $nl { $warning "C does not perform runtime type checking, automatic memory management or array bounds checks. Incorrect usage of C library functions can lead to crashes, data corruption, and security exploits." } { $subsection "loading-libs" } { $subsection "aliens" } -{ $subsection "alien.libraries" } { $subsection "alien-invoke" } { $subsection "alien-callback" } { $subsection "c-data" } From 785e3bcfd01db9e2bdf3e48a4cdfffc41bd0fbea Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Mar 2009 10:47:25 -0500 Subject: [PATCH 30/36] only use -fPIC on the ffi library --- Makefile | 2 +- vm/Config.linux.x86.64 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0c426ca5bc..bfaaa3eee4 100644 --- a/Makefile +++ b/Makefile @@ -160,7 +160,7 @@ factor-console: $(DLL_OBJS) $(EXE_OBJS) $(CFLAGS) $(CFLAGS_CONSOLE) -o factor$(EXE_SUFFIX)$(CONSOLE_EXTENSION) $(EXE_OBJS) factor-ffi-test: $(TEST_OBJS) - $(CC) $(LIBPATH) $(CFLAGS) $(SHARED_FLAG) -o libfactor-ffi-test$(DLL_EXTENSION) $(TEST_OBJS) + $(CC) $(LIBPATH) $(CFLAGS) $(FFI_TEST_CFLAGS) $(SHARED_FLAG) -o libfactor-ffi-test$(DLL_EXTENSION) $(TEST_OBJS) clean: rm -f vm/*.o diff --git a/vm/Config.linux.x86.64 b/vm/Config.linux.x86.64 index 7771ebdbbd..a02fcb4d6d 100644 --- a/vm/Config.linux.x86.64 +++ b/vm/Config.linux.x86.64 @@ -1,4 +1,4 @@ include vm/Config.linux include vm/Config.x86.64 LIBPATH = -L/usr/X11R6/lib64 -L/usr/X11R6/lib -CFLAGS = -fPIC +FFI_TEST_CFLAGS = -fPIC From 63e06589bddfa387fdbe41cc0abeaeac83f7b205 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Mar 2009 18:56:10 -0500 Subject: [PATCH 31/36] don't normalize-path in add-library --- basis/alien/libraries/libraries.factor | 1 - basis/compiler/tests/alien.factor | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/basis/alien/libraries/libraries.factor b/basis/alien/libraries/libraries.factor index adb9eeb1bb..3fcc15974c 100644 --- a/basis/alien/libraries/libraries.factor +++ b/basis/alien/libraries/libraries.factor @@ -18,5 +18,4 @@ TUPLE: library path abi dll ; library dup [ dll>> ] when ; : add-library ( name path abi -- ) - [ dup [ normalize-path ] when ] dip swap libraries get set-at ; diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index aa9346f788..b26abb561c 100644 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -1,18 +1,19 @@ -IN: compiler.tests USING: alien alien.c-types alien.syntax compiler kernel namespaces namespaces tools.test sequences stack-checker stack-checker.errors words arrays parser quotations continuations effects namespaces.private io io.streams.string memory system threads tools.test math accessors combinators specialized-arrays.float alien.libraries ; +IN: compiler.tests << : libfactor-ffi-tests-path ( -- string ) + "resource:" normalize-path { - { [ os winnt? ] [ "resource:libfactor-ffi-test.dll" ] } - { [ os macosx? ] [ "resource:libfactor-ffi-test.dylib" ] } - { [ os unix? ] [ "resource:libfactor-ffi-test.so" ] } - } cond ; + { [ os winnt? ] [ "libfactor-ffi-test.dll" ] } + { [ os macosx? ] [ "libfactor-ffi-test.dylib" ] } + { [ os unix? ] [ "libfactor-ffi-test.so" ] } + } cond append-path ; "f-cdecl" libfactor-ffi-tests-path "cdecl" add-library From 73b8bf1193deb75a4d147c979fc05c88df7cebb6 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Mar 2009 19:58:23 -0500 Subject: [PATCH 32/36] fix using list --- basis/compiler/tests/alien.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index b26abb561c..7d65ea7103 100644 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -3,7 +3,8 @@ namespaces namespaces tools.test sequences stack-checker stack-checker.errors words arrays parser quotations continuations effects namespaces.private io io.streams.string memory system threads tools.test math accessors combinators -specialized-arrays.float alien.libraries ; +specialized-arrays.float alien.libraries io.pathnames +io.backend ; IN: compiler.tests << From 9daf3d27715d427b49a0907379889717e9f1fd9f Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 26 Mar 2009 20:19:45 -0500 Subject: [PATCH 33/36] fix the makefile for linux64 ffi_test --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bfaaa3eee4..3f385ec496 100644 --- a/Makefile +++ b/Makefile @@ -159,7 +159,7 @@ factor-console: $(DLL_OBJS) $(EXE_OBJS) $(CC) $(LIBS) $(LIBPATH) -L. $(LINK_WITH_ENGINE) \ $(CFLAGS) $(CFLAGS_CONSOLE) -o factor$(EXE_SUFFIX)$(CONSOLE_EXTENSION) $(EXE_OBJS) -factor-ffi-test: $(TEST_OBJS) +factor-ffi-test: vm/ffi_test.o $(CC) $(LIBPATH) $(CFLAGS) $(FFI_TEST_CFLAGS) $(SHARED_FLAG) -o libfactor-ffi-test$(DLL_EXTENSION) $(TEST_OBJS) clean: @@ -169,6 +169,9 @@ clean: vm/resources.o: $(WINDRES) vm/factor.rs vm/resources.o +vm/ffi_test.o: vm/ffi_test.c + $(CC) -c $(CFLAGS) $(FFI_TEST_CFLAGS) -o $@ $< + .c.o: $(CC) -c $(CFLAGS) -o $@ $< From e04efe5f5acedd74d82298ac1b0269de52b5082f Mon Sep 17 00:00:00 2001 From: sheeple Date: Fri, 27 Mar 2009 10:41:24 -0500 Subject: [PATCH 34/36] use .a instead of .so on unix --- basis/compiler/tests/alien.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 7d65ea7103..c65fed55e2 100644 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -13,7 +13,7 @@ IN: compiler.tests { { [ os winnt? ] [ "libfactor-ffi-test.dll" ] } { [ os macosx? ] [ "libfactor-ffi-test.dylib" ] } - { [ os unix? ] [ "libfactor-ffi-test.so" ] } + { [ os unix? ] [ "libfactor-ffi-test.a" ] } } cond append-path ; "f-cdecl" libfactor-ffi-tests-path "cdecl" add-library From 1cf5c519ccb836a8e386626246d6d2e94b626040 Mon Sep 17 00:00:00 2001 From: sheeple Date: Fri, 27 Mar 2009 14:39:45 -0500 Subject: [PATCH 35/36] fix ffi tests on 32bit --- basis/compiler/tests/alien.factor | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index c65fed55e2..8d876891f2 100644 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -21,8 +21,6 @@ IN: compiler.tests "f-stdcall" libfactor-ffi-tests-path "stdcall" add-library >> -LIBRARY: f-cdecl - FUNCTION: void ffi_test_0 ; [ ] [ ffi_test_0 ] unit-test @@ -124,8 +122,6 @@ unit-test "int" { "int" "int" "int" "int" } "stdcall" alien-indirect gc ; -LIBRARY: f-stdcall - [ f ] [ "f-stdcall" load-library f = ] unit-test [ "stdcall" ] [ "f-stdcall" library abi>> ] unit-test @@ -166,7 +162,7 @@ FUNCTION: void ffi_test_20 double x1, double x2, double x3, : ffi_test_31 ( a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a -- result y ) "int" - "f-stdcall" "ffi_test_31" + "f-cdecl" "ffi_test_31" { "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" } alien-invoke gc 3 ; @@ -174,7 +170,7 @@ FUNCTION: void ffi_test_20 double x1, double x2, double x3, : ffi_test_31_point_5 ( a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a -- result ) "float" - "f-stdcall" "ffi_test_31_point_5" + "cdecl" "ffi_test_31_point_5" { "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" } alien-invoke ; From 45ed9b3b801173a85b76f691f025a5a1bf1395a9 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 27 Mar 2009 15:39:13 -0500 Subject: [PATCH 36/36] use -fPIC on all platforms for ffi lib --- Makefile | 1 + vm/Config.linux.x86.64 | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3f385ec496..ddfe916742 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ IMAGE = factor.image BUNDLE = Factor.app LIBPATH = -L/usr/X11R6/lib CFLAGS = -Wall +FFI_TEST_CFLAGS = -fPIC ifdef DEBUG CFLAGS += -g diff --git a/vm/Config.linux.x86.64 b/vm/Config.linux.x86.64 index a02fcb4d6d..bfd1222496 100644 --- a/vm/Config.linux.x86.64 +++ b/vm/Config.linux.x86.64 @@ -1,4 +1,3 @@ include vm/Config.linux include vm/Config.x86.64 LIBPATH = -L/usr/X11R6/lib64 -L/usr/X11R6/lib -FFI_TEST_CFLAGS = -fPIC