[Vm-dev] help on creating plugin
siguctua at gmail.com
Sat Sep 13 21:23:44 UTC 2008
2008/9/14 Esteban Lorenzano <estebanlm at gmail.com>:
> I need some help/advice for a plugin I'm writing.
> I'm already downloaded VMMaker and managed to compile a new VM in OS/X, and
> I already write and compile and test a simple plugin (and I have to say the
> process is very simple, and all my problems were because I never used Xcode
> before), but now, with the plugin running, comes the "optimization" phase,
> and there I have many doubts:
> 1) An external plugin blocks the VM when primitive is called? if so, how do
> I manage to avoid this?
No way. Primitive implements the behavior of your method. You can't
run interpreter before it will return.
Of course you can use pthreads: create own native thread and pass all
you need to this thread using own synchronization scheme. Then you can
avoid blocking. But this comes handy if your task is parallelisable.
Some are simply can't be parallelised.
> 2) what is the right way to use strings? now, I'm obtaining them as
> parameters, but the string comes without final zero, so C does not works
> fine... because of that, I'm copying them into a new variable (memory
> allocated with malloc and freed after use), but it does not seems to be very
> performant... is there a better way?
you have to copy string into buffer and terminate it with 0 character.
> 3) in general, what is the best way to return Strings into Squeak? I have to
> create an instance with interpreterProxy>>instantiateClass: each time?
> Well, I have many doubts about how to optimize my code... where can I look
> to see some example code?
you can look at plugins code, which you already having in VM.
Igor Stasenko AKA sig.
More information about the Vm-dev