diff --git a/basis/alarms/alarms-tests.factor b/basis/alarms/alarms-tests.factor index 786a7b1774..ffba05bccc 100644 --- a/basis/alarms/alarms-tests.factor +++ b/basis/alarms/alarms-tests.factor @@ -30,3 +30,17 @@ IN: alarms.tests 1/2 seconds sleep stop-alarm ] unit-test + +[ { 1 } ] [ + { 0 } + dup '[ 0 _ [ 1 + ] change-nth ] 3 seconds later + [ stop-alarm ] [ start-alarm ] bi + 4 seconds sleep +] unit-test + +[ { 0 } ] [ + { 0 } + dup '[ 3 seconds sleep 1 _ set-first ] 1 seconds later + 2 seconds sleep stop-alarm + 1/2 seconds sleep +] unit-test diff --git a/basis/alarms/alarms.factor b/basis/alarms/alarms.factor index 4d5295793d..a82f367a13 100644 --- a/basis/alarms/alarms.factor +++ b/basis/alarms/alarms.factor @@ -9,9 +9,10 @@ TUPLE: alarm { quot callable initial: [ ] } start-nanos delay-nanos - interval-nanos integer - { next-iteration-nanos integer } - { stop? boolean } ; + interval-nanos + iteration-start-nanos + quotation-running? + thread ; nanoseconds >integer ; M: duration >nanoseconds duration>nanoseconds >integer ; : set-next-alarm-time ( alarm -- alarm ) - ! start + delay + ceiling((now - start) / interval) * interval + ! start + delay + ceiling((now - (start + delay)) / interval) * interval nano-count over start-nanos>> - - over delay-nanos>> [ + ] when* + over delay-nanos>> [ - ] when* over interval-nanos>> / ceiling over interval-nanos>> * - over start-nanos>> + >>next-iteration-nanos ; inline + over start-nanos>> + + over delay-nanos>> [ + ] when* + >>iteration-start-nanos ; + +: stop-alarm? ( alarm -- ? ) + thread>> self eq? not ; DEFER: call-alarm-loop : loop-alarm ( alarm -- ) nano-count over - [ next-iteration-nanos>> - ] [ interval-nanos>> ] bi < + [ iteration-start-nanos>> - ] [ interval-nanos>> ] bi < [ set-next-alarm-time ] dip - [ dup next-iteration-nanos>> ] [ 0 ] if - sleep-until call-alarm-loop ; + [ dup iteration-start-nanos>> ] [ 0 ] if + 0 or sleep-until call-alarm-loop ; : maybe-loop-alarm ( alarm -- ) - dup { [ stop?>> ] [ interval-nanos>> not ] } 1|| + dup { [ stop-alarm? ] [ interval-nanos>> not ] } 1|| [ drop ] [ loop-alarm ] if ; : call-alarm-loop ( alarm -- ) - dup stop?>> [ + dup stop-alarm? [ drop ] [ - [ quot>> call( -- ) ] keep + [ + [ t >>quotation-running? drop ] + [ quot>> call( -- ) ] + [ f >>quotation-running? drop ] tri + ] keep maybe-loop-alarm ] if ; -: call-alarm ( alarm -- ) - [ delay-nanos>> ] [ ] bi - '[ _ [ sleep ] when* _ call-alarm-loop ] "Alarm execution" spawn drop ; - PRIVATE> : ( quot delay-duration/f interval-duration/f -- alarm ) @@ -63,14 +69,20 @@ PRIVATE> swap >>quot ; inline : start-alarm ( alarm -- ) - f >>stop? - nano-count >>start-nanos - call-alarm ; + [ + '[ + _ nano-count >>start-nanos + [ delay-nanos>> [ sleep ] when* ] + [ nano-count >>iteration-start-nanos call-alarm-loop ] bi + ] "Alarm execution" spawn + ] keep thread<< ; : stop-alarm ( alarm -- ) - t >>stop? - f >>start-nanos - drop ; + dup quotation-running?>> [ + f >>thread drop + ] [ + [ [ interrupt ] when* f ] change-thread drop + ] if ; > - EVP_MAX_MD_SIZE 0 - [ EVP_DigestFinal_ex ssl-error ] 2keep - *int memory>byte-array ; + { { int EVP_MAX_MD_SIZE } int } + [ EVP_DigestFinal_ex ssl-error ] + [ memory>byte-array ] + with-out-parameters ; PRIVATE> diff --git a/basis/cocoa/messages/messages.factor b/basis/cocoa/messages/messages.factor index 5cce0401ce..029b3f46e6 100644 --- a/basis/cocoa/messages/messages.factor +++ b/basis/cocoa/messages/messages.factor @@ -1,11 +1,11 @@ ! Copyright (C) 2006, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien alien.c-types alien.strings arrays assocs -classes.struct continuations combinators compiler +USING: accessors alien alien.c-types alien.data alien.strings +arrays assocs classes.struct continuations combinators compiler core-graphics.types stack-checker kernel math namespaces make quotations sequences strings words cocoa.runtime cocoa.types io -macros memoize io.encodings.utf8 effects layouts libc -lexer init core-foundation fry generalizations specialized-arrays ; +macros memoize io.encodings.utf8 effects layouts libc lexer init +core-foundation fry generalizations specialized-arrays ; QUALIFIED-WITH: alien.c-types c IN: cocoa.messages @@ -216,7 +216,7 @@ ERROR: no-objc-type name ; objc-methods get set-at ; : each-method-in-class ( class quot -- ) - [ 0 [ class_copyMethodList ] keep *uint ] dip + [ { uint } [ class_copyMethodList ] [ ] with-out-parameters ] dip over 0 = [ 3drop ] [ [ ] dip [ each ] [ drop (free) ] 2bi diff --git a/basis/cocoa/nibs/nibs.factor b/basis/cocoa/nibs/nibs.factor index a39cc794d0..d4a11cc9d5 100644 --- a/basis/cocoa/nibs/nibs.factor +++ b/basis/cocoa/nibs/nibs.factor @@ -1,8 +1,8 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: cocoa.application cocoa.messages cocoa.classes -cocoa.runtime kernel cocoa alien.c-types core-foundation -core-foundation.arrays ; +USING: alien.c-types alien.data cocoa.application cocoa.messages +cocoa.classes cocoa.runtime cocoa core-foundation +core-foundation.arrays kernel ; IN: cocoa.nibs : load-nib ( name -- ) @@ -15,5 +15,7 @@ IN: cocoa.nibs dup [ -> autorelease ] when ; : nib-objects ( anNSNib -- objects/f ) - f f [ -> instantiateNibWithOwner:topLevelObjects: ] keep - swap [ *void* CF>array ] [ drop f ] if ; \ No newline at end of file + f + { void* } [ -> instantiateNibWithOwner:topLevelObjects: ] [ ] + with-out-parameters + swap [ CF>array ] [ drop f ] if ; \ No newline at end of file diff --git a/basis/cocoa/plists/plists.factor b/basis/cocoa/plists/plists.factor index 86b13b2ddc..80d58e6340 100644 --- a/basis/cocoa/plists/plists.factor +++ b/basis/cocoa/plists/plists.factor @@ -36,9 +36,11 @@ DEFER: plist> NSFastEnumeration-map >hashtable ; : (read-plist) ( NSData -- id ) - NSPropertyListSerialization swap kCFPropertyListImmutable f f - [ -> propertyListFromData:mutabilityOption:format:errorDescription: ] keep - *void* [ -> release "read-plist failed" throw ] when* ; + NSPropertyListSerialization swap kCFPropertyListImmutable f + { void* } + [ -> propertyListFromData:mutabilityOption:format:errorDescription: ] [ ] + with-out-parameters + [ -> release "read-plist failed" throw ] when* ; MACRO: objc-class-case ( alist -- quot ) [ diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 7045e64928..476e6da39e 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -763,6 +763,14 @@ mingw? [ [ S{ test-struct-11 f 7 -3 } ] [ 3 4 7 fastcall-struct-return-iii-callback fastcall-struct-return-iii-indirect ] unit-test +: x64-regression-1 ( -- c ) + int { int int int int int } cdecl [ + + + + ] alien-callback ; + +: x64-regression-2 ( x x x x x c -- y ) + int { int int int int int } cdecl alien-indirect ; inline + +[ 661 ] [ 100 500 50 10 1 x64-regression-1 x64-regression-2 ] unit-test + ! Stack allocation : blah ( -- x ) { RECT } [ 1.5 >>x 2.0 >>y [ x>> ] [ y>> ] bi * >fixnum ] with-scoped-allocation ; diff --git a/basis/core-foundation/core-foundation.factor b/basis/core-foundation/core-foundation.factor index 2ef388563e..0185387597 100644 --- a/basis/core-foundation/core-foundation.factor +++ b/basis/core-foundation/core-foundation.factor @@ -8,23 +8,20 @@ TYPEDEF: void* CFTypeRef TYPEDEF: void* CFAllocatorRef CONSTANT: kCFAllocatorDefault f -TYPEDEF: bool Boolean -TYPEDEF: long CFIndex -TYPEDEF: uchar UInt8 -TYPEDEF: ushort UInt16 -TYPEDEF: uint UInt32 +TYPEDEF: bool Boolean +TYPEDEF: long CFIndex +TYPEDEF: uchar UInt8 +TYPEDEF: ushort UInt16 +TYPEDEF: uint UInt32 TYPEDEF: ulonglong UInt64 -TYPEDEF: char SInt8 -TYPEDEF: short SInt16 -TYPEDEF: int SInt32 -TYPEDEF: longlong SInt64 +TYPEDEF: char SInt8 +TYPEDEF: short SInt16 +TYPEDEF: int SInt32 +TYPEDEF: longlong SInt64 TYPEDEF: ulong CFTypeID TYPEDEF: UInt32 CFOptionFlags TYPEDEF: void* CFUUIDRef -ALIAS: -ALIAS: *CFIndex *long - STRUCT: CFRange { location CFIndex } { length CFIndex } ; diff --git a/basis/core-foundation/fsevents/fsevents.factor b/basis/core-foundation/fsevents/fsevents.factor index ef1a3ff7f1..fd17843bf3 100644 --- a/basis/core-foundation/fsevents/fsevents.factor +++ b/basis/core-foundation/fsevents/fsevents.factor @@ -119,8 +119,7 @@ FUNCTION: CFStringRef FSEventStreamCopyDescription ( FSEventStreamRef streamRef flags FSEventStreamCreate ; -: kCFRunLoopCommonModes ( -- string ) - &: kCFRunLoopCommonModes *void* ; +C-GLOBAL: void* kCFRunLoopCommonModes : schedule-event-stream ( event-stream -- ) CFRunLoopGetMain diff --git a/basis/core-foundation/strings/strings.factor b/basis/core-foundation/strings/strings.factor index 4c7e9ba261..b78e1046fe 100644 --- a/basis/core-foundation/strings/strings.factor +++ b/basis/core-foundation/strings/strings.factor @@ -1,8 +1,9 @@ -! Copyright (C) 2008, 2009 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types 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 ; +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 ; IN: core-foundation.strings TYPEDEF: void* CFStringRef @@ -75,8 +76,12 @@ FUNCTION: CFStringRef CFStringCreateWithCString ( : CF>string ( alien -- string ) dup CFStringGetLength [ 0 swap kCFStringEncodingUTF8 0 f ] keep - 4 * 1 + [ dup length 0 [ CFStringGetBytes drop ] keep ] keep - swap *CFIndex head-slice utf8 decode ; + 4 * 1 + [ + dup length + { CFIndex } [ CFStringGetBytes drop ] [ ] + with-out-parameters + ] keep + swap head-slice utf8 decode ; : CF>string-array ( alien -- seq ) CF>array [ CF>string ] map ; diff --git a/basis/core-graphics/types/types.factor b/basis/core-graphics/types/types.factor index 587154fb2f..ac0ba31270 100644 --- a/basis/core-graphics/types/types.factor +++ b/basis/core-graphics/types/types.factor @@ -8,12 +8,6 @@ IN: core-graphics.types SYMBOL: CGFloat << cell 4 = float double ? \ CGFloat typedef >> -: ( x -- alien ) - cell 4 = [ ] [ ] if ; inline - -: *CGFloat ( alien -- x ) - cell 4 = [ *float ] [ *double ] if ; inline - STRUCT: CGPoint { x CGFloat } { y CGFloat } ; @@ -30,7 +24,7 @@ STRUCT: CGSize STRUCT: CGRect { origin CGPoint } - { size CGSize } ; + { size CGSize } ; : CGPoint>loc ( CGPoint -- loc ) [ x>> ] [ y>> ] bi 2array ; @@ -40,7 +34,7 @@ STRUCT: CGRect : CGRect>rect ( CGRect -- rect ) [ origin>> CGPoint>loc ] - [ size>> CGSize>dim ] + [ size>> CGSize>dim ] bi ; inline : CGRect-x ( CGRect -- x ) diff --git a/basis/core-text/core-text.factor b/basis/core-text/core-text.factor index 7af6792e79..4de8b2c06a 100644 --- a/basis/core-text/core-text.factor +++ b/basis/core-text/core-text.factor @@ -1,12 +1,12 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays alien alien.c-types alien.syntax kernel destructors -accessors fry words hashtables strings sequences memoize assocs math -math.order math.vectors math.rectangles math.functions locals init -namespaces combinators fonts colors cache core-foundation -core-foundation.strings core-foundation.attributed-strings -core-foundation.utilities core-graphics core-graphics.types -core-text.fonts ; +USING: arrays alien alien.c-types alien.data alien.syntax kernel +destructors accessors fry words hashtables strings sequences +memoize assocs math math.order math.vectors math.rectangles +math.functions locals init namespaces combinators fonts colors +cache core-foundation core-foundation.strings +core-foundation.attributed-strings core-foundation.utilities +core-graphics core-graphics.types core-text.fonts ; IN: core-text TYPEDEF: void* CTLineRef @@ -50,8 +50,8 @@ ERROR: not-a-string object ; TUPLE: line < disposable line metrics image loc dim ; : typographic-bounds ( line -- width ascent descent leading ) - 0 0 0 - [ CTLineGetTypographicBounds ] 3keep [ *CGFloat ] tri@ ; inline + { CGFloat CGFloat CGFloat } + [ CTLineGetTypographicBounds ] [ ] with-out-parameters ; inline : store-typographic-bounds ( metrics width ascent descent leading -- metrics ) { diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index ad4fc626f1..bde0507af9 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -58,14 +58,10 @@ M: x86.64 %set-vm-field ( src offset -- ) M: x86.64 %vm-field-ptr ( dst offset -- ) [ vm-reg ] dip [+] LEA ; -! Must be a volatile register not used for parameter passing or -! integer return -HOOK: temp-reg cpu ( -- reg ) - M: x86.64 %prologue ( n -- ) - temp-reg -7 [RIP+] LEA + R11 -7 [RIP+] LEA dup PUSH - temp-reg PUSH + R11 PUSH stack-reg swap 3 cells - SUB ; M: x86.64 %prepare-jump diff --git a/basis/cpu/x86/64/unix/unix.factor b/basis/cpu/x86/64/unix/unix.factor index c25cfa19ec..2ce959d29a 100644 --- a/basis/cpu/x86/64/unix/unix.factor +++ b/basis/cpu/x86/64/unix/unix.factor @@ -45,6 +45,4 @@ M: x86.64 dummy-int-params? f ; M: x86.64 dummy-fp-params? f ; -M: x86.64 temp-reg R8 ; - M: x86.64 %prepare-var-args RAX RAX XOR ; diff --git a/basis/cpu/x86/64/winnt/winnt.factor b/basis/cpu/x86/64/winnt/winnt.factor index 011de59ccb..7f1f29a603 100644 --- a/basis/cpu/x86/64/winnt/winnt.factor +++ b/basis/cpu/x86/64/winnt/winnt.factor @@ -23,5 +23,3 @@ M: x86.64 dummy-stack-params? f ; M: x86.64 dummy-int-params? t ; M: x86.64 dummy-fp-params? t ; - -M: x86.64 temp-reg R11 ; diff --git a/basis/cpu/x86/x86.factor b/basis/cpu/x86/x86.factor index 38c51591e9..58343a4eee 100644 --- a/basis/cpu/x86/x86.factor +++ b/basis/cpu/x86/x86.factor @@ -583,7 +583,7 @@ M:: x86 %store-stack-param ( src n rep -- ) #! input values to callbacks; the callback has its own #! stack frame set up, and we want to read the frame #! set up by the caller. - frame-reg swap 2 cells + [+] ; + [ frame-reg ] dip 2 cells + reserved-stack-space + [+] ; M:: x86 %load-stack-param ( dst n rep -- ) dst n next-stack@ rep %copy ; diff --git a/basis/db/postgresql/lib/lib.factor b/basis/db/postgresql/lib/lib.factor index 5398e669ed..7fe40a73d6 100644 --- a/basis/db/postgresql/lib/lib.factor +++ b/basis/db/postgresql/lib/lib.factor @@ -139,15 +139,14 @@ M: postgresql-malloc-destructor dispose ( obj -- ) [ 3drop ] dip [ memory>byte-array >string - 0 + { uint } [ PQunescapeBytea dup zero? [ postgresql-result-error-message throw ] [ &postgresql-free ] if - ] keep - *uint memory>byte-array + ] [ ] with-out-parameters memory>byte-array ] with-destructors ] [ drop pq-get-is-null nip [ f ] [ B{ } clone ] if diff --git a/basis/db/sqlite/lib/lib.factor b/basis/db/sqlite/lib/lib.factor index b8e56863c3..58033a281e 100644 --- a/basis/db/sqlite/lib/lib.factor +++ b/basis/db/sqlite/lib/lib.factor @@ -27,16 +27,17 @@ ERROR: sqlite-sql-error < sql-error n string ; : sqlite-open ( path -- db ) normalize-path - void* - [ sqlite3_open sqlite-check-result ] keep *void* ; + { void* } [ sqlite3_open sqlite-check-result ] [ ] + with-out-parameters ; : sqlite-close ( db -- ) sqlite3_close sqlite-check-result ; : sqlite-prepare ( db sql -- handle ) - utf8 encode dup length void* void* - [ sqlite3_prepare_v2 sqlite-check-result ] 2keep - drop *void* ; + utf8 encode dup length + { void* void* } + [ sqlite3_prepare_v2 sqlite-check-result ] [ drop ] + with-out-parameters ; : sqlite-bind-parameter-index ( handle name -- index ) sqlite3_bind_parameter_index ; diff --git a/basis/game/input/x11/x11.factor b/basis/game/input/x11/x11.factor index 2e6514d396..ecdbee8284 100644 --- a/basis/game/input/x11/x11.factor +++ b/basis/game/input/x11/x11.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2010 Erik Charlebois, William Schlieper. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types arrays kernel game.input +USING: accessors alien.c-types alien.data arrays kernel game.input namespaces math classes bit-arrays system sequences vectors -x11 x11.xlib assocs ; +x11 x11.xlib assocs generalizations ; IN: game.input.x11 SINGLETON: x11-game-input-backend @@ -88,9 +88,9 @@ M: x11-game-input-backend read-keyboard : query-pointer ( -- x y buttons ) dpy get dup XDefaultRootWindow - 0 0 0 0 0 0 0 - [ XQueryPointer drop ] 3keep - [ *int ] tri@ ; + { int int int int int int int } + [ XQueryPointer drop ] [ ] with-out-parameters + [ 4 ndrop ] 3dip ; SYMBOL: mouse-reset? diff --git a/basis/io/backend/windows/nt/nt.factor b/basis/io/backend/windows/nt/nt.factor old mode 100644 new mode 100755 index bd59afc26d..c0a6ee807d --- a/basis/io/backend/windows/nt/nt.factor +++ b/basis/io/backend/windows/nt/nt.factor @@ -1,9 +1,11 @@ -USING: alien alien.c-types arrays assocs combinators continuations -destructors io io.backend io.ports io.timeouts io.backend.windows -io.files.windows io.files.windows.nt io.files io.pathnames io.buffers -io.streams.c io.streams.null libc kernel math namespaces sequences -threads windows windows.errors windows.kernel32 strings splitting -ascii system accessors locals classes.struct combinators.short-circuit ; +USING: alien alien.c-types alien.data alien.syntax arrays assocs +combinators continuations destructors io io.backend io.ports +io.timeouts io.backend.windows io.files.windows +io.files.windows.nt io.files io.pathnames io.buffers +io.streams.c io.streams.null libc kernel math namespaces +sequences threads windows windows.errors windows.kernel32 +strings splitting ascii system accessors locals classes.struct +combinators.short-circuit ; IN: io.backend.windows.nt ! Global variable with assoc mapping overlapped to threads @@ -51,16 +53,12 @@ M: winnt add-completion ( win32-handle -- ) ] with-timeout ; :: wait-for-overlapped ( nanos -- bytes-transferred overlapped error? ) - master-completion-port get-global - 0 :> bytes - f :> key - f :> overlapped nanos [ 1,000,000 /i ] [ INFINITE ] if* :> timeout - bytes key overlapped timeout GetQueuedCompletionStatus zero? :> error? - - bytes *int - overlapped *void* dup [ OVERLAPPED memory>struct ] when - error? ; + master-completion-port get-global + { int void* pointer: OVERLAPPED } + [ timeout GetQueuedCompletionStatus zero? ] [ ] with-out-parameters + :> ( error? bytes key overlapped ) + bytes overlapped error? ; : resume-callback ( result overlapped -- ) >c-ptr pending-overlapped get-global delete-at* drop resume-with ; diff --git a/basis/io/backend/windows/nt/privileges/privileges.factor b/basis/io/backend/windows/nt/privileges/privileges.factor index 6c63d3eda0..27687df9d5 100644 --- a/basis/io/backend/windows/nt/privileges/privileges.factor +++ b/basis/io/backend/windows/nt/privileges/privileges.factor @@ -13,8 +13,10 @@ TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES ! http://msdn.microsoft.com/msdnmag/issues/05/03/TokenPrivileges/ : (open-process-token) ( handle -- handle ) - flags{ TOKEN_ADJUST_PRIVILEGES TOKEN_QUERY } PHANDLE - [ OpenProcessToken win32-error=0/f ] keep *void* ; + flags{ TOKEN_ADJUST_PRIVILEGES TOKEN_QUERY } + { PHANDLE } + [ OpenProcessToken win32-error=0/f ] [ ] + with-out-parameters ; : open-process-token ( -- handle ) #! remember to CloseHandle diff --git a/basis/io/files/info/windows/windows.factor b/basis/io/files/info/windows/windows.factor old mode 100644 new mode 100755 index 799b6dc4b2..96e302860d --- a/basis/io/files/info/windows/windows.factor +++ b/basis/io/files/info/windows/windows.factor @@ -6,7 +6,7 @@ windows.time windows.types windows accessors alien.c-types combinators generalizations system alien.strings io.encodings.utf16n sequences splitting windows.errors fry continuations destructors calendar ascii -combinators.short-circuit locals classes.struct +combinators.short-circuit literals locals classes.struct specialized-arrays alien.data ; SPECIALIZED-ARRAY: ushort IN: io.files.info.windows @@ -21,12 +21,8 @@ IN: io.files.info.windows TUPLE: windows-file-info < file-info attributes ; : get-compressed-file-size ( path -- n ) - DWORD [ GetCompressedFileSize ] keep - over INVALID_FILE_SIZE = [ - win32-error-string throw - ] [ - *uint >64bit - ] if ; + { DWORD } [ GetCompressedFileSize ] [ ] with-out-parameters + over INVALID_FILE_SIZE = [ win32-error-string throw ] [ >64bit ] if ; : set-windows-size-on-disk ( file-info path -- file-info ) over attributes>> +compressed+ swap member? [ @@ -99,22 +95,18 @@ M: windows file-info ( path -- info ) M: windows link-info ( path -- info ) file-info ; +CONSTANT: path-length $[ MAX_PATH 1 + ] + : volume-information ( normalized-path -- volume-name volume-serial max-component flags type ) - MAX_PATH 1 + [ ] keep - DWORD - DWORD - DWORD - MAX_PATH 1 + [ ] keep - [ GetVolumeInformation win32-error=0/f ] 7 nkeep - drop 5 nrot drop - [ utf16n alien>string ] 4 ndip - utf16n alien>string ; + { { ushort path-length } DWORD DWORD DWORD { ushort path-length } } + [ [ path-length ] 4dip path-length GetVolumeInformation win32-error=0/f ] + [ [ utf16n alien>string ] 4dip utf16n alien>string ] + with-out-parameters ; : file-system-space ( normalized-path -- available-space total-space free-space ) - ULARGE_INTEGER - ULARGE_INTEGER - ULARGE_INTEGER - [ GetDiskFreeSpaceEx win32-error=0/f ] 3keep ; + { ULARGE_INTEGER ULARGE_INTEGER ULARGE_INTEGER } + [ GetDiskFreeSpaceEx win32-error=0/f ] [ ] + with-out-parameters ; : calculate-file-system-info ( file-system-info -- file-system-info' ) [ dup [ total-space>> ] [ free-space>> ] bi - >>used-space drop ] keep ; @@ -136,13 +128,13 @@ ERROR: not-absolute-path ; : (file-system-info) ( path -- file-system-info ) dup [ volume-information ] [ file-system-space ] bi \ win32-file-system-info new - swap *ulonglong >>free-space - swap *ulonglong >>total-space - swap *ulonglong >>available-space + swap >>free-space + swap >>total-space + swap >>available-space swap >>type - swap *uint >>flags - swap *uint >>max-component - swap *uint >>device-serial + swap >>flags + swap >>max-component + swap >>device-serial swap >>device-name swap >>mount-point calculate-file-system-info ; @@ -152,36 +144,29 @@ PRIVATE> M: winnt file-system-info ( path -- file-system-info ) normalize-path root-directory (file-system-info) ; -:: volume>paths ( string -- array ) - 16384 :> names-buf-length - names-buf-length :> names - 0 :> names-length +CONSTANT: names-buf-length 16384 - string names names-buf-length names-length GetVolumePathNamesForVolumeName :> ret - ret 0 = [ - ret win32-error-string throw - ] [ - names names-length *uint ushort heap-size * head - utf16n alien>string { CHAR: \0 } split - ] if ; +: volume>paths ( string -- array ) + { { ushort names-buf-length } uint } + [ [ names-buf-length ] dip GetVolumePathNamesForVolumeName win32-error=0/f ] + [ head utf16n alien>string { CHAR: \0 } split ] + with-out-parameters ; : find-first-volume ( -- string handle ) - MAX_PATH 1 + [ ] keep - dupd - FindFirstVolume dup win32-error=0/f - [ utf16n alien>string ] dip ; + { { ushort path-length } } + [ path-length FindFirstVolume dup win32-error=0/f ] + [ utf16n alien>string ] + with-out-parameters swap ; -:: find-next-volume ( handle -- string/f ) - MAX_PATH 1 + :> buf-length - buf-length :> buf - - handle buf buf-length FindNextVolume :> ret - ret 0 = [ - GetLastError ERROR_NO_MORE_FILES = - [ f ] [ win32-error-string throw ] if - ] [ - buf utf16n alien>string - ] if ; +: find-next-volume ( handle -- string/f ) + { { ushort path-length } } + [ path-length FindNextVolume ] + [ + swap 0 = [ + GetLastError ERROR_NO_MORE_FILES = + [ drop f ] [ win32-error-string throw ] if + ] [ utf16n alien>string ] if + ] with-out-parameters ; : find-volumes ( -- array ) find-first-volume @@ -202,11 +187,10 @@ M: winnt file-systems ( -- array ) : file-times ( path -- timestamp timestamp timestamp ) [ normalize-path open-read &dispose handle>> - FILETIME - FILETIME - FILETIME - [ GetFileTime win32-error=0/f ] 3keep - [ FILETIME>timestamp >local-time ] tri@ + { FILETIME FILETIME FILETIME } + [ GetFileTime win32-error=0/f ] + [ [ FILETIME>timestamp >local-time ] tri@ ] + with-out-parameters ] with-destructors ; : set-file-times ( path timestamp/f timestamp/f timestamp/f -- ) diff --git a/basis/io/launcher/unix/unix.factor b/basis/io/launcher/unix/unix.factor index 87af808df2..e036f34cc6 100644 --- a/basis/io/launcher/unix/unix.factor +++ b/basis/io/launcher/unix/unix.factor @@ -1,10 +1,11 @@ ! Copyright (C) 2007, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types arrays assocs combinators -continuations environment io io.backend io.backend.unix -io.files io.files.private io.files.unix io.launcher io.pathnames -io.ports kernel math namespaces sequences strings system threads -unix unix.process unix.ffi simple-tokenizer ; +USING: accessors alien.c-types alien.data arrays assocs +combinators continuations environment io io.backend +io.backend.unix io.files io.files.private io.files.unix +io.launcher io.pathnames io.ports kernel math namespaces +sequences strings system threads unix unix.process unix.ffi +simple-tokenizer ; IN: io.launcher.unix : get-arguments ( process -- seq ) @@ -94,10 +95,10 @@ TUPLE: signal n ; dup WIFSIGNALED [ WTERMSIG signal boa ] [ WEXITSTATUS ] if ; M: unix wait-for-processes ( -- ? ) - 0 -1 over WNOHANG waitpid - dup 0 <= [ + { int } [ -1 swap WNOHANG waitpid ] [ ] with-out-parameters + swap dup 0 <= [ 2drop t ] [ find-process dup - [ swap *int code>status notify-exit f ] [ 2drop f ] if + [ swap code>status notify-exit f ] [ 2drop f ] if ] if ; diff --git a/basis/io/launcher/windows/windows.factor b/basis/io/launcher/windows/windows.factor index b279b1e964..cc9e52a189 100755 --- a/basis/io/launcher/windows/windows.factor +++ b/basis/io/launcher/windows/windows.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007, 2010 Doug Coleman, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien alien.c-types arrays continuations io +USING: alien alien.c-types alien.data arrays continuations io io.backend.windows io.pipes.windows.nt io.pathnames libc io.ports windows.types math windows.kernel32 namespaces make io.launcher kernel sequences windows.errors splitting system @@ -159,7 +159,7 @@ M: windows kill-process* ( handle -- ) : exit-code ( process -- n ) hProcess>> - 0 [ GetExitCodeProcess ] keep *ulong + { DWORD } [ GetExitCodeProcess ] [ ] with-out-parameters swap win32-error=0/f ; : process-exited ( process -- ) diff --git a/basis/io/sockets/windows/nt/nt.factor b/basis/io/sockets/windows/nt/nt.factor index 7a961518a0..17e92b9b9f 100644 --- a/basis/io/sockets/windows/nt/nt.factor +++ b/basis/io/sockets/windows/nt/nt.factor @@ -17,7 +17,7 @@ M: winnt WSASocket-flags ( -- DWORD ) SIO_GET_EXTENSION_FUNCTION_POINTER WSAID_CONNECTEX GUID heap-size - void* + { void* } [ void* heap-size DWORD @@ -26,7 +26,7 @@ M: winnt WSASocket-flags ( -- DWORD ) WSAIoctl SOCKET_ERROR = [ winsock-error-string throw ] when - ] keep *void* ; + ] [ ] with-out-parameters ; TUPLE: ConnectEx-args port s name namelen lpSendBuffer dwSendDataLength diff --git a/basis/iokit/iokit.factor b/basis/iokit/iokit.factor index 577c9e1273..5720fc5997 100644 --- a/basis/iokit/iokit.factor +++ b/basis/iokit/iokit.factor @@ -1,4 +1,4 @@ -USING: alien.syntax alien.c-types core-foundation +USING: alien.syntax alien.c-types alien.data core-foundation core-foundation.bundles core-foundation.dictionaries system combinators kernel sequences io accessors unix.types ; IN: iokit @@ -131,12 +131,11 @@ TUPLE: mach-error error-code error-string ; dup KERN_SUCCESS = [ drop ] [ throw ] if ; : master-port ( -- port ) - MACH_PORT_NULL 0 [ IOMasterPort mach-error ] keep *uint ; + MACH_PORT_NULL { uint } [ IOMasterPort mach-error ] [ ] with-out-parameters ; : io-services-matching-dictionary ( nsdictionary -- iterator ) - master-port swap 0 - [ IOServiceGetMatchingServices mach-error ] keep - *uint ; + master-port swap + { uint } [ IOServiceGetMatchingServices mach-error ] [ ] with-out-parameters ; : io-services-matching-service ( service -- iterator ) IOServiceMatching io-services-matching-dictionary ; diff --git a/basis/opengl/framebuffers/framebuffers.factor b/basis/opengl/framebuffers/framebuffers.factor index d3e6d7e25a..ce19a2ec89 100644 --- a/basis/opengl/framebuffers/framebuffers.factor +++ b/basis/opengl/framebuffers/framebuffers.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Joe Groff. ! See http://factorcode.org/license.txt for BSD license. USING: opengl opengl.gl combinators continuations kernel -alien.c-types ; +alien.c-types alien.data ; IN: opengl.framebuffers : gen-framebuffer ( -- id ) @@ -51,4 +51,4 @@ IN: opengl.framebuffers : framebuffer-attachment ( attachment -- id ) GL_FRAMEBUFFER swap GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME - 0 [ glGetFramebufferAttachmentParameteriv ] keep *uint ; + { uint } [ glGetFramebufferAttachmentParameteriv ] [ ] with-out-parameters ; diff --git a/basis/opengl/gl/extensions/extensions.factor b/basis/opengl/gl/extensions/extensions.factor index 530f3ada6c..1c6cd3d9ed 100644 --- a/basis/opengl/gl/extensions/extensions.factor +++ b/basis/opengl/gl/extensions/extensions.factor @@ -7,7 +7,7 @@ ERROR: unknown-gl-platform ; << { { [ os windows? ] [ "opengl.gl.windows" ] } { [ os macosx? ] [ "opengl.gl.macosx" ] } - { [ os unix? ] [ "opengl.gl.unix" ] } + { [ os unix? ] [ "opengl.gl.x11" ] } [ unknown-gl-platform ] } cond use-vocab >> diff --git a/basis/opengl/gl/unix/authors.txt b/basis/opengl/gl/x11/authors.txt similarity index 100% rename from basis/opengl/gl/unix/authors.txt rename to basis/opengl/gl/x11/authors.txt diff --git a/basis/opengl/gl/unix/platforms.txt b/basis/opengl/gl/x11/platforms.txt similarity index 100% rename from basis/opengl/gl/unix/platforms.txt rename to basis/opengl/gl/x11/platforms.txt diff --git a/basis/opengl/gl/unix/unix.factor b/basis/opengl/gl/x11/x11.factor similarity index 92% rename from basis/opengl/gl/unix/unix.factor rename to basis/opengl/gl/x11/x11.factor index c0a0218ed2..2d752757bb 100644 --- a/basis/opengl/gl/unix/unix.factor +++ b/basis/opengl/gl/x11/x11.factor @@ -1,5 +1,5 @@ USING: alien kernel x11.glx ; -IN: opengl.gl.unix +IN: opengl.gl.x11 : gl-function-context ( -- context ) glXGetCurrentContext ; inline : gl-function-address ( name -- address ) glXGetProcAddressARB ; inline diff --git a/basis/opengl/opengl.factor b/basis/opengl/opengl.factor index 6dcb4110a2..893a8dfbd6 100644 --- a/basis/opengl/opengl.factor +++ b/basis/opengl/opengl.factor @@ -2,11 +2,11 @@ ! Portions copyright (C) 2007 Eduardo Cavazos. ! Portions copyright (C) 2008 Joe Groff. ! See http://factorcode.org/license.txt for BSD license. -USING: alien alien.c-types ascii calendar combinators.short-circuit -continuations kernel libc math macros namespaces math.vectors -math.parser opengl.gl combinators combinators.smart arrays -sequences splitting words byte-arrays assocs vocabs -colors colors.constants accessors generalizations +USING: alien alien.c-types alien.data ascii calendar +combinators.short-circuit continuations kernel libc math macros +namespaces math.vectors math.parser opengl.gl combinators +combinators.smart arrays sequences splitting words byte-arrays +assocs vocabs colors colors.constants accessors generalizations sequences.generalizations locals fry specialized-arrays ; FROM: alien.c-types => float ; SPECIALIZED-ARRAY: float @@ -139,7 +139,7 @@ MACRO: all-enabled-client-state ( seq quot -- ) swap glPushAttrib call glPopAttrib ; inline : (gen-gl-object) ( quot -- id ) - [ 1 0 ] dip keep *uint ; inline + [ 1 { uint } ] dip [ ] with-out-parameters ; inline : (delete-gl-object) ( id quot -- ) [ 1 swap ] dip call ; inline diff --git a/basis/opengl/shaders/shaders.factor b/basis/opengl/shaders/shaders.factor index 562cbc91ce..4e17a01624 100644 --- a/basis/opengl/shaders/shaders.factor +++ b/basis/opengl/shaders/shaders.factor @@ -20,7 +20,7 @@ IN: opengl.shaders dup integer? [ glIsShader c-bool> ] [ drop f ] if ; : gl-shader-get-int ( shader enum -- value ) - 0 [ glGetShaderiv ] keep *int ; + { int } [ glGetShaderiv ] [ ] with-out-parameters ; : gl-shader-ok? ( shader -- ? ) GL_COMPILE_STATUS gl-shader-get-int c-bool> ; @@ -79,7 +79,7 @@ PREDICATE: fragment-shader < gl-shader (fragment-shader?) ; dup integer? [ glIsProgram c-bool> ] [ drop f ] if ; : gl-program-get-int ( program enum -- value ) - 0 [ glGetProgramiv ] keep *int ; + { int } [ glGetProgramiv ] [ ] with-out-parameters ; : gl-program-ok? ( program -- ? ) GL_LINK_STATUS gl-program-get-int c-bool> ; diff --git a/basis/opengl/textures/textures.factor b/basis/opengl/textures/textures.factor index 2341706f4c..dacea0888a 100644 --- a/basis/opengl/textures/textures.factor +++ b/basis/opengl/textures/textures.factor @@ -1,11 +1,11 @@ ! Copyright (C) 2009, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs cache colors.constants destructors -kernel opengl opengl.gl opengl.capabilities combinators images -images.tesselation grouping sequences math math.vectors -generalizations fry arrays namespaces system -locals literals specialized-arrays ; -FROM: alien.c-types => float *float *int ; +USING: accessors alien.data assocs cache colors.constants +destructors kernel opengl opengl.gl opengl.capabilities +combinators images images.tesselation grouping sequences math +math.vectors generalizations fry arrays namespaces system locals +literals specialized-arrays ; +FROM: alien.c-types => int float ; SPECIALIZED-ARRAY: float IN: opengl.textures @@ -406,7 +406,7 @@ PRIVATE> [ [ max-texture-size tesselate ] dip ] if ; : get-texture-float ( target level enum -- value ) - 0 [ glGetTexLevelParameterfv ] keep *float ; inline -: get-texture-int ( target level enum -- value ) - 0 [ glGetTexLevelParameteriv ] keep *int ; inline + { float } [ glGetTexLevelParameterfv ] [ ] with-out-parameters ; inline +: get-texture-int ( target level enum -- value ) + { int } [ glGetTexLevelParameteriv ] [ ] with-out-parameters ; inline diff --git a/basis/pango/cairo/cairo.factor b/basis/pango/cairo/cairo.factor index 85d4cef424..68a9f2f6df 100644 --- a/basis/pango/cairo/cairo.factor +++ b/basis/pango/cairo/cairo.factor @@ -3,12 +3,13 @@ ! See http://factorcode.org/license.txt for BSD license. ! ! pangocairo bindings, from pango/pangocairo.h -USING: arrays sequences alien alien.c-types alien.destructors -alien.libraries alien.syntax math math.functions math.vectors -destructors combinators colors fonts accessors assocs namespaces -kernel pango pango.fonts pango.layouts glib unicode.data images -cache init system math.rectangles fry memoize io.encodings.utf8 -classes.struct cairo cairo.ffi ; +USING: arrays sequences alien alien.c-types alien.data +alien.destructors alien.libraries alien.syntax math +math.functions math.vectors destructors combinators colors fonts +accessors assocs namespaces kernel pango pango.fonts +pango.layouts glib unicode.data images cache init system +math.rectangles fry memoize io.encodings.utf8 classes.struct +cairo cairo.ffi ; IN: pango.cairo << { @@ -136,16 +137,17 @@ SYMBOL: dpi : line-offset>x ( layout n -- x ) #! n is an index into the UTF8 encoding of the text [ drop first-line ] [ swap string>> >utf8-index ] 2bi - 0 0 [ pango_layout_line_index_to_x ] keep - *int pango>float ; + 0 { int } [ pango_layout_line_index_to_x ] [ ] with-out-parameters + pango>float ; : x>line-offset ( layout x -- n ) #! n is an index into the UTF8 encoding of the text [ [ first-line ] dip - float>pango 0 0 - [ pango_layout_line_x_to_index drop ] 2keep - [ *int ] bi@ swap + float>pango + { int int } + [ pango_layout_line_x_to_index drop ] [ ] with-out-parameters + swap ] [ drop string>> ] 2bi utf8-index> + ; : selection-start/end ( selection -- start end ) diff --git a/basis/random/windows/windows.factor b/basis/random/windows/windows.factor old mode 100644 new mode 100755 index 72b908a32f..0629481a1b --- a/basis/random/windows/windows.factor +++ b/basis/random/windows/windows.factor @@ -16,24 +16,22 @@ M: windows-crypto-context dispose ( tuple -- ) CONSTANT: factor-crypto-container "FactorCryptoContainer" -:: (acquire-crypto-context) ( provider type flags -- handle ret ) - HCRYPTPROV :> handle - handle - factor-crypto-container - provider - type - flags - CryptAcquireContextW handle swap ; +:: (acquire-crypto-context) ( provider type flags -- ret handle ) + { HCRYPTPROV } [ + factor-crypto-container + provider + type + flags + CryptAcquireContextW + ] [ ] with-out-parameters ; : acquire-crypto-context ( provider type -- handle ) CRYPT_MACHINE_KEYSET (acquire-crypto-context) - 0 = [ + swap 0 = [ GetLastError NTE_BAD_KEYSET = [ drop f ] [ win32-error-string throw ] if - ] [ - *void* - ] if ; + ] when ; : create-crypto-context ( provider type -- handle ) flags{ CRYPT_MACHINE_KEYSET CRYPT_NEWKEYSET } diff --git a/basis/system-info/windows/nt/nt-tests.factor b/basis/system-info/windows/nt/nt-tests.factor new file mode 100755 index 0000000000..dfbd8b3283 --- /dev/null +++ b/basis/system-info/windows/nt/nt-tests.factor @@ -0,0 +1,7 @@ +USING: math.order strings system-info.backend +system-info.windows system-info.windows.nt +tools.test ; +IN: system-info.windows.nt.tests + +[ t ] [ cpus 0 1024 between? ] unit-test +[ t ] [ username string? ] unit-test diff --git a/basis/system-info/windows/nt/nt.factor b/basis/system-info/windows/nt/nt.factor index 6d293affba..804eb25def 100644 --- a/basis/system-info/windows/nt/nt.factor +++ b/basis/system-info/windows/nt/nt.factor @@ -12,7 +12,7 @@ M: winnt cpus ( -- n ) : memory-status ( -- MEMORYSTATUSEX ) MEMORYSTATUSEX - dup class heap-size >>dwLength + MEMORYSTATUSEX heap-size >>dwLength dup GlobalMemoryStatusEx win32-error=0/f ; M: winnt memory-load ( -- n ) diff --git a/basis/ui/backend/cocoa/cocoa.factor b/basis/ui/backend/cocoa/cocoa.factor index 0ce6a8cb08..72a9abcef0 100644 --- a/basis/ui/backend/cocoa/cocoa.factor +++ b/basis/ui/backend/cocoa/cocoa.factor @@ -1,14 +1,14 @@ ! Copyright (C) 2006, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types arrays assocs classes cocoa -cocoa.application cocoa.classes cocoa.messages cocoa.nibs +USING: accessors alien.c-types alien.data arrays assocs classes +cocoa cocoa.application cocoa.classes cocoa.messages cocoa.nibs cocoa.pasteboard cocoa.runtime cocoa.subclassing cocoa.types cocoa.views cocoa.windows combinators command-line core-foundation core-foundation.run-loop core-graphics core-graphics.types destructors fry generalizations io.thread -kernel libc literals locals math math.bitwise math.rectangles memory -namespaces sequences threads ui colors -ui.backend ui.backend.cocoa.views ui.clipboards ui.gadgets +kernel libc literals locals math math.bitwise math.rectangles +memory namespaces sequences threads ui colors ui.backend +ui.backend.cocoa.views ui.clipboards ui.gadgets ui.gadgets.worlds ui.pixel-formats ui.pixel-formats.private ui.private words.symbol ; IN: ui.backend.cocoa @@ -55,8 +55,11 @@ M: cocoa-ui-backend (free-pixel-format) M: cocoa-ui-backend (pixel-format-attribute) [ handle>> ] [ >NSOpenGLPFA ] bi* [ drop f ] - [ first 0 [ swap 0 -> getValues:forAttribute:forVirtualScreen: ] keep *int ] - if-empty ; + [ + first + { int } [ swap 0 -> getValues:forAttribute:forVirtualScreen: ] [ ] + with-out-parameters + ] if-empty ; TUPLE: pasteboard handle ; diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index 00fdb907fd..6ce43528e0 100755 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -59,16 +59,16 @@ PIXEL-FORMAT-ATTRIBUTE-TABLE: WGL_ARB { $ WGL_SUPPORT_OPENGL_ARB 1 } H{ drop f ; : arb-make-pixel-format ( world attributes -- pf ) - [ handle>> hDC>> ] dip >WGL_ARB-int-array f 1 0 0 - [ wglChoosePixelFormatARB win32-error=0/f ] 2keep drop *int ; + [ handle>> hDC>> ] dip >WGL_ARB-int-array f 1 { int int } + [ wglChoosePixelFormatARB win32-error=0/f ] [ ] with-out-parameters drop ; : arb-pixel-format-attribute ( pixel-format attribute -- value ) >WGL_ARB [ drop f ] [ [ [ world>> handle>> hDC>> ] [ handle>> ] bi 0 1 ] dip - first 0 - [ wglGetPixelFormatAttribivARB win32-error=0/f ] - keep *int + first { int } + [ wglGetPixelFormatAttribivARB win32-error=0/f ] [ ] + with-out-parameters ] if-empty ; CONSTANT: pfd-flag-map H{ diff --git a/basis/ui/backend/x11/x11.factor b/basis/ui/backend/x11/x11.factor index 2f979ee4f1..d43f814eef 100644 --- a/basis/ui/backend/x11/x11.factor +++ b/basis/ui/backend/x11/x11.factor @@ -1,14 +1,15 @@ ! Copyright (C) 2005, 2010 Eduardo Cavazos and Slava Pestov ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types ascii assocs classes.struct combinators -combinators.short-circuit command-line environment io.encodings.ascii -io.encodings.string io.encodings.utf8 kernel literals locals math -namespaces sequences specialized-arrays.instances.alien.c-types.uchar +USING: accessors alien.c-types alien.data ascii assocs classes.struct +combinators combinators.short-circuit command-line environment +io.encodings.ascii io.encodings.string io.encodings.utf8 kernel +literals locals math namespaces sequences specialized-arrays strings ui ui.backend ui.clipboards ui.event-loop ui.gadgets ui.gadgets.private ui.gadgets.worlds ui.gestures ui.pixel-formats ui.pixel-formats.private ui.private x11 x11.clipboard x11.constants x11.events x11.glx x11.io x11.windows x11.xim x11.xlib ; FROM: unix.ffi => system ; +SPECIALIZED-ARRAY: uchar IN: ui.backend.x11 SINGLETON: x11-ui-backend @@ -60,7 +61,7 @@ M: x11-ui-backend (pixel-format-attribute) [ handle>> ] [ >glx-visual ] bi* [ 2drop f ] [ first - 0 [ glXGetConfig drop ] keep *int + { int } [ glXGetConfig drop ] [ ] with-out-parameters ] if-empty ; CONSTANT: modifiers diff --git a/basis/ui/gadgets/editors/editors.factor b/basis/ui/gadgets/editors/editors.factor index f4dcff4cbe..15d2146603 100644 --- a/basis/ui/gadgets/editors/editors.factor +++ b/basis/ui/gadgets/editors/editors.factor @@ -65,7 +65,7 @@ SYMBOL: blink-interval : start-blinking ( editor -- ) [ stop-blinking ] [ t >>blink - dup '[ _ blink-caret ] blink-interval get every + dup '[ _ blink-caret ] blink-interval get delayed-every >>blink-alarm drop ] bi ; diff --git a/basis/ui/tools/tools.factor b/basis/ui/tools/tools.factor index 42bc0ef1f2..1b5fcb50c4 100644 --- a/basis/ui/tools/tools.factor +++ b/basis/ui/tools/tools.factor @@ -5,10 +5,7 @@ ui.tools.listener ui.tools.browser ui.tools.common ui.tools.error-list ui.tools.walker ui.commands ui.gestures ui ui.private ; IN: ui.tools -: main ( -- ) - restore-windows? [ restore-windows ] [ listener-window ] if ; - -MAIN: main +MAIN: listener-window \ refresh-all H{ { +nullary+ t } { +listener+ t } } define-command diff --git a/basis/ui/ui.factor b/basis/ui/ui.factor index bf186ee9a8..d55d1af096 100644 --- a/basis/ui/ui.factor +++ b/basis/ui/ui.factor @@ -1,11 +1,12 @@ -! Copyright (C) 2006, 2009 Slava Pestov. +! Copyright (C) 2006, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays assocs io kernel math models namespaces make dlists -deques sequences threads words continuations init -combinators combinators.short-circuit hashtables concurrency.flags -sets accessors calendar fry destructors ui.gadgets ui.gadgets.private -ui.gadgets.worlds ui.gadgets.tracks ui.gestures ui.backend ui.render -strings classes.tuple classes.tuple.parser lexer vocabs.parser parser ; +USING: arrays assocs boxes io kernel math models namespaces make +dlists deques sequences threads words continuations init +combinators combinators.short-circuit hashtables +concurrency.flags sets accessors calendar fry destructors +ui.gadgets ui.gadgets.private ui.gadgets.worlds +ui.gadgets.tracks ui.gestures ui.backend ui.render strings +classes.tuple classes.tuple.parser lexer vocabs.parser parser ; IN: ui >handle unfocus-world ; - -: (ungraft-world) ( world -- ) +M: world ungraft* { [ set-gl-context ] [ text-handle>> [ dispose ] when* ] @@ -96,38 +92,21 @@ M: world graft* [ hand-gadget close-global ] [ end-world ] [ [ [ [ dispose ] when* ] each V{ } clone ] change-window-resources drop ] + [ [ (close-window) f ] change-handle drop ] + [ unfocus-world ] } cleave ; -M: world ungraft* - [ (ungraft-world) ] - [ handle>> (close-window) ] - [ reset-world ] tri ; - : init-ui ( -- ) + drag-timer set-global + f hand-gadget set-global + f hand-clicked set-global + f hand-world set-global + f world set-global \ graft-queue set-global \ layout-queue set-global \ gesture-queue set-global V{ } clone windows set-global ; -: restore-gadget-later ( gadget -- ) - dup graft-state>> { - { { f f } [ ] } - { { f t } [ ] } - { { t t } [ { f f } >>graft-state ] } - { { t f } [ dup unqueue-graft { f f } >>graft-state ] } - } case graft-later ; - -: restore-gadget ( gadget -- ) - dup restore-gadget-later - children>> [ restore-gadget ] each ; - -: restore-world ( world -- ) - { - [ reset-world ] - [ f >>text-handle f >>images drop ] - [ restore-gadget ] - } cleave ; - : update-hand ( world -- ) dup hand-world get-global eq? [ hand-loc get-global swap move-hand ] [ drop ] if ; @@ -188,16 +167,6 @@ PRIVATE> : start-ui ( quot -- ) call( -- ) notify-ui-thread start-ui-thread ; -: restore-windows ( -- ) - [ - windows get [ values ] [ delete-all ] bi - [ restore-world ] each - forget-rollover - ] (with-ui) ; - -: restore-windows? ( -- ? ) - windows get empty? not ; - : ?attributes ( gadget title/attributes -- attributes ) dup string? [ world-attributes new swap >>title ] [ clone ] if swap [ [ [ 1array ] [ f ] if* ] curry unless* ] curry change-gadgets ; diff --git a/basis/unix/process/process.factor b/basis/unix/process/process.factor index 1e9129af58..a112b9829a 100644 --- a/basis/unix/process/process.factor +++ b/basis/unix/process/process.factor @@ -95,6 +95,3 @@ CONSTANT: WNOWAIT HEX: 1000000 FUNCTION: pid_t wait ( int* status ) ; FUNCTION: pid_t waitpid ( pid_t wpid, int* status, int options ) ; - -: wait-for-pid ( pid -- status ) - 0 [ 0 waitpid drop ] keep *int WEXITSTATUS ; diff --git a/basis/windows/dwmapi/dwmapi.factor b/basis/windows/dwmapi/dwmapi.factor index 60fa5b4d83..b9830a5347 100755 --- a/basis/windows/dwmapi/dwmapi.factor +++ b/basis/windows/dwmapi/dwmapi.factor @@ -34,5 +34,5 @@ CONSTANT: WM_DWMCOMPOSITIONCHANGED HEX: 31E : composition-enabled? ( -- ? ) windows-major 6 >= - [ 0 [ DwmIsCompositionEnabled drop ] keep *int c-bool> ] + [ { bool } [ DwmIsCompositionEnabled drop ] [ ] with-out-parameters ] [ f ] if ; diff --git a/basis/windows/offscreen/offscreen.factor b/basis/windows/offscreen/offscreen.factor index 4b4847f964..c2587698d0 100644 --- a/basis/windows/offscreen/offscreen.factor +++ b/basis/windows/offscreen/offscreen.factor @@ -26,8 +26,8 @@ IN: windows.offscreen : make-bitmap ( dim dc -- hBitmap bits ) [ nip ] [ - swap (bitmap-info) DIB_RGB_COLORS f - [ f 0 CreateDIBSection ] keep *void* + swap (bitmap-info) DIB_RGB_COLORS { void* } + [ f 0 CreateDIBSection ] [ ] with-out-parameters ] 2bi [ [ SelectObject drop ] keep ] dip ; diff --git a/basis/windows/uniscribe/uniscribe.factor b/basis/windows/uniscribe/uniscribe.factor old mode 100644 new mode 100755 index 2783840df0..92fec0a677 --- a/basis/windows/uniscribe/uniscribe.factor +++ b/basis/windows/uniscribe/uniscribe.factor @@ -2,10 +2,10 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel assocs math sequences fry io.encodings.string io.encodings.utf16n accessors arrays combinators destructors -cache namespaces init fonts alien.c-types windows.usp10 -windows.offscreen windows.gdi32 windows.ole32 windows.types -windows.fonts opengl.textures locals windows.errors -classes.struct ; +cache namespaces init fonts alien.c-types alien.data +windows.usp10 windows.offscreen windows.gdi32 windows.ole32 +windows.types windows.fonts opengl.textures locals +windows.errors classes.struct ; IN: windows.uniscribe TUPLE: script-string < disposable font string metrics ssa size image ; @@ -20,14 +20,12 @@ TUPLE: script-string < disposable font string metrics ssa size image ; swap ! icp FALSE ! fTrailing ] if - 0 [ ScriptStringCPtoX ole32-error ] keep *int ; + { int } [ ScriptStringCPtoX ole32-error ] [ ] with-out-parameters ; : x>line-offset ( x script-string -- n trailing ) ssa>> ! ssa swap ! iX - 0 ! pCh - 0 ! piTrailing - [ ScriptStringXtoCP ole32-error ] 2keep [ *int ] bi@ ; + { int int } [ ScriptStringXtoCP ole32-error ] [ ] with-out-parameters ;