From 679b03f8dbc61729363228a76d190bb1a20e0dea Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Thu, 23 Jun 2011 01:17:24 -0400 Subject: [PATCH 01/10] Remove unnecessary -std=gnu99 Flag isn't needed anymore with g++ and it causes warnings with clang. --- vm/Config.macosx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/Config.macosx b/vm/Config.macosx index 5b9de7f5cf..693ee9341d 100644 --- a/vm/Config.macosx +++ b/vm/Config.macosx @@ -14,7 +14,7 @@ else LIBS = -lm -framework Cocoa -framework AppKit endif -LINKER = $(CPP) $(CFLAGS) -dynamiclib -single_module -std=gnu99 \ +LINKER = $(CPP) $(CFLAGS) -dynamiclib -single_module \ -current_version $(VERSION) \ -compatibility_version $(VERSION) \ -fvisibility=hidden \ From 3acee3e55ecb9c034e8cacfab68c04ac08c08a9a Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Thu, 23 Jun 2011 01:18:35 -0400 Subject: [PATCH 02/10] Run vim synchronously If you run vim from the terminal asynchronously, vim and factor will conflict accessing stdin and stdout. --- basis/editors/vim/vim.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/editors/vim/vim.factor b/basis/editors/vim/vim.factor index a62ed9e0a5..55c3889e00 100644 --- a/basis/editors/vim/vim.factor +++ b/basis/editors/vim/vim.factor @@ -16,7 +16,7 @@ M: vim vim-command ] { } make ; : vim ( file line -- ) - vim-command run-detached drop ; + vim-command run-process drop ; "vim" vim-path set-global [ vim ] edit-hook set-global From 8eea81b0d407aaf1ffba55c18de22f93237c0648 Mon Sep 17 00:00:00 2001 From: yac Date: Thu, 23 Jun 2011 21:01:35 +0200 Subject: [PATCH 03/10] Improved stack effect highlighting in vim. Delimiters and items in stack effect are highlighted separately, works on call( -- ) and execute( -- ) too. --- misc/vim/syntax/factor.vim | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/misc/vim/syntax/factor.vim b/misc/vim/syntax/factor.vim index 5cea099f45..ede8eb2707 100644 --- a/misc/vim/syntax/factor.vim +++ b/misc/vim/syntax/factor.vim @@ -48,8 +48,8 @@ syn keyword factorBoolean f t syn keyword factorBreakpoint B syn keyword factorFrySpecifier @ _ contained syn keyword factorDeclaration delimiter deprecated final flushable foldable inline recursive -syn match factorCallQuotation /\/ -syn match factorExecute /\/ +syn match factorCallQuotation /\/ contained contains=factorStackEffect +syn match factorExecute /\/ contained contains=factorStackEffect syn keyword factorCallNextMethod call-next-method syn keyword factorKeyword or 2bi 2tri while wrapper nip 4dip wrapper? bi* callstack>array both? hashcode die dupd callstack callstack? 3dup tri@ pick curry build ?execute 3bi prepose >boolean ?if clone eq? tri* ? = swapd 2over 2keep 3keep clear 2dup when not tuple? dup 2bi* 2tri* call tri-curry object bi@ do unless* if* loop bi-curry* drop when* assert= retainstack assert? -rot execute 2bi@ 2tri@ boa with either? 3drop bi curry? datastack until 3dip over 3curry tri-curry* tri-curry@ swap and 2nip throw bi-curry (clone) hashcode* compose 2dip if 3tri unless compose? tuple keep 2curry equal? assert tri 2drop most boolean? identity-hashcode identity-tuple? null new dip bi-curry@ rot xor identity-tuple boolean @@ -148,8 +148,11 @@ syn match factorMultiStringContents /.*/ contained "syn match factorStackEffectErr /\<)\>/ "syn region factorStackEffectErr start=/\<(\>/ end=/\<)\>/ "syn region factorStackEffect start=/\<(\>/ end=/\<)\>/ contained -syn match factorStackEffect /\<(\s\(\S*\s\)\?--\(\s\S*\)\?\s)\>/ contained -syn match factorLiteralStackEffect /\<((\s\(\S*\s\)\?--\(\s\S*\)\?\s))\>/ +syn match factorStackEffect /(\s\+\(\S*\s\+\)*--\(\s\+\S*\)*\s\+)\>/ contained contains=factorStackDelims,factorStackItems,factorCallExecuteDelim +syn match factorLiteralStackEffect /((\s\+\(\S*\s\+\)*--\(\s\+\S*\)*\s\+))\>/ contained contains=factorStackDelims,factorStackItems +syn match factorStackItems contained "\<\S\+\>" +syn keyword factorStackDelims contained ( ) (( )) -- +syn match factorCallExecuteDelim contained /(\s/ "adapted from lisp.vim if exists("g:factor_norainbow") @@ -199,6 +202,9 @@ if version >= 508 || !exists("did_factor_syn_inits") HiLink factorShebang PreProc HiLink factorShebangErr Error HiLink factorStackEffect Typedef + HiLink factorStackDelims Delimiter + HiLink factorCallExecuteDelim Delimiter + HiLink factorStackItems Identifier HiLink factorLiteralStackEffect Typedef HiLink factorTodo Todo HiLink factorInclude Include From 62332cfa17b0b7e0fdc98d21089835bfc0d9acd6 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 20 Jul 2011 13:52:42 -0700 Subject: [PATCH 04/10] strings: a few more peace-of-mind tests setting out-of-range code points in strings --- core/strings/strings-tests.factor | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/strings/strings-tests.factor b/core/strings/strings-tests.factor index bebdb32820..869543fc0a 100644 --- a/core/strings/strings-tests.factor +++ b/core/strings/strings-tests.factor @@ -67,6 +67,10 @@ unit-test [ ] [ HEX: 4321 3 "s" get set-nth ] unit-test [ ] [ HEX: 654321 5 "s" get set-nth ] unit-test +[ ] [ HEX: -1 5 "s" get set-nth ] unit-test +[ ] [ HEX: 80,0000 5 "s" get set-nth ] unit-test +[ ] [ HEX: 100,0000 5 "s" get set-nth ] unit-test + [ { CHAR: h @@ -121,5 +125,3 @@ unit-test [ clone resize-string first ] keep = ] all-integers? ] unit-test - -[ HEX: 7fffff ] [ { -1 } >string first ] unit-test From 6fef726d5833c1232361334f00c1edd15e694933 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Fri, 29 Jul 2011 01:56:13 -0400 Subject: [PATCH 05/10] Replace deprecated words with alternatives. A load-all on OS X now completes without any deprecated word warnings. --- extra/24-game/24-game.factor | 1 + extra/trees/avl/avl.factor | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/extra/24-game/24-game.factor b/extra/24-game/24-game.factor index 28600b6c48..60f180877f 100644 --- a/extra/24-game/24-game.factor +++ b/extra/24-game/24-game.factor @@ -8,6 +8,7 @@ arrays words quotations accessors math.parser backtrack assocs ; IN: 24-game SYMBOL: commands : nop ( -- ) ; +: spin ( a b c -- c b a ) swapd swap swap ; : do-something ( a b -- c ) { + - * } amb-execute ; : maybe-swap ( a b -- a b ) { nop swap } amb-execute ; : some-rots ( a b c -- a b c ) diff --git a/extra/trees/avl/avl.factor b/extra/trees/avl/avl.factor index 68efbdd2b4..69252bf762 100644 --- a/extra/trees/avl/avl.factor +++ b/extra/trees/avl/avl.factor @@ -136,7 +136,7 @@ GENERIC: avl-delete ( key node -- node shorter? deleted? ) M: f avl-delete ( key f -- f f f ) nip f f ; : (avl-delete) ( key node -- node shorter? deleted? ) - tuck node-link avl-delete [ + swap over node-link avl-delete [ [ over set-node-link ] dip [ balance-delete ] [ f ] if ] dip ; From 981477a7ff33cf544417d47adc2f42a85b578ff2 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Fri, 29 Jul 2011 01:57:14 -0400 Subject: [PATCH 06/10] Fix mason following PPC changes; target-os and target-cpu are no longer strings. --- extra/mason/child/child-tests.factor | 17 +++++++++-------- extra/mason/child/child.factor | 8 ++++---- extra/mason/email/email-tests.factor | 7 ++++--- extra/mason/platform/platform.factor | 3 ++- extra/mason/release/branch/branch-tests.factor | 11 ++++++----- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/extra/mason/child/child-tests.factor b/extra/mason/child/child-tests.factor index 140288585f..34f9c10103 100644 --- a/extra/mason/child/child-tests.factor +++ b/extra/mason/child/child-tests.factor @@ -1,26 +1,27 @@ IN: mason.child.tests -USING: mason.child mason.config tools.test namespaces io kernel sequences ; +USING: mason.child mason.config tools.test namespaces io kernel +sequences system ; [ { "nmake" "/f" "nmakefile" "x86-32" } ] [ [ - "winnt" target-os set - "x86.32" target-cpu set + winnt target-os set + x86.32 target-cpu set make-cmd ] with-scope ] unit-test [ { "make" "macosx-x86-32" } ] [ [ - "macosx" target-os set - "x86.32" target-cpu set + macosx target-os set + x86.32 target-cpu set make-cmd ] with-scope ] unit-test [ { "./factor.com" "-i=boot.winnt-x86.32.image" "-no-user-init" } ] [ [ - "winnt" target-os set - "x86.32" target-cpu set + winnt target-os set + x86.32 target-cpu set boot-cmd ] with-scope ] unit-test @@ -43,4 +44,4 @@ USING: mason.child mason.config tools.test namespaces io kernel sequences ; { [ ] [ ] } [ "B" ] } recover-cond -] unit-test \ No newline at end of file +] unit-test diff --git a/extra/mason/child/child.factor b/extra/mason/child/child.factor index 66e6eb3722..3a7e88ac9b 100644 --- a/extra/mason/child/child.factor +++ b/extra/mason/child/child.factor @@ -9,14 +9,14 @@ IN: mason.child : nmake-cmd ( -- args ) { "nmake" "/f" "nmakefile" } - target-cpu get "." split "-" join suffix ; + target-cpu get name>> "." split "-" join suffix ; : gnu-make-cmd ( -- args ) gnu-make platform 2array ; : make-cmd ( -- args ) { - { [ target-os get "winnt" = ] [ nmake-cmd ] } + { [ target-os get winnt = ] [ nmake-cmd ] } [ gnu-make-cmd ] } cond ; @@ -30,7 +30,7 @@ IN: mason.child ] with-directory ; : factor-vm ( -- string ) - target-os get "winnt" = "./factor.com" "./factor" ? ; + target-os get winnt = "./factor.com" "./factor" ? ; : boot-cmd ( -- cmd ) [ @@ -79,4 +79,4 @@ MACRO: recover-cond ( alist -- ) { [ notify-boot boot ] [ boot-failed ] } { [ notify-test test ] [ test-failed ] } [ success ] - } recover-cond ; \ No newline at end of file + } recover-cond ; diff --git a/extra/mason/email/email-tests.factor b/extra/mason/email/email-tests.factor index 77f651feb9..5e4f93de52 100644 --- a/extra/mason/email/email-tests.factor +++ b/extra/mason/email/email-tests.factor @@ -1,10 +1,11 @@ IN: mason.email.tests -USING: mason.email mason.common mason.config namespaces tools.test ; +USING: mason.email mason.common mason.config namespaces +tools.test system ; [ "mason on linux-x86-64: 12345 -- error" ] [ [ - "linux" target-os set - "x86.64" target-cpu set + linux target-os set + x86.64 target-cpu set "12345" current-git-id set status-error report-subject ] with-scope diff --git a/extra/mason/platform/platform.factor b/extra/mason/platform/platform.factor index 2a33c5240b..92d4ace972 100644 --- a/extra/mason/platform/platform.factor +++ b/extra/mason/platform/platform.factor @@ -5,13 +5,14 @@ mason.config bootstrap.image assocs ; IN: mason.platform : (platform) ( os cpu -- string ) + [ name>> ] bi@ { { CHAR: . CHAR: - } } substitute "-" glue ; : platform ( -- string ) target-os get target-cpu get (platform) ; : gnu-make ( -- string ) - target-os get { "freebsd" "openbsd" "netbsd" } member? "gmake" "make" ? ; + target-os get { freebsd openbsd netbsd } member? "gmake" "make" ? ; : boot-image-arch ( -- string ) target-os get target-cpu get arch ; diff --git a/extra/mason/release/branch/branch-tests.factor b/extra/mason/release/branch/branch-tests.factor index 8327ae985d..47ebe3b404 100644 --- a/extra/mason/release/branch/branch-tests.factor +++ b/extra/mason/release/branch/branch-tests.factor @@ -1,13 +1,14 @@ IN: mason.release.branch.tests -USING: mason.release.branch mason.config tools.test namespaces ; +USING: mason.release.branch mason.config tools.test namespaces +system ; [ { "git" "push" "-f" "joe@blah.com:/my/git" "master:clean-linux-x86-32" } ] [ [ "joe" branch-username set "blah.com" branch-host set "/my/git" branch-directory set - "linux" target-os set - "x86.32" target-cpu set + linux target-os set + x86.32 target-cpu set push-to-clean-branch-cmd ] with-scope ] unit-test @@ -18,8 +19,8 @@ USING: mason.release.branch mason.config tools.test namespaces ; "joe" image-username set "blah.com" image-host set "/stuff/clean" image-directory set - "netbsd" target-os set - "x86.64" target-cpu set + netbsd target-os set + x86.64 target-cpu set upload-clean-image-cmd ] with-scope ] unit-test From f6d90ce51f3b862233863ba2ee3b0d05b635f3cb Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 29 Jul 2011 13:24:10 -0700 Subject: [PATCH 07/10] game.input.iokit: deal with Lion's breakage of the IOHID* API --- basis/core-foundation/strings/strings.factor | 10 ++++++++- basis/game/input/iokit/iokit.factor | 22 +++++++++++++++++--- basis/iokit/hid/hid.factor | 5 +++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/basis/core-foundation/strings/strings.factor b/basis/core-foundation/strings/strings.factor index 24bb38e09c..11d28024f8 100644 --- a/basis/core-foundation/strings/strings.factor +++ b/basis/core-foundation/strings/strings.factor @@ -3,7 +3,7 @@ USING: alien.c-types alien.data alien.syntax alien.strings io.encodings.string kernel sequences byte-arrays io.encodings.utf8 math core-foundation core-foundation.arrays -destructors parser fry alien words ; +core-foundation.data destructors parser fry alien words ; IN: core-foundation.strings TYPEDEF: void* CFStringRef @@ -60,6 +60,9 @@ FUNCTION: CFStringRef CFStringCreateWithCString ( CFStringEncoding encoding ) ; +FUNCTION: CFStringRef CFCopyDescription ( CFTypeRef cf ) ; +FUNCTION: CFStringRef CFCopyTypeIDDescription ( CFTypeID type_id ) ; + : prepare-CFString ( string -- byte-array ) [ dup HEX: 10ffff > @@ -88,6 +91,11 @@ FUNCTION: CFStringRef CFStringCreateWithCString ( : ( seq -- alien ) [ [ &CFRelease ] map ] with-destructors ; +: CF>description ( cf -- description ) + [ CFCopyDescription &CFRelease CF>string ] with-destructors ; +: CFType>description ( cf -- description ) + CFGetTypeID [ CFCopyTypeIDDescription &CFRelease CF>string ] with-destructors ; + SYNTAX: CFSTRING: CREATE scan-object [ drop ] [ '[ _ [ _ ] initialize-alien ] ] 2bi diff --git a/basis/game/input/iokit/iokit.factor b/basis/game/input/iokit/iokit.factor index 083be8e74f..3a953e8bab 100644 --- a/basis/game/input/iokit/iokit.factor +++ b/basis/game/input/iokit/iokit.factor @@ -1,5 +1,6 @@ USING: cocoa cocoa.plists core-foundation iokit iokit.hid kernel cocoa.enumeration destructors math.parser cocoa.application +core-foundation.data core-foundation.strings sequences locals combinators.short-circuit threads namespaces assocs arrays combinators hints alien core-foundation.run-loop accessors sequences.private @@ -270,11 +271,26 @@ M: iokit-game-input-backend reset-mouse : device-removed-callback ( -- alien ) [ (device-removed-callback) ] IOHIDDeviceCallback ; +! Lion sends the input callback an IOHIDQueue as the "sender". +! Leopard and Snow Leopard send an IOHIDDevice. +! This function gets the IOHIDDevice regardless of which is received +: get-input-device ( sender -- device ) + dup CFGetTypeID { + { [ dup IOHIDDeviceGetTypeID = ] [ drop ] } + { [ dup IOHIDQueueGetTypeID = ] [ drop IOHIDQueueGetDevice ] } + [ + drop + "input callback doesn't know how to deal with " + swap CF>description append throw + ] + } cond ; + :: (device-input-callback) ( context result sender value -- ) + sender get-input-device :> device { - { [ sender mouse-device? ] [ +mouse-state+ get-global value record-mouse ] } - { [ sender controller-device? ] [ - sender +controller-states+ get-global at value record-controller + { [ device mouse-device? ] [ +mouse-state+ get-global value record-mouse ] } + { [ device controller-device? ] [ + device +controller-states+ get-global at value record-controller ] } [ +keyboard-state+ get-global value record-keyboard ] } cond ; diff --git a/basis/iokit/hid/hid.factor b/basis/iokit/hid/hid.factor index a2ac0d5e6f..e72a3517ba 100644 --- a/basis/iokit/hid/hid.factor +++ b/basis/iokit/hid/hid.factor @@ -125,6 +125,7 @@ TYPEDEF: uint IOHIDQueueOptionsType TYPEDEF: uint IOHIDElementFlags TYPEDEF: void* IOHIDDeviceRef TYPEDEF: void* IOHIDElementRef +TYPEDEF: void* IOHIDQueueRef TYPEDEF: void* IOHIDValueRef TYPEDEF: void* IOHIDManagerRef TYPEDEF: void* IOHIDTransactionRef @@ -253,3 +254,7 @@ FUNCTION: IOReturn IOHIDTransactionCommit ( IOHIDTransactionRef transaction ) ; FUNCTION: IOReturn IOHIDTransactionCommitWithCallback ( IOHIDTransactionRef transaction, CFTimeInterval timeout, IOHIDCallback callback, void* context ) ; FUNCTION: void IOHIDTransactionClear ( IOHIDTransactionRef transaction ) ; +! IOHIDQueue + +FUNCTION: CFTypeID IOHIDQueueGetTypeID ( ) ; +FUNCTION: IOHIDDeviceRef IOHIDQueueGetDevice ( IOHIDQueueRef queue ) ; From 44ba9e086eccf857d697e6e2b554c7ec7b00acdd Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 29 Jul 2011 14:15:59 -0700 Subject: [PATCH 08/10] opengl.gl.extensions: annoying hack to make gpu.* demos work in Lion. opengl 3 entry points such as glGenVertexArrays are available, but they only actually work in core profile contexts which factor doesn't support yet, so favor extension entry points such as glGenVertexArraysAPPLE instead of standard entry points --- basis/opengl/gl/extensions/extensions.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/opengl/gl/extensions/extensions.factor b/basis/opengl/gl/extensions/extensions.factor index 327b552fa2..2232f32891 100644 --- a/basis/opengl/gl/extensions/extensions.factor +++ b/basis/opengl/gl/extensions/extensions.factor @@ -50,6 +50,6 @@ reset-gl-function-number-counter SYNTAX: GL-FUNCTION: gl-function-calling-convention scan-function-name - "{" expect "}" parse-tokens over prefix + "{" expect "}" parse-tokens over suffix gl-function-counter '[ _ _ gl-function-pointer ] ";" scan-c-args define-indirect ; From 31afdfef50f5bfcec8c7a564f025bd65a1ce57f8 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 29 Jul 2011 21:05:21 -0700 Subject: [PATCH 09/10] build-support/factor.sh: fix quick-update (reported by tsculpt) --- build-support/factor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-support/factor.sh b/build-support/factor.sh index d01fdb8c30..3ddab4ba3d 100755 --- a/build-support/factor.sh +++ b/build-support/factor.sh @@ -539,7 +539,7 @@ update_bootstrap() { } refresh_image() { - ./$FACTOR_BINARY -script -e="USING: vocabs.loader system memory ; refresh-all USE: memory save 0 exit" + ./$FACTOR_BINARY -script -e="USING: vocabs.loader vocabs.refresh system memory ; refresh-all save 0 exit" check_ret factor } From efe79cf6d331bc0ddc3fa588d6e262e1907285a0 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 1 Aug 2011 10:26:53 -0700 Subject: [PATCH 10/10] math.functions: make sure zero zero ^ is always nan, regardless of the type of zero --- basis/math/functions/functions-tests.factor | 1 + basis/math/functions/functions.factor | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/basis/math/functions/functions-tests.factor b/basis/math/functions/functions-tests.factor index 73f08e2665..507258f0d1 100644 --- a/basis/math/functions/functions-tests.factor +++ b/basis/math/functions/functions-tests.factor @@ -32,6 +32,7 @@ IN: math.functions.tests [ 0.0 ] [ 0.0 1.0 ^ ] unit-test [ 1/0. ] [ 0 -2 ^ ] unit-test [ t ] [ 0 0.0 ^ fp-nan? ] unit-test +[ t ] [ 0.0 0.0 ^ fp-nan? ] unit-test [ 1/0. ] [ 0 -2.0 ^ ] unit-test [ 0 ] [ 0 3.0 ^ ] unit-test [ 0 ] [ 0 3 ^ ] unit-test diff --git a/basis/math/functions/functions.factor b/basis/math/functions/functions.factor index 0a9b73fe0c..1b120831c0 100644 --- a/basis/math/functions/functions.factor +++ b/basis/math/functions/functions.factor @@ -82,8 +82,8 @@ M: complex exp >rect [ exp ] dip polar> ; inline : real^? ( x y -- ? ) 2dup [ real? ] both? [ drop 0 >= ] [ 2drop f ] if ; inline -: 0^ ( x -- z ) - [ 0/0. ] [ 0 < 1/0. 0 ? ] if-zero ; inline +: 0^ ( zero x -- z ) + swap [ 0/0. ] swap '[ 0 < 1/0. _ ? ] if-zero ; inline : (^mod) ( x y n -- z ) [ make-bits 1 ] dip dup @@ -100,7 +100,7 @@ PRIVATE> : ^ ( x y -- z ) { - { [ over 0 = ] [ nip 0^ ] } + { [ over zero? ] [ 0^ ] } { [ dup integer? ] [ integer^ ] } { [ 2dup real^? ] [ [ >float ] bi@ fpow ] } [ ^complex ]