From 3a1bb22618147bf2dfa7cc9cf21ad5d6fb342b5e Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 7 Oct 2009 19:30:06 -0500 Subject: [PATCH 01/10] delete malloc-file-contents 'cause it sucks and nobody likes it --- basis/alien/data/data-docs.factor | 1 - basis/alien/data/data.factor | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/basis/alien/data/data-docs.factor b/basis/alien/data/data-docs.factor index 68d5022630..0536d15736 100644 --- a/basis/alien/data/data-docs.factor +++ b/basis/alien/data/data-docs.factor @@ -56,7 +56,6 @@ $nl { $subsections malloc-object malloc-byte-array - malloc-file-contents } "The " { $vocab-link "libc" } " vocabulary defines several words which directly call C standard library memory management functions:" { $subsections diff --git a/basis/alien/data/data.factor b/basis/alien/data/data.factor index 372f3e5f98..fc18921ef1 100644 --- a/basis/alien/data/data.factor +++ b/basis/alien/data/data.factor @@ -56,9 +56,6 @@ M: word : malloc-string ( string encoding -- alien ) string>alien malloc-byte-array ; -: malloc-file-contents ( path -- alien len ) - binary file-contents [ malloc-byte-array ] [ length ] bi ; - M: memory-stream stream-read [ [ index>> ] [ alien>> ] bi @@ -81,3 +78,4 @@ M: value-type c-type-setter ( type -- quot ) [ c-type-getter ] [ c-type-unboxer-quot ] [ heap-size ] tri '[ @ swap @ _ memcpy ] ; + From 1f8495a62f2da319d158764b05f4f94848ec84ef Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 7 Oct 2009 21:49:04 -0500 Subject: [PATCH 02/10] vm/os-netbsd.cpp: fix double-free error --- vm/os-netbsd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/os-netbsd.cpp b/vm/os-netbsd.cpp index e280d99a80..e1bdc30460 100644 --- a/vm/os-netbsd.cpp +++ b/vm/os-netbsd.cpp @@ -10,7 +10,7 @@ const char *vm_executable_path() static Dl_info info = {0}; if (!info.dli_fname) dladdr((void *)main, &info); - return info.dli_fname; + return safe_strdup(info.dli_fname); } } From fcc53d174cfb62b32a2f2304f74d0bff76b5a85f Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 8 Oct 2009 01:42:54 -0500 Subject: [PATCH 03/10] move game-* to game.* and update all usages --- basis/game-input/dinput/summary.txt | 1 - basis/game-input/iokit/summary.txt | 1 - basis/{game-input => game/input}/authors.txt | 0 basis/{game-input => game/input}/dinput/authors.txt | 0 basis/{game-input => game/input}/dinput/dinput.factor | 4 ++-- .../input}/dinput/keys-array/keys-array.factor | 2 +- basis/game/input/dinput/summary.txt | 1 + basis/{game-input => game/input}/dinput/tags.txt | 0 .../game-input-docs.factor => game/input/input-docs.factor} | 6 +++--- .../input/input-tests.factor} | 4 ++-- .../game-input.factor => game/input/input.factor} | 6 +++--- basis/{game-input => game/input}/iokit/authors.txt | 0 basis/{game-input => game/input}/iokit/iokit.factor | 4 ++-- basis/game/input/iokit/summary.txt | 1 + basis/{game-input => game/input}/iokit/tags.txt | 0 basis/{game-input => game/input}/scancodes/authors.txt | 0 basis/{game-input => game/input}/scancodes/scancodes.factor | 2 +- basis/{game-input => game/input}/scancodes/summary.txt | 0 basis/{game-input => game/input}/scancodes/tags.txt | 0 basis/{game-input => game/input}/summary.txt | 0 basis/{game-input => game/input}/tags.txt | 0 extra/{game-loop/game-loop.factor => game/loop/loop.factor} | 4 ++-- .../{game-loop => game/loop}/prettyprint/prettyprint.factor | 4 ++-- .../game-worlds.factor => game/worlds/worlds.factor} | 4 ++-- extra/gpu/demos/bunny/bunny.factor | 2 +- extra/gpu/demos/raytrace/raytrace.factor | 2 +- extra/gpu/util/wasd/wasd.factor | 2 +- extra/joystick-demo/joystick-demo.factor | 2 +- extra/key-caps/key-caps.factor | 2 +- extra/terrain/terrain.factor | 6 +++--- 30 files changed, 30 insertions(+), 30 deletions(-) delete mode 100755 basis/game-input/dinput/summary.txt delete mode 100644 basis/game-input/iokit/summary.txt rename basis/{game-input => game/input}/authors.txt (100%) rename basis/{game-input => game/input}/dinput/authors.txt (100%) rename basis/{game-input => game/input}/dinput/dinput.factor (99%) rename basis/{game-input => game/input}/dinput/keys-array/keys-array.factor (91%) create mode 100755 basis/game/input/dinput/summary.txt rename basis/{game-input => game/input}/dinput/tags.txt (100%) rename basis/{game-input/game-input-docs.factor => game/input/input-docs.factor} (99%) rename basis/{game-input/game-input-tests.factor => game/input/input-tests.factor} (69%) rename basis/{game-input/game-input.factor => game/input/input.factor} (95%) rename basis/{game-input => game/input}/iokit/authors.txt (100%) rename basis/{game-input => game/input}/iokit/iokit.factor (99%) create mode 100644 basis/game/input/iokit/summary.txt rename basis/{game-input => game/input}/iokit/tags.txt (100%) rename basis/{game-input => game/input}/scancodes/authors.txt (100%) rename basis/{game-input => game/input}/scancodes/scancodes.factor (99%) rename basis/{game-input => game/input}/scancodes/summary.txt (100%) rename basis/{game-input => game/input}/scancodes/tags.txt (100%) rename basis/{game-input => game/input}/summary.txt (100%) rename basis/{game-input => game/input}/tags.txt (100%) rename extra/{game-loop/game-loop.factor => game/loop/loop.factor} (97%) rename extra/{game-loop => game/loop}/prettyprint/prettyprint.factor (77%) rename extra/{game-worlds/game-worlds.factor => game/worlds/worlds.factor} (85%) diff --git a/basis/game-input/dinput/summary.txt b/basis/game-input/dinput/summary.txt deleted file mode 100755 index f758a5f83a..0000000000 --- a/basis/game-input/dinput/summary.txt +++ /dev/null @@ -1 +0,0 @@ -DirectInput backend for game-input diff --git a/basis/game-input/iokit/summary.txt b/basis/game-input/iokit/summary.txt deleted file mode 100644 index 8fc5d827d0..0000000000 --- a/basis/game-input/iokit/summary.txt +++ /dev/null @@ -1 +0,0 @@ -IOKit HID Manager backend for game-input diff --git a/basis/game-input/authors.txt b/basis/game/input/authors.txt similarity index 100% rename from basis/game-input/authors.txt rename to basis/game/input/authors.txt diff --git a/basis/game-input/dinput/authors.txt b/basis/game/input/dinput/authors.txt similarity index 100% rename from basis/game-input/dinput/authors.txt rename to basis/game/input/dinput/authors.txt diff --git a/basis/game-input/dinput/dinput.factor b/basis/game/input/dinput/dinput.factor similarity index 99% rename from basis/game-input/dinput/dinput.factor rename to basis/game/input/dinput/dinput.factor index e6a8cca477..f03147205f 100755 --- a/basis/game-input/dinput/dinput.factor +++ b/basis/game/input/dinput/dinput.factor @@ -1,6 +1,6 @@ USING: accessors alien alien.c-types alien.strings arrays assocs byte-arrays combinators combinators.short-circuit -continuations game-input game-input.dinput.keys-array +continuations game.input game.input.dinput.keys-array io.encodings.utf16 io.encodings.utf16n kernel locals math math.bitwise math.rectangles namespaces parser sequences shuffle specialized-arrays ui.backend.windows vectors @@ -8,7 +8,7 @@ windows.com windows.dinput windows.dinput.constants windows.errors windows.kernel32 windows.messages windows.ole32 windows.user32 classes.struct alien.data ; SPECIALIZED-ARRAY: DIDEVICEOBJECTDATA -IN: game-input.dinput +IN: game.input.dinput CONSTANT: MOUSE-BUFFER-SIZE 16 diff --git a/basis/game-input/dinput/keys-array/keys-array.factor b/basis/game/input/dinput/keys-array/keys-array.factor similarity index 91% rename from basis/game-input/dinput/keys-array/keys-array.factor rename to basis/game/input/dinput/keys-array/keys-array.factor index a8813b0397..3426b89141 100755 --- a/basis/game-input/dinput/keys-array/keys-array.factor +++ b/basis/game/input/dinput/keys-array/keys-array.factor @@ -1,6 +1,6 @@ USING: sequences sequences.private math accessors alien.data ; -IN: game-input.dinput.keys-array +IN: game.input.dinput.keys-array TUPLE: keys-array { underlying sequence read-only } diff --git a/basis/game/input/dinput/summary.txt b/basis/game/input/dinput/summary.txt new file mode 100755 index 0000000000..69a3737072 --- /dev/null +++ b/basis/game/input/dinput/summary.txt @@ -0,0 +1 @@ +DirectInput backend for game.input diff --git a/basis/game-input/dinput/tags.txt b/basis/game/input/dinput/tags.txt similarity index 100% rename from basis/game-input/dinput/tags.txt rename to basis/game/input/dinput/tags.txt diff --git a/basis/game-input/game-input-docs.factor b/basis/game/input/input-docs.factor similarity index 99% rename from basis/game-input/game-input-docs.factor rename to basis/game/input/input-docs.factor index 42e4163696..bef08c4d2f 100755 --- a/basis/game-input/game-input-docs.factor +++ b/basis/game/input/input-docs.factor @@ -1,6 +1,6 @@ USING: help.markup help.syntax kernel ui.gestures quotations sequences strings math ; -IN: game-input +IN: game.input ARTICLE: "game-input" "Game controller input" "The " { $vocab-link "game-input" } " vocabulary provides cross-platform access to game controller devices such as joysticks and gamepads. It also provides an interface for polling raw keyboard and mouse input." $nl @@ -136,8 +136,8 @@ HELP: controller-state { "A value of " { $link f } " in any slot (besides the elements of " { $snippet "buttons" } ") indicates that the corresponding element is not present on the device." } } } ; HELP: keyboard-state -{ $class-description "The " { $link read-keyboard } " word returns objects of this class. The " { $snippet "keys" } " slot of a " { $snippet "keyboard-state" } " object contains a " { $link sequence } " of 256 members representing the state of the keys on the keyboard. Each element is a boolean value indicating whether the corresponding key is pressed. The sequence is indexed by scancode as defined under usage page 7 of the USB HID standard. Named scancode constants are provided in the " { $vocab-link "game-input.scancodes" } " vocabulary." } -{ $warning "The scancodes used to index " { $snippet "keyboard-state" } " objects correspond to physical key positions on the keyboard--they are unaffected by keymaps, modifier keys, or other operating environment postprocessing. The face value of the constants in " { $vocab-link "game-input.scancodes" } " do not necessarily correspond to what the user expects the key to type. Because of this, " { $link read-keyboard } " should not be used for text entry purposes. The Factor UI's standard gesture mechanism should be used in cases where the logical meaning of keypresses is needed; see " { $link "keyboard-gestures" } "." } ; +{ $class-description "The " { $link read-keyboard } " word returns objects of this class. The " { $snippet "keys" } " slot of a " { $snippet "keyboard-state" } " object contains a " { $link sequence } " of 256 members representing the state of the keys on the keyboard. Each element is a boolean value indicating whether the corresponding key is pressed. The sequence is indexed by scancode as defined under usage page 7 of the USB HID standard. Named scancode constants are provided in the " { $vocab-link "game.input.scancodes" } " vocabulary." } +{ $warning "The scancodes used to index " { $snippet "keyboard-state" } " objects correspond to physical key positions on the keyboard--they are unaffected by keymaps, modifier keys, or other operating environment postprocessing. The face value of the constants in " { $vocab-link "game.input.scancodes" } " do not necessarily correspond to what the user expects the key to type. Because of this, " { $link read-keyboard } " should not be used for text entry purposes. The Factor UI's standard gesture mechanism should be used in cases where the logical meaning of keypresses is needed; see " { $link "keyboard-gestures" } "." } ; HELP: mouse-state { $class-description "The " { $link read-mouse } " word returns objects of this class. " { $snippet "mouse-state" } " objects have the following slots:" diff --git a/basis/game-input/game-input-tests.factor b/basis/game/input/input-tests.factor similarity index 69% rename from basis/game-input/game-input-tests.factor rename to basis/game/input/input-tests.factor index 10f3b5d7f5..bd993bf811 100644 --- a/basis/game-input/game-input-tests.factor +++ b/basis/game/input/input-tests.factor @@ -1,6 +1,6 @@ -USING: ui game-input tools.test kernel system threads calendar +USING: ui game.input tools.test kernel system threads calendar combinators.short-circuit ; -IN: game-input.tests +IN: game.input.tests os { [ windows? ] [ macosx? ] } 1|| [ [ ] [ open-game-input ] unit-test diff --git a/basis/game-input/game-input.factor b/basis/game/input/input.factor similarity index 95% rename from basis/game-input/game-input.factor rename to basis/game/input/input.factor index c21b900d8c..377a89a884 100755 --- a/basis/game-input/game-input.factor +++ b/basis/game/input/input.factor @@ -1,6 +1,6 @@ USING: arrays accessors continuations kernel math system sequences namespaces init vocabs vocabs.loader combinators ; -IN: game-input +IN: game.input SYMBOLS: game-input-backend game-input-opened ; @@ -91,7 +91,7 @@ M: mouse-state clone call-next-method dup buttons>> clone >>buttons ; { - { [ os windows? ] [ "game-input.dinput" require ] } - { [ os macosx? ] [ "game-input.iokit" require ] } + { [ os windows? ] [ "game.input.dinput" require ] } + { [ os macosx? ] [ "game.input.iokit" require ] } { [ t ] [ ] } } cond diff --git a/basis/game-input/iokit/authors.txt b/basis/game/input/iokit/authors.txt similarity index 100% rename from basis/game-input/iokit/authors.txt rename to basis/game/input/iokit/authors.txt diff --git a/basis/game-input/iokit/iokit.factor b/basis/game/input/iokit/iokit.factor similarity index 99% rename from basis/game-input/iokit/iokit.factor rename to basis/game/input/iokit/iokit.factor index 85f058f283..258f19ed5e 100755 --- a/basis/game-input/iokit/iokit.factor +++ b/basis/game/input/iokit/iokit.factor @@ -3,9 +3,9 @@ kernel cocoa.enumeration destructors math.parser cocoa.application sequences locals combinators.short-circuit threads namespaces assocs arrays combinators hints alien core-foundation.run-loop accessors sequences.private -alien.c-types alien.data math parser game-input vectors +alien.c-types alien.data math parser game.input vectors bit-arrays ; -IN: game-input.iokit +IN: game.input.iokit SINGLETON: iokit-game-input-backend diff --git a/basis/game/input/iokit/summary.txt b/basis/game/input/iokit/summary.txt new file mode 100644 index 0000000000..5db3d08440 --- /dev/null +++ b/basis/game/input/iokit/summary.txt @@ -0,0 +1 @@ +IOKit HID Manager backend for game.input diff --git a/basis/game-input/iokit/tags.txt b/basis/game/input/iokit/tags.txt similarity index 100% rename from basis/game-input/iokit/tags.txt rename to basis/game/input/iokit/tags.txt diff --git a/basis/game-input/scancodes/authors.txt b/basis/game/input/scancodes/authors.txt similarity index 100% rename from basis/game-input/scancodes/authors.txt rename to basis/game/input/scancodes/authors.txt diff --git a/basis/game-input/scancodes/scancodes.factor b/basis/game/input/scancodes/scancodes.factor similarity index 99% rename from basis/game-input/scancodes/scancodes.factor rename to basis/game/input/scancodes/scancodes.factor index 3303a51c6f..cfa659e57a 100644 --- a/basis/game-input/scancodes/scancodes.factor +++ b/basis/game/input/scancodes/scancodes.factor @@ -1,4 +1,4 @@ -IN: game-input.scancodes +IN: game.input.scancodes CONSTANT: key-undefined HEX: 0000 CONSTANT: key-error-roll-over HEX: 0001 diff --git a/basis/game-input/scancodes/summary.txt b/basis/game/input/scancodes/summary.txt similarity index 100% rename from basis/game-input/scancodes/summary.txt rename to basis/game/input/scancodes/summary.txt diff --git a/basis/game-input/scancodes/tags.txt b/basis/game/input/scancodes/tags.txt similarity index 100% rename from basis/game-input/scancodes/tags.txt rename to basis/game/input/scancodes/tags.txt diff --git a/basis/game-input/summary.txt b/basis/game/input/summary.txt similarity index 100% rename from basis/game-input/summary.txt rename to basis/game/input/summary.txt diff --git a/basis/game-input/tags.txt b/basis/game/input/tags.txt similarity index 100% rename from basis/game-input/tags.txt rename to basis/game/input/tags.txt diff --git a/extra/game-loop/game-loop.factor b/extra/game/loop/loop.factor similarity index 97% rename from extra/game-loop/game-loop.factor rename to extra/game/loop/loop.factor index 5f78c6770c..1346988fd1 100644 --- a/extra/game-loop/game-loop.factor +++ b/extra/game/loop/loop.factor @@ -1,7 +1,7 @@ USING: accessors calendar continuations destructors kernel math math.order namespaces system threads ui ui.gadgets.worlds sequences ; -IN: game-loop +IN: game.loop TUPLE: game-loop { tick-length integer read-only } @@ -106,4 +106,4 @@ M: game-loop dispose USING: vocabs vocabs.loader ; -"prettyprint" vocab [ "game-loop.prettyprint" require ] when +"prettyprint" vocab [ "game.loop.prettyprint" require ] when diff --git a/extra/game-loop/prettyprint/prettyprint.factor b/extra/game/loop/prettyprint/prettyprint.factor similarity index 77% rename from extra/game-loop/prettyprint/prettyprint.factor rename to extra/game/loop/prettyprint/prettyprint.factor index 8b20dd4c9d..44649263de 100644 --- a/extra/game-loop/prettyprint/prettyprint.factor +++ b/extra/game/loop/prettyprint/prettyprint.factor @@ -1,6 +1,6 @@ ! (c)2009 Joe Groff bsd license -USING: accessors debugger game-loop io ; -IN: game-loop.prettyprint +USING: accessors debugger game.loop io ; +IN: game.loop.prettyprint M: game-loop-error error. "An error occurred inside a game loop." print diff --git a/extra/game-worlds/game-worlds.factor b/extra/game/worlds/worlds.factor similarity index 85% rename from extra/game-worlds/game-worlds.factor rename to extra/game/worlds/worlds.factor index 542c48fbae..399c5d1902 100644 --- a/extra/game-worlds/game-worlds.factor +++ b/extra/game/worlds/worlds.factor @@ -1,6 +1,6 @@ -USING: accessors game-input game-loop kernel math ui.gadgets +USING: accessors game.input game.loop kernel math ui.gadgets ui.gadgets.worlds ui.gestures threads ; -IN: game-worlds +IN: game.worlds TUPLE: game-world < world game-loop diff --git a/extra/gpu/demos/bunny/bunny.factor b/extra/gpu/demos/bunny/bunny.factor index d6c7456d63..2e292f0141 100755 --- a/extra/gpu/demos/bunny/bunny.factor +++ b/extra/gpu/demos/bunny/bunny.factor @@ -1,6 +1,6 @@ ! (c)2009 Joe Groff bsd license USING: accessors alien.c-types arrays classes.struct combinators -combinators.short-circuit game-worlds gpu gpu.buffers +combinators.short-circuit game.worlds gpu gpu.buffers gpu.util.wasd gpu.framebuffers gpu.render gpu.shaders gpu.state gpu.textures gpu.util grouping http.client images images.loader io io.encodings.ascii io.files io.files.temp kernel math diff --git a/extra/gpu/demos/raytrace/raytrace.factor b/extra/gpu/demos/raytrace/raytrace.factor index 339f192416..5a3d5864fb 100644 --- a/extra/gpu/demos/raytrace/raytrace.factor +++ b/extra/gpu/demos/raytrace/raytrace.factor @@ -1,5 +1,5 @@ ! (c)2009 Joe Groff bsd license -USING: accessors arrays combinators.tuple game-loop game-worlds +USING: accessors arrays combinators.tuple game.loop game.worlds generalizations gpu gpu.render gpu.shaders gpu.util gpu.util.wasd kernel literals math math.matrices math.order math.vectors method-chains sequences ui ui.gadgets ui.gadgets.worlds diff --git a/extra/gpu/util/wasd/wasd.factor b/extra/gpu/util/wasd/wasd.factor index 496735f0db..1f1187fd21 100644 --- a/extra/gpu/util/wasd/wasd.factor +++ b/extra/gpu/util/wasd/wasd.factor @@ -1,6 +1,6 @@ ! (c)2009 Joe Groff bsd license USING: accessors arrays combinators.smart game-input -game-input.scancodes game-loop game-worlds +game.input.scancodes game.loop game.worlds gpu.render gpu.state kernel literals locals math math.constants math.functions math.matrices math.order math.vectors opengl.gl sequences diff --git a/extra/joystick-demo/joystick-demo.factor b/extra/joystick-demo/joystick-demo.factor index 3f24a5bb39..90e28594e7 100755 --- a/extra/joystick-demo/joystick-demo.factor +++ b/extra/joystick-demo/joystick-demo.factor @@ -1,6 +1,6 @@ USING: ui ui.gadgets sequences kernel arrays math colors colors.constants ui.render ui.pens.polygon ui.pens.solid math.vectors -accessors fry ui.gadgets.packs game-input ui.gadgets.labels +accessors fry ui.gadgets.packs game.input ui.gadgets.labels ui.gadgets.borders alarms calendar locals strings ui.gadgets.buttons combinators math.parser assocs threads ; IN: joystick-demo diff --git a/extra/key-caps/key-caps.factor b/extra/key-caps/key-caps.factor index b58870fadc..da901ed61e 100755 --- a/extra/key-caps/key-caps.factor +++ b/extra/key-caps/key-caps.factor @@ -1,4 +1,4 @@ -USING: game-input game-input.scancodes +USING: game.input game.input.scancodes kernel ui.gadgets ui.gadgets.buttons sequences accessors words arrays assocs math calendar fry alarms ui ui.gadgets.borders ui.gestures ; diff --git a/extra/terrain/terrain.factor b/extra/terrain/terrain.factor index 050a835422..18e49f3e2f 100644 --- a/extra/terrain/terrain.factor +++ b/extra/terrain/terrain.factor @@ -1,12 +1,12 @@ ! (c)2009 Joe Groff, Doug Coleman. bsd license -USING: accessors arrays combinators game-input game-loop -game-input.scancodes grouping kernel literals locals +USING: accessors arrays combinators game.input game.loop +game.input.scancodes grouping kernel literals locals math math.constants math.functions math.matrices math.order math.vectors opengl opengl.capabilities opengl.gl opengl.shaders opengl.textures opengl.textures.private sequences sequences.product specialized-arrays terrain.generation terrain.shaders ui ui.gadgets -ui.gadgets.worlds ui.pixel-formats game-worlds method-chains +ui.gadgets.worlds ui.pixel-formats game.worlds method-chains math.affine-transforms noise ui.gestures combinators.short-circuit destructors grid-meshes ; FROM: alien.c-types => float ; From 9357ee378e4ff3a88cbd71d6a385cc71ed33f7dc Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 8 Oct 2009 03:48:03 -0500 Subject: [PATCH 04/10] cpu.architecture: move dummy -reps words here, from cpu.ppc --- basis/cpu/architecture/architecture.factor | 40 ++++++++++++++++++++++ basis/cpu/ppc/ppc.factor | 39 --------------------- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/basis/cpu/architecture/architecture.factor b/basis/cpu/architecture/architecture.factor index c7a7f0c5ef..8bf84f6670 100644 --- a/basis/cpu/architecture/architecture.factor +++ b/basis/cpu/architecture/architecture.factor @@ -324,6 +324,46 @@ HOOK: %shr-vector-reps cpu ( -- reps ) HOOK: %horizontal-shl-vector-reps cpu ( -- reps ) HOOK: %horizontal-shr-vector-reps cpu ( -- reps ) +M: object %zero-vector-reps { } ; +M: object %fill-vector-reps { } ; +M: object %gather-vector-2-reps { } ; +M: object %gather-vector-4-reps { } ; +M: object %shuffle-vector-reps { } ; +M: object %merge-vector-reps { } ; +M: object %signed-pack-vector-reps { } ; +M: object %unsigned-pack-vector-reps { } ; +M: object %unpack-vector-head-reps { } ; +M: object %unpack-vector-tail-reps { } ; +M: object %integer>float-vector-reps { } ; +M: object %float>integer-vector-reps { } ; +M: object %compare-vector-reps drop { } ; +M: object %compare-vector-ccs 2drop { } f ; +M: object %test-vector-reps { } ; +M: object %add-vector-reps { } ; +M: object %saturated-add-vector-reps { } ; +M: object %add-sub-vector-reps { } ; +M: object %sub-vector-reps { } ; +M: object %saturated-sub-vector-reps { } ; +M: object %mul-vector-reps { } ; +M: object %saturated-mul-vector-reps { } ; +M: object %div-vector-reps { } ; +M: object %min-vector-reps { } ; +M: object %max-vector-reps { } ; +M: object %dot-vector-reps { } ; +M: object %sqrt-vector-reps { } ; +M: object %horizontal-add-vector-reps { } ; +M: object %horizontal-sub-vector-reps { } ; +M: object %abs-vector-reps { } ; +M: object %and-vector-reps { } ; +M: object %andn-vector-reps { } ; +M: object %or-vector-reps { } ; +M: object %xor-vector-reps { } ; +M: object %not-vector-reps { } ; +M: object %shl-vector-reps { } ; +M: object %shr-vector-reps { } ; +M: object %horizontal-shl-vector-reps { } ; +M: object %horizontal-shr-vector-reps { } ; + HOOK: %unbox-alien cpu ( dst src -- ) HOOK: %unbox-any-c-ptr cpu ( dst src temp -- ) HOOK: %box-alien cpu ( dst src temp -- ) diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor index 32c92a8da0..9237d320f3 100644 --- a/basis/cpu/ppc/ppc.factor +++ b/basis/cpu/ppc/ppc.factor @@ -256,45 +256,6 @@ M:: ppc %binary-float-function ( dst src1 src2 func -- ) M: ppc %single>double-float double-rep %copy ; M: ppc %double>single-float double-rep %copy ; -! VMX/AltiVec not supported yet -M: ppc %zero-vector-reps { } ; -M: ppc %fill-vector-reps { } ; -M: ppc %gather-vector-2-reps { } ; -M: ppc %gather-vector-4-reps { } ; -M: ppc %shuffle-vector-reps { } ; -M: ppc %merge-vector-reps { } ; -M: ppc %signed-pack-vector-reps { } ; -M: ppc %unsigned-pack-vector-reps { } ; -M: ppc %unpack-vector-reps { } ; -M: ppc %integer>float-vector-reps { } ; -M: ppc %float>integer-vector-reps { } ; -M: ppc %compare-vector-reps drop { } ; -M: ppc %test-vector-reps { } ; -M: ppc %add-vector-reps { } ; -M: ppc %saturated-add-vector-reps { } ; -M: ppc %add-sub-vector-reps { } ; -M: ppc %sub-vector-reps { } ; -M: ppc %saturated-sub-vector-reps { } ; -M: ppc %mul-vector-reps { } ; -M: ppc %saturated-mul-vector-reps { } ; -M: ppc %div-vector-reps { } ; -M: ppc %min-vector-reps { } ; -M: ppc %max-vector-reps { } ; -M: ppc %dot-vector-reps { } ; -M: ppc %sqrt-vector-reps { } ; -M: ppc %horizontal-add-vector-reps { } ; -M: ppc %horizontal-sub-vector-reps { } ; -M: ppc %abs-vector-reps { } ; -M: ppc %and-vector-reps { } ; -M: ppc %andn-vector-reps { } ; -M: ppc %or-vector-reps { } ; -M: ppc %xor-vector-reps { } ; -M: ppc %not-vector-reps { } ; -M: ppc %shl-vector-reps { } ; -M: ppc %shr-vector-reps { } ; -M: ppc %horizontal-shl-vector-reps { } ; -M: ppc %horizontal-shr-vector-reps { } ; - M: ppc %unbox-alien ( dst src -- ) alien-offset LWZ ; From 09e8484777c4df7fe0fe1550f0707e1e58abc177 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 8 Oct 2009 05:03:40 -0500 Subject: [PATCH 05/10] fix using --- basis/game/input/input-docs.factor | 2 +- extra/gpu/util/wasd/wasd.factor | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/game/input/input-docs.factor b/basis/game/input/input-docs.factor index bef08c4d2f..29b74ff570 100755 --- a/basis/game/input/input-docs.factor +++ b/basis/game/input/input-docs.factor @@ -3,7 +3,7 @@ sequences strings math ; IN: game.input ARTICLE: "game-input" "Game controller input" -"The " { $vocab-link "game-input" } " vocabulary provides cross-platform access to game controller devices such as joysticks and gamepads. It also provides an interface for polling raw keyboard and mouse input." $nl +"The " { $vocab-link "game.input" } " vocabulary provides cross-platform access to game controller devices such as joysticks and gamepads. It also provides an interface for polling raw keyboard and mouse input." $nl "The game input interface must be initialized before being used:" { $subsections open-game-input diff --git a/extra/gpu/util/wasd/wasd.factor b/extra/gpu/util/wasd/wasd.factor index 1f1187fd21..bee05463af 100644 --- a/extra/gpu/util/wasd/wasd.factor +++ b/extra/gpu/util/wasd/wasd.factor @@ -1,5 +1,5 @@ ! (c)2009 Joe Groff bsd license -USING: accessors arrays combinators.smart game-input +USING: accessors arrays combinators.smart game.input game.input.scancodes game.loop game.worlds gpu.render gpu.state kernel literals locals math math.constants math.functions math.matrices From 5a2a99128bbc7ba7f54a0da4b03426dbb83bd91e Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 8 Oct 2009 11:34:20 -0500 Subject: [PATCH 06/10] add an "nspin" generalization --- basis/generalizations/generalizations-docs.factor | 7 +++++++ basis/generalizations/generalizations-tests.factor | 2 ++ basis/generalizations/generalizations.factor | 3 +++ 3 files changed, 12 insertions(+) diff --git a/basis/generalizations/generalizations-docs.factor b/basis/generalizations/generalizations-docs.factor index e05d871323..e3a7c2d7e4 100644 --- a/basis/generalizations/generalizations-docs.factor +++ b/basis/generalizations/generalizations-docs.factor @@ -303,6 +303,12 @@ HELP: ntuck } { $description "A generalization of " { $link tuck } " that can work for any stack depth. The top item will be copied and placed " { $snippet "n" } " items down on the stack." } ; +HELP: nspin +{ $values + { "n" integer } +} +{ $description "A generalization of " { $link spin } " that can work for any stack depth. The top " { $snippet "n" } " items will be reversed in order." } ; + ARTICLE: "sequence-generalizations" "Generalized sequence operations" { $subsections narray @@ -321,6 +327,7 @@ ARTICLE: "shuffle-generalizations" "Generalized shuffle words" nnip ndrop ntuck + nspin mnswap nweave } ; diff --git a/basis/generalizations/generalizations-tests.factor b/basis/generalizations/generalizations-tests.factor index ec5c1ecc2d..f95ba63228 100644 --- a/basis/generalizations/generalizations-tests.factor +++ b/basis/generalizations/generalizations-tests.factor @@ -26,6 +26,8 @@ IN: generalizations.tests { 0 } [ 0 1 2 3 4 4 ndrop ] unit-test [ [ 1 ] 5 ndip ] must-infer [ 1 2 3 4 ] [ 2 3 4 [ 1 ] 3 ndip ] unit-test +[ 5 nspin ] must-infer +[ 1 5 4 3 2 ] [ 1 2 3 4 5 4 nspin ] unit-test [ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] must-infer { 2 1 2 3 4 5 } [ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] unit-test diff --git a/basis/generalizations/generalizations.factor b/basis/generalizations/generalizations.factor index 03d4512196..a39d549d3b 100644 --- a/basis/generalizations/generalizations.factor +++ b/basis/generalizations/generalizations.factor @@ -104,3 +104,6 @@ MACRO: nbi-curry ( n -- ) [ narray concat ] dip like ; inline : nappend ( n -- seq ) narray concat ; inline + +MACRO: nspin ( n -- ) + [ [ ] ] swap [ swap [ ] curry compose ] n*quot [ call ] 3append ; From 531cfa1c33d657fc28b45d2da7e72f59629f5ff5 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 8 Oct 2009 11:35:40 -0500 Subject: [PATCH 07/10] refactor math.vectors.conversion --- .../math/vectors/conversion/conversion.factor | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/basis/math/vectors/conversion/conversion.factor b/basis/math/vectors/conversion/conversion.factor index 863cb9fea5..f70dfc9b27 100644 --- a/basis/math/vectors/conversion/conversion.factor +++ b/basis/math/vectors/conversion/conversion.factor @@ -39,32 +39,45 @@ ERROR: bad-vconvert-input value expected-type ; } cond [ from-type check-vconvert-type ] prepose ; -:: [vpack] ( from-element to-element from-size to-size from-type to-type -- quot ) - from-size to-size /i log2 :> steps - +:: check-vpack ( from-element to-element from-type to-type steps -- ) { [ steps 1 = not ] [ from-element to-element [ float-type? ] bi@ xor ] [ from-element unsigned-type? to-element unsigned-type? not and ] - } 0|| [ from-type to-type bad-vconvert ] when + } 0|| [ from-type to-type bad-vconvert ] when ; - to-element unsigned-type? [ to-type (vpack-unsigned) ] [ to-type (vpack-signed) ] ? - [ [ from-type check-vconvert-type ] bi@ ] prepose ; +:: [[vpack-unsigned]] ( from-type to-type -- quot ) + [ [ from-type check-vconvert-type ] bi@ to-type (vpack-unsigned) ] ; -:: [vunpack] ( from-element to-element from-size to-size from-type to-type -- quot ) - to-size from-size /i log2 :> steps +:: [[vpack-signed]] ( from-type to-type -- quot ) + [ [ from-type check-vconvert-type ] bi@ to-type (vpack-signed) ] ; +:: [vpack] ( from-element to-element from-size to-size from-type to-type -- quot ) + from-size to-size /i log2 :> steps + + from-element to-element from-type to-type steps check-vpack + + from-type to-type to-element unsigned-type? + [ [[vpack-unsigned]] ] [ [[vpack-signed]] ] if ; + +:: check-vunpack ( from-element to-element from-type to-type steps -- ) { [ steps 1 = not ] [ from-element to-element [ float-type? ] bi@ xor ] [ from-element unsigned-type? not to-element unsigned-type? and ] - } 0|| [ from-type to-type bad-vconvert ] when + } 0|| [ from-type to-type bad-vconvert ] when ; +:: [[vunpack]] ( from-type to-type -- quot ) [ from-type check-vconvert-type [ to-type (vunpack-head) ] [ to-type (vunpack-tail) ] bi ] ; +:: [vunpack] ( from-element to-element from-size to-size from-type to-type -- quot ) + to-size from-size /i log2 :> steps + from-element to-element from-type to-type steps check-vunpack + from-type to-type [[vunpack]] ; + PRIVATE> MACRO:: vconvert ( from-type to-type -- ) From 27c5ab9cc37e16cde8cc7b77259fa66631bf6e30 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 8 Oct 2009 12:24:07 -0500 Subject: [PATCH 08/10] shatter the four-argument barrier in memoize --- basis/memoize/memoize-docs.factor | 10 ++++----- basis/memoize/memoize-tests.factor | 11 +++++++++- basis/memoize/memoize.factor | 34 +++++++++++++++++++----------- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/basis/memoize/memoize-docs.factor b/basis/memoize/memoize-docs.factor index 674fa005c2..58ba60af7c 100644 --- a/basis/memoize/memoize-docs.factor +++ b/basis/memoize/memoize-docs.factor @@ -19,12 +19,10 @@ ABOUT: "memoize" HELP: define-memoized { $values { "word" word } { "quot" quotation } { "effect" effect } } -{ $description "defines the given word at runtime as one which memoizes its output given a particular input" } -{ $notes "A maximum of four input and four output arguments can be used" } -{ $see-also POSTPONE: MEMO: } ; +{ $description "Defines the given word at run time as one which memoizes its outputs given a particular input." } ; HELP: MEMO: { $syntax "MEMO: word ( stack -- effect ) definition ;" } -{ $description "defines the given word at parsetime as one which memoizes its output given a particular input. The stack effect is mandatory." } -{ $notes "A maximum of four input and four output arguments can be used" } -{ $see-also define-memoized } ; +{ $description "Defines the given word at parse time as one which memoizes its output given a particular input. The stack effect is mandatory." } ; + +{ define-memoized POSTPONE: MEMO: } related-words diff --git a/basis/memoize/memoize-tests.factor b/basis/memoize/memoize-tests.factor index 771c11c130..11dfd705c2 100644 --- a/basis/memoize/memoize-tests.factor +++ b/basis/memoize/memoize-tests.factor @@ -7,9 +7,18 @@ IN: memoize.tests MEMO: fib ( m -- n ) dup 1 <= [ drop 1 ] [ dup 1 - fib swap 2 - fib + ] if ; +MEMO: x ( a b c d e -- f g h i j ) + [ 1 + ] 4 ndip ; + [ 89 ] [ 10 fib ] unit-test -[ "USING: kernel math memoize generalizations ; IN: memoize.tests MEMO: x ( a b c d e -- f g h i j ) [ 1 + ] 4 ndip ;" eval( -- ) ] must-fail +[ + 1 0 0 0 0 + 1 0 0 0 0 +] [ + 0 0 0 0 0 x + 0 0 0 0 0 x +] unit-test MEMO: see-test ( a -- b ) reverse ; diff --git a/basis/memoize/memoize.factor b/basis/memoize/memoize.factor index 74ca07cda3..21291318b1 100644 --- a/basis/memoize/memoize.factor +++ b/basis/memoize/memoize.factor @@ -5,18 +5,32 @@ parser math assocs effects definitions quotations summary accessors fry ; IN: memoize -ERROR: too-many-arguments ; - -M: too-many-arguments summary - drop "There must be no more than 4 input and 4 output arguments" ; - concat >quotation ; + +: [narray] ( length -- quot ) + [ [ 1 - ] keep '[ _ _ f ] ] + [ [ [ set-nth ] 2keep [ 1 - ] dip ] (n*quot) ] bi + [ nip ] 3append ; + +: [firstn] ( length -- quot ) + [ 0 swap ] swap + [ [ nth ] 2keep [ 1 + ] dip ] (n*quot) + [ 2drop ] 3append ; + : packer ( seq -- quot ) - length { [ f ] [ ] [ 2array ] [ 3array ] [ 4array ] } nth ; + length dup 4 <= + [ { [ f ] [ ] [ 2array ] [ 3array ] [ 4array ] } nth ] + [ [narray] ] if ; : unpacker ( seq -- quot ) - length { [ drop ] [ ] [ first2 ] [ first3 ] [ first4 ] } nth ; + length dup 4 <= + [ { [ drop ] [ ] [ first2 ] [ first3 ] [ first4 ] } nth ] + [ [firstn] ] if ; : pack/unpack ( quot effect -- newquot ) [ in>> packer ] [ out>> unpacker ] bi surround ; @@ -24,11 +38,7 @@ M: too-many-arguments summary : unpack/pack ( quot effect -- newquot ) [ in>> unpacker ] [ out>> packer ] bi surround ; -: check-memoized ( effect -- ) - [ in>> ] [ out>> ] bi [ length 4 > ] either? [ too-many-arguments ] when ; - : make-memoizer ( table quot effect -- quot ) - [ check-memoized ] keep [ unpack/pack '[ _ _ cache ] ] keep pack/unpack ; @@ -62,4 +72,4 @@ M: memoized reset-word : invalidate-memoized ( inputs... word -- ) [ stack-effect in>> packer call ] [ "memoize" word-prop delete-at ] bi ; -\ invalidate-memoized t "no-compile" set-word-prop \ No newline at end of file +\ invalidate-memoized t "no-compile" set-word-prop From 9a09c3ced862980f276c6008b77e091f2229202b Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 8 Oct 2009 12:30:43 -0500 Subject: [PATCH 09/10] fix using --- basis/tools/deploy/test/8/8.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/tools/deploy/test/8/8.factor b/basis/tools/deploy/test/8/8.factor index ddf08d3654..6bbb85f9fc 100644 --- a/basis/tools/deploy/test/8/8.factor +++ b/basis/tools/deploy/test/8/8.factor @@ -1,4 +1,4 @@ -USING: calendar game-input threads ui ui.gadgets.worlds kernel +USING: calendar game.input threads ui ui.gadgets.worlds kernel method-chains system ; IN: tools.deploy.test.8 @@ -18,4 +18,4 @@ AFTER: my-world end-world drop close-game-input ; 0 exit ] with-ui ; -MAIN: test-game-input \ No newline at end of file +MAIN: test-game-input From b150deeb11cc006cc966d301f6a05a704b6fe46a Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 8 Oct 2009 12:55:52 -0500 Subject: [PATCH 10/10] refactor so that generalizations reuses the stub versions of nsequence, firstn, and n*quot needed by memoize --- basis/alien/parser/parser.factor | 2 +- basis/generalizations/generalizations.factor | 11 ++++------- basis/memoize/memoize.factor | 16 ++++++++-------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index 59607fa781..67f1d4e5fd 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -10,7 +10,7 @@ IN: alien.parser : parse-c-type-name ( name -- word ) dup search [ nip ] [ no-word ] if* ; -: parse-c-type ( string -- array ) +: parse-c-type ( string -- type ) { { [ dup "void" = ] [ drop void ] } { [ CHAR: ] over member? ] [ parse-array-type parse-c-type-name prefix ] } diff --git a/basis/generalizations/generalizations.factor b/basis/generalizations/generalizations.factor index a39d549d3b..5ca00018a2 100644 --- a/basis/generalizations/generalizations.factor +++ b/basis/generalizations/generalizations.factor @@ -2,22 +2,19 @@ ! Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences sequences.private math combinators -macros quotations fry effects ; +macros quotations fry effects memoize.private ; IN: generalizations << -: n*quot ( n quot -- quot' ) concat >quotation ; +ALIAS: n*quot (n*quot) : repeat ( n obj quot -- ) swapd times ; inline >> MACRO: nsequence ( n seq -- ) - [ - [ drop iota ] [ '[ _ _ new-sequence ] ] 2bi - [ '[ @ [ _ swap set-nth-unsafe ] keep ] ] reduce - ] keep + [ [nsequence] ] keep '[ @ _ like ] ; MACRO: narray ( n -- ) @@ -27,7 +24,7 @@ MACRO: nsum ( n -- ) 1 - [ + ] n*quot ; MACRO: firstn-unsafe ( n -- ) - iota [ '[ [ _ ] dip nth-unsafe ] ] map '[ _ cleave ] ; + [firstn] ; MACRO: firstn ( n -- ) dup zero? [ drop [ drop ] ] [ diff --git a/basis/memoize/memoize.factor b/basis/memoize/memoize.factor index 21291318b1..c949c34684 100644 --- a/basis/memoize/memoize.factor +++ b/basis/memoize/memoize.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel hashtables sequences arrays words namespaces make -parser math assocs effects definitions quotations summary -accessors fry ; +USING: kernel hashtables sequences sequences.private arrays +words namespaces make parser math assocs effects definitions +quotations summary accessors fry ; IN: memoize concat >quotation ; -: [narray] ( length -- quot ) - [ [ 1 - ] keep '[ _ _ f ] ] - [ [ [ set-nth ] 2keep [ 1 - ] dip ] (n*quot) ] bi +: [nsequence] ( length exemplar -- quot ) + [ [ [ 1 - ] keep ] dip '[ _ _ _ new-sequence ] ] + [ drop [ [ set-nth-unsafe ] 2keep [ 1 - ] dip ] (n*quot) ] 2bi [ nip ] 3append ; : [firstn] ( length -- quot ) [ 0 swap ] swap - [ [ nth ] 2keep [ 1 + ] dip ] (n*quot) + [ [ nth-unsafe ] 2keep [ 1 + ] dip ] (n*quot) [ 2drop ] 3append ; : packer ( seq -- quot ) length dup 4 <= [ { [ f ] [ ] [ 2array ] [ 3array ] [ 4array ] } nth ] - [ [narray] ] if ; + [ { } [nsequence] ] if ; : unpacker ( seq -- quot ) length dup 4 <=