diff --git a/basis/alien/c-types/c-types-tests.factor b/basis/alien/c-types/c-types-tests.factor index f57d102452..31542b2699 100644 --- a/basis/alien/c-types/c-types-tests.factor +++ b/basis/alien/c-types/c-types-tests.factor @@ -8,7 +8,7 @@ sequences system libc alien.strings io.encodings.utf8 ; [ { "blah" 123 } ] [ { "blah" xyz } expand-constants ] unit-test -: foo ( -- n ) "fdafd" f dlsym [ 123 ] unless* ; +: foo ( -- n ) &: fdafd [ 123 ] unless* ; [ 123 ] [ foo ] unit-test diff --git a/basis/alien/syntax/syntax-docs.factor b/basis/alien/syntax/syntax-docs.factor index 586bb97402..a3215cd8c6 100644 --- a/basis/alien/syntax/syntax-docs.factor +++ b/basis/alien/syntax/syntax-docs.factor @@ -77,6 +77,11 @@ HELP: C-ENUM: { $code "C-ENUM: red green blue ;" ": red 0 ; : green 1 ; : blue 2 ;" } } ; +HELP: &: +{ $syntax "&: symbol" } +{ $values { "symbol" "A C library symbol name" } } +{ $description "Pushes the address of a symbol named " { $snippet "symbol" } " from the current library, set with " { $link POSTPONE: LIBRARY: } "." } ; + HELP: typedef { $values { "old" "a string" } { "new" "a string" } } { $description "Alises the C type " { $snippet "old" } " under the name " { $snippet "new" } "." } diff --git a/basis/alien/syntax/syntax.factor b/basis/alien/syntax/syntax.factor index b0ba10a316..15d82884f9 100644 --- a/basis/alien/syntax/syntax.factor +++ b/basis/alien/syntax/syntax.factor @@ -3,7 +3,8 @@ USING: accessors arrays alien alien.c-types alien.structs alien.arrays alien.strings kernel math namespaces parser sequences words quotations math.parser splitting grouping -effects assocs combinators lexer strings.parser alien.parser ; +effects assocs combinators lexer strings.parser alien.parser +fry ; IN: alien.syntax : DLL" lexer get skip-blank parse-string dlopen parsed ; parsing @@ -33,3 +34,7 @@ IN: alien.syntax dup length [ [ create-in ] dip 1quotation define ] 2each ; parsing + +: &: + scan "c-library" get + '[ _ _ load-library dlsym ] over push-all ; parsing diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 230a7bf542..1b21e40bac 100644 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -83,14 +83,14 @@ FUNCTION: tiny ffi_test_17 int x ; { 1 1 } [ indirect-test-1 ] must-infer-as -[ 3 ] [ "ffi_test_1" f dlsym indirect-test-1 ] unit-test +[ 3 ] [ &: ffi_test_1 indirect-test-1 ] unit-test : indirect-test-1' ( ptr -- ) "int" { } "cdecl" alien-indirect drop ; { 1 0 } [ indirect-test-1' ] must-infer-as -[ ] [ "ffi_test_1" f dlsym indirect-test-1' ] unit-test +[ ] [ &: ffi_test_1 indirect-test-1' ] unit-test [ -1 indirect-test-1 ] must-fail @@ -100,7 +100,7 @@ FUNCTION: tiny ffi_test_17 int x ; { 3 1 } [ indirect-test-2 ] must-infer-as [ 5 ] -[ 2 3 "ffi_test_2" f dlsym indirect-test-2 ] +[ 2 3 &: ffi_test_2 indirect-test-2 ] unit-test : indirect-test-3 ( a b c d ptr -- result ) diff --git a/basis/core-foundation/fsevents/fsevents.factor b/basis/core-foundation/fsevents/fsevents.factor index d4d5e88512..b3c1444043 100644 --- a/basis/core-foundation/fsevents/fsevents.factor +++ b/basis/core-foundation/fsevents/fsevents.factor @@ -118,7 +118,7 @@ FUNCTION: CFStringRef FSEventStreamCopyDescription ( FSEventStreamRef streamRef FSEventStreamCreate ; : kCFRunLoopCommonModes ( -- string ) - "kCFRunLoopCommonModes" f dlsym *void* ; + &: kCFRunLoopCommonModes *void* ; : schedule-event-stream ( event-stream -- ) CFRunLoopGetMain diff --git a/basis/environment/unix/unix.factor b/basis/environment/unix/unix.factor index c2dddc25ab..7da19ee47b 100644 --- a/basis/environment/unix/unix.factor +++ b/basis/environment/unix/unix.factor @@ -2,12 +2,13 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.strings alien.syntax kernel layouts sequences system unix environment io.encodings.utf8 -unix.utilities vocabs.loader combinators alien.accessors ; +unix.utilities vocabs.loader combinators alien.accessors +alien.syntax ; IN: environment.unix HOOK: environ os ( -- void* ) -M: unix environ ( -- void* ) "environ" f dlsym ; +M: unix environ ( -- void* ) &: environ ; M: unix os-env ( key -- value ) getenv ; diff --git a/basis/io/unix/backend/backend.factor b/basis/io/unix/backend/backend.factor index 7f4e03ef09..954a0a61de 100644 --- a/basis/io/unix/backend/backend.factor +++ b/basis/io/unix/backend/backend.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien alien.c-types generic assocs kernel kernel.private -math io.ports sequences strings sbufs threads unix -vectors io.buffers io.backend io.encodings math.parser +USING: alien alien.c-types alien.syntax generic assocs kernel +kernel.private math io.ports sequences strings sbufs threads +unix vectors io.buffers io.backend io.encodings math.parser continuations system libc qualified namespaces make io.timeouts io.encodings.utf8 destructors accessors summary combinators locals unix.time fry ; @@ -184,11 +184,11 @@ M: stdin dispose* M: stdin refill [ buffer>> ] [ dup wait-for-stdin ] bi* refill-stdin f ; -: control-write-fd ( -- fd ) "control_write" f dlsym *uint ; +: control-write-fd ( -- fd ) &: control_write *uint ; -: size-read-fd ( -- fd ) "size_read" f dlsym *uint ; +: size-read-fd ( -- fd ) &: size_read *uint ; -: data-read-fd ( -- fd ) "stdin_read" f dlsym *uint ; +: data-read-fd ( -- fd ) &: stdin_read *uint ; : ( -- stdin ) stdin new diff --git a/basis/tools/disassembler/udis/udis.factor b/basis/tools/disassembler/udis/udis.factor index 113c07c8c3..c5b5c80d13 100644 --- a/basis/tools/disassembler/udis/udis.factor +++ b/basis/tools/disassembler/udis/udis.factor @@ -5,8 +5,6 @@ alien alien.syntax alien.c-types lexer parser kernel sequences layouts math math.parser system make fry arrays ; IN: tools.disassembler.udis -<< : & scan "c-library" get load-library dlsym parsed ; parsing >> - << "libudis86" { { [ os macosx? ] [ "libudis86.0.dylib" ] } @@ -22,8 +20,8 @@ TYPEDEF: char[592] ud FUNCTION: void ud_translate_intel ( ud* u ) ; FUNCTION: void ud_translate_att ( ud* u ) ; -: UD_SYN_INTEL & ud_translate_intel ; inline -: UD_SYN_ATT & ud_translate_att ; inline +: UD_SYN_INTEL &: ud_translate_intel ; inline +: UD_SYN_ATT &: ud_translate_att ; inline : UD_EOI -1 ; inline : UD_INP_CACHE_SZ 32 ; inline : UD_VENDOR_AMD 0 ; inline