From 026499e64fd6718418310dfdbff41e3350efb900 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 1 Apr 2010 14:43:27 -0500 Subject: [PATCH] Use flags{ instead of flags all over the place --- .../file-descriptors/file-descriptors.factor | 5 +-- basis/core-graphics/core-graphics.factor | 5 ++- .../unix/multiplexers/kqueue/kqueue.factor | 6 ++-- .../windows/nt/privileges/privileges.factor | 4 +-- basis/io/backend/windows/windows.factor | 8 ++--- basis/io/directories/unix/unix.factor | 5 ++- basis/io/files/unique/unix/unix.factor | 5 ++- basis/io/files/unix/unix-tests.factor | 6 ++-- basis/io/files/unix/unix.factor | 12 +++---- basis/io/files/windows/windows.factor | 9 ++--- basis/io/mmap/unix/unix.factor | 10 +++--- basis/io/mmap/windows/windows.factor | 8 ++--- basis/io/monitors/linux/linux.factor | 6 ++-- basis/io/monitors/windows/nt/nt.factor | 4 +-- basis/io/pipes/windows/nt/nt.factor | 4 +-- basis/literals/literals-docs.factor | 15 ++++++++- basis/literals/literals-tests.factor | 15 ++++++++- basis/literals/literals.factor | 7 ++-- basis/math/bitwise/bitwise-docs.factor | 13 -------- basis/math/bitwise/bitwise-tests.factor | 13 +------- basis/math/bitwise/bitwise.factor | 4 --- basis/openssl/libssl/libssl.factor | 9 +++-- basis/random/windows/windows.factor | 2 +- basis/ui/backend/windows/windows.factor | 7 ++-- basis/unix/linux/inotify/inotify.factor | 19 ++++++----- basis/unix/statfs/macosx/macosx.factor | 11 +++---- .../directx/d3d9types/d3d9types.factor | 33 ++++++++++--------- basis/windows/errors/errors.factor | 6 ++-- basis/windows/gdi32/gdi32.factor | 4 +-- basis/windows/user32/user32.factor | 17 +++++----- basis/windows/winsock/winsock.factor | 5 ++- basis/x11/windows/windows.factor | 10 +++--- basis/x11/xlib/xlib.factor | 7 ++-- extra/fullscreen/fullscreen.factor | 10 +++--- extra/io/serial/unix/bsd/bsd.factor | 5 +-- extra/io/serial/unix/unix-tests.factor | 11 ++++--- extra/io/serial/unix/unix.factor | 5 +-- extra/model-viewer/model-viewer.factor | 6 ++-- extra/webkit-demo/webkit-demo.factor | 8 ++--- 39 files changed, 168 insertions(+), 171 deletions(-) diff --git a/basis/core-foundation/file-descriptors/file-descriptors.factor b/basis/core-foundation/file-descriptors/file-descriptors.factor index ec5581d463..4ec362f0fc 100644 --- a/basis/core-foundation/file-descriptors/file-descriptors.factor +++ b/basis/core-foundation/file-descriptors/file-descriptors.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.syntax kernel math.bitwise core-foundation ; +USING: alien.c-types alien.syntax kernel math.bitwise core-foundation +literals ; IN: core-foundation.file-descriptors TYPEDEF: void* CFFileDescriptorRef @@ -25,7 +26,7 @@ FUNCTION: void CFFileDescriptorEnableCallBacks ( ) ; : enable-all-callbacks ( fd -- ) - { kCFFileDescriptorReadCallBack kCFFileDescriptorWriteCallBack } flags + flags{ kCFFileDescriptorReadCallBack kCFFileDescriptorWriteCallBack } CFFileDescriptorEnableCallBacks ; : ( fd callback -- handle ) diff --git a/basis/core-graphics/core-graphics.factor b/basis/core-graphics/core-graphics.factor index f3f759115c..82b8191621 100644 --- a/basis/core-graphics/core-graphics.factor +++ b/basis/core-graphics/core-graphics.factor @@ -3,7 +3,7 @@ USING: alien alien.c-types alien.destructors alien.syntax accessors destructors fry kernel math math.bitwise sequences libc colors images images.memory core-graphics.types core-foundation.utilities -opengl.gl ; +opengl.gl literals ; IN: core-graphics ! CGImageAlphaInfo @@ -121,8 +121,7 @@ FUNCTION: uint GetCurrentButtonState ( ) ; > close-file ; M: kqueue-mx add-input-callback ( thread fd mx -- ) [ call-next-method ] [ - [ EVFILT_READ { EV_ADD EV_ONESHOT } flags make-kevent ] dip + [ EVFILT_READ flags{ EV_ADD EV_ONESHOT } make-kevent ] dip register-kevent ] 2bi ; M: kqueue-mx add-output-callback ( thread fd mx -- ) [ call-next-method ] [ - [ EVFILT_WRITE { EV_ADD EV_ONESHOT } flags make-kevent ] dip + [ EVFILT_WRITE flags{ EV_ADD EV_ONESHOT } make-kevent ] dip register-kevent ] 2bi ; diff --git a/basis/io/backend/windows/nt/privileges/privileges.factor b/basis/io/backend/windows/nt/privileges/privileges.factor index 6022e91efd..53a67bbeab 100644 --- a/basis/io/backend/windows/nt/privileges/privileges.factor +++ b/basis/io/backend/windows/nt/privileges/privileges.factor @@ -2,7 +2,7 @@ USING: alien alien.c-types alien.data alien.syntax arrays continuations destructors generic io.mmap io.ports io.backend.windows io.files.windows kernel libc locals math math.bitwise namespaces quotations sequences windows windows.advapi32 windows.kernel32 windows.types io.backend system accessors -io.backend.windows.privileges classes.struct windows.errors ; +io.backend.windows.privileges classes.struct windows.errors literals ; IN: io.backend.windows.nt.privileges TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES @@ -11,7 +11,7 @@ TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES ! http://msdn.microsoft.com/msdnmag/issues/05/03/TokenPrivileges/ : (open-process-token) ( handle -- handle ) - { TOKEN_ADJUST_PRIVILEGES TOKEN_QUERY } flags PHANDLE + flags{ TOKEN_ADJUST_PRIVILEGES TOKEN_QUERY } PHANDLE [ OpenProcessToken win32-error=0/f ] keep *void* ; : open-process-token ( -- handle ) diff --git a/basis/io/backend/windows/windows.factor b/basis/io/backend/windows/windows.factor index 6ec2ec4dc5..0e0a803679 100644 --- a/basis/io/backend/windows/windows.factor +++ b/basis/io/backend/windows/windows.factor @@ -5,7 +5,7 @@ io.buffers io.files io.ports io.binary io.timeouts system strings kernel math namespaces sequences windows.errors windows.kernel32 windows.shell32 windows.types splitting continuations math.bitwise accessors init sets assocs -classes.struct classes ; +classes.struct classes literals ; IN: io.backend.windows TUPLE: win32-handle < disposable handle ; @@ -43,12 +43,12 @@ HOOK: add-completion io-backend ( port -- ) |dispose dup add-completion ; -: share-mode ( -- n ) - { +CONSTANT: share-mode + flags{ FILE_SHARE_READ FILE_SHARE_WRITE FILE_SHARE_DELETE - } flags ; foldable + } : default-security-attributes ( -- obj ) SECURITY_ATTRIBUTES diff --git a/basis/io/directories/unix/unix.factor b/basis/io/directories/unix/unix.factor index 77d7f2d1b2..0cc8aaa0e4 100644 --- a/basis/io/directories/unix/unix.factor +++ b/basis/io/directories/unix/unix.factor @@ -4,11 +4,10 @@ USING: accessors alien.c-types alien.strings combinators continuations destructors fry io io.backend io.backend.unix io.directories io.encodings.binary io.encodings.utf8 io.files io.pathnames io.files.types kernel math.bitwise sequences system -unix unix.stat vocabs.loader classes.struct unix.ffi ; +unix unix.stat vocabs.loader classes.struct unix.ffi literals ; IN: io.directories.unix -: touch-mode ( -- n ) - { O_WRONLY O_APPEND O_CREAT O_EXCL } flags ; foldable +CONSTANT: touch-mode flags{ O_WRONLY O_APPEND O_CREAT O_EXCL } M: unix touch-file ( path -- ) normalize-path diff --git a/basis/io/files/unique/unix/unix.factor b/basis/io/files/unique/unix/unix.factor index ec72d9128b..cd60e3d4b8 100644 --- a/basis/io/files/unique/unix/unix.factor +++ b/basis/io/files/unique/unix/unix.factor @@ -1,11 +1,10 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: kernel io.ports io.backend.unix math.bitwise -unix system io.files.unique unix.ffi ; +unix system io.files.unique unix.ffi literals ; IN: io.files.unique.unix -: open-unique-flags ( -- flags ) - { O_RDWR O_CREAT O_EXCL } flags ; +CONSTANT: open-unique-flags flags{ O_RDWR O_CREAT O_EXCL } M: unix (touch-unique-file) ( path -- ) open-unique-flags file-mode open-file close-file ; diff --git a/basis/io/files/unix/unix-tests.factor b/basis/io/files/unix/unix-tests.factor index 93e499a576..06f7473aed 100644 --- a/basis/io/files/unix/unix-tests.factor +++ b/basis/io/files/unix/unix-tests.factor @@ -2,7 +2,7 @@ USING: tools.test io.files io.files.temp io.pathnames io.directories io.files.info io.files.info.unix continuations kernel io.files.unix math.bitwise calendar accessors math.functions math unix.users unix.groups arrays sequences -grouping io.pathnames.private ; +grouping io.pathnames.private literals ; IN: io.files.unix.tests [ "/usr/libexec/" ] [ "/usr/libexec/awk/" parent-directory ] unit-test @@ -45,7 +45,7 @@ IN: io.files.unix.tests prepare-test-file [ t ] -[ test-file { USER-ALL GROUP-ALL OTHER-ALL } flags set-file-permissions perms OCT: 777 = ] unit-test +[ test-file flags{ USER-ALL GROUP-ALL OTHER-ALL } set-file-permissions perms OCT: 777 = ] unit-test [ t ] [ test-file user-read? ] unit-test [ t ] [ test-file user-write? ] unit-test @@ -85,7 +85,7 @@ prepare-test-file [ f ] [ test-file file-info other-read? ] unit-test [ t ] -[ test-file { USER-ALL GROUP-ALL OTHER-EXECUTE } flags set-file-permissions perms OCT: 771 = ] unit-test +[ test-file flags{ USER-ALL GROUP-ALL OTHER-EXECUTE } set-file-permissions perms OCT: 771 = ] unit-test prepare-test-file diff --git a/basis/io/files/unix/unix.factor b/basis/io/files/unix/unix.factor index bf0a21f997..e695345125 100644 --- a/basis/io/files/unix/unix.factor +++ b/basis/io/files/unix/unix.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: unix byte-arrays kernel io.backend.unix math.bitwise io.ports io.files io.files.private io.pathnames environment -destructors system unix.ffi ; +destructors system unix.ffi literals ; IN: io.files.unix M: unix cwd ( -- path ) @@ -12,15 +12,14 @@ M: unix cwd ( -- path ) M: unix cd ( path -- ) [ chdir ] unix-system-call drop ; -: read-flags ( -- n ) O_RDONLY ; inline +CONSTANT: read-flags flags{ O_RDONLY } -: open-read ( path -- fd ) O_RDONLY file-mode open-file ; +: open-read ( path -- fd ) read-flags file-mode open-file ; M: unix (file-reader) ( path -- stream ) open-read init-fd ; -: write-flags ( -- n ) - { O_WRONLY O_CREAT O_TRUNC } flags ; inline +CONSTANT: write-flags flags{ O_WRONLY O_CREAT O_TRUNC } : open-write ( path -- fd ) write-flags file-mode open-file ; @@ -28,8 +27,7 @@ M: unix (file-reader) ( path -- stream ) M: unix (file-writer) ( path -- stream ) open-write init-fd ; -: append-flags ( -- n ) - { O_WRONLY O_APPEND O_CREAT } flags ; inline +CONSTANT: append-flags flags{ O_WRONLY O_APPEND O_CREAT } : open-append ( path -- fd ) [ diff --git a/basis/io/files/windows/windows.factor b/basis/io/files/windows/windows.factor index c4c848cb64..4fc2057a74 100644 --- a/basis/io/files/windows/windows.factor +++ b/basis/io/files/windows/windows.factor @@ -6,7 +6,8 @@ io.backend.windows kernel math splitting fry alien.strings windows windows.kernel32 windows.time windows.types calendar combinators math.functions sequences namespaces make words system destructors accessors math.bitwise continuations -windows.errors arrays byte-arrays generalizations alien.data ; +windows.errors arrays byte-arrays generalizations alien.data +literals ; IN: io.files.windows : open-file ( path access-mode create-mode flags -- handle ) @@ -16,7 +17,7 @@ IN: io.files.windows ] with-destructors ; : open-r/w ( path -- win32-file ) - { GENERIC_READ GENERIC_WRITE } flags + flags{ GENERIC_READ GENERIC_WRITE } OPEN_EXISTING 0 open-file ; : open-read ( path -- win32-file ) @@ -29,7 +30,7 @@ IN: io.files.windows GENERIC_WRITE OPEN_ALWAYS 0 open-file ; : open-existing ( path -- win32-file ) - { GENERIC_READ GENERIC_WRITE } flags + flags{ GENERIC_READ GENERIC_WRITE } share-mode f OPEN_EXISTING @@ -38,7 +39,7 @@ IN: io.files.windows : maybe-create-file ( path -- win32-file ? ) #! return true if file was just created - { GENERIC_READ GENERIC_WRITE } flags + flags{ GENERIC_READ GENERIC_WRITE } share-mode f OPEN_ALWAYS diff --git a/basis/io/mmap/unix/unix.factor b/basis/io/mmap/unix/unix.factor index f426201b06..84378efeb8 100644 --- a/basis/io/mmap/unix/unix.factor +++ b/basis/io/mmap/unix/unix.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors destructors io.backend.unix io.mmap +USING: accessors destructors io.backend.unix io.mmap literals io.mmap.private kernel locals math.bitwise system unix unix.ffi ; IN: io.mmap.unix @@ -12,13 +12,13 @@ IN: io.mmap.unix ] with-destructors ; M: unix (mapped-file-r/w) - { PROT_READ PROT_WRITE } flags - { MAP_FILE MAP_SHARED } flags + flags{ PROT_READ PROT_WRITE } + flags{ MAP_FILE MAP_SHARED } O_RDWR mmap-open ; M: unix (mapped-file-reader) - { PROT_READ } flags - { MAP_FILE MAP_SHARED } flags + flags{ PROT_READ } + flags{ MAP_FILE MAP_SHARED } O_RDONLY mmap-open ; M: unix close-mapped-file ( mmap -- ) diff --git a/basis/io/mmap/windows/windows.factor b/basis/io/mmap/windows/windows.factor index e3e3116b59..b1191082b3 100644 --- a/basis/io/mmap/windows/windows.factor +++ b/basis/io/mmap/windows/windows.factor @@ -2,7 +2,7 @@ USING: alien alien.c-types arrays destructors generic io.mmap io.ports io.backend.windows io.files.windows io.backend.windows.privileges io.mmap.private kernel libc math math.bitwise namespaces quotations sequences windows windows.advapi32 windows.kernel32 io.backend system -accessors locals windows.errors ; +accessors locals windows.errors literals ; IN: io.mmap.windows : create-file-mapping ( hFile lpAttributes flProtect dwMaximumSizeHigh dwMaximumSizeLow lpName -- HANDLE ) @@ -29,9 +29,9 @@ C: win32-mapped-file M: windows (mapped-file-r/w) [ - { GENERIC_WRITE GENERIC_READ } flags + flags{ GENERIC_WRITE GENERIC_READ } OPEN_ALWAYS - { PAGE_READWRITE SEC_COMMIT } flags + flags{ PAGE_READWRITE SEC_COMMIT } FILE_MAP_ALL_ACCESS mmap-open -rot ] with-destructors ; @@ -40,7 +40,7 @@ M: windows (mapped-file-reader) [ GENERIC_READ OPEN_ALWAYS - { PAGE_READONLY SEC_COMMIT } flags + flags{ PAGE_READONLY SEC_COMMIT } FILE_MAP_READ mmap-open -rot ] with-destructors ; diff --git a/basis/io/monitors/linux/linux.factor b/basis/io/monitors/linux/linux.factor index 31442b7f0b..9b2440aec8 100644 --- a/basis/io/monitors/linux/linux.factor +++ b/basis/io/monitors/linux/linux.factor @@ -5,7 +5,7 @@ io.files io.pathnames io.buffers io.ports io.timeouts io.backend.unix io.encodings.utf8 unix.linux.inotify assocs namespaces make threads continuations init math math.bitwise sets alien alien.strings alien.c-types vocabs.loader accessors -system hashtables destructors unix classes.struct ; +system hashtables destructors unix classes.struct literals ; FROM: namespaces => set ; IN: io.monitors.linux @@ -65,13 +65,13 @@ M: linux-monitor dispose* ( monitor -- ) tri ; : ignore-flags? ( mask -- ? ) - { + flags{ IN_DELETE_SELF IN_MOVE_SELF IN_UNMOUNT IN_Q_OVERFLOW IN_IGNORED - } flags bitand 0 > ; + } bitand 0 > ; : parse-action ( mask -- changed ) [ diff --git a/basis/io/monitors/windows/nt/nt.factor b/basis/io/monitors/windows/nt/nt.factor index 4d061cbb1a..e6a055a9d6 100644 --- a/basis/io/monitors/windows/nt/nt.factor +++ b/basis/io/monitors/windows/nt/nt.factor @@ -5,7 +5,7 @@ locals kernel math assocs namespaces make continuations sequences hashtables sorting arrays combinators math.bitwise strings system accessors threads splitting io.backend io.backend.windows io.backend.windows.nt io.files.windows.nt io.monitors io.ports -io.buffers io.files io.timeouts io.encodings.string +io.buffers io.files io.timeouts io.encodings.string literals io.encodings.utf16n io windows.errors windows.kernel32 windows.types io.pathnames classes.struct ; IN: io.monitors.windows.nt @@ -16,7 +16,7 @@ IN: io.monitors.windows.nt share-mode f OPEN_EXISTING - { FILE_FLAG_BACKUP_SEMANTICS FILE_FLAG_OVERLAPPED } flags + flags{ FILE_FLAG_BACKUP_SEMANTICS FILE_FLAG_OVERLAPPED } f CreateFile opened-file ; diff --git a/basis/io/pipes/windows/nt/nt.factor b/basis/io/pipes/windows/nt/nt.factor index 7fce8b4de2..f87a98ab91 100644 --- a/basis/io/pipes/windows/nt/nt.factor +++ b/basis/io/pipes/windows/nt/nt.factor @@ -10,7 +10,7 @@ IN: io.pipes.windows.nt ! http://twistedmatrix.com/trac/browser/trunk/twisted/internet/iocpreactor/process.py : create-named-pipe ( name -- handle ) - { PIPE_ACCESS_INBOUND FILE_FLAG_OVERLAPPED } flags + flags{ PIPE_ACCESS_INBOUND FILE_FLAG_OVERLAPPED } PIPE_TYPE_BYTE 1 4096 @@ -21,7 +21,7 @@ IN: io.pipes.windows.nt : open-other-end ( name -- handle ) GENERIC_WRITE - { FILE_SHARE_READ FILE_SHARE_WRITE } flags + flags{ FILE_SHARE_READ FILE_SHARE_WRITE } default-security-attributes OPEN_EXISTING FILE_FLAG_OVERLAPPED diff --git a/basis/literals/literals-docs.factor b/basis/literals/literals-docs.factor index a464d75b22..6fcf8a5e07 100644 --- a/basis/literals/literals-docs.factor +++ b/basis/literals/literals-docs.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Joe Groff. ! See http://factorcode.org/license.txt for BSD license. -USING: help.markup help.syntax kernel multiline ; +USING: help.markup help.syntax kernel multiline sequences ; IN: literals HELP: $ @@ -62,6 +62,19 @@ ${ five six 7 } . { POSTPONE: $ POSTPONE: $[ POSTPONE: ${ } related-words +HELP: flags{ +{ $values { "values" sequence } } +{ $description "Constructs a constant flag value from a sequence of integers or words that output integers. The resulting constant is computed at parse-time, which makes this word as efficient as using a literal integer." } +{ $examples + { $example "USING: literals kernel prettyprint ;" + "IN: scratchpad" + "CONSTANT: x HEX: 1" + "flags{ HEX: 20 x BIN: 100 } .h" + "25" + } +} ; + + ARTICLE: "literals" "Interpolating code results into literal values" "The " { $vocab-link "literals" } " vocabulary contains words to run code at parse time and insert the results into more complex literal values." { $example """ diff --git a/basis/literals/literals-tests.factor b/basis/literals/literals-tests.factor index d7256a64b1..4357198db6 100644 --- a/basis/literals/literals-tests.factor +++ b/basis/literals/literals-tests.factor @@ -1,4 +1,4 @@ -USING: kernel literals math tools.test ; +USING: accessors kernel literals math tools.test ; IN: literals.tests << @@ -27,3 +27,16 @@ CONSTANT: constant-a 3 : sixty-nine ( -- a b ) 6 9 ; [ { 6 9 } ] [ ${ sixty-nine } ] unit-test + +CONSTANT: a 1 +CONSTANT: b 2 +ALIAS: c b +ALIAS: d c + +CONSTANT: foo flags{ a b d } + +[ 3 ] [ foo ] unit-test +[ 3 ] [ flags{ a b d } ] unit-test +\ foo def>> must-infer + +[ 1 ] [ flags{ 1 } ] unit-test diff --git a/basis/literals/literals.factor b/basis/literals/literals.factor index 3e541a80ce..42a7ab9668 100644 --- a/basis/literals/literals.factor +++ b/basis/literals/literals.factor @@ -25,6 +25,7 @@ SYNTAX: $ scan-word expand-literal >vector ; SYNTAX: $[ parse-quotation with-datastack >vector ; SYNTAX: ${ \ } [ expand-literals ] parse-literal ; SYNTAX: flags{ - "}" [ parse-word ] map-tokens - expand-literals - 0 [ bitor ] reduce suffix! ; + \ } [ + expand-literals + 0 [ bitor ] reduce + ] parse-literal ; diff --git a/basis/math/bitwise/bitwise-docs.factor b/basis/math/bitwise/bitwise-docs.factor index ee94479b46..4024953070 100644 --- a/basis/math/bitwise/bitwise-docs.factor +++ b/basis/math/bitwise/bitwise-docs.factor @@ -135,18 +135,6 @@ HELP: clear-bit } } ; -HELP: flags -{ $values { "values" sequence } } -{ $description "Constructs a constant flag value from a sequence of integers or words that output integers. The resulting constant is computed at compile-time, which makes this word as efficient as using a literal integer." } -{ $examples - { $example "USING: math.bitwise kernel prettyprint ;" - "IN: scratchpad" - "CONSTANT: x HEX: 1" - "{ HEX: 20 x BIN: 100 } flags .h" - "25" - } -} ; - HELP: symbols>flags { $values { "symbols" sequence } { "assoc" assoc } { "flag-bits" integer } } { $description "Constructs an integer value by mapping the values in the " { $snippet "symbols" } " sequence to integer values using " { $snippet "assoc" } " and " { $link bitor } "ing the values together." } @@ -408,7 +396,6 @@ $nl } "Bitfields:" { $subsections - flags "math-bitfields" } ; diff --git a/basis/math/bitwise/bitwise-tests.factor b/basis/math/bitwise/bitwise-tests.factor index a5919d3ec3..93d2d9e882 100644 --- a/basis/math/bitwise/bitwise-tests.factor +++ b/basis/math/bitwise/bitwise-tests.factor @@ -1,6 +1,6 @@ USING: accessors math math.bitwise tools.test kernel words specialized-arrays alien.c-types math.vectors.simd -sequences destructors libc ; +sequences destructors libc literals ; SPECIALIZED-ARRAY: int IN: math.bitwise.tests @@ -23,17 +23,6 @@ IN: math.bitwise.tests : test-1+ ( x -- y ) 1 + ; [ 512 ] [ 1 { { test-1+ 8 } } bitfield ] unit-test -CONSTANT: a 1 -CONSTANT: b 2 - -: foo ( -- flags ) { a b } flags ; - -[ 3 ] [ foo ] unit-test -[ 3 ] [ { a b } flags ] unit-test -\ foo def>> must-infer - -[ 1 ] [ { 1 } flags ] unit-test - [ 8 ] [ 0 3 toggle-bit ] unit-test [ 0 ] [ 8 3 toggle-bit ] unit-test diff --git a/basis/math/bitwise/bitwise.factor b/basis/math/bitwise/bitwise.factor index 15db425137..cd38c8513c 100644 --- a/basis/math/bitwise/bitwise.factor +++ b/basis/math/bitwise/bitwise.factor @@ -44,10 +44,6 @@ IN: math.bitwise : W- ( x y -- z ) - 64 bits ; inline : W* ( x y -- z ) * 64 bits ; inline -! flags -MACRO: flags ( values -- ) - [ 0 ] [ [ ?execute bitor ] curry compose ] reduce ; - : symbols>flags ( symbols assoc -- flag-bits ) [ at ] curry map 0 [ bitor ] reduce ; diff --git a/basis/openssl/libssl/libssl.factor b/basis/openssl/libssl/libssl.factor index bfd59cde25..96d235d271 100644 --- a/basis/openssl/libssl/libssl.factor +++ b/basis/openssl/libssl/libssl.factor @@ -3,7 +3,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.syntax combinators kernel system namespaces assocs parser lexer sequences words -quotations math.bitwise alien.libraries ; +quotations math.bitwise alien.libraries literals ; IN: openssl.libssl @@ -258,15 +258,14 @@ CONSTANT: SSL_SESS_CACHE_OFF HEX: 0000 CONSTANT: SSL_SESS_CACHE_CLIENT HEX: 0001 CONSTANT: SSL_SESS_CACHE_SERVER HEX: 0002 -: SSL_SESS_CACHE_BOTH ( -- n ) - { SSL_SESS_CACHE_CLIENT SSL_SESS_CACHE_SERVER } flags ; inline +CONSTANT: SSL_SESS_CACHE_BOTH flags{ SSL_SESS_CACHE_CLIENT SSL_SESS_CACHE_SERVER } CONSTANT: SSL_SESS_CACHE_NO_AUTO_CLEAR HEX: 0080 CONSTANT: SSL_SESS_CACHE_NO_INTERNAL_LOOKUP HEX: 0100 CONSTANT: SSL_SESS_CACHE_NO_INTERNAL_STORE HEX: 0200 -: SSL_SESS_CACHE_NO_INTERNAL ( -- n ) - { SSL_SESS_CACHE_NO_INTERNAL_LOOKUP SSL_SESS_CACHE_NO_INTERNAL_STORE } flags ; inline +CONSTANT: SSL_SESS_CACHE_NO_INTERNAL + flags{ SSL_SESS_CACHE_NO_INTERNAL_LOOKUP SSL_SESS_CACHE_NO_INTERNAL_STORE } ! =============================================== ! x509_vfy.h diff --git a/basis/random/windows/windows.factor b/basis/random/windows/windows.factor index 30b169bfed..72b908a32f 100644 --- a/basis/random/windows/windows.factor +++ b/basis/random/windows/windows.factor @@ -36,7 +36,7 @@ CONSTANT: factor-crypto-container "FactorCryptoContainer" ] if ; : create-crypto-context ( provider type -- handle ) - { CRYPT_MACHINE_KEYSET CRYPT_NEWKEYSET } flags + flags{ CRYPT_MACHINE_KEYSET CRYPT_NEWKEYSET } (acquire-crypto-context) win32-error=0/f *void* ; ERROR: acquire-crypto-context-failed provider type ; diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index 8a4ae9853f..c0829e5c8d 100644 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -628,7 +628,7 @@ M: windows-ui-backend do-events WNDCLASSEX f GetModuleHandle class-name-ptr pick GetClassInfoEx 0 = [ WNDCLASSEX heap-size >>cbSize - { CS_HREDRAW CS_VREDRAW CS_OWNDC } flags >>style + flags{ CS_HREDRAW CS_VREDRAW CS_OWNDC } >>style ui-wndproc >>lpfnWndProc 0 >>cbClsExtra 0 >>cbWndExtra @@ -811,8 +811,7 @@ M: windows-ui-backend (ungrab-input) ( handle -- ) f ClipCursor drop 1 ShowCursor drop ; -: fullscreen-flags ( -- n ) - { WS_CAPTION WS_BORDER WS_THICKFRAME } flags ; inline +CONSTANT: fullscreen-flags { WS_CAPTION WS_BORDER WS_THICKFRAME } : enter-fullscreen ( world -- ) handle>> hWnd>> @@ -838,7 +837,7 @@ M: windows-ui-backend (ungrab-input) ( handle -- ) [ f over hwnd>RECT get-RECT-dimensions - { SWP_NOMOVE SWP_NOSIZE SWP_NOZORDER SWP_FRAMECHANGED } flags + flags{ SWP_NOMOVE SWP_NOSIZE SWP_NOZORDER SWP_FRAMECHANGED } SetWindowPos win32-error=0/f ] [ SW_RESTORE ShowWindow win32-error=0/f ] diff --git a/basis/unix/linux/inotify/inotify.factor b/basis/unix/linux/inotify/inotify.factor index c296cc8166..947191e7dd 100644 --- a/basis/unix/linux/inotify/inotify.factor +++ b/basis/unix/linux/inotify/inotify.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.syntax math math.bitwise classes.struct ; +USING: alien.c-types alien.syntax math math.bitwise classes.struct +literals ; IN: unix.linux.inotify STRUCT: inotify-event @@ -27,8 +28,8 @@ CONSTANT: IN_UNMOUNT HEX: 2000 ! Backing fs was unmounted CONSTANT: IN_Q_OVERFLOW HEX: 4000 ! Event queued overflowed CONSTANT: IN_IGNORED HEX: 8000 ! File was ignored -: IN_CLOSE ( -- n ) { IN_CLOSE_WRITE IN_CLOSE_NOWRITE } flags ; foldable ! close -: IN_MOVE ( -- n ) { IN_MOVED_FROM IN_MOVED_TO } flags ; foldable ! moves +CONSTANT: IN_CLOSE flags{ IN_CLOSE_WRITE IN_CLOSE_NOWRITE } +CONSTANT: IN_MOVE flags{ IN_MOVED_FROM IN_MOVED_TO } CONSTANT: IN_ONLYDIR HEX: 1000000 ! only watch the path if it is a directory CONSTANT: IN_DONT_FOLLOW HEX: 2000000 ! don't follow a sym link @@ -36,20 +37,20 @@ CONSTANT: IN_MASK_ADD HEX: 20000000 ! add to the mask of an already existing w CONSTANT: IN_ISDIR HEX: 40000000 ! event occurred against dir CONSTANT: IN_ONESHOT HEX: 80000000 ! only send event once -: IN_CHANGE_EVENTS ( -- n ) - { +CONSTANT: IN_CHANGE_EVENTS + flags{ IN_MODIFY IN_ATTRIB IN_MOVED_FROM IN_MOVED_TO IN_DELETE IN_CREATE IN_DELETE_SELF IN_MOVE_SELF - } flags ; foldable + } -: IN_ALL_EVENTS ( -- n ) - { +CONSTANT: IN_ALL_EVENTS + flags{ IN_ACCESS IN_MODIFY IN_ATTRIB IN_CLOSE_WRITE IN_CLOSE_NOWRITE IN_OPEN IN_MOVED_FROM IN_MOVED_TO IN_DELETE IN_CREATE IN_DELETE_SELF IN_MOVE_SELF - } flags ; foldable + } FUNCTION: int inotify_init ( ) ; FUNCTION: int inotify_add_watch ( int fd, c-string name, uint mask ) ; diff --git a/basis/unix/statfs/macosx/macosx.factor b/basis/unix/statfs/macosx/macosx.factor index 75b231da96..b5ae2c2223 100644 --- a/basis/unix/statfs/macosx/macosx.factor +++ b/basis/unix/statfs/macosx/macosx.factor @@ -3,7 +3,7 @@ USING: alien.c-types io.encodings.utf8 io.encodings.string kernel sequences unix.stat accessors unix combinators math grouping system alien.strings math.bitwise alien.syntax -unix.types classes.struct unix.ffi ; +unix.types classes.struct unix.ffi literals ; IN: unix.statfs.macosx CONSTANT: MNT_RDONLY HEX: 00000001 @@ -29,8 +29,8 @@ CONSTANT: MNT_MULTILABEL HEX: 04000000 CONSTANT: MNT_NOATIME HEX: 10000000 ALIAS: MNT_UNKNOWNPERMISSIONS MNT_IGNORE_OWNERSHIP -: MNT_VISFLAGMASK ( -- n ) - { +CONSTANT: MNT_VISFLAGMASK + flags{ MNT_RDONLY MNT_SYNCHRONOUS MNT_NOEXEC MNT_NOSUID MNT_NODEV MNT_UNION MNT_ASYNC MNT_EXPORTED MNT_QUARANTINE @@ -38,14 +38,13 @@ ALIAS: MNT_UNKNOWNPERMISSIONS MNT_IGNORE_OWNERSHIP MNT_ROOTFS MNT_DOVOLFS MNT_DONTBROWSE MNT_IGNORE_OWNERSHIP MNT_AUTOMOUNTED MNT_JOURNALED MNT_NOUSERXATTR MNT_DEFWRITE MNT_MULTILABEL MNT_NOATIME - } flags ; inline + } CONSTANT: MNT_UPDATE HEX: 00010000 CONSTANT: MNT_RELOAD HEX: 00040000 CONSTANT: MNT_FORCE HEX: 00080000 -: MNT_CMDFLAGS ( -- n ) - { MNT_UPDATE MNT_RELOAD MNT_FORCE } flags ; inline +CONSTANT: MNT_CMDFLAGS flags{ MNT_UPDATE MNT_RELOAD MNT_FORCE } CONSTANT: VFS_GENERIC 0 CONSTANT: VFS_NUMMNTOPS 1 diff --git a/basis/windows/directx/d3d9types/d3d9types.factor b/basis/windows/directx/d3d9types/d3d9types.factor index dc02849553..618d3c79e5 100644 --- a/basis/windows/directx/d3d9types/d3d9types.factor +++ b/basis/windows/directx/d3d9types/d3d9types.factor @@ -1,5 +1,5 @@ USING: alien.syntax windows.types classes.struct math alien.c-types -math.bitwise kernel locals windows.kernel32 ; +math.bitwise kernel locals windows.kernel32 literals ; IN: windows.directx.d3d9types TYPEDEF: DWORD D3DCOLOR @@ -54,19 +54,21 @@ CONSTANT: D3DCS_PLANE3 HEX: 00000200 CONSTANT: D3DCS_PLANE4 HEX: 00000400 CONSTANT: D3DCS_PLANE5 HEX: 00000800 -: D3DCS_ALL ( -- n ) - { D3DCS_LEFT - D3DCS_RIGHT - D3DCS_TOP - D3DCS_BOTTOM - D3DCS_FRONT - D3DCS_BACK - D3DCS_PLANE0 - D3DCS_PLANE1 - D3DCS_PLANE2 - D3DCS_PLANE3 - D3DCS_PLANE4 - D3DCS_PLANE5 } flags ; inline +CONSTANT: D3DCS_ALL + flags{ + D3DCS_LEFT + D3DCS_RIGHT + D3DCS_TOP + D3DCS_BOTTOM + D3DCS_FRONT + D3DCS_BACK + D3DCS_PLANE0 + D3DCS_PLANE1 + D3DCS_PLANE2 + D3DCS_PLANE3 + D3DCS_PLANE4 + D3DCS_PLANE5 + } STRUCT: D3DCLIPSTATUS9 { ClipUnion DWORD } @@ -777,8 +779,7 @@ CONSTANT: D3DVS_SWIZZLE_MASK HEX: 00FF0000 : D3DVS_W_Z ( -- n ) 2 D3DVS_SWIZZLE_SHIFT 6 + shift ; inline : D3DVS_W_W ( -- n ) 3 D3DVS_SWIZZLE_SHIFT 6 + shift ; inline -: D3DVS_NOSWIZZLE ( -- n ) - { D3DVS_X_X D3DVS_Y_Y D3DVS_Z_Z D3DVS_W_W } flags ; inline +CONSTANT: D3DVS_NOSWIZZLE flags{ D3DVS_X_X D3DVS_Y_Y D3DVS_Z_Z D3DVS_W_W } CONSTANT: D3DSP_SWIZZLE_SHIFT 16 CONSTANT: D3DSP_SWIZZLE_MASK HEX: 00FF0000 diff --git a/basis/windows/errors/errors.factor b/basis/windows/errors/errors.factor index 67757d05d2..a22b6ec007 100755 --- a/basis/windows/errors/errors.factor +++ b/basis/windows/errors/errors.factor @@ -1,7 +1,7 @@ USING: alien.data kernel locals math math.bitwise windows.kernel32 sequences byte-arrays unicode.categories io.encodings.string io.encodings.utf16n alien.strings -arrays literals windows.types specialized-arrays ; +arrays literals windows.types specialized-arrays literals ; SPECIALIZED-ARRAY: TCHAR IN: windows.errors @@ -705,10 +705,10 @@ CONSTANT: FORMAT_MESSAGE_MAX_WIDTH_MASK HEX: 000000FF ERROR: error-message-failed id ; :: n>win32-error-string ( id -- string ) - { + flags{ FORMAT_MESSAGE_FROM_SYSTEM FORMAT_MESSAGE_ARGUMENT_ARRAY - } flags + } f id LANG_NEUTRAL SUBLANG_DEFAULT make-lang-id diff --git a/basis/windows/gdi32/gdi32.factor b/basis/windows/gdi32/gdi32.factor index 43307cb6ba..93784ea370 100644 --- a/basis/windows/gdi32/gdi32.factor +++ b/basis/windows/gdi32/gdi32.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005, 2006 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.syntax alien.destructors -kernel windows.types math.bitwise ; +kernel windows.types math.bitwise literals ; IN: windows.gdi32 CONSTANT: BI_RGB 0 @@ -818,7 +818,7 @@ CONSTANT: TA_RIGHT 2 CONSTANT: TA_RTLREADING 256 CONSTANT: TA_NOUPDATECP 0 CONSTANT: TA_UPDATECP 1 -: TA_MASK ( -- n ) { TA_BASELINE TA_CENTER TA_UPDATECP TA_RTLREADING } flags ; foldable +CONSTANT: TA_MASK flags{ TA_BASELINE TA_CENTER TA_UPDATECP TA_RTLREADING } CONSTANT: VTA_BASELINE 24 CONSTANT: VTA_CENTER 6 ALIAS: VTA_LEFT TA_BOTTOM diff --git a/basis/windows/user32/user32.factor b/basis/windows/user32/user32.factor index 1c23c36071..54d31bb12b 100644 --- a/basis/windows/user32/user32.factor +++ b/basis/windows/user32/user32.factor @@ -33,18 +33,17 @@ CONSTANT: WS_MINIMIZEBOX HEX: 00020000 CONSTANT: WS_MAXIMIZEBOX HEX: 00010000 ! Common window styles -: WS_OVERLAPPEDWINDOW ( -- n ) - { +CONSTANT: WS_OVERLAPPEDWINDOW + flags{ WS_OVERLAPPED WS_CAPTION WS_SYSMENU WS_THICKFRAME WS_MINIMIZEBOX WS_MAXIMIZEBOX - } flags ; foldable + } -: WS_POPUPWINDOW ( -- n ) - { WS_POPUP WS_BORDER WS_SYSMENU } flags ; foldable +CONSTANT: WS_POPUPWINDOW flags{ WS_POPUP WS_BORDER WS_SYSMENU } ALIAS: WS_CHILDWINDOW WS_CHILD @@ -76,11 +75,11 @@ CONSTANT: WS_EX_CONTROLPARENT HEX: 00010000 CONSTANT: WS_EX_STATICEDGE HEX: 00020000 CONSTANT: WS_EX_APPWINDOW HEX: 00040000 -: WS_EX_OVERLAPPEDWINDOW ( -- n ) - WS_EX_WINDOWEDGE WS_EX_CLIENTEDGE bitor ; foldable +CONSTANT: WS_EX_OVERLAPPEDWINDOW + flags{ WS_EX_WINDOWEDGE WS_EX_CLIENTEDGE } -: WS_EX_PALETTEWINDOW ( -- n ) - { WS_EX_WINDOWEDGE WS_EX_TOOLWINDOW WS_EX_TOPMOST } flags ; foldable +CONSTANT: WS_EX_PALETTEWINDOW + flags{ WS_EX_WINDOWEDGE WS_EX_TOOLWINDOW WS_EX_TOPMOST } CONSTANT: CS_VREDRAW HEX: 0001 CONSTANT: CS_HREDRAW HEX: 0002 diff --git a/basis/windows/winsock/winsock.factor b/basis/windows/winsock/winsock.factor index b58cbcacbd..49a3d6e9fa 100644 --- a/basis/windows/winsock/winsock.factor +++ b/basis/windows/winsock/winsock.factor @@ -3,7 +3,7 @@ USING: alien alien.c-types alien.strings alien.syntax arrays byte-arrays kernel literals math sequences windows.types windows.kernel32 windows.errors math.bitwise io.encodings.utf16n -classes.struct windows.com.syntax init ; +classes.struct windows.com.syntax init literals ; FROM: alien.c-types => short ; IN: windows.winsock @@ -73,8 +73,7 @@ CONSTANT: AI_PASSIVE 1 CONSTANT: AI_CANONNAME 2 CONSTANT: AI_NUMERICHOST 4 -: AI_MASK ( -- n ) - { AI_PASSIVE AI_CANONNAME AI_NUMERICHOST } flags ; inline +CONSTANT: AI_MASK flags{ AI_PASSIVE AI_CANONNAME AI_NUMERICHOST } CONSTANT: NI_NUMERICHOST 1 CONSTANT: NI_NUMERICSERV 2 diff --git a/basis/x11/windows/windows.factor b/basis/x11/windows/windows.factor index ad0a8b11a6..7b7ae8b106 100644 --- a/basis/x11/windows/windows.factor +++ b/basis/x11/windows/windows.factor @@ -5,15 +5,15 @@ namespaces sequences x11 x11.xlib x11.constants x11.glx arrays fry classes.struct ; IN: x11.windows -: create-window-mask ( -- n ) - { CWBackPixel CWBorderPixel CWColormap CWEventMask } flags ; +CONSTANT: create-window-mask + flags{ CWBackPixel CWBorderPixel CWColormap CWEventMask } : create-colormap ( visinfo -- colormap ) [ dpy get root get ] dip visual>> AllocNone XCreateColormap ; -: event-mask ( -- n ) - { +CONSTANT: event-mask + flags{ ExposureMask StructureNotifyMask KeyPressMask @@ -25,7 +25,7 @@ IN: x11.windows EnterWindowMask LeaveWindowMask PropertyChangeMask - } flags ; + } : window-attributes ( visinfo -- attributes ) XSetWindowAttributes diff --git a/basis/x11/xlib/xlib.factor b/basis/x11/xlib/xlib.factor index 1c5ff2e3ef..ac9e5591dc 100644 --- a/basis/x11/xlib/xlib.factor +++ b/basis/x11/xlib/xlib.factor @@ -12,7 +12,8 @@ ! and note the section. USING: accessors kernel arrays alien alien.c-types alien.data alien.strings alien.syntax classes.struct math math.bitwise words -sequences namespaces continuations io io.encodings.ascii x11.syntax ; +sequences namespaces continuations io io.encodings.ascii x11.syntax +literals ; FROM: alien.c-types => short ; IN: x11.xlib @@ -1134,8 +1135,8 @@ X-FUNCTION: Status XWithdrawWindow ( : PAspect ( -- n ) 7 2^ ; inline : PBaseSize ( -- n ) 8 2^ ; inline : PWinGravity ( -- n ) 9 2^ ; inline -: PAllHints ( -- n ) - { PPosition PSize PMinSize PMaxSize PResizeInc PAspect } flags ; foldable +CONSTANT: PAllHints + flags{ PPosition PSize PMinSize PMaxSize PResizeInc PAspect } STRUCT: XSizeHints { flags long } diff --git a/extra/fullscreen/fullscreen.factor b/extra/fullscreen/fullscreen.factor index a233d6f4f5..458ef3d51e 100755 --- a/extra/fullscreen/fullscreen.factor +++ b/extra/fullscreen/fullscreen.factor @@ -16,7 +16,7 @@ IN: fullscreen :: (monitor-info>devmodes) ( monitor-info n -- ) DEVMODE DEVMODE heap-size >>dmSize - { DM_BITSPERPEL DM_PELSWIDTH DM_PELSHEIGHT } flags >>dmFields + flags{ DM_BITSPERPEL DM_PELSWIDTH DM_PELSHEIGHT } >>dmFields :> devmode monitor-info szDevice>> @@ -73,11 +73,11 @@ ERROR: display-change-error n ; : set-fullscreen-styles ( hwnd -- ) [ GWL_STYLE [ WS_OVERLAPPEDWINDOW unmask ] change-style ] - [ GWL_EXSTYLE [ { WS_EX_APPWINDOW WS_EX_TOPMOST } flags bitor ] change-style ] bi ; + [ GWL_EXSTYLE [ flags{ WS_EX_APPWINDOW WS_EX_TOPMOST } bitor ] change-style ] bi ; : set-non-fullscreen-styles ( hwnd -- ) [ GWL_STYLE [ WS_OVERLAPPEDWINDOW bitor ] change-style ] - [ GWL_EXSTYLE [ { WS_EX_APPWINDOW WS_EX_TOPMOST } flags unmask ] change-style ] bi ; + [ GWL_EXSTYLE [ flags{ WS_EX_APPWINDOW WS_EX_TOPMOST } unmask ] change-style ] bi ; ERROR: unsupported-resolution triple ; @@ -92,10 +92,10 @@ ERROR: unsupported-resolution triple ; hwnd f desktop-monitor-info rcMonitor>> slots{ left top } first2 triple first2 - { + flags{ SWP_NOACTIVATE SWP_NOCOPYBITS SWP_NOOWNERZORDER SWP_NOREPOSITION SWP_NOZORDER - } flags + } SetWindowPos win32-error=0/f ; :: enable-fullscreen ( triple hwnd -- rect ) diff --git a/extra/io/serial/unix/bsd/bsd.factor b/extra/io/serial/unix/bsd/bsd.factor index dbb013aca0..14d4f515ae 100644 --- a/extra/io/serial/unix/bsd/bsd.factor +++ b/extra/io/serial/unix/bsd/bsd.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax kernel math.bitwise sequences system io.serial ; +USING: alien.syntax kernel math.bitwise sequences system io.serial +literals ; IN: io.serial.unix M: bsd lookup-baud ( m -- n ) @@ -60,7 +61,7 @@ CONSTANT: HUPCL HEX: 00004000 CONSTANT: CLOCAL HEX: 00008000 CONSTANT: CCTS_OFLOW HEX: 00010000 CONSTANT: CRTS_IFLOW HEX: 00020000 -: CRTSCTS ( -- n ) { CCTS_OFLOW CRTS_IFLOW } flags ; inline +CONSTANT: CRTSCTS flags{ CCTS_OFLOW CRTS_IFLOW } CONSTANT: CDTR_IFLOW HEX: 00040000 CONSTANT: CDSR_OFLOW HEX: 00080000 CONSTANT: CCAR_OFLOW HEX: 00100000 diff --git a/extra/io/serial/unix/unix-tests.factor b/extra/io/serial/unix/unix-tests.factor index f4c0c6b45a..422844ab82 100644 --- a/extra/io/serial/unix/unix-tests.factor +++ b/extra/io/serial/unix/unix-tests.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel math.bitwise io.serial io.serial.unix ; +USING: accessors kernel math.bitwise io.serial io.serial.unix +literals ; IN: io.serial.unix : serial-obj ( -- obj ) @@ -10,10 +11,10 @@ IN: io.serial.unix ! "/dev/ttyd0" >>path ! freebsd ! "/dev/ttyU0" >>path ! openbsd 19200 >>baud - { IGNPAR ICRNL } flags >>iflag - { } flags >>oflag - { CS8 CLOCAL CREAD } flags >>cflag - { ICANON } flags >>lflag ; + flags{ IGNPAR ICRNL } >>iflag + flags{ } >>oflag + flags{ CS8 CLOCAL CREAD } >>cflag + flags{ ICANON } >>lflag ; : serial-test ( -- serial ) serial-obj diff --git a/extra/io/serial/unix/unix.factor b/extra/io/serial/unix/unix.factor index 6c0de55ec8..fc613da423 100644 --- a/extra/io/serial/unix/unix.factor +++ b/extra/io/serial/unix/unix.factor @@ -3,7 +3,8 @@ USING: accessors alien.c-types alien.syntax alien.data classes.struct combinators io.ports io.streams.duplex system kernel math math.bitwise vocabs.loader io.serial -io.serial.unix.termios io.backend.unix unix unix.ffi ; +io.serial.unix.termios io.backend.unix unix unix.ffi +literals ; IN: io.serial.unix << { @@ -33,7 +34,7 @@ FUNCTION: int cfsetspeed ( termios* t, speed_t s ) ; M: unix open-serial ( serial -- serial' ) dup - path>> { O_RDWR O_NOCTTY O_NDELAY } flags file-mode open-file + path>> flags{ O_RDWR O_NOCTTY O_NDELAY } file-mode open-file fd>duplex-stream >>stream ; : serial-fd ( serial -- fd ) diff --git a/extra/model-viewer/model-viewer.factor b/extra/model-viewer/model-viewer.factor index 061ce07d1e..f1b184f220 100644 --- a/extra/model-viewer/model-viewer.factor +++ b/extra/model-viewer/model-viewer.factor @@ -11,7 +11,7 @@ ui.gadgets.worlds ui.pixel-formats specialized-arrays specialized-vectors literals fry sequences.deep destructors math.bitwise opengl.gl game.models game.models.obj game.models.loader game.models.collada -prettyprint images.tga ; +prettyprint images.tga literals ; FROM: alien.c-types => float ; SPECIALIZED-ARRAY: float SPECIALIZED-VECTOR: uint @@ -164,9 +164,9 @@ TUPLE: vbo 0 0 0 0 glClearColor 1 glClearDepth HEX: ffffffff glClearStencil - { GL_COLOR_BUFFER_BIT + flags{ GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT - GL_STENCIL_BUFFER_BIT } flags glClear ; + GL_STENCIL_BUFFER_BIT } glClear ; : draw-model ( world -- ) clear-screen diff --git a/extra/webkit-demo/webkit-demo.factor b/extra/webkit-demo/webkit-demo.factor index e6178a55c3..eb24d035dc 100644 --- a/extra/webkit-demo/webkit-demo.factor +++ b/extra/webkit-demo/webkit-demo.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: cocoa cocoa.application cocoa.types cocoa.classes cocoa.windows -core-graphics.types kernel math.bitwise ; +core-graphics.types kernel math.bitwise literals ; IN: webkit-demo FRAMEWORK: /System/Library/Frameworks/WebKit.framework @@ -13,13 +13,13 @@ IMPORT: WebView WebView -> alloc rect f f -> initWithFrame:frameName:groupName: ; -: window-style ( -- n ) - { +CONSTANT: window-style ( -- n ) + flags{ NSClosableWindowMask NSMiniaturizableWindowMask NSResizableWindowMask NSTitledWindowMask - } flags ; + } : ( -- id ) rect window-style ; -- 2.34.1