factor/library/compiler/alien/aliens.factor

42 lines
972 B
Factor
Raw Normal View History

2006-02-11 02:30:18 -05:00
! Copyright (C) 2004, 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
2005-04-09 18:30:46 -04:00
IN: alien
2006-05-15 01:01:47 -04:00
USING: arrays hashtables io kernel math namespaces parser
2006-02-11 02:30:18 -05:00
sequences ;
: <alien> ( address -- alien ) f <displaced-alien> ; inline
UNION: c-ptr byte-array alien ;
2005-04-09 18:30:46 -04:00
M: alien equal?
2006-03-17 03:21:09 -05:00
over alien? [
2dup [ expired? ] 2apply 2dup or [
2swap 2drop
] [
2drop [ alien-address ] 2apply
] if =
] [
2drop f
] if ;
2006-02-11 02:30:18 -05:00
global [ "libraries" nest drop ] bind
2005-04-09 18:30:46 -04:00
2005-12-10 01:02:13 -05:00
: library ( name -- object ) "libraries" get hash ;
2005-04-09 18:30:46 -04:00
2005-05-05 03:12:37 -04:00
: load-library ( name -- dll )
2005-04-09 18:30:46 -04:00
library dup [
[
"dll" get dup [
drop "name" get dlopen dup "dll" set
] unless
] bind
] when ;
: add-library ( library name abi -- )
"libraries" get [
[ "abi" set "name" set ] make-hash swap set
2005-04-09 18:30:46 -04:00
] bind ;
: library-abi ( library -- abi )
2005-08-25 15:27:38 -04:00
library "abi" swap ?hash [ "cdecl" ] unless* ;