run-module word

darcs
slava 2006-10-20 02:41:20 +00:00
parent bd41d181e8
commit 4ddc751365
12 changed files with 44 additions and 18 deletions

View File

@ -8,6 +8,7 @@
+ ui: + ui:
- x11 double click
- menu should stay up if mouse button released - menu should stay up if mouse button released
- completion is not ideal: eg, search for "buttons" - completion is not ideal: eg, search for "buttons"
- some way of intercepting all gestures - some way of intercepting all gestures
@ -35,7 +36,6 @@
+ module system: + module system:
- convention for main entry point of a module
- convention for main help article of a module - convention for main help article of a module
- track a list of assets loaded from each module's file - track a list of assets loaded from each module's file
- C types should be words - C types should be words

View File

@ -4,7 +4,7 @@ Loading factory
Putting factory into your image is as simple as this: Putting factory into your image is as simple as this:
"factory" require save "contrib/factory" require save
---------------------------------------------------------------------- ----------------------------------------------------------------------
Running factory in Xnest Running factory in Xnest
@ -17,7 +17,7 @@ can use 2 or greater.
Start factor and launch factory on the appropriate display: Start factor and launch factory on the appropriate display:
USE: factory ":2" start-factory "contrib/factory" run-module
In a terminal, start an application on the appropriate display: In a terminal, start an application on the appropriate display:

View File

@ -2,3 +2,7 @@ REQUIRES: contrib/process contrib/concurrency contrib/x11
contrib/vars ; contrib/vars ;
PROVIDE: contrib/factory { "factory.factor" } ; PROVIDE: contrib/factory { "factory.factor" } ;
USE: factory
MAIN: contrib/factory f start-factory ;

View File

@ -1,8 +1,8 @@
! Copyright (C) 2003, 2005 Slava Pestov. ! Copyright (C) 2003, 2006 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
IN: httpd IN: httpd
USING: errors hashtables kernel namespaces io strings USING: errors hashtables kernel namespaces io strings
threads http sequences ; threads http sequences prettyprint ;
: (url>path) ( uri -- path ) : (url>path) ( uri -- path )
url-decode "http://" ?head [ url-decode "http://" ?head [
@ -50,6 +50,7 @@ threads http sequences ;
] if ; ] if ;
: httpd ( port -- ) : httpd ( port -- )
"Starting HTTP server on port " write dup . flush
\ httpd [ \ httpd [
60000 stdio get set-timeout 60000 stdio get set-timeout
readln [ parse-request ] when* readln [ parse-request ] when*

View File

@ -21,7 +21,5 @@ PROVIDE: contrib/httpd {
"test/url-encoding.factor" "test/url-encoding.factor"
} ; } ;
"To start the HTTP server, issue the following command in the listener:" print USE: httpd
" USE: httpd" print MAIN: contrib/httpd 8888 httpd ;
" [ 8888 httpd ] in-thread" print
"Replacing '8888' with whatever port number you desire." print

View File

@ -6,4 +6,7 @@ PROVIDE: contrib/lambda {
"lambda.factor" "lambda.factor"
} { } {
"test/lambda.factor" "test/lambda.factor"
} ; } ;
USE: lambda
MAIN: contrib/lambda lambda ;

View File

@ -1,5 +1,10 @@
REQUIRES: contrib/parser-combinators contrib/concurrency ; REQUIRES: contrib/parser-combinators contrib/concurrency ;
PROVIDE: contrib/space-invaders { PROVIDE: contrib/space-invaders {
"cpu-8080.factor" "cpu-8080.factor"
"space-invaders.factor" "space-invaders.factor"
} { } ; } { } ;
USE: space-invaders
MAIN: contrib/space-invaders run ;

View File

@ -4,9 +4,8 @@ emulator, disassembler and assembler for the 8080 processor.
It is integrated into the Factor module system, the following will It is integrated into the Factor module system, the following will
load all necessary files and run it: load all necessary files and run it:
"space-invaders" require "contrib/space-invaders" require
USE: space-invaders "contrib/space-invaders" run-module
run
For this to work it needs a ROM file called 'invaders.rom' in the For this to work it needs a ROM file called 'invaders.rom' in the
factor root directory. factor root directory.

View File

@ -1,8 +1,7 @@
This is a simple tetris game. To play, open factor (in GUI mode), and run: This is a simple tetris game. To play, open factor (in GUI mode), and run:
"contrib/tetris" require "contrib/tetris" require
USING: tetris-gadget tetris ; "contrib/tetris" run-module
tetris-window
This should open a new window with a running tetris game. The commands are: This should open a new window with a running tetris game. The commands are:

View File

@ -10,3 +10,7 @@ PROVIDE: contrib/tetris {
} { } {
"test/tetris-piece.factor" "test/tetris-board.factor" "test/tetris.factor" "test/tetris-piece.factor" "test/tetris-board.factor" "test/tetris.factor"
} ; } ;
USE: tetris
MAIN: contrib/tetris tetris-window ;

View File

@ -2,11 +2,11 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
IN: modules IN: modules
USING: hashtables io kernel namespaces parser sequences USING: hashtables io kernel namespaces parser sequences
test words strings arrays math ; test words strings arrays math help ;
SYMBOL: modules SYMBOL: modules
TUPLE: module name files tests ; TUPLE: module name files tests main ;
: module-def ( name -- path ) : module-def ( name -- path )
"resource:" over ".factor" append3 "resource:" over ".factor" append3
@ -74,3 +74,13 @@ C: module ( name files tests -- module )
: reload-modules ( -- ) : reload-modules ( -- )
all-modules [ reload-module ] each do-parse-hook ; all-modules [ reload-module ] each do-parse-hook ;
: run-module ( name -- )
dup module module-main [
call
] [
"The module " write write
" does not define an entry point." print
"To define one, see the documentation for the " write
\ MAIN: ($link) " word." print
] ?if ;

View File

@ -81,6 +81,9 @@ DEFER: !PRIMITIVE: parsing
[ [ require ] each ] no-parse-hook [ [ require ] each ] no-parse-hook
] f ; parsing ] f ; parsing
: !MAIN:
scan [ swap module set-module-main ] f ; parsing
: !( : !(
parse-effect word [ parse-effect word [
swap "declared-effect" set-word-prop swap "declared-effect" set-word-prop