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 ;
|
|
|
|
|
2006-03-26 19:47:51 -05:00
|
|
|
: <alien> ( address -- alien ) f <displaced-alien> ; inline
|
2005-07-17 14:48:55 -04:00
|
|
|
|
2006-02-19 20:53:18 -05:00
|
|
|
UNION: c-ptr byte-array alien ;
|
2005-04-09 18:30:46 -04:00
|
|
|
|
2006-08-07 15:41:31 -04:00
|
|
|
M: alien equal? ( obj obj -- ? )
|
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 [
|
2005-08-22 02:06:32 -04:00
|
|
|
[ "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* ;
|