Hi!
I've trouble to create a named pluggable primitive DLL. I tried to figure
out what to do from the sources (mostly Andrew's pdf document and the
FlippyArray2 code) but nothing works. I don't know what goes wrong. I'm
using Windows 98.
Here's my code. I use VC++ 5 to compile a DLL (non-MFC DLL project) which
seems to work.
----------TestPlugin.c----------
#include "sqVirtualMachine.h"
#define EXPORT __declspec(dllexport)
static struct VirtualMachine *VM;
EXPORT
char *getModuleName(void) {
return "TestPlugin 24 Juni 2000";
}
EXPORT
int setInterpreter(struct VirtualMachine *interpreterProxy) {
VM = interpreterProxy;
return 1;
}
EXPORT
void test(void) {
int test = VM->stackIntegerValue(0);
VM->popthenPush(1, VM->integerObjectOf(-test));
}
----------End TestPlugin.c----------
I use Squeak 2.8 (the version Andreas provided, I've no VM source and
didn'T rebuilt that VM) and the following method to test my primitive
test: anInteger
"TestPlugin new test: 42"
<primitive: 'test' module: 'TestPlugin'>
^ nil
and always get "nil", not "-42" as answer. When I use the FFI to call each
function, it works. The first function answers the string, the second 1
and I can also call "test". I added a
MessageBox(NULL, "test", "TestPlugin", MB_OK);
to get some feedback. It seems that while getModuleName is correctly
called, it doesn't find the other functions.
What goes wrong? Where can I find better/more recent
documentation? Please help!
PS: Is there a method to unload a DLL? Now I've always have to restart
Squeak if I what to replace my DLL.
bye
--
Stefan Matthias Aust // Bevor wir fallen, fallen wir lieber auf