]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/libraries/libraries.factor
Remove cruddy string encoding/decoding code from VM
[factor.git] / basis / alien / libraries / libraries.factor
1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien alien.strings assocs io.backend kernel namespaces ;
4 IN: alien.libraries
5
6 : dlopen ( path -- dll ) native-string>alien (dlopen) ;
7
8 : dlsym ( name dll -- alien ) [ native-string>alien ] dip (dlsym) ;
9
10 SYMBOL: libraries
11
12 libraries [ H{ } clone ] initialize
13
14 TUPLE: library path abi dll ;
15
16 : library ( name -- library ) libraries get at ;
17
18 : <library> ( path abi -- library )
19     over dup [ dlopen ] when \ library boa ;
20
21 : load-library ( name -- dll )
22     library dup [ dll>> ] when ;
23
24 : add-library ( name path abi -- )
25     <library> swap libraries get set-at ;