DynamicLibrary for unix

Brian Rice water at tunes.org
Wed Oct 27 10:23:11 PDT 2004


Excellent! I'll start going over the code for incorporation purposes. 
It should also be interesting if we can use the pidgin tools to 
generate C code for us as well.

On Oct 27, 2004, at 9:59 AM, Tony Garnock-Jones wrote:

> Hi all.
>
> Attached is a patch implementing a DynamicLibrary object which allows 
> the use of .so files containing primitives, which are loaded into the 
> VM at runtime. It's quite basic, but so far code like this works:
>
> [| d h |
>
>   d: (DynamicLibrary newNamed: 'testplugin').
>   h: (d lookup: 'addSmallInts').
>   (h applyWith: 3 with: 4) printOn: Console writer.
>   Console ; '\n'.
> ] do.
>
>
> when run against a plugin like this one:
>
> /* libtool --mode=compile gcc -o testplugin.lo -c testplugin.c */
> /* libtool --mode=link gcc -module -o testplugin.la testplugin.lo
>      -rpath `pwd` */
> #include "slatevm.h"
>
> ObjectPointer addSmallInts(ObjectPointer *argv, unsigned long int 
> argc) {
>   signed long int a = ObjectPointer_asSmallInt(argv[0]);
>   signed long int b = ObjectPointer_asSmallInt(argv[1]);
>   return signedLongInt_asObject(a + b);
> }
>
>
> So far I've tried it on Debian Linux on x86 and Macos X on PPC. 
> Porting to Windows ought to be trivial: instead of 
> dlopen/dlsym/dlclose from dlfcn.h, use 
> LoadLibrary/GetProcAddress/FreeLibrary from windows.h. Of course, I've 
> no idea what to use instead of libtool on Windows :-)
>
> Regards,
>   Tony
> <dynlib-patch.tar.gz>
--
Brian T. Rice
LOGOS Research and Development
http://tunes.org/~water/




More information about the Slate mailing list