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

View File

@ -4,7 +4,7 @@ Loading factory
Putting factory into your image is as simple as this:
"factory" require save
"contrib/factory" require save
----------------------------------------------------------------------
Running factory in Xnest
@ -17,7 +17,7 @@ can use 2 or greater.
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:

View File

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

View File

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

View File

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

View File

@ -1,5 +1,10 @@
REQUIRES: contrib/parser-combinators contrib/concurrency ;
PROVIDE: contrib/space-invaders {
"cpu-8080.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
load all necessary files and run it:
"space-invaders" require
USE: space-invaders
run
"contrib/space-invaders" require
"contrib/space-invaders" run-module
For this to work it needs a ROM file called 'invaders.rom' in the
factor root directory.

View File

@ -1,8 +1,7 @@
This is a simple tetris game. To play, open factor (in GUI mode), and run:
"contrib/tetris" require
USING: tetris-gadget tetris ;
tetris-window
"contrib/tetris" run-module
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"
} ;
USE: tetris
MAIN: contrib/tetris tetris-window ;

View File

@ -2,11 +2,11 @@
! See http://factorcode.org/license.txt for BSD license.
IN: modules
USING: hashtables io kernel namespaces parser sequences
test words strings arrays math ;
test words strings arrays math help ;
SYMBOL: modules
TUPLE: module name files tests ;
TUPLE: module name files tests main ;
: module-def ( name -- path )
"resource:" over ".factor" append3
@ -74,3 +74,13 @@ C: module ( name files tests -- module )
: reload-modules ( -- )
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
] f ; parsing
: !MAIN:
scan [ swap module set-module-main ] f ; parsing
: !(
parse-effect word [
swap "declared-effect" set-word-prop