On 21-Nov-2008, at 11:50 AM, Igor Stasenko wrote:
I was pretty unhappy with some places in VM, where it loads a function from plugin by calling ioLoadFunction... Also, even more painful to see when one plugin wants to call another plugin function.
I know very little about the VM, but I agree what you describe is ugly and inelegant, even at a very generic level.
Now, plugins first, should declare the atoms they would want to use or provide. This can be done once at plugin initialization stage, for instance:
static sqInt bitBlitAtom = makeAtom('ioBitBlt');
Now, after acquiring atom, plugin can register a service fn under this atom:
registerService(bitBlitAtom, (void*) bitBlt); and upon unloading unregisterService(bitBlitAtom);
now, any other plugin can do:
bitBltFn = getService(bitBlitAtom);
Everything looked good until I got here.
How is another plugin supposed to access this 'bitBlitAtom' handle that is effectively always in the first plugin's private storage and literally (as you've declared it above) also in the other plugin module's private symbol namespace? (i.e. if it's compiled as a "static" variable in the first plugin module then there's no way the second plugin can use the same symbol to refer to the same storage)
Perhaps you meant to add a getAtom() function to your API? Then the second plugin would first do:
static sqInt theAtom;
theAtom = getAtom("ioBitBlt");
And then it could do the call above as:
if (theAtom != 0) bitBltFn = getService(theAtom);
if (bitBltFn) { bitBltFn( a, b,c blabla); }